Skip to contentSkip to conversation

support ipv6 routing header matching

RFC Superseded Rongwei Liu 6 participants 67 messages Dec 21, 2022 – Feb 3, 2023 Network drivers

lore
Share & tools
lore
#0 lore raw

cover support ipv6 routing header matching

Support IPv6 routing extension header matching.

Rongwei Liu (9):
ethdev: add IPv6 routing extension header definition app/testpmd: add IPv6 routing extension header support net/mlx5: adopt new flex item definition net/mlx5/hws: Definer, add mlx5dr context to definer_conv_data net/mlx5/hws: add IPv6 routing extension matching support app/testpmd: add IPv6 routing extension header in raw encap
ethdev: add modify IPv6 protocol field
app/testpmd: add modify IPv6 protocol command line net/mlx5/hws: add modify IPv6 protocol implementation

 app/test-pmd/cmdline_flow.c            |  61 ++++++++++-
 doc/guides/nics/features/mlx5.ini      |   1 +
 doc/guides/nics/mlx5.rst               |   1 +
 doc/guides/prog_guide/rte_flow.rst     |   9 ++
 doc/guides/rel_notes/release_22_03.rst |  11 ++
 drivers/common/mlx5/mlx5_devx_cmds.c   |  13 ++-
 drivers/common/mlx5/mlx5_devx_cmds.h   |   7 +-
 drivers/common/mlx5/mlx5_prm.h         |  23 +++-
 drivers/net/mlx5/hws/mlx5dr.h          |  21 ++++
 drivers/net/mlx5/hws/mlx5dr_context.c  |  81 +++++++++++++-
 drivers/net/mlx5/hws/mlx5dr_context.h  |   1 +
 drivers/net/mlx5/hws/mlx5dr_definer.c  | 144 +++++++++++++++++++++----
 drivers/net/mlx5/mlx5.c                |  15 ++-
 drivers/net/mlx5/mlx5.h                |  13 ++-
 drivers/net/mlx5/mlx5_flow.h           |   3 +
 drivers/net/mlx5/mlx5_flow_dv.c        |  10 ++
 drivers/net/mlx5/mlx5_flow_flex.c      |  14 ++-
 drivers/net/mlx5/mlx5_flow_hw.c        |  39 +++++--
 lib/ethdev/rte_flow.c                  |  15 +++
 lib/ethdev/rte_flow.h                  |  40 +++++++
 lib/net/rte_ip.h                       |  21 ++++
 21 files changed, 500 insertions(+), 43 deletions(-)
Signature · 1 line
2.27.0
#1 lore raw

RFC 1/9 ethdev: add IPv6 routing extension header definition

Add IPv6 routing extension header definition and no TLV support for now.
At rte_flow layer, there are new items defined for matching type/nexthdr/segment_left field.

---
 doc/guides/prog_guide/rte_flow.rst     |  9 ++++++
 doc/guides/rel_notes/release_22_03.rst |  5 ++++
 lib/ethdev/rte_flow.c                  | 15 ++++++++++
 lib/ethdev/rte_flow.h                  | 39 ++++++++++++++++++++++++++
 lib/net/rte_ip.h                       | 21 ++++++++++++++
 5 files changed, 89 insertions(+)
doc/guides/prog_guide/rte_flow.rst +9 -0
index 3e6242803d..1ebc159893 100644
@@ -1544,6 +1544,15 @@ Matches Color Marker set by a Meter.
 
 - ``color``: Metering color marker.
 
+Item: ``IPV6_ROUTING_EXT``
+^^^^^^^^^^^^^^^^^^^^^
+
+Matches ipv6 routing extension header.
+
+- ``nexthdr``: Next layer header type.
+- ``type``: IPv6 routing extension header type.
+- ``segments_left``: How many IPv6 destination addresses carries on 
+
 Actions
 ~~~~~~~
 
doc/guides/rel_notes/release_22_03.rst +5 -0
index 0923707cb8..cc050ff3e7 100644
@@ -207,6 +207,11 @@ API Changes
 * ethdev: Old public macros and enumeration constants without ``RTE_ETH_`` prefix,
   which are kept for backward compatibility, are marked as deprecated.
 
+* ethdev: added a new structure:
+
+    - IPv6 routing extension header ``rte_flow_item_ipv6_routing_ext`` and
+      ``rte_ipv6_routing_ext``
+
 * cryptodev: The asymmetric session handling was modified to use a single
   mempool object. An API ``rte_cryptodev_asym_session_pool_create`` was added
   to create a mempool with element size big enough to hold the generic asymmetric
lib/ethdev/rte_flow.c +15 -0
index 7d0c24366c..e08b690300 100644
@@ -76,6 +76,19 @@ rte_flow_item_flex_conv(void *buf, const void *data)
 	return src->length;
 }
 
