Skip to content

Commit 15074ac

Browse files
authored
[sonic-swss]:enable unconfiguring PFC on last TC on a port (sonic-net#1962)
* enable unconfiguring PFC on last TC on a port Signed-off-by: Alpesh S Patel <[email protected]>
1 parent 05c7c05 commit 15074ac

File tree

2 files changed

+34
-1
lines changed

2 files changed

+34
-1
lines changed

orchagent/qosorch.cpp

+7-1
Original file line numberDiff line numberDiff line change
@@ -1451,7 +1451,13 @@ task_process_status QosOrch::handlePortQosMapTable(Consumer& consumer)
14511451
SWSS_LOG_INFO("Applied %s to port %s", it->second.first.c_str(), port_name.c_str());
14521452
}
14531453

1454-
if (pfc_enable)
1454+
sai_uint8_t old_pfc_enable = 0;
1455+
if (!gPortsOrch->getPortPfc(port.m_port_id, &old_pfc_enable))
1456+
{
1457+
SWSS_LOG_ERROR("Failed to retrieve PFC bits on port %s", port_name.c_str());
1458+
}
1459+
1460+
if (pfc_enable || old_pfc_enable)
14551461
{
14561462
if (!gPortsOrch->setPortPfc(port.m_port_id, pfc_enable))
14571463
{

tests/test_pfc.py

+27
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,34 @@ def test_PfcAsymmetric(self, dvs, testlog):
101101
pfc = getPortAttr(dvs, port_oid, 'SAI_PORT_ATTR_PRIORITY_FLOW_CONTROL')
102102
assert pfc == pfc_tx
103103

104+
def test_PfcUnconfig(self, dvs, testlog):
104105

106+
port_name = 'Ethernet0'
107+
pfc_queues = [ 3, 4 ]
108+
109+
# Configure default PFC
110+
setPortPfc(dvs, port_name, pfc_queues)
111+
112+
# Get SAI object ID for the interface
113+
port_oid = getPortOid(dvs, port_name)
114+
115+
# Verify default PFC is set to configured value
116+
pfc = getPortAttr(dvs, port_oid, 'SAI_PORT_ATTR_PRIORITY_FLOW_CONTROL')
117+
assert pfc == getBitMaskStr(pfc_queues)
118+
119+
# Configure PFC on single TC
120+
pfc_queues = [ 3 ]
121+
setPortPfc(dvs, port_name, pfc_queues)
122+
# Verify default PFC is set to configured value
123+
pfc = getPortAttr(dvs, port_oid, 'SAI_PORT_ATTR_PRIORITY_FLOW_CONTROL')
124+
assert pfc == getBitMaskStr(pfc_queues)
125+
126+
# Disable PFC on last TC
127+
pfc_queues = [ ]
128+
setPortPfc(dvs, port_name, pfc_queues)
129+
# Verify default PFC is set to configured value
130+
pfc = getPortAttr(dvs, port_oid, 'SAI_PORT_ATTR_PRIORITY_FLOW_CONTROL')
131+
assert pfc == getBitMaskStr(pfc_queues)
105132

106133
# Add Dummy always-pass test at end as workaroud
107134
# for issue when Flaky fail on final test it invokes module tear-down before retrying

0 commit comments

Comments
 (0)