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

[202205] Create fabric ports for switch_type fabric #1189

Merged
merged 1 commit into from
Jan 2, 2023
Merged
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
26 changes: 26 additions & 0 deletions unittest/vslib/TestSwitchStateBase.cpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,37 @@
#include "SwitchStateBase.h"
#include "MACsecAttr.h"

#include <gtest/gtest.h>

#include <vector>

using namespace saivs;

//Test the following function:
//sai_status_t initialize_voq_switch_objects(
// _In_ uint32_t attr_count,
// _In_ const sai_attribute_t *attr_list);

TEST(SwitchStateBase, initialize_voq_switch_objects)
{
auto sc = std::make_shared<SwitchConfig>(0, "");
auto scc = std::make_shared<SwitchConfigContainer>();

SwitchStateBase ss(
0x2100000000,
std::make_shared<RealObjectIdManager>(0, scc),
sc);

sai_attribute_t attr;

attr.id = SAI_SWITCH_ATTR_TYPE;
attr.value.u32 = SAI_SWITCH_TYPE_FABRIC;
sc->m_fabricLaneMap = LaneMap::getDefaultLaneMap(0);
// Check the result of the initialize_voq_switch_objects
EXPECT_EQ(SAI_STATUS_SUCCESS,
ss.initialize_voq_switch_objects(1, &attr));
}

TEST(SwitchStateBase, initialize_voq_switch)
{
auto sc = std::make_shared<SwitchConfig>(0, "");
Expand Down
10 changes: 10 additions & 0 deletions vslib/SwitchStateBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3018,6 +3018,16 @@ sai_status_t SwitchStateBase::initialize_voq_switch_objects(
if (attr_list[i].value.u32 != SAI_SWITCH_TYPE_VOQ)
{
// Switch is not being set as VOQ type.
SWSS_LOG_NOTICE("initialize_voq_switch_objects the value is %d", attr_list[i].value.u32);
if (attr_list[i].value.u32 == SAI_SWITCH_TYPE_FABRIC)
{
SWSS_LOG_NOTICE("about to config fabric ports");
if (m_switchConfig->m_fabricLaneMap)
{
CHECK_STATUS(create_fabric_ports());
CHECK_STATUS(set_fabric_port_list());
}
}
return SAI_STATUS_SUCCESS;
}
else
Expand Down