From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 0231D41B88; Tue, 31 Jan 2023 04:09:40 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id DAE3440EF0; Tue, 31 Jan 2023 04:09:39 +0100 (CET) Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by mails.dpdk.org (Postfix) with ESMTP id 6EFF840DFB for ; Tue, 31 Jan 2023 04:09:38 +0100 (CET) Received: from kwepemi500020.china.huawei.com (unknown [172.30.72.53]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4P5VKJ5hq5zJqdD; Tue, 31 Jan 2023 11:05:08 +0800 (CST) Received: from [10.67.103.42] (10.67.103.42) by kwepemi500020.china.huawei.com (7.221.188.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Tue, 31 Jan 2023 11:09:36 +0800 Message-ID: <5b9b9e37-c9bb-9f12-6190-6ab1bc94c318@huawei.com> Date: Tue, 31 Jan 2023 11:09:36 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.9.1 Subject: Re: [PATCH v2 1/2] ring: add ring list telemetry cmd To: Konstantin Ananyev CC: , , References: <20230117091049.20194-1-haijie1@huawei.com> <20230117130333.8707-1-haijie1@huawei.com> <20230117130333.8707-2-haijie1@huawei.com> <8e561371-f993-8d0a-c147-c86099a33118@yandex.ru> From: Jie Hai In-Reply-To: <8e561371-f993-8d0a-c147-c86099a33118@yandex.ru> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 8bit X-Originating-IP: [10.67.103.42] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To kwepemi500020.china.huawei.com (7.221.188.8) X-CFilter-Loop: Reflected X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org On 2023/1/23 0:40, Konstantin Ananyev wrote: > Hi Jie, > >> This patch supports the list of rings with telemetry cmd. >> 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 >> --- >>   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..bb1dafd4d1ca 100644 >> --- a/lib/ring/rte_ring.c >> +++ b/lib/ring/rte_ring.c >> @@ -22,6 +22,7 @@ >>   #include >>   #include >>   #include >> +#include >>   #include "rte_ring.h" >>   #include "rte_ring_elem.h" >> @@ -419,3 +420,42 @@ rte_ring_lookup(const char *name) >>       return r; >>   } >> + >> +static void >> +rte_ring_walk(void (*func)(struct rte_ring *, void *), void *arg) > > As a nit: it is a static function, so I think we can skip 'rte_' prefix > for it. > Apart from that: > Acked-by: Konstantin Ananyev > Hi, Konstantin, Thanks for your review. Accepted and fixed in v3. Jie Hai >> +{ >> +    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); >> +    rte_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"); >> +} > > .