From patchwork Thu Oct 19 17:30:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sunil Kumar Kori X-Patchwork-Id: 133021 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 B27E7431B0; Thu, 19 Oct 2023 19:30:53 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9307742DA1; Thu, 19 Oct 2023 19:30:28 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by mails.dpdk.org (Postfix) with ESMTP id 62A5E4281D for ; Thu, 19 Oct 2023 19:30:27 +0200 (CEST) Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 39JCfFli008154 for ; Thu, 19 Oct 2023 10:30:26 -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=LPOzDsIFm54zE9E1DKR9mi8kT+q9s8IYFstrfHJ6NW0=; b=W7eRqDChBEEOkqOmrH3yxHTdD3sVpnxTaaeh6zhCYPUdL5OZTcp22F0+I8Z6wNnMEb1z glIFBn9QvPF11kXDjYyb50nz5vUR23bYtzWWE1Vna4uSiaACf43i8/ti7pu1yNfhZZmW kaI9S0KTXZ4FW62NY1S7mpaB60rFs5Bu+T4e9QUHAzd+xi9IIrx8P4TTu4XsnGG+5S/E vR8HBy4it28duLrNrL0iqOWZYvZpV23GnYBjFWZUGF7guu2hxHs/L7qmeUoHBZweRNrE QIvetbK1Ipz2PpRzPwZKEjjmWSZL8UTElevpnNwTEDA+qD51b3oVG9CCaHJEYdjEhqS+ Qw== Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 3ttshubs4x-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Thu, 19 Oct 2023 10:30:26 -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.48; Thu, 19 Oct 2023 10:30:24 -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.48 via Frontend Transport; Thu, 19 Oct 2023 10:30:24 -0700 Received: from localhost.localdomain (unknown [10.28.34.25]) by maili.marvell.com (Postfix) with ESMTP id 53D9F3F7094; Thu, 19 Oct 2023 10:30:23 -0700 (PDT) From: To: Sunil Kumar Kori , Rakesh Kudurumalla CC: , Jerin Jacob Subject: [PATCH v11 04/12] app/graph: support mempool command line interfaces Date: Thu, 19 Oct 2023 23:00:03 +0530 Message-ID: <20231019173011.1186656-5-skori@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231019173011.1186656-1-skori@marvell.com> References: <20231019105000.520914-13-skori@marvell.com> <20231019173011.1186656-1-skori@marvell.com> MIME-Version: 1.0 X-Proofpoint-GUID: OtGD3CIot-Ub-FlV1aZgJZ47qGHilmQz X-Proofpoint-ORIG-GUID: OtGD3CIot-Ub-FlV1aZgJZ47qGHilmQz X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.980,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-10-19_16,2023-10-19_01,2023-05-22_02 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 From: Rakesh Kudurumalla Adds mempool module which will be creating mempools. Following commands are exposed: - mempool size buffers \ cache numa - help mempool User will add this command in .cli file according to its need. Signed-off-by: Sunil Kumar Kori Signed-off-by: Rakesh Kudurumalla Acked-by: Jerin Jacob Acked-By: Nithin Dabilpuram --- app/graph/cli.c | 2 + app/graph/mempool.c | 140 +++++++++++++++++++++++++++++++++++++ app/graph/mempool.h | 24 +++++++ app/graph/mempool_priv.h | 34 +++++++++ app/graph/meson.build | 1 + app/graph/module_api.h | 2 + doc/guides/tools/graph.rst | 7 ++ 7 files changed, 210 insertions(+) create mode 100644 app/graph/mempool.c create mode 100644 app/graph/mempool.h create mode 100644 app/graph/mempool_priv.h diff --git a/app/graph/cli.c b/app/graph/cli.c index df4f8fcbb8..cf544d5f8f 100644 --- a/app/graph/cli.c +++ b/app/graph/cli.c @@ -20,6 +20,8 @@ #define MAX_LINE_SIZE 2048 cmdline_parse_ctx_t modules_ctx[] = { + (cmdline_parse_inst_t *)&mempool_config_cmd_ctx, + (cmdline_parse_inst_t *)&mempool_help_cmd_ctx, NULL, }; diff --git a/app/graph/mempool.c b/app/graph/mempool.c new file mode 100644 index 0000000000..9fd3f8460b --- /dev/null +++ b/app/graph/mempool.c @@ -0,0 +1,140 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2023 Marvell. + */ + +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include "mempool_priv.h" +#include "module_api.h" + +static const char +cmd_mempool_help[] = "mempool size buffers " + "cache numa "; + +struct mempools mpconfig; + +int +mempool_process(struct mempool_config *config) +{ + struct rte_mempool *mp; + uint8_t nb_pools; + + nb_pools = mpconfig.nb_pools; + rte_strscpy(mpconfig.config[nb_pools].name, config->name, RTE_MEMPOOL_NAMESIZE); + mpconfig.config[nb_pools].pool_size = config->pool_size; + mpconfig.config[nb_pools].buffer_size = config->buffer_size; + mpconfig.config[nb_pools].cache_size = config->cache_size; + mpconfig.config[nb_pools].numa_node = config->numa_node; + + mp = rte_pktmbuf_pool_create(config->name, config->pool_size, config->cache_size, + 128, config->buffer_size, config->numa_node); + if (!mp) + return -EINVAL; + + mpconfig.mp[nb_pools] = mp; + nb_pools++; + mpconfig.nb_pools = nb_pools; + + return 0; +} + +static void +cli_mempool_help(__rte_unused void *parsed_result, __rte_unused struct cmdline *cl, + __rte_unused void *data) +{ + size_t len; + + len = strlen(conn->msg_out); + conn->msg_out += len; + snprintf(conn->msg_out, conn->msg_out_len_max, "\n%s\n%s\n", + "----------------------------- mempool command help -----------------------------", + cmd_mempool_help); + + len = strlen(conn->msg_out); + conn->msg_out_len_max -= len; +} + +static void +cli_mempool(void *parsed_result, __rte_unused struct cmdline *cl, __rte_unused void *data) +{ + struct mempool_config_cmd_tokens *res = parsed_result; + struct mempool_config config; + int rc = -EINVAL; + + + rte_strscpy(config.name, res->name, RTE_MEMPOOL_NAMESIZE); + config.name[strlen(res->name)] = '\0'; + config.pool_size = res->nb_bufs; + config.buffer_size = res->buf_sz; + config.cache_size = res->cache_size; + config.numa_node = res->node; + + rc = mempool_process(&config); + if (rc < 0) + printf(MSG_CMD_FAIL, "mempool"); +} + +cmdline_parse_token_string_t mempool_config_add_mempool = + TOKEN_STRING_INITIALIZER(struct mempool_config_cmd_tokens, mempool, "mempool"); +cmdline_parse_token_string_t mempool_config_add_name = + TOKEN_STRING_INITIALIZER(struct mempool_config_cmd_tokens, name, NULL); +cmdline_parse_token_string_t mempool_config_add_size = + TOKEN_STRING_INITIALIZER(struct mempool_config_cmd_tokens, size, "size"); +cmdline_parse_token_num_t mempool_config_add_buf_sz = + TOKEN_NUM_INITIALIZER(struct mempool_config_cmd_tokens, buf_sz, RTE_UINT16); +cmdline_parse_token_string_t mempool_config_add_buffers = + TOKEN_STRING_INITIALIZER(struct mempool_config_cmd_tokens, buffers, "buffers"); +cmdline_parse_token_num_t mempool_config_add_nb_bufs = + TOKEN_NUM_INITIALIZER(struct mempool_config_cmd_tokens, nb_bufs, RTE_UINT16); +cmdline_parse_token_string_t mempool_config_add_cache = + TOKEN_STRING_INITIALIZER(struct mempool_config_cmd_tokens, cache, "cache"); +cmdline_parse_token_num_t mempool_config_add_cache_size = + TOKEN_NUM_INITIALIZER(struct mempool_config_cmd_tokens, cache_size, RTE_UINT16); +cmdline_parse_token_string_t mempool_config_add_numa = + TOKEN_STRING_INITIALIZER(struct mempool_config_cmd_tokens, numa, "numa"); +cmdline_parse_token_num_t mempool_config_add_node = + TOKEN_NUM_INITIALIZER(struct mempool_config_cmd_tokens, node, RTE_UINT16); + +cmdline_parse_inst_t mempool_config_cmd_ctx = { + .f = cli_mempool, + .data = NULL, + .help_str = cmd_mempool_help, + .tokens = { + (void *)&mempool_config_add_mempool, + (void *)&mempool_config_add_name, + (void *)&mempool_config_add_size, + (void *)&mempool_config_add_buf_sz, + (void *)&mempool_config_add_buffers, + (void *)&mempool_config_add_nb_bufs, + (void *)&mempool_config_add_cache, + (void *)&mempool_config_add_cache_size, + (void *)&mempool_config_add_numa, + (void *)&mempool_config_add_node, + NULL, + }, +}; + +cmdline_parse_token_string_t mempool_help_cmd = + TOKEN_STRING_INITIALIZER(struct mempool_help_cmd_tokens, help, "help"); +cmdline_parse_token_string_t mempool_help_mempool = + TOKEN_STRING_INITIALIZER(struct mempool_help_cmd_tokens, mempool, "mempool"); + +cmdline_parse_inst_t mempool_help_cmd_ctx = { + .f = cli_mempool_help, + .data = NULL, + .help_str = "", + .tokens = { + (void *)&mempool_help_cmd, + (void *)&mempool_help_mempool, + NULL, + }, +}; diff --git a/app/graph/mempool.h b/app/graph/mempool.h new file mode 100644 index 0000000000..0808c4259e --- /dev/null +++ b/app/graph/mempool.h @@ -0,0 +1,24 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2023 Marvell. + */ + +#ifndef APP_GRAPH_MEMPOOL_H +#define APP_GRAPH_MEMPOOL_H + +#include +#include + +struct mempool_config { + char name[RTE_MEMPOOL_NAMESIZE]; + int pool_size; + int cache_size; + int buffer_size; + int numa_node; +}; + +extern cmdline_parse_inst_t mempool_config_cmd_ctx; +extern cmdline_parse_inst_t mempool_help_cmd_ctx; + +int mempool_process(struct mempool_config *config); + +#endif diff --git a/app/graph/mempool_priv.h b/app/graph/mempool_priv.h new file mode 100644 index 0000000000..3ce64702a9 --- /dev/null +++ b/app/graph/mempool_priv.h @@ -0,0 +1,34 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2023 Marvell. + */ + +#ifndef APP_GRAPH_MEMPOOL_PRIV_H +#define APP_GRAPH_MEMPOOL_PRIV_H + +#include "mempool.h" + +struct mempool_config_cmd_tokens { + cmdline_fixed_string_t mempool; + cmdline_fixed_string_t size; + cmdline_fixed_string_t buffers; + cmdline_fixed_string_t cache; + cmdline_fixed_string_t numa; + cmdline_fixed_string_t name; + uint16_t buf_sz; + uint16_t nb_bufs; + uint16_t cache_size; + uint16_t node; +}; + +struct mempool_help_cmd_tokens { + cmdline_fixed_string_t help; + cmdline_fixed_string_t mempool; +}; + +struct mempools { + struct mempool_config config[RTE_MAX_ETHPORTS]; + struct rte_mempool *mp[RTE_MAX_ETHPORTS]; + uint8_t nb_pools; +}; + +#endif diff --git a/app/graph/meson.build b/app/graph/meson.build index fd71036a95..5dc23c875b 100644 --- a/app/graph/meson.build +++ b/app/graph/meson.build @@ -13,5 +13,6 @@ sources = files( 'cli.c', 'conn.c', 'main.c', + 'mempool.c', 'utils.c', ) diff --git a/app/graph/module_api.h b/app/graph/module_api.h index ad4fb50989..b45419811b 100644 --- a/app/graph/module_api.h +++ b/app/graph/module_api.h @@ -10,11 +10,13 @@ #include "cli.h" #include "conn.h" +#include "mempool.h" #include "utils.h" /* * Externs */ extern volatile bool force_quit; +extern struct conn *conn; bool app_graph_exit(void); #endif diff --git a/doc/guides/tools/graph.rst b/doc/guides/tools/graph.rst index 943f915049..6009b0c291 100644 --- a/doc/guides/tools/graph.rst +++ b/doc/guides/tools/graph.rst @@ -71,6 +71,13 @@ file to express the requested use case configuration. +--------------------------------------+-----------------------------------+---------+----------+ | Command | Description | Dynamic | Optional | +======================================+===================================+=========+==========+ + | | mempool size | | Command to create mempool which | No | No | + | | buffers | | will be further associated to | | | + | | | | RxQ to dequeue the packets. | | | + | | cache numa | | | | + +--------------------------------------+-----------------------------------+---------+----------+ + | help mempool | | Command to dump mempool help | Yes | Yes | + | | | message. | | | | | | | | +--------------------------------------+-----------------------------------+---------+----------+