ethdev: add HIGIG2 key field to flow API
[dpdk.git] / app / test-pmd / cmdline_flow.c
index 8409e41..970bdef 100644 (file)
@@ -18,6 +18,7 @@
 #include <rte_ethdev.h>
 #include <rte_byteorder.h>
 #include <cmdline_parse.h>
+#include <cmdline_parse_etheraddr.h>
 #include <rte_flow.h>
 
 #include "testpmd.h"
@@ -195,6 +196,16 @@ enum index {
        ITEM_META_DATA,
        ITEM_GRE_KEY,
        ITEM_GRE_KEY_VALUE,
+       ITEM_GTP_PSC,
+       ITEM_GTP_PSC_QFI,
+       ITEM_GTP_PSC_PDU_T,
+       ITEM_PPPOES,
+       ITEM_PPPOED,
+       ITEM_PPPOE_SEID,
+       ITEM_PPPOE_PROTO_ID,
+       ITEM_HIGIG2,
+       ITEM_HIGIG2_CLASSIFICATION,
+       ITEM_HIGIG2_VID,
 
        /* Validate/create actions. */
        ACTIONS,
@@ -219,6 +230,7 @@ enum index {
        ACTION_RSS_FUNC_DEFAULT,
        ACTION_RSS_FUNC_TOEPLITZ,
        ACTION_RSS_FUNC_SIMPLE_XOR,
+       ACTION_RSS_FUNC_SYMMETRIC_TOEPLITZ,
        ACTION_RSS_TYPES,
        ACTION_RSS_TYPE,
        ACTION_RSS_KEY,
@@ -662,6 +674,11 @@ static const enum index next_item[] = {
        ITEM_ICMP6_ND_OPT_TLA_ETH,
        ITEM_META,
        ITEM_GRE_KEY,
+       ITEM_GTP_PSC,
+       ITEM_PPPOES,
+       ITEM_PPPOED,
+       ITEM_PPPOE_PROTO_ID,
+       ITEM_HIGIG2,
        END_SET,
        ZERO,
 };
@@ -901,6 +918,38 @@ static const enum index item_meta[] = {
        ZERO,
 };
 
+static const enum index item_gtp_psc[] = {
+       ITEM_GTP_PSC_QFI,
+       ITEM_GTP_PSC_PDU_T,
+       ITEM_NEXT,
+       ZERO,
+};
+
+static const enum index item_pppoed[] = {
+       ITEM_PPPOE_SEID,
+       ITEM_NEXT,
+       ZERO,
+};
+
+static const enum index item_pppoes[] = {
+       ITEM_PPPOE_SEID,
+       ITEM_NEXT,
+       ZERO,
+};
+
+static const enum index item_pppoe_proto_id[] = {
+       ITEM_PPPOE_PROTO_ID,
+       ITEM_NEXT,
+       ZERO,
+};
+
+static const enum index item_higig2[] = {
+       ITEM_HIGIG2_CLASSIFICATION,
+       ITEM_HIGIG2_VID,
+       ITEM_NEXT,
+       ZERO,
+};
+
 static const enum index next_action[] = {
        ACTION_END,
        ACTION_VOID,
@@ -2330,7 +2379,79 @@ static const struct token token_list[] = {
                .next = NEXT(item_gre_key, NEXT_ENTRY(UNSIGNED), item_param),
                .args = ARGS(ARG_ENTRY_HTON(rte_be32_t)),
        },
-
+       [ITEM_GTP_PSC] = {
+               .name = "gtp_psc",
+               .help = "match GTP extension header with type 0x85",
+               .priv = PRIV_ITEM(GTP_PSC,
+                               sizeof(struct rte_flow_item_gtp_psc)),
+               .next = NEXT(item_gtp_psc),
+               .call = parse_vc,
+       },
+       [ITEM_GTP_PSC_QFI] = {
+               .name = "qfi",
+               .help = "QoS flow identifier",
+               .next = NEXT(item_gtp_psc, NEXT_ENTRY(UNSIGNED), item_param),
+               .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_gtp_psc,
+                                       qfi)),
+       },
+       [ITEM_GTP_PSC_PDU_T] = {
+               .name = "pdu_t",
+               .help = "PDU type",
+               .next = NEXT(item_gtp_psc, NEXT_ENTRY(UNSIGNED), item_param),
+               .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_gtp_psc,
+                                       pdu_type)),
+       },
+       [ITEM_PPPOES] = {
+               .name = "pppoes",
+               .help = "match PPPoE session header",
+               .priv = PRIV_ITEM(PPPOES, sizeof(struct rte_flow_item_pppoe)),
+               .next = NEXT(item_pppoes),
+               .call = parse_vc,
+       },
+       [ITEM_PPPOED] = {
+               .name = "pppoed",
+               .help = "match PPPoE discovery header",
+               .priv = PRIV_ITEM(PPPOED, sizeof(struct rte_flow_item_pppoe)),
+               .next = NEXT(item_pppoed),
+               .call = parse_vc,
+       },
+       [ITEM_PPPOE_SEID] = {
+               .name = "seid",
+               .help = "session identifier",
+               .next = NEXT(item_pppoes, NEXT_ENTRY(UNSIGNED), item_param),
+               .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_pppoe,
+                                       session_id)),
+       },
+       [ITEM_PPPOE_PROTO_ID] = {
+               .name = "proto_id",
+               .help = "match PPPoE session protocol identifier",
+               .priv = PRIV_ITEM(PPPOE_PROTO_ID,
+                               sizeof(struct rte_flow_item_pppoe_proto_id)),
+               .next = NEXT(item_pppoe_proto_id),
+               .call = parse_vc,
+       },
+       [ITEM_HIGIG2] = {
+               .name = "higig2",
+               .help = "matches higig2 header",
+               .priv = PRIV_ITEM(HIGIG2,
+                               sizeof(struct rte_flow_item_higig2_hdr)),
+               .next = NEXT(item_higig2),
+               .call = parse_vc,
+       },
+       [ITEM_HIGIG2_CLASSIFICATION] = {
+               .name = "classification",
+               .help = "matches classification of higig2 header",
+               .next = NEXT(item_higig2, NEXT_ENTRY(UNSIGNED), item_param),
+               .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_higig2_hdr,
+                                       hdr.ppt1.classification)),
+       },
+       [ITEM_HIGIG2_VID] = {
+               .name = "vid",
+               .help = "matches vid of higig2 header",
+               .next = NEXT(item_higig2, NEXT_ENTRY(UNSIGNED), item_param),
+               .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_higig2_hdr,
+                                       hdr.ppt1.vid)),
+       },
        /* Validate/create actions. */
        [ACTIONS] = {
                .name = "actions",
@@ -2456,7 +2577,8 @@ static const struct token token_list[] = {
                .next = NEXT(action_rss,
                             NEXT_ENTRY(ACTION_RSS_FUNC_DEFAULT,
                                        ACTION_RSS_FUNC_TOEPLITZ,
-                                       ACTION_RSS_FUNC_SIMPLE_XOR)),
+                                       ACTION_RSS_FUNC_SIMPLE_XOR,
+                                       ACTION_RSS_FUNC_SYMMETRIC_TOEPLITZ)),
        },
        [ACTION_RSS_FUNC_DEFAULT] = {
                .name = "default",
@@ -2473,6 +2595,11 @@ static const struct token token_list[] = {
                .help = "simple XOR hash function",
                .call = parse_vc_action_rss_func,
        },
+       [ACTION_RSS_FUNC_SYMMETRIC_TOEPLITZ] = {
+               .name = "symmetric_toeplitz",
+               .help = "Symmetric Toeplitz hash function",
+               .call = parse_vc_action_rss_func,
+       },
        [ACTION_RSS_LEVEL] = {
                .name = "level",
                .help = "encapsulation level for \"types\"",
@@ -3548,8 +3675,12 @@ parse_vc_action_rss(struct context *ctx, const struct token *token,
        if (!port_id_is_invalid(ctx->port, DISABLED_WARN) &&
            ctx->port != (portid_t)RTE_PORT_ALL) {
                struct rte_eth_dev_info info;
+               int ret2;
+
+               ret2 = rte_eth_dev_info_get(ctx->port, &info);
+               if (ret2 != 0)
+                       return ret2;
 
-               rte_eth_dev_info_get(ctx->port, &info);
                action_rss_data->conf.key_len =
                        RTE_MIN(sizeof(action_rss_data->key),
                                info.hash_key_size);
@@ -3587,6 +3718,9 @@ parse_vc_action_rss_func(struct context *ctx, const struct token *token,
        case ACTION_RSS_FUNC_SIMPLE_XOR:
                func = RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
                break;
+       case ACTION_RSS_FUNC_SYMMETRIC_TOEPLITZ:
+               func = RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ;
+               break;
        default:
                return -1;
        }
@@ -4978,8 +5112,8 @@ parse_mac_addr(struct context *ctx, const struct token *token,
        /* Only network endian is supported. */
        if (!arg->hton)
                goto error;
-       ret = rte_ether_unformat_addr(str, &tmp);
-       if (ret < 0)
+       ret = cmdline_parse_etheraddr(NULL, str, &tmp, size);
+       if (ret < 0 || (unsigned int)ret != len)
                goto error;
        if (!ctx->object)
                return len;
@@ -5683,6 +5817,7 @@ static const void *
 flow_item_default_mask(const struct rte_flow_item *item)
 {
        const void *mask = NULL;
+       static rte_be32_t gre_key_default_mask = RTE_BE32(UINT32_MAX);
 
        switch (item->type) {
        case RTE_FLOW_ITEM_TYPE_ANY:
@@ -5739,6 +5874,9 @@ flow_item_default_mask(const struct rte_flow_item *item)
        case RTE_FLOW_ITEM_TYPE_GRE:
                mask = &rte_flow_item_gre_mask;
                break;
+       case RTE_FLOW_ITEM_TYPE_GRE_KEY:
+               mask = &gre_key_default_mask;
+               break;
        case RTE_FLOW_ITEM_TYPE_META:
                mask = &rte_flow_item_meta_mask;
                break;
@@ -5751,6 +5889,11 @@ flow_item_default_mask(const struct rte_flow_item *item)
        case RTE_FLOW_ITEM_TYPE_ESP:
                mask = &rte_flow_item_esp_mask;
                break;
+       case RTE_FLOW_ITEM_TYPE_GTP_PSC:
+               mask = &rte_flow_item_gtp_psc_mask;
+               break;
+       case RTE_FLOW_ITEM_TYPE_PPPOE_PROTO_ID:
+               mask = &rte_flow_item_pppoe_proto_id_mask;
        default:
                break;
        }
@@ -5824,6 +5967,9 @@ cmd_set_raw_parsed(const struct buffer *in)
                        size = sizeof(struct rte_flow_item_gre);
                        proto = 0x2F;
                        break;
+               case RTE_FLOW_ITEM_TYPE_GRE_KEY:
+                       size = sizeof(rte_be32_t);
+                       break;
                case RTE_FLOW_ITEM_TYPE_MPLS:
                        size = sizeof(struct rte_flow_item_mpls);
                        break;