From patchwork Thu Jul 28 15:11:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cristian Dumitrescu X-Patchwork-Id: 114368 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 99A39A00C5; Thu, 28 Jul 2022 17:13:38 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E64D842C18; Thu, 28 Jul 2022 17:12:12 +0200 (CEST) Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by mails.dpdk.org (Postfix) with ESMTP id C84C742BE1 for ; Thu, 28 Jul 2022 17:12:08 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1659021129; x=1690557129; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=HmDg1AR982LIltOn9SqBqacO17+vmGA8gmgWNPsCCAk=; b=Htx2YP0ae8reaTfYEqCxd6mSjhPHG/h2uKq5zsBsahLPVAAjpBg1HYa3 retTxbDcdG0s2p0mdP5FyQPfZxg50bV6SSXqXSjlGQsTgW5OGrxPZQdS/ knobWYmdahg6+rs+Mi+uQruHKRuX/ik8umJR/2VTYk2h6wOdlTiHfXrZu o9qdatNiPH7ZM2COWi8fzZYF5gHG2+jSBSoDlApnqaWAyYqX5kbYobjVR wb+5/CA8+jSzPKSG/YTNjY1xOmix6xpdyzxxMeiCDky9NJgA/TPykbkjq 8M1iAClBjdvYaoWnODDNZoiV2QKtu8ZsJ0c3k7dwo16PUDJpz9dDTBUGT g==; X-IronPort-AV: E=McAfee;i="6400,9594,10422"; a="288547428" X-IronPort-AV: E=Sophos;i="5.93,198,1654585200"; d="scan'208";a="288547428" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Jul 2022 08:12:07 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.93,198,1654585200"; d="scan'208";a="633727381" Received: from silpixa00400573.ir.intel.com (HELO silpixa00400573.ger.corp.intel.com.) ([10.237.223.157]) by orsmga001.jf.intel.com with ESMTP; 28 Jul 2022 08:12:06 -0700 From: Cristian Dumitrescu To: dev@dpdk.org Cc: "Kamalakannan R ." Subject: [PATCH V6 15/17] examples/pipeline: rework the link CLI command Date: Thu, 28 Jul 2022 15:11:45 +0000 Message-Id: <20220728151147.603265-16-cristian.dumitrescu@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220728151147.603265-1-cristian.dumitrescu@intel.com> References: <20220718130713.339003-1-cristian.dumitrescu@intel.com> <20220728151147.603265-1-cristian.dumitrescu@intel.com> MIME-Version: 1.0 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;