Esempio 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);
	}
}
Esempio n. 2
0
/* Try to increment stats for all vport counters, which should
 * succeed */
static void
test_stats_vport_xxx_increment(int argc, char *argv[])
{
	int vportid = 0;

	stats_init();
	stats_vport_clear_all();

	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);
	}
}
Esempio n. 3
0
/*
 * Send a reply message to the vswitchd
 */
static void
send_reply_to_vswitchd(struct dpdk_message *reply)
{
	struct rte_mbuf *mbuf = NULL;
	void *pktmbuf_data = NULL;
	int rslt = 0;

	/* Preparing the buffer to send */
	mbuf = rte_pktmbuf_alloc(pktmbuf_pool);

	if (!mbuf) {
		RTE_LOG(WARNING, APP, "Error : Unable to allocate an mbuf "
		        ": %s : %d", __FUNCTION__, __LINE__);
		stats_vswitch_tx_drop_increment(INC_BY_1);
		stats_vport_rx_drop_increment(VSWITCHD, INC_BY_1);
		return;
	}

	pktmbuf_data = rte_pktmbuf_mtod(mbuf, void *);
	rte_memcpy(pktmbuf_data, reply, sizeof(*reply));
	rte_pktmbuf_data_len(mbuf) = sizeof(*reply);

	/* Sending the buffer to vswitchd */
	rslt = rte_ring_mp_enqueue(vswitchd_reply_ring, (void *)mbuf);
	if (rslt < 0) {
		if (rslt == -ENOBUFS) {
			rte_pktmbuf_free(mbuf);
			stats_vswitch_tx_drop_increment(INC_BY_1);
			stats_vport_rx_drop_increment(VSWITCHD, INC_BY_1);
		} else {
			stats_vport_overrun_increment(VSWITCHD, INC_BY_1);
			stats_vport_rx_increment(VSWITCHD, INC_BY_1);
		}
	} else {
		stats_vport_rx_increment(VSWITCHD, INC_BY_1);
	}
}