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 D6E97A0C43; Wed, 20 Oct 2021 18:32:44 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A7A7B410FA; Wed, 20 Oct 2021 18:32:25 +0200 (CEST) Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by mails.dpdk.org (Postfix) with ESMTP id 0F049410E9 for ; Wed, 20 Oct 2021 18:32:22 +0200 (CEST) X-IronPort-AV: E=McAfee;i="6200,9189,10143"; a="227594770" X-IronPort-AV: E=Sophos;i="5.87,167,1631602800"; d="scan'208";a="227594770" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Oct 2021 09:32:18 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.87,167,1631602800"; d="scan'208";a="567618884" Received: from orsmsx606.amr.corp.intel.com ([10.22.229.19]) by FMSMGA003.fm.intel.com with ESMTP; 20 Oct 2021 09:32:17 -0700 Received: from orsmsx601.amr.corp.intel.com (10.22.229.14) by ORSMSX606.amr.corp.intel.com (10.22.229.19) 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 09:32:16 -0700 Received: from orsedg603.ED.cps.intel.com (10.7.248.4) 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 via Frontend Transport; Wed, 20 Oct 2021 09:32:16 -0700 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (104.47.56.176) 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.2242.12; Wed, 20 Oct 2021 09:32:16 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ftUm64OXhjzbdnOmRw3J4opWdH7Lf99NkeZ+zc7Ps/CoCxc6uuB3bbbSyfxSe0cVYm79kAZ3l5sRPe7JO7vtcgRvXKx34+RidL4ChsfBhGv24+9yko1/rSIU9ji2cDqStO623xCpooqz9n6P9nyp+jvS7aUcMMtwUKwrZqPp74T4a28TJ65ajo6NHhOTaCJq85/Qb/hlY7sqMqVKMJ9z7bYhSo4ZR8Da2ZJYwhYXz2/Hk+kqyD5LzjtOZOQnFIslTsbcxQO2IFz726iWXg5Endow6cYqIg3RHqO/gcGwNea7U7oqe8fu3uY1YgrgBKE4xcyAtQ2ulpCXCYxLS+BI1Q== 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=ALRtguW5/mTukPePtRPmux5xkJCXHZ9MTWQyKDjq76I=; b=ehAp8RA5kcTtMHohbVMQdbg0bMQDsBclccqR0fmRXbbuQDYXjBDwOjbG8IDm+Ig9THbyUqSdkhuO5KBq3Nl5SSFyuInLnQkN6A6hPqAwWD4vpxp1AFVF5KLjBJcKLBOv0VEN/x8QVISKlbSii3fcwqzuP1+nQbf0Jm7VegUGxZ6ig1MKNDGpCTocXIas+8vAoduiQGqHixpBmzHcrCukZxRAveJJ33zCFDoCNwTpEGTag3JTEBKOju4cgF31H7mKVasE70BmylHmgQRwybBAvuWXf6HrQhavqIOPcOVxkwofo83tdqUJxHplGbCDK5D0z++qqA2LfBq1xSKYFX232w== 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=ALRtguW5/mTukPePtRPmux5xkJCXHZ9MTWQyKDjq76I=; b=PDHuSr9fVxZ5Uwy3CA7idAxx+coppU5BKCrSUNWT8z/vARyO0eGB4L36ipPEFo7EDKUQtVvBrms6z7Wwjbr2jMSYyEPm3X/9agucepI187Cg98RY8QrdMfkXIIShuH8K4Wzg6bEKlBCsT+HjZc6TWslurpa2BECklov0gsIIT/g= Authentication-Results: redhat.com; dkim=none (message not signed) header.d=none;redhat.com; dmarc=none action=none header.from=intel.com; Received: from PH0PR11MB5000.namprd11.prod.outlook.com (2603:10b6:510:41::19) by PH7PR11MB5886.namprd11.prod.outlook.com (2603:10b6:510:135::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4608.17; Wed, 20 Oct 2021 16:32:15 +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 16:32:15 +0000 Message-ID: Date: Wed, 20 Oct 2021 17:32:10 +0100 Content-Language: en-US To: Kevin Traynor , "lihuisong (C)" , "Min Hu (Connor)" , CC: References: <20210922033630.41130-1-humin29@huawei.com> <20211011092811.55172-1-humin29@huawei.com> <8decd3d4-4370-2f89-44d5-3e0dd848a628@intel.com> <31cd92b1-d388-bd50-963a-8a85a924c0a2@redhat.com> From: Ferruh Yigit X-User: ferruhy In-Reply-To: <31cd92b1-d388-bd50-963a-8a85a924c0a2@redhat.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-ClientProxiedBy: LO2P265CA0359.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:d::35) 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 LO2P265CA0359.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:d::35) 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 16:32:14 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: cf0362a5-4525-42c4-1ddd-08d993e72d24 X-MS-TrafficTypeDiagnostic: PH7PR11MB5886: 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: aSOCM+EH0pKea1WzOQOCAQK2Mgr2SHgDNlRI37NVM2l9l/FbMbcx1sF0Ol+/Pq7SF/M+k7Ui+pXd80lXe+bgi+fOwqcLVYT/fNjCjDhaLXJVMukf1GDfeyzjEpC0q0WF4bpfRZBvBXPjWkmJef/AUjbzRbZckJJvzTUFyyimQ3OIE0+FN7GAyyp0BD1T4PivrDMfZnHmvH5SLXbBJgJIxc3VI7WvwgVmwTFLmhRC7NWlU/AZReZToCd+EyHinkDA4o2EgKxeS+Viho9WXPFZ6d3iOfW48fmIVwW19tew8OKZJXFZjehjQITnVQLQM7biog0P/YogwCKu9ZXih7eAsHJZ3VokT+fyHqvluMB6ry+UAyivUyiiKwxb5fqkXg+O6u693iSbncGVTIw1ON1xYxCEs7CuqtWZpsj+0fOtikde/x/SpSCEyUm7OF5T1U00i0Ajdn33bG6rULGlwfeV3vcBSh7IWIPgCsQxlmqtRWqJqQ1SIsL3kAtjtaCyu0bZR1ZcUyM2D/2v75jUA4GQaUf1Uvo8JiKnv/W4SeZfu8Nv+2qCcF0fhNCcFHe+RzY85WTpCewdUfCsZjtyx9ImUjUsQ0Y6SMuPz2FG4D7Wi3X9/AuruGzKeOQFxuN0ZhT36gluoUcvtZxgW3Kn+HMB6zCjIa/aL+ok70xOW/iwHSRxspsYUCfS+PcV2gVuXglj9qqcMrZFrk6SaMjqztjrOg== 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)(186003)(2906002)(44832011)(508600001)(5660300002)(86362001)(66946007)(31696002)(66476007)(82960400001)(36756003)(110136005)(2616005)(6666004)(31686004)(66556008)(83380400001)(8676002)(6486002)(316002)(956004)(26005)(4326008)(16576012)(38100700002)(8936002)(53546011)(45980500001); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?ajVyalJqVVQ2Sk9VeEZqT2I1YjRtN2tVeUVJN2lHMUpTTktzK25oTHR3M1Rp?= =?utf-8?B?ZUp3WE9VT0pkSXh6WE9uNzY4bkorNGRMRE9YY3k5QUpBT1F5VWduYWdLRTcv?= =?utf-8?B?UWRVS29VOWhBeW92UGU1WEFQd0o2S1pUMVVsdHV0VVhBMjE5MDNHYUZkbERj?= =?utf-8?B?YUxNRnpjWjhaUnYrMU5xQ2VaelVTWGsvOFQvSGprT0ZCRkhvb3psbXFXek1Q?= =?utf-8?B?Wll4WGdCcEkyVHNyaXJQdFptTWxDZXk3d09IVFZuSUMzeVJ3a0dsOGpxYkxt?= =?utf-8?B?MklkWXZSSnQ0WnJCeW5ON21nUURLeTBKRGhocVpWM05wWDFjMmczT3JuOWNT?= =?utf-8?B?bytZKytOUHZ5cU9RS3ErS25PUkF0LzI5TTNvbVRaSWR1RGV1cjY4SHY5K2k3?= =?utf-8?B?SlZHNCszMkt5L3BvOWFnVjFmb0ZJQUZmM1FVd3V0R20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MUxCdy9SY1pqT09hUjRQR3hkdFRueW9J?= =?utf-8?B?Zk1lTDJ4N1Y4OW91M1F4d3NNTkl5cmhqMFF0SnI1TkhSaG1UMDNtNWdqZ2VP?= =?utf-8?B?ak9JaTJtZzh3TFEvbktWUW1BREV6TVREVU5hU0VWZ3ZIQXhQSDdyTURaUmxy?= =?utf-8?B?eUJ5bjNCY290V3E1WTBKc0ovTTkwSVM2S3JWTjlFZ3RPSGNxZXhrRGQ5Yy9O?= =?utf-8?B?UFdSWDRzNEljb0tidzhIeUtrcWlFTm4zL090WERmbWVGejNWTit0S2tIUGFw?= =?utf-8?B?bVVnUlkzYUdJUVl2VGEvUnQxbkMwdWtyQTRmUnZDSHdLcjdjNjNxd3JtWFdC?= =?utf-8?B?aGJzV0JXMThPS2QwVlpHT0dtN2pqbkdHNi9YKzZnbkFQUE4vZXRmN3R3MWNE?= =?utf-8?Q?IcZZJMzJVdqrxdUMG48ztgtnevxJ1AVWrNt6zg+?= X-MS-Exchange-CrossTenant-Network-Message-Id: cf0362a5-4525-42c4-1ddd-08d993e72d24 X-MS-Exchange-CrossTenant-AuthSource: PH0PR11MB5000.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Oct 2021 16:32:15.6224 (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: ferruh.yigit@intel.com X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR11MB5886 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 11:15 AM, Kevin Traynor wrote: > On 20/10/2021 08:41, Ferruh Yigit wrote: >> 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... >> > > Yes, the API view is more important than saving one entry in an array. From API perspective with this patch, > > set_default(MAC1) > add(MAC2) > add(MAC3) > add(MAC4) > default=MAC1, Filters=MAC2, MAC3, MAC4 > > set_default(MAC2) > default=MAC2, Filters= MAC3, MAC4 > > set_default(MAC3) > default=MAC3, Filters= MAC4 > > set_default(MAC4) > default=MAC4, Filters= > > set_default(MAC5) > default=MAC5, Filters= > > Did I get it right? If so, it seems wrong to silently remove the filters. In which case, it would be easier to just not remove them in the first place (current behaviour). > Yep, this is the updated behavior. And agree it looks wrong when you show like this. (btw, this is only ethdev record of MAC filters, what is updated in this patch, HW still may be keeping all filters.) > If they really need to be removed from the filter list when they are set_default(), then perhaps they should be restored to it when there is a new set_default(). > I am for keeping current behavior. Application always can explicitly remove a MAC filter before setting it default if required. >>>> >>>> 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]); >>>>> >>>> >>>> . >> >