[sai] Adopt pre-existing port serdes on SAI_STATUS_ITEM_ALREADY_EXISTS - #1484
Conversation
|
Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks! |
Summary
On cold-boot config apply,
SaiPortManagermay recreate a port viachangePortByRecreate()when a create-only attribute (e.g. lane or speed)differs from the port the SAI switch created by default. The recreate removes
the old SAI port and adds a new one, which programs a new port serdes.
Some SAI implementations do not remove the port serdes object when its parent
port is removed. On the subsequent recreate,
programSerdes()->store.setObject()->create_port_serdesthen fails withSAI_STATUS_ITEM_ALREADY_EXISTS. Because theSaiObjectStoreholds no handlefor the serdes (on XGS the serdes is not reloaded from the adapter beforehand),
the error propagates as an uncaught
SaiApiErrorand aborts the HW agent duringinitialization.
Fix
When the serdes create returns
SAI_STATUS_ITEM_ALREADY_EXISTS, adopt thepre-existing hardware serdes: reload it into the store from the port's
SerdesIdand re-apply the desired attributes. This reuses thegetAttribute(SerdesId)+reloadObject()idiom already used inprogramSerdes()on the non-XGS reload path. On implementations that remove theserdes together with its port, create never returns
ITEM_ALREADY_EXISTS, sothere is no behavior change. Both serdes create sites go through a small
setSerdesObject()helper.Test Plan
Reproduced on a xgs platform running the agent HW test in
multi_switchmode: the HW agent aborted during init in
SaiPortManager::programSerdes()->changePortByRecreate()with[port] Failed to create sai entity PortSerdes...: ITEM ALREADY EXISTS. Withthis change the existing serdes is adopted instead of aborting.