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 28961431DE; Mon, 23 Oct 2023 09:06:03 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 14683402D9; Mon, 23 Oct 2023 09:06:03 +0200 (CEST) Received: from mail-qt1-f174.google.com (mail-qt1-f174.google.com [209.85.160.174]) by mails.dpdk.org (Postfix) with ESMTP id 5CAF4402D9 for ; Mon, 23 Oct 2023 09:06:02 +0200 (CEST) Received: by mail-qt1-f174.google.com with SMTP id d75a77b69052e-41cbd1d7e04so18149531cf.1 for ; Mon, 23 Oct 2023 00:06:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1698044762; x=1698649562; 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=KciKHsWKPwbETN8QeB22lGsvNARectRRQfY5epd5rNI=; b=A92LZg+JX06flQuhCbuevlx/xC6Y4wYc9S5fxSfZmpc5OYwn9TNoI2cHgWWq3MipFc Kqs8IyWNP0ij2uLeSaC6CVPOFD4SK2yPy18tx5Io0GHeRoe8N4y5a55WGC+8NsIF3sQn WW0jukX/xk2FzXuOGqq5WINEYC8+YbZgco7fP4H8f3w/PSRugjAmc25dYJlimj1bbre5 DEAFm3/BvCWnTwTddj3RmQCAnhwFZip83ktPr7Lrpbx2Y4K2Dp+89iw0obXZnJpX3H/x u7mN4GII6ZkP7M3WuMtJdWPk2SndOL95N1jQwS/1xQ87YjeTW91sJ4HPPfhnQidtNgtW mBTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698044762; x=1698649562; 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=KciKHsWKPwbETN8QeB22lGsvNARectRRQfY5epd5rNI=; b=R2XTAyAoPfbXj1DORkpqcfwYwFKwbY8tg3/sPzyX4a3wYc7My2/49TteuFHNzsN/UG hrAelXvgnTJITMlZj6xcj2ag23gDKGam4TQo1qpOUIhH+JwuPkpLSoHhlPG8OfNPi6aN Ti5y1ERQz+J2PDO5RvKH39TH2GE14qMxPVcJMoYBysQQxpF5sMOCCF45Bly+QBaDLO25 hpplTLg5cmSwI6N7jMpOWxaPGPQRy6iLNREfn6u150jxXHzdU9FZEEamMcOBkTwTJbYT I6fKwEYq2oobBIC2YjSHkWvVwjXr6al3IGP82azXYt1XxtCh//hr5gLxMivL9Ne3GTor oXIw== X-Gm-Message-State: AOJu0YxLic9QmdZCfgekRxGrt9qkBleG0m6mgwZQvVIY2VgEDOocB1v/ bZILeGFVb2w8WPIxd1P1hzxOuruB+Ki8CzRj7AybO4qUzHM= X-Google-Smtp-Source: AGHT+IHiK9JXtQynCE0BmYztlRSZQy+dNJ2t/yiwh5vUr6GHX5aEkOUgBef8qDhwp4Xt3WUSbpM3TNHfnF0X2XjrVj0= X-Received: by 2002:a05:622a:303:b0:418:eee:15fb with SMTP id q3-20020a05622a030300b004180eee15fbmr10251415qtw.5.1698044761677; Mon, 23 Oct 2023 00:06:01 -0700 (PDT) MIME-Version: 1.0 References: <20231019105000.520914-13-skori@marvell.com> <20231019173011.1186656-1-skori@marvell.com> <20231019173011.1186656-10-skori@marvell.com> In-Reply-To: <20231019173011.1186656-10-skori@marvell.com> From: Nithin Dabilpuram Date: Mon, 23 Oct 2023 12:35:49 +0530 Message-ID: Subject: Re: [PATCH v11 09/12] app/graph: support ethdev Rx command line interfaces To: skori@marvell.com Cc: Rakesh Kudurumalla , dev@dpdk.org 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 Fri, Oct 20, 2023 at 1:27=E2=80=AFAM wrote: > > From: Rakesh Kudurumalla > > Adds ethdev_rx module to create port-queue-core mapping. > > Mapping will be used to launch graph worker thread and dequeue > packets on mentioned core from desired port/queue. > > Following commands are exposed: > - ethdev_rx map port queue core > - help ethdev_rx > > Signed-off-by: Sunil Kumar Kori > Signed-off-by: Rakesh Kudurumalla > --- > app/graph/cli.c | 2 + > app/graph/ethdev_rx.c | 165 +++++++++++++++++++++++++++++++++++++ > app/graph/ethdev_rx.h | 37 +++++++++ > app/graph/ethdev_rx_priv.h | 39 +++++++++ > app/graph/meson.build | 1 + > app/graph/module_api.h | 1 + > doc/guides/tools/graph.rst | 10 +++ > 7 files changed, 255 insertions(+) > create mode 100644 app/graph/ethdev_rx.c > create mode 100644 app/graph/ethdev_rx.h > create mode 100644 app/graph/ethdev_rx_priv.h > > diff --git a/app/graph/cli.c b/app/graph/cli.c > index f564362da1..ad7d7deadf 100644 > --- a/app/graph/cli.c > +++ b/app/graph/cli.c > @@ -30,6 +30,8 @@ cmdline_parse_ctx_t modules_ctx[] =3D { > (cmdline_parse_inst_t *)ðdev_ip6_cmd_ctx, > (cmdline_parse_inst_t *)ðdev_cmd_ctx, > (cmdline_parse_inst_t *)ðdev_help_cmd_ctx, > + (cmdline_parse_inst_t *)ðdev_rx_cmd_ctx, > + (cmdline_parse_inst_t *)ðdev_rx_help_cmd_ctx, > (cmdline_parse_inst_t *)&ipv4_lookup_cmd_ctx, > (cmdline_parse_inst_t *)&ipv4_lookup_help_cmd_ctx, > (cmdline_parse_inst_t *)&ipv6_lookup_cmd_ctx, > diff --git a/app/graph/ethdev_rx.c b/app/graph/ethdev_rx.c > new file mode 100644 > index 0000000000..f2cb8cf9a5 > --- /dev/null > +++ b/app/graph/ethdev_rx.c > @@ -0,0 +1,165 @@ > +/* SPDX-License-Identifier: BSD-3-Clause > + * Copyright(c) 2023 Marvell. > + */ > + > +#include > +#include > + > +#include > +#include > +#include > +#include > +#include > + > +#include "ethdev_rx_priv.h" > +#include "module_api.h" > + > +static const char > +cmd_ethdev_rx_help[] =3D "ethdev_rx map port queue = core "; > + > +static struct lcore_params lcore_params_array[ETHDEV_RX_LCORE_PARAMS_MAX= ]; > +struct rte_node_ethdev_config ethdev_conf[RTE_MAX_ETHPORTS]; > +struct lcore_params *lcore_params =3D lcore_params_array; > +struct lcore_conf lcore_conf[RTE_MAX_LCORE]; > +uint16_t nb_lcore_params; > + > +static void > +rx_map_configure(uint8_t port_id, uint32_t queue, uint32_t core) > +{ > + uint8_t n_rx_queue; > + > + n_rx_queue =3D lcore_conf[core].n_rx_queue; > + lcore_conf[core].rx_queue_list[n_rx_queue].port_id =3D port_id; > + lcore_conf[core].rx_queue_list[n_rx_queue].queue_id =3D queue; > + lcore_conf[core].n_rx_queue++; > +} > + > +uint8_t > +ethdev_rx_num_rx_queues_get(uint16_t port) > +{ > + int queue =3D -1; > + uint16_t i; > + > + for (i =3D 0; i < nb_lcore_params; ++i) { > + if (lcore_params[i].port_id =3D=3D port) { > + if (lcore_params[i].queue_id =3D=3D queue + 1) > + queue =3D lcore_params[i].queue_id; > + else > + rte_exit(EXIT_FAILURE, > + "Queue ids of the port %d must b= e" > + " in sequence and must start wit= h 0\n", > + lcore_params[i].port_id); > + } > + } > + > + return (uint8_t)(++queue); > +} > + > +static int > +ethdev_rx_map_add(char *name, uint32_t queue, uint32_t core) > +{ > + uint64_t coremask; > + uint16_t port_id; > + int rc; > + > + if (nb_lcore_params >=3D ETHDEV_RX_LCORE_PARAMS_MAX) > + return -EINVAL; > + > + rc =3D rte_eth_dev_get_port_by_name(name, &port_id); > + if (rc) > + return -EINVAL; > + > + coremask =3D 0xff; /* FIXME: Read from graph configuration */ > + > + if (!(coremask & (1 << core))) > + return -EINVAL; > + > + rx_map_configure(port_id, queue, core); > + > + lcore_params_array[nb_lcore_params].port_id =3D port_id; > + lcore_params_array[nb_lcore_params].queue_id =3D queue; > + lcore_params_array[nb_lcore_params].lcore_id =3D core; > + nb_lcore_params++; > + return 0; > +} > + > +static void > +cli_ethdev_rx_help(__rte_unused void *parsed_result, __rte_unused struct= cmdline *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", > + "----------------------------- ethdev_rx command help --= ---------------------------", > + cmd_ethdev_rx_help); > + > + len =3D strlen(conn->msg_out); > + conn->msg_out_len_max -=3D len; > +} > + > +static void > +cli_ethdev_rx(void *parsed_result, __rte_unused struct cmdline *cl, void= *data __rte_unused) > +{ > + struct ethdev_rx_cmd_tokens *res =3D parsed_result; > + int rc =3D -EINVAL; > + > + rc =3D ethdev_rx_map_add(res->dev, res->qid, res->core_id); > + if (rc < 0) { > + cli_exit(); > + printf(MSG_CMD_FAIL, res->cmd); > + rte_exit(EXIT_FAILURE, "input core is Invalid\n"); > + } > + > +} > + > +cmdline_parse_token_string_t ethdev_rx_cmd =3D > + TOKEN_STRING_INITIALIZER(struct ethdev_rx_cmd_tokens, cmd, "ethde= v_rx"); > +cmdline_parse_token_string_t ethdev_rx_map =3D > + TOKEN_STRING_INITIALIZER(struct ethdev_rx_cmd_tokens, map, "map")= ; > +cmdline_parse_token_string_t ethdev_rx_port =3D > + TOKEN_STRING_INITIALIZER(struct ethdev_rx_cmd_tokens, port, "port= "); > +cmdline_parse_token_string_t ethdev_rx_dev =3D > + TOKEN_STRING_INITIALIZER(struct ethdev_rx_cmd_tokens, dev, NULL); > +cmdline_parse_token_string_t ethdev_rx_queue =3D > + TOKEN_STRING_INITIALIZER(struct ethdev_rx_cmd_tokens, queue, "que= ue"); > +cmdline_parse_token_num_t ethdev_rx_qid =3D > + TOKEN_NUM_INITIALIZER(struct ethdev_rx_cmd_tokens, qid, RTE_UINT3= 2); > +cmdline_parse_token_string_t ethdev_rx_core =3D > + TOKEN_STRING_INITIALIZER(struct ethdev_rx_cmd_tokens, core, "core= "); > +cmdline_parse_token_num_t ethdev_rx_core_id =3D > + TOKEN_NUM_INITIALIZER(struct ethdev_rx_cmd_tokens, core_id, RTE_U= INT32); > + > +cmdline_parse_inst_t ethdev_rx_cmd_ctx =3D { > + .f =3D cli_ethdev_rx, > + .data =3D NULL, > + .help_str =3D cmd_ethdev_rx_help, > + .tokens =3D { > + (void *)ðdev_rx_cmd, > + (void *)ðdev_rx_map, > + (void *)ðdev_rx_port, > + (void *)ðdev_rx_dev, > + (void *)ðdev_rx_queue, > + (void *)ðdev_rx_qid, > + (void *)ðdev_rx_core, > + (void *)ðdev_rx_core_id, > + NULL, > + }, > +}; > + > +cmdline_parse_token_string_t ethdev_rx_help_cmd =3D > + TOKEN_STRING_INITIALIZER(struct ethdev_rx_help_cmd_tokens, cmd, "= help"); > +cmdline_parse_token_string_t ethdev_rx_help_module =3D > + TOKEN_STRING_INITIALIZER(struct ethdev_rx_help_cmd_tokens, module= , "ethdev_rx"); > + > +cmdline_parse_inst_t ethdev_rx_help_cmd_ctx =3D { > + .f =3D cli_ethdev_rx_help, > + .data =3D NULL, > + .help_str =3D "", > + .tokens =3D { > + (void *)ðdev_rx_help_cmd, > + (void *)ðdev_rx_help_module, > + NULL, > + }, > +}; > diff --git a/app/graph/ethdev_rx.h b/app/graph/ethdev_rx.h > new file mode 100644 > index 0000000000..8e7b31448c > --- /dev/null > +++ b/app/graph/ethdev_rx.h > @@ -0,0 +1,37 @@ > +/* SPDX-License-Identifier: BSD-3-Clause > + * Copyright(c) 2023 Marvell. > + */ > + > +#ifndef APP_GRAPH_ETHDEV_RX_H > +#define APP_GRAPH_ETHDEV_RX_H > + > +#include > +#include > + > +#define ETHDEV_RX_LCORE_PARAMS_MAX 1024 > +#define ETHDEV_RX_QUEUE_PER_LCORE_MAX 16 > + > +struct lcore_rx_queue { > + uint16_t port_id; > + uint8_t queue_id; > + char node_name[RTE_NODE_NAMESIZE]; > +}; > + > +struct lcore_conf { > + uint16_t n_rx_queue; > + struct lcore_rx_queue rx_queue_list[ETHDEV_RX_QUEUE_PER_LCORE_MAX= ]; > + struct rte_graph *graph; > + char name[RTE_GRAPH_NAMESIZE]; > + rte_graph_t graph_id; > +} __rte_cache_aligned; > + > +uint8_t ethdev_rx_num_rx_queues_get(uint16_t port); > + > +extern struct rte_node_ethdev_config ethdev_conf[RTE_MAX_ETHPORTS]; > +extern struct lcore_conf lcore_conf[RTE_MAX_LCORE]; > +extern cmdline_parse_inst_t ethdev_rx_help_cmd_ctx; > +extern cmdline_parse_inst_t ethdev_rx_cmd_ctx; > +extern struct lcore_params *lcore_params; > +extern uint16_t nb_lcore_params; > + > +#endif > diff --git a/app/graph/ethdev_rx_priv.h b/app/graph/ethdev_rx_priv.h > new file mode 100644 > index 0000000000..5d155be043 > --- /dev/null > +++ b/app/graph/ethdev_rx_priv.h > @@ -0,0 +1,39 @@ > +/* SPDX-License-Identifier: BSD-3-Clause > + * Copyright(c) 2023 Marvell. > + */ > + > +#ifndef APP_GRAPH_ETHDEV_RX_PRIV_H > +#define APP_GRAPH_ETHDEV_RX_PRIV_H > + > +#include > + > +#include > +#include > + > +#define MAX_RX_QUEUE_PER_PORT 128 > +#define MAX_JUMBO_PKT_LEN 9600 > +#define NB_SOCKETS 8 > + > +struct ethdev_rx_cmd_tokens { > + cmdline_fixed_string_t cmd; > + cmdline_fixed_string_t map; > + cmdline_fixed_string_t port; > + cmdline_fixed_string_t dev; > + cmdline_fixed_string_t queue; > + cmdline_fixed_string_t core; > + uint32_t core_id; > + uint32_t qid; > +}; > + > +struct ethdev_rx_help_cmd_tokens { > + cmdline_fixed_string_t cmd; > + cmdline_fixed_string_t module; > +}; > + > +struct lcore_params { > + uint16_t port_id; > + uint8_t queue_id; > + uint8_t lcore_id; > +} __rte_cache_aligned; > + > +#endif > diff --git a/app/graph/meson.build b/app/graph/meson.build > index 8fa9d605b9..d8391d5cae 100644 > --- a/app/graph/meson.build > +++ b/app/graph/meson.build > @@ -12,6 +12,7 @@ deps +=3D ['graph', 'eal', 'lpm', 'ethdev', 'node', 'cm= dline'] > sources =3D files( > 'cli.c', > 'conn.c', > + 'ethdev_rx.c', > 'ethdev.c', > 'ip4_route.c', > 'ip6_route.c', > diff --git a/app/graph/module_api.h b/app/graph/module_api.h > index e9e42da7cc..56b7c94ecc 100644 > --- a/app/graph/module_api.h > +++ b/app/graph/module_api.h > @@ -11,6 +11,7 @@ > #include "cli.h" > #include "conn.h" > #include "ethdev.h" > +#include "ethdev_rx.h" > #include "mempool.h" > #include "neigh.h" > #include "route.h" > diff --git a/doc/guides/tools/graph.rst b/doc/guides/tools/graph.rst > index b1bd2e6048..318d92a0fb 100644 > --- a/doc/guides/tools/graph.rst > +++ b/doc/guides/tools/graph.rst > @@ -141,6 +141,16 @@ file to express the requested use case configuration= . > | help neigh | | Command to dump neigh help= | Yes | Yes | > | | | message. = | | | > +--------------------------------------+-----------------------------= ------+---------+----------+ > + | | ethdev_rx map port | | Command to add port-queue-= core | No | No | > + | | queue core | | mapping to ``ethdev_rx`` n= ode. | | | > + | | | ``ethdev_rx`` node instanc= e will| | | > + | | | be pinned on given core an= d will| | | > + | | | poll on requested port/que= ue | | | > + | | | pair. = | | | > + +--------------------------------------+-----------------------------= ------+---------+----------+ > + | help ethdev_rx | | Command to dump ethdev_rx = help | Yes | Yes | > + | | | message. = | | | > + +--------------------------------------+-----------------------------= ------+---------+----------+ > > Runtime configuration > --------------------- > -- > 2.25.1 >