Switch ath9k and ath10k to mac80211 airtime framework
Subsystems (3)
v6 cover Switch ath9k and ath10k to mac80211 airtime framework
This is an updated resend of the driver part of the previous patch set that moves airtime fairness scheduling into mac80211 and enables it for ath10k as well.
This version is just a refresh of the driver code, along with a small fix for the issue I noticed yesterday where ath9k was calling ieee80211_return_txq() without proper logging.
Kan Yan (1):
ath10k: reporting estimated tx airtime for fairness
Toke Høiland-Jørgensen (3):
mac80211: Expose ieee80211_schedule_txq() function
ath9k: Switch to mac80211 TXQ scheduling and airtime APIs
ath10k: migrate to mac80211 txq scheduling
drivers/net/wireless/ath/ath10k/core.c | 2 - drivers/net/wireless/ath/ath10k/core.h | 8 +- drivers/net/wireless/ath/ath10k/htc.h | 1 - drivers/net/wireless/ath/ath10k/htt_rx.c | 9 + drivers/net/wireless/ath/ath10k/mac.c | 155 ++++++++----- drivers/net/wireless/ath/ath10k/txrx.c | 4 + drivers/net/wireless/ath/ath9k/ath9k.h | 14 -- drivers/net/wireless/ath/ath9k/debug.c | 3 - drivers/net/wireless/ath/ath9k/debug.h | 8 - drivers/net/wireless/ath/ath9k/debug_sta.c | 70 ------ drivers/net/wireless/ath/ath9k/init.c | 3 +- drivers/net/wireless/ath/ath9k/recv.c | 9 +- drivers/net/wireless/ath/ath9k/xmit.c | 244 ++++++--------------- include/net/mac80211.h | 13 ++ net/mac80211/driver-ops.h | 4 +- net/mac80211/tx.c | 13 ++ 16 files changed, 217 insertions(+), 343 deletions(-)
Signature · 1 line
2.20.1
PATCH v7 1/4 mac80211: Expose ieee80211_schedule_txq() function
Since we reworked ieee80211_return_txq() so it assumes that the caller takes care of logging, we need another function that can be called without holding any locks. Introduce ieee80211_schedule_txq() which serves this purpose.
--- include/net/mac80211.h | 13 +++++++++++++ net/mac80211/driver-ops.h | 4 +--- net/mac80211/tx.c | 13 +++++++++++++ 3 files changed, 27 insertions(+), 3 deletions(-)
include/net/mac80211.h +13 -0
@@ -6209,6 +6209,19 @@ void ieee80211_txq_schedule_start(struct ieee80211_hw *hw, u8 ac) void ieee80211_txq_schedule_end(struct ieee80211_hw *hw, u8 ac) __releases(txq_lock); +/** +* ieee80211_schedule_txq - schedule a TXQ for transmission +* +* @hw: pointer as obtained from ieee80211_alloc_hw() +* @txq: pointer obtained from station or virtual interface +* +* Schedules a TXQ for transmission if it is not already scheduled. Takes a +* lock, which means it must *not* be called between +* ieee80211_txq_schedule_start() and ieee80211_txq_schedule_end() +*/ +void ieee80211_schedule_txq(struct ieee80211_hw *hw, struct ieee80211_txq *txq) + __acquires(txq_lock) __releases(txq_lock); +/** * ieee80211_txq_may_transmit - check whether TXQ is allowed to transmit *
net/mac80211/driver-ops.h +1 -3
@@ -1176,9 +1176,7 @@ static inline void drv_wake_tx_queue(struct ieee80211_local *local,static inline void schedule_and_wake_txq (struct ieee80211_local *local,struct txq_info *txqi) { -spin_lock_bh (&local->active_txq_lock[txqi->txq.ac]); -ieee80211_return_txq (&local->hw, &txqi->txq); -spin_unlock_bh (&local->active_txq_lock[txqi->txq.ac]); +ieee80211_schedule_txq (&local->hw, &txqi->txq);drv_wake_tx_queue (local, txqi); }
net/mac80211/tx.c +13 -0
@@ -3703,6 +3703,19 @@ void ieee80211_return_txq(struct ieee80211_hw *hw, }EXPORT_SYMBOL (ieee80211_return_txq); +void ieee80211_schedule_txq (struct ieee80211_hw *hw, +struct ieee80211_txq *txq) +__acquires (txq_lock)__releases (txq_lock) +{ +struct ieee80211_local *local =hw_to_local (hw); +struct txq_info *txqi =to_txq_info (txq); + +spin_lock_bh (&local->active_txq_lock[txq->ac]); +ieee80211_return_txq (hw, txq); +spin_unlock_bh (&local->active_txq_lock[ac]); +} +EXPORT_SYMBOL (ieee80211_schedule_txq); +bool ieee80211_txq_may_transmit (struct ieee80211_hw *hw,struct ieee80211_txq *txq) {
Signature · 7 lines
2.20.1 _______________________________________________ ath10k mailing list [email protected] http://lists.infradead.org/mailman/listinfo/ath10k
Re: [PATCH v7 1/4] mac80211: Expose ieee80211_schedule_txq() function
Quoted 4 lines · Toke Høiland-Jørgensen
Since we reworked
ieee80211_return_txq()so it assumes that the caller takes care of logging, we need another function that can be called without holding any locks. Introduceieee80211_schedule_txq()which serves this purpose.
Hmm, messed up the version number on this one, sorry about that. It was supposed to be v6 along with the rest...
-Toke
Johannes Berg
maintainerRe: [PATCH v7 1/4] mac80211: Expose ieee80211_schedule_txq() function
In reply to Toke Høiland-Jørgensennet/mac80211/tx.c void ieee80211_return_txq(struct ieee80211_hw *hw, · line 3715
Quoted 12 lines
net/mac80211/tx.c +10
-0+void ieee80211_schedule_txq (struct ieee80211_hw *hw, +struct ieee80211_txq *txq) +__acquires (txq_lock)__releases (txq_lock) +{ +struct ieee80211_local *local =hw_to_local (hw); +struct txq_info *txqi =to_txq_info (txq); + +spin_lock_bh (&local->active_txq_lock[txq->ac]); +ieee80211_return_txq (hw, txq); +spin_unlock_bh (&local->active_txq_lock[ac]);
Maybe v6 had txq->ac here instead of just ac which doesn't compile ;-)
I fixed it up, but I hope you tested a compiling version :P
johannes
Re: [PATCH v7 1/4] mac80211: Expose ieee80211_schedule_txq() function
Quoted 13 lines · Johannes Berg
net/mac80211/tx.c void ieee80211_return_txq(struct ieee80211_hw *hw, · line 3715
Quoted 11 lines
net/mac80211/tx.c +10
-0+void ieee80211_schedule_txq (struct ieee80211_hw *hw, +struct ieee80211_txq *txq) +__acquires (txq_lock)__releases (txq_lock) +{ +struct ieee80211_local *local =hw_to_local (hw); +struct txq_info *txqi =to_txq_info (txq); + +spin_lock_bh (&local->active_txq_lock[txq->ac]); +ieee80211_return_txq (hw, txq); +spin_unlock_bh (&local->active_txq_lock[ac]);Maybe v6 had
txq->achere instead of just ac which doesn't compile ;-)
Quoted 1 line
I fixed it up, but I hope you tested a compiling version :P
Ah, right, thanks for fixing it! I think this was an artifact of moving things around while rebasing for submission (I have another patch on top of this series that I need to test first).
So yeah, I definitely have a version in my tree somewhere that actually compiles ;)
-Toke
PATCH v6 2/4 ath9k: Switch to mac80211 TXQ scheduling and airtime APIs
In reply to Toke Høiland-JørgensenFrom: Toke Høiland-Jørgensen <[email protected]>
This moves the ath9k driver to use the mac80211 TXQ scheduling and airtime accounting APIs, removing the corresponding state tracking inside the driver.
---
v6:
- Use the ieee80211_schedule_txq() function introduced in the previous patch instead of calling ieee80211_return_txq() with no locking.
drivers/net/wireless/ath/ath9k/ath9k.h | 14 -- drivers/net/wireless/ath/ath9k/debug.c | 3 - drivers/net/wireless/ath/ath9k/debug.h | 8 - drivers/net/wireless/ath/ath9k/debug_sta.c | 70 ------ drivers/net/wireless/ath/ath9k/init.c | 3 +- drivers/net/wireless/ath/ath9k/recv.c | 9 +- drivers/net/wireless/ath/ath9k/xmit.c | 244 ++++++--------------- 7 files changed, 75 insertions(+), 276 deletions(-)
drivers/net/wireless/ath/ath9k/ath9k.h +0 -14
@@ -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
@@ -246,10 +244,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 {
@@ -263,12 +259,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,11 +979,6 @@ void ath_ant_comb_scan(struct ath_softc *sc, struct ath_rx_status *rs);#define ATH9K_NUM_CHANCTX 2/* supports 2 operating channels */ -#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 {struct ieee80211_hw *hw;struct device *dev;
@@ -1034,8 +1022,6 @@ struct ath_softc {short nbcnvifs;unsigned long ps_usecount; -u16 airtime_flags;/* AIRTIME_* */ -struct ath_rx rx;struct ath_tx tx;struct ath_beacon beacon;
drivers/net/wireless/ath/ath9k/debug.c +0 -3
@@ -1443,9 +1443,6 @@ int ath9k_init_debug(struct ath_hw *ah)#endif debugfs_create_file ("tpc" ,0600 , sc->debug.debugfs_phy, sc, &fops_tpc); -debugfs_create_u16 ("airtime_flags" ,0600 , - sc->debug.debugfs_phy, &sc->airtime_flags); -debugfs_create_file ("nf_override" ,0600 , sc->debug.debugfs_phy, sc, &fops_nf_override);
drivers/net/wireless/ath/ath9k/debug.h +0 -8
@@ -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 -70
80 lines not on this page · raw message
drivers/net/wireless/ath/ath9k/init.c +1 -2
@@ -676,8 +676,6 @@ 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->sc_ah = ah; sc->dfs_detector =dfs_pattern_detector_init (common,NL80211_DFS_UNSET );
@@ -1013,6 +1011,7 @@ static void ath9k_set_hw_capab(struct ath_softc *sc, struct ieee80211_hw *hw)SET_IEEE80211_PERM_ADDR (hw, common->macaddr);wiphy_ext_feature_set (hw->wiphy,NL80211_EXT_FEATURE_CQM_RSSI_LIST ); +wiphy_ext_feature_set (hw->wiphy,NL80211_EXT_FEATURE_AIRTIME_FAIRNESS ); } int ath9k_init_device(u16 devid, struct ath_softc *sc,
drivers/net/wireless/ath/ath9k/recv.c +1 -8
@@ -1054,14 +1054,7 @@ 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 ); +ieee80211_sta_register_airtime (sta, tidno,0 , airtime); exit:rcu_read_unlock (); }
drivers/net/wireless/ath/ath9k/xmit.c +73 -171
491 lines not on this page · raw message
Signature · 7 lines
2.20.1 _______________________________________________ ath10k mailing list [email protected] http://lists.infradead.org/mailman/listinfo/ath10k
Re: [PATCH v6 2/4] ath9k: Switch to mac80211 TXQ scheduling and airtime APIs
Quoted 8 lines · Toke Høiland-Jørgensen
This moves the ath9k driver to use the mac80211 TXQ scheduling and airtime accounting APIs, removing the corresponding state tracking inside the driver.
Signed-off-by Toke Høiland-Jørgensen <[email protected]>[[email protected]: fixed checkpatch error and warnings]Signed-off-by Rajkumar Manoharan <[email protected]>Signed-off-by Kalle Valo <[email protected]>
3 patches applied to ath-next branch of ath.git, thanks.
89cea7493a34 ath9k: Switch to mac80211 TXQ scheduling and airtime APIs bb2edb733586 ath10k: migrate to mac80211 txq scheduling d1ce37b7831a ath10k: report estimated frame transmit airtime to improve fairness
Signature · 9 lines
https://patchwork.kernel.org/patch/10775549/ https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches _______________________________________________ ath10k mailing list [email protected] http://lists.infradead.org/mailman/listinfo/ath10k
Re: [PATCH v6 2/4] ath9k: Switch to mac80211 TXQ scheduling and airtime APIs
In reply to Toke Høiland-JørgensenQuoted 8 lines · Toke Høiland-Jørgensen
This moves the ath9k driver to use the mac80211 TXQ scheduling and airtime accounting APIs, removing the corresponding state tracking inside the driver.
Signed-off-by Toke Høiland-Jørgensen <[email protected]>[[email protected]: fixed checkpatch error and warnings]Signed-off-by Rajkumar Manoharan <[email protected]>Signed-off-by Kalle Valo <[email protected]>
3 patches applied to ath-next branch of ath.git, thanks.
89cea7493a34 ath9k: Switch to mac80211 TXQ scheduling and airtime APIs bb2edb733586 ath10k: migrate to mac80211 txq scheduling d1ce37b7831a ath10k: report estimated frame transmit airtime to improve fairness
Signature · 3 lines
https://patchwork.kernel.org/patch/10775549/ https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
PATCH v6 3/4 ath10k: migrate to mac80211 txq scheduling
In reply to Toke Høiland-JørgensenFrom: Toke Høiland-Jørgensen <[email protected]>
ath10k maintains common txqs list for all stations. This txq management can be removed by migrating to mac80211 txq APIs and let mac80211 handle txqs reordering based on reported airtime. By doing this, txq fairness maintained in ath10k i.e processing N frames per txq is removed. By adapting to mac80211 APIs, ath10k will support mac80211 based airtime fairness algorithm.
Tested on QCA4019 with firmware version 10.4-3.2.1.1-00015 Tested on QCA9984 with firmware version 10.4-3.9.0.1-00005
--- drivers/net/wireless/ath/ath10k/core.c | 2 - drivers/net/wireless/ath/ath10k/core.h | 6 +- drivers/net/wireless/ath/ath10k/htc.h | 1 - drivers/net/wireless/ath/ath10k/htt_rx.c | 8 ++ drivers/net/wireless/ath/ath10k/mac.c | 98 +++++++++++------------- 5 files changed, 54 insertions(+), 61 deletions(-)
drivers/net/wireless/ath/ath10k/core.c +0 -2
@@ -3098,9 +3098,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 +3 -3
@@ -90,6 +90,9 @@/* The magic used by QCA spec */ #define ATH10K_SMBIOS_BDF_EXT_MAGIC "BDF_" +/* Default Airtime weight multipler (Tuned for multiclient performance) */ +#define ATH10K_AIRTIME_WEIGHT_MULTIPLIER 4 +struct ath10k ;static inline const char *ath10k_bus_str (enum ath10k_bus bus)
@@ -1068,10 +1071,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/htc.h +0 -1
@@ -51,7 +51,6 @@ struct ath10k;*/ #define HTC_HOST_MAX_MSG_PER_RX_BUNDLE 8 -#define HTC_HOST_MAX_MSG_PER_TX_BUNDLE 16enum ath10k_htc_tx_flags {ATH10K_HTC_FLAG_NEED_CREDIT_UPDATE =0x01 ,
drivers/net/wireless/ath/ath10k/htt_rx.c +8 -0
@@ -2596,6 +2596,7 @@ static void ath10k_htt_rx_tx_fetch_ind(struct ath10k *ar, struct sk_buff *skb)u8 tid;int ret;int i; +bool may_tx;ath10k_dbg (ar,ATH10K_DBG_HTT ,"htt rx tx fetch ind\n" );
@@ -2668,8 +2669,13 @@ static void ath10k_htt_rx_tx_fetch_ind(struct ath10k *ar, struct sk_buff *skb) num_msdus =0 ; num_bytes =0 ; +ieee80211_txq_schedule_start (hw, txq->ac); + may_tx =ieee80211_txq_may_transmit (hw, txq);while (num_msdus < max_num_msdus && num_bytes < max_num_bytes) { +if (!may_tx) +break ; + ret =ath10k_mac_tx_push_txq (hw, txq);if (ret <0 )break ;
@@ -2677,6 +2683,8 @@ static void ath10k_htt_rx_tx_fetch_ind(struct ath10k *ar, struct sk_buff *skb) num_msdus++; num_bytes += ret; } +ieee80211_return_txq (hw, txq); +ieee80211_txq_schedule_end (hw, txq->ac); record->num_msdus =cpu_to_le16 (num_msdus); record->num_bytes =cpu_to_le32 (num_bytes);
drivers/net/wireless/ath/ath10k/mac.c +43 -55
154 lines not on this page · raw message
Signature · 7 lines
2.20.1 _______________________________________________ ath10k mailing list [email protected] http://lists.infradead.org/mailman/listinfo/ath10k
Re: [PATCH v6 3/4] ath10k: migrate to mac80211 txq scheduling
you mentioned yesterday that the called should own the right lock. doesnt that apply to ath10k as well? i dont see a lock here and you still calling txq_return
Sebastian
Am 22.01.2019 um 15:20 schrieb Toke Høiland-Jørgensen:
Quoted 266 lines
From: Toke Høiland-Jørgensen <[email protected]>
ath10k maintains common txqs list for all stations. This txq management can be removed by migrating to mac80211 txq APIs and let mac80211 handle txqs reordering based on reported airtime. By doing this, txq fairness maintained in ath10k i.e processing N frames per txq is removed. By adapting to mac80211 APIs, ath10k will support mac80211 based airtime fairness algorithm.
Tested on QCA4019 with firmware version 10.4-3.2.1.1-00015 Tested on QCA9984 with firmware version 10.4-3.9.0.1-00005
Co-developed-by Rajkumar Manoharan <[email protected]>Signed-off-by Rajkumar Manoharan <[email protected]>aSigned-off-by Toke Høiland-Jørgensen <[email protected]>--- drivers/net/wireless/ath/ath10k/core.c | 2 - drivers/net/wireless/ath/ath10k/core.h | 6 +- drivers/net/wireless/ath/ath10k/htc.h | 1 - drivers/net/wireless/ath/ath10k/htt_rx.c | 8 ++ drivers/net/wireless/ath/ath10k/mac.c | 98 +++++++++++------------- 5 files changed, 54 insertions(+), 61 deletions(-)drivers/net/wireless/ath/ath10k/core.c +0
-2@@ -3098,9 +3098,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 +3
-3@@ -90,6 +90,9 @@/* The magic used by QCA spec */ #define ATH10K_SMBIOS_BDF_EXT_MAGIC "BDF_" +/* Default Airtime weight multipler (Tuned for multiclient performance) */ +#define ATH10K_AIRTIME_WEIGHT_MULTIPLIER 4 +struct ath10k ;static inline const char *ath10k_bus_str (enum ath10k_bus bus)@@ -1068,10 +1071,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/htc.h +0
-1@@ -51,7 +51,6 @@ struct ath10k;*/ #define HTC_HOST_MAX_MSG_PER_RX_BUNDLE 8 -#define HTC_HOST_MAX_MSG_PER_TX_BUNDLE 16enum ath10k_htc_tx_flags {ATH10K_HTC_FLAG_NEED_CREDIT_UPDATE =0x01 ,drivers/net/wireless/ath/ath10k/htt_rx.c +8
-0@@ -2596,6 +2596,7 @@ static void ath10k_htt_rx_tx_fetch_ind(struct ath10k *ar, struct sk_buff *skb)u8 tid;int ret;int i; +bool may_tx;ath10k_dbg (ar,ATH10K_DBG_HTT ,"htt rx tx fetch ind\n" );@@ -2668,8 +2669,13 @@ static void ath10k_htt_rx_tx_fetch_ind(struct ath10k *ar, struct sk_buff *skb) num_msdus =0 ; num_bytes =0 ; +ieee80211_txq_schedule_start (hw, txq->ac); + may_tx =ieee80211_txq_may_transmit (hw, txq);while (num_msdus < max_num_msdus && num_bytes < max_num_bytes) { +if (!may_tx) +break ; + ret =ath10k_mac_tx_push_txq (hw, txq);if (ret <0 )break ;@@ -2677,6 +2683,8 @@ static void ath10k_htt_rx_tx_fetch_ind(struct ath10k *ar, struct sk_buff *skb) num_msdus++; num_bytes += ret; } +ieee80211_return_txq (hw, txq); +ieee80211_txq_schedule_end (hw, txq->ac); record->num_msdus =cpu_to_le16 (num_msdus); record->num_bytes =cpu_to_le32 (num_bytes);drivers/net/wireless/ath/ath10k/mac.c +41
-55@@ -3890,7 +3890,6 @@ static void ath10k_mac_txq_init(struct ieee80211_txq *txq)static void ath10k_mac_txq_unref (struct ath10k *ar,struct ieee80211_txq *txq) { -struct ath10k_txq *artxq;struct ath10k_skb_cb *cb;struct sk_buff *msdu;int msdu_id;@@ -3898,12 +3897,6 @@ static void ath10k_mac_txq_unref(struct ath10k *ar, struct ieee80211_txq *txq)if (!txq)return ; - artxq = (void *)txq->drv_priv; -spin_lock_bh (&ar->txqs_lock); -if (!list_empty (&artxq->list)) -list_del_init (&artxq->list); -spin_unlock_bh (&ar->txqs_lock); -spin_lock_bh (&ar->htt.tx_lock);idr_for_each_entry (&ar->htt.pending_tx, msdu, msdu_id) { cb =ATH10K_SKB_CB (msdu);@@ -3943,7 +3936,6 @@ static bool ath10k_mac_tx_can_push(struct ieee80211_hw *hw,struct ath10k_txq *artxq = (void *)txq->drv_priv;/* No need to get locks */ -if (ar->htt.tx_q_state.mode ==HTT_TX_MODE_SWITCH_PUSH )return true;@@ -4030,48 +4022,45 @@ int ath10k_mac_tx_push_txq(struct ieee80211_hw *hw,return skb_len; } -void ath10k_mac_tx_push_pending (struct ath10k *ar) +static int ath10k_mac_schedule_txq (struct ieee80211_hw *hw,u32 ac) { -struct ieee80211_hw *hw = ar->hw;struct ieee80211_txq *txq; -struct ath10k_txq *artxq; -struct ath10k_txq *last; -int ret; -int max; - -if (ar->htt.num_pending_tx >= (ar->htt.max_num_pending_tx /2 )) -return ; - -spin_lock_bh (&ar->txqs_lock); -rcu_read_lock (); - - last = list_last_entry(&ar->txqs, struct ath10k_txq, list); -while (!list_empty (&ar->txqs)) { - artxq = list_first_entry(&ar->txqs, struct ath10k_txq, list); - txq = container_of((void *)artxq, struct ieee80211_txq, - drv_priv); +int ret =0 ; -/* Prevent aggressive sta/tid taking over tx queue */ - max =HTC_HOST_MAX_MSG_PER_TX_BUNDLE ; - ret =0 ; -while (ath10k_mac_tx_can_push (hw, txq) && max--) { +ieee80211_txq_schedule_start (hw, ac); +while ((txq =ieee80211_next_txq (hw, ac))) { +while (ath10k_mac_tx_can_push (hw, txq)) { ret =ath10k_mac_tx_push_txq (hw, txq);if (ret <0 )break ; } +ieee80211_return_txq (hw, txq); +ath10k_htt_tx_txq_update (hw, txq); +if (ret == -EBUSY ) +break ; + } +ieee80211_txq_schedule_end (hw, ac); + +return ret; +} -list_del_init (&artxq->list); -if (ret != -ENOENT ) -list_add_tail (&artxq->list, &ar->txqs); +void ath10k_mac_tx_push_pending (struct ath10k *ar) +{ +struct ieee80211_hw *hw = ar->hw; +u32 ac; -ath10k_htt_tx_txq_update (hw, txq); +if (ar->htt.tx_q_state.mode !=HTT_TX_MODE_SWITCH_PUSH ) +return ; -if (artxq == last || (ret <0 && ret != -ENOENT )) +if (ar->htt.num_pending_tx >= (ar->htt.max_num_pending_tx /2 )) +return ; + +rcu_read_lock (); +for (ac =0 ; ac <IEEE80211_NUM_ACS ; ac++) { +if (ath10k_mac_schedule_txq (hw, ac) == -EBUSY )break ; } -rcu_read_unlock (); -spin_unlock_bh (&ar->txqs_lock); }EXPORT_SYMBOL (ath10k_mac_tx_push_pending);@@ -4310,31 +4299,28 @@ static void ath10k_mac_op_wake_tx_queue(struct ieee80211_hw *hw, struct ieee80211_txq *txq) {struct ath10k *ar = hw->priv; -struct ath10k_txq *artxq = (void *)txq->drv_priv; -struct ieee80211_txq *f_txq; -struct ath10k_txq *f_artxq; -int ret =0 ; -int max =HTC_HOST_MAX_MSG_PER_TX_BUNDLE ; +int ret; +u8 ac; -spin_lock_bh (&ar->txqs_lock); -if (list_empty (&artxq->list)) -list_add_tail (&artxq->list, &ar->txqs); +ath10k_htt_tx_txq_update (hw, txq); +if (ar->htt.tx_q_state.mode !=HTT_TX_MODE_SWITCH_PUSH ) +return ; - f_artxq = list_first_entry(&ar->txqs, struct ath10k_txq, list); - f_txq = container_of((void *)f_artxq, struct ieee80211_txq, drv_priv); -list_del_init (&f_artxq->list); + ac = txq->ac; +ieee80211_txq_schedule_start (hw, ac); + txq =ieee80211_next_txq (hw, ac); +if (!txq) + goto out; -while (ath10k_mac_tx_can_push (hw, f_txq) && max--) { - ret =ath10k_mac_tx_push_txq (hw, f_txq); +while (ath10k_mac_tx_can_push (hw, txq)) { + ret =ath10k_mac_tx_push_txq (hw, txq);if (ret <0 )break ; } -if (ret != -ENOENT ) -list_add_tail (&f_artxq->list, &ar->txqs); -spin_unlock_bh (&ar->txqs_lock); - -ath10k_htt_tx_txq_update (hw, f_txq); +ieee80211_return_txq (hw, txq);ath10k_htt_tx_txq_update (hw, txq); +out: +ieee80211_txq_schedule_end (hw, ac); }/* Must not be called with conf_mutex held as workers can use that also. */
drivers/net/wireless/ath/ath10k/mac.c int ath10k_mac_register(struct ath10k *ar) · line 8719
Quoted 8 lines
drivers/net/wireless/ath/ath10k/mac.c +2
-0@@ -8726,6 +8712,8 @@ int ath10k_mac_register(struct ath10k *ar)wiphy_ext_feature_set (ar->hw->wiphy,NL80211_EXT_FEATURE_CQM_RSSI_LIST ); + ar->hw->weight_multiplier =ATH10K_AIRTIME_WEIGHT_MULTIPLIER ; + ret =ieee80211_register_hw (ar->hw);if (ret) {ath10k_err (ar,"failed to register ieee80211: %d\n" , ret);
_______________________________________________
ath10k mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/ath10k
PATCH v6 4/4 ath10k: reporting estimated tx airtime for fairness
In reply to Toke Høiland-JørgensenFrom: Kan Yan <[email protected]>
Transmit airtime will be estimated from last tx rate used. Firmware report tx rate by peer stats. Airtime is computed on tx path and the same will be reported to mac80211 upon tx completion.
This change is based on Kan's orginal commit in Chromium tree ("CHROMIUM: ath10k: Implementing airtime fairness based TX scheduler")
ref: https://chromium-review.googlesource.com/588190
Tested on QCA4019 with firmware version 10.4-3.2.1.1-00015 Tested on QCA9984 with firmware version 10.4-3.9.0.1-00005
---
Rajkumar / Kan: Please check that I didn't mess anything up while rebasing this onto the current mac80211-next branch!
drivers/net/wireless/ath/ath10k/core.h | 2 + drivers/net/wireless/ath/ath10k/htt_rx.c | 1 + drivers/net/wireless/ath/ath10k/mac.c | 57 ++++++++++++++++++++++-- drivers/net/wireless/ath/ath10k/txrx.c | 4 ++ 4 files changed, 61 insertions(+), 3 deletions(-)
drivers/net/wireless/ath/ath10k/core.h +2 -0
@@ -126,6 +126,7 @@ struct ath10k_skb_cb {u8 flags;u8 eid;u16 msdu_id; +u16 airtime_est;struct ieee80211_vif *vif;struct ieee80211_txq *txq; } __packed;
@@ -498,6 +499,7 @@ struct ath10k_sta {u16 peer_id;struct rate_info txrate;struct ieee80211_tx_info tx_info; +u32 last_tx_bitrate;struct work_struct update_wk;u64 rx_duration;
drivers/net/wireless/ath/ath10k/htt_rx.c +1 -0
@@ -3078,6 +3078,7 @@ ath10k_update_per_peer_tx_stats(struct ath10k *ar, arsta->txrate.nss = txrate.nss; arsta->txrate.bw =ath10k_bw_to_mac80211_bw (txrate.bw); + arsta->last_tx_bitrate =cfg80211_calculate_bitrate (&arsta->txrate);if (sgi) arsta->txrate.flags |=RATE_INFO_FLAGS_SHORT_GI ;
drivers/net/wireless/ath/ath10k/mac.c +54 -3
100 lines not on this page · raw message
drivers/net/wireless/ath/ath10k/txrx.c +4 -0
@@ -95,6 +95,10 @@ int ath10k_txrx_tx_unref(struct ath10k_htt *htt,wake_up (&htt->empty_tx_wq);spin_unlock_bh (&htt->tx_lock); +if (txq && txq->sta) +ieee80211_sta_register_airtime (txq->sta, txq->tid, + skb_cb->airtime_est,0 ); +if (ar->dev_type !=ATH10K_DEV_TYPE_HL )dma_unmap_single (dev, skb_cb->paddr, msdu->len,DMA_TO_DEVICE );
Signature · 7 lines
2.20.1 _______________________________________________ ath10k mailing list [email protected] http://lists.infradead.org/mailman/listinfo/ath10k
Re: [PATCH v6 4/4] ath10k: reporting estimated tx airtime for fairness
Hi Toke,
This patch looks good to me. Great job on getting the airtime fairness scheduling framework done!
Quoted 190 lines · Toke Høiland-Jørgensen
From: Kan Yan <[email protected]>
Transmit airtime will be estimated from last tx rate used. Firmware report tx rate by peer stats. Airtime is computed on tx path and the same will be reported to mac80211 upon tx completion.
This change is based on Kan's orginal commit in Chromium tree ("CHROMIUM: ath10k: Implementing airtime fairness based TX scheduler")
ref: https://chromium-review.googlesource.com/588190Tested on QCA4019 with firmware version 10.4-3.2.1.1-00015 Tested on QCA9984 with firmware version 10.4-3.9.0.1-00005
Signed-off-by Kan Yan <[email protected]>[[email protected]: ported only the airtime computation]Signed-off-by Rajkumar Manoharan <[email protected]>[[email protected]: Rebase to mac80211-next, add test note]Signed-off-by Toke Høiland-Jørgensen <[email protected]>---
Rajkumar / Kan: Please check that I didn't mess anything up while rebasing this onto the current mac80211-next branch!
drivers/net/wireless/ath/ath10k/core.h | 2 + drivers/net/wireless/ath/ath10k/htt_rx.c | 1 + drivers/net/wireless/ath/ath10k/mac.c | 57 ++++++++++++++++++++++-- drivers/net/wireless/ath/ath10k/txrx.c | 4 ++ 4 files changed, 61 insertions(+), 3 deletions(-)drivers/net/wireless/ath/ath10k/core.h +2
-0@@ -126,6 +126,7 @@ struct ath10k_skb_cb {u8 flags;u8 eid;u16 msdu_id; +u16 airtime_est;struct ieee80211_vif *vif;struct ieee80211_txq *txq; } __packed;@@ -498,6 +499,7 @@ struct ath10k_sta {u16 peer_id;struct rate_info txrate;struct ieee80211_tx_info tx_info; +u32 last_tx_bitrate;struct work_struct update_wk;u64 rx_duration;drivers/net/wireless/ath/ath10k/htt_rx.c +1
-0@@ -3078,6 +3078,7 @@ ath10k_update_per_peer_tx_stats(struct ath10k *ar, arsta->txrate.nss = txrate.nss; arsta->txrate.bw =ath10k_bw_to_mac80211_bw (txrate.bw); + arsta->last_tx_bitrate =cfg80211_calculate_bitrate (&arsta->txrate);if (sgi) arsta->txrate.flags |=RATE_INFO_FLAGS_SHORT_GI ;drivers/net/wireless/ath/ath10k/mac.c +54
-3@@ -3544,7 +3544,7 @@ static void ath10k_tx_h_add_p2p_noa_ie(struct ath10k *ar,static void ath10k_mac_tx_h_fill_cb (struct ath10k *ar,struct ieee80211_vif *vif,struct ieee80211_txq *txq, -struct sk_buff *skb) +struct sk_buff *skb,u16 airtime) {struct ieee80211_hdr *hdr = (void *)skb->data;struct ath10k_skb_cb *cb =ATH10K_SKB_CB (skb);@@ -3561,6 +3561,7 @@ static void ath10k_mac_tx_h_fill_cb(struct ath10k *ar, cb->vif = vif; cb->txq = txq; + cb->airtime_est = airtime; }bool ath10k_mac_tx_frm_has_freq (struct ath10k *ar)@@ -3948,6 +3949,49 @@ static bool ath10k_mac_tx_can_push(struct ieee80211_hw *hw,return false; } +/* Return estimated airtime in microsecond, which is calculated using last +* reported TX rate. This is just a rough estimation because host driver has no +* knowledge of the actual transmit rate, retries or aggregation. If actual +* airtime can be reported by firmware, then delta between estimated and actual +* airtime can be adjusted from deficit. +*/ +#define IEEE80211_ATF_OVERHEAD 100/* IFS + some slot time */ +#define IEEE80211_ATF_OVERHEAD_IFS 16/* IFS only */ +static u16 ath10k_mac_update_airtime (struct ath10k *ar, +struct ieee80211_txq *txq, +struct sk_buff *skb) +{ +struct ath10k_sta *arsta; +u32 pktlen; +u16 airtime =0 ; + +if (!txq || !txq->sta) +return airtime; + +spin_lock_bh (&ar->data_lock); + arsta = (struct ath10k_sta *)txq->sta->drv_priv; + + pktlen = skb->len +38 ;/* Assume MAC header 30, SNAP 8 for most case */ +if (arsta->last_tx_bitrate) { +/* airtime in us, last_tx_bitrate in 100kbps */ + airtime = (pktlen *8 * (1000 /100 )) + / arsta->last_tx_bitrate; +/* overhead for media access time and IFS */ + airtime +=IEEE80211_ATF_OVERHEAD_IFS ; + }else { +/* This is mostly for throttle excessive BC/MC frames, and the +* airtime/rate doesn't need be exact. Airtime of BC/MC frames +* in 2G get some discount, which helps prevent very low rate +* frames from being blocked for too long. +*/ + airtime = (pktlen *8 * (1000 /100 )) /60 ;/* 6M */ + airtime +=IEEE80211_ATF_OVERHEAD ; + } +spin_unlock_bh (&ar->data_lock); + +return airtime; +} +int ath10k_mac_tx_push_txq (struct ieee80211_hw *hw,struct ieee80211_txq *txq) {@@ -3963,6 +4007,7 @@ int ath10k_mac_tx_push_txq(struct ieee80211_hw *hw,size_t skb_len;bool is_mgmt, is_presp;int ret; +u16 airtime;spin_lock_bh (&ar->htt.tx_lock); ret =ath10k_htt_tx_inc_pending (htt);@@ -3980,7 +4025,8 @@ int ath10k_mac_tx_push_txq(struct ieee80211_hw *hw,return -ENOENT ; } -ath10k_mac_tx_h_fill_cb (ar, vif, txq, skb); + airtime =ath10k_mac_update_airtime (ar, txq, skb); +ath10k_mac_tx_h_fill_cb (ar, vif, txq, skb, airtime); skb_len = skb->len; txmode =ath10k_mac_tx_h_get_txmode (ar, vif, sta, skb);@@ -4247,8 +4293,10 @@ static void ath10k_mac_op_tx(struct ieee80211_hw *hw,bool is_mgmt;bool is_presp;int ret; +u16 airtime; -ath10k_mac_tx_h_fill_cb (ar, vif, txq, skb); + airtime =ath10k_mac_update_airtime (ar, txq, skb); +ath10k_mac_tx_h_fill_cb (ar, vif, txq, skb, airtime); txmode =ath10k_mac_tx_h_get_txmode (ar, vif, sta, skb); txpath =ath10k_mac_tx_h_get_txpath (ar, skb, txmode);@@ -8603,6 +8651,9 @@ int ath10k_mac_register(struct ath10k *ar)wiphy_ext_feature_set (ar->hw->wiphy,NL80211_EXT_FEATURE_ACK_SIGNAL_SUPPORT ); +if (ath10k_peer_stats_enabled (ar)) +wiphy_ext_feature_set (ar->hw->wiphy, +NL80211_EXT_FEATURE_AIRTIME_FAIRNESS );/* * on LL hardware queues are managed entirely by the FW * so we only advertise to mac we can do the queues thing drivers/net/wireless/ath/ath10k/txrx.c +4
-1@@ -95,6 +95,10 @@ int ath10k_txrx_tx_unref(struct ath10k_htt *htt,wake_up (&htt->empty_tx_wq);spin_unlock_bh (&htt->tx_lock); +if (txq && txq->sta) +ieee80211_sta_register_airtime (txq->sta, txq->tid, + skb_cb->airtime_est,0 ); +if (ar->dev_type !=ATH10K_DEV_TYPE_HL )dma_unmap_single (dev, skb_cb->paddr, msdu->len,DMA_TO_DEVICE ); --
Quoted 2 lines
2.20.1
_______________________________________________
ath10k mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/ath10k
Re: [PATCH v6 4/4] ath10k: reporting estimated tx airtime for fairness
Quoted 4 lines · Kan Yan
Hi Toke,
This patch looks good to me. Great job on getting the airtime fairness scheduling framework done!
Great, thanks for checking! Have another patch to test on top of this series, then we should look into getting the airtime queue limit patch into mac80211 as well :)
-Toke
Re: [PATCH v6 4/4] ath10k: reporting estimated tx airtime for fairness
In reply to Toke Høiland-JørgensenQuoted 12 lines · Toke Høiland-Jørgensen
The airtime of a transmitted frame will be estimated from last used tx rate which the firmware reports with the peer stats feature (
WMI_SERVICE_PEER_STATS). The airtime is computed on the tx path and it will be reported to mac80211 upon tx completion.This change is based on Kan's orginal commit in Chromium tree ("CHROMIUM: ath10k: Implementing airtime fairness based TX scheduler")
ref: https://chromium-review.googlesource.com/588190Tested on QCA4019 with firmware version 10.4-3.2.1.1-00015 Tested on QCA9984 with firmware version 10.4-3.9.0.1-00005
Quoted 6 lines
Signed-off-by Kan Yan <[email protected]>[[email protected]: ported only the airtime computation]Signed-off-by Rajkumar Manoharan <[email protected]>[[email protected]: Rebase to mac80211-next, add test note]Signed-off-by Toke Høiland-Jørgensen <[email protected]>Signed-off-by Kalle Valo <[email protected]>
There was a trivial conflict, please check my resolution in the pending branch. I also reworded the commit log a bit.
$ git am -s --reject 10775551.mbox
Applying: ath10k: reporting estimated tx airtime for fairness
Checking patch drivers/net/wireless/ath/ath10k/core.h...
Checking patch drivers/net/wireless/ath/ath10k/htt_rx.c...
Hunk #1 succeeded at 3080 (offset 2 lines).
Checking patch drivers/net/wireless/ath/ath10k/mac.c...
Hunk #1 succeeded at 3566 (offset 22 lines).
Hunk #2 succeeded at 3583 (offset 22 lines).
Hunk #3 succeeded at 3971 (offset 22 lines).
Hunk #4 succeeded at 4029 (offset 22 lines).
Hunk #5 succeeded at 4047 (offset 22 lines).
Hunk #6 succeeded at 4315 (offset 22 lines).
Hunk #7 succeeded at 8671 (offset 20 lines).
Checking patch drivers/net/wireless/ath/ath10k/txrx.c...
error: while searching for:
wake_up(&htt->empty_tx_wq);
spin_unlock_bh(&htt->tx_lock); if (ar->dev_type != ATH10K_DEV_TYPE_HL)
dma_unmap_single(dev, skb_cb->paddr, msdu->len, DMA_TO_DEVICE);error: patch failed: drivers/net/wireless/ath/ath10k/txrx.c:95 Applied patch drivers/net/wireless/ath/ath10k/core.h cleanly. Applied patch drivers/net/wireless/ath/ath10k/htt_rx.c cleanly. Applied patch drivers/net/wireless/ath/ath10k/mac.c cleanly. Applying patch drivers/net/wireless/ath/ath10k/txrx.c with 1 reject... Rejected hunk #1.
Patch failed at 0001 ath10k: reporting estimated tx airtime for fairness
Signature · 3 lines
https://patchwork.kernel.org/patch/10775551/ https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
Re: [PATCH v6 4/4] ath10k: reporting estimated tx airtime for fairness
In reply to Toke Høiland-JørgensenQuoted 12 lines · Toke Høiland-Jørgensen
The airtime of a transmitted frame will be estimated from last used tx rate which the firmware reports with the peer stats feature (
WMI_SERVICE_PEER_STATS). The airtime is computed on the tx path and it will be reported to mac80211 upon tx completion.This change is based on Kan's orginal commit in Chromium tree ("CHROMIUM: ath10k: Implementing airtime fairness based TX scheduler")
ref: https://chromium-review.googlesource.com/588190Tested on QCA4019 with firmware version 10.4-3.2.1.1-00015 Tested on QCA9984 with firmware version 10.4-3.9.0.1-00005
Quoted 6 lines
Signed-off-by Kan Yan <[email protected]>[[email protected]: ported only the airtime computation]Signed-off-by Rajkumar Manoharan <[email protected]>[[email protected]: Rebase to mac80211-next, add test note]Signed-off-by Toke Høiland-Jørgensen <[email protected]>Signed-off-by Kalle Valo <[email protected]>
There was a trivial conflict, please check my resolution in the pending branch. I also reworded the commit log a bit.
$ git am -s --reject 10775551.mbox
Applying: ath10k: reporting estimated tx airtime for fairness
Checking patch drivers/net/wireless/ath/ath10k/core.h...
Checking patch drivers/net/wireless/ath/ath10k/htt_rx.c...
Hunk #1 succeeded at 3080 (offset 2 lines).
Checking patch drivers/net/wireless/ath/ath10k/mac.c...
Hunk #1 succeeded at 3566 (offset 22 lines).
Hunk #2 succeeded at 3583 (offset 22 lines).
Hunk #3 succeeded at 3971 (offset 22 lines).
Hunk #4 succeeded at 4029 (offset 22 lines).
Hunk #5 succeeded at 4047 (offset 22 lines).
Hunk #6 succeeded at 4315 (offset 22 lines).
Hunk #7 succeeded at 8671 (offset 20 lines).
Checking patch drivers/net/wireless/ath/ath10k/txrx.c...
error: while searching for:
wake_up(&htt->empty_tx_wq);
spin_unlock_bh(&htt->tx_lock); if (ar->dev_type != ATH10K_DEV_TYPE_HL)
dma_unmap_single(dev, skb_cb->paddr, msdu->len, DMA_TO_DEVICE);error: patch failed: drivers/net/wireless/ath/ath10k/txrx.c:95 Applied patch drivers/net/wireless/ath/ath10k/core.h cleanly. Applied patch drivers/net/wireless/ath/ath10k/htt_rx.c cleanly. Applied patch drivers/net/wireless/ath/ath10k/mac.c cleanly. Applying patch drivers/net/wireless/ath/ath10k/txrx.c with 1 reject... Rejected hunk #1.
Patch failed at 0001 ath10k: reporting estimated tx airtime for fairness
Signature · 9 lines
https://patchwork.kernel.org/patch/10775551/ https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches _______________________________________________ ath10k mailing list [email protected] http://lists.infradead.org/mailman/listinfo/ath10k