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 BDD5743B49; Mon, 19 Feb 2024 09:38:48 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 64BE440647; Mon, 19 Feb 2024 09:38:46 +0100 (CET) Received: from szxga04-in.huawei.com (szxga04-in.huawei.com [45.249.212.190]) by mails.dpdk.org (Postfix) with ESMTP id 72103402EC for ; Mon, 19 Feb 2024 09:38:44 +0100 (CET) Received: from mail.maildlp.com (unknown [172.19.163.44]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4TdbVS4jVDz2Bd4G; Mon, 19 Feb 2024 16:36:32 +0800 (CST) Received: from kwepemd100004.china.huawei.com (unknown [7.221.188.31]) by mail.maildlp.com (Postfix) with ESMTPS id A67241400CB; Mon, 19 Feb 2024 16:38:39 +0800 (CST) Received: from localhost.localdomain (10.67.165.2) by kwepemd100004.china.huawei.com (7.221.188.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.2.1258.28; Mon, 19 Feb 2024 16:38:39 +0800 From: Jie Hai To: CC: , , , , , , , , , Subject: [PATCH v8 1/2] ring: add telemetry cmd to list rings Date: Mon, 19 Feb 2024 16:32:52 +0800 Message-ID: <20240219083253.2215275-2-haijie1@huawei.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20240219083253.2215275-1-haijie1@huawei.com> References: <20230117091049.20194-1-haijie1@huawei.com> <20240219083253.2215275-1-haijie1@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit X-Originating-IP: [10.67.165.2] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To kwepemd100004.china.huawei.com (7.221.188.31) 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 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 Acked-by: Konstantin Ananyev Reviewed-by: Honnappa Nagarahalli Acked-by: Huisong Li Acked-by: Chengwen Feng Acked-by: Morten Brørup --- 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 c59f62626383..75f53c723186 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" @@ -423,3 +424,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 *tailq_entry; + + ring_list = RTE_TAILQ_CAST(rte_ring_tailq.head, rte_ring_list); + rte_mcfg_tailq_read_lock(); + + TAILQ_FOREACH(tailq_entry, ring_list, next) { + (*func)((struct rte_ring *) tailq_entry->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 rings. Takes no parameters"); +} -- 2.30.0