app/testpmd: add flow queue push operation
authorAlexander Kozyrev <akozyrev@nvidia.com>
Wed, 23 Feb 2022 03:02:38 +0000 (05:02 +0200)
committerFerruh Yigit <ferruh.yigit@intel.com>
Thu, 24 Feb 2022 13:04:48 +0000 (14:04 +0100)
Add testpmd support for the rte_flow_push API.
Provide the command line interface for pushing operations.
Usage example: flow queue 0 push 0

Signed-off-by: Alexander Kozyrev <akozyrev@nvidia.com>
Acked-by: Ori Kam <orika@nvidia.com>
app/test-pmd/cmdline_flow.c
app/test-pmd/config.c
app/test-pmd/testpmd.h
doc/guides/testpmd_app_ug/testpmd_funcs.rst

index d359127..af36975 100644 (file)
@@ -94,6 +94,7 @@ enum index {
        TUNNEL,
        FLEX,
        QUEUE,
+       PUSH,
 
        /* Flex arguments */
        FLEX_ITEM_INIT,
@@ -138,6 +139,9 @@ enum index {
        QUEUE_DESTROY_ID,
        QUEUE_DESTROY_POSTPONE,
 
+       /* Push arguments. */
+       PUSH_QUEUE,
+
        /* Table arguments. */
        TABLE_CREATE,
        TABLE_DESTROY,
@@ -2252,6 +2256,9 @@ static int parse_qo(struct context *, const struct token *,
 static int parse_qo_destroy(struct context *, const struct token *,
                            const char *, unsigned int,
                            void *, unsigned int);
+static int parse_push(struct context *, const struct token *,
+                     const char *, unsigned int,
+                     void *, unsigned int);
 static int parse_tunnel(struct context *, const struct token *,
                        const char *, unsigned int,
                        void *, unsigned int);
@@ -2530,7 +2537,8 @@ static const struct token token_list[] = {
                              ISOLATE,
                              TUNNEL,
                              FLEX,
-                             QUEUE)),
+                             QUEUE,
+                             PUSH)),
                .call = parse_init,
        },
        /* Top-level command. */
@@ -2911,6 +2919,21 @@ static const struct token token_list[] = {
                .call = parse_qo_destroy,
        },
        /* Top-level command. */
+       [PUSH] = {
+               .name = "push",
+               .help = "push enqueued operations",
+               .next = NEXT(NEXT_ENTRY(PUSH_QUEUE), NEXT_ENTRY(COMMON_PORT_ID)),
+               .args = ARGS(ARGS_ENTRY(struct buffer, port)),
+               .call = parse_push,
+       },
+       /* Sub-level commands. */
+       [PUSH_QUEUE] = {
+               .name = "queue",
+               .help = "specify queue id",
+               .next = NEXT(NEXT_ENTRY(END), NEXT_ENTRY(COMMON_QUEUE_ID)),
+               .args = ARGS(ARGS_ENTRY(struct buffer, queue)),
+       },
+       /* Top-level command. */
        [INDIRECT_ACTION] = {
                .name = "indirect_action",
                .type = "{command} {port_id} [{arg} [...]]",
@@ -8735,6 +8758,34 @@ parse_qo_destroy(struct context *ctx, const struct token *token,
        }
 }
 
+/** Parse tokens for push queue command. */
+static int
+parse_push(struct context *ctx, const struct token *token,
+          const char *str, unsigned int len,
+          void *buf, unsigned int size)
+{
+       struct buffer *out = buf;
+
+       /* Token name must match. */
+       if (parse_default(ctx, token, str, len, NULL, 0) < 0)
+               return -1;
+       /* Nothing else to do if there is no buffer. */
+       if (!out)
+               return len;
+       if (!out->command) {
+               if (ctx->curr != PUSH)
+                       return -1;
+               if (sizeof(*out) > size)
+                       return -1;
+               out->command = ctx->curr;
+               ctx->objdata = 0;
+               ctx->object = out;
+               ctx->objmask = NULL;
+               out->args.vc.data = (uint8_t *)out + size;
+       }
+       return len;
+}
+
 static int
 parse_flex(struct context *ctx, const struct token *token,
             const char *str, unsigned int len,
@@ -10120,6 +10171,9 @@ cmd_flow_parsed(const struct buffer *in)
                                        in->args.destroy.rule_n,
                                        in->args.destroy.rule);
                break;
+       case PUSH:
+               port_queue_flow_push(in->port, in->queue);
+               break;
        case INDIRECT_ACTION_CREATE:
                port_action_handle_create(
                                in->port, in->args.vc.attr.group,
index d7ab57b..9ffb7d8 100644 (file)
@@ -2626,6 +2626,34 @@ port_queue_flow_destroy(portid_t port_id, queueid_t queue_id,
        return ret;
 }
 
+/** Push all the queue operations in the queue to the NIC. */
+int
+port_queue_flow_push(portid_t port_id, queueid_t queue_id)
+{
+       struct rte_port *port;
+       struct rte_flow_error error;
+       int ret = 0;
+
+       if (port_id_is_invalid(port_id, ENABLED_WARN) ||
+           port_id == (portid_t)RTE_PORT_ALL)
+               return -EINVAL;
+       port = &ports[port_id];
+
+       if (queue_id >= port->queue_nb) {
+               printf("Queue #%u is invalid\n", queue_id);
+               return -EINVAL;
+       }
+
+       memset(&error, 0x55, sizeof(error));
+       ret = rte_flow_push(port_id, queue_id, &error);
+       if (ret < 0) {
+               printf("Failed to push operations in the queue\n");
+               return -EINVAL;
+       }
+       printf("Queue #%u operations pushed\n", queue_id);
+       return ret;
+}
+
 /** Create flow rule. */
 int
 port_flow_create(portid_t port_id,
index 62e874e..24a43fd 100644 (file)
@@ -940,6 +940,7 @@ int port_queue_flow_create(portid_t port_id, queueid_t queue_id,
                           const struct rte_flow_action *actions);
 int port_queue_flow_destroy(portid_t port_id, queueid_t queue_id,
                            bool postpone, uint32_t n, const uint32_t *rule);
+int port_queue_flow_push(portid_t port_id, queueid_t queue_id);
 int port_flow_validate(portid_t port_id,
                       const struct rte_flow_attr *attr,
                       const struct rte_flow_item *pattern,
index 194b350..4f1f908 100644 (file)
@@ -3398,6 +3398,10 @@ following sections.
    flow queue {port_id} destroy {queue_id}
        [postpone {boolean}] rule {rule_id} [...]
 
+- Push enqueued operations::
+
+   flow push {port_id} queue {queue_id}
+
 - Create a flow rule::
 
    flow create {port_id}
@@ -3616,6 +3620,23 @@ The usual error message is shown when a table cannot be destroyed::
 
    Caught error type [...] ([...]): [...]
 
+Pushing enqueued operations
+~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+``flow push`` pushes all the outstanding enqueued operations
+to the underlying device immediately.
+It is bound to ``rte_flow_push()``::
+
+   flow push {port_id} queue {queue_id}
+
+If successful, it will show::
+
+   Queue #[...] operations pushed
+
+The usual error message is shown when operations cannot be pushed::
+
+   Caught error type [...] ([...]): [...]
+
 Creating a tunnel stub for offload
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~