From patchwork Thu Nov 9 10:20:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jie Hai X-Patchwork-Id: 134017 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 76072432E3; Thu, 9 Nov 2023 11:25:35 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id DA3ED406BA; Thu, 9 Nov 2023 11:25:25 +0100 (CET) Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by mails.dpdk.org (Postfix) with ESMTP id C4438402DF for ; Thu, 9 Nov 2023 11:25:21 +0100 (CET) Received: from kwepemd100004.china.huawei.com (unknown [172.30.72.55]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4SQygL2bb7z1P8Bc; Thu, 9 Nov 2023 18:22:06 +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.23; Thu, 9 Nov 2023 18:24:27 +0800 From: Jie Hai To: , , , , , , CC: , , Subject: [RESEND v7 1/3] ring: fix unmatched type definition and usage Date: Thu, 9 Nov 2023 18:20:44 +0800 Message-ID: <20231109102046.1277893-2-haijie1@huawei.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20231109102046.1277893-1-haijie1@huawei.com> References: <20230117091049.20194-1-haijie1@huawei.com> <20231109102046.1277893-1-haijie1@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.67.165.2] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To kwepemd100004.china.huawei.com (7.221.188.31) 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 Field 'flags' of struct rte_ring is defined as int type. However, it is used as unsigned int. To ensure consistency, change the type of flags to unsigned int. Since these two types has the same byte size, this change is not an ABI change. Fixes: af75078fece3 ("first public release") Signed-off-by: Jie Hai Acked-by: Konstantin Ananyev Acked-by: Chengwen Feng Acked-by: Morten Brørup Acked-by: Huisong Li --- lib/ring/rte_ring_core.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ring/rte_ring_core.h b/lib/ring/rte_ring_core.h index b7708730658a..14dac6495d83 100644 --- a/lib/ring/rte_ring_core.h +++ b/lib/ring/rte_ring_core.h @@ -119,7 +119,7 @@ struct rte_ring_hts_headtail { struct rte_ring { char name[RTE_RING_NAMESIZE] __rte_cache_aligned; /**< Name of the ring. */ - int flags; /**< Flags supplied at creation. */ + uint32_t flags; /**< Flags supplied at creation. */ const struct rte_memzone *memzone; /**< Memzone, if any, containing the rte_ring */ uint32_t size; /**< Size of ring. */ From patchwork Thu Nov 9 10:20:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jie Hai X-Patchwork-Id: 134015 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 33203432E3; Thu, 9 Nov 2023 11:25:24 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 84D3040608; Thu, 9 Nov 2023 11:25:23 +0100 (CET) Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by mails.dpdk.org (Postfix) with ESMTP id 3FF644064A for ; Thu, 9 Nov 2023 11:25:21 +0100 (CET) Received: from kwepemd100004.china.huawei.com (unknown [172.30.72.55]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4SQygL44xnz1P8BD; Thu, 9 Nov 2023 18:22:06 +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.23; Thu, 9 Nov 2023 18:24:28 +0800 From: Jie Hai To: , , , , , , CC: , , Subject: [RESEND v7 2/3] ring: add telemetry cmd to list rings Date: Thu, 9 Nov 2023 18:20:45 +0800 Message-ID: <20231109102046.1277893-3-haijie1@huawei.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20231109102046.1277893-1-haijie1@huawei.com> References: <20230117091049.20194-1-haijie1@huawei.com> <20231109102046.1277893-1-haijie1@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.67.165.2] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To kwepemd100004.china.huawei.com (7.221.188.31) 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 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 Acked-by: Huisong Li --- 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 057d25ff6f2f..6a10280fb093 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" @@ -418,3 +419,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"); +} From patchwork Thu Nov 9 10:20:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jie Hai X-Patchwork-Id: 134016 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 32EC8432E3; Thu, 9 Nov 2023 11:25:30 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A5B404068E; Thu, 9 Nov 2023 11:25:24 +0100 (CET) Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by mails.dpdk.org (Postfix) with ESMTP id 221E840608 for ; Thu, 9 Nov 2023 11:25:21 +0100 (CET) Received: from kwepemd100004.china.huawei.com (unknown [172.30.72.55]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4SQygL5ZW5z1P88Y; Thu, 9 Nov 2023 18:22:06 +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.23; Thu, 9 Nov 2023 18:24:28 +0800 From: Jie Hai To: , , , , , , CC: , , Subject: [RESEND v7 3/3] ring: add telemetry cmd for ring info Date: Thu, 9 Nov 2023 18:20:46 +0800 Message-ID: <20231109102046.1277893-4-haijie1@huawei.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20231109102046.1277893-1-haijie1@huawei.com> References: <20230117091049.20194-1-haijie1@huawei.com> <20231109102046.1277893-1-haijie1@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.67.165.2] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To kwepemd100004.china.huawei.com (7.221.188.31) 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 This patch supports dump of ring information by its name. An example using this command is shown below: --> /ring/info,MP_mb_pool_0 { "/ring/info": { "name": "MP_mb_pool_0", "socket": 0, "flags": "0x0", "producer_type": "MP", "consumer_type": "MC", "size": 262144, "mask": "0x3ffff", "capacity": 262143, "used_count": 153197, "mz_name": "RG_MP_mb_pool_0", "mz_len": 2097536, "mz_hugepage_sz": 1073741824, "mz_socket_id": 0, "mz_flags": "0x0" } } Signed-off-by: Jie Hai Reviewed-by: Honnappa Nagarahalli Acked-by: Konstantin Ananyev Acked-by: Huisong Li Acked-by: Chengwen Feng Acked-by: Morten Brørup Acked-by: Huisong Li --- lib/ring/rte_ring.c | 95 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 95 insertions(+) diff --git a/lib/ring/rte_ring.c b/lib/ring/rte_ring.c index 6a10280fb093..5ee15037548e 100644 --- a/lib/ring/rte_ring.c +++ b/lib/ring/rte_ring.c @@ -453,8 +453,103 @@ ring_handle_list(const char *cmd __rte_unused, return 0; } +static const char * +ring_prod_sync_type_to_name(struct rte_ring *r) +{ + switch (r->prod.sync_type) { + case RTE_RING_SYNC_MT: + return "MP"; + case RTE_RING_SYNC_ST: + return "SP"; + case RTE_RING_SYNC_MT_RTS: + return "MP_RTS"; + case RTE_RING_SYNC_MT_HTS: + return "MP_HTS"; + default: + return "Unknown"; + } +} + +static const char * +ring_cons_sync_type_to_name(struct rte_ring *r) +{ + switch (r->cons.sync_type) { + case RTE_RING_SYNC_MT: + return "MC"; + case RTE_RING_SYNC_ST: + return "SC"; + case RTE_RING_SYNC_MT_RTS: + return "MC_RTS"; + case RTE_RING_SYNC_MT_HTS: + return "MC_HTS"; + default: + return "Unknown"; + } +} + +struct ring_info_cb_arg { + char *ring_name; + struct rte_tel_data *d; +}; + +static void +ring_info_cb(struct rte_ring *r, void *arg) +{ + struct ring_info_cb_arg *ring_arg = (struct ring_info_cb_arg *)arg; + struct rte_tel_data *d = ring_arg->d; + const struct rte_memzone *mz; + + if (strncmp(r->name, ring_arg->ring_name, RTE_RING_NAMESIZE)) + return; + + rte_tel_data_add_dict_string(d, "name", r->name); + rte_tel_data_add_dict_int(d, "socket", r->memzone->socket_id); + rte_tel_data_add_dict_uint_hex(d, "flags", r->flags, 0); + rte_tel_data_add_dict_string(d, "producer_type", + ring_prod_sync_type_to_name(r)); + rte_tel_data_add_dict_string(d, "consumer_type", + ring_cons_sync_type_to_name(r)); + rte_tel_data_add_dict_uint(d, "size", r->size); + rte_tel_data_add_dict_uint_hex(d, "mask", r->mask, 0); + rte_tel_data_add_dict_uint(d, "capacity", r->capacity); + rte_tel_data_add_dict_uint(d, "used_count", rte_ring_count(r)); + + mz = r->memzone; + if (mz == NULL) + return; + rte_tel_data_add_dict_string(d, "mz_name", mz->name); + rte_tel_data_add_dict_uint(d, "mz_len", mz->len); + rte_tel_data_add_dict_uint(d, "mz_hugepage_sz", mz->hugepage_sz); + rte_tel_data_add_dict_int(d, "mz_socket_id", mz->socket_id); + rte_tel_data_add_dict_uint_hex(d, "mz_flags", mz->flags, 0); +} + +static int +ring_handle_info(const char *cmd __rte_unused, const char *params, + struct rte_tel_data *d) +{ + char name[RTE_RING_NAMESIZE] = {0}; + struct ring_info_cb_arg ring_arg; + + if (params == NULL || strlen(params) == 0 || + strlen(params) >= RTE_RING_NAMESIZE) + return -EINVAL; + + rte_strlcpy(name, params, RTE_RING_NAMESIZE); + + ring_arg.ring_name = name; + ring_arg.d = d; + + rte_tel_data_start_dict(d); + ring_walk(ring_info_cb, &ring_arg); + + return 0; +} + RTE_INIT(ring_init_telemetry) { rte_telemetry_register_cmd("/ring/list", ring_handle_list, "Returns list of available rings. Takes no parameters"); + rte_telemetry_register_cmd("/ring/info", ring_handle_info, + "Returns ring info. Parameters: ring_name."); }