Skip to content

Commit

Permalink
[portsorch] add buffer drop FC group (#1368)
Browse files Browse the repository at this point in the history
Signed-off-by: Mykola Faryma <mykolaf@mellanox.com>
  • Loading branch information
mykolaf authored Aug 20, 2020
1 parent d5ddb82 commit 2267071
Show file tree
Hide file tree
Showing 3 changed files with 18 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 @@ -22,6 +22,7 @@ unordered_map<string, string> flexCounterGroupMap =
{
{"PORT", PORT_STAT_COUNTER_FLEX_COUNTER_GROUP},
{"PORT_RATES", PORT_RATE_COUNTER_FLEX_COUNTER_GROUP},
{"PORT_BUFFER_DROP", PORT_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
15 changes: 15 additions & 0 deletions orchagent/portsorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ extern BufferOrch *gBufferOrch;
#define MAX_VALID_VLAN_ID 4094

#define PORT_STAT_FLEX_COUNTER_POLLING_INTERVAL_MS 1000
#define PORT_BUFFER_DROP_STAT_POLLING_INTERVAL_MS 60000
#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"
Expand Down Expand Up @@ -145,6 +146,12 @@ const vector<sai_port_stat_t> port_stat_ids =
SAI_PORT_STAT_ETHER_IN_PKTS_128_TO_255_OCTETS,
};

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> queue_stat_ids =
{
SAI_QUEUE_STAT_PACKETS,
Expand Down Expand Up @@ -187,6 +194,7 @@ static char* hostif_vlan_tag[] = {
PortsOrch::PortsOrch(DBConnector *db, vector<table_name_with_pri_t> &tableNames) :
Orch(db, tableNames),
port_stat_manager(PORT_STAT_COUNTER_FLEX_COUNTER_GROUP, StatsMode::READ, PORT_STAT_FLEX_COUNTER_POLLING_INTERVAL_MS, true),
port_buffer_drop_stat_manager(PORT_BUFFER_DROP_STAT_FLEX_COUNTER_GROUP, StatsMode::READ, PORT_BUFFER_DROP_STAT_POLLING_INTERVAL_MS, true),
queue_stat_manager(QUEUE_STAT_COUNTER_FLEX_COUNTER_GROUP, StatsMode::READ, QUEUE_STAT_FLEX_COUNTER_POLLING_INTERVAL_MS, true)
{
SWSS_LOG_ENTER();
Expand Down Expand Up @@ -1845,6 +1853,13 @@ bool PortsOrch::initPort(const string &alias, const int index, const set<int> &l
counter_stats.emplace(sai_serialize_port_stat(it));
}
port_stat_manager.setCounterIdList(p.m_port_id, CounterType::PORT, counter_stats);
std::unordered_set<std::string> port_buffer_drop_stats;
for (const auto& it: port_buffer_drop_stat_ids)
{
port_buffer_drop_stats.emplace(sai_serialize_port_stat(it));
}
port_buffer_drop_stat_manager.setCounterIdList(p.m_port_id, CounterType::PORT, port_buffer_drop_stats);

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 @@ -18,6 +18,7 @@
#define VLAN_TAG_LEN 4
#define PORT_STAT_COUNTER_FLEX_COUNTER_GROUP "PORT_STAT_COUNTER"
#define PORT_RATE_COUNTER_FLEX_COUNTER_GROUP "PORT_RATE_COUNTER"
#define PORT_BUFFER_DROP_STAT_FLEX_COUNTER_GROUP "PORT_BUFFER_DROP_STAT"
#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 @@ -149,6 +150,7 @@ class PortsOrch : public Orch, public Subject
shared_ptr<DBConnector> m_flex_db;

FlexCounterManager port_stat_manager;
FlexCounterManager port_buffer_drop_stat_manager;
FlexCounterManager queue_stat_manager;

std::map<sai_object_id_t, PortSupportedSpeeds> m_portSupportedSpeeds;
Expand Down

0 comments on commit 2267071

Please sign in to comment.