Ejemplo n.º 1
0
/* Try to clear stats for all vport counters, which should succeed */
static void
test_stats_vport_xxx_clear(int argc, char *argv[])
{
	int vportid = 0;

	stats_init();
	stats_vport_clear_all();

	/* increment stats so there's something to clear */
	for (vportid = 0; vportid < MAX_VPORTS; vportid++) {
		stats_vport_rx_increment(vportid, 23);
		stats_vport_rx_drop_increment(vportid, 23);
		stats_vport_tx_increment(vportid, 23);
		stats_vport_tx_drop_increment(vportid, 23);
		stats_vport_overrun_increment(vportid, 23);
		stats_vport_rx_increment(vportid, 19);
		stats_vport_rx_drop_increment(vportid, 19);
		stats_vport_tx_increment(vportid, 19);
		stats_vport_tx_drop_increment(vportid, 19);
		stats_vport_overrun_increment(vportid, 19);
	}

	for (vportid = 0; vportid < MAX_VPORTS; vportid++) {
		stats_vport_clear(vportid);
		assert(stats_vport_rx_get(vportid) == 0);
		assert(stats_vport_rx_drop_get(vportid) == 0);
		assert(stats_vport_tx_get(vportid) == 0);
		assert(stats_vport_tx_drop_get(vportid) == 0);
		assert(stats_vport_overrun_get(vportid) == 0);
	}
}
Ejemplo n.º 2
0
/*
 * 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");
}