rte_sched: make RED optional at runtime
PATCH 1/4 rte_sched: make RED optional at runtime
We want to be able to build with RTE_SCHED_RED enabled but allow disabling RED on a per-queue basis at runtime. This is handled by allowing RED min/max to be zero to indicate that RED is not being used.
Signed-off-by Stephen Hemminger <[email protected]>
lib/librte_sched/rte_sched.c +9 -0
@@ -636,6 +636,12 @@ rte_sched_port_config(struct rte_sched_puint32_t j;for (j =0 ; j < e_RTE_METER_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(&port->red_config[i][j], params->red_params[i][j].wq_log2, params->red_params[i][j].min_th,
@@ -1069,6 +1075,9 @@ rte_sched_port_red_drop(struct rte_sched color =rte_sched_port_pkt_read_color (pkt); red_cfg = &port->red_config[tc_index][color]; +if ( (red_cfg->min_th | red_cfg->max_th) ==0 ) +return 0 ; + qe = port->queue_extra + qindex; red = &qe->red;
PATCH 3/4 rte_sched: don't clear statistics when read
Make rte_sched statistics API work like the ethernet statistics API. Don't auto-clear statistics when read.
Signed-off-by Stephen Hemminger <[email protected]>
lib/librte_sched/rte_sched.c +34 -6
@@ -924,9 +924,8 @@ rte_sched_subport_read_stats(struct rte_ } s = port->subport + subport_id; -/* Copy subport stats and clear */ -memcpy (stats, &s->stats,sizeof (struct rte_sched_subport_stats )); -memset (&s->stats,0 ,sizeof (struct rte_sched_subport_stats )); +/* Copy subport stats */ + *stats = s->stats;/* Subport TC ovesubscription status */ *tc_ov = s->tc_ov;
@@ -935,6 +934,21 @@ rte_sched_subport_read_stats(struct rte_ }int +rte_sched_subport_stats_reset (struct rte_sched_port *port, +uint32_t subport_id) +{ +struct rte_sched_subport *s; + +/* Check user parameters */ +if (port ==NULL || subport_id >= port->n_subports_per_port) +return -1 ; + + s = port->subport + subport_id; +memset (&s->stats,0 ,sizeof (struct rte_sched_subport_stats )); +return 0 ; +} + +int rte_sched_queue_read_stats(struct rte_sched_port *port, uint32_t queue_id, struct rte_sched_queue_stats *stats,
@@ -953,9 +967,8 @@ rte_sched_queue_read_stats(struct rte_sc q = port->queue + queue_id; qe = port->queue_extra + queue_id; -/* Copy queue stats and clear */ -memcpy (stats, &qe->stats,sizeof (struct rte_sched_queue_stats )); -memset (&qe->stats,0 ,sizeof (struct rte_sched_queue_stats )); +/* Copy queue stats */ + *stats = qe->stats;/* Queue length */ *qlen = q->qw - q->qr;
@@ -963,6 +976,21 @@ rte_sched_queue_read_stats(struct rte_screturn 0 ; } +int +rte_sched_queue_stats_reset (struct rte_sched_port *port, +uint32_t queue_id) +{ +struct rte_sched_queue_extra *qe; + +/* Check user parameters */ +if (port ==NULL || queue_id >=rte_sched_port_queues_per_port (port)) +return -1 ; + + qe = port->queue_extra + queue_id; +memset (&qe->stats,0 ,sizeof (struct rte_sched_queue_stats )); +return 0 ; +} +static inline uint32_t rte_sched_port_qindex (struct rte_sched_port *port,uint32_t subport,uint32_t pipe,uint32_t traffic_class,uint32_t queue) {
lib/librte_sched/rte_sched.h +29 -0
@@ -312,6 +312,21 @@ rte_sched_subport_read_stats(struct rte_struct rte_sched_subport_stats *stats, uint32_t *tc_ov); + +/** +* Hierarchical scheduler subport statistics reset +* +* @param port +* Handle to port scheduler instance +* @param subport_id +* Subport ID +* @return +* 0 upon success, error code otherwise +*/ +int +rte_sched_subport_stats_reset (struct rte_sched_port *port, +uint32_t subport_id); +/** * Hierarchical scheduler queue statistics read *
@@ -333,6 +348,20 @@ rte_sched_queue_read_stats(struct rte_scstruct rte_sched_queue_stats *stats, uint16_t *qlen); +/** +* Hierarchical scheduler queue statistics reset +* +* @param port +* Handle to port scheduler instance +* @param queue_id +* Queue ID within port scheduler +* @return +* 0 upon success, error code otherwise +*/ +int +rte_sched_queue_stats_reset (struct rte_sched_port *port, +uint32_t queue_id); +/* * Run-time *
PATCH 4/4 rte_sched: don't put tabs in log messages
In reply to Stephen Hemmingersyslog does not like tabs in log messages; tab gets translated to #011
Signed-off-by Stephen Hemminger <[email protected]>
lib/librte_sched/rte_sched.c +7 -7
@@ -495,10 +495,10 @@ rte_sched_port_log_pipe_profile(struct rstruct rte_sched_pipe_profile *p = port->pipe_profiles + i; RTE_LOG(INFO, SCHED, "Low level config for pipe profile %u:\n" - "\tToken bucket: period = %u, credits per period = %u, size = %u\n" - "\tTraffic classes: period = %u, credits per period = [%u, %u, %u, %u]\n" - "\tTraffic class 3 oversubscription: weight = %hhu\n" - "\tWRR cost: [%hhu, %hhu, %hhu, %hhu], [%hhu, %hhu, %hhu, %hhu], [%hhu, %hhu, %hhu, %hhu], [%hhu, %hhu, %hhu, %hhu]\n", + " Token bucket: period = %u, credits per period = %u, size = %u\n" + " Traffic classes: period = %u, credits per period = [%u, %u, %u, %u]\n" + " Traffic class 3 oversubscription: weight = %hhu\n" + " WRR cost: [%hhu, %hhu, %hhu, %hhu], [%hhu, %hhu, %hhu, %hhu], [%hhu, %hhu, %hhu, %hhu], [%hhu, %hhu, %hhu, %hhu]\n", i,/* Token bucket */
@@ -716,9 +716,9 @@ rte_sched_port_log_subport_config(structstruct rte_sched_subport *s = port->subport + i; RTE_LOG(INFO, SCHED, "Low level config for subport %u:\n" - "\tToken bucket: period = %u, credits per period = %u, size = %u\n" - "\tTraffic classes: period = %u, credits per period = [%u, %u, %u, %u]\n" - "\tTraffic class 3 oversubscription: wm min = %u, wm max = %u\n", + " Token bucket: period = %u, credits per period = %u, size = %u\n" + " Traffic classes: period = %u, credits per period = [%u, %u, %u, %u]\n" + " Traffic class 3 oversubscription: wm min = %u, wm max = %u\n", i,/* Token bucket */