DPDK patches and discussions
 help / color / mirror / Atom feed
From: Michael Baum <michaelba@nvidia.com>
To: <dev@dpdk.org>
Cc: Dariusz Sosnowski <dsosnowski@nvidia.com>,
	Thomas Monjalon <thomas@monjalon.net>,
	Ferruh Yigit <ferruh.yigit@amd.com>, Ori Kam <orika@nvidia.com>
Subject: [RFC 2/2] ethdev: add data size field to GENEVE option item
Date: Wed, 17 Apr 2024 10:23:04 +0300	[thread overview]
Message-ID: <20240417072304.3260172-3-michaelba@nvidia.com> (raw)
In-Reply-To: <20240417072304.3260172-1-michaelba@nvidia.com>

The "rte_flow_item_geneve_opt" structure has field for option length.
This field has 2 different usages which might limit each other:

 1. field to matching with value/mask.
 2. descriptor for data array size.

This patch adds a new field "data_array_size" into
"rte_flow_item_geneve_opt" structure in addition to existing
"option_len" field.

Signed-off-by: Michael Baum <michaelba@nvidia.com>
---
 app/test-pmd/cmdline_flow.c                 | 10 ++++++
 doc/guides/prog_guide/rte_flow.rst          | 16 +++++++++
 doc/guides/testpmd_app_ug/testpmd_funcs.rst |  3 +-
 lib/ethdev/rte_flow.c                       | 36 ++++++++++-----------
 lib/ethdev/rte_flow.h                       |  3 +-
 5 files changed, 47 insertions(+), 21 deletions(-)

diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c
index 60ee9337cf..966a47936a 100644
--- a/app/test-pmd/cmdline_flow.c
+++ b/app/test-pmd/cmdline_flow.c
@@ -492,6 +492,7 @@ enum index {
 	ITEM_GENEVE_OPT_TYPE,
 	ITEM_GENEVE_OPT_LENGTH,
 	ITEM_GENEVE_OPT_DATA,
+	ITEM_GENEVE_OPT_DATA_ARRAY_SIZE,
 	ITEM_INTEGRITY,
 	ITEM_INTEGRITY_LEVEL,
 	ITEM_INTEGRITY_VALUE,
@@ -2032,6 +2033,7 @@ static const enum index item_geneve_opt[] = {
 	ITEM_GENEVE_OPT_TYPE,
 	ITEM_GENEVE_OPT_LENGTH,
 	ITEM_GENEVE_OPT_DATA,
+	ITEM_GENEVE_OPT_DATA_ARRAY_SIZE,
 	ITEM_NEXT,
 	ZERO,
 };
@@ -5772,6 +5774,14 @@ static const struct token token_list[] = {
 				(sizeof(struct rte_flow_item_geneve_opt),
 				ITEM_GENEVE_OPT_DATA_SIZE)),
 	},
+	[ITEM_GENEVE_OPT_DATA_ARRAY_SIZE] = {
+		.name = "data_size",
+		.help = "GENEVE option data array size",
+		.next = NEXT(item_geneve_opt, NEXT_ENTRY(COMMON_UNSIGNED),
+			     item_param),
+		.args = ARGS(ARGS_ENTRY(struct rte_flow_item_geneve_opt,
+					data_array_size)),
+	},
 	[ITEM_INTEGRITY] = {
 		.name = "integrity",
 		.help = "match packet integrity",
diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst
index dad588763f..cce02fe1d6 100644
--- a/doc/guides/prog_guide/rte_flow.rst
+++ b/doc/guides/prog_guide/rte_flow.rst
@@ -1092,6 +1092,22 @@ Matches a GENEVE header.
 - ``rsvd1``: reserved, normally 0x00.
 - Default ``mask`` matches VNI only.
 
+
+Item: ``GENEVE_OPT``
+^^^^^^^^^^^^^^^^^^^^
+
+Matches a GENEVE TLV option header.
+
+- ``option_class``: option class ID.
+- ``option_type``: option type.
+- ``option_len``: option data length in 4-bytes granularity.
+- ``data``: option data array.
+- ``data_array_size``: option data array size.
+  This field is not matchable, it is descriptor how to read the array.
+  It should be specified in ``mask`` as well.
+- Default ``mask`` matches type only.
+
+
 Item: ``VXLAN-GPE``
 ^^^^^^^^^^^^^^^^^^^
 
diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
index 2fbf9220d8..97623044e9 100644
--- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst
+++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
@@ -3743,7 +3743,8 @@ This section lists supported pattern items and their attributes, if any.
   - ``type {unsigned}``: GENEVE option type.
   - ``length {unsigned}``: GENEVE option length in 32-bit words.
   - ``data {hex string}``: GENEVE option data, the length is defined by
-    ``length`` field.
+    ``data_size`` field.
+  - ``data_size {unsigned}``: GENEVE option data size in 32-bit words.
 
 - ``vxlan-gpe``: match VXLAN-GPE header.
 
diff --git a/lib/ethdev/rte_flow.c b/lib/ethdev/rte_flow.c
index 2803507462..d68359961d 100644
--- a/lib/ethdev/rte_flow.c
+++ b/lib/ethdev/rte_flow.c
@@ -81,6 +81,21 @@ rte_flow_item_flex_conv(void *buf, const void *data)
 	return src->length;
 }
 
