[Celestica] Leh800bcls: Support NPU-specific yamlConfig to allow differing polarity settings on multi-NPU platforms#1350
Conversation
| } | ||
| } | ||
| if (yamlConfig.empty()) { | ||
| yamlConfig = asicConfig.common()->get_yamlConfig(); |
There was a problem hiding this comment.
what if common yamlConfig is set to "". Then there will be no throw and code will not fallback to bcm yaml config
There was a problem hiding this comment.
Excellent point!
Added a check if (yamlConfig.empty()) { throw FbossError(...); } right after the fallback.
If the common entry is explicitly set to "", it successfully deserializes without throwing, but yamlConfig remains empty. The subsequent yamlConfig.empty() check will evaluate to true and explicitly throw FbossError, safely triggering the outer catch block to fall back to bcm.yamlConfig().
will update soon.
| cfg::AsicConfigEntry::Type::yamlConfig) { | ||
| XLOG(INFO) << "Loading NPU-specific yamlConfig for switchIndex=" | ||
| << switchIndex; | ||
| yamlConfig = npuEntry->second.get_yamlConfig(); |
There was a problem hiding this comment.
what if this code block throws? you have a single catch try for multiple errors. if per npu entry is not present, you should use the common entry. if common entry is also not present, you should fallback to the bcm yaml
There was a problem hiding this comment.
Thanks for the great catch!
To address your concerns, I have wrapped the npuEntries loading in a nested try-catch block. If NPU entries throw or are missing, the code now safely logs a warning and still proceeds to attempt the common configuration rather than skipping directly to bcm.yamlConfig.
will update soon.
| yamlConfig = npuEntry->second.get_yamlConfig(); | ||
| } else { | ||
| XLOG(INFO) << "No NPU-specific yamlConfig found for switchIndex=" | ||
| << switchIndex << ", falling back to common config"; |
There was a problem hiding this comment.
what if there is no common config?
There was a problem hiding this comment.
Excellent point!
I've added a defensive union type check (getType() == Type::yamlConfig) before accessing common to avoid potential bad_field_access crashes. If both NPU-specific and common configs are missing or invalid, we now explicitly throw FbossError to safely trigger the outer fallback to bcm.yamlConfig.
code will update soon.
…ering polarity settings on multi-NPU platforms
e643d0b to
45a9fa8
Compare
|
@msomasundaran Thank you very much for your review. I have made the modifications based on your comments. Currently, the code has been tested separately, and it can be fully ported up using both the distinct YAML configurations for the two NPUs and the shared common YAML configuration. |
Pre-submission checklist
pip install -r requirements-dev.txt && pre-commit installpre-commit runclang-format.............................................................Passed
shellcheck...........................................(no files to check)Skipped
shfmt................................................(no files to check)Skipped
trim trailing whitespace.................................................Passed
fix end of files.........................................................Passed
check yaml...........................................(no files to check)Skipped
check json...........................................(no files to check)Skipped
check for merge conflicts................................................Passed
ruff check...........................................(no files to check)Skipped
ruff format..........................................(no files to check)Skipped
Prevent sai_impl in fboss manifest.......................................Passed
Summary
Support NPU-specific
yamlConfigloading on multi-NPU platforms (likeleh800bcls) to allow differing hardware configurations (such as distinct PHY polarities) per NPU.Background
Due to hardware routing and layout differences on the new dual-NPU
leh800bclsplatform, NPU 0 and NPU 1 require different polarity settings (RX_POLARITY_FLIPandTX_POLARITY_FLIPin HSDK'syamlConfig).Previously,
SaiBcmPlatform::getHwConfig()always loaded configuration fromasicConfig.common()->get_yamlConfig(), forcing both NPUs to apply the exact same hardware YAML settings. Under split agent setups, this makes it impossible to configure distinct polarities for different NPUs.Changes
Refactored
SaiBcmPlatform::getHwConfig()infboss/agent/platforms/sai/SaiBcmPlatform.cpp:- Retrieve the current platform's active logic switch index via the first-class
HwAsicAPIgetAsic()->getSwitchIndex(). This is guaranteed to be populated on both split agent test runners and unified software agents (e.g.fboss_sw_agent).- Query the
npuEntriesmap inPlatformConfigusing the switch index.- If an NPU-specific entry is found and of type
cfg::AsicConfigEntry::Type::yamlConfig, extract and load its correspondingyamlConfig.- Fall back to
asicConfig.common()->get_yamlConfig()if no NPU-specific configuration is specified.Test Plan