-
Notifications
You must be signed in to change notification settings - Fork 303
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Summary: Add a test to validate that PFC counters are incremented when a PFC frame is received. Also updated ProductionFeatures. No need to update HW asic files since they already have PFC declared correctly. Reviewed By: nivinl Differential Revision: D62414831 fbshipit-source-id: 93887febcfcf134cfa771c8799f5ce486d09c220
- Loading branch information
1 parent
3d4261d
commit 265f3f7
Showing
2 changed files
with
94 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary. | ||
|
||
#include "fboss/agent/TxPacket.h" | ||
#include "fboss/agent/packet/PktFactory.h" | ||
#include "fboss/agent/test/AgentHwTest.h" | ||
#include "fboss/agent/test/utils/ConfigUtils.h" | ||
#include "fboss/agent/test/utils/PfcTestUtils.h" | ||
#include "fboss/lib/CommonUtils.h" | ||
|
||
namespace facebook::fboss { | ||
|
||
class AgentPfcTest : public AgentHwTest { | ||
public: | ||
cfg::SwitchConfig initialConfig( | ||
const AgentEnsemble& ensemble) const override { | ||
auto config = utility::onePortPerInterfaceConfig( | ||
ensemble.getSw(), | ||
ensemble.masterLogicalPortIds(), | ||
true /*interfaceHasSubnet*/); | ||
return config; | ||
} | ||
|
||
std::vector<production_features::ProductionFeature> | ||
getProductionFeaturesVerified() const override { | ||
return {production_features::ProductionFeature::PFC}; | ||
} | ||
|
||
protected: | ||
void sendPfcFrame(const std::vector<PortID>& portIds, uint8_t classVector) { | ||
for (auto portId : portIds) { | ||
// Construct PFC payload with fixed quanta 0x00F0. | ||
// See https://github.com/archjeb/pfctest for frame structure. | ||
std::vector<uint8_t> payload{ | ||
0x01, 0x01, 0x00, classVector, 0x00, 0xF0, 0x00, 0xF0, 0x00, 0xF0, | ||
0x00, 0xF0, 0x00, 0xF0, 0x00, 0xF0, 0x00, 0xF0, 0x00, 0xF0, | ||
}; | ||
std::vector<uint8_t> padding(28, 0); | ||
payload.insert(payload.end(), padding.begin(), padding.end()); | ||
|
||
// Send it out | ||
auto vlanId = utility::firstVlanID(getProgrammedState()); | ||
auto intfMac = utility::getFirstInterfaceMac(getProgrammedState()); | ||
auto srcMac = utility::MacAddressGenerator().get(intfMac.u64NBO() + 1); | ||
auto pkt = utility::makeEthTxPacket( | ||
getSw(), | ||
vlanId, | ||
srcMac, | ||
folly::MacAddress("01:80:C2:00:00:01"), // MAC control address | ||
ETHERTYPE::ETHERTYPE_EPON, // Ethertype for PFC frames | ||
std::move(payload)); | ||
getSw()->sendPacketOutOfPortAsync(std::move(pkt), portId); | ||
} | ||
} | ||
}; | ||
|
||
TEST_F(AgentPfcTest, verifyPfcCounters) { | ||
std::vector<PortID> portIds = { | ||
masterLogicalInterfacePortIds()[0], masterLogicalInterfacePortIds()[1]}; | ||
std::vector<int> losslessPgIds = {2}; | ||
|
||
auto setup = [&]() { | ||
auto cfg = getAgentEnsemble()->getCurrentConfig(); | ||
utility::setupPfcBuffers(cfg, portIds, losslessPgIds); | ||
applyNewConfig(cfg); | ||
|
||
for (auto portId : portIds) { | ||
auto inPfc = getLatestPortStats(portId).get_inPfc_(); | ||
for (auto [qos, value] : inPfc) { | ||
EXPECT_EQ(value, 0); | ||
} | ||
} | ||
}; | ||
|
||
auto verify = [&]() { | ||
sendPfcFrame(portIds, 0xFF); | ||
|
||
WITH_RETRIES({ | ||
for (auto portId : portIds) { | ||
// We map pgIds to PFC priorities 1:1, so check for the same IDs. | ||
auto inPfc = getLatestPortStats(portId).get_inPfc_(); | ||
ASSERT_EVENTUALLY_GE(inPfc.size(), losslessPgIds.size()); | ||
for (int pgId : losslessPgIds) { | ||
EXPECT_EVENTUALLY_EQ(inPfc[pgId], 1); | ||
} | ||
} | ||
}); | ||
}; | ||
|
||
verifyAcrossWarmBoots(setup, verify); | ||
} | ||
|
||
} // namespace facebook::fboss |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters