From 0372615fbd4723d1a97a99bdea4ee7e4e0986616 Mon Sep 17 00:00:00 2001 From: Wenda Ni Date: Wed, 31 Mar 2021 01:38:54 -0700 Subject: [PATCH] [vslib] Refresh queue pause status (#814) --- vslib/inc/SwitchStateBase.h | 3 +++ vslib/src/SwitchStateBase.cpp | 23 +++++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/vslib/inc/SwitchStateBase.h b/vslib/inc/SwitchStateBase.h index 4da145c0c673..5ee664b364ae 100644 --- a/vslib/inc/SwitchStateBase.h +++ b/vslib/inc/SwitchStateBase.h @@ -149,6 +149,9 @@ namespace saivs virtual sai_status_t refresh_macsec_sci_in_ingress_macsec_acl( _In_ sai_object_id_t object_id); + virtual sai_status_t refresh_queue_pause_status( + _In_ sai_object_id_t object_id); + public: virtual sai_status_t warm_boot_initialize_objects(); diff --git a/vslib/src/SwitchStateBase.cpp b/vslib/src/SwitchStateBase.cpp index 89460e1745c2..743b84b0af09 100644 --- a/vslib/src/SwitchStateBase.cpp +++ b/vslib/src/SwitchStateBase.cpp @@ -2056,6 +2056,24 @@ sai_status_t SwitchStateBase::refresh_macsec_sci_in_ingress_macsec_acl( return SAI_STATUS_SUCCESS; } +sai_status_t SwitchStateBase::refresh_queue_pause_status( + _In_ sai_object_id_t object_id) +{ + SWSS_LOG_ENTER(); + + // To trigger fake PFC storm on fake Broadcom platform, PFC storm detection + // lua requires SAI_QUEUE_ATTR_PAUSE_STATUS field to be present in COUNTERS_DB. + // However, the actual value of the attribute does not matter in this regard, + // so a dummy one is assigned here. + sai_attribute_t attr; + attr.id = SAI_QUEUE_ATTR_PAUSE_STATUS; + attr.value.booldata = false; + + CHECK_STATUS(set(SAI_OBJECT_TYPE_QUEUE, object_id, &attr)); + + return SAI_STATUS_SUCCESS; +} + // XXX extra work may be needed on GET api if N on list will be > then actual /* @@ -2205,6 +2223,11 @@ sai_status_t SwitchStateBase::refresh_read_only( return refresh_macsec_sci_in_ingress_macsec_acl(object_id); } + if (meta->objecttype == SAI_OBJECT_TYPE_QUEUE && meta->attrid == SAI_QUEUE_ATTR_PAUSE_STATUS) + { + return refresh_queue_pause_status(object_id); + } + auto mmeta = m_meta.lock(); if (mmeta)