From: Dariusz Sosnowski <dsosnowski@nvidia.com>
To: Aman Singh <aman.deep.singh@intel.com>,
Yuying Zhang <yuying.zhang@intel.com>
Cc: <dev@dpdk.org>, Ori Kam <orika@nvidia.com>,
Suanming Mou <suanmingm@nvidia.com>
Subject: [PATCH] app/testpmd: flush flow templates when port is removed
Date: Tue, 8 Nov 2022 09:30:45 +0000 [thread overview]
Message-ID: <20221108093045.445821-1-dsosnowski@nvidia.com> (raw)
From: Suanming Mou <suanmingm@nvidia.com>
This patch adds explicit flushing of template tables,
pattern and actions templates, when a port is closed or
detached.
Signed-off-by: Suanming Mou <suanmingm@nvidia.com>
---
app/test-pmd/config.c | 111 +++++++++++++++++++++++++++++++++++++++++
app/test-pmd/testpmd.c | 3 ++
app/test-pmd/testpmd.h | 3 ++
3 files changed, 117 insertions(+)
diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
index e8a1b77c2a..234d534d10 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -2293,6 +2293,42 @@ port_flow_pattern_template_destroy(portid_t port_id, uint32_t n,
return ret;
}
+/** Flush pattern template */
+int
+port_flow_pattern_template_flush(portid_t port_id)
+{
+ struct rte_port *port;
+ struct port_template **tmp;
+ 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];
+ tmp = &port->pattern_templ_list;
+ while (*tmp) {
+ struct rte_flow_error error;
+ struct port_template *pit = *tmp;
+
+ /*
+ * Poisoning to make sure PMDs update it in case
+ * of error.
+ */
+ memset(&error, 0x33, sizeof(error));
+ if (pit->template.pattern_template &&
+ rte_flow_pattern_template_destroy(port_id,
+ pit->template.pattern_template, &error)) {
+ printf("Pattern template #%u not destroyed\n", pit->id);
+ ret = port_flow_complain(&error);
+ tmp = &pit->next;
+ } else {
+ *tmp = pit->next;
+ free(pit);
+ }
+ }
+ return ret;
+}
+
/** Create actions template */
int
port_flow_actions_template_create(portid_t port_id, uint32_t id,
@@ -2373,6 +2409,43 @@ port_flow_actions_template_destroy(portid_t port_id, uint32_t n,
return ret;
}
+/** Flush actions template */
+int
+port_flow_actions_template_flush(portid_t port_id)
+{
+ struct rte_port *port;
+ struct port_template **tmp;
+ 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];
+ tmp = &port->actions_templ_list;
+ while (*tmp) {
+ struct rte_flow_error error;
+ struct port_template *pat = *tmp;
+
+ /*
+ * Poisoning to make sure PMDs update it in case
+ * of error.
+ */
+ memset(&error, 0x33, sizeof(error));
+
+ if (pat->template.actions_template &&
+ rte_flow_actions_template_destroy(port_id,
+ pat->template.actions_template, &error)) {
+ ret = port_flow_complain(&error);
+ printf("Actions template #%u not destroyed\n", pat->id);
+ tmp = &pat->next;
+ } else {
+ *tmp = pat->next;
+ free(pat);
+ }
+ }
+ return ret;
+}
+
/** Create table */
int
port_flow_template_table_create(portid_t port_id, uint32_t id,
@@ -2501,6 +2574,44 @@ port_flow_template_table_destroy(portid_t port_id,
return ret;
}
+/** Flush table */
+int
+port_flow_template_table_flush(portid_t port_id)
+{
+ struct rte_port *port;
+ struct port_table **tmp;
+ 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];
+ tmp = &port->table_list;
+ while (*tmp) {
+ struct rte_flow_error error;
+ struct port_table *pt = *tmp;
+
+ /*
+ * Poisoning to make sure PMDs update it in case
+ * of error.
+ */
+ memset(&error, 0x33, sizeof(error));
+
+ if (pt->table &&
+ rte_flow_template_table_destroy(port_id,
+ pt->table,
+ &error)) {
+ ret = port_flow_complain(&error);
+ printf("Template table #%u not destroyed\n", pt->id);
+ tmp = &pt->next;
+ } else {
+ *tmp = pt->next;
+ free(pt);
+ }
+ }
+ return ret;
+}
+
/** Enqueue create flow rule operation. */
int
port_queue_flow_create(portid_t port_id, queueid_t queue_id,
diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
index bf589c4e8d..6c5a3555b8 100644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ -3212,6 +3212,9 @@ flush_port_owned_resources(portid_t pi)
mcast_addr_pool_destroy(pi);
port_flow_flush(pi);
port_flex_item_flush(pi);
+ port_flow_template_table_flush(pi);
+ port_flow_pattern_template_flush(pi);
+ port_flow_actions_template_flush(pi);
port_action_handle_flush(pi);
}
diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h
index 93fdb9d331..277d4091ab 100644
--- a/app/test-pmd/testpmd.h
+++ b/app/test-pmd/testpmd.h
@@ -907,18 +907,21 @@ int port_flow_pattern_template_create(portid_t port_id, uint32_t id,
const struct rte_flow_item *pattern);
int port_flow_pattern_template_destroy(portid_t port_id, uint32_t n,
const uint32_t *template);
+int port_flow_pattern_template_flush(portid_t port_id);
int port_flow_actions_template_create(portid_t port_id, uint32_t id,
const struct rte_flow_actions_template_attr *attr,
const struct rte_flow_action *actions,
const struct rte_flow_action *masks);
int port_flow_actions_template_destroy(portid_t port_id, uint32_t n,
const uint32_t *template);
+int port_flow_actions_template_flush(portid_t port_id);
int port_flow_template_table_create(portid_t port_id, uint32_t id,
const struct rte_flow_template_table_attr *table_attr,
uint32_t nb_pattern_templates, uint32_t *pattern_templates,
uint32_t nb_actions_templates, uint32_t *actions_templates);
int port_flow_template_table_destroy(portid_t port_id,
uint32_t n, const uint32_t *table);
+int port_flow_template_table_flush(portid_t port_id);
int port_queue_flow_create(portid_t port_id, queueid_t queue_id,
bool postpone, uint32_t table_id,
uint32_t pattern_idx, uint32_t actions_idx,
--
2.25.1
next reply other threads:[~2022-11-08 9:32 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-08 9:30 Dariusz Sosnowski [this message]
2022-11-11 16:22 ` Singh, Aman Deep
2022-11-14 9:28 ` Andrew Rybchenko
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=20221108093045.445821-1-dsosnowski@nvidia.com \
--to=dsosnowski@nvidia.com \
--cc=aman.deep.singh@intel.com \
--cc=dev@dpdk.org \
--cc=orika@nvidia.com \
--cc=suanmingm@nvidia.com \
--cc=yuying.zhang@intel.com \
/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).