@@ -37,6 +37,13 @@ namespace qosorch_test
37
37
sai_set_switch_attribute_fn old_set_switch_attribute_fn;
38
38
sai_switch_api_t ut_sai_switch_api, *pold_sai_switch_api;
39
39
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
+
40
47
sai_status_t _ut_stub_sai_set_switch_attribute (sai_object_id_t switch_id, const sai_attribute_t *attr)
41
48
{
42
49
auto rc = old_set_switch_attribute_fn (switch_id, attr);
@@ -55,6 +62,7 @@ namespace qosorch_test
55
62
56
63
bool testing_wred_thresholds;
57
64
WredMapHandler::qos_wred_thresholds_t saiThresholds;
65
+ qos_wred_max_drop_probability_t saiMaxDropProbabilities;
58
66
void _ut_stub_sai_check_wred_attributes (const sai_attribute_t &attr)
59
67
{
60
68
if (!testing_wred_thresholds)
@@ -88,6 +96,15 @@ namespace qosorch_test
88
96
ASSERT_TRUE (!saiThresholds.red_max_threshold || saiThresholds.red_max_threshold > attr.value .u32 );
89
97
saiThresholds.red_min_threshold = attr.value .u32 ;
90
98
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 ;
91
108
default :
92
109
break ;
93
110
}
@@ -132,6 +149,23 @@ namespace qosorch_test
132
149
ASSERT_TRUE (ts.empty ());
133
150
}
134
151
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
+
135
169
sai_status_t _ut_stub_sai_create_wred (
136
170
_Out_ sai_object_id_t *wred_id,
137
171
_In_ sai_object_id_t switch_id,
@@ -1338,6 +1372,62 @@ namespace qosorch_test
1338
1372
testing_wred_thresholds = false ;
1339
1373
}
1340
1374
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
+
1341
1431
/*
1342
1432
* Make sure empty fields won't cause orchagent crash
1343
1433
*/
0 commit comments