Skip to content
Open
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
2 changes: 2 additions & 0 deletions orchagent/bufferorch.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include "flex_counter_manager.h"
#include "tokenize.h"
#include "bufferorch.h"
#include "directory.h"
Expand Down Expand Up @@ -246,6 +247,7 @@ void BufferOrch::initFlexCounterGroupTable(void)

setFlexCounterGroupParameter(BUFFER_POOL_WATERMARK_STAT_COUNTER_FLEX_COUNTER_GROUP,
BUFFER_POOL_WATERMARK_FLEX_STAT_COUNTER_POLL_MSECS,
BUFFER_POOL_WATERMARK_DEFAULT_SECONDARY_POLL_FACTOR,
"", // do not touch stats_mode
BUFFER_POOL_PLUGIN_FIELD,
bufferPoolWmSha);
Expand Down
1 change: 1 addition & 0 deletions orchagent/bufferorch.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

#define BUFFER_POOL_WATERMARK_STAT_COUNTER_FLEX_COUNTER_GROUP "BUFFER_POOL_WATERMARK_STAT_COUNTER"
#define BUFFER_POOL_WATERMARK_FLEX_STAT_COUNTER_POLL_MSECS "60000"
#define BUFFER_POOL_WATERMARK_DEFAULT_SECONDARY_POLL_FACTOR "0"

const string buffer_size_field_name = "size";
const string buffer_pool_type_field_name = "type";
Expand Down
1 change: 1 addition & 0 deletions orchagent/copporch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1388,6 +1388,7 @@ void CoppOrch::initTrapRatePlugin()

setFlexCounterGroupParameter(HOSTIF_TRAP_COUNTER_FLEX_COUNTER_GROUP,
"", // Do not touch poll interval
"",
STATS_MODE_READ,
FLOW_COUNTER_PLUGIN_FIELD,
trapSha);
Expand Down
2 changes: 2 additions & 0 deletions orchagent/debugcounterorch.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "debugcounterorch.h"
#include "flex_counter_manager.h"
#include "portsorch.h"
#include "rediscommand.h"
#include "sai_serialize.h"
Expand Down Expand Up @@ -54,6 +55,7 @@ DebugCounterOrch::DebugCounterOrch(DBConnector *db, const vector<string>& table_

setFlexCounterGroupParameter(DEBUG_DROP_MONITOR_FLEX_COUNTER_GROUP,
DEBUG_DROP_MONITOR_FLEX_COUNTER_POLLING_INTERVAL_MS,
DEBUG_DROP_MONITOR_SECONDARY_POLL_FACTOR,
STATS_MODE_READ,
PORT_PLUGIN_FIELD,
dropMonitorSha);
Expand Down
1 change: 1 addition & 0 deletions orchagent/debugcounterorch.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ extern "C" {
#define DEBUG_COUNTER_FLEX_COUNTER_GROUP "DEBUG_COUNTER"
#define DEBUG_DROP_MONITOR_FLEX_COUNTER_GROUP "DEBUG_MONITOR_COUNTER"
#define DEBUG_DROP_MONITOR_FLEX_COUNTER_POLLING_INTERVAL_MS "60000"
#define DEBUG_DROP_MONITOR_SECONDARY_POLL_FACTOR "0"

using DebugCounterMap = std::unordered_map<std::string, std::unique_ptr<DebugCounter>>;

Expand Down
27 changes: 25 additions & 2 deletions orchagent/flex_counter/flex_counter_manager.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "flex_counter_manager.h"

#include <string>
#include <vector>

#include "schema.h"
Expand Down Expand Up @@ -61,6 +62,7 @@ FlexCounterManager *FlexManagerDirectory::createFlexCounterManager(const string&
const StatsMode stats_mode,
const uint polling_interval,
const bool enabled,
const uint secondary_poll_factor,
FieldValueTuple fv_plugin)
{
if (m_managers.find(group_name) != m_managers.end())
Expand All @@ -77,6 +79,12 @@ FlexCounterManager *FlexManagerDirectory::createFlexCounterManager(const string&
group_name.c_str());
return NULL;
}
if (secondary_poll_factor != m_managers[group_name]->getSecondaryPollFactor())
{
SWSS_LOG_ERROR("Secondary poll factor mismatch with alreasy created flex counter manager %s",
group_name.c_str());
return NULL;
}
if (enabled != m_managers[group_name]->getEnabled())
{
SWSS_LOG_ERROR("Enabled field mismatch with already created flex counter manager %s",
Expand All @@ -86,7 +94,7 @@ FlexCounterManager *FlexManagerDirectory::createFlexCounterManager(const string&
return m_managers[group_name];
}
FlexCounterManager *fc_manager = new FlexCounterManager(group_name, stats_mode, polling_interval,
enabled, fv_plugin);
enabled, secondary_poll_factor, fv_plugin);
m_managers[group_name] = fc_manager;
return fc_manager;
}
Expand All @@ -96,9 +104,10 @@ FlexCounterManager::FlexCounterManager(
const StatsMode stats_mode,
const uint polling_interval,
const bool enabled,
const uint secondary_poll_factor,
FieldValueTuple fv_plugin) :
FlexCounterManager(false, group_name, stats_mode,
polling_interval, enabled, fv_plugin)
polling_interval, secondary_poll_factor, enabled, fv_plugin)
{
}

Expand All @@ -108,10 +117,12 @@ FlexCounterManager::FlexCounterManager(
const StatsMode stats_mode,
const uint polling_interval,
const bool enabled,
const uint secondary_poll_factor,
FieldValueTuple fv_plugin) :
group_name(group_name),
stats_mode(stats_mode),
polling_interval(polling_interval),
secondary_poll_factor(secondary_poll_factor),
enabled(enabled),
fv_plugin(fv_plugin),
is_gearbox(is_gearbox)
Expand Down Expand Up @@ -143,6 +154,7 @@ void FlexCounterManager::applyGroupConfiguration()

setFlexCounterGroupParameter(group_name,
std::to_string(polling_interval),
std::to_string(secondary_poll_factor),
stats_mode_lookup.at(stats_mode),
fvField(fv_plugin),
fvValue(fv_plugin),
Expand All @@ -161,6 +173,17 @@ void FlexCounterManager::updateGroupPollingInterval(
group_name.c_str(), polling_interval);
}

void FlexCounterManager::updateGroupSecondaryPollFactor(
const uint secondary_poll_factor)
{
SWSS_LOG_ENTER();

setFlexCounterGroupSecondaryPollFactor(group_name, std::to_string(secondary_poll_factor), is_gearbox);

SWSS_LOG_DEBUG("Set secondary poll factor for flex counter group '%s' to %d.",
group_name.c_str(), secondary_poll_factor);
}

// enableFlexCounterGroup will do nothing if the flex counter group is already
// enabled.
void FlexCounterManager::enableFlexCounterGroup()
Expand Down
26 changes: 20 additions & 6 deletions orchagent/flex_counter/flex_counter_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ extern "C" {
#include "sai.h"
}

#define FLEX_COUNTER_DEFAULT_SECONDARY_POLL_FACTOR 0

enum class StatsMode
{
READ,
Expand Down Expand Up @@ -63,6 +65,7 @@ class FlexCounterManager
const StatsMode stats_mode,
const uint polling_interval,
const bool enabled,
const uint secondary_poll_factor = 0,
swss::FieldValueTuple fv_plugin = std::make_pair("",""));

FlexCounterManager()
Expand All @@ -74,13 +77,15 @@ class FlexCounterManager
const StatsMode stats_mode,
const uint polling_interval,
const bool enabled,
const uint secondary_poll_factor = 0,
swss::FieldValueTuple fv_plugin = std::make_pair("",""));

