From c75db43fcf2b700aee5941e03c46ff4ad0e36bab Mon Sep 17 00:00:00 2001 From: Jai Kumar Date: Tue, 14 Sep 2021 11:53:02 -0700 Subject: [PATCH 1/3] Switch SER Error Handler Signed-off-by: Jai Kumar --- inc/saiswitch.h | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/inc/saiswitch.h b/inc/saiswitch.h index 7d8498519..01a547f67 100644 --- a/inc/saiswitch.h +++ b/inc/saiswitch.h @@ -400,6 +400,37 @@ typedef enum _sai_tunnel_decap_ecn_mode_t } sai_tunnel_decap_ecn_mode_t; +/** + * @brief SAI switch soft error recovery error type. + */ +typedef enum _sai_switch_soft_error_type_t +{ + /** + * @brief Unknown error type + */ + SAI_SWITCH_SOFT_ERROR_TYPE_UNKNOWN = 0, + + /** + * @brief Parity error + */ + SAI_SWITCH_SOFT_ERROR_TYPE_PARITY = 1, + + /** + * @brief ECC single bit error + */ + SAI_SWITCH_SOFT_ERROR_TYPE_ECC_SINGLE_BIT = 2, + + /** + * @brief ECC double bit error + */ + SAI_SWITCH_SOFT_ERROR_TYPE_ECC_DOUBLE_BIT = 3, + + /** + * @brief All soft error types + */ + SAI_SWITCH_SOFT_ERROR_TYPE_ALL = 4 +} sai_switch_soft_error_type_t; + /** * @brief Defines tunnel attributes at switch level. * SAI_OBJECT_TYPE_SWITCH_TUNNEL object provides From fd499607115a3c87450232394b972b2960ff561d Mon Sep 17 00:00:00 2001 From: Jai Kumar Date: Tue, 14 Sep 2021 15:06:43 -0400 Subject: [PATCH 2/3] SER Error Handling Signed-off-by: Jai Kumar --- inc/saiswitch.h | 94 +++++++++++++++++++++++++++++++++++++++++ meta/saiserializetest.c | 7 +++ 2 files changed, 101 insertions(+) diff --git a/inc/saiswitch.h b/inc/saiswitch.h index 01a547f67..72d6eef23 100644 --- a/inc/saiswitch.h +++ b/inc/saiswitch.h @@ -431,6 +431,77 @@ typedef enum _sai_switch_soft_error_type_t SAI_SWITCH_SOFT_ERROR_TYPE_ALL = 4 } sai_switch_soft_error_type_t; +/** + * @brief SAI switch soft error recovery error correction type. + */ +typedef enum _sai_switch_correction_type_t +{ + /** + * @brief S/W takes no action when error + * happens (Like some working memories) + */ + SAI_SWITCH_CORRECTION_TYPE_NO_ACTION = 0, + + /** + * @brief S/W tries to correct error but fails + */ + SAI_SWITCH_CORRECTION_TYPE_FAIL_TO_CORRECT = 1, + + /** + * @brief S/W writes NULL entry to clear the error + */ + SAI_SWITCH_CORRECTION_TYPE_ENTRY_CLEAR = 2, + + /** + * @brief Restore entry from a valid S/W cache + */ + SAI_SWITCH_CORRECTION_TYPE_CACHE_RESTORE = 3, + + /** + * @brief Restore entry from another pipe + */ + SAI_SWITCH_CORRECTION_TYPE_HW_CACHE_RESTORE = 4, + + /** + * @brief Memory needs special correction handling + */ + SAI_SWITCH_CORRECTION_TYPE_SPECIAL = 5, +} sai_switch_correction_type_t; + +/* soft error recovery log info flags */ +#define SAI_SWITCH_SER_LOG_MEM 0x00000001 /* Error happens on memory */ +#define SAI_SWITCH_SER_LOG_REG 0x00000002 /* Error happens on register */ +#define SAI_SWITCH_SER_LOG_MULTI 0x00000004 /* Parity errors detected more than once */ +#define SAI_SWITCH_SER_LOG_CORRECTED 0x00000008 /* Error be corrected by S/W */ +#define SAI_SWITCH_SER_LOG_ENTRY 0x00000010 /* Corrupt memory entry data is read in logfile */ +#define SAI_SWITCH_SER_LOG_CACHE 0x00000020 /* Cache data is valid */ + +/** + * @brief SAI switch soft error recovery info. + */ +typedef struct _sai_switch_ser_info_t +{ + /** + * @brief Error detected time + */ + uint32_t time; + + /** + * @brief Soft error recovery log info flags + */ + uint32_t flags; + + /** + * @brief Soft error type + */ + sai_switch_soft_error_type_t soft_error_type; + + /** + * @brief Correction type + */ + sai_switch_correction_type_t correction_type; +} sai_switch_ser_info_t; + /** * @brief Defines tunnel attributes at switch level. * SAI_OBJECT_TYPE_SWITCH_TUNNEL object provides @@ -2683,6 +2754,17 @@ typedef enum _sai_switch_attr_t */ SAI_SWITCH_ATTR_QOS_MPLS_EXP_TO_FORWARDING_CLASS_MAP, + /** + * @brief Parity Errors + * + * Use sai_switch_ser_event_notification_fn as notification function. + * + * @type sai_pointer_t sai_switch_ser_event_notification_fn + * @flags CREATE_AND_SET + * @default NULL + */ + SAI_SWITCH_ATTR_SWITCH_SER_EVENT_NOTIFY, + /** * @brief End of attributes */ @@ -2917,6 +2999,18 @@ typedef void (*sai_switch_state_change_notification_fn)( _In_ sai_object_id_t switch_id, _In_ sai_switch_oper_status_t switch_oper_status); +/** + * @brief Switch soft error recovery event callback + * + * @count data[count] + * + * @param[in] count Number of notifications + * @param[in] data Array of soft error recovery event types + */ +typedef void (*sai_switch_ser_event_notification_fn)( + _In_ uint32_t count, + _In_ const sai_switch_ser_info_t *data); + /** * @brief Platform specific device register read access * diff --git a/meta/saiserializetest.c b/meta/saiserializetest.c index 740fd2dbb..b1d9ca235 100644 --- a/meta/saiserializetest.c +++ b/meta/saiserializetest.c @@ -1367,6 +1367,13 @@ void test_serialize_notifications() ret = "{\"count\":1,\"data\":[{\"port_id\":\"oid:0x0\",\"port_state\":\"SAI_PORT_OPER_STATUS_UNKNOWN\"}]}"; ASSERT_STR_EQ(buf, ret , res); + sai_switch_ser_info_t data3; + memset(&data3, 0, sizeof(data3)); + + res = sai_serialize_switch_ser_event_notification(buf, 1, &data3); + ret = "{\"count\":1,\"data\":[{\"time\":0,\"flags\":0,\"soft_error_type\":\"SAI_SWITCH_SOFT_ERROR_TYPE_UNKNOWN\",\"correction_type\":\"SAI_SWITCH_CORRECTION_TYPE_NO_ACTION\"}]}"; + ASSERT_STR_EQ(buf, ret, res); + sai_queue_deadlock_notification_data_t data2; memset(&data2, 0, sizeof(data2)); From ddf25999d43ec08e779565759450a3694e52e8d2 Mon Sep 17 00:00:00 2001 From: Jai Kumar Date: Wed, 15 Sep 2021 19:46:41 -0400 Subject: [PATCH 3/3] SER flags defined as enums Signed-off-by: Jai Kumar --- inc/saiswitch.h | 48 ++++++++++++++++++++++++++++++++++------- meta/saisanitycheck.c | 1 + meta/saiserializetest.c | 3 ++- 3 files changed, 43 insertions(+), 9 deletions(-) diff --git a/inc/saiswitch.h b/inc/saiswitch.h index 72d6eef23..b7a8c3485 100644 --- a/inc/saiswitch.h +++ b/inc/saiswitch.h @@ -468,13 +468,45 @@ typedef enum _sai_switch_correction_type_t SAI_SWITCH_CORRECTION_TYPE_SPECIAL = 5, } sai_switch_correction_type_t; -/* soft error recovery log info flags */ -#define SAI_SWITCH_SER_LOG_MEM 0x00000001 /* Error happens on memory */ -#define SAI_SWITCH_SER_LOG_REG 0x00000002 /* Error happens on register */ -#define SAI_SWITCH_SER_LOG_MULTI 0x00000004 /* Parity errors detected more than once */ -#define SAI_SWITCH_SER_LOG_CORRECTED 0x00000008 /* Error be corrected by S/W */ -#define SAI_SWITCH_SER_LOG_ENTRY 0x00000010 /* Corrupt memory entry data is read in logfile */ -#define SAI_SWITCH_SER_LOG_CACHE 0x00000020 /* Cache data is valid */ +/** + * @brief Soft error recovery flag information + * + * Note enum values must be powers of 2 to be used as bit mask + * + * @flags Contains flags + */ +typedef enum _sai_switch_ser_log_t +{ + /** + * @brief Error happens on memory + */ + SAI_SWITCH_SER_LOG_MEM = 1 << 0, + + /** + * @brief Error happens on register + */ + SAI_SWITCH_SER_LOG_REG = 1 << 1, + + /** + * @brief Parity errors detected more than once + */ + SAI_SWITCH_SER_LOG_MULTI = 1 << 2, + + /** + * @brief Error be corrected by S/W + */ + SAI_SWITCH_SER_LOG_CORRECTED = 1 << 3, + + /** + * @brief Corrupt memory entry data is provided in log + */ + SAI_SWITCH_SER_LOG_ENTRY = 1 << 4, + + /** + * @brief Cache data is valid + */ + SAI_SWITCH_SER_LOG_CACHE = 1 << 5, +} sai_switch_ser_log_t; /** * @brief SAI switch soft error recovery info. @@ -489,7 +521,7 @@ typedef struct _sai_switch_ser_info_t /** * @brief Soft error recovery log info flags */ - uint32_t flags; + sai_switch_ser_log_t flags; /** * @brief Soft error type diff --git a/meta/saisanitycheck.c b/meta/saisanitycheck.c index 49d3cbb7c..cede7d27b 100644 --- a/meta/saisanitycheck.c +++ b/meta/saisanitycheck.c @@ -5117,6 +5117,7 @@ void check_enum_range_base( SKIP_ENUM(sai_attr_flags_t); SKIP_ENUM(sai_stats_mode_t); + SKIP_ENUM(sai_switch_ser_log_t); size_t i = 0; diff --git a/meta/saiserializetest.c b/meta/saiserializetest.c index b1d9ca235..f94b5b6c4 100644 --- a/meta/saiserializetest.c +++ b/meta/saiserializetest.c @@ -1369,9 +1369,10 @@ void test_serialize_notifications() sai_switch_ser_info_t data3; memset(&data3, 0, sizeof(data3)); + data3.flags = SAI_SWITCH_SER_LOG_MEM; res = sai_serialize_switch_ser_event_notification(buf, 1, &data3); - ret = "{\"count\":1,\"data\":[{\"time\":0,\"flags\":0,\"soft_error_type\":\"SAI_SWITCH_SOFT_ERROR_TYPE_UNKNOWN\",\"correction_type\":\"SAI_SWITCH_CORRECTION_TYPE_NO_ACTION\"}]}"; + ret = "{\"count\":1,\"data\":[{\"time\":0,\"flags\":\"SAI_SWITCH_SER_LOG_MEM\",\"soft_error_type\":\"SAI_SWITCH_SOFT_ERROR_TYPE_UNKNOWN\",\"correction_type\":\"SAI_SWITCH_CORRECTION_TYPE_NO_ACTION\"}]}"; ASSERT_STR_EQ(buf, ret, res); sai_queue_deadlock_notification_data_t data2;