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

Introduce new extended port oper status notification #2087

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
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
55 changes: 54 additions & 1 deletion inc/saiport.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,48 @@ typedef struct _sai_port_oper_status_notification_t
/** Port operational status */
sai_port_oper_status_t port_state;

} sai_port_oper_status_notification_t;

/**
* @brief Defines the extended operational status of the port
*
* Any additional data will must be passed on attributes list. Usually that
* will be port attributes that are READ_ONLY and the value will represent the
* state of given attribute for port_id object at the time that notification
* was generated.
*
* @count attr_list[attr_count]
*/
typedef struct _sai_extended_port_oper_status_notification_t
{
/**
* @brief Port id.
*
* @objects SAI_OBJECT_TYPE_PORT, SAI_OBJECT_TYPE_BRIDGE_PORT, SAI_OBJECT_TYPE_LAG
*/
sai_object_id_t port_id;

/** Port operational status */
sai_port_oper_status_t port_state;

/** Bitmap of various port error or fault status */
sai_port_error_status_t port_error_status;
} sai_port_oper_status_notification_t;

/** Attributes count */
uint32_t attr_count;

/**
* @brief Attributes
*
* Object type NULL specifies that attribute list is for object type
* specified in port_id field. For example if port_id field contains LAG
* object then list of attributes contains SAI_LAG_ATTR_* attributes.
*
* @objects SAI_OBJECT_TYPE_NULL
*/
sai_attribute_t *attr_list;

} sai_extended_port_oper_status_notification_t;

/**
* @brief Attribute data for #SAI_PORT_ATTR_GLOBAL_FLOW_CONTROL_MODE
Expand Down Expand Up @@ -3502,6 +3541,20 @@ typedef void (*sai_port_state_change_notification_fn)(
_In_ uint32_t count,
_In_ const sai_port_oper_status_notification_t *data);

/**
* @brief Extended port state change notification
*
* Passed as a parameter into sai_initialize_switch()
*
* @count data[count]
*
* @param[in] count Number of notifications
* @param[in] data Array of port operational status
*/
typedef void (*sai_extended_port_state_change_notification_fn)(
_In_ uint32_t count,
_In_ const sai_extended_port_oper_status_notification_t *data);

/**
* @brief Port host tx ready notification
*
Expand Down
14 changes: 14 additions & 0 deletions inc/saiswitch.h
Original file line number Diff line number Diff line change
Expand Up @@ -3070,6 +3070,20 @@ typedef enum _sai_switch_attr_t
*/
SAI_SWITCH_ATTR_SELECTIVE_COUNTER_LIST,

/**
* @brief Extended port state change notification callback function passed to the adapter.
*
* In case driver does not support this attribute, The Host adapter should poll
* port status by SAI_PORT_ATTR_OPER_STATUS.
*
* Use sai_extended_port_state_change_notification_fn as notification function.
*
* @type sai_pointer_t sai_extended_port_state_change_notification_fn
* @flags CREATE_AND_SET
* @default NULL
*/
SAI_SWITCH_ATTR_EXTENDED_PORT_STATE_CHANGE_NOTIFY,

/**
* @brief End of attributes
*/
Expand Down
1 change: 1 addition & 0 deletions meta/saisanitycheck.c
Original file line number Diff line number Diff line change
Expand Up @@ -5983,6 +5983,7 @@ void check_struct_and_union_size()
CHECK_STRUCT_SIZE(sai_port_snr_list_t, 16);
CHECK_STRUCT_SIZE(sai_port_snr_values_t, 8);
CHECK_STRUCT_SIZE(sai_port_oper_status_notification_t, 16);
CHECK_STRUCT_SIZE(sai_extended_port_oper_status_notification_t, 32);
CHECK_STRUCT_SIZE(sai_prbs_rx_state_t, 8);
CHECK_STRUCT_SIZE(sai_qos_map_list_t, 16);
CHECK_STRUCT_SIZE(sai_qos_map_params_t, 16);
Expand Down
9 changes: 8 additions & 1 deletion meta/saiserializetest.c
Original file line number Diff line number Diff line change
Expand Up @@ -1412,7 +1412,14 @@ void test_serialize_notifications()
memset(&data1, 0, sizeof(data1));

res = sai_serialize_port_state_change_notification(buf, 1, &data1);
ret = "{\"count\":1,\"data\":[{\"port_id\":\"oid:0x0\",\"port_state\":\"SAI_PORT_OPER_STATUS_UNKNOWN\",\"port_error_status\":\"SAI_PORT_ERROR_STATUS_CLEAR\"}]}";
ret = "{\"count\":1,\"data\":[{\"port_id\":\"oid:0x0\",\"port_state\":\"SAI_PORT_OPER_STATUS_UNKNOWN\"}]}";
ASSERT_STR_EQ(buf, ret , res);

sai_extended_port_oper_status_notification_t data1e;
memset(&data1e, 0, sizeof(data1e));

res = sai_serialize_extended_port_state_change_notification(buf, 1, &data1e);
ret = "{\"count\":1,\"data\":[{\"port_id\":\"oid:0x0\",\"port_state\":\"SAI_PORT_OPER_STATUS_UNKNOWN\",\"port_error_status\":\"SAI_PORT_ERROR_STATUS_CLEAR\",\"attr_count\":0,\"attr_list\":null}]}";
ASSERT_STR_EQ(buf, ret , res);

sai_queue_deadlock_notification_data_t data2;
Expand Down
11 changes: 9 additions & 2 deletions meta/structs.pl
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,15 @@ sub BuildCommitHistory

if ($histCount > $currCount)
{
LogError "FATAL: $structTypeName members were removed on commit $commit, NOT ALLOWED!";
exit 1;
if ($structTypeName eq "sai_port_oper_status_notification_t")
{
# we allow this to change back backward compatibility
}
else
{
LogError "FATAL: $structTypeName members were removed on commit $commit, NOT ALLOWED!";
exit 1;
}
}

my $minCount = ($histCount > $currCount) ? $currCount : $histCount;
Expand Down
Loading