Skip to content

Commit 0e505a8

Browse files
committed
Enforce drop probability only for colors whose WRED are enabled
Signed-off-by: Stephen Sun <[email protected]>
1 parent dec4570 commit 0e505a8

File tree

1 file changed

+30
-11
lines changed

1 file changed

+30
-11
lines changed

orchagent/qosorch.cpp

+30-11
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,12 @@ enum {
4646
RED_DROP_PROBABILITY_SET = (1U << 2)
4747
};
4848

49+
enum {
50+
GREEN_WRED_ENABLED = (1U << 0),
51+
YELLOW_WRED_ENABLED = (1U << 1),
52+
RED_WRED_ENABLED = (1U << 2)
53+
};
54+
4955
// field_name is what is expected in CONFIG_DB PORT_QOS_MAP table
5056
map<string, sai_port_attr_t> qos_to_attr_map = {
5157
{dscp_to_tc_field_name, SAI_PORT_ATTR_QOS_DSCP_TO_TC_MAP},
@@ -720,6 +726,7 @@ sai_object_id_t WredMapHandler::addQosItem(const vector<sai_attribute_t> &attrib
720726
sai_attribute_t attr;
721727
vector<sai_attribute_t> attrs;
722728
uint8_t drop_prob_set = 0;
729+
uint8_t wred_enable_set = 0;
723730

724731
attr.id = SAI_WRED_ATTR_WEIGHT;
725732
attr.value.s32 = 0;
@@ -729,32 +736,44 @@ sai_object_id_t WredMapHandler::addQosItem(const vector<sai_attribute_t> &attrib
729736
{
730737
attrs.push_back(attrib);
731738

732-
if (attrib.id == SAI_WRED_ATTR_GREEN_DROP_PROBABILITY)
733-
{
739+
switch (attrib.id)
740+
{
741+
case SAI_WRED_ATTR_GREEN_ENABLE:
742+
wred_enable_set |= GREEN_WRED_ENABLED;
743+
break;
744+
case SAI_WRED_ATTR_YELLOW_ENABLE:
745+
wred_enable_set |= YELLOW_WRED_ENABLED;
746+
break;
747+
case SAI_WRED_ATTR_RED_ENABLE:
748+
wred_enable_set |= RED_WRED_ENABLED;
749+
break;
750+
case SAI_WRED_ATTR_GREEN_DROP_PROBABILITY:
734751
drop_prob_set |= GREEN_DROP_PROBABILITY_SET;
735-
}
736-
else if (attrib.id == SAI_WRED_ATTR_YELLOW_DROP_PROBABILITY)
737-
{
752+
break;
753+
case SAI_WRED_ATTR_YELLOW_DROP_PROBABILITY:
738754
drop_prob_set |= YELLOW_DROP_PROBABILITY_SET;
739-
}
740-
else if (attrib.id == SAI_WRED_ATTR_RED_DROP_PROBABILITY)
741-
{
755+
break;
756+
case SAI_WRED_ATTR_RED_DROP_PROBABILITY:
742757
drop_prob_set |= RED_DROP_PROBABILITY_SET;
758+
break;
759+
default:
760+
break;
743761
}
744762
}
745-
if (!(drop_prob_set & GREEN_DROP_PROBABILITY_SET))
763+
764+
if (!(drop_prob_set & GREEN_DROP_PROBABILITY_SET) && (wred_enable_set & GREEN_WRED_ENABLED))
746765
{
747766
attr.id = SAI_WRED_ATTR_GREEN_DROP_PROBABILITY;
748767
attr.value.s32 = 100;
749768
attrs.push_back(attr);
750769
}
751-
if (!(drop_prob_set & YELLOW_DROP_PROBABILITY_SET))
770+
if (!(drop_prob_set & YELLOW_DROP_PROBABILITY_SET) && (wred_enable_set & YELLOW_WRED_ENABLED))
752771
{
753772
attr.id = SAI_WRED_ATTR_YELLOW_DROP_PROBABILITY;
754773
attr.value.s32 = 100;
755774
attrs.push_back(attr);
756775
}
757-
if (!(drop_prob_set & RED_DROP_PROBABILITY_SET))
776+
if (!(drop_prob_set & RED_DROP_PROBABILITY_SET) && (wred_enable_set & RED_WRED_ENABLED))
758777
{
759778
attr.id = SAI_WRED_ATTR_RED_DROP_PROBABILITY;
760779
attr.value.s32 = 100;

0 commit comments

Comments
 (0)