app/testpmd: flush flow templates when port is removed
Checks
Commit Message
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(+)
Comments
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>
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.
@@ -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,
@@ -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);
}
@@ -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,