[PATCH v6 1/5] net/mlx5: remove MAC addresses flush helper on Linux
From: David Marchand <hidden>
Date: 2026-09-08 09:28:00
Subsystem:
networking drivers, the rest · Maintainers:
Andrew Lunn, "David S. Miller", Eric Dumazet, Jakub Kicinski, Paolo Abeni, Linus Torvalds
This helper is exposing internals of net/mlx5 for no good reason. All this code does is calling the remove helper. Walk through the list in Linux implementation like the Windows implementation. Signed-off-by: David Marchand <redacted> --- drivers/common/mlx5/linux/mlx5_nl.c | 40 ----------------------------- drivers/common/mlx5/linux/mlx5_nl.h | 5 ---- drivers/net/mlx5/linux/mlx5_os.c | 13 +++++++--- 3 files changed, 10 insertions(+), 48 deletions(-)
diff --git a/drivers/common/mlx5/linux/mlx5_nl.c b/drivers/common/mlx5/linux/mlx5_nl.c
index 42ccb73e36..40a8b8a2cc 100644
--- a/drivers/common/mlx5/linux/mlx5_nl.c
+++ b/drivers/common/mlx5/linux/mlx5_nl.c@@ -825,46 +825,6 @@ mlx5_nl_mac_addr_sync(int nlsk_fd, unsigned int iface_idx, } } -/** - * Flush all added MAC addresses. - * - * @param[in] nlsk_fd - * Netlink socket file descriptor. - * @param[in] iface_idx - * Net device interface index. - * @param[in] mac_addrs - * Mac addresses array to flush. - * @param n - * @p mac_addrs array size. - * @param mac_own - * BITFIELD_DECLARE array to store the mac. - * @param vf - * Flag for a VF device. - */ -RTE_EXPORT_INTERNAL_SYMBOL(mlx5_nl_mac_addr_flush) -void -mlx5_nl_mac_addr_flush(int nlsk_fd, unsigned int iface_idx, - struct rte_ether_addr *mac_addrs, int n, - uint64_t *mac_own, bool vf) -{ - int i; - - if (n <= 0 || n > MLX5_MAX_MAC_ADDRESSES) - return; - - for (i = n - 1; i >= 0; --i) { - struct rte_ether_addr *m = &mac_addrs[i]; - - if (BITFIELD_ISSET(mac_own, i)) { - if (vf) - mlx5_nl_mac_addr_remove(nlsk_fd, - iface_idx, - m, i); - BITFIELD_RESET(mac_own, i); - } - } -} - /** * Enable promiscuous / all multicast mode through Netlink. *
diff --git a/drivers/common/mlx5/linux/mlx5_nl.h b/drivers/common/mlx5/linux/mlx5_nl.h
index 8ccdd244b0..0242342c47 100644
--- a/drivers/common/mlx5/linux/mlx5_nl.h
+++ b/drivers/common/mlx5/linux/mlx5_nl.h@@ -65,11 +65,6 @@ __rte_internal void mlx5_nl_mac_addr_sync(int nlsk_fd, unsigned int iface_idx, struct rte_ether_addr *mac_addrs, int n); __rte_internal -void mlx5_nl_mac_addr_flush(int nlsk_fd, unsigned int iface_idx, - struct rte_ether_addr *mac_addrs, int n, - uint64_t *mac_own, - bool vf); -__rte_internal int mlx5_nl_promisc(int nlsk_fd, unsigned int iface_idx, int enable); __rte_internal int mlx5_nl_allmulti(int nlsk_fd, unsigned int iface_idx, int enable);
diff --git a/drivers/net/mlx5/linux/mlx5_os.c b/drivers/net/mlx5/linux/mlx5_os.c
index 592e233844..49a8751761 100644
--- a/drivers/net/mlx5/linux/mlx5_os.c
+++ b/drivers/net/mlx5/linux/mlx5_os.c@@ -3529,10 +3529,17 @@ mlx5_os_mac_addr_flush(struct rte_eth_dev *dev) { struct mlx5_priv *priv = dev->data->dev_private; const int vf = priv->sh->dev_cap.vf; + int i; - mlx5_nl_mac_addr_flush(priv->nl_socket_route, mlx5_ifindex(dev), - dev->data->mac_addrs, - MLX5_MAX_MAC_ADDRESSES, priv->mac_own, vf); + for (i = MLX5_MAX_MAC_ADDRESSES - 1; i >= 0; --i) { + if (BITFIELD_ISSET(priv->mac_own, i)) { + if (vf) + mlx5_nl_mac_addr_remove(priv->nl_socket_route, + mlx5_ifindex(dev), + &dev->data->mac_addrs[i], i); + BITFIELD_RESET(priv->mac_own, i); + } + } } static bool
--
2.54.0