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 5DFA7A00C4; Thu, 28 Jul 2022 00:38:08 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6280542BAD; Thu, 28 Jul 2022 00:37:05 +0200 (CEST) Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by mails.dpdk.org (Postfix) with ESMTP id 1512642B9B for ; Thu, 28 Jul 2022 00:36:56 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1658961417; x=1690497417; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=HmDg1AR982LIltOn9SqBqacO17+vmGA8gmgWNPsCCAk=; b=b+K98+rUiIDZiTBoQGxpZ8uEywtARwJz92wv3QUUzY14o7AFQiF6VITc sQJ6g+FjCPIAHjUPC/vwBFb/cDodIlD8OHzOcbCrzgKeelXoWJHadO4Sl 3gH2qJoBvFeQQIf3qNbSBiaURUA7hpdtIRpMngHFzjN5ecuddRK0JDxD5 68ZLPuRL+lrme06wG2gcPcQ7MAWebD9vrljgdDrdf3owyKW7qgqx0wS3K zV5OUyxuptU/oIewJ4BIWOZaaMucO7B8VnCjrYp9xZ0dN1Iyhy/f0Ytan DtG3vE/CIr4gilc09ZxJfO5vmZ792Jd5qb+/ePyY90UCpQ8Qr4Zzv4+GZ Q==; X-IronPort-AV: E=McAfee;i="6400,9594,10421"; a="350068853" X-IronPort-AV: E=Sophos;i="5.93,196,1654585200"; d="scan'208";a="350068853" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Jul 2022 15:36:56 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.93,196,1654585200"; d="scan'208";a="628567684" Received: from silpixa00400573.ir.intel.com (HELO silpixa00400573.ger.corp.intel.com.) ([10.237.223.157]) by orsmga008.jf.intel.com with ESMTP; 27 Jul 2022 15:36:55 -0700 From: Cristian Dumitrescu To: dev@dpdk.org Cc: "Kamalakannan R ." Subject: [PATCH V3 15/17] examples/pipeline: rework the link CLI command Date: Wed, 27 Jul 2022 22:36:37 +0000 Message-Id: <20220727223639.598932-15-cristian.dumitrescu@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220727223639.598932-1-cristian.dumitrescu@intel.com> References: <20220718132603.339314-1-cristian.dumitrescu@intel.com> <20220727223639.598932-1-cristian.dumitrescu@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 Rework the link CLI command for better alignment with the naming conventions used in the pipeline I/O specification file. Use the library linked list of devices and remove the application list. Signed-off-by: Cristian Dumitrescu Signed-off-by: Kamalakannan R. --- examples/pipeline/cli.c | 81 +++++++++++++---------------------------- examples/pipeline/obj.c | 16 ++------ examples/pipeline/obj.h | 4 -- 3 files changed, 29 insertions(+), 72 deletions(-) diff --git a/examples/pipeline/cli.c b/examples/pipeline/cli.c index f48ff326be..d56a830fb7 100644 --- a/examples/pipeline/cli.c +++ b/examples/pipeline/cli.c @@ -106,22 +106,6 @@ parser_read_uint32(uint32_t *value, const char *p) return 0; } -static int -parser_read_uint16(uint16_t *value, const char *p) -{ - uint64_t val = 0; - int ret = parser_read_uint64(&val, p); - - if (ret < 0) - return ret; - - if (val > UINT16_MAX) - return -ERANGE; - - *value = val; - return 0; -} - #define PARSE_DELIMITER " \f\n\r\t\v" static int @@ -230,16 +214,15 @@ cmd_mempool(char **tokens, } } -static const char cmd_link_help[] = -"link \n" -" dev | port \n" +static const char cmd_ethdev_help[] = +"ethdev \n" " rxq \n" " txq \n" " promiscuous on | off\n" " [rss ... ]\n"; static void -cmd_link(char **tokens, +cmd_ethdev(char **tokens, uint32_t n_tokens, char *out, size_t out_size, @@ -252,65 +235,51 @@ cmd_link(char **tokens, memset(&p, 0, sizeof(p)); - if ((n_tokens < 13) || (n_tokens > 14 + LINK_RXQ_RSS_MAX)) { + if ((n_tokens < 11) || (n_tokens > 12 + LINK_RXQ_RSS_MAX)) { snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]); return; } name = tokens[1]; - if (strcmp(tokens[2], "dev") == 0) - p.dev_name = tokens[3]; - else if (strcmp(tokens[2], "port") == 0) { - p.dev_name = NULL; - - if (parser_read_uint16(&p.port_id, tokens[3]) != 0) { - snprintf(out, out_size, MSG_ARG_INVALID, "port_id"); - return; - } - } else { - snprintf(out, out_size, MSG_ARG_NOT_FOUND, "dev or port"); - return; - } - - if (strcmp(tokens[4], "rxq") != 0) { + if (strcmp(tokens[2], "rxq") != 0) { snprintf(out, out_size, MSG_ARG_NOT_FOUND, "rxq"); return; } - if (parser_read_uint32(&p.rx.n_queues, tokens[5]) != 0) { + if (parser_read_uint32(&p.rx.n_queues, tokens[3]) != 0) { snprintf(out, out_size, MSG_ARG_INVALID, "n_queues"); return; } - if (parser_read_uint32(&p.rx.queue_size, tokens[6]) != 0) { + if (parser_read_uint32(&p.rx.queue_size, tokens[4]) != 0) { snprintf(out, out_size, MSG_ARG_INVALID, "queue_size"); return; } - p.rx.mempool_name = tokens[7]; + p.rx.mempool_name = tokens[5]; - if (strcmp(tokens[8], "txq") != 0) { + if (strcmp(tokens[6], "txq") != 0) { snprintf(out, out_size, MSG_ARG_NOT_FOUND, "txq"); return; } - if (parser_read_uint32(&p.tx.n_queues, tokens[9]) != 0) { + if (parser_read_uint32(&p.tx.n_queues, tokens[7]) != 0) { snprintf(out, out_size, MSG_ARG_INVALID, "n_queues"); return; } - if (parser_read_uint32(&p.tx.queue_size, tokens[10]) != 0) { + if (parser_read_uint32(&p.tx.queue_size, tokens[8]) != 0) { snprintf(out, out_size, MSG_ARG_INVALID, "queue_size"); return; } - if (strcmp(tokens[11], "promiscuous") != 0) { + if (strcmp(tokens[9], "promiscuous") != 0) { snprintf(out, out_size, MSG_ARG_NOT_FOUND, "promiscuous"); return; } - if (strcmp(tokens[12], "on") == 0) + if (strcmp(tokens[10], "on") == 0) p.promiscuous = 1; - else if (strcmp(tokens[12], "off") == 0) + else if (strcmp(tokens[10], "off") == 0) p.promiscuous = 0; else { snprintf(out, out_size, MSG_ARG_NOT_FOUND, "on or off"); @@ -319,10 +288,10 @@ cmd_link(char **tokens, /* RSS */ p.rx.rss = NULL; - if (n_tokens > 13) { + if (n_tokens > 11) { uint32_t queue_id, i; - if (strcmp(tokens[13], "rss") != 0) { + if (strcmp(tokens[11], "rss") != 0) { snprintf(out, out_size, MSG_ARG_NOT_FOUND, "rss"); return; } @@ -330,7 +299,7 @@ cmd_link(char **tokens, p.rx.rss = &rss; rss.n_queues = 0; - for (i = 14; i < n_tokens; i++) { + for (i = 12; i < n_tokens; i++) { if (parser_read_uint32(&queue_id, tokens[i]) != 0) { snprintf(out, out_size, MSG_ARG_INVALID, "queue_id"); @@ -406,10 +375,10 @@ print_link_info(struct link *link, char *out, size_t out_size) } /* - * link show [] + * ethdev show [] */ static void -cmd_link_show(char **tokens, +cmd_ethdev_show(char **tokens, uint32_t n_tokens, char *out, size_t out_size, @@ -2675,7 +2644,7 @@ cmd_help(char **tokens, "Type 'help ' for command details.\n\n" "List of commands:\n" "\tmempool\n" - "\tlink\n" + "\tethdev\n" "\ttap\n" "\tpipeline codegen\n" "\tpipeline libbuild\n" @@ -2711,8 +2680,8 @@ cmd_help(char **tokens, return; } - if (strcmp(tokens[0], "link") == 0) { - snprintf(out, out_size, "\n%s\n", cmd_link_help); + if (strcmp(tokens[0], "ethdev") == 0) { + snprintf(out, out_size, "\n%s\n", cmd_ethdev_help); return; } @@ -2966,13 +2935,13 @@ cli_process(char *in, char *out, size_t out_size, void *obj) return; } - if (strcmp(tokens[0], "link") == 0) { + if (strcmp(tokens[0], "ethdev") == 0) { if ((n_tokens >= 2) && (strcmp(tokens[1], "show") == 0)) { - cmd_link_show(tokens, n_tokens, out, out_size, obj); + cmd_ethdev_show(tokens, n_tokens, out, out_size, obj); return; } - cmd_link(tokens, n_tokens, out, out_size, obj); + cmd_ethdev(tokens, n_tokens, out, out_size, obj); return; } diff --git a/examples/pipeline/obj.c b/examples/pipeline/obj.c index d1f519180e..950ab831fb 100644 --- a/examples/pipeline/obj.c +++ b/examples/pipeline/obj.c @@ -181,7 +181,7 @@ link_create(struct obj *obj, const char *name, struct link_params *params) struct mempool *mempool; uint32_t cpu_id, i; int status; - uint16_t port_id; + uint16_t port_id = 0; /* Check input params */ if ((name == NULL) || @@ -193,16 +193,9 @@ link_create(struct obj *obj, const char *name, struct link_params *params) (params->tx.queue_size == 0)) return NULL; - port_id = params->port_id; - if (params->dev_name) { - status = rte_eth_dev_get_port_by_name(params->dev_name, - &port_id); - - if (status) - return NULL; - } else - if (!rte_eth_dev_is_valid_port(port_id)) - return NULL; + status = rte_eth_dev_get_port_by_name(name, &port_id); + if (status) + return NULL; if (rte_eth_dev_info_get(port_id, &port_info) != 0) return NULL; @@ -315,7 +308,6 @@ link_create(struct obj *obj, const char *name, struct link_params *params) /* Node fill in */ strlcpy(link->name, name, sizeof(link->name)); link->port_id = port_id; - rte_eth_dev_get_name_by_port(port_id, link->dev_name); link->n_rxq = params->rx.n_queues; link->n_txq = params->tx.n_queues; diff --git a/examples/pipeline/obj.h b/examples/pipeline/obj.h index e63a9c0e9a..af270a8e57 100644 --- a/examples/pipeline/obj.h +++ b/examples/pipeline/obj.h @@ -63,9 +63,6 @@ struct link_params_rss { }; struct link_params { - const char *dev_name; - uint16_t port_id; /**< Valid only when *dev_name* is NULL. */ - struct { uint32_t n_queues; uint32_t queue_size; @@ -84,7 +81,6 @@ struct link_params { struct link { TAILQ_ENTRY(link) node; char name[NAME_SIZE]; - char dev_name[NAME_SIZE]; uint16_t port_id; uint32_t n_rxq; uint32_t n_txq; -- 2.34.1