Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[portsorch] CPU port queues support #1544

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 36 additions & 1 deletion orchagent/portsorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,7 @@ PortsOrch::PortsOrch(DBConnector *db, vector<table_name_with_pri_t> &tableNames)

m_cpuPort = Port("CPU", Port::CPU);
m_cpuPort.m_port_id = attr.value.oid;
initCpuPort(m_cpuPort);
m_portList[m_cpuPort.m_alias] = m_cpuPort;
m_port_ref_count[m_cpuPort.m_alias] = 0;

Expand Down Expand Up @@ -1787,6 +1788,11 @@ sai_status_t PortsOrch::removePort(sai_object_id_t port_id)
return status;
}

string PortsOrch::getPortFlexCounterTableKey(string key)
{
return string(PORT_STAT_COUNTER_FLEX_COUNTER_GROUP) + ":" + key;
}

string PortsOrch::getQueueWatermarkFlexCounterTableKey(string key)
{
return string(QUEUE_WATERMARK_STAT_COUNTER_FLEX_COUNTER_GROUP) + ":" + key;
Expand Down Expand Up @@ -1871,6 +1877,35 @@ bool PortsOrch::initPort(const string &alias, const int index, const set<int> &l
return true;
}

void PortsOrch::initCpuPort(Port &cpu_port)
{
SWSS_LOG_ENTER();

initializeQueues(cpu_port);

/* Add port name map to counter table */
FieldValueTuple tuple(cpu_port.m_alias, sai_serialize_object_id(cpu_port.m_port_id));
vector<FieldValueTuple> fields;
fields.push_back(tuple);
m_counterTable->set("", fields);

/* Add port to flex_counter for updating stat counters */
string key = getPortFlexCounterTableKey(sai_serialize_object_id(cpu_port.m_port_id));
std::string delimiter = "";
std::ostringstream counters_stream;
for (const auto &id: port_stat_ids)
{
counters_stream << delimiter << sai_serialize_port_stat(id);
delimiter = comma;
}

fields.clear();
fields.emplace_back(PORT_COUNTER_ID_LIST, counters_stream.str());

m_flexCounterTable->set(key, fields);
return;
}

void PortsOrch::deInitPort(string alias, sai_object_id_t port_id)
{
SWSS_LOG_ENTER();
Expand Down Expand Up @@ -3934,7 +3969,7 @@ void PortsOrch::generateQueueMap()

for (const auto& it: m_portList)
{
if (it.second.m_type == Port::PHY)
if ((it.second.m_type == Port::PHY) || (it.second.m_type == Port::CPU))
{
generateQueueMapPerPort(it.second);
}
Expand Down
2 changes: 2 additions & 0 deletions orchagent/portsorch.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ class PortsOrch : public Orch, public Subject
unique_ptr<ProducerTable> m_flexCounterGroupTable;

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

Expand Down Expand Up @@ -235,6 +236,7 @@ class PortsOrch : public Orch, public Subject
bool addPort(const set<int> &lane_set, uint32_t speed, int an=0, string fec="");
sai_status_t removePort(sai_object_id_t port_id);
bool initPort(const string &alias, const int index, const set<int> &lane_set);
void initCpuPort(Port &cpu_port);
void deInitPort(string alias, sai_object_id_t port_id);

bool setPortAdminStatus(Port &port, bool up);
Expand Down