Skip to content

Commit

Permalink
Utilize getRemotePortNumVoqs to compute num VOQs for remote sys ports
Browse files Browse the repository at this point in the history
Summary: As titled. Use getRemotePortNumVoqs to compute num VOQs

Reviewed By: jasmeetbagga

Differential Revision: D66681169

fbshipit-source-id: 074c05b9e3a828a03277882c7f30147e81cd351f
  • Loading branch information
Ron He authored and facebook-github-bot committed Dec 3, 2024
1 parent 384e1ed commit 12db3da
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 10 deletions.
27 changes: 18 additions & 9 deletions fboss/agent/test/utils/VoqTestUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ constexpr auto kNumPortPerCore = 10;
// 0: CPU port, 1: gloabl rcy port, 2-5: local recycle port, 6: eventor port,
// 7: mgm port, 8-43 front panel nif
constexpr auto kRemoteSysPortOffset = 7;
constexpr auto kNumVoq = 8;
constexpr auto k3q2qNumVoq = 3;
constexpr auto kNumRdswSysPort = 44;
constexpr auto kNumEdswSysPort = 26;

Expand All @@ -33,14 +31,15 @@ std::shared_ptr<SystemPort> makeRemoteSysPort(
SwitchID remoteSwitchId,
int coreIndex,
int corePortIndex,
int64_t speed) {
int64_t speed,
HwAsic::InterfaceNodeRole intfRole,
cfg::PortType portType) {
auto remoteSysPort = std::make_shared<SystemPort>(portId);
auto voqConfig = getDefaultVoqConfig();
remoteSysPort->setName(folly::to<std::string>(
"hwTestSwitch", remoteSwitchId, ":eth/", portId, "/1"));
remoteSysPort->setSwitchId(remoteSwitchId);
// TODO(zecheng): NIF MGMT port for 3q2q mode should have 2 VOQ
remoteSysPort->setNumVoqs(isDualStage3Q2QMode() ? k3q2qNumVoq : kNumVoq);
remoteSysPort->setNumVoqs(getRemotePortNumVoqs(intfRole, portType));
remoteSysPort->setCoreIndex(coreIndex);
remoteSysPort->setCorePortIndex(corePortIndex);
remoteSysPort->setSpeedMbps(speed);
Expand Down Expand Up @@ -204,7 +203,9 @@ std::shared_ptr<SwitchState> addRemoteSysPort(
SystemPortID portId,
SwitchID remoteSwitchId,
int coreIndex,
int corePortIndex) {
int corePortIndex,
HwAsic::InterfaceNodeRole intfRole,
cfg::PortType portType) {
auto newState = currState->clone();
const auto& localPorts = newState->getSystemPorts()->cbegin()->second;
auto localPort = localPorts->cbegin()->second;
Expand All @@ -214,7 +215,9 @@ std::shared_ptr<SwitchState> addRemoteSysPort(
remoteSwitchId,
coreIndex,
corePortIndex,
localPort->getSpeedMbps());
localPort->getSpeedMbps(),
intfRole,
portType);
remoteSystemPorts->addNode(remoteSysPort, scopeResolver.scope(remoteSysPort));
return newState;
}
Expand Down Expand Up @@ -332,7 +335,9 @@ void populateRemoteIntfAndSysPorts(
SwitchID(switchId),
(i - minPortID - kRemoteSysPortOffset) / kNumPortPerCore,
(i - minPortID) % kNumPortPerCore,
static_cast<int64_t>(portSpeed));
static_cast<int64_t>(portSpeed),
HwAsic::InterfaceNodeRole::IN_CLUSTER_NODE,
cfg::PortType::INTERFACE_PORT);
remoteSysPorts->addSystemPort(remoteSysPort);

auto remoteRif = makeRemoteInterface(
Expand Down Expand Up @@ -404,7 +409,11 @@ void populateRemoteIntfAndSysPorts(
SwitchID(switchId),
*mapping.attachedCoreId(),
*mapping.attachedCorePortIndex(),
static_cast<int64_t>(portSpeed));
static_cast<int64_t>(portSpeed),
*dsfNode.clusterId() >= k2StageEdgePodClusterId
? HwAsic::InterfaceNodeRole::DUAL_STAGE_EDGE_NODE
: HwAsic::InterfaceNodeRole::IN_CLUSTER_NODE,
*mapping.portType());
remoteSysPorts->addSystemPort(remoteSysPort);

auto remoteRif = makeRemoteInterface(
Expand Down
6 changes: 5 additions & 1 deletion fboss/agent/test/utils/VoqTestUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#include "fboss/agent/SwitchIdScopeResolver.h"
#include "fboss/agent/gen-cpp2/switch_config_types.h"
#include "fboss/agent/hw/switch_asics/HwAsic.h"
#include "fboss/agent/state/SwitchState.h"
#include "fboss/agent/test/EcmpSetupHelper.h"
#include "fboss/agent/types.h"
Expand All @@ -20,7 +21,10 @@ std::shared_ptr<SwitchState> addRemoteSysPort(
SystemPortID portId,
SwitchID remoteSwitchId,
int coreIndex = 0,
int corePortIndex = 1);
int corePortIndex = 1,
HwAsic::InterfaceNodeRole intfRole =
HwAsic::InterfaceNodeRole::IN_CLUSTER_NODE,
cfg::PortType portType = cfg::PortType::INTERFACE_PORT);

std::shared_ptr<SwitchState> removeRemoteSysPort(
std::shared_ptr<SwitchState> currState,
Expand Down

0 comments on commit 12db3da

Please sign in to comment.