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 E41EFA0C45; Wed, 20 Oct 2021 09:41:47 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9E5F740150; Wed, 20 Oct 2021 09:41:47 +0200 (CEST) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by mails.dpdk.org (Postfix) with ESMTP id 6F68B40142 for ; Wed, 20 Oct 2021 09:41:46 +0200 (CEST) X-IronPort-AV: E=McAfee;i="6200,9189,10142"; a="215883000" X-IronPort-AV: E=Sophos;i="5.87,166,1631602800"; d="scan'208";a="215883000" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Oct 2021 00:41:45 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.87,166,1631602800"; d="scan'208";a="718817458" Received: from orsmsx601.amr.corp.intel.com ([10.22.229.14]) by fmsmga006.fm.intel.com with ESMTP; 20 Oct 2021 00:41:44 -0700 Received: from orsmsx602.amr.corp.intel.com (10.22.229.15) by ORSMSX601.amr.corp.intel.com (10.22.229.14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.12; Wed, 20 Oct 2021 00:41:44 -0700 Received: from ORSEDG601.ED.cps.intel.com (10.7.248.6) 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.2242.12 via Frontend Transport; Wed, 20 Oct 2021 00:41:44 -0700 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (104.47.58.175) by edgegateway.intel.com (134.134.137.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2242.12; Wed, 20 Oct 2021 00:41:43 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BoxY30AdDoITR+kIZ+sPOM5sFF8UIWTSbrtsLcqlvwCSMef3mx1mUlQfLvvf0RWRQHRHQrgGPOnBtyTM/XRxsQ9KTGSU2gIV9jZrBJVb1b/CKQbYUK75/FcfS3w3mKP4mdvTPoTDO9UOGlr9BvDDiGBf+J2pLV6SCJVXqaKmaWf1Rp5c9oo0VS7x1eHHtbWkntkmrIKaC6pfdtcxYz7vI/ZKiAgAo06QS9nMbGasZVVkL4Fy/SWi6XF1xbZobik0GNrdUdrueG44XJxYzAn7vR1z5UqQfhtQLWB1/+xT90XiM8RQOX0mrYi11oTNAmQ6AF8iKjtSjiOdJALZXxDKvA== 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=JqNM7/0MQdDpfFCpM50HtgHyCFEu93UQwP2bR45a0tY=; b=naSt1PwfbN5NVPI9SpXIquA9aMO5eiYWXsHJ4lIvowgwv/eFMal8jRtEMxs0fbdrzWYhuD2KyQLEyA85dIusTnxjros2OwFZWi3BiVFQ2/pRVtFfw6IbTGMXcSY2eZeVM/ou6+8AtJ2txq7OBvtuWfWG4EVWQx2CQB4Y8pLzJGVMhfbNyOn8MsVVYRG7m4LIDTy5YP6kAqAr/vrSvqsK0cJCjHFZluAmBgxF0FGZh1XYKeN1Iabr+O0L+jmCScwA6YIYzzqi5UwQGRU1XdnlO+4Eb0bm3FN+iFbayaeXT3xRlcJDNalqiv+4fRbEnEH+s/2TnU1aSm5cs6x/RQv2vw== 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 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.onmicrosoft.com; s=selector2-intel-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=JqNM7/0MQdDpfFCpM50HtgHyCFEu93UQwP2bR45a0tY=; b=FgjSASIR/Qt6qFHdN76XedUBm76k1q+iAPD5IBjAVQlR9INfOkyZrtY0P7nrDGjkMCC+wSj0eJcRc7p1Itohius8Lgo5FR+mU+HtOMhL2gP+8UwbpmAoORqoddKlrAkrJ1XXSPNF8COQDCbUnAS5DvCHD8hjmQUBmabv45rUem0= Authentication-Results: huawei.com; dkim=none (message not signed) header.d=none;huawei.com; dmarc=none action=none header.from=intel.com; Received: from PH0PR11MB5000.namprd11.prod.outlook.com (2603:10b6:510:41::19) by PH0PR11MB4901.namprd11.prod.outlook.com (2603:10b6:510:3a::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4628.16; Wed, 20 Oct 2021 07:41:41 +0000 Received: from PH0PR11MB5000.namprd11.prod.outlook.com ([fe80::bd7d:29be:3342:632c]) by PH0PR11MB5000.namprd11.prod.outlook.com ([fe80::bd7d:29be:3342:632c%5]) with mapi id 15.20.4608.018; Wed, 20 Oct 2021 07:41:41 +0000 Message-ID: <8decd3d4-4370-2f89-44d5-3e0dd848a628@intel.com> Date: Wed, 20 Oct 2021 08:41:33 +0100 Content-Language: en-US To: "lihuisong (C)" , "Min Hu (Connor)" , CC: References: <20210922033630.41130-1-humin29@huawei.com> <20211011092811.55172-1-humin29@huawei.com> From: Ferruh Yigit X-User: ferruhy In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-ClientProxiedBy: LO4P123CA0279.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:195::14) To PH0PR11MB5000.namprd11.prod.outlook.com (2603:10b6:510:41::19) MIME-Version: 1.0 Received: from [192.168.0.206] (37.228.236.146) by LO4P123CA0279.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:195::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4628.16 via Frontend Transport; Wed, 20 Oct 2021 07:41:40 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: e808218f-e2c7-4ba0-11a5-08d9939d0e8c X-MS-TrafficTypeDiagnostic: PH0PR11MB4901: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:9508; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Vvay/uZ5cHg5EWv9fBu7tC2V3Ep3/ISlwzEFmlWUD11ttfp2tehRkX7Gs1JHf0HCY4Jlnh41gRWTjrN1Ts+IW9+hoW4NG4FNYJEO6TxK3wkPIDNwYfL/O+A0/Km6zrbIT5EUcNDUcltNlW69hsttVmtm476zIz9NYZ+APxtTpdMxPzvfl0UoeBUr4cSVR8tlxPAW730+obj0yRTpYbwLyHUmyJZtpqb7hJFu/7OwM6ZXdh7+Gh3Ibk06BN8o0GV3RtNmYpSoYISg+ojEBN0XBmXWofVm95leQEfisG5BMAtiJdLt+SIwI7w9aaX+d625RjGXzzk0oMeSzqOzNtBm4O5SFU8W1lMdvvvpaDJy5rtfsaX0JuLtSscRDjgpDIu8gxZNc9b0fSb/CYAqVg0XQ0HaBhbCyq2qwFYvYbvz8n42fRTiyB+ww6gf93eI3eDM6318kQT7/DWH3JIVytgURjwT5gxkx5Y7jbLLjA7iTDGoYtQxGDqsEc4dMzNisjVYUjtoxC25w6DO4FInCMlViutUnoiN1+qb1dKCaKdTxiCSt7MqCrgdhIrzyRV5FJi0L6XCVE+BmntNjjpdl2eOBYmLQVxtPwBcEidjdsC+4vWH67fbn+XemuR/zUWfOoUGZcZ4obzr2MP9hM1KhdkcdHc9VCFmmh9mTvMAPNZwe8LBahYdzkCaZGEs1xNmKVIv7+XyQZ23Qe4cpOTQD5uqcQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PH0PR11MB5000.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(366004)(16576012)(956004)(186003)(2616005)(82960400001)(6666004)(8936002)(110136005)(316002)(26005)(36756003)(2906002)(4326008)(86362001)(53546011)(38100700002)(66946007)(44832011)(31696002)(83380400001)(508600001)(8676002)(66556008)(5660300002)(31686004)(6486002)(66476007)(45980500001); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?MWJENDN2aCtma0t4RGpoakZNa1NaeDhkRkdac2lTdEdFUEt6cjZvNmlHcnk1?= =?utf-8?B?SENteHFWZWl0VnNFQk5ncndzVlZUSE95a21FRHBvWUNvTk1Jejk4VXdpSzVZ?= =?utf-8?B?bllDMnFmbHd1LzRjOHNXa1NTcHFWUTNhKzJ3bVVvMjRkdVExL2QwY2x2RTVJ?= =?utf-8?B?NldXTThkeGFjc00zbjVsb0k3dXBZZENJak9kbGFWNFJEMElmOUk5cE1ySVdK?= =?utf-8?B?bmxqMmZTdTh1K21YZDhjUWdvcUhldWFOb2xFcUV6TCtmU0NEWSt1L01JOGxl?= =?utf-8?B?b1gyMGRSY0VqOU1LYnRJalJUdTZ5a21UOTRuK2hkbzd6SjBZbkdwYnBjMFht?= =?utf-8?B?MVNESjlDM29lSVc0MG14eUtGVUsvdkNxVzMvYkFXbVlJT0xkZ0wxemYyeW9U?= =?utf-8?B?eFJJcjY5L0RLMDIyTklkYlFFc0QyeGw3Sm9MMnB3cGlTUWsxaGFiWGZQRW5w?= =?utf-8?B?Y0I3cGE5bkhYV0M3UEVMN3plWjF2T0xkWm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hMeTRSNEZMVjNFTHpIRDIzOXdKQ3pSZmxqM0pO?= =?utf-8?B?anRsYW5NOGxBSEpQUUMxZkZwSjVvb3UwRVN6T0N1RUJvdVZiYjRURHltcURn?= =?utf-8?B?cVhrS3I3UExzVHNGM3EzRkZrK28zMXkrNFFncldQaGFJQjFmMVdZbzgzUklD?= =?utf-8?B?UVFnUk1BcWd1RHFxZVFpQ0JkWjBOQUp2TVJvNXUzUmdOcFNWV2cyU0lrZTRy?= =?utf-8?B?TnB4WUlGRnlrNThNS1JFbVVHTjNhdG1FVTBsay9XcUpZYkNQSmxyWm1GUVRp?= =?utf-8?B?elE4SDBEZkhwWDFrTjBjWlBqTzZwbzBvLys1V3haVnY2bEpOajR4a0NCNXo2?= =?utf-8?B?YTB1QTVxaktDTi9RQkJlK2VDeHVFYm5NZHBMU2M2RTNoZktpcDFzamxSWEtu?= =?utf-8?B?elhlbXIrem1CbUZMb1lpaWMrQTRUazhzZXVUOGRqNG5PcGQxWFRBYnAvMy9H?= =?utf-8?B?WnB2SUYwcE96TnhieUJSQzF0cjhpdE0rSDJRSmkxMC90cXVsVTNCRHlxc2pt?= =?utf-8?B?WVhPMUNDTkQ4aW9WQkNKektkRXZmQUdEckI2Q0tFQVNqTC9iKzhYNUVCYTF3?= =?utf-8?B?MmtaRG0vcWJYaEZEK0p2RVJBL3dnWUVXek9zYkdNNnplR2VDVjk5Nnd2VG9i?= =?utf-8?B?bXVOb3NpcWRYbjRBV1FwKzc1ZU9vK1BwcHpUa1h6d2ZvVlVpVDdtR2ZJQ3h1?= =?utf-8?B?ekdwdTVrREMrMmxuazdBVDgrWmxoQ1RreFJsbVFKc0RUNmt4aEorb0JLSm83?= =?utf-8?Q?Eg3TN9K6pWBA76TyQ3nZLTI=3D?= X-MS-Exchange-CrossTenant-Network-Message-Id: e808218f-e2c7-4ba0-11a5-08d9939d0e8c X-MS-Exchange-CrossTenant-AuthSource: PH0PR11MB5000.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Oct 2021 07:41:41.5563 (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: IbSHyRRylvuQpbyrAYY5fKoZCbJf1744RXNtim6Hs7KgNaLl1kx9qEXYSOwS+P4XZcd5vflkFMveRr4ZWIVHSA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR11MB4901 X-OriginatorOrg: intel.com Subject: Re: [dpdk-dev] [PATCH v2] ethdev: fix one MAC address occupies two index in mac addrs 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 Sender: "dev" On 10/20/2021 7:49 AM, lihuisong (C) wrote: > Hi Ferruh > > 在 2021/10/20 1:45, Ferruh Yigit 写道: >> On 10/11/2021 10:28 AM, Min Hu (Connor) wrote: >>> From: Huisong Li >>> >>> The dev->data->mac_addrs[0] will be changed to a new MAC address when >>> applications modify the default MAC address by >>> rte_eth_dev_default_mac_addr_set() API. However, If the new default >>> MAC address has been added as a non-default MAC address by >>> rte_eth_dev_mac_addr_add() API, the rte_eth_dev_default_mac_addr_set() >>> API doesn't remove it from dev->data->mac_addrs[]. As a result, one MAC >>> address occupies two index capacities in dev->data->mac_addrs[]. >>> >> >> Hi Connor, >> >> I see the problem, but can you please clarify what is the impact to the end user? >> >> If application does as following: >>   rte_eth_dev_mac_addr_add(MAC1); >>   rte_eth_dev_mac_addr_add(MAC2); >>   rte_eth_dev_mac_addr_add(MAC3); >>   rte_eth_dev_default_mac_addr_set(MAC2); >> >> The 'dev->data->mac_addrs[]' will have: "MAC2,MAC2,MAC3" which has 'MAC2' duplicated. >> >> Will this cause any problem for the application to receive the packets >> with 'MAC2' address? >> Or is the only problem one extra space used in 'dev->data->mac_addrs[]' >> without any other impact to the application? > I think it's just a waste of space. True, it is a waste. But if there is no other visible user impact, we can handle the issue with lower priority and clarifying the impact in commit log helps to others. >> >>> This patch adds the logic of removing MAC addresses for this scenario. >>> >>> Fixes: 854d8ad4ef68 ("ethdev: add default mac address modifier") >>> Cc: stable@dpdk.org >>> >>> Signed-off-by: Huisong Li >>> Signed-off-by: Min Hu (Connor) >>> --- >>> v2: >>> * fixed commit log. >>> --- >>>   lib/ethdev/rte_ethdev.c | 15 +++++++++++++++ >>>   1 file changed, 15 insertions(+) >>> >>> diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c >>> index 028907bc4b..7faff17d9a 100644 >>> --- a/lib/ethdev/rte_ethdev.c >>> +++ b/lib/ethdev/rte_ethdev.c >>> @@ -4340,6 +4340,7 @@ int >>>   rte_eth_dev_default_mac_addr_set(uint16_t port_id, struct rte_ether_addr *addr) >>>   { >>>       struct rte_eth_dev *dev; >>> +    int index; >>>       int ret; >>>         RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV); >>> @@ -4361,6 +4362,20 @@ rte_eth_dev_default_mac_addr_set(uint16_t port_id, struct rte_ether_addr *addr) >>>       if (ret < 0) >>>           return ret; >>>   +    /* >>> +     * If the address has been added as a non-default MAC address by >>> +     * rte_eth_dev_mac_addr_add API, it should be removed from >>> +     * dev->data->mac_addrs[]. >>> +     */ >>> +    index = eth_dev_get_mac_addr_index(port_id, addr); >>> +    if (index > 0) { >>> +        /* remove address in NIC data structure */ >>> +        rte_ether_addr_copy(&null_mac_addr, >>> +                    &dev->data->mac_addrs[index]); >>> +        /* reset pool bitmap */ >>> +        dev->data->mac_pool_sel[index] = 0; >>> +    } >>> + >> >> Here only 'dev->data->mac_addrs[]' array is updated and it assumes >> driver removes similar duplication itself, but I am not sure if this is >> valid for all drivers. >> >> If driver is not removing the duplicate in the HW configuration, the driver >> config and 'dev->data->mac_addrs[]' will diverge, which is not good. > The same MAC address does not occupy two HW entries, which is also a > waste for HW. After all, HW entry resources are also limited. > The PMD should also take this into account. > So, I think, we don't have to think about it here. I am not sure all PMD take this into account, I briefly checked the ixgbe code and I am not sure if it handles this. Also it is possible to think that this responsibility is pushed to the application, like application should remove a MAC address before setting it as default MAC... >> >> What about following logic to be sure HW configuration and >> 'dev->data->mac_addrs[]' is same: >> >>   index = eth_dev_get_mac_addr_index(port_id, addr); >>   if (index > 0) >> rte_eth_dev_mac_addr_remove(port_id, addr); >>   (*dev->dev_ops->mac_addr_set)(dev, addr); > The logic above seems to be good. But if .mac_addr_set() failed to > execute, the addr has been removed from HW and 'dev->data->mac_addrs[]'. > It's not good. > Agree. So may need to get a copy of 'addr' and add it back on failure. The concern I have to call 'rte_eth_dev_mac_addr_remove()' after 'dev_ops->mac_addr_set()' is, it may result different behavior on different PMDs. For the PMDs that clean the redundant MAC address via 'dev_ops->mac_addr_set()' may try to remove (although it will fail) the new set default MAC address. That is why first remove the MAC and later add it back as default seems safer to me. > Hope for your reply.  Thanks. >>>       /* Update default address in NIC data structure */ >>>       rte_ether_addr_copy(addr, &dev->data->mac_addrs[0]); >>> >> >> .