Skip to content

Commit

Permalink
[orchagent] Increase SAI REDIS response timeout to support FW upgrade…
Browse files Browse the repository at this point in the history
… during init (Mellanox only). (#1637)

Signed-off-by: liora <liora@nvidia.com>

Co-authored-by: liora <liora@nvidia.com>
  • Loading branch information
2 people authored and yxieca committed Mar 3, 2021
1 parent 6c285f6 commit 9376ec6
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions orchagent/saihelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand Down Expand Up @@ -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);
Expand All @@ -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)
Expand Down

0 comments on commit 9376ec6

Please sign in to comment.