[dpdk-dev] Question about store_return() in ~/dpdk/lib/librte_distributor/rte_distributor.c

최익성 pnk003 at naver.com
Wed Oct 7 11:07:23 CEST 2015


Dear DPDK experts.
 
Thank you very much for your excellent efforts and contributions.
 
I have a question about store_return() in ~/dpdk/lib/librte_distributor/rte_distributor.c
 
The store_return() function adds a oldbuf packet to d->returns.mbuf[] queue.
 
If the queue is full and the oldbuf packet is NULL, the queue seems to lost a packet in the queue without modifying ret_start/ret_count values.
 
Is the last position of the queue always empty?
 
Would you check it? 
 
 
#define RTE_DISTRIB_MAX_RETURNS 128
#define RTE_DISTRIB_RETURNS_MASK (RTE_DISTRIB_MAX_RETURNS - 1)
 
/* stores a packet returned from a worker inside the returns array */
static inline void
store_return(uintptr_t oldbuf, struct rte_distributor *d,
                unsigned *ret_start, unsigned *ret_count)
{
        /* store returns in a circular buffer - code is branch-free. buffer 끝에 oldbuf를 추가함 */
        d->returns.mbufs[(*ret_start + *ret_count) & RTE_DISTRIB_RETURNS_MASK]
                        = (void *)oldbuf;
        *ret_start += (*ret_count == RTE_DISTRIB_RETURNS_MASK) & !!(oldbuf);
        *ret_count += (*ret_count != RTE_DISTRIB_RETURNS_MASK) & !!(oldbuf);
}
 
If d->returns.mbufs[] queue is full, oldbuf replaces the first cell of the queue (new packet overwrites the last packet in the queue).
 
ret_start is preserved if the queue is not full (count!= MAX_VALUE(RTE_DISTRIB_RETURNS_MASK))
if ret_start is MAX value and oldbuf is not NULL, ret_start is incremented by 1.
 
ret_count is incremented by 1 if it is not MAX value and oldbuf is not NULL).
if ret_count is MAX value, ret_count is preserved.
 
The mbufs queue is written by oldbuf(NULL) even though when the queue is full and the oldbuf packet is NULL (no packet insertion). 
It may lost a cell in the queue.
If the last position of the queue is always empty, it may not be a problem.
 
Would you check it?
 
Thank you very much.
 
Sincerely Yours,
 
Ick-Sung Choi.



More information about the dev mailing list