Re: [PATCH v2] ath10k: Implement get_expected_throughput callback

2018-04-16 Thread akolli

On 2018-04-14 01:54, Peter Oh wrote:

On 04/13/2018 06:48 AM, Kalle Valo wrote:

Sven Eckelmann  writes:

But of course, I cannot say much about how the rate control from QCA 
works and

in which form these information are already available.

If you want to know the average PHY rate then wouldn't it be better 
to report
the rates to one of the upper layers and let them to the averaging? 
Similar to

what there already is for NL80211_STA_INFO_CHAIN_SIGNAL
(NL80211_STA_INFO_CHAIN_SIGNAL_AVG) just for 
NL80211_STA_INFO_TX_BITRATE/
NL80211_STA_INFO_RX_BITRATE. Not sure whether this makes sense or 
whether

someone has an use-case for it.

Sounds like a good idea, but I don't see it preventing to apply this
patch. We can always change the implementation later as this is just
communication between ath10k and mac80211, right?


I agree with Sven on the usage or expectation of
get_expected_throughput cabllback.
It's not really ab expected throughput implementation.
However I'm with Kalle about approving this patch as Sven also
mentioned "here sounds a little bit like in "Our medical doctor would
ideally not decapitate each patient but we have at least an MD"".
I could improve it once merged since there are more members in
ath10k_per_peer_tx_stats useful such as succ_bytes, failed_bytes,
duration, and etc.


On each packet sent successfully, driver has the success_bytes details.
Throughput calculation can be done using these bytes and tx rate 
(tx_rate * bytes),

send this average value to mac80211. is this you are thinking of?

Thanks,
Anil.


Re: [PATCH v2] ath10k: Implement get_expected_throughput callback

2018-03-28 Thread akolli

On 2018-03-26 12:52, Sven Eckelmann wrote:

On Freitag, 23. März 2018 19:37:14 CEST Anilkumar Kolli wrote:

+static u32 ath10k_get_expected_throughput(struct ieee80211_hw *hw,
+ struct ieee80211_sta *sta)
+{
+   struct ath10k_sta *arsta = (struct ath10k_sta *)sta->drv_priv;
+
+   return ewma_sta_txrate_read(>ave_sta_txrate);
+}


On Freitag, 23. März 2018 19:11:48 CEST ako...@codeaurora.org wrote:

> Antonio and Felix, please correct me when this statement is incorrect.
>
> The expected_throughput as initially implemented for minstrel(_ht) is
> not
> about the raw physical bitrate but about the throughput which is
> expected for
> things running on top of the wifi link. See
> 
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=cca674d47e59665630f3005291b61bb883015fc5
> for more details
>
> when I interpret your change correctly then your it doesn't get the
> information about packet loss or aggregation and doesn't do anything
> convert
> from raw physical rate to something the user could get see. It will
> just
> overestimate the throughput for ath10k links and thus give wrong
> information
> to routing algorithms. This could for example cause them to prefer
> links over
> ath10k based hw when mt76 would actually provide a significant better
> throughput.
>
> Beside that - why is the ave_sta_txrate only filled when with new
> information
> when someone requests the current expected_throughput via
> get_expected_throughput. I would have expected that it is filled
> everytime you
> get new information about the current rate from the firmware
> (ath10k_sta_statistics).
>
Yes. ideally it should be doing the rate avg. of all the sent packets.


No, not the PHY rate average - but the "throughput avg". And the 
"ideally"

here sounds a little bit like in "Our medical doctor would ideally not
decapitate each patient but we have at least an MD".



The rate average and throughput are relative. no?

- Anil.


Re: [PATCH] ath10k: Implement get_expected_throughput callback

2018-03-23 Thread akolli


On 2018-03-23 19:14, Johannes Berg wrote:

On Fri, 2018-03-23 at 19:11 +0530, ako...@codeaurora.org wrote:


> > +
> > +   sinfo->expected_throughput =
> > +
> > ewma_sta_txrate_read(>ave_sta_txrate);
> > +   sinfo->filled |=
> > BIT(NL80211_STA_INFO_EXPECTED_THROUGHPUT);
> > +}



Yes. This looks redundant, I will remove this line,
  sinfo->filled |= BIT(NL80211_STA_INFO_EXPECTED_THROUGHPUT);


You don't need any of the changes here in ath10k_sta_statistics().


Hi Jaohannes,

Yes. I removed this in ath10k driver and sent a v2 patch.

Thanks,
Anil.


Re: [PATCH] ath10k: Implement get_expected_throughput callback

2018-03-23 Thread akolli

Hi Sven,

Thanks for the review.

On 2018-03-23 13:39, Sven Eckelmann wrote:

On Freitag, 23. März 2018 13:07:00 CET Anilkumar Kolli wrote:
[...]

+static u32 ath10k_get_expected_throughput(struct ieee80211_hw *hw,
+ struct ieee80211_sta *sta)
+{
+   struct ath10k_sta *arsta = (struct ath10k_sta *)sta->drv_priv;
+   u32 tx_bitrate;
+
+   tx_bitrate = cfg80211_calculate_bitrate(>txrate);
+   ewma_sta_txrate_add(>ave_sta_txrate, tx_bitrate);
+
+   return ewma_sta_txrate_read(>ave_sta_txrate);
 }


Antonio and Felix, please correct me when this statement is incorrect.

The expected_throughput as initially implemented for minstrel(_ht) is 
not
about the raw physical bitrate but about the throughput which is 
expected for

things running on top of the wifi link. See
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=cca674d47e59665630f3005291b61bb883015fc5
for more details

when I interpret your change correctly then your it doesn't get the
information about packet loss or aggregation and doesn't do anything 
convert
from raw physical rate to something the user could get see. It will 
just
overestimate the throughput for ath10k links and thus give wrong 
information
to routing algorithms. This could for example cause them to prefer 
links over

ath10k based hw when mt76 would actually provide a significant better
throughput.

Beside that - why is the ave_sta_txrate only filled when with new 
information

when someone requests the current expected_throughput via
get_expected_throughput. I would have expected that it is filled 
everytime you

get new information about the current rate from the firmware
(ath10k_sta_statistics).


Yes. ideally it should be doing the rate avg. of all the sent packets.

@@ -7686,6 +7686,22 @@ static void ath10k_sta_statistics(struct 
ieee80211_hw *hw,

}
sinfo->txrate.flags = arsta->txrate.flags;
sinfo->filled |= 1ULL << NL80211_STA_INFO_TX_BITRATE;
+
+   sinfo->expected_throughput =
+   
ewma_sta_txrate_read(>ave_sta_txrate);

+   sinfo->filled |= BIT(NL80211_STA_INFO_EXPECTED_THROUGHPUT);
+}


This brings me directly to the next point. Why are you changing these 
values
here? Isn't sta_set_sinfo is expected to do that? This is at least what 
we

expect how it works when we call cfg80211_get_station() in batman-adv.



Yes. This looks redundant, I will remove this line,
 sinfo->filled |= BIT(NL80211_STA_INFO_EXPECTED_THROUGHPUT);

I will make these changes and send v2.

Thanks,
Anil.


Re: [PATCH 2/2] ath10k: add debugfs support to configure fwtest parameters

2018-03-05 Thread akolli

On 2018-03-05 13:12, Sven Eckelmann wrote:

On Montag, 5. März 2018 12:29:08 CET Anilkumar Kolli wrote:

@@ -496,6 +497,8 @@ struct ath10k_debug {
u32 reg_addr;
u32 nf_cal_period;
void *cal_data;
+   u32 fw_test_param_id;
+   u32 fw_test_param_value;
 };


Why is it necessary to have these two values in ath10k_debug? They seem 
to be

used only in the context of ath10k_write_fw_test().


Yes. it is not reused, will remove this.

Where can we find the documentation of the possible param_id and 
param_values?



All these parameters are for experimentation purpose.

Thanks,
Anil.



Re: [PATCH] ath10k: Add BMI parameters to fix calibration from DT/pre-cal

2017-12-11 Thread akolli

On 2017-12-08 19:10, Sven Eckelmann wrote:

On Freitag, 8. Dezember 2017 18:05:38 CET ako...@codeaurora.org wrote:

On 2017-12-08 17:42, Sven Eckelmann wrote:
> On Donnerstag, 25. Mai 2017 16:21:23 CET ako...@qti.qualcomm.com wrote:
>> From: Anilkumar Kolli 
>>
>> QCA99X0, QCA9888, QCA9984 supports calibration data in
>> either OTP or DT/pre-cal file. Current ath10k supports
>> Calibration data from OTP only.

[...]

> Just tried this on an QCA9984 which doesn't seem to have the
> calibration data in the PCI EEPROM.
>
> [   71.728929] ath10k_pci :01:00.0: qca9984/qca9994 hw1.0
> target 0x0100 chip_id 0x sub 168c:cafe
> [   71.732926] ath10k_pci :01:00.0: kconfig debug 1 debugfs 1
> tracing 0 dfs 1 testmode 1
> [   71.752282] ath10k_pci :01:00.0: firmware ver
> 10.4-ct-9984-fW-009-dfa0083 api 5 features peer-flow-ctrl crc32
> 7198d117
> [   73.805730] ath10k_pci :01:00.0: unable to read from the
> device
> [   73.805769] ath10k_pci :01:00.0: could not execute otp for
> board id check: -110
>

'ATH10K driver <-> 10.4 firmware' expects cal data to be either in
EEPROM or pre-cal-file or DT.
Hope the error is observed when there is no cal data loaded.


The problem happens when pre-cal data file is loaded using the 
userspace
helper on the QCA9984. I was only able to use the device when I (for a 
test)

used the pre-cal data as cal-data (file).

The EEPROM on the on the PCI device doesn't seem to be populated with a 
valid
pre-cal data. I've already tested it with a QCA9984 device which had 
pre-cal
data in the PCI device's EEPROM and this worked fine (without cal file 
and

without pre-cal file).


> It works when I use the pre-cal data as calibration data. The checksum
> in the
> pre-cal seems to be correct. Also the pre-cal data from 0:ART for the
> 2.4GHz
> and 5GHz QCA4019 seem to work perfectly fine.
>

Do you mean this patch works for only QCA4019 and not working for
QCA9984 ?


Worked fine for QCA4019 and QCA9888 - but I had no luck with QCA9984. 
The

error shown above it the only thing I get.



I tested this on QCA9984 and it worked with below config,

pre-cal file location: /lib/firmware/ath10k/pre-cal-pci-:01:00.0.bin
FW: 
https://github.com/kvalo/ath10k-firmware/raw/master/QCA9984/hw1.0/firmware-5.bin_10.4-3.2-00072
BDF: 
https://github.com/kvalo/ath10k-firmware/raw/master/QCA9984/hw1.0/board-2.bin


Logs:

ath10k_pci :01:00.0: found calibration file 
ath10k/pre-cal-pci-:01:00.0.bin

ath10k_pci :01:00.0: found fw version 10.4-3.2-00072
ath10k_pci :01:00.0: boot cal file downloaded
ath10k_pci :01:00.0: boot using calibration mode pre-cal-file
ath10k_pci :01:00.0: boot upload otp to 0x1234 len 8919 for board id
bmi execute address 0x1234 param 0x8000
ath10k_pci :01:00.0: bmi execute result 0x2800
ath10k_pci :01:00.0: boot get otp board id result 0x2800 
board_id 10 chip_id 0
ath10k_pci :01:00.0: boot using board name 
'bus=pci,bmi-chip-id=0,bmi-board-id=10'

ath10k_pci :01:00.0: Firmware loaded from user helper succesfully
ath10k_pci :01:00.0: boot fw request 
'ath10k/QCA9984/hw1.0/board-2.bin': 0


Kindly try with the latest firmware from Kalle's git mentioned above.

Thanks
Anil.




Re: [PATCH] ath10k: Add BMI parameters to fix calibration from DT/pre-cal

2017-12-08 Thread akolli

On 2017-12-08 17:42, Sven Eckelmann wrote:

On Donnerstag, 25. Mai 2017 16:21:23 CET ako...@qti.qualcomm.com wrote:

From: Anilkumar Kolli 

QCA99X0, QCA9888, QCA9984 supports calibration data in
either OTP or DT/pre-cal file. Current ath10k supports
Calibration data from OTP only.

If caldata is loaded from DT/pre-cal file, fetching board id
and applying calibration parameters like tx power gets failed.

error log:
[   15.733663] ath10k_pci :01:00.0: failed to fetch board file: -2
[   15.741474] ath10k_pci :01:00.0: could not probe fw (-2)

This patch adds calibration data support from DT/pre-cal
file.  Below parameters are used to get board id and
applying calibration parameters from cal data.

EEPROM[OTP] FLASH[DT/pre-cal file]
Cal param   0x700   0x1
Board id0x100x8000

Tested on QCA9888 with pre-cal file.

Signed-off-by: Anilkumar Kolli 
---
 drivers/net/wireless/ath/ath10k/bmi.h  |2 ++
 drivers/net/wireless/ath/ath10k/core.c |   16 +---
 2 files changed, 15 insertions(+), 3 deletions(-)


Just tried this on an QCA9984 which doesn't seem to have the
calibration data in the PCI EEPROM.

[   71.728929] ath10k_pci :01:00.0: qca9984/qca9994 hw1.0
target 0x0100 chip_id 0x sub 168c:cafe
[   71.732926] ath10k_pci :01:00.0: kconfig debug 1 debugfs 1
tracing 0 dfs 1 testmode 1
[   71.752282] ath10k_pci :01:00.0: firmware ver
10.4-ct-9984-fW-009-dfa0083 api 5 features peer-flow-ctrl crc32
7198d117
[   73.805730] ath10k_pci :01:00.0: unable to read from the 
device

[   73.805769] ath10k_pci :01:00.0: could not execute otp for
board id check: -110



'ATH10K driver <-> 10.4 firmware' expects cal data to be either in 
EEPROM or pre-cal-file or DT.

Hope the error is observed when there is no cal data loaded.

It works when I use the pre-cal data as calibration data. The checksum 
in the
pre-cal seems to be correct. Also the pre-cal data from 0:ART for the 
2.4GHz

and 5GHz QCA4019 seem to work perfectly fine.



Do you mean this patch works for only QCA4019 and not working for 
QCA9984 ?


Anything which I could have missed or what I could test? Btw. I've also 
tested

the non-ct firmware (aka the official one from QCA).



Thanks,
Anil.



[PATCHv2 3/3] ath10k: add per peer tx stats support for 10.2.4

2017-12-05 Thread akolli
From: Anilkumar Kolli 

10.2.4 firmware branch (used in QCA988X) does not support
HTT_10_4_T2H_MSG_TYPE_PEER_STATS and that's why ath10k does not provide
tranmission rate statistics to user space, instead it just shows
hardcoded 6 Mbit/s. But pktlog firmware facility provides per peer tx
statistics. The firmware sends one pktlog event for every four
PPDUs per peer, which include:

* successful number of packets and bytes transmitted
* number of packets and bytes dropped
* retried number of packets and bytes
* rate info per ppdu

Firmware supports WMI_SERVICE_PEER_STATS, pktlog is enabled through
ATH10K_FLAG_PEER_STATS, which is nowadays enabled by default in ath10k.

This patch does not impact throughput.

Tested on QCA9880 with firmware version 10.2.4.70.48. This should also
work with firmware branch 10.2.4-1.0-00029

Parse peer stats from pktlog packets and update the tx rate information
per STA. This way user space can query about transmit rate with iw:

$iw wlan0 station dump
Station 3c:a9:f4:72:bb:a4 (on wlan1)
inactive time:  8210 ms
rx bytes:   9166
rx packets: 44
tx bytes:   1105
tx packets: 9
tx retries: 0
tx failed:  1
rx drop misc:   3
signal: -75 [-75, -87, -88] dBm
signal avg: -75 [-75, -85, -88] dBm
tx bitrate: 39.0 MBit/s MCS 10
rx bitrate: 26.0 MBit/s MCS 3
rx duration:23250 us
authorized: yes
authenticated:  yes
associated: yes
preamble:   short
WMM/WME:yes
MFP:no
TDLS peer:  no
DTIM period:2
beacon interval:100
short preamble: yes
short slot time:yes
connected time: 22 seconds

