[v5,03/11] sched: add max pipe profiles config in run time

Message ID 20190717144245.138876-4-jasvinder.singh@intel.com (mailing list archive)
State Superseded, archived
Delegated to: Cristian Dumitrescu
Headers
Series sched: feature enhancements |

Checks

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

Commit Message

Jasvinder Singh July 17, 2019, 2:42 p.m. UTC
  Allow setting the maximum number of pipe profiles in run time.

Signed-off-by: Jasvinder Singh <jasvinder.singh@intel.com>
Signed-off-by: Abraham Tovar <abrahamx.tovar@intel.com>
Signed-off-by: Lukasz Krakowiak <lukaszx.krakowiak@intel.com>
---
 lib/librte_sched/rte_sched.c | 8 +++++---
 lib/librte_sched/rte_sched.h | 2 ++
 2 files changed, 7 insertions(+), 3 deletions(-)
  

Patch

diff --git a/lib/librte_sched/rte_sched.c b/lib/librte_sched/rte_sched.c
index 3d3d4c69f..8aff34f5c 100644
--- a/lib/librte_sched/rte_sched.c
+++ b/lib/librte_sched/rte_sched.c
@@ -180,6 +180,7 @@  struct rte_sched_port {
 	uint32_t frame_overhead;
 	uint16_t qsize[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
 	uint32_t n_pipe_profiles;
+	uint32_t n_max_pipe_profiles;
 	uint32_t pipe_tc3_rate_max;
 #ifdef RTE_SCHED_RED
 	struct rte_red_config red_config[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE][RTE_COLORS];
@@ -357,7 +358,7 @@  rte_sched_port_check_params(struct rte_sched_port_params *params)
 	/* pipe_profiles and n_pipe_profiles */
 	if (params->pipe_profiles == NULL ||
 	    params->n_pipe_profiles == 0 ||
-	    params->n_pipe_profiles > RTE_SCHED_PIPE_PROFILES_PER_PORT)
+	    params->n_pipe_profiles > params->n_max_pipe_profiles)
 		return -9;
 
 	for (i = 0; i < params->n_pipe_profiles; i++) {
@@ -386,7 +387,7 @@  rte_sched_port_get_array_base(struct rte_sched_port_params *params, enum rte_sch
 	uint32_t size_queue_extra
 		= n_queues_per_port * sizeof(struct rte_sched_queue_extra);
 	uint32_t size_pipe_profiles
-		= RTE_SCHED_PIPE_PROFILES_PER_PORT * sizeof(struct rte_sched_pipe_profile);
+		= params->n_max_pipe_profiles * sizeof(struct rte_sched_pipe_profile);
 	uint32_t size_bmp_array = rte_bitmap_get_memory_footprint(n_queues_per_port);
 	uint32_t size_per_pipe_queue_array, size_queue_array;
 
@@ -663,6 +664,7 @@  rte_sched_port_config(struct rte_sched_port_params *params)
 	port->frame_overhead = params->frame_overhead;
 	memcpy(port->qsize, params->qsize, sizeof(params->qsize));
 	port->n_pipe_profiles = params->n_pipe_profiles;
+	port->n_max_pipe_profiles = params->n_max_pipe_profiles;
 
 #ifdef RTE_SCHED_RED
 	for (i = 0; i < RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE; i++) {
@@ -1014,7 +1016,7 @@  rte_sched_port_pipe_profile_add(struct rte_sched_port *port,
 		return -1;
 
 	/* Pipe profiles not exceeds the max limit */
-	if (port->n_pipe_profiles >= RTE_SCHED_PIPE_PROFILES_PER_PORT)
+	if (port->n_pipe_profiles >= port->n_max_pipe_profiles)
 		return -2;
 
 	/* Pipe params */
diff --git a/lib/librte_sched/rte_sched.h b/lib/librte_sched/rte_sched.h
index 2b55c97ab..fb2688ff0 100644
--- a/lib/librte_sched/rte_sched.h
+++ b/lib/librte_sched/rte_sched.h
@@ -216,6 +216,8 @@  struct rte_sched_port_params {
 	/**< Pipe profile table.
 	 * Every pipe is configured using one of the profiles from this table. */
 	uint32_t n_pipe_profiles;        /**< Profiles in the pipe profile table */
+	uint32_t n_max_pipe_profiles;
+	/**< Max profiles allowed in the pipe profile table */
 #ifdef RTE_SCHED_RED
 	struct rte_red_params red_params[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE][RTE_COLORS]; /**< RED parameters */
 #endif