DPDK patches and discussions
 help / color / mirror / Atom feed
From: Michael Baum <michaelba@nvidia.com>
To: <dev@dpdk.org>
Cc: Ori Kam <orika@nvidia.com>,
	Aman Singh <aman.deep.singh@intel.com>,
	"Yuying Zhang" <yuying.zhang@intel.com>,
	Ferruh Yigit <ferruh.yigit@amd.com>,
	 "Thomas Monjalon" <thomas@monjalon.net>
Subject: [PATCH v1 6/7] ethdev: add MPLS header modification support
Date: Tue, 16 May 2023 09:37:46 +0300	[thread overview]
Message-ID: <20230516063747.3047758-7-michaelba@nvidia.com> (raw)
In-Reply-To: <20230516063747.3047758-1-michaelba@nvidia.com>

Add support for MPLS modify header using "RTE_FLOW_FIELD_MPLS" id.

Since MPLS heaser might appear more the one time in inner/outer/tunnel,
a new field was added to "rte_flow_action_modify_data" structure in
addition to "level" field.
The "sub_level" field is the index of the header inside encapsulation
level. It is used for modify multiple MPLS headers in same encapsulation
level.

This addition enables to modify multiple VLAN headers too, so the
description of "RTE_FLOW_FIELD_VLAN_XXXX" was updated.

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

diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c
index 8c1dea53c0..5370be1e3c 100644
--- a/app/test-pmd/cmdline_flow.c
+++ b/app/test-pmd/cmdline_flow.c
@@ -636,6 +636,7 @@ enum index {
 	ACTION_MODIFY_FIELD_DST_TYPE_VALUE,
 	ACTION_MODIFY_FIELD_DST_LEVEL,
 	ACTION_MODIFY_FIELD_DST_LEVEL_VALUE,
+	ACTION_MODIFY_FIELD_DST_SUB_LEVEL,
 	ACTION_MODIFY_FIELD_DST_TYPE_ID,
 	ACTION_MODIFY_FIELD_DST_CLASS_ID,
 	ACTION_MODIFY_FIELD_DST_OFFSET,
@@ -643,6 +644,7 @@ enum index {
 	ACTION_MODIFY_FIELD_SRC_TYPE_VALUE,
 	ACTION_MODIFY_FIELD_SRC_LEVEL,
 	ACTION_MODIFY_FIELD_SRC_LEVEL_VALUE,
+	ACTION_MODIFY_FIELD_SRC_SUB_LEVEL,
 	ACTION_MODIFY_FIELD_SRC_TYPE_ID,
 	ACTION_MODIFY_FIELD_SRC_CLASS_ID,
 	ACTION_MODIFY_FIELD_SRC_OFFSET,
@@ -859,7 +861,7 @@ static const char *const modify_field_ids[] = {
 	"ipv6_proto",
 	"flex_item",
 	"hash_result",
-	"geneve_opt_type", "geneve_opt_class", "geneve_opt_data",
+	"geneve_opt_type", "geneve_opt_class", "geneve_opt_data", "mpls",
 	NULL
 };
 
@@ -2301,6 +2303,7 @@ static const enum index next_action_sample[] = {
 
 static const enum index action_modify_field_dst[] = {
 	ACTION_MODIFY_FIELD_DST_LEVEL,
+	ACTION_MODIFY_FIELD_DST_SUB_LEVEL,
 	ACTION_MODIFY_FIELD_DST_TYPE_ID,
 	ACTION_MODIFY_FIELD_DST_CLASS_ID,
 	ACTION_MODIFY_FIELD_DST_OFFSET,
@@ -2310,6 +2313,7 @@ static const enum index action_modify_field_dst[] = {
 
 static const enum index action_modify_field_src[] = {
 	ACTION_MODIFY_FIELD_SRC_LEVEL,
+	ACTION_MODIFY_FIELD_SRC_SUB_LEVEL,
 	ACTION_MODIFY_FIELD_SRC_TYPE_ID,
 	ACTION_MODIFY_FIELD_SRC_CLASS_ID,
 	ACTION_MODIFY_FIELD_SRC_OFFSET,
@@ -6398,6 +6402,15 @@ static const struct token token_list[] = {
 		.call = parse_vc_modify_field_level,
 		.comp = comp_none,
 	},
+	[ACTION_MODIFY_FIELD_DST_SUB_LEVEL] = {
+		.name = "dst_sub_level",
+		.help = "destination field sub level",
+		.next = NEXT(action_modify_field_dst,
+			     NEXT_ENTRY(COMMON_UNSIGNED)),
+		.args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field,
+					dst.sub_level)),
+		.call = parse_vc_conf,
+	},
 	[ACTION_MODIFY_FIELD_DST_TYPE_ID] = {
 		.name = "dst_type_id",
 		.help = "destination field type ID",
@@ -6451,6 +6464,15 @@ static const struct token token_list[] = {
 		.call = parse_vc_modify_field_level,
 		.comp = comp_none,
 	},
+	[ACTION_MODIFY_FIELD_SRC_SUB_LEVEL] = {
+		.name = "stc_sub_level",
+		.help = "source field sub level",
+		.next = NEXT(action_modify_field_src,
+			     NEXT_ENTRY(COMMON_UNSIGNED)),
+		.args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field,
+					src.sub_level)),
+		.call = parse_vc_conf,
+	},
 	[ACTION_MODIFY_FIELD_SRC_TYPE_ID] = {
 		.name = "src_type_id",
 		.help = "source field type ID",
diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst
index cd38f0de46..1f681a38e4 100644
--- a/doc/guides/prog_guide/rte_flow.rst
+++ b/doc/guides/prog_guide/rte_flow.rst
@@ -2937,6 +2937,10 @@ as well as any tag element in the tag array:
 For the tag array (in case of multiple tags are supported and present)
 ``level`` translates directly into the array index.
 
+- ``sub_level`` is the index of the header inside encapsulation level.
+  It is used for modify either ``VLAN`` or ``MPLS`` headers which multiple of
+  them might be supported in same encapsulation level.
+
 ``type`` is used to specify (along with ``class_id``) the Geneve option which
 is being modified.
 This field is relevant only for ``RTE_FLOW_FIELD_GENEVE_OPT_XXXX`` type.
@@ -3002,6 +3006,8 @@ value as sequence of bytes {xxx, xxx, 0x85, xxx, xxx, xxx}.
    +-----------------+----------------------------------------------------------+
    | ``level``       | encapsulation level of a packet field or tag array index |
    +-----------------+----------------------------------------------------------+
+   | ``sub_level``   | header level inside encapsulation level                  |
+   +-----------------+----------------------------------------------------------+
    | ``type``        | geneve option type                                       |
    +-----------------+----------------------------------------------------------+
    | ``class_id``    | geneve option class ID                                   |
diff --git a/lib/ethdev/rte_flow.h b/lib/ethdev/rte_flow.h
index b82eb0c0a8..4b2e17e266 100644
--- a/lib/ethdev/rte_flow.h
+++ b/lib/ethdev/rte_flow.h
@@ -3740,8 +3740,8 @@ enum rte_flow_field_id {
 	RTE_FLOW_FIELD_START = 0,	/**< Start of a packet. */
 	RTE_FLOW_FIELD_MAC_DST,		/**< Destination MAC Address. */
 	RTE_FLOW_FIELD_MAC_SRC,		/**< Source MAC Address. */
-	RTE_FLOW_FIELD_VLAN_TYPE,	/**< 802.1Q Tag Identifier. */
-	RTE_FLOW_FIELD_VLAN_ID,		/**< 802.1Q VLAN Identifier. */
+	RTE_FLOW_FIELD_VLAN_TYPE,	/**< VLAN Tag Identifier. */
+	RTE_FLOW_FIELD_VLAN_ID,		/**< VLAN Identifier. */
 	RTE_FLOW_FIELD_MAC_TYPE,	/**< EtherType. */
 	RTE_FLOW_FIELD_IPV4_DSCP,	/**< IPv4 DSCP. */
 	RTE_FLOW_FIELD_IPV4_TTL,	/**< IPv4 Time To Live. */
@@ -3775,7 +3775,8 @@ enum rte_flow_field_id {
 	RTE_FLOW_FIELD_HASH_RESULT,	/**< Hash result. */
 	RTE_FLOW_FIELD_GENEVE_OPT_TYPE,	/**< GENEVE option type */
 	RTE_FLOW_FIELD_GENEVE_OPT_CLASS,/**< GENEVE option class */
-	RTE_FLOW_FIELD_GENEVE_OPT_DATA	/**< GENEVE option data */
+	RTE_FLOW_FIELD_GENEVE_OPT_DATA,	/**< GENEVE option data */
+	RTE_FLOW_FIELD_MPLS		/**< MPLS header. */
 };
 
 /**
@@ -3821,22 +3822,38 @@ struct rte_flow_action_modify_data {
 					 * Values other than @p 0 are not
 					 * necessarily supported.
 					 *
+					 * @note that for MPLS field,
+					 * encapsulation level also include
+					 * tunnel since MPLS may appear in
+					 * outer, inner or tunnel.
+					 *
 					 * For RTE_FLOW_FIELD_TAG it represents
 					 * the tag element in the tag array.
 					 */
 					uint8_t level;
-					/**
-					 * Geneve option type. relevant only
-					 * for RTE_FLOW_FIELD_GENEVE_OPT_XXXX
-					 * modification type.
-					 */
-					uint8_t type;
-					/**
-					 * Geneve option class. relevant only
-					 * for RTE_FLOW_FIELD_GENEVE_OPT_XXXX
-					 * modification type.
-					 */
-					rte_be16_t class_id;
+					union {
+						/**
+						 * Header level inside
+						 * encapsulation level.
+						 */
+						uint8_t sub_level;
+						/**
+						 * Geneve option identifier.
+						 * relevant only for
+						 * RTE_FLOW_FIELD_GENEVE_OPT_XXXX
+						 * modification type.
+						 */
+						struct {
+							/**
+							 * Geneve option type.
+							 */
+							uint8_t type;
+							/**
+							 * Geneve option class.
+							 */
+							rte_be16_t class_id;
+						};
+					};
 				};
 				struct rte_flow_item_flex_handle *flex_handle;
 			};
-- 
2.25.1


  parent reply	other threads:[~2023-05-16  6:38 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-16  6:37 [PATCH v1 0/7] ethdev: modify field API for multiple headers Michael Baum
2023-05-16  6:37 ` [PATCH v1 1/7] doc: fix blank lines in modify field action description Michael Baum
2023-05-16  6:37 ` [PATCH v1 2/7] doc: fix blank line in asynchronous operations description Michael Baum
2023-05-17 17:13   ` Ori Kam
2023-05-16  6:37 ` [PATCH v1 3/7] doc: fix wrong indentation in RSS action description Michael Baum
2023-05-18  6:18   ` Ori Kam
2023-05-16  6:37 ` [PATCH v1 4/7] net/mlx5: reduce modify field encapsulation level size Michael Baum
2023-05-16  6:37 ` [PATCH v1 5/7] ethdev: add GENEVE TLV option modification support Michael Baum
2023-05-16  6:37 ` Michael Baum [this message]
2023-05-16  6:37 ` [PATCH v1 7/7] net/mlx5: add MPLS modify field support Michael Baum
2023-05-18 17:40 ` [PATCH v2 0/5] ethdev: modify field API for multiple headers Michael Baum
2023-05-18 17:40   ` [PATCH v2 1/5] doc: fix blank lines in modify field action description Michael Baum
2023-05-21 10:07     ` Ori Kam
2023-05-18 17:40   ` [PATCH v2 2/5] doc: fix blank line in asynchronous operations description Michael Baum
2023-05-21 10:07     ` Ori Kam
2023-05-18 17:40   ` [PATCH v2 3/5] doc: fix wrong indentation in RSS action description Michael Baum
2023-05-21 10:08     ` Ori Kam
2023-05-18 17:40   ` [PATCH v2 4/5] ethdev: add GENEVE TLV option modification support Michael Baum
2023-05-21 18:52     ` Ori Kam
2023-05-18 17:40   ` [PATCH v2 5/5] ethdev: add MPLS header " Michael Baum
2023-05-21 19:03     ` Ori Kam
2023-05-22 12:04       ` Michael Baum
2023-05-22 19:27   ` [PATCH v3 0/5] ethdev: modify field API for multiple headers Michael Baum
2023-05-22 19:28     ` [PATCH v3 1/5] doc: fix blank lines in modify field action description Michael Baum
2023-05-22 19:28     ` [PATCH v3 2/5] doc: fix blank line in asynchronous operations description Michael Baum
2023-05-22 19:28     ` [PATCH v3 3/5] doc: fix wrong indentation in RSS action description Michael Baum
2023-05-22 19:28     ` [PATCH v3 4/5] ethdev: add GENEVE TLV option modification support Michael Baum
2023-05-22 19:28     ` [PATCH v3 5/5] ethdev: add MPLS header " Michael Baum
2023-05-23 10:40     ` [PATCH v3 0/5] ethdev: modify field API for multiple headers Ori Kam
2023-05-23 12:48     ` [PATCH v4 " Michael Baum
2023-05-23 12:48       ` [PATCH v4 1/5] doc: fix blank lines in modify field action description Michael Baum
2023-05-23 12:48       ` [PATCH v4 2/5] doc: fix blank line in asynchronous operations description Michael Baum
2023-05-23 12:48       ` [PATCH v4 3/5] doc: fix wrong indentation in RSS action description Michael Baum
2023-05-23 12:48       ` [PATCH v4 4/5] ethdev: add GENEVE TLV option modification support Michael Baum
2023-05-23 12:48       ` [PATCH v4 5/5] ethdev: add MPLS header " Michael Baum
2023-05-23 21:31       ` [PATCH v5 0/5] ethdev: modify field API for multiple headers Michael Baum
2023-05-23 21:31         ` [PATCH v5 1/5] doc: fix blank lines in modify field action description Michael Baum
2023-05-23 21:31         ` [PATCH v5 2/5] doc: fix blank line in asynchronous operations description Michael Baum
2023-05-23 21:31         ` [PATCH v5 3/5] doc: fix wrong indentation in RSS action description Michael Baum
2023-05-23 21:31         ` [PATCH v5 4/5] ethdev: add GENEVE TLV option modification support Michael Baum
2023-05-23 21:31         ` [PATCH v5 5/5] ethdev: add MPLS header " Michael Baum
2023-06-01 11:54           ` Ferruh Yigit
2023-06-01 11:54         ` [PATCH v5 0/5] ethdev: modify field API for multiple headers 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=20230516063747.3047758-7-michaelba@nvidia.com \
    --to=michaelba@nvidia.com \
    --cc=aman.deep.singh@intel.com \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@amd.com \
    --cc=orika@nvidia.com \
    --cc=thomas@monjalon.net \
    --cc=yuying.zhang@intel.com \
    /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).