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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

kcudnik
Copy link
Collaborator

@kcudnik kcudnik commented Oct 9, 2024

Bring back compatibility with old structure.

So we are actually in luck, since sizeof(sai_port_oper_status_notification_t) == 16, because of port_id being 64 bit aligned, also as sizeof(sai_extended_port_oper_status_notification_t) == 16, which means we maybe don't need this PR

@kcudnik
Copy link
Collaborator Author

kcudnik commented Oct 31, 2024

Ok below is explanation with some examples:

before SAI version v1.15, sai_port_oper_status_notification_t structure was containing 2 members, port_id and port_state.

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:

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:

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;

what could be used like this:

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
    data.port_error_status = zzz; // new bitmap field

   fn(1, &data); // callback
}

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 let's use new extended notification type like this:

// 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; // oif 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
}

@kcudnik
Copy link
Collaborator Author

kcudnik commented Oct 31, 2024

@JaiOCP please take a look

@JaiOCP
Copy link
Contributor

JaiOCP commented Nov 4, 2024

@JaiOCP please take a look

Looks good to me


/** 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;
Copy link
Contributor

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?

Copy link
Collaborator Author

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

Copy link
Collaborator Author

@kcudnik kcudnik Nov 18, 2024

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 ?

@tjchadaga tjchadaga added the reviewed PR is discussed in SAI Meeting label Nov 6, 2024
@kcudnik kcudnik marked this pull request as ready for review November 10, 2024 11:25
@JaiOCP
Copy link
Contributor

JaiOCP commented Nov 18, 2024 via email

@kcudnik
Copy link
Collaborator Author

kcudnik commented Nov 19, 2024

i will create documentation for this

Bring back compatybility with old structure
@kcudnik
Copy link
Collaborator Author

kcudnik commented Nov 19, 2024

yes, I am ok to leave it here as long as there is an example workflow captured in md doc for future additions.

@JaiOCP please check, i added documentation md file to this PR, basically it's the same as ahttps://github.com//pull/2087#issuecomment-2450236051 and i preserved port_error_status field in extended structure, so by default attr_count passed should be zero

@JaiOCP
Copy link
Contributor

JaiOCP commented Nov 19, 2024

yes, I am ok to leave it here as long as there is an example workflow captured in md doc for future additions.

@JaiOCP please check, i added documentation md file to this PR, basically it's the same as ahttps://github.com//pull/2087#issuecomment-2450236051 and i preserved port_error_status field in extended structure, so by default attr_count passed should be zero

Thank You. This looks good

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature reviewed PR is discussed in SAI Meeting
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants