Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added query Enum value capability for vxlan EVPN feature #920

Merged
merged 7 commits into from
Sep 15, 2021
Merged
Show file tree
Hide file tree
Changes from 4 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
132 changes: 132 additions & 0 deletions unittest/vslib/TestSwitchBCM56850.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -268,3 +268,135 @@ 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,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please use 1 parameter per line if you want to break function params to multiple lines, also do this across this PR

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

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++)
kcudnik marked this conversation as resolved.
Show resolved Hide resolved
{
if (enum_val_cap.list[i] == SAI_TUNNEL_PEER_MODE_P2MP || enum_val_cap.list[i] == SAI_TUNNEL_PEER_MODE_P2P)
{
modes_found++;
}
}
kcudnik marked this conversation as resolved.
Show resolved Hide resolved
EXPECT_EQ(modes_found, 2);

kcudnik marked this conversation as resolved.
Show resolved Hide resolved
}

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);
}
125 changes: 125 additions & 0 deletions unittest/vslib/TestSwitchMLNX2700.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -267,3 +267,128 @@ 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;

};
}
55 changes: 55 additions & 0 deletions vslib/SwitchStateBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3296,3 +3296,58 @@ bool SwitchStateBase::dumpObject(

return true;
}

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

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

enum_values_capability->count = 2;
enum_values_capability->list[0] = SAI_TUNNEL_PEER_MODE_P2MP;
enum_values_capability->list[1] = SAI_TUNNEL_PEER_MODE_P2P;
return SAI_STATUS_SUCCESS;
}

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

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

enum_values_capability->count = 3;
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;

return SAI_STATUS_SUCCESS;
}

sai_status_t SwitchStateBase::queryAttrEnumValuesCapability(
_In_ sai_object_id_t switch_id,
_In_ sai_object_type_t object_type,
_In_ sai_attr_id_t attr_id,
_Inout_ sai_s32_list_t *enum_values_capability)
{
SWSS_LOG_ENTER();

if (object_type == SAI_OBJECT_TYPE_TUNNEL && attr_id == SAI_TUNNEL_ATTR_PEER_MODE)
{
return queryTunnelPeerModeCapability(enum_values_capability);
}
else if (object_type == SAI_OBJECT_TYPE_VLAN && (attr_id == SAI_VLAN_ATTR_UNKNOWN_UNICAST_FLOOD_CONTROL_TYPE ||
attr_id == SAI_VLAN_ATTR_UNKNOWN_MULTICAST_FLOOD_CONTROL_TYPE ||
attr_id == SAI_VLAN_ATTR_BROADCAST_FLOOD_CONTROL_TYPE))
{
return queryVlanfloodTypeCapability(enum_values_capability);
}
return SAI_STATUS_NOT_SUPPORTED;
}
Loading