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 AF876A04FF; Mon, 21 Mar 2022 15:26:07 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9BA88427E9; Mon, 21 Mar 2022 15:26:07 +0100 (CET) Received: from mail-wr1-f48.google.com (mail-wr1-f48.google.com [209.85.221.48]) by mails.dpdk.org (Postfix) with ESMTP id 5761E4161A for ; Mon, 21 Mar 2022 15:26:07 +0100 (CET) Received: by mail-wr1-f48.google.com with SMTP id v22so7025208wra.2 for ; Mon, 21 Mar 2022 07:26:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=emumba-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=bVsXm0LVa1UqBGGt6MpdRXU9xDrf2sgKqhlTchCUZzM=; b=Kw3H8kxtsQYFv9sISazalZ0CruE78tV3beRpVjITh1+K+mRtYagJ8j6gdpEh+92oql dQFrVb3wBTqfTP7LDLRrEjqGllUZPy53vzUtQAi3BCcmF91APJtvJaZtuj71B/uKqT27 BpT7GArX50Tcb3Ij6cmykAPiYTDdQBEpYS41GTJiMvzHOEKz5MWjq723qCSrlq3VWNa2 /lku+uxbvRjlFinFbqCYp6F0xyqA4BUx7LL0AVtsrvOb7u4Nxfn4rb1UHY5RCgAz4U3U nB02Bu/WRSK3EKZesXldwlb0+/VnVlnzub8Hp10biI3gM/PE2rWevONObEKMmnCjnGfm I0Mw== 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=bVsXm0LVa1UqBGGt6MpdRXU9xDrf2sgKqhlTchCUZzM=; b=YJAAc7HbwID+FKItD37bXK6KSwkNX2duXv0d4bV0xfza2BsDjhEI0s7s+mF2WrR5f9 kXomeCW2sPivYxXADXdsGdVcJucfm6zhZBsC4IA/wrSGsbrpjtV6n7Jchd3UXUMAx5mV /MGBM8hhEuf3EdfnVvWNtdUZXM8xUTSFxJINuJd31Fdw7tMJG8SyoU6iplbeHE5Xe/DV sdlpARGT6SMV2JX7oBaNiNQx/pPsiuZ/hB/Xz0m2/XaWlUR/pZkieXs7cHJ8YaFJlEH2 OH3LwGHB2/KReoNhRkBMyAU2LUToB806jiY+RgXF0wsbsacwxYTTb5njY974De2N+8BG NpQA== X-Gm-Message-State: AOAM533AWI+ZmiXl1S/iXbNqdjRFhw3C8UqpDmlJARblBPePospHxH/g jpnBqDkH9wow7A/FRFHsNno3q5qy9EBr2A== X-Google-Smtp-Source: ABdhPJzJ8WvBrz2yeDJUgfZ+WA4yNnwdUgZqdFaPZKsoe9D6mUm4MLRWB905R9NbKZVl/B8H1EOiXQ== X-Received: by 2002:a05:6000:18a7:b0:204:1bc0:45a with SMTP id b7-20020a05600018a700b002041bc0045amr2041265wri.119.1647872766847; Mon, 21 Mar 2022 07:26:06 -0700 (PDT) Received: from localhost.localdomain ([39.50.109.105]) by smtp.gmail.com with ESMTPSA id m185-20020a1ca3c2000000b0038c836a5c13sm10417669wme.20.2022.03.21.07.26.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Mar 2022 07:26:06 -0700 (PDT) From: "huzaifa.rahman" To: dev@dpdk.org Cc: Huzaifa696 Subject: [PATCH] ethtool: added list command to list all available commands Date: Mon, 21 Mar 2022 19:25:47 +0500 Message-Id: <20220321142547.82966-1-huzaifa.rahman@emumba.com> X-Mailer: git-send-email 2.25.1 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 From: Huzaifa696 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, -- 2.25.1