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 206225A53 for ; Tue, 9 Jun 2015 05:25:12 +0200 (CEST) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga101.fm.intel.com with ESMTP; 08 Jun 2015 20:25:12 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.13,577,1427785200"; d="scan'208";a="505214951" Received: from pgsmsx101.gar.corp.intel.com ([10.221.44.78]) by FMSMGA003.fm.intel.com with ESMTP; 08 Jun 2015 20:25:11 -0700 Received: from shsmsx101.ccr.corp.intel.com (10.239.4.153) by PGSMSX101.gar.corp.intel.com (10.221.44.78) with Microsoft SMTP Server (TLS) id 14.3.224.2; Tue, 9 Jun 2015 11:25:10 +0800 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.109]) by SHSMSX101.ccr.corp.intel.com ([10.239.4.153]) with mapi id 14.03.0224.002; Tue, 9 Jun 2015 11:25:09 +0800 From: "Chen, Jing D" To: "He, Shaopeng" , "dev@dpdk.org" Thread-Topic: [PATCH 2/3] fm10k: add MAC filter Thread-Index: AQHQnOAn07JByHrhpkKvn9jJBrgnHZ2jjcAA Date: Tue, 9 Jun 2015 03:25:08 +0000 Message-ID: <4341B239C0EFF9468EE453F9E9F4604D016FA27C@shsmsx102.ccr.corp.intel.com> References: <1433213937-21690-1-git-send-email-shaopeng.he@intel.com> <1433213937-21690-3-git-send-email-shaopeng.he@intel.com> In-Reply-To: <1433213937-21690-3-git-send-email-shaopeng.he@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 2/3] fm10k: add MAC 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: Tue, 09 Jun 2015 03:25:13 -0000 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 2/3] fm10k: add MAC filter >=20 > MAC filter function was newly added, each PF and VF can have up to 64 MAC > addresses. VF filter needs support from PF host, which is not available n= ow. >=20 > Signed-off-by: Shaopeng He > --- > drivers/net/fm10k/fm10k.h | 3 +- > drivers/net/fm10k/fm10k_ethdev.c | 90 > ++++++++++++++++++++++++++++++++++++---- > 2 files changed, 85 insertions(+), 8 deletions(-) >=20 > diff --git a/drivers/net/fm10k/fm10k.h b/drivers/net/fm10k/fm10k.h > index 3b95b72..f5be5f8 100644 > --- a/drivers/net/fm10k/fm10k.h > +++ b/drivers/net/fm10k/fm10k.h > @@ -110,7 +110,7 @@ > #define FM10K_VLAN_TAG_SIZE 4 >=20 > /* Maximum number of MAC addresses per PF/VF */ > -#define FM10K_MAX_MACADDR_NUM 1 > +#define FM10K_MAX_MACADDR_NUM 64 >=20 > #define FM10K_UINT32_BIT_SIZE (CHAR_BIT * sizeof(uint32_t)) > #define FM10K_VFTA_SIZE (4096 / FM10K_UINT32_BIT_SIZE) > @@ -125,6 +125,7 @@ >=20 > struct fm10k_macvlan_filter_info { > uint16_t vlan_num; /* Total VLAN number */ > + uint16_t mac_num; /* Total mac number */ > uint32_t vfta[FM10K_VFTA_SIZE]; /* VLAN bitmap */ > }; >=20 > diff --git a/drivers/net/fm10k/fm10k_ethdev.c > b/drivers/net/fm10k/fm10k_ethdev.c > index d2f3e44..4f23bf1 100644 > --- a/drivers/net/fm10k/fm10k_ethdev.c > +++ b/drivers/net/fm10k/fm10k_ethdev.c > @@ -54,6 +54,10 @@ > #define BIT_MASK_PER_UINT32 ((1 << CHARS_PER_UINT32) - 1) >=20 > static void fm10k_close_mbx_service(struct fm10k_hw *hw); > +static int > +fm10k_vlan_filter_set(struct rte_eth_dev *dev, uint16_t vlan_id, int on)= ; > +static void > +fm10k_MAC_filter_set(struct rte_eth_dev *dev, const u8 *mac, bool add); >=20 > static void > fm10k_mbx_initlock(struct fm10k_hw *hw) > @@ -668,14 +672,11 @@ fm10k_dev_start(struct rte_eth_dev *dev) > } >=20 > if (hw->mac.default_vid && hw->mac.default_vid <=3D > ETHER_MAX_VLAN_ID) { > - fm10k_mbx_lock(hw); > /* Update default vlan */ > - hw->mac.ops.update_vlan(hw, hw->mac.default_vid, 0, > true); > + fm10k_vlan_filter_set(dev, hw->mac.default_vid, true); >=20 > /* Add default mac/vlan filter to PF/Switch manger */ > - hw->mac.ops.update_uc_addr(hw, hw->mac.dglort_map, > hw->mac.addr, > - hw->mac.default_vid, true, 0); > - fm10k_mbx_unlock(hw); > + fm10k_MAC_filter_set(dev, hw->mac.addr, true); > } >=20 > return 0; > @@ -781,7 +782,7 @@ fm10k_dev_infos_get(struct rte_eth_dev *dev, > dev_info->max_rx_pktlen =3D FM10K_MAX_PKT_SIZE; > dev_info->max_rx_queues =3D hw->mac.max_queues; > dev_info->max_tx_queues =3D hw->mac.max_queues; > - dev_info->max_mac_addrs =3D 1; > + dev_info->max_mac_addrs =3D FM10K_MAX_MACADDR_NUM; > dev_info->max_hash_mac_addrs =3D 0; > dev_info->max_vfs =3D FM10K_MAX_VF_NUM; > dev_info->max_vmdq_pools =3D ETH_64_POOLS; > @@ -820,6 +821,7 @@ static int > fm10k_vlan_filter_set(struct rte_eth_dev *dev, uint16_t vlan_id, int on) > { > s32 result; > + uint16_t mac_num =3D 0; > uint32_t vid_idx, vid_bit, mac_index; > struct fm10k_hw *hw; > struct fm10k_macvlan_filter_info *macvlan; > @@ -864,9 +866,15 @@ fm10k_vlan_filter_set(struct rte_eth_dev *dev, > uint16_t vlan_id, int on) > mac_index++) { > if (is_zero_ether_addr(&data- > >mac_addrs[mac_index])) > continue; > + if (mac_num > macvlan->mac_num - 1) { > + PMD_INIT_LOG(ERR, "MAC address number > " > + "not match"); > + break; > + } > fm10k_update_uc_addr(hw, hw->mac.dglort_map, > data->mac_addrs[mac_index].addr_bytes, > vlan_id, on, 0); > + mac_num++; > } > } > fm10k_mbx_unlock(hw); > @@ -876,6 +884,71 @@ fm10k_vlan_filter_set(struct rte_eth_dev *dev, > uint16_t vlan_id, int on) > return (-EIO); > } >=20 > +/* Add/Remove a MAC address, and update filters */ > +static void > +fm10k_MAC_filter_set(struct rte_eth_dev *dev, const u8 *mac, bool add) > +{ > + uint32_t i, j, k; > + struct fm10k_hw *hw; > + struct fm10k_macvlan_filter_info *macvlan; > + > + 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; > + Since it only supports PF, it's better to clarify in the log. > + fm10k_mbx_lock(hw); > + i =3D 0; > + for (j =3D 0; j < FM10K_VFTA_SIZE; j++) { > + if (macvlan->vfta[j]) { > + for (k =3D 0; k < FM10K_UINT32_BIT_SIZE; k++) { > + if (macvlan->vfta[j] & (1 << k)) { > + if (i + 1 > macvlan->vlan_num) { > + PMD_INIT_LOG(ERR, "vlan > number " > + "not match"); > + fm10k_mbx_unlock(hw); > + return; > + } > + fm10k_update_uc_addr(hw, > + hw->mac.dglort_map, mac, > + j * FM10K_UINT32_BIT_SIZE > + k, > + add, 0); > + i++; > + } > + } > + } > + } > + fm10k_mbx_unlock(hw); > + > + if (add) > + macvlan->mac_num++; > + else > + macvlan->mac_num--; > +} > + > +/* Add a MAC address, and update filters */ > +static void > +fm10k_macaddr_add(struct rte_eth_dev *dev, > + struct ether_addr *mac_addr, > + __rte_unused uint32_t index, > + __rte_unused uint32_t pool) > +{ > + fm10k_MAC_filter_set(dev, mac_addr->addr_bytes, TRUE); > +} > + > +/* Remove a MAC address, and update filters */ > +static void > +fm10k_macaddr_remove(struct rte_eth_dev *dev, uint32_t index) > +{ > + struct rte_eth_dev_data *data =3D dev->data; > + > + if (index < FM10K_MAX_MACADDR_NUM) > + fm10k_MAC_filter_set(dev, data- > >mac_addrs[index].addr_bytes, > + FALSE); > +} > + > static inline int > check_nb_desc(uint16_t min, uint16_t max, uint16_t mult, uint16_t reques= t) > { > @@ -1728,6 +1801,8 @@ static const struct eth_dev_ops > fm10k_eth_dev_ops =3D { > .link_update =3D fm10k_link_update, > .dev_infos_get =3D fm10k_dev_infos_get, > .vlan_filter_set =3D fm10k_vlan_filter_set, > + .mac_addr_add =3D fm10k_macaddr_add, > + .mac_addr_remove =3D fm10k_macaddr_remove, > .rx_queue_start =3D fm10k_dev_rx_queue_start, > .rx_queue_stop =3D fm10k_dev_rx_queue_stop, > .tx_queue_start =3D fm10k_dev_tx_queue_start, > @@ -1809,7 +1884,8 @@ eth_fm10k_dev_init(struct rte_eth_dev *dev) > } >=20 > /* Initialize MAC address(es) */ > - dev->data->mac_addrs =3D rte_zmalloc("fm10k", ETHER_ADDR_LEN, 0); > + dev->data->mac_addrs =3D rte_zmalloc("fm10k", > + ETHER_ADDR_LEN * FM10K_MAX_MACADDR_NUM, > 0); > if (dev->data->mac_addrs =3D=3D NULL) { > PMD_INIT_LOG(ERR, "Cannot allocate memory for MAC > addresses"); > return -ENOMEM; > -- > 1.9.3