From: Alexander Kozyrev <akozyrev@nvidia.com>
To: <dev@dpdk.org>
Cc: <orika@nvidia.com>, <thomas@monjalon.net>,
<ivan.malov@oktetlabs.ru>, <andrew.rybchenko@oktetlabs.ru>,
<ferruh.yigit@intel.com>, <mohammad.abdul.awal@intel.com>,
<qi.z.zhang@intel.com>, <jerinj@marvell.com>,
<ajit.khaparde@broadcom.com>
Subject: [PATCH 09/10] app/testpmd: implement rte flow queue dequeue
Date: Tue, 18 Jan 2022 07:08:01 +0200 [thread overview]
Message-ID: <20220118050802.3915187-10-akozyrev@nvidia.com> (raw)
In-Reply-To: <20220118050802.3915187-6-akozyrev@nvidia.com>
Add testpmd support for the rte_flow_q_dequeue API.
Provide the command line interface for operations dequeue.
Usage example: flow dequeue 0 queue 0
Signed-off-by: Alexander Kozyrev <akozyrev@nvidia.com>
---
app/test-pmd/cmdline_flow.c | 54 +++++++++++++++
app/test-pmd/config.c | 74 +++++++++++++--------
app/test-pmd/testpmd.h | 1 +
doc/guides/testpmd_app_ug/testpmd_funcs.rst | 25 +++++++
4 files changed, 126 insertions(+), 28 deletions(-)
diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c
index e94c01cf75..507eb87984 100644
--- a/app/test-pmd/cmdline_flow.c
+++ b/app/test-pmd/cmdline_flow.c
@@ -93,6 +93,7 @@ enum index {
TUNNEL,
FLEX,
QUEUE,
+ DEQUEUE,
DRAIN,
/* Flex arguments */
@@ -132,6 +133,9 @@ enum index {
QUEUE_DESTROY_ID,
QUEUE_DESTROY_DRAIN,
+ /* Dequeue arguments. */
+ DEQUEUE_QUEUE,
+
/* Drain arguments. */
DRAIN_QUEUE,
@@ -2159,6 +2163,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_dequeue(struct context *, const struct token *,
+ const char *, unsigned int,
+ void *, unsigned int);
static int parse_drain(struct context *, const struct token *,
const char *, unsigned int,
void *, unsigned int);
@@ -2440,6 +2447,7 @@ static const struct token token_list[] = {
TUNNEL,
FLEX,
QUEUE,
+ DEQUEUE,
DRAIN)),
.call = parse_init,
},
@@ -2775,6 +2783,21 @@ static const struct token token_list[] = {
.call = parse_qo_destroy,
},
/* Top-level command. */
+ [DEQUEUE] = {
+ .name = "dequeue",
+ .help = "dequeue flow operations",
+ .next = NEXT(NEXT_ENTRY(DEQUEUE_QUEUE), NEXT_ENTRY(COMMON_PORT_ID)),
+ .args = ARGS(ARGS_ENTRY(struct buffer, port)),
+ .call = parse_dequeue,
+ },
+ /* Sub-level commands. */
+ [DEQUEUE_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. */
[DRAIN] = {
.name = "drain",
.help = "drain a flow queue",
@@ -8408,6 +8431,34 @@ parse_qo_destroy(struct context *ctx, const struct token *token,
}
}
+/** Parse tokens for dequeue command. */
+static int
+parse_dequeue(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 != DEQUEUE)
+ 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;
+}
+
/** Parse tokens for drain queue command. */
static int
parse_drain(struct context *ctx, const struct token *token,
@@ -9800,6 +9851,9 @@ cmd_flow_parsed(const struct buffer *in)
in->args.destroy.rule_n,
in->args.destroy.rule);
break;
+ case DEQUEUE:
+ port_queue_flow_dequeue(in->port, in->queue);
+ break;
case DRAIN:
port_queue_flow_drain(in->port, in->queue);
break;
diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
index c6469dd06f..5d23edf562 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -2420,14 +2420,12 @@ port_queue_flow_create(portid_t port_id, queueid_t queue_id,
const struct rte_flow_action *actions)
{
struct rte_flow_q_ops_attr ops_attr = { .drain = drain };
- struct rte_flow_q_op_res 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;
struct rte_flow_action_age *age = age_action_get(actions);
@@ -2477,16 +2475,6 @@ port_queue_flow_create(portid_t port_id, queueid_t queue_id,
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_q_dequeue(port_id, queue_id, &comp, 1, &error);
- if (ret < 0) {
- printf("Failed to poll queue\n");
- return -EINVAL;
- }
- }
-
pf->next = port->flow_list;
pf->id = id;
pf->flow = flow;
@@ -2501,7 +2489,6 @@ port_queue_flow_destroy(portid_t port_id, queueid_t queue_id,
bool drain, uint32_t n, const uint32_t *rule)
{
struct rte_flow_q_ops_attr op_attr = { .drain = drain };
- struct rte_flow_q_op_res comp = { 0 };
struct rte_port *port;
struct port_flow **tmp;
uint32_t c = 0;
@@ -2537,21 +2524,6 @@ port_queue_flow_destroy(portid_t port_id, queueid_t queue_id,
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_q_dequeue(port_id, queue_id,
- &comp, 1, &error);
- if (ret < 0) {
- printf("Failed to poll queue\n");
- return -EINVAL;
- }
- }
-
printf("Flow rule #%u destruction enqueued\n", pf->id);
*tmp = pf->next;
free(pf);
@@ -2592,6 +2564,52 @@ port_queue_flow_drain(portid_t port_id, queueid_t queue_id)
return ret;
}
+/** Dequeue a queue operation from the queue. */
+int
+port_queue_flow_dequeue(portid_t port_id, queueid_t queue_id)
+{
+ struct rte_port *port;
+ struct rte_flow_q_op_res *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 = malloc(sizeof(struct rte_flow_q_op_res) * port->queue_sz);
+ if (!res) {
+ printf("Failed to allocate memory for dequeue results\n");
+ return -ENOMEM;
+ }
+
+ memset(&error, 0x66, sizeof(error));
+ ret = rte_flow_q_dequeue(port_id, queue_id, res,
+ port->queue_sz, &error);
+ if (ret < 0) {
+ printf("Failed to dequeue a queue\n");
+ free(res);
+ return -EINVAL;
+ }
+
+ for (i = 0; i < ret; i++) {
+ if (res[i].status == RTE_FLOW_Q_OP_SUCCESS)
+ success++;
+ }
+ printf("Queue #%u dequeued %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,
diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h
index bf4597e7ba..3cf336dbae 100644
--- a/app/test-pmd/testpmd.h
+++ b/app/test-pmd/testpmd.h
@@ -935,6 +935,7 @@ int port_queue_flow_create(portid_t port_id, queueid_t queue_id,
int port_queue_flow_destroy(portid_t port_id, queueid_t queue_id,
bool drain, uint32_t n, const uint32_t *rule);
int port_queue_flow_drain(portid_t port_id, queueid_t queue_id);
+int port_queue_flow_dequeue(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,
diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
index 2ff4e4aef1..fff4de8f00 100644
--- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst
+++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
@@ -3372,6 +3372,10 @@ following sections.
flow drain {port_id} queue {queue_id}
+- Dequeue all operations from a queue::
+
+ flow dequeue {port_id} queue {queue_id}
+
- Create a flow rule::
flow create {port_id}
@@ -3582,6 +3586,23 @@ The usual error message is shown when a queue cannot be drained::
Caught error type [...] ([...]): [...]
+Dequeueing flow operations
+~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+``flow dequeue`` asks the underlying device about flow queue operations
+results and return all the processed (successfully or not) operations.
+It is bound to ``rte_flow_q_dequeue()``::
+
+ flow dequeue {port_id} queue {queue_id}
+
+If successful, it will show::
+
+ Queue #[...] dequeued #[...] operations (#[...] failed, #[...] succeeded)
+
+The usual error message is shown when a queue cannot be drained::
+
+ Caught error type [...] ([...]): [...]
+
Creating a tunnel stub for offload
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -3711,6 +3732,8 @@ Otherwise it will show an error message of the form::
This command uses the same pattern items and actions as ``flow create``,
their format is described in `Creating flow rules`_.
+``flow queue dequeue`` must be called to retrieve the operation status.
+
Attributes
^^^^^^^^^^
@@ -4444,6 +4467,8 @@ message is shown when a rule cannot be destroyed::
Caught error type [...] ([...]): [...]
+``flow queue dequeue`` must be called to retrieve the operation status.
+
Querying flow rules
~~~~~~~~~~~~~~~~~~~
--
2.18.2
prev parent reply other threads:[~2022-01-18 5:09 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-18 5:07 [PATCH 05/10] app/testpmd: implement rte flow item/action template Alexander Kozyrev
2022-01-18 5:07 ` [PATCH 06/10] app/testpmd: implement rte flow table Alexander Kozyrev
2022-01-18 5:07 ` [PATCH 07/10] app/testpmd: implement rte flow queue create flow Alexander Kozyrev
2022-01-18 5:08 ` [PATCH 08/10] app/testpmd: implement rte flow queue drain Alexander Kozyrev
2022-01-18 5:08 ` Alexander Kozyrev [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220118050802.3915187-10-akozyrev@nvidia.com \
--to=akozyrev@nvidia.com \
--cc=ajit.khaparde@broadcom.com \
--cc=andrew.rybchenko@oktetlabs.ru \
--cc=dev@dpdk.org \
--cc=ferruh.yigit@intel.com \
--cc=ivan.malov@oktetlabs.ru \
--cc=jerinj@marvell.com \
--cc=mohammad.abdul.awal@intel.com \
--cc=orika@nvidia.com \
--cc=qi.z.zhang@intel.com \
--cc=thomas@monjalon.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).