Commit e98e6df6 authored by Lorenzo Bianconi's avatar Lorenzo Bianconi Committed by Felix Fietkau

mt76: move pad estimation out of mt76_skb_adjust_pad

Move frame pad computation out of mt76_skb_adjust_pad routine.
This is a preliminary patch to introduce sdio tx aggregation.
Tested-by: default avatarSean Wang <sean.wang@mediatek.com>
Co-developed-by: default avatarSean Wang <sean.wang@mediatek.com>
Signed-off-by: default avatarSean Wang <sean.wang@mediatek.com>
Signed-off-by: default avatarLorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: default avatarFelix Fietkau <nbd@nbd.name>
parent ab25d9d4
...@@ -1043,7 +1043,7 @@ mt76u_bulk_msg(struct mt76_dev *dev, void *data, int len, int *actual_len, ...@@ -1043,7 +1043,7 @@ mt76u_bulk_msg(struct mt76_dev *dev, void *data, int len, int *actual_len,
return usb_bulk_msg(udev, pipe, data, len, actual_len, timeout); return usb_bulk_msg(udev, pipe, data, len, actual_len, timeout);
} }
int mt76_skb_adjust_pad(struct sk_buff *skb); int mt76_skb_adjust_pad(struct sk_buff *skb, int pad);
int mt76u_vendor_request(struct mt76_dev *dev, u8 req, int mt76u_vendor_request(struct mt76_dev *dev, u8 req,
u8 req_type, u16 val, u16 offset, u8 req_type, u16 val, u16 offset,
void *buf, size_t len); void *buf, size_t len);
......
...@@ -190,6 +190,8 @@ static int mt7663s_tx_run_queue(struct mt76_dev *dev, enum mt76_txq_id qid) ...@@ -190,6 +190,8 @@ static int mt7663s_tx_run_queue(struct mt76_dev *dev, enum mt76_txq_id qid)
&ple_sz)) &ple_sz))
break; break;
__skb_put_zero(e->skb, 4);
err = __mt7663s_xmit_queue(dev, e->skb->data, e->skb->len); err = __mt7663s_xmit_queue(dev, e->skb->data, e->skb->len);
if (err) if (err)
return err; return err;
......
...@@ -18,8 +18,7 @@ mt7663u_mcu_send_message(struct mt76_dev *mdev, struct sk_buff *skb, ...@@ -18,8 +18,7 @@ mt7663u_mcu_send_message(struct mt76_dev *mdev, struct sk_buff *skb,
int cmd, bool wait_resp) int cmd, bool wait_resp)
{ {
struct mt7615_dev *dev = container_of(mdev, struct mt7615_dev, mt76); struct mt7615_dev *dev = container_of(mdev, struct mt7615_dev, mt76);
int ret, seq, ep; int ret, seq, ep, len, pad;
u32 len;
mutex_lock(&mdev->mcu.mutex); mutex_lock(&mdev->mcu.mutex);
...@@ -31,7 +30,8 @@ mt7663u_mcu_send_message(struct mt76_dev *mdev, struct sk_buff *skb, ...@@ -31,7 +30,8 @@ mt7663u_mcu_send_message(struct mt76_dev *mdev, struct sk_buff *skb,
len = skb->len; len = skb->len;
put_unaligned_le32(len, skb_push(skb, sizeof(len))); put_unaligned_le32(len, skb_push(skb, sizeof(len)));
ret = mt76_skb_adjust_pad(skb); pad = round_up(skb->len, 4) + 4 - skb->len;
ret = mt76_skb_adjust_pad(skb, pad);
if (ret < 0) if (ret < 0)
goto out; goto out;
......
...@@ -247,6 +247,7 @@ int mt7663_usb_sdio_tx_prepare_skb(struct mt76_dev *mdev, void *txwi_ptr, ...@@ -247,6 +247,7 @@ int mt7663_usb_sdio_tx_prepare_skb(struct mt76_dev *mdev, void *txwi_ptr,
struct mt7615_dev *dev = container_of(mdev, struct mt7615_dev, mt76); struct mt7615_dev *dev = container_of(mdev, struct mt7615_dev, mt76);
struct sk_buff *skb = tx_info->skb; struct sk_buff *skb = tx_info->skb;
struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
int pad;
if ((info->flags & IEEE80211_TX_CTL_RATE_CTRL_PROBE) && if ((info->flags & IEEE80211_TX_CTL_RATE_CTRL_PROBE) &&
!msta->rate_probe) { !msta->rate_probe) {
...@@ -262,9 +263,12 @@ int mt7663_usb_sdio_tx_prepare_skb(struct mt76_dev *mdev, void *txwi_ptr, ...@@ -262,9 +263,12 @@ int mt7663_usb_sdio_tx_prepare_skb(struct mt76_dev *mdev, void *txwi_ptr,
u32 len = skb->len; u32 len = skb->len;
put_unaligned_le32(len, skb_push(skb, sizeof(len))); put_unaligned_le32(len, skb_push(skb, sizeof(len)));
pad = round_up(skb->len, 4) + 4 - skb->len;
} else {
pad = round_up(skb->len, 4) - skb->len;
} }
return mt76_skb_adjust_pad(skb); return mt76_skb_adjust_pad(skb, pad);
} }
EXPORT_SYMBOL_GPL(mt7663_usb_sdio_tx_prepare_skb); EXPORT_SYMBOL_GPL(mt7663_usb_sdio_tx_prepare_skb);
......
...@@ -45,7 +45,7 @@ EXPORT_SYMBOL_GPL(mt76x02u_mac_start); ...@@ -45,7 +45,7 @@ EXPORT_SYMBOL_GPL(mt76x02u_mac_start);
int mt76x02u_skb_dma_info(struct sk_buff *skb, int port, u32 flags) int mt76x02u_skb_dma_info(struct sk_buff *skb, int port, u32 flags)
{ {
u32 info; u32 info, pad;
/* Buffer layout: /* Buffer layout:
* | 4B | xfer len | pad | 4B | * | 4B | xfer len | pad | 4B |
...@@ -57,7 +57,8 @@ int mt76x02u_skb_dma_info(struct sk_buff *skb, int port, u32 flags) ...@@ -57,7 +57,8 @@ int mt76x02u_skb_dma_info(struct sk_buff *skb, int port, u32 flags)
FIELD_PREP(MT_TXD_INFO_DPORT, port) | flags; FIELD_PREP(MT_TXD_INFO_DPORT, port) | flags;
put_unaligned_le32(info, skb_push(skb, sizeof(info))); put_unaligned_le32(info, skb_push(skb, sizeof(info)));
return mt76_skb_adjust_pad(skb); pad = round_up(skb->len, 4) + 4 - skb->len;
return mt76_skb_adjust_pad(skb, pad);
} }
int mt76x02u_tx_prepare_skb(struct mt76_dev *mdev, void *data, int mt76x02u_tx_prepare_skb(struct mt76_dev *mdev, void *data,
......
...@@ -226,12 +226,13 @@ mt76s_tx_queue_skb_raw(struct mt76_dev *dev, enum mt76_txq_id qid, ...@@ -226,12 +226,13 @@ mt76s_tx_queue_skb_raw(struct mt76_dev *dev, enum mt76_txq_id qid,
struct sk_buff *skb, u32 tx_info) struct sk_buff *skb, u32 tx_info)
{ {
struct mt76_queue *q = dev->q_tx[qid]; struct mt76_queue *q = dev->q_tx[qid];
int ret = -ENOSPC, len = skb->len; int ret = -ENOSPC, len = skb->len, pad;
if (q->queued == q->ndesc) if (q->queued == q->ndesc)
goto error; goto error;
ret = mt76_skb_adjust_pad(skb); pad = round_up(skb->len, 4) - skb->len;
ret = mt76_skb_adjust_pad(skb, pad);
if (ret) if (ret)
goto error; goto error;
......
...@@ -589,13 +589,9 @@ u8 mt76_ac_to_hwq(u8 ac) ...@@ -589,13 +589,9 @@ u8 mt76_ac_to_hwq(u8 ac)
} }
EXPORT_SYMBOL_GPL(mt76_ac_to_hwq); EXPORT_SYMBOL_GPL(mt76_ac_to_hwq);
int mt76_skb_adjust_pad(struct sk_buff *skb) int mt76_skb_adjust_pad(struct sk_buff *skb, int pad)
{ {
struct sk_buff *iter, *last = skb; struct sk_buff *iter, *last = skb;
u32 pad;
/* Add zero pad of 4 - 7 bytes */
pad = round_up(skb->len, 4) + 4 - skb->len;
/* First packet of a A-MSDU burst keeps track of the whole burst /* First packet of a A-MSDU burst keeps track of the whole burst
* length, need to update length of it and the last packet. * length, need to update length of it and the last packet.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment