Skip to content

Commit

Permalink
Added query Enum value capability for vxlan EVPN feature (#920)
Browse files Browse the repository at this point in the history
  • Loading branch information
dgsudharsan authored Sep 15, 2021
1 parent 2e58cd9 commit 78f3613
Show file tree
Hide file tree
Showing 7 changed files with 406 additions and 1 deletion.
150 changes: 150 additions & 0 deletions unittest/vslib/TestSwitchBCM56850.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -268,3 +268,153 @@ TEST(SwitchBCM56850, warm_update_queues)

EXPECT_EQ(sw.get(SAI_OBJECT_TYPE_BRIDGE, sboid, 1, &attr), SAI_STATUS_SUCCESS);
}

TEST(SwitchBCM56850, test_tunnel_term_capability)
{
auto sc = std::make_shared<SwitchConfig>(0, "");
auto signal = std::make_shared<Signal>();
auto eventQueue = std::make_shared<EventQueue>(signal);

sc->m_saiSwitchType = SAI_SWITCH_TYPE_NPU;
sc->m_switchType = SAI_VS_SWITCH_TYPE_BCM56850;
sc->m_bootType = SAI_VS_BOOT_TYPE_COLD;
sc->m_useTapDevice = false;
sc->m_laneMap = LaneMap::getDefaultLaneMap(0);
sc->m_eventQueue = eventQueue;

auto scc = std::make_shared<SwitchConfigContainer>();

scc->insert(sc);

SwitchBCM56850 sw(
0x2100000000,
std::make_shared<RealObjectIdManager>(0, scc),
sc);


sai_s32_list_t enum_val_cap;
int32_t list[2];

enum_val_cap.count = 2;
enum_val_cap.list = list;

EXPECT_EQ(sw.queryAttrEnumValuesCapability(0x2100000000,
SAI_OBJECT_TYPE_TUNNEL,
SAI_TUNNEL_ATTR_PEER_MODE,
&enum_val_cap),
SAI_STATUS_SUCCESS);

EXPECT_EQ(enum_val_cap.count, 2);

int modes_found = 0;

for (uint32_t i = 0; i < enum_val_cap.count; i++)
{
if (enum_val_cap.list[i] == SAI_TUNNEL_PEER_MODE_P2MP || enum_val_cap.list[i] == SAI_TUNNEL_PEER_MODE_P2P)
{
modes_found++;
}
}

EXPECT_EQ(modes_found, 2);
}

TEST(SwitchBCM56850, test_vlan_flood_capability)
{
auto sc = std::make_shared<SwitchConfig>(0, "");
auto signal = std::make_shared<Signal>();
auto eventQueue = std::make_shared<EventQueue>(signal);

sc->m_saiSwitchType = SAI_SWITCH_TYPE_NPU;
sc->m_switchType = SAI_VS_SWITCH_TYPE_BCM56850;
sc->m_bootType = SAI_VS_BOOT_TYPE_COLD;
sc->m_useTapDevice = false;
sc->m_laneMap = LaneMap::getDefaultLaneMap(0);
sc->m_eventQueue = eventQueue;

auto scc = std::make_shared<SwitchConfigContainer>();

scc->insert(sc);

SwitchBCM56850 sw(
0x2100000000,
std::make_shared<RealObjectIdManager>(0, scc),
sc);

sai_s32_list_t enum_val_cap;
int32_t list[4];

enum_val_cap.count = 4;
enum_val_cap.list = list;

EXPECT_EQ(sw.queryAttrEnumValuesCapability(0x2100000000,
SAI_OBJECT_TYPE_VLAN,
SAI_VLAN_ATTR_UNKNOWN_UNICAST_FLOOD_CONTROL_TYPE,
&enum_val_cap),
SAI_STATUS_SUCCESS);

EXPECT_EQ(enum_val_cap.count, 3);

int flood_types_found = 0;
for (uint32_t i = 0; i < enum_val_cap.count; i++)
{
if (enum_val_cap.list[i] == SAI_VLAN_FLOOD_CONTROL_TYPE_ALL ||
enum_val_cap.list[i] == SAI_VLAN_FLOOD_CONTROL_TYPE_NONE ||
enum_val_cap.list[i] == SAI_VLAN_FLOOD_CONTROL_TYPE_L2MC_GROUP)
{
flood_types_found++;
}
}

EXPECT_EQ(flood_types_found, 3);

memset(list, 0, sizeof(list));
flood_types_found = 0;
enum_val_cap.count = 4;
enum_val_cap.list = list;

EXPECT_EQ(sw.queryAttrEnumValuesCapability(0x2100000000,
SAI_OBJECT_TYPE_VLAN,
SAI_VLAN_ATTR_UNKNOWN_MULTICAST_FLOOD_CONTROL_TYPE,
&enum_val_cap),
SAI_STATUS_SUCCESS);

EXPECT_EQ(enum_val_cap.count, 3);

for (uint32_t i = 0; i < enum_val_cap.count; i++)
{
if (enum_val_cap.list[i] == SAI_VLAN_FLOOD_CONTROL_TYPE_ALL ||
enum_val_cap.list[i] == SAI_VLAN_FLOOD_CONTROL_TYPE_NONE ||
enum_val_cap.list[i] == SAI_VLAN_FLOOD_CONTROL_TYPE_L2MC_GROUP)
{
flood_types_found++;
}
}

EXPECT_EQ(flood_types_found, 3);

memset(list, 0, sizeof(list));
flood_types_found = 0;
enum_val_cap.count = 4;
enum_val_cap.list = list;

EXPECT_EQ(sw.queryAttrEnumValuesCapability(0x2100000000,
SAI_OBJECT_TYPE_VLAN,
SAI_VLAN_ATTR_BROADCAST_FLOOD_CONTROL_TYPE,
&enum_val_cap),
SAI_STATUS_SUCCESS);

EXPECT_EQ(enum_val_cap.count, 3);

for (uint32_t i = 0; i < enum_val_cap.count; i++)
{
if (enum_val_cap.list[i] == SAI_VLAN_FLOOD_CONTROL_TYPE_ALL ||
enum_val_cap.list[i] == SAI_VLAN_FLOOD_CONTROL_TYPE_NONE ||
enum_val_cap.list[i] == SAI_VLAN_FLOOD_CONTROL_TYPE_L2MC_GROUP)
{
flood_types_found++;
}
}

EXPECT_EQ(flood_types_found, 3);
}
144 changes: 144 additions & 0 deletions unittest/vslib/TestSwitchMLNX2700.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -267,3 +267,147 @@ TEST(SwitchMLNX2700, warm_update_queues)

