Enable dyynamic configuration of subport bandwidth profile
cover Enable dyynamic configuration of subport bandwidth profile
DPDK sched library allows runtime configuration of the pipe profiles to the pipes of the subport once scheduler hierarchy is constructed. However, to change the subport level bandwidth, existing hierarchy needs to be dismantled and whole process of building hierarchy under subport nodes needs to be repeated which might result in router downtime. Furthermore, due to lack of dynamic configuration of the subport bandwidth profile configuration (shaper and Traffic class rates), the user application is unable to dynamically re-distribute the excess-bandwidth of one subport among other subports in the scheduler hierarchy. Therefore, it is also not possible to adjust the subport bandwidth profile in sync with dynamic changes in pipe profiles of subscribers who want to consume higher bandwidth opportunistically.
This RFC proposes dynamic configuration of the subport bandwidth profile to overcome the runtime situation when group of subscribers are not using the allotted bandwidth and dynamic bandwidth re-distribution is needed the without making any structural changes in the hierarchy.
The implementation work includes refactoring the existing data structures defined for port and subport level, new APIs for adding subport level bandwidth profiles that can be used in runtime which causes API/ABI change. Therefore, deprecation notice will be sent out soon.
Savinay Dharmappa (2):
sched: add dynamic config of subport bandwidth profile example/qos_sched: subport bandwidth dynmaic conf
examples/qos_sched/cfg_file.c | 158 ++++++----- examples/qos_sched/cfg_file.h | 4 + examples/qos_sched/init.c | 24 +- examples/qos_sched/main.h | 1 + examples/qos_sched/profile.cfg | 3 + lib/librte_sched/rte_sched.c | 486 ++++++++++++++++++++++++--------- lib/librte_sched/rte_sched.h | 82 +++++- lib/librte_sched/rte_sched_version.map | 2 + 8 files changed, 544 insertions(+), 216 deletions(-)
Signature · 1 line
2.7.4
RFC PATCH 1/2 sched: add dynamic config of subport bandwidth profile
This patch modifies the subport level data structures and add new API to allow dynamic configuration of the subport bandwidth profile.
--- lib/librte_sched/rte_sched.c | 486 ++++++++++++++++++++++++--------- lib/librte_sched/rte_sched.h | 82 +++++- lib/librte_sched/rte_sched_version.map | 2 + 3 files changed, 424 insertions(+), 146 deletions(-)
lib/librte_sched/rte_sched.c +352 -134
@@ -2,6 +2,7 @@* Copyright(c) 2010-2014 Intel Corporation */ +#include <stdint.h> #include <stdio.h> #include <string.h>
@@ -101,6 +102,16 @@ enum grinder_state {e_GRINDER_READ_MBUF }; +struct rte_sched_subport_profile { +/* Token bucket (TB) */ +uint64_t tb_period; +uint64_t tb_credits_per_period; +uint64_t tb_size; + +uint64_t tc_credits_per_period[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE ]; +uint64_t tc_period; +}; +struct rte_sched_grinder {/* Pipe cache */ uint16_t pcache_qmask[RTE_SCHED_GRINDER_PCACHE_SIZE ];
@@ -113,6 +124,7 @@ struct rte_sched_grinder {uint32_t productive;uint32_t pindex;struct rte_sched_subport *subport; +struct rte_sched_subport_profile *subport_params;struct rte_sched_pipe *pipe;struct rte_sched_pipe_profile *pipe_params;
@@ -139,18 +151,13 @@ struct rte_sched_grinder { };struct rte_sched_subport { -/* Token bucket (TB) */ +uint64_t tb_time;/* time of last update */ -uint64_t tb_period; -uint64_t tb_credits_per_period; -uint64_t tb_size;uint64_t tb_credits;/* Traffic classes (TCs) */ uint64_t tc_time;/* time of next update */ -uint64_t tc_credits_per_period[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE ];uint64_t tc_credits[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE ]; -uint64_t tc_period;/* TC oversubscription */ uint64_t tc_ov_wm;
@@ -164,6 +171,8 @@ struct rte_sched_subport {/* Statistics */ struct rte_sched_subport_stats stats __rte_cache_aligned; +/* subport profile flag */ +uint32_t profile;/* Subport pipes */ uint32_t n_pipes_per_subport_enabled;uint32_t n_pipe_profiles;
@@ -212,6 +221,8 @@ struct rte_sched_port {uint16_t pipe_queue[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE ];uint8_t pipe_tc[RTE_SCHED_QUEUES_PER_PIPE ];uint8_t tc_queue[RTE_SCHED_QUEUES_PER_PIPE ]; +uint32_t n_subport_profiles; +uint32_t n_max_subport_profiles;uint64_t rate;uint32_t mtu;uint32_t frame_overhead;
@@ -229,6 +240,7 @@ struct rte_sched_port {uint32_t subport_id;/* Large data structures */ +struct rte_sched_subport_profile *subport_profiles; struct rte_sched_subport *subports[0] __rte_cache_aligned; } __rte_cache_aligned;
@@ -375,8 +387,60 @@ pipe_profile_check(struct rte_sched_pipe_params *params, }static int +subport_profile_check (struct rte_sched_subport_profile_params *params, +uint64_t rate) +{ +uint32_t i; + +/* Check user parameters */ +if (params ==NULL ) { +RTE_LOG (ERR ,SCHED , +"%s: Incorrect value for parameter params\n" , __func__); +return -EINVAL ; + } + +if (params->tb_rate ==0 || params->tb_rate > rate) { +RTE_LOG (ERR ,SCHED , +"%s: Incorrect value for tb rate\n" , __func__); +return -EINVAL ; + } + +if (params->tb_size ==0 ) { +RTE_LOG (ERR ,SCHED , +"%s: Incorrect value for tb size\n" , __func__); +return -EINVAL ; + } + +for (i =0 ; i <RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE ; i++) { +uint64_t tc_rate = params->tc_rate[i]; + +if (tc_rate ==0 || (tc_rate > params->tb_rate)) { +RTE_LOG (ERR ,SCHED , +"%s: Incorrect value for tc rate\n" , __func__); +return -EINVAL ; + } + } + +if (params->tc_rate[RTE_SCHED_TRAFFIC_CLASS_BE ] ==0 ) { +RTE_LOG (ERR ,SCHED , +"%s: Incorrect tc rate(best effort)\n" , __func__); +return -EINVAL ; + } + +if (params->tc_period ==0 ) { +RTE_LOG (ERR ,SCHED , +"%s: Incorrect value for tc period\n" , __func__); +return -EINVAL ; + } + +return 0 ; +} + +static int rte_sched_port_check_params (struct rte_sched_port_params *params) { +uint32_t i; +if (params ==NULL ) {RTE_LOG (ERR ,SCHED ,"%s: Incorrect value for parameter params\n" , __func__);
@@ -413,6 +477,29 @@ rte_sched_port_check_params(struct rte_sched_port_params *params)return -EINVAL ; } +if (params->subport_profiles ==NULL || + params->n_subport_profiles ==0 || + params->n_max_subport_profiles ==0 || + params->n_subport_profiles > params->n_max_subport_profiles) { +RTE_LOG (ERR ,SCHED , +"%s: Incorrect value for subport profiles\n" , __func__); +return -EINVAL ; + } + +for (i =0 ; i < params->n_subport_profiles; i++) { +struct rte_sched_subport_profile_params *p = + params->subport_profiles + i; +int status; + + status =subport_profile_check (p, params->rate); +if (status !=0 ) { +RTE_LOG (ERR ,SCHED , +"%s: subport profile check failed(%d)\n" , + __func__, status); +return -EINVAL ; + } + } +/* n_pipes_per_subport: non-zero, power of 2 */ if (params->n_pipes_per_subport ==0 || !rte_is_power_of_2 (params->n_pipes_per_subport)) {
@@ -554,6 +641,42 @@ rte_sched_port_log_pipe_profile(struct rte_sched_subport *subport, uint32_t i) p->wrr_cost[0], p->wrr_cost[1], p->wrr_cost[2], p->wrr_cost[3]); } +static void +rte_sched_port_log_subport_profile (struct rte_sched_port *port,uint32_t i) +{ +struct rte_sched_subport_profile *p = port->subport_profiles + i; + +RTE_LOG (DEBUG ,SCHED ,"Low level config for subport profile %u:\n" +"Token bucket: period = %" PRIu64", credits per period = %" PRIu64",\ +size = %" PRIu64"\n" +"Traffic classes: period = %" PRIu64",\n" +"credits per period = [%" PRIu64", %" PRIu64", %" PRIu64", %" PRIu64 +" %" PRIu64", %" PRIu64", %" PRIu64", %" PRIu64", %" PRIu64", %" PRIu64 +" %" PRIu64", %" PRIu64", %" PRIu64"]\n" , + i, + +/* Token bucket */ + p->tb_period, + p->tb_credits_per_period, + p->tb_size, + +/* Traffic classes */ + p->tc_period, + p->tc_credits_per_period[0 ], + p->tc_credits_per_period[1 ], + p->tc_credits_per_period[2 ], + p->tc_credits_per_period[3 ], + p->tc_credits_per_period[4 ], + p->tc_credits_per_period[5 ], + p->tc_credits_per_period[6 ], + p->tc_credits_per_period[7 ], + p->tc_credits_per_period[8 ], + p->tc_credits_per_period[9 ], + p->tc_credits_per_period[10 ], + p->tc_credits_per_period[11 ], + p->tc_credits_per_period[12 ]); +} +static inline uint64_t rte_sched_time_ms_to_bytes (uint64_t time_ms,uint64_t rate) {
@@ -623,6 +746,37 @@ rte_sched_pipe_profile_convert(struct rte_sched_subport *subport, }static void +rte_sched_subport_profile_convert (struct rte_sched_subport_profile_params *src, +struct rte_sched_subport_profile *dst, +uint64_t rate) +{ +uint32_t i; + +/* Token Bucket */ +if (src->tb_rate == rate) { + dst->tb_credits_per_period =1 ; + dst->tb_period =1 ; + }else { +double tb_rate = (double ) src->tb_rate + / (double ) rate; +double d =RTE_SCHED_TB_RATE_CONFIG_ERR ; + +rte_approx_64 (tb_rate, d, &dst->tb_credits_per_period, + &dst->tb_period); + } + + dst->tb_size = src->tb_size; + +/* Traffic Classes */ + dst->tc_period =rte_sched_time_ms_to_bytes (src->tc_period, rate); + +for (i =0 ; i <RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE ; i++) + dst->tc_credits_per_period[i] + =rte_sched_time_ms_to_bytes (src->tc_period, + src->tc_rate[i]); +} + +static void rte_sched_subport_config_pipe_profile_table (struct rte_sched_subport *subport,struct rte_sched_subport_params *params,uint32_t rate) {
@@ -646,6 +800,24 @@ rte_sched_subport_config_pipe_profile_table(struct rte_sched_subport *subport, } } +static void +rte_sched_port_config_subport_profile_table (struct rte_sched_port *port, +struct rte_sched_port_params *params, +uint64_t rate) +{ +uint32_t i; + +for (i =0 ; i < port->n_subport_profiles; i++) { +struct rte_sched_subport_profile_params *src + = params->subport_profiles + i; +struct rte_sched_subport_profile *dst + = port->subport_profiles + i; + +rte_sched_subport_profile_convert (src, dst, rate); +rte_sched_port_log_subport_profile (port, i); + } +} + static int rte_sched_subport_check_params(struct rte_sched_subport_params *params, uint32_t n_max_pipes_per_subport,
@@ -660,18 +832,6 @@ rte_sched_subport_check_params(struct rte_sched_subport_params *params,return -EINVAL ; } -if (params->tb_rate ==0 || params->tb_rate > rate) { -RTE_LOG (ERR ,SCHED , -"%s: Incorrect value for tb rate\n" , __func__); -return -EINVAL ; - } - -if (params->tb_size ==0 ) { -RTE_LOG (ERR ,SCHED , -"%s: Incorrect value for tb size\n" , __func__); -return -EINVAL ; - } -/* qsize: if non-zero, power of 2, * no bigger than 32K (due to 16-bit read/write pointers) */
@@ -685,32 +845,12 @@ rte_sched_subport_check_params(struct rte_sched_subport_params *params, } } -for (i =0 ; i <RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE ; i++) { -uint64_t tc_rate = params->tc_rate[i]; -uint16_t qsize = params->qsize[i]; - -if ((qsize ==0 && tc_rate !=0 ) || - (qsize !=0 && tc_rate ==0 ) || - (tc_rate > params->tb_rate)) { -RTE_LOG (ERR ,SCHED , -"%s: Incorrect value for tc rate\n" , __func__); -return -EINVAL ; - } - } - -if (params->qsize[RTE_SCHED_TRAFFIC_CLASS_BE ] ==0 || - params->tc_rate[RTE_SCHED_TRAFFIC_CLASS_BE ] ==0 ) { +if (params->qsize[RTE_SCHED_TRAFFIC_CLASS_BE ] ==0 ) {RTE_LOG (ERR ,SCHED ,"%s: Incorrect qsize or tc rate(best effort)\n" , __func__);return -EINVAL ; } -if (params->tc_period ==0 ) { -RTE_LOG (ERR ,SCHED , -"%s: Incorrect value for tc period\n" , __func__); -return -EINVAL ; - } -/* n_pipes_per_subport: non-zero, power of 2 */ if (params->n_pipes_per_subport_enabled == 0 || params->n_pipes_per_subport_enabled > n_max_pipes_per_subport ||
@@ -792,7 +932,7 @@ struct rte_sched_port * rte_sched_port_config(struct rte_sched_port_params *params) {struct rte_sched_port *port =NULL ; -uint32_t size0, size1; +uint32_t size0, size1, size2;uint32_t cycles_per_byte;uint32_t i, j;int status;
@@ -807,10 +947,21 @@ rte_sched_port_config(struct rte_sched_port_params *params) size0 =sizeof (struct rte_sched_port ); size1 = params->n_subports_per_port *sizeof (struct rte_sched_subport *); + size2 = params->n_max_subport_profiles * +sizeof (struct rte_sched_subport_profile );/* Allocate memory to store the data structures */ - port =rte_zmalloc_socket ("qos_params" , size0 + size1,RTE_CACHE_LINE_SIZE , - params->socket); + port =rte_zmalloc_socket ("qos_params" , size0 + size1, +RTE_CACHE_LINE_SIZE , params->socket); +if (port ==NULL ) { +RTE_LOG (ERR ,SCHED ,"%s: Memory allocation fails\n" , __func__); + +return NULL ; + } + +/* Allocate memory to store the subport profile */ + port->subport_profiles =rte_zmalloc_socket ("subport_profile" , size2, +RTE_CACHE_LINE_SIZE , params->socket);if (port ==NULL ) {RTE_LOG (ERR ,SCHED ,"%s: Memory allocation fails\n" , __func__);
@@ -819,6 +970,8 @@ rte_sched_port_config(struct rte_sched_port_params *params)/* User parameters */ port->n_subports_per_port = params->n_subports_per_port; + port->n_subport_profiles = params->n_subport_profiles; + port->n_max_subport_profiles = params->n_max_subport_profiles; port->n_pipes_per_subport = params->n_pipes_per_subport; port->n_pipes_per_subport_log2 =__builtin_ctz (params->n_pipes_per_subport);
@@ -849,6 +1002,9 @@ rte_sched_port_config(struct rte_sched_port_params *params) port->time_cpu_bytes =0 ; port->time =0 ; +/* Subport profile table */ +rte_sched_port_config_subport_profile_table (port, params, port->rate); + cycles_per_byte = (rte_get_tsc_hz () <<RTE_SCHED_TIME_SHIFT ) / params->rate; port->inv_cycles_per_byte =rte_reciprocal_value (cycles_per_byte);
@@ -907,48 +1063,6 @@ rte_sched_port_free(struct rte_sched_port *port) }static void -rte_sched_port_log_subport_config (struct rte_sched_port *port,uint32_t i) -{ -struct rte_sched_subport *s = port->subports[i]; - -RTE_LOG (DEBUG ,SCHED ,"Low level config for subport %u:\n" -" Token bucket: period = %" PRIu64", credits per period = %" PRIu64 -", size = %" PRIu64"\n" -" Traffic classes: period = %" PRIu64"\n" -" credits per period = [%" PRIu64", %" PRIu64", %" PRIu64", %" PRIu64 -", %" PRIu64", %" PRIu64", %" PRIu64", %" PRIu64", %" PRIu64", %" PRIu64 -", %" PRIu64", %" PRIu64", %" PRIu64"]\n" -" Best effort traffic class oversubscription: wm min = %" PRIu64 -", wm max = %" PRIu64"\n" , - i, - -/* Token bucket */ - s->tb_period, - s->tb_credits_per_period, - s->tb_size, - -/* Traffic classes */ - s->tc_period, - s->tc_credits_per_period[0 ], - s->tc_credits_per_period[1 ], - s->tc_credits_per_period[2 ], - s->tc_credits_per_period[3 ], - s->tc_credits_per_period[4 ], - s->tc_credits_per_period[5 ], - s->tc_credits_per_period[6 ], - s->tc_credits_per_period[7 ], - s->tc_credits_per_period[8 ], - s->tc_credits_per_period[9 ], - s->tc_credits_per_period[10 ], - s->tc_credits_per_period[11 ], - s->tc_credits_per_period[12 ], - -/* Best effort traffic class oversubscription */ - s->tc_ov_wm_min, - s->tc_ov_wm_max); -} - -static void rte_sched_free_memory (struct rte_sched_port *port,uint32_t n_subports) {uint32_t i;
@@ -1021,33 +1135,7 @@ rte_sched_subport_config(struct rte_sched_port *port,/* Port */ port->subports[subport_id] = s; -/* Token Bucket (TB) */ -if (params->tb_rate == port->rate) { - s->tb_credits_per_period =1 ; - s->tb_period =1 ; - }else { -double tb_rate = ((double ) params->tb_rate) / ((double ) port->rate); -double d =RTE_SCHED_TB_RATE_CONFIG_ERR ; - -rte_approx_64 (tb_rate, d, &s->tb_credits_per_period, &s->tb_period); - } - - s->tb_size = params->tb_size; s->tb_time = port->time; - s->tb_credits = s->tb_size /2 ; - -/* Traffic Classes (TCs) */ - s->tc_period =rte_sched_time_ms_to_bytes (params->tc_period, port->rate); -for (i =0 ; i <RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE ; i++) { -if (params->qsize[i]) - s->tc_credits_per_period[i] - =rte_sched_time_ms_to_bytes (params->tc_period, - params->tc_rate[i]); - } - s->tc_time = port->time + s->tc_period; -for (i =0 ; i <RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE ; i++) -if (params->qsize[i]) - s->tc_credits[i] = s->tc_credits_per_period[i];/* compile time checks */ RTE_BUILD_BUG_ON (RTE_SCHED_PORT_N_GRINDERS ==0 );
@@ -1137,8 +1225,6 @@ rte_sched_subport_config(struct rte_sched_port *port,#ifdef RTE_SCHED_SUBPORT_TC_OV /* TC oversubscription */ s->tc_ov_wm_min = port->mtu; - s->tc_ov_wm_max =rte_sched_time_ms_to_bytes (params->tc_period, - s->pipe_tc_be_rate_max); s->tc_ov_wm = s->tc_ov_wm_max; s->tc_ov_period_id =0 ; s->tc_ov =0 ;
@@ -1146,7 +1232,54 @@ rte_sched_subport_config(struct rte_sched_port *port, s->tc_ov_rate =0 ;#endif -rte_sched_port_log_subport_config (port, subport_id); +return 0 ; +} + +int +rte_sched_subport_profile_config (struct rte_sched_port *port, +uint32_t subport_id, +uint32_t profile_id) +{ +int i; +struct rte_sched_subport_profile *params; +uint32_t n_subports = subport_id +1 ; +struct rte_sched_subport *s; + +if (port ==NULL ) { +RTE_LOG (ERR ,SCHED , +"%s: Incorrect value for parameter port\n" , __func__); +return -EINVAL ; + } + +if (subport_id >= port->n_subports_per_port) { +RTE_LOG (ERR ,SCHED , +"%s: Incorrect value for parameter subport id\n" , __func__); + +rte_sched_free_memory (port, n_subports); +return -EINVAL ; + } + + params = port->subport_profiles + profile_id; + + s = port->subports[subport_id]; + + s->tb_credits = params->tb_size /2 ; + + s->tc_time = port->time + params->tc_period; + +for (i =0 ; i <RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE ; i++) +if (s->qsize[i]) + s->tc_credits[i] = params->tc_credits_per_period[i]; +else + params->tc_credits_per_period[i] =0 ; + +#ifdef RTE_SCHED_SUBPORT_TC_OV + s->tc_ov_wm_max =rte_sched_time_ms_to_bytes (params->tc_period, + s->pipe_tc_be_rate_max); +#endif + s->profile = profile_id; + +rte_sched_port_log_subport_profile (port, profile_id);return 0 ; }
@@ -1158,6 +1291,7 @@ rte_sched_pipe_config(struct rte_sched_port *port, int32_t pipe_profile) {struct rte_sched_subport *s; +struct rte_sched_subport_profile *sp;struct rte_sched_pipe *p;struct rte_sched_pipe_profile *params;uint32_t n_subports = subport_id +1 ;
@@ -1198,14 +1332,16 @@ rte_sched_pipe_config(struct rte_sched_port *port,return -EINVAL ; } + sp = port->subport_profiles + s->profile; +/* Handle the case when pipe already has a valid configuration */ p = s->pipe + pipe_id;if (p->tb_time) { params = s->pipe_profiles + p->profile;double subport_tc_be_rate = - (double ) s->tc_credits_per_period[RTE_SCHED_TRAFFIC_CLASS_BE ] - / (double ) s->tc_period; + (double ) sp->tc_credits_per_period[RTE_SCHED_TRAFFIC_CLASS_BE ] + / (double ) sp->tc_period;double pipe_tc_be_rate = (double ) params->tc_credits_per_period[RTE_SCHED_TRAFFIC_CLASS_BE ] / (double ) params->tc_period;
@@ -1247,8 +1383,8 @@ rte_sched_pipe_config(struct rte_sched_port *port, {/* Subport best effort tc oversubscription */ double subport_tc_be_rate = - (double ) s->tc_credits_per_period[RTE_SCHED_TRAFFIC_CLASS_BE ] - / (double ) s->tc_period; + (double ) sp->tc_credits_per_period[RTE_SCHED_TRAFFIC_CLASS_BE ] + / (double ) sp->tc_period;double pipe_tc_be_rate = (double ) params->tc_credits_per_period[RTE_SCHED_TRAFFIC_CLASS_BE ] / (double ) params->tc_period;
@@ -1260,8 +1396,9 @@ rte_sched_pipe_config(struct rte_sched_port *port,if (s->tc_ov != tc_be_ov) {RTE_LOG (DEBUG ,SCHED , -"Subport %u Best effort TC oversubscription is ON (%.4lf < %.4lf)\n" , - subport_id, subport_tc_be_rate, s->tc_ov_rate); +"Subport %u Best effort TC oversubscription is ON \ +(%.4lf < %.4lf)\n" , + subport_id, subport_tc_be_rate, s->tc_ov_rate); } p->tc_ov_period_id = s->tc_ov_period_id; p->tc_ov_credits = s->tc_ov_wm;
@@ -1335,6 +1472,72 @@ rte_sched_subport_pipe_profile_add(struct rte_sched_port *port,return 0 ; } +int +rte_sched_port_subport_profile_add (struct rte_sched_port *port, +struct rte_sched_subport_profile_params *params, +uint32_t *subport_profile_id) +{ +int status; +uint32_t i; +struct rte_sched_subport_profile *dst; + +/* Port */ +if (port ==NULL ) { +RTE_LOG (ERR ,SCHED , +"%s: Incorrect value for parameter port\n" , __func__); +return -EINVAL ; + } + +if (params ==NULL ) { +RTE_LOG (ERR ,SCHED , +"%s: Incorrect value for parameter profile\n" , __func__); +return -EINVAL ; + } + +if (subport_profile_id ==NULL ) { +RTE_LOG (ERR ,SCHED , +"%s: Incorrect value for parameter \ +subport_profile_id\n" , __func__); +return -EINVAL ; + } + + dst = port->subport_profiles + port->n_subport_profiles; + +/* Subport profiles exceeds the max limit */ +if (port->n_subport_profiles >= port->n_max_subport_profiles) { +RTE_LOG (ERR ,SCHED , +"%s: Number of subport profiles exceeds \ +the max limit\n" , __func__); +return -EINVAL ; + } + + status =subport_profile_check (params, port->rate); +if (status !=0 ) { +RTE_LOG (ERR ,SCHED , +"%s: subport profile check failed(%d)\n" , __func__, status); +return -EINVAL ; + } + +rte_sched_subport_profile_convert (params, dst, port->rate); + +/* Subport profile should not exists */ +for (i =0 ; i < port->n_subport_profiles; i++) +if (memcmp (port->subport_profiles + i, + params,sizeof (*params)) ==0 ) { +RTE_LOG (ERR ,SCHED , +"%s: subport profile exists\n" , __func__); +return -EINVAL ; + } + +/* Subport profile commit */ + *subport_profile_id = port->n_subport_profiles; + port->n_subport_profiles++; + +rte_sched_port_log_subport_profile (port, *subport_profile_id); + +return 0 ; +} + static inline uint32_t rte_sched_port_qindex(struct rte_sched_port *port, uint32_t subport,
@@ -1970,14 +2173,18 @@ grinder_credits_update(struct rte_sched_port *port,struct rte_sched_grinder *grinder = subport->grinder + pos;struct rte_sched_pipe *pipe = grinder->pipe;struct rte_sched_pipe_profile *params = grinder->pipe_params; +struct rte_sched_subport_profile *subport_params = + grinder->subport_params;uint64_t n_periods;uint32_t i;/* Subport TB */ - n_periods = (port->time - subport->tb_time) / subport->tb_period; - subport->tb_credits += n_periods * subport->tb_credits_per_period; - subport->tb_credits =RTE_MIN (subport->tb_credits, subport->tb_size); - subport->tb_time += n_periods * subport->tb_period; + n_periods = (port->time - subport->tb_time) / subport_params->tb_period; + subport->tb_credits += n_periods * + subport_params->tb_credits_per_period; + subport->tb_credits =RTE_MIN (subport->tb_credits, + subport_params->tb_size); + subport->tb_time += n_periods * subport_params->tb_period;/* Pipe TB */ n_periods = (port->time - pipe->tb_time) / params->tb_period;
@@ -1988,9 +2195,10 @@ grinder_credits_update(struct rte_sched_port *port,/* Subport TCs */ if (unlikely (port->time >= subport->tc_time)) {for (i =0 ; i <RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE ; i++) - subport->tc_credits[i] = subport->tc_credits_per_period[i]; + subport->tc_credits[i] = + subport_params->tc_credits_per_period[i]; - subport->tc_time = port->time + subport->tc_period; + subport->tc_time = port->time + subport_params->tc_period; }/* Pipe TCs */
@@ -2008,6 +2216,8 @@ static inline uint64_t grinder_tc_ov_credits_update(struct rte_sched_port *port, struct rte_sched_subport *subport) { + struct rte_sched_subport_profile *subport_params = + grinder->subport_params;uint64_t tc_ov_consumption[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE ];uint64_t tc_consumption =0 , tc_ov_consumption_max;uint64_t tc_ov_wm = subport->tc_ov_wm;
@@ -2018,16 +2228,17 @@ grinder_tc_ov_credits_update(struct rte_sched_port *port,for (i =0 ; i <RTE_SCHED_TRAFFIC_CLASS_BE ; i++) { tc_ov_consumption[i] = - subport->tc_credits_per_period[i] - subport->tc_credits[i]; + subport_params->tc_credits_per_period[i] - + subport->tc_credits[i]; tc_consumption += tc_ov_consumption[i]; } tc_ov_consumption[RTE_SCHED_TRAFFIC_CLASS_BE ] = - subport->tc_credits_per_period[RTE_SCHED_TRAFFIC_CLASS_BE ] - + subport_params->tc_credits_per_period[RTE_SCHED_TRAFFIC_CLASS_BE ] - subport->tc_credits[RTE_SCHED_TRAFFIC_CLASS_BE ]; tc_ov_consumption_max = - subport->tc_credits_per_period[RTE_SCHED_TRAFFIC_CLASS_BE ] - + subport_params->tc_credits_per_period[RTE_SCHED_TRAFFIC_CLASS_BE ] - tc_consumption; if (tc_ov_consumption[RTE_SCHED_TRAFFIC_CLASS_BE] >
@@ -2053,14 +2264,18 @@ grinder_credits_update(struct rte_sched_port *port,struct rte_sched_grinder *grinder = subport->grinder + pos;struct rte_sched_pipe *pipe = grinder->pipe;struct rte_sched_pipe_profile *params = grinder->pipe_params; +struct rte_sched_subport_profile *subport_params = + grinder->subport_params;uint64_t n_periods;uint32_t i;/* Subport TB */ - n_periods = (port->time - subport->tb_time) / subport->tb_period; - subport->tb_credits += n_periods * subport->tb_credits_per_period; - subport->tb_credits =RTE_MIN (subport->tb_credits, subport->tb_size); - subport->tb_time += n_periods * subport->tb_period; + n_periods = (port->time - subport->tb_time) / subport_params->tb_period; + subport->tb_credits += n_periods * + subport_params->tb_credits_per_period; + subport->tb_credits =RTE_MIN (subport->tb_credits, + subport_params->tb_size); + subport->tb_time += n_periods * subport_params->tb_period;/* Pipe TB */ n_periods = (port->time - pipe->tb_time) / params->tb_period;
@@ -2073,9 +2288,10 @@ grinder_credits_update(struct rte_sched_port *port, subport->tc_ov_wm =grinder_tc_ov_credits_update (port, subport);for (i =0 ; i <RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE ; i++) - subport->tc_credits[i] = subport->tc_credits_per_period[i]; + subport->tc_credits[i] = + subport_params->tc_credits_per_period[i]; - subport->tc_time = port->time + subport->tc_period; + subport->tc_time = port->time + subport_params->tc_period; subport->tc_ov_period_id++; }
@@ -2598,6 +2814,8 @@ grinder_handle(struct rte_sched_port *port,struct rte_sched_pipe *pipe = grinder->pipe; grinder->pipe_params = subport->pipe_profiles + pipe->profile; + grinder->subport_params = port->subport_profiles + + subport->profile;grinder_prefetch_tc_queue_arrays (subport, pos);grinder_credits_update (port, subport, pos);
lib/librte_sched/rte_sched.h +70 -12
112 lines not on this page · raw message
lib/librte_sched/rte_sched_version.map +2 -0
@@ -28,4 +28,6 @@ EXPERIMENTAL { global: rte_sched_subport_pipe_profile_add; + rte_sched_port_subport_profile_add; + rte_sched_subport_profile_config; };
Signature · 1 line
2.7.4
Re: [dpdk-dev] [RFC PATCH 1/2] sched: add dynamic config of subport bandwidth profile
Quoted 988 lines
-----Original Message-----
From: Dharmappa, Savinay <[email protected]>
Sent: Wednesday, July 15, 2020 7:28 PM
To: Dharmappa, Savinay <[email protected]>; Singh, Jasvinder <[email protected]>; [email protected]
Subject: [RFC PATCH 1/2] sched: add dynamic config of subport bandwidth profileThis patch modifies the subport level data structures and add new API to allow dynamic configuration of the subport bandwidth profile.
Signed-off-by Savinay Dharmappa <[email protected]>Signed-off-by Jasvinder Singh <[email protected]>--- lib/librte_sched/rte_sched.c | 486 ++++++++++++++++++++++++--------- lib/librte_sched/rte_sched.h | 82 +++++- lib/librte_sched/rte_sched_version.map | 2 + 3 files changed, 424 insertions(+), 146 deletions(-)lib/librte_sched/rte_sched.c index renamed from lib/librte_sched/rte_sched.c +0
-0c0983dd..5bb0d2b 100644
lib/librte_sched/rte_sched.c +11
-0@@ -2,6 +2,7 @@* Copyright(c) 2010-2014 Intel Corporation */ +#include <stdint.h> #include <stdio.h> #include <string.h> @@ -101,6 +102,16 @@ enum grinder_state {e_GRINDER_READ_MBUF }; +struct rte_sched_subport_profile { +/* Token bucket (TB) */ +uint64_t tb_period; +uint64_t tb_credits_per_period; +uint64_t tb_size; + +uint64_t tc_credits_per_period[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE ]; +uint64_t tc_period; +}; +struct rte_sched_grinder {/* Pipe cache */ lib/librte_sched/rte_sched.c +59
-6uint16_t pcache_qmask[RTE_SCHED_GRINDER_PCACHE_SIZE ];@@ -113,6 +124,7 @@ struct rte_sched_grinder {uint32_t productive;uint32_t pindex;struct rte_sched_subport *subport; +struct rte_sched_subport_profile *subport_params;struct rte_sched_pipe *pipe;struct rte_sched_pipe_profile *pipe_params;@@ -139,18 +151,13 @@ struct rte_sched_grinder { };struct rte_sched_subport { -/* Token bucket (TB) */ +uint64_t tb_time;/* time of last update */ -uint64_t tb_period; -uint64_t tb_credits_per_period; -uint64_t tb_size;uint64_t tb_credits;/* Traffic classes (TCs) */ uint64_t tc_time;/* time of next update */ -uint64_t tc_credits_per_period[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];uint64_t tc_credits[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE ]; -uint64_t tc_period;/* TC oversubscription */ uint64_t tc_ov_wm;@@ -164,6 +171,8 @@ struct rte_sched_subport {/* Statistics */ struct rte_sched_subport_stats stats __rte_cache_aligned; +/* subport profile flag */ +uint32_t profile;/* Subport pipes */ uint32_t n_pipes_per_subport_enabled;uint32_t n_pipe_profiles;@@ -212,6 +221,8 @@ struct rte_sched_port {uint16_t pipe_queue[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE ];uint8_t pipe_tc[RTE_SCHED_QUEUES_PER_PIPE ];uint8_t tc_queue[RTE_SCHED_QUEUES_PER_PIPE ]; +uint32_t n_subport_profiles; +uint32_t n_max_subport_profiles;uint64_t rate;uint32_t mtu;uint32_t frame_overhead;@@ -229,6 +240,7 @@ struct rte_sched_port {uint32_t subport_id;/* Large data structures */ +struct rte_sched_subport_profile *subport_profiles; struct rte_sched_subport *subports[0] __rte_cache_aligned; } __rte_cache_aligned;@@ -375,8 +387,60 @@ pipe_profile_check(struct rte_sched_pipe_params *params, }static int +subport_profile_check (struct rte_sched_subport_profile_params *params, +uint64_t rate) +{ +uint32_t i; + +/* Check user parameters */ +if (params ==NULL ) { +RTE_LOG (ERR ,SCHED , +"%s: Incorrect value for parameter params\n" , __func__); +return -EINVAL ; + } + +if (params->tb_rate ==0 || params->tb_rate > rate) { +RTE_LOG (ERR ,SCHED , +"%s: Incorrect value for tb rate\n" , __func__); +return -EINVAL ; + } + +if (params->tb_size ==0 ) { +RTE_LOG (ERR ,SCHED , +"%s: Incorrect value for tb size\n" , __func__); +return -EINVAL ; + } + +for (i =0 ; i <RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE ; i++) { +uint64_t tc_rate = params->tc_rate[i]; + +if (tc_rate ==0 || (tc_rate > params->tb_rate)) { +RTE_LOG (ERR ,SCHED , +"%s: Incorrect value for tc rate\n" , __func__); +return -EINVAL ; + } + } + +if (params->tc_rate[RTE_SCHED_TRAFFIC_CLASS_BE ] ==0 ) { +RTE_LOG (ERR ,SCHED , +"%s: Incorrect tc rate(best effort)\n" , __func__); +return -EINVAL ; + } + +if (params->tc_period ==0 ) { +RTE_LOG (ERR ,SCHED , +"%s: Incorrect value for tc period\n" , __func__); +return -EINVAL ; + } + +return 0 ; +} + +static int rte_sched_port_check_params (struct rte_sched_port_params *params) { +uint32_t i; +if (params ==NULL ) { RTE_LOG(ERR, SCHED, "%s: Incorrect value for parameter params\n",
__func__); @@ -413,6 +477,29 @@rte_sched_port_check_params(struct rte_sched_port_params *params)lib/librte_sched/rte_sched.c +4
-0return -EINVAL ; } +if (params->subport_profiles ==NULL || + params->n_subport_profiles ==0 || + params->n_max_subport_profiles ==0 || + params->n_subport_profiles > params-Quoted 1 line
n_max_subport_profiles) {lib/librte_sched/rte_sched.c +20
-0+RTE_LOG (ERR ,SCHED , +"%s: Incorrect value for subport profiles\n" , __func__); +return -EINVAL ; + } + +for (i =0 ; i < params->n_subport_profiles; i++) { +struct rte_sched_subport_profile_params *p = + params->subport_profiles + i; +int status; + + status =subport_profile_check (p, params->rate); +if (status !=0 ) { +RTE_LOG (ERR ,SCHED , +"%s: subport profile check failed(%d)\n" , + __func__, status); +return -EINVAL ; + } + } +/* n_pipes_per_subport: non-zero, power of 2 */ if (params->n_pipes_per_subport == 0 || !rte_is_power_of_2(params->n_pipes_per_subport)) { @@ -554,6 +641,42 @@ rte_sched_port_log_pipe_profile(struct rte_sched_subport*subport,
uint32_ti)
p->wrr_cost[0], p->wrr_cost[1], p->wrr_cost[2], p-Quoted 1 line
wrr_cost[3]); }
lib/librte_sched/rte_sched.c +6
-0+static void +rte_sched_port_log_subport_profile (struct rte_sched_port *port, +uint32_t i) { +struct rte_sched_subport_profile *p = port->subport_profiles + i; + + RTE_LOG(DEBUG, SCHED, "Low level config for subport profile%u:\n"
lib/librte_sched/rte_sched.c +5
-0+"Token bucket: period = %" PRIu64", credits per period = %" PRIu64",\ +size = %" PRIu64"\n" +"Traffic classes: period = %" PRIu64",\n" +"credits per period = [%" PRIu64", %" PRIu64", %" PRIu64", %" PRIu64 + " %"PRIu64", %"PRIu64", %"PRIu64", %"PRIu64", %"PRIu64",%"PRIu64
lib/librte_sched/rte_sched.c +26
-0+" %" PRIu64", %" PRIu64", %" PRIu64"]\n" , + i, + +/* Token bucket */ + p->tb_period, + p->tb_credits_per_period, + p->tb_size, + +/* Traffic classes */ + p->tc_period, + p->tc_credits_per_period[0 ], + p->tc_credits_per_period[1 ], + p->tc_credits_per_period[2 ], + p->tc_credits_per_period[3 ], + p->tc_credits_per_period[4 ], + p->tc_credits_per_period[5 ], + p->tc_credits_per_period[6 ], + p->tc_credits_per_period[7 ], + p->tc_credits_per_period[8 ], + p->tc_credits_per_period[9 ], + p->tc_credits_per_period[10 ], + p->tc_credits_per_period[11 ], + p->tc_credits_per_period[12]); +} + static inline uint64_t rte_sched_time_ms_to_bytes(uint64_t time_ms, uint64_t rate) { @@ -623,6 +746,37 @@ rte_sched_pipe_profile_convert(struct rte_sched_subport*subport, }
static void
+rte_sched_subport_profile_convert(structrte_sched_subport_profile_params*src,lib/librte_sched/rte_sched.c +30
-0+struct rte_sched_subport_profile *dst, + uint64_t rate) +{ + uint32_t i; + +/* Token Bucket */ +if (src->tb_rate == rate) { + dst->tb_credits_per_period =1 ; + dst->tb_period =1 ; + }else { +double tb_rate = (double ) src->tb_rate + / (double ) rate; +double d =RTE_SCHED_TB_RATE_CONFIG_ERR ; + +rte_approx_64 (tb_rate, d, &dst->tb_credits_per_period, + &dst->tb_period); + } + + dst->tb_size = src->tb_size; + +/* Traffic Classes */ + dst->tc_period =rte_sched_time_ms_to_bytes (src->tc_period, rate); + +for (i =0 ; i <RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE ; i++) + dst->tc_credits_per_period[i] + =rte_sched_time_ms_to_bytes (src->tc_period, + src->tc_rate[i]); +} + +static void rte_sched_subport_config_pipe_profile_table(struct rte_sched_subport*subport,
structrte_sched_subport_params*params,uint32_trate) { @@ -
646,6 +800,24 @@ rte_sched_subport_config_pipe_profile_table(structrte_sched_subport*subport,lib/librte_sched/rte_sched.c +18
-0} } +static void +rte_sched_port_config_subport_profile_table (struct rte_sched_port *port, +struct rte_sched_port_params *params, +uint64_t rate) +{ +uint32_t i; + +for (i =0 ; i < port->n_subport_profiles; i++) { +struct rte_sched_subport_profile_params *src + = params->subport_profiles + i; +struct rte_sched_subport_profile *dst + = port->subport_profiles + i; + +rte_sched_subport_profile_convert (src, dst, rate); +rte_sched_port_log_subport_profile (port, i); + } +} +static int rte_sched_subport_check_params(struct rte_sched_subport_params*params,
lib/librte_sched/rte_sched.c +0
-12uint32_t n_max_pipes_per_subport,@@ -660,18 +832,6 @@ rte_sched_subport_check_params(struct rte_sched_subport_params *params, return -EINVAL ; } -if (params->tb_rate ==0 || params->tb_rate > rate) { -RTE_LOG (ERR ,SCHED , -"%s: Incorrect value for tb rate\n" , __func__); -return -EINVAL ; - } - -if (params->tb_size ==0 ) { -RTE_LOG (ERR ,SCHED , -"%s: Incorrect value for tb size\n" , __func__); -return -EINVAL ; - } -/* qsize: if non-zero, power of 2, * no bigger than 32K (due to 16-bit read/write pointers) lib/librte_sched/rte_sched.c +1
-21*/ @@ -685,32 +845,12 @@ rte_sched_subport_check_params(struct rte_sched_subport_params *params, } } -for (i =0 ; i <RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE ; i++) { -uint64_t tc_rate = params->tc_rate[i]; -uint16_t qsize = params->qsize[i]; - -if ((qsize ==0 && tc_rate !=0 ) || - (qsize !=0 && tc_rate ==0 ) || - (tc_rate > params->tb_rate)) { -RTE_LOG (ERR ,SCHED , -"%s: Incorrect value for tc rate\n" , __func__); -return -EINVAL ; - } - } - -if (params->qsize[RTE_SCHED_TRAFFIC_CLASS_BE ] ==0 || - params->tc_rate[RTE_SCHED_TRAFFIC_CLASS_BE ] ==0 ) { +if (params->qsize[RTE_SCHED_TRAFFIC_CLASS_BE ] ==0 ) {RTE_LOG (ERR ,SCHED ,"%s: Incorrect qsize or tc rate(best effort)\n" , __func__);return -EINVAL ; } -if (params->tc_period ==0 ) { -RTE_LOG (ERR ,SCHED , -"%s: Incorrect value for tc period\n" , __func__); -return -EINVAL ; - } -/* n_pipes_per_subport: non-zero, power of 2 */ lib/librte_sched/rte_sched.c +0
-0if (params->n_pipes_per_subport_enabled ==0 || params->n_pipes_per_subport_enabled >
n_max_pipes_per_subport|| @@ -792,7 +932,7 @@ structrte_sched_port
*rte_sched_port_config(struct rte_sched_port_params *params){lib/librte_sched/rte_sched.c +7
-3struct rte_sched_port *port =NULL ; -uint32_t size0, size1; +uint32_t size0, size1, size2;uint32_t cycles_per_byte;uint32_t i, j;int status;@@ -807,10 +947,21 @@ rte_sched_port_config(struct rte_sched_port_params *params) size0 =sizeof (struct rte_sched_port ); size1 = params->n_subports_per_port *sizeof (struct rte_sched_subport *); + size2 = params->n_max_subport_profiles * +sizeof (struct rte_sched_subport_profile );/* Allocate memory to store the data structures */ - port =rte_zmalloc_socket ("qos_params" , size0 + size1,RTE_CACHE_LINE_SIZE , - params->socket); + port =rte_zmalloc_socket ("qos_params" , size0 + size1, +RTE_CACHE_LINE_SIZE , params->socket); +if (port ==NULL ) { + RTE_LOG(ERR, SCHED, "%s: Memory allocation fails\n",
__func__);lib/librte_sched/rte_sched.c +6
-0+ +return NULL ; + } + +/* Allocate memory to store the subport profile */ + port->subport_profiles = rte_zmalloc_socket("subport_profile",size2,
lib/librte_sched/rte_sched.c +1
-0+ RTE_CACHE_LINE_SIZE, params-Quoted 1 line
socket);
lib/librte_sched/rte_sched.c +0
-0if (port ==NULL ) { RTE_LOG(ERR, SCHED, "%s: Memory allocation fails\n",
__func__);lib/librte_sched/rte_sched.c +2
-0@@ -819,6 +970,8 @@ rte_sched_port_config(struct rte_sched_port_params *params)/* User parameters */ port->n_subports_per_port = params->n_subports_per_port; + port->n_subport_profiles = params->n_subport_profiles; + port->n_max_subport_profiles = params->n_max_subport_profiles; port->n_pipes_per_subport = params->n_pipes_per_subport; port->n_pipes_per_subport_log2 =lib/librte_sched/rte_sched.c +3
-0__builtin_ctz (params->n_pipes_per_subport);@@ -849,6 +1002,9 @@ rte_sched_port_config(struct rte_sched_port_params *params) port->time_cpu_bytes = 0; port->time =0 ; +/* Subport profile table */ +rte_sched_port_config_subport_profile_table (port, params, port- >rate); + cycles_per_byte = (rte_get_tsc_hz () <<RTE_SCHED_TIME_SHIFT )lib/librte_sched/rte_sched.c +0
-6/ params->rate; port->inv_cycles_per_byte =rte_reciprocal_value (cycles_per_byte);@@ -907,48 +1063,6 @@ rte_sched_port_free(struct rte_sched_port *port) } static void -rte_sched_port_log_subport_config(struct rte_sched_port *port, uint32_t i) -{ - struct rte_sched_subport *s = port->subports[i]; - - RTE_LOG(DEBUG, SCHED, "Low level config for subport %u:\n" - " Token bucket: period = %"PRIu64", credits per period= %"PRIu64
lib/librte_sched/rte_sched.c +0
-3-", size = %" PRIu64"\n" -" Traffic classes: period = %" PRIu64"\n" - " credits per period = [%"PRIu64", %"PRIu64",%"PRIu64", %"PRIu64
lib/librte_sched/rte_sched.c +0
-1- ", %"PRIu64", %"PRIu64", %"PRIu64", %"PRIu64", %"PRIu64",%"PRIu64
lib/librte_sched/rte_sched.c +0
-2-", %" PRIu64", %" PRIu64", %" PRIu64"]\n" - " Best effort traffic class oversubscription: wm min =%"PRIu64
lib/librte_sched/rte_sched.c +0
-30-", wm max = %" PRIu64"\n" , - i, - -/* Token bucket */ - s->tb_period, - s->tb_credits_per_period, - s->tb_size, - -/* Traffic classes */ - s->tc_period, - s->tc_credits_per_period[0 ], - s->tc_credits_per_period[1 ], - s->tc_credits_per_period[2 ], - s->tc_credits_per_period[3 ], - s->tc_credits_per_period[4 ], - s->tc_credits_per_period[5 ], - s->tc_credits_per_period[6 ], - s->tc_credits_per_period[7 ], - s->tc_credits_per_period[8 ], - s->tc_credits_per_period[9 ], - s->tc_credits_per_period[10 ], - s->tc_credits_per_period[11 ], - s->tc_credits_per_period[12 ], - -/* Best effort traffic class oversubscription */ - s->tc_ov_wm_min, - s->tc_ov_wm_max); -} - -static void rte_sched_free_memory(struct rte_sched_port *port, uint32_t n_subports){
lib/librte_sched/rte_sched.c +0
-16uint32_t i;@@ -1021,33 +1135,7 @@ rte_sched_subport_config(struct rte_sched_port *port,/* Port */ port->subports[subport_id] = s; -/* Token Bucket (TB) */ -if (params->tb_rate == port->rate) { - s->tb_credits_per_period =1 ; - s->tb_period =1 ; - }else { -double tb_rate = ((double ) params->tb_rate) / ((double ) port->rate); -double d =RTE_SCHED_TB_RATE_CONFIG_ERR ; - -rte_approx_64 (tb_rate, d, &s->tb_credits_per_period, &s- >tb_period); - } - - s->tb_size = params->tb_size; s->tb_time = port->time; - s->tb_credits = s->tb_size /2 ; - -/* Traffic Classes (TCs) */ - s->tc_period = rte_sched_time_ms_to_bytes(params->tc_period,
port->rate);lib/librte_sched/rte_sched.c +0
-4-for (i =0 ; i <RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE ; i++) { -if (params->qsize[i]) - s->tc_credits_per_period[i] - = rte_sched_time_ms_to_bytes(params-Quoted 1 line
tc_period,lib/librte_sched/rte_sched.c +0
-6- params->tc_rate[i]); - } - s->tc_time = port->time + s->tc_period; -for (i =0 ; i <RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE ; i++) -if (params->qsize[i]) - s->tc_credits[i] = s->tc_credits_per_period[i];/* compile time checks */ RTE_BUILD_BUG_ON(RTE_SCHED_PORT_N_GRINDERS == 0); @@ -1137,8 +1225,6 @@ rte_sched_subport_config(struct
rte_sched_port*port, #ifdefRTE_SCHED_SUBPORT_TC_OVlib/librte_sched/rte_sched.c +0
-1/* TC oversubscription */ s->tc_ov_wm_min = port->mtu; - s->tc_ov_wm_max = rte_sched_time_ms_to_bytes(params-Quoted 1 line
tc_period,lib/librte_sched/rte_sched.c +43
-2- s->pipe_tc_be_rate_max); s->tc_ov_wm = s->tc_ov_wm_max; s->tc_ov_period_id =0 ; s->tc_ov =0 ;@@ -1146,7 +1232,54 @@ rte_sched_subport_config(struct rte_sched_port *port, s->tc_ov_rate =0 ;#endif -rte_sched_port_log_subport_config (port, subport_id); +return 0 ; +} + +int +rte_sched_subport_profile_config (struct rte_sched_port *port, +uint32_t subport_id, +uint32_t profile_id) +{ +int i; +struct rte_sched_subport_profile *params; +uint32_t n_subports = subport_id +1 ; +struct rte_sched_subport *s; + +if (port ==NULL ) { +RTE_LOG (ERR ,SCHED , +"%s: Incorrect value for parameter port\n" , __func__); +return -EINVAL ; + } + +if (subport_id >= port->n_subports_per_port) { +RTE_LOG (ERR ,SCHED , +"%s: Incorrect value for parameter subport id\n" , __func__); + +rte_sched_free_memory (port, n_subports); +return -EINVAL ; + } + + params = port->subport_profiles + profile_id; + + s = port->subports[subport_id]; + + s->tb_credits = params->tb_size /2 ; + + s->tc_time = port->time + params->tc_period; + +for (i =0 ; i <RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE ; i++) +if (s->qsize[i]) + s->tc_credits[i] = params->tc_credits_per_period[i]; +else + params->tc_credits_per_period[i] =0 ; + +#ifdef RTE_SCHED_SUBPORT_TC_OV + s->tc_ov_wm_max = rte_sched_time_ms_to_bytes(params-Quoted 1 line
tc_period,lib/librte_sched/rte_sched.c +6
-0+ s->pipe_tc_be_rate_max); +#endif + s->profile = profile_id; + +rte_sched_port_log_subport_profile (port, profile_id);return 0 ; }@@ -1158,6 +1291,7 @@ rte_sched_pipe_config(struct rte_sched_port *port, int32_t pipe_profile) {struct rte_sched_subport *s; +struct rte_sched_subport_profile *sp;struct rte_sched_pipe *p;struct rte_sched_pipe_profile *params;lib/librte_sched/rte_sched.c +2
-1uint32_t n_subports = subport_id +1 ;@@ -1198,14 +1332,16 @@ rte_sched_pipe_config(struct rte_sched_port *port, return -EINVAL ; } + sp = port->subport_profiles + s->profile; +/* Handle the case when pipe already has a valid configuration */ p = s->pipe + pipe_id;if (p->tb_time) { params = s->pipe_profiles + p->profile; double subport_tc_be_rate = - (double) s-Quoted 1 line
tc_credits_per_period[RTE_SCHED_TRAFFIC_CLASS_BE]
lib/librte_sched/rte_sched.c +1
-1- / (double) s->tc_period; + (double) sp-Quoted 1 line
tc_credits_per_period[RTE_SCHED_TRAFFIC_CLASS_BE]
lib/librte_sched/rte_sched.c +1
-0+ / (double) sp->tc_period;double pipe_tc_be_rate = (double) params-Quoted 1 line
tc_credits_per_period[RTE_SCHED_TRAFFIC_CLASS_BE]
lib/librte_sched/rte_sched.c +0
-1/ (double) params->tc_period;@@ -1247,8 +1383,8 @@ rte_sched_pipe_config(struct rte_sched_port *port, {/* Subport best effort tc oversubscription */ double subport_tc_be_rate = - (double) s-Quoted 1 line
tc_credits_per_period[RTE_SCHED_TRAFFIC_CLASS_BE]
lib/librte_sched/rte_sched.c +1
-1- / (double) s->tc_period; + (double) sp-Quoted 1 line
tc_credits_per_period[RTE_SCHED_TRAFFIC_CLASS_BE]
lib/librte_sched/rte_sched.c +1
-0+ / (double) sp->tc_period;double pipe_tc_be_rate = (double) params-Quoted 1 line
tc_credits_per_period[RTE_SCHED_TRAFFIC_CLASS_BE]
lib/librte_sched/rte_sched.c +3
-2/ (double) params->tc_period;@@ -1260,8 +1396,9 @@ rte_sched_pipe_config(struct rte_sched_port *port, if (s->tc_ov != tc_be_ov) { RTE_LOG(DEBUG, SCHED, - "Subport %u Best effort TC oversubscription is ON (%.4lf < %.4lf)\n", - subport_id, subport_tc_be_rate, s- >tc_ov_rate); +"Subport %u Best effort TC oversubscription is ON \ +(%.4lf < %.4lf)\n" , + subport_id, subport_tc_be_rate, s->tc_ov_rate);lib/librte_sched/rte_sched.c +66
-0} p->tc_ov_period_id = s->tc_ov_period_id; p->tc_ov_credits = s->tc_ov_wm;@@ -1335,6 +1472,72 @@ rte_sched_subport_pipe_profile_add(structrte_sched_port *port, return 0; } +int +rte_sched_port_subport_profile_add (struct rte_sched_port *port, +struct rte_sched_subport_profile_params *params, +uint32_t *subport_profile_id) +{ +int status; +uint32_t i; +struct rte_sched_subport_profile *dst; + +/* Port */ +if (port ==NULL ) { +RTE_LOG (ERR ,SCHED , +"%s: Incorrect value for parameter port\n" , __func__); +return -EINVAL ; + } + +if (params ==NULL ) { +RTE_LOG (ERR ,SCHED , +"%s: Incorrect value for parameter profile\n" , __func__); +return -EINVAL ; + } + +if (subport_profile_id ==NULL ) { +RTE_LOG (ERR ,SCHED , +"%s: Incorrect value for parameter \ +subport_profile_id\n" , __func__); +return -EINVAL ; + } + + dst = port->subport_profiles + port->n_subport_profiles; + +/* Subport profiles exceeds the max limit */ +if (port->n_subport_profiles >= port->n_max_subport_profiles) { +RTE_LOG (ERR ,SCHED , +"%s: Number of subport profiles exceeds \ +the max limit\n" , __func__); +return -EINVAL ; + } + + status =subport_profile_check (params, port->rate); +if (status !=0 ) { +RTE_LOG (ERR ,SCHED , +"%s: subport profile check failed(%d)\n" , __func__, status); +return -EINVAL ; + } + +rte_sched_subport_profile_convert (params, dst, port->rate); + +/* Subport profile should not exists */ +for (i =0 ; i < port->n_subport_profiles; i++) +if (memcmp (port->subport_profiles + i, + params,sizeof (*params)) ==0 ) { +RTE_LOG (ERR ,SCHED , +"%s: subport profile exists\n" , __func__); +return -EINVAL ; + } + +/* Subport profile commit */ + *subport_profile_id = port->n_subport_profiles; + port->n_subport_profiles++; + +rte_sched_port_log_subport_profile (port, *subport_profile_id); + +return 0 ; +} + static inline uint32_t rte_sched_port_qindex(struct rte_sched_port *port,lib/librte_sched/rte_sched.c +8
-4uint32_t subport,@@ -1970,14 +2173,18 @@ grinder_credits_update(struct rte_sched_port *port, struct rte_sched_grinder *grinder = subport->grinder + pos;struct rte_sched_pipe *pipe = grinder->pipe;struct rte_sched_pipe_profile *params = grinder->pipe_params; +struct rte_sched_subport_profile *subport_params = + grinder->subport_params;uint64_t n_periods;uint32_t i;/* Subport TB */ - n_periods = (port->time - subport->tb_time) / subport->tb_period; - subport->tb_credits += n_periods * subport->tb_credits_per_period; - subport->tb_credits =RTE_MIN (subport->tb_credits, subport- >tb_size); - subport->tb_time += n_periods * subport->tb_period; + n_periods = (port->time - subport->tb_time) / subport_params- >tb_period; + subport->tb_credits += n_periods * + subport_params->tb_credits_per_period; + subport->tb_credits =RTE_MIN (subport->tb_credits, + subport_params->tb_size); + subport->tb_time += n_periods * subport_params->tb_period;lib/librte_sched/rte_sched.c +0
-0/* Pipe TB */ n_periods = (port->time - pipe->tb_time) / params->tb_period; @@ -1988,9 +2195,10 @@ grinder_credits_update(struct
rte_sched_port*port,lib/librte_sched/rte_sched.c +0
-1/* Subport TCs */ if (unlikely (port->time >= subport->tc_time)) {for (i =0 ; i <RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE ; i++) - subport->tc_credits[i] = subport-Quoted 1 line
tc_credits_per_period[i];
lib/librte_sched/rte_sched.c +5
-1+ subport->tc_credits[i] = + subport_params->tc_credits_per_period[i]; - subport->tc_time = port->time + subport->tc_period; + subport->tc_time = port->time + subport_params->tc_period; }/* Pipe TCs */ @@ -2008,6 +2216,8 @@ static inline uint64_t grinder_tc_ov_credits_update(struct rte_sched_port *port, struct rte_sched_subport *subport) { + struct rte_sched_subport_profile *subport_params = + grinder->subport_params;uint64_t tc_ov_consumption[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE ];uint64_t tc_consumption =0 , tc_ov_consumption_max;
uint64_ttc_ov_wm=subport->tc_ov_wm; @@ -2018,16 +2228,17
@@ grinder_tc_ov_credits_update(structrte_sched_port*port,lib/librte_sched/rte_sched.c +0
-1for (i =0 ; i <RTE_SCHED_TRAFFIC_CLASS_BE ; i++) { tc_ov_consumption[i] = - subport->tc_credits_per_period[i] - subport-Quoted 1 line
tc_credits[i];
lib/librte_sched/rte_sched.c +2
-1+ subport_params->tc_credits_per_period[i] - + subport->tc_credits[i]; tc_consumption += tc_ov_consumption[i]; } tc_ov_consumption[RTE_SCHED_TRAFFIC_CLASS_BE] = - subport-Quoted 1 line
tc_credits_per_period[RTE_SCHED_TRAFFIC_CLASS_BE] -
lib/librte_sched/rte_sched.c +1
-0+ subport_params-Quoted 1 line
tc_credits_per_period[RTE_SCHED_TRAFFIC_CLASS_BE] -
lib/librte_sched/rte_sched.c +0
-1subport->tc_credits[RTE_SCHED_TRAFFIC_CLASS_BE ]; tc_ov_consumption_max = - subport-Quoted 1 line
tc_credits_per_period[RTE_SCHED_TRAFFIC_CLASS_BE] -
lib/librte_sched/rte_sched.c +1
-0+ subport_params-Quoted 1 line
tc_credits_per_period[RTE_SCHED_TRAFFIC_CLASS_BE] -
lib/librte_sched/rte_sched.c +0
-0tc_consumption ; if (tc_ov_consumption[RTE_SCHED_TRAFFIC_CLASS_BE] > @@ -2053,14 +2264,18 @@ grinder_credits_update(struct
rte_sched_port*port,lib/librte_sched/rte_sched.c +2
-3struct rte_sched_grinder *grinder = subport->grinder + pos;struct rte_sched_pipe *pipe = grinder->pipe;struct rte_sched_pipe_profile *params = grinder->pipe_params; +struct rte_sched_subport_profile *subport_params = + grinder->subport_params;uint64_t n_periods;uint32_t i;/* Subport TB */ - n_periods = (port->time - subport->tb_time) / subport->tb_period; - subport->tb_credits += n_periods * subport->tb_credits_per_period; - subport->tb_credits = RTE_MIN(subport->tb_credits, subport-Quoted 1 line
tb_size);lib/librte_sched/rte_sched.c +1
-1- subport->tb_time += n_periods * subport->tb_period; + n_periods = (port->time - subport->tb_time) / subport_params-Quoted 1 line
tb_period;lib/librte_sched/rte_sched.c +5
-0+ subport->tb_credits += n_periods * + subport_params->tb_credits_per_period; + subport->tb_credits =RTE_MIN (subport->tb_credits, + subport_params->tb_size); + subport->tb_time += n_periods * subport_params->tb_period;/* Pipe TB */ n_periods = (port->time - pipe->tb_time) / params->tb_period; @@ -2073,9 +2288,10 @@ grinder_credits_update(struct
rte_sched_port*port,
subport->tc_ov_wm= grinder_tc_ov_credits_update(port,
subport);lib/librte_sched/rte_sched.c +0
-1for (i =0 ; i <RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE ; i++) - subport->tc_credits[i] = subport-Quoted 1 line
tc_credits_per_period[i];
lib/librte_sched/rte_sched.c +5
-1+ subport->tc_credits[i] = + subport_params->tc_credits_per_period[i]; - subport->tc_time = port->time + subport->tc_period; + subport->tc_time = port->time + subport_params->tc_period; subport->tc_ov_period_id++; }@@ -2598,6 +2814,8 @@ grinder_handle(struct rte_sched_port *port,struct rte_sched_pipe *pipe = grinder->pipe; grinder->pipe_params = subport->pipe_profiles + pipe- >profile; + grinder->subport_params = port->subport_profiles + + subport->profile;grinder_prefetch_tc_queue_arrays (subport, pos);grinder_credits_update (port, subport, pos);lib/librte_sched/rte_sched.h index renamed from lib/librte_sched/rte_sched.h +0
-08a5a93c..7623919 100644
lib/librte_sched/rte_sched.h +0
-12@@ -149,18 +149,6 @@ struct rte_sched_pipe_params {* byte. */ struct rte_sched_subport_params { -/** Token bucket rate (measured in bytes per second) */ -uint64_t tb_rate; - -/** Token bucket size (measured in credits) */ -uint64_t tb_size; - -/** Traffic class rates (measured in bytes per second) */ -uint64_t tc_rate[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE ]; - -/** Enforcement period for rates (measured in milliseconds) */ -uint64_t tc_period; -/** Number of subport pipes. * The subport can enable/allocate fewer pipes than the maximum * number set through struct
port_params::n_max_pipes_per_subport,lib/librte_sched/rte_sched.h +14
-0@@ -192,6 +180,20 @@ struct rte_sched_subport_params { #endif }; +struct rte_sched_subport_profile_params { +/** Token bucket rate (measured in bytes per second) */ +uint64_t tb_rate; + +/** Token bucket size (measured in credits) */ +uint64_t tb_size; + +/** Traffic class rates (measured in bytes per second) */ +uint64_t tc_rate[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE ]; + +/** Enforcement period for rates (measured in milliseconds) */ +uint64_t tc_period; +}; +/** Subport statistics */ struct rte_sched_subport_stats { /** Number of packets successfully written */ @@ -254,6 +256,17 @@ struct rte_sched_port_params {/** Number of subports */ lib/librte_sched/rte_sched.h +11
-0uint32_t n_subports_per_port; +/** subport profile table. +* Every pipe is configured using one of the profiles from this table. +*/ +struct rte_sched_subport_profile_params *subport_profiles; + +/** Profiles in the pipe profile table */ +uint32_t n_subport_profiles; + +/** Max allowed profiles in the pipe profile table */ +uint32_t n_max_subport_profiles; +/** Maximum number of subport pipes. * This parameter is used to reserve a fixed number of bits * in struct rte_mbuf::sched.queue_id for the pipe_id for all @@ - 312,6 +325,29 @@ rte_sched_subport_pipe_profile_add(struct
rte_sched_port*port,lib/librte_sched/rte_sched.h +48
-0uint32_t *pipe_profile_id);/** +* @warning +* @b EXPERIMENTAL: this API may change without prior notice. +* +* Hierarchical scheduler subport bandwidth profile add +* Note that this function is safe to use in runtime for adding new +* subport bandwidth profile as it doesn't have any impact on +hiearchical +* structure of the scheduler. +* @param port +* Handle to port scheduler instance +* @param struct rte_sched_subport_profile +* Subport bandwidth profile +* @param subport_profile_d +* Subport profile id +* @return +* 0 upon success, error code otherwise +*/ +__rte_experimental +int +rte_sched_port_subport_profile_add (struct rte_sched_port *port, +struct rte_sched_subport_profile_params *profile, +uint32_t *subport_profile_id); + +/** * Hierarchical scheduler subport configuration * * @param port @@ -329,6 +365,28 @@ rte_sched_subport_config(struct rte_sched_port *port, struct rte_sched_subport_params *params);/** +* @warning +* @b EXPERIMENTAL: this API may change without prior notice. +* +* Hierarchical scheduler subport profile configuration +* Note that this function is safe to use in runtime for applying any +specific +* subport bandwidth profile as it doesn't have any impact on +hiearchical +* structure of the scheduler. +* @param port +* Handle to port scheduler instance +* @param subport_id +* Subport ID +* @param profile_d +* Subport profile id +* @return +* 0 upon success, error code otherwise +*/ +__rte_experimental +int +rte_sched_subport_profile_config (struct rte_sched_port *port, +uint32_t subport_id, +uint32_t profile_id); +/** * Hierarchical scheduler pipe configuration * * @param port lib/librte_sched/rte_sched_version.map +2
-1@@ -28,4 +28,6 @@ EXPERIMENTAL { global: rte_sched_subport_pipe_profile_add; + rte_sched_port_subport_profile_add; + rte_sched_subport_profile_config; }; --
Quoted 1 line
2.7.4
+ Cristian
Re: [dpdk-dev] [RFC PATCH 1/2] sched: add dynamic config of subport bandwidth profile
In reply to Savinay DharmappaQuoted 14 lines
-----Original Message-----
From: dev <[email protected]> On Behalf Of Savinay Dharmappa
Sent: Wednesday, July 15, 2020 7:28 PM
To: Dharmappa, Savinay <[email protected]>; Singh, Jasvinder <[email protected]>; [email protected]
Subject: [dpdk-dev] [RFC PATCH 1/2] sched: add dynamic config of subport bandwidth profileThis patch modifies the subport level data structures and add new API to allow dynamic configuration of the subport bandwidth profile.
Quoted 9 lines
Signed-off-by Savinay Dharmappa <[email protected]>Signed-off-by Jasvinder Singh <[email protected]>--- lib/librte_sched/rte_sched.c | 486 ++++++++++++++++++++++++------ --- lib/librte_sched/rte_sched.h | 82 +++++- lib/librte_sched/rte_sched_version.map | 2 + 3 files changed, 424 insertions(+), 146 deletions(-)
Hi Savinay,
Your patch makes sense, but it is very hard to review, as you put a massive amount of changes (~500 LOCs) in a single patch file.
Can you please split your patch into a patchset with incremental changes that can be reviewed easier? Some suggestions: split the internal changes in multiple increments first before changing the API (like move the check code into separate functions in individual patches, etc), change the API afterwards.
Thanks,
Cristian
Re: [dpdk-dev] [RFC PATCH 1/2] sched: add dynamic config of subport bandwidth profile
Quoted 41 lines
-----Original Message-----
From: Dumitrescu, Cristian
Sent: Monday, July 20, 2020 12:21 PM
To: Savinay Dharmappa <[email protected]>; Dharmappa, Savinay <[email protected]>; Singh, Jasvinder <[email protected]>; [email protected]
Subject: RE: [dpdk-dev] [RFC PATCH 1/2] sched: add dynamic config of subport bandwidth profileQuoted 8 lines
-----Original Message-----
From: dev <[email protected]> On Behalf Of Savinay Dharmappa
Sent: Wednesday, July 15, 2020 7:28 PM
To: Dharmappa, Savinay <[email protected]>; Singh, Jasvinder <[email protected]>; [email protected]
Subject: [dpdk-dev] [RFC PATCH 1/2] sched: add dynamic config of subport bandwidth profileQuoted 8 lines
This patch modifies the subport level data structures and add new API to allow dynamic configuration of the subport bandwidth profile.
Signed-off-by Savinay Dharmappa <[email protected]>Signed-off-by Jasvinder Singh <[email protected]>--- lib/librte_sched/rte_sched.c | 486 ++++++++++++++++++++++++------
Quoted 5 lines
--- lib/librte_sched/rte_sched.h | 82 +++++- lib/librte_sched/rte_sched_version.map | 2 + 3 files changed, 424 insertions(+), 146 deletions(-)Hi Savinay,
Your patch makes sense, but it is very hard to review, as you put a massive amount of changes (~500 LOCs) in a single patch file.
Quoted 8 lines
Can you please split your patch into a patchset with incremental changes that can be reviewed easier? Some suggestions: split the internal changes in multiple increments first before changing the API (like move the check code into separate functions in individual patches, etc), change the API afterwards.
Thanks,
Cristian
Also please send v1 (non-RFC) as part of the next iteration, thanks!
PATCH 1/4 sched: add dynamic config of subport bandwidth profile
In reply to Savinay DharmappaThis patch modifies the subport level data structures and add internal functions to create subport profile table.
--- lib/librte_sched/rte_sched.c | 173 +++++++++++++++++++++++++++++++++++++++---- lib/librte_sched/rte_sched.h | 37 ++++++--- 2 files changed, 185 insertions(+), 25 deletions(-)
lib/librte_sched/rte_sched.c +160 -13
@@ -2,6 +2,7 @@* Copyright(c) 2010-2014 Intel Corporation */ +#include <stdint.h> #include <stdio.h> #include <string.h>
@@ -101,6 +102,16 @@ enum grinder_state {e_GRINDER_READ_MBUF }; +struct rte_sched_subport_profile { +/* Token bucket (TB) */ +uint64_t tb_period; +uint64_t tb_credits_per_period; +uint64_t tb_size; + +uint64_t tc_credits_per_period[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE ]; +uint64_t tc_period; +}; +struct rte_sched_grinder {/* Pipe cache */ uint16_t pcache_qmask[RTE_SCHED_GRINDER_PCACHE_SIZE ];
@@ -139,18 +150,13 @@ struct rte_sched_grinder { };struct rte_sched_subport { -/* Token bucket (TB) */ +uint64_t tb_time;/* time of last update */ -uint64_t tb_period; -uint64_t tb_credits_per_period; -uint64_t tb_size;uint64_t tb_credits;/* Traffic classes (TCs) */ uint64_t tc_time;/* time of next update */ -uint64_t tc_credits_per_period[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE ];uint64_t tc_credits[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE ]; -uint64_t tc_period;/* TC oversubscription */ uint64_t tc_ov_wm;
@@ -164,6 +170,8 @@ struct rte_sched_subport {/* Statistics */ struct rte_sched_subport_stats stats __rte_cache_aligned; +/* subport profile flag */ +uint32_t profile;/* Subport pipes */ uint32_t n_pipes_per_subport_enabled;uint32_t n_pipe_profiles;
@@ -212,6 +220,8 @@ struct rte_sched_port {uint16_t pipe_queue[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE ];uint8_t pipe_tc[RTE_SCHED_QUEUES_PER_PIPE ];uint8_t tc_queue[RTE_SCHED_QUEUES_PER_PIPE ]; +uint32_t n_subport_profiles; +uint32_t n_max_subport_profiles;uint64_t rate;uint32_t mtu;uint32_t frame_overhead;
@@ -229,6 +239,7 @@ struct rte_sched_port {uint32_t subport_id;/* Large data structures */ +struct rte_sched_subport_profile *subport_profiles; struct rte_sched_subport *subports[0] __rte_cache_aligned; } __rte_cache_aligned;
@@ -375,6 +386,56 @@ pipe_profile_check(struct rte_sched_pipe_params *params, }static int +subport_profile_check (struct rte_sched_subport_profile_params *params, +uint64_t rate) +{ +uint32_t i; + +/* Check user parameters */ +if (params ==NULL ) { +RTE_LOG (ERR ,SCHED , +"%s: Incorrect value for parameter params\n" , __func__); +return -EINVAL ; + } + +if (params->tb_rate ==0 || params->tb_rate > rate) { +RTE_LOG (ERR ,SCHED , +"%s: Incorrect value for tb rate\n" , __func__); +return -EINVAL ; + } + +if (params->tb_size ==0 ) { +RTE_LOG (ERR ,SCHED , +"%s: Incorrect value for tb size\n" , __func__); +return -EINVAL ; + } + +for (i =0 ; i <RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE ; i++) { +uint64_t tc_rate = params->tc_rate[i]; + +if (tc_rate ==0 || (tc_rate > params->tb_rate)) { +RTE_LOG (ERR ,SCHED , +"%s: Incorrect value for tc rate\n" , __func__); +return -EINVAL ; + } + } + +if (params->tc_rate[RTE_SCHED_TRAFFIC_CLASS_BE ] ==0 ) { +RTE_LOG (ERR ,SCHED , +"%s: Incorrect tc rate(best effort)\n" , __func__); +return -EINVAL ; + } + +if (params->tc_period ==0 ) { +RTE_LOG (ERR ,SCHED , +"%s: Incorrect value for tc period\n" , __func__); +return -EINVAL ; + } + +return 0 ; +} + +static int rte_sched_port_check_params (struct rte_sched_port_params *params) {if (params ==NULL ) {
@@ -517,13 +578,14 @@ rte_sched_port_log_pipe_profile(struct rte_sched_subport *subport, uint32_t i)struct rte_sched_pipe_profile *p = subport->pipe_profiles + i; RTE_LOG(DEBUG, SCHED, "Low level config for pipe profile %u:\n" - " Token bucket: period = %"PRIu64", credits per period = %"PRIu64", size = %"PRIu64"\n" - " Traffic classes: period = %"PRIu64",\n" - " credits per period = [%"PRIu64", %"PRIu64", %"PRIu64", %"PRIu64 - ", %"PRIu64", %"PRIu64", %"PRIu64", %"PRIu64", %"PRIu64", %"PRIu64 - ", %"PRIu64", %"PRIu64", %"PRIu64"]\n" - " Best-effort traffic class oversubscription: weight = %hhu\n" - " WRR cost: [%hhu, %hhu, %hhu, %hhu]\n", + "Token bucket: period = %"PRIu64", credits per period = %"PRIu64"" + " size = %"PRIu64",\n" + " Traffic classes: period = %"PRIu64",\n" + " credits per period = [%"PRIu64", %"PRIu64", %"PRIu64", %"PRIu64"" + ", %"PRIu64", %"PRIu64", %"PRIu64", %"PRIu64", %"PRIu64", %"PRIu64"" + ", %"PRIu64", %"PRIu64", %"PRIu64"]\n" + " Best-effort traffic class oversubscription: weight = %hhu\n" + " WRR cost: [%hhu, %hhu, %hhu, %hhu]\n", i,/* Token bucket */
@@ -554,6 +616,42 @@ rte_sched_port_log_pipe_profile(struct rte_sched_subport *subport, uint32_t i) p->wrr_cost[0], p->wrr_cost[1], p->wrr_cost[2], p->wrr_cost[3]); } +static void +rte_sched_port_log_subport_profile (struct rte_sched_port *port,uint32_t i) +{ +struct rte_sched_subport_profile *p = port->subport_profiles + i; + +RTE_LOG (DEBUG ,SCHED ,"Low level config for subport profile %u:\n" +"Token bucket: period = %" PRIu64", credits per period = %" PRIu64",\ +size = %" PRIu64"\n" +"Traffic classes: period = %" PRIu64",\n" +"credits per period = [%" PRIu64", %" PRIu64", %" PRIu64", %" PRIu64 +" %" PRIu64", %" PRIu64", %" PRIu64", %" PRIu64", %" PRIu64", %" PRIu64 +" %" PRIu64", %" PRIu64", %" PRIu64"]\n" , + i, + +/* Token bucket */ + p->tb_period, + p->tb_credits_per_period, + p->tb_size, + +/* Traffic classes */ + p->tc_period, + p->tc_credits_per_period[0 ], + p->tc_credits_per_period[1 ], + p->tc_credits_per_period[2 ], + p->tc_credits_per_period[3 ], + p->tc_credits_per_period[4 ], + p->tc_credits_per_period[5 ], + p->tc_credits_per_period[6 ], + p->tc_credits_per_period[7 ], + p->tc_credits_per_period[8 ], + p->tc_credits_per_period[9 ], + p->tc_credits_per_period[10 ], + p->tc_credits_per_period[11 ], + p->tc_credits_per_period[12 ]); +} +static inline uint64_t rte_sched_time_ms_to_bytes (uint64_t time_ms,uint64_t rate) {
@@ -623,6 +721,37 @@ rte_sched_pipe_profile_convert(struct rte_sched_subport *subport, }static void +rte_sched_subport_profile_convert (struct rte_sched_subport_profile_params *src, +struct rte_sched_subport_profile *dst, +uint64_t rate) +{ +uint32_t i; + +/* Token Bucket */ +if (src->tb_rate == rate) { + dst->tb_credits_per_period =1 ; + dst->tb_period =1 ; + }else { +double tb_rate = (double ) src->tb_rate + / (double ) rate; +double d =RTE_SCHED_TB_RATE_CONFIG_ERR ; + +rte_approx_64 (tb_rate, d, &dst->tb_credits_per_period, + &dst->tb_period); + } + + dst->tb_size = src->tb_size; + +/* Traffic Classes */ + dst->tc_period =rte_sched_time_ms_to_bytes (src->tc_period, rate); + +for (i =0 ; i <RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE ; i++) + dst->tc_credits_per_period[i] + =rte_sched_time_ms_to_bytes (src->tc_period, + src->tc_rate[i]); +} + +static void rte_sched_subport_config_pipe_profile_table (struct rte_sched_subport *subport,struct rte_sched_subport_params *params,uint32_t rate) {
@@ -646,6 +775,24 @@ rte_sched_subport_config_pipe_profile_table(struct rte_sched_subport *subport, } } +static void +rte_sched_port_config_subport_profile_table (struct rte_sched_port *port, +struct rte_sched_port_params *params, +uint64_t rate) +{ +uint32_t i; + +for (i =0 ; i < port->n_subport_profiles; i++) { +struct rte_sched_subport_profile_params *src + = params->subport_profiles + i; +struct rte_sched_subport_profile *dst + = port->subport_profiles + i; + +rte_sched_subport_profile_convert (src, dst, rate); +rte_sched_port_log_subport_profile (port, i); + } +} + static int rte_sched_subport_check_params(struct rte_sched_subport_params *params, uint32_t n_max_pipes_per_subport,
lib/librte_sched/rte_sched.h +25 -12
@@ -149,18 +149,6 @@ struct rte_sched_pipe_params {* byte. */ struct rte_sched_subport_params { -/** Token bucket rate (measured in bytes per second) */ -uint64_t tb_rate; - -/** Token bucket size (measured in credits) */ -uint64_t tb_size; - -/** Traffic class rates (measured in bytes per second) */ -uint64_t tc_rate[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE ]; - -/** Enforcement period for rates (measured in milliseconds) */ -uint64_t tc_period; -/** Number of subport pipes. * The subport can enable/allocate fewer pipes than the maximum * number set through struct port_params::n_max_pipes_per_subport,
@@ -192,6 +180,20 @@ struct rte_sched_subport_params {#endif }; +struct rte_sched_subport_profile_params { +/** Token bucket rate (measured in bytes per second) */ +uint64_t tb_rate; + +/** Token bucket size (measured in credits) */ +uint64_t tb_size; + +/** Traffic class rates (measured in bytes per second) */ +uint64_t tc_rate[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE ]; + +/** Enforcement period for rates (measured in milliseconds) */ +uint64_t tc_period; +}; +/** Subport statistics */ struct rte_sched_subport_stats {/** Number of packets successfully written */
@@ -254,6 +256,17 @@ struct rte_sched_port_params {/** Number of subports */ uint32_t n_subports_per_port; +/** subport profile table. +* Every pipe is configured using one of the profiles from this table. +*/ +struct rte_sched_subport_profile_params *subport_profiles; + +/** Profiles in the pipe profile table */ +uint32_t n_subport_profiles; + +/** Max allowed profiles in the pipe profile table */ +uint32_t n_max_subport_profiles; +/** Maximum number of subport pipes. * This parameter is used to reserve a fixed number of bits * in struct rte_mbuf::sched.queue_id for the pipe_id for all
Signature · 1 line
2.7.4
PATCH 2/4 sched: add dynamic config of subport bandwidth profile
This patch builds the subport profile table during port configuration. Since the tb_period,tb_size,tc_period, tb_credits_per_period and tc_credits_per_period are updated in subport profile table, references to them are removed from subport configuration.
--- lib/librte_sched/rte_sched.c | 154 +++++++++++++------------------------------ 1 file changed, 47 insertions(+), 107 deletions(-)
lib/librte_sched/rte_sched.c +47 -107
@@ -438,6 +438,8 @@ subport_profile_check(struct rte_sched_subport_profile_params *params,static int rte_sched_port_check_params (struct rte_sched_port_params *params) { +uint32_t i; +if (params ==NULL ) {RTE_LOG (ERR ,SCHED ,"%s: Incorrect value for parameter params\n" , __func__);
@@ -474,6 +476,29 @@ rte_sched_port_check_params(struct rte_sched_port_params *params)return -EINVAL ; } +if (params->subport_profiles ==NULL || + params->n_subport_profiles ==0 || + params->n_max_subport_profiles ==0 || + params->n_subport_profiles > params->n_max_subport_profiles) { +RTE_LOG (ERR ,SCHED , +"%s: Incorrect value for subport profiles\n" , __func__); +return -EINVAL ; + } + +for (i =0 ; i < params->n_subport_profiles; i++) { +struct rte_sched_subport_profile_params *p = + params->subport_profiles + i; +int status; + + status =subport_profile_check (p, params->rate); +if (status !=0 ) { +RTE_LOG (ERR ,SCHED , +"%s: subport profile check failed(%d)\n" , + __func__, status); +return -EINVAL ; + } + } +/* n_pipes_per_subport: non-zero, power of 2 */ if (params->n_pipes_per_subport ==0 || !rte_is_power_of_2 (params->n_pipes_per_subport)) {
@@ -807,18 +832,6 @@ rte_sched_subport_check_params(struct rte_sched_subport_params *params,return -EINVAL ; } -if (params->tb_rate ==0 || params->tb_rate > rate) { -RTE_LOG (ERR ,SCHED , -"%s: Incorrect value for tb rate\n" , __func__); -return -EINVAL ; - } - -if (params->tb_size ==0 ) { -RTE_LOG (ERR ,SCHED , -"%s: Incorrect value for tb size\n" , __func__); -return -EINVAL ; - } -/* qsize: if non-zero, power of 2, * no bigger than 32K (due to 16-bit read/write pointers) */
@@ -832,32 +845,12 @@ rte_sched_subport_check_params(struct rte_sched_subport_params *params, } } -for (i =0 ; i <RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE ; i++) { -uint64_t tc_rate = params->tc_rate[i]; -uint16_t qsize = params->qsize[i]; - -if ((qsize ==0 && tc_rate !=0 ) || - (qsize !=0 && tc_rate ==0 ) || - (tc_rate > params->tb_rate)) { -RTE_LOG (ERR ,SCHED , -"%s: Incorrect value for tc rate\n" , __func__); -return -EINVAL ; - } - } - -if (params->qsize[RTE_SCHED_TRAFFIC_CLASS_BE ] ==0 || - params->tc_rate[RTE_SCHED_TRAFFIC_CLASS_BE ] ==0 ) { +if (params->qsize[RTE_SCHED_TRAFFIC_CLASS_BE ] ==0 ) {RTE_LOG (ERR ,SCHED ,"%s: Incorrect qsize or tc rate(best effort)\n" , __func__);return -EINVAL ; } -if (params->tc_period ==0 ) { -RTE_LOG (ERR ,SCHED , -"%s: Incorrect value for tc period\n" , __func__); -return -EINVAL ; - } -/* n_pipes_per_subport: non-zero, power of 2 */ if (params->n_pipes_per_subport_enabled == 0 || params->n_pipes_per_subport_enabled > n_max_pipes_per_subport ||
@@ -939,7 +932,7 @@ struct rte_sched_port * rte_sched_port_config(struct rte_sched_port_params *params) {struct rte_sched_port *port =NULL ; -uint32_t size0, size1; +uint32_t size0, size1, size2;uint32_t cycles_per_byte;uint32_t i, j;int status;
@@ -954,10 +947,21 @@ rte_sched_port_config(struct rte_sched_port_params *params) size0 =sizeof (struct rte_sched_port ); size1 = params->n_subports_per_port *sizeof (struct rte_sched_subport *); + size2 = params->n_max_subport_profiles * +sizeof (struct rte_sched_subport_profile );/* Allocate memory to store the data structures */ - port =rte_zmalloc_socket ("qos_params" , size0 + size1,RTE_CACHE_LINE_SIZE , - params->socket); + port =rte_zmalloc_socket ("qos_params" , size0 + size1, +RTE_CACHE_LINE_SIZE , params->socket); +if (port ==NULL ) { +RTE_LOG (ERR ,SCHED ,"%s: Memory allocation fails\n" , __func__); + +return NULL ; + } + +/* Allocate memory to store the subport profile */ + port->subport_profiles =rte_zmalloc_socket ("subport_profile" , size2, +RTE_CACHE_LINE_SIZE , params->socket);if (port ==NULL ) {RTE_LOG (ERR ,SCHED ,"%s: Memory allocation fails\n" , __func__);
@@ -966,6 +970,8 @@ rte_sched_port_config(struct rte_sched_port_params *params)/* User parameters */ port->n_subports_per_port = params->n_subports_per_port; + port->n_subport_profiles = params->n_subport_profiles; + port->n_max_subport_profiles = params->n_max_subport_profiles; port->n_pipes_per_subport = params->n_pipes_per_subport; port->n_pipes_per_subport_log2 =__builtin_ctz (params->n_pipes_per_subport);
@@ -996,6 +1002,9 @@ rte_sched_port_config(struct rte_sched_port_params *params) port->time_cpu_bytes =0 ; port->time =0 ; +/* Subport profile table */ +rte_sched_port_config_subport_profile_table (port, params, port->rate); + cycles_per_byte = (rte_get_tsc_hz () <<RTE_SCHED_TIME_SHIFT ) / params->rate; port->inv_cycles_per_byte =rte_reciprocal_value (cycles_per_byte);
@@ -1054,48 +1063,6 @@ rte_sched_port_free(struct rte_sched_port *port) }static void -rte_sched_port_log_subport_config (struct rte_sched_port *port,uint32_t i) -{ -struct rte_sched_subport *s = port->subports[i]; - -RTE_LOG (DEBUG ,SCHED ,"Low level config for subport %u:\n" -" Token bucket: period = %" PRIu64", credits per period = %" PRIu64 -", size = %" PRIu64"\n" -" Traffic classes: period = %" PRIu64"\n" -" credits per period = [%" PRIu64", %" PRIu64", %" PRIu64", %" PRIu64 -", %" PRIu64", %" PRIu64", %" PRIu64", %" PRIu64", %" PRIu64", %" PRIu64 -", %" PRIu64", %" PRIu64", %" PRIu64"]\n" -" Best effort traffic class oversubscription: wm min = %" PRIu64 -", wm max = %" PRIu64"\n" , - i, - -/* Token bucket */ - s->tb_period, - s->tb_credits_per_period, - s->tb_size, - -/* Traffic classes */ - s->tc_period, - s->tc_credits_per_period[0 ], - s->tc_credits_per_period[1 ], - s->tc_credits_per_period[2 ], - s->tc_credits_per_period[3 ], - s->tc_credits_per_period[4 ], - s->tc_credits_per_period[5 ], - s->tc_credits_per_period[6 ], - s->tc_credits_per_period[7 ], - s->tc_credits_per_period[8 ], - s->tc_credits_per_period[9 ], - s->tc_credits_per_period[10 ], - s->tc_credits_per_period[11 ], - s->tc_credits_per_period[12 ], - -/* Best effort traffic class oversubscription */ - s->tc_ov_wm_min, - s->tc_ov_wm_max); -} - -static void rte_sched_free_memory (struct rte_sched_port *port,uint32_t n_subports) {uint32_t i;
@@ -1168,33 +1135,7 @@ rte_sched_subport_config(struct rte_sched_port *port,/* Port */ port->subports[subport_id] = s; -/* Token Bucket (TB) */ -if (params->tb_rate == port->rate) { - s->tb_credits_per_period =1 ; - s->tb_period =1 ; - }else { -double tb_rate = ((double ) params->tb_rate) / ((double ) port->rate); -double d =RTE_SCHED_TB_RATE_CONFIG_ERR ; - -rte_approx_64 (tb_rate, d, &s->tb_credits_per_period, &s->tb_period); - } - - s->tb_size = params->tb_size; s->tb_time = port->time; - s->tb_credits = s->tb_size /2 ; - -/* Traffic Classes (TCs) */ - s->tc_period =rte_sched_time_ms_to_bytes (params->tc_period, port->rate); -for (i =0 ; i <RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE ; i++) { -if (params->qsize[i]) - s->tc_credits_per_period[i] - =rte_sched_time_ms_to_bytes (params->tc_period, - params->tc_rate[i]); - } - s->tc_time = port->time + s->tc_period; -for (i =0 ; i <RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE ; i++) -if (params->qsize[i]) - s->tc_credits[i] = s->tc_credits_per_period[i];/* compile time checks */ RTE_BUILD_BUG_ON (RTE_SCHED_PORT_N_GRINDERS ==0 );
@@ -1284,8 +1225,6 @@ rte_sched_subport_config(struct rte_sched_port *port,#ifdef RTE_SCHED_SUBPORT_TC_OV /* TC oversubscription */ s->tc_ov_wm_min = port->mtu; - s->tc_ov_wm_max =rte_sched_time_ms_to_bytes (params->tc_period, - s->pipe_tc_be_rate_max); s->tc_ov_wm = s->tc_ov_wm_max; s->tc_ov_period_id =0 ; s->tc_ov =0 ;
@@ -1293,7 +1232,8 @@ rte_sched_subport_config(struct rte_sched_port *port, s->tc_ov_rate =0 ;#endif -rte_sched_port_log_subport_config (port, subport_id); +return 0 ; +}return 0 ; }
Signature · 1 line
2.7.4
PATCH 3/4 sched: add dynamic config of subport bandwidth profile
In reply to Savinay DharmappaThis patch add public APIs to add new subport profile and to configure them.
--- lib/librte_sched/rte_sched.c | 115 ++++++++++++++++++++++++++++++++++++++++++- lib/librte_sched/rte_sched.h | 45 +++++++++++++++++ 2 files changed, 158 insertions(+), 2 deletions(-)
lib/librte_sched/rte_sched.c +113 -2
@@ -1212,8 +1212,8 @@ rte_sched_subport_config(struct rte_sched_port *port, s->bmp =rte_bitmap_init (n_subport_pipe_queues, s->bmp_array, bmp_mem_size);if (s->bmp ==NULL ) { -RTE_LOG (ERR ,SCHED , -"%s: Subport bitmap init error\n" , __func__); +RTE_LOG (ERR ,SCHED ,"%s: " +"Subport bitmap init error\n" , __func__);rte_sched_free_memory (port, n_subports);return -EINVAL ;
@@ -1235,6 +1235,52 @@ rte_sched_subport_config(struct rte_sched_port *port,return 0 ; } +int +rte_sched_subport_profile_config (struct rte_sched_port *port, +uint32_t subport_id, +uint32_t profile_id) +{ +int i; +struct rte_sched_subport_profile *params; +uint32_t n_subports = subport_id +1 ; +struct rte_sched_subport *s; + +if (port ==NULL ) { +RTE_LOG (ERR ,SCHED ,"%s: " +"Incorrect value for parameter port\n" , __func__); +return -EINVAL ; + } + +if (subport_id >= port->n_subports_per_port) { +RTE_LOG (ERR ,SCHED ,"%s: " +"Incorrect value for parameter subport id\n" , __func__); + +rte_sched_free_memory (port, n_subports); +return -EINVAL ; + } + + params = port->subport_profiles + profile_id; + + s = port->subports[subport_id]; + + s->tb_credits = params->tb_size /2 ; + + s->tc_time = port->time + params->tc_period; + +for (i =0 ; i <RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE ; i++) +if (s->qsize[i]) + s->tc_credits[i] = params->tc_credits_per_period[i]; +else + params->tc_credits_per_period[i] =0 ; + +#ifdef RTE_SCHED_SUBPORT_TC_OV + s->tc_ov_wm_max =rte_sched_time_ms_to_bytes (params->tc_period, + s->pipe_tc_be_rate_max); +#endif + s->profile = profile_id; + +rte_sched_port_log_subport_profile (port, profile_id); +return 0 ; }
@@ -1422,6 +1468,71 @@ rte_sched_subport_pipe_profile_add(struct rte_sched_port *port,return 0 ; } +int +rte_sched_port_subport_profile_add (struct rte_sched_port *port, +struct rte_sched_subport_profile_params *params, +uint32_t *subport_profile_id) +{ +int status; +uint32_t i; +struct rte_sched_subport_profile *dst; + +/* Port */ +if (port ==NULL ) { +RTE_LOG (ERR ,SCHED ,"%s: " +"Incorrect value for parameter port\n" , __func__); +return -EINVAL ; + } + +if (params ==NULL ) { +RTE_LOG (ERR ,SCHED ,"%s: " +"Incorrect value for parameter profile\n" , __func__); +return -EINVAL ; + } + +if (subport_profile_id ==NULL ) { +RTE_LOG (ERR ,SCHED ,"%s: " +"Incorrect value for parametersubport_profile_id\n" , + __func__); +return -EINVAL ; + } + + dst = port->subport_profiles + port->n_subport_profiles; + +/* Subport profiles exceeds the max limit */ +if (port->n_subport_profiles >= port->n_max_subport_profiles) { +RTE_LOG (ERR ,SCHED ,"%s: " +"Number of subport profiles exceeds the max limit" , __func__); +return -EINVAL ; + } + + status =subport_profile_check (params, port->rate); +if (status !=0 ) { +RTE_LOG (ERR ,SCHED ,"%s: " +"subport profile check failed(%d)\n" , __func__, status); +return -EINVAL ; + } + +rte_sched_subport_profile_convert (params, dst, port->rate); + +/* Subport profile should not exists */ +for (i =0 ; i < port->n_subport_profiles; i++) +if (memcmp (port->subport_profiles + i, + params,sizeof (*params)) ==0 ) { +RTE_LOG (ERR ,SCHED , +"%s: subport profile exists\n" , __func__); +return -EINVAL ; + } + +/* Subport profile commit */ + *subport_profile_id = port->n_subport_profiles; + port->n_subport_profiles++; + +rte_sched_port_log_subport_profile (port, *subport_profile_id); + +return 0 ; +} + static inline uint32_t rte_sched_port_qindex(struct rte_sched_port *port, uint32_t subport,
lib/librte_sched/rte_sched.h +45 -0
57 lines not on this page · raw message
Signature · 1 line
2.7.4
PATCH 4/4 sched: add dynamic config of subport bandwidth profile
In reply to Savinay DharmappaThis patch modifies the way credits are updated. Credits are updated by fetching parameters from subport profile table.
--- lib/librte_sched/rte_sched.c | 62 ++++++++++++++++++++++------------ lib/librte_sched/rte_sched_version.map | 2 ++ 2 files changed, 43 insertions(+), 21 deletions(-)
lib/librte_sched/rte_sched.c +41 -21
@@ -124,6 +124,7 @@ struct rte_sched_grinder {uint32_t productive;uint32_t pindex;struct rte_sched_subport *subport; +struct rte_sched_subport_profile *subport_params;struct rte_sched_pipe *pipe;struct rte_sched_pipe_profile *pipe_params;
@@ -1291,6 +1292,7 @@ rte_sched_pipe_config(struct rte_sched_port *port, int32_t pipe_profile) {struct rte_sched_subport *s; +struct rte_sched_subport_profile *sp;struct rte_sched_pipe *p;struct rte_sched_pipe_profile *params;uint32_t n_subports = subport_id +1 ;
@@ -1331,14 +1333,16 @@ rte_sched_pipe_config(struct rte_sched_port *port,return -EINVAL ; } + sp = port->subport_profiles + s->profile; +/* Handle the case when pipe already has a valid configuration */ p = s->pipe + pipe_id;if (p->tb_time) { params = s->pipe_profiles + p->profile;double subport_tc_be_rate = - (double ) s->tc_credits_per_period[RTE_SCHED_TRAFFIC_CLASS_BE ] - / (double ) s->tc_period; + (double ) sp->tc_credits_per_period[RTE_SCHED_TRAFFIC_CLASS_BE ] + / (double ) sp->tc_period;double pipe_tc_be_rate = (double ) params->tc_credits_per_period[RTE_SCHED_TRAFFIC_CLASS_BE ] / (double ) params->tc_period;
@@ -1380,8 +1384,8 @@ rte_sched_pipe_config(struct rte_sched_port *port, {/* Subport best effort tc oversubscription */ double subport_tc_be_rate = - (double ) s->tc_credits_per_period[RTE_SCHED_TRAFFIC_CLASS_BE ] - / (double ) s->tc_period; + (double ) sp->tc_credits_per_period[RTE_SCHED_TRAFFIC_CLASS_BE ] + / (double ) sp->tc_period;double pipe_tc_be_rate = (double ) params->tc_credits_per_period[RTE_SCHED_TRAFFIC_CLASS_BE ] / (double ) params->tc_period;
@@ -1393,8 +1397,9 @@ rte_sched_pipe_config(struct rte_sched_port *port,if (s->tc_ov != tc_be_ov) {RTE_LOG (DEBUG ,SCHED , -"Subport %u Best effort TC oversubscription is ON (%.4lf < %.4lf)\n" , - subport_id, subport_tc_be_rate, s->tc_ov_rate); +"Subport %u Best effort TC oversubscription is ON " +"(%.4lf < %.4lf)\n" , + subport_id, subport_tc_be_rate, s->tc_ov_rate); } p->tc_ov_period_id = s->tc_ov_period_id; p->tc_ov_credits = s->tc_ov_wm;
@@ -2168,14 +2173,18 @@ grinder_credits_update(struct rte_sched_port *port,struct rte_sched_grinder *grinder = subport->grinder + pos;struct rte_sched_pipe *pipe = grinder->pipe;struct rte_sched_pipe_profile *params = grinder->pipe_params; +struct rte_sched_subport_profile *subport_params = + grinder->subport_params;uint64_t n_periods;uint32_t i;/* Subport TB */ - n_periods = (port->time - subport->tb_time) / subport->tb_period; - subport->tb_credits += n_periods * subport->tb_credits_per_period; - subport->tb_credits =RTE_MIN (subport->tb_credits, subport->tb_size); - subport->tb_time += n_periods * subport->tb_period; + n_periods = (port->time - subport->tb_time) / subport_params->tb_period; + subport->tb_credits += n_periods * + subport_params->tb_credits_per_period; + subport->tb_credits =RTE_MIN (subport->tb_credits, + subport_params->tb_size); + subport->tb_time += n_periods * subport_params->tb_period;/* Pipe TB */ n_periods = (port->time - pipe->tb_time) / params->tb_period;
@@ -2186,9 +2195,10 @@ grinder_credits_update(struct rte_sched_port *port,/* Subport TCs */ if (unlikely (port->time >= subport->tc_time)) {for (i =0 ; i <RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE ; i++) - subport->tc_credits[i] = subport->tc_credits_per_period[i]; + subport->tc_credits[i] = + subport_params->tc_credits_per_period[i]; - subport->tc_time = port->time + subport->tc_period; + subport->tc_time = port->time + subport_params->tc_period; }/* Pipe TCs */
@@ -2206,6 +2216,8 @@ static inline uint64_t grinder_tc_ov_credits_update(struct rte_sched_port *port, struct rte_sched_subport *subport) { + struct rte_sched_subport_profile *subport_params = + grinder->subport_params;uint64_t tc_ov_consumption[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE ];uint64_t tc_consumption =0 , tc_ov_consumption_max;uint64_t tc_ov_wm = subport->tc_ov_wm;
@@ -2216,16 +2228,17 @@ grinder_tc_ov_credits_update(struct rte_sched_port *port,for (i =0 ; i <RTE_SCHED_TRAFFIC_CLASS_BE ; i++) { tc_ov_consumption[i] = - subport->tc_credits_per_period[i] - subport->tc_credits[i]; + subport_params->tc_credits_per_period[i] - + subport->tc_credits[i]; tc_consumption += tc_ov_consumption[i]; } tc_ov_consumption[RTE_SCHED_TRAFFIC_CLASS_BE ] = - subport->tc_credits_per_period[RTE_SCHED_TRAFFIC_CLASS_BE ] - + subport_params->tc_credits_per_period[RTE_SCHED_TRAFFIC_CLASS_BE ] - subport->tc_credits[RTE_SCHED_TRAFFIC_CLASS_BE ]; tc_ov_consumption_max = - subport->tc_credits_per_period[RTE_SCHED_TRAFFIC_CLASS_BE ] - + subport_params->tc_credits_per_period[RTE_SCHED_TRAFFIC_CLASS_BE ] - tc_consumption; if (tc_ov_consumption[RTE_SCHED_TRAFFIC_CLASS_BE] >
@@ -2251,14 +2264,18 @@ grinder_credits_update(struct rte_sched_port *port,struct rte_sched_grinder *grinder = subport->grinder + pos;struct rte_sched_pipe *pipe = grinder->pipe;struct rte_sched_pipe_profile *params = grinder->pipe_params; +struct rte_sched_subport_profile *subport_params = + grinder->subport_params;uint64_t n_periods;uint32_t i;/* Subport TB */ - n_periods = (port->time - subport->tb_time) / subport->tb_period; - subport->tb_credits += n_periods * subport->tb_credits_per_period; - subport->tb_credits =RTE_MIN (subport->tb_credits, subport->tb_size); - subport->tb_time += n_periods * subport->tb_period; + n_periods = (port->time - subport->tb_time) / subport_params->tb_period; + subport->tb_credits += n_periods * + subport_params->tb_credits_per_period; + subport->tb_credits =RTE_MIN (subport->tb_credits, + subport_params->tb_size); + subport->tb_time += n_periods * subport_params->tb_period;/* Pipe TB */ n_periods = (port->time - pipe->tb_time) / params->tb_period;
@@ -2271,9 +2288,10 @@ grinder_credits_update(struct rte_sched_port *port, subport->tc_ov_wm =grinder_tc_ov_credits_update (port, subport);for (i =0 ; i <RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE ; i++) - subport->tc_credits[i] = subport->tc_credits_per_period[i]; + subport->tc_credits[i] = + subport_params->tc_credits_per_period[i]; - subport->tc_time = port->time + subport->tc_period; + subport->tc_time = port->time + subport_params->tc_period; subport->tc_ov_period_id++; }
@@ -2796,6 +2814,8 @@ grinder_handle(struct rte_sched_port *port,struct rte_sched_pipe *pipe = grinder->pipe; grinder->pipe_params = subport->pipe_profiles + pipe->profile; + grinder->subport_params = port->subport_profiles + + subport->profile;grinder_prefetch_tc_queue_arrays (subport, pos);grinder_credits_update (port, subport, pos);
lib/librte_sched/rte_sched_version.map +2 -0
@@ -28,4 +28,6 @@ EXPERIMENTAL { global: rte_sched_subport_pipe_profile_add; + rte_sched_port_subport_profile_add; + rte_sched_subport_profile_config; };
Signature · 1 line
2.7.4
v2 cover Enable dynamic config of subport bandwidth
In reply to Savinay DharmappaDPDK sched library allows runtime configuration of the pipe profiles to the pipes of the subport once scheduler hierarchy is constructed. However, to change the subport level bandwidth, existing hierarchy needs to be dismantled and whole process of building hierarchy under subport nodes needs to be repeated which might result in router downtime. Furthermore, due to lack of dynamic configuration of the subport bandwidth profile configuration (shaper and Traffic class rates), the user application is unable to dynamically re-distribute the excess-bandwidth of one subport among other subports in the scheduler hierarchy. Therefore, it is also not possible to adjust the subport bandwidth profile in sync with dynamic changes in pipe profiles of subscribers who want to consume higher bandwidth opportunistically.
This patch series implements dynamic configuration of the subport bandwidth profile to overcome the runtime situation when group of subscribers are not using the allotted bandwidth and dynamic bandwidth re-distribution is needed the without making any structural changes in the hierarchy.
The implementation work includes refactoring the existing data structures defined for port and subport level, new APIs for adding subport level bandwidth profiles that can be used in runtime.
Savinay Dharmappa (10):
sched: add data structure to support dynamic conf of subport bandwidth
sched: create subport profile table
sched: Add public APIs to support dynamic conf of subport profile
sched: modify the way credits are updated
sched: Modify subport best effort tc oversubscription example/qos_sched: add dynamic config of subport example/ip_pipeline: add dynamic config of subport drivers/softnic: add dynamic config of subport app/test_sched: add dynamic config of subport
sched: remove the redundant code
app/test/test_sched.c | 18 +- doc/guides/rel_notes/deprecation.rst | 6 - doc/guides/rel_notes/release_20_11.rst | 4 + drivers/net/softnic/rte_eth_softnic_internals.h | 9 + drivers/net/softnic/rte_eth_softnic_tm.c | 223 ++++++++--- examples/ip_pipeline/cli.c | 10 +- examples/ip_pipeline/tmgr.c | 28 +- examples/ip_pipeline/tmgr.h | 3 +- examples/qos_sched/cfg_file.c | 158 ++++---- examples/qos_sched/cfg_file.h | 4 + examples/qos_sched/init.c | 24 +- examples/qos_sched/main.h | 1 + examples/qos_sched/profile.cfg | 3 + lib/librte_sched/rte_sched.c | 484 +++++++++++++++++------- lib/librte_sched/rte_sched.h | 82 +++- lib/librte_sched/rte_sched_version.map | 2 + 16 files changed, 780 insertions(+), 279 deletions(-)
Signature · 1 line
2.7.4
PATCH v2 1/10 sched: add support profile data structure
Add subport profile data structure to support dynamic configuration of subport bandwidth
--- lib/librte_sched/rte_sched.c | 11 +++++++++++ lib/librte_sched/rte_sched.h | 25 +++++++++++++++++++++++++ 2 files changed, 36 insertions(+)
lib/librte_sched/rte_sched.c +11 -0
@@ -2,6 +2,7 @@* Copyright(c) 2010-2014 Intel Corporation */ +#include <stdint.h> #include <stdio.h> #include <string.h>
@@ -101,6 +102,16 @@ enum grinder_state {e_GRINDER_READ_MBUF }; +struct rte_sched_subport_profile { +/* Token bucket (TB) */ +uint64_t tb_period; +uint64_t tb_credits_per_period; +uint64_t tb_size; + +uint64_t tc_credits_per_period[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE ]; +uint64_t tc_period; +}; +struct rte_sched_grinder {/* Pipe cache */ uint16_t pcache_qmask[RTE_SCHED_GRINDER_PCACHE_SIZE ];
lib/librte_sched/rte_sched.h +25 -0
@@ -192,6 +192,20 @@ struct rte_sched_subport_params {#endif }; +struct rte_sched_subport_profile_params { +/** Token bucket rate (measured in bytes per second) */ +uint64_t tb_rate; + +/** Token bucket size (measured in credits) */ +uint64_t tb_size; + +/** Traffic class rates (measured in bytes per second) */ +uint64_t tc_rate[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE ]; + +/** Enforcement period for rates (measured in milliseconds) */ +uint64_t tc_period; +}; +/** Subport statistics */ struct rte_sched_subport_stats {/** Number of packets successfully written */
@@ -254,6 +268,17 @@ struct rte_sched_port_params {/** Number of subports */ uint32_t n_subports_per_port; +/** subport profile table. +* Every pipe is configured using one of the profiles from this table. +*/ +struct rte_sched_subport_profile_params *subport_profiles; + +/** Profiles in the pipe profile table */ +uint32_t n_subport_profiles; + +/** Max allowed profiles in the pipe profile table */ +uint32_t n_max_subport_profiles; +/** Maximum number of subport pipes. * This parameter is used to reserve a fixed number of bits * in struct rte_mbuf::sched.queue_id for the pipe_id for all
Signature · 1 line
2.7.4
PATCH v2 2/10 sched: add subport profile table
In reply to Savinay DharmappaAdd subport profile table to internal port data structure and update the port config function.
--- lib/librte_sched/rte_sched.c | 185 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 182 insertions(+), 3 deletions(-)
lib/librte_sched/rte_sched.c +182 -3
@@ -223,6 +223,8 @@ struct rte_sched_port {uint16_t pipe_queue[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE ];uint8_t pipe_tc[RTE_SCHED_QUEUES_PER_PIPE ];uint8_t tc_queue[RTE_SCHED_QUEUES_PER_PIPE ]; +uint32_t n_subport_profiles; +uint32_t n_max_subport_profiles;uint64_t rate;uint32_t mtu;uint32_t frame_overhead;
@@ -241,6 +243,7 @@ struct rte_sched_port {uint32_t subport_id;/* Large data structures */ +struct rte_sched_subport_profile *subport_profiles; struct rte_sched_subport *subports[0] __rte_cache_aligned; } __rte_cache_aligned;
@@ -387,8 +390,60 @@ pipe_profile_check(struct rte_sched_pipe_params *params, }static int +subport_profile_check (struct rte_sched_subport_profile_params *params, +uint64_t rate) +{ +uint32_t i; + +/* Check user parameters */ +if (params ==NULL ) { +RTE_LOG (ERR ,SCHED ,"%s: " +"Incorrect value for parameter params\n" , __func__); +return -EINVAL ; + } + +if (params->tb_rate ==0 || params->tb_rate > rate) { +RTE_LOG (ERR ,SCHED ,"%s: " +"Incorrect value for tb rate\n" , __func__); +return -EINVAL ; + } + +if (params->tb_size ==0 ) { +RTE_LOG (ERR ,SCHED ,"%s: " +"Incorrect value for tb size\n" , __func__); +return -EINVAL ; + } + +for (i =0 ; i <RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE ; i++) { +uint64_t tc_rate = params->tc_rate[i]; + +if (tc_rate ==0 || (tc_rate > params->tb_rate)) { +RTE_LOG (ERR ,SCHED ,"%s: " +"Incorrect value for tc rate\n" , __func__); +return -EINVAL ; + } + } + +if (params->tc_rate[RTE_SCHED_TRAFFIC_CLASS_BE ] ==0 ) { +RTE_LOG (ERR ,SCHED ,"%s: " +"Incorrect tc rate(best effort)\n" , __func__); +return -EINVAL ; + } + +if (params->tc_period ==0 ) { +RTE_LOG (ERR ,SCHED ,"%s: " +"Incorrect value for tc period\n" , __func__); +return -EINVAL ; + } + +return 0 ; +} + +static int rte_sched_port_check_params (struct rte_sched_port_params *params) { +uint32_t i; +if (params ==NULL ) {RTE_LOG (ERR ,SCHED ,"%s: Incorrect value for parameter params\n" , __func__);
@@ -425,6 +480,29 @@ rte_sched_port_check_params(struct rte_sched_port_params *params)return -EINVAL ; } +if (params->subport_profiles ==NULL || + params->n_subport_profiles ==0 || + params->n_max_subport_profiles ==0 || + params->n_subport_profiles > params->n_max_subport_profiles) { +RTE_LOG (ERR ,SCHED , +"%s: Incorrect value for subport profiles\n" , __func__); +return -EINVAL ; + } + +for (i =0 ; i < params->n_subport_profiles; i++) { +struct rte_sched_subport_profile_params *p = + params->subport_profiles + i; +int status; + + status =subport_profile_check (p, params->rate); +if (status !=0 ) { +RTE_LOG (ERR ,SCHED , +"%s: subport profile check failed(%d)\n" , + __func__, status); +return -EINVAL ; + } + } +/* n_pipes_per_subport: non-zero, power of 2 */ if (params->n_pipes_per_subport ==0 || !rte_is_power_of_2 (params->n_pipes_per_subport)) {
@@ -566,6 +644,42 @@ rte_sched_port_log_pipe_profile(struct rte_sched_subport *subport, uint32_t i) p->wrr_cost[0], p->wrr_cost[1], p->wrr_cost[2], p->wrr_cost[3]); } +static void +rte_sched_port_log_subport_profile (struct rte_sched_port *port,uint32_t i) +{ +struct rte_sched_subport_profile *p = port->subport_profiles + i; + +RTE_LOG (DEBUG ,SCHED ,"Low level config for subport profile %u:\n" +"Token bucket: period = %" PRIu64", credits per period = %" PRIu64"," +"size = %" PRIu64"\n" +"Traffic classes: period = %" PRIu64",\n" +"credits per period = [%" PRIu64", %" PRIu64", %" PRIu64", %" PRIu64 +" %" PRIu64", %" PRIu64", %" PRIu64", %" PRIu64", %" PRIu64", %" PRIu64 +" %" PRIu64", %" PRIu64", %" PRIu64"]\n" , + i, + +/* Token bucket */ + p->tb_period, + p->tb_credits_per_period, + p->tb_size, + +/* Traffic classes */ + p->tc_period, + p->tc_credits_per_period[0 ], + p->tc_credits_per_period[1 ], + p->tc_credits_per_period[2 ], + p->tc_credits_per_period[3 ], + p->tc_credits_per_period[4 ], + p->tc_credits_per_period[5 ], + p->tc_credits_per_period[6 ], + p->tc_credits_per_period[7 ], + p->tc_credits_per_period[8 ], + p->tc_credits_per_period[9 ], + p->tc_credits_per_period[10 ], + p->tc_credits_per_period[11 ], + p->tc_credits_per_period[12 ]); +} +static inline uint64_t rte_sched_time_ms_to_bytes (uint64_t time_ms,uint64_t rate) {
@@ -635,6 +749,37 @@ rte_sched_pipe_profile_convert(struct rte_sched_subport *subport, }static void +rte_sched_subport_profile_convert (struct rte_sched_subport_profile_params *src, +struct rte_sched_subport_profile *dst, +uint64_t rate) +{ +uint32_t i; + +/* Token Bucket */ +if (src->tb_rate == rate) { + dst->tb_credits_per_period =1 ; + dst->tb_period =1 ; + }else { +double tb_rate = (double ) src->tb_rate + / (double ) rate; +double d =RTE_SCHED_TB_RATE_CONFIG_ERR ; + +rte_approx_64 (tb_rate, d, &dst->tb_credits_per_period, + &dst->tb_period); + } + + dst->tb_size = src->tb_size; + +/* Traffic Classes */ + dst->tc_period =rte_sched_time_ms_to_bytes (src->tc_period, rate); + +for (i =0 ; i <RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE ; i++) + dst->tc_credits_per_period[i] + =rte_sched_time_ms_to_bytes (src->tc_period, + src->tc_rate[i]); +} + +static void rte_sched_subport_config_pipe_profile_table (struct rte_sched_subport *subport,struct rte_sched_subport_params *params,uint64_t rate) {
@@ -658,6 +803,24 @@ rte_sched_subport_config_pipe_profile_table(struct rte_sched_subport *subport, } } +static void +rte_sched_port_config_subport_profile_table (struct rte_sched_port *port, +struct rte_sched_port_params *params, +uint64_t rate) +{ +uint32_t i; + +for (i =0 ; i < port->n_subport_profiles; i++) { +struct rte_sched_subport_profile_params *src + = params->subport_profiles + i; +struct rte_sched_subport_profile *dst + = port->subport_profiles + i; + +rte_sched_subport_profile_convert (src, dst, rate); +rte_sched_port_log_subport_profile (port, i); + } +} + static int rte_sched_subport_check_params(struct rte_sched_subport_params *params, uint32_t n_max_pipes_per_subport,
@@ -804,7 +967,7 @@ struct rte_sched_port * rte_sched_port_config(struct rte_sched_port_params *params) {struct rte_sched_port *port =NULL ; -uint32_t size0, size1; +uint32_t size0, size1, size2;uint32_t cycles_per_byte;uint32_t i, j;int status;
@@ -819,10 +982,21 @@ rte_sched_port_config(struct rte_sched_port_params *params) size0 =sizeof (struct rte_sched_port ); size1 = params->n_subports_per_port *sizeof (struct rte_sched_subport *); + size2 = params->n_max_subport_profiles * +sizeof (struct rte_sched_subport_profile );/* Allocate memory to store the data structures */ - port =rte_zmalloc_socket ("qos_params" , size0 + size1,RTE_CACHE_LINE_SIZE , - params->socket); + port =rte_zmalloc_socket ("qos_params" , size0 + size1, +RTE_CACHE_LINE_SIZE , params->socket); +if (port ==NULL ) { +RTE_LOG (ERR ,SCHED ,"%s: Memory allocation fails\n" , __func__); + +return NULL ; + } + +/* Allocate memory to store the subport profile */ + port->subport_profiles =rte_zmalloc_socket ("subport_profile" , size2, +RTE_CACHE_LINE_SIZE , params->socket);if (port ==NULL ) {RTE_LOG (ERR ,SCHED ,"%s: Memory allocation fails\n" , __func__);
@@ -831,6 +1005,8 @@ rte_sched_port_config(struct rte_sched_port_params *params)/* User parameters */ port->n_subports_per_port = params->n_subports_per_port; + port->n_subport_profiles = params->n_subport_profiles; + port->n_max_subport_profiles = params->n_max_subport_profiles; port->n_pipes_per_subport = params->n_pipes_per_subport; port->n_pipes_per_subport_log2 =__builtin_ctz (params->n_pipes_per_subport);
@@ -861,6 +1037,9 @@ rte_sched_port_config(struct rte_sched_port_params *params) port->time_cpu_bytes =0 ; port->time =0 ; +/* Subport profile table */ +rte_sched_port_config_subport_profile_table (port, params, port->rate); + cycles_per_byte = (rte_get_tsc_hz () <<RTE_SCHED_TIME_SHIFT ) / params->rate; port->inv_cycles_per_byte =rte_reciprocal_value (cycles_per_byte);
Signature · 1 line
2.7.4
PATCH v2 3/10 sched: add subport profile add and config api
In reply to Savinay DharmappaAdd apis to add new subport profile and configure it.
--- lib/librte_sched/rte_sched.c | 118 +++++++++++++++++++++++++++++++++ lib/librte_sched/rte_sched.h | 45 +++++++++++++ lib/librte_sched/rte_sched_version.map | 2 + 3 files changed, 165 insertions(+)
lib/librte_sched/rte_sched.c +118 -0
@@ -175,6 +175,8 @@ struct rte_sched_subport {/* Statistics */ struct rte_sched_subport_stats stats __rte_cache_aligned; +/* subport profile flag */ +uint32_t profile;/* Subport pipes */ uint32_t n_pipes_per_subport_enabled;uint32_t n_pipe_profiles;
@@ -1344,6 +1346,56 @@ rte_sched_subport_config(struct rte_sched_port *port, }int +rte_sched_subport_profile_config (struct rte_sched_port *port, +uint32_t subport_id, +uint32_t profile_id) +{ +int i; +struct rte_sched_subport_profile *params; +uint32_t n_subports = subport_id +1 ; +struct rte_sched_subport *s; + +if (port ==NULL ) { +RTE_LOG (ERR ,SCHED , +"%s: Incorrect value for parameter port\n" , __func__); +return -EINVAL ; + } + +if (subport_id >= port->n_subports_per_port) { +RTE_LOG (ERR ,SCHED ,"%s: " +"Incorrect value for parameter subport id\n" , __func__); + +rte_sched_free_memory (port, n_subports); +return -EINVAL ; + } + + params = port->subport_profiles + profile_id; + + s = port->subports[subport_id]; + + s->tb_credits = params->tb_size /2 ; + + s->tc_time = port->time + params->tc_period; + +for (i =0 ; i <RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE ; i++) +if (s->qsize[i]) + s->tc_credits[i] = + params->tc_credits_per_period[i]; +else + params->tc_credits_per_period[i] =0 ; + +#ifdef RTE_SCHED_SUBPORT_TC_OV + s->tc_ov_wm_max =rte_sched_time_ms_to_bytes (params->tc_period, + s->pipe_tc_be_rate_max); +#endif + s->profile = profile_id; + +rte_sched_port_log_subport_profile (port, profile_id); + +return 0 ; +} + +int rte_sched_pipe_config(struct rte_sched_port *port, uint32_t subport_id, uint32_t pipe_id,
@@ -1527,6 +1579,72 @@ rte_sched_subport_pipe_profile_add(struct rte_sched_port *port,return 0 ; } +int +rte_sched_port_subport_profile_add (struct rte_sched_port *port, +struct rte_sched_subport_profile_params *params, +uint32_t *subport_profile_id) +{ +int status; +uint32_t i; +struct rte_sched_subport_profile *dst; + +/* Port */ +if (port ==NULL ) { +RTE_LOG (ERR ,SCHED ,"%s: " +"Incorrect value for parameter port\n" , __func__); +return -EINVAL ; + } + +if (params ==NULL ) { +RTE_LOG (ERR ,SCHED ,"%s: " +"Incorrect value for parameter profile\n" , __func__); +return -EINVAL ; + } + +if (subport_profile_id ==NULL ) { +RTE_LOG (ERR ,SCHED ,"%s: " +"Incorrect value for parameter subport_profile_id\n" , + __func__); +return -EINVAL ; + } + + dst = port->subport_profiles + port->n_subport_profiles; + +/* Subport profiles exceeds the max limit */ +if (port->n_subport_profiles >= port->n_max_subport_profiles) { +RTE_LOG (ERR ,SCHED ,"%s: " +"Number of subport profiles exceeds the max limit\n" , + __func__); +return -EINVAL ; + } + + status =subport_profile_check (params, port->rate); +if (status !=0 ) { +RTE_LOG (ERR ,SCHED , +"%s: subport profile check failed(%d)\n" , __func__, status); +return -EINVAL ; + } + +rte_sched_subport_profile_convert (params, dst, port->rate); + +/* Subport profile should not exists */ +for (i =0 ; i < port->n_subport_profiles; i++) +if (memcmp (port->subport_profiles + i, + params,sizeof (*params)) ==0 ) { +RTE_LOG (ERR ,SCHED , +"%s: subport profile exists\n" , __func__); +return -EINVAL ; + } + +/* Subport profile commit */ + *subport_profile_id = port->n_subport_profiles; + port->n_subport_profiles++; + +rte_sched_port_log_subport_profile (port, *subport_profile_id); + +return 0 ; +} + static inline uint32_t rte_sched_port_qindex(struct rte_sched_port *port, uint32_t subport,
lib/librte_sched/rte_sched.h +45 -0
57 lines not on this page · raw message
lib/librte_sched/rte_sched_version.map +2 -0
@@ -28,4 +28,6 @@ EXPERIMENTAL { global: rte_sched_subport_pipe_profile_add; + rte_sched_port_subport_profile_add; + rte_sched_subport_profile_config; };
Signature · 1 line
2.7.4
Re: [dpdk-dev] [PATCH v2 03/10] sched: add subport profile add and config api
Quoted 145 lines
-----Original Message-----
From: Dharmappa, Savinay <[email protected]>
Sent: Thursday, September 10, 2020 7:49 PM
To: Singh, Jasvinder <[email protected]>; Dumitrescu, Cristian <[email protected]>; [email protected]
Cc: Dharmappa, Savinay <[email protected]>
Subject: [PATCH v2 03/10] sched: add subport profile add and config apiAdd apis to add new subport profile and configure it.
Signed-off-by Savinay Dharmappa <[email protected]>Signed-off-by Jasvinder Singh <[email protected]>--- lib/librte_sched/rte_sched.c | 118 +++++++++++++++++++++++++++++++++ lib/librte_sched/rte_sched.h | 45 +++++++++++++ lib/librte_sched/rte_sched_version.map | 2 + 3 files changed, 165 insertions(+)lib/librte_sched/rte_sched.c index renamed from lib/librte_sched/rte_sched.c +0
-0ec6e6bf..ba5700a 100644
lib/librte_sched/rte_sched.c +52
-0@@ -175,6 +175,8 @@ struct rte_sched_subport {/* Statistics */ struct rte_sched_subport_stats stats __rte_cache_aligned; +/* subport profile flag */ +uint32_t profile;/* Subport pipes */ uint32_t n_pipes_per_subport_enabled;uint32_t n_pipe_profiles;@@ -1344,6 +1346,56 @@ rte_sched_subport_config(struct rte_sched_port *port, }int +rte_sched_subport_profile_config (struct rte_sched_port *port, +uint32_t subport_id, +uint32_t profile_id) +{ +int i; +struct rte_sched_subport_profile *params; +uint32_t n_subports = subport_id +1 ; +struct rte_sched_subport *s; + +if (port ==NULL ) { +RTE_LOG (ERR ,SCHED , +"%s: Incorrect value for parameter port\n" , __func__); +return -EINVAL ; + } + +if (subport_id >= port->n_subports_per_port) { +RTE_LOG (ERR ,SCHED ,"%s: " +"Incorrect value for parameter subport id\n" , __func__); + +rte_sched_free_memory (port, n_subports); +return -EINVAL ; + } + + params = port->subport_profiles + profile_id; + + s = port->subports[subport_id]; + + s->tb_credits = params->tb_size /2 ; + + s->tc_time = port->time + params->tc_period; + +for (i =0 ; i <RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE ; i++) +if (s->qsize[i]) + s->tc_credits[i] = + params->tc_credits_per_period[i]; +else + params->tc_credits_per_period[i] =0 ; + +#ifdef RTE_SCHED_SUBPORT_TC_OV + s->tc_ov_wm_max =rte_sched_time_ms_to_bytes (params- >tc_period, + s->pipe_tc_be_rate_max); +#endif + s->profile = profile_id; + +rte_sched_port_log_subport_profile (port, profile_id); + +return 0 ; +} + +int rte_sched_pipe_config(struct rte_sched_port *port,lib/librte_sched/rte_sched.c +47
-0uint32_t subport_id, uint32_t pipe_id,@@ -1527,6 +1579,72 @@ rte_sched_subport_pipe_profile_add(structrte_sched_port *port, return 0; } +int +rte_sched_port_subport_profile_add (struct rte_sched_port *port, +struct rte_sched_subport_profile_params *params, +uint32_t *subport_profile_id) +{ +int status; +uint32_t i; +struct rte_sched_subport_profile *dst; + +/* Port */ +if (port ==NULL ) { +RTE_LOG (ERR ,SCHED ,"%s: " +"Incorrect value for parameter port\n" , __func__); +return -EINVAL ; + } + +if (params ==NULL ) { +RTE_LOG (ERR ,SCHED ,"%s: " +"Incorrect value for parameter profile\n" , __func__); +return -EINVAL ; + } + +if (subport_profile_id ==NULL ) { +RTE_LOG (ERR ,SCHED ,"%s: " +"Incorrect value for parameter subport_profile_id\n" , + __func__); +return -EINVAL ; + } + + dst = port->subport_profiles + port->n_subport_profiles; + +/* Subport profiles exceeds the max limit */ +if (port->n_subport_profiles >= port->n_max_subport_profiles) { +RTE_LOG (ERR ,SCHED ,"%s: " +"Number of subport profiles exceeds the max limit\n" , + __func__); +return -EINVAL ; + } + + status =subport_profile_check (params, port->rate); +if (status !=0 ) { +RTE_LOG (ERR ,SCHED , +"%s: subport profile check failed(%d)\n" , __func__, status); +return -EINVAL ; + } + +rte_sched_subport_profile_convert (params, dst, port->rate);
lib/librte_sched/rte_sched.c rte_sched_subport_pipe_profile_add(struct · line 1639
Quoted 10 lines
lib/librte_sched/rte_sched.c +10
-0+ +/* Subport profile should not exists */ +for (i =0 ; i < port->n_subport_profiles; i++) +if (memcmp (port->subport_profiles + i, + params,sizeof (*params)) ==0 ) { +RTE_LOG (ERR ,SCHED , +"%s: subport profile exists\n" , __func__); +return -EINVAL ; + } +
Savinay, Comparing port->subport_profiles with params is wrong as they are different structures, need to compare port->subport_profiles with dst.
Quoted 94 lines
lib/librte_sched/rte_sched.c +9
-0+/* Subport profile commit */ + *subport_profile_id = port->n_subport_profiles; + port->n_subport_profiles++; + +rte_sched_port_log_subport_profile (port, *subport_profile_id); + +return 0 ; +} + static inline uint32_t rte_sched_port_qindex(struct rte_sched_port *port,lib/librte_sched/rte_sched.c +0
-0uint32_t subport,lib/librte_sched/rte_sched.h index renamed from lib/librte_sched/rte_sched.h +0
-039339b7..a7c2638 100644
lib/librte_sched/rte_sched.h +48
-0@@ -337,6 +337,29 @@ rte_sched_subport_pipe_profile_add(struct rte_sched_port *port, uint32_t *pipe_profile_id);/** +* @warning +* @b EXPERIMENTAL: this API may change without prior notice. +* +* Hierarchical scheduler subport bandwidth profile add +* Note that this function is safe to use in runtime for adding new +* subport bandwidth profile as it doesn't have any impact on +hiearchical +* structure of the scheduler. +* @param port +* Handle to port scheduler instance +* @param struct rte_sched_subport_profile +* Subport bandwidth profile +* @param subport_profile_d +* Subport profile id +* @return +* 0 upon success, error code otherwise +*/ +__rte_experimental +int +rte_sched_port_subport_profile_add (struct rte_sched_port *port, +struct rte_sched_subport_profile_params *profile, +uint32_t *subport_profile_id); + +/** * Hierarchical scheduler subport configuration * * @param port @@ -354,6 +377,28 @@ rte_sched_subport_config(struct rte_sched_port *port, struct rte_sched_subport_params *params);/** +* @warning +* @b EXPERIMENTAL: this API may change without prior notice. +* +* Hierarchical scheduler subport profile configuration +* Note that this function is safe to use in runtime for applying any +specific +* subport bandwidth profile as it doesn't have any impact on +hiearchical +* structure of the scheduler. +* @param port +* Handle to port scheduler instance +* @param subport_id +* Subport ID +* @param profile_d +* Subport profile id +* @return +* 0 upon success, error code otherwise +*/ +__rte_experimental +int +rte_sched_subport_profile_config (struct rte_sched_port *port, +uint32_t subport_id, +uint32_t profile_id); +/** * Hierarchical scheduler pipe configuration * * @param port lib/librte_sched/rte_sched_version.map +2
-1@@ -28,4 +28,6 @@ EXPERIMENTAL { global: rte_sched_subport_pipe_profile_add; + rte_sched_port_subport_profile_add; + rte_sched_subport_profile_config; }; --2.7.4
PATCH v2 4/10 sched: update the grinder credit update function
In reply to Savinay DharmappaCredits are updated by fetching subport profile parameters from subport profile table.
--- lib/librte_sched/rte_sched.c | 49 ++++++++++++++++++++++++++++---------------- 1 file changed, 31 insertions(+), 18 deletions(-)
lib/librte_sched/rte_sched.c +31 -18
@@ -124,6 +124,7 @@ struct rte_sched_grinder {uint32_t productive;uint32_t pindex;struct rte_sched_subport *subport; +struct rte_sched_subport_profile *subport_params;struct rte_sched_pipe *pipe;struct rte_sched_pipe_profile *pipe_params;
@@ -2280,14 +2281,16 @@ grinder_credits_update(struct rte_sched_port *port,struct rte_sched_grinder *grinder = subport->grinder + pos;struct rte_sched_pipe *pipe = grinder->pipe;struct rte_sched_pipe_profile *params = grinder->pipe_params; +struct rte_sched_subport_profile *sp_params = grinder->subport_params;uint64_t n_periods;uint32_t i;/* Subport TB */ - n_periods = (port->time - subport->tb_time) / subport->tb_period; - subport->tb_credits += n_periods * subport->tb_credits_per_period; - subport->tb_credits =RTE_MIN (subport->tb_credits, subport->tb_size); - subport->tb_time += n_periods * subport->tb_period; + n_periods = (port->time - subport->tb_time) / sp_params->sp_tb_period; + subport->tb_credits += n_periods * sp_params->sp_tb_credits_per_period; + subport->tb_credits =RTE_MIN (subport->tb_credits, + sp_params->sp_tb_size); + subport->tb_time += n_periods * sp_params->sp_tb_period;/* Pipe TB */ n_periods = (port->time - pipe->tb_time) / params->tb_period;
@@ -2298,9 +2301,10 @@ grinder_credits_update(struct rte_sched_port *port,/* Subport TCs */ if (unlikely (port->time >= subport->tc_time)) {for (i =0 ; i <RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE ; i++) - subport->tc_credits[i] = subport->tc_credits_per_period[i]; + subport->tc_credits[i] = + sp_params->sp_tc_credits_per_period[i]; - subport->tc_time = port->time + subport->tc_period; + subport->tc_time = port->time + sp_params->sp_tc_period; }/* Pipe TCs */
@@ -2316,8 +2320,10 @@ grinder_credits_update(struct rte_sched_port *port,static inline uint64_t grinder_tc_ov_credits_update (struct rte_sched_port *port, -struct rte_sched_subport *subport) +struct rte_sched_subport *subport,uint32_t pos) { +struct rte_sched_grinder *grinder = subport->grinder + pos; +struct rte_sched_subport_profile *sp_params = grinder->subport_params;uint64_t tc_ov_consumption[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE ];uint64_t tc_consumption =0 , tc_ov_consumption_max;uint64_t tc_ov_wm = subport->tc_ov_wm;
@@ -2327,17 +2333,17 @@ grinder_tc_ov_credits_update(struct rte_sched_port *port,return subport->tc_ov_wm_max;for (i =0 ; i <RTE_SCHED_TRAFFIC_CLASS_BE ; i++) { - tc_ov_consumption[i] = - subport->tc_credits_per_period[i] - subport->tc_credits[i]; + tc_ov_consumption[i] = sp_params->sp_tc_credits_per_period[i] + - subport->tc_credits[i]; tc_consumption += tc_ov_consumption[i]; } tc_ov_consumption[RTE_SCHED_TRAFFIC_CLASS_BE ] = - subport->tc_credits_per_period[RTE_SCHED_TRAFFIC_CLASS_BE ] - + sp_params->sp_tc_credits_per_period[RTE_SCHED_TRAFFIC_CLASS_BE ] - subport->tc_credits[RTE_SCHED_TRAFFIC_CLASS_BE ]; tc_ov_consumption_max = - subport->tc_credits_per_period[RTE_SCHED_TRAFFIC_CLASS_BE ] - + sp_params->sp_tc_credits_per_period[RTE_SCHED_TRAFFIC_CLASS_BE ] - tc_consumption; if (tc_ov_consumption[RTE_SCHED_TRAFFIC_CLASS_BE] >
@@ -2363,14 +2369,16 @@ grinder_credits_update(struct rte_sched_port *port,struct rte_sched_grinder *grinder = subport->grinder + pos;struct rte_sched_pipe *pipe = grinder->pipe;struct rte_sched_pipe_profile *params = grinder->pipe_params; +struct rte_sched_subport_profile *sp_params = grinder->subport_params;uint64_t n_periods;uint32_t i;/* Subport TB */ - n_periods = (port->time - subport->tb_time) / subport->tb_period; - subport->tb_credits += n_periods * subport->tb_credits_per_period; - subport->tb_credits =RTE_MIN (subport->tb_credits, subport->tb_size); - subport->tb_time += n_periods * subport->tb_period; + n_periods = (port->time - subport->tb_time) / sp_params->sp_tb_period; + subport->tb_credits += n_periods * sp_params->sp_tb_credits_per_period; + subport->tb_credits =RTE_MIN (subport->tb_credits, + sp_params->sp_tb_size); + subport->tb_time += n_periods * sp_params->sp_tb_period;/* Pipe TB */ n_periods = (port->time - pipe->tb_time) / params->tb_period;
@@ -2380,12 +2388,14 @@ grinder_credits_update(struct rte_sched_port *port,/* Subport TCs */ if (unlikely (port->time >= subport->tc_time)) { - subport->tc_ov_wm =grinder_tc_ov_credits_update (port, subport); + subport->tc_ov_wm = +grinder_tc_ov_credits_update (port, subport, pos);for (i =0 ; i <RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE ; i++) - subport->tc_credits[i] = subport->tc_credits_per_period[i]; + subport->tc_credits[i] = + sp_params->sp_tc_credits_per_period[i]; - subport->tc_time = port->time + subport->tc_period; + subport->tc_time = port->time + sp_params->sp_tc_period; subport->tc_ov_period_id++; }
@@ -2908,6 +2918,9 @@ grinder_handle(struct rte_sched_port *port,struct rte_sched_pipe *pipe = grinder->pipe; grinder->pipe_params = subport->pipe_profiles + pipe->profile; + grinder->subport_params = port->subport_profiles + + subport->profile; +grinder_prefetch_tc_queue_arrays (subport, pos);grinder_credits_update (port, subport, pos);
Signature · 1 line
2.7.4
PATCH v2 5/10 sched: update the pipe config api implementation
In reply to Savinay DharmappaSubport profile parameters are fetched from subport profile table to calculate the subport best effort tc rate.
--- lib/librte_sched/rte_sched.c | 40 +++++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 19 deletions(-)
lib/librte_sched/rte_sched.c +21 -19
@@ -1403,6 +1403,7 @@ rte_sched_pipe_config(struct rte_sched_port *port, int32_t pipe_profile) {struct rte_sched_subport *s; +struct rte_sched_subport_profile *sp;struct rte_sched_pipe *p;struct rte_sched_pipe_profile *params;uint32_t n_subports = subport_id +1 ;
@@ -1443,14 +1444,15 @@ rte_sched_pipe_config(struct rte_sched_port *port,return -EINVAL ; } + sp = port->subport_profiles + s->profile;/* Handle the case when pipe already has a valid configuration */ p = s->pipe + pipe_id;if (p->tb_time) { params = s->pipe_profiles + p->profile;double subport_tc_be_rate = - (double ) s->tc_credits_per_period[RTE_SCHED_TRAFFIC_CLASS_BE ] - / (double ) s->tc_period; + (double )sp->tc_credits_per_period[RTE_SCHED_TRAFFIC_CLASS_BE ] + / (double ) sp->tc_period;double pipe_tc_be_rate = (double ) params->tc_credits_per_period[RTE_SCHED_TRAFFIC_CLASS_BE ] / (double ) params->tc_period;
@@ -1492,8 +1494,8 @@ rte_sched_pipe_config(struct rte_sched_port *port, {/* Subport best effort tc oversubscription */ double subport_tc_be_rate = - (double ) s->tc_credits_per_period[RTE_SCHED_TRAFFIC_CLASS_BE ] - / (double ) s->tc_period; + (double )sp->tc_credits_per_period[RTE_SCHED_TRAFFIC_CLASS_BE ] + / (double ) sp->tc_period;double pipe_tc_be_rate = (double ) params->tc_credits_per_period[RTE_SCHED_TRAFFIC_CLASS_BE ] / (double ) params->tc_period;
@@ -2286,11 +2288,11 @@ grinder_credits_update(struct rte_sched_port *port,uint32_t i;/* Subport TB */ - n_periods = (port->time - subport->tb_time) / sp_params->sp_tb_period; - subport->tb_credits += n_periods * sp_params->sp_tb_credits_per_period; + n_periods = (port->time - subport->tb_time) / sp_params->tb_period; + subport->tb_credits += n_periods * sp_params->tb_credits_per_period; subport->tb_credits =RTE_MIN (subport->tb_credits, - sp_params->sp_tb_size); - subport->tb_time += n_periods * sp_params->sp_tb_period; + sp_params->tb_size); + subport->tb_time += n_periods * sp_params->tb_period;/* Pipe TB */ n_periods = (port->time - pipe->tb_time) / params->tb_period;
@@ -2302,9 +2304,9 @@ grinder_credits_update(struct rte_sched_port *port,if (unlikely (port->time >= subport->tc_time)) {for (i =0 ; i <RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE ; i++) subport->tc_credits[i] = - sp_params->sp_tc_credits_per_period[i]; + sp_params->tc_credits_per_period[i]; - subport->tc_time = port->time + sp_params->sp_tc_period; + subport->tc_time = port->time + sp_params->tc_period; }/* Pipe TCs */
@@ -2333,17 +2335,17 @@ grinder_tc_ov_credits_update(struct rte_sched_port *port,return subport->tc_ov_wm_max;for (i =0 ; i <RTE_SCHED_TRAFFIC_CLASS_BE ; i++) { - tc_ov_consumption[i] = sp_params->sp_tc_credits_per_period[i] + tc_ov_consumption[i] = sp_params->tc_credits_per_period[i] - subport->tc_credits[i]; tc_consumption += tc_ov_consumption[i]; } tc_ov_consumption[RTE_SCHED_TRAFFIC_CLASS_BE ] = - sp_params->sp_tc_credits_per_period[RTE_SCHED_TRAFFIC_CLASS_BE ] - + sp_params->tc_credits_per_period[RTE_SCHED_TRAFFIC_CLASS_BE ] - subport->tc_credits[RTE_SCHED_TRAFFIC_CLASS_BE ]; tc_ov_consumption_max = - sp_params->sp_tc_credits_per_period[RTE_SCHED_TRAFFIC_CLASS_BE ] - + sp_params->tc_credits_per_period[RTE_SCHED_TRAFFIC_CLASS_BE ] - tc_consumption; if (tc_ov_consumption[RTE_SCHED_TRAFFIC_CLASS_BE] >
@@ -2374,11 +2376,11 @@ grinder_credits_update(struct rte_sched_port *port,uint32_t i;/* Subport TB */ - n_periods = (port->time - subport->tb_time) / sp_params->sp_tb_period; - subport->tb_credits += n_periods * sp_params->sp_tb_credits_per_period; + n_periods = (port->time - subport->tb_time) / sp_params->tb_period; + subport->tb_credits += n_periods * sp_params->tb_credits_per_period; subport->tb_credits =RTE_MIN (subport->tb_credits, - sp_params->sp_tb_size); - subport->tb_time += n_periods * sp_params->sp_tb_period; + sp_params->tb_size); + subport->tb_time += n_periods * sp_params->tb_period;/* Pipe TB */ n_periods = (port->time - pipe->tb_time) / params->tb_period;
@@ -2393,9 +2395,9 @@ grinder_credits_update(struct rte_sched_port *port,for (i =0 ; i <RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE ; i++) subport->tc_credits[i] = - sp_params->sp_tc_credits_per_period[i]; + sp_params->tc_credits_per_period[i]; - subport->tc_time = port->time + sp_params->sp_tc_period; + subport->tc_time = port->time + sp_params->tc_period; subport->tc_ov_period_id++; }
Signature · 1 line
2.7.4
Re: [dpdk-dev] [PATCH v2 05/10] sched: update the pipe config api implementation
Quoted 163 lines
-----Original Message-----
From: Dharmappa, Savinay <[email protected]>
Sent: Thursday, September 10, 2020 7:49 PM
To: Singh, Jasvinder <[email protected]>; Dumitrescu, Cristian <[email protected]>; [email protected]
Cc: Dharmappa, Savinay <[email protected]>
Subject: [PATCH v2 05/10] sched: update the pipe config api implementationSubport profile parameters are fetched from subport profile table to calculate the subport best effort tc rate.
Signed-off-by Savinay Dharmappa <[email protected]>Signed-off-by Jasvinder Singh <[email protected]>--- lib/librte_sched/rte_sched.c | 40 +++++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 19 deletions(-)lib/librte_sched/rte_sched.c index renamed from lib/librte_sched/rte_sched.c +0
-08e66d08..9ff67e0 100644
lib/librte_sched/rte_sched.c +1
-0@@ -1403,6 +1403,7 @@ rte_sched_pipe_config(struct rte_sched_port *port, int32_t pipe_profile) {struct rte_sched_subport *s; +struct rte_sched_subport_profile *sp;struct rte_sched_pipe *p;struct rte_sched_pipe_profile *params;lib/librte_sched/rte_sched.c +1
-1uint32_t n_subports = subport_id +1 ;@@ -1443,14 +1444,15 @@ rte_sched_pipe_config(struct rte_sched_port *port, return -EINVAL ; } + sp = port->subport_profiles + s->profile;/* Handle the case when pipe already has a valid configuration */ p = s->pipe + pipe_id;if (p->tb_time) { params = s->pipe_profiles + p->profile; double subport_tc_be_rate = - (double) s-Quoted 1 line
tc_credits_per_period[RTE_SCHED_TRAFFIC_CLASS_BE]
lib/librte_sched/rte_sched.c +1
-1- / (double) s->tc_period; + (double)sp-Quoted 1 line
tc_credits_per_period[RTE_SCHED_TRAFFIC_CLASS_BE]
lib/librte_sched/rte_sched.c +1
-0+ / (double) sp->tc_period;double pipe_tc_be_rate = (double) params-Quoted 1 line
tc_credits_per_period[RTE_SCHED_TRAFFIC_CLASS_BE]
lib/librte_sched/rte_sched.c +0
-1/ (double) params->tc_period;@@ -1492,8 +1494,8 @@ rte_sched_pipe_config(struct rte_sched_port *port, {/* Subport best effort tc oversubscription */ double subport_tc_be_rate = - (double) s-Quoted 1 line
tc_credits_per_period[RTE_SCHED_TRAFFIC_CLASS_BE]
lib/librte_sched/rte_sched.c +1
-1- / (double) s->tc_period; + (double)sp-Quoted 1 line
tc_credits_per_period[RTE_SCHED_TRAFFIC_CLASS_BE]
lib/librte_sched/rte_sched.c +1
-0+ / (double) sp->tc_period;double pipe_tc_be_rate = (double) params-Quoted 1 line
tc_credits_per_period[RTE_SCHED_TRAFFIC_CLASS_BE]
lib/librte_sched/rte_sched.c +4
-4/ (double) params->tc_period;@@ -2286,11 +2288,11 @@ grinder_credits_update(struct rte_sched_port *port, uint32_t i;/* Subport TB */ - n_periods = (port->time - subport->tb_time) / sp_params- >sp_tb_period; - subport->tb_credits += n_periods * sp_params- >sp_tb_credits_per_period; + n_periods = (port->time - subport->tb_time) / sp_params- >tb_period; + subport->tb_credits += n_periods * sp_params- >tb_credits_per_period; subport->tb_credits =RTE_MIN (subport->tb_credits, - sp_params->sp_tb_size); - subport->tb_time += n_periods * sp_params->sp_tb_period; + sp_params->tb_size); + subport->tb_time += n_periods * sp_params->tb_period;/* Pipe TB */ n_periods = (port->time - pipe->tb_time) / params->tb_period; @@ -2302,9 +2304,9 @@ grinder_credits_update(struct
rte_sched_port*port,lib/librte_sched/rte_sched.c +0
-1if (unlikely (port->time >= subport->tc_time)) {for (i =0 ; i <RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE ; i++) subport->tc_credits[i] = - sp_params-Quoted 1 line
sp_tc_credits_per_period[i];
lib/librte_sched/rte_sched.c +2
-2+ sp_params->tc_credits_per_period[i]; - subport->tc_time = port->time + sp_params->sp_tc_period; + subport->tc_time = port->time + sp_params->tc_period; }/* Pipe TCs */ @@ -2333,17 +2335,17 @@ grinder_tc_ov_credits_update(structrte_sched_port *port, return subport->tc_ov_wm_max;for (i =0 ; i <RTE_SCHED_TRAFFIC_CLASS_BE ; i++) { - tc_ov_consumption[i] = sp_params-Quoted 1 line
sp_tc_credits_per_period[i]
lib/librte_sched/rte_sched.c +1
-1+ tc_ov_consumption[i] = sp_params->tc_credits_per_period[i] - subport->tc_credits[i]; tc_consumption += tc_ov_consumption[i]; } tc_ov_consumption[RTE_SCHED_TRAFFIC_CLASS_BE] = - sp_params-Quoted 1 line
sp_tc_credits_per_period[RTE_SCHED_TRAFFIC_CLASS_BE] -
lib/librte_sched/rte_sched.c +1
-2+ sp_params->tc_credits_per_period[RTE_SCHED_TRAFFIC_CLASS_BE ] - subport->tc_credits[RTE_SCHED_TRAFFIC_CLASS_BE]; tc_ov_consumption_max = - sp_params-Quoted 1 line
sp_tc_credits_per_period[RTE_SCHED_TRAFFIC_CLASS_BE] -
lib/librte_sched/rte_sched.c +1
-1+ sp_params->tc_credits_per_period[RTE_SCHED_TRAFFIC_CLASS_BE] - tc_consumption; if (tc_ov_consumption[RTE_SCHED_TRAFFIC_CLASS_BE] > @@ -2374,11 +2376,11 @@ grinder_credits_update(struct
rte_sched_port*port,lib/librte_sched/rte_sched.c +0
-1uint32_t i;/* Subport TB */ - n_periods = (port->time - subport->tb_time) / sp_params-Quoted 1 line
sp_tb_period;lib/librte_sched/rte_sched.c +0
-1- subport->tb_credits += n_periods * sp_params-Quoted 1 line
sp_tb_credits_per_period;lib/librte_sched/rte_sched.c +1
-0+ n_periods = (port->time - subport->tb_time) / sp_params-Quoted 1 line
tb_period;lib/librte_sched/rte_sched.c +1
-0+ subport->tb_credits += n_periods * sp_params-Quoted 1 line
tb_credits_per_period;lib/librte_sched/rte_sched.c +2
-2subport->tb_credits =RTE_MIN (subport->tb_credits, - sp_params->sp_tb_size); - subport->tb_time += n_periods * sp_params->sp_tb_period; + sp_params->tb_size); + subport->tb_time += n_periods * sp_params->tb_period;/* Pipe TB */ n_periods = (port->time - pipe->tb_time) / params->tb_period; @@ -2393,9 +2395,9 @@ grinder_credits_update(struct
rte_sched_port*port,lib/librte_sched/rte_sched.c +2
-3for (i =0 ; i <RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE ; i++) subport->tc_credits[i] = - sp_params->sp_tc_credits_per_period[i]; + sp_params->tc_credits_per_period[i]; - subport->tc_time = port->time + sp_params->sp_tc_period; + subport->tc_time = port->time + sp_params->tc_period; subport->tc_ov_period_id++; } --
Quoted 1 line
2.7.4
Looks like the above changes have already been done in the last patch of this series. Please check.
PATCH v2 6/10 example/qos_sched: add dynamic config of subport
In reply to Savinay DharmappaModify the qos_sched application to build the hierarchical scheduler with default subport bandwidth profile. It also allows to configure a subport with different subport bandwidth profile dynamically.
--- examples/qos_sched/cfg_file.c | 158 ++++++++++++++++++++++++----------------- examples/qos_sched/cfg_file.h | 4 ++ examples/qos_sched/init.c | 24 +++++-- examples/qos_sched/main.h | 1 + examples/qos_sched/profile.cfg | 3 + 5 files changed, 120 insertions(+), 70 deletions(-)
examples/qos_sched/cfg_file.c +92 -66
@@ -53,8 +53,11 @@ cfg_load_pipe(struct rte_cfgfile *cfg, struct rte_sched_pipe_params *pipe_paramsif (!cfg || !pipe_params)return -1 ; - profiles =rte_cfgfile_num_sections (cfg,"pipe profile" ,sizeof ("pipe profile" ) -1 ); - subport_params[0 ].n_pipe_profiles = profiles; + profiles =rte_cfgfile_num_sections (cfg,"pipe profile" , +sizeof ("pipe profile" ) -1 ); + port_params.n_subport_profiles = profiles; + +printf (" profiles = %d" , profiles);for (j =0 ; j < profiles; j++) {char pipe_name[32 ];
@@ -143,6 +146,93 @@ cfg_load_pipe(struct rte_cfgfile *cfg, struct rte_sched_pipe_params *pipe_params }int +cfg_load_subport_profile (struct rte_cfgfile *cfg, +struct rte_sched_subport_profile_params *subport_profile) +{ +int i; +const char *entry; +int profiles; + +if (!cfg || !subport_profile) +return -1 ; + + profiles =rte_cfgfile_num_sections (cfg,"subport profile" , +sizeof ("subport profile" ) -1 ); + subport_params[0 ].n_pipe_profiles = profiles; + +for (i =0 ; i < profiles; i++) { +char sec_name[32 ]; +snprintf (sec_name,sizeof (sec_name),"subport profile %d" , i); + + entry =rte_cfgfile_get_entry (cfg, sec_name,"tb rate" ); +if (entry) + subport_profile[i].tb_rate = (uint64_t )atoi (entry); + + entry =rte_cfgfile_get_entry (cfg, sec_name,"tb size" ); +if (entry) + subport_profile[i].tb_size = (uint64_t )atoi (entry); + + entry =rte_cfgfile_get_entry (cfg, sec_name,"tc period" ); +if (entry) + subport_profile[i].tc_period = (uint64_t )atoi (entry); + + entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 0 rate" ); +if (entry) + subport_profile[i].tc_rate[0 ] = (uint64_t )atoi (entry); + + entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 1 rate" ); +if (entry) + subport_profile[i].tc_rate[1 ] = (uint64_t )atoi (entry); + + entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 2 rate" ); +if (entry) + subport_profile[i].tc_rate[2 ] = (uint64_t )atoi (entry); + + entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 3 rate" ); +if (entry) + subport_profile[i].tc_rate[3 ] = (uint64_t )atoi (entry); + + entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 4 rate" ); +if (entry) + subport_profile[i].tc_rate[4 ] = (uint64_t )atoi (entry); + + entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 5 rate" ); +if (entry) + subport_profile[i].tc_rate[5 ] = (uint64_t )atoi (entry); + + entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 6 rate" ); +if (entry) + subport_profile[i].tc_rate[6 ] = (uint64_t )atoi (entry); + + entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 7 rate" ); +if (entry) + subport_profile[i].tc_rate[7 ] = (uint64_t )atoi (entry); + + entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 8 rate" ); +if (entry) + subport_profile[i].tc_rate[8 ] = (uint64_t )atoi (entry); + + entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 9 rate" ); +if (entry) + subport_profile[i].tc_rate[9 ] = (uint64_t )atoi (entry); + + entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 10 rate" ); +if (entry) + subport_profile[i].tc_rate[10 ] = (uint64_t )atoi (entry); + + entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 11 rate" ); +if (entry) + subport_profile[i].tc_rate[11 ] = (uint64_t )atoi (entry); + + entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 12 rate" ); +if (entry) + subport_profile[i].tc_rate[12 ] = (uint64_t )atoi (entry); + } + +return 0 ; +} + +int cfg_load_subport (struct rte_cfgfile *cfg,struct rte_sched_subport_params *subport_params) {const char *entry;
@@ -267,70 +357,6 @@ cfg_load_subport(struct rte_cfgfile *cfg, struct rte_sched_subport_params *subpo } } - entry =rte_cfgfile_get_entry (cfg, sec_name,"tb rate" ); -if (entry) - subport_params[i].tb_rate = (uint64_t )atoi (entry); - - entry =rte_cfgfile_get_entry (cfg, sec_name,"tb size" ); -if (entry) - subport_params[i].tb_size = (uint64_t )atoi (entry); - - entry =rte_cfgfile_get_entry (cfg, sec_name,"tc period" ); -if (entry) - subport_params[i].tc_period = (uint64_t )atoi (entry); - - entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 0 rate" ); -if (entry) - subport_params[i].tc_rate[0 ] = (uint64_t )atoi (entry); - - entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 1 rate" ); -if (entry) - subport_params[i].tc_rate[1 ] = (uint64_t )atoi (entry); - - entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 2 rate" ); -if (entry) - subport_params[i].tc_rate[2 ] = (uint64_t )atoi (entry); - - entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 3 rate" ); -if (entry) - subport_params[i].tc_rate[3 ] = (uint64_t )atoi (entry); - - entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 4 rate" ); -if (entry) - subport_params[i].tc_rate[4 ] = (uint64_t )atoi (entry); - - entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 5 rate" ); -if (entry) - subport_params[i].tc_rate[5 ] = (uint64_t )atoi (entry); - - entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 6 rate" ); -if (entry) - subport_params[i].tc_rate[6 ] = (uint64_t )atoi (entry); - - entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 7 rate" ); -if (entry) - subport_params[i].tc_rate[7 ] = (uint64_t )atoi (entry); - - entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 8 rate" ); -if (entry) - subport_params[i].tc_rate[8 ] = (uint64_t )atoi (entry); - - entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 9 rate" ); -if (entry) - subport_params[i].tc_rate[9 ] = (uint64_t )atoi (entry); - - entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 10 rate" ); -if (entry) - subport_params[i].tc_rate[10 ] = (uint64_t )atoi (entry); - - entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 11 rate" ); -if (entry) - subport_params[i].tc_rate[11 ] = (uint64_t )atoi (entry); - - entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 12 rate" ); -if (entry) - subport_params[i].tc_rate[12 ] = (uint64_t )atoi (entry); -int n_entries =rte_cfgfile_section_num_entries (cfg, sec_name);struct rte_cfgfile_entry entries[n_entries];
examples/qos_sched/cfg_file.h +4 -0
@@ -14,4 +14,8 @@ int cfg_load_pipe(struct rte_cfgfile *cfg, struct rte_sched_pipe_params *pipe);int cfg_load_subport (struct rte_cfgfile *cfg,struct rte_sched_subport_params *subport); +int cfg_load_subport_profile (struct rte_cfgfile *cfg, +struct rte_sched_subport_profile_params + *subport_profile); +#endif
examples/qos_sched/init.c +20 -4
@@ -196,15 +196,20 @@ static struct rte_sched_pipe_params pipe_profiles[MAX_SCHED_PIPE_PROFILES] = { }, }; -struct rte_sched_subport_params subport_params[MAX_SCHED_SUBPORTS ] = { +static struct rte_sched_subport_profile_params + subport_profile[MAX_SCHED_SUBPORT_PROFILES ] = { { .tb_rate =1250000000 , .tb_size =1000000 , - .tc_rate = {1250000000 ,1250000000 ,1250000000 ,1250000000 ,1250000000 ,1250000000 ,1250000000 ,1250000000 ,1250000000 ,1250000000 ,1250000000 ,1250000000 ,1250000000 }, .tc_period =10 , + }, +}; + +struct rte_sched_subport_params subport_params[MAX_SCHED_SUBPORTS ] = { + { .n_pipes_per_subport_enabled =4096 , .qsize = {64 ,64 ,64 ,64 ,64 ,64 ,64 ,64 ,64 ,64 ,64 ,64 ,64 }, .pipe_profiles = pipe_profiles,
@@ -289,6 +294,9 @@ struct rte_sched_port_params port_params = { .mtu = 6 + 6 + 4 + 4 + 2 + 1500, .frame_overhead = RTE_SCHED_FRAME_OVERHEAD_DEFAULT, .n_subports_per_port = 1, + .n_subport_profiles = 1, + .subport_profiles = subport_profile, + .n_max_subport_profiles = MAX_SCHED_SUBPORT_PROFILES, .n_pipes_per_subport = MAX_SCHED_PIPES, };
@@ -320,8 +328,15 @@ app_init_sched_port(uint32_t portid, uint32_t socketid)for (subport =0 ; subport < port_params.n_subports_per_port; subport ++) { err =rte_sched_subport_config (port, subport, &subport_params[subport]);if (err) { -rte_exit (EXIT_FAILURE ,"Unable to config sched subport %u, err=%d\n" , - subport, err); +rte_exit (EXIT_FAILURE ,"Unable to config schedi " +"subport %u, err=%d\n" , subport, err); + } + + err =rte_sched_subport_profile_config (port, subport,0 ); +if (err) { +rte_exit (EXIT_FAILURE ,"failed to configure " +"profile err=%d\n" , err); + } uint32_t n_pipes_per_subport =
@@ -354,6 +369,7 @@ app_load_cfg_profile(const char *profile)cfg_load_port (file, &port_params);cfg_load_subport (file, subport_params); +cfg_load_subport_profile (file, subport_profile);cfg_load_pipe (file, pipe_profiles);rte_cfgfile_close (file);
examples/qos_sched/main.h +1 -0
@@ -51,6 +51,7 @@ extern "C" {#define MAX_SCHED_SUBPORTS 8#define MAX_SCHED_PIPES 4096#define MAX_SCHED_PIPE_PROFILES 256 +#define MAX_SCHED_SUBPORT_PROFILES 8#ifndef APP_COLLECT_STAT #define APP_COLLECT_STAT 1
examples/qos_sched/profile.cfg +3 -0
@@ -26,6 +26,9 @@ number of subports per port = 1 number of pipes per subport = 4096 queue sizes = 64 64 64 64 64 64 64 64 64 64 64 64 64 +subport 0-8 = 0 ; These subports are configured with subport profile 0 + +[subport profile 0] tb rate = 1250000000 ; Bytes per second tb size = 1000000 ; Bytes
Signature · 1 line
2.7.4
PATCH v2 7/10 example/ip_pipeline: add dynamic config of subport
In reply to Savinay DharmappaModify 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
--- examples/ip_pipeline/cli.c | 10 ++++++---- examples/ip_pipeline/tmgr.c | 28 +++++++++++++++++++++++++--- examples/ip_pipeline/tmgr.h | 3 ++- 3 files changed, 33 insertions(+), 8 deletions(-)
examples/ip_pipeline/cli.c +6 -4
@@ -406,7 +406,8 @@ cmd_tmgr_subport_profile(char **tokens, char *out, size_t out_size) { -struct rte_sched_subport_params p; +struct rte_sched_subport_params params; +struct rte_sched_subport_profile_params p;int status, i;if (n_tokens !=35 ) {
@@ -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 (¶ms.n_pipes_per_subport_enabled, + tokens[20 ]) !=0 ) {snprintf (out, out_size,MSG_ARG_INVALID ,"n_pipes_per_subport" );return ; }
@@ -451,12 +453,12 @@ cmd_tmgr_subport_profile(char **tokens, }for (i =0 ; i <RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE ; i++) -if (parser_read_uint16 (&p.qsize[i], tokens[22 + i]) !=0 ) { +if (parser_read_uint16 (¶ms.qsize[i], tokens[22 + i]) !=0 ) {snprintf (out, out_size,MSG_ARG_INVALID ,"qsize" );return ; } - status =tmgr_subport_profile_add (&p); + status =tmgr_subport_profile_add (&p, ¶ms);if (status !=0 ) {snprintf (out, out_size,MSG_CMD_FAIL , tokens[0 ]);return ;
examples/ip_pipeline/tmgr.c +25 -3
@@ -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,15 +47,20 @@ 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_profile_params *p, +struct rte_sched_subport_params *params) {/* Check input params */ -if (p ==NULL || - p->n_pipes_per_subport_enabled ==0 ) +if (p ==NULL || params ==NULL || + params->n_pipes_per_subport_enabled ==0 )return -1 ;/* Save profile */ memcpy (&subport_profile[n_subport_profiles], + params, +sizeof (*params)); + +memcpy (&profile_params[n_subport_profiles], p,sizeof (*p));
@@ -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; }
examples/ip_pipeline/tmgr.h +2 -1
@@ -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_profile_params *p, +struct rte_sched_subport_params *params);int tmgr_pipe_profile_add (struct rte_sched_pipe_params *p);
Signature · 1 line
2.7.4
PATCH v2 8/10 drivers/softnic: add dynamic config of subport
In reply to Savinay DharmappaModify the softnic drivers to build the hierarchical scheduler with default subport bandwidth profile. It also allows to configure a subport with different subport bandwidth profile dynamically.
--- drivers/net/softnic/rte_eth_softnic_internals.h | 9 + drivers/net/softnic/rte_eth_softnic_tm.c | 223 +++++++++++++++++++----- 2 files changed, 187 insertions(+), 45 deletions(-)
drivers/net/softnic/rte_eth_softnic_internals.h +9 -0
@@ -164,10 +164,19 @@ TAILQ_HEAD(softnic_link_list, softnic_link);#ifndef TM_MAX_PIPE_PROFILE #define TM_MAX_PIPE_PROFILE 256#endif + +#ifndef TM_MAX_SUBPORT_PROFILE +#define TM_MAX_SUBPORT_PROFILE 256 +#endif +struct tm_params {struct rte_sched_port_params port_params;struct rte_sched_subport_params subport_params[TM_MAX_SUBPORTS ]; +struct rte_sched_subport_profile_params + subport_profiles[TM_MAX_SUBPORT_PROFILE ]; +uint32_t n_subport_profiles; +uint32_t subport_to_profile[TM_MAX_SUBPORT_PROFILE ];struct rte_sched_pipe_params pipe_profiles[TM_MAX_PIPE_PROFILE ];uint32_t n_pipe_profiles;
drivers/net/softnic/rte_eth_softnic_tm.c +178 -45
301 lines not on this page · raw message
Signature · 1 line
2.7.4
PATCH v2 9/10 app/test_sched: add dynamic config of subport
In reply to Savinay DharmappaModify the test_sched application to build the hierarchical scheduler with default subport bandwidth profile. It also allows to configure a subport with different subport bandwidth profile dynamically
--- app/test/test_sched.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-)
app/test/test_sched.c +16 -2
@@ -21,6 +21,7 @@#define PIPE 1#define TC 2#define QUEUE 0 +#define MAX_SCHED_SUBPORT_PROFILES 8static struct rte_sched_pipe_params pipe_profile[] = { {/* Profile #0 */
@@ -36,15 +37,20 @@ static struct rte_sched_pipe_params pipe_profile[] = { }, }; -static struct rte_sched_subport_params subport_param[] = { +static struct rte_sched_subport_profile_params + subport_profile[] = { { .tb_rate =1250000000 , .tb_size =1000000 , - .tc_rate = {1250000000 ,1250000000 ,1250000000 ,1250000000 ,1250000000 ,1250000000 ,1250000000 ,1250000000 ,1250000000 ,1250000000 ,1250000000 ,1250000000 ,1250000000 }, .tc_period =10 , + }, +}; + +static struct rte_sched_subport_params subport_param[] = { + { .n_pipes_per_subport_enabled =1024 , .qsize = {32 ,32 ,32 ,32 ,32 ,32 ,32 ,32 ,32 ,32 ,32 ,32 ,32 }, .pipe_profiles = pipe_profile,
@@ -59,6 +65,9 @@ static struct rte_sched_port_params port_param = { .mtu = 1522, .frame_overhead = RTE_SCHED_FRAME_OVERHEAD_DEFAULT, .n_subports_per_port = 1, + .n_subport_profiles = 1, + .subport_profiles = subport_profile, + .n_max_subport_profiles = MAX_SCHED_SUBPORT_PROFILES, .n_pipes_per_subport = 1024, };
@@ -66,6 +75,7 @@ static struct rte_sched_port_params port_param = {#define MBUF_DATA_SZ (2048 + RTE_PKTMBUF_HEADROOM)#define MEMPOOL_CACHE_SZ 0#define SOCKET 0 +#define DEFAULT_PROFILE 0 static struct rte_mempool *
@@ -141,6 +151,10 @@ test_sched(void) err =rte_sched_subport_config (port,SUBPORT , subport_param);TEST_ASSERT_SUCCESS (err,"Error config sched, err=%d\n" , err); + err =rte_sched_subport_profile_config (port,SUBPORT , +DEFAULT_PROFILE ); +TEST_ASSERT_SUCCESS (err,"Error config sched, err=%d\n" , err); +for (pipe =0 ; pipe < subport_param[0 ].n_pipes_per_subport_enabled; pipe++) { err =rte_sched_pipe_config (port,SUBPORT , pipe,0 );TEST_ASSERT_SUCCESS (err,"Error config sched pipe %u, err=%d\n" , pipe, err);
Signature · 1 line
2.7.4
PATCH v2 10/10 sched: remove the redundant code
In reply to Savinay DharmappaRemove redundant data structure fields references from functions and subport level data structures. It also update the release and deprecation note.
--- doc/guides/rel_notes/deprecation.rst | 6 -- doc/guides/rel_notes/release_20_11.rst | 4 ++ lib/librte_sched/rte_sched.c | 115 +-------------------------------- lib/librte_sched/rte_sched.h | 12 ---- 4 files changed, 6 insertions(+), 131 deletions(-)
doc/guides/rel_notes/deprecation.rst +0 -6
@@ -311,12 +311,6 @@ Deprecation Notices in "rte_sched.h". These changes are aligned to improvements suggested in the RFC https://mails.dpdk.org/archives/dev/2018-November/120035.html. -* sched: To allow dynamic configuration of the subport bandwidth profile, - changes will be made to data structures ``rte_sched_subport_params``, - ``rte_sched_port_params`` and new data structure, API functions will be - defined in ``rte_sched.h``. These changes are aligned as suggested in the - RFC https://mails.dpdk.org/archives/dev/2020-July/175161.html - * metrics: The function ``rte_metrics_init`` will have a non-void return in order to notify errors instead of calling ``rte_exit``.
doc/guides/rel_notes/release_20_11.rst +4 -0
@@ -84,6 +84,10 @@ API Changes Also, make sure to start the actual text at the margin. ======================================================= +* sched: The subport bandwidth configuration parameters such as tb_rate, + tc_rate, tc_period etc., are moved from subport level data structure to + new a data structure. This allows to configure a subport with different + subport bandwidth configuration dynamically. ABI Changes -----------
lib/librte_sched/rte_sched.c +2 -113
163 lines not on this page · raw message
lib/librte_sched/rte_sched.h +0 -12
@@ -149,18 +149,6 @@ struct rte_sched_pipe_params {* byte. */ struct rte_sched_subport_params { -/** Token bucket rate (measured in bytes per second) */ -uint64_t tb_rate; - -/** Token bucket size (measured in credits) */ -uint64_t tb_size; - -/** Traffic class rates (measured in bytes per second) */ -uint64_t tc_rate[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE ]; - -/** Enforcement period for rates (measured in milliseconds) */ -uint64_t tc_period; -/** Number of subport pipes. * The subport can enable/allocate fewer pipes than the maximum * number set through struct port_params::n_max_pipes_per_subport,
Signature · 1 line
2.7.4
v3 cover Enable dynamic config of subport bandwidth
In reply to Savinay DharmappaDPDK sched library allows runtime configuration of the pipe profiles to the pipes of the subport once scheduler hierarchy is constructed. However, to change the subport level bandwidth, existing hierarchy needs to be dismantled and whole process of building hierarchy under subport nodes needs to be repeated which might result in router downtime. Furthermore, due to lack of dynamic configuration of the subport bandwidth profile configuration (shaper and Traffic class rates), the user application is unable to dynamically re-distribute the excess-bandwidth of one subport among other subports in the scheduler hierarchy. Therefore, it is also not possible to adjust the subport bandwidth profile in sync with dynamic changes in pipe profiles of subscribers who want to consume higher bandwidth opportunistically.
This patch series implements dynamic configuration of the subport bandwidth profile to overcome the runtime situation when group of subscribers are not using the allotted bandwidth and dynamic bandwidth re-distribution is needed the without making any structural changes in the hierarchy.
The implementation work includes refactoring the existing data structures defined for port and subport level, new APIs for adding subport level bandwidth profiles that can be used in runtime.
Savinay Dharmappa (9):
sched: add support profile data structure
sched: add subport profile table
sched: add subport profile add and config api
sched: update grinder credit and pipe config function example/qos_sched: add dynamic config of subport example/ip_pipeline: add dynamic config of subport drivers/softnic: add dynamic config of subport app/test_sched: add dynamic config of subport
sched: remove the redundant code
app/test/test_sched.c | 18 +- doc/guides/rel_notes/deprecation.rst | 6 - doc/guides/rel_notes/release_20_11.rst | 4 + drivers/net/softnic/rte_eth_softnic_internals.h | 9 + drivers/net/softnic/rte_eth_softnic_tm.c | 223 ++++++++--- examples/ip_pipeline/cli.c | 14 +- examples/ip_pipeline/tmgr.c | 26 +- examples/ip_pipeline/tmgr.h | 3 +- examples/qos_sched/cfg_file.c | 151 ++++---- examples/qos_sched/cfg_file.h | 4 + examples/qos_sched/init.c | 24 +- examples/qos_sched/main.h | 1 + examples/qos_sched/profile.cfg | 3 + lib/librte_sched/rte_sched.c | 479 +++++++++++++++++------- lib/librte_sched/rte_sched.h | 82 +++- lib/librte_sched/rte_sched_version.map | 2 + 16 files changed, 771 insertions(+), 278 deletions(-)
Signature · 1 line
2.7.4
PATCH v3 1/9 sched: add support profile data structure
Add subport profile data structure to support dynamic configuration of subport bandwidth
--- lib/librte_sched/rte_sched.c | 10 ++++++++++ lib/librte_sched/rte_sched.h | 25 +++++++++++++++++++++++++ 2 files changed, 35 insertions(+)
lib/librte_sched/rte_sched.c +10 -0
@@ -101,6 +101,16 @@ enum grinder_state {e_GRINDER_READ_MBUF }; +struct rte_sched_subport_profile { +/* Token bucket (TB) */ +uint64_t tb_period; +uint64_t tb_credits_per_period; +uint64_t tb_size; + +uint64_t tc_credits_per_period[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE ]; +uint64_t tc_period; +}; +struct rte_sched_grinder {/* Pipe cache */ uint16_t pcache_qmask[RTE_SCHED_GRINDER_PCACHE_SIZE ];
lib/librte_sched/rte_sched.h +25 -0
@@ -192,6 +192,20 @@ struct rte_sched_subport_params {#endif }; +struct rte_sched_subport_profile_params { +/** Token bucket rate (measured in bytes per second) */ +uint64_t tb_rate; + +/** Token bucket size (measured in credits) */ +uint64_t tb_size; + +/** Traffic class rates (measured in bytes per second) */ +uint64_t tc_rate[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE ]; + +/** Enforcement period for rates (measured in milliseconds) */ +uint64_t tc_period; +}; +/** Subport statistics */ struct rte_sched_subport_stats {/** Number of packets successfully written */
@@ -254,6 +268,17 @@ struct rte_sched_port_params {/** Number of subports */ uint32_t n_subports_per_port; +/** subport profile table. +* Every pipe is configured using one of the profiles from this table. +*/ +struct rte_sched_subport_profile_params *subport_profiles; + +/** Profiles in the pipe profile table */ +uint32_t n_subport_profiles; + +/** Max allowed profiles in the pipe profile table */ +uint32_t n_max_subport_profiles; +/** Maximum number of subport pipes. * This parameter is used to reserve a fixed number of bits * in struct rte_mbuf::sched.queue_id for the pipe_id for all
Signature · 1 line
2.7.4
PATCH v3 2/9 sched: add subport profile table
In reply to Savinay DharmappaAdd subport profile table to internal port data structure and update the port config function.
--- lib/librte_sched/rte_sched.c | 185 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 182 insertions(+), 3 deletions(-)
lib/librte_sched/rte_sched.c +182 -3
@@ -222,6 +222,8 @@ struct rte_sched_port {uint16_t pipe_queue[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE ];uint8_t pipe_tc[RTE_SCHED_QUEUES_PER_PIPE ];uint8_t tc_queue[RTE_SCHED_QUEUES_PER_PIPE ]; +uint32_t n_subport_profiles; +uint32_t n_max_subport_profiles;uint64_t rate;uint32_t mtu;uint32_t frame_overhead;
@@ -240,6 +242,7 @@ struct rte_sched_port {uint32_t subport_id;/* Large data structures */ +struct rte_sched_subport_profile *subport_profiles; struct rte_sched_subport *subports[0] __rte_cache_aligned; } __rte_cache_aligned;
@@ -386,8 +389,60 @@ pipe_profile_check(struct rte_sched_pipe_params *params, }static int +subport_profile_check (struct rte_sched_subport_profile_params *params, +uint64_t rate) +{ +uint32_t i; + +/* Check user parameters */ +if (params ==NULL ) { +RTE_LOG (ERR ,SCHED ,"%s: " +"Incorrect value for parameter params\n" , __func__); +return -EINVAL ; + } + +if (params->tb_rate ==0 || params->tb_rate > rate) { +RTE_LOG (ERR ,SCHED ,"%s: " +"Incorrect value for tb rate\n" , __func__); +return -EINVAL ; + } + +if (params->tb_size ==0 ) { +RTE_LOG (ERR ,SCHED ,"%s: " +"Incorrect value for tb size\n" , __func__); +return -EINVAL ; + } + +for (i =0 ; i <RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE ; i++) { +uint64_t tc_rate = params->tc_rate[i]; + +if (tc_rate ==0 || (tc_rate > params->tb_rate)) { +RTE_LOG (ERR ,SCHED ,"%s: " +"Incorrect value for tc rate\n" , __func__); +return -EINVAL ; + } + } + +if (params->tc_rate[RTE_SCHED_TRAFFIC_CLASS_BE ] ==0 ) { +RTE_LOG (ERR ,SCHED ,"%s: " +"Incorrect tc rate(best effort)\n" , __func__); +return -EINVAL ; + } + +if (params->tc_period ==0 ) { +RTE_LOG (ERR ,SCHED ,"%s: " +"Incorrect value for tc period\n" , __func__); +return -EINVAL ; + } + +return 0 ; +} + +static int rte_sched_port_check_params (struct rte_sched_port_params *params) { +uint32_t i; +if (params ==NULL ) {RTE_LOG (ERR ,SCHED ,"%s: Incorrect value for parameter params\n" , __func__);
@@ -424,6 +479,29 @@ rte_sched_port_check_params(struct rte_sched_port_params *params)return -EINVAL ; } +if (params->subport_profiles ==NULL || + params->n_subport_profiles ==0 || + params->n_max_subport_profiles ==0 || + params->n_subport_profiles > params->n_max_subport_profiles) { +RTE_LOG (ERR ,SCHED , +"%s: Incorrect value for subport profiles\n" , __func__); +return -EINVAL ; + } + +for (i =0 ; i < params->n_subport_profiles; i++) { +struct rte_sched_subport_profile_params *p = + params->subport_profiles + i; +int status; + + status =subport_profile_check (p, params->rate); +if (status !=0 ) { +RTE_LOG (ERR ,SCHED , +"%s: subport profile check failed(%d)\n" , + __func__, status); +return -EINVAL ; + } + } +/* n_pipes_per_subport: non-zero, power of 2 */ if (params->n_pipes_per_subport ==0 || !rte_is_power_of_2 (params->n_pipes_per_subport)) {
@@ -565,6 +643,42 @@ rte_sched_port_log_pipe_profile(struct rte_sched_subport *subport, uint32_t i) p->wrr_cost[0], p->wrr_cost[1], p->wrr_cost[2], p->wrr_cost[3]); } +static void +rte_sched_port_log_subport_profile (struct rte_sched_port *port,uint32_t i) +{ +struct rte_sched_subport_profile *p = port->subport_profiles + i; + +RTE_LOG (DEBUG ,SCHED ,"Low level config for subport profile %u:\n" +"Token bucket: period = %" PRIu64", credits per period = %" PRIu64"," +"size = %" PRIu64"\n" +"Traffic classes: period = %" PRIu64",\n" +"credits per period = [%" PRIu64", %" PRIu64", %" PRIu64", %" PRIu64 +" %" PRIu64", %" PRIu64", %" PRIu64", %" PRIu64", %" PRIu64", %" PRIu64 +" %" PRIu64", %" PRIu64", %" PRIu64"]\n" , + i, + +/* Token bucket */ + p->tb_period, + p->tb_credits_per_period, + p->tb_size, + +/* Traffic classes */ + p->tc_period, + p->tc_credits_per_period[0 ], + p->tc_credits_per_period[1 ], + p->tc_credits_per_period[2 ], + p->tc_credits_per_period[3 ], + p->tc_credits_per_period[4 ], + p->tc_credits_per_period[5 ], + p->tc_credits_per_period[6 ], + p->tc_credits_per_period[7 ], + p->tc_credits_per_period[8 ], + p->tc_credits_per_period[9 ], + p->tc_credits_per_period[10 ], + p->tc_credits_per_period[11 ], + p->tc_credits_per_period[12 ]); +} +static inline uint64_t rte_sched_time_ms_to_bytes (uint64_t time_ms,uint64_t rate) {
@@ -634,6 +748,37 @@ rte_sched_pipe_profile_convert(struct rte_sched_subport *subport, }static void +rte_sched_subport_profile_convert (struct rte_sched_subport_profile_params *src, +struct rte_sched_subport_profile *dst, +uint64_t rate) +{ +uint32_t i; + +/* Token Bucket */ +if (src->tb_rate == rate) { + dst->tb_credits_per_period =1 ; + dst->tb_period =1 ; + }else { +double tb_rate = (double ) src->tb_rate + / (double ) rate; +double d =RTE_SCHED_TB_RATE_CONFIG_ERR ; + +rte_approx_64 (tb_rate, d, &dst->tb_credits_per_period, + &dst->tb_period); + } + + dst->tb_size = src->tb_size; + +/* Traffic Classes */ + dst->tc_period =rte_sched_time_ms_to_bytes (src->tc_period, rate); + +for (i =0 ; i <RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE ; i++) + dst->tc_credits_per_period[i] + =rte_sched_time_ms_to_bytes (src->tc_period, + src->tc_rate[i]); +} + +static void rte_sched_subport_config_pipe_profile_table (struct rte_sched_subport *subport,struct rte_sched_subport_params *params,uint64_t rate) {
@@ -657,6 +802,24 @@ rte_sched_subport_config_pipe_profile_table(struct rte_sched_subport *subport, } } +static void +rte_sched_port_config_subport_profile_table (struct rte_sched_port *port, +struct rte_sched_port_params *params, +uint64_t rate) +{ +uint32_t i; + +for (i =0 ; i < port->n_subport_profiles; i++) { +struct rte_sched_subport_profile_params *src + = params->subport_profiles + i; +struct rte_sched_subport_profile *dst + = port->subport_profiles + i; + +rte_sched_subport_profile_convert (src, dst, rate); +rte_sched_port_log_subport_profile (port, i); + } +} + static int rte_sched_subport_check_params(struct rte_sched_subport_params *params, uint32_t n_max_pipes_per_subport,
@@ -803,7 +966,7 @@ struct rte_sched_port * rte_sched_port_config(struct rte_sched_port_params *params) {struct rte_sched_port *port =NULL ; -uint32_t size0, size1; +uint32_t size0, size1, size2;uint32_t cycles_per_byte;uint32_t i, j;int status;
@@ -818,10 +981,21 @@ rte_sched_port_config(struct rte_sched_port_params *params) size0 =sizeof (struct rte_sched_port ); size1 = params->n_subports_per_port *sizeof (struct rte_sched_subport *); + size2 = params->n_max_subport_profiles * +sizeof (struct rte_sched_subport_profile );/* Allocate memory to store the data structures */ - port =rte_zmalloc_socket ("qos_params" , size0 + size1,RTE_CACHE_LINE_SIZE , - params->socket); + port =rte_zmalloc_socket ("qos_params" , size0 + size1, +RTE_CACHE_LINE_SIZE , params->socket); +if (port ==NULL ) { +RTE_LOG (ERR ,SCHED ,"%s: Memory allocation fails\n" , __func__); + +return NULL ; + } + +/* Allocate memory to store the subport profile */ + port->subport_profiles =rte_zmalloc_socket ("subport_profile" , size2, +RTE_CACHE_LINE_SIZE , params->socket);if (port ==NULL ) {RTE_LOG (ERR ,SCHED ,"%s: Memory allocation fails\n" , __func__);
@@ -830,6 +1004,8 @@ rte_sched_port_config(struct rte_sched_port_params *params)/* User parameters */ port->n_subports_per_port = params->n_subports_per_port; + port->n_subport_profiles = params->n_subport_profiles; + port->n_max_subport_profiles = params->n_max_subport_profiles; port->n_pipes_per_subport = params->n_pipes_per_subport; port->n_pipes_per_subport_log2 =__builtin_ctz (params->n_pipes_per_subport);
@@ -860,6 +1036,9 @@ rte_sched_port_config(struct rte_sched_port_params *params) port->time_cpu_bytes =0 ; port->time =0 ; +/* Subport profile table */ +rte_sched_port_config_subport_profile_table (port, params, port->rate); + cycles_per_byte = (rte_get_tsc_hz () <<RTE_SCHED_TIME_SHIFT ) / params->rate; port->inv_cycles_per_byte =rte_reciprocal_value (cycles_per_byte);
Signature · 1 line
2.7.4
PATCH v3 3/9 sched: add subport profile add and config api
In reply to Savinay DharmappaAdd apis to add new subport profile and configure it.
--- lib/librte_sched/rte_sched.c | 118 +++++++++++++++++++++++++++++++++ lib/librte_sched/rte_sched.h | 45 +++++++++++++ lib/librte_sched/rte_sched_version.map | 2 + 3 files changed, 165 insertions(+)
lib/librte_sched/rte_sched.c +118 -0
@@ -174,6 +174,8 @@ struct rte_sched_subport {/* Statistics */ struct rte_sched_subport_stats stats __rte_cache_aligned; +/* subport profile */ +uint32_t profile;/* Subport pipes */ uint32_t n_pipes_per_subport_enabled;uint32_t n_pipe_profiles;
@@ -1343,6 +1345,56 @@ rte_sched_subport_config(struct rte_sched_port *port, }int +rte_sched_subport_profile_config (struct rte_sched_port *port, +uint32_t subport_id, +uint32_t profile_id) +{ +int i; +struct rte_sched_subport_profile *params; +uint32_t n_subports = subport_id +1 ; +struct rte_sched_subport *s; + +if (port ==NULL ) { +RTE_LOG (ERR ,SCHED , +"%s: Incorrect value for parameter port\n" , __func__); +return -EINVAL ; + } + +if (subport_id >= port->n_subports_per_port) { +RTE_LOG (ERR ,SCHED ,"%s: " +"Incorrect value for parameter subport id\n" , __func__); + +rte_sched_free_memory (port, n_subports); +return -EINVAL ; + } + + params = port->subport_profiles + profile_id; + + s = port->subports[subport_id]; + + s->tb_credits = params->tb_size /2 ; + + s->tc_time = port->time + params->tc_period; + +for (i =0 ; i <RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE ; i++) +if (s->qsize[i]) + s->tc_credits[i] = + params->tc_credits_per_period[i]; +else + params->tc_credits_per_period[i] =0 ; + +#ifdef RTE_SCHED_SUBPORT_TC_OV + s->tc_ov_wm_max =rte_sched_time_ms_to_bytes (params->tc_period, + s->pipe_tc_be_rate_max); +#endif + s->profile = profile_id; + +rte_sched_port_log_subport_profile (port, profile_id); + +return 0 ; +} + +int rte_sched_pipe_config(struct rte_sched_port *port, uint32_t subport_id, uint32_t pipe_id,
@@ -1526,6 +1578,72 @@ rte_sched_subport_pipe_profile_add(struct rte_sched_port *port,return 0 ; } +int +rte_sched_port_subport_profile_add (struct rte_sched_port *port, +struct rte_sched_subport_profile_params *params, +uint32_t *subport_profile_id) +{ +int status; +uint32_t i; +struct rte_sched_subport_profile *dst; + +/* Port */ +if (port ==NULL ) { +RTE_LOG (ERR ,SCHED ,"%s: " +"Incorrect value for parameter port\n" , __func__); +return -EINVAL ; + } + +if (params ==NULL ) { +RTE_LOG (ERR ,SCHED ,"%s: " +"Incorrect value for parameter profile\n" , __func__); +return -EINVAL ; + } + +if (subport_profile_id ==NULL ) { +RTE_LOG (ERR ,SCHED ,"%s: " +"Incorrect value for parameter subport_profile_id\n" , + __func__); +return -EINVAL ; + } + + dst = port->subport_profiles + port->n_subport_profiles; + +/* Subport profiles exceeds the max limit */ +if (port->n_subport_profiles >= port->n_max_subport_profiles) { +RTE_LOG (ERR ,SCHED ,"%s: " +"Number of subport profiles exceeds the max limit\n" , + __func__); +return -EINVAL ; + } + + status =subport_profile_check (params, port->rate); +if (status !=0 ) { +RTE_LOG (ERR ,SCHED , +"%s: subport profile check failed(%d)\n" , __func__, status); +return -EINVAL ; + } + +rte_sched_subport_profile_convert (params, dst, port->rate); + +/* Subport profile should not exists */ +for (i =0 ; i < port->n_subport_profiles; i++) +if (memcmp (port->subport_profiles + i, + dst,sizeof (*dst)) ==0 ) { +RTE_LOG (ERR ,SCHED , +"%s: subport profile exists\n" , __func__); +return -EINVAL ; + } + +/* Subport profile commit */ + *subport_profile_id = port->n_subport_profiles; + port->n_subport_profiles++; + +rte_sched_port_log_subport_profile (port, *subport_profile_id); + +return 0 ; +} + static inline uint32_t rte_sched_port_qindex(struct rte_sched_port *port, uint32_t subport,
lib/librte_sched/rte_sched.h +45 -0
57 lines not on this page · raw message
lib/librte_sched/rte_sched_version.map +2 -0
@@ -28,4 +28,6 @@ EXPERIMENTAL { global: rte_sched_subport_pipe_profile_add; + rte_sched_port_subport_profile_add; + rte_sched_subport_profile_config; };
Signature · 1 line
2.7.4
PATCH v3 4/9 sched: update grinder credit and pipe config function
In reply to Savinay DharmappaCredits are updated by fetching subport profile parameters from subport profile table. Similarly subport best effort tc is calculated in pipe config.
--- lib/librte_sched/rte_sched.c | 55 ++++++++++++++++++++++++++------------------ 1 file changed, 33 insertions(+), 22 deletions(-)
lib/librte_sched/rte_sched.c +33 -22
@@ -123,6 +123,7 @@ struct rte_sched_grinder {uint32_t productive;uint32_t pindex;struct rte_sched_subport *subport; +struct rte_sched_subport_profile *subport_params;struct rte_sched_pipe *pipe;struct rte_sched_pipe_profile *pipe_params;
@@ -1401,6 +1402,7 @@ rte_sched_pipe_config(struct rte_sched_port *port, int32_t pipe_profile) {struct rte_sched_subport *s; +struct rte_sched_subport_profile *sp;struct rte_sched_pipe *p;struct rte_sched_pipe_profile *params;uint32_t n_subports = subport_id +1 ;
@@ -1441,14 +1443,15 @@ rte_sched_pipe_config(struct rte_sched_port *port,return -EINVAL ; } + sp = port->subport_profiles + s->profile;/* Handle the case when pipe already has a valid configuration */ p = s->pipe + pipe_id;if (p->tb_time) { params = s->pipe_profiles + p->profile;double subport_tc_be_rate = - (double ) s->tc_credits_per_period[RTE_SCHED_TRAFFIC_CLASS_BE ] - / (double ) s->tc_period; + (double )sp->tc_credits_per_period[RTE_SCHED_TRAFFIC_CLASS_BE ] + / (double ) sp->tc_period;double pipe_tc_be_rate = (double ) params->tc_credits_per_period[RTE_SCHED_TRAFFIC_CLASS_BE ] / (double ) params->tc_period;
@@ -1490,8 +1493,8 @@ rte_sched_pipe_config(struct rte_sched_port *port, {/* Subport best effort tc oversubscription */ double subport_tc_be_rate = - (double ) s->tc_credits_per_period[RTE_SCHED_TRAFFIC_CLASS_BE ] - / (double ) s->tc_period; + (double )sp->tc_credits_per_period[RTE_SCHED_TRAFFIC_CLASS_BE ] + / (double ) sp->tc_period;double pipe_tc_be_rate = (double ) params->tc_credits_per_period[RTE_SCHED_TRAFFIC_CLASS_BE ] / (double ) params->tc_period;
@@ -2279,14 +2282,15 @@ grinder_credits_update(struct rte_sched_port *port,struct rte_sched_grinder *grinder = subport->grinder + pos;struct rte_sched_pipe *pipe = grinder->pipe;struct rte_sched_pipe_profile *params = grinder->pipe_params; +struct rte_sched_subport_profile *sp = grinder->subport_params;uint64_t n_periods;uint32_t i;/* Subport TB */ - n_periods = (port->time - subport->tb_time) / subport->tb_period; - subport->tb_credits += n_periods * subport->tb_credits_per_period; - subport->tb_credits =RTE_MIN (subport->tb_credits, subport->tb_size); - subport->tb_time += n_periods * subport->tb_period; + n_periods = (port->time - subport->tb_time) / sp->tb_period; + subport->tb_credits += n_periods * sp->tb_credits_per_period; + subport->tb_credits =RTE_MIN (subport->tb_credits, sp->tb_size); + subport->tb_time += n_periods * sp->tb_period;/* Pipe TB */ n_periods = (port->time - pipe->tb_time) / params->tb_period;
@@ -2297,9 +2301,9 @@ grinder_credits_update(struct rte_sched_port *port,/* Subport TCs */ if (unlikely (port->time >= subport->tc_time)) {for (i =0 ; i <RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE ; i++) - subport->tc_credits[i] = subport->tc_credits_per_period[i]; + subport->tc_credits[i] = sp->tc_credits_per_period[i]; - subport->tc_time = port->time + subport->tc_period; + subport->tc_time = port->time + sp->tc_period; }/* Pipe TCs */
@@ -2315,8 +2319,10 @@ grinder_credits_update(struct rte_sched_port *port,static inline uint64_t grinder_tc_ov_credits_update (struct rte_sched_port *port, -struct rte_sched_subport *subport) +struct rte_sched_subport *subport,uint32_t pos) { +struct rte_sched_grinder *grinder = subport->grinder + pos; +struct rte_sched_subport_profile *sp = grinder->subport_params;uint64_t tc_ov_consumption[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE ];uint64_t tc_consumption =0 , tc_ov_consumption_max;uint64_t tc_ov_wm = subport->tc_ov_wm;
@@ -2326,17 +2332,17 @@ grinder_tc_ov_credits_update(struct rte_sched_port *port,return subport->tc_ov_wm_max;for (i =0 ; i <RTE_SCHED_TRAFFIC_CLASS_BE ; i++) { - tc_ov_consumption[i] = - subport->tc_credits_per_period[i] - subport->tc_credits[i]; + tc_ov_consumption[i] = sp->tc_credits_per_period[i] + - subport->tc_credits[i]; tc_consumption += tc_ov_consumption[i]; } tc_ov_consumption[RTE_SCHED_TRAFFIC_CLASS_BE ] = - subport->tc_credits_per_period[RTE_SCHED_TRAFFIC_CLASS_BE ] - + sp->tc_credits_per_period[RTE_SCHED_TRAFFIC_CLASS_BE ] - subport->tc_credits[RTE_SCHED_TRAFFIC_CLASS_BE ]; tc_ov_consumption_max = - subport->tc_credits_per_period[RTE_SCHED_TRAFFIC_CLASS_BE ] - + sp->tc_credits_per_period[RTE_SCHED_TRAFFIC_CLASS_BE ] - tc_consumption; if (tc_ov_consumption[RTE_SCHED_TRAFFIC_CLASS_BE] >
@@ -2362,14 +2368,15 @@ grinder_credits_update(struct rte_sched_port *port,struct rte_sched_grinder *grinder = subport->grinder + pos;struct rte_sched_pipe *pipe = grinder->pipe;struct rte_sched_pipe_profile *params = grinder->pipe_params; +struct rte_sched_subport_profile *sp = grinder->subport_params;uint64_t n_periods;uint32_t i;/* Subport TB */ - n_periods = (port->time - subport->tb_time) / subport->tb_period; - subport->tb_credits += n_periods * subport->tb_credits_per_period; - subport->tb_credits =RTE_MIN (subport->tb_credits, subport->tb_size); - subport->tb_time += n_periods * subport->tb_period; + n_periods = (port->time - subport->tb_time) / sp->tb_period; + subport->tb_credits += n_periods * sp->tb_credits_per_period; + subport->tb_credits =RTE_MIN (subport->tb_credits, sp->tb_size); + subport->tb_time += n_periods * sp->tb_period;/* Pipe TB */ n_periods = (port->time - pipe->tb_time) / params->tb_period;
@@ -2379,12 +2386,13 @@ grinder_credits_update(struct rte_sched_port *port,/* Subport TCs */ if (unlikely (port->time >= subport->tc_time)) { - subport->tc_ov_wm =grinder_tc_ov_credits_update (port, subport); + subport->tc_ov_wm = +grinder_tc_ov_credits_update (port, subport, pos);for (i =0 ; i <RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE ; i++) - subport->tc_credits[i] = subport->tc_credits_per_period[i]; + subport->tc_credits[i] = sp->tc_credits_per_period[i]; - subport->tc_time = port->time + subport->tc_period; + subport->tc_time = port->time + sp->tc_period; subport->tc_ov_period_id++; }
@@ -2907,6 +2915,9 @@ grinder_handle(struct rte_sched_port *port,struct rte_sched_pipe *pipe = grinder->pipe; grinder->pipe_params = subport->pipe_profiles + pipe->profile; + grinder->subport_params = port->subport_profiles + + subport->profile; +grinder_prefetch_tc_queue_arrays (subport, pos);grinder_credits_update (port, subport, pos);
Signature · 1 line
2.7.4
PATCH v3 5/9 example/qos_sched: add dynamic config of subport
In reply to Savinay DharmappaModify the qos_sched application to build the hierarchical scheduler with default subport bandwidth profile. It also allows to configure a subport with different subport bandwidth profile dynamically.
--- examples/qos_sched/cfg_file.c | 151 ++++++++++++++++++++++++----------------- examples/qos_sched/cfg_file.h | 4 ++ examples/qos_sched/init.c | 24 +++++-- examples/qos_sched/main.h | 1 + examples/qos_sched/profile.cfg | 3 + 5 files changed, 115 insertions(+), 68 deletions(-)
examples/qos_sched/cfg_file.c +87 -64
@@ -143,6 +143,93 @@ cfg_load_pipe(struct rte_cfgfile *cfg, struct rte_sched_pipe_params *pipe_params }int +cfg_load_subport_profile (struct rte_cfgfile *cfg, +struct rte_sched_subport_profile_params *subport_profile) +{ +int i; +const char *entry; +int profiles; + +if (!cfg || !subport_profile) +return -1 ; + + profiles =rte_cfgfile_num_sections (cfg,"subport profile" , +sizeof ("subport profile" ) -1 ); + subport_params[0 ].n_pipe_profiles = profiles; + +for (i =0 ; i < profiles; i++) { +char sec_name[32 ]; +snprintf (sec_name,sizeof (sec_name),"subport profile %d" , i); + + entry =rte_cfgfile_get_entry (cfg, sec_name,"tb rate" ); +if (entry) + subport_profile[i].tb_rate = (uint64_t )atoi (entry); + + entry =rte_cfgfile_get_entry (cfg, sec_name,"tb size" ); +if (entry) + subport_profile[i].tb_size = (uint64_t )atoi (entry); + + entry =rte_cfgfile_get_entry (cfg, sec_name,"tc period" ); +if (entry) + subport_profile[i].tc_period = (uint64_t )atoi (entry); + + entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 0 rate" ); +if (entry) + subport_profile[i].tc_rate[0 ] = (uint64_t )atoi (entry); + + entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 1 rate" ); +if (entry) + subport_profile[i].tc_rate[1 ] = (uint64_t )atoi (entry); + + entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 2 rate" ); +if (entry) + subport_profile[i].tc_rate[2 ] = (uint64_t )atoi (entry); + + entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 3 rate" ); +if (entry) + subport_profile[i].tc_rate[3 ] = (uint64_t )atoi (entry); + + entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 4 rate" ); +if (entry) + subport_profile[i].tc_rate[4 ] = (uint64_t )atoi (entry); + + entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 5 rate" ); +if (entry) + subport_profile[i].tc_rate[5 ] = (uint64_t )atoi (entry); + + entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 6 rate" ); +if (entry) + subport_profile[i].tc_rate[6 ] = (uint64_t )atoi (entry); + + entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 7 rate" ); +if (entry) + subport_profile[i].tc_rate[7 ] = (uint64_t )atoi (entry); + + entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 8 rate" ); +if (entry) + subport_profile[i].tc_rate[8 ] = (uint64_t )atoi (entry); + + entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 9 rate" ); +if (entry) + subport_profile[i].tc_rate[9 ] = (uint64_t )atoi (entry); + + entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 10 rate" ); +if (entry) + subport_profile[i].tc_rate[10 ] = (uint64_t )atoi (entry); + + entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 11 rate" ); +if (entry) + subport_profile[i].tc_rate[11 ] = (uint64_t )atoi (entry); + + entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 12 rate" ); +if (entry) + subport_profile[i].tc_rate[12 ] = (uint64_t )atoi (entry); + } + +return 0 ; +} + +int cfg_load_subport (struct rte_cfgfile *cfg,struct rte_sched_subport_params *subport_params) {const char *entry;
@@ -267,70 +354,6 @@ cfg_load_subport(struct rte_cfgfile *cfg, struct rte_sched_subport_params *subpo } } - entry =rte_cfgfile_get_entry (cfg, sec_name,"tb rate" ); -if (entry) - subport_params[i].tb_rate = (uint64_t )atoi (entry); - - entry =rte_cfgfile_get_entry (cfg, sec_name,"tb size" ); -if (entry) - subport_params[i].tb_size = (uint64_t )atoi (entry); - - entry =rte_cfgfile_get_entry (cfg, sec_name,"tc period" ); -if (entry) - subport_params[i].tc_period = (uint64_t )atoi (entry); - - entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 0 rate" ); -if (entry) - subport_params[i].tc_rate[0 ] = (uint64_t )atoi (entry); - - entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 1 rate" ); -if (entry) - subport_params[i].tc_rate[1 ] = (uint64_t )atoi (entry); - - entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 2 rate" ); -if (entry) - subport_params[i].tc_rate[2 ] = (uint64_t )atoi (entry); - - entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 3 rate" ); -if (entry) - subport_params[i].tc_rate[3 ] = (uint64_t )atoi (entry); - - entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 4 rate" ); -if (entry) - subport_params[i].tc_rate[4 ] = (uint64_t )atoi (entry); - - entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 5 rate" ); -if (entry) - subport_params[i].tc_rate[5 ] = (uint64_t )atoi (entry); - - entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 6 rate" ); -if (entry) - subport_params[i].tc_rate[6 ] = (uint64_t )atoi (entry); - - entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 7 rate" ); -if (entry) - subport_params[i].tc_rate[7 ] = (uint64_t )atoi (entry); - - entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 8 rate" ); -if (entry) - subport_params[i].tc_rate[8 ] = (uint64_t )atoi (entry); - - entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 9 rate" ); -if (entry) - subport_params[i].tc_rate[9 ] = (uint64_t )atoi (entry); - - entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 10 rate" ); -if (entry) - subport_params[i].tc_rate[10 ] = (uint64_t )atoi (entry); - - entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 11 rate" ); -if (entry) - subport_params[i].tc_rate[11 ] = (uint64_t )atoi (entry); - - entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 12 rate" ); -if (entry) - subport_params[i].tc_rate[12 ] = (uint64_t )atoi (entry); -int n_entries =rte_cfgfile_section_num_entries (cfg, sec_name);struct rte_cfgfile_entry entries[n_entries];
examples/qos_sched/cfg_file.h +4 -0
@@ -14,4 +14,8 @@ int cfg_load_pipe(struct rte_cfgfile *cfg, struct rte_sched_pipe_params *pipe);int cfg_load_subport (struct rte_cfgfile *cfg,struct rte_sched_subport_params *subport); +int cfg_load_subport_profile (struct rte_cfgfile *cfg, +struct rte_sched_subport_profile_params + *subport_profile); +#endif
examples/qos_sched/init.c +20 -4
@@ -196,15 +196,20 @@ static struct rte_sched_pipe_params pipe_profiles[MAX_SCHED_PIPE_PROFILES] = { }, }; -struct rte_sched_subport_params subport_params[MAX_SCHED_SUBPORTS ] = { +static struct rte_sched_subport_profile_params + subport_profile[MAX_SCHED_SUBPORT_PROFILES ] = { { .tb_rate =1250000000 , .tb_size =1000000 , - .tc_rate = {1250000000 ,1250000000 ,1250000000 ,1250000000 ,1250000000 ,1250000000 ,1250000000 ,1250000000 ,1250000000 ,1250000000 ,1250000000 ,1250000000 ,1250000000 }, .tc_period =10 , + }, +}; + +struct rte_sched_subport_params subport_params[MAX_SCHED_SUBPORTS ] = { + { .n_pipes_per_subport_enabled =4096 , .qsize = {64 ,64 ,64 ,64 ,64 ,64 ,64 ,64 ,64 ,64 ,64 ,64 ,64 }, .pipe_profiles = pipe_profiles,
@@ -289,6 +294,9 @@ struct rte_sched_port_params port_params = { .mtu = 6 + 6 + 4 + 4 + 2 + 1500, .frame_overhead = RTE_SCHED_FRAME_OVERHEAD_DEFAULT, .n_subports_per_port = 1, + .n_subport_profiles = 1, + .subport_profiles = subport_profile, + .n_max_subport_profiles = MAX_SCHED_SUBPORT_PROFILES, .n_pipes_per_subport = MAX_SCHED_PIPES, };
@@ -320,8 +328,15 @@ app_init_sched_port(uint32_t portid, uint32_t socketid)for (subport =0 ; subport < port_params.n_subports_per_port; subport ++) { err =rte_sched_subport_config (port, subport, &subport_params[subport]);if (err) { -rte_exit (EXIT_FAILURE ,"Unable to config sched subport %u, err=%d\n" , - subport, err); +rte_exit (EXIT_FAILURE ,"Unable to config schedi " +"subport %u, err=%d\n" , subport, err); + } + + err =rte_sched_subport_profile_config (port, subport,0 ); +if (err) { +rte_exit (EXIT_FAILURE ,"failed to configure " +"profile err=%d\n" , err); + } uint32_t n_pipes_per_subport =
@@ -354,6 +369,7 @@ app_load_cfg_profile(const char *profile)cfg_load_port (file, &port_params);cfg_load_subport (file, subport_params); +cfg_load_subport_profile (file, subport_profile);cfg_load_pipe (file, pipe_profiles);rte_cfgfile_close (file);
examples/qos_sched/main.h +1 -0
@@ -51,6 +51,7 @@ extern "C" {#define MAX_SCHED_SUBPORTS 8#define MAX_SCHED_PIPES 4096#define MAX_SCHED_PIPE_PROFILES 256 +#define MAX_SCHED_SUBPORT_PROFILES 8#ifndef APP_COLLECT_STAT #define APP_COLLECT_STAT 1
examples/qos_sched/profile.cfg +3 -0
@@ -26,6 +26,9 @@ number of subports per port = 1 number of pipes per subport = 4096 queue sizes = 64 64 64 64 64 64 64 64 64 64 64 64 64 +subport 0-8 = 0 ; These subports are configured with subport profile 0 + +[subport profile 0] tb rate = 1250000000 ; Bytes per second tb size = 1000000 ; Bytes
Signature · 1 line
2.7.4
PATCH v3 6/9 example/ip_pipeline: add dynamic config of subport
In reply to Savinay DharmappaModify 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
--- 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(-)
examples/ip_pipeline/cli.c +8 -6
@@ -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 ;
examples/ip_pipeline/tmgr.c +24 -2
@@ -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; }
examples/ip_pipeline/tmgr.h +2 -1
@@ -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);
Signature · 1 line
2.7.4
PATCH v3 7/9 drivers/softnic: add dynamic config of subport
In reply to Savinay DharmappaModify the softnic drivers to build the hierarchical scheduler with default subport bandwidth profile. It also allows to configure a subport with different subport bandwidth profile dynamically.
--- drivers/net/softnic/rte_eth_softnic_internals.h | 9 + drivers/net/softnic/rte_eth_softnic_tm.c | 223 +++++++++++++++++++----- 2 files changed, 187 insertions(+), 45 deletions(-)
drivers/net/softnic/rte_eth_softnic_internals.h +9 -0
@@ -164,10 +164,19 @@ TAILQ_HEAD(softnic_link_list, softnic_link);#ifndef TM_MAX_PIPE_PROFILE #define TM_MAX_PIPE_PROFILE 256#endif + +#ifndef TM_MAX_SUBPORT_PROFILE +#define TM_MAX_SUBPORT_PROFILE 256 +#endif +struct tm_params {struct rte_sched_port_params port_params;struct rte_sched_subport_params subport_params[TM_MAX_SUBPORTS ]; +struct rte_sched_subport_profile_params + subport_profiles[TM_MAX_SUBPORT_PROFILE ]; +uint32_t n_subport_profiles; +uint32_t subport_to_profile[TM_MAX_SUBPORT_PROFILE ];struct rte_sched_pipe_params pipe_profiles[TM_MAX_PIPE_PROFILE ];uint32_t n_pipe_profiles;
drivers/net/softnic/rte_eth_softnic_tm.c +178 -45
301 lines not on this page · raw message
Signature · 1 line
2.7.4
PATCH v3 8/9 app/test_sched: add dynamic config of subport
In reply to Savinay DharmappaModify the test_sched application to build the hierarchical scheduler with default subport bandwidth profile. It also allows to configure a subport with different subport bandwidth profile dynamically
--- app/test/test_sched.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-)
app/test/test_sched.c +16 -2
@@ -21,6 +21,7 @@#define PIPE 1#define TC 2#define QUEUE 0 +#define MAX_SCHED_SUBPORT_PROFILES 8static struct rte_sched_pipe_params pipe_profile[] = { {/* Profile #0 */
@@ -36,15 +37,20 @@ static struct rte_sched_pipe_params pipe_profile[] = { }, }; -static struct rte_sched_subport_params subport_param[] = { +static struct rte_sched_subport_profile_params + subport_profile[] = { { .tb_rate =1250000000 , .tb_size =1000000 , - .tc_rate = {1250000000 ,1250000000 ,1250000000 ,1250000000 ,1250000000 ,1250000000 ,1250000000 ,1250000000 ,1250000000 ,1250000000 ,1250000000 ,1250000000 ,1250000000 }, .tc_period =10 , + }, +}; + +static struct rte_sched_subport_params subport_param[] = { + { .n_pipes_per_subport_enabled =1024 , .qsize = {32 ,32 ,32 ,32 ,32 ,32 ,32 ,32 ,32 ,32 ,32 ,32 ,32 }, .pipe_profiles = pipe_profile,
@@ -59,6 +65,9 @@ static struct rte_sched_port_params port_param = { .mtu = 1522, .frame_overhead = RTE_SCHED_FRAME_OVERHEAD_DEFAULT, .n_subports_per_port = 1, + .n_subport_profiles = 1, + .subport_profiles = subport_profile, + .n_max_subport_profiles = MAX_SCHED_SUBPORT_PROFILES, .n_pipes_per_subport = 1024, };
@@ -66,6 +75,7 @@ static struct rte_sched_port_params port_param = {#define MBUF_DATA_SZ (2048 + RTE_PKTMBUF_HEADROOM)#define MEMPOOL_CACHE_SZ 0#define SOCKET 0 +#define DEFAULT_PROFILE 0 static struct rte_mempool *
@@ -141,6 +151,10 @@ test_sched(void) err =rte_sched_subport_config (port,SUBPORT , subport_param);TEST_ASSERT_SUCCESS (err,"Error config sched, err=%d\n" , err); + err =rte_sched_subport_profile_config (port,SUBPORT , +DEFAULT_PROFILE ); +TEST_ASSERT_SUCCESS (err,"Error config sched, err=%d\n" , err); +for (pipe =0 ; pipe < subport_param[0 ].n_pipes_per_subport_enabled; pipe++) { err =rte_sched_pipe_config (port,SUBPORT , pipe,0 );TEST_ASSERT_SUCCESS (err,"Error config sched pipe %u, err=%d\n" , pipe, err);
Signature · 1 line
2.7.4
PATCH v3 9/9 sched: remove the redundant code
In reply to Savinay DharmappaRemove redundant data structure fields references from functions and subport level data structures. It also update the release and deprecation note.
--- doc/guides/rel_notes/deprecation.rst | 6 -- doc/guides/rel_notes/release_20_11.rst | 4 ++ lib/librte_sched/rte_sched.c | 115 +-------------------------------- lib/librte_sched/rte_sched.h | 12 ---- 4 files changed, 6 insertions(+), 131 deletions(-)
doc/guides/rel_notes/deprecation.rst +0 -6
@@ -318,12 +318,6 @@ Deprecation Notices in "rte_sched.h". These changes are aligned to improvements suggested in the RFC https://mails.dpdk.org/archives/dev/2018-November/120035.html. -* sched: To allow dynamic configuration of the subport bandwidth profile, - changes will be made to data structures ``rte_sched_subport_params``, - ``rte_sched_port_params`` and new data structure, API functions will be - defined in ``rte_sched.h``. These changes are aligned as suggested in the - RFC https://mails.dpdk.org/archives/dev/2020-July/175161.html - * metrics: The function ``rte_metrics_init`` will have a non-void return in order to notify errors instead of calling ``rte_exit``.
doc/guides/rel_notes/release_20_11.rst +4 -0
@@ -84,6 +84,10 @@ API Changes Also, make sure to start the actual text at the margin. ======================================================= +* sched: The subport bandwidth configuration parameters such as tb_rate, + tc_rate, tc_period etc., are moved from subport level data structure to + new a data structure. This allows to configure a subport with different + subport bandwidth configuration dynamically. ABI Changes -----------
lib/librte_sched/rte_sched.c +2 -113
163 lines not on this page · raw message
lib/librte_sched/rte_sched.h +0 -12
@@ -149,18 +149,6 @@ struct rte_sched_pipe_params {* byte. */ struct rte_sched_subport_params { -/** Token bucket rate (measured in bytes per second) */ -uint64_t tb_rate; - -/** Token bucket size (measured in credits) */ -uint64_t tb_size; - -/** Traffic class rates (measured in bytes per second) */ -uint64_t tc_rate[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE ]; - -/** Enforcement period for rates (measured in milliseconds) */ -uint64_t tc_period; -/** Number of subport pipes. * The subport can enable/allocate fewer pipes than the maximum * number set through struct port_params::n_max_pipes_per_subport,
Signature · 1 line
2.7.4
v4 cover Enable dynamic config of subport bandwidth
In reply to Savinay DharmappaDPDK sched library allows runtime configuration of the pipe profiles to the pipes of the subport once scheduler hierarchy is constructed. However, to change the subport level bandwidth, existing hierarchy needs to be dismantled and whole process of building hierarchy under subport nodes needs to be repeated which might result in router downtime. Furthermore, due to lack of dynamic configuration of the subport bandwidth profile configuration (shaper and Traffic class rates), the user application is unable to dynamically re-distribute the excess-bandwidth of one subport among other subports in the scheduler hierarchy. Therefore, it is also not possible to adjust the subport bandwidth profile in sync with dynamic changes in pipe profiles of subscribers who want to consume higher bandwidth opportunistically.
This patch series implements dynamic configuration of the subport bandwidth profile to overcome the runtime situation when group of subscribers are not using the allotted bandwidth and dynamic bandwidth re-distribution is needed the without making any structural changes in the hierarchy.
The implementation work includes refactoring the existing data structures defined for port and subport level, new APIs for adding subport level bandwidth profiles that can be used in runtime.
Savinay Dharmappa (9):
sched: add support profile data structure
sched: add subport profile table
sched: add subport profile add and config api
sched: update grinder credit and pipe config function example/qos_sched: add dynamic config of subport example/ip_pipeline: add dynamic config of subport drivers/softnic: add dynamic config of subport app/test_sched: add dynamic config of subport
sched: remove the redundant code
app/test/test_sched.c | 18 +- doc/guides/rel_notes/deprecation.rst | 6 - doc/guides/rel_notes/release_20_11.rst | 4 + drivers/net/softnic/rte_eth_softnic_internals.h | 9 + drivers/net/softnic/rte_eth_softnic_tm.c | 223 ++++++++--- examples/ip_pipeline/cli.c | 14 +- examples/ip_pipeline/tmgr.c | 26 +- examples/ip_pipeline/tmgr.h | 3 +- examples/qos_sched/cfg_file.c | 151 ++++---- examples/qos_sched/cfg_file.h | 4 + examples/qos_sched/init.c | 24 +- examples/qos_sched/main.h | 1 + examples/qos_sched/profile.cfg | 3 + lib/librte_sched/rte_sched.c | 479 +++++++++++++++++------- lib/librte_sched/rte_sched.h | 82 +++- lib/librte_sched/rte_sched_version.map | 2 + 16 files changed, 771 insertions(+), 278 deletions(-)
Signature · 1 line
2.7.4
PATCH v4 1/9 sched: add support profile data structure
Add subport profile data structure to support dynamic configuration of subport bandwidth
--- lib/librte_sched/rte_sched.c | 10 ++++++++++ lib/librte_sched/rte_sched.h | 25 +++++++++++++++++++++++++ 2 files changed, 35 insertions(+)
lib/librte_sched/rte_sched.c +10 -0
@@ -101,6 +101,16 @@ enum grinder_state {e_GRINDER_READ_MBUF }; +struct rte_sched_subport_profile { +/* Token bucket (TB) */ +uint64_t tb_period; +uint64_t tb_credits_per_period; +uint64_t tb_size; + +uint64_t tc_credits_per_period[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE ]; +uint64_t tc_period; +}; +struct rte_sched_grinder {/* Pipe cache */ uint16_t pcache_qmask[RTE_SCHED_GRINDER_PCACHE_SIZE ];
lib/librte_sched/rte_sched.h +25 -0
@@ -192,6 +192,20 @@ struct rte_sched_subport_params {#endif }; +struct rte_sched_subport_profile_params { +/** Token bucket rate (measured in bytes per second) */ +uint64_t tb_rate; + +/** Token bucket size (measured in credits) */ +uint64_t tb_size; + +/** Traffic class rates (measured in bytes per second) */ +uint64_t tc_rate[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE ]; + +/** Enforcement period for rates (measured in milliseconds) */ +uint64_t tc_period; +}; +/** Subport statistics */ struct rte_sched_subport_stats {/** Number of packets successfully written */
@@ -254,6 +268,17 @@ struct rte_sched_port_params {/** Number of subports */ uint32_t n_subports_per_port; +/** subport profile table. +* Every pipe is configured using one of the profiles from this table. +*/ +struct rte_sched_subport_profile_params *subport_profiles; + +/** Profiles in the pipe profile table */ +uint32_t n_subport_profiles; + +/** Max allowed profiles in the pipe profile table */ +uint32_t n_max_subport_profiles; +/** Maximum number of subport pipes. * This parameter is used to reserve a fixed number of bits * in struct rte_mbuf::sched.queue_id for the pipe_id for all
Signature · 1 line
2.7.4
PATCH v4 2/9 sched: add subport profile table
In reply to Savinay DharmappaAdd subport profile table to internal port data structure and update the port config function.
--- lib/librte_sched/rte_sched.c | 185 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 182 insertions(+), 3 deletions(-)
lib/librte_sched/rte_sched.c +182 -3
@@ -222,6 +222,8 @@ struct rte_sched_port {uint16_t pipe_queue[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE ];uint8_t pipe_tc[RTE_SCHED_QUEUES_PER_PIPE ];uint8_t tc_queue[RTE_SCHED_QUEUES_PER_PIPE ]; +uint32_t n_subport_profiles; +uint32_t n_max_subport_profiles;uint64_t rate;uint32_t mtu;uint32_t frame_overhead;
@@ -240,6 +242,7 @@ struct rte_sched_port {uint32_t subport_id;/* Large data structures */ +struct rte_sched_subport_profile *subport_profiles; struct rte_sched_subport *subports[0] __rte_cache_aligned; } __rte_cache_aligned;
@@ -386,8 +389,60 @@ pipe_profile_check(struct rte_sched_pipe_params *params, }static int +subport_profile_check (struct rte_sched_subport_profile_params *params, +uint64_t rate) +{ +uint32_t i; + +/* Check user parameters */ +if (params ==NULL ) { +RTE_LOG (ERR ,SCHED ,"%s: " +"Incorrect value for parameter params\n" , __func__); +return -EINVAL ; + } + +if (params->tb_rate ==0 || params->tb_rate > rate) { +RTE_LOG (ERR ,SCHED ,"%s: " +"Incorrect value for tb rate\n" , __func__); +return -EINVAL ; + } + +if (params->tb_size ==0 ) { +RTE_LOG (ERR ,SCHED ,"%s: " +"Incorrect value for tb size\n" , __func__); +return -EINVAL ; + } + +for (i =0 ; i <RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE ; i++) { +uint64_t tc_rate = params->tc_rate[i]; + +if (tc_rate ==0 || (tc_rate > params->tb_rate)) { +RTE_LOG (ERR ,SCHED ,"%s: " +"Incorrect value for tc rate\n" , __func__); +return -EINVAL ; + } + } + +if (params->tc_rate[RTE_SCHED_TRAFFIC_CLASS_BE ] ==0 ) { +RTE_LOG (ERR ,SCHED ,"%s: " +"Incorrect tc rate(best effort)\n" , __func__); +return -EINVAL ; + } + +if (params->tc_period ==0 ) { +RTE_LOG (ERR ,SCHED ,"%s: " +"Incorrect value for tc period\n" , __func__); +return -EINVAL ; + } + +return 0 ; +} + +static int rte_sched_port_check_params (struct rte_sched_port_params *params) { +uint32_t i; +if (params ==NULL ) {RTE_LOG (ERR ,SCHED ,"%s: Incorrect value for parameter params\n" , __func__);
@@ -424,6 +479,29 @@ rte_sched_port_check_params(struct rte_sched_port_params *params)return -EINVAL ; } +if (params->subport_profiles ==NULL || + params->n_subport_profiles ==0 || + params->n_max_subport_profiles ==0 || + params->n_subport_profiles > params->n_max_subport_profiles) { +RTE_LOG (ERR ,SCHED , +"%s: Incorrect value for subport profiles\n" , __func__); +return -EINVAL ; + } + +for (i =0 ; i < params->n_subport_profiles; i++) { +struct rte_sched_subport_profile_params *p = + params->subport_profiles + i; +int status; + + status =subport_profile_check (p, params->rate); +if (status !=0 ) { +RTE_LOG (ERR ,SCHED , +"%s: subport profile check failed(%d)\n" , + __func__, status); +return -EINVAL ; + } + } +/* n_pipes_per_subport: non-zero, power of 2 */ if (params->n_pipes_per_subport ==0 || !rte_is_power_of_2 (params->n_pipes_per_subport)) {
@@ -565,6 +643,42 @@ rte_sched_port_log_pipe_profile(struct rte_sched_subport *subport, uint32_t i) p->wrr_cost[0], p->wrr_cost[1], p->wrr_cost[2], p->wrr_cost[3]); } +static void +rte_sched_port_log_subport_profile (struct rte_sched_port *port,uint32_t i) +{ +struct rte_sched_subport_profile *p = port->subport_profiles + i; + +RTE_LOG (DEBUG ,SCHED ,"Low level config for subport profile %u:\n" +"Token bucket: period = %" PRIu64", credits per period = %" PRIu64"," +"size = %" PRIu64"\n" +"Traffic classes: period = %" PRIu64",\n" +"credits per period = [%" PRIu64", %" PRIu64", %" PRIu64", %" PRIu64 +" %" PRIu64", %" PRIu64", %" PRIu64", %" PRIu64", %" PRIu64", %" PRIu64 +" %" PRIu64", %" PRIu64", %" PRIu64"]\n" , + i, + +/* Token bucket */ + p->tb_period, + p->tb_credits_per_period, + p->tb_size, + +/* Traffic classes */ + p->tc_period, + p->tc_credits_per_period[0 ], + p->tc_credits_per_period[1 ], + p->tc_credits_per_period[2 ], + p->tc_credits_per_period[3 ], + p->tc_credits_per_period[4 ], + p->tc_credits_per_period[5 ], + p->tc_credits_per_period[6 ], + p->tc_credits_per_period[7 ], + p->tc_credits_per_period[8 ], + p->tc_credits_per_period[9 ], + p->tc_credits_per_period[10 ], + p->tc_credits_per_period[11 ], + p->tc_credits_per_period[12 ]); +} +static inline uint64_t rte_sched_time_ms_to_bytes (uint64_t time_ms,uint64_t rate) {
@@ -634,6 +748,37 @@ rte_sched_pipe_profile_convert(struct rte_sched_subport *subport, }static void +rte_sched_subport_profile_convert (struct rte_sched_subport_profile_params *src, +struct rte_sched_subport_profile *dst, +uint64_t rate) +{ +uint32_t i; + +/* Token Bucket */ +if (src->tb_rate == rate) { + dst->tb_credits_per_period =1 ; + dst->tb_period =1 ; + }else { +double tb_rate = (double ) src->tb_rate + / (double ) rate; +double d =RTE_SCHED_TB_RATE_CONFIG_ERR ; + +rte_approx_64 (tb_rate, d, &dst->tb_credits_per_period, + &dst->tb_period); + } + + dst->tb_size = src->tb_size; + +/* Traffic Classes */ + dst->tc_period =rte_sched_time_ms_to_bytes (src->tc_period, rate); + +for (i =0 ; i <RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE ; i++) + dst->tc_credits_per_period[i] + =rte_sched_time_ms_to_bytes (src->tc_period, + src->tc_rate[i]); +} + +static void rte_sched_subport_config_pipe_profile_table (struct rte_sched_subport *subport,struct rte_sched_subport_params *params,uint64_t rate) {
@@ -657,6 +802,24 @@ rte_sched_subport_config_pipe_profile_table(struct rte_sched_subport *subport, } } +static void +rte_sched_port_config_subport_profile_table (struct rte_sched_port *port, +struct rte_sched_port_params *params, +uint64_t rate) +{ +uint32_t i; + +for (i =0 ; i < port->n_subport_profiles; i++) { +struct rte_sched_subport_profile_params *src + = params->subport_profiles + i; +struct rte_sched_subport_profile *dst + = port->subport_profiles + i; + +rte_sched_subport_profile_convert (src, dst, rate); +rte_sched_port_log_subport_profile (port, i); + } +} + static int rte_sched_subport_check_params(struct rte_sched_subport_params *params, uint32_t n_max_pipes_per_subport,
@@ -803,7 +966,7 @@ struct rte_sched_port * rte_sched_port_config(struct rte_sched_port_params *params) {struct rte_sched_port *port =NULL ; -uint32_t size0, size1; +uint32_t size0, size1, size2;uint32_t cycles_per_byte;uint32_t i, j;int status;
@@ -818,10 +981,21 @@ rte_sched_port_config(struct rte_sched_port_params *params) size0 =sizeof (struct rte_sched_port ); size1 = params->n_subports_per_port *sizeof (struct rte_sched_subport *); + size2 = params->n_max_subport_profiles * +sizeof (struct rte_sched_subport_profile );/* Allocate memory to store the data structures */ - port =rte_zmalloc_socket ("qos_params" , size0 + size1,RTE_CACHE_LINE_SIZE , - params->socket); + port =rte_zmalloc_socket ("qos_params" , size0 + size1, +RTE_CACHE_LINE_SIZE , params->socket); +if (port ==NULL ) { +RTE_LOG (ERR ,SCHED ,"%s: Memory allocation fails\n" , __func__); + +return NULL ; + } + +/* Allocate memory to store the subport profile */ + port->subport_profiles =rte_zmalloc_socket ("subport_profile" , size2, +RTE_CACHE_LINE_SIZE , params->socket);if (port ==NULL ) {RTE_LOG (ERR ,SCHED ,"%s: Memory allocation fails\n" , __func__);
@@ -830,6 +1004,8 @@ rte_sched_port_config(struct rte_sched_port_params *params)/* User parameters */ port->n_subports_per_port = params->n_subports_per_port; + port->n_subport_profiles = params->n_subport_profiles; + port->n_max_subport_profiles = params->n_max_subport_profiles; port->n_pipes_per_subport = params->n_pipes_per_subport; port->n_pipes_per_subport_log2 =__builtin_ctz (params->n_pipes_per_subport);
@@ -860,6 +1036,9 @@ rte_sched_port_config(struct rte_sched_port_params *params) port->time_cpu_bytes =0 ; port->time =0 ; +/* Subport profile table */ +rte_sched_port_config_subport_profile_table (port, params, port->rate); + cycles_per_byte = (rte_get_tsc_hz () <<RTE_SCHED_TIME_SHIFT ) / params->rate; port->inv_cycles_per_byte =rte_reciprocal_value (cycles_per_byte);
Signature · 1 line
2.7.4
PATCH v4 3/9 sched: add subport profile add and config api
In reply to Savinay DharmappaAdd apis to add new subport profile and configure it.
--- lib/librte_sched/rte_sched.c | 118 +++++++++++++++++++++++++++++++++ lib/librte_sched/rte_sched.h | 45 +++++++++++++ lib/librte_sched/rte_sched_version.map | 2 + 3 files changed, 165 insertions(+)
lib/librte_sched/rte_sched.c +118 -0
@@ -174,6 +174,8 @@ struct rte_sched_subport {/* Statistics */ struct rte_sched_subport_stats stats __rte_cache_aligned; +/* subport profile */ +uint32_t profile;/* Subport pipes */ uint32_t n_pipes_per_subport_enabled;uint32_t n_pipe_profiles;
@@ -1343,6 +1345,56 @@ rte_sched_subport_config(struct rte_sched_port *port, }int +rte_sched_subport_profile_config (struct rte_sched_port *port, +uint32_t subport_id, +uint32_t profile_id) +{ +int i; +struct rte_sched_subport_profile *params; +uint32_t n_subports = subport_id +1 ; +struct rte_sched_subport *s; + +if (port ==NULL ) { +RTE_LOG (ERR ,SCHED , +"%s: Incorrect value for parameter port\n" , __func__); +return -EINVAL ; + } + +if (subport_id >= port->n_subports_per_port) { +RTE_LOG (ERR ,SCHED ,"%s: " +"Incorrect value for parameter subport id\n" , __func__); + +rte_sched_free_memory (port, n_subports); +return -EINVAL ; + } + + params = port->subport_profiles + profile_id; + + s = port->subports[subport_id]; + + s->tb_credits = params->tb_size /2 ; + + s->tc_time = port->time + params->tc_period; + +for (i =0 ; i <RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE ; i++) +if (s->qsize[i]) + s->tc_credits[i] = + params->tc_credits_per_period[i]; +else + params->tc_credits_per_period[i] =0 ; + +#ifdef RTE_SCHED_SUBPORT_TC_OV + s->tc_ov_wm_max =rte_sched_time_ms_to_bytes (params->tc_period, + s->pipe_tc_be_rate_max); +#endif + s->profile = profile_id; + +rte_sched_port_log_subport_profile (port, profile_id); + +return 0 ; +} + +int rte_sched_pipe_config(struct rte_sched_port *port, uint32_t subport_id, uint32_t pipe_id,
@@ -1526,6 +1578,72 @@ rte_sched_subport_pipe_profile_add(struct rte_sched_port *port,return 0 ; } +int +rte_sched_port_subport_profile_add (struct rte_sched_port *port, +struct rte_sched_subport_profile_params *params, +uint32_t *subport_profile_id) +{ +int status; +uint32_t i; +struct rte_sched_subport_profile *dst; + +/* Port */ +if (port ==NULL ) { +RTE_LOG (ERR ,SCHED ,"%s: " +"Incorrect value for parameter port\n" , __func__); +return -EINVAL ; + } + +if (params ==NULL ) { +RTE_LOG (ERR ,SCHED ,"%s: " +"Incorrect value for parameter profile\n" , __func__); +return -EINVAL ; + } + +if (subport_profile_id ==NULL ) { +RTE_LOG (ERR ,SCHED ,"%s: " +"Incorrect value for parameter subport_profile_id\n" , + __func__); +return -EINVAL ; + } + + dst = port->subport_profiles + port->n_subport_profiles; + +/* Subport profiles exceeds the max limit */ +if (port->n_subport_profiles >= port->n_max_subport_profiles) { +RTE_LOG (ERR ,SCHED ,"%s: " +"Number of subport profiles exceeds the max limit\n" , + __func__); +return -EINVAL ; + } + + status =subport_profile_check (params, port->rate); +if (status !=0 ) { +RTE_LOG (ERR ,SCHED , +"%s: subport profile check failed(%d)\n" , __func__, status); +return -EINVAL ; + } + +rte_sched_subport_profile_convert (params, dst, port->rate); + +/* Subport profile should not exists */ +for (i =0 ; i < port->n_subport_profiles; i++) +if (memcmp (port->subport_profiles + i, + dst,sizeof (*dst)) ==0 ) { +RTE_LOG (ERR ,SCHED , +"%s: subport profile exists\n" , __func__); +return -EINVAL ; + } + +/* Subport profile commit */ + *subport_profile_id = port->n_subport_profiles; + port->n_subport_profiles++; + +rte_sched_port_log_subport_profile (port, *subport_profile_id); + +return 0 ; +} + static inline uint32_t rte_sched_port_qindex(struct rte_sched_port *port, uint32_t subport,
lib/librte_sched/rte_sched.h +45 -0
57 lines not on this page · raw message
lib/librte_sched/rte_sched_version.map +2 -0
@@ -28,4 +28,6 @@ EXPERIMENTAL { global: rte_sched_subport_pipe_profile_add; + rte_sched_port_subport_profile_add; + rte_sched_subport_profile_config; };
Signature · 1 line
2.7.4
Re: [dpdk-dev] [PATCH v4 3/9] sched: add subport profile add and config api
Hi Savinay,
Trying to summarize the main points of what we discussed and agreed last week for the benefit of all ...
Quoted 187 lines
-----Original Message-----
From: Dharmappa, Savinay <[email protected]>
Sent: Thursday, September 17, 2020 9:43 AM
To: Singh, Jasvinder <[email protected]>; Dumitrescu, Cristian <[email protected]>; [email protected]
Cc: Dharmappa, Savinay <[email protected]>
Subject: [PATCH v4 3/9] sched: add subport profile add and config apiAdd apis to add new subport profile and configure it.
Signed-off-by Savinay Dharmappa <[email protected]>Signed-off-by Jasvinder Singh <[email protected]>--- lib/librte_sched/rte_sched.c | 118 +++++++++++++++++++++++++++++++++ lib/librte_sched/rte_sched.h | 45 +++++++++++++ lib/librte_sched/rte_sched_version.map | 2 + 3 files changed, 165 insertions(+)lib/librte_sched/rte_sched.c +52
-0@@ -174,6 +174,8 @@ struct rte_sched_subport {/* Statistics */ struct rte_sched_subport_stats stats __rte_cache_aligned; +/* subport profile */ +uint32_t profile;/* Subport pipes */ uint32_t n_pipes_per_subport_enabled;uint32_t n_pipe_profiles;@@ -1343,6 +1345,56 @@ rte_sched_subport_config(struct rte_sched_port *port, }int +rte_sched_subport_profile_config (struct rte_sched_port *port, +uint32_t subport_id, +uint32_t profile_id) +{ +int i; +struct rte_sched_subport_profile *params; +uint32_t n_subports = subport_id +1 ; +struct rte_sched_subport *s; + +if (port ==NULL ) { +RTE_LOG (ERR ,SCHED , +"%s: Incorrect value for parameter port\n" , __func__); +return -EINVAL ; + } + +if (subport_id >= port->n_subports_per_port) { +RTE_LOG (ERR ,SCHED ,"%s: " +"Incorrect value for parameter subport id\n" , __func__); + +rte_sched_free_memory (port, n_subports); +return -EINVAL ; + } + + params = port->subport_profiles + profile_id; + + s = port->subports[subport_id]; + + s->tb_credits = params->tb_size /2 ; + + s->tc_time = port->time + params->tc_period; + +for (i =0 ; i <RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE ; i++) +if (s->qsize[i]) + s->tc_credits[i] = + params->tc_credits_per_period[i]; +else + params->tc_credits_per_period[i] =0 ; + +#ifdef RTE_SCHED_SUBPORT_TC_OV + s->tc_ov_wm_max =rte_sched_time_ms_to_bytes (params- >tc_period, + s->pipe_tc_be_rate_max); +#endif + s->profile = profile_id; + +rte_sched_port_log_subport_profile (port, profile_id); + +return 0 ; +} + +int rte_sched_pipe_config(struct
rte_sched_port*port,lib/librte_sched/rte_sched.c +66
-0uint32_t subport_id, uint32_t pipe_id,@@ -1526,6 +1578,72 @@ rte_sched_subport_pipe_profile_add(structrte_sched_port *port, return 0; } +int +rte_sched_port_subport_profile_add (struct rte_sched_port *port, +struct rte_sched_subport_profile_params *params, +uint32_t *subport_profile_id) +{ +int status; +uint32_t i; +struct rte_sched_subport_profile *dst; + +/* Port */ +if (port ==NULL ) { +RTE_LOG (ERR ,SCHED ,"%s: " +"Incorrect value for parameter port\n" , __func__); +return -EINVAL ; + } + +if (params ==NULL ) { +RTE_LOG (ERR ,SCHED ,"%s: " +"Incorrect value for parameter profile\n" , __func__); +return -EINVAL ; + } + +if (subport_profile_id ==NULL ) { +RTE_LOG (ERR ,SCHED ,"%s: " +"Incorrect value for parameter subport_profile_id\n" , + __func__); +return -EINVAL ; + } + + dst = port->subport_profiles + port->n_subport_profiles; + +/* Subport profiles exceeds the max limit */ +if (port->n_subport_profiles >= port->n_max_subport_profiles) { +RTE_LOG (ERR ,SCHED ,"%s: " +"Number of subport profiles exceeds the max limit\n" , + __func__); +return -EINVAL ; + } + + status =subport_profile_check (params, port->rate); +if (status !=0 ) { +RTE_LOG (ERR ,SCHED , +"%s: subport profile check failed(%d)\n" , __func__, status); +return -EINVAL ; + } + +rte_sched_subport_profile_convert (params, dst, port->rate); + +/* Subport profile should not exists */ +for (i =0 ; i < port->n_subport_profiles; i++) +if (memcmp (port->subport_profiles + i, + dst,sizeof (*dst)) ==0 ) { +RTE_LOG (ERR ,SCHED , +"%s: subport profile exists\n" , __func__); +return -EINVAL ; + } + +/* Subport profile commit */ + *subport_profile_id = port->n_subport_profiles; + port->n_subport_profiles++; + +rte_sched_port_log_subport_profile (port, *subport_profile_id); + +return 0 ; +} + static inline uint32_t rte_sched_port_qindex(struct rte_sched_port *port,lib/librte_sched/rte_sched.c +0
-0uint32_t subport,lib/librte_sched/rte_sched.h +12
-0@@ -337,6 +337,29 @@ rte_sched_subport_pipe_profile_add(struct rte_sched_port *port, uint32_t *pipe_profile_id);/** +* @warning +* @b EXPERIMENTAL: this API may change without prior notice. +* +* Hierarchical scheduler subport bandwidth profile add +* Note that this function is safe to use in runtime for adding new +* subport bandwidth profile as it doesn't have any impact on hiearchical +* structure of the scheduler. +* @param port +* Handle to port scheduler instance +* @param struct rte_sched_subport_profile +* Subport bandwidth profile +* @param subport_profile_d
lib/librte_sched/rte_sched.h rte_sched_subport_pipe_profile_add(struct · line 362
Quoted 10 lines
lib/librte_sched/rte_sched.h +10
-0+* Subport profile id +* @return +* 0 upon success, error code otherwise +*/ +__rte_experimental +int +rte_sched_port_subport_profile_add (struct rte_sched_port *port, +struct rte_sched_subport_profile_params *profile, +uint32_t *subport_profile_id); +
Please make sure the internal subport profile table is freed correctly, which is not the case currently.
Quoted 20 lines
lib/librte_sched/rte_sched.h +1
-0+/** * Hierarchical scheduler subport configuration * * @param port
lib/librte_sched/rte_sched.h +11
-0@@ -354,6 +377,28 @@ rte_sched_subport_config(struct rte_sched_port *port, struct rte_sched_subport_params *params);/** +* @warning +* @b EXPERIMENTAL: this API may change without prior notice. +* +* Hierarchical scheduler subport profile configuration +* Note that this function is safe to use in runtime for applying any specific +* subport bandwidth profile as it doesn't have any impact on hiearchical +* structure of the scheduler. +* @param port +* Handle to port scheduler instance +* @param subport_id +* Subport ID
lib/librte_sched/rte_sched.h rte_sched_subport_config(struct rte_sched_port · line 401
Quoted 10 lines
lib/librte_sched/rte_sched.h +10
-0+* @param profile_d +* Subport profile id +* @return +* 0 upon success, error code otherwise +*/ +__rte_experimental +int +rte_sched_subport_profile_config (struct rte_sched_port *port, +uint32_t subport_id, +uint32_t profile_id);
This function should be melted into rte_sched_subport_config(), which should get an extra profile_id argument.
This preserves the symmetry with rte_sched_pipe_config(), which is both an init time and a run-time config update function, and also avoid user confusion and error prone situation when only rte_sched_subport_config() is called while rte_sched_subport_profile_config() is not.
First time rte_sched_subport_config() is called (init time), its params argument should be non-NULL; this argument should be ignored (with NULL as the recommended value) for any subsequent calls. A subport-internal init_done flag could be maintained to distinguish between first and any subsequent calls. This should also be documented in the argument description.
Quoted 10 lines
lib/librte_sched/rte_sched.h +1
-0+/** * Hierarchical scheduler pipe configuration * * @param port
lib/librte_sched/rte_sched_version.map +0
-0
lib/librte_sched/rte_sched_version.map EXPERIMENTAL {
Quoted 7 lines
lib/librte_sched/rte_sched_version.map +2
-1@@ -28,4 +28,6 @@ EXPERIMENTAL { global: rte_sched_subport_pipe_profile_add; + rte_sched_port_subport_profile_add; + rte_sched_subport_profile_config; }; --
Need to increment the ABI version here, as new data structures and API function changes took place, inline with the deprecation note.
Quoted 1 line
2.7.4
PATCH v4 4/9 sched: update grinder credit and pipe config function
In reply to Savinay DharmappaCredits are updated by fetching subport profile parameters from subport profile table. Similarly subport best effort tc is calculated in pipe config.
--- lib/librte_sched/rte_sched.c | 55 ++++++++++++++++++++++++++------------------ 1 file changed, 33 insertions(+), 22 deletions(-)
lib/librte_sched/rte_sched.c +33 -22
@@ -123,6 +123,7 @@ struct rte_sched_grinder {uint32_t productive;uint32_t pindex;struct rte_sched_subport *subport; +struct rte_sched_subport_profile *subport_params;struct rte_sched_pipe *pipe;struct rte_sched_pipe_profile *pipe_params;
@@ -1401,6 +1402,7 @@ rte_sched_pipe_config(struct rte_sched_port *port, int32_t pipe_profile) {struct rte_sched_subport *s; +struct rte_sched_subport_profile *sp;struct rte_sched_pipe *p;struct rte_sched_pipe_profile *params;uint32_t n_subports = subport_id +1 ;
@@ -1441,14 +1443,15 @@ rte_sched_pipe_config(struct rte_sched_port *port,return -EINVAL ; } + sp = port->subport_profiles + s->profile;/* Handle the case when pipe already has a valid configuration */ p = s->pipe + pipe_id;if (p->tb_time) { params = s->pipe_profiles + p->profile;double subport_tc_be_rate = - (double ) s->tc_credits_per_period[RTE_SCHED_TRAFFIC_CLASS_BE ] - / (double ) s->tc_period; + (double )sp->tc_credits_per_period[RTE_SCHED_TRAFFIC_CLASS_BE ] + / (double ) sp->tc_period;double pipe_tc_be_rate = (double ) params->tc_credits_per_period[RTE_SCHED_TRAFFIC_CLASS_BE ] / (double ) params->tc_period;
@@ -1490,8 +1493,8 @@ rte_sched_pipe_config(struct rte_sched_port *port, {/* Subport best effort tc oversubscription */ double subport_tc_be_rate = - (double ) s->tc_credits_per_period[RTE_SCHED_TRAFFIC_CLASS_BE ] - / (double ) s->tc_period; + (double )sp->tc_credits_per_period[RTE_SCHED_TRAFFIC_CLASS_BE ] + / (double ) sp->tc_period;double pipe_tc_be_rate = (double ) params->tc_credits_per_period[RTE_SCHED_TRAFFIC_CLASS_BE ] / (double ) params->tc_period;
@@ -2279,14 +2282,15 @@ grinder_credits_update(struct rte_sched_port *port,struct rte_sched_grinder *grinder = subport->grinder + pos;struct rte_sched_pipe *pipe = grinder->pipe;struct rte_sched_pipe_profile *params = grinder->pipe_params; +struct rte_sched_subport_profile *sp = grinder->subport_params;uint64_t n_periods;uint32_t i;/* Subport TB */ - n_periods = (port->time - subport->tb_time) / subport->tb_period; - subport->tb_credits += n_periods * subport->tb_credits_per_period; - subport->tb_credits =RTE_MIN (subport->tb_credits, subport->tb_size); - subport->tb_time += n_periods * subport->tb_period; + n_periods = (port->time - subport->tb_time) / sp->tb_period; + subport->tb_credits += n_periods * sp->tb_credits_per_period; + subport->tb_credits =RTE_MIN (subport->tb_credits, sp->tb_size); + subport->tb_time += n_periods * sp->tb_period;/* Pipe TB */ n_periods = (port->time - pipe->tb_time) / params->tb_period;
@@ -2297,9 +2301,9 @@ grinder_credits_update(struct rte_sched_port *port,/* Subport TCs */ if (unlikely (port->time >= subport->tc_time)) {for (i =0 ; i <RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE ; i++) - subport->tc_credits[i] = subport->tc_credits_per_period[i]; + subport->tc_credits[i] = sp->tc_credits_per_period[i]; - subport->tc_time = port->time + subport->tc_period; + subport->tc_time = port->time + sp->tc_period; }/* Pipe TCs */
@@ -2315,8 +2319,10 @@ grinder_credits_update(struct rte_sched_port *port,static inline uint64_t grinder_tc_ov_credits_update (struct rte_sched_port *port, -struct rte_sched_subport *subport) +struct rte_sched_subport *subport,uint32_t pos) { +struct rte_sched_grinder *grinder = subport->grinder + pos; +struct rte_sched_subport_profile *sp = grinder->subport_params;uint64_t tc_ov_consumption[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE ];uint64_t tc_consumption =0 , tc_ov_consumption_max;uint64_t tc_ov_wm = subport->tc_ov_wm;
@@ -2326,17 +2332,17 @@ grinder_tc_ov_credits_update(struct rte_sched_port *port,return subport->tc_ov_wm_max;for (i =0 ; i <RTE_SCHED_TRAFFIC_CLASS_BE ; i++) { - tc_ov_consumption[i] = - subport->tc_credits_per_period[i] - subport->tc_credits[i]; + tc_ov_consumption[i] = sp->tc_credits_per_period[i] + - subport->tc_credits[i]; tc_consumption += tc_ov_consumption[i]; } tc_ov_consumption[RTE_SCHED_TRAFFIC_CLASS_BE ] = - subport->tc_credits_per_period[RTE_SCHED_TRAFFIC_CLASS_BE ] - + sp->tc_credits_per_period[RTE_SCHED_TRAFFIC_CLASS_BE ] - subport->tc_credits[RTE_SCHED_TRAFFIC_CLASS_BE ]; tc_ov_consumption_max = - subport->tc_credits_per_period[RTE_SCHED_TRAFFIC_CLASS_BE ] - + sp->tc_credits_per_period[RTE_SCHED_TRAFFIC_CLASS_BE ] - tc_consumption; if (tc_ov_consumption[RTE_SCHED_TRAFFIC_CLASS_BE] >
@@ -2362,14 +2368,15 @@ grinder_credits_update(struct rte_sched_port *port,struct rte_sched_grinder *grinder = subport->grinder + pos;struct rte_sched_pipe *pipe = grinder->pipe;struct rte_sched_pipe_profile *params = grinder->pipe_params; +struct rte_sched_subport_profile *sp = grinder->subport_params;uint64_t n_periods;uint32_t i;/* Subport TB */ - n_periods = (port->time - subport->tb_time) / subport->tb_period; - subport->tb_credits += n_periods * subport->tb_credits_per_period; - subport->tb_credits =RTE_MIN (subport->tb_credits, subport->tb_size); - subport->tb_time += n_periods * subport->tb_period; + n_periods = (port->time - subport->tb_time) / sp->tb_period; + subport->tb_credits += n_periods * sp->tb_credits_per_period; + subport->tb_credits =RTE_MIN (subport->tb_credits, sp->tb_size); + subport->tb_time += n_periods * sp->tb_period;/* Pipe TB */ n_periods = (port->time - pipe->tb_time) / params->tb_period;
@@ -2379,12 +2386,13 @@ grinder_credits_update(struct rte_sched_port *port,/* Subport TCs */ if (unlikely (port->time >= subport->tc_time)) { - subport->tc_ov_wm =grinder_tc_ov_credits_update (port, subport); + subport->tc_ov_wm = +grinder_tc_ov_credits_update (port, subport, pos);for (i =0 ; i <RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE ; i++) - subport->tc_credits[i] = subport->tc_credits_per_period[i]; + subport->tc_credits[i] = sp->tc_credits_per_period[i]; - subport->tc_time = port->time + subport->tc_period; + subport->tc_time = port->time + sp->tc_period; subport->tc_ov_period_id++; }
@@ -2907,6 +2915,9 @@ grinder_handle(struct rte_sched_port *port,struct rte_sched_pipe *pipe = grinder->pipe; grinder->pipe_params = subport->pipe_profiles + pipe->profile; + grinder->subport_params = port->subport_profiles + + subport->profile; +grinder_prefetch_tc_queue_arrays (subport, pos);grinder_credits_update (port, subport, pos);
Signature · 1 line
2.7.4
PATCH v4 5/9 example/qos_sched: add dynamic config of subport
In reply to Savinay DharmappaModify the qos_sched application to build the hierarchical scheduler with default subport bandwidth profile. It also allows to configure a subport with different subport bandwidth profile dynamically.
--- examples/qos_sched/cfg_file.c | 151 ++++++++++++++++++++++++----------------- examples/qos_sched/cfg_file.h | 4 ++ examples/qos_sched/init.c | 24 +++++-- examples/qos_sched/main.h | 1 + examples/qos_sched/profile.cfg | 3 + 5 files changed, 115 insertions(+), 68 deletions(-)
examples/qos_sched/cfg_file.c +87 -64
@@ -143,6 +143,93 @@ cfg_load_pipe(struct rte_cfgfile *cfg, struct rte_sched_pipe_params *pipe_params }int +cfg_load_subport_profile (struct rte_cfgfile *cfg, +struct rte_sched_subport_profile_params *subport_profile) +{ +int i; +const char *entry; +int profiles; + +if (!cfg || !subport_profile) +return -1 ; + + profiles =rte_cfgfile_num_sections (cfg,"subport profile" , +sizeof ("subport profile" ) -1 ); + subport_params[0 ].n_pipe_profiles = profiles; + +for (i =0 ; i < profiles; i++) { +char sec_name[32 ]; +snprintf (sec_name,sizeof (sec_name),"subport profile %d" , i); + + entry =rte_cfgfile_get_entry (cfg, sec_name,"tb rate" ); +if (entry) + subport_profile[i].tb_rate = (uint64_t )atoi (entry); + + entry =rte_cfgfile_get_entry (cfg, sec_name,"tb size" ); +if (entry) + subport_profile[i].tb_size = (uint64_t )atoi (entry); + + entry =rte_cfgfile_get_entry (cfg, sec_name,"tc period" ); +if (entry) + subport_profile[i].tc_period = (uint64_t )atoi (entry); + + entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 0 rate" ); +if (entry) + subport_profile[i].tc_rate[0 ] = (uint64_t )atoi (entry); + + entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 1 rate" ); +if (entry) + subport_profile[i].tc_rate[1 ] = (uint64_t )atoi (entry); + + entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 2 rate" ); +if (entry) + subport_profile[i].tc_rate[2 ] = (uint64_t )atoi (entry); + + entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 3 rate" ); +if (entry) + subport_profile[i].tc_rate[3 ] = (uint64_t )atoi (entry); + + entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 4 rate" ); +if (entry) + subport_profile[i].tc_rate[4 ] = (uint64_t )atoi (entry); + + entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 5 rate" ); +if (entry) + subport_profile[i].tc_rate[5 ] = (uint64_t )atoi (entry); + + entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 6 rate" ); +if (entry) + subport_profile[i].tc_rate[6 ] = (uint64_t )atoi (entry); + + entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 7 rate" ); +if (entry) + subport_profile[i].tc_rate[7 ] = (uint64_t )atoi (entry); + + entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 8 rate" ); +if (entry) + subport_profile[i].tc_rate[8 ] = (uint64_t )atoi (entry); + + entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 9 rate" ); +if (entry) + subport_profile[i].tc_rate[9 ] = (uint64_t )atoi (entry); + + entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 10 rate" ); +if (entry) + subport_profile[i].tc_rate[10 ] = (uint64_t )atoi (entry); + + entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 11 rate" ); +if (entry) + subport_profile[i].tc_rate[11 ] = (uint64_t )atoi (entry); + + entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 12 rate" ); +if (entry) + subport_profile[i].tc_rate[12 ] = (uint64_t )atoi (entry); + } + +return 0 ; +} + +int cfg_load_subport (struct rte_cfgfile *cfg,struct rte_sched_subport_params *subport_params) {const char *entry;
@@ -267,70 +354,6 @@ cfg_load_subport(struct rte_cfgfile *cfg, struct rte_sched_subport_params *subpo } } - entry =rte_cfgfile_get_entry (cfg, sec_name,"tb rate" ); -if (entry) - subport_params[i].tb_rate = (uint64_t )atoi (entry); - - entry =rte_cfgfile_get_entry (cfg, sec_name,"tb size" ); -if (entry) - subport_params[i].tb_size = (uint64_t )atoi (entry); - - entry =rte_cfgfile_get_entry (cfg, sec_name,"tc period" ); -if (entry) - subport_params[i].tc_period = (uint64_t )atoi (entry); - - entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 0 rate" ); -if (entry) - subport_params[i].tc_rate[0 ] = (uint64_t )atoi (entry); - - entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 1 rate" ); -if (entry) - subport_params[i].tc_rate[1 ] = (uint64_t )atoi (entry); - - entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 2 rate" ); -if (entry) - subport_params[i].tc_rate[2 ] = (uint64_t )atoi (entry); - - entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 3 rate" ); -if (entry) - subport_params[i].tc_rate[3 ] = (uint64_t )atoi (entry); - - entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 4 rate" ); -if (entry) - subport_params[i].tc_rate[4 ] = (uint64_t )atoi (entry); - - entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 5 rate" ); -if (entry) - subport_params[i].tc_rate[5 ] = (uint64_t )atoi (entry); - - entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 6 rate" ); -if (entry) - subport_params[i].tc_rate[6 ] = (uint64_t )atoi (entry); - - entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 7 rate" ); -if (entry) - subport_params[i].tc_rate[7 ] = (uint64_t )atoi (entry); - - entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 8 rate" ); -if (entry) - subport_params[i].tc_rate[8 ] = (uint64_t )atoi (entry); - - entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 9 rate" ); -if (entry) - subport_params[i].tc_rate[9 ] = (uint64_t )atoi (entry); - - entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 10 rate" ); -if (entry) - subport_params[i].tc_rate[10 ] = (uint64_t )atoi (entry); - - entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 11 rate" ); -if (entry) - subport_params[i].tc_rate[11 ] = (uint64_t )atoi (entry); - - entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 12 rate" ); -if (entry) - subport_params[i].tc_rate[12 ] = (uint64_t )atoi (entry); -int n_entries =rte_cfgfile_section_num_entries (cfg, sec_name);struct rte_cfgfile_entry entries[n_entries];
examples/qos_sched/cfg_file.h +4 -0
@@ -14,4 +14,8 @@ int cfg_load_pipe(struct rte_cfgfile *cfg, struct rte_sched_pipe_params *pipe);int cfg_load_subport (struct rte_cfgfile *cfg,struct rte_sched_subport_params *subport); +int cfg_load_subport_profile (struct rte_cfgfile *cfg, +struct rte_sched_subport_profile_params + *subport_profile); +#endif
examples/qos_sched/init.c +20 -4
@@ -196,15 +196,20 @@ static struct rte_sched_pipe_params pipe_profiles[MAX_SCHED_PIPE_PROFILES] = { }, }; -struct rte_sched_subport_params subport_params[MAX_SCHED_SUBPORTS ] = { +static struct rte_sched_subport_profile_params + subport_profile[MAX_SCHED_SUBPORT_PROFILES ] = { { .tb_rate =1250000000 , .tb_size =1000000 , - .tc_rate = {1250000000 ,1250000000 ,1250000000 ,1250000000 ,1250000000 ,1250000000 ,1250000000 ,1250000000 ,1250000000 ,1250000000 ,1250000000 ,1250000000 ,1250000000 }, .tc_period =10 , + }, +}; + +struct rte_sched_subport_params subport_params[MAX_SCHED_SUBPORTS ] = { + { .n_pipes_per_subport_enabled =4096 , .qsize = {64 ,64 ,64 ,64 ,64 ,64 ,64 ,64 ,64 ,64 ,64 ,64 ,64 }, .pipe_profiles = pipe_profiles,
@@ -289,6 +294,9 @@ struct rte_sched_port_params port_params = { .mtu = 6 + 6 + 4 + 4 + 2 + 1500, .frame_overhead = RTE_SCHED_FRAME_OVERHEAD_DEFAULT, .n_subports_per_port = 1, + .n_subport_profiles = 1, + .subport_profiles = subport_profile, + .n_max_subport_profiles = MAX_SCHED_SUBPORT_PROFILES, .n_pipes_per_subport = MAX_SCHED_PIPES, };
@@ -320,8 +328,15 @@ app_init_sched_port(uint32_t portid, uint32_t socketid)for (subport =0 ; subport < port_params.n_subports_per_port; subport ++) { err =rte_sched_subport_config (port, subport, &subport_params[subport]);if (err) { -rte_exit (EXIT_FAILURE ,"Unable to config sched subport %u, err=%d\n" , - subport, err); +rte_exit (EXIT_FAILURE ,"Unable to config schedi " +"subport %u, err=%d\n" , subport, err); + } + + err =rte_sched_subport_profile_config (port, subport,0 ); +if (err) { +rte_exit (EXIT_FAILURE ,"failed to configure " +"profile err=%d\n" , err); + } uint32_t n_pipes_per_subport =
@@ -354,6 +369,7 @@ app_load_cfg_profile(const char *profile)cfg_load_port (file, &port_params);cfg_load_subport (file, subport_params); +cfg_load_subport_profile (file, subport_profile);cfg_load_pipe (file, pipe_profiles);rte_cfgfile_close (file);
examples/qos_sched/main.h +1 -0
@@ -51,6 +51,7 @@ extern "C" {#define MAX_SCHED_SUBPORTS 8#define MAX_SCHED_PIPES 4096#define MAX_SCHED_PIPE_PROFILES 256 +#define MAX_SCHED_SUBPORT_PROFILES 8#ifndef APP_COLLECT_STAT #define APP_COLLECT_STAT 1
examples/qos_sched/profile.cfg +3 -0
@@ -26,6 +26,9 @@ number of subports per port = 1 number of pipes per subport = 4096 queue sizes = 64 64 64 64 64 64 64 64 64 64 64 64 64 +subport 0-8 = 0 ; These subports are configured with subport profile 0 + +[subport profile 0] tb rate = 1250000000 ; Bytes per second tb size = 1000000 ; Bytes
Signature · 1 line
2.7.4
PATCH v4 6/9 example/ip_pipeline: add dynamic config of subport
In reply to Savinay DharmappaModify 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
--- 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(-)
examples/ip_pipeline/cli.c +8 -6
@@ -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 ;
examples/ip_pipeline/tmgr.c +24 -2
@@ -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; }
examples/ip_pipeline/tmgr.h +2 -1
@@ -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);
Signature · 1 line
2.7.4
Re: [dpdk-dev] [PATCH v4 6/9] example/ip_pipeline: add dynamic config of subport
Quoted 88 lines
-----Original Message-----
From: Dharmappa, Savinay <[email protected]>
Sent: Thursday, September 17, 2020 9:43 AM
To: Singh, Jasvinder <[email protected]>; Dumitrescu, Cristian <[email protected]>; [email protected]
Cc: Dharmappa, Savinay <[email protected]>
Subject: [PATCH v4 6/9] example/ip_pipeline: add dynamic config of subportModify the
ip_pipelineapplication to build the hierarchical scheduler with default subport bandwidth profile. It also allows to configure a subport with different subport bandwidth profile dynamicallySigned-off-by Savinay Dharmappa <[email protected]>--- 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(-)examples/ip_pipeline/cli.c +5
-4@@ -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 ;examples/ip_pipeline/cli.c +2
-1}@@ -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" );examples/ip_pipeline/cli.c +1
-1return ; }@@ -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 ;examples/ip_pipeline/tmgr.c +0
-0
examples/ip_pipeline/tmgr.c line 16
Quoted 6 lines
examples/ip_pipeline/tmgr.c +3
-0@@ -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.
Quoted 84 lines
examples/ip_pipeline/tmgr.c +7
-2static 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++;examples/ip_pipeline/tmgr.c +3
-0return 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 ;examples/ip_pipeline/tmgr.c +7
-0s =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++) {examples/ip_pipeline/tmgr.c +4
-0status = 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; }examples/ip_pipeline/tmgr.h +2
-2@@ -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 v4 7/9 drivers/softnic: add dynamic config of subport
In reply to Savinay DharmappaModify the softnic drivers to build the hierarchical scheduler with default subport bandwidth profile. It also allows to configure a subport with different subport bandwidth profile dynamically.
--- drivers/net/softnic/rte_eth_softnic_internals.h | 9 + drivers/net/softnic/rte_eth_softnic_tm.c | 223 +++++++++++++++++++----- 2 files changed, 187 insertions(+), 45 deletions(-)
drivers/net/softnic/rte_eth_softnic_internals.h +9 -0
@@ -164,10 +164,19 @@ TAILQ_HEAD(softnic_link_list, softnic_link);#ifndef TM_MAX_PIPE_PROFILE #define TM_MAX_PIPE_PROFILE 256#endif + +#ifndef TM_MAX_SUBPORT_PROFILE +#define TM_MAX_SUBPORT_PROFILE 256 +#endif +struct tm_params {struct rte_sched_port_params port_params;struct rte_sched_subport_params subport_params[TM_MAX_SUBPORTS ]; +struct rte_sched_subport_profile_params + subport_profiles[TM_MAX_SUBPORT_PROFILE ]; +uint32_t n_subport_profiles; +uint32_t subport_to_profile[TM_MAX_SUBPORT_PROFILE ];struct rte_sched_pipe_params pipe_profiles[TM_MAX_PIPE_PROFILE ];uint32_t n_pipe_profiles;
drivers/net/softnic/rte_eth_softnic_tm.c +178 -45
301 lines not on this page · raw message
Signature · 1 line
2.7.4
PATCH v4 8/9 app/test_sched: add dynamic config of subport
In reply to Savinay DharmappaModify the test_sched application to build the hierarchical scheduler with default subport bandwidth profile. It also allows to configure a subport with different subport bandwidth profile dynamically
--- app/test/test_sched.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-)
app/test/test_sched.c +16 -2
@@ -21,6 +21,7 @@#define PIPE 1#define TC 2#define QUEUE 0 +#define MAX_SCHED_SUBPORT_PROFILES 8static struct rte_sched_pipe_params pipe_profile[] = { {/* Profile #0 */
@@ -36,15 +37,20 @@ static struct rte_sched_pipe_params pipe_profile[] = { }, }; -static struct rte_sched_subport_params subport_param[] = { +static struct rte_sched_subport_profile_params + subport_profile[] = { { .tb_rate =1250000000 , .tb_size =1000000 , - .tc_rate = {1250000000 ,1250000000 ,1250000000 ,1250000000 ,1250000000 ,1250000000 ,1250000000 ,1250000000 ,1250000000 ,1250000000 ,1250000000 ,1250000000 ,1250000000 }, .tc_period =10 , + }, +}; + +static struct rte_sched_subport_params subport_param[] = { + { .n_pipes_per_subport_enabled =1024 , .qsize = {32 ,32 ,32 ,32 ,32 ,32 ,32 ,32 ,32 ,32 ,32 ,32 ,32 }, .pipe_profiles = pipe_profile,
@@ -59,6 +65,9 @@ static struct rte_sched_port_params port_param = { .mtu = 1522, .frame_overhead = RTE_SCHED_FRAME_OVERHEAD_DEFAULT, .n_subports_per_port = 1, + .n_subport_profiles = 1, + .subport_profiles = subport_profile, + .n_max_subport_profiles = MAX_SCHED_SUBPORT_PROFILES, .n_pipes_per_subport = 1024, };
@@ -66,6 +75,7 @@ static struct rte_sched_port_params port_param = {#define MBUF_DATA_SZ (2048 + RTE_PKTMBUF_HEADROOM)#define MEMPOOL_CACHE_SZ 0#define SOCKET 0 +#define DEFAULT_PROFILE 0 static struct rte_mempool *
@@ -141,6 +151,10 @@ test_sched(void) err =rte_sched_subport_config (port,SUBPORT , subport_param);TEST_ASSERT_SUCCESS (err,"Error config sched, err=%d\n" , err); + err =rte_sched_subport_profile_config (port,SUBPORT , +DEFAULT_PROFILE ); +TEST_ASSERT_SUCCESS (err,"Error config sched, err=%d\n" , err); +for (pipe =0 ; pipe < subport_param[0 ].n_pipes_per_subport_enabled; pipe++) { err =rte_sched_pipe_config (port,SUBPORT , pipe,0 );TEST_ASSERT_SUCCESS (err,"Error config sched pipe %u, err=%d\n" , pipe, err);
Signature · 1 line
2.7.4
PATCH v4 9/9 sched: remove the redundant code
In reply to Savinay DharmappaRemove redundant data structure fields references from functions and subport level data structures. It also update the release and deprecation note.
--- doc/guides/rel_notes/deprecation.rst | 6 -- doc/guides/rel_notes/release_20_11.rst | 4 ++ lib/librte_sched/rte_sched.c | 115 +-------------------------------- lib/librte_sched/rte_sched.h | 12 ---- 4 files changed, 6 insertions(+), 131 deletions(-)
doc/guides/rel_notes/deprecation.rst +0 -6
@@ -294,12 +294,6 @@ Deprecation Notices in "rte_sched.h". These changes are aligned to improvements suggested in the RFC https://mails.dpdk.org/archives/dev/2018-November/120035.html. -* sched: To allow dynamic configuration of the subport bandwidth profile, - changes will be made to data structures ``rte_sched_subport_params``, - ``rte_sched_port_params`` and new data structure, API functions will be - defined in ``rte_sched.h``. These changes are aligned as suggested in the - RFC https://mails.dpdk.org/archives/dev/2020-July/175161.html - * metrics: The function ``rte_metrics_init`` will have a non-void return in order to notify errors instead of calling ``rte_exit``.
doc/guides/rel_notes/release_20_11.rst +4 -0
@@ -68,6 +68,10 @@ Removed Items Also, make sure to start the actual text at the margin. ======================================================= +* sched: The subport bandwidth configuration parameters such as tb_rate, + tc_rate, tc_period etc., are moved from subport level data structure to + new a data structure. This allows to configure a subport with different + subport bandwidth configuration dynamically. API Changes -----------
lib/librte_sched/rte_sched.c +2 -113
163 lines not on this page · raw message
lib/librte_sched/rte_sched.h +0 -12
@@ -149,18 +149,6 @@ struct rte_sched_pipe_params {* byte. */ struct rte_sched_subport_params { -/** Token bucket rate (measured in bytes per second) */ -uint64_t tb_rate; - -/** Token bucket size (measured in credits) */ -uint64_t tb_size; - -/** Traffic class rates (measured in bytes per second) */ -uint64_t tc_rate[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE ]; - -/** Enforcement period for rates (measured in milliseconds) */ -uint64_t tc_period; -/** Number of subport pipes. * The subport can enable/allocate fewer pipes than the maximum * number set through struct port_params::n_max_pipes_per_subport,
Signature · 1 line
2.7.4
v5 cover Enable dynamic config of subport bandwidth
In reply to Savinay DharmappaDPDK sched library allows runtime configuration of the pipe profiles to the pipes of the subport once scheduler hierarchy is constructed. However, to change the subport level bandwidth, existing hierarchy needs to be dismantled and whole process of building hierarchy under subport nodes needs to be repeated which might result in router downtime. Furthermore, due to lack of dynamic configuration of the subport bandwidth profile configuration (shaper and Traffic class rates), the user application is unable to dynamically re-distribute the excess-bandwidth of one subport among other subports in the scheduler hierarchy. Therefore, it is also not possible to adjust the subport bandwidth profile in sync with dynamic changes in pipe profiles of subscribers who want to consume higher bandwidth opportunistically.
This patch series implements dynamic configuration of the subport bandwidth profile to overcome the runtime situation when group of subscribers are not using the allotted bandwidth and dynamic bandwidth re-distribution is needed the without making any structural changes in the hierarchy.
The implementation work includes refactoring the existing api and data structures defined for port and subport level, new APIs for adding subport level bandwidth profiles that can be used in runtime
Savinay Dharmappa (9):
sched: add support profile table
sched: add subport profile add api
sched : add dynamic config of subport bandwidth
sched: update grinder credit and pipe config function example/qos_sched: add dynamic config of subport example/ip_pipeline: add dynamic config of subport drivers/softnic: add dynamic config of subport app/test_sched: add dynamic config of subport sched : remove redundant code
app/test/test_sched.c | 17 +- doc/guides/rel_notes/deprecation.rst | 6 - doc/guides/rel_notes/release_20_11.rst | 4 + .../net/softnic/rte_eth_softnic_internals.h | 18 +- drivers/net/softnic/rte_eth_softnic_tm.c | 224 ++++-- examples/ip_pipeline/cli.c | 17 +- examples/ip_pipeline/tmgr.c | 53 +- examples/ip_pipeline/tmgr.h | 7 +- examples/qos_sched/cfg_file.c | 151 ++-- examples/qos_sched/cfg_file.h | 4 + examples/qos_sched/init.c | 21 +- examples/qos_sched/main.h | 1 + examples/qos_sched/profile.cfg | 3 + lib/librte_sched/rte_sched.c | 701 ++++++++++++------ lib/librte_sched/rte_sched.h | 74 +- lib/librte_sched/rte_sched_version.map | 2 + 16 files changed, 891 insertions(+), 412 deletions(-)
Signature · 1 line
2.17.1
PATCH v5 1/9 sched: add support profile table
Add subport profile data structure, subport profile table to internal port data structure and update the port config function.
--- lib/librte_sched/rte_sched.c | 197 ++++++++++++++++++++++++++++++++++- lib/librte_sched/rte_sched.h | 25 +++++ 2 files changed, 219 insertions(+), 3 deletions(-)
lib/librte_sched/rte_sched.c +194 -3
@@ -101,6 +101,16 @@ enum grinder_state {e_GRINDER_READ_MBUF }; +struct rte_sched_subport_profile { +/* Token bucket (TB) */ +uint64_t tb_period; +uint64_t tb_credits_per_period; +uint64_t tb_size; + +uint64_t tc_credits_per_period[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE ]; +uint64_t tc_period; +}; +struct rte_sched_grinder {/* Pipe cache */ uint16_t pcache_qmask[RTE_SCHED_GRINDER_PCACHE_SIZE ];
@@ -212,6 +222,8 @@ struct rte_sched_port {uint16_t pipe_queue[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE ];uint8_t pipe_tc[RTE_SCHED_QUEUES_PER_PIPE ];uint8_t tc_queue[RTE_SCHED_QUEUES_PER_PIPE ]; +uint32_t n_subport_profiles; +uint32_t n_max_subport_profiles;uint64_t rate;uint32_t mtu;uint32_t frame_overhead;
@@ -230,6 +242,7 @@ struct rte_sched_port {uint32_t subport_id;/* Large data structures */ +struct rte_sched_subport_profile *subport_profiles; struct rte_sched_subport *subports[0] __rte_cache_aligned; } __rte_cache_aligned;
@@ -375,9 +388,61 @@ pipe_profile_check(struct rte_sched_pipe_params *params,return 0 ; } +static int +subport_profile_check (struct rte_sched_subport_profile_params *params, +uint64_t rate) +{ +uint32_t i; + +/* Check user parameters */ +if (params ==NULL ) { +RTE_LOG (ERR ,SCHED ,"%s: " +"Incorrect value for parameter params\n" , __func__); +return -EINVAL ; + } + +if (params->tb_rate ==0 || params->tb_rate > rate) { +RTE_LOG (ERR ,SCHED ,"%s: " +"Incorrect value for tb rate\n" , __func__); +return -EINVAL ; + } + +if (params->tb_size ==0 ) { +RTE_LOG (ERR ,SCHED ,"%s: " +"Incorrect value for tb size\n" , __func__); +return -EINVAL ; + } + +for (i =0 ; i <RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE ; i++) { +uint64_t tc_rate = params->tc_rate[i]; + +if (tc_rate ==0 || (tc_rate > params->tb_rate)) { +RTE_LOG (ERR ,SCHED ,"%s: " +"Incorrect value for tc rate\n" , __func__); +return -EINVAL ; + } + } + +if (params->tc_rate[RTE_SCHED_TRAFFIC_CLASS_BE ] ==0 ) { +RTE_LOG (ERR ,SCHED ,"%s: " +"Incorrect tc rate(best effort)\n" , __func__); +return -EINVAL ; + } + +if (params->tc_period ==0 ) { +RTE_LOG (ERR ,SCHED ,"%s: " +"Incorrect value for tc period\n" , __func__); +return -EINVAL ; + } + +return 0 ; +} +static int rte_sched_port_check_params (struct rte_sched_port_params *params) { +uint32_t i; +if (params ==NULL ) {RTE_LOG (ERR ,SCHED ,"%s: Incorrect value for parameter params\n" , __func__);
@@ -414,6 +479,29 @@ rte_sched_port_check_params(struct rte_sched_port_params *params)return -EINVAL ; } +if (params->subport_profiles ==NULL || + params->n_subport_profiles ==0 || + params->n_max_subport_profiles ==0 || + params->n_subport_profiles > params->n_max_subport_profiles) { +RTE_LOG (ERR ,SCHED , +"%s: Incorrect value for subport profiles\n" , __func__); +return -EINVAL ; + } + +for (i =0 ; i < params->n_subport_profiles; i++) { +struct rte_sched_subport_profile_params *p = + params->subport_profiles + i; +int status; + + status =subport_profile_check (p, params->rate); +if (status !=0 ) { +RTE_LOG (ERR ,SCHED , +"%s: subport profile check failed(%d)\n" , + __func__, status); +return -EINVAL ; + } + } +/* n_pipes_per_subport: non-zero, power of 2 */ if (params->n_pipes_per_subport ==0 || !rte_is_power_of_2 (params->n_pipes_per_subport)) {
@@ -555,6 +643,42 @@ rte_sched_port_log_pipe_profile(struct rte_sched_subport *subport, uint32_t i) p->wrr_cost[0], p->wrr_cost[1], p->wrr_cost[2], p->wrr_cost[3]); } +static void +rte_sched_port_log_subport_profile (struct rte_sched_port *port,uint32_t i) +{ +struct rte_sched_subport_profile *p = port->subport_profiles + i; + +RTE_LOG (DEBUG ,SCHED ,"Low level config for subport profile %u:\n" +"Token bucket: period = %" PRIu64", credits per period = %" PRIu64"," +"size = %" PRIu64"\n" +"Traffic classes: period = %" PRIu64",\n" +"credits per period = [%" PRIu64", %" PRIu64", %" PRIu64", %" PRIu64 +" %" PRIu64", %" PRIu64", %" PRIu64", %" PRIu64", %" PRIu64", %" PRIu64 +" %" PRIu64", %" PRIu64", %" PRIu64"]\n" , + i, + +/* Token bucket */ + p->tb_period, + p->tb_credits_per_period, + p->tb_size, + +/* Traffic classes */ + p->tc_period, + p->tc_credits_per_period[0 ], + p->tc_credits_per_period[1 ], + p->tc_credits_per_period[2 ], + p->tc_credits_per_period[3 ], + p->tc_credits_per_period[4 ], + p->tc_credits_per_period[5 ], + p->tc_credits_per_period[6 ], + p->tc_credits_per_period[7 ], + p->tc_credits_per_period[8 ], + p->tc_credits_per_period[9 ], + p->tc_credits_per_period[10 ], + p->tc_credits_per_period[11 ], + p->tc_credits_per_period[12 ]); +} +static inline uint64_t rte_sched_time_ms_to_bytes (uint64_t time_ms,uint64_t rate) {
@@ -623,6 +747,37 @@ rte_sched_pipe_profile_convert(struct rte_sched_subport *subport, dst->wrr_cost[3 ] = (uint8_t ) wrr_cost[3 ]; } +static void +rte_sched_subport_profile_convert (struct rte_sched_subport_profile_params *src, +struct rte_sched_subport_profile *dst, +uint64_t rate) +{ +uint32_t i; + +/* Token Bucket */ +if (src->tb_rate == rate) { + dst->tb_credits_per_period =1 ; + dst->tb_period =1 ; + }else { +double tb_rate = (double ) src->tb_rate + / (double ) rate; +double d =RTE_SCHED_TB_RATE_CONFIG_ERR ; + +rte_approx_64 (tb_rate, d, &dst->tb_credits_per_period, + &dst->tb_period); + } + + dst->tb_size = src->tb_size; + +/* Traffic Classes */ + dst->tc_period =rte_sched_time_ms_to_bytes (src->tc_period, rate); + +for (i =0 ; i <RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE ; i++) + dst->tc_credits_per_period[i] + =rte_sched_time_ms_to_bytes (src->tc_period, + src->tc_rate[i]); +} +static void rte_sched_subport_config_pipe_profile_table (struct rte_sched_subport *subport,struct rte_sched_subport_params *params,uint64_t rate)
@@ -647,6 +802,24 @@ rte_sched_subport_config_pipe_profile_table(struct rte_sched_subport *subport, } } +static void +rte_sched_port_config_subport_profile_table (struct rte_sched_port *port, +struct rte_sched_port_params *params, +uint64_t rate) +{ +uint32_t i; + +for (i =0 ; i < port->n_subport_profiles; i++) { +struct rte_sched_subport_profile_params *src + = params->subport_profiles + i; +struct rte_sched_subport_profile *dst + = port->subport_profiles + i; + +rte_sched_subport_profile_convert (src, dst, rate); +rte_sched_port_log_subport_profile (port, i); + } +} + static int rte_sched_subport_check_params(struct rte_sched_subport_params *params, uint32_t n_max_pipes_per_subport,
@@ -793,7 +966,7 @@ struct rte_sched_port * rte_sched_port_config(struct rte_sched_port_params *params) {struct rte_sched_port *port =NULL ; -uint32_t size0, size1; +uint32_t size0, size1, size2;uint32_t cycles_per_byte;uint32_t i, j;int status;
@@ -808,10 +981,21 @@ rte_sched_port_config(struct rte_sched_port_params *params) size0 =sizeof (struct rte_sched_port ); size1 = params->n_subports_per_port *sizeof (struct rte_sched_subport *); + size2 = params->n_max_subport_profiles * +sizeof (struct rte_sched_subport_profile );/* Allocate memory to store the data structures */ - port =rte_zmalloc_socket ("qos_params" , size0 + size1,RTE_CACHE_LINE_SIZE , - params->socket); + port =rte_zmalloc_socket ("qos_params" , size0 + size1, +RTE_CACHE_LINE_SIZE , params->socket); +if (port ==NULL ) { +RTE_LOG (ERR ,SCHED ,"%s: Memory allocation fails\n" , __func__); + +return NULL ; + } + +/* Allocate memory to store the subport profile */ + port->subport_profiles =rte_zmalloc_socket ("subport_profile" , size2, +RTE_CACHE_LINE_SIZE , params->socket);if (port ==NULL ) {RTE_LOG (ERR ,SCHED ,"%s: Memory allocation fails\n" , __func__);
@@ -820,6 +1004,8 @@ rte_sched_port_config(struct rte_sched_port_params *params)/* User parameters */ port->n_subports_per_port = params->n_subports_per_port; + port->n_subport_profiles = params->n_subport_profiles; + port->n_max_subport_profiles = params->n_max_subport_profiles; port->n_pipes_per_subport = params->n_pipes_per_subport; port->n_pipes_per_subport_log2 =__builtin_ctz (params->n_pipes_per_subport);
@@ -850,6 +1036,9 @@ rte_sched_port_config(struct rte_sched_port_params *params) port->time_cpu_bytes =0 ; port->time =0 ; +/* Subport profile table */ +rte_sched_port_config_subport_profile_table (port, params, port->rate); + cycles_per_byte = (rte_get_tsc_hz () <<RTE_SCHED_TIME_SHIFT ) / params->rate; port->inv_cycles_per_byte =rte_reciprocal_value (cycles_per_byte);
@@ -905,6 +1094,7 @@ rte_sched_port_free(struct rte_sched_port *port)for (i =0 ; i < port->n_subports_per_port; i++)rte_sched_subport_free (port, port->subports[i]); +rte_free (port->subport_profiles);rte_free (port); }
@@ -961,6 +1151,7 @@ rte_sched_free_memory(struct rte_sched_port *port, uint32_t n_subports)rte_sched_subport_free (port, subport); } +rte_free (port->subport_profiles);rte_free (port); }
lib/librte_sched/rte_sched.h +25 -0
@@ -192,6 +192,20 @@ struct rte_sched_subport_params {#endif }; +struct rte_sched_subport_profile_params { +/** Token bucket rate (measured in bytes per second) */ +uint64_t tb_rate; + +/** Token bucket size (measured in credits) */ +uint64_t tb_size; + +/** Traffic class rates (measured in bytes per second) */ +uint64_t tc_rate[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE ]; + +/** Enforcement period for rates (measured in milliseconds) */ +uint64_t tc_period; +}; +/** Subport statistics */ struct rte_sched_subport_stats {/** Number of packets successfully written */
@@ -254,6 +268,17 @@ struct rte_sched_port_params {/** Number of subports */ uint32_t n_subports_per_port; +/** subport profile table. +* Every pipe is configured using one of the profiles from this table. +*/ +struct rte_sched_subport_profile_params *subport_profiles; + +/** Profiles in the pipe profile table */ +uint32_t n_subport_profiles; + +/** Max allowed profiles in the pipe profile table */ +uint32_t n_max_subport_profiles; +/** Maximum number of subport pipes. * This parameter is used to reserve a fixed number of bits * in struct rte_mbuf::sched.queue_id for the pipe_id for all
Signature · 1 line
2.17.1
PATCH v5 2/9 sched: add subport profile add api
In reply to Savinay DharmappaAdd api to add new subport profile.
--- lib/librte_sched/rte_sched.c | 66 ++++++++++++++++++++++++++ lib/librte_sched/rte_sched.h | 23 +++++++++ lib/librte_sched/rte_sched_version.map | 2 + 3 files changed, 91 insertions(+)
lib/librte_sched/rte_sched.c +66 -0
@@ -1528,6 +1528,72 @@ rte_sched_subport_pipe_profile_add(struct rte_sched_port *port,return 0 ; } +int +rte_sched_port_subport_profile_add (struct rte_sched_port *port, +struct rte_sched_subport_profile_params *params, +uint32_t *subport_profile_id) +{ +int status; +uint32_t i; +struct rte_sched_subport_profile *dst; + +/* Port */ +if (port ==NULL ) { +RTE_LOG (ERR ,SCHED ,"%s: " +"Incorrect value for parameter port\n" , __func__); +return -EINVAL ; + } + +if (params ==NULL ) { +RTE_LOG (ERR ,SCHED ,"%s: " +"Incorrect value for parameter profile\n" , __func__); +return -EINVAL ; + } + +if (subport_profile_id ==NULL ) { +RTE_LOG (ERR ,SCHED ,"%s: " +"Incorrect value for parameter subport_profile_id\n" , + __func__); +return -EINVAL ; + } + + dst = port->subport_profiles + port->n_subport_profiles; + +/* Subport profiles exceeds the max limit */ +if (port->n_subport_profiles >= port->n_max_subport_profiles) { +RTE_LOG (ERR ,SCHED ,"%s: " +"Number of subport profiles exceeds the max limit\n" , + __func__); +return -EINVAL ; + } + + status =subport_profile_check (params, port->rate); +if (status !=0 ) { +RTE_LOG (ERR ,SCHED , +"%s: subport profile check failed(%d)\n" , __func__, status); +return -EINVAL ; + } + +rte_sched_subport_profile_convert (params, dst, port->rate); + +/* Subport profile should not exists */ +for (i =0 ; i < port->n_subport_profiles; i++) +if (memcmp (port->subport_profiles + i, + dst,sizeof (*dst)) ==0 ) { +RTE_LOG (ERR ,SCHED , +"%s: subport profile exists\n" , __func__); +return -EINVAL ; + } + +/* Subport profile commit */ + *subport_profile_id = port->n_subport_profiles; + port->n_subport_profiles++; + +rte_sched_port_log_subport_profile (port, *subport_profile_id); + +return 0 ; +} + static inline uint32_t rte_sched_port_qindex(struct rte_sched_port *port, uint32_t subport,
lib/librte_sched/rte_sched.h +23 -0
@@ -336,6 +336,29 @@ rte_sched_subport_pipe_profile_add(struct rte_sched_port *port,struct rte_sched_pipe_params *params, uint32_t *pipe_profile_id); +/** +* @warning +* @b EXPERIMENTAL: this API may change without prior notice. +* +* Hierarchical scheduler subport bandwidth profile add +* Note that this function is safe to use in runtime for adding new +* subport bandwidth profile as it doesn't have any impact on hiearchical +* structure of the scheduler. +* @param port +* Handle to port scheduler instance +* @param struct rte_sched_subport_profile +* Subport bandwidth profile +* @param subport_profile_d +* Subport profile id +* @return +* 0 upon success, error code otherwise +*/ +__rte_experimental +int +rte_sched_port_subport_profile_add (struct rte_sched_port *port, +struct rte_sched_subport_profile_params *profile, +uint32_t *subport_profile_id); +/** * Hierarchical scheduler subport configuration *
lib/librte_sched/rte_sched_version.map +2 -0
@@ -28,4 +28,6 @@ EXPERIMENTAL { global: rte_sched_subport_pipe_profile_add; + # added in 20.11 + rte_sched_port_subport_profile_add; };
Signature · 1 line
2.17.1
PATCH v5 3/9 sched : add dynamic config of subport bandwidth
In reply to Savinay DharmappaThis patch adds support for dynamic config of subport bandwidth.
--- lib/librte_sched/rte_sched.c | 219 +++++++++++++++++++++++++++++++++++ lib/librte_sched/rte_sched.h | 23 ++++ 2 files changed, 242 insertions(+)
lib/librte_sched/rte_sched.c +219 -0
@@ -174,6 +174,8 @@ struct rte_sched_subport {/* Statistics */ struct rte_sched_subport_stats stats __rte_cache_aligned; +/* subport profile */ +uint32_t profile;/* Subport pipes */ uint32_t n_pipes_per_subport_enabled;uint32_t n_pipe_profiles;
@@ -1155,6 +1157,49 @@ rte_sched_free_memory(struct rte_sched_port *port, uint32_t n_subports)rte_free (port); } +static int +rte_sched_subport_profile_config (struct rte_sched_port *port, +uint32_t subport_id, +uint32_t subport_profile_id) +{ +int i; +struct rte_sched_subport_profile *params; +struct rte_sched_subport *s; + +/* Subport profile exceeds the max limit */ +if (subport_profile_id >= port->n_max_subport_profiles) { +RTE_LOG (ERR ,SCHED ,"%s: " +"Number of subport profile exceeds the max limit\n" , + __func__); +return -EINVAL ; + } + + params = port->subport_profiles + subport_profile_id; + + s = port->subports[subport_id]; + + s->tb_credits = params->tb_size /2 ; + + s->tc_time = port->time + params->tc_period; + +for (i =0 ; i <RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE ; i++) +if (s->qsize[i]) + s->tc_credits[i] = + params->tc_credits_per_period[i]; +else + params->tc_credits_per_period[i] =0 ; + +#ifdef RTE_SCHED_SUBPORT_TC_OV + s->tc_ov_wm_max =rte_sched_time_ms_to_bytes (params->tc_period, + s->pipe_tc_be_rate_max); +#endif + s->profile = subport_profile_id; + +rte_sched_port_log_subport_profile (port, subport_profile_id); + +return 0 ; +} + int rte_sched_subport_config(struct rte_sched_port *port, uint32_t subport_id,
@@ -1344,6 +1389,180 @@ rte_sched_subport_config(struct rte_sched_port *port,return 0 ; } +int +rte_dynamic_sched_subport_config (struct rte_sched_port *port, +uint32_t subport_id, +struct rte_sched_subport_params *params, +uint32_t subport_profile_id) +{ +struct rte_sched_subport *s =NULL ; +uint32_t n_subports = subport_id; +uint32_t n_subport_pipe_queues, i; +uint32_t size0, size1, bmp_mem_size; +int status; + +/* Check user parameters */ +if (port ==NULL ) { +RTE_LOG (ERR ,SCHED , +"%s: Incorrect value for parameter port\n" , __func__); +return 0 ; + } + +if (subport_id >= port->n_subports_per_port) { +RTE_LOG (ERR ,SCHED , +"%s: Incorrect value for subport id\n" , __func__); + +rte_sched_free_memory (port, n_subports); +return -EINVAL ; + } + + +if (port->subports[subport_id] ==NULL ) { + + status =rte_sched_subport_check_params (params, + port->n_pipes_per_subport, + port->rate); + +if (status !=0 ) { +RTE_LOG (NOTICE ,SCHED , +"%s: Port scheduler params check failed (%d)\n" , + __func__, status); + +rte_sched_free_memory (port, n_subports); +return -EINVAL ; + } + +/* Determine the amount of memory to allocate */ + size0 =sizeof (struct rte_sched_subport ); + size1 =rte_sched_subport_get_array_base (params, + e_RTE_SCHED_SUBPORT_ARRAY_TOTAL); + +/* Allocate memory to store the data structures */ + s =rte_zmalloc_socket ("subport_params" , size0 + size1, +RTE_CACHE_LINE_SIZE , port->socket); +if (s ==NULL ) { +RTE_LOG (ERR ,SCHED , +"%s: Memory allocation fails\n" , __func__); + +rte_sched_free_memory (port, n_subports); +return -ENOMEM ; + } + + n_subports++; + +/* Port */ + port->subports[subport_id] = s; + + s->tb_time = port->time; + + subport_profile_id =0 ; + +/* compile time checks */ +RTE_BUILD_BUG_ON (RTE_SCHED_PORT_N_GRINDERS ==0 ); +RTE_BUILD_BUG_ON (RTE_SCHED_PORT_N_GRINDERS & + (RTE_SCHED_PORT_N_GRINDERS -1 )); + +/* User parameters */ + s->n_pipes_per_subport_enabled = + params->n_pipes_per_subport_enabled; +memcpy (s->qsize, params->qsize,sizeof (params->qsize)); + s->n_pipe_profiles = params->n_pipe_profiles; + s->n_max_pipe_profiles = params->n_max_pipe_profiles; + +#ifdef RTE_SCHED_RED +for (i =0 ; i <RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE ; i++) { +uint32_t j; + +for (j =0 ; j <RTE_COLORS ; j++) { +/* if min/max are both zero, then RED is disabled */ +if ((params->red_params[i][j].min_th | + params->red_params[i][j].max_th) ==0 ) { +continue ; + } + +if (rte_red_config_init (&s->red_config[i][j], + params->red_params[i][j].wq_log2, + params->red_params[i][j].min_th, + params->red_params[i][j].max_th, + params->red_params[i][j].maxp_inv) !=0 ) { +rte_sched_free_memory (port, n_subports); + +RTE_LOG (NOTICE ,SCHED , +"%s: RED configuration init fails\n" , + __func__); +return -EINVAL ; + } + } + } +#endif + +/* Scheduling loop detection */ + s->pipe_loop =RTE_SCHED_PIPE_INVALID ; + s->pipe_exhaustion =0 ; + +/* Grinders */ + s->busy_grinders =0 ; + +/* Queue base calculation */ +rte_sched_subport_config_qsize (s); + +/* Large data structures */ + s->pipe = (struct rte_sched_pipe *) + (s->memory +rte_sched_subport_get_array_base (params, + e_RTE_SCHED_SUBPORT_ARRAY_PIPE)); + s->queue = (struct rte_sched_queue *) + (s->memory +rte_sched_subport_get_array_base (params, + e_RTE_SCHED_SUBPORT_ARRAY_QUEUE)); + s->queue_extra = (struct rte_sched_queue_extra *) + (s->memory +rte_sched_subport_get_array_base (params, + e_RTE_SCHED_SUBPORT_ARRAY_QUEUE_EXTRA)); + s->pipe_profiles = (struct rte_sched_pipe_profile *) + (s->memory +rte_sched_subport_get_array_base (params, + e_RTE_SCHED_SUBPORT_ARRAY_PIPE_PROFILES)); + s->bmp_array = s->memory + +rte_sched_subport_get_array_base (params, + e_RTE_SCHED_SUBPORT_ARRAY_BMP_ARRAY); + s->queue_array = (struct rte_mbuf **) + (s->memory +rte_sched_subport_get_array_base (params, + e_RTE_SCHED_SUBPORT_ARRAY_QUEUE_ARRAY)); + +/* Pipe profile table */ +rte_sched_subport_config_pipe_profile_table (s, params, + port->rate); + +/* Bitmap */ + n_subport_pipe_queues =rte_sched_subport_pipe_queues (s); + bmp_mem_size =rte_bitmap_get_memory_footprint ( + n_subport_pipe_queues); + s->bmp =rte_bitmap_init (n_subport_pipe_queues, s->bmp_array, + bmp_mem_size); +if (s->bmp ==NULL ) { +RTE_LOG (ERR ,SCHED , +"%s: Subport bitmap init error\n" , __func__); + +rte_sched_free_memory (port, n_subports); +return -EINVAL ; + } + +for (i =0 ; i <RTE_SCHED_PORT_N_GRINDERS ; i++) + s->grinder_base_bmp_pos[i] =RTE_SCHED_PIPE_INVALID ; + +#ifdef RTE_SCHED_SUBPORT_TC_OV +/* TC oversubscription */ + s->tc_ov_wm_min = port->mtu; + s->tc_ov_wm = s->tc_ov_wm_max; + s->tc_ov_period_id =0 ; + s->tc_ov =0 ; + s->tc_ov_n =0 ; + s->tc_ov_rate =0 ; +#endif + } + +rte_sched_subport_profile_config (port, subport_id, subport_profile_id); + +return 0 ; +} + int rte_sched_pipe_config(struct rte_sched_port *port, uint32_t subport_id,
lib/librte_sched/rte_sched.h +23 -0
@@ -376,6 +376,29 @@ rte_sched_subport_config(struct rte_sched_port *port,uint32_t subport_id, struct rte_sched_subport_params *params); +/** +* Hierarchical scheduler subport configuration. +* Note that this function is also used at runtime +* to configure subport bandwidth profile. +* @param port +* Handle to port scheduler instance +* @param subport_id +* Subport ID +* @param params +* Subport configuration parameters. +* This parameter should be set to NULL, to +* configure the subport bandwidth profile +* at runtime. +* @param subport_profile_id +* ID of profile configured for subport +* @return +* 0 upon success, error code otherwise +*/ +int +rte_dynamic_sched_subport_config (struct rte_sched_port *port, +uint32_t subport_id, +struct rte_sched_subport_params *params, +uint32_t subport_profile_id);/** * Hierarchical scheduler pipe configuration *
Signature · 1 line
2.17.1
PATCH v5 4/9 sched: update grinder credit and pipe config function
In reply to Savinay DharmappaCredits are updated by fetching subport profile parameters from subport profile table. Similarly subport best effort tc is calculated in pipe config.
--- lib/librte_sched/rte_sched.c | 55 +++++++++++++++++++++--------------- 1 file changed, 33 insertions(+), 22 deletions(-)
lib/librte_sched/rte_sched.c +33 -22
@@ -123,6 +123,7 @@ struct rte_sched_grinder {uint32_t productive;uint32_t pindex;struct rte_sched_subport *subport; +struct rte_sched_subport_profile *subport_params;struct rte_sched_pipe *pipe;struct rte_sched_pipe_profile *pipe_params;
@@ -1570,6 +1571,7 @@ rte_sched_pipe_config(struct rte_sched_port *port, int32_t pipe_profile) {struct rte_sched_subport *s; +struct rte_sched_subport_profile *sp;struct rte_sched_pipe *p;struct rte_sched_pipe_profile *params;uint32_t n_subports = subport_id +1 ;
@@ -1610,14 +1612,15 @@ rte_sched_pipe_config(struct rte_sched_port *port,return -EINVAL ; } + sp = port->subport_profiles + s->profile;/* Handle the case when pipe already has a valid configuration */ p = s->pipe + pipe_id;if (p->tb_time) { params = s->pipe_profiles + p->profile;double subport_tc_be_rate = - (double ) s->tc_credits_per_period[RTE_SCHED_TRAFFIC_CLASS_BE ] - / (double ) s->tc_period; + (double )sp->tc_credits_per_period[RTE_SCHED_TRAFFIC_CLASS_BE ] + / (double ) sp->tc_period;double pipe_tc_be_rate = (double ) params->tc_credits_per_period[RTE_SCHED_TRAFFIC_CLASS_BE ] / (double ) params->tc_period;
@@ -1659,8 +1662,8 @@ rte_sched_pipe_config(struct rte_sched_port *port, {/* Subport best effort tc oversubscription */ double subport_tc_be_rate = - (double ) s->tc_credits_per_period[RTE_SCHED_TRAFFIC_CLASS_BE ] - / (double ) s->tc_period; + (double )sp->tc_credits_per_period[RTE_SCHED_TRAFFIC_CLASS_BE ] + / (double ) sp->tc_period;double pipe_tc_be_rate = (double ) params->tc_credits_per_period[RTE_SCHED_TRAFFIC_CLASS_BE ] / (double ) params->tc_period;
@@ -2448,14 +2451,15 @@ grinder_credits_update(struct rte_sched_port *port,struct rte_sched_grinder *grinder = subport->grinder + pos;struct rte_sched_pipe *pipe = grinder->pipe;struct rte_sched_pipe_profile *params = grinder->pipe_params; +struct rte_sched_subport_profile *sp = grinder->subport_params;uint64_t n_periods;uint32_t i;/* Subport TB */ - n_periods = (port->time - subport->tb_time) / subport->tb_period; - subport->tb_credits += n_periods * subport->tb_credits_per_period; - subport->tb_credits =RTE_MIN (subport->tb_credits, subport->tb_size); - subport->tb_time += n_periods * subport->tb_period; + n_periods = (port->time - subport->tb_time) / sp->tb_period; + subport->tb_credits += n_periods * sp->tb_credits_per_period; + subport->tb_credits =RTE_MIN (subport->tb_credits, sp->tb_size); + subport->tb_time += n_periods * sp->tb_period;/* Pipe TB */ n_periods = (port->time - pipe->tb_time) / params->tb_period;
@@ -2466,9 +2470,9 @@ grinder_credits_update(struct rte_sched_port *port,/* Subport TCs */ if (unlikely (port->time >= subport->tc_time)) {for (i =0 ; i <RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE ; i++) - subport->tc_credits[i] = subport->tc_credits_per_period[i]; + subport->tc_credits[i] = sp->tc_credits_per_period[i]; - subport->tc_time = port->time + subport->tc_period; + subport->tc_time = port->time + sp->tc_period; }/* Pipe TCs */
@@ -2484,8 +2488,10 @@ grinder_credits_update(struct rte_sched_port *port,static inline uint64_t grinder_tc_ov_credits_update (struct rte_sched_port *port, -struct rte_sched_subport *subport) +struct rte_sched_subport *subport,uint32_t pos) { +struct rte_sched_grinder *grinder = subport->grinder + pos; +struct rte_sched_subport_profile *sp = grinder->subport_params;uint64_t tc_ov_consumption[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE ];uint64_t tc_consumption =0 , tc_ov_consumption_max;uint64_t tc_ov_wm = subport->tc_ov_wm;
@@ -2495,17 +2501,17 @@ grinder_tc_ov_credits_update(struct rte_sched_port *port,return subport->tc_ov_wm_max;for (i =0 ; i <RTE_SCHED_TRAFFIC_CLASS_BE ; i++) { - tc_ov_consumption[i] = - subport->tc_credits_per_period[i] - subport->tc_credits[i]; + tc_ov_consumption[i] = sp->tc_credits_per_period[i] + - subport->tc_credits[i]; tc_consumption += tc_ov_consumption[i]; } tc_ov_consumption[RTE_SCHED_TRAFFIC_CLASS_BE ] = - subport->tc_credits_per_period[RTE_SCHED_TRAFFIC_CLASS_BE ] - + sp->tc_credits_per_period[RTE_SCHED_TRAFFIC_CLASS_BE ] - subport->tc_credits[RTE_SCHED_TRAFFIC_CLASS_BE ]; tc_ov_consumption_max = - subport->tc_credits_per_period[RTE_SCHED_TRAFFIC_CLASS_BE ] - + sp->tc_credits_per_period[RTE_SCHED_TRAFFIC_CLASS_BE ] - tc_consumption; if (tc_ov_consumption[RTE_SCHED_TRAFFIC_CLASS_BE] >
@@ -2531,14 +2537,15 @@ grinder_credits_update(struct rte_sched_port *port,struct rte_sched_grinder *grinder = subport->grinder + pos;struct rte_sched_pipe *pipe = grinder->pipe;struct rte_sched_pipe_profile *params = grinder->pipe_params; +struct rte_sched_subport_profile *sp = grinder->subport_params;uint64_t n_periods;uint32_t i;/* Subport TB */ - n_periods = (port->time - subport->tb_time) / subport->tb_period; - subport->tb_credits += n_periods * subport->tb_credits_per_period; - subport->tb_credits =RTE_MIN (subport->tb_credits, subport->tb_size); - subport->tb_time += n_periods * subport->tb_period; + n_periods = (port->time - subport->tb_time) / sp->tb_period; + subport->tb_credits += n_periods * sp->tb_credits_per_period; + subport->tb_credits =RTE_MIN (subport->tb_credits, sp->tb_size); + subport->tb_time += n_periods * sp->tb_period;/* Pipe TB */ n_periods = (port->time - pipe->tb_time) / params->tb_period;
@@ -2548,12 +2555,13 @@ grinder_credits_update(struct rte_sched_port *port,/* Subport TCs */ if (unlikely (port->time >= subport->tc_time)) { - subport->tc_ov_wm =grinder_tc_ov_credits_update (port, subport); + subport->tc_ov_wm = +grinder_tc_ov_credits_update (port, subport, pos);for (i =0 ; i <RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE ; i++) - subport->tc_credits[i] = subport->tc_credits_per_period[i]; + subport->tc_credits[i] = sp->tc_credits_per_period[i]; - subport->tc_time = port->time + subport->tc_period; + subport->tc_time = port->time + sp->tc_period; subport->tc_ov_period_id++; }
@@ -3076,6 +3084,9 @@ grinder_handle(struct rte_sched_port *port,struct rte_sched_pipe *pipe = grinder->pipe; grinder->pipe_params = subport->pipe_profiles + pipe->profile; + grinder->subport_params = port->subport_profiles + + subport->profile; +grinder_prefetch_tc_queue_arrays (subport, pos);grinder_credits_update (port, subport, pos);
Signature · 1 line
2.17.1
PATCH v5 5/9 example/qos_sched: add dynamic config of subport
In reply to Savinay DharmappaModify the qos_sched application to build the hierarchical scheduler with default subport bandwidth profile. It also allows to configure a subport with different subport bandwidth profile dynamically.
--- examples/qos_sched/cfg_file.c | 151 +++++++++++++++++++-------------- examples/qos_sched/cfg_file.h | 4 + examples/qos_sched/init.c | 21 +++-- examples/qos_sched/main.h | 1 + examples/qos_sched/profile.cfg | 3 + 5 files changed, 111 insertions(+), 69 deletions(-)
examples/qos_sched/cfg_file.c +87 -64
@@ -142,6 +142,93 @@ cfg_load_pipe(struct rte_cfgfile *cfg, struct rte_sched_pipe_params *pipe_paramsreturn 0 ; } +int +cfg_load_subport_profile (struct rte_cfgfile *cfg, +struct rte_sched_subport_profile_params *subport_profile) +{ +int i; +const char *entry; +int profiles; + +if (!cfg || !subport_profile) +return -1 ; + + profiles =rte_cfgfile_num_sections (cfg,"subport profile" , +sizeof ("subport profile" ) -1 ); + subport_params[0 ].n_pipe_profiles = profiles; + +for (i =0 ; i < profiles; i++) { +char sec_name[32 ]; +snprintf (sec_name,sizeof (sec_name),"subport profile %d" , i); + + entry =rte_cfgfile_get_entry (cfg, sec_name,"tb rate" ); +if (entry) + subport_profile[i].tb_rate = (uint64_t )atoi (entry); + + entry =rte_cfgfile_get_entry (cfg, sec_name,"tb size" ); +if (entry) + subport_profile[i].tb_size = (uint64_t )atoi (entry); + + entry =rte_cfgfile_get_entry (cfg, sec_name,"tc period" ); +if (entry) + subport_profile[i].tc_period = (uint64_t )atoi (entry); + + entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 0 rate" ); +if (entry) + subport_profile[i].tc_rate[0 ] = (uint64_t )atoi (entry); + + entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 1 rate" ); +if (entry) + subport_profile[i].tc_rate[1 ] = (uint64_t )atoi (entry); + + entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 2 rate" ); +if (entry) + subport_profile[i].tc_rate[2 ] = (uint64_t )atoi (entry); + + entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 3 rate" ); +if (entry) + subport_profile[i].tc_rate[3 ] = (uint64_t )atoi (entry); + + entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 4 rate" ); +if (entry) + subport_profile[i].tc_rate[4 ] = (uint64_t )atoi (entry); + + entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 5 rate" ); +if (entry) + subport_profile[i].tc_rate[5 ] = (uint64_t )atoi (entry); + + entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 6 rate" ); +if (entry) + subport_profile[i].tc_rate[6 ] = (uint64_t )atoi (entry); + + entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 7 rate" ); +if (entry) + subport_profile[i].tc_rate[7 ] = (uint64_t )atoi (entry); + + entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 8 rate" ); +if (entry) + subport_profile[i].tc_rate[8 ] = (uint64_t )atoi (entry); + + entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 9 rate" ); +if (entry) + subport_profile[i].tc_rate[9 ] = (uint64_t )atoi (entry); + + entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 10 rate" ); +if (entry) + subport_profile[i].tc_rate[10 ] = (uint64_t )atoi (entry); + + entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 11 rate" ); +if (entry) + subport_profile[i].tc_rate[11 ] = (uint64_t )atoi (entry); + + entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 12 rate" ); +if (entry) + subport_profile[i].tc_rate[12 ] = (uint64_t )atoi (entry); + } + +return 0 ; +} +int cfg_load_subport (struct rte_cfgfile *cfg,struct rte_sched_subport_params *subport_params) {
@@ -267,70 +354,6 @@ cfg_load_subport(struct rte_cfgfile *cfg, struct rte_sched_subport_params *subpo } } - entry =rte_cfgfile_get_entry (cfg, sec_name,"tb rate" ); -if (entry) - subport_params[i].tb_rate = (uint64_t )atoi (entry); - - entry =rte_cfgfile_get_entry (cfg, sec_name,"tb size" ); -if (entry) - subport_params[i].tb_size = (uint64_t )atoi (entry); - - entry =rte_cfgfile_get_entry (cfg, sec_name,"tc period" ); -if (entry) - subport_params[i].tc_period = (uint64_t )atoi (entry); - - entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 0 rate" ); -if (entry) - subport_params[i].tc_rate[0 ] = (uint64_t )atoi (entry); - - entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 1 rate" ); -if (entry) - subport_params[i].tc_rate[1 ] = (uint64_t )atoi (entry); - - entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 2 rate" ); -if (entry) - subport_params[i].tc_rate[2 ] = (uint64_t )atoi (entry); - - entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 3 rate" ); -if (entry) - subport_params[i].tc_rate[3 ] = (uint64_t )atoi (entry); - - entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 4 rate" ); -if (entry) - subport_params[i].tc_rate[4 ] = (uint64_t )atoi (entry); - - entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 5 rate" ); -if (entry) - subport_params[i].tc_rate[5 ] = (uint64_t )atoi (entry); - - entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 6 rate" ); -if (entry) - subport_params[i].tc_rate[6 ] = (uint64_t )atoi (entry); - - entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 7 rate" ); -if (entry) - subport_params[i].tc_rate[7 ] = (uint64_t )atoi (entry); - - entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 8 rate" ); -if (entry) - subport_params[i].tc_rate[8 ] = (uint64_t )atoi (entry); - - entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 9 rate" ); -if (entry) - subport_params[i].tc_rate[9 ] = (uint64_t )atoi (entry); - - entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 10 rate" ); -if (entry) - subport_params[i].tc_rate[10 ] = (uint64_t )atoi (entry); - - entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 11 rate" ); -if (entry) - subport_params[i].tc_rate[11 ] = (uint64_t )atoi (entry); - - entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 12 rate" ); -if (entry) - subport_params[i].tc_rate[12 ] = (uint64_t )atoi (entry); -int n_entries =rte_cfgfile_section_num_entries (cfg, sec_name);struct rte_cfgfile_entry entries[n_entries];
examples/qos_sched/cfg_file.h +4 -0
@@ -14,4 +14,8 @@ int cfg_load_pipe(struct rte_cfgfile *cfg, struct rte_sched_pipe_params *pipe);int cfg_load_subport (struct rte_cfgfile *cfg,struct rte_sched_subport_params *subport); +int cfg_load_subport_profile (struct rte_cfgfile *cfg, +struct rte_sched_subport_profile_params + *subport_profile); +#endif
examples/qos_sched/init.c +16 -5
@@ -192,15 +192,20 @@ static struct rte_sched_pipe_params pipe_profiles[MAX_SCHED_PIPE_PROFILES] = { }, }; -struct rte_sched_subport_params subport_params[MAX_SCHED_SUBPORTS ] = { +static struct rte_sched_subport_profile_params + subport_profile[MAX_SCHED_SUBPORT_PROFILES ] = { { .tb_rate =1250000000 , .tb_size =1000000 , - .tc_rate = {1250000000 ,1250000000 ,1250000000 ,1250000000 ,1250000000 ,1250000000 ,1250000000 ,1250000000 ,1250000000 ,1250000000 ,1250000000 ,1250000000 ,1250000000 }, .tc_period =10 , + }, +}; + +struct rte_sched_subport_params subport_params[MAX_SCHED_SUBPORTS ] = { + { .n_pipes_per_subport_enabled =4096 , .qsize = {64 ,64 ,64 ,64 ,64 ,64 ,64 ,64 ,64 ,64 ,64 ,64 ,64 }, .pipe_profiles = pipe_profiles,
@@ -285,6 +290,9 @@ struct rte_sched_port_params port_params = { .mtu = 6 + 6 + 4 + 4 + 2 + 1500, .frame_overhead = RTE_SCHED_FRAME_OVERHEAD_DEFAULT, .n_subports_per_port = 1, + .n_subport_profiles = 1, + .subport_profiles = subport_profile, + .n_max_subport_profiles = MAX_SCHED_SUBPORT_PROFILES, .n_pipes_per_subport = MAX_SCHED_PIPES, };
@@ -314,10 +322,12 @@ app_init_sched_port(uint32_t portid, uint32_t socketid) }for (subport =0 ; subport < port_params.n_subports_per_port; subport ++) { - err =rte_sched_subport_config (port, subport, &subport_params[subport]); + err =rte_dynamic_sched_subport_config (port, subport, + &subport_params[subport], +0 );if (err) { -rte_exit (EXIT_FAILURE ,"Unable to config sched subport %u, err=%d\n" , - subport, err); +rte_exit (EXIT_FAILURE ,"Unable to config schedi " +"subport %u, err=%d\n" , subport, err); } uint32_t n_pipes_per_subport =
@@ -350,6 +360,7 @@ app_load_cfg_profile(const char *profile)cfg_load_port (file, &port_params);cfg_load_subport (file, subport_params); +cfg_load_subport_profile (file, subport_profile);cfg_load_pipe (file, pipe_profiles);rte_cfgfile_close (file);
examples/qos_sched/main.h +1 -0
@@ -51,6 +51,7 @@ extern "C" {#define MAX_SCHED_SUBPORTS 8#define MAX_SCHED_PIPES 4096#define MAX_SCHED_PIPE_PROFILES 256 +#define MAX_SCHED_SUBPORT_PROFILES 8#ifndef APP_COLLECT_STAT #define APP_COLLECT_STAT 1
examples/qos_sched/profile.cfg +3 -0
@@ -26,6 +26,9 @@ number of subports per port = 1 number of pipes per subport = 4096 queue sizes = 64 64 64 64 64 64 64 64 64 64 64 64 64 +subport 0-8 = 0 ; These subports are configured with subport profile 0 + +[subport profile 0] tb rate = 1250000000 ; Bytes per second tb size = 1000000 ; Bytes
Signature · 1 line
2.17.1
PATCH v5 6/9 example/ip_pipeline: add dynamic config of subport
In reply to Savinay DharmappaModify 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
--- examples/ip_pipeline/cli.c | 17 +++++------ examples/ip_pipeline/tmgr.c | 57 ++++++++++++++++++++++++------------- examples/ip_pipeline/tmgr.h | 7 ++++- 3 files changed, 52 insertions(+), 29 deletions(-)
examples/ip_pipeline/cli.c +9 -8
@@ -406,7 +406,7 @@ cmd_tmgr_subport_profile(char **tokens, char *out, size_t out_size) { -struct rte_sched_subport_params p; +struct tmgr_subport sp;int status, i;if (n_tokens !=35 ) {
@@ -414,23 +414,23 @@ cmd_tmgr_subport_profile(char **tokens,return ; } -if (parser_read_uint64 (&p.tb_rate, tokens[3 ]) !=0 ) { +if (parser_read_uint64 (&sp.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 (&sp.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 (&sp.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 (&sp.pp.tc_period, tokens[18 ]) !=0 ) {snprintf (out, out_size,MSG_ARG_INVALID ,"tc_period" );return ; }
@@ -440,7 +440,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 (&sp.p.n_pipes_per_subport_enabled, + tokens[20 ]) !=0 ) {snprintf (out, out_size,MSG_ARG_INVALID ,"n_pipes_per_subport" );return ; }
@@ -451,12 +452,12 @@ cmd_tmgr_subport_profile(char **tokens, }for (i =0 ; i <RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE ; i++) -if (parser_read_uint16 (&p.qsize[i], tokens[22 + i]) !=0 ) { +if (parser_read_uint16 (&sp.p.qsize[i], tokens[22 + i]) !=0 ) {snprintf (out, out_size,MSG_ARG_INVALID ,"qsize" );return ; } - status =tmgr_subport_profile_add (&p); + status =tmgr_subport_profile_add (&sp);if (status !=0 ) {snprintf (out, out_size,MSG_CMD_FAIL , tokens[0 ]);return ;
examples/ip_pipeline/tmgr.c +37 -20
112 lines not on this page · raw message
examples/ip_pipeline/tmgr.h +6 -1
@@ -31,6 +31,11 @@ struct tmgr_port {uint32_t n_subports_per_port; }; +struct tmgr_subport { +struct rte_sched_subport_params p; +struct rte_sched_subport_profile_params pp; +}; +TAILQ_HEAD (tmgr_port_list, tmgr_port);int
@@ -48,7 +53,7 @@ struct tmgr_port_params { };int -tmgr_subport_profile_add (struct rte_sched_subport_params *p); +tmgr_subport_profile_add (struct tmgr_subport *sp);int tmgr_pipe_profile_add (struct rte_sched_pipe_params *p);
Signature · 1 line
2.17.1
PATCH v5 7/9 drivers/softnic: add dynamic config of subport
In reply to Savinay DharmappaModify the softnic drivers to build the hierarchical scheduler with default subport bandwidth profile. It also allows to configure a subport with different subport bandwidth profile dynamically.
--- .../net/softnic/rte_eth_softnic_internals.h | 18 +- drivers/net/softnic/rte_eth_softnic_tm.c | 228 ++++++++++++++---- 2 files changed, 194 insertions(+), 52 deletions(-)
drivers/net/softnic/rte_eth_softnic_internals.h +15 -3
@@ -164,11 +164,23 @@ TAILQ_HEAD(softnic_link_list, softnic_link);#ifndef TM_MAX_PIPE_PROFILE #define TM_MAX_PIPE_PROFILE 256#endif -struct tm_params { -struct rte_sched_port_params port_params; -struct rte_sched_subport_params subport_params[TM_MAX_SUBPORTS ]; +#ifndef TM_MAX_SUBPORT_PROFILE +#define TM_MAX_SUBPORT_PROFILE 256 +#endif + +struct subport_profile_params { +struct rte_sched_subport_params params[TM_MAX_SUBPORTS ]; +struct rte_sched_subport_profile_params + profile[TM_MAX_SUBPORT_PROFILE ]; +}; + +struct tm_params { +struct rte_sched_port_params port_params; +struct subport_profile_params subport_profile; +uint32_t n_subport_profiles; +uint32_t subport_to_profile[TM_MAX_SUBPORT_PROFILE ];struct rte_sched_pipe_params pipe_profiles[TM_MAX_PIPE_PROFILE ];uint32_t n_pipe_profiles;uint32_t pipe_to_profile[TM_MAX_SUBPORTS *TM_MAX_PIPES_PER_SUBPORT ];
drivers/net/softnic/rte_eth_softnic_tm.c +179 -49
316 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH v5 8/9 app/test_sched: add dynamic config of subport
In reply to Savinay DharmappaModify the test_sched application to build the hierarchical scheduler with default subport bandwidth profile. It also allows to configure a subport with different subport bandwidth profile dynamically
--- app/test/test_sched.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-)
app/test/test_sched.c +14 -3
@@ -21,6 +21,7 @@#define PIPE 1#define TC 2#define QUEUE 0 +#define MAX_SCHED_SUBPORT_PROFILES 8static struct rte_sched_pipe_params pipe_profile[] = { {/* Profile #0 */
@@ -36,15 +37,20 @@ static struct rte_sched_pipe_params pipe_profile[] = { }, }; -static struct rte_sched_subport_params subport_param[] = { +static struct rte_sched_subport_profile_params + subport_profile[] = { { .tb_rate =1250000000 , .tb_size =1000000 , - .tc_rate = {1250000000 ,1250000000 ,1250000000 ,1250000000 ,1250000000 ,1250000000 ,1250000000 ,1250000000 ,1250000000 ,1250000000 ,1250000000 ,1250000000 ,1250000000 }, .tc_period =10 , + }, +}; + +static struct rte_sched_subport_params subport_param[] = { + { .n_pipes_per_subport_enabled =1024 , .qsize = {32 ,32 ,32 ,32 ,32 ,32 ,32 ,32 ,32 ,32 ,32 ,32 ,32 }, .pipe_profiles = pipe_profile,
@@ -59,6 +65,9 @@ static struct rte_sched_port_params port_param = { .mtu = 1522, .frame_overhead = RTE_SCHED_FRAME_OVERHEAD_DEFAULT, .n_subports_per_port = 1, + .n_subport_profiles = 1, + .subport_profiles = subport_profile, + .n_max_subport_profiles = MAX_SCHED_SUBPORT_PROFILES, .n_pipes_per_subport = 1024, };
@@ -66,6 +75,7 @@ static struct rte_sched_port_params port_param = {#define MBUF_DATA_SZ (2048 + RTE_PKTMBUF_HEADROOM)#define MEMPOOL_CACHE_SZ 0#define SOCKET 0 +#define DEFAULT_PROFILE 0 static struct rte_mempool *
@@ -138,7 +148,8 @@ test_sched(void) port =rte_sched_port_config (&port_param);TEST_ASSERT_NOT_NULL (port,"Error config sched port\n" ); - err =rte_sched_subport_config (port,SUBPORT , subport_param); + err =rte_dynamic_sched_subport_config (port,SUBPORT , subport_param, +DEFAULT_PROFILE );TEST_ASSERT_SUCCESS (err,"Error config sched, err=%d\n" , err);for (pipe =0 ; pipe < subport_param[0 ].n_pipes_per_subport_enabled; pipe++) {
Signature · 1 line
2.17.1
PATCH v5 9/9 sched : remove redundant code
In reply to Savinay DharmappaRemove redundant data structure fields references from functions and subport level data structures. It also update the release and deprecation note
--- app/test/test_sched.c | 2 +- doc/guides/rel_notes/deprecation.rst | 6 - doc/guides/rel_notes/release_20_11.rst | 4 + drivers/net/softnic/rte_eth_softnic_tm.c | 4 +- examples/ip_pipeline/tmgr.c | 4 +- examples/qos_sched/init.c | 2 +- lib/librte_sched/rte_sched.c | 273 +---------------------- lib/librte_sched/rte_sched.h | 31 +-- 8 files changed, 13 insertions(+), 313 deletions(-)
app/test/test_sched.c +1 -1
@@ -148,7 +148,7 @@ test_sched(void) port =rte_sched_port_config (&port_param);TEST_ASSERT_NOT_NULL (port,"Error config sched port\n" ); - err =rte_dynamic_sched_subport_config (port,SUBPORT , subport_param, + err =rte_sched_subport_config (port,SUBPORT , subport_param,DEFAULT_PROFILE );TEST_ASSERT_SUCCESS (err,"Error config sched, err=%d\n" , err);
doc/guides/rel_notes/deprecation.rst +0 -6
@@ -231,12 +231,6 @@ Deprecation Notices in "rte_sched.h". These changes are aligned to improvements suggested in the RFC https://mails.dpdk.org/archives/dev/2018-November/120035.html. -* sched: To allow dynamic configuration of the subport bandwidth profile, - changes will be made to data structures ``rte_sched_subport_params``, - ``rte_sched_port_params`` and new data structure, API functions will be - defined in ``rte_sched.h``. These changes are aligned as suggested in the - RFC https://mails.dpdk.org/archives/dev/2020-July/175161.html - * metrics: The function ``rte_metrics_init`` will have a non-void return in order to notify errors instead of calling ``rte_exit``.
doc/guides/rel_notes/release_20_11.rst +4 -0
@@ -91,6 +91,10 @@ Removed Items Also, make sure to start the actual text at the margin. ======================================================= +* sched: The subport bandwidth configuration parameters such as tb_rate, + tc_rate, tc_period etc., are moved from subport level data structure to + new a data structure. This allows to configure a subport with different + subport bandwidth configuration dynamically. API Changes -----------
drivers/net/softnic/rte_eth_softnic_tm.c +2 -2
@@ -90,7 +90,7 @@ softnic_tmgr_port_create(struct pmd_internals *p,uint32_t pipe_id;int status; - status =rte_dynamic_sched_subport_config (sched, + status =rte_sched_subport_config (sched, subport_id, &t->subport_profile.params[subport_id], t->subport_to_profile[subport_id]);
@@ -1162,7 +1162,7 @@ update_subport_tc_rate(struct rte_eth_dev *dev,return -1 ;/* Update the subport configuration. */ -if (rte_dynamic_sched_subport_config (SCHED (p), +if (rte_sched_subport_config (SCHED (p), subport_id,NULL , subport_profile_id))return -1 ;
examples/ip_pipeline/tmgr.c +2 -2
@@ -130,7 +130,7 @@ tmgr_port_create(const char *name, struct tmgr_port_params *params)for (i =0 ; i < params->n_subports_per_port; i++) {int status; - status =rte_dynamic_sched_subport_config ( + status =rte_sched_subport_config ( s, i, &subport_profile.params[0 ],0 );
@@ -193,7 +193,7 @@ tmgr_subport_config(const char *port_name,return -1 ;/* Resource config */ - status = rte_dynamic_sched_subport_config( + status = rte_sched_subport_config( port->s, subport_id, NULL,
examples/qos_sched/init.c +1 -1
@@ -322,7 +322,7 @@ app_init_sched_port(uint32_t portid, uint32_t socketid) }for (subport =0 ; subport < port_params.n_subports_per_port; subport ++) { - err =rte_dynamic_sched_subport_config (port, subport, + err =rte_sched_subport_config (port, subport, &subport_params[subport],0 );if (err) {
lib/librte_sched/rte_sched.c +2 -271
308 lines not on this page · raw message
lib/librte_sched/rte_sched.h +1 -30
@@ -149,18 +149,6 @@ struct rte_sched_pipe_params {* byte. */ struct rte_sched_subport_params { -/** Token bucket rate (measured in bytes per second) */ -uint64_t tb_rate; - -/** Token bucket size (measured in credits) */ -uint64_t tb_size; - -/** Traffic class rates (measured in bytes per second) */ -uint64_t tc_rate[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE ]; - -/** Enforcement period for rates (measured in milliseconds) */ -uint64_t tc_period; -/** Number of subport pipes. * The subport can enable/allocate fewer pipes than the maximum * number set through struct port_params::n_max_pipes_per_subport,
@@ -359,23 +347,6 @@ rte_sched_port_subport_profile_add(struct rte_sched_port *port,struct rte_sched_subport_profile_params *profile, uint32_t *subport_profile_id); -/** -* Hierarchical scheduler subport configuration -* -* @param port -* Handle to port scheduler instance -* @param subport_id -* Subport ID -* @param params -* Subport configuration parameters -* @return -* 0 upon success, error code otherwise -*/ -int -rte_sched_subport_config (struct rte_sched_port *port, -uint32_t subport_id, -struct rte_sched_subport_params *params); -/** * Hierarchical scheduler subport configuration. * Note that this function is also used at runtime
@@ -395,7 +366,7 @@ rte_sched_subport_config(struct rte_sched_port *port,* 0 upon success, error code otherwise */ int -rte_dynamic_sched_subport_config (struct rte_sched_port *port, +rte_sched_subport_config (struct rte_sched_port *port,uint32_t subport_id,struct rte_sched_subport_params *params,uint32_t subport_profile_id);
Signature · 1 line
2.17.1
v6 cover Enable dynamic config of subport bandwidth
In reply to Savinay DharmappaDPDK sched library allows runtime configuration of the pipe profiles to the pipes of the subport once scheduler hierarchy is constructed. However, to change the subport level bandwidth, existing hierarchy needs to be dismantled and whole process of building hierarchy under subport nodes needs to be repeated which might result in router downtime. Furthermore, due to lack of dynamic configuration of the subport bandwidth profile configuration (shaper and Traffic class rates), the user application is unable to dynamically re-distribute the excess-bandwidth of one subport among other subports in the scheduler hierarchy. Therefore, it is also not possible to adjust the subport bandwidth profile in sync with dynamic changes in pipe profiles of subscribers who want to consume higher bandwidth opportunistically.
This patch series implements dynamic configuration of the subport bandwidth profile to overcome the runtime situation when group of subscribers are not using the allotted bandwidth and dynamic bandwidth re-distribution is needed the without making any structural changes in the hierarchy.
The implementation work includes refactoring the existing api and data structures defined for port and subport level, new APIs for adding subport level bandwidth profiles that can be used in runtime
Savinay Dharmappa (8):
sched: add support profile table
sched: introduce subport profile add function
sched: update subport rate dynamically example/qos_sched: update subport rate dynamically example/ip_pipeline: update subport rate dynamically drivers/softnic: update subport rate dynamically app/test_sched: update subport rate dynamically
sched: remove redundant code
app/test/test_sched.c | 15 +- doc/guides/rel_notes/deprecation.rst | 6 - doc/guides/rel_notes/release_20_11.rst | 2 + .../net/softnic/rte_eth_softnic_internals.h | 11 +- drivers/net/softnic/rte_eth_softnic_tm.c | 243 +++++-- examples/ip_pipeline/cli.c | 68 +- examples/ip_pipeline/tmgr.c | 121 +++- examples/ip_pipeline/tmgr.h | 5 +- examples/qos_sched/cfg_file.c | 151 ++-- examples/qos_sched/cfg_file.h | 4 + examples/qos_sched/init.c | 21 +- examples/qos_sched/main.h | 1 + examples/qos_sched/profile.cfg | 3 + lib/librte_sched/rte_sched.c | 678 ++++++++++++------ lib/librte_sched/rte_sched.h | 73 +- lib/librte_sched/rte_sched_version.map | 2 + 16 files changed, 959 insertions(+), 445 deletions(-)
Signature · 1 line
2.17.1
PATCH v6 1/8 sched: add support profile table
Add subport profile table to internal port data structure and update the port config function.
--- lib/librte_sched/rte_sched.c | 197 ++++++++++++++++++++++++++++++++++- lib/librte_sched/rte_sched.h | 25 +++++ 2 files changed, 219 insertions(+), 3 deletions(-)
lib/librte_sched/rte_sched.c +194 -3
@@ -101,6 +101,16 @@ enum grinder_state {e_GRINDER_READ_MBUF }; +struct rte_sched_subport_profile { +/* Token bucket (TB) */ +uint64_t tb_period; +uint64_t tb_credits_per_period; +uint64_t tb_size; + +uint64_t tc_credits_per_period[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE ]; +uint64_t tc_period; +}; +struct rte_sched_grinder {/* Pipe cache */ uint16_t pcache_qmask[RTE_SCHED_GRINDER_PCACHE_SIZE ];
@@ -212,6 +222,8 @@ struct rte_sched_port {uint16_t pipe_queue[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE ];uint8_t pipe_tc[RTE_SCHED_QUEUES_PER_PIPE ];uint8_t tc_queue[RTE_SCHED_QUEUES_PER_PIPE ]; +uint32_t n_subport_profiles; +uint32_t n_max_subport_profiles;uint64_t rate;uint32_t mtu;uint32_t frame_overhead;
@@ -230,6 +242,7 @@ struct rte_sched_port {uint32_t subport_id;/* Large data structures */ +struct rte_sched_subport_profile *subport_profiles; struct rte_sched_subport *subports[0] __rte_cache_aligned; } __rte_cache_aligned;
@@ -375,9 +388,61 @@ pipe_profile_check(struct rte_sched_pipe_params *params,return 0 ; } +static int +subport_profile_check (struct rte_sched_subport_profile_params *params, +uint64_t rate) +{ +uint32_t i; + +/* Check user parameters */ +if (params ==NULL ) { +RTE_LOG (ERR ,SCHED ,"%s: " +"Incorrect value for parameter params\n" , __func__); +return -EINVAL ; + } + +if (params->tb_rate ==0 || params->tb_rate > rate) { +RTE_LOG (ERR ,SCHED ,"%s: " +"Incorrect value for tb rate\n" , __func__); +return -EINVAL ; + } + +if (params->tb_size ==0 ) { +RTE_LOG (ERR ,SCHED ,"%s: " +"Incorrect value for tb size\n" , __func__); +return -EINVAL ; + } + +for (i =0 ; i <RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE ; i++) { +uint64_t tc_rate = params->tc_rate[i]; + +if (tc_rate ==0 || (tc_rate > params->tb_rate)) { +RTE_LOG (ERR ,SCHED ,"%s: " +"Incorrect value for tc rate\n" , __func__); +return -EINVAL ; + } + } + +if (params->tc_rate[RTE_SCHED_TRAFFIC_CLASS_BE ] ==0 ) { +RTE_LOG (ERR ,SCHED ,"%s: " +"Incorrect tc rate(best effort)\n" , __func__); +return -EINVAL ; + } + +if (params->tc_period ==0 ) { +RTE_LOG (ERR ,SCHED ,"%s: " +"Incorrect value for tc period\n" , __func__); +return -EINVAL ; + } + +return 0 ; +} +static int rte_sched_port_check_params (struct rte_sched_port_params *params) { +uint32_t i; +if (params ==NULL ) {RTE_LOG (ERR ,SCHED ,"%s: Incorrect value for parameter params\n" , __func__);
@@ -414,6 +479,29 @@ rte_sched_port_check_params(struct rte_sched_port_params *params)return -EINVAL ; } +if (params->subport_profiles ==NULL || + params->n_subport_profiles ==0 || + params->n_max_subport_profiles ==0 || + params->n_subport_profiles > params->n_max_subport_profiles) { +RTE_LOG (ERR ,SCHED , +"%s: Incorrect value for subport profiles\n" , __func__); +return -EINVAL ; + } + +for (i =0 ; i < params->n_subport_profiles; i++) { +struct rte_sched_subport_profile_params *p = + params->subport_profiles + i; +int status; + + status =subport_profile_check (p, params->rate); +if (status !=0 ) { +RTE_LOG (ERR ,SCHED , +"%s: subport profile check failed(%d)\n" , + __func__, status); +return -EINVAL ; + } + } +/* n_pipes_per_subport: non-zero, power of 2 */ if (params->n_pipes_per_subport ==0 || !rte_is_power_of_2 (params->n_pipes_per_subport)) {
@@ -555,6 +643,42 @@ rte_sched_port_log_pipe_profile(struct rte_sched_subport *subport, uint32_t i) p->wrr_cost[0], p->wrr_cost[1], p->wrr_cost[2], p->wrr_cost[3]); } +static void +rte_sched_port_log_subport_profile (struct rte_sched_port *port,uint32_t i) +{ +struct rte_sched_subport_profile *p = port->subport_profiles + i; + +RTE_LOG (DEBUG ,SCHED ,"Low level config for subport profile %u:\n" +"Token bucket: period = %" PRIu64", credits per period = %" PRIu64"," +"size = %" PRIu64"\n" +"Traffic classes: period = %" PRIu64",\n" +"credits per period = [%" PRIu64", %" PRIu64", %" PRIu64", %" PRIu64 +" %" PRIu64", %" PRIu64", %" PRIu64", %" PRIu64", %" PRIu64", %" PRIu64 +" %" PRIu64", %" PRIu64", %" PRIu64"]\n" , + i, + +/* Token bucket */ + p->tb_period, + p->tb_credits_per_period, + p->tb_size, + +/* Traffic classes */ + p->tc_period, + p->tc_credits_per_period[0 ], + p->tc_credits_per_period[1 ], + p->tc_credits_per_period[2 ], + p->tc_credits_per_period[3 ], + p->tc_credits_per_period[4 ], + p->tc_credits_per_period[5 ], + p->tc_credits_per_period[6 ], + p->tc_credits_per_period[7 ], + p->tc_credits_per_period[8 ], + p->tc_credits_per_period[9 ], + p->tc_credits_per_period[10 ], + p->tc_credits_per_period[11 ], + p->tc_credits_per_period[12 ]); +} +static inline uint64_t rte_sched_time_ms_to_bytes (uint64_t time_ms,uint64_t rate) {
@@ -623,6 +747,37 @@ rte_sched_pipe_profile_convert(struct rte_sched_subport *subport, dst->wrr_cost[3 ] = (uint8_t ) wrr_cost[3 ]; } +static void +rte_sched_subport_profile_convert (struct rte_sched_subport_profile_params *src, +struct rte_sched_subport_profile *dst, +uint64_t rate) +{ +uint32_t i; + +/* Token Bucket */ +if (src->tb_rate == rate) { + dst->tb_credits_per_period =1 ; + dst->tb_period =1 ; + }else { +double tb_rate = (double ) src->tb_rate + / (double ) rate; +double d =RTE_SCHED_TB_RATE_CONFIG_ERR ; + +rte_approx_64 (tb_rate, d, &dst->tb_credits_per_period, + &dst->tb_period); + } + + dst->tb_size = src->tb_size; + +/* Traffic Classes */ + dst->tc_period =rte_sched_time_ms_to_bytes (src->tc_period, rate); + +for (i =0 ; i <RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE ; i++) + dst->tc_credits_per_period[i] + =rte_sched_time_ms_to_bytes (src->tc_period, + src->tc_rate[i]); +} +static void rte_sched_subport_config_pipe_profile_table (struct rte_sched_subport *subport,struct rte_sched_subport_params *params,uint64_t rate)
@@ -647,6 +802,24 @@ rte_sched_subport_config_pipe_profile_table(struct rte_sched_subport *subport, } } +static void +rte_sched_port_config_subport_profile_table (struct rte_sched_port *port, +struct rte_sched_port_params *params, +uint64_t rate) +{ +uint32_t i; + +for (i =0 ; i < port->n_subport_profiles; i++) { +struct rte_sched_subport_profile_params *src + = params->subport_profiles + i; +struct rte_sched_subport_profile *dst + = port->subport_profiles + i; + +rte_sched_subport_profile_convert (src, dst, rate); +rte_sched_port_log_subport_profile (port, i); + } +} + static int rte_sched_subport_check_params(struct rte_sched_subport_params *params, uint32_t n_max_pipes_per_subport,
@@ -793,7 +966,7 @@ struct rte_sched_port * rte_sched_port_config(struct rte_sched_port_params *params) {struct rte_sched_port *port =NULL ; -uint32_t size0, size1; +uint32_t size0, size1, size2;uint32_t cycles_per_byte;uint32_t i, j;int status;
@@ -808,10 +981,21 @@ rte_sched_port_config(struct rte_sched_port_params *params) size0 =sizeof (struct rte_sched_port ); size1 = params->n_subports_per_port *sizeof (struct rte_sched_subport *); + size2 = params->n_max_subport_profiles * +sizeof (struct rte_sched_subport_profile );/* Allocate memory to store the data structures */ - port =rte_zmalloc_socket ("qos_params" , size0 + size1,RTE_CACHE_LINE_SIZE , - params->socket); + port =rte_zmalloc_socket ("qos_params" , size0 + size1, +RTE_CACHE_LINE_SIZE , params->socket); +if (port ==NULL ) { +RTE_LOG (ERR ,SCHED ,"%s: Memory allocation fails\n" , __func__); + +return NULL ; + } + +/* Allocate memory to store the subport profile */ + port->subport_profiles =rte_zmalloc_socket ("subport_profile" , size2, +RTE_CACHE_LINE_SIZE , params->socket);if (port ==NULL ) {RTE_LOG (ERR ,SCHED ,"%s: Memory allocation fails\n" , __func__);
@@ -820,6 +1004,8 @@ rte_sched_port_config(struct rte_sched_port_params *params)/* User parameters */ port->n_subports_per_port = params->n_subports_per_port; + port->n_subport_profiles = params->n_subport_profiles; + port->n_max_subport_profiles = params->n_max_subport_profiles; port->n_pipes_per_subport = params->n_pipes_per_subport; port->n_pipes_per_subport_log2 =__builtin_ctz (params->n_pipes_per_subport);
@@ -850,6 +1036,9 @@ rte_sched_port_config(struct rte_sched_port_params *params) port->time_cpu_bytes =0 ; port->time =0 ; +/* Subport profile table */ +rte_sched_port_config_subport_profile_table (port, params, port->rate); + cycles_per_byte = (rte_get_tsc_hz () <<RTE_SCHED_TIME_SHIFT ) / params->rate; port->inv_cycles_per_byte =rte_reciprocal_value (cycles_per_byte);
@@ -905,6 +1094,7 @@ rte_sched_port_free(struct rte_sched_port *port)for (i =0 ; i < port->n_subports_per_port; i++)rte_sched_subport_free (port, port->subports[i]); +rte_free (port->subport_profiles);rte_free (port); }
@@ -961,6 +1151,7 @@ rte_sched_free_memory(struct rte_sched_port *port, uint32_t n_subports)rte_sched_subport_free (port, subport); } +rte_free (port->subport_profiles);rte_free (port); }
lib/librte_sched/rte_sched.h +25 -0
@@ -192,6 +192,20 @@ struct rte_sched_subport_params {#endif }; +struct rte_sched_subport_profile_params { +/** Token bucket rate (measured in bytes per second) */ +uint64_t tb_rate; + +/** Token bucket size (measured in credits) */ +uint64_t tb_size; + +/** Traffic class rates (measured in bytes per second) */ +uint64_t tc_rate[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE ]; + +/** Enforcement period for rates (measured in milliseconds) */ +uint64_t tc_period; +}; +/** Subport statistics */ struct rte_sched_subport_stats {/** Number of packets successfully written */
@@ -254,6 +268,17 @@ struct rte_sched_port_params {/** Number of subports */ uint32_t n_subports_per_port; +/** subport profile table. +* Every pipe is configured using one of the profiles from this table. +*/ +struct rte_sched_subport_profile_params *subport_profiles; + +/** Profiles in the pipe profile table */ +uint32_t n_subport_profiles; + +/** Max allowed profiles in the pipe profile table */ +uint32_t n_max_subport_profiles; +/** Maximum number of subport pipes. * This parameter is used to reserve a fixed number of bits * in struct rte_mbuf::sched.queue_id for the pipe_id for all
Signature · 1 line
2.17.1
PATCH v6 2/8 sched: introduce subport profile add function
In reply to Savinay DharmappaAPI to add new subport bandwidth profile.
--- lib/librte_sched/rte_sched.c | 66 ++++++++++++++++++++++++++ lib/librte_sched/rte_sched.h | 23 +++++++++ lib/librte_sched/rte_sched_version.map | 2 + 3 files changed, 91 insertions(+)
lib/librte_sched/rte_sched.c +66 -0
@@ -1528,6 +1528,72 @@ rte_sched_subport_pipe_profile_add(struct rte_sched_port *port,return 0 ; } +int +rte_sched_port_subport_profile_add (struct rte_sched_port *port, +struct rte_sched_subport_profile_params *params, +uint32_t *subport_profile_id) +{ +int status; +uint32_t i; +struct rte_sched_subport_profile *dst; + +/* Port */ +if (port ==NULL ) { +RTE_LOG (ERR ,SCHED ,"%s: " +"Incorrect value for parameter port\n" , __func__); +return -EINVAL ; + } + +if (params ==NULL ) { +RTE_LOG (ERR ,SCHED ,"%s: " +"Incorrect value for parameter profile\n" , __func__); +return -EINVAL ; + } + +if (subport_profile_id ==NULL ) { +RTE_LOG (ERR ,SCHED ,"%s: " +"Incorrect value for parameter subport_profile_id\n" , + __func__); +return -EINVAL ; + } + + dst = port->subport_profiles + port->n_subport_profiles; + +/* Subport profiles exceeds the max limit */ +if (port->n_subport_profiles >= port->n_max_subport_profiles) { +RTE_LOG (ERR ,SCHED ,"%s: " +"Number of subport profiles exceeds the max limit\n" , + __func__); +return -EINVAL ; + } + + status =subport_profile_check (params, port->rate); +if (status !=0 ) { +RTE_LOG (ERR ,SCHED , +"%s: subport profile check failed(%d)\n" , __func__, status); +return -EINVAL ; + } + +rte_sched_subport_profile_convert (params, dst, port->rate); + +/* Subport profile should not exists */ +for (i =0 ; i < port->n_subport_profiles; i++) +if (memcmp (port->subport_profiles + i, + dst,sizeof (*dst)) ==0 ) { +RTE_LOG (ERR ,SCHED , +"%s: subport profile exists\n" , __func__); +return -EINVAL ; + } + +/* Subport profile commit */ + *subport_profile_id = port->n_subport_profiles; + port->n_subport_profiles++; + +rte_sched_port_log_subport_profile (port, *subport_profile_id); + +return 0 ; +} + static inline uint32_t rte_sched_port_qindex(struct rte_sched_port *port, uint32_t subport,
lib/librte_sched/rte_sched.h +23 -0
@@ -336,6 +336,29 @@ rte_sched_subport_pipe_profile_add(struct rte_sched_port *port,struct rte_sched_pipe_params *params, uint32_t *pipe_profile_id); +/** +* @warning +* @b EXPERIMENTAL: this API may change without prior notice. +* +* Hierarchical scheduler subport bandwidth profile add +* Note that this function is safe to use in runtime for adding new +* subport bandwidth profile as it doesn't have any impact on hiearchical +* structure of the scheduler. +* @param port +* Handle to port scheduler instance +* @param profile +* Subport bandwidth profile +* @param subport_profile_d +* Subport profile id +* @return +* 0 upon success, error code otherwise +*/ +__rte_experimental +int +rte_sched_port_subport_profile_add (struct rte_sched_port *port, +struct rte_sched_subport_profile_params *profile, +uint32_t *subport_profile_id); +/** * Hierarchical scheduler subport configuration *
lib/librte_sched/rte_sched_version.map +2 -0
@@ -28,4 +28,6 @@ EXPERIMENTAL { global: rte_sched_subport_pipe_profile_add; + # added in 20.11 + rte_sched_port_subport_profile_add; };
Signature · 1 line
2.17.1
PATCH v6 3/8 sched: update subport rate dynamically
In reply to Savinay DharmappaAdd support to update subport rate dynamically.
--- app/test/test_sched.c | 2 +- drivers/net/softnic/rte_eth_softnic_tm.c | 6 +- examples/ip_pipeline/tmgr.c | 6 +- examples/qos_sched/init.c | 3 +- lib/librte_sched/rte_sched.c | 373 +++++++++++------------ lib/librte_sched/rte_sched.h | 13 +- 6 files changed, 202 insertions(+), 201 deletions(-)
app/test/test_sched.c +1 -1
@@ -138,7 +138,7 @@ test_sched(void) port =rte_sched_port_config (&port_param);TEST_ASSERT_NOT_NULL (port,"Error config sched port\n" ); - err =rte_sched_subport_config (port,SUBPORT , subport_param); + err =rte_sched_subport_config (port,SUBPORT , subport_param,0 );TEST_ASSERT_SUCCESS (err,"Error config sched, err=%d\n" , err);for (pipe =0 ; pipe < subport_param[0 ].n_pipes_per_subport_enabled; pipe++) {
drivers/net/softnic/rte_eth_softnic_tm.c +3 -3
@@ -92,7 +92,7 @@ softnic_tmgr_port_create(struct pmd_internals *p, status =rte_sched_subport_config (sched, subport_id, - &t->subport_params[subport_id]); + &t->subport_params[subport_id],0 );if (status) {rte_sched_port_free (sched);return NULL ;
@@ -1141,7 +1141,7 @@ update_subport_tc_rate(struct rte_eth_dev *dev,/* Update the subport configuration. */ if (rte_sched_subport_config (SCHED (p), - subport_id, &subport_params)) + subport_id, &subport_params,0 ))return -1 ;/* Commit changes. */
@@ -2912,7 +2912,7 @@ update_subport_rate(struct rte_eth_dev *dev,/* Update the subport configuration. */ if (rte_sched_subport_config (SCHED (p), subport_id, - &subport_params)) + &subport_params,0 ))return -1 ;/* Commit changes. */
examples/ip_pipeline/tmgr.c +4 -2
@@ -119,7 +119,8 @@ tmgr_port_create(const char *name, struct tmgr_port_params *params) status =rte_sched_subport_config ( s, i, - &subport_profile[0 ]); + &subport_profile[0 ], +0 );if (status) {rte_sched_port_free (s);
@@ -180,7 +181,8 @@ tmgr_subport_config(const char *port_name, status =rte_sched_subport_config ( port->s, subport_id, - &subport_profile[subport_profile_id]); + &subport_profile[subport_profile_id], +0 );return status; }
examples/qos_sched/init.c +2 -1
@@ -314,7 +314,8 @@ app_init_sched_port(uint32_t portid, uint32_t socketid) }for (subport =0 ; subport < port_params.n_subports_per_port; subport ++) { - err =rte_sched_subport_config (port, subport, &subport_params[subport]); + err =rte_sched_subport_config (port, subport, + &subport_params[subport],0 );if (err) {rte_exit (EXIT_FAILURE ,"Unable to config sched subport %u, err=%d\n" , subport, err);
lib/librte_sched/rte_sched.c +182 -191
525 lines not on this page · raw message
lib/librte_sched/rte_sched.h +10 -3
@@ -361,20 +361,27 @@ rte_sched_port_subport_profile_add(struct rte_sched_port *port,/** * Hierarchical scheduler subport configuration -* +* Note that this function is safe to use at runtime +* to configure subport bandwidth profile. * @param port * Handle to port scheduler instance * @param subport_id * Subport ID * @param params -* Subport configuration parameters +* Subport configuration parameters. Must be non-NULL +* for first invocation (i.e intialization) for a given +* subport. Ignored (recommended value is NULL) for all +* subsequent invocation on the same subport. +* @param subport_profile_id +* ID of subport bandwidth profile * @return * 0 upon success, error code otherwise */ int rte_sched_subport_config (struct rte_sched_port *port,uint32_t subport_id, -struct rte_sched_subport_params *params); +struct rte_sched_subport_params *params, +uint32_t subport_profile_id);/** * Hierarchical scheduler pipe configuration
Signature · 1 line
2.17.1
PATCH v6 4/8 example/qos_sched: update subport rate dynamically
In reply to Savinay DharmappaModify the qos_sched application to build the hierarchical scheduler with default subport bandwidth profile. It also allows to update a subport with different subport rates dynamically.
--- examples/qos_sched/cfg_file.c | 151 +++++++++++++++++++-------------- examples/qos_sched/cfg_file.h | 4 + examples/qos_sched/init.c | 20 +++-- examples/qos_sched/main.h | 1 + examples/qos_sched/profile.cfg | 3 + 5 files changed, 110 insertions(+), 69 deletions(-)
examples/qos_sched/cfg_file.c +87 -64
@@ -142,6 +142,93 @@ cfg_load_pipe(struct rte_cfgfile *cfg, struct rte_sched_pipe_params *pipe_paramsreturn 0 ; } +int +cfg_load_subport_profile (struct rte_cfgfile *cfg, +struct rte_sched_subport_profile_params *subport_profile) +{ +int i; +const char *entry; +int profiles; + +if (!cfg || !subport_profile) +return -1 ; + + profiles =rte_cfgfile_num_sections (cfg,"subport profile" , +sizeof ("subport profile" ) -1 ); + subport_params[0 ].n_pipe_profiles = profiles; + +for (i =0 ; i < profiles; i++) { +char sec_name[32 ]; +snprintf (sec_name,sizeof (sec_name),"subport profile %d" , i); + + entry =rte_cfgfile_get_entry (cfg, sec_name,"tb rate" ); +if (entry) + subport_profile[i].tb_rate = (uint64_t )atoi (entry); + + entry =rte_cfgfile_get_entry (cfg, sec_name,"tb size" ); +if (entry) + subport_profile[i].tb_size = (uint64_t )atoi (entry); + + entry =rte_cfgfile_get_entry (cfg, sec_name,"tc period" ); +if (entry) + subport_profile[i].tc_period = (uint64_t )atoi (entry); + + entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 0 rate" ); +if (entry) + subport_profile[i].tc_rate[0 ] = (uint64_t )atoi (entry); + + entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 1 rate" ); +if (entry) + subport_profile[i].tc_rate[1 ] = (uint64_t )atoi (entry); + + entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 2 rate" ); +if (entry) + subport_profile[i].tc_rate[2 ] = (uint64_t )atoi (entry); + + entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 3 rate" ); +if (entry) + subport_profile[i].tc_rate[3 ] = (uint64_t )atoi (entry); + + entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 4 rate" ); +if (entry) + subport_profile[i].tc_rate[4 ] = (uint64_t )atoi (entry); + + entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 5 rate" ); +if (entry) + subport_profile[i].tc_rate[5 ] = (uint64_t )atoi (entry); + + entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 6 rate" ); +if (entry) + subport_profile[i].tc_rate[6 ] = (uint64_t )atoi (entry); + + entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 7 rate" ); +if (entry) + subport_profile[i].tc_rate[7 ] = (uint64_t )atoi (entry); + + entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 8 rate" ); +if (entry) + subport_profile[i].tc_rate[8 ] = (uint64_t )atoi (entry); + + entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 9 rate" ); +if (entry) + subport_profile[i].tc_rate[9 ] = (uint64_t )atoi (entry); + + entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 10 rate" ); +if (entry) + subport_profile[i].tc_rate[10 ] = (uint64_t )atoi (entry); + + entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 11 rate" ); +if (entry) + subport_profile[i].tc_rate[11 ] = (uint64_t )atoi (entry); + + entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 12 rate" ); +if (entry) + subport_profile[i].tc_rate[12 ] = (uint64_t )atoi (entry); + } + +return 0 ; +} +int cfg_load_subport (struct rte_cfgfile *cfg,struct rte_sched_subport_params *subport_params) {
@@ -267,70 +354,6 @@ cfg_load_subport(struct rte_cfgfile *cfg, struct rte_sched_subport_params *subpo } } - entry =rte_cfgfile_get_entry (cfg, sec_name,"tb rate" ); -if (entry) - subport_params[i].tb_rate = (uint64_t )atoi (entry); - - entry =rte_cfgfile_get_entry (cfg, sec_name,"tb size" ); -if (entry) - subport_params[i].tb_size = (uint64_t )atoi (entry); - - entry =rte_cfgfile_get_entry (cfg, sec_name,"tc period" ); -if (entry) - subport_params[i].tc_period = (uint64_t )atoi (entry); - - entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 0 rate" ); -if (entry) - subport_params[i].tc_rate[0 ] = (uint64_t )atoi (entry); - - entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 1 rate" ); -if (entry) - subport_params[i].tc_rate[1 ] = (uint64_t )atoi (entry); - - entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 2 rate" ); -if (entry) - subport_params[i].tc_rate[2 ] = (uint64_t )atoi (entry); - - entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 3 rate" ); -if (entry) - subport_params[i].tc_rate[3 ] = (uint64_t )atoi (entry); - - entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 4 rate" ); -if (entry) - subport_params[i].tc_rate[4 ] = (uint64_t )atoi (entry); - - entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 5 rate" ); -if (entry) - subport_params[i].tc_rate[5 ] = (uint64_t )atoi (entry); - - entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 6 rate" ); -if (entry) - subport_params[i].tc_rate[6 ] = (uint64_t )atoi (entry); - - entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 7 rate" ); -if (entry) - subport_params[i].tc_rate[7 ] = (uint64_t )atoi (entry); - - entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 8 rate" ); -if (entry) - subport_params[i].tc_rate[8 ] = (uint64_t )atoi (entry); - - entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 9 rate" ); -if (entry) - subport_params[i].tc_rate[9 ] = (uint64_t )atoi (entry); - - entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 10 rate" ); -if (entry) - subport_params[i].tc_rate[10 ] = (uint64_t )atoi (entry); - - entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 11 rate" ); -if (entry) - subport_params[i].tc_rate[11 ] = (uint64_t )atoi (entry); - - entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 12 rate" ); -if (entry) - subport_params[i].tc_rate[12 ] = (uint64_t )atoi (entry); -int n_entries =rte_cfgfile_section_num_entries (cfg, sec_name);struct rte_cfgfile_entry entries[n_entries];
examples/qos_sched/cfg_file.h +4 -0
@@ -14,4 +14,8 @@ int cfg_load_pipe(struct rte_cfgfile *cfg, struct rte_sched_pipe_params *pipe);int cfg_load_subport (struct rte_cfgfile *cfg,struct rte_sched_subport_params *subport); +int cfg_load_subport_profile (struct rte_cfgfile *cfg, +struct rte_sched_subport_profile_params + *subport_profile); +#endif
examples/qos_sched/init.c +15 -5
@@ -192,15 +192,20 @@ static struct rte_sched_pipe_params pipe_profiles[MAX_SCHED_PIPE_PROFILES] = { }, }; -struct rte_sched_subport_params subport_params[MAX_SCHED_SUBPORTS ] = { +static struct rte_sched_subport_profile_params + subport_profile[MAX_SCHED_SUBPORT_PROFILES ] = { { .tb_rate =1250000000 , .tb_size =1000000 , - .tc_rate = {1250000000 ,1250000000 ,1250000000 ,1250000000 ,1250000000 ,1250000000 ,1250000000 ,1250000000 ,1250000000 ,1250000000 ,1250000000 ,1250000000 ,1250000000 }, .tc_period =10 , + }, +}; + +struct rte_sched_subport_params subport_params[MAX_SCHED_SUBPORTS ] = { + { .n_pipes_per_subport_enabled =4096 , .qsize = {64 ,64 ,64 ,64 ,64 ,64 ,64 ,64 ,64 ,64 ,64 ,64 ,64 }, .pipe_profiles = pipe_profiles,
@@ -285,6 +290,9 @@ struct rte_sched_port_params port_params = { .mtu = 6 + 6 + 4 + 4 + 2 + 1500, .frame_overhead = RTE_SCHED_FRAME_OVERHEAD_DEFAULT, .n_subports_per_port = 1, + .n_subport_profiles = 1, + .subport_profiles = subport_profile, + .n_max_subport_profiles = MAX_SCHED_SUBPORT_PROFILES, .n_pipes_per_subport = MAX_SCHED_PIPES, };
@@ -315,10 +323,11 @@ app_init_sched_port(uint32_t portid, uint32_t socketid)for (subport =0 ; subport < port_params.n_subports_per_port; subport ++) { err =rte_sched_subport_config (port, subport, - &subport_params[subport],0 ); + &subport_params[subport], +0 );if (err) { -rte_exit (EXIT_FAILURE ,"Unable to config sched subport %u, err=%d\n" , - subport, err); +rte_exit (EXIT_FAILURE ,"Unable to config sched " +"subport %u, err=%d\n" , subport, err); } uint32_t n_pipes_per_subport =
@@ -351,6 +360,7 @@ app_load_cfg_profile(const char *profile)cfg_load_port (file, &port_params);cfg_load_subport (file, subport_params); +cfg_load_subport_profile (file, subport_profile);cfg_load_pipe (file, pipe_profiles);rte_cfgfile_close (file);
examples/qos_sched/main.h +1 -0
@@ -51,6 +51,7 @@ extern "C" {#define MAX_SCHED_SUBPORTS 8#define MAX_SCHED_PIPES 4096#define MAX_SCHED_PIPE_PROFILES 256 +#define MAX_SCHED_SUBPORT_PROFILES 8#ifndef APP_COLLECT_STAT #define APP_COLLECT_STAT 1
examples/qos_sched/profile.cfg +3 -0
@@ -26,6 +26,9 @@ number of subports per port = 1 number of pipes per subport = 4096 queue sizes = 64 64 64 64 64 64 64 64 64 64 64 64 64 +subport 0-8 = 0 ; These subports are configured with subport profile 0 + +[subport profile 0] tb rate = 1250000000 ; Bytes per second tb size = 1000000 ; Bytes
Signature · 1 line
2.17.1
PATCH v6 5/8 example/ip_pipeline: update subport rate dynamically
In reply to Savinay DharmappaModify the ip_pipeline application to build the hierarchical scheduler with default subport bandwidth profile. It also allows to update a subport with different subport rates dynamically
--- examples/ip_pipeline/cli.c | 68 ++++++++------------ examples/ip_pipeline/tmgr.c | 121 ++++++++++++++++++++++++++++++------ examples/ip_pipeline/tmgr.h | 5 +- 3 files changed, 134 insertions(+), 60 deletions(-)
examples/ip_pipeline/cli.c +27 -41
@@ -393,12 +393,7 @@ static const char cmd_tmgr_subport_profile_help[] =" <tc0_rate> <tc1_rate> <tc2_rate> <tc3_rate> <tc4_rate>" " <tc5_rate> <tc6_rate> <tc7_rate> <tc8_rate>" " <tc9_rate> <tc10_rate> <tc11_rate> <tc12_rate>\n" -" <tc_period>\n" -" pps <n_pipes_per_subport>\n" -" qsize <qsize_tc0> <qsize_tc1> <qsize_tc2>" -" <qsize_tc3> <qsize_tc4> <qsize_tc5> <qsize_tc6>" -" <qsize_tc7> <qsize_tc8> <qsize_tc9> <qsize_tc10>" -" <qsize_tc11> <qsize_tc12>" ; +" <tc_period>\n" ; static void cmd_tmgr_subport_profile(char **tokens,
@@ -406,57 +401,37 @@ cmd_tmgr_subport_profile(char **tokens, char *out, size_t out_size) { -struct rte_sched_subport_params p; +struct rte_sched_subport_profile_params subport_profile;int status, i; -if (n_tokens !=35 ) { +if (n_tokens !=21 ) {snprintf (out, out_size,MSG_ARG_MISMATCH , tokens[0 ]);return ; } -if (parser_read_uint64 (&p.tb_rate, tokens[3 ]) !=0 ) { +if (parser_read_uint64 (&subport_profile.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 (&subport_profile.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 (&subport_profile.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 (&subport_profile.tc_period, tokens[18 ]) !=0 ) {snprintf (out, out_size,MSG_ARG_INVALID ,"tc_period" );return ; } -if (strcmp (tokens[19 ],"pps" ) !=0 ) { -snprintf (out, out_size,MSG_ARG_NOT_FOUND ,"pps" ); -return ; - } - -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 ; - } - -if (strcmp (tokens[21 ],"qsize" ) !=0 ) { -snprintf (out, out_size,MSG_ARG_NOT_FOUND ,"qsize" ); -return ; - } - -for (i =0 ; i <RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE ; i++) -if (parser_read_uint16 (&p.qsize[i], tokens[22 + i]) !=0 ) { -snprintf (out, out_size,MSG_ARG_INVALID ,"qsize" ); -return ; - } - - status =tmgr_subport_profile_add (&p); + status =tmgr_subport_profile_add (&subport_profile);if (status !=0 ) {snprintf (out, out_size,MSG_CMD_FAIL , tokens[0 ]);return ;
@@ -530,6 +505,7 @@ static const char cmd_tmgr_help[] ="tmgr <tmgr_name>\n" " rate <rate>\n" " spp <n_subports_per_port>\n" +" pps <n_pipes_per_subport>\n" " fo <frame_overhead>\n" " mtu <mtu>\n" " cpu <cpu_id>\n" ;
@@ -544,7 +520,7 @@ cmd_tmgr(char **tokens,char *name;struct tmgr_port *tmgr_port; -if (n_tokens !=12 ) { +if (n_tokens !=14 ) {snprintf (out, out_size,MSG_ARG_MISMATCH , tokens[0 ]);return ; }
@@ -571,32 +547,42 @@ cmd_tmgr(char **tokens,return ; } -if (strcmp (tokens[6 ],"fo" ) !=0 ) { +if (strcmp (tokens[6 ],"pps" ) !=0 ) { +snprintf (out, out_size,MSG_ARG_NOT_FOUND ,"spp" ); +return ; + } + +if (parser_read_uint32 (&p.n_pipes_per_subport, tokens[7 ]) !=0 ) { +snprintf (out, out_size,MSG_ARG_INVALID ,"n_pipes_per_subport" ); +return ; + } + +if (strcmp (tokens[8 ],"fo" ) !=0 ) {snprintf (out, out_size,MSG_ARG_NOT_FOUND ,"fo" );return ; } -if (parser_read_uint32 (&p.frame_overhead, tokens[7 ]) !=0 ) { +if (parser_read_uint32 (&p.frame_overhead, tokens[9 ]) !=0 ) {snprintf (out, out_size,MSG_ARG_INVALID ,"frame_overhead" );return ; } -if (strcmp (tokens[8 ],"mtu" ) !=0 ) { +if (strcmp (tokens[10 ],"mtu" ) !=0 ) {snprintf (out, out_size,MSG_ARG_NOT_FOUND ,"mtu" );return ; } -if (parser_read_uint32 (&p.mtu, tokens[9 ]) !=0 ) { +if (parser_read_uint32 (&p.mtu, tokens[11 ]) !=0 ) {snprintf (out, out_size,MSG_ARG_INVALID ,"mtu" );return ; } -if (strcmp (tokens[10 ],"cpu" ) !=0 ) { +if (strcmp (tokens[12 ],"cpu" ) !=0 ) {snprintf (out, out_size,MSG_ARG_NOT_FOUND ,"cpu" );return ; } -if (parser_read_uint32 (&p.cpu_id, tokens[11 ]) !=0 ) { +if (parser_read_uint32 (&p.cpu_id, tokens[13 ]) !=0 ) {snprintf (out, out_size,MSG_ARG_INVALID ,"cpu_id" );return ; }
examples/ip_pipeline/tmgr.c +103 -18
202 lines not on this page · raw message
examples/ip_pipeline/tmgr.h +4 -1
@@ -9,6 +9,7 @@#include <sys/queue.h> #include <rte_sched.h> +#include <rte_red.h> #include "common.h"
@@ -29,6 +30,7 @@ struct tmgr_port {char name[NAME_SIZE ];struct rte_sched_port *s;uint32_t n_subports_per_port; +uint32_t n_pipes_per_subport; };TAILQ_HEAD (tmgr_port_list, tmgr_port);
@@ -42,13 +44,14 @@ tmgr_port_find(const char *name);struct tmgr_port_params {uint64_t rate;uint32_t n_subports_per_port; +uint32_t n_pipes_per_subport;uint32_t frame_overhead;uint32_t mtu;uint32_t cpu_id; };int -tmgr_subport_profile_add (struct rte_sched_subport_params *p); +tmgr_subport_profile_add (struct rte_sched_subport_profile_params *sp);int tmgr_pipe_profile_add (struct rte_sched_pipe_params *p);
Signature · 1 line
2.17.1
PATCH v6 6/8 drivers/softnic: update subport rate dynamically
In reply to Savinay DharmappaModify the softnic drivers to build the hierarchical scheduler with default subport bandwidth profile. It also allows to update a subport with different subport rates dynamically.
--- .../net/softnic/rte_eth_softnic_internals.h | 11 +- drivers/net/softnic/rte_eth_softnic_tm.c | 243 ++++++++++++++---- 2 files changed, 195 insertions(+), 59 deletions(-)
drivers/net/softnic/rte_eth_softnic_internals.h +9 -2
@@ -164,11 +164,18 @@ TAILQ_HEAD(softnic_link_list, softnic_link);#ifndef TM_MAX_PIPE_PROFILE #define TM_MAX_PIPE_PROFILE 256#endif + +#ifndef TM_MAX_SUBPORT_PROFILE +#define TM_MAX_SUBPORT_PROFILE 256 +#endif +struct tm_params {struct rte_sched_port_params port_params; -struct rte_sched_subport_params subport_params[TM_MAX_SUBPORTS ]; - +struct rte_sched_subport_profile_params + subport_profile[TM_MAX_SUBPORT_PROFILE ]; +uint32_t n_subport_profiles; +uint32_t subport_to_profile[TM_MAX_SUBPORT_PROFILE ];struct rte_sched_pipe_params pipe_profiles[TM_MAX_PIPE_PROFILE ];uint32_t n_pipe_profiles;uint32_t pipe_to_profile[TM_MAX_SUBPORTS *TM_MAX_PIPES_PER_SUBPORT ];
drivers/net/softnic/rte_eth_softnic_tm.c +186 -57
335 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH v6 7/8 app/test_sched: update subport rate dynamically
In reply to Savinay DharmappaModify the test_sched application to build the hierarchical scheduler with default subport bandwidth profile. It also allows to update a subport with different subport rates dynamically
--- app/test/test_sched.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)
app/test/test_sched.c +11 -2
@@ -21,6 +21,7 @@#define PIPE 1#define TC 2#define QUEUE 0 +#define MAX_SCHED_SUBPORT_PROFILES 8static struct rte_sched_pipe_params pipe_profile[] = { {/* Profile #0 */
@@ -36,15 +37,20 @@ static struct rte_sched_pipe_params pipe_profile[] = { }, }; -static struct rte_sched_subport_params subport_param[] = { +static struct rte_sched_subport_profile_params + subport_profile[] = { { .tb_rate =1250000000 , .tb_size =1000000 , - .tc_rate = {1250000000 ,1250000000 ,1250000000 ,1250000000 ,1250000000 ,1250000000 ,1250000000 ,1250000000 ,1250000000 ,1250000000 ,1250000000 ,1250000000 ,1250000000 }, .tc_period =10 , + }, +}; + +static struct rte_sched_subport_params subport_param[] = { + { .n_pipes_per_subport_enabled =1024 , .qsize = {32 ,32 ,32 ,32 ,32 ,32 ,32 ,32 ,32 ,32 ,32 ,32 ,32 }, .pipe_profiles = pipe_profile,
@@ -59,6 +65,9 @@ static struct rte_sched_port_params port_param = { .mtu = 1522, .frame_overhead = RTE_SCHED_FRAME_OVERHEAD_DEFAULT, .n_subports_per_port = 1, + .n_subport_profiles = 1, + .subport_profiles = subport_profile, + .n_max_subport_profiles = MAX_SCHED_SUBPORT_PROFILES, .n_pipes_per_subport = 1024, };
Signature · 1 line
2.17.1
PATCH v6 8/8 sched: remove redundant code
In reply to Savinay DharmappaRemove redundant data structure fields references from functions and subport level data structures. It also update the release and deprecation note
--- doc/guides/rel_notes/deprecation.rst | 6 ---- doc/guides/rel_notes/release_20_11.rst | 2 ++ lib/librte_sched/rte_sched.c | 42 ++------------------------ lib/librte_sched/rte_sched.h | 12 -------- 4 files changed, 4 insertions(+), 58 deletions(-)
doc/guides/rel_notes/deprecation.rst +0 -6
@@ -212,12 +212,6 @@ Deprecation Notices in "rte_sched.h". These changes are aligned to improvements suggested in the RFC https://mails.dpdk.org/archives/dev/2018-November/120035.html. -* sched: To allow dynamic configuration of the subport bandwidth profile, - changes will be made to data structures ``rte_sched_subport_params``, - ``rte_sched_port_params`` and new data structure, API functions will be - defined in ``rte_sched.h``. These changes are aligned as suggested in the - RFC https://mails.dpdk.org/archives/dev/2020-July/175161.html - * metrics: The function ``rte_metrics_init`` will have a non-void return in order to notify errors instead of calling ``rte_exit``.
doc/guides/rel_notes/release_20_11.rst +2 -0
@@ -131,6 +131,8 @@ Removed Items * Removed Python 2 support since it was EOL'd in January 2020. +* sched: Add support to update subport bandwidth dynamically. + API Changes -----------
lib/librte_sched/rte_sched.c +2 -40
65 lines not on this page · raw message
lib/librte_sched/rte_sched.h +0 -12
@@ -149,18 +149,6 @@ struct rte_sched_pipe_params {* byte. */ struct rte_sched_subport_params { -/** Token bucket rate (measured in bytes per second) */ -uint64_t tb_rate; - -/** Token bucket size (measured in credits) */ -uint64_t tb_size; - -/** Traffic class rates (measured in bytes per second) */ -uint64_t tc_rate[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE ]; - -/** Enforcement period for rates (measured in milliseconds) */ -uint64_t tc_period; -/** Number of subport pipes. * The subport can enable/allocate fewer pipes than the maximum * number set through struct port_params::n_max_pipes_per_subport,
Signature · 1 line
2.17.1
Re: [dpdk-dev] [PATCH v6 0/8] Enable dynamic config of subport bandwidth
In reply to Savinay DharmappaQuoted 29 lines
-----Original Message-----
From: Dharmappa, Savinay <[email protected]>
Sent: Tuesday, October 6, 2020 4:27 PM
To: Dumitrescu, Cristian <[email protected]>; Singh, Jasvinder <[email protected]>; [email protected]
Cc: Dharmappa, Savinay <[email protected]>
Subject: [PATCH v6 0/8] Enable dynamic config of subport bandwidthDPDK sched library allows runtime configuration of the pipe profiles to the pipes of the subport once scheduler hierarchy is constructed. However, to change the subport level bandwidth, existing hierarchy needs to be dismantled and whole process of building hierarchy under subport nodes needs to be repeated which might result in router downtime. Furthermore, due to lack of dynamic configuration of the subport bandwidth profile configuration (shaper and Traffic class rates), the user application is unable to dynamically re-distribute the excess-bandwidth of one subport among other subports in the scheduler hierarchy. Therefore, it is also not possible to adjust the subport bandwidth profile in sync with dynamic changes in pipe profiles of subscribers who want to consume higher bandwidth opportunistically.
This patch series implements dynamic configuration of the subport bandwidth
profile to overcome the runtime situation when group of subscribers are not using the allotted bandwidth and dynamic bandwidth re-distribution is needed the without making any structural changes in the hierarchy.
Quoted 4 lines
The implementation work includes refactoring the existing api and data structures defined for port and subport level, new APIs for adding subport level bandwidth profiles that can be used in runtime
v7 cover Enable dynamic config of subport bandwidth
In reply to Savinay DharmappaDPDK sched library allows runtime configuration of the pipe profiles to the pipes of the subport once scheduler hierarchy is constructed. However, to change the subport level bandwidth, existing hierarchy needs to be dismantled and whole process of building hierarchy under subport nodes needs to be repeated which might result in router downtime. Furthermore, due to lack of dynamic configuration of the subport bandwidth profile configuration (shaper and Traffic class rates), the user application is unable to dynamically re-distribute the excess-bandwidth of one subport among other subports in the scheduler hierarchy. Therefore, it is also not possible to adjust the subport bandwidth profile in sync with dynamic changes in pipe profiles of subscribers who want to consume higher bandwidth opportunistically.
This patch series implements dynamic configuration of the subport bandwidth profile to overcome the runtime situation when group of subscribers are not using the allotted bandwidth and dynamic bandwidth re-distribution is needed the without making any structural changes in the hierarchy.
The implementation work includes refactoring the existing api and data structures defined for port and subport level, new APIs for adding subport level bandwidth profiles that can be used in runtime
Savinay Dharmappa (8):
sched: add support profile table
sched: introduce subport profile add function
sched: update subport rate dynamically example/qos_sched: update subport rate dynamically example/ip_pipeline: update subport rate dynamically drivers/softnic: update subport rate dynamically app/test_sched: update subport rate dynamically
sched: remove redundant code
app/test/test_sched.c | 15 +- doc/guides/rel_notes/deprecation.rst | 6 - doc/guides/rel_notes/release_20_11.rst | 1 + .../net/softnic/rte_eth_softnic_internals.h | 11 +- drivers/net/softnic/rte_eth_softnic_tm.c | 243 +++++-- examples/ip_pipeline/cli.c | 68 +- examples/ip_pipeline/tmgr.c | 121 +++- examples/ip_pipeline/tmgr.h | 5 +- examples/qos_sched/cfg_file.c | 151 ++-- examples/qos_sched/cfg_file.h | 4 + examples/qos_sched/init.c | 21 +- examples/qos_sched/main.h | 1 + examples/qos_sched/profile.cfg | 3 + lib/librte_sched/rte_sched.c | 678 ++++++++++++------ lib/librte_sched/rte_sched.h | 73 +- lib/librte_sched/rte_sched_version.map | 2 + 16 files changed, 958 insertions(+), 445 deletions(-)
Signature · 1 line
2.17.1
PATCH v7 1/8 sched: add support profile table
Add subport profile table to internal port data structure and update the port config function.
--- lib/librte_sched/rte_sched.c | 197 ++++++++++++++++++++++++++++++++++- lib/librte_sched/rte_sched.h | 25 +++++ 2 files changed, 219 insertions(+), 3 deletions(-)
lib/librte_sched/rte_sched.c +194 -3
@@ -101,6 +101,16 @@ enum grinder_state {e_GRINDER_READ_MBUF }; +struct rte_sched_subport_profile { +/* Token bucket (TB) */ +uint64_t tb_period; +uint64_t tb_credits_per_period; +uint64_t tb_size; + +uint64_t tc_credits_per_period[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE ]; +uint64_t tc_period; +}; +struct rte_sched_grinder {/* Pipe cache */ uint16_t pcache_qmask[RTE_SCHED_GRINDER_PCACHE_SIZE ];
@@ -212,6 +222,8 @@ struct rte_sched_port {uint16_t pipe_queue[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE ];uint8_t pipe_tc[RTE_SCHED_QUEUES_PER_PIPE ];uint8_t tc_queue[RTE_SCHED_QUEUES_PER_PIPE ]; +uint32_t n_subport_profiles; +uint32_t n_max_subport_profiles;uint64_t rate;uint32_t mtu;uint32_t frame_overhead;
@@ -230,6 +242,7 @@ struct rte_sched_port {uint32_t subport_id;/* Large data structures */ +struct rte_sched_subport_profile *subport_profiles; struct rte_sched_subport *subports[0] __rte_cache_aligned; } __rte_cache_aligned;
@@ -375,9 +388,61 @@ pipe_profile_check(struct rte_sched_pipe_params *params,return 0 ; } +static int +subport_profile_check (struct rte_sched_subport_profile_params *params, +uint64_t rate) +{ +uint32_t i; + +/* Check user parameters */ +if (params ==NULL ) { +RTE_LOG (ERR ,SCHED ,"%s: " +"Incorrect value for parameter params\n" , __func__); +return -EINVAL ; + } + +if (params->tb_rate ==0 || params->tb_rate > rate) { +RTE_LOG (ERR ,SCHED ,"%s: " +"Incorrect value for tb rate\n" , __func__); +return -EINVAL ; + } + +if (params->tb_size ==0 ) { +RTE_LOG (ERR ,SCHED ,"%s: " +"Incorrect value for tb size\n" , __func__); +return -EINVAL ; + } + +for (i =0 ; i <RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE ; i++) { +uint64_t tc_rate = params->tc_rate[i]; + +if (tc_rate ==0 || (tc_rate > params->tb_rate)) { +RTE_LOG (ERR ,SCHED ,"%s: " +"Incorrect value for tc rate\n" , __func__); +return -EINVAL ; + } + } + +if (params->tc_rate[RTE_SCHED_TRAFFIC_CLASS_BE ] ==0 ) { +RTE_LOG (ERR ,SCHED ,"%s: " +"Incorrect tc rate(best effort)\n" , __func__); +return -EINVAL ; + } + +if (params->tc_period ==0 ) { +RTE_LOG (ERR ,SCHED ,"%s: " +"Incorrect value for tc period\n" , __func__); +return -EINVAL ; + } + +return 0 ; +} +static int rte_sched_port_check_params (struct rte_sched_port_params *params) { +uint32_t i; +if (params ==NULL ) {RTE_LOG (ERR ,SCHED ,"%s: Incorrect value for parameter params\n" , __func__);
@@ -414,6 +479,29 @@ rte_sched_port_check_params(struct rte_sched_port_params *params)return -EINVAL ; } +if (params->subport_profiles ==NULL || + params->n_subport_profiles ==0 || + params->n_max_subport_profiles ==0 || + params->n_subport_profiles > params->n_max_subport_profiles) { +RTE_LOG (ERR ,SCHED , +"%s: Incorrect value for subport profiles\n" , __func__); +return -EINVAL ; + } + +for (i =0 ; i < params->n_subport_profiles; i++) { +struct rte_sched_subport_profile_params *p = + params->subport_profiles + i; +int status; + + status =subport_profile_check (p, params->rate); +if (status !=0 ) { +RTE_LOG (ERR ,SCHED , +"%s: subport profile check failed(%d)\n" , + __func__, status); +return -EINVAL ; + } + } +/* n_pipes_per_subport: non-zero, power of 2 */ if (params->n_pipes_per_subport ==0 || !rte_is_power_of_2 (params->n_pipes_per_subport)) {
@@ -555,6 +643,42 @@ rte_sched_port_log_pipe_profile(struct rte_sched_subport *subport, uint32_t i) p->wrr_cost[0], p->wrr_cost[1], p->wrr_cost[2], p->wrr_cost[3]); } +static void +rte_sched_port_log_subport_profile (struct rte_sched_port *port,uint32_t i) +{ +struct rte_sched_subport_profile *p = port->subport_profiles + i; + +RTE_LOG (DEBUG ,SCHED ,"Low level config for subport profile %u:\n" +"Token bucket: period = %" PRIu64", credits per period = %" PRIu64"," +"size = %" PRIu64"\n" +"Traffic classes: period = %" PRIu64",\n" +"credits per period = [%" PRIu64", %" PRIu64", %" PRIu64", %" PRIu64 +" %" PRIu64", %" PRIu64", %" PRIu64", %" PRIu64", %" PRIu64", %" PRIu64 +" %" PRIu64", %" PRIu64", %" PRIu64"]\n" , + i, + +/* Token bucket */ + p->tb_period, + p->tb_credits_per_period, + p->tb_size, + +/* Traffic classes */ + p->tc_period, + p->tc_credits_per_period[0 ], + p->tc_credits_per_period[1 ], + p->tc_credits_per_period[2 ], + p->tc_credits_per_period[3 ], + p->tc_credits_per_period[4 ], + p->tc_credits_per_period[5 ], + p->tc_credits_per_period[6 ], + p->tc_credits_per_period[7 ], + p->tc_credits_per_period[8 ], + p->tc_credits_per_period[9 ], + p->tc_credits_per_period[10 ], + p->tc_credits_per_period[11 ], + p->tc_credits_per_period[12 ]); +} +static inline uint64_t rte_sched_time_ms_to_bytes (uint64_t time_ms,uint64_t rate) {
@@ -623,6 +747,37 @@ rte_sched_pipe_profile_convert(struct rte_sched_subport *subport, dst->wrr_cost[3 ] = (uint8_t ) wrr_cost[3 ]; } +static void +rte_sched_subport_profile_convert (struct rte_sched_subport_profile_params *src, +struct rte_sched_subport_profile *dst, +uint64_t rate) +{ +uint32_t i; + +/* Token Bucket */ +if (src->tb_rate == rate) { + dst->tb_credits_per_period =1 ; + dst->tb_period =1 ; + }else { +double tb_rate = (double ) src->tb_rate + / (double ) rate; +double d =RTE_SCHED_TB_RATE_CONFIG_ERR ; + +rte_approx_64 (tb_rate, d, &dst->tb_credits_per_period, + &dst->tb_period); + } + + dst->tb_size = src->tb_size; + +/* Traffic Classes */ + dst->tc_period =rte_sched_time_ms_to_bytes (src->tc_period, rate); + +for (i =0 ; i <RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE ; i++) + dst->tc_credits_per_period[i] + =rte_sched_time_ms_to_bytes (src->tc_period, + src->tc_rate[i]); +} +static void rte_sched_subport_config_pipe_profile_table (struct rte_sched_subport *subport,struct rte_sched_subport_params *params,uint64_t rate)
@@ -647,6 +802,24 @@ rte_sched_subport_config_pipe_profile_table(struct rte_sched_subport *subport, } } +static void +rte_sched_port_config_subport_profile_table (struct rte_sched_port *port, +struct rte_sched_port_params *params, +uint64_t rate) +{ +uint32_t i; + +for (i =0 ; i < port->n_subport_profiles; i++) { +struct rte_sched_subport_profile_params *src + = params->subport_profiles + i; +struct rte_sched_subport_profile *dst + = port->subport_profiles + i; + +rte_sched_subport_profile_convert (src, dst, rate); +rte_sched_port_log_subport_profile (port, i); + } +} + static int rte_sched_subport_check_params(struct rte_sched_subport_params *params, uint32_t n_max_pipes_per_subport,
@@ -793,7 +966,7 @@ struct rte_sched_port * rte_sched_port_config(struct rte_sched_port_params *params) {struct rte_sched_port *port =NULL ; -uint32_t size0, size1; +uint32_t size0, size1, size2;uint32_t cycles_per_byte;uint32_t i, j;int status;
@@ -808,10 +981,21 @@ rte_sched_port_config(struct rte_sched_port_params *params) size0 =sizeof (struct rte_sched_port ); size1 = params->n_subports_per_port *sizeof (struct rte_sched_subport *); + size2 = params->n_max_subport_profiles * +sizeof (struct rte_sched_subport_profile );/* Allocate memory to store the data structures */ - port =rte_zmalloc_socket ("qos_params" , size0 + size1,RTE_CACHE_LINE_SIZE , - params->socket); + port =rte_zmalloc_socket ("qos_params" , size0 + size1, +RTE_CACHE_LINE_SIZE , params->socket); +if (port ==NULL ) { +RTE_LOG (ERR ,SCHED ,"%s: Memory allocation fails\n" , __func__); + +return NULL ; + } + +/* Allocate memory to store the subport profile */ + port->subport_profiles =rte_zmalloc_socket ("subport_profile" , size2, +RTE_CACHE_LINE_SIZE , params->socket);if (port ==NULL ) {RTE_LOG (ERR ,SCHED ,"%s: Memory allocation fails\n" , __func__);
@@ -820,6 +1004,8 @@ rte_sched_port_config(struct rte_sched_port_params *params)/* User parameters */ port->n_subports_per_port = params->n_subports_per_port; + port->n_subport_profiles = params->n_subport_profiles; + port->n_max_subport_profiles = params->n_max_subport_profiles; port->n_pipes_per_subport = params->n_pipes_per_subport; port->n_pipes_per_subport_log2 =__builtin_ctz (params->n_pipes_per_subport);
@@ -850,6 +1036,9 @@ rte_sched_port_config(struct rte_sched_port_params *params) port->time_cpu_bytes =0 ; port->time =0 ; +/* Subport profile table */ +rte_sched_port_config_subport_profile_table (port, params, port->rate); + cycles_per_byte = (rte_get_tsc_hz () <<RTE_SCHED_TIME_SHIFT ) / params->rate; port->inv_cycles_per_byte =rte_reciprocal_value (cycles_per_byte);
@@ -905,6 +1094,7 @@ rte_sched_port_free(struct rte_sched_port *port)for (i =0 ; i < port->n_subports_per_port; i++)rte_sched_subport_free (port, port->subports[i]); +rte_free (port->subport_profiles);rte_free (port); }
@@ -961,6 +1151,7 @@ rte_sched_free_memory(struct rte_sched_port *port, uint32_t n_subports)rte_sched_subport_free (port, subport); } +rte_free (port->subport_profiles);rte_free (port); }
lib/librte_sched/rte_sched.h +25 -0
@@ -192,6 +192,20 @@ struct rte_sched_subport_params {#endif }; +struct rte_sched_subport_profile_params { +/** Token bucket rate (measured in bytes per second) */ +uint64_t tb_rate; + +/** Token bucket size (measured in credits) */ +uint64_t tb_size; + +/** Traffic class rates (measured in bytes per second) */ +uint64_t tc_rate[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE ]; + +/** Enforcement period for rates (measured in milliseconds) */ +uint64_t tc_period; +}; +/** Subport statistics */ struct rte_sched_subport_stats {/** Number of packets successfully written */
@@ -254,6 +268,17 @@ struct rte_sched_port_params {/** Number of subports */ uint32_t n_subports_per_port; +/** subport profile table. +* Every pipe is configured using one of the profiles from this table. +*/ +struct rte_sched_subport_profile_params *subport_profiles; + +/** Profiles in the pipe profile table */ +uint32_t n_subport_profiles; + +/** Max allowed profiles in the pipe profile table */ +uint32_t n_max_subport_profiles; +/** Maximum number of subport pipes. * This parameter is used to reserve a fixed number of bits * in struct rte_mbuf::sched.queue_id for the pipe_id for all
Signature · 1 line
2.17.1
PATCH v7 2/8 sched: introduce subport profile add function
In reply to Savinay DharmappaAPI to add new subport bandwidth profile.
--- lib/librte_sched/rte_sched.c | 66 ++++++++++++++++++++++++++ lib/librte_sched/rte_sched.h | 23 +++++++++ lib/librte_sched/rte_sched_version.map | 2 + 3 files changed, 91 insertions(+)
lib/librte_sched/rte_sched.c +66 -0
@@ -1528,6 +1528,72 @@ rte_sched_subport_pipe_profile_add(struct rte_sched_port *port,return 0 ; } +int +rte_sched_port_subport_profile_add (struct rte_sched_port *port, +struct rte_sched_subport_profile_params *params, +uint32_t *subport_profile_id) +{ +int status; +uint32_t i; +struct rte_sched_subport_profile *dst; + +/* Port */ +if (port ==NULL ) { +RTE_LOG (ERR ,SCHED ,"%s: " +"Incorrect value for parameter port\n" , __func__); +return -EINVAL ; + } + +if (params ==NULL ) { +RTE_LOG (ERR ,SCHED ,"%s: " +"Incorrect value for parameter profile\n" , __func__); +return -EINVAL ; + } + +if (subport_profile_id ==NULL ) { +RTE_LOG (ERR ,SCHED ,"%s: " +"Incorrect value for parameter subport_profile_id\n" , + __func__); +return -EINVAL ; + } + + dst = port->subport_profiles + port->n_subport_profiles; + +/* Subport profiles exceeds the max limit */ +if (port->n_subport_profiles >= port->n_max_subport_profiles) { +RTE_LOG (ERR ,SCHED ,"%s: " +"Number of subport profiles exceeds the max limit\n" , + __func__); +return -EINVAL ; + } + + status =subport_profile_check (params, port->rate); +if (status !=0 ) { +RTE_LOG (ERR ,SCHED , +"%s: subport profile check failed(%d)\n" , __func__, status); +return -EINVAL ; + } + +rte_sched_subport_profile_convert (params, dst, port->rate); + +/* Subport profile should not exists */ +for (i =0 ; i < port->n_subport_profiles; i++) +if (memcmp (port->subport_profiles + i, + dst,sizeof (*dst)) ==0 ) { +RTE_LOG (ERR ,SCHED , +"%s: subport profile exists\n" , __func__); +return -EINVAL ; + } + +/* Subport profile commit */ + *subport_profile_id = port->n_subport_profiles; + port->n_subport_profiles++; + +rte_sched_port_log_subport_profile (port, *subport_profile_id); + +return 0 ; +} + static inline uint32_t rte_sched_port_qindex(struct rte_sched_port *port, uint32_t subport,
lib/librte_sched/rte_sched.h +23 -0
@@ -336,6 +336,29 @@ rte_sched_subport_pipe_profile_add(struct rte_sched_port *port,struct rte_sched_pipe_params *params, uint32_t *pipe_profile_id); +/** +* @warning +* @b EXPERIMENTAL: this API may change without prior notice. +* +* Hierarchical scheduler subport bandwidth profile add +* Note that this function is safe to use in runtime for adding new +* subport bandwidth profile as it doesn't have any impact on hiearchical +* structure of the scheduler. +* @param port +* Handle to port scheduler instance +* @param profile +* Subport bandwidth profile +* @param subport_profile_d +* Subport profile id +* @return +* 0 upon success, error code otherwise +*/ +__rte_experimental +int +rte_sched_port_subport_profile_add (struct rte_sched_port *port, +struct rte_sched_subport_profile_params *profile, +uint32_t *subport_profile_id); +/** * Hierarchical scheduler subport configuration *
lib/librte_sched/rte_sched_version.map +2 -0
@@ -28,4 +28,6 @@ EXPERIMENTAL { global: rte_sched_subport_pipe_profile_add; + # added in 20.11 + rte_sched_port_subport_profile_add; };
Signature · 1 line
2.17.1
PATCH v7 3/8 sched: update subport rate dynamically
In reply to Savinay DharmappaAdd support to update subport rate dynamically.
--- app/test/test_sched.c | 2 +- drivers/net/softnic/rte_eth_softnic_tm.c | 6 +- examples/ip_pipeline/tmgr.c | 6 +- examples/qos_sched/init.c | 3 +- lib/librte_sched/rte_sched.c | 373 +++++++++++------------ lib/librte_sched/rte_sched.h | 13 +- 6 files changed, 202 insertions(+), 201 deletions(-)
app/test/test_sched.c +1 -1
@@ -138,7 +138,7 @@ test_sched(void) port =rte_sched_port_config (&port_param);TEST_ASSERT_NOT_NULL (port,"Error config sched port\n" ); - err =rte_sched_subport_config (port,SUBPORT , subport_param); + err =rte_sched_subport_config (port,SUBPORT , subport_param,0 );TEST_ASSERT_SUCCESS (err,"Error config sched, err=%d\n" , err);for (pipe =0 ; pipe < subport_param[0 ].n_pipes_per_subport_enabled; pipe++) {
drivers/net/softnic/rte_eth_softnic_tm.c +3 -3
@@ -92,7 +92,7 @@ softnic_tmgr_port_create(struct pmd_internals *p, status =rte_sched_subport_config (sched, subport_id, - &t->subport_params[subport_id]); + &t->subport_params[subport_id],0 );if (status) {rte_sched_port_free (sched);return NULL ;
@@ -1141,7 +1141,7 @@ update_subport_tc_rate(struct rte_eth_dev *dev,/* Update the subport configuration. */ if (rte_sched_subport_config (SCHED (p), - subport_id, &subport_params)) + subport_id, &subport_params,0 ))return -1 ;/* Commit changes. */
@@ -2912,7 +2912,7 @@ update_subport_rate(struct rte_eth_dev *dev,/* Update the subport configuration. */ if (rte_sched_subport_config (SCHED (p), subport_id, - &subport_params)) + &subport_params,0 ))return -1 ;/* Commit changes. */
examples/ip_pipeline/tmgr.c +4 -2
@@ -119,7 +119,8 @@ tmgr_port_create(const char *name, struct tmgr_port_params *params) status =rte_sched_subport_config ( s, i, - &subport_profile[0 ]); + &subport_profile[0 ], +0 );if (status) {rte_sched_port_free (s);
@@ -180,7 +181,8 @@ tmgr_subport_config(const char *port_name, status =rte_sched_subport_config ( port->s, subport_id, - &subport_profile[subport_profile_id]); + &subport_profile[subport_profile_id], +0 );return status; }
examples/qos_sched/init.c +2 -1
@@ -314,7 +314,8 @@ app_init_sched_port(uint32_t portid, uint32_t socketid) }for (subport =0 ; subport < port_params.n_subports_per_port; subport ++) { - err =rte_sched_subport_config (port, subport, &subport_params[subport]); + err =rte_sched_subport_config (port, subport, + &subport_params[subport],0 );if (err) {rte_exit (EXIT_FAILURE ,"Unable to config sched subport %u, err=%d\n" , subport, err);
lib/librte_sched/rte_sched.c +182 -191
525 lines not on this page · raw message
lib/librte_sched/rte_sched.h +10 -3
@@ -361,20 +361,27 @@ rte_sched_port_subport_profile_add(struct rte_sched_port *port,/** * Hierarchical scheduler subport configuration -* +* Note that this function is safe to use at runtime +* to configure subport bandwidth profile. * @param port * Handle to port scheduler instance * @param subport_id * Subport ID * @param params -* Subport configuration parameters +* Subport configuration parameters. Must be non-NULL +* for first invocation (i.e initialization) for a given +* subport. Ignored (recommended value is NULL) for all +* subsequent invocation on the same subport. +* @param subport_profile_id +* ID of subport bandwidth profile * @return * 0 upon success, error code otherwise */ int rte_sched_subport_config (struct rte_sched_port *port,uint32_t subport_id, -struct rte_sched_subport_params *params); +struct rte_sched_subport_params *params, +uint32_t subport_profile_id);/** * Hierarchical scheduler pipe configuration
Signature · 1 line
2.17.1
PATCH v7 4/8 example/qos_sched: update subport rate dynamically
In reply to Savinay DharmappaModify the qos_sched application to build the hierarchical scheduler with default subport bandwidth profile. It also allows to update a subport with different subport rates dynamically.
--- examples/qos_sched/cfg_file.c | 151 +++++++++++++++++++-------------- examples/qos_sched/cfg_file.h | 4 + examples/qos_sched/init.c | 20 +++-- examples/qos_sched/main.h | 1 + examples/qos_sched/profile.cfg | 3 + 5 files changed, 110 insertions(+), 69 deletions(-)
examples/qos_sched/cfg_file.c +87 -64
@@ -142,6 +142,93 @@ cfg_load_pipe(struct rte_cfgfile *cfg, struct rte_sched_pipe_params *pipe_paramsreturn 0 ; } +int +cfg_load_subport_profile (struct rte_cfgfile *cfg, +struct rte_sched_subport_profile_params *subport_profile) +{ +int i; +const char *entry; +int profiles; + +if (!cfg || !subport_profile) +return -1 ; + + profiles =rte_cfgfile_num_sections (cfg,"subport profile" , +sizeof ("subport profile" ) -1 ); + subport_params[0 ].n_pipe_profiles = profiles; + +for (i =0 ; i < profiles; i++) { +char sec_name[32 ]; +snprintf (sec_name,sizeof (sec_name),"subport profile %d" , i); + + entry =rte_cfgfile_get_entry (cfg, sec_name,"tb rate" ); +if (entry) + subport_profile[i].tb_rate = (uint64_t )atoi (entry); + + entry =rte_cfgfile_get_entry (cfg, sec_name,"tb size" ); +if (entry) + subport_profile[i].tb_size = (uint64_t )atoi (entry); + + entry =rte_cfgfile_get_entry (cfg, sec_name,"tc period" ); +if (entry) + subport_profile[i].tc_period = (uint64_t )atoi (entry); + + entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 0 rate" ); +if (entry) + subport_profile[i].tc_rate[0 ] = (uint64_t )atoi (entry); + + entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 1 rate" ); +if (entry) + subport_profile[i].tc_rate[1 ] = (uint64_t )atoi (entry); + + entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 2 rate" ); +if (entry) + subport_profile[i].tc_rate[2 ] = (uint64_t )atoi (entry); + + entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 3 rate" ); +if (entry) + subport_profile[i].tc_rate[3 ] = (uint64_t )atoi (entry); + + entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 4 rate" ); +if (entry) + subport_profile[i].tc_rate[4 ] = (uint64_t )atoi (entry); + + entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 5 rate" ); +if (entry) + subport_profile[i].tc_rate[5 ] = (uint64_t )atoi (entry); + + entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 6 rate" ); +if (entry) + subport_profile[i].tc_rate[6 ] = (uint64_t )atoi (entry); + + entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 7 rate" ); +if (entry) + subport_profile[i].tc_rate[7 ] = (uint64_t )atoi (entry); + + entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 8 rate" ); +if (entry) + subport_profile[i].tc_rate[8 ] = (uint64_t )atoi (entry); + + entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 9 rate" ); +if (entry) + subport_profile[i].tc_rate[9 ] = (uint64_t )atoi (entry); + + entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 10 rate" ); +if (entry) + subport_profile[i].tc_rate[10 ] = (uint64_t )atoi (entry); + + entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 11 rate" ); +if (entry) + subport_profile[i].tc_rate[11 ] = (uint64_t )atoi (entry); + + entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 12 rate" ); +if (entry) + subport_profile[i].tc_rate[12 ] = (uint64_t )atoi (entry); + } + +return 0 ; +} +int cfg_load_subport (struct rte_cfgfile *cfg,struct rte_sched_subport_params *subport_params) {
@@ -267,70 +354,6 @@ cfg_load_subport(struct rte_cfgfile *cfg, struct rte_sched_subport_params *subpo } } - entry =rte_cfgfile_get_entry (cfg, sec_name,"tb rate" ); -if (entry) - subport_params[i].tb_rate = (uint64_t )atoi (entry); - - entry =rte_cfgfile_get_entry (cfg, sec_name,"tb size" ); -if (entry) - subport_params[i].tb_size = (uint64_t )atoi (entry); - - entry =rte_cfgfile_get_entry (cfg, sec_name,"tc period" ); -if (entry) - subport_params[i].tc_period = (uint64_t )atoi (entry); - - entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 0 rate" ); -if (entry) - subport_params[i].tc_rate[0 ] = (uint64_t )atoi (entry); - - entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 1 rate" ); -if (entry) - subport_params[i].tc_rate[1 ] = (uint64_t )atoi (entry); - - entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 2 rate" ); -if (entry) - subport_params[i].tc_rate[2 ] = (uint64_t )atoi (entry); - - entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 3 rate" ); -if (entry) - subport_params[i].tc_rate[3 ] = (uint64_t )atoi (entry); - - entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 4 rate" ); -if (entry) - subport_params[i].tc_rate[4 ] = (uint64_t )atoi (entry); - - entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 5 rate" ); -if (entry) - subport_params[i].tc_rate[5 ] = (uint64_t )atoi (entry); - - entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 6 rate" ); -if (entry) - subport_params[i].tc_rate[6 ] = (uint64_t )atoi (entry); - - entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 7 rate" ); -if (entry) - subport_params[i].tc_rate[7 ] = (uint64_t )atoi (entry); - - entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 8 rate" ); -if (entry) - subport_params[i].tc_rate[8 ] = (uint64_t )atoi (entry); - - entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 9 rate" ); -if (entry) - subport_params[i].tc_rate[9 ] = (uint64_t )atoi (entry); - - entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 10 rate" ); -if (entry) - subport_params[i].tc_rate[10 ] = (uint64_t )atoi (entry); - - entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 11 rate" ); -if (entry) - subport_params[i].tc_rate[11 ] = (uint64_t )atoi (entry); - - entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 12 rate" ); -if (entry) - subport_params[i].tc_rate[12 ] = (uint64_t )atoi (entry); -int n_entries =rte_cfgfile_section_num_entries (cfg, sec_name);struct rte_cfgfile_entry entries[n_entries];
examples/qos_sched/cfg_file.h +4 -0
@@ -14,4 +14,8 @@ int cfg_load_pipe(struct rte_cfgfile *cfg, struct rte_sched_pipe_params *pipe);int cfg_load_subport (struct rte_cfgfile *cfg,struct rte_sched_subport_params *subport); +int cfg_load_subport_profile (struct rte_cfgfile *cfg, +struct rte_sched_subport_profile_params + *subport_profile); +#endif
examples/qos_sched/init.c +15 -5
@@ -192,15 +192,20 @@ static struct rte_sched_pipe_params pipe_profiles[MAX_SCHED_PIPE_PROFILES] = { }, }; -struct rte_sched_subport_params subport_params[MAX_SCHED_SUBPORTS ] = { +static struct rte_sched_subport_profile_params + subport_profile[MAX_SCHED_SUBPORT_PROFILES ] = { { .tb_rate =1250000000 , .tb_size =1000000 , - .tc_rate = {1250000000 ,1250000000 ,1250000000 ,1250000000 ,1250000000 ,1250000000 ,1250000000 ,1250000000 ,1250000000 ,1250000000 ,1250000000 ,1250000000 ,1250000000 }, .tc_period =10 , + }, +}; + +struct rte_sched_subport_params subport_params[MAX_SCHED_SUBPORTS ] = { + { .n_pipes_per_subport_enabled =4096 , .qsize = {64 ,64 ,64 ,64 ,64 ,64 ,64 ,64 ,64 ,64 ,64 ,64 ,64 }, .pipe_profiles = pipe_profiles,
@@ -285,6 +290,9 @@ struct rte_sched_port_params port_params = { .mtu = 6 + 6 + 4 + 4 + 2 + 1500, .frame_overhead = RTE_SCHED_FRAME_OVERHEAD_DEFAULT, .n_subports_per_port = 1, + .n_subport_profiles = 1, + .subport_profiles = subport_profile, + .n_max_subport_profiles = MAX_SCHED_SUBPORT_PROFILES, .n_pipes_per_subport = MAX_SCHED_PIPES, };
@@ -315,10 +323,11 @@ app_init_sched_port(uint32_t portid, uint32_t socketid)for (subport =0 ; subport < port_params.n_subports_per_port; subport ++) { err =rte_sched_subport_config (port, subport, - &subport_params[subport],0 ); + &subport_params[subport], +0 );if (err) { -rte_exit (EXIT_FAILURE ,"Unable to config sched subport %u, err=%d\n" , - subport, err); +rte_exit (EXIT_FAILURE ,"Unable to config sched " +"subport %u, err=%d\n" , subport, err); } uint32_t n_pipes_per_subport =
@@ -351,6 +360,7 @@ app_load_cfg_profile(const char *profile)cfg_load_port (file, &port_params);cfg_load_subport (file, subport_params); +cfg_load_subport_profile (file, subport_profile);cfg_load_pipe (file, pipe_profiles);rte_cfgfile_close (file);
examples/qos_sched/main.h +1 -0
@@ -51,6 +51,7 @@ extern "C" {#define MAX_SCHED_SUBPORTS 8#define MAX_SCHED_PIPES 4096#define MAX_SCHED_PIPE_PROFILES 256 +#define MAX_SCHED_SUBPORT_PROFILES 8#ifndef APP_COLLECT_STAT #define APP_COLLECT_STAT 1
examples/qos_sched/profile.cfg +3 -0
@@ -26,6 +26,9 @@ number of subports per port = 1 number of pipes per subport = 4096 queue sizes = 64 64 64 64 64 64 64 64 64 64 64 64 64 +subport 0-8 = 0 ; These subports are configured with subport profile 0 + +[subport profile 0] tb rate = 1250000000 ; Bytes per second tb size = 1000000 ; Bytes
Signature · 1 line
2.17.1
PATCH v7 5/8 example/ip_pipeline: update subport rate dynamically
In reply to Savinay DharmappaModify the ip_pipeline application to build the hierarchical scheduler with default subport bandwidth profile. It also allows to update a subport with different subport rates dynamically
--- examples/ip_pipeline/cli.c | 68 ++++++++------------ examples/ip_pipeline/tmgr.c | 121 ++++++++++++++++++++++++++++++------ examples/ip_pipeline/tmgr.h | 5 +- 3 files changed, 134 insertions(+), 60 deletions(-)
examples/ip_pipeline/cli.c +27 -41
@@ -393,12 +393,7 @@ static const char cmd_tmgr_subport_profile_help[] =" <tc0_rate> <tc1_rate> <tc2_rate> <tc3_rate> <tc4_rate>" " <tc5_rate> <tc6_rate> <tc7_rate> <tc8_rate>" " <tc9_rate> <tc10_rate> <tc11_rate> <tc12_rate>\n" -" <tc_period>\n" -" pps <n_pipes_per_subport>\n" -" qsize <qsize_tc0> <qsize_tc1> <qsize_tc2>" -" <qsize_tc3> <qsize_tc4> <qsize_tc5> <qsize_tc6>" -" <qsize_tc7> <qsize_tc8> <qsize_tc9> <qsize_tc10>" -" <qsize_tc11> <qsize_tc12>" ; +" <tc_period>\n" ; static void cmd_tmgr_subport_profile(char **tokens,
@@ -406,57 +401,37 @@ cmd_tmgr_subport_profile(char **tokens, char *out, size_t out_size) { -struct rte_sched_subport_params p; +struct rte_sched_subport_profile_params subport_profile;int status, i; -if (n_tokens !=35 ) { +if (n_tokens !=21 ) {snprintf (out, out_size,MSG_ARG_MISMATCH , tokens[0 ]);return ; } -if (parser_read_uint64 (&p.tb_rate, tokens[3 ]) !=0 ) { +if (parser_read_uint64 (&subport_profile.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 (&subport_profile.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 (&subport_profile.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 (&subport_profile.tc_period, tokens[18 ]) !=0 ) {snprintf (out, out_size,MSG_ARG_INVALID ,"tc_period" );return ; } -if (strcmp (tokens[19 ],"pps" ) !=0 ) { -snprintf (out, out_size,MSG_ARG_NOT_FOUND ,"pps" ); -return ; - } - -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 ; - } - -if (strcmp (tokens[21 ],"qsize" ) !=0 ) { -snprintf (out, out_size,MSG_ARG_NOT_FOUND ,"qsize" ); -return ; - } - -for (i =0 ; i <RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE ; i++) -if (parser_read_uint16 (&p.qsize[i], tokens[22 + i]) !=0 ) { -snprintf (out, out_size,MSG_ARG_INVALID ,"qsize" ); -return ; - } - - status =tmgr_subport_profile_add (&p); + status =tmgr_subport_profile_add (&subport_profile);if (status !=0 ) {snprintf (out, out_size,MSG_CMD_FAIL , tokens[0 ]);return ;
@@ -530,6 +505,7 @@ static const char cmd_tmgr_help[] ="tmgr <tmgr_name>\n" " rate <rate>\n" " spp <n_subports_per_port>\n" +" pps <n_pipes_per_subport>\n" " fo <frame_overhead>\n" " mtu <mtu>\n" " cpu <cpu_id>\n" ;
@@ -544,7 +520,7 @@ cmd_tmgr(char **tokens,char *name;struct tmgr_port *tmgr_port; -if (n_tokens !=12 ) { +if (n_tokens !=14 ) {snprintf (out, out_size,MSG_ARG_MISMATCH , tokens[0 ]);return ; }
@@ -571,32 +547,42 @@ cmd_tmgr(char **tokens,return ; } -if (strcmp (tokens[6 ],"fo" ) !=0 ) { +if (strcmp (tokens[6 ],"pps" ) !=0 ) { +snprintf (out, out_size,MSG_ARG_NOT_FOUND ,"spp" ); +return ; + } + +if (parser_read_uint32 (&p.n_pipes_per_subport, tokens[7 ]) !=0 ) { +snprintf (out, out_size,MSG_ARG_INVALID ,"n_pipes_per_subport" ); +return ; + } + +if (strcmp (tokens[8 ],"fo" ) !=0 ) {snprintf (out, out_size,MSG_ARG_NOT_FOUND ,"fo" );return ; } -if (parser_read_uint32 (&p.frame_overhead, tokens[7 ]) !=0 ) { +if (parser_read_uint32 (&p.frame_overhead, tokens[9 ]) !=0 ) {snprintf (out, out_size,MSG_ARG_INVALID ,"frame_overhead" );return ; } -if (strcmp (tokens[8 ],"mtu" ) !=0 ) { +if (strcmp (tokens[10 ],"mtu" ) !=0 ) {snprintf (out, out_size,MSG_ARG_NOT_FOUND ,"mtu" );return ; } -if (parser_read_uint32 (&p.mtu, tokens[9 ]) !=0 ) { +if (parser_read_uint32 (&p.mtu, tokens[11 ]) !=0 ) {snprintf (out, out_size,MSG_ARG_INVALID ,"mtu" );return ; } -if (strcmp (tokens[10 ],"cpu" ) !=0 ) { +if (strcmp (tokens[12 ],"cpu" ) !=0 ) {snprintf (out, out_size,MSG_ARG_NOT_FOUND ,"cpu" );return ; } -if (parser_read_uint32 (&p.cpu_id, tokens[11 ]) !=0 ) { +if (parser_read_uint32 (&p.cpu_id, tokens[13 ]) !=0 ) {snprintf (out, out_size,MSG_ARG_INVALID ,"cpu_id" );return ; }
examples/ip_pipeline/tmgr.c +103 -18
202 lines not on this page · raw message
examples/ip_pipeline/tmgr.h +4 -1
@@ -9,6 +9,7 @@#include <sys/queue.h> #include <rte_sched.h> +#include <rte_red.h> #include "common.h"
@@ -29,6 +30,7 @@ struct tmgr_port {char name[NAME_SIZE ];struct rte_sched_port *s;uint32_t n_subports_per_port; +uint32_t n_pipes_per_subport; };TAILQ_HEAD (tmgr_port_list, tmgr_port);
@@ -42,13 +44,14 @@ tmgr_port_find(const char *name);struct tmgr_port_params {uint64_t rate;uint32_t n_subports_per_port; +uint32_t n_pipes_per_subport;uint32_t frame_overhead;uint32_t mtu;uint32_t cpu_id; };int -tmgr_subport_profile_add (struct rte_sched_subport_params *p); +tmgr_subport_profile_add (struct rte_sched_subport_profile_params *sp);int tmgr_pipe_profile_add (struct rte_sched_pipe_params *p);
Signature · 1 line
2.17.1
PATCH v7 6/8 drivers/softnic: update subport rate dynamically
In reply to Savinay DharmappaModify the softnic drivers to build the hierarchical scheduler with default subport bandwidth profile. It also allows to update a subport with different subport rates dynamically.
--- .../net/softnic/rte_eth_softnic_internals.h | 11 +- drivers/net/softnic/rte_eth_softnic_tm.c | 243 ++++++++++++++---- 2 files changed, 195 insertions(+), 59 deletions(-)
drivers/net/softnic/rte_eth_softnic_internals.h +9 -2
@@ -164,11 +164,18 @@ TAILQ_HEAD(softnic_link_list, softnic_link);#ifndef TM_MAX_PIPE_PROFILE #define TM_MAX_PIPE_PROFILE 256#endif + +#ifndef TM_MAX_SUBPORT_PROFILE +#define TM_MAX_SUBPORT_PROFILE 256 +#endif +struct tm_params {struct rte_sched_port_params port_params; -struct rte_sched_subport_params subport_params[TM_MAX_SUBPORTS ]; - +struct rte_sched_subport_profile_params + subport_profile[TM_MAX_SUBPORT_PROFILE ]; +uint32_t n_subport_profiles; +uint32_t subport_to_profile[TM_MAX_SUBPORT_PROFILE ];struct rte_sched_pipe_params pipe_profiles[TM_MAX_PIPE_PROFILE ];uint32_t n_pipe_profiles;uint32_t pipe_to_profile[TM_MAX_SUBPORTS *TM_MAX_PIPES_PER_SUBPORT ];
drivers/net/softnic/rte_eth_softnic_tm.c +186 -57
335 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH v7 7/8 app/test_sched: update subport rate dynamically
In reply to Savinay DharmappaModify the test_sched application to build the hierarchical scheduler with default subport bandwidth profile. It also allows to update a subport with different subport rates dynamically
--- app/test/test_sched.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)
app/test/test_sched.c +11 -2
@@ -21,6 +21,7 @@#define PIPE 1#define TC 2#define QUEUE 0 +#define MAX_SCHED_SUBPORT_PROFILES 8static struct rte_sched_pipe_params pipe_profile[] = { {/* Profile #0 */
@@ -36,15 +37,20 @@ static struct rte_sched_pipe_params pipe_profile[] = { }, }; -static struct rte_sched_subport_params subport_param[] = { +static struct rte_sched_subport_profile_params + subport_profile[] = { { .tb_rate =1250000000 , .tb_size =1000000 , - .tc_rate = {1250000000 ,1250000000 ,1250000000 ,1250000000 ,1250000000 ,1250000000 ,1250000000 ,1250000000 ,1250000000 ,1250000000 ,1250000000 ,1250000000 ,1250000000 }, .tc_period =10 , + }, +}; + +static struct rte_sched_subport_params subport_param[] = { + { .n_pipes_per_subport_enabled =1024 , .qsize = {32 ,32 ,32 ,32 ,32 ,32 ,32 ,32 ,32 ,32 ,32 ,32 ,32 }, .pipe_profiles = pipe_profile,
@@ -59,6 +65,9 @@ static struct rte_sched_port_params port_param = { .mtu = 1522, .frame_overhead = RTE_SCHED_FRAME_OVERHEAD_DEFAULT, .n_subports_per_port = 1, + .n_subport_profiles = 1, + .subport_profiles = subport_profile, + .n_max_subport_profiles = MAX_SCHED_SUBPORT_PROFILES, .n_pipes_per_subport = 1024, };
Signature · 1 line
2.17.1
PATCH v7 8/8 sched: remove redundant code
In reply to Savinay DharmappaRemove redundant data structure fields references from functions and subport level data structures. It also update the release and deprecation note
--- doc/guides/rel_notes/deprecation.rst | 6 ---- doc/guides/rel_notes/release_20_11.rst | 1 + lib/librte_sched/rte_sched.c | 42 ++------------------------ lib/librte_sched/rte_sched.h | 12 -------- 4 files changed, 3 insertions(+), 58 deletions(-)
doc/guides/rel_notes/deprecation.rst +0 -6
@@ -212,12 +212,6 @@ Deprecation Notices in "rte_sched.h". These changes are aligned to improvements suggested in the RFC https://mails.dpdk.org/archives/dev/2018-November/120035.html. -* sched: To allow dynamic configuration of the subport bandwidth profile, - changes will be made to data structures ``rte_sched_subport_params``, - ``rte_sched_port_params`` and new data structure, API functions will be - defined in ``rte_sched.h``. These changes are aligned as suggested in the - RFC https://mails.dpdk.org/archives/dev/2020-July/175161.html - * metrics: The function ``rte_metrics_init`` will have a non-void return in order to notify errors instead of calling ``rte_exit``.
doc/guides/rel_notes/release_20_11.rst +1 -0
@@ -111,6 +111,7 @@ New Features * Extern objects and functions can be plugged into the pipeline. * Transaction-oriented table updates. +* sched: Add support to update subport bandwidth dynamically. Removed Items -------------
lib/librte_sched/rte_sched.c +2 -40
65 lines not on this page · raw message
lib/librte_sched/rte_sched.h +0 -12
@@ -149,18 +149,6 @@ struct rte_sched_pipe_params {* byte. */ struct rte_sched_subport_params { -/** Token bucket rate (measured in bytes per second) */ -uint64_t tb_rate; - -/** Token bucket size (measured in credits) */ -uint64_t tb_size; - -/** Traffic class rates (measured in bytes per second) */ -uint64_t tc_rate[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE ]; - -/** Enforcement period for rates (measured in milliseconds) */ -uint64_t tc_period; -/** Number of subport pipes. * The subport can enable/allocate fewer pipes than the maximum * number set through struct port_params::n_max_pipes_per_subport,
Signature · 1 line
2.17.1
Re: [dpdk-dev] [PATCH v7 0/8] Enable dynamic config of subport bandwidth
In reply to Savinay DharmappaQuoted 61 lines
-----Original Message-----
From: Dharmappa, Savinay <[email protected]>
Sent: Tuesday, October 6, 2020 7:02 PM
To: Dumitrescu, Cristian <[email protected]>; Singh, Jasvinder <[email protected]>; [email protected]
Cc: Dharmappa, Savinay <[email protected]>
Subject: [PATCH v7 0/8] Enable dynamic config of subport bandwidthDPDK sched library allows runtime configuration of the pipe profiles to the pipes of the subport once scheduler hierarchy is constructed. However, to change the subport level bandwidth, existing hierarchy needs to be dismantled and whole process of building hierarchy under subport nodes needs to be repeated which might result in router downtime. Furthermore, due to lack of dynamic configuration of the subport bandwidth profile configuration (shaper and Traffic class rates), the user application is unable to dynamically re-distribute the excess-bandwidth of one subport among other subports in the scheduler hierarchy. Therefore, it is also not possible to adjust the subport bandwidth profile in sync with dynamic changes in pipe profiles of subscribers who want to consume higher bandwidth opportunistically.
This patch series implements dynamic configuration of the subport bandwidth
profile to overcome the runtime situation when group of subscribers are not using the allotted bandwidth and dynamic bandwidth re-distribution is needed the without making any structural changes in the hierarchy.The implementation work includes refactoring the existing api and data structures defined for port and subport level, new APIs for adding subport level bandwidth profiles that can be used in runtime
Savinay Dharmappa (8):
sched: add support profile table
sched: introduce subport profile add function
sched: update subport rate dynamically example/qos_sched: update subport rate dynamically example/ip_pipeline: update subport rate dynamicallydrivers/softnic: update subport rate dynamically app/test_sched: update subport rate dynamically
sched: remove redundant codeapp/test/test_sched.c | 15 +- doc/guides/rel_notes/deprecation.rst | 6 - doc/guides/rel_notes/release_20_11.rst | 1 + .../net/softnic/rte_eth_softnic_internals.h | 11 +- drivers/net/softnic/rte_eth_softnic_tm.c | 243 +++++-- examples/ip_pipeline/cli.c | 68 +- examples/ip_pipeline/tmgr.c | 121 +++- examples/ip_pipeline/tmgr.h | 5 +- examples/qos_sched/cfg_file.c | 151 ++-- examples/qos_sched/cfg_file.h | 4 + examples/qos_sched/init.c | 21 +- examples/qos_sched/main.h | 1 + examples/qos_sched/profile.cfg | 3 + lib/librte_sched/rte_sched.c | 678 ++++++++++++------ lib/librte_sched/rte_sched.h | 73 +- lib/librte_sched/rte_sched_version.map | 2 + 16 files changed, 958 insertions(+), 445 deletions(-)
Quoted 2 lines
--
2.17.1
v8 cover Enable dynamic config of subport bandwidth
In reply to Savinay DharmappaDPDK sched library allows runtime configuration of the pipe profiles to the pipes of the subport once scheduler hierarchy is constructed. However, to change the subport level bandwidth, existing hierarchy needs to be dismantled and whole process of building hierarchy under subport nodes needs to be repeated which might result in router downtime. Furthermore, due to lack of dynamic configuration of the subport bandwidth profile configuration (shaper and Traffic class rates), the user application is unable to dynamically re-distribute the excess-bandwidth of one subport among other subports in the scheduler hierarchy. Therefore, it is also not possible to adjust the subport bandwidth profile in sync with dynamic changes in pipe profiles of subscribers who want to consume higher bandwidth opportunistically.
This patch series implements dynamic configuration of the subport bandwidth profile to overcome the runtime situation when group of subscribers are not using the allotted bandwidth and dynamic bandwidth re-distribution is needed the without making any structural changes in the hierarchy.
The implementation work includes refactoring the existing api and data structures defined for port and subport level, new APIs for adding subport level bandwidth profiles that can be used in runtime.
---
v7 -> v8
- Fix doxygen and clang build error.
v6 -> v7
- Fix checkpatch warning
and patch apply issue.
v5 -> v6
- Fix build warning.
- change cli of tmgr :
* remove queue size and pipes per subport
from cmdline argument to add traffic
manager subport profile.
* add pipes per subport as cmdline argument to create traffic manger port.
v4 -> v5
- Review comments from patch 3 & 6
from v4 are addressed.
v3 -> v4
- Fix patch apply issue.
v2 -> v3
- Review comments from patch 3 & 5
from v2 are addressed.
v1 -> v2
- Fix checkpatch warnings.
---
Savinay Dharmappa (8):
sched: add support profile table
sched: introduce subport profile add function
sched: update subport rate dynamically example/qos_sched: update subport rate dynamically example/ip_pipeline: update subport rate dynamically drivers/softnic: update subport rate dynamically app/test_sched: update subport rate dynamically
sched: remove redundant code
app/test/test_sched.c | 15 +- doc/guides/rel_notes/deprecation.rst | 6 - doc/guides/rel_notes/release_20_11.rst | 1 + .../net/softnic/rte_eth_softnic_internals.h | 11 +- drivers/net/softnic/rte_eth_softnic_tm.c | 243 +++++-- examples/ip_pipeline/cli.c | 68 +- examples/ip_pipeline/tmgr.c | 121 +++- examples/ip_pipeline/tmgr.h | 5 +- examples/qos_sched/cfg_file.c | 151 ++-- examples/qos_sched/cfg_file.h | 4 + examples/qos_sched/init.c | 21 +- examples/qos_sched/main.h | 1 + examples/qos_sched/profile.cfg | 3 + lib/librte_sched/rte_sched.c | 678 ++++++++++++------ lib/librte_sched/rte_sched.h | 73 +- lib/librte_sched/rte_sched_version.map | 2 + 16 files changed, 958 insertions(+), 445 deletions(-)
Signature · 1 line
2.17.1
PATCH v8 1/8 sched: add support profile table
Add subport profile table to internal port data structure and update the port config function.
--- lib/librte_sched/rte_sched.c | 197 ++++++++++++++++++++++++++++++++++- lib/librte_sched/rte_sched.h | 25 +++++ 2 files changed, 219 insertions(+), 3 deletions(-)
lib/librte_sched/rte_sched.c +194 -3
@@ -101,6 +101,16 @@ enum grinder_state {e_GRINDER_READ_MBUF }; +struct rte_sched_subport_profile { +/* Token bucket (TB) */ +uint64_t tb_period; +uint64_t tb_credits_per_period; +uint64_t tb_size; + +uint64_t tc_credits_per_period[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE ]; +uint64_t tc_period; +}; +struct rte_sched_grinder {/* Pipe cache */ uint16_t pcache_qmask[RTE_SCHED_GRINDER_PCACHE_SIZE ];
@@ -212,6 +222,8 @@ struct rte_sched_port {uint16_t pipe_queue[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE ];uint8_t pipe_tc[RTE_SCHED_QUEUES_PER_PIPE ];uint8_t tc_queue[RTE_SCHED_QUEUES_PER_PIPE ]; +uint32_t n_subport_profiles; +uint32_t n_max_subport_profiles;uint64_t rate;uint32_t mtu;uint32_t frame_overhead;
@@ -230,6 +242,7 @@ struct rte_sched_port {uint32_t subport_id;/* Large data structures */ +struct rte_sched_subport_profile *subport_profiles; struct rte_sched_subport *subports[0] __rte_cache_aligned; } __rte_cache_aligned;
@@ -375,9 +388,61 @@ pipe_profile_check(struct rte_sched_pipe_params *params,return 0 ; } +static int +subport_profile_check (struct rte_sched_subport_profile_params *params, +uint64_t rate) +{ +uint32_t i; + +/* Check user parameters */ +if (params ==NULL ) { +RTE_LOG (ERR ,SCHED ,"%s: " +"Incorrect value for parameter params\n" , __func__); +return -EINVAL ; + } + +if (params->tb_rate ==0 || params->tb_rate > rate) { +RTE_LOG (ERR ,SCHED ,"%s: " +"Incorrect value for tb rate\n" , __func__); +return -EINVAL ; + } + +if (params->tb_size ==0 ) { +RTE_LOG (ERR ,SCHED ,"%s: " +"Incorrect value for tb size\n" , __func__); +return -EINVAL ; + } + +for (i =0 ; i <RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE ; i++) { +uint64_t tc_rate = params->tc_rate[i]; + +if (tc_rate ==0 || (tc_rate > params->tb_rate)) { +RTE_LOG (ERR ,SCHED ,"%s: " +"Incorrect value for tc rate\n" , __func__); +return -EINVAL ; + } + } + +if (params->tc_rate[RTE_SCHED_TRAFFIC_CLASS_BE ] ==0 ) { +RTE_LOG (ERR ,SCHED ,"%s: " +"Incorrect tc rate(best effort)\n" , __func__); +return -EINVAL ; + } + +if (params->tc_period ==0 ) { +RTE_LOG (ERR ,SCHED ,"%s: " +"Incorrect value for tc period\n" , __func__); +return -EINVAL ; + } + +return 0 ; +} +static int rte_sched_port_check_params (struct rte_sched_port_params *params) { +uint32_t i; +if (params ==NULL ) {RTE_LOG (ERR ,SCHED ,"%s: Incorrect value for parameter params\n" , __func__);
@@ -414,6 +479,29 @@ rte_sched_port_check_params(struct rte_sched_port_params *params)return -EINVAL ; } +if (params->subport_profiles ==NULL || + params->n_subport_profiles ==0 || + params->n_max_subport_profiles ==0 || + params->n_subport_profiles > params->n_max_subport_profiles) { +RTE_LOG (ERR ,SCHED , +"%s: Incorrect value for subport profiles\n" , __func__); +return -EINVAL ; + } + +for (i =0 ; i < params->n_subport_profiles; i++) { +struct rte_sched_subport_profile_params *p = + params->subport_profiles + i; +int status; + + status =subport_profile_check (p, params->rate); +if (status !=0 ) { +RTE_LOG (ERR ,SCHED , +"%s: subport profile check failed(%d)\n" , + __func__, status); +return -EINVAL ; + } + } +/* n_pipes_per_subport: non-zero, power of 2 */ if (params->n_pipes_per_subport ==0 || !rte_is_power_of_2 (params->n_pipes_per_subport)) {
@@ -555,6 +643,42 @@ rte_sched_port_log_pipe_profile(struct rte_sched_subport *subport, uint32_t i) p->wrr_cost[0], p->wrr_cost[1], p->wrr_cost[2], p->wrr_cost[3]); } +static void +rte_sched_port_log_subport_profile (struct rte_sched_port *port,uint32_t i) +{ +struct rte_sched_subport_profile *p = port->subport_profiles + i; + +RTE_LOG (DEBUG ,SCHED ,"Low level config for subport profile %u:\n" +"Token bucket: period = %" PRIu64", credits per period = %" PRIu64"," +"size = %" PRIu64"\n" +"Traffic classes: period = %" PRIu64",\n" +"credits per period = [%" PRIu64", %" PRIu64", %" PRIu64", %" PRIu64 +" %" PRIu64", %" PRIu64", %" PRIu64", %" PRIu64", %" PRIu64", %" PRIu64 +" %" PRIu64", %" PRIu64", %" PRIu64"]\n" , + i, + +/* Token bucket */ + p->tb_period, + p->tb_credits_per_period, + p->tb_size, + +/* Traffic classes */ + p->tc_period, + p->tc_credits_per_period[0 ], + p->tc_credits_per_period[1 ], + p->tc_credits_per_period[2 ], + p->tc_credits_per_period[3 ], + p->tc_credits_per_period[4 ], + p->tc_credits_per_period[5 ], + p->tc_credits_per_period[6 ], + p->tc_credits_per_period[7 ], + p->tc_credits_per_period[8 ], + p->tc_credits_per_period[9 ], + p->tc_credits_per_period[10 ], + p->tc_credits_per_period[11 ], + p->tc_credits_per_period[12 ]); +} +static inline uint64_t rte_sched_time_ms_to_bytes (uint64_t time_ms,uint64_t rate) {
@@ -623,6 +747,37 @@ rte_sched_pipe_profile_convert(struct rte_sched_subport *subport, dst->wrr_cost[3 ] = (uint8_t ) wrr_cost[3 ]; } +static void +rte_sched_subport_profile_convert (struct rte_sched_subport_profile_params *src, +struct rte_sched_subport_profile *dst, +uint64_t rate) +{ +uint32_t i; + +/* Token Bucket */ +if (src->tb_rate == rate) { + dst->tb_credits_per_period =1 ; + dst->tb_period =1 ; + }else { +double tb_rate = (double ) src->tb_rate + / (double ) rate; +double d =RTE_SCHED_TB_RATE_CONFIG_ERR ; + +rte_approx_64 (tb_rate, d, &dst->tb_credits_per_period, + &dst->tb_period); + } + + dst->tb_size = src->tb_size; + +/* Traffic Classes */ + dst->tc_period =rte_sched_time_ms_to_bytes (src->tc_period, rate); + +for (i =0 ; i <RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE ; i++) + dst->tc_credits_per_period[i] + =rte_sched_time_ms_to_bytes (src->tc_period, + src->tc_rate[i]); +} +static void rte_sched_subport_config_pipe_profile_table (struct rte_sched_subport *subport,struct rte_sched_subport_params *params,uint64_t rate)
@@ -647,6 +802,24 @@ rte_sched_subport_config_pipe_profile_table(struct rte_sched_subport *subport, } } +static void +rte_sched_port_config_subport_profile_table (struct rte_sched_port *port, +struct rte_sched_port_params *params, +uint64_t rate) +{ +uint32_t i; + +for (i =0 ; i < port->n_subport_profiles; i++) { +struct rte_sched_subport_profile_params *src + = params->subport_profiles + i; +struct rte_sched_subport_profile *dst + = port->subport_profiles + i; + +rte_sched_subport_profile_convert (src, dst, rate); +rte_sched_port_log_subport_profile (port, i); + } +} + static int rte_sched_subport_check_params(struct rte_sched_subport_params *params, uint32_t n_max_pipes_per_subport,
@@ -793,7 +966,7 @@ struct rte_sched_port * rte_sched_port_config(struct rte_sched_port_params *params) {struct rte_sched_port *port =NULL ; -uint32_t size0, size1; +uint32_t size0, size1, size2;uint32_t cycles_per_byte;uint32_t i, j;int status;
@@ -808,10 +981,21 @@ rte_sched_port_config(struct rte_sched_port_params *params) size0 =sizeof (struct rte_sched_port ); size1 = params->n_subports_per_port *sizeof (struct rte_sched_subport *); + size2 = params->n_max_subport_profiles * +sizeof (struct rte_sched_subport_profile );/* Allocate memory to store the data structures */ - port =rte_zmalloc_socket ("qos_params" , size0 + size1,RTE_CACHE_LINE_SIZE , - params->socket); + port =rte_zmalloc_socket ("qos_params" , size0 + size1, +RTE_CACHE_LINE_SIZE , params->socket); +if (port ==NULL ) { +RTE_LOG (ERR ,SCHED ,"%s: Memory allocation fails\n" , __func__); + +return NULL ; + } + +/* Allocate memory to store the subport profile */ + port->subport_profiles =rte_zmalloc_socket ("subport_profile" , size2, +RTE_CACHE_LINE_SIZE , params->socket);if (port ==NULL ) {RTE_LOG (ERR ,SCHED ,"%s: Memory allocation fails\n" , __func__);
@@ -820,6 +1004,8 @@ rte_sched_port_config(struct rte_sched_port_params *params)/* User parameters */ port->n_subports_per_port = params->n_subports_per_port; + port->n_subport_profiles = params->n_subport_profiles; + port->n_max_subport_profiles = params->n_max_subport_profiles; port->n_pipes_per_subport = params->n_pipes_per_subport; port->n_pipes_per_subport_log2 =__builtin_ctz (params->n_pipes_per_subport);
@@ -850,6 +1036,9 @@ rte_sched_port_config(struct rte_sched_port_params *params) port->time_cpu_bytes =0 ; port->time =0 ; +/* Subport profile table */ +rte_sched_port_config_subport_profile_table (port, params, port->rate); + cycles_per_byte = (rte_get_tsc_hz () <<RTE_SCHED_TIME_SHIFT ) / params->rate; port->inv_cycles_per_byte =rte_reciprocal_value (cycles_per_byte);
@@ -905,6 +1094,7 @@ rte_sched_port_free(struct rte_sched_port *port)for (i =0 ; i < port->n_subports_per_port; i++)rte_sched_subport_free (port, port->subports[i]); +rte_free (port->subport_profiles);rte_free (port); }
@@ -961,6 +1151,7 @@ rte_sched_free_memory(struct rte_sched_port *port, uint32_t n_subports)rte_sched_subport_free (port, subport); } +rte_free (port->subport_profiles);rte_free (port); }
lib/librte_sched/rte_sched.h +25 -0
@@ -192,6 +192,20 @@ struct rte_sched_subport_params {#endif }; +struct rte_sched_subport_profile_params { +/** Token bucket rate (measured in bytes per second) */ +uint64_t tb_rate; + +/** Token bucket size (measured in credits) */ +uint64_t tb_size; + +/** Traffic class rates (measured in bytes per second) */ +uint64_t tc_rate[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE ]; + +/** Enforcement period for rates (measured in milliseconds) */ +uint64_t tc_period; +}; +/** Subport statistics */ struct rte_sched_subport_stats {/** Number of packets successfully written */
@@ -254,6 +268,17 @@ struct rte_sched_port_params {/** Number of subports */ uint32_t n_subports_per_port; +/** subport profile table. +* Every pipe is configured using one of the profiles from this table. +*/ +struct rte_sched_subport_profile_params *subport_profiles; + +/** Profiles in the pipe profile table */ +uint32_t n_subport_profiles; + +/** Max allowed profiles in the pipe profile table */ +uint32_t n_max_subport_profiles; +/** Maximum number of subport pipes. * This parameter is used to reserve a fixed number of bits * in struct rte_mbuf::sched.queue_id for the pipe_id for all
Signature · 1 line
2.17.1
PATCH v8 2/8 sched: introduce subport profile add function
In reply to Savinay DharmappaAPI to add new subport bandwidth profile.
--- lib/librte_sched/rte_sched.c | 66 ++++++++++++++++++++++++++ lib/librte_sched/rte_sched.h | 23 +++++++++ lib/librte_sched/rte_sched_version.map | 2 + 3 files changed, 91 insertions(+)
lib/librte_sched/rte_sched.c +66 -0
@@ -1528,6 +1528,72 @@ rte_sched_subport_pipe_profile_add(struct rte_sched_port *port,return 0 ; } +int +rte_sched_port_subport_profile_add (struct rte_sched_port *port, +struct rte_sched_subport_profile_params *params, +uint32_t *subport_profile_id) +{ +int status; +uint32_t i; +struct rte_sched_subport_profile *dst; + +/* Port */ +if (port ==NULL ) { +RTE_LOG (ERR ,SCHED ,"%s: " +"Incorrect value for parameter port\n" , __func__); +return -EINVAL ; + } + +if (params ==NULL ) { +RTE_LOG (ERR ,SCHED ,"%s: " +"Incorrect value for parameter profile\n" , __func__); +return -EINVAL ; + } + +if (subport_profile_id ==NULL ) { +RTE_LOG (ERR ,SCHED ,"%s: " +"Incorrect value for parameter subport_profile_id\n" , + __func__); +return -EINVAL ; + } + + dst = port->subport_profiles + port->n_subport_profiles; + +/* Subport profiles exceeds the max limit */ +if (port->n_subport_profiles >= port->n_max_subport_profiles) { +RTE_LOG (ERR ,SCHED ,"%s: " +"Number of subport profiles exceeds the max limit\n" , + __func__); +return -EINVAL ; + } + + status =subport_profile_check (params, port->rate); +if (status !=0 ) { +RTE_LOG (ERR ,SCHED , +"%s: subport profile check failed(%d)\n" , __func__, status); +return -EINVAL ; + } + +rte_sched_subport_profile_convert (params, dst, port->rate); + +/* Subport profile should not exists */ +for (i =0 ; i < port->n_subport_profiles; i++) +if (memcmp (port->subport_profiles + i, + dst,sizeof (*dst)) ==0 ) { +RTE_LOG (ERR ,SCHED , +"%s: subport profile exists\n" , __func__); +return -EINVAL ; + } + +/* Subport profile commit */ + *subport_profile_id = port->n_subport_profiles; + port->n_subport_profiles++; + +rte_sched_port_log_subport_profile (port, *subport_profile_id); + +return 0 ; +} + static inline uint32_t rte_sched_port_qindex(struct rte_sched_port *port, uint32_t subport,
lib/librte_sched/rte_sched.h +23 -0
@@ -336,6 +336,29 @@ rte_sched_subport_pipe_profile_add(struct rte_sched_port *port,struct rte_sched_pipe_params *params, uint32_t *pipe_profile_id); +/** +* @warning +* @b EXPERIMENTAL: this API may change without prior notice. +* +* Hierarchical scheduler subport bandwidth profile add +* Note that this function is safe to use in runtime for adding new +* subport bandwidth profile as it doesn't have any impact on hiearchical +* structure of the scheduler. +* @param port +* Handle to port scheduler instance +* @param profile +* Subport bandwidth profile +* @param subport_profile_id +* Subport profile id +* @return +* 0 upon success, error code otherwise +*/ +__rte_experimental +int +rte_sched_port_subport_profile_add (struct rte_sched_port *port, +struct rte_sched_subport_profile_params *profile, +uint32_t *subport_profile_id); +/** * Hierarchical scheduler subport configuration *
lib/librte_sched/rte_sched_version.map +2 -0
@@ -28,4 +28,6 @@ EXPERIMENTAL { global: rte_sched_subport_pipe_profile_add; + # added in 20.11 + rte_sched_port_subport_profile_add; };
Signature · 1 line
2.17.1
PATCH v8 3/8 sched: update subport rate dynamically
In reply to Savinay DharmappaAdd support to update subport rate dynamically.
--- app/test/test_sched.c | 2 +- drivers/net/softnic/rte_eth_softnic_tm.c | 6 +- examples/ip_pipeline/tmgr.c | 6 +- examples/qos_sched/init.c | 3 +- lib/librte_sched/rte_sched.c | 373 +++++++++++------------ lib/librte_sched/rte_sched.h | 13 +- 6 files changed, 202 insertions(+), 201 deletions(-)
app/test/test_sched.c +1 -1
@@ -138,7 +138,7 @@ test_sched(void) port =rte_sched_port_config (&port_param);TEST_ASSERT_NOT_NULL (port,"Error config sched port\n" ); - err =rte_sched_subport_config (port,SUBPORT , subport_param); + err =rte_sched_subport_config (port,SUBPORT , subport_param,0 );TEST_ASSERT_SUCCESS (err,"Error config sched, err=%d\n" , err);for (pipe =0 ; pipe < subport_param[0 ].n_pipes_per_subport_enabled; pipe++) {
drivers/net/softnic/rte_eth_softnic_tm.c +3 -3
@@ -92,7 +92,7 @@ softnic_tmgr_port_create(struct pmd_internals *p, status =rte_sched_subport_config (sched, subport_id, - &t->subport_params[subport_id]); + &t->subport_params[subport_id],0 );if (status) {rte_sched_port_free (sched);return NULL ;
@@ -1141,7 +1141,7 @@ update_subport_tc_rate(struct rte_eth_dev *dev,/* Update the subport configuration. */ if (rte_sched_subport_config (SCHED (p), - subport_id, &subport_params)) + subport_id, &subport_params,0 ))return -1 ;/* Commit changes. */
@@ -2912,7 +2912,7 @@ update_subport_rate(struct rte_eth_dev *dev,/* Update the subport configuration. */ if (rte_sched_subport_config (SCHED (p), subport_id, - &subport_params)) + &subport_params,0 ))return -1 ;/* Commit changes. */
examples/ip_pipeline/tmgr.c +4 -2
@@ -119,7 +119,8 @@ tmgr_port_create(const char *name, struct tmgr_port_params *params) status =rte_sched_subport_config ( s, i, - &subport_profile[0 ]); + &subport_profile[0 ], +0 );if (status) {rte_sched_port_free (s);
@@ -180,7 +181,8 @@ tmgr_subport_config(const char *port_name, status =rte_sched_subport_config ( port->s, subport_id, - &subport_profile[subport_profile_id]); + &subport_profile[subport_profile_id], +0 );return status; }
examples/qos_sched/init.c +2 -1
@@ -314,7 +314,8 @@ app_init_sched_port(uint32_t portid, uint32_t socketid) }for (subport =0 ; subport < port_params.n_subports_per_port; subport ++) { - err =rte_sched_subport_config (port, subport, &subport_params[subport]); + err =rte_sched_subport_config (port, subport, + &subport_params[subport],0 );if (err) {rte_exit (EXIT_FAILURE ,"Unable to config sched subport %u, err=%d\n" , subport, err);
lib/librte_sched/rte_sched.c +182 -191
525 lines not on this page · raw message
lib/librte_sched/rte_sched.h +10 -3
@@ -361,20 +361,27 @@ rte_sched_port_subport_profile_add(struct rte_sched_port *port,/** * Hierarchical scheduler subport configuration -* +* Note that this function is safe to use at runtime +* to configure subport bandwidth profile. * @param port * Handle to port scheduler instance * @param subport_id * Subport ID * @param params -* Subport configuration parameters +* Subport configuration parameters. Must be non-NULL +* for first invocation (i.e initialization) for a given +* subport. Ignored (recommended value is NULL) for all +* subsequent invocation on the same subport. +* @param subport_profile_id +* ID of subport bandwidth profile * @return * 0 upon success, error code otherwise */ int rte_sched_subport_config (struct rte_sched_port *port,uint32_t subport_id, -struct rte_sched_subport_params *params); +struct rte_sched_subport_params *params, +uint32_t subport_profile_id);/** * Hierarchical scheduler pipe configuration
Signature · 1 line
2.17.1
PATCH v8 4/8 example/qos_sched: update subport rate dynamically
In reply to Savinay DharmappaModify the qos_sched application to build the hierarchical scheduler with default subport bandwidth profile. It also allows to update a subport with different subport rates dynamically.
--- examples/qos_sched/cfg_file.c | 151 +++++++++++++++++++-------------- examples/qos_sched/cfg_file.h | 4 + examples/qos_sched/init.c | 20 +++-- examples/qos_sched/main.h | 1 + examples/qos_sched/profile.cfg | 3 + 5 files changed, 110 insertions(+), 69 deletions(-)
examples/qos_sched/cfg_file.c +87 -64
@@ -142,6 +142,93 @@ cfg_load_pipe(struct rte_cfgfile *cfg, struct rte_sched_pipe_params *pipe_paramsreturn 0 ; } +int +cfg_load_subport_profile (struct rte_cfgfile *cfg, +struct rte_sched_subport_profile_params *subport_profile) +{ +int i; +const char *entry; +int profiles; + +if (!cfg || !subport_profile) +return -1 ; + + profiles =rte_cfgfile_num_sections (cfg,"subport profile" , +sizeof ("subport profile" ) -1 ); + subport_params[0 ].n_pipe_profiles = profiles; + +for (i =0 ; i < profiles; i++) { +char sec_name[32 ]; +snprintf (sec_name,sizeof (sec_name),"subport profile %d" , i); + + entry =rte_cfgfile_get_entry (cfg, sec_name,"tb rate" ); +if (entry) + subport_profile[i].tb_rate = (uint64_t )atoi (entry); + + entry =rte_cfgfile_get_entry (cfg, sec_name,"tb size" ); +if (entry) + subport_profile[i].tb_size = (uint64_t )atoi (entry); + + entry =rte_cfgfile_get_entry (cfg, sec_name,"tc period" ); +if (entry) + subport_profile[i].tc_period = (uint64_t )atoi (entry); + + entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 0 rate" ); +if (entry) + subport_profile[i].tc_rate[0 ] = (uint64_t )atoi (entry); + + entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 1 rate" ); +if (entry) + subport_profile[i].tc_rate[1 ] = (uint64_t )atoi (entry); + + entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 2 rate" ); +if (entry) + subport_profile[i].tc_rate[2 ] = (uint64_t )atoi (entry); + + entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 3 rate" ); +if (entry) + subport_profile[i].tc_rate[3 ] = (uint64_t )atoi (entry); + + entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 4 rate" ); +if (entry) + subport_profile[i].tc_rate[4 ] = (uint64_t )atoi (entry); + + entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 5 rate" ); +if (entry) + subport_profile[i].tc_rate[5 ] = (uint64_t )atoi (entry); + + entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 6 rate" ); +if (entry) + subport_profile[i].tc_rate[6 ] = (uint64_t )atoi (entry); + + entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 7 rate" ); +if (entry) + subport_profile[i].tc_rate[7 ] = (uint64_t )atoi (entry); + + entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 8 rate" ); +if (entry) + subport_profile[i].tc_rate[8 ] = (uint64_t )atoi (entry); + + entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 9 rate" ); +if (entry) + subport_profile[i].tc_rate[9 ] = (uint64_t )atoi (entry); + + entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 10 rate" ); +if (entry) + subport_profile[i].tc_rate[10 ] = (uint64_t )atoi (entry); + + entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 11 rate" ); +if (entry) + subport_profile[i].tc_rate[11 ] = (uint64_t )atoi (entry); + + entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 12 rate" ); +if (entry) + subport_profile[i].tc_rate[12 ] = (uint64_t )atoi (entry); + } + +return 0 ; +} +int cfg_load_subport (struct rte_cfgfile *cfg,struct rte_sched_subport_params *subport_params) {
@@ -267,70 +354,6 @@ cfg_load_subport(struct rte_cfgfile *cfg, struct rte_sched_subport_params *subpo } } - entry =rte_cfgfile_get_entry (cfg, sec_name,"tb rate" ); -if (entry) - subport_params[i].tb_rate = (uint64_t )atoi (entry); - - entry =rte_cfgfile_get_entry (cfg, sec_name,"tb size" ); -if (entry) - subport_params[i].tb_size = (uint64_t )atoi (entry); - - entry =rte_cfgfile_get_entry (cfg, sec_name,"tc period" ); -if (entry) - subport_params[i].tc_period = (uint64_t )atoi (entry); - - entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 0 rate" ); -if (entry) - subport_params[i].tc_rate[0 ] = (uint64_t )atoi (entry); - - entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 1 rate" ); -if (entry) - subport_params[i].tc_rate[1 ] = (uint64_t )atoi (entry); - - entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 2 rate" ); -if (entry) - subport_params[i].tc_rate[2 ] = (uint64_t )atoi (entry); - - entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 3 rate" ); -if (entry) - subport_params[i].tc_rate[3 ] = (uint64_t )atoi (entry); - - entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 4 rate" ); -if (entry) - subport_params[i].tc_rate[4 ] = (uint64_t )atoi (entry); - - entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 5 rate" ); -if (entry) - subport_params[i].tc_rate[5 ] = (uint64_t )atoi (entry); - - entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 6 rate" ); -if (entry) - subport_params[i].tc_rate[6 ] = (uint64_t )atoi (entry); - - entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 7 rate" ); -if (entry) - subport_params[i].tc_rate[7 ] = (uint64_t )atoi (entry); - - entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 8 rate" ); -if (entry) - subport_params[i].tc_rate[8 ] = (uint64_t )atoi (entry); - - entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 9 rate" ); -if (entry) - subport_params[i].tc_rate[9 ] = (uint64_t )atoi (entry); - - entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 10 rate" ); -if (entry) - subport_params[i].tc_rate[10 ] = (uint64_t )atoi (entry); - - entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 11 rate" ); -if (entry) - subport_params[i].tc_rate[11 ] = (uint64_t )atoi (entry); - - entry =rte_cfgfile_get_entry (cfg, sec_name,"tc 12 rate" ); -if (entry) - subport_params[i].tc_rate[12 ] = (uint64_t )atoi (entry); -int n_entries =rte_cfgfile_section_num_entries (cfg, sec_name);struct rte_cfgfile_entry entries[n_entries];
examples/qos_sched/cfg_file.h +4 -0
@@ -14,4 +14,8 @@ int cfg_load_pipe(struct rte_cfgfile *cfg, struct rte_sched_pipe_params *pipe);int cfg_load_subport (struct rte_cfgfile *cfg,struct rte_sched_subport_params *subport); +int cfg_load_subport_profile (struct rte_cfgfile *cfg, +struct rte_sched_subport_profile_params + *subport_profile); +#endif
examples/qos_sched/init.c +15 -5
@@ -192,15 +192,20 @@ static struct rte_sched_pipe_params pipe_profiles[MAX_SCHED_PIPE_PROFILES] = { }, }; -struct rte_sched_subport_params subport_params[MAX_SCHED_SUBPORTS ] = { +static struct rte_sched_subport_profile_params + subport_profile[MAX_SCHED_SUBPORT_PROFILES ] = { { .tb_rate =1250000000 , .tb_size =1000000 , - .tc_rate = {1250000000 ,1250000000 ,1250000000 ,1250000000 ,1250000000 ,1250000000 ,1250000000 ,1250000000 ,1250000000 ,1250000000 ,1250000000 ,1250000000 ,1250000000 }, .tc_period =10 , + }, +}; + +struct rte_sched_subport_params subport_params[MAX_SCHED_SUBPORTS ] = { + { .n_pipes_per_subport_enabled =4096 , .qsize = {64 ,64 ,64 ,64 ,64 ,64 ,64 ,64 ,64 ,64 ,64 ,64 ,64 }, .pipe_profiles = pipe_profiles,
@@ -285,6 +290,9 @@ struct rte_sched_port_params port_params = { .mtu = 6 + 6 + 4 + 4 + 2 + 1500, .frame_overhead = RTE_SCHED_FRAME_OVERHEAD_DEFAULT, .n_subports_per_port = 1, + .n_subport_profiles = 1, + .subport_profiles = subport_profile, + .n_max_subport_profiles = MAX_SCHED_SUBPORT_PROFILES, .n_pipes_per_subport = MAX_SCHED_PIPES, };
@@ -315,10 +323,11 @@ app_init_sched_port(uint32_t portid, uint32_t socketid)for (subport =0 ; subport < port_params.n_subports_per_port; subport ++) { err =rte_sched_subport_config (port, subport, - &subport_params[subport],0 ); + &subport_params[subport], +0 );if (err) { -rte_exit (EXIT_FAILURE ,"Unable to config sched subport %u, err=%d\n" , - subport, err); +rte_exit (EXIT_FAILURE ,"Unable to config sched " +"subport %u, err=%d\n" , subport, err); } uint32_t n_pipes_per_subport =
@@ -351,6 +360,7 @@ app_load_cfg_profile(const char *profile)cfg_load_port (file, &port_params);cfg_load_subport (file, subport_params); +cfg_load_subport_profile (file, subport_profile);cfg_load_pipe (file, pipe_profiles);rte_cfgfile_close (file);
examples/qos_sched/main.h +1 -0
@@ -51,6 +51,7 @@ extern "C" {#define MAX_SCHED_SUBPORTS 8#define MAX_SCHED_PIPES 4096#define MAX_SCHED_PIPE_PROFILES 256 +#define MAX_SCHED_SUBPORT_PROFILES 8#ifndef APP_COLLECT_STAT #define APP_COLLECT_STAT 1
examples/qos_sched/profile.cfg +3 -0
@@ -26,6 +26,9 @@ number of subports per port = 1 number of pipes per subport = 4096 queue sizes = 64 64 64 64 64 64 64 64 64 64 64 64 64 +subport 0-8 = 0 ; These subports are configured with subport profile 0 + +[subport profile 0] tb rate = 1250000000 ; Bytes per second tb size = 1000000 ; Bytes
Signature · 1 line
2.17.1
PATCH v8 5/8 example/ip_pipeline: update subport rate dynamically
In reply to Savinay DharmappaModify the ip_pipeline application to build the hierarchical scheduler with default subport bandwidth profile. It also allows to update a subport with different subport rates dynamically
--- examples/ip_pipeline/cli.c | 68 ++++++++------------ examples/ip_pipeline/tmgr.c | 121 ++++++++++++++++++++++++++++++------ examples/ip_pipeline/tmgr.h | 5 +- 3 files changed, 134 insertions(+), 60 deletions(-)
examples/ip_pipeline/cli.c +27 -41
@@ -393,12 +393,7 @@ static const char cmd_tmgr_subport_profile_help[] =" <tc0_rate> <tc1_rate> <tc2_rate> <tc3_rate> <tc4_rate>" " <tc5_rate> <tc6_rate> <tc7_rate> <tc8_rate>" " <tc9_rate> <tc10_rate> <tc11_rate> <tc12_rate>\n" -" <tc_period>\n" -" pps <n_pipes_per_subport>\n" -" qsize <qsize_tc0> <qsize_tc1> <qsize_tc2>" -" <qsize_tc3> <qsize_tc4> <qsize_tc5> <qsize_tc6>" -" <qsize_tc7> <qsize_tc8> <qsize_tc9> <qsize_tc10>" -" <qsize_tc11> <qsize_tc12>" ; +" <tc_period>\n" ; static void cmd_tmgr_subport_profile(char **tokens,
@@ -406,57 +401,37 @@ cmd_tmgr_subport_profile(char **tokens, char *out, size_t out_size) { -struct rte_sched_subport_params p; +struct rte_sched_subport_profile_params subport_profile;int status, i; -if (n_tokens !=35 ) { +if (n_tokens !=19 ) {snprintf (out, out_size,MSG_ARG_MISMATCH , tokens[0 ]);return ; } -if (parser_read_uint64 (&p.tb_rate, tokens[3 ]) !=0 ) { +if (parser_read_uint64 (&subport_profile.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 (&subport_profile.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 (&subport_profile.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 (&subport_profile.tc_period, tokens[18 ]) !=0 ) {snprintf (out, out_size,MSG_ARG_INVALID ,"tc_period" );return ; } -if (strcmp (tokens[19 ],"pps" ) !=0 ) { -snprintf (out, out_size,MSG_ARG_NOT_FOUND ,"pps" ); -return ; - } - -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 ; - } - -if (strcmp (tokens[21 ],"qsize" ) !=0 ) { -snprintf (out, out_size,MSG_ARG_NOT_FOUND ,"qsize" ); -return ; - } - -for (i =0 ; i <RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE ; i++) -if (parser_read_uint16 (&p.qsize[i], tokens[22 + i]) !=0 ) { -snprintf (out, out_size,MSG_ARG_INVALID ,"qsize" ); -return ; - } - - status =tmgr_subport_profile_add (&p); + status =tmgr_subport_profile_add (&subport_profile);if (status !=0 ) {snprintf (out, out_size,MSG_CMD_FAIL , tokens[0 ]);return ;
@@ -530,6 +505,7 @@ static const char cmd_tmgr_help[] ="tmgr <tmgr_name>\n" " rate <rate>\n" " spp <n_subports_per_port>\n" +" pps <n_pipes_per_subport>\n" " fo <frame_overhead>\n" " mtu <mtu>\n" " cpu <cpu_id>\n" ;
@@ -544,7 +520,7 @@ cmd_tmgr(char **tokens,char *name;struct tmgr_port *tmgr_port; -if (n_tokens !=12 ) { +if (n_tokens !=14 ) {snprintf (out, out_size,MSG_ARG_MISMATCH , tokens[0 ]);return ; }
@@ -571,32 +547,42 @@ cmd_tmgr(char **tokens,return ; } -if (strcmp (tokens[6 ],"fo" ) !=0 ) { +if (strcmp (tokens[6 ],"pps" ) !=0 ) { +snprintf (out, out_size,MSG_ARG_NOT_FOUND ,"spp" ); +return ; + } + +if (parser_read_uint32 (&p.n_pipes_per_subport, tokens[7 ]) !=0 ) { +snprintf (out, out_size,MSG_ARG_INVALID ,"n_pipes_per_subport" ); +return ; + } + +if (strcmp (tokens[8 ],"fo" ) !=0 ) {snprintf (out, out_size,MSG_ARG_NOT_FOUND ,"fo" );return ; } -if (parser_read_uint32 (&p.frame_overhead, tokens[7 ]) !=0 ) { +if (parser_read_uint32 (&p.frame_overhead, tokens[9 ]) !=0 ) {snprintf (out, out_size,MSG_ARG_INVALID ,"frame_overhead" );return ; } -if (strcmp (tokens[8 ],"mtu" ) !=0 ) { +if (strcmp (tokens[10 ],"mtu" ) !=0 ) {snprintf (out, out_size,MSG_ARG_NOT_FOUND ,"mtu" );return ; } -if (parser_read_uint32 (&p.mtu, tokens[9 ]) !=0 ) { +if (parser_read_uint32 (&p.mtu, tokens[11 ]) !=0 ) {snprintf (out, out_size,MSG_ARG_INVALID ,"mtu" );return ; } -if (strcmp (tokens[10 ],"cpu" ) !=0 ) { +if (strcmp (tokens[12 ],"cpu" ) !=0 ) {snprintf (out, out_size,MSG_ARG_NOT_FOUND ,"cpu" );return ; } -if (parser_read_uint32 (&p.cpu_id, tokens[11 ]) !=0 ) { +if (parser_read_uint32 (&p.cpu_id, tokens[13 ]) !=0 ) {snprintf (out, out_size,MSG_ARG_INVALID ,"cpu_id" );return ; }
examples/ip_pipeline/tmgr.c +103 -18
202 lines not on this page · raw message
examples/ip_pipeline/tmgr.h +4 -1
@@ -9,6 +9,7 @@#include <sys/queue.h> #include <rte_sched.h> +#include <rte_red.h> #include "common.h"
@@ -29,6 +30,7 @@ struct tmgr_port {char name[NAME_SIZE ];struct rte_sched_port *s;uint32_t n_subports_per_port; +uint32_t n_pipes_per_subport; };TAILQ_HEAD (tmgr_port_list, tmgr_port);
@@ -42,13 +44,14 @@ tmgr_port_find(const char *name);struct tmgr_port_params {uint64_t rate;uint32_t n_subports_per_port; +uint32_t n_pipes_per_subport;uint32_t frame_overhead;uint32_t mtu;uint32_t cpu_id; };int -tmgr_subport_profile_add (struct rte_sched_subport_params *p); +tmgr_subport_profile_add (struct rte_sched_subport_profile_params *sp);int tmgr_pipe_profile_add (struct rte_sched_pipe_params *p);
Signature · 1 line
2.17.1
PATCH v8 6/8 drivers/softnic: update subport rate dynamically
In reply to Savinay DharmappaModify the softnic drivers to build the hierarchical scheduler with default subport bandwidth profile. It also allows to update a subport with different subport rates dynamically.
--- .../net/softnic/rte_eth_softnic_internals.h | 11 +- drivers/net/softnic/rte_eth_softnic_tm.c | 243 ++++++++++++++---- 2 files changed, 195 insertions(+), 59 deletions(-)
drivers/net/softnic/rte_eth_softnic_internals.h +9 -2
@@ -164,11 +164,18 @@ TAILQ_HEAD(softnic_link_list, softnic_link);#ifndef TM_MAX_PIPE_PROFILE #define TM_MAX_PIPE_PROFILE 256#endif + +#ifndef TM_MAX_SUBPORT_PROFILE +#define TM_MAX_SUBPORT_PROFILE 256 +#endif +struct tm_params {struct rte_sched_port_params port_params; -struct rte_sched_subport_params subport_params[TM_MAX_SUBPORTS ]; - +struct rte_sched_subport_profile_params + subport_profile[TM_MAX_SUBPORT_PROFILE ]; +uint32_t n_subport_profiles; +uint32_t subport_to_profile[TM_MAX_SUBPORT_PROFILE ];struct rte_sched_pipe_params pipe_profiles[TM_MAX_PIPE_PROFILE ];uint32_t n_pipe_profiles;uint32_t pipe_to_profile[TM_MAX_SUBPORTS *TM_MAX_PIPES_PER_SUBPORT ];
drivers/net/softnic/rte_eth_softnic_tm.c +186 -57
335 lines not on this page · raw message
Signature · 1 line
2.17.1