Ejemplo n.º 1
0
static int
handle_work_for_shutdown_test(void *arg)
{
	struct rte_mbuf *pkt = NULL;
	struct rte_distributor *d = arg;
	unsigned count = 0;
	const unsigned id = __sync_fetch_and_add(&worker_idx, 1);

	pkt = rte_distributor_get_pkt(d, id, NULL);
	/* wait for quit single globally, or for worker zero, wait
	 * for zero_quit */
	while (!quit && !(id == 0 && zero_quit)) {
		worker_stats[id].handled_packets++, count++;
		rte_pktmbuf_free(pkt);
		pkt = rte_distributor_get_pkt(d, id, NULL);
	}
	worker_stats[id].handled_packets++, count++;
	rte_distributor_return_pkt(d, id, pkt);

	if (id == 0) {
		/* for worker zero, allow it to restart to pick up last packet
		 * when all workers are shutting down.
		 */
		while (zero_quit)
			usleep(100);
		pkt = rte_distributor_get_pkt(d, id, NULL);
		while (!quit) {
			worker_stats[id].handled_packets++, count++;
			rte_pktmbuf_free(pkt);
			pkt = rte_distributor_get_pkt(d, id, NULL);
		}
		rte_distributor_return_pkt(d, id, pkt);
	}
	return 0;
}
Ejemplo n.º 2
0
/* to test that the distributor does not lose packets, we use this worker
 * function which frees mbufs when it gets them. The distributor thread does
 * the mbuf allocation. If distributor drops packets we'll eventually run out
 * of mbufs.
 */
static int
handle_work_with_free_mbufs(void *arg)
{
	struct rte_mbuf *buf[8] __rte_cache_aligned;
	struct worker_params *wp = arg;
	struct rte_distributor *d = wp->dist;
	unsigned int count = 0;
	unsigned int i;
	unsigned int num = 0;
	unsigned int id = __sync_fetch_and_add(&worker_idx, 1);

	for (i = 0; i < 8; i++)
		buf[i] = NULL;
	num = rte_distributor_get_pkt(d, id, buf, buf, num);
	while (!quit) {
		worker_stats[id].handled_packets += num;
		count += num;
		for (i = 0; i < num; i++)
			rte_pktmbuf_free(buf[i]);
		num = rte_distributor_get_pkt(d,
				id, buf, buf, num);
	}
	worker_stats[id].handled_packets += num;
	count += num;
	rte_distributor_return_pkt(d, id, buf, num);
	return 0;
}
Ejemplo n.º 3
0
static int
handle_work_for_shutdown_test(void *arg)
{
	struct rte_mbuf *pkt = NULL;
	struct rte_mbuf *buf[8] __rte_cache_aligned;
	struct worker_params *wp = arg;
	struct rte_distributor *d = wp->dist;
	unsigned int count = 0;
	unsigned int num = 0;
	unsigned int total = 0;
	unsigned int i;
	unsigned int returned = 0;
	const unsigned int id = __sync_fetch_and_add(&worker_idx, 1);

	num = rte_distributor_get_pkt(d, id, buf, buf, num);

	/* wait for quit single globally, or for worker zero, wait
	 * for zero_quit */
	while (!quit && !(id == 0 && zero_quit)) {
		worker_stats[id].handled_packets += num;
		count += num;
		for (i = 0; i < num; i++)
			rte_pktmbuf_free(buf[i]);
		num = rte_distributor_get_pkt(d,
				id, buf, buf, num);
		total += num;
	}
	worker_stats[id].handled_packets += num;
	count += num;
	returned = rte_distributor_return_pkt(d, id, buf, num);

	if (id == 0) {
		/* for worker zero, allow it to restart to pick up last packet
		 * when all workers are shutting down.
		 */
		while (zero_quit)
			usleep(100);

		num = rte_distributor_get_pkt(d,
				id, buf, buf, num);

		while (!quit) {
			worker_stats[id].handled_packets++, count++;
			rte_pktmbuf_free(pkt);
			num = rte_distributor_get_pkt(d, id, buf, buf, num);
		}
		returned = rte_distributor_return_pkt(d,
				id, buf, num);
		printf("Num returned = %d\n", returned);
	}
	return 0;
}
Ejemplo n.º 4
0
/* this is the basic worker function for performance tests.
 * it does nothing but return packets and count them.
 */
static int
handle_work(void *arg)
{
	struct rte_mbuf *pkt = NULL;
	struct rte_distributor *d = arg;
	unsigned count = 0;
	unsigned id = __sync_fetch_and_add(&worker_idx, 1);

	pkt = rte_distributor_get_pkt(d, id, NULL);
	while (!quit) {
		worker_stats[id].handled_packets++, count++;
		pkt = rte_distributor_get_pkt(d, id, pkt);
	}
	worker_stats[id].handled_packets++, count++;
	rte_distributor_return_pkt(d, id, pkt);
	return 0;
}