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

[orchagent] Support for aggregrate VOQ Counters. #3047

Closed
wants to merge 10 commits into from
71 changes: 71 additions & 0 deletions orchagent/portsorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ extern event_handle_t g_events_handle;
#define PG_WATERMARK_FLEX_STAT_COUNTER_POLL_MSECS "60000"
#define PG_DROP_FLEX_STAT_COUNTER_POLL_MSECS "10000"
#define PORT_RATE_FLEX_COUNTER_POLLING_INTERVAL_MS "1000"
#define AGG_VOQ_POLL_SEC 10

// types --------------------------------------------------------------------------------------------------------------

Expand Down Expand Up @@ -682,6 +683,12 @@ PortsOrch::PortsOrch(DBConnector *db, DBConnector *stateDb, vector<table_name_wi
m_tableVoqSystemLagMemberTable = unique_ptr<Table>(new Table(chassisAppDb, CHASSIS_APP_LAG_MEMBER_TABLE_NAME));

m_lagIdAllocator = unique_ptr<LagIdAllocator> (new LagIdAllocator(chassisAppDb));
m_tableVoqQueueCounter = unique_ptr<Table>(new Table(chassisAppDb, CHASSIS_APP_COUNTERS_TABLE_NAME));
m_agg_voq_poller = new SelectableTimer(timespec { .tv_sec = AGG_VOQ_POLL_SEC, .tv_nsec = 0 });

auto agg_voq_executor = new ExecutableTimer(m_agg_voq_poller, this, "AGG_VOQ_POLLER");
Orch::addExecutor(agg_voq_executor);
m_agg_voq_poller->start();
}

auto executor = new ExecutableTimer(m_port_state_poller, this, "PORT_STATE_POLLER");
Expand Down Expand Up @@ -9058,7 +9065,19 @@ void PortsOrch::updatePortStatePoll(const Port &port, port_state_poll_t type, bo
void PortsOrch::doTask(swss::SelectableTimer &timer)
{
Port port;
if (timer.getFd() == m_port_state_poller->getFd())
{
updatePortState();
}
else if(m_agg_voq_poller && timer.getFd() == m_agg_voq_poller->getFd())
{
updateVoqStatsChassisDb();
}
}

void PortsOrch::updatePortState()
{
Port port;
for (auto it = m_port_state_poll.begin(); it != m_port_state_poll.end(); )
{
if ((it->second == PORT_STATE_POLL_NONE) || !getPort(it->first, port))
Expand Down Expand Up @@ -9087,3 +9106,55 @@ void PortsOrch::doTask(swss::SelectableTimer &timer)
}
}

void PortsOrch::updateVoqStatsPerPortChassisDb(const Port& port)
{
std::vector<sai_object_id_t> queue_ids;
static const vector<sai_stat_id_t> queueStatIds =
{
SAI_QUEUE_STAT_PACKETS,
SAI_QUEUE_STAT_BYTES,
SAI_QUEUE_STAT_DROPPED_PACKETS,
SAI_QUEUE_STAT_DROPPED_BYTES,
};
vector<uint64_t> queueStats(queueStatIds.size());

queue_ids = m_port_voq_ids[port.m_alias];
SWSS_LOG_ENTER();

for (size_t queueIndex = 0; queueIndex < queue_ids.size(); ++queueIndex)
{
std::ostringstream key;
key << port.m_system_port_info.alias << "@" << gMyHostName << "|" << gMyAsicName << ":" << queueIndex;
Copy link
Contributor

Choose a reason for hiding this comment

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

Please share key example here.


sai_status_t status = sai_queue_api->get_queue_stats(
Copy link
Contributor

Choose a reason for hiding this comment

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

We support getting the voq stats locally at the linecard level, can we update the chassis_db when the voq stats are updated locally on the linecard? why we another timer and get the stats again to update to the chassis?

queue_ids[queueIndex],
static_cast<uint32_t>(queueStatIds.size()),
queueStatIds.data(),
queueStats.data());

if (status != SAI_STATUS_SUCCESS)
{
SWSS_LOG_ERROR("Failed to fetch queue 0x%" PRIx64 " status: %d", queue_ids[queueIndex], status);
continue;
}

//Add to CHASSIS_APP_DB
int index = 0;
for (const auto& it: queue_stat_ids)
{
SWSS_LOG_DEBUG("%s %s %s",key.str().c_str(), sai_serialize_queue_stat(it).c_str(),
to_string(queueStats[index]).c_str());
m_tableVoqQueueCounter->hset(key.str(), sai_serialize_queue_stat(it), to_string(queueStats[index++]));
Copy link
Contributor

@vmittal-msft vmittal-msft Feb 28, 2024

Choose a reason for hiding this comment

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

  1. Is this feature supported on SUP ?
  2. Please share CLI command as well as o/p.
  3. Please explain how aggregation of VoQ Stats from multiple LCs happening here. As VoQ id may be same across multiple LCs, it may end up over-writing existing data.
  4. please try reading the queue counters from LC while this polling is happening to make sure LC queue counter show is not impacting SUP o/p.

}
}
}

void PortsOrch::updateVoqStatsChassisDb(){
for (const auto& it: m_portList)
{
if (it.second.m_type != Port::PHY && it.second.m_type != Port::SYSTEM)
continue;
updateVoqStatsPerPortChassisDb( it.second );
}
}

6 changes: 6 additions & 0 deletions orchagent/portsorch.h
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,7 @@ class PortsOrch : public Orch, public Subject
bool oper_fec_sup = false;

swss::SelectableTimer *m_port_state_poller = nullptr;
swss::SelectableTimer *m_agg_voq_poller = nullptr;

bool m_cmisModuleAsicSyncSupported = false;

Expand Down Expand Up @@ -474,6 +475,7 @@ class PortsOrch : public Orch, public Subject
void updatePortStatePoll(const Port &port, port_state_poll_t type, bool active);
void refreshPortStateAutoNeg(const Port &port);
void refreshPortStateLinkTraining(const Port &port);
void updatePortState();

void getPortSerdesVal(const std::string& s, std::vector<uint32_t> &lane_values, int base = 16);
bool setPortSerdesAttribute(sai_object_id_t port_id, sai_object_id_t switch_id,
Expand Down Expand Up @@ -511,6 +513,10 @@ class PortsOrch : public Orch, public Subject
std::unordered_set<std::string> generateCounterStats(const string& type, bool gearbox = false);
map<sai_object_id_t, struct queueInfo> m_queueInfo;

void updateVoqStatsChassisDb();
void updateVoqStatsPerPortChassisDb(const Port& port);
unique_ptr<Table> m_tableVoqQueueCounter;

private:
void initializeCpuPort();
void initializePorts();
Expand Down
Loading