app/testpmd: add flow matching on IPv4 version and IHL
authorGregory Etelson <getelson@nvidia.com>
Tue, 13 Jul 2021 07:29:25 +0000 (10:29 +0300)
committerAndrew Rybchenko <Andrew.Rybchenko@oktetlabs.ru>
Tue, 13 Jul 2021 11:15:14 +0000 (13:15 +0200)
The new flow item allows PMD to offload IPv4 IHL field for matching,
if hardware supports that operation.

Signed-off-by: Gregory Etelson <getelson@nvidia.com>
Reviewed-by: Viacheslav Ovsiienko <viacheslavo@nvidia.com>
app/test-pmd/cmdline_flow.c
doc/guides/testpmd_app_ug/testpmd_funcs.rst

index 8fc0e14..34e0436 100644 (file)
@@ -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;
index 33857ac..ab7e91a 100644 (file)
@@ -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.