DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH V3 0/2] resolve flow creation issue for multicast MAC addresses
@ 2025-08-25 14:13 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 ` [PATCH V3 2/2] net/mlx5: add support for flows targeting multicast MAC addresses Gavin Li
  0 siblings, 2 replies; 5+ messages in thread
From: Gavin Li @ 2025-08-25 14:13 UTC (permalink / raw)
  To: matan, viacheslavo, orika, thomas; +Cc: dev, rasland

A bug was introduced by commit 2d0665a7f771 ("net/mlx5: align PF and
VF/SF MAC address handling"). Flows for multicast MAC addresses would
not be created anymore.

This patch series are to fix the issue.

Minggang Li (Gavin) (2):
  net/mlx5: update how MAC address bit-fields are used
  net/mlx5: add support for flows targeting multicast MAC addresses

 drivers/common/mlx5/linux/mlx5_nl.c | 26 ++++++++++++--------------
 drivers/common/mlx5/linux/mlx5_nl.h |  8 ++++----
 drivers/net/mlx5/linux/mlx5_os.c    | 12 +++++++++---
 drivers/net/mlx5/mlx5_trigger.c     |  5 ++++-
 4 files changed, 29 insertions(+), 22 deletions(-)

-- 
2.34.1


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

* [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

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

25/08/2025 16:13, Gavin Li:
> Rules for multicast MAC addresses are intended to filter multicast traffic
> and are managed through multicast MAC add/remove APIs.

You should name the functions to be explicit.
Also it is not only managed via DPDK API,
as you say below we also retrieve kernel addresses.

> 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.

To be clear, it was blocking addresses added in DPDK,
not ones created in kernel, right?

> 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.

Actually you allow default rules for multicast addresses to be created.

> -		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;

PS: you forgot to use --in-reply-to to keep all versions in the same mail thread.



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

* Re: [PATCH V3 1/2] net/mlx5: update how MAC address bit-fields are used
  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:54   ` Thomas Monjalon
  0 siblings, 0 replies; 5+ messages in thread
From: Thomas Monjalon @ 2025-08-25 14:54 UTC (permalink / raw)
  To: Gavin Li
  Cc: matan, viacheslavo, orika, Dariusz Sosnowski, Bing Zhao,
	Suanming Mou, dev, rasland

25/08/2025 16:13, Gavin Li:
> 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.

To be clear, there is no behaviour change in this patch?

You should mention the goal of this patch (preparation of a fix for multicast).




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

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

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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:54   ` Thomas Monjalon
2025-08-25 14:13 ` [PATCH V3 2/2] net/mlx5: add support for flows targeting multicast MAC addresses Gavin Li
2025-08-25 14:52   ` 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).