Skip to content

Commit

Permalink
portsorch: Writing the port name map into the counter table (sonic-ne…
Browse files Browse the repository at this point in the history
  • Loading branch information
stcheng committed Aug 16, 2016
1 parent 7f83a99 commit 744ba86
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
13 changes: 13 additions & 0 deletions orchagent/portsorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "net/if.h"

#include "logger.h"
#include "schema.h"

extern sai_switch_api_t *sai_switch_api;
extern sai_port_api_t *sai_port_api;
Expand All @@ -23,6 +24,10 @@ PortsOrch::PortsOrch(DBConnector *db, vector<string> tableNames) :
{
SWSS_LOG_ENTER();

/* Initialize Counter Table */
DBConnector *counter_db = new DBConnector(COUNTERS_DB, "localhost", 6379, 0);
m_counterTable = new Table(counter_db, COUNTERS_PORT_NAME_MAP);

int i, j;
sai_status_t status;
sai_attribute_t attr;
Expand Down Expand Up @@ -244,6 +249,14 @@ void PortsOrch::doPortTask(Consumer &consumer)
{
/* Add port to port list */
m_portList[alias] = p;
/* Add port name map to counter table */
std::stringstream ss;
ss << hex << p.m_port_id;
FieldValueTuple tuple(p.m_alias, ss.str());
vector<FieldValueTuple> vector;
vector.push_back(tuple);
m_counterTable->set("", vector);

SWSS_LOG_NOTICE("Port is initialized alias:%s\n", alias.c_str());

}
Expand Down
2 changes: 2 additions & 0 deletions orchagent/portsorch.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ class PortsOrch : public Orch
void setPort(string alias, Port port);

private:
Table *m_counterTable;

bool m_initDone = false;
sai_object_id_t m_cpuPort;

Expand Down

0 comments on commit 744ba86

Please sign in to comment.