[PATCH 2/3] mt76: mt7663s: make all of packets 4-bytes aligned in sdio tx aggregation

Lorenzo Bianconi lorenzo.bianconi at redhat.com
Thu Mar 4 13:38:33 GMT 2021


> From: Sean Wang <sean.wang at mediatek.com>
> 
> Each packet should be padded with the additional zero to become 4-bytes
> alignment in sdio tx aggregation.
> 
> Fixes: 1522ff731f84 ("mt76: mt7663s: introduce sdio tx aggregation")
> Signed-off-by: Sean Wang <sean.wang at mediatek.com>
> ---
>  drivers/net/wireless/mediatek/mt76/mt7615/sdio_txrx.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/sdio_txrx.c b/drivers/net/wireless/mediatek/mt76/mt7615/sdio_txrx.c
> index 9fb506f2ace6..2d3b7d1e2c92 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt7615/sdio_txrx.c
> +++ b/drivers/net/wireless/mediatek/mt76/mt7615/sdio_txrx.c
> @@ -218,6 +218,7 @@ static int mt7663s_tx_run_queue(struct mt76_dev *dev, struct mt76_queue *q)
>  	int qid, err, nframes = 0, len = 0, pse_sz = 0, ple_sz = 0;
>  	bool mcu = q == dev->q_mcu[MT_MCUQ_WM];
>  	struct mt76_sdio *sdio = &dev->sdio;
> +	u8 pad;
>  
>  	qid = mcu ? ARRAY_SIZE(sdio->xmit_buf) - 1 : q->qid;
>  	while (q->first != q->head) {
> @@ -234,7 +235,8 @@ static int mt7663s_tx_run_queue(struct mt76_dev *dev, struct mt76_queue *q)
>  			goto next;
>  		}
>  
> -		if (len + e->skb->len + 4 > MT76S_XMIT_BUF_SZ)
> +		pad = roundup(e->skb->len, 4) - e->skb->len;
> +		if (len + e->skb->len + pad + 4 > MT76S_XMIT_BUF_SZ)
>  			break;
>  
>  		if (mt7663s_tx_pick_quota(sdio, mcu, e->buf_sz, &pse_sz,
> @@ -252,6 +254,9 @@ static int mt7663s_tx_run_queue(struct mt76_dev *dev, struct mt76_queue *q)
>  			len += iter->len;
>  			nframes++;
>  		}
> +
> +		memset(sdio->xmit_buf[qid] + len, 0, pad);
> +		len += pad;

maybe it is better to do something like:

		if (unlikely(pad)) {
			memset(sdio->xmit_buf[qid] + len, 0, pad);
			len += pad;
		}

Regards,
Lorenzo

>  next:
>  		q->first = (q->first + 1) % q->ndesc;
>  		e->done = true;
> -- 
> 2.25.1
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 228 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-mediatek/attachments/20210304/6830810b/attachment.sig>


More information about the Linux-mediatek mailing list