Skip to content
Closed
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
33 changes: 30 additions & 3 deletions orchagent/bufferorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ extern PortsOrch *gPortsOrch;
extern Directory<Orch*> gDirectory;
extern sai_object_id_t gSwitchId;
extern string gMySwitchType;
extern string gMyHostName;
extern string gMyAsicName;

#define BUFFER_POOL_WATERMARK_FLEX_STAT_COUNTER_POLL_MSECS "60000"

Expand Down Expand Up @@ -788,6 +790,8 @@ task_process_status BufferOrch::processQueue(KeyOpFieldsValuesTuple &tuple)
vector<string> tokens;
sai_uint32_t range_low, range_high;
bool need_update_sai = true;
bool local_port = false;
string local_port_name;

SWSS_LOG_DEBUG("Processing:%s", key.c_str());
tokens = tokenize(key, delimiter);
Expand All @@ -806,6 +810,13 @@ task_process_status BufferOrch::processQueue(KeyOpFieldsValuesTuple &tuple)
{
return task_process_status::task_invalid_entry;
}

if(tokens[0] == gMyHostName)
{
local_port = true;
local_port_name = tokens[2];
SWSS_LOG_INFO("System port %s is local port %d local port name %s", port_names[0].c_str(), local_port, local_port_name.c_str());
}
}
else
{
Expand Down Expand Up @@ -883,7 +894,13 @@ task_process_status BufferOrch::processQueue(KeyOpFieldsValuesTuple &tuple)
for (string port_name : port_names)
{
Port port;
SWSS_LOG_DEBUG("processing port:%s", port_name.c_str());
SWSS_LOG_ERROR("processing port:%s", port_name.c_str());

if(local_port == true)
{
port_name = local_port_name;
}

if (!gPortsOrch->getPort(port_name, port))
{
SWSS_LOG_ERROR("Port with alias:%s not found", port_name.c_str());
Expand Down Expand Up @@ -1001,9 +1018,19 @@ task_process_status BufferOrch::processQueue(KeyOpFieldsValuesTuple &tuple)
// set order is detected.
for (const auto &port_name : port_names)
{
if (gPortsOrch->isPortAdminUp(port_name)) {
SWSS_LOG_WARN("Queue profile '%s' applied after port %s is up", key.c_str(), port_name.c_str());
if(local_port == true)
{
if (gPortsOrch->isPortAdminUp(local_port_name)) {
SWSS_LOG_WARN("Queue profile '%s' applied after port %s is up", key.c_str(), port_name.c_str());
}
}
else
{
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.

Looks like the difference here is the param passed to isPortAdminUp. Can you change it to the following?

            auto &tmp_port_name = local_port ? local_port_name : port_name;
            if (gPortsOrch->isPortAdminUp(tmp_port_name)) {
                SWSS_LOG_WARN("Queue profile '%s' applied after port %s is up", key.c_str(), port_name.c_str());
            }

if (gPortsOrch->isPortAdminUp(port_name)) {
SWSS_LOG_WARN("Queue profile '%s' applied after port %s is up", key.c_str(), port_name.c_str());
}
}

}
}

Expand Down
1 change: 0 additions & 1 deletion orchagent/portsorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7971,7 +7971,6 @@ bool PortsOrch::addSystemPorts()
}
}

//System port for local port. Update the system port info in the existing physical port
if(!getPort(attr.value.oid, port))
{
//This is system port for non-front panel local port (CPU or OLP or RCY (Inband)). Not an error
Expand Down
134 changes: 111 additions & 23 deletions orchagent/qosorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ extern PortsOrch *gPortsOrch;
extern QosOrch *gQosOrch;
extern sai_object_id_t gSwitchId;
extern CrmOrch *gCrmOrch;
extern string gMySwitchType;
extern string gMyHostName;
extern string gMyAsicName;

map<string, sai_ecn_mark_mode_t> ecn_map = {
{"ecn_none", SAI_ECN_MARK_MODE_NONE},
Expand Down Expand Up @@ -1626,22 +1629,58 @@ sai_object_id_t QosOrch::getSchedulerGroup(const Port &port, const sai_object_id
bool QosOrch::applySchedulerToQueueSchedulerGroup(Port &port, size_t queue_ind, sai_object_id_t scheduler_profile_id)
{
SWSS_LOG_ENTER();
sai_object_id_t queue_id;
Port input_port = port;
sai_object_id_t group_id = 0;

if (port.m_queue_ids.size() <= queue_ind)
if (gMySwitchType == "voq")
{
SWSS_LOG_ERROR("Invalid queue index specified:%zd", queue_ind);
return false;
}
if(port.m_system_port_info.type == SAI_SYSTEM_PORT_TYPE_REMOTE)
{
return true;
}

// Get local port from system port. port is pointing to local port now
if (!gPortsOrch->getPort(port.m_system_port_info.local_port_oid, port))
{
SWSS_LOG_ERROR("Port with alias:%s not found", port.m_alias.c_str());
return task_process_status::task_invalid_entry;
}

const sai_object_id_t queue_id = port.m_queue_ids[queue_ind];
if (port.m_queue_ids.size() <= queue_ind)
{
SWSS_LOG_ERROR("Invalid queue index specified:%zd", queue_ind);
return false;
}
queue_id = port.m_queue_ids[queue_ind];

group_id = getSchedulerGroup(port, queue_id);
if(group_id == SAI_NULL_OBJECT_ID)
{
SWSS_LOG_ERROR("Failed to find a scheduler group for port: %s queue: %zu", port.m_alias.c_str(), queue_ind);
return false;
}

const sai_object_id_t group_id = getSchedulerGroup(port, queue_id);
if(group_id == SAI_NULL_OBJECT_ID)
// port is set back to system port
port = input_port;
}
else
{
SWSS_LOG_ERROR("Failed to find a scheduler group for port: %s queue: %zu", port.m_alias.c_str(), queue_ind);
return false;
if (port.m_queue_ids.size() <= queue_ind)
{
SWSS_LOG_ERROR("Invalid queue index specified:%zd", queue_ind);
return false;
}
queue_id = port.m_queue_ids[queue_ind];

group_id = getSchedulerGroup(port, queue_id);
if(group_id == SAI_NULL_OBJECT_ID)
{
SWSS_LOG_ERROR("Failed to find a scheduler group for port: %s queue: %zu", port.m_alias.c_str(), queue_ind);
return false;
}
}

/* Apply scheduler profile to all port groups */
sai_attribute_t attr;
sai_status_t sai_status;
Expand All @@ -1652,7 +1691,6 @@ bool QosOrch::applySchedulerToQueueSchedulerGroup(Port &port, size_t queue_ind,
sai_status = sai_scheduler_group_api->set_scheduler_group_attribute(group_id, &attr);
if (SAI_STATUS_SUCCESS != sai_status)
{
SWSS_LOG_ERROR("Failed applying scheduler profile:0x%" PRIx64 " to scheduler group:0x%" PRIx64 ", port:%s", scheduler_profile_id, group_id, port.m_alias.c_str());
task_process_status handle_status = handleSaiSetStatus(SAI_API_SCHEDULER_GROUP, sai_status);
if (handle_status != task_success)
{
Expand All @@ -1672,12 +1710,25 @@ bool QosOrch::applyWredProfileToQueue(Port &port, size_t queue_ind, sai_object_i
sai_status_t sai_status;
sai_object_id_t queue_id;

if (port.m_queue_ids.size() <= queue_ind)
if (gMySwitchType == "voq")
{
SWSS_LOG_ERROR("Invalid queue index specified:%zd", queue_ind);
return false;
std :: vector<sai_object_id_t> queue_ids = gPortsOrch->getPortVoQIds(port);
if (queue_ids.size() <= queue_ind)
{
SWSS_LOG_ERROR("Invalid voq index specified:%zd", queue_ind);
return task_process_status::task_invalid_entry;
}
queue_id = queue_ids[queue_ind];
}
else
{
if (port.m_queue_ids.size() <= queue_ind)
{
SWSS_LOG_ERROR("Invalid queue index specified:%zd", queue_ind);
return false;
}
queue_id = port.m_queue_ids[queue_ind];
}
queue_id = port.m_queue_ids[queue_ind];

attr.id = SAI_QUEUE_ATTR_WRED_PROFILE_ID;
attr.value.oid = sai_wred_profile;
Expand All @@ -1703,23 +1754,54 @@ task_process_status QosOrch::handleQueueTable(Consumer& consumer, KeyOpFieldsVal
string op = kfvOp(tuple);
size_t queue_ind = 0;
vector<string> tokens;
bool local_port = false;
string local_port_name;

sai_uint32_t range_low, range_high;
vector<string> port_names;

ref_resolve_status resolve_result;
// sample "QUEUE: {Ethernet4|0-1}"
/*
Input sample "QUEUE : {Ethernet4|0-1}" or
"QUEUE : {STG01-0101-0400-01T2-LC6|ASIC0|Ethernet4|0-1}"
*/
tokens = tokenize(key, config_db_key_delimiter);
if (tokens.size() != 2)

if (gMySwitchType == "voq")
{
SWSS_LOG_ERROR("malformed key:%s. Must contain 2 tokens", key.c_str());
return task_process_status::task_invalid_entry;
if (tokens.size() != 4)
{
SWSS_LOG_ERROR("malformed key:%s. Must contain 4 tokens", key.c_str());
return task_process_status::task_invalid_entry;
}

port_names = tokenize(tokens[0] + config_db_key_delimiter + tokens[1] + config_db_key_delimiter + tokens[2], list_item_delimiter);
if (!parseIndexRange(tokens[3], range_low, range_high))
{
SWSS_LOG_ERROR("Failed to parse range:%s", tokens[3].c_str());
return task_process_status::task_invalid_entry;
}

if(tokens[0] == gMyHostName)
{
local_port = true;
local_port_name = tokens[2];
SWSS_LOG_INFO("System port %s is local port %d local port name %s", port_names[0].c_str(), local_port, local_port_name.c_str());
}
}
port_names = tokenize(tokens[0], list_item_delimiter);
if (!parseIndexRange(tokens[1], range_low, range_high))
else
{
SWSS_LOG_ERROR("Failed to parse range:%s", tokens[1].c_str());
return task_process_status::task_invalid_entry;
if (tokens.size() != 2)
{
SWSS_LOG_ERROR("malformed key:%s. Must contain 2 tokens", key.c_str());
return task_process_status::task_invalid_entry;
}
port_names = tokenize(tokens[0], list_item_delimiter);
if (!parseIndexRange(tokens[1], range_low, range_high))
{
SWSS_LOG_ERROR("Failed to parse range:%s", tokens[1].c_str());
return task_process_status::task_invalid_entry;
}
}

bool donotChangeScheduler = false;
Expand Down Expand Up @@ -1813,6 +1895,12 @@ task_process_status QosOrch::handleQueueTable(Consumer& consumer, KeyOpFieldsVal
{
Port port;
SWSS_LOG_DEBUG("processing port:%s", port_name.c_str());

if(local_port == true)
{
port_name = local_port_name;
}

if (!gPortsOrch->getPort(port_name, port))
{
SWSS_LOG_ERROR("Port with alias:%s not found", port_name.c_str());
Expand Down