Skip to contentSkip to conversation

add GTP PSC extension header support

PATCH Superseded Shiri Kuzin 3 participants 18 messages Dec 28, 2020 – Jan 15, 2021 Network drivers

lore
Share & tools
lore
#0 lore raw

cover add GTP PSC extension header support

In this patch we add the support for GTP PSC in net/mlx5. This will enable matching on "rte_flow_item_gtp_psc" item.

The support in testpmd is extended to support raw
encap\decap of GTP PSC.

Shiri Kuzin (4):
common/mlx5: add matcher fields for GTP extensions net/mlx5: add GTP PSC flow validation net/mlx5: add GTP PSC item translation
doc: update GTP extension header support

Viacheslav Ovsiienko (2):
ethdev: update GTP headers
app/testpmd: add GTP PSC option support in raw sets

 app/test-pmd/cmdline_flow.c     |  66 +++++++++++++-
 doc/guides/nics/mlx5.rst        |   5 ++
 drivers/common/mlx5/mlx5_prm.h  |   7 +-
 drivers/net/mlx5/mlx5_flow.h    |   5 ++
 drivers/net/mlx5/mlx5_flow_dv.c | 155 ++++++++++++++++++++++++++++++++
 lib/librte_net/rte_gtp.h        |  33 ++++++-
 6 files changed, 264 insertions(+), 7 deletions(-)
Signature · 1 line
2.21.0
#1 lore raw

PATCH 1/6 ethdev: update GTP headers

From: Viacheslav Ovsiienko <[email protected]>

This patch introduces the GTP header individual flag bit fields and the header optional word with N-PDU number, Sequence Number and Next Extension Header type.

---
 lib/librte_net/rte_gtp.h | 33 ++++++++++++++++++++++++++++++---
 1 file changed, 30 insertions(+), 3 deletions(-)
