Skip to contentSkip to conversation

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

PATCH Superseded Gregory Etelson 3 participants 8 messages Jul 5, 2021 – Jul 13, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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.

---
 app/test-pmd/cmdline_flow.c                 | 12 +++++++++++-
 doc/guides/testpmd_app_ug/testpmd_funcs.rst |  1 +
 2 files changed, 12 insertions(+), 1 deletion(-)
app/test-pmd/cmdline_flow.c +11 -1
index 1c587bb7b8..c1c7b9a9f9 100644
@@ -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;
doc/guides/testpmd_app_ug/testpmd_funcs.rst +1 -0
index 33857acf54..ab7e91ad6c 100644
@@ -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.
Signature · 1 line
2.31.1
#1 lore raw

Hello Andrew,

Can you estimate when that patch will be merged ?

Regards,
Gregory

Quoted 80 lines

-----Original Message-----
From: Gregory Etelson <[email protected]>
Sent: Monday, July 5, 2021 14:52
To: [email protected]
Cc: Gregory Etelson <[email protected]>; Slava Ovsiienko <[email protected]>; Ori Kam <[email protected]>; Xiaoyun Li <[email protected]>
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.

---
 app/test-pmd/cmdline_flow.c                 | 12 +++++++++++-
 doc/guides/testpmd_app_ug/testpmd_funcs.rst |  1 +
 2 files changed, 12 insertions(+), 1 deletion(-)
app/test-pmd/cmdline_flow.c +9 -0
index 1c587bb7b8..c1c7b9a9f9 100644
@@ -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",
app/test-pmd/cmdline_flow.c +2 -1
 		.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;
app/test-pmd/cmdline_flow.c +0 -0
 		break;
doc/guides/testpmd_app_ug/testpmd_funcs.rst +0 -0
index 33857acf54..ab7e91ad6c 100644
@@ -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

#2 lore raw

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

In reply to Gregory Etelson

The new flow item allows PMD to offload IPv4 IHL field for matching, if hardware supports that operation.

---
v2: replace UNSIGNED with COMMON_UNSIGNED following 21.08 API change.

---
 app/test-pmd/cmdline_flow.c                 | 13 ++++++++++++-
 doc/guides/testpmd_app_ug/testpmd_funcs.rst |  1 +
 2 files changed, 13 insertions(+), 1 deletion(-)
