app/testpmd: add flow item to match on IPv4 version_ihl field

Message ID 20210705115217.4768-1-getelson@nvidia.com (mailing list archive)
State Superseded, archived
Delegated to: Andrew Rybchenko
Headers
Series app/testpmd: add flow item to match on IPv4 version_ihl field |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/github-robot success github build: passed
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-testing success Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-mellanox-Functional fail Functional Testing issues
ci/Intel-compilation fail Compilation issues
ci/iol-abi-testing success Testing PASS

Commit Message

Gregory Etelson July 5, 2021, 11:52 a.m. UTC
  The new item allows PMD to offload IPv4 IHL field for matching,
if hardware supports that operation.

Signed-off-by: Gregory Etelson <getelson@nvidia.com>
---
 app/test-pmd/cmdline_flow.c                 | 12 +++++++++++-
 doc/guides/testpmd_app_ug/testpmd_funcs.rst |  1 +
 2 files changed, 12 insertions(+), 1 deletion(-)
  

Comments

Gregory Etelson July 11, 2021, 10:25 a.m. UTC | #1
Hello Andrew,

Can you estimate when that patch will be merged ?

Regards,
Gregory

> -----Original Message-----
> From: Gregory Etelson <getelson@nvidia.com>
> Sent: Monday, July 5, 2021 14:52
> To: dev@dpdk.org
> Cc: Gregory Etelson <getelson@nvidia.com>; Slava Ovsiienko
> <viacheslavo@nvidia.com>; Ori Kam <orika@nvidia.com>; Xiaoyun Li
> <xiaoyun.li@intel.com>
> Subject: [PATCH] app/testpmd: add flow item to match on IPv4 version_ihl
> field
> 
> The new item allows PMD to offload IPv4 IHL field for matching, if hardware
> supports that operation.
> 
> Signed-off-by: Gregory Etelson <getelson@nvidia.com>
> ---
>  app/test-pmd/cmdline_flow.c                 | 12 +++++++++++-
>  doc/guides/testpmd_app_ug/testpmd_funcs.rst |  1 +
>  2 files changed, 12 insertions(+), 1 deletion(-)
> 
> diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c
> index 1c587bb7b8..c1c7b9a9f9 100644
> --- a/app/test-pmd/cmdline_flow.c
> +++ b/app/test-pmd/cmdline_flow.c
> @@ -173,6 +173,7 @@ enum index {
>  	ITEM_VLAN_INNER_TYPE,
>  	ITEM_VLAN_HAS_MORE_VLAN,
>  	ITEM_IPV4,
> +	ITEM_IPV4_VER_IHL,
>  	ITEM_IPV4_TOS,
>  	ITEM_IPV4_ID,
>  	ITEM_IPV4_FRAGMENT_OFFSET,
> @@ -1071,6 +1072,7 @@ static const enum index item_vlan[] = {  };
> 
>  static const enum index item_ipv4[] = {
> +	ITEM_IPV4_VER_IHL,
>  	ITEM_IPV4_TOS,
>  	ITEM_IPV4_ID,
>  	ITEM_IPV4_FRAGMENT_OFFSET,
> @@ -2567,6 +2569,13 @@ static const struct token token_list[] = {
>  		.next = NEXT(item_ipv4),
>  		.call = parse_vc,
>  	},
> +	[ITEM_IPV4_VER_IHL] = {
> +		.name = "version_ihl",
> +		.help = "match header length",
> +		.next = NEXT(item_ipv4, NEXT_ENTRY(UNSIGNED),
> item_param),
> +		.args = ARGS(ARGS_ENTRY(struct rte_flow_item_ipv4,
> +				     hdr.version_ihl)),
> +	},
>  	[ITEM_IPV4_TOS] = {
>  		.name = "tos",
>  		.help = "type of service",
> @@ -8123,7 +8132,8 @@ update_fields(uint8_t *buf, struct rte_flow_item
> *item, uint16_t next_proto)
>  		break;
>  	case RTE_FLOW_ITEM_TYPE_IPV4:
>  		ipv4 = (struct rte_ipv4_hdr *)buf;
> -		ipv4->version_ihl = 0x45;
> +		if (!ipv4->version_ihl)
> +			ipv4->version_ihl = RTE_IPV4_VHL_DEF;
>  		if (next_proto && ipv4->next_proto_id == 0)
>  			ipv4->next_proto_id = (uint8_t)next_proto;
>  		break;
> diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst
> b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
> index 33857acf54..ab7e91ad6c 100644
> --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst
> +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
> @@ -3654,6 +3654,7 @@ This section lists supported pattern items and
> their attributes, if any.
> 
>  - ``ipv4``: match IPv4 header.
> 
> +  - ``version_ihl {unsigned}``: IPv4 version and IP header length.
>    - ``tos {unsigned}``: type of service.
>    - ``ttl {unsigned}``: time to live.
>    - ``proto {unsigned}``: next protocol ID.
> --
> 2.31.1
  

Patch

diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c
index 1c587bb7b8..c1c7b9a9f9 100644
--- a/app/test-pmd/cmdline_flow.c
+++ b/app/test-pmd/cmdline_flow.c
@@ -173,6 +173,7 @@  enum index {
 	ITEM_VLAN_INNER_TYPE,
 	ITEM_VLAN_HAS_MORE_VLAN,
 	ITEM_IPV4,
+	ITEM_IPV4_VER_IHL,
 	ITEM_IPV4_TOS,
 	ITEM_IPV4_ID,
 	ITEM_IPV4_FRAGMENT_OFFSET,
@@ -1071,6 +1072,7 @@  static const enum index item_vlan[] = {
 };
 
 static const enum index item_ipv4[] = {
+	ITEM_IPV4_VER_IHL,
 	ITEM_IPV4_TOS,
 	ITEM_IPV4_ID,
 	ITEM_IPV4_FRAGMENT_OFFSET,
@@ -2567,6 +2569,13 @@  static const struct token token_list[] = {
 		.next = NEXT(item_ipv4),
 		.call = parse_vc,
 	},
+	[ITEM_IPV4_VER_IHL] = {
+		.name = "version_ihl",
+		.help = "match header length",
+		.next = NEXT(item_ipv4, NEXT_ENTRY(UNSIGNED), item_param),
+		.args = ARGS(ARGS_ENTRY(struct rte_flow_item_ipv4,
+				     hdr.version_ihl)),
+	},
 	[ITEM_IPV4_TOS] = {
 		.name = "tos",
 		.help = "type of service",
@@ -8123,7 +8132,8 @@  update_fields(uint8_t *buf, struct rte_flow_item *item, uint16_t next_proto)
 		break;
 	case RTE_FLOW_ITEM_TYPE_IPV4:
 		ipv4 = (struct rte_ipv4_hdr *)buf;
-		ipv4->version_ihl = 0x45;
+		if (!ipv4->version_ihl)
+			ipv4->version_ihl = RTE_IPV4_VHL_DEF;
 		if (next_proto && ipv4->next_proto_id == 0)
 			ipv4->next_proto_id = (uint8_t)next_proto;
 		break;
diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
index 33857acf54..ab7e91ad6c 100644
--- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst
+++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
@@ -3654,6 +3654,7 @@  This section lists supported pattern items and their attributes, if any.
 
 - ``ipv4``: match IPv4 header.
 
+  - ``version_ihl {unsigned}``: IPv4 version and IP header length.
   - ``tos {unsigned}``: type of service.
   - ``ttl {unsigned}``: time to live.
   - ``proto {unsigned}``: next protocol ID.