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

Message ID 20231017111837.1434411-1-adwivedi@marvell.com (mailing list archive)
State Accepted, archived
Delegated to: Jerin Jacob
Headers
Series [v1] common/cnxk: fix flow add in age flow list |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/loongarch-compilation success Compilation OK
ci/loongarch-unit-testing success Unit Testing PASS
ci/github-robot: build success github build: passed
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-compile-amd64-testing success Testing PASS
ci/iol-compile-arm64-testing success Testing PASS
ci/iol-unit-arm64-testing success Testing PASS
ci/iol-unit-amd64-testing success Testing PASS
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/intel-Functional success Functional PASS
ci/iol-intel-Functional success Functional Testing PASS

Commit Message

Ankur Dwivedi Oct. 17, 2023, 11:18 a.m. UTC
  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@dpdk.org

Signed-off-by: Ankur Dwivedi <adwivedi@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(-)
  

Comments

Jerin Jacob Oct. 18, 2023, 7:18 a.m. UTC | #1
On Tue, Oct 17, 2023 at 4:48 PM Ankur Dwivedi <adwivedi@marvell.com> wrote:
>
> 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@dpdk.org
>
> Signed-off-by: Ankur Dwivedi <adwivedi@marvell.com>

Updated the git commit as follows and applied to
dpdk-next-net-mrvl/for-next-net. Thanks


    common/cnxk: fix age flow list update

    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@dpdk.org

    Signed-off-by: Ankur Dwivedi <adwivedi@marvell.com>
  

Patch

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;