Skip to content

Commit

Permalink
Add port lanes mapping and vlan member list for VS (sonic-net#59)
Browse files Browse the repository at this point in the history
* Populate port hardware lanes for ports in virtual switch
* Add static VLAN member list for all ports
* Update Makefile for virtual switch
  • Loading branch information
kcudnik authored and stcheng committed Aug 17, 2016
1 parent 2417121 commit 26b2c90
Show file tree
Hide file tree
Showing 2 changed files with 98 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
@@ -1 +1 @@
SUBDIRS = lib syncd
SUBDIRS = lib vslib syncd
99 changes: 97 additions & 2 deletions vslib/src/sai_vs_switch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ sai_object_id_t switch_object_id = (sai_object_id_t)SAI_OBJECT_TYPE_SWITCH << 48
if (status != SAI_STATUS_SUCCESS) \
return status;

// should always be 1
#define DEFAULT_VLAN_NUMBER 1

sai_status_t vs_initialize_default_objects()
{
SWSS_LOG_ENTER();
Expand Down Expand Up @@ -52,7 +55,7 @@ sai_status_t vs_initialize_default_objects()
SWSS_LOG_INFO("create default vlan");

{
status = vs_vlan_api.create_vlan(1);
status = vs_vlan_api.create_vlan(DEFAULT_VLAN_NUMBER);

CHECK_STATUS(status);
}
Expand Down Expand Up @@ -97,6 +100,41 @@ sai_status_t vs_initialize_default_objects()

SWSS_LOG_INFO("create ports");

sai_uint32_t lanes[] = {
29,30,31,32,
25,26,27,28,
37,38,39,40,
33,34,35,36,
41,42,43,44,
45,46,47,48,
5,6,7,8,
1,2,3,4,
9,10,11,12,
13,14,15,16,
21,22,23,24,
17,18,19,20,
49,50,51,52,
53,54,55,56,
61,62,63,64,
57,58,59,60,
65,66,67,68,
69,70,71,72,
77,78,79,80,
73,74,75,76,
105,106,107,108,
109,110,111,112,
117,118,119,120,
113,114,115,116,
121,122,123,124,
125,126,127,128,
85,86,87,88,
81,82,83,84,
89,90,91,92,
93,94,95,96,
97,98,99,100,
101,102,103,104
};

// create ports
{
for (uint32_t i = 0; i < port_count; i++)
Expand All @@ -122,9 +160,18 @@ sai_status_t vs_initialize_default_objects()

CHECK_STATUS(status);

// populate lanes for each port

attr.id = SAI_PORT_ATTR_HW_LANE_LIST;
attr.value.u32list.count = 4;
attr.value.u32list.list = &lanes[4 * i];

status = vs_port_api.set_port_attribute(port_id, &attr);

CHECK_STATUS(status);

// TODO populate ports attributes
// TODO populate vlan members
// TODO populate port lanes
}
}

Expand Down Expand Up @@ -168,6 +215,54 @@ sai_status_t vs_initialize_default_objects()
CHECK_STATUS(status);
}

SWSS_LOG_INFO("create vlan members for all ports");

std::vector<sai_object_id_t> vlan_member_list;

{
for (auto &portId : port_list)
{
std::vector<sai_attribute_t> attrs;

sai_attribute_t attr_vlan_id;

attr_vlan_id.id = SAI_VLAN_MEMBER_ATTR_VLAN_ID;
attr_vlan_id.value.u16 = DEFAULT_VLAN_NUMBER;
attrs.push_back(attr_vlan_id);

sai_attribute_t attr_port_id;

attr_port_id.id = SAI_VLAN_MEMBER_ATTR_PORT_ID;
attr_port_id.value.oid = portId;
attrs.push_back(attr_port_id);

sai_object_id_t vlan_member_id;
status = vs_vlan_api.create_vlan_member(&vlan_member_id, attrs.size() , attrs.data());

CHECK_STATUS(status);

vlan_member_list.push_back(vlan_member_id);
}
}

SWSS_LOG_INFO("create vlan member list");

{
// TODO this list should be updated each time we modify any VLAN member
// and it probably should be handled inside create/remove vlan member api
// and not here

sai_attribute_t attr;

attr.id = SAI_VLAN_ATTR_MEMBER_LIST;
attr.value.objlist.count = vlan_member_list.size();
attr.value.objlist.list = vlan_member_list.data();

status = vs_vlan_api.set_vlan_attribute(DEFAULT_VLAN_NUMBER, &attr);

CHECK_STATUS(status);
}

return status;
}

Expand Down

0 comments on commit 26b2c90

Please sign in to comment.