[v1] common/cnxk: fix flow add in age flow list
Checks
Commit Message
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
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>
@@ -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);
@@ -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;
};
@@ -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;