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

[bufferorch] : Support for buffer profiles for VoQ on chassis (#2465) #2618

Merged
merged 4 commits into from
Mar 8, 2023
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
135 changes: 114 additions & 21 deletions orchagent/bufferorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ extern sai_buffer_api_t *sai_buffer_api;
extern PortsOrch *gPortsOrch;
extern Directory<Orch*> gDirectory;
extern sai_object_id_t gSwitchId;
extern string gMySwitchType;

#define BUFFER_POOL_WATERMARK_FLEX_STAT_COUNTER_POLL_MSECS "60000"

Expand Down Expand Up @@ -103,16 +104,32 @@ void BufferOrch::initBufferReadyLists(DBConnector *applDb, DBConnector *confDb)
Table pg_table(applDb, APP_BUFFER_PG_TABLE_NAME);
initBufferReadyList(pg_table, false);

Table queue_table(applDb, APP_BUFFER_QUEUE_TABLE_NAME);
initBufferReadyList(queue_table, false);
if(gMySwitchType == "voq")
{
Table queue_table(applDb, APP_BUFFER_QUEUE_TABLE_NAME);
initVoqBufferReadyList(queue_table, false);
}
else
{
Table queue_table(applDb, APP_BUFFER_QUEUE_TABLE_NAME);
initBufferReadyList(queue_table, false);
}
}
else
{
Table pg_table(confDb, CFG_BUFFER_PG_TABLE_NAME);
initBufferReadyList(pg_table, true);

Table queue_table(confDb, CFG_BUFFER_QUEUE_TABLE_NAME);
initBufferReadyList(queue_table, true);
if(gMySwitchType == "voq")
{
Table queue_table(confDb, CFG_BUFFER_QUEUE_TABLE_NAME);
initVoqBufferReadyList(queue_table, true);
}
else
{
Table queue_table(confDb, CFG_BUFFER_QUEUE_TABLE_NAME);
initBufferReadyList(queue_table, true);
}
}
}

Expand Down Expand Up @@ -149,6 +166,38 @@ void BufferOrch::initBufferReadyList(Table& table, bool isConfigDb)
}
}

void BufferOrch::initVoqBufferReadyList(Table& table, bool isConfigDb)
{
SWSS_LOG_ENTER();

std::vector<std::string> keys;
table.getKeys(keys);

const char dbKeyDelimiter = (isConfigDb ? config_db_key_delimiter : delimiter);

// populate the lists with buffer configuration information
for (const auto& key: keys)
{
auto &&tokens = tokenize(key, dbKeyDelimiter);
if (tokens.size() != 4)
{
SWSS_LOG_ERROR("Wrong format of a table '%s' key '%s'. Skip it", table.getTableName().c_str(), key.c_str());
continue;
}

// We need transform the key from config db format to appl db format
auto appldb_key = tokens[0] + config_db_key_delimiter + tokens[1] + config_db_key_delimiter + tokens[2] + delimiter + tokens[3];
m_ready_list[appldb_key] = false;

auto &&port_names = tokenize(tokens[0] + config_db_key_delimiter + tokens[1] + config_db_key_delimiter + tokens[2], list_item_delimiter);
for(const auto& port_name: port_names)
{
SWSS_LOG_INFO("Item %s has been inserted into ready list", appldb_key.c_str());
m_port_ready_list_ref[port_name].push_back(appldb_key);
}
}
}

void BufferOrch::initBufferConstants()
{
sai_status_t status;
Expand Down Expand Up @@ -712,7 +761,8 @@ task_process_status BufferOrch::processBufferProfile(KeyOpFieldsValuesTuple &tup
}

/*
Input sample "BUFFER_QUEUE|Ethernet4,Ethernet45|10-15"
Input sample "BUFFER_QUEUE|Ethernet4,Ethernet45|10-15" or
"BUFFER_QUEUE|STG01-0101-0400-01T2-LC6|ASIC0|Ethernet4|10-15"
*/
task_process_status BufferOrch::processQueue(KeyOpFieldsValuesTuple &tuple)
{
Expand All @@ -727,15 +777,35 @@ task_process_status BufferOrch::processQueue(KeyOpFieldsValuesTuple &tuple)

SWSS_LOG_DEBUG("Processing:%s", key.c_str());
tokens = tokenize(key, delimiter);
if (tokens.size() != 2)

vector<string> port_names;
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))
{
return task_process_status::task_invalid_entry;
}
}
vector<string> port_names = tokenize(tokens[0], list_item_delimiter);
if (!parseIndexRange(tokens[1], range_low, range_high))
else
{
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))
{
return task_process_status::task_invalid_entry;
}
}

