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 C8E76A04B9; Mon, 11 Nov 2019 14:20:46 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id A35E62C2B; Mon, 11 Nov 2019 14:20:05 +0100 (CET) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by dpdk.org (Postfix) with ESMTP id 0DFE42BF9 for ; Mon, 11 Nov 2019 14:20:01 +0100 (CET) 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 xABDHTmY026232; Mon, 11 Nov 2019 05:20:01 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=pfpt0818; bh=ppGIu8d0KNRE3XzkUqFKX4MhJsicKcTsRSXZveRfRys=; b=d7+AsJGV5/N8Bo3ConGnvA/kU0JAMRq02ph5NjRxS/mSOsJd2TZ74Ievi11bdrQIJ6bY VAaG+OdniTWl4szy142+k+4xPRNvC2E20UhhRMaUquCsxBJa9qAlSiHMru9ikNQgLg9t Sm8AvylsxwYw8E8jPOSF/ebRq/OSZQXdWLm3UFTsPBECkLucTrFyH7YiXyzGAUHJ2L6e K8h3San58qKh6Rq5nqNCrJrG/hO0nwPlJoNTk1DhuhA+A8eNxpIx224w8UyWh0ghYNza CvZZ/tR+ZeQ5voQ8ors8VSGzyuVhiU5242BTzyb2qBhH4mnpzne+vitQfvx3Kyu2v9Er eg== Received: from sc-exch02.marvell.com ([199.233.58.182]) by mx0b-0016f401.pphosted.com with ESMTP id 2w5wurp90h-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Mon, 11 Nov 2019 05:20:01 -0800 Received: from SC-EXCH03.marvell.com (10.93.176.83) by SC-EXCH02.marvell.com (10.93.176.82) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Mon, 11 Nov 2019 05:19:59 -0800 Received: from maili.marvell.com (10.93.176.43) by SC-EXCH03.marvell.com (10.93.176.83) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Mon, 11 Nov 2019 05:19:59 -0800 Received: from BG-LT7430.marvell.com (unknown [10.28.17.38]) by maili.marvell.com (Postfix) with ESMTP id E11703F703F; Mon, 11 Nov 2019 05:19:55 -0800 (PST) From: To: , , , , Wenzhuo Lu , Jingjing Wu , "Bernard Iremonger" , John McNamara , Marko Kovacevic CC: , Pavan Nikhilesh Date: Mon, 11 Nov 2019 18:49:12 +0530 Message-ID: <20191111131914.16559-9-pbhagavatula@marvell.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191111131914.16559-1-pbhagavatula@marvell.com> References: <20191106191803.15098-1-pbhagavatula@marvell.com> <20191111131914.16559-1-pbhagavatula@marvell.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.95,18.0.572 definitions=2019-11-11_04:2019-11-11,2019-11-11 signatures=0 Subject: [dpdk-dev] [PATCH v17 08/10] app/testpmd: add command to set supported ptype mask 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: Pavan Nikhilesh Add command to set supported ptype mask. Usage: set port ptype_mask Signed-off-by: Pavan Nikhilesh --- app/test-pmd/cmdline.c | 84 +++++++++++++++++++++ doc/guides/testpmd_app_ug/testpmd_funcs.rst | 7 ++ 2 files changed, 91 insertions(+) diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index 48627c8aa..da556f91e 100644 --- a/app/test-pmd/cmdline.c +++ b/app/test-pmd/cmdline.c @@ -671,6 +671,9 @@ static void cmd_help_long_parsed(void *parsed_result, "ptype mapping update (port_id) (hw_ptype) (sw_ptype)\n" " Update a ptype mapping item on a port\n\n" + "set port (port_id) ptype_mask (ptype_mask)\n" + " set packet types classification for a specific port\n\n" + "set port (port_id) queue-region region_id (value) " "queue_start_index (value) queue_num (value)\n" " Set a queue region on a port\n\n" @@ -19015,6 +19018,86 @@ cmdline_parse_inst_t cmd_show_rx_tx_desc_status = { }, }; +/* Common result structure for set port ptypes */ +struct cmd_set_port_ptypes_result { + cmdline_fixed_string_t set; + cmdline_fixed_string_t port; + portid_t port_id; + cmdline_fixed_string_t ptype_mask; + uint32_t mask; +}; + +/* Common CLI fields for set port ptypes */ +cmdline_parse_token_string_t cmd_set_port_ptypes_set = + TOKEN_STRING_INITIALIZER + (struct cmd_set_port_ptypes_result, + set, "set"); +cmdline_parse_token_string_t cmd_set_port_ptypes_port = + TOKEN_STRING_INITIALIZER + (struct cmd_set_port_ptypes_result, + port, "port"); +cmdline_parse_token_num_t cmd_set_port_ptypes_port_id = + TOKEN_NUM_INITIALIZER + (struct cmd_set_port_ptypes_result, + port_id, UINT16); +cmdline_parse_token_string_t cmd_set_port_ptypes_mask_str = + TOKEN_STRING_INITIALIZER + (struct cmd_set_port_ptypes_result, + ptype_mask, "ptype_mask"); +cmdline_parse_token_num_t cmd_set_port_ptypes_mask_u32 = + TOKEN_NUM_INITIALIZER + (struct cmd_set_port_ptypes_result, + mask, UINT32); + +static void +cmd_set_port_ptypes_parsed( + void *parsed_result, + __attribute__((unused)) struct cmdline *cl, + __attribute__((unused)) void *data) +{ + struct cmd_set_port_ptypes_result *res = parsed_result; +#define PTYPE_NAMESIZE 256 + char ptype_name[PTYPE_NAMESIZE]; + uint16_t port_id = res->port_id; + uint32_t ptype_mask = res->mask; + int ret, i; + + ret = rte_eth_dev_get_supported_ptypes(port_id, RTE_PTYPE_ALL_MASK, + NULL, 0); + if (ret <= 0) { + printf("Port %d doesn't support any ptypes.\n", port_id); + return; + } + + uint32_t ptypes[ret]; + + ret = rte_eth_dev_set_ptypes(port_id, ptype_mask, ptypes, ret); + if (ret < 0) { + printf("Unable to set requested ptypes for Port %d\n", port_id); + return; + } + + printf("Successfully set following ptypes for Port %d\n", port_id); + for (i = 0; i < ret && ptypes[i] != RTE_PTYPE_UNKNOWN; i++) { + rte_get_ptype_name(ptypes[i], ptype_name, sizeof(ptype_name)); + printf("%s\n", ptype_name); + } +} + +cmdline_parse_inst_t cmd_set_port_ptypes = { + .f = cmd_set_port_ptypes_parsed, + .data = NULL, + .help_str = "set port ptype_mask ", + .tokens = { + (void *)&cmd_set_port_ptypes_set, + (void *)&cmd_set_port_ptypes_port, + (void *)&cmd_set_port_ptypes_port_id, + (void *)&cmd_set_port_ptypes_mask_str, + (void *)&cmd_set_port_ptypes_mask_u32, + NULL, + }, +}; + /* ******************************************************************************** */ /* list of instructions */ @@ -19254,6 +19337,7 @@ cmdline_parse_ctx_t main_ctx[] = { (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_set_port_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 9a5e5cb05..c331b4d90 100644 --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst @@ -480,6 +480,13 @@ Show ptypes supported for a specific port:: testpmd> show port (port_id) ptypes +set port supported ptypes +~~~~~~~~~~~~~~~~~~~~~~~~~ + +set packet types classification for a specific port:: + + testpmd> set port (port_id) ptypes_mask (mask) + show device info ~~~~~~~~~~~~~~~~ -- 2.17.1