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

Switch SER Callback and Log Info #1307

Closed
wants to merge 4 commits into from
Closed
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
157 changes: 157 additions & 0 deletions inc/saiswitch.h
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,140 @@ 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,
JaiOCP marked this conversation as resolved.
Show resolved Hide resolved

/**
* @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,

/**
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this meant to be "all other soft error types"? If so, how does it differ from UNKNOWN? (if not, what is it?)

* @brief All soft error types
*/
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,
JaiOCP marked this conversation as resolved.
Show resolved Hide resolved

/**
* @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,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you clarify if error is corrected or not?

} sai_switch_correction_type_t;

/**
* @brief Soft error recovery flag information
*
* Note enum values must be powers of 2 to be used as bit mask
*
* @flags Contains flags
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you will need to change this to "@flags strict"

*/
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
JaiOCP marked this conversation as resolved.
Show resolved Hide resolved
*/
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.
*/
typedef struct _sai_switch_ser_info_t
{
/**
* @brief Error detected time
JaiOCP marked this conversation as resolved.
Show resolved Hide resolved
*/
uint32_t time;

/**
* @brief Soft error recovery log info flags
*/
sai_switch_ser_log_t flags;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be uint32_t if this will be combination of flags ? currently we have similar thing in stats_mode flags

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


/**
* @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
Expand Down Expand Up @@ -2695,6 +2829,17 @@ typedef enum _sai_switch_attr_t
*/
SAI_SWITCH_ATTR_IPSEC_SA_STATUS_CHANGE_NOTIFY,

/*
* @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
*/
Expand Down Expand Up @@ -2929,6 +3074,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)(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this include the switch_id in the callback?

_In_ uint32_t count,
_In_ const sai_switch_ser_info_t *data);

/**
* @brief Platform specific device register read access
*
Expand Down
1 change: 1 addition & 0 deletions meta/saisanitycheck.c
Original file line number Diff line number Diff line change
Expand Up @@ -5124,6 +5124,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);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need for this change, i updated sainitycheck to use flags enum type


size_t i = 0;

Expand Down
8 changes: 8 additions & 0 deletions meta/saiserializetest.c
Original file line number Diff line number Diff line change
Expand Up @@ -1415,6 +1415,14 @@ 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));
data3.flags = SAI_SWITCH_SER_LOG_MEM;

res = sai_serialize_switch_ser_event_notification(buf, 1, &data3);
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;
memset(&data2, 0, sizeof(data2));

Expand Down