Skip to contentSkip to conversation

net/mlx5: connection tracking changes

PATCH Superseded Dariusz Sosnowski 2 participants 16 messages Feb 21, 2024 – Feb 28, 2024 Network drivers

lore
Share & tools
lore
#0 lore raw

cover net/mlx5: connection tracking changes

Patches 1 and 2 contain fixes for existing implementation of connection tracking flow actions.

Patch 3 adds support for sharing connection tracking flow actions between ports when ports' flow engines are configured with RTE_FLOW_PORT_FLAG_SHARE_INDIRECT flag set.

Patch 4 is based on the previous one and removes the limitation on number of ports when connection tracking flow actions are used with HW Steering flow engine.

Dariusz Sosnowski (3):
net/mlx5: fix conntrack action handle representation net/mlx5: fix connection tracking action validation net/mlx5: remove port from conntrack handle representation

Suanming Mou (1):
net/mlx5: add cross port CT object sharing

 doc/guides/nics/mlx5.rst               |   4 +-
 doc/guides/rel_notes/release_24_03.rst |   3 +
 drivers/net/mlx5/mlx5_flow.h           |  20 ++-
 drivers/net/mlx5/mlx5_flow_dv.c        |   9 ++
 drivers/net/mlx5/mlx5_flow_hw.c        | 182 +++++++++++++------------
 5 files changed, 126 insertions(+), 92 deletions(-)

--
2.25.1

#1 lore raw

PATCH 1/4 net/mlx5: fix conntrack action handle representation

In mlx5 PMD, handles to indirect connection tracking flow actions are encoded in 32-bit unsigned integers as follows:

- Bits 31-29 - indirect action type.
- Bits 28-25 - port on which connection tracking action was created.
- Bits 24-0 - index of connection tracking object.

Macro defining a bit shift for owner part in this representation was incorrectly defined as 22. This patch fixes that, as well as aligns documented limitations.

Fixes 463170a7c934 ("net/mlx5: support connection tracking with HWS")
Fixes 48fbb0e93d06 ("net/mlx5: support flow meter mark indirect action with HWS")
---
 doc/guides/nics/mlx5.rst     | 4 ++--
 drivers/net/mlx5/mlx5_flow.h | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)
doc/guides/nics/mlx5.rst +2 -2
index fa013b03bb..b78753696a 100644
@@ -739,8 +739,8 @@ Limitations
 
   - Cannot co-exist with ASO meter, ASO age action in a single flow rule.
   - Flow rules insertion rate and memory consumption need more optimization.
-  - 256 ports maximum.
-  - 4M connections maximum with ``dv_flow_en`` 1 mode. 16M with ``dv_flow_en`` 2.
+  - 16 ports maximum.
+  - 32M connections maximum.
 
 - Multi-thread flow insertion:
 
