From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <dev-bounces@dpdk.org>
Received: from dpdk.org (dpdk.org [92.243.14.124])
	by inbox.dpdk.org (Postfix) with ESMTP id 553F6A034E;
	Thu,  7 Nov 2019 15:36:27 +0100 (CET)
Received: from [92.243.14.124] (localhost [127.0.0.1])
	by dpdk.org (Postfix) with ESMTP id A7C8E1BEF4;
	Thu,  7 Nov 2019 15:36:26 +0100 (CET)
Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com
 [67.231.156.173]) by dpdk.org (Postfix) with ESMTP id 51C821BEF1
 for <dev@dpdk.org>; Thu,  7 Nov 2019 15:36:25 +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
 xA7EQ7h6021143; Thu, 7 Nov 2019 06:36:24 -0800
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com;
 h=from : to : cc :
 subject : date : message-id : references : in-reply-to : content-type :
 content-transfer-encoding : mime-version; s=pfpt0818;
 bh=92nrAs0jqYj3g5ICthrduBueVlNGYw/aMC61QA7xRsU=;
 b=MjRadZBMq77i9ltoOLQg/zj4yCfkLwjFs7bdHeEMMXZ6RfHuQ4zXgqnIDaX9KJnjF+ht
 uQWsCv+yf8D6vkbHR63rxF2WKC1PFWMbOX7Q+UVRysWCmixfMHRkC8gxvXq0WHWAFiAR
 oAE+BWRjj1SQcXjP5t0pWOCmSyTp3XEobqwizUVBSeYxLfq0+10CK3OnpwHCn5x7LYnv
 WH84wZArN0XEOD16GUzlMfyCbyA+25Ki4MKf2g5KxPrbOHhkrzeIwZOT38Et+7MWO5dj
 zv/cLPL7R/fMeBqw9/dOkKYG1SsbjvO3rNyG39aFwnp80Xz31tUz0ObItdYmnIYipkYP dQ== 
Received: from sc-exch01.marvell.com ([199.233.58.181])
 by mx0b-0016f401.pphosted.com with ESMTP id 2w4fq6s84u-1
 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT);
 Thu, 07 Nov 2019 06:36:24 -0800
Received: from SC-EXCH02.marvell.com (10.93.176.82) by SC-EXCH01.marvell.com
 (10.93.176.81) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 7 Nov
 2019 06:36:21 -0800
Received: from NAM03-DM3-obe.outbound.protection.outlook.com (104.47.41.57) by
 SC-EXCH02.marvell.com (10.93.176.82) with Microsoft SMTP Server
 (TLS) id
 15.0.1367.3 via Frontend Transport; Thu, 7 Nov 2019 06:36:21 -0800
ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none;
 b=kN/sXyF9tkxNplJNkis/JcbqK/l7dmlYWs7pO6727W7Q8ZREPPdNr7Iz6MlhEtCqNGLvVi0ZJCtxS0hEEEF6iGcsbMfFrHvEjIFduimSsxCWYgc+atNeVl5BwuTgnxCKguDswGaBqEeIWjqPJAZ8XMJ99xMJQgpT+wN0PUHZ2txQH4Te4fUFhmVDFUOu7qhTf1RT+Zq6MkmhqA8ZS34mbCzttInPLSh3y+7uN0rQzb0zzIWMeLA1+Ejy7EGizSgsjwkwhIRblvSwMmRSGP53180T5UelfRqSDXaALf8h9Fe754V57rB00AagBknoXk43XPW7AjvCBrGSGgjGFxKx2A==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; 
 s=arcselector9901;
 h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck;
 bh=92nrAs0jqYj3g5ICthrduBueVlNGYw/aMC61QA7xRsU=;
 b=ea058qbSuc03C8vVKkF6XzF9drzP7gw9DtCn9OtSzm/NLG53SEKkq+ymb40s6vh30C86c4ygC0grfQuZQlfHNbWkNSbkEoIPfaSJ4QeaNxn9ha5uZs2VyO1El/DKQsoRb3BcernGwO/dR7NZ0IIb8ykWno+IwZrEiAQkMjzIc0QhAURYA2LKxFOeVDO9NRDyT8rte+WLzKMO7wcqRrbo1+ZVwuPoYbOhcJSXfxDTnuv8drfOfFJri7O6XM2/TVtqWsniXDxuSGENdZzMTXpfHkJEPFATrgQlK9ipMTXk44w1/5pCIer43aYpIP4s8x1YukJm5jKv28ycJky7hLJ3aQ==
ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass
 smtp.mailfrom=marvell.com; dmarc=pass action=none header.from=marvell.com;
 dkim=pass header.d=marvell.com; arc=none
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=marvell.onmicrosoft.com; s=selector2-marvell-onmicrosoft-com;
 h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck;
 bh=92nrAs0jqYj3g5ICthrduBueVlNGYw/aMC61QA7xRsU=;
 b=bfHQllgHo4V++CiYn7bX3AEaa24vQ8cgMLNOveCi+PFDsM57K5UKb+Fa6de5hwOV7Dl6/RmPGzdoj8bu/ZcVI+AYgmfXg0rdyVAqul4lB79oAA+bD1FF1SmwXMJaFPItDZIUNcBsZehoYNWaj4JsIoi3ed018jRLvYJcuPBlkxI=
