Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add SAI_SWITCH_ATTR_CURRENT_TEMP to get average temperature from sensors #880

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
29 changes: 29 additions & 0 deletions inc/saiswitch.h
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,24 @@ typedef enum _sai_switch_attr_t
*/
SAI_SWITCH_ATTR_OPER_STATUS,

/**
* @brief Maximum number of temperature sensors available.
*
* @type sai_uint8_t
* @flags READ_ONLY
*/
SAI_SWITCH_ATTR_MAX_NUMBER_OF_TEMP_SENSORS,

/**
* @brief List of temperature readings from all sensors.
*
* Values in Celsius.
*
* @type sai_s32_list_t
* @flags READ_ONLY
*/
SAI_SWITCH_ATTR_TEMP_LIST,

/**
* @brief The current value of the maximum temperature
* retrieved from the switch sensors
Expand All @@ -409,6 +427,17 @@ typedef enum _sai_switch_attr_t
*/
SAI_SWITCH_ATTR_MAX_TEMP,

/**
* @brief The average of temperature readings over all
* sensors in the switch
*
* Value in Celsius.
*
* @type sai_int32_t
* @flags READ_ONLY
*/
SAI_SWITCH_ATTR_AVERAGE_TEMP,

/**
* @brief Minimum priority for ACL table
*
Expand Down
86 changes: 86 additions & 0 deletions stub/src/stub_sai_switch.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,26 @@ sai_status_t stub_switch_fdb_size_get(_In_ const sai_object_key_t *key,
_In_ uint32_t attr_index,
_Inout_ vendor_cache_t *cache,
void *arg);
sai_status_t stub_switch_max_num_sensors_get(_In_ const sai_object_key_t *key,
_Inout_ sai_attribute_value_t *value,
_In_ uint32_t attr_index,
_Inout_ vendor_cache_t *cache,
void *arg);
sai_status_t stub_switch_temp_get(_In_ const sai_object_key_t *key,
_Inout_ sai_attribute_value_t *value,
_In_ uint32_t attr_index,
_Inout_ vendor_cache_t *cache,
void *arg);
sai_status_t stub_switch_max_temp_get(_In_ const sai_object_key_t *key,
_Inout_ sai_attribute_value_t *value,
_In_ uint32_t attr_index,
_Inout_ vendor_cache_t *cache,
void *arg);
sai_status_t stub_switch_average_temp_get(_In_ const sai_object_key_t *key,
_Inout_ sai_attribute_value_t *value,
_In_ uint32_t attr_index,
_Inout_ vendor_cache_t *cache,
void *arg);
sai_status_t stub_switch_default_stp_get(_In_ const sai_object_key_t *key,
_Inout_ sai_attribute_value_t *value,
_In_ uint32_t attr_index,
Expand Down Expand Up @@ -190,8 +205,14 @@ static const sai_attribute_entry_t switch_attribs[] = {
"Switch on link route supported", SAI_ATTR_VAL_TYPE_BOOL },
{ SAI_SWITCH_ATTR_OPER_STATUS, false, false, false, true,
"Switch operational status", SAI_ATTR_VAL_TYPE_S32 },
{ SAI_SWITCH_ATTR_MAX_NUMBER_OF_TEMP_SENSORS, false, false, false, true,
"Switch Maximum sensors", SAI_ATTR_VAL_TYPE_U8 },
{ SAI_SWITCH_ATTR_TEMP_LIST, false, false, false, true,
"Switch temperature list", SAI_ATTR_VAL_TYPE_S32LIST},
{ SAI_SWITCH_ATTR_MAX_TEMP, false, false, false, true,
"Switch maximum temperature", SAI_ATTR_VAL_TYPE_S32 },
{ SAI_SWITCH_ATTR_AVERAGE_TEMP, false, false, false, true,
"Switch current temperature", SAI_ATTR_VAL_TYPE_S32 },
{ SAI_SWITCH_ATTR_ACL_TABLE_MINIMUM_PRIORITY, false, false, false, true,
"Switch ACL table min prio", SAI_ATTR_VAL_TYPE_U32 },
{ SAI_SWITCH_ATTR_ACL_TABLE_MAXIMUM_PRIORITY, false, false, false, true,
Expand Down Expand Up @@ -277,11 +298,26 @@ static const sai_vendor_attribute_entry_t switch_vendor_attribs[] = {
{ false, false, false, true },
stub_switch_oper_status_get, NULL,
NULL, NULL },
{ SAI_SWITCH_ATTR_MAX_NUMBER_OF_TEMP_SENSORS,
{ false, false, false, true },
{ false, false, false, true },
stub_switch_max_num_sensors_get, NULL,
NULL, NULL },
{ SAI_SWITCH_ATTR_TEMP_LIST,
{ false, false, false, true },
{ false, false, false, true },
stub_switch_temp_get, NULL,
NULL, NULL },
{ SAI_SWITCH_ATTR_MAX_TEMP,
{ false, false, false, true },
{ false, false, false, true },
stub_switch_max_temp_get, NULL,
NULL, NULL },
{ SAI_SWITCH_ATTR_AVERAGE_TEMP,
{ false, false, false, true },
{ false, false, false, true },
stub_switch_average_temp_get, NULL,
NULL, NULL },
{ SAI_SWITCH_ATTR_ACL_TABLE_MINIMUM_PRIORITY,
{ false, false, false, true },
{ false, false, false, true },
Expand Down Expand Up @@ -846,6 +882,40 @@ sai_status_t stub_switch_fdb_size_get(_In_ const sai_object_key_t *key,
return SAI_STATUS_SUCCESS;
}

/* The Maximum number of temperature sensors available */
sai_status_t stub_switch_max_num_sensors_get(_In_ const sai_object_key_t *key,
_Inout_ sai_attribute_value_t *value,
_In_ uint32_t attr_index,
_Inout_ vendor_cache_t *cache,
void *arg)
{
STUB_LOG_ENTER();

value->u8 = 1;

STUB_LOG_EXIT();
return SAI_STATUS_SUCCESS;
}

/* List of temperature readings from all sensors in Celsius [int32_t] */
sai_status_t stub_switch_temp_get(_In_ const sai_object_key_t *key,
_Inout_ sai_attribute_value_t *value,
_In_ uint32_t attr_index,
_Inout_ vendor_cache_t *cache,
void *arg)
{
sai_status_t status;
int32_t temp;

STUB_LOG_ENTER();

temp = 50;
status = stub_fill_s32list(&temp, 1, &value->s32list);

STUB_LOG_EXIT();
return SAI_STATUS_SUCCESS;
}

/* The current value of the maximum temperature
* retrieved from the switch sensors, in Celsius [int32_t] */
sai_status_t stub_switch_max_temp_get(_In_ const sai_object_key_t *key,
Expand All @@ -862,6 +932,22 @@ sai_status_t stub_switch_max_temp_get(_In_ const sai_object_key_t *key,
return SAI_STATUS_SUCCESS;
}

/* The average value of the temperature
* retrieved from the switch sensors, in Celsius [int32_t] */
sai_status_t stub_switch_average_temp_get(_In_ const sai_object_key_t *key,
_Inout_ sai_attribute_value_t *value,
_In_ uint32_t attr_index,
_Inout_ vendor_cache_t *cache,
void *arg)
{
STUB_LOG_ENTER();

value->s32 = 50;

STUB_LOG_EXIT();
return SAI_STATUS_SUCCESS;
}

/* Default SAI STP instance ID [sai_object_id_t] */
sai_status_t stub_switch_default_stp_get(_In_ const sai_object_key_t *key,
_Inout_ sai_attribute_value_t *value,
Expand Down