From a3095b8e2e76db2d1924e9a059cc544ea7f807f8 Mon Sep 17 00:00:00 2001 From: Prabhu Sreenivasan <45380242+PrabhuSreenivasan@users.noreply.github.com> Date: Fri, 18 Dec 2020 18:45:05 +0530 Subject: [PATCH] CPU queues on vslib (#732) Signed-off-by: Prabhu Sreenivasan Co-authored-by: Prabhu Sreenivasan --- vslib/inc/SwitchBCM56850.h | 3 ++ vslib/inc/SwitchStateBase.h | 3 ++ vslib/src/SwitchBCM56850.cpp | 52 +++++++++++++++++++++++++++++++++++ vslib/src/SwitchStateBase.cpp | 11 ++++++++ 4 files changed, 69 insertions(+) diff --git a/vslib/inc/SwitchBCM56850.h b/vslib/inc/SwitchBCM56850.h index 283d027da..44b5e9598 100644 --- a/vslib/inc/SwitchBCM56850.h +++ b/vslib/inc/SwitchBCM56850.h @@ -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; diff --git a/vslib/inc/SwitchStateBase.h b/vslib/inc/SwitchStateBase.h index 68d74c792..9a28db9dc 100644 --- a/vslib/inc/SwitchStateBase.h +++ b/vslib/inc/SwitchStateBase.h @@ -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); diff --git a/vslib/src/SwitchBCM56850.cpp b/vslib/src/SwitchBCM56850.cpp index 4b35858db..d48aaecd2 100644 --- a/vslib/src/SwitchBCM56850.cpp +++ b/vslib/src/SwitchBCM56850.cpp @@ -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 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(); @@ -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; } diff --git a/vslib/src/SwitchStateBase.cpp b/vslib/src/SwitchStateBase.cpp index 733978fdc..304f9d72a 100644 --- a/vslib/src/SwitchStateBase.cpp +++ b/vslib/src/SwitchStateBase.cpp @@ -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) { @@ -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));