Start support matching on icmpv4 and icmpv6.

Usage:
--icmpv4: add icmp item to match on.
--icmpv6: add icmpv6 item to match on.

Signed-off-by: Wisam Jaddo <wis...@mellanox.com>
Acked-by: Alexander Kozyrev <akozy...@nvidia.com>
---
 app/test-flow-perf/items_gen.c         | 41 +++++++++++++++++++++++++-
 app/test-flow-perf/main.c              | 16 ++++++++++
 doc/guides/rel_notes/release_20_08.rst |  2 ++
 doc/guides/tools/flow-perf.rst         |  6 ++++
 4 files changed, 64 insertions(+), 1 deletion(-)

diff --git a/app/test-flow-perf/items_gen.c b/app/test-flow-perf/items_gen.c
index 8277ac70da..2b1ab41467 100644
--- a/app/test-flow-perf/items_gen.c
+++ b/app/test-flow-perf/items_gen.c
@@ -310,6 +310,38 @@ add_meta_tag(struct rte_flow_item *items,
        items[items_counter].mask = &tag_mask;
 }
 
+static void
+add_icmpv4(struct rte_flow_item *items,
+       uint8_t items_counter,
+       __rte_unused struct additional_para para)
+{
+       static struct rte_flow_item_icmp icmpv4_spec;
+       static struct rte_flow_item_icmp icmpv4_mask;
+
+       memset(&icmpv4_spec, 0, sizeof(struct rte_flow_item_icmp));
+       memset(&icmpv4_mask, 0, sizeof(struct rte_flow_item_icmp));
+
+       items[items_counter].type = RTE_FLOW_ITEM_TYPE_ICMP;
+       items[items_counter].spec = &icmpv4_spec;
+       items[items_counter].mask = &icmpv4_mask;
+}
+
+static void
+add_icmpv6(struct rte_flow_item *items,
+       uint8_t items_counter,
+       __rte_unused struct additional_para para)
+{
+       static struct rte_flow_item_icmp6 icmpv6_spec;
+       static struct rte_flow_item_icmp6 icmpv6_mask;
+
+       memset(&icmpv6_spec, 0, sizeof(struct rte_flow_item_icmp6));
+       memset(&icmpv6_mask, 0, sizeof(struct rte_flow_item_icmp6));
+
+       items[items_counter].type = RTE_FLOW_ITEM_TYPE_ICMP6;
+       items[items_counter].spec = &icmpv6_spec;
+       items[items_counter].mask = &icmpv6_mask;
+}
+
 void
 fill_items(struct rte_flow_item *items,
        uint64_t *flow_items, uint32_t outer_ip_src)
@@ -381,7 +413,14 @@ fill_items(struct rte_flow_item *items,
                        .mask = RTE_FLOW_ITEM_TYPE_GTP,
                        .funct = add_gtp,
                },
-
+               {
+                       .mask = RTE_FLOW_ITEM_TYPE_ICMP,
+                       .funct = add_icmpv4,
+               },
+               {
+                       .mask = RTE_FLOW_ITEM_TYPE_ICMP6,
+                       .funct = add_icmpv6,
+               },
        };
 
        for (j = 0; j < MAX_ITEMS_NUM; j++) {
diff --git a/app/test-flow-perf/main.c b/app/test-flow-perf/main.c
index 18199c6e2e..c420da6a57 100644
--- a/app/test-flow-perf/main.c
+++ b/app/test-flow-perf/main.c
@@ -130,6 +130,8 @@ usage(char *progname)
        printf("  --gtp: add gtp layer in flow items\n");
        printf("  --meta: add meta layer in flow items\n");
        printf("  --tag: add tag layer in flow items\n");
+       printf("  --icmpv4: add icmpv4 layer in flow items\n");
+       printf("  --icmpv6: add icmpv6 layer in flow items\n");
 
        printf("To set flow actions:\n");
        printf("  --port-id: add port-id action in flow actions\n");
@@ -284,6 +286,18 @@ args_parse(int argc, char **argv)
                        .map = &flow_items[0],
                        .map_idx = &items_idx
                },
+               {
+                       .str = "icmpv4",
+                       .mask = FLOW_ITEM_MASK(RTE_FLOW_ITEM_TYPE_ICMP),
+                       .map = &flow_items[0],
+                       .map_idx = &items_idx
+               },
+               {
+                       .str = "icmpv6",
+                       .mask = FLOW_ITEM_MASK(RTE_FLOW_ITEM_TYPE_ICMP6),
+                       .map = &flow_items[0],
+                       .map_idx = &items_idx
+               },
                {
                        .str = "ingress",
                        .mask = INGRESS,
@@ -538,6 +552,8 @@ args_parse(int argc, char **argv)
                { "gtp",                        0, 0, 0 },
                { "meta",                       0, 0, 0 },
                { "tag",                        0, 0, 0 },
+               { "icmpv4",                     0, 0, 0 },
+               { "icmpv6",                     0, 0, 0 },
                /* Actions */
                { "port-id",                    0, 0, 0 },
                { "rss",                        0, 0, 0 },
diff --git a/doc/guides/rel_notes/release_20_08.rst 
b/doc/guides/rel_notes/release_20_08.rst
index b21f0bfb03..03eb4948e0 100644
--- a/doc/guides/rel_notes/release_20_08.rst
+++ b/doc/guides/rel_notes/release_20_08.rst
@@ -287,6 +287,8 @@ New Features
   * Add new option to set portmask for insertion/deletion:
     ``--portmask=N`` Where N represent the hexadecimal
     bitmask of ports used.
+  * Start supporting icmp and icmp6 matching items.
+
 
 Removed Items
 -------------
diff --git a/doc/guides/tools/flow-perf.rst b/doc/guides/tools/flow-perf.rst
index bbefc978c6..7e5dc0c54b 100644
--- a/doc/guides/tools/flow-perf.rst
+++ b/doc/guides/tools/flow-perf.rst
@@ -175,6 +175,12 @@ Items:
        under ``TAG_INDEX`` with full mask, default value = 0.
        Other fields are open mask.
 
+*      ``--icmpv4``
+       Add icmpv4 item to all flows items, This item have open mask.
+
+*      ``--icmpv6``
+       Add icmpv6 item to all flows items, This item have open mask.
+
 
 Actions:
 
-- 
2.17.1

Reply via email to