Skip to content

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

Open
ksravani-hcl wants to merge 1 commit into
sonic-net:masterfrom
ksravani-hcl:gautam_1
Open

[Generic-P4Orch] Add infra of supporting unique label to be used for SAI label attribute.#4176
ksravani-hcl wants to merge 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

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.

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 draft May 15, 2026 12:07
mint570
mint570 previously approved these changes May 15, 2026
Comment thread orchagent/orchdaemon.cpp
@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

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

mint570
mint570 previously approved these changes May 29, 2026
@ksravani-hcl

Copy link
Copy Markdown
Author

@prsunny, can you please review this PR.

@ksravani-hcl ksravani-hcl marked this pull request as ready for review June 2, 2026 05:24
@prsunny

prsunny commented Jun 2, 2026

Copy link
Copy Markdown
Collaborator

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

@prsunny

prsunny commented Jun 2, 2026

Copy link
Copy Markdown
Collaborator

@mint570 for viz

@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).

@prsunny

prsunny commented Jun 9, 2026

Copy link
Copy Markdown
Collaborator

@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

@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
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!

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