* [PATCH V3 1/2] net/mlx5: update how MAC address bit-fields are used
2025-08-25 14:13 [PATCH V3 0/2] resolve flow creation issue for multicast MAC addresses Gavin Li
@ 2025-08-25 14:13 ` Gavin Li
2025-08-25 14:54 ` Thomas Monjalon
2025-08-25 14:13 ` [PATCH V3 2/2] net/mlx5: add support for flows targeting multicast MAC addresses Gavin Li
1 sibling, 1 reply; 5+ messages in thread
From: Gavin Li @ 2025-08-25 14:13 UTC (permalink / raw)
To: matan, viacheslavo, orika, thomas, Dariusz Sosnowski, Bing Zhao,
Suanming Mou
Cc: dev, rasland
Previously, mac_own was a bit-field indicating the MAC addresses owned by
the PMD, specifically marking those added to VFs by the PMD and allowing
them to be flushed during exit.
With this commit, the bit-field now applies to all MAC addresses added by
the PMD, including those for PF, VF, and SFs. The process for flushing MAC
addresses added to VFs by the PMD remains unchanged.
Signed-off-by: Gavin Li <gavinl@nvidia.com>
---
drivers/common/mlx5/linux/mlx5_nl.c | 26 ++++++++++++--------------
drivers/common/mlx5/linux/mlx5_nl.h | 8 ++++----
drivers/net/mlx5/linux/mlx5_os.c | 12 +++++++++---
3 files changed, 25 insertions(+), 21 deletions(-)
diff --git a/drivers/common/mlx5/linux/mlx5_nl.c b/drivers/common/mlx5/linux/mlx5_nl.c
index dd69e229e3..1c2f15ad8a 100644
--- a/drivers/common/mlx5/linux/mlx5_nl.c
+++ b/drivers/common/mlx5/linux/mlx5_nl.c
@@ -721,8 +721,6 @@ mlx5_nl_vf_mac_addr_modify(int nlsk_fd, unsigned int iface_idx,
* Netlink socket file descriptor.
* @param[in] iface_idx
* Net device interface index.
- * @param mac_own
- * BITFIELD_DECLARE array to store the mac.
* @param mac
* MAC address to register.
* @param index
@@ -734,8 +732,7 @@ 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,
- uint64_t *mac_own, struct rte_ether_addr *mac,
- uint32_t index)
+ struct rte_ether_addr *mac, uint32_t index)
{
int ret;
@@ -744,8 +741,6 @@ mlx5_nl_mac_addr_add(int nlsk_fd, unsigned int iface_idx,
MLX5_ASSERT(index < MLX5_MAX_MAC_ADDRESSES);
if (index >= MLX5_MAX_MAC_ADDRESSES)
return -EINVAL;
-
- BITFIELD_SET(mac_own, index);
}
if (ret == -EEXIST)
return 0;
@@ -759,8 +754,6 @@ mlx5_nl_mac_addr_add(int nlsk_fd, unsigned int iface_idx,
* Netlink socket file descriptor.
* @param[in] iface_idx
* Net device interface index.
- * @param mac_own
- * BITFIELD_DECLARE array to store the mac.
* @param mac
* MAC address to remove.
* @param index
@@ -771,14 +764,13 @@ 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, uint64_t *mac_own,
+mlx5_nl_mac_addr_remove(int nlsk_fd, unsigned int iface_idx,
struct rte_ether_addr *mac, uint32_t index)
{
MLX5_ASSERT(index < MLX5_MAX_MAC_ADDRESSES);
if (index >= MLX5_MAX_MAC_ADDRESSES)
return -EINVAL;
- BITFIELD_RESET(mac_own, index);
return mlx5_nl_mac_addr_modify(nlsk_fd, iface_idx, mac, 0);
}
@@ -850,12 +842,14 @@ mlx5_nl_mac_addr_sync(int nlsk_fd, unsigned int iface_idx,
* @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)
+ uint64_t *mac_own, bool vf)
{
int i;
@@ -865,9 +859,13 @@ mlx5_nl_mac_addr_flush(int nlsk_fd, unsigned int iface_idx,
for (i = n - 1; i >= 0; --i) {
struct rte_ether_addr *m = &mac_addrs[i];
- if (BITFIELD_ISSET(mac_own, i))
- mlx5_nl_mac_addr_remove(nlsk_fd, iface_idx, mac_own, m,
- 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);
+ }
}
}
diff --git a/drivers/common/mlx5/linux/mlx5_nl.h b/drivers/common/mlx5/linux/mlx5_nl.h
index 26923a88fd..3f79a73c85 100644
--- a/drivers/common/mlx5/linux/mlx5_nl.h
+++ b/drivers/common/mlx5/linux/mlx5_nl.h
@@ -56,19 +56,19 @@ struct mlx5_nl_port_info {
__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, uint64_t *mac_own,
+int mlx5_nl_mac_addr_add(int nlsk_fd, unsigned int iface_idx,
struct rte_ether_addr *mac, uint32_t index);
__rte_internal
int mlx5_nl_mac_addr_remove(int nlsk_fd, unsigned int iface_idx,
- uint64_t *mac_own, struct rte_ether_addr *mac,
- uint32_t index);
+ struct rte_ether_addr *mac, uint32_t index);
__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);
+ uint64_t *mac_own,
+ bool vf);
__rte_internal
int mlx5_nl_promisc(int nlsk_fd, unsigned int iface_idx, int enable);
__rte_internal
diff --git a/drivers/net/mlx5/linux/mlx5_os.c b/drivers/net/mlx5/linux/mlx5_os.c
index 85b3fabaf5..dda51a138e 100644
--- a/drivers/net/mlx5/linux/mlx5_os.c
+++ b/drivers/net/mlx5/linux/mlx5_os.c
@@ -3223,8 +3223,10 @@ 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), priv->mac_own,
+ mlx5_ifindex(dev),
&dev->data->mac_addrs[index], index);
+ if (index < MLX5_MAX_MAC_ADDRESSES)
+ BITFIELD_RESET(priv->mac_own, index);
}
/**
@@ -3250,8 +3252,11 @@ 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), priv->mac_own,
+ mlx5_ifindex(dev),
mac, index);
+ if (!ret)
+ BITFIELD_SET(priv->mac_own, index);
+
return ret;
}
@@ -3331,8 +3336,9 @@ void
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;
mlx5_nl_mac_addr_flush(priv->nl_socket_route, mlx5_ifindex(dev),
dev->data->mac_addrs,
- MLX5_MAX_MAC_ADDRESSES, priv->mac_own);
+ MLX5_MAX_MAC_ADDRESSES, priv->mac_own, vf);
}
--
2.34.1
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH V3 2/2] net/mlx5: add support for flows targeting multicast MAC addresses
2025-08-25 14:13 [PATCH V3 0/2] resolve flow creation issue for multicast MAC addresses Gavin Li
2025-08-25 14:13 ` [PATCH V3 1/2] net/mlx5: update how MAC address bit-fields are used Gavin Li
@ 2025-08-25 14:13 ` Gavin Li
2025-08-25 14:52 ` Thomas Monjalon
1 sibling, 1 reply; 5+ messages in thread
From: Gavin Li @ 2025-08-25 14:13 UTC (permalink / raw)
To: matan, viacheslavo, orika, thomas, Dariusz Sosnowski, Bing Zhao,
Suanming Mou, Minggang Li (Gavin)
Cc: dev, rasland, stable
Rules for multicast MAC addresses are intended to filter multicast traffic
and are managed through multicast MAC add/remove APIs. In mlx5_dev_spawn
function, devices (PF, VFs, and SFs) retrieve the netdev-configured MAC
addresses via netlink and store them in the PMD device data, which
includes multicast MAC addresses.
Previously, flows for multicast MAC addresses were incorrectly disabled,
causing the multicast MAC add API to stop working. As a result, multicast
traffic directed to those multicast MAC addresses was not received.
To resolve this and update the multicast MAC address rules, create them
within mlx5_traffic_enable.
Fixes: 2d0665a7f771 ("net/mlx5: align PF and VF/SF MAC address handling")
Cc: stable@dpdk.org
Signed-off-by: Gavin Li <gavinl@nvidia.com>
---
drivers/net/mlx5/mlx5_trigger.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/net/mlx5/mlx5_trigger.c b/drivers/net/mlx5/mlx5_trigger.c
index 6c6f228afd..46479fbf09 100644
--- a/drivers/net/mlx5/mlx5_trigger.c
+++ b/drivers/net/mlx5/mlx5_trigger.c
@@ -1813,7 +1813,10 @@ mlx5_traffic_enable(struct rte_eth_dev *dev)
for (i = 0; i != MLX5_MAX_MAC_ADDRESSES; ++i) {
struct rte_ether_addr *mac = &dev->data->mac_addrs[i];
- if (!memcmp(mac, &cmp, sizeof(*mac)) || rte_is_multicast_ether_addr(mac))
+ /* Add flows for unicast and multicast mac addresses added by API. */
+ if (!memcmp(mac, &cmp, sizeof(*mac)) ||
+ !BITFIELD_ISSET(priv->mac_own, i) ||
+ (dev->data->all_multicast && rte_is_multicast_ether_addr(mac)))
continue;
memcpy(&unicast.hdr.dst_addr.addr_bytes,
mac->addr_bytes,
--
2.34.1
^ permalink raw reply [flat|nested] 5+ messages in thread