Skip to content

Commit

Permalink
sonic-swss: Code changes for WRED and ECN statistics
Browse files Browse the repository at this point in the history
* New flex counter group for per-Queue WRED and ECN statistics
* New flex counter group for per-Port WRED and ECN statistics

Signed-off-by: rpmarvell <[email protected]>
  • Loading branch information
rpmarvell committed Apr 24, 2023
1 parent 5bedf4e commit 72089a0
Show file tree
Hide file tree
Showing 7 changed files with 352 additions and 0 deletions.
2 changes: 2 additions & 0 deletions orchagent/flex_counter/flex_counter_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ const unordered_map<CounterType, string> FlexCounterManager::counter_id_field_lo
{ CounterType::TUNNEL, TUNNEL_COUNTER_ID_LIST },
{ CounterType::HOSTIF_TRAP, FLOW_COUNTER_ID_LIST },
{ CounterType::ROUTE, FLOW_COUNTER_ID_LIST },
{ CounterType::WRED_ECN_QUEUE, WRED_QUEUE_COUNTER_ID_LIST},
{ CounterType::WRED_ECN_PORT, WRED_PORT_COUNTER_ID_LIST},
};

FlexManagerDirectory g_FlexManagerDirectory;
Expand Down
2 changes: 2 additions & 0 deletions orchagent/flex_counter/flex_counter_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ enum class CounterType
TUNNEL,
HOSTIF_TRAP,
ROUTE,
WRED_ECN_PORT,
WRED_ECN_QUEUE,
};

// FlexCounterManager allows users to manage a group of flex counters.
Expand Down
26 changes: 26 additions & 0 deletions orchagent/flexcounterorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ extern FlowCounterRouteOrch *gFlowCounterRouteOrch;
#define TUNNEL_KEY "TUNNEL"
#define FLOW_CNT_TRAP_KEY "FLOW_CNT_TRAP"
#define FLOW_CNT_ROUTE_KEY "FLOW_CNT_ROUTE"
#define WRED_QUEUE_KEY "WRED_ECN_QUEUE"
#define WRED_PORT_KEY "WRED_ECN_PORT"

unordered_map<string, string> flexCounterGroupMap =
{
Expand All @@ -59,6 +61,8 @@ unordered_map<string, string> flexCounterGroupMap =
{"MACSEC_SA", COUNTERS_MACSEC_SA_GROUP},
{"MACSEC_SA_ATTR", COUNTERS_MACSEC_SA_ATTR_GROUP},
{"MACSEC_FLOW", COUNTERS_MACSEC_FLOW_GROUP},
{"WRED_ECN_PORT", WRED_PORT_STAT_COUNTER_FLEX_COUNTER_GROUP},
{"WRED_ECN_QUEUE", WRED_QUEUE_STAT_COUNTER_FLEX_COUNTER_GROUP},
};


Expand Down Expand Up @@ -184,6 +188,17 @@ void FlexCounterOrch::doTask(Consumer &consumer)
m_pg_watermark_enabled = true;
gPortsOrch->addPriorityGroupWatermarkFlexCounters(getPgConfigurations());
}
else if(key == WRED_PORT_KEY)
{
gPortsOrch->generateWredPortCounterMap();
m_wred_port_counter_enabled = true;
}
else if(key == WRED_QUEUE_KEY)
{
gPortsOrch->generateQueueMap(getQueueConfigurations());
m_wred_queue_counter_enabled = true;
gPortsOrch->addWredQueueFlexCounters(getQueueConfigurations());
}
}
if(gIntfsOrch && (key == RIF_KEY) && (value == "enable"))
{
Expand Down Expand Up @@ -286,6 +301,17 @@ bool FlexCounterOrch::getPgWatermarkCountersState() const
return m_pg_watermark_enabled;
}

bool FlexCounterOrch::getWredQueueCountersState() const
{
return m_wred_queue_counter_enabled;
}

bool FlexCounterOrch::getWredPortCountersState() const
{
return m_wred_port_counter_enabled;
}


bool FlexCounterOrch::bake()
{
/*
Expand Down
4 changes: 4 additions & 0 deletions orchagent/flexcounterorch.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ class FlexCounterOrch: public Orch
std::map<std::string, FlexCounterPgStates> getPgConfigurations();
bool getHostIfTrapCounterState() const {return m_hostif_trap_counter_enabled;}
bool getRouteFlowCountersState() const {return m_route_flow_counter_enabled;}
bool getWredQueueCountersState() const;
bool getWredPortCountersState() const;
bool bake() override;

private:
Expand All @@ -65,6 +67,8 @@ class FlexCounterOrch: public Orch
bool m_pg_watermark_enabled = false;
bool m_hostif_trap_counter_enabled = false;
bool m_route_flow_counter_enabled = false;
bool m_wred_queue_counter_enabled = false;
bool m_wred_port_counter_enabled = false;
Table m_flexCounterConfigTable;
Table m_bufferQueueConfigTable;
Table m_bufferPgConfigTable;
Expand Down
Loading

0 comments on commit 72089a0

Please sign in to comment.