[PATCH v5 07/10] net/mlx5: remove redundant MAC address index checks
David Marchand
david.marchand at redhat.com
Thu Jul 23 14:41:53 CEST 2026
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 <david.marchand at redhat.com>
---
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 85736738ac..ceb504f84d 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 256ed7e2b7..500198b654 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 9fd366b10a..1b241ba9d2 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);
@@ -3502,7 +3501,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
More information about the dev
mailing list