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 DDE834412D; Sun, 2 Jun 2024 04:46:13 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3475842DDA; Sun, 2 Jun 2024 04:45:49 +0200 (CEST) Received: from mail-qt1-f178.google.com (mail-qt1-f178.google.com [209.85.160.178]) by mails.dpdk.org (Postfix) with ESMTP id CCC7542DB6 for ; Sun, 2 Jun 2024 04:45:47 +0200 (CEST) Received: by mail-qt1-f178.google.com with SMTP id d75a77b69052e-43fdbfc65e5so18637351cf.0 for ; Sat, 01 Jun 2024 19:45:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1717296346; x=1717901146; darn=dpdk.org; h=mime-version:references:in-reply-to:message-id:date:subject:to:from :from:to:cc:subject:date:message-id:reply-to; bh=Hh6N4N5JirHXbMQ9hXXnjX+BK3MATYYZWcx0katcMxY=; b=eP20HHq9NHxkzmpe3WOtizck8N8eNhMV2SRS2tU/NKPVMho93uwo4ii/jYtAgQ9cgE 0elGYLkarQufmkgqutJQg0vHHRm/0/TYe99yXtjahchGQR4ttlo545pMaEQnVEBjz2kx sh45VMRHp6JNqwOrHUUNae7fgK4dkiwO1FDiQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717296346; x=1717901146; h=mime-version:references:in-reply-to:message-id:date:subject:to:from :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Hh6N4N5JirHXbMQ9hXXnjX+BK3MATYYZWcx0katcMxY=; b=fXcTwqj5UwggU5AOUoWLQdd665KAVEVN61AieJ43oXwNy/gwnleKcgWGRQoVn97CS2 lepso33OvHicmE3LdDhsAVRsasnc6SfeIX9tgXPNnVFj/ahMMrEt9LWcZ9RPZ6QHpg7b KgSGUzG3FVY3K6MQcb7yMpY4dsaJsXaF39csesM64QaXUmupgkegx0aZPcSeT3gfWV74 MX0Xaljewp2sOLVb9vKSkyaRryCMSi/2nKvb0S4YH21PkTZKtToVNNZWtx9I3xxw9Qtu l7vkPpvGpI5t9ruXA8S/Oi4fH8spauSE5rfH9zIkMX7rFGpKJcu1IlVw0njRYMvyqpiO xyHQ== X-Gm-Message-State: AOJu0YxghCr4cTg+0wCXRk5H9BbC6pDfE104mfsDnROHjf1jb9eSs/1l 9WiZxK6YLiShOMUYYQGoJhUayTjx29wkZKqQDDtkIxAHoXR27uS45IPEKO5GQaGA79pQUJqt7El 9f0MW0gqYNarem5SXJDCzRcMDHqDWAjMn1AEWH+HrVQXvIT42vASBRegniqpdkck3lKtBB89cwz P5HiWCMLQONOXNDVl7UJqwdkCCUaJYYiQYT3VdcA== X-Google-Smtp-Source: AGHT+IGFfpilToRqTNcujE3Co3EPNTFHiNt5uB01To4hC51g5fheHkMegi7dwgCM15rk/gHZm1Sd2A== X-Received: by 2002:ac8:58d6:0:b0:43a:f1ef:fd8d with SMTP id d75a77b69052e-43ff525b222mr77557841cf.1.1717296345992; Sat, 01 Jun 2024 19:45:45 -0700 (PDT) Received: from dhcp-10-193-55-224.dhcp.broadcom.net ([192.19.224.250]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-43ff23e0de8sm24579281cf.40.2024.06.01.19.45.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Jun 2024 19:45:44 -0700 (PDT) From: Damodharam Ammepalli To: dev@dpdk.org Subject: [PATCH v2 4/4] testpmd: add support for displaying lanes capability Date: Sat, 1 Jun 2024 19:45:04 -0700 Message-Id: <20240602024504.179506-5-damodharam.ammepalli@broadcom.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20240602024504.179506-1-damodharam.ammepalli@broadcom.com> References: <20240602024504.179506-1-damodharam.ammepalli@broadcom.com> MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" 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 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 = { }, }; +/* *** 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"); +} + +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}; + 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 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, }; -- 2.39.3 -- This electronic communication and the information and any files transmitted with it, or attached to it, are confidential and are intended solely for the use of the individual or entity to whom it is addressed and may contain information that is confidential, legally privileged, protected by privacy laws, or otherwise restricted from disclosure to anyone else. If you are not the intended recipient or the person responsible for delivering the e-mail to the intended recipient, you are hereby notified that any use, copying, distributing, dissemination, forwarding, printing, or copying of this e-mail is strictly prohibited. If you received this e-mail in error, please return the e-mail to the sender, delete it from your computer, and destroy any printed copy of it.