Received: from CY4PR1801MB1863.namprd18.prod.outlook.com (10.171.255.160) by
 CY4PR1801MB1816.namprd18.prod.outlook.com (10.165.89.161) with Microsoft SMTP
 Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id
 15.20.2408.24; Thu, 7 Nov 2019 14:36:20 +0000
Received: from CY4PR1801MB1863.namprd18.prod.outlook.com
 ([fe80::d918:c54e:c3b1:3167]) by CY4PR1801MB1863.namprd18.prod.outlook.com
 ([fe80::d918:c54e:c3b1:3167%7]) with mapi id 15.20.2408.025; Thu, 7 Nov 2019
 14:36:20 +0000
From: Pavan Nikhilesh Bhagavatula <pbhagavatula@marvell.com>
To: "Iremonger, Bernard" <bernard.iremonger@intel.com>, "Yigit, Ferruh"
 <ferruh.yigit@intel.com>, "arybchenko@solarflare.com"
 <arybchenko@solarflare.com>,
 Jerin Jacob Kollanukkaran <jerinj@marvell.com>,
 "thomas@monjalon.net" <thomas@monjalon.net>, "Lu, Wenzhuo"
 <wenzhuo.lu@intel.com>, "Wu, Jingjing" <jingjing.wu@intel.com>, "Mcnamara,
 John" <john.mcnamara@intel.com>, "Kovacevic, Marko"
 <marko.kovacevic@intel.com>
CC: "dev@dpdk.org" <dev@dpdk.org>
Thread-Topic: [dpdk-dev] [PATCH v16 8/8] app/testpmd: add command to set
 supported ptype mask
Thread-Index: AQHVlWKVVAthyCSD4Em14MgcHNDXc6d/ossAgAAh/KA=
Date: Thu, 7 Nov 2019 14:36:20 +0000
Message-ID: <CY4PR1801MB1863F11E5A4F2A1EACCCBF45DE780@CY4PR1801MB1863.namprd18.prod.outlook.com>
References: <20191029153722.4547-1-pbhagavatula@marvell.com>
 <20191106191803.15098-1-pbhagavatula@marvell.com>
 <20191106191803.15098-9-pbhagavatula@marvell.com>
 <8CEF83825BEC744B83065625E567D7C260E22E87@IRSMSX108.ger.corp.intel.com>
 <8CEF83825BEC744B83065625E567D7C260E22EB4@IRSMSX108.ger.corp.intel.com>
In-Reply-To: <8CEF83825BEC744B83065625E567D7C260E22EB4@IRSMSX108.ger.corp.intel.com>
Accept-Language: en-IN, en-US
Content-Language: en-US
X-MS-Has-Attach: 
X-MS-TNEF-Correlator: 
x-originating-ip: [117.198.150.252]
x-ms-publictraffictype: Email
x-ms-office365-filtering-correlation-id: 49728c95-525c-497d-dc25-08d7638fdb01
x-ms-traffictypediagnostic: CY4PR1801MB1816:
x-ms-exchange-transport-forked: True
x-microsoft-antispam-prvs: <CY4PR1801MB1816E2578ADD38D605B76C8DDE780@CY4PR1801MB1816.namprd18.prod.outlook.com>
x-ms-oob-tlc-oobclassifiers: OLM:298;
x-forefront-prvs: 0214EB3F68
x-forefront-antispam-report: SFV:NSPM;
 SFS:(10009020)(4636009)(376002)(136003)(346002)(396003)(39850400004)(366004)(189003)(199004)(8676002)(7696005)(110136005)(7736002)(476003)(55236004)(102836004)(14444005)(6246003)(9686003)(305945005)(229853002)(14454004)(478600001)(486006)(8936002)(81156014)(52536014)(86362001)(81166006)(5660300002)(6436002)(4326008)(186003)(25786009)(64756008)(26005)(76116006)(316002)(2501003)(66556008)(3846002)(66066001)(66446008)(66946007)(66476007)(256004)(446003)(6116002)(33656002)(99286004)(71190400001)(55016002)(71200400001)(11346002)(74316002)(2906002)(6506007)(76176011)(921003)(1121003);
 DIR:OUT; SFP:1101; SCL:1; SRVR:CY4PR1801MB1816;
 H:CY4PR1801MB1863.namprd18.prod.outlook.com; FPR:; SPF:None; LANG:en;
 PTR:InfoNoRecords; MX:1; A:1; 
