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

[202012][PFCWD + Asym PFC]: Allow PFCWD to detect PFC storm on all pr… #1887

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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 @@ -444,16 +444,18 @@ PfcWdLossyHandler::PfcWdLossyHandler(sai_object_id_t port, sai_object_id_t queue
return;
}

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));
pfcRxMask = static_cast<uint8_t>(pfcRxMask & ~(1 << queueId));
pfcTxMask = static_cast<uint8_t>(pfcTxMask & ~(1 << queueId));

if (!gPortsOrch->setPortPfc(port, pfcMask))
if (!gPortsOrch->setPortPfc(port, pfcTxMask, pfcRxMask))
{
SWSS_LOG_ERROR("Failed to set PFC mask on port 0x%" PRIx64, port);
}
Expand All @@ -471,16 +473,18 @@ PfcWdLossyHandler::~PfcWdLossyHandler(void)
return;
}

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()));
pfcRxMask = static_cast<uint8_t>(pfcRxMask | (1 << getQueueId()));
pfcTxMask = static_cast<uint8_t>(pfcTxMask | (1 << getQueueId()));

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
23 changes: 14 additions & 9 deletions orchagent/pfcwdorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -391,15 +391,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 @@ -408,7 +409,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 @@ -435,23 +436,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 @@ -487,18 +489,21 @@ 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;
}

// "losslessTc" contains lossless priorities provided by "pfc_enable" attr in QoS config
// "losslessTc" contains all priorities in case of enabled asymmetric PFC feature
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
9 changes: 8 additions & 1 deletion orchagent/port.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,13 @@ struct VlanInfo
sai_object_id_t host_intf_id = SAI_NULL_OBJECT_ID;
};

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 @@ -105,8 +112,8 @@ class Port
std::set<std::string> m_child_ports;
std::vector<sai_object_id_t> m_queue_ids;
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;
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
Loading