Skip to content
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
4 changes: 4 additions & 0 deletions vslib/inc/sai_vs_switch_BCM56850.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,8 @@ sai_status_t refresh_read_only_BCM56850(
_In_ sai_object_id_t object_id,
_In_ sai_object_id_t switch_id);

sai_status_t vs_create_port_BCM56850(
_In_ sai_object_id_t port_id,
_In_ sai_object_id_t switch_id);

#endif // __SAI_VS_SWITCH_BCM56850__
4 changes: 4 additions & 0 deletions vslib/inc/sai_vs_switch_MLNX2700.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,8 @@ sai_status_t refresh_read_only_MLNX2700(
_In_ sai_object_id_t object_id,
_In_ sai_object_id_t switch_id);

sai_status_t vs_create_port_MLNX2700(
_In_ sai_object_id_t port_id,
_In_ sai_object_id_t switch_id);

#endif // __SAI_VS_SWITCH_MLNX2700__
32 changes: 31 additions & 1 deletion vslib/src/sai_vs_port.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#include "sai_vs.h"
#include "sai_vs_internal.h"
#include "sai_vs_state.h"
#include "sai_vs_switch_BCM56850.h"
#include "sai_vs_switch_MLNX2700.h"

sai_status_t vs_clear_port_all_stats(
_In_ sai_object_id_t port_id)
Expand All @@ -11,7 +14,34 @@ sai_status_t vs_clear_port_all_stats(
return SAI_STATUS_NOT_IMPLEMENTED;
}

VS_GENERIC_QUAD(PORT,port);
sai_status_t vs_create_port(
_Out_ sai_object_id_t *port_id,
_In_ sai_object_id_t switch_id,
_In_ uint32_t attr_count,
_In_ const sai_attribute_t *attr_list)
{
MUTEX();
SWSS_LOG_ENTER();

/* create port */
CHECK_STATUS(meta_sai_create_oid((sai_object_type_t)SAI_OBJECT_TYPE_PORT,
port_id,switch_id,attr_count,attr_list,&vs_generic_create));

if (g_vs_switch_type == SAI_VS_SWITCH_TYPE_BCM56850)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

what about mlnx chipset implementation ?

{
vs_create_port_BCM56850(*port_id, switch_id);
}
else if (g_vs_switch_type == SAI_VS_SWITCH_TYPE_MLNX2700)
{
vs_create_port_MLNX2700(*port_id, switch_id);
}

return SAI_STATUS_SUCCESS;
}

VS_REMOVE(PORT,port);
VS_SET(PORT,port);
VS_GET(PORT,port);
VS_GENERIC_QUAD(PORT_POOL,port_pool);
VS_GENERIC_STATS(PORT,port);
VS_GENERIC_STATS(PORT_POOL,port_pool);
Expand Down
134 changes: 90 additions & 44 deletions vslib/src/sai_vs_switch_BCM56850.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,42 @@ static sai_status_t create_default_trap_group()
return vs_generic_set(SAI_OBJECT_TYPE_SWITCH, switch_object_id, &attr);
}

static sai_status_t create_qos_queues_per_port(
_In_ sai_object_id_t switch_object_id,
_In_ sai_object_id_t port_id)
{
SWSS_LOG_ENTER();

// 10 in and 10 out queues per port
const uint32_t port_qos_queues_count = 20;

std::vector<sai_object_id_t> queues;

for (uint32_t i = 0; i < port_qos_queues_count; ++i)
{
sai_object_id_t queue_id;

CHECK_STATUS(vs_generic_create(SAI_OBJECT_TYPE_QUEUE, &queue_id, switch_object_id, 0, NULL));

queues.push_back(queue_id);
}

sai_attribute_t attr;

attr.id = SAI_PORT_ATTR_QOS_NUMBER_OF_QUEUES;
attr.value.u32 = port_qos_queues_count;

CHECK_STATUS(vs_generic_set(SAI_OBJECT_TYPE_PORT, port_id, &attr));

attr.id = SAI_PORT_ATTR_QOS_QUEUE_LIST;
attr.value.objlist.count = port_qos_queues_count;
attr.value.objlist.list = queues.data();

CHECK_STATUS(vs_generic_set(SAI_OBJECT_TYPE_PORT, port_id, &attr));

return SAI_STATUS_SUCCESS;
}

