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 5840B42CBC for ; Thu, 15 Jun 2023 03:34:24 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 51EF742D30; Thu, 15 Jun 2023 03:34:24 +0200 (CEST) Received: from mail-wm1-f48.google.com (mail-wm1-f48.google.com [209.85.128.48]) by mails.dpdk.org (Postfix) with ESMTP id 52AAC40E0F for ; Thu, 15 Jun 2023 03:34:23 +0200 (CEST) Received: by mail-wm1-f48.google.com with SMTP id 5b1f17b1804b1-3f8d61cb36cso13167175e9.1 for ; Wed, 14 Jun 2023 18:34:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1686792863; x=1689384863; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Cvl2Jr8C8SbSJ+sE3c/Tki9WiadVnyTonZ4CJcu7WRM=; b=ZwkhhlJfI39FLGHtwgb8cHOuOZRr17lMHu4HyLs0pUAslTY9f/rmc6MkNSFMP8F413 g8jWTL06KeGwNYWD5MWhKJiVm5ZP4PQ8TjCJkJ9cI6UivCYWCm6wUAMmSzBvz7Ua1X96 tmzI+PLV5rL8qT9AVPNz//eJE24YcYdzgr0Ak1h6bcQleO4dAL0FHFefPEhOHoKSSuew Yu5BxfCt36UC5FGto7eMJValW1aBigh54rzp6ltQSt57twi9zzc8YtlSPEcBf3rvL7IP HdnBGfAipZ9j4IK0EbjLTHh+1z0LSpUsJKf2ztVq9esuAVeqvRDCDIeZHuXXY/Xj0hCx 4h5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686792863; x=1689384863; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Cvl2Jr8C8SbSJ+sE3c/Tki9WiadVnyTonZ4CJcu7WRM=; b=O7v3B3CI0HwgWzhJJp9E60FUDZmUTRAgvxAW27RbIviWpap9yaBL+ghBS1SLA7KmI6 AoE1CJlcxnBorGY8OR2RPngCvHVh/ISpRRBJ9nJ5w4LpulnOOH0G5fkaidOOu7chAiEQ RMQpTsuS9fzXDv4kTxC0hdAbimuJG0uyoQk0/E1E3wNh477psCYxw5P1lRKzWYHlTbyS J00oqDS8WY6xtGXqzl8bkR+9cLs9Ncoj7r2143DJDqHvXpMqSF0Zyx1Z3uwdh4Sqnx1O QYK5t42egfwosst0/DmQ+8nDpvJmUEAclYKMfT/hNAs3kVPADZc7sD7sHQiQm83blTA1 svOQ== X-Gm-Message-State: AC+VfDzYLzXNdLyNdCBp+Dp+BqRTRUVJRvZSrpsZUVw2XnN4VyWz2j+S +O3jenKkwd3mTPC8YVY8D7s= X-Google-Smtp-Source: ACHHUZ6gZdFdUTyeoP2tng3BeHaR7/x7pjiBsIc4umI69IjwGcAc3YseiZagxeOXlQVSmLWzZ3e5Eg== X-Received: by 2002:a5d:452d:0:b0:30f:c30e:5eda with SMTP id j13-20020a5d452d000000b0030fc30e5edamr8566818wra.20.1686792862877; Wed, 14 Jun 2023 18:34:22 -0700 (PDT) Received: from localhost ([2a01:4b00:d307:1000:f1d3:eb5e:11f4:a7d9]) by smtp.gmail.com with ESMTPSA id e10-20020a056000194a00b0030497b3224bsm19595634wry.64.2023.06.14.18.34.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Jun 2023 18:34:22 -0700 (PDT) From: luca.boccassi@gmail.com 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 20.11.9 Date: Thu, 15 Jun 2023 02:32:21 +0100 Message-Id: <20230615013258.1439718-26-luca.boccassi@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230615013258.1439718-1-luca.boccassi@gmail.com> References: <20230615013258.1439718-1-luca.boccassi@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 20.11.9 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/17/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://github.com/bluca/dpdk-stable This queued commit can be viewed at: https://github.com/bluca/dpdk-stable/commit/2928ea4fedd0902a8f85af2aceca90e24c116759 Thanks. Luca Boccassi --- >From 2928ea4fedd0902a8f85af2aceca90e24c116759 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 [ 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/librte_ethdev/rte_ethdev.c | 10 ++++++++++ lib/librte_ethdev/rte_ethdev.h | 4 ++++ 2 files changed, 14 insertions(+) diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c index 4b59854c12..b5c5af3cf5 100644 --- a/lib/librte_ethdev/rte_ethdev.c +++ b/lib/librte_ethdev/rte_ethdev.c @@ -4150,6 +4150,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); @@ -4160,6 +4161,15 @@ rte_eth_dev_default_mac_addr_set(uint16_t port_id, struct rte_ether_addr *addr) dev = &rte_eth_devices[port_id]; RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->mac_addr_set, -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/librte_ethdev/rte_ethdev.h b/lib/librte_ethdev/rte_ethdev.h index 5e8331da1c..709563215f 100644 --- a/lib/librte_ethdev/rte_ethdev.h +++ b/lib/librte_ethdev/rte_ethdev.h @@ -3840,6 +3840,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. @@ -3850,6 +3853,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.39.2 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2023-06-15 01:56:36.122879824 +0100 +++ 0026-ethdev-fix-MAC-address-occupies-two-entries.patch 2023-06-15 01:56:34.575541478 +0100 @@ -1 +1 @@ -From 8f02f472a29432650d999969359d6a49ea6aadca Mon Sep 17 00:00:00 2001 +From 2928ea4fedd0902a8f85af2aceca90e24c116759 Mon Sep 17 00:00:00 2001 @@ -5,0 +6,2 @@ +[ upstream commit 8f02f472a29432650d999969359d6a49ea6aadca ] + @@ -28 +29,0 @@ -Cc: stable@dpdk.org @@ -35,45 +36,9 @@ - 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 - ----------- -diff --git a/lib/ethdev/ethdev_driver.h b/lib/ethdev/ethdev_driver.h -index 2c9d615fb5..367c0c4878 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 4d03255683..d46e74504e 100644 ---- a/lib/ethdev/rte_ethdev.c -+++ b/lib/ethdev/rte_ethdev.c -@@ -4898,6 +4898,7 @@ int + lib/librte_ethdev/rte_ethdev.c | 10 ++++++++++ + lib/librte_ethdev/rte_ethdev.h | 4 ++++ + 2 files changed, 14 insertions(+) + +diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c +index 4b59854c12..b5c5af3cf5 100644 +--- a/lib/librte_ethdev/rte_ethdev.c ++++ b/lib/librte_ethdev/rte_ethdev.c +@@ -4150,6 +4150,7 @@ int @@ -87,3 +52,3 @@ -@@ -4916,6 +4917,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; +@@ -4160,6 +4161,15 @@ rte_eth_dev_default_mac_addr_set(uint16_t port_id, struct rte_ether_addr *addr) + dev = &rte_eth_devices[port_id]; + RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->mac_addr_set, -ENOTSUP); @@ -103,5 +68,5 @@ -diff --git a/lib/ethdev/rte_ethdev.h b/lib/ethdev/rte_ethdev.h -index 99fe9e238b..fe8f7466c8 100644 ---- a/lib/ethdev/rte_ethdev.h -+++ b/lib/ethdev/rte_ethdev.h -@@ -4381,6 +4381,9 @@ int rte_eth_dev_mac_addr_remove(uint16_t port_id, +diff --git a/lib/librte_ethdev/rte_ethdev.h b/lib/librte_ethdev/rte_ethdev.h +index 5e8331da1c..709563215f 100644 +--- a/lib/librte_ethdev/rte_ethdev.h ++++ b/lib/librte_ethdev/rte_ethdev.h +@@ -3840,6 +3840,9 @@ int rte_eth_dev_mac_addr_remove(uint16_t port_id, @@ -117 +82 @@ -@@ -4391,6 +4394,7 @@ int rte_eth_dev_mac_addr_remove(uint16_t port_id, +@@ -3850,6 +3853,7 @@ int rte_eth_dev_mac_addr_remove(uint16_t port_id,