From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 21893A04B5; Thu, 10 Sep 2020 21:25:51 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 3FACC1DB8; Thu, 10 Sep 2020 21:25:50 +0200 (CEST) Received: from mail-lj1-f193.google.com (mail-lj1-f193.google.com [209.85.208.193]) by dpdk.org (Postfix) with ESMTP id E987F160 for ; Thu, 10 Sep 2020 21:25:47 +0200 (CEST) Received: by mail-lj1-f193.google.com with SMTP id b19so9642391lji.11 for ; Thu, 10 Sep 2020 12:25:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iol.unh.edu; s=unh-iol; h=mime-version:from:date:message-id:subject:to:cc; bh=QsNODbPlX2bxChFy/03T4cjHCotHj6kiwq9eCAbwU9w=; b=ICKkmmYTUOKjbMRPMr/wjjQGdiJEqtrLTI6lFE4GWqZTM+VModPQbvuz6HKdRxT9oa dF66hLB1Hom5jlYPx2U5UzO1MW+83eELKQH8vfcaYeR7vJSIaxLjtXetAKuOsyWR0NDS ZEDjMCszoHpPJWqUMgnB8lkBkL4qmKrxicshI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to:cc; bh=QsNODbPlX2bxChFy/03T4cjHCotHj6kiwq9eCAbwU9w=; b=PcQU8tbqCZmlivfQL5+BVlimrKACMll20TKkBMpcKJ0eEwGKhX+Wl/5nIDvBpFNERU g+UTgIC6JztHLhyHG46X5bocNMWV23GB5lQvYa956xl411seaI8DErvZTu+KoDUw+2AF GnbQtqWR3MFapMhl3HamrcTPJMQcGB9PaoDXFif75jvUB5GCXP4AeOnyLeU3I974Vzqj QjIxa2gXXY/s3alpOH+pOC8Hrnv+Zb0BJgUCjRRa7dKzx1VacmK0lvjzQBL2i23NiJV4 cs/vDtNE+UuQB0I0d0svKFG3EI81TesRrlTe+aSIUg4AGdiOkbaCQHJbbhjzVULl+9Nc SADg== X-Gm-Message-State: AOAM5335vwmMbkCYMjSC/0g8vM00/JGhXu8rK2ZyKXMaOPo9kTP/MyW4 Dpybuu2EZwFwF5WlFLrJ/b8JHBCnwabRlZWxDnecJQ== X-Google-Smtp-Source: ABdhPJxwothKsa6HEmXJ+KsY5tvAuF5QGq13SSCfUbsmCEjhHY/tyVQeRVQKQFC9rynTrO7azcanWl+peFpl37Y04oo= X-Received: by 2002:a05:651c:151:: with SMTP id c17mr5585375ljd.467.1599765947280; Thu, 10 Sep 2020 12:25:47 -0700 (PDT) MIME-Version: 1.0 From: David Liu Date: Thu, 10 Sep 2020 15:25:11 -0400 Message-ID: To: Ferruh Yigit Cc: dpdk-dev , Lincoln Lavoie , Thomas Monjalon Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.15 Subject: Re: [dpdk-dev] [PATCH V2] testpmd: add eeprom/module eeprom display X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Add module EEPROM/EEPROM dump command "show port (module_eeprom|eeprom)" Commands will dump the content of the EEPROM/module EEPROM for the selected port. Signed-off-by: David Liu --- app/test-pmd/cmdline.c | 49 ++++++++ app/test-pmd/config.c | 118 ++++++++++++++++++++ app/test-pmd/testpmd.h | 2 + doc/guides/testpmd_app_ug/testpmd_funcs.rst | 7 ++ 4 files changed, 177 insertions(+) diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index a037a55c6..ba240c410 100644 --- a/app/test-pmd/cmdline.c +++ b/app/test-pmd/cmdline.c @@ -166,6 +166,9 @@ static void cmd_help_long_parsed(void *parsed_result, "show port (info|stats|summary|xstats|fdir|stat_qmap|dcb_tc|cap) (port_id|all)\n" " Display information for port_id, or all.\n\n" + "show port port_id (module_eeprom|eeprom)\n" + " Display the module EEPROM or EEPROM information for port_id.\n\n" + "show port X rss reta (size) (mask0,mask1,...)\n" " Display the rss redirection table entry indicated" " by masks on port X. size is used to indicate the" @@ -7594,6 +7597,51 @@ cmdline_parse_inst_t cmd_showdevice = { NULL, }, }; + +/* *** SHOW MODULE EEPROM/EEPROM port INFO *** */ +struct cmd_showeeprom_result { + cmdline_fixed_string_t show; + cmdline_fixed_string_t port; + uint16_t portnum; + cmdline_fixed_string_t type; +}; + +static void cmd_showeeprom_parsed(void *parsed_result, + __rte_unused struct cmdline *cl, + __rte_unused void *data) +{ + struct cmd_showeeprom_result *res = parsed_result; + + if (!strcmp(res->type, "eeprom")) + port_eeprom_display(res->portnum); + else if (!strcmp(res->type, "module_eeprom")) + port_module_eeprom_display(res->portnum); + else + printf("Unknown argument\n"); +} + +cmdline_parse_token_string_t cmd_showeeprom_show = + TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, show, "show"); +cmdline_parse_token_string_t cmd_showeeprom_port = + TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, port, "port"); +cmdline_parse_token_num_t cmd_showeeprom_portnum = + TOKEN_NUM_INITIALIZER(struct cmd_showeeprom_result, portnum, UINT16); +cmdline_parse_token_string_t cmd_showeeprom_type = + TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, type, "module_eeprom#eeprom"); + +cmdline_parse_inst_t cmd_showeeprom = { + .f = cmd_showeeprom_parsed, + .data = NULL, + .help_str = "show port module_eeprom|eeprom", + .tokens = { + (void *)&cmd_showeeprom_show, + (void *)&cmd_showeeprom_port, + (void *)&cmd_showeeprom_portnum, + (void *)&cmd_showeeprom_type, + NULL, + }, +}; + /* *** SHOW QUEUE INFO *** */ struct cmd_showqueue_result { cmdline_fixed_string_t show; @@ -19325,6 +19373,7 @@ cmdline_parse_ctx_t main_ctx[] = { (cmdline_parse_inst_t *)&cmd_load_from_file, (cmdline_parse_inst_t *)&cmd_showport, (cmdline_parse_inst_t *)&cmd_showqueue, + (cmdline_parse_inst_t *)&cmd_showeeprom, (cmdline_parse_inst_t *)&cmd_showportall, (cmdline_parse_inst_t *)&cmd_showdevice, (cmdline_parse_inst_t *)&cmd_showcfg, diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index 8cf84ccd3..5e3e9e211 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -49,6 +49,9 @@ #include #endif #include +#include + #include "testpmd.h" @@ -710,6 +713,122 @@ port_summary_display(portid_t port_id) (unsigned int) link.link_speed); } +void +port_eeprom_display(portid_t port_id) +{ + struct rte_dev_eeprom_info einfo; + int ret; + if (port_id_is_invalid(port_id, ENABLED_WARN)) { + print_valid_ports(); + return; + } + + int len_eeprom = rte_eth_dev_get_eeprom_length(port_id); + if(len_eeprom < 0) { + switch (len_eeprom) { + case -ENODEV: + printf("port index %d invalid\n", port_id); + break; + case -ENOTSUP: + printf("operation not supported by device\n"); + break; + case -EIO: + printf("device is removed\n"); + break; + default: + printf("Unable to get EEPROM: %d\n", len_eeprom); + break; + } + return; + } + + char buf[len_eeprom]; + einfo.offset = 0; + einfo.length = len_eeprom; + einfo.data = buf; + + ret = rte_eth_dev_get_eeprom(port_id, &einfo); + if (ret != 0) { + switch (ret) { + case -ENODEV: + printf("port index %d invalid\n", port_id); + break; + case -ENOTSUP: + printf("operation not supported by device\n"); + break; + case -EIO: + printf("device is removed\n"); + break; + default: + printf("Unable to get EEPROM: %d\n", ret); + break; + } + return; + } + rte_hexdump(stdout, "hexdump", einfo.data, einfo.length); + printf("Finish -- Port: %d EEPROM length: %d bytes\n", port_id, len_eeprom); +} + +void +port_module_eeprom_display(portid_t port_id) +{ + struct rte_eth_dev_module_info minfo; + struct rte_dev_eeprom_info einfo; + int ret; + + if (port_id_is_invalid(port_id, ENABLED_WARN)) { + print_valid_ports(); + return; + } + + + ret = rte_eth_dev_get_module_info(port_id, &minfo); + if (ret != 0) { + switch (ret) { + case -ENODEV: + printf("port index %d invalid\n", port_id); + break; + case -ENOTSUP: + printf("operation not supported by device\n"); + break; + case -EIO: + printf("device is removed\n"); + break; + default: + printf("Unable to get module EEPROM: %d\n", ret); + break; + } + return; + } + + char buf[minfo.eeprom_len]; + einfo.offset = 0; + einfo.length = minfo.eeprom_len; + einfo.data = buf; + + ret = rte_eth_dev_get_module_eeprom(port_id, &einfo); + if (ret != 0) { + switch (ret) { + case -ENODEV: + printf("port index %d invalid\n", port_id); + break; + case -ENOTSUP: + printf("operation not supported by device\n"); + break; + case -EIO: + printf("device is removed\n"); + break; + default: + printf("Unable to get module EEPROM: %d\n", ret); + break; + } + return; + } + + rte_hexdump(stdout, "hexdump", einfo.data, einfo.length); + printf("Finish -- Port: %d MODULE EEPROM length: %d bytes\n", port_id, einfo.length); +} + void port_offload_cap_display(portid_t port_id) { diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h index 7a7c73f79..e3a0d17e5 100644 --- a/app/test-pmd/testpmd.h +++ b/app/test-pmd/testpmd.h @@ -714,6 +714,8 @@ void nic_stats_mapping_display(portid_t port_id); void device_infos_display(const char *identifier); void port_infos_display(portid_t port_id); void port_summary_display(portid_t port_id); +void port_eeprom_display(portid_t port_id); +void port_module_eeprom_display(portid_t port_id); void port_summary_header_display(void); void port_offload_cap_display(portid_t port_id); void rx_queue_infos_display(portid_t port_idi, uint16_t queue_id); diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst index 5103ff925..6a2e1c0f2 100644 --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst @@ -218,6 +218,13 @@ For example: nvgre vxlan-gpe +show port (module_eeprom|eeprom) +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Display the module EEPROM/EEPROM informatioon for port_id:: + + testpmd> show port (port_id) (module_eeprom|eeprom) + show port rss reta ~~~~~~~~~~~~~~~~~~ -- 2.17.1 On Thu, Sep 10, 2020 at 2:48 PM David Liu wrote: > > On Thu, Sep 10, 2020 at 7:47 AM Ferruh Yigit > wrote: > >> On 9/10/2020 7:00 AM, David Liu wrote: >> > Add module EEPROM/EEPROM dump command >> > "show port (module_eeprom|eeprom)" >> > Commands will dump the content of the >> > EEPROM/module EEPROM for the selected port. >> >> >> Hi David, >> >> When sending a new version, can you please increase the verstion tag in >> the >> title, V1 -> V2 -> ... -> vN >> >> Also sending new patch as reply to previos one keep all versions in same >> email >> thread and helps reviewers also people who later checks from archives for >> a feature. >> >> For both above you can find more details in the contribution guide, >> please check >> https://doc.dpdk.org/guides/contributing/patches.html#sending-patches >> >> >> And there are a few errors below that this patch shouldn't be compiling >> successfully, you can verify the build error from lab reports :) >> > > Thank you so much, I will change to that format. > > >> <...> >> >> > /* *** SHOW QUEUE INFO *** */ >> > struct cmd_showqueue_result { >> > cmdline_fixed_string_t show; >> > @@ -19325,6 +19373,8 @@ cmdline_parse_ctx_t main_ctx[] = { >> > (cmdline_parse_inst_t *)&cmd_load_from_file, >> > (cmdline_parse_inst_t *)&cmd_showport, >> > (cmdline_parse_inst_t *)&cmd_showqueue, >> > + (cmdline_parse_inst_t *)&cmd_showeeprom, >> > + (cmdline_parse_inst_t *)&cmd_showmoduleeeprom, >> >> This shouldn't compile because 'cmd_showmoduleeeprom' no more exists ... >> >> <...> >> >> > + >> > +void >> > +port_module_eeprom_displao(portid_t port_id) >> > +{ >> >> There is a typo in the function name. >> >> > + struct rte_eth_dev_module_info minfo; >> > + struct rte_dev_eeprom_info einfo; >> > + int ret; >> > + >> > + if (port_id_is_invalid(port_id, ENABLED_WARN)) { >> > + print_valid_ports(); >> > + return; >> > + } >> > + >> > + >> > + ret = rte_eth_dev_get_module_info(port_id, &minfo); >> > + if (ret != 0) { >> > + switch (ret) { >> > + case -ENODEV: >> > + printf("port index %d invalid\n", port_id); >> > + break; >> > + case -ENOTSUP: >> > + printf("operation not supported by device\n"); >> > + break; >> > + case -EIO: >> > + printf("device is removed\n"); >> > + break; >> > + default: >> > + printf("Unable to get module EEPROM: %d\n", >> len_eeprom); >> >> I guess this is copy/paste error 'len_eeprom' is not defined in this >> function. >> There is one more occurance below. >> >> > I will send out a new patch with all the fixes and that can be compiled > hopefully. > > <...> >> >