+#ifdef RTE_SCHED_CMAN
+static int
+rte_sched_red_config(struct rte_sched_port *port,
+ struct rte_sched_subport *s,
+ struct rte_sched_subport_params *params,
+ uint32_t n_subports)
+{
+ uint32_t i;
+
+ 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->cman_params->red_params[i][j].min_th |
+ params->cman_params->red_params[i][j].max_th) == 0) {
+ continue;
+ }
+
+ if (rte_red_config_init(&s->red_config[i][j],
+ params->cman_params->red_params[i][j].wq_log2,
+ params->cman_params->red_params[i][j].min_th,
+ params->cman_params->red_params[i][j].max_th,
+ params->cman_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;
+ }
+ }
+ }
+ s->cman = RTE_SCHED_CMAN_RED;
+ return 0;
+}
+
+static int
+rte_sched_pie_config(struct rte_sched_port *port,
+ struct rte_sched_subport *s,
+ struct rte_sched_subport_params *params,
+ uint32_t n_subports)
+{
+ uint32_t i;
+
+ for (i = 0; i < RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE; i++) {
+ if (params->cman_params->pie_params[i].tailq_th > params->qsize[i]) {
+ RTE_LOG(NOTICE, SCHED,
+ "%s: PIE tailq threshold incorrect\n", __func__);
+ return -EINVAL;
+ }
+
+ if (rte_pie_config_init(&s->pie_config[i],
+ params->cman_params->pie_params[i].qdelay_ref,
+ params->cman_params->pie_params[i].dp_update_interval,
+ params->cman_params->pie_params[i].max_burst,
+ params->cman_params->pie_params[i].tailq_th) != 0) {
+ rte_sched_free_memory(port, n_subports);
+
+ RTE_LOG(NOTICE, SCHED,
+ "%s: PIE configuration init fails\n", __func__);
+ return -EINVAL;
+ }
+ }
+ s->cman = RTE_SCHED_CMAN_PIE;
+ return 0;
+}
+
+static int
+rte_sched_cman_config(struct rte_sched_port *port,
+ struct rte_sched_subport *s,
+ struct rte_sched_subport_params *params,
+ uint32_t n_subports)
+{
+ if (params->cman_params->cman_mode == RTE_SCHED_CMAN_RED)
+ return rte_sched_red_config(port, s, params, n_subports);
+
+ else if (params->cman_params->cman_mode == RTE_SCHED_CMAN_PIE)
+ return rte_sched_pie_config(port, s, params, n_subports);
+
+ return -EINVAL;
+}
+#endif
+