Signed-off-by: Anilkumar Kolli 
---
 drivers/net/wireless/ath/ath10k/debug.h  |   18 -
 drivers/net/wireless/ath/ath10k/htt.h|   17 +
 drivers/net/wireless/ath/ath10k/htt_rx.c |   60 ++
 drivers/net/wireless/ath/ath10k/mac.c|   10 +
 4 files changed, 104 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/ath/ath10k/debug.h 
b/drivers/net/wireless/ath/ath10k/debug.h
index dd82a61ed1c8..5e662994c49a 100644
--- a/drivers/net/wireless/ath/ath10k/debug.h
+++ b/drivers/net/wireless/ath/ath10k/debug.h
@@ -51,7 +51,8 @@ enum ath10k_pktlog_filter {
ATH10K_PKTLOG_RCFIND = 0x4,
ATH10K_PKTLOG_RCUPDATE   = 0x8,
ATH10K_PKTLOG_DBG_PRINT  = 0x00010,
-   ATH10K_PKTLOG_ANY= 0x0001f,
+   ATH10K_PKTLOG_PEER_STATS = 0x00040,
+   ATH10K_PKTLOG_ANY= 0x0005f,
 };
 
 enum ath10k_dbg_aggr_mode {
@@ -60,6 +61,21 @@ enum ath10k_dbg_aggr_mode {
ATH10K_DBG_AGGR_MODE_MAX,
 };
 
+/* Types of packet log events */
+enum ath_pktlog_type {
+   ATH_PKTLOG_TYPE_TX_CTRL = 1,
+   ATH_PKTLOG_TYPE_TX_STAT,
+};
+
+struct ath10k_pktlog_hdr {
+   __le16 flags;
+   __le16 missed_cnt;
+   __le16 log_type; /* Type of log information foll this header */
+   __le16 size; /* Size of variable length log information in bytes */
+   __le32 timestamp;
+   u8 payload[0];
+} __packed;
+
 /* FIXME: How to calculate the buffer size sanely? */
 #define ATH10K_FW_STATS_BUF_SIZE (1024 * 1024)
 
diff --git a/drivers/net/wireless/ath/ath10k/htt.h 
b/drivers/net/wireless/ath/ath10k/htt.h
index 6305308422c4..89db96afea17 100644
--- a/drivers/net/wireless/ath/ath10k/htt.h
+++ b/drivers/net/wireless/ath/ath10k/htt.h
@@ -1497,6 +1497,23 @@ struct htt_peer_tx_stats {
u8 payload[0];
 } __packed;
 
+#define ATH10K_10_2_TX_STATS_OFFSET136
+#define PEER_STATS_FOR_NO_OF_PPDUS 4
+
+struct ath10k_10_2_peer_tx_stats {
+   u8 ratecode[PEER_STATS_FOR_NO_OF_PPDUS];
+   u8 success_pkts[PEER_STATS_FOR_NO_OF_PPDUS];
+   __le16 success_bytes[PEER_STATS_FOR_NO_OF_PPDUS];
+   u8 retry_pkts[PEER_STATS_FOR_NO_OF_PPDUS];
+   __le16 retry_bytes[PEER_STATS_FOR_NO_OF_PPDUS];
+   u8 failed_pkts[PEER_STATS_FOR_NO_OF_PPDUS];
+   __le16 failed_bytes[PEER_STATS_FOR_NO_OF_PPDUS];
+   u8 flags[PEER_STATS_FOR_NO_OF_PPDUS];
+   __le32 tx_duration;
+   u8 tx_ppdu_cnt;
+   u8 peer_id;
+} __packed;
+
 union htt_rx_pn_t {
/* WEP: 24-bit PN */
u32 pn24;
diff --git a/drivers/net/wireless/ath/ath10k/htt_rx.c 
b/drivers/net/wireless/ath/ath10k/htt_rx.c
index 7d295ee71534..50670d651cff 100644
--- a/drivers/net/wireless/ath/ath10k/htt_rx.c
+++ b/drivers/net/wireless/ath/ath10k/htt_rx.c
@@ -2449,6 +2449,62 @@ static void ath10k_htt_fetch_peer_stats(struct ath10k 
*ar,
rcu_read_unlock();
 }
 
+static void ath10k_fetch_10_2_tx_stats(struct ath10k *ar, u8 *data)
+{
+   struct ath10k_pktlog_hdr *hdr = (struct ath10k_pktlog_hdr *)data;
+   struct ath10k_per_peer_tx_stats *p_tx_stats = >peer_tx_stats;
+   struct 

[PATCHv2 1/3] ath10k: remove MAC80211_DEBUGFS dependency on ath10k_sta_statistics

2017-12-05 Thread akolli
From: Anilkumar Kolli 

Remove CONFIG_MAC80211_DEBUGFS dependency on ath10k_sta_statistics().
ath10k_sta_statistics() has per sta tx/rx stats and this should not
be dependent on MAC80211_DEBUGFS.

No changes in functionality.

Signed-off-by: Anilkumar Kolli 
---
 drivers/net/wireless/ath/ath10k/core.h|2 +-
 drivers/net/wireless/ath/ath10k/debug.h   |3 ---
 drivers/net/wireless/ath/ath10k/debugfs_sta.c |   27 --
 drivers/net/wireless/ath/ath10k/mac.c |   30 -
 4 files changed, 30 insertions(+), 32 deletions(-)

diff --git a/drivers/net/wireless/ath/ath10k/core.h 
b/drivers/net/wireless/ath/ath10k/core.h
index 643041ef3271..15e386d091a4 100644
--- a/drivers/net/wireless/ath/ath10k/core.h
+++ b/drivers/net/wireless/ath/ath10k/core.h
@@ -364,11 +364,11 @@ struct ath10k_sta {
struct rate_info txrate;
 
struct work_struct update_wk;
+   u64 rx_duration;
 
 #ifdef CONFIG_MAC80211_DEBUGFS
/* protected by conf_mutex */
bool aggr_mode;
-   u64 rx_duration;
 #endif
 };
 
diff --git a/drivers/net/wireless/ath/ath10k/debug.h 
b/drivers/net/wireless/ath/ath10k/debug.h
index 548ad5483a4a..dd82a61ed1c8 100644
--- a/drivers/net/wireless/ath/ath10k/debug.h
+++ b/drivers/net/wireless/ath/ath10k/debug.h
@@ -190,9 +190,6 @@ void ath10k_sta_add_debugfs(struct ieee80211_hw *hw, struct 
ieee80211_vif *vif,
struct ieee80211_sta *sta, struct dentry *dir);
 void ath10k_sta_update_rx_duration(struct ath10k *ar,
   struct ath10k_fw_stats *stats);
-void ath10k_sta_statistics(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
-  struct ieee80211_sta *sta,
-  struct station_info *sinfo);
 #else
 static inline
 void ath10k_sta_update_rx_duration(struct ath10k *ar,
diff --git a/drivers/net/wireless/ath/ath10k/debugfs_sta.c 
b/drivers/net/wireless/ath/ath10k/debugfs_sta.c
index d59ac6b83340..ff96f70d2282 100644
--- a/drivers/net/wireless/ath/ath10k/debugfs_sta.c
+++ b/drivers/net/wireless/ath/ath10k/debugfs_sta.c
@@ -65,33 +65,6 @@ void ath10k_sta_update_rx_duration(struct ath10k *ar,
ath10k_sta_update_stats_rx_duration(ar, stats);
 }
 
-void ath10k_sta_statistics(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
-  struct ieee80211_sta *sta,
-  struct station_info *sinfo)
-{
-   struct ath10k_sta *arsta = (struct ath10k_sta *)sta->drv_priv;
-   struct ath10k *ar = arsta->arvif->ar;
-
-   if (!ath10k_peer_stats_enabled(ar))
-   return;
-
-   sinfo->rx_duration = arsta->rx_duration;
-   sinfo->filled |= 1ULL << NL80211_STA_INFO_RX_DURATION;
-
-   if (!arsta->txrate.legacy && !arsta->txrate.nss)
-   return;
-
-   if (arsta->txrate.legacy) {
-   sinfo->txrate.legacy = arsta->txrate.legacy;
-   } else {
-   sinfo->txrate.mcs = arsta->txrate.mcs;
-   sinfo->txrate.nss = arsta->txrate.nss;
-   sinfo->txrate.bw = arsta->txrate.bw;
-   }
-   sinfo->txrate.flags = arsta->txrate.flags;
-   sinfo->filled |= 1ULL << NL80211_STA_INFO_TX_BITRATE;
-}
-
 static ssize_t ath10k_dbg_sta_read_aggr_mode(struct file *file,
 char __user *user_buf,
 size_t count, loff_t *ppos)
diff --git a/drivers/net/wireless/ath/ath10k/mac.c 
b/drivers/net/wireless/ath/ath10k/mac.c
index 06383e70e009..884543026f3a 100644
--- a/drivers/net/wireless/ath/ath10k/mac.c
+++ b/drivers/net/wireless/ath/ath10k/mac.c
@@ -7630,6 +7630,34 @@ static void ath10k_mac_op_sta_pre_rcu_remove(struct 
ieee80211_hw *hw,
peer->removed = true;
 }
 
+static void ath10k_sta_statistics(struct ieee80211_hw *hw,
+ struct ieee80211_vif *vif,
+ struct ieee80211_sta *sta,
+ struct station_info *sinfo)
+{
+   struct ath10k_sta *arsta = (struct ath10k_sta *)sta->drv_priv;
+   struct ath10k *ar = arsta->arvif->ar;
+
+   if (!ath10k_peer_stats_enabled(ar))
+   return;
+
+   sinfo->rx_duration = arsta->rx_duration;
+   sinfo->filled |= 1ULL << NL80211_STA_INFO_RX_DURATION;
+
+   if (!arsta->txrate.legacy && !arsta->txrate.nss)
+   return;
+
+   if (arsta->txrate.legacy) {
+   sinfo->txrate.legacy = arsta->txrate.legacy;
+   } else {
+   sinfo->txrate.mcs = arsta->txrate.mcs;
+   sinfo->txrate.nss = arsta->txrate.nss;
+   sinfo->txrate.bw = arsta->txrate.bw;
+   }
+   sinfo->txrate.flags = arsta->txrate.flags;
+   sinfo->filled |= 1ULL << NL80211_STA_INFO_TX_BITRATE;
+}
+
 static const struct ieee80211_ops ath10k_ops = {
.tx 

[PATCHv2 2/3] ath10k: move pktlog_filter out of ath10k_debug

2017-12-05 Thread akolli
From: Anilkumar Kolli 

Move pktlog_filter from struct ath10k_debug to struct ath10k
so that pktlog can be enabled even when debugfs is not
enabled, needed to enable peer tx stats for 10.2.4.

No changes in functionality.

Signed-off-by: Anilkumar Kolli 
---
 drivers/net/wireless/ath/ath10k/core.h  |2 +-
 drivers/net/wireless/ath/ath10k/debug.c |   16 
 2 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/net/wireless/ath/ath10k/core.h 
b/drivers/net/wireless/ath/ath10k/core.h
index 15e386d091a4..eac9737ee407 100644
--- a/drivers/net/wireless/ath/ath10k/core.h
+++ b/drivers/net/wireless/ath/ath10k/core.h
@@ -488,7 +488,6 @@ struct ath10k_debug {
/* protected by conf_mutex */
u64 fw_dbglog_mask;
u32 fw_dbglog_level;
-   u32 pktlog_filter;
u32 reg_addr;
u32 nf_cal_period;
void *cal_data;
@@ -963,6 +962,7 @@ struct ath10k {
} spectral;
 #endif
 
+   u32 pktlog_filter;
struct {
/* protected by conf_mutex */
struct ath10k_fw_components utf_mode_fw;
diff --git a/drivers/net/wireless/ath/ath10k/debug.c 
b/drivers/net/wireless/ath/ath10k/debug.c
index df514507d3f1..e278300b4f14 100644
--- a/drivers/net/wireless/ath/ath10k/debug.c
+++ b/drivers/net/wireless/ath/ath10k/debug.c
@@ -1950,14 +1950,14 @@ int ath10k_debug_start(struct ath10k *ar)
ret);
}
 
-   if (ar->debug.pktlog_filter) {
+   if (ar->pktlog_filter) {
ret = ath10k_wmi_pdev_pktlog_enable(ar,
-   ar->debug.pktlog_filter);
+   ar->pktlog_filter);
if (ret)
/* not serious */
ath10k_warn(ar,
"failed to enable pktlog filter %x: %d\n",
-   ar->debug.pktlog_filter, ret);
+   ar->pktlog_filter, ret);
} else {
ret = ath10k_wmi_pdev_pktlog_disable(ar);
if (ret)
@@ -2097,12 +2097,12 @@ static ssize_t ath10k_write_pktlog_filter(struct file 
*file,
mutex_lock(>conf_mutex);
 
if (ar->state != ATH10K_STATE_ON) {
-   ar->debug.pktlog_filter = filter;
+   ar->pktlog_filter = filter;
ret = count;
goto out;
}
 
-   if (filter == ar->debug.pktlog_filter) {
+   if (filter == ar->pktlog_filter) {
ret = count;
goto out;
}
@@ -2111,7 +2111,7 @@ static ssize_t ath10k_write_pktlog_filter(struct file 
*file,
ret = ath10k_wmi_pdev_pktlog_enable(ar, filter);
if (ret) {
ath10k_warn(ar, "failed to enable pktlog filter %x: 
%d\n",
-   ar->debug.pktlog_filter, ret);
+   ar->pktlog_filter, ret);
goto out;
}
} else {
@@ -2122,7 +2122,7 @@ static ssize_t ath10k_write_pktlog_filter(struct file 
*file,
}
}
 
-   ar->debug.pktlog_filter = filter;
+   ar->pktlog_filter = filter;
ret = count;
 
 out:
@@ -2139,7 +2139,7 @@ static ssize_t ath10k_read_pktlog_filter(struct file 
*file, char __user *ubuf,
 
mutex_lock(>conf_mutex);
len = scnprintf(buf, sizeof(buf) - len, "%08x\n",
-   ar->debug.pktlog_filter);
+   ar->pktlog_filter);
mutex_unlock(>conf_mutex);
 
return simple_read_from_buffer(ubuf, count, ppos, buf, len);
-- 
1.7.9.5



[PATCHv2 0/3] ath10k: tx stats for 10.2.4

2017-12-05 Thread akolli
From: Anilkumar Kolli 

Add tx stats supoort for QCA988X.
Parse peer stats from pktlog packets and update the tx rate
information per STA.
This way user space can query about transmit rate with iw.

V2:
  - Added  patch ath10k: remove MAC80211_DEBUGFS dependency on 
ath10k_sta_statistics
  - No other changes
 
Anilkumar Kolli (3):
  ath10k: remove MAC80211_DEBUGFS dependency on ath10k_sta_statistics
  ath10k: move pktlog_filter out of ath10k_debug
  ath10k: add per peer tx stats support for 10.2.4

 drivers/net/wireless/ath/ath10k/core.h|4 +-
 drivers/net/wireless/ath/ath10k/debug.c   |   16 +++
 drivers/net/wireless/ath/ath10k/debug.h   |   21 +++--
 drivers/net/wireless/ath/ath10k/debugfs_sta.c |   27 ---
 drivers/net/wireless/ath/ath10k/htt.h |   17 +++
 drivers/net/wireless/ath/ath10k/htt_rx.c  |   60 +
 drivers/net/wireless/ath/ath10k/mac.c |   40 -
 7 files changed, 143 insertions(+), 42 deletions(-)

-- 
1.7.9.5



Re: [PATCH 2/2] ath10k: add per peer tx stats support for 10.2.4

2017-12-04 Thread akolli

On 2017-12-04 19:53, Maxime Bizon wrote:

On Mon, 2017-12-04 at 18:54 +0530, ako...@codeaurora.org wrote:


Hope 10.2.4-1.0-00029 Firmware binary works for you.


it does


I will check this warning.


fixed by applying patch:
 "[PATCH] ath10k: fix recent bandwidth conversion bug"

as suggested by Christian Lamparter

only remaining oddity is the CONFIG_MAC80211_DEBUGFS dependency


I will send a patch to remove this dependency.

Thanks,
Anil.


Re: [PATCH 2/2] ath10k: add per peer tx stats support for 10.2.4

2017-12-04 Thread akolli

On 2017-12-01 20:35, Maxime Bizon wrote:

On Fri, 2017-12-01 at 19:18 +0530, ako...@codeaurora.org wrote:


Hope CONFIG_MAC80211_DEBUGFS is enabled in your build.


it wasn't and IMHO it's confusing because tx rate is filled by the 
other

drivers without it.

I now have the following warning:

[   96.174967] [ cut here ]
[   96.179640] WARNING: CPU: 0 PID: 609 at net/wireless/util.c:1254
cfg80211_calculate_bitrate+0x174/0x220
[   96.189538] invalid rate bw=1, mcs=9, nss=2
[   96.219736] CPU: 0 PID: 609 Comm: hostapd Not tainted
4.14.3-00381-gec9756b0f64d #28
[   96.227910] Hardware name: Marvell Kirkwood (Flattened Device Tree)
[   96.235450] [<80010124>] (unwind_backtrace) from [<8000d9ec>]
(show_stack+0x10/0x14)
[   96.247180] [<8000d9ec>] (show_stack) from [<8002016c>] 
(__warn+0xdc/0xf8)

[   96.254243] [<8002016c>] (__warn) from [<800201bc>]
(warn_slowpath_fmt+0x34/0x44)
[   96.262016] [<800201bc>] (warn_slowpath_fmt) from [<8064dfdc>]
(cfg80211_calculate_bitrate+0x174/0x220)
[   96.272652] [<8064dfdc>] (cfg80211_calculate_bitrate) from
[<806692d4>] (nl80211_put_sta_rate+0x44/0x1dc)
[   96.282509] [<806692d4>] (nl80211_put_sta_rate) from [<8066001c>]
(nl80211_send_station+0x388/0xaf0)
[   96.292261] [<8066001c>] (nl80211_send_station) from [<8066082c>]
(nl80211_get_station+0xa8/0xec)
[   96.304166] [<8066082c>] (nl80211_get_station) from [<80509c20>]
(genl_rcv_msg+0x2dc/0x34c)
[   96.313324] [<80509c20>] (genl_rcv_msg) from [<8050890c>]
(netlink_rcv_skb+0x84/0xdc)
[   96.321880] [<8050890c>] (netlink_rcv_skb) from [<805093c0>]
(genl_rcv+0x20/0x34)
[   96.329668] [<805093c0>] (genl_rcv) from [<80508188>]
(netlink_unicast+0x12c/0x1e0)
[   96.338408] [<80508188>] (netlink_unicast) from [<805085d8>]
(netlink_sendmsg+0x2e0/0x304)
[   96.350736] [<805085d8>] (netlink_sendmsg) from [<804b5f9c>]
(sock_sendmsg+0x14/0x24)
[   96.358656] [<804b5f9c>] (sock_sendmsg) from [<804b66e8>]
(___sys_sendmsg+0x1c8/0x20c)
[   96.367093] [<804b66e8>] (___sys_sendmsg) from [<804b739c>]
(__sys_sendmsg+0x40/0x64)
[   96.375276] [<804b739c>] (__sys_sendmsg) from [<8000a3e0>]
(ret_fast_syscall+0x0/0x44)
[   96.383455] ---[ end trace da8257d6a850e91a ]---

# iw dev wlan1 station dump
Station e4:42:a6:24:c8:95 (on wlan1)
inactive time:  550 ms
rx bytes:   41217
rx packets: 152
tx bytes:   49397
tx packets: 107
tx retries: 0
tx failed:  1
rx drop misc:   0
signal: -62 [-66, -65, -83] dBm
signal avg: -61 [-65, -65, -78] dBm
tx bitrate:  VHT-MCS 9 short GI VHT-NSS 2
rx bitrate: 360.0 MBit/s VHT-MCS 8 40MHz short GI VHT-NSS 2
rx duration:0 us
authorized: yes
authenticated:  yes
associated: yes
preamble:   long
WMM/WME:yes
MFP:no
TDLS peer:  no
DTIM period:2
beacon interval:96
short slot time:yes
connected time: 5 seconds

Thanks


Hope 10.2.4-1.0-00029 Firmware binary works for you.
I will check this warning.

Thanks,
Anil.


Re: [PATCH 2/2] ath10k: add per peer tx stats support for 10.2.4

2017-12-04 Thread akolli





Parse peer stats from pktlog packets and update the tx rate
information
per STA. This way user space can query about transmit rate with iw:


everything works ok, ath10k_update_per_peer_tx_stats() is called and
ath10k_sta fields are updated correctly

but tx bitrate is still 6 MBit/s in station dump


Hope CONFIG_MAC80211_DEBUGFS is enabled in your build.
Please Run ping traffic and see and 'station dump'


This feature should not depend on debugfs. Why is it needed? In patch 1
you already moved pktlog_filter to struct ath10k, does it need 
something

else as well?


ATH10K updates tx rate from this callback,
.sta_statistics = ath10k_sta_statistics,

This callback is defined under CONFIG_MAC80211_DEBUGFS.

Thanks,
Anil.


Re: [PATCH 2/2] ath10k: add per peer tx stats support for 10.2.4

2017-12-01 Thread akolli


Hello,

Thanks for verifying the patch.

On 2017-12-01 16:15, Maxime Bizon wrote:

On Thu, 2017-11-30 at 18:28 +0530, ako...@qti.qualcomm.com wrote:

Hello,


Tested on QCA9880 with firmware version 10.2.4.70.48. This should also
work with firmware branch 10.2.4-1.0-00029


I tried using your patch on 4.14 with firmware 10.2.4-1.0-00029


I will test update.

Parse peer stats from pktlog packets and update the tx rate 
information

per STA. This way user space can query about transmit rate with iw:


everything works ok, ath10k_update_per_peer_tx_stats() is called and
ath10k_sta fields are updated correctly

but tx bitrate is still 6 MBit/s in station dump


Hope CONFIG_MAC80211_DEBUGFS is enabled in your build.
Please Run ping traffic and see and 'station dump'


 # iw dev wlan1 station dump
Station e4:42:a6:24:c8:95 (on wlan1)
inactive time:  0 ms
rx bytes:   222415
rx packets: 1678
tx bytes:   8511140
tx packets: 5828
tx retries: 0
tx failed:  4
rx drop misc:   2
signal: -39 [-54, -56, -39] dBm
signal avg: -39 [-53, -55, -39] dBm
tx bitrate: 6.0 MBit/s
rx bitrate: 360.0 MBit/s VHT-MCS 8 40MHz short GI VHT-NSS 2
authorized: yes
authenticated:  yes
associated: yes
preamble:   long
WMM/WME:yes
MFP:no
TDLS peer:  no
DTIM period:2
beacon interval:96
short slot time:yes
connected time: 1136 seconds

I see that ath10k does not implement ->dump_station callback, so which
part of the code updates the generic "struct station_info" fields ?

Am I missing a patch ?


Rate parameters are updated from below call,
.sta_statistics = ath10k_sta_statistics,

Thanks,
Anil.


Re: [PATCH 2/2] ath10k: add per peer tx stats support for 10.2.4

2017-11-30 Thread akolli

On 2017-11-30 22:08, Kalle Valo wrote:

Toke Høiland-Jørgensen  writes:


+struct ath10k_10_2_peer_tx_stats {
+   u8 ratecode[PEER_STATS_FOR_NO_OF_PPDUS];
+   u8 success_pkts[PEER_STATS_FOR_NO_OF_PPDUS];
+   __le16 success_bytes[PEER_STATS_FOR_NO_OF_PPDUS];
+   u8 retry_pkts[PEER_STATS_FOR_NO_OF_PPDUS];
+   __le16 retry_bytes[PEER_STATS_FOR_NO_OF_PPDUS];
+   u8 failed_pkts[PEER_STATS_FOR_NO_OF_PPDUS];
+   __le16 failed_bytes[PEER_STATS_FOR_NO_OF_PPDUS];
+   u8 flags[PEER_STATS_FOR_NO_OF_PPDUS];
+   __le32 tx_duration;
+   u8 tx_ppdu_cnt;
+   u8 peer_id;
+} __packed;


Toke, hopefully the tx_duration value here helps with ATF
implementation
using QCA988X.


Awesome! What's the semantics of this field? Just total
duration spent serving that station in the reporting interval?
Does it include retry attempts?


I have no clue :) I just noticed this while I was reviewing the patch
internally and immediately recalled our discussions at Seoul. I can try
to find out, but that will take a long time as I have way too much 
stuff
pending at the moment. Hopefully someone more knowledgeable 
(Anilkumar?)

can chime in and help.


tx_duration is aggregate time duration of 4 PPDU sent to STA.
FW sends these values for retry packets also.

Thanks,
Anil.


[PATCH 1/2] ath10k: move pktlog_filter out of ath10k_debug

2017-11-30 Thread akolli
From: Anilkumar Kolli 

Move pktlog_filter from struct ath10k_debug to struct ath10k
so that pktlog can be enabled even when debugfs is not
enabled, needed to enable peer tx stats for 10.2.4.

No changes in functionality.

Signed-off-by: Anilkumar Kolli 
---
 drivers/net/wireless/ath/ath10k/core.h  |2 +-
 drivers/net/wireless/ath/ath10k/debug.c |   16 
 2 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/net/wireless/ath/ath10k/core.h 
b/drivers/net/wireless/ath/ath10k/core.h
index 643041ef3271..75dbfffe677a 100644
--- a/drivers/net/wireless/ath/ath10k/core.h
+++ b/drivers/net/wireless/ath/ath10k/core.h
@@ -488,7 +488,6 @@ struct ath10k_debug {
/* protected by conf_mutex */
u64 fw_dbglog_mask;
u32 fw_dbglog_level;
-   u32 pktlog_filter;
u32 reg_addr;
u32 nf_cal_period;
void *cal_data;
@@ -963,6 +962,7 @@ struct ath10k {
} spectral;
 #endif
 
+   u32 pktlog_filter;
struct {
/* protected by conf_mutex */
struct ath10k_fw_components utf_mode_fw;
diff --git a/drivers/net/wireless/ath/ath10k/debug.c 
b/drivers/net/wireless/ath/ath10k/debug.c
index df514507d3f1..e278300b4f14 100644
--- a/drivers/net/wireless/ath/ath10k/debug.c
+++ b/drivers/net/wireless/ath/ath10k/debug.c
@@ -1950,14 +1950,14 @@ int ath10k_debug_start(struct ath10k *ar)
ret);
}
 
-   if (ar->debug.pktlog_filter) {
+   if (ar->pktlog_filter) {
ret = ath10k_wmi_pdev_pktlog_enable(ar,
-   ar->debug.pktlog_filter);
+   ar->pktlog_filter);
if (ret)
/* not serious */
ath10k_warn(ar,
"failed to enable pktlog filter %x: %d\n",
-   ar->debug.pktlog_filter, ret);
+   ar->pktlog_filter, ret);
} else {
ret = ath10k_wmi_pdev_pktlog_disable(ar);
if (ret)
@@ -2097,12 +2097,12 @@ static ssize_t ath10k_write_pktlog_filter(struct file 
*file,
mutex_lock(>conf_mutex);
 
if (ar->state != ATH10K_STATE_ON) {
-   ar->debug.pktlog_filter = filter;
+   ar->pktlog_filter = filter;
ret = count;
goto out;
}
 
-   if (filter == ar->debug.pktlog_filter) {
+   if (filter == ar->pktlog_filter) {
ret = count;
goto out;
}
@@ -2111,7 +2111,7 @@ static ssize_t ath10k_write_pktlog_filter(struct file 
*file,
ret = ath10k_wmi_pdev_pktlog_enable(ar, filter);
if (ret) {
ath10k_warn(ar, "failed to enable pktlog filter %x: 
%d\n",
-   ar->debug.pktlog_filter, ret);
+   ar->pktlog_filter, ret);
goto out;
}
} else {
@@ -2122,7 +2122,7 @@ static ssize_t ath10k_write_pktlog_filter(struct file 
*file,
}
}
 
-   ar->debug.pktlog_filter = filter;
+   ar->pktlog_filter = filter;
ret = count;
 
 out:
@@ -2139,7 +2139,7 @@ static ssize_t ath10k_read_pktlog_filter(struct file 
*file, char __user *ubuf,
 
mutex_lock(>conf_mutex);
len = scnprintf(buf, sizeof(buf) - len, "%08x\n",
-   ar->debug.pktlog_filter);
+   ar->pktlog_filter);
mutex_unlock(>conf_mutex);
 
return simple_read_from_buffer(ubuf, count, ppos, buf, len);
-- 
1.7.9.5



[PATCH 2/2] ath10k: add per peer tx stats support for 10.2.4

2017-11-30 Thread akolli
From: Anilkumar Kolli 

10.2.4 firmware branch (used in QCA988X) does not support
HTT_10_4_T2H_MSG_TYPE_PEER_STATS and that's why ath10k does not provide
tranmission rate statistics to user space, instead it just shows
hardcoded 6 Mbit/s. But pktlog firmware facility provides per peer tx
statistics. The firmware sends one pktlog event for every four
PPDUs per peer, which include:

* successful number of packets and bytes transmitted
* number of packets and bytes dropped
* retried number of packets and bytes
* rate info per ppdu

Firmware supports WMI_SERVICE_PEER_STATS, pktlog is enabled through
ATH10K_FLAG_PEER_STATS, which is nowadays enabled by default in ath10k.

This patch does not impact throughput.

Tested on QCA9880 with firmware version 10.2.4.70.48. This should also
work with firmware branch 10.2.4-1.0-00029

Parse peer stats from pktlog packets and update the tx rate information
per STA. This way user space can query about transmit rate with iw:

$iw wlan0 station dump
Station 3c:a9:f4:72:bb:a4 (on wlan1)
inactive time:  8210 ms
rx bytes:   9166
rx packets: 44
tx bytes:   1105
tx packets: 9
tx retries: 0
tx failed:  1
rx drop misc:   3
signal: -75 [-75, -87, -88] dBm
signal avg: -75 [-75, -85, -88] dBm
tx bitrate: 39.0 MBit/s MCS 10
rx bitrate: 26.0 MBit/s MCS 3
rx duration:23250 us
authorized: yes
authenticated:  yes
associated: yes
preamble:   short
WMM/WME:yes
MFP:no
TDLS peer:  no
DTIM period:2
beacon interval:100
short preamble: yes
short slot time:yes
connected time: 22 seconds

Signed-off-by: Anilkumar Kolli 
---
 drivers/net/wireless/ath/ath10k/debug.h  |   18 -
 drivers/net/wireless/ath/ath10k/htt.h|   17 +
 drivers/net/wireless/ath/ath10k/htt_rx.c |   60 ++
 drivers/net/wireless/ath/ath10k/mac.c|   10 +
 4 files changed, 104 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/ath/ath10k/debug.h 
b/drivers/net/wireless/ath/ath10k/debug.h
index 548ad5483a4a..290979ef4915 100644
--- a/drivers/net/wireless/ath/ath10k/debug.h
+++ b/drivers/net/wireless/ath/ath10k/debug.h
@@ -51,7 +51,8 @@ enum ath10k_pktlog_filter {
ATH10K_PKTLOG_RCFIND = 0x4,
ATH10K_PKTLOG_RCUPDATE   = 0x8,
ATH10K_PKTLOG_DBG_PRINT  = 0x00010,
-   ATH10K_PKTLOG_ANY= 0x0001f,
+   ATH10K_PKTLOG_PEER_STATS = 0x00040,
+   ATH10K_PKTLOG_ANY= 0x0005f,
 };
 
 enum ath10k_dbg_aggr_mode {
@@ -60,6 +61,21 @@ enum ath10k_dbg_aggr_mode {
ATH10K_DBG_AGGR_MODE_MAX,
 };
 
+/* Types of packet log events */
+enum ath_pktlog_type {
+   ATH_PKTLOG_TYPE_TX_CTRL = 1,
+   ATH_PKTLOG_TYPE_TX_STAT,
+};
+
+struct ath10k_pktlog_hdr {
+   __le16 flags;
+   __le16 missed_cnt;
+   __le16 log_type; /* Type of log information foll this header */
+   __le16 size; /* Size of variable length log information in bytes */
+   __le32 timestamp;
+   u8 payload[0];
+} __packed;
+
 /* FIXME: How to calculate the buffer size sanely? */
 #define ATH10K_FW_STATS_BUF_SIZE (1024 * 1024)
 
diff --git a/drivers/net/wireless/ath/ath10k/htt.h 
b/drivers/net/wireless/ath/ath10k/htt.h
index 6305308422c4..89db96afea17 100644
--- a/drivers/net/wireless/ath/ath10k/htt.h
+++ b/drivers/net/wireless/ath/ath10k/htt.h
@@ -1497,6 +1497,23 @@ struct htt_peer_tx_stats {
u8 payload[0];
 } __packed;
 
+#define ATH10K_10_2_TX_STATS_OFFSET136
+#define PEER_STATS_FOR_NO_OF_PPDUS 4
+
+struct ath10k_10_2_peer_tx_stats {
+   u8 ratecode[PEER_STATS_FOR_NO_OF_PPDUS];
+   u8 success_pkts[PEER_STATS_FOR_NO_OF_PPDUS];
+   __le16 success_bytes[PEER_STATS_FOR_NO_OF_PPDUS];
+   u8 retry_pkts[PEER_STATS_FOR_NO_OF_PPDUS];
+   __le16 retry_bytes[PEER_STATS_FOR_NO_OF_PPDUS];
+   u8 failed_pkts[PEER_STATS_FOR_NO_OF_PPDUS];
+   __le16 failed_bytes[PEER_STATS_FOR_NO_OF_PPDUS];
+   u8 flags[PEER_STATS_FOR_NO_OF_PPDUS];
+   __le32 tx_duration;
+   u8 tx_ppdu_cnt;
+   u8 peer_id;
+} __packed;
+
 union htt_rx_pn_t {
/* WEP: 24-bit PN */
u32 pn24;
diff --git a/drivers/net/wireless/ath/ath10k/htt_rx.c 
b/drivers/net/wireless/ath/ath10k/htt_rx.c
index e31438541ee1..3361807b87b3 100644
--- a/drivers/net/wireless/ath/ath10k/htt_rx.c
+++ b/drivers/net/wireless/ath/ath10k/htt_rx.c
@@ -2424,6 +2424,62 @@ static void ath10k_htt_fetch_peer_stats(struct ath10k 
*ar,
rcu_read_unlock();
 }
 
+static void ath10k_fetch_10_2_tx_stats(struct ath10k *ar, u8 *data)
+{
+   struct ath10k_pktlog_hdr *hdr = (struct ath10k_pktlog_hdr *)data;
+   struct ath10k_per_peer_tx_stats *p_tx_stats = >peer_tx_stats;
+   struct 

[PATCH 0/2] ath10k: tx stats for 10.2.4

2017-11-30 Thread akolli
From: Anilkumar Kolli 

Add tx stats supoort for QCA988X.
Parse peer stats from pktlog packets and update the tx rate
information per STA.
This way user space can query about transmit rate with iw.

Anilkumar Kolli (2):
  ath10k: move pktlog_filter out of ath10k_debug
  ath10k: add per peer tx stats support for 10.2.4

 drivers/net/wireless/ath/ath10k/core.h   |2 +-
 drivers/net/wireless/ath/ath10k/debug.c  |   16 
 drivers/net/wireless/ath/ath10k/debug.h  |   18 -
 drivers/net/wireless/ath/ath10k/htt.h|   17 +
 drivers/net/wireless/ath/ath10k/htt_rx.c |   60 ++
 drivers/net/wireless/ath/ath10k/mac.c|   10 +
 6 files changed, 113 insertions(+), 10 deletions(-)

-- 
1.7.9.5



Re: ath10k: Fix reported HT MCS rates with NSS > 1

2017-11-20 Thread akolli

On 2017-11-20 17:40, Kalle Valo wrote:

Peter Oh  writes:


On 11/06/2017 01:02 AM, Sven Eckelmann wrote:

On Montag, 6. November 2017 09:28:42 CET Sebastian Gottschall wrote:

Am 06.11.2017 um 09:23 schrieb Sven Eckelmann:
On Sonntag, 5. November 2017 10:22:22 CET Sebastian Gottschall 
wrote:
the assumption made in this patch is obviously wrong (at least for 
more

recent firmwares and 9984)
my log is flooded with messages like
[208802.803537] ath10k_pci 0001:03:00.0: Invalid VHT mcs 15 peer 
stats
[208805.108515] ath10k_pci 0001:03:00.0: Invalid VHT mcs 15 peer 
stats
[208821.747621] ath10k_pci 0001:03:00.0: Invalid VHT mcs 15 peer 
stats
[208822.516599] ath10k_pci 0001:03:00.0: Invalid VHT mcs 15 peer 
stats
[208841.257780] ath10k_pci 0001:03:00.0: Invalid VHT mcs 15 peer 
stats

[...]
This patch only splits WMI_RATE_PREAMBLE_HT & 
WMI_RATE_PREAMBLE_VHT. And for
WMI_RATE_PREAMBLE_HT (*not VHT*), it uses a slightly different 
approach. But
the WMI_RATE_PREAMBLE_VHT part (which you see in your logs) is 
basically

untouched.

then a question follows up. is this check really neccessary?
Until we find out what the heck VHT MCS 15 should mean in this 
context - maybe.
But to the message - no, the message is most likely not necessary for 
each

received "invalid" peer tx stat.


This validation check expects peer tx stat packets from FW contain
reasonable values and gives warning if values are different from
expectation. The problem comes from the assumption that "it always
contains reasonable stat value" which is wrong at least based on my
results. For instance, the reason MCS == 15 is because all 4 bits of
mcs potion set to 1, not because FW really sets it to 15
intentionally. when the mcs potion bits are set to all 1s, the other
bits such as nss are also set to all 1s.
Hence it looks FW passed totally invalid stat info to me.

I don't have preference on whether it's better to split VHT and HT
check or not, but it is more appropriate to change that warning level
to debug level.


I think we should add a special case to not print the warning if mcs ==
15 until we figure out what it means.


Fix identified in Firmware and will push ASAP.

--
Anil.


[PATCH] ath10k: fix sending wmi cmd during the tdls teardown

2017-10-05 Thread akolli
From: Anilkumar Kolli 

The current firmware 10.4-3.5.1-00035 on QCA9888 supports
TDLS explicit mode, it expects WMI_TDLS_ENABLE_PASSIVE
for tdls setup and WMI_TDLS_DISABLE for tdls teardown.

Signed-off-by: Anilkumar Kolli 
---
 drivers/net/wireless/ath/ath10k/wmi.c |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/ath/ath10k/wmi.c 
b/drivers/net/wireless/ath/ath10k/wmi.c
index 38a97086708b..cad2e42dcef6 100644
--- a/drivers/net/wireless/ath/ath10k/wmi.c
+++ b/drivers/net/wireless/ath/ath10k/wmi.c
@@ -7870,7 +7870,8 @@ static int ath10k_wmi_10_4_op_get_vdev_subtype(struct 
ath10k *ar,
if (!skb)
return ERR_PTR(-ENOMEM);
 
-   if (test_bit(WMI_SERVICE_TDLS_EXPLICIT_MODE_ONLY, ar->wmi.svc_map))
+   if (test_bit(WMI_SERVICE_TDLS_EXPLICIT_MODE_ONLY, ar->wmi.svc_map) &&
+   state == WMI_TDLS_ENABLE_ACTIVE)
state = WMI_TDLS_ENABLE_PASSIVE;
 
if (test_bit(WMI_SERVICE_TDLS_UAPSD_BUFFER_STA, ar->wmi.svc_map))
-- 
1.7.9.5



[PATCH 2/2] ath10k: block offchannel operations if TDLS session is active

2017-10-05 Thread akolli
From: Anilkumar Kolli 

Do not allow off channel operations like scans/roc when
there are active TDLS sessions.

The Current firmware 10.4-3.5.1-00035 on QCA9888 does not
supports any offchannel operations on active TDLS sessions,
either driver needs to block the offchannel operation requests
or should teardown the TDLS connection.

Signed-off-by: Anilkumar Kolli 
---
 drivers/net/wireless/ath/ath10k/mac.c |   10 ++
 1 file changed, 10 insertions(+)

diff --git a/drivers/net/wireless/ath/ath10k/mac.c 
b/drivers/net/wireless/ath/ath10k/mac.c
index 0f14da73cf64..2f3851e688f4 100644
--- a/drivers/net/wireless/ath/ath10k/mac.c
+++ b/drivers/net/wireless/ath/ath10k/mac.c
@@ -5641,6 +5641,11 @@ static int ath10k_hw_scan(struct ieee80211_hw *hw,
 
mutex_lock(>conf_mutex);
 
+   if (ath10k_mac_tdls_vif_stations_count(hw, vif) > 0) {
+   ret = -EBUSY;
+   goto exit;
+   }
+
spin_lock_bh(>data_lock);
switch (ar->scan.state) {
case ATH10K_SCAN_IDLE:
@@ -6477,6 +6482,11 @@ static int ath10k_remain_on_channel(struct ieee80211_hw 
*hw,
 
mutex_lock(>conf_mutex);
 
+   if (ath10k_mac_tdls_vif_stations_count(hw, vif) > 0) {
+   ret = -EBUSY;
+   goto exit;
+   }
+
spin_lock_bh(>data_lock);
switch (ar->scan.state) {
case ATH10K_SCAN_IDLE:
-- 
1.7.9.5



[PATCH 1/2] ath10k: move ath10k_mac_tdls_vif*() functions

2017-10-05 Thread akolli
From: Anilkumar Kolli 

To be able to use ath10k_mac_tdls_vif_stations_count() in
ath10k_hw_scan() in the following patch, move the functions
earlier in the file.

This commit is pure code move, no functional changes.

Signed-off-by: Anilkumar Kolli 
---
 drivers/net/wireless/ath/ath10k/mac.c |  106 -
 1 file changed, 53 insertions(+), 53 deletions(-)

diff --git a/drivers/net/wireless/ath/ath10k/mac.c 
b/drivers/net/wireless/ath/ath10k/mac.c
index 5683f1a5330e..0f14da73cf64 100644
--- a/drivers/net/wireless/ath/ath10k/mac.c
+++ b/drivers/net/wireless/ath/ath10k/mac.c
@@ -5575,6 +5575,59 @@ static void ath10k_mac_op_set_coverage_class(struct 
ieee80211_hw *hw, s16 value)
ar->hw_params.hw_ops->set_coverage_class(ar, value);
 }
 
+struct ath10k_mac_tdls_iter_data {
+   u32 num_tdls_stations;
+   struct ieee80211_vif *curr_vif;
+};
+
+static void ath10k_mac_tdls_vif_stations_count_iter(void *data,
+   struct ieee80211_sta *sta)
+{
+   struct ath10k_mac_tdls_iter_data *iter_data = data;
+   struct ath10k_sta *arsta = (struct ath10k_sta *)sta->drv_priv;
+   struct ieee80211_vif *sta_vif = arsta->arvif->vif;
+
+   if (sta->tdls && sta_vif == iter_data->curr_vif)
+   iter_data->num_tdls_stations++;
+}
+
+static int ath10k_mac_tdls_vif_stations_count(struct ieee80211_hw *hw,
+ struct ieee80211_vif *vif)
+{
+   struct ath10k_mac_tdls_iter_data data = {};
+
+   data.curr_vif = vif;
+
+   ieee80211_iterate_stations_atomic(hw,
+ 
ath10k_mac_tdls_vif_stations_count_iter,
+ );
+   return data.num_tdls_stations;
+}
+
+static void ath10k_mac_tdls_vifs_count_iter(void *data, u8 *mac,
+   struct ieee80211_vif *vif)
+{
+   struct ath10k_vif *arvif = (void *)vif->drv_priv;
+   int *num_tdls_vifs = data;
+
+   if (vif->type != NL80211_IFTYPE_STATION)
+   return;
+
+   if (ath10k_mac_tdls_vif_stations_count(arvif->ar->hw, vif) > 0)
+   (*num_tdls_vifs)++;
+}
+
+static int ath10k_mac_tdls_vifs_count(struct ieee80211_hw *hw)
+{
+   int num_tdls_vifs = 0;
+
+   ieee80211_iterate_active_interfaces_atomic(hw,
+  IEEE80211_IFACE_ITER_NORMAL,
+  
ath10k_mac_tdls_vifs_count_iter,
+  _tdls_vifs);
+   return num_tdls_vifs;
+}
+
 static int ath10k_hw_scan(struct ieee80211_hw *hw,
  struct ieee80211_vif *vif,
  struct ieee80211_scan_request *hw_req)
@@ -6000,59 +6053,6 @@ static void ath10k_mac_dec_num_stations(struct 
ath10k_vif *arvif,
ar->num_stations--;
 }
 
-struct ath10k_mac_tdls_iter_data {
-   u32 num_tdls_stations;
-   struct ieee80211_vif *curr_vif;
-};
-
-static void ath10k_mac_tdls_vif_stations_count_iter(void *data,
-   struct ieee80211_sta *sta)
-{
-   struct ath10k_mac_tdls_iter_data *iter_data = data;
-   struct ath10k_sta *arsta = (struct ath10k_sta *)sta->drv_priv;
-   struct ieee80211_vif *sta_vif = arsta->arvif->vif;
-
-   if (sta->tdls && sta_vif == iter_data->curr_vif)
-   iter_data->num_tdls_stations++;
-}
-
-static int ath10k_mac_tdls_vif_stations_count(struct ieee80211_hw *hw,
- struct ieee80211_vif *vif)
-{
-   struct ath10k_mac_tdls_iter_data data = {};
-
-   data.curr_vif = vif;
-
-   ieee80211_iterate_stations_atomic(hw,
- 
ath10k_mac_tdls_vif_stations_count_iter,
- );
-   return data.num_tdls_stations;
-}
-
-static void ath10k_mac_tdls_vifs_count_iter(void *data, u8 *mac,
-   struct ieee80211_vif *vif)
-{
-   struct ath10k_vif *arvif = (void *)vif->drv_priv;
-   int *num_tdls_vifs = data;
-
-   if (vif->type != NL80211_IFTYPE_STATION)
-   return;
-
-   if (ath10k_mac_tdls_vif_stations_count(arvif->ar->hw, vif) > 0)
-   (*num_tdls_vifs)++;
-}
-
-static int ath10k_mac_tdls_vifs_count(struct ieee80211_hw *hw)
-{
-   int num_tdls_vifs = 0;
-
-   ieee80211_iterate_active_interfaces_atomic(hw,
-  IEEE80211_IFACE_ITER_NORMAL,
-  
ath10k_mac_tdls_vifs_count_iter,
-  _tdls_vifs);
-   return num_tdls_vifs;
-}
-
 static int ath10k_sta_state(struct ieee80211_hw *hw,
struct ieee80211_vif *vif,
struct ieee80211_sta *sta,

[PATCH] ath10k: Add BMI parameters to fix calibration from DT/pre-cal

2017-05-25 Thread akolli
From: Anilkumar Kolli 

QCA99X0, QCA9888, QCA9984 supports calibration data in
either OTP or DT/pre-cal file. Current ath10k supports
Calibration data from OTP only.

If caldata is loaded from DT/pre-cal file, fetching board id
and applying calibration parameters like tx power gets failed.

error log:
[   15.733663] ath10k_pci :01:00.0: failed to fetch board file: -2
[   15.741474] ath10k_pci :01:00.0: could not probe fw (-2)

This patch adds calibration data support from DT/pre-cal
file.  Below parameters are used to get board id and
applying calibration parameters from cal data.

EEPROM[OTP] FLASH[DT/pre-cal file]
Cal param   0x700   0x1
Board id0x100x8000

Tested on QCA9888 with pre-cal file.

Signed-off-by: Anilkumar Kolli 
---
 drivers/net/wireless/ath/ath10k/bmi.h  |2 ++
 drivers/net/wireless/ath/ath10k/core.c |   16 +---
 2 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/drivers/net/wireless/ath/ath10k/bmi.h 
b/drivers/net/wireless/ath/ath10k/bmi.h
index 0342073ed397..9834f351807e 100644
--- a/drivers/net/wireless/ath/ath10k/bmi.h
+++ b/drivers/net/wireless/ath/ath10k/bmi.h
@@ -83,6 +83,8 @@ enum bmi_cmd_id {
 #define BMI_NVRAM_SEG_NAME_SZ 16
 
 #define BMI_PARAM_GET_EEPROM_BOARD_ID 0x10
+#define BMI_PARAM_GET_FLASH_BOARD_ID 0x8000
+#define BMI_PARAM_FLASH_SECTION_ALL 0x1
 
 #define ATH10K_BMI_BOARD_ID_FROM_OTP_MASK   0x7c00
 #define ATH10K_BMI_BOARD_ID_FROM_OTP_LSB10
diff --git a/drivers/net/wireless/ath/ath10k/core.c 
b/drivers/net/wireless/ath/ath10k/core.c
index eea111d704c5..fb859a0c197a 100644
--- a/drivers/net/wireless/ath/ath10k/core.c
+++ b/drivers/net/wireless/ath/ath10k/core.c
@@ -691,7 +691,7 @@ static int ath10k_core_get_board_id_from_otp(struct ath10k 
*ar)
 {
u32 result, address;
u8 board_id, chip_id;
-   int ret;
+   int ret, bmi_board_id_param;
 
address = ar->hw_params.patch_load_addr;
 
@@ -715,8 +715,13 @@ static int ath10k_core_get_board_id_from_otp(struct ath10k 
*ar)
return ret;
}
 
-   ret = ath10k_bmi_execute(ar, address, BMI_PARAM_GET_EEPROM_BOARD_ID,
-);
+   if (ar->cal_mode == ATH10K_PRE_CAL_MODE_DT ||
+   ar->cal_mode == ATH10K_PRE_CAL_MODE_FILE)
+   bmi_board_id_param = BMI_PARAM_GET_FLASH_BOARD_ID;
+   else
+   bmi_board_id_param = BMI_PARAM_GET_EEPROM_BOARD_ID;
+
+   ret = ath10k_bmi_execute(ar, address, bmi_board_id_param, );
if (ret) {
ath10k_err(ar, "could not execute otp for board id check: %d\n",
   ret);
@@ -845,6 +850,11 @@ static int ath10k_download_and_run_otp(struct ath10k *ar)
return ret;
}
 
+   /* As of now pre-cal is valid for 10_4 variants */
+   if (ar->cal_mode == ATH10K_PRE_CAL_MODE_DT ||
+   ar->cal_mode == ATH10K_PRE_CAL_MODE_FILE)
+   bmi_otp_exe_param = BMI_PARAM_FLASH_SECTION_ALL;
+
ret = ath10k_bmi_execute(ar, address, bmi_otp_exe_param, );
if (ret) {
ath10k_err(ar, "could not execute otp (%d)\n", ret);
-- 
1.7.9.5



[PATCHv3 2/2] ath10k: add support for per sta tx bitrate

2016-11-15 Thread akolli
From: Anilkumar Kolli 

Per STA tx bitrate info is filled from peer stats.
Export per sta txrate info to cfg80211/nl80211

Signed-off-by: Anilkumar Kolli 
---
v2:
 * address Kalle's comments

 drivers/net/wireless/ath/ath10k/debugfs_sta.c |   13 +
 1 file changed, 13 insertions(+)

diff --git a/drivers/net/wireless/ath/ath10k/debugfs_sta.c 
b/drivers/net/wireless/ath/ath10k/debugfs_sta.c
index 9955fea0802a..fce6f8137d33 100644
--- a/drivers/net/wireless/ath/ath10k/debugfs_sta.c
+++ b/drivers/net/wireless/ath/ath10k/debugfs_sta.c
@@ -77,6 +77,19 @@ void ath10k_sta_statistics(struct ieee80211_hw *hw, struct 
ieee80211_vif *vif,
 
sinfo->rx_duration = arsta->rx_duration;
sinfo->filled |= 1ULL << NL80211_STA_INFO_RX_DURATION;
+
+   if (!arsta->txrate.legacy && !arsta->txrate.nss)
+   return;
+
+   if (arsta->txrate.legacy) {
+   sinfo->txrate.legacy = arsta->txrate.legacy;
+   } else {
+   sinfo->txrate.mcs = arsta->txrate.mcs;
+   sinfo->txrate.nss = arsta->txrate.nss;
+   sinfo->txrate.bw = arsta->txrate.bw;
+   }
+   sinfo->txrate.flags = arsta->txrate.flags;
+   sinfo->filled |= 1ULL << NL80211_STA_INFO_TX_BITRATE;
 }
 
 static ssize_t ath10k_dbg_sta_read_aggr_mode(struct file *file,
-- 
1.7.9.5



[PATCHv3 1/2] ath10k: add per peer htt tx stats support for 10.4

2016-11-15 Thread akolli
From: Anilkumar Kolli 

Per peer tx stats are part of 'HTT_10_4_T2H_MSG_TYPE_PEER_STATS'
event, Firmware sends one HTT event for every four PPDUs.
HTT payload has success pkts/bytes, failed pkts/bytes, retry
pkts/bytes and rate info per ppdu.
Peer stats are enabled through 'WMI_SERVICE_PEER_STATS',
which are nowadays enabled by default.

Parse peer stats and update the tx rate information per STA.

tx rate, Peer stats are tested on QCA4019 with Firmware version
10.4-3.2.1-00028.

Signed-off-by: Anilkumar Kolli 
---
v2:
 * address Kalle's comments
 * fix compilation warnings
v3:
 * fix compilation warnings (kvalo)

 drivers/net/wireless/ath/ath10k/core.h   |   17 
 drivers/net/wireless/ath/ath10k/htt.c|2 +
 drivers/net/wireless/ath/ath10k/htt.h|   25 ++
 drivers/net/wireless/ath/ath10k/htt_rx.c |  125 ++
 drivers/net/wireless/ath/ath10k/wmi.h|   10 ++-
 5 files changed, 178 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/ath/ath10k/core.h 
b/drivers/net/wireless/ath/ath10k/core.h
index e8decfaba5b6..2f324a115b18 100644
--- a/drivers/net/wireless/ath/ath10k/core.h
+++ b/drivers/net/wireless/ath/ath10k/core.h
@@ -337,6 +337,7 @@ struct ath10k_sta {
u32 nss;
u32 smps;
u16 peer_id;
+   struct rate_info txrate;
 
struct work_struct update_wk;
 
@@ -693,6 +694,21 @@ struct ath10k_fw_components {
struct ath10k_fw_file fw_file;
 };
 
+struct ath10k_per_peer_tx_stats {
+   u32 succ_bytes;
+   u32 retry_bytes;
+   u32 failed_bytes;
+   u8  ratecode;
+   u8  flags;
+   u16 peer_id;
+   u16 succ_pkts;
+   u16 retry_pkts;
+   u16 failed_pkts;
+   u16 duration;
+   u32 reserved1;
+   u32 reserved2;
+};
+
 struct ath10k {
struct ath_common ath_common;
struct ieee80211_hw *hw;
@@ -906,6 +922,7 @@ struct ath10k {
 
struct ath10k_thermal thermal;
struct ath10k_wow wow;
+   struct ath10k_per_peer_tx_stats peer_tx_stats;
 
/* NAPI */
struct net_device napi_dev;
diff --git a/drivers/net/wireless/ath/ath10k/htt.c 
b/drivers/net/wireless/ath/ath10k/htt.c
index 130cd9502021..cd160b16db1e 100644
--- a/drivers/net/wireless/ath/ath10k/htt.c
+++ b/drivers/net/wireless/ath/ath10k/htt.c
@@ -137,6 +137,8 @@
HTT_T2H_MSG_TYPE_STATS_NOUPLOAD,
[HTT_10_4_T2H_MSG_TYPE_TX_MODE_SWITCH_IND] =
HTT_T2H_MSG_TYPE_TX_MODE_SWITCH_IND,
+   [HTT_10_4_T2H_MSG_TYPE_PEER_STATS] =
+   HTT_T2H_MSG_TYPE_PEER_STATS,
 };
 
 int ath10k_htt_connect(struct ath10k_htt *htt)
diff --git a/drivers/net/wireless/ath/ath10k/htt.h 
b/drivers/net/wireless/ath/ath10k/htt.h
index 0d2ed09f202b..164eb3a10566 100644
--- a/drivers/net/wireless/ath/ath10k/htt.h
+++ b/drivers/net/wireless/ath/ath10k/htt.h
@@ -419,6 +419,7 @@ enum htt_10_4_t2h_msg_type {
HTT_10_4_T2H_MSG_TYPE_STATS_NOUPLOAD = 0x18,
/* 0x19 to 0x2f are reserved */
HTT_10_4_T2H_MSG_TYPE_TX_MODE_SWITCH_IND = 0x30,
+   HTT_10_4_T2H_MSG_TYPE_PEER_STATS = 0x31,
/* keep this last */
HTT_10_4_T2H_NUM_MSGS
 };
@@ -453,6 +454,7 @@ enum htt_t2h_msg_type {
HTT_T2H_MSG_TYPE_TX_FETCH_IND,
HTT_T2H_MSG_TYPE_TX_FETCH_CONFIRM,
HTT_T2H_MSG_TYPE_TX_MODE_SWITCH_IND,
+   HTT_T2H_MSG_TYPE_PEER_STATS,
/* keep this last */
HTT_T2H_NUM_MSGS
 };
@@ -1470,6 +1472,28 @@ struct htt_channel_change {
__le32 phymode;
 } __packed;
 
+struct htt_per_peer_tx_stats_ind {
+   __le32  succ_bytes;
+   __le32  retry_bytes;
+   __le32  failed_bytes;
+   u8  ratecode;
+   u8  flags;
+   __le16  peer_id;
+   __le16  succ_pkts;
+   __le16  retry_pkts;
+   __le16  failed_pkts;
+   __le16  tx_duration;
+   __le32  reserved1;
+   __le32  reserved2;
+} __packed;
+
+struct htt_peer_tx_stats {
+   u8 num_ppdu;
+   u8 ppdu_len;
+   u8 version;
+   u8 payload[0];
+} __packed;
+
 union htt_rx_pn_t {
/* WEP: 24-bit PN */
u32 pn24;
@@ -1521,6 +1545,7 @@ struct htt_resp {
struct htt_tx_fetch_confirm tx_fetch_confirm;
struct htt_tx_mode_switch_ind tx_mode_switch_ind;
struct htt_channel_change chan_change;
+   struct htt_peer_tx_stats peer_tx_stats;
};
 } __packed;
 
diff --git a/drivers/net/wireless/ath/ath10k/htt_rx.c 
b/drivers/net/wireless/ath/ath10k/htt_rx.c
index 285b235268d7..86d082cf4eef 100644
--- a/drivers/net/wireless/ath/ath10k/htt_rx.c
+++ b/drivers/net/wireless/ath/ath10k/htt_rx.c
@@ -2194,6 +2194,128 @@ void ath10k_htt_htc_t2h_msg_handler(struct ath10k *ar, 
struct sk_buff *skb)
dev_kfree_skb_any(skb);
 }
 
+static inline bool is_valid_legacy_rate(u8 rate)
+{
+  

[PATCHv2 0/2] ath10k: add support for tx bitrate

2016-10-18 Thread akolli
From: Anilkumar Kolli 

This patch series adds support for tx bitrate using 
.sta_statistics callback.

tx bitrate tested on QCA4019 using iw.

Anilkumar Kolli (2):
  ath10k: add per peer htt tx stats support for 10.4
  ath10k: add support for per sta tx bitrate

 drivers/net/wireless/ath/ath10k/core.h|   17 
 drivers/net/wireless/ath/ath10k/debugfs_sta.c |   13 +++
 drivers/net/wireless/ath/ath10k/htt.c |2 +
 drivers/net/wireless/ath/ath10k/htt.h |   25 +
 drivers/net/wireless/ath/ath10k/htt_rx.c  |  125 +
 drivers/net/wireless/ath/ath10k/wmi.h |   10 +-
 6 files changed, 191 insertions(+), 1 deletion(-)

-- 
1.7.9.5



[PATCHv2 1/2] ath10k: add per peer htt tx stats support for 10.4

2016-10-18 Thread akolli
From: Anilkumar Kolli 

Per peer tx stats are part of 'HTT_10_4_T2H_MSG_TYPE_PEER_STATS'
event, Firmware sends one HTT event for every four PPDUs.
HTT payload has success pkts/bytes, failed pkts/bytes, retry
pkts/bytes and rate info per ppdu.
Peer stats are enabled through 'WMI_SERVICE_PEER_STATS',
which are nowadays enabled by default.

Parse peer stats and update the tx rate information per STA.

tx rate, Peer stats are tested on QCA4019 with Firmware version
10.4-3.2.1-00028.

Signed-off-by: Anilkumar Kolli 
---
v2:
 * address Kalle's comments 
 * fix compilation warnings

 drivers/net/wireless/ath/ath10k/core.h   |   17 
 drivers/net/wireless/ath/ath10k/htt.c|2 +
 drivers/net/wireless/ath/ath10k/htt.h|   25 ++
 drivers/net/wireless/ath/ath10k/htt_rx.c |  125 ++
 drivers/net/wireless/ath/ath10k/wmi.h|   10 ++-
 5 files changed, 178 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/ath/ath10k/core.h 
b/drivers/net/wireless/ath/ath10k/core.h
index dda49af1eb74..fc3d3bded265 100644
--- a/drivers/net/wireless/ath/ath10k/core.h
+++ b/drivers/net/wireless/ath/ath10k/core.h
@@ -337,6 +337,7 @@ struct ath10k_sta {
u32 nss;
u32 smps;
u16 peer_id;
+   struct rate_info txrate;
 
struct work_struct update_wk;
 
@@ -694,6 +695,21 @@ struct ath10k_fw_components {
struct ath10k_fw_file fw_file;
 };
 
+struct ath10k_per_peer_tx_stats {
+   u32 succ_bytes;
+   u32 retry_bytes;
+   u32 failed_bytes;
+   u8  ratecode;
+   u8  flags;
+   u16 peer_id;
+   u16 succ_pkts;
+   u16 retry_pkts;
+   u16 failed_pkts;
+   u16 duration;
+   u32 reserved1;
+   u32 reserved2;
+};
+
 struct ath10k {
struct ath_common ath_common;
struct ieee80211_hw *hw;
@@ -906,6 +922,7 @@ struct ath10k {
 
struct ath10k_thermal thermal;
struct ath10k_wow wow;
+   struct ath10k_per_peer_tx_stats peer_tx_stats;
 
/* NAPI */
struct net_device napi_dev;
diff --git a/drivers/net/wireless/ath/ath10k/htt.c 
b/drivers/net/wireless/ath/ath10k/htt.c
index 130cd9502021..cd160b16db1e 100644
--- a/drivers/net/wireless/ath/ath10k/htt.c
+++ b/drivers/net/wireless/ath/ath10k/htt.c
@@ -137,6 +137,8 @@ static const enum htt_t2h_msg_type htt_10_4_t2h_msg_types[] 
= {
HTT_T2H_MSG_TYPE_STATS_NOUPLOAD,
[HTT_10_4_T2H_MSG_TYPE_TX_MODE_SWITCH_IND] =
HTT_T2H_MSG_TYPE_TX_MODE_SWITCH_IND,
+   [HTT_10_4_T2H_MSG_TYPE_PEER_STATS] =
+   HTT_T2H_MSG_TYPE_PEER_STATS,
 };
 
 int ath10k_htt_connect(struct ath10k_htt *htt)
diff --git a/drivers/net/wireless/ath/ath10k/htt.h 
b/drivers/net/wireless/ath/ath10k/htt.h
index 0d2ed09f202b..164eb3a10566 100644
--- a/drivers/net/wireless/ath/ath10k/htt.h
+++ b/drivers/net/wireless/ath/ath10k/htt.h
@@ -419,6 +419,7 @@ enum htt_10_4_t2h_msg_type {
HTT_10_4_T2H_MSG_TYPE_STATS_NOUPLOAD = 0x18,
/* 0x19 to 0x2f are reserved */
HTT_10_4_T2H_MSG_TYPE_TX_MODE_SWITCH_IND = 0x30,
+   HTT_10_4_T2H_MSG_TYPE_PEER_STATS = 0x31,
/* keep this last */
HTT_10_4_T2H_NUM_MSGS
 };
@@ -453,6 +454,7 @@ enum htt_t2h_msg_type {
HTT_T2H_MSG_TYPE_TX_FETCH_IND,
HTT_T2H_MSG_TYPE_TX_FETCH_CONFIRM,
HTT_T2H_MSG_TYPE_TX_MODE_SWITCH_IND,
+   HTT_T2H_MSG_TYPE_PEER_STATS,
/* keep this last */
HTT_T2H_NUM_MSGS
 };
@@ -1470,6 +1472,28 @@ struct htt_channel_change {
__le32 phymode;
 } __packed;
 
+struct htt_per_peer_tx_stats_ind {
+   __le32  succ_bytes;
+   __le32  retry_bytes;
+   __le32  failed_bytes;
+   u8  ratecode;
+   u8  flags;
+   __le16  peer_id;
+   __le16  succ_pkts;
+   __le16  retry_pkts;
+   __le16  failed_pkts;
+   __le16  tx_duration;
+   __le32  reserved1;
+   __le32  reserved2;
+} __packed;
+
+struct htt_peer_tx_stats {
+   u8 num_ppdu;
+   u8 ppdu_len;
+   u8 version;
+   u8 payload[0];
+} __packed;
+
 union htt_rx_pn_t {
/* WEP: 24-bit PN */
u32 pn24;
@@ -1521,6 +1545,7 @@ struct htt_resp {
struct htt_tx_fetch_confirm tx_fetch_confirm;
struct htt_tx_mode_switch_ind tx_mode_switch_ind;
struct htt_channel_change chan_change;
+   struct htt_peer_tx_stats peer_tx_stats;
};
 } __packed;
 
diff --git a/drivers/net/wireless/ath/ath10k/htt_rx.c 
b/drivers/net/wireless/ath/ath10k/htt_rx.c
index 0b4c1562420f..ef28b358cf5e 100644
--- a/drivers/net/wireless/ath/ath10k/htt_rx.c
+++ b/drivers/net/wireless/ath/ath10k/htt_rx.c
@@ -2194,6 +2194,128 @@ void ath10k_htt_htc_t2h_msg_handler(struct ath10k *ar, 
struct sk_buff *skb)
dev_kfree_skb_any(skb);
 }
 
+static inline bool 

[PATCH 1/2] ath10k: add per peer htt tx stats support for 10.4

2016-10-18 Thread akolli
From: Anilkumar Kolli 

Per peer tx stats are part of 'HTT_10_4_T2H_MSG_TYPE_PEER_STATS'
event, Firmware sends one HTT event for every four PPDUs.
HTT payload has success pkts/bytes, failed pkts/bytes, retry
pkts/bytes and rate info per ppdu.
Peer stats are enabled through 'WMI_SERVICE_PEER_STATS',
which are nowadays enabled by default.

Parse peer stats and update the tx rate information per STA.

tx rate, Peer stats are tested on QCA4019 with Firmware version
10.4-3.2.1-00028.

Signed-off-by: Anilkumar Kolli 
---
v2:
 * address Kalle's comments 
 * fix compilation warnings

 drivers/net/wireless/ath/ath10k/core.h   |   17 
 drivers/net/wireless/ath/ath10k/htt.c|2 +
 drivers/net/wireless/ath/ath10k/htt.h|   25 ++
 drivers/net/wireless/ath/ath10k/htt_rx.c |  125 ++
 drivers/net/wireless/ath/ath10k/wmi.h|   10 ++-
 5 files changed, 178 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/ath/ath10k/core.h 
b/drivers/net/wireless/ath/ath10k/core.h
index dda49af1eb74..fc3d3bded265 100644
--- a/drivers/net/wireless/ath/ath10k/core.h
+++ b/drivers/net/wireless/ath/ath10k/core.h
@@ -337,6 +337,7 @@ struct ath10k_sta {
u32 nss;
u32 smps;
u16 peer_id;
+   struct rate_info txrate;
 
struct work_struct update_wk;
 
@@ -694,6 +695,21 @@ struct ath10k_fw_components {
struct ath10k_fw_file fw_file;
 };
 
+struct ath10k_per_peer_tx_stats {
+   u32 succ_bytes;
+   u32 retry_bytes;
+   u32 failed_bytes;
+   u8  ratecode;
+   u8  flags;
+   u16 peer_id;
+   u16 succ_pkts;
+   u16 retry_pkts;
+   u16 failed_pkts;
+   u16 duration;
+   u32 reserved1;
+   u32 reserved2;
+};
+
 struct ath10k {
struct ath_common ath_common;
struct ieee80211_hw *hw;
@@ -906,6 +922,7 @@ struct ath10k {
 
struct ath10k_thermal thermal;
struct ath10k_wow wow;
+   struct ath10k_per_peer_tx_stats peer_tx_stats;
 
/* NAPI */
struct net_device napi_dev;
diff --git a/drivers/net/wireless/ath/ath10k/htt.c 
b/drivers/net/wireless/ath/ath10k/htt.c
index 130cd9502021..cd160b16db1e 100644
--- a/drivers/net/wireless/ath/ath10k/htt.c
+++ b/drivers/net/wireless/ath/ath10k/htt.c
@@ -137,6 +137,8 @@ static const enum htt_t2h_msg_type htt_10_4_t2h_msg_types[] 
= {
HTT_T2H_MSG_TYPE_STATS_NOUPLOAD,
[HTT_10_4_T2H_MSG_TYPE_TX_MODE_SWITCH_IND] =
HTT_T2H_MSG_TYPE_TX_MODE_SWITCH_IND,
+   [HTT_10_4_T2H_MSG_TYPE_PEER_STATS] =
+   HTT_T2H_MSG_TYPE_PEER_STATS,
 };
 
 int ath10k_htt_connect(struct ath10k_htt *htt)
diff --git a/drivers/net/wireless/ath/ath10k/htt.h 
b/drivers/net/wireless/ath/ath10k/htt.h
index 0d2ed09f202b..164eb3a10566 100644
--- a/drivers/net/wireless/ath/ath10k/htt.h
+++ b/drivers/net/wireless/ath/ath10k/htt.h
@@ -419,6 +419,7 @@ enum htt_10_4_t2h_msg_type {
HTT_10_4_T2H_MSG_TYPE_STATS_NOUPLOAD = 0x18,
/* 0x19 to 0x2f are reserved */
HTT_10_4_T2H_MSG_TYPE_TX_MODE_SWITCH_IND = 0x30,
+   HTT_10_4_T2H_MSG_TYPE_PEER_STATS = 0x31,
/* keep this last */
HTT_10_4_T2H_NUM_MSGS
 };
@@ -453,6 +454,7 @@ enum htt_t2h_msg_type {
HTT_T2H_MSG_TYPE_TX_FETCH_IND,
HTT_T2H_MSG_TYPE_TX_FETCH_CONFIRM,
HTT_T2H_MSG_TYPE_TX_MODE_SWITCH_IND,
+   HTT_T2H_MSG_TYPE_PEER_STATS,
/* keep this last */
HTT_T2H_NUM_MSGS
 };
@@ -1470,6 +1472,28 @@ struct htt_channel_change {
__le32 phymode;
 } __packed;
 
+struct htt_per_peer_tx_stats_ind {
+   __le32  succ_bytes;
+   __le32  retry_bytes;
+   __le32  failed_bytes;
+   u8  ratecode;
+   u8  flags;
+   __le16  peer_id;
+   __le16  succ_pkts;
+   __le16  retry_pkts;
+   __le16  failed_pkts;
+   __le16  tx_duration;
+   __le32  reserved1;
+   __le32  reserved2;
+} __packed;
+
+struct htt_peer_tx_stats {
+   u8 num_ppdu;
+   u8 ppdu_len;
+   u8 version;
+   u8 payload[0];
+} __packed;
+
 union htt_rx_pn_t {
/* WEP: 24-bit PN */
u32 pn24;
@@ -1521,6 +1545,7 @@ struct htt_resp {
struct htt_tx_fetch_confirm tx_fetch_confirm;
struct htt_tx_mode_switch_ind tx_mode_switch_ind;
struct htt_channel_change chan_change;
+   struct htt_peer_tx_stats peer_tx_stats;
};
 } __packed;
 
diff --git a/drivers/net/wireless/ath/ath10k/htt_rx.c 
b/drivers/net/wireless/ath/ath10k/htt_rx.c
index 0b4c1562420f..ef28b358cf5e 100644
--- a/drivers/net/wireless/ath/ath10k/htt_rx.c
+++ b/drivers/net/wireless/ath/ath10k/htt_rx.c
@@ -2194,6 +2194,128 @@ void ath10k_htt_htc_t2h_msg_handler(struct ath10k *ar, 
struct sk_buff *skb)
dev_kfree_skb_any(skb);
 }
 
+static inline bool 

[PATCHv2 0/2] ath10k: add support for tx bitrate

2016-10-18 Thread akolli
From: Anilkumar Kolli 

This patch series adds support for tx bitrate using 
.sta_statistics callback.

tx bitrate tested on QCA4019 using iw.

Anilkumar Kolli (2):
  ath10k: add per peer htt tx stats support for 10.4
  ath10k: add support for per sta tx bitrate

 drivers/net/wireless/ath/ath10k/core.h|   17 
 drivers/net/wireless/ath/ath10k/debugfs_sta.c |   13 +++
 drivers/net/wireless/ath/ath10k/htt.c |2 +
 drivers/net/wireless/ath/ath10k/htt.h |   25 +
 drivers/net/wireless/ath/ath10k/htt_rx.c  |  125 +
 drivers/net/wireless/ath/ath10k/wmi.h |   10 +-
 6 files changed, 191 insertions(+), 1 deletion(-)

-- 
1.7.9.5



[PATCHv2 0/2] ath10k: add support for tx bitrate

2016-10-18 Thread akolli
From: Anilkumar Kolli 

This patch series adds support for tx bitrate using 
.sta_statistics callback.

tx bitrate tested on QCA4019 using iw.

Anilkumar Kolli (2):
  ath10k: add per peer htt tx stats support for 10.4
  ath10k: add support for per sta tx bitrate

 drivers/net/wireless/ath/ath10k/core.h|   17 
 drivers/net/wireless/ath/ath10k/debugfs_sta.c |   13 +++
 drivers/net/wireless/ath/ath10k/htt.c |2 +
 drivers/net/wireless/ath/ath10k/htt.h |   25 +
 drivers/net/wireless/ath/ath10k/htt_rx.c  |  125 +
 drivers/net/wireless/ath/ath10k/wmi.h |   10 +-
 6 files changed, 191 insertions(+), 1 deletion(-)

-- 
1.7.9.5



Re: [PATCH 1/2] ath10k: add per peer htt tx stats support for 10.4

2016-10-17 Thread akolli


On 2016-10-12 10:29, Valo, Kalle wrote:

 writes:


From: Anilkumar Kolli 

Per peer tx stats are part of 'HTT_10_4_T2H_MSG_TYPE_PEER_STATS'
event, Firmware sends one HTT event for every four PPDUs.
HTT payload has success pkts/bytes, failed pkts/bytes, retry
pkts/bytes and rate info per ppdu.
Peer stats are enabled through 'WMI_SERVICE_PEER_STATS',
which are nowadays enabled by default.

Parse peer stats and update the tx rate information per STA.

tx rate, Peer stats are tested on QCA4019 with Firmware version
10.4-3.2.1-00028.

Signed-off-by: Anilkumar Kolli 


This and patch 2 add few new warnings:

drivers/net/wireless/ath/ath10k/htt_rx.c: In function
'ath10k_htt_fetch_peer_stats':
drivers/net/wireless/ath/ath10k/htt_rx.c:2279:3: warning: too many
arguments for format [-Wformat-extra-args]
drivers/net/wireless/ath/ath10k/htt_rx.c:2285:17: warning: incorrect
type in assignment (different base types)
drivers/net/wireless/ath/ath10k/htt_rx.c:2285:17:expected unsigned
int [unsigned] [usertype] peer_id
drivers/net/wireless/ath/ath10k/htt_rx.c:2285:17:got restricted
__le16 [usertype] peer_id
drivers/net/wireless/ath/ath10k/debugfs_sta.c:84: space required
before the open parenthesis '('


I will fix and send V2.

Thanks,
Anil.


[PATCH 2/2] ath10k: add support for per sta tx bitrate

2016-10-07 Thread akolli
From: Anilkumar Kolli 

Per STA tx bitrate info is filled from peer stats.
Export per sta txrate info to cfg80211/nl80211

Signed-off-by: Anilkumar Kolli 
---
 drivers/net/wireless/ath/ath10k/debugfs_sta.c |   13 +
 1 file changed, 13 insertions(+)

diff --git a/drivers/net/wireless/ath/ath10k/debugfs_sta.c 
b/drivers/net/wireless/ath/ath10k/debugfs_sta.c
index 9955fea0802a..7daf9927a1ef 100644
--- a/drivers/net/wireless/ath/ath10k/debugfs_sta.c
+++ b/drivers/net/wireless/ath/ath10k/debugfs_sta.c
@@ -77,6 +77,19 @@ void ath10k_sta_statistics(struct ieee80211_hw *hw, struct 
ieee80211_vif *vif,
 
sinfo->rx_duration = arsta->rx_duration;
sinfo->filled |= 1ULL << NL80211_STA_INFO_RX_DURATION;
+
+   if (!arsta->txrate.legacy && !arsta->txrate.nss)
+   return;
+
+   if(arsta->txrate.legacy) {
+   sinfo->txrate.legacy = arsta->txrate.legacy;
+   } else {
+   sinfo->txrate.mcs = arsta->txrate.mcs;
+   sinfo->txrate.nss = arsta->txrate.nss;
+   sinfo->txrate.bw = arsta->txrate.bw;
+   }
+   sinfo->txrate.flags = arsta->txrate.flags;
+   sinfo->filled |= 1ULL << NL80211_STA_INFO_TX_BITRATE;
 }
 
 static ssize_t ath10k_dbg_sta_read_aggr_mode(struct file *file,
-- 
1.7.9.5



[PATCH 1/2] ath10k: add per peer htt tx stats support for 10.4

2016-10-07 Thread akolli
From: Anilkumar Kolli 

Per peer tx stats are part of 'HTT_10_4_T2H_MSG_TYPE_PEER_STATS'
event, Firmware sends one HTT event for every four PPDUs.
HTT payload has success pkts/bytes, failed pkts/bytes, retry
pkts/bytes and rate info per ppdu.
Peer stats are enabled through 'WMI_SERVICE_PEER_STATS',
which are nowadays enabled by default.

Parse peer stats and update the tx rate information per STA.

tx rate, Peer stats are tested on QCA4019 with Firmware version
10.4-3.2.1-00028.

Signed-off-by: Anilkumar Kolli 
---
 drivers/net/wireless/ath/ath10k/core.h   |   17 
 drivers/net/wireless/ath/ath10k/htt.c|2 +
 drivers/net/wireless/ath/ath10k/htt.h|   25 ++
 drivers/net/wireless/ath/ath10k/htt_rx.c |  125 ++
 drivers/net/wireless/ath/ath10k/wmi.h|   10 ++-
 5 files changed, 178 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/ath/ath10k/core.h 
b/drivers/net/wireless/ath/ath10k/core.h
index dda49af1eb74..fc3d3bded265 100644
--- a/drivers/net/wireless/ath/ath10k/core.h
+++ b/drivers/net/wireless/ath/ath10k/core.h
@@ -337,6 +337,7 @@ struct ath10k_sta {
u32 nss;
u32 smps;
u16 peer_id;
+   struct rate_info txrate;
 
struct work_struct update_wk;
 
@@ -694,6 +695,21 @@ struct ath10k_fw_components {
struct ath10k_fw_file fw_file;
 };
 
+struct ath10k_per_peer_tx_stats {
+   u32 succ_bytes;
+   u32 retry_bytes;
+   u32 failed_bytes;
+   u8  ratecode;
+   u8  flags;
+   u16 peer_id;
+   u16 succ_pkts;
+   u16 retry_pkts;
+   u16 failed_pkts;
+   u16 duration;
+   u32 reserved1;
+   u32 reserved2;
+};
+
 struct ath10k {
struct ath_common ath_common;
struct ieee80211_hw *hw;
@@ -906,6 +922,7 @@ struct ath10k {
 
struct ath10k_thermal thermal;
struct ath10k_wow wow;
+   struct ath10k_per_peer_tx_stats peer_tx_stats;
 
/* NAPI */
struct net_device napi_dev;
diff --git a/drivers/net/wireless/ath/ath10k/htt.c 
b/drivers/net/wireless/ath/ath10k/htt.c
index 130cd9502021..cd160b16db1e 100644
--- a/drivers/net/wireless/ath/ath10k/htt.c
+++ b/drivers/net/wireless/ath/ath10k/htt.c
@@ -137,6 +137,8 @@ static const enum htt_t2h_msg_type htt_10_4_t2h_msg_types[] 
= {
HTT_T2H_MSG_TYPE_STATS_NOUPLOAD,
[HTT_10_4_T2H_MSG_TYPE_TX_MODE_SWITCH_IND] =
HTT_T2H_MSG_TYPE_TX_MODE_SWITCH_IND,
+   [HTT_10_4_T2H_MSG_TYPE_PEER_STATS] =
+   HTT_T2H_MSG_TYPE_PEER_STATS,
 };
 
 int ath10k_htt_connect(struct ath10k_htt *htt)
diff --git a/drivers/net/wireless/ath/ath10k/htt.h 
b/drivers/net/wireless/ath/ath10k/htt.h
index 0d2ed09f202b..164eb3a10566 100644
--- a/drivers/net/wireless/ath/ath10k/htt.h
+++ b/drivers/net/wireless/ath/ath10k/htt.h
@@ -419,6 +419,7 @@ enum htt_10_4_t2h_msg_type {
HTT_10_4_T2H_MSG_TYPE_STATS_NOUPLOAD = 0x18,
/* 0x19 to 0x2f are reserved */
HTT_10_4_T2H_MSG_TYPE_TX_MODE_SWITCH_IND = 0x30,
+   HTT_10_4_T2H_MSG_TYPE_PEER_STATS = 0x31,
/* keep this last */
HTT_10_4_T2H_NUM_MSGS
 };
@@ -453,6 +454,7 @@ enum htt_t2h_msg_type {
HTT_T2H_MSG_TYPE_TX_FETCH_IND,
HTT_T2H_MSG_TYPE_TX_FETCH_CONFIRM,
HTT_T2H_MSG_TYPE_TX_MODE_SWITCH_IND,
+   HTT_T2H_MSG_TYPE_PEER_STATS,
/* keep this last */
HTT_T2H_NUM_MSGS
 };
@@ -1470,6 +1472,28 @@ struct htt_channel_change {
__le32 phymode;
 } __packed;
 
+struct htt_per_peer_tx_stats_ind {
+   __le32  succ_bytes;
+   __le32  retry_bytes;
+   __le32  failed_bytes;
+   u8  ratecode;
+   u8  flags;
+   __le16  peer_id;
+   __le16  succ_pkts;
+   __le16  retry_pkts;
+   __le16  failed_pkts;
+   __le16  tx_duration;
+   __le32  reserved1;
+   __le32  reserved2;
+} __packed;
+
+struct htt_peer_tx_stats {
+   u8 num_ppdu;
+   u8 ppdu_len;
+   u8 version;
+   u8 payload[0];
+} __packed;
+
 union htt_rx_pn_t {
/* WEP: 24-bit PN */
u32 pn24;
@@ -1521,6 +1545,7 @@ struct htt_resp {
struct htt_tx_fetch_confirm tx_fetch_confirm;
struct htt_tx_mode_switch_ind tx_mode_switch_ind;
struct htt_channel_change chan_change;
+   struct htt_peer_tx_stats peer_tx_stats;
};
 } __packed;
 
diff --git a/drivers/net/wireless/ath/ath10k/htt_rx.c 
b/drivers/net/wireless/ath/ath10k/htt_rx.c
index 0b4c1562420f..eab719d9729b 100644
--- a/drivers/net/wireless/ath/ath10k/htt_rx.c
+++ b/drivers/net/wireless/ath/ath10k/htt_rx.c
@@ -2194,6 +2194,128 @@ void ath10k_htt_htc_t2h_msg_handler(struct ath10k *ar, 
struct sk_buff *skb)
dev_kfree_skb_any(skb);
 }
 
+static inline bool is_valid_legacy_rate(u8 rate)
+{
+   static const u8 legacy_rates[] = 

[PATCH 0/2] ath10k: add support for tx bitrate

2016-10-07 Thread akolli
From: Anilkumar Kolli 

This patch series adds support for tx bitrate using 
.sta_statistics callback.

tx bitrate tested on QCA4019 using iw.

Anilkumar Kolli (2):
  ath10k: add per peer htt tx stats support for 10.4
  ath10k: add support for per sta tx bitrate

 drivers/net/wireless/ath/ath10k/core.h|   17 
 drivers/net/wireless/ath/ath10k/debugfs_sta.c |   13 +++
 drivers/net/wireless/ath/ath10k/htt.c |2 +
 drivers/net/wireless/ath/ath10k/htt.h |   25 +
 drivers/net/wireless/ath/ath10k/htt_rx.c  |  125 +
 drivers/net/wireless/ath/ath10k/wmi.h |   10 +-
 6 files changed, 191 insertions(+), 1 deletion(-)

-- 
1.7.9.5



[PATCH] ath10k: add cc_wraparound type for QCA9888 and QCA9884

2016-09-16 Thread akolli
From: Anilkumar Kolli 

During offchannel scan, iw survey dump shows wrong values.
Fix this by assigning cycle counter wranarround type for
QCA9888 and QCA9884, they share same config with QCA4019.

Signed-off-by: Anilkumar Kolli 
---
 drivers/net/wireless/ath/ath10k/core.c |2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/wireless/ath/ath10k/core.c 
b/drivers/net/wireless/ath/ath10k/core.c
index 3a8984ba9f74..93168d9f8902 100644
--- a/drivers/net/wireless/ath/ath10k/core.c
+++ b/drivers/net/wireless/ath/ath10k/core.c
@@ -191,6 +191,7 @@ static const struct ath10k_hw_params 
ath10k_hw_params_list[] = {
.name = "qca9984/qca9994 hw1.0",
.patch_load_addr = QCA9984_HW_1_0_PATCH_LOAD_ADDR,
.uart_pin = 7,
+   .cc_wraparound_type = ATH10K_HW_CC_WRAP_SHIFTED_EACH,
.otp_exe_param = 0x0700,
.continuous_frag_desc = true,
.cck_rate_map_rev2 = true,
@@ -215,6 +216,7 @@ static const struct ath10k_hw_params 
ath10k_hw_params_list[] = {
.name = "qca9888 hw2.0",
.patch_load_addr = QCA9888_HW_2_0_PATCH_LOAD_ADDR,
.uart_pin = 7,
+   .cc_wraparound_type = ATH10K_HW_CC_WRAP_SHIFTED_EACH,
.otp_exe_param = 0x0700,
.continuous_frag_desc = true,
.channel_counters_freq_hz = 15,
-- 
1.7.9.5



[PATCH 2/2] ath10k: Enable support for QCA9888

2016-06-20 Thread akolli
From: Anilkumar Kolli 

QCA9888 shares the same configuration with QCA99X0
with NSS=2.

Signed-off-by: Anilkumar Kolli 
---
 drivers/net/wireless/ath/ath10k/core.c |   26 ++
 drivers/net/wireless/ath/ath10k/hw.c   |9 +
 drivers/net/wireless/ath/ath10k/hw.h   |   12 
 drivers/net/wireless/ath/ath10k/pci.c  |   13 +
 4 files changed, 60 insertions(+)

diff --git a/drivers/net/wireless/ath/ath10k/core.c 
b/drivers/net/wireless/ath/ath10k/core.c
index a003980d8972..8a080ab5b07e 100644
--- a/drivers/net/wireless/ath/ath10k/core.c
+++ b/drivers/net/wireless/ath/ath10k/core.c
@@ -185,6 +185,28 @@ static const struct ath10k_hw_params 
ath10k_hw_params_list[] = {
},
},
{
+   .id = QCA9888_HW_2_0_DEV_VERSION,
+   .dev_id = QCA9888_2_0_DEVICE_ID,
+   .name = "qca9888 hw2.0",
+   .patch_load_addr = QCA9888_HW_2_0_PATCH_LOAD_ADDR,
+   .uart_pin = 7,
+   .otp_exe_param = 0x0700,
+   .continuous_frag_desc = true,
+   .channel_counters_freq_hz = 15,
+   .max_probe_resp_desc_thres = 24,
+   .hw_4addr_pad = ATH10K_HW_4ADDR_PAD_BEFORE,
+   .tx_chain_mask = 3,
+   .rx_chain_mask = 3,
+   .max_spatial_stream = 2,
+   .cal_data_len = 12064,
+   .fw = {
+   .dir = QCA9888_HW_2_0_FW_DIR,
+   .board = QCA9888_HW_2_0_BOARD_DATA_FILE,
+   .board_size = QCA99X0_BOARD_DATA_SZ,
+   .board_ext_size = QCA99X0_BOARD_EXT_DATA_SZ,
+   },
+   },
+   {
.id = QCA9377_HW_1_0_DEV_VERSION,
.dev_id = QCA9377_1_0_DEVICE_ID,
.name = "qca9377 hw1.0",
@@ -2097,6 +2119,10 @@ struct ath10k *ath10k_core_create(size_t priv_size, 
struct device *dev,
ar->regs = _regs;
ar->hw_values = _values;
break;
+   case ATH10K_HW_QCA9888:
+   ar->regs = _regs;
+   ar->hw_values = _values;
+   break;
case ATH10K_HW_QCA4019:
ar->regs = _regs;
ar->hw_values = _values;
diff --git a/drivers/net/wireless/ath/ath10k/hw.c 
b/drivers/net/wireless/ath/ath10k/hw.c
index 433e064c7718..c2c0122a140b 100644
--- a/drivers/net/wireless/ath/ath10k/hw.c
+++ b/drivers/net/wireless/ath/ath10k/hw.c
@@ -165,6 +165,15 @@ const struct ath10k_hw_values qca99x0_values = {
.ce_desc_meta_data_lsb  = 4,
 };
 
+const struct ath10k_hw_values qca9888_values = {
+   .rtc_state_val_on   = 3,
+   .ce_count   = 12,
+   .msi_assign_ce_max  = 12,
+   .num_target_ce_config_wlan  = 10,
+   .ce_desc_meta_data_mask = 0xFFF0,
+   .ce_desc_meta_data_lsb  = 4,
+};
+
 const struct ath10k_hw_values qca4019_values = {
.ce_count   = 12,
.num_target_ce_config_wlan  = 10,
diff --git a/drivers/net/wireless/ath/ath10k/hw.h 
b/drivers/net/wireless/ath/ath10k/hw.h
index 549f99bdfb86..d537555b28e7 100644
--- a/drivers/net/wireless/ath/ath10k/hw.h
+++ b/drivers/net/wireless/ath/ath10k/hw.h
@@ -26,6 +26,7 @@
 #define QCA6164_2_1_DEVICE_ID   (0x0041)
 #define QCA6174_2_1_DEVICE_ID   (0x003e)
 #define QCA99X0_2_0_DEVICE_ID   (0x0040)
+#define QCA9888_2_0_DEVICE_ID  (0x0056)
 #define QCA9984_1_0_DEVICE_ID  (0x0046)
 #define QCA9377_1_0_DEVICE_ID   (0x0042)
 
@@ -100,6 +101,14 @@ enum qca9377_chip_id_rev {
 #define QCA9984_HW_1_0_BOARD_DATA_FILE "board.bin"
 #define QCA9984_HW_1_0_PATCH_LOAD_ADDR 0x1234
 
+/* QCA9888 2.0 defines */
+#define QCA9888_HW_2_0_DEV_VERSION 0x100
+#define QCA9888_HW_DEV_TYPE0xc
+#define QCA9888_HW_2_0_CHIP_ID_REV 0x0
+#define QCA9888_HW_2_0_FW_DIR  ATH10K_FW_DIR "/QCA9888/hw2.0"
+#define QCA9888_HW_2_0_BOARD_DATA_FILE "board.bin"
+#define QCA9888_HW_2_0_PATCH_LOAD_ADDR 0x1234
+
 /* QCA9377 1.0 definitions */
 #define QCA9377_HW_1_0_FW_DIR  ATH10K_FW_DIR "/QCA9377/hw1.0"
 #define QCA9377_HW_1_0_BOARD_DATA_FILE "board.bin"
@@ -202,6 +211,7 @@ enum ath10k_hw_rev {
ATH10K_HW_QCA988X,
ATH10K_HW_QCA6174,
ATH10K_HW_QCA99X0,
+   ATH10K_HW_QCA9888,
ATH10K_HW_QCA9984,
ATH10K_HW_QCA9377,
ATH10K_HW_QCA4019,
@@ -250,6 +260,7 @@ struct ath10k_hw_values {
 extern const struct ath10k_hw_values qca988x_values;
 extern const struct ath10k_hw_values qca6174_values;
 extern const struct ath10k_hw_values qca99x0_values;
+extern const struct ath10k_hw_values qca9888_values;
 extern const struct ath10k_hw_values qca4019_values;
 
 void ath10k_hw_fill_survey_time(struct ath10k *ar, struct survey_info *survey,
@@ -258,6 +269,7 @@ void ath10k_hw_fill_survey_time(struct ath10k *ar, struct 
survey_info 

[PATCH 1/2] ath10k: remove unused member in ath10k_hw_regs

2016-06-20 Thread akolli
From: Anilkumar Kolli 

rtc_state_cold_reset_mask is unused in ath10k_hw_regs.
instead fixed delays are used.

Signed-off-by: Anilkumar Kolli 
---
 drivers/net/wireless/ath/ath10k/hw.c |3 ---
 drivers/net/wireless/ath/ath10k/hw.h |2 --
 2 files changed, 5 deletions(-)

diff --git a/drivers/net/wireless/ath/ath10k/hw.c 
b/drivers/net/wireless/ath/ath10k/hw.c
index f544d48518c3..433e064c7718 100644
--- a/drivers/net/wireless/ath/ath10k/hw.c
+++ b/drivers/net/wireless/ath/ath10k/hw.c
@@ -19,7 +19,6 @@
 #include "hw.h"
 
 const struct ath10k_hw_regs qca988x_regs = {
-   .rtc_state_cold_reset_mask  = 0x0400,
.rtc_soc_base_address   = 0x4000,
.rtc_wmac_base_address  = 0x5000,
.soc_core_base_address  = 0x9000,
@@ -46,7 +45,6 @@ const struct ath10k_hw_regs qca988x_regs = {
 };
 
 const struct ath10k_hw_regs qca6174_regs = {
-   .rtc_state_cold_reset_mask  = 0x2000,
.rtc_soc_base_address   = 0x0800,
.rtc_wmac_base_address  = 0x1000,
.soc_core_base_address  = 0x0003a000,
@@ -73,7 +71,6 @@ const struct ath10k_hw_regs qca6174_regs = {
 };
 
 const struct ath10k_hw_regs qca99x0_regs = {
-   .rtc_state_cold_reset_mask  = 0x0400,
.rtc_soc_base_address   = 0x0008,
.rtc_wmac_base_address  = 0x,
.soc_core_base_address  = 0x00082000,
diff --git a/drivers/net/wireless/ath/ath10k/hw.h 
b/drivers/net/wireless/ath/ath10k/hw.h
index f41c91ccb56a..549f99bdfb86 100644
--- a/drivers/net/wireless/ath/ath10k/hw.h
+++ b/drivers/net/wireless/ath/ath10k/hw.h
@@ -208,7 +208,6 @@ enum ath10k_hw_rev {
 };
 
 struct ath10k_hw_regs {
-   u32 rtc_state_cold_reset_mask;
u32 rtc_soc_base_address;
u32 rtc_wmac_base_address;
u32 soc_core_base_address;
@@ -495,7 +494,6 @@ enum ath10k_hw_4addr_pad {
 /* as of IP3.7.1 */
 #define RTC_STATE_V_ON ar->hw_values->rtc_state_val_on
 
-#define RTC_STATE_COLD_RESET_MASK  
ar->regs->rtc_state_cold_reset_mask
 #define RTC_STATE_V_LSB0
 #define RTC_STATE_V_MASK   0x0007
 #define RTC_STATE_ADDRESS  0x
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] ath10k: fix kernel panic, move arvifs list head init before htt init

2016-04-26 Thread akolli
From: Anilkumar Kolli 

It is observed that while loading and unloading ath10k modules
in an infinite loop, before ath10k_core_start() completion HTT
rx frames are received, while processing these frames,
dereferencing the arvifs list code is getting hit before
initilizing the arvifs list, causing a kernel panic.

This patch initilizes the arvifs list before initilizing htt.

Fixes the below issue:
 [] (ath10k_htt_rx_pktlog_completion_handler+0x278/0xd08 
[ath10k_core])
 [] (ath10k_htt_rx_pktlog_completion_handler [ath10k_core])
 [] (ath10k_htt_txrx_compl_task+0x5f4/0xeb0 [ath10k_core])
 [] (ath10k_htt_txrx_compl_task [ath10k_core])
 [] (tasklet_action+0x8c/0xec)
 [] (tasklet_action)
 [] (__do_softirq+0xf8/0x228)
 [] (__do_softirq)  [] (run_ksoftirqd+0x30/0x90)
 Code: e5954ad8 e2899008 e1540009 0a0d (e5943008)
 ---[ end trace 71de5c2e011dbf56 ]---
 Kernel panic - not syncing: Fatal exception in interrupt

Fixes: 500ff9f9389d ("ath10k: implement chanctx API")
Cc: sta...@vger.kernel.org

Signed-off-by: Anilkumar Kolli 
---
 drivers/net/wireless/ath/ath10k/core.c |8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/net/wireless/ath/ath10k/core.c 
b/drivers/net/wireless/ath/ath10k/core.c
index b2c7fe3d30a4..83e02f292828 100644
--- a/drivers/net/wireless/ath/ath10k/core.c
+++ b/drivers/net/wireless/ath/ath10k/core.c
@@ -1822,6 +1822,10 @@ int ath10k_core_start(struct ath10k *ar, enum 
ath10k_firmware_mode mode)
goto err_hif_stop;
}
 
+   ar->free_vdev_map = (1LL << ar->max_num_vdevs) - 1;
+
+   INIT_LIST_HEAD(>arvifs);
+
/* we don't care about HTT in UTF mode */
if (mode == ATH10K_FIRMWARE_MODE_NORMAL) {
status = ath10k_htt_setup(>htt);
@@ -1835,10 +1839,6 @@ int ath10k_core_start(struct ath10k *ar, enum 
ath10k_firmware_mode mode)
if (status)
goto err_hif_stop;
 
-   ar->free_vdev_map = (1LL << ar->max_num_vdevs) - 1;
-
-   INIT_LIST_HEAD(>arvifs);
-
return 0;
 
 err_hif_stop:
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2] ath10k: fix debugfs pktlog_filter write

2016-03-10 Thread akolli
From: Anilkumar Kolli 

It is observed that, we are disabling the packet log if we write same
value to the pktlog_filter for the second time. Always enable pktlogs
on non zero filter.

Fixes: 90174455ae05 ("ath10k: add support to configure pktlog filter")
Cc: sta...@vger.kernel.org
Signed-off-by: Anilkumar Kolli 
---
v2:
 * added sta...@vger.kernel.org

 drivers/net/wireless/ath/ath10k/debug.c |7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/ath/ath10k/debug.c 
b/drivers/net/wireless/ath/ath10k/debug.c
index 076d29b53ddf..0f834646e6a7 100644
--- a/drivers/net/wireless/ath/ath10k/debug.c
+++ b/drivers/net/wireless/ath/ath10k/debug.c
@@ -2019,7 +2019,12 @@ static ssize_t ath10k_write_pktlog_filter(struct file 
*file,
goto out;
}
 
-   if (filter && (filter != ar->debug.pktlog_filter)) {
+   if (filter == ar->debug.pktlog_filter) {
+   ret = count;
+   goto out;
+   }
+
+   if (filter) {
ret = ath10k_wmi_pdev_pktlog_enable(ar, filter);
if (ret) {
ath10k_warn(ar, "failed to enable pktlog filter %x: 
%d\n",
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] ath10k: fix debugfs pktlog_filter write

2016-03-10 Thread akolli
From: Anilkumar Kolli 

It is observed that, we are disabling the packet log if we write same
value to the pktlog_filter for the second time. Always enable pktlogs
on non zero filter.

Fixes: 90174455ae05 ("ath10k: add support to configure pktlog filter")
Signed-off-by: Anilkumar Kolli 
---
 drivers/net/wireless/ath/ath10k/debug.c |7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/ath/ath10k/debug.c 
b/drivers/net/wireless/ath/ath10k/debug.c
index 076d29b53ddf..0f834646e6a7 100644
--- a/drivers/net/wireless/ath/ath10k/debug.c
+++ b/drivers/net/wireless/ath/ath10k/debug.c
@@ -2019,7 +2019,12 @@ static ssize_t ath10k_write_pktlog_filter(struct file 
*file,
goto out;
}
 
-   if (filter && (filter != ar->debug.pktlog_filter)) {
+   if (filter == ar->debug.pktlog_filter) {
+   ret = count;
+   goto out;
+   }
+
+   if (filter) {
ret = ath10k_wmi_pdev_pktlog_enable(ar, filter);
if (ret) {
ath10k_warn(ar, "failed to enable pktlog filter %x: 
%d\n",
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] ath10k: Reduce number of peers to support peer stats feature

2016-02-22 Thread akolli
From: Anilkumar Kolli 

To enable per peer stats feature we are reducing the number of peers.
Firmware has introduced tx stats feature. We have memory limitation in
firmware to add these additional bytes.

These are the new variables introduced in the firmware.
===
VariableBytes required/per rate
===
TX success packets  1
TX failed packets   1
Retry packets   1
Success bytes   2
TX failed bytes 2
Retry bytes 2
Tx duration 4
Rate1
Bw and AMPDU flags  1
Total   16 (because of allocation in word pattern)

Firmware sends these tx_stats in pktlog.
If we consider 4 feedbacks at a time, Frimware need about ~1K memory for coding
and 8192 bytes required / per rate [ 4*16*128(peers)].
To accommodate this firmware needs to reduce 10 peers.

Signed-off-by: Anilkumar Kolli 
---
 drivers/net/wireless/ath/ath10k/core.c |  9 +++--
 drivers/net/wireless/ath/ath10k/hw.h   |  5 +
 drivers/net/wireless/ath/ath10k/wmi.c  | 10 --
 3 files changed, 20 insertions(+), 4 deletions(-)

diff --git a/drivers/net/wireless/ath/ath10k/core.c 
b/drivers/net/wireless/ath/ath10k/core.c
index 1f4a278..59a7b00 100644
--- a/drivers/net/wireless/ath/ath10k/core.c
+++ b/drivers/net/wireless/ath/ath10k/core.c
@@ -1479,8 +1479,13 @@ static int ath10k_core_init_firmware_features(struct 
ath10k *ar)
case ATH10K_FW_WMI_OP_VERSION_10_1:
case ATH10K_FW_WMI_OP_VERSION_10_2:
case ATH10K_FW_WMI_OP_VERSION_10_2_4:
-   ar->max_num_peers = TARGET_10X_NUM_PEERS;
-   ar->max_num_stations = TARGET_10X_NUM_STATIONS;
+   if (test_bit(WMI_SERVICE_PEER_STATS, ar->wmi.svc_map)) {
+   ar->max_num_peers = TARGET_10X_TX_STATS_NUM_PEERS;
+   ar->max_num_stations = TARGET_10X_TX_STATS_NUM_STATIONS;
+   } else {
+   ar->max_num_peers = TARGET_10X_NUM_PEERS;
+   ar->max_num_stations = TARGET_10X_NUM_STATIONS;
+   }
ar->max_num_vdevs = TARGET_10X_NUM_VDEVS;
ar->htt.max_num_pending_tx = TARGET_10X_NUM_MSDU_DESC;
ar->fw_stats_req_mask = WMI_STAT_PEER;
diff --git a/drivers/net/wireless/ath/ath10k/hw.h 
b/drivers/net/wireless/ath/ath10k/hw.h
index 4217bdb..c8c86a7 100644
--- a/drivers/net/wireless/ath/ath10k/hw.h
+++ b/drivers/net/wireless/ath/ath10k/hw.h
@@ -367,14 +367,19 @@ enum ath10k_hw_4addr_pad {
 #define TARGET_10X_MAC_AGGR_DELIM  0
 #define TARGET_10X_AST_SKID_LIMIT  128
 #define TARGET_10X_NUM_STATIONS128
+#define TARGET_10X_TX_STATS_NUM_STATIONS   118
 #define TARGET_10X_NUM_PEERS   ((TARGET_10X_NUM_STATIONS) + \
 (TARGET_10X_NUM_VDEVS))
+#define TARGET_10X_TX_STATS_NUM_PEERS  
((TARGET_10X_TX_STATS_NUM_STATIONS) + \
+(TARGET_10X_NUM_VDEVS))
 #define TARGET_10X_NUM_OFFLOAD_PEERS   0
 #define TARGET_10X_NUM_OFFLOAD_REORDER_BUFS0
 #define TARGET_10X_NUM_PEER_KEYS   2
 #define TARGET_10X_NUM_TIDS_MAX256
 #define TARGET_10X_NUM_TIDSmin((TARGET_10X_NUM_TIDS_MAX), \
(TARGET_10X_NUM_PEERS) * 2)
+#define TARGET_10X_TX_STATS_NUM_TIDS   min((TARGET_10X_NUM_TIDS_MAX), \
+   
(TARGET_10X_TX_STATS_NUM_PEERS) * 2)
 #define TARGET_10X_TX_CHAIN_MASK   (BIT(0) | BIT(1) | BIT(2))
 #define TARGET_10X_RX_CHAIN_MASK   (BIT(0) | BIT(1) | BIT(2))
 #define TARGET_10X_RX_TIMEOUT_LO_PRI   100
diff --git a/drivers/net/wireless/ath/ath10k/wmi.c 
b/drivers/net/wireless/ath/ath10k/wmi.c
index b109b80..e77e60c 100644
--- a/drivers/net/wireless/ath/ath10k/wmi.c
+++ b/drivers/net/wireless/ath/ath10k/wmi.c
@@ -5517,9 +5517,15 @@ static struct sk_buff 
*ath10k_wmi_10_2_op_gen_init(struct ath10k *ar)
u32 len, val, features;
 
config.num_vdevs = __cpu_to_le32(TARGET_10X_NUM_VDEVS);
-   config.num_peers = __cpu_to_le32(TARGET_10X_NUM_PEERS);
config.num_peer_keys = __cpu_to_le32(TARGET_10X_NUM_PEER_KEYS);
-   config.num_tids = __cpu_to_le32(TARGET_10X_NUM_TIDS);
+   if (test_bit(WMI_SERVICE_PEER_STATS, ar->wmi.svc_map)) {
+   config.num_peers = __cpu_to_le32(TARGET_10X_TX_STATS_NUM_PEERS);
+   config.num_tids = __cpu_to_le32(TARGET_10X_TX_STATS_NUM_TIDS);
+   } else {
+   config.num_peers = __cpu_to_le32(TARGET_10X_NUM_PEERS);
+   config.num_tids = __cpu_to_le32(TARGET_10X_NUM_TIDS);
+   }
+
config.ast_skid_limit = __cpu_to_le32(TARGET_10X_AST_SKID_LIMIT);

[PATCH] ath10k: Disable PCI PS for QCA988X and QCA99X0

2015-09-28 Thread akolli
From: Anilkumar Kolli 

This patch disables PCI PS for QCA988X and QCA99X0, Since PCI PS is
validated for QCA6174, let it be enabled only for QCA6174. It would be
better to execute PCI PS related functions only for the supported devices.

PCI time out issue is observed with QCA99X0 on x86 platform, We will
disable PCI PS for QCA988X and QCA99X0 until PCI PS is properly implemented.

Taking and releasing ps_lock is causing higher CPU consumption. Michal Kazior
suggested ps_lock overhead to be reworked so that ath10k_pci_wake/sleep
functions are called less often, i.e. move the powersave logic up (only during
irq handling, tx path, submitting fw commands).

Signed-off-by: Anilkumar Kolli 
---

 drivers/net/wireless/ath/ath10k/pci.c | 83 ++-
 drivers/net/wireless/ath/ath10k/pci.h |  6 +++
 2 files changed, 88 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/ath/ath10k/pci.c 
b/drivers/net/wireless/ath/ath10k/pci.c
index 1046ab6..36b6f34 100644
--- a/drivers/net/wireless/ath/ath10k/pci.c
+++ b/drivers/net/wireless/ath/ath10k/pci.c
@@ -465,12 +465,53 @@ static int ath10k_pci_wake_wait(struct ath10k *ar)
return -ETIMEDOUT;
 }
 
+static int ath10k_pci_force_wake(struct ath10k *ar)
+{
+   struct ath10k_pci *ar_pci = ath10k_pci_priv(ar);
+   unsigned long flags;
+   int ret = 0;
+
+   spin_lock_irqsave(_pci->ps_lock, flags);
+
+   if (!ar_pci->ps_awake) {
+   iowrite32(PCIE_SOC_WAKE_V_MASK,
+   ar_pci->mem + PCIE_LOCAL_BASE_ADDRESS +
+   PCIE_SOC_WAKE_ADDRESS);
+
+   ret = ath10k_pci_wake_wait(ar);
+   if (ret == 0)
+   ar_pci->ps_awake = true;
+   }
+
+   spin_unlock_irqrestore(_pci->ps_lock, flags);
+
+   return ret;
+}
+
+static void ath10k_pci_force_sleep(struct ath10k *ar)
+{
+   struct ath10k_pci *ar_pci = ath10k_pci_priv(ar);
+   unsigned long flags;
+
+   spin_lock_irqsave(_pci->ps_lock, flags);
+
+   iowrite32(PCIE_SOC_WAKE_RESET,
+   ar_pci->mem + PCIE_LOCAL_BASE_ADDRESS +
+   PCIE_SOC_WAKE_ADDRESS);
+   ar_pci->ps_awake = false;
+
+   spin_unlock_irqrestore(_pci->ps_lock, flags);
+}
+
 static int ath10k_pci_wake(struct ath10k *ar)
 {
struct ath10k_pci *ar_pci = ath10k_pci_priv(ar);
unsigned long flags;
int ret = 0;
 
+   if (ar_pci->pci_ps == 0)
+   return ret;
+
spin_lock_irqsave(_pci->ps_lock, flags);
 
ath10k_dbg(ar, ATH10K_DBG_PCI_PS, "pci ps wake refcount %lu awake %d\n",
@@ -502,6 +543,9 @@ static void ath10k_pci_sleep(struct ath10k *ar)
struct ath10k_pci *ar_pci = ath10k_pci_priv(ar);
unsigned long flags;
 
+   if (ar_pci->pci_ps == 0)
+   return;
+
spin_lock_irqsave(_pci->ps_lock, flags);
 
ath10k_dbg(ar, ATH10K_DBG_PCI_PS, "pci ps sleep refcount %lu awake 
%d\n",
@@ -544,6 +588,11 @@ static void ath10k_pci_sleep_sync(struct ath10k *ar)
struct ath10k_pci *ar_pci = ath10k_pci_priv(ar);
unsigned long flags;
 
+   if (ar_pci->pci_ps == 0) {
+   ath10k_pci_force_sleep(ar);
+   return;
+   }
+
del_timer_sync(_pci->ps_timer);
 
spin_lock_irqsave(_pci->ps_lock, flags);
@@ -2397,6 +2446,15 @@ static int ath10k_pci_hif_resume(struct ath10k *ar)
struct ath10k_pci *ar_pci = ath10k_pci_priv(ar);
struct pci_dev *pdev = ar_pci->pdev;
u32 val;
+   int ret = 0;
+
+   if (ar_pci->pci_ps == 0) {
+   ret = ath10k_pci_force_wake(ar);
+   if (ret) {
+   ath10k_err(ar, "failed to wake up target: %d\n", ret);
+   return ret;
+   }
+   }
 
/* Suspend/Resume resets the PCI configuration space, so we have to
 * re-disable the RETRY_TIMEOUT register (0x41) to keep PCI Tx retries
@@ -2407,7 +2465,7 @@ static int ath10k_pci_hif_resume(struct ath10k *ar)
if ((val & 0xff00) != 0)
pci_write_config_dword(pdev, 0x40, val & 0x00ff);
 
-   return 0;
+   return ret;
 }
 #endif
 
@@ -2501,6 +2559,16 @@ static irqreturn_t ath10k_pci_interrupt_handler(int irq, 
void *arg)
 {
struct ath10k *ar = arg;
struct ath10k_pci *ar_pci = ath10k_pci_priv(ar);
+   int ret;
+
+   if (ar_pci->pci_ps == 0) {
+   ret = ath10k_pci_force_wake(ar);
+   if (ret) {
+   ath10k_warn(ar, "failed to wake device up on irq: \
+   %d\n", ret);
+   return IRQ_NONE;
+   }
+   }
 
if (ar_pci->num_msi_intrs == 0) {
if (!ath10k_pci_irq_pending(ar))
@@ -2908,17 +2976,21 @@ static int ath10k_pci_probe(struct pci_dev *pdev,
struct ath10k_pci *ar_pci;
enum