Skip to content

Commit 45c1ed4

Browse files
marian-pritsaklguohan
authored andcommitted
[pfcwdorch]: Allow unlimited restoration time (sonic-net#341)
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 <[email protected]>
1 parent 26d37d1 commit 45c1ed4

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

orchagent/pfc_restore.lua

+3-2
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,10 @@ for i = n, 1, -1 do
1818
local counter_keys = redis.call('HKEYS', counters_table_name .. ':' .. KEYS[i])
1919
local pfc_rx_pkt_key = ''
2020
local pfc_wd_status = redis.call('HGET', counters_table_name .. ':' .. KEYS[i], 'PFC_WD_STATUS')
21+
local restoration_time = redis.call('HGET', counters_table_name .. ':' .. KEYS[i], 'PFC_WD_RESTORATION_TIME')
2122
local pfc_wd_action = redis.call('HGET', counters_table_name .. ':' .. KEYS[i], 'PFC_WD_ACTION')
22-
if pfc_wd_status ~= 'operational' and pfc_wd_action ~= 'alert' then
23-
local restoration_time = tonumber(redis.call('HGET', counters_table_name .. ':' .. KEYS[i], 'PFC_WD_RESTORATION_TIME'))
23+
if pfc_wd_status ~= 'operational' and pfc_wd_action ~= 'alert' and restoration_time ~= '' then
24+
restoration_time = tonumber(restoration_time)
2425
local time_left = redis.call('HGET', counters_table_name .. ':' .. KEYS[i], 'PFC_WD_RESTORATION_TIME_LEFT')
2526
if time_left == nil then
2627
time_left = restoration_time

orchagent/pfcwdorch.cpp

+5-7
Original file line numberDiff line numberDiff line change
@@ -223,12 +223,6 @@ void PfcWdOrch<DropHandler, ForwardHandler>::createEntry(const string& key,
223223
return;
224224
}
225225

226-
if (restorationTime == 0)
227-
{
228-
SWSS_LOG_ERROR("%s missing", PFC_WD_RESTORATION_TIME);
229-
return;
230-
}
231-
232226
if (!startWdOnPort(port, detectionTime, restorationTime, action))
233227
{
234228
SWSS_LOG_ERROR("Failed to start PFC Watchdog on port %s", port.m_alias.c_str());
@@ -296,7 +290,11 @@ void PfcWdSwOrch<DropHandler, ForwardHandler>::registerInWdDb(const Port& port,
296290
// Store detection and restoration time for plugins
297291
vector<FieldValueTuple> countersFieldValues;
298292
countersFieldValues.emplace_back("PFC_WD_DETECTION_TIME", to_string(detectionTime * 1000));
299-
countersFieldValues.emplace_back("PFC_WD_RESTORATION_TIME", to_string(restorationTime * 1000));
293+
// Restoration time is optional
294+
countersFieldValues.emplace_back("PFC_WD_RESTORATION_TIME",
295+
restorationTime == 0 ?
296+
"" :
297+
to_string(restorationTime * 1000));
300298
countersFieldValues.emplace_back("PFC_WD_ACTION", this->serializeAction(action));
301299

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

0 commit comments

Comments
 (0)