@@ -210,6 +210,15 @@ bool BufferOrch::isPortReady(const std::string& port_name) const
210
210
return result;
211
211
}
212
212
213
+ void BufferOrch::clearBufferPoolWatermarkCounterIdList (const sai_object_id_t object_id)
214
+ {
215
+ if (m_isBufferPoolWatermarkCounterIdListGenerated)
216
+ {
217
+ string key = BUFFER_POOL_WATERMARK_STAT_COUNTER_FLEX_COUNTER_GROUP " :" + sai_serialize_object_id (object_id);
218
+ m_flexCounterTable->del (key);
219
+ }
220
+ }
221
+
213
222
void BufferOrch::generateBufferPoolWatermarkCounterIdList (void )
214
223
{
215
224
// This function will be called in FlexCounterOrch when field:value tuple "FLEX_COUNTER_STATUS":"enable"
@@ -460,6 +469,7 @@ task_process_status BufferOrch::processBufferPool(KeyOpFieldsValuesTuple &tuple)
460
469
461
470
if (SAI_NULL_OBJECT_ID != sai_object)
462
471
{
472
+ clearBufferPoolWatermarkCounterIdList (sai_object);
463
473
sai_status = sai_buffer_api->remove_buffer_pool (sai_object);
464
474
if (SAI_STATUS_SUCCESS != sai_status)
465
475
{
@@ -699,6 +709,7 @@ task_process_status BufferOrch::processQueue(KeyOpFieldsValuesTuple &tuple)
699
709
string op = kfvOp (tuple);
700
710
vector<string> tokens;
701
711
sai_uint32_t range_low, range_high;
712
+ bool need_update_sai = true ;
702
713
703
714
SWSS_LOG_DEBUG (" Processing:%s" , key.c_str ());
704
715
tokens = tokenize (key, delimiter);
@@ -736,6 +747,12 @@ task_process_status BufferOrch::processQueue(KeyOpFieldsValuesTuple &tuple)
736
747
}
737
748
else if (op == DEL_COMMAND)
738
749
{
750
+ auto &typemap = (*m_buffer_type_maps[APP_BUFFER_QUEUE_TABLE_NAME]);
751
+ if (typemap.find (key) == typemap.end ())
752
+ {
753
+ SWSS_LOG_INFO (" %s doesn't not exist, don't need to notfiy SAI" , key.c_str ());
754
+ need_update_sai = false ;
755
+ }
739
756
sai_buffer_profile = SAI_NULL_OBJECT_ID;
740
757
SWSS_LOG_NOTICE (" Remove buffer queue %s" , key.c_str ());
741
758
removeObject (m_buffer_type_maps, APP_BUFFER_QUEUE_TABLE_NAME, key);
@@ -760,7 +777,6 @@ task_process_status BufferOrch::processQueue(KeyOpFieldsValuesTuple &tuple)
760
777
}
761
778
for (size_t ind = range_low; ind <= range_high; ind++)
762
779
{
763
- sai_object_id_t queue_id;
764
780
SWSS_LOG_DEBUG (" processing queue:%zd" , ind);
765
781
if (port.m_queue_ids .size () <= ind)
766
782
{
@@ -772,16 +788,20 @@ task_process_status BufferOrch::processQueue(KeyOpFieldsValuesTuple &tuple)
772
788
SWSS_LOG_WARN (" Queue %zd on port %s is locked, will retry" , ind, port_name.c_str ());
773
789
return task_process_status::task_need_retry;
774
790
}
775
- queue_id = port.m_queue_ids [ind];
776
- SWSS_LOG_DEBUG (" Applying buffer profile:0x%" PRIx64 " to queue index:%zd, queue sai_id:0x%" PRIx64, sai_buffer_profile, ind, queue_id);
777
- sai_status_t sai_status = sai_queue_api->set_queue_attribute (queue_id, &attr);
778
- if (sai_status != SAI_STATUS_SUCCESS)
791
+ if (need_update_sai)
779
792
{
780
- SWSS_LOG_ERROR (" Failed to set queue's buffer profile attribute, status:%d" , sai_status);
781
- task_process_status handle_status = handleSaiSetStatus (SAI_API_QUEUE, sai_status);
782
- if (handle_status != task_process_status::task_success)
793
+ sai_object_id_t queue_id;
794
+ queue_id = port.m_queue_ids [ind];
795
+ SWSS_LOG_DEBUG (" Applying buffer profile:0x%" PRIx64 " to queue index:%zd, queue sai_id:0x%" PRIx64, sai_buffer_profile, ind, queue_id);
796
+ sai_status_t sai_status = sai_queue_api->set_queue_attribute (queue_id, &attr);
797
+ if (sai_status != SAI_STATUS_SUCCESS)
783
798
{
784
- return handle_status;
799
+ SWSS_LOG_ERROR (" Failed to set queue's buffer profile attribute, status:%d" , sai_status);
800
+ task_process_status handle_status = handleSaiSetStatus (SAI_API_QUEUE, sai_status);
801
+ if (handle_status != task_process_status::task_success)
802
+ {
803
+ return handle_status;
804
+ }
785
805
}
786
806
}
787
807
}
@@ -823,6 +843,7 @@ task_process_status BufferOrch::processPriorityGroup(KeyOpFieldsValuesTuple &tup
823
843
string op = kfvOp (tuple);
824
844
vector<string> tokens;
825
845
sai_uint32_t range_low, range_high;
846
+ bool need_update_sai = true ;
826
847
827
848
SWSS_LOG_DEBUG (" processing:%s" , key.c_str ());
828
849
tokens = tokenize (key, delimiter);
@@ -861,6 +882,12 @@ task_process_status BufferOrch::processPriorityGroup(KeyOpFieldsValuesTuple &tup
861
882
}
862
883
else if (op == DEL_COMMAND)
863
884
{
885
+ auto &typemap = (*m_buffer_type_maps[APP_BUFFER_PG_TABLE_NAME]);
886
+ if (typemap.find (key) == typemap.end ())
887
+ {
888
+ SWSS_LOG_INFO (" %s doesn't not exist, don't need to notfiy SAI" , key.c_str ());
889
+ need_update_sai = false ;
890
+ }
864
891
sai_buffer_profile = SAI_NULL_OBJECT_ID;
865
892
SWSS_LOG_NOTICE (" Remove buffer PG %s" , key.c_str ());
866
893
removeObject (m_buffer_type_maps, APP_BUFFER_PG_TABLE_NAME, key);
@@ -886,7 +913,6 @@ task_process_status BufferOrch::processPriorityGroup(KeyOpFieldsValuesTuple &tup
886
913
}
887
914
for (size_t ind = range_low; ind <= range_high; ind++)
888
915
{
889
- sai_object_id_t pg_id;
890
916
SWSS_LOG_DEBUG (" processing pg:%zd" , ind);
891
917
if (port.m_priority_group_ids .size () <= ind)
892
918
{
@@ -901,16 +927,20 @@ task_process_status BufferOrch::processPriorityGroup(KeyOpFieldsValuesTuple &tup
901
927
}
902
928
else
903
929
{
904
- pg_id = port.m_priority_group_ids [ind];
905
- SWSS_LOG_DEBUG (" Applying buffer profile:0x%" PRIx64 " to port:%s pg index:%zd, pg sai_id:0x%" PRIx64, sai_buffer_profile, port_name.c_str (), ind, pg_id);
906
- sai_status_t sai_status = sai_buffer_api->set_ingress_priority_group_attribute (pg_id, &attr);
907
- if (sai_status != SAI_STATUS_SUCCESS)
930
+ if (need_update_sai)
908
931
{
909
- SWSS_LOG_ERROR (" Failed to set port:%s pg:%zd buffer profile attribute, status:%d" , port_name.c_str (), ind, sai_status);
910
- task_process_status handle_status = handleSaiSetStatus (SAI_API_BUFFER, sai_status);
911
- if (handle_status != task_process_status::task_success)
932
+ sai_object_id_t pg_id;
933
+ pg_id = port.m_priority_group_ids [ind];
934
+ SWSS_LOG_DEBUG (" Applying buffer profile:0x%" PRIx64 " to port:%s pg index:%zd, pg sai_id:0x%" PRIx64, sai_buffer_profile, port_name.c_str (), ind, pg_id);
935
+ sai_status_t sai_status = sai_buffer_api->set_ingress_priority_group_attribute (pg_id, &attr);
936
+ if (sai_status != SAI_STATUS_SUCCESS)
912
937
{
913
- return handle_status;
938
+ SWSS_LOG_ERROR (" Failed to set port:%s pg:%zd buffer profile attribute, status:%d" , port_name.c_str (), ind, sai_status);
939
+ task_process_status handle_status = handleSaiSetStatus (SAI_API_BUFFER, sai_status);
940
+ if (handle_status != task_process_status::task_success)
941
+ {
942
+ return handle_status;
943
+ }
914
944
}
915
945
}
916
946
}
0 commit comments