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 2 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
11 changes: 11 additions & 0 deletions inc/saiswitch.h
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,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_CURRENT_TEMP,

/**
* @brief Minimum priority for ACL table
*
Expand Down
28 changes: 28 additions & 0 deletions stub/src/stub_sai_switch.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ sai_status_t stub_switch_max_temp_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_current_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 @@ -192,6 +197,8 @@ static const sai_attribute_entry_t switch_attribs[] = {
"Switch operational status", SAI_ATTR_VAL_TYPE_S32 },
{ SAI_SWITCH_ATTR_MAX_TEMP, false, false, false, true,
"Switch maximum temperature", SAI_ATTR_VAL_TYPE_S32 },
{ SAI_SWITCH_ATTR_CURRENT_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 @@ -282,6 +289,11 @@ static const sai_vendor_attribute_entry_t switch_vendor_attribs[] = {
{ false, false, false, true },
stub_switch_max_temp_get, NULL,
NULL, NULL },
{ SAI_SWITCH_ATTR_CURRENT_TEMP,
{ false, false, false, true },
{ false, false, false, true },
stub_switch_current_temp_get, NULL,
NULL, NULL },
{ SAI_SWITCH_ATTR_ACL_TABLE_MINIMUM_PRIORITY,
{ false, false, false, true },
{ false, false, false, true },
Expand Down Expand Up @@ -862,6 +874,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_current_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