received-spf: None (protection.outlook.com: marvell.com does not designate
 permitted sender hosts)
x-ms-exchange-senderadcheck: 1
x-microsoft-antispam: BCL:0;
x-microsoft-antispam-message-info: ct83gnd602Q0fyjxScrW8nylkIdeojR3JYRyaUomJNJ7/RPk5tJs0yBCT1ga3V8UzI39iloYGE6WeIn1Om526yVNUFQVCWk4rpEKRVkAef1hkC0y+tUG9BeTAus8YNAPu5dZallvanZvyf6jI2I9A1pd/9eYCHenfmIzUV1Sw0xywPpVYURMy/dld0c2R7eIPlCFkBxkAw5dfIyGFIqMfVu6rAKVytmsaU8QpXBKY94CUUHVgSWFgTVvI89XfptM7Ne/7APV//n3M08v7ivY2LeJg8TY0gPPujxAuQKgx6bWmj/uXn7bxZR4p/ospcfhpYlWnIR9hnWVk4iZRUNQ4vVUY9Ax41VC+V2XUDH6R6MohxZDfi9IagCW1dT5PWdNRvQu7my2/iGViF0gitOoYrki1OPVyLttHrD9kaHk45T0mnONzTamNNIY3tT1SqWN
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0
X-MS-Exchange-CrossTenant-Network-Message-Id: 49728c95-525c-497d-dc25-08d7638fdb01
X-MS-Exchange-CrossTenant-originalarrivaltime: 07 Nov 2019 14:36:20.1020 (UTC)
X-MS-Exchange-CrossTenant-fromentityheader: Hosted
X-MS-Exchange-CrossTenant-id: 70e1fb47-1155-421d-87fc-2e58f638b6e0
X-MS-Exchange-CrossTenant-mailboxtype: HOSTED
X-MS-Exchange-CrossTenant-userprincipalname: 5vMfWvChomPJ5gPY8vbgwK65I5/Q6C2x0bLeaduUPJLJalFLUiUpJbK+K6egVS3hRbbN1rg3xyY6Ppevna4R02muU4gs7LPF055JLn1jC5g=
X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR1801MB1816
X-OriginatorOrg: marvell.com
X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.95,18.0.572
 definitions=2019-11-07_05:2019-11-07,2019-11-07 signatures=0
Subject: Re: [dpdk-dev] [PATCH v16 8/8] 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 <dev.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
Errors-To: dev-bounces@dpdk.org
Sender: "dev" <dev-bounces@dpdk.org>


Hi Bernard,

