DPDK patches and discussions
 help / color / mirror / Atom feed
From: "Iremonger, Bernard" <bernard.iremonger@intel.com>
To: "vattunuru@marvell.com" <vattunuru@marvell.com>,
	"dev@dpdk.org" <dev@dpdk.org>
Cc: "Lu, Wenzhuo" <wenzhuo.lu@intel.com>,
	"Wu, Jingjing" <jingjing.wu@intel.com>,
	"thomas@monjalon.net" <thomas@monjalon.net>
Subject: Re: [dpdk-dev] [PATCH v1 1/1] app/testpmd: add function to display port supported ptypes
Date: Thu, 12 Sep 2019 10:53:49 +0000	[thread overview]
Message-ID: <8CEF83825BEC744B83065625E567D7C260DF7131@IRSMSX108.ger.corp.intel.com> (raw)
In-Reply-To: <20190901040731.13820-1-vattunuru@marvell.com>

Hi Vamsi,

> -----Original Message-----
> From: vattunuru@marvell.com [mailto:vattunuru@marvell.com]
> Sent: Sunday, September 1, 2019 5:08 AM
> To: dev@dpdk.org
> Cc: Lu, Wenzhuo <wenzhuo.lu@intel.com>; Wu, Jingjing
> <jingjing.wu@intel.com>; Iremonger, Bernard <bernard.iremonger@intel.com>;
> thomas@monjalon.net; Vamsi Attunuru <vattunuru@marvell.com>
> Subject: [dpdk-dev] [PATCH v1 1/1] app/testpmd: add function to display port
> supported ptypes
> 
> From: Vamsi Attunuru <vattunuru@marvell.com>
> 
> Patch adds a runtime function to display ptypes supported by the given port in
> different layers.
> 
> Signed-off-by: Vamsi Attunuru <vattunuru@marvell.com>
> ---
>  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 (<identifier>|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;

It would be better to replace 0xf0000000 with a  macro.

> +	uint16_t port_id = res->port_id;
> +	int max_layer_ptypes = 16;
> +	uint32_t ptypes[max_layer_ptypes];
> +	char buf[256], ltype[32];

It would be better to replace the numbers 16, 256 and 32 with macros.

> +	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 <port_id> 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

The 19.11 release notes should also be updated to announce the new command.

Regards,

Bernard.


  reply	other threads:[~2019-09-12 10:53 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-01  4:07 vattunuru
2019-09-12 10:53 ` Iremonger, Bernard [this message]
2019-09-13  5:40 ` [dpdk-dev] [PATCH v2 1/1] app/testpmd: add console cmd to show " vattunuru
2019-09-16 10:48   ` Iremonger, Bernard
2019-09-19  3:48   ` [dpdk-dev] [dpdk-dev PATCH v3 " vattunuru
2019-09-19  3:50   ` [dpdk-dev] [PATCH " vattunuru
2019-09-19  9:16     ` Iremonger, Bernard
2019-10-09 17:02       ` Ferruh Yigit

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=8CEF83825BEC744B83065625E567D7C260DF7131@IRSMSX108.ger.corp.intel.com \
    --to=bernard.iremonger@intel.com \
    --cc=dev@dpdk.org \
    --cc=jingjing.wu@intel.com \
    --cc=thomas@monjalon.net \
    --cc=vattunuru@marvell.com \
    --cc=wenzhuo.lu@intel.com \
    /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).