Skip to content

[pfcwd] Remove APPL_DB queue in-storm status at pfcwd config removal and big red switch enable #1691

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

Open
wants to merge 53 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
76add4b
Disable last tc
wendani Jan 13, 2021
099582e
Adjust log level
wendani Jan 18, 2021
41a9d4e
Introduce pfc bit mask status to track the pfc bit mask status in asic
wendani Jan 21, 2021
fb4fef4
Introduce private member function bool setPortPfcStatus(const Port &p…
wendani Jan 21, 2021
c2ba1e0
getPortPfc to get pfc status and cfg bit masks
wendani Jan 21, 2021
5b1e38c
Overload setPortPfcStatus
wendani Jan 21, 2021
908166e
Fix compile error
wendani Jan 21, 2021
b6e06d0
Fix typo
wendani Jan 21, 2021
d7fb1bf
Fix typo
wendani Jan 21, 2021
ddd480f
Set pfc bit in lossy handler destruction only if the corresponding bit
wendani Jan 23, 2021
53b2043
Update comment
wendani Jan 23, 2021
6c96bb6
Update code format and comment
wendani Jan 24, 2021
90cd76f
Merge remote-tracking branch 'origin/master' into pfc_bitmask
wendani Feb 4, 2021
60ade5d
Merge remote-tracking branch 'origin/master' into pfc_bitmask
wendani Feb 8, 2021
eb9f10a
Merge remote-tracking branch 'origin/master' into pfc_bitmask
wendani Feb 10, 2021
eb46d98
Merge remote-tracking branch 'public/master' into pfc_bitmask
wendani Feb 16, 2021
d08fe01
Fix typo
wendani Feb 16, 2021
a2c2527
Merge remote-tracking branch 'public/master' into pfc_bitmask
wendani Feb 17, 2021
6979e38
Merge remote-tracking branch 'public/master' into pfc_bitmask
wendani Feb 17, 2021
f609c95
Merge remote-tracking branch 'public/master' into pfc_bitmask
wendani Mar 12, 2021
cbcdc3d
Address comment: Revert log level
wendani Mar 12, 2021
3668328
Address comment: rename private function as setPortPfcStatus_
wendani Mar 12, 2021
095c2de
Address comment: rename m_pfc_bitmask_cfg to m_pfc_bitmask_usercfg,
wendani Mar 26, 2021
31e366b
Address comment: getPortPfc use reference
wendani Mar 26, 2021
19c5277
Address comment: getPortPfc use reference in pfcactionhandler
wendani Mar 26, 2021
625270c
Address comment: Address comment: getPortPfc use reference in pfcwdorch
wendani Mar 26, 2021
f548b2d
Address comment: getPortPfc use reference in setPortPfcAsym
wendani Mar 26, 2021
12e6c1f
Update comment
wendani Mar 27, 2021
df020b4
Restore log level
wendani Mar 27, 2021
47a8fad
Test case 1
wendani Mar 28, 2021
26bb587
Correct typo
wendani Mar 28, 2021
87f8dd0
Refactor
wendani Mar 28, 2021
50f60bf
Use getBitMaskStr
wendani Mar 28, 2021
d8d8dff
Test pfc enable bits clear
wendani Mar 28, 2021
6cf47b5
If pfc enable bits stay unchanged, sleep 2 seconds before check; Reve…
wendani Mar 28, 2021
f6d6e6d
brd test case
wendani Mar 28, 2021
e1bd125
Add comment
wendani Mar 28, 2021
ed11cac
Check fc cntr db removal of both queues
wendani Mar 30, 2021
8de9ac4
Rename variable
wendani Mar 30, 2021
92a0e35
Rename variable
wendani Mar 30, 2021
36d347b
Refactor
wendani Mar 30, 2021
7fc6079
Rename variable
wendani Mar 30, 2021
cbb2410
Merge remote-tracking branch 'public/master' into pfc_bitmask
wendani Mar 31, 2021
6673a9c
Merge remote-tracking branch 'public/master' into pfc_bitmask
wendani Apr 2, 2021
c491f08
Merge remote-tracking branch 'public/master' into pfc_bitmask
wendani Apr 3, 2021
63b6ba2
Remove {port, queue} in-storm status when pfc wd config on port is re…
wendani Apr 4, 2021
7e59764
Remove {port, queue} in-storm status when big red switch mode is enabled
wendani Apr 4, 2021
d8b5e09
Update code formats
wendani Apr 4, 2021
116daf1
Update code formats
wendani Apr 5, 2021
254d56c
Use create_entry in place of raw hset
wendani Apr 5, 2021
8248910
Update code formats
wendani Apr 5, 2021
e930ce4
Merge commit '8248910' into pfcwd_appl
wendani Apr 5, 2021
cedb134
Clear queue deadlock counters
wendani Apr 5, 2021
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 dummy = 0;
uint8_t pfcMaskCfg = 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, dummy, pfcMaskCfg))
{
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) & pfcMaskCfg) == 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 dummy = 0;
uint8_t pfcMaskCfg = 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, dummy, pfcMaskCfg))
{
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) & pfcMaskCfg) == 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 @@ -238,6 +238,7 @@ PfcWdAclHandler::PfcWdAclHandler(sai_object_id_t port, sai_object_id_t queue,
{
// First time of handling PFC for this queue, create ACL table, and bind
createPfcAclTable(port, m_strIngressTable, true);
// Create acl rule in bound acl table
shared_ptr<AclRulePfcwd> newRule = make_shared<AclRulePfcwd>(gAclOrch, m_strRule, m_strIngressTable, table_type);
createPfcAclRule(newRule, queueId, m_strIngressTable, port);
}
Expand Down Expand Up @@ -393,16 +394,17 @@ PfcWdLossyHandler::PfcWdLossyHandler(sai_object_id_t port, sai_object_id_t queue
{
SWSS_LOG_ENTER();

uint8_t pfcMask = 0;
uint8_t pfcMaskWdCfg = 0;
uint8_t dummy = 0;

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

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

if (!gPortsOrch->setPortPfc(port, pfcMask))
if (!gPortsOrch->setPortPfcStatus(port, pfcMaskWdCfg))
{
SWSS_LOG_ERROR("Failed to set PFC mask on port 0x%" PRIx64, port);
}
Expand All @@ -412,16 +414,18 @@ PfcWdLossyHandler::~PfcWdLossyHandler(void)
{
SWSS_LOG_ENTER();

uint8_t pfcMask = 0;
uint8_t pfcMaskWdCfg = 0;
uint8_t pfcMaskUserCfg = 0;

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

pfcMask = static_cast<uint8_t>(pfcMask | (1 << getQueueId()));
// Set PFC enable bit to asic only if the corresponding bit in user config is set
pfcMaskWdCfg = static_cast<uint8_t>(pfcMaskWdCfg | ((1 << getQueueId()) & pfcMaskUserCfg));

if (!gPortsOrch->setPortPfc(getPort(), pfcMask))
if (!gPortsOrch->setPortPfcStatus(getPort(), pfcMaskWdCfg))
{
SWSS_LOG_ERROR("Failed to set PFC mask on port 0x%" PRIx64, getPort());
}
Expand Down
46 changes: 32 additions & 14 deletions orchagent/pfcwdorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ void PfcWdSwOrch<DropHandler, ForwardHandler>::setBigRedSwitchMode(const string

if (value == "enable")
{
// When BIG_RED_SWITCH mode is enabled, pfcwd is automatically disabled
// When BIG_RED_SWITCH mode is enabled, pfcwd state machine is automatically disabled
enableBigRedSwitchMode();
}
else if (value == "disable")
Expand Down Expand Up @@ -362,7 +362,8 @@ void PfcWdSwOrch<DropHandler, ForwardHandler>::disableBigRedSwitchMode()
}

auto queueId = entry.first;
string countersKey = this->getCountersTable()->getTableName() + this->getCountersTable()->getTableNameSeparator() + sai_serialize_object_id(queueId);
string countersKey = this->getCountersTable()->getTableName() + this->getCountersTable()->getTableNameSeparator()
+ sai_serialize_object_id(queueId);
this->getCountersDb()->hdel(countersKey, "BIG_RED_SWITCH_MODE");
}

Expand All @@ -381,15 +382,16 @@ void PfcWdSwOrch<DropHandler, ForwardHandler>::enableBigRedSwitchMode()
for (auto &it: allPorts)
{
Port port = it.second;
uint8_t pfcMask = 0;
uint8_t pfcMaskWdCfg = 0;
uint8_t dummy = 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, pfcMaskWdCfg, dummy))
{
SWSS_LOG_ERROR("Failed to get PFC mask on port %s", port.m_alias.c_str());
return;
Expand All @@ -398,7 +400,11 @@ 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())
// PFC enable bit not set can be the case that the corresponding TC
// is lossless, and is currently in PFC storm, with PFC action in act.
// We pick up such a case to enable big red switch mode by checking if a corresponding
// entry exists in m_entryMap
if ((pfcMaskWdCfg & (1 << i)) == 0 && m_entryMap.find(queueId) == m_entryMap.end())
{
continue;
}
Expand All @@ -418,30 +424,37 @@ void PfcWdSwOrch<DropHandler, ForwardHandler>::enableBigRedSwitchMode()
{
entry.second.handler->commitCounters();
entry.second.handler = nullptr;
// Remove storm status in APPL_DB for warm-reboot purpose
string key = m_applTable->getTableName() + m_applTable->getTableNameSeparator() + entry.second.portAlias;
m_applDb->hdel(key, to_string(entry.second.index));
}
}

// Create pfcwdaction handler on all the ports.
// Create pfcwdaction handler on all ports.
for (auto & it: allPorts)
{
Port port = it.second;
uint8_t pfcMask = 0;
uint8_t pfcMaskWdCfg = 0;
uint8_t pfcMaskUserCfg = 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, pfcMaskWdCfg, pfcMaskUserCfg))
{
SWSS_LOG_ERROR("Failed to get PFC mask on port %s", port.m_alias.c_str());
return;
}
// By removing action handler, we expect PFC bit mask status in asic (pfcwd config) to
// be the same as user config
assert(pfcMaskWdCfg == pfcMaskUserCfg);

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

