From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <michael.qiu@intel.com>
Received: from mga01.intel.com (mga01.intel.com [192.55.52.88])
 by dpdk.org (Postfix) with ESMTP id B668BC324
 for <dev@dpdk.org>; Tue, 16 Jun 2015 13:56:32 +0200 (CEST)
Received: from fmsmga002.fm.intel.com ([10.253.24.26])
 by fmsmga101.fm.intel.com with ESMTP; 16 Jun 2015 04:56:31 -0700
X-ExtLoop1: 1
X-IronPort-AV: E=Sophos;i="5.13,626,1427785200"; d="scan'208";a="744355533"
Received: from pgsmsx102.gar.corp.intel.com ([10.221.44.80])
 by fmsmga002.fm.intel.com with ESMTP; 16 Jun 2015 04:56:23 -0700
Received: from shsmsx151.ccr.corp.intel.com (10.239.6.50) by
 PGSMSX102.gar.corp.intel.com (10.221.44.80) with Microsoft SMTP Server (TLS)
 id 14.3.224.2; Tue, 16 Jun 2015 19:54:03 +0800
Received: from shsmsx101.ccr.corp.intel.com ([169.254.1.246]) by
 SHSMSX151.ccr.corp.intel.com ([169.254.3.168]) with mapi id 14.03.0224.002;
 Tue, 16 Jun 2015 19:54:02 +0800
From: "Qiu, Michael" <michael.qiu@intel.com>
To: "He, Shaopeng" <shaopeng.he@intel.com>, "dev@dpdk.org" <dev@dpdk.org>
Thread-Topic: [PATCH v2] fm10k: fix PF/VF MAC address register and clean up bug
Thread-Index: AQHQpwpQSpKrNYcq00uMZWy6XBZaPA==
Date: Tue, 16 Jun 2015 11:54:02 +0000
Message-ID: <533710CFB86FA344BFBF2D6802E602860469C456@SHSMSX101.ccr.corp.intel.com>
References: <1433474672-30951-1-git-send-email-shaopeng.he@intel.com>
 <1434331570-31289-1-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] fm10k: fix PF/VF MAC address register and
 clean up bug
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: patches and discussions about DPDK <dev.dpdk.org>
List-Unsubscribe: <http://dpdk.org/ml/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://dpdk.org/ml/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <http://dpdk.org/ml/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
X-List-Received-Date: Tue, 16 Jun 2015 11:56:33 -0000

