From: "He, Shaopeng" <shaopeng.he@intel.com>
To: "Chen, Jing D" <jing.d.chen@intel.com>, "dev@dpdk.org" <dev@dpdk.org>
Subject: Re: [dpdk-dev] [PATCH 1/3] fm10k: update VLAN filter
Date: Tue, 9 Jun 2015 07:18:07 +0000 [thread overview]
Message-ID: <FB82FCC69332B84596FE0CEC3C1310949C4B15@shsmsx102.ccr.corp.intel.com> (raw)
In-Reply-To: <4341B239C0EFF9468EE453F9E9F4604D016FA25D@shsmsx102.ccr.corp.intel.com>
> -----Original Message-----
> From: Chen, Jing D
> Sent: Tuesday, June 09, 2015 10:54 AM
> To: He, Shaopeng; dev@dpdk.org
> Cc: Qiu, Michael
> Subject: RE: [PATCH 1/3] fm10k: update VLAN filter
>
> Hi,
>
> > -----Original Message-----
> > From: He, Shaopeng
> > Sent: Tuesday, June 02, 2015 10:59 AM
> > To: dev@dpdk.org
> > Cc: Chen, Jing D; Qiu, Michael; He, Shaopeng
> > Subject: [PATCH 1/3] fm10k: update VLAN filter
> >
> > VLAN filter was updated to add/delete one static entry in MAC table
> > for each combination of VLAN and MAC address. More sanity checks were
> added.
> >
> > Signed-off-by: Shaopeng He <shaopeng.he@intel.com>
> > ---
> > drivers/net/fm10k/fm10k.h | 23 +++++++++++++++++
> > drivers/net/fm10k/fm10k_ethdev.c | 55
> > +++++++++++++++++++++++++++++++++++++---
> > 2 files changed, 75 insertions(+), 3 deletions(-)
> >
> > diff --git a/drivers/net/fm10k/fm10k.h b/drivers/net/fm10k/fm10k.h
> > index ad7a7d1..3b95b72 100644
> > --- a/drivers/net/fm10k/fm10k.h
> > +++ b/drivers/net/fm10k/fm10k.h
> > @@ -109,11 +109,31 @@
> >
> > #define FM10K_VLAN_TAG_SIZE 4
> >
> > +/* Maximum number of MAC addresses per PF/VF */
> > +#define FM10K_MAX_MACADDR_NUM 1
> > +
> > +#define FM10K_UINT32_BIT_SIZE (CHAR_BIT * sizeof(uint32_t))
> > +#define FM10K_VFTA_SIZE (4096 / FM10K_UINT32_BIT_SIZE)
> > +
> > +/* vlan_id is a 12 bit number.
> > + * The VFTA array is actually a 4096 bit array, 128 of 32bit elements.
> > + * 2^5 = 32. The val of lower 5 bits specifies the bit in the 32bit element.
> > + * The higher 7 bit val specifies VFTA array index.
> > + */
> > +#define FM10K_VFTA_BIT(vlan_id) (1 << ((vlan_id) & 0x1F))
> > +#define FM10K_VFTA_IDX(vlan_id) ((vlan_id) >> 5)
> > +
> > +struct fm10k_macvlan_filter_info {
> > + uint16_t vlan_num; /* Total VLAN number */
> > + uint32_t vfta[FM10K_VFTA_SIZE]; /* VLAN bitmap */
> > +};
> > +
> > struct fm10k_dev_info {
> > volatile uint32_t enable;
> > volatile uint32_t glort;
> > /* Protect the mailbox to avoid race condition */
> > rte_spinlock_t mbx_lock;
> > + struct fm10k_macvlan_filter_info macvlan;
> > };
> >
> > /*
> > @@ -137,6 +157,9 @@ struct fm10k_adapter { #define
> > FM10K_DEV_PRIVATE_TO_MBXLOCK(adapter) \
> > (&(((struct fm10k_adapter *)adapter)->info.mbx_lock))
> >
> > +#define FM10K_DEV_PRIVATE_TO_MACVLAN(adapter) \
> > + (&(((struct fm10k_adapter *)adapter)->info.macvlan))
> > +
> > struct fm10k_rx_queue {
> > struct rte_mempool *mp;
> > struct rte_mbuf **sw_ring;
> > diff --git a/drivers/net/fm10k/fm10k_ethdev.c
> > b/drivers/net/fm10k/fm10k_ethdev.c
> > index 3a26480..d2f3e44 100644
> > --- a/drivers/net/fm10k/fm10k_ethdev.c
> > +++ b/drivers/net/fm10k/fm10k_ethdev.c
> > @@ -819,15 +819,61 @@ fm10k_dev_infos_get(struct rte_eth_dev *dev,
> > static int fm10k_vlan_filter_set(struct rte_eth_dev *dev, uint16_t
> > vlan_id, int on) {
> > - struct fm10k_hw *hw = FM10K_DEV_PRIVATE_TO_HW(dev->data-
> > >dev_private);
> > + s32 result;
> > + uint32_t vid_idx, vid_bit, mac_index;
> > + struct fm10k_hw *hw;
> > + struct fm10k_macvlan_filter_info *macvlan;
> > + struct rte_eth_dev_data *data = dev->data;
> >
> > - PMD_INIT_FUNC_TRACE();
> > + hw = FM10K_DEV_PRIVATE_TO_HW(dev->data->dev_private);
> > + macvlan = FM10K_DEV_PRIVATE_TO_MACVLAN(dev->data-
> > >dev_private);
> >
> > /* @todo - add support for the VF */
> > if (hw->mac.type != fm10k_mac_pf)
> > return -ENOTSUP;
> >
> > - return fm10k_update_vlan(hw, vlan_id, 0, on);
> > + if (vlan_id > ETH_VLAN_ID_MAX) {
> > + PMD_INIT_LOG(ERR, "Invalid vlan_id: must be < 4096");
> > + return (-EINVAL);
> > + }
> > +
> > + vid_idx = FM10K_VFTA_IDX(vlan_id);
> > + vid_bit = FM10K_VFTA_BIT(vlan_id);
> > + /* this VLAN ID is already in the VLAN filter table, return SUCCESS */
> > + if (on && (macvlan->vfta[vid_idx] & vid_bit))
> > + return 0;
> > + /* this VLAN ID is NOT in the VLAN filter table, cannot remove */
> > + if (!on && !(macvlan->vfta[vid_idx] & vid_bit)) {
> > + PMD_INIT_LOG(ERR, "Invalid vlan_id: not existing "
> > + "in the VLAN filter table");
> > + return (-EINVAL);
> > + }
> > +
> > + fm10k_mbx_lock(hw);
> > + result = fm10k_update_vlan(hw, vlan_id, 0, on);
> > + if (FM10K_SUCCESS == result) {
> > + if (on) {
> > + macvlan->vlan_num++;
> > + macvlan->vfta[vid_idx] |= vid_bit;
> > + } else {
> > + macvlan->vlan_num--;
> > + macvlan->vfta[vid_idx] &= ~vid_bit;
> > + }
> > +
> > + for (mac_index = 0; mac_index <
> > FM10K_MAX_MACADDR_NUM;
> > + mac_index++) {
> > + if (is_zero_ether_addr(&data-
> > >mac_addrs[mac_index]))
> > + continue;
> > + fm10k_update_uc_addr(hw, hw->mac.dglort_map,
> > + data->mac_addrs[mac_index].addr_bytes,
> > + vlan_id, on, 0);
>
>
> Result = fm10k_update_uc_addr()? If meeting any error, it should break.
> In the meanwhile, I think above if (on)...else... should be moved after the
> loop.
Agree, make sense, thanks for the comment.
next prev parent reply other threads:[~2015-06-09 7:18 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-02 2:58 [dpdk-dev] [PATCH 0/3] fm10k: update MAC/VLAN filter and VLAN offload features Shaopeng He
2015-06-02 2:58 ` [dpdk-dev] [PATCH 1/3] fm10k: update VLAN filter Shaopeng He
2015-06-09 2:54 ` Chen, Jing D
2015-06-09 7:18 ` He, Shaopeng [this message]
2015-06-09 15:51 ` Qiu, Michael
2015-06-10 5:52 ` He, Shaopeng
2015-06-02 2:58 ` [dpdk-dev] [PATCH 2/3] fm10k: add MAC filter Shaopeng He
2015-06-09 3:25 ` Chen, Jing D
2015-06-09 8:31 ` He, Shaopeng
2015-06-09 15:59 ` Qiu, Michael
2015-06-10 1:03 ` He, Shaopeng
2015-06-02 2:58 ` [dpdk-dev] [PATCH 3/3] fm10k: update VLAN offload features Shaopeng He
2015-06-09 3:27 ` Chen, Jing D
2015-06-09 8:55 ` He, Shaopeng
2015-06-09 15:40 ` Qiu, Michael
2015-06-10 6:03 ` He, Shaopeng
2015-06-15 1:23 ` [dpdk-dev] [PATCH v2 0/3] fm10k: update MAC/VLAN filter and " Shaopeng He
2015-06-15 1:23 ` [dpdk-dev] [PATCH v2 1/3] fm10k: update VLAN filter Shaopeng He
2015-06-15 1:23 ` [dpdk-dev] [PATCH v2 2/3] fm10k: add MAC filter Shaopeng He
2015-06-16 12:38 ` Qiu, Michael
2015-06-15 1:23 ` [dpdk-dev] [PATCH v2 3/3] fm10k: update VLAN offload features Shaopeng He
2015-06-18 7:21 ` [dpdk-dev] [PATCH v3 0/3] fm10k: update MAC/VLAN filter and " Shaopeng He
2015-06-18 7:21 ` [dpdk-dev] [PATCH v3 1/3] fm10k: update VLAN filter Shaopeng He
2015-06-18 7:21 ` [dpdk-dev] [PATCH v3 2/3] fm10k: add MAC filter Shaopeng He
2015-06-18 7:21 ` [dpdk-dev] [PATCH v3 3/3] fm10k: update VLAN offload features Shaopeng He
2015-06-18 8:23 ` [dpdk-dev] [PATCH v3 0/3] fm10k: update MAC/VLAN filter and " Chen, Jing D
2015-06-22 14:21 ` Thomas Monjalon
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=FB82FCC69332B84596FE0CEC3C1310949C4B15@shsmsx102.ccr.corp.intel.com \
--to=shaopeng.he@intel.com \
--cc=dev@dpdk.org \
--cc=jing.d.chen@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).