* [PATCH] app/testpmd: flush flow templates when port is removed
@ 2022-11-08 9:30 Dariusz Sosnowski
2022-11-11 16:22 ` Singh, Aman Deep
0 siblings, 1 reply; 3+ messages in thread
From: Dariusz Sosnowski @ 2022-11-08 9:30 UTC (permalink / raw)
To: Aman Singh, Yuying Zhang; +Cc: dev, Ori Kam, Suanming Mou
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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] app/testpmd: flush flow templates when port is removed
2022-11-08 9:30 [PATCH] app/testpmd: flush flow templates when port is removed Dariusz Sosnowski
@ 2022-11-11 16:22 ` Singh, Aman Deep
2022-11-14 9:28 ` Andrew Rybchenko
0 siblings, 1 reply; 3+ messages in thread
From: Singh, Aman Deep @ 2022-11-11 16:22 UTC (permalink / raw)
To: Dariusz Sosnowski, Yuying Zhang; +Cc: dev, Ori Kam, Suanming Mou
On 11/8/2022 3:00 PM, Dariusz Sosnowski wrote:
> 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>
Acked-by: Aman Singh<aman.deep.singh@intel.com>
> ---
> <Snip>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] app/testpmd: flush flow templates when port is removed
2022-11-11 16:22 ` Singh, Aman Deep
@ 2022-11-14 9:28 ` Andrew Rybchenko
0 siblings, 0 replies; 3+ messages in thread
From: Andrew Rybchenko @ 2022-11-14 9:28 UTC (permalink / raw)
To: Singh, Aman Deep, Dariusz Sosnowski, Yuying Zhang
Cc: dev, Ori Kam, Suanming Mou
On 11/11/22 19:22, Singh, Aman Deep wrote:
>
> On 11/8/2022 3:00 PM, Dariusz Sosnowski wrote:
>> 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>
>
> Acked-by: Aman Singh<aman.deep.singh@intel.com>
Applied to dpdk-next-net/main, thanks.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-11-14 9:28 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-08 9:30 [PATCH] app/testpmd: flush flow templates when port is removed Dariusz Sosnowski
2022-11-11 16:22 ` Singh, Aman Deep
2022-11-14 9:28 ` Andrew Rybchenko
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).