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 153C6A00E6 for ; Sun, 1 Sep 2019 06:08:43 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 428071D178; Sun, 1 Sep 2019 06:08:42 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by dpdk.org (Postfix) with ESMTP id B3E551C1DD for ; Sun, 1 Sep 2019 06:08:40 +0200 (CEST) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id x8145PcJ006196; Sat, 31 Aug 2019 21:08:39 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : mime-version : content-type; s=pfpt0818; bh=Bzr6eSknPnKpX+9CevFjteCm4MUlb3lKQcvWyIx4fLk=; b=HQdEoNI4kEwR+I0uVNj/taVZorsHZq6EWYVcniyD3s9tQM1Sc+cTlXviJmkGDeHLsQRy MumLQFjNoBc1vL9eh9hEcz6+A/JZCNkdDPKPJr0ls/Rg0uYzEXhS0oAKgYJ1O2peXGVr yJ3lJMEfJyXV3EP5BmFGwn3nUplPLzqe8DCoxkB69zXYVj4AfzdIFlDA9aw/MF4OEH1H S1QDZr+pkZdS+s4aYDkGG/GtFLkom2VrN6NpunFtR5tGouqRHLlHZDuTQDaQF8aRzHYx ZWWkThlGtC0RqoHYT291uSII2lJapCOwm6X1rnl1apHP79h42TJKScB+Z7gU9tMzQAVF ZQ== Received: from sc-exch03.marvell.com ([199.233.58.183]) by mx0b-0016f401.pphosted.com with ESMTP id 2uqrdm1tf0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Sat, 31 Aug 2019 21:08:39 -0700 Received: from SC-EXCH01.marvell.com (10.93.176.81) by SC-EXCH03.marvell.com (10.93.176.83) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Sat, 31 Aug 2019 21:08:37 -0700 Received: from maili.marvell.com (10.93.176.43) by SC-EXCH01.marvell.com (10.93.176.81) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Sat, 31 Aug 2019 21:08:37 -0700 Received: from hyd1vattunuru-dt.caveonetworks.com (unknown [10.29.52.72]) by maili.marvell.com (Postfix) with ESMTP id C321F3F7040; Sat, 31 Aug 2019 21:08:34 -0700 (PDT) From: To: CC: , , , , Vamsi Attunuru Date: Sun, 1 Sep 2019 09:37:31 +0530 Message-ID: <20190901040731.13820-1-vattunuru@marvell.com> X-Mailer: git-send-email 2.8.4 MIME-Version: 1.0 Content-Type: text/plain X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.70,1.0.8 definitions=2019-09-01_01:2019-08-29,2019-09-01 signatures=0 Subject: [dpdk-dev] [PATCH v1 1/1] app/testpmd: add function to display port supported ptypes 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" From: Vamsi Attunuru Patch adds a runtime function to display ptypes supported by the given port in different layers. Signed-off-by: Vamsi Attunuru --- app/test-pmd/cmdline.c | 111 ++++++++++++++++++++++++++++ doc/guides/testpmd_app_ug/testpmd_funcs.rst | 7 ++ 2 files changed, 118 insertions(+) diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index 56783aa..839c1b0 100644 --- a/app/test-pmd/cmdline.c +++ b/app/test-pmd/cmdline.c @@ -238,6 +238,10 @@ static void cmd_help_long_parsed(void *parsed_result, " Show Tx metadata value set" " for a specific port\n\n" + "show port (port_id) ptypes\n" + " Show port supported ptypes" + " for a specific port\n\n" + "show device info (|all)" " Show general information about devices probed.\n\n" ); @@ -18820,6 +18824,112 @@ cmdline_parse_inst_t cmd_show_tx_metadata = { }, }; +/* show port supported ptypes */ + +/* Common result structure for show port ptypes */ +struct cmd_show_port_supported_ptypes_result { + cmdline_fixed_string_t show; + cmdline_fixed_string_t port; + portid_t port_id; + cmdline_fixed_string_t ptypes; +}; + +/* Common CLI fields for show port ptypes */ +cmdline_parse_token_string_t cmd_show_port_supported_ptypes_show = + TOKEN_STRING_INITIALIZER + (struct cmd_show_port_supported_ptypes_result, + show, "show"); +cmdline_parse_token_string_t cmd_show_port_supported_ptypes_port = + TOKEN_STRING_INITIALIZER + (struct cmd_show_port_supported_ptypes_result, + port, "port"); +cmdline_parse_token_num_t cmd_show_port_supported_ptypes_port_id = + TOKEN_NUM_INITIALIZER + (struct cmd_show_port_supported_ptypes_result, + port_id, UINT16); +cmdline_parse_token_string_t cmd_show_port_supported_ptypes_ptypes = + TOKEN_STRING_INITIALIZER + (struct cmd_show_port_supported_ptypes_result, + ptypes, "ptypes"); + +static void +cmd_show_port_supported_ptypes_parsed( + void *parsed_result, + __attribute__((unused)) struct cmdline *cl, + __attribute__((unused)) void *data) +{ + struct cmd_show_port_supported_ptypes_result *res = parsed_result; + uint32_t ptype_mask = RTE_PTYPE_L2_MASK; + uint32_t resv_mask = 0xf0000000; + uint16_t port_id = res->port_id; + int max_layer_ptypes = 16; + uint32_t ptypes[max_layer_ptypes]; + char buf[256], ltype[32]; + int ret, i; + + ret = rte_eth_dev_get_supported_ptypes(port_id, ptype_mask, NULL, 0); + if (ret < 0) + return; + + while (ptype_mask != resv_mask) { + + switch (ptype_mask) { + case RTE_PTYPE_L2_MASK: + strlcpy(ltype, "L2", sizeof(ltype)); + break; + case RTE_PTYPE_L3_MASK: + strlcpy(ltype, "L3", sizeof(ltype)); + break; + case RTE_PTYPE_L4_MASK: + strlcpy(ltype, "L4", sizeof(ltype)); + break; + case RTE_PTYPE_TUNNEL_MASK: + strlcpy(ltype, "Tunnel", sizeof(ltype)); + break; + case RTE_PTYPE_INNER_L2_MASK: + strlcpy(ltype, "Inner L2", sizeof(ltype)); + break; + case RTE_PTYPE_INNER_L3_MASK: + strlcpy(ltype, "Inner L3", sizeof(ltype)); + break; + case RTE_PTYPE_INNER_L4_MASK: + strlcpy(ltype, "Inner L4", sizeof(ltype)); + break; + default: + return; + } + + ret = rte_eth_dev_get_supported_ptypes(res->port_id, + ptype_mask, ptypes, + max_layer_ptypes); + + if (ret > 0) + printf("Supported %s ptypes:\n", ltype); + else + printf("%s ptypes unsupported\n", ltype); + + for (i = 0; i < ret; ++i) { + rte_get_ptype_name(ptypes[i], buf, sizeof(buf)); + printf("%s\n", buf); + } + + ptype_mask <<= 4; + } +} + +cmdline_parse_inst_t cmd_show_port_supported_ptypes = { + .f = cmd_show_port_supported_ptypes_parsed, + .data = NULL, + .help_str = "show port ptypes", + .tokens = { + (void *)&cmd_show_port_supported_ptypes_show, + (void *)&cmd_show_port_supported_ptypes_port, + (void *)&cmd_show_port_supported_ptypes_port_id, + (void *)&cmd_show_port_supported_ptypes_ptypes, + NULL, + }, +}; + /* ******************************************************************************** */ /* list of instructions */ @@ -19058,6 +19168,7 @@ cmdline_parse_ctx_t main_ctx[] = { (cmdline_parse_inst_t *)&cmd_clear_input_set, (cmdline_parse_inst_t *)&cmd_show_vf_stats, (cmdline_parse_inst_t *)&cmd_clear_vf_stats, + (cmdline_parse_inst_t *)&cmd_show_port_supported_ptypes, (cmdline_parse_inst_t *)&cmd_ptype_mapping_get, (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace, (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset, diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst index 313e070..1acd958 100644 --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst @@ -467,6 +467,13 @@ Show Tx metadata value set for a specific port:: testpmd> show port (port_id) tx_metadata +show port supported ptypes +~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Show ptypes supported for a specific port:: + + testpmd> show port (port_id) ptypes + show device info ~~~~~~~~~~~~~~~~ -- 2.8.4