Skip to content

Commit 4bcd3de

Browse files
author
Shuotian Cheng
authored
[portsorch]: Only add stat IDs that are needed to query (sonic-net#396)
The hardcoded for loop was not the good option to query all IDs defined in the SAI header. While only limited partial of the counters are needed, we don't need to query each of them. Signed-off-by: Shu0T1an ChenG <shuche@microsoft.com>
1 parent 7c9f01c commit 4bcd3de

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

orchagent/portsorch.cpp

+10-2
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,14 @@ static map<string, sai_port_fec_mode_t> fec_mode_map =
3939
{ "fc", SAI_PORT_FEC_MODE_FC }
4040
};
4141

42+
static const vector<sai_queue_stat_t> queueStatIds =
43+
{
44+
SAI_QUEUE_STAT_PACKETS,
45+
SAI_QUEUE_STAT_BYTES,
46+
SAI_QUEUE_STAT_DROPPED_PACKETS,
47+
SAI_QUEUE_STAT_DROPPED_BYTES
48+
};
49+
4250
/*
4351
* Initialize PortsOrch
4452
* 0) By default, a switch has one CPU port, one 802.1Q bridge, and one default
@@ -1498,9 +1506,9 @@ void PortsOrch::initializeQueues(Port &port)
14981506

14991507
std::string delimiter = "";
15001508
std::ostringstream counters_stream;
1501-
for (int cntr = SAI_QUEUE_STAT_PACKETS; cntr <= SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES ; ++cntr)
1509+
for (auto it = queueStatIds.begin(); it != queueStatIds.end(); it++)
15021510
{
1503-
counters_stream << delimiter << sai_serialize_queue_stat(static_cast<sai_queue_stat_t>(cntr));
1511+
counters_stream << delimiter << sai_serialize_queue_stat(*it);
15041512
delimiter = ",";
15051513
}
15061514

0 commit comments

Comments
 (0)