Skip to content

Commit f2ac7e3

Browse files
Michal Kaziorjmberg-intel
authored andcommitted
mac80211: expose txq queue depth and size to drivers
This will allow drivers to make more educated decisions whether to defer transmission or not. Relying on wake_tx_queue() call count implicitly was not possible because it could be called without queued frame count actually changing on software tx aggregation start/stop code paths. It was also not possible to know how long byte-wise queue was without dequeueing. Signed-off-by: Michal Kazior <[email protected]> Signed-off-by: Johannes Berg <[email protected]>
1 parent dfdfc2b commit f2ac7e3

File tree

6 files changed

+39
-1
lines changed

6 files changed

+39
-1
lines changed

include/net/mac80211.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5596,4 +5596,19 @@ void ieee80211_unreserve_tid(struct ieee80211_sta *sta, u8 tid);
55965596
*/
55975597
struct sk_buff *ieee80211_tx_dequeue(struct ieee80211_hw *hw,
55985598
struct ieee80211_txq *txq);
5599+
5600+
/**
5601+
* ieee80211_txq_get_depth - get pending frame/byte count of given txq
5602+
*
5603+
* The values are not guaranteed to be coherent with regard to each other, i.e.
5604+
* txq state can change half-way of this function and the caller may end up
5605+
* with "new" frame_cnt and "old" byte_cnt or vice-versa.
5606+
*
5607+
* @txq: pointer obtained from station or virtual interface
5608+
* @frame_cnt: pointer to store frame count
5609+
* @byte_cnt: pointer to store byte count
5610+
*/
5611+
void ieee80211_txq_get_depth(struct ieee80211_txq *txq,
5612+
unsigned long *frame_cnt,
5613+
unsigned long *byte_cnt);
55995614
#endif /* MAC80211_H */

net/mac80211/ieee80211_i.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -804,6 +804,7 @@ enum txq_info_flags {
804804
struct txq_info {
805805
struct sk_buff_head queue;
806806
unsigned long flags;
807+
unsigned long byte_cnt;
807808

808809
/* keep last! */
809810
struct ieee80211_txq txq;

net/mac80211/iface.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -979,6 +979,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
979979

980980
spin_lock_bh(&txqi->queue.lock);
981981
ieee80211_purge_tx_queue(&local->hw, &txqi->queue);
982+
txqi->byte_cnt = 0;
982983
spin_unlock_bh(&txqi->queue.lock);
983984

984985
atomic_set(&sdata->txqs_len[txqi->txq.ac], 0);

net/mac80211/sta_info.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ static void __cleanup_single_sta(struct sta_info *sta)
116116

117117
ieee80211_purge_tx_queue(&local->hw, &txqi->queue);
118118
atomic_sub(n, &sdata->txqs_len[txqi->txq.ac]);
119+
txqi->byte_cnt = 0;
119120
}
120121
}
121122

net/mac80211/tx.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1270,7 +1270,11 @@ static void ieee80211_drv_tx(struct ieee80211_local *local,
12701270
if (atomic_read(&sdata->txqs_len[ac]) >= local->hw.txq_ac_max_pending)
12711271
netif_stop_subqueue(sdata->dev, ac);
12721272

1273-
skb_queue_tail(&txqi->queue, skb);
1273+
spin_lock_bh(&txqi->queue.lock);
1274+
txqi->byte_cnt += skb->len;
1275+
__skb_queue_tail(&txqi->queue, skb);
1276+
spin_unlock_bh(&txqi->queue.lock);
1277+
12741278
drv_wake_tx_queue(local, txqi);
12751279

12761280
return;
@@ -1298,6 +1302,8 @@ struct sk_buff *ieee80211_tx_dequeue(struct ieee80211_hw *hw,
12981302
if (!skb)
12991303
goto out;
13001304

1305+
txqi->byte_cnt -= skb->len;
1306+
13011307
atomic_dec(&sdata->txqs_len[ac]);
13021308
if (__netif_subqueue_stopped(sdata->dev, ac))
13031309
ieee80211_propagate_queue_wake(local, sdata->vif.hw_queue[ac]);

net/mac80211/util.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3368,3 +3368,17 @@ void ieee80211_init_tx_queue(struct ieee80211_sub_if_data *sdata,
33683368
txqi->txq.ac = IEEE80211_AC_BE;
33693369
}
33703370
}
3371+
3372+
void ieee80211_txq_get_depth(struct ieee80211_txq *txq,
3373+
unsigned long *frame_cnt,
3374+
unsigned long *byte_cnt)
3375+
{
3376+
struct txq_info *txqi = to_txq_info(txq);
3377+
3378+
if (frame_cnt)
3379+
*frame_cnt = txqi->queue.qlen;
3380+
3381+
if (byte_cnt)
3382+
*byte_cnt = txqi->byte_cnt;
3383+
}
3384+
EXPORT_SYMBOL(ieee80211_txq_get_depth);

0 commit comments

Comments
 (0)