FlexCounterManager(const FlexCounterManager&) = delete;
FlexCounterManager& operator=(const FlexCounterManager&) = delete;
virtual ~FlexCounterManager();

void updateGroupPollingInterval(const uint polling_interval);
void updateGroupSecondaryPollFactor(const uint secondary_poll_factor);
void enableFlexCounterGroup();
void disableFlexCounterGroup();

Expand All @@ -106,6 +111,11 @@ class FlexCounterManager
return polling_interval;
}

const uint& getSecondaryPollFactor() const
{
return secondary_poll_factor;
}

const bool& getEnabled() const
{
return enabled;
Expand All @@ -122,6 +132,7 @@ class FlexCounterManager
StatsMode stats_mode;
uint polling_interval;
bool enabled;
uint secondary_poll_factor;
swss::FieldValueTuple fv_plugin;
std::unordered_map<sai_object_id_t, sai_object_id_t> installed_counters;
bool is_gearbox;
Expand Down Expand Up @@ -217,8 +228,9 @@ class FlexCounterCachedManager : public FlexCounterManager
const StatsMode stats_mode,
const uint polling_interval,
const bool enabled,
const uint secondary_poll_factor = 0,
swss::FieldValueTuple fv_plugin = std::make_pair("","")) :
FlexCounterManager(group_name, stats_mode, polling_interval, enabled, fv_plugin)
FlexCounterManager(group_name, stats_mode, polling_interval, enabled, secondary_poll_factor, fv_plugin)
{
}

