From: Chris Strong Drivers that queue received SKBs from a threaded interrupt may need to publish a partial batch before the handler returns. The existing overflow check covers only the NAPI-visible queue after the IRQ-local queue has been spliced, so it cannot guide that decision. Add can_rx_offload_irq_queue_needs_flush() to report when the IRQ-local queue reaches the NAPI poll weight. Keep the query separate from the flush operation so callers can finish processing related interrupt sources before publishing the batch. Assisted-by: LLM Signed-off-by: Chris Strong Link: https://patch.msgid.link/20260929-upstream-can-rx-offload-batching-v2-1-3b587c519f5d@flocksafety.com Signed-off-by: Marc Kleine-Budde --- include/linux/can/rx-offload.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/include/linux/can/rx-offload.h b/include/linux/can/rx-offload.h index d29bb4521947..f9b9474f7190 100644 --- a/include/linux/can/rx-offload.h +++ b/include/linux/can/rx-offload.h @@ -62,4 +62,11 @@ static inline void can_rx_offload_disable(struct can_rx_offload *offload) napi_disable(&offload->napi); } +static inline bool +can_rx_offload_irq_queue_needs_flush(const struct can_rx_offload *offload) +{ + /* skb_irq_queue is owned by the interrupt context queuing the SKBs. */ + return skb_queue_len(&offload->skb_irq_queue) >= offload->napi.weight; +} + #endif /* !_CAN_RX_OFFLOAD_H */ -- 2.53.0