@@ -19,6 +19,7 @@ extern sai_buffer_api_t *sai_buffer_api;
19
19
extern PortsOrch *gPortsOrch ;
20
20
extern Directory<Orch*> gDirectory ;
21
21
extern sai_object_id_t gSwitchId ;
22
+ extern string gMySwitchType ;
22
23
23
24
#define BUFFER_POOL_WATERMARK_FLEX_STAT_COUNTER_POLL_MSECS " 60000"
24
25
@@ -103,16 +104,32 @@ void BufferOrch::initBufferReadyLists(DBConnector *applDb, DBConnector *confDb)
103
104
Table pg_table (applDb, APP_BUFFER_PG_TABLE_NAME);
104
105
initBufferReadyList (pg_table, false );
105
106
106
- Table queue_table (applDb, APP_BUFFER_QUEUE_TABLE_NAME);
107
- initBufferReadyList (queue_table, false );
107
+ if (gMySwitchType == " voq" )
108
+ {
109
+ Table queue_table (applDb, APP_BUFFER_QUEUE_TABLE_NAME);
110
+ initVoqBufferReadyList (queue_table, false );
111
+ }
112
+ else
113
+ {
114
+ Table queue_table (applDb, APP_BUFFER_QUEUE_TABLE_NAME);
115
+ initBufferReadyList (queue_table, false );
116
+ }
108
117
}
109
118
else
110
119
{
111
120
Table pg_table (confDb, CFG_BUFFER_PG_TABLE_NAME);
112
121
initBufferReadyList (pg_table, true );
113
122
114
- Table queue_table (confDb, CFG_BUFFER_QUEUE_TABLE_NAME);
115
- initBufferReadyList (queue_table, true );
123
+ if (gMySwitchType == " voq" )
124
+ {
125
+ Table queue_table (confDb, CFG_BUFFER_QUEUE_TABLE_NAME);
126
+ initVoqBufferReadyList (queue_table, true );
127
+ }
128
+ else
129
+ {
130
+ Table queue_table (confDb, CFG_BUFFER_QUEUE_TABLE_NAME);
131
+ initBufferReadyList (queue_table, true );
132
+ }
116
133
}
117
134
}
118
135
@@ -149,6 +166,38 @@ void BufferOrch::initBufferReadyList(Table& table, bool isConfigDb)
149
166
}
150
167
}
151
168
169
+ void BufferOrch::initVoqBufferReadyList (Table& table, bool isConfigDb)
170
+ {
171
+ SWSS_LOG_ENTER ();
172
+
173
+ std::vector<std::string> keys;
174
+ table.getKeys (keys);
175
+
176
+ const char dbKeyDelimiter = (isConfigDb ? config_db_key_delimiter : delimiter);
177
+
178
+ // populate the lists with buffer configuration information
179
+ for (const auto & key: keys)
180
+ {
181
+ auto &&tokens = tokenize (key, dbKeyDelimiter);
182
+ if (tokens.size () != 4 )
183
+ {
184
+ SWSS_LOG_ERROR (" Wrong format of a table '%s' key '%s'. Skip it" , table.getTableName ().c_str (), key.c_str ());
185
+ continue ;
186
+ }
187
+
188
+ // We need transform the key from config db format to appl db format
189
+ auto appldb_key = tokens[0 ] + config_db_key_delimiter + tokens[1 ] + config_db_key_delimiter + tokens[2 ] + delimiter + tokens[3 ];
190
+ m_ready_list[appldb_key] = false ;
191
+
192
+ auto &&port_names = tokenize (tokens[0 ] + config_db_key_delimiter + tokens[1 ] + config_db_key_delimiter + tokens[2 ], list_item_delimiter);
193
+ for (const auto & port_name: port_names)
194
+ {
195
+ SWSS_LOG_INFO (" Item %s has been inserted into ready list" , appldb_key.c_str ());
196
+ m_port_ready_list_ref[port_name].push_back (appldb_key);
197
+ }
198
+ }
199
+ }
200
+
152
201
void BufferOrch::initBufferConstants ()
153
202
{
154
203
sai_status_t status;
@@ -712,7 +761,8 @@ task_process_status BufferOrch::processBufferProfile(KeyOpFieldsValuesTuple &tup
712
761
}
713
762
714
763
/*
715
- Input sample "BUFFER_QUEUE|Ethernet4,Ethernet45|10-15"
764
+ Input sample "BUFFER_QUEUE|Ethernet4,Ethernet45|10-15" or
765
+ "BUFFER_QUEUE|STG01-0101-0400-01T2-LC6|ASIC0|Ethernet4|10-15"
716
766
*/
717
767
task_process_status BufferOrch::processQueue (KeyOpFieldsValuesTuple &tuple)
718
768
{
@@ -727,15 +777,35 @@ task_process_status BufferOrch::processQueue(KeyOpFieldsValuesTuple &tuple)
727
777
728
778
SWSS_LOG_DEBUG (" Processing:%s" , key.c_str ());
729
779
tokens = tokenize (key, delimiter);
730
- if (tokens.size () != 2 )
780
+
781
+ vector<string> port_names;
782
+ if (gMySwitchType == " voq" )
731
783
{
732
- SWSS_LOG_ERROR (" malformed key:%s. Must contain 2 tokens" , key.c_str ());
733
- return task_process_status::task_invalid_entry;
784
+ if (tokens.size () != 4 )
785
+ {
786
+ SWSS_LOG_ERROR (" malformed key:%s. Must contain 4 tokens" , key.c_str ());
787
+ return task_process_status::task_invalid_entry;
788
+ }
789
+
790
+ port_names = tokenize (tokens[0 ] + config_db_key_delimiter + tokens[1 ] + config_db_key_delimiter + tokens[2 ], list_item_delimiter);
791
+ if (!parseIndexRange (tokens[3 ], range_low, range_high))
792
+ {
793
+ return task_process_status::task_invalid_entry;
794
+ }
734
795
}
735
- vector<string> port_names = tokenize (tokens[0 ], list_item_delimiter);
736
- if (!parseIndexRange (tokens[1 ], range_low, range_high))
796
+ else
737
797
{
738
- return task_process_status::task_invalid_entry;
798
+ if (tokens.size () != 2 )
799
+ {
800
+ SWSS_LOG_ERROR (" malformed key:%s. Must contain 2 tokens" , key.c_str ());
801
+ return task_process_status::task_invalid_entry;
802
+ }
803
+
804
+ port_names = tokenize (tokens[0 ], list_item_delimiter);
805
+ if (!parseIndexRange (tokens[1 ], range_low, range_high))
806
+ {
807
+ return task_process_status::task_invalid_entry;
808
+ }
739
809
}
740
810
741
811
if (op == SET_COMMAND)
@@ -792,20 +862,35 @@ task_process_status BufferOrch::processQueue(KeyOpFieldsValuesTuple &tuple)
792
862
for (size_t ind = range_low; ind <= range_high; ind++)
793
863
{
794
864
SWSS_LOG_DEBUG (" processing queue:%zd" , ind);
795
- if (port.m_queue_ids .size () <= ind)
865
+ sai_object_id_t queue_id;
866
+
867
+ if (gMySwitchType == " voq" )
796
868
{
797
- SWSS_LOG_ERROR (" Invalid queue index specified:%zd" , ind);
798
- return task_process_status::task_invalid_entry;
799
- }
800
- if (port.m_queue_lock [ind])
869
+ std :: vector<sai_object_id_t > queue_ids = gPortsOrch ->getPortVoQIds (port);
870
+ if (queue_ids.size () <= ind)
871
+ {
872
+ SWSS_LOG_ERROR (" Invalid voq index specified:%zd" , ind);
873
+ return task_process_status::task_invalid_entry;
874
+ }
875
+ queue_id = queue_ids[ind];
876
+ }
877
+ else
801
878
{
802
- SWSS_LOG_WARN (" Queue %zd on port %s is locked, will retry" , ind, port_name.c_str ());
803
- return task_process_status::task_need_retry;
879
+ if (port.m_queue_ids .size () <= ind)
880
+ {
881
+ SWSS_LOG_ERROR (" Invalid queue index specified:%zd" , ind);
882
+ return task_process_status::task_invalid_entry;
883
+ }
884
+ if (port.m_queue_lock [ind])
885
+ {
886
+ SWSS_LOG_WARN (" Queue %zd on port %s is locked, will retry" , ind, port_name.c_str ());
887
+ return task_process_status::task_need_retry;
888
+ }
889
+ queue_id = port.m_queue_ids [ind];
804
890
}
891
+
805
892
if (need_update_sai)
806
893
{
807
- sai_object_id_t queue_id;
808
- queue_id = port.m_queue_ids [ind];
809
894
SWSS_LOG_DEBUG (" Applying buffer profile:0x%" PRIx64 " to queue index:%zd, queue sai_id:0x%" PRIx64, sai_buffer_profile, ind, queue_id);
810
895
sai_status_t sai_status = sai_queue_api->set_queue_attribute (queue_id, &attr);
811
896
if (sai_status != SAI_STATUS_SUCCESS)
@@ -1258,7 +1343,15 @@ void BufferOrch::doTask(Consumer &consumer)
1258
1343
{
1259
1344
SWSS_LOG_ENTER ();
1260
1345
1261
- if (!gPortsOrch ->isConfigDone ())
1346
+ if (gMySwitchType == " voq" )
1347
+ {
1348
+ if (!gPortsOrch ->isInitDone ())
1349
+ {
1350
+ SWSS_LOG_INFO (" Buffer task for %s can't be executed ahead of port config done" , consumer.getTableName ().c_str ());
1351
+ return ;
1352
+ }
1353
+ }
1354
+ else if (!gPortsOrch ->isConfigDone ())
1262
1355
{
1263
1356
SWSS_LOG_INFO (" Buffer task for %s can't be executed ahead of port config done" , consumer.getTableName ().c_str ());
1264
1357
return ;
0 commit comments