From: Julius Bairaktaris <julius@bairaktaris.de>
To: Jeff Johnson <jjohnson@kernel.org>
Cc: ath11k@lists.infradead.org, linux-wireless@vger.kernel.org,
linux-kernel@vger.kernel.org,
Baochen Qiang <baochen.qiang@oss.qualcomm.com>,
Vasanthakumar Thiagarajan
<vasanthakumar.thiagarajan@oss.qualcomm.com>,
Rameshkumar Sundaram <rameshkumar.sundaram@oss.qualcomm.com>,
Praneesh P <praneesh.p@oss.qualcomm.com>,
Lorenzo Bianconi <lorenzo.bianconi@oss.qualcomm.com>,
Mark Ruvald Pedersen <wabsie@gmail.com>,
Rosen Penev <rosenp@gmail.com>
Subject: [PATCH ath-next v1 09/10] wifi: ath11k: hand the CPU only the part of a REO buffer the device wrote
Date: Mon, 23 Nov 2026 14:41:36 +0100 [thread overview]
Message-ID: <20261123134137.718575-10-julius@bairaktaris.de> (raw)
In-Reply-To: <20261123134137.718575-1-julius@bairaktaris.de>
The REO reap takes each page pool buffer back from the device with a
dma_sync_single_for_cpu() over the whole buffer, 2048 bytes, while the
device wrote the descriptor, the L3 padding and the MSDU, whose length
the REO entry carries. A TCP acknowledgment, which is what a station
sends back on downlink, takes 453 bytes of it on IPQ8074 (384 of
descriptor, at most 3 of padding, 66 of frame): on a non-coherent system
the invalidation walks 32 cache lines where 8 hold what the device wrote.
Take back the descriptor, the largest padding of the two padding fields
and the MSDU length of the entry. The buffers of an MSDU that spans
several, the one with the continuation bit and the ones after it on the
ring, are taken whole as before; whether the last entry reaped had the
bit is kept per ring, so a chain split between two polls is still seen.
The length taken is recorded in the frame's control block, and
ath11k_dp_rx_process_msdu() takes back the rest, up to the length the
descriptor gives, before it reads the frame, should that be longer than
the entry's: the CPU never reads a byte of the buffer it has not
invalidated after the device wrote it. A line past what was taken back
is not read and may hold a stale copy; the page pool syncs the whole
page for the device before the device gets it again, and the reap of its
next frame invalidates what that frame covers.
A buffer of its own, without a page pool, is unmapped whole as before.
Tested-on: IPQ8074 hw2.0 AHB WLAN.HK.2.9.0.1-02146-QCAHKSWPL_SILICONZ-1
Signed-off-by: Julius Bairaktaris <julius@bairaktaris.de>
---
drivers/net/wireless/ath/ath11k/core.h | 2 +
drivers/net/wireless/ath/ath11k/dp.h | 4 ++
drivers/net/wireless/ath/ath11k/dp_rx.c | 71 +++++++++++++++++++++++--
3 files changed, 72 insertions(+), 5 deletions(-)
diff --git a/drivers/net/wireless/ath/ath11k/core.h b/drivers/net/wireless/ath/ath11k/core.h
index 4eb40e674c14..6b05b2e4d926 100644
--- a/drivers/net/wireless/ath/ath11k/core.h
+++ b/drivers/net/wireless/ath/ath11k/core.h
@@ -142,6 +142,8 @@ struct ath11k_skb_rxcb {
u8 tid;
u16 peer_id;
u16 seq_no;
+ /* the bytes of the buffer from its start that the CPU took back */
+ u16 sync_len;
struct ieee80211_sta *sta;
};
diff --git a/drivers/net/wireless/ath/ath11k/dp.h b/drivers/net/wireless/ath/ath11k/dp.h
index 5e973c337cb2..861cf65c5218 100644
--- a/drivers/net/wireless/ath/ath11k/dp.h
+++ b/drivers/net/wireless/ath/ath11k/dp.h
@@ -234,6 +234,8 @@ struct ath11k_pdev_dp {
#define DP_RX_BUFFER_SIZE 2048
#define DP_RX_BUFFER_SIZE_LITE 1024
#define DP_RX_BUFFER_ALIGN_SIZE 128
+/* The most L3 header padding the msdu_end TLV of any chip gives */
+#define DP_RX_L3_PAD_MAX 3
#define DP_RX_PP_ORDER 1
#define DP_RX_PP_FRAG_SIZE ALIGN(SKB_HEAD_ALIGN(DP_RX_BUFFER_SIZE), \
DP_RX_BUFFER_ALIGN_SIZE)
@@ -279,6 +281,8 @@ struct ath11k_dp {
struct dp_srng reo_cmd_ring;
struct dp_srng reo_status_ring;
struct dp_srng reo_dst_ring[DP_REO_DST_RING_MAX];
+ /* the last entry reaped from the ring had the continuation bit */
+ bool reo_dst_cont[DP_REO_DST_RING_MAX];
struct dp_tx_ring tx_ring[DP_TCL_NUM_RING_MAX];
struct hal_wbm_idle_scatter_list scatter_list[DP_IDLE_SCATTER_BUFS_MAX];
struct list_head reo_cmd_list;
diff --git a/drivers/net/wireless/ath/ath11k/dp_rx.c b/drivers/net/wireless/ath/ath11k/dp_rx.c
index dd5bc35581f7..313a39f15781 100644
--- a/drivers/net/wireless/ath/ath11k/dp_rx.c
+++ b/drivers/net/wireless/ath/ath11k/dp_rx.c
@@ -410,17 +410,59 @@ static bool ath11k_dp_rx_buf_is_pp(struct sk_buff *skb)
return skb->pp_recycle && skb->head_frag;
}
-static void ath11k_dp_rx_unmap_buf(struct ath11k_base *ab, struct sk_buff *skb,
- enum dma_data_direction dir)
+/*
+ * Hands a receive buffer back to the CPU: of a page pool buffer the first
+ * @want bytes, or all of it for a @want of 0 or past its end, and records
+ * how much in sync_len. A buffer of its own is unmapped whole.
+ */
+static void ath11k_dp_rx_unmap_buf_len(struct ath11k_base *ab,
+ struct sk_buff *skb,
+ enum dma_data_direction dir,
+ unsigned int want)
{
struct ath11k_skb_rxcb *rxcb = ATH11K_SKB_RXCB(skb);
unsigned int len = skb->len + skb_tailroom(skb);
- if (ath11k_dp_rx_buf_is_pp(skb))
+ BUILD_BUG_ON(FIELD_MAX(RX_MSDU_END_INFO2_L3_HDR_PADDING) >
+ DP_RX_L3_PAD_MAX);
+ BUILD_BUG_ON(FIELD_MAX(RX_MSDU_END_INFO4_L3_HDR_PADDING) >
+ DP_RX_L3_PAD_MAX);
+
+ if (ath11k_dp_rx_buf_is_pp(skb)) {
+ if (want && want < len)
+ len = want;
dma_sync_single_for_cpu(ab->dev, rxcb->paddr, len,
DMA_BIDIRECTIONAL);
- else
+ } else {
dma_unmap_single(ab->dev, rxcb->paddr, len, dir);
+ }
+ rxcb->sync_len = len;
+}
+
+static void ath11k_dp_rx_unmap_buf(struct ath11k_base *ab, struct sk_buff *skb,
+ enum dma_data_direction dir)
+{
+ ath11k_dp_rx_unmap_buf_len(ab, skb, dir, 0);
+}
+
+/*
+ * Takes back from the device the bytes of @msdu past those it took at the
+ * reap, up to @need, for a frame whose descriptor says it is longer than
+ * its REO entry did.
+ */
+static void ath11k_dp_rx_sync_more(struct ath11k_base *ab, struct sk_buff *msdu,
+ unsigned int need)
+{
+ struct ath11k_skb_rxcb *rxcb = ATH11K_SKB_RXCB(msdu);
+ unsigned int len = msdu->len + skb_tailroom(msdu);
+
+ need = min(need, len);
+ if (likely(need <= rxcb->sync_len))
+ return;
+
+ dma_sync_single_for_cpu(ab->dev, rxcb->paddr + rxcb->sync_len,
+ need - rxcb->sync_len, DMA_BIDIRECTIONAL);
+ rxcb->sync_len = need;
}
static dma_addr_t ath11k_dp_rx_pp_dma_addr(struct sk_buff *skb)
@@ -2870,6 +2912,8 @@ static int ath11k_dp_rx_process_msdu(struct ath11k *ar,
sizeof(struct hal_rx_desc));
goto free_out;
}
+ ath11k_dp_rx_sync_more(ab, msdu, hal_rx_desc_sz + l3_pad_bytes +
+ msdu_len);
skb_put(msdu, hal_rx_desc_sz + l3_pad_bytes + msdu_len);
skb_pull(msdu, hal_rx_desc_sz + l3_pad_bytes);
} else {
@@ -3027,6 +3071,8 @@ static void ath11k_dp_rx_prefetch_frame(struct ath11k_base *ab,
int ath11k_dp_process_rx(struct ath11k_base *ab, int ring_id,
struct napi_struct *napi, int budget)
{
+ unsigned int want;
+ u32 info0;
struct ath11k_dp *dp = &ab->dp;
struct dp_rxdma_ring *rx_ring;
int num_buffs_reaped[MAX_RADIOS] = {};
@@ -3067,6 +3113,21 @@ int ath11k_dp_process_rx(struct ath11k_base *ab, int ring_id,
cookie);
mac_id = FIELD_GET(DP_RXDMA_BUF_COOKIE_PDEV_ID, cookie);
+ /*
+ * The device wrote the descriptor, the padding and the MSDU
+ * of the length the entry gives. A buffer of an MSDU that
+ * spans several, which follows one with the continuation bit
+ * or has it, is taken whole.
+ */
+ info0 = desc->rx_msdu_info.info0;
+ want = ab->hw_params.hal_desc_sz + DP_RX_L3_PAD_MAX +
+ FIELD_GET(RX_MSDU_DESC_INFO0_MSDU_LENGTH, info0);
+ if (dp->reo_dst_cont[ring_id] ||
+ (info0 & RX_MSDU_DESC_INFO0_MSDU_CONTINUATION))
+ want = 0;
+ dp->reo_dst_cont[ring_id] =
+ !!(info0 & RX_MSDU_DESC_INFO0_MSDU_CONTINUATION);
+
if (unlikely(buf_id == 0))
continue;
@@ -3086,7 +3147,7 @@ int ath11k_dp_process_rx(struct ath11k_base *ab, int ring_id,
spin_unlock(&rx_ring->bufs_lock);
rxcb = ATH11K_SKB_RXCB(msdu);
- ath11k_dp_rx_unmap_buf(ab, msdu, DMA_FROM_DEVICE);
+ ath11k_dp_rx_unmap_buf_len(ab, msdu, DMA_FROM_DEVICE, want);
if (cached)
ath11k_dp_rx_prefetch_frame(ab, msdu);
--
2.53.0
next prev parent reply other threads:[~2026-11-23 13:41 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-23 13:41 [PATCH ath-next v1 00/10] wifi: ath11k: cut the per-packet cost of the RX path Julius Bairaktaris
2026-11-23 13:41 ` [PATCH ath-next v1 01/10] wifi: ath11k: use page_pool for the RX refill ring Julius Bairaktaris
2026-11-23 13:41 ` [PATCH ath-next v1 02/10] wifi: ath11k: replace the RX buffer IDR with a table Julius Bairaktaris
2026-11-23 13:41 ` [PATCH ath-next v1 03/10] wifi: ath11k: request only the PPDU stats TLVs it reads Julius Bairaktaris
2026-11-23 13:41 ` [PATCH ath-next v1 04/10] wifi: ath11k: set the skb hash of a received frame from the hardware Julius Bairaktaris
2026-11-23 13:41 ` [PATCH ath-next v1 05/10] wifi: ath11k: sync a cached ring's new entries once per head read Julius Bairaktaris
2026-11-23 13:41 ` [PATCH ath-next v1 06/10] wifi: ath11k: prefetch the buffers of the REO entries ahead of their reap Julius Bairaktaris
2026-11-23 13:41 ` [PATCH ath-next v1 07/10] wifi: ath11k: look the peer of a received MSDU up once Julius Bairaktaris
2026-11-23 13:41 ` [PATCH ath-next v1 08/10] wifi: ath11k: take the refill buffer lock without a second BH disable Julius Bairaktaris
2026-11-23 13:41 ` Julius Bairaktaris [this message]
2026-11-23 13:41 ` [PATCH ath-next v1 10/10] wifi: ath11k: give the refill buffers their ids a chunk at a time Julius Bairaktaris
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261123134137.718575-10-julius@bairaktaris.de \
--to=julius@bairaktaris.de \
--cc=ath11k@lists.infradead.org \
--cc=baochen.qiang@oss.qualcomm.com \
--cc=jjohnson@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-wireless@vger.kernel.org \
--cc=lorenzo.bianconi@oss.qualcomm.com \
--cc=praneesh.p@oss.qualcomm.com \
--cc=rameshkumar.sundaram@oss.qualcomm.com \
--cc=rosenp@gmail.com \
--cc=vasanthakumar.thiagarajan@oss.qualcomm.com \
--cc=wabsie@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®