Skip to content

Commit

Permalink
[portsorch] Add buffer drop FC group (sonic-net#1377)
Browse files Browse the repository at this point in the history
Signed-off-by: Mykola Faryma <mykolaf@mellanox.com>
Co-authored-by: Volodymyr Samotiy <volodymyrs@nvidia.com>
  • Loading branch information
mykolaf and volodymyrsamotiy authored Sep 1, 2020
1 parent 2c31941 commit 15a277b
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
1 change: 1 addition & 0 deletions orchagent/flexcounterorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ extern BufferOrch *gBufferOrch;
unordered_map<string, string> flexCounterGroupMap =
{
{"PORT", PORT_STAT_COUNTER_FLEX_COUNTER_GROUP},
{"PORT_BUFFER_DROP", PORT_DROP_STAT_COUNTER_FLEX_COUNTER_GROUP},
{"QUEUE", QUEUE_STAT_COUNTER_FLEX_COUNTER_GROUP},
{"PFCWD", PFC_WD_FLEX_COUNTER_GROUP},
{"QUEUE_WATERMARK", QUEUE_WATERMARK_STAT_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 @@ -42,6 +42,7 @@ extern BufferOrch *gBufferOrch;
#define DEFAULT_VLAN_ID 1
#define MAX_VALID_VLAN_ID 4094
#define PORT_FLEX_STAT_COUNTER_POLL_MSECS "1000"
#define PORT_BUFFER_DROP_STAT_POLLING_INTERVAL_MS "60000"
#define QUEUE_FLEX_STAT_COUNTER_POLL_MSECS "10000"
#define QUEUE_WATERMARK_FLEX_STAT_COUNTER_POLL_MSECS "10000"
#define PG_WATERMARK_FLEX_STAT_COUNTER_POLL_MSECS "10000"
Expand Down Expand Up @@ -113,6 +114,12 @@ const vector<sai_port_stat_t> portStatIds =
SAI_PORT_STAT_ETHER_IN_PKTS_128_TO_255_OCTETS,
};

static const vector<sai_port_stat_t> port_buffer_drop_stat_ids =
{
SAI_PORT_STAT_IN_DROPPED_PKTS,
SAI_PORT_STAT_OUT_DROPPED_PKTS
};

static const vector<sai_queue_stat_t> queueStatIds =
{
SAI_QUEUE_STAT_PACKETS,
Expand Down Expand Up @@ -188,6 +195,12 @@ PortsOrch::PortsOrch(DBConnector *db, vector<table_name_with_pri_t> &tableNames)
fields.emplace_back(STATS_MODE_FIELD, STATS_MODE_READ);
m_flexCounterGroupTable->set(PORT_STAT_COUNTER_FLEX_COUNTER_GROUP, fields);

fields.clear();
fields.emplace_back(POLL_INTERVAL_FIELD, PORT_BUFFER_DROP_STAT_POLLING_INTERVAL_MS);
fields.emplace_back(STATS_MODE_FIELD, STATS_MODE_READ);
m_flexCounterGroupTable->set(PORT_DROP_STAT_COUNTER_FLEX_COUNTER_GROUP, fields);

fields.clear();
fields.emplace_back(POLL_INTERVAL_FIELD, QUEUE_FLEX_STAT_COUNTER_POLL_MSECS);
fields.emplace_back(STATS_MODE_FIELD, STATS_MODE_READ);
m_flexCounterGroupTable->set(QUEUE_STAT_COUNTER_FLEX_COUNTER_GROUP, fields);
Expand Down Expand Up @@ -1484,6 +1497,11 @@ string PortsOrch::getPortFlexCounterTableKey(string key)
return string(PORT_STAT_COUNTER_FLEX_COUNTER_GROUP) + ":" + key;
}

string PortsOrch::getPortBuffDropFlexCounterTableKey(string key)
{
return string(PORT_DROP_STAT_COUNTER_FLEX_COUNTER_GROUP) + ":" + key;
}

string PortsOrch::getQueueFlexCounterTableKey(string key)
{
return string(QUEUE_STAT_COUNTER_FLEX_COUNTER_GROUP) + ":" + key;
Expand Down Expand Up @@ -1547,6 +1565,19 @@ bool PortsOrch::initPort(const string &alias, const set<int> &lane_set)

m_flexCounterTable->set(key, fields);

delimiter = "";
string port_drop_key = getPortBuffDropFlexCounterTableKey(sai_serialize_object_id(p.m_port_id));
std::ostringstream port_buffer_drop_stream;
for (const auto& it: port_buffer_drop_stat_ids)
{
port_buffer_drop_stream << delimiter << sai_serialize_port_stat(it);
delimiter = comma;
}

fields.clear();
fields.emplace_back(PORT_COUNTER_ID_LIST, counters_stream.str());
m_flexCounterTable->set(port_drop_key, fields);

PortUpdate update = {p, true };
notify(SUBJECT_TYPE_PORT_CHANGE, static_cast<void *>(&update));

Expand Down
2 changes: 2 additions & 0 deletions orchagent/portsorch.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#define FCS_LEN 4
#define VLAN_TAG_LEN 4
#define PORT_STAT_COUNTER_FLEX_COUNTER_GROUP "PORT_STAT_COUNTER"
#define PORT_DROP_STAT_COUNTER_FLEX_COUNTER_GROUP "PORT_DROP_STAT_COUNTER"
#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"
Expand Down Expand Up @@ -108,6 +109,7 @@ class PortsOrch : public Orch, public Subject
std::string getQueueFlexCounterTableKey(std::string s);
std::string getQueueWatermarkFlexCounterTableKey(std::string s);
std::string getPortFlexCounterTableKey(std::string s);
std::string getPortBuffDropFlexCounterTableKey(std::string s);
std::string getPriorityGroupWatermarkFlexCounterTableKey(std::string s);

shared_ptr<DBConnector> m_counter_db;
Expand Down

0 comments on commit 15a277b

Please sign in to comment.