app/testpmd: use SPDX tags in 6WIND copyrighted files
[dpdk.git] / app / test-pmd / cmdline_flow.c
index a17a004..a5cf84f 100644 (file)
@@ -1,34 +1,6 @@
-/*-
- *   BSD LICENSE
- *
- *   Copyright 2016 6WIND S.A.
- *   Copyright 2016 Mellanox.
- *
- *   Redistribution and use in source and binary forms, with or without
- *   modification, are permitted provided that the following conditions
- *   are met:
- *
- *     * Redistributions of source code must retain the above copyright
- *       notice, this list of conditions and the following disclaimer.
- *     * Redistributions in binary form must reproduce the above copyright
- *       notice, this list of conditions and the following disclaimer in
- *       the documentation and/or other materials provided with the
- *       distribution.
- *     * Neither the name of 6WIND S.A. nor the names of its
- *       contributors may be used to endorse or promote products derived
- *       from this software without specific prior written permission.
- *
- *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright 2016 6WIND S.A.
+ * Copyright 2016 Mellanox.
  */
 
 #include <stddef.h>
@@ -171,6 +143,13 @@ enum index {
        ITEM_GRE_PROTO,
        ITEM_FUZZY,
        ITEM_FUZZY_THRESH,
+       ITEM_GTP,
+       ITEM_GTP_TEID,
+       ITEM_GTPC,
+       ITEM_GTPU,
+       ITEM_GENEVE,
+       ITEM_GENEVE_VNI,
+       ITEM_GENEVE_PROTO,
 
        /* Validate/create actions. */
        ACTIONS,
@@ -194,6 +173,8 @@ enum index {
        ACTION_VF,
        ACTION_VF_ORIGINAL,
        ACTION_VF_ID,
+       ACTION_METER,
+       ACTION_METER_ID,
 };
 
 /** Size of pattern[] field in struct rte_flow_item_raw. */
@@ -226,7 +207,7 @@ struct context {
        int args_num; /**< Number of entries in args[]. */
        uint32_t eol:1; /**< EOL has been detected. */
        uint32_t last:1; /**< No more arguments. */
-       uint16_t port; /**< Current port ID (for completions). */
+       portid_t port; /**< Current port ID (for completions). */
        uint32_t objdata; /**< Object-specific data. */
        void *object; /**< Address of current object for relative offsets. */
        void *objmask; /**< Object a full mask must be written to. */
@@ -346,7 +327,7 @@ struct token {
 /** Parser output buffer layout expected by cmd_flow_parsed(). */
 struct buffer {
        enum index command; /**< Flow command. */
-       uint16_t port; /**< Affected port ID. */
+       portid_t port; /**< Affected port ID. */
        union {
                struct {
                        struct rte_flow_attr attr;
@@ -451,6 +432,10 @@ static const enum index next_item[] = {
        ITEM_MPLS,
        ITEM_GRE,
        ITEM_FUZZY,
+       ITEM_GTP,
+       ITEM_GTPC,
+       ITEM_GTPU,
+       ITEM_GENEVE,
        ZERO,
 };
 
@@ -588,6 +573,19 @@ static const enum index item_gre[] = {
        ZERO,
 };
 
+static const enum index item_gtp[] = {
+       ITEM_GTP_TEID,
+       ITEM_NEXT,
+       ZERO,
+};
+
+static const enum index item_geneve[] = {
+       ITEM_GENEVE_VNI,
+       ITEM_GENEVE_PROTO,
+       ITEM_NEXT,
+       ZERO,
+};
+
 static const enum index next_action[] = {
        ACTION_END,
        ACTION_VOID,
@@ -601,6 +599,7 @@ static const enum index next_action[] = {
        ACTION_RSS,
        ACTION_PF,
        ACTION_VF,
+       ACTION_METER,
        ZERO,
 };
 
@@ -635,6 +634,12 @@ static const enum index action_vf[] = {
        ZERO,
 };
 
+static const enum index action_meter[] = {
+       ACTION_METER_ID,
+       ACTION_NEXT,
+       ZERO,
+};
+
 static int parse_init(struct context *, const struct token *,
                      const char *, unsigned int,
                      void *, unsigned int);
@@ -1421,6 +1426,53 @@ static const struct token token_list[] = {
                .args = ARGS(ARGS_ENTRY(struct rte_flow_item_fuzzy,
                                        thresh)),
        },
+       [ITEM_GTP] = {
+               .name = "gtp",
+               .help = "match GTP header",
+               .priv = PRIV_ITEM(GTP, sizeof(struct rte_flow_item_gtp)),
+               .next = NEXT(item_gtp),
+               .call = parse_vc,
+       },
+       [ITEM_GTP_TEID] = {
+               .name = "teid",
+               .help = "tunnel endpoint identifier",
+               .next = NEXT(item_gtp, NEXT_ENTRY(UNSIGNED), item_param),
+               .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_gtp, teid)),
+       },
+       [ITEM_GTPC] = {
+               .name = "gtpc",
+               .help = "match GTP header",
+               .priv = PRIV_ITEM(GTPC, sizeof(struct rte_flow_item_gtp)),
+               .next = NEXT(item_gtp),
+               .call = parse_vc,
+       },
+       [ITEM_GTPU] = {
+               .name = "gtpu",
+               .help = "match GTP header",
+               .priv = PRIV_ITEM(GTPU, sizeof(struct rte_flow_item_gtp)),
+               .next = NEXT(item_gtp),
+               .call = parse_vc,
+       },
+       [ITEM_GENEVE] = {
+               .name = "geneve",
+               .help = "match GENEVE header",
+               .priv = PRIV_ITEM(GENEVE, sizeof(struct rte_flow_item_geneve)),
+               .next = NEXT(item_geneve),
+               .call = parse_vc,
+       },
+       [ITEM_GENEVE_VNI] = {
+               .name = "vni",
+               .help = "virtual network identifier",
+               .next = NEXT(item_geneve, NEXT_ENTRY(UNSIGNED), item_param),
+               .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_geneve, vni)),
+       },
+       [ITEM_GENEVE_PROTO] = {
+               .name = "protocol",
+               .help = "GENEVE protocol type",
+               .next = NEXT(item_geneve, NEXT_ENTRY(UNSIGNED), item_param),
+               .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_geneve,
+                                            protocol)),
+       },
 
        /* Validate/create actions. */
        [ACTIONS] = {
@@ -1566,6 +1618,21 @@ static const struct token token_list[] = {
                .args = ARGS(ARGS_ENTRY(struct rte_flow_action_vf, id)),
                .call = parse_vc_conf,
        },
+       [ACTION_METER] = {
+               .name = "meter",
+               .help = "meter the directed packets at given id",
+               .priv = PRIV_ACTION(METER,
+                                   sizeof(struct rte_flow_action_meter)),
+               .next = NEXT(action_meter),
+               .call = parse_vc,
+       },
+       [ACTION_METER_ID] = {
+               .name = "mtr_id",
+               .help = "meter id to use",
+               .next = NEXT(action_meter, NEXT_ENTRY(UNSIGNED)),
+               .args = ARGS(ARGS_ENTRY(struct rte_flow_action_meter, mtr_id)),
+               .call = parse_vc_conf,
+       },
 };
 
 /** Remove and return last entry from argument stack. */
@@ -2578,7 +2645,7 @@ comp_rule_id(struct context *ctx, const struct token *token,
 
        (void)token;
        if (port_id_is_invalid(ctx->port, DISABLED_WARN) ||
-           ctx->port == (uint16_t)RTE_PORT_ALL)
+           ctx->port == (portid_t)RTE_PORT_ALL)
                return -1;
        port = &ports[ctx->port];
        for (pf = port->flow_list; pf != NULL; pf = pf->next) {