Skip to content

Commit b4618d6

Browse files
Prabhu SreenivasanPrabhuSreenivasan
Prabhu Sreenivasan
authored andcommitted
[portsorch] CPU Queues support
Signed-off-by: Prabhu Sreenivasan <[email protected]>
1 parent 86e1171 commit b4618d6

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed

orchagent/portsorch.cpp

+36-1
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,7 @@ PortsOrch::PortsOrch(DBConnector *db, vector<table_name_with_pri_t> &tableNames)
288288

289289
m_cpuPort = Port("CPU", Port::CPU);
290290
m_cpuPort.m_port_id = attr.value.oid;
291+
initCpuPort(m_cpuPort);
291292
m_portList[m_cpuPort.m_alias] = m_cpuPort;
292293
m_port_ref_count[m_cpuPort.m_alias] = 0;
293294

@@ -1787,6 +1788,11 @@ sai_status_t PortsOrch::removePort(sai_object_id_t port_id)
17871788
return status;
17881789
}
17891790

1791+
string PortsOrch::getPortFlexCounterTableKey(string key)
1792+
{
1793+
return string(PORT_STAT_COUNTER_FLEX_COUNTER_GROUP) + ":" + key;
1794+
}
1795+
17901796
string PortsOrch::getQueueWatermarkFlexCounterTableKey(string key)
17911797
{
17921798
return string(QUEUE_WATERMARK_STAT_COUNTER_FLEX_COUNTER_GROUP) + ":" + key;
@@ -1871,6 +1877,35 @@ bool PortsOrch::initPort(const string &alias, const int index, const set<int> &l
18711877
return true;
18721878
}
18731879

1880+
void PortsOrch::initCpuPort(Port &cpu_port)
1881+
{
1882+
SWSS_LOG_ENTER();
1883+
1884+
initializeQueues(cpu_port);
1885+
1886+
/* Add port name map to counter table */
1887+
FieldValueTuple tuple(cpu_port.m_alias, sai_serialize_object_id(cpu_port.m_port_id));
1888+
vector<FieldValueTuple> fields;
1889+
fields.push_back(tuple);
1890+
m_counterTable->set("", fields);
1891+
1892+
/* Add port to flex_counter for updating stat counters */
1893+
string key = getPortFlexCounterTableKey(sai_serialize_object_id(cpu_port.m_port_id));
1894+
std::string delimiter = "";
1895+
std::ostringstream counters_stream;
1896+
for (const auto &id: port_stat_ids)
1897+
{
1898+
counters_stream << delimiter << sai_serialize_port_stat(id);
1899+
delimiter = comma;
1900+
}
1901+
1902+
fields.clear();
1903+
fields.emplace_back(PORT_COUNTER_ID_LIST, counters_stream.str());
1904+
1905+
m_flexCounterTable->set(key, fields);
1906+
return;
1907+
}
1908+
18741909
void PortsOrch::deInitPort(string alias, sai_object_id_t port_id)
18751910
{
18761911
SWSS_LOG_ENTER();
@@ -3934,7 +3969,7 @@ void PortsOrch::generateQueueMap()
39343969

39353970
for (const auto& it: m_portList)
39363971
{
3937-
if (it.second.m_type == Port::PHY)
3972+
if ((it.second.m_type == Port::PHY) || (it.second.m_type == Port::CPU))
39383973
{
39393974
generateQueueMapPerPort(it.second);
39403975
}

orchagent/portsorch.h

+1
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,7 @@ class PortsOrch : public Orch, public Subject
235235
bool addPort(const set<int> &lane_set, uint32_t speed, int an=0, string fec="");
236236
sai_status_t removePort(sai_object_id_t port_id);
237237
bool initPort(const string &alias, const int index, const set<int> &lane_set);
238+
void initCpuPort(Port &cpu_port);
238239
void deInitPort(string alias, sai_object_id_t port_id);
239240

240241
bool setPortAdminStatus(Port &port, bool up);

0 commit comments

Comments
 (0)