Skip to contentSkip to conversation

mac80211: Add TXQ scheduling API

PATCH Superseded Toke Høiland-Jørgensen 4 participants 20 messages Oct 16, 2017 – Dec 19, 2017

Subsystems (3)

v1 of 5 Superseded Latest is v5 →

lore
Share & tools
lore

Toke Høiland-Jørgensen

author maintainer
#0 lore raw

PATCH 1/2 mac80211: Add TXQ scheduling API

This adds an API to mac80211 to handle scheduling of TXQs and changes the interface between driver and mac80211 for TXQ handling as follows:

- The wake_tx_queue callback interface no longer includes the TXQ. Instead, the driver is expected to retrieve that from ieee80211_next_txq()

- Two new mac80211 functions are added: ieee80211_next_txq() and ieee80211_schedule_txq(). The former returns the next TXQ that should be scheduled, and is how the driver gets a queue to pull packets from. The latter is called internally by mac80211 to start scheduling a queue, and the driver is supposed to call it to re-schedule the TXQ after it is finished pulling packets from it (unless the queue emptied).

The ath9k and ath10k drivers are changed to use the new API.

---
Changes since the RFC:

- Don't call wake_tx_queue() if the TXQ was already scheduled.
- Fold ath9k and ath9k patches into this one.
- Don't mess with the powersave buffering behaviour, but keep the old driver behaviour for that (haven't tested with powersave enabled, though...).
- A couple of adjustments to ath9k behaviour after testing.

I don't have ath10k hardware handy, so this is untested on ath10k. However, ath10k required way less surgery to support the new API than ath9k did....

 drivers/net/wireless/ath/ath10k/core.c |   2 -
 drivers/net/wireless/ath/ath10k/core.h |   3 -
 drivers/net/wireless/ath/ath10k/mac.c  |  54 +++------
 drivers/net/wireless/ath/ath9k/ath9k.h |   6 +-
 drivers/net/wireless/ath/ath9k/main.c  |   2 +-
 drivers/net/wireless/ath/ath9k/xmit.c  | 209 ++++++++-------------------------
 include/net/mac80211.h                 |  35 +++++-
 net/mac80211/agg-tx.c                  |   6 +-
 net/mac80211/driver-ops.h              |  12 +-
 net/mac80211/ieee80211_i.h             |   4 +
 net/mac80211/main.c                    |   3 +
 net/mac80211/sta_info.c                |   5 +-
 net/mac80211/trace.h                   |  21 +---
 net/mac80211/tx.c                      |  48 +++++++-
 14 files changed, 167 insertions(+), 243 deletions(-)
drivers/net/wireless/ath/ath10k/core.c +0 -2
index a4f635820f35..759df3297d48 100644
@@ -2561,9 +2561,7 @@ struct ath10k *ath10k_core_create(size_t priv_size, struct device *dev,
 
 	mutex_init(&ar->conf_mutex);
 	spin_lock_init(&ar->data_lock);
-	spin_lock_init(&ar->txqs_lock);
 
-	INIT_LIST_HEAD(&ar->txqs);
 	INIT_LIST_HEAD(&ar->peers);
 	init_waitqueue_head(&ar->peer_mapping_wq);
 	init_waitqueue_head(&ar->htt.empty_tx_wq);
drivers/net/wireless/ath/ath10k/core.h +0 -3
index 949ebb3e967b..e7fc241addf6 100644
@@ -892,10 +892,7 @@ struct ath10k {
 
 	/* protects shared structure data */
 	spinlock_t data_lock;
-	/* protects: ar->txqs, artxq->list */
-	spinlock_t txqs_lock;
 
-	struct list_head txqs;
 	struct list_head arvifs;
 	struct list_head peers;
 	struct ath10k_peer *peer_map[ATH10K_MAX_NUM_PEER_IDS];
drivers/net/wireless/ath/ath10k/mac.c +16 -38

110 lines not on this page · raw message

drivers/net/wireless/ath/ath9k/ath9k.h +2 -4
index cf076719c27e..f6c53df78856 100644
@@ -246,7 +246,6 @@ struct ath_atx_tid {
 	s8 bar_index;
 	bool active;
 	bool clear_ps_filter;
-	bool has_queued;
 };
 
 void __ath_tx_queue_tid(struct ath_softc *sc, struct ath_atx_tid *tid);
@@ -591,8 +590,7 @@ bool ath_drain_all_txq(struct ath_softc *sc);
 void ath_draintxq(struct ath_softc *sc, struct ath_txq *txq);
 void ath_tx_node_init(struct ath_softc *sc, struct ath_node *an);
 void ath_tx_node_cleanup(struct ath_softc *sc, struct ath_node *an);
-void ath_txq_schedule(struct ath_softc *sc, struct ath_txq *txq);
-void ath_txq_schedule_all(struct ath_softc *sc);
+void ath_txq_schedule(struct ath_softc *sc);
 int ath_tx_init(struct ath_softc *sc, int nbufs);
 int ath_txq_update(struct ath_softc *sc, int qnum,
 		   struct ath9k_tx_queue_info *q);
@@ -618,7 +616,7 @@ void ath9k_release_buffered_frames(struct ieee80211_hw *hw,
 				   u16 tids, int nframes,
 				   enum ieee80211_frame_release_type reason,
 				   bool more_data);
-void ath9k_wake_tx_queue(struct ieee80211_hw *hw, struct ieee80211_txq *queue);
+void ath9k_wake_tx_queue(struct ieee80211_hw *hw);
 
 /********/
 /* VIFs */
drivers/net/wireless/ath/ath9k/main.c +1 -1
index 8b4ac7f0a09b..7c2ba21fd972 100644
@@ -265,7 +265,7 @@ static bool ath_complete_reset(struct ath_softc *sc, bool start)
 		}
 	work:
 		ath_restart_work(sc);
-		ath_txq_schedule_all(sc);
+		ath_txq_schedule(sc);
 	}
 
 	sc->gtt_cnt = 0;
drivers/net/wireless/ath/ath9k/xmit.c +48 -161

372 lines not on this page · raw message

include/net/mac80211.h +30 -5
index cc9073e45be9..f0373dd3d714 100644
@@ -105,9 +105,12 @@
  * The driver is expected to initialize its private per-queue data for stations
  * and interfaces in the .add_interface and .sta_add ops.
  *
- * The driver can't access the queue directly. To dequeue a frame, it calls
- * ieee80211_tx_dequeue(). Whenever mac80211 adds a new frame to a queue, it
- * calls the .wake_tx_queue driver op.
+ * The driver can't access the queue directly. To obtain the next queue to pull
+ * frames from, the driver calls ieee80211_next_txq(). To dequeue a frame from a
+ * txq, it calls ieee80211_tx_dequeue(). Whenever mac80211 adds a new frame to a
+ * queue, it calls the .wake_tx_queue driver op. The driver is expected to
+ * re-schedule the txq using ieee80211_schedule_txq() if it is still active
+ * after the driver has finished pulling packets from it.
  *
  * For AP powersave TIM handling, the driver only needs to indicate if it has
  * buffered packets in the driver specific data structures by calling
@@ -3723,8 +3726,7 @@ struct ieee80211_ops {
 					 struct ieee80211_vif *vif,
 					 struct ieee80211_tdls_ch_sw_params *params);
 
