Re: [PATCH 4/4] ath10k: update bss channel survey information

2016-04-26 Thread Valo, Kalle
Rajkumar Manoharan  writes:

> During hw scan, firmware sends two channel information events (pre-
> complete, complete) to host for each channel change. The snap shot of cycle
> counters (rx_clear and total) between these two events are given for
> survey dump. In order to get latest survey statistics of all channels, a
> scan request has to be issued. In general, an AP DUT is brought up, it
> won't leave BSS channel except few cases like overlapping bss or radar
> detection. So survey statistics of bss channel is always referring to
> older data that are collected before starting AP (either ACS/OBSS scan).
>
> To collect latest survey information from target, firmware provides WMI
> interface to read cycle counters from hardware. For each survey dump
> request, BSS channel cycle counters are read and cleared in hardware.
> This makes sure that behavior is in align with ath9k survey report.
> So survey dump always gives snap shot of cycle counters b/w two survey
> requests.
>
> Signed-off-by: Yanbo Li 
> Signed-off-by: Rajkumar Manoharan 

This patch adds new sparse warnings:

drivers/net/wireless/ath/ath10k/wmi.c:4824:33: warning: incorrect type in 
argument 2 (different base types)
drivers/net/wireless/ath/ath10k/wmi.c:4824:33:expected int [signed] freq
drivers/net/wireless/ath/ath10k/wmi.c:4824:33:got restricted __le32 
[usertype] freq
drivers/net/wireless/ath/ath10k/wmi.c:4833:27: warning: incorrect type in 
assignment (different base types)
drivers/net/wireless/ath/ath10k/wmi.c:4833:27:expected signed char [signed] 
[usertype] [explicitly-signed] noise
drivers/net/wireless/ath/ath10k/wmi.c:4833:27:got restricted __le32 
[usertype] noise_floor

-- 
Kalle Valo--
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 4/4] ath10k: update bss channel survey information

2016-04-21 Thread Rajkumar Manoharan
During hw scan, firmware sends two channel information events (pre-
complete, complete) to host for each channel change. The snap shot of cycle
counters (rx_clear and total) between these two events are given for
survey dump. In order to get latest survey statistics of all channels, a
scan request has to be issued. In general, an AP DUT is brought up, it
won't leave BSS channel except few cases like overlapping bss or radar
detection. So survey statistics of bss channel is always referring to
older data that are collected before starting AP (either ACS/OBSS scan).

To collect latest survey information from target, firmware provides WMI
interface to read cycle counters from hardware. For each survey dump
request, BSS channel cycle counters are read and cleared in hardware.
This makes sure that behavior is in align with ath9k survey report.
So survey dump always gives snap shot of cycle counters b/w two survey
requests.

Signed-off-by: Yanbo Li 
Signed-off-by: Rajkumar Manoharan 
---
 drivers/net/wireless/ath/ath10k/core.c |  5 +
 drivers/net/wireless/ath/ath10k/core.h |  1 +
 drivers/net/wireless/ath/ath10k/mac.c  | 35 ++
 drivers/net/wireless/ath/ath10k/wmi.c  | 29 
 4 files changed, 70 insertions(+)

diff --git a/drivers/net/wireless/ath/ath10k/core.c 
b/drivers/net/wireless/ath/ath10k/core.c
index 1c4106b84a35..5f846bd4054c 100644
--- a/drivers/net/wireless/ath/ath10k/core.c
+++ b/drivers/net/wireless/ath/ath10k/core.c
@@ -1460,6 +1460,7 @@ static void ath10k_core_restart(struct work_struct *work)
complete_all(>install_key_done);
complete_all(>vdev_setup_done);
complete_all(>thermal.wmi_sync);
+   complete_all(>bss_survey_done);
wake_up(>htt.empty_tx_wq);
wake_up(>wmi.tx_credits_wq);
wake_up(>peer_mapping_wq);
@@ -1787,6 +1788,9 @@ int ath10k_core_start(struct ath10k *ar, enum 
ath10k_firmware_mode mode)
if (ath10k_peer_stats_enabled(ar))
val = WMI_10_4_PEER_STATS;
 
+   if (test_bit(WMI_SERVICE_BSS_CHANNEL_INFO_64, ar->wmi.svc_map))
+   val |= WMI_10_4_BSS_CHANNEL_INFO_64;
+
status = ath10k_mac_ext_resource_config(ar, val);
if (status) {
ath10k_err(ar,
@@ -2142,6 +2146,7 @@ struct ath10k *ath10k_core_create(size_t priv_size, 
struct device *dev,
init_completion(>install_key_done);
init_completion(>vdev_setup_done);
init_completion(>thermal.wmi_sync);
+   init_completion(>bss_survey_done);
 
INIT_DELAYED_WORK(>scan.timeout, ath10k_scan_timeout_work);
 
diff --git a/drivers/net/wireless/ath/ath10k/core.h 
b/drivers/net/wireless/ath/ath10k/core.h
index ccc3d639b077..16c979b1bf2d 100644
--- a/drivers/net/wireless/ath/ath10k/core.h
+++ b/drivers/net/wireless/ath/ath10k/core.h
@@ -859,6 +859,7 @@ struct ath10k {
 * avoid reporting garbage data.
 */
bool ch_info_can_report_survey;
+   struct completion bss_survey_done;
 
struct dfs_pattern_detector *dfs_detector;
 
diff --git a/drivers/net/wireless/ath/ath10k/mac.c 
b/drivers/net/wireless/ath/ath10k/mac.c
index bcf025f51310..8e5fb931d816 100644
--- a/drivers/net/wireless/ath/ath10k/mac.c
+++ b/drivers/net/wireless/ath/ath10k/mac.c
@@ -6404,6 +6404,39 @@ static void ath10k_reconfig_complete(struct ieee80211_hw 
*hw,
mutex_unlock(>conf_mutex);
 }
 
+static void
+ath10k_mac_update_bss_chan_survey(struct ath10k *ar,
+ struct ieee80211_channel *channel)
+{
+   int ret;
+   enum wmi_bss_survey_req_type type = WMI_BSS_SURVEY_REQ_TYPE_READ_CLEAR;
+
+   lockdep_assert_held(>conf_mutex);
+
+   if (!test_bit(WMI_SERVICE_BSS_CHANNEL_INFO_64, ar->wmi.svc_map) ||
+   (ar->rx_channel != channel))
+   return;
+
+   if (ar->scan.state != ATH10K_SCAN_IDLE) {
+   ath10k_dbg(ar, ATH10K_DBG_MAC, "ignoring bss chan info request 
while scanning..\n");
+   return;
+   }
+
+   reinit_completion(>bss_survey_done);
+
+   ret = ath10k_wmi_pdev_bss_chan_info_request(ar, type);
+   if (ret) {
+   ath10k_warn(ar, "failed to send pdev bss chan info request\n");
+   return;
+   }
+
+   ret = wait_for_completion_timeout(>bss_survey_done, 3 * HZ);
+   if (!ret) {
+   ath10k_warn(ar, "bss channel survey timed out\n");
+   return;
+   }
+}
+
 static int ath10k_get_survey(struct ieee80211_hw *hw, int idx,
 struct survey_info *survey)
 {
@@ -6428,6 +6461,8 @@ static int ath10k_get_survey(struct ieee80211_hw *hw, int 
idx,
goto exit;
}
 
+   ath10k_mac_update_bss_chan_survey(ar, survey->channel);
+
spin_lock_bh(>data_lock);
memcpy(survey, ar_survey, sizeof(*survey));