Skip to content

Commit 367017a

Browse files
wendanilguohan
authored andcommitted
Expose the capability to config wred drop probability (sonic-net#571)
* Add the capability to set wred drop probability of all packet colors (green, yellow, and red) Signed-off-by: Wenda <[email protected]> * Ensure drop probability takes default value 100% if not explicitly specified in qos.json Signed-off-by: Wenda <[email protected]>
1 parent 76f258b commit 367017a

2 files changed

Lines changed: 95 additions & 43 deletions

File tree

orchagent/qosorch.cpp

Lines changed: 57 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@ map<string, sai_ecn_mark_mode_t> ecn_map = {
3434
{"ecn_all", SAI_ECN_MARK_MODE_ALL}
3535
};
3636

37+
enum {
38+
GREEN_DROP_PROBABILITY_SET = (1U << 0),
39+
YELLOW_DROP_PROBABILITY_SET = (1U << 1),
40+
RED_DROP_PROBABILITY_SET = (1U << 2)
41+
};
42+
3743
map<string, sai_port_attr_t> qos_to_attr_map = {
3844
{dscp_to_tc_field_name, SAI_PORT_ATTR_QOS_DSCP_TO_TC_MAP},
3945
{tc_to_queue_field_name, SAI_PORT_ATTR_QOS_TC_TO_QUEUE_MAP},
@@ -329,6 +335,24 @@ bool WredMapHandler::convertFieldValuesToAttributes(KeyOpFieldsValuesTuple &tupl
329335
attr.value.s32 = stoi(fvValue(*i));
330336
attribs.push_back(attr);
331337
}
338+
else if (fvField(*i) == green_drop_probability_field_name)
339+
{
340+
attr.id = SAI_WRED_ATTR_GREEN_DROP_PROBABILITY;
341+
attr.value.s32 = stoi(fvValue(*i));
342+
attribs.push_back(attr);
343+
}
344+
else if (fvField(*i) == yellow_drop_probability_field_name)
345+
{
346+
attr.id = SAI_WRED_ATTR_YELLOW_DROP_PROBABILITY;
347+
attr.value.s32 = stoi(fvValue(*i));
348+
attribs.push_back(attr);
349+
}
350+
else if (fvField(*i) == red_drop_probability_field_name)
351+
{
352+
attr.id = SAI_WRED_ATTR_RED_DROP_PROBABILITY;
353+
attr.value.s32 = stoi(fvValue(*i));
354+
attribs.push_back(attr);
355+
}
332356
else if (fvField(*i) == wred_green_enable_field_name)
333357
{
334358
attr.id = SAI_WRED_ATTR_GREEN_ENABLE;
@@ -394,14 +418,7 @@ sai_object_id_t WredMapHandler::addQosItem(const vector<sai_attribute_t> &attrib
394418
sai_object_id_t sai_object;
395419
sai_attribute_t attr;
396420
vector<sai_attribute_t> attrs;
397-
398-
attr.id = SAI_WRED_ATTR_GREEN_DROP_PROBABILITY;
399-
attr.value.s32 = 100;
400-
attrs.push_back(attr);
401-
402-
attr.id = SAI_WRED_ATTR_YELLOW_DROP_PROBABILITY;
403-
attr.value.s32 = 100;
404-
attrs.push_back(attr);
421+
uint8_t drop_prob_set = 0;
405422

406423
attr.id = SAI_WRED_ATTR_WEIGHT;
407424
attr.value.s32 = 0;
@@ -410,7 +427,39 @@ sai_object_id_t WredMapHandler::addQosItem(const vector<sai_attribute_t> &attrib
410427
for(auto attrib : attribs)
411428
{
412429
attrs.push_back(attrib);
430+
431+
if (attrib.id == SAI_WRED_ATTR_GREEN_DROP_PROBABILITY)
432+
{
433+
drop_prob_set |= GREEN_DROP_PROBABILITY_SET;
434+
}
435+
else if (attrib.id == SAI_WRED_ATTR_YELLOW_DROP_PROBABILITY)
436+
{
437+
drop_prob_set |= YELLOW_DROP_PROBABILITY_SET;
438+
}
439+
else if (attrib.id == SAI_WRED_ATTR_RED_DROP_PROBABILITY)
440+
{
441+
drop_prob_set |= RED_DROP_PROBABILITY_SET;
442+
}
443+
}
444+
if (!(drop_prob_set & GREEN_DROP_PROBABILITY_SET))
445+
{
446+
attr.id = SAI_WRED_ATTR_GREEN_DROP_PROBABILITY;
447+
attr.value.s32 = 100;
448+
attrs.push_back(attr);
449+
}
450+
if (!(drop_prob_set & YELLOW_DROP_PROBABILITY_SET))
451+
{
452+
attr.id = SAI_WRED_ATTR_YELLOW_DROP_PROBABILITY;
453+
attr.value.s32 = 100;
454+
attrs.push_back(attr);
455+
}
456+
if (!(drop_prob_set & RED_DROP_PROBABILITY_SET))
457+
{
458+
attr.id = SAI_WRED_ATTR_RED_DROP_PROBABILITY;
459+
attr.value.s32 = 100;
460+
attrs.push_back(attr);
413461
}
462+
414463
sai_status = sai_wred_api->create_wred(&sai_object, gSwitchId, (uint32_t)attrs.size(), attrs.data());
415464
if (sai_status != SAI_STATUS_SUCCESS)
416465
{

orchagent/qosorch.h

Lines changed: 38 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -7,41 +7,44 @@
77
#include "orch.h"
88
#include "portsorch.h"
99

10-
const string dscp_to_tc_field_name = "dscp_to_tc_map";
11-
const string pfc_to_pg_map_name = "pfc_to_pg_map";
12-
const string pfc_to_queue_map_name = "pfc_to_queue_map";
13-
const string pfc_enable_name = "pfc_enable";
14-
const string tc_to_pg_map_field_name = "tc_to_pg_map";
15-
const string tc_to_queue_field_name = "tc_to_queue_map";
16-
const string scheduler_field_name = "scheduler";
17-
const string red_max_threshold_field_name = "red_max_threshold";
18-
const string red_min_threshold_field_name = "red_min_threshold";
19-
const string yellow_max_threshold_field_name = "yellow_max_threshold";
20-
const string yellow_min_threshold_field_name = "yellow_min_threshold";
21-
const string green_max_threshold_field_name = "green_max_threshold";
22-
const string green_min_threshold_field_name = "green_min_threshold";
23-
24-
const string wred_profile_field_name = "wred_profile";
25-
const string wred_red_enable_field_name = "wred_red_enable";
26-
const string wred_yellow_enable_field_name = "wred_yellow_enable";
27-
const string wred_green_enable_field_name = "wred_green_enable";
28-
29-
const string scheduler_algo_type_field_name = "type";
30-
const string scheduler_algo_DWRR = "DWRR";
31-
const string scheduler_algo_WRR = "WRR";
32-
const string scheduler_algo_STRICT = "STRICT";
33-
const string scheduler_weight_field_name = "weight";
34-
const string scheduler_priority_field_name = "priority";
35-
36-
const string ecn_field_name = "ecn";
37-
const string ecn_none = "ecn_none";
38-
const string ecn_red = "ecn_red";
39-
const string ecn_yellow = "ecn_yellow";
40-
const string ecn_yellow_red = "ecn_yellow_red";
41-
const string ecn_green = "ecn_green";
42-
const string ecn_green_red = "ecn_green_red";
43-
const string ecn_green_yellow = "ecn_green_yellow";
44-
const string ecn_all = "ecn_all";
10+
const string dscp_to_tc_field_name = "dscp_to_tc_map";
11+
const string pfc_to_pg_map_name = "pfc_to_pg_map";
12+
const string pfc_to_queue_map_name = "pfc_to_queue_map";
13+
const string pfc_enable_name = "pfc_enable";
14+
const string tc_to_pg_map_field_name = "tc_to_pg_map";
15+
const string tc_to_queue_field_name = "tc_to_queue_map";
16+
const string scheduler_field_name = "scheduler";
17+
const string red_max_threshold_field_name = "red_max_threshold";
18+
const string red_min_threshold_field_name = "red_min_threshold";
19+
const string yellow_max_threshold_field_name = "yellow_max_threshold";
20+
const string yellow_min_threshold_field_name = "yellow_min_threshold";
21+
const string green_max_threshold_field_name = "green_max_threshold";
22+
const string green_min_threshold_field_name = "green_min_threshold";
23+
const string red_drop_probability_field_name = "red_drop_probability";
24+
const string yellow_drop_probability_field_name = "yellow_drop_probability";
25+
const string green_drop_probability_field_name = "green_drop_probability";
26+
27+
const string wred_profile_field_name = "wred_profile";
28+
const string wred_red_enable_field_name = "wred_red_enable";
29+
const string wred_yellow_enable_field_name = "wred_yellow_enable";
30+
const string wred_green_enable_field_name = "wred_green_enable";
31+
32+
const string scheduler_algo_type_field_name = "type";
33+
const string scheduler_algo_DWRR = "DWRR";
34+
const string scheduler_algo_WRR = "WRR";
35+
const string scheduler_algo_STRICT = "STRICT";
36+
const string scheduler_weight_field_name = "weight";
37+
const string scheduler_priority_field_name = "priority";
38+
39+
const string ecn_field_name = "ecn";
40+
const string ecn_none = "ecn_none";
41+
const string ecn_red = "ecn_red";
42+
const string ecn_yellow = "ecn_yellow";
43+
const string ecn_yellow_red = "ecn_yellow_red";
44+
const string ecn_green = "ecn_green";
45+
const string ecn_green_red = "ecn_green_red";
46+
const string ecn_green_yellow = "ecn_green_yellow";
47+
const string ecn_all = "ecn_all";
4548

4649
class QosMapHandler
4750
{

0 commit comments

Comments
 (0)