lib/librte_net/rte_gtp.h +30 -3
index 104384cc53..6a6f9b238d 100644
@@ -27,13 +27,40 @@ extern "C" {
  * 16-bit payload length after mandatory header, 32-bit TEID.
  * No optional fields and next extension header.
  */
+__extension__
 struct rte_gtp_hdr {
-	uint8_t gtp_hdr_info; /**< GTP header info */
+	union {
+		uint8_t gtp_hdr_info; /**< GTP header info */
+		struct {
+#if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
+			uint8_t pn:1;   /**< N-PDU Number present bit */
+			uint8_t s:1;    /**< Sequence Number Present bit */
+			uint8_t e:1;    /**< Extension Present bit */
+			uint8_t res1:1; /**< Reserved */
+			uint8_t pt:1;   /**< Protocol Type bit */
+			uint8_t ver:3;  /**< Version Number */
+#elif RTE_BYTE_ORDER == RTE_BIG_ENDIAN
+			uint8_t ver:3;  /**< Version Number */
+			uint8_t pt:1;   /**< Protocol Type bit */
+			uint8_t res1:1; /**< Reserved */
+			uint8_t e:1;    /**< Extension Present bit */
+			uint8_t s:1;    /**< Sequence Number Present bit */
+			uint8_t pn:1;   /**< N-PDU Number present bit */
+#endif
+		};
+	};
 	uint8_t msg_type;     /**< GTP message type */
-	uint16_t plen;        /**< Total payload length */
-	uint32_t teid;        /**< Tunnel endpoint ID */
+	rte_be16_t plen;      /**< Total payload length */
+	rte_be32_t teid;      /**< Tunnel endpoint ID */
 } __rte_packed;
 
+/* Optional word of GTP header, present if any of E, S, PN is set. */
+struct rte_gtp_hdr_ext_word {
+	rte_be16_t sqn;	      /**< Sequence Number. */
+	uint8_t npdu;	      /**< N-PDU number. */
+	uint8_t next_ext;     /**< Next Extension Header Type. */
+}  __rte_packed;
+
 /** GTP header length */
 #define RTE_ETHER_GTP_HLEN \
 	(sizeof(struct rte_udp_hdr) + sizeof(struct rte_gtp_hdr))
Signature · 1 line
2.21.0
Acked-by on v1 1/6
#2 lore raw

Re: [dpdk-dev] [PATCH 1/6] ethdev: update GTP headers

Quoted 65 lines

-----Original Message-----
From: Shiri Kuzin <[email protected]>

From: Viacheslav Ovsiienko <[email protected]>

This patch introduces the GTP header individual flag bit fields and the header optional word with N-PDU number, Sequence Number and Next Extension Header type.

---
 lib/librte_net/rte_gtp.h | 33 ++++++++++++++++++++++++++++++---
 1 file changed, 30 insertions(+), 3 deletions(-)
lib/librte_net/rte_gtp.h +30 -4
index 104384cc53..6a6f9b238d 100644
@@ -27,13 +27,40 @@ extern "C" {
  * 16-bit payload length after mandatory header, 32-bit TEID.
  * No optional fields and next extension header.
  */
+__extension__
 struct rte_gtp_hdr {
-	uint8_t gtp_hdr_info; /**< GTP header info */
+	union {
+		uint8_t gtp_hdr_info; /**< GTP header info */
+		struct {
+#if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
+			uint8_t pn:1;   /**< N-PDU Number present bit */
+			uint8_t s:1;    /**< Sequence Number Present bit */
+			uint8_t e:1;    /**< Extension Present bit */
+			uint8_t res1:1; /**< Reserved */
+			uint8_t pt:1;   /**< Protocol Type bit */
+			uint8_t ver:3;  /**< Version Number */
+#elif RTE_BYTE_ORDER == RTE_BIG_ENDIAN
+			uint8_t ver:3;  /**< Version Number */
+			uint8_t pt:1;   /**< Protocol Type bit */
+			uint8_t res1:1; /**< Reserved */
+			uint8_t e:1;    /**< Extension Present bit */
+			uint8_t s:1;    /**< Sequence Number Present bit */
+			uint8_t pn:1;   /**< N-PDU Number present bit */
+#endif
+		};
+	};
 	uint8_t msg_type;     /**< GTP message type */
-	uint16_t plen;        /**< Total payload length */
-	uint32_t teid;        /**< Tunnel endpoint ID */
+	rte_be16_t plen;      /**< Total payload length */
+	rte_be32_t teid;      /**< Tunnel endpoint ID */
 } __rte_packed;
 
+/* Optional word of GTP header, present if any of E, S, PN is set. */
+struct rte_gtp_hdr_ext_word {
+	rte_be16_t sqn;	      /**< Sequence Number. */
+	uint8_t npdu;	      /**< N-PDU number. */
+	uint8_t next_ext;     /**< Next Extension Header Type. */
+}  __rte_packed;
+
 /** GTP header length */
 #define RTE_ETHER_GTP_HLEN \
 	(sizeof(struct rte_udp_hdr) + sizeof(struct rte_gtp_hdr))
--
Quoted 1 line

2.21.0

Thanks,
Ori

#3 lore raw

PATCH 2/6 app/testpmd: add GTP PSC option support in raw sets

In reply to Shiri Kuzin

From: Viacheslav Ovsiienko <[email protected]>

This patch add support for generating GTP PDU container session option for the raw encap and raw decap sets. The generated options is single 32-bit word with minimal length specified as 4, no extra fields in the option are supported. The option item must be preceded with the GTP item itself, and GTP item flags must be set accordingly:

- E flag must be set, we are going to provide extension
- S flag must be reset, because GTP item does not provide the value for SQN field, we can't fill this one
- PN flag must be reset, no N-PDU value provided by GTP item either

The raw set example:

set raw_encap 2 eth / ipv4 / udp /

                  gtp v_pt_rsv_flags is 0x34 / gtp_psc / end_set

Please, note - value 0x34 provides the required flag combination.

---
 app/test-pmd/cmdline_flow.c | 66 +++++++++++++++++++++++++++++++++++--
 1 file changed, 63 insertions(+), 3 deletions(-)
app/test-pmd/cmdline_flow.c +63 -3
index 585cab98b4..37b10e61bf 100644
@@ -7581,6 +7581,7 @@ cmd_set_raw_parsed(const struct buffer *in)
 	uint16_t upper_layer = 0;
 	uint16_t proto = 0;
 	uint16_t idx = in->port; /* We borrow port field as index */
+	int gtp_psc = -1; /* GTP PSC option index. */
 
 	if (in->command == SET_SAMPLE_ACTIONS)
 		return cmd_set_raw_parsed_sample(in);
@@ -7598,6 +7599,8 @@ cmd_set_raw_parsed(const struct buffer *in)
 	/* process hdr from upper layer to low layer (L3/L4 -> L2). */
 	data_tail = data + ACTION_RAW_ENCAP_MAX_DATA;
 	for (i = n - 1 ; i >= 0; --i) {
+		const struct rte_flow_item_gtp *gtp;
+
 		item = in->args.vc.pattern + i;
 		if (item->spec == NULL)
 			item->spec = flow_item_default_mask(item);
@@ -7663,16 +7666,68 @@ cmd_set_raw_parsed(const struct buffer *in)
 			proto = 0x33;
 			break;
 		case RTE_FLOW_ITEM_TYPE_GTP:
+			if (gtp_psc < 0) {
+				size = sizeof(struct rte_gtp_hdr);
+				break;
+			}
+			if (gtp_psc != i + 1) {
+				printf("Error - GTP PSC does not follow GTP\n");
+				goto error;
+			}
+			gtp = item->spec;
+			if ((gtp->v_pt_rsv_flags & 0x07) != 0x04) {
+				/* Only E flag should be set. */
+				printf("Error - GTP unsupported flags\n");
+				goto error;
+			} else {
+				struct rte_gtp_hdr_ext_word ext_word = {
+					.next_ext = 0x85
+				};
+
+				/* We have to add GTP header extra word. */
+				*total_size += sizeof(ext_word);
+				rte_memcpy(data_tail - (*total_size),
+					   &ext_word, sizeof(ext_word));
+			}
 			size = sizeof(struct rte_gtp_hdr);
 			break;
+		case RTE_FLOW_ITEM_TYPE_GTP_PSC:
+			if (gtp_psc >= 0) {
+				printf("Error - Multiple GTP PSC items\n");
+				goto error;
+			} else {
+				const struct rte_flow_item_gtp_psc
+					*opt = item->spec;
+				struct {
+					uint8_t len;
+					uint8_t pdu_type;
+					uint8_t qfi;
+					uint8_t next;
+				} psc;
+
+				if (opt->pdu_type & 0x0F) {
+					/* Support the minimal option only. */
+					printf("Error - GTP PSC option with "
+					       "extra fields not supported\n");
+					goto error;
+				}
+				psc.len = sizeof(psc);
+				psc.pdu_type = opt->pdu_type;
+				psc.qfi = opt->qfi;
+				psc.next = 0;
+				*total_size += sizeof(psc);
+				rte_memcpy(data_tail - (*total_size),
+					   &psc, sizeof(psc));
+				gtp_psc = i;
+				size = 0;
+			}
+			break;
 		case RTE_FLOW_ITEM_TYPE_PFCP:
 			size = sizeof(struct rte_flow_item_pfcp);
 			break;
 		default:
 			printf("Error - Not supported item\n");
-			*total_size = 0;
-			memset(data, 0x00, ACTION_RAW_ENCAP_MAX_DATA);
-			return;
+			goto error;
 		}
 		*total_size += size;
 		rte_memcpy(data_tail - (*total_size), item->spec, size);
@@ -7685,6 +7740,11 @@ cmd_set_raw_parsed(const struct buffer *in)
 		printf("total data size is %zu\n", (*total_size));
 	RTE_ASSERT((*total_size) <= ACTION_RAW_ENCAP_MAX_DATA);
 	memmove(data, (data_tail - (*total_size)), *total_size);
+	return;
+
+error:
+	*total_size = 0;
+	memset(data, 0x00, ACTION_RAW_ENCAP_MAX_DATA);
 }
 
 /** Populate help strings for current token (cmdline API). */
Signature · 1 line
2.21.0
Acked-by on v1 2/6
#4 lore raw

Re: [dpdk-dev] [PATCH 2/6] app/testpmd: add GTP PSC option support in raw sets

Hi

Quoted 21 lines

-----Original Message-----
From: Shiri Kuzin <[email protected]>
Sent: Monday, December 28, 2020 9:44 PM
From: Viacheslav Ovsiienko <[email protected]>

This patch add support for generating GTP PDU container session option for the raw encap and raw decap sets. The generated options is single 32-bit word with minimal length specified as 4, no extra fields in the option are supported. The option item must be preceded with the GTP item itself, and GTP item flags must be set accordingly:

- E flag must be set, we are going to provide extension
- S flag must be reset, because GTP item does not provide the value for SQN field, we can't fill this one
- PN flag must be reset, no N-PDU value provided by GTP item either

The raw set example:

Quoted 7 lines

set raw_encap 2 eth / ipv4 / udp /

                  gtp v_pt_rsv_flags is 0x34 / gtp_psc / end_set

Please, note - value 0x34 provides the required flag combination.

---

Thanks,
Ori

#5 lore raw

PATCH 3/6 common/mlx5: add matcher fields for GTP extensions

In reply to Shiri Kuzin

This is a preparation step to support GTP extension header.

In this patch we add the matcher fields that will be used to match on the GTP extension header.

---
 drivers/common/mlx5/mlx5_prm.h | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/common/mlx5/mlx5_prm.h +6 -1
index 58d180486e..2878223ed9 100644
@@ -791,7 +791,12 @@ struct mlx5_ifc_fte_match_set_misc3_bits {
 	u8 gtpu_teid[0x20];
 	u8 gtpu_msg_type[0x08];
 	u8 gtpu_msg_flags[0x08];
-	u8 reserved_at_170[0x90];
+	u8 reserved_at_170[0x10];
+	u8 gtpu_dw_2[0x20];
+	u8 gtpu_first_ext_dw_0[0x20];
+	u8 gtpu_dw_0[0x20];
+	u8 reserved_at_240[0x20];
+
 };
 
 struct mlx5_ifc_fte_match_set_misc4_bits {
Signature · 1 line
2.21.0
#6 lore raw

PATCH 4/6 net/mlx5: add GTP PSC flow validation

In reply to Shiri Kuzin

In this patch we add validation routine for
GTP PSC extension header.

The GTP PSC extension header must follow the
GTP item.

---
 drivers/net/mlx5/mlx5_flow.h    |  5 +++
 drivers/net/mlx5/mlx5_flow_dv.c | 70 +++++++++++++++++++++++++++++++++
 2 files changed, 75 insertions(+)
drivers/net/mlx5/mlx5_flow.h +5 -0
index d85dd19929..fd6b24c32d 100644
@@ -138,6 +138,9 @@ enum mlx5_feature_name {
 #define MLX5_FLOW_LAYER_OUTER_L3_IPV6_FRAG_EXT (1u << 30)
 #define MLX5_FLOW_LAYER_INNER_L3_IPV6_FRAG_EXT (1u << 31)
 
+/* Pattern tunnel Layer bits (continued). */
+#define MLX5_FLOW_LAYER_GTP_PSC (UINT64_C(1) << 33)
+
 /* Outer Masks. */
 #define MLX5_FLOW_LAYER_OUTER_L3 \
 	(MLX5_FLOW_LAYER_OUTER_L3_IPV4 | MLX5_FLOW_LAYER_OUTER_L3_IPV6)
@@ -348,6 +351,8 @@ enum mlx5_feature_name {
 
 #define MLX5_ENCAPSULATION_DECISION_SIZE (sizeof(struct rte_ether_hdr) + \
 					  sizeof(struct rte_ipv4_hdr))
+/* GTP extension header flag. */
+#define MLX5_GTP_EXT_HEADER_FLAG 4
 
 /* IPv4 fragment_offset field contains relevant data in bits 2 to 15. */
 #define MLX5_IPV4_FRAG_OFFSET_MASK \
drivers/net/mlx5/mlx5_flow_dv.c +70 -0

90 lines not on this page · raw message

Signature · 1 line
2.21.0
#7 lore raw

PATCH 5/6 net/mlx5: add GTP PSC item translation

In reply to Shiri Kuzin

This patch adds the translation function which
sets the qfi, PDU type.

The next extension header which indicates the following extension header type is set to 0x85 - a PDU session container.

---
 drivers/net/mlx5/mlx5_flow_dv.c | 85 +++++++++++++++++++++++++++++++++
 1 file changed, 85 insertions(+)
drivers/net/mlx5/mlx5_flow_dv.c +85 -0
index 3f6d44a265..7a85ad0887 100644
@@ -7903,6 +7903,81 @@ flow_dv_translate_item_gtp(void *matcher, void *key,
 		 rte_be_to_cpu_32(gtp_v->teid & gtp_m->teid));
 }
 
+/**
+ * Add GTP PSC item to matcher.
+ *
+ * @param[in, out] matcher
+ *   Flow matcher.
+ * @param[in, out] key
+ *   Flow matcher value.
+ * @param[in] item
+ *   Flow pattern to translate.
+ */
+static int
+flow_dv_translate_item_gtp_psc(void *matcher, void *key,
+			       const struct rte_flow_item *item)
+{
+	const struct rte_flow_item_gtp_psc *gtp_psc_m = item->mask;
+	const struct rte_flow_item_gtp_psc *gtp_psc_v = item->spec;
+	void *misc3_m = MLX5_ADDR_OF(fte_match_param, matcher,
+			misc_parameters_3);
+	void *misc3_v = MLX5_ADDR_OF(fte_match_param, key, misc_parameters_3);
+	union {
+		uint32_t w32;
+		struct {
+			uint16_t seq_num;
+			uint8_t npdu_num;
+			uint8_t next_ext_header_type;
+		};
+	} dw_2;
+	uint8_t gtp_flags;
+
+	/* Always set E-flag match on one, regardless of GTP item settings. */
+	gtp_flags = MLX5_GET(fte_match_set_misc3, misc3_m, gtpu_msg_flags);
+	gtp_flags |= MLX5_GTP_EXT_HEADER_FLAG;
+	MLX5_SET(fte_match_set_misc3, misc3_m, gtpu_msg_flags, gtp_flags);
+	gtp_flags = MLX5_GET(fte_match_set_misc3, misc3_v, gtpu_msg_flags);
+	gtp_flags |= MLX5_GTP_EXT_HEADER_FLAG;
+	MLX5_SET(fte_match_set_misc3, misc3_v, gtpu_msg_flags, gtp_flags);
+	/*Set next extension header type. */
+	dw_2.seq_num = 0;
+	dw_2.npdu_num = 0;
+	dw_2.next_ext_header_type = 0xff;
+	MLX5_SET(fte_match_set_misc3, misc3_m, gtpu_dw_2,
+		 rte_cpu_to_be_32(dw_2.w32));
+	dw_2.seq_num = 0;
+	dw_2.npdu_num = 0;
+	dw_2.next_ext_header_type = 0x85;
+	MLX5_SET(fte_match_set_misc3, misc3_v, gtpu_dw_2,
+		 rte_cpu_to_be_32(dw_2.w32));
+	if (gtp_psc_v) {
+		union {
+			uint32_t w32;
+			struct {
+				uint8_t len;
+				uint8_t pdu_type;
+				uint8_t qfi;
+				uint8_t reserved;
+			};
+		} dw_0;
+
+		/*Set extension header PDU type and Qos. */
+		if (!gtp_psc_m)
+			gtp_psc_m = &rte_flow_item_gtp_psc_mask;
+		dw_0.w32 = 0;
+		dw_0.pdu_type = gtp_psc_m->pdu_type;
+		dw_0.qfi = gtp_psc_m->qfi;
+		MLX5_SET(fte_match_set_misc3, misc3_m, gtpu_first_ext_dw_0,
+			 rte_cpu_to_be_32(dw_0.w32));
+		dw_0.w32 = 0;
+		dw_0.pdu_type = gtp_psc_v->pdu_type &  gtp_psc_m->pdu_type;
+		dw_0.qfi = gtp_psc_v->qfi & gtp_psc_m->qfi;
+		MLX5_SET(fte_match_set_misc3, misc3_v, gtpu_first_ext_dw_0,
+			 rte_cpu_to_be_32(dw_0.w32));
+	}
+	return 0;
+}
+
 /**
  * Add eCPRI item to matcher and to the value.
  *
@@ -10585,6 +10660,16 @@ flow_dv_translate(struct rte_eth_dev *dev,
 			matcher.priority = MLX5_TUNNEL_PRIO_GET(rss_desc);
 			last_item = MLX5_FLOW_LAYER_GTP;
 			break;
+		case RTE_FLOW_ITEM_TYPE_GTP_PSC:
+			ret = flow_dv_translate_item_gtp_psc(match_mask,
+							  match_value,
+							  items);
+			if (ret)
+				return rte_flow_error_set(error, -ret,
+					RTE_FLOW_ERROR_TYPE_ITEM, NULL,
+					"cannot create GTP PSC item");
+			last_item = MLX5_FLOW_LAYER_GTP_PSC;
+			break;
 		case RTE_FLOW_ITEM_TYPE_ECPRI:
 			if (!mlx5_flex_parser_ecpri_exist(dev)) {
 				/* Create it only the first time to be used. */
Signature · 1 line
2.21.0
#8 lore raw

PATCH 6/6 doc: update GTP extension header support

In reply to Shiri Kuzin

added GTP extension header support to mlx5 PMD.

The limitations and support were updated in
documentation.

---
 doc/guides/nics/mlx5.rst | 5 +++++
 1 file changed, 5 insertions(+)
doc/guides/nics/mlx5.rst +5 -0
index 3bda0f8417..3b1a08f40a 100644
@@ -98,6 +98,7 @@ Features
 - Hardware LRO.
 - Hairpin.
 - Multiple-thread flow insertion.
+- Matching on GTP extension header with raw encap/decap action.
 
 Limitations
 -----------
@@ -186,6 +187,10 @@ Limitations
      - msg_type
      - teid
 
+- Match on GTP extension header only for GTP PDU session container (next
+  extension header type = 0x85).
+- Match on GTP extension header is not supported in group 0.
+
 - No Tx metadata go to the E-Switch steering domain for the Flow group 0.
   The flows within group 0 and set metadata action are rejected by hardware.
 
Signature · 1 line
2.21.0
#9 lore raw

v2 cover add GTP PSC extension header support

In reply to Shiri Kuzin

In this patch we add the support for GTP PSC in net/mlx5. This will enable matching on "rte_flow_item_gtp_psc" item.

The support in testpmd is extended to support raw
encap\decap of GTP PSC.

v2:
- update documentation.
- fix PDU type shift.

Shiri Kuzin (4):
common/mlx5: add matcher fields for GTP extensions net/mlx5: add GTP PSC flow validation net/mlx5: add GTP PSC item translation
doc: update GTP extension header support

Viacheslav Ovsiienko (2):
ethdev: update GTP headers
app/testpmd: add GTP PSC option support in raw sets

 app/test-pmd/cmdline_flow.c            |  66 +++++++++-
 doc/guides/nics/mlx5.rst               |  10 ++
 doc/guides/rel_notes/release_21_02.rst |   5 +
 drivers/common/mlx5/mlx5_prm.h         |   7 +-
 drivers/net/mlx5/mlx5_flow.h           |  11 ++
 drivers/net/mlx5/mlx5_flow_dv.c        | 162 +++++++++++++++++++++++++
 lib/librte_net/rte_gtp.h               |  33 ++++-
 7 files changed, 287 insertions(+), 7 deletions(-)
Signature · 1 line
2.21.0
#10 lore raw

PATCH v2 1/6 ethdev: update GTP headers

From: Viacheslav Ovsiienko <[email protected]>

This patch introduces the GTP header individual flag bit fields and the header optional word with N-PDU number, Sequence Number and Next Extension Header type.

---
 lib/librte_net/rte_gtp.h | 33 ++++++++++++++++++++++++++++++---
 1 file changed, 30 insertions(+), 3 deletions(-)
lib/librte_net/rte_gtp.h +30 -3
index 104384cc53..6a6f9b238d 100644
@@ -27,13 +27,40 @@ extern "C" {
  * 16-bit payload length after mandatory header, 32-bit TEID.
  * No optional fields and next extension header.
  */
+__extension__
 struct rte_gtp_hdr {
-	uint8_t gtp_hdr_info; /**< GTP header info */
+	union {
+		uint8_t gtp_hdr_info; /**< GTP header info */
+		struct {
+#if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
+			uint8_t pn:1;   /**< N-PDU Number present bit */
+			uint8_t s:1;    /**< Sequence Number Present bit */
+			uint8_t e:1;    /**< Extension Present bit */
+			uint8_t res1:1; /**< Reserved */
+			uint8_t pt:1;   /**< Protocol Type bit */
+			uint8_t ver:3;  /**< Version Number */
+#elif RTE_BYTE_ORDER == RTE_BIG_ENDIAN
+			uint8_t ver:3;  /**< Version Number */
+			uint8_t pt:1;   /**< Protocol Type bit */
+			uint8_t res1:1; /**< Reserved */
+			uint8_t e:1;    /**< Extension Present bit */
+			uint8_t s:1;    /**< Sequence Number Present bit */
+			uint8_t pn:1;   /**< N-PDU Number present bit */
+#endif
+		};
+	};
 	uint8_t msg_type;     /**< GTP message type */
-	uint16_t plen;        /**< Total payload length */
-	uint32_t teid;        /**< Tunnel endpoint ID */
+	rte_be16_t plen;      /**< Total payload length */
+	rte_be32_t teid;      /**< Tunnel endpoint ID */
 } __rte_packed;
 
+/* Optional word of GTP header, present if any of E, S, PN is set. */
+struct rte_gtp_hdr_ext_word {
+	rte_be16_t sqn;	      /**< Sequence Number. */
+	uint8_t npdu;	      /**< N-PDU number. */
+	uint8_t next_ext;     /**< Next Extension Header Type. */
+}  __rte_packed;
+
 /** GTP header length */
 #define RTE_ETHER_GTP_HLEN \
 	(sizeof(struct rte_udp_hdr) + sizeof(struct rte_gtp_hdr))
Signature · 1 line
2.21.0
Reviewed-by on v2 1/6
#11 lore raw

Re: [dpdk-dev] [PATCH v2 1/6] ethdev: update GTP headers

Quoted 8 lines · Shiri Kuzin

From: Viacheslav Ovsiienko <[email protected]>

This patch introduces the GTP header individual flag bit fields and the header optional word with N-PDU number, Sequence Number and Next Extension Header type.

#12 lore raw

PATCH v2 2/6 app/testpmd: add GTP PSC option support in raw sets

In reply to Shiri Kuzin

From: Viacheslav Ovsiienko <[email protected]>

This patch add support for generating GTP PDU container session option for the raw encap and raw decap sets. The generated options is single 32-bit word with minimal length specified as 4, no extra fields in the option are supported. The option item must be preceded with the GTP item itself, and GTP item flags must be set accordingly:

- E flag must be set, we are going to provide extension
- S flag must be reset, because GTP item does not provide the value for SQN field, we can't fill this one
- PN flag must be reset, no N-PDU value provided by GTP item either

The raw set example:

set raw_encap 2 eth / ipv4 / udp /

                  gtp v_pt_rsv_flags is 0x34 / gtp_psc / end_set

Please, note - value 0x34 provides the required flag combination.

---
 app/test-pmd/cmdline_flow.c | 66 +++++++++++++++++++++++++++++++++++--
 1 file changed, 63 insertions(+), 3 deletions(-)
app/test-pmd/cmdline_flow.c +63 -3
index 585cab98b4..37b10e61bf 100644
@@ -7581,6 +7581,7 @@ cmd_set_raw_parsed(const struct buffer *in)
 	uint16_t upper_layer = 0;
 	uint16_t proto = 0;
 	uint16_t idx = in->port; /* We borrow port field as index */
+	int gtp_psc = -1; /* GTP PSC option index. */
 
 	if (in->command == SET_SAMPLE_ACTIONS)
 		return cmd_set_raw_parsed_sample(in);
@@ -7598,6 +7599,8 @@ cmd_set_raw_parsed(const struct buffer *in)
 	/* process hdr from upper layer to low layer (L3/L4 -> L2). */
 	data_tail = data + ACTION_RAW_ENCAP_MAX_DATA;
 	for (i = n - 1 ; i >= 0; --i) {
+		const struct rte_flow_item_gtp *gtp;
+
 		item = in->args.vc.pattern + i;
 		if (item->spec == NULL)
 			item->spec = flow_item_default_mask(item);
@@ -7663,16 +7666,68 @@ cmd_set_raw_parsed(const struct buffer *in)
 			proto = 0x33;
 			break;
 		case RTE_FLOW_ITEM_TYPE_GTP:
+			if (gtp_psc < 0) {
+				size = sizeof(struct rte_gtp_hdr);
+				break;
+			}
+			if (gtp_psc != i + 1) {
+				printf("Error - GTP PSC does not follow GTP\n");
+				goto error;
+			}
+			gtp = item->spec;
+			if ((gtp->v_pt_rsv_flags & 0x07) != 0x04) {
+				/* Only E flag should be set. */
+				printf("Error - GTP unsupported flags\n");
+				goto error;
+			} else {
+				struct rte_gtp_hdr_ext_word ext_word = {
+					.next_ext = 0x85
+				};
+
+				/* We have to add GTP header extra word. */
+				*total_size += sizeof(ext_word);
+				rte_memcpy(data_tail - (*total_size),
+					   &ext_word, sizeof(ext_word));
+			}
 			size = sizeof(struct rte_gtp_hdr);
 			break;
+		case RTE_FLOW_ITEM_TYPE_GTP_PSC:
+			if (gtp_psc >= 0) {
+				printf("Error - Multiple GTP PSC items\n");
+				goto error;
+			} else {
+				const struct rte_flow_item_gtp_psc
+					*opt = item->spec;
+				struct {
+					uint8_t len;
+					uint8_t pdu_type;
+					uint8_t qfi;
+					uint8_t next;
+				} psc;
+
+				if (opt->pdu_type & 0x0F) {
+					/* Support the minimal option only. */
+					printf("Error - GTP PSC option with "
+					       "extra fields not supported\n");
+					goto error;
+				}
+				psc.len = sizeof(psc);
+				psc.pdu_type = opt->pdu_type;
+				psc.qfi = opt->qfi;
+				psc.next = 0;
+				*total_size += sizeof(psc);
+				rte_memcpy(data_tail - (*total_size),
+					   &psc, sizeof(psc));
+				gtp_psc = i;
+				size = 0;
+			}
+			break;
 		case RTE_FLOW_ITEM_TYPE_PFCP:
 			size = sizeof(struct rte_flow_item_pfcp);
 			break;
 		default:
 			printf("Error - Not supported item\n");
-			*total_size = 0;
-			memset(data, 0x00, ACTION_RAW_ENCAP_MAX_DATA);
-			return;
+			goto error;
 		}
 		*total_size += size;
 		rte_memcpy(data_tail - (*total_size), item->spec, size);
@@ -7685,6 +7740,11 @@ cmd_set_raw_parsed(const struct buffer *in)
 		printf("total data size is %zu\n", (*total_size));
 	RTE_ASSERT((*total_size) <= ACTION_RAW_ENCAP_MAX_DATA);
 	memmove(data, (data_tail - (*total_size)), *total_size);
+	return;
+
+error:
+	*total_size = 0;
+	memset(data, 0x00, ACTION_RAW_ENCAP_MAX_DATA);
 }
 
 /** Populate help strings for current token (cmdline API). */
Signature · 1 line
2.21.0
#13 lore raw

PATCH v2 3/6 common/mlx5: add matcher fields for GTP extensions

In reply to Shiri Kuzin

This is a preparation step to support GTP extension header.

In this patch we add the matcher fields that will be used to match on the GTP extension header.

---
 drivers/common/mlx5/mlx5_prm.h | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/common/mlx5/mlx5_prm.h +6 -1
index 8c9b53ce10..8a82c4f5ec 100644
@@ -793,7 +793,12 @@ struct mlx5_ifc_fte_match_set_misc3_bits {
 	u8 gtpu_teid[0x20];
 	u8 gtpu_msg_type[0x08];
 	u8 gtpu_msg_flags[0x08];
-	u8 reserved_at_170[0x90];
+	u8 reserved_at_170[0x10];
+	u8 gtpu_dw_2[0x20];
+	u8 gtpu_first_ext_dw_0[0x20];
+	u8 gtpu_dw_0[0x20];
+	u8 reserved_at_240[0x20];
+
 };
 
 struct mlx5_ifc_fte_match_set_misc4_bits {
Signature · 1 line
2.21.0
#14 lore raw

PATCH v2 4/6 net/mlx5: add GTP PSC flow validation

In reply to Shiri Kuzin

In this patch we add validation routine for
GTP PSC extension header.

The GTP PSC extension header must follow the
GTP item.

---
 drivers/net/mlx5/mlx5_flow.h    |  8 ++++
 drivers/net/mlx5/mlx5_flow_dv.c | 76 +++++++++++++++++++++++++++++++++
 2 files changed, 84 insertions(+)
drivers/net/mlx5/mlx5_flow.h +8 -0
index ee85c9d8a5..e54412e07b 100644
@@ -138,6 +138,9 @@ enum mlx5_feature_name {
 #define MLX5_FLOW_LAYER_OUTER_L3_IPV6_FRAG_EXT (1u << 30)
 #define MLX5_FLOW_LAYER_INNER_L3_IPV6_FRAG_EXT (1u << 31)
 
+/* Pattern tunnel Layer bits (continued). */
+#define MLX5_FLOW_LAYER_GTP_PSC (UINT64_C(1) << 33)
+
 /* Outer Masks. */
 #define MLX5_FLOW_LAYER_OUTER_L3 \
 	(MLX5_FLOW_LAYER_OUTER_L3_IPV4 | MLX5_FLOW_LAYER_OUTER_L3_IPV6)
@@ -348,6 +351,11 @@ enum mlx5_feature_name {
 
 #define MLX5_ENCAPSULATION_DECISION_SIZE (sizeof(struct rte_ether_hdr) + \
 					  sizeof(struct rte_ipv4_hdr))
+/* GTP extension header flag. */
+#define MLX5_GTP_EXT_HEADER_FLAG 4
+
+/* GTP extension header max PDU type value. */
+#define MLX5_GTP_EXT_MAX_PDU_TYPE 15
 
 /* IPv4 fragment_offset field contains relevant data in bits 2 to 15. */
 #define MLX5_IPV4_FRAG_OFFSET_MASK \
drivers/net/mlx5/mlx5_flow_dv.c +76 -0

96 lines not on this page · raw message

Signature · 1 line
2.21.0
#15 lore raw

PATCH v2 5/6 net/mlx5: add GTP PSC item translation

In reply to Shiri Kuzin

This patch adds the translation function which sets the qfi, PDU type.

The next extension header which indicates the following extension header type is set to 0x85 - a PDU session container.

---
 drivers/net/mlx5/mlx5_flow.h    |  3 ++
 drivers/net/mlx5/mlx5_flow_dv.c | 86 +++++++++++++++++++++++++++++++++
 2 files changed, 89 insertions(+)
drivers/net/mlx5/mlx5_flow.h +3 -0
index e54412e07b..c25b100945 100644
@@ -357,6 +357,9 @@ enum mlx5_feature_name {
 /* GTP extension header max PDU type value. */
 #define MLX5_GTP_EXT_MAX_PDU_TYPE 15
 
+/* GTP extension header PDU type shift. */
+#define MLX5_GTP_PDU_TYPE_SHIFT(a) ((a) << 4)
+
 /* IPv4 fragment_offset field contains relevant data in bits 2 to 15. */
 #define MLX5_IPV4_FRAG_OFFSET_MASK \
 		(RTE_IPV4_HDR_OFFSET_MASK | RTE_IPV4_HDR_MF_FLAG)
drivers/net/mlx5/mlx5_flow_dv.c +86 -0

98 lines not on this page · raw message

Signature · 1 line
2.21.0
#16 lore raw

PATCH v2 6/6 doc: update GTP extension header support

In reply to Shiri Kuzin

added GTP extension header support to mlx5 PMD.

The limitations and support were updated in
documentation.

---
 doc/guides/nics/mlx5.rst               | 10 ++++++++++
 doc/guides/rel_notes/release_21_02.rst |  5 +++++
 2 files changed, 15 insertions(+)
doc/guides/nics/mlx5.rst +10 -0
index 3bda0f8417..b025eb7bc9 100644
@@ -98,6 +98,7 @@ Features
 - Hardware LRO.
 - Hairpin.
 - Multiple-thread flow insertion.
+- Matching on GTP extension header with raw encap/decap action.
 
 Limitations
 -----------
@@ -186,6 +187,10 @@ Limitations
      - msg_type
      - teid
 
+- Match on GTP extension header only for GTP PDU session container (next
+  extension header type = 0x85).
+- Match on GTP extension header is not supported in group 0.
+
 - No Tx metadata go to the E-Switch steering domain for the Flow group 0.
   The flows within group 0 and set metadata action are rejected by hardware.
 
@@ -1501,6 +1506,11 @@ Supported hardware offloads
    |                       | |  rdma-core 32 | | rdma-core 32  |
    |                       | |  ConnectX-6 Dx| | ConnectX-6 Dx |
    +-----------------------+-----------------+-----------------+
+   | Encapsulation         | |  DPDK 21.02   | | DPDK 21.02    |
+   | GTP PSC               | |  OFED 5.2     | | OFED 5.2      |
+   |                       | |  rdma-core 35 | | rdma-core 35  |
+   |                       | |  ConnectX-6 Dx| | ConnectX-6 Dx |
+   +-----------------------+-----------------+-----------------+
 
 Notes for metadata
 ------------------
doc/guides/rel_notes/release_21_02.rst +5 -0
index 638f98168b..61961aab2b 100644
@@ -55,6 +55,11 @@ New Features
      Also, make sure to start the actual text at the margin.
      =======================================================
 
+* **Updated Mellanox mlx5 driver.**
+
+  Updated the Mellanox mlx5 driver with new features and improvements, including:
+
+  * Added GTP PDU session container matching and raw encap/decap.
 
 Removed Items
 -------------
Signature · 1 line
2.21.0
#17 lore raw
In reply to Shiri Kuzin
Quoted 16 lines · Shiri Kuzin

In this patch we add the support for GTP PSC in net/mlx5. This will enable matching on "rte_flow_item_gtp_psc" item.

The support in testpmd is extended to support raw
encap\decap of GTP PSC.

v2:
- update documentation.
- fix PDU type shift.

Shiri Kuzin (4):
common/mlx5: add matcher fields for GTP extensions net/mlx5: add GTP PSC flow validation net/mlx5: add GTP PSC item translation
doc: update GTP extension header support

Quoted 4 lines

Viacheslav Ovsiienko (2):
ethdev: update GTP headers
app/testpmd: add GTP PSC option support in raw sets

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