EXPECT_EQ(sw.get(SAI_OBJECT_TYPE_BRIDGE, sboid, 1, &attr), SAI_STATUS_SUCCESS);
}

TEST(SwitchMLNX2700, test_tunnel_term_capability)
{
auto sc = std::make_shared<SwitchConfig>(0, "");
auto signal = std::make_shared<Signal>();
auto eventQueue = std::make_shared<EventQueue>(signal);

sc->m_saiSwitchType = SAI_SWITCH_TYPE_NPU;
sc->m_switchType = SAI_VS_SWITCH_TYPE_MLNX2700;
sc->m_bootType = SAI_VS_BOOT_TYPE_COLD;
sc->m_useTapDevice = false;
sc->m_laneMap = LaneMap::getDefaultLaneMap(0);
sc->m_eventQueue = eventQueue;

auto scc = std::make_shared<SwitchConfigContainer>();

scc->insert(sc);

SwitchMLNX2700 sw(
0x2100000000,
std::make_shared<RealObjectIdManager>(0, scc),
sc);

sai_s32_list_t enum_val_cap;
int32_t list[2];

enum_val_cap.count = 2;
enum_val_cap.list = list;

EXPECT_EQ(sw.queryAttrEnumValuesCapability(0x2100000000,
SAI_OBJECT_TYPE_TUNNEL,
SAI_TUNNEL_ATTR_PEER_MODE,
&enum_val_cap),
SAI_STATUS_SUCCESS);

EXPECT_EQ(enum_val_cap.count, 1);

EXPECT_EQ(enum_val_cap.list[0], SAI_TUNNEL_PEER_MODE_P2MP);

}

