/* * This function displays the recorded statistics for each port * and for each client. It uses ANSI terminal codes to clear * screen when called. It is called from a single non-master * thread in the server process, when the process is run with more * than one lcore enabled. */ static void do_stats_display(void) { unsigned 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 client_tx[MAX_CLIENTS], client_tx_drop[MAX_CLIENTS]; /* 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(client_tx, 0, sizeof(client_tx)); memset(client_tx_drop, 0, sizeof(client_tx_drop)); for (i = 0; i < num_clients; i++){ const volatile struct tx_stats *tx = &ports->tx_stats[i]; for (j = 0; j < ports->num_ports; j++){ /* assign to local variables here, save re-reading volatile vars */ const uint64_t tx_val = tx->tx[ports->id[j]]; const uint64_t drop_val = tx->tx_drop[ports->id[j]]; port_tx[j] += tx_val; port_tx_drop[j] += drop_val; client_tx[i] += tx_val; client_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 < ports->num_ports; i++) printf("Port %u: '%s'\t", (unsigned)ports->id[i], get_printable_mac_addr(ports->id[i])); printf("\n\n"); for (i = 0; i < ports->num_ports; i++){ printf("Port %u - rx: %9"PRIu64"\t" "tx: %9"PRIu64"\n", (unsigned)ports->id[i], ports->rx_stats.rx[i], port_tx[i]); } printf("\nCLIENTS\n"); printf("-------\n"); for (i = 0; i < num_clients; i++){ const unsigned long long rx = clients[i].stats.rx; const unsigned long long rx_drop = clients[i].stats.rx_drop; printf("Client %2u - rx: %9llu, rx_drop: %9llu\n" " tx: %9"PRIu64", tx_drop: %9"PRIu64"\n", i, rx, rx_drop, client_tx[i], client_tx_drop[i]); } printf("\n"); }
/* * This function displays the recorded statistics for each port * and for each client. It uses ANSI terminal codes to clear * screen when called. It is called from a single non-master * thread in the server process, when the process is run with more * than one lcore enabled. */ static void stats_display(void) { unsigned i = 0; unsigned j = 0; /* ANSI escape sequences for terminal display. * 27 = ESC, 2J = Clear screen */ const char clr[] = {27, '[', '2', 'J', '\0'}; /* H = Home position for cursor*/ const char topLeft[] = {27, '[', '1', ';', '1', 'H','\0'}; uint64_t overruns = 0; /* Clear screen and move to top left */ printf("%s%s", clr, topLeft); printf("Physical Ports\n"); printf("-----\n"); for (i = 0; i < ports->num_ports; i++) printf("Port %u: '%s'\t", ports->id[i], get_printable_mac_addr(ports->id[i])); printf("\n\n"); printf("\nVport Statistics\n" "============ ============ ============ ============ ============\n" "Interface rx_packets rx_dropped tx_packets tx_dropped \n" "------------ ------------ ------------ ------------ ------------\n"); for (i = 0; i < MAX_VPORTS; i++) { if (i == 0) { printf("vswitchd "); } else if (i <= PORT_MASK) { printf("Client %2u", i); } else if (i <= KNI_MASK) { printf("Port %2u", i & PORT_MASK); } else { printf("KNI Port %2u", i & KNI_MASK); } printf("%13"PRIu64" %13"PRIu64" %13"PRIu64" %13"PRIu64"\n", stats_vport_rx_get(i), stats_vport_rx_drop_get(i), stats_vport_tx_get(i), stats_vport_tx_drop_get(i)); overruns += stats_vport_overrun_get(i); } printf("============ ============ ============ ============ ============\n"); printf("\n Switch rx dropped %d\n", stats_vswitch_rx_drop_get()); printf("\n Switch tx dropped %d\n", stats_vswitch_tx_drop_get()); printf("\n Queue overruns %d\n", overruns); printf("\n Mempool count %9u\n", rte_mempool_count(pktmbuf_pool)); printf("\n"); }
/* * This function displays the recorded statistics for each port * and for each node. It uses ANSI terminal codes to clear * screen when called. It is called from a single non-master * thread in the server process, when the process is run with more * than one lcore enabled. */ 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"); }