-
Notifications
You must be signed in to change notification settings - Fork 477
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
Open
kcudnik
wants to merge
1
commit into
opencomputeproject:master
Choose a base branch
from
kcudnik:back
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+234
−4
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,148 @@ | ||
Before SAI version v1.15, *sai_port_oper_status_notification_t* structure was containing 2 members, port_id and port_state. | ||
|
||
```C | ||
typedef struct _sai_port_oper_status_notification_t { // v1.14.0 | ||
sai_object_id_t port_id; | ||
sai_port_oper_status_t port_state; | ||
} sai_port_oper_status_notification_t; | ||
``` | ||
|
||
In vendor use case it could be used like this, when notificaiton was created: | ||
|
||
```C | ||
sai_port_state_change_notification_fn fn = ... ; // pointer obtained from SAI_SWITCH_ATTR_PORT_STATE_CHANGE_NOTIFY | ||
|
||
if (fn != NULL) | ||
{ | ||
sai_port_oper_status_notification_t data; // sizeof(data) == 16 | ||
|
||
data.port_id = xxx; // oif of affected port | ||
data.port_state = yyy; // actual port status | ||
|
||
fn(1, &data); // callback | ||
} | ||
``` | ||
|
||
In SAI version v1.15 breaking change was introduced: | ||
|
||
```C | ||
typedef struct _sai_port_oper_status_notification_t { // v1.15.0 | ||
sai_object_id_t port_id; | ||
sai_port_oper_status_t port_state; | ||
sai_port_error_status_t port_error_status; | ||
} sai_port_oper_status_notification_t; | ||
``` | ||
|
||
Which added 3rd field to notification (port_error_status). | ||
|
||
Which could be used like this: | ||
|
||
```C | ||
sai_port_state_change_notification_fn fn = ... ; // pointer obtained from SAI_SWITCH_ATTR_PORT_STATE_CHANGE_NOTIFY | ||
|
||
if (fn != NULL) | ||
{ | ||
sai_port_oper_status_notification_t data; // sizeof(data) == 16 | ||
|
||
data.port_id = xxx; // oid of affected port | ||
data.port_state = yyy; // actual port status | ||
data.port_error_status = zzz; // new bitmap field | ||
|
||
fn(1, &data); // callback | ||
} | ||
``` | ||
|
||
Fortunetly that change didn't change sizeof(sai_port_oper_status_notification_t) == 16, which is not impatcing | ||
sai_port_state_change_notification_fn data pointer, which would cause troubles when iterating over notification | ||
data using next indexes, since allignment of structures would be off. | ||
|
||
Now this is my proposal, we bring back structure sai_port_oper_status_notification_t to as it was in v1.14 | ||
by removing port_error_status field, and introduce attr_count and attr_list fields: | ||
|
||
```C | ||
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; | ||
|
||
/** 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; | ||
``` | ||
|
||
This could be strucutre used from SAI v1.16.0. | ||
Let's use new extended notification type like this: | ||
|
||
```C | ||
// still support previous notification | ||
|
||
sai_port_state_change_notification_fn fn = ... ; // obtained from SAI_SWITCH_ATTR_PORT_STATE_CHANGE_NOTIFY | ||
|
||
if (fn != NULL) | ||
{ | ||
sai_port_oper_status_notification_t data; // sizeof(data) == 16 | ||
|
||
data.port_id = xxx; // oif of affected port | ||
data.port_state = yyy; // actual port status | ||
|
||
fn(1, &data); // callback | ||
} | ||
|
||
// here support new notification | ||
|
||
sai_extended_port_state_change_notification_fn extfn = ...; // pointer obtained from SAI_SWITCH_ATTR_EXTENDED_PORT_STATE_CHANGE_NOTIFY | ||
|
||
if (extfn != NULL) | ||
{ | ||
sai_extended_port_oper_status_notification_t data; | ||
|
||
data.port_id = xxx; // oid of affected port | ||
data.port_state = yyy; // actual port status | ||
data.port_error_status = zzz; // bitmap value of port error status | ||
|
||
sai_attribute_t list[1]; | ||
|
||
// example attribute with value at the time of the event for port_id fired | ||
|
||
list[0].id = SAI_PORT_ATTR_LINK_TRAINING_RX_STATUS; | ||
list[0].value.s32 = SAI_PORT_LINK_TRAINING_FAILURE_STATUS_NO_ERROR; | ||
|
||
data.attr_count = 1; | ||
data.attr_list = list; | ||
|
||
fn(1, &data); // callback for extended notification | ||
} | ||
``` | ||
|
||
With this solution we are still backward compatible with old notification and we also can support new one. | ||
Advantage is that we can add as many new members to the attr_list as we want not breaking compatibility in the | ||
future. | ||
|
||
The only hiccup is that we have 2 breaking changes: | ||
* SAI version v1.14.0 sai_port_oper_status_notification_t have 2 fields (sizeof == 16) | ||
* SAI version v1.15.0 sai_port_oper_status_notification_t have 3 fields (sizeof == 16) - breaking changea - adding port_error_status | ||
* SAI version v1.16.0 sai_port_oper_status_notification_t have 2 fields (sizeof == 16) - breaking change - removing port_error_status | ||
|
||
but we will keep compatibility over all previous and future version for this strucute, and all new extensions would be added in new notification. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we still need this field. Can it be removed and we just the attr count and attr list?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We cna leave it or remove it both ways works fine
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@JaiOCP are you ok to leave this port_error_status here ? since it was main reason to introduce new port status ? and all new future extended attributes will be added in attr count ? or should we start alrady doint it from attr/list ?