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
24 changes: 22 additions & 2 deletions fboss/agent/hw/sai/api/RouterInterfaceApi.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,12 @@ struct RouterInterfaceTraitsAttributes<
typename Attributes::Type,
typename Attributes::VlanId,
std::optional<typename Attributes::SrcMac>,
std::optional<typename Attributes::Mtu>>;
std::optional<typename Attributes::Mtu>
#if SAI_API_VERSION >= SAI_VERSION(1, 9, 0)
,
std::optional<typename Attributes::AdminMplsState>
#endif
>;
using AdapterHostKey = std::
tuple<typename Attributes::VirtualRouterId, typename Attributes::VlanId>;
};
Expand All @@ -81,7 +86,12 @@ struct RouterInterfaceTraitsAttributes<
typename Attributes::Type,
typename Attributes::PortId,
std::optional<typename Attributes::SrcMac>,
std::optional<typename Attributes::Mtu>>;
std::optional<typename Attributes::Mtu>
#if SAI_API_VERSION >= SAI_VERSION(1, 9, 0)
,
std::optional<typename Attributes::AdminMplsState>
#endif
>;
using AdapterHostKey = std::
tuple<typename Attributes::VirtualRouterId, typename Attributes::PortId>;
};
Expand Down Expand Up @@ -122,6 +132,13 @@ struct SaiRouterInterfaceTraitsT {
SAI_ROUTER_INTERFACE_ATTR_MTU,
sai_uint32_t,
SaiIntDefault<sai_int32_t>>;
#if SAI_API_VERSION >= SAI_VERSION(1, 9, 0)
using AdminMplsState = SaiAttribute<
EnumType,
SAI_ROUTER_INTERFACE_ATTR_ADMIN_MPLS_STATE,
bool,
SaiBoolDefaultFalse>;
#endif
};
using AdapterKey = RouterInterfaceSaiId;
using AdapterHostKey = typename detail::
Expand Down Expand Up @@ -186,6 +203,9 @@ SAI_ATTRIBUTE_NAME(VlanRouterInterface, VirtualRouterId)
SAI_ATTRIBUTE_NAME(VlanRouterInterface, VlanId)
SAI_ATTRIBUTE_NAME(PortRouterInterface, PortId)
SAI_ATTRIBUTE_NAME(VlanRouterInterface, Mtu)
#if SAI_API_VERSION >= SAI_VERSION(1, 9, 0)
SAI_ATTRIBUTE_NAME(VlanRouterInterface, AdminMplsState)
#endif

