Skip to contentSkip to conversation

net/mlx5: future HW devargs defaults and fixes

PATCH In review Maayan Kashani 5 participants 14 messages Jan 12 – Feb 12 Network drivers

lore
Share & tools
lore
#0 lore raw

cover net/mlx5: future HW devargs defaults and fixes

This patch series contains bug fixes for the mlx5 PMD, primarily addressing issues with Hardware Steering (HWS) and flow devarg handling.

Summary of changes:

1. drivers: fix flow devarg handling for future HW Addresses SWS (Software Steering) deprecation on future hardware generations (e.g., ConnectX-9). Updates default behavior for dv_flow_en and allow_duplicate_pattern devargs based on device capabilities, with proper error handling and user feedback.

2. net/mlx5: fix default memzone requirements in HWS
Fixes memzone exhaustion when probing setups with ~1K SFs. The default HWS sync flow API configuration was allocating unnecessary rings (flow_transfer_pending/completed) that are only used with async flow API. This patch removes the unnecessary allocations to stay within memzone limits.

3. net/mlx5: fix internal HWS pattern template creation Improves PMD initialization time by separating pattern templates into internal and external categories. Internal templates (created by PMD) skip expensive validations, while application-provided templates remain fully validated.

4. net/mlx5: fix redundant control rules in promiscuous mode Removes redundant DMAC and multicast/broadcast control flow rules when promiscuous mode is enabled, as the device already receives all traffic in this mode.

All patches are targeted for stable backport.

Dariusz Sosnowski (1):
net/mlx5: fix default memzone requirements in HWS

Maayan Kashani (3):
drivers: fix flow devarg handling for future HW net/mlx5: fix internal HWS pattern template creation net/mlx5: fix redundant control rules in promiscuous mode

 doc/guides/nics/mlx5.rst             |  11 ++-
 drivers/common/mlx5/mlx5_devx_cmds.c |  18 ++++
 drivers/common/mlx5/mlx5_devx_cmds.h |   6 ++
 drivers/common/mlx5/mlx5_prm.h       |  14 +++-
 drivers/net/mlx5/mlx5.c              |  71 +++++++++++++++-
 drivers/net/mlx5/mlx5_flow_hw.c      | 121 ++++++++++++++++++++-------
 drivers/net/mlx5/mlx5_trigger.c      |  16 ++--
 7 files changed, 214 insertions(+), 43 deletions(-)
Signature · 1 line
2.21.0
#1 lore raw

PATCH 1/4 drivers: fix flow devarg handling for future HW

SWS (software steering) will be disabled on future hardware generations. This fix should check for SWS capability bits and return relevant error. Update the defaults for the dv_flow_en and allow_duplicate_pattern devargs accordingly.

- Default dv_flow_en devarg value will be chosen based on whether NIC supports SW steering and/or HW steering.
- If DV flow is not supported and allow_duplicate_pattern is set by the user, forcibly disable it and emit a clear log message.

This change improves reliability by ensuring only valid configurations are applied, and provides clear feedback to the user when fallbacks are triggered.

Fixes 1b55eeb7b76f ("common/mlx5: add ConnectX-9 SuperNIC")
---
 doc/guides/nics/mlx5.rst             | 11 +++--
 drivers/common/mlx5/mlx5_devx_cmds.c | 18 +++++++
 drivers/common/mlx5/mlx5_devx_cmds.h |  6 +++
 drivers/common/mlx5/mlx5_prm.h       | 14 ++++--
 drivers/net/mlx5/mlx5.c              | 71 +++++++++++++++++++++++++++-
 5 files changed, 111 insertions(+), 9 deletions(-)
doc/guides/nics/mlx5.rst +8 -3
index 904a0ac3584..0b123461a30 100644
@@ -698,8 +698,11 @@ for an additional list of options shared with other mlx5 drivers.
   Value 2 enables the WQE based hardware steering.
   In this mode, only queue-based flow management is supported.
 
-  It is configured by default to 1 (DV flow steering) if supported.
-  Otherwise, the value is 0 which indicates legacy Verbs flow offloading.
+  By default, the PMD will set this value according to capability.
+  If DV flow steering is supported, it will be set to 1.
+  If DV flow steering is not supported and HW steering is supported,
+  then it will be set to 2.
+  Otherwise, it will be set to 0.
 
 - ``dv_esw_en`` parameter [int]
 
@@ -834,8 +837,10 @@ for an additional list of options shared with other mlx5 drivers.
   - 1. Allow insertion of rules with the same pattern items.
     In this case, all rules are inserted but only the first rule takes effect,
     the next rule takes effect only if the previous rules are deleted.
+    This option is not supported in :ref:`HWS mode <mlx5_hws>`.
+    If this option is set to 1 in HWS mode, it will be set to 0.
 
-  By default, the PMD will set this value to 1.
+  By default, the PMD will set this value according to capability.
 
 
 .. _mlx5_net_stats:
drivers/common/mlx5/mlx5_devx_cmds.c +18 -0
index d885a95c04e..d12ebf8487d 100644
@@ -1304,6 +1304,18 @@ mlx5_devx_cmd_query_hca_attr(void *ctx,
 		rx_reg |= ((0xff & reg_c_8_15) << 8);
 		attr->set_reg_c &= (rx_reg & tx_reg);
 
+		attr->rx_sw_owner_v2 = MLX5_GET(flow_table_nic_cap, hcattr,
+						flow_table_properties_nic_receive.sw_owner_v2);
+		if (!attr->rx_sw_owner_v2)
+			attr->rx_sw_owner = MLX5_GET(flow_table_nic_cap, hcattr,
+						flow_table_properties_nic_receive.sw_owner);
+
+		attr->tx_sw_owner_v2 = MLX5_GET(flow_table_nic_cap, hcattr,
+						flow_table_properties_nic_transmit.sw_owner_v2);
+		if (!attr->tx_sw_owner_v2)
+			attr->tx_sw_owner = MLX5_GET(flow_table_nic_cap, hcattr,
+						flow_table_properties_nic_transmit.sw_owner);
+
 #undef GET_RX_REG_X_BITS
 #undef GET_TX_REG_X_BITS
 	}
@@ -1456,6 +1468,12 @@ mlx5_devx_cmd_query_hca_attr(void *ctx,
 		reg_c_8_15 = MLX5_GET(flow_table_esw_cap, hcattr,
 				      ft_field_support_2_esw_fdb.metadata_reg_c_8_15);
 		attr->set_reg_c &= ((0xff & reg_c_8_15) << 8) | esw_reg;
+
+		attr->esw_sw_owner_v2 = MLX5_GET(flow_table_esw_cap, hcattr,
+						 flow_table_properties_nic_esw_fdb.sw_owner_v2);
+		if (!attr->esw_sw_owner_v2)
+			attr->esw_sw_owner = MLX5_GET(flow_table_esw_cap, hcattr,
+						 flow_table_properties_nic_esw_fdb.sw_owner);
 	}
 	return 0;
 error:
drivers/common/mlx5/mlx5_devx_cmds.h +6 -0
index f6e8afbf395..da50fc686cd 100644
@@ -337,6 +337,12 @@ struct mlx5_hca_attr {
 	uint8_t max_header_modify_pattern_length;
 	uint64_t system_image_guid;
 	uint32_t log_max_conn_track_offload:5;
+	uint8_t rx_sw_owner:1;
+	uint8_t rx_sw_owner_v2:1;
+	uint8_t tx_sw_owner:1;
+	uint8_t tx_sw_owner_v2:1;
+	uint8_t esw_sw_owner:1;
+	uint8_t esw_sw_owner_v2:1;
 };
 
 /* LAG Context. */
