From patchwork Mon Mar 21 14:07:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Huzaifa696 X-Patchwork-Id: 108803 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 B2B21A04FF; Tue, 22 Mar 2022 10:26:31 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C6BBF427FD; Tue, 22 Mar 2022 10:26:17 +0100 (CET) Received: from mail-ed1-f51.google.com (mail-ed1-f51.google.com [209.85.208.51]) by mails.dpdk.org (Postfix) with ESMTP id 07C994161A for ; Mon, 21 Mar 2022 15:08:42 +0100 (CET) Received: by mail-ed1-f51.google.com with SMTP id h13so17998139ede.5 for ; Mon, 21 Mar 2022 07:08:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=Ds/Xy8iZqT49Fdd7nXfzM3x3gsgoEsr5EAMJi4xmZls=; b=jHzFn5appSpQe89AxM2XS4SLdBKS3NuLHIyYTypk5TuQvPFIVFZzubC6C/8qLInk+O PVSUYxcEItfSceffg0CaOe9eC54MlkSt7bDXPGysDY8MH/2m12avUoxJxYkkHOx5fBQ2 pfJQd00rO3I2FIh+Rmmq+V++JPhnzTGeUVsAatYv/rVBOzb/lxSYq4Mgn8jpuCfAUr1j 4f3YCk6Wm4asSQvkP/tgMqxKj5DdKwQWLGRnXudsgYWPzjnOZaCZk30D/9vklwwcUnE0 Zw4JgbfQKep1TiBiIfDTE8rovR0aF2vv3WYJnE7igpb+GGsADDlA44jDWIkCcrafpatm tRBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=Ds/Xy8iZqT49Fdd7nXfzM3x3gsgoEsr5EAMJi4xmZls=; b=EId5fJPYf+ideg4PGtHwLmQU8punWootZQ3jcBhlQj+qtykee/9SXnE5+l1lZUIpAZ vbU5qnvEumpZ52vYpIdSkXUEJ3NdWUZHg225/SjDump+nlZxPQeQ/eIIYufGJqRXhKXj fKHKGBTHhIbsN3l+SET8lrCH0U9LG10B8UCeIhu29SWKg5j0ledMVpcB1x/5uPnxBl4K gDxcZDDVBP19NBBq3X/EsjebBWKV6TW9aLDJKv4cbhuReQH4V6YwyfWB6It4cVF4ZZYj PnQQMLk2aNgDJdYrFFDW30LXu0ZCoQsusAsgtw62DHnrltaHI7eo2RT+S0qE/W/L5Pde Dtgw== X-Gm-Message-State: AOAM531v5GNcgnD8CVOFJ6EtF83OYgb8fESWgNAq4Mkwze7EClwkWv+i /yd3Y6N31zBp6dIPSZyf6fShjc4KN/wJ2g== X-Google-Smtp-Source: ABdhPJwgb2xlSGmv7m/1koiOfvDUiDeU2uy/r5czsMwPKxiR19gxNtt+OxtwmdVmCPmIGQA4/be45w== X-Received: by 2002:a05:6402:368d:b0:419:31c4:4db8 with SMTP id ej13-20020a056402368d00b0041931c44db8mr7230957edb.93.1647871721254; Mon, 21 Mar 2022 07:08:41 -0700 (PDT) Received: from localhost.localdomain ([39.50.109.105]) by smtp.gmail.com with ESMTPSA id o5-20020a170906974500b006dfc781498dsm3605394ejy.37.2022.03.21.07.08.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Mar 2022 07:08:40 -0700 (PDT) From: Huzaifa696 X-Google-Original-From: Huzaifa696 To: dev@dpdk.org Cc: Huzaifa696 Subject: [PATCH] ethtool: added list command to list all available commands Date: Mon, 21 Mar 2022 19:07:18 +0500 Message-Id: <20220321140718.82578-1-huzaifa.rehman696@gmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Mailman-Approved-At: Tue, 22 Mar 2022 10:26:13 +0100 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 help command is needed so user can see all the available commands directly from the command line along with the formats. Signed-off-by: Huzaifa696 --- doc/guides/sample_app_ug/ethtool.rst | 1 + examples/ethtool/ethtool-app/ethapp.c | 38 +++++++++++++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/doc/guides/sample_app_ug/ethtool.rst b/doc/guides/sample_app_ug/ethtool.rst index 159e9e0639..6e57015170 100644 --- a/doc/guides/sample_app_ug/ethtool.rst +++ b/doc/guides/sample_app_ug/ethtool.rst @@ -58,6 +58,7 @@ they do as follows: * ``validate``: Check that given MAC address is valid unicast address * ``vlan``: Add/remove VLAN id * ``quit``: Exit program +* ``help``: List all available commands Explanation diff --git a/examples/ethtool/ethtool-app/ethapp.c b/examples/ethtool/ethtool-app/ethapp.c index 78e86534e8..361e2daf9b 100644 --- a/examples/ethtool/ethtool-app/ethapp.c +++ b/examples/ethtool/ethtool-app/ethapp.c @@ -57,6 +57,8 @@ cmdline_parse_token_string_t pcmd_stats_token_cmd = TOKEN_STRING_INITIALIZER(struct pcmd_get_params, cmd, "stats"); cmdline_parse_token_string_t pcmd_drvinfo_token_cmd = TOKEN_STRING_INITIALIZER(struct pcmd_get_params, cmd, "drvinfo"); +cmdline_parse_token_string_t pcmd_list_token_cmd = + TOKEN_STRING_INITIALIZER(struct pcmd_get_params, cmd, "help"); cmdline_parse_token_string_t pcmd_link_token_cmd = TOKEN_STRING_INITIALIZER(struct pcmd_get_params, cmd, "link"); @@ -133,6 +135,11 @@ cmdline_parse_token_string_t pcmd_vlan_token_mode = cmdline_parse_token_num_t pcmd_vlan_token_vid = TOKEN_NUM_INITIALIZER(struct pcmd_vlan_params, vid, RTE_UINT16); +void +list_cmd(unsigned int sr, const char *name, const char *format, const char *description) +{ + printf("%-4d%-17s%-45s%-50s\n", sr, name, format, description); +} static void pcmd_quit_callback(__rte_unused void *ptr_params, @@ -142,6 +149,30 @@ pcmd_quit_callback(__rte_unused void *ptr_params, cmdline_quit(ctx); } +static void +pcmd_list_callback(__rte_unused void *ptr_params, + struct cmdline *ctx, + __rte_unused void *ptr_data) +{ + printf("%-4s%-17s%-45s%-50s\n\n", "Sr.", "Name", "Format", "Description"); + list_cmd(1, "drvinfo", "drvinfo", "Print driver info"); + list_cmd(2, "open", "open ", "Open port"); + list_cmd(3, "pause", "pause ", "Get/set port pause state"); + list_cmd(4, "stop", "stop ", "Stop port"); + list_cmd(5, "portstats", "portstats ", "Print port statistics"); + list_cmd(6, "link", "link", "Print port link states"); + list_cmd(7, "macaddr", "macaddr ", "Gets/sets MAC address"); + list_cmd(8, "mtu", "mtu ", "Set NIC MTU"); + list_cmd(9, "regs", "regs ", "Dump port register(s) to file"); + list_cmd(10, "ringparam", "ringparam ", "Get/set ring parameters"); + list_cmd(11, "rxmode", "rxmode ", "Toggle port Rx mode"); + list_cmd(12, "validate", "validate ", "Check that given MAC address is valid unicast address"); + list_cmd(13, "vlan", "vlan ", "Add/remove VLAN id"); + list_cmd(14, "eeprom", "eeprom ", "Dump EEPROM to file"); + list_cmd(15, "module-eeprom", "module-eeprom ", "Dump plugin module EEPROM to file"); + list_cmd(16, "quit", "quit", "Exit program"); + list_cmd(17, "help", "help", "List all available commands"); +} static void pcmd_drvinfo_callback(__rte_unused void *ptr_params, @@ -680,6 +711,12 @@ cmdline_parse_inst_t pcmd_drvinfo = { .help_str = "drvinfo\n Print driver info", .tokens = {(void *)&pcmd_drvinfo_token_cmd, NULL}, }; +cmdline_parse_inst_t pcmd_list_cmds = { + .f = pcmd_list_callback, + .data = NULL, + .help_str = "help\n List all available commands", + .tokens = {(void *)&pcmd_list_token_cmd, NULL}, +}; cmdline_parse_inst_t pcmd_link = { .f = pcmd_link_callback, .data = NULL, @@ -871,6 +908,7 @@ cmdline_parse_inst_t pcmd_vlan = { cmdline_parse_ctx_t list_prompt_commands[] = { + (cmdline_parse_inst_t *)&pcmd_list_cmds, (cmdline_parse_inst_t *)&pcmd_drvinfo, (cmdline_parse_inst_t *)&pcmd_eeprom, (cmdline_parse_inst_t *)&pcmd_module_eeprom,