@@ -369,6 +369,8 @@ PortsOrch::PortsOrch(DBConnector *db, DBConnector *stateDb, vector<table_name_wi
369
369
/* Initialize counter table */
370
370
m_counter_db = shared_ptr<DBConnector>(new DBConnector (" COUNTERS_DB" , 0 ));
371
371
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));
372
374
m_counterLagTable = unique_ptr<Table>(new Table (m_counter_db.get (), COUNTERS_LAG_NAME_MAP));
373
375
FieldValueTuple tuple (" " , " " );
374
376
vector<FieldValueTuple> defaultLagFv;
@@ -383,6 +385,7 @@ PortsOrch::PortsOrch(DBConnector *db, DBConnector *stateDb, vector<table_name_wi
383
385
384
386
/* Initialize queue tables */
385
387
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));
386
389
m_queuePortTable = unique_ptr<Table>(new Table (m_counter_db.get (), COUNTERS_QUEUE_PORT_MAP));
387
390
m_queueIndexTable = unique_ptr<Table>(new Table (m_counter_db.get (), COUNTERS_QUEUE_INDEX_MAP));
388
391
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
2465
2468
case SAI_QUEUE_TYPE_MULTICAST:
2466
2469
type = " SAI_QUEUE_TYPE_MULTICAST" ;
2467
2470
break ;
2471
+ case SAI_QUEUE_TYPE_UNICAST_VOQ:
2472
+ type = " SAI_QUEUE_TYPE_UNICAST_VOQ" ;
2473
+ break ;
2468
2474
default :
2469
2475
SWSS_LOG_ERROR (" Got unsupported queue type %d for %" PRIu64 " queue" , attr[0 ].value .s32 , queue_id);
2470
2476
throw runtime_error (" Got unsupported queue type" );
@@ -2797,7 +2803,7 @@ bool PortsOrch::initPort(const string &alias, const string &role, const int inde
2797
2803
/* when a port is added and queue map counter is enabled --> we need to add queue map counter for it */
2798
2804
if (m_isQueueMapGenerated)
2799
2805
{
2800
- generateQueueMapPerPort (p);
2806
+ generateQueueMapPerPort (p, false );
2801
2807
}
2802
2808
2803
2809
PortUpdate update = { p, true };
@@ -4512,6 +4518,51 @@ void PortsOrch::doTask(Consumer &consumer)
4512
4518
}
4513
4519
}
4514
4520
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
+
4515
4566
void PortsOrch::initializeQueues (Port &port)
4516
4567
{
4517
4568
SWSS_LOG_ENTER ();
@@ -5981,7 +6032,16 @@ void PortsOrch::generateQueueMap()
5981
6032
{
5982
6033
if (it.second .m_type == Port::PHY)
5983
6034
{
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 );
5985
6045
}
5986
6046
}
5987
6047
@@ -6026,28 +6086,51 @@ void PortsOrch::removeQueueMapPerPort(const Port& port)
6026
6086
CounterCheckOrch::getInstance ().removePort (port);
6027
6087
}
6028
6088
6029
- void PortsOrch::generateQueueMapPerPort (const Port& port)
6089
+ void PortsOrch::generateQueueMapPerPort (const Port& port, bool voq )
6030
6090
{
6031
6091
/* Create the Queue map in the Counter DB */
6032
6092
/* Add stat counters to flex_counter */
6033
6093
vector<FieldValueTuple> queueVector;
6034
6094
vector<FieldValueTuple> queuePortVector;
6035
6095
vector<FieldValueTuple> queueIndexVector;
6036
6096
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
+ }
6037
6106
6038
- for (size_t queueIndex = 0 ; queueIndex < port. m_queue_ids .size (); ++queueIndex)
6107
+ for (size_t queueIndex = 0 ; queueIndex < queue_ids .size (); ++queueIndex)
6039
6108
{
6040
6109
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
+ }
6042
6118
6043
- const auto id = sai_serialize_object_id (port. m_queue_ids [queueIndex]);
6119
+ const auto id = sai_serialize_object_id (queue_ids [queueIndex]);
6044
6120
6045
6121
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
+ }
6047
6130
6048
6131
string queueType;
6049
6132
uint8_t queueRealIndex = 0 ;
6050
- if (getQueueTypeAndIndex (port. m_queue_ids [queueIndex], queueType, queueRealIndex))
6133
+ if (getQueueTypeAndIndex (queue_ids [queueIndex], queueType, queueRealIndex))
6051
6134
{
6052
6135
queueTypeVector.emplace_back (id, queueType);
6053
6136
queueIndexVector.emplace_back (id, to_string (queueRealIndex));
@@ -6059,7 +6142,11 @@ void PortsOrch::generateQueueMapPerPort(const Port& port)
6059
6142
{
6060
6143
counter_stats.emplace (sai_serialize_queue_stat (it));
6061
6144
}
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
+ }
6063
6150
6064
6151
/* add watermark queue counters */
6065
6152
string key = getQueueWatermarkFlexCounterTableKey (id);
@@ -6078,7 +6165,14 @@ void PortsOrch::generateQueueMapPerPort(const Port& port)
6078
6165
m_flexCounterTable->set (key, fieldValues);
6079
6166
}
6080
6167
6081
- m_queueTable->set (" " , queueVector);
6168
+ if (voq)
6169
+ {
6170
+ m_voqTable->set (" " , queueVector);
6171
+ }
6172
+ else
6173
+ {
6174
+ m_queueTable->set (" " , queueVector);
6175
+ }
6082
6176
m_queuePortTable->set (" " , queuePortVector);
6083
6177
m_queueIndexTable->set (" " , queueIndexVector);
6084
6178
m_queueTypeTable->set (" " , queueTypeVector);
@@ -7361,7 +7455,14 @@ bool PortsOrch::addSystemPorts()
7361
7455
port.m_system_port_info .speed = attrs[1 ].value .sysportconfig .speed ;
7362
7456
port.m_system_port_info .num_voq = attrs[1 ].value .sysportconfig .num_voq ;
7363
7457
7458
+ initializeVoqs ( port );
7364
7459
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);
7365
7466
if (m_port_ref_count.find (port.m_alias ) == m_port_ref_count.end ())
7366
7467
{
7367
7468
m_port_ref_count[port.m_alias ] = 0 ;
0 commit comments