diff mbox series

[2/2] app/testpmd: add meter profile packet mode option

Message ID 20210331085405.1445546-3-lizh@nvidia.com (mailing list archive)
State Superseded
Delegated to: Ferruh Yigit
Headers show
Series Support PPS(packet per second) on meter | expand

Checks

Context Check Description
ci/Intel-compilation fail apply issues
ci/checkpatch success coding style OK

Commit Message

Li Zhang March 31, 2021, 8:54 a.m. UTC
add meter profile packet_mode to the ethernet device.
One example:
add port meter profile rfc2697 (port_id) (profile_id)
(cir) (cbs) (ebs) (packet_mode)

Signed-off-by: Li Zhang <lizh@nvidia.com>
---
 app/test-pmd/cmdline_mtr.c                  | 40 +++++++++++++++++++--
 doc/guides/testpmd_app_ug/testpmd_funcs.rst | 31 ++++++++--------
 2 files changed, 54 insertions(+), 17 deletions(-)

Comments

Dumitrescu, Cristian April 7, 2021, 8:17 p.m. UTC | #1
> -----Original Message-----
> From: Li Zhang <lizh@nvidia.com>
> Sent: Wednesday, March 31, 2021 9:54 AM
> To: dekelp@nvidia.com; orika@nvidia.com; viacheslavo@nvidia.com;
> matan@nvidia.com; shahafs@nvidia.com; Dumitrescu, Cristian
> <cristian.dumitrescu@intel.com>; Li, Xiaoyun <xiaoyun.li@intel.com>
> Cc: dev@dpdk.org; thomas@monjalon.net; rasland@nvidia.com;
> roniba@nvidia.com
> Subject: [PATCH 2/2] app/testpmd: add meter profile packet mode option
> 
> add meter profile packet_mode to the ethernet device.
> One example:
> add port meter profile rfc2697 (port_id) (profile_id)
> (cir) (cbs) (ebs) (packet_mode)
> 
> Signed-off-by: Li Zhang <lizh@nvidia.com>
> ---
>  app/test-pmd/cmdline_mtr.c                  | 40 +++++++++++++++++++--
>  doc/guides/testpmd_app_ug/testpmd_funcs.rst | 31 ++++++++--------
>  2 files changed, 54 insertions(+), 17 deletions(-)
> 
> diff --git a/app/test-pmd/cmdline_mtr.c b/app/test-pmd/cmdline_mtr.c
> index bdc9ae8bfe..eff2473e7b 100644
> --- a/app/test-pmd/cmdline_mtr.c
> +++ b/app/test-pmd/cmdline_mtr.c
> @@ -263,6 +263,18 @@ static void cmd_show_port_meter_cap_parsed(void
> *parsed_result,
>  		cap.color_aware_trtcm_rfc2698_supported);
>  	printf("cap.color_aware_trtcm_rfc4115_supported %" PRId32 "\n",
>  		cap.color_aware_trtcm_rfc4115_supported);
> +	printf("cap.srtcm_rfc2697_byte_mode_supported %" PRId32 "\n",
> +		cap.srtcm_rfc2697_byte_mode_supported);
> +	printf("cap.srtcm_rfc2697_packet_mode_supported %" PRId32 "\n",
> +		cap.srtcm_rfc2697_packet_mode_supported);
> +	printf("cap.trtcm_rfc2698_byte_mode_supported %" PRId32 "\n",
> +		cap.trtcm_rfc2698_byte_mode_supported);
> +	printf("cap.trtcm_rfc2698_packet_mode_supported %" PRId32 "\n",
> +		cap.trtcm_rfc2698_packet_mode_supported);
> +	printf("cap.trtcm_rfc4115_byte_mode_supported %" PRId32 "\n",
> +		cap.trtcm_rfc4115_byte_mode_supported);
> +	printf("cap.trtcm_rfc4115_packet_mode_supported %" PRId32 "\n",
> +		cap.trtcm_rfc4115_packet_mode_supported);
>  	printf("cap.stats_mask %" PRIx64 "\n", cap.stats_mask);
>  }
> 
> @@ -292,6 +304,7 @@ struct cmd_add_port_meter_profile_srtcm_result {
>  	uint64_t cir;
>  	uint64_t cbs;
>  	uint64_t ebs;
> +	int packet_mode;
>  };
> 
>  cmdline_parse_token_string_t cmd_add_port_meter_profile_srtcm_add =
> @@ -333,6 +346,10 @@ cmdline_parse_token_num_t
> cmd_add_port_meter_profile_srtcm_ebs =
>  	TOKEN_NUM_INITIALIZER(
>  		struct cmd_add_port_meter_profile_srtcm_result,
>  			ebs, RTE_UINT64);
> +cmdline_parse_token_num_t
> cmd_add_port_meter_profile_srtcm_packet_mode =
> +	TOKEN_NUM_INITIALIZER(
> +		struct cmd_add_port_meter_profile_srtcm_result,
> +			packet_mode, RTE_UINT32);
> 
>  static void cmd_add_port_meter_profile_srtcm_parsed(void
> *parsed_result,
>  	__rte_unused struct cmdline *cl,
> @@ -354,6 +371,7 @@ static void
> cmd_add_port_meter_profile_srtcm_parsed(void *parsed_result,
>  	mp.srtcm_rfc2697.cir = res->cir;
>  	mp.srtcm_rfc2697.cbs = res->cbs;
>  	mp.srtcm_rfc2697.ebs = res->ebs;
> +	mp.packet_mode = res->packet_mode;
> 
>  	ret = rte_mtr_meter_profile_add(port_id, profile_id, &mp, &error);
>  	if (ret != 0) {
> @@ -365,7 +383,7 @@ static void
> cmd_add_port_meter_profile_srtcm_parsed(void *parsed_result,
>  cmdline_parse_inst_t cmd_add_port_meter_profile_srtcm = {
>  	.f = cmd_add_port_meter_profile_srtcm_parsed,
>  	.data = NULL,
> -	.help_str = "add port meter profile srtcm_rfc2697 <port_id>
> <profile_id> <cir> <cbs> <ebs>",
> +	.help_str = "add port meter profile srtcm_rfc2697 <port_id>
> <profile_id> <cir> <cbs> <ebs> <packet_mode>",
>  	.tokens = {
>  		(void *)&cmd_add_port_meter_profile_srtcm_add,
>  		(void *)&cmd_add_port_meter_profile_srtcm_port,
> @@ -377,6 +395,7 @@ cmdline_parse_inst_t
> cmd_add_port_meter_profile_srtcm = {
>  		(void *)&cmd_add_port_meter_profile_srtcm_cir,
>  		(void *)&cmd_add_port_meter_profile_srtcm_cbs,
>  		(void *)&cmd_add_port_meter_profile_srtcm_ebs,
> +		(void
> *)&cmd_add_port_meter_profile_srtcm_packet_mode,
>  		NULL,
>  	},
>  };
> @@ -394,6 +413,7 @@ struct cmd_add_port_meter_profile_trtcm_result {
>  	uint64_t pir;
>  	uint64_t cbs;
>  	uint64_t pbs;
> +	int packet_mode;
>  };
> 
>  cmdline_parse_token_string_t cmd_add_port_meter_profile_trtcm_add =
> @@ -439,6 +459,10 @@ cmdline_parse_token_num_t
> cmd_add_port_meter_profile_trtcm_pbs =
>  	TOKEN_NUM_INITIALIZER(
>  		struct cmd_add_port_meter_profile_trtcm_result,
>  			pbs, RTE_UINT64);
> +cmdline_parse_token_num_t
> cmd_add_port_meter_profile_trtcm_packet_mode =
> +	TOKEN_NUM_INITIALIZER(
> +		struct cmd_add_port_meter_profile_trtcm_result,
> +			packet_mode, RTE_UINT32);
> 
>  static void cmd_add_port_meter_profile_trtcm_parsed(void
> *parsed_result,
>  	__rte_unused struct cmdline *cl,
> @@ -461,6 +485,7 @@ static void
> cmd_add_port_meter_profile_trtcm_parsed(void *parsed_result,
>  	mp.trtcm_rfc2698.pir = res->pir;
>  	mp.trtcm_rfc2698.cbs = res->cbs;
>  	mp.trtcm_rfc2698.pbs = res->pbs;
> +	mp.packet_mode = res->packet_mode;
> 
>  	ret = rte_mtr_meter_profile_add(port_id, profile_id, &mp, &error);
>  	if (ret != 0) {
> @@ -472,7 +497,7 @@ static void
> cmd_add_port_meter_profile_trtcm_parsed(void *parsed_result,
>  cmdline_parse_inst_t cmd_add_port_meter_profile_trtcm = {
>  	.f = cmd_add_port_meter_profile_trtcm_parsed,
>  	.data = NULL,
> -	.help_str = "add port meter profile trtcm_rfc2698 <port_id>
> <profile_id> <cir> <pir> <cbs> <pbs>",
> +	.help_str = "add port meter profile trtcm_rfc2698 <port_id>
> <profile_id> <cir> <pir> <cbs> <pbs> <packet_mode>",
>  	.tokens = {
>  		(void *)&cmd_add_port_meter_profile_trtcm_add,
>  		(void *)&cmd_add_port_meter_profile_trtcm_port,
> @@ -485,6 +510,7 @@ cmdline_parse_inst_t
> cmd_add_port_meter_profile_trtcm = {
>  		(void *)&cmd_add_port_meter_profile_trtcm_pir,
>  		(void *)&cmd_add_port_meter_profile_trtcm_cbs,
>  		(void *)&cmd_add_port_meter_profile_trtcm_pbs,
> +		(void
> *)&cmd_add_port_meter_profile_trtcm_packet_mode,
>  		NULL,
>  	},
>  };
> @@ -502,6 +528,7 @@ struct
> cmd_add_port_meter_profile_trtcm_rfc4115_result {
>  	uint64_t eir;
>  	uint64_t cbs;
>  	uint64_t ebs;
> +	int packet_mode;
>  };
> 
>  cmdline_parse_token_string_t
> cmd_add_port_meter_profile_trtcm_rfc4115_add =
> @@ -549,6 +576,11 @@ cmdline_parse_token_num_t
> cmd_add_port_meter_profile_trtcm_rfc4115_ebs =
>  	TOKEN_NUM_INITIALIZER(
>  		struct cmd_add_port_meter_profile_trtcm_rfc4115_result,
>  			ebs, RTE_UINT64);
> +cmdline_parse_token_num_t
> +	cmd_add_port_meter_profile_trtcm_rfc4115_packet_mode =
> +	TOKEN_NUM_INITIALIZER(
> +		struct cmd_add_port_meter_profile_trtcm_rfc4115_result,
> +			packet_mode, RTE_UINT32);
> 
>  static void cmd_add_port_meter_profile_trtcm_rfc4115_parsed(
>  	void *parsed_result,
> @@ -573,6 +605,7 @@ static void
> cmd_add_port_meter_profile_trtcm_rfc4115_parsed(
>  	mp.trtcm_rfc4115.eir = res->eir;
>  	mp.trtcm_rfc4115.cbs = res->cbs;
>  	mp.trtcm_rfc4115.ebs = res->ebs;
> +	mp.packet_mode = res->packet_mode;
> 
>  	ret = rte_mtr_meter_profile_add(port_id, profile_id, &mp, &error);
>  	if (ret != 0) {
> @@ -584,7 +617,7 @@ static void
> cmd_add_port_meter_profile_trtcm_rfc4115_parsed(
>  cmdline_parse_inst_t cmd_add_port_meter_profile_trtcm_rfc4115 = {
>  	.f = cmd_add_port_meter_profile_trtcm_rfc4115_parsed,
>  	.data = NULL,
> -	.help_str = "add port meter profile trtcm_rfc4115 <port_id>
> <profile_id> <cir> <eir> <cbs> <ebs>",
> +	.help_str = "add port meter profile trtcm_rfc4115 <port_id>
> <profile_id> <cir> <eir> <cbs> <ebs> <packet_mode>",
>  	.tokens = {
>  		(void *)&cmd_add_port_meter_profile_trtcm_rfc4115_add,
>  		(void *)&cmd_add_port_meter_profile_trtcm_rfc4115_port,
> @@ -597,6 +630,7 @@ cmdline_parse_inst_t
> cmd_add_port_meter_profile_trtcm_rfc4115 = {
>  		(void *)&cmd_add_port_meter_profile_trtcm_rfc4115_eir,
>  		(void *)&cmd_add_port_meter_profile_trtcm_rfc4115_cbs,
>  		(void *)&cmd_add_port_meter_profile_trtcm_rfc4115_ebs,
> +		(void
> *)&cmd_add_port_meter_profile_trtcm_rfc4115_packet_mode,
>  		NULL,
>  	},
>  };
> diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst
> b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
> index f59eb8a27d..b5e52f6b1c 100644
> --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst
> +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
> @@ -2698,14 +2698,15 @@ add port meter profile (srTCM rfc2967)
>  Add meter profile (srTCM rfc2697) to the ethernet device::
> 
>     testpmd> add port meter profile srtcm_rfc2697 (port_id) (profile_id) \
> -   (cir) (cbs) (ebs)
> +   (cir) (cbs) (ebs) (packet_mode)
> 
>  where:
> 
>  * ``profile_id``: ID for the meter profile.
> -* ``cir``: Committed Information Rate (CIR) (bytes/second).
> -* ``cbs``: Committed Burst Size (CBS) (bytes).
> -* ``ebs``: Excess Burst Size (EBS) (bytes).
> +* ``cir``: Committed Information Rate (CIR) (bytes per second or packets per
> second).
> +* ``cbs``: Committed Burst Size (CBS) (bytes or packets).
> +* ``ebs``: Excess Burst Size (EBS) (bytes or packets).
> +* ``packet_mode``: Packets mode for meter profile.
> 
>  add port meter profile (trTCM rfc2968)
>  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> @@ -2713,15 +2714,16 @@ add port meter profile (trTCM rfc2968)
>  Add meter profile (srTCM rfc2698) to the ethernet device::
> 
>     testpmd> add port meter profile trtcm_rfc2698 (port_id) (profile_id) \
> -   (cir) (pir) (cbs) (pbs)
> +   (cir) (pir) (cbs) (pbs) (packet_mode)
> 
>  where:
> 
>  * ``profile_id``: ID for the meter profile.
> -* ``cir``: Committed information rate (bytes/second).
> -* ``pir``: Peak information rate (bytes/second).
> -* ``cbs``: Committed burst size (bytes).
> -* ``pbs``: Peak burst size (bytes).
> +* ``cir``: Committed information rate (bytes per second or packets per
> second).
> +* ``pir``: Peak information rate (bytes per second or packets per second).
> +* ``cbs``: Committed burst size (bytes or packets).
> +* ``pbs``: Peak burst size (bytes or packets).
> +* ``packet_mode``: Packets mode for meter profile.
> 
>  add port meter profile (trTCM rfc4115)
>  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> @@ -2729,15 +2731,16 @@ add port meter profile (trTCM rfc4115)
>  Add meter profile (trTCM rfc4115) to the ethernet device::
> 
>     testpmd> add port meter profile trtcm_rfc4115 (port_id) (profile_id) \
> -   (cir) (eir) (cbs) (ebs)
> +   (cir) (eir) (cbs) (ebs) (packet_mode)
> 
>  where:
> 
>  * ``profile_id``: ID for the meter profile.
> -* ``cir``: Committed information rate (bytes/second).
> -* ``eir``: Excess information rate (bytes/second).
> -* ``cbs``: Committed burst size (bytes).
> -* ``ebs``: Excess burst size (bytes).
> +* ``cir``: Committed information rate (bytes per second or packets per
> second).
> +* ``eir``: Excess information rate (bytes per second or packets per second).
> +* ``cbs``: Committed burst size (bytes or packets).
> +* ``ebs``: Excess burst size (bytes or packets).
> +* ``packet_mode``: Packets mode for meter profile.
> 
>  delete port meter profile
>  ~~~~~~~~~~~~~~~~~~~~~~~~~
> --
> 2.27.0

There is already a patch from this series numbered PATCH 2/2. Does this belong to the same series?

It is not easy to review this set of patches related to the packet mode addition to the API, as it is split across multiple patch series and the numbering is confusing. I am not sure I am replying to the latest version or a superseded one.

Could you please create a unified V2 that contains both the series with the API changes and the series with the necessary error checks in the drivers?
Dumitrescu, Cristian April 7, 2021, 8:21 p.m. UTC | #2
> -----Original Message-----
> From: Li Zhang <lizh@nvidia.com>
> Sent: Wednesday, March 31, 2021 9:54 AM
> To: dekelp@nvidia.com; orika@nvidia.com; viacheslavo@nvidia.com;
> matan@nvidia.com; shahafs@nvidia.com; Dumitrescu, Cristian
> <cristian.dumitrescu@intel.com>; Li, Xiaoyun <xiaoyun.li@intel.com>
> Cc: dev@dpdk.org; thomas@monjalon.net; rasland@nvidia.com;
> roniba@nvidia.com
> Subject: [PATCH 2/2] app/testpmd: add meter profile packet mode option
> 
> add meter profile packet_mode to the ethernet device.
> One example:
> add port meter profile rfc2697 (port_id) (profile_id)
> (cir) (cbs) (ebs) (packet_mode)
> 
> Signed-off-by: Li Zhang <lizh@nvidia.com>
> ---
>  app/test-pmd/cmdline_mtr.c                  | 40 +++++++++++++++++++--
>  doc/guides/testpmd_app_ug/testpmd_funcs.rst | 31 ++++++++--------
>  2 files changed, 54 insertions(+), 17 deletions(-)
> 
> diff --git a/app/test-pmd/cmdline_mtr.c b/app/test-pmd/cmdline_mtr.c
> index bdc9ae8bfe..eff2473e7b 100644
> --- a/app/test-pmd/cmdline_mtr.c
> +++ b/app/test-pmd/cmdline_mtr.c
> @@ -263,6 +263,18 @@ static void cmd_show_port_meter_cap_parsed(void
> *parsed_result,
>  		cap.color_aware_trtcm_rfc2698_supported);
>  	printf("cap.color_aware_trtcm_rfc4115_supported %" PRId32 "\n",
>  		cap.color_aware_trtcm_rfc4115_supported);
> +	printf("cap.srtcm_rfc2697_byte_mode_supported %" PRId32 "\n",
> +		cap.srtcm_rfc2697_byte_mode_supported);
> +	printf("cap.srtcm_rfc2697_packet_mode_supported %" PRId32 "\n",
> +		cap.srtcm_rfc2697_packet_mode_supported);
> +	printf("cap.trtcm_rfc2698_byte_mode_supported %" PRId32 "\n",
> +		cap.trtcm_rfc2698_byte_mode_supported);
> +	printf("cap.trtcm_rfc2698_packet_mode_supported %" PRId32 "\n",
> +		cap.trtcm_rfc2698_packet_mode_supported);
> +	printf("cap.trtcm_rfc4115_byte_mode_supported %" PRId32 "\n",
> +		cap.trtcm_rfc4115_byte_mode_supported);
> +	printf("cap.trtcm_rfc4115_packet_mode_supported %" PRId32 "\n",
> +		cap.trtcm_rfc4115_packet_mode_supported);
>  	printf("cap.stats_mask %" PRIx64 "\n", cap.stats_mask);
>  }
> 
> @@ -292,6 +304,7 @@ struct cmd_add_port_meter_profile_srtcm_result {
>  	uint64_t cir;
>  	uint64_t cbs;
>  	uint64_t ebs;
> +	int packet_mode;
>  };
> 
>  cmdline_parse_token_string_t cmd_add_port_meter_profile_srtcm_add =
> @@ -333,6 +346,10 @@ cmdline_parse_token_num_t
> cmd_add_port_meter_profile_srtcm_ebs =
>  	TOKEN_NUM_INITIALIZER(
>  		struct cmd_add_port_meter_profile_srtcm_result,
>  			ebs, RTE_UINT64);
> +cmdline_parse_token_num_t
> cmd_add_port_meter_profile_srtcm_packet_mode =
> +	TOKEN_NUM_INITIALIZER(
> +		struct cmd_add_port_meter_profile_srtcm_result,
> +			packet_mode, RTE_UINT32);
> 
>  static void cmd_add_port_meter_profile_srtcm_parsed(void
> *parsed_result,
>  	__rte_unused struct cmdline *cl,
> @@ -354,6 +371,7 @@ static void
> cmd_add_port_meter_profile_srtcm_parsed(void *parsed_result,
>  	mp.srtcm_rfc2697.cir = res->cir;
>  	mp.srtcm_rfc2697.cbs = res->cbs;
>  	mp.srtcm_rfc2697.ebs = res->ebs;
> +	mp.packet_mode = res->packet_mode;
> 
>  	ret = rte_mtr_meter_profile_add(port_id, profile_id, &mp, &error);
>  	if (ret != 0) {
> @@ -365,7 +383,7 @@ static void
> cmd_add_port_meter_profile_srtcm_parsed(void *parsed_result,
>  cmdline_parse_inst_t cmd_add_port_meter_profile_srtcm = {
>  	.f = cmd_add_port_meter_profile_srtcm_parsed,
>  	.data = NULL,
> -	.help_str = "add port meter profile srtcm_rfc2697 <port_id>
> <profile_id> <cir> <cbs> <ebs>",
> +	.help_str = "add port meter profile srtcm_rfc2697 <port_id>
> <profile_id> <cir> <cbs> <ebs> <packet_mode>",
>  	.tokens = {
>  		(void *)&cmd_add_port_meter_profile_srtcm_add,
>  		(void *)&cmd_add_port_meter_profile_srtcm_port,
> @@ -377,6 +395,7 @@ cmdline_parse_inst_t
> cmd_add_port_meter_profile_srtcm = {
>  		(void *)&cmd_add_port_meter_profile_srtcm_cir,
>  		(void *)&cmd_add_port_meter_profile_srtcm_cbs,
>  		(void *)&cmd_add_port_meter_profile_srtcm_ebs,
> +		(void
> *)&cmd_add_port_meter_profile_srtcm_packet_mode,
>  		NULL,
>  	},
>  };
> @@ -394,6 +413,7 @@ struct cmd_add_port_meter_profile_trtcm_result {
>  	uint64_t pir;
>  	uint64_t cbs;
>  	uint64_t pbs;
> +	int packet_mode;
>  };
> 
>  cmdline_parse_token_string_t cmd_add_port_meter_profile_trtcm_add =
> @@ -439,6 +459,10 @@ cmdline_parse_token_num_t
> cmd_add_port_meter_profile_trtcm_pbs =
>  	TOKEN_NUM_INITIALIZER(
>  		struct cmd_add_port_meter_profile_trtcm_result,
>  			pbs, RTE_UINT64);
> +cmdline_parse_token_num_t
> cmd_add_port_meter_profile_trtcm_packet_mode =
> +	TOKEN_NUM_INITIALIZER(
> +		struct cmd_add_port_meter_profile_trtcm_result,
> +			packet_mode, RTE_UINT32);
> 
>  static void cmd_add_port_meter_profile_trtcm_parsed(void
> *parsed_result,
>  	__rte_unused struct cmdline *cl,
> @@ -461,6 +485,7 @@ static void
> cmd_add_port_meter_profile_trtcm_parsed(void *parsed_result,
>  	mp.trtcm_rfc2698.pir = res->pir;
>  	mp.trtcm_rfc2698.cbs = res->cbs;
>  	mp.trtcm_rfc2698.pbs = res->pbs;
> +	mp.packet_mode = res->packet_mode;
> 
>  	ret = rte_mtr_meter_profile_add(port_id, profile_id, &mp, &error);
>  	if (ret != 0) {
> @@ -472,7 +497,7 @@ static void
> cmd_add_port_meter_profile_trtcm_parsed(void *parsed_result,
>  cmdline_parse_inst_t cmd_add_port_meter_profile_trtcm = {
>  	.f = cmd_add_port_meter_profile_trtcm_parsed,
>  	.data = NULL,
> -	.help_str = "add port meter profile trtcm_rfc2698 <port_id>
> <profile_id> <cir> <pir> <cbs> <pbs>",
> +	.help_str = "add port meter profile trtcm_rfc2698 <port_id>
> <profile_id> <cir> <pir> <cbs> <pbs> <packet_mode>",
>  	.tokens = {
>  		(void *)&cmd_add_port_meter_profile_trtcm_add,
>  		(void *)&cmd_add_port_meter_profile_trtcm_port,
> @@ -485,6 +510,7 @@ cmdline_parse_inst_t
> cmd_add_port_meter_profile_trtcm = {
>  		(void *)&cmd_add_port_meter_profile_trtcm_pir,
>  		(void *)&cmd_add_port_meter_profile_trtcm_cbs,
>  		(void *)&cmd_add_port_meter_profile_trtcm_pbs,
> +		(void
> *)&cmd_add_port_meter_profile_trtcm_packet_mode,
>  		NULL,
>  	},
>  };
> @@ -502,6 +528,7 @@ struct
> cmd_add_port_meter_profile_trtcm_rfc4115_result {
>  	uint64_t eir;
>  	uint64_t cbs;
>  	uint64_t ebs;
> +	int packet_mode;
>  };
> 
>  cmdline_parse_token_string_t
> cmd_add_port_meter_profile_trtcm_rfc4115_add =
> @@ -549,6 +576,11 @@ cmdline_parse_token_num_t
> cmd_add_port_meter_profile_trtcm_rfc4115_ebs =
>  	TOKEN_NUM_INITIALIZER(
>  		struct cmd_add_port_meter_profile_trtcm_rfc4115_result,
>  			ebs, RTE_UINT64);
> +cmdline_parse_token_num_t
> +	cmd_add_port_meter_profile_trtcm_rfc4115_packet_mode =
> +	TOKEN_NUM_INITIALIZER(
> +		struct cmd_add_port_meter_profile_trtcm_rfc4115_result,
> +			packet_mode, RTE_UINT32);
> 
>  static void cmd_add_port_meter_profile_trtcm_rfc4115_parsed(
>  	void *parsed_result,
> @@ -573,6 +605,7 @@ static void
> cmd_add_port_meter_profile_trtcm_rfc4115_parsed(
>  	mp.trtcm_rfc4115.eir = res->eir;
>  	mp.trtcm_rfc4115.cbs = res->cbs;
>  	mp.trtcm_rfc4115.ebs = res->ebs;
> +	mp.packet_mode = res->packet_mode;
> 
>  	ret = rte_mtr_meter_profile_add(port_id, profile_id, &mp, &error);
>  	if (ret != 0) {
> @@ -584,7 +617,7 @@ static void
> cmd_add_port_meter_profile_trtcm_rfc4115_parsed(
>  cmdline_parse_inst_t cmd_add_port_meter_profile_trtcm_rfc4115 = {
>  	.f = cmd_add_port_meter_profile_trtcm_rfc4115_parsed,
>  	.data = NULL,
> -	.help_str = "add port meter profile trtcm_rfc4115 <port_id>
> <profile_id> <cir> <eir> <cbs> <ebs>",
> +	.help_str = "add port meter profile trtcm_rfc4115 <port_id>
> <profile_id> <cir> <eir> <cbs> <ebs> <packet_mode>",
>  	.tokens = {
>  		(void *)&cmd_add_port_meter_profile_trtcm_rfc4115_add,
>  		(void *)&cmd_add_port_meter_profile_trtcm_rfc4115_port,
> @@ -597,6 +630,7 @@ cmdline_parse_inst_t
> cmd_add_port_meter_profile_trtcm_rfc4115 = {
>  		(void *)&cmd_add_port_meter_profile_trtcm_rfc4115_eir,
>  		(void *)&cmd_add_port_meter_profile_trtcm_rfc4115_cbs,
>  		(void *)&cmd_add_port_meter_profile_trtcm_rfc4115_ebs,
> +		(void
> *)&cmd_add_port_meter_profile_trtcm_rfc4115_packet_mode,
>  		NULL,
>  	},
>  };
> diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst
> b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
> index f59eb8a27d..b5e52f6b1c 100644
> --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst
> +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
> @@ -2698,14 +2698,15 @@ add port meter profile (srTCM rfc2967)
>  Add meter profile (srTCM rfc2697) to the ethernet device::
> 
>     testpmd> add port meter profile srtcm_rfc2697 (port_id) (profile_id) \
> -   (cir) (cbs) (ebs)
> +   (cir) (cbs) (ebs) (packet_mode)
> 
>  where:
> 
>  * ``profile_id``: ID for the meter profile.
> -* ``cir``: Committed Information Rate (CIR) (bytes/second).
> -* ``cbs``: Committed Burst Size (CBS) (bytes).
> -* ``ebs``: Excess Burst Size (EBS) (bytes).
> +* ``cir``: Committed Information Rate (CIR) (bytes per second or packets per
> second).
> +* ``cbs``: Committed Burst Size (CBS) (bytes or packets).
> +* ``ebs``: Excess Burst Size (EBS) (bytes or packets).
> +* ``packet_mode``: Packets mode for meter profile.
> 
>  add port meter profile (trTCM rfc2968)
>  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> @@ -2713,15 +2714,16 @@ add port meter profile (trTCM rfc2968)
>  Add meter profile (srTCM rfc2698) to the ethernet device::
> 
>     testpmd> add port meter profile trtcm_rfc2698 (port_id) (profile_id) \
> -   (cir) (pir) (cbs) (pbs)
> +   (cir) (pir) (cbs) (pbs) (packet_mode)
> 
>  where:
> 
>  * ``profile_id``: ID for the meter profile.
> -* ``cir``: Committed information rate (bytes/second).
> -* ``pir``: Peak information rate (bytes/second).
> -* ``cbs``: Committed burst size (bytes).
> -* ``pbs``: Peak burst size (bytes).
> +* ``cir``: Committed information rate (bytes per second or packets per
> second).
> +* ``pir``: Peak information rate (bytes per second or packets per second).
> +* ``cbs``: Committed burst size (bytes or packets).
> +* ``pbs``: Peak burst size (bytes or packets).
> +* ``packet_mode``: Packets mode for meter profile.
> 
>  add port meter profile (trTCM rfc4115)
>  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> @@ -2729,15 +2731,16 @@ add port meter profile (trTCM rfc4115)
>  Add meter profile (trTCM rfc4115) to the ethernet device::
> 
>     testpmd> add port meter profile trtcm_rfc4115 (port_id) (profile_id) \
> -   (cir) (eir) (cbs) (ebs)
> +   (cir) (eir) (cbs) (ebs) (packet_mode)
> 
>  where:
> 
>  * ``profile_id``: ID for the meter profile.
> -* ``cir``: Committed information rate (bytes/second).
> -* ``eir``: Excess information rate (bytes/second).
> -* ``cbs``: Committed burst size (bytes).
> -* ``ebs``: Excess burst size (bytes).
> +* ``cir``: Committed information rate (bytes per second or packets per
> second).
> +* ``eir``: Excess information rate (bytes per second or packets per second).
> +* ``cbs``: Committed burst size (bytes or packets).
> +* ``ebs``: Excess burst size (bytes or packets).
> +* ``packet_mode``: Packets mode for meter profile.
> 
>  delete port meter profile
>  ~~~~~~~~~~~~~~~~~~~~~~~~~
> --
> 2.27.0

This patch should also be part of the unified V2, thanks!
Li Zhang April 8, 2021, 2:34 a.m. UTC | #3
Hi Cristian

> -----Original Message-----
> From: Dumitrescu, Cristian <cristian.dumitrescu@intel.com>
> Sent: Thursday, April 8, 2021 4:18 AM
> To: Li Zhang <lizh@nvidia.com>; dekelp@nvidia.com; Ori Kam
> <orika@nvidia.com>; Slava Ovsiienko <viacheslavo@nvidia.com>; Matan
> Azrad <matan@nvidia.com>; Shahaf Shuler <shahafs@nvidia.com>; Li,
> Xiaoyun <xiaoyun.li@intel.com>
> Cc: dev@dpdk.org; NBU-Contact-Thomas Monjalon <thomas@monjalon.net>;
> Raslan Darawsheh <rasland@nvidia.com>; Roni Bar Yanai
> <roniba@nvidia.com>
> Subject: RE: [PATCH 2/2] app/testpmd: add meter profile packet mode option
> 
> External email: Use caution opening links or attachments
> 
> 
> > -----Original Message-----
> > From: Li Zhang <lizh@nvidia.com>
> > Sent: Wednesday, March 31, 2021 9:54 AM
> > To: dekelp@nvidia.com; orika@nvidia.com; viacheslavo@nvidia.com;
> > matan@nvidia.com; shahafs@nvidia.com; Dumitrescu, Cristian
> > <cristian.dumitrescu@intel.com>; Li, Xiaoyun <xiaoyun.li@intel.com>
> > Cc: dev@dpdk.org; thomas@monjalon.net; rasland@nvidia.com;
> > roniba@nvidia.com
> > Subject: [PATCH 2/2] app/testpmd: add meter profile packet mode option
> >
> > add meter profile packet_mode to the ethernet device.
> > One example:
> > add port meter profile rfc2697 (port_id) (profile_id)
> > (cir) (cbs) (ebs) (packet_mode)
> >
> > Signed-off-by: Li Zhang <lizh@nvidia.com>
> > ---
> >  app/test-pmd/cmdline_mtr.c                  | 40 +++++++++++++++++++--
> >  doc/guides/testpmd_app_ug/testpmd_funcs.rst | 31 ++++++++--------
> >  2 files changed, 54 insertions(+), 17 deletions(-)
> >
> > diff --git a/app/test-pmd/cmdline_mtr.c b/app/test-pmd/cmdline_mtr.c
> > index bdc9ae8bfe..eff2473e7b 100644
> > --- a/app/test-pmd/cmdline_mtr.c
> > +++ b/app/test-pmd/cmdline_mtr.c
> > @@ -263,6 +263,18 @@ static void cmd_show_port_meter_cap_parsed(void
> > *parsed_result,
> >               cap.color_aware_trtcm_rfc2698_supported);
> >       printf("cap.color_aware_trtcm_rfc4115_supported %" PRId32 "\n",
> >               cap.color_aware_trtcm_rfc4115_supported);
> > +     printf("cap.srtcm_rfc2697_byte_mode_supported %" PRId32 "\n",
> > +             cap.srtcm_rfc2697_byte_mode_supported);
> > +     printf("cap.srtcm_rfc2697_packet_mode_supported %" PRId32 "\n",
> > +             cap.srtcm_rfc2697_packet_mode_supported);
> > +     printf("cap.trtcm_rfc2698_byte_mode_supported %" PRId32 "\n",
> > +             cap.trtcm_rfc2698_byte_mode_supported);
> > +     printf("cap.trtcm_rfc2698_packet_mode_supported %" PRId32 "\n",
> > +             cap.trtcm_rfc2698_packet_mode_supported);
> > +     printf("cap.trtcm_rfc4115_byte_mode_supported %" PRId32 "\n",
> > +             cap.trtcm_rfc4115_byte_mode_supported);
> > +     printf("cap.trtcm_rfc4115_packet_mode_supported %" PRId32 "\n",
> > +             cap.trtcm_rfc4115_packet_mode_supported);
> >       printf("cap.stats_mask %" PRIx64 "\n", cap.stats_mask);  }
> >
> > @@ -292,6 +304,7 @@ struct cmd_add_port_meter_profile_srtcm_result {
> >       uint64_t cir;
> >       uint64_t cbs;
> >       uint64_t ebs;
> > +     int packet_mode;
> >  };
> >
> >  cmdline_parse_token_string_t cmd_add_port_meter_profile_srtcm_add =
> > @@ -333,6 +346,10 @@ cmdline_parse_token_num_t
> > cmd_add_port_meter_profile_srtcm_ebs =
> >       TOKEN_NUM_INITIALIZER(
> >               struct cmd_add_port_meter_profile_srtcm_result,
> >                       ebs, RTE_UINT64);
> > +cmdline_parse_token_num_t
> > cmd_add_port_meter_profile_srtcm_packet_mode =
> > +     TOKEN_NUM_INITIALIZER(
> > +             struct cmd_add_port_meter_profile_srtcm_result,
> > +                     packet_mode, RTE_UINT32);
> >
> >  static void cmd_add_port_meter_profile_srtcm_parsed(void
> > *parsed_result,
> >       __rte_unused struct cmdline *cl, @@ -354,6 +371,7 @@ static void
> > cmd_add_port_meter_profile_srtcm_parsed(void *parsed_result,
> >       mp.srtcm_rfc2697.cir = res->cir;
> >       mp.srtcm_rfc2697.cbs = res->cbs;
> >       mp.srtcm_rfc2697.ebs = res->ebs;
> > +     mp.packet_mode = res->packet_mode;
> >
> >       ret = rte_mtr_meter_profile_add(port_id, profile_id, &mp, &error);
> >       if (ret != 0) {
> > @@ -365,7 +383,7 @@ static void
> > cmd_add_port_meter_profile_srtcm_parsed(void *parsed_result,
> > cmdline_parse_inst_t cmd_add_port_meter_profile_srtcm = {
> >       .f = cmd_add_port_meter_profile_srtcm_parsed,
> >       .data = NULL,
> > -     .help_str = "add port meter profile srtcm_rfc2697 <port_id>
> > <profile_id> <cir> <cbs> <ebs>",
> > +     .help_str = "add port meter profile srtcm_rfc2697 <port_id>
> > <profile_id> <cir> <cbs> <ebs> <packet_mode>",
> >       .tokens = {
> >               (void *)&cmd_add_port_meter_profile_srtcm_add,
> >               (void *)&cmd_add_port_meter_profile_srtcm_port,
> > @@ -377,6 +395,7 @@ cmdline_parse_inst_t
> > cmd_add_port_meter_profile_srtcm = {
> >               (void *)&cmd_add_port_meter_profile_srtcm_cir,
> >               (void *)&cmd_add_port_meter_profile_srtcm_cbs,
> >               (void *)&cmd_add_port_meter_profile_srtcm_ebs,
> > +             (void
> > *)&cmd_add_port_meter_profile_srtcm_packet_mode,
> >               NULL,
> >       },
> >  };
> > @@ -394,6 +413,7 @@ struct cmd_add_port_meter_profile_trtcm_result {
> >       uint64_t pir;
> >       uint64_t cbs;
> >       uint64_t pbs;
> > +     int packet_mode;
> >  };
> >
> >  cmdline_parse_token_string_t cmd_add_port_meter_profile_trtcm_add =
> > @@ -439,6 +459,10 @@ cmdline_parse_token_num_t
> > cmd_add_port_meter_profile_trtcm_pbs =
> >       TOKEN_NUM_INITIALIZER(
> >               struct cmd_add_port_meter_profile_trtcm_result,
> >                       pbs, RTE_UINT64);
> > +cmdline_parse_token_num_t
> > cmd_add_port_meter_profile_trtcm_packet_mode =
> > +     TOKEN_NUM_INITIALIZER(
> > +             struct cmd_add_port_meter_profile_trtcm_result,
> > +                     packet_mode, RTE_UINT32);
> >
> >  static void cmd_add_port_meter_profile_trtcm_parsed(void
> > *parsed_result,
> >       __rte_unused struct cmdline *cl, @@ -461,6 +485,7 @@ static void
> > cmd_add_port_meter_profile_trtcm_parsed(void *parsed_result,
> >       mp.trtcm_rfc2698.pir = res->pir;
> >       mp.trtcm_rfc2698.cbs = res->cbs;
> >       mp.trtcm_rfc2698.pbs = res->pbs;
> > +     mp.packet_mode = res->packet_mode;
> >
> >       ret = rte_mtr_meter_profile_add(port_id, profile_id, &mp, &error);
> >       if (ret != 0) {
> > @@ -472,7 +497,7 @@ static void
> > cmd_add_port_meter_profile_trtcm_parsed(void *parsed_result,
> > cmdline_parse_inst_t cmd_add_port_meter_profile_trtcm = {
> >       .f = cmd_add_port_meter_profile_trtcm_parsed,
> >       .data = NULL,
> > -     .help_str = "add port meter profile trtcm_rfc2698 <port_id>
> > <profile_id> <cir> <pir> <cbs> <pbs>",
> > +     .help_str = "add port meter profile trtcm_rfc2698 <port_id>
> > <profile_id> <cir> <pir> <cbs> <pbs> <packet_mode>",
> >       .tokens = {
> >               (void *)&cmd_add_port_meter_profile_trtcm_add,
> >               (void *)&cmd_add_port_meter_profile_trtcm_port,
> > @@ -485,6 +510,7 @@ cmdline_parse_inst_t
> > cmd_add_port_meter_profile_trtcm = {
> >               (void *)&cmd_add_port_meter_profile_trtcm_pir,
> >               (void *)&cmd_add_port_meter_profile_trtcm_cbs,
> >               (void *)&cmd_add_port_meter_profile_trtcm_pbs,
> > +             (void
> > *)&cmd_add_port_meter_profile_trtcm_packet_mode,
> >               NULL,
> >       },
> >  };
> > @@ -502,6 +528,7 @@ struct
> > cmd_add_port_meter_profile_trtcm_rfc4115_result {
> >       uint64_t eir;
> >       uint64_t cbs;
> >       uint64_t ebs;
> > +     int packet_mode;
> >  };
> >
> >  cmdline_parse_token_string_t
> > cmd_add_port_meter_profile_trtcm_rfc4115_add = @@ -549,6 +576,11 @@
> > cmdline_parse_token_num_t
> cmd_add_port_meter_profile_trtcm_rfc4115_ebs
> > =
> >       TOKEN_NUM_INITIALIZER(
> >               struct cmd_add_port_meter_profile_trtcm_rfc4115_result,
> >                       ebs, RTE_UINT64);
> > +cmdline_parse_token_num_t
> > +     cmd_add_port_meter_profile_trtcm_rfc4115_packet_mode =
> > +     TOKEN_NUM_INITIALIZER(
> > +             struct cmd_add_port_meter_profile_trtcm_rfc4115_result,
> > +                     packet_mode, RTE_UINT32);
> >
> >  static void cmd_add_port_meter_profile_trtcm_rfc4115_parsed(
> >       void *parsed_result,
> > @@ -573,6 +605,7 @@ static void
> > cmd_add_port_meter_profile_trtcm_rfc4115_parsed(
> >       mp.trtcm_rfc4115.eir = res->eir;
> >       mp.trtcm_rfc4115.cbs = res->cbs;
> >       mp.trtcm_rfc4115.ebs = res->ebs;
> > +     mp.packet_mode = res->packet_mode;
> >
> >       ret = rte_mtr_meter_profile_add(port_id, profile_id, &mp, &error);
> >       if (ret != 0) {
> > @@ -584,7 +617,7 @@ static void
> > cmd_add_port_meter_profile_trtcm_rfc4115_parsed(
> >  cmdline_parse_inst_t cmd_add_port_meter_profile_trtcm_rfc4115 = {
> >       .f = cmd_add_port_meter_profile_trtcm_rfc4115_parsed,
> >       .data = NULL,
> > -     .help_str = "add port meter profile trtcm_rfc4115 <port_id>
> > <profile_id> <cir> <eir> <cbs> <ebs>",
> > +     .help_str = "add port meter profile trtcm_rfc4115 <port_id>
> > <profile_id> <cir> <eir> <cbs> <ebs> <packet_mode>",
> >       .tokens = {
> >               (void *)&cmd_add_port_meter_profile_trtcm_rfc4115_add,
> >               (void *)&cmd_add_port_meter_profile_trtcm_rfc4115_port,
> > @@ -597,6 +630,7 @@ cmdline_parse_inst_t
> > cmd_add_port_meter_profile_trtcm_rfc4115 = {
> >               (void *)&cmd_add_port_meter_profile_trtcm_rfc4115_eir,
> >               (void *)&cmd_add_port_meter_profile_trtcm_rfc4115_cbs,
> >               (void *)&cmd_add_port_meter_profile_trtcm_rfc4115_ebs,
> > +             (void
> > *)&cmd_add_port_meter_profile_trtcm_rfc4115_packet_mode,
> >               NULL,
> >       },
> >  };
> > diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst
> > b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
> > index f59eb8a27d..b5e52f6b1c 100644
> > --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst
> > +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
> > @@ -2698,14 +2698,15 @@ add port meter profile (srTCM rfc2967)  Add
> > meter profile (srTCM rfc2697) to the ethernet device::
> >
> >     testpmd> add port meter profile srtcm_rfc2697 (port_id) (profile_id) \
> > -   (cir) (cbs) (ebs)
> > +   (cir) (cbs) (ebs) (packet_mode)
> >
> >  where:
> >
> >  * ``profile_id``: ID for the meter profile.
> > -* ``cir``: Committed Information Rate (CIR) (bytes/second).
> > -* ``cbs``: Committed Burst Size (CBS) (bytes).
> > -* ``ebs``: Excess Burst Size (EBS) (bytes).
> > +* ``cir``: Committed Information Rate (CIR) (bytes per second or
> > +packets per
> > second).
> > +* ``cbs``: Committed Burst Size (CBS) (bytes or packets).
> > +* ``ebs``: Excess Burst Size (EBS) (bytes or packets).
> > +* ``packet_mode``: Packets mode for meter profile.
> >
> >  add port meter profile (trTCM rfc2968)
> > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> > @@ -2713,15 +2714,16 @@ add port meter profile (trTCM rfc2968)  Add
> > meter profile (srTCM rfc2698) to the ethernet device::
> >
> >     testpmd> add port meter profile trtcm_rfc2698 (port_id) (profile_id) \
> > -   (cir) (pir) (cbs) (pbs)
> > +   (cir) (pir) (cbs) (pbs) (packet_mode)
> >
> >  where:
> >
> >  * ``profile_id``: ID for the meter profile.
> > -* ``cir``: Committed information rate (bytes/second).
> > -* ``pir``: Peak information rate (bytes/second).
> > -* ``cbs``: Committed burst size (bytes).
> > -* ``pbs``: Peak burst size (bytes).
> > +* ``cir``: Committed information rate (bytes per second or packets
> > +per
> > second).
> > +* ``pir``: Peak information rate (bytes per second or packets per second).
> > +* ``cbs``: Committed burst size (bytes or packets).
> > +* ``pbs``: Peak burst size (bytes or packets).
> > +* ``packet_mode``: Packets mode for meter profile.
> >
> >  add port meter profile (trTCM rfc4115)
> > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> > @@ -2729,15 +2731,16 @@ add port meter profile (trTCM rfc4115)  Add
> > meter profile (trTCM rfc4115) to the ethernet device::
> >
> >     testpmd> add port meter profile trtcm_rfc4115 (port_id) (profile_id) \
> > -   (cir) (eir) (cbs) (ebs)
> > +   (cir) (eir) (cbs) (ebs) (packet_mode)
> >
> >  where:
> >
> >  * ``profile_id``: ID for the meter profile.
> > -* ``cir``: Committed information rate (bytes/second).
> > -* ``eir``: Excess information rate (bytes/second).
> > -* ``cbs``: Committed burst size (bytes).
> > -* ``ebs``: Excess burst size (bytes).
> > +* ``cir``: Committed information rate (bytes per second or packets
> > +per
> > second).
> > +* ``eir``: Excess information rate (bytes per second or packets per second).
> > +* ``cbs``: Committed burst size (bytes or packets).
> > +* ``ebs``: Excess burst size (bytes or packets).
> > +* ``packet_mode``: Packets mode for meter profile.
> >
> >  delete port meter profile
> >  ~~~~~~~~~~~~~~~~~~~~~~~~~
> > --
> > 2.27.0
> 
> There is already a patch from this series numbered PATCH 2/2. Does this
> belong to the same series?
> 
> It is not easy to review this set of patches related to the packet mode addition
> to the API, as it is split across multiple patch series and the numbering is
> confusing. I am not sure I am replying to the latest version or a superseded one.
> 
> Could you please create a unified V2 that contains both the series with the API
> changes and the series with the necessary error checks in the drivers?

Sure, will send V2 patch include the API and necessary error checks.

Regards,
Li Zhang
diff mbox series

Patch

diff --git a/app/test-pmd/cmdline_mtr.c b/app/test-pmd/cmdline_mtr.c
index bdc9ae8bfe..eff2473e7b 100644
--- a/app/test-pmd/cmdline_mtr.c
+++ b/app/test-pmd/cmdline_mtr.c
@@ -263,6 +263,18 @@  static void cmd_show_port_meter_cap_parsed(void *parsed_result,
 		cap.color_aware_trtcm_rfc2698_supported);
 	printf("cap.color_aware_trtcm_rfc4115_supported %" PRId32 "\n",
 		cap.color_aware_trtcm_rfc4115_supported);
+	printf("cap.srtcm_rfc2697_byte_mode_supported %" PRId32 "\n",
+		cap.srtcm_rfc2697_byte_mode_supported);
+	printf("cap.srtcm_rfc2697_packet_mode_supported %" PRId32 "\n",
+		cap.srtcm_rfc2697_packet_mode_supported);
+	printf("cap.trtcm_rfc2698_byte_mode_supported %" PRId32 "\n",
+		cap.trtcm_rfc2698_byte_mode_supported);
+	printf("cap.trtcm_rfc2698_packet_mode_supported %" PRId32 "\n",
+		cap.trtcm_rfc2698_packet_mode_supported);
+	printf("cap.trtcm_rfc4115_byte_mode_supported %" PRId32 "\n",
+		cap.trtcm_rfc4115_byte_mode_supported);
+	printf("cap.trtcm_rfc4115_packet_mode_supported %" PRId32 "\n",
+		cap.trtcm_rfc4115_packet_mode_supported);
 	printf("cap.stats_mask %" PRIx64 "\n", cap.stats_mask);
 }
 
@@ -292,6 +304,7 @@  struct cmd_add_port_meter_profile_srtcm_result {
 	uint64_t cir;
 	uint64_t cbs;
 	uint64_t ebs;
+	int packet_mode;
 };
 
 cmdline_parse_token_string_t cmd_add_port_meter_profile_srtcm_add =
@@ -333,6 +346,10 @@  cmdline_parse_token_num_t cmd_add_port_meter_profile_srtcm_ebs =
 	TOKEN_NUM_INITIALIZER(
 		struct cmd_add_port_meter_profile_srtcm_result,
 			ebs, RTE_UINT64);
+cmdline_parse_token_num_t cmd_add_port_meter_profile_srtcm_packet_mode =
+	TOKEN_NUM_INITIALIZER(
+		struct cmd_add_port_meter_profile_srtcm_result,
+			packet_mode, RTE_UINT32);
 
 static void cmd_add_port_meter_profile_srtcm_parsed(void *parsed_result,
 	__rte_unused struct cmdline *cl,
@@ -354,6 +371,7 @@  static void cmd_add_port_meter_profile_srtcm_parsed(void *parsed_result,
 	mp.srtcm_rfc2697.cir = res->cir;
 	mp.srtcm_rfc2697.cbs = res->cbs;
 	mp.srtcm_rfc2697.ebs = res->ebs;
+	mp.packet_mode = res->packet_mode;
 
 	ret = rte_mtr_meter_profile_add(port_id, profile_id, &mp, &error);
 	if (ret != 0) {
@@ -365,7 +383,7 @@  static void cmd_add_port_meter_profile_srtcm_parsed(void *parsed_result,
 cmdline_parse_inst_t cmd_add_port_meter_profile_srtcm = {
 	.f = cmd_add_port_meter_profile_srtcm_parsed,
 	.data = NULL,
-	.help_str = "add port meter profile srtcm_rfc2697 <port_id> <profile_id> <cir> <cbs> <ebs>",
+	.help_str = "add port meter profile srtcm_rfc2697 <port_id> <profile_id> <cir> <cbs> <ebs> <packet_mode>",
 	.tokens = {
 		(void *)&cmd_add_port_meter_profile_srtcm_add,
 		(void *)&cmd_add_port_meter_profile_srtcm_port,
@@ -377,6 +395,7 @@  cmdline_parse_inst_t cmd_add_port_meter_profile_srtcm = {
 		(void *)&cmd_add_port_meter_profile_srtcm_cir,
 		(void *)&cmd_add_port_meter_profile_srtcm_cbs,
 		(void *)&cmd_add_port_meter_profile_srtcm_ebs,
+		(void *)&cmd_add_port_meter_profile_srtcm_packet_mode,
 		NULL,
 	},
 };
@@ -394,6 +413,7 @@  struct cmd_add_port_meter_profile_trtcm_result {
 	uint64_t pir;
 	uint64_t cbs;
 	uint64_t pbs;
+	int packet_mode;
 };
 
 cmdline_parse_token_string_t cmd_add_port_meter_profile_trtcm_add =
@@ -439,6 +459,10 @@  cmdline_parse_token_num_t cmd_add_port_meter_profile_trtcm_pbs =
 	TOKEN_NUM_INITIALIZER(
 		struct cmd_add_port_meter_profile_trtcm_result,
 			pbs, RTE_UINT64);
+cmdline_parse_token_num_t cmd_add_port_meter_profile_trtcm_packet_mode =
+	TOKEN_NUM_INITIALIZER(
+		struct cmd_add_port_meter_profile_trtcm_result,
+			packet_mode, RTE_UINT32);
 
 static void cmd_add_port_meter_profile_trtcm_parsed(void *parsed_result,
 	__rte_unused struct cmdline *cl,
@@ -461,6 +485,7 @@  static void cmd_add_port_meter_profile_trtcm_parsed(void *parsed_result,
 	mp.trtcm_rfc2698.pir = res->pir;
 	mp.trtcm_rfc2698.cbs = res->cbs;
 	mp.trtcm_rfc2698.pbs = res->pbs;
+	mp.packet_mode = res->packet_mode;
 
 	ret = rte_mtr_meter_profile_add(port_id, profile_id, &mp, &error);
 	if (ret != 0) {
@@ -472,7 +497,7 @@  static void cmd_add_port_meter_profile_trtcm_parsed(void *parsed_result,
 cmdline_parse_inst_t cmd_add_port_meter_profile_trtcm = {
 	.f = cmd_add_port_meter_profile_trtcm_parsed,
 	.data = NULL,
-	.help_str = "add port meter profile trtcm_rfc2698 <port_id> <profile_id> <cir> <pir> <cbs> <pbs>",
+	.help_str = "add port meter profile trtcm_rfc2698 <port_id> <profile_id> <cir> <pir> <cbs> <pbs> <packet_mode>",
 	.tokens = {
 		(void *)&cmd_add_port_meter_profile_trtcm_add,
 		(void *)&cmd_add_port_meter_profile_trtcm_port,
@@ -485,6 +510,7 @@  cmdline_parse_inst_t cmd_add_port_meter_profile_trtcm = {
 		(void *)&cmd_add_port_meter_profile_trtcm_pir,
 		(void *)&cmd_add_port_meter_profile_trtcm_cbs,
 		(void *)&cmd_add_port_meter_profile_trtcm_pbs,
+		(void *)&cmd_add_port_meter_profile_trtcm_packet_mode,
 		NULL,
 	},
 };
@@ -502,6 +528,7 @@  struct cmd_add_port_meter_profile_trtcm_rfc4115_result {
 	uint64_t eir;
 	uint64_t cbs;
 	uint64_t ebs;
+	int packet_mode;
 };
 
 cmdline_parse_token_string_t cmd_add_port_meter_profile_trtcm_rfc4115_add =
@@ -549,6 +576,11 @@  cmdline_parse_token_num_t cmd_add_port_meter_profile_trtcm_rfc4115_ebs =
 	TOKEN_NUM_INITIALIZER(
 		struct cmd_add_port_meter_profile_trtcm_rfc4115_result,
 			ebs, RTE_UINT64);
+cmdline_parse_token_num_t
+	cmd_add_port_meter_profile_trtcm_rfc4115_packet_mode =
+	TOKEN_NUM_INITIALIZER(
+		struct cmd_add_port_meter_profile_trtcm_rfc4115_result,
+			packet_mode, RTE_UINT32);
 
 static void cmd_add_port_meter_profile_trtcm_rfc4115_parsed(
 	void *parsed_result,
@@ -573,6 +605,7 @@  static void cmd_add_port_meter_profile_trtcm_rfc4115_parsed(
 	mp.trtcm_rfc4115.eir = res->eir;
 	mp.trtcm_rfc4115.cbs = res->cbs;
 	mp.trtcm_rfc4115.ebs = res->ebs;
+	mp.packet_mode = res->packet_mode;
 
 	ret = rte_mtr_meter_profile_add(port_id, profile_id, &mp, &error);
 	if (ret != 0) {
@@ -584,7 +617,7 @@  static void cmd_add_port_meter_profile_trtcm_rfc4115_parsed(
 cmdline_parse_inst_t cmd_add_port_meter_profile_trtcm_rfc4115 = {
 	.f = cmd_add_port_meter_profile_trtcm_rfc4115_parsed,
 	.data = NULL,
-	.help_str = "add port meter profile trtcm_rfc4115 <port_id> <profile_id> <cir> <eir> <cbs> <ebs>",
+	.help_str = "add port meter profile trtcm_rfc4115 <port_id> <profile_id> <cir> <eir> <cbs> <ebs> <packet_mode>",
 	.tokens = {
 		(void *)&cmd_add_port_meter_profile_trtcm_rfc4115_add,
 		(void *)&cmd_add_port_meter_profile_trtcm_rfc4115_port,
@@ -597,6 +630,7 @@  cmdline_parse_inst_t cmd_add_port_meter_profile_trtcm_rfc4115 = {
 		(void *)&cmd_add_port_meter_profile_trtcm_rfc4115_eir,
 		(void *)&cmd_add_port_meter_profile_trtcm_rfc4115_cbs,
 		(void *)&cmd_add_port_meter_profile_trtcm_rfc4115_ebs,
+		(void *)&cmd_add_port_meter_profile_trtcm_rfc4115_packet_mode,
 		NULL,
 	},
 };
diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
index f59eb8a27d..b5e52f6b1c 100644
--- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst
+++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
@@ -2698,14 +2698,15 @@  add port meter profile (srTCM rfc2967)
 Add meter profile (srTCM rfc2697) to the ethernet device::
 
    testpmd> add port meter profile srtcm_rfc2697 (port_id) (profile_id) \
-   (cir) (cbs) (ebs)
+   (cir) (cbs) (ebs) (packet_mode)
 
 where:
 
 * ``profile_id``: ID for the meter profile.
-* ``cir``: Committed Information Rate (CIR) (bytes/second).
-* ``cbs``: Committed Burst Size (CBS) (bytes).
-* ``ebs``: Excess Burst Size (EBS) (bytes).
+* ``cir``: Committed Information Rate (CIR) (bytes per second or packets per second).
+* ``cbs``: Committed Burst Size (CBS) (bytes or packets).
+* ``ebs``: Excess Burst Size (EBS) (bytes or packets).
+* ``packet_mode``: Packets mode for meter profile.
 
 add port meter profile (trTCM rfc2968)
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -2713,15 +2714,16 @@  add port meter profile (trTCM rfc2968)
 Add meter profile (srTCM rfc2698) to the ethernet device::
 
    testpmd> add port meter profile trtcm_rfc2698 (port_id) (profile_id) \
-   (cir) (pir) (cbs) (pbs)
+   (cir) (pir) (cbs) (pbs) (packet_mode)
 
 where:
 
 * ``profile_id``: ID for the meter profile.
-* ``cir``: Committed information rate (bytes/second).
-* ``pir``: Peak information rate (bytes/second).
-* ``cbs``: Committed burst size (bytes).
-* ``pbs``: Peak burst size (bytes).
+* ``cir``: Committed information rate (bytes per second or packets per second).
+* ``pir``: Peak information rate (bytes per second or packets per second).
+* ``cbs``: Committed burst size (bytes or packets).
+* ``pbs``: Peak burst size (bytes or packets).
+* ``packet_mode``: Packets mode for meter profile.
 
 add port meter profile (trTCM rfc4115)
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -2729,15 +2731,16 @@  add port meter profile (trTCM rfc4115)
 Add meter profile (trTCM rfc4115) to the ethernet device::
 
    testpmd> add port meter profile trtcm_rfc4115 (port_id) (profile_id) \
-   (cir) (eir) (cbs) (ebs)
+   (cir) (eir) (cbs) (ebs) (packet_mode)
 
 where:
 
 * ``profile_id``: ID for the meter profile.
-* ``cir``: Committed information rate (bytes/second).
-* ``eir``: Excess information rate (bytes/second).
-* ``cbs``: Committed burst size (bytes).
-* ``ebs``: Excess burst size (bytes).
+* ``cir``: Committed information rate (bytes per second or packets per second).
+* ``eir``: Excess information rate (bytes per second or packets per second).
+* ``cbs``: Committed burst size (bytes or packets).
+* ``ebs``: Excess burst size (bytes or packets).
+* ``packet_mode``: Packets mode for meter profile.
 
 delete port meter profile
 ~~~~~~~~~~~~~~~~~~~~~~~~~