From patchwork Tue Mar 22 09:36:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Huzaifa Rahman X-Patchwork-Id: 108804 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 12995A04FF; Tue, 22 Mar 2022 10:36:32 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 95995427ED; Tue, 22 Mar 2022 10:36:31 +0100 (CET) Received: from mail-ej1-f52.google.com (mail-ej1-f52.google.com [209.85.218.52]) by mails.dpdk.org (Postfix) with ESMTP id 59F6D410E5 for ; Tue, 22 Mar 2022 10:36:30 +0100 (CET) Received: by mail-ej1-f52.google.com with SMTP id a8so34916886ejc.8 for ; Tue, 22 Mar 2022 02:36:30 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=tC8bkszQPO2OMWhcybYGNVMqzO4b/9PHK9ZtU3dzZSA=; b=EOuH2shX6Jcv95/AjoLFLA432cupzHcqadXAgAxRTX3nPPMEvF0bIDlTF0o+G0lTw7 FXIYJJay0lWYuvRhoVSmfkwwwd8swcoj71QzGKZYTbdjR5mcAdgG1xaYsSnJYMhBBsjV 5vuZjlYIUv+FeGhWzhmjM8zmPjLz17f5O1pv4gdzhadC6XiXXZhLEpRt7aTrpsZjpw9V 3cWkcYjQcUzlGmIP7ywd+odnE8VJpPc2H1AbnZK1Niav9EguaxqbJaenR4HB4yoQj7OK oFMOLR7EfzxomZJnNuQtUU67pjRY75kPaeySiQi1Kt6ivDWWtiWdSCFtfQ59FT9DuzDd EH7Q== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=tC8bkszQPO2OMWhcybYGNVMqzO4b/9PHK9ZtU3dzZSA=; b=KxcbQbl4M6CvfnQkRVHCLXGXnJeYQu9q1WYXitwPjioBtrwEvUdxJyRiZLNMKAQXA5 hdocsFBAkVb3squrskFM6z+PR8XXNISP2LL074DVOpm/gw2lPS0alsnWKroyFLH/zgEc 9WF+f/9cRF2xFl5zrHR39eLz4Tb36088C5TNnmzOn2L3EaMwXAT5yFA3KeQDr6zMos// TOkS7Ielz14MiqSSe2XDAuGN/pV+0ws7oprM0M4upZ/XA1E/CXKdA6g27lf8xdhE1nn3 0l0I2iv3Mcmu6aH67YplsJidUYiDMf4sT+h8GD3eBOkVq/hq9SkBalDk0sObDqXhnfka 8LEg== X-Gm-Message-State: AOAM532/C/Jrzl2Xe//iaDzmWc1SPUyZlPP8l1tKuFrqn5MtwM+Qa9/e UA8i5A0+PgrbYojSpz2zqLVbCUDn/z3FUg== X-Google-Smtp-Source: ABdhPJyS9g4L8ocv+4bQMes1yUBxLffKXvZ9aA7smetHpgOzuovF5gOwbQZJIohydnQR/yYyU30C+Q== X-Received: by 2002:a17:907:608d:b0:6df:f79c:2e67 with SMTP id ht13-20020a170907608d00b006dff79c2e67mr10562462ejc.577.1647941789432; Tue, 22 Mar 2022 02:36:29 -0700 (PDT) Received: from localhost.localdomain ([182.191.83.208]) by smtp.gmail.com with ESMTPSA id q15-20020a1709060e4f00b006cdf4535cf2sm7962986eji.67.2022.03.22.02.36.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Mar 2022 02:36:28 -0700 (PDT) From: "huzaifa.rahman" To: dev@dpdk.org Cc: "huzaifa.rahman" Subject: [PATCH v2] ethtool: added help command to list all available Date: Tue, 22 Mar 2022 14:36:15 +0500 Message-Id: <20220322093615.260856-1-huzaifa.rahman@emumba.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220321142547.82966-1-huzaifa.rahman@emumba.com> References: <20220321142547.82966-1-huzaifa.rahman@emumba.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 Help command is not available for ethtool example. It is needed so user can see all the available commands directly from the command line along with the formats. Signed-off-by: huzaifa.rahman --- doc/guides/sample_app_ug/ethtool.rst | 1 + examples/ethtool/ethtool-app/ethapp.c | 38 +++++++++++++++++++++++++++ examples/ethtool/ethtool-app/ethapp.h | 1 + 3 files changed, 40 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..1c0e6c050f 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 +print_cmd_info(unsigned int sr, const char *name, const char *format, const char *description) +{ + printf("%-4u%-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_help_callback(__rte_unused void *ptr_params, + __rte_unused struct cmdline *ctx, + __rte_unused void *ptr_data) +{ + printf("%-4s%-17s%-45s%-50s\n\n", "Sr.", "Name", "Format", "Description"); + print_cmd_info(1, "drvinfo", "drvinfo", "Print driver info"); + print_cmd_info(2, "open", "open ", "Open port"); + print_cmd_info(3, "pause", "pause []", "Get/set port pause state"); + print_cmd_info(4, "stop", "stop ", "Stop port"); + print_cmd_info(5, "portstats", "portstats ", "Print port statistics"); + print_cmd_info(6, "link", "link", "Print port link states"); + print_cmd_info(7, "macaddr", "macaddr []", "Gets/sets MAC address"); + print_cmd_info(8, "mtu", "mtu ", "Set NIC MTU"); + print_cmd_info(9, "regs", "regs ", "Dump port register(s) to file"); + print_cmd_info(10, "ringparam", "ringparam [ ]", "Get/set ring parameters"); + print_cmd_info(11, "rxmode", "rxmode ", "Toggle port Rx mode"); + print_cmd_info(12, "validate", "validate ", "Check that given MAC address is valid unicast address"); + print_cmd_info(13, "vlan", "vlan ", "Add/remove VLAN id"); + print_cmd_info(14, "eeprom", "eeprom ", "Dump EEPROM to file"); + print_cmd_info(15, "module-eeprom", "module-eeprom ", "Dump plugin module EEPROM to file"); + print_cmd_info(16, "quit", "quit", "Exit program"); + print_cmd_info(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_help_cmds = { + .f = pcmd_help_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_help_cmds, (cmdline_parse_inst_t *)&pcmd_drvinfo, (cmdline_parse_inst_t *)&pcmd_eeprom, (cmdline_parse_inst_t *)&pcmd_module_eeprom, diff --git a/examples/ethtool/ethtool-app/ethapp.h b/examples/ethtool/ethtool-app/ethapp.h index 7a70480c88..4db09ed771 100644 --- a/examples/ethtool/ethtool-app/ethapp.h +++ b/examples/ethtool/ethtool-app/ethapp.h @@ -10,3 +10,4 @@ void unlock_port(int idx_port); void mark_port_inactive(int idx_port); void mark_port_active(int idx_port); void mark_port_newmac(int idx_port); +void print_cmd_info(unsigned int sr, const char *name, const char *format, const char *description);