diff --git a/orchagent/qosorch.cpp b/orchagent/qosorch.cpp index 3c422c67d669..1430aceef150 100644 --- a/orchagent/qosorch.cpp +++ b/orchagent/qosorch.cpp @@ -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)) { diff --git a/tests/test_pfc.py b/tests/test_pfc.py index 2e3b12479098..9bd5c41f0a18 100644 --- a/tests/test_pfc.py +++ b/tests/test_pfc.py @@ -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