src/dpdk/lib/librte_distributor/rte_distributor.c
static unsigned int
handle_returns(struct rte_distributor *d, unsigned int wkr)
{
	struct rte_distributor_buffer *buf = &(d->bufs[wkr]);
	uintptr_t oldbuf;
	unsigned int ret_start = d->returns.start,
			ret_count = d->returns.count;
	unsigned int count = 0;
	unsigned int i;

	/* Sync on GET_BUF flag. Acquire retptrs. */
	if (__atomic_load_n(&(buf->retptr64[0]), __ATOMIC_ACQUIRE)
		& (RTE_DISTRIB_GET_BUF | RTE_DISTRIB_RETURN_BUF)) {
		for (i = 0; i < RTE_DIST_BURST_SIZE; i++) {
			if (buf->retptr64[i] & RTE_DISTRIB_VALID_BUF) {
				oldbuf = ((uintptr_t)(buf->retptr64[i] >>
					RTE_DISTRIB_FLAG_BITS));
				/* store returns in a circular buffer */
				store_return(oldbuf, d, &ret_start, &ret_count);
				count++;
				buf->retptr64[i] &= ~RTE_DISTRIB_VALID_BUF;
			}
		}
		d->returns.start = ret_start;
		d->returns.count = ret_count;

		/* If worker requested packets with GET_BUF, set it to active
		 * otherwise (RETURN_BUF), set it to not active.
		 */
		d->activesum -= d->active[wkr];
		d->active[wkr] = !!(buf->retptr64[0] & RTE_DISTRIB_GET_BUF);
		d->activesum += d->active[wkr];

		/* If worker returned packets without requesting new ones,
		 * handle all in-flights and backlog packets assigned to it.
		 */
		if (unlikely(buf->retptr64[0] & RTE_DISTRIB_RETURN_BUF))
			handle_worker_shutdown(d, wkr);

		/* Clear for the worker to populate with more returns.
		 * Sync with distributor on GET_BUF flag. Release retptrs.
		 */
		__atomic_store_n(&(buf->retptr64[0]), 0, __ATOMIC_RELEASE);
	}
	return count;
}
/*
 * When the handshake bits indicate that there are packets coming
 * back from the worker, this function is called to copy and store
 * the valid returned pointers (store_return).
 */
When the handshake bits indicate that there are packets coming
back from the worker, this function is called to copy and store
the valid returned pointers (store_return).
When the handshake bits indicate that there are packets coming back from the worker this function is called to copy and store the valid returned pointers ( store_return ) .
static unsigned int
handle_returns(struct rte_distributor *d, unsigned int wkr)
{
	struct rte_distributor_buffer *buf = &(d->bufs[wkr]);
	uintptr_t oldbuf;
	unsigned int ret_start = d->returns.start,
			ret_count = d->returns.count;
	unsigned int count = 0;
	unsigned int i;
	if (__atomic_load_n(&(buf->retptr64[0]), __ATOMIC_ACQUIRE)
		& (RTE_DISTRIB_GET_BUF | RTE_DISTRIB_RETURN_BUF)) {
		for (i = 0; i < RTE_DIST_BURST_SIZE; i++) {
			if (buf->retptr64[i] & RTE_DISTRIB_VALID_BUF) {
				oldbuf = ((uintptr_t)(buf->retptr64[i] >>
					RTE_DISTRIB_FLAG_BITS));
				store_return(oldbuf, d, &ret_start, &ret_count);
				count++;
				buf->retptr64[i] &= ~RTE_DISTRIB_VALID_BUF;
			}
		}
		d->returns.start = ret_start;
		d->returns.count = ret_count;
		d->activesum -= d->active[wkr];
		d->active[wkr] = !!(buf->retptr64[0] & RTE_DISTRIB_GET_BUF);
		d->activesum += d->active[wkr];
		if (unlikely(buf->retptr64[0] & RTE_DISTRIB_RETURN_BUF))
			handle_worker_shutdown(d, wkr);
		__atomic_store_n(&(buf->retptr64[0]), 0, __ATOMIC_RELEASE);
	}
	return count;
}
static unsigned int handle_returns ( struct rte_distributor * d , unsigned int wkr ) { struct rte_distributor_buffer * buf = & ( d -> bufs [ wkr ] ) ; uintptr_t oldbuf ; unsigned int ret_start = d -> returns . start , ret_count = d -> returns . count ; unsigned int count = 0 ; unsigned int i ; if ( __atomic_load_n ( & ( buf -> retptr64 [ 0 ] ) , __ATOMIC_ACQUIRE ) & ( RTE_DISTRIB_GET_BUF | RTE_DISTRIB_RETURN_BUF ) ) { for ( i = 0 ; i < RTE_DIST_BURST_SIZE ; i ++ ) { if ( buf -> retptr64 [ i ] & RTE_DISTRIB_VALID_BUF ) { oldbuf = ( ( uintptr_t ) ( buf -> retptr64 [ i ] >> RTE_DISTRIB_FLAG_BITS ) ) ; store_return ( oldbuf , d , & ret_start , & ret_count ) ; count ++ ; buf -> retptr64 [ i ] &= ~ RTE_DISTRIB_VALID_BUF ; } } d -> returns . start = ret_start ; d -> returns . count = ret_count ; d -> activesum -= d -> active [ wkr ] ; d -> active [ wkr ] = ! ! ( buf -> retptr64 [ 0 ] & RTE_DISTRIB_GET_BUF ) ; d -> activesum += d -> active [ wkr ] ; if ( unlikely ( buf -> retptr64 [ 0 ] & RTE_DISTRIB_RETURN_BUF ) ) handle_worker_shutdown ( d , wkr ) ; __atomic_store_n ( & ( buf -> retptr64 [ 0 ] ) , 0 , __ATOMIC_RELEASE ) ; } return count ; }
When the handshake bits indicate that there are packets coming
 back from the worker, this function is called to copy and store
 the valid returned pointers (store_return).
When the handshake bits indicate that there are packets coming back from the worker this function is called to copy and store the valid returned pointers ( store_return ) .
/* Sync on GET_BUF flag. Acquire retptrs. */ /* store returns in a circular buffer */ /* If worker requested packets with GET_BUF, set it to active
		 * otherwise (RETURN_BUF), set it to not active.
		 */ /* If worker returned packets without requesting new ones,
		 * handle all in-flights and backlog packets assigned to it.
		 */ /* Clear for the worker to populate with more returns.
		 * Sync with distributor on GET_BUF flag. Release retptrs.
		 */