@@ -48,11 +48,7 @@ BufferOrch::BufferOrch(DBConnector *applDb, DBConnector *confDb, DBConnector *st
4848 m_flexCounterTable(new ProducerTable(m_flexCounterDb.get(), FLEX_COUNTER_TABLE)),
4949 m_flexCounterGroupTable(new ProducerTable(m_flexCounterDb.get(), FLEX_COUNTER_GROUP_TABLE)),
5050 m_countersDb(new DBConnector(" COUNTERS_DB" , 0 )),
51- m_stateBufferMaximumValueTable(stateDb, STATE_BUFFER_MAXIMUM_VALUE_TABLE),
52- m_ingressZeroBufferPool(SAI_NULL_OBJECT_ID),
53- m_egressZeroBufferPool(SAI_NULL_OBJECT_ID),
54- m_ingressZeroPoolRefCount(0 ),
55- m_egressZeroPoolRefCount(0 )
51+ m_stateBufferMaximumValueTable(stateDb, STATE_BUFFER_MAXIMUM_VALUE_TABLE)
5652{
5753 SWSS_LOG_ENTER ();
5854 initTableHandlers ();
@@ -314,65 +310,6 @@ const object_reference_map &BufferOrch::getBufferPoolNameOidMap(void)
314310 return *m_buffer_type_maps[APP_BUFFER_POOL_TABLE_NAME];
315311}
316312
317- void BufferOrch::lockZeroBufferPool (bool ingress)
318- {
319- if (ingress)
320- m_ingressZeroPoolRefCount++;
321- else
322- m_egressZeroPoolRefCount++;
323- }
324-
325- void BufferOrch::unlockZeroBufferPool (bool ingress)
326- {
327- sai_object_id_t pool = SAI_NULL_OBJECT_ID;
328- if (ingress)
329- {
330- if (--m_ingressZeroPoolRefCount <= 0 )
331- {
332- pool = m_ingressZeroBufferPool;
333- m_ingressZeroBufferPool = SAI_NULL_OBJECT_ID;
334- }
335- }
336- else
337- {
338- if (--m_egressZeroPoolRefCount <= 0 )
339- {
340- pool = m_egressZeroBufferPool;
341- m_egressZeroBufferPool = SAI_NULL_OBJECT_ID;
342- }
343- }
344-
345- if (pool != SAI_NULL_OBJECT_ID)
346- {
347- auto sai_status = sai_buffer_api->remove_buffer_pool (pool);
348- if (SAI_STATUS_SUCCESS != sai_status)
349- {
350- SWSS_LOG_ERROR (" Failed to remove buffer pool, rv:%d" , sai_status);
351- task_process_status handle_status = handleSaiRemoveStatus (SAI_API_BUFFER, sai_status);
352- if (handle_status != task_process_status::task_success)
353- {
354- return ;
355- }
356- }
357- else
358- {
359- SWSS_LOG_NOTICE (" Zero buffer pool has been successfully removed" );
360- }
361- }
362- }
363-
364- void BufferOrch::setZeroBufferPool (bool ingress, sai_object_id_t pool)
365- {
366- if (ingress)
367- {
368- m_ingressZeroBufferPool = pool;
369- }
370- else
371- {
372- m_egressZeroBufferPool = pool;
373- }
374- }
375-
376313task_process_status BufferOrch::processBufferPool (KeyOpFieldsValuesTuple &tuple)
377314{
378315 SWSS_LOG_ENTER ();
@@ -381,8 +318,6 @@ task_process_status BufferOrch::processBufferPool(KeyOpFieldsValuesTuple &tuple)
381318 string map_type_name = APP_BUFFER_POOL_TABLE_NAME;
382319 string object_name = kfvKey (tuple);
383320 string op = kfvOp (tuple);
384- sai_buffer_pool_type_t pool_direction = SAI_BUFFER_POOL_TYPE_INGRESS;
385- bool creating_zero_pool = false ;
386321
387322 SWSS_LOG_DEBUG (" object name:%s" , object_name.c_str ());
388323 if (m_buffer_type_maps[map_type_name]->find (object_name) != m_buffer_type_maps[map_type_name]->end ())
@@ -396,16 +331,6 @@ task_process_status BufferOrch::processBufferPool(KeyOpFieldsValuesTuple &tuple)
396331 }
397332 }
398333 SWSS_LOG_DEBUG (" processing command:%s" , op.c_str ());
399- if (object_name == " ingress_zero_pool" )
400- {
401- creating_zero_pool = true ;
402- pool_direction = SAI_BUFFER_POOL_TYPE_INGRESS;
403- }
404- else if (object_name == " egress_zero_pool" )
405- {
406- creating_zero_pool = true ;
407- pool_direction = SAI_BUFFER_POOL_TYPE_EGRESS;
408- }
409334
410335 if (op == SET_COMMAND)
411336 {
@@ -453,11 +378,6 @@ task_process_status BufferOrch::processBufferPool(KeyOpFieldsValuesTuple &tuple)
453378 return task_process_status::task_invalid_entry;
454379 }
455380 attr.id = SAI_BUFFER_POOL_ATTR_TYPE;
456- if (creating_zero_pool && pool_direction != static_cast <sai_buffer_pool_type_t >(attr.value .u32 ))
457- {
458- SWSS_LOG_ERROR (" Wrong pool direction for pool %s" , object_name.c_str ());
459- return task_process_status::task_invalid_entry;
460- }
461381 attribs.push_back (attr);
462382 }
463383 else if (field == buffer_pool_mode_field_name)
@@ -523,54 +443,20 @@ task_process_status BufferOrch::processBufferPool(KeyOpFieldsValuesTuple &tuple)
523443 }
524444 else
525445 {
526- if (creating_zero_pool)
527- {
528- if (pool_direction == SAI_BUFFER_POOL_TYPE_INGRESS)
529- {
530- sai_object = m_ingressZeroBufferPool;
531- }
532- else if (pool_direction == SAI_BUFFER_POOL_TYPE_EGRESS)
533- {
534- sai_object = m_egressZeroBufferPool;
535- }
536- }
537-
538- if (SAI_NULL_OBJECT_ID == sai_object)
539- {
540- sai_status = sai_buffer_api->create_buffer_pool (&sai_object, gSwitchId , (uint32_t )attribs.size (), attribs.data ());
541- if (SAI_STATUS_SUCCESS != sai_status)
542- {
543- SWSS_LOG_ERROR (" Failed to create buffer pool %s with type %s, rv:%d" , object_name.c_str (), map_type_name.c_str (), sai_status);
544- task_process_status handle_status = handleSaiCreateStatus (SAI_API_BUFFER, sai_status);
545- if (handle_status != task_process_status::task_success)
546- {
547- return handle_status;
548- }
549- }
550-
551- SWSS_LOG_NOTICE (" Created buffer pool %s with type %s" , object_name.c_str (), map_type_name.c_str ());
552- }
553- else
554- {
555- SWSS_LOG_NOTICE (" No need to create buffer pool %s since it has been created" , object_name.c_str ());
556- }
557-
558- if (creating_zero_pool)
446+ sai_status = sai_buffer_api->create_buffer_pool (&sai_object, gSwitchId , (uint32_t )attribs.size (), attribs.data ());
447+ if (SAI_STATUS_SUCCESS != sai_status)
559448 {
560- if (pool_direction == SAI_BUFFER_POOL_TYPE_INGRESS)
561- {
562- m_ingressZeroPoolRefCount++;
563- m_ingressZeroBufferPool = sai_object;
564- }
565- else if (pool_direction == SAI_BUFFER_POOL_TYPE_EGRESS)
449+ SWSS_LOG_ERROR (" Failed to create buffer pool %s with type %s, rv:%d" , object_name.c_str (), map_type_name.c_str (), sai_status);
450+ task_process_status handle_status = handleSaiCreateStatus (SAI_API_BUFFER, sai_status);
451+ if (handle_status != task_process_status::task_success)
566452 {
567- m_egressZeroPoolRefCount++;
568- m_egressZeroBufferPool = sai_object;
453+ return handle_status;
569454 }
570455 }
571456
572457 (*(m_buffer_type_maps[map_type_name]))[object_name].m_saiObjectId = sai_object;
573458 (*(m_buffer_type_maps[map_type_name]))[object_name].m_pendingRemove = false ;
459+ SWSS_LOG_NOTICE (" Created buffer pool %s with type %s" , object_name.c_str (), map_type_name.c_str ());
574460 // Here we take the PFC watchdog approach to update the COUNTERS_DB metadata (e.g., PFC_WD_DETECTION_TIME per queue)
575461 // at initialization (creation and registration phase)
576462 // Specifically, we push the buffer pool name to oid mapping upon the creation of the oid
@@ -593,39 +479,17 @@ task_process_status BufferOrch::processBufferPool(KeyOpFieldsValuesTuple &tuple)
593479 if (SAI_NULL_OBJECT_ID != sai_object)
594480 {
595481 clearBufferPoolWatermarkCounterIdList (sai_object);
596- bool remove = true ;
597- if (sai_object == m_ingressZeroBufferPool)
598- {
599- if (--m_ingressZeroPoolRefCount > 0 )
600- remove = false ;
601- else
602- m_ingressZeroBufferPool = SAI_NULL_OBJECT_ID;
603- }
604- else if (sai_object == m_egressZeroBufferPool)
605- {
606- if (--m_egressZeroPoolRefCount > 0 )
607- remove = false ;
608- else
609- m_egressZeroBufferPool = SAI_NULL_OBJECT_ID;
610- }
611- if (remove)
482+ sai_status = sai_buffer_api->remove_buffer_pool (sai_object);
483+ if (SAI_STATUS_SUCCESS != sai_status)
612484 {
613- sai_status = sai_buffer_api->remove_buffer_pool (sai_object);
614- if (SAI_STATUS_SUCCESS != sai_status)
485+ SWSS_LOG_ERROR (" Failed to remove buffer pool %s with type %s, rv:%d" , object_name.c_str (), map_type_name.c_str (), sai_status);
486+ task_process_status handle_status = handleSaiRemoveStatus (SAI_API_BUFFER, sai_status);
487+ if (handle_status != task_process_status::task_success)
615488 {
616- SWSS_LOG_ERROR (" Failed to remove buffer pool %s with type %s, rv:%d" , object_name.c_str (), map_type_name.c_str (), sai_status);
617- task_process_status handle_status = handleSaiRemoveStatus (SAI_API_BUFFER, sai_status);
618- if (handle_status != task_process_status::task_success)
619- {
620- return handle_status;
621- }
489+ return handle_status;
622490 }
623- SWSS_LOG_NOTICE (" Removed buffer pool %s with type %s" , object_name.c_str (), map_type_name.c_str ());
624- }
625- else
626- {
627- SWSS_LOG_NOTICE (" Will not remove buffer pool %s since it is still referenced" , object_name.c_str ());
628491 }
492+ SWSS_LOG_NOTICE (" Removed buffer pool %s with type %s" , object_name.c_str (), map_type_name.c_str ());
629493 }
630494 auto it_to_delete = (m_buffer_type_maps[map_type_name])->find (object_name);
631495 (m_buffer_type_maps[map_type_name])->erase (it_to_delete);
@@ -1049,7 +913,6 @@ task_process_status BufferOrch::processPriorityGroup(KeyOpFieldsValuesTuple &tup
1049913 for (string port_name : port_names)
1050914 {
1051915 Port port;
1052- bool portUpdated = false ;
1053916 SWSS_LOG_DEBUG (" processing port:%s" , port_name.c_str ());
1054917 if (!gPortsOrch ->getPort (port_name, port))
1055918 {
@@ -1064,12 +927,6 @@ task_process_status BufferOrch::processPriorityGroup(KeyOpFieldsValuesTuple &tup
1064927 SWSS_LOG_ERROR (" Invalid pg index specified:%zd" , ind);
1065928 return task_process_status::task_invalid_entry;
1066929 }
1067- if (port.m_priority_group_lock [ind])
1068- {
1069- SWSS_LOG_WARN (" Priority group %zd on port %s is locked, pending profile 0x%" PRIx64 " until unlocked" , ind, port_name.c_str (), sai_buffer_profile);
1070- portUpdated = true ;
1071- port.m_priority_group_pending_profile [ind] = sai_buffer_profile;
1072- }
1073930 else
1074931 {
1075932 if (need_update_sai)
@@ -1090,10 +947,6 @@ task_process_status BufferOrch::processPriorityGroup(KeyOpFieldsValuesTuple &tup
1090947 }
1091948 }
1092949 }
1093- if (portUpdated)
1094- {
1095- gPortsOrch ->setPort (port_name, port);
1096- }
1097950 }
1098951
1099952 if (m_ready_list.find (key) != m_ready_list.end ())
0 commit comments