[v4,6/9] example/ip_pipeline: add dynamic config of subport
diff mbox series

Message ID 1600332159-26018-7-git-send-email-savinay.dharmappa@intel.com
State Superseded
Delegated to: Thomas Monjalon
Headers show
Series
  • Enable dynamic config of subport bandwidth
Related show

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Savinay Dharmappa Sept. 17, 2020, 8:42 a.m. UTC
Modify the ip_pipeline application to build the hierarchical scheduler
with default subport bandwidth profile. It also allows to configure
a subport with different subport bandwidth profile dynamically

Signed-off-by: Savinay Dharmappa <savinay.dharmappa@intel.com>
---
 examples/ip_pipeline/cli.c  | 14 ++++++++------
 examples/ip_pipeline/tmgr.c | 26 ++++++++++++++++++++++++--
 examples/ip_pipeline/tmgr.h |  3 ++-
 3 files changed, 34 insertions(+), 9 deletions(-)

Comments

Dumitrescu, Cristian Sept. 29, 2020, 9:23 p.m. UTC | #1
> -----Original Message-----
> From: Dharmappa, Savinay <savinay.dharmappa@intel.com>
> Sent: Thursday, September 17, 2020 9:43 AM
> To: Singh, Jasvinder <jasvinder.singh@intel.com>; Dumitrescu, Cristian
> <cristian.dumitrescu@intel.com>; dev@dpdk.org
> Cc: Dharmappa, Savinay <savinay.dharmappa@intel.com>
> Subject: [PATCH v4 6/9] example/ip_pipeline: add dynamic config of subport
> 
> Modify the ip_pipeline application to build the hierarchical scheduler
> with default subport bandwidth profile. It also allows to configure
> a subport with different subport bandwidth profile dynamically
> 
> Signed-off-by: Savinay Dharmappa <savinay.dharmappa@intel.com>
> ---
>  examples/ip_pipeline/cli.c  | 14 ++++++++------
>  examples/ip_pipeline/tmgr.c | 26 ++++++++++++++++++++++++--
>  examples/ip_pipeline/tmgr.h |  3 ++-
>  3 files changed, 34 insertions(+), 9 deletions(-)
> 
> diff --git a/examples/ip_pipeline/cli.c b/examples/ip_pipeline/cli.c
> index d79699e..7eccde3 100644
> --- a/examples/ip_pipeline/cli.c
> +++ b/examples/ip_pipeline/cli.c
> @@ -407,6 +407,7 @@ cmd_tmgr_subport_profile(char **tokens,
>  	size_t out_size)
>  {
>  	struct rte_sched_subport_params p;
> +	struct rte_sched_subport_profile_params pp;
>  	int status, i;
> 
>  	if (n_tokens != 35) {
> @@ -414,23 +415,23 @@ cmd_tmgr_subport_profile(char **tokens,
>  		return;
>  	}
> 
> -	if (parser_read_uint64(&p.tb_rate, tokens[3]) != 0) {
> +	if (parser_read_uint64(&pp.tb_rate, tokens[3]) != 0) {
>  		snprintf(out, out_size, MSG_ARG_INVALID, "tb_rate");
>  		return;
>  	}
> 
> -	if (parser_read_uint64(&p.tb_size, tokens[4]) != 0) {
> +	if (parser_read_uint64(&pp.tb_size, tokens[4]) != 0) {
>  		snprintf(out, out_size, MSG_ARG_INVALID, "tb_size");
>  		return;
>  	}
> 
>  	for (i = 0; i < RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE; i++)
> -		if (parser_read_uint64(&p.tc_rate[i], tokens[5 + i]) != 0) {
> +		if (parser_read_uint64(&pp.tc_rate[i], tokens[5 + i]) != 0) {
>  			snprintf(out, out_size, MSG_ARG_INVALID,
> "tc_rate");
>  			return;
>  		}
> 
> -	if (parser_read_uint64(&p.tc_period, tokens[18]) != 0) {
> +	if (parser_read_uint64(&pp.tc_period, tokens[18]) != 0) {
>  		snprintf(out, out_size, MSG_ARG_INVALID, "tc_period");
>  		return;
>  	}
> @@ -440,7 +441,8 @@ cmd_tmgr_subport_profile(char **tokens,
>  		return;
>  	}
> 
> -	if (parser_read_uint32(&p.n_pipes_per_subport_enabled,
> tokens[20]) != 0) {
> +	if (parser_read_uint32(&p.n_pipes_per_subport_enabled,
> +		tokens[20]) != 0) {
>  		snprintf(out, out_size, MSG_ARG_INVALID,
> "n_pipes_per_subport");
>  		return;
>  	}
> @@ -456,7 +458,7 @@ cmd_tmgr_subport_profile(char **tokens,
>  			return;
>  		}
> 
> -	status = tmgr_subport_profile_add(&p);
> +	status = tmgr_subport_profile_add(&p, &pp);
>  	if (status != 0) {
>  		snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
>  		return;
> diff --git a/examples/ip_pipeline/tmgr.c b/examples/ip_pipeline/tmgr.c
> index 91ccbf6..5c3df92 100644
> --- a/examples/ip_pipeline/tmgr.c
> +++ b/examples/ip_pipeline/tmgr.c
> @@ -11,6 +11,9 @@
>  static struct rte_sched_subport_params
>  	subport_profile[TMGR_SUBPORT_PROFILE_MAX];
> 
> +static struct rte_sched_subport_profile_params
> +		profile_params[TMGR_SUBPORT_PROFILE_MAX];
> +

As discussed, it is probably better to merge these two tables into one.

struct subport_profile_params {
	struct rte_sched_subport_params params;
	rte_sched_subport_profile_params profile;
};

struct subport_profile_params subport_profile[TMGR_SUBPORT_PROFILE_MAX];

It avoids confusion and also minimizes the app changes.

The same should be done for the SoftNIC code.

>  static uint32_t n_subport_profiles;
> 
>  static struct rte_sched_pipe_params
> @@ -44,10 +47,11 @@ tmgr_port_find(const char *name)
>  }
> 
>  int
> -tmgr_subport_profile_add(struct rte_sched_subport_params *p)
> +tmgr_subport_profile_add(struct rte_sched_subport_params *p,
> +			 struct rte_sched_subport_profile_params *pp)
>  {
>  	/* Check input params */
> -	if (p == NULL ||
> +	if (p == NULL || pp == NULL ||
>  		p->n_pipes_per_subport_enabled == 0)
>  		return -1;
> 
> @@ -56,6 +60,10 @@ tmgr_subport_profile_add(struct
> rte_sched_subport_params *p)
>  		p,
>  		sizeof(*p));
> 
> +	memcpy(&profile_params[n_subport_profiles],
> +		pp,
> +		sizeof(*pp));
> +
>  	n_subport_profiles++;
> 
>  	return 0;
> @@ -103,6 +111,9 @@ tmgr_port_create(const char *name, struct
> tmgr_port_params *params)
>  	p.mtu = params->mtu;
>  	p.frame_overhead = params->frame_overhead;
>  	p.n_subports_per_port = params->n_subports_per_port;
> +	p.n_subport_profiles = n_subport_profiles;
> +	p.subport_profiles = profile_params;
> +	p.n_max_subport_profiles = TMGR_SUBPORT_PROFILE_MAX;
>  	p.n_pipes_per_subport = TMGR_PIPE_SUBPORT_MAX;
> 
>  	s = rte_sched_port_config(&p);
> @@ -126,6 +137,13 @@ tmgr_port_create(const char *name, struct
> tmgr_port_params *params)
>  			return NULL;
>  		}
> 
> +		status = rte_sched_subport_profile_config(s, i, 0);
> +
> +		if (status) {
> +			rte_sched_port_free(s);
> +			return NULL;
> +		}
> +
>  		for (j = 0; j <
> subport_profile[0].n_pipes_per_subport_enabled; j++) {
>  			status = rte_sched_pipe_config(
>  				s,
> @@ -182,6 +200,10 @@ tmgr_subport_config(const char *port_name,
>  		subport_id,
>  		&subport_profile[subport_profile_id]);
> 
> +	if (!status)
> +		status = rte_sched_subport_profile_config(port->s,
> subport_id,
> +							subport_profile_id);
> +
>  	return status;
>  }
> 
> diff --git a/examples/ip_pipeline/tmgr.h b/examples/ip_pipeline/tmgr.h
> index ee50cf7..8c14523 100644
> --- a/examples/ip_pipeline/tmgr.h
> +++ b/examples/ip_pipeline/tmgr.h
> @@ -48,7 +48,8 @@ struct tmgr_port_params {
>  };
> 
>  int
> -tmgr_subport_profile_add(struct rte_sched_subport_params *p);
> +tmgr_subport_profile_add(struct rte_sched_subport_params *p,
> +			 struct rte_sched_subport_profile_params *pp);
> 
>  int
>  tmgr_pipe_profile_add(struct rte_sched_pipe_params *p);
> --
> 2.7.4

Patch
diff mbox series

diff --git a/examples/ip_pipeline/cli.c b/examples/ip_pipeline/cli.c
index d79699e..7eccde3 100644
--- a/examples/ip_pipeline/cli.c
+++ b/examples/ip_pipeline/cli.c
@@ -407,6 +407,7 @@  cmd_tmgr_subport_profile(char **tokens,
 	size_t out_size)
 {
 	struct rte_sched_subport_params p;
+	struct rte_sched_subport_profile_params pp;
 	int status, i;
 
 	if (n_tokens != 35) {
@@ -414,23 +415,23 @@  cmd_tmgr_subport_profile(char **tokens,
 		return;
 	}
 
-	if (parser_read_uint64(&p.tb_rate, tokens[3]) != 0) {
+	if (parser_read_uint64(&pp.tb_rate, tokens[3]) != 0) {
 		snprintf(out, out_size, MSG_ARG_INVALID, "tb_rate");
 		return;
 	}
 
-	if (parser_read_uint64(&p.tb_size, tokens[4]) != 0) {
+	if (parser_read_uint64(&pp.tb_size, tokens[4]) != 0) {
 		snprintf(out, out_size, MSG_ARG_INVALID, "tb_size");
 		return;
 	}
 
 	for (i = 0; i < RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE; i++)
-		if (parser_read_uint64(&p.tc_rate[i], tokens[5 + i]) != 0) {
+		if (parser_read_uint64(&pp.tc_rate[i], tokens[5 + i]) != 0) {
 			snprintf(out, out_size, MSG_ARG_INVALID, "tc_rate");
 			return;
 		}
 
-	if (parser_read_uint64(&p.tc_period, tokens[18]) != 0) {
+	if (parser_read_uint64(&pp.tc_period, tokens[18]) != 0) {
 		snprintf(out, out_size, MSG_ARG_INVALID, "tc_period");
 		return;
 	}
@@ -440,7 +441,8 @@  cmd_tmgr_subport_profile(char **tokens,
 		return;
 	}
 
-	if (parser_read_uint32(&p.n_pipes_per_subport_enabled, tokens[20]) != 0) {
+	if (parser_read_uint32(&p.n_pipes_per_subport_enabled,
+		tokens[20]) != 0) {
 		snprintf(out, out_size, MSG_ARG_INVALID, "n_pipes_per_subport");
 		return;
 	}
@@ -456,7 +458,7 @@  cmd_tmgr_subport_profile(char **tokens,
 			return;
 		}
 
-	status = tmgr_subport_profile_add(&p);
+	status = tmgr_subport_profile_add(&p, &pp);
 	if (status != 0) {
 		snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
 		return;
diff --git a/examples/ip_pipeline/tmgr.c b/examples/ip_pipeline/tmgr.c
index 91ccbf6..5c3df92 100644
--- a/examples/ip_pipeline/tmgr.c
+++ b/examples/ip_pipeline/tmgr.c
@@ -11,6 +11,9 @@ 
 static struct rte_sched_subport_params
 	subport_profile[TMGR_SUBPORT_PROFILE_MAX];
 
+static struct rte_sched_subport_profile_params
+		profile_params[TMGR_SUBPORT_PROFILE_MAX];
+
 static uint32_t n_subport_profiles;
 
 static struct rte_sched_pipe_params
@@ -44,10 +47,11 @@  tmgr_port_find(const char *name)
 }
 
 int
-tmgr_subport_profile_add(struct rte_sched_subport_params *p)
+tmgr_subport_profile_add(struct rte_sched_subport_params *p,
+			 struct rte_sched_subport_profile_params *pp)
 {
 	/* Check input params */
-	if (p == NULL ||
+	if (p == NULL || pp == NULL ||
 		p->n_pipes_per_subport_enabled == 0)
 		return -1;
 
@@ -56,6 +60,10 @@  tmgr_subport_profile_add(struct rte_sched_subport_params *p)
 		p,
 		sizeof(*p));
 
+	memcpy(&profile_params[n_subport_profiles],
+		pp,
+		sizeof(*pp));
+
 	n_subport_profiles++;
 
 	return 0;
@@ -103,6 +111,9 @@  tmgr_port_create(const char *name, struct tmgr_port_params *params)
 	p.mtu = params->mtu;
 	p.frame_overhead = params->frame_overhead;
 	p.n_subports_per_port = params->n_subports_per_port;
+	p.n_subport_profiles = n_subport_profiles;
+	p.subport_profiles = profile_params;
+	p.n_max_subport_profiles = TMGR_SUBPORT_PROFILE_MAX;
 	p.n_pipes_per_subport = TMGR_PIPE_SUBPORT_MAX;
 
 	s = rte_sched_port_config(&p);
@@ -126,6 +137,13 @@  tmgr_port_create(const char *name, struct tmgr_port_params *params)
 			return NULL;
 		}
 
+		status = rte_sched_subport_profile_config(s, i, 0);
+
+		if (status) {
+			rte_sched_port_free(s);
+			return NULL;
+		}
+
 		for (j = 0; j < subport_profile[0].n_pipes_per_subport_enabled; j++) {
 			status = rte_sched_pipe_config(
 				s,
@@ -182,6 +200,10 @@  tmgr_subport_config(const char *port_name,
 		subport_id,
 		&subport_profile[subport_profile_id]);
 
+	if (!status)
+		status = rte_sched_subport_profile_config(port->s, subport_id,
+							subport_profile_id);
+
 	return status;
 }
 
diff --git a/examples/ip_pipeline/tmgr.h b/examples/ip_pipeline/tmgr.h
index ee50cf7..8c14523 100644
--- a/examples/ip_pipeline/tmgr.h
+++ b/examples/ip_pipeline/tmgr.h
@@ -48,7 +48,8 @@  struct tmgr_port_params {
 };
 
 int
-tmgr_subport_profile_add(struct rte_sched_subport_params *p);
+tmgr_subport_profile_add(struct rte_sched_subport_params *p,
+			 struct rte_sched_subport_profile_params *pp);
 
 int
 tmgr_pipe_profile_add(struct rte_sched_pipe_params *p);