DPDK patches and discussions
 help / color / mirror / Atom feed
From: Ferruh Yigit <ferruh.yigit@amd.com>
To: Damodharam Ammepalli <damodharam.ammepalli@broadcom.com>, dev@dpdk.org
Subject: Re: [PATCH v2 4/4] testpmd: add support for displaying lanes capability
Date: Wed, 12 Jun 2024 00:39:27 +0100	[thread overview]
Message-ID: <deb5421e-52ed-4312-8d02-25908f300c0a@amd.com> (raw)
In-Reply-To: <20240602024504.179506-5-damodharam.ammepalli@broadcom.com>

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 <damodharam.ammepalli@broadcom.com>
> ---
>  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 = {
>  	},
>  };
>  
> +/* *** 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?


> +
> +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 = parsed_result;
> +	uint32_t speed_lanes_bmap[RTE_ETH_LINK_SPEED_MAX_BIT] = {0};
> +	struct rte_eth_speed_lanes_capa spd_lanes = {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] = {0};
> +	bool skip_spd_chk = 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 = rte_eth_speed_lanes_get(res->cmd_pid, &spd_lanes);
> +        if (ret == -ENOTSUP)
> +		return;
> +
> +	/* Pull out capability if nic supports */
> +	ret = rte_eth_speed_lanes_get_capa(res->cmd_pid, speed_lanes_bmap);
> +        if (ret == -ENOTSUP)
> +		return;
> +
> +	ret = eth_dev_info_get_print_err(res->cmd_pid, &dev_info);
> +	/* when link is down, PHY does not report any speeds */
> +	if (ret == 0)
> +		skip_spd_chk = true;
> +
> +	printf("\n%-25s %-10s", " Supported speeds", "Valid lanes");
> +	printf("\n-----------------------------------");
> +        for (i = 1; i <= 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 = 0; j <= 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 =
> +	TOKEN_STRING_INITIALIZER(struct cmd_show_speed_lanes_result,
> +				 cmd_show, "show");
> +static cmdline_parse_token_string_t cmd_show_speed_lanes_port =
> +	TOKEN_STRING_INITIALIZER(struct cmd_show_speed_lanes_result,
> +				 cmd_port, "port");
> +static cmdline_parse_token_num_t cmd_show_speed_lanes_pid =
> +	TOKEN_NUM_INITIALIZER(struct cmd_show_speed_lanes_result,
> +			      cmd_pid, RTE_UINT16);
> +static cmdline_parse_token_string_t cmd_show_speed_lanes_keyword =
> +	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 =
> +	TOKEN_STRING_INITIALIZER(struct cmd_show_speed_lanes_result,
> +				 cmd_keyword, "capabilities");
> +
> +static cmdline_parse_inst_t cmd_show_speed_lanes = {
> +	.f = cmd_show_speed_lanes_parsed,
> +	.data = NULL,
> +	.help_str = "show port <port_id> speed_lanes capabilities",
> +	.tokens = {
> +		(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[] = {
>  	(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,
>  };
>  


  reply	other threads:[~2024-06-11 23:39 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-22 22:25 [RFC 0/2] Add support for link speed lanes Damodharam Ammepalli
2024-03-22 22:25 ` [RFC 1/2] lib/ethdev: Add link_speed lanes support into rte lib Damodharam Ammepalli
2024-03-22 22:25 ` [RFC 2/2] testpmd: Add speed lanes to testpmd config and show command Damodharam Ammepalli
2024-05-22 20:59 ` [RFC 0/2] Add support for link speed lanes Ferruh Yigit
2024-05-28 21:19   ` Damodharam Ammepalli
2024-06-02  2:45     ` [PATCH v2 0/4] " Damodharam Ammepalli
2024-06-02  2:45       ` [PATCH v2 1/4] lib/ethdev: Add link_speed lanes support into rte lib Damodharam Ammepalli
2024-06-11 23:39         ` Ferruh Yigit
2024-06-14 18:27           ` Damodharam Ammepalli
2024-06-17 20:34             ` [PATCH v3] ethdev: Add link_speed lanes support Damodharam Ammepalli
2024-06-02  2:45       ` [PATCH v2 2/4] testpmd: Add speed lanes to testpmd config and show command Damodharam Ammepalli
2024-06-11 23:39         ` Ferruh Yigit
2024-06-02  2:45       ` [PATCH v2 3/4] lib/ethdev: add support for displaying lanes capability Damodharam Ammepalli
2024-06-11 23:39         ` Ferruh Yigit
2024-06-02  2:45       ` [PATCH v2 4/4] testpmd: " Damodharam Ammepalli
2024-06-11 23:39         ` Ferruh Yigit [this message]
2024-06-12 17:53           ` Damodharam Ammepalli
2024-06-12 20:57             ` Ferruh Yigit
2024-06-11 23:38       ` [PATCH v2 0/4] Add support for link speed lanes Ferruh Yigit
2024-06-12 17:46         ` Damodharam Ammepalli

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=deb5421e-52ed-4312-8d02-25908f300c0a@amd.com \
    --to=ferruh.yigit@amd.com \
    --cc=damodharam.ammepalli@broadcom.com \
    --cc=dev@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).