[dpdk-dev] app/testpmd: allow setting shaper profile id to none

Message ID 1517297828-3111-1-git-send-email-tdu@semihalf.com (mailing list archive)
State Accepted, archived
Delegated to: Thomas Monjalon
Headers

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Tomasz Duszynski Jan. 30, 2018, 7:37 a.m. UTC
  Private shaper profiles are attached to nodes defined
in traffic manager hierarchy.

Since not every node must have a configured shaper
testpmd should allow setting shaper profile id to
invalid (RTE_TM_SHAPER_PROFILE_ID_NONE) easily.

This patch follows same approach as in case of setting
parent id of the root node i.e passing a negative value
sets node id to RTE_TM_NODE_ID_NULL.

In case of private shaper profile negative value will set
shaper profile id to RTE_TM_SHAPER_PROFILE_ID_NONE.

Signed-off-by: Tomasz Duszynski <tdu@semihalf.com>
---
 app/test-pmd/cmdline_tm.c | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)
  

Comments

Tomasz Duszynski Feb. 16, 2018, 8:13 a.m. UTC | #1
On Tue, Jan 30, 2018 at 08:37:08AM +0100, Tomasz Duszynski wrote:
> Private shaper profiles are attached to nodes defined
> in traffic manager hierarchy.
>
> Since not every node must have a configured shaper
> testpmd should allow setting shaper profile id to
> invalid (RTE_TM_SHAPER_PROFILE_ID_NONE) easily.
>
> This patch follows same approach as in case of setting
> parent id of the root node i.e passing a negative value
> sets node id to RTE_TM_NODE_ID_NULL.
>
> In case of private shaper profile negative value will set
> shaper profile id to RTE_TM_SHAPER_PROFILE_ID_NONE.
>
> Signed-off-by: Tomasz Duszynski <tdu@semihalf.com>
> ---
>  app/test-pmd/cmdline_tm.c | 20 ++++++++++++++------
>  1 file changed, 14 insertions(+), 6 deletions(-)
>
> diff --git a/app/test-pmd/cmdline_tm.c b/app/test-pmd/cmdline_tm.c
> index 35cad54..9859c3d 100644
> --- a/app/test-pmd/cmdline_tm.c
> +++ b/app/test-pmd/cmdline_tm.c
> @@ -1500,7 +1500,7 @@ struct cmd_add_port_tm_nonleaf_node_result {
>  	uint32_t priority;
>  	uint32_t weight;
>  	uint32_t level_id;
> -	uint32_t shaper_profile_id;
> +	int32_t shaper_profile_id;
>  	uint32_t n_sp_priorities;
>  	uint64_t stats_mask;
>  	cmdline_multi_string_t multi_shared_shaper_id;
> @@ -1542,7 +1542,7 @@ cmdline_parse_token_num_t cmd_add_port_tm_nonleaf_node_level_id =
>  		 level_id, UINT32);
>  cmdline_parse_token_num_t cmd_add_port_tm_nonleaf_node_shaper_profile_id =
>  	TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_nonleaf_node_result,
> -		 shaper_profile_id, UINT32);
> +		 shaper_profile_id, INT32);
>  cmdline_parse_token_num_t cmd_add_port_tm_nonleaf_node_n_sp_priorities =
>  	TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_nonleaf_node_result,
>  		 n_sp_priorities, UINT32);
> @@ -1593,7 +1593,11 @@ static void cmd_add_port_tm_nonleaf_node_parsed(void *parsed_result,
>  		return;
>  	}
>
> -	np.shaper_profile_id = res->shaper_profile_id;
> +	if (res->shaper_profile_id < 0)
> +		np.shaper_profile_id = UINT32_MAX;
> +	else
> +		np.shaper_profile_id = res->shaper_profile_id;
> +
>  	np.n_shared_shapers = n_shared_shapers;
>  	if (np.n_shared_shapers)
>  		np.shared_shaper_id = &shared_shaper_id[0];
> @@ -1651,7 +1655,7 @@ struct cmd_add_port_tm_leaf_node_result {
>  	uint32_t priority;
>  	uint32_t weight;
>  	uint32_t level_id;
> -	uint32_t shaper_profile_id;
> +	int32_t shaper_profile_id;
>  	uint32_t cman_mode;
>  	uint32_t wred_profile_id;
>  	uint64_t stats_mask;
> @@ -1693,7 +1697,7 @@ cmdline_parse_token_num_t cmd_add_port_tm_leaf_node_level_id =
>  		 level_id, UINT32);
>  cmdline_parse_token_num_t cmd_add_port_tm_leaf_node_shaper_profile_id =
>  	TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_leaf_node_result,
> -		 shaper_profile_id, UINT32);
> +		 shaper_profile_id, INT32);
>  cmdline_parse_token_num_t cmd_add_port_tm_leaf_node_cman_mode =
>  	TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_leaf_node_result,
>  		 cman_mode, UINT32);
> @@ -1747,7 +1751,11 @@ static void cmd_add_port_tm_leaf_node_parsed(void *parsed_result,
>  		return;
>  	}
>
> -	np.shaper_profile_id = res->shaper_profile_id;
> +	if (res->shaper_profile_id < 0)
> +		np.shaper_profile_id = UINT32_MAX;
> +	else
> +		np.shaper_profile_id = res->shaper_profile_id;
> +
>  	np.n_shared_shapers = n_shared_shapers;
>
>  	if (np.n_shared_shapers)
> --
> 2.7.4
>

This has been here for a while already. Any comments?

--
- Tomasz Duszyński
  
Jasvinder Singh Feb. 16, 2018, 9:38 a.m. UTC | #2
<snip>

> -----Original Message-----

> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Tomasz Duszynski

> Sent: Friday, February 16, 2018 8:14 AM

> To: dev@dpdk.org

> Cc: Lu, Wenzhuo <wenzhuo.lu@intel.com>; Wu, Jingjing

> <jingjing.wu@intel.com>; Tomasz Duszynski <tdu@semihalf.com>

> Subject: Re: [dpdk-dev] [PATCH] app/testpmd: allow setting shaper profile id

> to none

> 

> On Tue, Jan 30, 2018 at 08:37:08AM +0100, Tomasz Duszynski wrote:

> > Private shaper profiles are attached to nodes defined in traffic

> > manager hierarchy.

> >

> > Since not every node must have a configured shaper testpmd should

> > allow setting shaper profile id to invalid

> > (RTE_TM_SHAPER_PROFILE_ID_NONE) easily.

> >

> > This patch follows same approach as in case of setting parent id of

> > the root node i.e passing a negative value sets node id to

> > RTE_TM_NODE_ID_NULL.

> >

> > In case of private shaper profile negative value will set shaper

> > profile id to RTE_TM_SHAPER_PROFILE_ID_NONE.

> >

> > Signed-off-by: Tomasz Duszynski <tdu@semihalf.com>

> > ---


Reviewed-by: Jasvinder Singh <jasvinder.singh@intel.com>
  
Thomas Monjalon April 23, 2018, 7:47 p.m. UTC | #3
16/02/2018 10:38, Singh, Jasvinder:
> > On Tue, Jan 30, 2018 at 08:37:08AM +0100, Tomasz Duszynski wrote:
> > > Private shaper profiles are attached to nodes defined in traffic
> > > manager hierarchy.
> > >
> > > Since not every node must have a configured shaper testpmd should
> > > allow setting shaper profile id to invalid
> > > (RTE_TM_SHAPER_PROFILE_ID_NONE) easily.
> > >
> > > This patch follows same approach as in case of setting parent id of
> > > the root node i.e passing a negative value sets node id to
> > > RTE_TM_NODE_ID_NULL.
> > >
> > > In case of private shaper profile negative value will set shaper
> > > profile id to RTE_TM_SHAPER_PROFILE_ID_NONE.
> > >
> > > Signed-off-by: Tomasz Duszynski <tdu@semihalf.com>
> 
> Reviewed-by: Jasvinder Singh <jasvinder.singh@intel.com>

Applied, thanks
  

Patch

diff --git a/app/test-pmd/cmdline_tm.c b/app/test-pmd/cmdline_tm.c
index 35cad54..9859c3d 100644
--- a/app/test-pmd/cmdline_tm.c
+++ b/app/test-pmd/cmdline_tm.c
@@ -1500,7 +1500,7 @@  struct cmd_add_port_tm_nonleaf_node_result {
 	uint32_t priority;
 	uint32_t weight;
 	uint32_t level_id;
-	uint32_t shaper_profile_id;
+	int32_t shaper_profile_id;
 	uint32_t n_sp_priorities;
 	uint64_t stats_mask;
 	cmdline_multi_string_t multi_shared_shaper_id;
@@ -1542,7 +1542,7 @@  cmdline_parse_token_num_t cmd_add_port_tm_nonleaf_node_level_id =
 		 level_id, UINT32);
 cmdline_parse_token_num_t cmd_add_port_tm_nonleaf_node_shaper_profile_id =
 	TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_nonleaf_node_result,
-		 shaper_profile_id, UINT32);
+		 shaper_profile_id, INT32);
 cmdline_parse_token_num_t cmd_add_port_tm_nonleaf_node_n_sp_priorities =
 	TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_nonleaf_node_result,
 		 n_sp_priorities, UINT32);
@@ -1593,7 +1593,11 @@  static void cmd_add_port_tm_nonleaf_node_parsed(void *parsed_result,
 		return;
 	}
 
-	np.shaper_profile_id = res->shaper_profile_id;
+	if (res->shaper_profile_id < 0)
+		np.shaper_profile_id = UINT32_MAX;
+	else
+		np.shaper_profile_id = res->shaper_profile_id;
+
 	np.n_shared_shapers = n_shared_shapers;
 	if (np.n_shared_shapers)
 		np.shared_shaper_id = &shared_shaper_id[0];
@@ -1651,7 +1655,7 @@  struct cmd_add_port_tm_leaf_node_result {
 	uint32_t priority;
 	uint32_t weight;
 	uint32_t level_id;
-	uint32_t shaper_profile_id;
+	int32_t shaper_profile_id;
 	uint32_t cman_mode;
 	uint32_t wred_profile_id;
 	uint64_t stats_mask;
@@ -1693,7 +1697,7 @@  cmdline_parse_token_num_t cmd_add_port_tm_leaf_node_level_id =
 		 level_id, UINT32);
 cmdline_parse_token_num_t cmd_add_port_tm_leaf_node_shaper_profile_id =
 	TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_leaf_node_result,
-		 shaper_profile_id, UINT32);
+		 shaper_profile_id, INT32);
 cmdline_parse_token_num_t cmd_add_port_tm_leaf_node_cman_mode =
 	TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_leaf_node_result,
 		 cman_mode, UINT32);
@@ -1747,7 +1751,11 @@  static void cmd_add_port_tm_leaf_node_parsed(void *parsed_result,
 		return;
 	}
 
-	np.shaper_profile_id = res->shaper_profile_id;
+	if (res->shaper_profile_id < 0)
+		np.shaper_profile_id = UINT32_MAX;
+	else
+		np.shaper_profile_id = res->shaper_profile_id;
+
 	np.n_shared_shapers = n_shared_shapers;
 
 	if (np.n_shared_shapers)