Skip to content

Commit 521e794

Browse files
Protick Bhowmickmeta-codesync[bot]
authored andcommitted
Fix Agera3 retimer cold-boot crash (uninitialized productInfo + PAI platform-port factory)
Summary: ## Summary Cold boot on Ladakh/Leh800bcls (Agera3, PAI 4.1) crashed with a SIGSEGV in `StateDelta` construction during parallel XPHY programming, and firmware never downloaded. Two defects, both exposed when the platform-port creation was refactored per-vendor (the old `else -> SaiFakePlatformPort` catch-all in `SaiPlatform::initPorts()` became a hard `throw`): 1. **Uninitialized product info.** `BspSaiPhyManager::createExternalPhy` created a `PlatformProductInfo` but never called `initialize()`. `Platform::getType()` returns `productInfo_->getType()`, so the retimer platform type was uninitialized garbage -> `createSaiPlatformPort()` returned null and `initPorts()` threw for every XPHY. (Same fix D114436354 made for Elbert; the retimer path was missed.) 2. **PAI build linked the fake port factory.** After the refactor, each binary links one vendor-specific `createSaiPlatformPort`. The PAI phy build was wired to `SaiPlatformInitFake.cpp`, whose factory only handles `PLATFORM_FAKE_*` and returns null for `LEH800BCLS`/`LADAKH800BCLS` -> throw, even once the type was correct. Together these failed all XPHY inits; programming then ran against uninitialized switches and hit the `StateDelta` null-deref crash. ## Changes - `BspSaiPhyManager::createExternalPhy`: call `productInfo->initialize()` before constructing `SaiPhyPlatform` (mirrors `ElbertPhyManager`/`SaiPlatformInit`). - New `SaiPlatformInitPai.cpp`: PAI-specific `createSaiPlatformPort` (`LADAKH800BCLS`/`LEH800BCLS` -> `SaiBcmPlatformPort`, plus fake fallback) and `chooseSaiPlatformImpl`. - `platform.bzl` (internal buck): `brcm_pai_srcs` links `SaiPlatformInitPai.cpp` instead of `SaiPlatformInitFake.cpp`. - `AgentPlatformsSai.cmake` (OSS): the `SAI_BRCM_PAI_IMPL` branch swaps the factory the same way -- reuse the fake port sources but drop `SaiPlatformInitFake.cpp` and add `SaiPlatformInitPai.cpp`. The real fake build (`SAI_PLATFORM_FAKE_SRC` / `else()` branch) is untouched. No new build deps (`SaiBcmPlatformPort.cpp` + `SaiFakePlatform*.cpp` are already in both source lists). The OSS PAI source set is now identical to the buck `brcm_pai_srcs` (22 files, same set), so exactly one `createSaiPlatformPort` is linked -- no duplicate/missing symbols, and the new file is wired into CMake (OSS-003 satisfied). Reviewed By: daiwei1983, birdsoup Differential Revision: D115255918 fbshipit-source-id: 391c89521ff5ae94def7f0d46827dc7cadd4c73d
1 parent 27df8e0 commit 521e794

3 files changed

Lines changed: 60 additions & 1 deletion

File tree

cmake/AgentPlatformsSai.cmake

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,17 @@ elseif (CHENAB_SAI_SDK)
9191
${SAI_PLATFORM_CHENAB_SRC}
9292
)
9393
elseif (SAI_BRCM_PAI_IMPL)
94+
# PAI (retimer / XPHY) build: same platform-port sources as the fake build,
95+
# but with a PAI-specific createSaiPlatformPort that builds real ports for the
96+
# Agera3 retimer boxes (LEH800BCLS/LADAKH800BCLS) instead of the fake-only
97+
# factory. Mirrors brcm_pai_srcs in platform.bzl.
98+
set(SAI_PLATFORM_PAI_SRC ${SAI_PLATFORM_FAKE_SRC})
99+
list(REMOVE_ITEM SAI_PLATFORM_PAI_SRC
100+
fboss/agent/platforms/sai/SaiPlatformInitFake.cpp)
94101
list(APPEND SAI_PLATFORM_SRC
95102
fboss/agent/platforms/sai/SaiPhyPlatform.cpp
96-
${SAI_PLATFORM_FAKE_SRC}
103+
fboss/agent/platforms/sai/SaiPlatformInitPai.cpp
104+
${SAI_PLATFORM_PAI_SRC}
97105
)
98106
else()
99107
list(APPEND SAI_PLATFORM_SRC
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/*
2+
* Copyright (c) 2004-present, Facebook, Inc.
3+
* All rights reserved.
4+
*
5+
* This source code is licensed under the BSD-style license found in the
6+
* LICENSE file in the root directory of this source tree. An additional grant
7+
* of patent rights can be found in the PATENTS file in the same directory.
8+
*
9+
*/
10+
11+
#include "fboss/agent/platforms/sai/SaiPlatformInitImpl.h"
12+
13+
#include "fboss/agent/platforms/sai/SaiBcmPlatformPort.h"
14+
#include "fboss/agent/platforms/sai/SaiFakePlatform.h"
15+
#include "fboss/agent/platforms/sai/SaiFakePlatformPort.h"
16+
17+
namespace facebook::fboss {
18+
19+
// Broadcom PAI (retimer / XPHY) build. The retimer SaiPhyPlatform is created
20+
// directly by BspSaiPhyManager::createExternalPhy, so chooseSaiPlatformImpl is
21+
// only exercised by fake test paths here.
22+
std::unique_ptr<SaiPlatform> chooseSaiPlatformImpl(
23+
std::unique_ptr<PlatformProductInfo>& productInfo,
24+
folly::MacAddress /*localMac*/,
25+
const std::string& /*platformMappingStr*/) {
26+
if (productInfo->getType() == PlatformType::PLATFORM_FAKE_SAI) {
27+
return std::make_unique<SaiFakePlatform>(std::move(productInfo));
28+
}
29+
return nullptr;
30+
}
31+
32+
std::unique_ptr<SaiPlatformPort> createSaiPlatformPort(
33+
const PortID& portId,
34+
SaiPlatform* platform) {
35+
const auto type = platform->getType();
36+
// Agera3 retimer boxes: XPHY ports use the generic SaiBcmPlatformPort, same
37+
// as the agent bcm build. (These are the only real platforms the PAI build
38+
// instantiates.)
39+
if (type == PlatformType::PLATFORM_LADAKH800BCLS ||
40+
type == PlatformType::PLATFORM_LEH800BCLS) {
41+
return std::make_unique<SaiBcmPlatformPort>(portId, platform);
42+
}
43+
if (type == PlatformType::PLATFORM_FAKE_SAI ||
44+
type == PlatformType::PLATFORM_FAKE_WEDGE) {
45+
return std::make_unique<SaiFakePlatformPort>(portId, platform);
46+
}
47+
return nullptr;
48+
}
49+
50+
} // namespace facebook::fboss

fboss/lib/phy/BspSaiPhyManager.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ void BspSaiPhyManager::createExternalPhy(
189189
// Create SaiPhyPlatform for this xphy
190190
auto productInfo =
191191
std::make_unique<PlatformProductInfo>(FLAGS_fruid_filepath);
192+
productInfo->initialize();
192193
addSaiPlatform(
193194
xphyID,
194195
std::make_unique<SaiPhyPlatform>(

0 commit comments

Comments
 (0)