Skip to content

Commit

Permalink
Introduce new extended port oper status notification
Browse files Browse the repository at this point in the history
Bring back compatybility with old structure
  • Loading branch information
kcudnik committed Oct 9, 2024
1 parent 5302cbc commit e31fdfc
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 3 deletions.
33 changes: 32 additions & 1 deletion inc/saiport.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,26 @@ 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
*/
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;
} sai_extended_port_oper_status_notification_t;

/**
* @brief Attribute data for #SAI_PORT_ATTR_GLOBAL_FLOW_CONTROL_MODE
Expand Down Expand Up @@ -3496,6 +3513,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, 16);
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
7 changes: 7 additions & 0 deletions meta/saiserializetest.c
Original file line number Diff line number Diff line change
Expand Up @@ -1412,6 +1412,13 @@ 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\"}]}";
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\"}]}";
ASSERT_STR_EQ(buf, ret , res);

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

0 comments on commit e31fdfc

Please sign in to comment.