From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by dpdk.org (Postfix) with ESMTP id CE50E34F2 for ; Tue, 27 Mar 2018 15:51:50 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 27 Mar 2018 06:51:49 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.48,367,1517904000"; d="scan'208";a="41060027" Received: from fmsmsx108.amr.corp.intel.com ([10.18.124.206]) by fmsmga004.fm.intel.com with ESMTP; 27 Mar 2018 06:51:49 -0700 Received: from shsmsx104.ccr.corp.intel.com (10.239.4.70) by FMSMSX108.amr.corp.intel.com (10.18.124.206) with Microsoft SMTP Server (TLS) id 14.3.319.2; Tue, 27 Mar 2018 06:51:49 -0700 Received: from shsmsx103.ccr.corp.intel.com ([169.254.4.235]) by SHSMSX104.ccr.corp.intel.com ([169.254.5.226]) with mapi id 14.03.0319.002; Tue, 27 Mar 2018 21:51:47 +0800 From: "Zhang, Qi Z" To: Olivier Matz , "dev@dpdk.org" , "Xing, Beilei" , "Lu, Wenzhuo" Thread-Topic: [dpdk-dev] [PATCH] net/i40evf: add multicast MAC address filtering Thread-Index: AQHTlen5ZGCAOui+9UCTAUeT42hmGKPkeUew Date: Tue, 27 Mar 2018 13:51:46 +0000 Message-ID: <039ED4275CED7440929022BC67E7061153174E97@SHSMSX103.ccr.corp.intel.com> References: <20180125143622.904-1-olivier.matz@6wind.com> In-Reply-To: <20180125143622.904-1-olivier.matz@6wind.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-version: 11.0.0.116 dlp-reaction: no-action 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] net/i40evf: add multicast MAC address filtering X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 27 Mar 2018 13:51:51 -0000 > -----Original Message----- > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Olivier Matz > Sent: Thursday, January 25, 2018 10:36 PM > To: dev@dpdk.org; Xing, Beilei ; Zhang, Qi Z > ; Lu, Wenzhuo > Subject: [dpdk-dev] [PATCH] net/i40evf: add multicast MAC address filteri= ng >=20 > Add support the set_mc_addr_list device operation in the i40evf PMD. >=20 > The configured addresses are stored in the device private area, so they c= an be > flushed before adding new ones. >=20 > Signed-off-by: Olivier Matz Acked-by: Qi Zhang Thanks for enable this! > --- >=20 > Target is v18.05. >=20 > To reproduce the issue: >=20 > guest (testpmd) > +----------+ > | | > | port1 | > | VF | > | X | > +------X---+ > X > +------X---+ +----------+ > | X | | | > | ens3f2+--------+ntfp2 | > | PF | | | > | | | | > +----------+ +----------+ > host tester > (linux) node >=20 >=20 > Start testpmd in guest in rx only mode: >=20 > set fwd rxonly > set verbose 1 > start >=20 > Send packets from the tester node: >=20 > # broadcast packet is received > arp =3D Ether(dst=3D'ff:ff:ff:ff:ff:ff')/ARP(psrc=3D'1.1.1.2', pdst=3D'1= .1.1.3') > sendp(arp, iface=3D"ntfp2") >=20 > # unicast packet to the correct mac (VF) is received arp =3D > Ether(dst=3D'00:09:C0:38:6D:C2')/ARP(psrc=3D'1.1.1.2', pdst=3D'1.1.1.3') > sendp(arp, iface=3D"ntfp2") >=20 > # multicast packet is not received > arp =3D Ether(dst=3D'33:33:00:01:00:02')/ARP(psrc=3D'1.1.1.2', pdst=3D'1= .1.1.3') > sendp(arp, iface=3D"ntfp2") >=20 > Try to add the multicast address in testpmd: >=20 > mcast_addr add 1 33:33:00:01:00:02 >=20 > Without the patch, it fails (ENOTSUP). >=20 > With the patch, it is possible to add/remove several multicast addresses,= and > the multicast packets sent by the tester node are properly received. >=20 >=20 > drivers/net/i40e/i40e_ethdev.h | 3 ++ > drivers/net/i40e/i40e_ethdev_vf.c | 100 > ++++++++++++++++++++++++++++++++++++++ > 2 files changed, 103 insertions(+) >=20 > diff --git a/drivers/net/i40e/i40e_ethdev.h b/drivers/net/i40e/i40e_ethde= v.h > index 69ea6c189..83c9d3b19 100644 > --- a/drivers/net/i40e/i40e_ethdev.h > +++ b/drivers/net/i40e/i40e_ethdev.h > @@ -995,6 +995,9 @@ struct i40e_vf { > uint16_t promisc_flags; /* Promiscuous setting */ > uint32_t vlan[I40E_VFTA_SIZE]; /* VLAN bit map */ >=20 > + struct ether_addr mc_addrs[I40E_NUM_MACADDR_MAX]; /* Multicast > addrs */ > + uint16_t mc_addrs_num; /* Multicast mac addresses number */ > + > /* Event from pf */ > bool dev_closed; > bool link_up; > diff --git a/drivers/net/i40e/i40e_ethdev_vf.c > b/drivers/net/i40e/i40e_ethdev_vf.c > index 6ac3f8c04..0d73c1b7f 100644 > --- a/drivers/net/i40e/i40e_ethdev_vf.c > +++ b/drivers/net/i40e/i40e_ethdev_vf.c > @@ -130,6 +130,14 @@ static void i40evf_handle_pf_event(struct > rte_eth_dev *dev, > uint8_t *msg, > uint16_t msglen); >=20 > +static int > +i40evf_add_del_mc_addr_list(struct rte_eth_dev *dev, > + struct ether_addr *mc_addr_set, > + uint32_t nb_mc_addr, bool add); > +static int > +i40evf_set_mc_addr_list(struct rte_eth_dev *dev, struct ether_addr > *mc_addr_set, > + uint32_t nb_mc_addr); > + > /* Default hash key buffer for RSS */ > static uint32_t rss_key_default[I40E_VFQF_HKEY_MAX_INDEX + 1]; >=20 > @@ -195,6 +203,7 @@ static const struct eth_dev_ops i40evf_eth_dev_ops > =3D { > .txq_info_get =3D i40e_txq_info_get, > .mac_addr_add =3D i40evf_add_mac_addr, > .mac_addr_remove =3D i40evf_del_mac_addr, > + .set_mc_addr_list =3D i40evf_set_mc_addr_list, > .reta_update =3D i40evf_dev_rss_reta_update, > .reta_query =3D i40evf_dev_rss_reta_query, > .rss_hash_update =3D i40evf_dev_rss_hash_update, > @@ -2011,6 +2020,9 @@ i40evf_dev_start(struct rte_eth_dev *dev) >=20 > /* Set all mac addrs */ > i40evf_add_del_all_mac_addr(dev, TRUE); > + /* Set all multicast addresses */ > + i40evf_add_del_mc_addr_list(dev, vf->mc_addrs, vf->mc_addrs_num, > + TRUE); >=20 > if (i40evf_start_queues(dev) !=3D 0) { > PMD_DRV_LOG(ERR, "enable queues failed"); @@ -2035,6 +2047,8 > @@ i40evf_dev_start(struct rte_eth_dev *dev) >=20 > err_mac: > i40evf_add_del_all_mac_addr(dev, FALSE); > + i40evf_add_del_mc_addr_list(dev, vf->mc_addrs, vf->mc_addrs_num, > + FALSE); > err_queue: > return -1; > } > @@ -2045,6 +2059,7 @@ i40evf_dev_stop(struct rte_eth_dev *dev) > struct rte_pci_device *pci_dev =3D RTE_ETH_DEV_TO_PCI(dev); > struct rte_intr_handle *intr_handle =3D &pci_dev->intr_handle; > struct i40e_hw *hw =3D > I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private); > + struct i40e_vf *vf =3D > I40EVF_DEV_PRIVATE_TO_VF(dev->data->dev_private); >=20 > PMD_INIT_FUNC_TRACE(); >=20 > @@ -2062,6 +2077,9 @@ i40evf_dev_stop(struct rte_eth_dev *dev) > } > /* remove all mac addrs */ > i40evf_add_del_all_mac_addr(dev, FALSE); > + /* remove all multicast addresses */ > + i40evf_add_del_mc_addr_list(dev, vf->mc_addrs, vf->mc_addrs_num, > + FALSE); > hw->adapter_stopped =3D 1; >=20 > } > @@ -2676,3 +2694,85 @@ i40evf_set_default_mac_addr(struct > rte_eth_dev *dev, >=20 > ether_addr_copy(mac_addr, (struct ether_addr *)hw->mac.addr); } > + > +static int > +i40evf_add_del_mc_addr_list(struct rte_eth_dev *dev, > + struct ether_addr *mc_addrs, > + uint32_t mc_addrs_num, bool add) > +{ > + struct virtchnl_ether_addr_list *list; > + struct i40e_vf *vf =3D > I40EVF_DEV_PRIVATE_TO_VF(dev->data->dev_private); > + uint8_t cmd_buffer[sizeof(struct virtchnl_ether_addr_list) + > + (I40E_NUM_MACADDR_MAX * sizeof(struct > virtchnl_ether_addr))]; > + uint32_t i; > + int err; > + struct vf_cmd_info args; > + > + if (mc_addrs =3D=3D NULL || mc_addrs_num =3D=3D 0) > + return 0; > + > + if (mc_addrs_num > I40E_NUM_MACADDR_MAX) > + return -EINVAL; > + > + list =3D (struct virtchnl_ether_addr_list *)cmd_buffer; > + list->vsi_id =3D vf->vsi_res->vsi_id; > + list->num_elements =3D mc_addrs_num; > + > + for (i =3D 0; i < mc_addrs_num; i++) { > + if (!I40E_IS_MULTICAST(mc_addrs[i].addr_bytes)) { > + PMD_DRV_LOG(ERR, "Invalid mac:%x:%x:%x:%x:%x:%x", > + mc_addrs[i].addr_bytes[0], > + mc_addrs[i].addr_bytes[1], > + mc_addrs[i].addr_bytes[2], > + mc_addrs[i].addr_bytes[3], > + mc_addrs[i].addr_bytes[4], > + mc_addrs[i].addr_bytes[5]); > + return -EINVAL; > + } > + > + memcpy(list->list[i].addr, mc_addrs[i].addr_bytes, > + sizeof(list->list[i].addr)); > + } > + > + args.ops =3D add ? VIRTCHNL_OP_ADD_ETH_ADDR : > VIRTCHNL_OP_DEL_ETH_ADDR; > + args.in_args =3D cmd_buffer; > + args.in_args_size =3D sizeof(struct virtchnl_ether_addr_list) + > + i * sizeof(struct virtchnl_ether_addr); > + args.out_buffer =3D vf->aq_resp; > + args.out_size =3D I40E_AQ_BUF_SZ; > + err =3D i40evf_execute_vf_cmd(dev, &args); > + if (err) { > + PMD_DRV_LOG(ERR, "fail to execute command %s", > + add ? "OP_ADD_ETH_ADDR" : "OP_DEL_ETH_ADDR"); > + return err; > + } > + > + return 0; > +} > + > +static int > +i40evf_set_mc_addr_list(struct rte_eth_dev *dev, struct ether_addr > *mc_addrs, > + uint32_t mc_addrs_num) > +{ > + struct i40e_vf *vf =3D > I40EVF_DEV_PRIVATE_TO_VF(dev->data->dev_private); > + int err; > + > + /* flush previous addresses */ > + err =3D i40evf_add_del_mc_addr_list(dev, vf->mc_addrs, > vf->mc_addrs_num, > + FALSE); > + if (err) > + return err; > + > + vf->mc_addrs_num =3D 0; > + > + /* add new ones */ > + err =3D i40evf_add_del_mc_addr_list(dev, mc_addrs, mc_addrs_num, > + TRUE); > + if (err) > + return err; > + > + vf->mc_addrs_num =3D mc_addrs_num; > + memcpy(vf->mc_addrs, mc_addrs, mc_addrs_num * > sizeof(*mc_addrs)); > + > + return 0; > +} > -- > 2.11.0