From 5a286fccf1bcbe4eaf3df39c04216ecea5a87edc Mon Sep 17 00:00:00 2001 From: Alpesh S Patel Date: Fri, 15 Oct 2021 07:55:53 -0700 Subject: [PATCH 1/2] enable unconfiguring PFC on last TC on a port Signed-off-by: Alpesh S Patel --- orchagent/qosorch.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/orchagent/qosorch.cpp b/orchagent/qosorch.cpp index 771ffbcd8a..ce72b4a530 100644 --- a/orchagent/qosorch.cpp +++ b/orchagent/qosorch.cpp @@ -1392,7 +1392,12 @@ 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)) { From be7827f7165da9d0390c63024ec1d7636f9d611a Mon Sep 17 00:00:00 2001 From: Alpesh S Patel Date: Wed, 3 Nov 2021 05:02:15 -0700 Subject: [PATCH 2/2] address PR comments Signed-off-by: Alpesh S Patel --- orchagent/qosorch.cpp | 3 ++- tests/test_pfc.py | 27 +++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/orchagent/qosorch.cpp b/orchagent/qosorch.cpp index ce72b4a530..63da8b2035 100644 --- a/orchagent/qosorch.cpp +++ b/orchagent/qosorch.cpp @@ -1393,7 +1393,8 @@ task_process_status QosOrch::handlePortQosMapTable(Consumer& consumer) } sai_uint8_t old_pfc_enable = 0; - if (!gPortsOrch->getPortPfc(port.m_port_id, &old_pfc_enable)) { + 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()); } diff --git a/tests/test_pfc.py b/tests/test_pfc.py index 2e3b124790..9bd5c41f0a 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