app/test-pmd/cmdline_flow.c +12 -1
index 8fc0e1469d..34e043621c 100644
@@ -171,6 +171,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,
@@ -1069,6 +1070,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,
@@ -2576,6 +2578,14 @@ 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(COMMON_UNSIGNED),
+			     item_param),
+		.args = ARGS(ARGS_ENTRY(struct rte_flow_item_ipv4,
+				     hdr.version_ihl)),
+	},
 	[ITEM_IPV4_TOS] = {
 		.name = "tos",
 		.help = "type of service",
@@ -8193,7 +8203,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;
doc/guides/testpmd_app_ug/testpmd_funcs.rst +1 -0
index 33857acf54..ab7e91ad6c 100644
@@ -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.
Signature · 1 line
2.31.1
#3 lore raw

@Ori, could you review it, please.

Thanks,
Andrew.

Quoted 69 lines · Gregory Etelson

The new flow item allows PMD to offload IPv4 IHL field for matching, if hardware supports that operation.

---
v2: replace UNSIGNED with COMMON_UNSIGNED following 21.08 API change.

---
 app/test-pmd/cmdline_flow.c                 | 13 ++++++++++++-
 doc/guides/testpmd_app_ug/testpmd_funcs.rst |  1 +
 2 files changed, 13 insertions(+), 1 deletion(-)
app/test-pmd/cmdline_flow.c +12 -1
index 8fc0e1469d..34e043621c 100644
@@ -171,6 +171,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,
@@ -1069,6 +1070,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,
@@ -2576,6 +2578,14 @@ 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(COMMON_UNSIGNED),
+			     item_param),
+		.args = ARGS(ARGS_ENTRY(struct rte_flow_item_ipv4,
+				     hdr.version_ihl)),
+	},
 	[ITEM_IPV4_TOS] = {
 		.name = "tos",
 		.help = "type of service",
@@ -8193,7 +8203,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;
doc/guides/testpmd_app_ug/testpmd_funcs.rst +1 -0
index 33857acf54..ab7e91ad6c 100644
@@ -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.
#4 lore raw

Hello,

The patch was reviewed and approved by @Slava Ovsiienko

Regards,
Gregory

Quoted 91 lines

-----Original Message-----
From: Andrew Rybchenko <[email protected]>
Sent: Tuesday, July 13, 2021 11:08
To: Ori Kam <[email protected]>
Cc: Slava Ovsiienko <[email protected]>; Xiaoyun Li <[email protected]>; Gregory Etelson <[email protected]>; [email protected]
Subject: Re: [PATCH v2] app/testpmd: add flow item to match on IPv4 version_ihl field

External email: Use caution opening links or attachments

@Ori, could you review it, please.

Thanks,
Andrew.

Quoted 6 lines · Gregory Etelson

The new flow item allows PMD to offload IPv4 IHL field for matching, if hardware supports that operation.

---
v2: replace UNSIGNED with COMMON_UNSIGNED following 21.08 API

change.

Quoted 39 lines
---
 app/test-pmd/cmdline_flow.c                 | 13 ++++++++++++-
 doc/guides/testpmd_app_ug/testpmd_funcs.rst |  1 +
 2 files changed, 13 insertions(+), 1 deletion(-)
app/test-pmd/cmdline_flow.c +10 -0
index 8fc0e1469d..34e043621c 100644
@@ -171,6 +171,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,
@@ -1069,6 +1070,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,
@@ -2576,6 +2578,14 @@ 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(COMMON_UNSIGNED),
+                          item_param),
+             .args = ARGS(ARGS_ENTRY(struct rte_flow_item_ipv4,
+                                  hdr.version_ihl)),
+     },
      [ITEM_IPV4_TOS] = {
              .name = "tos",
              .help = "type of service", @@ -8193,7 +8203,8 @@
Quoted 1 line

update_fields(uint8_t *buf, struct rte_flow_item *item, uint16_t

next_proto)

doc/guides/testpmd_app_ug/testpmd_funcs.rst This section lists supported pattern items and

Quoted 15 lines
              break;
      case RTE_FLOW_ITEM_TYPE_IPV4:
              ipv4 = (struct rte_ipv4_hdr *)buf;
app/test-pmd/cmdline_flow.c +2 -1
-             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;
doc/guides/testpmd_app_ug/testpmd_funcs.rst +0 -0
index 33857acf54..ab7e91ad6c 100644
@@ -3654,6 +3654,7 @@ This section lists supported pattern items and

their attributes, if any.

Quoted 8 lines
doc/guides/testpmd_app_ug/testpmd_funcs.rst +1 -0
 - ``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.
 
#5 lore raw
Quoted 3 lines · Gregory Etelson

Hello,

The patch was reviewed and approved by @Slava Ovsiienko

I don't see it in patchwork and mailing list.

Slava, could you send formal Acked-by or Reviewed-by, please.

Thanks,
Andrew.

Reviewed-by on v2 1/1
#6 lore raw
In reply to Gregory Etelson
Quoted 10 lines

-----Original Message-----
From: Gregory Etelson <[email protected]>
Sent: Tuesday, July 13, 2021 10:29
To: [email protected]; [email protected]
Cc: Gregory Etelson <[email protected]>; Slava Ovsiienko <[email protected]>; Ori Kam <[email protected]>; Xiaoyun Li <[email protected]>
Subject: [PATCH v2] app/testpmd: add flow item to match on IPv4 version_ihl field

Quoted 4 lines

The new flow item allows PMD to offload IPv4 IHL field for matching, if hardware supports that operation.

#7 lore raw
Quoted 10 lines · Slava Ovsiienko
Quoted 10 lines

-----Original Message-----
From: Gregory Etelson <[email protected]>
Sent: Tuesday, July 13, 2021 10:29
To: [email protected]; [email protected]
Cc: Gregory Etelson <[email protected]>; Slava Ovsiienko <[email protected]>; Ori Kam <[email protected]>; Xiaoyun Li <[email protected]>
Subject: [PATCH v2] app/testpmd: add flow item to match on IPv4 version_ihl field

Quoted 6 lines
Quoted 4 lines

The new flow item allows PMD to offload IPv4 IHL field for matching, if hardware supports that operation.

Applied, thanks