@@ -369,6 +369,8 @@ PortsOrch::PortsOrch(DBConnector *db, DBConnector *stateDb, vector<table_name_wi
369369 /* Initialize counter table */
370370 m_counter_db = shared_ptr<DBConnector>(new DBConnector (" COUNTERS_DB" , 0 ));
371371 m_counterTable = unique_ptr<Table>(new Table (m_counter_db.get (), COUNTERS_PORT_NAME_MAP));
372+ m_counterSysPortTable = unique_ptr<Table>(
373+ new Table (m_counter_db.get (), COUNTERS_SYSTEM_PORT_NAME_MAP));
372374 m_counterLagTable = unique_ptr<Table>(new Table (m_counter_db.get (), COUNTERS_LAG_NAME_MAP));
373375 FieldValueTuple tuple (" " , " " );
374376 vector<FieldValueTuple> defaultLagFv;
@@ -383,6 +385,7 @@ PortsOrch::PortsOrch(DBConnector *db, DBConnector *stateDb, vector<table_name_wi
383385
384386 /* Initialize queue tables */
385387 m_queueTable = unique_ptr<Table>(new Table (m_counter_db.get (), COUNTERS_QUEUE_NAME_MAP));
388+ m_voqTable = unique_ptr<Table>(new Table (m_counter_db.get (), COUNTERS_VOQ_NAME_MAP));
386389 m_queuePortTable = unique_ptr<Table>(new Table (m_counter_db.get (), COUNTERS_QUEUE_PORT_MAP));
387390 m_queueIndexTable = unique_ptr<Table>(new Table (m_counter_db.get (), COUNTERS_QUEUE_INDEX_MAP));
388391 m_queueTypeTable = unique_ptr<Table>(new Table (m_counter_db.get (), COUNTERS_QUEUE_TYPE_MAP));
@@ -2465,6 +2468,9 @@ bool PortsOrch::getQueueTypeAndIndex(sai_object_id_t queue_id, string &type, uin
24652468 case SAI_QUEUE_TYPE_MULTICAST:
24662469 type = " SAI_QUEUE_TYPE_MULTICAST" ;
24672470 break ;
2471+ case SAI_QUEUE_TYPE_UNICAST_VOQ:
2472+ type = " SAI_QUEUE_TYPE_UNICAST_VOQ" ;
2473+ break ;
24682474 default :
24692475 SWSS_LOG_ERROR (" Got unsupported queue type %d for %" PRIu64 " queue" , attr[0 ].value .s32 , queue_id);
24702476 throw runtime_error (" Got unsupported queue type" );
@@ -2797,7 +2803,7 @@ bool PortsOrch::initPort(const string &alias, const string &role, const int inde
27972803 /* when a port is added and queue map counter is enabled --> we need to add queue map counter for it */
27982804 if (m_isQueueMapGenerated)
27992805 {
2800- generateQueueMapPerPort (p);
2806+ generateQueueMapPerPort (p, false );
28012807 }
28022808
28032809 PortUpdate update = { p, true };
@@ -4512,6 +4518,51 @@ void PortsOrch::doTask(Consumer &consumer)
45124518 }
45134519}
45144520
4521+ void PortsOrch::initializeVoqs (Port &port)
4522+ {
4523+ SWSS_LOG_ENTER ();
4524+
4525+ sai_attribute_t attr;
4526+ attr.id = SAI_SYSTEM_PORT_ATTR_QOS_NUMBER_OF_VOQS;
4527+ sai_status_t status = sai_system_port_api->get_system_port_attribute (
4528+ port.m_system_port_oid , 1 , &attr);
4529+ if (status != SAI_STATUS_SUCCESS)
4530+ {
4531+ SWSS_LOG_ERROR (" Failed to get number of voqs for port %s rv:%d" , port.m_alias .c_str (), status);
4532+ task_process_status handle_status = handleSaiGetStatus (SAI_API_PORT, status);
4533+ if (handle_status != task_process_status::task_success)
4534+ {
4535+ throw runtime_error (" PortsOrch initialization failure." );
4536+ }
4537+ }
4538+ SWSS_LOG_INFO (" Get %d voq for port %s" , attr.value .u32 , port.m_alias .c_str ());
4539+
4540+ m_port_voq_ids[port.m_alias ] = std::vector<sai_object_id_t >( attr.value .u32 );
4541+
4542+ if (attr.value .u32 == 0 )
4543+ {
4544+ return ;
4545+ }
4546+
4547+ attr.id = SAI_SYSTEM_PORT_ATTR_QOS_VOQ_LIST;
4548+ attr.value .objlist .count = (uint32_t ) m_port_voq_ids[port.m_alias ].size ();
4549+ attr.value .objlist .list = m_port_voq_ids[port.m_alias ].data ();
4550+
4551+ status = sai_system_port_api->get_system_port_attribute (
4552+ port.m_system_port_oid , 1 , &attr);
4553+ if (status != SAI_STATUS_SUCCESS)
4554+ {
4555+ SWSS_LOG_ERROR (" Failed to get voq list for port %s rv:%d" , port.m_alias .c_str (), status);
4556+ task_process_status handle_status = handleSaiGetStatus (SAI_API_PORT, status);
4557+ if (handle_status != task_process_status::task_success)
4558+ {
4559+ throw runtime_error (" PortsOrch initialization failure." );
4560+ }
4561+ }
4562+
4563+ SWSS_LOG_INFO (" Get voqs for port %s" , port.m_alias .c_str ());
4564+ }
4565+
45154566void PortsOrch::initializeQueues (Port &port)
45164567{
45174568 SWSS_LOG_ENTER ();
@@ -5981,7 +6032,16 @@ void PortsOrch::generateQueueMap()
59816032 {
59826033 if (it.second .m_type == Port::PHY)
59836034 {
5984- generateQueueMapPerPort (it.second );
6035+ generateQueueMapPerPort (it.second , false );
6036+ if (gMySwitchType == " voq" )
6037+ {
6038+ generateQueueMapPerPort (it.second , true );
6039+ }
6040+ }
6041+
6042+ if (it.second .m_type == Port::SYSTEM)
6043+ {
6044+ generateQueueMapPerPort (it.second , true );
59856045 }
59866046 }
59876047
@@ -6026,28 +6086,51 @@ void PortsOrch::removeQueueMapPerPort(const Port& port)
60266086 CounterCheckOrch::getInstance ().removePort (port);
60276087}
60286088
6029- void PortsOrch::generateQueueMapPerPort (const Port& port)
6089+ void PortsOrch::generateQueueMapPerPort (const Port& port, bool voq )
60306090{
60316091 /* Create the Queue map in the Counter DB */
60326092 /* Add stat counters to flex_counter */
60336093 vector<FieldValueTuple> queueVector;
60346094 vector<FieldValueTuple> queuePortVector;
60356095 vector<FieldValueTuple> queueIndexVector;
60366096 vector<FieldValueTuple> queueTypeVector;
6097+ std::vector<sai_object_id_t > queue_ids;
6098+ if (voq)
6099+ {
6100+ queue_ids = m_port_voq_ids[port.m_alias ];
6101+ }
6102+ else
6103+ {
6104+ queue_ids = port.m_queue_ids ;
6105+ }
60376106
6038- for (size_t queueIndex = 0 ; queueIndex < port. m_queue_ids .size (); ++queueIndex)
6107+ for (size_t queueIndex = 0 ; queueIndex < queue_ids .size (); ++queueIndex)
60396108 {
60406109 std::ostringstream name;
6041- name << port.m_alias << " :" << queueIndex;
6110+ if (voq)
6111+ {
6112+ name << port.m_system_port_info .alias << " :" << queueIndex;
6113+ }
6114+ else
6115+ {
6116+ name << port.m_alias << " :" << queueIndex;
6117+ }
60426118
6043- const auto id = sai_serialize_object_id (port. m_queue_ids [queueIndex]);
6119+ const auto id = sai_serialize_object_id (queue_ids [queueIndex]);
60446120
60456121 queueVector.emplace_back (name.str (), id);
6046- queuePortVector.emplace_back (id, sai_serialize_object_id (port.m_port_id ));
6122+ if (voq)
6123+ {
6124+ queuePortVector.emplace_back (id, sai_serialize_object_id (port.m_system_port_oid ));
6125+ }
6126+ else
6127+ {
6128+ queuePortVector.emplace_back (id, sai_serialize_object_id (port.m_port_id ));
6129+ }
60476130
60486131 string queueType;
60496132 uint8_t queueRealIndex = 0 ;
6050- if (getQueueTypeAndIndex (port. m_queue_ids [queueIndex], queueType, queueRealIndex))
6133+ if (getQueueTypeAndIndex (queue_ids [queueIndex], queueType, queueRealIndex))
60516134 {
60526135 queueTypeVector.emplace_back (id, queueType);
60536136 queueIndexVector.emplace_back (id, to_string (queueRealIndex));
@@ -6059,7 +6142,11 @@ void PortsOrch::generateQueueMapPerPort(const Port& port)
60596142 {
60606143 counter_stats.emplace (sai_serialize_queue_stat (it));
60616144 }
6062- queue_stat_manager.setCounterIdList (port.m_queue_ids [queueIndex], CounterType::QUEUE, counter_stats);
6145+ queue_stat_manager.setCounterIdList (queue_ids[queueIndex], CounterType::QUEUE, counter_stats);
6146+
6147+ if (voq) {
6148+ continue ;
6149+ }
60636150
60646151 /* add watermark queue counters */
60656152 string key = getQueueWatermarkFlexCounterTableKey (id);
@@ -6078,7 +6165,14 @@ void PortsOrch::generateQueueMapPerPort(const Port& port)
60786165 m_flexCounterTable->set (key, fieldValues);
60796166 }
60806167
6081- m_queueTable->set (" " , queueVector);
6168+ if (voq)
6169+ {
6170+ m_voqTable->set (" " , queueVector);
6171+ }
6172+ else
6173+ {
6174+ m_queueTable->set (" " , queueVector);
6175+ }
60826176 m_queuePortTable->set (" " , queuePortVector);
60836177 m_queueIndexTable->set (" " , queueIndexVector);
60846178 m_queueTypeTable->set (" " , queueTypeVector);
@@ -7361,7 +7455,14 @@ bool PortsOrch::addSystemPorts()
73617455 port.m_system_port_info .speed = attrs[1 ].value .sysportconfig .speed ;
73627456 port.m_system_port_info .num_voq = attrs[1 ].value .sysportconfig .num_voq ;
73637457
7458+ initializeVoqs ( port );
73647459 setPort (port.m_alias , port);
7460+ /* Add system port name map to counter table */
7461+ FieldValueTuple tuple (port.m_system_port_info .alias ,
7462+ sai_serialize_object_id (system_port_oid));
7463+ vector<FieldValueTuple> fields;
7464+ fields.push_back (tuple);
7465+ m_counterSysPortTable->set (" " , fields);
73657466 if (m_port_ref_count.find (port.m_alias ) == m_port_ref_count.end ())
73667467 {
73677468 m_port_ref_count[port.m_alias ] = 0 ;
0 commit comments