@@ -37,6 +37,13 @@ namespace qosorch_test
3737 sai_set_switch_attribute_fn old_set_switch_attribute_fn;
3838 sai_switch_api_t ut_sai_switch_api, *pold_sai_switch_api;
3939
40+ typedef struct
41+ {
42+ sai_uint32_t green_max_drop_probability;
43+ sai_uint32_t yellow_max_drop_probability;
44+ sai_uint32_t red_max_drop_probability;
45+ } qos_wred_max_drop_probability_t ;
46+
4047 sai_status_t _ut_stub_sai_set_switch_attribute (sai_object_id_t switch_id, const sai_attribute_t *attr)
4148 {
4249 auto rc = old_set_switch_attribute_fn (switch_id, attr);
@@ -55,6 +62,7 @@ namespace qosorch_test
5562
5663 bool testing_wred_thresholds;
5764 WredMapHandler::qos_wred_thresholds_t saiThresholds;
65+ qos_wred_max_drop_probability_t saiMaxDropProbabilities;
5866 void _ut_stub_sai_check_wred_attributes (const sai_attribute_t &attr)
5967 {
6068 if (!testing_wred_thresholds)
@@ -88,6 +96,15 @@ namespace qosorch_test
8896 ASSERT_TRUE (!saiThresholds.red_max_threshold || saiThresholds.red_max_threshold > attr.value .u32 );
8997 saiThresholds.red_min_threshold = attr.value .u32 ;
9098 break ;
99+ case SAI_WRED_ATTR_GREEN_DROP_PROBABILITY:
100+ saiMaxDropProbabilities.green_max_drop_probability = attr.value .u32 ;
101+ break ;
102+ case SAI_WRED_ATTR_YELLOW_DROP_PROBABILITY:
103+ saiMaxDropProbabilities.yellow_max_drop_probability = attr.value .u32 ;
104+ break ;
105+ case SAI_WRED_ATTR_RED_DROP_PROBABILITY:
106+ saiMaxDropProbabilities.red_max_drop_probability = attr.value .u32 ;
107+ break ;
91108 default :
92109 break ;
93110 }
@@ -132,6 +149,23 @@ namespace qosorch_test
132149 ASSERT_TRUE (ts.empty ());
133150 }
134151
152+ void updateMaxDropProbabilityAndCheck (string name, vector<FieldValueTuple> &maxDropProbabilityVector, qos_wred_max_drop_probability_t &maxDropProbabilities)
153+ {
154+ std::deque<KeyOpFieldsValuesTuple> entries;
155+ vector<string> ts;
156+ entries.push_back ({name, " SET" , maxDropProbabilityVector});
157+ auto consumer = dynamic_cast <Consumer *>(gQosOrch ->getExecutor (CFG_WRED_PROFILE_TABLE_NAME));
158+ consumer->addToSync (entries);
159+ entries.clear ();
160+ saiMaxDropProbabilities.green_max_drop_probability = 0 ;
161+ saiMaxDropProbabilities.yellow_max_drop_probability = 0 ;
162+ saiMaxDropProbabilities.red_max_drop_probability = 0 ;
163+ static_cast <Orch *>(gQosOrch )->doTask ();
164+ ASSERT_EQ (saiMaxDropProbabilities.green_max_drop_probability , maxDropProbabilities.green_max_drop_probability );
165+ ASSERT_EQ (saiMaxDropProbabilities.yellow_max_drop_probability , maxDropProbabilities.yellow_max_drop_probability );
166+ ASSERT_EQ (saiMaxDropProbabilities.red_max_drop_probability , maxDropProbabilities.red_max_drop_probability );
167+ }
168+
135169 sai_status_t _ut_stub_sai_create_wred (
136170 _Out_ sai_object_id_t *wred_id,
137171 _In_ sai_object_id_t switch_id,
@@ -1338,6 +1372,62 @@ namespace qosorch_test
13381372 testing_wred_thresholds = false ;
13391373 }
13401374
1375+ TEST_F (QosOrchTest, QosOrchTestWredDropProbability)
1376+ {
1377+ testing_wred_thresholds = true ;
1378+
1379+ // The order of fields matters when the wred profile is updated from the upper set to the lower set
1380+ // It should be max, min for each color. In this order, the new max is less then the current min
1381+ // QoS orchagent should guarantee that the new min is configured first and then new max
1382+ vector<FieldValueTuple> greenProfile = {
1383+ {" wred_green_enable" , " true" },
1384+ {" wred_yellow_enable" , " false" },
1385+ };
1386+ qos_wred_max_drop_probability_t greenProbabilities = {
1387+ 100 , // green_max_drop_probability
1388+ 0 , // yellow_max_drop_probability
1389+ 0 // red_max_drop_probability
1390+ };
1391+ updateMaxDropProbabilityAndCheck (" green_default" , greenProfile, greenProbabilities);
1392+
1393+ greenProfile.push_back ({" green_drop_probability" , " 5" });
1394+ greenProbabilities.green_max_drop_probability = 5 ;
1395+ updateMaxDropProbabilityAndCheck (" green" , greenProfile, greenProbabilities);
1396+
1397+ vector<FieldValueTuple> yellowProfile = {
1398+ {" wred_yellow_enable" , " true" },
1399+ {" wred_red_enable" , " false" },
1400+ };
1401+ qos_wred_max_drop_probability_t yellowProbabilities = {
1402+ 0 , // green_max_drop_probability
1403+ 100 , // yellow_max_drop_probability
1404+ 0 // red_max_drop_probability
1405+ };
1406+ updateMaxDropProbabilityAndCheck (" yellow_default" , yellowProfile, yellowProbabilities);
1407+
1408+ yellowProfile.push_back ({" yellow_drop_probability" , " 5" });
1409+ yellowProbabilities.yellow_max_drop_probability = 5 ;
1410+ updateMaxDropProbabilityAndCheck (" yellow" , yellowProfile, yellowProbabilities);
1411+
1412+ vector<FieldValueTuple> redProfile = {
1413+ {" wred_green_enable" , " false" },
1414+ {" wred_red_enable" , " true" },
1415+ };
1416+ qos_wred_max_drop_probability_t redProbabilities = {
1417+ 0 , // green_max_drop_probability
1418+ 0 , // yellow_max_drop_probability
1419+ 100 // red_max_drop_probability
1420+ };
1421+ updateMaxDropProbabilityAndCheck (" red_default" , redProfile, redProbabilities);
1422+
1423+ redProfile.push_back ({" red_drop_probability" , " 5" });
1424+ redProbabilities.red_max_drop_probability = 5 ;
1425+ updateMaxDropProbabilityAndCheck (" red" , redProfile, redProbabilities);
1426+
1427+ testing_wred_thresholds = false ;
1428+ }
1429+
1430+
13411431 /*
13421432 * Make sure empty fields won't cause orchagent crash
13431433 */
0 commit comments