Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PFCWD + Asym PFC]: Allow PFCWD to detect PFC storm on all priorities when Asym PFC is enabled #1360

Closed
Closed
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
0f3e9f3
[PFCWD + Asym PFC]: Allow PFCWD to detect PFC storm on all priorities…
Jul 23, 2020
93fb08e
Merge branch 'master' of https://github.com/Azure/sonic-swss into pfc…
volodymyrsamotiy Feb 23, 2021
3ab862b
[PFCWD + Asym PFC]: Allow PFCWD to detect PFC storm on all priorities…
volodymyrsamotiy Feb 23, 2021
571e991
[PFCWD + Asym PFC]: Allow PFCWD to detect PFC storm on all priorities…
volodymyrsamotiy Feb 23, 2021
a6b31ea
Merge branch 'master' of https://github.com/Azure/sonic-swss into pfc…
volodymyrsamotiy Jun 18, 2021
acf21f5
[PFCWD + Asym PFC]: Allow PFCWD to detect PFC storm on all priorities…
volodymyrsamotiy Jun 18, 2021
0d36d37
[PFCWD + Asym PFC]: Allow PFCWD to detect PFC storm on all priorities…
volodymyrsamotiy Jun 18, 2021
53cf04e
[PFCWD + Asym PFC]: Add VS test
volodymyrsamotiy Jun 25, 2021
a946c21
[PFCWD + Asym PFC]: Add cleanup to VS test
volodymyrsamotiy Aug 18, 2021
4837534
[PFCWD + Asym PFC]: Allow PFCWD to detect PFC storm on all priorities…
volodymyrsamotiy Sep 14, 2021
9586b6f
[PFCWD + Asym PFC]: Allow PFCWD to detect PFC storm on all priorities…
volodymyrsamotiy Sep 14, 2021
1e001f5
Merge branch 'master' of https://github.com/Azure/sonic-swss into pfc…
volodymyrsamotiy Dec 20, 2021
d710235
[PFCWD + Asym PFC]: Align the code according to latest changes in qos…
volodymyrsamotiy Dec 22, 2021
6fd9206
Merge branch 'master' of https://github.com/Azure/sonic-swss into pfc…
volodymyrsamotiy Jan 12, 2022
c7f26fc
Merge branch 'master' of https://github.com/Azure/sonic-swss into pfc…
volodymyrsamotiy Mar 29, 2022
0c720df
[PFCWD + Asym PFC]: Align the code according to latest changes in qos…
volodymyrsamotiy Mar 29, 2022
7990b32
[PFCWD + Asym PFC]: Remove old VS test which should be replaced by ne…
volodymyrsamotiy Mar 29, 2022
13b56d8
[PFCWD + Asym PFC]: Add VS test for PFCWD with enabled asymetric PFC
volodymyrsamotiy Mar 29, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions orchagent/countercheckorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ void CounterCheckOrch::mcCounterCheck()
{
auto oid = i.first;
auto mcCounters = i.second;
uint8_t pfcMask = 0;
uint8_t pfcTxMask = 0;
uint8_t pfcRxMask = 0;

Port port;
if (!gPortsOrch->getPort(oid, port))
Expand All @@ -67,15 +68,15 @@ void CounterCheckOrch::mcCounterCheck()

auto newMcCounters = getQueueMcCounters(port);

if (!gPortsOrch->getPortPfc(port.m_port_id, &pfcMask))
if (!gPortsOrch->getPortPfc(port.m_port_id, &pfcTxMask, &pfcRxMask))
{
SWSS_LOG_ERROR("Failed to get PFC mask on port %s", port.m_alias.c_str());
continue;
}

for (size_t prio = 0; prio != mcCounters.size(); prio++)
{
bool isLossy = ((1 << prio) & pfcMask) == 0;
bool isLossy = ((1 << prio) & pfcRxMask) == 0;
if (newMcCounters[prio] == numeric_limits<uint64_t>::max())
{
SWSS_LOG_WARN("Could not retreive MC counters on queue %zu port %s",
Expand Down Expand Up @@ -104,7 +105,8 @@ void CounterCheckOrch::pfcFrameCounterCheck()
auto oid = i.first;
auto counters = i.second;
auto newCounters = getPfcFrameCounters(oid);
uint8_t pfcMask = 0;
uint8_t pfcTxMask = 0;
uint8_t pfcRxMask = 0;

Port port;
if (!gPortsOrch->getPort(oid, port))
Expand All @@ -113,15 +115,15 @@ void CounterCheckOrch::pfcFrameCounterCheck()
continue;
}

if (!gPortsOrch->getPortPfc(port.m_port_id, &pfcMask))
if (!gPortsOrch->getPortPfc(port.m_port_id, &pfcTxMask, &pfcRxMask))
{
SWSS_LOG_ERROR("Failed to get PFC mask on port %s", port.m_alias.c_str());
continue;
}

for (size_t prio = 0; prio != counters.size(); prio++)
{
bool isLossy = ((1 << prio) & pfcMask) == 0;
bool isLossy = ((1 << prio) & pfcRxMask) == 0;
if (newCounters[prio] == numeric_limits<uint64_t>::max())
{
SWSS_LOG_WARN("Could not retreive PFC frame count on queue %zu port %s",
Expand Down
20 changes: 12 additions & 8 deletions orchagent/pfcactionhandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -385,16 +385,18 @@ PfcWdLossyHandler::PfcWdLossyHandler(sai_object_id_t port, sai_object_id_t queue
{
SWSS_LOG_ENTER();

uint8_t pfcMask = 0;
uint8_t pfcTxMask = 0;
uint8_t pfcRxMask = 0;

if (!gPortsOrch->getPortPfc(port, &pfcMask))
if (!gPortsOrch->getPortPfc(port, &pfcTxMask, &pfcRxMask))
{
SWSS_LOG_ERROR("Failed to get PFC mask on port 0x%" PRIx64, port);
}

pfcMask = static_cast<uint8_t>(pfcMask & ~(1 << queueId));
pfcTxMask = static_cast<uint8_t>(pfcTxMask & ~(1 << queueId));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need to modify Tx Mask? In any case, its a noop if pfcwd is triggered on a lossy priority because the txMask only contains priorities 3 and 4

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree, we don' need it. Fixed to modify only Rx mask.

pfcRxMask = static_cast<uint8_t>(pfcRxMask & ~(1 << queueId));

if (!gPortsOrch->setPortPfc(port, pfcMask))
if (!gPortsOrch->setPortPfc(port, pfcTxMask, pfcRxMask))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In normal mode, when pfcwd is triggered, we reset the bit corresponding to that queueId in the 'pfcMask'. The new logic in L404 does it only for 'pfcRxMask'. In 'setPortPfc' func, the new condition in L1076 (check if txmask and rxmask are not the same in combined mode) will evaluate to true and we will return false.
We will need to modify pfcTxMask as well here for combined mode

Also in asym mode, when any of the queues specified in the pfc_enable field of PORT_QOS_MAP is in storm, we need to disable pfc for that queue. so pfcTxMask needs to be updated for that case as well.

{
SWSS_LOG_ERROR("Failed to set PFC mask on port 0x%" PRIx64, port);
}
Expand All @@ -404,16 +406,18 @@ PfcWdLossyHandler::~PfcWdLossyHandler(void)
{
SWSS_LOG_ENTER();

uint8_t pfcMask = 0;
uint8_t pfcTxMask = 0;
uint8_t pfcRxMask = 0;

if (!gPortsOrch->getPortPfc(getPort(), &pfcMask))
if (!gPortsOrch->getPortPfc(getPort(), &pfcTxMask, &pfcRxMask))
{
SWSS_LOG_ERROR("Failed to get PFC mask on port 0x%" PRIx64, getPort());
}

pfcMask = static_cast<uint8_t>(pfcMask | (1 << getQueueId()));
pfcTxMask = static_cast<uint8_t>(pfcTxMask | (1 << getQueueId()));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We shouldn't be modifying Tx Mask since it contains only priorities 3 and 4. We will setting tx mask to incorrect values on pfcwd storm restore if pfcwd was triggered on a lossy priority

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree, we don' need it. Fixed to modify only Rx mask.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thinking about this more, we need to set the txmask but need to do it only for queues set in 'pfc_enable' field

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I will change it back and verify

pfcRxMask = static_cast<uint8_t>(pfcRxMask | (1 << getQueueId()));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to update pfcTxMask as well in combined mode and in asym mode, update pfcTxMask if the queue is one specified in 'pfc_enable' fields of PORT_QOS_MAP


if (!gPortsOrch->setPortPfc(getPort(), pfcMask))
if (!gPortsOrch->setPortPfc(getPort(), pfcTxMask, pfcRxMask))
{
SWSS_LOG_ERROR("Failed to set PFC mask on port 0x%" PRIx64, getPort());
}
Expand Down
21 changes: 12 additions & 9 deletions orchagent/pfcwdorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -381,15 +381,16 @@ void PfcWdSwOrch<DropHandler, ForwardHandler>::enableBigRedSwitchMode()
for (auto &it: allPorts)
{
Port port = it.second;
uint8_t pfcMask = 0;
uint8_t pfcTxMask = 0;
uint8_t pfcRxMask = 0;

if (port.m_type != Port::PHY)
{
SWSS_LOG_INFO("Skip non-phy port %s", port.m_alias.c_str());
continue;
}

if (!gPortsOrch->getPortPfc(port.m_port_id, &pfcMask))
if (!gPortsOrch->getPortPfc(port.m_port_id, &pfcTxMask, &pfcRxMask))
{
SWSS_LOG_ERROR("Failed to get PFC mask on port %s", port.m_alias.c_str());
return;
Expand All @@ -398,7 +399,7 @@ void PfcWdSwOrch<DropHandler, ForwardHandler>::enableBigRedSwitchMode()
for (uint8_t i = 0; i < PFC_WD_TC_MAX; i++)
{
sai_object_id_t queueId = port.m_queue_ids[i];
if ((pfcMask & (1 << i)) == 0 && m_entryMap.find(queueId) == m_entryMap.end())
if ((pfcRxMask & (1 << i)) == 0 && m_entryMap.find(queueId) == m_entryMap.end())
{
continue;
}
Expand All @@ -425,23 +426,24 @@ void PfcWdSwOrch<DropHandler, ForwardHandler>::enableBigRedSwitchMode()
for (auto & it: allPorts)
{
Port port = it.second;
uint8_t pfcMask = 0;
uint8_t pfcTxMask = 0;
uint8_t pfcRxMask = 0;

if (port.m_type != Port::PHY)
{
SWSS_LOG_INFO("Skip non-phy port %s", port.m_alias.c_str());
continue;
}

if (!gPortsOrch->getPortPfc(port.m_port_id, &pfcMask))
if (!gPortsOrch->getPortPfc(port.m_port_id, &pfcTxMask, &pfcRxMask))
{
SWSS_LOG_ERROR("Failed to get PFC mask on port %s", port.m_alias.c_str());
return;
}

for (uint8_t i = 0; i < PFC_WD_TC_MAX; i++)
{
if ((pfcMask & (1 << i)) == 0)
if ((pfcRxMask & (1 << i)) == 0)
{
continue;
}
Expand Down Expand Up @@ -477,9 +479,10 @@ bool PfcWdSwOrch<DropHandler, ForwardHandler>::registerInWdDb(const Port& port,
{
SWSS_LOG_ENTER();

uint8_t pfcMask = 0;
uint8_t pfcTxMask = 0;
uint8_t pfcRxMask = 0;

if (!gPortsOrch->getPortPfc(port.m_port_id, &pfcMask))
if (!gPortsOrch->getPortPfc(port.m_port_id, &pfcTxMask, &pfcRxMask))
{
SWSS_LOG_ERROR("Failed to get PFC mask on port %s", port.m_alias.c_str());
return false;
Expand All @@ -488,7 +491,7 @@ bool PfcWdSwOrch<DropHandler, ForwardHandler>::registerInWdDb(const Port& port,
set<uint8_t> losslessTc;
for (uint8_t i = 0; i < PFC_WD_TC_MAX; i++)
{
if ((pfcMask & (1 << i)) == 0)
if ((pfcRxMask & (1 << i)) == 0)
{
continue;
}
Expand Down
8 changes: 8 additions & 0 deletions orchagent/port.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,13 @@ struct SystemPortInfo
uint32_t num_voq = 8;
};

struct PfcInfo
{
sai_port_priority_flow_control_mode_t pfc_mode = SAI_PORT_PRIORITY_FLOW_CONTROL_MODE_COMBINED;
uint8_t pfc_tx_bitmask = 0;
uint8_t pfc_rx_bitmask = 0;
};

class Port
{
public:
Expand Down Expand Up @@ -120,6 +127,7 @@ class Port
std::vector<sai_object_id_t> m_priority_group_ids;
sai_port_priority_flow_control_mode_t m_pfc_asym = SAI_PORT_PRIORITY_FLOW_CONTROL_MODE_COMBINED;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have two variable for save port priority flow control mode: m_pfc_asym and pfc_mode in struct PfcInfo
Maybe we can remove m_pfc_asym ?

uint8_t m_pfc_bitmask = 0;
PfcInfo m_pfc_info;
uint32_t m_nat_zone_id = 0;
uint32_t m_vnid = VNID_NONE;
uint32_t m_fdb_count = 0;
Expand Down
119 changes: 72 additions & 47 deletions orchagent/portsorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -907,7 +907,7 @@ bool PortsOrch::setPortFec(Port &port, sai_port_fec_mode_t mode)
return true;
}

bool PortsOrch::getPortPfc(sai_object_id_t portId, uint8_t *pfc_bitmask)
bool PortsOrch::getPortPfc(sai_object_id_t portId, uint8_t *pfc_tx_bitmask, uint8_t *pfc_rx_bitmask)
{
SWSS_LOG_ENTER();

Expand All @@ -919,12 +919,13 @@ bool PortsOrch::getPortPfc(sai_object_id_t portId, uint8_t *pfc_bitmask)
return false;
}

*pfc_bitmask = p.m_pfc_bitmask;
*pfc_tx_bitmask = p.m_pfc_info.pfc_tx_bitmask;
*pfc_rx_bitmask = p.m_pfc_info.pfc_rx_bitmask;

return true;
}

bool PortsOrch::setPortPfc(sai_object_id_t portId, uint8_t pfc_bitmask)
bool PortsOrch::setPortPfc(sai_object_id_t portId, uint8_t pfc_tx_bitmask, uint8_t pfc_rx_bitmask)
{
SWSS_LOG_ENTER();

Expand All @@ -937,34 +938,60 @@ bool PortsOrch::setPortPfc(sai_object_id_t portId, uint8_t pfc_bitmask)
return false;
}

if (p.m_pfc_asym == SAI_PORT_PRIORITY_FLOW_CONTROL_MODE_COMBINED)
if (p.m_pfc_info.pfc_mode == SAI_PORT_PRIORITY_FLOW_CONTROL_MODE_COMBINED)
{
if (pfc_tx_bitmask != pfc_rx_bitmask)
{
SWSS_LOG_ERROR("Cannot set unequal Tx 0x%x and Rx 0x%x PFC bitmasks "
"for the port 0x%" PRIx64 " with disabled \"asymmetric\" PFC mode",
pfc_tx_bitmask, pfc_rx_bitmask, portId);
return false;
}

attr.id = SAI_PORT_ATTR_PRIORITY_FLOW_CONTROL;
attr.value.u8 = pfc_tx_bitmask;

sai_status_t status = sai_port_api->set_port_attribute(portId, &attr);
if (status != SAI_STATUS_SUCCESS)
{
SWSS_LOG_ERROR("Failed to set PFC bitmask 0x%x for the port 0x%" PRIx64 " (rc:%d)",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure i understand this part.
you are using the tx pfc bitmask for setting flow control and the message in the log is still pfc bitmask which i can see later on you have one for rx and tx.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This logic is explained in the "Asymmentric PFC" HLD in the "2.2.1 PortsOrch" section
https://github.com/Azure/SONiC/wiki/Asymmetric-PFC-High-Level-Design#221-portsorch

attr.value.u8, portId, status);
return false;
}
}
else if (p.m_pfc_asym == SAI_PORT_PRIORITY_FLOW_CONTROL_MODE_SEPARATE)
else if (p.m_pfc_info.pfc_mode == SAI_PORT_PRIORITY_FLOW_CONTROL_MODE_SEPARATE)
{
attr.id = SAI_PORT_ATTR_PRIORITY_FLOW_CONTROL_TX;
}
else
{
SWSS_LOG_ERROR("Incorrect asymmetric PFC mode: %u", p.m_pfc_asym);
return false;
}
attr.value.u8 = pfc_tx_bitmask;

attr.value.u8 = pfc_bitmask;
sai_status_t status = sai_port_api->set_port_attribute(portId, &attr);
if (status != SAI_STATUS_SUCCESS)
{
SWSS_LOG_ERROR("Failed to set Tx PFC bitmask 0x%x for the port 0x%" PRIx64 " (rc:%d)",
attr.value.u8, portId, status);
return false;
}

sai_status_t status = sai_port_api->set_port_attribute(portId, &attr);
if (status != SAI_STATUS_SUCCESS)
attr.id = SAI_PORT_ATTR_PRIORITY_FLOW_CONTROL_RX;
attr.value.u8 = pfc_rx_bitmask;

status = sai_port_api->set_port_attribute(portId, &attr);
if (status != SAI_STATUS_SUCCESS)
{
SWSS_LOG_ERROR("Failed to set Rx PFC bitmask 0x%x for the port 0x%" PRIx64 " (rc:%d)",
attr.value.u8, portId, status);
return false;
}
}
else
{
SWSS_LOG_ERROR("Failed to set PFC 0x%x to port id 0x%" PRIx64 " (rc:%d)", attr.value.u8, portId, status);
SWSS_LOG_ERROR("Incorrect PFC mode %u for the port 0x%" PRIx64, p.m_pfc_info.pfc_mode, portId);
return false;
}

if (p.m_pfc_bitmask != pfc_bitmask)
{
p.m_pfc_bitmask = pfc_bitmask;
m_portList[p.m_alias] = p;
}
p.m_pfc_info.pfc_tx_bitmask = pfc_tx_bitmask;
p.m_pfc_info.pfc_rx_bitmask = pfc_rx_bitmask;
m_portList[p.m_alias] = p;

return true;
}
Expand All @@ -974,59 +1001,57 @@ bool PortsOrch::setPortPfcAsym(Port &port, string pfc_asym)
SWSS_LOG_ENTER();

sai_attribute_t attr;
uint8_t pfc = 0;
uint8_t pfc_tx_bitmask = 0;
uint8_t pfc_rx_bitmask = 0;

if (!getPortPfc(port.m_port_id, &pfc))
if (pfc_asym_map.find(pfc_asym) == pfc_asym_map.end())
{
SWSS_LOG_ERROR("Incorrect asymmetric PFC mode: %s", pfc_asym.c_str());
return false;
}

auto found = pfc_asym_map.find(pfc_asym);
if (found == pfc_asym_map.end())
if (port.m_pfc_info.pfc_mode == pfc_asym_map[pfc_asym])
{
SWSS_LOG_NOTICE("Asymmetric PFC mode is alredy set to \"%s\" for the port 0x%" PRIx64,
pfc_asym.c_str(), port.m_port_id);
return true;
}

if (!getPortPfc(port.m_port_id, &pfc_tx_bitmask, &pfc_rx_bitmask))
{
SWSS_LOG_ERROR("Incorrect asymmetric PFC mode: %s", pfc_asym.c_str());
return false;
}

auto new_pfc_asym = found->second;
if (port.m_pfc_asym == new_pfc_asym)
if (pfc_asym_map[pfc_asym] == SAI_PORT_PRIORITY_FLOW_CONTROL_MODE_SEPARATE)
{
SWSS_LOG_NOTICE("Already set asymmetric PFC mode: %s", pfc_asym.c_str());
return true;
pfc_rx_bitmask = static_cast<uint8_t>(0xff);
}
else
{
pfc_rx_bitmask = pfc_tx_bitmask;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic has changed, can you elaborate it in the code?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Logic is exactly the same but code was refactored according to changes for set/getPortPfc API.

}

port.m_pfc_asym = new_pfc_asym;
port.m_pfc_info.pfc_mode = pfc_asym_map[pfc_asym];
m_portList[port.m_alias] = port;

attr.id = SAI_PORT_ATTR_PRIORITY_FLOW_CONTROL_MODE;
attr.value.s32 = (int32_t) port.m_pfc_asym;
attr.value.s32 = static_cast<int32_t>(port.m_pfc_info.pfc_mode);

sai_status_t status = sai_port_api->set_port_attribute(port.m_port_id, &attr);
if (status != SAI_STATUS_SUCCESS)
{
SWSS_LOG_ERROR("Failed to set PFC mode %d to port id 0x%" PRIx64 " (rc:%d)", port.m_pfc_asym, port.m_port_id, status);
SWSS_LOG_ERROR("Failed to set PFC mode %d for port 0x%" PRIx64 " (rc:%d)",
port.m_pfc_info.pfc_mode, port.m_port_id, status);
return false;
}

if (!setPortPfc(port.m_port_id, pfc))
if (!setPortPfc(port.m_port_id, pfc_tx_bitmask, pfc_rx_bitmask))
{
return false;
}

if (port.m_pfc_asym == SAI_PORT_PRIORITY_FLOW_CONTROL_MODE_SEPARATE)
{
attr.id = SAI_PORT_ATTR_PRIORITY_FLOW_CONTROL_RX;
attr.value.u8 = static_cast<uint8_t>(0xff);

sai_status_t status = sai_port_api->set_port_attribute(port.m_port_id, &attr);
if (status != SAI_STATUS_SUCCESS)
{
SWSS_LOG_ERROR("Failed to set RX PFC 0x%x to port id 0x%" PRIx64 " (rc:%d)", attr.value.u8, port.m_port_id, status);
return false;
}
}

SWSS_LOG_INFO("Set asymmetric PFC %s to port id 0x%" PRIx64, pfc_asym.c_str(), port.m_port_id);
SWSS_LOG_INFO("Set asymmetric PFC mode to \"%s\" for the port id 0x%" PRIx64,
pfc_asym.c_str(), port.m_port_id);

return true;
}
Expand Down
Loading