-.. code-block:: c
-
- static void
- do_stats_display(void)
- {
- unsigned int i, j;
- const char clr[] = {27, '[', '2', 'J', '\0'};
- const char topLeft[] = {27, '[', '1', ';', '1', 'H', '\0'};
- uint64_t port_tx[RTE_MAX_ETHPORTS], port_tx_drop[RTE_MAX_ETHPORTS];
- uint64_t node_tx[MAX_NODES], node_tx_drop[MAX_NODES];
-
- /* to get TX stats, we need to do some summing calculations */
- memset(port_tx, 0, sizeof(port_tx));
- memset(port_tx_drop, 0, sizeof(port_tx_drop));
- memset(node_tx, 0, sizeof(node_tx));
- memset(node_tx_drop, 0, sizeof(node_tx_drop));
-
- for (i = 0; i < num_nodes; i++) {
- const struct tx_stats *tx = &info->tx_stats[i];
-
- for (j = 0; j < info->num_ports; j++) {
- const uint64_t tx_val = tx->tx[info->id[j]];
- const uint64_t drop_val = tx->tx_drop[info->id[j]];
-
- port_tx[j] += tx_val;
- port_tx_drop[j] += drop_val;
- node_tx[i] += tx_val;
- node_tx_drop[i] += drop_val;
- }
- }
-
- /* Clear screen and move to top left */
- printf("%s%s", clr, topLeft);
-
- printf("PORTS\n");
- printf("-----\n");
- for (i = 0; i < info->num_ports; i++)
- printf("Port %u: '%s'\t", (unsigned int)info->id[i],
- get_printable_mac_addr(info->id[i]));
- printf("\n\n");
- for (i = 0; i < info->num_ports; i++) {
- printf("Port %u - rx: %9"PRIu64"\t"
- "tx: %9"PRIu64"\n",
- (unsigned int)info->id[i], info->rx_stats.rx[i],
- port_tx[i]);
- }
-
- printf("\nSERVER\n");
- printf("-----\n");
- printf("distributed: %9"PRIu64", drop: %9"PRIu64"\n",
- flow_dist_stats.distributed, flow_dist_stats.drop);
-
- printf("\nNODES\n");
- printf("-------\n");
- for (i = 0; i < num_nodes; i++) {
- const unsigned long long rx = nodes[i].stats.rx;
- const unsigned long long rx_drop = nodes[i].stats.rx_drop;
- const struct filter_stats *filter = &info->filter_stats[i];
-
- printf("Node %2u - rx: %9llu, rx_drop: %9llu\n"
- " tx: %9"PRIu64", tx_drop: %9"PRIu64"\n"
- " filter_passed: %9"PRIu64", "
- "filter_drop: %9"PRIu64"\n",
- i, rx, rx_drop, node_tx[i], node_tx_drop[i],
- filter->passed, filter->drop);
- }
-
- printf("\n");
- }