Added checks to only enable HA set actor state update after HA set table entry is programmed#205
Merged
zjswhhh merged 1 commit intoJul 14, 2026
Conversation
…ble entry is programmed Signed-off-by: BYGX-wcr <wcr@live.cn>
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
Contributor
|
@yue-fred-gao @dypet - please help review. |
yue-fred-gao
approved these changes
Jul 8, 2026
There was a problem hiding this comment.
Pull request overview
This PR tightens HA actor sequencing in hamgrd to prevent a dependent HA scope actor from programming DASH_HA_SCOPE_TABLE before the corresponding DASH_HA_SET_TABLE entry exists on the DPU. It does this by ensuring the HA set actor only advertises HaSetActorState (the gating signal consumed by HA scope actors) after it has issued the DASH_HA_SET_TABLE write.
Changes:
- Added
dash_ha_set_programmedtoHaSetActorand gateHaSetActorStateregistration replies until the HA set table write has been issued. - Set/reset the flag in the HA set table update/delete paths to re-establish gating when the entry is removed.
- Documented in the NPU HA scope state machine that
HaSetActorStatenow serves as the “HA set programmed” ack for safely driving the scope state machine.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| crates/hamgrd/src/actors/ha_set.rs | Adds “programmed” gating so HaSetActorState is only emitted/replied after issuing the DASH_HA_SET_TABLE write, preventing premature scope programming. |
| crates/hamgrd/src/actors/ha_scope/npu.rs | Adds clarifying comment tying scope state-machine gating to the HA set actor’s post-programming HaSetActorState ack. |
Comment on lines
+896
to
+904
| // Only reply with the HaSetActorState ack once the DASH_HA_SET_TABLE entry has | ||
| // actually been programmed. A registration arriving before programming must not | ||
| // hand the HA scope actor an ha-set state it could act on prematurely (which would | ||
| // let it program DASH_HA_SCOPE_TABLE before the HA set entry exists). The HA scope | ||
| // will receive the state later via update_dash_ha_set_table once it is programmed. | ||
| if !self.dash_ha_set_programmed { | ||
| debug!("DASH_HA_SET_TABLE not programmed yet. Defer HaSetActorState reply to registration"); | ||
| return Ok(()); | ||
| } |
zjswhhh
approved these changes
Jul 14, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description of PR
Summary:
Ensure the DPU's
DASH_HA_SCOPE_TABLEentry is never programmed before theDASH_HA_SET_TABLEentry it depends on. The HA set actor now only advertises itsHaSetActorState(the signal every HA scope actor gates on) after it hasprogrammed the
DASH_HA_SET_TABLEentry, so a dependent HA scope actor cannot driveits state machine — and program
DASH_HA_SCOPE_TABLE(including the initialdeadrole) — until the HA set entry exists.
Fixes # (issue) sonic-net/sonic-buildimage#28073
Background / where to start reviewing:
crates/hamgrd/src/actors/ha_set.rs:the new
dash_ha_set_programmedflag onHaSetActorand the gating inhandle_haset_state_registration.crates/hamgrd/src/actors/ha_scope/npu.rs:the clarifying comment on the existing
get_hasetgate indrive_npu_state_machine.Dependencies: none.
Type of change
Approach
What is the motivation for this PR?
During a DPU reboot test on a SmartSwitch testbed, the initial
DASH_HA_SCOPE_TABLEentry (with thedeadrole) wasobserved being programmed before the initial
DASH_HA_SET_TABLEentry that itreferences. The DPU expects the HA set entry to exist before the HA scope entry, so
this ordering is incorrect.
Root cause: the HA scope actor only needs the in-memory
HaSetActorStatemessage todrive its state machine and program
DASH_HA_SCOPE_TABLE— it does not check whetherthe HA set actor has actually written
DASH_HA_SET_TABLEto the DPU. ThatHaSetActorStatecould be delivered via the registration-reply path(
HaSetActor::handle_haset_state_registration), which replies with the cached statewithout ever programming
DASH_HA_SET_TABLE. As a result the HA scope actor couldprogram its (dead-role) scope entry before the HA set entry was written. The two
tables are also written by two independent actors through two independent
ConsumerBridgeinstances, so there is no inherent ordering guarantee between them.How did you do it?
dash_ha_set_programmed: boolfield toHaSetActor.trueinupdate_dash_ha_set_tableimmediately after theDASH_HA_SET_TABLEwrite is issued to the DPU (and before theHaSetActorStateisemitted to registered HA scope actors). Reset it to
falseindelete_dash_ha_set_tableso scopes wait again if the entry is removed.handle_haset_state_registration, defer theHaSetActorStatereply untildash_ha_set_programmedistrue. A registration that arrives before programmingno longer hands the HA scope actor a state it could act on prematurely; the HA scope
is instead notified later (proactively) via
update_dash_ha_set_tableonce the entryis programmed. Because the registration record persists in the HA set actor's
incoming state, no re-registration/retry is required from the scope.
drive_npu_state_machinewhenget_hasetreturnsNone. Added a comment theredocumenting that the presence of
HaSetActorStatenow means "the HA set entry isprogrammed," so the machine only functions after the ack.
Note: this change lives in the shared HA set actor, so it applies consistently to both
the NPU-driven and DPU-driven HA scope actors (both gate on receiving
HaSetActorState). No behavioral regression for DPU-driven mode — it gets the sameordering guarantee.
Known limitation: "programmed" here means the HA set actor has issued the
producer-bridge write, not that it has been confirmed applied in the DPU APPL_DB. The
actor framework does not surface producer-bridge write acks back into actor logic, so a
true end-to-end APPL_DB write confirmation would require additional plumbing in
swbus-actor. This change removes the actual race that was hit (the registration-replypath, which programmed nothing) and orders the two writes correctly in the normal path.
How did you verify/test it?
hamgrdunit test suite:cargo test -p hamgrd— 41 tests pass,including all
ha_setand NPU/DPU-drivenha_scopetests.cargo fmtandcargo clippy -p hamgrd --all-targetsare clean (no new warnings).across all
dash-hadpu0..3containers, followedby
config reload, to validate the corrected ordering during the DPU reboot test.Any platform specific information?
SmartSwitch / DASH HA only. Affects
hamgrdbehavior on the switch NPU and the DPUDASH_HA_SET_TABLE/DASH_HA_SCOPE_TABLEprogramming order.Documentation
No documentation/Wiki changes required. Behavior is internal to
hamgrdactorsequencing and does not change any external API or schema.