Add testpmd support for the rte_flow_pull API.
Provide the command line interface for pulling operations results.
Usage example: flow pull 0 queue 0
Signed-off-by: Alexander Kozyrev <akozyrev@nvidia.com>
Acked-by: Ori Kam <orika@nvidia.com>
FLEX,
QUEUE,
PUSH,
+ PULL,
/* Flex arguments */
FLEX_ITEM_INIT,
/* Push arguments. */
PUSH_QUEUE,
+ /* Pull arguments. */
+ PULL_QUEUE,
+
/* Table arguments. */
TABLE_CREATE,
TABLE_DESTROY,
static int parse_push(struct context *, const struct token *,
const char *, unsigned int,
void *, unsigned int);
+static int parse_pull(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);
TUNNEL,
FLEX,
QUEUE,
- PUSH)),
+ PUSH,
+ PULL)),
.call = parse_init,
},
/* Top-level command. */
.args = ARGS(ARGS_ENTRY(struct buffer, queue)),
},
/* Top-level command. */
+ [PULL] = {
+ .name = "pull",
+ .help = "pull flow operations results",
+ .next = NEXT(NEXT_ENTRY(PULL_QUEUE), NEXT_ENTRY(COMMON_PORT_ID)),
+ .args = ARGS(ARGS_ENTRY(struct buffer, port)),
+ .call = parse_pull,
+ },
+ /* Sub-level commands. */
+ [PULL_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} [...]]",
return len;
}
+/** Parse tokens for pull command. */
+static int
+parse_pull(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 != PULL)
+ 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,
case PUSH:
port_queue_flow_push(in->port, in->queue);
break;
+ case PULL:
+ port_queue_flow_pull(in->port, in->queue);
+ break;
case INDIRECT_ACTION_CREATE:
port_action_handle_create(
in->port, in->args.vc.attr.group,
const struct rte_flow_action *actions)
{
struct rte_flow_op_attr op_attr = { .postpone = postpone };
- struct rte_flow_op_result comp = { 0 };
struct rte_flow *flow;
struct rte_port *port;
struct port_flow *pf;
struct port_table *pt;
uint32_t id = 0;
bool found;
- int ret = 0;
struct rte_flow_error error = { RTE_FLOW_ERROR_TYPE_NONE, NULL, NULL };
struct rte_flow_action_age *age = age_action_get(actions);
return port_flow_complain(&error);
}
- while (ret == 0) {
- /* Poisoning to make sure PMDs update it in case of error. */
- memset(&error, 0x22, sizeof(error));
- ret = rte_flow_pull(port_id, queue_id, &comp, 1, &error);
- if (ret < 0) {
- printf("Failed to pull queue\n");
- return -EINVAL;
- }
- }
-
pf->next = port->flow_list;
pf->id = id;
pf->flow = flow;
bool postpone, uint32_t n, const uint32_t *rule)
{
struct rte_flow_op_attr op_attr = { .postpone = postpone };
- struct rte_flow_op_result comp = { 0 };
struct rte_port *port;
struct port_flow **tmp;
uint32_t c = 0;
ret = port_flow_complain(&error);
continue;
}
-
- while (ret == 0) {
- /*
- * Poisoning to make sure PMD
- * update it in case of error.
- */
- memset(&error, 0x44, sizeof(error));
- ret = rte_flow_pull(port_id, queue_id,
- &comp, 1, &error);
- if (ret < 0) {
- printf("Failed to pull queue\n");
- return -EINVAL;
- }
- }
-
printf("Flow rule #%u destruction enqueued\n", pf->id);
*tmp = pf->next;
free(pf);
return ret;
}
+/** Pull queue operation results from the queue. */
+int
+port_queue_flow_pull(portid_t port_id, queueid_t queue_id)
+{
+ struct rte_port *port;
+ struct rte_flow_op_result *res;
+ struct rte_flow_error error;
+ int ret = 0;
+ int success = 0;
+ int i;
+
+ 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;
+ }
+
+ res = calloc(port->queue_sz, sizeof(struct rte_flow_op_result));
+ if (!res) {
+ printf("Failed to allocate memory for pulled results\n");
+ return -ENOMEM;
+ }
+
+ memset(&error, 0x66, sizeof(error));
+ ret = rte_flow_pull(port_id, queue_id, res,
+ port->queue_sz, &error);
+ if (ret < 0) {
+ printf("Failed to pull a operation results\n");
+ free(res);
+ return -EINVAL;
+ }
+
+ for (i = 0; i < ret; i++) {
+ if (res[i].status == RTE_FLOW_OP_SUCCESS)
+ success++;
+ }
+ printf("Queue #%u pulled %u operations (%u failed, %u succeeded)\n",
+ queue_id, ret, ret - success, success);
+ free(res);
+ return ret;
+}
+
/** Create flow rule. */
int
port_flow_create(portid_t port_id,
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_queue_flow_pull(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,
flow push {port_id} queue {queue_id}
+- Pull all operations results from a queue::
+
+ flow pull {port_id} queue {queue_id}
+
- Create a flow rule::
flow create {port_id}
Caught error type [...] ([...]): [...]
+Pulling flow operations results
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+``flow pull`` asks the underlying device about flow queue operations
+results and return all the processed (successfully or not) operations.
+It is bound to ``rte_flow_pull()``::
+
+ flow pull {port_id} queue {queue_id}
+
+If successful, it will show::
+
+ Queue #[...] pulled #[...] operations (#[...] failed, #[...] succeeded)
+
+The usual error message is shown when operations results cannot be pulled::
+
+ Caught error type [...] ([...]): [...]
+
Creating a tunnel stub for offload
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This command uses the same pattern items and actions as ``flow create``,
their format is described in `Creating flow rules`_.
+``flow queue pull`` must be called to retrieve the operation status.
+
Attributes
^^^^^^^^^^
Caught error type [...] ([...]): [...]
+``flow queue pull`` must be called to retrieve the operation status.
+
Querying flow rules
~~~~~~~~~~~~~~~~~~~