[PATCH v2 1/2] common/cnxk: add support to get aged flows
Jerin Jacob
jerinjacobk at gmail.com
Thu Sep 28 10:13:50 CEST 2023
On Mon, Aug 14, 2023 at 12:26 PM Jerin Jacob <jerinjacobk at gmail.com> wrote:
>
> On Tue, Aug 8, 2023 at 2:20 PM Ankur Dwivedi <adwivedi at marvell.com> wrote:
> >
> > Adds support to get aged flows in CNXK driver.
> > The control thread polls the status of flows having age action, every 10
> > seconds and updates a bitmap array with the aged flows. The poll frequency
> > of control thread can be set by devargs.
> >
> > Signed-off-by: Ankur Dwivedi <adwivedi at marvell.com>
> > ---
> > drivers/common/cnxk/meson.build | 1 +
> > drivers/common/cnxk/roc_mbox.h | 27 +++
> > drivers/common/cnxk/roc_npc.c | 22 ++
> > drivers/common/cnxk/roc_npc.h | 28 +++
> > drivers/common/cnxk/roc_npc_aging.c | 315 ++++++++++++++++++++++++++++
> > drivers/common/cnxk/roc_npc_priv.h | 17 ++
> > drivers/common/cnxk/roc_platform.h | 8 +
> > drivers/common/cnxk/version.map | 1 +
> > 8 files changed, 419 insertions(+)
> > create mode 100644 drivers/common/cnxk/roc_npc_aging.c
>
> Updated the release notes as
> diff --git a/doc/guides/rel_notes/release_23_11.rst
> b/doc/guides/rel_notes/release_23_11.rst
> index 5b01a52593..10d4484685 100644
> --- a/doc/guides/rel_notes/release_23_11.rst
> +++ b/doc/guides/rel_notes/release_23_11.rst
> @@ -58,6 +58,7 @@ New Features
> * **Updated Marvell cnxk ethdev driver.**
>
> * Added support for ``RTE_FLOW_ITEM_TYPE_IPV6_ROUTING_EXT`` flow item.
> + * Added support for ``RTE_FLOW_ACTION_TYPE_AGE`` flow action.
>
> Updated the git commit as follows and applied to
> dpdk-next-net-mrvl/for-next-net. Thanks
Ankur, following changes in upstream changed the thread APIs. I have
adapted to this change in [1]. Please review ASAP - It is blocking rc1
PR.
commit 1c1abf1786a6de044bd396da4cc316961e3fd812
Author: Thomas Monjalon <thomas at monjalon.net>
Date: Wed Sep 13 13:28:19 2023 +0200
lib: convert to internal control threads
Calls to rte_ctrl_thread_create() are replaced with
rte_thread_create_internal_control().
Other pthread-related functions are replaced with the rte_thread API.
Only pthread_cancel() has no replacement.
Signed-off-by: Thomas Monjalon <thomas at monjalon.net>
Acked-by: Morten Brørup <mb at smartsharesystems.com>
Acked-by: Tyler Retzlaff <roretzla at linux.microsoft.com>
Acked-by: Konstantin Ananyev <konstantin.v.ananyev at yandex.ru
[1]
diff --git a/drivers/common/cnxk/roc_npc.c b/drivers/common/cnxk/roc_npc.c
index 83c04880f2..94c8e94400 100644
--- a/drivers/common/cnxk/roc_npc.c
+++ b/drivers/common/cnxk/roc_npc.c
@@ -1623,7 +1623,8 @@ 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 (roc_npc->flow_age.age_flow_refcnt == 0 &&
roc_npc->flow_age.aged_flows_poll_thread)
+ 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);
done:
diff --git a/drivers/common/cnxk/roc_npc.h b/drivers/common/cnxk/roc_npc.h
index ad1c3b08cc..5a7117eae4 100644
--- a/drivers/common/cnxk/roc_npc.h
+++ b/drivers/common/cnxk/roc_npc.h
@@ -359,7 +359,7 @@ struct roc_npc_flow_age {
uint32_t aged_flows_cnt;
uint32_t start_id;
uint32_t end_id;
- pthread_t aged_flows_poll_thread;
+ rte_thread_t aged_flows_poll_thread;
struct plt_bitmap *aged_flows;
void *age_mem;
bool aged_flows_get_thread_exit;
diff --git a/drivers/common/cnxk/roc_npc_aging.c
b/drivers/common/cnxk/roc_npc_aging.c
index 4b845954b4..74543f227b 100644
--- a/drivers/common/cnxk/roc_npc_aging.c
+++ b/drivers/common/cnxk/roc_npc_aging.c
@@ -134,7 +134,7 @@ npc_mcam_get_hit_status(struct npc *npc, uint64_t
*mcam_ids, uint16_t start_id,
return rc;
}
-void *
+uint32_t
npc_aged_flows_get(void *args)
{
uint64_t hit_status[MCAM_ARR_SIZE] = {0};
@@ -182,7 +182,7 @@ npc_aged_flows_get(void *args)
rc = npc_mcam_get_hit_status(npc, mcam_ids, start_id, end_id,
hit_status, true);
if (rc)
- return NULL;
+ return 0;
plt_seqcount_write_begin(&flow_age->seq_cnt);
flow_age->aged_flows_cnt = 0;
@@ -201,7 +201,7 @@ npc_aged_flows_get(void *args)
sleep(flow_age->aging_poll_freq);
}
- return NULL;
+ return 0;
}
void
@@ -276,8 +276,8 @@ npc_aging_ctrl_thread_create(struct roc_npc *roc_npc,
if (flow_age->age_flow_refcnt == 0) {
flow_age->aged_flows_get_thread_exit = false;
- if (plt_ctrl_thread_create(&flow_age->aged_flows_poll_thread,
- "Aged Flows Get Ctrl Thread", NULL,
+ if (plt_thread_create_control(&flow_age->aged_flows_poll_thread,
+ "Aged Flows Get Ctrl Thread",
npc_aged_flows_get, roc_npc) != 0) {
plt_err("Failed to create thread for age flows");
errcode = NPC_ERR_ACTION_NOTSUP;
@@ -295,7 +295,7 @@ npc_aging_ctrl_thread_destroy(struct roc_npc *roc_npc)
flow_age = &roc_npc->flow_age;
flow_age->aged_flows_get_thread_exit = true;
- pthread_join(flow_age->aged_flows_poll_thread, NULL);
+ plt_thread_join(flow_age->aged_flows_poll_thread, NULL);
npc_aged_flows_bitmap_free(roc_npc);
}
diff --git a/drivers/common/cnxk/roc_npc_priv.h
b/drivers/common/cnxk/roc_npc_priv.h
index 6d6cb64c65..424f8e207a 100644
--- a/drivers/common/cnxk/roc_npc_priv.h
+++ b/drivers/common/cnxk/roc_npc_priv.h
@@ -490,7 +490,7 @@ int npc_mcam_init(struct npc *npc, struct
roc_npc_flow *flow, int mcam_id);
int npc_mcam_move(struct mbox *mbox, uint16_t old_ent, uint16_t new_ent);
void npc_age_flow_list_entry_add(struct roc_npc *npc, struct
roc_npc_flow *flow);
void npc_age_flow_list_entry_delete(struct roc_npc *npc, struct
roc_npc_flow *flow);
-void *npc_aged_flows_get(void *args);
+uint32_t npc_aged_flows_get(void *args);
int npc_aged_flows_bitmap_alloc(struct roc_npc *roc_npc);
void npc_aged_flows_bitmap_free(struct roc_npc *roc_npc);
int npc_aging_ctrl_thread_create(struct roc_npc *roc_npc,
diff --git a/drivers/common/cnxk/roc_platform.h
b/drivers/common/cnxk/roc_platform.h
index ad0d1624a3..1e535a527d 100644
--- a/drivers/common/cnxk/roc_platform.h
+++ b/drivers/common/cnxk/roc_platform.h
@@ -145,6 +145,12 @@
#define plt_thread_create_control rte_thread_create_internal_control
#define plt_thread_join rte_thread_join
+static inline bool
+plt_thread_is_valid(rte_thread_t thr)
+{
+ return thr.opaque_id ? true : false;
+}
+
#define plt_intr_efd_counter_size_get rte_intr_efd_counter_size_get
#define plt_intr_efd_counter_size_set rte_intr_efd_counter_size_set
#define plt_intr_vec_list_index_get rte_intr_vec_list_index_get
More information about the dev
mailing list