net/mlx5: add support for flows targeting multicast MAC addresses
PATCH v2 1/1 net/mlx5: add support for flows targeting multicast MAC addresses
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.
--- 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(-)
drivers/net/mlx5/linux/mlx5_os.c +3 -0
@@ -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; }
drivers/net/mlx5/mlx5.h +1 -0
@@ -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. */
drivers/net/mlx5/mlx5_trigger.c +4 -1
@@ -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,
Signature · 1 line
2.34.1
14/08/2025 12:08, Gavin Li:
Quoted 8 lines
Rules for multicast MAC addresses are intended to filter multicast traffic and are managed through multicast MAC add/remove APIs. In
mlx5_dev_spawnfunction, 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.
drivers/net/mlx5/mlx5.h struct mlx5_priv { · line 1979
Quoted 2 lines
drivers/net/mlx5/mlx5.h +1
-0BITFIELD_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?
Quoted 7 lines · Thomas Monjalon
14/08/2025 12:08, Gavin Li:
Quoted 6 lines
Rules for multicast MAC addresses are intended to filter multicast traffic and are managed through multicast MAC add/remove APIs. In
mlx5_dev_spawnfunction, 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.
Quoted 5 lines
Quoted 2 lines
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.
ACK
Quoted 4 lines
drivers/net/mlx5/mlx5.h struct mlx5_priv { · line 1979
Quoted 2 lines
BITFIELD_DECLARE(mac_own, uint64_t, MLX5_MAX_MAC_ADDRESSES);drivers/net/mlx5/mlx5.h +1
-0+BITFIELD_DECLARE (mac_pmd, uint64_t,MLX5_MAX_MAC_ADDRESSES );Not sure about the naming.
What is the difference betweenmac_ownandmac_pmd?
mac_own serves as a flag for MAC addresses, indicating that they were added for VF by pmd. This flag is useful for the flush API, which can clear flows associated with VF MAC addresses. Similarly, mac_pmd is used to show that a MAC address was added by pmd for PF, VF, and SFs. It helps differentiate MAC addresses that have been synchronized from the kernel driver.
Quoted 1 line
15/08/2025 03:55, Minggang(Gavin) Li:
Quoted 20 lines · Thomas Monjalon
Quoted 7 lines
14/08/2025 12:08, Gavin Li:
Quoted 6 lines
Rules for multicast MAC addresses are intended to filter multicast traffic and are managed through multicast MAC add/remove APIs. In
mlx5_dev_spawnfunction, 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.Quoted 5 lines
Quoted 2 lines
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.ACK
Quoted 4 lines
drivers/net/mlx5/mlx5.h struct mlx5_priv { · line 1979
Quoted 2 lines
BITFIELD_DECLARE(mac_own, uint64_t, MLX5_MAX_MAC_ADDRESSES);drivers/net/mlx5/mlx5.h +1
-0+BITFIELD_DECLARE (mac_pmd, uint64_t,MLX5_MAX_MAC_ADDRESSES );Not sure about the naming.
What is the difference betweenmac_ownandmac_pmd?
Quoted 6 lines
mac_ownserves as a flag for MAC addresses, indicating that they were added for VF by pmd. This flag is useful for the flush API, which can clear flows associated with VF MAC addresses. Similarly,mac_pmdis used to show that a MAC address was added by pmd for PF, VF, and SFs. It helps differentiate MAC addresses that have been synchronized from the kernel driver.
The description does not match the name.
Please could you find a better name and add a comment in the code to explain the details?
If you need to change the previous variable, I suppose it would be accepted.