From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Wu, Jingjing" Subject: Re: [PATCH v7 04/27] net/i40e: set VF VLAN anti-spoofing from PF Date: Thu, 5 Jan 2017 08:52:29 +0000 Message-ID: <9BB6961774997848B5B42BEC655768F810CC36FA@SHSMSX103.ccr.corp.intel.com> References: <1480637533-37425-1-git-send-email-wenzhuo.lu@intel.com> <1483426488-117332-1-git-send-email-wenzhuo.lu@intel.com> <1483426488-117332-5-git-send-email-wenzhuo.lu@intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Cc: "Lu, Wenzhuo" To: "Lu, Wenzhuo" , "dev@dpdk.org" Return-path: Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by dpdk.org (Postfix) with ESMTP id 38CFAF614 for ; Thu, 5 Jan 2017 09:52:34 +0100 (CET) In-Reply-To: <1483426488-117332-5-git-send-email-wenzhuo.lu@intel.com> Content-Language: en-US List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" > -----Original Message----- > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Wenzhuo Lu > Sent: Tuesday, January 3, 2017 2:54 PM > To: dev@dpdk.org > Cc: Lu, Wenzhuo > Subject: [dpdk-dev] [PATCH v7 04/27] net/i40e: set VF VLAN anti-spoofing = from > PF >=20 > Support enabling/disabling VF VLAN anti-spoofing from PF. > User can call the API on PF to enable/disable a specific VF's VLAN anti-s= poofing. >=20 > Signed-off-by: Wenzhuo Lu > --- > drivers/net/i40e/i40e_ethdev.c | 116 > +++++++++++++++++++++++++++++- > drivers/net/i40e/i40e_ethdev.h | 1 + > drivers/net/i40e/rte_pmd_i40e.h | 19 +++++ > drivers/net/i40e/rte_pmd_i40e_version.map | 1 + > 4 files changed, 135 insertions(+), 2 deletions(-) >=20 > diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethde= v.c > index 68c07de..bcc59b2 100644 > --- a/drivers/net/i40e/i40e_ethdev.c > +++ b/drivers/net/i40e/i40e_ethdev.c > @@ -4418,6 +4418,7 @@ struct i40e_vsi * > vsi->max_macaddrs =3D I40E_NUM_MACADDR_MAX; > vsi->parent_vsi =3D uplink_vsi ? uplink_vsi : pf->main_vsi; > vsi->user_param =3D user_param; > + vsi->vlan_anti_spoof_on =3D 0; > /* Allocate queues */ > switch (vsi->type) { > case I40E_VSI_MAIN : > @@ -5761,17 +5762,35 @@ struct i40e_vsi * > uint16_t vlan_id, bool on) > { > uint32_t vid_idx, vid_bit; > + struct i40e_hw *hw =3D I40E_VSI_TO_HW(vsi); > + struct i40e_aqc_add_remove_vlan_element_data vlan_data =3D {0}; > + int ret; >=20 > if (vlan_id > ETH_VLAN_ID_MAX) > return; >=20 > vid_idx =3D I40E_VFTA_IDX(vlan_id); > vid_bit =3D I40E_VFTA_BIT(vlan_id); > + vlan_data.vlan_tag =3D rte_cpu_to_le_16(vlan_id); >=20 > - if (on) > + if (on) { > + if (vsi->vlan_anti_spoof_on) { > + ret =3D i40e_aq_add_vlan(hw, vsi->seid, > + &vlan_data, 1, NULL); > + if (ret !=3D I40E_SUCCESS) > + PMD_DRV_LOG(ERR, "Failed to add vlan filter"); > + } > vsi->vfta[vid_idx] |=3D vid_bit; > - else > + } else { > + if (vsi->vlan_anti_spoof_on) { > + ret =3D i40e_aq_remove_vlan(hw, vsi->seid, > + &vlan_data, 1, NULL); > + if (ret !=3D I40E_SUCCESS) > + PMD_DRV_LOG(ERR, > + "Failed to remove vlan filter"); > + } > vsi->vfta[vid_idx] &=3D ~vid_bit; > + } > } >=20 The function i40e_set_vlan_filter is used to store the vlan info in vsi structure. I think it will be better to move the hardware vlan filte= r handling to i40e_vsi_add_vlan who called the i40e_set_vlan_filter function to let th= e code more easy to maintain. Thanks Jingjing