Skip to content

Commit

Permalink
[pfcwdorch]: Allow unlimited restoration time (sonic-net#341)
Browse files Browse the repository at this point in the history
In case if user does not pass restoration time, it is assumed that queue
will be mitigated indefinitely in an event of PFC storm until user disables
watchdog on that port.

Signed-off-by: marian-pritsak <marianp@mellanox.com>
  • Loading branch information
marian-pritsak authored and lguohan committed Nov 7, 2017
1 parent 26d37d1 commit 45c1ed4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
5 changes: 3 additions & 2 deletions orchagent/pfc_restore.lua
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@ for i = n, 1, -1 do
local counter_keys = redis.call('HKEYS', counters_table_name .. ':' .. KEYS[i])
local pfc_rx_pkt_key = ''
local pfc_wd_status = redis.call('HGET', counters_table_name .. ':' .. KEYS[i], 'PFC_WD_STATUS')
local restoration_time = redis.call('HGET', counters_table_name .. ':' .. KEYS[i], 'PFC_WD_RESTORATION_TIME')
local pfc_wd_action = redis.call('HGET', counters_table_name .. ':' .. KEYS[i], 'PFC_WD_ACTION')
if pfc_wd_status ~= 'operational' and pfc_wd_action ~= 'alert' then
local restoration_time = tonumber(redis.call('HGET', counters_table_name .. ':' .. KEYS[i], 'PFC_WD_RESTORATION_TIME'))
if pfc_wd_status ~= 'operational' and pfc_wd_action ~= 'alert' and restoration_time ~= '' then
restoration_time = tonumber(restoration_time)
local time_left = redis.call('HGET', counters_table_name .. ':' .. KEYS[i], 'PFC_WD_RESTORATION_TIME_LEFT')
if time_left == nil then
time_left = restoration_time
Expand Down
12 changes: 5 additions & 7 deletions orchagent/pfcwdorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,12 +223,6 @@ void PfcWdOrch<DropHandler, ForwardHandler>::createEntry(const string& key,
return;
}

if (restorationTime == 0)
{
SWSS_LOG_ERROR("%s missing", PFC_WD_RESTORATION_TIME);
return;
}

if (!startWdOnPort(port, detectionTime, restorationTime, action))
{
SWSS_LOG_ERROR("Failed to start PFC Watchdog on port %s", port.m_alias.c_str());
Expand Down Expand Up @@ -296,7 +290,11 @@ void PfcWdSwOrch<DropHandler, ForwardHandler>::registerInWdDb(const Port& port,
// Store detection and restoration time for plugins
vector<FieldValueTuple> countersFieldValues;
countersFieldValues.emplace_back("PFC_WD_DETECTION_TIME", to_string(detectionTime * 1000));
countersFieldValues.emplace_back("PFC_WD_RESTORATION_TIME", to_string(restorationTime * 1000));
// Restoration time is optional
countersFieldValues.emplace_back("PFC_WD_RESTORATION_TIME",
restorationTime == 0 ?
"" :
to_string(restorationTime * 1000));
countersFieldValues.emplace_back("PFC_WD_ACTION", this->serializeAction(action));

PfcWdOrch<DropHandler, ForwardHandler>::getCountersTable()->set(queueIdStr, countersFieldValues);
Expand Down

0 comments on commit 45c1ed4

Please sign in to comment.