All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] ath10k: handle cycle count wrap around
@ 2015-05-15 22:29 Srinivasa Duvvuri
  2015-05-18 12:05 ` Michal Kazior
  2015-05-20 12:42 ` [PATCH v2] ath10k: handle cycle count wrap around Kalle Valo
  0 siblings, 2 replies; 25+ messages in thread
From: Srinivasa Duvvuri @ 2015-05-15 22:29 UTC (permalink / raw)
  To: ath10k

This patch addresses
 couple of issues related to survey data that results   in a random/large
 values in the out put of iw dev wlan0 surevey dump.

  These are the 2 changes that address the issue.

  1) Handle Cycle count wrap around.
     When the cycle counts part of wmi_ch_info_ev_arg reach max value of
     0xffffffff. The HW/FW right shifts all the counteirs by 1 . The cycle
     count will be reset to 0x7fffffff and starts counting from 0x7fffffff and
     the other counters will have their value right shifted by 1 (divided by 2).
     There is no way to handle this odd wrap around. Detect and ignore the wrap
     around case.

  2) Handle Back to back channel info events from FW with
     WMI_CHAN_INFO_FLAG_COMPLETE.
     Between 2 scans FW sends back to back events with
     WMI_CHAN_INFO_FLAG_COMPLETE flag set. One at the end of first scan
     and the second at the beginning of scan. Depending on the time
     between 2 scans , the cycle counts could have wrapped around several
     timesi. Fix is detect and to ignore such events.

Signed-off-by: Srinivasa Duvvuri <sduvvuri@chromium.org>

---
 drivers/net/wireless/ath/ath10k/core.h |  1 +
 drivers/net/wireless/ath/ath10k/wmi.c  | 40 +++++++++++++++++++++++++++-------
 2 files changed, 33 insertions(+), 8 deletions(-)

diff --git a/drivers/net/wireless/ath/ath10k/core.h
b/drivers/net/wireless/ath/ath10k/core.h
index 827b3d7..fea6665 100644
--- a/drivers/net/wireless/ath/ath10k/core.h
+++ b/drivers/net/wireless/ath/ath10k/core.h
@@ -688,6 +688,7 @@ struct ath10k {
        u32 survey_last_rx_clear_count;
        u32 survey_last_cycle_count;
        struct survey_info survey[ATH10K_NUM_CHANS];
+       bool ch_info_can_process;

        struct dfs_pattern_detector *dfs_detector;

diff --git a/drivers/net/wireless/ath/ath10k/wmi.c
b/drivers/net/wireless/ath/ath10k/wmi.c
index 0fabe68..e9ae071 100644
--- a/drivers/net/wireless/ath/ath10k/wmi.c
+++ b/drivers/net/wireless/ath/ath10k/wmi.c
@@ -1640,16 +1640,40 @@ void ath10k_wmi_event_chan_info(struct ath10k
*ar, struct sk_buff *skb)
                 * visited channel. The reported cycle count is global
                 * and per-channel cycle count must be calculated */

-               cycle_count -= ar->survey_last_cycle_count;
-               rx_clear_count -= ar->survey_last_rx_clear_count;
-
                survey = &ar->survey[idx];
-               survey->time = WMI_CHAN_INFO_MSEC(cycle_count);
-               survey->time_busy = WMI_CHAN_INFO_MSEC(rx_clear_count);
+
+               if (cycle_count < ar->survey_last_cycle_count) {
+                       /*
+                        * Ignore the wrapped around cycle data. When
the total cycle
+                        * count  wraps around, FW/HW will right shift
all the counts
+                        * (including total cycle counts) by 1.The
cycle counts wrap
+                        * around every 24 seconds. To handle this wrap around
+                        * behavior,  we need the value of each
counter at the time
+                        * of wrap around which FW does not provide.
+                        * For now ignore the data.
+                        */
+                       survey->filled &= ~(SURVEY_INFO_CHANNEL_TIME |
+                                           SURVEY_INFO_CHANNEL_TIME_BUSY);
+               } else if (ar->ch_info_can_process) {
+                       /*
+                        * FW sends back to back events with
WMI_CHAN_INFO_FLAG_COMPLETE set.
+                        * One event at the end of the scan and other
ath the beginning of next
+                        * scan. Ignore such events.
+                        */
+                       cycle_count -= ar->survey_last_cycle_count;
+                       rx_clear_count -= ar->survey_last_rx_clear_count;
+
+                       survey->channel_time = WMI_CHAN_INFO_MSEC(cycle_count);
+                       /* the rx_clear_count count indicates the busy time */
+                       survey->channel_time_busy =
WMI_CHAN_INFO_MSEC(rx_clear_count);
+                       survey->filled = SURVEY_INFO_CHANNEL_TIME |
+                               SURVEY_INFO_CHANNEL_TIME_BUSY;
+               }
                survey->noise = noise_floor;
-               survey->filled = SURVEY_INFO_TIME |
-                                SURVEY_INFO_TIME_BUSY |
-                                SURVEY_INFO_NOISE_DBM;
+               survey->filled |= SURVEY_INFO_NOISE_DBM;
+               ar->ch_info_can_process = false;
+       } else {
+               ar->ch_info_can_process = true;
        }

        ar->survey_last_rx_clear_count = rx_clear_count;
-- 
2.2.0.rc0.207.ga3a616c

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

^ permalink raw reply related	[flat|nested] 25+ messages in thread

end of thread, other threads:[~2015-05-29 14:42 UTC | newest]

Thread overview: 25+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-05-15 22:29 [PATCH v2] ath10k: handle cycle count wrap around Srinivasa Duvvuri
2015-05-18 12:05 ` Michal Kazior
2015-05-22  8:18   ` [PATCH v3 1/2] ath10k: handle cycle counter wraparound Michal Kazior
2015-05-22  8:18     ` Michal Kazior
2015-05-22  8:18     ` [PATCH v3 2/2] ath10k: fix inconsistent survey reports Michal Kazior
2015-05-22  8:18       ` Michal Kazior
2015-05-22 11:36     ` [PATCH v3 1/2] ath10k: handle cycle counter wraparound Kalle Valo
2015-05-22 11:36       ` Kalle Valo
2015-05-22 11:56       ` Michal Kazior
2015-05-22 11:56         ` Michal Kazior
2015-05-22 12:00         ` Michal Kazior
2015-05-22 12:00           ` Michal Kazior
2015-05-22 12:12           ` Kalle Valo
2015-05-22 12:12             ` Kalle Valo
     [not found]     ` <CACZoB6-+AUWN6gBqnwgJY101jfjBkDukLYNNffbe2bWNidjJ0Q@mail.gmail.com>
2015-05-25  8:23       ` Michal Kazior
2015-05-25  8:23         ` Michal Kazior
2015-05-25 12:06     ` [PATCH v4 1/3] ath10k: move cycle_count macro Michal Kazior
2015-05-25 12:06       ` Michal Kazior
2015-05-25 12:06       ` [PATCH v4 2/3] ath10k: handle cycle counter wraparound Michal Kazior
2015-05-25 12:06         ` Michal Kazior
2015-05-25 12:06       ` [PATCH v4 3/3] ath10k: fix inconsistent survey reports Michal Kazior
2015-05-25 12:06         ` Michal Kazior
2015-05-29 14:41       ` [PATCH v4 1/3] ath10k: move cycle_count macro Kalle Valo
2015-05-29 14:41         ` Kalle Valo
2015-05-20 12:42 ` [PATCH v2] ath10k: handle cycle count wrap around Kalle Valo

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.