From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 9F9ADA04A4; Wed, 3 Jun 2020 16:21:02 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id E9C601D568; Wed, 3 Jun 2020 16:20:30 +0200 (CEST) Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by dpdk.org (Postfix) with ESMTP id 0485C1D560 for ; Wed, 3 Jun 2020 16:20:28 +0200 (CEST) IronPort-SDR: UBxPqpt9Xg3Hkgr4HZiHN5mV/eDnzVVUAar7HJqf+Lt/Kd/MHo8FYODx64q4C4yN+w0SFS6vvL 2CQQhXoQo1tQ== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Jun 2020 07:20:28 -0700 IronPort-SDR: 9nFHB1/BfuCsk++6CjVTDqiBWFqqG5QrQlHxmVyOzJo1rUqx75KuIevCf0X2iOIfwOGACu6Ckp YXW9Xgve1TnQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,467,1583222400"; d="scan'208";a="416572754" Received: from sivswdev08.ir.intel.com (HELO localhost.localdomain) ([10.237.217.47]) by orsmga004.jf.intel.com with ESMTP; 03 Jun 2020 07:20:27 -0700 From: Bernard Iremonger To: dev@dpdk.org, beilei.xing@intel.com, qi.z.zhang@intel.com, declan.doherty@intel.com, orika@mellanox.com Cc: Bernard Iremonger Date: Wed, 3 Jun 2020 15:20:05 +0100 Message-Id: <1591194009-4086-5-git-send-email-bernard.iremonger@intel.com> X-Mailer: git-send-email 1.7.0.7 In-Reply-To: <1591194009-4086-1-git-send-email-bernard.iremonger@intel.com> References: <1591194009-4086-1-git-send-email-bernard.iremonger@intel.com> Subject: [dpdk-dev] [PATCH 4/8] app/testpmd: parse map actions X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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 --- 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