Skip to content

Commit 8dd9733

Browse files
Arun Yerrameta-codesync[bot]
authored andcommitted
Fix Ladakh800BCLS multi-NPU switch info configuration
Summary: The existing switch info configuration for Ladakh800BCLS wasn't handling dual NPU setup. This change properly registers both switch IDs (0 and 1) with their respective port ID ranges, connection handles, and switch indices in the configuration maps. The port ID ranges are also corrected to use the full 2048-port ranges per NPU (0-2047 and 2048-4095). Additionally fixed the switch index for SwitchID(1) to correctly use `(SwitchID)1` instead of `(SwitchID)0` in the `generateSwitchInfo` call, ensuring the second NPU gets the correct switch index. Reviewed By: msomasundaran Differential Revision: D91050691 fbshipit-source-id: e2a62cbba07b35fca7b4d7ee1d9a8228be0da477
1 parent e8b7323 commit 8dd9733

File tree

2 files changed

+66
-43
lines changed

2 files changed

+66
-43
lines changed

fboss/agent/test/utils/ConfigUtils.cpp

Lines changed: 62 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -853,56 +853,64 @@ cfg::SwitchConfig genPortVlanCfg(
853853
} else {
854854
std::map<SwitchID, cfg::SwitchInfo> defaultSwitchIdToSwitchInfo;
855855
std::map<SwitchID, const HwAsic*> defaultHwAsicTable;
856-
auto switchType = asic->getSwitchType();
857856
auto asicType = asic->getAsicType();
858857
int64_t switchId{0};
858+
std::string connectionHandle;
859859
if (asic->getSwitchId().has_value()) {
860860
switchId = *asic->getSwitchId();
861861
}
862-
defaultHwAsicTable.insert({SwitchID(switchId), asic});
863-
cfg::SwitchInfo switchInfo;
864862
cfg::Range64 portIdRange;
865863
portIdRange.minimum() =
866864
cfg::switch_config_constants::DEFAULT_PORT_ID_RANGE_MIN();
867865
portIdRange.maximum() = cfg::switch_config_constants::
868866
DEFAULT_DUAL_STAGE_3Q_2Q_PORT_ID_RANGE_MAX();
869-
switchInfo.portIdRange() = portIdRange;
870-
switchInfo.switchIndex() = 0;
871-
switchInfo.switchType() = switchType;
872-
switchInfo.asicType() = asicType;
867+
873868
// TODO: Instead of using hard codings for connection handle and
874869
// src mac, get the configs from AgentConfig
875870
if (asicType == cfg::AsicType::ASIC_TYPE_RAMON) {
876-
switchInfo.connectionHandle() = "0c:00";
877-
} else if (asicType == cfg::AsicType::ASIC_TYPE_RAMON3) {
878-
switchInfo.connectionHandle() = "15:00";
871+
connectionHandle = "0c:00";
872+
} else if (
873+
asicType == cfg::AsicType::ASIC_TYPE_RAMON3 ||
874+
asicType == cfg::AsicType::ASIC_TYPE_JERICHO3) {
875+
connectionHandle = "15:00";
879876
} else if (asicType == cfg::AsicType::ASIC_TYPE_JERICHO2) {
880-
switchInfo.switchMac() = "02:00:00:00:00:01";
881-
switchInfo.connectionHandle() = "68:00";
882-
} else if (asicType == cfg::AsicType::ASIC_TYPE_JERICHO3) {
883-
switchInfo.switchMac() = "02:00:00:00:00:01";
884-
switchInfo.connectionHandle() = "15:00";
877+
connectionHandle = "68:00";
885878
} else if (
886879
asicType == cfg::AsicType::ASIC_TYPE_EBRO ||
887880
asicType == cfg::AsicType::ASIC_TYPE_YUBA ||
888881
asicType == cfg::AsicType::ASIC_TYPE_G202X) {
889-
switchInfo.connectionHandle() = "/dev/uio0";
890-
}
891-
switchInfo.systemPortRanges() = asic->getSystemPortRanges();
892-
if (asic->getLocalSystemPortOffset().has_value()) {
893-
switchInfo.localSystemPortOffset() = *asic->getLocalSystemPortOffset();
894-
}
895-
if (asic->getGlobalSystemPortOffset().has_value()) {
896-
switchInfo.globalSystemPortOffset() = *asic->getGlobalSystemPortOffset();
897-
}
898-
if (asic->getInbandPortId().has_value()) {
899-
switchInfo.inbandPortId() = *asic->getInbandPortId();
882+
connectionHandle = "/dev/uio0";
900883
}
884+
901885
if (platformType.has_value() &&
902886
platformType.value() == PlatformType::PLATFORM_LADAKH800BCLS) {
903-
populateSwitchInfoForLadakh(static_cast<SwitchID>(switchId), switchInfo);
887+
portIdRange.maximum() =
888+
cfg::switch_config_constants::DEFAULT_PORT_ID_RANGE_MAX();
889+
defaultSwitchIdToSwitchInfo.insert(
890+
{SwitchID(0),
891+
generateSwitchInfo((SwitchID)0, portIdRange, "0000:15:00=0", asic)});
892+
defaultHwAsicTable.insert({SwitchID(0), asic});
893+
894+
// Add switch info for switch ID 1
895+
auto numPorts =
896+
(cfg::switch_config_constants::DEFAULT_PORT_ID_RANGE_MAX() -
897+
cfg::switch_config_constants::DEFAULT_PORT_ID_RANGE_MIN()) +
898+
1;
899+
portIdRange.minimum() =
900+
cfg::switch_config_constants::DEFAULT_PORT_ID_RANGE_MAX() + 1;
901+
portIdRange.maximum() =
902+
cfg::switch_config_constants::DEFAULT_PORT_ID_RANGE_MAX() + numPorts;
903+
904+
defaultSwitchIdToSwitchInfo.insert(
905+
{SwitchID(1),
906+
generateSwitchInfo((SwitchID)1, portIdRange, "0000:18:00=0", asic)});
907+
defaultHwAsicTable.insert({SwitchID(1), asic});
908+
} else {
909+
cfg::SwitchInfo switchInfo = generateSwitchInfo(
910+
(SwitchID)switchId, portIdRange, connectionHandle, asic);
911+
defaultSwitchIdToSwitchInfo.insert({SwitchID(switchId), switchInfo});
912+
defaultHwAsicTable.insert({SwitchID(switchId), asic});
904913
}
905-
defaultSwitchIdToSwitchInfo.insert({SwitchID(switchId), switchInfo});
906914
populateSwitchInfo(
907915
config, defaultSwitchIdToSwitchInfo, defaultHwAsicTable, platformType);
908916
}
@@ -1083,21 +1091,34 @@ void populateSwitchInfo(
10831091
config.dsfNodes() = newDsfNodes;
10841092
}
10851093

