[PATCH v1] common/cnxk: fix flow add in age flow list

Ankur Dwivedi adwivedi at marvell.com
Tue Oct 17 13:18:37 CEST 2023


While adding flow in npc_flow_list, the flow can be added before the
current flow iterator. The function returns after adding this flow.
This prevents flow to be added in age flow list correctly. This patch moves
the addition of age flow list before npc_flow_list add to prevent the
error. Also the flow is added or deleted to/from age flow list if the flow
has age action.

Fixes: 357f5ebc8a24 ("common/cnxk: support flow aging")
Cc: stable at dpdk.org

Signed-off-by: Ankur Dwivedi <adwivedi at marvell.com>
---
 drivers/common/cnxk/roc_npc.c       | 9 ++++++---
 drivers/common/cnxk/roc_npc.h       | 1 +
 drivers/common/cnxk/roc_npc_aging.c | 1 +
 3 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/drivers/common/cnxk/roc_npc.c b/drivers/common/cnxk/roc_npc.c
index f36f5e42c8..7593466bc1 100644
--- a/drivers/common/cnxk/roc_npc.c
+++ b/drivers/common/cnxk/roc_npc.c
@@ -1510,6 +1510,9 @@ roc_npc_flow_create(struct roc_npc *roc_npc, const struct roc_npc_attr *attr,
 		goto set_rss_failed;
 	}
 
+	if (flow->has_age_action)
+		npc_age_flow_list_entry_add(roc_npc, flow);
+
 	if (flow->use_pre_alloc == 0)
 		list = &npc->flow_list[flow->priority];
 	else
@@ -1523,8 +1526,6 @@ roc_npc_flow_create(struct roc_npc *roc_npc, const struct roc_npc_attr *attr,
 	}
 	TAILQ_INSERT_TAIL(list, flow, next);
 
-	npc_age_flow_list_entry_add(roc_npc, flow);
-
 	return flow;
 
 set_rss_failed:
@@ -1622,7 +1623,9 @@ roc_npc_flow_destroy(struct roc_npc *roc_npc, struct roc_npc_flow *flow)
 
 	npc_delete_prio_list_entry(npc, flow);
 
-	npc_age_flow_list_entry_delete(roc_npc, flow);
+	if (flow->has_age_action)
+		npc_age_flow_list_entry_delete(roc_npc, flow);
+
 	if (roc_npc->flow_age.age_flow_refcnt == 0 &&
 		plt_thread_is_valid(roc_npc->flow_age.aged_flows_poll_thread))
 		npc_aging_ctrl_thread_destroy(roc_npc);
diff --git a/drivers/common/cnxk/roc_npc.h b/drivers/common/cnxk/roc_npc.h
index cf7e6c9548..4b387f2a6b 100644
--- a/drivers/common/cnxk/roc_npc.h
+++ b/drivers/common/cnxk/roc_npc.h
@@ -320,6 +320,7 @@ struct roc_npc_flow {
 	uint64_t timeout_cycles;
 	void *age_context;
 	uint32_t timeout;
+	bool has_age_action;
 
 	TAILQ_ENTRY(roc_npc_flow) next;
 };
diff --git a/drivers/common/cnxk/roc_npc_aging.c b/drivers/common/cnxk/roc_npc_aging.c
index 74543f227b..a456d2b893 100644
--- a/drivers/common/cnxk/roc_npc_aging.c
+++ b/drivers/common/cnxk/roc_npc_aging.c
@@ -273,6 +273,7 @@ npc_aging_ctrl_thread_create(struct roc_npc *roc_npc,
 	flow->age_context = age->context == NULL ? flow : age->context;
 	flow->timeout = age->timeout;
 	flow->timeout_cycles = plt_tsc_cycles() + age->timeout * plt_tsc_hz();
+	flow->has_age_action = true;
 
 	if (flow_age->age_flow_refcnt == 0) {
 		flow_age->aged_flows_get_thread_exit = false;
-- 
2.25.1



More information about the dev mailing list