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 25BB842D46 for ; Sun, 25 Jun 2023 08:39:29 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 161B442BDA; Sun, 25 Jun 2023 08:39:29 +0200 (CEST) Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2054.outbound.protection.outlook.com [40.107.94.54]) by mails.dpdk.org (Postfix) with ESMTP id A8EE140A7F for ; Sun, 25 Jun 2023 08:39:27 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=P8HwSjgPa2pZSdr86tNnr1o2o6KeA6e6G97YJ85PjehjEtFwKXFXExXTaI9GUySvC1IfohcbYdIIZmLSElMf7r/GzrWn7g9MBGVRbIN2stEbGDZSERovQYFPvYlsg5jOJLZNlA1SPIn+onPgfNdVivuN9guhdqG9tcH4cUnAXbRf/Du7YbAEgmBIrx1aKgkzGpcJ4DIwtnr1CBAnAX4MMIqQB5SYft3NLPkTaxWpa+0y5DaftLtXYJG9vyEqwvbNhyTrcLokaYHU7+J1ZHWf3DUaIOFTKruJR5i64sApnj8dEI+GPcaiT0zhiJHCHnHnzfc2kCb8xz6WJRplPYCmzQ== 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=NiRd9PIbcLCOdS5/PwHHJBn4L17dse8PxbrqF70IJVk=; b=eCscaig4cb2AUGy4eEb6EtHeBTYEtB/AGlLNLXgvWP0wU3cTZ9ndfpGmnkJ4thidAaPmjBbHED58abMHYI0hgCH6MHNGi5FfIjUl1R9rjKu+dGe7I9tYo/sgaoLETKSjnrZ1ODHznp24O0gX+zyXrVzhlClIxJ43kP3yI+VcTO9mBZmnDdxfD7nPuKKzOQjplZV1GSLSAwEyI8GY5/oy29sKqqrPYYVRz3lzioZShkdWEvWwqBmJRmG/lL1kY89O9mi7bplcmPEEodObFhhPOP32KLCPBfB067kXQ86Mgk4Ki4W1+4fQgBxkGpD8YBSNpI1Tw0pxumlhOjzOcQx5AA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=huawei.com smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=NiRd9PIbcLCOdS5/PwHHJBn4L17dse8PxbrqF70IJVk=; b=ZDE/MbFDnkdVDltUzl18j8o/M++Zx1sJH/F5SVxaO7MOxgtOJ7fR9n7qPaIPl9IbtxeFKyNq/xk2hO76dvrbJpOqMp0JHnDwuoFqCzy1K2K7OqJsQfPhVwzrW7joxWrG66V6uMIbv7hMHeFgb017SGf+CjCwb7lkE53aWjjGtWKkTuZ5CKL6k4mTzMPkYn2SftNZIbfQEak4EXSa54+/FXItEGFfx/2vlKwed6/CClUaAqTgy+EH+mRQ13MVg1uCWidO4kJCNX2qFKHeiEhFoFwTj8GIquj25YB13+kuGGhw/AB0JuhVcPrdTJEF655uiGjDvE9iQcZo9vJPRSIgzQ== Received: from BN8PR15CA0039.namprd15.prod.outlook.com (2603:10b6:408:80::16) by PH0PR12MB8798.namprd12.prod.outlook.com (2603:10b6:510:28d::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.26; Sun, 25 Jun 2023 06:39:25 +0000 Received: from BN8NAM11FT052.eop-nam11.prod.protection.outlook.com (2603:10b6:408:80:cafe::7e) by BN8PR15CA0039.outlook.office365.com (2603:10b6:408:80::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.32 via Frontend Transport; Sun, 25 Jun 2023 06:39:25 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by BN8NAM11FT052.mail.protection.outlook.com (10.13.177.210) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6500.47 via Frontend Transport; Sun, 25 Jun 2023 06:39:23 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.5; Sat, 24 Jun 2023 23:39:11 -0700 Received: from nvidia.com (10.126.230.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.37; Sat, 24 Jun 2023 23:39:10 -0700 From: Xueming Li To: Huisong Li CC: Chengwen Feng , Thomas Monjalon , Ferruh Yigit , dpdk stable Subject: patch 'ethdev: fix MAC address occupies two entries' has been queued to stable release 22.11.3 Date: Sun, 25 Jun 2023 14:34:15 +0800 Message-ID: <20230625063544.11183-38-xuemingl@nvidia.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230625063544.11183-1-xuemingl@nvidia.com> References: <20230625063544.11183-1-xuemingl@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.126.230.35] X-ClientProxiedBy: rnnvmail202.nvidia.com (10.129.68.7) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT052:EE_|PH0PR12MB8798:EE_ X-MS-Office365-Filtering-Correlation-Id: 74e42c7c-f36d-43b5-442c-08db7546ea05 X-LD-Processed: 43083d15-7273-40c1-b7db-39efd9ccc17a,ExtAddr X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 1a5I9DIPChgEQV5/keNxr7nTtVAJopfYGHzhAagGOE3lvz1/nk4ifZ8x71xmWtZI4qheAwvRgRXHms6Ngy0cYYQpJOS9CAMoCyGOjYEGwB4cBjzHH1zCvEEB5YA3PTBFbFfEH8Ba7QaaWnr2ePSGjJTiWGbhznVWETatNCXZlsyV52JE/5dFAB319Ko5oVWdktpyIMYZl0GrVhJZt7LIiZGo3PIC690EEEcjDlphsisdZbP+jVBtSOc8AskE/3Aec1AoS1rzywsXDO5o2IYPFJD8it5Jmhcs8+7yvFHbDulKpphQvTkjNJtXXZyKbhwrRua9yFcHR3UU6bx0lxrSj7Q4kvrcN7mOQJdiE+mi+3+3Y0JI/nCeAwqoX3syBe5y77CF1+oa515wQDb4uoHdSuRhAnILufQAXsEEfjysllrCcMSydTOYVt5gT3L4Yr+Scz8f6KVYw46J7si1QOirA0NtTFC9+QeEDJeVMgY5iCGLJbvyV2sWjXvAfZr7Iug+cu0RlJJPZNEsLnLToh+qGNJvMmesS2pL53lOOmWX0loMTi/+EnclZMa+KfhmMB7wXmhvTgMn9thKN0KqYw5VbW0rwqSz8W68ws+CYfQxI52FBpthfcXts8s2UQM5f0/fLs3UA2ZzmD0PIMhesua+/ruvNOnEy0/yb7OYuqzeh9Pe38/3mT2e5MKas4MHQW/Z841wjQ7B8U2wf6lGpJjZUVTOLJnZDsDMQXRAIIM4UAPPmS4wUWPtmLptL1bk/8CVD8Ps3NdP4zYca2ww30sSHw== X-Forefront-Antispam-Report: CIP:216.228.117.160; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge1.nvidia.com; CAT:NONE; SFS:(13230028)(4636009)(39860400002)(376002)(346002)(396003)(136003)(451199021)(40470700004)(46966006)(36840700001)(40460700003)(2906002)(7696005)(82310400005)(82740400003)(356005)(7636003)(2616005)(83380400001)(47076005)(336012)(426003)(1076003)(26005)(186003)(6286002)(16526019)(53546011)(966005)(36860700001)(55016003)(41300700001)(40480700001)(86362001)(54906003)(478600001)(316002)(70586007)(70206006)(40140700001)(36756003)(6916009)(4326008)(8936002)(8676002)(5660300002); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Jun 2023 06:39:23.5400 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 74e42c7c-f36d-43b5-442c-08db7546ea05 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.117.160]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT052.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR12MB8798 X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Hi, FYI, your patch has been queued to stable release 22.11.3 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 06/27/23. So please shout if anyone has objections. Also note that after the patch there's a diff of the upstream commit vs the patch applied to the branch. This will indicate if there was any rebasing needed to apply to the stable branch. If there were code changes for rebasing (ie: not only metadata diffs), please double check that the rebase was correctly done. Queued patches are on a temporary branch at: https://git.dpdk.org/dpdk-stable/log/?h=22.11-staging This queued commit can be viewed at: https://git.dpdk.org/dpdk-stable/commit/?h=22.11-staging&id=631f57f5effabb6b358e47b81c71855c8336a6c9 Thanks. Xueming Li --- >From 631f57f5effabb6b358e47b81c71855c8336a6c9 Mon Sep 17 00:00:00 2001 From: Huisong Li Date: Fri, 19 May 2023 17:31:55 +0800 Subject: [PATCH] ethdev: fix MAC address occupies two entries Cc: Xueming Li [ upstream commit 8f02f472a29432650d999969359d6a49ea6aadca ] The dev->data->mac_addrs[0] will be changed to a new MAC address when applications modify the default MAC address by .mac_addr_set(). However, if the new default one has been added as a non-default MAC address by .mac_addr_add(), the .mac_addr_set() didn't check this address. As a result, this MAC address occupies two entries in the list. Like: add(MAC1) add(MAC2) add(MAC3) add(MAC4) set_default(MAC3) default=MAC3, the rest of the list=MAC1, MAC2, MAC3, MAC4 Note: MAC3 occupies two entries. But .mac_addr_set() cannot remove it implicitly in case of MAC address shrinking in the list. So this patch adds a check on whether the new default address was already in the list and if so requires the user to remove it first. In addition, this patch documents the position of the default MAC address and address unique in the list. Fixes: 854d8ad4ef68 ("ethdev: add default mac address modifier") Signed-off-by: Huisong Li Acked-by: Chengwen Feng Acked-by: Thomas Monjalon Reviewed-by: Ferruh Yigit --- lib/ethdev/ethdev_driver.h | 6 +++++- lib/ethdev/rte_ethdev.c | 10 ++++++++++ lib/ethdev/rte_ethdev.h | 4 ++++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/lib/ethdev/ethdev_driver.h b/lib/ethdev/ethdev_driver.h index 6a550cfc83..cd2cd89649 100644 --- a/lib/ethdev/ethdev_driver.h +++ b/lib/ethdev/ethdev_driver.h @@ -117,7 +117,11 @@ struct rte_eth_dev_data { uint64_t rx_mbuf_alloc_failed; /**< Rx ring mbuf allocation failures */ - /** Device Ethernet link address. @see rte_eth_dev_release_port() */ + /** + * Device Ethernet link addresses. + * All entries are unique. + * The first entry (index zero) is the default address. + */ struct rte_ether_addr *mac_addrs; /** Bitmap associating MAC addresses to pools */ uint64_t mac_pool_sel[RTE_ETH_NUM_RECEIVE_MAC_ADDR]; diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c index b9c8f79f8c..f21dea7150 100644 --- a/lib/ethdev/rte_ethdev.c +++ b/lib/ethdev/rte_ethdev.c @@ -4499,6 +4499,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); @@ -4517,6 +4518,15 @@ rte_eth_dev_default_mac_addr_set(uint16_t port_id, struct rte_ether_addr *addr) if (*dev->dev_ops->mac_addr_set == NULL) return -ENOTSUP; + /* Keep address unique in dev->data->mac_addrs[]. */ + index = eth_dev_get_mac_addr_index(port_id, addr); + if (index > 0) { + RTE_ETHDEV_LOG(ERR, + "New default address for port %u was already in the address list. Please remove it first.\n", + port_id); + return -EEXIST; + } + ret = (*dev->dev_ops->mac_addr_set)(dev, addr); if (ret < 0) return ret; diff --git a/lib/ethdev/rte_ethdev.h b/lib/ethdev/rte_ethdev.h index c129ca1eaf..0d83df42a9 100644 --- a/lib/ethdev/rte_ethdev.h +++ b/lib/ethdev/rte_ethdev.h @@ -4354,6 +4354,9 @@ int rte_eth_dev_mac_addr_remove(uint16_t port_id, /** * Set the default MAC address. + * It replaces the address at index 0 of the MAC address list. + * If the address was already in the MAC address list, + * please remove it first. * * @param port_id * The port identifier of the Ethernet device. @@ -4364,6 +4367,7 @@ int rte_eth_dev_mac_addr_remove(uint16_t port_id, * - (-ENOTSUP) if hardware doesn't support. * - (-ENODEV) if *port* invalid. * - (-EINVAL) if MAC address is invalid. + * - (-EEXIST) if MAC address was already in the address list. */ int rte_eth_dev_default_mac_addr_set(uint16_t port_id, struct rte_ether_addr *mac_addr); -- 2.25.1 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2023-06-25 14:31:59.513936300 +0800 +++ 0037-ethdev-fix-MAC-address-occupies-two-entries.patch 2023-06-25 14:31:58.335773900 +0800 @@ -1 +1 @@ -From 8f02f472a29432650d999969359d6a49ea6aadca Mon Sep 17 00:00:00 2001 +From 631f57f5effabb6b358e47b81c71855c8336a6c9 Mon Sep 17 00:00:00 2001 @@ -4,0 +5,3 @@ +Cc: Xueming Li + +[ upstream commit 8f02f472a29432650d999969359d6a49ea6aadca ] @@ -28 +30,0 @@ -Cc: stable@dpdk.org @@ -35,23 +37,5 @@ - doc/guides/rel_notes/release_23_07.rst | 6 ++++++ - lib/ethdev/ethdev_driver.h | 6 +++++- - lib/ethdev/rte_ethdev.c | 10 ++++++++++ - lib/ethdev/rte_ethdev.h | 4 ++++ - 4 files changed, 25 insertions(+), 1 deletion(-) - -diff --git a/doc/guides/rel_notes/release_23_07.rst b/doc/guides/rel_notes/release_23_07.rst -index 11cf5c6a0c..58d4e59487 100644 ---- a/doc/guides/rel_notes/release_23_07.rst -+++ b/doc/guides/rel_notes/release_23_07.rst -@@ -108,6 +108,12 @@ API Changes - Also, make sure to start the actual text at the margin. - ======================================================= - -+* ethdev: Ensured all entries in MAC address list are uniques. -+ When setting a default MAC address with the function -+ ``rte_eth_dev_default_mac_addr_set``, -+ the default one needs to be removed by the user -+ if it was already in the address list. -+ - - ABI Changes - ----------- + lib/ethdev/ethdev_driver.h | 6 +++++- + lib/ethdev/rte_ethdev.c | 10 ++++++++++ + lib/ethdev/rte_ethdev.h | 4 ++++ + 3 files changed, 19 insertions(+), 1 deletion(-) + @@ -59 +43 @@ -index 2c9d615fb5..367c0c4878 100644 +index 6a550cfc83..cd2cd89649 100644 @@ -76 +60 @@ -index 4d03255683..d46e74504e 100644 +index b9c8f79f8c..f21dea7150 100644 @@ -79 +63 @@ -@@ -4898,6 +4898,7 @@ int +@@ -4499,6 +4499,7 @@ int @@ -87 +71 @@ -@@ -4916,6 +4917,15 @@ rte_eth_dev_default_mac_addr_set(uint16_t port_id, struct rte_ether_addr *addr) +@@ -4517,6 +4518,15 @@ rte_eth_dev_default_mac_addr_set(uint16_t port_id, struct rte_ether_addr *addr) @@ -104 +88 @@ -index 99fe9e238b..fe8f7466c8 100644 +index c129ca1eaf..0d83df42a9 100644 @@ -107 +91 @@ -@@ -4381,6 +4381,9 @@ int rte_eth_dev_mac_addr_remove(uint16_t port_id, +@@ -4354,6 +4354,9 @@ int rte_eth_dev_mac_addr_remove(uint16_t port_id, @@ -117 +101 @@ -@@ -4391,6 +4394,7 @@ int rte_eth_dev_mac_addr_remove(uint16_t port_id, +@@ -4364,6 +4367,7 @@ int rte_eth_dev_mac_addr_remove(uint16_t port_id,