Skip to content

Commit

Permalink
[pfcwd]: only init counter when handler is created and change lua to …
Browse files Browse the repository at this point in the history
…support infinite restoration time (sonic-net#458)

Signed-off-by: Sihui Han <sihan@microsoft.com>
  • Loading branch information
sihuihan88 authored Mar 28, 2018
1 parent 8995b30 commit d4ab3ee
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 12 deletions.
2 changes: 1 addition & 1 deletion orchagent/pfc_restore.lua
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ for i = n, 1, -1 do
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' and restoration_time then
if pfc_wd_status ~= 'operational' and pfc_wd_action ~= 'alert' and restoration_time 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
Expand Down
12 changes: 4 additions & 8 deletions orchagent/pfcwdorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
#define PFC_WD_RESTORATION_TIME_MAX (60 * 1000)
#define PFC_WD_RESTORATION_TIME_MIN 100
#define PFC_WD_POLL_TIMEOUT 5000
#define PFC_WD_LOSSY_POLL_TIMEOUT_SEC (5 * 60)
#define SAI_PORT_STAT_PFC_PREFIX "SAI_PORT_STAT_PFC_"
#define PFC_WD_TC_MAX 8

Expand All @@ -36,12 +35,6 @@ PfcWdOrch<DropHandler, ForwardHandler>::PfcWdOrch(DBConnector *db, vector<string
m_countersTable(new Table(m_countersDb.get(), COUNTERS_TABLE))
{
SWSS_LOG_ENTER();

auto interv = timespec { .tv_sec = PFC_WD_LOSSY_POLL_TIMEOUT_SEC, .tv_nsec = 0 };
auto timer = new SelectableTimer(interv);
auto executor = new ExecutableTimer(timer, this);
Orch::addExecutor("COUNTERS_POLL", executor);
timer->start();
}


Expand Down Expand Up @@ -442,6 +435,7 @@ void PfcWdSwOrch<DropHandler, ForwardHandler>::unregisterFromWdDb(const Port& po
redisClient.hdel(countersKey, "PFC_WD_ACTION");
redisClient.hdel(countersKey, "PFC_WD_STATUS");
}

}

template <typename DropHandler, typename ForwardHandler>
Expand Down Expand Up @@ -574,6 +568,7 @@ void PfcWdSwOrch<DropHandler, ForwardHandler>::doTask(swss::NotificationConsumer
entry->first,
entry->second.index,
PfcWdOrch<DropHandler, ForwardHandler>::getCountersTable());
entry->second.handler->initCounters();
}
}
else if (entry->second.action == PfcWdAction::PFC_WD_ACTION_DROP)
Expand All @@ -585,6 +580,7 @@ void PfcWdSwOrch<DropHandler, ForwardHandler>::doTask(swss::NotificationConsumer
entry->first,
entry->second.index,
PfcWdOrch<DropHandler, ForwardHandler>::getCountersTable());
entry->second.handler->initCounters();
}
}
else if (entry->second.action == PfcWdAction::PFC_WD_ACTION_FORWARD)
Expand All @@ -596,13 +592,13 @@ void PfcWdSwOrch<DropHandler, ForwardHandler>::doTask(swss::NotificationConsumer
entry->first,
entry->second.index,
PfcWdOrch<DropHandler, ForwardHandler>::getCountersTable());
entry->second.handler->initCounters();
}
}
else
{
throw runtime_error("Unknown PFC WD action");
}
entry->second.handler->initCounters();
}
else if (event == "restore")
{
Expand Down
3 changes: 0 additions & 3 deletions orchagent/pfcwdorch.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,6 @@ class PfcWdSwOrch: public PfcWdOrch<DropHandler, ForwardHandler>
shared_ptr<ProducerTable> m_flexCounterTable = nullptr;
shared_ptr<ProducerTable> m_flexCounterGroupTable = nullptr;

atomic_bool m_runPfcWdSwOrchThread = { false };
shared_ptr<thread> m_pfcWatchdogThread = nullptr;

int m_pollInterval;
};

Expand Down

0 comments on commit d4ab3ee

Please sign in to comment.