From 15617e3866dfe2b51bda3a25f775dc2662f9415c Mon Sep 17 00:00:00 2001 From: PADMANABHAN NARAYANAN Date: Sat, 20 Oct 2018 12:02:42 -0700 Subject: [PATCH 1/4] Add SAI_SWITCH_ATTR_CURRENT_TEMP to get average temperature from sensors --- inc/saiswitch.h | 11 +++++++++++ stub/src/stub_sai_switch.c | 28 ++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/inc/saiswitch.h b/inc/saiswitch.h index a5533e962..54ac3e907 100644 --- a/inc/saiswitch.h +++ b/inc/saiswitch.h @@ -409,6 +409,17 @@ typedef enum _sai_switch_attr_t */ SAI_SWITCH_ATTR_MAX_TEMP, + /** + * @brief The average value of the temperature + * retrieved from the switch sensors + * + * Value in Celsius. + * + * @type sai_int32_t + * @flags READ_ONLY + */ + SAI_SWITCH_ATTR_CURRENT_TEMP, + /** * @brief Minimum priority for ACL table * diff --git a/stub/src/stub_sai_switch.c b/stub/src/stub_sai_switch.c index 6da416a24..a8afc4523 100644 --- a/stub/src/stub_sai_switch.c +++ b/stub/src/stub_sai_switch.c @@ -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, @@ -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, @@ -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 }, @@ -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, From 40de9db12359cef84cbb2ef206f4110d2c0fa4e7 Mon Sep 17 00:00:00 2001 From: PADMANABHAN NARAYANAN Date: Tue, 23 Oct 2018 14:54:48 -0700 Subject: [PATCH 2/4] Update description for SAI_SWITCH_ATTR_CURRENT_TEMP --- inc/saiswitch.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/inc/saiswitch.h b/inc/saiswitch.h index 54ac3e907..a8331ffa0 100644 --- a/inc/saiswitch.h +++ b/inc/saiswitch.h @@ -410,8 +410,8 @@ typedef enum _sai_switch_attr_t SAI_SWITCH_ATTR_MAX_TEMP, /** - * @brief The average value of the temperature - * retrieved from the switch sensors + * @brief The average of temperature readings over all + * sensors in the switch * * Value in Celsius. * From d195c97803640208237bddfa49f1253b3996d080 Mon Sep 17 00:00:00 2001 From: PADMANABHAN NARAYANAN Date: Thu, 8 Nov 2018 02:15:57 -0800 Subject: [PATCH 3/4] Added new sensor attributes --- inc/saiswitch.h | 20 ++++++++++- stub/src/stub_sai_switch.c | 68 +++++++++++++++++++++++++++++++++++--- 2 files changed, 82 insertions(+), 6 deletions(-) diff --git a/inc/saiswitch.h b/inc/saiswitch.h index a8331ffa0..5fd1e24cc 100644 --- a/inc/saiswitch.h +++ b/inc/saiswitch.h @@ -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 @@ -418,7 +436,7 @@ typedef enum _sai_switch_attr_t * @type sai_int32_t * @flags READ_ONLY */ - SAI_SWITCH_ATTR_CURRENT_TEMP, + SAI_SWITCH_ATTR_AVERAGE_TEMP, /** * @brief Minimum priority for ACL table diff --git a/stub/src/stub_sai_switch.c b/stub/src/stub_sai_switch.c index a8afc4523..05185970d 100644 --- a/stub/src/stub_sai_switch.c +++ b/stub/src/stub_sai_switch.c @@ -49,12 +49,22 @@ 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_current_temp_get(_In_ const sai_object_key_t *key, +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, @@ -195,9 +205,13 @@ 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_U32 }, + { 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_CURRENT_TEMP, false, false, false, true, + { 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 }, @@ -284,15 +298,25 @@ 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_CURRENT_TEMP, + { SAI_SWITCH_ATTR_AVERAGE_TEMP, { false, false, false, true }, { false, false, false, true }, - stub_switch_current_temp_get, NULL, + stub_switch_average_temp_get, NULL, NULL, NULL }, { SAI_SWITCH_ATTR_ACL_TABLE_MINIMUM_PRIORITY, { false, false, false, true }, @@ -858,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, @@ -876,7 +934,7 @@ sai_status_t stub_switch_max_temp_get(_In_ const sai_object_key_t *key, /* 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, +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, From 80036413ce13312ed3b7722a65b4311326813911 Mon Sep 17 00:00:00 2001 From: PADMANABHAN NARAYANAN Date: Thu, 8 Nov 2018 08:20:38 -0800 Subject: [PATCH 4/4] Change SAI_SWITCH_ATTR_MAX_NUMBER_OF_TEMP_SENSORS to U8 --- stub/src/stub_sai_switch.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stub/src/stub_sai_switch.c b/stub/src/stub_sai_switch.c index 05185970d..971e750c2 100644 --- a/stub/src/stub_sai_switch.c +++ b/stub/src/stub_sai_switch.c @@ -206,7 +206,7 @@ static const sai_attribute_entry_t switch_attribs[] = { { 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_U32 }, + "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,