DPDK patches and discussions
 help / color / mirror / Atom feed
From: Ankur Dwivedi <adwivedi@marvell.com>
To: <dev@dpdk.org>
Cc: <jerinj@marvell.com>, <ndabilpuram@marvell.com>,
	<kirankumark@marvell.com>, <skori@marvell.com>,
	<skoteshwar@marvell.com>, Ankur Dwivedi <adwivedi@marvell.com>,
	<stable@dpdk.org>
Subject: [PATCH v1] common/cnxk: fix flow add in age flow list
Date: Tue, 17 Oct 2023 16:48:37 +0530	[thread overview]
Message-ID: <20231017111837.1434411-1-adwivedi@marvell.com> (raw)

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(-)

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


             reply	other threads:[~2023-10-17 11:18 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-17 11:18 Ankur Dwivedi [this message]
2023-10-18  7:18 ` Jerin Jacob

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=20231017111837.1434411-1-adwivedi@marvell.com \
    --to=adwivedi@marvell.com \
    --cc=dev@dpdk.org \
    --cc=jerinj@marvell.com \
    --cc=kirankumark@marvell.com \
    --cc=ndabilpuram@marvell.com \
    --cc=skori@marvell.com \
    --cc=skoteshwar@marvell.com \
    --cc=stable@dpdk.org \
    /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).