Skip to content

Commit

Permalink
mt76: rely on AQL for burst size limits on tx queueing
Browse files Browse the repository at this point in the history
Now that AQL works well on all mt76 drivers, completely replace the arbitrary
burst sizing and number of bursts logic for tx scheduling.
For the short period of time in which AQL does not work well yet, limit each
stations to 16 in-flight packets that have no estimated tx time.
This should avoid filling the queue if a station connects and queues up a
large number of packets before rate control information is available, especially
with hardware rate control

Signed-off-by: Felix Fietkau <nbd@nbd.name>
  • Loading branch information
nbd168 committed Aug 24, 2020
1 parent 05aa857 commit e861cb0
Show file tree
Hide file tree
Showing 12 changed files with 109 additions and 75 deletions.
9 changes: 4 additions & 5 deletions debugfs.c
Expand Up @@ -31,15 +31,14 @@ int mt76_queues_read(struct seq_file *s, void *data)
int i;

for (i = 0; i < ARRAY_SIZE(dev->q_tx); i++) {
struct mt76_sw_queue *q = &dev->q_tx[i];
struct mt76_queue *q = dev->q_tx[i].q;

if (!q->q)
if (!q)
continue;

seq_printf(s,
"%d: queued=%d head=%d tail=%d swq_queued=%d\n",
i, q->q->queued, q->q->head, q->q->tail,
q->swq_queued);
"%d: queued=%d head=%d tail=%d\n",
i, q->queued, q->head, q->tail);
}

return 0;
Expand Down
11 changes: 6 additions & 5 deletions mt76.h
Expand Up @@ -22,6 +22,9 @@
#define MT_RX_BUF_SIZE 2048
#define MT_SKB_HEAD_LEN 128

#define MT_MAX_NON_AQL_PKT 16
#define MT_TXQ_FREE_THR 32

struct mt76_dev;
struct mt76_phy;
struct mt76_wcid;
Expand Down Expand Up @@ -100,10 +103,9 @@ struct mt76_queue_entry {
struct urb *urb;
int buf_sz;
};
enum mt76_txq_id qid;
u16 wcid;
bool skip_buf0:1;
bool skip_buf1:1;
bool schedule:1;
bool done:1;
};

Expand Down Expand Up @@ -139,8 +141,6 @@ struct mt76_queue {

struct mt76_sw_queue {
struct mt76_queue *q;

int swq_queued;
};

struct mt76_mcu_ops {
Expand Down Expand Up @@ -206,6 +206,7 @@ DECLARE_EWMA(signal, 10, 8);
struct mt76_wcid {
struct mt76_rx_tid __rcu *aggr[IEEE80211_NUM_TIDS];

atomic_t non_aql_packets;
unsigned long flags;

struct ewma_signal rssi;
Expand Down Expand Up @@ -953,7 +954,7 @@ struct sk_buff *mt76_tx_status_skb_get(struct mt76_dev *dev,
struct sk_buff_head *list);
void mt76_tx_status_skb_done(struct mt76_dev *dev, struct sk_buff *skb,
struct sk_buff_head *list);
void mt76_tx_complete_skb(struct mt76_dev *dev, struct sk_buff *skb);
void mt76_tx_complete_skb(struct mt76_dev *dev, u16 wcid, struct sk_buff *skb);
void mt76_tx_status_check(struct mt76_dev *dev, struct mt76_wcid *wcid,
bool flush);
int mt76_sta_state(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
Expand Down
2 changes: 1 addition & 1 deletion mt7603/mac.c
Expand Up @@ -1282,7 +1282,7 @@ void mt7603_tx_complete_skb(struct mt76_dev *mdev, struct mt76_queue_entry *e)
}

dev->tx_hang_check = 0;
mt76_tx_complete_skb(mdev, skb);
mt76_tx_complete_skb(mdev, e->wcid, skb);
}

static bool
Expand Down
9 changes: 8 additions & 1 deletion mt7615/mac.c
Expand Up @@ -1400,6 +1400,9 @@ mt7615_mac_tx_free_token(struct mt7615_dev *dev, u16 token)
{
struct mt76_dev *mdev = &dev->mt76;
struct mt76_txwi_cache *txwi;
__le32 *txwi_data;
u32 val;
u8 wcid;

trace_mac_tx_free(dev, token);

Expand All @@ -1410,9 +1413,13 @@ mt7615_mac_tx_free_token(struct mt7615_dev *dev, u16 token)
if (!txwi)
return;

txwi_data = (__le32 *)mt76_get_txwi_ptr(mdev, txwi);
val = le32_to_cpu(txwi_data[1]);
wcid = FIELD_GET(MT_TXD1_WLAN_IDX, val);

mt7615_txp_skb_unmap(mdev, txwi);
if (txwi->skb) {
mt76_tx_complete_skb(mdev, txwi->skb);
mt76_tx_complete_skb(mdev, wcid, txwi->skb);
txwi->skb = NULL;
}

Expand Down
2 changes: 1 addition & 1 deletion mt7615/pci_mac.c
Expand Up @@ -44,7 +44,7 @@ void mt7615_tx_complete_skb(struct mt76_dev *mdev, struct mt76_queue_entry *e)
}

if (e->skb)
mt76_tx_complete_skb(mdev, e->skb);
mt76_tx_complete_skb(mdev, e->wcid, e->skb);
}

static void
Expand Down
2 changes: 1 addition & 1 deletion mt7615/usb_sdio.c
Expand Up @@ -234,7 +234,7 @@ void mt7663_usb_sdio_tx_complete_skb(struct mt76_dev *mdev,
headroom += MT_USB_HDR_SIZE;
skb_pull(e->skb, headroom);

mt76_tx_complete_skb(mdev, e->skb);
mt76_tx_complete_skb(mdev, e->wcid, e->skb);
}
EXPORT_SYMBOL_GPL(mt7663_usb_sdio_tx_complete_skb);

Expand Down
2 changes: 1 addition & 1 deletion mt76x02_mac.c
Expand Up @@ -917,7 +917,7 @@ void mt76x02_tx_complete_skb(struct mt76_dev *mdev, struct mt76_queue_entry *e)
txwi = (struct mt76x02_txwi *)txwi_ptr;
trace_mac_txdone(mdev, txwi->wcid, txwi->pktid);

mt76_tx_complete_skb(mdev, e->skb);
mt76_tx_complete_skb(mdev, e->wcid, e->skb);
}
EXPORT_SYMBOL_GPL(mt76x02_tx_complete_skb);

Expand Down
2 changes: 1 addition & 1 deletion mt76x02_usb_core.c
Expand Up @@ -18,7 +18,7 @@ static void mt76x02u_remove_dma_hdr(struct sk_buff *skb)
void mt76x02u_tx_complete_skb(struct mt76_dev *mdev, struct mt76_queue_entry *e)
{
mt76x02u_remove_dma_hdr(e->skb);
mt76_tx_complete_skb(mdev, e->skb);
mt76_tx_complete_skb(mdev, e->wcid, e->skb);
}
EXPORT_SYMBOL_GPL(mt76x02u_tx_complete_skb);

Expand Down
11 changes: 11 additions & 0 deletions mt7915/mac.c
Expand Up @@ -997,10 +997,21 @@ void mt7915_mac_tx_free(struct mt7915_dev *dev, struct sk_buff *skb)

mt7915_txp_skb_unmap(mdev, txwi);
if (txwi->skb) {
struct ieee80211_tx_info *info = IEEE80211_SKB_CB(txwi->skb);
void *txwi_ptr = mt76_get_txwi_ptr(mdev, txwi);

if (likely(txwi->skb->protocol != cpu_to_be16(ETH_P_PAE)))
mt7915_tx_check_aggr(sta, txwi_ptr);

if (sta && !info->tx_time_est) {
struct mt76_wcid *wcid = (struct mt76_wcid *)sta->drv_priv;
int pending;

pending = atomic_dec_return(&wcid->non_aql_packets);
if (pending < 0)
atomic_cmpxchg(&wcid->non_aql_packets, pending, 0);
}

mt7915_tx_complete_status(mdev, txwi->skb, sta, stat);
txwi->skb = NULL;
}
Expand Down
1 change: 0 additions & 1 deletion sdio.c
Expand Up @@ -144,7 +144,6 @@ static void mt76s_process_tx_queue(struct mt76_dev *dev, enum mt76_txq_id qid)

entry = q->entry[q->tail];
q->entry[q->tail].done = false;
q->entry[q->tail].schedule = false;

if (qid == MT_TXQ_MCU) {
dev_kfree_skb(entry.skb);
Expand Down

0 comments on commit e861cb0

Please sign in to comment.