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 queue_id
, count
, i
;
20 for (i
= 0; i
< nb_pfc
; i
++) {
21 if (qos_conf
[i
].tx_port
== port_id
)
24 if (i
== nb_pfc
|| subport_id
>= port_params
.n_subports_per_port
|| pipe_id
>= port_params
.n_pipes_per_subport
25 || tc
>= RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE
|| q
>= RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS
)
28 port
= qos_conf
[i
].sched_port
;
30 queue_id
= RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE
* RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS
* (subport_id
* port_params
.n_pipes_per_subport
+ pipe_id
);
31 queue_id
= queue_id
+ (tc
* RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS
+ q
);
35 for (count
= 0; count
< qavg_ntimes
; count
++) {
36 rte_sched_queue_read_stats(port
, queue_id
, &stats
, &qlen
);
41 average
/= qavg_ntimes
;
43 printf("\nAverage queue size: %" PRIu32
" bytes.\n\n", average
);
49 qavg_tcpipe(uint16_t port_id
, uint32_t subport_id
, uint32_t pipe_id
,
52 struct rte_sched_queue_stats stats
;
53 struct rte_sched_port
*port
;
55 uint32_t queue_id
, count
, i
;
56 uint32_t average
, part_average
;
58 for (i
= 0; i
< nb_pfc
; i
++) {
59 if (qos_conf
[i
].tx_port
== port_id
)
62 if (i
== nb_pfc
|| subport_id
>= port_params
.n_subports_per_port
|| pipe_id
>= port_params
.n_pipes_per_subport
63 || tc
>= RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE
)
66 port
= qos_conf
[i
].sched_port
;
68 queue_id
= RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE
* RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS
* (subport_id
* port_params
.n_pipes_per_subport
+ pipe_id
);
72 for (count
= 0; count
< qavg_ntimes
; count
++) {
74 for (i
= 0; i
< RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS
; i
++) {
75 rte_sched_queue_read_stats(port
, queue_id
+ (tc
* RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS
+ i
), &stats
, &qlen
);
78 average
+= part_average
/ RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS
;
82 average
/= qavg_ntimes
;
84 printf("\nAverage queue size: %" PRIu32
" bytes.\n\n", average
);
90 qavg_pipe(uint16_t port_id
, uint32_t subport_id
, uint32_t pipe_id
)
92 struct rte_sched_queue_stats stats
;
93 struct rte_sched_port
*port
;
95 uint32_t queue_id
, count
, i
;
96 uint32_t average
, part_average
;
98 for (i
= 0; i
< nb_pfc
; i
++) {
99 if (qos_conf
[i
].tx_port
== port_id
)
102 if (i
== nb_pfc
|| subport_id
>= port_params
.n_subports_per_port
|| pipe_id
>= port_params
.n_pipes_per_subport
)
105 port
= qos_conf
[i
].sched_port
;
107 queue_id
= RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE
* RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS
* (subport_id
* port_params
.n_pipes_per_subport
+ pipe_id
);
111 for (count
= 0; count
< qavg_ntimes
; count
++) {
113 for (i
= 0; i
< RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE
* RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS
; i
++) {
114 rte_sched_queue_read_stats(port
, queue_id
+ i
, &stats
, &qlen
);
115 part_average
+= qlen
;
117 average
+= part_average
/ (RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE
* RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS
);
121 average
/= qavg_ntimes
;
123 printf("\nAverage queue size: %" PRIu32
" bytes.\n\n", average
);
129 qavg_tcsubport(uint16_t port_id
, uint32_t subport_id
, uint8_t tc
)
131 struct rte_sched_queue_stats stats
;
132 struct rte_sched_port
*port
;
134 uint32_t queue_id
, count
, i
, j
;
135 uint32_t average
, part_average
;
137 for (i
= 0; i
< nb_pfc
; i
++) {
138 if (qos_conf
[i
].tx_port
== port_id
)
141 if (i
== nb_pfc
|| subport_id
>= port_params
.n_subports_per_port
|| tc
>= RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE
)
144 port
= qos_conf
[i
].sched_port
;
148 for (count
= 0; count
< qavg_ntimes
; count
++) {
150 for (i
= 0; i
< port_params
.n_pipes_per_subport
; i
++) {
151 queue_id
= RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE
* RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS
* (subport_id
* port_params
.n_pipes_per_subport
+ i
);
153 for (j
= 0; j
< RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS
; j
++) {
154 rte_sched_queue_read_stats(port
, queue_id
+ (tc
* RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS
+ j
), &stats
, &qlen
);
155 part_average
+= qlen
;
159 average
+= part_average
/ (port_params
.n_pipes_per_subport
* RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS
);
163 average
/= qavg_ntimes
;
165 printf("\nAverage queue size: %" PRIu32
" bytes.\n\n", average
);
171 qavg_subport(uint16_t port_id
, uint32_t subport_id
)
173 struct rte_sched_queue_stats stats
;
174 struct rte_sched_port
*port
;
176 uint32_t queue_id
, count
, i
, j
;
177 uint32_t average
, part_average
;
179 for (i
= 0; i
< nb_pfc
; i
++) {
180 if (qos_conf
[i
].tx_port
== port_id
)
183 if (i
== nb_pfc
|| subport_id
>= port_params
.n_subports_per_port
)
186 port
= qos_conf
[i
].sched_port
;
190 for (count
= 0; count
< qavg_ntimes
; count
++) {
192 for (i
= 0; i
< port_params
.n_pipes_per_subport
; i
++) {
193 queue_id
= RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE
* RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS
* (subport_id
* port_params
.n_pipes_per_subport
+ i
);
195 for (j
= 0; j
< RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE
* RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS
; j
++) {
196 rte_sched_queue_read_stats(port
, queue_id
+ j
, &stats
, &qlen
);
197 part_average
+= qlen
;
201 average
+= part_average
/ (port_params
.n_pipes_per_subport
* RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE
* RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS
);
205 average
/= qavg_ntimes
;
207 printf("\nAverage queue size: %" PRIu32
" bytes.\n\n", average
);
213 subport_stat(uint16_t port_id
, uint32_t subport_id
)
215 struct rte_sched_subport_stats stats
;
216 struct rte_sched_port
*port
;
217 uint32_t tc_ov
[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE
];
220 for (i
= 0; i
< nb_pfc
; i
++) {
221 if (qos_conf
[i
].tx_port
== port_id
)
224 if (i
== nb_pfc
|| subport_id
>= port_params
.n_subports_per_port
)
227 port
= qos_conf
[i
].sched_port
;
228 memset (tc_ov
, 0, sizeof(tc_ov
));
230 rte_sched_subport_read_stats(port
, subport_id
, &stats
, tc_ov
);
233 printf("+----+-------------+-------------+-------------+-------------+-------------+\n");
234 printf("| TC | Pkts OK |Pkts Dropped | Bytes OK |Bytes Dropped| OV Status |\n");
235 printf("+----+-------------+-------------+-------------+-------------+-------------+\n");
237 for (i
= 0; i
< RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE
; i
++) {
238 printf("| %d | %11" PRIu32
" | %11" PRIu32
" | %11" PRIu32
" | %11" PRIu32
" | %11" PRIu32
" |\n", i
,
239 stats
.n_pkts_tc
[i
], stats
.n_pkts_tc_dropped
[i
],
240 stats
.n_bytes_tc
[i
], stats
.n_bytes_tc_dropped
[i
], tc_ov
[i
]);
241 printf("+----+-------------+-------------+-------------+-------------+-------------+\n");
249 pipe_stat(uint16_t port_id
, uint32_t subport_id
, uint32_t pipe_id
)
251 struct rte_sched_queue_stats stats
;
252 struct rte_sched_port
*port
;
257 for (i
= 0; i
< nb_pfc
; i
++) {
258 if (qos_conf
[i
].tx_port
== port_id
)
261 if (i
== nb_pfc
|| subport_id
>= port_params
.n_subports_per_port
|| pipe_id
>= port_params
.n_pipes_per_subport
)
264 port
= qos_conf
[i
].sched_port
;
266 queue_id
= RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE
* RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS
* (subport_id
* port_params
.n_pipes_per_subport
+ pipe_id
);
269 printf("+----+-------+-------------+-------------+-------------+-------------+-------------+\n");
270 printf("| TC | Queue | Pkts OK |Pkts Dropped | Bytes OK |Bytes Dropped| Length |\n");
271 printf("+----+-------+-------------+-------------+-------------+-------------+-------------+\n");
273 for (i
= 0; i
< RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE
; i
++) {
274 for (j
= 0; j
< RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS
; j
++) {
276 rte_sched_queue_read_stats(port
, queue_id
+ (i
* RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS
+ j
), &stats
, &qlen
);
278 printf("| %d | %d | %11" PRIu32
" | %11" PRIu32
" | %11" PRIu32
" | %11" PRIu32
" | %11i |\n", i
, j
,
279 stats
.n_pkts
, stats
.n_pkts_dropped
, stats
.n_bytes
, stats
.n_bytes_dropped
, qlen
);
280 printf("+----+-------+-------------+-------------+-------------+-------------+-------------+\n");
282 if (i
< RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE
- 1)
283 printf("+----+-------+-------------+-------------+-------------+-------------+-------------+\n");