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(uint16_t port_id, uint32_t subport_id, uint32_t pipe_id, uint8_t tc,
43 struct rte_sched_queue_stats stats;
44 struct rte_sched_port *port;
46 uint32_t queue_id, count, i;
49 for (i = 0; i < nb_pfc; i++) {
50 if (qos_conf[i].tx_port == port_id)
53 if (i == nb_pfc || subport_id >= port_params.n_subports_per_port || pipe_id >= port_params.n_pipes_per_subport
54 || tc >= RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE || q >= RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS)
57 port = qos_conf[i].sched_port;
59 queue_id = RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE * RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS * (subport_id * port_params.n_pipes_per_subport + pipe_id);
60 queue_id = queue_id + (tc * RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS + q);
64 for (count = 0; count < qavg_ntimes; count++) {
65 rte_sched_queue_read_stats(port, queue_id, &stats, &qlen);
70 average /= qavg_ntimes;
72 printf("\nAverage queue size: %" PRIu32 " bytes.\n\n", average);
78 qavg_tcpipe(uint16_t port_id, uint32_t subport_id, uint32_t pipe_id,
81 struct rte_sched_queue_stats stats;
82 struct rte_sched_port *port;
84 uint32_t queue_id, count, i;
85 uint32_t average, part_average;
87 for (i = 0; i < nb_pfc; i++) {
88 if (qos_conf[i].tx_port == port_id)
91 if (i == nb_pfc || subport_id >= port_params.n_subports_per_port || pipe_id >= port_params.n_pipes_per_subport
92 || tc >= RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE)
95 port = qos_conf[i].sched_port;
97 queue_id = RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE * RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS * (subport_id * port_params.n_pipes_per_subport + pipe_id);
101 for (count = 0; count < qavg_ntimes; count++) {
103 for (i = 0; i < RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS; i++) {
104 rte_sched_queue_read_stats(port, queue_id + (tc * RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS + i), &stats, &qlen);
105 part_average += qlen;
107 average += part_average / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS;
111 average /= qavg_ntimes;
113 printf("\nAverage queue size: %" PRIu32 " bytes.\n\n", average);
119 qavg_pipe(uint16_t port_id, uint32_t subport_id, uint32_t pipe_id)
121 struct rte_sched_queue_stats stats;
122 struct rte_sched_port *port;
124 uint32_t queue_id, count, i;
125 uint32_t average, part_average;
127 for (i = 0; i < nb_pfc; i++) {
128 if (qos_conf[i].tx_port == port_id)
131 if (i == nb_pfc || subport_id >= port_params.n_subports_per_port || pipe_id >= port_params.n_pipes_per_subport)
134 port = qos_conf[i].sched_port;
136 queue_id = RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE * RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS * (subport_id * port_params.n_pipes_per_subport + pipe_id);
140 for (count = 0; count < qavg_ntimes; count++) {
142 for (i = 0; i < RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE * RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS; i++) {
143 rte_sched_queue_read_stats(port, queue_id + i, &stats, &qlen);
144 part_average += qlen;
146 average += part_average / (RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE * RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS);
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;
164 uint32_t average, part_average;
166 for (i = 0; i < nb_pfc; i++) {
167 if (qos_conf[i].tx_port == port_id)
170 if (i == nb_pfc || subport_id >= port_params.n_subports_per_port || tc >= RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE)
173 port = qos_conf[i].sched_port;
177 for (count = 0; count < qavg_ntimes; count++) {
179 for (i = 0; i < port_params.n_pipes_per_subport; i++) {
180 queue_id = RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE * RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS * (subport_id * port_params.n_pipes_per_subport + i);
182 for (j = 0; j < RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS; j++) {
183 rte_sched_queue_read_stats(port, queue_id + (tc * RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS + j), &stats, &qlen);
184 part_average += qlen;
188 average += part_average / (port_params.n_pipes_per_subport * RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS);
192 average /= qavg_ntimes;
194 printf("\nAverage queue size: %" PRIu32 " bytes.\n\n", average);
200 qavg_subport(uint16_t port_id, uint32_t subport_id)
202 struct rte_sched_queue_stats stats;
203 struct rte_sched_port *port;
205 uint32_t queue_id, count, i, j;
206 uint32_t average, part_average;
208 for (i = 0; i < nb_pfc; i++) {
209 if (qos_conf[i].tx_port == port_id)
212 if (i == nb_pfc || subport_id >= port_params.n_subports_per_port)
215 port = qos_conf[i].sched_port;
219 for (count = 0; count < qavg_ntimes; count++) {
221 for (i = 0; i < port_params.n_pipes_per_subport; i++) {
222 queue_id = RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE * RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS * (subport_id * port_params.n_pipes_per_subport + i);
224 for (j = 0; j < RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE * RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS; j++) {
225 rte_sched_queue_read_stats(port, queue_id + j, &stats, &qlen);
226 part_average += qlen;
230 average += part_average / (port_params.n_pipes_per_subport * RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE * RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS);
234 average /= qavg_ntimes;
236 printf("\nAverage queue size: %" PRIu32 " bytes.\n\n", average);
242 subport_stat(uint16_t port_id, uint32_t subport_id)
244 struct rte_sched_subport_stats stats;
245 struct rte_sched_port *port;
246 uint32_t tc_ov[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
249 for (i = 0; i < nb_pfc; i++) {
250 if (qos_conf[i].tx_port == port_id)
253 if (i == nb_pfc || subport_id >= port_params.n_subports_per_port)
256 port = qos_conf[i].sched_port;
257 memset (tc_ov, 0, sizeof(tc_ov));
259 rte_sched_subport_read_stats(port, subport_id, &stats, tc_ov);
262 printf("+----+-------------+-------------+-------------+-------------+-------------+\n");
263 printf("| TC | Pkts OK |Pkts Dropped | Bytes OK |Bytes Dropped| OV Status |\n");
264 printf("+----+-------------+-------------+-------------+-------------+-------------+\n");
266 for (i = 0; i < RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE; i++) {
267 printf("| %d | %11" PRIu32 " | %11" PRIu32 " | %11" PRIu32 " | %11" PRIu32 " | %11" PRIu32 " |\n", i,
268 stats.n_pkts_tc[i], stats.n_pkts_tc_dropped[i],
269 stats.n_bytes_tc[i], stats.n_bytes_tc_dropped[i], tc_ov[i]);
270 printf("+----+-------------+-------------+-------------+-------------+-------------+\n");
278 pipe_stat(uint16_t port_id, uint32_t subport_id, uint32_t pipe_id)
280 struct rte_sched_queue_stats stats;
281 struct rte_sched_port *port;
286 for (i = 0; i < nb_pfc; i++) {
287 if (qos_conf[i].tx_port == port_id)
290 if (i == nb_pfc || subport_id >= port_params.n_subports_per_port || pipe_id >= port_params.n_pipes_per_subport)
293 port = qos_conf[i].sched_port;
295 queue_id = RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE * RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS * (subport_id * port_params.n_pipes_per_subport + pipe_id);
298 printf("+----+-------+-------------+-------------+-------------+-------------+-------------+\n");
299 printf("| TC | Queue | Pkts OK |Pkts Dropped | Bytes OK |Bytes Dropped| Length |\n");
300 printf("+----+-------+-------------+-------------+-------------+-------------+-------------+\n");
302 for (i = 0; i < RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE; i++) {
303 for (j = 0; j < RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS; j++) {
305 rte_sched_queue_read_stats(port, queue_id + (i * RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS + j), &stats, &qlen);
307 printf("| %d | %d | %11" PRIu32 " | %11" PRIu32 " | %11" PRIu32 " | %11" PRIu32 " | %11i |\n", i, j,
308 stats.n_pkts, stats.n_pkts_dropped, stats.n_bytes, stats.n_bytes_dropped, qlen);
309 printf("+----+-------+-------------+-------------+-------------+-------------+-------------+\n");
311 if (i < RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE - 1)
312 printf("+----+-------+-------------+-------------+-------------+-------------+-------------+\n");