From d0774f4d74e594bbd2306ed15ffab9754bc7227a Mon Sep 17 00:00:00 2001 From: Arvind Bhat Date: Mon, 14 Nov 2022 14:49:46 -0800 Subject: [PATCH 1/2] Keeping sched_group_ids in port --- orchagent/port.h | 1 + orchagent/portsorch.cpp | 7 +++---- orchagent/qosorch.cpp | 36 +++--------------------------------- 3 files changed, 7 insertions(+), 37 deletions(-) diff --git a/orchagent/port.h b/orchagent/port.h index a5e003584b..57f7250ebe 100644 --- a/orchagent/port.h +++ b/orchagent/port.h @@ -144,6 +144,7 @@ class Port std::set m_members; std::set m_child_ports; std::vector m_queue_ids; + std::vector m_scheduler_group_ids; std::vector m_priority_group_ids; sai_port_priority_flow_control_mode_t m_pfc_asym = SAI_PORT_PRIORITY_FLOW_CONTROL_MODE_COMBINED; uint8_t m_pfc_bitmask = 0; // PFC enable bit mask diff --git a/orchagent/portsorch.cpp b/orchagent/portsorch.cpp index a7a6e25548..4f5d7fb8eb 100755 --- a/orchagent/portsorch.cpp +++ b/orchagent/portsorch.cpp @@ -4589,7 +4589,6 @@ void PortsOrch::initializeQueues(Port &port) void PortsOrch::initializeSchedulerGroups(Port &port) { - std::vector scheduler_group_ids; SWSS_LOG_ENTER(); sai_attribute_t attr; @@ -4606,7 +4605,7 @@ void PortsOrch::initializeSchedulerGroups(Port &port) } SWSS_LOG_INFO("Got %d number of scheduler groups for port %s", attr.value.u32, port.m_alias.c_str()); - scheduler_group_ids.resize(attr.value.u32); + port.m_scheduler_group_ids.resize(attr.value.u32); if (attr.value.u32 == 0) { @@ -4614,8 +4613,8 @@ void PortsOrch::initializeSchedulerGroups(Port &port) } attr.id = SAI_PORT_ATTR_QOS_SCHEDULER_GROUP_LIST; - attr.value.objlist.count = (uint32_t)scheduler_group_ids.size(); - attr.value.objlist.list = scheduler_group_ids.data(); + attr.value.objlist.count = (uint32_t)port.m_scheduler_group_ids.size(); + attr.value.objlist.list = port.m_scheduler_group_ids.data(); status = sai_port_api->get_port_attribute(port.m_port_id, 1, &attr); if (status != SAI_STATUS_SUCCESS) diff --git a/orchagent/qosorch.cpp b/orchagent/qosorch.cpp index 2f8378d284..6efeabf42b 100644 --- a/orchagent/qosorch.cpp +++ b/orchagent/qosorch.cpp @@ -1459,44 +1459,14 @@ sai_object_id_t QosOrch::getSchedulerGroup(const Port &port, const sai_object_id const auto it = m_scheduler_group_port_info.find(port.m_port_id); if (it == m_scheduler_group_port_info.end()) { - /* Get max sched groups count */ - attr.id = SAI_PORT_ATTR_QOS_NUMBER_OF_SCHEDULER_GROUPS; - sai_status = sai_port_api->get_port_attribute(port.m_port_id, 1, &attr); - if (SAI_STATUS_SUCCESS != sai_status) - { - SWSS_LOG_ERROR("Failed to get number of scheduler groups for port:%s", port.m_alias.c_str()); - task_process_status handle_status = handleSaiGetStatus(SAI_API_PORT, sai_status); - if (handle_status != task_process_status::task_success) - { - return SAI_NULL_OBJECT_ID; - } - } - - /* Get total groups list on the port */ - uint32_t groups_count = attr.value.u32; - std::vector groups(groups_count); - - attr.id = SAI_PORT_ATTR_QOS_SCHEDULER_GROUP_LIST; - attr.value.objlist.list = groups.data(); - attr.value.objlist.count = groups_count; - sai_status = sai_port_api->get_port_attribute(port.m_port_id, 1, &attr); - if (SAI_STATUS_SUCCESS != sai_status) - { - SWSS_LOG_ERROR("Failed to get scheduler group list for port:%s", port.m_alias.c_str()); - task_process_status handle_status = handleSaiGetStatus(SAI_API_PORT, sai_status); - if (handle_status != task_process_status::task_success) - { - return SAI_NULL_OBJECT_ID; - } - } - + size_t groups_count = port.m_scheduler_group_ids.size(); m_scheduler_group_port_info[port.m_port_id] = { - .groups = std::move(groups), + .groups = std::move(port.m_scheduler_group_ids), .child_groups = std::vector>(groups_count), .group_has_been_initialized = std::vector(groups_count) }; - SWSS_LOG_INFO("Port %s has been initialized with %u group(s)", port.m_alias.c_str(), groups_count); + SWSS_LOG_INFO("Port %s has been initialized with %zu group(s)", port.m_alias.c_str(), groups_count); } /* Lookup groups to which queue belongs */ From df2c7bf4571f36b65c3b2bd2d85db9ed45c3f65a Mon Sep 17 00:00:00 2001 From: Arvind Bhat Date: Fri, 2 Dec 2022 10:35:45 -0800 Subject: [PATCH 2/2] Fixing based on review comments --- orchagent/qosorch.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/orchagent/qosorch.cpp b/orchagent/qosorch.cpp index 6efeabf42b..22d3f84c9d 100644 --- a/orchagent/qosorch.cpp +++ b/orchagent/qosorch.cpp @@ -1461,7 +1461,7 @@ sai_object_id_t QosOrch::getSchedulerGroup(const Port &port, const sai_object_id { size_t groups_count = port.m_scheduler_group_ids.size(); m_scheduler_group_port_info[port.m_port_id] = { - .groups = std::move(port.m_scheduler_group_ids), + .groups = port.m_scheduler_group_ids, .child_groups = std::vector>(groups_count), .group_has_been_initialized = std::vector(groups_count) };