DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH V2] net/mlx5: add support for flows targeting multicast MAC addresses
@ 2025-08-14 10:08 Gavin Li
  2025-08-14 14:05 ` Thomas Monjalon
  0 siblings, 1 reply; 2+ messages in thread
From: Gavin Li @ 2025-08-14 10:08 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.

To update 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/linux/mlx5_os.c | 3 +++
 drivers/net/mlx5/mlx5.h          | 1 +
 drivers/net/mlx5/mlx5_trigger.c  | 5 ++++-
 3 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/net/mlx5/linux/mlx5_os.c b/drivers/net/mlx5/linux/mlx5_os.c
index 696a3e12c7..b8d75a97e7 100644
--- a/drivers/net/mlx5/linux/mlx5_os.c
+++ b/drivers/net/mlx5/linux/mlx5_os.c
@@ -3216,6 +3216,7 @@ mlx5_os_mac_addr_remove(struct rte_eth_dev *dev, uint32_t index)
 		mlx5_nl_mac_addr_remove(priv->nl_socket_route,
 					mlx5_ifindex(dev), priv->mac_own,
 					&dev->data->mac_addrs[index], index);
+	BITFIELD_RESET(priv->mac_pmd, index);
 }
 
 /**
@@ -3243,6 +3244,8 @@ mlx5_os_mac_addr_add(struct rte_eth_dev *dev, struct rte_ether_addr *mac,
 		ret = mlx5_nl_mac_addr_add(priv->nl_socket_route,
 					   mlx5_ifindex(dev), priv->mac_own,
 					   mac, index);
+	if (!ret)
+		BITFIELD_SET(priv->mac_pmd, index);
 	return ret;
 }
 
diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h
index c08894cd03..50ed46540c 100644
--- a/drivers/net/mlx5/mlx5.h
+++ b/drivers/net/mlx5/mlx5.h
@@ -1976,6 +1976,7 @@ struct mlx5_priv {
 	struct rte_pci_device *pci_dev; /* Backend PCI device. */
 	struct rte_ether_addr mac[MLX5_MAX_MAC_ADDRESSES]; /* MAC addresses. */
 	BITFIELD_DECLARE(mac_own, uint64_t, MLX5_MAX_MAC_ADDRESSES);
+	BITFIELD_DECLARE(mac_pmd, uint64_t, MLX5_MAX_MAC_ADDRESSES);
 	/* Bit-field of MAC addresses owned by the PMD. */
 	uint16_t vlan_filter[MLX5_MAX_VLAN_IDS]; /* VLAN filters table. */
 	unsigned int vlan_filter_n; /* Number of configured VLAN filters. */
diff --git a/drivers/net/mlx5/mlx5_trigger.c b/drivers/net/mlx5/mlx5_trigger.c
index 6c6f228afd..cbc91be3b1 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_pmd, 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] 2+ messages in thread

* Re: [PATCH V2] net/mlx5: add support for flows targeting multicast MAC addresses
  2025-08-14 10:08 [PATCH V2] net/mlx5: add support for flows targeting multicast MAC addresses Gavin Li
@ 2025-08-14 14:05 ` Thomas Monjalon
  0 siblings, 0 replies; 2+ messages in thread
From: Thomas Monjalon @ 2025-08-14 14:05 UTC (permalink / raw)
  To: Gavin Li
  Cc: matan, viacheslavo, orika, Dariusz Sosnowski, Bing Zhao,
	Suanming Mou, dev, rasland, stable

14/08/2025 12:08, Gavin Li:
> 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.
> 
> To update multicast MAC address rules, create them within
> mlx5_traffic_enable.

Sorry this is not clear.
Please explain what was the previous behaviour with a past tense,
and what is the new changed behaviour.

>  	BITFIELD_DECLARE(mac_own, uint64_t, MLX5_MAX_MAC_ADDRESSES);
> +	BITFIELD_DECLARE(mac_pmd, uint64_t, MLX5_MAX_MAC_ADDRESSES);

Not sure about the naming.
What is the difference between mac_own and mac_pmd?



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-08-14 14:05 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-08-14 10:08 [PATCH V2] net/mlx5: add support for flows targeting multicast MAC addresses Gavin Li
2025-08-14 14:05 ` Thomas Monjalon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).