class RouterInterfaceApi : public SaiApi<RouterInterfaceApi> {
public:
Expand Down
8 changes: 6 additions & 2 deletions fboss/agent/hw/sai/api/SaiApi.h
Original file line number Diff line number Diff line change
Expand Up @@ -289,11 +289,15 @@ class SaiApi {
* If default value is provided, allow fallback in case of certain
* error conditions (primarily to support the case where adapter should,
* but does not return a default value for unimplemented attributes).
* INVALID_PARAMETER is included so that adapters (e.g. fake_sai) that
* do not support get for an optional attribute can be skipped.
* The error codes here are not very precise and may need to be revised
* based on experience.
*/
static constexpr std::array<sai_status_t, 2> kFallbackToDefaultErrCode{
SAI_STATUS_NOT_IMPLEMENTED, SAI_STATUS_NOT_SUPPORTED};
static constexpr std::array<sai_status_t, 3> kFallbackToDefaultErrCode{
SAI_STATUS_NOT_IMPLEMENTED,
SAI_STATUS_NOT_SUPPORTED,
SAI_STATUS_INVALID_PARAMETER};
auto status = e.getSaiStatus();
auto fallbackToDefault =
std::find(
Expand Down
73 changes: 73 additions & 0 deletions fboss/agent/hw/sai/api/tests/AclApiTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -410,13 +410,22 @@ class AclApiTest : public ::testing::Test {
true, // neighbor meta
true, // ether type
true, // outer vlan id
#if !defined(TAJO_SDK) || defined(TAJO_SDK_GTE_24_8_3001)
true, // bth opcode
#endif
#if !defined(TAJO_SDK) && !defined(BRCM_SAI_SDK_XGS)
true, // ipv6 next header
#endif
#if ( \
(SAI_API_VERSION >= SAI_VERSION(1, 14, 0) || \
(defined(BRCM_SAI_SDK_GTE_11_0) && defined(BRCM_SAI_SDK_XGS))) && \
!defined(TAJO_SDK))
kUserDefinedFieldGroup0(), // udf group 0
kUserDefinedFieldGroup1(), // udf group 1
kUserDefinedFieldGroup2(), // udf group 2
kUserDefinedFieldGroup3(), // udf group 3
kUserDefinedFieldGroup4(), // udf group 4
#endif
},
kSwitchID());
}
Expand Down Expand Up @@ -499,8 +508,14 @@ class AclApiTest : public ::testing::Test {
aclFieldOuterVlanIdAttribute{AclEntryFieldU16(kOuterVlanId())};
SaiAclEntryTraits::Attributes::FieldBthOpcode aclFieldBthOpcodeAttribute{
AclEntryFieldU8(kBthOpcode())};
#if !defined(TAJO_SDK) && !defined(BRCM_SAI_SDK_XGS)
SaiAclEntryTraits::Attributes::FieldIpv6NextHeader
aclFieldIpv6NextHeaderAttribute{AclEntryFieldU8(kIpv6NextHeader())};
#endif
#if ( \
(SAI_API_VERSION >= SAI_VERSION(1, 14, 0) || \
(defined(BRCM_SAI_SDK_GTE_11_0) && defined(BRCM_SAI_SDK_XGS))) && \
!defined(TAJO_SDK))
SaiAclEntryTraits::Attributes::UserDefinedFieldGroupMin0
aclUserDefinedGroup0{AclEntryFieldU8List{kUDFGroupData()}};
SaiAclEntryTraits::Attributes::UserDefinedFieldGroupMin1
Expand All @@ -511,6 +526,7 @@ class AclApiTest : public ::testing::Test {
aclUserDefinedGroup3{AclEntryFieldU8List{kUDFGroupData()}};
SaiAclEntryTraits::Attributes::UserDefinedFieldGroupMin4
aclUserDefinedGroup4{AclEntryFieldU8List{kUDFGroupData()}};
#endif
SaiAclEntryTraits::Attributes::ActionPacketAction aclActionPacketAction{
AclEntryActionU32(kPacketAction())};
SaiAclEntryTraits::Attributes::ActionCounter aclActionCounter{
Expand All @@ -526,8 +542,10 @@ class AclApiTest : public ::testing::Test {
AclEntryActionSaiObjectIdList(kMirrorEgress())};
SaiAclEntryTraits::Attributes::ActionMacsecFlow aclActionMacsecFlow{
AclEntryActionSaiObjectIdT(kMacsecFlow())};
#if !defined(TAJO_SDK)
SaiAclEntryTraits::Attributes::ActionSetUserTrap aclActionSetUserTrap{
AclEntryActionSaiObjectIdT(kSetUserTrap())};
#endif
SaiAclEntryTraits::Attributes::ActionSetArsObject aclActionSetArsObject{
AclEntryActionSaiObjectIdT(kSetArsObject())};
SaiAclEntryTraits::Attributes::ActionDisableArsForwarding
Expand Down Expand Up @@ -568,20 +586,29 @@ class AclApiTest : public ::testing::Test {
aclFieldEtherTypeAttribute,
aclFieldOuterVlanIdAttribute,
aclFieldBthOpcodeAttribute,
#if !defined(TAJO_SDK) && !defined(BRCM_SAI_SDK_XGS)
aclFieldIpv6NextHeaderAttribute,
#endif
#if ( \
(SAI_API_VERSION >= SAI_VERSION(1, 14, 0) || \
(defined(BRCM_SAI_SDK_GTE_11_0) && defined(BRCM_SAI_SDK_XGS))) && \
!defined(TAJO_SDK))
aclUserDefinedGroup0,
aclUserDefinedGroup1,
aclUserDefinedGroup2,
aclUserDefinedGroup3,
aclUserDefinedGroup4,
#endif
aclActionPacketAction,
aclActionCounter,
aclActionSetTC,
aclActionSetDSCP,
aclActionMirrorIngress,
aclActionMirrorEgress,
aclActionMacsecFlow,
#if !defined(TAJO_SDK)
aclActionSetUserTrap,
#endif
aclActionSetArsObject,
aclActionDisableArsForwarding,
aclActionSetEcmpHashAlgorithm,
Expand Down Expand Up @@ -782,8 +809,14 @@ class AclApiTest : public ::testing::Test {
aclEntryId, SaiAclEntryTraits::Attributes::FieldOuterVlanId());
auto aclFieldBthOpcodeGot = aclApi->getAttribute(
aclEntryId, SaiAclEntryTraits::Attributes::FieldBthOpcode());
#if !defined(TAJO_SDK) && !defined(BRCM_SAI_SDK_XGS)
auto aclFieldIpv6NextHeaderGot = aclApi->getAttribute(
aclEntryId, SaiAclEntryTraits::Attributes::FieldIpv6NextHeader());
#endif
#if ( \
(SAI_API_VERSION >= SAI_VERSION(1, 14, 0) || \
(defined(BRCM_SAI_SDK_GTE_11_0) && defined(BRCM_SAI_SDK_XGS))) && \
!defined(TAJO_SDK))
auto aclUdfGroupData0Got = aclApi->getAttribute(
aclEntryId, SaiAclEntryTraits::Attributes::UserDefinedFieldGroupMin0());
auto aclUdfGroupData1Got = aclApi->getAttribute(
Expand All @@ -794,6 +827,7 @@ class AclApiTest : public ::testing::Test {
aclEntryId, SaiAclEntryTraits::Attributes::UserDefinedFieldGroupMin3());
auto aclUdfGroupData4Got = aclApi->getAttribute(
aclEntryId, SaiAclEntryTraits::Attributes::UserDefinedFieldGroupMin4());
#endif

auto aclActionPacketActionGot = aclApi->getAttribute(
aclEntryId, SaiAclEntryTraits::Attributes::ActionPacketAction());
Expand All @@ -809,8 +843,10 @@ class AclApiTest : public ::testing::Test {
aclEntryId, SaiAclEntryTraits::Attributes::ActionMirrorEgress());
auto aclActionMacsecFlowGot = aclApi->getAttribute(
aclEntryId, SaiAclEntryTraits::Attributes::ActionMacsecFlow());
#if !defined(TAJO_SDK)
auto aclActionSetUserTrapGot = aclApi->getAttribute(
aclEntryId, SaiAclEntryTraits::Attributes::ActionSetUserTrap());
#endif
auto aclActionSetArsObjectGot = aclApi->getAttribute(
aclEntryId, SaiAclEntryTraits::Attributes::ActionSetArsObject());
auto aclActionDisableArsForwardingGot = aclApi->getAttribute(
Expand Down Expand Up @@ -851,12 +887,19 @@ class AclApiTest : public ::testing::Test {
EXPECT_EQ(aclFieldEtherTypeGot.getDataAndMask(), etherType);
EXPECT_EQ(aclFieldOuterVlanIdGot.getDataAndMask(), outerVlanId);
EXPECT_EQ(aclFieldBthOpcodeGot.getDataAndMask(), bthOpcode);
#if !defined(TAJO_SDK) && !defined(BRCM_SAI_SDK_XGS)
EXPECT_EQ(aclFieldIpv6NextHeaderGot.getDataAndMask(), ipv6NextHeader);
#endif
#if ( \
(SAI_API_VERSION >= SAI_VERSION(1, 14, 0) || \
(defined(BRCM_SAI_SDK_GTE_11_0) && defined(BRCM_SAI_SDK_XGS))) && \
!defined(TAJO_SDK))
EXPECT_EQ(aclUdfGroupData0Got.getDataAndMask(), udfGroupData0);
EXPECT_EQ(aclUdfGroupData1Got.getDataAndMask(), udfGroupData1);
EXPECT_EQ(aclUdfGroupData2Got.getDataAndMask(), udfGroupData2);
EXPECT_EQ(aclUdfGroupData3Got.getDataAndMask(), udfGroupData3);
EXPECT_EQ(aclUdfGroupData4Got.getDataAndMask(), udfGroupData4);
#endif

EXPECT_EQ(aclActionPacketActionGot.getData(), packetAction);
EXPECT_EQ(aclActionCounterGot.getData(), counter);
Expand All @@ -865,7 +908,9 @@ class AclApiTest : public ::testing::Test {
EXPECT_EQ(aclActionMirrorIngress.getData(), mirrorIngress);
EXPECT_EQ(aclActionMirrorEgress.getData(), mirrorEgress);
EXPECT_EQ(aclActionMacsecFlowGot.getData(), macsecFlow);
#if !defined(TAJO_SDK)
EXPECT_EQ(aclActionSetUserTrapGot.getData(), setUserTrap);
#endif
EXPECT_EQ(aclActionSetArsObjectGot.getData(), setArsObject);
EXPECT_EQ(aclActionDisableArsForwardingGot.getData(), disableArsForwarding);
EXPECT_EQ(aclActionSetEcmpHashAlgorithmGot.getData(), setEcmpHashAlgorithm);
Expand Down Expand Up @@ -1016,6 +1061,10 @@ TEST_F(AclApiTest, getAclTableAttribute) {
aclTableId, SaiAclTableTraits::Attributes::FieldRouteDstUserMeta());
auto aclTableFieldNeighborDstUserMetaGot = aclApi->getAttribute(
aclTableId, SaiAclTableTraits::Attributes::FieldNeighborDstUserMeta());
#if ( \
(SAI_API_VERSION >= SAI_VERSION(1, 14, 0) || \
(defined(BRCM_SAI_SDK_GTE_11_0) && defined(BRCM_SAI_SDK_XGS))) && \
!defined(TAJO_SDK))
auto aclTableUserDefinedFieldGroup0 = aclApi->getAttribute(
aclTableId, SaiAclTableTraits::Attributes::UserDefinedFieldGroupMin0());
auto aclTableUserDefinedFieldGroup1 = aclApi->getAttribute(
Expand All @@ -1026,6 +1075,7 @@ TEST_F(AclApiTest, getAclTableAttribute) {
aclTableId, SaiAclTableTraits::Attributes::UserDefinedFieldGroupMin3());
auto aclTableUserDefinedFieldGroup4 = aclApi->getAttribute(
aclTableId, SaiAclTableTraits::Attributes::UserDefinedFieldGroupMin4());
#endif

EXPECT_EQ(aclTableStageGot, SAI_ACL_STAGE_INGRESS);
EXPECT_EQ(aclTableBindPointTypeListGot.size(), 1);
Expand Down Expand Up @@ -1057,11 +1107,16 @@ TEST_F(AclApiTest, getAclTableAttribute) {
EXPECT_EQ(aclTableFieldFdbDstUserMetaGot, true);
EXPECT_EQ(aclTableFieldRouteDstUserMetaGot, true);
EXPECT_EQ(aclTableFieldNeighborDstUserMetaGot, true);
#if ( \
(SAI_API_VERSION >= SAI_VERSION(1, 14, 0) || \
(defined(BRCM_SAI_SDK_GTE_11_0) && defined(BRCM_SAI_SDK_XGS))) && \
!defined(TAJO_SDK))
EXPECT_EQ(aclTableUserDefinedFieldGroup0, kUserDefinedFieldGroup0());
EXPECT_EQ(aclTableUserDefinedFieldGroup1, kUserDefinedFieldGroup1());
EXPECT_EQ(aclTableUserDefinedFieldGroup2, kUserDefinedFieldGroup2());
EXPECT_EQ(aclTableUserDefinedFieldGroup3, kUserDefinedFieldGroup3());
EXPECT_EQ(aclTableUserDefinedFieldGroup4, kUserDefinedFieldGroup4());
#endif
}

TEST_F(AclApiTest, getAclEntryAttribute) {
Expand Down Expand Up @@ -1292,8 +1347,14 @@ TEST_F(AclApiTest, setAclEntryAttribute) {
AclEntryFieldU16(kOuterVlanId())};
SaiAclEntryTraits::Attributes::FieldBthOpcode aclFieldBthOpcode{
AclEntryFieldU8(kBthOpcode())};
#if !defined(TAJO_SDK) && !defined(BRCM_SAI_SDK_XGS)
SaiAclEntryTraits::Attributes::FieldIpv6NextHeader aclFieldIpv6NextHeader{
AclEntryFieldU8(kIpv6NextHeader())};
#endif
#if ( \
(SAI_API_VERSION >= SAI_VERSION(1, 14, 0) || \
(defined(BRCM_SAI_SDK_GTE_11_0) && defined(BRCM_SAI_SDK_XGS))) && \
!defined(TAJO_SDK))
SaiAclEntryTraits::Attributes::UserDefinedFieldGroupMin0 aclUserDefinedGroup0{
AclEntryFieldU8List{kUDFGroupData()}};
SaiAclEntryTraits::Attributes::UserDefinedFieldGroupMin1 aclUserDefinedGroup1{
Expand All @@ -1304,6 +1365,7 @@ TEST_F(AclApiTest, setAclEntryAttribute) {
AclEntryFieldU8List{kUDFGroupData()}};
SaiAclEntryTraits::Attributes::UserDefinedFieldGroupMin4 aclUserDefinedGroup4{
AclEntryFieldU8List{kUDFGroupData()}};
#endif

SaiAclEntryTraits::Attributes::ActionPacketAction aclActionPacketAction2{
AclEntryActionU32(kPacketAction2())};
Expand All @@ -1319,8 +1381,10 @@ TEST_F(AclApiTest, setAclEntryAttribute) {
AclEntryActionSaiObjectIdList(kMirrorEgress2())};
SaiAclEntryTraits::Attributes::ActionMacsecFlow aclActionMacsecFlow2{
AclEntryActionSaiObjectIdT(kMacsecFlow2())};
#if !defined(TAJO_SDK)
SaiAclEntryTraits::Attributes::ActionSetUserTrap aclActionSetUserTrap{
AclEntryActionSaiObjectIdT(kSetUserTrap())};
#endif
SaiAclEntryTraits::Attributes::ActionSetArsObject aclActionSetArsObject{
AclEntryActionSaiObjectIdT(kSetArsObject())};
SaiAclEntryTraits::Attributes::ActionDisableArsForwarding
Expand Down Expand Up @@ -1358,20 +1422,29 @@ TEST_F(AclApiTest, setAclEntryAttribute) {
aclApi->setAttribute(aclEntryId, aclFieldEtherType);
aclApi->setAttribute(aclEntryId, aclFieldOuterVlanId);
aclApi->setAttribute(aclEntryId, aclFieldBthOpcode);
#if !defined(TAJO_SDK) && !defined(BRCM_SAI_SDK_XGS)
aclApi->setAttribute(aclEntryId, aclFieldIpv6NextHeader);
#endif
#if ( \
(SAI_API_VERSION >= SAI_VERSION(1, 14, 0) || \
(defined(BRCM_SAI_SDK_GTE_11_0) && defined(BRCM_SAI_SDK_XGS))) && \
!defined(TAJO_SDK))
aclApi->setAttribute(aclEntryId, aclUserDefinedGroup0);
aclApi->setAttribute(aclEntryId, aclUserDefinedGroup1);
aclApi->setAttribute(aclEntryId, aclUserDefinedGroup2);
aclApi->setAttribute(aclEntryId, aclUserDefinedGroup3);
aclApi->setAttribute(aclEntryId, aclUserDefinedGroup4);
#endif
aclApi->setAttribute(aclEntryId, aclActionPacketAction2);
aclApi->setAttribute(aclEntryId, aclActionCounter2);
aclApi->setAttribute(aclEntryId, aclActionSetTC2);
aclApi->setAttribute(aclEntryId, aclActionSetDSCP2);
aclApi->setAttribute(aclEntryId, aclActionMirrorIngress2);
aclApi->setAttribute(aclEntryId, aclActionMirrorEgress2);
aclApi->setAttribute(aclEntryId, aclActionMacsecFlow2);
#if !defined(TAJO_SDK)
aclApi->setAttribute(aclEntryId, aclActionSetUserTrap);
#endif
aclApi->setAttribute(aclEntryId, aclActionSetArsObject);
aclApi->setAttribute(aclEntryId, aclActionDisableArsForwarding);
aclApi->setAttribute(aclEntryId, aclActionSetEcmpHashAlgorithm);
Expand Down
2 changes: 2 additions & 0 deletions fboss/agent/hw/sai/api/tests/RouterInterfaceApiTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class RouterInterfaceApiTest : public ::testing::Test {
typeAttribute,
vlanIdAttribute,
std::nullopt,
std::nullopt,
std::nullopt},
0);
EXPECT_EQ(rifId, fs->routeInterfaceManager.get(rifId).id);
Expand Down Expand Up @@ -68,6 +69,7 @@ class RouterInterfaceApiTest : public ::testing::Test {
typeAttribute,
portIdAttribute,
std::nullopt,
std::nullopt,
std::nullopt},
0);
EXPECT_EQ(rifId, fs->routeInterfaceManager.get(rifId).id);
Expand Down
10 changes: 10 additions & 0 deletions fboss/agent/hw/sai/fake/FakeSaiRouterInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ sai_status_t create_router_interface_fn(
case SAI_ROUTER_INTERFACE_ATTR_MTU:
mtu = attr_list[i].value.u32;
break;
case SAI_ROUTER_INTERFACE_ATTR_ADMIN_MPLS_STATE:
// Ignore in fake implementation - just accept the attribute
break;
default:
return SAI_STATUS_INVALID_PARAMETER;
}
Expand Down Expand Up @@ -99,6 +102,9 @@ sai_status_t set_router_interface_attribute_fn(
case SAI_ROUTER_INTERFACE_ATTR_MTU:
ri.mtu = attr->value.u32;
break;
case SAI_ROUTER_INTERFACE_ATTR_ADMIN_MPLS_STATE:
// Ignore in fake implementation - just accept the attribute
break;
default:
return SAI_STATUS_INVALID_PARAMETER;
}
Expand Down Expand Up @@ -137,6 +143,10 @@ sai_status_t get_router_interface_attribute_fn(
case SAI_ROUTER_INTERFACE_ATTR_MTU:
attr[i].value.u32 = ri.mtu;
break;
case SAI_ROUTER_INTERFACE_ATTR_ADMIN_MPLS_STATE:
// Return default value (false) in fake implementation
attr[i].value.booldata = false;
break;
default:
return SAI_STATUS_INVALID_PARAMETER;
}
Expand Down
9 changes: 9 additions & 0 deletions fboss/agent/hw/sai/store/tests/AclTableGroupStoreTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,22 @@ class AclTableGroupStoreTest : public SaiStoreTest {
true, // neighbor meta
true, // ether type
true, // outer vlan id
#if !defined(TAJO_SDK) || defined(TAJO_SDK_GTE_24_8_3001)
true, // bth opcode
#endif
#if !defined(TAJO_SDK) && !defined(BRCM_SAI_SDK_XGS)
true, // ipv6 next header
#endif
#if ( \
(SAI_API_VERSION >= SAI_VERSION(1, 14, 0) || \
(defined(BRCM_SAI_SDK_GTE_11_0) && defined(BRCM_SAI_SDK_XGS))) && \
!defined(TAJO_SDK))
0, // udf group 0
1, // udf group 1
2, // udf group 2
3, // udf group 3
4, // udf group 4
#endif
},
0);
}
Expand Down
Loading