From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by dpdk.org (Postfix) with ESMTP id 9036E93C0 for ; Wed, 3 Feb 2016 02:15:43 +0100 (CET) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga101.fm.intel.com with ESMTP; 02 Feb 2016 17:15:42 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.22,387,1449561600"; d="scan'208";a="907261631" Received: from fmsmsx103.amr.corp.intel.com ([10.18.124.201]) by fmsmga002.fm.intel.com with ESMTP; 02 Feb 2016 17:15:43 -0800 Received: from fmsmsx116.amr.corp.intel.com (10.18.116.20) by FMSMSX103.amr.corp.intel.com (10.18.124.201) with Microsoft SMTP Server (TLS) id 14.3.248.2; Tue, 2 Feb 2016 17:15:42 -0800 Received: from shsmsx103.ccr.corp.intel.com (10.239.110.14) by fmsmsx116.amr.corp.intel.com (10.18.116.20) with Microsoft SMTP Server (TLS) id 14.3.248.2; Tue, 2 Feb 2016 17:15:42 -0800 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.117]) by SHSMSX103.ccr.corp.intel.com ([169.254.4.218]) with mapi id 14.03.0248.002; Wed, 3 Feb 2016 09:15:40 +0800 From: "Zhang, Helin" To: Julien Meunier Thread-Topic: [PATCH v2] i40e: fix vlan filtering Thread-Index: AQHRXcDTA4wCNY+Dy0qUndBHk67dq58ZhQRQ Date: Wed, 3 Feb 2016 01:15:39 +0000 Message-ID: References: <1453137515-19195-1-git-send-email-julien.meunier@6wind.com> <1454421057-6602-1-git-send-email-julien.meunier@6wind.com> In-Reply-To: <1454421057-6602-1-git-send-email-julien.meunier@6wind.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ctpclassification: CTP_IC x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiOWFmMzZmY2QtNDAwMC00ZWJhLWE4NmItNzFkNDQ4NjA1ZjdkIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX0lDIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE1LjQuMTAuMTkiLCJUcnVzdGVkTGFiZWxIYXNoIjoibklNZTZrS0dOUmk2UTQ3c1Z4SElneUJJNDFFbGVKdWRFdEpJTEpDa1BVRT0ifQ== x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Cc: "dev@dpdk.org" Subject: Re: [dpdk-dev] [PATCH v2] i40e: fix vlan filtering 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, 03 Feb 2016 01:15:44 -0000 > -----Original Message----- > From: Julien Meunier [mailto:julien.meunier@6wind.com] > Sent: Tuesday, February 2, 2016 9:51 PM > To: Zhang, Helin > Cc: dev@dpdk.org > Subject: [PATCH v2] i40e: fix vlan filtering >=20 > VLAN filtering was always performed, even if hw_vlan_filter was disabled. > During device initialization, default filter RTE_MACVLAN_PERFECT_MATCH > was applied. In this situation, all incoming VLAN frames were dropped by = the > card (increase of the register RUPP - Rx Unsupported Protocol). >=20 > In order to restore default behavior, if HW VLAN filtering is activated, = set a > filter to match MAC and VLAN. If not, set a filter to only match MAC. >=20 > Signed-off-by: Julien Meunier > --- > Changes since v1: > - use ether_addr_copy() for mac copy > - add more debug messages in case of failure > - update all existing filters when multiple mac addresses have been confi= gured > - when adding new mac address, use correct filter >=20 > TODO: > - i40e_update_default_filter_setting always forces to > RTE_MACVLAN_PERFECT_MATCH. > =3D> The type of filter should be changed according to vlan filter sett= ing. >=20 > - What happens if vlan filter setting changes when various filters are al= ready > set like RTE_MACVLAN_PERFECT_MATCH, > RTE_MACVLAN_PERFECT_MATCH, > RTE_MAC_HASH_MATCH, RTE_MACVLAN_HASH_MATCH ? > =3D> With testpmd, it is possible to add manually these filters. But wh= en > changing vlan filter setting, all previous filter set manually are over= riden. > --- > drivers/net/i40e/i40e_ethdev.c | 73 > ++++++++++++++++++++++++++++++++++++++++-- > drivers/net/i40e/i40e_ethdev.h | 1 + > 2 files changed, 72 insertions(+), 2 deletions(-) >=20 > diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethde= v.c > index bf6220d..64d6ada 100644 > --- a/drivers/net/i40e/i40e_ethdev.c > +++ b/drivers/net/i40e/i40e_ethdev.c > @@ -2332,6 +2332,13 @@ i40e_vlan_offload_set(struct rte_eth_dev *dev, int > mask) > struct i40e_pf *pf =3D I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private); > struct i40e_vsi *vsi =3D pf->main_vsi; >=20 > + if (mask & ETH_VLAN_FILTER_MASK) { > + if (dev->data->dev_conf.rxmode.hw_vlan_filter) > + i40e_vsi_config_vlan_filter(vsi, TRUE); > + else > + i40e_vsi_config_vlan_filter(vsi, FALSE); > + } > + > if (mask & ETH_VLAN_STRIP_MASK) { > /* Enable or disable VLAN stripping */ > if (dev->data->dev_conf.rxmode.hw_vlan_strip) > @@ -2583,7 +2590,10 @@ i40e_macaddr_add(struct rte_eth_dev *dev, > } >=20 > (void)rte_memcpy(&mac_filter.mac_addr, mac_addr, ETHER_ADDR_LEN); > - mac_filter.filter_type =3D RTE_MACVLAN_PERFECT_MATCH; > + if (dev->data->dev_conf.rxmode.hw_vlan_filter) > + mac_filter.filter_type =3D RTE_MACVLAN_PERFECT_MATCH; > + else > + mac_filter.filter_type =3D RTE_MAC_PERFECT_MATCH; >=20 > if (pool =3D=3D 0) > vsi =3D pf->main_vsi; > @@ -4156,6 +4166,63 @@ fail_mem: > return NULL; > } >=20 > +/* Configure vlan filter on or off */ > +int > +i40e_vsi_config_vlan_filter(struct i40e_vsi *vsi, bool on) { > + int i, num; > + struct i40e_mac_filter *f; > + struct i40e_mac_filter_info *mac_filter; > + enum rte_mac_filter_type desired_filter; > + int ret =3D I40E_SUCCESS; > + > + if (on) { > + /* Filter to match MAC and VLAN */ > + desired_filter =3D RTE_MACVLAN_PERFECT_MATCH; > + } else { > + /* Filter to match only MAC */ > + desired_filter =3D RTE_MAC_PERFECT_MATCH; > + } > + > + num =3D vsi->mac_num; > + > + mac_filter =3D rte_zmalloc("mac_filter_info_data", > + num * sizeof(*mac_filter), 0); > + if (mac_filter =3D=3D NULL) { > + PMD_DRV_LOG(ERR, "failed to allocate memory"); > + return I40E_ERR_NO_MEMORY; > + } > + > + i =3D 0; > + > + /* Remove all existing mac */ > + TAILQ_FOREACH(f, &vsi->mac_list, next) { > + mac_filter[i] =3D f->mac_info; > + ret =3D i40e_vsi_delete_mac(vsi, &f->mac_info.mac_addr); > + if (ret) { > + PMD_DRV_LOG(INFO, "Update VSI failed to %s vlan filter", INFO should he changed to ERR? > + on ? "enable" : "disable"); > + goto DONE; > + } > + i++; > + } > + > + /* Override with new filter */ > + for (i =3D 0; i < num; i++) { > + mac_filter[i].filter_type =3D desired_filter; > + ret =3D i40e_vsi_add_mac(vsi, &mac_filter[i]); > + if (ret) { > + PMD_DRV_LOG(INFO, "Update VSI failed to %s vlan filter", INFO should he changed to ERR? All others looks good to me. Thanks! Helin > + on ? "enable" : "disable"); > + goto DONE; > + } > + } > + > +DONE: > + rte_free(mac_filter); > + return ret; > +} > + > /* Configure vlan stripping on or off */ int > i40e_vsi_config_vlan_stripping(struct i40e_vsi *vsi, bool on) @@ -4203,9 > +4270,11 @@ i40e_dev_init_vlan(struct rte_eth_dev *dev) { > struct rte_eth_dev_data *data =3D dev->data; > int ret; > + int mask =3D 0; >=20 > /* Apply vlan offload setting */ > - i40e_vlan_offload_set(dev, ETH_VLAN_STRIP_MASK); > + mask =3D ETH_VLAN_STRIP_MASK | ETH_VLAN_FILTER_MASK; > + i40e_vlan_offload_set(dev, mask); >=20 > /* Apply double-vlan setting, not implemented yet */ >=20 > diff --git a/drivers/net/i40e/i40e_ethdev.h b/drivers/net/i40e/i40e_ethde= v.h > index 1f9792b..5505d72 100644 > --- a/drivers/net/i40e/i40e_ethdev.h > +++ b/drivers/net/i40e/i40e_ethdev.h > @@ -551,6 +551,7 @@ void i40e_vsi_queues_unbind_intr(struct i40e_vsi *vsi= ); > int i40e_vsi_vlan_pvid_set(struct i40e_vsi *vsi, > struct i40e_vsi_vlan_pvid_info *info); int > i40e_vsi_config_vlan_stripping(struct i40e_vsi *vsi, bool on); > +int i40e_vsi_config_vlan_filter(struct i40e_vsi *vsi, bool on); > uint64_t i40e_config_hena(uint64_t flags); uint64_t > i40e_parse_hena(uint64_t flags); enum i40e_status_code > i40e_fdir_setup_tx_resources(struct i40e_pf *pf); > -- > 2.1.4