examples/ip_pipeline: support packet tag action
authorCristian Dumitrescu <cristian.dumitrescu@intel.com>
Tue, 9 Oct 2018 13:17:01 +0000 (14:17 +0100)
committerCristian Dumitrescu <cristian.dumitrescu@intel.com>
Fri, 12 Oct 2018 17:33:29 +0000 (19:33 +0200)
Add support for the packet tag table action.

Signed-off-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
examples/ip_pipeline/action.c
examples/ip_pipeline/cli.c
examples/ip_pipeline/pipeline.h
examples/ip_pipeline/thread.c

index a0f97be..3f825a0 100644 (file)
@@ -344,6 +344,17 @@ table_action_profile_create(const char *name,
                }
        }
 
+       if (params->action_mask & (1LLU << RTE_TABLE_ACTION_TAG)) {
+               status = rte_table_action_profile_action_register(ap,
+                       RTE_TABLE_ACTION_TAG,
+                       NULL);
+
+               if (status) {
+                       rte_table_action_profile_free(ap);
+                       return NULL;
+               }
+       }
+
        status = rte_table_action_profile_freeze(ap);
        if (status) {
                rte_table_action_profile_free(ap);
index 3ff7caa..a85d04c 100644 (file)
@@ -1032,7 +1032,8 @@ static const char cmd_table_action_profile_help[] =
 "   [time]\n"
 "   [sym_crypto dev <CRYPTODEV_NAME> offset <op_offset> "
 "       mempool_create <mempool_name>\n"
-"       mempool_init <mempool_name>]\n";
+"       mempool_init <mempool_name>]\n"
+"   [tag]\n";
 
 static void
 cmd_table_action_profile(char **tokens,
@@ -1451,6 +1452,11 @@ cmd_table_action_profile(char **tokens,
                t0 += 9;
        } /* sym_crypto */
 
+       if ((t0 < n_tokens) && (strcmp(tokens[t0], "tag") == 0)) {
+               p.action_mask |= 1LLU << RTE_TABLE_ACTION_TAG;
+               t0 += 1;
+       } /* tag */
+
        if (t0 < n_tokens) {
                snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
                return;
@@ -3107,6 +3113,7 @@ parse_match(char **tokens,
  *          aead_algo <algo> aead_key <key> aead_iv <iv> aead_aad <aad>
  *          digest_size <size>
  *       data_offset <data_offset>]
+ *    [tag <tag>]
  *
  * where:
  *    <pa> ::= g | y | r | drop
@@ -4067,6 +4074,22 @@ parse_table_action_sym_crypto(char **tokens,
        return used_n_tokens + 5;
 }
 
+static uint32_t
+parse_table_action_tag(char **tokens,
+       uint32_t n_tokens,
+       struct table_rule_action *a)
+{
+       if ((n_tokens < 2) ||
+               strcmp(tokens[0], "tag"))
+               return 0;
+
+       if (parser_read_uint32(&a->tag.tag, tokens[1]))
+               return 0;
+
+       a->action_mask |= 1 << RTE_TABLE_ACTION_TAG;
+       return 2;
+}
+
 static uint32_t
 parse_table_action(char **tokens,
        uint32_t n_tokens,
@@ -4218,6 +4241,19 @@ parse_table_action(char **tokens,
                if (n == 0) {
                        snprintf(out, out_size, MSG_ARG_INVALID,
                                "action sym_crypto");
+               }
+
+               tokens += n;
+               n_tokens -= n;
+       }
+
+       if (n_tokens && (strcmp(tokens[0], "tag") == 0)) {
+               uint32_t n;
+
+               n = parse_table_action_tag(tokens, n_tokens, a);
+               if (n == 0) {
+                       snprintf(out, out_size, MSG_ARG_INVALID,
+                               "action tag");
                        return 0;
                }
 
index b6b9dc0..73485f6 100644 (file)
@@ -282,6 +282,7 @@ struct table_rule_action {
        struct rte_table_action_stats_params stats;
        struct rte_table_action_time_params time;
        struct rte_table_action_sym_crypto_params sym_crypto;
+       struct rte_table_action_tag_params tag;
 };
 
 int
index 3ec44c9..41891f4 100644 (file)
@@ -2494,6 +2494,16 @@ action_convert(struct rte_table_action *a,
                        return status;
        }
 
+       if (action->action_mask & (1LLU << RTE_TABLE_ACTION_TAG)) {
+               status = rte_table_action_apply(a,
+                       data,
+                       RTE_TABLE_ACTION_TAG,
+                       &action->tag);
+
+               if (status)
+                       return status;
+       }
+
        return 0;
 }