drivers/common/mlx5/mlx5_prm.h +10 -4
index 411c35f456e..ba33336e588 100644
@@ -1597,9 +1597,13 @@ enum {
 #define MLX5_HCA_FLEX_GTPU_DW_0_ENABLED (1UL << 18)
 #define MLX5_HCA_FLEX_GTPU_TEID_ENABLED (1UL << 19)
 
-/* The device steering logic format. */
-#define MLX5_STEERING_LOGIC_FORMAT_CONNECTX_5 0x0
-#define MLX5_STEERING_LOGIC_FORMAT_CONNECTX_6DX 0x1
+/* The device steering logic format version. */
+enum {
+	MLX5_STEERING_LOGIC_FORMAT_CONNECTX_5 = 0,
+	MLX5_STEERING_LOGIC_FORMAT_CONNECTX_6DX = 1,
+	MLX5_STEERING_LOGIC_FORMAT_CONNECTX_7 = 2,
+	MLX5_STEERING_LOGIC_FORMAT_CONNECTX_8 = 3,
+};
 
 struct mlx5_ifc_cmd_hca_cap_bits {
 	u8 access_other_hca_roce[0x1];
@@ -2348,7 +2352,9 @@ struct mlx5_ifc_flow_table_nic_cap_bits {
 };
 
 struct mlx5_ifc_flow_table_esw_cap_bits {
-	u8 reserved_at_0[0x800];
+	u8 reserved_at_0[0x200];
+	struct mlx5_ifc_flow_table_prop_layout_bits flow_table_properties_nic_esw_fdb;
+	u8 reserved_at_400[0x400];
 	struct mlx5_ifc_ft_fields_support_bits ft_header_modify_esw_fdb;
 	u8 reserved_at_C00[0x800];
 	struct mlx5_ifc_ft_fields_support_2_bits
drivers/net/mlx5/mlx5.c +69 -2

96 lines not on this page · raw message

Signature · 1 line
2.21.0
Acked-by on v1 1/4
#2 lore raw

Re: [PATCH 1/4] drivers: fix flow devarg handling for future HW

Quoted 10 lines · Maayan Kashani

SWS (software steering) will be disabled on future hardware generations. This fix should check for SWS capability bits and return relevant error. Update the defaults for the dv_flow_en and allow_duplicate_pattern devargs accordingly.

- Default dv_flow_en devarg value will be chosen based on whether NIC supports SW steering and/or HW steering.
- If DV flow is not supported and allow_duplicate_pattern is set by the user, forcibly disable it and emit a clear log message.

Quoted 8 lines

This change improves reliability by ensuring only valid configurations are applied, and provides clear feedback to the user when fallbacks are triggered.

Fixes 1b55eeb7b76f ("common/mlx5: add ConnectX-9 SuperNIC")

Best regards,
Dariusz Sosnowski

#3 lore raw

Re: [PATCH 1/4] drivers: fix flow devarg handling for future HW

In reply to Maayan Kashani
Quoted 14 lines · On Mon, 12 Jan 2026 11:24:35 +0200 Maayan Kashani <[email protected]> wrote:

SWS (software steering) will be disabled on future hardware generations. This fix should check for SWS capability bits and return relevant error. Update the defaults for the dv_flow_en and allow_duplicate_pattern devargs accordingly.

- Default dv_flow_en devarg value will be chosen based on whether NIC supports SW steering and/or HW steering.
- If DV flow is not supported and allow_duplicate_pattern is set by the user, forcibly disable it and emit a clear log message.

This change improves reliability by ensuring only valid configurations are applied, and provides clear feedback to the user when fallbacks are triggered.

Quoted 5 lines
Fixes 1b55eeb7b76f ("common/mlx5: add ConnectX-9 SuperNIC")

---

Experimental AI review was generally happy with this patch.

The only thing it squawked about was:

## Revised Patch Review: [PATCH 1/4] drivers: fix flow devarg handling for future HW

### Commit Message Review

| Check | Status | Notes |
|-------|--------|-------|
| Subject ≤60 chars | ✅ Pass | 47 characters |
| Imperative mood | ✅ Pass | "fix" is imperative |
| No trailing period | ✅ Pass | |
| Lowercase after colon | ✅ Pass | |
| Body line wrap ≤75 chars | ✅ Pass | |
| Body doesn't start with "It" | ✅ Pass | |
| Signed-off-by present | ✅ Pass | |
| Fixes tag format | ✅ Pass | 12-char SHA with quoted subject |
| Cc: [email protected] | ✅ Pass | |
| Tag order | ✅ Pass | |

#### ⚠️ Warning: Subject Prefix
drivers: is generic. Since this primarily affects net/mlx5 with supporting changes in common/mlx5, consider:
- **Suggested**: net/mlx5: fix flow devarg handling for future HW

---

### Code Style Review

| Check | Status |
|-------|--------|
| Line length ≤100 chars | ✅ Pass |
| Explicit NULL comparisons | ✅ Pass |
| Comment formatting | ✅ Pass |
| Function naming | ✅ Pass |
| Documentation updated atomically | ✅ Pass |

#### ⚠️ Warning: Implicit Boolean Tests on Integer Bitfields

In mlx5_sws_is_any_supported():

```c
if (hca_attr->rx_sw_owner_v2 || hca_attr->rx_sw_owner)
    return true;
```

These are uint8_t bitfields, not bool. Per AGENTS.md guidelines, prefer explicit comparisons:

```c
if (hca_attr->rx_sw_owner_v2 != 0 || hca_attr->rx_sw_owner != 0)
```

Same pattern appears for tx_sw_owner* and esw_sw_owner* checks.

---

### Summary

| Severity | Issue | Location |
|----------|-------|----------|
| **Warning** | Subject prefix `drivers:` could be more specific | Commit message |
| **Warning** | Implicit boolean tests on integer bitfields | `mlx5.c` |

---

### Recommendation

**Acceptable for merge** — No blocking errors. The warnings are minor style preferences. The patch is well-structured with proper documentation updates and correct tag formatting.

#4 lore raw

PATCH 2/4 net/mlx5: fix default memzone requirements in HWS

In reply to Maayan Kashani

From: Dariusz Sosnowski <[email protected]>

Commit [1] has changed the default behavior of flow engine selection in mlx5 PMD to accommodate for new NIC generations. Whenever underlying device does not support SWS (e.g., ConnectX-9 or untrusted VFs/SFs) and device does support HWS, default flow engine would be HWS (dv_flow_en=2) which also supports sync flow API.

This behavior change had consequence in memory usage whenever SFs are probed by DPDK. In default HWS configuration supporting sync flow API (i.e. without calling rte_flow_configure()) mlx5 PMD allocated 4 rte_ring objects per port:

- indir_iq and indir_cq - For handling indirect action completions.
- flow_transfer_pending and flow_transfer_completed - For handling template table resizing.

This has not happened previously with SWS as default flow engine.

Since a dedicated memzone is allocated for each rte_ring object, this lead to exhaustion of default memzone limit
on setups with ~1K SFs to probe.
It resulted in the following error on port start:

EAL: memzone_reserve_aligned_thread_unsafe():
Number of requested memzone segments exceeds maximum 2560
RING: Cannot reserve memory
mlx5_net: Failed to start port 998 mlx5_core.sf.998:
fail to configure port

Since template table resizing is allowed if and only if async flow API was configured, 2 of the aforementioned rings are never used in the default sync flow API configuration.

This patch removes allocation of flow_transfer_pending and flow_transfer_completed rings in default sync flow API configuration of mlx5 PMD to reduce memzone usage and allow DPDK probing to succeed on setups with ~1K SFs to probe.

[1] commit d1ac7b6c64d9
("net/mlx5: update flow devargs handling for future HW")

Fixes 27d171b88031 ("net/mlx5: abstract flow action and enable reconfigure")
---
 drivers/net/mlx5/mlx5_flow_hw.c | 86 ++++++++++++++++++++++++++-------
 1 file changed, 68 insertions(+), 18 deletions(-)
drivers/net/mlx5/mlx5_flow_hw.c +68 -18
index 98483abc7fc..1dada2e7cef 100644
@@ -4483,6 +4483,9 @@ mlx5_hw_pull_flow_transfer_comp(struct rte_eth_dev *dev,
 	struct mlx5_priv *priv = dev->data->dev_private;
 	struct rte_ring *ring = priv->hw_q[queue].flow_transfer_completed;
 
+	if (ring == NULL)
+		return 0;
+
 	size = RTE_MIN(rte_ring_count(ring), n_res);
 	for (i = 0; i < size; i++) {
 		res[i].status = RTE_FLOW_OP_SUCCESS;
@@ -4714,8 +4717,9 @@ __flow_hw_push_action(struct rte_eth_dev *dev,
 	struct mlx5_hw_q *hw_q = &priv->hw_q[queue];
 
 	mlx5_hw_push_queue(hw_q->indir_iq, hw_q->indir_cq);
-	mlx5_hw_push_queue(hw_q->flow_transfer_pending,
-			   hw_q->flow_transfer_completed);
+	if (hw_q->flow_transfer_pending != NULL && hw_q->flow_transfer_completed != NULL)
+		mlx5_hw_push_queue(hw_q->flow_transfer_pending,
+				   hw_q->flow_transfer_completed);
 	if (!priv->shared_host) {
 		if (priv->hws_ctpool)
 			mlx5_aso_push_wqe(priv->sh,
@@ -11889,6 +11893,60 @@ mlx5_hwq_ring_create(uint16_t port_id, uint32_t queue, uint32_t size, const char
 			       RING_F_SP_ENQ | RING_F_SC_DEQ | RING_F_EXACT_SZ);
 }
 
+static int
+flow_hw_queue_setup_rings(struct rte_eth_dev *dev,
+			  uint16_t queue,
+			  uint32_t queue_size,
+			  bool nt_mode)
+{
+	struct mlx5_priv *priv = dev->data->dev_private;
+
+	/* HWS queue info container must be already allocated. */
+	MLX5_ASSERT(priv->hw_q != NULL);
+
+	/* Notice ring name length is limited. */
+	priv->hw_q[queue].indir_cq = mlx5_hwq_ring_create
+		(dev->data->port_id, queue, queue_size, "indir_act_cq");
+	if (!priv->hw_q[queue].indir_cq) {
+		DRV_LOG(ERR, "port %u failed to allocate indir_act_cq ring for HWS",
+			dev->data->port_id);
+		return -ENOMEM;
+	}
+
+	priv->hw_q[queue].indir_iq = mlx5_hwq_ring_create
+		(dev->data->port_id, queue, queue_size, "indir_act_iq");
+	if (!priv->hw_q[queue].indir_iq) {
+		DRV_LOG(ERR, "port %u failed to allocate indir_act_iq ring for HWS",
+			dev->data->port_id);
+		return -ENOMEM;
+	}
+
+	/*
+	 * Sync flow API does not require rings used for table resize handling,
+	 * because these rings are only used through async flow APIs.
+	 */
+	if (nt_mode)
+		return 0;
+
+	priv->hw_q[queue].flow_transfer_pending = mlx5_hwq_ring_create
+		(dev->data->port_id, queue, queue_size, "tx_pending");
+	if (!priv->hw_q[queue].flow_transfer_pending) {
+		DRV_LOG(ERR, "port %u failed to allocate tx_pending ring for HWS",
+			dev->data->port_id);
+		return -ENOMEM;
+	}
+
+	priv->hw_q[queue].flow_transfer_completed = mlx5_hwq_ring_create
+		(dev->data->port_id, queue, queue_size, "tx_done");
+	if (!priv->hw_q[queue].flow_transfer_completed) {
+		DRV_LOG(ERR, "port %u failed to allocate tx_done ring for HWS",
+			dev->data->port_id);
+		return -ENOMEM;
+	}
+
+	return 0;
+}
+
 static int
 flow_hw_validate_attributes(const struct rte_flow_port_attr *port_attr,
 			    uint16_t nb_queue,
@@ -12057,22 +12115,8 @@ __flow_hw_configure(struct rte_eth_dev *dev,
 		      &priv->hw_q[i].job[_queue_attr[i]->size];
 		for (j = 0; j < _queue_attr[i]->size; j++)
 			priv->hw_q[i].job[j] = &job[j];
-		/* Notice ring name length is limited. */
-		priv->hw_q[i].indir_cq = mlx5_hwq_ring_create
-			(dev->data->port_id, i, _queue_attr[i]->size, "indir_act_cq");
-		if (!priv->hw_q[i].indir_cq)
-			goto err;
-		priv->hw_q[i].indir_iq = mlx5_hwq_ring_create
-			(dev->data->port_id, i, _queue_attr[i]->size, "indir_act_iq");
-		if (!priv->hw_q[i].indir_iq)
-			goto err;
-		priv->hw_q[i].flow_transfer_pending = mlx5_hwq_ring_create
-			(dev->data->port_id, i, _queue_attr[i]->size, "tx_pending");
-		if (!priv->hw_q[i].flow_transfer_pending)
-			goto err;
-		priv->hw_q[i].flow_transfer_completed = mlx5_hwq_ring_create
-			(dev->data->port_id, i, _queue_attr[i]->size, "tx_done");
-		if (!priv->hw_q[i].flow_transfer_completed)
+
+		if (flow_hw_queue_setup_rings(dev, i, _queue_attr[i]->size, nt_mode) < 0)
 			goto err;
 	}
 	dr_ctx_attr.pd = priv->sh->cdev->pd;
@@ -15440,6 +15484,12 @@ flow_hw_update_resized(struct rte_eth_dev *dev, uint32_t queue,
 	};
 
 	MLX5_ASSERT(hw_flow->flags & MLX5_FLOW_HW_FLOW_FLAG_MATCHER_SELECTOR);
+	/*
+	 * Update resized can be called only through async flow API.
+	 * These rings are allocated if and only if async flow API was configured.
+	 */
+	MLX5_ASSERT(priv->hw_q[queue].flow_transfer_completed != NULL);
+	MLX5_ASSERT(priv->hw_q[queue].flow_transfer_pending != NULL);
 	/**
 	 * mlx5dr_matcher_resize_rule_move() accepts original table matcher -
 	 * the one that was used BEFORE table resize.
Signature · 1 line
2.21.0
Acked-by on v1 2/4
#5 lore raw

RE: [PATCH 2/4] net/mlx5: fix default memzone requirements in HWS

Hi,

The code LGTM.
I am thinking that if the user wants to use HWS for up-to 1K SFs, we will still reach such limitations or if the application try to create some rings per device. Maybe in the log we can tell the user try to use some API to re-configure the maximal memzones as a hint. WDYT?

Quoted 205 lines

-----Original Message-----
From: Maayan Kashani <[email protected]>
Sent: Monday, January 12, 2026 5:25 PM
To: [email protected]
Cc: Maayan Kashani <[email protected]>; Raslan Darawsheh <[email protected]>; Dariusz Sosnowski <[email protected]>; [email protected]; Slava Ovsiienko <[email protected]>; Bing Zhao <[email protected]>; Ori Kam <[email protected]>; Suanming Mou <[email protected]>; Matan Azrad <[email protected]>
Subject: [PATCH 2/4] net/mlx5: fix default memzone requirements in HWS

From: Dariusz Sosnowski <[email protected]>

Commit [1] has changed the default behavior of flow engine selection in mlx5 PMD to accommodate for new NIC generations.
Whenever underlying device does not support SWS (e.g., ConnectX-9 or untrusted VFs/SFs) and device does support HWS, default flow engine would be HWS (dv_flow_en=2) which also supports sync flow API.

This behavior change had consequence in memory usage whenever SFs are probed by DPDK. In default HWS configuration supporting sync flow API (i.e. without calling rte_flow_configure())
mlx5 PMD allocated 4 rte_ring objects per port:

- indir_iq and indir_cq - For handling indirect action completions.
- flow_transfer_pending and flow_transfer_completed - For handling template table resizing.

This has not happened previously with SWS as default flow engine.

Since a dedicated memzone is allocated for each rte_ring object, this lead to exhaustion of default memzone limit on setups with ~1K SFs to probe. It resulted in the following error on port start:

EAL: memzone_reserve_aligned_thread_unsafe():
Number of requested memzone segments exceeds maximum 2560
RING: Cannot reserve memory
mlx5_net: Failed to start port 998 mlx5_core.sf.998:
fail to configure port

Since template table resizing is allowed if and only if async flow API was configured, 2 of the aforementioned rings are never used in the default sync flow API configuration.

This patch removes allocation of flow_transfer_pending and flow_transfer_completed rings in default sync flow API configuration of mlx5 PMD to reduce memzone usage and allow DPDK probing to succeed on setups with ~1K SFs to probe.

[1] commit d1ac7b6c64d9
("net/mlx5: update flow devargs handling for future HW")

Fixes 27d171b88031 ("net/mlx5: abstract flow action and enable

reconfigure")
Cc: [email protected]

---
 drivers/net/mlx5/mlx5_flow_hw.c | 86 ++++++++++++++++++++++++++-------
 1 file changed, 68 insertions(+), 18 deletions(-)
(quoted diff) +0 -0

b/drivers/net/mlx5/mlx5_flow_hw.c index 98483abc7fc..1dada2e7cef 100644

drivers/net/mlx5/mlx5_flow_hw.c +3 -0
@@ -4483,6 +4483,9 @@ mlx5_hw_pull_flow_transfer_comp(struct rte_eth_dev
 *dev,
 	struct mlx5_priv *priv = dev->data->dev_private;
 	struct rte_ring *ring = priv->hw_q[queue].flow_transfer_completed;
 
+	if (ring == NULL)
+		return 0;
+
 	size = RTE_MIN(rte_ring_count(ring), n_res);
 	for (i = 0; i < size; i++) {
drivers/net/mlx5/mlx5_flow_hw.c +3 -2
 		res[i].status = RTE_FLOW_OP_SUCCESS;
@@ -4714,8 +4717,9 @@ __flow_hw_push_action(struct rte_eth_dev *dev,
 	struct mlx5_hw_q *hw_q = &priv->hw_q[queue];
 
 	mlx5_hw_push_queue(hw_q->indir_iq, hw_q->indir_cq);
-	mlx5_hw_push_queue(hw_q->flow_transfer_pending,
-			   hw_q->flow_transfer_completed);
+	if (hw_q->flow_transfer_pending != NULL && hw_q-
 >flow_transfer_completed != NULL)
+		mlx5_hw_push_queue(hw_q->flow_transfer_pending,
+				   hw_q->flow_transfer_completed);
 	if (!priv->shared_host) {
 		if (priv->hws_ctpool)
drivers/net/mlx5/mlx5_flow_hw.c +0 -0
 			mlx5_aso_push_wqe(priv->sh,
@@ -11889,6 +11893,60 @@ mlx5_hwq_ring_create(uint16_t port_id, uint32_t

queue, uint32_t size, const char
RING_F_SP_ENQ | RING_F_SC_DEQ |
RING_F_EXACT_SZ); }

drivers/net/mlx5/mlx5_flow_hw.c +16 -0
+static int
+flow_hw_queue_setup_rings(struct rte_eth_dev *dev,
+			  uint16_t queue,
+			  uint32_t queue_size,
+			  bool nt_mode)
+{
+	struct mlx5_priv *priv = dev->data->dev_private;
+
+	/* HWS queue info container must be already allocated. */
+	MLX5_ASSERT(priv->hw_q != NULL);
+
+	/* Notice ring name length is limited. */
+	priv->hw_q[queue].indir_cq = mlx5_hwq_ring_create
+		(dev->data->port_id, queue, queue_size, "indir_act_cq");
+	if (!priv->hw_q[queue].indir_cq) {
+		DRV_LOG(ERR, "port %u failed to allocate indir_act_cq ring for

HWS",

drivers/net/mlx5/mlx5_flow_hw.c +8 -0
+			dev->data->port_id);
+		return -ENOMEM;
+	}
+
+	priv->hw_q[queue].indir_iq = mlx5_hwq_ring_create
+		(dev->data->port_id, queue, queue_size, "indir_act_iq");
+	if (!priv->hw_q[queue].indir_iq) {
+		DRV_LOG(ERR, "port %u failed to allocate indir_act_iq ring for

HWS",

drivers/net/mlx5/mlx5_flow_hw.c +6 -0
+			dev->data->port_id);
+		return -ENOMEM;
+	}
+
+	/*
+	 * Sync flow API does not require rings used for table resize

handling,

drivers/net/mlx5/mlx5_flow_hw.c +9 -0
+	 * because these rings are only used through async flow APIs.
+	 */
+	if (nt_mode)
+		return 0;
+
+	priv->hw_q[queue].flow_transfer_pending = mlx5_hwq_ring_create
+		(dev->data->port_id, queue, queue_size, "tx_pending");
+	if (!priv->hw_q[queue].flow_transfer_pending) {
+		DRV_LOG(ERR, "port %u failed to allocate tx_pending ring for

HWS",

drivers/net/mlx5/mlx5_flow_hw.c +8 -0
+			dev->data->port_id);
+		return -ENOMEM;
+	}
+
+	priv->hw_q[queue].flow_transfer_completed = mlx5_hwq_ring_create
+		(dev->data->port_id, queue, queue_size, "tx_done");
+	if (!priv->hw_q[queue].flow_transfer_completed) {
+		DRV_LOG(ERR, "port %u failed to allocate tx_done ring for

HWS",

drivers/net/mlx5/mlx5_flow_hw.c +9 -16
+			dev->data->port_id);
+		return -ENOMEM;
+	}
+
+	return 0;
+}
+
 static int
 flow_hw_validate_attributes(const struct rte_flow_port_attr *port_attr,
 			    uint16_t nb_queue,
@@ -12057,22 +12115,8 @@ __flow_hw_configure(struct rte_eth_dev *dev,
 		      &priv->hw_q[i].job[_queue_attr[i]->size];
 		for (j = 0; j < _queue_attr[i]->size; j++)
 			priv->hw_q[i].job[j] = &job[j];
-		/* Notice ring name length is limited. */
-		priv->hw_q[i].indir_cq = mlx5_hwq_ring_create
-			(dev->data->port_id, i, _queue_attr[i]->size,
 "indir_act_cq");
-		if (!priv->hw_q[i].indir_cq)
-			goto err;
-		priv->hw_q[i].indir_iq = mlx5_hwq_ring_create
-			(dev->data->port_id, i, _queue_attr[i]->size,
 "indir_act_iq");
-		if (!priv->hw_q[i].indir_iq)
-			goto err;
-		priv->hw_q[i].flow_transfer_pending = mlx5_hwq_ring_create
-			(dev->data->port_id, i, _queue_attr[i]->size,
 "tx_pending");
-		if (!priv->hw_q[i].flow_transfer_pending)
-			goto err;
-		priv->hw_q[i].flow_transfer_completed = mlx5_hwq_ring_create
-			(dev->data->port_id, i, _queue_attr[i]->size,
 "tx_done");
-		if (!priv->hw_q[i].flow_transfer_completed)
+
+		if (flow_hw_queue_setup_rings(dev, i, _queue_attr[i]->size,

nt_mode)
+< 0)

drivers/net/mlx5/mlx5_flow_hw.c +3 -0
 			goto err;
 	}
 	dr_ctx_attr.pd = priv->sh->cdev->pd;
@@ -15440,6 +15484,12 @@ flow_hw_update_resized(struct rte_eth_dev *dev,
 uint32_t queue,
 	};
 
 	MLX5_ASSERT(hw_flow->flags &
 MLX5_FLOW_HW_FLOW_FLAG_MATCHER_SELECTOR);
+	/*
+	 * Update resized can be called only through async flow API.
+	 * These rings are allocated if and only if async flow API was

configured.

drivers/net/mlx5/mlx5_flow_hw.c +3 -2
+	 */
+	MLX5_ASSERT(priv->hw_q[queue].flow_transfer_completed != NULL);
+	MLX5_ASSERT(priv->hw_q[queue].flow_transfer_pending != NULL);
 	/**
 	 * mlx5dr_matcher_resize_rule_move() accepts original table matcher
-
 	 * the one that was used BEFORE table resize.
--
Quoted 1 line

2.21.0

#6 lore raw

Re: [PATCH 2/4] net/mlx5: fix default memzone requirements in HWS

Quoted 5 lines · Bing Zhao

Hi,

The code LGTM.
I am thinking that if the user wants to use HWS for up-to 1K SFs, we will still reach such limitations or if the application try to create some rings per device. Maybe in the log we can tell the user try to use some API to re-configure the maximal memzones as a hint. WDYT?

If such a situation occurs, I think the existing error log from EAL sufficiently describes the root cause and possible workaround. I attach the error log below:

EAL: memzone_reserve_aligned_thread_unsafe():
Number of requested memzone segments exceeds maximum 2560
RING: Cannot reserve memory
mlx5_net: Failed to start port 998 mlx5_core.sf.998:
fail to configure port

Quoted 210 lines
Quoted 206 lines

-----Original Message-----
From: Maayan Kashani <[email protected]>
Sent: Monday, January 12, 2026 5:25 PM
To: [email protected]
Cc: Maayan Kashani <[email protected]>; Raslan Darawsheh <[email protected]>; Dariusz Sosnowski <[email protected]>; [email protected]; Slava Ovsiienko <[email protected]>; Bing Zhao <[email protected]>; Ori Kam <[email protected]>; Suanming Mou <[email protected]>; Matan Azrad <[email protected]>
Subject: [PATCH 2/4] net/mlx5: fix default memzone requirements in HWS

From: Dariusz Sosnowski <[email protected]>

Commit [1] has changed the default behavior of flow engine selection in mlx5 PMD to accommodate for new NIC generations.
Whenever underlying device does not support SWS (e.g., ConnectX-9 or untrusted VFs/SFs) and device does support HWS, default flow engine would be HWS (dv_flow_en=2) which also supports sync flow API.

This behavior change had consequence in memory usage whenever SFs are probed by DPDK. In default HWS configuration supporting sync flow API (i.e. without calling rte_flow_configure())
mlx5 PMD allocated 4 rte_ring objects per port:

- indir_iq and indir_cq - For handling indirect action completions.
- flow_transfer_pending and flow_transfer_completed - For handling template table resizing.

This has not happened previously with SWS as default flow engine.

Since a dedicated memzone is allocated for each rte_ring object, this lead to exhaustion of default memzone limit on setups with ~1K SFs to probe. It resulted in the following error on port start:

EAL: memzone_reserve_aligned_thread_unsafe():
Number of requested memzone segments exceeds maximum 2560
RING: Cannot reserve memory
mlx5_net: Failed to start port 998 mlx5_core.sf.998:
fail to configure port

Since template table resizing is allowed if and only if async flow API was configured, 2 of the aforementioned rings are never used in the default sync flow API configuration.

This patch removes allocation of flow_transfer_pending and flow_transfer_completed rings in default sync flow API configuration of mlx5 PMD to reduce memzone usage and allow DPDK probing to succeed on setups with ~1K SFs to probe.

[1] commit d1ac7b6c64d9
("net/mlx5: update flow devargs handling for future HW")

Fixes 27d171b88031 ("net/mlx5: abstract flow action and enable

reconfigure")
Cc: [email protected]

---
 drivers/net/mlx5/mlx5_flow_hw.c | 86 ++++++++++++++++++++++++++-------
 1 file changed, 68 insertions(+), 18 deletions(-)
(quoted diff) +0 -0

b/drivers/net/mlx5/mlx5_flow_hw.c index 98483abc7fc..1dada2e7cef 100644

drivers/net/mlx5/mlx5_flow_hw.c +3 -0
@@ -4483,6 +4483,9 @@ mlx5_hw_pull_flow_transfer_comp(struct rte_eth_dev
 *dev,
 	struct mlx5_priv *priv = dev->data->dev_private;
 	struct rte_ring *ring = priv->hw_q[queue].flow_transfer_completed;
 
+	if (ring == NULL)
+		return 0;
+
 	size = RTE_MIN(rte_ring_count(ring), n_res);
 	for (i = 0; i < size; i++) {
drivers/net/mlx5/mlx5_flow_hw.c +3 -2
 		res[i].status = RTE_FLOW_OP_SUCCESS;
@@ -4714,8 +4717,9 @@ __flow_hw_push_action(struct rte_eth_dev *dev,
 	struct mlx5_hw_q *hw_q = &priv->hw_q[queue];
 
 	mlx5_hw_push_queue(hw_q->indir_iq, hw_q->indir_cq);
-	mlx5_hw_push_queue(hw_q->flow_transfer_pending,
-			   hw_q->flow_transfer_completed);
+	if (hw_q->flow_transfer_pending != NULL && hw_q-
 >flow_transfer_completed != NULL)
+		mlx5_hw_push_queue(hw_q->flow_transfer_pending,
+				   hw_q->flow_transfer_completed);
 	if (!priv->shared_host) {
 		if (priv->hws_ctpool)
drivers/net/mlx5/mlx5_flow_hw.c +0 -0
 			mlx5_aso_push_wqe(priv->sh,
@@ -11889,6 +11893,60 @@ mlx5_hwq_ring_create(uint16_t port_id, uint32_t

queue, uint32_t size, const char
RING_F_SP_ENQ | RING_F_SC_DEQ |
RING_F_EXACT_SZ); }

drivers/net/mlx5/mlx5_flow_hw.c +16 -0
+static int
+flow_hw_queue_setup_rings(struct rte_eth_dev *dev,
+			  uint16_t queue,
+			  uint32_t queue_size,
+			  bool nt_mode)
+{
+	struct mlx5_priv *priv = dev->data->dev_private;
+
+	/* HWS queue info container must be already allocated. */
+	MLX5_ASSERT(priv->hw_q != NULL);
+
+	/* Notice ring name length is limited. */
+	priv->hw_q[queue].indir_cq = mlx5_hwq_ring_create
+		(dev->data->port_id, queue, queue_size, "indir_act_cq");
+	if (!priv->hw_q[queue].indir_cq) {
+		DRV_LOG(ERR, "port %u failed to allocate indir_act_cq ring for

HWS",

drivers/net/mlx5/mlx5_flow_hw.c +8 -0
+			dev->data->port_id);
+		return -ENOMEM;
+	}
+
+	priv->hw_q[queue].indir_iq = mlx5_hwq_ring_create
+		(dev->data->port_id, queue, queue_size, "indir_act_iq");
+	if (!priv->hw_q[queue].indir_iq) {
+		DRV_LOG(ERR, "port %u failed to allocate indir_act_iq ring for

HWS",

drivers/net/mlx5/mlx5_flow_hw.c +6 -0
+			dev->data->port_id);
+		return -ENOMEM;
+	}
+
+	/*
+	 * Sync flow API does not require rings used for table resize

handling,

drivers/net/mlx5/mlx5_flow_hw.c +9 -0
+	 * because these rings are only used through async flow APIs.
+	 */
+	if (nt_mode)
+		return 0;
+
+	priv->hw_q[queue].flow_transfer_pending = mlx5_hwq_ring_create
+		(dev->data->port_id, queue, queue_size, "tx_pending");
+	if (!priv->hw_q[queue].flow_transfer_pending) {
+		DRV_LOG(ERR, "port %u failed to allocate tx_pending ring for

HWS",

drivers/net/mlx5/mlx5_flow_hw.c +8 -0
+			dev->data->port_id);
+		return -ENOMEM;
+	}
+
+	priv->hw_q[queue].flow_transfer_completed = mlx5_hwq_ring_create
+		(dev->data->port_id, queue, queue_size, "tx_done");
+	if (!priv->hw_q[queue].flow_transfer_completed) {
+		DRV_LOG(ERR, "port %u failed to allocate tx_done ring for

HWS",

drivers/net/mlx5/mlx5_flow_hw.c +9 -16
+			dev->data->port_id);
+		return -ENOMEM;
+	}
+
+	return 0;
+}
+
 static int
 flow_hw_validate_attributes(const struct rte_flow_port_attr *port_attr,
 			    uint16_t nb_queue,
@@ -12057,22 +12115,8 @@ __flow_hw_configure(struct rte_eth_dev *dev,
 		      &priv->hw_q[i].job[_queue_attr[i]->size];
 		for (j = 0; j < _queue_attr[i]->size; j++)
 			priv->hw_q[i].job[j] = &job[j];
-		/* Notice ring name length is limited. */
-		priv->hw_q[i].indir_cq = mlx5_hwq_ring_create
-			(dev->data->port_id, i, _queue_attr[i]->size,
 "indir_act_cq");
-		if (!priv->hw_q[i].indir_cq)
-			goto err;
-		priv->hw_q[i].indir_iq = mlx5_hwq_ring_create
-			(dev->data->port_id, i, _queue_attr[i]->size,
 "indir_act_iq");
-		if (!priv->hw_q[i].indir_iq)
-			goto err;
-		priv->hw_q[i].flow_transfer_pending = mlx5_hwq_ring_create
-			(dev->data->port_id, i, _queue_attr[i]->size,
 "tx_pending");
-		if (!priv->hw_q[i].flow_transfer_pending)
-			goto err;
-		priv->hw_q[i].flow_transfer_completed = mlx5_hwq_ring_create
-			(dev->data->port_id, i, _queue_attr[i]->size,
 "tx_done");
-		if (!priv->hw_q[i].flow_transfer_completed)
+
+		if (flow_hw_queue_setup_rings(dev, i, _queue_attr[i]->size,

nt_mode)
+< 0)

drivers/net/mlx5/mlx5_flow_hw.c +3 -0
 			goto err;
 	}
 	dr_ctx_attr.pd = priv->sh->cdev->pd;
@@ -15440,6 +15484,12 @@ flow_hw_update_resized(struct rte_eth_dev *dev,
 uint32_t queue,
 	};
 
 	MLX5_ASSERT(hw_flow->flags &
 MLX5_FLOW_HW_FLOW_FLAG_MATCHER_SELECTOR);
+	/*
+	 * Update resized can be called only through async flow API.
+	 * These rings are allocated if and only if async flow API was

configured.

drivers/net/mlx5/mlx5_flow_hw.c +3 -2
+	 */
+	MLX5_ASSERT(priv->hw_q[queue].flow_transfer_completed != NULL);
+	MLX5_ASSERT(priv->hw_q[queue].flow_transfer_pending != NULL);
 	/**
 	 * mlx5dr_matcher_resize_rule_move() accepts original table matcher
-
 	 * the one that was used BEFORE table resize.
--
Quoted 1 line

2.21.0

#7 lore raw

PATCH 3/4 net/mlx5: fix internal HWS pattern template creation

In reply to Maayan Kashani

HWS pattern template creation tries to build a table with the tested items after basic verifications to check if the pattern is valid.

Time consumed in that table creation can be critical for applications that require fast PMD initialization.

The patch separates pattern templates to internal and external. Internal templates are created by the PMD and are considered safe and can skip some validations.
Pattern templates provided by applications will be fully validated.

Fixes a190f25e6a93 ("net/mlx5: improve pattern template validation")
---
 drivers/net/mlx5/mlx5_flow_hw.c | 35 +++++++++++++++++++++++----------
 1 file changed, 25 insertions(+), 10 deletions(-)
drivers/net/mlx5/mlx5_flow_hw.c +25 -10
index 1dada2e7cef..4af654967ca 100644
@@ -9110,6 +9110,7 @@ static struct rte_flow_pattern_template *
 flow_hw_pattern_template_create(struct rte_eth_dev *dev,
 			     const struct rte_flow_pattern_template_attr *attr,
 			     const struct rte_flow_item items[],
+			     bool external,
 			     struct rte_flow_error *error)
 {
 	struct mlx5_priv *priv = dev->data->dev_private;
@@ -9264,9 +9265,11 @@ flow_hw_pattern_template_create(struct rte_eth_dev *dev,
 		}
 	}
 	rte_atomic_fetch_add_explicit(&it->refcnt, 1, rte_memory_order_relaxed);
-	rc = pattern_template_validate(dev, &it, 1, error);
-	if (rc)
-		goto error;
+	if (external) {
+		rc = pattern_template_validate(dev, &it, 1, error);
+		if (rc)
+			goto error;
+	}
 	LIST_INSERT_HEAD(&priv->flow_hw_itt, it, next);
 	return it;
 error:
@@ -9285,6 +9288,16 @@ flow_hw_pattern_template_create(struct rte_eth_dev *dev,
 	return NULL;
 }
 
+static struct rte_flow_pattern_template *
+flow_hw_external_pattern_template_create
+			(struct rte_eth_dev *dev,
+			 const struct rte_flow_pattern_template_attr *attr,
+			 const struct rte_flow_item items[],
+			 struct rte_flow_error *error)
+{
+	return flow_hw_pattern_template_create(dev, attr, items, true, error);
+}
+
 /**
  * Destroy flow item template.
  *
@@ -9890,7 +9903,7 @@ flow_hw_create_tx_repr_sq_pattern_tmpl(struct rte_eth_dev *dev, struct rte_flow_
 		},
 	};
 
-	return flow_hw_pattern_template_create(dev, &attr, items, error);
+	return flow_hw_pattern_template_create(dev, &attr, items, false, error);
 }
 
 static __rte_always_inline uint32_t
@@ -10182,7 +10195,7 @@ flow_hw_create_ctrl_esw_mgr_pattern_template(struct rte_eth_dev *dev,
 		},
 	};
 
-	return flow_hw_pattern_template_create(dev, &attr, items, error);
+	return flow_hw_pattern_template_create(dev, &attr, items, false, error);
 }
 
 /**
@@ -10236,7 +10249,7 @@ flow_hw_create_ctrl_regc_sq_pattern_template(struct rte_eth_dev *dev,
 		},
 	};
 
-	return flow_hw_pattern_template_create(dev, &attr, items, error);
+	return flow_hw_pattern_template_create(dev, &attr, items, false, error);
 }
 
 /**
@@ -10273,7 +10286,7 @@ flow_hw_create_ctrl_port_pattern_template(struct rte_eth_dev *dev,
 		},
 	};
 
-	return flow_hw_pattern_template_create(dev, &attr, items, error);
+	return flow_hw_pattern_template_create(dev, &attr, items, false, error);
 }
 
 /*
@@ -10309,7 +10322,8 @@ flow_hw_create_lacp_rx_pattern_template(struct rte_eth_dev *dev, struct rte_flow
 			.type = RTE_FLOW_ITEM_TYPE_END,
 		},
 	};
-	return flow_hw_pattern_template_create(dev, &pa_attr, eth_all, error);
+	return flow_hw_pattern_template_create(dev, &pa_attr, eth_all,
+					       false, error);
 }
 
 /**
@@ -11553,7 +11567,7 @@ flow_hw_create_ctrl_rx_pattern_template
 		{ .type = RTE_FLOW_ITEM_TYPE_END }
 	};
 
-	return flow_hw_pattern_template_create(dev, &attr, items, NULL);
+	return flow_hw_pattern_template_create(dev, &attr, items, false, NULL);
 }
 
 int
@@ -15574,6 +15588,7 @@ flow_hw_validate(struct rte_eth_dev *dev, const struct rte_flow_attr *attr,
 	return 0;
 }
 
+
 const struct mlx5_flow_driver_ops mlx5_flow_hw_drv_ops = {
 	.list_create = flow_hw_list_create,
 	.list_destroy = flow_hw_list_destroy,
@@ -15581,7 +15596,7 @@ const struct mlx5_flow_driver_ops mlx5_flow_hw_drv_ops = {
 	.info_get = flow_hw_info_get,
 	.configure = flow_hw_configure,
 	.pattern_validate = flow_hw_pattern_validate,
-	.pattern_template_create = flow_hw_pattern_template_create,
+	.pattern_template_create = flow_hw_external_pattern_template_create,
 	.pattern_template_destroy = flow_hw_pattern_template_destroy,
 	.actions_validate = flow_hw_actions_validate,
 	.actions_template_create = flow_hw_actions_template_create,
Signature · 1 line
2.21.0
Acked-by on v1 3/4
#8 lore raw

Re: [PATCH 3/4] net/mlx5: fix internal HWS pattern template creation

Quoted 12 lines · Maayan Kashani

HWS pattern template creation tries to build a table with the tested items after basic verifications to check if the pattern is valid.

Time consumed in that table creation can be critical for applications that require fast PMD initialization.

The patch separates pattern templates to internal and external. Internal templates are created by the PMD and are considered safe and can skip some validations.
Pattern templates provided by applications will be fully validated.

Quoted 5 lines
Fixes a190f25e6a93 ("net/mlx5: improve pattern template validation")

Best regards,
Dariusz Sosnowski

#9 lore raw

PATCH 4/4 net/mlx5: fix redundant control rules in promiscuous mode

In reply to Maayan Kashani

When promiscuous mode is enabled, the device receives all traffic regardless of destination MAC address. Previously, the code was setting both the promiscuous flag AND the DMAC/multicast control flow rules, which is redundant.

This patch makes the DMAC and multicast/broadcast control flow rules conditional on NOT being in promiscuous mode. When promiscuous mode is enabled, only the MLX5_CTRL_PROMISCUOUS flag is set.

Fixes 9fa7c1cddb85 ("net/mlx5: create control flow rules with HWS")
---
 drivers/net/mlx5/mlx5_trigger.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)
drivers/net/mlx5/mlx5_trigger.c +10 -6
index 028844e45d6..b38ba9022ea 100644
@@ -1682,13 +1682,17 @@ mlx5_traffic_enable_hws(struct rte_eth_dev *dev)
 			dev->data->port_id, -ret);
 		goto error;
 	}
-	if (dev->data->promiscuous)
+	if (dev->data->promiscuous) {
 		flags |= MLX5_CTRL_PROMISCUOUS;
-	if (dev->data->all_multicast)
-		flags |= MLX5_CTRL_ALL_MULTICAST;
-	else
-		flags |= MLX5_CTRL_BROADCAST | MLX5_CTRL_IPV4_MULTICAST | MLX5_CTRL_IPV6_MULTICAST;
-	flags |= MLX5_CTRL_DMAC;
+	} else {
+		if (dev->data->all_multicast)
+			flags |= MLX5_CTRL_ALL_MULTICAST;
+		else
+			flags |= (MLX5_CTRL_BROADCAST |
+				  MLX5_CTRL_IPV4_MULTICAST |
+				  MLX5_CTRL_IPV6_MULTICAST);
+		flags |= MLX5_CTRL_DMAC;
+	}
 	if (priv->vlan_filter_n)
 		flags |= MLX5_CTRL_VLAN_FILTER;
 	return mlx5_flow_hw_ctrl_flows(dev, flags);
Signature · 1 line
2.21.0
Acked-by on v1 4/4
#10 lore raw

Re: [PATCH 4/4] net/mlx5: fix redundant control rules in promiscuous mode

Quoted 5 lines · Maayan Kashani

When promiscuous mode is enabled, the device receives all traffic regardless of destination MAC address. Previously, the code was setting both the promiscuous flag AND the DMAC/multicast control flow rules, which is redundant.

Quoted 8 lines

This patch makes the DMAC and multicast/broadcast control flow rules conditional on NOT being in promiscuous mode. When promiscuous mode is enabled, only the MLX5_CTRL_PROMISCUOUS flag is set.

Fixes 9fa7c1cddb85 ("net/mlx5: create control flow rules with HWS")

Best regards,
Dariusz Sosnowski

#11 lore raw

RE: [PATCH 4/4] net/mlx5: fix redundant control rules in promiscuous mode

In reply to Maayan Kashani

Recheck-request: rebase=next-net-mlx, iol-compile-arm64-testing

Regards,
Maayan Kashani

Quoted 61 lines

-----Original Message-----
From: Maayan Kashani <[email protected]>
Sent: Monday, 12 January 2026 11:25
To: [email protected]
Cc: Maayan Kashani <[email protected]>; Raslan Darawsheh <[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 4/4] net/mlx5: fix redundant control rules in promiscuous mode

When promiscuous mode is enabled, the device receives all traffic regardless of destination MAC address. Previously, the code was setting both the promiscuous flag AND the DMAC/multicast control flow rules, which is redundant.

This patch makes the DMAC and multicast/broadcast control flow rules conditional on NOT being in promiscuous mode. When promiscuous mode is enabled, only the MLX5_CTRL_PROMISCUOUS flag is set.

Fixes 9fa7c1cddb85 ("net/mlx5: create control flow rules with HWS")
---
 drivers/net/mlx5/mlx5_trigger.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)
(quoted diff) +0 -0

b/drivers/net/mlx5/mlx5_trigger.c index 028844e45d6..b38ba9022ea 100644

drivers/net/mlx5/mlx5_trigger.c +10 -6
@@ -1682,13 +1682,17 @@ mlx5_traffic_enable_hws(struct rte_eth_dev
 *dev)
 			dev->data->port_id, -ret);
 		goto error;
 	}
-	if (dev->data->promiscuous)
+	if (dev->data->promiscuous) {
 		flags |= MLX5_CTRL_PROMISCUOUS;
-	if (dev->data->all_multicast)
-		flags |= MLX5_CTRL_ALL_MULTICAST;
-	else
-		flags |= MLX5_CTRL_BROADCAST |
 MLX5_CTRL_IPV4_MULTICAST | MLX5_CTRL_IPV6_MULTICAST;
-	flags |= MLX5_CTRL_DMAC;
+	} else {
+		if (dev->data->all_multicast)
+			flags |= MLX5_CTRL_ALL_MULTICAST;
+		else
+			flags |= (MLX5_CTRL_BROADCAST |
+				  MLX5_CTRL_IPV4_MULTICAST |
+				  MLX5_CTRL_IPV6_MULTICAST);
+		flags |= MLX5_CTRL_DMAC;
+	}
 	if (priv->vlan_filter_n)
drivers/net/mlx5/mlx5_trigger.c +0 -1
 		flags |= MLX5_CTRL_VLAN_FILTER;
 	return mlx5_flow_hw_ctrl_flows(dev, flags);
--

2.21.0

#12 lore raw
In reply to Maayan Kashani
Quoted 39 lines · On Mon, 12 Jan 2026 11:24:34 +0200 Maayan Kashani <[email protected]> wrote:

This patch series contains bug fixes for the mlx5 PMD, primarily addressing issues with Hardware Steering (HWS) and flow devarg handling.

Summary of changes:

1. drivers: fix flow devarg handling for future HW Addresses SWS (Software Steering) deprecation on future hardware generations (e.g., ConnectX-9). Updates default behavior for dv_flow_en and allow_duplicate_pattern devargs based on device capabilities, with proper error handling and user feedback.

2. net/mlx5: fix default memzone requirements in HWS
Fixes memzone exhaustion when probing setups with ~1K SFs. The default HWS sync flow API configuration was allocating unnecessary rings (flow_transfer_pending/completed) that are only used with async flow API. This patch removes the unnecessary allocations to stay within memzone limits.

3. net/mlx5: fix internal HWS pattern template creation Improves PMD initialization time by separating pattern templates into internal and external categories. Internal templates (created by PMD) skip expensive validations, while application-provided templates remain fully validated.

4. net/mlx5: fix redundant control rules in promiscuous mode Removes redundant DMAC and multicast/broadcast control flow rules when promiscuous mode is enabled, as the device already receives all traffic in this mode.

All patches are targeted for stable backport.

Dariusz Sosnowski (1):
net/mlx5: fix default memzone requirements in HWS

Maayan Kashani (3):
drivers: fix flow devarg handling for future HW net/mlx5: fix internal HWS pattern template creation net/mlx5: fix redundant control rules in promiscuous mode

Quoted 9 lines
 doc/guides/nics/mlx5.rst             |  11 ++-
 drivers/common/mlx5/mlx5_devx_cmds.c |  18 ++++
 drivers/common/mlx5/mlx5_devx_cmds.h |   6 ++
 drivers/common/mlx5/mlx5_prm.h       |  14 +++-
 drivers/net/mlx5/mlx5.c              |  71 +++++++++++++++-
 drivers/net/mlx5/mlx5_flow_hw.c      | 121 ++++++++++++++++++++-------
 drivers/net/mlx5/mlx5_trigger.c      |  16 ++--
 7 files changed, 214 insertions(+), 43 deletions(-)

It looks ok to me, AI code review had some useful feedback. Also, it looks like AGENTS.md doesn't really know what is best for declaration placement.

# DPDK Patch Review: mlx5 devargs Series

**Series**: [PATCH 1/4] - [PATCH 4/4] mlx5 devargs and flow handling fixes **Submitter**: Maayan Kashani <[email protected]>
**Date**: Mon, 12 Jan 2026
**Reviewed against**: AGENTS.md criteria

---

## Series Overview

This 4-patch series addresses flow devarg handling for future NVIDIA hardware generations where SWS (Software Steering) is disabled. The patches update defaults, fix memory usage issues, optimize initialization performance, and correct redundant control flow rules.

---

## Patch 1/4: drivers: fix flow devarg handling for future HW

### Commit Message Analysis

| Criterion | Status | Notes |
|-----------|--------|-------|
| Subject ≤60 chars | ✅ PASS | 50 chars: "drivers: fix flow devarg handling for future HW" |
| Lowercase after colon | ✅ PASS | "fix flow devarg..." |
| Imperative mood | ✅ PASS | "fix" |
| No trailing period | ✅ PASS | |
| Component prefix | ⚠️ WARNING | Uses "drivers:" but changes span `common/mlx5` and `net/mlx5`. Consider using `common/mlx5` or splitting. |
| Body wrap ≤75 chars | ✅ PASS | All lines within limit |
| Body doesn't start with "It" | ✅ PASS | Starts with "SWS (software steering)..." |
| Signed-off-by present | ✅ PASS | `Signed-off-by: Maayan Kashani <[email protected]>` |
| Fixes tag format | ✅ PASS | `Fixes: 1b55eeb7b76f ("common/mlx5: add ConnectX-9 SuperNIC")` - 12-char SHA |
| Cc: [email protected] | ✅ PASS | Present |
| Tag order | ✅ PASS | Fixes → Cc → blank → Signed-off-by → Acked-by |

### Code Analysis

**New functions added:**

```c
static bool mlx5_hws_is_supported(struct mlx5_dev_ctx_shared *sh)
static bool mlx5_sws_is_any_supported(struct mlx5_dev_ctx_shared *sh)
static bool mlx5_kvargs_is_used(struct mlx5_kvargs_ctrl *mkvlist, const char *key)
```
| Criterion | Status | Notes |
|-----------|--------|-------|
| Line length ≤100 chars | ⚠️ WARNING | Line 295: `if (hca_attr->eswitch_manager && (hca_attr->esw_sw_owner_v2 || hca_attr->esw_sw_owner))` is ~95 chars - acceptable but borderline |
| Explicit comparisons | ✅ PASS | Uses `== 0`, `== 1`, `== 2`, `!= NULL` appropriately |
| No forbidden tokens | ✅ PASS | |
| Naming conventions | ✅ PASS | Functions use lowercase with underscores |
| Comment style | ✅ PASS | Multi-line comments follow C style |

**Style Issues:**

| Issue | Severity | Location | Description |
|-------|----------|----------|-------------|
| Mixed declaration and code | ⚠️ WARNING | Line 358 | `bool allow_dup_pattern_set = ...` declared mid-block after statements. C90 style prefers declarations at block start. |
| Duplicate logic | ℹ️ INFO | Lines 338-341 vs 360-367 | The `allow_duplicate_pattern` handling appears in two places with slightly different logic. Consider consolidating. |

**Documentation:**

| Criterion | Status | Notes |
|-----------|--------|-------|
| doc/guides updated | ✅ PASS | Updates `doc/guides/nics/mlx5.rst` for `dv_flow_en` and `allow_duplicate_pattern` |
| Docs match code | ✅ PASS | Documentation accurately reflects the new default behavior |

### Patch 1 Verdict: **ACCEPTABLE WITH MINOR ISSUES**

- Consider using net/mlx5: prefix since that's the primary subsystem being modified
- Minor C90 style preference for declarations at block start

---

## Patch 2/4: net/mlx5: fix default memzone requirements in HWS

### Commit Message Analysis

| Criterion | Status | Notes |
|-----------|--------|-------|
| Subject ≤60 chars | ✅ PASS | 51 chars: "net/mlx5: fix default memzone requirements in HWS" |
| Component prefix | ✅ PASS | `net/mlx5:` correct |
| Lowercase after colon | ✅ PASS | |
| Imperative mood | ✅ PASS | "fix" |
| Body wrap ≤75 chars | ✅ PASS | |
| Signed-off-by | ✅ PASS | |
| Fixes tag | ✅ PASS | `Fixes: 27d171b88031 ("net/mlx5: abstract flow action and enable reconfigure")` |
| Cc: stable | ✅ PASS | |
| Tag order | ✅ PASS | |
| References commit | ✅ PASS | Uses `[1] commit d1ac7b6c64d9` notation correctly |

**Author note**: Patch is From: Dariusz Sosnowski but submitted by Maayan Kashani - this is fine for series coordination.

### Code Analysis

**New function:**

```c
static int flow_hw_queue_setup_rings(struct rte_eth_dev *dev,
                                     uint16_t queue,
                                     uint32_t queue_size,
                                     bool nt_mode)
```
| Criterion | Status | Notes |
|-----------|--------|-------|
| Line length ≤100 chars | ✅ PASS | |
| NULL checks | ✅ PASS | Uses `== NULL` and `!= NULL` explicitly |
| Error handling | ✅ PASS | Returns -ENOMEM on allocation failures |
| Assertion usage | ✅ PASS | Uses `MLX5_ASSERT()` appropriately |
| Refactoring | ✅ PASS | Good refactoring - extracts ring creation to separate function |

**Logic review:**

```c
if (ring == NULL)
    return 0;
```

This early return in mlx5_hw_pull_flow_transfer_comp() is safe since rings may not be allocated in sync flow API mode.

```c
if (hw_q->flow_transfer_pending != NULL && hw_q->flow_transfer_completed != NULL)
    mlx5_hw_push_queue(...)
```

Appropriate guard for optional rings.

### Patch 2 Verdict: **GOOD**

Clean, well-structured fix that reduces memzone usage significantly for SF-heavy deployments.

---

## Patch 3/4: net/mlx5: skip internal pattern template validation

### Commit Message Analysis

| Criterion | Status | Notes |
|-----------|--------|-------|
| Subject ≤60 chars | ✅ PASS | 53 chars |
| Component prefix | ✅ PASS | `net/mlx5:` |
| Lowercase | ✅ PASS | |
| Signed-off-by | ✅ PASS | Two authors: Gregory Etelson and Maayan Kashani |
| Fixes tag | ✅ PASS | `Fixes: a190f25e6a93 ("net/mlx5: improve pattern template validation")` |
| Cc: stable | ✅ PASS | |

### Code Analysis

| Criterion | Status | Notes |
|-----------|--------|-------|
| Function signature change | ✅ PASS | Added `bool external` parameter |
| Wrapper function | ✅ PASS | `flow_hw_external_pattern_template_create()` wraps with `true` |
| Internal calls | ✅ PASS | All internal calls use `false` |
| Line length | ✅ PASS | |

**Style issue:**

| Issue | Severity | Location | Description |
|-------|----------|----------|-------------|
| Extra blank line | ⚠️ WARNING | Line 925-926 | Double blank line before `const struct mlx5_flow_driver_ops` |

The optimization approach is sound - internal PMD-created templates are known-safe and don't need expensive validation.

### Patch 3 Verdict: **GOOD**

Minor style nit with extra blank line.

---

## Patch 4/4: net/mlx5: fix redundant control rules in promiscuous mode

### Commit Message Analysis

| Criterion | Status | Notes |
|-----------|--------|-------|
| Subject ≤60 chars | ✅ PASS | 58 chars |
| Component prefix | ✅ PASS | `net/mlx5:` |
| Imperative mood | ✅ PASS | "fix" |
| Body doesn't start with "It" | ⚠️ WARNING | Body starts with "When promiscuous..." but third paragraph starts "This patch makes..." which is discouraged phrasing |
| Signed-off-by | ✅ PASS | |
| Fixes tag | ✅ PASS | `Fixes: 9fa7c1cddb85 ("net/mlx5: create control flow rules with HWS")` |
| Cc: stable | ✅ PASS | |

### Code Analysis

| Criterion | Status | Notes |
|-----------|--------|-------|
| Logic correctness | ✅ PASS | Correctly makes DMAC/multicast rules conditional on non-promiscuous mode |
| Brace style | ✅ PASS | Correct K&R style |
| Flag handling | ✅ PASS | Clean bitwise OR operations |

**Before:**

```c
if (dev->data->promiscuous)
    flags |= MLX5_CTRL_PROMISCUOUS;
if (dev->data->all_multicast)
    flags |= MLX5_CTRL_ALL_MULTICAST;
else
    flags |= MLX5_CTRL_BROADCAST | ...;
flags |= MLX5_CTRL_DMAC;
```

**After:**

```c
if (dev->data->promiscuous) {
    flags |= MLX5_CTRL_PROMISCUOUS;
} else {
    if (dev->data->all_multicast)
        flags |= MLX5_CTRL_ALL_MULTICAST;
    else
        flags |= (MLX5_CTRL_BROADCAST | ...);
    flags |= MLX5_CTRL_DMAC;
}
```

The refactored logic correctly avoids setting redundant DMAC and multicast rules when promiscuous mode already accepts all traffic.

### Patch 4 Verdict: **GOOD**

---

## Series-Level Analysis

### Compilation Independence

Each patch should compile independently. The series has proper ordering:
1. Patch 1 adds capability detection and devarg handling
2. Patch 2 depends on HWS mode changes from patch 1
3. Patch 3 is independent (optimization)
4. Patch 4 is independent (bug fix)

⚠️ **Potential issue**: Patch 2 references d1ac7b6c64d9 which appears to be a different commit than patch 1's 1b55eeb7b76f. The series should be self-contained or clearly document the dependency.

### ABI Considerations

| Change | Impact |
|--------|--------|
| New fields in `mlx5_hca_attr` | Internal structure, no ABI impact |
| New static functions | No ABI impact |
| Function signature change (`flow_hw_pattern_template_create`) | Static function, no ABI impact |

### Documentation Completeness

| Criterion | Status |
|-----------|--------|
| Release notes needed? | ⚠️ CONSIDER | These are bug fixes, but the behavioral changes (default dv_flow_en) may warrant release note mention |
| API documentation | ✅ N/A | No public API changes |

---

## Summary

| Patch | Verdict | Blocking Issues |
|-------|---------|-----------------|
| 1/4 | ✅ Acceptable | Component prefix could be more specific |
| 2/4 | ✅ Good | None |
| 3/4 | ✅ Good | Extra blank line (minor) |
| 4/4 | ✅ Good | None |

### Errors (Must Fix)
None

### Warnings (Should Fix)
1. **Patch 1**: Consider net/mlx5: prefix instead of generic drivers:
2. **Patch 1**: Mixed declaration and code (C90 style)
3. **Patch 3**: Extra blank line at line 925

### Info (Consider)
1. **Patch 1**: Logic for allow_duplicate_pattern appears in two locations
2. **Series**: Consider adding release notes entry for the default behavior change
3. **Patch 2**: Commit reference [1] should ideally use Fixes: format or be clear it's not in this series

---

## Recommendation

**Series is ready for merge** with optional minor cleanups. The fixes address real issues for future hardware support and scalability with large numbers of SFs. Code quality is good and follows DPDK conventions.

#13 lore raw
In reply to Maayan Kashani

Hi,

Quoted 39 lines · Maayan Kashani

This patch series contains bug fixes for the mlx5 PMD, primarily addressing issues with Hardware Steering (HWS) and flow devarg handling.

Summary of changes:

1. drivers: fix flow devarg handling for future HW Addresses SWS (Software Steering) deprecation on future hardware generations (e.g., ConnectX-9). Updates default behavior for dv_flow_en and allow_duplicate_pattern devargs based on device capabilities, with proper error handling and user feedback.

2. net/mlx5: fix default memzone requirements in HWS
Fixes memzone exhaustion when probing setups with ~1K SFs. The default HWS sync flow API configuration was allocating unnecessary rings (flow_transfer_pending/completed) that are only used with async flow API. This patch removes the unnecessary allocations to stay within memzone limits.

3. net/mlx5: fix internal HWS pattern template creation Improves PMD initialization time by separating pattern templates into internal and external categories. Internal templates (created by PMD) skip expensive validations, while application-provided templates remain fully validated.

4. net/mlx5: fix redundant control rules in promiscuous mode Removes redundant DMAC and multicast/broadcast control flow rules when promiscuous mode is enabled, as the device already receives all traffic in this mode.

All patches are targeted for stable backport.

Dariusz Sosnowski (1):
net/mlx5: fix default memzone requirements in HWS

Maayan Kashani (3):
drivers: fix flow devarg handling for future HW net/mlx5: fix internal HWS pattern template creation net/mlx5: fix redundant control rules in promiscuous mode

Quoted 9 lines
  doc/guides/nics/mlx5.rst             |  11 ++-
  drivers/common/mlx5/mlx5_devx_cmds.c |  18 ++++
  drivers/common/mlx5/mlx5_devx_cmds.h |   6 ++
  drivers/common/mlx5/mlx5_prm.h       |  14 +++-
  drivers/net/mlx5/mlx5.c              |  71 +++++++++++++++-
  drivers/net/mlx5/mlx5_flow_hw.c      | 121 ++++++++++++++++++++-------
  drivers/net/mlx5/mlx5_trigger.c      |  16 ++--
  7 files changed, 214 insertions(+), 43 deletions(-)

Series applied to next-net-mlx,

Kindest regards
Raslan Darawsheh