2018-04-25 21:00 GMT+02:00 Willem de Bruijn <willemdebruijn.ker...@gmail.com>: [...] >>> static inline struct xdp_desc *xskq_peek_desc(struct xsk_queue *q, >>> + struct xdp_desc *desc) >>> +{ >>> + struct xdp_rxtx_ring *ring; >>> + >>> + if (q->cons_tail == q->cons_head) { >>> + WRITE_ONCE(q->ring->consumer, q->cons_tail); >>> + q->cons_head = q->cons_tail + xskq_nb_avail(q, >>> RX_BATCH_SIZE); >>> + >>> + /* Order consumer and data */ >>> + smp_rmb(); >>> + >>> + return xskq_validate_desc(q, desc); >>> + } >>> + >>> + ring = (struct xdp_rxtx_ring *)q->ring; >>> + *desc = ring->desc[q->cons_tail & q->ring_mask]; >>> + return desc; >>> >>> This only validates descriptors if taking the branch. >> >> Yes, that is because we only want to validate the descriptors once >> even if we call this function multiple times for the same entry. > > Then I am probably misreading this function. But isn't head increased > by up to RX_BATCH_SIZE frames at once. If so, then for many frames > the branch is not taken.
You're not misreading it! :-) The head is indeed increased, but only the tail descriptor is validated in that function. Later in the xskq_discard_desc function when the tail is moved, the next descriptor is validated. So, the peek function will always return a validated descriptor, but the validation can be done in either peek or discard. Björn