From f50bb7956bc47921dca090b9885e257811f75883 Mon Sep 17 00:00:00 2001 From: Alpesh S Patel Date: Sun, 21 Nov 2021 15:43:13 -0800 Subject: [PATCH 1/3] patch for issue #1971. Signed-off-by: Alpesh S Patel --- orchagent/pfc_restore_cisco-8000.lua | 2 +- orchagent/pfcactionhandler.cpp | 53 ++++++++++------------------ orchagent/pfcactionhandler.h | 3 +- 3 files changed, 21 insertions(+), 37 deletions(-) diff --git a/orchagent/pfc_restore_cisco-8000.lua b/orchagent/pfc_restore_cisco-8000.lua index 686de0464be..172e67b9609 100644 --- a/orchagent/pfc_restore_cisco-8000.lua +++ b/orchagent/pfc_restore_cisco-8000.lua @@ -44,7 +44,7 @@ for i = n, 1, -1 do and (debug_storm ~= "enabled") -- DEBUG CODE END. then - if time_left <= 0 then + if time_left <= poll_time then redis.call('PUBLISH', 'PFC_WD_ACTION', '["' .. KEYS[i] .. '","restore"]') time_left = restoration_time else diff --git a/orchagent/pfcactionhandler.cpp b/orchagent/pfcactionhandler.cpp index 0a24b1ba012..b75c46cac69 100644 --- a/orchagent/pfcactionhandler.cpp +++ b/orchagent/pfcactionhandler.cpp @@ -221,7 +221,7 @@ void PfcWdActionHandler::updateWdCounters(const string& queueIdStr, const PfcWdQ PfcWdSaiDlrInitHandler::PfcWdSaiDlrInitHandler(sai_object_id_t port, sai_object_id_t queue, uint8_t queueId, shared_ptr countersTable): - PfcWdActionHandler(port, queue, queueId, countersTable) + PfcWdZeroBufferHandler(port, queue, queueId, countersTable) { SWSS_LOG_ENTER(); @@ -262,39 +262,6 @@ PfcWdSaiDlrInitHandler::~PfcWdSaiDlrInitHandler(void) } } -bool PfcWdSaiDlrInitHandler::getHwCounters(PfcWdHwStats& counters) -{ - SWSS_LOG_ENTER(); - - static const vector queueStatIds = - { - SAI_QUEUE_STAT_PACKETS, - SAI_QUEUE_STAT_DROPPED_PACKETS, - }; - - vector queueStats; - queueStats.resize(queueStatIds.size()); - - sai_status_t status = sai_queue_api->get_queue_stats( - getQueue(), - static_cast(queueStatIds.size()), - queueStatIds.data(), - queueStats.data()); - - if (status != SAI_STATUS_SUCCESS) - { - SWSS_LOG_ERROR("Failed to fetch queue 0x%" PRIx64 " stats: %d", getQueue(), status); - return false; - } - - counters.txPkt = queueStats[0]; - counters.txDropPkt = queueStats[1]; - counters.rxPkt = 0; - counters.rxDropPkt = 0; - - return true; -} - PfcWdAclHandler::PfcWdAclHandler(sai_object_id_t port, sai_object_id_t queue, uint8_t queueId, shared_ptr
countersTable): PfcWdLossyHandler(port, queue, queueId, countersTable) @@ -469,6 +436,15 @@ PfcWdLossyHandler::PfcWdLossyHandler(sai_object_id_t port, sai_object_id_t queue { SWSS_LOG_ENTER(); + string platform(getenv("platform")); + + if (platform == CISCO_8000_PLATFORM_SUBSTRING) + { + SWSS_LOG_DEBUG("Skipping in constructor PfcWdLossyHandler for platform %s on port 0x%" PRIx64, + platform.c_str(), port); + return; + } + uint8_t pfcMask = 0; if (!gPortsOrch->getPortPfc(port, &pfcMask)) @@ -488,6 +464,15 @@ PfcWdLossyHandler::~PfcWdLossyHandler(void) { SWSS_LOG_ENTER(); + string platform(getenv("platform")); + + if (platform == CISCO_8000_PLATFORM_SUBSTRING) + { + SWSS_LOG_DEBUG("Skipping in destructor PfcWdLossyHandler for platform %s on port 0x%" PRIx64, + platform.c_str(), getPort()); + return; + } + uint8_t pfcMask = 0; if (!gPortsOrch->getPortPfc(getPort(), &pfcMask)) diff --git a/orchagent/pfcactionhandler.h b/orchagent/pfcactionhandler.h index 381f9bdca84..a72225f21ac 100644 --- a/orchagent/pfcactionhandler.h +++ b/orchagent/pfcactionhandler.h @@ -165,13 +165,12 @@ class PfcWdZeroBufferHandler: public PfcWdLossyHandler // PFC queue that implements drop action by draining queue via SAI // attribute SAI_QUEUE_ATTR_PFC_DLR_INIT. -class PfcWdSaiDlrInitHandler: public PfcWdActionHandler +class PfcWdSaiDlrInitHandler: public PfcWdZeroBufferHandler { public: PfcWdSaiDlrInitHandler(sai_object_id_t port, sai_object_id_t queue, uint8_t queueId, shared_ptr
countersTable); virtual ~PfcWdSaiDlrInitHandler(void); - virtual bool getHwCounters(PfcWdHwStats& counters); }; #endif From cdcc3d65a1dec1c86c5bb9343cb5b2252dbf8d62 Mon Sep 17 00:00:00 2001 From: Alpesh S Patel Date: Tue, 14 Dec 2021 15:34:04 -0800 Subject: [PATCH 2/3] to address PR comments, assiging empty string in case platform is not defined Signed-off-by: Alpesh S Patel --- orchagent/pfcactionhandler.cpp | 36 +++++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/orchagent/pfcactionhandler.cpp b/orchagent/pfcactionhandler.cpp index b75c46cac69..cd021015afd 100644 --- a/orchagent/pfcactionhandler.cpp +++ b/orchagent/pfcactionhandler.cpp @@ -436,13 +436,20 @@ PfcWdLossyHandler::PfcWdLossyHandler(sai_object_id_t port, sai_object_id_t queue { SWSS_LOG_ENTER(); - string platform(getenv("platform")); - - if (platform == CISCO_8000_PLATFORM_SUBSTRING) + const char *env_plat = getenv("platform"); + if (env_plat == nullptr) { - SWSS_LOG_DEBUG("Skipping in constructor PfcWdLossyHandler for platform %s on port 0x%" PRIx64, - platform.c_str(), port); - return; + string platform(""); + } + else + { + string platform(env_plat); + if (platform == CISCO_8000_PLATFORM_SUBSTRING) + { + SWSS_LOG_DEBUG("Skipping in constructor PfcWdLossyHandler for platform %s on port 0x%" PRIx64, + platform.c_str(), port); + return; + } } uint8_t pfcMask = 0; @@ -464,13 +471,20 @@ PfcWdLossyHandler::~PfcWdLossyHandler(void) { SWSS_LOG_ENTER(); - string platform(getenv("platform")); - - if (platform == CISCO_8000_PLATFORM_SUBSTRING) + const char *env_plat = getenv("platform"); + if (env_plat == nullptr) + { + string platform(""); + } + else { - SWSS_LOG_DEBUG("Skipping in destructor PfcWdLossyHandler for platform %s on port 0x%" PRIx64, + string platform(env_plat); + if (platform == CISCO_8000_PLATFORM_SUBSTRING) + { + SWSS_LOG_DEBUG("Skipping in destructor PfcWdLossyHandler for platform %s on port 0x%" PRIx64, platform.c_str(), getPort()); - return; + return; + } } uint8_t pfcMask = 0; From 6b0f1f6f6886190ff42f5258d6a263c4006c4645 Mon Sep 17 00:00:00 2001 From: Alpesh S Patel Date: Tue, 14 Dec 2021 19:15:34 -0800 Subject: [PATCH 3/3] to address PR comments, assiging empty string in case platform is not defined Signed-off-by: Alpesh S Patel --- orchagent/pfcactionhandler.cpp | 34 +++++++++------------------------- 1 file changed, 9 insertions(+), 25 deletions(-) diff --git a/orchagent/pfcactionhandler.cpp b/orchagent/pfcactionhandler.cpp index cd021015afd..1509f56e9aa 100644 --- a/orchagent/pfcactionhandler.cpp +++ b/orchagent/pfcactionhandler.cpp @@ -436,20 +436,12 @@ PfcWdLossyHandler::PfcWdLossyHandler(sai_object_id_t port, sai_object_id_t queue { SWSS_LOG_ENTER(); - const char *env_plat = getenv("platform"); - if (env_plat == nullptr) + string platform = getenv("platform") ? getenv("platform") : ""; + if (platform == CISCO_8000_PLATFORM_SUBSTRING) { - string platform(""); - } - else - { - string platform(env_plat); - if (platform == CISCO_8000_PLATFORM_SUBSTRING) - { - SWSS_LOG_DEBUG("Skipping in constructor PfcWdLossyHandler for platform %s on port 0x%" PRIx64, - platform.c_str(), port); - return; - } + SWSS_LOG_DEBUG("Skipping in constructor PfcWdLossyHandler for platform %s on port 0x%" PRIx64, + platform.c_str(), port); + return; } uint8_t pfcMask = 0; @@ -471,20 +463,12 @@ PfcWdLossyHandler::~PfcWdLossyHandler(void) { SWSS_LOG_ENTER(); - const char *env_plat = getenv("platform"); - if (env_plat == nullptr) + string platform = getenv("platform") ? getenv("platform") : ""; + if (platform == CISCO_8000_PLATFORM_SUBSTRING) { - string platform(""); - } - else - { - string platform(env_plat); - if (platform == CISCO_8000_PLATFORM_SUBSTRING) - { - SWSS_LOG_DEBUG("Skipping in destructor PfcWdLossyHandler for platform %s on port 0x%" PRIx64, + SWSS_LOG_DEBUG("Skipping in destructor PfcWdLossyHandler for platform %s on port 0x%" PRIx64, platform.c_str(), getPort()); - return; - } + return; } uint8_t pfcMask = 0;