Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions lib/inc/sai_redis.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,6 @@ void check_notifications_pointers(
_In_ uint32_t attr_count,
_In_ const sai_attribute_t *attr_list);

// if we don't receive response from syncd in 60 seconds
// there is something wrong and we should fail
#define GET_RESPONSE_TIMEOUT (60*1000)

extern std::string getSelectResultAsString(int result);
extern void clear_local_state();
extern void setRecording(bool record);
Expand All @@ -66,6 +62,7 @@ extern volatile bool g_useTempView;
extern volatile bool g_asicInitViewMode;
extern volatile bool g_logrotate;
extern volatile bool g_syncMode;
extern volatile uint64_t g_responseTimeoutMs;

extern sai_service_method_table_t g_services;
extern std::shared_ptr<swss::ProducerTable> g_asicState;
Expand Down
16 changes: 16 additions & 0 deletions lib/inc/sairedis.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ const std::string attrEnumValuesCapabilityResponse("attr_enum_values_capability_
const std::string objectTypeGetAvailabilityQuery("object_type_get_availability_query");
const std::string objectTypeGetAvailabilityResponse("object_type_get_availability_response");

/**
* @brief Default synchronous operation response timeout in milliseconds.
*/
#define SAI_REDIS_DEFAULT_SYNC_OPERATION_RESPONSE_TIMEOUT (60*1000)

typedef enum _sai_redis_notify_syncd_t
{
SAI_REDIS_NOTIFY_SYNCD_INIT_VIEW,
Expand Down Expand Up @@ -134,6 +139,17 @@ typedef enum _sai_redis_switch_attr_t
*/
SAI_REDIS_SWITCH_ATTR_RECORDING_FILENAME,

/**
* @brief Synchronous operation response timeout in milliseconds.
*
* Used for every synchronous API call. In asynchronous mode used for GET
* operation.
*
* @type sai_uint64_t
* @flags CREATE_AND_SET
* @default 60000
*/
SAI_REDIS_SWITCH_ATTR_SYNC_OPERATION_RESPONSE_TIMEOUT,

} sai_redis_switch_attr_t;

Expand Down
2 changes: 1 addition & 1 deletion lib/src/sai_redis_fdb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ sai_status_t internal_redis_flush_fdb_entries(

swss::Selectable *sel;

int result = s.select(&sel, GET_RESPONSE_TIMEOUT);
int result = s.select(&sel, (int)g_responseTimeoutMs);

if (result == swss::Select::OBJECT)
{
Expand Down
2 changes: 1 addition & 1 deletion lib/src/sai_redis_generic_get.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ sai_status_t internal_redis_generic_get(

swss::Selectable *sel;

int result = s.select(&sel, GET_RESPONSE_TIMEOUT);
int result = s.select(&sel, (int)g_responseTimeoutMs);

if (result == swss::Select::OBJECT)
{
Expand Down
2 changes: 1 addition & 1 deletion lib/src/sai_redis_generic_set.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ sai_status_t internal_api_wait_for_response(
swss::Selectable *sel;

// get timeout and selector is used for all quad api's
int result = s.select(&sel, GET_RESPONSE_TIMEOUT);
int result = s.select(&sel, (int)g_responseTimeoutMs);

if (result == swss::Select::OBJECT)
{
Expand Down
4 changes: 2 additions & 2 deletions lib/src/sai_redis_generic_stats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ sai_status_t internal_redis_generic_get_stats(

swss::Selectable *sel;

int result = s.select(&sel, GET_RESPONSE_TIMEOUT);
int result = s.select(&sel, (int)g_responseTimeoutMs);

if (result == swss::Select::OBJECT)
{
Expand Down Expand Up @@ -419,7 +419,7 @@ sai_status_t internal_redis_generic_clear_stats(
SWSS_LOG_DEBUG("wait for clear_stats response");

swss::Selectable *sel;
int result = s.select(&sel, GET_RESPONSE_TIMEOUT);
int result = s.select(&sel, (int)g_responseTimeoutMs);
if (result == swss::Select::OBJECT)
{
swss::KeyOpFieldsValuesTuple kco;
Expand Down
4 changes: 2 additions & 2 deletions lib/src/sai_redis_interfacequery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ sai_status_t sai_query_attribute_enum_values_capability(

swss::Selectable *sel;

auto result = callback.select(&sel, GET_RESPONSE_TIMEOUT);
auto result = callback.select(&sel, (int)g_responseTimeoutMs);

if (result == swss::Select::OBJECT)
{
Expand Down Expand Up @@ -460,7 +460,7 @@ sai_status_t sai_object_type_get_availability(

swss::Selectable *sel;

auto result = callback.select(&sel, GET_RESPONSE_TIMEOUT);
auto result = callback.select(&sel, (int)g_responseTimeoutMs);

if (result == swss::Select::OBJECT)
{
Expand Down
10 changes: 9 additions & 1 deletion lib/src/sai_redis_switch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
volatile bool g_asicInitViewMode = false; // default mode is apply mode
volatile bool g_useTempView = false;
volatile bool g_syncMode = false;
volatile uint64_t g_responseTimeoutMs = SAI_REDIS_DEFAULT_SYNC_OPERATION_RESPONSE_TIMEOUT;

sai_status_t sai_redis_internal_notify_syncd(
_In_ const std::string& key)
Expand Down Expand Up @@ -36,7 +37,7 @@ sai_status_t sai_redis_internal_notify_syncd(

swss::Selectable *sel;

int result = s.select(&sel, GET_RESPONSE_TIMEOUT);
int result = s.select(&sel, (int)g_responseTimeoutMs);

if (result == swss::Select::OBJECT)
{
Expand Down Expand Up @@ -299,6 +300,13 @@ sai_status_t redis_set_switch_attribute(

case SAI_REDIS_SWITCH_ATTR_RECORDING_FILENAME:
return setRecordingOutputFile(*attr);

case SAI_REDIS_SWITCH_ATTR_SYNC_OPERATION_RESPONSE_TIMEOUT:

g_responseTimeoutMs = attr->value.u64;

return SAI_STATUS_SUCCESS;

default:
break;
}
Expand Down