DPDK patches and discussions
 help / color / mirror / Atom feed
From: Bernard Iremonger <bernard.iremonger@intel.com>
To: dev@dpdk.org, beilei.xing@intel.com, qi.z.zhang@intel.com,
	declan.doherty@intel.com, orika@mellanox.com
Cc: Bernard Iremonger <bernard.iremonger@intel.com>
Subject: [dpdk-dev] [PATCH 4/8] app/testpmd: parse map actions
Date: Wed,  3 Jun 2020 15:20:05 +0100	[thread overview]
Message-ID: <1591194009-4086-5-git-send-email-bernard.iremonger@intel.com> (raw)
In-Reply-To: <1591194009-4086-1-git-send-email-bernard.iremonger@intel.com>

Parse map, pctype and flowtype on testpmd command line.

In cmdline_flow.c add the following:

ACTION_MAP
ACTION_MAP_PCTYPE
ACTION_MAP_FLOWTYPE
add parse_vc_action_map()

Update testpmd user guide with map action and
sample map action rules.

Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
---
 app/test-pmd/cmdline_flow.c                 | 85 +++++++++++++++++++++++++++++
 doc/guides/testpmd_app_ug/testpmd_funcs.rst | 27 +++++++++
 2 files changed, 112 insertions(+)

diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c
index 4e2006c..3b7f775 100644
--- a/app/test-pmd/cmdline_flow.c
+++ b/app/test-pmd/cmdline_flow.c
@@ -349,6 +349,9 @@ enum index {
 	ACTION_SET_IPV6_DSCP_VALUE,
 	ACTION_AGE,
 	ACTION_AGE_TIMEOUT,
+	ACTION_MAP,
+	ACTION_MAP_PCTYPE,
+	ACTION_MAP_FLOWTYPE,
 };
 
 /** Maximum size for pattern in struct rte_flow_item_raw. */
@@ -368,6 +371,11 @@ struct action_rss_data {
 	uint16_t queue[ACTION_RSS_QUEUE_NUM];
 };
 
+/** Storage for struct rte_flow_action_map including external data. */
+struct action_map_data {
+	struct rte_flow_action_map conf;
+};
+
 /** Maximum data size in struct rte_flow_action_raw_encap. */
 #define ACTION_RAW_ENCAP_MAX_DATA 128
 #define RAW_ENCAP_CONFS_MAX_NUM 8
@@ -1161,6 +1169,7 @@ static const enum index next_action[] = {
 	ACTION_SET_IPV4_DSCP,
 	ACTION_SET_IPV6_DSCP,
 	ACTION_AGE,
+	ACTION_MAP,
 	ZERO,
 };
 
@@ -1194,6 +1203,13 @@ static const enum index action_rss[] = {
 	ZERO,
 };
 