Expand Down Expand Up @@ -293,8 +305,9 @@ class FlexCounterTaggedCachedManager : public FlexCounterCachedManager
const StatsMode stats_mode,
const uint polling_interval,
const bool enabled,
const uint secondary_poll_factor = 0,
swss::FieldValueTuple fv_plugin = std::make_pair("","")) :
FlexCounterCachedManager(group_name, stats_mode, polling_interval, enabled, fv_plugin)
FlexCounterCachedManager(group_name, stats_mode, polling_interval, enabled, secondary_poll_factor, fv_plugin)
{
}

Expand Down Expand Up @@ -327,15 +340,16 @@ class FlexCounterTaggedCachedManager : public FlexCounterCachedManager

template <typename TagType>
class FlexCounterTaggedCachedManager<TagType, typename std::enable_if_t<std::is_enum<TagType>::value>> : public FlexCounterCachedManager
{
{
public:
FlexCounterTaggedCachedManager(
const std::string& group_name,
const StatsMode stats_mode,
const uint polling_interval,
const bool enabled,
const uint secondary_poll_factor = 0,
swss::FieldValueTuple fv_plugin = std::make_pair("","")) :
FlexCounterCachedManager(group_name, stats_mode, polling_interval, enabled, fv_plugin)
FlexCounterCachedManager(group_name, stats_mode, polling_interval, enabled, secondary_poll_factor, fv_plugin)
{
}

Expand Down Expand Up @@ -375,8 +389,8 @@ class FlexManagerDirectory
{
public:
FlexCounterManager* createFlexCounterManager(const std::string& group_name, const StatsMode stats_mode,
const uint polling_interval, const bool enabled,
swss::FieldValueTuple fv_plugin = std::make_pair("",""));
const uint polling_interval, bool enabled,
const uint secondary_poll_factor = 0, swss::FieldValueTuple fv_plugin = std::make_pair("",""));
private:
std::unordered_map<std::string, FlexCounterManager*> m_managers;
};
Expand Down
14 changes: 14 additions & 0 deletions orchagent/flexcounterorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "portsorch.h"
#include "pfcwdorch.h"
#include "routeorch.h"
#include "schema.h"
#include "srv6orch.h"
#include "switchorch.h"
#include "debugcounterorch.h"
Expand Down Expand Up @@ -202,6 +203,19 @@ void FlexCounterOrch::doTask(Consumer &consumer)
}
}
}
else if (field == SECONDARY_POLL_FACTOR_FIELD)
{
// Only handle FLR_INTERVAL_FACTOR for PORT counter group
if (key == PORT_KEY)
{
setFlexCounterGroupSecondaryPollFactor(flexCounterGroupMap[key], value);

if (gPortsOrch && gPortsOrch->isGearboxEnabled())
{
setFlexCounterGroupSecondaryPollFactor(flexCounterGroupMap[key], value, true);
}
}
}
else if (field == BULK_CHUNK_SIZE_FIELD)
{
bulk_chunk_size = value;
Expand Down
1 change: 1 addition & 0 deletions orchagent/intfsorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ IntfsOrch::IntfsOrch(DBConnector *db, string tableName, VRFOrch *vrf_orch, DBCon

setFlexCounterGroupParameter(RIF_STAT_COUNTER_FLEX_COUNTER_GROUP,
RIF_FLEX_STAT_COUNTER_POLL_MSECS,
RIF_DEFAULT_SECONDARY_POLL_FACTOR,
STATS_MODE_READ,
RIF_PLUGIN_FIELD,
rifRateSha);
Expand Down
1 change: 1 addition & 0 deletions orchagent/intfsorch.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ extern MacAddress gMacAddress;
#define RIF_STAT_COUNTER_FLEX_COUNTER_GROUP "RIF_STAT_COUNTER"
#define RIF_RATE_COUNTER_FLEX_COUNTER_GROUP "RIF_RATE_COUNTER"
#define RIF_FLEX_STAT_COUNTER_POLL_MSECS "1000"
#define RIF_DEFAULT_SECONDARY_POLL_FACTOR "0"

struct IntfsEntry
{
Expand Down
8 changes: 8 additions & 0 deletions orchagent/p4orch/tests/test_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@ int main(int argc, char *argv[])

void setFlexCounterGroupParameter(const std::string &group,
const std::string &poll_interval,
const std::string &secondary_poll_factor,
const std::string &stats_mode,
const std::string &plugin_name,
const std::string &plugins,
Expand Down Expand Up @@ -284,6 +285,13 @@ void setFlexCounterGroupStatsMode(const std::string &group,
return;
}

void setFlexCounterGroupSecondaryPollFactor(const std::string &group,
const std::string &secondary_poll_factor,
bool is_gearbox)
{
return;
}

void delFlexCounterGroup(const std::string &group,
bool is_gearbox)
{
Expand Down
3 changes: 2 additions & 1 deletion orchagent/pfcwdorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include <inttypes.h>
#include <unordered_map>
#include "pfcwdorch.h"
#include "flex_counter_manager.h"
#include "sai_serialize.h"
#include "portsorch.h"
#include "converter.h"
Expand Down Expand Up @@ -719,7 +720,7 @@ PfcWdSwOrch<DropHandler, ForwardHandler>::PfcWdSwOrch(
}

this->m_pfcwdFlexCounterManager = make_shared<FlexCounterTaggedCachedManager<sai_object_type_t>>(
"PFC_WD", StatsMode::READ, m_pollInterval, true, make_pair(QUEUE_PLUGIN_FIELD, plugins));
"PFC_WD", StatsMode::READ, m_pollInterval, true, FLEX_COUNTER_DEFAULT_SECONDARY_POLL_FACTOR, make_pair(QUEUE_PLUGIN_FIELD, plugins));

auto consumer = new swss::NotificationConsumer(
this->getCountersDb().get(),
Expand Down
5 changes: 4 additions & 1 deletion orchagent/port_flr.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ end

local counters_db = ARGV[1]
local counters_table_name = ARGV[2]
local poll_interval = tonumber(ARGV[3]) -- In milli Seconds
local secondary_poll_factor = tonumber(ARGV[4])

local FEC_FLR_POLL_INTERVAL = (poll_interval/1000) * secondary_poll_factor -- In Seconds

local APPL_DB = 0 -- Application database
local COUNTERS_DB = 2 -- Counters and statistics
Expand All @@ -28,7 +32,6 @@ local rates_table_name = "RATES"
local bookmark_table_name = "RATES:GLOBAL"
local BIN_FILTER_VALUE = 10
local MIN_SIGNIFICANT_BINS = 2
local FEC_FLR_POLL_INTERVAL = 120
local MFC = 8

local function get_port_name_from_oid(port)
Expand Down
5 changes: 5 additions & 0 deletions orchagent/portsorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <algorithm>

#include "portsorch.h"
#include "flex_counter_manager.h"
#include "intfsorch.h"
#include "bufferorch.h"
#include "neighorch.h"
Expand Down Expand Up @@ -782,24 +783,28 @@ PortsOrch::PortsOrch(DBConnector *db, DBConnector *stateDb, vector<table_name_wi

setFlexCounterGroupParameter(QUEUE_WATERMARK_STAT_COUNTER_FLEX_COUNTER_GROUP,
QUEUE_WATERMARK_FLEX_STAT_COUNTER_POLL_MSECS,
PORTS_ORCH_DEFAULT_SECONDARY_POLL_FACTOR,
STATS_MODE_READ_AND_CLEAR,
QUEUE_PLUGIN_FIELD,
queueWmSha);

setFlexCounterGroupParameter(PG_WATERMARK_STAT_COUNTER_FLEX_COUNTER_GROUP,
PG_WATERMARK_FLEX_STAT_COUNTER_POLL_MSECS,
PORTS_ORCH_DEFAULT_SECONDARY_POLL_FACTOR,
STATS_MODE_READ_AND_CLEAR,
PG_PLUGIN_FIELD,
pgWmSha);

setFlexCounterGroupParameter(PORT_STAT_COUNTER_FLEX_COUNTER_GROUP,
PORT_RATE_FLEX_COUNTER_POLLING_INTERVAL_MS,
PORTS_ORCH_DEFAULT_SECONDARY_POLL_FACTOR,
STATS_MODE_READ,
PORT_PLUGIN_FIELD,
portStatPlugins);

setFlexCounterGroupParameter(PG_DROP_STAT_COUNTER_FLEX_COUNTER_GROUP,
PG_DROP_FLEX_STAT_COUNTER_POLL_MSECS,
PORTS_ORCH_DEFAULT_SECONDARY_POLL_FACTOR,
STATS_MODE_READ);

/* Get CPU port */
Expand Down
1 change: 1 addition & 0 deletions orchagent/portsorch.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#define PG_WATERMARK_FLEX_STAT_COUNTER_POLL_MSECS "60000"
#define PG_DROP_FLEX_STAT_COUNTER_POLL_MSECS "10000"
#define PORT_RATE_FLEX_COUNTER_POLLING_INTERVAL_MS "1000"
#define PORTS_ORCH_DEFAULT_SECONDARY_POLL_FACTOR "0"
#define WRED_QUEUE_STAT_COUNTER_FLEX_COUNTER_GROUP "WRED_ECN_QUEUE_STAT_COUNTER"
#define WRED_PORT_STAT_COUNTER_FLEX_COUNTER_GROUP "WRED_ECN_PORT_STAT_COUNTER"

Expand Down
Loading
Loading