libeth adds the buffers it sends on an XDPSQ to the driver's in-flight
XDP_TX count. On completion, libeth counts them in struct
libeth_cq_pp, whose kernel-doc calls it the number processed, and idpf
subtracts that number. Currently libeth counts down from 0, so the
subtraction adds, and the count grows by two per buffer.
idpf reads the count only on its XSk queues. At 0 it completes all
done descriptors as XSk xmit frames at once. After the first XDP_TX
buffer the count never gets back to 0, and every completion takes the
slow path. After about 2^31 buffers the count wraps. If it lands on 0
while XDP_TX buffers are in flight, idpf completes them as XSk xmit
frames. Their buffers are never freed, and userspace gets completions
for xmit descriptors that are still in flight.
Count the completed buffers up, as the kernel-doc says, and say
buffers there, not frames.
Found by an AI code review agent in review of this series. Not
triggered at runtime.
Fixes: 8ff6d62261a3 ("idpf: implement XSk xmit")
Signed-off-by: Björn Töpel <bjo…@kernel.org>
---
include/net/libeth/tx.h | 2 +-
include/net/libeth/xdp.h | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/include/net/libeth/tx.h b/include/net/libeth/tx.h
index c3db5c6f1641..622c26059cb9 100644
--- a/include/net/libeth/tx.h
+++ b/include/net/libeth/tx.h
@@ -93,7 +93,7 @@ struct libeth_sqe {
* @bq: XDP frame bulk to combine return operations
* @ss: onstack NAPI stats to fill
* @xss: onstack XDPSQ NAPI stats to fill
- * @xdp_tx: number of XDP-not-XSk frames processed
+ * @xdp_tx: number of non-XSk-xmit XDP buffers processed
* @napi: whether it's called from the NAPI context
*
* libeth uses this structure to access objects needed for performing full
diff --git a/include/net/libeth/xdp.h b/include/net/libeth/xdp.h
index 898723ab62e8..38fcd3fdff70 100644
--- a/include/net/libeth/xdp.h
+++ b/include/net/libeth/xdp.h
@@ -1795,7 +1795,7 @@ __libeth_xdp_complete_tx(struct libeth_sqe *sqe, struct libeth_cq_pp *cp,
case LIBETH_SQE_XDP_TX:
case LIBETH_SQE_XDP_XMIT:
case LIBETH_SQE_XSK_TX:
- cp->xdp_tx -= sqe->nr_frags;
+ cp->xdp_tx += sqe->nr_frags;
cp->xss->packets++;
cp->xss->bytes += sqe->bytes;
--
2.53.1