Skip to content

[Generic-P4Orch] Add infra of supporting unique label to be used for SAI label attribute. - #4176

Merged
prsunny merged 1 commit into
sonic-net:masterfrom
ksravani-hcl:gautam_1
Jul 20, 2026
Merged

[Generic-P4Orch] Add infra of supporting unique label to be used for SAI label attribute.#4176
prsunny merged 1 commit into
sonic-net:masterfrom
ksravani-hcl:gautam_1

Conversation

@ksravani-hcl

@ksravani-hcl ksravani-hcl commented Jan 30, 2026

Copy link
Copy Markdown
Contributor

Description
The main purpose of this helper class(NameLabelMapper) is to create and manage unique labels for SAI objects.
A unique label is a unique string identifier for a SAI object. It is used in warm boot for syncd reconciliation.
A SAI object will need a unique label if the existing SAI attrs cannot distinguish the object from each other.

The high level flow is the following:

  1. Generate a unique label and pass it to the SAI attr when the SAI object is created. For new object, a new label will be generated and added into the NameLabelMapper. For existing object, the saved label will be return from NameLabelMapper.
  2. During warmboot shut down, save the NameLabelMapper into STATE_DB. This STATE_DB table will persist across warm boot. This change will be part of the warm boot upstreaming. (Not in the current PR yet). Notice that label is a SAI attr, and hence it is in ASIC_DB as well, which will persist across warm boot.
  3. During warmboot start up, read the STATE_DB and populate the NameLabelMapper.
  4. During init_view, p4orch will process the requests in APPL_DB. Since NameLabelMapper is already populated, all objects that require labels will use the same labels as before warm boot. Syncd can uniquly identify each SAI object as the label will match in ASIC_DB.

The NameLabelMapper usage document PR is sonic-net/SONiC#2383

What I did
Adding infra of supporting unique label to be used for SAI label attribute.
Implemented the Namelabelmapper utility to map SAI object keys to unique, timestamp-based labels. Integrated this into the Orchdaemon lifecycle, enabling the serialization of these mappings to STATE_DB using the schema SAI_OBJECT_TYPE|KEY to ensure persistent identification.

Why I did it
To provide a reliable mechanism to uniquely identify hardware objects during warm boot reconciliation. This prevents resource duplication and enables orchagent to correctly correlate existing hardware state with control plane requests for hitless upgrades.

How I verified it
Validated the logic with new C++ unit tests covering label allocation and collision prevention. Confirmed the end-to-end persistence flow via successful execution of the SWSS test suite.

Details if related

@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@ksravani-hcl ksravani-hcl changed the title [P4Orch] Add infra of supporting unique label to be used for SAI label attribu… [P4Orch] Add infra of supporting unique label to be used for SAI label attribute. Feb 11, 2026
@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@yunang-c yunang-c left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. @mint570 can you also take a look?

@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@ksravani-hcl ksravani-hcl changed the title [P4Orch] Add infra of supporting unique label to be used for SAI label attribute. [Generic-P4Orch] Add infra of supporting unique label to be used for SAI label attribute. Apr 15, 2026
mint570
mint570 previously approved these changes Apr 17, 2026
@divyagayathri-hcl

Copy link
Copy Markdown
Contributor

@prsunny can you take a look at this PR to see how this can impact upstream SONiC?

@ksravani-hcl
ksravani-hcl marked this pull request as ready for review April 24, 2026 14:28
@ksravani-hcl
ksravani-hcl requested a review from prsunny as a code owner April 24, 2026 14:28
@kishanps

Copy link
Copy Markdown
Contributor

@prsunny Can you please review this PR?
cc: @mint570

@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run

@ksravani-hcl
ksravani-hcl marked this pull request as ready for review June 10, 2026 06:05
@ksravani-hcl
ksravani-hcl marked this pull request as draft June 10, 2026 06:10
@ksravani-hcl
ksravani-hcl marked this pull request as ready for review June 16, 2026 05:54
@ksravani-hcl

ksravani-hcl commented Jun 16, 2026

Copy link
Copy Markdown
Contributor Author

