[PATCH] wifi: ath12k: fix monitor buffer address TLV parsing on big-endian hosts

Alexander Wilhelm alexander.wilhelm at westermo.com
Mon Nov 23 04:57:28 PST 2026


ath12k_wifi7_dp_mon_parse_rx_dest_tlv() passes the value of the
HAL_MON_BUF_ADDR TLV directly to ath12k_dp_mon_parse_status_buf(), which
reads it as struct dp_mon_packet_info. The TLV consists of little-endian
32-bit words: the buffer cookie in word 0 and 1, and dma_length (bits
11:0), msdu_continuation (bit 16) and truncated (bit 17) in word 2. The
struct however uses host-endian u64/u16 fields and two bool fields covering
whole bytes instead of single bits.

On big-endian hosts (powerpc64) the cookie is read byte-swapped, the
resulting buf_id is invalid and every monitor buffer is dropped with "mon
dest desc with inval buf_id". A monitor interface does not receive any
frame. If the wrong buf_id matches a buffer still owned by the hardware,
that buffer is unmapped and freed while in use.

Describe the TLV as little-endian 32-bit words with bit masks, rename the
struct to dp_mon_packet_info_params as it represents the wire format, and
read the fields with le32_get_bits().

Fixes: d889913205cf ("wifi: ath12k: driver for Qualcomm Wi-Fi 7 devices")
Signed-off-by: Alexander Wilhelm <alexander.wilhelm at westermo.com>
---
 drivers/net/wireless/ath/ath12k/dp_mon.c |  8 +++++---
 drivers/net/wireless/ath/ath12k/dp_mon.h | 15 +++++++++------
 2 files changed, 14 insertions(+), 9 deletions(-)

diff --git a/drivers/net/wireless/ath/ath12k/dp_mon.c b/drivers/net/wireless/ath/ath12k/dp_mon.c
index ae14e118fe36..ab806e93843a 100644
--- a/drivers/net/wireless/ath/ath12k/dp_mon.c
+++ b/drivers/net/wireless/ath/ath12k/dp_mon.c
@@ -538,7 +538,7 @@ EXPORT_SYMBOL(ath12k_dp_pkt_set_pktlen);
 int
 ath12k_dp_mon_parse_status_buf(struct ath12k_pdev_dp *dp_pdev,
 			       struct ath12k_mon_data *pmon,
-			       const struct dp_mon_packet_info *packet_info)
+			       const struct dp_mon_packet_info_params *packet_info)
 {
 	struct ath12k_dp *dp = dp_pdev->dp;
 	struct ath12k_base *ab = dp->ab;
@@ -547,7 +547,7 @@ ath12k_dp_mon_parse_status_buf(struct ath12k_pdev_dp *dp_pdev,
 	int buf_id;
 	u32 offset;
 
-	buf_id = u32_get_bits(packet_info->cookie, DP_RXDMA_BUF_COOKIE_BUF_ID);
+	buf_id = le32_get_bits(packet_info->cookie_lo, DP_RXDMA_BUF_COOKIE_BUF_ID);
 
 	spin_lock_bh(&buf_ring->idr_lock);
 	msdu = idr_remove(&buf_ring->bufs_idr, buf_id);
@@ -562,7 +562,9 @@ ath12k_dp_mon_parse_status_buf(struct ath12k_pdev_dp *dp_pdev,
 			 msdu->len + skb_tailroom(msdu),
 			 DMA_FROM_DEVICE);
 
-	offset = packet_info->dma_length + ATH12K_MON_RX_DOT11_OFFSET;
+	offset = le32_get_bits(packet_info->info0,
+			       DP_MON_PACKET_INFO_INFO0_DMA_LENGTH) +
+		 ATH12K_MON_RX_DOT11_OFFSET;
 	if (ath12k_dp_pkt_set_pktlen(msdu, offset)) {
 		dev_kfree_skb_any(msdu);
 		goto dest_replenish;
diff --git a/drivers/net/wireless/ath/ath12k/dp_mon.h b/drivers/net/wireless/ath/ath12k/dp_mon.h
index f352655eae9d..6fffea1f284f 100644
--- a/drivers/net/wireless/ath/ath12k/dp_mon.h
+++ b/drivers/net/wireless/ath/ath12k/dp_mon.h
@@ -67,11 +67,14 @@ struct dp_mon_frame_min_one {
 	u8 addr1[ETH_ALEN];
 } __packed;
 
-struct dp_mon_packet_info {
-	u64 cookie;
-	u16 dma_length;
-	bool msdu_continuation;
-	bool truncated;
+#define DP_MON_PACKET_INFO_INFO0_DMA_LENGTH		GENMASK(11, 0)
+#define DP_MON_PACKET_INFO_INFO0_MSDU_CONTINUATION	BIT(16)
+#define DP_MON_PACKET_INFO_INFO0_TRUNCATED		BIT(17)
+
+struct dp_mon_packet_info_params {
+	__le32 cookie_lo;
+	__le32 cookie_hi;
+	__le32 info0;
 };
 
 struct dp_mon_tx_ppdu_info {
@@ -104,7 +107,7 @@ bool ath12k_dp_mon_comp_ppduid(u32 msdu_ppdu_id, u32 *ppdu_id);
 int
 ath12k_dp_mon_parse_status_buf(struct ath12k_pdev_dp *dp_pdev,
 			       struct ath12k_mon_data *pmon,
-			       const struct dp_mon_packet_info *packet_info);
+			       const struct dp_mon_packet_info_params *packet_info);
 void ath12k_dp_mon_update_radiotap(struct ath12k_pdev_dp *dp_pdev,
 				   struct hal_rx_mon_ppdu_info *ppduinfo,
 				   struct sk_buff *mon_skb,

---
base-commit: 03b7c601b6e314115015a57061f5b377afe13190
change-id: 20261123-ath11k-fix-monitor-mode-on-big-endian-8506849a6c49

Best regards,
-- 
Alexander Wilhelm <alexander.wilhelm at westermo.com>




More information about the ath12k mailing list