Skip to content

[sai] Adopt pre-existing port serdes on SAI_STATUS_ITEM_ALREADY_EXISTS - #1484

Open
AnantKishorSharma wants to merge 1 commit into
facebook:mainfrom
AnantKishorSharma:sai-port-serdes-adopt-item-already-exists
Open

[sai] Adopt pre-existing port serdes on SAI_STATUS_ITEM_ALREADY_EXISTS#1484
AnantKishorSharma wants to merge 1 commit into
facebook:mainfrom
AnantKishorSharma:sai-port-serdes-adopt-item-already-exists

Conversation

@AnantKishorSharma

@AnantKishorSharma AnantKishorSharma commented Aug 7, 2026

Copy link
Copy Markdown

Summary

On cold-boot config apply, SaiPortManager may recreate a port via
changePortByRecreate() 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_serdes then fails with
SAI_STATUS_ITEM_ALREADY_EXISTS. Because the SaiObjectStore holds no handle
for the serdes (on XGS the serdes is not reloaded from the adapter beforehand),
the error propagates as an uncaught SaiApiError and aborts the HW agent during
initialization.

Fix

When the serdes create returns SAI_STATUS_ITEM_ALREADY_EXISTS, adopt the
pre-existing hardware serdes: reload it into the store from the port's
SerdesId and re-apply the desired attributes. This reuses the
getAttribute(SerdesId) + reloadObject() idiom already used in
programSerdes() on the non-XGS reload path. On implementations that remove the
serdes together with its port, create never returns ITEM_ALREADY_EXISTS, so
there 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_switch
mode: the HW agent aborted during init in
SaiPortManager::programSerdes() -> changePortByRecreate() with
[port] Failed to create sai entity PortSerdes...: ITEM ALREADY EXISTS. With
this change the existing serdes is adopted instead of aborting.

@meta-cla

meta-cla Bot commented Aug 7, 2026

Copy link
Copy Markdown

Hi @AnantKishorSharma!

Thank you for your pull request and welcome to our community.

Action Required

In 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.

Process

In 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 CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

@AnantKishorSharma
AnantKishorSharma marked this pull request as ready for review August 7, 2026 16:18
@AnantKishorSharma
AnantKishorSharma requested a review from a team as a code owner August 7, 2026 16:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant