rt2800usb reads TX_STA_FIFO with one control transfer per report, and keeps each frame in its 16 entry TX queue until its report has been read, so the TX rate is bound to the latency of control transfers. On the AMD X470 chipset USB 2.0 ports, each control transfer to an RT3070 takes 3 ms or more (the host retries an endpoint that NAKs only every few ms; the CPU's own xHCI does that within 0.25 ms). Pipelining reads doesn't help, the host still serves one transfer per 3 ms. TX there is limited to about 300 frames per second. Enable REQUIRE_TXSTATUS_SAMPLING: complete frames that don't need their status when the URB is done, read the FIFO while samples or waiting frames are outstanding, and give the sample slots back only when the FIFO is found empty. RT3070 as station on an X470 chipset port, MT7612U AP, channel 6 HT20, WPA2-CCMP, median of three 15 s iperf3 runs: before after TCP TX 3.4 Mbit/s, ~340 retr 37.8 Mbit/s, 1-8 retr UDP TX (60M sent) 8.9 Mbit/s, 60% loss 43.8 Mbit/s, 0% loss TCP RX 10.2 Mbit/s 29.8 Mbit/s minstrel_ht keeps getting samples with retries at all rates and picks MCS7. A GTK rekey every 10 s during 60 s of saturating TX with an A-MPDU session completes every time, without TX status timeouts. WPA2 (CCMP, TKIP, mixed) and SAE connect in both station and AP mode. Signed-off-by: Rosen Penev --- .../net/wireless/ralink/rt2x00/rt2800usb.c | 27 ++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/drivers/net/wireless/ralink/rt2x00/rt2800usb.c b/drivers/net/wireless/ralink/rt2x00/rt2800usb.c index 15de3db12429..5dd849e3dde5 100644 --- a/drivers/net/wireless/ralink/rt2x00/rt2800usb.c +++ b/drivers/net/wireless/ralink/rt2x00/rt2800usb.c @@ -104,6 +104,14 @@ static bool rt2800usb_tx_sta_fifo_read_completed(struct rt2x00_dev *rt2x00dev, } valid = rt2x00_get_field32(tx_status, TX_STA_FIFO_VALID); + + /* + * Rate control samples may produce more than one report each (A-MPDU), + * so the sample slots are only given back once the FIFO is empty. + */ + if (!valid) + atomic_set(&rt2x00dev->txstatus_samples, 0); + if (valid) { if (!kfifo_put(&rt2x00dev->txstatus_fifo, tx_status)) rt2x00_warn(rt2x00dev, "TX status FIFO overrun\n"); @@ -156,7 +164,12 @@ static void rt2800usb_tx_dma_done(struct queue_entry *entry) { struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev; - rt2800usb_async_read_tx_status(rt2x00dev); + if (test_bit(ENTRY_DATA_NO_TXSTATUS, &entry->flags)) + queue_work(rt2x00dev->workqueue, &rt2x00dev->txdone_work); + + if (!test_bit(ENTRY_DATA_NO_TXSTATUS, &entry->flags) || + test_bit(ENTRY_DATA_TXSTATUS_SAMPLE, &entry->flags)) + rt2800usb_async_read_tx_status(rt2x00dev); } static enum hrtimer_restart rt2800usb_tx_sta_fifo_timeout(struct hrtimer *timer) @@ -458,11 +471,15 @@ static void rt2800usb_work_txdone(struct work_struct *work) struct rt2x00_dev *rt2x00dev = container_of(work, struct rt2x00_dev, txdone_work); + rt2800_txdone_unreported(rt2x00dev); + while (!kfifo_is_empty(&rt2x00dev->txstatus_fifo) || rt2800_txstatus_timeout(rt2x00dev)) { rt2800_txdone(rt2x00dev, UINT_MAX); + rt2800_txdone_unreported(rt2x00dev); + rt2800_txdone_nostatus(rt2x00dev); /* @@ -615,6 +632,14 @@ static int rt2800usb_probe_hw(struct rt2x00_dev *rt2x00dev) if (retval) return retval; + /* + * Each TX status read is a USB control transfer, which can take + * several milliseconds. Holding every frame until its status has + * been read caps TX at one frame per transfer, so only frames that + * need a status wait for it. + */ + __set_bit(REQUIRE_TXSTATUS_SAMPLING, &rt2x00dev->cap_flags); + /* * Set txstatus timer function. */ -- 2.56.1