[RFC v2 2/2] ath10k: reporting estimated tx airtime for fairness

2018-09-28 Thread 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 
Signed-off-by: Rajkumar Manoharan 
---
 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 d3e20aaf8023..4bfc370bf659 100644
--- a/drivers/net/wireless/ath/ath10k/core.h
+++ b/drivers/net/wireless/ath/ath10k/core.h
@@ -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;
diff --git a/drivers/net/wireless/ath/ath10k/htt_rx.c 
b/drivers/net/wireless/ath/ath10k/htt_rx.c
index f2aaa2f7a022..f1de9fc09d9f 100644
--- a/drivers/net/wireless/ath/ath10k/htt_rx.c
+++ b/drivers/net/wireless/ath/ath10k/htt_rx.c
@@ -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(>txrate);
 
if (ath10k_debug_is_extd_tx_stats_enabled(ar))
ath10k_accumulate_per_peer_tx_stats(ar, arsta, peer_stats,
diff --git a/drivers/net/wireless/ath/ath10k/mac.c 
b/drivers/net/wireless/ath/ath10k/mac.c
index 3b441179a36c..7021e3b67cf0 100644
--- a/drivers/net/wireless/ath/ath10k/mac.c
+++ b/drivers/net/wireless/ath/ath10k/mac.c
@@ -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,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
+* frames from being blocked for too long.
+*/
+   airtime = (pktlen * 8 * (1000 / 100)) / 60; /* 6M */
+   airtime += IEEE80211_ATF_OVERHEAD;
+   }
+   spin_unlock_bh(>data_lock);
+
+   return airtime;
+}
+
 int ath10k_mac_tx_push_txq(struct ieee80211_hw *hw,
   struct ieee80211_txq *txq)
 {
@@ -3947,6 +3991,7 @@ int ath10k_mac_tx_push_txq(struct ieee80211_hw *hw,
size_t skb_len;
bool is_mgmt, is_presp;
int ret;
+   u16 airtime;
 

Re: [RFC 2/2] ath10k: reporting estimated tx airtime for fairness

2018-09-28 Thread Ben Greear

On 09/28/2018 03:47 PM, Rajkumar Manoharan wrote:

On 2018-09-28 12:57, Ben Greear wrote:

On 09/28/2018 12:47 PM, Rajkumar Manoharan wrote:

On 2018-09-28 08:25, Toke Høiland-Jørgensen wrote:


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


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

--
Ben Greear 
Candela Technologies Inc  http://www.candelatech.com


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


Re: [RFC 2/2] ath10k: reporting estimated tx airtime for fairness

2018-09-28 Thread Rajkumar Manoharan

On 2018-09-28 12:57, Ben Greear wrote:

On 09/28/2018 12:47 PM, Rajkumar Manoharan wrote:

On 2018-09-28 08:25, Toke Høiland-Jørgensen wrote:

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


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

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


Re: [RFC 1/2] ath10k: migrate to mac80211 txq scheduling

2018-09-28 Thread Rajkumar Manoharan

On 2018-09-26 17:41, Rajkumar Manoharan wrote:
@@ -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(>txqs_lock);
-   if (list_empty(>list))
-   list_add_tail(>list, >txqs);
-
-   f_artxq = list_first_entry(>txqs, struct ath10k_txq, list);
-	f_txq = container_of((void *)f_artxq, struct ieee80211_txq, 
drv_priv);

-   list_del_init(_artxq->list);
-
-   while (ath10k_mac_tx_can_push(hw, f_txq) && max--) {
-   ret = ath10k_mac_tx_push_txq(hw, f_txq);
-   if (ret < 0)
-   break;
-   }
-   if (ret != -ENOENT)
-   list_add_tail(_artxq->list, >txqs);
-   spin_unlock_bh(>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.

diff --git a/drivers/net/wireless/ath/ath10k/mac.c 
b/drivers/net/wireless/ath/ath10k/mac.c

index 6da64412cc14..965aaa731f04 100644
--- a/drivers/net/wireless/ath/ath10k/mac.c
+++ b/drivers/net/wireless/ath/ath10k/mac.c
@@ -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

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


Re: [RFC 2/2] ath10k: reporting estimated tx airtime for fairness

2018-09-28 Thread Rajkumar Manoharan

On 2018-09-28 08:25, Toke Høiland-Jørgensen wrote:


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

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


Update board-2.bin files in linux-firmware

2018-09-28 Thread Hauke Mehrtens
Hi,

the ath10k-firmware repository already contains updated board-2.bin
files with support for more devices. Please also update the board-2.bin
files shipped in the linux-firmware repository as they are normally
taken by distributions.

Hauke



signature.asc
Description: OpenPGP digital signature
___
ath10k mailing list
ath10k@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/ath10k


Re: [RFC v4 2/2] ath10k: report tx rate using ieee80211_tx_rate_update()

2018-09-28 Thread Peter Oh



On 09/28/2018 12:10 PM, Peter Oh wrote:
>
> On 09/24/2018 12:10 AM, Anilkumar Kolli wrote:
>> diff --git a/drivers/net/wireless/ath/ath10k/htt_rx.c 
>> b/drivers/net/wireless/ath/ath10k/htt_rx.c
>> index f2405258a6d3..355c39a0486c 100644
>> --- a/drivers/net/wireless/ath/ath10k/htt_rx.c
>> +++ b/drivers/net/wireless/ath/ath10k/htt_rx.c
>> @@ -2753,8 +2753,11 @@ static inline int ath10k_get_legacy_rate_idx(struct 
>> ath10k *ar, u8 rate)
>>  struct ath10k_per_peer_tx_stats *peer_stats)
>>{
>>  struct ath10k_sta *arsta = (struct ath10k_sta *)sta->drv_priv;
>> -u8 rate = 0, rate_idx = 0, sgi;
>> +struct ieee80211_chanctx_conf *conf = NULL;
>>  struct rate_info txrate;
>> +u8 rate = 0, sgi;
>> +int rate_idx = 0;
> type mismatch. ath10k_accumulate_per_peer_tx_stats() take u8 rate_idx,
> but you're passing int.
It looks like you better change return type of 
ath10k_get_legacy_rate_idx() from int to u8 by using u8 i; instead of 
int i inside of ath10k_get_legacy_rate_idx() and keep using rate_idx as 
u8 here.

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


Re: [RFC v4 2/2] ath10k: report tx rate using ieee80211_tx_rate_update()

2018-09-28 Thread Peter Oh



On 09/24/2018 12:10 AM, Anilkumar Kolli wrote:
> diff --git a/drivers/net/wireless/ath/ath10k/htt_rx.c 
> b/drivers/net/wireless/ath/ath10k/htt_rx.c
> index f2405258a6d3..355c39a0486c 100644
> --- a/drivers/net/wireless/ath/ath10k/htt_rx.c
> +++ b/drivers/net/wireless/ath/ath10k/htt_rx.c
> @@ -2753,8 +2753,11 @@ static inline int ath10k_get_legacy_rate_idx(struct 
> ath10k *ar, u8 rate)
>   struct ath10k_per_peer_tx_stats *peer_stats)
>   {
>   struct ath10k_sta *arsta = (struct ath10k_sta *)sta->drv_priv;
> - u8 rate = 0, rate_idx = 0, sgi;
> + struct ieee80211_chanctx_conf *conf = NULL;
>   struct rate_info txrate;
> + u8 rate = 0, sgi;
> + int rate_idx = 0;
type mismatch. ath10k_accumulate_per_peer_tx_stats() take u8 rate_idx, 
but you're passing int.

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


Re: [RFC 2/2] ath10k: reporting estimated tx airtime for fairness

2018-09-28 Thread Toke Høiland-Jørgensen
Rajkumar Manoharan  writes:

> 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 
> Signed-off-by: Rajkumar Manoharan 
> ---
>  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(-)
>
> diff --git a/drivers/net/wireless/ath/ath10k/core.h 
> b/drivers/net/wireless/ath/ath10k/core.h
> index d3e20aaf8023..4bfc370bf659 100644
> --- a/drivers/net/wireless/ath/ath10k/core.h
> +++ b/drivers/net/wireless/ath/ath10k/core.h
> @@ -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;
> diff --git a/drivers/net/wireless/ath/ath10k/htt_rx.c 
> b/drivers/net/wireless/ath/ath10k/htt_rx.c
> index f2aaa2f7a022..f1de9fc09d9f 100644
> --- a/drivers/net/wireless/ath/ath10k/htt_rx.c
> +++ b/drivers/net/wireless/ath/ath10k/htt_rx.c
> @@ -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(>txrate);
>  
>   if (ath10k_debug_is_extd_tx_stats_enabled(ar))
>   ath10k_accumulate_per_peer_tx_stats(ar, arsta, peer_stats,
> diff --git a/drivers/net/wireless/ath/ath10k/mac.c 
> b/drivers/net/wireless/ath/ath10k/mac.c
> index d4648b22ad64..a694dae6f024 100644
> --- a/drivers/net/wireless/ath/ath10k/mac.c
> +++ b/drivers/net/wireless/ath/ath10k/mac.c
> @@ -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(>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(>data_lock);
> +
> + return 

WLE900VX / QCA9880 poor TCP performances

2018-09-28 Thread Gilbert Moisio
Hi, using linux-firmware 1.173.1 as well as 1.175 with Ubuntu 18.04
kernel 4.15.0-34-generic, I got poor TCP performances.

For a connection with a Data Rates going from 975 Mbps to 1,170 Mbps I
got the following results with Iperf3 3.1.3:

UDP during 60 secondes:
Max --> 480 Mbps
Min --> 318 Mbps
0.92% lost

TCP during 60 secondes:
Start with slow throughput during 20s
Max --> 244 Mbps
Min --> 21.5 Mbps
Avr --> 177 Mbps

Thanks
Regards

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