2019-11-21 18:01:24

by Markus Theil

[permalink] [raw]
Subject: [PATCH v8 4/6] mt76: mt76x02: remove a copy call for usb speedup

This patch removes a mt76_wr_copy call from the beacon path to hw.
The skb which is used in this place gets therefore build with txwi
inside its data. For mt76 usb drivers, this saves one synchronuous
copy call over usb, which lets the beacon work complete faster.

In mmio case, there is not enough headroom to put the txwi into the
skb, it is therefore using an additional mt76_wr_copy, which is fast
over mmio. Thanks Stanislaw for pointing this out.

Signed-off-by: Markus Theil <[email protected]>
---
.../wireless/mediatek/mt76/mt76x02_beacon.c | 19 +++++++++++++++----
1 file changed, 15 insertions(+), 4 deletions(-)

diff --git a/drivers/net/wireless/mediatek/mt76/mt76x02_beacon.c b/drivers/net/wireless/mediatek/mt76/mt76x02_beacon.c
index b01a6745ed47..043cb03c86a2 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76x02_beacon.c
+++ b/drivers/net/wireless/mediatek/mt76/mt76x02_beacon.c
@@ -27,15 +27,26 @@ static int
mt76x02_write_beacon(struct mt76x02_dev *dev, int offset, struct sk_buff *skb)
{
int beacon_len = dev->beacon_ops->slot_size;
- struct mt76x02_txwi txwi;

if (WARN_ON_ONCE(beacon_len < skb->len + sizeof(struct mt76x02_txwi)))
return -ENOSPC;

- mt76x02_mac_write_txwi(dev, &txwi, skb, NULL, NULL, skb->len);
+ /* USB devices already reserve enough skb headroom for txwi's. This
+ * helps to save slow copies over USB.
+ */
+ if (mt76_is_usb(&dev->mt76)) {
+ struct mt76x02_txwi *txwi;
+
+ mt76_insert_hdr_pad(skb);
+ txwi = (struct mt76x02_txwi *)(skb->data - sizeof(*txwi));
+ mt76x02_mac_write_txwi(dev, txwi, skb, NULL, NULL, skb->len);
+ skb_push(skb, sizeof(*txwi));
+ } else {
+ struct mt76x02_txwi txwi;

- mt76_wr_copy(dev, offset, &txwi, sizeof(txwi));
- offset += sizeof(txwi);
+ mt76_wr_copy(dev, offset, &txwi, sizeof(txwi));
+ offset += sizeof(txwi);
+ }

mt76_wr_copy(dev, offset, skb->data, skb->len);
return 0;
--
2.24.0


2019-11-25 12:52:15

by Stanislaw Gruszka

[permalink] [raw]
Subject: Re: [PATCH v8 4/6] mt76: mt76x02: remove a copy call for usb speedup

On Thu, Nov 21, 2019 at 06:59:59PM +0100, Markus Theil wrote:
> + if (mt76_is_usb(&dev->mt76)) {
> + struct mt76x02_txwi *txwi;
> +
> + mt76_insert_hdr_pad(skb);
> + txwi = (struct mt76x02_txwi *)(skb->data - sizeof(*txwi));
> + mt76x02_mac_write_txwi(dev, txwi, skb, NULL, NULL, skb->len);
> + skb_push(skb, sizeof(*txwi));
> + } else {
> + struct mt76x02_txwi txwi;

Here lack mt76x02_mac_write_txwi()

>
> - mt76_wr_copy(dev, offset, &txwi, sizeof(txwi));
> - offset += sizeof(txwi);
> + mt76_wr_copy(dev, offset, &txwi, sizeof(txwi));
> + offset += sizeof(txwi);

> + }

Stanislaw