Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions fboss/agent/hw/sai/hw_test/SaiAclTableGroupTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,10 @@ class SaiAclTableGroupTest : public HwTest {

// Table 2: Create TTL acl Table follwed by entry.
// This utlity call adds the TTL Acl entry as well.
utility::addTtlAclTable(newCfg, 2 /* priority */);
utility::addTtlAclTable(
newCfg,
2 /* priority */,
isSupported(HwAsic::Feature::ACL_BYTE_COUNTER));
applyNewConfig(*newCfg);
}

Expand Down Expand Up @@ -403,7 +406,10 @@ class SaiAclTableGroupTest : public HwTest {
case tableAddType::table2:
utility::addAclTableGroup(&newCfg, kAclStage(), kAclTableGroup());
// Add Table 2: TtlTable
utility::addTtlAclTable(&newCfg, 2 /* priority */);
utility::addTtlAclTable(
&newCfg,
2 /* priority */,
isSupported(HwAsic::Feature::ACL_BYTE_COUNTER));
break;
case tableAddType::tableBoth:
addTwoAclTables(&newCfg);
Expand Down Expand Up @@ -495,7 +501,11 @@ class SaiAclTableGroupTest : public HwTest {

utility::addAclTableGroup(&newCfg, kAclStage(), kAclTableGroup());
addAclTable3WithEntry(&newCfg, addExtraQualifier, false);
utility::addTtlAclTable(&newCfg, 2 /* priority */, addExtraQualifier);
utility::addTtlAclTable(
&newCfg,
2 /* priority */,
isSupported(HwAsic::Feature::ACL_BYTE_COUNTER),
addExtraQualifier);

return newCfg;
}
Expand Down
10 changes: 5 additions & 5 deletions fboss/agent/test/agent_hw_tests/AgentAclCounterTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,10 @@ class AgentAclCounterTest : public AgentHwTest {
auto* acl = &aclEntry;
auto l3Asics = getAgentEnsemble()->getL3Asics();
auto asic = checkSameAndGetAsicForTesting(l3Asics);
std::vector<cfg::CounterType> counterTypes{cfg::CounterType::PACKETS};
if (asic->isSupported(HwAsic::Feature::ACL_BYTE_COUNTER)) {
counterTypes.push_back(cfg::CounterType::BYTES);
}
bool isSai = getAgentEnsemble()->isSai();
switch (aclType) {
case AclType::TCP_TTLD:
Expand Down Expand Up @@ -523,8 +527,6 @@ class AgentAclCounterTest : public AgentHwTest {
// and v6 traffic. The test sends IPv6 traffic, so the IPv6 copy
// keeps the canonical name/counter (the one verifyAclType checks);
// the IPv4 copy gets a "-v4" suffix.
std::vector<cfg::CounterType> counterTypes{
cfg::CounterType::PACKETS, cfg::CounterType::BYTES};
auto addSrcPortEntry = [&](const std::string& name,
const std::string& counter,
cfg::EtherType etherType,
Expand Down Expand Up @@ -595,9 +597,7 @@ class AgentAclCounterTest : public AgentHwTest {
}
utility::addAcl(config, aclEntry, cfg::AclStage::INGRESS);

std::vector<cfg::CounterType> setCounterTypes{
cfg::CounterType::PACKETS, cfg::CounterType::BYTES};
utility::addAclStat(config, aclName, counterName, setCounterTypes);
utility::addAclStat(config, aclName, counterName, counterTypes);
}

std::unique_ptr<utility::EcmpSetupAnyNPorts6> helper_;
Expand Down
21 changes: 17 additions & 4 deletions fboss/agent/test/agent_hw_tests/AgentAclTableGroupTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,10 @@ class AgentAclTableGroupTest : public AgentHwTest {
void addTwoAclTables(cfg::SwitchConfig* newCfg) {
utility::addAclTableGroup(newCfg, kAclStage(), kAclTableGroup());
addAclTable3WithEntry(newCfg);
utility::addTtlAclTable(newCfg, 2 /* priority */);
utility::addTtlAclTable(
newCfg,
2 /* priority */,
isSupportedOnAllAsics(HwAsic::Feature::ACL_BYTE_COUNTER));
applyNewConfig(*newCfg);
}

Expand Down Expand Up @@ -325,7 +328,10 @@ class AgentAclTableGroupTest : public AgentHwTest {
break;
case tableAddType::table2:
utility::addAclTableGroup(&newCfg, kAclStage(), kAclTableGroup());
utility::addTtlAclTable(&newCfg, 2 /* priority */);
utility::addTtlAclTable(
&newCfg,
2 /* priority */,
isSupportedOnAllAsics(HwAsic::Feature::ACL_BYTE_COUNTER));
break;
case tableAddType::tableBoth:
addTwoAclTables(&newCfg);
Expand Down Expand Up @@ -415,7 +421,11 @@ class AgentAclTableGroupTest : public AgentHwTest {
auto newCfg = initialConfig(ensemble);
utility::addAclTableGroup(&newCfg, kAclStage(), kAclTableGroup());
addAclTable3WithEntry(&newCfg, addExtraQualifier, false);
utility::addTtlAclTable(&newCfg, 2 /* priority */, addExtraQualifier);
utility::addTtlAclTable(
&newCfg,
2 /* priority */,
isSupportedOnAllAsics(HwAsic::Feature::ACL_BYTE_COUNTER),
addExtraQualifier);
return newCfg;
}

Expand Down Expand Up @@ -671,7 +681,10 @@ TEST_F(AgentAclTableGroupTest, AddTwoTablesDeleteAddSecond) {
auto newCfg = initialConfig(ensemble);
addTwoAclTables(&newCfg);
deleteTtlAclTable(&newCfg);
utility::addTtlAclTable(&newCfg, 2 /* priority */);
utility::addTtlAclTable(
&newCfg,
2 /* priority */,
isSupportedOnAllAsics(HwAsic::Feature::ACL_BYTE_COUNTER));
applyNewConfig(newCfg);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,10 @@ class AgentAclTableGroupTrafficTest : public AgentHwTest {
1 /*priority*/,
addAllQualifiers,
getAgentEnsemble()->isSai());
utility::addTtlAclTable(&newCfg, 2 /*priority*/);
utility::addTtlAclTable(
&newCfg,
2 /*priority*/,
isSupportedOnAllAsics(HwAsic::Feature::ACL_BYTE_COUNTER));
applyNewConfig(newCfg);

utility::EcmpSetupAnyNPorts6 ecmpHelper(
Expand Down Expand Up @@ -403,7 +406,8 @@ class AgentAclTableGroupTrafficTest : public AgentHwTest {
1 /*priority*/,
addAllQualifiers,
getAgentEnsemble()->isSai());
utility::addTtlAclTable(&newCfg, 2);
utility::addTtlAclTable(
&newCfg, 2, isSupportedOnAllAsics(HwAsic::Feature::ACL_BYTE_COUNTER));
applyNewConfig(newCfg);

utility::EcmpSetupAnyNPorts6 ecmpHelper(
Expand Down
4 changes: 4 additions & 0 deletions fboss/agent/test/agent_hw_tests/AgentHwAclStatTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,10 @@ TEST_F(AgentHwAclStatTest, AclStatCreateMultiple) {
}

TEST_F(AgentHwAclStatCounterTypeTest, AclStatChangeCounterType) {
if (!isSupportedOnAllAsics(HwAsic::Feature::ACL_BYTE_COUNTER)) {
GTEST_SKIP();
}

auto setup = [=, this]() {
auto& ensemble = *getAgentEnsemble();
auto newCfg = initialConfig(ensemble);
Expand Down
16 changes: 9 additions & 7 deletions fboss/agent/test/agent_hw_tests/AgentQueuePerHostTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -440,11 +440,13 @@ class AgentQueuePerHostTest : public AgentHwTest {
auto ttlAclName = utility::getQueuePerHostTtlAclName();
auto ttlCounterName = utility::getQueuePerHostTtlCounterName();

const auto aclByteCounterSupported =
isSupportedOnAllAsics(HwAsic::Feature::ACL_BYTE_COUNTER);
for (bool frontPanel : {false, true}) {
auto packetsBefore = utility::getAclInOutPackets(getSw(), ttlCounterName);

auto bytesBefore =
utility::getAclInOutPackets(getSw(), ttlCounterName, true);
auto bytesBefore = aclByteCounterSupported
? utility::getAclInOutPackets(getSw(), ttlCounterName, true)
: 0;

auto dstIP = getIpToMacAndClassID<AddrT>().begin()->first;
sendPacket(dstIP, frontPanel, 64 /* ttl < 128 */);
Expand All @@ -453,9 +455,9 @@ class AgentQueuePerHostTest : public AgentHwTest {
WITH_RETRIES({
auto packetsAfter =
utility::getAclInOutPackets(getSw(), ttlCounterName);

auto bytesAfter =
utility::getAclInOutPackets(getSw(), ttlCounterName, true);
auto bytesAfter = aclByteCounterSupported
? utility::getAclInOutPackets(getSw(), ttlCounterName, true)
: 0;

XLOG(DBG2) << "verify send packets "
<< (frontPanel ? "out of port" : "switched") << "\n"
Expand All @@ -466,7 +468,7 @@ class AgentQueuePerHostTest : public AgentHwTest {

// counts ttl >= 128 packet only
EXPECT_EVENTUALLY_EQ(packetsAfter - packetsBefore, 1);
if (isSupportedOnAllAsics(HwAsic::Feature::ACL_BYTE_COUNTER)) {
if (aclByteCounterSupported) {
if (frontPanel) {
EXPECT_EVENTUALLY_EQ(bytesAfter - bytesBefore, packetSize);
}
Expand Down
6 changes: 3 additions & 3 deletions fboss/agent/test/utils/AclTestUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -667,12 +667,12 @@ std::vector<cfg::CounterType> getAclCounterTypes(
// one of the two is enabled. FBOSS use case does not require enabling
// only one, but always enables both packets and bytes counters. Thus,
// enable both in the test. Reference: CS00012271364
if (asic->isSupported(
if (!asic->isSupported(HwAsic::Feature::ACL_BYTE_COUNTER) ||
asic->isSupported(
HwAsic::Feature::SEPARATE_BYTE_AND_PACKET_ACL_COUNTER)) {
return {cfg::CounterType::PACKETS};
} else {
return {cfg::CounterType::BYTES, cfg::CounterType::PACKETS};
}
return {cfg::CounterType::BYTES, cfg::CounterType::PACKETS};
}

uint64_t getAclInOutPackets(
Expand Down
17 changes: 9 additions & 8 deletions fboss/agent/test/utils/QueuePerHostTestUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -390,30 +390,31 @@ void deleteTtlCounters(cfg::SwitchConfig* config) {

void addTtlAclEntry(
cfg::SwitchConfig* config,
const std::string& aclTableName) {
const std::string& aclTableName,
bool aclByteCounterSupported) {
cfg::Ttl ttl;
std::tie(*ttl.value(), *ttl.mask()) = std::make_tuple(0x80, 0x80);
auto ttlCounterName = getQueuePerHostTtlCounterName();
std::vector<cfg::CounterType> counterTypes{
cfg::CounterType::PACKETS, cfg::CounterType::BYTES};
std::vector<cfg::CounterType> counterTypes{cfg::CounterType::PACKETS};
if (aclByteCounterSupported) {
counterTypes.push_back(cfg::CounterType::BYTES);
}
utility::addTrafficCounter(config, ttlCounterName, counterTypes);

cfg::AclEntry ttlAcl{};
ttlAcl.name() = getQueuePerHostTtlAclName();
ttlAcl.ttl() = ttl;
ttlAcl.actionType() = cfg::AclActionType::PERMIT;
utility::addAclEntry(config, ttlAcl, aclTableName);
std::vector<cfg::CounterType> setCounterTypes{
cfg::CounterType::PACKETS, cfg::CounterType::BYTES};

utility::addAclStat(
config, getQueuePerHostTtlAclName(), ttlCounterName, setCounterTypes);
config, getQueuePerHostTtlAclName(), ttlCounterName, counterTypes);
}

// Utility to add TTL ACL table to a multi acl table group
void addTtlAclTable(
cfg::SwitchConfig* config,
int16_t priority,
bool aclByteCounterSupported,
bool addExtraQualifier) {
std::vector<cfg::AclTableQualifier> qualifiers = {
cfg::AclTableQualifier::TTL, cfg::AclTableQualifier::DSCP};
Expand All @@ -432,7 +433,7 @@ void addTtlAclTable(
cfg::AclTableActionType::COUNTER},
qualifiers);

addTtlAclEntry(config, getTtlAclTableName());
addTtlAclEntry(config, getTtlAclTableName(), aclByteCounterSupported);
}

void deleteQueuePerHostMatchers(cfg::SwitchConfig* config) {
Expand Down
6 changes: 5 additions & 1 deletion fboss/agent/test/utils/QueuePerHostTestUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,14 @@ void updateRoutesClassID(
std::optional<cfg::AclLookupClass>>& routePrefix2ClassID,
RouteUpdateWrapper* updater);

void addTtlAclEntry(cfg::SwitchConfig* config, const std::string& aclTableName);
void addTtlAclEntry(
cfg::SwitchConfig* config,
const std::string& aclTableName,
bool aclByteCounterSupported);
void addTtlAclTable(
cfg::SwitchConfig* config,
int16_t priority,
bool aclByteCounterSupported,
bool addExtraQualifier = false);
void deleteTtlCounters(cfg::SwitchConfig* config);
void addQueuePerHostAclEntry(
Expand Down
Loading