-	void (*wake_tx_queue)(struct ieee80211_hw *hw,
-			      struct ieee80211_txq *txq);
+	void (*wake_tx_queue)(struct ieee80211_hw *hw);
 	void (*sync_rx_queues)(struct ieee80211_hw *hw);
 
 	int (*start_nan)(struct ieee80211_hw *hw,
@@ -5876,6 +5878,29 @@ void ieee80211_unreserve_tid(struct ieee80211_sta *sta, u8 tid);
 struct sk_buff *ieee80211_tx_dequeue(struct ieee80211_hw *hw,
 				     struct ieee80211_txq *txq);
 
+/**
+ * ieee80211_schedule_txq - add txq to scheduling loop
+ *
+ * @hw: pointer as obtained from ieee80211_alloc_hw()
+ * @txq: pointer obtained from station or virtual interface
+ *
+ * Returns true if the txq was actually added to the scheduling,
+ * false otherwise.
+ */
+bool ieee80211_schedule_txq(struct ieee80211_hw *hw,
+			    struct ieee80211_txq *txq);
+
+/**
+ * ieee80211_next_txq - get next tx queue to pull packets from
+ *
+ * @hw: pointer as obtained from ieee80211_alloc_hw()
+ *
+ * Returns the next txq if successful, %NULL if no queue is eligible. If a txq
+ * is returned, it will have been removed from the scheduler queue and needs to
+ * be re-scheduled with ieee80211_schedule_txq() to continue to be active.
+ */
+struct ieee80211_txq *ieee80211_next_txq(struct ieee80211_hw *hw);
+
 /**
  * ieee80211_txq_get_depth - get pending frame/byte count of given txq
  *
net/mac80211/agg-tx.c +5 -1
index bef516ec47f9..569b5b5c6d70 100644
@@ -226,9 +226,13 @@ ieee80211_agg_start_txq(struct sta_info *sta, int tid, bool enable)
 		clear_bit(IEEE80211_TXQ_AMPDU, &txqi->flags);
 
 	clear_bit(IEEE80211_TXQ_STOP, &txqi->flags);
+
+	if (!ieee80211_schedule_txq(&sta->sdata->local->hw, txq))
+		return;
+
 	local_bh_disable();
 	rcu_read_lock();
-	drv_wake_tx_queue(sta->sdata->local, txqi);
+	drv_wake_tx_queue(sta->sdata->local);
 	rcu_read_unlock();
 	local_bh_enable();
 }
net/mac80211/driver-ops.h +3 -9
index 09f77e4a8a79..e20a9e2acd53 100644
@@ -1157,16 +1157,10 @@ drv_tdls_recv_channel_switch(struct ieee80211_local *local,
 	trace_drv_return_void(local);
 }
 
-static inline void drv_wake_tx_queue(struct ieee80211_local *local,
-				     struct txq_info *txq)
+static inline void drv_wake_tx_queue(struct ieee80211_local *local)
 {
-	struct ieee80211_sub_if_data *sdata = vif_to_sdata(txq->txq.vif);
-
-	if (!check_sdata_in_driver(sdata))
-		return;
-
-	trace_drv_wake_tx_queue(local, sdata, txq);
-	local->ops->wake_tx_queue(&local->hw, &txq->txq);
+	trace_drv_wake_tx_queue(local);
+	local->ops->wake_tx_queue(&local->hw);
 }
 
 static inline int drv_start_nan(struct ieee80211_local *local,
net/mac80211/ieee80211_i.h +4 -0
index 9675814f64db..48bf933435a8 100644
@@ -832,6 +832,7 @@ struct txq_info {
 	struct codel_vars def_cvars;
 	struct codel_stats cstats;
 	struct sk_buff_head frags;
+	struct list_head schedule_order;
 	unsigned long flags;
 
 	/* keep last! */
@@ -1121,6 +1122,9 @@ struct ieee80211_local {
 	struct codel_vars *cvars;
 	struct codel_params cparams;
 
+	struct list_head active_txqs;
+	spinlock_t active_txq_lock;
+
 	const struct ieee80211_ops *ops;
 
 	/*
net/mac80211/main.c +3 -0
index 8aa1f5b6a051..9ad0556aa24b 100644
@@ -616,6 +616,9 @@ struct ieee80211_hw *ieee80211_alloc_hw_nm(size_t priv_data_len,
 	spin_lock_init(&local->rx_path_lock);
 	spin_lock_init(&local->queue_stop_reason_lock);
 
+	INIT_LIST_HEAD(&local->active_txqs);
+	spin_lock_init(&local->active_txq_lock);
+
 	INIT_LIST_HEAD(&local->chanctx_list);
 	mutex_init(&local->chanctx_mtx);
 
net/mac80211/sta_info.c +4 -1
index 9673e157bf8f..5db76db6bfc8 100644
@@ -1246,12 +1246,15 @@ void ieee80211_sta_ps_deliver_wakeup(struct sta_info *sta)
 		drv_sta_notify(local, sdata, STA_NOTIFY_AWAKE, &sta->sta);
 
 	if (sta->sta.txq[0]) {
+		bool wake = false;
 		for (i = 0; i < ARRAY_SIZE(sta->sta.txq); i++) {
 			if (!txq_has_queue(sta->sta.txq[i]))
 				continue;
 
-			drv_wake_tx_queue(local, to_txq_info(sta->sta.txq[i]));
+			wake = wake || ieee80211_schedule_txq(&local->hw, sta->sta.txq[i]);
 		}
+		if (wake)
+			drv_wake_tx_queue(local);
 	}
 
 	skb_queue_head_init(&pending);
net/mac80211/trace.h +4 -17
index 3d9ac17af407..531c0e7f2358 100644
@@ -2550,33 +2550,20 @@ TRACE_EVENT(drv_tdls_recv_channel_switch,
 );
 
 TRACE_EVENT(drv_wake_tx_queue,
-	TP_PROTO(struct ieee80211_local *local,
-		 struct ieee80211_sub_if_data *sdata,
-		 struct txq_info *txq),
+	TP_PROTO(struct ieee80211_local *local),
 
-	TP_ARGS(local, sdata, txq),
+	TP_ARGS(local),
 
 	TP_STRUCT__entry(
 		LOCAL_ENTRY
-		VIF_ENTRY
-		STA_ENTRY
-		__field(u8, ac)
-		__field(u8, tid)
 	),
 
 	TP_fast_assign(
-		struct ieee80211_sta *sta = txq->txq.sta;
-
 		LOCAL_ASSIGN;
-		VIF_ASSIGN;
-		STA_ASSIGN;
-		__entry->ac = txq->txq.ac;
-		__entry->tid = txq->txq.tid;
 	),
-
 	TP_printk(
-		LOCAL_PR_FMT  VIF_PR_FMT  STA_PR_FMT " ac:%d tid:%d",
-		LOCAL_PR_ARG, VIF_PR_ARG, STA_PR_ARG, __entry->ac, __entry->tid
+		LOCAL_PR_FMT,
+		LOCAL_PR_ARG
 	)
 );
 
net/mac80211/tx.c +47 -1

72 lines not on this page · raw message

Signature · 1 line
2.14.2
author maintainer
#1 lore raw

PATCH 2/2 mac80211: Add airtime accounting and scheduling to TXQs

This adds airtime accounting and scheduling to the mac80211 TXQ scheduler. A new hardware flag, AIRTIME_ACCOUNTING, is added that drivers can set if they support reporting airtime usage of transmissions. When this flag is set, mac80211 will expect the actual airtime usage to be reported in the tx_time and rx_time fields of the respective status structs.

When airtime information is present, mac80211 will schedule TXQs (through ieee80211_next_txq()) in a way that enforces airtime fairness between active stations. This scheduling works the same way as the ath9k in-driver airtime fairness scheduling, which is then removed.

Only ath9k currently sets the AIRTIME_ACCOUNTING flag.

---
Changes since the RFC:

- Don't try to calculate airtime usage in mac80211; instead, add a field to struct ieee80211_rx_status for the driver to fill in.
- Fold ath9k patch into this patch, and remove all the airtime bits from ath9k apart from the actual airtime accounting.
- Feature parity with the ath9k scheduler (in particular, the old/new station optimisation is retained).
- Add explicit hardware flag for the driver to signal that it supports airtime accounting and wants the scheduling.
- This has actually been tested... :)

 drivers/net/wireless/ath/ath9k/ath9k.h     |  7 +---
 drivers/net/wireless/ath/ath9k/debug.h     |  8 -----
 drivers/net/wireless/ath/ath9k/debug_sta.c | 54 ------------------------------
 drivers/net/wireless/ath/ath9k/init.c      |  4 +--
 drivers/net/wireless/ath/ath9k/recv.c      | 11 ++----
 drivers/net/wireless/ath/ath9k/xmit.c      | 21 ++++--------
 include/net/mac80211.h                     |  6 ++++
 net/mac80211/debugfs.c                     |  1 +
 net/mac80211/debugfs_sta.c                 | 29 ++++++++++++++++
 net/mac80211/ieee80211_i.h                 |  6 +++-
 net/mac80211/main.c                        |  3 +-
 net/mac80211/rx.c                          |  9 +++++
 net/mac80211/sta_info.c                    |  2 ++
 net/mac80211/sta_info.h                    |  7 ++++
 net/mac80211/status.c                      | 15 +++++++++
 net/mac80211/tx.c                          | 28 +++++++++++++---
 16 files changed, 112 insertions(+), 99 deletions(-)
drivers/net/wireless/ath/ath9k/ath9k.h +1 -6
index f6c53df78856..f6e8f9b1b984 100644
@@ -112,8 +112,6 @@ int ath_descdma_setup(struct ath_softc *sc, struct ath_descdma *dd,
 #define ATH_TXFIFO_DEPTH           8
 #define ATH_TX_ERROR               0x01
 
-#define ATH_AIRTIME_QUANTUM        300 /* usec */
-
 /* Stop tx traffic 1ms before the GO goes away */
 #define ATH_P2P_PS_STOP_TIME       1000
 
@@ -215,6 +213,7 @@ struct ath_buf_state {
 	bool stale;
 	u16 seqno;
 	unsigned long bfs_paprd_timestamp;
+	u32 airtime;
 };
 
 struct ath_buf {
@@ -262,12 +261,9 @@ struct ath_node {
 
 	bool sleeping;
 	bool no_ps_filter;
-	s64 airtime_deficit[IEEE80211_NUM_ACS];
-	u32 airtime_rx_start;
 
 #ifdef CONFIG_ATH9K_STATION_STATISTICS
 	struct ath_rx_rate_stats rx_rate_stats;
-	struct ath_airtime_stats airtime_stats;
 #endif
 	u8 key_idx[4];
 
@@ -986,7 +982,6 @@ void ath_ant_comb_scan(struct ath_softc *sc, struct ath_rx_status *rs);
 
 #define AIRTIME_USE_TX		BIT(0)
 #define AIRTIME_USE_RX		BIT(1)
-#define AIRTIME_USE_NEW_QUEUES	BIT(2)
 #define AIRTIME_ACTIVE(flags) (!!(flags & (AIRTIME_USE_TX|AIRTIME_USE_RX)))
 
 struct ath_softc {
drivers/net/wireless/ath/ath9k/debug.h +0 -8
index 249f8141cd00..559d9628f280 100644
@@ -319,20 +319,12 @@ ath9k_debug_sync_cause(struct ath_softc *sc, u32 sync_cause)
 void ath_debug_rate_stats(struct ath_softc *sc,
 			  struct ath_rx_status *rs,
 			  struct sk_buff *skb);
-void ath_debug_airtime(struct ath_softc *sc,
-		       struct ath_node *an,
-		       u32 rx, u32 tx);
 #else
 static inline void ath_debug_rate_stats(struct ath_softc *sc,
 					struct ath_rx_status *rs,
 					struct sk_buff *skb)
 {
 }
-static inline void ath_debug_airtime(struct ath_softc *sc,
-			      struct ath_node *an,
-			      u32 rx, u32 tx)
-{
-}
 #endif /* CONFIG_ATH9K_STATION_STATISTICS */
 
 #endif /* DEBUG_H */
drivers/net/wireless/ath/ath9k/debug_sta.c +0 -54

64 lines not on this page · raw message

drivers/net/wireless/ath/ath9k/init.c +2 -2
index bb7936090b91..b4c6fc49b19e 100644
@@ -620,8 +620,7 @@ static int ath9k_init_softc(u16 devid, struct ath_softc *sc,
 
 	/* Will be cleared in ath9k_start() */
 	set_bit(ATH_OP_INVALID, &common->op_flags);
-	sc->airtime_flags = (AIRTIME_USE_TX | AIRTIME_USE_RX |
-			     AIRTIME_USE_NEW_QUEUES);
+	sc->airtime_flags = (AIRTIME_USE_TX | AIRTIME_USE_RX);
 
 	sc->sc_ah = ah;
 	sc->dfs_detector = dfs_pattern_detector_init(common, NL80211_DFS_UNSET);
@@ -873,6 +872,7 @@ static void ath9k_set_hw_capab(struct ath_softc *sc, struct ieee80211_hw *hw)
 	ieee80211_hw_set(hw, HOST_BROADCAST_PS_BUFFERING);
 	ieee80211_hw_set(hw, SUPPORT_FAST_XMIT);
 	ieee80211_hw_set(hw, SUPPORTS_CLONED_SKBS);
+	ieee80211_hw_set(hw, AIRTIME_ACCOUNTING);
 
 	if (ath9k_ps_enable)
 		ieee80211_hw_set(hw, SUPPORTS_PS);
drivers/net/wireless/ath/ath9k/recv.c +3 -8
index 2197aee2bb72..e77e5c839abc 100644
@@ -1054,14 +1054,9 @@ static void ath_rx_count_airtime(struct ath_softc *sc,
 						len, rxs->rate_idx, is_sp);
 	}
 
- 	if (!!(sc->airtime_flags & AIRTIME_USE_RX)) {
-		spin_lock_bh(&acq->lock);
-		an->airtime_deficit[acno] -= airtime;
-		if (an->airtime_deficit[acno] <= 0)
-			__ath_tx_queue_tid(sc, ATH_AN_2_TID(an, tidno));
-		spin_unlock_bh(&acq->lock);
-	}
-	ath_debug_airtime(sc, an, airtime, 0);
+ 	if (sc->airtime_flags & AIRTIME_USE_RX)
+		rxs->rx_time = min_t(u32, 0xffff, airtime);
+
 exit:
 	rcu_read_unlock();
 }
drivers/net/wireless/ath/ath9k/xmit.c +6 -15
index 4256701500ff..86b1d21b237e 100644
@@ -638,11 +638,9 @@ static bool bf_is_ampdu_not_probing(struct ath_buf *bf)
     return bf_isampdu(bf) && !(info->flags & IEEE80211_TX_CTL_RATE_CTRL_PROBE);
 }
 
-static void ath_tx_count_airtime(struct ath_softc *sc, struct ath_node *an,
-				 struct ath_atx_tid *tid, struct ath_buf *bf,
+static void ath_tx_count_airtime(struct ath_softc *sc, struct ath_buf *bf,
 				 struct ath_tx_status *ts)
 {
-	struct ath_txq *txq = tid->txq;
 	u32 airtime = 0;
 	int i;
 
@@ -652,15 +650,9 @@ static void ath_tx_count_airtime(struct ath_softc *sc, struct ath_node *an,
 		airtime += rate_dur * bf->rates[i].count;
 	}
 
-	if (sc->airtime_flags & AIRTIME_USE_TX) {
-		int q = txq->mac80211_qnum;
-		struct ath_acq *acq = &sc->cur_chan->acq[q];
+	if (sc->airtime_flags & AIRTIME_USE_TX)
+		bf->bf_state.airtime = airtime;
 
-		spin_lock_bh(&acq->lock);
-		an->airtime_deficit[q] -= airtime;
-		spin_unlock_bh(&acq->lock);
-	}
-	ath_debug_airtime(sc, an, 0, airtime);
 }
 
 static void ath_tx_process_buffer(struct ath_softc *sc, struct ath_txq *txq,
@@ -690,7 +682,7 @@ static void ath_tx_process_buffer(struct ath_softc *sc, struct ath_txq *txq,
 	if (sta) {
 		struct ath_node *an = (struct ath_node *)sta->drv_priv;
 		tid = ath_get_skb_tid(sc, an, bf->bf_mpdu);
-		ath_tx_count_airtime(sc, an, tid, bf, ts);
+		ath_tx_count_airtime(sc, bf, ts);
 		if (ts->ts_status & (ATH9K_TXERR_FILT | ATH9K_TXERR_XRETRY))
 			tid->clear_ps_filter = true;
 	}
@@ -2425,6 +2417,8 @@ static void ath_tx_complete_buf(struct ath_softc *sc, struct ath_buf *bf,
 	if (ts->ts_status & ATH9K_TXERR_FILT)
 		tx_info->flags |= IEEE80211_TX_STAT_TX_FILTERED;
 
+	tx_info->status.tx_time = min_t(u32, 0xffff, bf->bf_state.airtime);
+
 	dma_unmap_single(sc->dev, bf->bf_buf_addr, skb->len, DMA_TO_DEVICE);
 	bf->bf_buf_addr = 0;
 	if (sc->tx99_state)
@@ -2751,9 +2745,6 @@ void ath_tx_node_init(struct ath_softc *sc, struct ath_node *an)
 	struct ath_atx_tid *tid;
 	int tidno, acno;
 
-	for (acno = 0; acno < IEEE80211_NUM_ACS; acno++)
-		an->airtime_deficit[acno] = ATH_AIRTIME_QUANTUM;
-
 	for (tidno = 0; tidno < IEEE80211_NUM_TIDS; tidno++) {
 		tid = ath_node_to_tid(an, tidno);
 		tid->an        = an;
include/net/mac80211.h +6 -0
index f0373dd3d714..2bedd361511b 100644
@@ -1202,6 +1202,7 @@ struct ieee80211_rx_status {
 	u32 device_timestamp;
 	u32 ampdu_reference;
 	u32 flag;
+	u16 rx_time;
 	u16 freq;
 	u8 enc_flags;
 	u8 encoding:2, bw:3;
@@ -2059,6 +2060,10 @@ struct ieee80211_txq {
  *	The stack will not do fragmentation.
  *	The callback for @set_frag_threshold should be set as well.
  *
+ * @IEEE80211_HW_AIRTIME_ACCOUNTING: Hardware supports accounting the airtime
+ *      usage of other stations and reports it in the @tx_time and/or @rx_time
+ *      fields of the TX/RX status structs.
+ *
  * @NUM_IEEE80211_HW_FLAGS: number of hardware flags, used for sizing arrays
  */
 enum ieee80211_hw_flags {
@@ -2101,6 +2106,7 @@ enum ieee80211_hw_flags {
 	IEEE80211_HW_TX_FRAG_LIST,
 	IEEE80211_HW_REPORTS_LOW_ACK,
 	IEEE80211_HW_SUPPORTS_TX_FRAG,
+	IEEE80211_HW_AIRTIME_ACCOUNTING,
 
 	/* keep last, obviously */
 	NUM_IEEE80211_HW_FLAGS
net/mac80211/debugfs.c +1 -0
index 5fae001f286c..20e3aa0e8464 100644
@@ -211,6 +211,7 @@ static const char *hw_flag_names[] = {
 	FLAG(TX_FRAG_LIST),
 	FLAG(REPORTS_LOW_ACK),
 	FLAG(SUPPORTS_TX_FRAG),
+	FLAG(AIRTIME_ACCOUNTING),
 #undef FLAG
 };
 
net/mac80211/debugfs_sta.c +29 -0
index b15412c21ac9..57bc6b544f0e 100644
@@ -188,6 +188,32 @@ static ssize_t sta_aqm_read(struct file *file, char __user *userbuf,
 }
 STA_OPS(aqm);
 
+static ssize_t sta_airtime_read(struct file *file, char __user *userbuf,
+				size_t count, loff_t *ppos)
+{
+	struct sta_info *sta = file->private_data;
+	size_t bufsz = 200;
+	char *buf = kzalloc(bufsz, GFP_KERNEL), *p = buf;
+	ssize_t rv;
+
+	if (!buf)
+		return -ENOMEM;
+
+	spin_lock_bh(&sta->lock);
+
+	p += scnprintf(p, bufsz+buf-p,
+		"RX: %llu us\nTX: %llu us\nDeficit: %lld us\n",
+		sta->airtime_stats.rx_airtime,
+		sta->airtime_stats.tx_airtime,
+		sta->airtime_deficit);
+
+	spin_unlock_bh(&sta->lock);
+	rv = simple_read_from_buffer(userbuf, count, ppos, buf, p - buf);
+	kfree(buf);
+	return rv;
+}
+STA_OPS(airtime);
+
 static ssize_t sta_agg_status_read(struct file *file, char __user *userbuf,
 					size_t count, loff_t *ppos)
 {
@@ -542,6 +568,9 @@ void ieee80211_sta_debugfs_add(struct sta_info *sta)
 	if (local->ops->wake_tx_queue)
 		DEBUGFS_ADD(aqm);
 
+	if (ieee80211_hw_check(&local->hw, AIRTIME_ACCOUNTING))
+		DEBUGFS_ADD(airtime);
+
 	if (sizeof(sta->driver_buffered_tids) == sizeof(u32))
 		debugfs_create_x32("driver_buffered_tids", 0400,
 				   sta->debugfs_dir,
net/mac80211/ieee80211_i.h +5 -1
index 48bf933435a8..7f6fe5285813 100644
@@ -90,6 +90,9 @@ extern const u8 ieee80211_ac_to_qos_mask[IEEE80211_NUM_ACS];
 
 #define IEEE80211_MAX_NAN_INSTANCE_ID 255
 
+/* How much to increase airtime deficit on each scheduling round */
+#define IEEE80211_AIRTIME_QUANTUM        1000 /* usec */
+
 struct ieee80211_fragment_entry {
 	struct sk_buff_head skb_list;
 	unsigned long first_frag_time;
@@ -1122,7 +1125,8 @@ struct ieee80211_local {
 	struct codel_vars *cvars;
 	struct codel_params cparams;
 
-	struct list_head active_txqs;
+	struct list_head active_txqs_new;
+	struct list_head active_txqs_old;
 	spinlock_t active_txq_lock;
 
 	const struct ieee80211_ops *ops;
net/mac80211/main.c +2 -1
index 9ad0556aa24b..acf73c398d9b 100644
@@ -616,7 +616,8 @@ struct ieee80211_hw *ieee80211_alloc_hw_nm(size_t priv_data_len,
 	spin_lock_init(&local->rx_path_lock);
 	spin_lock_init(&local->queue_stop_reason_lock);
 
-	INIT_LIST_HEAD(&local->active_txqs);
+	INIT_LIST_HEAD(&local->active_txqs_new);
+	INIT_LIST_HEAD(&local->active_txqs_old);
 	spin_lock_init(&local->active_txq_lock);
 
 	INIT_LIST_HEAD(&local->chanctx_list);
net/mac80211/rx.c +9 -0
index 70e9d2ca8bbe..14cc1a5902a7 100644
@@ -1637,6 +1637,15 @@ ieee80211_rx_h_sta_process(struct ieee80211_rx_data *rx)
 	if (ieee80211_vif_is_mesh(&rx->sdata->vif))
 		ieee80211_mps_rx_h_sta_process(sta, hdr);
 
+	/* airtime accounting */
+	if (ieee80211_hw_check(&sta->local->hw, AIRTIME_ACCOUNTING) &&
+	    status->rx_time) {
+		spin_lock_bh(&sta->lock);
+		sta->airtime_stats.rx_airtime += status->rx_time;
+		sta->airtime_deficit -= status->rx_time;
+		spin_unlock_bh(&sta->lock);
+	}
+
 	/*
 	 * Drop (qos-)data::nullfunc frames silently, since they
 	 * are used only to control station power saving mode.
net/mac80211/sta_info.c +2 -0
index 5db76db6bfc8..51fe010af20e 100644
@@ -433,6 +433,8 @@ struct sta_info *sta_info_alloc(struct ieee80211_sub_if_data *sdata,
 	sta->cparams.interval = MS2TIME(100);
 	sta->cparams.ecn = true;
 
+	sta->airtime_deficit = IEEE80211_AIRTIME_QUANTUM;
+
 	sta_dbg(sdata, "Allocated STA %pM\n", sta->sta.addr);
 
 	return sta;
net/mac80211/sta_info.h +7 -0
index 5c54acd10562..5d1802f22550 100644
@@ -550,6 +550,13 @@ struct sta_info {
 	} tx_stats;
 	u16 tid_seq[IEEE80211_QOS_CTL_TID_MASK + 1];
 
+	/* Airtime stats and deficit, protected by lock */
+	struct {
+		u64 rx_airtime;
+		u64 tx_airtime;
+	} airtime_stats;
+	s64 airtime_deficit;
+
 	/*
 	 * Aggregation information, locked with lock.
 	 */
net/mac80211/status.c +15 -0
index da7427a41529..2f1111532be0 100644
@@ -823,6 +823,13 @@ static void __ieee80211_tx_status(struct ieee80211_hw *hw,
 				ieee80211_lost_packet(sta, info);
 			}
 		}
+
+		if (info->status.tx_time) {
+			spin_lock_bh(&sta->lock);
+			sta->airtime_stats.tx_airtime += info->status.tx_time;
+			sta->airtime_deficit -= info->status.tx_time;
+			spin_unlock_bh(&sta->lock);
+		}
 	}
 
 	/* SNMP counters
@@ -947,6 +954,14 @@ void ieee80211_tx_status_ext(struct ieee80211_hw *hw,
 			sta->status_stats.retry_failed++;
 		sta->status_stats.retry_count += retry_count;
 
+		if (ieee80211_hw_check(&local->hw, AIRTIME_ACCOUNTING) &&
+		    info->status.tx_time) {
+			spin_lock_bh(&sta->lock);
+			sta->airtime_stats.tx_airtime += info->status.tx_time;
+			sta->airtime_deficit -= info->status.tx_time;
+			spin_unlock_bh(&sta->lock);
+		}
+
 		if (acked) {
 			sta->status_stats.last_ack = jiffies;
 
net/mac80211/tx.c +24 -4
index 0ee6ea71d1c4..937d48a1ba7a 100644
@@ -3530,7 +3530,7 @@ bool ieee80211_schedule_txq(struct ieee80211_hw *hw,
 	spin_lock_bh(&local->active_txq_lock);
 
 	if (list_empty(&txqi->schedule_order)) {
-		list_add_tail(&txqi->schedule_order, &local->active_txqs);
+		list_add_tail(&txqi->schedule_order, &local->active_txqs_new);
 		ret = 1;
 	}
 
@@ -3544,13 +3544,33 @@ struct ieee80211_txq *ieee80211_next_txq(struct ieee80211_hw *hw)
 {
 	struct ieee80211_local *local = hw_to_local(hw);
 	struct txq_info *txqi = NULL;
+	struct list_head *head;
 
 	spin_lock_bh(&local->active_txq_lock);
 
-	if (list_empty(&local->active_txqs))
-		goto out;
+begin:
+	head = &local->active_txqs_new;
+	if (list_empty(head)) {
+		head = &local->active_txqs_old;
+		if (list_empty(head))
+			goto out;
+	}
+
+	txqi = list_first_entry(head, struct txq_info, schedule_order);
+
+	if (txqi->txq.sta) {
+		struct sta_info *sta = container_of(txqi->txq.sta, struct sta_info, sta);
+
+		spin_lock_bh(&sta->lock);
+		if (sta->airtime_deficit < 0) {
+			sta->airtime_deficit += IEEE80211_AIRTIME_QUANTUM;
+			list_move_tail(&txqi->schedule_order, &local->active_txqs_old);
+			spin_unlock_bh(&sta->lock);
+			goto begin;
+		}
+		spin_unlock_bh(&sta->lock);
+	}
 
-	txqi = list_first_entry(&local->active_txqs, struct txq_info, schedule_order);
 	list_del_init(&txqi->schedule_order);
 
 out:
Signature · 1 line
2.14.2
maintainer
#2 lore raw

Re: [PATCH 2/2] mac80211: Add airtime accounting and scheduling to TXQs

Quoted 2 lines

Only ath9k currently sets the AIRTIME_ACCOUNTING flag.

I think you should actually make that a separate patch.

In the previous patch that's not possible or it breaks things, but this patch just adds a new feature that drivers _may_ use, they don't have to since it doesn't change the API, so you should split the patches.

[snip ath9k, I don't really know anything about it]

include/net/mac80211.h struct ieee80211_rx_status { · line 1205

Quoted 7 lines
include/net/mac80211.h +1 -0
@@ -1202,6 +1202,7 @@ struct ieee80211_rx_status {
 	u32 device_timestamp;
 	u32 ampdu_reference;
 	u32 flag;
+	u16 rx_time;

I'd prefer this were called "airtime" or such, and you clearly need to add documentation regarding this field. In particular, you should point to the IEEE80211_HW_AIRTIME_ACCOUNTING hw flag, and document what should be taken into account here (preamble length, IFS, rts/cts/ack, etc.?) and additionally how this should be handled wrt. A-MPDU (and A- MSDU where decapsulated by the device.)

For aggregation, either form, I expect you just want to see 0 for all but the very first frame? but that may be very difficult for some drivers to implement.

Quoted 9 lines
include/net/mac80211.h +3 -0
+++ b/net/mac80211/rx.c
@@ -1637,6 +1637,15 @@ ieee80211_rx_h_sta_process(struct
 ieee80211_rx_data *rx)
 	if (ieee80211_vif_is_mesh(&rx->sdata->vif))
 		ieee80211_mps_rx_h_sta_process(sta, hdr);
 
+	/* airtime accounting */
+	if (ieee80211_hw_check(&sta->local->hw, AIRTIME_ACCOUNTING)

&&

Is there much point in this check? I think we can assume drivers are well-behaved and just leave the field at 0 if they don't support it?

include/net/mac80211.h

Quoted 6 lines
include/net/mac80211.h +6 -0
+	    status->rx_time) {
+		spin_lock_bh(&sta->lock);
+		sta->airtime_stats.rx_airtime += status->rx_time;
+		sta->airtime_deficit -= status->rx_time;
+		spin_unlock_bh(&sta->lock);
+	}

I can't say I'm a big fan of the locking here, we have multi-queue RX where we spread the load across multiple CPUs, and this will lead to massive cache-line bouncing. Maybe we can make it per-CPU or something?

This gets tricky though, so perhaps we can defer that to a separate patch to make it multi-queue aware.

Perhaps for such drivers it'd be better anyway to report the used RX airtime per station *separately*, as part of some kind of statistics API, rather than inline through RX - there's no need for the inline reporting after all as long as the values are updated frequently enough.

Quoted 4 lines

+++ b/net/mac80211/status.c

include/net/mac80211.h +0 -0
@@ -823,6 +823,13 @@ static void __ieee80211_tx_status(struct
 ieee80211_hw *hw,
 				ieee80211_lost_packet(sta, info);

include/net/mac80211.h static void __ieee80211_tx_status(struct · line 834

Quoted 10 lines
include/net/mac80211.h +7 -0
 			}
 		}
+
+		if (info->status.tx_time) {
+			spin_lock_bh(&sta->lock);
+			sta->airtime_stats.tx_airtime += info->status.tx_time;
+			sta->airtime_deficit -= info->status.tx_time;
+			spin_unlock_bh(&sta->lock);
+		}
 	}

Those lines also seem pretty long, and the concerns from above apply.

Here you also don't have the hw_check,

include/net/mac80211.h void ieee80211_tx_status_ext(struct ieee80211_hw · line 958

Quoted 7 lines
include/net/mac80211.h +1 -0
 	/* SNMP counters
@@ -947,6 +954,14 @@ void ieee80211_tx_status_ext(struct ieee80211_hw
 *hw,
 			sta->status_stats.retry_failed++;
 		sta->status_stats.retry_count += retry_count;
 
+		if (ieee80211_hw_check(&local->hw, AIRTIME_ACCOUNTING) &&

but here you do?

tx_time already existed anyway though, for other purposes, so you probably need the check (or do useless work if the driver uses tx_time for WMM-AC but not for airtime accounting).

include/net/mac80211.h void ieee80211_tx_status_ext(struct ieee80211_hw

Quoted 5 lines
include/net/mac80211.h +1 -1
 	if (list_empty(&txqi->schedule_order)) {
-		list_add_tail(&txqi->schedule_order, &local->active_txqs);
+		list_add_tail(&txqi->schedule_order, &local->active_txqs_new);
 		ret = 1;
 	}

lines seem long?

Quoted 13 lines
include/net/mac80211.h +1 -0
+	txqi = list_first_entry(head, struct txq_info,

schedule_order);

include/net/mac80211.h +3 -0
+
+	if (txqi->txq.sta) {
+		struct sta_info *sta = container_of(txqi->txq.sta,

struct sta_info, sta);

include/net/mac80211.h +4 -0
+
+		spin_lock_bh(&sta->lock);
+		if (sta->airtime_deficit < 0) {
+			sta->airtime_deficit +=

IEEE80211_AIRTIME_QUANTUM;

include/net/mac80211.h +1 -0
+			list_move_tail(&txqi->schedule_order,

&local->active_txqs_old);

include/net/mac80211.h

Quoted 5 lines
include/net/mac80211.h +5 -0
+			spin_unlock_bh(&sta->lock);
+			goto begin;
+		}
+		spin_unlock_bh(&sta->lock);
+	}

ditto here.

johannes

author maintainer
#3 lore raw

Re: [PATCH 2/2] mac80211: Add airtime accounting and scheduling to TXQs

Quoted 8 lines · Johannes Berg
Quoted 1 line

Only ath9k currently sets the AIRTIME_ACCOUNTING flag.

I think you should actually make that a separate patch.

In the previous patch that's not possible or it breaks things, but this patch just adds a new feature that drivers _may_ use, they don't have to since it doesn't change the API, so you should split the patches.

Yeah, I did that initially. The reason I ended up squashing them is that this patch moved the per-station 'airtime' debugfs-entry that was previously created by ath9k into mac80211. I assumed it would create problems if both the driver and mac80211 tried to create the same file; not sure how to handle that if it's split into two patches?

Quoted 11 lines

[snip ath9k, I don't really know anything about it]

include/net/mac80211.h struct ieee80211_rx_status { · line 1205

Quoted 7 lines
include/net/mac80211.h +1 -0
@@ -1202,6 +1202,7 @@ struct ieee80211_rx_status {
 	u32 device_timestamp;
 	u32 ampdu_reference;
 	u32 flag;
+	u16 rx_time;

I'd prefer this were called "airtime" or such,

Right. I picked rx_time for symmetry with the tx side; should I rename that as well, then, or is asymmetry fine?

Quoted 5 lines

and you clearly need to add documentation regarding this field. In particular, you should point to the IEEE80211_HW_AIRTIME_ACCOUNTING hw flag, and document what should be taken into account here (preamble length, IFS, rts/cts/ack, etc.?) and additionally how this should be handled wrt. A-MPDU (and A- MSDU where decapsulated by the device.)

Ah yes, of course; will add some documentation.

Quoted 3 lines

For aggregation, either form, I expect you just want to see 0 for all but the very first frame? but that may be very difficult for some drivers to implement.

Well yeah, either report the airtime of the whole aggregate on the first frame and zero on the rest, or report the aggregate overhead on the first frame and the data+padding time on each frame. Depends on the information the driver has handy / can calculate, I guess.

Quoted 6 lines
Quoted 6 lines
include/net/mac80211.h +1 -0
+++ b/net/mac80211/rx.c
@@ -1637,6 +1637,15 @@ ieee80211_rx_h_sta_process(struct
 ieee80211_rx_data *rx)
 	if (ieee80211_vif_is_mesh(&rx->sdata->vif))
 		ieee80211_mps_rx_h_sta_process(sta, hdr);
 
Quoted 6 lines
Quoted 3 lines
include/net/mac80211.h +2 -0
+	/* airtime accounting */
+	if (ieee80211_hw_check(&sta->local->hw, AIRTIME_ACCOUNTING)

&&

Is there much point in this check? I think we can assume drivers are well-behaved and just leave the field at 0 if they don't support it?

I guess it could be omitted for the RX side, yeah. I added the flag because the tx_time field overlaps with other fields in the tx_info struct and so can be non-zero even if the driver doesn't add airtime information (but seems I botched the TX side check as you noted below).

Quoted 11 lines

include/net/mac80211.h

Quoted 6 lines
include/net/mac80211.h +6 -0
+	    status->rx_time) {
+		spin_lock_bh(&sta->lock);
+		sta->airtime_stats.rx_airtime += status->rx_time;
+		sta->airtime_deficit -= status->rx_time;
+		spin_unlock_bh(&sta->lock);
+	}

I can't say I'm a big fan of the locking here, we have multi-queue RX where we spread the load across multiple CPUs, and this will lead to massive cache-line bouncing. Maybe we can make it per-CPU or something?

A per-CPU counter on RX and a separate task that sums those into the global counter, perhaps?

Quoted 2 lines

This gets tricky though, so perhaps we can defer that to a separate patch to make it multi-queue aware.

ACK. I also don't have any hardware to test this, so would probably be good to leave that as a separate entry once we're convinced that the rest is correct.

Quoted 5 lines

Perhaps for such drivers it'd be better anyway to report the used RX airtime per station *separately*, as part of some kind of statistics API, rather than inline through RX - there's no need for the inline reporting after all as long as the values are updated frequently enough.

Ah yes, that would be an option as well.

Quoted 17 lines
Quoted 4 lines

+++ b/net/mac80211/status.c

include/net/mac80211.h +0 -0
@@ -823,6 +823,13 @@ static void __ieee80211_tx_status(struct
 ieee80211_hw *hw,
 				ieee80211_lost_packet(sta, info);

include/net/mac80211.h static void __ieee80211_tx_status(struct · line 834

Quoted 10 lines
include/net/mac80211.h +7 -0
 			}
 		}
+
+		if (info->status.tx_time) {
+			spin_lock_bh(&sta->lock);
+			sta->airtime_stats.tx_airtime += info->status.tx_time;
+			sta->airtime_deficit -= info->status.tx_time;
+			spin_unlock_bh(&sta->lock);
+		}
 	}

Those lines also seem pretty long, and the concerns from above apply.

Quoted 1 line

Here you also don't have the hw_check,

Yeah, oops. :)

[snip]

Will fix the rest of your comments and resend. Thanks!

-Toke

maintainer
#4 lore raw

Re: [PATCH 2/2] mac80211: Add airtime accounting and scheduling to TXQs

Quoted 7 lines · Toke Høiland-Jørgensen

Yeah, I did that initially. The reason I ended up squashing them is that
this patch moved the per-station 'airtime' debugfs-entry that was previously created by ath9k into mac80211. I assumed it would create problems if both the driver and mac80211 tried to create the same file;
not sure how to handle that if it's split into two patches?

That might indeed be problematic, so perhaps just use a different name? Then again, if adding the entry fails in ath9k, nothing will happen since it doesn't even check the return value - so I think it doesn't actually matter.

Quoted 4 lines
Quoted 1 line

I'd prefer this were called "airtime" or such,

Right. I picked rx_time for symmetry with the tx side; should I rename that as well, then, or is asymmetry fine?

Let's not change the tx side in this patch, but we can clean it up later I guess.

johannes

author maintainer
#5 lore raw

Re: [PATCH 2/2] mac80211: Add airtime accounting and scheduling to TXQs

Quoted 10 lines · Johannes Berg
Quoted 7 lines · On Tue, 2017-10-17 at 09:34 +0200, Toke H=C3=B8iland-J=C3=B8rgensen wrote:

Yeah, I did that initially. The reason I ended up squashing them is that
this patch moved the per-station 'airtime' debugfs-entry that was previously created by ath9k into mac80211. I assumed it would create problems if both the driver and mac80211 tried to create the same file;
not sure how to handle that if it's split into two patches?

Quoted 2 lines

That might indeed be problematic, so perhaps just use a different name?

Well I would like to keep compatibility with my tooling that reads the values :)

Quoted 3 lines

Then again, if adding the entry fails in ath9k, nothing will happen since it doesn't even check the return value - so I think it doesn't actually matter.

Right, I'll try that, and otherwise create a separate patch to ath9k that removes the debugfs entry before applying the mac80211 patch.

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

I'd prefer this were called "airtime" or such,

=20
Right. I picked rx_time for symmetry with the tx side; should I rename that as well, then, or is asymmetry fine?

Let's not change the tx side in this patch, but we can clean it up later I guess.

ACK.

-Toke

maintainer
#6 lore raw
In reply to Toke Høiland-Jørgensen

drivers/net/wireless/ath/ath10k/core.h struct ath10k { · line 898

Quoted 7 lines
drivers/net/wireless/ath/ath10k/core.h +0 -3
 	/* protects shared structure data */
 	spinlock_t data_lock;
-	/* protects: ar->txqs, artxq->list */
-	spinlock_t txqs_lock;
 
-	struct list_head txqs;

I don't see you removing the artxq->list member, but surely it can't be used any more now, without a list?

[snip] that's about all I can comment on ath*k :)

Quoted 5 lines

+/**
+ * ieee80211_schedule_txq - add txq to scheduling loop
+ *
+ * @hw: pointer as obtained from ieee80211_alloc_hw()
+ * @txq: pointer obtained from station or virtual interface

or more likely next_txq()? :)

Quoted 2 lines

+ * Returns true if the txq was actually added to the scheduling,
+ * false otherwise.

Perhaps use %true/%false.

net/mac80211/sta_info.c void ieee80211_sta_ps_deliver_wakeup(struct sta_info *sta) · line 1249

Quoted 2 lines
net/mac80211/sta_info.c +1 -0
 	if (sta->sta.txq[0]) {
+		bool wake = false;

please add a blank line after this new line

net/mac80211/sta_info.c void ieee80211_sta_ps_deliver_wakeup(struct sta_info *sta) · line 1258

Quoted 10 lines
net/mac80211/sta_info.c +3 -1
 		for (i = 0; i < ARRAY_SIZE(sta->sta.txq); i++) {
 			if (!txq_has_queue(sta->sta.txq[i]))
 				continue;
 
-			drv_wake_tx_queue(local, to_txq_info(sta->sta.txq[i]));
+			wake = wake || ieee80211_schedule_txq(&local->hw, sta->sta.txq[i]);
 		}
+		if (wake)
+			drv_wake_tx_queue(local);
 	}

Are you sure you want to skip the call to ieee80211_schedule_txq() if wake is true? I think you don't, but boolean short-circuit evaluation would lead to that, afaict?

So it better be written as

  if (ieee80211_schedule_txq(...))
    wake = true;

No need to even check wake anyway, since it can only ever go from false to true.

(Also, that line is getting a bit long)

net/mac80211/trace.h TRACE_EVENT(drv_tdls_recv_channel_switch, · line 2553

Quoted 13 lines
net/mac80211/sta_info.c +0 -0
 	skb_queue_head_init(&pending);
net/mac80211/trace.h +1 -3
index 3d9ac17af407..531c0e7f2358 100644
@@ -2550,33 +2550,20 @@ TRACE_EVENT(drv_tdls_recv_channel_switch,
 );
 
 TRACE_EVENT(drv_wake_tx_queue,
-	TP_PROTO(struct ieee80211_local *local,
-		 struct ieee80211_sub_if_data *sdata,
-		 struct txq_info *txq),
+	TP_PROTO(struct ieee80211_local *local),

You should just replace all of this with

DEFINE_EVENT(local_only_evt, drv_wake_tx_queue,

        TP_PROTO(struct ieee80211_local *local),
        TP_ARGS(local)

);

now.

net/mac80211/trace.h TRACE_EVENT(drv_tdls_recv_channel_switch, · line 2559

Quoted 6 lines
net/mac80211/trace.h +6 -0
+bool ieee80211_schedule_txq(struct ieee80211_hw *hw,
+			     struct ieee80211_txq *txq)
+{
+	struct ieee80211_local *local = hw_to_local(hw);
+	struct txq_info *txqi = to_txq_info(txq);
+	int ret = 0;

bool/false/true please.

net/mac80211/trace.h TRACE_EVENT(drv_tdls_recv_channel_switch,

Quoted 11 lines
net/mac80211/trace.h +11 -0
+struct ieee80211_txq *ieee80211_next_txq(struct ieee80211_hw *hw)
+{
+	struct ieee80211_local *local = hw_to_local(hw);
+	struct txq_info *txqi = NULL;
+
+	spin_lock_bh(&local->active_txq_lock);
+
+	if (list_empty(&local->active_txqs))
+		goto out;
+
+	txqi = list_first_entry(&local->active_txqs, struct txq_info, schedule_order);

that line seems pretty long, but I haven't counted :)

johannes

author maintainer
#7 lore raw

PATCH v2 1/3 mac80211: Add TXQ scheduling API

In reply to Toke Høiland-Jørgensen

This adds an API to mac80211 to handle scheduling of TXQs and changes the interface between driver and mac80211 for TXQ handling as follows:

- The wake_tx_queue callback interface no longer includes the TXQ. Instead, the driver is expected to retrieve that from ieee80211_next_txq()

- Two new mac80211 functions are added: ieee80211_next_txq() and ieee80211_schedule_txq(). The former returns the next TXQ that should be scheduled, and is how the driver gets a queue to pull packets from. The latter is called internally by mac80211 to start scheduling a queue, and the driver is supposed to call it to re-schedule the TXQ after it is finished pulling packets from it (unless the queue emptied).

The ath9k and ath10k drivers are changed to use the new API.

---
Changes since v1:
- Also remove artxq->list member from ath10k
- Don't skip ieee80211_schedule_txq() calls due to boolean short-circuiting
- Some documentation and checkpatch fixes

 drivers/net/wireless/ath/ath10k/core.c |   2 -
 drivers/net/wireless/ath/ath10k/core.h |   4 -
 drivers/net/wireless/ath/ath10k/mac.c  |  55 +++------
 drivers/net/wireless/ath/ath9k/ath9k.h |   6 +-
 drivers/net/wireless/ath/ath9k/main.c  |   2 +-
 drivers/net/wireless/ath/ath9k/xmit.c  | 210 ++++++++-------------------------
 include/net/mac80211.h                 |  37 +++++-
 net/mac80211/agg-tx.c                  |   6 +-
 net/mac80211/driver-ops.h              |  12 +-
 net/mac80211/ieee80211_i.h             |   5 +
 net/mac80211/main.c                    |   3 +
 net/mac80211/sta_info.c                |   7 +-
 net/mac80211/trace.h                   |  32 +----
 net/mac80211/tx.c                      |  49 +++++++-
 14 files changed, 173 insertions(+), 257 deletions(-)
drivers/net/wireless/ath/ath10k/core.c +0 -2
index a4f635820f35..759df3297d48 100644
@@ -2561,9 +2561,7 @@ struct ath10k *ath10k_core_create(size_t priv_size, struct device *dev,
 
 	mutex_init(&ar->conf_mutex);
 	spin_lock_init(&ar->data_lock);
-	spin_lock_init(&ar->txqs_lock);
 
-	INIT_LIST_HEAD(&ar->txqs);
 	INIT_LIST_HEAD(&ar->peers);
 	init_waitqueue_head(&ar->peer_mapping_wq);
 	init_waitqueue_head(&ar->htt.empty_tx_wq);
drivers/net/wireless/ath/ath10k/core.h +0 -4
index 949ebb3e967b..3c3b158cdb20 100644
@@ -347,7 +347,6 @@ struct ath10k_peer {
 };
 
 struct ath10k_txq {
-	struct list_head list;
 	unsigned long num_fw_queued;
 	unsigned long num_push_allowed;
 };
@@ -892,10 +891,7 @@ struct ath10k {
 
 	/* protects shared structure data */
 	spinlock_t data_lock;
-	/* protects: ar->txqs, artxq->list */
-	spinlock_t txqs_lock;
 
-	struct list_head txqs;
 	struct list_head arvifs;
 	struct list_head peers;
 	struct ath10k_peer *peer_map[ATH10K_MAX_NUM_PEER_IDS];
drivers/net/wireless/ath/ath10k/mac.c +16 -39

115 lines not on this page · raw message

drivers/net/wireless/ath/ath9k/ath9k.h +2 -4
index cf076719c27e..f6c53df78856 100644
@@ -246,7 +246,6 @@ struct ath_atx_tid {
 	s8 bar_index;
 	bool active;
 	bool clear_ps_filter;
-	bool has_queued;
 };
 
 void __ath_tx_queue_tid(struct ath_softc *sc, struct ath_atx_tid *tid);
@@ -591,8 +590,7 @@ bool ath_drain_all_txq(struct ath_softc *sc);
 void ath_draintxq(struct ath_softc *sc, struct ath_txq *txq);
 void ath_tx_node_init(struct ath_softc *sc, struct ath_node *an);
 void ath_tx_node_cleanup(struct ath_softc *sc, struct ath_node *an);
-void ath_txq_schedule(struct ath_softc *sc, struct ath_txq *txq);
-void ath_txq_schedule_all(struct ath_softc *sc);
+void ath_txq_schedule(struct ath_softc *sc);
 int ath_tx_init(struct ath_softc *sc, int nbufs);
 int ath_txq_update(struct ath_softc *sc, int qnum,
 		   struct ath9k_tx_queue_info *q);
@@ -618,7 +616,7 @@ void ath9k_release_buffered_frames(struct ieee80211_hw *hw,
 				   u16 tids, int nframes,
 				   enum ieee80211_frame_release_type reason,
 				   bool more_data);
-void ath9k_wake_tx_queue(struct ieee80211_hw *hw, struct ieee80211_txq *queue);
+void ath9k_wake_tx_queue(struct ieee80211_hw *hw);
 
 /********/
 /* VIFs */
drivers/net/wireless/ath/ath9k/main.c +1 -1
index 8b4ac7f0a09b..7c2ba21fd972 100644
@@ -265,7 +265,7 @@ static bool ath_complete_reset(struct ath_softc *sc, bool start)
 		}
 	work:
 		ath_restart_work(sc);
-		ath_txq_schedule_all(sc);
+		ath_txq_schedule(sc);
 	}
 
 	sc->gtt_cnt = 0;
drivers/net/wireless/ath/ath9k/xmit.c +50 -160

374 lines not on this page · raw message

include/net/mac80211.h +31 -6
index cc9073e45be9..715f45501aff 100644
@@ -105,9 +105,12 @@
  * The driver is expected to initialize its private per-queue data for stations
  * and interfaces in the .add_interface and .sta_add ops.
  *
- * The driver can't access the queue directly. To dequeue a frame, it calls
- * ieee80211_tx_dequeue(). Whenever mac80211 adds a new frame to a queue, it
- * calls the .wake_tx_queue driver op.
+ * The driver can't access the queue directly. To obtain the next queue to pull
+ * frames from, the driver calls ieee80211_next_txq(). To dequeue a frame from a
+ * txq, it calls ieee80211_tx_dequeue(). Whenever mac80211 adds a new frame to a
+ * queue, it calls the .wake_tx_queue driver op. The driver is expected to
+ * re-schedule the txq using ieee80211_schedule_txq() if it is still active
+ * after the driver has finished pulling packets from it.
  *
  * For AP powersave TIM handling, the driver only needs to indicate if it has
  * buffered packets in the driver specific data structures by calling
@@ -3723,8 +3726,7 @@ struct ieee80211_ops {
 					 struct ieee80211_vif *vif,
 					 struct ieee80211_tdls_ch_sw_params *params);
 
-	void (*wake_tx_queue)(struct ieee80211_hw *hw,
-			      struct ieee80211_txq *txq);
+	void (*wake_tx_queue)(struct ieee80211_hw *hw);
 	void (*sync_rx_queues)(struct ieee80211_hw *hw);
 
 	int (*start_nan)(struct ieee80211_hw *hw,
@@ -5869,13 +5871,36 @@ void ieee80211_unreserve_tid(struct ieee80211_sta *sta, u8 tid);
  * ieee80211_tx_dequeue - dequeue a packet from a software tx queue
  *
  * @hw: pointer as obtained from ieee80211_alloc_hw()
- * @txq: pointer obtained from station or virtual interface
+ * @txq: pointer obtained from ieee80211_next_txq()
  *
  * Returns the skb if successful, %NULL if no frame was available.
  */
 struct sk_buff *ieee80211_tx_dequeue(struct ieee80211_hw *hw,
 				     struct ieee80211_txq *txq);
 
+/**
+ * ieee80211_schedule_txq - add txq to scheduling loop
+ *
+ * @hw: pointer as obtained from ieee80211_alloc_hw()
+ * @txq: pointer obtained from station or virtual interface
+ *
+ * Returns %true if the txq was actually added to the scheduling,
+ * %false otherwise.
+ */
+bool ieee80211_schedule_txq(struct ieee80211_hw *hw,
+			    struct ieee80211_txq *txq);
+
+/**
+ * ieee80211_next_txq - get next tx queue to pull packets from
+ *
+ * @hw: pointer as obtained from ieee80211_alloc_hw()
+ *
+ * Returns the next txq if successful, %NULL if no queue is eligible. If a txq
+ * is returned, it will have been removed from the scheduler queue and needs to
+ * be re-scheduled with ieee80211_schedule_txq() to continue to be active.
+ */
+struct ieee80211_txq *ieee80211_next_txq(struct ieee80211_hw *hw);
+
 /**
  * ieee80211_txq_get_depth - get pending frame/byte count of given txq
  *
net/mac80211/agg-tx.c +5 -1
index bef516ec47f9..569b5b5c6d70 100644
@@ -226,9 +226,13 @@ ieee80211_agg_start_txq(struct sta_info *sta, int tid, bool enable)
 		clear_bit(IEEE80211_TXQ_AMPDU, &txqi->flags);
 
 	clear_bit(IEEE80211_TXQ_STOP, &txqi->flags);
+
+	if (!ieee80211_schedule_txq(&sta->sdata->local->hw, txq))
+		return;
+
 	local_bh_disable();
 	rcu_read_lock();
-	drv_wake_tx_queue(sta->sdata->local, txqi);
+	drv_wake_tx_queue(sta->sdata->local);
 	rcu_read_unlock();
 	local_bh_enable();
 }
net/mac80211/driver-ops.h +3 -9
index 09f77e4a8a79..e20a9e2acd53 100644
@@ -1157,16 +1157,10 @@ drv_tdls_recv_channel_switch(struct ieee80211_local *local,
 	trace_drv_return_void(local);
 }
 
-static inline void drv_wake_tx_queue(struct ieee80211_local *local,
-				     struct txq_info *txq)
+static inline void drv_wake_tx_queue(struct ieee80211_local *local)
 {
-	struct ieee80211_sub_if_data *sdata = vif_to_sdata(txq->txq.vif);
-
-	if (!check_sdata_in_driver(sdata))
-		return;
-
-	trace_drv_wake_tx_queue(local, sdata, txq);
-	local->ops->wake_tx_queue(&local->hw, &txq->txq);
+	trace_drv_wake_tx_queue(local);
+	local->ops->wake_tx_queue(&local->hw);
 }
 
 static inline int drv_start_nan(struct ieee80211_local *local,
net/mac80211/ieee80211_i.h +5 -0
index 9675814f64db..95be548b1d4f 100644
@@ -832,6 +832,7 @@ struct txq_info {
 	struct codel_vars def_cvars;
 	struct codel_stats cstats;
 	struct sk_buff_head frags;
+	struct list_head schedule_order;
 	unsigned long flags;
 
 	/* keep last! */
@@ -1121,6 +1122,10 @@ struct ieee80211_local {
 	struct codel_vars *cvars;
 	struct codel_params cparams;
 
+	/* protects active_txqs and txqi->schedule_order */
+	spinlock_t active_txq_lock;
+	struct list_head active_txqs;
+
 	const struct ieee80211_ops *ops;
 
 	/*
net/mac80211/main.c +3 -0
index 8aa1f5b6a051..9ad0556aa24b 100644
@@ -616,6 +616,9 @@ struct ieee80211_hw *ieee80211_alloc_hw_nm(size_t priv_data_len,
 	spin_lock_init(&local->rx_path_lock);
 	spin_lock_init(&local->queue_stop_reason_lock);
 
+	INIT_LIST_HEAD(&local->active_txqs);
+	spin_lock_init(&local->active_txq_lock);
+
 	INIT_LIST_HEAD(&local->chanctx_list);
 	mutex_init(&local->chanctx_mtx);
 
net/mac80211/sta_info.c +6 -1
index 9673e157bf8f..da3737d4778f 100644
@@ -1246,12 +1246,17 @@ void ieee80211_sta_ps_deliver_wakeup(struct sta_info *sta)
 		drv_sta_notify(local, sdata, STA_NOTIFY_AWAKE, &sta->sta);
 
 	if (sta->sta.txq[0]) {
+		bool wake = false;
+
 		for (i = 0; i < ARRAY_SIZE(sta->sta.txq); i++) {
 			if (!txq_has_queue(sta->sta.txq[i]))
 				continue;
 
-			drv_wake_tx_queue(local, to_txq_info(sta->sta.txq[i]));
+			if (ieee80211_schedule_txq(&local->hw, sta->sta.txq[i]))
+				wake = true;
 		}
+		if (wake)
+			drv_wake_tx_queue(local);
 	}
 
 	skb_queue_head_init(&pending);
net/mac80211/trace.h +3 -29
index 3d9ac17af407..f51eade947ee 100644
@@ -2549,35 +2549,9 @@ TRACE_EVENT(drv_tdls_recv_channel_switch,
 	)
 );
 
-TRACE_EVENT(drv_wake_tx_queue,
-	TP_PROTO(struct ieee80211_local *local,
-		 struct ieee80211_sub_if_data *sdata,
-		 struct txq_info *txq),
-
-	TP_ARGS(local, sdata, txq),
-
-	TP_STRUCT__entry(
-		LOCAL_ENTRY
-		VIF_ENTRY
-		STA_ENTRY
-		__field(u8, ac)
-		__field(u8, tid)
-	),
-
-	TP_fast_assign(
-		struct ieee80211_sta *sta = txq->txq.sta;
-
-		LOCAL_ASSIGN;
-		VIF_ASSIGN;
-		STA_ASSIGN;
-		__entry->ac = txq->txq.ac;
-		__entry->tid = txq->txq.tid;
-	),
-
-	TP_printk(
-		LOCAL_PR_FMT  VIF_PR_FMT  STA_PR_FMT " ac:%d tid:%d",
-		LOCAL_PR_ARG, VIF_PR_ARG, STA_PR_ARG, __entry->ac, __entry->tid
-	)
+DEFINE_EVENT(local_only_evt, drv_wake_tx_queue,
+	     TP_PROTO(struct ieee80211_local *local),
+	     TP_ARGS(local)
 );
 
 #endif /* !__MAC80211_DRIVER_TRACE || TRACE_HEADER_MULTI_READ */
net/mac80211/tx.c +48 -1

73 lines not on this page · raw message

Signature · 1 line
2.14.2
author maintainer
#8 lore raw

PATCH v2 2/3 mac80211: Add airtime account and scheduling to TXQs

This adds airtime accounting and scheduling to the mac80211 TXQ scheduler. A new hardware flag, AIRTIME_ACCOUNTING, is added that drivers can set if they support reporting airtime usage of transmissions. When this flag is set, mac80211 will expect the actual airtime usage to be reported in the tx_time and rx_time fields of the respective status structs.

When airtime information is present, mac80211 will schedule TXQs (through ieee80211_next_txq()) in a way that enforces airtime fairness between active stations. This scheduling works the same way as the ath9k in-driver airtime fairness scheduling.

---
Changes since v1:
- Split ath9k changes into separate patch
- Rename RX status variable to 'airtime', add documentation
- Add documentation on usage to the IEEE80211_HW_AIRTIME_ACCOUNTING hw accounting flag
- Remove HW flag check on RX side, add it where it was missing on TX side
- Fix checkpatch issues

This still implements the basic fairness that is more or less equivalent to the previous implementation in ath9k. I figure any changes to a different mechanism should be made separately anyway, and I don't believe they will require any changes to the driver/mac80211 API.

 include/net/mac80211.h     | 24 ++++++++++++++++++++++++
 net/mac80211/debugfs.c     |  1 +
 net/mac80211/debugfs_sta.c | 29 +++++++++++++++++++++++++++++
 net/mac80211/ieee80211_i.h |  9 +++++++--
 net/mac80211/main.c        |  3 ++-
 net/mac80211/rx.c          |  8 ++++++++
 net/mac80211/sta_info.c    |  2 ++
 net/mac80211/sta_info.h    |  7 +++++++
 net/mac80211/status.c      | 16 ++++++++++++++++
 net/mac80211/tx.c          | 31 ++++++++++++++++++++++++++-----
 10 files changed, 122 insertions(+), 8 deletions(-)
include/net/mac80211.h +24 -0
index 715f45501aff..453653d082af 100644
@@ -1188,6 +1188,8 @@ enum mac80211_rx_encoding {
  *	HT or VHT is used (%RX_FLAG_HT/%RX_FLAG_VHT)
  * @nss: number of streams (VHT and HE only)
  * @flag: %RX_FLAG_\*
+ * @airtime: Duration of frame in usec. See @IEEE80211_HW_AIRTIME_ACCOUNTING for
+ *       how to use this.
  * @encoding: &enum mac80211_rx_encoding
  * @bw: &enum rate_info_bw
  * @enc_flags: uses bits from &enum mac80211_rx_encoding_flags
@@ -1202,6 +1204,7 @@ struct ieee80211_rx_status {
 	u32 device_timestamp;
 	u32 ampdu_reference;
 	u32 flag;
+	u16 airtime;
 	u16 freq;
 	u8 enc_flags;
 	u8 encoding:2, bw:3;
@@ -2059,6 +2062,26 @@ struct ieee80211_txq {
  *	The stack will not do fragmentation.
  *	The callback for @set_frag_threshold should be set as well.
  *
+ * @IEEE80211_HW_AIRTIME_ACCOUNTING: Hardware supports accounting the airtime
+ *      usage of other stations and reports it in the @tx_time and/or @airtime
+ *      fields of the TX/RX status structs.
+ *      When setting this flag, the driver should ensure that the respective
+ *      fields in the TX and RX status structs are always either zero or
+ *      contains a valid duration for the frame in usec. The driver can choose
+ *      to report either or both of TX and RX airtime, but it is recommended to
+ *      report both.
+ *      The reported airtime should as a minimum include all time that is spent
+ *      transmitting to the remote station, including overhead and padding, but
+ *      not including time spent waiting for a TXOP. If the time is not reported
+ *      by the hardware it can in some cases be calculated from the rate and
+ *      known frame composition. When possible, the time should include any
+ *      failed transmission attempts.
+ *      For aggregated frames, there are two possible strategies to report the
+ *      airtime: Either include the airtime of the entire aggregate in the first
+ *      (or last) frame and leave the others at zero. Alternatively, include the
+ *      overhead of the full aggregate in the first or last frame and report the
+ *      time of each frame + padding not including the full aggregate overhead.
+ *
  * @NUM_IEEE80211_HW_FLAGS: number of hardware flags, used for sizing arrays
  */
 enum ieee80211_hw_flags {
@@ -2101,6 +2124,7 @@ enum ieee80211_hw_flags {
 	IEEE80211_HW_TX_FRAG_LIST,
 	IEEE80211_HW_REPORTS_LOW_ACK,
 	IEEE80211_HW_SUPPORTS_TX_FRAG,
+	IEEE80211_HW_AIRTIME_ACCOUNTING,
 
 	/* keep last, obviously */
 	NUM_IEEE80211_HW_FLAGS
net/mac80211/debugfs.c +1 -0
index 5fae001f286c..20e3aa0e8464 100644
@@ -211,6 +211,7 @@ static const char *hw_flag_names[] = {
 	FLAG(TX_FRAG_LIST),
 	FLAG(REPORTS_LOW_ACK),
 	FLAG(SUPPORTS_TX_FRAG),
+	FLAG(AIRTIME_ACCOUNTING),
 #undef FLAG
 };
 
net/mac80211/debugfs_sta.c +29 -0
index b15412c21ac9..40dba446836f 100644
@@ -188,6 +188,32 @@ static ssize_t sta_aqm_read(struct file *file, char __user *userbuf,
 }
 STA_OPS(aqm);
 
+static ssize_t sta_airtime_read(struct file *file, char __user *userbuf,
+				size_t count, loff_t *ppos)
+{
+	struct sta_info *sta = file->private_data;
+	size_t bufsz = 200;
+	char *buf = kzalloc(bufsz, GFP_KERNEL), *p = buf;
+	ssize_t rv;
+
+	if (!buf)
+		return -ENOMEM;
+
+	spin_lock_bh(&sta->lock);
+
+	p += scnprintf(p, bufsz + buf - p,
+		"RX: %llu us\nTX: %llu us\nDeficit: %lld us\n",
+		sta->airtime_stats.rx_airtime,
+		sta->airtime_stats.tx_airtime,
+		sta->airtime_deficit);
+
+	spin_unlock_bh(&sta->lock);
+	rv = simple_read_from_buffer(userbuf, count, ppos, buf, p - buf);
+	kfree(buf);
+	return rv;
+}
+STA_OPS(airtime);
+
 static ssize_t sta_agg_status_read(struct file *file, char __user *userbuf,
 					size_t count, loff_t *ppos)
 {
@@ -542,6 +568,9 @@ void ieee80211_sta_debugfs_add(struct sta_info *sta)
 	if (local->ops->wake_tx_queue)
 		DEBUGFS_ADD(aqm);
 
+	if (ieee80211_hw_check(&local->hw, AIRTIME_ACCOUNTING))
+		DEBUGFS_ADD(airtime);
+
 	if (sizeof(sta->driver_buffered_tids) == sizeof(u32))
 		debugfs_create_x32("driver_buffered_tids", 0400,
 				   sta->debugfs_dir,
net/mac80211/ieee80211_i.h +7 -2
index 95be548b1d4f..e74aeff7662a 100644
@@ -90,6 +90,9 @@ extern const u8 ieee80211_ac_to_qos_mask[IEEE80211_NUM_ACS];
 
 #define IEEE80211_MAX_NAN_INSTANCE_ID 255
 
+/* How much to increase airtime deficit on each scheduling round */
+#define IEEE80211_AIRTIME_QUANTUM        1000 /* usec */
+
 struct ieee80211_fragment_entry {
 	struct sk_buff_head skb_list;
 	unsigned long first_frag_time;
@@ -1122,9 +1125,11 @@ struct ieee80211_local {
 	struct codel_vars *cvars;
 	struct codel_params cparams;
 
-	/* protects active_txqs and txqi->schedule_order */
+	/* protects active_txqs_{new,old} and txqi->schedule_order */
 	spinlock_t active_txq_lock;
-	struct list_head active_txqs;
+	struct list_head active_txqs_new;
+	struct list_head active_txqs_old;
+
 
 	const struct ieee80211_ops *ops;
 
net/mac80211/main.c +2 -1
index 9ad0556aa24b..acf73c398d9b 100644
@@ -616,7 +616,8 @@ struct ieee80211_hw *ieee80211_alloc_hw_nm(size_t priv_data_len,
 	spin_lock_init(&local->rx_path_lock);
 	spin_lock_init(&local->queue_stop_reason_lock);
 
-	INIT_LIST_HEAD(&local->active_txqs);
+	INIT_LIST_HEAD(&local->active_txqs_new);
+	INIT_LIST_HEAD(&local->active_txqs_old);
 	spin_lock_init(&local->active_txq_lock);
 
 	INIT_LIST_HEAD(&local->chanctx_list);
net/mac80211/rx.c +8 -0
index 70e9d2ca8bbe..a6166850b971 100644
@@ -1637,6 +1637,14 @@ ieee80211_rx_h_sta_process(struct ieee80211_rx_data *rx)
 	if (ieee80211_vif_is_mesh(&rx->sdata->vif))
 		ieee80211_mps_rx_h_sta_process(sta, hdr);
 
+	/* airtime accounting */
+	if (status->airtime) {
+		spin_lock_bh(&sta->lock);
+		sta->airtime_stats.rx_airtime += status->airtime;
+		sta->airtime_deficit -= status->airtime;
+		spin_unlock_bh(&sta->lock);
+	}
+
 	/*
 	 * Drop (qos-)data::nullfunc frames silently, since they
 	 * are used only to control station power saving mode.
net/mac80211/sta_info.c +2 -0
index da3737d4778f..e8511922a7c7 100644
@@ -433,6 +433,8 @@ struct sta_info *sta_info_alloc(struct ieee80211_sub_if_data *sdata,
 	sta->cparams.interval = MS2TIME(100);
 	sta->cparams.ecn = true;
 
+	sta->airtime_deficit = IEEE80211_AIRTIME_QUANTUM;
+
 	sta_dbg(sdata, "Allocated STA %pM\n", sta->sta.addr);
 
 	return sta;
net/mac80211/sta_info.h +7 -0
index 5c54acd10562..5d1802f22550 100644
@@ -550,6 +550,13 @@ struct sta_info {
 	} tx_stats;
 	u16 tid_seq[IEEE80211_QOS_CTL_TID_MASK + 1];
 
+	/* Airtime stats and deficit, protected by lock */
+	struct {
+		u64 rx_airtime;
+		u64 tx_airtime;
+	} airtime_stats;
+	s64 airtime_deficit;
+
 	/*
 	 * Aggregation information, locked with lock.
 	 */
net/mac80211/status.c +16 -0
index da7427a41529..cf7956f7a040 100644
@@ -823,6 +823,14 @@ static void __ieee80211_tx_status(struct ieee80211_hw *hw,
 				ieee80211_lost_packet(sta, info);
 			}
 		}
+
+		if (ieee80211_hw_check(&local->hw, AIRTIME_ACCOUNTING) &&
+		    info->status.tx_time) {
+			spin_lock_bh(&sta->lock);
+			sta->airtime_stats.tx_airtime += info->status.tx_time;
+			sta->airtime_deficit -= info->status.tx_time;
+			spin_unlock_bh(&sta->lock);
+		}
 	}
 
 	/* SNMP counters
@@ -947,6 +955,14 @@ void ieee80211_tx_status_ext(struct ieee80211_hw *hw,
 			sta->status_stats.retry_failed++;
 		sta->status_stats.retry_count += retry_count;
 
+		if (ieee80211_hw_check(&local->hw, AIRTIME_ACCOUNTING) &&
+		    info->status.tx_time) {
+			spin_lock_bh(&sta->lock);
+			sta->airtime_stats.tx_airtime += info->status.tx_time;
+			sta->airtime_deficit -= info->status.tx_time;
+			spin_unlock_bh(&sta->lock);
+		}
+
 		if (acked) {
 			sta->status_stats.last_ack = jiffies;
 
net/mac80211/tx.c +26 -5
index 824d87e6d3eb..409e84509625 100644
@@ -3530,7 +3530,7 @@ bool ieee80211_schedule_txq(struct ieee80211_hw *hw,
 	spin_lock_bh(&local->active_txq_lock);
 
 	if (list_empty(&txqi->schedule_order)) {
-		list_add_tail(&txqi->schedule_order, &local->active_txqs);
+		list_add_tail(&txqi->schedule_order, &local->active_txqs_new);
 		ret = true;
 	}
 
@@ -3544,14 +3544,35 @@ struct ieee80211_txq *ieee80211_next_txq(struct ieee80211_hw *hw)
 {
 	struct ieee80211_local *local = hw_to_local(hw);
 	struct txq_info *txqi = NULL;
+	struct list_head *head;
 
 	spin_lock_bh(&local->active_txq_lock);
 
-	if (list_empty(&local->active_txqs))
-		goto out;
+begin:
+	head = &local->active_txqs_new;
+	if (list_empty(head)) {
+		head = &local->active_txqs_old;
+		if (list_empty(head))
+			goto out;
+	}
+
+	txqi = list_first_entry(head, struct txq_info, schedule_order);
+
+	if (txqi->txq.sta) {
+		struct sta_info *sta = container_of(txqi->txq.sta,
+						struct sta_info, sta);
+
+		spin_lock_bh(&sta->lock);
+		if (sta->airtime_deficit < 0) {
+			sta->airtime_deficit += IEEE80211_AIRTIME_QUANTUM;
+			list_move_tail(&txqi->schedule_order,
+				       &local->active_txqs_old);
+			spin_unlock_bh(&sta->lock);
+			goto begin;
+		}
+		spin_unlock_bh(&sta->lock);
+	}
 
-	txqi = list_first_entry(&local->active_txqs,
-				struct txq_info, schedule_order);
 	list_del_init(&txqi->schedule_order);
 
 out:
Signature · 1 line
2.14.2
author maintainer
#9 lore raw

PATCH v2 3/3 ath9k: Switch to mac80211 airtime API

In reply to Toke Høiland-Jørgensen

This removes the in-driver airtime fairness scheduling from ath9k and switches the driver to use the API introduced in mac80211 in the previous commit.

---
Changes since v1:
- Split out ath9k changes into separate patch

 drivers/net/wireless/ath/ath9k/ath9k.h     |  7 +---
 drivers/net/wireless/ath/ath9k/debug.h     |  8 -----
 drivers/net/wireless/ath/ath9k/debug_sta.c | 54 ------------------------------
 drivers/net/wireless/ath/ath9k/init.c      |  4 +--
 drivers/net/wireless/ath/ath9k/recv.c      | 11 ++----
 drivers/net/wireless/ath/ath9k/xmit.c      | 21 ++++--------
 6 files changed, 12 insertions(+), 93 deletions(-)
drivers/net/wireless/ath/ath9k/ath9k.h +1 -6
index f6c53df78856..f6e8f9b1b984 100644
@@ -112,8 +112,6 @@ int ath_descdma_setup(struct ath_softc *sc, struct ath_descdma *dd,
 #define ATH_TXFIFO_DEPTH           8
 #define ATH_TX_ERROR               0x01
 
-#define ATH_AIRTIME_QUANTUM        300 /* usec */
-
 /* Stop tx traffic 1ms before the GO goes away */
 #define ATH_P2P_PS_STOP_TIME       1000
 
@@ -215,6 +213,7 @@ struct ath_buf_state {
 	bool stale;
 	u16 seqno;
 	unsigned long bfs_paprd_timestamp;
+	u32 airtime;
 };
 
 struct ath_buf {
@@ -262,12 +261,9 @@ struct ath_node {
 
 	bool sleeping;
 	bool no_ps_filter;
-	s64 airtime_deficit[IEEE80211_NUM_ACS];
-	u32 airtime_rx_start;
 
 #ifdef CONFIG_ATH9K_STATION_STATISTICS
 	struct ath_rx_rate_stats rx_rate_stats;
-	struct ath_airtime_stats airtime_stats;
 #endif
 	u8 key_idx[4];
 
@@ -986,7 +982,6 @@ void ath_ant_comb_scan(struct ath_softc *sc, struct ath_rx_status *rs);
 
 #define AIRTIME_USE_TX		BIT(0)
 #define AIRTIME_USE_RX		BIT(1)
-#define AIRTIME_USE_NEW_QUEUES	BIT(2)
 #define AIRTIME_ACTIVE(flags) (!!(flags & (AIRTIME_USE_TX|AIRTIME_USE_RX)))
 
 struct ath_softc {
drivers/net/wireless/ath/ath9k/debug.h +0 -8
index 249f8141cd00..559d9628f280 100644
@@ -319,20 +319,12 @@ ath9k_debug_sync_cause(struct ath_softc *sc, u32 sync_cause)
 void ath_debug_rate_stats(struct ath_softc *sc,
 			  struct ath_rx_status *rs,
 			  struct sk_buff *skb);
-void ath_debug_airtime(struct ath_softc *sc,
-		       struct ath_node *an,
-		       u32 rx, u32 tx);
 #else
 static inline void ath_debug_rate_stats(struct ath_softc *sc,
 					struct ath_rx_status *rs,
 					struct sk_buff *skb)
 {
 }
-static inline void ath_debug_airtime(struct ath_softc *sc,
-			      struct ath_node *an,
-			      u32 rx, u32 tx)
-{
-}
 #endif /* CONFIG_ATH9K_STATION_STATISTICS */
 
 #endif /* DEBUG_H */
drivers/net/wireless/ath/ath9k/debug_sta.c +0 -54

64 lines not on this page · raw message

drivers/net/wireless/ath/ath9k/init.c +2 -2
index bb7936090b91..b4c6fc49b19e 100644
@@ -620,8 +620,7 @@ static int ath9k_init_softc(u16 devid, struct ath_softc *sc,
 
 	/* Will be cleared in ath9k_start() */
 	set_bit(ATH_OP_INVALID, &common->op_flags);
-	sc->airtime_flags = (AIRTIME_USE_TX | AIRTIME_USE_RX |
-			     AIRTIME_USE_NEW_QUEUES);
+	sc->airtime_flags = (AIRTIME_USE_TX | AIRTIME_USE_RX);
 
 	sc->sc_ah = ah;
 	sc->dfs_detector = dfs_pattern_detector_init(common, NL80211_DFS_UNSET);
@@ -873,6 +872,7 @@ static void ath9k_set_hw_capab(struct ath_softc *sc, struct ieee80211_hw *hw)
 	ieee80211_hw_set(hw, HOST_BROADCAST_PS_BUFFERING);
 	ieee80211_hw_set(hw, SUPPORT_FAST_XMIT);
 	ieee80211_hw_set(hw, SUPPORTS_CLONED_SKBS);
+	ieee80211_hw_set(hw, AIRTIME_ACCOUNTING);
 
 	if (ath9k_ps_enable)
 		ieee80211_hw_set(hw, SUPPORTS_PS);
drivers/net/wireless/ath/ath9k/recv.c +3 -8
index 2197aee2bb72..69a4ba5d4013 100644
@@ -1054,14 +1054,9 @@ static void ath_rx_count_airtime(struct ath_softc *sc,
 						len, rxs->rate_idx, is_sp);
 	}
 
- 	if (!!(sc->airtime_flags & AIRTIME_USE_RX)) {
-		spin_lock_bh(&acq->lock);
-		an->airtime_deficit[acno] -= airtime;
-		if (an->airtime_deficit[acno] <= 0)
-			__ath_tx_queue_tid(sc, ATH_AN_2_TID(an, tidno));
-		spin_unlock_bh(&acq->lock);
-	}
-	ath_debug_airtime(sc, an, airtime, 0);
+	if (!!(sc->airtime_flags & AIRTIME_USE_RX))
+		rxs->airtime = airtime;
+
 exit:
 	rcu_read_unlock();
 }
drivers/net/wireless/ath/ath9k/xmit.c +6 -15
index bd438062a6db..5ffd44a4b3de 100644
@@ -640,11 +640,9 @@ static bool bf_is_ampdu_not_probing(struct ath_buf *bf)
     return bf_isampdu(bf) && !(info->flags & IEEE80211_TX_CTL_RATE_CTRL_PROBE);
 }
 
-static void ath_tx_count_airtime(struct ath_softc *sc, struct ath_node *an,
-				 struct ath_atx_tid *tid, struct ath_buf *bf,
+static void ath_tx_count_airtime(struct ath_softc *sc, struct ath_buf *bf,
 				 struct ath_tx_status *ts)
 {
-	struct ath_txq *txq = tid->txq;
 	u32 airtime = 0;
 	int i;
 
@@ -654,15 +652,9 @@ static void ath_tx_count_airtime(struct ath_softc *sc, struct ath_node *an,
 		airtime += rate_dur * bf->rates[i].count;
 	}
 
-	if (sc->airtime_flags & AIRTIME_USE_TX) {
-		int q = txq->mac80211_qnum;
-		struct ath_acq *acq = &sc->cur_chan->acq[q];
+	if (sc->airtime_flags & AIRTIME_USE_TX)
+		bf->bf_state.airtime = airtime;
 
-		spin_lock_bh(&acq->lock);
-		an->airtime_deficit[q] -= airtime;
-		spin_unlock_bh(&acq->lock);
-	}
-	ath_debug_airtime(sc, an, 0, airtime);
 }
 
 static void ath_tx_process_buffer(struct ath_softc *sc, struct ath_txq *txq,
@@ -692,7 +684,7 @@ static void ath_tx_process_buffer(struct ath_softc *sc, struct ath_txq *txq,
 	if (sta) {
 		struct ath_node *an = (struct ath_node *)sta->drv_priv;
 		tid = ath_get_skb_tid(sc, an, bf->bf_mpdu);
-		ath_tx_count_airtime(sc, an, tid, bf, ts);
+		ath_tx_count_airtime(sc, bf, ts);
 		if (ts->ts_status & (ATH9K_TXERR_FILT | ATH9K_TXERR_XRETRY))
 			tid->clear_ps_filter = true;
 	}
@@ -2428,6 +2420,8 @@ static void ath_tx_complete_buf(struct ath_softc *sc, struct ath_buf *bf,
 	if (ts->ts_status & ATH9K_TXERR_FILT)
 		tx_info->flags |= IEEE80211_TX_STAT_TX_FILTERED;
 
+	tx_info->status.tx_time = min_t(u32, 0xffff, bf->bf_state.airtime);
+
 	dma_unmap_single(sc->dev, bf->bf_buf_addr, skb->len, DMA_TO_DEVICE);
 	bf->bf_buf_addr = 0;
 	if (sc->tx99_state)
@@ -2754,9 +2748,6 @@ void ath_tx_node_init(struct ath_softc *sc, struct ath_node *an)
 	struct ath_atx_tid *tid;
 	int tidno, acno;
 
-	for (acno = 0; acno < IEEE80211_NUM_ACS; acno++)
-		an->airtime_deficit[acno] = ATH_AIRTIME_QUANTUM;
-
 	for (tidno = 0; tidno < IEEE80211_NUM_TIDS; tidno++) {
 		tid = ath_node_to_tid(an, tidno);
 		tid->an        = an;
Signature · 1 line
2.14.2
#10 lore raw
In reply to Toke Høiland-Jørgensen
Thank you for the patch! Yet something to improve:

Hi Toke,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on mac80211/master]
[also build test ERROR on v4.14-rc7 next-20171018]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Toke-H-iland-J-rgensen/mac80211-Add-TXQ-scheduling-API/20171030-220903
base:   https://git.kernel.org/pub/scm/linux/kernel/git/jberg/mac80211.git master
config: x86_64-allyesdebian (attached as .config)
compiler: gcc-6 (Debian 6.2.0-3) 6.2.0 20160901
reproduce:
        # save the attached .config to linux build tree
        make ARCH=x86_64 

Note: the linux-review/Toke-H-iland-J-rgensen/mac80211-Add-TXQ-scheduling-API/20171030-220903 HEAD aa503ef75660b7c9cb9ede292f03047372517d4e builds fine.
It only hurts bisectibility.

All errors (new ones prefixed by >>):

drivers/net/wireless/ath/ath9k/recv.o: In function `ath_rx_tasklet':

>> recv.c:(.text+0x16bc): undefined reference to `__ath_tx_queue_tid'

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation

#11 lore raw
In reply to Toke Høiland-Jørgensen
Thank you for the patch! Yet something to improve:

Hi Toke,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on mac80211/master]
[also build test ERROR on v4.14-rc7]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Toke-H-iland-J-rgensen/mac80211-Add-TXQ-scheduling-API/20171030-220903
base:   https://git.kernel.org/pub/scm/linux/kernel/git/jberg/mac80211.git master
config: mips-ip27_defconfig (attached as .config)
compiler: mips64-linux-gnuabi64-gcc (Debian 6.1.1-9) 6.1.1 20160705

reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=mips

Note: the linux-review/Toke-H-iland-J-rgensen/mac80211-Add-TXQ-scheduling-API/20171030-220903 HEAD aa503ef75660b7c9cb9ede292f03047372517d4e builds fine.
It only hurts bisectibility.

All errors (new ones prefixed by >>):

>> ERROR: "__ath_tx_queue_tid" [drivers/net/wireless/ath/ath9k/ath9k.ko] undefined!

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation

author maintainer
#12 lore raw

PATCH v3 1/3 mac80211: Add TXQ scheduling API

In reply to Toke Høiland-Jørgensen

This adds an API to mac80211 to handle scheduling of TXQs and changes the interface between driver and mac80211 for TXQ handling as follows:

- The wake_tx_queue callback interface no longer includes the TXQ. Instead, the driver is expected to retrieve that from ieee80211_next_txq()

- Two new mac80211 functions are added: ieee80211_next_txq() and ieee80211_schedule_txq(). The former returns the next TXQ that should be scheduled, and is how the driver gets a queue to pull packets from. The latter is called internally by mac80211 to start scheduling a queue, and the driver is supposed to call it to re-schedule the TXQ after it is finished pulling packets from it (unless the queue emptied).

The ath9k and ath10k drivers are changed to use the new API.

---
Changes since v2:
- Fix build error of first patch in the series reported by the kbuild bot

 drivers/net/wireless/ath/ath10k/core.c |   2 -
 drivers/net/wireless/ath/ath10k/core.h |   4 -
 drivers/net/wireless/ath/ath10k/mac.c  |  55 +++------
 drivers/net/wireless/ath/ath9k/ath9k.h |   9 +-
 drivers/net/wireless/ath/ath9k/main.c  |   2 +-
 drivers/net/wireless/ath/ath9k/recv.c  |   2 -
 drivers/net/wireless/ath/ath9k/xmit.c  | 210 ++++++++-------------------------
 include/net/mac80211.h                 |  37 +++++-
 net/mac80211/agg-tx.c                  |   6 +-
 net/mac80211/driver-ops.h              |  12 +-
 net/mac80211/ieee80211_i.h             |   5 +
 net/mac80211/main.c                    |   3 +
 net/mac80211/sta_info.c                |   7 +-
 net/mac80211/trace.h                   |  32 +----
 net/mac80211/tx.c                      |  49 +++++++-
 15 files changed, 173 insertions(+), 262 deletions(-)
drivers/net/wireless/ath/ath10k/core.c +0 -2
index a4f635820f35..759df3297d48 100644
@@ -2561,9 +2561,7 @@ struct ath10k *ath10k_core_create(size_t priv_size, struct device *dev,
 
 	mutex_init(&ar->conf_mutex);
 	spin_lock_init(&ar->data_lock);
-	spin_lock_init(&ar->txqs_lock);
 
-	INIT_LIST_HEAD(&ar->txqs);
 	INIT_LIST_HEAD(&ar->peers);
 	init_waitqueue_head(&ar->peer_mapping_wq);
 	init_waitqueue_head(&ar->htt.empty_tx_wq);
drivers/net/wireless/ath/ath10k/core.h +0 -4
index 949ebb3e967b..3c3b158cdb20 100644
@@ -347,7 +347,6 @@ struct ath10k_peer {
 };
 
 struct ath10k_txq {
-	struct list_head list;
 	unsigned long num_fw_queued;
 	unsigned long num_push_allowed;
 };
@@ -892,10 +891,7 @@ struct ath10k {
 
 	/* protects shared structure data */
 	spinlock_t data_lock;
-	/* protects: ar->txqs, artxq->list */
-	spinlock_t txqs_lock;
 
-	struct list_head txqs;
 	struct list_head arvifs;
 	struct list_head peers;
 	struct ath10k_peer *peer_map[ATH10K_MAX_NUM_PEER_IDS];
drivers/net/wireless/ath/ath10k/mac.c +16 -39

115 lines not on this page · raw message

drivers/net/wireless/ath/ath9k/ath9k.h +2 -7
index cf076719c27e..a5088792b769 100644
@@ -246,12 +246,8 @@ struct ath_atx_tid {
 	s8 bar_index;
 	bool active;
 	bool clear_ps_filter;
-	bool has_queued;
 };
 
-void __ath_tx_queue_tid(struct ath_softc *sc, struct ath_atx_tid *tid);
-void ath_tx_queue_tid(struct ath_softc *sc, struct ath_atx_tid *tid);
-
 struct ath_node {
 	struct ath_softc *sc;
 	struct ieee80211_sta *sta; /* station struct we're part of */
@@ -591,8 +587,7 @@ bool ath_drain_all_txq(struct ath_softc *sc);
 void ath_draintxq(struct ath_softc *sc, struct ath_txq *txq);
 void ath_tx_node_init(struct ath_softc *sc, struct ath_node *an);
 void ath_tx_node_cleanup(struct ath_softc *sc, struct ath_node *an);
-void ath_txq_schedule(struct ath_softc *sc, struct ath_txq *txq);
-void ath_txq_schedule_all(struct ath_softc *sc);
+void ath_txq_schedule(struct ath_softc *sc);
 int ath_tx_init(struct ath_softc *sc, int nbufs);
 int ath_txq_update(struct ath_softc *sc, int qnum,
 		   struct ath9k_tx_queue_info *q);
@@ -618,7 +613,7 @@ void ath9k_release_buffered_frames(struct ieee80211_hw *hw,
 				   u16 tids, int nframes,
 				   enum ieee80211_frame_release_type reason,
 				   bool more_data);
-void ath9k_wake_tx_queue(struct ieee80211_hw *hw, struct ieee80211_txq *queue);
+void ath9k_wake_tx_queue(struct ieee80211_hw *hw);
 
 /********/
 /* VIFs */
drivers/net/wireless/ath/ath9k/main.c +1 -1
index 8b4ac7f0a09b..7c2ba21fd972 100644
@@ -265,7 +265,7 @@ static bool ath_complete_reset(struct ath_softc *sc, bool start)
 		}
 	work:
 		ath_restart_work(sc);
-		ath_txq_schedule_all(sc);
+		ath_txq_schedule(sc);
 	}
 
 	sc->gtt_cnt = 0;
drivers/net/wireless/ath/ath9k/recv.c +0 -2
index 2197aee2bb72..a768e841524d 100644
@@ -1057,8 +1057,6 @@ static void ath_rx_count_airtime(struct ath_softc *sc,
  	if (!!(sc->airtime_flags & AIRTIME_USE_RX)) {
 		spin_lock_bh(&acq->lock);
 		an->airtime_deficit[acno] -= airtime;
-		if (an->airtime_deficit[acno] <= 0)
-			__ath_tx_queue_tid(sc, ATH_AN_2_TID(an, tidno));
 		spin_unlock_bh(&acq->lock);
 	}
 	ath_debug_airtime(sc, an, airtime, 0);
drivers/net/wireless/ath/ath9k/xmit.c +50 -160

374 lines not on this page · raw message

include/net/mac80211.h +31 -6
index cc9073e45be9..715f45501aff 100644
@@ -105,9 +105,12 @@
  * The driver is expected to initialize its private per-queue data for stations
  * and interfaces in the .add_interface and .sta_add ops.
  *
- * The driver can't access the queue directly. To dequeue a frame, it calls
- * ieee80211_tx_dequeue(). Whenever mac80211 adds a new frame to a queue, it
- * calls the .wake_tx_queue driver op.
+ * The driver can't access the queue directly. To obtain the next queue to pull
+ * frames from, the driver calls ieee80211_next_txq(). To dequeue a frame from a
+ * txq, it calls ieee80211_tx_dequeue(). Whenever mac80211 adds a new frame to a
+ * queue, it calls the .wake_tx_queue driver op. The driver is expected to
+ * re-schedule the txq using ieee80211_schedule_txq() if it is still active
+ * after the driver has finished pulling packets from it.
  *
  * For AP powersave TIM handling, the driver only needs to indicate if it has
  * buffered packets in the driver specific data structures by calling
@@ -3723,8 +3726,7 @@ struct ieee80211_ops {
 					 struct ieee80211_vif *vif,
 					 struct ieee80211_tdls_ch_sw_params *params);
 
-	void (*wake_tx_queue)(struct ieee80211_hw *hw,
-			      struct ieee80211_txq *txq);
+	void (*wake_tx_queue)(struct ieee80211_hw *hw);
 	void (*sync_rx_queues)(struct ieee80211_hw *hw);
 
 	int (*start_nan)(struct ieee80211_hw *hw,
@@ -5869,13 +5871,36 @@ void ieee80211_unreserve_tid(struct ieee80211_sta *sta, u8 tid);
  * ieee80211_tx_dequeue - dequeue a packet from a software tx queue
  *
  * @hw: pointer as obtained from ieee80211_alloc_hw()
- * @txq: pointer obtained from station or virtual interface
+ * @txq: pointer obtained from ieee80211_next_txq()
  *
  * Returns the skb if successful, %NULL if no frame was available.
  */
 struct sk_buff *ieee80211_tx_dequeue(struct ieee80211_hw *hw,
 				     struct ieee80211_txq *txq);
 
+/**
+ * ieee80211_schedule_txq - add txq to scheduling loop
+ *
+ * @hw: pointer as obtained from ieee80211_alloc_hw()
+ * @txq: pointer obtained from station or virtual interface
+ *
+ * Returns %true if the txq was actually added to the scheduling,
+ * %false otherwise.
+ */
+bool ieee80211_schedule_txq(struct ieee80211_hw *hw,
+			    struct ieee80211_txq *txq);
+
+/**
+ * ieee80211_next_txq - get next tx queue to pull packets from
+ *
+ * @hw: pointer as obtained from ieee80211_alloc_hw()
+ *
+ * Returns the next txq if successful, %NULL if no queue is eligible. If a txq
+ * is returned, it will have been removed from the scheduler queue and needs to
+ * be re-scheduled with ieee80211_schedule_txq() to continue to be active.
+ */
+struct ieee80211_txq *ieee80211_next_txq(struct ieee80211_hw *hw);
+
 /**
  * ieee80211_txq_get_depth - get pending frame/byte count of given txq
  *
net/mac80211/agg-tx.c +5 -1
index bef516ec47f9..569b5b5c6d70 100644
@@ -226,9 +226,13 @@ ieee80211_agg_start_txq(struct sta_info *sta, int tid, bool enable)
 		clear_bit(IEEE80211_TXQ_AMPDU, &txqi->flags);
 
 	clear_bit(IEEE80211_TXQ_STOP, &txqi->flags);
+
+	if (!ieee80211_schedule_txq(&sta->sdata->local->hw, txq))
+		return;
+
 	local_bh_disable();
 	rcu_read_lock();
-	drv_wake_tx_queue(sta->sdata->local, txqi);
+	drv_wake_tx_queue(sta->sdata->local);
 	rcu_read_unlock();
 	local_bh_enable();
 }
net/mac80211/driver-ops.h +3 -9
index 09f77e4a8a79..e20a9e2acd53 100644
@@ -1157,16 +1157,10 @@ drv_tdls_recv_channel_switch(struct ieee80211_local *local,
 	trace_drv_return_void(local);
 }
 
-static inline void drv_wake_tx_queue(struct ieee80211_local *local,
-				     struct txq_info *txq)
+static inline void drv_wake_tx_queue(struct ieee80211_local *local)
 {
-	struct ieee80211_sub_if_data *sdata = vif_to_sdata(txq->txq.vif);
-
-	if (!check_sdata_in_driver(sdata))
-		return;
-
-	trace_drv_wake_tx_queue(local, sdata, txq);
-	local->ops->wake_tx_queue(&local->hw, &txq->txq);
+	trace_drv_wake_tx_queue(local);
+	local->ops->wake_tx_queue(&local->hw);
 }
 
 static inline int drv_start_nan(struct ieee80211_local *local,
net/mac80211/ieee80211_i.h +5 -0
index 9675814f64db..95be548b1d4f 100644
@@ -832,6 +832,7 @@ struct txq_info {
 	struct codel_vars def_cvars;
 	struct codel_stats cstats;
 	struct sk_buff_head frags;
+	struct list_head schedule_order;
 	unsigned long flags;
 
 	/* keep last! */
@@ -1121,6 +1122,10 @@ struct ieee80211_local {
 	struct codel_vars *cvars;
 	struct codel_params cparams;
 
+	/* protects active_txqs and txqi->schedule_order */
+	spinlock_t active_txq_lock;
+	struct list_head active_txqs;
+
 	const struct ieee80211_ops *ops;
 
 	/*
net/mac80211/main.c +3 -0
index 8aa1f5b6a051..9ad0556aa24b 100644
@@ -616,6 +616,9 @@ struct ieee80211_hw *ieee80211_alloc_hw_nm(size_t priv_data_len,
 	spin_lock_init(&local->rx_path_lock);
 	spin_lock_init(&local->queue_stop_reason_lock);
 
+	INIT_LIST_HEAD(&local->active_txqs);
+	spin_lock_init(&local->active_txq_lock);
+
 	INIT_LIST_HEAD(&local->chanctx_list);
 	mutex_init(&local->chanctx_mtx);
 
net/mac80211/sta_info.c +6 -1
index 9673e157bf8f..da3737d4778f 100644
@@ -1246,12 +1246,17 @@ void ieee80211_sta_ps_deliver_wakeup(struct sta_info *sta)
 		drv_sta_notify(local, sdata, STA_NOTIFY_AWAKE, &sta->sta);
 
 	if (sta->sta.txq[0]) {
+		bool wake = false;
+
 		for (i = 0; i < ARRAY_SIZE(sta->sta.txq); i++) {
 			if (!txq_has_queue(sta->sta.txq[i]))
 				continue;
 
-			drv_wake_tx_queue(local, to_txq_info(sta->sta.txq[i]));
+			if (ieee80211_schedule_txq(&local->hw, sta->sta.txq[i]))
+				wake = true;
 		}
+		if (wake)
+			drv_wake_tx_queue(local);
 	}
 
 	skb_queue_head_init(&pending);
net/mac80211/trace.h +3 -29
index 3d9ac17af407..f51eade947ee 100644
@@ -2549,35 +2549,9 @@ TRACE_EVENT(drv_tdls_recv_channel_switch,
 	)
 );
 
-TRACE_EVENT(drv_wake_tx_queue,
-	TP_PROTO(struct ieee80211_local *local,
-		 struct ieee80211_sub_if_data *sdata,
-		 struct txq_info *txq),
-
-	TP_ARGS(local, sdata, txq),
-
-	TP_STRUCT__entry(
-		LOCAL_ENTRY
-		VIF_ENTRY
-		STA_ENTRY
-		__field(u8, ac)
-		__field(u8, tid)
-	),
-
-	TP_fast_assign(
-		struct ieee80211_sta *sta = txq->txq.sta;
-
-		LOCAL_ASSIGN;
-		VIF_ASSIGN;
-		STA_ASSIGN;
-		__entry->ac = txq->txq.ac;
-		__entry->tid = txq->txq.tid;
-	),
-
-	TP_printk(
-		LOCAL_PR_FMT  VIF_PR_FMT  STA_PR_FMT " ac:%d tid:%d",
-		LOCAL_PR_ARG, VIF_PR_ARG, STA_PR_ARG, __entry->ac, __entry->tid
-	)
+DEFINE_EVENT(local_only_evt, drv_wake_tx_queue,
+	     TP_PROTO(struct ieee80211_local *local),
+	     TP_ARGS(local)
 );
 
 #endif /* !__MAC80211_DRIVER_TRACE || TRACE_HEADER_MULTI_READ */
net/mac80211/tx.c +48 -1

73 lines not on this page · raw message

Signature · 1 line
2.14.3
author maintainer
#13 lore raw

PATCH v3 2/3 mac80211: Add airtime account and scheduling to TXQs

This adds airtime accounting and scheduling to the mac80211 TXQ scheduler. A new hardware flag, AIRTIME_ACCOUNTING, is added that drivers can set if they support reporting airtime usage of transmissions. When this flag is set, mac80211 will expect the actual airtime usage to be reported in the tx_time and rx_time fields of the respective status structs.

When airtime information is present, mac80211 will schedule TXQs (through ieee80211_next_txq()) in a way that enforces airtime fairness between active stations. This scheduling works the same way as the ath9k in-driver airtime fairness scheduling.

---
 include/net/mac80211.h     | 24 ++++++++++++++++++++++++
 net/mac80211/debugfs.c     |  1 +
 net/mac80211/debugfs_sta.c | 29 +++++++++++++++++++++++++++++
 net/mac80211/ieee80211_i.h |  9 +++++++--
 net/mac80211/main.c        |  3 ++-
 net/mac80211/rx.c          |  8 ++++++++
 net/mac80211/sta_info.c    |  2 ++
 net/mac80211/sta_info.h    |  7 +++++++
 net/mac80211/status.c      | 16 ++++++++++++++++
 net/mac80211/tx.c          | 31 ++++++++++++++++++++++++++-----
 10 files changed, 122 insertions(+), 8 deletions(-)
include/net/mac80211.h +24 -0
index 715f45501aff..453653d082af 100644
@@ -1188,6 +1188,8 @@ enum mac80211_rx_encoding {
  *	HT or VHT is used (%RX_FLAG_HT/%RX_FLAG_VHT)
  * @nss: number of streams (VHT and HE only)
  * @flag: %RX_FLAG_\*
+ * @airtime: Duration of frame in usec. See @IEEE80211_HW_AIRTIME_ACCOUNTING for
+ *       how to use this.
  * @encoding: &enum mac80211_rx_encoding
  * @bw: &enum rate_info_bw
  * @enc_flags: uses bits from &enum mac80211_rx_encoding_flags
@@ -1202,6 +1204,7 @@ struct ieee80211_rx_status {
 	u32 device_timestamp;
 	u32 ampdu_reference;
 	u32 flag;
+	u16 airtime;
 	u16 freq;
 	u8 enc_flags;
 	u8 encoding:2, bw:3;
@@ -2059,6 +2062,26 @@ struct ieee80211_txq {
  *	The stack will not do fragmentation.
  *	The callback for @set_frag_threshold should be set as well.
  *
+ * @IEEE80211_HW_AIRTIME_ACCOUNTING: Hardware supports accounting the airtime
+ *      usage of other stations and reports it in the @tx_time and/or @airtime
+ *      fields of the TX/RX status structs.
+ *      When setting this flag, the driver should ensure that the respective
+ *      fields in the TX and RX status structs are always either zero or
+ *      contains a valid duration for the frame in usec. The driver can choose
+ *      to report either or both of TX and RX airtime, but it is recommended to
+ *      report both.
+ *      The reported airtime should as a minimum include all time that is spent
+ *      transmitting to the remote station, including overhead and padding, but
+ *      not including time spent waiting for a TXOP. If the time is not reported
+ *      by the hardware it can in some cases be calculated from the rate and
+ *      known frame composition. When possible, the time should include any
+ *      failed transmission attempts.
+ *      For aggregated frames, there are two possible strategies to report the
+ *      airtime: Either include the airtime of the entire aggregate in the first
+ *      (or last) frame and leave the others at zero. Alternatively, include the
+ *      overhead of the full aggregate in the first or last frame and report the
+ *      time of each frame + padding not including the full aggregate overhead.
+ *
  * @NUM_IEEE80211_HW_FLAGS: number of hardware flags, used for sizing arrays
  */
 enum ieee80211_hw_flags {
@@ -2101,6 +2124,7 @@ enum ieee80211_hw_flags {
 	IEEE80211_HW_TX_FRAG_LIST,
 	IEEE80211_HW_REPORTS_LOW_ACK,
 	IEEE80211_HW_SUPPORTS_TX_FRAG,
+	IEEE80211_HW_AIRTIME_ACCOUNTING,
 
 	/* keep last, obviously */
 	NUM_IEEE80211_HW_FLAGS
net/mac80211/debugfs.c +1 -0
index 5fae001f286c..20e3aa0e8464 100644
@@ -211,6 +211,7 @@ static const char *hw_flag_names[] = {
 	FLAG(TX_FRAG_LIST),
 	FLAG(REPORTS_LOW_ACK),
 	FLAG(SUPPORTS_TX_FRAG),
+	FLAG(AIRTIME_ACCOUNTING),
 #undef FLAG
 };
 
net/mac80211/debugfs_sta.c +29 -0
index b15412c21ac9..40dba446836f 100644
@@ -188,6 +188,32 @@ static ssize_t sta_aqm_read(struct file *file, char __user *userbuf,
 }
 STA_OPS(aqm);
 
+static ssize_t sta_airtime_read(struct file *file, char __user *userbuf,
+				size_t count, loff_t *ppos)
+{
+	struct sta_info *sta = file->private_data;
+	size_t bufsz = 200;
+	char *buf = kzalloc(bufsz, GFP_KERNEL), *p = buf;
+	ssize_t rv;
+
+	if (!buf)
+		return -ENOMEM;
+
+	spin_lock_bh(&sta->lock);
+
+	p += scnprintf(p, bufsz + buf - p,
+		"RX: %llu us\nTX: %llu us\nDeficit: %lld us\n",
+		sta->airtime_stats.rx_airtime,
+		sta->airtime_stats.tx_airtime,
+		sta->airtime_deficit);
+
+	spin_unlock_bh(&sta->lock);
+	rv = simple_read_from_buffer(userbuf, count, ppos, buf, p - buf);
+	kfree(buf);
+	return rv;
+}
+STA_OPS(airtime);
+
 static ssize_t sta_agg_status_read(struct file *file, char __user *userbuf,
 					size_t count, loff_t *ppos)
 {
@@ -542,6 +568,9 @@ void ieee80211_sta_debugfs_add(struct sta_info *sta)
 	if (local->ops->wake_tx_queue)
 		DEBUGFS_ADD(aqm);
 
+	if (ieee80211_hw_check(&local->hw, AIRTIME_ACCOUNTING))
+		DEBUGFS_ADD(airtime);
+
 	if (sizeof(sta->driver_buffered_tids) == sizeof(u32))
 		debugfs_create_x32("driver_buffered_tids", 0400,
 				   sta->debugfs_dir,
net/mac80211/ieee80211_i.h +7 -2
index 95be548b1d4f..e74aeff7662a 100644
@@ -90,6 +90,9 @@ extern const u8 ieee80211_ac_to_qos_mask[IEEE80211_NUM_ACS];
 
 #define IEEE80211_MAX_NAN_INSTANCE_ID 255
 
+/* How much to increase airtime deficit on each scheduling round */
+#define IEEE80211_AIRTIME_QUANTUM        1000 /* usec */
+
 struct ieee80211_fragment_entry {
 	struct sk_buff_head skb_list;
 	unsigned long first_frag_time;
@@ -1122,9 +1125,11 @@ struct ieee80211_local {
 	struct codel_vars *cvars;
 	struct codel_params cparams;
 
-	/* protects active_txqs and txqi->schedule_order */
+	/* protects active_txqs_{new,old} and txqi->schedule_order */
 	spinlock_t active_txq_lock;
-	struct list_head active_txqs;
+	struct list_head active_txqs_new;
+	struct list_head active_txqs_old;
+
 
 	const struct ieee80211_ops *ops;
 
net/mac80211/main.c +2 -1
index 9ad0556aa24b..acf73c398d9b 100644
@@ -616,7 +616,8 @@ struct ieee80211_hw *ieee80211_alloc_hw_nm(size_t priv_data_len,
 	spin_lock_init(&local->rx_path_lock);
 	spin_lock_init(&local->queue_stop_reason_lock);
 
-	INIT_LIST_HEAD(&local->active_txqs);
+	INIT_LIST_HEAD(&local->active_txqs_new);
+	INIT_LIST_HEAD(&local->active_txqs_old);
 	spin_lock_init(&local->active_txq_lock);
 
 	INIT_LIST_HEAD(&local->chanctx_list);
net/mac80211/rx.c +8 -0
index 70e9d2ca8bbe..a6166850b971 100644
@@ -1637,6 +1637,14 @@ ieee80211_rx_h_sta_process(struct ieee80211_rx_data *rx)
 	if (ieee80211_vif_is_mesh(&rx->sdata->vif))
 		ieee80211_mps_rx_h_sta_process(sta, hdr);
 
+	/* airtime accounting */
+	if (status->airtime) {
+		spin_lock_bh(&sta->lock);
+		sta->airtime_stats.rx_airtime += status->airtime;
+		sta->airtime_deficit -= status->airtime;
+		spin_unlock_bh(&sta->lock);
+	}
+
 	/*
 	 * Drop (qos-)data::nullfunc frames silently, since they
 	 * are used only to control station power saving mode.
net/mac80211/sta_info.c +2 -0
index da3737d4778f..e8511922a7c7 100644
@@ -433,6 +433,8 @@ struct sta_info *sta_info_alloc(struct ieee80211_sub_if_data *sdata,
 	sta->cparams.interval = MS2TIME(100);
 	sta->cparams.ecn = true;
 
+	sta->airtime_deficit = IEEE80211_AIRTIME_QUANTUM;
+
 	sta_dbg(sdata, "Allocated STA %pM\n", sta->sta.addr);
 
 	return sta;
net/mac80211/sta_info.h +7 -0
index 5c54acd10562..5d1802f22550 100644
@@ -550,6 +550,13 @@ struct sta_info {
 	} tx_stats;
 	u16 tid_seq[IEEE80211_QOS_CTL_TID_MASK + 1];
 
+	/* Airtime stats and deficit, protected by lock */
+	struct {
+		u64 rx_airtime;
+		u64 tx_airtime;
+	} airtime_stats;
+	s64 airtime_deficit;
+
 	/*
 	 * Aggregation information, locked with lock.
 	 */
net/mac80211/status.c +16 -0
index da7427a41529..cf7956f7a040 100644
@@ -823,6 +823,14 @@ static void __ieee80211_tx_status(struct ieee80211_hw *hw,
 				ieee80211_lost_packet(sta, info);
 			}
 		}
+
+		if (ieee80211_hw_check(&local->hw, AIRTIME_ACCOUNTING) &&
+		    info->status.tx_time) {
+			spin_lock_bh(&sta->lock);
+			sta->airtime_stats.tx_airtime += info->status.tx_time;
+			sta->airtime_deficit -= info->status.tx_time;
+			spin_unlock_bh(&sta->lock);
+		}
 	}
 
 	/* SNMP counters
@@ -947,6 +955,14 @@ void ieee80211_tx_status_ext(struct ieee80211_hw *hw,
 			sta->status_stats.retry_failed++;
 		sta->status_stats.retry_count += retry_count;
 
+		if (ieee80211_hw_check(&local->hw, AIRTIME_ACCOUNTING) &&
+		    info->status.tx_time) {
+			spin_lock_bh(&sta->lock);
+			sta->airtime_stats.tx_airtime += info->status.tx_time;
+			sta->airtime_deficit -= info->status.tx_time;
+			spin_unlock_bh(&sta->lock);
+		}
+
 		if (acked) {
 			sta->status_stats.last_ack = jiffies;
 
net/mac80211/tx.c +26 -5
index 824d87e6d3eb..409e84509625 100644
@@ -3530,7 +3530,7 @@ bool ieee80211_schedule_txq(struct ieee80211_hw *hw,
 	spin_lock_bh(&local->active_txq_lock);
 
 	if (list_empty(&txqi->schedule_order)) {
-		list_add_tail(&txqi->schedule_order, &local->active_txqs);
+		list_add_tail(&txqi->schedule_order, &local->active_txqs_new);
 		ret = true;
 	}
 
@@ -3544,14 +3544,35 @@ struct ieee80211_txq *ieee80211_next_txq(struct ieee80211_hw *hw)
 {
 	struct ieee80211_local *local = hw_to_local(hw);
 	struct txq_info *txqi = NULL;
+	struct list_head *head;
 
 	spin_lock_bh(&local->active_txq_lock);
 
-	if (list_empty(&local->active_txqs))
-		goto out;
+begin:
+	head = &local->active_txqs_new;
+	if (list_empty(head)) {
+		head = &local->active_txqs_old;
+		if (list_empty(head))
+			goto out;
+	}
+
+	txqi = list_first_entry(head, struct txq_info, schedule_order);
+
+	if (txqi->txq.sta) {
+		struct sta_info *sta = container_of(txqi->txq.sta,
+						struct sta_info, sta);
+
+		spin_lock_bh(&sta->lock);
+		if (sta->airtime_deficit < 0) {
+			sta->airtime_deficit += IEEE80211_AIRTIME_QUANTUM;
+			list_move_tail(&txqi->schedule_order,
+				       &local->active_txqs_old);
+			spin_unlock_bh(&sta->lock);
+			goto begin;
+		}
+		spin_unlock_bh(&sta->lock);
+	}
 
-	txqi = list_first_entry(&local->active_txqs,
-				struct txq_info, schedule_order);
 	list_del_init(&txqi->schedule_order);
 
 out:
Signature · 1 line
2.14.3
author maintainer
#14 lore raw

PATCH v3 3/3 ath9k: Switch to mac80211 airtime API

In reply to Toke Høiland-Jørgensen

This removes the in-driver airtime fairness scheduling from ath9k and switches the driver to use the API introduced in mac80211 in the previous commit.

---
 drivers/net/wireless/ath/ath9k/ath9k.h     |  7 +---
 drivers/net/wireless/ath/ath9k/debug.h     |  8 -----
 drivers/net/wireless/ath/ath9k/debug_sta.c | 54 ------------------------------
 drivers/net/wireless/ath/ath9k/init.c      |  4 +--
 drivers/net/wireless/ath/ath9k/recv.c      |  9 ++---
 drivers/net/wireless/ath/ath9k/xmit.c      | 21 ++++--------
 6 files changed, 12 insertions(+), 91 deletions(-)
drivers/net/wireless/ath/ath9k/ath9k.h +1 -6
index a5088792b769..7c7dece6cb91 100644
@@ -112,8 +112,6 @@ int ath_descdma_setup(struct ath_softc *sc, struct ath_descdma *dd,
 #define ATH_TXFIFO_DEPTH           8
 #define ATH_TX_ERROR               0x01
 
-#define ATH_AIRTIME_QUANTUM        300 /* usec */
-
 /* Stop tx traffic 1ms before the GO goes away */
 #define ATH_P2P_PS_STOP_TIME       1000
 
@@ -215,6 +213,7 @@ struct ath_buf_state {
 	bool stale;
 	u16 seqno;
 	unsigned long bfs_paprd_timestamp;
+	u32 airtime;
 };
 
 struct ath_buf {
@@ -259,12 +258,9 @@ struct ath_node {
 
 	bool sleeping;
 	bool no_ps_filter;
-	s64 airtime_deficit[IEEE80211_NUM_ACS];
-	u32 airtime_rx_start;
 
 #ifdef CONFIG_ATH9K_STATION_STATISTICS
 	struct ath_rx_rate_stats rx_rate_stats;
-	struct ath_airtime_stats airtime_stats;
 #endif
 	u8 key_idx[4];
 
@@ -983,7 +979,6 @@ void ath_ant_comb_scan(struct ath_softc *sc, struct ath_rx_status *rs);
 
 #define AIRTIME_USE_TX		BIT(0)
 #define AIRTIME_USE_RX		BIT(1)
-#define AIRTIME_USE_NEW_QUEUES	BIT(2)
 #define AIRTIME_ACTIVE(flags) (!!(flags & (AIRTIME_USE_TX|AIRTIME_USE_RX)))
 
 struct ath_softc {
drivers/net/wireless/ath/ath9k/debug.h +0 -8
index 249f8141cd00..559d9628f280 100644
@@ -319,20 +319,12 @@ ath9k_debug_sync_cause(struct ath_softc *sc, u32 sync_cause)
 void ath_debug_rate_stats(struct ath_softc *sc,
 			  struct ath_rx_status *rs,
 			  struct sk_buff *skb);
-void ath_debug_airtime(struct ath_softc *sc,
-		       struct ath_node *an,
-		       u32 rx, u32 tx);
 #else
 static inline void ath_debug_rate_stats(struct ath_softc *sc,
 					struct ath_rx_status *rs,
 					struct sk_buff *skb)
 {
 }
-static inline void ath_debug_airtime(struct ath_softc *sc,
-			      struct ath_node *an,
-			      u32 rx, u32 tx)
-{
-}
 #endif /* CONFIG_ATH9K_STATION_STATISTICS */
 
 #endif /* DEBUG_H */
drivers/net/wireless/ath/ath9k/debug_sta.c +0 -54

64 lines not on this page · raw message

drivers/net/wireless/ath/ath9k/init.c +2 -2
index bb7936090b91..b4c6fc49b19e 100644
@@ -620,8 +620,7 @@ static int ath9k_init_softc(u16 devid, struct ath_softc *sc,
 
 	/* Will be cleared in ath9k_start() */
 	set_bit(ATH_OP_INVALID, &common->op_flags);
-	sc->airtime_flags = (AIRTIME_USE_TX | AIRTIME_USE_RX |
-			     AIRTIME_USE_NEW_QUEUES);
+	sc->airtime_flags = (AIRTIME_USE_TX | AIRTIME_USE_RX);
 
 	sc->sc_ah = ah;
 	sc->dfs_detector = dfs_pattern_detector_init(common, NL80211_DFS_UNSET);
@@ -873,6 +872,7 @@ static void ath9k_set_hw_capab(struct ath_softc *sc, struct ieee80211_hw *hw)
 	ieee80211_hw_set(hw, HOST_BROADCAST_PS_BUFFERING);
 	ieee80211_hw_set(hw, SUPPORT_FAST_XMIT);
 	ieee80211_hw_set(hw, SUPPORTS_CLONED_SKBS);
+	ieee80211_hw_set(hw, AIRTIME_ACCOUNTING);
 
 	if (ath9k_ps_enable)
 		ieee80211_hw_set(hw, SUPPORTS_PS);
drivers/net/wireless/ath/ath9k/recv.c +3 -6
index a768e841524d..69a4ba5d4013 100644
@@ -1054,12 +1054,9 @@ static void ath_rx_count_airtime(struct ath_softc *sc,
 						len, rxs->rate_idx, is_sp);
 	}
 
- 	if (!!(sc->airtime_flags & AIRTIME_USE_RX)) {
-		spin_lock_bh(&acq->lock);
-		an->airtime_deficit[acno] -= airtime;
-		spin_unlock_bh(&acq->lock);
-	}
-	ath_debug_airtime(sc, an, airtime, 0);
+	if (!!(sc->airtime_flags & AIRTIME_USE_RX))
+		rxs->airtime = airtime;
+
 exit:
 	rcu_read_unlock();
 }
drivers/net/wireless/ath/ath9k/xmit.c +6 -15
index bd438062a6db..5ffd44a4b3de 100644
@@ -640,11 +640,9 @@ static bool bf_is_ampdu_not_probing(struct ath_buf *bf)
     return bf_isampdu(bf) && !(info->flags & IEEE80211_TX_CTL_RATE_CTRL_PROBE);
 }
 
-static void ath_tx_count_airtime(struct ath_softc *sc, struct ath_node *an,
-				 struct ath_atx_tid *tid, struct ath_buf *bf,
+static void ath_tx_count_airtime(struct ath_softc *sc, struct ath_buf *bf,
 				 struct ath_tx_status *ts)
 {
-	struct ath_txq *txq = tid->txq;
 	u32 airtime = 0;
 	int i;
 
@@ -654,15 +652,9 @@ static void ath_tx_count_airtime(struct ath_softc *sc, struct ath_node *an,
 		airtime += rate_dur * bf->rates[i].count;
 	}
 
-	if (sc->airtime_flags & AIRTIME_USE_TX) {
-		int q = txq->mac80211_qnum;
-		struct ath_acq *acq = &sc->cur_chan->acq[q];
+	if (sc->airtime_flags & AIRTIME_USE_TX)
+		bf->bf_state.airtime = airtime;
 
-		spin_lock_bh(&acq->lock);
-		an->airtime_deficit[q] -= airtime;
-		spin_unlock_bh(&acq->lock);
-	}
-	ath_debug_airtime(sc, an, 0, airtime);
 }
 
 static void ath_tx_process_buffer(struct ath_softc *sc, struct ath_txq *txq,
@@ -692,7 +684,7 @@ static void ath_tx_process_buffer(struct ath_softc *sc, struct ath_txq *txq,
 	if (sta) {
 		struct ath_node *an = (struct ath_node *)sta->drv_priv;
 		tid = ath_get_skb_tid(sc, an, bf->bf_mpdu);
-		ath_tx_count_airtime(sc, an, tid, bf, ts);
+		ath_tx_count_airtime(sc, bf, ts);
 		if (ts->ts_status & (ATH9K_TXERR_FILT | ATH9K_TXERR_XRETRY))
 			tid->clear_ps_filter = true;
 	}
@@ -2428,6 +2420,8 @@ static void ath_tx_complete_buf(struct ath_softc *sc, struct ath_buf *bf,
 	if (ts->ts_status & ATH9K_TXERR_FILT)
 		tx_info->flags |= IEEE80211_TX_STAT_TX_FILTERED;
 
+	tx_info->status.tx_time = min_t(u32, 0xffff, bf->bf_state.airtime);
+
 	dma_unmap_single(sc->dev, bf->bf_buf_addr, skb->len, DMA_TO_DEVICE);
 	bf->bf_buf_addr = 0;
 	if (sc->tx99_state)
@@ -2754,9 +2748,6 @@ void ath_tx_node_init(struct ath_softc *sc, struct ath_node *an)
 	struct ath_atx_tid *tid;
 	int tidno, acno;
 
-	for (acno = 0; acno < IEEE80211_NUM_ACS; acno++)
-		an->airtime_deficit[acno] = ATH_AIRTIME_QUANTUM;
-
 	for (tidno = 0; tidno < IEEE80211_NUM_TIDS; tidno++) {
 		tid = ath_node_to_tid(an, tidno);
 		tid->an        = an;
Signature · 1 line
2.14.3
#15 lore raw
In reply to Toke Høiland-Jørgensen
Quoted 13 lines · Toke Høiland-Jørgensen

This adds an API to mac80211 to handle scheduling of TXQs and changes the interface between driver and mac80211 for TXQ handling as follows:

- The wake_tx_queue callback interface no longer includes the TXQ. Instead, the driver is expected to retrieve that from ieee80211_next_txq()

- Two new mac80211 functions are added: ieee80211_next_txq() and ieee80211_schedule_txq(). The former returns the next TXQ that should be scheduled, and is how the driver gets a queue to pull packets from. The latter is called internally by mac80211 to start scheduling a queue, and the driver is supposed to call it to re-schedule the TXQ after it is finished pulling packets from it (unless the queue emptied).

Quoted 3 lines

The ath9k and ath10k drivers are changed to use the new API.

Sorry that I didn't have time to give this a thorough review earlier, since I was pretty busy with other projects. Now that I'm working on porting mt76 to this new API, some things in this patch strike me as rather odd, and there might be some bugs and nasty limitations here:

In the new API you can no longer select txq entries by hardware queue. When using multiple WMM queues, this could lead to station entries being requeued unnecessarily (because there is no room in the hw queue for the txq entry that ieee80211_next_txq happens to return).
Since ieee80211_next_txq also refills the airtime fairness quantum, this might lead to some minor fairness issues.

In ath9k the code used to have a loop that goes through all pending txq entries until it has filled the hw queues again. You replaced that with some calls to ath_txq_schedule which now only considers one single txq. There are several reasons why this queue could potentially not be serviced:
- ieee80211_tx_dequeue returned no frame
- frame does not fit within BA window
- txq was for another queue which is already filled
Depending on the exact circumstances with enough stations this might lead to hardware queues getting starved.

In ath10k the issues are different. You left a loop to service queues in place, and if I'm reading it correctly, you could be facing an infinite loop here:
Let's assume that ath10k_mac_tx_push_pending gets called and there are multiple txqs pending.
The first txq has 16 frames pending, gets serviced, requeued. Second txq has lots of frames pending, 16 frames are pushed out, the txq is requeued.
Back to the first one, ath10k_mac_tx_push_txq returns -ENOENT, so no requeue.
Back to the second one, hardware queues are filled, ath10k_mac_tx_can_push returns false, so ret stays 0, txq gets requeued. By now first == txq can never happen anymore because the first txq is not scheduled anymore.
Seems like an infinite loop to me.

I think dealing with these corner cases will be easier if we support filtering by queue in ieee80211_next_txq, so I will send a patch for that.

- Felix

author maintainer
#16 lore raw
Quoted 5 lines · Felix Fietkau
Quoted 4 lines · On 2017-10-31 12:27, Toke H=C3=B8iland-J=C3=B8rgensen wrote:

This adds an API to mac80211 to handle scheduling of TXQs and changes the interface between driver and mac80211 for TXQ handling as follows:
=20
- The wake_tx_queue callback interface no longer includes the TXQ. Inste=

ad,

Quoted 4 lines
Quoted 4 lines

the driver is expected to retrieve that from ieee80211_next_txq()
=20
- Two new mac80211 functions are added: ieee80211_next_txq() and ieee80211_schedule_txq(). The former returns the next TXQ that should =

be

Quoted 2 lines
Quoted 2 lines

scheduled, and is how the driver gets a queue to pull packets from. The latter is called internally by mac80211 to start scheduling a queue, a=

nd

Quoted 11 lines
Quoted 6 lines

the driver is supposed to call it to re-schedule the TXQ after it is finished pulling packets from it (unless the queue emptied).
=20
The ath9k and ath10k drivers are changed to use the new API. =20

Sorry that I didn't have time to give this a thorough review earlier, since I was pretty busy with other projects. Now that I'm working on porting mt76 to this new API, some things in this patch strike me as rather odd, and there might be some bugs and nasty limitations here:

Quoted 4 lines

In the new API you can no longer select txq entries by hardware queue. When using multiple WMM queues, this could lead to station entries being requeued unnecessarily (because there is no room in the hw queue for the txq entry that ieee80211_next_txq happens to return).

Yeah, there's some tension between enforcing fairness (which is a per station thing) and the WMM queueing stuff (which gives priority based on WMM levels and ignores stations). There are basically two ways to resolve this: Prioritising fairness or prioritising WMM levels. In the former case, we first select which station to transmit to, and then select the highest WMM priority level queued *for that station* (the last part of this is missing from the code as it is now). In the latter case, we keep scheduling per-WMM, then enforce fairness within that.

The former case has the potential to lead to starved hardware queues, while the latter leads to unfairness. We had a bit of discussion of which is better at netdev, but did not resolve it. Personally, I think prioritising fairness is better, but I'm willing to be convinced otherwise by data :). So my plan is to implement that fully and try it out, then evaluate based on actual experiments...

Quoted 2 lines

Since ieee80211_next_txq also refills the airtime fairness quantum, this might lead to some minor fairness issues.

I'm planning to change the way the scheduler works anyway, so this issue should go away. Haven't had time to do that yet, unfortunately.

Quoted 4 lines

In ath9k the code used to have a loop that goes through all pending txq entries until it has filled the hw queues again. You replaced that with some calls to ath_txq_schedule which now only considers one single txq. There are several reasons why this queue could potentially not be service=

d:

Quoted 5 lines

- ieee80211_tx_dequeue returned no frame
- frame does not fit within BA window
- txq was for another queue which is already filled Depending on the exact circumstances with enough stations this might lead to hardware queues getting starved.

Well, that loop was already removed when I implemented the in-driver fairness scheduler. We can't really avoid those cases entirely if we want to enforce fairness (the BAW case in particular; if the only eligible station from an airtime PoW has a full BAW, you have to throttle and can potentially starve hwqs). However, don't think this happens much in practice (or we would have seen performance regressions by now).

The 'txq was for another queue' case is new with this patch, but that goes back to the WMM/fairness tention above.

Quoted 7 lines

In ath10k the issues are different. You left a loop to service queues in place, and if I'm reading it correctly, you could be facing an infinite loop here:
Let's assume that ath10k_mac_tx_push_pending gets called and there are multiple txqs pending.
The first txq has 16 frames pending, gets serviced, requeued. Second txq has lots of frames pending, 16 frames are pushed out, the txq

Quoted 8 lines

is requeued.
Back to the first one, ath10k_mac_tx_push_txq returns -ENOENT, so no requeue.
Back to the second one, hardware queues are filled, ath10k_mac_tx_can_push returns false, so ret stays 0, txq gets requeued. By now first =3D=3D txq can never happen anymore because the first txq is not scheduled anymore.
Seems like an infinite loop to me.

Hmm, you may be right here. I don't have the hardware to test this on ath10k :/

Quoted 3 lines

I think dealing with these corner cases will be easier if we support filtering by queue in ieee80211_next_txq, so I will send a patch for that.

Not necessarily opposed to a flag (or however you end up implementing this). We may have to ignore it if we want to prioritise fairness, as noted above. However, having the flag could potentially make this user configurable. I guess I'll have a look at your patch :)

-Toke

#17 lore raw
Quoted 38 lines · Toke Høiland-Jørgensen
Quoted 22 lines · Felix Fietkau
Quoted 13 lines · Toke Høiland-Jørgensen

This adds an API to mac80211 to handle scheduling of TXQs and changes the interface between driver and mac80211 for TXQ handling as follows:

- The wake_tx_queue callback interface no longer includes the TXQ. Instead, the driver is expected to retrieve that from ieee80211_next_txq()

- Two new mac80211 functions are added: ieee80211_next_txq() and ieee80211_schedule_txq(). The former returns the next TXQ that should be scheduled, and is how the driver gets a queue to pull packets from. The latter is called internally by mac80211 to start scheduling a queue, and the driver is supposed to call it to re-schedule the TXQ after it is finished pulling packets from it (unless the queue emptied).

Quoted 3 lines

The ath9k and ath10k drivers are changed to use the new API.

Sorry that I didn't have time to give this a thorough review earlier, since I was pretty busy with other projects. Now that I'm working on porting mt76 to this new API, some things in this patch strike me as rather odd, and there might be some bugs and nasty limitations here:

Quoted 4 lines

In the new API you can no longer select txq entries by hardware queue. When using multiple WMM queues, this could lead to station entries being requeued unnecessarily (because there is no room in the hw queue for the txq entry that ieee80211_next_txq happens to return).

Yeah, there's some tension between enforcing fairness (which is a per station thing) and the WMM queueing stuff (which gives priority based on WMM levels and ignores stations). There are basically two ways to resolve this: Prioritising fairness or prioritising WMM levels. In the former case, we first select which station to transmit to, and then select the highest WMM priority level queued *for that station* (the last part of this is missing from the code as it is now). In the latter case, we keep scheduling per-WMM, then enforce fairness within that.

Quoted 6 lines

The former case has the potential to lead to starved hardware queues, while the latter leads to unfairness. We had a bit of discussion of which is better at netdev, but did not resolve it. Personally, I think prioritising fairness is better, but I'm willing to be convinced otherwise by data :). So my plan is to implement that fully and try it out, then evaluate based on actual experiments...

I don't really see how the approach taken in the current code is actually prioritising fairness by starving hardware queues, since any txq that can't be serviced in the current call because of queue depth will be requeued. So based on the traffic pattern this might actually lead to *more* unfairness.

Quoted 5 lines
Quoted 2 lines

Since ieee80211_next_txq also refills the airtime fairness quantum, this might lead to some minor fairness issues.

I'm planning to change the way the scheduler works anyway, so this issue
should go away. Haven't had time to do that yet, unfortunately.Well, the problem is that the new code inside ath9k is a lot harder to

verify for correct behavior (regarding the queue starvation issue), and I would really like to avoid nasty regressions that will be a nightmare to debug.

Quoted 10 lines
Quoted 9 lines

In ath9k the code used to have a loop that goes through all pending txq entries until it has filled the hw queues again. You replaced that with some calls to ath_txq_schedule which now only considers one single txq. There are several reasons why this queue could potentially not be serviced:
- ieee80211_tx_dequeue returned no frame
- frame does not fit within BA window
- txq was for another queue which is already filled
Depending on the exact circumstances with enough stations this might lead to hardware queues getting starved.

Quoted 2 lines

Well, that loop was already removed when I implemented the in-driver fairness scheduler.

Now that's not true. I'm looking at the diff for "mac80211: Add TXQ scheduling API", and it removes these lines:

- /*
- * If we succeed in scheduling something, immediately restart to
make
- * sure we keep the HW busy.
- */
- if(ath_tx_sched_aggr(sc, txq, tid)) {
- if (!active) {

-                       spin_lock_bh(&acq->lock);
-                       list_move_tail(&tid->list, &acq->acq_old);
-                       spin_unlock_bh(&acq->lock);

- }
- goto begin;
- }

Quoted 6 lines

We can't really avoid those cases entirely if we
want to enforce fairness (the BAW case in particular; if the only eligible station from an airtime PoW has a full BAW, you have to throttle and can potentially starve hwqs). However, don't think this happens much in practice (or we would have seen performance regressions by now).I think so far you simply haven't had enough users hammering on the new

code yet.

Quoted 2 lines

The 'txq was for another queue' case is new with this patch, but that goes back to the WMM/fairness tention above.

I agree that this is something we need to figure out. One aspect that I have a major problem with is the fact that this *really* intrusive patch that completely changes the way that ath9k schedules tx queues is hidden behind this "API change" patch.

The way the API stands now, mt76 would require an equally big rework to a different scheduling model which I'm not comfortable with at this point.

I would like to suggest the following to resolve these issues:

First we should revert these patches.
We can respin them shortly after in a modified form where ieee80211_next_txq takes a 'queue' argument.
I'm almost done with the incremental change for that, and it also supports passing -1 for queue so incrementally switching to the scheduling that you're proposing will also work.

With that in place we can replace the ath9k change with a much smaller patch that is easier to verify for correctness and won't introduce the potential regressions that I pointed out.

I will take care of the mt76 porting today and I'll also help with sorting out the ath10k issues.

Is that acceptable to you?

- Felix

author maintainer
#18 lore raw
Quoted 5 lines · Felix Fietkau
Quoted 4 lines · On 2017-12-14 13:15, Toke H=C3=B8iland-J=C3=B8rgensen wrote:

Felix Fietkau <[email protected]> writes:
=20

Quoted 2 lines · On 2017-10-31 12:27, Toke H=C3=B8iland-J=C3=B8rgensen wrote:
Quoted 1 line

This adds an API to mac80211 to handle scheduling of TXQs and changes =

the

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

interface between driver and mac80211 for TXQ handling as follows:
=20
- The wake_tx_queue callback interface no longer includes the TXQ. Ins=

tead,

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

the driver is expected to retrieve that from ieee80211_next_txq()
=20
- Two new mac80211 functions are added: ieee80211_next_txq() and ieee80211_schedule_txq(). The former returns the next TXQ that shoul=

d be

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

scheduled, and is how the driver gets a queue to pull packets from. =

The

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

latter is called internally by mac80211 to start scheduling a queue,=

and

Quoted 32 lines
Quoted 15 lines
Quoted 11 lines
Quoted 6 lines

the driver is supposed to call it to re-schedule the TXQ after it is finished pulling packets from it (unless the queue emptied).
=20
The ath9k and ath10k drivers are changed to use the new API. =20

Sorry that I didn't have time to give this a thorough review earlier, since I was pretty busy with other projects. Now that I'm working on porting mt76 to this new API, some things in this patch strike me as rather odd, and there might be some bugs and nasty limitations here:

Quoted 4 lines

In the new API you can no longer select txq entries by hardware queue. When using multiple WMM queues, this could lead to station entries being requeued unnecessarily (because there is no room in the hw queue for the txq entry that ieee80211_next_txq happens to return).

Quoted 16 lines

=20
Yeah, there's some tension between enforcing fairness (which is a per station thing) and the WMM queueing stuff (which gives priority based on WMM levels and ignores stations). There are basically two ways to resolve this: Prioritising fairness or prioritising WMM levels. In the former case, we first select which station to transmit to, and then select the highest WMM priority level queued *for that station* (the last part of this is missing from the code as it is now). In the latter case, we keep scheduling per-WMM, then enforce fairness within that. =20
The former case has the potential to lead to starved hardware queues, while the latter leads to unfairness. We had a bit of discussion of which is better at netdev, but did not resolve it. Personally, I think prioritising fairness is better, but I'm willing to be convinced otherwise by data :). So my plan is to implement that fully and try it out, then evaluate based on actual experiments...

Quoted 5 lines

I don't really see how the approach taken in the current code is actually prioritising fairness by starving hardware queues, since any txq that can't be serviced in the current call because of queue depth will be requeued. So based on the traffic pattern this might actually lead to *more* unfairness.

Yeah, I'm not quite happy with the current state of the code as far as that is concerned. I thought I would have had time to revisit this, but then a bunch of other stuff came up and I never got around to it... Will come back to this soon I hope... :/

Quoted 10 lines
Quoted 5 lines
Quoted 2 lines

Since ieee80211_next_txq also refills the airtime fairness quantum, this might lead to some minor fairness issues.

=20
I'm planning to change the way the scheduler works anyway, so this issue should go away. Haven't had time to do that yet, unfortunately.

Well, the problem is that the new code inside ath9k is a lot harder to verify for correct behavior (regarding the queue starvation issue), and I would really like to avoid nasty regressions that will be a nightmare to debug.

Fair point, avoiding that would be good of course :)

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

In ath9k the code used to have a loop that goes through all pending txq entries until it has filled the hw queues again. You replaced that with some calls to ath_txq_schedule which now only considers one single txq. There are several reasons why this queue could potentially not be servi=

ced:

Quoted 14 lines
Quoted 8 lines
Quoted 5 lines

- ieee80211_tx_dequeue returned no frame
- frame does not fit within BA window
- txq was for another queue which is already filled Depending on the exact circumstances with enough stations this might lead to hardware queues getting starved.

=20
Well, that loop was already removed when I implemented the in-driver fairness scheduler.

Now that's not true. I'm looking at the diff for "mac80211: Add TXQ scheduling API", and it removes these lines:

(quoted diff) +0 -2
-       /*
-        * If we succeed in scheduling something, immediately restart to

make

drivers/net/wireless/ath/ath9k/xmit.c void ath_tx_cleanupq(struct ath_softc *sc, struct ath_txq *txq) · line 2012

Quoted 10 lines
drivers/net/wireless/ath/ath9k/xmit.c +0 -10
-        * sure we keep the HW busy.
-        */
-       if(ath_tx_sched_aggr(sc, txq, tid)) {
-               if (!active) {
-                       spin_lock_bh(&acq->lock);
-                       list_move_tail(&tid->list, &acq->acq_old);
-                       spin_unlock_bh(&acq->lock);
-               }
-               goto begin;
-       }

Yeah, that is removed (which I suppose you are right could be problematic in itself), but it was only being called when ath_tx_sched_aggr() succeeds. Before (pre-airtime fairness) it did a full loop through all scheduled tids until the hwq was full, which is what I thought you were referring to.

Quoted 8 lines
Quoted 6 lines

We can't really avoid those cases entirely if we
want to enforce fairness (the BAW case in particular; if the only eligible station from an airtime PoW has a full BAW, you have to throttle and can potentially starve hwqs). However, don't think this happens much in practice (or we would have seen performance regressions by now).

I think so far you simply haven't had enough users hammering on the new code yet.

Heh. Guess that could also be the case... ;)

Quoted 10 lines
Quoted 2 lines

The 'txq was for another queue' case is new with this patch, but that goes back to the WMM/fairness tention above.

I agree that this is something we need to figure out. One aspect that I have a major problem with is the fact that this *really* intrusive patch that completely changes the way that ath9k schedules tx queues is hidden behind this "API change" patch.

The way the API stands now, mt76 would require an equally big rework to a different scheduling model which I'm not comfortable with at this point.

That is a fair point. I suppose that I was thinking too far ahead to what I wanted to do next and didn't pay enough attention to splitting things up into incremental changes. Of course this becomes more important when there are more drivers affected.

Quoted 5 lines

I would like to suggest the following to resolve these issues:

First we should revert these patches.
We can respin them shortly after in a modified form where ieee80211_next_txq takes a 'queue' argument.

By 'queue' you mean 'wmm hardware queue', right?

Quoted 4 lines

I'm almost done with the incremental change for that, and it also supports passing -1 for queue so incrementally switching to the scheduling that you're proposing will also work.

Quoted 8 lines

With that in place we can replace the ath9k change with a much smaller patch that is easier to verify for correctness and won't introduce the potential regressions that I pointed out.

I will take care of the mt76 porting today and I'll also help with sorting out the ath10k issues.

Is that acceptable to you?

Yup, sounds quite reasonable. And help with ath10k will be much appreciated, thanks :)

-Toke

maintainer
#19 lore raw
In reply to Felix Fietkau
Quoted 2 lines · Felix Fietkau

First we should revert these patches.

FWIW, I've just done that, if only to make the mt76 merge possible.

Quoted 2 lines

We can respin them shortly after in a modified form where ieee80211_next_txq takes a 'queue' argument.

I'll leave the two of you to discuss that :-)

Quoted 3 lines

I'm almost done with the incremental change for that, and it also supports passing -1 for queue so incrementally switching to the scheduling that you're proposing will also work.

Sounds fine to me.

Quoted 6 lines

With that in place we can replace the ath9k change with a much smaller patch that is easier to verify for correctness and won't introduce the potential regressions that I pointed out.

I will take care of the mt76 porting today and I'll also help with sorting out the ath10k issues.

So are you going to resend Toke's patches with your adjustments folded in? Or just one of them?

johannes