1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2010-2014 Intel Corporation
11 qavg_q(uint16_t port_id, uint32_t subport_id, uint32_t pipe_id, uint8_t tc,
14 struct rte_sched_queue_stats stats;
15 struct rte_sched_port *port;
17 uint32_t count, i, queue_id = 0;
20 for (i = 0; i < nb_pfc; i++) {
21 if (qos_conf[i].tx_port == port_id)
26 subport_id >= port_params.n_subports_per_port ||
27 pipe_id >= subport_params[subport_id].n_pipes_per_subport_enabled ||
28 tc >= RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE ||
29 q >= RTE_SCHED_BE_QUEUES_PER_PIPE ||
30 (tc < RTE_SCHED_TRAFFIC_CLASS_BE && q > 0))
33 port = qos_conf[i].sched_port;
34 for (i = 0; i < subport_id; i++)
35 queue_id += subport_params[i].n_pipes_per_subport_enabled *
36 RTE_SCHED_QUEUES_PER_PIPE;
37 if (tc < RTE_SCHED_TRAFFIC_CLASS_BE)
38 queue_id += pipe_id * RTE_SCHED_QUEUES_PER_PIPE + tc;
40 queue_id += pipe_id * RTE_SCHED_QUEUES_PER_PIPE + tc + q;
43 for (count = 0; count < qavg_ntimes; count++) {
44 rte_sched_queue_read_stats(port, queue_id, &stats, &qlen);
49 average /= qavg_ntimes;
51 printf("\nAverage queue size: %" PRIu32 " bytes.\n\n", average);
57 qavg_tcpipe(uint16_t port_id, uint32_t subport_id, uint32_t pipe_id,
60 struct rte_sched_queue_stats stats;
61 struct rte_sched_port *port;
63 uint32_t count, i, queue_id = 0;
64 uint32_t average, part_average;
66 for (i = 0; i < nb_pfc; i++) {
67 if (qos_conf[i].tx_port == port_id)
71 if (i == nb_pfc || subport_id >= port_params.n_subports_per_port ||
72 pipe_id >= subport_params[subport_id].n_pipes_per_subport_enabled ||
73 tc >= RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE)
76 port = qos_conf[i].sched_port;
78 for (i = 0; i < subport_id; i++)
80 subport_params[i].n_pipes_per_subport_enabled *
81 RTE_SCHED_QUEUES_PER_PIPE;
83 queue_id += pipe_id * RTE_SCHED_QUEUES_PER_PIPE + tc;
87 for (count = 0; count < qavg_ntimes; count++) {
90 if (tc < RTE_SCHED_TRAFFIC_CLASS_BE) {
91 rte_sched_queue_read_stats(port, queue_id,
95 for (i = 0; i < RTE_SCHED_BE_QUEUES_PER_PIPE; i++) {
96 rte_sched_queue_read_stats(port, queue_id + i,
100 average += part_average / RTE_SCHED_BE_QUEUES_PER_PIPE;
105 average /= qavg_ntimes;
107 printf("\nAverage queue size: %" PRIu32 " bytes.\n\n", average);
113 qavg_pipe(uint16_t port_id, uint32_t subport_id, uint32_t pipe_id)
115 struct rte_sched_queue_stats stats;
116 struct rte_sched_port *port;
118 uint32_t count, i, queue_id = 0;
119 uint32_t average, part_average;
121 for (i = 0; i < nb_pfc; i++) {
122 if (qos_conf[i].tx_port == port_id)
127 subport_id >= port_params.n_subports_per_port ||
128 pipe_id >= subport_params[subport_id].n_pipes_per_subport_enabled)
131 port = qos_conf[i].sched_port;
133 for (i = 0; i < subport_id; i++)
134 queue_id += subport_params[i].n_pipes_per_subport_enabled *
135 RTE_SCHED_QUEUES_PER_PIPE;
137 queue_id += pipe_id * RTE_SCHED_QUEUES_PER_PIPE;
141 for (count = 0; count < qavg_ntimes; count++) {
143 for (i = 0; i < RTE_SCHED_QUEUES_PER_PIPE; i++) {
144 rte_sched_queue_read_stats(port, queue_id + i,
146 part_average += qlen;
148 average += part_average / RTE_SCHED_QUEUES_PER_PIPE;
152 average /= qavg_ntimes;
154 printf("\nAverage queue size: %" PRIu32 " bytes.\n\n", average);
160 qavg_tcsubport(uint16_t port_id, uint32_t subport_id, uint8_t tc)
162 struct rte_sched_queue_stats stats;
163 struct rte_sched_port *port;
165 uint32_t queue_id, count, i, j, subport_queue_id = 0;
166 uint32_t average, part_average;
168 for (i = 0; i < nb_pfc; i++) {
169 if (qos_conf[i].tx_port == port_id)
174 subport_id >= port_params.n_subports_per_port ||
175 tc >= RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE)
178 port = qos_conf[i].sched_port;
180 for (i = 0; i < subport_id; i++)
182 subport_params[i].n_pipes_per_subport_enabled *
183 RTE_SCHED_QUEUES_PER_PIPE;
187 for (count = 0; count < qavg_ntimes; count++) {
188 uint32_t n_pipes_per_subport =
189 subport_params[subport_id].n_pipes_per_subport_enabled;
192 for (i = 0; i < n_pipes_per_subport; i++) {
193 if (tc < RTE_SCHED_TRAFFIC_CLASS_BE) {
194 queue_id = subport_queue_id +
195 i * RTE_SCHED_QUEUES_PER_PIPE + tc;
196 rte_sched_queue_read_stats(port, queue_id,
198 part_average += qlen;
200 for (j = 0; j < RTE_SCHED_BE_QUEUES_PER_PIPE; j++) {
201 queue_id = subport_queue_id +
202 i * RTE_SCHED_QUEUES_PER_PIPE +
204 rte_sched_queue_read_stats(port, queue_id,
206 part_average += qlen;
211 if (tc < RTE_SCHED_TRAFFIC_CLASS_BE)
212 average += part_average /
213 (subport_params[subport_id].n_pipes_per_subport_enabled);
215 average += part_average /
216 (subport_params[subport_id].n_pipes_per_subport_enabled) *
217 RTE_SCHED_BE_QUEUES_PER_PIPE;
222 average /= qavg_ntimes;
224 printf("\nAverage queue size: %" PRIu32 " bytes.\n\n", average);
230 qavg_subport(uint16_t port_id, uint32_t subport_id)
232 struct rte_sched_queue_stats stats;
233 struct rte_sched_port *port;
235 uint32_t queue_id, count, i, j, subport_queue_id = 0;
236 uint32_t average, part_average;
238 for (i = 0; i < nb_pfc; i++) {
239 if (qos_conf[i].tx_port == port_id)
244 subport_id >= port_params.n_subports_per_port)
247 port = qos_conf[i].sched_port;
249 for (i = 0; i < subport_id; i++)
250 subport_queue_id += subport_params[i].n_pipes_per_subport_enabled *
251 RTE_SCHED_QUEUES_PER_PIPE;
255 for (count = 0; count < qavg_ntimes; count++) {
256 uint32_t n_pipes_per_subport =
257 subport_params[subport_id].n_pipes_per_subport_enabled;
260 for (i = 0; i < n_pipes_per_subport; i++) {
261 queue_id = subport_queue_id + i * RTE_SCHED_QUEUES_PER_PIPE;
263 for (j = 0; j < RTE_SCHED_QUEUES_PER_PIPE; j++) {
264 rte_sched_queue_read_stats(port, queue_id + j,
266 part_average += qlen;
270 average += part_average /
271 (subport_params[subport_id].n_pipes_per_subport_enabled *
272 RTE_SCHED_QUEUES_PER_PIPE);
276 average /= qavg_ntimes;
278 printf("\nAverage queue size: %" PRIu32 " bytes.\n\n", average);
284 subport_stat(uint16_t port_id, uint32_t subport_id)
286 struct rte_sched_subport_stats stats;
287 struct rte_sched_port *port;
288 uint32_t tc_ov[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
291 for (i = 0; i < nb_pfc; i++) {
292 if (qos_conf[i].tx_port == port_id)
296 if (i == nb_pfc || subport_id >= port_params.n_subports_per_port)
299 port = qos_conf[i].sched_port;
300 memset(tc_ov, 0, sizeof(tc_ov));
302 rte_sched_subport_read_stats(port, subport_id, &stats, tc_ov);
305 printf("+----+-------------+-------------+-------------+-------------+-------------+\n");
306 printf("| TC | Pkts OK |Pkts Dropped | Bytes OK |Bytes Dropped| OV Status |\n");
307 printf("+----+-------------+-------------+-------------+-------------+-------------+\n");
309 for (i = 0; i < RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE; i++) {
310 printf("| %d | %11" PRIu64 " | %11" PRIu64 " | %11" PRIu64 " | %11" PRIu64 " | %11" PRIu32 " |\n",
311 i, stats.n_pkts_tc[i], stats.n_pkts_tc_dropped[i],
312 stats.n_bytes_tc[i], stats.n_bytes_tc_dropped[i], tc_ov[i]);
313 printf("+----+-------------+-------------+-------------+-------------+-------------+\n");
321 pipe_stat(uint16_t port_id, uint32_t subport_id, uint32_t pipe_id)
323 struct rte_sched_queue_stats stats;
324 struct rte_sched_port *port;
327 uint32_t queue_id = 0;
329 for (i = 0; i < nb_pfc; i++) {
330 if (qos_conf[i].tx_port == port_id)
335 subport_id >= port_params.n_subports_per_port ||
336 pipe_id >= subport_params[subport_id].n_pipes_per_subport_enabled)
339 port = qos_conf[i].sched_port;
340 for (i = 0; i < subport_id; i++)
341 queue_id += subport_params[i].n_pipes_per_subport_enabled *
342 RTE_SCHED_QUEUES_PER_PIPE;
344 queue_id += pipe_id * RTE_SCHED_QUEUES_PER_PIPE;
347 printf("+----+-------+-------------+-------------+-------------+-------------+-------------+\n");
348 printf("| TC | Queue | Pkts OK |Pkts Dropped | Bytes OK |Bytes Dropped| Length |\n");
349 printf("+----+-------+-------------+-------------+-------------+-------------+-------------+\n");
351 for (i = 0; i < RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE; i++) {
352 if (i < RTE_SCHED_TRAFFIC_CLASS_BE) {
353 rte_sched_queue_read_stats(port, queue_id + i, &stats, &qlen);
354 printf("| %d | %d | %11" PRIu64 " | %11" PRIu64 " | %11" PRIu64 " | %11" PRIu64 " | %11i |\n",
355 i, 0, stats.n_pkts, stats.n_pkts_dropped, stats.n_bytes,
356 stats.n_bytes_dropped, qlen);
357 printf("+----+-------+-------------+-------------+-------------+-------------+-------------+\n");
359 for (j = 0; j < RTE_SCHED_BE_QUEUES_PER_PIPE; j++) {
360 rte_sched_queue_read_stats(port, queue_id + i + j,
362 printf("| %d | %d | %11" PRIu64 " | %11" PRIu64 " | %11" PRIu64 " | %11" PRIu64 " | %11i |\n",
363 i, j, stats.n_pkts, stats.n_pkts_dropped, stats.n_bytes,
364 stats.n_bytes_dropped, qlen);
365 printf("+----+-------+-------------+-------------+-------------+-------------+-------------+\n");