ath10k: migrate to mac80211 txq scheduling
RFC 1/2 ath10k: migrate to mac80211 txq scheduling
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.
--- drivers/net/wireless/ath/ath10k/core.c | 2 - drivers/net/wireless/ath/ath10k/core.h | 3 -- drivers/net/wireless/ath/ath10k/htc.h | 1 - drivers/net/wireless/ath/ath10k/htt_rx.c | 8 +++ drivers/net/wireless/ath/ath10k/mac.c | 87 +++++++++----------------------- 5 files changed, 33 insertions(+), 68 deletions(-)
drivers/net/wireless/ath/ath10k/core.c +0 -2
@@ -3068,9 +3068,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
@@ -1054,10 +1054,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 @@*/ #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
@@ -2379,6 +2379,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" );
@@ -2451,8 +2452,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 ;
@@ -2460,6 +2466,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 +25 -62
131 lines not on this page · raw message
Signature · 1 line
1.9.1
RFC 2/2 ath10k: reporting estimated tx airtime for fairness
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.
--- drivers/net/wireless/ath/ath10k/core.h | 2 ++ drivers/net/wireless/ath/ath10k/htt_rx.c | 1 + drivers/net/wireless/ath/ath10k/mac.c | 58 ++++++++++++++++++++++++++++++-- drivers/net/wireless/ath/ath10k/txrx.c | 4 +++ 4 files changed, 62 insertions(+), 3 deletions(-)
drivers/net/wireless/ath/ath10k/core.h +2 -0
@@ -123,6 +123,7 @@ struct ath10k_skb_cb {u8 flags;u8 eid;u16 msdu_id; +u16 airtime_est;struct ieee80211_vif *vif;struct ieee80211_txq *txq; } __packed;
@@ -493,6 +494,7 @@ struct ath10k_sta {u32 smps;u16 peer_id;struct rate_info txrate; +u32 last_tx_bitrate;struct work_struct update_wk;u64 rx_duration;
drivers/net/wireless/ath/ath10k/htt_rx.c +1 -0
@@ -2809,6 +2809,7 @@ static inline int ath10k_get_legacy_rate_idx(struct ath10k *ar, u8 rate) 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 (ath10k_debug_is_extd_tx_stats_enabled (ar)) ath10k_accumulate_per_peer_tx_stats(ar, arsta, peer_stats,
drivers/net/wireless/ath/ath10k/mac.c +55 -3
101 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 · 1 line
1.9.1
Re: [RFC 2/2] ath10k: reporting estimated tx airtime for fairness
Quoted 163 lines · Rajkumar Manoharan
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.
Signed-off-by Kan Yan <[email protected]>Signed-off-by Rajkumar Manoharan <[email protected]>--- drivers/net/wireless/ath/ath10k/core.h | 2 ++ drivers/net/wireless/ath/ath10k/htt_rx.c | 1 + drivers/net/wireless/ath/ath10k/mac.c | 58 ++++++++++++++++++++++++++++++-- drivers/net/wireless/ath/ath10k/txrx.c | 4 +++ 4 files changed, 62 insertions(+), 3 deletions(-)drivers/net/wireless/ath/ath10k/core.h +2
-0@@ -123,6 +123,7 @@ struct ath10k_skb_cb {u8 flags;u8 eid;u16 msdu_id; +u16 airtime_est;struct ieee80211_vif *vif;struct ieee80211_txq *txq; } __packed;@@ -493,6 +494,7 @@ struct ath10k_sta {u32 smps;u16 peer_id;struct rate_info txrate; +u32 last_tx_bitrate;struct work_struct update_wk;u64 rx_duration;drivers/net/wireless/ath/ath10k/htt_rx.c +1
-0@@ -2809,6 +2809,7 @@ static inline int ath10k_get_legacy_rate_idx(struct ath10k *ar, u8 rate) 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 (ath10k_debug_is_extd_tx_stats_enabled (ar)) ath10k_accumulate_per_peer_tx_stats(ar, arsta, peer_stats,drivers/net/wireless/ath/ath10k/mac.c +55
-3@@ -3528,7 +3528,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);@@ -3545,6 +3545,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)@@ -3932,6 +3933,50 @@ 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 ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; +struct ath10k_sta *arsta; +u32 pktlen; +u16 airtime =0 ; + +if (!txq || !txq->sta || !ieee80211_is_data (hdr->frame_control)) +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) {@@ -3947,6 +3992,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);@@ -3964,7 +4010,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);@@ -4230,8 +4277,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);@@ -8446,6 +8495,9 @@ int ath10k_mac_register(struct ath10k *ar)wiphy_ext_feature_set (ar->hw->wiphy,NL80211_EXT_FEATURE_DATA_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 +0
-0
drivers/net/wireless/ath/ath10k/txrx.c int ath10k_txrx_tx_unref(struct ath10k_htt *htt, · line 101
Quoted 7 lines
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 ); +
So this just uses the calculated airtime based on rate and size? Wasn't there supposed to be an airtime usage value reported by the firmware? :)
-Toke
Re: [RFC 2/2] ath10k: reporting estimated tx airtime for fairness
Quoted 3 lines · Toke Høiland-Jørgensen
So this just uses the calculated airtime based on rate and size? Wasn't there supposed to be an airtime usage value reported by the firmware? :)
Firmware interface changes are in progress. Airtime for sta/tid will be reported via htt tx-compl and rx ind messages. Meantime I thought it would be useful to use Kan's changes for ATF validation in ath10k using existing firmware. :)
-Rajkumar
Re: [RFC 2/2] ath10k: reporting estimated tx airtime for fairness
Quoted 8 lines · Rajkumar Manoharan
Quoted 3 lines · Toke Høiland-Jørgensen
So this just uses the calculated airtime based on rate and size? Wasn't there supposed to be an airtime usage value reported by the firmware? :)
Firmware interface changes are in progress. Airtime for sta/tid will be reported via htt tx-compl and rx ind messages. Meantime I thought it would be useful to use Kan's changes for ATF validation in ath10k using existing firmware. :)
Maybe you can get the firmware guys to report the tx rate in the tx-completion (like I have been doing for years in my ath10k-ct firmware)? Then let the host do the air-time calculating?
I'll give them firmware patches if the want :)
Thanks,
Ben
Quoted 3 lines
-Rajkumar
Signature · 2 lines
Ben Greear <[email protected]> Candela Technologies Inc http://www.candelatech.com
Quoted 25 lines · Rajkumar Manoharan
(quoted diff) +0
-18@@ -4293,32 +4281,7 @@ static void ath10k_mac_op_tx(struct ieee80211_hw *hw, 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; - - spin_lock_bh(&ar->txqs_lock); - if (list_empty(&artxq->list)) - list_add_tail(&artxq->list, &ar->txqs); - - 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); - - while (ath10k_mac_tx_can_push(hw, f_txq) && max--) { - ret = ath10k_mac_tx_push_txq(hw, f_txq); - if (ret < 0)
Review static void ath10k_mac_op_tx(struct ieee80211_hw · line 4287
Quoted 10 lines
(quoted diff) +1
-8- 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); - ath10k_htt_tx_txq_update(hw, txq); + ath10k_mac_schedule_txq(hw, txq->ac); }
With below change I were able to fix the performance impact in multiclient scenario. Will fold them in next version.
drivers/net/wireless/ath/ath10k/mac.c +20 -2
@@ -4473,7 +4473,26 @@ static void ath10k_mac_op_tx(struct ieee80211_hw *hw,static void ath10k_mac_op_wake_tx_queue (struct ieee80211_hw *hw,struct ieee80211_txq *txq) { -ath10k_mac_schedule_txq (hw, txq->ac); +u8 ac = txq->ac; +int ret =0 ; + +ieee80211_txq_schedule_start (hw, ac); + txq =ieee80211_next_txq (hw, ac); +ieee80211_txq_schedule_end (hw, ac); +if (!txq) +return ; + +while (ath10k_mac_tx_can_push (hw, txq)) { + ret =ath10k_mac_tx_push_txq (hw, txq); +if (ret <0 ) +break ; + } +if (ret == -EBUSY ) { +ieee80211_txq_schedule_start (hw, ac); +ieee80211_return_txq (hw, txq); +ieee80211_txq_schedule_end (hw, ac); + } +ath10k_htt_tx_txq_update (hw, txq); } -Rajkumar
Re: [RFC 2/2] ath10k: reporting estimated tx airtime for fairness
In reply to Ben GreearQuoted 10 lines · Ben Greear
Quoted 8 lines · Rajkumar Manoharan
Quoted 3 lines · Toke Høiland-Jørgensen
So this just uses the calculated airtime based on rate and size? Wasn't there supposed to be an airtime usage value reported by the firmware? :)
Firmware interface changes are in progress. Airtime for sta/tid will be reported via htt tx-compl and rx ind messages. Meantime I thought it would be useful to use Kan's changes for ATF validation in ath10k using existing firmware. :)
Quoted 6 lines
Maybe you can get the firmware guys to report the tx rate in the tx-completion (like I have been doing for years in my ath10k-ct firmware)? Then let the host do the air-time calculating?
I'll give them firmware patches if the want :)
Ben,
As you know, it needs cleanup in firmware to free up space for new interface changes. Most of time we try to leverage rsvd/unused slots. I am aware of that you did a lot of clean up in CT firmware which is quite hard in official firmware as it also has to support prop. releases. Kalle can answer much better.
-Rajkumar
Re: [RFC 2/2] ath10k: reporting estimated tx airtime for fairness
Quoted 15 lines · Rajkumar Manoharan
Quoted 14 lines · Ben Greear
Quoted 8 lines · Rajkumar Manoharan
Quoted 3 lines · Toke Høiland-Jørgensen
So this just uses the calculated airtime based on rate and size? Wasn't there supposed to be an airtime usage value reported by the firmware? :)
Firmware interface changes are in progress. Airtime for sta/tid will be reported via htt tx-compl and rx ind messages. Meantime I thought it would be useful to use Kan's changes for ATF validation in ath10k using existing firmware. :)
Maybe you can get the firmware guys to report the tx rate in the tx-completion (like I have been doing for years in my ath10k-ct firmware)? Then let the host do the air-time calculating?
Quoted 8 lines
Quoted 2 lines
I'll give them firmware patches if the want :)
Ben,
As you know, it needs cleanup in firmware to free up space for new interface changes. Most of time we try to leverage rsvd/unused slots. I am aware of that you did a lot of clean up in CT firmware which is quite hard in official firmware as it also has to support prop. releases. Kalle can answer much better.
There are hard ways to get more space in the firmware, but there are also some easier ones (un-used members in structs, better natural packing, and such).
If there was a QCA firmware engineer that could promptly discuss these things with me and apply patches, I can feed them patches.
And, the 10.4 firmware already has some extra space in its tx descriptor that can be used to report tx-status without much additional code or RAM. The wave-1 stuff needs some more serious hacking and does consume more memory.
Thanks,
Ben
Signature · 2 lines
Ben Greear <[email protected]> Candela Technologies Inc http://www.candelatech.com