Linux wireless drivers development
 help / color / mirror / Atom feed
From: Lorenzo Bianconi <lorenzo.bianconi@oss.qualcomm.com>
To: Vasanthakumar Thiagarajan <vasanthakumar.thiagarajan@oss.qualcomm.com>
Cc: Jeff Johnson <jjohnson@kernel.org>,
	Baochen Qiang <baochen.qiang@oss.qualcomm.com>,
	Carl Huang <quic_cjhuang@quicinc.com>,
	Bhagavathi Perumal S <quic_bperumal@quicinc.com>,
	Pradeep Kumar Chitrapu <quic_pradeepc@quicinc.com>,
	Karthikeyan Periyasamy <quic_periyasa@quicinc.com>,
	Sriram R <sriram.ramachandran@oss.qualcomm.com>,
	Ramya Gnanasekar <quic_rgnanase@quicinc.com>,
	Wen Gong <quic_wgong@quicinc.com>,
	P Praneesh <quic_ppranees@quicinc.com>,
	Balamurugan Selvarajan <quic_bselvara@quicinc.com>,
	linux-wireless@vger.kernel.org, ath12k@lists.infradead.org,
	Jeff Johnson <jeff.johnson@oss.qualcomm.com>
Subject: Re: [PATCH ath-next v2 4/4] wifi: ath12k: use ieee80211_rx_list() to deliver packets to mac80211
Date: Fri, 4 Dec 2026 16:24:38 +0100	[thread overview]
Message-ID: <axLbNqRL6dqaarFS@lore-desk> (raw)
In-Reply-To: <8f3969c6-3f95-4251-a628-c8239578d7d5@oss.qualcomm.com>

