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 >= port_params.n_pipes_per_subport ||
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 += port_params.n_pipes_per_subport *
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 >= port_params.n_pipes_per_subport ||
73 tc >= RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE)
76 port = qos_conf[i].sched_port;
78 for (i = 0; i < subport_id; i++)
79 queue_id += port_params.n_pipes_per_subport * RTE_SCHED_QUEUES_PER_PIPE;
81 queue_id += pipe_id * RTE_SCHED_QUEUES_PER_PIPE + tc;
85 for (count = 0; count < qavg_ntimes; count++) {
88 if (tc < RTE_SCHED_TRAFFIC_CLASS_BE) {
89 rte_sched_queue_read_stats(port, queue_id,
93 for (i = 0; i < RTE_SCHED_BE_QUEUES_PER_PIPE; i++) {
94 rte_sched_queue_read_stats(port, queue_id + i,
98 average += part_average / RTE_SCHED_BE_QUEUES_PER_PIPE;
103 average /= qavg_ntimes;
105 printf("\nAverage queue size: %" PRIu32 " bytes.\n\n", average);
111 qavg_pipe(uint16_t port_id, uint32_t subport_id, uint32_t pipe_id)
113 struct rte_sched_queue_stats stats;
114 struct rte_sched_port *port;
116 uint32_t count, i, queue_id = 0;
117 uint32_t average, part_average;
119 for (i = 0; i < nb_pfc; i++) {
120 if (qos_conf[i].tx_port == port_id)
125 subport_id >= port_params.n_subports_per_port ||
126 pipe_id >= port_params.n_pipes_per_subport)
129 port = qos_conf[i].sched_port;
131 for (i = 0; i < subport_id; i++)
132 queue_id += port_params.n_pipes_per_subport *
133 RTE_SCHED_QUEUES_PER_PIPE;
135 queue_id += pipe_id * RTE_SCHED_QUEUES_PER_PIPE;
139 for (count = 0; count < qavg_ntimes; count++) {
141 for (i = 0; i < RTE_SCHED_QUEUES_PER_PIPE; i++) {
142 rte_sched_queue_read_stats(port, queue_id + i,
144 part_average += qlen;
146 average += part_average / RTE_SCHED_QUEUES_PER_PIPE;
150 average /= qavg_ntimes;
152 printf("\nAverage queue size: %" PRIu32 " bytes.\n\n", average);
158 qavg_tcsubport(uint16_t port_id, uint32_t subport_id, uint8_t tc)
160 struct rte_sched_queue_stats stats;
161 struct rte_sched_port *port;
163 uint32_t queue_id, count, i, j, subport_queue_id = 0;
164 uint32_t average, part_average;
166 for (i = 0; i < nb_pfc; i++) {
167 if (qos_conf[i].tx_port == port_id)
172 subport_id >= port_params.n_subports_per_port ||
173 tc >= RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE)
176 port = qos_conf[i].sched_port;
178 for (i = 0; i < subport_id; i++)
180 port_params.n_pipes_per_subport * RTE_SCHED_QUEUES_PER_PIPE;
184 for (count = 0; count < qavg_ntimes; count++) {
186 for (i = 0; i < port_params.n_pipes_per_subport; i++) {
187 if (tc < RTE_SCHED_TRAFFIC_CLASS_BE) {
188 queue_id = subport_queue_id +
189 i * RTE_SCHED_QUEUES_PER_PIPE + tc;
190 rte_sched_queue_read_stats(port, queue_id,
192 part_average += qlen;
194 for (j = 0; j < RTE_SCHED_BE_QUEUES_PER_PIPE; j++) {
195 queue_id = subport_queue_id +
196 i * RTE_SCHED_QUEUES_PER_PIPE +
198 rte_sched_queue_read_stats(port, queue_id,
200 part_average += qlen;
205 if (tc < RTE_SCHED_TRAFFIC_CLASS_BE)
206 average += part_average / (port_params.n_pipes_per_subport);
209 part_average / (port_params.n_pipes_per_subport) *
210 RTE_SCHED_BE_QUEUES_PER_PIPE;
215 average /= qavg_ntimes;
217 printf("\nAverage queue size: %" PRIu32 " bytes.\n\n", average);
223 qavg_subport(uint16_t port_id, uint32_t subport_id)
225 struct rte_sched_queue_stats stats;
226 struct rte_sched_port *port;
228 uint32_t queue_id, count, i, j, subport_queue_id = 0;
229 uint32_t average, part_average;
231 for (i = 0; i < nb_pfc; i++) {
232 if (qos_conf[i].tx_port == port_id)
237 subport_id >= port_params.n_subports_per_port)
240 port = qos_conf[i].sched_port;
242 for (i = 0; i < subport_id; i++)
243 subport_queue_id += port_params.n_pipes_per_subport *
244 RTE_SCHED_QUEUES_PER_PIPE;
248 for (count = 0; count < qavg_ntimes; count++) {
250 for (i = 0; i < port_params.n_pipes_per_subport; i++) {
251 queue_id = subport_queue_id + i * RTE_SCHED_QUEUES_PER_PIPE;
253 for (j = 0; j < RTE_SCHED_QUEUES_PER_PIPE; j++) {
254 rte_sched_queue_read_stats(port, queue_id + j,
256 part_average += qlen;
260 average += part_average /
261 (port_params.n_pipes_per_subport * RTE_SCHED_QUEUES_PER_PIPE);
265 average /= qavg_ntimes;
267 printf("\nAverage queue size: %" PRIu32 " bytes.\n\n", average);
273 subport_stat(uint16_t port_id, uint32_t subport_id)
275 struct rte_sched_subport_stats stats;
276 struct rte_sched_port *port;
277 uint32_t tc_ov[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
280 for (i = 0; i < nb_pfc; i++) {
281 if (qos_conf[i].tx_port == port_id)
285 if (i == nb_pfc || subport_id >= port_params.n_subports_per_port)
288 port = qos_conf[i].sched_port;
289 memset(tc_ov, 0, sizeof(tc_ov));
291 rte_sched_subport_read_stats(port, subport_id, &stats, tc_ov);
294 printf("+----+-------------+-------------+-------------+-------------+-------------+\n");
295 printf("| TC | Pkts OK |Pkts Dropped | Bytes OK |Bytes Dropped| OV Status |\n");
296 printf("+----+-------------+-------------+-------------+-------------+-------------+\n");
298 for (i = 0; i < RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE; i++) {
299 printf("| %d | %11" PRIu32 " | %11" PRIu32 " | %11" PRIu32 " | %11" PRIu32 " | %11" PRIu32 " |\n",
300 i, stats.n_pkts_tc[i], stats.n_pkts_tc_dropped[i],
301 stats.n_bytes_tc[i], stats.n_bytes_tc_dropped[i], tc_ov[i]);
302 printf("+----+-------------+-------------+-------------+-------------+-------------+\n");
310 pipe_stat(uint16_t port_id, uint32_t subport_id, uint32_t pipe_id)
312 struct rte_sched_queue_stats stats;
313 struct rte_sched_port *port;
316 uint32_t queue_id = 0;
318 for (i = 0; i < nb_pfc; i++) {
319 if (qos_conf[i].tx_port == port_id)
324 subport_id >= port_params.n_subports_per_port ||
325 pipe_id >= port_params.n_pipes_per_subport)
328 port = qos_conf[i].sched_port;
329 for (i = 0; i < subport_id; i++)
330 queue_id += port_params.n_pipes_per_subport * RTE_SCHED_QUEUES_PER_PIPE;
332 queue_id += pipe_id * RTE_SCHED_QUEUES_PER_PIPE;
335 printf("+----+-------+-------------+-------------+-------------+-------------+-------------+\n");
336 printf("| TC | Queue | Pkts OK |Pkts Dropped | Bytes OK |Bytes Dropped| Length |\n");
337 printf("+----+-------+-------------+-------------+-------------+-------------+-------------+\n");
339 for (i = 0; i < RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE; i++) {
340 if (i < RTE_SCHED_TRAFFIC_CLASS_BE) {
341 rte_sched_queue_read_stats(port, queue_id + i, &stats, &qlen);
342 printf("| %d | %d | %11" PRIu32 " | %11" PRIu32 " | %11" PRIu32 " | %11" PRIu32 " | %11i |\n",
343 i, 0, stats.n_pkts, stats.n_pkts_dropped, stats.n_bytes,
344 stats.n_bytes_dropped, qlen);
345 printf("+----+-------+-------------+-------------+-------------+-------------+-------------+\n");
347 for (j = 0; j < RTE_SCHED_BE_QUEUES_PER_PIPE; j++) {
348 rte_sched_queue_read_stats(port, queue_id + i + j,
350 printf("| %d | %d | %11" PRIu32 " | %11" PRIu32 " | %11" PRIu32 " | %11" PRIu32 " | %11i |\n",
351 i, j, stats.n_pkts, stats.n_pkts_dropped, stats.n_bytes,
352 stats.n_bytes_dropped, qlen);
353 printf("+----+-------+-------------+-------------+-------------+-------------+-------------+\n");