Skip to content
Open
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
1 change: 1 addition & 0 deletions orchagent/port.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ class Port
std::set<std::string> m_members;
std::set<std::string> m_child_ports;
std::vector<sai_object_id_t> m_queue_ids;
std::vector<sai_object_id_t> m_scheduler_group_ids;
std::vector<sai_object_id_t> 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
Expand Down
7 changes: 3 additions & 4 deletions orchagent/portsorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4606,7 +4606,6 @@ void PortsOrch::initializeQueues(Port &port)

void PortsOrch::initializeSchedulerGroups(Port &port)
{
std::vector<sai_object_id_t> scheduler_group_ids;
SWSS_LOG_ENTER();

sai_attribute_t attr;
Expand All @@ -4623,16 +4622,16 @@ 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)
{
return;
}

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)
Expand Down
36 changes: 3 additions & 33 deletions orchagent/qosorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<sai_object_id_t> 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 = port.m_scheduler_group_ids,
Copy link
Copy Markdown
Collaborator

@stephenxs stephenxs Dec 6, 2022

Choose a reason for hiding this comment

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

This avoids the memory issue but there is still a memory leak issue in DPB. eg. if the old port is removed then a set of new ports are created, the SAI OID of ports will be changed but m_scheduler_group_port_info[<SAI OID of old port>] won't be removed. Eventually, m_scheduler_group_port_info will contain a lot of info of ports that have been removed.
I would like to suggest

  1. moving the whole m_scheduler_group_port_info to Port struct and initialize it during port initialization or in this function.
  2. or keeping in m_scheduler_group_port_info and removing items from it on port removing.

@neethajohn how do you think

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think the second solution will be a lot cleaner

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Hi Stephen/Neetha, I am not familiar with DPB. How is the port removal scenario handled currently for scheduler group? Is it already getting covered in existing code before this PR or it is new functionality that needs to be added? Please clarify, thanks.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@stephenxs, can you comment on the DPB scenario?

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.

When it comes to DPB, I think what we care about is the port removal flow.
In short, the QoS orchagent should listen to the config_db.PORT table and handle the port removal event.
On receiving a port removal event, it should map the port name to OID and then erase the item indexed by the OID from m_scheduler_group_port_info.
I think we can use the function bool PortsOrch::getPort(string alias, Port &p) to map the port name to OID.
But what I'm not sure about is whether the mapping is still available in ports orch in the port removal scenario because there is no guarantee in terms of the order in which the orchagents (ports ~, QoS ~) handle the port removal notification.
this is why I proposed option #1. but if we want to use #2 maybe we also have a way. I will check with the DPB expert in my team (if there is one) and get back to you.
thanks.

.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);
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 */
Expand Down