netdev-afxdp: fix corner case where umem entries were not released
If for some reason the last element in the batch was already pushed on
the stack, none of the elements where pushed. This was leading to
buffer starvation.
@@ -811,15 +811,15 @@ afxdp_complete_tx(struct xsk_socket_info *xsk_info)
void *elem;
addr = (uint64_t *)xsk_ring_cons__comp_addr(&umem->cq, idx_cq++);
- if (*addr == UINT64_MAX) {
- /* The elem has been pushed already. */
- COVERAGE_INC(afxdp_cq_skip);
- continue;
- }
+ if (*addr != UINT64_MAX) {
elem = ALIGNED_CAST(void *, (char *)umem->buffer + *addr);
elems_push[tx_to_free] = elem;
*addr = UINT64_MAX; /* Mark as pushed. */
tx_to_free++;
+ } else {
+ /* The elem has been pushed already. */
+ COVERAGE_INC(afxdp_cq_skip);
+ }
if (tx_to_free == BATCH_SIZE || j == tx_done - 1) {
umem_elem_push_n(&umem->mpool, tx_to_free, elems_push);