1086-
void populateSwitchInfoForLadakh(
1094+
cfg::SwitchInfo generateSwitchInfo(
10871095
SwitchID switchId,
1088-
cfg::SwitchInfo& switchInfo) {
1089-
cfg::Range64 portIdRange;
1090-
switchInfo.switchIndex() = static_cast<int64_t>(switchId);
1091-
if (switchId == SwitchID(0)) {
1092-
portIdRange.minimum() = 1;
1093-
portIdRange.maximum() = 512;
1094-
switchInfo.connectionHandle() = "0000:15:00=0";
1095-
} else {
1096-
portIdRange.minimum() = 2049;
1097-
portIdRange.maximum() = 2560;
1098-
switchInfo.connectionHandle() = "0000:18:00=0";
1099-
}
1096+
const cfg::Range64 portIdRange,
1097+
std::string connectionHandle,
1098+
const HwAsic* asic) {
1099+
cfg::SwitchInfo switchInfo;
1100+
auto asicType = asic->getAsicType();
11001101
switchInfo.portIdRange() = portIdRange;
1102+
switchInfo.switchIndex() = switchId;
1103+
switchInfo.switchType() = asic->getSwitchType();
1104+
switchInfo.asicType() = asicType;
1105+
1106+
if (asicType == cfg::AsicType::ASIC_TYPE_JERICHO2 ||
1107+
asicType == cfg::AsicType::ASIC_TYPE_JERICHO3) {
1108+
switchInfo.switchMac() = "02:00:00:00:00:01";
1109+
}
1110+
switchInfo.systemPortRanges() = asic->getSystemPortRanges();
1111+
if (asic->getLocalSystemPortOffset().has_value()) {
1112+
switchInfo.localSystemPortOffset() = *asic->getLocalSystemPortOffset();
1113+
}
1114+
if (asic->getGlobalSystemPortOffset().has_value()) {
1115+
switchInfo.globalSystemPortOffset() = *asic->getGlobalSystemPortOffset();
1116+
}
1117+
if (asic->getInbandPortId().has_value()) {
1118+
switchInfo.inbandPortId() = *asic->getInbandPortId();
1119+
}
1120+
switchInfo.connectionHandle() = connectionHandle;
1121+
return switchInfo;
11011122
}
11021123

11031124
cfg::SwitchConfig

fboss/agent/test/utils/ConfigUtils.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,9 +241,11 @@ void populateSwitchInfo(
241241
const std::map<SwitchID, const HwAsic*>& hwAsicTable,
242242
const std::optional<PlatformType> platformType = std::nullopt);
243243

244-
void populateSwitchInfoForLadakh(
244+
cfg::SwitchInfo generateSwitchInfo(
245245
SwitchID switchId,
246-
cfg::SwitchInfo& switchInfo);
246+
const cfg::Range64 portIdRange,
247+
std::string connectionHandle,
248+
const HwAsic* asic);
247249

248250
cfg::SwitchConfig twoL3IntfConfig(
249251
SwSwitch* swSwitch,

0 commit comments

Comments
 (0)