TEST(SwitchMLNX2700, test_vlan_flood_capability)
{
auto sc = std::make_shared<SwitchConfig>(0, "");
auto signal = std::make_shared<Signal>();
auto eventQueue = std::make_shared<EventQueue>(signal);

sc->m_saiSwitchType = SAI_SWITCH_TYPE_NPU;
sc->m_switchType = SAI_VS_SWITCH_TYPE_MLNX2700;
sc->m_bootType = SAI_VS_BOOT_TYPE_COLD;
sc->m_useTapDevice = false;
sc->m_laneMap = LaneMap::getDefaultLaneMap(0);
sc->m_eventQueue = eventQueue;

auto scc = std::make_shared<SwitchConfigContainer>();

scc->insert(sc);

SwitchMLNX2700 sw(
0x2100000000,
std::make_shared<RealObjectIdManager>(0, scc),
sc);

sai_s32_list_t enum_val_cap;
int32_t list[4];

enum_val_cap.count = 4;
enum_val_cap.list = list;

EXPECT_EQ(sw.queryAttrEnumValuesCapability(0x2100000000,
SAI_OBJECT_TYPE_VLAN,
SAI_VLAN_ATTR_UNKNOWN_UNICAST_FLOOD_CONTROL_TYPE,
&enum_val_cap),
SAI_STATUS_SUCCESS);

EXPECT_EQ(enum_val_cap.count, 4);

int flood_types_found = 0;

for (uint32_t i = 0; i < enum_val_cap.count; i++)
{
if (enum_val_cap.list[i] == SAI_VLAN_FLOOD_CONTROL_TYPE_ALL ||
enum_val_cap.list[i] == SAI_VLAN_FLOOD_CONTROL_TYPE_NONE ||
enum_val_cap.list[i] == SAI_VLAN_FLOOD_CONTROL_TYPE_L2MC_GROUP ||
enum_val_cap.list[i] == SAI_VLAN_FLOOD_CONTROL_TYPE_COMBINED)
{
flood_types_found++;
}
}

EXPECT_EQ(flood_types_found, 4);

memset(list, 0, sizeof(list));
flood_types_found = 0;
enum_val_cap.count = 4;
enum_val_cap.list = list;

EXPECT_EQ(sw.queryAttrEnumValuesCapability(0x2100000000,
SAI_OBJECT_TYPE_VLAN,
SAI_VLAN_ATTR_UNKNOWN_MULTICAST_FLOOD_CONTROL_TYPE,
&enum_val_cap),
SAI_STATUS_SUCCESS);

EXPECT_EQ(enum_val_cap.count, 4);

for (uint32_t i = 0; i < enum_val_cap.count; i++)
{
if (enum_val_cap.list[i] == SAI_VLAN_FLOOD_CONTROL_TYPE_ALL ||
enum_val_cap.list[i] == SAI_VLAN_FLOOD_CONTROL_TYPE_NONE ||
enum_val_cap.list[i] == SAI_VLAN_FLOOD_CONTROL_TYPE_L2MC_GROUP ||
enum_val_cap.list[i] == SAI_VLAN_FLOOD_CONTROL_TYPE_COMBINED)
{
flood_types_found++;
}
}

EXPECT_EQ(flood_types_found, 4);

memset(list, 0, sizeof(list));
flood_types_found = 0;
enum_val_cap.count = 4;
enum_val_cap.list = list;

EXPECT_EQ(sw.queryAttrEnumValuesCapability(0x2100000000,
SAI_OBJECT_TYPE_VLAN,
SAI_VLAN_ATTR_BROADCAST_FLOOD_CONTROL_TYPE,
&enum_val_cap),
SAI_STATUS_SUCCESS);

EXPECT_EQ(enum_val_cap.count, 4);

for (uint32_t i = 0; i < enum_val_cap.count; i++)
{
if (enum_val_cap.list[i] == SAI_VLAN_FLOOD_CONTROL_TYPE_ALL ||
enum_val_cap.list[i] == SAI_VLAN_FLOOD_CONTROL_TYPE_NONE ||
enum_val_cap.list[i] == SAI_VLAN_FLOOD_CONTROL_TYPE_L2MC_GROUP ||
enum_val_cap.list[i] == SAI_VLAN_FLOOD_CONTROL_TYPE_COMBINED)
{
flood_types_found++;
}
}

EXPECT_EQ(flood_types_found, 4);
}
34 changes: 34 additions & 0 deletions vslib/SwitchMLNX2700.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -424,3 +424,37 @@ sai_status_t SwitchMLNX2700::warm_update_queues()

return SAI_STATUS_SUCCESS;
}

sai_status_t SwitchMLNX2700::queryVlanfloodTypeCapability(
_Inout_ sai_s32_list_t *enum_values_capability)
{
SWSS_LOG_ENTER();

if (enum_values_capability->count < 4)
{
return SAI_STATUS_BUFFER_OVERFLOW;
}

enum_values_capability->count = 4;
enum_values_capability->list[0] = SAI_VLAN_FLOOD_CONTROL_TYPE_ALL;
enum_values_capability->list[1] = SAI_VLAN_FLOOD_CONTROL_TYPE_NONE;
enum_values_capability->list[2] = SAI_VLAN_FLOOD_CONTROL_TYPE_L2MC_GROUP;
enum_values_capability->list[3] = SAI_VLAN_FLOOD_CONTROL_TYPE_COMBINED;

return SAI_STATUS_SUCCESS;
}

sai_status_t SwitchMLNX2700::queryTunnelPeerModeCapability(
_Inout_ sai_s32_list_t *enum_values_capability)
{
SWSS_LOG_ENTER();

if (enum_values_capability->count < 1)
{
return SAI_STATUS_BUFFER_OVERFLOW;
}

enum_values_capability->count = 1;
enum_values_capability->list[0] = SAI_TUNNEL_PEER_MODE_P2MP;
return SAI_STATUS_SUCCESS;
}
7 changes: 7 additions & 0 deletions vslib/SwitchMLNX2700.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,12 @@ namespace saivs
_In_ sai_object_id_t bridge_id) override;

virtual sai_status_t warm_update_queues() override;

protected:
virtual sai_status_t queryTunnelPeerModeCapability(
_Inout_ sai_s32_list_t *enum_values_capability) override;
virtual sai_status_t queryVlanfloodTypeCapability(
_Inout_ sai_s32_list_t *enum_values_capability) override;

};
}
Loading

0 comments on commit 78f3613

Please sign in to comment.