Skip to content

Commit

Permalink
[sonic-swss]:enable unconfiguring PFC on last TC on a port (#1962)
Browse files Browse the repository at this point in the history
* enable unconfiguring PFC on last TC on a port
Signed-off-by: Alpesh S Patel <[email protected]>
  • Loading branch information
alpeshspatel authored Nov 9, 2021
1 parent 05c7c05 commit 15074ac
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
8 changes: 7 additions & 1 deletion orchagent/qosorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1451,7 +1451,13 @@ task_process_status QosOrch::handlePortQosMapTable(Consumer& consumer)
SWSS_LOG_INFO("Applied %s to port %s", it->second.first.c_str(), port_name.c_str());
}

if (pfc_enable)
sai_uint8_t old_pfc_enable = 0;
if (!gPortsOrch->getPortPfc(port.m_port_id, &old_pfc_enable))
{
SWSS_LOG_ERROR("Failed to retrieve PFC bits on port %s", port_name.c_str());
}

if (pfc_enable || old_pfc_enable)
{
if (!gPortsOrch->setPortPfc(port.m_port_id, pfc_enable))
{
Expand Down
27 changes: 27 additions & 0 deletions tests/test_pfc.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,34 @@ def test_PfcAsymmetric(self, dvs, testlog):
pfc = getPortAttr(dvs, port_oid, 'SAI_PORT_ATTR_PRIORITY_FLOW_CONTROL')
assert pfc == pfc_tx

def test_PfcUnconfig(self, dvs, testlog):

port_name = 'Ethernet0'
pfc_queues = [ 3, 4 ]

# Configure default PFC
setPortPfc(dvs, port_name, pfc_queues)

# Get SAI object ID for the interface
port_oid = getPortOid(dvs, port_name)

# Verify default PFC is set to configured value
pfc = getPortAttr(dvs, port_oid, 'SAI_PORT_ATTR_PRIORITY_FLOW_CONTROL')
assert pfc == getBitMaskStr(pfc_queues)

# Configure PFC on single TC
pfc_queues = [ 3 ]
setPortPfc(dvs, port_name, pfc_queues)
# Verify default PFC is set to configured value
pfc = getPortAttr(dvs, port_oid, 'SAI_PORT_ATTR_PRIORITY_FLOW_CONTROL')
assert pfc == getBitMaskStr(pfc_queues)

# Disable PFC on last TC
pfc_queues = [ ]
setPortPfc(dvs, port_name, pfc_queues)
# Verify default PFC is set to configured value
pfc = getPortAttr(dvs, port_oid, 'SAI_PORT_ATTR_PRIORITY_FLOW_CONTROL')
assert pfc == getBitMaskStr(pfc_queues)

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

0 comments on commit 15074ac

Please sign in to comment.