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 CDFD3431DE; Mon, 23 Oct 2023 09:04:27 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id BC2C140647; Mon, 23 Oct 2023 09:04:27 +0200 (CEST) Received: from mail-qt1-f181.google.com (mail-qt1-f181.google.com [209.85.160.181]) by mails.dpdk.org (Postfix) with ESMTP id AD4EA40647 for ; Mon, 23 Oct 2023 09:04:26 +0200 (CEST) Received: by mail-qt1-f181.google.com with SMTP id d75a77b69052e-41cb9419975so16688561cf.2 for ; Mon, 23 Oct 2023 00:04:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1698044666; x=1698649466; darn=dpdk.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=D9p9cC6JQj6HBSJAKf4952+kAtAiSGtaPAtpGH3h7vY=; b=RyjByu3wU6BLmzN+MK33FYUxtPpJVLc4NZQpgTk2olEAf7WpR3lq3KzR5NHtFsBDTR bnyUhN0HZYo3xKz7S2uocU0h9W+TzthTNMadtUb7/YXaLYsAiM2RHMzzOLKYaQP/oyYg 5YUA5HKQBh1tF7/Id358KRPOKfTr5EGgihJUFAwM1EPdj6YAS+zVASKAWgGtgEHhERSw HhW7s1tjXus+DamNUu7iq4q17/YkolWMYLaknT9iu/7EfGacsj9QD1lx4QUOdAOX14Mx H8O4j8zdDAV2/yrpcsCw62U6YYSeHASWLJiajLYCKoOj+9jaBmTwo9j20cAoB0w/OlkD Dgow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698044666; x=1698649466; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=D9p9cC6JQj6HBSJAKf4952+kAtAiSGtaPAtpGH3h7vY=; b=EpxY+FHhNdQ+KKkqrivwmK2Whe5CpyjwiHFR0wN9DRLCe3vaC1kdeVzkEPGUgQ2iau eB4u0wZQKwuU1GpPh9rWb4rdGFZkafUUCMI0dx9qjbEOz7CIJ8VZ3UFSXzHMHYqdu/Wo /5nqf4+cwAsm2PEpv6ELjDQr7KdohbpdRHTppDwFlg0YyWnvcd0RP5M+hS+lVz9+sea2 /caj5a+bPO5yJzrE/EdV4e8mFjtXqlPea3tEoi0t8J0myq7VHuXMaRLU1ypsnOQ0bEOF X3WZOQTWRC9f+M47JOS1bulMOHoUMhHL6IiSxdeuszmaHtkXLWrDZmfCazDycuwsUahB ThdQ== X-Gm-Message-State: AOJu0Yy+M7JAPVKGFRb616xrjpNSu9Amt6Ig8qg1L5cuHX+D0/FlZT7o Bnf9246Iec20adXduw1IWaQkPEgYeQt9qEmwyCrG0shJheo= X-Google-Smtp-Source: AGHT+IHLlnaJWrN4PkUTrk9GNmKyu+9JQMjRScN4wHwmG8hRmKARKHb/Dl8NLyhCQcYU3gFV3RmniJ0JdzzIfHn8kl8= X-Received: by 2002:ac8:5b94:0:b0:417:a74f:69b5 with SMTP id a20-20020ac85b94000000b00417a74f69b5mr11540243qta.33.1698044666035; Mon, 23 Oct 2023 00:04:26 -0700 (PDT) MIME-Version: 1.0 References: <20231019105000.520914-13-skori@marvell.com> <20231019173011.1186656-1-skori@marvell.com> <20231019173011.1186656-5-skori@marvell.com> In-Reply-To: <20231019173011.1186656-5-skori@marvell.com> From: Nithin Dabilpuram Date: Mon, 23 Oct 2023 12:34:12 +0530 Message-ID: Subject: Re: [PATCH v11 04/12] app/graph: support mempool command line interfaces To: skori@marvell.com Cc: Rakesh Kudurumalla , dev@dpdk.org, Jerin Jacob Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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 Acked-By: Nithin Dabilpuram On Thu, Oct 19, 2023 at 11:00=E2=80=AFPM wrote: > > 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 > --- > 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[] =3D { > + (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[] =3D "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 =3D mpconfig.nb_pools; > + rte_strscpy(mpconfig.config[nb_pools].name, config->name, RTE_MEM= POOL_NAMESIZE); > + mpconfig.config[nb_pools].pool_size =3D config->pool_size; > + mpconfig.config[nb_pools].buffer_size =3D config->buffer_size; > + mpconfig.config[nb_pools].cache_size =3D config->cache_size; > + mpconfig.config[nb_pools].numa_node =3D config->numa_node; > + > + mp =3D rte_pktmbuf_pool_create(config->name, config->pool_size, c= onfig->cache_size, > + 128, config->buffer_size, config->numa_node); > + if (!mp) > + return -EINVAL; > + > + mpconfig.mp[nb_pools] =3D mp; > + nb_pools++; > + mpconfig.nb_pools =3D nb_pools; > + > + return 0; > +} > + > +static void > +cli_mempool_help(__rte_unused void *parsed_result, __rte_unused struct c= mdline *cl, > + __rte_unused void *data) > +{ > + size_t len; > + > + len =3D strlen(conn->msg_out); > + conn->msg_out +=3D len; > + snprintf(conn->msg_out, conn->msg_out_len_max, "\n%s\n%s\n", > + "----------------------------- mempool command help ----= -------------------------", > + cmd_mempool_help); > + > + len =3D strlen(conn->msg_out); > + conn->msg_out_len_max -=3D len; > +} > + > +static void > +cli_mempool(void *parsed_result, __rte_unused struct cmdline *cl, __rte_= unused void *data) > +{ > + struct mempool_config_cmd_tokens *res =3D parsed_result; > + struct mempool_config config; > + int rc =3D -EINVAL; > + > + > + rte_strscpy(config.name, res->name, RTE_MEMPOOL_NAMESIZE); > + config.name[strlen(res->name)] =3D '\0'; > + config.pool_size =3D res->nb_bufs; > + config.buffer_size =3D res->buf_sz; > + config.cache_size =3D res->cache_size; > + config.numa_node =3D res->node; > + > + rc =3D mempool_process(&config); > + if (rc < 0) > + printf(MSG_CMD_FAIL, "mempool"); > +} > + > +cmdline_parse_token_string_t mempool_config_add_mempool =3D > + TOKEN_STRING_INITIALIZER(struct mempool_config_cmd_tokens, mempoo= l, "mempool"); > +cmdline_parse_token_string_t mempool_config_add_name =3D > + TOKEN_STRING_INITIALIZER(struct mempool_config_cmd_tokens, name, = NULL); > +cmdline_parse_token_string_t mempool_config_add_size =3D > + TOKEN_STRING_INITIALIZER(struct mempool_config_cmd_tokens, size, = "size"); > +cmdline_parse_token_num_t mempool_config_add_buf_sz =3D > + TOKEN_NUM_INITIALIZER(struct mempool_config_cmd_tokens, buf_sz, R= TE_UINT16); > +cmdline_parse_token_string_t mempool_config_add_buffers =3D > + TOKEN_STRING_INITIALIZER(struct mempool_config_cmd_tokens, buffer= s, "buffers"); > +cmdline_parse_token_num_t mempool_config_add_nb_bufs =3D > + TOKEN_NUM_INITIALIZER(struct mempool_config_cmd_tokens, nb_bufs, = RTE_UINT16); > +cmdline_parse_token_string_t mempool_config_add_cache =3D > + TOKEN_STRING_INITIALIZER(struct mempool_config_cmd_tokens, cache,= "cache"); > +cmdline_parse_token_num_t mempool_config_add_cache_size =3D > + TOKEN_NUM_INITIALIZER(struct mempool_config_cmd_tokens, cache_siz= e, RTE_UINT16); > +cmdline_parse_token_string_t mempool_config_add_numa =3D > + TOKEN_STRING_INITIALIZER(struct mempool_config_cmd_tokens, numa, = "numa"); > +cmdline_parse_token_num_t mempool_config_add_node =3D > + TOKEN_NUM_INITIALIZER(struct mempool_config_cmd_tokens, node, RTE= _UINT16); > + > +cmdline_parse_inst_t mempool_config_cmd_ctx =3D { > + .f =3D cli_mempool, > + .data =3D NULL, > + .help_str =3D cmd_mempool_help, > + .tokens =3D { > + (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 =3D > + TOKEN_STRING_INITIALIZER(struct mempool_help_cmd_tokens, help, "h= elp"); > +cmdline_parse_token_string_t mempool_help_mempool =3D > + TOKEN_STRING_INITIALIZER(struct mempool_help_cmd_tokens, mempool,= "mempool"); > + > +cmdline_parse_inst_t mempool_help_cmd_ctx =3D { > + .f =3D cli_mempool_help, > + .data =3D NULL, > + .help_str =3D "", > + .tokens =3D { > + (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 =3D 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 | > +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D+=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D+=3D=3D=3D=3D=3D=3D=3D=3D=3D+=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D+ > + | | 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 he= lp | Yes | Yes | > + | | | message. = | | | > | | = | | | > +--------------------------------------+-----------------------------= ------+---------+----------+ > > -- > 2.25.1 >