#include <unistd.h>
#include <string.h>
#include "main.h"
int
qavg_q(uint16_t port_id, uint32_t subport_id, uint32_t pipe_id, uint8_t tc,
uint8_t q)
{
struct rte_sched_port *port;
uint16_t qlen;
uint32_t count, i, queue_id = 0;
uint32_t average;
for (i = 0; i < nb_pfc; i++) {
if (qos_conf[i].tx_port == port_id)
break;
}
if (i == nb_pfc ||
subport_id >= port_params.n_subports_per_port ||
pipe_id >= subport_params[subport_id].n_pipes_per_subport_enabled ||
(tc < RTE_SCHED_TRAFFIC_CLASS_BE && q > 0))
return -1;
port = qos_conf[i].sched_port;
for (i = 0; i < subport_id; i++)
queue_id += subport_params[i].n_pipes_per_subport_enabled *
else
average = 0;
for (count = 0; count < qavg_ntimes; count++) {
average += qlen;
usleep(qavg_period);
}
average /= qavg_ntimes;
printf("\nAverage queue size: %" PRIu32 " bytes.\n\n", average);
return 0;
}
int
qavg_tcpipe(uint16_t port_id, uint32_t subport_id, uint32_t pipe_id,
uint8_t tc)
{
struct rte_sched_port *port;
uint16_t qlen;
uint32_t count, i, queue_id = 0;
uint32_t average, part_average;
for (i = 0; i < nb_pfc; i++) {
if (qos_conf[i].tx_port == port_id)
break;
}
if (i == nb_pfc || subport_id >= port_params.n_subports_per_port ||
pipe_id >= subport_params[subport_id].n_pipes_per_subport_enabled ||
return -1;
port = qos_conf[i].sched_port;
for (i = 0; i < subport_id; i++)
queue_id +=
subport_params[i].n_pipes_per_subport_enabled *
average = 0;
for (count = 0; count < qavg_ntimes; count++) {
part_average = 0;
&stats, &qlen);
part_average += qlen;
} else {
&stats, &qlen);
part_average += qlen;
}
}
usleep(qavg_period);
}
average /= qavg_ntimes;
printf("\nAverage queue size: %" PRIu32 " bytes.\n\n", average);
return 0;
}
int
qavg_pipe(uint16_t port_id, uint32_t subport_id, uint32_t pipe_id)
{
struct rte_sched_port *port;
uint16_t qlen;
uint32_t count, i, queue_id = 0;
uint32_t average, part_average;
for (i = 0; i < nb_pfc; i++) {
if (qos_conf[i].tx_port == port_id)
break;
}
if (i == nb_pfc ||
subport_id >= port_params.n_subports_per_port ||
pipe_id >= subport_params[subport_id].n_pipes_per_subport_enabled)
return -1;
port = qos_conf[i].sched_port;
for (i = 0; i < subport_id; i++)
queue_id += subport_params[i].n_pipes_per_subport_enabled *
average = 0;
for (count = 0; count < qavg_ntimes; count++) {
part_average = 0;
&stats, &qlen);
part_average += qlen;
}
usleep(qavg_period);
}
average /= qavg_ntimes;
printf("\nAverage queue size: %" PRIu32 " bytes.\n\n", average);
return 0;
}
int
qavg_tcsubport(uint16_t port_id, uint32_t subport_id, uint8_t tc)
{
struct rte_sched_port *port;
uint16_t qlen;
uint32_t queue_id, count, i, j, subport_queue_id = 0;
uint32_t average, part_average;
for (i = 0; i < nb_pfc; i++) {
if (qos_conf[i].tx_port == port_id)
break;
}
if (i == nb_pfc ||
subport_id >= port_params.n_subports_per_port ||
return -1;
port = qos_conf[i].sched_port;
for (i = 0; i < subport_id; i++)
subport_queue_id +=
subport_params[i].n_pipes_per_subport_enabled *
average = 0;
for (count = 0; count < qavg_ntimes; count++) {
uint32_t n_pipes_per_subport =
subport_params[subport_id].n_pipes_per_subport_enabled;
part_average = 0;
for (i = 0; i < n_pipes_per_subport; i++) {
queue_id = subport_queue_id +
&stats, &qlen);
part_average += qlen;
} else {
queue_id = subport_queue_id +
tc + j;
&stats, &qlen);
part_average += qlen;
}
}
}
average += part_average /
(subport_params[subport_id].n_pipes_per_subport_enabled);
else
average += part_average /
(subport_params[subport_id].n_pipes_per_subport_enabled) *
usleep(qavg_period);
}
average /= qavg_ntimes;
printf("\nAverage queue size: %" PRIu32 " bytes.\n\n", average);
return 0;
}
int
qavg_subport(uint16_t port_id, uint32_t subport_id)
{
struct rte_sched_port *port;
uint16_t qlen;
uint32_t queue_id, count, i, j, subport_queue_id = 0;
uint32_t average, part_average;
for (i = 0; i < nb_pfc; i++) {
if (qos_conf[i].tx_port == port_id)
break;
}
if (i == nb_pfc ||
subport_id >= port_params.n_subports_per_port)
return -1;
port = qos_conf[i].sched_port;
for (i = 0; i < subport_id; i++)
subport_queue_id += subport_params[i].n_pipes_per_subport_enabled *
average = 0;
for (count = 0; count < qavg_ntimes; count++) {
uint32_t n_pipes_per_subport =
subport_params[subport_id].n_pipes_per_subport_enabled;
part_average = 0;
for (i = 0; i < n_pipes_per_subport; i++) {
&stats, &qlen);
part_average += qlen;
}
}
average += part_average /
(subport_params[subport_id].n_pipes_per_subport_enabled *
usleep(qavg_period);
}
average /= qavg_ntimes;
printf("\nAverage queue size: %" PRIu32 " bytes.\n\n", average);
return 0;
}
int
subport_stat(uint16_t port_id, uint32_t subport_id)
{
struct rte_sched_port *port;
uint8_t i;
for (i = 0; i < nb_pfc; i++) {
if (qos_conf[i].tx_port == port_id)
break;
}
if (i == nb_pfc || subport_id >= port_params.n_subports_per_port)
return -1;
port = qos_conf[i].sched_port;
memset(tc_ov, 0, sizeof(tc_ov));
printf("\n");
printf("+----+-------------+-------------+-------------+-------------+-------------+\n");
printf("| TC | Pkts OK |Pkts Dropped | Bytes OK |Bytes Dropped| OV Status |\n");
printf("+----+-------------+-------------+-------------+-------------+-------------+\n");
printf("| %d | %11" PRIu64 " | %11" PRIu64 " | %11" PRIu64 " | %11" PRIu64 " | %11" PRIu32 " |\n",
printf("+----+-------------+-------------+-------------+-------------+-------------+\n");
}
printf("\n");
return 0;
}
int
pipe_stat(uint16_t port_id, uint32_t subport_id, uint32_t pipe_id)
{
struct rte_sched_port *port;
uint16_t qlen;
uint8_t i, j;
uint32_t queue_id = 0;
for (i = 0; i < nb_pfc; i++) {
if (qos_conf[i].tx_port == port_id)
break;
}
if (i == nb_pfc ||
subport_id >= port_params.n_subports_per_port ||
pipe_id >= subport_params[subport_id].n_pipes_per_subport_enabled)
return -1;
port = qos_conf[i].sched_port;
for (i = 0; i < subport_id; i++)
queue_id += subport_params[i].n_pipes_per_subport_enabled *
printf("\n");
printf("+----+-------+-------------+-------------+-------------+-------------+-------------+\n");
printf("| TC | Queue | Pkts OK |Pkts Dropped | Bytes OK |Bytes Dropped| Length |\n");
printf("+----+-------+-------------+-------------+-------------+-------------+-------------+\n");
printf("| %d | %d | %11" PRIu64 " | %11" PRIu64 " | %11" PRIu64 " | %11" PRIu64 " | %11i |\n",
printf("+----+-------+-------------+-------------+-------------+-------------+-------------+\n");
} else {
&stats, &qlen);
printf("| %d | %d | %11" PRIu64 " | %11" PRIu64 " | %11" PRIu64 " | %11" PRIu64 " | %11i |\n",
printf("+----+-------+-------------+-------------+-------------+-------------+-------------+\n");
}
}
}
printf("\n");
return 0;
}