From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id B161E5A8B for ; Wed, 10 Jun 2015 07:54:50 +0200 (CEST) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga102.fm.intel.com with ESMTP; 09 Jun 2015 22:54:49 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.13,586,1427785200"; d="scan'208";a="724383611" Received: from pgsmsx108.gar.corp.intel.com ([10.221.44.103]) by fmsmga001.fm.intel.com with ESMTP; 09 Jun 2015 22:54:48 -0700 Received: from shsmsx103.ccr.corp.intel.com (10.239.4.69) by PGSMSX108.gar.corp.intel.com (10.221.44.103) with Microsoft SMTP Server (TLS) id 14.3.224.2; Wed, 10 Jun 2015 13:52:53 +0800 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.165]) by SHSMSX103.ccr.corp.intel.com ([169.254.4.46]) with mapi id 14.03.0224.002; Wed, 10 Jun 2015 13:52:52 +0800 From: "He, Shaopeng" To: "Qiu, Michael" , "dev@dpdk.org" Thread-Topic: [PATCH 1/3] fm10k: update VLAN filter Thread-Index: AQHQnOAmjaC4n5aiDUqmrEzvRgXnP52lSQIA Date: Wed, 10 Jun 2015 05:52:51 +0000 Message-ID: References: <1433213937-21690-1-git-send-email-shaopeng.he@intel.com> <1433213937-21690-2-git-send-email-shaopeng.he@intel.com> <533710CFB86FA344BFBF2D6802E60286046959E4@SHSMSX101.ccr.corp.intel.com> In-Reply-To: <533710CFB86FA344BFBF2D6802E60286046959E4@SHSMSX101.ccr.corp.intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH 1/3] fm10k: update VLAN filter X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 10 Jun 2015 05:54:51 -0000 > -----Original Message----- > From: Qiu, Michael > Sent: Tuesday, June 09, 2015 11:52 PM > To: He, Shaopeng; dev@dpdk.org > Cc: Chen, Jing D > Subject: Re: [PATCH 1/3] fm10k: update VLAN filter >=20 > On 2015/6/2 10:59, He, Shaopeng wrote: > > 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 > > --- > > 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 =3D 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 =3D 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 =3D dev->data; > > > > - PMD_INIT_FUNC_TRACE(); > > + hw =3D FM10K_DEV_PRIVATE_TO_HW(dev->data->dev_private); > > + macvlan =3D FM10K_DEV_PRIVATE_TO_MACVLAN(dev->data- > >dev_private); > > > > /* @todo - add support for the VF */ > > if (hw->mac.type !=3D 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 =3D FM10K_VFTA_IDX(vlan_id); > > + vid_bit =3D 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 =3D fm10k_update_vlan(hw, vlan_id, 0, on); >=20 > Would it make sense about release the lock here? So that to make sure we > do not hold this lock for a long time. Agree, make sense, thanks for the suggestion!