Re: [PATCH v6 4/4] ath10k: reporting estimated tx airtime for fairness

2019-02-11 Thread Kalle Valo
Toke Høiland-Jørgensen wrote:

> 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/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-5
> 
> Signed-off-by: Kan Yan 
> [rmano...@codeaurora.org: ported only the airtime computation]
> Signed-off-by: Rajkumar Manoharan 
> [t...@redhat.com: Rebase to mac80211-next, add test note]
> Signed-off-by: Toke Høiland-Jørgensen 
> Signed-off-by: Kalle Valo 

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(>empty_tx_wq);
spin_unlock_bh(>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

-- 
https://patchwork.kernel.org/patch/10775551/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches


___
ath10k mailing list
ath10k@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/ath10k


Re: [PATCH v6 4/4] ath10k: reporting estimated tx airtime for fairness

2019-01-25 Thread Toke Høiland-Jørgensen
Kan Yan  writes:

> 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

___
ath10k mailing list
ath10k@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/ath10k


Re: [PATCH v6 4/4] ath10k: reporting estimated tx airtime for fairness

2019-01-24 Thread Kan Yan
Hi Toke,

This patch looks good to me. Great job on getting the airtime fairness
scheduling framework done!


On Tue, Jan 22, 2019 at 6:21 AM Toke Høiland-Jørgensen  wrote:
>
> From: Kan Yan 
>
> 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-5
>
> Signed-off-by: Kan Yan 
> [rmano...@codeaurora.org: ported only the airtime computation]
> Signed-off-by: Rajkumar Manoharan 
> [t...@redhat.com: Rebase to mac80211-next, add test note]
> Signed-off-by: Toke Høiland-Jørgensen 
> ---
>
> 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(-)
>
> diff --git a/drivers/net/wireless/ath/ath10k/core.h 
> b/drivers/net/wireless/ath/ath10k/core.h
> index 28cecf7375f8..4528a6e47b8d 100644
> --- a/drivers/net/wireless/ath/ath10k/core.h
> +++ b/drivers/net/wireless/ath/ath10k/core.h
> @@ -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;
> diff --git a/drivers/net/wireless/ath/ath10k/htt_rx.c 
> b/drivers/net/wireless/ath/ath10k/htt_rx.c
> index dc9895f2eb9d..6a93b57900ae 100644
> --- a/drivers/net/wireless/ath/ath10k/htt_rx.c
> +++ b/drivers/net/wireless/ath/ath10k/htt_rx.c
> @@ -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(>txrate);
> if (sgi)
> arsta->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI;
>
> diff --git a/drivers/net/wireless/ath/ath10k/mac.c 
> b/drivers/net/wireless/ath/ath10k/mac.c
> index cf7fdf72e990..b13dcb4533cb 100644
> --- a/drivers/net/wireless/ath/ath10k/mac.c
> +++ b/drivers/net/wireless/ath/ath10k/mac.c
> @@ -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(>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))
> +   

[PATCH v6 4/4] ath10k: reporting estimated tx airtime for fairness

2019-01-22 Thread Toke Høiland-Jørgensen
From: Kan Yan 

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-5

Signed-off-by: Kan Yan 
[rmano...@codeaurora.org: ported only the airtime computation]
Signed-off-by: Rajkumar Manoharan 
[t...@redhat.com: Rebase to mac80211-next, add test note]
Signed-off-by: Toke Høiland-Jørgensen 
---

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(-)

diff --git a/drivers/net/wireless/ath/ath10k/core.h 
b/drivers/net/wireless/ath/ath10k/core.h
index 28cecf7375f8..4528a6e47b8d 100644
--- a/drivers/net/wireless/ath/ath10k/core.h
+++ b/drivers/net/wireless/ath/ath10k/core.h
@@ -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;
diff --git a/drivers/net/wireless/ath/ath10k/htt_rx.c 
b/drivers/net/wireless/ath/ath10k/htt_rx.c
index dc9895f2eb9d..6a93b57900ae 100644
--- a/drivers/net/wireless/ath/ath10k/htt_rx.c
+++ b/drivers/net/wireless/ath/ath10k/htt_rx.c
@@ -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(>txrate);
if (sgi)
arsta->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI;
 
diff --git a/drivers/net/wireless/ath/ath10k/mac.c 
b/drivers/net/wireless/ath/ath10k/mac.c
index cf7fdf72e990..b13dcb4533cb 100644
--- a/drivers/net/wireless/ath/ath10k/mac.c
+++ b/drivers/net/wireless/ath/ath10k/mac.c
@@ -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(>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
+