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 7889042DC6; Tue, 4 Jul 2023 00:24:21 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0434C40F18; Tue, 4 Jul 2023 00:24:21 +0200 (CEST) Received: from mail-pf1-f179.google.com (mail-pf1-f179.google.com [209.85.210.179]) by mails.dpdk.org (Postfix) with ESMTP id 38EF940E03 for ; Tue, 4 Jul 2023 00:24:20 +0200 (CEST) Received: by mail-pf1-f179.google.com with SMTP id d2e1a72fcca58-666e3b15370so2725755b3a.0 for ; Mon, 03 Jul 2023 15:24:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20221208.gappssmtp.com; s=20221208; t=1688423059; x=1691015059; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=eEn+9Wx3Ye1l0SOCN5/mkOqNMHidKABEBaVgedf7lOM=; b=DRUBlutYraUdgnKOiP+vmkDeoSRqFCEPN8E8hs7xnXHcQC9hLNQfUmLyGoxL20PStH Ir7h1MIMfJkfrNOWIM2BM2JNxqwHN1KtRNAEUOTkPbNOBD8cMqOWQih4YCiGaMuz9ko9 eXMKE83VETEX4GNMGFe7K9c8DQA2te5rmbRwQ6aPUfwkrZKQ7y2Pai2kiCXZMPJY1qwe M71Vzj7zzKM5m3oMYRNfO1XpAsdlvWyZFwxtWOFpd7JEg7tLNxzsYNegaaWGIOWRT2aI UCyZeUJ2aEtAQjGacf4mJFxjhTatuTrknWbPSTwf/lvv7yunBE7KqqKnS5LN+1uZEmmR nyVw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688423059; x=1691015059; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=eEn+9Wx3Ye1l0SOCN5/mkOqNMHidKABEBaVgedf7lOM=; b=Vt13uYBMj+MOMktPzIirhpeuAqTk9EXSES6CS+4XrwyA66QFRQjw6C4FM7T12zTy69 Spxx+8znrGAR+lkxU10tVQo0wpG4EmzfyKSSmr5baKJ8ftiTgvL5wqd8YgjGB7ZKKAhW qecgkJuPyeNr+9FOnYDhE+8tKk+oAzLAKmAItBdShZBCkema2U6DtTJjBemmd/EPEOco RR+YAZ1A78+xrBKrxsEsXxfB4nzWSXpR4YRpB4yQ3UhcU3n476zQ/izUE2SMcnHVbWBw 8ZMfom/cVGxLJnMelWDUpqQpQ5X1aVnCxLJOv2uImUayR5MuHtza+VRTp1XcFNGYUckj Rn2A== X-Gm-Message-State: ABy/qLYQVxVN4SASXrgCZ+3Oql+SNXE6zM0lpp2higrwHAgciAxpuYqX h+B7ULjv0oGhLq3QMonYJZJ/QQ== X-Google-Smtp-Source: APBJJlEfo1uSC8tGmtyMBGcVNgHYbEf/RGfhnMFQkLn00DU9itz2BDjgeXQ2fHh+jDvM7lwIhroKsg== X-Received: by 2002:a05:6a00:139b:b0:679:bc89:e5b with SMTP id t27-20020a056a00139b00b00679bc890e5bmr12785148pfg.19.1688423059257; Mon, 03 Jul 2023 15:24:19 -0700 (PDT) Received: from hermes.local (204-195-120-218.wavecable.com. [204.195.120.218]) by smtp.gmail.com with ESMTPSA id t26-20020aa7939a000000b006702c433741sm13384470pfe.3.2023.07.03.15.24.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Jul 2023 15:24:18 -0700 (PDT) Date: Mon, 3 Jul 2023 15:24:16 -0700 From: Stephen Hemminger To: "huzaifa.rahman" Cc: dev@dpdk.org, Huzaifa696 Subject: Re: [PATCH] ethtool: added list command to list all available commands Message-ID: <20230703152416.1d9692c0@hermes.local> In-Reply-To: <20220321142547.82966-1-huzaifa.rahman@emumba.com> References: <20220321142547.82966-1-huzaifa.rahman@emumba.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit 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 On Mon, 21 Mar 2022 19:25:47 +0500 "huzaifa.rahman" wrote: > 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 Developer Certificate of Origin is intended to a legal assertion. Therefore you must use your legal name (not alias here). > --- > 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"); > +} I think with some additional programming effort. The help command could extract the existing help command strings for this.