Remove limitations coming from legacy VMDq
PATCH v8 5/5 net/mlx5: accept more unicast MAC addresses
In reply to David MarchandStarting firmware version 22.49.1014, the number of mac addresses per VF is not capped to 128 anymore.
The value can be increased via devlink:
$ devlink dev param set pci/0000:3b:00.2 name max_macs value 4096 \ cmode driverinit $ devlink dev reload pci/0000:3b:00.2
On the DPDK side, we must retrieve the maximum number of unicast and multicast addresses supported with a query to the firmware.
Then, dynamically allocate the mac addresses arrays and report the limit instead of the previous hardcoded value.
---
Changes since v7:
- updated HWS control path and removed MLX5_MAX_MAC_ADDRESSES constant,
Changes since v6:
- fixed crash in case of partial init failure in mlx5_dev_spawn, and cleaned mlx5_os_pci_probe_pf,
- fixed compilation without assert in mlx5_internal_mac_addr_remove,
Changes since v4:
- added RN update,
- fixed types of fields added to mlx5_hca_attr and mlx5_dev_cap,
- used RTE_BIT32,
- fixed mlx5_nl_mac_addr_sync inverted arguments,
--- doc/guides/rel_notes/release_26_11.rst | 5 +++ drivers/common/mlx5/mlx5_devx_cmds.c | 4 +++ drivers/common/mlx5/mlx5_devx_cmds.h | 2 ++ drivers/net/mlx5/linux/mlx5_os.c | 47 +++++++++++++++++++------- drivers/net/mlx5/mlx5.c | 9 ++--- drivers/net/mlx5/mlx5.h | 11 +++--- drivers/net/mlx5/mlx5_ethdev.c | 2 +- drivers/net/mlx5/mlx5_flow_hw.c | 5 +-- drivers/net/mlx5/mlx5_mac.c | 20 ++++++----- drivers/net/mlx5/mlx5_trigger.c | 10 +++--- drivers/net/mlx5/windows/mlx5_os.c | 41 +++++++++++++++++----- 11 files changed, 108 insertions(+), 48 deletions(-)
doc/guides/rel_notes/release_26_11.rst +5 -0
@@ -55,6 +55,11 @@ New Features Also, make sure to start the actual text at the margin. ======================================================= +* **Updated NVIDIA mlx5 ethernet driver.** + + * Increased the maximum number of secondary unicast MAC addresses from 128 to up to 4096 + (depending on devlink configuration on the associated kernel netdevice). + Removed Items -------------
drivers/common/mlx5/mlx5_devx_cmds.c +4 -0
@@ -1110,6 +1110,10 @@ mlx5_devx_cmd_query_hca_attr(void *ctx, attr->log_max_pd =MLX5_GET (cmd_hca_cap, hcattr, log_max_pd); attr->log_max_srq =MLX5_GET (cmd_hca_cap, hcattr, log_max_srq); attr->log_max_srq_sz =MLX5_GET (cmd_hca_cap, hcattr, log_max_srq_sz); + attr->log_max_current_uc_list =MLX5_GET (cmd_hca_cap, hcattr, + log_max_current_uc_list); + attr->log_max_current_mc_list =MLX5_GET (cmd_hca_cap, hcattr, + log_max_current_mc_list); attr->reg_c_preserve =MLX5_GET (cmd_hca_cap, hcattr, reg_c_preserve); attr->mmo_regex_qp_en =MLX5_GET (cmd_hca_cap, hcattr, regexp_mmo_qp);
drivers/common/mlx5/mlx5_devx_cmds.h +2 -0
@@ -356,6 +356,8 @@ struct mlx5_hca_attr { uint8_t tx_sw_owner_v2:1; uint8_t esw_sw_owner:1; uint8_t esw_sw_owner_v2:1; + uint8_t log_max_current_uc_list:5; + uint8_t log_max_current_mc_list:5; };/* LAG Context. */
drivers/net/mlx5/linux/mlx5_os.c +35 -12
87 lines not on this page · raw message
drivers/net/mlx5/mlx5.c +3 -6
@@ -2556,6 +2556,9 @@ mlx5_dev_close(struct rte_eth_dev *dev)mlx5_list_destroy (priv->hrxqs);mlx5_free (priv->ext_rxqs);mlx5_free (priv->ext_txqs); +mlx5_free (priv->mac); + dev->data->mac_addrs =NULL ; +mlx5_free (priv->mac_own); sh->port[priv->dev_port -1 ].nl_ih_port_id =RTE_MAX_ETHPORTS ;/* * The interrupt handler port id must be reset before priv is reset
@@ -2590,12 +2593,6 @@ mlx5_dev_close(struct rte_eth_dev *dev)mlx5_flow_pools_destroy (priv);memset (priv,0 ,sizeof (*priv)); priv->domain_id =RTE_ETH_DEV_SWITCH_DOMAIN_ID_INVALID ; -/* -* Reset mac_addrs to NULL such that it is not freed as part of -* rte_eth_dev_release_port(). mac_addrs is part of dev_private so -* it is freed when dev_private is freed. -*/ - dev->data->mac_addrs =NULL ;return 0 ; }
drivers/net/mlx5/mlx5.h +5 -6
@@ -87,9 +87,6 @@#define MLX5_MAX_UC_MAC_ADDRESSES 128/* Maximum number of simultaneous Multicast MAC addresses. */ #define MLX5_MAX_MC_MAC_ADDRESSES 128 -/* Maximum number of simultaneous MAC addresses. */ -#define MLX5_MAX_MAC_ADDRESSES \ - (MLX5_MAX_UC_MAC_ADDRESSES + MLX5_MAX_MC_MAC_ADDRESSES)enum mlx5_ipool_index {#if defined(HAVE_IBV_FLOW_DV_SUPPORT ) || !defined(HAVE_INFINIBAND_VERBS_H )
@@ -217,6 +214,9 @@ struct mlx5_dev_cap { } mprq;/* Capability for Multi-Packet RQ. */ char fw_ver[64 ];/* Firmware version of this device. */ struct flow_hw_port_info esw_info;/* E-switch manager reg_c0. */ +uint32_t max_uc_mac_addrs;/* Maximum unicast MAC addresses. */ +uint32_t max_mc_mac_addrs;/* Maximum multicast MAC addresses. */ +uint32_t max_mac_addrs;/* Total maximum MAC addresses. */ };#define MLX5_MPESW_PORT_INVALID (-1)
@@ -2018,9 +2018,8 @@ struct mlx5_priv {struct mlx5_dev_ctx_shared *sh;/* Shared device context. */ uint32_t dev_port;/* Device port number. */ struct rte_pci_device *pci_dev;/* Backend PCI device. */ -struct rte_ether_addr mac[MLX5_MAX_MAC_ADDRESSES ];/* MAC addresses. */ -RTE_BITSET_DECLARE (mac_own,MLX5_MAX_MAC_ADDRESSES ); -/* Bit-field of MAC addresses owned by the PMD. */ +struct rte_ether_addr *mac;/* MAC addresses. */ +uint64_t *mac_own;/* 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. */ /* Device properties. */
drivers/net/mlx5/mlx5_ethdev.c +1 -1
@@ -392,7 +392,7 @@ mlx5_dev_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *info) max =RTE_MIN (max, (unsigned int )UINT16_MAX ); info->max_rx_queues = max; info->max_tx_queues = max; - info->max_mac_addrs =MLX5_MAX_UC_MAC_ADDRESSES ; + info->max_mac_addrs = priv->sh->dev_cap.max_uc_mac_addrs; info->rx_queue_offload_capa =mlx5_get_rx_queue_offloads (dev); info->rx_seg_capa.max_nseg =MLX5_MAX_RXQ_NSEG ; info->rx_seg_capa.multi_pools = !priv->config.mprq.enabled;
drivers/net/mlx5/mlx5_flow_hw.c +3 -2
@@ -16697,10 +16697,11 @@ __flow_hw_ctrl_flows_unicast(struct rte_eth_dev *dev,struct rte_flow_template_table *tbl, const enum mlx5_flow_ctrl_rx_expanded_rss_type rss_type) { + struct mlx5_priv *priv = dev->data->dev_private;unsigned int i;int ret; -for (i =0 ; i <MLX5_MAX_MAC_ADDRESSES ; ++i) { +for (i =0 ; i < priv->sh->dev_cap.max_mac_addrs; ++i) {struct rte_ether_addr *mac = &dev->data->mac_addrs[i];if (rte_is_zero_ether_addr (mac))
@@ -16767,7 +16768,7 @@ __flow_hw_ctrl_flows_unicast_vlan(struct rte_eth_dev *dev,unsigned int i;unsigned int j; -for (i =0 ; i <MLX5_MAX_MAC_ADDRESSES ; ++i) { +for (i =0 ; i < priv->sh->dev_cap.max_mac_addrs; ++i) {struct rte_ether_addr *mac = &dev->data->mac_addrs[i];if (rte_is_zero_ether_addr (mac))
drivers/net/mlx5/mlx5_mac.c +12 -8
@@ -36,7 +36,7 @@ mlx5_internal_mac_addr_remove(struct rte_eth_dev *dev,uint32_t index, struct rte_ether_addr *addr) { - MLX5_ASSERT(index < MLX5_MAX_MAC_ADDRESSES); + MLX5_ASSERT(index < MLX5_SH(dev)->dev_cap.max_mac_addrs);if (rte_is_zero_ether_addr (&dev->data->mac_addrs[index]))return false;mlx5_os_mac_addr_remove (dev, index);
@@ -63,16 +63,17 @@ static int mlx5_internal_mac_addr_add(struct rte_eth_dev *dev, struct rte_ether_addr *mac, uint32_t index) { + struct mlx5_priv *priv = dev->data->dev_private;unsigned int i;int ret; -MLX5_ASSERT (index <MLX5_MAX_MAC_ADDRESSES ); +MLX5_ASSERT (index < priv->sh->dev_cap.max_mac_addrs);if (rte_is_zero_ether_addr (mac)) { rte_errno =EINVAL ;return -rte_errno; }/* First, make sure this address isn't already configured. */ -for (i =0 ; (i !=MLX5_MAX_MAC_ADDRESSES ); ++i) { +for (i =0 ; i != priv->sh->dev_cap.max_mac_addrs; ++i) {/* Skip this index, it's going to be reconfigured. */ if (i == index)continue ;
@@ -101,10 +102,11 @@ mlx5_internal_mac_addr_add(struct rte_eth_dev *dev, struct rte_ether_addr *mac,void mlx5_mac_addr_remove (struct rte_eth_dev *dev,uint32_t index) { +struct mlx5_priv *priv = dev->data->dev_private;struct rte_ether_addr addr = {0 };int ret; -if (index >=MLX5_MAX_UC_MAC_ADDRESSES ) +if (index >= priv->sh->dev_cap.max_uc_mac_addrs)return ;if (mlx5_internal_mac_addr_remove (dev, index, &addr)) { ret =mlx5_traffic_mac_remove (dev, &addr);
@@ -133,9 +135,10 @@ int mlx5_mac_addr_add(struct rte_eth_dev *dev, struct rte_ether_addr *mac, uint32_t index, uint32_t vmdq __rte_unused) { + struct mlx5_priv *priv = dev->data->dev_private;int ret; -if (index >=MLX5_MAX_UC_MAC_ADDRESSES ) { +if (index >= priv->sh->dev_cap.max_uc_mac_addrs) { rte_errno =EINVAL ;return -rte_errno; }
@@ -217,16 +220,17 @@ int mlx5_set_mc_addr_list(struct rte_eth_dev *dev, struct rte_ether_addr *mc_addr_set, uint32_t nb_mc_addr) { + struct mlx5_priv *priv = dev->data->dev_private;uint32_t i;int ret; -if (nb_mc_addr >=MLX5_MAX_MC_MAC_ADDRESSES ) { +if (nb_mc_addr >= priv->sh->dev_cap.max_mc_mac_addrs) { rte_errno =ENOSPC ;return -rte_errno; } -for (i =MLX5_MAX_UC_MAC_ADDRESSES ; i !=MLX5_MAX_MAC_ADDRESSES ; ++i) +for (i = priv->sh->dev_cap.max_uc_mac_addrs; i != priv->sh->dev_cap.max_mac_addrs; ++i)mlx5_internal_mac_addr_remove (dev, i,NULL ); - i =MLX5_MAX_UC_MAC_ADDRESSES ; + i = priv->sh->dev_cap.max_uc_mac_addrs;while (nb_mc_addr--) { ret =mlx5_internal_mac_addr_add (dev, mc_addr_set++, i++);if (ret)
drivers/net/mlx5/mlx5_trigger.c +5 -5
@@ -1916,7 +1916,7 @@ mlx5_traffic_enable(struct rte_eth_dev *dev) } }/* Add MAC address flows. */ -for (i =0 ; i !=MLX5_MAX_MAC_ADDRESSES ; ++i) { +for (i =0 ; i != priv->sh->dev_cap.max_mac_addrs; ++i) {struct rte_ether_addr *mac = &dev->data->mac_addrs[i];/* Add flows for unicast and multicast mac addresses added by API. */
@@ -2186,7 +2186,7 @@ mlx5_traffic_vlan_add(struct rte_eth_dev *dev, const uint16_t vid)return 0 ;/* Add all unicast DMAC flow rules with new VLAN attached. */ -for (i =0 ; i !=MLX5_MAX_MAC_ADDRESSES ; ++i) { +for (i =0 ; i != priv->sh->dev_cap.max_mac_addrs; ++i) {struct rte_ether_addr *mac = &dev->data->mac_addrs[i];if (rte_is_zero_ether_addr (mac))
@@ -2203,7 +2203,7 @@ mlx5_traffic_vlan_add(struct rte_eth_dev *dev, const uint16_t vid)* Removing after creating VLAN rules so that traffic "gap" is not introduced. */ -for (i =0 ; i !=MLX5_MAX_MAC_ADDRESSES ; ++i) { +for (i =0 ; i != priv->sh->dev_cap.max_mac_addrs; ++i) {struct rte_ether_addr *mac = &dev->data->mac_addrs[i];if (rte_is_zero_ether_addr (mac))
@@ -2241,7 +2241,7 @@ mlx5_traffic_vlan_remove(struct rte_eth_dev *dev, const uint16_t vid)* Recreating first to ensure no traffic "gap". */ -for (i =0 ; i !=MLX5_MAX_MAC_ADDRESSES ; ++i) { +for (i =0 ; i != priv->sh->dev_cap.max_mac_addrs; ++i) {struct rte_ether_addr *mac = &dev->data->mac_addrs[i];if (rte_is_zero_ether_addr (mac))
@@ -2254,7 +2254,7 @@ mlx5_traffic_vlan_remove(struct rte_eth_dev *dev, const uint16_t vid) }/* Remove all unicast DMAC flow rules with this VLAN. */ -for (i =0 ; i !=MLX5_MAX_MAC_ADDRESSES ; ++i) { +for (i =0 ; i != priv->sh->dev_cap.max_mac_addrs; ++i) {struct rte_ether_addr *mac = &dev->data->mac_addrs[i];if (rte_is_zero_ether_addr (mac))
drivers/net/mlx5/windows/mlx5_os.c +33 -8
69 lines not on this page · raw message
Signature · 1 line
2.54.0
Re: [PATCH v8 5/5] net/mlx5: accept more unicast MAC addresses
Quoted 9 lines · David Marchand
Starting firmware version 22.49.1014, the number of mac addresses per VF is not capped to 128 anymore.
The value can be increased via devlink:
$ devlink dev param set pci/0000:3b:00.2 name max_macs value 4096 \ cmode driverinit $ devlink dev reload pci/0000:3b:00.2
Quoted 7 lines
On the DPDK side, we must retrieve the maximum number of unicast and multicast addresses supported with a query to the firmware.
Then, dynamically allocate the mac addresses arrays and report the limit instead of the previous hardcoded value.
Signed-off-by David Marchand <[email protected]>
Sorry, I forgot to add:
Signature · 1 line
David Marchand
Re: [PATCH v8 5/5] net/mlx5: accept more unicast MAC addresses
In reply to David MarchandHi David,
🤖 This review was drafted with assistance from Claude (Anthropic) and reviewed by me before posting.
Thanks for fixing __flow_hw_ctrl_flows_unicast() / _vlan() to loop over priv->sh->dev_cap.max_mac_addrs.
One more spot to check: ctrl_rx_nb_flows_map[MLX5_FLOW_HW_CTRL_RX_ETH_PATTERN_DMAC] (mlx5_flow_hw.c, ~line 11588) is a static initializer still set to the fixed MLX5_MAX_UC_MAC_ADDRESSES (128, unchanged by this series). That value becomes nb_flows -> cfg.max_idx (mlx5_flow_hw.c, ~line 5335), which hard-caps the ipool backing the DMAC/DMAC_VLAN control-flow template table, and this table isn't on the resizable-table path.
So __flow_hw_ctrl_flows_unicast() now loops up to priv->sh->dev_cap.max_mac_addrs (which can be up to ~4096 per this series) and tries to insert one control-flow rule per configured unicast MAC into that same 128-capacity table. On any device that now advertises more than 128 unicast MACs -- which is the whole point of this series -- configuring more than 128 will make flow-rule insertion fail for the 129th+ MAC, even though mlx5_mac_addr_add() itself succeeded. Rx breaks silently for those addresses.
Could you take a look at this one too?
Thanks,
Raslan
PATCH v9 1/5 net/mlx5: remove MAC addresses flush helper on Linux
In reply to David MarchandThis helper is exposing internals of net/mlx5 for no good reason. All this code does is calling the remove helper.
Walk through the list in Linux implementation like the Windows implementation.
--- drivers/common/mlx5/linux/mlx5_nl.c | 40 ----------------------------- drivers/common/mlx5/linux/mlx5_nl.h | 5 ---- drivers/net/mlx5/linux/mlx5_os.c | 13 +++++++--- 3 files changed, 10 insertions(+), 48 deletions(-)
drivers/common/mlx5/linux/mlx5_nl.c +0 -40
@@ -825,46 +825,6 @@ mlx5_nl_mac_addr_sync(int nlsk_fd, unsigned int iface_idx, } } -/** -* Flush all added MAC addresses. -* -* @param[in] nlsk_fd -* Netlink socket file descriptor. -* @param[in] iface_idx -* Net device interface index. -* @param[in] mac_addrs -* Mac addresses array to flush. -* @param n -* @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,bool vf) -{ -int i; - -if (n <=0 || n >MLX5_MAX_MAC_ADDRESSES ) -return ; - -for (i = n -1 ; i >=0 ; --i) { -struct rte_ether_addr *m = &mac_addrs[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); - } - } -} -/** * Enable promiscuous / all multicast mode through Netlink. *
drivers/common/mlx5/linux/mlx5_nl.h +0 -5
@@ -65,11 +65,6 @@ __rte_internalvoid 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, -bool vf); -__rte_internal int mlx5_nl_promisc(int nlsk_fd, unsigned int iface_idx, int enable);__rte_internal int mlx5_nl_allmulti(int nlsk_fd, unsigned int iface_idx, int enable);
drivers/net/mlx5/linux/mlx5_os.c +10 -3
@@ -3529,10 +3529,17 @@ 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; +int i; -mlx5_nl_mac_addr_flush (priv->nl_socket_route,mlx5_ifindex (dev), - dev->data->mac_addrs, -MLX5_MAX_MAC_ADDRESSES , priv->mac_own, vf); +for (i =MLX5_MAX_MAC_ADDRESSES -1 ; i >=0 ; --i) { +if (BITFIELD_ISSET (priv->mac_own, i)) { +if (vf) +mlx5_nl_mac_addr_remove (priv->nl_socket_route, +mlx5_ifindex (dev), + &dev->data->mac_addrs[i], i); +BITFIELD_RESET (priv->mac_own, i); + } + } } static bool
Signature · 1 line
2.54.0
PATCH v9 2/5 net/mlx5: remove redundant MAC address index checks
On the net/mlx5 side, mlx5_mac.c validates that any MAC address and its index is valid before calling the OS specific helpers.
So those OS helpers do not have to validate again the index.
Cascading this consideration, validating the MAC index against MLX5_MAX_MAC_ADDRESSES in common code is also redundant. The common code only deals with netlink, remove any index concern.
---
Changes since v7:
- updated Windows implementation,
--- drivers/common/mlx5/linux/mlx5_nl.c | 17 ++--------------- drivers/common/mlx5/linux/mlx5_nl.h | 4 ++-- drivers/net/mlx5/linux/mlx5_os.c | 9 ++++----- drivers/net/mlx5/windows/mlx5_os.c | 3 +-- 4 files changed, 9 insertions(+), 24 deletions(-)
drivers/common/mlx5/linux/mlx5_nl.c +2 -15
@@ -719,8 +719,6 @@ mlx5_nl_vf_mac_addr_modify(int nlsk_fd, unsigned int iface_idx,* Net device interface index. * @param mac * MAC address to register. -* @param index -* MAC address index. * * @return * 0 on success, a negative errno value otherwise and rte_errno is set.
@@ -728,16 +726,11 @@ mlx5_nl_vf_mac_addr_modify(int nlsk_fd, unsigned int iface_idx,RTE_EXPORT_INTERNAL_SYMBOL (mlx5_nl_mac_addr_add) intmlx5_nl_mac_addr_add (int nlsk_fd,unsigned int iface_idx, -struct rte_ether_addr *mac,uint32_t index) +struct rte_ether_addr *mac) {int ret; ret =mlx5_nl_mac_addr_modify (nlsk_fd, iface_idx, mac,1 ); -if (!ret) { -MLX5_ASSERT (index <MLX5_MAX_MAC_ADDRESSES ); -if (index >=MLX5_MAX_MAC_ADDRESSES ) -return -EINVAL ; - }if (ret == -EEXIST )return 0 ;return ret;
@@ -752,8 +745,6 @@ mlx5_nl_mac_addr_add(int nlsk_fd, unsigned int iface_idx,* Net device interface index. * @param mac * MAC address to remove. -* @param index -* MAC address index. * * @return * 0 on success, a negative errno value otherwise and rte_errno is set.
@@ -761,12 +752,8 @@ mlx5_nl_mac_addr_add(int nlsk_fd, unsigned int iface_idx,RTE_EXPORT_INTERNAL_SYMBOL (mlx5_nl_mac_addr_remove) intmlx5_nl_mac_addr_remove (int nlsk_fd,unsigned int iface_idx, -struct rte_ether_addr *mac,uint32_t index) +struct rte_ether_addr *mac) { -MLX5_ASSERT (index <MLX5_MAX_MAC_ADDRESSES ); -if (index >=MLX5_MAX_MAC_ADDRESSES ) -return -EINVAL ; -return mlx5_nl_mac_addr_modify (nlsk_fd, iface_idx, mac,0 ); }
drivers/common/mlx5/linux/mlx5_nl.h +2 -2
@@ -57,10 +57,10 @@ __rte_internalint mlx5_nl_init (int protocol,int groups);__rte_internal int mlx5_nl_mac_addr_add(int nlsk_fd, unsigned int iface_idx, -struct rte_ether_addr *mac,uint32_t index); +struct rte_ether_addr *mac);__rte_internal int mlx5_nl_mac_addr_remove(int nlsk_fd, unsigned int iface_idx, -struct rte_ether_addr *mac,uint32_t index); +struct rte_ether_addr *mac);__rte_internal void mlx5_nl_mac_addr_sync(int nlsk_fd, unsigned int iface_idx,struct rte_ether_addr *mac_addrs,int n);
drivers/net/mlx5/linux/mlx5_os.c +4 -5
@@ -3382,9 +3382,8 @@ 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), - &dev->data->mac_addrs[index], index); -if (index <MLX5_MAX_MAC_ADDRESSES ) -BITFIELD_RESET (priv->mac_own, index); + &dev->data->mac_addrs[index]); +BITFIELD_RESET (priv->mac_own, index); }/**
@@ -3411,7 +3410,7 @@ 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), - mac, index); + mac);if (!ret)BITFIELD_SET (priv->mac_own, index);
@@ -3536,7 +3535,7 @@ mlx5_os_mac_addr_flush(struct rte_eth_dev *dev)if (vf)mlx5_nl_mac_addr_remove (priv->nl_socket_route,mlx5_ifindex (dev), - &dev->data->mac_addrs[i], i); + &dev->data->mac_addrs[i]);BITFIELD_RESET (priv->mac_own, i); } }
drivers/net/mlx5/windows/mlx5_os.c +1 -2
@@ -718,8 +718,7 @@ mlx5_os_mac_addr_remove(struct rte_eth_dev *dev, uint32_t index) {struct mlx5_priv *priv = dev->data->dev_private; -if (index <MLX5_MAX_MAC_ADDRESSES ) -BITFIELD_RESET (priv->mac_own, index); +BITFIELD_RESET (priv->mac_own, index); }/**
Signature · 1 line
2.54.0
Re: [PATCH v9 2/5] net/mlx5: remove redundant MAC address index checks
PATCH v9 3/5 net/mlx5: pass maximum number of unicast MAC to common code
In reply to David MarchandIsolate how the MAC addresses array is walked through in the common code by passing the max index at which a unicast MAC address is stored in dev->data->mac_addrs[].
With this change, only net/mlx5 knows about the max number of unicast/multicast MAC addresses.
---
Changes since v7:
- switched to heap allocation for intermediate array,
Changes since v5:
- fixed mlx5_nl_mac_addr_cb,
--- drivers/common/mlx5/linux/mlx5_nl.c | 36 ++++++++++++++++++----------- drivers/common/mlx5/linux/mlx5_nl.h | 2 +- drivers/common/mlx5/mlx5_common.h | 8 ------- drivers/net/mlx5/linux/mlx5_os.c | 1 + drivers/net/mlx5/mlx5.h | 8 +++++++ 5 files changed, 33 insertions(+), 22 deletions(-)
drivers/common/mlx5/linux/mlx5_nl.c +23 -13
@@ -171,9 +171,10 @@/* Add/remove MAC address through Netlink */ struct mlx5_nl_mac_addr { -struct rte_ether_addr (*mac)[]; +struct rte_ether_addr **mac;/**< MAC address handled by the device. */ int mac_n;/**< Number of addresses in the array. */ +int max_macs;/**< Size of the array. */ };static RTE_ATOMIC (uint32_t ) atomic_sn;
@@ -475,7 +476,7 @@ mlx5_nl_mac_addr_cb(struct nlmsghdr *nh, void *arg)RTA_OK (attribute, len); attribute = RTA_NEXT(attribute, len)) {if (attribute->rta_type ==NDA_LLADDR ) { -if (data->mac_n ==MLX5_MAX_MAC_ADDRESSES ) { +if (data->mac_n == data->max_macs) {DRV_LOG (WARNING ,"not enough room to finalize the" " request" );
@@ -505,16 +506,16 @@ mlx5_nl_mac_addr_cb(struct nlmsghdr *nh, void *arg)* Net device interface index. * @param mac[out] * Pointer to the array table of MAC addresses to fill. -* Its size should be of MLX5_MAX_MAC_ADDRESSES. -* @param mac_n[out] -* Number of entries filled in MAC array. +* @param mac_n[in,out] +* Size of the MAC array on input. +* Number of entries filled in MAC array on output. * * @return * 0 on success, a negative errno value otherwise and rte_errno is set. */ static int mlx5_nl_mac_addr_list (int nlsk_fd,unsigned int iface_idx, -struct rte_ether_addr (*mac)[],int *mac_n) +struct rte_ether_addr **mac,int *mac_n) {struct {struct nlmsghdr hdr;
@@ -533,6 +534,7 @@ mlx5_nl_mac_addr_list(int nlsk_fd, unsigned int iface_idx,struct mlx5_nl_mac_addr data = { .mac = mac, .mac_n =0 , + .max_macs = *mac_n, };uint32_t sn =MLX5_NL_SN_GENERATE ;int ret;
@@ -766,23 +768,28 @@ mlx5_nl_mac_addr_remove(int nlsk_fd, unsigned int iface_idx,* Net device interface index. * @param mac_addrs * Mac addresses array to sync. +* @param uc_n +* Number of UC entries in @p mac_addrs. * @param n * @p mac_addrs array size. */ RTE_EXPORT_INTERNAL_SYMBOL (mlx5_nl_mac_addr_sync) voidmlx5_nl_mac_addr_sync (int nlsk_fd,unsigned int iface_idx, -struct rte_ether_addr *mac_addrs,int n) +struct rte_ether_addr *mac_addrs,int uc_n,int n) { -struct rte_ether_addr macs[n]; -int macs_n =0 ; +struct rte_ether_addr *macs =NULL ; +int macs_n = n;int i;int ret; -memset (macs,0 , n *sizeof (macs[0 ])); + macs =calloc (n,sizeof (macs[0 ])); +if (macs ==NULL ) + goto out; + ret =mlx5_nl_mac_addr_list (nlsk_fd, iface_idx, &macs, &macs_n);if (ret) -return ; + goto out;for (i =0 ; i != macs_n; ++i) {int j;
@@ -794,7 +801,7 @@ mlx5_nl_mac_addr_sync(int nlsk_fd, unsigned int iface_idx,continue ;if (rte_is_multicast_ether_addr (&macs[i])) {/* Find the first entry available. */ -for (j =MLX5_MAX_UC_MAC_ADDRESSES ; j != n; ++j) { +for (j = uc_n; j != n; ++j) {if (rte_is_zero_ether_addr (&mac_addrs[j])) { mac_addrs[j] = macs[i];break ;
@@ -802,7 +809,7 @@ mlx5_nl_mac_addr_sync(int nlsk_fd, unsigned int iface_idx, } }else {/* Find the first entry available. */ -for (j =0 ; j !=MLX5_MAX_UC_MAC_ADDRESSES ; ++j) { +for (j =0 ; j != uc_n; ++j) {if (rte_is_zero_ether_addr (&mac_addrs[j])) { mac_addrs[j] = macs[i];break ;
@@ -810,6 +817,9 @@ mlx5_nl_mac_addr_sync(int nlsk_fd, unsigned int iface_idx, } } } + +out: +free (macs); }/**
drivers/common/mlx5/linux/mlx5_nl.h +1 -1
@@ -63,7 +63,7 @@ int mlx5_nl_mac_addr_remove(int nlsk_fd, unsigned int iface_idx, struct rte_ether_addr *mac);__rte_internal void mlx5_nl_mac_addr_sync(int nlsk_fd, unsigned int iface_idx, -struct rte_ether_addr *mac_addrs,int n); +struct rte_ether_addr *mac_addrs,int uc_n,int n);__rte_internal int mlx5_nl_promisc(int nlsk_fd, unsigned int iface_idx, int enable); __rte_internal
drivers/common/mlx5/mlx5_common.h +0 -8
@@ -160,14 +160,6 @@ enum { PCI_DEVICE_ID_MELLANOX_CONNECTX10C2C = 0x2101, }; -/* Maximum number of simultaneous unicast MAC addresses. */ -#define MLX5_MAX_UC_MAC_ADDRESSES 128 -/* Maximum number of simultaneous Multicast MAC addresses. */ -#define MLX5_MAX_MC_MAC_ADDRESSES 128 -/* Maximum number of simultaneous MAC addresses. */ -#define MLX5_MAX_MAC_ADDRESSES \ - (MLX5_MAX_UC_MAC_ADDRESSES + MLX5_MAX_MC_MAC_ADDRESSES) -/* Recognized Infiniband device physical port name types. */ enum mlx5_nl_phys_port_name_type {MLX5_PHYS_PORT_NAME_TYPE_NOTSET =0 ,/* Not set. */
drivers/net/mlx5/linux/mlx5_os.c +1 -0
@@ -1762,6 +1762,7 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev,mlx5_nl_mac_addr_sync (priv->nl_socket_route,mlx5_ifindex (eth_dev), eth_dev->data->mac_addrs, +MLX5_MAX_UC_MAC_ADDRESSES ,MLX5_MAX_MAC_ADDRESSES ); priv->ctrl_flows =0 ;rte_spinlock_init (&priv->flow_list_lock);
drivers/net/mlx5/mlx5.h +8 -0
@@ -82,6 +82,14 @@/* Maximum allowed MTU to be reported whenever PMD cannot query it from OS. */ #define MLX5_ETH_MAX_MTU (9978) +/* Maximum number of simultaneous unicast MAC addresses. */ +#define MLX5_MAX_UC_MAC_ADDRESSES 128 +/* Maximum number of simultaneous Multicast MAC addresses. */ +#define MLX5_MAX_MC_MAC_ADDRESSES 128 +/* Maximum number of simultaneous MAC addresses. */ +#define MLX5_MAX_MAC_ADDRESSES \ + (MLX5_MAX_UC_MAC_ADDRESSES + MLX5_MAX_MC_MAC_ADDRESSES) +enum mlx5_ipool_index {#if defined(HAVE_IBV_FLOW_DV_SUPPORT ) || !defined(HAVE_INFINIBAND_VERBS_H )MLX5_IPOOL_DECAP_ENCAP =0 ,/* Pool for encap/decap resource. */
Signature · 1 line
2.54.0
Re: [PATCH v9 3/5] net/mlx5: pass maximum number of unicast MAC to common code
PATCH v9 4/5 net/mlx5: use bitset for tracking MAC addresses
In reply to David MarchandEAL provides bitset that does the same as this set of mlx5 macros.
--- drivers/common/mlx5/mlx5_common.h | 16 ---------------- drivers/net/mlx5/linux/mlx5_os.c | 8 ++++---- drivers/net/mlx5/mlx5.h | 3 ++- drivers/net/mlx5/mlx5_trigger.c | 2 +- drivers/net/mlx5/windows/mlx5_os.c | 8 ++++---- 5 files changed, 11 insertions(+), 26 deletions(-)
drivers/common/mlx5/mlx5_common.h +0 -16
@@ -30,22 +30,6 @@#define MLX5_PCI_DRIVER_NAME "mlx5_pci"#define MLX5_AUXILIARY_DRIVER_NAME "mlx5_auxiliary" -/* Bit-field manipulation. */ -#define BITFIELD_DECLARE (bf, type, size) \ - type bf[(((size_t)(size) / (sizeof(type) * CHAR_BIT)) + \ - !!((size_t)(size) % (sizeof(type) * CHAR_BIT)))] -#define BITFIELD_DEFINE (bf, type, size) \ - BITFIELD_DECLARE((bf), type, (size)) = { 0 } -#define BITFIELD_SET (bf, b) \ - (void)((bf)[((b) / (sizeof((bf)[0]) * CHAR_BIT))] |= \ - ((size_t)1 << ((b) % (sizeof((bf)[0]) * CHAR_BIT)))) -#define BITFIELD_RESET (bf, b) \ - (void)((bf)[((b) / (sizeof((bf)[0]) * CHAR_BIT))] &= \ - ~((size_t)1 << ((b) % (sizeof((bf)[0]) * CHAR_BIT)))) -#define BITFIELD_ISSET (bf, b) \ - !!(((bf)[((b) / (sizeof((bf)[0]) * CHAR_BIT))] & \ - ((size_t)1 << ((b) % (sizeof((bf)[0]) * CHAR_BIT))))) -/* * Helper macros to work around __VA_ARGS__ limitations in a C99 compliant * manner.
drivers/net/mlx5/linux/mlx5_os.c +4 -4
@@ -3384,7 +3384,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), &dev->data->mac_addrs[index]); -BITFIELD_RESET (priv->mac_own, index); +rte_bitset_clear (priv->mac_own, index); }/**
@@ -3413,7 +3413,7 @@ mlx5_os_mac_addr_add(struct rte_eth_dev *dev, struct rte_ether_addr *mac,mlx5_ifindex (dev), mac);if (!ret) -BITFIELD_SET (priv->mac_own, index); +rte_bitset_set (priv->mac_own, index);return ret; }
@@ -3532,12 +3532,12 @@ mlx5_os_mac_addr_flush(struct rte_eth_dev *dev)int i;for (i =MLX5_MAX_MAC_ADDRESSES -1 ; i >=0 ; --i) { -if (BITFIELD_ISSET (priv->mac_own, i)) { +if (rte_bitset_test (priv->mac_own, i)) {if (vf)mlx5_nl_mac_addr_remove (priv->nl_socket_route,mlx5_ifindex (dev), &dev->data->mac_addrs[i]); -BITFIELD_RESET (priv->mac_own, i); +rte_bitset_clear (priv->mac_own, i); } } }
drivers/net/mlx5/mlx5.h +2 -1
@@ -14,6 +14,7 @@#include <rte_pci.h> #include <rte_ether.h> +#include <rte_bitset.h> #include <ethdev_driver.h> #include <rte_rwlock.h> #include <rte_interrupts.h>
@@ -2018,7 +2019,7 @@ struct mlx5_priv {uint32_t dev_port;/* Device port number. */ 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 ); +RTE_BITSET_DECLARE (mac_own,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 +1 -1
@@ -1921,7 +1921,7 @@ mlx5_traffic_enable(struct rte_eth_dev *dev)/* Add flows for unicast and multicast mac addresses added by API. */ if (!memcmp (mac, &cmp,sizeof (*mac)) || - !BITFIELD_ISSET (priv->mac_own, i) || + !rte_bitset_test (priv->mac_own, i) || (dev->data->all_multicast &&rte_is_multicast_ether_addr (mac)))continue ; memcpy(&unicast.hdr.dst_addr.addr_bytes,
drivers/net/mlx5/windows/mlx5_os.c +4 -4
@@ -699,8 +699,8 @@ mlx5_os_mac_addr_flush(struct rte_eth_dev *dev)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); +if (rte_bitset_test (priv->mac_own, i)) +rte_bitset_clear (priv->mac_own, i); } }
@@ -718,7 +718,7 @@ mlx5_os_mac_addr_remove(struct rte_eth_dev *dev, uint32_t index) {struct mlx5_priv *priv = dev->data->dev_private; -BITFIELD_RESET (priv->mac_own, index); +rte_bitset_clear (priv->mac_own, index); }/**
@@ -756,7 +756,7 @@ mlx5_os_mac_addr_add(struct rte_eth_dev *dev, struct rte_ether_addr *mac,return -ENOTSUP ; }/* Mark this MAC address as owned by the PMD */ -BITFIELD_SET (priv->mac_own, index); +rte_bitset_set (priv->mac_own, index);return 0 ; }
Signature · 1 line
2.54.0
Re: [PATCH v9 4/5] net/mlx5: use bitset for tracking MAC addresses
PATCH v9 5/5 net/mlx5: accept more unicast MAC addresses
In reply to David MarchandStarting firmware version 22.49.1014, the number of mac addresses per VF is not capped to 128 anymore.
The value can be increased via devlink:
$ devlink dev param set pci/0000:3b:00.2 name max_macs value 4096 \ cmode driverinit $ devlink dev reload pci/0000:3b:00.2
On the DPDK side, we must retrieve the maximum number of unicast and multicast addresses supported with a query to the firmware.
Then, dynamically allocate the mac addresses arrays and report the limit instead of the previous hardcoded value.
---
Changes since v8:
- fixed (hopefully...) last thing in HWS stuff,
Changes since v7:
- updated HWS control path and removed MLX5_MAX_MAC_ADDRESSES constant,
Changes since v6:
- fixed crash in case of partial init failure in mlx5_dev_spawn, and cleaned mlx5_os_pci_probe_pf,
- fixed compilation without assert in mlx5_internal_mac_addr_remove,
Changes since v4:
- added RN update,
- fixed types of fields added to mlx5_hca_attr and mlx5_dev_cap,
- used RTE_BIT32,
- fixed mlx5_nl_mac_addr_sync inverted arguments,
--- doc/guides/rel_notes/release_26_11.rst | 5 +++ drivers/common/mlx5/mlx5_devx_cmds.c | 4 ++ drivers/common/mlx5/mlx5_devx_cmds.h | 2 + drivers/net/mlx5/linux/mlx5_os.c | 47 +++++++++++++++++------ drivers/net/mlx5/mlx5.c | 9 ++--- drivers/net/mlx5/mlx5.h | 11 +++--- drivers/net/mlx5/mlx5_ethdev.c | 2 +- drivers/net/mlx5/mlx5_flow_hw.c | 53 +++++++++++++++++--------- drivers/net/mlx5/mlx5_mac.c | 20 ++++++---- drivers/net/mlx5/mlx5_trigger.c | 10 ++--- drivers/net/mlx5/windows/mlx5_os.c | 41 ++++++++++++++++---- 11 files changed, 140 insertions(+), 64 deletions(-)
doc/guides/rel_notes/release_26_11.rst +5 -0
@@ -55,6 +55,11 @@ New Features Also, make sure to start the actual text at the margin. ======================================================= +* **Updated NVIDIA mlx5 ethernet driver.** + + * Increased the maximum number of secondary unicast MAC addresses from 128 to up to 4096 + (depending on devlink configuration on the associated kernel netdevice). + Removed Items -------------
drivers/common/mlx5/mlx5_devx_cmds.c +4 -0
@@ -1110,6 +1110,10 @@ mlx5_devx_cmd_query_hca_attr(void *ctx, attr->log_max_pd =MLX5_GET (cmd_hca_cap, hcattr, log_max_pd); attr->log_max_srq =MLX5_GET (cmd_hca_cap, hcattr, log_max_srq); attr->log_max_srq_sz =MLX5_GET (cmd_hca_cap, hcattr, log_max_srq_sz); + attr->log_max_current_uc_list =MLX5_GET (cmd_hca_cap, hcattr, + log_max_current_uc_list); + attr->log_max_current_mc_list =MLX5_GET (cmd_hca_cap, hcattr, + log_max_current_mc_list); attr->reg_c_preserve =MLX5_GET (cmd_hca_cap, hcattr, reg_c_preserve); attr->mmo_regex_qp_en =MLX5_GET (cmd_hca_cap, hcattr, regexp_mmo_qp);
drivers/common/mlx5/mlx5_devx_cmds.h +2 -0
@@ -356,6 +356,8 @@ struct mlx5_hca_attr { uint8_t tx_sw_owner_v2:1; uint8_t esw_sw_owner:1; uint8_t esw_sw_owner_v2:1; + uint8_t log_max_current_uc_list:5; + uint8_t log_max_current_mc_list:5; };/* LAG Context. */
drivers/net/mlx5/linux/mlx5_os.c +35 -12
87 lines not on this page · raw message
drivers/net/mlx5/mlx5.c +3 -6
@@ -2556,6 +2556,9 @@ mlx5_dev_close(struct rte_eth_dev *dev)mlx5_list_destroy (priv->hrxqs);mlx5_free (priv->ext_rxqs);mlx5_free (priv->ext_txqs); +mlx5_free (priv->mac); + dev->data->mac_addrs =NULL ; +mlx5_free (priv->mac_own); sh->port[priv->dev_port -1 ].nl_ih_port_id =RTE_MAX_ETHPORTS ;/* * The interrupt handler port id must be reset before priv is reset
@@ -2590,12 +2593,6 @@ mlx5_dev_close(struct rte_eth_dev *dev)mlx5_flow_pools_destroy (priv);memset (priv,0 ,sizeof (*priv)); priv->domain_id =RTE_ETH_DEV_SWITCH_DOMAIN_ID_INVALID ; -/* -* Reset mac_addrs to NULL such that it is not freed as part of -* rte_eth_dev_release_port(). mac_addrs is part of dev_private so -* it is freed when dev_private is freed. -*/ - dev->data->mac_addrs =NULL ;return 0 ; }
drivers/net/mlx5/mlx5.h +5 -6
@@ -87,9 +87,6 @@#define MLX5_MAX_UC_MAC_ADDRESSES 128/* Maximum number of simultaneous Multicast MAC addresses. */ #define MLX5_MAX_MC_MAC_ADDRESSES 128 -/* Maximum number of simultaneous MAC addresses. */ -#define MLX5_MAX_MAC_ADDRESSES \ - (MLX5_MAX_UC_MAC_ADDRESSES + MLX5_MAX_MC_MAC_ADDRESSES)enum mlx5_ipool_index {#if defined(HAVE_IBV_FLOW_DV_SUPPORT ) || !defined(HAVE_INFINIBAND_VERBS_H )
@@ -217,6 +214,9 @@ struct mlx5_dev_cap { } mprq;/* Capability for Multi-Packet RQ. */ char fw_ver[64 ];/* Firmware version of this device. */ struct flow_hw_port_info esw_info;/* E-switch manager reg_c0. */ +uint32_t max_uc_mac_addrs;/* Maximum unicast MAC addresses. */ +uint32_t max_mc_mac_addrs;/* Maximum multicast MAC addresses. */ +uint32_t max_mac_addrs;/* Total maximum MAC addresses. */ };#define MLX5_MPESW_PORT_INVALID (-1)
@@ -2018,9 +2018,8 @@ struct mlx5_priv {struct mlx5_dev_ctx_shared *sh;/* Shared device context. */ uint32_t dev_port;/* Device port number. */ struct rte_pci_device *pci_dev;/* Backend PCI device. */ -struct rte_ether_addr mac[MLX5_MAX_MAC_ADDRESSES ];/* MAC addresses. */ -RTE_BITSET_DECLARE (mac_own,MLX5_MAX_MAC_ADDRESSES ); -/* Bit-field of MAC addresses owned by the PMD. */ +struct rte_ether_addr *mac;/* MAC addresses. */ +uint64_t *mac_own;/* 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. */ /* Device properties. */
drivers/net/mlx5/mlx5_ethdev.c +1 -1
@@ -392,7 +392,7 @@ mlx5_dev_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *info) max =RTE_MIN (max, (unsigned int )UINT16_MAX ); info->max_rx_queues = max; info->max_tx_queues = max; - info->max_mac_addrs =MLX5_MAX_UC_MAC_ADDRESSES ; + info->max_mac_addrs = priv->sh->dev_cap.max_uc_mac_addrs; info->rx_queue_offload_capa =mlx5_get_rx_queue_offloads (dev); info->rx_seg_capa.max_nseg =MLX5_MAX_RXQ_NSEG ; info->rx_seg_capa.multi_pools = !priv->config.mprq.enabled;
drivers/net/mlx5/mlx5_flow_hw.c +35 -18
88 lines not on this page · raw message
drivers/net/mlx5/mlx5_mac.c +12 -8
@@ -36,7 +36,7 @@ mlx5_internal_mac_addr_remove(struct rte_eth_dev *dev,uint32_t index, struct rte_ether_addr *addr) { - MLX5_ASSERT(index < MLX5_MAX_MAC_ADDRESSES); + MLX5_ASSERT(index < MLX5_SH(dev)->dev_cap.max_mac_addrs);if (rte_is_zero_ether_addr (&dev->data->mac_addrs[index]))return false;mlx5_os_mac_addr_remove (dev, index);
@@ -63,16 +63,17 @@ static int mlx5_internal_mac_addr_add(struct rte_eth_dev *dev, struct rte_ether_addr *mac, uint32_t index) { + struct mlx5_priv *priv = dev->data->dev_private;unsigned int i;int ret; -MLX5_ASSERT (index <MLX5_MAX_MAC_ADDRESSES ); +MLX5_ASSERT (index < priv->sh->dev_cap.max_mac_addrs);if (rte_is_zero_ether_addr (mac)) { rte_errno =EINVAL ;return -rte_errno; }/* First, make sure this address isn't already configured. */ -for (i =0 ; (i !=MLX5_MAX_MAC_ADDRESSES ); ++i) { +for (i =0 ; i != priv->sh->dev_cap.max_mac_addrs; ++i) {/* Skip this index, it's going to be reconfigured. */ if (i == index)continue ;
@@ -101,10 +102,11 @@ mlx5_internal_mac_addr_add(struct rte_eth_dev *dev, struct rte_ether_addr *mac,void mlx5_mac_addr_remove (struct rte_eth_dev *dev,uint32_t index) { +struct mlx5_priv *priv = dev->data->dev_private;struct rte_ether_addr addr = {0 };int ret; -if (index >=MLX5_MAX_UC_MAC_ADDRESSES ) +if (index >= priv->sh->dev_cap.max_uc_mac_addrs)return ;if (mlx5_internal_mac_addr_remove (dev, index, &addr)) { ret =mlx5_traffic_mac_remove (dev, &addr);
@@ -133,9 +135,10 @@ int mlx5_mac_addr_add(struct rte_eth_dev *dev, struct rte_ether_addr *mac, uint32_t index, uint32_t vmdq __rte_unused) { + struct mlx5_priv *priv = dev->data->dev_private;int ret; -if (index >=MLX5_MAX_UC_MAC_ADDRESSES ) { +if (index >= priv->sh->dev_cap.max_uc_mac_addrs) { rte_errno =EINVAL ;return -rte_errno; }
@@ -217,16 +220,17 @@ int mlx5_set_mc_addr_list(struct rte_eth_dev *dev, struct rte_ether_addr *mc_addr_set, uint32_t nb_mc_addr) { + struct mlx5_priv *priv = dev->data->dev_private;uint32_t i;int ret; -if (nb_mc_addr >=MLX5_MAX_MC_MAC_ADDRESSES ) { +if (nb_mc_addr >= priv->sh->dev_cap.max_mc_mac_addrs) { rte_errno =ENOSPC ;return -rte_errno; } -for (i =MLX5_MAX_UC_MAC_ADDRESSES ; i !=MLX5_MAX_MAC_ADDRESSES ; ++i) +for (i = priv->sh->dev_cap.max_uc_mac_addrs; i != priv->sh->dev_cap.max_mac_addrs; ++i)mlx5_internal_mac_addr_remove (dev, i,NULL ); - i =MLX5_MAX_UC_MAC_ADDRESSES ; + i = priv->sh->dev_cap.max_uc_mac_addrs;while (nb_mc_addr--) { ret =mlx5_internal_mac_addr_add (dev, mc_addr_set++, i++);if (ret)
drivers/net/mlx5/mlx5_trigger.c +5 -5
@@ -1916,7 +1916,7 @@ mlx5_traffic_enable(struct rte_eth_dev *dev) } }/* Add MAC address flows. */ -for (i =0 ; i !=MLX5_MAX_MAC_ADDRESSES ; ++i) { +for (i =0 ; i != priv->sh->dev_cap.max_mac_addrs; ++i) {struct rte_ether_addr *mac = &dev->data->mac_addrs[i];/* Add flows for unicast and multicast mac addresses added by API. */
@@ -2186,7 +2186,7 @@ mlx5_traffic_vlan_add(struct rte_eth_dev *dev, const uint16_t vid)return 0 ;/* Add all unicast DMAC flow rules with new VLAN attached. */ -for (i =0 ; i !=MLX5_MAX_MAC_ADDRESSES ; ++i) { +for (i =0 ; i != priv->sh->dev_cap.max_mac_addrs; ++i) {struct rte_ether_addr *mac = &dev->data->mac_addrs[i];if (rte_is_zero_ether_addr (mac))
@@ -2203,7 +2203,7 @@ mlx5_traffic_vlan_add(struct rte_eth_dev *dev, const uint16_t vid)* Removing after creating VLAN rules so that traffic "gap" is not introduced. */ -for (i =0 ; i !=MLX5_MAX_MAC_ADDRESSES ; ++i) { +for (i =0 ; i != priv->sh->dev_cap.max_mac_addrs; ++i) {struct rte_ether_addr *mac = &dev->data->mac_addrs[i];if (rte_is_zero_ether_addr (mac))
@@ -2241,7 +2241,7 @@ mlx5_traffic_vlan_remove(struct rte_eth_dev *dev, const uint16_t vid)* Recreating first to ensure no traffic "gap". */ -for (i =0 ; i !=MLX5_MAX_MAC_ADDRESSES ; ++i) { +for (i =0 ; i != priv->sh->dev_cap.max_mac_addrs; ++i) {struct rte_ether_addr *mac = &dev->data->mac_addrs[i];if (rte_is_zero_ether_addr (mac))
@@ -2254,7 +2254,7 @@ mlx5_traffic_vlan_remove(struct rte_eth_dev *dev, const uint16_t vid) }/* Remove all unicast DMAC flow rules with this VLAN. */ -for (i =0 ; i !=MLX5_MAX_MAC_ADDRESSES ; ++i) { +for (i =0 ; i != priv->sh->dev_cap.max_mac_addrs; ++i) {struct rte_ether_addr *mac = &dev->data->mac_addrs[i];if (rte_is_zero_ether_addr (mac))
drivers/net/mlx5/windows/mlx5_os.c +33 -8
69 lines not on this page · raw message
Signature · 1 line
2.54.0
RE: [PATCH v9 5/5] net/mlx5: accept more unicast MAC addresses
Quoted 18 lines
-----Original Message-----
From: David Marchand <[email protected]>
Sent: Thursday, September 24, 2026 8:39 AM
To: [email protected]
Cc: [email protected]; [email protected]; Dariusz Sosnowski <[email protected]>; Slava Ovsiienko <[email protected]>; Bing Zhao <[email protected]>; Ori Kam <[email protected]>; Suanming Mou <[email protected]>; Matan Azrad <[email protected]>
Subject: [PATCH v9 5/5] net/mlx5: accept more unicast MAC addressesStarting firmware version 22.49.1014, the number of mac addresses per VF is not capped to 128 anymore.
The value can be increased via devlink:
$ devlink dev param set pci/0000:3b:00.2 name max_macs value 4096 \ cmode driverinit $ devlink dev reload pci/0000:3b:00.2
Quoted 7 lines
On the DPDK side, we must retrieve the maximum number of unicast and multicast addresses supported with a query to the firmware.
Then, dynamically allocate the mac addresses arrays and report the limit instead of the previous hardcoded value.
Signed-off-by David Marchand <[email protected]>
Re: [PATCH v9 5/5] net/mlx5: accept more unicast MAC addresses
In reply to David MarchandI'll squash the following fixup into this patch during merge, to handle non-DevX devices (where mlx5_os_capabilities_prepare() would otherwise return before max_uc_mac_addrs/max_mc_mac_addrs/max_mac_addrs get set, leaving them at 0):
drivers/net/mlx5/linux/mlx5_os.c +10 -10
@@ -325,6 +325,16 @@ mlx5_os_capabilities_prepare(struct mlx5_dev_ctx_shared *sh)DRV_LOG (WARNING ,"Tunnel offloading disabled due to old OFED/rdma-core version" );#endif +if (hca_attr->log_max_current_uc_list >0 ) + sh->dev_cap.max_uc_mac_addrs =RTE_BIT32 (hca_attr->log_max_current_uc_list); +else + sh->dev_cap.max_uc_mac_addrs =MLX5_MAX_UC_MAC_ADDRESSES ; +if (hca_attr->log_max_current_mc_list >0 ) + sh->dev_cap.max_mc_mac_addrs =RTE_BIT32 (hca_attr->log_max_current_mc_list); +else + sh->dev_cap.max_mc_mac_addrs =MLX5_MAX_MC_MAC_ADDRESSES ; + sh->dev_cap.max_mac_addrs = + sh->dev_cap.max_uc_mac_addrs + sh->dev_cap.max_mc_mac_addrs;if (!sh->cdev->config.devx)return 0 ;/* Check capabilities for Packet Pacing. */
@@ -389,16 +399,6 @@ mlx5_os_capabilities_prepare(struct mlx5_dev_ctx_shared *sh) sh->dev_cap.esw_info.regc_mask =0 ;#endif sh->dev_cap.esw_info.is_set =1 ; -if (hca_attr->log_max_current_uc_list >0 ) - sh->dev_cap.max_uc_mac_addrs =RTE_BIT32 (hca_attr->log_max_current_uc_list); -else - sh->dev_cap.max_uc_mac_addrs =MLX5_MAX_UC_MAC_ADDRESSES ; -if (hca_attr->log_max_current_mc_list >0 ) - sh->dev_cap.max_mc_mac_addrs =RTE_BIT32 (hca_attr->log_max_current_mc_list); -else - sh->dev_cap.max_mc_mac_addrs =MLX5_MAX_MC_MAC_ADDRESSES ; - sh->dev_cap.max_mac_addrs = - sh->dev_cap.max_uc_mac_addrs + sh->dev_cap.max_mc_mac_addrs;return 0 ; }
Thanks,
Raslan
Re: [PATCH v9 5/5] net/mlx5: accept more unicast MAC addresses
Quoted 35 lines · Raslan Darawsheh
Acked-by Raslan Darawsheh <[email protected]>I'll squash the following fixup into this patch during merge, to handle non-DevX devices (where
mlx5_os_capabilities_prepare()would otherwise return before max_uc_mac_addrs/max_mc_mac_addrs/max_mac_addrs get set, leaving them at 0):drivers/net/mlx5/linux/mlx5_os.c +10
-2@@ -325,6 +325,16 @@ mlx5_os_capabilities_prepare(struct mlx5_dev_ctx_shared *sh)DRV_LOG (WARNING ,"Tunnel offloading disabled due to old OFED/rdma-core version" );#endif +if (hca_attr->log_max_current_uc_list >0 ) + sh->dev_cap.max_uc_mac_addrs =RTE_BIT32 (hca_attr->log_max_current_uc_list); +else + sh->dev_cap.max_uc_mac_addrs =MLX5_MAX_UC_MAC_ADDRESSES ; +if (hca_attr->log_max_current_mc_list >0 ) + sh->dev_cap.max_mc_mac_addrs =RTE_BIT32 (hca_attr->log_max_current_mc_list); +else + sh->dev_cap.max_mc_mac_addrs =MLX5_MAX_MC_MAC_ADDRESSES ; + sh->dev_cap.max_mac_addrs = + sh->dev_cap.max_uc_mac_addrs + sh->dev_cap.max_mc_mac_addrs;if (!sh->cdev->config.devx)return 0 ;/* Check capabilities for Packet Pacing. */ @@ -389,16 +399,6 @@ mlx5_os_capabilities_prepare(struct mlx5_dev_ctx_shared *sh) sh->dev_cap.esw_info.regc_mask =0 ;#endif sh->dev_cap.esw_info.is_set =1 ; -if (hca_attr->log_max_current_uc_list >0 ) - sh->dev_cap.max_uc_mac_addrs =RTE_BIT32 (hca_attr->log_max_current_uc_list);
drivers/net/mlx5/linux/mlx5_os.c mlx5_os_capabilities_prepare(struct mlx5_dev_ctx_shared *sh) · line 403
Quoted 10 lines
drivers/net/mlx5/linux/mlx5_os.c +0
-8-else - sh->dev_cap.max_uc_mac_addrs =MLX5_MAX_UC_MAC_ADDRESSES ; -if (hca_attr->log_max_current_mc_list >0 ) - sh->dev_cap.max_mc_mac_addrs =RTE_BIT32 (hca_attr->log_max_current_mc_list); -else - sh->dev_cap.max_mc_mac_addrs =MLX5_MAX_MC_MAC_ADDRESSES ; - sh->dev_cap.max_mac_addrs = - sh->dev_cap.max_uc_mac_addrs + sh->dev_cap.max_mc_mac_addrs;return 0 ; }
This lgtm.
Thank you.
Signature · 1 line
David Marchand
Re: [PATCH v9 1/5] net/mlx5: remove MAC addresses flush helper on Linux
In reply to David Marchand