Skip to content

Commit

Permalink
Add SAI_INGRESS_PRIORITY_GROUP_STAT_DROPPED_PACKETS counter, create n…
Browse files Browse the repository at this point in the history
…ew FlexCounter group

Signed-off-by: Andriy Yurkiv <[email protected]>
  • Loading branch information
ayurkiv-nvda committed Jan 26, 2021
1 parent 36f7332 commit f267cbc
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 1 deletion.
1 change: 1 addition & 0 deletions orchagent/flexcounterorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ unordered_map<string, string> flexCounterGroupMap =
{"PFCWD", PFC_WD_FLEX_COUNTER_GROUP},
{"QUEUE_WATERMARK", QUEUE_WATERMARK_STAT_COUNTER_FLEX_COUNTER_GROUP},
{"PG_WATERMARK", PG_WATERMARK_STAT_COUNTER_FLEX_COUNTER_GROUP},
{"PG_DROP", PG_DROP_STAT_COUNTER_FLEX_COUNTER_GROUP},
{BUFFER_POOL_WATERMARK_KEY, BUFFER_POOL_WATERMARK_STAT_COUNTER_FLEX_COUNTER_GROUP},
{"RIF", RIF_STAT_COUNTER_FLEX_COUNTER_GROUP},
{"RIF_RATES", RIF_RATE_COUNTER_FLEX_COUNTER_GROUP},
Expand Down
31 changes: 31 additions & 0 deletions orchagent/portsorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ extern Directory<Orch*> gDirectory;
#define QUEUE_STAT_FLEX_COUNTER_POLLING_INTERVAL_MS 10000
#define QUEUE_WATERMARK_FLEX_STAT_COUNTER_POLL_MSECS "10000"
#define PG_WATERMARK_FLEX_STAT_COUNTER_POLL_MSECS "10000"
#define PG_DROP_FLEX_STAT_COUNTER_POLL_MSECS "10000"
#define PORT_RATE_FLEX_COUNTER_POLLING_INTERVAL_MS "1000"


Expand Down Expand Up @@ -198,6 +199,11 @@ static const vector<sai_ingress_priority_group_stat_t> ingressPriorityGroupWater
SAI_INGRESS_PRIORITY_GROUP_STAT_SHARED_WATERMARK_BYTES,
};

static const vector<sai_ingress_priority_group_stat_t> ingressPriorityGroupDropStatIds =
{
SAI_INGRESS_PRIORITY_GROUP_STAT_DROPPED_PACKETS
};

static char* hostif_vlan_tag[] = {
[SAI_HOSTIF_VLAN_TAG_STRIP] = "SAI_HOSTIF_VLAN_TAG_STRIP",
[SAI_HOSTIF_VLAN_TAG_KEEP] = "SAI_HOSTIF_VLAN_TAG_KEEP",
Expand Down Expand Up @@ -291,6 +297,11 @@ PortsOrch::PortsOrch(DBConnector *db, vector<table_name_with_pri_t> &tableNames)
fieldValues.emplace_back(POLL_INTERVAL_FIELD, PORT_RATE_FLEX_COUNTER_POLLING_INTERVAL_MS);
fieldValues.emplace_back(STATS_MODE_FIELD, STATS_MODE_READ);
m_flexCounterGroupTable->set(PORT_STAT_COUNTER_FLEX_COUNTER_GROUP, fieldValues);

fieldValues.clear();
fieldValues.emplace_back(POLL_INTERVAL_FIELD, PG_DROP_FLEX_STAT_COUNTER_POLL_MSECS);
fieldValues.emplace_back(STATS_MODE_FIELD, STATS_MODE_READ);
m_flexCounterGroupTable->set(PG_DROP_STAT_COUNTER_FLEX_COUNTER_GROUP, fieldValues);
}
catch (const runtime_error &e)
{
Expand Down Expand Up @@ -1852,6 +1863,11 @@ string PortsOrch::getPriorityGroupWatermarkFlexCounterTableKey(string key)
return string(PG_WATERMARK_STAT_COUNTER_FLEX_COUNTER_GROUP) + ":" + key;
}

string PortsOrch::getPriorityGroupDropPacketsFlexCounterTableKey(string key)
{
return string(PG_DROP_STAT_COUNTER_FLEX_COUNTER_GROUP) + ":" + key;
}

bool PortsOrch::initPort(const string &alias, const int index, const set<int> &lane_set)
{
SWSS_LOG_ENTER();
Expand Down Expand Up @@ -4158,7 +4174,22 @@ void PortsOrch::generatePriorityGroupMapPerPort(const Port& port)

vector<FieldValueTuple> fieldValues;
fieldValues.emplace_back(PG_COUNTER_ID_LIST, counters_stream.str());
m_flexCounterTable->set(key, fieldValues);

delimiter = "";
std::ostringstream ingress_pg_drop_packets_counters_stream;
key = getPriorityGroupDropPacketsFlexCounterTableKey(id);
/* Add dropped packets counters to flex_counter */
for (const auto& it: ingressPriorityGroupDropStatIds)
{
ingress_pg_drop_packets_counters_stream << delimiter << sai_serialize_ingress_priority_group_stat(it);
if (delimiter.empty())
{
delimiter = comma;
}
}
fieldValues.clear();
fieldValues.emplace_back(PG_COUNTER_ID_LIST, ingress_pg_drop_packets_counters_stream.str());
m_flexCounterTable->set(key, fieldValues);
}

Expand Down
3 changes: 2 additions & 1 deletion orchagent/portsorch.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#define QUEUE_STAT_COUNTER_FLEX_COUNTER_GROUP "QUEUE_STAT_COUNTER"
#define QUEUE_WATERMARK_STAT_COUNTER_FLEX_COUNTER_GROUP "QUEUE_WATERMARK_STAT_COUNTER"
#define PG_WATERMARK_STAT_COUNTER_FLEX_COUNTER_GROUP "PG_WATERMARK_STAT_COUNTER"

#define PG_DROP_STAT_COUNTER_FLEX_COUNTER_GROUP "PG_DROP_STAT_COUNTER"

typedef std::vector<sai_uint32_t> PortSupportedSpeeds;

Expand Down Expand Up @@ -155,6 +155,7 @@ class PortsOrch : public Orch, public Subject

std::string getQueueWatermarkFlexCounterTableKey(std::string s);
std::string getPriorityGroupWatermarkFlexCounterTableKey(std::string s);
std::string getPriorityGroupDropPacketsFlexCounterTableKey(std::string s);
std::string getPortRateFlexCounterTableKey(std::string s);

shared_ptr<DBConnector> m_counter_db;
Expand Down

0 comments on commit f267cbc

Please sign in to comment.