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 6F8F9A0C43; Fri, 22 Oct 2021 05:28:17 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6551541153; Fri, 22 Oct 2021 05:28:16 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by mails.dpdk.org (Postfix) with ESMTP id 2F60541152 for ; Fri, 22 Oct 2021 05:28:15 +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 19LK0B5M016910; Thu, 21 Oct 2021 20:28:12 -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=o4/616yv2HCD0I+JMslES0y56tfVFYE9IuOzdL7XtvI=; b=aVQr1fVvgGoBtk/n5KEUQ7CfcpCOG90359mUw1FW3CWfPZbFVVg/cp3+tCrlETDZ15Xe gy+JRq2NxOSWPcAlTAFub/24L27n6mrSsvCXJnBbOKoRVf589MbA5YoG2KtNz9oxQnnr asJIasZXlaaYlH6MJ2V7yrJSScT/shZqF2Cc0QDakDte/nLK50u1gGsK8wI8yJsViK7j Ct4dB7J+1fCrD6QG0Z6pTfa7FMG+gT5XPj/f2RPlHqlipTRJF5VV/Zdb9KPKYVDsYU2p qg/3SAOoLAXDE5DuYCn1o/f5tr/khKW7BjSJXD+kPCnJA+4jK8LWcvCa+5iVaPU4sotN PA== Received: from dc5-exch02.marvell.com ([199.233.59.182]) by mx0a-0016f401.pphosted.com with ESMTP id 3bueuysfd0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Thu, 21 Oct 2021 20:28:12 -0700 Received: from DC5-EXCH01.marvell.com (10.69.176.38) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Thu, 21 Oct 2021 20:28:11 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server id 15.0.1497.18 via Frontend Transport; Thu, 21 Oct 2021 20:28:11 -0700 Received: from localhost.localdomain (unknown [10.28.34.38]) by maili.marvell.com (Postfix) with ESMTP id 770113F707A; Thu, 21 Oct 2021 20:28:09 -0700 (PDT) From: Gowrishankar Muthukrishnan To: CC: Olivier Matz , Andrew Rybchenko , , , Gowrishankar Muthukrishnan Date: Fri, 22 Oct 2021 08:58:04 +0530 Message-ID: <6dabad2f3b015ea429397e4585f5c47f8ad121ad.1634873109.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-ORIG-GUID: CfR3Lyj0BYGQY_hKdhjzkyR7nnEcyfP7 X-Proofpoint-GUID: CfR3Lyj0BYGQY_hKdhjzkyR7nnEcyfP7 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_01,2021-10-21_02,2020-04-07_01 Subject: [dpdk-dev] [v2] 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 --- v2: - code alignments fixed --- lib/mempool/rte_mempool.c | 84 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) 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