if (op == SET_COMMAND)
Expand Down Expand Up @@ -792,20 +862,35 @@ task_process_status BufferOrch::processQueue(KeyOpFieldsValuesTuple &tuple)
for (size_t ind = range_low; ind <= range_high; ind++)
{
SWSS_LOG_DEBUG("processing queue:%zd", ind);
if (port.m_queue_ids.size() <= ind)
sai_object_id_t queue_id;

if (gMySwitchType == "voq")
{
SWSS_LOG_ERROR("Invalid queue index specified:%zd", ind);
return task_process_status::task_invalid_entry;
}
if (port.m_queue_lock[ind])
std :: vector<sai_object_id_t> queue_ids = gPortsOrch->getPortVoQIds(port);
if (queue_ids.size() <= ind)
{
SWSS_LOG_ERROR("Invalid voq index specified:%zd", ind);
return task_process_status::task_invalid_entry;
}
queue_id = queue_ids[ind];
}
else
{
SWSS_LOG_WARN("Queue %zd on port %s is locked, will retry", ind, port_name.c_str());
return task_process_status::task_need_retry;
if (port.m_queue_ids.size() <= ind)
{
SWSS_LOG_ERROR("Invalid queue index specified:%zd", ind);
return task_process_status::task_invalid_entry;
}
if (port.m_queue_lock[ind])
{
SWSS_LOG_WARN("Queue %zd on port %s is locked, will retry", ind, port_name.c_str());
return task_process_status::task_need_retry;
}
queue_id = port.m_queue_ids[ind];
}

if (need_update_sai)
{
sai_object_id_t queue_id;
queue_id = port.m_queue_ids[ind];
SWSS_LOG_DEBUG("Applying buffer profile:0x%" PRIx64 " to queue index:%zd, queue sai_id:0x%" PRIx64, sai_buffer_profile, ind, queue_id);
sai_status_t sai_status = sai_queue_api->set_queue_attribute(queue_id, &attr);
if (sai_status != SAI_STATUS_SUCCESS)
Expand Down Expand Up @@ -1258,7 +1343,15 @@ void BufferOrch::doTask(Consumer &consumer)
{
SWSS_LOG_ENTER();

if (!gPortsOrch->isConfigDone())
if (gMySwitchType == "voq")
{
if(!gPortsOrch->isInitDone())
{
SWSS_LOG_INFO("Buffer task for %s can't be executed ahead of port config done", consumer.getTableName().c_str());
return;
}
}
else if (!gPortsOrch->isConfigDone())
{
SWSS_LOG_INFO("Buffer task for %s can't be executed ahead of port config done", consumer.getTableName().c_str());
return;
Expand Down
1 change: 1 addition & 0 deletions orchagent/bufferorch.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class BufferOrch : public Orch
void initTableHandlers();
void initBufferReadyLists(DBConnector *confDb, DBConnector *applDb);
void initBufferReadyList(Table& table, bool isConfigDb);
void initVoqBufferReadyList(Table& table, bool isConfigDb);
void initFlexCounterGroupTable(void);
void initBufferConstants();
task_process_status processBufferPool(KeyOpFieldsValuesTuple &tuple);
Expand Down
6 changes: 6 additions & 0 deletions orchagent/flexcounterorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ extern BufferOrch *gBufferOrch;
extern Directory<Orch*> gDirectory;
extern CoppOrch *gCoppOrch;
extern FlowCounterRouteOrch *gFlowCounterRouteOrch;
extern string gMySwitchType;

#define BUFFER_POOL_WATERMARK_KEY "BUFFER_POOL_WATERMARK"
#define PORT_KEY "PORT"
Expand Down Expand Up @@ -336,6 +337,11 @@ map<string, FlexCounterQueueStates> FlexCounterOrch::getQueueConfigurations()
std::vector<std::string> portQueueKeys;
m_bufferQueueConfigTable.getKeys(portQueueKeys);

if (gMySwitchType == "voq")
{
return queuesStateVector;
}

for (const auto& portQueueKey : portQueueKeys)
{
auto toks = tokenize(portQueueKey, '|');
Expand Down
9 changes: 8 additions & 1 deletion orchagent/portsorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6101,7 +6101,7 @@ void PortsOrch::generateQueueMapPerPort(const Port& port, FlexCounterQueueStates
{
/* voq counters are always enabled. There is no mechanism to disable voq
* counters in a voq system. */
if (!voq && !queuesState.isQueueCounterEnabled(queueRealIndex))
if ((gMySwitchType != "voq") && !queuesState.isQueueCounterEnabled(queueRealIndex))
{
continue;
}
Expand Down Expand Up @@ -8059,6 +8059,13 @@ bool PortsOrch::isMACsecPort(sai_object_id_t port_id) const
return m_macsecEnabledPorts.find(port_id) != m_macsecEnabledPorts.end();
}

vector<sai_object_id_t> PortsOrch::getPortVoQIds(Port& port)
{
SWSS_LOG_ENTER();

return m_port_voq_ids[port.m_alias];
}

/* Refresh the per-port Auto-Negotiation operational states */
void PortsOrch::refreshPortStateAutoNeg(const Port &port)
{
Expand Down
1 change: 1 addition & 0 deletions orchagent/portsorch.h
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ class PortsOrch : public Orch, public Subject

void setMACsecEnabledState(sai_object_id_t port_id, bool enabled);
bool isMACsecPort(sai_object_id_t port_id) const;
vector<sai_object_id_t> getPortVoQIds(Port& port);

private:
unique_ptr<Table> m_counterTable;
Expand Down