Few minor comments inline. Otherwise, Reviewed-by: Honnappa Nagarahalli <honnappa.nagaraha...@arm.com>
> -----Original Message----- > From: Jie Hai <haij...@huawei.com> > Sent: Monday, January 30, 2023 8:29 PM > To: Honnappa Nagarahalli <honnappa.nagaraha...@arm.com>; > konstantin.v.anan...@yandex.ru; dev@dpdk.org > Cc: liudongdo...@huawei.com; haij...@huawei.com > Subject: [PATCH v3 1/2] ring: add ring list telemetry cmd How about "ring: add telemetry cmd to list rings" > > This patch supports the list of rings with telemetry cmd. Add a telemetry command to list the rings used in the system. > An example using this command is shown below: > > --> /ring/list > { > "/ring/list": [ > "HT_0000:7d:00.2", > "MP_mb_pool_0" > ] > } > > Signed-off-by: Jie Hai <haij...@huawei.com> > Acked-by: Konstantin Ananyev <konstantin.v.anan...@yandex.ru> > --- > lib/ring/meson.build | 1 + > lib/ring/rte_ring.c | 40 ++++++++++++++++++++++++++++++++++++++++ > 2 files changed, 41 insertions(+) > > diff --git a/lib/ring/meson.build b/lib/ring/meson.build index > c20685c689ac..7fca958ed7fa 100644 > --- a/lib/ring/meson.build > +++ b/lib/ring/meson.build > @@ -18,3 +18,4 @@ indirect_headers += files ( > 'rte_ring_rts.h', > 'rte_ring_rts_elem_pvt.h', > ) > +deps += ['telemetry'] > diff --git a/lib/ring/rte_ring.c b/lib/ring/rte_ring.c index > cddaf6b2876f..e6aac332d88f 100644 > --- a/lib/ring/rte_ring.c > +++ b/lib/ring/rte_ring.c > @@ -22,6 +22,7 @@ > #include <rte_errno.h> > #include <rte_string_fns.h> > #include <rte_tailq.h> > +#include <rte_telemetry.h> > > #include "rte_ring.h" > #include "rte_ring_elem.h" > @@ -419,3 +420,42 @@ rte_ring_lookup(const char *name) > > return r; > } > + > +static void > +ring_walk(void (*func)(struct rte_ring *, void *), void *arg) { > + struct rte_ring_list *ring_list; > + struct rte_tailq_entry *te; > + > + ring_list = RTE_TAILQ_CAST(rte_ring_tailq.head, rte_ring_list); > + rte_mcfg_tailq_read_lock(); > + > + TAILQ_FOREACH(te, ring_list, next) { > + (*func)((struct rte_ring *) te->data, arg); > + } > + > + rte_mcfg_tailq_read_unlock(); > +} > + > +static void > +ring_list_cb(struct rte_ring *r, void *arg) { > + struct rte_tel_data *d = (struct rte_tel_data *)arg; > + > + rte_tel_data_add_array_string(d, r->name); } > + > +static int > +ring_handle_list(const char *cmd __rte_unused, > + const char *params __rte_unused, struct rte_tel_data *d) { > + rte_tel_data_start_array(d, RTE_TEL_STRING_VAL); > + ring_walk(ring_list_cb, d); > + return 0; > +} > + > +RTE_INIT(ring_init_telemetry) > +{ > + rte_telemetry_register_cmd("/ring/list", ring_handle_list, > + "Returns list of available ring. Takes no parameters"); } ^^^^ rings > -- > 2.33.0