DPDK patches and discussions
 help / color / mirror / Atom feed
From: Itai Sharoni <isharoni@nvidia.com>
To: <dev@dpdk.org>
Cc: <mkashani@nvidia.com>, <rasland@nvidia.com>,
	Itai Sharoni <isharoni@nvidia.com>, <stable@dpdk.org>,
	Bing Zhao <bingz@nvidia.com>,
	Dariusz Sosnowski <dsosnowski@nvidia.com>,
	Viacheslav Ovsiienko <viacheslavo@nvidia.com>,
	Ori Kam <orika@nvidia.com>, Suanming Mou <suanmingm@nvidia.com>,
	Matan Azrad <matan@nvidia.com>, Gavin Li <gavinl@nvidia.com>
Subject: [PATCH] net/mlx5/windows: fix MAC address ownership tracking
Date: Tue, 9 Dec 2025 14:24:05 +0200	[thread overview]
Message-ID: <20251209122406.3364-1-isharoni@nvidia.com> (raw)

The Windows implementation was not properly tracking MAC address
ownership via the mac_own bitfield, unlike the Linux implementation.
This caused issues with control flow creation for MAC addresses.

Commit 8c06434cd9e4 ("net/mlx5: fix multicast") added a check to skip
creating control flows for MAC addresses where the mac_own bit is not
set. Since Windows never set these bits, the primary MAC address flow
was skipped, resulting in packet drops when promiscuous mode is
disabled.

Update all three MAC address ownership functions to properly manage
the mac_own bitfield:

- mlx5_os_mac_addr_add: Set mac_own bit when adding the device's
  primary MAC address (the only MAC that Windows supports)

- mlx5_os_mac_addr_remove: Clear mac_own bit for the specified index
  to maintain internal tracking consistency

- mlx5_os_mac_addr_flush: Iterate and clear all mac_own bits during
  device cleanup

While Windows cannot add or remove MAC addresses from hardware (no
Netlink equivalent), proper bitfield tracking is essential for internal
state consistency and correct control flow management.

Fixes: 8c06434cd9e4 ("net/mlx5: fix multicast")
Cc: stable@dpdk.org

Signed-off-by: Itai Sharoni <isharoni@nvidia.com>
Acked-by: Bing Zhao <bingz@nvidia.com>
---
 drivers/net/mlx5/windows/mlx5_os.c | 32 +++++++++++++++++++-----------
 1 file changed, 20 insertions(+), 12 deletions(-)

diff --git a/drivers/net/mlx5/windows/mlx5_os.c b/drivers/net/mlx5/windows/mlx5_os.c
index 4eadc872a5..4a00c28009 100644
--- a/drivers/net/mlx5/windows/mlx5_os.c
+++ b/drivers/net/mlx5/windows/mlx5_os.c
@@ -689,23 +689,27 @@ mlx5_os_read_dev_stat(struct mlx5_priv *priv, const char *ctr_name,
 
 /**
  * Flush device MAC addresses
- * Currently it has no support under Windows.
- *
+ * Currently Windows does not support adding and removing MAC addresses,
+ * This function resets the mac_own bit for all MAC addresses for internal tracking.
  * @param dev
  *   Pointer to Ethernet device structure.
- *
  */
 void
 mlx5_os_mac_addr_flush(struct rte_eth_dev *dev)
 {
-	(void)dev;
-	DRV_LOG(WARNING, "%s: is not supported", __func__);
+	struct mlx5_priv *priv = dev->data->dev_private;
+	int i;
+
+	for (i = MLX5_MAX_MAC_ADDRESSES - 1; i >= 0; --i) {
+		if (BITFIELD_ISSET(priv->mac_own, i))
+			BITFIELD_RESET(priv->mac_own, i);
+	}
 }
 
 /**
  * Remove a MAC address from device
- * Currently it has no support under Windows.
- *
+ * Currently Windows does not support adding and removing MAC addresses,
+ * This function resets the mac_own bit for the specified index for internal tracking.
  * @param dev
  *   Pointer to Ethernet device structure.
  * @param index
@@ -714,14 +718,16 @@ mlx5_os_mac_addr_flush(struct rte_eth_dev *dev)
 void
 mlx5_os_mac_addr_remove(struct rte_eth_dev *dev, uint32_t index)
 {
-	(void)dev;
-	(void)(index);
-	DRV_LOG(WARNING, "%s: is not supported", __func__);
+	struct mlx5_priv *priv = dev->data->dev_private;
+
+	if (index < MLX5_MAX_MAC_ADDRESSES)
+		BITFIELD_RESET(priv->mac_own, index);
 }
 
 /**
  * Adds a MAC address to the device
- * Currently it has no support under Windows.
+ * Currently Windows does not support adding and removing MAC addresses,
+ * This function sets the mac_own bit only if the MAC address already exists.
  *
  * @param dev
  *   Pointer to Ethernet device structure.
@@ -737,7 +743,7 @@ int
 mlx5_os_mac_addr_add(struct rte_eth_dev *dev, struct rte_ether_addr *mac,
 		     uint32_t index)
 {
-	(void)index;
+	struct mlx5_priv *priv = dev->data->dev_private;
 	struct rte_ether_addr lmac;
 
 	if (mlx5_get_mac(dev, &lmac.addr_bytes)) {
@@ -752,6 +758,8 @@ mlx5_os_mac_addr_add(struct rte_eth_dev *dev, struct rte_ether_addr *mac,
 			"adding new mac address to device is unsupported");
 		return -ENOTSUP;
 	}
+	/* Mark this MAC address as owned by the PMD */
+	BITFIELD_SET(priv->mac_own, index);
 	return 0;
 }
 
-- 
2.28.0.windows.1


                 reply	other threads:[~2025-12-09 12:24 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20251209122406.3364-1-isharoni@nvidia.com \
    --to=isharoni@nvidia.com \
    --cc=bingz@nvidia.com \
    --cc=dev@dpdk.org \
    --cc=dsosnowski@nvidia.com \
    --cc=gavinl@nvidia.com \
    --cc=matan@nvidia.com \
    --cc=mkashani@nvidia.com \
    --cc=orika@nvidia.com \
    --cc=rasland@nvidia.com \
    --cc=stable@dpdk.org \
    --cc=suanmingm@nvidia.com \
    --cc=viacheslavo@nvidia.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).