Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions lib/util/xdpsock.c
Original file line number Diff line number Diff line change
Expand Up @@ -1144,8 +1144,10 @@ static inline int complete_tx_l2fwd(struct xsk_socket_info *xsk,
if (busy_poll || xsk_ring_prod__needs_wakeup(&umem->fq)) {
xsk->app_stats.fill_fail_polls++;
if (recvfrom(xsk_socket__fd(xsk->xsk), NULL, 0,
MSG_DONTWAIT, NULL, NULL) < 0)
MSG_DONTWAIT, NULL, NULL) < 0) {
xsk_ring_cons__cancel(&umem->cq, rcvd);
return -errno;
}
}
slots = xsk_ring_prod__reserve(&umem->fq, rcvd, &idx_fq);
}
Expand All @@ -1166,6 +1168,8 @@ static inline int complete_tx_l2fwd(struct xsk_socket_info *xsk,
}

xsk_ring_prod__submit(&xsk->umem->fq, i);
if (i < rcvd)
xsk_ring_cons__cancel(&umem->cq, rcvd - i);
xsk_ring_cons__release(&xsk->umem->cq, i);
xsk->outstanding_tx -= i;
}
Expand Down Expand Up @@ -1214,8 +1218,10 @@ static int rx_drop(struct xsk_socket_info *xsk, __u32 batch_size, bool busy_poll
if (busy_poll || xsk_ring_prod__needs_wakeup(&xsk->umem->fq)) {
xsk->app_stats.fill_fail_polls++;
if (recvfrom(xsk_socket__fd(xsk->xsk), NULL, 0,
MSG_DONTWAIT, NULL, NULL) < 0)
MSG_DONTWAIT, NULL, NULL) < 0) {
xsk_ring_cons__cancel(&xsk->rx, rcvd);
return -errno;
}
}
slots = xsk_ring_prod__reserve(&xsk->umem->fq, rcvd, &idx_fq);
}
Expand Down Expand Up @@ -1245,6 +1251,8 @@ static int rx_drop(struct xsk_socket_info *xsk, __u32 batch_size, bool busy_poll
}

xsk_ring_prod__submit(&xsk->umem->fq, i);
if (i < rcvd)
xsk_ring_cons__cancel(&xsk->rx, rcvd - i);
xsk_ring_cons__release(&xsk->rx, i);
xsk->ring_stats.rx_npkts += eop_cnt;
xsk->ring_stats.rx_frags += i;
Expand Down Expand Up @@ -1482,8 +1490,10 @@ static int l2fwd(struct xsk_ctx *ctx, struct xsk_socket_info *xsk)
if (ctx->opt.busy_poll || xsk_ring_prod__needs_wakeup(&xsk->tx)) {
xsk->app_stats.tx_wakeup_sendtos++;
ret = kick_tx(xsk);
if (ret)
if (ret) {
xsk_ring_cons__cancel(&xsk->rx, rcvd);
return ret;
}
}
slots = xsk_ring_prod__reserve(&xsk->tx, rcvd, &idx_tx);
}
Expand Down Expand Up @@ -1528,6 +1538,8 @@ static int l2fwd(struct xsk_ctx *ctx, struct xsk_socket_info *xsk)
}

xsk_ring_prod__submit(&xsk->tx, frags_done);
if (i < rcvd)
xsk_ring_cons__cancel(&xsk->rx, rcvd - i);
xsk_ring_cons__release(&xsk->rx, frags_done);

xsk->ring_stats.rx_npkts += eop_cnt;
Expand Down