>Hi Pavin,
>
><snip>
>
>> > Subject: [dpdk-dev] [PATCH v16 8/8] app/testpmd: add command
>to set
>> > supported ptype mask
>> >
>> > From: Pavan Nikhilesh <pbhagavatula@marvell.com>
>> >
>> > Add command to set supported ptype mask.
>> > Usage:
>> > 	set port <port_id> ptype_mask <ptype_mask>
>> >
>> > Disable ptype parsing by default.
>> >
>> > Signed-off-by: Pavan Nikhilesh <pbhagavatula@marvell.com>
>> > ---
>> >  app/test-pmd/cmdline.c                      | 83 ++++++++++++++++++++=
+
>> >  app/test-pmd/testpmd.c                      |  5 ++
>> >  doc/guides/testpmd_app_ug/testpmd_funcs.rst |  7 ++
>> >  3 files changed, 95 insertions(+)
>> >
>> > diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
>index
>> > 49c45a3f0..7af2c58c3 100644
>> > --- a/app/test-pmd/cmdline.c
>> > +++ b/app/test-pmd/cmdline.c
>>
>> The help text should be updated to describe the new command at
>line 240 in
>> cmdline.c
>>
>> > @@ -668,6 +668,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"
>> > @@ -18916,6 +18919,85 @@ cmdline_parse_inst_t
>> > cmd_show_port_supported_ptypes =3D {
>> >  	},
>> >  };
>> >
>> > +/* 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 =3D
>> > +	TOKEN_STRING_INITIALIZER
>> > +		(struct cmd_set_port_ptypes_result,
>> > +		 set, "set");
>> > +cmdline_parse_token_string_t cmd_set_port_ptypes_port =3D
>> > +	TOKEN_STRING_INITIALIZER
>> > +		(struct cmd_set_port_ptypes_result,
>> > +		 port, "port");
>> > +cmdline_parse_token_num_t cmd_set_port_ptypes_port_id =3D
>> > +	TOKEN_NUM_INITIALIZER
>> > +		(struct cmd_set_port_ptypes_result,
>> > +		 port_id, UINT16);
>> > +cmdline_parse_token_string_t cmd_set_port_ptypes_mask_str =3D
>> > +	TOKEN_STRING_INITIALIZER
>> > +		(struct cmd_set_port_ptypes_result,
>> > +		 ptype_mask, "ptype_mask");
>> > +cmdline_parse_token_num_t cmd_set_port_ptypes_mask_u32 =3D
>> > +	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 =3D parsed_result;
>> > +#define PTYPE_NAMESIZE        256
>> > +	char ptype_name[PTYPE_NAMESIZE];
>> > +	uint16_t port_id =3D res->port_id;
>> > +	uint32_t ptype_mask =3D res->mask;
>> > +	int ret, i;
>> > +
>> > +	ret =3D rte_eth_dev_get_supported_ptypes(port_id,
>ptype_mask,
>> > NULL, 0);
>
>The last 2 parameters to the above function do not look correct, here is
>the function declaration:
>int rte_eth_dev_get_supported_ptypes(uint16_t port_id, uint32_t
>ptype_mask,  uint32_t *ptypes, int num);
>
>ptypes should be a pointer to an array to hold the ptypes, and num
>should be the size of the array.

We can use the same API to get the number of ptypes supported to initialize=
 the=20
array below.

@see examples/l3fwd/l3fwd_lpm.c +424

>
>> > +	if (ret <=3D 0) {
>> > +		printf("Port %d doesn't support any ptypes.\n",
>port_id);
>> > +		return;
>> > +	}
>> > +
>> > +	uint32_t ptypes[ret];
>
>The above declaration can then be moved to the top of the function
>with the other declarations.


I intentionally placed it here as the array size depends on ret and there i=
s=20
no readily available macro for max number of packet types.


Thanks,
Pavan.

>
>> > +
>> > +	ret =3D rte_eth_dev_set_ptypes(port_id, ptype_mask, ptypes,
>ret);
>> > +	if (ret <=3D 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 =3D 0; i < ret && ptypes[i] !=3D 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 =3D {
>> > +	.f =3D cmd_set_port_ptypes_parsed,
>> > +	.data =3D NULL,
>> > +	.help_str =3D "set port <port_id> ptype_mask <mask>",
>> > +	.tokens =3D {
>> > +		(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 */
>> > @@ -19155,6 +19237,7 @@ cmdline_parse_ctx_t main_ctx[] =3D {
>> >  	(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/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index
>> > 5ba974162..812aebf35 100644
>> > --- a/app/test-pmd/testpmd.c
>> > +++ b/app/test-pmd/testpmd.c
>> > @@ -2024,6 +2024,7 @@ start_port(portid_t pid)
>> >  	queueid_t qi;
>> >  	struct rte_port *port;
>> >  	struct rte_ether_addr mac_addr;
>> > +	static uint8_t clr_ptypes =3D 1;
>> >
>> >  	if (port_id_is_invalid(pid, ENABLED_WARN))
>> >  		return 0;
>> > @@ -2153,6 +2154,10 @@ start_port(portid_t pid)
>> >  			}
>> >  		}
>> >  		configure_rxtx_dump_callbacks(verbose_level);
>> > +		if (clr_ptypes) {
>> > +			clr_ptypes =3D 0;
>> > +			rte_eth_dev_set_ptypes(pi,
>> > RTE_PTYPE_UNKNOWN, NULL, 0);
>> > +		}
>> >  		/* start port */
>> >  		if (rte_eth_dev_start(pi) < 0) {
>> >  			printf("Fail to start port %d\n", pi); diff --git
>> > a/doc/guides/testpmd_app_ug/testpmd_funcs.rst
>> > b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
>> > index c68a742eb..f78ac9444 100644
>> > --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst
>> > +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
>> > @@ -472,6 +472,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
> Regards,
>
> Bernard.