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 35A6E44060; Wed, 12 Jun 2024 19:53:17 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5B701402C6; Wed, 12 Jun 2024 19:53:15 +0200 (CEST) Received: from mail-lf1-f53.google.com (mail-lf1-f53.google.com [209.85.167.53]) by mails.dpdk.org (Postfix) with ESMTP id A0E39402B9 for ; Wed, 12 Jun 2024 19:53:13 +0200 (CEST) Received: by mail-lf1-f53.google.com with SMTP id 2adb3069b0e04-52c84a21c62so195208e87.1 for ; Wed, 12 Jun 2024 10:53:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1718214793; x=1718819593; darn=dpdk.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=IjlGB8pVNbxBehFPdElUBpDj581/sSLfIWCVBsHl+/E=; b=Jn2cK7kbAnzeTLThW5DJ/lLhjjRGnSPtWmCEjtsh9T4irKqj6mzwdCkjxDVkWrjitY 9AcHx9pEQ0vyFPtlQqzotY+7QskGEbOS5xPI2LyBg0CMpFYh7twcSt9ys0z4dUpRVKSD eAHyo+QLWqolOGGsCCg3G3yk09hEDW6kxE34w= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718214793; x=1718819593; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=IjlGB8pVNbxBehFPdElUBpDj581/sSLfIWCVBsHl+/E=; b=AWze8B9XkpE+SJyXsJnfzFbrrp1//f0dbrh4a2Sk8FZfeH2dMNIJCfJkV/05qbdNDA QQjZUtLWdTNFFXaq7UF/karu6V/75K0YJTmtDqHwjWq9gq28lZqpeRMcY/UdaP3k/HS5 qhV4WYKfcQbapuxod7LFn1TdYSN7UV6avig6bPdqVFZLuUTalMS5eVUZJK++JhX5v/Tf 1FW4bSyANvpuM7S0ZN4yQLkmEcYNBRyomGtWu6eBdGbLg3CH310EQxF4Qw9OLz0wi27A kS1tKvv3mQcGqtxmneQtT/0zjYdDhDz4hZRm0bxsnrBBtAl6sL45+VBphAmK3CsjaZcQ jqOQ== X-Gm-Message-State: AOJu0YzQoLnN82TwuMGNJPkrNMDkhHdD+1xyGUxtdtqYdjnDQcu0T+x/ qAqXiR5a2FkZgQxz0z8tjnl2Ukvt+UTkZx6v8nEXwXCEFlQ6BBZZRvCpdR5IGbL7WxCB10rZ+VS gm3mMIGTfPFfqRrLzDdFpK991wJJfF+QZrDj8mTvy1SQD0sDzvjUZQ8phCg6NqiDR6plflHRkRl K0tsOg X-Google-Smtp-Source: AGHT+IG3McQ4FOTjzJSYzld1aPfmYUsE80CoCT1F6FVmxz7BUBIiQW57vt9Y+AV4Ap0to5AHftEiMo2QR1ScjjECgv0= X-Received: by 2002:a05:6512:39d4:b0:52c:a016:5405 with SMTP id 2adb3069b0e04-52ca01654c6mr304244e87.8.1718214792920; Wed, 12 Jun 2024 10:53:12 -0700 (PDT) MIME-Version: 1.0 References: <20240602024504.179506-1-damodharam.ammepalli@broadcom.com> <20240602024504.179506-5-damodharam.ammepalli@broadcom.com> In-Reply-To: From: Damodharam Ammepalli Date: Wed, 12 Jun 2024 10:53:01 -0700 Message-ID: Subject: Re: [PATCH v2 4/4] testpmd: add support for displaying lanes capability To: Ferruh Yigit Cc: dev@dpdk.org, Dengdui Huang , fengchengwen@huawei.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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 Tue, Jun 11, 2024 at 4:39=E2=80=AFPM Ferruh Yigit = wrote: > > On 6/2/2024 3:45 AM, Damodharam Ammepalli wrote: > > Add a new api support that displays the speeds and bitmap of > > supported lanes configuration by the ethernet controller. > > This patch adds support in the testpmd cli chain. > > > > Signed-off-by: Damodharam Ammepalli > > --- > > app/test-pmd/cmdline.c | 128 +++++++++++++++++++++++++++++++++++++++++ > > 1 file changed, 128 insertions(+) > > > > diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c > > index 785e5dd4de..8b0a85f632 100644 > > --- a/app/test-pmd/cmdline.c > > +++ b/app/test-pmd/cmdline.c > > @@ -1637,6 +1637,133 @@ static cmdline_parse_inst_t cmd_config_loopback= _all =3D { > > }, > > }; > > > > +/* *** display speed lanes per port capabilities *** */ > > +struct cmd_show_speed_lanes_result { > > + cmdline_fixed_string_t cmd_show; > > + cmdline_fixed_string_t cmd_port; > > + cmdline_fixed_string_t cmd_keyword; > > + portid_t cmd_pid; > > +}; > > + > > +static const char* > > +get_device_infos_display_speeds(uint32_t speed_capa) > > +{ > > + if (speed_capa & RTE_ETH_LINK_SPEED_10M_HD) > > + return(" 10 Mbps half-duplex "); > > + if (speed_capa & RTE_ETH_LINK_SPEED_10M) > > + return(" 10 Mbps full-duplex "); > > + if (speed_capa & RTE_ETH_LINK_SPEED_100M_HD) > > + return(" 100 Mbps half-duplex "); > > + if (speed_capa & RTE_ETH_LINK_SPEED_100M) > > + return(" 100 Mbps full-duplex "); > > + if (speed_capa & RTE_ETH_LINK_SPEED_1G) > > + return(" 1 Gbps "); > > + if (speed_capa & RTE_ETH_LINK_SPEED_2_5G) > > + return(" 2.5 Gbps "); > > + if (speed_capa & RTE_ETH_LINK_SPEED_5G) > > + return(" 5 Gbps "); > > + if (speed_capa & RTE_ETH_LINK_SPEED_10G) > > + return(" 10 Gbps "); > > + if (speed_capa & RTE_ETH_LINK_SPEED_20G) > > + return(" 20 Gbps "); > > + if (speed_capa & RTE_ETH_LINK_SPEED_25G) > > + return(" 25 Gbps "); > > + if (speed_capa & RTE_ETH_LINK_SPEED_40G) > > + return(" 40 Gbps "); > > + if (speed_capa & RTE_ETH_LINK_SPEED_50G) > > + return(" 50 Gbps "); > > + if (speed_capa & RTE_ETH_LINK_SPEED_56G) > > + return(" 56 Gbps "); > > + if (speed_capa & RTE_ETH_LINK_SPEED_100G) > > + return(" 100 Gbps "); > > + if (speed_capa & RTE_ETH_LINK_SPEED_200G) > > + return(" 200 Gbps "); > > + if (speed_capa & RTE_ETH_LINK_SPEED_400G) > > + return(" 400 Gbps "); > > + > > + return("Unkown"); > > +} > > > > As far as I remember, there was already a function to convert speed to > string, can you please double check? > Yes. I picked up from this. app/test-pmd/config.c:device_infos_display_spee= ds() Can I make this function app/test-pmd/config.c:device_infos_display_speeds() a non-static and declare it in testpmd.h? > > > + > > +static void > > +cmd_show_speed_lanes_parsed(void *parsed_result, > > + __rte_unused struct cmdline *cl, > > + __rte_unused void *data) > > +{ > > + struct cmd_show_speed_lanes_result *res =3D parsed_result; > > + uint32_t speed_lanes_bmap[RTE_ETH_LINK_SPEED_MAX_BIT] =3D {0}; > > + struct rte_eth_speed_lanes_capa spd_lanes =3D {0}; > > > > I think this function will change completely because of previous > comments, but as a generic comment, can you please prefer full 'speed' > wording instead of 'spd'. > > > + struct rte_eth_dev_info dev_info; > > + //char lanes_speed_str[128] =3D {0}; > > + bool skip_spd_chk =3D false; > > + int ret, i; > > + uint32_t j; > > + > > + if (!rte_eth_dev_is_valid_port(res->cmd_pid)) { > > + fprintf(stderr, "Invalid port id %u\n", res->cmd_pid); > > + return; > > + } > > + > > + /* get max lanes this nic supports */ > > + ret =3D rte_eth_speed_lanes_get(res->cmd_pid, &spd_lanes); > > + if (ret =3D=3D -ENOTSUP) > > + return; > > + > > + /* Pull out capability if nic supports */ > > + ret =3D rte_eth_speed_lanes_get_capa(res->cmd_pid, speed_lanes_bm= ap); > > + if (ret =3D=3D -ENOTSUP) > > + return; > > + > > + ret =3D eth_dev_info_get_print_err(res->cmd_pid, &dev_info); > > + /* when link is down, PHY does not report any speeds */ > > + if (ret =3D=3D 0) > > + skip_spd_chk =3D true; > > + > > + printf("\n%-25s %-10s", " Supported speeds", "Valid lanes"); > > + printf("\n-----------------------------------"); > > + for (i =3D 1; i <=3D RTE_ETH_LINK_SPEED_MAX_BIT; i++) { > > + if ((dev_info.speed_capa & RTE_BIT32(i) || skip_spd_chk) = && > > + (speed_lanes_bmap[i])) { > > + printf("\n%-25s ", > > + get_device_infos_display_speeds(RTE_BIT32(= i))) ; > > + for (j =3D 0; j <=3D spd_lanes.max_lanes_cap; j++= ) { > > + if (RTE_BIT32(j) & speed_lanes_bmap[i]) > > + printf("%-2d", j); > > + } > > + } > > + } > > + printf("\n"); > > +} > > + > > +static cmdline_parse_token_string_t cmd_show_speed_lanes_show =3D > > + TOKEN_STRING_INITIALIZER(struct cmd_show_speed_lanes_result, > > + cmd_show, "show"); > > +static cmdline_parse_token_string_t cmd_show_speed_lanes_port =3D > > + TOKEN_STRING_INITIALIZER(struct cmd_show_speed_lanes_result, > > + cmd_port, "port"); > > +static cmdline_parse_token_num_t cmd_show_speed_lanes_pid =3D > > + TOKEN_NUM_INITIALIZER(struct cmd_show_speed_lanes_result, > > + cmd_pid, RTE_UINT16); > > +static cmdline_parse_token_string_t cmd_show_speed_lanes_keyword =3D > > + TOKEN_STRING_INITIALIZER(struct cmd_show_speed_lanes_result, > > + cmd_keyword, "speed_lanes"); > > +static cmdline_parse_token_string_t cmd_show_speed_lanes_cap_keyword = =3D > > + TOKEN_STRING_INITIALIZER(struct cmd_show_speed_lanes_result, > > + cmd_keyword, "capabilities"); > > + > > +static cmdline_parse_inst_t cmd_show_speed_lanes =3D { > > + .f =3D cmd_show_speed_lanes_parsed, > > + .data =3D NULL, > > + .help_str =3D "show port speed_lanes capabilities", > > + .tokens =3D { > > + (void *)&cmd_show_speed_lanes_show, > > + (void *)&cmd_show_speed_lanes_port, > > + (void *)&cmd_show_speed_lanes_pid, > > + (void *)&cmd_show_speed_lanes_keyword, > > + (void *)&cmd_show_speed_lanes_cap_keyword, > > + NULL, > > + }, > > +}; > > + > > /* *** configure loopback for specific port *** */ > > struct cmd_config_loopback_specific { > > cmdline_fixed_string_t port; > > @@ -13523,6 +13650,7 @@ static cmdline_parse_ctx_t builtin_ctx[] =3D { > > (cmdline_parse_inst_t *)&cmd_config_tx_affinity_map, > > (cmdline_parse_inst_t *)&cmd_config_speed_lanes_all, > > (cmdline_parse_inst_t *)&cmd_config_speed_lanes_specific, > > + (cmdline_parse_inst_t *)&cmd_show_speed_lanes, > > NULL, > > }; > > > --=20 This electronic communication and the information and any files transmitted= =20 with it, or attached to it, are confidential and are intended solely for=20 the use of the individual or entity to whom it is addressed and may contain= =20 information that is confidential, legally privileged, protected by privacy= =20 laws, or otherwise restricted from disclosure to anyone else. If you are=20 not the intended recipient or the person responsible for delivering the=20 e-mail to the intended recipient, you are hereby notified that any use,=20 copying, distributing, dissemination, forwarding, printing, or copying of= =20 this e-mail is strictly prohibited. If you received this e-mail in error,= =20 please return the e-mail to the sender, delete it from your computer, and= =20 destroy any printed copy of it.