drivers/net/mlx5/mlx5_flow.h +1 -1
index a4d0ff7b13..b4bf96cd64 100644
@@ -77,7 +77,7 @@ enum mlx5_indirect_type {
 /* Now, the maximal ports will be supported is 16, action number is 32M. */
 #define MLX5_INDIRECT_ACT_CT_MAX_PORT 0x10
 
-#define MLX5_INDIRECT_ACT_CT_OWNER_SHIFT 22
+#define MLX5_INDIRECT_ACT_CT_OWNER_SHIFT 25
 #define MLX5_INDIRECT_ACT_CT_OWNER_MASK (MLX5_INDIRECT_ACT_CT_MAX_PORT - 1)
 
 /* 29-31: type, 25-28: owner port, 0-24: index */

--
2.25.1

#2 lore raw

PATCH 2/4 net/mlx5: fix connection tracking action validation

In reply to Dariusz Sosnowski

In mlx5 PMD, handles to indirect connection tracking flow actions are encoded as 32-bit unsigned integers, where port ID is stored in bits 28-25. Because of this, connection tracking flow actions cannot be created on ports with IDs higher than 15. This patch adds missing validation.

Fixes 463170a7c934 ("net/mlx5: support connection tracking with HWS")
---
 drivers/net/mlx5/mlx5_flow_dv.c | 9 +++++++++
 drivers/net/mlx5/mlx5_flow_hw.c | 7 +++++++
 2 files changed, 16 insertions(+)
drivers/net/mlx5/mlx5_flow_dv.c +9 -0
index 6fded15d91..0604f92531 100644
@@ -13861,6 +13861,13 @@ flow_dv_translate_create_conntrack(struct rte_eth_dev *dev,
 		return rte_flow_error_set(error, ENOTSUP,
 					  RTE_FLOW_ERROR_TYPE_ACTION, NULL,
 					  "Connection is not supported");
+	if (dev->data->port_id >= MLX5_INDIRECT_ACT_CT_MAX_PORT) {
+		rte_flow_error_set(error, EINVAL,
+				   RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,
+				   "CT supports port indexes up to "
+				   RTE_STR(MLX5_ACTION_CTX_CT_MAX_PORT));
+		return 0;
+	}
 	idx = flow_dv_aso_ct_alloc(dev, error);
 	if (!idx)
 		return rte_flow_error_set(error, rte_errno,
@@ -16558,6 +16565,8 @@ flow_dv_action_create(struct rte_eth_dev *dev,
 	case RTE_FLOW_ACTION_TYPE_CONNTRACK:
 		ret = flow_dv_translate_create_conntrack(dev, action->conf,
 							 err);
+		if (!ret)
+			break;
 		idx = MLX5_INDIRECT_ACT_CT_GEN_IDX(PORT_ID(priv), ret);
 		break;
 	default:
drivers/net/mlx5/mlx5_flow_hw.c +7 -0
index 3bb3a9a178..2f366e9078 100644
@@ -10048,6 +10048,13 @@ flow_hw_conntrack_create(struct rte_eth_dev *dev, uint32_t queue,
 				   "CT is not enabled");
 		return 0;
 	}
+	if (dev->data->port_id >= MLX5_INDIRECT_ACT_CT_MAX_PORT) {
+		rte_flow_error_set(error, EINVAL,
+				   RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,
+				   "CT supports port indexes up to "
+				   RTE_STR(MLX5_ACTION_CTX_CT_MAX_PORT));
+		return 0;
+	}
 	ct = mlx5_ipool_zmalloc(pool->cts, &ct_idx);
 	if (!ct) {
 		rte_flow_error_set(error, rte_errno,

--
2.25.1

#3 lore raw

PATCH 3/4 net/mlx5: add cross port CT object sharing

In reply to Dariusz Sosnowski

From: Suanming Mou <[email protected]>

This commit adds cross port CT object sharing.

Shared CT object shares the same DevX objects, but allocate port's own action locally. Once the CT object is shared between two flows in different ports, the two flows use their own local action with the same offset index.

The shared CT object can only be created/updated/queried/destroyed by host port.

---
 doc/guides/rel_notes/release_24_03.rst |   3 +
 drivers/net/mlx5/mlx5_flow_hw.c        | 145 ++++++++++++++-----------
 2 files changed, 86 insertions(+), 62 deletions(-)
doc/guides/rel_notes/release_24_03.rst +3 -0
index 619459baae..2262f350b5 100644
@@ -133,6 +133,9 @@ New Features
   * Added HW steering support for modify field ``RTE_FLOW_FIELD_ESP_SEQ_NUM`` flow action.
   * Added HW steering support for modify field ``RTE_FLOW_FIELD_ESP_PROTO`` flow action.
 
+  * Added support for sharing indirect action objects of type ``RTE_FLOW_ACTION_TYPE_CONNTRACK``
+    with HW steering flow engine.
+
 
 Removed Items
 -------------
drivers/net/mlx5/mlx5_flow_hw.c +83 -62

231 lines not on this page · raw message

--
2.25.1

#4 lore raw

PATCH 4/4 net/mlx5: remove port from conntrack handle representation

In reply to Dariusz Sosnowski

This patch removes the owner port index from integer representation of indirect action handle in mlx5 PMD for conntrack flow actions.
This index is not needed when HW Steering flow engine is enabled, because either:

- port references its own indirect actions or,
- port references indirect actions of the host port when sharing indirect actions was configured.

In both cases it is explicitly known which port owns the action. Port index, included in action handle, introduced unnecessary limitation and caused undefined behavior issues when application used more than supported number of ports.

This patch removes the port index from indirect conntrack action handle representation when HW steering flow engine is used.
It does not affect SW Steering flow engine.

---
 drivers/net/mlx5/mlx5_flow.h    | 18 +++++++++++---
 drivers/net/mlx5/mlx5_flow_hw.c | 44 +++++++++++----------------------
 2 files changed, 28 insertions(+), 34 deletions(-)
drivers/net/mlx5/mlx5_flow.h +14 -4
index b4bf96cd64..187f440893 100644
@@ -80,7 +80,12 @@ enum mlx5_indirect_type {
 #define MLX5_INDIRECT_ACT_CT_OWNER_SHIFT 25
 #define MLX5_INDIRECT_ACT_CT_OWNER_MASK (MLX5_INDIRECT_ACT_CT_MAX_PORT - 1)
 
-/* 29-31: type, 25-28: owner port, 0-24: index */
+/*
+ * When SW steering flow engine is used, the CT action handles are encoded in a following way:
+ * - bits 31:29 - type
+ * - bits 28:25 - port index of the action owner
+ * - bits 24:0 - action index
+ */
 #define MLX5_INDIRECT_ACT_CT_GEN_IDX(owner, index) \
 	((MLX5_INDIRECT_ACTION_TYPE_CT << MLX5_INDIRECT_ACTION_TYPE_OFFSET) | \
 	 (((owner) & MLX5_INDIRECT_ACT_CT_OWNER_MASK) << \
@@ -93,9 +98,14 @@ enum mlx5_indirect_type {
 #define MLX5_INDIRECT_ACT_CT_GET_IDX(index) \
 	((index) & ((1 << MLX5_INDIRECT_ACT_CT_OWNER_SHIFT) - 1))
 
-#define MLX5_ACTION_CTX_CT_GET_IDX  MLX5_INDIRECT_ACT_CT_GET_IDX
-#define MLX5_ACTION_CTX_CT_GET_OWNER MLX5_INDIRECT_ACT_CT_GET_OWNER
-#define MLX5_ACTION_CTX_CT_GEN_IDX MLX5_INDIRECT_ACT_CT_GEN_IDX
+/*
+ * When HW steering flow engine is used, the CT action handles are encoded in a following way:
+ * - bits 31:29 - type
+ * - bits 28:0 - action index
+ */
+#define MLX5_INDIRECT_ACT_HWS_CT_GEN_IDX(index) \
+	((struct rte_flow_action_handle *)(uintptr_t) \
+	 ((MLX5_INDIRECT_ACTION_TYPE_CT << MLX5_INDIRECT_ACTION_TYPE_OFFSET) | (index)))
 
 enum mlx5_indirect_list_type {
 	MLX5_INDIRECT_ACTION_LIST_TYPE_ERR = 0,
drivers/net/mlx5/mlx5_flow_hw.c +14 -30

152 lines not on this page · raw message

--
2.25.1

#5 lore raw

v2 cover net/mlx5: connection tracking changes

In reply to Dariusz Sosnowski

Patches 1 and 2 contain fixes for existing implementation of connection tracking flow actions.

Patch 3 adds support for sharing connection tracking flow actions between ports when ports' flow engines are configured with RTE_FLOW_PORT_FLAG_SHARE_INDIRECT flag set.

Patch 4 is based on the previous one and removes the limitation on number of ports when connection tracking flow actions are used with HW Steering flow engine.

v2:
- Rebased on top of v24.03-rc1
- Updated mlx5 docs.

Dariusz Sosnowski (3):
net/mlx5: fix conntrack action handle representation net/mlx5: fix connection tracking action validation net/mlx5: remove port from conntrack handle representation

Suanming Mou (1):
net/mlx5: add cross port CT object sharing

 doc/guides/nics/mlx5.rst               |   4 +-
 doc/guides/rel_notes/release_24_03.rst |   2 +
 drivers/net/mlx5/mlx5_flow.h           |  20 ++-
 drivers/net/mlx5/mlx5_flow_dv.c        |   9 ++
 drivers/net/mlx5/mlx5_flow_hw.c        | 182 +++++++++++++------------
 5 files changed, 125 insertions(+), 92 deletions(-)

--
2.34.1

#6 lore raw

PATCH v2 1/4 net/mlx5: fix conntrack action handle representation

In mlx5 PMD, handles to indirect connection tracking flow actions are encoded in 32-bit unsigned integers as follows:

- Bits 31-29 - indirect action type.
- Bits 28-25 - port on which connection tracking action was created.
- Bits 24-0 - index of connection tracking object.

Macro defining a bit shift for owner part in this representation was incorrectly defined as 22. This patch fixes that, as well as aligns documented limitations.

Fixes 463170a7c934 ("net/mlx5: support connection tracking with HWS")
Fixes 48fbb0e93d06 ("net/mlx5: support flow meter mark indirect action with HWS")
---
 doc/guides/nics/mlx5.rst     | 4 ++--
 drivers/net/mlx5/mlx5_flow.h | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)
doc/guides/nics/mlx5.rst +2 -2
index 0d2213497a..90ae3f3047 100644
@@ -783,8 +783,8 @@ Limitations
 
   - Cannot co-exist with ASO meter, ASO age action in a single flow rule.
   - Flow rules insertion rate and memory consumption need more optimization.
-  - 256 ports maximum.
-  - 4M connections maximum with ``dv_flow_en`` 1 mode. 16M with ``dv_flow_en`` 2.
+  - 16 ports maximum.
+  - 32M connections maximum.
 
 - Multi-thread flow insertion:
 
drivers/net/mlx5/mlx5_flow.h +1 -1
index a4d0ff7b13..b4bf96cd64 100644
@@ -77,7 +77,7 @@ enum mlx5_indirect_type {
 /* Now, the maximal ports will be supported is 16, action number is 32M. */
 #define MLX5_INDIRECT_ACT_CT_MAX_PORT 0x10
 
-#define MLX5_INDIRECT_ACT_CT_OWNER_SHIFT 22
+#define MLX5_INDIRECT_ACT_CT_OWNER_SHIFT 25
 #define MLX5_INDIRECT_ACT_CT_OWNER_MASK (MLX5_INDIRECT_ACT_CT_MAX_PORT - 1)
 
 /* 29-31: type, 25-28: owner port, 0-24: index */
Signature · 1 line
2.34.1
#7 lore raw

PATCH v2 2/4 net/mlx5: fix connection tracking action validation

In reply to Dariusz Sosnowski

In mlx5 PMD, handles to indirect connection tracking flow actions are encoded as 32-bit unsigned integers, where port ID is stored in bits 28-25. Because of this, connection tracking flow actions cannot be created on ports with IDs higher than 15. This patch adds missing validation.

Fixes 463170a7c934 ("net/mlx5: support connection tracking with HWS")
---
 drivers/net/mlx5/mlx5_flow_dv.c | 9 +++++++++
 drivers/net/mlx5/mlx5_flow_hw.c | 7 +++++++
 2 files changed, 16 insertions(+)
drivers/net/mlx5/mlx5_flow_dv.c +9 -0
index 23a2388320..c78ef1f616 100644
@@ -13861,6 +13861,13 @@ flow_dv_translate_create_conntrack(struct rte_eth_dev *dev,
 		return rte_flow_error_set(error, ENOTSUP,
 					  RTE_FLOW_ERROR_TYPE_ACTION, NULL,
 					  "Connection is not supported");
+	if (dev->data->port_id >= MLX5_INDIRECT_ACT_CT_MAX_PORT) {
+		rte_flow_error_set(error, EINVAL,
+				   RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,
+				   "CT supports port indexes up to "
+				   RTE_STR(MLX5_ACTION_CTX_CT_MAX_PORT));
+		return 0;
+	}
 	idx = flow_dv_aso_ct_alloc(dev, error);
 	if (!idx)
 		return rte_flow_error_set(error, rte_errno,
@@ -16558,6 +16565,8 @@ flow_dv_action_create(struct rte_eth_dev *dev,
 	case RTE_FLOW_ACTION_TYPE_CONNTRACK:
 		ret = flow_dv_translate_create_conntrack(dev, action->conf,
 							 err);
+		if (!ret)
+			break;
 		idx = MLX5_INDIRECT_ACT_CT_GEN_IDX(PORT_ID(priv), ret);
 		break;
 	default:
drivers/net/mlx5/mlx5_flow_hw.c +7 -0
index bcf43f5457..366a6956d2 100644
@@ -10048,6 +10048,13 @@ flow_hw_conntrack_create(struct rte_eth_dev *dev, uint32_t queue,
 				   "CT is not enabled");
 		return 0;
 	}
+	if (dev->data->port_id >= MLX5_INDIRECT_ACT_CT_MAX_PORT) {
+		rte_flow_error_set(error, EINVAL,
+				   RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,
+				   "CT supports port indexes up to "
+				   RTE_STR(MLX5_ACTION_CTX_CT_MAX_PORT));
+		return 0;
+	}
 	ct = mlx5_ipool_zmalloc(pool->cts, &ct_idx);
 	if (!ct) {
 		rte_flow_error_set(error, rte_errno,
Signature · 1 line
2.34.1
#8 lore raw

PATCH v2 3/4 net/mlx5: add cross port CT object sharing

In reply to Dariusz Sosnowski

From: Suanming Mou <[email protected]>

This commit adds cross port CT object sharing.

Shared CT object shares the same DevX objects, but allocate port's own action locally. Once the CT object is shared between two flows in different ports, the two flows use their own local action with the same offset index.

The shared CT object can only be created/updated/queried/destroyed by host port.

---
 doc/guides/rel_notes/release_24_03.rst |   2 +
 drivers/net/mlx5/mlx5_flow_hw.c        | 145 ++++++++++++++-----------
 2 files changed, 85 insertions(+), 62 deletions(-)
doc/guides/rel_notes/release_24_03.rst +2 -0
index 879bb4944c..b660c2c7cf 100644
@@ -130,6 +130,8 @@ New Features
   * Added support for matching a random value.
   * Added support for comparing result between packet fields or value.
   * Added support for accumulating value of field into another one.
+  * Added support for sharing indirect action objects of type ``RTE_FLOW_ACTION_TYPE_CONNTRACK``
+    with HW steering flow engine.
 
 * **Updated Marvell cnxk crypto driver.**
 
drivers/net/mlx5/mlx5_flow_hw.c +83 -62

231 lines not on this page · raw message

Signature · 1 line
2.34.1
#9 lore raw

PATCH v2 4/4 net/mlx5: remove port from conntrack handle representation

In reply to Dariusz Sosnowski

This patch removes the owner port index from integer representation of indirect action handle in mlx5 PMD for conntrack flow actions.
This index is not needed when HW Steering flow engine is enabled, because either:

- port references its own indirect actions or,
- port references indirect actions of the host port when sharing indirect actions was configured.

In both cases it is explicitly known which port owns the action. Port index, included in action handle, introduced unnecessary limitation and caused undefined behavior issues when application used more than supported number of ports.

This patch removes the port index from indirect conntrack action handle representation when HW steering flow engine is used.
It does not affect SW Steering flow engine.

---
 doc/guides/nics/mlx5.rst        |  2 +-
 drivers/net/mlx5/mlx5_flow.h    | 18 +++++++++++---
 drivers/net/mlx5/mlx5_flow_hw.c | 44 +++++++++++----------------------
 3 files changed, 29 insertions(+), 35 deletions(-)
doc/guides/nics/mlx5.rst +1 -1
index 90ae3f3047..7729fe4151 100644
@@ -783,7 +783,7 @@ Limitations
 
   - Cannot co-exist with ASO meter, ASO age action in a single flow rule.
   - Flow rules insertion rate and memory consumption need more optimization.
-  - 16 ports maximum.
+  - 16 ports maximum (with ``dv_flow_en=1``).
   - 32M connections maximum.
 
 - Multi-thread flow insertion:
drivers/net/mlx5/mlx5_flow.h +14 -4
index b4bf96cd64..187f440893 100644
@@ -80,7 +80,12 @@ enum mlx5_indirect_type {
 #define MLX5_INDIRECT_ACT_CT_OWNER_SHIFT 25
 #define MLX5_INDIRECT_ACT_CT_OWNER_MASK (MLX5_INDIRECT_ACT_CT_MAX_PORT - 1)
 
-/* 29-31: type, 25-28: owner port, 0-24: index */
+/*
+ * When SW steering flow engine is used, the CT action handles are encoded in a following way:
+ * - bits 31:29 - type
+ * - bits 28:25 - port index of the action owner
+ * - bits 24:0 - action index
+ */
 #define MLX5_INDIRECT_ACT_CT_GEN_IDX(owner, index) \
 	((MLX5_INDIRECT_ACTION_TYPE_CT << MLX5_INDIRECT_ACTION_TYPE_OFFSET) | \
 	 (((owner) & MLX5_INDIRECT_ACT_CT_OWNER_MASK) << \
@@ -93,9 +98,14 @@ enum mlx5_indirect_type {
 #define MLX5_INDIRECT_ACT_CT_GET_IDX(index) \
 	((index) & ((1 << MLX5_INDIRECT_ACT_CT_OWNER_SHIFT) - 1))
 
-#define MLX5_ACTION_CTX_CT_GET_IDX  MLX5_INDIRECT_ACT_CT_GET_IDX
-#define MLX5_ACTION_CTX_CT_GET_OWNER MLX5_INDIRECT_ACT_CT_GET_OWNER
-#define MLX5_ACTION_CTX_CT_GEN_IDX MLX5_INDIRECT_ACT_CT_GEN_IDX
+/*
+ * When HW steering flow engine is used, the CT action handles are encoded in a following way:
+ * - bits 31:29 - type
+ * - bits 28:0 - action index
+ */
+#define MLX5_INDIRECT_ACT_HWS_CT_GEN_IDX(index) \
+	((struct rte_flow_action_handle *)(uintptr_t) \
+	 ((MLX5_INDIRECT_ACTION_TYPE_CT << MLX5_INDIRECT_ACTION_TYPE_OFFSET) | (index)))
 
 enum mlx5_indirect_list_type {
 	MLX5_INDIRECT_ACTION_LIST_TYPE_ERR = 0,
drivers/net/mlx5/mlx5_flow_hw.c +14 -30

152 lines not on this page · raw message

Signature · 1 line
2.34.1
#10 lore raw

v3 cover net/mlx5: connection tracking changes

In reply to Dariusz Sosnowski

Patches 1 and 2 contain fixes for existing implementation of connection tracking flow actions.

Patch 3 adds support for sharing connection tracking flow actions between ports when ports' flow engines are configured with RTE_FLOW_PORT_FLAG_SHARE_INDIRECT flag set.

Patch 4 is based on the previous one and removes the limitation on number of ports when connection tracking flow actions are used with HW Steering flow engine.

Depends-on: series-31246 ("net/mlx5: move meter init functions")

v3:
- Rebased.
- Added Depends-on tag.

v2:
- Rebased on top of v24.03-rc1
- Updated mlx5 docs.

Dariusz Sosnowski (3):
net/mlx5: fix conntrack action handle representation net/mlx5: fix connection tracking action validation net/mlx5: remove port from conntrack handle representation

Suanming Mou (1):
net/mlx5: add cross port CT object sharing

 doc/guides/nics/mlx5.rst               |   4 +-
 doc/guides/rel_notes/release_24_03.rst |   2 +
 drivers/net/mlx5/mlx5_flow.h           |  20 ++-
 drivers/net/mlx5/mlx5_flow_dv.c        |   9 ++
 drivers/net/mlx5/mlx5_flow_hw.c        | 180 +++++++++++++------------
 5 files changed, 123 insertions(+), 92 deletions(-)

--
2.25.1

#11 lore raw

PATCH v3 1/4 net/mlx5: fix conntrack action handle representation

In mlx5 PMD, handles to indirect connection tracking flow actions are encoded in 32-bit unsigned integers as follows:

- Bits 31-29 - indirect action type.
- Bits 28-25 - port on which connection tracking action was created.
- Bits 24-0 - index of connection tracking object.

Macro defining a bit shift for owner part in this representation was incorrectly defined as 22. This patch fixes that, as well as aligns documented limitations.

Fixes 463170a7c934 ("net/mlx5: support connection tracking with HWS")
Fixes 48fbb0e93d06 ("net/mlx5: support flow meter mark indirect action with HWS")
---
 doc/guides/nics/mlx5.rst     | 4 ++--
 drivers/net/mlx5/mlx5_flow.h | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)
doc/guides/nics/mlx5.rst +2 -2
index 0079176ba3..db47d70b70 100644
@@ -815,8 +815,8 @@ Limitations
 
   - Cannot co-exist with ASO meter, ASO age action in a single flow rule.
   - Flow rules insertion rate and memory consumption need more optimization.
-  - 256 ports maximum.
-  - 4M connections maximum with ``dv_flow_en`` 1 mode. 16M with ``dv_flow_en`` 2.
+  - 16 ports maximum.
+  - 32M connections maximum.
 
 - Multi-thread flow insertion:
 
drivers/net/mlx5/mlx5_flow.h +1 -1
index a4d0ff7b13..b4bf96cd64 100644
@@ -77,7 +77,7 @@ enum mlx5_indirect_type {
 /* Now, the maximal ports will be supported is 16, action number is 32M. */
 #define MLX5_INDIRECT_ACT_CT_MAX_PORT 0x10
 
-#define MLX5_INDIRECT_ACT_CT_OWNER_SHIFT 22
+#define MLX5_INDIRECT_ACT_CT_OWNER_SHIFT 25
 #define MLX5_INDIRECT_ACT_CT_OWNER_MASK (MLX5_INDIRECT_ACT_CT_MAX_PORT - 1)
 
 /* 29-31: type, 25-28: owner port, 0-24: index */
Signature · 1 line
2.25.1
#12 lore raw

PATCH v3 2/4 net/mlx5: fix connection tracking action validation

In reply to Dariusz Sosnowski

In mlx5 PMD, handles to indirect connection tracking flow actions are encoded as 32-bit unsigned integers, where port ID is stored in bits 28-25. Because of this, connection tracking flow actions cannot be created on ports with IDs higher than 15. This patch adds missing validation.

Fixes 463170a7c934 ("net/mlx5: support connection tracking with HWS")
---
 drivers/net/mlx5/mlx5_flow_dv.c | 9 +++++++++
 drivers/net/mlx5/mlx5_flow_hw.c | 7 +++++++
 2 files changed, 16 insertions(+)
drivers/net/mlx5/mlx5_flow_dv.c +9 -0
index 75a8a223ab..ddf19e9a51 100644
@@ -13889,6 +13889,13 @@ flow_dv_translate_create_conntrack(struct rte_eth_dev *dev,
 		return rte_flow_error_set(error, ENOTSUP,
 					  RTE_FLOW_ERROR_TYPE_ACTION, NULL,
 					  "Connection is not supported");
+	if (dev->data->port_id >= MLX5_INDIRECT_ACT_CT_MAX_PORT) {
+		rte_flow_error_set(error, EINVAL,
+				   RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,
+				   "CT supports port indexes up to "
+				   RTE_STR(MLX5_ACTION_CTX_CT_MAX_PORT));
+		return 0;
+	}
 	idx = flow_dv_aso_ct_alloc(dev, error);
 	if (!idx)
 		return rte_flow_error_set(error, rte_errno,
@@ -16586,6 +16593,8 @@ flow_dv_action_create(struct rte_eth_dev *dev,
 	case RTE_FLOW_ACTION_TYPE_CONNTRACK:
 		ret = flow_dv_translate_create_conntrack(dev, action->conf,
 							 err);
+		if (!ret)
+			break;
 		idx = MLX5_INDIRECT_ACT_CT_GEN_IDX(PORT_ID(priv), ret);
 		break;
 	default:
drivers/net/mlx5/mlx5_flow_hw.c +7 -0
index 2a1281732a..a8e2c9cc9e 100644
@@ -10344,6 +10344,13 @@ flow_hw_conntrack_create(struct rte_eth_dev *dev, uint32_t queue,
 				   "CT is not enabled");
 		return 0;
 	}
+	if (dev->data->port_id >= MLX5_INDIRECT_ACT_CT_MAX_PORT) {
+		rte_flow_error_set(error, EINVAL,
+				   RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,
+				   "CT supports port indexes up to "
+				   RTE_STR(MLX5_ACTION_CTX_CT_MAX_PORT));
+		return 0;
+	}
 	ct = mlx5_ipool_zmalloc(pool->cts, &ct_idx);
 	if (!ct) {
 		rte_flow_error_set(error, rte_errno,
Signature · 1 line
2.25.1
#13 lore raw

PATCH v3 3/4 net/mlx5: add cross port CT object sharing

In reply to Dariusz Sosnowski

From: Suanming Mou <[email protected]>

This commit adds cross port CT object sharing.

Shared CT object shares the same DevX objects, but allocate port's own action locally. Once the CT object is shared between two flows in different ports, the two flows use their own local action with the same offset index.

The shared CT object can only be created/updated/queried/destroyed by host port.

---
 doc/guides/rel_notes/release_24_03.rst |   2 +
 drivers/net/mlx5/mlx5_flow_hw.c        | 143 ++++++++++++++-----------
 2 files changed, 83 insertions(+), 62 deletions(-)
doc/guides/rel_notes/release_24_03.rst +2 -0
index 76d2e60f59..23ac6568ac 100644
@@ -135,6 +135,8 @@ New Features
   * Added support for copy inner fields in HWS flow engine.
   * Added support for sharing indirect action objects of type ``RTE_FLOW_ACTION_TYPE_METER_MARK``
     in HWS flow engine.
+  * Added support for sharing indirect action objects of type ``RTE_FLOW_ACTION_TYPE_CONNTRACK``
+    with HW steering flow engine.
 
 * **Updated Marvell cnxk crypto driver.**
 
drivers/net/mlx5/mlx5_flow_hw.c +81 -62

230 lines not on this page · raw message

Signature · 1 line
2.25.1
#14 lore raw

PATCH v3 4/4 net/mlx5: remove port from conntrack handle representation

In reply to Dariusz Sosnowski

This patch removes the owner port index from integer representation of indirect action handle in mlx5 PMD for conntrack flow actions.
This index is not needed when HW Steering flow engine is enabled, because either:

- port references its own indirect actions or,
- port references indirect actions of the host port when sharing indirect actions was configured.

In both cases it is explicitly known which port owns the action. Port index, included in action handle, introduced unnecessary limitation and caused undefined behavior issues when application used more than supported number of ports.

This patch removes the port index from indirect conntrack action handle representation when HW steering flow engine is used.
It does not affect SW Steering flow engine.

---
 doc/guides/nics/mlx5.rst        |  2 +-
 drivers/net/mlx5/mlx5_flow.h    | 18 +++++++++++---
 drivers/net/mlx5/mlx5_flow_hw.c | 44 +++++++++++----------------------
 3 files changed, 29 insertions(+), 35 deletions(-)
doc/guides/nics/mlx5.rst +1 -1
index db47d70b70..329b98f68f 100644
@@ -815,7 +815,7 @@ Limitations
 
   - Cannot co-exist with ASO meter, ASO age action in a single flow rule.
   - Flow rules insertion rate and memory consumption need more optimization.
-  - 16 ports maximum.
+  - 16 ports maximum (with ``dv_flow_en=1``).
   - 32M connections maximum.
 
 - Multi-thread flow insertion:
drivers/net/mlx5/mlx5_flow.h +14 -4
index b4bf96cd64..187f440893 100644
@@ -80,7 +80,12 @@ enum mlx5_indirect_type {
 #define MLX5_INDIRECT_ACT_CT_OWNER_SHIFT 25
 #define MLX5_INDIRECT_ACT_CT_OWNER_MASK (MLX5_INDIRECT_ACT_CT_MAX_PORT - 1)
 
-/* 29-31: type, 25-28: owner port, 0-24: index */
+/*
+ * When SW steering flow engine is used, the CT action handles are encoded in a following way:
+ * - bits 31:29 - type
+ * - bits 28:25 - port index of the action owner
+ * - bits 24:0 - action index
+ */
 #define MLX5_INDIRECT_ACT_CT_GEN_IDX(owner, index) \
 	((MLX5_INDIRECT_ACTION_TYPE_CT << MLX5_INDIRECT_ACTION_TYPE_OFFSET) | \
 	 (((owner) & MLX5_INDIRECT_ACT_CT_OWNER_MASK) << \
@@ -93,9 +98,14 @@ enum mlx5_indirect_type {
 #define MLX5_INDIRECT_ACT_CT_GET_IDX(index) \
 	((index) & ((1 << MLX5_INDIRECT_ACT_CT_OWNER_SHIFT) - 1))
 
-#define MLX5_ACTION_CTX_CT_GET_IDX  MLX5_INDIRECT_ACT_CT_GET_IDX
-#define MLX5_ACTION_CTX_CT_GET_OWNER MLX5_INDIRECT_ACT_CT_GET_OWNER
-#define MLX5_ACTION_CTX_CT_GEN_IDX MLX5_INDIRECT_ACT_CT_GEN_IDX
+/*
+ * When HW steering flow engine is used, the CT action handles are encoded in a following way:
+ * - bits 31:29 - type
+ * - bits 28:0 - action index
+ */
+#define MLX5_INDIRECT_ACT_HWS_CT_GEN_IDX(index) \
+	((struct rte_flow_action_handle *)(uintptr_t) \
+	 ((MLX5_INDIRECT_ACTION_TYPE_CT << MLX5_INDIRECT_ACTION_TYPE_OFFSET) | (index)))
 
 enum mlx5_indirect_list_type {
 	MLX5_INDIRECT_ACTION_LIST_TYPE_ERR = 0,
drivers/net/mlx5/mlx5_flow_hw.c +14 -30

152 lines not on this page · raw message

Signature · 1 line
2.25.1
#15 lore raw
In reply to Dariusz Sosnowski

Hi,

Quoted 45 lines

-----Original Message-----
From: Dariusz Sosnowski <[email protected]>
Sent: Tuesday, February 27, 2024 3:52 PM
To: Slava Ovsiienko <[email protected]>; Ori Kam <[email protected]>; Suanming Mou <[email protected]>; Matan Azrad <[email protected]>
Cc: [email protected]
Subject: [PATCH v3 0/4] net/mlx5: connection tracking changes

Patches 1 and 2 contain fixes for existing implementation of connection tracking flow actions.

Patch 3 adds support for sharing connection tracking flow actions between ports when ports' flow engines are configured with RTE_FLOW_PORT_FLAG_SHARE_INDIRECT flag set.

Patch 4 is based on the previous one and removes the limitation on number of ports when connection tracking flow actions are used with HW Steering flow engine.

Depends-on: series-31246 ("net/mlx5: move meter init functions")

v3:
- Rebased.
- Added Depends-on tag.

v2:
- Rebased on top of v24.03-rc1
- Updated mlx5 docs.

Dariusz Sosnowski (3):
net/mlx5: fix conntrack action handle representation net/mlx5: fix connection tracking action validation net/mlx5: remove port from conntrack handle representation

Suanming Mou (1):
net/mlx5: add cross port CT object sharing

 doc/guides/nics/mlx5.rst               |   4 +-
 doc/guides/rel_notes/release_24_03.rst |   2 +
 drivers/net/mlx5/mlx5_flow.h           |  20 ++-
 drivers/net/mlx5/mlx5_flow_dv.c        |   9 ++
 drivers/net/mlx5/mlx5_flow_hw.c        | 180 +++++++++++++------------
 5 files changed, 123 insertions(+), 92 deletions(-)
Quoted 2 lines

--
2.25.1

Series applied to next-net-mlx,
Kindest regards,
Raslan Darawsheh