static sai_status_t create_qos_queues()
{
SWSS_LOG_ENTER();
Expand All @@ -428,36 +464,46 @@ static sai_status_t create_qos_queues()

sai_object_id_t switch_object_id = ss->getSwitchId();

// 10 in and 10 out queues per port
const uint32_t port_qos_queues_count = 20;

for (auto &port_id : port_list)
{
std::vector<sai_object_id_t> queues;

for (uint32_t i = 0; i < port_qos_queues_count; ++i)
{
sai_object_id_t queue_id;
create_qos_queues_per_port(switch_object_id, port_id);
}

CHECK_STATUS(vs_generic_create(SAI_OBJECT_TYPE_QUEUE, &queue_id, switch_object_id, 0, NULL));
return SAI_STATUS_SUCCESS;
}

queues.push_back(queue_id);
}
static sai_status_t create_ingress_priority_groups_per_port(
_In_ sai_object_id_t switch_object_id,
_In_ sai_object_id_t port_id)
{
SWSS_LOG_ENTER();

sai_attribute_t attr;
const uint32_t port_pgs_count = 8;

attr.id = SAI_PORT_ATTR_QOS_NUMBER_OF_QUEUES;
attr.value.u32 = port_qos_queues_count;
std::vector<sai_object_id_t> pgs;

CHECK_STATUS(vs_generic_set(SAI_OBJECT_TYPE_PORT, port_id, &attr));
for (uint32_t i = 0; i < port_pgs_count; ++i)
{
sai_object_id_t pg_id;

attr.id = SAI_PORT_ATTR_QOS_QUEUE_LIST;
attr.value.objlist.count = port_qos_queues_count;
attr.value.objlist.list = queues.data();
CHECK_STATUS(vs_generic_create(SAI_OBJECT_TYPE_INGRESS_PRIORITY_GROUP, &pg_id, switch_object_id, 0, NULL));

CHECK_STATUS(vs_generic_set(SAI_OBJECT_TYPE_PORT, port_id, &attr));
pgs.push_back(pg_id);
}

sai_attribute_t attr;

attr.id = SAI_PORT_ATTR_NUMBER_OF_INGRESS_PRIORITY_GROUPS;
attr.value.u32 = port_pgs_count;

CHECK_STATUS(vs_generic_set(SAI_OBJECT_TYPE_PORT, port_id, &attr));

attr.id = SAI_PORT_ATTR_INGRESS_PRIORITY_GROUP_LIST;
attr.value.objlist.count = port_pgs_count;
attr.value.objlist.list = pgs.data();

CHECK_STATUS(vs_generic_set(SAI_OBJECT_TYPE_PORT, port_id, &attr));

return SAI_STATUS_SUCCESS;
}

Expand All @@ -472,33 +518,9 @@ static sai_status_t create_ingress_priority_groups()
sai_object_id_t switch_object_id = ss->getSwitchId();

//
const uint32_t port_pgs_count = 8;

for (auto &port_id : port_list)
{
std::vector<sai_object_id_t> pgs;

for (uint32_t i = 0; i < port_pgs_count; ++i)
{
sai_object_id_t pg_id;

CHECK_STATUS(vs_generic_create(SAI_OBJECT_TYPE_INGRESS_PRIORITY_GROUP, &pg_id, switch_object_id, 0, NULL));

pgs.push_back(pg_id);
}

sai_attribute_t attr;

attr.id = SAI_PORT_ATTR_NUMBER_OF_INGRESS_PRIORITY_GROUPS;
attr.value.u32 = port_pgs_count;

CHECK_STATUS(vs_generic_set(SAI_OBJECT_TYPE_PORT, port_id, &attr));

attr.id = SAI_PORT_ATTR_INGRESS_PRIORITY_GROUP_LIST;
attr.value.objlist.count = port_pgs_count;
attr.value.objlist.list = pgs.data();

CHECK_STATUS(vs_generic_set(SAI_OBJECT_TYPE_PORT, port_id, &attr));
create_ingress_priority_groups_per_port(switch_object_id, port_id);
}

return SAI_STATUS_SUCCESS;
Expand Down Expand Up @@ -1210,3 +1232,27 @@ sai_status_t refresh_read_only_BCM56850(

return SAI_STATUS_NOT_IMPLEMENTED;
}

sai_status_t vs_create_port_BCM56850(
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

please reuse logic that creates ports in init function, extract that code to separate function and reuse

_In_ sai_object_id_t port_id,
_In_ sai_object_id_t switch_id)
{
SWSS_LOG_ENTER();

sai_attribute_t attr;

attr.id = SAI_PORT_ATTR_ADMIN_STATE;
attr.value.booldata = false; /* default admin state is down as defined in SAI */

CHECK_STATUS(vs_generic_set(SAI_OBJECT_TYPE_PORT, port_id, &attr));

/* create priority groups */
create_ingress_priority_groups_per_port(switch_id, port_id);

/* create qos queues */
create_qos_queues_per_port(switch_id, port_id);

return SAI_STATUS_SUCCESS;
}


Loading