[-- Attachment #1: Type: text/plain, Size: 10411 bytes --]

> 
> 
> On 13-11-2026 20:21, Lorenzo Bianconi wrote:
> > Currently the regular rx path hands MSDUs to mac80211 one by one through
> > ieee80211_rx_napi(), and MSDUs spread over multiple rx buffers
> > (MSDU_CONTINUATION) are first linearized by
> > ath12k_wifi7_dp_rx_msdu_coalesce(), which may require a
> > pskb_expand_head() reallocation.
> > 
> > Rework the receive path to collect processed frames on a list and
> > deliver them to mac80211 as a batch with ieee80211_rx_list(), feeding
> > the result to napi_gro_receive() once the received packets have been
> > processed. Delivering frames in batches improves the icache footprint
> > and lets GRO process more frames together.
> > 
> > While at it, drop the linearization for multi-buffer MSDUs: chain the
> > continuation buffers on the head skb with frag_list and deliver a single
> > (possibly non-linear) skb per MSDU, running the per-frame processing
> > (h_ppdu, h_mpdu, link station lookup and rx_status copy) only on the
> > head.
> > 
> > Tested-on: WCN7850 hw2.0 PCI WLAN.HMT.1.1.c7-00108-QCAHMTSWPL_V1.0_V2.0_SILICONZ_UPSTREAM-3
> > 
> > Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@oss.qualcomm.com>
> > ---
> >   drivers/net/wireless/ath/ath12k/wifi7/dp_rx.c | 257 +++++++++++++-------------
> >   1 file changed, 126 insertions(+), 131 deletions(-)
> > 
> > diff --git a/drivers/net/wireless/ath/ath12k/wifi7/dp_rx.c b/drivers/net/wireless/ath/ath12k/wifi7/dp_rx.c
> > index f151f7de5554..c51faac4eb20 100644
> > --- a/drivers/net/wireless/ath/ath12k/wifi7/dp_rx.c
> > +++ b/drivers/net/wireless/ath/ath12k/wifi7/dp_rx.c
> > @@ -441,114 +441,28 @@ static int ath12k_wifi7_dp_rx_h_mpdu(struct ath12k_pdev_dp *dp_pdev,
> >   	return 0;
> >   }
> > -static int ath12k_wifi7_dp_rx_msdu_coalesce(struct ath12k_hal *hal,
> > -					    struct sk_buff_head *msdu_list,
> > -					    struct sk_buff *first, struct sk_buff *last,
> > -					    u8 l3pad_bytes, int msdu_len,
> > -					    struct hal_rx_desc_data *rx_info)
> > -{
> > -	struct sk_buff *skb;
> > -	struct ath12k_skb_rxcb *rxcb = ATH12K_SKB_RXCB(first);
> > -	int buf_first_hdr_len, buf_first_len;
> > -	struct hal_rx_desc *ldesc;
> > -	int space_extra, rem_len, buf_len;
> > -	u32 hal_rx_desc_sz = hal->hal_desc_sz;
> > -	bool is_continuation;
> > -
> > -	/* As the msdu is spread across multiple rx buffers,
> > -	 * find the offset to the start of msdu for computing
> > -	 * the length of the msdu in the first buffer.
> > -	 */
> > -	buf_first_hdr_len = hal_rx_desc_sz + l3pad_bytes;
> > -	buf_first_len = DP_RX_BUFFER_SIZE - buf_first_hdr_len;
> > -
> > -	if (WARN_ON_ONCE(msdu_len <= buf_first_len)) {
> > -		skb_put(first, buf_first_hdr_len + msdu_len);
> > -		skb_pull(first, buf_first_hdr_len);
> > -		return 0;
> > -	}
> > -
> > -	ldesc = (struct hal_rx_desc *)last->data;
> > -	rxcb->is_first_msdu = rx_info->is_first_msdu;
> > -	rxcb->is_last_msdu = rx_info->is_last_msdu;
> > -
> > -	/* MSDU spans over multiple buffers because the length of the MSDU
> > -	 * exceeds DP_RX_BUFFER_SIZE - HAL_RX_DESC_SIZE. So assume the data
> > -	 * in the first buf is of length DP_RX_BUFFER_SIZE - HAL_RX_DESC_SIZE.
> > -	 */
> > -	skb_put(first, DP_RX_BUFFER_SIZE);
> > -	skb_pull(first, buf_first_hdr_len);
> > -
> > -	/* When an MSDU spread over multiple buffers MSDU_END
> > -	 * tlvs are valid only in the last buffer. Copy those tlvs.
> > -	 */
> > -	ath12k_dp_rx_desc_end_tlv_copy(hal, rxcb->rx_desc, ldesc);
> > -
> > -	space_extra = msdu_len - (buf_first_len + skb_tailroom(first));
> > -	if (space_extra > 0 &&
> > -	    (pskb_expand_head(first, 0, space_extra, GFP_ATOMIC) < 0)) {
> > -		/* Free up all buffers of the MSDU */
> > -		while ((skb = __skb_dequeue(msdu_list)) != NULL) {
> > -			rxcb = ATH12K_SKB_RXCB(skb);
> > -			if (!rxcb->is_continuation) {
> > -				dev_kfree_skb_any(skb);
> > -				break;
> > -			}
> > -			dev_kfree_skb_any(skb);
> > -		}
> > -		return -ENOMEM;
> > -	}
> > -
> > -	rem_len = msdu_len - buf_first_len;
> > -	while ((skb = __skb_dequeue(msdu_list)) != NULL && rem_len > 0) {
> > -		rxcb = ATH12K_SKB_RXCB(skb);
> > -		is_continuation = rxcb->is_continuation;
> > -		if (is_continuation)
> > -			buf_len = DP_RX_BUFFER_SIZE - hal_rx_desc_sz;
> > -		else
> > -			buf_len = rem_len;
> > -
> > -		if (buf_len > (DP_RX_BUFFER_SIZE - hal_rx_desc_sz)) {
> > -			WARN_ON_ONCE(1);
> > -			dev_kfree_skb_any(skb);
> > -			return -EINVAL;
> > -		}
> > -
> > -		skb_put(skb, buf_len + hal_rx_desc_sz);
> > -		skb_pull(skb, hal_rx_desc_sz);
> > -		skb_copy_from_linear_data(skb, skb_put(first, buf_len),
> > -					  buf_len);
> > -		dev_kfree_skb_any(skb);
> > -
> > -		rem_len -= buf_len;
> > -		if (!is_continuation)
> > -			break;
> > -	}
> > -
> > -	return 0;
> > -}
> > -
> >   static int ath12k_wifi7_dp_rx_process_msdu(struct ath12k_pdev_dp *dp_pdev,
> >   					   struct sk_buff *msdu,
> >   					   struct sk_buff_head *msdu_list,
> > -					   struct hal_rx_desc_data *rx_info)
> > +					   struct hal_rx_desc_data *rx_info,
> > +					   struct list_head *list)
> >   {
> > -	struct ath12k_dp *dp = dp_pdev->dp;
> > +	struct ieee80211_rx_status *rx_status = IEEE80211_SKB_RXCB(msdu);
> > +	struct ieee80211_rx_status *status = rx_info->rx_status;
> > +	struct ath12k_skb_rxcb *rxcb = ATH12K_SKB_RXCB(msdu);
> > +	struct sk_buff *last_buf, *frag_list = NULL;
> > +	struct ieee80211_link_sta *link_sta = NULL;
> >   	struct hal_rx_desc *rx_desc, *lrx_desc;
> > -	struct ath12k_skb_rxcb *rxcb;
> > -	struct sk_buff *last_buf;
> > +	int ret, msdu_len, rx_desc_headroom;
> > +	struct ath12k_dp *dp = dp_pdev->dp;
> >   	struct ath12k_hal *hal = dp->hal;
> > -	u8 l3_pad_bytes;
> > -	u16 msdu_len;
> > -	int ret;
> > -	u32 hal_rx_desc_sz = hal->hal_desc_sz;
> > +	struct ath12k_dp_peer *peer;
> >   	last_buf = ath12k_dp_rx_get_msdu_last_buf(msdu_list, msdu);
> >   	if (!last_buf) {
> >   		ath12k_warn(dp->ab,
> >   			    "No valid Rx buffer to access MSDU_END tlv\n");
> > -		ret = -EIO;
> > -		goto free_out;
> > +		return -EIO;
> >   	}
> >   	rx_desc = (struct hal_rx_desc *)msdu->data;
> > @@ -557,56 +471,131 @@ static int ath12k_wifi7_dp_rx_process_msdu(struct ath12k_pdev_dp *dp_pdev,
> >   	ath12k_dp_extract_rx_desc_data(hal, rx_info, rx_desc, lrx_desc);
> >   	if (!rx_info->msdu_done) {
> >   		ath12k_warn(dp->ab, "msdu_done bit in msdu_end is not set\n");
> > -		ret = -EIO;
> > -		goto free_out;
> > +		return -EIO;
> >   	}
> > -	rxcb = ATH12K_SKB_RXCB(msdu);
> >   	rxcb->rx_desc = rx_desc;
> > +	rxcb->is_first_msdu = rx_info->is_first_msdu;
> > +	rxcb->is_last_msdu = rx_info->is_last_msdu;
> >   	msdu_len = rx_info->msdu_len;
> > -	l3_pad_bytes = rx_info->l3_pad_bytes;
> > +	rx_desc_headroom = hal->hal_desc_sz + rx_info->l3_pad_bytes;
> > +	/* When an MSDU spread over multiple buffers MSDU_END
> > +	 * tlvs are valid only in the last buffer. Copy those tlvs.
> > +	 */
> > +	if (rxcb->is_continuation)
> > +		ath12k_dp_rx_desc_end_tlv_copy(hal, rxcb->rx_desc, lrx_desc);
> >   	if (rxcb->is_frag) {
> > -		skb_pull(msdu, hal_rx_desc_sz);
> > -	} else if (!rxcb->is_continuation) {
> > -		if ((msdu_len + hal_rx_desc_sz) > DP_RX_BUFFER_SIZE) {
> > -			ret = -EINVAL;
> > -			ath12k_warn(dp->ab, "invalid msdu len %u\n", msdu_len);
> > -			ath12k_dbg_dump(dp->ab, ATH12K_DBG_DATA, NULL, "", rx_desc,
> > -					sizeof(*rx_desc));
> > -			goto free_out;
> > -		}
> > -		skb_put(msdu, hal_rx_desc_sz + l3_pad_bytes + msdu_len);
> > -		skb_pull(msdu, hal_rx_desc_sz + l3_pad_bytes);
> > +		skb_pull(msdu, hal->hal_desc_sz);
> >   	} else {
> > -		ret = ath12k_wifi7_dp_rx_msdu_coalesce(hal, msdu_list,
> > -						       msdu, last_buf,
> > -						       l3_pad_bytes, msdu_len,
> > -						       rx_info);
> > -		if (ret) {
> > -			ath12k_warn(dp->ab,
> > -				    "failed to coalesce msdu rx buffer%d\n", ret);
> > -			goto free_out;
> > +		if (!rxcb->is_continuation &&
> > +		    msdu_len + hal->hal_desc_sz > DP_RX_BUFFER_SIZE) {
> > +			ath12k_warn(dp->ab, "invalid msdu len %u\n", msdu_len);
> > +			ath12k_dbg_dump(dp->ab, ATH12K_DBG_DATA, NULL, "",
> > +					rx_desc, sizeof(*rx_desc));
> > +			return -EINVAL;
> >   		}
> > +
> > +		if (!rxcb->is_continuation ||
> > +		    msdu_len <= DP_RX_BUFFER_SIZE - rx_desc_headroom)
> > +			skb_put(msdu, rx_desc_headroom + msdu_len);
> > +		else
> > +			skb_put(msdu, DP_RX_BUFFER_SIZE);
> > +		skb_pull(msdu, rx_desc_headroom);
> >   	}
> > -	if (unlikely(!ath12k_dp_rx_check_nwifi_hdr_len_valid(dp, msdu,
> > -							     rx_info))) {
> > -		ret = -EINVAL;
> > -		goto free_out;
> > +	if (!rxcb->is_frag && rxcb->is_continuation) {
> > +		unsigned int frag_len = 0, truesize = 0;
> > +		struct sk_buff *skb, *last_frag;
> > +
> > +		/* The MSDU is spread across multiple rx buffers */
> > +		msdu_len -= (DP_RX_BUFFER_SIZE - rx_desc_headroom);
> > +
> > +		while (msdu_len > 0) {
> > +			struct ath12k_skb_rxcb *cb;
> > +			int len;
> > +
> > +			skb = __skb_dequeue(msdu_list);
> > +			if (!skb) {
> > +				WARN_ON_ONCE(msdu_len > 0);
> > +				goto free_frag_list;
> > +			}
> > +
> > +			cb = ATH12K_SKB_RXCB(skb);
> > +			if (cb->is_continuation)
> > +				len = DP_RX_BUFFER_SIZE - hal->hal_desc_sz;
> > +			else
> > +				len = msdu_len;
> > +
> > +			if (len > DP_RX_BUFFER_SIZE - hal->hal_desc_sz) {
> > +				dev_kfree_skb_any(skb);
> > +				goto free_frag_list;
> > +			}
> > +
> > +			skb_put(skb, len + hal->hal_desc_sz);
> > +			skb_pull(skb, hal->hal_desc_sz);
> > +
> > +			if (!frag_list)
> > +				frag_list = skb;
> > +			else
> > +				last_frag->next = skb;
> > +
> > +			skb->next = NULL;
> > +			last_frag = skb;
> > +
> > +			msdu_len -= len;
> > +			frag_len += skb->len;
> > +			truesize += skb->truesize;
> > +			if (!cb->is_continuation)
> > +				break;
> > +		}
> > +
> > +		if (frag_list) {
> > +			skb_shinfo(msdu)->frag_list = frag_list;
> > +			msdu->data_len = frag_len;
> > +			msdu->len += frag_len;
> > +			msdu->truesize += truesize;
> > +			msdu->next = NULL;
> > +		}
> 
> nit: This multi-buffer MSDU processingt and frag_list preparation along with
> the clean ups can be better done in a separate function?

ack, I will fix it in v3.

Regards,
Lorenzo

> 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

      reply	other threads:[~2026-12-04 15:24 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-13 14:51 [PATCH ath-next v2 0/4] wifi: ath12k: rely on ieee80211_rx_list() to send rx packets to mac80211 Lorenzo Bianconi
2026-11-13 14:51 ` [PATCH ath-next v2 1/4] wifi: ath12k: validate RX frame length before undecapsulation Lorenzo Bianconi
2026-11-13 14:51 ` [PATCH ath-next v2 2/4] wifi: ath12k: use MICHAEL_MIC_LEN for the TKIP Michael MIC Lorenzo Bianconi
2026-11-13 14:51 ` [PATCH ath-next v2 3/4] wifi: ath12k: rely on pskb_trim() to trim the received skb Lorenzo Bianconi
2026-11-13 14:51 ` [PATCH ath-next v2 4/4] wifi: ath12k: use ieee80211_rx_list() to deliver packets to mac80211 Lorenzo Bianconi
2026-12-01  6:57   ` Vasanthakumar Thiagarajan
2026-12-04 15:24     ` Lorenzo Bianconi [this message]

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=axLbNqRL6dqaarFS@lore-desk \
    --to=lorenzo.bianconi@oss.qualcomm.com \
    --cc=ath12k@lists.infradead.org \
    --cc=baochen.qiang@oss.qualcomm.com \
    --cc=jeff.johnson@oss.qualcomm.com \
    --cc=jjohnson@kernel.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=quic_bperumal@quicinc.com \
    --cc=quic_bselvara@quicinc.com \
    --cc=quic_cjhuang@quicinc.com \
    --cc=quic_periyasa@quicinc.com \
    --cc=quic_ppranees@quicinc.com \
    --cc=quic_pradeepc@quicinc.com \
    --cc=quic_rgnanase@quicinc.com \
    --cc=quic_wgong@quicinc.com \
    --cc=sriram.ramachandran@oss.qualcomm.com \
    --cc=vasanthakumar.thiagarajan@oss.qualcomm.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