+static size_t
+rte_flow_item_ipv6_routing_ext_conv(void *buf, const void *data)
+{
+	struct rte_flow_item_ipv6_routing_ext *dst = buf;
+	const struct rte_flow_item_ipv6_routing_ext *src = data;
+
+	if (buf)
+		rte_memcpy((void *)((uintptr_t)(dst->hdr.segments)),
+			   src->hdr.segments,
+			   src->hdr.segments_left << 4);
+	return src->hdr.segments_left << 4;
+}
+
 /** Generate flow_item[] entry. */
 #define MK_FLOW_ITEM(t, s) \
 	[RTE_FLOW_ITEM_TYPE_ ## t] = { \
@@ -157,6 +170,8 @@ static const struct rte_flow_desc_data rte_flow_desc_item[] = {
 	MK_FLOW_ITEM(L2TPV2, sizeof(struct rte_flow_item_l2tpv2)),
 	MK_FLOW_ITEM(PPP, sizeof(struct rte_flow_item_ppp)),
 	MK_FLOW_ITEM(METER_COLOR, sizeof(struct rte_flow_item_meter_color)),
+	MK_FLOW_ITEM_FN(IPV6_ROUTING_EXT, sizeof(struct rte_flow_item_ipv6_routing_ext),
+			rte_flow_item_ipv6_routing_ext_conv),
 };
 
 /** Generate flow_action[] entry. */
lib/ethdev/rte_flow.h +39 -0
index b60987db4b..f8f1d6f9dd 100644
@@ -624,6 +624,33 @@ enum rte_flow_item_type {
 	 * See struct rte_flow_item_meter_color.
 	 */
 	RTE_FLOW_ITEM_TYPE_METER_COLOR,
+	/**
+	 * Matches the presence of IPv6 routing extension header.
+	 *
+	 * See struct rte_flow_item_ipv6_routing_ext.
+	 */
+	RTE_FLOW_ITEM_TYPE_IPV6_ROUTING_EXT,
+
+	/**
+	 * Matches IPv6 routing extension header next header.
+	 *
+	 * See struct rte_flow_item_ipv6_routing_ext.
+	 */
+	RTE_FLOW_ITEM_TYPE_IPV6_ROUTING_EXT_NEXT_HDR,
+
+	/**
+	 * Matches IPv6 routing extension header type.
+	 *
+	 * See struct rte_flow_item_ipv6_routing_ext.
+	 */
+	RTE_FLOW_ITEM_TYPE_IPV6_ROUTING_EXT_TYPE,
+
+	/**
+	 * Matches IPv6 routing extension header segment left.
+	 *
+	 * See struct rte_flow_item_ipv6_routing_ext.
+	 */
+	RTE_FLOW_ITEM_TYPE_IPV6_ROUTING_EXT_SEG_LEFT,
 };
 
 /**
@@ -873,6 +900,18 @@ struct rte_flow_item_ipv6 {
 	uint32_t reserved:23;
 };
 
+/**
+ * @warning
+ * @b EXPERIMENTAL: this structure may change without prior notice
+ *
+ * RTE_FLOW_ITEM_TYPE_IPV6_ROUTING_EXT.
+ *
+ * Matches an IPv6 routing extension header.
+ */
+struct rte_flow_item_ipv6_routing_ext {
+	struct rte_ipv6_routing_ext hdr;
+};
+
 /** Default mask for RTE_FLOW_ITEM_TYPE_IPV6. */
 #ifndef __cplusplus
 static const struct rte_flow_item_ipv6 rte_flow_item_ipv6_mask = {
lib/net/rte_ip.h +21 -0
index 9c8e8206f0..2b9a65dfcb 100644
@@ -539,6 +539,27 @@ struct rte_ipv6_hdr {
 	uint8_t  dst_addr[16];	/**< IP address of destination host(s). */
 } __rte_packed;
 
+/**
+ * IPv6 Routing Extension Header
+ */
+struct rte_ipv6_routing_ext {
+	uint8_t nexthdr;			/**< Protocol, next header. */
+	uint8_t hdrlen;				/**< Header length. */
+	uint8_t type;				/**< Extension header type. */
+	uint8_t segments_left;			/**< Valid segments number. */
+	__extension__
+	union {
+		uint32_t flags;
+		struct {
+			uint8_t last_entry;	/**< The last_entry field of SRH */
+			uint8_t flag;		/**< Packet flag. */
+			uint16_t tag;		/**< Packet tag. */
+		};
+	};
+	__extension__
+	uint32_t segments[0];			/**< Each hop IPv6 address. */
+} __rte_packed;
+
 /* IPv6 vtc_flow: IPv / TC / flow_label */
 #define RTE_IPV6_HDR_FL_SHIFT 0
 #define RTE_IPV6_HDR_TC_SHIFT 20
Signature · 1 line
2.27.0
#2 lore raw

RE: [RFC 1/9] ethdev: add IPv6 routing extension header definition

Hi Rongwei,

Quoted 106 lines

-----Original Message-----
From: Rongwei Liu <[email protected]>
Sent: Wednesday, 21 December 2022 10:43

Add IPv6 routing extension header definition and no TLV support for now.
At rte_flow layer, there are new items defined for matching type/nexthdr/segment_left field.

---
 doc/guides/prog_guide/rte_flow.rst     |  9 ++++++
 doc/guides/rel_notes/release_22_03.rst |  5 ++++
 lib/ethdev/rte_flow.c                  | 15 ++++++++++
 lib/ethdev/rte_flow.h                  | 39 ++++++++++++++++++++++++++
 lib/net/rte_ip.h                       | 21 ++++++++++++++
 5 files changed, 89 insertions(+)
doc/guides/prog_guide/rte_flow.rst +9 -0
index 3e6242803d..1ebc159893 100644
@@ -1544,6 +1544,15 @@ Matches Color Marker set by a Meter.
 
 - ``color``: Metering color marker.
 
+Item: ``IPV6_ROUTING_EXT``
+^^^^^^^^^^^^^^^^^^^^^
+
+Matches ipv6 routing extension header.
+
+- ``nexthdr``: Next layer header type.
+- ``type``: IPv6 routing extension header type.
+- ``segments_left``: How many IPv6 destination addresses carries on
+
 Actions
 ~~~~~~~
 
doc/guides/rel_notes/release_22_03.rst +5 -0
index 0923707cb8..cc050ff3e7 100644
@@ -207,6 +207,11 @@ API Changes
 * ethdev: Old public macros and enumeration constants without
 ``RTE_ETH_`` prefix,
   which are kept for backward compatibility, are marked as deprecated.
 
+* ethdev: added a new structure:
+
+    - IPv6 routing extension header ``rte_flow_item_ipv6_routing_ext`` and
+      ``rte_ipv6_routing_ext``
+
 * cryptodev: The asymmetric session handling was modified to use a single
   mempool object. An API ``rte_cryptodev_asym_session_pool_create`` was

added
to create a mempool with element size big enough to hold the generic
asymmetric

lib/ethdev/rte_flow.c +15 -0
index 7d0c24366c..e08b690300 100644
@@ -76,6 +76,19 @@ rte_flow_item_flex_conv(void *buf, const void *data)
 	return src->length;
 }
 
+static size_t
+rte_flow_item_ipv6_routing_ext_conv(void *buf, const void *data)
+{
+	struct rte_flow_item_ipv6_routing_ext *dst = buf;
+	const struct rte_flow_item_ipv6_routing_ext *src = data;
+
+	if (buf)
+		rte_memcpy((void *)((uintptr_t)(dst->hdr.segments)),
+			   src->hdr.segments,
+			   src->hdr.segments_left << 4);
+	return src->hdr.segments_left << 4;
+}
+
 /** Generate flow_item[] entry. */
 #define MK_FLOW_ITEM(t, s) \
 	[RTE_FLOW_ITEM_TYPE_ ## t] = { \
@@ -157,6 +170,8 @@ static const struct rte_flow_desc_data
 rte_flow_desc_item[] = {
 	MK_FLOW_ITEM(L2TPV2, sizeof(struct rte_flow_item_l2tpv2)),
 	MK_FLOW_ITEM(PPP, sizeof(struct rte_flow_item_ppp)),
 	MK_FLOW_ITEM(METER_COLOR, sizeof(struct
 rte_flow_item_meter_color)),
+	MK_FLOW_ITEM_FN(IPV6_ROUTING_EXT, sizeof(struct
 rte_flow_item_ipv6_routing_ext),
+			rte_flow_item_ipv6_routing_ext_conv),

};

/** Generate flow_action[] entry. */

lib/ethdev/rte_flow.h +3 -0
index b60987db4b..f8f1d6f9dd 100644
@@ -624,6 +624,33 @@ enum rte_flow_item_type {
 	 * See struct rte_flow_item_meter_color.
 	 */
 	RTE_FLOW_ITEM_TYPE_METER_COLOR,
+	/**
+	 * Matches the presence of IPv6 routing extension header.
+	 *

lib/ethdev/rte_flow.h enum rte_flow_item_type { · line 639

Quoted 10 lines
lib/ethdev/rte_flow.h +10 -0
+	 * See struct rte_flow_item_ipv6_routing_ext.
+	 */
+	RTE_FLOW_ITEM_TYPE_IPV6_ROUTING_EXT,
+
+	/**
+	 * Matches IPv6 routing extension header next header.
+	 *
+	 * See struct rte_flow_item_ipv6_routing_ext.
+	 */
+	RTE_FLOW_ITEM_TYPE_IPV6_ROUTING_EXT_NEXT_HDR,

Why do we need this item? Isn't it part of the rte_ipv6_routing_ext?

lib/ethdev/rte_flow.h enum rte_flow_item_type { · line 647

Quoted 8 lines
lib/ethdev/rte_flow.h +8 -0
+
+	/**
+	 * Matches IPv6 routing extension header type.
+	 *
+	 * See struct rte_flow_item_ipv6_routing_ext.
+	 */
+	RTE_FLOW_ITEM_TYPE_IPV6_ROUTING_EXT_TYPE,
+

Why do we need this item? Isn't it part of the rte_ipv6_routing_ext?

lib/ethdev/rte_flow.h enum rte_flow_item_type { · line 653

Quoted 6 lines
lib/ethdev/rte_flow.h +6 -0
+	/**
+	 * Matches IPv6 routing extension header segment left.
+	 *
+	 * See struct rte_flow_item_ipv6_routing_ext.
+	 */
+	RTE_FLOW_ITEM_TYPE_IPV6_ROUTING_EXT_SEG_LEFT,

Why do we need this item? Isn't it part of the rte_ipv6_routing_ext?

Quoted 60 lines
lib/ethdev/rte_flow.h +12 -0
 };
 
 /**
@@ -873,6 +900,18 @@ struct rte_flow_item_ipv6 {
 	uint32_t reserved:23;
 };
 
+/**
+ * @warning
+ * @b EXPERIMENTAL: this structure may change without prior notice
+ *
+ * RTE_FLOW_ITEM_TYPE_IPV6_ROUTING_EXT.
+ *
+ * Matches an IPv6 routing extension header.
+ */
+struct rte_flow_item_ipv6_routing_ext {
+	struct rte_ipv6_routing_ext hdr;
+};
+
 /** Default mask for RTE_FLOW_ITEM_TYPE_IPV6. */
 #ifndef __cplusplus
 static const struct rte_flow_item_ipv6 rte_flow_item_ipv6_mask = {
lib/net/rte_ip.h +13 -0
index 9c8e8206f0..2b9a65dfcb 100644
@@ -539,6 +539,27 @@ struct rte_ipv6_hdr {
 	uint8_t  dst_addr[16];	/**< IP address of destination host(s). */
 } __rte_packed;
 
+/**
+ * IPv6 Routing Extension Header
+ */
+struct rte_ipv6_routing_ext {
+	uint8_t nexthdr;			/**< Protocol, next header.
 */
+	uint8_t hdrlen;				/**< Header length. */
+	uint8_t type;				/**< Extension header type.
 */
+	uint8_t segments_left;			/**< Valid segments number.
 */
+	__extension__
+	union {
+		uint32_t flags;
+		struct {
+			uint8_t last_entry;	/**< The last_entry field of

SRH */

lib/net/rte_ip.h +6 -0
+			uint8_t flag;		/**< Packet flag. */
+			uint16_t tag;		/**< Packet tag. */
+		};
+	};
+	__extension__
+	uint32_t segments[0];			/**< Each hop IPv6 address.

*/

lib/net/rte_ip.h +2 -1
+} __rte_packed;
+
 /* IPv6 vtc_flow: IPv / TC / flow_label */
 #define RTE_IPV6_HDR_FL_SHIFT 0
 #define RTE_IPV6_HDR_TC_SHIFT 20
--
Quoted 1 line

2.27.0

Best,
Ori

#3 lore raw

RE: [RFC 1/9] ethdev: add IPv6 routing extension header definition

HI Ori:
Those three matching items are redundant. Has been removed already. Do I need to send RFC v2?

BR
Rongwei

Quoted 122 lines

-----Original Message-----
From: Ori Kam <[email protected]>
Sent: Tuesday, January 17, 2023 00:15
To: Rongwei Liu <[email protected]>; Matan Azrad <[email protected]>; Slava Ovsiienko <[email protected]>; NBU-Contact-Thomas Monjalon (EXTERNAL) <[email protected]>; Ferruh Yigit <[email protected]>; Andrew Rybchenko <[email protected]>; Olivier Matz <[email protected]>
Cc: [email protected]; Raslan Darawsheh <[email protected]>
Subject: RE: [RFC 1/9] ethdev: add IPv6 routing extension header definition

Hi Rongwei,

Quoted 82 lines

-----Original Message-----
From: Rongwei Liu <[email protected]>
Sent: Wednesday, 21 December 2022 10:43

Add IPv6 routing extension header definition and no TLV support for now.
At rte_flow layer, there are new items defined for matching type/nexthdr/segment_left field.

---
 doc/guides/prog_guide/rte_flow.rst     |  9 ++++++
 doc/guides/rel_notes/release_22_03.rst |  5 ++++
 lib/ethdev/rte_flow.c                  | 15 ++++++++++
 lib/ethdev/rte_flow.h                  | 39 ++++++++++++++++++++++++++
 lib/net/rte_ip.h                       | 21 ++++++++++++++
 5 files changed, 89 insertions(+)
doc/guides/prog_guide/rte_flow.rst +9 -0
index 3e6242803d..1ebc159893 100644
@@ -1544,6 +1544,15 @@ Matches Color Marker set by a Meter.
 
 - ``color``: Metering color marker.
 
+Item: ``IPV6_ROUTING_EXT``
+^^^^^^^^^^^^^^^^^^^^^
+
+Matches ipv6 routing extension header.
+
+- ``nexthdr``: Next layer header type.
+- ``type``: IPv6 routing extension header type.
+- ``segments_left``: How many IPv6 destination addresses carries on
+
 Actions
 ~~~~~~~
 
doc/guides/rel_notes/release_22_03.rst +5 -0
index 0923707cb8..cc050ff3e7 100644
@@ -207,6 +207,11 @@ API Changes
 * ethdev: Old public macros and enumeration constants without
 ``RTE_ETH_`` prefix,
   which are kept for backward compatibility, are marked as deprecated.
 
+* ethdev: added a new structure:
+
+    - IPv6 routing extension header ``rte_flow_item_ipv6_routing_ext`` and
+      ``rte_ipv6_routing_ext``
+
 * cryptodev: The asymmetric session handling was modified to use a single
   mempool object. An API ``rte_cryptodev_asym_session_pool_create``

was added
to create a mempool with element size big enough to hold the
generic asymmetric diff --git a/lib/ethdev/rte_flow.c b/lib/ethdev/rte_flow.c index 7d0c24366c..e08b690300 100644

lib/ethdev/rte_flow.c +12 -0
@@ -76,6 +76,19 @@ rte_flow_item_flex_conv(void *buf, const void *data)
 	return src->length;
 }
 
+static size_t
+rte_flow_item_ipv6_routing_ext_conv(void *buf, const void *data) {
+	struct rte_flow_item_ipv6_routing_ext *dst = buf;
+	const struct rte_flow_item_ipv6_routing_ext *src = data;
+
+	if (buf)
+		rte_memcpy((void *)((uintptr_t)(dst->hdr.segments)),
+			   src->hdr.segments,
+			   src->hdr.segments_left << 4);
+	return src->hdr.segments_left << 4;
+}
+
 /** Generate flow_item[] entry. */
 #define MK_FLOW_ITEM(t, s) \
 	[RTE_FLOW_ITEM_TYPE_ ## t] = { \

lib/ethdev/rte_flow.c static const struct rte_flow_desc_data · line 173

Quoted 4 lines
lib/ethdev/rte_flow.c +0 -0
@@ -157,6 +170,8 @@ static const struct rte_flow_desc_data
 rte_flow_desc_item[] = {
 	MK_FLOW_ITEM(L2TPV2, sizeof(struct rte_flow_item_l2tpv2)),
 	MK_FLOW_ITEM(PPP, sizeof(struct rte_flow_item_ppp)),
 	MK_FLOW_ITEM(METER_COLOR, sizeof(struct

rte_flow_item_meter_color)),

Quoted 21 lines
lib/ethdev/rte_flow.c +2 -0
+	MK_FLOW_ITEM_FN(IPV6_ROUTING_EXT, sizeof(struct
 rte_flow_item_ipv6_routing_ext),
+			rte_flow_item_ipv6_routing_ext_conv),
 };

/** Generate flow_action[] entry. */

lib/ethdev/rte_flow.h index renamed from lib/ethdev/rte_flow.h +0 -0

b60987db4b..f8f1d6f9dd 100644

lib/ethdev/rte_flow.h +7 -0
@@ -624,6 +624,33 @@ enum rte_flow_item_type {
 	 * See struct rte_flow_item_meter_color.
 	 */
 	RTE_FLOW_ITEM_TYPE_METER_COLOR,
+	/**
+	 * Matches the presence of IPv6 routing extension header.
+	 *
+	 * See struct rte_flow_item_ipv6_routing_ext.
+	 */
+	RTE_FLOW_ITEM_TYPE_IPV6_ROUTING_EXT,
+
Quoted 8 lines

lib/ethdev/rte_flow.h enum rte_flow_item_type { · line 639

Quoted 6 lines
lib/ethdev/rte_flow.h +6 -0
+	/**
+	 * Matches IPv6 routing extension header next header.
+	 *
+	 * See struct rte_flow_item_ipv6_routing_ext.
+	 */
+	RTE_FLOW_ITEM_TYPE_IPV6_ROUTING_EXT_NEXT_HDR,

Why do we need this item? Isn't it part of the rte_ipv6_routing_ext?

Will remove in the patch.

Quoted 11 lines

lib/ethdev/rte_flow.h enum rte_flow_item_type { · line 647

Quoted 9 lines
lib/ethdev/rte_flow.h +8 -0
+
+	/**
+	 * Matches IPv6 routing extension header type.
+	 *
+	 * See struct rte_flow_item_ipv6_routing_ext.
+	 */
+	RTE_FLOW_ITEM_TYPE_IPV6_ROUTING_EXT_TYPE,
+

Why do we need this item? Isn't it part of the rte_ipv6_routing_ext?

Will remove in the patch.

Quoted 9 lines

lib/ethdev/rte_flow.h enum rte_flow_item_type { · line 653

Quoted 7 lines
lib/ethdev/rte_flow.h +6 -0
+	/**
+	 * Matches IPv6 routing extension header segment left.
+	 *
+	 * See struct rte_flow_item_ipv6_routing_ext.
+	 */
+	RTE_FLOW_ITEM_TYPE_IPV6_ROUTING_EXT_SEG_LEFT,

Why do we need this item? Isn't it part of the rte_ipv6_routing_ext?

Will remove in the patch.

Quoted 64 lines
Quoted 30 lines
lib/ethdev/rte_flow.h +12 -0
 };
 
 /**
@@ -873,6 +900,18 @@ struct rte_flow_item_ipv6 {
 	uint32_t reserved:23;
 };
 
+/**
+ * @warning
+ * @b EXPERIMENTAL: this structure may change without prior notice
+ *
+ * RTE_FLOW_ITEM_TYPE_IPV6_ROUTING_EXT.
+ *
+ * Matches an IPv6 routing extension header.
+ */
+struct rte_flow_item_ipv6_routing_ext {
+	struct rte_ipv6_routing_ext hdr;
+};
+
 /** Default mask for RTE_FLOW_ITEM_TYPE_IPV6. */  #ifndef __cplusplus
 static const struct rte_flow_item_ipv6 rte_flow_item_ipv6_mask = {
lib/net/rte_ip.h index renamed from lib/net/rte_ip.h +0 -0

9c8e8206f0..2b9a65dfcb 100644

lib/net/rte_ip.h +0 -0
@@ -539,6 +539,27 @@ struct rte_ipv6_hdr {
 	uint8_t  dst_addr[16];	/**< IP address of destination host(s). */
 } __rte_packed;
 

lib/net/rte_ip.h struct rte_ipv6_hdr { · line 551

Quoted 10 lines
lib/net/rte_ip.h +8 -0
+/**
+ * IPv6 Routing Extension Header
+ */
+struct rte_ipv6_routing_ext {
+	uint8_t nexthdr;			/**< Protocol, next header.
 */
+	uint8_t hdrlen;				/**< Header length. */
+	uint8_t type;				/**< Extension header type.
 */
+	uint8_t segments_left;			/**< Valid segments

number.

Quoted 17 lines
lib/net/rte_ip.h +5 -0
 */
+	__extension__
+	union {
+		uint32_t flags;
+		struct {
+			uint8_t last_entry;	/**< The last_entry field of

SRH */

lib/net/rte_ip.h +6 -0
+			uint8_t flag;		/**< Packet flag. */
+			uint16_t tag;		/**< Packet tag. */
+		};
+	};
+	__extension__
+	uint32_t segments[0];			/**< Each hop IPv6 address.

*/

lib/net/rte_ip.h +2 -0
+} __rte_packed;
+
 /* IPv6 vtc_flow: IPv / TC / flow_label */  #define
Quoted 3 lines

RTE_IPV6_HDR_FL_SHIFT 0 #define RTE_IPV6_HDR_TC_SHIFT 20 --
2.27.0

Best,
Ori

#4 lore raw

v2 cover add IPv6 routing extension support

In reply to Rongwei Liu

Support IPv6 routing extension header matching with new rte_flow item. Add encapsulation support for IPv6 routing extension header.

v2: remove redundant rte_flow items. include the commit from Gregory
to pass the compilation.

Gregory Etelson (1):
net/mlx5/hws: Definer, add mlx5dr context to definer_conv_data

Rongwei Liu (7):
ethdev: add IPv6 routing extension header definition net/mlx5: adopt IPv6 routing extension prm definition net/mlx5/hws: add IPv6 routing extension matching support app/testpmd: add IPv6 routing extension header in raw encap
ethdev: add modify IPv6 protocol field net/mlx5/hws: add modify IPv6 protocol implementation doc/mlx5: add IPv6 routing extension matching docs

 app/test-pmd/cmdline_flow.c            |  72 ++++++++++++-
 doc/guides/nics/features/default.ini   |   1 +
 doc/guides/nics/features/mlx5.ini      |   1 +
 doc/guides/nics/mlx5.rst               |   2 +
 doc/guides/prog_guide/rte_flow.rst     |   9 ++
 doc/guides/rel_notes/release_23_03.rst |  10 ++
 drivers/common/mlx5/mlx5_devx_cmds.c   |  17 +++-
 drivers/common/mlx5/mlx5_devx_cmds.h   |   7 +-
 drivers/common/mlx5/mlx5_prm.h         |  29 +++++-
 drivers/net/mlx5/hws/mlx5dr_definer.c  | 133 +++++++++++++++++++++----
 drivers/net/mlx5/hws/mlx5dr_definer.h  |  15 +++
 drivers/net/mlx5/mlx5.c                | 103 ++++++++++++++++++-
 drivers/net/mlx5/mlx5.h                |  19 +++-
 drivers/net/mlx5/mlx5_flow.h           |  28 ++++++
 drivers/net/mlx5/mlx5_flow_dv.c        |  10 ++
 drivers/net/mlx5/mlx5_flow_flex.c      |  14 ++-
 drivers/net/mlx5/mlx5_flow_hw.c        |  29 +++++-
 lib/ethdev/rte_flow.c                  |  16 +++
 lib/ethdev/rte_flow.h                  |  20 ++++
 lib/net/rte_ip.h                       |  21 ++++
 20 files changed, 515 insertions(+), 41 deletions(-)
Signature · 1 line
2.27.0
#5 lore raw

PATCH v2 1/8 ethdev: add IPv6 routing extension header definition

Add IPv6 routing extension header definition and no TLV support for now.

At rte_flow layer, there are new items defined for matching type/nexthdr/segments_left field.

Add command line support for IPv6 routing extension header
matching: type/nexthdr/segment_list.

---
 app/test-pmd/cmdline_flow.c            | 46 ++++++++++++++++++++++++++
 doc/guides/prog_guide/rte_flow.rst     |  9 +++++
 doc/guides/rel_notes/release_23_03.rst | 10 ++++++
 lib/ethdev/rte_flow.c                  | 16 +++++++++
 lib/ethdev/rte_flow.h                  | 19 +++++++++++
 lib/net/rte_ip.h                       | 21 ++++++++++++
 6 files changed, 121 insertions(+)
app/test-pmd/cmdline_flow.c +46 -0
index 88108498e0..7a8516829c 100644
@@ -298,6 +298,10 @@ enum index {
 	ITEM_IPV6_SRC,
 	ITEM_IPV6_DST,
 	ITEM_IPV6_HAS_FRAG_EXT,
+	ITEM_IPV6_ROUTING_EXT,
+	ITEM_IPV6_ROUTING_EXT_TYPE,
+	ITEM_IPV6_ROUTING_EXT_NEXT_HDR,
+	ITEM_IPV6_ROUTING_EXT_SEG_LEFT,
 	ITEM_ICMP,
 	ITEM_ICMP_TYPE,
 	ITEM_ICMP_CODE,
@@ -1326,6 +1330,7 @@ static const enum index next_item[] = {
 	ITEM_ARP_ETH_IPV4,
 	ITEM_IPV6_EXT,
 	ITEM_IPV6_FRAG_EXT,
+	ITEM_IPV6_ROUTING_EXT,
 	ITEM_ICMP6,
 	ITEM_ICMP6_ND_NS,
 	ITEM_ICMP6_ND_NA,
@@ -1435,6 +1440,15 @@ static const enum index item_ipv6[] = {
 	ITEM_IPV6_SRC,
 	ITEM_IPV6_DST,
 	ITEM_IPV6_HAS_FRAG_EXT,
+	ITEM_IPV6_ROUTING_EXT,
+	ITEM_NEXT,
+	ZERO,
+};
+
+static const enum index item_ipv6_routing_ext[] = {
+	ITEM_IPV6_ROUTING_EXT_TYPE,
+	ITEM_IPV6_ROUTING_EXT_NEXT_HDR,
+	ITEM_IPV6_ROUTING_EXT_SEG_LEFT,
 	ITEM_NEXT,
 	ZERO,
 };
@@ -3844,6 +3858,38 @@ static const struct token token_list[] = {
 		.args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_ipv6,
 					   has_frag_ext, 1)),
 	},
+	[ITEM_IPV6_ROUTING_EXT] = {
+		.name = "ipv6_routing_ext",
+		.help = "match IPv6 routing extension header",
+		.priv = PRIV_ITEM(IPV6_ROUTING_EXT,
+				  sizeof(struct rte_flow_item_ipv6_routing_ext)),
+		.next = NEXT(item_ipv6_routing_ext),
+		.call = parse_vc,
+	},
+	[ITEM_IPV6_ROUTING_EXT_TYPE] = {
+		.name = "ext_type",
+		.help = "match IPv6 routing extension header type",
+		.next = NEXT(item_ipv6_routing_ext, NEXT_ENTRY(COMMON_UNSIGNED),
+			     item_param),
+		.args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6_routing_ext,
+					     hdr.type)),
+	},
+	[ITEM_IPV6_ROUTING_EXT_NEXT_HDR] = {
+		.name = "ext_next_hdr",
+		.help = "match IPv6 routing extension header next header type",
+		.next = NEXT(item_ipv6_routing_ext, NEXT_ENTRY(COMMON_UNSIGNED),
+			     item_param),
+		.args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6_routing_ext,
+					     hdr.next_hdr)),
+	},
+	[ITEM_IPV6_ROUTING_EXT_SEG_LEFT] = {
+		.name = "ext_seg_left",
+		.help = "match IPv6 routing extension header segment left",
+		.next = NEXT(item_ipv6_routing_ext, NEXT_ENTRY(COMMON_UNSIGNED),
+			     item_param),
+		.args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6_routing_ext,
+					     hdr.segments_left)),
+	},
 	[ITEM_ICMP] = {
 		.name = "icmp",
 		.help = "match ICMP header",
doc/guides/prog_guide/rte_flow.rst +9 -0
index 3e6242803d..ae99036be0 100644
@@ -1544,6 +1544,15 @@ Matches Color Marker set by a Meter.
 
 - ``color``: Metering color marker.
 
+Item: ``IPV6_ROUTING_EXT``
+^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+Matches ipv6 routing extension header.
+
+- ``next_hdr``: Next layer header type.
+- ``type``: IPv6 routing extension header type.
+- ``segments_left``: How many IPv6 destination addresses carries on
+
 Actions
 ~~~~~~~
 
doc/guides/rel_notes/release_23_03.rst +10 -0
index b8c5b68d6c..2a794d598e 100644
@@ -55,6 +55,11 @@ New Features
      Also, make sure to start the actual text at the margin.
      =======================================================
 
+* **Added rte_flow support for matching IPv6 routing extension header fields.**
+
+  Added ``ipv6_routing_ext`` items in rte_flow to match IPv6 routing extension
+  header
+
 
 Removed Items
 -------------
@@ -84,6 +89,11 @@ API Changes
    Also, make sure to start the actual text at the margin.
    =======================================================
 
+* ethdev: added a new structure:
+
+    - IPv6 routing extension header ``rte_flow_item_ipv6_routing_ext`` and
+      ``rte_ipv6_routing_ext``
+
 
 ABI Changes
 -----------
lib/ethdev/rte_flow.c +16 -0
index 7d0c24366c..4074b475c8 100644
@@ -76,6 +76,20 @@ rte_flow_item_flex_conv(void *buf, const void *data)
 	return src->length;
 }
 
+static size_t
+rte_flow_item_ipv6_routing_ext_conv(void *buf, const void *data)
+{
+	struct rte_flow_item_ipv6_routing_ext *dst = buf;
+	const struct rte_flow_item_ipv6_routing_ext *src = data;
+	size_t len;
+
+	len = src->hdr.hdr_len ? src->hdr.hdr_len << 3 : src->hdr.segments_left << 4;
+	if (buf)
+		rte_memcpy((void *)((uintptr_t)(dst->hdr.segments)),
+			   src->hdr.segments, len);
+	return len;
+}
+
 /** Generate flow_item[] entry. */
 #define MK_FLOW_ITEM(t, s) \
 	[RTE_FLOW_ITEM_TYPE_ ## t] = { \
@@ -157,6 +171,8 @@ static const struct rte_flow_desc_data rte_flow_desc_item[] = {
 	MK_FLOW_ITEM(L2TPV2, sizeof(struct rte_flow_item_l2tpv2)),
 	MK_FLOW_ITEM(PPP, sizeof(struct rte_flow_item_ppp)),
 	MK_FLOW_ITEM(METER_COLOR, sizeof(struct rte_flow_item_meter_color)),
+	MK_FLOW_ITEM_FN(IPV6_ROUTING_EXT, sizeof(struct rte_flow_item_ipv6_routing_ext),
+			rte_flow_item_ipv6_routing_ext_conv),
 };
 
 /** Generate flow_action[] entry. */
lib/ethdev/rte_flow.h +19 -0
index b60987db4b..0120d3e7d2 100644
@@ -624,6 +624,13 @@ enum rte_flow_item_type {
 	 * See struct rte_flow_item_meter_color.
 	 */
 	RTE_FLOW_ITEM_TYPE_METER_COLOR,
+
+	/**
+	 * Matches the presence of IPv6 routing extension header.
+	 *
+	 * See struct rte_flow_item_ipv6_routing_ext.
+	 */
+	RTE_FLOW_ITEM_TYPE_IPV6_ROUTING_EXT,
 };
 
 /**
@@ -873,6 +880,18 @@ struct rte_flow_item_ipv6 {
 	uint32_t reserved:23;
 };
 
+/**
+ * @warning
+ * @b EXPERIMENTAL: this structure may change without prior notice
+ *
+ * RTE_FLOW_ITEM_TYPE_IPV6_ROUTING_EXT.
+ *
+ * Matches an IPv6 routing extension header.
+ */
+struct rte_flow_item_ipv6_routing_ext {
+	struct rte_ipv6_routing_ext hdr;
+};
+
 /** Default mask for RTE_FLOW_ITEM_TYPE_IPV6. */
 #ifndef __cplusplus
 static const struct rte_flow_item_ipv6 rte_flow_item_ipv6_mask = {
lib/net/rte_ip.h +21 -0
index 9c8e8206f0..158a2f83ce 100644
@@ -539,6 +539,27 @@ struct rte_ipv6_hdr {
 	uint8_t  dst_addr[16];	/**< IP address of destination host(s). */
 } __rte_packed;
 
+/**
+ * IPv6 Routing Extension Header
+ */
+struct rte_ipv6_routing_ext {
+	uint8_t next_hdr;			/**< Protocol, next header. */
+	uint8_t hdr_len;			/**< Header length. */
+	uint8_t type;				/**< Extension header type. */
+	uint8_t segments_left;			/**< Valid segments number. */
+	__extension__
+	union {
+		uint32_t flags;
+		struct {
+			uint8_t last_entry;	/**< The last_entry field of SRH */
+			uint8_t flag;		/**< Packet flag. */
+			uint16_t tag;		/**< Packet tag. */
+		};
+	};
+	__extension__
+	uint32_t segments[0];			/**< Each hop IPv6 address. */
+} __rte_packed;
+
 /* IPv6 vtc_flow: IPv / TC / flow_label */
 #define RTE_IPV6_HDR_FL_SHIFT 0
 #define RTE_IPV6_HDR_TC_SHIFT 20
Signature · 1 line
2.27.0
#6 lore raw

Re: [PATCH v2 1/8] ethdev: add IPv6 routing extension header definition

Quoted 11 lines · Rongwei Liu

Add IPv6 routing extension header definition and no TLV support for now.

At rte_flow layer, there are new items defined for matching type/nexthdr/segments_left field.

Add command line support for IPv6 routing extension header
matching: type/nexthdr/segment_list.

[snip]

doc/guides/prog_guide/rte_flow.rst Matches Color Marker set by a Meter. · line 1550

Quoted 12 lines
doc/guides/prog_guide/rte_flow.rst +4 -0
index 3e6242803d..ae99036be0 100644
@@ -1544,6 +1544,15 @@ Matches Color Marker set by a Meter.
 
  - ``color``: Metering color marker.
 
+Item: ``IPV6_ROUTING_EXT``
+^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+Matches ipv6 routing extension header.

ipv6 -> IPv6

doc/guides/prog_guide/rte_flow.rst Matches Color Marker set by a Meter. · line 1554

Quoted 4 lines
doc/guides/prog_guide/rte_flow.rst +4 -0
+
+- ``next_hdr``: Next layer header type.
+- ``type``: IPv6 routing extension header type.
+- ``segments_left``: How many IPv6 destination addresses carries on

Why are only 3 fields mentioned above?

Quoted 9 lines
doc/guides/prog_guide/rte_flow.rst +1 -0
+
  Actions
  ~~~~~~~
 
doc/guides/rel_notes/release_23_03.rst +0 -0
index b8c5b68d6c..2a794d598e 100644

doc/guides/rel_notes/release_23_03.rst New Features · line 61

Quoted 7 lines
doc/guides/rel_notes/release_23_03.rst +4 -0
@@ -55,6 +55,11 @@ New Features
       Also, make sure to start the actual text at the margin.
       =======================================================
 
+* **Added rte_flow support for matching IPv6 routing extension header fields.**
+
+  Added ``ipv6_routing_ext`` items in rte_flow to match IPv6 routing extension
+  header

Missing full stop above.

doc/guides/rel_notes/release_23_03.rst API Changes · line 96

Quoted 13 lines
doc/guides/rel_notes/release_23_03.rst +6 -0
+
 
  Removed Items
  -------------
@@ -84,6 +89,11 @@ API Changes
     Also, make sure to start the actual text at the margin.
     =======================================================
 
+* ethdev: added a new structure:
+
+    - IPv6 routing extension header ``rte_flow_item_ipv6_routing_ext`` and
+      ``rte_ipv6_routing_ext``
+

If I'm not mistaken, additions should not be here. It is not an API change.

Quoted 9 lines
doc/guides/rel_notes/release_23_03.rst +0 -0
  ABI Changes
  -----------
lib/ethdev/rte_flow.c +0 -0
index 7d0c24366c..4074b475c8 100644
@@ -76,6 +76,20 @@ rte_flow_item_flex_conv(void *buf, const void *data)
  	return src->length;

lib/ethdev/rte_flow.c rte_flow_item_flex_conv(void *buf, const void *data) · line 86

Quoted 10 lines
lib/ethdev/rte_flow.c +8 -0
  }
 
+static size_t
+rte_flow_item_ipv6_routing_ext_conv(void *buf, const void *data)
+{
+	struct rte_flow_item_ipv6_routing_ext *dst = buf;
+	const struct rte_flow_item_ipv6_routing_ext *src = data;
+	size_t len;
+
+	len = src->hdr.hdr_len ? src->hdr.hdr_len << 3 : src->hdr.segments_left << 4;

Compare hdr_len vs 0 explicitly.
Also I'd add parenthesis around ternary operator
values to make it simpler to understand.

lib/ethdev/rte_flow.c rte_flow_item_flex_conv(void *buf, const void *data) · line 87

Quoted 1 line
lib/ethdev/rte_flow.c +1 -0
+	if (buf)

Please, compare vs NULL explicitly. May be 'dst' would be better here?

Quoted 22 lines
lib/ethdev/rte_flow.c +7 -0
+		rte_memcpy((void *)((uintptr_t)(dst->hdr.segments)),
+			   src->hdr.segments, len);
+	return len;
+}
+
  /** Generate flow_item[] entry. */
  #define MK_FLOW_ITEM(t, s) \
  	[RTE_FLOW_ITEM_TYPE_ ## t] = { \
@@ -157,6 +171,8 @@ static const struct rte_flow_desc_data rte_flow_desc_item[] = {
  	MK_FLOW_ITEM(L2TPV2, sizeof(struct rte_flow_item_l2tpv2)),
  	MK_FLOW_ITEM(PPP, sizeof(struct rte_flow_item_ppp)),
  	MK_FLOW_ITEM(METER_COLOR, sizeof(struct rte_flow_item_meter_color)),
+	MK_FLOW_ITEM_FN(IPV6_ROUTING_EXT, sizeof(struct rte_flow_item_ipv6_routing_ext),
+			rte_flow_item_ipv6_routing_ext_conv),
  };
 
  /** Generate flow_action[] entry. */
lib/ethdev/rte_flow.h +0 -0
index b60987db4b..0120d3e7d2 100644

lib/ethdev/rte_flow.h enum rte_flow_item_type { · line 631

Quoted 8 lines
lib/ethdev/rte_flow.h +5 -0
@@ -624,6 +624,13 @@ enum rte_flow_item_type {
  	 * See struct rte_flow_item_meter_color.
  	 */
  	RTE_FLOW_ITEM_TYPE_METER_COLOR,
+
+	/**
+	 * Matches the presence of IPv6 routing extension header.
+	 *
+	 * See struct rte_flow_item_ipv6_routing_ext.

@see

Quoted 11 lines
lib/ethdev/rte_flow.h +4 -0
+	 */
+	RTE_FLOW_ITEM_TYPE_IPV6_ROUTING_EXT,
  };
 
  /**
@@ -873,6 +880,18 @@ struct rte_flow_item_ipv6 {
  	uint32_t reserved:23;
  };
 
+/**
+ * @warning

lib/ethdev/rte_flow.h struct rte_flow_item_ipv6 { · line 894

Quoted 10 lines
lib/ethdev/rte_flow.h +10 -0
+ * @b EXPERIMENTAL: this structure may change without prior notice
+ *
+ * RTE_FLOW_ITEM_TYPE_IPV6_ROUTING_EXT.
+ *
+ * Matches an IPv6 routing extension header.
+ */
+struct rte_flow_item_ipv6_routing_ext {
+	struct rte_ipv6_routing_ext hdr;
+};
+

What about default mask?

Quoted 12 lines
lib/ethdev/rte_flow.h +0 -0
  /** Default mask for RTE_FLOW_ITEM_TYPE_IPV6. */
  #ifndef __cplusplus
  static const struct rte_flow_item_ipv6 rte_flow_item_ipv6_mask = {
lib/net/rte_ip.h +1 -0
index 9c8e8206f0..158a2f83ce 100644
@@ -539,6 +539,27 @@ struct rte_ipv6_hdr {
  	uint8_t  dst_addr[16];	/**< IP address of destination host(s). */
  } __rte_packed;
 
+/**

lib/net/rte_ip.h struct rte_ipv6_hdr { · line 552

Quoted 10 lines
lib/net/rte_ip.h +10 -0
+ * IPv6 Routing Extension Header
+ */
+struct rte_ipv6_routing_ext {
+	uint8_t next_hdr;			/**< Protocol, next header. */
+	uint8_t hdr_len;			/**< Header length. */
+	uint8_t type;				/**< Extension header type. */
+	uint8_t segments_left;			/**< Valid segments number. */
+	__extension__
+	union {
+		uint32_t flags;

rte_be32_t ?

lib/net/rte_ip.h struct rte_ipv6_hdr { · line 556

Quoted 4 lines
lib/net/rte_ip.h +4 -0
+		struct {
+			uint8_t last_entry;	/**< The last_entry field of SRH */
+			uint8_t flag;		/**< Packet flag. */
+			uint16_t tag;		/**< Packet tag. */

rte_be16_t

lib/net/rte_ip.h struct rte_ipv6_hdr { · line 560

Quoted 4 lines
lib/net/rte_ip.h +4 -0
+		};
+	};
+	__extension__
+	uint32_t segments[0];			/**< Each hop IPv6 address. */

rte_be32_t

Quoted 5 lines
lib/net/rte_ip.h +2 -0
+} __rte_packed;
+
  /* IPv6 vtc_flow: IPv / TC / flow_label */
  #define RTE_IPV6_HDR_FL_SHIFT 0
  #define RTE_IPV6_HDR_TC_SHIFT 20
#7 lore raw

RE: [PATCH v2 1/8] ethdev: add IPv6 routing extension header definition

HI Andrew

BR
Rongwei

Quoted 38 lines

-----Original Message-----
From: Andrew Rybchenko <[email protected]>
Sent: Friday, January 20, 2023 17:21
To: Rongwei Liu <[email protected]>; Matan Azrad <[email protected]>; Slava Ovsiienko <[email protected]>; Ori Kam <[email protected]>; NBU-Contact-Thomas Monjalon (EXTERNAL) <[email protected]>; Aman Singh <[email protected]>; Yuying Zhang <[email protected]>; Ferruh Yigit <[email protected]>; Olivier Matz <[email protected]>
Cc: [email protected]; Raslan Darawsheh <[email protected]>
Subject: Re: [PATCH v2 1/8] ethdev: add IPv6 routing extension header definition

External email: Use caution opening links or attachments

Quoted 11 lines · Rongwei Liu

Add IPv6 routing extension header definition and no TLV support for now.

At rte_flow layer, there are new items defined for matching type/nexthdr/segments_left field.

Add command line support for IPv6 routing extension header
matching: type/nexthdr/segment_list.

[snip]

Quoted 7 lines
doc/guides/prog_guide/rte_flow.rst +0 -0
index 3e6242803d..ae99036be0 100644
@@ -1544,6 +1544,15 @@ Matches Color Marker set by a Meter.
 
Quoted 8 lines

doc/guides/prog_guide/rte_flow.rst Matches Color Marker set by a Meter. · line 1550

Quoted 6 lines
doc/guides/prog_guide/rte_flow.rst +4 -0
  - ``color``: Metering color marker.
 
+Item: ``IPV6_ROUTING_EXT``
+^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+Matches ipv6 routing extension header.

ipv6 -> IPv6

Sure.

Quoted 8 lines

doc/guides/prog_guide/rte_flow.rst Matches Color Marker set by a Meter. · line 1554

Quoted 5 lines
doc/guides/prog_guide/rte_flow.rst +4 -0
+
+- ``next_hdr``: Next layer header type.
+- ``type``: IPv6 routing extension header type.
+- ``segments_left``: How many IPv6 destination addresses carries on

Why are only 3 fields mentioned above?

This is the 1st phase to matching the 1st uint32 of IPv6 routing extension. No need to match hdr_len since TLV is ignored.

Quoted 13 lines
Quoted 13 lines
doc/guides/prog_guide/rte_flow.rst +1 -0
+
  Actions
  ~~~~~~~
 
doc/guides/rel_notes/release_23_03.rst +0 -0
index b8c5b68d6c..2a794d598e 100644
@@ -55,6 +55,11 @@ New Features
       Also, make sure to start the actual text at the margin.
       =======================================================
 
Quoted 8 lines

doc/guides/rel_notes/release_23_03.rst New Features · line 62

Quoted 5 lines
doc/guides/rel_notes/release_23_03.rst +5 -0
+* **Added rte_flow support for matching IPv6 routing extension header
+fields.**
+
+  Added ``ipv6_routing_ext`` items in rte_flow to match IPv6 routing
+ extension  header

Missing full stop above.

Sure

Quoted 8 lines
Quoted 8 lines
doc/guides/rel_notes/release_23_03.rst +1 -0
+
 
  Removed Items
  -------------
@@ -84,6 +89,11 @@ API Changes
     Also, make sure to start the actual text at the margin.
     =======================================================
 
Quoted 8 lines

doc/guides/rel_notes/release_23_03.rst API Changes · line 96

Quoted 5 lines
doc/guides/rel_notes/release_23_03.rst +5 -0
+* ethdev: added a new structure:
+
+    - IPv6 routing extension header ``rte_flow_item_ipv6_routing_ext`` and
+      ``rte_ipv6_routing_ext``
+

If I'm not mistaken, additions should not be here. It is not an API change.

Checked existing release doc, "ihl" and "version" of IPv4 header is added here but with "net:" prefix. Do you think it' good to follow?

Quoted 11 lines
Quoted 11 lines
doc/guides/rel_notes/release_23_03.rst +0 -0
  ABI Changes
  -----------
lib/ethdev/rte_flow.c index renamed from lib/ethdev/rte_flow.c +0 -0

7d0c24366c..4074b475c8 100644

lib/ethdev/rte_flow.c +0 -0
@@ -76,6 +76,20 @@ rte_flow_item_flex_conv(void *buf, const void *data)
      return src->length;
  }
 
Quoted 12 lines

lib/ethdev/rte_flow.c rte_flow_item_flex_conv(void *buf, const void *data)

Quoted 8 lines
lib/ethdev/rte_flow.c +8 -0
+static size_t
+rte_flow_item_ipv6_routing_ext_conv(void *buf, const void *data) {
+     struct rte_flow_item_ipv6_routing_ext *dst = buf;
+     const struct rte_flow_item_ipv6_routing_ext *src = data;
+     size_t len;
+
+     len = src->hdr.hdr_len ? src->hdr.hdr_len << 3 :
+ src->hdr.segments_left << 4;

Compare hdr_len vs 0 explicitly.
Also I'd add parenthesis around ternary operator values to make it simpler to understand.

Sure.

Quoted 10 lines

lib/ethdev/rte_flow.c rte_flow_item_flex_conv(void *buf, const void *data) · line 87

Quoted 2 lines
lib/ethdev/rte_flow.c +1 -0
+     if (buf)

Please, compare vs NULL explicitly. May be 'dst' would be better here?

lib/ethdev/rte_flow.c rte_flow_item_flex_conv(void *buf, const void *data) · line 92

Quoted 5 lines
lib/ethdev/rte_flow.c +5 -0
+             rte_memcpy((void *)((uintptr_t)(dst->hdr.segments)),
+                        src->hdr.segments, len);
+     return len;
+}
+

Sure.

Quoted 13 lines
Quoted 9 lines
lib/ethdev/rte_flow.c +0 -0
  /** Generate flow_item[] entry. */
  #define MK_FLOW_ITEM(t, s) \
      [RTE_FLOW_ITEM_TYPE_ ## t] = { \ @@ -157,6 +171,8 @@ static

const struct rte_flow_desc_data rte_flow_desc_item[] = {
MK_FLOW_ITEM(L2TPV2, sizeof(struct rte_flow_item_l2tpv2)), MK_FLOW_ITEM(PPP, sizeof(struct rte_flow_item_ppp)), MK_FLOW_ITEM(METER_COLOR, sizeof(struct
rte_flow_item_meter_color)),
+ MK_FLOW_ITEM_FN(IPV6_ROUTING_EXT, sizeof(struct

rte_flow_item_ipv6_routing_ext),

Quoted 3 lines

+ rte_flow_item_ipv6_routing_ext_conv),
};

Quoted 17 lines
Quoted 6 lines

/** Generate flow_action[] entry. */ diff --git
a/lib/ethdev/rte_flow.h b/lib/ethdev/rte_flow.h index b60987db4b..0120d3e7d2 100644

lib/ethdev/rte_flow.h enum rte_flow_item_type { · line 631

Quoted 8 lines
lib/ethdev/rte_flow.h +5 -0
@@ -624,6 +624,13 @@ enum rte_flow_item_type {
       * See struct rte_flow_item_meter_color.
       */
      RTE_FLOW_ITEM_TYPE_METER_COLOR,
+
+     /**
+      * Matches the presence of IPv6 routing extension header.
+      *
+      * See struct rte_flow_item_ipv6_routing_ext.

@see

Sure. Looks like there are so many existing wrong usages "See struct" in this file.

Quoted 9 lines
Quoted 9 lines
lib/ethdev/rte_flow.h +2 -0
+      */
+     RTE_FLOW_ITEM_TYPE_IPV6_ROUTING_EXT,
  };
 
  /**
@@ -873,6 +880,18 @@ struct rte_flow_item_ipv6 {
      uint32_t reserved:23;
  };
 
Quoted 13 lines

lib/ethdev/rte_flow.h struct rte_flow_item_ipv6 { · line 894

Quoted 11 lines
lib/ethdev/rte_flow.h +11 -0
+/**
+ * @warning
+ * @b EXPERIMENTAL: this structure may change without prior notice
+ *
+ * RTE_FLOW_ITEM_TYPE_IPV6_ROUTING_EXT.
+ *
+ * Matches an IPv6 routing extension header.
+ */
+struct rte_flow_item_ipv6_routing_ext {
+     struct rte_ipv6_routing_ext hdr; };
+

What about default mask?

Tried to add default mask declaration in this file but got "unused variable" warning. Moved it to "cmdline_flow.c" since it' only used in testpmd encap logic.

Quoted 12 lines
Quoted 12 lines
lib/ethdev/rte_flow.h +0 -0
  /** Default mask for RTE_FLOW_ITEM_TYPE_IPV6. */
  #ifndef __cplusplus
  static const struct rte_flow_item_ipv6 rte_flow_item_ipv6_mask = {
lib/net/rte_ip.h index renamed from lib/net/rte_ip.h +0 -0

9c8e8206f0..158a2f83ce 100644

lib/net/rte_ip.h +0 -0
@@ -539,6 +539,27 @@ struct rte_ipv6_hdr {
      uint8_t  dst_addr[16];  /**< IP address of destination host(s). */
  } __rte_packed;
 
Quoted 13 lines

lib/net/rte_ip.h struct rte_ipv6_hdr { · line 552

Quoted 11 lines
lib/net/rte_ip.h +11 -0
+/**
+ * IPv6 Routing Extension Header
+ */
+struct rte_ipv6_routing_ext {
+     uint8_t next_hdr;                       /**< Protocol, next header. */
+     uint8_t hdr_len;                        /**< Header length. */
+     uint8_t type;                           /**< Extension header type. */
+     uint8_t segments_left;                  /**< Valid segments number. */
+     __extension__
+     union {
+             uint32_t flags;

rte_be32_t ?

Sure.

Quoted 7 lines

lib/net/rte_ip.h struct rte_ipv6_hdr { · line 556

Quoted 5 lines
lib/net/rte_ip.h +4 -0
+             struct {
+                     uint8_t last_entry;     /**< The last_entry field of SRH */
+                     uint8_t flag;           /**< Packet flag. */
+                     uint16_t tag;           /**< Packet tag. */

rte_be16_t

Sure.

Quoted 7 lines

lib/net/rte_ip.h struct rte_ipv6_hdr { · line 560

Quoted 5 lines
lib/net/rte_ip.h +4 -0
+             };
+     };
+     __extension__
+     uint32_t segments[0];                   /**< Each hop IPv6 address. */

rte_be32_t

Sure.

Quoted 6 lines
Quoted 6 lines
lib/net/rte_ip.h +2 -0
+} __rte_packed;
+
  /* IPv6 vtc_flow: IPv / TC / flow_label */
  #define RTE_IPV6_HDR_FL_SHIFT 0
  #define RTE_IPV6_HDR_TC_SHIFT 20
#8 lore raw

v3 cover add IPv6 routing extension support

In reply to Andrew Rybchenko

Support IPv6 routing extension header matching with new rte_flow item. Add encapsulation support for IPv6 routing extension header.

v3: enhance the format and use be32/be16 in network header structure.
v2: remove redundant rte_flow items. include the commit from Gregory
to pass the compilation.

Gregory Etelson (1):
net/mlx5/hws: Definer, add mlx5dr context to definer_conv_data

Rongwei Liu (7):
ethdev: add IPv6 routing extension header definition net/mlx5: adopt IPv6 routing extension prm definition net/mlx5/hws: add IPv6 routing extension matching support app/testpmd: add IPv6 routing extension header in raw encap
ethdev: add modify IPv6 protocol field net/mlx5/hws: add modify IPv6 protocol implementation doc/mlx5: add IPv6 routing extension matching docs

 app/test-pmd/cmdline_flow.c            |  72 ++++++++++++-
 doc/guides/nics/features/default.ini   |   1 +
 doc/guides/nics/features/mlx5.ini      |   1 +
 doc/guides/nics/mlx5.rst               |   2 +
 doc/guides/prog_guide/rte_flow.rst     |   9 ++
 doc/guides/rel_notes/release_23_03.rst |   9 ++
 drivers/common/mlx5/mlx5_devx_cmds.c   |  17 +++-
 drivers/common/mlx5/mlx5_devx_cmds.h   |   7 +-
 drivers/common/mlx5/mlx5_prm.h         |  29 +++++-
 drivers/net/mlx5/hws/mlx5dr_definer.c  | 133 +++++++++++++++++++++----
 drivers/net/mlx5/hws/mlx5dr_definer.h  |  15 +++
 drivers/net/mlx5/mlx5.c                | 103 ++++++++++++++++++-
 drivers/net/mlx5/mlx5.h                |  19 +++-
 drivers/net/mlx5/mlx5_flow.h           |  28 ++++++
 drivers/net/mlx5/mlx5_flow_dv.c        |  10 ++
 drivers/net/mlx5/mlx5_flow_flex.c      |  14 ++-
 drivers/net/mlx5/mlx5_flow_hw.c        |  29 +++++-
 lib/ethdev/rte_flow.c                  |  19 ++++
 lib/ethdev/rte_flow.h                  |  20 ++++
 lib/net/rte_ip.h                       |  21 ++++
 20 files changed, 517 insertions(+), 41 deletions(-)
Signature · 1 line
2.27.0
#9 lore raw

PATCH v3 1/8 ethdev: add IPv6 routing extension header definition

Add IPv6 routing extension header definition and no TLV support for now.

At rte_flow layer, there are new items defined for matching type/nexthdr/segments_left field.

Add command line support for IPv6 routing extension header
matching: type/nexthdr/segment_list.

---
 app/test-pmd/cmdline_flow.c            | 46 ++++++++++++++++++++++++++
 doc/guides/prog_guide/rte_flow.rst     |  9 +++++
 doc/guides/rel_notes/release_23_03.rst |  9 +++++
 lib/ethdev/rte_flow.c                  | 19 +++++++++++
 lib/ethdev/rte_flow.h                  | 19 +++++++++++
 lib/net/rte_ip.h                       | 21 ++++++++++++
 6 files changed, 123 insertions(+)
app/test-pmd/cmdline_flow.c +46 -0
index 88108498e0..7a8516829c 100644
@@ -298,6 +298,10 @@ enum index {
 	ITEM_IPV6_SRC,
 	ITEM_IPV6_DST,
 	ITEM_IPV6_HAS_FRAG_EXT,
+	ITEM_IPV6_ROUTING_EXT,
+	ITEM_IPV6_ROUTING_EXT_TYPE,
+	ITEM_IPV6_ROUTING_EXT_NEXT_HDR,
+	ITEM_IPV6_ROUTING_EXT_SEG_LEFT,
 	ITEM_ICMP,
 	ITEM_ICMP_TYPE,
 	ITEM_ICMP_CODE,
@@ -1326,6 +1330,7 @@ static const enum index next_item[] = {
 	ITEM_ARP_ETH_IPV4,
 	ITEM_IPV6_EXT,
 	ITEM_IPV6_FRAG_EXT,
+	ITEM_IPV6_ROUTING_EXT,
 	ITEM_ICMP6,
 	ITEM_ICMP6_ND_NS,
 	ITEM_ICMP6_ND_NA,
@@ -1435,6 +1440,15 @@ static const enum index item_ipv6[] = {
 	ITEM_IPV6_SRC,
 	ITEM_IPV6_DST,
 	ITEM_IPV6_HAS_FRAG_EXT,
+	ITEM_IPV6_ROUTING_EXT,
+	ITEM_NEXT,
+	ZERO,
+};
+
+static const enum index item_ipv6_routing_ext[] = {
+	ITEM_IPV6_ROUTING_EXT_TYPE,
+	ITEM_IPV6_ROUTING_EXT_NEXT_HDR,
+	ITEM_IPV6_ROUTING_EXT_SEG_LEFT,
 	ITEM_NEXT,
 	ZERO,
 };
@@ -3844,6 +3858,38 @@ static const struct token token_list[] = {
 		.args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_ipv6,
 					   has_frag_ext, 1)),
 	},
+	[ITEM_IPV6_ROUTING_EXT] = {
+		.name = "ipv6_routing_ext",
+		.help = "match IPv6 routing extension header",
+		.priv = PRIV_ITEM(IPV6_ROUTING_EXT,
+				  sizeof(struct rte_flow_item_ipv6_routing_ext)),
+		.next = NEXT(item_ipv6_routing_ext),
+		.call = parse_vc,
+	},
+	[ITEM_IPV6_ROUTING_EXT_TYPE] = {
+		.name = "ext_type",
+		.help = "match IPv6 routing extension header type",
+		.next = NEXT(item_ipv6_routing_ext, NEXT_ENTRY(COMMON_UNSIGNED),
+			     item_param),
+		.args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6_routing_ext,
+					     hdr.type)),
+	},
+	[ITEM_IPV6_ROUTING_EXT_NEXT_HDR] = {
+		.name = "ext_next_hdr",
+		.help = "match IPv6 routing extension header next header type",
+		.next = NEXT(item_ipv6_routing_ext, NEXT_ENTRY(COMMON_UNSIGNED),
+			     item_param),
+		.args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6_routing_ext,
+					     hdr.next_hdr)),
+	},
+	[ITEM_IPV6_ROUTING_EXT_SEG_LEFT] = {
+		.name = "ext_seg_left",
+		.help = "match IPv6 routing extension header segment left",
+		.next = NEXT(item_ipv6_routing_ext, NEXT_ENTRY(COMMON_UNSIGNED),
+			     item_param),
+		.args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6_routing_ext,
+					     hdr.segments_left)),
+	},
 	[ITEM_ICMP] = {
 		.name = "icmp",
 		.help = "match ICMP header",
doc/guides/prog_guide/rte_flow.rst +9 -0
index 3e6242803d..602fab29d3 100644
@@ -1544,6 +1544,15 @@ Matches Color Marker set by a Meter.
 
 - ``color``: Metering color marker.
 
+Item: ``IPV6_ROUTING_EXT``
+^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+Matches IPv6 routing extension header.
+
+- ``next_hdr``: Next layer header type.
+- ``type``: IPv6 routing extension header type.
+- ``segments_left``: How many IPv6 destination addresses carries on.
+
 Actions
 ~~~~~~~
 
doc/guides/rel_notes/release_23_03.rst +9 -0
index b8c5b68d6c..8f482301f7 100644
@@ -55,6 +55,11 @@ New Features
      Also, make sure to start the actual text at the margin.
      =======================================================
 
+* **Added rte_flow support for matching IPv6 routing extension header fields.**
+
+  Added ``ipv6_routing_ext`` items in rte_flow to match IPv6 routing extension
+  header.
+
 
 Removed Items
 -------------
@@ -84,6 +89,10 @@ API Changes
    Also, make sure to start the actual text at the margin.
    =======================================================
 
+* net: added a new structure:
+
+    - IPv6 routing extension header ``rte_ipv6_routing_ext``.
+
 
 ABI Changes
 -----------
lib/ethdev/rte_flow.c +19 -0
index 7d0c24366c..5c423db160 100644
@@ -76,6 +76,23 @@ rte_flow_item_flex_conv(void *buf, const void *data)
 	return src->length;
 }
 
+static size_t
+rte_flow_item_ipv6_routing_ext_conv(void *buf, const void *data)
+{
+	struct rte_flow_item_ipv6_routing_ext *dst = buf;
+	const struct rte_flow_item_ipv6_routing_ext *src = data;
+	size_t len;
+
+	if (src->hdr.hdr_len)
+		len = src->hdr.hdr_len << 3;
+	else
+		len = src->hdr.segments_left << 4;
+	if (dst == NULL)
+		return 0;
+	rte_memcpy((void *)((uintptr_t)(dst->hdr.segments)), src->hdr.segments, len);
+	return len;
+}
+
 /** Generate flow_item[] entry. */
 #define MK_FLOW_ITEM(t, s) \
 	[RTE_FLOW_ITEM_TYPE_ ## t] = { \
@@ -157,6 +174,8 @@ static const struct rte_flow_desc_data rte_flow_desc_item[] = {
 	MK_FLOW_ITEM(L2TPV2, sizeof(struct rte_flow_item_l2tpv2)),
 	MK_FLOW_ITEM(PPP, sizeof(struct rte_flow_item_ppp)),
 	MK_FLOW_ITEM(METER_COLOR, sizeof(struct rte_flow_item_meter_color)),
+	MK_FLOW_ITEM_FN(IPV6_ROUTING_EXT, sizeof(struct rte_flow_item_ipv6_routing_ext),
+			rte_flow_item_ipv6_routing_ext_conv),
 };
 
 /** Generate flow_action[] entry. */
lib/ethdev/rte_flow.h +19 -0
index b60987db4b..9b9018cba2 100644
@@ -624,6 +624,13 @@ enum rte_flow_item_type {
 	 * See struct rte_flow_item_meter_color.
 	 */
 	RTE_FLOW_ITEM_TYPE_METER_COLOR,
+
+	/**
+	 * Matches the presence of IPv6 routing extension header.
+	 *
+	 * @see struct rte_flow_item_ipv6_routing_ext.
+	 */
+	RTE_FLOW_ITEM_TYPE_IPV6_ROUTING_EXT,
 };
 
 /**
@@ -873,6 +880,18 @@ struct rte_flow_item_ipv6 {
 	uint32_t reserved:23;
 };
 
+/**
+ * @warning
+ * @b EXPERIMENTAL: this structure may change without prior notice
+ *
+ * RTE_FLOW_ITEM_TYPE_IPV6_ROUTING_EXT.
+ *
+ * Matches an IPv6 routing extension header.
+ */
+struct rte_flow_item_ipv6_routing_ext {
+	struct rte_ipv6_routing_ext hdr;
+};
+
 /** Default mask for RTE_FLOW_ITEM_TYPE_IPV6. */
 #ifndef __cplusplus
 static const struct rte_flow_item_ipv6 rte_flow_item_ipv6_mask = {
lib/net/rte_ip.h +21 -0
index 9c8e8206f0..56c151372a 100644
@@ -539,6 +539,27 @@ struct rte_ipv6_hdr {
 	uint8_t  dst_addr[16];	/**< IP address of destination host(s). */
 } __rte_packed;
 
+/**
+ * IPv6 Routing Extension Header
+ */
+struct rte_ipv6_routing_ext {
+	uint8_t next_hdr;			/**< Protocol, next header. */
+	uint8_t hdr_len;			/**< Header length. */
+	uint8_t type;				/**< Extension header type. */
+	uint8_t segments_left;			/**< Valid segments number. */
+	__extension__
+	union {
+		rte_be32_t flags;
+		struct {
+			uint8_t last_entry;	/**< The last_entry field of SRH */
+			uint8_t flag;		/**< Packet flag. */
+			rte_be16_t tag;		/**< Packet tag. */
+		};
+	};
+	__extension__
+	rte_be32_t segments[0];			/**< Each hop IPv6 address. */
+} __rte_packed;
+
 /* IPv6 vtc_flow: IPv / TC / flow_label */
 #define RTE_IPV6_HDR_FL_SHIFT 0
 #define RTE_IPV6_HDR_TC_SHIFT 20
Signature · 1 line
2.27.0
#10 lore raw

Re: [PATCH v3 1/8] ethdev: add IPv6 routing extension header definition

Quoted 10 lines · On Mon, 30 Jan 2023 05:59:33 +0200 Rongwei Liu <[email protected]> wrote:
lib/net/rte_ip.h +9 -0
+/**
+ * IPv6 Routing Extension Header
+ */
+struct rte_ipv6_routing_ext {
+	uint8_t next_hdr;			/**< Protocol, next header. */
+	uint8_t hdr_len;			/**< Header length. */
+	uint8_t type;				/**< Extension header type. */
+	uint8_t segments_left;			/**< Valid segments number. */
+	__extension__

lib/net/rte_ip.h struct rte_ipv6_hdr { · line 560

Quoted 10 lines
lib/net/rte_ip.h +10 -0
+	union {
+		rte_be32_t flags;
+		struct {
+			uint8_t last_entry;	/**< The last_entry field of SRH */
+			uint8_t flag;		/**< Packet flag. */
+			rte_be16_t tag;		/**< Packet tag. */
+		};
+	};
+	__extension__
+	rte_be32_t segments[0];			/**< Each hop IPv6 address. */

Use flex array rather than zero size.
Zero size arrays cause warnings with later compilers.

#11 lore raw

RE: [PATCH v3 1/8] ethdev: add IPv6 routing extension header definition

HI Stephen:

BR
Rongwei

Quoted 35 lines

-----Original Message-----
From: Stephen Hemminger <[email protected]>
Sent: Tuesday, January 31, 2023 00:48
To: Rongwei Liu <[email protected]>
Cc: Matan Azrad <[email protected]>; Slava Ovsiienko <[email protected]>; Ori Kam <[email protected]>; NBU-Contact- Thomas Monjalon (EXTERNAL) <[email protected]>; Aman Singh <[email protected]>; Yuying Zhang <[email protected]>; Ferruh Yigit <[email protected]>; Andrew Rybchenko <[email protected]>; Olivier Matz <[email protected]>; [email protected]; Raslan Darawsheh <[email protected]>
Subject: Re: [PATCH v3 1/8] ethdev: add IPv6 routing extension header definition

External email: Use caution opening links or attachments

Quoted 15 lines · On Mon, 30 Jan 2023 05:59:33 +0200 Rongwei Liu <[email protected]> wrote:
lib/net/rte_ip.h +14 -0
+/**
+ * IPv6 Routing Extension Header
+ */
+struct rte_ipv6_routing_ext {
+     uint8_t next_hdr;                       /**< Protocol, next header. */
+     uint8_t hdr_len;                        /**< Header length. */
+     uint8_t type;                           /**< Extension header type. */
+     uint8_t segments_left;                  /**< Valid segments number. */
+     __extension__
+     union {
+             rte_be32_t flags;
+             struct {
+                     uint8_t last_entry;     /**< The last_entry field of SRH */
+                     uint8_t flag;           /**< Packet flag. */
Quoted 8 lines

lib/net/rte_ip.h struct rte_ipv6_hdr { · line 560

Quoted 5 lines
lib/net/rte_ip.h +5 -0
+                     rte_be16_t tag;         /**< Packet tag. */
+             };
+     };
+     __extension__
+     rte_be32_t segments[0];                 /**< Each hop IPv6 address. */

Use flex array rather than zero size.
Zero size arrays cause warnings with later compilers.

Sure. Thanks.

#12 lore raw

RE: [PATCH v3 1/8] ethdev: add IPv6 routing extension header definition

In reply to Stephen Hemminger

HI Stephen

BR
Rongwei

Quoted 35 lines

-----Original Message-----
From: Stephen Hemminger <[email protected]>
Sent: Tuesday, January 31, 2023 00:48
To: Rongwei Liu <[email protected]>
Cc: Matan Azrad <[email protected]>; Slava Ovsiienko <[email protected]>; Ori Kam <[email protected]>; NBU-Contact- Thomas Monjalon (EXTERNAL) <[email protected]>; Aman Singh <[email protected]>; Yuying Zhang <[email protected]>; Ferruh Yigit <[email protected]>; Andrew Rybchenko <[email protected]>; Olivier Matz <[email protected]>; [email protected]; Raslan Darawsheh <[email protected]>
Subject: Re: [PATCH v3 1/8] ethdev: add IPv6 routing extension header definition

External email: Use caution opening links or attachments

Quoted 15 lines · On Mon, 30 Jan 2023 05:59:33 +0200 Rongwei Liu <[email protected]> wrote:
lib/net/rte_ip.h +14 -0
+/**
+ * IPv6 Routing Extension Header
+ */
+struct rte_ipv6_routing_ext {
+     uint8_t next_hdr;                       /**< Protocol, next header. */
+     uint8_t hdr_len;                        /**< Header length. */
+     uint8_t type;                           /**< Extension header type. */
+     uint8_t segments_left;                  /**< Valid segments number. */
+     __extension__
+     union {
+             rte_be32_t flags;
+             struct {
+                     uint8_t last_entry;     /**< The last_entry field of SRH */
+                     uint8_t flag;           /**< Packet flag. */
Quoted 8 lines

lib/net/rte_ip.h struct rte_ipv6_hdr { · line 560

Quoted 5 lines
lib/net/rte_ip.h +5 -0
+                     rte_be16_t tag;         /**< Packet tag. */
+             };
+     };
+     __extension__
+     rte_be32_t segments[0];                 /**< Each hop IPv6 address. */

Use flex array rather than zero size.
Zero size arrays cause warnings with later compilers.

Using flex array helps improve this network header definition but caused warning in the rte_flow_item_**

struct rte_flow_item_ipv6_routing_ext {
       struct rte_ipv6_routing_ext hdr;                                                                                                                                                                                                                    
}; 

"invalid use of structure with flexible array member [-Werror=pedantic]"

#13 lore raw

Re: [PATCH v3 1/8] ethdev: add IPv6 routing extension header definition

Quoted 48 lines · On Tue, 31 Jan 2023 02:27:56 +0000 Rongwei Liu <[email protected]> wrote:

HI Stephen

BR
Rongwei

Quoted 35 lines

-----Original Message-----
From: Stephen Hemminger <[email protected]>
Sent: Tuesday, January 31, 2023 00:48
To: Rongwei Liu <[email protected]>
Cc: Matan Azrad <[email protected]>; Slava Ovsiienko <[email protected]>; Ori Kam <[email protected]>; NBU-Contact- Thomas Monjalon (EXTERNAL) <[email protected]>; Aman Singh <[email protected]>; Yuying Zhang <[email protected]>; Ferruh Yigit <[email protected]>; Andrew Rybchenko <[email protected]>; Olivier Matz <[email protected]>; [email protected]; Raslan Darawsheh <[email protected]>
Subject: Re: [PATCH v3 1/8] ethdev: add IPv6 routing extension header definition

External email: Use caution opening links or attachments

Quoted 15 lines · On Mon, 30 Jan 2023 05:59:33 +0200 Rongwei Liu <[email protected]> wrote:
lib/net/rte_ip.h +14 -0
+/**
+ * IPv6 Routing Extension Header
+ */
+struct rte_ipv6_routing_ext {
+     uint8_t next_hdr;                       /**< Protocol, next header. */
+     uint8_t hdr_len;                        /**< Header length. */
+     uint8_t type;                           /**< Extension header type. */
+     uint8_t segments_left;                  /**< Valid segments number. */
+     __extension__
+     union {
+             rte_be32_t flags;
+             struct {
+                     uint8_t last_entry;     /**< The last_entry field of SRH */
+                     uint8_t flag;           /**< Packet flag. */
Quoted 8 lines

lib/net/rte_ip.h struct rte_ipv6_hdr { · line 560

Quoted 5 lines
lib/net/rte_ip.h +5 -0
+                     rte_be16_t tag;         /**< Packet tag. */
+             };
+     };
+     __extension__
+     rte_be32_t segments[0];                 /**< Each hop IPv6 address. */  

Use flex array rather than zero size.
Zero size arrays cause warnings with later compilers.

Quoted 5 lines

Using flex array helps improve this network header definition but caused warning in the rte_flow_item_**

struct rte_flow_item_ipv6_routing_ext {
       struct rte_ipv6_routing_ext hdr;                                                                                                                                                                                                                    
}; 

"invalid use of structure with flexible array member [-Werror=pedantic]"

Not sure, only Nvidia/Mellanox messes with pedantic

#14 lore raw

RE: [PATCH v3 1/8] ethdev: add IPv6 routing extension header definition

HI Stephen

BR
Rongwei

Quoted 69 lines

-----Original Message-----
From: Stephen Hemminger <[email protected]>
Sent: Tuesday, January 31, 2023 10:56
To: Rongwei Liu <[email protected]>
Cc: Matan Azrad <[email protected]>; Slava Ovsiienko <[email protected]>; Ori Kam <[email protected]>; NBU-Contact- Thomas Monjalon (EXTERNAL) <[email protected]>; Aman Singh <[email protected]>; Yuying Zhang <[email protected]>; Ferruh Yigit <[email protected]>; Andrew Rybchenko <[email protected]>; Olivier Matz <[email protected]>; [email protected]; Raslan Darawsheh <[email protected]>
Subject: Re: [PATCH v3 1/8] ethdev: add IPv6 routing extension header definition

External email: Use caution opening links or attachments

Quoted 49 lines · On Tue, 31 Jan 2023 02:27:56 +0000 Rongwei Liu <[email protected]> wrote:

HI Stephen

BR
Rongwei

Quoted 44 lines

-----Original Message-----
From: Stephen Hemminger <[email protected]>
Sent: Tuesday, January 31, 2023 00:48
To: Rongwei Liu <[email protected]>
Cc: Matan Azrad <[email protected]>; Slava Ovsiienko <[email protected]>; Ori Kam <[email protected]>; NBU-Contact- Thomas Monjalon (EXTERNAL) <[email protected]>; Aman Singh <[email protected]>; Yuying Zhang <[email protected]>; Ferruh Yigit <[email protected]>; Andrew Rybchenko <[email protected]>; Olivier Matz <[email protected]>; [email protected]; Raslan Darawsheh <[email protected]>
Subject: Re: [PATCH v3 1/8] ethdev: add IPv6 routing extension header definition

External email: Use caution opening links or attachments

Quoted 10 lines · On Mon, 30 Jan 2023 05:59:33 +0200 Rongwei Liu <[email protected]> wrote:
lib/net/rte_ip.h +9 -0
+/**
+ * IPv6 Routing Extension Header
+ */
+struct rte_ipv6_routing_ext {
+     uint8_t next_hdr;                       /**< Protocol, next header. */
+     uint8_t hdr_len;                        /**< Header length. */
+     uint8_t type;                           /**< Extension header type. */
+     uint8_t segments_left;                  /**< Valid segments number. */
+     __extension__

lib/net/rte_ip.h struct rte_ipv6_hdr { · line 560

Quoted 10 lines
lib/net/rte_ip.h +10 -0
+     union {
+             rte_be32_t flags;
+             struct {
+                     uint8_t last_entry;     /**< The last_entry field of SRH */
+                     uint8_t flag;           /**< Packet flag. */
+                     rte_be16_t tag;         /**< Packet tag. */
+             };
+     };
+     __extension__
+     rte_be32_t segments[0];                 /**< Each hop IPv6 address. */

Use flex array rather than zero size.
Zero size arrays cause warnings with later compilers.

Quoted 7 lines
Quoted 2 lines

Using flex array helps improve this network header definition but caused warning in the rte_flow_item_** struct

rte_flow_item_ipv6_routing_ext {

Quoted 2 lines

struct rte_ipv6_routing_ext hdr; }; "invalid use of structure
with flexible array member [-Werror=pedantic]"

Not sure, only Nvidia/Mellanox messes with pedantic

This is caused by failsafe driver.
In file included from ../drivers/net/failsafe/failsafe_ether.c:8:
../lib/ethdev/rte_flow.h:892:44: error: invalid use of structure with flexible array member [-Werror=pedantic]

  __extension__ struct rte_ipv6_routing_ext hdr;
                                            ^~~
#15 lore raw

Re: [PATCH v3 1/8] ethdev: add IPv6 routing extension header definition

In reply to Rongwei Liu
Quoted 6 lines · On Mon, 30 Jan 2023 05:59:33 +0200 Rongwei Liu <[email protected]> wrote:
lib/ethdev/rte_flow.c +5 -0
+static size_t
+rte_flow_item_ipv6_routing_ext_conv(void *buf, const void *data)
 
+{
+	struct rte_flow_item_ipv6_routing_ext *dst = buf;
+	const struct rte_flow_item_ipv6_routing_ext *src = data;

lib/ethdev/rte_flow.c rte_flow_item_flex_conv(void *buf, const void *data) · line 93

Quoted 10 lines
lib/ethdev/rte_flow.c +10 -0
+	size_t len;
+
+	if (src->hdr.hdr_len)
+		len = src->hdr.hdr_len << 3;
+	else
+		len = src->hdr.segments_left << 4;
+	if (dst == NULL)
+		return 0;
+	rte_memcpy((void *)((uintptr_t)(dst->hdr.segments)), src->hdr.segments, len);
+	return len;

Why use rte_memcpy for such a small size? Please just use normal memcpy which will cause more compiler and static scan checking.

That cast is unnecessary in C because "segments" is an array and any valid pointer type can be passed as void *.

#16 lore raw

RE: [PATCH v3 1/8] ethdev: add IPv6 routing extension header definition

HI Stephen:

BR
Rongwei

Quoted 36 lines

-----Original Message-----
From: Stephen Hemminger <[email protected]>
Sent: Tuesday, January 31, 2023 00:50
To: Rongwei Liu <[email protected]>
Cc: Matan Azrad <[email protected]>; Slava Ovsiienko <[email protected]>; Ori Kam <[email protected]>; NBU-Contact- Thomas Monjalon (EXTERNAL) <[email protected]>; Aman Singh <[email protected]>; Yuying Zhang <[email protected]>; Ferruh Yigit <[email protected]>; Andrew Rybchenko <[email protected]>; Olivier Matz <[email protected]>; [email protected]; Raslan Darawsheh <[email protected]>
Subject: Re: [PATCH v3 1/8] ethdev: add IPv6 routing extension header definition

External email: Use caution opening links or attachments

Quoted 5 lines · On Mon, 30 Jan 2023 05:59:33 +0200 Rongwei Liu <[email protected]> wrote:
lib/ethdev/rte_flow.c +4 -0
+static size_t
+rte_flow_item_ipv6_routing_ext_conv(void *buf, const void *data)
 
+{
+     struct rte_flow_item_ipv6_routing_ext *dst = buf;

lib/ethdev/rte_flow.c rte_flow_item_flex_conv(void *buf, const void *data)

Quoted 10 lines
lib/ethdev/rte_flow.c +10 -0
+     const struct rte_flow_item_ipv6_routing_ext *src = data;
+     size_t len;
+
+     if (src->hdr.hdr_len)
+             len = src->hdr.hdr_len << 3;
+     else
+             len = src->hdr.segments_left << 4;
+     if (dst == NULL)
+             return 0;
+     rte_memcpy((void *)((uintptr_t)(dst->hdr.segments)), src->hdr.segments,

len);

Quoted 5 lines
Quoted 1 line

+ return len;

Why use rte_memcpy for such a small size? Please just use normal memcpy which will cause more compiler and static scan checking.

Following existing routine, rte_flow_item_***_conv(). Change to memcpy() in the next version

Quoted 2 lines

That cast is unnecessary in C because "segments" is an array and any valid pointer type can be passed as void *.

Sure

#17 lore raw

Re: [PATCH v3 1/8] ethdev: add IPv6 routing extension header definition

In reply to Rongwei Liu

lib/ethdev/rte_flow.h struct rte_flow_item_ipv6 { · line 893

Quoted 11 lines · On Mon, 30 Jan 2023 05:59:33 +0200 Rongwei Liu <[email protected]> wrote:
lib/ethdev/rte_flow.h +11 -0
+/**
+ * @warning
+ * @b EXPERIMENTAL: this structure may change without prior notice
+ *
+ * RTE_FLOW_ITEM_TYPE_IPV6_ROUTING_EXT.
+ *
+ * Matches an IPv6 routing extension header.
+ */
+struct rte_flow_item_ipv6_routing_ext {
+	struct rte_ipv6_routing_ext hdr;
+};

The problem with nesting a variable length structure inside another structure is not allowed.

The issue is that the applicaiton would have to pass a variable length structure in for the flow definition. The flow item is variable length for this type? all the others are fixed length.

One option would be to get rid of the wrapper structure.

#18 lore raw

RE: [PATCH v3 1/8] ethdev: add IPv6 routing extension header definition

Hi Stephen

BR
Rongwei

Quoted 34 lines

-----Original Message-----
From: Stephen Hemminger <[email protected]>
Sent: Tuesday, January 31, 2023 11:02
To: Rongwei Liu <[email protected]>
Cc: Matan Azrad <[email protected]>; Slava Ovsiienko <[email protected]>; Ori Kam <[email protected]>; NBU-Contact- Thomas Monjalon (EXTERNAL) <[email protected]>; Aman Singh <[email protected]>; Yuying Zhang <[email protected]>; Ferruh Yigit <[email protected]>; Andrew Rybchenko <[email protected]>; Olivier Matz <[email protected]>; [email protected]; Raslan Darawsheh <[email protected]>
Subject: Re: [PATCH v3 1/8] ethdev: add IPv6 routing extension header definition

External email: Use caution opening links or attachments

lib/ethdev/rte_flow.h struct rte_flow_item_ipv6 {

Quoted 10 lines · On Mon, 30 Jan 2023 05:59:33 +0200 Rongwei Liu <[email protected]> wrote:
lib/ethdev/rte_flow.h +10 -0
+/**
+ * @warning
+ * @b EXPERIMENTAL: this structure may change without prior notice
+ *
+ * RTE_FLOW_ITEM_TYPE_IPV6_ROUTING_EXT.
+ *
+ * Matches an IPv6 routing extension header.
+ */
+struct rte_flow_item_ipv6_routing_ext {
+     struct rte_ipv6_routing_ext hdr; };

The problem with nesting a variable length structure inside another structure is not allowed.

Quoted 4 lines

The issue is that the applicaiton would have to pass a variable length structure in for the flow definition. The flow item is variable length for this type? all the others are fixed length.

Yeah, segments_left is uint8 per definition. RFC doesn't set an upper limitation. It stands for intermediate routing nodes between src and dst nodes.

Quoted 1 line

One option would be to get rid of the wrapper structure.

Yeah, it works. @Andrew Rybchenko Can you share your preference here?

#19 lore raw

RE: [PATCH v3 1/8] ethdev: add IPv6 routing extension header definition

HI Stephen:

BR
Rongwei

Quoted 55 lines

-----Original Message-----
From: Rongwei Liu
Sent: Tuesday, January 31, 2023 11:25
To: Stephen Hemminger <[email protected]>; Andrew Rybchenko <[email protected]>
Cc: Matan Azrad <[email protected]>; Slava Ovsiienko <[email protected]>; Ori Kam <[email protected]>; NBU-Contact- Thomas Monjalon (EXTERNAL) <[email protected]>; Aman Singh <[email protected]>; Yuying Zhang <[email protected]>; Ferruh Yigit <[email protected]>; Olivier Matz <[email protected]>; [email protected]; Raslan Darawsheh <[email protected]>
Subject: RE: [PATCH v3 1/8] ethdev: add IPv6 routing extension header definition

Hi Stephen

BR
Rongwei

Quoted 35 lines

-----Original Message-----
From: Stephen Hemminger <[email protected]>
Sent: Tuesday, January 31, 2023 11:02
To: Rongwei Liu <[email protected]>
Cc: Matan Azrad <[email protected]>; Slava Ovsiienko <[email protected]>; Ori Kam <[email protected]>; NBU-Contact- Thomas Monjalon (EXTERNAL) <[email protected]>; Aman Singh <[email protected]>; Yuying Zhang <[email protected]>; Ferruh Yigit <[email protected]>; Andrew Rybchenko <[email protected]>; Olivier Matz <[email protected]>; [email protected]; Raslan Darawsheh <[email protected]>
Subject: Re: [PATCH v3 1/8] ethdev: add IPv6 routing extension header definition

External email: Use caution opening links or attachments

lib/ethdev/rte_flow.h struct rte_flow_item_ipv6 {

Quoted 10 lines · On Mon, 30 Jan 2023 05:59:33 +0200 Rongwei Liu <[email protected]> wrote:
lib/ethdev/rte_flow.h +10 -0
+/**
+ * @warning
+ * @b EXPERIMENTAL: this structure may change without prior notice
+ *
+ * RTE_FLOW_ITEM_TYPE_IPV6_ROUTING_EXT.
+ *
+ * Matches an IPv6 routing extension header.
+ */
+struct rte_flow_item_ipv6_routing_ext {
+     struct rte_ipv6_routing_ext hdr; };

The problem with nesting a variable length structure inside another structure is not allowed.

Quoted 8 lines
Quoted 4 lines

The issue is that the applicaiton would have to pass a variable length structure in for the flow definition. The flow item is variable length for this type? all the others are fixed length.

Yeah, segments_left is uint8 per definition. RFC doesn't set an upper limitation. It stands for intermediate routing nodes between src and dst nodes.

Quoted 1 line

One option would be to get rid of the wrapper structure.

Yeah, it works. @Andrew Rybchenko Can you share your preference here?

I want to propose "moving flex array" out of the "struct rte_ipv6_routing_ext " and present in " struct rte_flow_item_ipv6_routing_ext" Sounds good?

#20 lore raw

Re: [PATCH v3 1/8] ethdev: add IPv6 routing extension header definition

31/01/2023 10:18, Rongwei Liu:

Quoted 22 lines

From: Rongwei Liu

Quoted 21 lines

From: Stephen Hemminger <[email protected]>

Quoted 20 lines

lib/ethdev/rte_flow.h struct rte_flow_item_ipv6 {

Quoted 10 lines · Rongwei Liu
lib/ethdev/rte_flow.h +10 -0
+/**
+ * @warning
+ * @b EXPERIMENTAL: this structure may change without prior notice
+ *
+ * RTE_FLOW_ITEM_TYPE_IPV6_ROUTING_EXT.
+ *
+ * Matches an IPv6 routing extension header.
+ */
+struct rte_flow_item_ipv6_routing_ext {
+     struct rte_ipv6_routing_ext hdr; };

The problem with nesting a variable length structure inside another structure is not allowed.

The issue is that the applicaiton would have to pass a variable length structure in for the flow definition. The flow item is variable length for this type? all the others are fixed length.

Quoted 6 lines
Quoted 4 lines

Yeah, segments_left is uint8 per definition. RFC doesn't set an upper limitation. It stands for intermediate routing nodes between src and dst nodes.

Quoted 1 line

One option would be to get rid of the wrapper structure.

Yeah, it works. @Andrew Rybchenko Can you share your preference here?

I want to propose "moving flex array" out of the "struct rte_ipv6_routing_ext " and present in " struct rte_flow_item_ipv6_routing_ext" Sounds good?

For Geneve, we have defined a separate flow item: rte_flow_item_geneve_opt. I'm OK to move the optional fields in the flow item.
This is what you did in v4.

#21 lore raw

RE: [PATCH v3 1/8] ethdev: add IPv6 routing extension header definition

Quoted 38 lines

-----Original Message-----
From: Thomas Monjalon <[email protected]>
Sent: Tuesday, 31 January 2023 11:43
Subject: Re: [PATCH v3 1/8] ethdev: add IPv6 routing extension header definition

31/01/2023 10:18, Rongwei Liu:

Quoted 23 lines

From: Rongwei Liu

Quoted 22 lines

From: Stephen Hemminger <[email protected]>

Quoted 16 lines

lib/ethdev/rte_flow.h struct rte_flow_item_ipv6 {

Quoted 10 lines · Rongwei Liu
lib/ethdev/rte_flow.h +10 -0
+/**
+ * @warning
+ * @b EXPERIMENTAL: this structure may change without prior notice
+ *
+ * RTE_FLOW_ITEM_TYPE_IPV6_ROUTING_EXT.
+ *
+ * Matches an IPv6 routing extension header.
+ */
+struct rte_flow_item_ipv6_routing_ext {
+     struct rte_ipv6_routing_ext hdr; };

The problem with nesting a variable length structure inside another structure is not allowed.

Quoted 4 lines

The issue is that the applicaiton would have to pass a variable length structure in for the flow definition. The flow item is variable length for this type? all the others are fixed length.

Yeah, segments_left is uint8 per definition. RFC doesn't set an upper

limitation.

Quoted 3 lines
Quoted 3 lines

It stands for intermediate routing nodes between src and dst nodes.

Quoted 1 line

One option would be to get rid of the wrapper structure.

Yeah, it works. @Andrew Rybchenko Can you share your preference

here?

Quoted 1 line

I want to propose "moving flex array" out of the "struct

Quoted 9 lines

rte_ipv6_routing_ext " and present in " struct rte_flow_item_ipv6_routing_ext"

Quoted 1 line

Sounds good?

For Geneve, we have defined a separate flow item:
rte_flow_item_geneve_opt.
I'm OK to move the optional fields in the flow item. This is what you did in v4.

I also think we should just drop the rte_be32_t segments[0]; /**< Each hop IPv6 address. */
In any case application must allocate the correct size so maybe we can just remove it.

Best,
Ori

Quoted 3 lines
#22 lore raw

v4 cover add IPv6 routing extension support

In reply to Stephen Hemminger

Support IPv6 routing extension header matching with new rte_flow item. Add encapsulation support for IPv6 routing extension header.

v4: use flex array to define variable length segments and move PMD
implementation out.
v3: enhance the format and use be32/be16 in network header structure.
v2: remove redundant rte_flow items.

Rongwei Liu (3):
ethdev: add IPv6 routing extension header definition
ethdev: add modify IPv6 protocol field app/testpmd: add IPv6 routing extension header in raw encap

 app/test-pmd/cmdline_flow.c            | 72 +++++++++++++++++++++++++-
 doc/guides/prog_guide/rte_flow.rst     |  9 ++++
 doc/guides/rel_notes/release_23_03.rst |  9 ++++
 lib/ethdev/rte_flow.c                  | 19 +++++++
 lib/ethdev/rte_flow.h                  | 22 ++++++++
 lib/net/rte_ip.h                       | 19 +++++++
 6 files changed, 149 insertions(+), 1 deletion(-)
Signature · 1 line
2.27.0
#23 lore raw

PATCH v4 1/3 ethdev: add IPv6 routing extension header definition

Add IPv6 routing extension header definition and no TLV support for now.

At rte_flow layer, there are new items defined for matching type/nexthdr/segments_left field.

Add command line support for IPv6 routing extension header
matching: type/nexthdr/segment_list.

---
 app/test-pmd/cmdline_flow.c            | 46 ++++++++++++++++++++++++++
 doc/guides/prog_guide/rte_flow.rst     |  9 +++++
 doc/guides/rel_notes/release_23_03.rst |  9 +++++
 lib/ethdev/rte_flow.c                  | 19 +++++++++++
 lib/ethdev/rte_flow.h                  | 21 ++++++++++++
 lib/net/rte_ip.h                       | 19 +++++++++++
 6 files changed, 123 insertions(+)
app/test-pmd/cmdline_flow.c +46 -0
index 88108498e0..7a8516829c 100644
@@ -298,6 +298,10 @@ enum index {
 	ITEM_IPV6_SRC,
 	ITEM_IPV6_DST,
 	ITEM_IPV6_HAS_FRAG_EXT,
+	ITEM_IPV6_ROUTING_EXT,
+	ITEM_IPV6_ROUTING_EXT_TYPE,
+	ITEM_IPV6_ROUTING_EXT_NEXT_HDR,
+	ITEM_IPV6_ROUTING_EXT_SEG_LEFT,
 	ITEM_ICMP,
 	ITEM_ICMP_TYPE,
 	ITEM_ICMP_CODE,
@@ -1326,6 +1330,7 @@ static const enum index next_item[] = {
 	ITEM_ARP_ETH_IPV4,
 	ITEM_IPV6_EXT,
 	ITEM_IPV6_FRAG_EXT,
+	ITEM_IPV6_ROUTING_EXT,
 	ITEM_ICMP6,
 	ITEM_ICMP6_ND_NS,
 	ITEM_ICMP6_ND_NA,
@@ -1435,6 +1440,15 @@ static const enum index item_ipv6[] = {
 	ITEM_IPV6_SRC,
 	ITEM_IPV6_DST,
 	ITEM_IPV6_HAS_FRAG_EXT,
+	ITEM_IPV6_ROUTING_EXT,
+	ITEM_NEXT,
+	ZERO,
+};
+
+static const enum index item_ipv6_routing_ext[] = {
+	ITEM_IPV6_ROUTING_EXT_TYPE,
+	ITEM_IPV6_ROUTING_EXT_NEXT_HDR,
+	ITEM_IPV6_ROUTING_EXT_SEG_LEFT,
 	ITEM_NEXT,
 	ZERO,
 };
@@ -3844,6 +3858,38 @@ static const struct token token_list[] = {
 		.args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_ipv6,
 					   has_frag_ext, 1)),
 	},
+	[ITEM_IPV6_ROUTING_EXT] = {
+		.name = "ipv6_routing_ext",
+		.help = "match IPv6 routing extension header",
+		.priv = PRIV_ITEM(IPV6_ROUTING_EXT,
+				  sizeof(struct rte_flow_item_ipv6_routing_ext)),
+		.next = NEXT(item_ipv6_routing_ext),
+		.call = parse_vc,
+	},
+	[ITEM_IPV6_ROUTING_EXT_TYPE] = {
+		.name = "ext_type",
+		.help = "match IPv6 routing extension header type",
+		.next = NEXT(item_ipv6_routing_ext, NEXT_ENTRY(COMMON_UNSIGNED),
+			     item_param),
+		.args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6_routing_ext,
+					     hdr.type)),
+	},
+	[ITEM_IPV6_ROUTING_EXT_NEXT_HDR] = {
+		.name = "ext_next_hdr",
+		.help = "match IPv6 routing extension header next header type",
+		.next = NEXT(item_ipv6_routing_ext, NEXT_ENTRY(COMMON_UNSIGNED),
+			     item_param),
+		.args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6_routing_ext,
+					     hdr.next_hdr)),
+	},
+	[ITEM_IPV6_ROUTING_EXT_SEG_LEFT] = {
+		.name = "ext_seg_left",
+		.help = "match IPv6 routing extension header segment left",
+		.next = NEXT(item_ipv6_routing_ext, NEXT_ENTRY(COMMON_UNSIGNED),
+			     item_param),
+		.args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6_routing_ext,
+					     hdr.segments_left)),
+	},
 	[ITEM_ICMP] = {
 		.name = "icmp",
 		.help = "match ICMP header",
doc/guides/prog_guide/rte_flow.rst +9 -0
index 3e6242803d..602fab29d3 100644
@@ -1544,6 +1544,15 @@ Matches Color Marker set by a Meter.
 
 - ``color``: Metering color marker.
 
+Item: ``IPV6_ROUTING_EXT``
+^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+Matches IPv6 routing extension header.
+
+- ``next_hdr``: Next layer header type.
+- ``type``: IPv6 routing extension header type.
+- ``segments_left``: How many IPv6 destination addresses carries on.
+
 Actions
 ~~~~~~~
 
doc/guides/rel_notes/release_23_03.rst +9 -0
index c15f6fbb9f..1337da73b8 100644
@@ -69,6 +69,11 @@ New Features
     ``rte_event_dev_config::nb_single_link_event_port_queues`` parameter
     required for eth_rx, eth_tx, crypto and timer eventdev adapters.
 
+* **Added rte_flow support for matching IPv6 routing extension header fields.**
+
+  Added ``ipv6_routing_ext`` items in rte_flow to match IPv6 routing extension
+  header.
+
 
 Removed Items
 -------------
@@ -98,6 +103,10 @@ API Changes
    Also, make sure to start the actual text at the margin.
    =======================================================
 
+* net: added a new structure:
+
+    - IPv6 routing extension header ``rte_ipv6_routing_ext``.
+
 
 ABI Changes
 -----------
lib/ethdev/rte_flow.c +19 -0
index 7d0c24366c..833382c466 100644
@@ -76,6 +76,23 @@ rte_flow_item_flex_conv(void *buf, const void *data)
 	return src->length;
 }
 
+static size_t
+rte_flow_item_ipv6_routing_ext_conv(void *buf, const void *data)
+{
+	struct rte_flow_item_ipv6_routing_ext *dst = buf;
+	const struct rte_flow_item_ipv6_routing_ext *src = data;
+	size_t len;
+
+	if (src->hdr.hdr_len)
+		len = src->hdr.hdr_len << 3;
+	else
+		len = src->hdr.segments_left << 4;
+	if (dst == NULL)
+		return 0;
+	memcpy(dst->segments, src->segments, len);
+	return len;
+}
+
 /** Generate flow_item[] entry. */
 #define MK_FLOW_ITEM(t, s) \
 	[RTE_FLOW_ITEM_TYPE_ ## t] = { \
@@ -157,6 +174,8 @@ static const struct rte_flow_desc_data rte_flow_desc_item[] = {
 	MK_FLOW_ITEM(L2TPV2, sizeof(struct rte_flow_item_l2tpv2)),
 	MK_FLOW_ITEM(PPP, sizeof(struct rte_flow_item_ppp)),
 	MK_FLOW_ITEM(METER_COLOR, sizeof(struct rte_flow_item_meter_color)),
+	MK_FLOW_ITEM_FN(IPV6_ROUTING_EXT, sizeof(struct rte_flow_item_ipv6_routing_ext),
+			rte_flow_item_ipv6_routing_ext_conv),
 };
 
 /** Generate flow_action[] entry. */
lib/ethdev/rte_flow.h +21 -0
index b60987db4b..ff9270690c 100644
@@ -624,6 +624,13 @@ enum rte_flow_item_type {
 	 * See struct rte_flow_item_meter_color.
 	 */
 	RTE_FLOW_ITEM_TYPE_METER_COLOR,
+
+	/**
+	 * Matches the presence of IPv6 routing extension header.
+	 *
+	 * @see struct rte_flow_item_ipv6_routing_ext.
+	 */
+	RTE_FLOW_ITEM_TYPE_IPV6_ROUTING_EXT,
 };
 
 /**
@@ -873,6 +880,20 @@ struct rte_flow_item_ipv6 {
 	uint32_t reserved:23;
 };
 
+/**
+ * @warning
+ * @b EXPERIMENTAL: this structure may change without prior notice
+ *
+ * RTE_FLOW_ITEM_TYPE_IPV6_ROUTING_EXT.
+ *
+ * Matches an IPv6 routing extension header.
+ */
+struct rte_flow_item_ipv6_routing_ext {
+	struct rte_ipv6_routing_ext hdr;
+	__extension__
+	rte_be32_t segments[]; /**< Each hop IPv6 address. */
+};
+
 /** Default mask for RTE_FLOW_ITEM_TYPE_IPV6. */
 #ifndef __cplusplus
 static const struct rte_flow_item_ipv6 rte_flow_item_ipv6_mask = {
lib/net/rte_ip.h +19 -0
index 9c8e8206f0..778fb5ef83 100644
@@ -539,6 +539,25 @@ struct rte_ipv6_hdr {
 	uint8_t  dst_addr[16];	/**< IP address of destination host(s). */
 } __rte_packed;
 
+/**
+ * IPv6 Routing Extension Header
+ */
+struct rte_ipv6_routing_ext {
+	uint8_t next_hdr;			/**< Protocol, next header. */
+	uint8_t hdr_len;			/**< Header length. */
+	uint8_t type;				/**< Extension header type. */
+	uint8_t segments_left;			/**< Valid segments number. */
+	__extension__
+	union {
+		rte_be32_t flags;
+		struct {
+			uint8_t last_entry;	/**< The last_entry field of SRH */
+			uint8_t flag;		/**< Packet flag. */
+			rte_be16_t tag;		/**< Packet tag. */
+		};
+	};
+} __rte_packed;
+
 /* IPv6 vtc_flow: IPv / TC / flow_label */
 #define RTE_IPV6_HDR_FL_SHIFT 0
 #define RTE_IPV6_HDR_TC_SHIFT 20
Signature · 1 line
2.27.0
#24 lore raw

Re: [PATCH v4 1/3] ethdev: add IPv6 routing extension header definition

Quoted 151 lines · Rongwei Liu

Add IPv6 routing extension header definition and no TLV support for now.

At rte_flow layer, there are new items defined for matching type/nexthdr/segments_left field.

Add command line support for IPv6 routing extension header
matching: type/nexthdr/segment_list.

---
  app/test-pmd/cmdline_flow.c            | 46 ++++++++++++++++++++++++++
  doc/guides/prog_guide/rte_flow.rst     |  9 +++++
  doc/guides/rel_notes/release_23_03.rst |  9 +++++
  lib/ethdev/rte_flow.c                  | 19 +++++++++++
  lib/ethdev/rte_flow.h                  | 21 ++++++++++++
  lib/net/rte_ip.h                       | 19 +++++++++++
  6 files changed, 123 insertions(+)
app/test-pmd/cmdline_flow.c +46 -0
index 88108498e0..7a8516829c 100644
@@ -298,6 +298,10 @@ enum index {
  	ITEM_IPV6_SRC,
  	ITEM_IPV6_DST,
  	ITEM_IPV6_HAS_FRAG_EXT,
+	ITEM_IPV6_ROUTING_EXT,
+	ITEM_IPV6_ROUTING_EXT_TYPE,
+	ITEM_IPV6_ROUTING_EXT_NEXT_HDR,
+	ITEM_IPV6_ROUTING_EXT_SEG_LEFT,
  	ITEM_ICMP,
  	ITEM_ICMP_TYPE,
  	ITEM_ICMP_CODE,
@@ -1326,6 +1330,7 @@ static const enum index next_item[] = {
  	ITEM_ARP_ETH_IPV4,
  	ITEM_IPV6_EXT,
  	ITEM_IPV6_FRAG_EXT,
+	ITEM_IPV6_ROUTING_EXT,
  	ITEM_ICMP6,
  	ITEM_ICMP6_ND_NS,
  	ITEM_ICMP6_ND_NA,
@@ -1435,6 +1440,15 @@ static const enum index item_ipv6[] = {
  	ITEM_IPV6_SRC,
  	ITEM_IPV6_DST,
  	ITEM_IPV6_HAS_FRAG_EXT,
+	ITEM_IPV6_ROUTING_EXT,
+	ITEM_NEXT,
+	ZERO,
+};
+
+static const enum index item_ipv6_routing_ext[] = {
+	ITEM_IPV6_ROUTING_EXT_TYPE,
+	ITEM_IPV6_ROUTING_EXT_NEXT_HDR,
+	ITEM_IPV6_ROUTING_EXT_SEG_LEFT,
  	ITEM_NEXT,
  	ZERO,
  };
@@ -3844,6 +3858,38 @@ static const struct token token_list[] = {
  		.args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_ipv6,
  					   has_frag_ext, 1)),
  	},
+	[ITEM_IPV6_ROUTING_EXT] = {
+		.name = "ipv6_routing_ext",
+		.help = "match IPv6 routing extension header",
+		.priv = PRIV_ITEM(IPV6_ROUTING_EXT,
+				  sizeof(struct rte_flow_item_ipv6_routing_ext)),
+		.next = NEXT(item_ipv6_routing_ext),
+		.call = parse_vc,
+	},
+	[ITEM_IPV6_ROUTING_EXT_TYPE] = {
+		.name = "ext_type",
+		.help = "match IPv6 routing extension header type",
+		.next = NEXT(item_ipv6_routing_ext, NEXT_ENTRY(COMMON_UNSIGNED),
+			     item_param),
+		.args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6_routing_ext,
+					     hdr.type)),
+	},
+	[ITEM_IPV6_ROUTING_EXT_NEXT_HDR] = {
+		.name = "ext_next_hdr",
+		.help = "match IPv6 routing extension header next header type",
+		.next = NEXT(item_ipv6_routing_ext, NEXT_ENTRY(COMMON_UNSIGNED),
+			     item_param),
+		.args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6_routing_ext,
+					     hdr.next_hdr)),
+	},
+	[ITEM_IPV6_ROUTING_EXT_SEG_LEFT] = {
+		.name = "ext_seg_left",
+		.help = "match IPv6 routing extension header segment left",
+		.next = NEXT(item_ipv6_routing_ext, NEXT_ENTRY(COMMON_UNSIGNED),
+			     item_param),
+		.args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6_routing_ext,
+					     hdr.segments_left)),
+	},
  	[ITEM_ICMP] = {
  		.name = "icmp",
  		.help = "match ICMP header",
doc/guides/prog_guide/rte_flow.rst +9 -0
index 3e6242803d..602fab29d3 100644
@@ -1544,6 +1544,15 @@ Matches Color Marker set by a Meter.
 
  - ``color``: Metering color marker.
 
+Item: ``IPV6_ROUTING_EXT``
+^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+Matches IPv6 routing extension header.
+
+- ``next_hdr``: Next layer header type.
+- ``type``: IPv6 routing extension header type.
+- ``segments_left``: How many IPv6 destination addresses carries on.
+
  Actions
  ~~~~~~~
 
doc/guides/rel_notes/release_23_03.rst +9 -0
index c15f6fbb9f..1337da73b8 100644
@@ -69,6 +69,11 @@ New Features
      ``rte_event_dev_config::nb_single_link_event_port_queues`` parameter
      required for eth_rx, eth_tx, crypto and timer eventdev adapters.
 
+* **Added rte_flow support for matching IPv6 routing extension header fields.**
+
+  Added ``ipv6_routing_ext`` items in rte_flow to match IPv6 routing extension
+  header.
+
 
  Removed Items
  -------------
@@ -98,6 +103,10 @@ API Changes
     Also, make sure to start the actual text at the margin.
     =======================================================
 
+* net: added a new structure:
+
+    - IPv6 routing extension header ``rte_ipv6_routing_ext``.
+
 
  ABI Changes
  -----------
lib/ethdev/rte_flow.c +0 -0
index 7d0c24366c..833382c466 100644
@@ -76,6 +76,23 @@ rte_flow_item_flex_conv(void *buf, const void *data)
  	return src->length;

lib/ethdev/rte_flow.c rte_flow_item_flex_conv(void *buf, const void *data) · line 86

Quoted 10 lines
lib/ethdev/rte_flow.c +8 -0
  }
 
+static size_t
+rte_flow_item_ipv6_routing_ext_conv(void *buf, const void *data)
+{
+	struct rte_flow_item_ipv6_routing_ext *dst = buf;
+	const struct rte_flow_item_ipv6_routing_ext *src = data;
+	size_t len;
+
+	if (src->hdr.hdr_len)

Please, compare vs 0

Quoted 45 lines
lib/ethdev/rte_flow.c +11 -0
+		len = src->hdr.hdr_len << 3;
+	else
+		len = src->hdr.segments_left << 4;
+	if (dst == NULL)
+		return 0;
+	memcpy(dst->segments, src->segments, len);
+	return len;
+}
+
  /** Generate flow_item[] entry. */
  #define MK_FLOW_ITEM(t, s) \
  	[RTE_FLOW_ITEM_TYPE_ ## t] = { \
@@ -157,6 +174,8 @@ static const struct rte_flow_desc_data rte_flow_desc_item[] = {
  	MK_FLOW_ITEM(L2TPV2, sizeof(struct rte_flow_item_l2tpv2)),
  	MK_FLOW_ITEM(PPP, sizeof(struct rte_flow_item_ppp)),
  	MK_FLOW_ITEM(METER_COLOR, sizeof(struct rte_flow_item_meter_color)),
+	MK_FLOW_ITEM_FN(IPV6_ROUTING_EXT, sizeof(struct rte_flow_item_ipv6_routing_ext),
+			rte_flow_item_ipv6_routing_ext_conv),
  };
 
  /** Generate flow_action[] entry. */
lib/ethdev/rte_flow.h +9 -0
index b60987db4b..ff9270690c 100644
@@ -624,6 +624,13 @@ enum rte_flow_item_type {
  	 * See struct rte_flow_item_meter_color.
  	 */
  	RTE_FLOW_ITEM_TYPE_METER_COLOR,
+
+	/**
+	 * Matches the presence of IPv6 routing extension header.
+	 *
+	 * @see struct rte_flow_item_ipv6_routing_ext.
+	 */
+	RTE_FLOW_ITEM_TYPE_IPV6_ROUTING_EXT,
  };
 
  /**
@@ -873,6 +880,20 @@ struct rte_flow_item_ipv6 {
  	uint32_t reserved:23;
  };
 
+/**
+ * @warning

lib/ethdev/rte_flow.h struct rte_flow_item_ipv6 { · line 894

Quoted 10 lines
lib/ethdev/rte_flow.h +10 -0
+ * @b EXPERIMENTAL: this structure may change without prior notice
+ *
+ * RTE_FLOW_ITEM_TYPE_IPV6_ROUTING_EXT.
+ *
+ * Matches an IPv6 routing extension header.
+ */
+struct rte_flow_item_ipv6_routing_ext {
+	struct rte_ipv6_routing_ext hdr;
+	__extension__
+	rte_be32_t segments[]; /**< Each hop IPv6 address. */

Do we really need it? Are you going to support it? Will testpmd and flow conf work correctly since it uses size of the structure?

IMHO we should just remove it right now if we're not going to support it.

Quoted 14 lines
lib/ethdev/rte_flow.h +2 -0
+};
+
  /** Default mask for RTE_FLOW_ITEM_TYPE_IPV6. */
  #ifndef __cplusplus
  static const struct rte_flow_item_ipv6 rte_flow_item_ipv6_mask = {
lib/net/rte_ip.h +1 -0
index 9c8e8206f0..778fb5ef83 100644
@@ -539,6 +539,25 @@ struct rte_ipv6_hdr {
  	uint8_t  dst_addr[16];	/**< IP address of destination host(s). */
  } __rte_packed;
 
+/**

lib/net/rte_ip.h struct rte_ipv6_hdr { · line 552

Quoted 10 lines
lib/net/rte_ip.h +10 -0
+ * IPv6 Routing Extension Header
+ */
+struct rte_ipv6_routing_ext {
+	uint8_t next_hdr;			/**< Protocol, next header. */
+	uint8_t hdr_len;			/**< Header length. */
+	uint8_t type;				/**< Extension header type. */
+	uint8_t segments_left;			/**< Valid segments number. */
+	__extension__
+	union {
+		rte_be32_t flags;

flags should be documented as well.

lib/net/rte_ip.h struct rte_ipv6_hdr { · line 558

Quoted 6 lines
lib/net/rte_ip.h +6 -0
+		struct {
+			uint8_t last_entry;	/**< The last_entry field of SRH */
+			uint8_t flag;		/**< Packet flag. */
+			rte_be16_t tag;		/**< Packet tag. */
+		};
+	};

May be we should add a comment here that segments follow?

Quoted 5 lines
lib/net/rte_ip.h +2 -0
+} __rte_packed;
+
  /* IPv6 vtc_flow: IPv / TC / flow_label */
  #define RTE_IPV6_HDR_FL_SHIFT 0
  #define RTE_IPV6_HDR_TC_SHIFT 20
#25 lore raw

RE: [PATCH v4 1/3] ethdev: add IPv6 routing extension header definition

HI Andrew:

BR
Rongwei

Quoted 234 lines

-----Original Message-----
From: Andrew Rybchenko <[email protected]>
Sent: Wednesday, February 1, 2023 17:21
To: Rongwei Liu <[email protected]>; [email protected]; Matan Azrad <[email protected]>; Slava Ovsiienko <[email protected]>; Ori Kam <[email protected]>; NBU-Contact-Thomas Monjalon (EXTERNAL) <[email protected]>
Cc: Raslan Darawsheh <[email protected]>; Aman Singh <[email protected]>; Yuying Zhang <[email protected]>; Ferruh Yigit <[email protected]>; Olivier Matz <[email protected]>
Subject: Re: [PATCH v4 1/3] ethdev: add IPv6 routing extension header definition

External email: Use caution opening links or attachments

Quoted 65 lines · Rongwei Liu

Add IPv6 routing extension header definition and no TLV support for now.

At rte_flow layer, there are new items defined for matching type/nexthdr/segments_left field.

Add command line support for IPv6 routing extension header
matching: type/nexthdr/segment_list.

---
  app/test-pmd/cmdline_flow.c            | 46 ++++++++++++++++++++++++++
  doc/guides/prog_guide/rte_flow.rst     |  9 +++++
  doc/guides/rel_notes/release_23_03.rst |  9 +++++
  lib/ethdev/rte_flow.c                  | 19 +++++++++++
  lib/ethdev/rte_flow.h                  | 21 ++++++++++++
  lib/net/rte_ip.h                       | 19 +++++++++++
  6 files changed, 123 insertions(+)
app/test-pmd/cmdline_flow.c +16 -0
index 88108498e0..7a8516829c 100644
@@ -298,6 +298,10 @@ enum index {
      ITEM_IPV6_SRC,
      ITEM_IPV6_DST,
      ITEM_IPV6_HAS_FRAG_EXT,
+     ITEM_IPV6_ROUTING_EXT,
+     ITEM_IPV6_ROUTING_EXT_TYPE,
+     ITEM_IPV6_ROUTING_EXT_NEXT_HDR,
+     ITEM_IPV6_ROUTING_EXT_SEG_LEFT,
      ITEM_ICMP,
      ITEM_ICMP_TYPE,
      ITEM_ICMP_CODE,
@@ -1326,6 +1330,7 @@ static const enum index next_item[] = {
      ITEM_ARP_ETH_IPV4,
      ITEM_IPV6_EXT,
      ITEM_IPV6_FRAG_EXT,
+     ITEM_IPV6_ROUTING_EXT,
      ITEM_ICMP6,
      ITEM_ICMP6_ND_NS,
      ITEM_ICMP6_ND_NA,
@@ -1435,6 +1440,15 @@ static const enum index item_ipv6[] = {
      ITEM_IPV6_SRC,
      ITEM_IPV6_DST,
      ITEM_IPV6_HAS_FRAG_EXT,
+     ITEM_IPV6_ROUTING_EXT,
+     ITEM_NEXT,
+     ZERO,
+};
+
+static const enum index item_ipv6_routing_ext[] = {
+     ITEM_IPV6_ROUTING_EXT_TYPE,
+     ITEM_IPV6_ROUTING_EXT_NEXT_HDR,
+     ITEM_IPV6_ROUTING_EXT_SEG_LEFT,
      ITEM_NEXT,
      ZERO,
  };
@@ -3844,6 +3858,38 @@ static const struct token token_list[] = {
              .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_ipv6,
                                         has_frag_ext, 1)),
      },
+     [ITEM_IPV6_ROUTING_EXT] = {
+             .name = "ipv6_routing_ext",

app/test-pmd/cmdline_flow.c static const struct token token_list[] = { · line 3872

Quoted 10 lines
app/test-pmd/cmdline_flow.c +10 -0
+             .help = "match IPv6 routing extension header",
+             .priv = PRIV_ITEM(IPV6_ROUTING_EXT,
+                               sizeof(struct rte_flow_item_ipv6_routing_ext)),
+             .next = NEXT(item_ipv6_routing_ext),
+             .call = parse_vc,
+     },
+     [ITEM_IPV6_ROUTING_EXT_TYPE] = {
+             .name = "ext_type",
+             .help = "match IPv6 routing extension header type",
+             .next = NEXT(item_ipv6_routing_ext,

NEXT_ENTRY(COMMON_UNSIGNED),

app/test-pmd/cmdline_flow.c static const struct token token_list[] = { · line 3874

Quoted 2 lines
app/test-pmd/cmdline_flow.c +2 -0
+                          item_param),
+             .args = ARGS(ARGS_ENTRY_HTON(struct

rte_flow_item_ipv6_routing_ext,

app/test-pmd/cmdline_flow.c static const struct token token_list[] = {

Quoted 6 lines
app/test-pmd/cmdline_flow.c +6 -0
+                                          hdr.type)),
+     },
+     [ITEM_IPV6_ROUTING_EXT_NEXT_HDR] = {
+             .name = "ext_next_hdr",
+             .help = "match IPv6 routing extension header next header type",
+             .next = NEXT(item_ipv6_routing_ext,

NEXT_ENTRY(COMMON_UNSIGNED),

app/test-pmd/cmdline_flow.c static const struct token token_list[] = { · line 3882

Quoted 2 lines
app/test-pmd/cmdline_flow.c +2 -0
+                          item_param),
+             .args = ARGS(ARGS_ENTRY_HTON(struct

rte_flow_item_ipv6_routing_ext,

app/test-pmd/cmdline_flow.c static const struct token token_list[] = {

Quoted 6 lines
app/test-pmd/cmdline_flow.c +6 -0
+                                          hdr.next_hdr)),
+     },
+     [ITEM_IPV6_ROUTING_EXT_SEG_LEFT] = {
+             .name = "ext_seg_left",
+             .help = "match IPv6 routing extension header segment left",
+             .next = NEXT(item_ipv6_routing_ext,

NEXT_ENTRY(COMMON_UNSIGNED),

app/test-pmd/cmdline_flow.c static const struct token token_list[] = { · line 3890

Quoted 2 lines
app/test-pmd/cmdline_flow.c +2 -0
+                          item_param),
+             .args = ARGS(ARGS_ENTRY_HTON(struct

rte_flow_item_ipv6_routing_ext,

Quoted 60 lines
app/test-pmd/cmdline_flow.c +2 -0
+                                          hdr.segments_left)),
+     },
      [ITEM_ICMP] = {
              .name = "icmp",
              .help = "match ICMP header", diff --git

a/doc/guides/prog_guide/rte_flow.rst
b/doc/guides/prog_guide/rte_flow.rst
index 3e6242803d..602fab29d3 100644

doc/guides/prog_guide/rte_flow.rst +9 -0
@@ -1544,6 +1544,15 @@ Matches Color Marker set by a Meter.
 
  - ``color``: Metering color marker.
 
+Item: ``IPV6_ROUTING_EXT``
+^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+Matches IPv6 routing extension header.
+
+- ``next_hdr``: Next layer header type.
+- ``type``: IPv6 routing extension header type.
+- ``segments_left``: How many IPv6 destination addresses carries on.
+
  Actions
  ~~~~~~~
 
doc/guides/rel_notes/release_23_03.rst +10 -0
index c15f6fbb9f..1337da73b8 100644
@@ -69,6 +69,11 @@ New Features
      ``rte_event_dev_config::nb_single_link_event_port_queues`` parameter
      required for eth_rx, eth_tx, crypto and timer eventdev adapters.
 
+* **Added rte_flow support for matching IPv6 routing extension header
+fields.**
+
+  Added ``ipv6_routing_ext`` items in rte_flow to match IPv6 routing
+ extension  header.
+
 
  Removed Items
  -------------
@@ -98,6 +103,10 @@ API Changes
     Also, make sure to start the actual text at the margin.
     =======================================================
 
+* net: added a new structure:
+
+    - IPv6 routing extension header ``rte_ipv6_routing_ext``.
+
 
  ABI Changes
  -----------
lib/ethdev/rte_flow.c index renamed from lib/ethdev/rte_flow.c +0 -0

7d0c24366c..833382c466 100644

lib/ethdev/rte_flow.c rte_flow_item_flex_conv(void *buf, const void *data) · line 85

Quoted 10 lines
lib/ethdev/rte_flow.c +7 -0
@@ -76,6 +76,23 @@ rte_flow_item_flex_conv(void *buf, const void *data)
      return src->length;
  }
 
+static size_t
+rte_flow_item_ipv6_routing_ext_conv(void *buf, const void *data) {
+     struct rte_flow_item_ipv6_routing_ext *dst = buf;
+     const struct rte_flow_item_ipv6_routing_ext *src = data;
+     size_t len;
+
+     if (src->hdr.hdr_len)

Please, compare vs 0

Quoted 12 lines
lib/ethdev/rte_flow.c +9 -0
+             len = src->hdr.hdr_len << 3;
+     else
+             len = src->hdr.segments_left << 4;
+     if (dst == NULL)
+             return 0;
+     memcpy(dst->segments, src->segments, len);
+     return len;
+}
+
  /** Generate flow_item[] entry. */
  #define MK_FLOW_ITEM(t, s) \
      [RTE_FLOW_ITEM_TYPE_ ## t] = { \ @@ -157,6 +174,8 @@ static
Quoted 6 lines

const struct rte_flow_desc_data rte_flow_desc_item[] = {
MK_FLOW_ITEM(L2TPV2, sizeof(struct rte_flow_item_l2tpv2)), MK_FLOW_ITEM(PPP, sizeof(struct rte_flow_item_ppp)), MK_FLOW_ITEM(METER_COLOR, sizeof(struct
rte_flow_item_meter_color)),
+ MK_FLOW_ITEM_FN(IPV6_ROUTING_EXT, sizeof(struct

rte_flow_item_ipv6_routing_ext),

Quoted 26 lines

+ rte_flow_item_ipv6_routing_ext_conv),
};

/** Generate flow_action[] entry. */ diff --git
a/lib/ethdev/rte_flow.h b/lib/ethdev/rte_flow.h index b60987db4b..ff9270690c 100644

lib/ethdev/rte_flow.h +7 -0
@@ -624,6 +624,13 @@ enum rte_flow_item_type {
       * See struct rte_flow_item_meter_color.
       */
      RTE_FLOW_ITEM_TYPE_METER_COLOR,
+
+     /**
+      * Matches the presence of IPv6 routing extension header.
+      *
+      * @see struct rte_flow_item_ipv6_routing_ext.
+      */
+     RTE_FLOW_ITEM_TYPE_IPV6_ROUTING_EXT,
  };
 
  /**
@@ -873,6 +880,20 @@ struct rte_flow_item_ipv6 {
      uint32_t reserved:23;
  };
 
Quoted 16 lines

lib/ethdev/rte_flow.h struct rte_flow_item_ipv6 { · line 894

Quoted 12 lines
lib/ethdev/rte_flow.h +12 -0
+/**
+ * @warning
+ * @b EXPERIMENTAL: this structure may change without prior notice
+ *
+ * RTE_FLOW_ITEM_TYPE_IPV6_ROUTING_EXT.
+ *
+ * Matches an IPv6 routing extension header.
+ */
+struct rte_flow_item_ipv6_routing_ext {
+     struct rte_ipv6_routing_ext hdr;
+     __extension__
+     rte_be32_t segments[]; /**< Each hop IPv6 address. */

Do we really need it? Are you going to support it?
Will testpmd and flow conf work correctly since it uses size of the structure?

In the rte_flow.c and testpmd raw_encap() function, it relies on the hdr_len or segment_left fild not sizeof this structure.

Quoted 2 lines

IMHO we should just remove it right now if we're not going to support it.

In matching, we don't support segments field. I am ok to remove it.

Quoted 13 lines
Quoted 13 lines
lib/ethdev/rte_flow.h +2 -0
+};
+
  /** Default mask for RTE_FLOW_ITEM_TYPE_IPV6. */
  #ifndef __cplusplus
  static const struct rte_flow_item_ipv6 rte_flow_item_ipv6_mask = {
lib/net/rte_ip.h index renamed from lib/net/rte_ip.h +0 -0

9c8e8206f0..778fb5ef83 100644

lib/net/rte_ip.h +0 -0
@@ -539,6 +539,25 @@ struct rte_ipv6_hdr {
      uint8_t  dst_addr[16];  /**< IP address of destination host(s). */
  } __rte_packed;
 
Quoted 13 lines

lib/net/rte_ip.h struct rte_ipv6_hdr { · line 552

Quoted 11 lines
lib/net/rte_ip.h +11 -0
+/**
+ * IPv6 Routing Extension Header
+ */
+struct rte_ipv6_routing_ext {
+     uint8_t next_hdr;                       /**< Protocol, next header. */
+     uint8_t hdr_len;                        /**< Header length. */
+     uint8_t type;                           /**< Extension header type. */
+     uint8_t segments_left;                  /**< Valid segments number. */
+     __extension__
+     union {
+             rte_be32_t flags;

flags should be documented as well.

Sure.

Quoted 9 lines

lib/net/rte_ip.h struct rte_ipv6_hdr { · line 558

Quoted 7 lines
lib/net/rte_ip.h +6 -0
+             struct {
+                     uint8_t last_entry;     /**< The last_entry field of SRH */
+                     uint8_t flag;           /**< Packet flag. */
+                     rte_be16_t tag;         /**< Packet tag. */
+             };
+     };

May be we should add a comment here that segments follow?

Sure.

Quoted 6 lines
Quoted 6 lines
lib/net/rte_ip.h +2 -0
+} __rte_packed;
+
  /* IPv6 vtc_flow: IPv / TC / flow_label */
  #define RTE_IPV6_HDR_FL_SHIFT 0
  #define RTE_IPV6_HDR_TC_SHIFT 20
#26 lore raw

Re: [PATCH v4 1/3] ethdev: add IPv6 routing extension header definition

Quoted 255 lines · Rongwei Liu

HI Andrew:

BR
Rongwei

Quoted 234 lines

-----Original Message-----
From: Andrew Rybchenko <[email protected]>
Sent: Wednesday, February 1, 2023 17:21
To: Rongwei Liu <[email protected]>; [email protected]; Matan Azrad <[email protected]>; Slava Ovsiienko <[email protected]>; Ori Kam <[email protected]>; NBU-Contact-Thomas Monjalon (EXTERNAL) <[email protected]>
Cc: Raslan Darawsheh <[email protected]>; Aman Singh <[email protected]>; Yuying Zhang <[email protected]>; Ferruh Yigit <[email protected]>; Olivier Matz <[email protected]>
Subject: Re: [PATCH v4 1/3] ethdev: add IPv6 routing extension header definition

External email: Use caution opening links or attachments

Quoted 65 lines · Rongwei Liu

Add IPv6 routing extension header definition and no TLV support for now.

At rte_flow layer, there are new items defined for matching type/nexthdr/segments_left field.

Add command line support for IPv6 routing extension header
matching: type/nexthdr/segment_list.

---
   app/test-pmd/cmdline_flow.c            | 46 ++++++++++++++++++++++++++
   doc/guides/prog_guide/rte_flow.rst     |  9 +++++
   doc/guides/rel_notes/release_23_03.rst |  9 +++++
   lib/ethdev/rte_flow.c                  | 19 +++++++++++
   lib/ethdev/rte_flow.h                  | 21 ++++++++++++
   lib/net/rte_ip.h                       | 19 +++++++++++
   6 files changed, 123 insertions(+)
app/test-pmd/cmdline_flow.c +16 -0
index 88108498e0..7a8516829c 100644
@@ -298,6 +298,10 @@ enum index {
       ITEM_IPV6_SRC,
       ITEM_IPV6_DST,
       ITEM_IPV6_HAS_FRAG_EXT,
+     ITEM_IPV6_ROUTING_EXT,
+     ITEM_IPV6_ROUTING_EXT_TYPE,
+     ITEM_IPV6_ROUTING_EXT_NEXT_HDR,
+     ITEM_IPV6_ROUTING_EXT_SEG_LEFT,
       ITEM_ICMP,
       ITEM_ICMP_TYPE,
       ITEM_ICMP_CODE,
@@ -1326,6 +1330,7 @@ static const enum index next_item[] = {
       ITEM_ARP_ETH_IPV4,
       ITEM_IPV6_EXT,
       ITEM_IPV6_FRAG_EXT,
+     ITEM_IPV6_ROUTING_EXT,
       ITEM_ICMP6,
       ITEM_ICMP6_ND_NS,
       ITEM_ICMP6_ND_NA,
@@ -1435,6 +1440,15 @@ static const enum index item_ipv6[] = {
       ITEM_IPV6_SRC,
       ITEM_IPV6_DST,
       ITEM_IPV6_HAS_FRAG_EXT,
+     ITEM_IPV6_ROUTING_EXT,
+     ITEM_NEXT,
+     ZERO,
+};
+
+static const enum index item_ipv6_routing_ext[] = {
+     ITEM_IPV6_ROUTING_EXT_TYPE,
+     ITEM_IPV6_ROUTING_EXT_NEXT_HDR,
+     ITEM_IPV6_ROUTING_EXT_SEG_LEFT,
       ITEM_NEXT,
       ZERO,
   };
@@ -3844,6 +3858,38 @@ static const struct token token_list[] = {
               .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_ipv6,
                                          has_frag_ext, 1)),
       },
+     [ITEM_IPV6_ROUTING_EXT] = {
+             .name = "ipv6_routing_ext",

app/test-pmd/cmdline_flow.c static const struct token token_list[] = { · line 3872

Quoted 10 lines
app/test-pmd/cmdline_flow.c +10 -0
+             .help = "match IPv6 routing extension header",
+             .priv = PRIV_ITEM(IPV6_ROUTING_EXT,
+                               sizeof(struct rte_flow_item_ipv6_routing_ext)),
+             .next = NEXT(item_ipv6_routing_ext),
+             .call = parse_vc,
+     },
+     [ITEM_IPV6_ROUTING_EXT_TYPE] = {
+             .name = "ext_type",
+             .help = "match IPv6 routing extension header type",
+             .next = NEXT(item_ipv6_routing_ext,

NEXT_ENTRY(COMMON_UNSIGNED),

app/test-pmd/cmdline_flow.c static const struct token token_list[] = { · line 3874

Quoted 2 lines
app/test-pmd/cmdline_flow.c +2 -0
+                          item_param),
+             .args = ARGS(ARGS_ENTRY_HTON(struct

rte_flow_item_ipv6_routing_ext,

app/test-pmd/cmdline_flow.c static const struct token token_list[] = {

Quoted 6 lines
app/test-pmd/cmdline_flow.c +6 -0
+                                          hdr.type)),
+     },
+     [ITEM_IPV6_ROUTING_EXT_NEXT_HDR] = {
+             .name = "ext_next_hdr",
+             .help = "match IPv6 routing extension header next header type",
+             .next = NEXT(item_ipv6_routing_ext,

NEXT_ENTRY(COMMON_UNSIGNED),

app/test-pmd/cmdline_flow.c static const struct token token_list[] = { · line 3882

Quoted 2 lines
app/test-pmd/cmdline_flow.c +2 -0
+                          item_param),
+             .args = ARGS(ARGS_ENTRY_HTON(struct

rte_flow_item_ipv6_routing_ext,

app/test-pmd/cmdline_flow.c static const struct token token_list[] = {

Quoted 6 lines
app/test-pmd/cmdline_flow.c +6 -0
+                                          hdr.next_hdr)),
+     },
+     [ITEM_IPV6_ROUTING_EXT_SEG_LEFT] = {
+             .name = "ext_seg_left",
+             .help = "match IPv6 routing extension header segment left",
+             .next = NEXT(item_ipv6_routing_ext,

NEXT_ENTRY(COMMON_UNSIGNED),

app/test-pmd/cmdline_flow.c static const struct token token_list[] = { · line 3890

Quoted 2 lines
app/test-pmd/cmdline_flow.c +2 -0
+                          item_param),
+             .args = ARGS(ARGS_ENTRY_HTON(struct

rte_flow_item_ipv6_routing_ext,

Quoted 60 lines
app/test-pmd/cmdline_flow.c +2 -0
+                                          hdr.segments_left)),
+     },
       [ITEM_ICMP] = {
               .name = "icmp",
               .help = "match ICMP header", diff --git

a/doc/guides/prog_guide/rte_flow.rst
b/doc/guides/prog_guide/rte_flow.rst
index 3e6242803d..602fab29d3 100644

doc/guides/prog_guide/rte_flow.rst +9 -0
@@ -1544,6 +1544,15 @@ Matches Color Marker set by a Meter.
 
   - ``color``: Metering color marker.
 
+Item: ``IPV6_ROUTING_EXT``
+^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+Matches IPv6 routing extension header.
+
+- ``next_hdr``: Next layer header type.
+- ``type``: IPv6 routing extension header type.
+- ``segments_left``: How many IPv6 destination addresses carries on.
+
   Actions
   ~~~~~~~
 
doc/guides/rel_notes/release_23_03.rst +10 -0
index c15f6fbb9f..1337da73b8 100644
@@ -69,6 +69,11 @@ New Features
       ``rte_event_dev_config::nb_single_link_event_port_queues`` parameter
       required for eth_rx, eth_tx, crypto and timer eventdev adapters.
 
+* **Added rte_flow support for matching IPv6 routing extension header
+fields.**
+
+  Added ``ipv6_routing_ext`` items in rte_flow to match IPv6 routing
+ extension  header.
+
 
   Removed Items
   -------------
@@ -98,6 +103,10 @@ API Changes
      Also, make sure to start the actual text at the margin.
      =======================================================
 
+* net: added a new structure:
+
+    - IPv6 routing extension header ``rte_ipv6_routing_ext``.
+
 
   ABI Changes
   -----------
lib/ethdev/rte_flow.c index renamed from lib/ethdev/rte_flow.c +0 -0

7d0c24366c..833382c466 100644

lib/ethdev/rte_flow.c rte_flow_item_flex_conv(void *buf, const void *data) · line 85

Quoted 10 lines
lib/ethdev/rte_flow.c +7 -0
@@ -76,6 +76,23 @@ rte_flow_item_flex_conv(void *buf, const void *data)
       return src->length;
   }
 
+static size_t
+rte_flow_item_ipv6_routing_ext_conv(void *buf, const void *data) {
+     struct rte_flow_item_ipv6_routing_ext *dst = buf;
+     const struct rte_flow_item_ipv6_routing_ext *src = data;
+     size_t len;
+
+     if (src->hdr.hdr_len)

Please, compare vs 0

Quoted 12 lines
lib/ethdev/rte_flow.c +9 -0
+             len = src->hdr.hdr_len << 3;
+     else
+             len = src->hdr.segments_left << 4;
+     if (dst == NULL)
+             return 0;
+     memcpy(dst->segments, src->segments, len);
+     return len;
+}
+
   /** Generate flow_item[] entry. */
   #define MK_FLOW_ITEM(t, s) \
       [RTE_FLOW_ITEM_TYPE_ ## t] = { \ @@ -157,6 +174,8 @@ static
Quoted 6 lines

const struct rte_flow_desc_data rte_flow_desc_item[] = {
MK_FLOW_ITEM(L2TPV2, sizeof(struct rte_flow_item_l2tpv2)), MK_FLOW_ITEM(PPP, sizeof(struct rte_flow_item_ppp)), MK_FLOW_ITEM(METER_COLOR, sizeof(struct
rte_flow_item_meter_color)),
+ MK_FLOW_ITEM_FN(IPV6_ROUTING_EXT, sizeof(struct

rte_flow_item_ipv6_routing_ext),

Quoted 26 lines

+ rte_flow_item_ipv6_routing_ext_conv),
};

   /** Generate flow_action[] entry. */ diff --git

a/lib/ethdev/rte_flow.h b/lib/ethdev/rte_flow.h index b60987db4b..ff9270690c 100644

lib/ethdev/rte_flow.h +7 -0
@@ -624,6 +624,13 @@ enum rte_flow_item_type {
        * See struct rte_flow_item_meter_color.
        */
       RTE_FLOW_ITEM_TYPE_METER_COLOR,
+
+     /**
+      * Matches the presence of IPv6 routing extension header.
+      *
+      * @see struct rte_flow_item_ipv6_routing_ext.
+      */
+     RTE_FLOW_ITEM_TYPE_IPV6_ROUTING_EXT,
   };
 
   /**
@@ -873,6 +880,20 @@ struct rte_flow_item_ipv6 {
       uint32_t reserved:23;
   };
 
Quoted 16 lines

lib/ethdev/rte_flow.h struct rte_flow_item_ipv6 { · line 894

Quoted 12 lines
lib/ethdev/rte_flow.h +12 -0
+/**
+ * @warning
+ * @b EXPERIMENTAL: this structure may change without prior notice
+ *
+ * RTE_FLOW_ITEM_TYPE_IPV6_ROUTING_EXT.
+ *
+ * Matches an IPv6 routing extension header.
+ */
+struct rte_flow_item_ipv6_routing_ext {
+     struct rte_ipv6_routing_ext hdr;
+     __extension__
+     rte_be32_t segments[]; /**< Each hop IPv6 address. */

Do we really need it? Are you going to support it?
Will testpmd and flow conf work correctly since it uses size of the structure?

Quoted 1 line

In the rte_flow.c and testpmd raw_encap() function, it relies on the hdr_len or segment_left fild not sizeof this structure.

We still have a number of sizeof() invocations for the structure in the patch. I worry that related code will not work fine if someone tries to specify segments.

Quoted 3 lines
Quoted 2 lines

IMHO we should just remove it right now if we're not going to support it.

In matching, we don't support segments field. I am ok to remove it.

Me too

#27 lore raw

v5 cover add IPv6 routing extension support

Support IPv6 routing extension header matching with new rte_flow item. Add encapsulation support for IPv6 routing extension header.

v5: remove flex array 'segments'.
v4: use flex array to define variable length segments and move PMD
implementation out.
v3: enhance the format and use be32/be16 in network header structure.
v2: remove redundant rte_flow items.

Rongwei Liu (3):
ethdev: add IPv6 routing extension header definition
ethdev: add modify IPv6 protocol field app/testpmd: add IPv6 routing extension header in raw encap

 app/test-pmd/cmdline_flow.c            | 72 +++++++++++++++++++++++++-
 doc/guides/prog_guide/rte_flow.rst     |  9 ++++
 doc/guides/rel_notes/release_23_03.rst |  9 ++++
 lib/ethdev/rte_flow.c                  |  1 +
 lib/ethdev/rte_flow.h                  | 20 +++++++
 lib/net/rte_ip.h                       | 20 +++++++
 6 files changed, 130 insertions(+), 1 deletion(-)
Signature · 1 line
2.27.0
#28 lore raw

PATCH v5 1/3 ethdev: add IPv6 routing extension header definition

Add IPv6 routing extension header definition and no TLV support for now.

At rte_flow layer, there are new items defined for matching type/nexthdr/segments_left field.

Add command line support for IPv6 routing extension header
matching: type/nexthdr/segment_list.

---
 app/test-pmd/cmdline_flow.c            | 46 ++++++++++++++++++++++++++
 doc/guides/prog_guide/rte_flow.rst     |  9 +++++
 doc/guides/rel_notes/release_23_03.rst |  9 +++++
 lib/ethdev/rte_flow.c                  |  1 +
 lib/ethdev/rte_flow.h                  | 19 +++++++++++
 lib/net/rte_ip.h                       | 20 +++++++++++
 6 files changed, 104 insertions(+)
app/test-pmd/cmdline_flow.c +46 -0
index 88108498e0..7a8516829c 100644
@@ -298,6 +298,10 @@ enum index {
 	ITEM_IPV6_SRC,
 	ITEM_IPV6_DST,
 	ITEM_IPV6_HAS_FRAG_EXT,
+	ITEM_IPV6_ROUTING_EXT,
+	ITEM_IPV6_ROUTING_EXT_TYPE,
+	ITEM_IPV6_ROUTING_EXT_NEXT_HDR,
+	ITEM_IPV6_ROUTING_EXT_SEG_LEFT,
 	ITEM_ICMP,
 	ITEM_ICMP_TYPE,
 	ITEM_ICMP_CODE,
@@ -1326,6 +1330,7 @@ static const enum index next_item[] = {
 	ITEM_ARP_ETH_IPV4,
 	ITEM_IPV6_EXT,
 	ITEM_IPV6_FRAG_EXT,
+	ITEM_IPV6_ROUTING_EXT,
 	ITEM_ICMP6,
 	ITEM_ICMP6_ND_NS,
 	ITEM_ICMP6_ND_NA,
@@ -1435,6 +1440,15 @@ static const enum index item_ipv6[] = {
 	ITEM_IPV6_SRC,
 	ITEM_IPV6_DST,
 	ITEM_IPV6_HAS_FRAG_EXT,
+	ITEM_IPV6_ROUTING_EXT,
+	ITEM_NEXT,
+	ZERO,
+};
+
+static const enum index item_ipv6_routing_ext[] = {
+	ITEM_IPV6_ROUTING_EXT_TYPE,
+	ITEM_IPV6_ROUTING_EXT_NEXT_HDR,
+	ITEM_IPV6_ROUTING_EXT_SEG_LEFT,
 	ITEM_NEXT,
 	ZERO,
 };
@@ -3844,6 +3858,38 @@ static const struct token token_list[] = {
 		.args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_ipv6,
 					   has_frag_ext, 1)),
 	},
+	[ITEM_IPV6_ROUTING_EXT] = {
+		.name = "ipv6_routing_ext",
+		.help = "match IPv6 routing extension header",
+		.priv = PRIV_ITEM(IPV6_ROUTING_EXT,
+				  sizeof(struct rte_flow_item_ipv6_routing_ext)),
+		.next = NEXT(item_ipv6_routing_ext),
+		.call = parse_vc,
+	},
+	[ITEM_IPV6_ROUTING_EXT_TYPE] = {
+		.name = "ext_type",
+		.help = "match IPv6 routing extension header type",
+		.next = NEXT(item_ipv6_routing_ext, NEXT_ENTRY(COMMON_UNSIGNED),
+			     item_param),
+		.args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6_routing_ext,
+					     hdr.type)),
+	},
+	[ITEM_IPV6_ROUTING_EXT_NEXT_HDR] = {
+		.name = "ext_next_hdr",
+		.help = "match IPv6 routing extension header next header type",
+		.next = NEXT(item_ipv6_routing_ext, NEXT_ENTRY(COMMON_UNSIGNED),
+			     item_param),
+		.args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6_routing_ext,
+					     hdr.next_hdr)),
+	},
+	[ITEM_IPV6_ROUTING_EXT_SEG_LEFT] = {
+		.name = "ext_seg_left",
+		.help = "match IPv6 routing extension header segment left",
+		.next = NEXT(item_ipv6_routing_ext, NEXT_ENTRY(COMMON_UNSIGNED),
+			     item_param),
+		.args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6_routing_ext,
+					     hdr.segments_left)),
+	},
 	[ITEM_ICMP] = {
 		.name = "icmp",
 		.help = "match ICMP header",
doc/guides/prog_guide/rte_flow.rst +9 -0
index 3e6242803d..602fab29d3 100644
@@ -1544,6 +1544,15 @@ Matches Color Marker set by a Meter.
 
 - ``color``: Metering color marker.
 
+Item: ``IPV6_ROUTING_EXT``
+^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+Matches IPv6 routing extension header.
+
+- ``next_hdr``: Next layer header type.
+- ``type``: IPv6 routing extension header type.
+- ``segments_left``: How many IPv6 destination addresses carries on.
+
 Actions
 ~~~~~~~
 
doc/guides/rel_notes/release_23_03.rst +9 -0
index c15f6fbb9f..1337da73b8 100644
@@ -69,6 +69,11 @@ New Features
     ``rte_event_dev_config::nb_single_link_event_port_queues`` parameter
     required for eth_rx, eth_tx, crypto and timer eventdev adapters.
 
+* **Added rte_flow support for matching IPv6 routing extension header fields.**
+
+  Added ``ipv6_routing_ext`` items in rte_flow to match IPv6 routing extension
+  header.
+
 
 Removed Items
 -------------
@@ -98,6 +103,10 @@ API Changes
    Also, make sure to start the actual text at the margin.
    =======================================================
 
+* net: added a new structure:
+
+    - IPv6 routing extension header ``rte_ipv6_routing_ext``.
+
 
 ABI Changes
 -----------
lib/ethdev/rte_flow.c +1 -0
index 7d0c24366c..4da581146e 100644
@@ -157,6 +157,7 @@ static const struct rte_flow_desc_data rte_flow_desc_item[] = {
 	MK_FLOW_ITEM(L2TPV2, sizeof(struct rte_flow_item_l2tpv2)),
 	MK_FLOW_ITEM(PPP, sizeof(struct rte_flow_item_ppp)),
 	MK_FLOW_ITEM(METER_COLOR, sizeof(struct rte_flow_item_meter_color)),
+	MK_FLOW_ITEM(IPV6_ROUTING_EXT, sizeof(struct rte_flow_item_ipv6_routing_ext)),
 };
 
 /** Generate flow_action[] entry. */
lib/ethdev/rte_flow.h +19 -0
index b60987db4b..9b9018cba2 100644
@@ -624,6 +624,13 @@ enum rte_flow_item_type {
 	 * See struct rte_flow_item_meter_color.
 	 */
 	RTE_FLOW_ITEM_TYPE_METER_COLOR,
+
+	/**
+	 * Matches the presence of IPv6 routing extension header.
+	 *
+	 * @see struct rte_flow_item_ipv6_routing_ext.
+	 */
+	RTE_FLOW_ITEM_TYPE_IPV6_ROUTING_EXT,
 };
 
 /**
@@ -873,6 +880,18 @@ struct rte_flow_item_ipv6 {
 	uint32_t reserved:23;
 };
 
+/**
+ * @warning
+ * @b EXPERIMENTAL: this structure may change without prior notice
+ *
+ * RTE_FLOW_ITEM_TYPE_IPV6_ROUTING_EXT.
+ *
+ * Matches an IPv6 routing extension header.
+ */
+struct rte_flow_item_ipv6_routing_ext {
+	struct rte_ipv6_routing_ext hdr;
+};
+
 /** Default mask for RTE_FLOW_ITEM_TYPE_IPV6. */
 #ifndef __cplusplus
 static const struct rte_flow_item_ipv6 rte_flow_item_ipv6_mask = {
lib/net/rte_ip.h +20 -0
index 9c8e8206f0..1f23e24af5 100644
@@ -539,6 +539,26 @@ struct rte_ipv6_hdr {
 	uint8_t  dst_addr[16];	/**< IP address of destination host(s). */
 } __rte_packed;
 
+/**
+ * IPv6 Routing Extension Header
+ */
+struct rte_ipv6_routing_ext {
+	uint8_t next_hdr;			/**< Protocol, next header. */
+	uint8_t hdr_len;			/**< Header length. */
+	uint8_t type;				/**< Extension header type. */
+	uint8_t segments_left;			/**< Valid segments number. */
+	__extension__
+	union {
+		rte_be32_t flags;		/**< Packet control data per type. */
+		struct {
+			uint8_t last_entry;	/**< The last_entry field of SRH */
+			uint8_t flag;		/**< Packet flag. */
+			rte_be16_t tag;		/**< Packet tag. */
+		};
+	};
+	/** Following variable number of segments. */
+} __rte_packed;
+
 /* IPv6 vtc_flow: IPv / TC / flow_label */
 #define RTE_IPV6_HDR_FL_SHIFT 0
 #define RTE_IPV6_HDR_TC_SHIFT 20
Signature · 1 line
2.27.0
Acked-by on v5 1/3
#29 lore raw

Re: [PATCH v5 1/3] ethdev: add IPv6 routing extension header definition

Quoted 11 lines · Rongwei Liu

Add IPv6 routing extension header definition and no TLV support for now.

At rte_flow layer, there are new items defined for matching type/nexthdr/segments_left field.

Add command line support for IPv6 routing extension header
matching: type/nexthdr/segment_list.

#30 lore raw

Re: [PATCH v5 1/3] ethdev: add IPv6 routing extension header definition

In reply to Rongwei Liu

01/02/2023 12:35, Rongwei Liu:

Quoted 8 lines
lib/net/rte_ip.h +8 -0
+/**
+ * IPv6 Routing Extension Header
+ */
+struct rte_ipv6_routing_ext {
+	uint8_t next_hdr;			/**< Protocol, next header. */
+	uint8_t hdr_len;			/**< Header length. */
+	uint8_t type;				/**< Extension header type. */
+	uint8_t segments_left;			/**< Valid segments number. */

lib/net/rte_ip.h struct rte_ipv6_hdr { · line 559

Quoted 10 lines
lib/net/rte_ip.h +10 -0
+	__extension__
+	union {
+		rte_be32_t flags;		/**< Packet control data per type. */
+		struct {
+			uint8_t last_entry;	/**< The last_entry field of SRH */
+			uint8_t flag;		/**< Packet flag. */
+			rte_be16_t tag;		/**< Packet tag. */
+		};
+	};
+	/** Following variable number of segments. */

Don't use doxygen here as there is no field following.

Wording suggestion:
"Next are 128-bit IPv6 address fields to describe segments."

Quoted 1 line

+} __rte_packed;

#31 lore raw

v6 cover add IPv6 routing extension support

Support IPv6 routing extension header matching with new rte_flow item. Add encapsulation support for IPv6 routing extension header.

v6: use non doxgen style comments for 'segments'.
v5: remove flex array 'segments'.
v4: use flex array to define variable length segments and move PMD
implementation out.
v3: enhance the format and use be32/be16 in network header
structure.
v2: remove redundant rte_flow items.

Rongwei Liu (3):
ethdev: add IPv6 routing extension header definition
ethdev: add modify IPv6 protocol field app/testpmd: add IPv6 routing extension header in raw encap

 app/test-pmd/cmdline_flow.c            | 72 +++++++++++++++++++++++++-
 doc/guides/prog_guide/rte_flow.rst     |  9 ++++
 doc/guides/rel_notes/release_23_03.rst |  9 ++++
 lib/ethdev/rte_flow.c                  |  1 +
 lib/ethdev/rte_flow.h                  | 20 +++++++
 lib/net/rte_ip.h                       | 20 +++++++
 6 files changed, 130 insertions(+), 1 deletion(-)
Signature · 1 line
2.27.0
#32 lore raw

PATCH v6 1/3 ethdev: add IPv6 routing extension header definition

Add IPv6 routing extension header definition and no TLV support for now.

At rte_flow layer, there are new items defined for matching type/nexthdr/segments_left field.

Add command line support for IPv6 routing extension header
matching: type/nexthdr/segment_list.

---
 app/test-pmd/cmdline_flow.c            | 46 ++++++++++++++++++++++++++
 doc/guides/prog_guide/rte_flow.rst     |  9 +++++
 doc/guides/rel_notes/release_23_03.rst |  9 +++++
 lib/ethdev/rte_flow.c                  |  1 +
 lib/ethdev/rte_flow.h                  | 19 +++++++++++
 lib/net/rte_ip.h                       | 20 +++++++++++
 6 files changed, 104 insertions(+)
app/test-pmd/cmdline_flow.c +46 -0
index 88108498e0..7a8516829c 100644
@@ -298,6 +298,10 @@ enum index {
 	ITEM_IPV6_SRC,
 	ITEM_IPV6_DST,
 	ITEM_IPV6_HAS_FRAG_EXT,
+	ITEM_IPV6_ROUTING_EXT,
+	ITEM_IPV6_ROUTING_EXT_TYPE,
+	ITEM_IPV6_ROUTING_EXT_NEXT_HDR,
+	ITEM_IPV6_ROUTING_EXT_SEG_LEFT,
 	ITEM_ICMP,
 	ITEM_ICMP_TYPE,
 	ITEM_ICMP_CODE,
@@ -1326,6 +1330,7 @@ static const enum index next_item[] = {
 	ITEM_ARP_ETH_IPV4,
 	ITEM_IPV6_EXT,
 	ITEM_IPV6_FRAG_EXT,
+	ITEM_IPV6_ROUTING_EXT,
 	ITEM_ICMP6,
 	ITEM_ICMP6_ND_NS,
 	ITEM_ICMP6_ND_NA,
@@ -1435,6 +1440,15 @@ static const enum index item_ipv6[] = {
 	ITEM_IPV6_SRC,
 	ITEM_IPV6_DST,
 	ITEM_IPV6_HAS_FRAG_EXT,
+	ITEM_IPV6_ROUTING_EXT,
+	ITEM_NEXT,
+	ZERO,
+};
+
+static const enum index item_ipv6_routing_ext[] = {
+	ITEM_IPV6_ROUTING_EXT_TYPE,
+	ITEM_IPV6_ROUTING_EXT_NEXT_HDR,
+	ITEM_IPV6_ROUTING_EXT_SEG_LEFT,
 	ITEM_NEXT,
 	ZERO,
 };
@@ -3844,6 +3858,38 @@ static const struct token token_list[] = {
 		.args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_ipv6,
 					   has_frag_ext, 1)),
 	},
+	[ITEM_IPV6_ROUTING_EXT] = {
+		.name = "ipv6_routing_ext",
+		.help = "match IPv6 routing extension header",
+		.priv = PRIV_ITEM(IPV6_ROUTING_EXT,
+				  sizeof(struct rte_flow_item_ipv6_routing_ext)),
+		.next = NEXT(item_ipv6_routing_ext),
+		.call = parse_vc,
+	},
+	[ITEM_IPV6_ROUTING_EXT_TYPE] = {
+		.name = "ext_type",
+		.help = "match IPv6 routing extension header type",
+		.next = NEXT(item_ipv6_routing_ext, NEXT_ENTRY(COMMON_UNSIGNED),
+			     item_param),
+		.args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6_routing_ext,
+					     hdr.type)),
+	},
+	[ITEM_IPV6_ROUTING_EXT_NEXT_HDR] = {
+		.name = "ext_next_hdr",
+		.help = "match IPv6 routing extension header next header type",
+		.next = NEXT(item_ipv6_routing_ext, NEXT_ENTRY(COMMON_UNSIGNED),
+			     item_param),
+		.args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6_routing_ext,
+					     hdr.next_hdr)),
+	},
+	[ITEM_IPV6_ROUTING_EXT_SEG_LEFT] = {
+		.name = "ext_seg_left",
+		.help = "match IPv6 routing extension header segment left",
+		.next = NEXT(item_ipv6_routing_ext, NEXT_ENTRY(COMMON_UNSIGNED),
+			     item_param),
+		.args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6_routing_ext,
+					     hdr.segments_left)),
+	},
 	[ITEM_ICMP] = {
 		.name = "icmp",
 		.help = "match ICMP header",
doc/guides/prog_guide/rte_flow.rst +9 -0
index 3e6242803d..602fab29d3 100644
@@ -1544,6 +1544,15 @@ Matches Color Marker set by a Meter.
 
 - ``color``: Metering color marker.
 
+Item: ``IPV6_ROUTING_EXT``
+^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+Matches IPv6 routing extension header.
+
+- ``next_hdr``: Next layer header type.
+- ``type``: IPv6 routing extension header type.
+- ``segments_left``: How many IPv6 destination addresses carries on.
+
 Actions
 ~~~~~~~
 
doc/guides/rel_notes/release_23_03.rst +9 -0
index c15f6fbb9f..1337da73b8 100644
@@ -69,6 +69,11 @@ New Features
     ``rte_event_dev_config::nb_single_link_event_port_queues`` parameter
     required for eth_rx, eth_tx, crypto and timer eventdev adapters.
 
+* **Added rte_flow support for matching IPv6 routing extension header fields.**
+
+  Added ``ipv6_routing_ext`` items in rte_flow to match IPv6 routing extension
+  header.
+
 
 Removed Items
 -------------
@@ -98,6 +103,10 @@ API Changes
    Also, make sure to start the actual text at the margin.
    =======================================================
 
+* net: added a new structure:
+
+    - IPv6 routing extension header ``rte_ipv6_routing_ext``.
+
 
 ABI Changes
 -----------
lib/ethdev/rte_flow.c +1 -0
index 7d0c24366c..4da581146e 100644
@@ -157,6 +157,7 @@ static const struct rte_flow_desc_data rte_flow_desc_item[] = {
 	MK_FLOW_ITEM(L2TPV2, sizeof(struct rte_flow_item_l2tpv2)),
 	MK_FLOW_ITEM(PPP, sizeof(struct rte_flow_item_ppp)),
 	MK_FLOW_ITEM(METER_COLOR, sizeof(struct rte_flow_item_meter_color)),
+	MK_FLOW_ITEM(IPV6_ROUTING_EXT, sizeof(struct rte_flow_item_ipv6_routing_ext)),
 };
 
 /** Generate flow_action[] entry. */
lib/ethdev/rte_flow.h +19 -0
index b60987db4b..9b9018cba2 100644
@@ -624,6 +624,13 @@ enum rte_flow_item_type {
 	 * See struct rte_flow_item_meter_color.
 	 */
 	RTE_FLOW_ITEM_TYPE_METER_COLOR,
+
+	/**
+	 * Matches the presence of IPv6 routing extension header.
+	 *
+	 * @see struct rte_flow_item_ipv6_routing_ext.
+	 */
+	RTE_FLOW_ITEM_TYPE_IPV6_ROUTING_EXT,
 };
 
 /**
@@ -873,6 +880,18 @@ struct rte_flow_item_ipv6 {
 	uint32_t reserved:23;
 };
 
+/**
+ * @warning
+ * @b EXPERIMENTAL: this structure may change without prior notice
+ *
+ * RTE_FLOW_ITEM_TYPE_IPV6_ROUTING_EXT.
+ *
+ * Matches an IPv6 routing extension header.
+ */
+struct rte_flow_item_ipv6_routing_ext {
+	struct rte_ipv6_routing_ext hdr;
+};
+
 /** Default mask for RTE_FLOW_ITEM_TYPE_IPV6. */
 #ifndef __cplusplus
 static const struct rte_flow_item_ipv6 rte_flow_item_ipv6_mask = {
lib/net/rte_ip.h +20 -0
index 9c8e8206f0..a310e9d498 100644
@@ -539,6 +539,26 @@ struct rte_ipv6_hdr {
 	uint8_t  dst_addr[16];	/**< IP address of destination host(s). */
 } __rte_packed;
 
+/**
+ * IPv6 Routing Extension Header
+ */
+struct rte_ipv6_routing_ext {
+	uint8_t next_hdr;			/**< Protocol, next header. */
+	uint8_t hdr_len;			/**< Header length. */
+	uint8_t type;				/**< Extension header type. */
+	uint8_t segments_left;			/**< Valid segments number. */
+	__extension__
+	union {
+		rte_be32_t flags;		/**< Packet control data per type. */
+		struct {
+			uint8_t last_entry;	/**< The last_entry field of SRH */
+			uint8_t flag;		/**< Packet flag. */
+			rte_be16_t tag;		/**< Packet tag. */
+		};
+	};
+	/* Next are 128-bit IPv6 address fields to describe segments. */
+} __rte_packed;
+
 /* IPv6 vtc_flow: IPv / TC / flow_label */
 #define RTE_IPV6_HDR_FL_SHIFT 0
 #define RTE_IPV6_HDR_TC_SHIFT 20
Signature · 1 line
2.27.0
#33 lore raw

PATCH v6 2/3 ethdev: add modify IPv6 protocol field

In reply to Rongwei Liu

Add IPv6 protocol modify field definition.

Add new modify field destination type string: "ipv6_proto".

---
 app/test-pmd/cmdline_flow.c | 3 ++-
 lib/ethdev/rte_flow.h       | 1 +
 2 files changed, 3 insertions(+), 1 deletion(-)
app/test-pmd/cmdline_flow.c +2 -1
index 7a8516829c..b8156ebca2 100644
@@ -811,7 +811,8 @@ static const char *const modify_field_ids[] = {
 	"udp_port_src", "udp_port_dst",
 	"vxlan_vni", "geneve_vni", "gtp_teid",
 	"tag", "mark", "meta", "pointer", "value",
-	"ipv4_ecn", "ipv6_ecn", "gtp_psc_qfi", "meter_color", NULL
+	"ipv4_ecn", "ipv6_ecn", "gtp_psc_qfi", "meter_color",
+	"ipv6_proto", NULL
 };
 
 static const char *const meter_colors[] = {
lib/ethdev/rte_flow.h +1 -0
index 9b9018cba2..f4797682b7 100644
@@ -3547,6 +3547,7 @@ enum rte_flow_field_id {
 	RTE_FLOW_FIELD_IPV6_ECN,	/**< IPv6 ECN. */
 	RTE_FLOW_FIELD_GTP_PSC_QFI,	/**< GTP QFI. */
 	RTE_FLOW_FIELD_METER_COLOR,	/**< Meter color marker. */
+	RTE_FLOW_FIELD_IPV6_PROTO,	/**< IPv6 next header. */
 };
 
 /**
Signature · 1 line
2.27.0
#34 lore raw

PATCH v6 3/3 app/testpmd: add IPv6 routing extension header in raw encap

In reply to Rongwei Liu

Add IPv6 routing extension header support in raw_encap command.
1. No TLV support now.
2. Assume header length equals to the current segment_left.

---
 app/test-pmd/cmdline_flow.c | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)
app/test-pmd/cmdline_flow.c +23 -0
index b8156ebca2..1340cf3a9b 100644
@@ -10926,6 +10926,13 @@ flow_item_default_mask(const struct rte_flow_item *item)
 {
 	const void *mask = NULL;
 	static rte_be32_t gre_key_default_mask = RTE_BE32(UINT32_MAX);
+	static struct rte_flow_item_ipv6_routing_ext ipv6_routing_ext_default_mask = {
+		.hdr = {
+			.next_hdr = 0xff,
+			.type = 0xff,
+			.segments_left = 0xff,
+		},
+	};
 
 	switch (item->type) {
 	case RTE_FLOW_ITEM_TYPE_ANY:
@@ -11028,6 +11035,9 @@ flow_item_default_mask(const struct rte_flow_item *item)
 	case RTE_FLOW_ITEM_TYPE_METER_COLOR:
 		mask = &rte_flow_item_meter_color_mask;
 		break;
+	case RTE_FLOW_ITEM_TYPE_IPV6_ROUTING_EXT:
+		mask = &ipv6_routing_ext_default_mask;
+		break;
 	default:
 		break;
 	}
@@ -11182,6 +11192,7 @@ cmd_set_raw_parsed(const struct buffer *in)
 	for (i = n - 1 ; i >= 0; --i) {
 		const struct rte_flow_item_gtp *gtp;
 		const struct rte_flow_item_geneve_opt *opt;
+		struct rte_flow_item_ipv6_routing_ext *ext;
 
 		item = in->args.vc.pattern + i;
 		if (item->spec == NULL)
@@ -11202,6 +11213,18 @@ cmd_set_raw_parsed(const struct buffer *in)
 			size = sizeof(struct rte_ipv6_hdr);
 			proto = RTE_ETHER_TYPE_IPV6;
 			break;
+		case RTE_FLOW_ITEM_TYPE_IPV6_ROUTING_EXT:
+			ext = (struct rte_flow_item_ipv6_routing_ext *)(uintptr_t)item->spec;
+			if (!ext->hdr.hdr_len) {
+				size = sizeof(struct rte_ipv6_routing_ext) +
+					(ext->hdr.segments_left << 4);
+				ext->hdr.hdr_len = ext->hdr.segments_left << 1;
+			} else {
+				size = sizeof(struct rte_ipv6_routing_ext) +
+					(ext->hdr.hdr_len << 3);
+			}
+			proto = IPPROTO_ROUTING;
+			break;
 		case RTE_FLOW_ITEM_TYPE_UDP:
 			size = sizeof(struct rte_udp_hdr);
 			proto = 0x11;
Signature · 1 line
2.27.0
#35 lore raw

Re: [PATCH v6 0/3] add IPv6 routing extension support

In reply to Rongwei Liu
Quoted 11 lines · Rongwei Liu

Support IPv6 routing extension header matching with new rte_flow item. Add encapsulation support for IPv6 routing extension header.

v6: use non doxgen style comments for 'segments'.
v5: remove flex array 'segments'.
v4: use flex array to define variable length segments and move PMD
implementation out.
v3: enhance the format and use be32/be16 in network header
structure.
v2: remove redundant rte_flow items.

Quoted 4 lines

Rongwei Liu (3):
ethdev: add IPv6 routing extension header definition
ethdev: add modify IPv6 protocol field app/testpmd: add IPv6 routing extension header in raw encap

Series applied to dpdk-next-net/main, thanks.

#36 lore raw

PATCH v5 2/3 ethdev: add modify IPv6 protocol field

In reply to Rongwei Liu

Add IPv6 protocol modify field definition.

Add new modify field destination type string: "ipv6_proto".

---
 app/test-pmd/cmdline_flow.c | 3 ++-
 lib/ethdev/rte_flow.h       | 1 +
 2 files changed, 3 insertions(+), 1 deletion(-)
app/test-pmd/cmdline_flow.c +2 -1
index 7a8516829c..b8156ebca2 100644
@@ -811,7 +811,8 @@ static const char *const modify_field_ids[] = {
 	"udp_port_src", "udp_port_dst",
 	"vxlan_vni", "geneve_vni", "gtp_teid",
 	"tag", "mark", "meta", "pointer", "value",
-	"ipv4_ecn", "ipv6_ecn", "gtp_psc_qfi", "meter_color", NULL
+	"ipv4_ecn", "ipv6_ecn", "gtp_psc_qfi", "meter_color",
+	"ipv6_proto", NULL
 };
 
 static const char *const meter_colors[] = {
lib/ethdev/rte_flow.h +1 -0
index 9b9018cba2..f4797682b7 100644
@@ -3547,6 +3547,7 @@ enum rte_flow_field_id {
 	RTE_FLOW_FIELD_IPV6_ECN,	/**< IPv6 ECN. */
 	RTE_FLOW_FIELD_GTP_PSC_QFI,	/**< GTP QFI. */
 	RTE_FLOW_FIELD_METER_COLOR,	/**< Meter color marker. */
+	RTE_FLOW_FIELD_IPV6_PROTO,	/**< IPv6 next header. */
 };
 
 /**
Signature · 1 line
2.27.0
#38 lore raw

Re: [PATCH v5 2/3] ethdev: add modify IPv6 protocol field

In reply to Rongwei Liu

app/test-pmd/cmdline_flow.c static const char *const modify_field_ids[] = { · line 817

Quoted 13 lines · On Wed, 1 Feb 2023 13:35:10 +0200 Rongwei Liu <[email protected]> wrote:
app/test-pmd/cmdline_flow.c +2 -1
index 7a8516829c..b8156ebca2 100644
@@ -811,7 +811,8 @@ static const char *const modify_field_ids[] = {
 	"udp_port_src", "udp_port_dst",
 	"vxlan_vni", "geneve_vni", "gtp_teid",
 	"tag", "mark", "meta", "pointer", "value",
-	"ipv4_ecn", "ipv6_ecn", "gtp_psc_qfi", "meter_color", NULL
+	"ipv4_ecn", "ipv6_ecn", "gtp_psc_qfi", "meter_color",
+	"ipv6_proto", NULL
 };
 

Would it be better to keep the table in alphabetical order here?

#39 lore raw

RE: [PATCH v5 2/3] ethdev: add modify IPv6 protocol field

Hi Stephen

BR
Rongwei

Quoted 18 lines

-----Original Message-----
From: Stephen Hemminger <[email protected]>
Sent: Thursday, February 2, 2023 00:56
To: Rongwei Liu <[email protected]>
Cc: [email protected]; Matan Azrad <[email protected]>; Slava Ovsiienko <[email protected]>; Ori Kam <[email protected]>; NBU-Contact- Thomas Monjalon (EXTERNAL) <[email protected]>; Raslan Darawsheh <[email protected]>; Aman Singh <[email protected]>; Yuying Zhang <[email protected]>; Ferruh Yigit <[email protected]>; Andrew Rybchenko <[email protected]>
Subject: Re: [PATCH v5 2/3] ethdev: add modify IPv6 protocol field

External email: Use caution opening links or attachments

On Wed, 1 Feb 2023 13:35:10 +0200
Rongwei Liu <[email protected]> wrote:

Quoted 15 lines

app/test-pmd/cmdline_flow.c static const char *const modify_field_ids[] = { · line 817

Quoted 13 lines
app/test-pmd/cmdline_flow.c +2 -1
index 7a8516829c..b8156ebca2 100644
@@ -811,7 +811,8 @@ static const char *const modify_field_ids[] = {
      "udp_port_src", "udp_port_dst",
      "vxlan_vni", "geneve_vni", "gtp_teid",
      "tag", "mark", "meta", "pointer", "value",
-     "ipv4_ecn", "ipv6_ecn", "gtp_psc_qfi", "meter_color", NULL
+     "ipv4_ecn", "ipv6_ecn", "gtp_psc_qfi", "meter_color",
+     "ipv6_proto", NULL
 };
 

Would it be better to keep the table in alphabetical order here?

There are two arrays related to modify_filed resources: one for enumeration definition and the other is string for testpmd cli. The sequence is strictly same.
" keep the table in alphabetical " needs to change both the array and make sure the new comer is the same index. IMO, current approach is more friendly for new coming fields.

#40 lore raw

PATCH v5 3/3 app/testpmd: add IPv6 routing extension header in raw encap

In reply to Rongwei Liu

Add IPv6 routing extension header support in raw_encap command.
1. No TLV support now.
2. Assume header length equals to the current segment_left.

---
 app/test-pmd/cmdline_flow.c | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)
app/test-pmd/cmdline_flow.c +23 -0
index b8156ebca2..1340cf3a9b 100644
@@ -10926,6 +10926,13 @@ flow_item_default_mask(const struct rte_flow_item *item)
 {
 	const void *mask = NULL;
 	static rte_be32_t gre_key_default_mask = RTE_BE32(UINT32_MAX);
+	static struct rte_flow_item_ipv6_routing_ext ipv6_routing_ext_default_mask = {
+		.hdr = {
+			.next_hdr = 0xff,
+			.type = 0xff,
+			.segments_left = 0xff,
+		},
+	};
 
 	switch (item->type) {
 	case RTE_FLOW_ITEM_TYPE_ANY:
@@ -11028,6 +11035,9 @@ flow_item_default_mask(const struct rte_flow_item *item)
 	case RTE_FLOW_ITEM_TYPE_METER_COLOR:
 		mask = &rte_flow_item_meter_color_mask;
 		break;
+	case RTE_FLOW_ITEM_TYPE_IPV6_ROUTING_EXT:
+		mask = &ipv6_routing_ext_default_mask;
+		break;
 	default:
 		break;
 	}
@@ -11182,6 +11192,7 @@ cmd_set_raw_parsed(const struct buffer *in)
 	for (i = n - 1 ; i >= 0; --i) {
 		const struct rte_flow_item_gtp *gtp;
 		const struct rte_flow_item_geneve_opt *opt;
+		struct rte_flow_item_ipv6_routing_ext *ext;
 
 		item = in->args.vc.pattern + i;
 		if (item->spec == NULL)
@@ -11202,6 +11213,18 @@ cmd_set_raw_parsed(const struct buffer *in)
 			size = sizeof(struct rte_ipv6_hdr);
 			proto = RTE_ETHER_TYPE_IPV6;
 			break;
+		case RTE_FLOW_ITEM_TYPE_IPV6_ROUTING_EXT:
+			ext = (struct rte_flow_item_ipv6_routing_ext *)(uintptr_t)item->spec;
+			if (!ext->hdr.hdr_len) {
+				size = sizeof(struct rte_ipv6_routing_ext) +
+					(ext->hdr.segments_left << 4);
+				ext->hdr.hdr_len = ext->hdr.segments_left << 1;
+			} else {
+				size = sizeof(struct rte_ipv6_routing_ext) +
+					(ext->hdr.hdr_len << 3);
+			}
+			proto = IPPROTO_ROUTING;
+			break;
 		case RTE_FLOW_ITEM_TYPE_UDP:
 			size = sizeof(struct rte_udp_hdr);
 			proto = 0x11;
Signature · 1 line
2.27.0
#41 lore raw

PATCH v4 2/3 ethdev: add modify IPv6 protocol field

In reply to Rongwei Liu

Add IPv6 protocol modify field definition.

Add new modify field destination type string: "ipv6_proto".

---
 app/test-pmd/cmdline_flow.c | 3 ++-
 lib/ethdev/rte_flow.h       | 1 +
 2 files changed, 3 insertions(+), 1 deletion(-)
app/test-pmd/cmdline_flow.c +2 -1
index 7a8516829c..b8156ebca2 100644
@@ -811,7 +811,8 @@ static const char *const modify_field_ids[] = {
 	"udp_port_src", "udp_port_dst",
 	"vxlan_vni", "geneve_vni", "gtp_teid",
 	"tag", "mark", "meta", "pointer", "value",
-	"ipv4_ecn", "ipv6_ecn", "gtp_psc_qfi", "meter_color", NULL
+	"ipv4_ecn", "ipv6_ecn", "gtp_psc_qfi", "meter_color",
+	"ipv6_proto", NULL
 };
 
 static const char *const meter_colors[] = {
lib/ethdev/rte_flow.h +1 -0
index ff9270690c..70b910b73a 100644
@@ -3549,6 +3549,7 @@ enum rte_flow_field_id {
 	RTE_FLOW_FIELD_IPV6_ECN,	/**< IPv6 ECN. */
 	RTE_FLOW_FIELD_GTP_PSC_QFI,	/**< GTP QFI. */
 	RTE_FLOW_FIELD_METER_COLOR,	/**< Meter color marker. */
+	RTE_FLOW_FIELD_IPV6_PROTO,	/**< IPv6 next header. */
 };
 
 /**
Signature · 1 line
2.27.0
#43 lore raw

PATCH v4 3/3 app/testpmd: add IPv6 routing extension header in raw encap

In reply to Rongwei Liu

Add IPv6 routing extension header support in raw_encap command.
1. No TLV support now.
2. Assume header length equals to the current segment_left.

---
 app/test-pmd/cmdline_flow.c | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)
app/test-pmd/cmdline_flow.c +23 -0
index b8156ebca2..1340cf3a9b 100644
@@ -10926,6 +10926,13 @@ flow_item_default_mask(const struct rte_flow_item *item)
 {
 	const void *mask = NULL;
 	static rte_be32_t gre_key_default_mask = RTE_BE32(UINT32_MAX);
+	static struct rte_flow_item_ipv6_routing_ext ipv6_routing_ext_default_mask = {
+		.hdr = {
+			.next_hdr = 0xff,
+			.type = 0xff,
+			.segments_left = 0xff,
+		},
+	};
 
 	switch (item->type) {
 	case RTE_FLOW_ITEM_TYPE_ANY:
@@ -11028,6 +11035,9 @@ flow_item_default_mask(const struct rte_flow_item *item)
 	case RTE_FLOW_ITEM_TYPE_METER_COLOR:
 		mask = &rte_flow_item_meter_color_mask;
 		break;
+	case RTE_FLOW_ITEM_TYPE_IPV6_ROUTING_EXT:
+		mask = &ipv6_routing_ext_default_mask;
+		break;
 	default:
 		break;
 	}
@@ -11182,6 +11192,7 @@ cmd_set_raw_parsed(const struct buffer *in)
 	for (i = n - 1 ; i >= 0; --i) {
 		const struct rte_flow_item_gtp *gtp;
 		const struct rte_flow_item_geneve_opt *opt;
+		struct rte_flow_item_ipv6_routing_ext *ext;
 
 		item = in->args.vc.pattern + i;
 		if (item->spec == NULL)
@@ -11202,6 +11213,18 @@ cmd_set_raw_parsed(const struct buffer *in)
 			size = sizeof(struct rte_ipv6_hdr);
 			proto = RTE_ETHER_TYPE_IPV6;
 			break;
+		case RTE_FLOW_ITEM_TYPE_IPV6_ROUTING_EXT:
+			ext = (struct rte_flow_item_ipv6_routing_ext *)(uintptr_t)item->spec;
+			if (!ext->hdr.hdr_len) {
+				size = sizeof(struct rte_ipv6_routing_ext) +
+					(ext->hdr.segments_left << 4);
+				ext->hdr.hdr_len = ext->hdr.segments_left << 1;
+			} else {
+				size = sizeof(struct rte_ipv6_routing_ext) +
+					(ext->hdr.hdr_len << 3);
+			}
+			proto = IPPROTO_ROUTING;
+			break;
 		case RTE_FLOW_ITEM_TYPE_UDP:
 			size = sizeof(struct rte_udp_hdr);
 			proto = 0x11;
Signature · 1 line
2.27.0
#44 lore raw

PATCH v3 2/8 net/mlx5: adopt IPv6 routing extension prm definition

In reply to Rongwei Liu

Per newest PRM definition, sample_id stands for 3 parts of information instead of single uint32_t id: sample_id + modify_filed_id + format_select_dw.

Also new FW capability bits have been introduces to identify the new capability.

---
 drivers/common/mlx5/mlx5_devx_cmds.c | 14 +++++++++++---
 drivers/common/mlx5/mlx5_devx_cmds.h |  7 ++++++-
 drivers/common/mlx5/mlx5_prm.h       | 28 ++++++++++++++++++++++++++--
 drivers/net/mlx5/mlx5.c              | 15 +++++++++++----
 drivers/net/mlx5/mlx5.h              |  3 ++-
 drivers/net/mlx5/mlx5_flow_flex.c    | 14 +++++++++++---
 6 files changed, 67 insertions(+), 14 deletions(-)
drivers/common/mlx5/mlx5_devx_cmds.c +11 -3
index e3a4927d0f..1f65ea7dcb 100644
@@ -607,7 +607,8 @@ mlx5_devx_cmd_query_hca_vdpa_attr(void *ctx,
 
 int
 mlx5_devx_cmd_query_parse_samples(struct mlx5_devx_obj *flex_obj,
-				  uint32_t ids[], uint32_t num)
+				  struct mlx5_ext_sample_id ids[],
+				  uint32_t num, uint8_t *anchor)
 {
 	uint32_t in[MLX5_ST_SZ_DW(general_obj_in_cmd_hdr)] = {0};
 	uint32_t out[MLX5_ST_SZ_DW(create_flex_parser_out)] = {0};
@@ -636,6 +637,7 @@ mlx5_devx_cmd_query_parse_samples(struct mlx5_devx_obj *flex_obj,
 			(void *)flex_obj);
 		return -rte_errno;
 	}
+	*anchor = MLX5_GET(parse_graph_flex, flex, head_anchor_id);
 	for (i = 0; i < MLX5_GRAPH_NODE_SAMPLE_NUM; i++) {
 		void *s_off = (void *)((char *)sample + i *
 			      MLX5_ST_SZ_BYTES(parse_graph_flow_match_sample));
@@ -645,8 +647,8 @@ mlx5_devx_cmd_query_parse_samples(struct mlx5_devx_obj *flex_obj,
 			      flow_match_sample_en);
 		if (!en)
 			continue;
-		ids[idx++] = MLX5_GET(parse_graph_flow_match_sample, s_off,
-				  flow_match_sample_field_id);
+		ids[idx++].id = MLX5_GET(parse_graph_flow_match_sample, s_off,
+					 flow_match_sample_field_id);
 	}
 	if (num != idx) {
 		rte_errno = EINVAL;
@@ -794,6 +796,12 @@ mlx5_devx_cmd_query_hca_parse_graph_node_cap
 					 max_num_arc_out);
 	attr->max_num_sample = MLX5_GET(parse_graph_node_cap, hcattr,
 					max_num_sample);
+	attr->anchor_en = MLX5_GET(parse_graph_node_cap, hcattr, anchor_en);
+	attr->ext_sample_id = MLX5_GET(parse_graph_node_cap, hcattr, ext_sample_id);
+	attr->sample_tunnel_inner2 = MLX5_GET(parse_graph_node_cap, hcattr,
+					      sample_tunnel_inner2);
+	attr->zero_size_supported = MLX5_GET(parse_graph_node_cap, hcattr,
+					     zero_size_supported);
 	attr->sample_id_in_out = MLX5_GET(parse_graph_node_cap, hcattr,
 					  sample_id_in_out);
 	attr->max_base_header_length = MLX5_GET(parse_graph_node_cap, hcattr,
drivers/common/mlx5/mlx5_devx_cmds.h +6 -1
index c94b9eac06..5b33010155 100644
@@ -114,6 +114,10 @@ struct mlx5_hca_flex_attr {
 	uint8_t  max_num_arc_out;
 	uint8_t  max_num_sample;
 	uint8_t  max_num_prog_sample:5;	/* From HCA CAP 2 */
+	uint8_t  anchor_en:1;
+	uint8_t  ext_sample_id:1;
+	uint8_t  sample_tunnel_inner2:1;
+	uint8_t  zero_size_supported:1;
 	uint8_t  sample_id_in_out:1;
 	uint16_t max_base_header_length;
 	uint8_t  max_sample_base_offset;
@@ -706,7 +710,8 @@ int mlx5_devx_cmd_modify_tir(struct mlx5_devx_obj *tir,
 			     struct mlx5_devx_modify_tir_attr *tir_attr);
 __rte_internal
 int mlx5_devx_cmd_query_parse_samples(struct mlx5_devx_obj *flex_obj,
-				      uint32_t ids[], uint32_t num);
+				      struct mlx5_ext_sample_id ids[],
+				      uint32_t num, uint8_t *anchor);
 
 __rte_internal
 struct mlx5_devx_obj *
drivers/common/mlx5/mlx5_prm.h +26 -2
index 3790dc84b8..ce6cd98fd7 100644
@@ -1893,7 +1893,11 @@ struct mlx5_ifc_parse_graph_node_cap_bits {
 	u8 max_num_arc_in[0x08];
 	u8 max_num_arc_out[0x08];
 	u8 max_num_sample[0x08];
-	u8 reserved_at_78[0x07];
+	u8 reserved_at_78[0x03];
+	u8 anchor_en[0x1];
+	u8 ext_sample_id[0x1];
+	u8 sample_tunnel_inner2[0x1];
+	u8 zero_size_supported[0x1];
 	u8 sample_id_in_out[0x1];
 	u8 max_base_header_length[0x10];
 	u8 reserved_at_90[0x08];
@@ -1903,6 +1907,24 @@ struct mlx5_ifc_parse_graph_node_cap_bits {
 	u8 header_length_mask_width[0x08];
 };
 
+/* ext_sample_id structure, see PRM Table: Flow Match Sample ID Format. */
+struct mlx5_ext_sample_id {
+	union {
+		struct {
+#if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
+			uint32_t format_select_dw:8;
+			uint32_t modify_field_id:12;
+			uint32_t sample_id:12;
+#else
+			uint32_t sample_id:12;
+			uint32_t modify_field_id:12;
+			uint32_t format_select_dw:8;
+#endif
+		};
+		uint32_t id;
+	};
+};
+
 struct mlx5_ifc_flow_table_prop_layout_bits {
 	u8 ft_support[0x1];
 	u8 flow_tag[0x1];
@@ -4522,7 +4544,9 @@ struct mlx5_ifc_parse_graph_flex_bits {
 	u8 header_length_mode[0x4];
 	u8 header_length_field_offset[0x10];
 	u8 next_header_field_offset[0x10];
-	u8 reserved_at_160[0x1b];
+	u8 reserved_at_160[0x12];
+	u8 head_anchor_id[0x6];
+	u8 reserved_at_178[0x3];
 	u8 next_header_field_size[0x5];
 	u8 header_length_field_mask[0x20];
 	u8 reserved_at_224[0x20];
drivers/net/mlx5/mlx5.c +11 -4
index b8643cebdd..0b97c4e78d 100644
@@ -964,11 +964,13 @@ int
 mlx5_flex_parser_ecpri_alloc(struct rte_eth_dev *dev)
 {
 	struct mlx5_priv *priv = dev->data->dev_private;
+	struct mlx5_hca_flex_attr *attr = &priv->sh->cdev->config.hca_attr.flex;
 	struct mlx5_ecpri_parser_profile *prf =	&priv->sh->ecpri_parser;
 	struct mlx5_devx_graph_node_attr node = {
 		.modify_field_select = 0,
 	};
-	uint32_t ids[8];
+	struct mlx5_ext_sample_id ids[8];
+	uint8_t anchor_id;
 	int ret;
 
 	if (!priv->sh->cdev->config.hca_attr.parse_graph_flex_node) {
@@ -1004,15 +1006,20 @@ mlx5_flex_parser_ecpri_alloc(struct rte_eth_dev *dev)
 		return (rte_errno == 0) ? -ENODEV : -rte_errno;
 	}
 	prf->num = 2;
-	ret = mlx5_devx_cmd_query_parse_samples(prf->obj, ids, prf->num);
+	ret = mlx5_devx_cmd_query_parse_samples(prf->obj, ids, prf->num, &anchor_id);
 	if (ret) {
 		DRV_LOG(ERR, "Failed to query sample IDs.");
 		return (rte_errno == 0) ? -ENODEV : -rte_errno;
 	}
 	prf->offset[0] = 0x0;
 	prf->offset[1] = sizeof(uint32_t);
-	prf->ids[0] = ids[0];
-	prf->ids[1] = ids[1];
+	if (attr->ext_sample_id) {
+		prf->ids[0] = ids[0].sample_id;
+		prf->ids[1] = ids[1].sample_id;
+	} else {
+		prf->ids[0] = ids[0].id;
+		prf->ids[1] = ids[1].id;
+	}
 	return 0;
 }
 
drivers/net/mlx5/mlx5.h +2 -1
index 16b33e1548..83fb316ad8 100644
@@ -1307,9 +1307,10 @@ struct mlx5_lag {
 struct mlx5_flex_parser_devx {
 	struct mlx5_list_entry entry;  /* List element at the beginning. */
 	uint32_t num_samples;
+	uint8_t anchor_id;
 	void *devx_obj;
 	struct mlx5_devx_graph_node_attr devx_conf;
-	uint32_t sample_ids[MLX5_GRAPH_NODE_SAMPLE_NUM];
+	struct mlx5_ext_sample_id sample_ids[MLX5_GRAPH_NODE_SAMPLE_NUM];
 };
 
 /* Pattern field descriptor - how to translate flex pattern into samples. */
drivers/net/mlx5/mlx5_flow_flex.c +11 -3
index fb08910ddb..35f2a9923d 100644
@@ -226,15 +226,18 @@ mlx5_flex_flow_translate_item(struct rte_eth_dev *dev,
 	void *misc4_m = MLX5_ADDR_OF(fte_match_param, matcher,
 				     misc_parameters_4);
 	void *misc4_v = MLX5_ADDR_OF(fte_match_param, key, misc_parameters_4);
+	struct mlx5_priv *priv = dev->data->dev_private;
+	struct mlx5_hca_flex_attr *attr = &priv->sh->cdev->config.hca_attr.flex;
 	struct mlx5_flex_item *tp;
 	uint32_t i, pos = 0;
+	uint32_t sample_id;
 
 	RTE_SET_USED(dev);
 	MLX5_ASSERT(item->spec && item->mask);
 	spec = item->spec;
 	mask = item->mask;
 	tp = (struct mlx5_flex_item *)spec->handle;
-	MLX5_ASSERT(mlx5_flex_index(dev->data->dev_private, tp) >= 0);
+	MLX5_ASSERT(mlx5_flex_index(priv, tp) >= 0);
 	for (i = 0; i < tp->mapnum; i++) {
 		struct mlx5_flex_pattern_field *map = tp->map + i;
 		uint32_t id = map->reg_id;
@@ -257,9 +260,13 @@ mlx5_flex_flow_translate_item(struct rte_eth_dev *dev,
 			MLX5_ASSERT(id < num_samples);
 			id += num_samples;
 		}
+		if (attr->ext_sample_id)
+			sample_id = tp->devx_fp->sample_ids[id].sample_id;
+		else
+			sample_id = tp->devx_fp->sample_ids[id].id;
 		mlx5_flex_set_match_sample(misc4_m, misc4_v,
 					   def, msk & def, val & msk & def,
-					   tp->devx_fp->sample_ids[id], id);
+					   sample_id, id);
 		pos += map->width;
 	}
 }
@@ -1298,7 +1305,8 @@ mlx5_flex_parser_create_cb(void *list_ctx, void *ctx)
 	/* Query the firmware assigned sample ids. */
 	ret = mlx5_devx_cmd_query_parse_samples(fp->devx_obj,
 						fp->sample_ids,
-						fp->num_samples);
+						fp->num_samples,
+						&fp->anchor_id);
 	if (ret)
 		goto error;
 	DRV_LOG(DEBUG, "DEVx flex parser %p created, samples num: %u",
Signature · 1 line
2.27.0
#45 lore raw

PATCH v3 3/8 net/mlx5/hws: Definer, add mlx5dr context to definer_conv_data

In reply to Rongwei Liu

From: Gregory Etelson <[email protected]>

New mlx5dr_context member replaces mlx5dr_cmd_query_caps. Capabilities structure is a member of mlx5dr_context.

---
 drivers/net/mlx5/hws/mlx5dr_definer.c | 42 ++++++++++++++-------------
 1 file changed, 22 insertions(+), 20 deletions(-)
drivers/net/mlx5/hws/mlx5dr_definer.c +22 -20
index 6b98eb8c96..0f1cab7e07 100644
@@ -100,7 +100,7 @@ struct mlx5dr_definer_sel_ctrl {
 };
 
 struct mlx5dr_definer_conv_data {
-	struct mlx5dr_cmd_query_caps *caps;
+	struct mlx5dr_context *ctx;
 	struct mlx5dr_definer_fc *fc;
 	uint8_t relaxed;
 	uint8_t tunnel;
@@ -815,6 +815,7 @@ mlx5dr_definer_conv_item_gtp(struct mlx5dr_definer_conv_data *cd,
 			     struct rte_flow_item *item,
 			     int item_idx)
 {
+	struct mlx5dr_cmd_query_caps *caps = cd->ctx->caps;
 	const struct rte_flow_item_gtp *m = item->mask;
 	struct mlx5dr_definer_fc *fc;
 
@@ -836,7 +837,7 @@ mlx5dr_definer_conv_item_gtp(struct mlx5dr_definer_conv_data *cd,
 	}
 
 	if (m->teid) {
-		if (!(cd->caps->flex_protocols & MLX5_HCA_FLEX_GTPU_TEID_ENABLED)) {
+		if (!(caps->flex_protocols & MLX5_HCA_FLEX_GTPU_TEID_ENABLED)) {
 			rte_errno = ENOTSUP;
 			return rte_errno;
 		}
@@ -844,11 +845,11 @@ mlx5dr_definer_conv_item_gtp(struct mlx5dr_definer_conv_data *cd,
 		fc->item_idx = item_idx;
 		fc->tag_set = &mlx5dr_definer_gtp_teid_set;
 		fc->bit_mask = __mlx5_mask(header_gtp, teid);
-		fc->byte_off = cd->caps->format_select_gtpu_dw_1 * DW_SIZE;
+		fc->byte_off = caps->format_select_gtpu_dw_1 * DW_SIZE;
 	}
 
 	if (m->v_pt_rsv_flags) {
-		if (!(cd->caps->flex_protocols & MLX5_HCA_FLEX_GTPU_DW_0_ENABLED)) {
+		if (!(caps->flex_protocols & MLX5_HCA_FLEX_GTPU_DW_0_ENABLED)) {
 			rte_errno = ENOTSUP;
 			return rte_errno;
 		}
@@ -857,12 +858,12 @@ mlx5dr_definer_conv_item_gtp(struct mlx5dr_definer_conv_data *cd,
 		fc->tag_set = &mlx5dr_definer_gtp_ext_flag_set;
 		fc->bit_mask = __mlx5_mask(header_gtp, ext_hdr_flag);
 		fc->bit_off = __mlx5_dw_bit_off(header_gtp, ext_hdr_flag);
-		fc->byte_off = cd->caps->format_select_gtpu_dw_0 * DW_SIZE;
+		fc->byte_off = caps->format_select_gtpu_dw_0 * DW_SIZE;
 	}
 
 
 	if (m->msg_type) {
-		if (!(cd->caps->flex_protocols & MLX5_HCA_FLEX_GTPU_DW_0_ENABLED)) {
+		if (!(caps->flex_protocols & MLX5_HCA_FLEX_GTPU_DW_0_ENABLED)) {
 			rte_errno = ENOTSUP;
 			return rte_errno;
 		}
@@ -871,7 +872,7 @@ mlx5dr_definer_conv_item_gtp(struct mlx5dr_definer_conv_data *cd,
 		fc->tag_set = &mlx5dr_definer_gtp_msg_type_set;
 		fc->bit_mask = __mlx5_mask(header_gtp, msg_type);
 		fc->bit_off = __mlx5_dw_bit_off(header_gtp, msg_type);
-		fc->byte_off = cd->caps->format_select_gtpu_dw_0 * DW_SIZE;
+		fc->byte_off = caps->format_select_gtpu_dw_0 * DW_SIZE;
 	}
 
 	return 0;
@@ -882,12 +883,13 @@ mlx5dr_definer_conv_item_gtp_psc(struct mlx5dr_definer_conv_data *cd,
 				 struct rte_flow_item *item,
 				 int item_idx)
 {
+	struct mlx5dr_cmd_query_caps *caps = cd->ctx->caps;
 	const struct rte_flow_item_gtp_psc *m = item->mask;
 	struct mlx5dr_definer_fc *fc;
 
 	/* Overwrite GTP extension flag to be 1 */
 	if (!cd->relaxed) {
-		if (!(cd->caps->flex_protocols & MLX5_HCA_FLEX_GTPU_DW_0_ENABLED)) {
+		if (!(caps->flex_protocols & MLX5_HCA_FLEX_GTPU_DW_0_ENABLED)) {
 			rte_errno = ENOTSUP;
 			return rte_errno;
 		}
@@ -896,12 +898,12 @@ mlx5dr_definer_conv_item_gtp_psc(struct mlx5dr_definer_conv_data *cd,
 		fc->tag_set = &mlx5dr_definer_ones_set;
 		fc->bit_mask = __mlx5_mask(header_gtp, ext_hdr_flag);
 		fc->bit_off = __mlx5_dw_bit_off(header_gtp, ext_hdr_flag);
-		fc->byte_off = cd->caps->format_select_gtpu_dw_0 * DW_SIZE;
+		fc->byte_off = caps->format_select_gtpu_dw_0 * DW_SIZE;
 	}
 
 	/* Overwrite next extension header type */
 	if (!cd->relaxed) {
-		if (!(cd->caps->flex_protocols & MLX5_HCA_FLEX_GTPU_DW_2_ENABLED)) {
+		if (!(caps->flex_protocols & MLX5_HCA_FLEX_GTPU_DW_2_ENABLED)) {
 			rte_errno = ENOTSUP;
 			return rte_errno;
 		}
@@ -911,14 +913,14 @@ mlx5dr_definer_conv_item_gtp_psc(struct mlx5dr_definer_conv_data *cd,
 		fc->tag_mask_set = &mlx5dr_definer_ones_set;
 		fc->bit_mask = __mlx5_mask(header_opt_gtp, next_ext_hdr_type);
 		fc->bit_off = __mlx5_dw_bit_off(header_opt_gtp, next_ext_hdr_type);
-		fc->byte_off = cd->caps->format_select_gtpu_dw_2 * DW_SIZE;
+		fc->byte_off = caps->format_select_gtpu_dw_2 * DW_SIZE;
 	}
 
 	if (!m)
 		return 0;
 
 	if (m->hdr.type) {
-		if (!(cd->caps->flex_protocols & MLX5_HCA_FLEX_GTPU_FIRST_EXT_DW_0_ENABLED)) {
+		if (!(caps->flex_protocols & MLX5_HCA_FLEX_GTPU_FIRST_EXT_DW_0_ENABLED)) {
 			rte_errno = ENOTSUP;
 			return rte_errno;
 		}
@@ -927,11 +929,11 @@ mlx5dr_definer_conv_item_gtp_psc(struct mlx5dr_definer_conv_data *cd,
 		fc->tag_set = &mlx5dr_definer_gtp_ext_hdr_pdu_set;
 		fc->bit_mask = __mlx5_mask(header_gtp_psc, pdu_type);
 		fc->bit_off = __mlx5_dw_bit_off(header_gtp_psc, pdu_type);
-		fc->byte_off = cd->caps->format_select_gtpu_ext_dw_0 * DW_SIZE;
+		fc->byte_off = caps->format_select_gtpu_ext_dw_0 * DW_SIZE;
 	}
 
 	if (m->hdr.qfi) {
-		if (!(cd->caps->flex_protocols & MLX5_HCA_FLEX_GTPU_FIRST_EXT_DW_0_ENABLED)) {
+		if (!(caps->flex_protocols & MLX5_HCA_FLEX_GTPU_FIRST_EXT_DW_0_ENABLED)) {
 			rte_errno = ENOTSUP;
 			return rte_errno;
 		}
@@ -940,7 +942,7 @@ mlx5dr_definer_conv_item_gtp_psc(struct mlx5dr_definer_conv_data *cd,
 		fc->tag_set = &mlx5dr_definer_gtp_ext_hdr_qfi_set;
 		fc->bit_mask = __mlx5_mask(header_gtp_psc, qfi);
 		fc->bit_off = __mlx5_dw_bit_off(header_gtp_psc, qfi);
-		fc->byte_off = cd->caps->format_select_gtpu_ext_dw_0 * DW_SIZE;
+		fc->byte_off = caps->format_select_gtpu_ext_dw_0 * DW_SIZE;
 	}
 
 	return 0;
@@ -951,18 +953,19 @@ mlx5dr_definer_conv_item_port(struct mlx5dr_definer_conv_data *cd,
 			      struct rte_flow_item *item,
 			      int item_idx)
 {
+	struct mlx5dr_cmd_query_caps *caps = cd->ctx->caps;
 	const struct rte_flow_item_ethdev *m = item->mask;
 	struct mlx5dr_definer_fc *fc;
 	uint8_t bit_offset = 0;
 
 	if (m->port_id) {
-		if (!cd->caps->wire_regc_mask) {
+		if (!caps->wire_regc_mask) {
 			DR_LOG(ERR, "Port ID item not supported, missing wire REGC mask");
 			rte_errno = ENOTSUP;
 			return rte_errno;
 		}
 
-		while (!(cd->caps->wire_regc_mask & (1 << bit_offset)))
+		while (!(caps->wire_regc_mask & (1 << bit_offset)))
 			bit_offset++;
 
 		fc = &cd->fc[MLX5DR_DEFINER_FNAME_VPORT_REG_C_0];
@@ -971,7 +974,7 @@ mlx5dr_definer_conv_item_port(struct mlx5dr_definer_conv_data *cd,
 		fc->tag_mask_set = &mlx5dr_definer_ones_set;
 		DR_CALC_SET_HDR(fc, registers, register_c_0);
 		fc->bit_off = bit_offset;
-		fc->bit_mask = cd->caps->wire_regc_mask >> bit_offset;
+		fc->bit_mask = caps->wire_regc_mask >> bit_offset;
 	} else {
 		DR_LOG(ERR, "Pord ID item mask must specify ID mask");
 		rte_errno = EINVAL;
@@ -1479,8 +1482,7 @@ mlx5dr_definer_conv_items_to_hl(struct mlx5dr_context *ctx,
 	int ret;
 
 	cd.fc = fc;
-	cd.hl = hl;
-	cd.caps = ctx->caps;
+	cd.ctx = ctx;
 	cd.relaxed = mt->flags & MLX5DR_MATCH_TEMPLATE_FLAG_RELAXED_MATCH;
 
 	/* Collect all RTE fields to the field array and set header layout */
Signature · 1 line
2.27.0
#46 lore raw

PATCH v3 4/8 net/mlx5/hws: add IPv6 routing extension matching support

In reply to Rongwei Liu

Add mlx5 HWS logic to match IPv6 routing extension header.

Once detecting IPv6 matching extension items in pattern template create callback, PMD allocates a flex parser to sample the first dword of srv6 header.

Only support next_hdr/segments_left/type for now.

---
 drivers/common/mlx5/mlx5_devx_cmds.c  |  7 +-
 drivers/net/mlx5/hws/mlx5dr_definer.c | 91 ++++++++++++++++++++++++++
 drivers/net/mlx5/hws/mlx5dr_definer.h | 15 +++++
 drivers/net/mlx5/mlx5.c               | 92 ++++++++++++++++++++++++++-
 drivers/net/mlx5/mlx5.h               | 16 +++++
 drivers/net/mlx5/mlx5_flow.h          | 28 ++++++++
 drivers/net/mlx5/mlx5_flow_hw.c       | 29 +++++++--
 7 files changed, 268 insertions(+), 10 deletions(-)
drivers/common/mlx5/mlx5_devx_cmds.c +4 -3
index 1f65ea7dcb..22a94c1e1a 100644
@@ -607,7 +607,7 @@ mlx5_devx_cmd_query_hca_vdpa_attr(void *ctx,
 
 int
 mlx5_devx_cmd_query_parse_samples(struct mlx5_devx_obj *flex_obj,
-				  struct mlx5_ext_sample_id ids[],
+				  struct mlx5_ext_sample_id *ids,
 				  uint32_t num, uint8_t *anchor)
 {
 	uint32_t in[MLX5_ST_SZ_DW(general_obj_in_cmd_hdr)] = {0};
@@ -637,8 +637,9 @@ mlx5_devx_cmd_query_parse_samples(struct mlx5_devx_obj *flex_obj,
 			(void *)flex_obj);
 		return -rte_errno;
 	}
-	*anchor = MLX5_GET(parse_graph_flex, flex, head_anchor_id);
-	for (i = 0; i < MLX5_GRAPH_NODE_SAMPLE_NUM; i++) {
+	if (anchor)
+		*anchor = MLX5_GET(parse_graph_flex, flex, head_anchor_id);
+	for (i = 0; i < MLX5_GRAPH_NODE_SAMPLE_NUM && idx <= num; i++) {
 		void *s_off = (void *)((char *)sample + i *
 			      MLX5_ST_SZ_BYTES(parse_graph_flow_match_sample));
 		uint32_t en;
drivers/net/mlx5/hws/mlx5dr_definer.c +91 -0

115 lines not on this page · raw message

drivers/net/mlx5/hws/mlx5dr_definer.h +15 -0
index d52c6b0627..c857848a28 100644
@@ -511,6 +511,21 @@ struct mlx5_ifc_header_ipv6_vtc_bits {
 	u8 flow_label[0x14];
 };
 
+struct mlx5_ifc_header_ipv6_routing_ext_bits {
+	u8 next_hdr[0x8];
+	u8 hdr_len[0x8];
+	u8 type[0x8];
+	u8 segments_left[0x8];
+	union {
+		u8 flags[0x20];
+		struct {
+			u8 last_entry[0x8];
+			u8 flag[0x8];
+			u8 tag[0x10];
+		};
+	};
+};
+
 struct mlx5_ifc_header_vxlan_bits {
 	u8 flags[0x8];
 	u8 reserved1[0x18];
drivers/net/mlx5/mlx5.c +90 -2

110 lines not on this page · raw message

drivers/net/mlx5/mlx5.h +16 -0
index 83fb316ad8..bea1f62ea8 100644
@@ -543,6 +543,17 @@ struct mlx5_counter_stats_raw {
 	volatile struct flow_counter_stats *data;
 };
 
+/* Mlx5 internal flex parser profile structure. */
+struct mlx5_internal_flex_parser_profile {
+	uint32_t num;/* Actual number of samples. */
+	/* Sample IDs for this profile. */
+	struct mlx5_ext_sample_id ids[MLX5_FLEX_ITEM_MAPPING_NUM];
+	uint32_t offset[MLX5_FLEX_ITEM_MAPPING_NUM]; /* Each ID sample offset. */
+	uint8_t anchor_id;
+	uint32_t refcnt;
+	void *fp; /* DevX flex parser object. */
+};
+
 TAILQ_HEAD(mlx5_counter_pools, mlx5_flow_counter_pool);
 
 /* Counter global management structure. */
@@ -1436,6 +1447,7 @@ struct mlx5_dev_ctx_shared {
 	struct mlx5_uar rx_uar; /* DevX UAR for Rx. */
 	struct mlx5_proc_priv *pppriv; /* Pointer to primary private process. */
 	struct mlx5_ecpri_parser_profile ecpri_parser;
+	struct mlx5_internal_flex_parser_profile srh_flex_parser; /* srh flex parser structure. */
 	/* Flex parser profiles information. */
 	LIST_HEAD(shared_rxqs, mlx5_rxq_ctrl) shared_rxqs; /* Shared RXQs. */
 	struct mlx5_aso_age_mng *aso_age_mng;
@@ -2258,4 +2270,8 @@ struct mlx5_list_entry *mlx5_flex_parser_clone_cb(void *list_ctx,
 						  void *ctx);
 void mlx5_flex_parser_clone_free_cb(void *tool_ctx,
 				    struct mlx5_list_entry *entry);
+
+int mlx5_alloc_srh_flex_parser(struct rte_eth_dev *dev);
+
+void mlx5_free_srh_flex_parser(struct rte_eth_dev *dev);
 #endif /* RTE_PMD_MLX5_H_ */
drivers/net/mlx5/mlx5_flow.h +28 -0
index e376dcae93..1f359cfb12 100644
@@ -219,6 +219,10 @@ enum mlx5_feature_name {
 /* Meter color item */
 #define MLX5_FLOW_ITEM_METER_COLOR (UINT64_C(1) << 44)
 
+/* IPv6 routing extension item */
+#define MLX5_FLOW_ITEM_OUTER_IPV6_ROUTING_EXT (UINT64_C(1) << 45)
+#define MLX5_FLOW_ITEM_INNER_IPV6_ROUTING_EXT (UINT64_C(1) << 46)
+
 /* Outer Masks. */
 #define MLX5_FLOW_LAYER_OUTER_L3 \
 	(MLX5_FLOW_LAYER_OUTER_L3_IPV4 | MLX5_FLOW_LAYER_OUTER_L3_IPV6)
@@ -2611,4 +2615,28 @@ int mlx5_flow_item_field_width(struct rte_eth_dev *dev,
 			   enum rte_flow_field_id field, int inherit,
 			   const struct rte_flow_attr *attr,
 			   struct rte_flow_error *error);
+
+static __rte_always_inline int
+flow_hw_get_srh_flex_parser_byte_off_from_ctx(void *dr_ctx __rte_unused)
+{
+#ifdef HAVE_IBV_FLOW_DV_SUPPORT
+	uint16_t port;
+
+	MLX5_ETH_FOREACH_DEV(port, NULL) {
+		struct mlx5_priv *priv;
+		struct mlx5_hca_flex_attr *attr;
+
+		priv = rte_eth_devices[port].data->dev_private;
+		attr = &priv->sh->cdev->config.hca_attr.flex;
+		if (priv->dr_ctx == dr_ctx && attr->ext_sample_id) {
+			if (priv->sh->srh_flex_parser.num)
+				return priv->sh->srh_flex_parser.ids[0].format_select_dw *
+					sizeof(uint32_t);
+			else
+				return UINT32_MAX;
+		}
+	}
+#endif
+	return UINT32_MAX;
+}
 #endif /* RTE_PMD_MLX5_FLOW_H_ */
drivers/net/mlx5/mlx5_flow_hw.c +24 -5
index 20c71ff7f0..c6542bdee9 100644
@@ -213,17 +213,17 @@ flow_hw_hashfields_set(struct mlx5_flow_rss_desc *rss_desc,
 }
 
 /**
- * Generate the pattern item flags.
- * Will be used for shared RSS action.
+ * Generate the matching pattern item flags.
  *
  * @param[in] items
  *   Pointer to the list of items.
  *
  * @return
- *   Item flags.
+ *   Matching item flags. RSS hash field function
+ *   silently ignores the flags which are unsupported.
  */
 static uint64_t
-flow_hw_rss_item_flags_get(const struct rte_flow_item items[])
+flow_hw_matching_item_flags_get(const struct rte_flow_item items[])
 {
 	uint64_t item_flags = 0;
 	uint64_t last_item = 0;
@@ -249,6 +249,10 @@ flow_hw_rss_item_flags_get(const struct rte_flow_item items[])
 			last_item = tunnel ? MLX5_FLOW_LAYER_INNER_L4_UDP :
 					     MLX5_FLOW_LAYER_OUTER_L4_UDP;
 			break;
+		case RTE_FLOW_ITEM_TYPE_IPV6_ROUTING_EXT:
+			last_item = tunnel ? MLX5_FLOW_ITEM_INNER_IPV6_ROUTING_EXT :
+					     MLX5_FLOW_ITEM_OUTER_IPV6_ROUTING_EXT;
+			break;
 		case RTE_FLOW_ITEM_TYPE_GRE:
 			last_item = MLX5_FLOW_LAYER_GRE;
 			break;
@@ -4732,6 +4736,7 @@ flow_hw_pattern_validate(struct rte_eth_dev *dev,
 		case RTE_FLOW_ITEM_TYPE_ICMP:
 		case RTE_FLOW_ITEM_TYPE_ICMP6:
 		case RTE_FLOW_ITEM_TYPE_CONNTRACK:
+		case RTE_FLOW_ITEM_TYPE_IPV6_ROUTING_EXT:
 			break;
 		case RTE_FLOW_ITEM_TYPE_INTEGRITY:
 			/*
@@ -4860,7 +4865,7 @@ flow_hw_pattern_template_create(struct rte_eth_dev *dev,
 				   "cannot create match template");
 		return NULL;
 	}
-	it->item_flags = flow_hw_rss_item_flags_get(tmpl_items);
+	it->item_flags = flow_hw_matching_item_flags_get(tmpl_items);
 	if (copied_items) {
 		if (attr->ingress)
 			it->implicit_port = true;
@@ -4868,6 +4873,17 @@ flow_hw_pattern_template_create(struct rte_eth_dev *dev,
 			it->implicit_tag = true;
 		mlx5_free(copied_items);
 	}
+	/* Either inner or outer, can't both. */
+	if (it->item_flags & (MLX5_FLOW_ITEM_OUTER_IPV6_ROUTING_EXT |
+			      MLX5_FLOW_ITEM_INNER_IPV6_ROUTING_EXT)) {
+		if (((it->item_flags & MLX5_FLOW_ITEM_OUTER_IPV6_ROUTING_EXT) &&
+		     (it->item_flags & MLX5_FLOW_ITEM_INNER_IPV6_ROUTING_EXT)) ||
+		    (mlx5_alloc_srh_flex_parser(dev))) {
+			claim_zero(mlx5dr_match_template_destroy(it->mt));
+			mlx5_free(it);
+			return NULL;
+		}
+	}
 	__atomic_fetch_add(&it->refcnt, 1, __ATOMIC_RELAXED);
 	LIST_INSERT_HEAD(&priv->flow_hw_itt, it, next);
 	return it;
@@ -4899,6 +4915,9 @@ flow_hw_pattern_template_destroy(struct rte_eth_dev *dev __rte_unused,
 				   NULL,
 				   "item template in using");
 	}
+	if (template->item_flags & (MLX5_FLOW_ITEM_OUTER_IPV6_ROUTING_EXT |
+				    MLX5_FLOW_ITEM_INNER_IPV6_ROUTING_EXT))
+		mlx5_free_srh_flex_parser(dev);
 	LIST_REMOVE(template, next);
 	claim_zero(mlx5dr_match_template_destroy(template->mt));
 	mlx5_free(template);
Signature · 1 line
2.27.0
#47 lore raw

PATCH v3 5/8 app/testpmd: add IPv6 routing extension header in raw encap

In reply to Rongwei Liu

Add IPv6 routing extension header support in raw_encap command.
1. No TLV support now.
2. Assume header length equals to the current segment_left.

---
 app/test-pmd/cmdline_flow.c | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)
app/test-pmd/cmdline_flow.c +23 -0
index 7a8516829c..4bdb46e89a 100644
@@ -10925,6 +10925,13 @@ flow_item_default_mask(const struct rte_flow_item *item)
 {
 	const void *mask = NULL;
 	static rte_be32_t gre_key_default_mask = RTE_BE32(UINT32_MAX);
+	static struct rte_flow_item_ipv6_routing_ext ipv6_routing_ext_default_mask = {
+		.hdr = {
+			.next_hdr = 0xff,
+			.type = 0xff,
+			.segments_left = 0xff,
+		},
+	};
 
 	switch (item->type) {
 	case RTE_FLOW_ITEM_TYPE_ANY:
@@ -11027,6 +11034,9 @@ flow_item_default_mask(const struct rte_flow_item *item)
 	case RTE_FLOW_ITEM_TYPE_METER_COLOR:
 		mask = &rte_flow_item_meter_color_mask;
 		break;
+	case RTE_FLOW_ITEM_TYPE_IPV6_ROUTING_EXT:
+		mask = &ipv6_routing_ext_default_mask;
+		break;
 	default:
 		break;
 	}
@@ -11181,6 +11191,7 @@ cmd_set_raw_parsed(const struct buffer *in)
 	for (i = n - 1 ; i >= 0; --i) {
 		const struct rte_flow_item_gtp *gtp;
 		const struct rte_flow_item_geneve_opt *opt;
+		struct rte_flow_item_ipv6_routing_ext *ext;
 
 		item = in->args.vc.pattern + i;
 		if (item->spec == NULL)
@@ -11201,6 +11212,18 @@ cmd_set_raw_parsed(const struct buffer *in)
 			size = sizeof(struct rte_ipv6_hdr);
 			proto = RTE_ETHER_TYPE_IPV6;
 			break;
+		case RTE_FLOW_ITEM_TYPE_IPV6_ROUTING_EXT:
+			ext = (struct rte_flow_item_ipv6_routing_ext *)(uintptr_t)item->spec;
+			if (!ext->hdr.hdr_len) {
+				size = sizeof(struct rte_ipv6_routing_ext) +
+					(ext->hdr.segments_left << 4);
+				ext->hdr.hdr_len = ext->hdr.segments_left << 1;
+			} else {
+				size = sizeof(struct rte_ipv6_routing_ext) +
+					(ext->hdr.hdr_len << 3);
+			}
+			proto = IPPROTO_ROUTING;
+			break;
 		case RTE_FLOW_ITEM_TYPE_UDP:
 			size = sizeof(struct rte_udp_hdr);
 			proto = 0x11;
Signature · 1 line
2.27.0
#48 lore raw

PATCH v3 6/8 ethdev: add modify IPv6 protocol field

In reply to Rongwei Liu

Add IPv6 protocol modify field definition.

Add new modify field destination type string: "ipv6_proto".

---
 app/test-pmd/cmdline_flow.c | 3 ++-
 lib/ethdev/rte_flow.h       | 1 +
 2 files changed, 3 insertions(+), 1 deletion(-)
app/test-pmd/cmdline_flow.c +2 -1
index 4bdb46e89a..1340cf3a9b 100644
@@ -811,7 +811,8 @@ static const char *const modify_field_ids[] = {
 	"udp_port_src", "udp_port_dst",
 	"vxlan_vni", "geneve_vni", "gtp_teid",
 	"tag", "mark", "meta", "pointer", "value",
-	"ipv4_ecn", "ipv6_ecn", "gtp_psc_qfi", "meter_color", NULL
+	"ipv4_ecn", "ipv6_ecn", "gtp_psc_qfi", "meter_color",
+	"ipv6_proto", NULL
 };
 
 static const char *const meter_colors[] = {
lib/ethdev/rte_flow.h +1 -0
index 9b9018cba2..f4797682b7 100644
@@ -3547,6 +3547,7 @@ enum rte_flow_field_id {
 	RTE_FLOW_FIELD_IPV6_ECN,	/**< IPv6 ECN. */
 	RTE_FLOW_FIELD_GTP_PSC_QFI,	/**< GTP QFI. */
 	RTE_FLOW_FIELD_METER_COLOR,	/**< Meter color marker. */
+	RTE_FLOW_FIELD_IPV6_PROTO,	/**< IPv6 next header. */
 };
 
 /**
Signature · 1 line
2.27.0
#49 lore raw

PATCH v3 7/8 net/mlx5: add modify IPv6 protocol implementation

In reply to Rongwei Liu

Add HWS modify IPv6 protocol implementation.

---
 drivers/common/mlx5/mlx5_prm.h  |  1 +
 drivers/net/mlx5/mlx5_flow_dv.c | 10 ++++++++++
 2 files changed, 11 insertions(+)
drivers/common/mlx5/mlx5_prm.h +1 -0
index ce6cd98fd7..497f2622b2 100644
@@ -759,6 +759,7 @@ enum mlx5_modification_field {
 	MLX5_MODI_OUT_IP_ECN = 0x73,
 	MLX5_MODI_TUNNEL_HDR_DW_1 = 0x75,
 	MLX5_MODI_GTPU_FIRST_EXT_DW_0 = 0x76,
+	MLX5_MODI_OUT_IPV6_NEXT_HDR = 0x4A,
 };
 
 /* Total number of metadata reg_c's. */
drivers/net/mlx5/mlx5_flow_dv.c +10 -0
index 7ca909999b..e972a2dc5a 100644
@@ -1357,6 +1357,7 @@ mlx5_flow_item_field_width(struct rte_eth_dev *dev,
 	case RTE_FLOW_FIELD_IPV6_DSCP:
 		return 6;
 	case RTE_FLOW_FIELD_IPV6_HOPLIMIT:
+	case RTE_FLOW_FIELD_IPV6_PROTO:
 		return 8;
 	case RTE_FLOW_FIELD_IPV6_SRC:
 	case RTE_FLOW_FIELD_IPV6_DST:
@@ -1883,6 +1884,15 @@ mlx5_flow_field_id_to_modify_info
 				info[idx].offset = data->offset;
 		}
 		break;
+	case RTE_FLOW_FIELD_IPV6_PROTO:
+		MLX5_ASSERT(data->offset + width <= 8);
+		off_be = 8 - (data->offset + width);
+		info[idx] = (struct field_modify_info){1, 0, MLX5_MODI_OUT_IPV6_NEXT_HDR};
+		if (mask)
+			mask[idx] = flow_modify_info_mask_8(width, off_be);
+		else
+			info[idx].offset = off_be;
+		break;
 	case RTE_FLOW_FIELD_POINTER:
 	case RTE_FLOW_FIELD_VALUE:
 	default:
Signature · 1 line
2.27.0
#50 lore raw

PATCH v3 8/8 doc/mlx5: add IPv6 routing extension matching docs

In reply to Rongwei Liu

Update mlx5 related document on IPv6 routing extension header matching.

---
 doc/guides/nics/features/default.ini | 1 +
 doc/guides/nics/features/mlx5.ini    | 1 +
 doc/guides/nics/mlx5.rst             | 2 ++
 3 files changed, 4 insertions(+)
doc/guides/nics/features/default.ini +1 -0
index 510cc6679d..3d0744a243 100644
@@ -141,6 +141,7 @@ udp                  =
 vlan                 =
 vxlan                =
 vxlan_gpe            =
+ipv6_routing_ext     =
 
 [rte_flow actions]
 age                  =
doc/guides/nics/features/mlx5.ini +1 -0
index 62fd330e2b..bd911a467b 100644
@@ -87,6 +87,7 @@ vlan                 = Y
 vxlan                = Y
 vxlan_gpe            = Y
 represented_port     = Y
+ipv6_routing_ext     = Y
 
 [rte_flow actions]
 age                  = I
doc/guides/nics/mlx5.rst +2 -0
index b23ca35b8f..fb8001faef 100644
@@ -106,6 +106,7 @@ Features
 - Sub-Function representors.
 - Sub-Function.
 - Matching on represented port.
+- Matching on IPv6 routing extension header.
 
 
 Limitations
@@ -174,6 +175,7 @@ Limitations
 
     - ``-EAGAIN`` for ``rte_eth_dev_start()``.
     - ``-EBUSY`` for ``rte_eth_dev_stop()``.
+  - Matching on ICMP6 following IPv6 routing extension header, should match ipv6_routing_ext_next_hdr instead of ICMP6.
 
 - When using Verbs flow engine (``dv_flow_en`` = 0), flow pattern without any
   specific VLAN will match for VLAN packets as well:
Signature · 1 line
2.27.0
#51 lore raw

PATCH v2 2/8 net/mlx5: adopt IPv6 routing extension prm definition

In reply to Rongwei Liu

Per newest PRM definition, sample_id stands for 3 parts of information instead of single uint32_t id: sample_id + modify_filed_id + format_select_dw.

Also new FW capability bits have been introduces to identify the new capability.

---
 drivers/common/mlx5/mlx5_devx_cmds.c | 14 +++++++++++---
 drivers/common/mlx5/mlx5_devx_cmds.h |  7 ++++++-
 drivers/common/mlx5/mlx5_prm.h       | 28 ++++++++++++++++++++++++++--
 drivers/net/mlx5/mlx5.c              | 15 +++++++++++----
 drivers/net/mlx5/mlx5.h              |  3 ++-
 drivers/net/mlx5/mlx5_flow_flex.c    | 14 +++++++++++---
 6 files changed, 67 insertions(+), 14 deletions(-)
drivers/common/mlx5/mlx5_devx_cmds.c +11 -3
index e3a4927d0f..1f65ea7dcb 100644
@@ -607,7 +607,8 @@ mlx5_devx_cmd_query_hca_vdpa_attr(void *ctx,
 
 int
 mlx5_devx_cmd_query_parse_samples(struct mlx5_devx_obj *flex_obj,
-				  uint32_t ids[], uint32_t num)
+				  struct mlx5_ext_sample_id ids[],
+				  uint32_t num, uint8_t *anchor)
 {
 	uint32_t in[MLX5_ST_SZ_DW(general_obj_in_cmd_hdr)] = {0};
 	uint32_t out[MLX5_ST_SZ_DW(create_flex_parser_out)] = {0};
@@ -636,6 +637,7 @@ mlx5_devx_cmd_query_parse_samples(struct mlx5_devx_obj *flex_obj,
 			(void *)flex_obj);
 		return -rte_errno;
 	}
+	*anchor = MLX5_GET(parse_graph_flex, flex, head_anchor_id);
 	for (i = 0; i < MLX5_GRAPH_NODE_SAMPLE_NUM; i++) {
 		void *s_off = (void *)((char *)sample + i *
 			      MLX5_ST_SZ_BYTES(parse_graph_flow_match_sample));
@@ -645,8 +647,8 @@ mlx5_devx_cmd_query_parse_samples(struct mlx5_devx_obj *flex_obj,
 			      flow_match_sample_en);
 		if (!en)
 			continue;
-		ids[idx++] = MLX5_GET(parse_graph_flow_match_sample, s_off,
-				  flow_match_sample_field_id);
+		ids[idx++].id = MLX5_GET(parse_graph_flow_match_sample, s_off,
+					 flow_match_sample_field_id);
 	}
 	if (num != idx) {
 		rte_errno = EINVAL;
@@ -794,6 +796,12 @@ mlx5_devx_cmd_query_hca_parse_graph_node_cap
 					 max_num_arc_out);
 	attr->max_num_sample = MLX5_GET(parse_graph_node_cap, hcattr,
 					max_num_sample);
+	attr->anchor_en = MLX5_GET(parse_graph_node_cap, hcattr, anchor_en);
+	attr->ext_sample_id = MLX5_GET(parse_graph_node_cap, hcattr, ext_sample_id);
+	attr->sample_tunnel_inner2 = MLX5_GET(parse_graph_node_cap, hcattr,
+					      sample_tunnel_inner2);
+	attr->zero_size_supported = MLX5_GET(parse_graph_node_cap, hcattr,
+					     zero_size_supported);
 	attr->sample_id_in_out = MLX5_GET(parse_graph_node_cap, hcattr,
 					  sample_id_in_out);
 	attr->max_base_header_length = MLX5_GET(parse_graph_node_cap, hcattr,
drivers/common/mlx5/mlx5_devx_cmds.h +6 -1
index c94b9eac06..5b33010155 100644
@@ -114,6 +114,10 @@ struct mlx5_hca_flex_attr {
 	uint8_t  max_num_arc_out;
 	uint8_t  max_num_sample;
 	uint8_t  max_num_prog_sample:5;	/* From HCA CAP 2 */
+	uint8_t  anchor_en:1;
+	uint8_t  ext_sample_id:1;
+	uint8_t  sample_tunnel_inner2:1;
+	uint8_t  zero_size_supported:1;
 	uint8_t  sample_id_in_out:1;
 	uint16_t max_base_header_length;
 	uint8_t  max_sample_base_offset;
@@ -706,7 +710,8 @@ int mlx5_devx_cmd_modify_tir(struct mlx5_devx_obj *tir,
 			     struct mlx5_devx_modify_tir_attr *tir_attr);
 __rte_internal
 int mlx5_devx_cmd_query_parse_samples(struct mlx5_devx_obj *flex_obj,
-				      uint32_t ids[], uint32_t num);
+				      struct mlx5_ext_sample_id ids[],
+				      uint32_t num, uint8_t *anchor);
 
 __rte_internal
 struct mlx5_devx_obj *
drivers/common/mlx5/mlx5_prm.h +26 -2
index 3790dc84b8..ce6cd98fd7 100644
@@ -1893,7 +1893,11 @@ struct mlx5_ifc_parse_graph_node_cap_bits {
 	u8 max_num_arc_in[0x08];
 	u8 max_num_arc_out[0x08];
 	u8 max_num_sample[0x08];
-	u8 reserved_at_78[0x07];
+	u8 reserved_at_78[0x03];
+	u8 anchor_en[0x1];
+	u8 ext_sample_id[0x1];
+	u8 sample_tunnel_inner2[0x1];
+	u8 zero_size_supported[0x1];
 	u8 sample_id_in_out[0x1];
 	u8 max_base_header_length[0x10];
 	u8 reserved_at_90[0x08];
@@ -1903,6 +1907,24 @@ struct mlx5_ifc_parse_graph_node_cap_bits {
 	u8 header_length_mask_width[0x08];
 };
 
+/* ext_sample_id structure, see PRM Table: Flow Match Sample ID Format. */
+struct mlx5_ext_sample_id {
+	union {
+		struct {
+#if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
+			uint32_t format_select_dw:8;
+			uint32_t modify_field_id:12;
+			uint32_t sample_id:12;
+#else
+			uint32_t sample_id:12;
+			uint32_t modify_field_id:12;
+			uint32_t format_select_dw:8;
+#endif
+		};
+		uint32_t id;
+	};
+};
+
 struct mlx5_ifc_flow_table_prop_layout_bits {
 	u8 ft_support[0x1];
 	u8 flow_tag[0x1];
@@ -4522,7 +4544,9 @@ struct mlx5_ifc_parse_graph_flex_bits {
 	u8 header_length_mode[0x4];
 	u8 header_length_field_offset[0x10];
 	u8 next_header_field_offset[0x10];
-	u8 reserved_at_160[0x1b];
+	u8 reserved_at_160[0x12];
+	u8 head_anchor_id[0x6];
+	u8 reserved_at_178[0x3];
 	u8 next_header_field_size[0x5];
 	u8 header_length_field_mask[0x20];
 	u8 reserved_at_224[0x20];
drivers/net/mlx5/mlx5.c +11 -4
index b8643cebdd..0b97c4e78d 100644
@@ -964,11 +964,13 @@ int
 mlx5_flex_parser_ecpri_alloc(struct rte_eth_dev *dev)
 {
 	struct mlx5_priv *priv = dev->data->dev_private;
+	struct mlx5_hca_flex_attr *attr = &priv->sh->cdev->config.hca_attr.flex;
 	struct mlx5_ecpri_parser_profile *prf =	&priv->sh->ecpri_parser;
 	struct mlx5_devx_graph_node_attr node = {
 		.modify_field_select = 0,
 	};
-	uint32_t ids[8];
+	struct mlx5_ext_sample_id ids[8];
+	uint8_t anchor_id;
 	int ret;
 
 	if (!priv->sh->cdev->config.hca_attr.parse_graph_flex_node) {
@@ -1004,15 +1006,20 @@ mlx5_flex_parser_ecpri_alloc(struct rte_eth_dev *dev)
 		return (rte_errno == 0) ? -ENODEV : -rte_errno;
 	}
 	prf->num = 2;
-	ret = mlx5_devx_cmd_query_parse_samples(prf->obj, ids, prf->num);
+	ret = mlx5_devx_cmd_query_parse_samples(prf->obj, ids, prf->num, &anchor_id);
 	if (ret) {
 		DRV_LOG(ERR, "Failed to query sample IDs.");
 		return (rte_errno == 0) ? -ENODEV : -rte_errno;
 	}
 	prf->offset[0] = 0x0;
 	prf->offset[1] = sizeof(uint32_t);
-	prf->ids[0] = ids[0];
-	prf->ids[1] = ids[1];
+	if (attr->ext_sample_id) {
+		prf->ids[0] = ids[0].sample_id;
+		prf->ids[1] = ids[1].sample_id;
+	} else {
+		prf->ids[0] = ids[0].id;
+		prf->ids[1] = ids[1].id;
+	}
 	return 0;
 }
 
drivers/net/mlx5/mlx5.h +2 -1
index 16b33e1548..83fb316ad8 100644
@@ -1307,9 +1307,10 @@ struct mlx5_lag {
 struct mlx5_flex_parser_devx {
 	struct mlx5_list_entry entry;  /* List element at the beginning. */
 	uint32_t num_samples;
+	uint8_t anchor_id;
 	void *devx_obj;
 	struct mlx5_devx_graph_node_attr devx_conf;
-	uint32_t sample_ids[MLX5_GRAPH_NODE_SAMPLE_NUM];
+	struct mlx5_ext_sample_id sample_ids[MLX5_GRAPH_NODE_SAMPLE_NUM];
 };
 
 /* Pattern field descriptor - how to translate flex pattern into samples. */
drivers/net/mlx5/mlx5_flow_flex.c +11 -3
index fb08910ddb..35f2a9923d 100644
@@ -226,15 +226,18 @@ mlx5_flex_flow_translate_item(struct rte_eth_dev *dev,
 	void *misc4_m = MLX5_ADDR_OF(fte_match_param, matcher,
 				     misc_parameters_4);
 	void *misc4_v = MLX5_ADDR_OF(fte_match_param, key, misc_parameters_4);
+	struct mlx5_priv *priv = dev->data->dev_private;
+	struct mlx5_hca_flex_attr *attr = &priv->sh->cdev->config.hca_attr.flex;
 	struct mlx5_flex_item *tp;
 	uint32_t i, pos = 0;
+	uint32_t sample_id;
 
 	RTE_SET_USED(dev);
 	MLX5_ASSERT(item->spec && item->mask);
 	spec = item->spec;
 	mask = item->mask;
 	tp = (struct mlx5_flex_item *)spec->handle;
-	MLX5_ASSERT(mlx5_flex_index(dev->data->dev_private, tp) >= 0);
+	MLX5_ASSERT(mlx5_flex_index(priv, tp) >= 0);
 	for (i = 0; i < tp->mapnum; i++) {
 		struct mlx5_flex_pattern_field *map = tp->map + i;
 		uint32_t id = map->reg_id;
@@ -257,9 +260,13 @@ mlx5_flex_flow_translate_item(struct rte_eth_dev *dev,
 			MLX5_ASSERT(id < num_samples);
 			id += num_samples;
 		}
+		if (attr->ext_sample_id)
+			sample_id = tp->devx_fp->sample_ids[id].sample_id;
+		else
+			sample_id = tp->devx_fp->sample_ids[id].id;
 		mlx5_flex_set_match_sample(misc4_m, misc4_v,
 					   def, msk & def, val & msk & def,
-					   tp->devx_fp->sample_ids[id], id);
+					   sample_id, id);
 		pos += map->width;
 	}
 }
@@ -1298,7 +1305,8 @@ mlx5_flex_parser_create_cb(void *list_ctx, void *ctx)
 	/* Query the firmware assigned sample ids. */
 	ret = mlx5_devx_cmd_query_parse_samples(fp->devx_obj,
 						fp->sample_ids,
-						fp->num_samples);
+						fp->num_samples,
+						&fp->anchor_id);
 	if (ret)
 		goto error;
 	DRV_LOG(DEBUG, "DEVx flex parser %p created, samples num: %u",
Signature · 1 line
2.27.0
#52 lore raw

PATCH v2 3/8 net/mlx5/hws: Definer, add mlx5dr context to definer_conv_data

In reply to Rongwei Liu

From: Gregory Etelson <[email protected]>

New mlx5dr_context member replaces mlx5dr_cmd_query_caps. Capabilities structure is a member of mlx5dr_context.

---
 drivers/net/mlx5/hws/mlx5dr_definer.c | 42 ++++++++++++++-------------
 1 file changed, 22 insertions(+), 20 deletions(-)
drivers/net/mlx5/hws/mlx5dr_definer.c +22 -20
index 6b98eb8c96..0f1cab7e07 100644
@@ -100,7 +100,7 @@ struct mlx5dr_definer_sel_ctrl {
 };
 
 struct mlx5dr_definer_conv_data {
-	struct mlx5dr_cmd_query_caps *caps;
+	struct mlx5dr_context *ctx;
 	struct mlx5dr_definer_fc *fc;
 	uint8_t relaxed;
 	uint8_t tunnel;
@@ -815,6 +815,7 @@ mlx5dr_definer_conv_item_gtp(struct mlx5dr_definer_conv_data *cd,
 			     struct rte_flow_item *item,
 			     int item_idx)
 {
+	struct mlx5dr_cmd_query_caps *caps = cd->ctx->caps;
 	const struct rte_flow_item_gtp *m = item->mask;
 	struct mlx5dr_definer_fc *fc;
 
@@ -836,7 +837,7 @@ mlx5dr_definer_conv_item_gtp(struct mlx5dr_definer_conv_data *cd,
 	}
 
 	if (m->teid) {
-		if (!(cd->caps->flex_protocols & MLX5_HCA_FLEX_GTPU_TEID_ENABLED)) {
+		if (!(caps->flex_protocols & MLX5_HCA_FLEX_GTPU_TEID_ENABLED)) {
 			rte_errno = ENOTSUP;
 			return rte_errno;
 		}
@@ -844,11 +845,11 @@ mlx5dr_definer_conv_item_gtp(struct mlx5dr_definer_conv_data *cd,
 		fc->item_idx = item_idx;
 		fc->tag_set = &mlx5dr_definer_gtp_teid_set;
 		fc->bit_mask = __mlx5_mask(header_gtp, teid);
-		fc->byte_off = cd->caps->format_select_gtpu_dw_1 * DW_SIZE;
+		fc->byte_off = caps->format_select_gtpu_dw_1 * DW_SIZE;
 	}
 
 	if (m->v_pt_rsv_flags) {
-		if (!(cd->caps->flex_protocols & MLX5_HCA_FLEX_GTPU_DW_0_ENABLED)) {
+		if (!(caps->flex_protocols & MLX5_HCA_FLEX_GTPU_DW_0_ENABLED)) {
 			rte_errno = ENOTSUP;
 			return rte_errno;
 		}
@@ -857,12 +858,12 @@ mlx5dr_definer_conv_item_gtp(struct mlx5dr_definer_conv_data *cd,
 		fc->tag_set = &mlx5dr_definer_gtp_ext_flag_set;
 		fc->bit_mask = __mlx5_mask(header_gtp, ext_hdr_flag);
 		fc->bit_off = __mlx5_dw_bit_off(header_gtp, ext_hdr_flag);
-		fc->byte_off = cd->caps->format_select_gtpu_dw_0 * DW_SIZE;
+		fc->byte_off = caps->format_select_gtpu_dw_0 * DW_SIZE;
 	}
 
 
 	if (m->msg_type) {
-		if (!(cd->caps->flex_protocols & MLX5_HCA_FLEX_GTPU_DW_0_ENABLED)) {
+		if (!(caps->flex_protocols & MLX5_HCA_FLEX_GTPU_DW_0_ENABLED)) {
 			rte_errno = ENOTSUP;
 			return rte_errno;
 		}
@@ -871,7 +872,7 @@ mlx5dr_definer_conv_item_gtp(struct mlx5dr_definer_conv_data *cd,
 		fc->tag_set = &mlx5dr_definer_gtp_msg_type_set;
 		fc->bit_mask = __mlx5_mask(header_gtp, msg_type);
 		fc->bit_off = __mlx5_dw_bit_off(header_gtp, msg_type);
-		fc->byte_off = cd->caps->format_select_gtpu_dw_0 * DW_SIZE;
+		fc->byte_off = caps->format_select_gtpu_dw_0 * DW_SIZE;
 	}
 
 	return 0;
@@ -882,12 +883,13 @@ mlx5dr_definer_conv_item_gtp_psc(struct mlx5dr_definer_conv_data *cd,
 				 struct rte_flow_item *item,
 				 int item_idx)
 {
+	struct mlx5dr_cmd_query_caps *caps = cd->ctx->caps;
 	const struct rte_flow_item_gtp_psc *m = item->mask;
 	struct mlx5dr_definer_fc *fc;
 
 	/* Overwrite GTP extension flag to be 1 */
 	if (!cd->relaxed) {
-		if (!(cd->caps->flex_protocols & MLX5_HCA_FLEX_GTPU_DW_0_ENABLED)) {
+		if (!(caps->flex_protocols & MLX5_HCA_FLEX_GTPU_DW_0_ENABLED)) {
 			rte_errno = ENOTSUP;
 			return rte_errno;
 		}
@@ -896,12 +898,12 @@ mlx5dr_definer_conv_item_gtp_psc(struct mlx5dr_definer_conv_data *cd,
 		fc->tag_set = &mlx5dr_definer_ones_set;
 		fc->bit_mask = __mlx5_mask(header_gtp, ext_hdr_flag);
 		fc->bit_off = __mlx5_dw_bit_off(header_gtp, ext_hdr_flag);
-		fc->byte_off = cd->caps->format_select_gtpu_dw_0 * DW_SIZE;
+		fc->byte_off = caps->format_select_gtpu_dw_0 * DW_SIZE;
 	}
 
 	/* Overwrite next extension header type */
 	if (!cd->relaxed) {
-		if (!(cd->caps->flex_protocols & MLX5_HCA_FLEX_GTPU_DW_2_ENABLED)) {
+		if (!(caps->flex_protocols & MLX5_HCA_FLEX_GTPU_DW_2_ENABLED)) {
 			rte_errno = ENOTSUP;
 			return rte_errno;
 		}
@@ -911,14 +913,14 @@ mlx5dr_definer_conv_item_gtp_psc(struct mlx5dr_definer_conv_data *cd,
 		fc->tag_mask_set = &mlx5dr_definer_ones_set;
 		fc->bit_mask = __mlx5_mask(header_opt_gtp, next_ext_hdr_type);
 		fc->bit_off = __mlx5_dw_bit_off(header_opt_gtp, next_ext_hdr_type);
-		fc->byte_off = cd->caps->format_select_gtpu_dw_2 * DW_SIZE;
+		fc->byte_off = caps->format_select_gtpu_dw_2 * DW_SIZE;
 	}
 
 	if (!m)
 		return 0;
 
 	if (m->hdr.type) {
-		if (!(cd->caps->flex_protocols & MLX5_HCA_FLEX_GTPU_FIRST_EXT_DW_0_ENABLED)) {
+		if (!(caps->flex_protocols & MLX5_HCA_FLEX_GTPU_FIRST_EXT_DW_0_ENABLED)) {
 			rte_errno = ENOTSUP;
 			return rte_errno;
 		}
@@ -927,11 +929,11 @@ mlx5dr_definer_conv_item_gtp_psc(struct mlx5dr_definer_conv_data *cd,
 		fc->tag_set = &mlx5dr_definer_gtp_ext_hdr_pdu_set;
 		fc->bit_mask = __mlx5_mask(header_gtp_psc, pdu_type);
 		fc->bit_off = __mlx5_dw_bit_off(header_gtp_psc, pdu_type);
-		fc->byte_off = cd->caps->format_select_gtpu_ext_dw_0 * DW_SIZE;
+		fc->byte_off = caps->format_select_gtpu_ext_dw_0 * DW_SIZE;
 	}
 
 	if (m->hdr.qfi) {
-		if (!(cd->caps->flex_protocols & MLX5_HCA_FLEX_GTPU_FIRST_EXT_DW_0_ENABLED)) {
+		if (!(caps->flex_protocols & MLX5_HCA_FLEX_GTPU_FIRST_EXT_DW_0_ENABLED)) {
 			rte_errno = ENOTSUP;
 			return rte_errno;
 		}
@@ -940,7 +942,7 @@ mlx5dr_definer_conv_item_gtp_psc(struct mlx5dr_definer_conv_data *cd,
 		fc->tag_set = &mlx5dr_definer_gtp_ext_hdr_qfi_set;
 		fc->bit_mask = __mlx5_mask(header_gtp_psc, qfi);
 		fc->bit_off = __mlx5_dw_bit_off(header_gtp_psc, qfi);
-		fc->byte_off = cd->caps->format_select_gtpu_ext_dw_0 * DW_SIZE;
+		fc->byte_off = caps->format_select_gtpu_ext_dw_0 * DW_SIZE;
 	}
 
 	return 0;
@@ -951,18 +953,19 @@ mlx5dr_definer_conv_item_port(struct mlx5dr_definer_conv_data *cd,
 			      struct rte_flow_item *item,
 			      int item_idx)
 {
+	struct mlx5dr_cmd_query_caps *caps = cd->ctx->caps;
 	const struct rte_flow_item_ethdev *m = item->mask;
 	struct mlx5dr_definer_fc *fc;
 	uint8_t bit_offset = 0;
 
 	if (m->port_id) {
-		if (!cd->caps->wire_regc_mask) {
+		if (!caps->wire_regc_mask) {
 			DR_LOG(ERR, "Port ID item not supported, missing wire REGC mask");
 			rte_errno = ENOTSUP;
 			return rte_errno;
 		}
 
-		while (!(cd->caps->wire_regc_mask & (1 << bit_offset)))
+		while (!(caps->wire_regc_mask & (1 << bit_offset)))
 			bit_offset++;
 
 		fc = &cd->fc[MLX5DR_DEFINER_FNAME_VPORT_REG_C_0];
@@ -971,7 +974,7 @@ mlx5dr_definer_conv_item_port(struct mlx5dr_definer_conv_data *cd,
 		fc->tag_mask_set = &mlx5dr_definer_ones_set;
 		DR_CALC_SET_HDR(fc, registers, register_c_0);
 		fc->bit_off = bit_offset;
-		fc->bit_mask = cd->caps->wire_regc_mask >> bit_offset;
+		fc->bit_mask = caps->wire_regc_mask >> bit_offset;
 	} else {
 		DR_LOG(ERR, "Pord ID item mask must specify ID mask");
 		rte_errno = EINVAL;
@@ -1479,8 +1482,7 @@ mlx5dr_definer_conv_items_to_hl(struct mlx5dr_context *ctx,
 	int ret;
 
 	cd.fc = fc;
-	cd.hl = hl;
-	cd.caps = ctx->caps;
+	cd.ctx = ctx;
 	cd.relaxed = mt->flags & MLX5DR_MATCH_TEMPLATE_FLAG_RELAXED_MATCH;
 
 	/* Collect all RTE fields to the field array and set header layout */
Signature · 1 line
2.27.0
#53 lore raw

PATCH v2 4/8 net/mlx5/hws: add IPv6 routing extension matching support

In reply to Rongwei Liu

Add mlx5 HWS logic to match IPv6 routing extension header.

Once detecting IPv6 matching extension items in pattern template create callback, PMD allocates a flex parser to sample the first dword of srv6 header.

Only support next_hdr/segments_left/type for now.

---
 drivers/common/mlx5/mlx5_devx_cmds.c  |  7 +-
 drivers/net/mlx5/hws/mlx5dr_definer.c | 91 ++++++++++++++++++++++++++
 drivers/net/mlx5/hws/mlx5dr_definer.h | 15 +++++
 drivers/net/mlx5/mlx5.c               | 92 ++++++++++++++++++++++++++-
 drivers/net/mlx5/mlx5.h               | 16 +++++
 drivers/net/mlx5/mlx5_flow.h          | 28 ++++++++
 drivers/net/mlx5/mlx5_flow_hw.c       | 29 +++++++--
 7 files changed, 268 insertions(+), 10 deletions(-)
drivers/common/mlx5/mlx5_devx_cmds.c +4 -3
index 1f65ea7dcb..22a94c1e1a 100644
@@ -607,7 +607,7 @@ mlx5_devx_cmd_query_hca_vdpa_attr(void *ctx,
 
 int
 mlx5_devx_cmd_query_parse_samples(struct mlx5_devx_obj *flex_obj,
-				  struct mlx5_ext_sample_id ids[],
+				  struct mlx5_ext_sample_id *ids,
 				  uint32_t num, uint8_t *anchor)
 {
 	uint32_t in[MLX5_ST_SZ_DW(general_obj_in_cmd_hdr)] = {0};
@@ -637,8 +637,9 @@ mlx5_devx_cmd_query_parse_samples(struct mlx5_devx_obj *flex_obj,
 			(void *)flex_obj);
 		return -rte_errno;
 	}
-	*anchor = MLX5_GET(parse_graph_flex, flex, head_anchor_id);
-	for (i = 0; i < MLX5_GRAPH_NODE_SAMPLE_NUM; i++) {
+	if (anchor)
+		*anchor = MLX5_GET(parse_graph_flex, flex, head_anchor_id);
+	for (i = 0; i < MLX5_GRAPH_NODE_SAMPLE_NUM && idx <= num; i++) {
 		void *s_off = (void *)((char *)sample + i *
 			      MLX5_ST_SZ_BYTES(parse_graph_flow_match_sample));
 		uint32_t en;
drivers/net/mlx5/hws/mlx5dr_definer.c +91 -0

115 lines not on this page · raw message

drivers/net/mlx5/hws/mlx5dr_definer.h +15 -0
index d52c6b0627..c857848a28 100644
@@ -511,6 +511,21 @@ struct mlx5_ifc_header_ipv6_vtc_bits {
 	u8 flow_label[0x14];
 };
 
+struct mlx5_ifc_header_ipv6_routing_ext_bits {
+	u8 next_hdr[0x8];
+	u8 hdr_len[0x8];
+	u8 type[0x8];
+	u8 segments_left[0x8];
+	union {
+		u8 flags[0x20];
+		struct {
+			u8 last_entry[0x8];
+			u8 flag[0x8];
+			u8 tag[0x10];
+		};
+	};
+};
+
 struct mlx5_ifc_header_vxlan_bits {
 	u8 flags[0x8];
 	u8 reserved1[0x18];
drivers/net/mlx5/mlx5.c +90 -2

110 lines not on this page · raw message

drivers/net/mlx5/mlx5.h +16 -0
index 83fb316ad8..bea1f62ea8 100644
@@ -543,6 +543,17 @@ struct mlx5_counter_stats_raw {
 	volatile struct flow_counter_stats *data;
 };
 
+/* Mlx5 internal flex parser profile structure. */
+struct mlx5_internal_flex_parser_profile {
+	uint32_t num;/* Actual number of samples. */
+	/* Sample IDs for this profile. */
+	struct mlx5_ext_sample_id ids[MLX5_FLEX_ITEM_MAPPING_NUM];
+	uint32_t offset[MLX5_FLEX_ITEM_MAPPING_NUM]; /* Each ID sample offset. */
+	uint8_t anchor_id;
+	uint32_t refcnt;
+	void *fp; /* DevX flex parser object. */
+};
+
 TAILQ_HEAD(mlx5_counter_pools, mlx5_flow_counter_pool);
 
 /* Counter global management structure. */
@@ -1436,6 +1447,7 @@ struct mlx5_dev_ctx_shared {
 	struct mlx5_uar rx_uar; /* DevX UAR for Rx. */
 	struct mlx5_proc_priv *pppriv; /* Pointer to primary private process. */
 	struct mlx5_ecpri_parser_profile ecpri_parser;
+	struct mlx5_internal_flex_parser_profile srh_flex_parser; /* srh flex parser structure. */
 	/* Flex parser profiles information. */
 	LIST_HEAD(shared_rxqs, mlx5_rxq_ctrl) shared_rxqs; /* Shared RXQs. */
 	struct mlx5_aso_age_mng *aso_age_mng;
@@ -2258,4 +2270,8 @@ struct mlx5_list_entry *mlx5_flex_parser_clone_cb(void *list_ctx,
 						  void *ctx);
 void mlx5_flex_parser_clone_free_cb(void *tool_ctx,
 				    struct mlx5_list_entry *entry);
+
+int mlx5_alloc_srh_flex_parser(struct rte_eth_dev *dev);
+
+void mlx5_free_srh_flex_parser(struct rte_eth_dev *dev);
 #endif /* RTE_PMD_MLX5_H_ */
drivers/net/mlx5/mlx5_flow.h +28 -0
index e376dcae93..1f359cfb12 100644
@@ -219,6 +219,10 @@ enum mlx5_feature_name {
 /* Meter color item */
 #define MLX5_FLOW_ITEM_METER_COLOR (UINT64_C(1) << 44)
 
+/* IPv6 routing extension item */
+#define MLX5_FLOW_ITEM_OUTER_IPV6_ROUTING_EXT (UINT64_C(1) << 45)
+#define MLX5_FLOW_ITEM_INNER_IPV6_ROUTING_EXT (UINT64_C(1) << 46)
+
 /* Outer Masks. */
 #define MLX5_FLOW_LAYER_OUTER_L3 \
 	(MLX5_FLOW_LAYER_OUTER_L3_IPV4 | MLX5_FLOW_LAYER_OUTER_L3_IPV6)
@@ -2611,4 +2615,28 @@ int mlx5_flow_item_field_width(struct rte_eth_dev *dev,
 			   enum rte_flow_field_id field, int inherit,
 			   const struct rte_flow_attr *attr,
 			   struct rte_flow_error *error);
+
+static __rte_always_inline int
+flow_hw_get_srh_flex_parser_byte_off_from_ctx(void *dr_ctx __rte_unused)
+{
+#ifdef HAVE_IBV_FLOW_DV_SUPPORT
+	uint16_t port;
+
+	MLX5_ETH_FOREACH_DEV(port, NULL) {
+		struct mlx5_priv *priv;
+		struct mlx5_hca_flex_attr *attr;
+
+		priv = rte_eth_devices[port].data->dev_private;
+		attr = &priv->sh->cdev->config.hca_attr.flex;
+		if (priv->dr_ctx == dr_ctx && attr->ext_sample_id) {
+			if (priv->sh->srh_flex_parser.num)
+				return priv->sh->srh_flex_parser.ids[0].format_select_dw *
+					sizeof(uint32_t);
+			else
+				return UINT32_MAX;
+		}
+	}
+#endif
+	return UINT32_MAX;
+}
 #endif /* RTE_PMD_MLX5_FLOW_H_ */
drivers/net/mlx5/mlx5_flow_hw.c +24 -5
index 20c71ff7f0..c6542bdee9 100644
@@ -213,17 +213,17 @@ flow_hw_hashfields_set(struct mlx5_flow_rss_desc *rss_desc,
 }
 
 /**
- * Generate the pattern item flags.
- * Will be used for shared RSS action.
+ * Generate the matching pattern item flags.
  *
  * @param[in] items
  *   Pointer to the list of items.
  *
  * @return
- *   Item flags.
+ *   Matching item flags. RSS hash field function
+ *   silently ignores the flags which are unsupported.
  */
 static uint64_t
-flow_hw_rss_item_flags_get(const struct rte_flow_item items[])
+flow_hw_matching_item_flags_get(const struct rte_flow_item items[])
 {
 	uint64_t item_flags = 0;
 	uint64_t last_item = 0;
@@ -249,6 +249,10 @@ flow_hw_rss_item_flags_get(const struct rte_flow_item items[])
 			last_item = tunnel ? MLX5_FLOW_LAYER_INNER_L4_UDP :
 					     MLX5_FLOW_LAYER_OUTER_L4_UDP;
 			break;
+		case RTE_FLOW_ITEM_TYPE_IPV6_ROUTING_EXT:
+			last_item = tunnel ? MLX5_FLOW_ITEM_INNER_IPV6_ROUTING_EXT :
+					     MLX5_FLOW_ITEM_OUTER_IPV6_ROUTING_EXT;
+			break;
 		case RTE_FLOW_ITEM_TYPE_GRE:
 			last_item = MLX5_FLOW_LAYER_GRE;
 			break;
@@ -4732,6 +4736,7 @@ flow_hw_pattern_validate(struct rte_eth_dev *dev,
 		case RTE_FLOW_ITEM_TYPE_ICMP:
 		case RTE_FLOW_ITEM_TYPE_ICMP6:
 		case RTE_FLOW_ITEM_TYPE_CONNTRACK:
+		case RTE_FLOW_ITEM_TYPE_IPV6_ROUTING_EXT:
 			break;
 		case RTE_FLOW_ITEM_TYPE_INTEGRITY:
 			/*
@@ -4860,7 +4865,7 @@ flow_hw_pattern_template_create(struct rte_eth_dev *dev,
 				   "cannot create match template");
 		return NULL;
 	}
-	it->item_flags = flow_hw_rss_item_flags_get(tmpl_items);
+	it->item_flags = flow_hw_matching_item_flags_get(tmpl_items);
 	if (copied_items) {
 		if (attr->ingress)
 			it->implicit_port = true;
@@ -4868,6 +4873,17 @@ flow_hw_pattern_template_create(struct rte_eth_dev *dev,
 			it->implicit_tag = true;
 		mlx5_free(copied_items);
 	}
+	/* Either inner or outer, can't both. */
+	if (it->item_flags & (MLX5_FLOW_ITEM_OUTER_IPV6_ROUTING_EXT |
+			      MLX5_FLOW_ITEM_INNER_IPV6_ROUTING_EXT)) {
+		if (((it->item_flags & MLX5_FLOW_ITEM_OUTER_IPV6_ROUTING_EXT) &&
+		     (it->item_flags & MLX5_FLOW_ITEM_INNER_IPV6_ROUTING_EXT)) ||
+		    (mlx5_alloc_srh_flex_parser(dev))) {
+			claim_zero(mlx5dr_match_template_destroy(it->mt));
+			mlx5_free(it);
+			return NULL;
+		}
+	}
 	__atomic_fetch_add(&it->refcnt, 1, __ATOMIC_RELAXED);
 	LIST_INSERT_HEAD(&priv->flow_hw_itt, it, next);
 	return it;
@@ -4899,6 +4915,9 @@ flow_hw_pattern_template_destroy(struct rte_eth_dev *dev __rte_unused,
 				   NULL,
 				   "item template in using");
 	}
+	if (template->item_flags & (MLX5_FLOW_ITEM_OUTER_IPV6_ROUTING_EXT |
+				    MLX5_FLOW_ITEM_INNER_IPV6_ROUTING_EXT))
+		mlx5_free_srh_flex_parser(dev);
 	LIST_REMOVE(template, next);
 	claim_zero(mlx5dr_match_template_destroy(template->mt));
 	mlx5_free(template);
Signature · 1 line
2.27.0
#54 lore raw

PATCH v2 5/8 app/testpmd: add IPv6 routing extension header in raw encap

In reply to Rongwei Liu

Add IPv6 routing extension header support in raw_encap command.
1. No TLV support now.
2. Assume header length equals to the current segment_left.

---
 app/test-pmd/cmdline_flow.c | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)
app/test-pmd/cmdline_flow.c +23 -0
index 7a8516829c..4bdb46e89a 100644
@@ -10925,6 +10925,13 @@ flow_item_default_mask(const struct rte_flow_item *item)
 {
 	const void *mask = NULL;
 	static rte_be32_t gre_key_default_mask = RTE_BE32(UINT32_MAX);
+	static struct rte_flow_item_ipv6_routing_ext ipv6_routing_ext_default_mask = {
+		.hdr = {
+			.next_hdr = 0xff,
+			.type = 0xff,
+			.segments_left = 0xff,
+		},
+	};
 
 	switch (item->type) {
 	case RTE_FLOW_ITEM_TYPE_ANY:
@@ -11027,6 +11034,9 @@ flow_item_default_mask(const struct rte_flow_item *item)
 	case RTE_FLOW_ITEM_TYPE_METER_COLOR:
 		mask = &rte_flow_item_meter_color_mask;
 		break;
+	case RTE_FLOW_ITEM_TYPE_IPV6_ROUTING_EXT:
+		mask = &ipv6_routing_ext_default_mask;
+		break;
 	default:
 		break;
 	}
@@ -11181,6 +11191,7 @@ cmd_set_raw_parsed(const struct buffer *in)
 	for (i = n - 1 ; i >= 0; --i) {
 		const struct rte_flow_item_gtp *gtp;
 		const struct rte_flow_item_geneve_opt *opt;
+		struct rte_flow_item_ipv6_routing_ext *ext;
 
 		item = in->args.vc.pattern + i;
 		if (item->spec == NULL)
@@ -11201,6 +11212,18 @@ cmd_set_raw_parsed(const struct buffer *in)
 			size = sizeof(struct rte_ipv6_hdr);
 			proto = RTE_ETHER_TYPE_IPV6;
 			break;
+		case RTE_FLOW_ITEM_TYPE_IPV6_ROUTING_EXT:
+			ext = (struct rte_flow_item_ipv6_routing_ext *)(uintptr_t)item->spec;
+			if (!ext->hdr.hdr_len) {
+				size = sizeof(struct rte_ipv6_routing_ext) +
+					(ext->hdr.segments_left << 4);
+				ext->hdr.hdr_len = ext->hdr.segments_left << 1;
+			} else {
+				size = sizeof(struct rte_ipv6_routing_ext) +
+					(ext->hdr.hdr_len << 3);
+			}
+			proto = IPPROTO_ROUTING;
+			break;
 		case RTE_FLOW_ITEM_TYPE_UDP:
 			size = sizeof(struct rte_udp_hdr);
 			proto = 0x11;
Signature · 1 line
2.27.0
#55 lore raw

PATCH v2 6/8 ethdev: add modify IPv6 protocol field

In reply to Rongwei Liu

Add IPv6 protocol modify field definition.

Add new modify field destination type string: "ipv6_proto".

---
 app/test-pmd/cmdline_flow.c | 3 ++-
 lib/ethdev/rte_flow.h       | 1 +
 2 files changed, 3 insertions(+), 1 deletion(-)
app/test-pmd/cmdline_flow.c +2 -1
index 4bdb46e89a..1340cf3a9b 100644
@@ -811,7 +811,8 @@ static const char *const modify_field_ids[] = {
 	"udp_port_src", "udp_port_dst",
 	"vxlan_vni", "geneve_vni", "gtp_teid",
 	"tag", "mark", "meta", "pointer", "value",
-	"ipv4_ecn", "ipv6_ecn", "gtp_psc_qfi", "meter_color", NULL
+	"ipv4_ecn", "ipv6_ecn", "gtp_psc_qfi", "meter_color",
+	"ipv6_proto", NULL
 };
 
 static const char *const meter_colors[] = {
lib/ethdev/rte_flow.h +1 -0
index 0120d3e7d2..05a90c8201 100644
@@ -3547,6 +3547,7 @@ enum rte_flow_field_id {
 	RTE_FLOW_FIELD_IPV6_ECN,	/**< IPv6 ECN. */
 	RTE_FLOW_FIELD_GTP_PSC_QFI,	/**< GTP QFI. */
 	RTE_FLOW_FIELD_METER_COLOR,	/**< Meter color marker. */
+	RTE_FLOW_FIELD_IPV6_PROTO,	/**< IPv6 next header. */
 };
 
 /**
Signature · 1 line
2.27.0
#56 lore raw

PATCH v2 7/8 net/mlx5: add modify IPv6 protocol implementation

In reply to Rongwei Liu

Add HWS modify IPv6 protocol implementation.

---
 drivers/common/mlx5/mlx5_prm.h  |  1 +
 drivers/net/mlx5/mlx5_flow_dv.c | 10 ++++++++++
 2 files changed, 11 insertions(+)
drivers/common/mlx5/mlx5_prm.h +1 -0
index ce6cd98fd7..497f2622b2 100644
@@ -759,6 +759,7 @@ enum mlx5_modification_field {
 	MLX5_MODI_OUT_IP_ECN = 0x73,
 	MLX5_MODI_TUNNEL_HDR_DW_1 = 0x75,
 	MLX5_MODI_GTPU_FIRST_EXT_DW_0 = 0x76,
+	MLX5_MODI_OUT_IPV6_NEXT_HDR = 0x4A,
 };
 
 /* Total number of metadata reg_c's. */
drivers/net/mlx5/mlx5_flow_dv.c +10 -0
index 7ca909999b..e972a2dc5a 100644
@@ -1357,6 +1357,7 @@ mlx5_flow_item_field_width(struct rte_eth_dev *dev,
 	case RTE_FLOW_FIELD_IPV6_DSCP:
 		return 6;
 	case RTE_FLOW_FIELD_IPV6_HOPLIMIT:
+	case RTE_FLOW_FIELD_IPV6_PROTO:
 		return 8;
 	case RTE_FLOW_FIELD_IPV6_SRC:
 	case RTE_FLOW_FIELD_IPV6_DST:
@@ -1883,6 +1884,15 @@ mlx5_flow_field_id_to_modify_info
 				info[idx].offset = data->offset;
 		}
 		break;
+	case RTE_FLOW_FIELD_IPV6_PROTO:
+		MLX5_ASSERT(data->offset + width <= 8);
+		off_be = 8 - (data->offset + width);
+		info[idx] = (struct field_modify_info){1, 0, MLX5_MODI_OUT_IPV6_NEXT_HDR};
+		if (mask)
+			mask[idx] = flow_modify_info_mask_8(width, off_be);
+		else
+			info[idx].offset = off_be;
+		break;
 	case RTE_FLOW_FIELD_POINTER:
 	case RTE_FLOW_FIELD_VALUE:
 	default:
Signature · 1 line
2.27.0
#57 lore raw

PATCH v2 8/8 doc/mlx5: add IPv6 routing extension matching docs

In reply to Rongwei Liu

Update mlx5 related document on IPv6 routing extension header matching.

---
 doc/guides/nics/features/default.ini | 1 +
 doc/guides/nics/features/mlx5.ini    | 1 +
 doc/guides/nics/mlx5.rst             | 2 ++
 3 files changed, 4 insertions(+)
doc/guides/nics/features/default.ini +1 -0
index 510cc6679d..3d0744a243 100644
@@ -141,6 +141,7 @@ udp                  =
 vlan                 =
 vxlan                =
 vxlan_gpe            =
+ipv6_routing_ext     =
 
 [rte_flow actions]
 age                  =
doc/guides/nics/features/mlx5.ini +1 -0
index 62fd330e2b..bd911a467b 100644
@@ -87,6 +87,7 @@ vlan                 = Y
 vxlan                = Y
 vxlan_gpe            = Y
 represented_port     = Y
+ipv6_routing_ext     = Y
 
 [rte_flow actions]
 age                  = I
doc/guides/nics/mlx5.rst +2 -0
index f137f156f9..966f1bd83f 100644
@@ -106,6 +106,7 @@ Features
 - Sub-Function representors.
 - Sub-Function.
 - Matching on represented port.
+- Matching on IPv6 routing extension header.
 
 
 Limitations
@@ -174,6 +175,7 @@ Limitations
 
     - ``-EAGAIN`` for ``rte_eth_dev_start()``.
     - ``-EBUSY`` for ``rte_eth_dev_stop()``.
+  - Matching on ICMP6 following IPv6 routing extension header, should match ipv6_routing_ext_next_hdr instead of ICMP6.
 
 - When using Verbs flow engine (``dv_flow_en`` = 0), flow pattern without any
   specific VLAN will match for VLAN packets as well:
Signature · 1 line
2.27.0
#58 lore raw

RFC 2/9 app/testpmd: add IPv6 routing extension header support

In reply to Rongwei Liu

Add command line support for IPv6 routing extension header
matching: type/nexthdr/segment_list.

---
 app/test-pmd/cmdline_flow.c            | 41 ++++++++++++++++++++++++++
 doc/guides/rel_notes/release_22_03.rst |  6 ++++
 2 files changed, 47 insertions(+)
app/test-pmd/cmdline_flow.c +41 -0
index 88108498e0..70685aafb1 100644
@@ -298,6 +298,10 @@ enum index {
 	ITEM_IPV6_SRC,
 	ITEM_IPV6_DST,
 	ITEM_IPV6_HAS_FRAG_EXT,
+	ITEM_IPV6_ROUTING_EXT,
+	ITEM_IPV6_ROUTING_EXT_TYPE,
+	ITEM_IPV6_ROUTING_EXT_NEXT_HDR,
+	ITEM_IPV6_ROUTING_EXT_SEG_LEFT,
 	ITEM_ICMP,
 	ITEM_ICMP_TYPE,
 	ITEM_ICMP_CODE,
@@ -1326,6 +1330,7 @@ static const enum index next_item[] = {
 	ITEM_ARP_ETH_IPV4,
 	ITEM_IPV6_EXT,
 	ITEM_IPV6_FRAG_EXT,
+	ITEM_IPV6_ROUTING_EXT,
 	ITEM_ICMP6,
 	ITEM_ICMP6_ND_NS,
 	ITEM_ICMP6_ND_NA,
@@ -1435,6 +1440,10 @@ static const enum index item_ipv6[] = {
 	ITEM_IPV6_SRC,
 	ITEM_IPV6_DST,
 	ITEM_IPV6_HAS_FRAG_EXT,
+	ITEM_IPV6_ROUTING_EXT,
+	ITEM_IPV6_ROUTING_EXT_TYPE,
+	ITEM_IPV6_ROUTING_EXT_NEXT_HDR,
+	ITEM_IPV6_ROUTING_EXT_SEG_LEFT,
 	ITEM_NEXT,
 	ZERO,
 };
@@ -3844,6 +3853,38 @@ static const struct token token_list[] = {
 		.args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_ipv6,
 					   has_frag_ext, 1)),
 	},
+	[ITEM_IPV6_ROUTING_EXT] = {
+		.name = "ipv6_routing_ext",
+		.help = "match IPv6 routing extension header",
+		.priv = PRIV_ITEM(IPV6_ROUTING_EXT,
+				  sizeof(struct rte_flow_item_ipv6_routing_ext)),
+		.next = NEXT(item_ipv6),
+		.call = parse_vc,
+	},
+	[ITEM_IPV6_ROUTING_EXT_TYPE] = {
+		.name = "ipv6_routing_ext_type",
+		.help = "match IPv6 routing extension header type",
+		.next = NEXT(item_ipv6, NEXT_ENTRY(COMMON_UNSIGNED),
+			     item_param),
+		.args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6_routing_ext,
+					     hdr.type)),
+	},
+	[ITEM_IPV6_ROUTING_EXT_NEXT_HDR] = {
+		.name = "ipv6_routing_ext_next_hdr",
+		.help = "match IPv6 routing extension header next header type",
+		.next = NEXT(item_ipv6, NEXT_ENTRY(COMMON_UNSIGNED),
+			     item_param),
+		.args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6_routing_ext,
+					     hdr.nexthdr)),
+	},
+	[ITEM_IPV6_ROUTING_EXT_SEG_LEFT] = {
+		.name = "ipv6_routing_ext_seg_left",
+		.help = "match IPv6 routing extension header segment left",
+		.next = NEXT(item_ipv6, NEXT_ENTRY(COMMON_UNSIGNED),
+			     item_param),
+		.args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6_routing_ext,
+					     hdr.segments_left)),
+	},
 	[ITEM_ICMP] = {
 		.name = "icmp",
 		.help = "match ICMP header",
doc/guides/rel_notes/release_22_03.rst +6 -0
index cc050ff3e7..6208f2677c 100644
@@ -58,6 +58,12 @@ New Features
   Added ``gre_option`` item in rte_flow to support checksum/key/sequence
   matching in GRE packets.
 
+* **Added rte_flow support for matching IPv6 routing extension header fields.**
+
+  Added ``ipv6_routing_ext`` ``ipv6_routing_ext_type`` ``ipv6_routing_ext_seg_left``
+  and ``ipv6_routing_ext_next_hdr`` items in rte_flow to match IPv6 routing extension
+  header.
+
 * **Added new RSS offload types for L2TPv2 in RSS flow.**
 
   Added ``RTE_ETH_RSS_L2TPV2`` macro so that he L2TPv2 session ID field can be used as
Signature · 1 line
2.27.0
#59 lore raw

RFC 3/9 net/mlx5: adopt new flex item definition

In reply to Rongwei Liu

Per newest PRM definition, sample_id stands for 3 parts of information instead of single uint32_t id: sample_id + modify_filed_id + formate_select_dw.

Also new FW capability bits have been introduces to identify the new capability.

---
 drivers/common/mlx5/mlx5_devx_cmds.c | 13 +++++++++++--
 drivers/common/mlx5/mlx5_devx_cmds.h |  7 ++++++-
 drivers/common/mlx5/mlx5_prm.h       | 22 ++++++++++++++++++++--
 drivers/net/mlx5/mlx5.c              | 15 +++++++++++----
 drivers/net/mlx5/mlx5.h              |  3 ++-
 drivers/net/mlx5/mlx5_flow_flex.c    | 14 +++++++++++---
 6 files changed, 61 insertions(+), 13 deletions(-)
drivers/common/mlx5/mlx5_devx_cmds.c +11 -2
index 59cebb530f..ccd03e2a94 100644
@@ -607,7 +607,8 @@ mlx5_devx_cmd_query_hca_vdpa_attr(void *ctx,
 
 int
 mlx5_devx_cmd_query_parse_samples(struct mlx5_devx_obj *flex_obj,
-				  uint32_t ids[], uint32_t num)
+				  struct mlx5_ext_sample_id ids[],
+				  uint32_t num, uint8_t *anchor)
 {
 	uint32_t in[MLX5_ST_SZ_DW(general_obj_in_cmd_hdr)] = {0};
 	uint32_t out[MLX5_ST_SZ_DW(create_flex_parser_out)] = {0};
@@ -636,6 +637,7 @@ mlx5_devx_cmd_query_parse_samples(struct mlx5_devx_obj *flex_obj,
 			(void *)flex_obj);
 		return -rte_errno;
 	}
+	*anchor = MLX5_GET(parse_graph_flex, flex, head_anchor_id);
 	for (i = 0; i < MLX5_GRAPH_NODE_SAMPLE_NUM; i++) {
 		void *s_off = (void *)((char *)sample + i *
 			      MLX5_ST_SZ_BYTES(parse_graph_flow_match_sample));
@@ -645,8 +647,9 @@ mlx5_devx_cmd_query_parse_samples(struct mlx5_devx_obj *flex_obj,
 			      flow_match_sample_en);
 		if (!en)
 			continue;
-		ids[idx++] = MLX5_GET(parse_graph_flow_match_sample, s_off,
+		ids[idx++].id = MLX5_GET(parse_graph_flow_match_sample, s_off,
 				  flow_match_sample_field_id);
+		printf("id index %d val %x\n", idx - 1, ids[idx-1].id);
 	}
 	if (num != idx) {
 		rte_errno = EINVAL;
@@ -794,6 +797,12 @@ mlx5_devx_cmd_query_hca_parse_graph_node_cap
 					 max_num_arc_out);
 	attr->max_num_sample = MLX5_GET(parse_graph_node_cap, hcattr,
 					max_num_sample);
+	attr->anchor_en = MLX5_GET(parse_graph_node_cap, hcattr, anchor_en);
+	attr->ext_sample_id = MLX5_GET(parse_graph_node_cap, hcattr, ext_sample_id);
+	attr->sample_tunnel_inner2 = MLX5_GET(parse_graph_node_cap, hcattr,
+					      sample_tunnel_inner2);
+	attr->zero_size_supported = MLX5_GET(parse_graph_node_cap, hcattr,
+					     zero_size_supported);
 	attr->sample_id_in_out = MLX5_GET(parse_graph_node_cap, hcattr,
 					  sample_id_in_out);
 	attr->max_base_header_length = MLX5_GET(parse_graph_node_cap, hcattr,
drivers/common/mlx5/mlx5_devx_cmds.h +6 -1
index c94b9eac06..5b33010155 100644
@@ -114,6 +114,10 @@ struct mlx5_hca_flex_attr {
 	uint8_t  max_num_arc_out;
 	uint8_t  max_num_sample;
 	uint8_t  max_num_prog_sample:5;	/* From HCA CAP 2 */
+	uint8_t  anchor_en:1;
+	uint8_t  ext_sample_id:1;
+	uint8_t  sample_tunnel_inner2:1;
+	uint8_t  zero_size_supported:1;
 	uint8_t  sample_id_in_out:1;
 	uint16_t max_base_header_length;
 	uint8_t  max_sample_base_offset;
@@ -706,7 +710,8 @@ int mlx5_devx_cmd_modify_tir(struct mlx5_devx_obj *tir,
 			     struct mlx5_devx_modify_tir_attr *tir_attr);
 __rte_internal
 int mlx5_devx_cmd_query_parse_samples(struct mlx5_devx_obj *flex_obj,
-				      uint32_t ids[], uint32_t num);
+				      struct mlx5_ext_sample_id ids[],
+				      uint32_t num, uint8_t *anchor);
 
 __rte_internal
 struct mlx5_devx_obj *
drivers/common/mlx5/mlx5_prm.h +20 -2
index 2b5c43ee6e..1545b929b6 100644
@@ -1890,7 +1890,11 @@ struct mlx5_ifc_parse_graph_node_cap_bits {
 	u8 max_num_arc_in[0x08];
 	u8 max_num_arc_out[0x08];
 	u8 max_num_sample[0x08];
-	u8 reserved_at_78[0x07];
+	u8 reserved_at_78[0x03];
+	u8 anchor_en[0x1];
+	u8 ext_sample_id[0x1];
+	u8 sample_tunnel_inner2[0x1];
+	u8 zero_size_supported[0x1];
 	u8 sample_id_in_out[0x1];
 	u8 max_base_header_length[0x10];
 	u8 reserved_at_90[0x08];
@@ -1900,6 +1904,18 @@ struct mlx5_ifc_parse_graph_node_cap_bits {
 	u8 header_length_mask_width[0x08];
 };
 
+/* ext_sample_id structure, see PRM Table 539. */
+struct mlx5_ext_sample_id {
+	union {
+		struct {
+			uint32_t format_select_dw:8;
+			uint32_t modify_field_id:12;
+			uint32_t sample_id:12;
+		};
+		uint32_t id;
+	};
+};
+
 struct mlx5_ifc_flow_table_prop_layout_bits {
 	u8 ft_support[0x1];
 	u8 flow_tag[0x1];
@@ -4455,7 +4471,9 @@ struct mlx5_ifc_parse_graph_flex_bits {
 	u8 header_length_mode[0x4];
 	u8 header_length_field_offset[0x10];
 	u8 next_header_field_offset[0x10];
-	u8 reserved_at_160[0x1b];
+	u8 reserved_at_160[0x12];
+	u8 head_anchor_id[0x6];
+	u8 reserved_at_178[0x3];
 	u8 next_header_field_size[0x5];
 	u8 header_length_field_mask[0x20];
 	u8 reserved_at_224[0x20];
drivers/net/mlx5/mlx5.c +11 -4
index e55be8720e..04b641aa75 100644
@@ -964,11 +964,13 @@ int
 mlx5_flex_parser_ecpri_alloc(struct rte_eth_dev *dev)
 {
 	struct mlx5_priv *priv = dev->data->dev_private;
+	struct mlx5_hca_flex_attr *attr = &priv->sh->cdev->config.hca_attr.flex;
 	struct mlx5_ecpri_parser_profile *prf =	&priv->sh->ecpri_parser;
 	struct mlx5_devx_graph_node_attr node = {
 		.modify_field_select = 0,
 	};
-	uint32_t ids[8];
+	struct mlx5_ext_sample_id ids[8];
+	uint8_t anchor_id;
 	int ret;
 
 	if (!priv->sh->cdev->config.hca_attr.parse_graph_flex_node) {
@@ -1004,15 +1006,20 @@ mlx5_flex_parser_ecpri_alloc(struct rte_eth_dev *dev)
 		return (rte_errno == 0) ? -ENODEV : -rte_errno;
 	}
 	prf->num = 2;
-	ret = mlx5_devx_cmd_query_parse_samples(prf->obj, ids, prf->num);
+	ret = mlx5_devx_cmd_query_parse_samples(prf->obj, ids, prf->num, &anchor_id);
 	if (ret) {
 		DRV_LOG(ERR, "Failed to query sample IDs.");
 		return (rte_errno == 0) ? -ENODEV : -rte_errno;
 	}
 	prf->offset[0] = 0x0;
 	prf->offset[1] = sizeof(uint32_t);
-	prf->ids[0] = ids[0];
-	prf->ids[1] = ids[1];
+	if (attr->ext_sample_id) {
+		prf->ids[0] = ids[0].sample_id;
+		prf->ids[1] = ids[1].sample_id;
+	} else {
+		prf->ids[0] = ids[0].id;
+		prf->ids[1] = ids[1].id;
+	}
 	return 0;
 }
 
drivers/net/mlx5/mlx5.h +2 -1
index 31982002ee..1c11b77ac3 100644
@@ -1307,9 +1307,10 @@ struct mlx5_lag {
 struct mlx5_flex_parser_devx {
 	struct mlx5_list_entry entry;  /* List element at the beginning. */
 	uint32_t num_samples;
+	uint8_t anchor_id;
 	void *devx_obj;
 	struct mlx5_devx_graph_node_attr devx_conf;
-	uint32_t sample_ids[MLX5_GRAPH_NODE_SAMPLE_NUM];
+	struct mlx5_ext_sample_id sample_ids[MLX5_GRAPH_NODE_SAMPLE_NUM];
 };
 
 /* Pattern field descriptor - how to translate flex pattern into samples. */
drivers/net/mlx5/mlx5_flow_flex.c +11 -3
index fb08910ddb..35f2a9923d 100644
@@ -226,15 +226,18 @@ mlx5_flex_flow_translate_item(struct rte_eth_dev *dev,
 	void *misc4_m = MLX5_ADDR_OF(fte_match_param, matcher,
 				     misc_parameters_4);
 	void *misc4_v = MLX5_ADDR_OF(fte_match_param, key, misc_parameters_4);
+	struct mlx5_priv *priv = dev->data->dev_private;
+	struct mlx5_hca_flex_attr *attr = &priv->sh->cdev->config.hca_attr.flex;
 	struct mlx5_flex_item *tp;
 	uint32_t i, pos = 0;
+	uint32_t sample_id;
 
 	RTE_SET_USED(dev);
 	MLX5_ASSERT(item->spec && item->mask);
 	spec = item->spec;
 	mask = item->mask;
 	tp = (struct mlx5_flex_item *)spec->handle;
-	MLX5_ASSERT(mlx5_flex_index(dev->data->dev_private, tp) >= 0);
+	MLX5_ASSERT(mlx5_flex_index(priv, tp) >= 0);
 	for (i = 0; i < tp->mapnum; i++) {
 		struct mlx5_flex_pattern_field *map = tp->map + i;
 		uint32_t id = map->reg_id;
@@ -257,9 +260,13 @@ mlx5_flex_flow_translate_item(struct rte_eth_dev *dev,
 			MLX5_ASSERT(id < num_samples);
 			id += num_samples;
 		}
+		if (attr->ext_sample_id)
+			sample_id = tp->devx_fp->sample_ids[id].sample_id;
+		else
+			sample_id = tp->devx_fp->sample_ids[id].id;
 		mlx5_flex_set_match_sample(misc4_m, misc4_v,
 					   def, msk & def, val & msk & def,
-					   tp->devx_fp->sample_ids[id], id);
+					   sample_id, id);
 		pos += map->width;
 	}
 }
@@ -1298,7 +1305,8 @@ mlx5_flex_parser_create_cb(void *list_ctx, void *ctx)
 	/* Query the firmware assigned sample ids. */
 	ret = mlx5_devx_cmd_query_parse_samples(fp->devx_obj,
 						fp->sample_ids,
-						fp->num_samples);
+						fp->num_samples,
+						&fp->anchor_id);
 	if (ret)
 		goto error;
 	DRV_LOG(DEBUG, "DEVx flex parser %p created, samples num: %u",
Signature · 1 line
2.27.0
#60 lore raw

RFC 4/9 net/mlx5/hws: Definer, add mlx5dr context to definer_conv_data

In reply to Rongwei Liu

New mlx5dr_context member replaces mlx5dr_cmd_query_caps. Capabilities structure is a member of mlx5dr_context.

---
 drivers/net/mlx5/hws/mlx5dr_definer.c | 41 ++++++++++++++-------------
 1 file changed, 22 insertions(+), 19 deletions(-)
drivers/net/mlx5/hws/mlx5dr_definer.c +22 -19
index 6b98eb8c96..10b1e43d6e 100644
@@ -100,7 +100,7 @@ struct mlx5dr_definer_sel_ctrl {
 };
 
 struct mlx5dr_definer_conv_data {
-	struct mlx5dr_cmd_query_caps *caps;
+	struct mlx5dr_context *ctx;
 	struct mlx5dr_definer_fc *fc;
 	uint8_t relaxed;
 	uint8_t tunnel;
@@ -815,6 +815,7 @@ mlx5dr_definer_conv_item_gtp(struct mlx5dr_definer_conv_data *cd,
 			     struct rte_flow_item *item,
 			     int item_idx)
 {
+	struct mlx5dr_cmd_query_caps *caps = cd->ctx->caps;
 	const struct rte_flow_item_gtp *m = item->mask;
 	struct mlx5dr_definer_fc *fc;
 
@@ -836,7 +837,7 @@ mlx5dr_definer_conv_item_gtp(struct mlx5dr_definer_conv_data *cd,
 	}
 
 	if (m->teid) {
-		if (!(cd->caps->flex_protocols & MLX5_HCA_FLEX_GTPU_TEID_ENABLED)) {
+		if (!(caps->flex_protocols & MLX5_HCA_FLEX_GTPU_TEID_ENABLED)) {
 			rte_errno = ENOTSUP;
 			return rte_errno;
 		}
@@ -844,11 +845,11 @@ mlx5dr_definer_conv_item_gtp(struct mlx5dr_definer_conv_data *cd,
 		fc->item_idx = item_idx;
 		fc->tag_set = &mlx5dr_definer_gtp_teid_set;
 		fc->bit_mask = __mlx5_mask(header_gtp, teid);
-		fc->byte_off = cd->caps->format_select_gtpu_dw_1 * DW_SIZE;
+		fc->byte_off = caps->format_select_gtpu_dw_1 * DW_SIZE;
 	}
 
 	if (m->v_pt_rsv_flags) {
-		if (!(cd->caps->flex_protocols & MLX5_HCA_FLEX_GTPU_DW_0_ENABLED)) {
+		if (!(caps->flex_protocols & MLX5_HCA_FLEX_GTPU_DW_0_ENABLED)) {
 			rte_errno = ENOTSUP;
 			return rte_errno;
 		}
@@ -857,12 +858,12 @@ mlx5dr_definer_conv_item_gtp(struct mlx5dr_definer_conv_data *cd,
 		fc->tag_set = &mlx5dr_definer_gtp_ext_flag_set;
 		fc->bit_mask = __mlx5_mask(header_gtp, ext_hdr_flag);
 		fc->bit_off = __mlx5_dw_bit_off(header_gtp, ext_hdr_flag);
-		fc->byte_off = cd->caps->format_select_gtpu_dw_0 * DW_SIZE;
+		fc->byte_off = caps->format_select_gtpu_dw_0 * DW_SIZE;
 	}
 
 
 	if (m->msg_type) {
-		if (!(cd->caps->flex_protocols & MLX5_HCA_FLEX_GTPU_DW_0_ENABLED)) {
+		if (!(caps->flex_protocols & MLX5_HCA_FLEX_GTPU_DW_0_ENABLED)) {
 			rte_errno = ENOTSUP;
 			return rte_errno;
 		}
@@ -871,7 +872,7 @@ mlx5dr_definer_conv_item_gtp(struct mlx5dr_definer_conv_data *cd,
 		fc->tag_set = &mlx5dr_definer_gtp_msg_type_set;
 		fc->bit_mask = __mlx5_mask(header_gtp, msg_type);
 		fc->bit_off = __mlx5_dw_bit_off(header_gtp, msg_type);
-		fc->byte_off = cd->caps->format_select_gtpu_dw_0 * DW_SIZE;
+		fc->byte_off = caps->format_select_gtpu_dw_0 * DW_SIZE;
 	}
 
 	return 0;
@@ -882,12 +883,13 @@ mlx5dr_definer_conv_item_gtp_psc(struct mlx5dr_definer_conv_data *cd,
 				 struct rte_flow_item *item,
 				 int item_idx)
 {
+	struct mlx5dr_cmd_query_caps *caps = cd->ctx->caps;
 	const struct rte_flow_item_gtp_psc *m = item->mask;
 	struct mlx5dr_definer_fc *fc;
 
 	/* Overwrite GTP extension flag to be 1 */
 	if (!cd->relaxed) {
-		if (!(cd->caps->flex_protocols & MLX5_HCA_FLEX_GTPU_DW_0_ENABLED)) {
+		if (!(caps->flex_protocols & MLX5_HCA_FLEX_GTPU_DW_0_ENABLED)) {
 			rte_errno = ENOTSUP;
 			return rte_errno;
 		}
@@ -896,12 +898,12 @@ mlx5dr_definer_conv_item_gtp_psc(struct mlx5dr_definer_conv_data *cd,
 		fc->tag_set = &mlx5dr_definer_ones_set;
 		fc->bit_mask = __mlx5_mask(header_gtp, ext_hdr_flag);
 		fc->bit_off = __mlx5_dw_bit_off(header_gtp, ext_hdr_flag);
-		fc->byte_off = cd->caps->format_select_gtpu_dw_0 * DW_SIZE;
+		fc->byte_off = caps->format_select_gtpu_dw_0 * DW_SIZE;
 	}
 
 	/* Overwrite next extension header type */
 	if (!cd->relaxed) {
-		if (!(cd->caps->flex_protocols & MLX5_HCA_FLEX_GTPU_DW_2_ENABLED)) {
+		if (!(caps->flex_protocols & MLX5_HCA_FLEX_GTPU_DW_2_ENABLED)) {
 			rte_errno = ENOTSUP;
 			return rte_errno;
 		}
@@ -911,14 +913,14 @@ mlx5dr_definer_conv_item_gtp_psc(struct mlx5dr_definer_conv_data *cd,
 		fc->tag_mask_set = &mlx5dr_definer_ones_set;
 		fc->bit_mask = __mlx5_mask(header_opt_gtp, next_ext_hdr_type);
 		fc->bit_off = __mlx5_dw_bit_off(header_opt_gtp, next_ext_hdr_type);
-		fc->byte_off = cd->caps->format_select_gtpu_dw_2 * DW_SIZE;
+		fc->byte_off = caps->format_select_gtpu_dw_2 * DW_SIZE;
 	}
 
 	if (!m)
 		return 0;
 
 	if (m->hdr.type) {
-		if (!(cd->caps->flex_protocols & MLX5_HCA_FLEX_GTPU_FIRST_EXT_DW_0_ENABLED)) {
+		if (!(caps->flex_protocols & MLX5_HCA_FLEX_GTPU_FIRST_EXT_DW_0_ENABLED)) {
 			rte_errno = ENOTSUP;
 			return rte_errno;
 		}
@@ -927,11 +929,11 @@ mlx5dr_definer_conv_item_gtp_psc(struct mlx5dr_definer_conv_data *cd,
 		fc->tag_set = &mlx5dr_definer_gtp_ext_hdr_pdu_set;
 		fc->bit_mask = __mlx5_mask(header_gtp_psc, pdu_type);
 		fc->bit_off = __mlx5_dw_bit_off(header_gtp_psc, pdu_type);
-		fc->byte_off = cd->caps->format_select_gtpu_ext_dw_0 * DW_SIZE;
+		fc->byte_off = caps->format_select_gtpu_ext_dw_0 * DW_SIZE;
 	}
 
 	if (m->hdr.qfi) {
-		if (!(cd->caps->flex_protocols & MLX5_HCA_FLEX_GTPU_FIRST_EXT_DW_0_ENABLED)) {
+		if (!(caps->flex_protocols & MLX5_HCA_FLEX_GTPU_FIRST_EXT_DW_0_ENABLED)) {
 			rte_errno = ENOTSUP;
 			return rte_errno;
 		}
@@ -940,7 +942,7 @@ mlx5dr_definer_conv_item_gtp_psc(struct mlx5dr_definer_conv_data *cd,
 		fc->tag_set = &mlx5dr_definer_gtp_ext_hdr_qfi_set;
 		fc->bit_mask = __mlx5_mask(header_gtp_psc, qfi);
 		fc->bit_off = __mlx5_dw_bit_off(header_gtp_psc, qfi);
-		fc->byte_off = cd->caps->format_select_gtpu_ext_dw_0 * DW_SIZE;
+		fc->byte_off = caps->format_select_gtpu_ext_dw_0 * DW_SIZE;
 	}
 
 	return 0;
@@ -951,18 +953,19 @@ mlx5dr_definer_conv_item_port(struct mlx5dr_definer_conv_data *cd,
 			      struct rte_flow_item *item,
 			      int item_idx)
 {
+	struct mlx5dr_cmd_query_caps *caps = cd->ctx->caps;
 	const struct rte_flow_item_ethdev *m = item->mask;
 	struct mlx5dr_definer_fc *fc;
 	uint8_t bit_offset = 0;
 
 	if (m->port_id) {
-		if (!cd->caps->wire_regc_mask) {
+		if (!caps->wire_regc_mask) {
 			DR_LOG(ERR, "Port ID item not supported, missing wire REGC mask");
 			rte_errno = ENOTSUP;
 			return rte_errno;
 		}
 
-		while (!(cd->caps->wire_regc_mask & (1 << bit_offset)))
+		while (!(caps->wire_regc_mask & (1 << bit_offset)))
 			bit_offset++;
 
 		fc = &cd->fc[MLX5DR_DEFINER_FNAME_VPORT_REG_C_0];
@@ -971,7 +974,7 @@ mlx5dr_definer_conv_item_port(struct mlx5dr_definer_conv_data *cd,
 		fc->tag_mask_set = &mlx5dr_definer_ones_set;
 		DR_CALC_SET_HDR(fc, registers, register_c_0);
 		fc->bit_off = bit_offset;
-		fc->bit_mask = cd->caps->wire_regc_mask >> bit_offset;
+		fc->bit_mask = caps->wire_regc_mask >> bit_offset;
 	} else {
 		DR_LOG(ERR, "Pord ID item mask must specify ID mask");
 		rte_errno = EINVAL;
@@ -1480,7 +1483,7 @@ mlx5dr_definer_conv_items_to_hl(struct mlx5dr_context *ctx,
 
 	cd.fc = fc;
 	cd.hl = hl;
-	cd.caps = ctx->caps;
+	cd.ctx = ctx;
 	cd.relaxed = mt->flags & MLX5DR_MATCH_TEMPLATE_FLAG_RELAXED_MATCH;
 
 	/* Collect all RTE fields to the field array and set header layout */
Signature · 1 line
2.27.0
#61 lore raw

RFC 5/9 net/mlx5/hws: add IPv6 routing extension matching support

In reply to Rongwei Liu

Add mlx5 HWS logic to match IPv6 routing extension header.

Once detecting IPv6 matching extension items in pattern template create callback, PMD allocates a flex parser to sample the first dword of srv6 header.

Only support next_hdr/segments_left/type for now.

---
 doc/guides/nics/features/mlx5.ini     |   1 +
 doc/guides/nics/mlx5.rst              |   1 +
 drivers/net/mlx5/hws/mlx5dr.h         |  21 ++++++
 drivers/net/mlx5/hws/mlx5dr_context.c |  81 +++++++++++++++++++-
 drivers/net/mlx5/hws/mlx5dr_context.h |   1 +
 drivers/net/mlx5/hws/mlx5dr_definer.c | 103 ++++++++++++++++++++++++++
 drivers/net/mlx5/mlx5.h               |  10 +++
 drivers/net/mlx5/mlx5_flow.h          |   3 +
 drivers/net/mlx5/mlx5_flow_hw.c       |  39 ++++++++--
 9 files changed, 250 insertions(+), 10 deletions(-)
doc/guides/nics/features/mlx5.ini +1 -0
index 62fd330e2b..bd911a467b 100644
@@ -87,6 +87,7 @@ vlan                 = Y
 vxlan                = Y
 vxlan_gpe            = Y
 represented_port     = Y
+ipv6_routing_ext     = Y
 
 [rte_flow actions]
 age                  = I
doc/guides/nics/mlx5.rst +1 -0
index 51f51259e3..98dcf9af16 100644
@@ -106,6 +106,7 @@ Features
 - Sub-Function representors.
 - Sub-Function.
 - Matching on represented port.
+- Matching on IPv6 routing extension header.
 
 
 Limitations
drivers/net/mlx5/hws/mlx5dr.h +21 -0
index f8de27c615..ba1566de9f 100644
@@ -592,4 +592,25 @@ int mlx5dr_send_queue_action(struct mlx5dr_context *ctx,
  */
 int mlx5dr_debug_dump(struct mlx5dr_context *ctx, FILE *f);
 
+/* Allocate an internal flex parser for srv6 option.
+ *
+ * @param[in] dr_ctx
+ *	The dr_context which the flex parser belongs to.
+ * @param[in] config
+ *	Devx configuration per port.
+ * @param[in] ctx
+ *	Device contex
+ * @return zero on success non zero otherwise.
+ */
+int mlx5dr_alloc_srh_flex_parser(struct mlx5dr_context *dr_ctx,
+				 struct mlx5_common_dev_config *config,
+				 void *ctx);
+
+/* Free srv6 flex parser.
+ *
+ * @param[in] dr_ctx
+ *	The dr_context which the flex parser belongs to.
+ * @return zero on success non zero otherwise.
+ */
+int mlx5dr_free_srh_flex_parser(struct mlx5dr_context *dr_ctx);
 #endif
drivers/net/mlx5/hws/mlx5dr_context.c +79 -2

107 lines not on this page · raw message

drivers/net/mlx5/hws/mlx5dr_context.h +1 -0
index b0c7802daf..c1c627aced 100644
@@ -35,6 +35,7 @@ struct mlx5dr_context {
 	struct mlx5dr_send_engine *send_queue;
 	size_t queues;
 	LIST_HEAD(table_head, mlx5dr_table) head;
+	struct mlx5_internal_flex_parser_profile *srh_flex_parser;
 };
 
 #endif /* MLX5DR_CONTEXT_H_ */
drivers/net/mlx5/hws/mlx5dr_definer.c +103 -0

127 lines not on this page · raw message

drivers/net/mlx5/mlx5.h +10 -0
index 1c11b77ac3..6dbd5f9622 100644
@@ -543,6 +543,16 @@ struct mlx5_counter_stats_raw {
 	volatile struct flow_counter_stats *data;
 };
 
+/* Mlx5 internal flex parser profile structure. */
+struct mlx5_internal_flex_parser_profile {
+	uint32_t num;/* Actual number of samples. */
+	struct mlx5_ext_sample_id ids[MLX5_FLEX_ITEM_MAPPING_NUM];/* Sample IDs for this profile. */
+	uint32_t offset[MLX5_FLEX_ITEM_MAPPING_NUM];/* Each ID sample offset. */
+	uint8_t anchor_id;
+	uint32_t refcnt;
+	void *fp; /* DevX flex parser object. */
+};
+
 TAILQ_HEAD(mlx5_counter_pools, mlx5_flow_counter_pool);
 
 /* Counter global management structure. */
drivers/net/mlx5/mlx5_flow.h +3 -0
index 1f57ecd6e1..81e2bc47a0 100644
@@ -218,6 +218,9 @@ enum mlx5_feature_name {
 
 /* Meter color item */
 #define MLX5_FLOW_ITEM_METER_COLOR (UINT64_C(1) << 44)
+/* IPv6 routing extension item */
+#define MLX5_FLOW_ITEM_OUTER_IPV6_ROUTING_EXT (UINT64_C(1) << 45)
+#define MLX5_FLOW_ITEM_INNER_IPV6_ROUTING_EXT (UINT64_C(1) << 46)
 
 /* Outer Masks. */
 #define MLX5_FLOW_LAYER_OUTER_L3 \
drivers/net/mlx5/mlx5_flow_hw.c +31 -8
index 20c71ff7f0..ff52eb28f0 100644
@@ -213,23 +213,25 @@ flow_hw_hashfields_set(struct mlx5_flow_rss_desc *rss_desc,
 }
 
 /**
- * Generate the pattern item flags.
+ * Generate the matching pattern item flags.
  * Will be used for shared RSS action.
  *
  * @param[in] items
  *   Pointer to the list of items.
+ * @param[out] flags
+ *   Flags superset including non-RSS items.
  *
  * @return
- *   Item flags.
+ *   RSS Item flags.
  */
 static uint64_t
-flow_hw_rss_item_flags_get(const struct rte_flow_item items[])
+flow_hw_matching_item_flags_get(const struct rte_flow_item items[], uint64_t *flags)
 {
-	uint64_t item_flags = 0;
 	uint64_t last_item = 0;
 
+	*flags = 0;
 	for (; items->type != RTE_FLOW_ITEM_TYPE_END; items++) {
-		int tunnel = !!(item_flags & MLX5_FLOW_LAYER_TUNNEL);
+		int tunnel = !!(*flags & MLX5_FLOW_LAYER_TUNNEL);
 		int item_type = items->type;
 
 		switch (item_type) {
@@ -249,6 +251,10 @@ flow_hw_rss_item_flags_get(const struct rte_flow_item items[])
 			last_item = tunnel ? MLX5_FLOW_LAYER_INNER_L4_UDP :
 					     MLX5_FLOW_LAYER_OUTER_L4_UDP;
 			break;
+		case RTE_FLOW_ITEM_TYPE_IPV6_ROUTING_EXT:
+			last_item = tunnel ? MLX5_FLOW_ITEM_INNER_IPV6_ROUTING_EXT :
+					     MLX5_FLOW_ITEM_OUTER_IPV6_ROUTING_EXT;
+			break;
 		case RTE_FLOW_ITEM_TYPE_GRE:
 			last_item = MLX5_FLOW_LAYER_GRE;
 			break;
@@ -273,9 +279,10 @@ flow_hw_rss_item_flags_get(const struct rte_flow_item items[])
 		default:
 			break;
 		}
-		item_flags |= last_item;
+		*flags |= last_item;
 	}
-	return item_flags;
+	return *flags & ~(MLX5_FLOW_ITEM_INNER_IPV6_ROUTING_EXT |
+			  MLX5_FLOW_ITEM_OUTER_IPV6_ROUTING_EXT);
 }
 
 /**
@@ -4732,6 +4739,7 @@ flow_hw_pattern_validate(struct rte_eth_dev *dev,
 		case RTE_FLOW_ITEM_TYPE_ICMP:
 		case RTE_FLOW_ITEM_TYPE_ICMP6:
 		case RTE_FLOW_ITEM_TYPE_CONNTRACK:
+		case RTE_FLOW_ITEM_TYPE_IPV6_ROUTING_EXT:
 			break;
 		case RTE_FLOW_ITEM_TYPE_INTEGRITY:
 			/*
@@ -4809,6 +4817,8 @@ flow_hw_pattern_template_create(struct rte_eth_dev *dev,
 		.mask = &tag_m,
 		.last = NULL
 	};
+	struct mlx5dr_context *dr_ctx = priv->dr_ctx;
+	uint64_t flags;
 
 	if (flow_hw_pattern_validate(dev, attr, items, error))
 		return NULL;
@@ -4860,7 +4870,7 @@ flow_hw_pattern_template_create(struct rte_eth_dev *dev,
 				   "cannot create match template");
 		return NULL;
 	}
-	it->item_flags = flow_hw_rss_item_flags_get(tmpl_items);
+	it->item_flags = flow_hw_matching_item_flags_get(tmpl_items, &flags);
 	if (copied_items) {
 		if (attr->ingress)
 			it->implicit_port = true;
@@ -4868,6 +4878,15 @@ flow_hw_pattern_template_create(struct rte_eth_dev *dev,
 			it->implicit_tag = true;
 		mlx5_free(copied_items);
 	}
+	if (flags & (MLX5_FLOW_ITEM_OUTER_IPV6_ROUTING_EXT |
+		     MLX5_FLOW_ITEM_INNER_IPV6_ROUTING_EXT)) {
+		if (mlx5dr_alloc_srh_flex_parser(dr_ctx, &priv->sh->cdev->config,
+						 priv->sh->cdev->ctx)) {
+			claim_zero(mlx5dr_match_template_destroy(it->mt));
+			mlx5_free(it);
+			return NULL;
+		}
+	}
 	__atomic_fetch_add(&it->refcnt, 1, __ATOMIC_RELAXED);
 	LIST_INSERT_HEAD(&priv->flow_hw_itt, it, next);
 	return it;
@@ -4891,6 +4910,9 @@ flow_hw_pattern_template_destroy(struct rte_eth_dev *dev __rte_unused,
 			      struct rte_flow_pattern_template *template,
 			      struct rte_flow_error *error __rte_unused)
 {
+	struct mlx5_priv *priv = dev->data->dev_private;
+	struct mlx5dr_context *dr_ctx = priv->dr_ctx;
+
 	if (__atomic_load_n(&template->refcnt, __ATOMIC_RELAXED) > 1) {
 		DRV_LOG(WARNING, "Item template %p is still in use.",
 			(void *)template);
@@ -4899,6 +4921,7 @@ flow_hw_pattern_template_destroy(struct rte_eth_dev *dev __rte_unused,
 				   NULL,
 				   "item template in using");
 	}
+	mlx5dr_free_srh_flex_parser(dr_ctx);
 	LIST_REMOVE(template, next);
 	claim_zero(mlx5dr_match_template_destroy(template->mt));
 	mlx5_free(template);
Signature · 1 line
2.27.0
#62 lore raw

RFC 6/9 app/testpmd: add IPv6 routing extension header in raw encap

In reply to Rongwei Liu

Add IPv6 routing extension header support in raw_encap command.
1. No TLV support now.
2. Assume header length equals to the current segment_left.

---
 app/test-pmd/cmdline_flow.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
app/test-pmd/cmdline_flow.c +17 -0
index 70685aafb1..24fdb260e9 100644
@@ -10920,6 +10920,13 @@ flow_item_default_mask(const struct rte_flow_item *item)
 {
 	const void *mask = NULL;
 	static rte_be32_t gre_key_default_mask = RTE_BE32(UINT32_MAX);
+	static struct rte_flow_item_ipv6_routing_ext ipv6_routing_ext_default_mask = {
+		.hdr = {
+			.nexthdr = 0xff,
+			.type = 0xff,
+			.segments_left = 0xff,
+		},
+	};
 
 	switch (item->type) {
 	case RTE_FLOW_ITEM_TYPE_ANY:
@@ -11022,6 +11029,9 @@ flow_item_default_mask(const struct rte_flow_item *item)
 	case RTE_FLOW_ITEM_TYPE_METER_COLOR:
 		mask = &rte_flow_item_meter_color_mask;
 		break;
+	case RTE_FLOW_ITEM_TYPE_IPV6_ROUTING_EXT:
+		mask = &ipv6_routing_ext_default_mask;
+		break;
 	default:
 		break;
 	}
@@ -11176,6 +11186,7 @@ cmd_set_raw_parsed(const struct buffer *in)
 	for (i = n - 1 ; i >= 0; --i) {
 		const struct rte_flow_item_gtp *gtp;
 		const struct rte_flow_item_geneve_opt *opt;
+		struct rte_flow_item_ipv6_routing_ext *ext;
 
 		item = in->args.vc.pattern + i;
 		if (item->spec == NULL)
@@ -11196,6 +11207,12 @@ cmd_set_raw_parsed(const struct buffer *in)
 			size = sizeof(struct rte_ipv6_hdr);
 			proto = RTE_ETHER_TYPE_IPV6;
 			break;
+		case RTE_FLOW_ITEM_TYPE_IPV6_ROUTING_EXT:
+			ext = (struct rte_flow_item_ipv6_routing_ext *)(uintptr_t)item->spec;
+			size = sizeof(struct rte_ipv6_routing_ext) + (ext->hdr.segments_left << 4);
+			ext->hdr.hdrlen = ext->hdr.segments_left << 1;
+			proto = IPPROTO_ROUTING;
+			break;
 		case RTE_FLOW_ITEM_TYPE_UDP:
 			size = sizeof(struct rte_udp_hdr);
 			proto = 0x11;
Signature · 1 line
2.27.0
#63 lore raw

RFC 7/9 ethdev: add modify IPv6 protocol field

In reply to Rongwei Liu

Add IPv6 protocol modify field definition.

---
 lib/ethdev/rte_flow.h | 1 +
 1 file changed, 1 insertion(+)
lib/ethdev/rte_flow.h +1 -0
index f8f1d6f9dd..b1240b0cb0 100644
@@ -3567,6 +3567,7 @@ enum rte_flow_field_id {
 	RTE_FLOW_FIELD_IPV6_ECN,	/**< IPv6 ECN. */
 	RTE_FLOW_FIELD_GTP_PSC_QFI,	/**< GTP QFI. */
 	RTE_FLOW_FIELD_METER_COLOR,	/**< Meter color marker. */
+	RTE_FLOW_FIELD_IPV6_PROTO,	/**< IPv6 next header. */
 };
 
 /**
Signature · 1 line
2.27.0
Acked-by on v1 7/9
#64 lore raw

RE: [RFC 7/9] ethdev: add modify IPv6 protocol field

Hi Rongwei,

Quoted 24 lines

-----Original Message-----
From: Rongwei Liu <[email protected]>
Sent: Wednesday, 21 December 2022 10:43

Add IPv6 protocol modify field definition.

---
 lib/ethdev/rte_flow.h | 1 +
 1 file changed, 1 insertion(+)
lib/ethdev/rte_flow.h +1 -1
index f8f1d6f9dd..b1240b0cb0 100644
@@ -3567,6 +3567,7 @@ enum rte_flow_field_id {
 	RTE_FLOW_FIELD_IPV6_ECN,	/**< IPv6 ECN. */
 	RTE_FLOW_FIELD_GTP_PSC_QFI,	/**< GTP QFI. */
 	RTE_FLOW_FIELD_METER_COLOR,	/**< Meter color marker. */
+	RTE_FLOW_FIELD_IPV6_PROTO,	/**< IPv6 next header. */
 };
 
 /**
--
Quoted 1 line

2.27.0

Best,
Ori

#65 lore raw

RFC 8/9 app/testpmd: add modify IPv6 protocol command line

In reply to Rongwei Liu

Add new modify field destination type string: "ipv6_proto".

---
 app/test-pmd/cmdline_flow.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
app/test-pmd/cmdline_flow.c +2 -1
index 24fdb260e9..374c89d434 100644
@@ -811,7 +811,8 @@ static const char *const modify_field_ids[] = {
 	"udp_port_src", "udp_port_dst",
 	"vxlan_vni", "geneve_vni", "gtp_teid",
 	"tag", "mark", "meta", "pointer", "value",
-	"ipv4_ecn", "ipv6_ecn", "gtp_psc_qfi", "meter_color", NULL
+	"ipv4_ecn", "ipv6_ecn", "gtp_psc_qfi", "meter_color",
+	"ipv6_proto", NULL
 };
 
 static const char *const meter_colors[] = {
Signature · 1 line
2.27.0
#66 lore raw

RFC 9/9 net/mlx5/hws: add modify IPv6 protocol implementation

In reply to Rongwei Liu

Add HWS modify IPv6 protocol implementation.

---
 drivers/common/mlx5/mlx5_prm.h  |  1 +
 drivers/net/mlx5/mlx5_flow_dv.c | 10 ++++++++++
 2 files changed, 11 insertions(+)
drivers/common/mlx5/mlx5_prm.h +1 -0
index 1545b929b6..c57d49e079 100644
@@ -753,6 +753,7 @@ enum mlx5_modification_field {
 	MLX5_MODI_OUT_IP_ECN = 0x73,
 	MLX5_MODI_TUNNEL_HDR_DW_1 = 0x75,
 	MLX5_MODI_GTPU_FIRST_EXT_DW_0 = 0x76,
+	MLX5_MODI_OUT_IPV6_NEXT_HDR = 0x82,
 };
 
 /* Total number of metadata reg_c's. */
drivers/net/mlx5/mlx5_flow_dv.c +10 -0
index 7ca909999b..e972a2dc5a 100644
@@ -1357,6 +1357,7 @@ mlx5_flow_item_field_width(struct rte_eth_dev *dev,
 	case RTE_FLOW_FIELD_IPV6_DSCP:
 		return 6;
 	case RTE_FLOW_FIELD_IPV6_HOPLIMIT:
+	case RTE_FLOW_FIELD_IPV6_PROTO:
 		return 8;
 	case RTE_FLOW_FIELD_IPV6_SRC:
 	case RTE_FLOW_FIELD_IPV6_DST:
@@ -1883,6 +1884,15 @@ mlx5_flow_field_id_to_modify_info
 				info[idx].offset = data->offset;
 		}
 		break;
+	case RTE_FLOW_FIELD_IPV6_PROTO:
+		MLX5_ASSERT(data->offset + width <= 8);
+		off_be = 8 - (data->offset + width);
+		info[idx] = (struct field_modify_info){1, 0, MLX5_MODI_OUT_IPV6_NEXT_HDR};
+		if (mask)
+			mask[idx] = flow_modify_info_mask_8(width, off_be);
+		else
+			info[idx].offset = off_be;
+		break;
 	case RTE_FLOW_FIELD_POINTER:
 	case RTE_FLOW_FIELD_VALUE:
 	default:
Signature · 1 line
2.27.0