From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 38D62A0548; Thu, 8 Sep 2022 04:29:28 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 1044340143; Thu, 8 Sep 2022 04:29:28 +0200 (CEST) Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by mails.dpdk.org (Postfix) with ESMTP id 0E53D400D6 for ; Thu, 8 Sep 2022 04:29:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1662604166; x=1694140166; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=gEe4sOOfhjDZtCTFCwiE+z5MeAi99oz8NiLVqPbUJdM=; b=Mgl/tbGX0XvJ/38SyJzoKlUk513l3vM+Xxq5N1C5n4cB1y5Zz+Oc4DKg coq6icAAgnUMuGv6K3MefI2ao1D8Svs+aoXY/0AYAietnKasIb4QSYeNx oWzeOm+hVhf4L+xVPkmTl9jKc7Ym6g+WXfA+D2E3qpGpVd7vBQrSm+vYr g/YKh0bGcBcsEGeOaluJoWUKAesL4bCfFm0Ram26garUorroXzISY8Qq4 24X7/PWnCNUofqPPdQ9bUQagG6heeWdJHFZOAMB3B4wBXMFcL6lwEEMlT AjVR1XX4ptKxxEpEzzozQTyuukIiMrH23MjSsm10ePlsR+x6STJeTgBGl Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10463"; a="295781347" X-IronPort-AV: E=Sophos;i="5.93,298,1654585200"; d="scan'208";a="295781347" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Sep 2022 19:29:25 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.93,298,1654585200"; d="scan'208";a="757012177" Received: from orsmsx603.amr.corp.intel.com ([10.22.229.16]) by fmsmga001.fm.intel.com with ESMTP; 07 Sep 2022 19:29:25 -0700 Received: from orsmsx608.amr.corp.intel.com (10.22.229.21) by ORSMSX603.amr.corp.intel.com (10.22.229.16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Wed, 7 Sep 2022 19:29:24 -0700 Received: from orsmsx602.amr.corp.intel.com (10.22.229.15) by ORSMSX608.amr.corp.intel.com (10.22.229.21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Wed, 7 Sep 2022 19:29:24 -0700 Received: from orsedg603.ED.cps.intel.com (10.7.248.4) by orsmsx602.amr.corp.intel.com (10.22.229.15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31 via Frontend Transport; Wed, 7 Sep 2022 19:29:24 -0700 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (104.47.57.169) by edgegateway.intel.com (134.134.137.100) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2375.31; Wed, 7 Sep 2022 19:29:23 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=c/zfwG9WTPRp8nCZSpLtFB96seXoT/E6kkNpY8msYl+1p3ArvHTGZy6vUh+BGkUU5PYYuLT1dBFW0L8O7KwUVLQvqsKnTGEjpTlMHDXUGmQz2VCFOK+njlXAGVkV0gTfzEJ9i3FChkL+abFlD/7u1ou+G0iP2cTEZfYz6jsy1l6CVGpxTqA77LVbJcHjU669msrZmVGh9q6hEPLT5OIe1PlLpjIO0wZ+1JPQPDRvMBuqKp6tslv93ySbmiAN6F8kmWhx8WLzQbCNZwjDldLZd7+KLtbf8q7WJL1q10T12N8nfmsrYaIJkGB4EvxYItTbIWNpdReqL3TxLaEVrzd+Kw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=EoppD28dgz60NHRhC57dL5/uVbjonk5Oh4GF+jmS+fo=; b=SfTDPL/vKnfo6rKPioSM8RZ+UDNvqsD3SKRfATQ+kbBqg6TYcy1mB6AtBFgHkdDwuaJa8w6PK0nV9CRsjwmEYAQI8QTF/nr3K6mqu/GW+o3clNSE2VveTQep8KChtdOPixt2dCKkzkXT9OocS2zDoa0aMImhMQuLItJkITswvxdsSE+fOq147UTPITNoEnZz+sQfU54EEd2Q/TBDdfUqOoy6FhUDGjxyr2XXqgwmil9KiwsPaU00XEoEcCmiLLenqEHDfxizm4iL1Hn380Pq4Rs1+SEkkbjwdD9lXsS7HtVHkdYEqmoFg2BHz32p6PwI7JrIwiLgZ8xiE3e3xzhNBg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Received: from DM6PR11MB3516.namprd11.prod.outlook.com (2603:10b6:5:72::13) by SN6PR11MB2717.namprd11.prod.outlook.com (2603:10b6:805:60::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5588.16; Thu, 8 Sep 2022 02:29:08 +0000 Received: from DM6PR11MB3516.namprd11.prod.outlook.com ([fe80::4416:c910:4c93:1e60]) by DM6PR11MB3516.namprd11.prod.outlook.com ([fe80::4416:c910:4c93:1e60%5]) with mapi id 15.20.5588.018; Thu, 8 Sep 2022 02:29:08 +0000 From: "Zhang, Yuying" To: "Liu, KevinX" , "dev@dpdk.org" CC: "Xing, Beilei" , "Yang, SteveX" Subject: RE: [PATCH v4] net/i40e: fix single VLAN cannot work normally Thread-Topic: [PATCH v4] net/i40e: fix single VLAN cannot work normally Thread-Index: AQHYwooro4/+U6JS8EyVg4yCzZhtq63Uz9gg Date: Thu, 8 Sep 2022 02:29:07 +0000 Message-ID: References: <20220818160351.1353003-1-kevinx.liu@intel.com> <20220907151819.93024-1-kevinx.liu@intel.com> In-Reply-To: <20220907151819.93024-1-kevinx.liu@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: ef29a422-71e6-49f2-6447-08da9141e824 x-ms-traffictypediagnostic: SN6PR11MB2717:EE_ x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: gfP/2KZ+/w8gzckGnZBn6QISTW25cA/jajx1iQ1HXtG0B5DLvvpe1swVfrIfLpLu9eUZKu/HQ4vHzOC+OTFWUmqBFvlehFs+I8D5tvrTUQ2PjM6HOGGDAaUYGDq1s9hwzGdSTb4V5W+p/IJFaBdZkf61gv+7gWC9Upx6e80bD/1pAlukoun2TwFM/YTpHFVb677faLRdj+a90TgS72IAyfQe9MhUs1nEN05Ae6qHEi0kCMuGECEJ+y4ioZn+LZSwxBhlUpory9O9QEvqb5JwE6xmYtxMEtU/3rrEZwscOr9g95HKErQQ754YsPy4MX3Cx7dR4OI98lCLXkvpVnDkQjRl40jqWdZo4iSj+154/rABxpGSORvrHjFT5LAUZjpfSXp6ArbY4bjrjVFwEFZqYl2yZGEuL9E9C8ATCoNMab6GFmr3YA3cf6f1NlKnBCjwhNyugstSWzFl1BB+tqm2sfrNdUKpjJ46+2/D5W9vT5GBmE6K1gLA7qvnNRbnqcsPqFFuIIEA8o9Zf78h5Jh/kr9jDzTr+lsQmUQokw1vC2qi62qyMmMehlfQ/cGUvlBtaN4Gx8i/VPxZgHntxMZHG5rBbldz8pf5RyOImXOPiPzrGroFRSnLoAHDIhpjkZCONFZqMZIZgJEgRQ1lZlWa4OaxiRnlVT0uFHsYI9+7flSTOW0ns2pn4PHc2pEsR4iqb3qsvaZFgS75C8dM0eWJZeq4tlCcOXSk1ViJ69+XM3cb7LQBQ9Mi+OQwulNhjTZnB3/faxyJDTz0rl5Z9/2ZHg== x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM6PR11MB3516.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230016)(376002)(136003)(39860400002)(346002)(366004)(396003)(71200400001)(186003)(53546011)(26005)(6506007)(107886003)(9686003)(8936002)(83380400001)(55016003)(52536014)(8676002)(7696005)(4326008)(5660300002)(64756008)(41300700001)(54906003)(76116006)(66476007)(66446008)(2906002)(478600001)(66946007)(110136005)(316002)(86362001)(38100700002)(38070700005)(66556008)(82960400001)(33656002)(122000001); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?q36p8vZlDvOSdwYypi7ck7kmXMGbVnPhy8popJiPHX5GcJVe7CXYoXKwJpU1?= =?us-ascii?Q?BHAxc3QycMkRzbeoJJ6pi64scDwTiZf9ZCrBPIMYmwpiKbgZ8EOPmZR1qx5v?= =?us-ascii?Q?uB7l+Rncjt8FVRGKWRE0IOxfW7KD2T9IeAKqms2LYV6f5MnAdhDb7nXs0sKE?= =?us-ascii?Q?9MHVl/+wLMvb2JDJFqxmHX/kOJobwjhzv/slzO5sQ+QAVxJNMWkC6QYo/a8H?= =?us-ascii?Q?raeEwPTy7joH5wEsWgVdc1sTeS0d4axYe8i1j5Jwo/RDVULK+OjiZ72WS1ic?= =?us-ascii?Q?4M1LfJBUirkxF5AEQ0P3won1jTHa1Dc6KOJF6DO+dGoqakoPYwcTWrAGpb6+?= =?us-ascii?Q?c7gROybG5UOhHPH3rVYJxuIr9xxn/TiRX3rKbeEjhGHZBK0Jj+eVtuAYvO6K?= =?us-ascii?Q?6xLz4cr5ohPfz8JAGAhaaVSfXIrz2HvVz5FKvJ1nbFjk+vMzQ9KsYuPnU8Od?= =?us-ascii?Q?d2dJqy9RhcOhEDLklelJ8TomhijqQuq1NON3aRce2US61HIv4qNQMD6uH/Jy?= =?us-ascii?Q?18cWq6E9ClNcOYJxgRRaKuh6QeUr9abzgSZWcCVRPITA+sklM8ZtdIwRpRhM?= =?us-ascii?Q?OSDp38NL+Rw0LSY9d0IQgKHZAo1shWtKIguUNiOKU+o70ZTatj4P5cYRBuuq?= =?us-ascii?Q?o7S/1rq7/1e2b4dDg549FJo6I3d5K3XKJOeBxtbA6UgzFdlO2g+g435JaaF1?= =?us-ascii?Q?O3ZSqznSCBMXzuHb0HRzXaQTVodlF9RRxzgMkJ8/BeasW2kU1ZEGlMdvtDDs?= =?us-ascii?Q?sFrgpcqJJPRiV1SdAVsr9EVRfb7421QC7PpqouYIv3iewj5UPdqW3V+w/otS?= =?us-ascii?Q?RuEGWd73+55DRtMZbH33hwDF5cf+HSiaFQQfCLVj9Ci/8KpIhkCYGXT3BtjX?= =?us-ascii?Q?mI6yDujdotG5aC4rXVB6P6mcsMKtxhFFqIwYSo8X+vyDLlPpS5WeZBVqfBRR?= =?us-ascii?Q?uSCNDecjAdDbDsKR9CeTYZerQLEWOXyi+6r0GkSEAY0pwnbAJCO7HW0i9peS?= =?us-ascii?Q?biDYRvs/bW4dSxG4vLKK0dgYaom/Xi97+Wscjn55hgPgvedohjjv787bx2oc?= =?us-ascii?Q?JzlOXV6sWSob3aufFB6IdQ+CmbARwIaUm5RJhbPNKMNmswEVNahpZX4opkgB?= =?us-ascii?Q?6nTBpxXDvcFZrbk+cg1LvwJHyKjjSOKbNICW5oGEG8TbAMpte4AlyHfliDdD?= =?us-ascii?Q?c21xEmt91v9XyBhZDkYlwuhG1i34C6HrcAGWpz24Or8nH4bDUVnEIQuVSDKA?= =?us-ascii?Q?aiNm0rS6WlcLF/gdSGMRlCpZeZwttIPdF5mZUS7Q2wADIAhZzwJpqWTnWDmF?= =?us-ascii?Q?tjcay0yJi5jFCuf3EBgX2yjmNcA7l4WqIC2Q/y4eKoAeBgmyPsGMhQI4CTja?= =?us-ascii?Q?a/RxMDfTXSHblMosXeBzFFQ5mk9iHdLpefvCbT/GonfVxutEA8M02jG8lGqr?= =?us-ascii?Q?NoGo5HUwBreFQicLp2v22rGv071v1kXYnAEaBMExGBYRl4FB2wraLov1IrCw?= =?us-ascii?Q?SGAK0pntvc7c+dN3JXaKjjx5UJzsi9X4n7DZUGKxqzqqN8GtIpFUqyV57J/j?= =?us-ascii?Q?jU9zN5MAYy/V2zfU8tJMf8TkTQWjmWfOfAfJBJpK?= Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: DM6PR11MB3516.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: ef29a422-71e6-49f2-6447-08da9141e824 X-MS-Exchange-CrossTenant-originalarrivaltime: 08 Sep 2022 02:29:07.9634 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: CQ6owcFTzb0Rrp1TiPZohQMF0ug4BteOxAMlYajHeoCSMs1AmbtkNEax0BVh8FUADCxCcVz02SyuNFpE9xyGKA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR11MB2717 X-OriginatorOrg: intel.com X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Hi, > -----Original Message----- > From: Liu, KevinX > Sent: Wednesday, September 7, 2022 11:18 PM > To: dev@dpdk.org > Cc: Zhang, Yuying ; Xing, Beilei > ; Yang, SteveX ; Liu, Kevin= X > > Subject: [PATCH v4] net/i40e: fix single VLAN cannot work normally >=20 > After disabling QinQ, single VLAN can not work normally. > The reason is that QinQ is not disabled correctly. >=20 > Before configuring QinQ, need to back up and clean MAC/VLAN filters of al= l > ports. After configuring QinQ, restore MAC/VLAN filters of all ports. Whe= n QinQ > is disabled, need to set valid_flags to > 'I40E_AQ_SET_SWITCH_CFG_OUTER_VLAN' and set first_tag to > 'RTE_ETHER_TYPE_QINQ'. >=20 > Fixes: 38e9762be16a ("net/i40e: add outer VLAN processing") > Signed-off-by: Kevin Liu > --- > v2: refine code > --- > v3: refine code > --- > v4: refine code and commit log > --- > doc/guides/nics/i40e.rst | 1 - > drivers/net/i40e/i40e_ethdev.c | 156 ++++++++++++++++++++++----------- > 2 files changed, 104 insertions(+), 53 deletions(-) >=20 > diff --git a/doc/guides/nics/i40e.rst b/doc/guides/nics/i40e.rst index > abb99406b3..15b796e67a 100644 > --- a/doc/guides/nics/i40e.rst > +++ b/doc/guides/nics/i40e.rst > @@ -983,7 +983,6 @@ If FW version >=3D 8.4, there'll be some Vlan related= issues: >=20 > #. TCI input set for QinQ is invalid. > #. Fail to configure TPID for QinQ. > -#. Need to enable QinQ before enabling Vlan filter. > #. Fail to strip outer Vlan. >=20 > Example of getting best performance with l3fwd example diff --git > a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c index > 67d79de08d..4fb0993cc2 100644 > --- a/drivers/net/i40e/i40e_ethdev.c > +++ b/drivers/net/i40e/i40e_ethdev.c > @@ -3909,7 +3909,6 @@ i40e_vlan_tpid_set(struct rte_eth_dev *dev, > struct i40e_pf *pf =3D I40E_DEV_PRIVATE_TO_PF(dev->data- > >dev_private); > int qinq =3D dev->data->dev_conf.rxmode.offloads & > RTE_ETH_RX_OFFLOAD_VLAN_EXTEND; > - u16 sw_flags =3D 0, valid_flags =3D 0; > int ret =3D 0; >=20 > if ((vlan_type !=3D RTE_ETH_VLAN_TYPE_INNER && @@ -3928,10 > +3927,6 @@ i40e_vlan_tpid_set(struct rte_eth_dev *dev, > /* 802.1ad frames ability is added in NVM API 1.7*/ > if (hw->flags & I40E_HW_FLAG_802_1AD_CAPABLE) { > if (qinq) { > - if (pf->fw8_3gt) { > - sw_flags =3D > I40E_AQ_SET_SWITCH_CFG_OUTER_VLAN; > - valid_flags =3D > I40E_AQ_SET_SWITCH_CFG_OUTER_VLAN; > - } > if (vlan_type =3D=3D RTE_ETH_VLAN_TYPE_OUTER) > hw->first_tag =3D rte_cpu_to_le_16(tpid); > else if (vlan_type =3D=3D RTE_ETH_VLAN_TYPE_INNER) @@ > -3940,8 +3935,8 @@ i40e_vlan_tpid_set(struct rte_eth_dev *dev, > if (vlan_type =3D=3D RTE_ETH_VLAN_TYPE_OUTER) > hw->second_tag =3D rte_cpu_to_le_16(tpid); > } > - ret =3D i40e_aq_set_switch_config(hw, sw_flags, > - valid_flags, 0, NULL); > + ret =3D i40e_aq_set_switch_config(hw, 0, > + 0, 0, NULL); > if (ret !=3D I40E_SUCCESS) { > PMD_DRV_LOG(ERR, > "Set switch config failed aq_err: %d", @@ - > 3993,13 +3988,8 @@ static int 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_mac_filter_info *mac_filter; > struct i40e_vsi *vsi =3D pf->main_vsi; > struct rte_eth_rxmode *rxmode; > - struct i40e_mac_filter *f; > - int i, num; > - void *temp; > - int ret; >=20 > rxmode =3D &dev->data->dev_conf.rxmode; > if (mask & RTE_ETH_VLAN_FILTER_MASK) { @@ -4018,50 +4008,18 > @@ i40e_vlan_offload_set(struct rte_eth_dev *dev, int mask) > } >=20 > if (mask & RTE_ETH_VLAN_EXTEND_MASK) { > - i =3D 0; > - 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; > - } > - > - /* > - * Outer VLAN processing is supported after firmware v8.4, > kernel driver > - * also change the default behavior to support this feature. To > align with > - * kernel driver, set switch config in 'i40e_vlan_tpie_set' to > support for > - * outer VLAN processing. But it is forbidden for firmware to > change the > - * Inner/Outer VLAN configuration while there are MAC/VLAN > filters in the > - * switch table. Therefore, we need to clear the MAC table > before setting > - * config, and then restore the MAC table after setting. This > feature is > - * recommended to be used in firmware v8.6. > - */ > - /* Remove all existing mac */ > - RTE_TAILQ_FOREACH_SAFE(f, &vsi->mac_list, next, temp) { > - mac_filter[i] =3D f->mac_info; > - ret =3D i40e_vsi_delete_mac(vsi, &f- > >mac_info.mac_addr); > - if (ret) > - PMD_DRV_LOG(ERR, "i40e vsi delete mac fail."); > - i++; > - } > if (rxmode->offloads & RTE_ETH_RX_OFFLOAD_VLAN_EXTEND) > { > i40e_vsi_config_double_vlan(vsi, TRUE); > - /* Set global registers with default ethertype. */ > - i40e_vlan_tpid_set(dev, RTE_ETH_VLAN_TYPE_OUTER, > - RTE_ETHER_TYPE_VLAN); > - i40e_vlan_tpid_set(dev, RTE_ETH_VLAN_TYPE_INNER, > - RTE_ETHER_TYPE_VLAN); > + if (!pf->fw8_3gt) { > + /* Set global registers with default ethertype. > */ > + i40e_vlan_tpid_set(dev, > RTE_ETH_VLAN_TYPE_OUTER, > + > RTE_ETHER_TYPE_VLAN); > + i40e_vlan_tpid_set(dev, > RTE_ETH_VLAN_TYPE_INNER, > + > RTE_ETHER_TYPE_VLAN); > + } > } else { > i40e_vsi_config_double_vlan(vsi, FALSE); > } > - /* Restore all mac */ > - for (i =3D 0; i < num; i++) { > - ret =3D i40e_vsi_add_mac(vsi, &mac_filter[i]); > - if (ret) > - PMD_DRV_LOG(ERR, "i40e vsi add mac fail."); > - } > - rte_free(mac_filter); > } >=20 > if (mask & RTE_ETH_QINQ_STRIP_MASK) { > @@ -6176,9 +6134,103 @@ i40e_dev_init_vlan(struct rte_eth_dev *dev) stat= ic > int i40e_vsi_config_double_vlan(struct i40e_vsi *vsi, int on) { > + struct i40e_mac_filter_info *vmac_filter[RTE_MAX_ETHPORTS]; > struct i40e_hw *hw =3D I40E_VSI_TO_HW(vsi); > + struct i40e_pf *pf =3D I40E_VSI_TO_PF(vsi); > + struct i40e_vsi *vvsi[RTE_MAX_ETHPORTS]; > + struct i40e_mac_filter_info *mac_filter; > + u16 sw_flags =3D 0, valid_flags =3D 0; > + int vnum[RTE_MAX_ETHPORTS]; > + struct i40e_mac_filter *f; > + int port_num =3D 0; > + int i, num, j; > + void *temp; > + int ret =3D 0; >=20 > - return i40e_aq_set_port_parameters(hw, vsi->seid, 0, 1, on, NULL); > + ret =3D i40e_aq_set_port_parameters(hw, vsi->seid, 0, 1, on, NULL); > + if (ret !=3D I40E_SUCCESS) { > + PMD_DRV_LOG(ERR, "Failed to set port params"); > + return -1; > + } > + > + if (pf->fw8_3gt) { > + /* back up and clean mac/vlan filters of all ports */ > + for (j =3D 0; j < RTE_MAX_ETHPORTS; j++) { > + /* > + * It is impossible to confirm whether the port is pf > + * only through the state field, so it is also necessary > + * to verify the intr_handle field. > + */ > + if (rte_eth_devices[j].state !=3D RTE_ETH_DEV_UNUSED > && > + > rte_eth_devices[j].intr_handle) { Use vsi_id to check if dev is pf, not intr_handle or you can delete this va= lidation since just main_vsi will be transfer to this function. > + struct rte_eth_dev *tmp_dev =3D > &rte_eth_devices[j]; > + struct i40e_pf *tmp_pf =3D > + I40E_DEV_PRIVATE_TO_PF(tmp_dev- > >data->dev_private); > + struct i40e_vsi *tmp_vsi =3D tmp_pf->main_vsi; > + i =3D 0; > + num =3D tmp_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; > + } > + /* > + * Outer VLAN processing is supported after > firmware v8.4, > + * kernel driver also change the default > behavior to support > + * this feature. To align with kernel driver, set > switch > + * config in 'i40e_vlan_tpid_set' to support for > outer VLAN > + * processing. But it is forbidden for firmware > to change the > + * Inner/Outer VLAN configuration while there > are MAC/VLAN > + * filters in the switch table. Therefore, we > need to clean > + * MAC/VLAN filters of all ports before setting > config, and > + * then restore the MAC table after setting. This > feature is > + * recommended to be used in firmware v8.6. > + */ > + /* Remove all existing mac */ > + RTE_TAILQ_FOREACH_SAFE(f, &tmp_vsi- > >mac_list, next, temp) { > + mac_filter[i] =3D f->mac_info; > + ret =3D i40e_vsi_delete_mac(tmp_vsi, &f- > >mac_info.mac_addr); > + if (ret) > + PMD_DRV_LOG(ERR, "i40e vsi > delete mac fail."); > + i++; > + } > + vmac_filter[port_num] =3D mac_filter; > + vvsi[port_num] =3D tmp_vsi; > + vnum[port_num] =3D num; > + port_num++; > + } > + } > + > + if (on) { > + sw_flags =3D I40E_AQ_SET_SWITCH_CFG_OUTER_VLAN; > + valid_flags =3D > I40E_AQ_SET_SWITCH_CFG_OUTER_VLAN; > + hw->first_tag =3D > rte_cpu_to_le_16(RTE_ETHER_TYPE_VLAN); > + } else { > + valid_flags =3D > I40E_AQ_SET_SWITCH_CFG_OUTER_VLAN; > + hw->first_tag =3D > rte_cpu_to_le_16(RTE_ETHER_TYPE_QINQ); > + } > + > + ret =3D i40e_aq_set_switch_config(hw, sw_flags, valid_flags, 0, > NULL); > + if (ret) { > + PMD_DRV_LOG(ERR, > + "Set switch config failed > aq_err: %d", > + hw->aq.asq_last_status); > + } > + > + /* restore mac/vlan filters of all ports */ > + for (j =3D 0; j < port_num; j++) { > + mac_filter =3D vmac_filter[j]; > + for (i =3D 0; i < vnum[j]; i++) { > + ret =3D i40e_vsi_add_mac(vvsi[j], &mac_filter[i]); > + if (ret) > + PMD_DRV_LOG(ERR, "i40e vsi add mac > fail."); > + } > + rte_free(mac_filter); > + } > + } > + > + return ret; > } >=20 > static int > -- > 2.34.1