Tested-by: Michael Qiu <michael.qiu@intel.com>=0A=
=0A=
- OS: Fedora20  3.11.10-301=0A=
- GCC: gcc version 4.8.3 2014911=0A=
- CPU: Intel(R) Xeon(R) CPU E5-2680 v2 @ 2.80GHz=0A=
- NIC: Ethernet controller: Intel Corporation Device 15a4 (rev 01)=0A=
- Default x86_64-native-linuxapp-gcc configuration=0A=
- Total 1 cases, 1 passed, 0 failed=0A=
=0A=
=0A=
On 6/15/2015 9:26 AM, He, Shaopeng wrote:=0A=
> v2 changes:=0A=
>  - rebase this patch onto the HEAD=0A=
>  - add more description for this patch=0A=
>=0A=
> This patch includes 3 changes related to MAC/VLAN address table=0A=
> when the system(e.g. testpmd) is started and closed:=0A=
>  - remove default MAC address with fixed VLAN 0 which was for the=0A=
>    debug purpose before the MAC/VLAN filter function was implemented.=0A=
>  - enable VF MAC/VLAN filter for the first valid MAC address=0A=
>    and first valid VLAN ID. This is needed for system(e.g. testpmd)=0A=
>    to setup default MAC address and default VLAN for VF.=0A=
>    Later attempt to change these default value will be refused by=0A=
>    under layer shared code and PF host functions.=0A=
>  - un-register any combination of VLAN and MAC address from fm10k=0A=
>    switch side MAC table when the system(e.g. testpmd) is closed.=0A=
>=0A=
> Signed-off-by: Shaopeng He <shaopeng.he@intel.com>=0A=
> ---=0A=
>  drivers/net/fm10k/fm10k_ethdev.c | 42 ++++++++++++++++++++++------------=
------=0A=
>  1 file changed, 23 insertions(+), 19 deletions(-)=0A=
>=0A=
> diff --git a/drivers/net/fm10k/fm10k_ethdev.c b/drivers/net/fm10k/fm10k_e=
thdev.c=0A=
> index 802a930..625fd31 100644=0A=
> --- a/drivers/net/fm10k/fm10k_ethdev.c=0A=
> +++ b/drivers/net/fm10k/fm10k_ethdev.c=0A=
> @@ -58,6 +58,8 @@ static int=0A=
>  fm10k_vlan_filter_set(struct rte_eth_dev *dev, uint16_t vlan_id, int on)=
;=0A=
>  static void=0A=
>  fm10k_MAC_filter_set(struct rte_eth_dev *dev, const u8 *mac, bool add);=
=0A=
> +static void=0A=
> +fm10k_MACVLAN_remove_all(struct rte_eth_dev *dev);=0A=
>  =0A=
>  static void=0A=
>  fm10k_mbx_initlock(struct fm10k_hw *hw)=0A=
> @@ -703,6 +705,8 @@ fm10k_dev_close(struct rte_eth_dev *dev)=0A=
>  =0A=
>  	PMD_INIT_FUNC_TRACE();=0A=
>  =0A=
> +	fm10k_MACVLAN_remove_all(dev);=0A=
> +=0A=
>  	/* Stop mailbox service first */=0A=
>  	fm10k_close_mbx_service(hw);=0A=
>  	fm10k_dev_stop(dev);=0A=
> @@ -832,12 +836,6 @@ fm10k_vlan_filter_set(struct rte_eth_dev *dev, uint1=
6_t vlan_id, int on)=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, "VLAN filter not available on VF");=0A=
> -		return -ENOTSUP;=0A=
> -	}=0A=
> -=0A=
>  	if (vlan_id > ETH_VLAN_ID_MAX) {=0A=
>  		PMD_INIT_LOG(ERR, "Invalid vlan_id: must be < 4096");=0A=
>  		return (-EINVAL);=0A=
> @@ -926,12 +924,6 @@ fm10k_MAC_filter_set(struct rte_eth_dev *dev, const =
u8 *mac, bool add)=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=
> @@ -981,6 +973,25 @@ fm10k_macaddr_remove(struct rte_eth_dev *dev, uint32=
_t index)=0A=
>  				FALSE);=0A=
>  }=0A=
>  =0A=
> +/* Remove all VLAN and MAC address table entries */=0A=
> +static void=0A=
> +fm10k_MACVLAN_remove_all(struct rte_eth_dev *dev)=0A=
> +{=0A=
> +	uint32_t j, k;=0A=
> +	struct fm10k_macvlan_filter_info *macvlan;=0A=
> +=0A=
> +	macvlan =3D FM10K_DEV_PRIVATE_TO_MACVLAN(dev->data->dev_private);=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=
> +					fm10k_vlan_filter_set(dev,=0A=
> +						j * FM10K_UINT32_BIT_SIZE + k, false);=0A=
> +			}=0A=
> +		}=0A=
> +	}=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=
> @@ -2008,13 +2019,6 @@ eth_fm10k_dev_init(struct rte_eth_dev *dev)=0A=
>  	/* Enable port first */=0A=
>  	hw->mac.ops.update_lport_state(hw, hw->mac.dglort_map, 1, 1);=0A=
>  =0A=
> -	/*=0A=
> -	 * Add default mac. glort is assigned by SM for PF, while is=0A=
> -	 * unused for VF. PF will assign correct glort for VF.=0A=
> -	 */=0A=
> -	hw->mac.ops.update_uc_addr(hw, hw->mac.dglort_map, hw->mac.addr,=0A=
> -				0, 1, 0);=0A=
> -=0A=
>  	/* Set unicast mode by default. App can change to other mode in other=
=0A=
>  	 * API func.=0A=
>  	 */=0A=
=0A=