From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by smtp.lore.kernel.org (Postfix) with ESMTP id 67A45C88E72 for ; Mon, 14 Sep 2026 14:42:53 +0000 (UTC) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C3F4040E2E; Mon, 14 Sep 2026 16:42:52 +0200 (CEST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mails.dpdk.org (Postfix) with ESMTP id D140840A87 for ; Mon, 14 Sep 2026 16:42:51 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789396971; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=k3Oy0sEZyQveevMXKUkKVP7w9qEe2upVMNkVCs1iclQ=; b=MmCQANXrRQbWjM4AkEyCClAqgndxOaCSouLfnb5o+XCzejzRU7hqOY5sZt9TT2nQ97mh+0 cdaAzhM6TTG1ROZKpKAae7tQ/7v4zdqxFJ9ZklDfGmJ4LE7Nc3JPZTpBMjL1GCkC9+x3Wt SbuGpBpbAPcTpQAgZVIRI1E26dEaf20= Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-121-mET2PrbXNj-RInWiPOMhtw-1; Mon, 14 Sep 2026 10:42:47 -0400 X-MC-Unique: mET2PrbXNj-RInWiPOMhtw-1 X-Mimecast-MFC-AGG-ID: mET2PrbXNj-RInWiPOMhtw_1789396965 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id AF8CC18009E7; Mon, 14 Sep 2026 14:42:45 +0000 (UTC) Received: from dmarchan.redhat.corp (headnet05.pony-001.prod.iad2.dc.redhat.com [10.2.32.117]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 5F0831956053; Mon, 14 Sep 2026 14:42:43 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: dsosnowski@nvidia.com, rjarry@redhat.com, cfontain@redhat.com, Viacheslav Ovsiienko , Bing Zhao , Ori Kam , Suanming Mou , Matan Azrad Subject: [PATCH v7 2/5] net/mlx5: remove redundant MAC address index checks Date: Mon, 14 Sep 2026 16:42:30 +0200 Message-ID: <20260914144234.1540150-2-david.marchand@redhat.com> In-Reply-To: <20260914144234.1540150-1-david.marchand@redhat.com> References: <20260403091836.1073484-1-david.marchand@redhat.com> <20260914144234.1540150-1-david.marchand@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: 3HY-lxwqo9PRgBCZiH3rq4qrz0zVEGswiVrisp0C79c_1789396965 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit content-type: text/plain; charset="US-ASCII"; x-default=true 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 the net/mlx5 side, mlx5_mac.c validates that any MAC address and its index is valid before calling the OS specific helpers. So those OS helpers do not have to validate again the index. Cascading this consideration, validating the MAC index against MLX5_MAX_MAC_ADDRESSES in common code is also redundant. The common code only deals with netlink, remove any index concern. Signed-off-by: David Marchand Acked-by: Dariusz Sosnowski --- drivers/common/mlx5/linux/mlx5_nl.c | 17 ++--------------- drivers/common/mlx5/linux/mlx5_nl.h | 4 ++-- drivers/net/mlx5/linux/mlx5_os.c | 9 ++++----- 3 files changed, 8 insertions(+), 22 deletions(-) diff --git a/drivers/common/mlx5/linux/mlx5_nl.c b/drivers/common/mlx5/linux/mlx5_nl.c index 40a8b8a2cc..3207eae563 100644 --- a/drivers/common/mlx5/linux/mlx5_nl.c +++ b/drivers/common/mlx5/linux/mlx5_nl.c @@ -719,8 +719,6 @@ mlx5_nl_vf_mac_addr_modify(int nlsk_fd, unsigned int iface_idx, * Net device interface index. * @param mac * MAC address to register. - * @param index - * MAC address index. * * @return * 0 on success, a negative errno value otherwise and rte_errno is set. @@ -728,16 +726,11 @@ mlx5_nl_vf_mac_addr_modify(int nlsk_fd, unsigned int iface_idx, RTE_EXPORT_INTERNAL_SYMBOL(mlx5_nl_mac_addr_add) int mlx5_nl_mac_addr_add(int nlsk_fd, unsigned int iface_idx, - struct rte_ether_addr *mac, uint32_t index) + struct rte_ether_addr *mac) { int ret; ret = mlx5_nl_mac_addr_modify(nlsk_fd, iface_idx, mac, 1); - if (!ret) { - MLX5_ASSERT(index < MLX5_MAX_MAC_ADDRESSES); - if (index >= MLX5_MAX_MAC_ADDRESSES) - return -EINVAL; - } if (ret == -EEXIST) return 0; return ret; @@ -752,8 +745,6 @@ mlx5_nl_mac_addr_add(int nlsk_fd, unsigned int iface_idx, * Net device interface index. * @param mac * MAC address to remove. - * @param index - * MAC address index. * * @return * 0 on success, a negative errno value otherwise and rte_errno is set. @@ -761,12 +752,8 @@ mlx5_nl_mac_addr_add(int nlsk_fd, unsigned int iface_idx, RTE_EXPORT_INTERNAL_SYMBOL(mlx5_nl_mac_addr_remove) int mlx5_nl_mac_addr_remove(int nlsk_fd, unsigned int iface_idx, - struct rte_ether_addr *mac, uint32_t index) + struct rte_ether_addr *mac) { - MLX5_ASSERT(index < MLX5_MAX_MAC_ADDRESSES); - if (index >= MLX5_MAX_MAC_ADDRESSES) - return -EINVAL; - return mlx5_nl_mac_addr_modify(nlsk_fd, iface_idx, mac, 0); } diff --git a/drivers/common/mlx5/linux/mlx5_nl.h b/drivers/common/mlx5/linux/mlx5_nl.h index 0242342c47..0d6259f4ad 100644 --- a/drivers/common/mlx5/linux/mlx5_nl.h +++ b/drivers/common/mlx5/linux/mlx5_nl.h @@ -57,10 +57,10 @@ __rte_internal int mlx5_nl_init(int protocol, int groups); __rte_internal int mlx5_nl_mac_addr_add(int nlsk_fd, unsigned int iface_idx, - struct rte_ether_addr *mac, uint32_t index); + struct rte_ether_addr *mac); __rte_internal int mlx5_nl_mac_addr_remove(int nlsk_fd, unsigned int iface_idx, - struct rte_ether_addr *mac, uint32_t index); + struct rte_ether_addr *mac); __rte_internal void mlx5_nl_mac_addr_sync(int nlsk_fd, unsigned int iface_idx, struct rte_ether_addr *mac_addrs, int n); diff --git a/drivers/net/mlx5/linux/mlx5_os.c b/drivers/net/mlx5/linux/mlx5_os.c index 49a8751761..c65293cb25 100644 --- a/drivers/net/mlx5/linux/mlx5_os.c +++ b/drivers/net/mlx5/linux/mlx5_os.c @@ -3382,9 +3382,8 @@ mlx5_os_mac_addr_remove(struct rte_eth_dev *dev, uint32_t index) if (vf) mlx5_nl_mac_addr_remove(priv->nl_socket_route, mlx5_ifindex(dev), - &dev->data->mac_addrs[index], index); - if (index < MLX5_MAX_MAC_ADDRESSES) - BITFIELD_RESET(priv->mac_own, index); + &dev->data->mac_addrs[index]); + BITFIELD_RESET(priv->mac_own, index); } /** @@ -3411,7 +3410,7 @@ mlx5_os_mac_addr_add(struct rte_eth_dev *dev, struct rte_ether_addr *mac, if (vf) ret = mlx5_nl_mac_addr_add(priv->nl_socket_route, mlx5_ifindex(dev), - mac, index); + mac); if (!ret) BITFIELD_SET(priv->mac_own, index); @@ -3536,7 +3535,7 @@ mlx5_os_mac_addr_flush(struct rte_eth_dev *dev) if (vf) mlx5_nl_mac_addr_remove(priv->nl_socket_route, mlx5_ifindex(dev), - &dev->data->mac_addrs[i], i); + &dev->data->mac_addrs[i]); BITFIELD_RESET(priv->mac_own, i); } } -- 2.54.0