Skip to content

Commit e882c2a

Browse files
Protick Bhowmickmeta-codesync[bot]
authored andcommitted
Auto-populate XPHY backplane port overrides from qsfpTestConfig
Summary: When FLAGS_override_program_iphy_ports_for_test is set, WedgeManager auto-populates overrideTcvrToPortAndProfileForTest_ from qsfpTestConfig for ports WITH transceivers. This change adds the equivalent functionality in PortManager for ports WITHOUT transceivers but WITH XPHY. Changes: 1. Added setOverrideXphyNoTcvrPortToProfileForTesting() call in PortManager::init() 2. Added the logic in setOverrideXphyNoTcvrPortToProfileForTesting() that reads cabledPortPairs from qsfpTestConfig and adds ports that does not have a transiever but has xphy ** Also removed the else branch from setOverrideXphyNoTcvrPortToProfileForTesting() that cleared the port-to-profile override map when called without arguments and FLAGS_override_program_iphy_ports_for_test was not set. This was causing unit tests to fail because they set up the override map first, then PortManager::init() would call this function without arguments and clear the previously-set mappings. This aligns with WedgeManager::setOverrideTcvrToPortAndProfileForTesting() which also doesn't have an else branch that clears its override map. Reviewed By: shiva-menta Differential Revision: D91012058 fbshipit-source-id: f2e1c7517870505a528dbc3c4e2796b2a9526a62
1 parent ad8d956 commit e882c2a

File tree

5 files changed

+31
-7
lines changed

5 files changed

+31
-7
lines changed

fboss/qsfp_service/BUCK

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,7 @@ cpp_library(
273273
compiler_flags = QSFP_COMMON_COMPILER_FLAGS,
274274
exported_deps = [
275275
"fbsource//third-party/fmt:fmt",
276+
":qsfp-config",
276277
":qsfp-service-threads",
277278
":transceiver-manager",
278279
"//fboss/agent:fboss-error",

fboss/qsfp_service/PortManager.cpp

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include <folly/json/DynamicConverter.h>
66
#include "fboss/agent/Utils.h"
77
#include "fboss/lib/thrift_service_client/ThriftServiceClient.h"
8+
#include "fboss/qsfp_service/QsfpConfig.h"
89

910
namespace facebook::fboss {
1011
namespace {
@@ -178,6 +179,11 @@ void PortManager::init() {
178179
if (transceiverManager_->canWarmBoot()) {
179180
restoreAgentConfigAppliedInfo();
180181
}
182+
// Set overrideXphyNoTcvrPortToProfileForTest_ if
183+
// FLAGS_override_program_iphy_ports_for_test is true.
184+
// This mirrors what WedgeManager::initTransceiverMap() does for
185+
// overrideTcvrToPortAndProfileForTest_.
186+
setOverrideXphyNoTcvrPortToProfileForTesting();
181187

182188
initExternalPhyMap();
183189
}
@@ -890,8 +896,23 @@ void PortManager::setOverrideXphyNoTcvrPortToProfileForTesting(
890896
overrideXphyNoTcvrPortToProfile) {
891897
if (overrideXphyNoTcvrPortToProfile.has_value()) {
892898
overrideXphyNoTcvrPortToProfileForTest_ = *overrideXphyNoTcvrPortToProfile;
893-
} else {
894-
overrideXphyNoTcvrPortToProfileForTest_.clear();
899+
} else if (FLAGS_override_program_iphy_ports_for_test) {
900+
auto qsfpTestConfig =
901+
transceiverManager_->getQsfpConfig()->thrift.qsfpTestConfig();
902+
CHECK(qsfpTestConfig.has_value());
903+
for (const auto& portPairs : *qsfpTestConfig->cabledPortPairs()) {
904+
auto aPortID = getPortIDByPortName(*portPairs.aPortName());
905+
auto zPortID = getPortIDByPortName(*portPairs.zPortName());
906+
// If the SW port does NOT have a transceiver but HAS XPHY, add it to
907+
// overrideXphyNoTcvrPortToProfileForTest_ (XPHY backplane port)
908+
for (const auto& portID : {aPortID, zPortID}) {
909+
if (portID.has_value() && !portHasTransceiver(*portID) &&
910+
cachedXphyPorts_.find(*portID) != cachedXphyPorts_.end()) {
911+
overrideXphyNoTcvrPortToProfileForTest_.emplace(
912+
*portID, *portPairs.profileID());
913+
}
914+
}
915+
}
895916
}
896917
}
897918

fboss/qsfp_service/PortManager.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
#include "fboss/qsfp_service/TransceiverManager.h"
2424
#include "fboss/qsfp_service/if/gen-cpp2/transceiver_types.h"
2525

26+
DECLARE_bool(override_program_iphy_ports_for_test);
27+
2628
#define TYPED_LOG(level, logType) XLOG(level) << logType << " "
2729

2830
#define PORTMGR_SM_LOG(level) TYPED_LOG(level, "[SM]")

fboss/qsfp_service/TransceiverManager.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,11 @@ DEFINE_bool(
7575
false,
7676
"Set to true to enable Port Manager mode. This means PortManager object will manage all port-level logic and TransceiverManager object will only manage transceiver-level logic.");
7777

78+
DEFINE_bool(
79+
override_program_iphy_ports_for_test,
80+
false,
81+
"Override wedge_agent programInternalPhyPorts(). For test only");
82+
7883
namespace {
7984
constexpr auto kFbossPortNameRegex = "(eth|fab)(\\d+)/(\\d+)/(\\d+)";
8085
constexpr auto kForceColdBootFileName = "cold_boot_once_qsfp_service";

fboss/qsfp_service/platforms/wedge/WedgeManager.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,6 @@
2424
#include <thrift/lib/cpp/util/EnumUtils.h>
2525
#include <chrono>
2626

27-
DEFINE_bool(
28-
override_program_iphy_ports_for_test,
29-
false,
30-
"Override wedge_agent programInternalPhyPorts(). For test only");
31-
3227
DEFINE_bool(
3328
optics_data_post_to_rest,
3429
false,

0 commit comments

Comments
 (0)