Skip to content

Commit

Permalink
CPU queues on vslib (sonic-net#732)
Browse files Browse the repository at this point in the history
Signed-off-by: Prabhu Sreenivasan <prabhu.sreenivasan@broadcom.com>

Co-authored-by: Prabhu Sreenivasan <ps944501@lvnvde0930.lvn.broadcom.net>
  • Loading branch information
2 people authored and lguohan committed Dec 19, 2020
1 parent 36e912b commit a3095b8
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 0 deletions.
3 changes: 3 additions & 0 deletions vslib/inc/SwitchBCM56850.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ namespace saivs

protected:

virtual sai_status_t create_cpu_qos_queues(
_In_ sai_object_id_t port_id) override;

virtual sai_status_t create_qos_queues_per_port(
_In_ sai_object_id_t port_id) override;

Expand Down
3 changes: 3 additions & 0 deletions vslib/inc/SwitchStateBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,9 @@ namespace saivs

protected: // TODO should be pure

virtual sai_status_t create_cpu_qos_queues(
_In_ sai_object_id_t port_id);

virtual sai_status_t create_qos_queues_per_port(
_In_ sai_object_id_t port_id);

Expand Down
52 changes: 52 additions & 0 deletions vslib/src/SwitchBCM56850.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,56 @@ sai_status_t SwitchBCM56850::create_qos_queues_per_port(
return SAI_STATUS_SUCCESS;
}

sai_status_t SwitchBCM56850::create_cpu_qos_queues(
_In_ sai_object_id_t port_id)
{
SWSS_LOG_ENTER();

sai_attribute_t attr;

// CPU queues are of type multicast queues
const uint32_t port_qos_queues_count = 32;

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(create(SAI_OBJECT_TYPE_QUEUE, &queue_id, m_switch_id, 0, NULL));

queues.push_back(queue_id);

attr.id = SAI_QUEUE_ATTR_TYPE;
attr.value.s32 = SAI_QUEUE_TYPE_MULTICAST;

CHECK_STATUS(set(SAI_OBJECT_TYPE_QUEUE, queue_id, &attr));

attr.id = SAI_QUEUE_ATTR_INDEX;
attr.value.u8 = (uint8_t)i;

CHECK_STATUS(set(SAI_OBJECT_TYPE_QUEUE, queue_id, &attr));

attr.id = SAI_QUEUE_ATTR_PORT;
attr.value.oid = port_id;

CHECK_STATUS(set(SAI_OBJECT_TYPE_QUEUE, queue_id, &attr));
}

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

CHECK_STATUS(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(set(SAI_OBJECT_TYPE_PORT, port_id, &attr));

return SAI_STATUS_SUCCESS;
}

sai_status_t SwitchBCM56850::create_qos_queues()
{
SWSS_LOG_ENTER();
Expand All @@ -91,6 +141,8 @@ sai_status_t SwitchBCM56850::create_qos_queues()
CHECK_STATUS(create_qos_queues_per_port(port_id));
}

CHECK_STATUS(create_cpu_qos_queues(m_cpu_port_id));

return SAI_STATUS_SUCCESS;
}

Expand Down
11 changes: 11 additions & 0 deletions vslib/src/SwitchStateBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1430,6 +1430,16 @@ sai_status_t SwitchStateBase::set_acl_capabilities()
return set(SAI_OBJECT_TYPE_SWITCH, m_switch_id, &attr);
}

sai_status_t SwitchStateBase::create_cpu_qos_queues(
_In_ sai_object_id_t port_id)
{
SWSS_LOG_ENTER();

SWSS_LOG_ERROR("implement in child class");

return SAI_STATUS_NOT_IMPLEMENTED;
}

sai_status_t SwitchStateBase::create_qos_queues_per_port(
_In_ sai_object_id_t port_id)
{
Expand Down Expand Up @@ -1566,6 +1576,7 @@ sai_status_t SwitchStateBase::create_port_dependencies(
// attributes are not required since they will be set outside this function

CHECK_STATUS(create_ingress_priority_groups_per_port(port_id));
CHECK_STATUS(create_cpu_qos_queues(port_id));
CHECK_STATUS(create_qos_queues_per_port(port_id));
CHECK_STATUS(create_scheduler_groups_per_port(port_id));

Expand Down

0 comments on commit a3095b8

Please sign in to comment.