]> git.droids-corp.org - dpdk.git/commitdiff
app/testpmd: support GRE option flow item
authorSean Zhang <xiazhang@nvidia.com>
Fri, 11 Feb 2022 01:45:29 +0000 (03:45 +0200)
committerFerruh Yigit <ferruh.yigit@intel.com>
Fri, 11 Feb 2022 15:51:59 +0000 (16:51 +0100)
Add gre_option command for matching optional fields
(checksum/key/sequence) in GRE header. The item must follow gre item,
and the item does not change the flags in gre item, the application
should set the flags in gre item correspondingly.
Application can still use gre_key item 'gre_key value is xx' for key
matching, the effect is the same with using 'gre_option key is xx'.

The examples for gre_option are as follows:

To match on checksum field with value 0x11:
testpmd> ... pattern / eth / gre c_bit is 1 / gre_option checksum is
0x11 / end ..

To match on checksum field with value 0x11 and any value of key:
testpmd> ... pattern / eth / gre c_bit is 1 k_bit is 1 / gre_option
checksum is 0x11 / end ..

To match on checksum field with value 0x11 and no key field in packet:
testpmd> ... pattern / eth / gre c_bit is 1 k_bit is 0 / gre_option
checksum is 0x11 / end ..

The invalid patterns for gre_option are as follows:

testpmd> ... pattern / eth / gre / gre_option checksum is 0x11 / end ..
(c_bit in gre item not present)
testpmd> ... pattern / eth / gre c_bit is 0 / gre_option checksum is 0x11 /
end .. (c_bit is unset for gre item, but checksum is
specified by gre_option item)

Signed-off-by: Sean Zhang <xiazhang@nvidia.com>
Acked-by: Ori Kam <orika@nvidia.com>
app/test-pmd/cmdline_flow.c
doc/guides/testpmd_app_ug/testpmd_funcs.rst

index e0c79d57a3950c66fb222bdeb750a5c540daa5ea..c0644d678c632cff0893dd9f8a87bfa62f662f75 100644 (file)
@@ -272,6 +272,10 @@ enum index {
        ITEM_META_DATA,
        ITEM_GRE_KEY,
        ITEM_GRE_KEY_VALUE,
+       ITEM_GRE_OPTION,
+       ITEM_GRE_OPTION_CHECKSUM,
+       ITEM_GRE_OPTION_KEY,
+       ITEM_GRE_OPTION_SEQUENCE,
        ITEM_GTP_PSC,
        ITEM_GTP_PSC_QFI,
        ITEM_GTP_PSC_PDU_T,
@@ -1060,6 +1064,7 @@ static const enum index next_item[] = {
        ITEM_ICMP6_ND_OPT_TLA_ETH,
        ITEM_META,
        ITEM_GRE_KEY,
+       ITEM_GRE_OPTION,
        ITEM_GTP_PSC,
        ITEM_PPPOES,
        ITEM_PPPOED,
@@ -1251,6 +1256,14 @@ static const enum index item_gre_key[] = {
        ZERO,
 };
 
+static const enum index item_gre_option[] = {
+       ITEM_GRE_OPTION_CHECKSUM,
+       ITEM_GRE_OPTION_KEY,
+       ITEM_GRE_OPTION_SEQUENCE,
+       ITEM_NEXT,
+       ZERO,
+};
+
 static const enum index item_gtp[] = {
        ITEM_GTP_FLAGS,
        ITEM_GTP_MSG_TYPE,
@@ -3562,6 +3575,38 @@ static const struct token token_list[] = {
                             item_param),
                .args = ARGS(ARG_ENTRY_HTON(rte_be32_t)),
        },
+       [ITEM_GRE_OPTION] = {
+               .name = "gre_option",
+               .help = "match GRE optional fields",
+               .priv = PRIV_ITEM(GRE_OPTION,
+                                 sizeof(struct rte_flow_item_gre_opt)),
+               .next = NEXT(item_gre_option),
+               .call = parse_vc,
+       },
+       [ITEM_GRE_OPTION_CHECKSUM] = {
+               .name = "checksum",
+               .help = "match GRE checksum",
+               .next = NEXT(item_gre_option, NEXT_ENTRY(COMMON_UNSIGNED),
+                            item_param),
+               .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_gre_opt,
+                                            checksum_rsvd.checksum)),
+       },
+       [ITEM_GRE_OPTION_KEY] = {
+               .name = "key",
+               .help = "match GRE key",
+               .next = NEXT(item_gre_option, NEXT_ENTRY(COMMON_UNSIGNED),
+                            item_param),
+               .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_gre_opt,
+                                            key.key)),
+       },
+       [ITEM_GRE_OPTION_SEQUENCE] = {
+               .name = "sequence",
+               .help = "match GRE sequence",
+               .next = NEXT(item_gre_option, NEXT_ENTRY(COMMON_UNSIGNED),
+                            item_param),
+               .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_gre_opt,
+                                            sequence.sequence)),
+       },
        [ITEM_GTP_PSC] = {
                .name = "gtp_psc",
                .help = "match GTP extension header with type 0x85",
@@ -9463,6 +9508,33 @@ cmd_set_raw_parsed(const struct buffer *in)
                                ((const struct rte_flow_item_flex *)
                                item->spec)->length : 0;
                        break;
+               case RTE_FLOW_ITEM_TYPE_GRE_OPTION:
+                       size = 0;
+                       if (item->spec) {
+                               const struct rte_flow_item_gre_opt
+                                       *opt = item->spec;
+                               if (opt->checksum_rsvd.checksum) {
+                                       *total_size +=
+                                               sizeof(opt->checksum_rsvd);
+                                       rte_memcpy(data_tail - (*total_size),
+                                                  &opt->checksum_rsvd,
+                                                  sizeof(opt->checksum_rsvd));
+                               }
+                               if (opt->key.key) {
+                                       *total_size += sizeof(opt->key.key);
+                                       rte_memcpy(data_tail - (*total_size),
+                                                  &opt->key.key,
+                                                  sizeof(opt->key.key));
+                               }
+                               if (opt->sequence.sequence) {
+                                       *total_size += sizeof(opt->sequence.sequence);
+                                       rte_memcpy(data_tail - (*total_size),
+                                                  &opt->sequence.sequence,
+                                                  sizeof(opt->sequence.sequence));
+                               }
+                       }
+                       proto = 0x2F;
+                       break;
                default:
                        fprintf(stderr, "Error - Not supported item\n");
                        goto error;
index f6884ea088945c0644c0c1b620659e09c1f4b32d..9cc248084f360208af68a838177444c4d9691d3d 100644 (file)
@@ -3738,6 +3738,12 @@ This section lists supported pattern items and their attributes, if any.
 
   - ``value {unsigned}``: key value.
 
+- ``gre_option``: match GRE optional fields(checksum/key/sequence).
+
+  - ``checksum {unsigned}``: checksum value.
+  - ``key {unsigned}``: key value.
+  - ``sequence {unsigned}``: sequence number value.
+
 - ``fuzzy``: fuzzy pattern match, expect faster than default.
 
   - ``thresh {unsigned}``: accuracy threshold.