app/testpmd: update raw flow to take hex input

Message ID 20210928110850.21184-2-nipun.gupta@nxp.com (mailing list archive)
State Rejected, archived
Headers
Series app/testpmd: update raw flow to take hex input |

Checks

Context Check Description
ci/checkpatch warning coding style issues
ci/github-robot: build fail github build: failed
ci/intel-Testing success Testing PASS

Commit Message

Nipun Gupta Sept. 28, 2021, 11:08 a.m. UTC
  From: Nipun Gupta <nipun.gupta@nxp.com>

This patch enables method to provide key and mask for raw rules
to be provided as hexadecimal values. There is new parameter
pattern_mask added to support this.

Signed-off-by: Nipun Gupta <nipun.gupta@nxp.com>
---
 app/test-pmd/cmdline_flow.c                 | 15 +++++++++++++++
 doc/guides/testpmd_app_ug/testpmd_funcs.rst | 13 +++++++++++++
 2 files changed, 28 insertions(+)
  

Comments

Nipun Gupta Sept. 28, 2021, 11:51 a.m. UTC | #1
Please ignore this patch for now.

Regards,
Nipun

> -----Original Message-----
> From: nipun.gupta@nxp.com <nipun.gupta@nxp.com>
> Sent: Tuesday, September 28, 2021 4:39 PM
> To: dev@dpdk.org
> Cc: xiaoyun.li@intel.com; orika@nvidia.com; thomas@monjalon.net;
> ferruh.yigit@intel.com; Hemant Agrawal <hemant.agrawal@nxp.com>; Nipun
> Gupta <nipun.gupta@nxp.com>
> Subject: [PATCH] app/testpmd: update raw flow to take hex input
> 
> From: Nipun Gupta <nipun.gupta@nxp.com>
> 
> This patch enables method to provide key and mask for raw rules
> to be provided as hexadecimal values. There is new parameter
> pattern_mask added to support this.
> 
> Signed-off-by: Nipun Gupta <nipun.gupta@nxp.com>
> ---
>  app/test-pmd/cmdline_flow.c                 | 15 +++++++++++++++
>  doc/guides/testpmd_app_ug/testpmd_funcs.rst | 13 +++++++++++++
>  2 files changed, 28 insertions(+)
> 
> diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c
> index 6cd99bf37f..a95b147d92 100644
> --- a/app/test-pmd/cmdline_flow.c
> +++ b/app/test-pmd/cmdline_flow.c
> @@ -158,6 +158,7 @@ enum index {
>  	ITEM_RAW_OFFSET,
>  	ITEM_RAW_LIMIT,
>  	ITEM_RAW_PATTERN,
> +	ITEM_RAW_PATTERN_HEX,
>  	ITEM_ETH,
>  	ITEM_ETH_DST,
>  	ITEM_ETH_SRC,
> @@ -1046,6 +1047,7 @@ static const enum index item_raw[] = {
>  	ITEM_RAW_OFFSET,
>  	ITEM_RAW_LIMIT,
>  	ITEM_RAW_PATTERN,
> +	ITEM_RAW_PATTERN_HEX,
>  	ITEM_NEXT,
>  	ZERO,
>  };
> @@ -2487,6 +2489,19 @@ static const struct token token_list[] = {
>  			     ARGS_ENTRY_ARB(sizeof(struct rte_flow_item_raw),
>  					    ITEM_RAW_PATTERN_SIZE)),
>  	},
> +	[ITEM_RAW_PATTERN_HEX] = {
> +		.name = "pattern_hex",
> +		.help = "hex string to look for",
> +		.next = NEXT(item_raw,
> +			     NEXT_ENTRY(HEX),
> +			     NEXT_ENTRY(ITEM_PARAM_IS,
> +					ITEM_PARAM_SPEC,
> +					ITEM_PARAM_MASK)),
> +		.args = ARGS(ARGS_ENTRY(struct rte_flow_item_raw, pattern),
> +			     ARGS_ENTRY(struct rte_flow_item_raw, length),
> +			     ARGS_ENTRY_ARB(sizeof(struct rte_flow_item_raw),
> +					    ITEM_RAW_PATTERN_SIZE)),
> +	},
>  	[ITEM_ETH] = {
>  		.name = "eth",
>  		.help = "match Ethernet header",
> diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst
> b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
> index 4f8751be1c..3a69d37037 100644
> --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst
> +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
> @@ -3637,6 +3637,7 @@ This section lists supported pattern items and their
> attributes, if any.
>    - ``offset {integer}``: absolute or relative offset for pattern.
>    - ``limit {unsigned}``: search area limit for start of pattern.
>    - ``pattern {string}``: byte string to look for.
> +  - ``pattern_hex {string}``: byte string (provided in hexadecimal) to look for.
> 
>  - ``eth``: match Ethernet header.
> 
> @@ -5036,6 +5037,18 @@ The meter policy action list: ``green -> green, yellow
> -> yellow, red -> red``.
>     testpmd> create port meter 0 1 13 1 yes 0xffff 0 0
>     testpmd> flow create 0 priority 0 ingress group 1 pattern eth / end actions
> meter mtr_id 1 / end
> 
> +Sample RAW rule
> +~~~~~~~~~~~~~~~
> +
> +A RAW rule can be creted as following using ``pattern_hex`` key and mask.
> +
> +::
> +
> +    testpmd> flow create 0 group 0 priority 1 ingress pattern raw relative is 0
> search is 0 offset
> +             is 0 limit is 0 pattern_hex spec
> 00000000000000000000000000000000000000000000000000000a0a0a0a
> +             pattern_hex mask
> 0000000000000000000000000000000000000000000000000000ffffffff / end
> actions
> +             queue index 4 / end
> +
>  BPF Functions
>  --------------
> 
> --
> 2.17.1
  

Patch

diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c
index 6cd99bf37f..a95b147d92 100644
--- a/app/test-pmd/cmdline_flow.c
+++ b/app/test-pmd/cmdline_flow.c
@@ -158,6 +158,7 @@  enum index {
 	ITEM_RAW_OFFSET,
 	ITEM_RAW_LIMIT,
 	ITEM_RAW_PATTERN,
+	ITEM_RAW_PATTERN_HEX,
 	ITEM_ETH,
 	ITEM_ETH_DST,
 	ITEM_ETH_SRC,
@@ -1046,6 +1047,7 @@  static const enum index item_raw[] = {
 	ITEM_RAW_OFFSET,
 	ITEM_RAW_LIMIT,
 	ITEM_RAW_PATTERN,
+	ITEM_RAW_PATTERN_HEX,
 	ITEM_NEXT,
 	ZERO,
 };
@@ -2487,6 +2489,19 @@  static const struct token token_list[] = {
 			     ARGS_ENTRY_ARB(sizeof(struct rte_flow_item_raw),
 					    ITEM_RAW_PATTERN_SIZE)),
 	},
+	[ITEM_RAW_PATTERN_HEX] = {
+		.name = "pattern_hex",
+		.help = "hex string to look for",
+		.next = NEXT(item_raw,
+			     NEXT_ENTRY(HEX),
+			     NEXT_ENTRY(ITEM_PARAM_IS,
+					ITEM_PARAM_SPEC,
+					ITEM_PARAM_MASK)),
+		.args = ARGS(ARGS_ENTRY(struct rte_flow_item_raw, pattern),
+			     ARGS_ENTRY(struct rte_flow_item_raw, length),
+			     ARGS_ENTRY_ARB(sizeof(struct rte_flow_item_raw),
+					    ITEM_RAW_PATTERN_SIZE)),
+	},
 	[ITEM_ETH] = {
 		.name = "eth",
 		.help = "match Ethernet header",
diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
index 4f8751be1c..3a69d37037 100644
--- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst
+++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
@@ -3637,6 +3637,7 @@  This section lists supported pattern items and their attributes, if any.
   - ``offset {integer}``: absolute or relative offset for pattern.
   - ``limit {unsigned}``: search area limit for start of pattern.
   - ``pattern {string}``: byte string to look for.
+  - ``pattern_hex {string}``: byte string (provided in hexadecimal) to look for.
 
 - ``eth``: match Ethernet header.
 
@@ -5036,6 +5037,18 @@  The meter policy action list: ``green -> green, yellow -> yellow, red -> red``.
    testpmd> create port meter 0 1 13 1 yes 0xffff 0 0
    testpmd> flow create 0 priority 0 ingress group 1 pattern eth / end actions meter mtr_id 1 / end
 
+Sample RAW rule
+~~~~~~~~~~~~~~~
+
+A RAW rule can be creted as following using ``pattern_hex`` key and mask.
+
+::
+
+    testpmd> flow create 0 group 0 priority 1 ingress pattern raw relative is 0 search is 0 offset
+             is 0 limit is 0 pattern_hex spec 00000000000000000000000000000000000000000000000000000a0a0a0a
+             pattern_hex mask 0000000000000000000000000000000000000000000000000000ffffffff / end actions
+             queue index 4 / end
+
 BPF Functions
 --------------