sched: add PIE based congestion management
[dpdk.git] / drivers / net / softnic / rte_eth_softnic_tm.c
index 725b023..e74092c 100644 (file)
@@ -420,7 +420,7 @@ pmd_tm_node_type_get(struct rte_eth_dev *dev,
        return 0;
 }
 
-#ifdef RTE_SCHED_RED
+#ifdef RTE_SCHED_CMAN
 #define WRED_SUPPORTED                                         1
 #else
 #define WRED_SUPPORTED                                         0
@@ -1147,10 +1147,15 @@ update_subport_tc_rate(struct rte_eth_dev *dev,
        struct tm_node *ns = np->parent_node;
        uint32_t subport_id = tm_node_subport_id(dev, ns);
        struct tm_params *t = &p->soft.tm.params;
-       uint32_t subport_profile_id = t->subport_to_profile[subport_id];
+       uint32_t subport_profile_id;
        struct tm_shaper_profile *sp_old = tm_shaper_profile_search(dev,
                ss->shaper_profile_id);
 
+       if (subport_id >= TM_MAX_SUBPORT_PROFILE)
+               return -1;
+
+       subport_profile_id = t->subport_to_profile[subport_id];
+
        /* Derive new subport configuration. */
        memcpy(&subport_profile,
                &p->soft.tm.params.subport_profile[subport_profile_id],
@@ -2301,7 +2306,7 @@ tm_tc_wred_profile_get(struct rte_eth_dev *dev, uint32_t tc_id)
        return NULL;
 }
 
-#ifdef RTE_SCHED_RED
+#ifdef RTE_SCHED_CMAN
 
 static void
 wred_profiles_set(struct rte_eth_dev *dev, uint32_t subport_id)
@@ -2316,7 +2321,7 @@ wred_profiles_set(struct rte_eth_dev *dev, uint32_t subport_id)
        for (tc_id = 0; tc_id < RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE; tc_id++)
                for (color = RTE_COLOR_GREEN; color < RTE_COLORS; color++) {
                        struct rte_red_params *dst =
-                               &pp->red_params[tc_id][color];
+                               &pp->cman_params->red_params[tc_id][color];
                        struct tm_wred_profile *src_wp =
                                tm_tc_wred_profile_get(dev, tc_id);
                        struct rte_tm_red_params *src =
@@ -2370,6 +2375,9 @@ subport_profile_get(struct rte_eth_dev *dev, struct tm_node *np)
        struct tm_params *t = &p->soft.tm.params;
        uint32_t subport_id = tm_node_subport_id(dev, np->parent_node);
 
+       if (subport_id >= TM_MAX_SUBPORT_PROFILE)
+               return NULL;
+
        return &t->subport_profile[subport_id];
 }
 
@@ -3024,6 +3032,9 @@ update_subport_rate(struct rte_eth_dev *dev,
        struct rte_sched_subport_profile_params profile1;
        uint32_t subport_profile_id;
 
+       if (profile0 == NULL)
+               return -1;
+
        /* Derive new pipe profile. */
        memcpy(&profile1, profile0, sizeof(profile1));
        profile1.tb_rate = sp->params.peak.rate;