+static const enum index action_map[] = {
+	ACTION_MAP_PCTYPE,
+	ACTION_MAP_FLOWTYPE,
+	ACTION_NEXT,
+	ZERO,
+};
+
 static const enum index action_vf[] = {
 	ACTION_VF_ORIGINAL,
 	ACTION_VF_ID,
@@ -1421,6 +1437,9 @@ static int parse_vc_action_rss_type(struct context *, const struct token *,
 static int parse_vc_action_rss_queue(struct context *, const struct token *,
 				     const char *, unsigned int, void *,
 				     unsigned int);
+static int parse_vc_action_map(struct context *, const struct token *,
+			       const char *, unsigned int, void *,
+			       unsigned int);
 static int parse_vc_action_vxlan_encap(struct context *, const struct token *,
 				       const char *, unsigned int, void *,
 				       unsigned int);
@@ -3609,6 +3628,36 @@ static const struct token token_list[] = {
 		.call = parse_vc_action_raw_decap_index,
 		.comp = comp_set_raw_index,
 	},
+	[ACTION_MAP] = {
+		.name = "map",
+		.help = "map Packet Classification type to flow type",
+		.priv = PRIV_ACTION(MAP, sizeof(struct action_map_data)),
+		.next = NEXT(action_map),
+		.args = ARGS(ARGS_ENTRY(struct rte_flow_action_map, pctype),
+			     ARGS_ENTRY(struct rte_flow_action_map,
+						flowtype)),
+		.call = parse_vc_action_map,
+	},
+	[ACTION_MAP_PCTYPE] = {
+		.name = "pctype",
+		.help = "Packet Classification type ",
+		.next = NEXT(action_map, NEXT_ENTRY(UNSIGNED)),
+		.args = ARGS(ARGS_ENTRY_ARB
+			     (offsetof(struct action_map_data, conf) +
+			      offsetof(struct rte_flow_action_map, pctype),
+			      sizeof(((struct rte_flow_action_map *)0)->
+				     pctype))),
+	},
+	[ACTION_MAP_FLOWTYPE] = {
+		.name = "flowtype",
+		.help = "flow type ",
+		.next = NEXT(action_map, NEXT_ENTRY(UNSIGNED)),
+		.args = ARGS(ARGS_ENTRY_ARB
+			     (offsetof(struct action_map_data, conf) +
+			      offsetof(struct rte_flow_action_map, flowtype),
+			      sizeof(((struct rte_flow_action_map *)0)->
+				     flowtype))),
+	},
 	/* Top level command. */
 	[SET] = {
 		.name = "set",
@@ -5207,6 +5256,42 @@ parse_vc_action_set_meta(struct context *ctx, const struct token *token,
 	return len;
 }
 
+/** Parse MAP action. */
+static int
+parse_vc_action_map(struct context *ctx, const struct token *token,
+		    const char *str, unsigned int len,
+		    void *buf, unsigned int size)
+{
+	struct buffer *out = buf;
+	struct rte_flow_action *action;
+	struct action_map_data *action_map_data;
+	int ret;
+
+	ret = parse_vc(ctx, token, str, len, buf, size);
+	if (ret < 0)
+		return ret;
+	/* Nothing else to do if there is no buffer. */
+	if (!out)
+		return ret;
+	if (!out->args.vc.actions_n)
+		return -1;
+	action = &out->args.vc.actions[out->args.vc.actions_n - 1];
+	/* Point to selected object. */
+	ctx->object = out->args.vc.data;
+	ctx->objmask = NULL;
+	/* Set up default configuration. */
+	action_map_data = ctx->object;
+	*action_map_data = (struct action_map_data){
+		.conf = (struct rte_flow_action_map){
+			.flowtype = 0,
+			.pctype = 0
+		},
+	};
+
+	action->conf = &action_map_data->conf;
+	return ret;
+}
+
 /** Parse tokens for destroy command. */
 static int
 parse_destroy(struct context *ctx, const struct token *token,
diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
index a808b6a..d0c0b09 100644
--- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst
+++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
@@ -4281,6 +4281,8 @@ This section lists supported actions and their attributes, if any.
 
   - ``dscp_value {unsigned}``: The new DSCP value to be set
 
+- ``map``: map Packet Classification (PC) type to flow type.
+
 Destroying flow rules
 ~~~~~~~~~~~~~~~~~~~~~
 
@@ -4936,6 +4938,31 @@ if seid is set)::
  testpmd> flow create 0 ingress pattern eth / ipv6 / pfcp s_field is 1
         seid is 1 / end actions queue index 3 / end
 
+Sample PCTYPE mapping rules
+~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+The following sequence of commands is required for pctype mapping::
+
+ testpmd> port stop 0
+ testpmd> flow create 0 ingress pattern end actions map pctype 15 flowtype 27 /
+        end
+ testpmd> show port 0 pctype mapping
+ pctype: 15  ->  flowtype: 27
+
+ testpmd> port start 0
+ testpmd> flow create 0 ingress pattern end actions rss types end queues 0 1 2
+        3 end / end
+ testpmd> flow create 0 ingress pattern eth / ipv4 / esp / end actions rss
+        types esp end queues end / end
+
+ testpmd> flow list 0
+ ID Group   Prio    Attr Rule
+ 0  0       0       i--  => MAP
+ 1  0       0       i--  => RSS
+ 2  0       0       i--  ETH IPV4 ESP => RSS
+ testpmd> set verbose 1
+ testpmd> start
+
 BPF Functions
 --------------
 
-- 
2.7.4


  parent reply	other threads:[~2020-06-03 14:21 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-03 14:20 [dpdk-dev] [PATCH 0/8] add flow action map Bernard Iremonger
2020-06-03 14:20 ` [dpdk-dev] [PATCH 1/8] librte_ethdev: add new flow types and action Bernard Iremonger
2020-06-03 14:20 ` [dpdk-dev] [PATCH 2/8] librte_ethdev: add map filter type Bernard Iremonger
2020-06-03 14:20 ` [dpdk-dev] [PATCH 3/8] librte_ethdev: add map action Bernard Iremonger
2020-06-03 14:20 ` Bernard Iremonger [this message]
2020-06-03 14:20 ` [dpdk-dev] [PATCH 5/8] net/i40e: add map filter Bernard Iremonger
2020-06-03 14:20 ` [dpdk-dev] [PATCH 6/8] net/i40e: add map functions Bernard Iremonger
2020-06-03 14:20 ` [dpdk-dev] [PATCH 7/8] net/i40e: parse map pattern and action Bernard Iremonger
2020-06-03 14:20 ` [dpdk-dev] [PATCH 8/8] doc: release note Bernard Iremonger
2020-06-04  6:05 ` [dpdk-dev] [PATCH 0/8] add flow action map Ori Kam
2020-06-04 11:21   ` Iremonger, Bernard
2020-06-04 13:12     ` Thomas Monjalon

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=1591194009-4086-5-git-send-email-bernard.iremonger@intel.com \
    --to=bernard.iremonger@intel.com \
    --cc=beilei.xing@intel.com \
    --cc=declan.doherty@intel.com \
    --cc=dev@dpdk.org \
    --cc=orika@mellanox.com \
    --cc=qi.z.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).