Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove redundant calls to get child scheduler group during initialization #1965

Merged
merged 3 commits into from
Nov 17, 2021
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
26 changes: 20 additions & 6 deletions orchagent/qosorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -972,18 +972,29 @@ sai_object_id_t QosOrch::getSchedulerGroup(const Port &port, const sai_object_id

m_scheduler_group_port_info[port.m_port_id] = {
.groups = std::move(groups),
.child_groups = std::vector<std::vector<sai_object_id_t>>(groups_count)
.child_groups = std::vector<std::vector<sai_object_id_t>>(groups_count),
.group_has_been_initialized = std::vector<bool>(groups_count)
};
}

SWSS_LOG_INFO("Port %s has been initialized with %u group(s)", port.m_alias.c_str(), groups_count);
}

/* Lookup groups to which queue belongs */
const auto& groups = m_scheduler_group_port_info[port.m_port_id].groups;
auto& scheduler_group_port_info = m_scheduler_group_port_info[port.m_port_id];
const auto& groups = scheduler_group_port_info.groups;
for (uint32_t ii = 0; ii < groups.size() ; ii++)
{
const auto& group_id = groups[ii];
const auto& child_groups_per_group = m_scheduler_group_port_info[port.m_port_id].child_groups[ii];
const auto& child_groups_per_group = scheduler_group_port_info.child_groups[ii];
if (child_groups_per_group.empty())
{
if (scheduler_group_port_info.group_has_been_initialized[ii])
{
// skip this iteration if it has been initialized which means there're no children in this group
SWSS_LOG_INFO("No child group for port %s group 0x%" PRIx64 ", skip", port.m_alias.c_str(), group_id);
continue;
}

attr.id = SAI_SCHEDULER_GROUP_ATTR_CHILD_COUNT;//Number of queues/groups childs added to scheduler group
sai_status = sai_scheduler_group_api->get_scheduler_group_attribute(group_id, 1, &attr);
if (SAI_STATUS_SUCCESS != sai_status)
Expand All @@ -997,14 +1008,17 @@ sai_object_id_t QosOrch::getSchedulerGroup(const Port &port, const sai_object_id
}

uint32_t child_count = attr.value.u32;
vector<sai_object_id_t> child_groups(child_count);

SWSS_LOG_INFO("Port %s group 0x%" PRIx64 " has been initialized with %u child group(s)", port.m_alias.c_str(), group_id, child_count);
scheduler_group_port_info.group_has_been_initialized[ii] = true;

// skip this iteration if there're no children in this group
if (child_count == 0)
{
continue;
}

vector<sai_object_id_t> child_groups(child_count);
attr.id = SAI_SCHEDULER_GROUP_ATTR_CHILD_LIST;
attr.value.objlist.list = child_groups.data();
attr.value.objlist.count = child_count;
Expand All @@ -1019,7 +1033,7 @@ sai_object_id_t QosOrch::getSchedulerGroup(const Port &port, const sai_object_id
}
}

m_scheduler_group_port_info[port.m_port_id].child_groups[ii] = std::move(child_groups);
scheduler_group_port_info.child_groups[ii] = std::move(child_groups);
}

for (const auto& child_group_id: child_groups_per_group)
Expand Down
1 change: 1 addition & 0 deletions orchagent/qosorch.h
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ class QosOrch : public Orch
{
std::vector<sai_object_id_t> groups;
std::vector<std::vector<sai_object_id_t>> child_groups;
std::vector<bool> group_has_been_initialized;
};

std::unordered_map<sai_object_id_t, SchedulerGroupPortInfo_t> m_scheduler_group_port_info;
Expand Down