+static size_t
+rte_flow_item_geneve_opt_conv(void *buf, const void *data)
+{
+	const struct rte_flow_item_geneve_opt *src = data;
+	uint16_t byte_size = src->data_array_size << 2;
+
+	if (buf) {
+		struct rte_flow_item_geneve_opt *dst = buf;
+		void *deep_src = (void *)((uintptr_t)(dst + 1));
+
+		dst->data = rte_memcpy(deep_src, src->data, byte_size);
+	}
+	return byte_size;
+}
+
 /** Generate flow_item[] entry. */
 #define MK_FLOW_ITEM(t, s) \
 	[RTE_FLOW_ITEM_TYPE_ ## t] = { \
@@ -155,7 +170,8 @@ static const struct rte_flow_desc_data rte_flow_desc_item[] = {
 	MK_FLOW_ITEM(L2TPV3OIP, sizeof(struct rte_flow_item_l2tpv3oip)),
 	MK_FLOW_ITEM(PFCP, sizeof(struct rte_flow_item_pfcp)),
 	MK_FLOW_ITEM(ECPRI, sizeof(struct rte_flow_item_ecpri)),
-	MK_FLOW_ITEM(GENEVE_OPT, sizeof(struct rte_flow_item_geneve_opt)),
+	MK_FLOW_ITEM_FN(GENEVE_OPT, sizeof(struct rte_flow_item_geneve_opt),
+			rte_flow_item_geneve_opt_conv),
 	MK_FLOW_ITEM(INTEGRITY, sizeof(struct rte_flow_item_integrity)),
 	MK_FLOW_ITEM(CONNTRACK, sizeof(uint32_t)),
 	MK_FLOW_ITEM(PORT_REPRESENTOR, sizeof(struct rte_flow_item_ethdev)),
@@ -622,7 +638,6 @@ rte_flow_conv_item_spec(void *buf, const size_t size,
 	switch (item->type) {
 		union {
 			const struct rte_flow_item_raw *raw;
-			const struct rte_flow_item_geneve_opt *geneve_opt;
 		} spec;
 		union {
 			const struct rte_flow_item_raw *raw;
@@ -632,11 +647,9 @@ rte_flow_conv_item_spec(void *buf, const size_t size,
 		} mask;
 		union {
 			const struct rte_flow_item_raw *raw;
-			const struct rte_flow_item_geneve_opt *geneve_opt;
 		} src;
 		union {
 			struct rte_flow_item_raw *raw;
-			struct rte_flow_item_geneve_opt *geneve_opt;
 		} dst;
 		void *deep_src;
 		size_t tmp;
@@ -676,21 +689,6 @@ rte_flow_conv_item_spec(void *buf, const size_t size,
 			off += tmp;
 		}
 		break;
-	case RTE_FLOW_ITEM_TYPE_GENEVE_OPT:
-		off = rte_flow_conv_copy(buf, data, size,
-					 rte_flow_desc_item, item->type);
-		spec.geneve_opt = item->spec;
-		src.geneve_opt = data;
-		dst.geneve_opt = buf;
-		tmp = spec.geneve_opt->option_len << 2;
-		if (size > 0 && src.geneve_opt->data) {
-			deep_src = (void *)((uintptr_t)(dst.geneve_opt + 1));
-			dst.geneve_opt->data = rte_memcpy(deep_src,
-							  src.geneve_opt->data,
-							  tmp);
-		}
-		off += tmp;
-		break;
 	default:
 		off = rte_flow_conv_copy(buf, data, size,
 					 rte_flow_desc_item, item->type);
diff --git a/lib/ethdev/rte_flow.h b/lib/ethdev/rte_flow.h
index 6e8ab1d4c7..0ccb7562bd 100644
--- a/lib/ethdev/rte_flow.h
+++ b/lib/ethdev/rte_flow.h
@@ -1876,7 +1876,8 @@ struct rte_flow_item_geneve_opt {
 	rte_be16_t option_class;
 	uint8_t option_type;
 	uint8_t option_len;
-	uint32_t *data;
+	rte_be32_t *data;
+	uint8_t data_array_size;
 };
 
 /** Default mask for RTE_FLOW_ITEM_TYPE_GENEVE_OPT. */
-- 
2.25.1


  parent reply	other threads:[~2024-04-17  7:23 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-17  7:23 [RFC 0/2] ethdev: update GENEVE option item structure Michael Baum
2024-04-17  7:23 ` [RFC 1/2] ethdev: fix GENEVE option item conversion Michael Baum
2024-04-17  7:23 ` Michael Baum [this message]
2024-09-22 21:51   ` [RFC 2/2] ethdev: add data size field to GENEVE option item Ferruh Yigit
2024-06-11 17:07 ` [RFC 0/2] ethdev: update GENEVE option item structure Ferruh Yigit

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240417072304.3260172-3-michaelba@nvidia.com \
    --to=michaelba@nvidia.com \
    --cc=dev@dpdk.org \
    --cc=dsosnowski@nvidia.com \
    --cc=ferruh.yigit@amd.com \
    --cc=orika@nvidia.com \
    --cc=thomas@monjalon.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).