@ksravani-hcl , the namelabel mapper can be a PR by itself and can be used by community. Would you seperate the PR for namelabel mapper, create a doc https://github.com/sonic-net/SONiC on the usage and purpose so that community can use it for future.

@ksravani-hcl , thanks for splitting the PR to have namelabel mapper. Please create the doc for usage examples and schematics

@prsunny, As you suggested, the NameLabelMapper usage document is prepared and raised as a document PR sonic-net/SONiC#2383, and we have updated the description of this PR with more details, can you please review and approve these PRs.
Thank you!

@ksravani-hcl

Copy link
Copy Markdown
Contributor Author

@ksravani-hcl , the namelabel mapper can be a PR by itself and can be used by community. Would you seperate the PR for namelabel mapper, create a doc https://github.com/sonic-net/SONiC on the usage and purpose so that community can use it for future.

@ksravani-hcl , thanks for splitting the PR to have namelabel mapper. Please create the doc for usage examples and schematics

@prsunny, As you suggested, the NameLabelMapper usage document is prepared and raised as a document PR sonic-net/SONiC#2383, and we have updated the description of this PR with more details, can you please review and approve these PRs. Thank you!

@prsunny, Could you please review and approve the PR.
Thank you!

@prsunny

prsunny commented Jun 30, 2026

Copy link
Copy Markdown
Collaborator

Thanks, Can you link the doc to description and mark it ready? Also please fix coverage on this PR

@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

prsunny
prsunny previously approved these changes Jun 30, 2026

@prsunny prsunny left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, thanks for doc

@prsunny

prsunny commented Jun 30, 2026

Copy link
Copy Markdown
Collaborator

Related PR - opencomputeproject/SAI#2283

@prsunny

prsunny commented Jun 30, 2026

Copy link
Copy Markdown
Collaborator

@ksravani-hcl , please fix coverage for merge. Changes lgtm

@ksravani-hcl
ksravani-hcl marked this pull request as draft July 6, 2026 16:00
@ksravani-hcl
ksravani-hcl dismissed stale reviews from prsunny and mint570 via 0996d64 July 8, 2026 13:34
@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

Signed-off-by: SRAVANI KANASANI <kanasanis@google.com>
@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@ksravani-hcl
ksravani-hcl marked this pull request as ready for review July 13, 2026 13:07
@ksravani-hcl

Copy link
Copy Markdown
Contributor Author

@prsunny, coverage is fixed, Could you please help to merge this PR.

@prsunny
prsunny merged commit 5397e7c into sonic-net:master Jul 20, 2026
19 checks passed
leenr pushed a commit to leenr/sonic-swss that referenced this pull request Aug 4, 2026
…te. (sonic-net#4176)

Description
The main purpose of this helper class(NameLabelMapper) is to create and manage unique labels for SAI objects.
A unique label is a unique string identifier for a SAI object. It is used in warm boot for syncd reconciliation.
A SAI object will need a unique label if the existing SAI attrs cannot distinguish the object from each other.

The high level flow is the following:

Generate a unique label and pass it to the SAI attr when the SAI object is created. For new object, a new label will be generated and added into the NameLabelMapper. For existing object, the saved label will be return from NameLabelMapper.
During warmboot shut down, save the NameLabelMapper into STATE_DB. This STATE_DB table will persist across warm boot. This change will be part of the warm boot upstreaming. (Not in the current PR yet). Notice that label is a SAI attr, and hence it is in ASIC_DB as well, which will persist across warm boot.
During warmboot start up, read the STATE_DB and populate the NameLabelMapper.
During init_view, p4orch will process the requests in APPL_DB. Since NameLabelMapper is already populated, all objects that require labels will use the same labels as before warm boot. Syncd can uniquly identify each SAI object as the label will match in ASIC_DB.
The NameLabelMapper usage document PR is sonic-net/SONiC#2383

What I did
Adding infra of supporting unique label to be used for SAI label attribute.
Implemented the Namelabelmapper utility to map SAI object keys to unique, timestamp-based labels. Integrated this into the Orchdaemon lifecycle, enabling the serialization of these mappings to STATE_DB using the schema SAI_OBJECT_TYPE|KEY to ensure persistent identification.
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.

7 participants