app/testpmd: fix lack of flow action configuration
[dpdk.git] / app / test-pmd / cmdline_flow.c
index a5cf84f..a0e06db 100644 (file)
@@ -1,6 +1,6 @@
 /* SPDX-License-Identifier: BSD-3-Clause
  * Copyright 2016 6WIND S.A.
- * Copyright 2016 Mellanox.
+ * Copyright 2016 Mellanox Technologies, Ltd
  */
 
 #include <stddef.h>
@@ -1909,6 +1909,7 @@ parse_vc(struct context *ctx, const struct token *token,
                        return -1;
                *action = (struct rte_flow_action){
                        .type = priv->type,
+                       .conf = data_size ? data : NULL,
                };
                ++out->args.vc.actions_n;
                ctx->object = action;
@@ -1989,7 +1990,6 @@ parse_vc_conf(struct context *ctx, const struct token *token,
              void *buf, unsigned int size)
 {
        struct buffer *out = buf;
-       struct rte_flow_action *action;
 
        (void)size;
        /* Token name must match. */
@@ -1998,14 +1998,9 @@ parse_vc_conf(struct context *ctx, const struct token *token,
        /* Nothing else to do if there is no buffer. */
        if (!out)
                return len;
-       if (!out->args.vc.actions_n)
-               return -1;
-       action = &out->args.vc.actions[out->args.vc.actions_n - 1];
        /* Point to selected object. */
        ctx->object = out->args.vc.data;
        ctx->objmask = NULL;
-       /* Update configuration pointer. */
-       action->conf = ctx->object;
        return len;
 }
 
@@ -2663,17 +2658,15 @@ static int
 comp_vc_action_rss_queue(struct context *ctx, const struct token *token,
                         unsigned int ent, char *buf, unsigned int size)
 {
-       static const char *const str[] = { "", "end", NULL };
-       unsigned int i;
-
        (void)ctx;
        (void)token;
-       for (i = 0; str[i] != NULL; ++i)
-               if (buf && i == ent)
-                       return snprintf(buf, size, "%s", str[i]);
-       if (buf)
-               return -1;
-       return i;
+       if (!buf)
+               return nb_rxq + 1;
+       if (ent < nb_rxq)
+               return snprintf(buf, size, "%u", ent);
+       if (ent == nb_rxq)
+               return snprintf(buf, size, "end");
+       return -1;
 }
 
 /** Internal context. */