net/mlx5/windows: fix MAC address ownership tracking
PATCH 1/1 net/mlx5/windows: fix MAC address ownership tracking
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.
--- drivers/net/mlx5/windows/mlx5_os.c | 32 +++++++++++++++++++----------- 1 file changed, 20 insertions(+), 12 deletions(-)
drivers/net/mlx5/windows/mlx5_os.c +20 -12
@@ -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 ; }
Signature · 1 line
2.28.0.windows.1
Hi,
Quoted 26 lines · Itai Sharoni
The Windows implementation was not properly tracking MAC address ownership via the
mac_ownbitfield, 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 themac_ownbit 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_ownbitfield:-
mlx5_os_mac_addr_add: Setmac_ownbit when adding the device's primary MAC address (the only MAC that Windows supports)-
mlx5_os_mac_addr_remove: Clearmac_ownbit for the specified index to maintain internal tracking consistency-
mlx5_os_mac_addr_flush: Iterate and clear allmac_ownbits during device cleanupWhile 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.
Quoted 5 lines
Fixes 8c06434cd9e4 ("net/mlx5: fix multicast")Signed-off-by Itai Sharoni <[email protected]>Acked-by Bing Zhao <[email protected]>
Patch applied to next-net-mlx,
Kindest regards
Raslan Darawsheh