4 * * Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
5 * * All rights reserved.
7 * * Redistribution and use in source and binary forms, with or without
8 * * modification, are permitted provided that the following conditions
11 * * * Redistributions of source code must retain the above copyright
12 * * notice, this list of conditions and the following disclaimer.
13 * * * Redistributions in binary form must reproduce the above copyright
14 * * notice, this list of conditions and the following disclaimer in
15 * * the documentation and/or other materials provided with the
17 * * * Neither the name of Intel Corporation nor the names of its
18 * * contributors may be used to endorse or promote products derived
19 * * from this software without specific prior written permission.
21 * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 * * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 * * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 * * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 * * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 * * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
40 qavg_q(uint8_t port_id
, uint32_t subport_id
, uint32_t pipe_id
, uint8_t tc
, uint8_t q
)
42 struct rte_sched_queue_stats stats
;
43 struct rte_sched_port
*port
;
45 uint32_t queue_id
, count
, i
;
48 for (i
= 0; i
< nb_pfc
; i
++) {
49 if (qos_conf
[i
].tx_port
== port_id
)
52 if (i
== nb_pfc
|| subport_id
>= port_params
.n_subports_per_port
|| pipe_id
>= port_params
.n_pipes_per_subport
53 || tc
>= RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE
|| q
>= RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS
)
56 port
= qos_conf
[i
].sched_port
;
58 queue_id
= RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE
* RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS
* (subport_id
* port_params
.n_pipes_per_subport
+ pipe_id
);
59 queue_id
= queue_id
+ (tc
* RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS
+ q
);
63 for (count
= 0; count
< qavg_ntimes
; count
++) {
64 rte_sched_queue_read_stats(port
, queue_id
, &stats
, &qlen
);
69 average
/= qavg_ntimes
;
71 printf("\nAverage queue size: %" PRIu32
" bytes.\n\n", average
);
77 qavg_tcpipe(uint8_t port_id
, uint32_t subport_id
, uint32_t pipe_id
, uint8_t tc
)
79 struct rte_sched_queue_stats stats
;
80 struct rte_sched_port
*port
;
82 uint32_t queue_id
, count
, i
;
83 uint32_t average
, part_average
;
85 for (i
= 0; i
< nb_pfc
; i
++) {
86 if (qos_conf
[i
].tx_port
== port_id
)
89 if (i
== nb_pfc
|| subport_id
>= port_params
.n_subports_per_port
|| pipe_id
>= port_params
.n_pipes_per_subport
90 || tc
>= RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE
)
93 port
= qos_conf
[i
].sched_port
;
95 queue_id
= RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE
* RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS
* (subport_id
* port_params
.n_pipes_per_subport
+ pipe_id
);
99 for (count
= 0; count
< qavg_ntimes
; count
++) {
101 for (i
= 0; i
< RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS
; i
++) {
102 rte_sched_queue_read_stats(port
, queue_id
+ (tc
* RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS
+ i
), &stats
, &qlen
);
103 part_average
+= qlen
;
105 average
+= part_average
/ RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS
;
109 average
/= qavg_ntimes
;
111 printf("\nAverage queue size: %" PRIu32
" bytes.\n\n", average
);
117 qavg_pipe(uint8_t port_id
, uint32_t subport_id
, uint32_t pipe_id
)
119 struct rte_sched_queue_stats stats
;
120 struct rte_sched_port
*port
;
122 uint32_t queue_id
, count
, i
;
123 uint32_t average
, part_average
;
125 for (i
= 0; i
< nb_pfc
; i
++) {
126 if (qos_conf
[i
].tx_port
== port_id
)
129 if (i
== nb_pfc
|| subport_id
>= port_params
.n_subports_per_port
|| pipe_id
>= port_params
.n_pipes_per_subport
)
132 port
= qos_conf
[i
].sched_port
;
134 queue_id
= RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE
* RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS
* (subport_id
* port_params
.n_pipes_per_subport
+ pipe_id
);
138 for (count
= 0; count
< qavg_ntimes
; count
++) {
140 for (i
= 0; i
< RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE
* RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS
; i
++) {
141 rte_sched_queue_read_stats(port
, queue_id
+ i
, &stats
, &qlen
);
142 part_average
+= qlen
;
144 average
+= part_average
/ (RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE
* RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS
);
148 average
/= qavg_ntimes
;
150 printf("\nAverage queue size: %" PRIu32
" bytes.\n\n", average
);
156 qavg_tcsubport(uint8_t port_id
, uint32_t subport_id
, uint8_t tc
)
158 struct rte_sched_queue_stats stats
;
159 struct rte_sched_port
*port
;
161 uint32_t queue_id
, count
, i
, j
;
162 uint32_t average
, part_average
;
164 for (i
= 0; i
< nb_pfc
; i
++) {
165 if (qos_conf
[i
].tx_port
== port_id
)
168 if (i
== nb_pfc
|| subport_id
>= port_params
.n_subports_per_port
|| tc
>= RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE
)
171 port
= qos_conf
[i
].sched_port
;
175 for (count
= 0; count
< qavg_ntimes
; count
++) {
177 for (i
= 0; i
< port_params
.n_pipes_per_subport
; i
++) {
178 queue_id
= RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE
* RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS
* (subport_id
* port_params
.n_pipes_per_subport
+ i
);
180 for (j
= 0; j
< RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS
; j
++) {
181 rte_sched_queue_read_stats(port
, queue_id
+ (tc
* RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS
+ j
), &stats
, &qlen
);
182 part_average
+= qlen
;
186 average
+= part_average
/ (port_params
.n_pipes_per_subport
* RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS
);
190 average
/= qavg_ntimes
;
192 printf("\nAverage queue size: %" PRIu32
" bytes.\n\n", average
);
198 qavg_subport(uint8_t port_id
, uint32_t subport_id
)
200 struct rte_sched_queue_stats stats
;
201 struct rte_sched_port
*port
;
203 uint32_t queue_id
, count
, i
, j
;
204 uint32_t average
, part_average
;
206 for (i
= 0; i
< nb_pfc
; i
++) {
207 if (qos_conf
[i
].tx_port
== port_id
)
210 if (i
== nb_pfc
|| subport_id
>= port_params
.n_subports_per_port
)
213 port
= qos_conf
[i
].sched_port
;
217 for (count
= 0; count
< qavg_ntimes
; count
++) {
219 for (i
= 0; i
< port_params
.n_pipes_per_subport
; i
++) {
220 queue_id
= RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE
* RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS
* (subport_id
* port_params
.n_pipes_per_subport
+ i
);
222 for (j
= 0; j
< RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE
* RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS
; j
++) {
223 rte_sched_queue_read_stats(port
, queue_id
+ j
, &stats
, &qlen
);
224 part_average
+= qlen
;
228 average
+= part_average
/ (port_params
.n_pipes_per_subport
* RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE
* RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS
);
232 average
/= qavg_ntimes
;
234 printf("\nAverage queue size: %" PRIu32
" bytes.\n\n", average
);
240 subport_stat(uint8_t port_id
, uint32_t subport_id
)
242 struct rte_sched_subport_stats stats
;
243 struct rte_sched_port
*port
;
244 uint32_t tc_ov
[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE
];
247 for (i
= 0; i
< nb_pfc
; i
++) {
248 if (qos_conf
[i
].tx_port
== port_id
)
251 if (i
== nb_pfc
|| subport_id
>= port_params
.n_subports_per_port
)
254 port
= qos_conf
[i
].sched_port
;
255 memset (tc_ov
, 0, sizeof(tc_ov
));
257 rte_sched_subport_read_stats(port
, subport_id
, &stats
, tc_ov
);
260 printf("+----+-------------+-------------+-------------+-------------+-------------+\n");
261 printf("| TC | Pkts OK |Pkts Dropped | Bytes OK |Bytes Dropped| OV Status |\n");
262 printf("+----+-------------+-------------+-------------+-------------+-------------+\n");
264 for (i
= 0; i
< RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE
; i
++) {
265 printf("| %d | %11" PRIu32
" | %11" PRIu32
" | %11" PRIu32
" | %11" PRIu32
" | %11" PRIu32
" |\n", i
,
266 stats
.n_pkts_tc
[i
], stats
.n_pkts_tc_dropped
[i
],
267 stats
.n_bytes_tc
[i
], stats
.n_bytes_tc_dropped
[i
], tc_ov
[i
]);
268 printf("+----+-------------+-------------+-------------+-------------+-------------+\n");
276 pipe_stat(uint8_t port_id
, uint32_t subport_id
, uint32_t pipe_id
)
278 struct rte_sched_queue_stats stats
;
279 struct rte_sched_port
*port
;
284 for (i
= 0; i
< nb_pfc
; i
++) {
285 if (qos_conf
[i
].tx_port
== port_id
)
288 if (i
== nb_pfc
|| subport_id
>= port_params
.n_subports_per_port
|| pipe_id
>= port_params
.n_pipes_per_subport
)
291 port
= qos_conf
[i
].sched_port
;
293 queue_id
= RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE
* RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS
* (subport_id
* port_params
.n_pipes_per_subport
+ pipe_id
);
296 printf("+----+-------+-------------+-------------+-------------+-------------+-------------+\n");
297 printf("| TC | Queue | Pkts OK |Pkts Dropped | Bytes OK |Bytes Dropped| Length |\n");
298 printf("+----+-------+-------------+-------------+-------------+-------------+-------------+\n");
300 for (i
= 0; i
< RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE
; i
++) {
301 for (j
= 0; j
< RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS
; j
++) {
303 rte_sched_queue_read_stats(port
, queue_id
+ (i
* RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS
+ j
), &stats
, &qlen
);
305 printf("| %d | %d | %11" PRIu32
" | %11" PRIu32
" | %11" PRIu32
" | %11" PRIu32
" | %11i |\n", i
, j
,
306 stats
.n_pkts
, stats
.n_pkts_dropped
, stats
.n_bytes
, stats
.n_bytes_dropped
, qlen
);
307 printf("+----+-------+-------------+-------------+-------------+-------------+-------------+\n");
309 if (i
< RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE
- 1)
310 printf("+----+-------+-------------+-------------+-------------+-------------+-------------+\n");