uint8_t pfcMask = 0;
uint8_t dummy = 0;
uint8_t pfcMaskUserCfg = 0;

if (!gPortsOrch->getPortPfc(port.m_port_id, &pfcMask))
if (!gPortsOrch->getPortPfc(port.m_port_id, dummy, pfcMaskUserCfg))
{
SWSS_LOG_ERROR("Failed to get PFC mask on port %s", port.m_alias.c_str());
return false;
Expand All @@ -488,11 +502,12 @@ 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 ((pfcMaskUserCfg & (1 << i)) == 0)
{
continue;
}

SWSS_LOG_NOTICE("Lossless TC %u found on port %s", i, port.m_alias.c_str());
losslessTc.insert(i);
}
if (losslessTc.empty())
Expand Down Expand Up @@ -625,12 +640,16 @@ void PfcWdSwOrch<DropHandler, ForwardHandler>::unregisterFromWdDb(const Port& po
if (entry != m_entryMap.end() && entry->second.handler != nullptr)
{
entry->second.handler->commitCounters();
// Remove storm status in APPL_DB for warm-reboot purpose
string key = m_applTable->getTableName() + m_applTable->getTableNameSeparator() + entry->second.portAlias;
m_applDb->hdel(key, to_string(entry->second.index));
}

m_entryMap.erase(queueId);

// Clean up
string countersKey = this->getCountersTable()->getTableName() + this->getCountersTable()->getTableNameSeparator() + sai_serialize_object_id(queueId);
string countersKey = this->getCountersTable()->getTableName() + this->getCountersTable()->getTableNameSeparator()
+ sai_serialize_object_id(queueId);
this->getCountersDb()->hdel(countersKey, {"PFC_WD_DETECTION_TIME", "PFC_WD_RESTORATION_TIME", "PFC_WD_ACTION", "PFC_WD_STATUS"});
}

Expand Down Expand Up @@ -889,7 +908,6 @@ void PfcWdSwOrch<DropHandler, ForwardHandler>::doTask(SelectableTimer &timer)
handlerPair.second.handler->commitCounters(true);
}
}

}

template <typename DropHandler, typename ForwardHandler>
Expand Down
3 changes: 2 additions & 1 deletion orchagent/port.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,8 @@ class Port
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;
uint8_t m_pfc_bitmask_usercfg = 0; // bitmask from user config
uint8_t m_pfc_bitmask_wdcfg = 0; // bitmask of pfcwd config / status in asic
uint32_t m_nat_zone_id = 0;
uint32_t m_vnid = VNID_NONE;
uint32_t m_fdb_count = 0;
Expand Down
Loading