From 9376ec694925c5cd715870e48a5aec7c8060c8a8 Mon Sep 17 00:00:00 2001 From: Lior Avramov <73036155+liorghub@users.noreply.github.com> Date: Mon, 22 Feb 2021 16:56:01 +0200 Subject: [PATCH] [orchagent] Increase SAI REDIS response timeout to support FW upgrade during init (Mellanox only). (#1637) Signed-off-by: liora Co-authored-by: liora --- orchagent/saihelper.cpp | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/orchagent/saihelper.cpp b/orchagent/saihelper.cpp index d047852488..9e0faa2fe9 100644 --- a/orchagent/saihelper.cpp +++ b/orchagent/saihelper.cpp @@ -19,6 +19,7 @@ extern "C" { #include "timestamp.h" #include "sai_serialize.h" #include "saihelper.h" +#include "orch.h" using namespace std; using namespace swss; @@ -27,6 +28,7 @@ using namespace swss; #define STR(s) _STR(s) #define CONTEXT_CFG_FILE "/usr/share/sonic/hwsku/context_config.json" +#define SAI_REDIS_SYNC_OPERATION_RESPONSE_TIMEOUT (480*1000) // hwinfo = "INTERFACE_NAME/PHY ID", mii_ioctl_data->phy_id is a __u16 #define HWINFO_MAX_SIZE IFNAMSIZ + 1 + 5 @@ -259,6 +261,26 @@ void initSaiRedis(const string &record_location) } SWSS_LOG_NOTICE("Enable redis pipeline"); + char *platform = getenv("platform"); + if (platform && strstr(platform, MLNX_PLATFORM_SUBSTRING)) + { + /* We set this long timeout in order for Orchagent to wait enough time for + * response from syncd. It is needed since in init, systemd syncd startup + * script first calls FW upgrade script (that might take up to 7 minutes + * in systems with Gearbox) and only then launches syncd container */ + attr.id = SAI_REDIS_SWITCH_ATTR_SYNC_OPERATION_RESPONSE_TIMEOUT; + attr.value.u64 = SAI_REDIS_SYNC_OPERATION_RESPONSE_TIMEOUT; + status = sai_switch_api->set_switch_attribute(gSwitchId, &attr); + + if (status != SAI_STATUS_SUCCESS) + { + SWSS_LOG_ERROR("Failed to set SAI REDIS response timeout"); + exit(EXIT_FAILURE); + } + + SWSS_LOG_NOTICE("SAI REDIS response timeout set successfully to %" PRIu64 " ", attr.value.u64); + } + attr.id = SAI_REDIS_SWITCH_ATTR_NOTIFY_SYNCD; attr.value.s32 = SAI_REDIS_NOTIFY_SYNCD_INIT_VIEW; status = sai_switch_api->set_switch_attribute(gSwitchId, &attr); @@ -269,6 +291,22 @@ void initSaiRedis(const string &record_location) exit(EXIT_FAILURE); } SWSS_LOG_NOTICE("Notify syncd INIT_VIEW"); + + if (platform && strstr(platform, MLNX_PLATFORM_SUBSTRING)) + { + /* Set timeout back to the default value */ + attr.id = SAI_REDIS_SWITCH_ATTR_SYNC_OPERATION_RESPONSE_TIMEOUT; + attr.value.u64 = SAI_REDIS_DEFAULT_SYNC_OPERATION_RESPONSE_TIMEOUT; + status = sai_switch_api->set_switch_attribute(gSwitchId, &attr); + + if (status != SAI_STATUS_SUCCESS) + { + SWSS_LOG_ERROR("Failed to set SAI REDIS response timeout"); + exit(EXIT_FAILURE); + } + + SWSS_LOG_NOTICE("SAI REDIS response timeout set successfully to %" PRIu64 " ", attr.value.u64); + } } sai_status_t initSaiPhyApi(swss::gearbox_phy_t *phy)