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 08053A0C43; Fri, 22 Oct 2021 18:11:52 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id AE8BE410DF; Fri, 22 Oct 2021 18:11:52 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by mails.dpdk.org (Postfix) with ESMTP id E96B14003E for ; Fri, 22 Oct 2021 18:11:50 +0200 (CEST) Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 19M9qIlq011085; Fri, 22 Oct 2021 09:11:49 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=pfpt0220; bh=7l+5VdTHlCDl9ILY8+/JEqBGpJndHoiRypFGVWEDoE4=; b=R90Haij7Sh4sr0lMQrh+euJAxANcRSRoMlrhsqATo74nkcchCVenfJGdE9opRkJ2mDHJ xAk+BTsoS8Rad3ZezkAH50n5N5ZmGdoPHVu8Nz4R4ZbRvZgOs2/C5pQnkVbwotQOhSLZ LsSKU0NGrjV8iR0VmsiUH3vcsMEkxJbxm25Kw6gHRdOykleUl0uALePcXQsME88iNeLw qiWDertf6r8LCohGwf5fQonmmZ7TB65wJeJuzj6COuz8iwoOtb7xMyR7lvzXDKUHI9y0 2tMJWNzhAdZ4WyXmVcICSNLxHNu6XeOG5GkwfhDm1ww9ooE319zEUXxiQZ195XXFZorw sg== Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0a-0016f401.pphosted.com with ESMTP id 3buu23scxj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Fri, 22 Oct 2021 09:11:48 -0700 Received: from DC5-EXCH02.marvell.com (10.69.176.39) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Fri, 22 Oct 2021 09:11:47 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server id 15.0.1497.18 via Frontend Transport; Fri, 22 Oct 2021 09:11:47 -0700 Received: from localhost.localdomain (unknown [10.28.34.38]) by maili.marvell.com (Postfix) with ESMTP id 9E4923F7079; Fri, 22 Oct 2021 09:11:45 -0700 (PDT) From: Gowrishankar Muthukrishnan To: CC: Olivier Matz , Andrew Rybchenko , , , Gowrishankar Muthukrishnan Date: Fri, 22 Oct 2021 21:41:42 +0530 Message-ID: <48f7b483238dec1b63282f892562f614fb447394.1634919021.git.gmuthukrishn@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-GUID: 0A4dIbbOcAeFVV0iExBbCYV3vyaKwdCB X-Proofpoint-ORIG-GUID: 0A4dIbbOcAeFVV0iExBbCYV3vyaKwdCB X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.182.1,Aquarius:18.0.790,Hydra:6.0.425,FMLib:17.0.607.475 definitions=2021-10-22_04,2021-10-22_01,2020-04-07_01 Subject: [dpdk-dev] [v3] mempool: add telemetry endpoint for mempool info 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 Sender: "dev" Add telemetry endpoint for mempool info. Signed-off-by: Gowrishankar Muthukrishnan Reviewed-by: Bruce Richardson --- v3: - added explicit telemetry dependency in meson --- lib/mempool/meson.build | 2 +- lib/mempool/rte_mempool.c | 84 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 85 insertions(+), 1 deletion(-) diff --git a/lib/mempool/meson.build b/lib/mempool/meson.build index e48bd6a14a..b8aaa00694 100644 --- a/lib/mempool/meson.build +++ b/lib/mempool/meson.build @@ -20,4 +20,4 @@ headers = files( 'rte_mempool_trace.h', 'rte_mempool_trace_fp.h', ) -deps += ['ring'] +deps += ['ring', 'telemetry'] diff --git a/lib/mempool/rte_mempool.c b/lib/mempool/rte_mempool.c index b75d26c82a..2d915e591d 100644 --- a/lib/mempool/rte_mempool.c +++ b/lib/mempool/rte_mempool.c @@ -31,6 +31,7 @@ #include #include #include +#include #include "rte_mempool.h" #include "rte_mempool_trace.h" @@ -1483,3 +1484,86 @@ rte_mempool_event_callback_unregister(rte_mempool_event_callback *func, rte_errno = -ret; return ret; } + +static void +mempool_list_cb(struct rte_mempool *mp, void *arg) +{ + struct rte_tel_data *d = (struct rte_tel_data *)arg; + + rte_tel_data_add_array_string(d, mp->name); +} + +static int +mempool_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_mempool_walk(mempool_list_cb, d); + return 0; +} + +struct mempool_info_cb_arg { + char *pool_name; + struct rte_tel_data *d; +}; + +static void +mempool_info_cb(struct rte_mempool *mp, void *arg) +{ + struct mempool_info_cb_arg *info = (struct mempool_info_cb_arg *)arg; + const struct rte_memzone *mz; + + if (strncmp(mp->name, info->pool_name, RTE_MEMZONE_NAMESIZE)) + return; + + rte_tel_data_add_dict_string(info->d, "name", mp->name); + rte_tel_data_add_dict_int(info->d, "pool_id", mp->pool_id); + rte_tel_data_add_dict_int(info->d, "flags", mp->flags); + rte_tel_data_add_dict_int(info->d, "socket_id", mp->socket_id); + rte_tel_data_add_dict_int(info->d, "size", mp->size); + rte_tel_data_add_dict_int(info->d, "cache_size", mp->cache_size); + rte_tel_data_add_dict_int(info->d, "elt_size", mp->elt_size); + rte_tel_data_add_dict_int(info->d, "header_size", mp->header_size); + rte_tel_data_add_dict_int(info->d, "trailer_size", mp->trailer_size); + rte_tel_data_add_dict_int(info->d, "private_data_size", + mp->private_data_size); + rte_tel_data_add_dict_int(info->d, "ops_index", mp->ops_index); + rte_tel_data_add_dict_int(info->d, "populated_size", + mp->populated_size); + + mz = mp->mz; + rte_tel_data_add_dict_string(info->d, "mz_name", mz->name); + rte_tel_data_add_dict_int(info->d, "mz_len", mz->len); + rte_tel_data_add_dict_int(info->d, "mz_hugepage_sz", + mz->hugepage_sz); + rte_tel_data_add_dict_int(info->d, "mz_socket_id", mz->socket_id); + rte_tel_data_add_dict_int(info->d, "mz_flags", mz->flags); +} + +static int +mempool_handle_info(const char *cmd __rte_unused, const char *params, + struct rte_tel_data *d) +{ + struct mempool_info_cb_arg mp_arg; + char name[RTE_MEMZONE_NAMESIZE]; + + if (!params || strlen(params) == 0) + return -EINVAL; + + rte_strlcpy(name, params, RTE_MEMZONE_NAMESIZE); + + rte_tel_data_start_dict(d); + mp_arg.pool_name = name; + mp_arg.d = d; + rte_mempool_walk(mempool_info_cb, &mp_arg); + + return 0; +} + +RTE_INIT(mempool_init_telemetry) +{ + rte_telemetry_register_cmd("/mempool/list", mempool_handle_list, + "Returns list of available mempool. Takes no parameters"); + rte_telemetry_register_cmd("/mempool/info", mempool_handle_info, + "Returns mempool info. Parameters: pool_name"); +} -- 2.25.1