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 843B1A00C5; Mon, 14 Feb 2022 14:37:51 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 7292140DDA; Mon, 14 Feb 2022 14:37:51 +0100 (CET) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by mails.dpdk.org (Postfix) with ESMTP id D32C54067E for ; Mon, 14 Feb 2022 14:37:49 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1644845870; x=1676381870; h=message-id:date:to:references:from:subject:in-reply-to: content-transfer-encoding:mime-version; bh=BaTtwtPxcY17WA2g58lASrVzheCQHuxwUTypiYxhVMc=; b=W90NeZkwRCG9mBHPpydgTrPX4kgds9tOJAL7lLiabkR4fH6I4fmkxU0b wcU9aQ4o6K3CXT5G4kVHcbNjl4hKz5yBl0uzFf/HS6ZCI6kHXhonDe77B L9ugcAaJ01jAv7O5X+r+gwWTKKrrKBacyKk30u6ls36TmbFtiSnoQS9H1 gBZfuugBzuBpevUXF3Kx0cw50JwdAmV5TT25cfQmMlk9Va58taDhId2gj CD4Y7bw+e7rHshnFIufnzmYEWYzwTkd4oKka4aWnXbypfipFjSklvZzV5 p0r6a88UIrhIf4gMF43wwJmQaaayIdKZ8kLtVLs6Qg427wotWmd776P4L Q==; X-IronPort-AV: E=McAfee;i="6200,9189,10257"; a="313366315" X-IronPort-AV: E=Sophos;i="5.88,368,1635231600"; d="scan'208";a="313366315" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Feb 2022 05:37:48 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.88,368,1635231600"; d="scan'208";a="635198019" Received: from orsmsx601.amr.corp.intel.com ([10.22.229.14]) by orsmga004.jf.intel.com with ESMTP; 14 Feb 2022 05:37:48 -0800 Received: from orsmsx609.amr.corp.intel.com (10.22.229.22) 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.2308.20; Mon, 14 Feb 2022 05:37:48 -0800 Received: from ORSEDG601.ED.cps.intel.com (10.7.248.6) by orsmsx609.amr.corp.intel.com (10.22.229.22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.20 via Frontend Transport; Mon, 14 Feb 2022 05:37:48 -0800 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (104.47.58.105) 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.2308.20; Mon, 14 Feb 2022 05:37:47 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eSADj2BLhjhdjWSGFSGiVRR5qwcpwtmQwFii+XG2FcceLaNmzjwFSJEJhgIU5+pV3Uz/0GKb9xIDNjnguJPIjRN+jWpyA6+GasSOSTiC/Rh/eUbkERHwzFgHqM4+EHjMp/K49NYwk846P4RGOkBYaUV9V68j+c2Rp9BWZoI6Kl/0NYp2nMOsg2oQeRbuq0EnjqBLVfOw1TUQ0REtjWD8Ubx26D0tsvjTSb3BpwGrert9xMW+ldplPCDAudyFPSHL0Rq3j8c0Izil5KTMpO+0oTa/xc6dkmmF7VPkDzjCQ+Jvp4nXmpNdhr225pCueaL3hel+x0iHkzJH1ujJSHiJwg== 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=0d4N3Msmzehse7wEoXVBgpmdYaEs3C80ZzR82dyWbuY=; b=A18MAtIoY3DlFhE9cIh8/cYThhmBFHi3XCE8vrql0j4wNydhQgdSMoNI0hljgr9acy0qCZ+YBNXkjTXApf5SJdvp2C8PW+PstOVAA2nJV9o40Cx2ybBiK6IuQdQMvy6E/WvdG/YJx2n48ny5Ff2j5WuBRZEqEa+qXkMIV0HNGmNo611H4jdx7P8oAj5/rhK8BNk3Pg4jd0a3nUmp74wIrDCOPzU9uSsJDWDel52NpoW6MLx8vtBoMHiNxKw9pmKqnMMQE4Vfbcm1Z9h/v4q0ysXNhoaWyTtZfwrfs9StsT87RB35Yt8GsN3THm8vPdpnbQsl0Ntk16EwHw2UheasXw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; Received: from PH0PR11MB5000.namprd11.prod.outlook.com (2603:10b6:510:41::19) by SN6PR11MB2654.namprd11.prod.outlook.com (2603:10b6:805:54::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4975.15; Mon, 14 Feb 2022 13:37:46 +0000 Received: from PH0PR11MB5000.namprd11.prod.outlook.com ([fe80::98be:5506:5020:28a2]) by PH0PR11MB5000.namprd11.prod.outlook.com ([fe80::98be:5506:5020:28a2%4]) with mapi id 15.20.4975.019; Mon, 14 Feb 2022 13:37:46 +0000 Message-ID: Date: Mon, 14 Feb 2022 13:37:40 +0000 Content-Language: en-US To: , References: <20220214112541.29782-1-spinler@cesnet.cz> <20220214112541.29782-6-spinler@cesnet.cz> From: Ferruh Yigit Subject: Re: [PATCH 6/6] drivers/nfb: add support for more MAC addresses X-User: ferruhy In-Reply-To: <20220214112541.29782-6-spinler@cesnet.cz> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-ClientProxiedBy: LO2P265CA0279.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:a1::27) To PH0PR11MB5000.namprd11.prod.outlook.com (2603:10b6:510:41::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: e30c2268-d7bc-48ea-f4a9-08d9efbf2f11 X-MS-TrafficTypeDiagnostic: SN6PR11MB2654:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4714; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 0tCNXHZiBcRrRmqvVVnBVr9eoPQX/mvfDmp1Dty0BaCmezYfzM9ngsWgjSMvqRGzhMevupqsW0kFwsiyD7ZXMS0YS91BqTUA42TQ2hWuHU3o0JX3gMjL44YCHg5Pu60YuodqPFXM+VHUvt9hoqWVKqIXUWbhpUQoRz8EotxRHG4MDDg6MjF/SqqVkruXwmitZQQljYsAETwOXuCNXhADLaUNCzBKjNoRtqGSzu+jCi2x10xlDtu9Z4af61LnWe/znNiw9I1Y+K//CF7ErYVMI2b0LCvDZPMIaC1w9O0MdsdurXFi7ExbFL5q+9d3cajphxFi1NpatMNLkF61yO6a3sVan4ADoH9kLz9KQC6f00xPz1wpQz46ArAXocGIaXQe2RmfgNjlLEZEFCU4B4Enl8KoEcJApt2mr2x8M6EWl8vE5HTggW9/SigEyhmQv0CKuYUuTDs8fZat1SBz1KjI9AgBplpNkogbeBYHRz73ytk+5mXzYhvVjS3yCJgGHMqzL0SWjYg6xonDQuWFv2ImeLR/jy8YzGNAI1ng8nUBdT21EBsJ/3Xq3NrC9ptaw7v74sBQUD0TUks9k936yc9p8I4Z7kUnwl8m1Ln6aXAYhymnzLsHas3IF5z3y/TwAA+1FjvvwMn8LIWQxac5Vuhc173+ZhFgqHN6zeJic4feH/fTg0waUyLSjMARJkfbAluhTn8KkeF4hngtKK8iYpXoeA== 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:(13230001)(366004)(508600001)(6506007)(186003)(66476007)(36756003)(66946007)(66556008)(6486002)(8676002)(5660300002)(2906002)(6512007)(316002)(31686004)(26005)(2616005)(83380400001)(86362001)(31696002)(38100700002)(82960400001)(53546011)(6666004)(8936002)(44832011)(45980500001); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?bEhXemhvZVNNb3VaTDF1OEhJV1RHTERHVTM2N3VUZFY3QWM4Y1h5RjBxOGNF?= =?utf-8?B?cHJsS1d6UCtwNkE2bVNHbW83TzFmU1RZSFVKU0RoRU82MHFmVDJ5cEhsZENT?= =?utf-8?B?RnNJOHF0RFRBcHBHQ3VEQWJydmIySlFvZ1ZsUnNYL25vc2R0ci8yYWNzTVc3?= =?utf-8?B?VjhnMG9Wa3F0Y1p2R1F3SmFwZlNGMG5SWWhJR3V1MHF4SGx2U2ZCSE54Mm9L?= =?utf-8?B?Z2VrNVQxQUlKZHg1V2N3S3VIN3NKeG5wS1Z2QUhqRHVtYi9vUW0yUGpPb0ZB?= =?utf-8?B?Q05NeVhwVEJ6dW5tQ1VUUEZNbk9zbjZnRGVWcjVwSGpyWU1DQ2dnRW9IaS9X?= =?utf-8?B?RW1GQjJGVWk3ZVQ4ZUk5NmNlUnY0VVpHbE1kcTB4c1F6YUFZU2hFMEhUL0s5?= =?utf-8?B?NjV2S3FadTEvM0NqVVJad0NJVnRFZGcreGxjclpEdnp4ZnBYSzAyR2lHQkxN?= =?utf-8?B?WnZERm8vejV2U0VidHR5OWJWK1FnQm1VVFJ1dXp5U25rbVRqcnJhd2JRS2RU?= =?utf-8?B?ZmNoMDZiSmNNMnJ5alBoK1Q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OWgvRFk0UzlvN291NWU5VUYwQ3RCSS81b2FkR0NhdC9M?= =?utf-8?B?blVoNGdyZkdOTFhGOWE0LzUxcys5Y1JzS2tBRHo2ZE5hUzc0SEFSbEs0Nm10?= =?utf-8?B?ZUY0N1B2Qk96Q2FRcmFZT0FraHlOUUJsclY5VjIyMUJhbnVnd0d3VlBrUXhG?= =?utf-8?B?UnFRSDl4My9ERk9tcllzbVhIZ2xpeHdkb0F0K3RqMWhTNUFaMTVRWXg4eFpz?= =?utf-8?B?cFkyWlVIcDRTTWdodnFDejVjWDZHbERvTDBZYXJ3a0lmSm5ZS3pQcHJjQURr?= =?utf-8?B?cmVETG83V1hvMGs5ekg5ZE50MFNnL2dLZzRSY3JFeS9jR2l4UVoxL3o4cVda?= =?utf-8?B?NlR4aEpYckQ0WDJENWlpa2lRMURuU2hpNnRVbVNpTElJTXJObGdMaGIzS3dl?= =?utf-8?B?QVNhYkVDNUVQQy82elZEZjRsL2Q4TEs4d0hzU2grMTJ4ME9wdnJPVnRRZWx6?= =?utf-8?B?UC8yOHF0d09YZmdXVm9FM1RNWnpyVmsvQkNVUS9KcmJGalVUWTNpdUlqcEhq?= =?utf-8?B?MHYvVzFsd2FUeURDb1BrdWFnZXpsdis5Ym9OdE5GYU9FZTZHVzhjWHNEbzZU?= =?utf-8?B?cUszNVJjV0JmVW1lcHM1WHJpOXFQekNFQmdLQWFiYXg0QlpGbUxzdEhlVDZ2?= =?utf-8?B?S0VsVWorN1NoR3NZakJIckpob2w2WkI4SHhybmlWS05DRTRkdWp0alhDZTFF?= =?utf-8?Q?4MQQ9FvqhwwGkJE+mGT/9Do=3D?= X-MS-Exchange-CrossTenant-Network-Message-Id: e30c2268-d7bc-48ea-f4a9-08d9efbf2f11 X-MS-Exchange-CrossTenant-AuthSource: PH0PR11MB5000.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Feb 2022 13:37:45.9789 (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: 2faVbouhbq8X8FeWjCguf3LWJUKJzFasToMCZ8agSovRM7xC3E4b+PzlRdL1hrQ3J/Ah9Nai/Hn0PJvl52pvaw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR11MB2654 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 On 2/14/2022 11:25 AM, spinler@cesnet.cz wrote: > From: Martin Spinler > > Extend the eth_dev_ops by add/remove MAC address functions. > > Signed-off-by: Martin Spinler > --- > drivers/net/nfb/nfb_ethdev.c | 69 ++++++++++++++++++++++++++++++------ > 1 file changed, 58 insertions(+), 11 deletions(-) > > diff --git a/drivers/net/nfb/nfb_ethdev.c b/drivers/net/nfb/nfb_ethdev.c > index 5d503e131a..7dec8e022e 100644 > --- a/drivers/net/nfb/nfb_ethdev.c > +++ b/drivers/net/nfb/nfb_ethdev.c > @@ -214,7 +214,19 @@ static int > nfb_eth_dev_info(struct rte_eth_dev *dev, > struct rte_eth_dev_info *dev_info) > { > - dev_info->max_mac_addrs = 1; > + uint16_t i; > + uint32_t max_mac_addrs; > + struct pmd_internals *internals = dev->data->dev_private; > + > + dev_info->max_mac_addrs = (uint32_t)-1; > + for (i = 0; i < internals->max_rxmac; i++) { > + max_mac_addrs = nc_rxmac_mac_address_count(internals->rxmac[i]); > + dev_info->max_mac_addrs = RTE_MIN(max_mac_addrs, > + dev_info->max_mac_addrs); > + } > + if (internals->max_rxmac == 0) > + dev_info->max_mac_addrs = 0; > + Not sure if 'max_mac_addrs = 0' is valid value, as far as I can see driver allocates memory for at least one MAC address, so there is no case that NIC doesn't support any MAC address. It looks like max_mac_addrs usage is not clear, what is exactly the 'max_rxmac' & 'rxmac[]' variables are? > dev_info->max_rx_pktlen = (uint32_t)-1; > dev_info->max_rx_queues = dev->data->nb_rx_queues; > dev_info->max_tx_queues = dev->data->nb_tx_queues; > @@ -376,6 +388,18 @@ nfb_eth_dev_set_link_down(struct rte_eth_dev *dev) > return 0; > } > > +static uint64_t > +nfb_eth_mac_addr_conv(struct rte_ether_addr *mac_addr) > +{ > + int i; > + uint64_t res = 0; > + for (i = 0; i < RTE_ETHER_ADDR_LEN; i++) { > + res <<= 8; > + res |= mac_addr->addr_bytes[i] & 0xFF; > + } > + return res; > +} > + > /** > * DPDK callback to set primary MAC address. > * > @@ -392,26 +416,47 @@ nfb_eth_mac_addr_set(struct rte_eth_dev *dev, > struct rte_ether_addr *mac_addr) > { > unsigned int i; > - uint64_t mac = 0; > + uint64_t mac; > struct rte_eth_dev_data *data = dev->data; > struct pmd_internals *internals = (struct pmd_internals *) > data->dev_private; > > - if (!rte_is_valid_assigned_ether_addr(mac_addr)) > - return -EINVAL; > + mac = nfb_eth_mac_addr_conv(mac_addr); > + for (i = 0; i < internals->max_rxmac; ++i) > + nc_rxmac_set_mac(internals->rxmac[i], 0, mac, 1); This functions is to set default MAC address 'data->mac_addrs[0]', why same MAC set multiple times in a loop? > > - for (i = 0; i < RTE_ETHER_ADDR_LEN; i++) { > - mac <<= 8; > - mac |= mac_addr->addr_bytes[i] & 0xFF; > - } > + return 0; > +} > > +static int > +nfb_eth_mac_addr_add(struct rte_eth_dev *dev, > + struct rte_ether_addr *mac_addr, uint32_t index, uint32_t pool __rte_unused) > +{ > + unsigned int i; > + uint64_t mac = 0; > + struct rte_eth_dev_data *data = dev->data; > + struct pmd_internals *internals = (struct pmd_internals *) > + data->dev_private; > + > + mac = nfb_eth_mac_addr_conv(mac_addr); > for (i = 0; i < internals->max_rxmac; ++i) > - nc_rxmac_set_mac(internals->rxmac[i], 0, mac, 1); > + nc_rxmac_set_mac(internals->rxmac[i], index, mac, 1); > > - rte_ether_addr_copy(mac_addr, data->mac_addrs); > return 0; > } > > +static void > +nfb_eth_mac_addr_remove(struct rte_eth_dev *dev, uint32_t index) > +{ > + unsigned int i; > + struct rte_eth_dev_data *data = dev->data; > + struct pmd_internals *internals = (struct pmd_internals *) > + data->dev_private; > + > + for (i = 0; i < internals->max_rxmac; ++i) > + nc_rxmac_set_mac(internals->rxmac[i], index, 0, 0); > +} > + > static const struct eth_dev_ops ops = { > .dev_start = nfb_eth_dev_start, > .dev_stop = nfb_eth_dev_stop, > @@ -436,6 +481,8 @@ static const struct eth_dev_ops ops = { > .stats_get = nfb_eth_stats_get, > .stats_reset = nfb_eth_stats_reset, > .mac_addr_set = nfb_eth_mac_addr_set, > + .mac_addr_add = nfb_eth_mac_addr_add, > + .mac_addr_remove = nfb_eth_mac_addr_remove, > }; > > /** > @@ -530,7 +577,7 @@ nfb_eth_dev_init(struct rte_eth_dev *dev) > eth_addr_init.addr_bytes[1] = eth_addr.addr_bytes[1]; > eth_addr_init.addr_bytes[2] = eth_addr.addr_bytes[2]; > > - nfb_eth_mac_addr_set(dev, ð_addr_init); > + rte_eth_dev_default_mac_addr_set(dev->data->port_id, ð_addr_init); > I didn't get this change, why calling the API from the driver, instead of calling the dev_ops directly as original code did? > data->promiscuous = nfb_eth_promiscuous_get(dev); > data->all_multicast = nfb_eth_allmulticast_get(dev);