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 69DDCC320 for ; Tue, 16 Jun 2015 14:38:44 +0200 (CEST) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga101.fm.intel.com with ESMTP; 16 Jun 2015 05:38:43 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.13,626,1427785200"; d="scan'208";a="728384578" Received: from pgsmsx104.gar.corp.intel.com ([10.221.44.91]) by fmsmga001.fm.intel.com with ESMTP; 16 Jun 2015 05:38:42 -0700 Received: from shsmsx102.ccr.corp.intel.com (10.239.4.154) by PGSMSX104.gar.corp.intel.com (10.221.44.91) with Microsoft SMTP Server (TLS) id 14.3.224.2; Tue, 16 Jun 2015 20:38:41 +0800 Received: from shsmsx101.ccr.corp.intel.com ([169.254.1.246]) by shsmsx102.ccr.corp.intel.com ([169.254.2.165]) with mapi id 14.03.0224.002; Tue, 16 Jun 2015 20:38:40 +0800 From: "Qiu, Michael" To: "He, Shaopeng" , "dev@dpdk.org" Thread-Topic: [PATCH v2 2/3] fm10k: add MAC filter Thread-Index: AQHQpwoji6QpYFaGRU28BpnO+WTGZg== Date: Tue, 16 Jun 2015 12:38:39 +0000 Message-ID: <533710CFB86FA344BFBF2D6802E602860469C505@SHSMSX101.ccr.corp.intel.com> References: <1433213937-21690-1-git-send-email-shaopeng.he@intel.com> <1434331439-31223-1-git-send-email-shaopeng.he@intel.com> <1434331439-31223-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 v2 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, 16 Jun 2015 12:38:45 -0000 On 6/15/2015 9:25 AM, He, Shaopeng wrote:=0A= > MAC filter function was newly added, each PF and VF can have up to 64 MAC= =0A= > addresses. VF filter needs support from PF host, which is not available n= ow.=0A= >=0A= > Signed-off-by: Shaopeng He =0A= =0A= [.../...]=0A= =0A= > @@ -820,6 +821,7 @@ static int=0A= > fm10k_vlan_filter_set(struct rte_eth_dev *dev, uint16_t vlan_id, int on)= =0A= > {=0A= > s32 result;=0A= > + uint16_t mac_num =3D 0;=0A= > uint32_t vid_idx, vid_bit, mac_index;=0A= > struct fm10k_hw *hw;=0A= > struct fm10k_macvlan_filter_info *macvlan;=0A= > @@ -863,11 +865,17 @@ fm10k_vlan_filter_set(struct rte_eth_dev *dev, uint= 16_t vlan_id, int on)=0A= > mac_index++) {=0A= > if (is_zero_ether_addr(&data->mac_addrs[mac_index]))=0A= > continue;=0A= > + if (mac_num > macvlan->mac_num - 1) {=0A= > + PMD_INIT_LOG(ERR, "MAC address number "=0A= > + "not match");=0A= =0A= It's so strange why so many indentations here.=0A= =0A= > + break;=0A= > + }=0A= > fm10k_mbx_lock(hw);=0A= > result =3D fm10k_update_uc_addr(hw, hw->mac.dglort_map,=0A= > data->mac_addrs[mac_index].addr_bytes,=0A= > vlan_id, on, 0);=0A= > fm10k_mbx_unlock(hw);=0A= > + mac_num++;=0A= > }=0A= > if (result !=3D FM10K_SUCCESS) {=0A= > PMD_INIT_LOG(ERR, "MAC address update failed: %d", result);=0A= > @@ -884,6 +892,72 @@ fm10k_vlan_filter_set(struct rte_eth_dev *dev, uint1= 6_t vlan_id, int on)=0A= > return 0;=0A= > }=0A= > =0A= > +/* Add/Remove a MAC address, and update filters */=0A= > +static void=0A= > +fm10k_MAC_filter_set(struct rte_eth_dev *dev, const u8 *mac, bool add)= =0A= > +{=0A= > + uint32_t i, j, k;=0A= > + struct fm10k_hw *hw;=0A= > + struct fm10k_macvlan_filter_info *macvlan;=0A= > +=0A= > + hw =3D FM10K_DEV_PRIVATE_TO_HW(dev->data->dev_private);=0A= > + macvlan =3D FM10K_DEV_PRIVATE_TO_MACVLAN(dev->data->dev_private);=0A= > +=0A= > + /* @todo - add support for the VF */=0A= > + if (hw->mac.type !=3D fm10k_mac_pf) {=0A= > + PMD_INIT_LOG(ERR, "MAC filter not available on VF");=0A= > + return;=0A= > + }=0A= > +=0A= > + i =3D 0;=0A= > + for (j =3D 0; j < FM10K_VFTA_SIZE; j++) {=0A= > + if (macvlan->vfta[j]) {=0A= > + for (k =3D 0; k < FM10K_UINT32_BIT_SIZE; k++) {=0A= > + if (macvlan->vfta[j] & (1 << k)) {=0A= > + if (i + 1 > macvlan->vlan_num) {=0A= > + PMD_INIT_LOG(ERR, "vlan number "=0A= > + "not match");=0A= > + return;=0A= > + }=0A= > + fm10k_mbx_lock(hw);=0A= > + fm10k_update_uc_addr(hw,=0A= > + hw->mac.dglort_map, mac,=0A= > + j * FM10K_UINT32_BIT_SIZE + k,=0A= > + add, 0);=0A= > + fm10k_mbx_unlock(hw);=0A= > + i++;=0A= > + }=0A= > + }=0A= > + }=0A= > + }=0A= > +=0A= > + if (add)=0A= > + macvlan->mac_num++;=0A= > + else=0A= > + macvlan->mac_num--;=0A= > +}=0A= > +=0A= > +/* Add a MAC address, and update filters */=0A= > +static void=0A= > +fm10k_macaddr_add(struct rte_eth_dev *dev,=0A= > + struct ether_addr *mac_addr,=0A= > + __rte_unused uint32_t index,=0A= > + __rte_unused uint32_t pool)=0A= > +{=0A= > + fm10k_MAC_filter_set(dev, mac_addr->addr_bytes, TRUE);=0A= > +}=0A= > +=0A= > +/* Remove a MAC address, and update filters */=0A= > +static void=0A= > +fm10k_macaddr_remove(struct rte_eth_dev *dev, uint32_t index)=0A= > +{=0A= > + struct rte_eth_dev_data *data =3D dev->data;=0A= > +=0A= > + if (index < FM10K_MAX_MACADDR_NUM)=0A= > + fm10k_MAC_filter_set(dev, data->mac_addrs[index].addr_bytes,=0A= > + FALSE);=0A= > +}=0A= > +=0A= > static inline int=0A= > check_nb_desc(uint16_t min, uint16_t max, uint16_t mult, uint16_t reques= t)=0A= > {=0A= > @@ -1736,6 +1810,8 @@ static const struct eth_dev_ops fm10k_eth_dev_ops = =3D {=0A= > .link_update =3D fm10k_link_update,=0A= > .dev_infos_get =3D fm10k_dev_infos_get,=0A= > .vlan_filter_set =3D fm10k_vlan_filter_set,=0A= > + .mac_addr_add =3D fm10k_macaddr_add,=0A= > + .mac_addr_remove =3D fm10k_macaddr_remove,=0A= > .rx_queue_start =3D fm10k_dev_rx_queue_start,=0A= > .rx_queue_stop =3D fm10k_dev_rx_queue_stop,=0A= > .tx_queue_start =3D fm10k_dev_tx_queue_start,=0A= > @@ -1817,7 +1893,8 @@ eth_fm10k_dev_init(struct rte_eth_dev *dev)=0A= > }=0A= > =0A= > /* Initialize MAC address(es) */=0A= > - dev->data->mac_addrs =3D rte_zmalloc("fm10k", ETHER_ADDR_LEN, 0);=0A= > + dev->data->mac_addrs =3D rte_zmalloc("fm10k",=0A= > + ETHER_ADDR_LEN * FM10K_MAX_MACADDR_NUM, 0);=0A= > if (dev->data->mac_addrs =3D=3D NULL) {=0A= > PMD_INIT_LOG(ERR, "Cannot allocate memory for MAC addresses");=0A= > return -ENOMEM;=0A= =0A=