aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/ath
diff options
context:
space:
mode:
authorZefir Kurtisi <zefir.kurtisi@neratec.com>2013-04-15 05:29:06 -0400
committerJohn W. Linville <linville@tuxdriver.com>2013-04-22 15:17:40 -0400
commitca21cfde84e2cb0d64222cbb2ee2cf3163c5f068 (patch)
tree6bcfb450617e293d5777666b5c6c3674dd87d120 /drivers/net/wireless/ath
parent7e9dafd873034dd64ababcb858be424c4780ae13 (diff)
ath9k: change DFS logging to use ath_dbg()
The DFS pattern detector was initially planned to reside on a higher layer and used generic pr_*() logging functions. Being part of ath9k, use ath_dbg() instead and make DFS log ouput selectable via ATH_DBG_DFS (0x20000) at runtime. This patch does not contain functional modifications. Signed-off-by: Zefir Kurtisi <zefir.kurtisi@neratec.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/ath')
-rw-r--r--drivers/net/wireless/ath/ath9k/dfs.c6
-rw-r--r--drivers/net/wireless/ath/ath9k/dfs_pattern_detector.c43
-rw-r--r--drivers/net/wireless/ath/ath9k/dfs_pattern_detector.h6
-rw-r--r--drivers/net/wireless/ath/ath9k/dfs_pri_detector.c46
-rw-r--r--drivers/net/wireless/ath/ath9k/dfs_pri_detector.h27
-rw-r--r--drivers/net/wireless/ath/ath9k/init.c2
6 files changed, 63 insertions, 67 deletions
diff --git a/drivers/net/wireless/ath/ath9k/dfs.c b/drivers/net/wireless/ath/ath9k/dfs.c
index 508f8b33f0ef..7187d3671512 100644
--- a/drivers/net/wireless/ath/ath9k/dfs.c
+++ b/drivers/net/wireless/ath/ath9k/dfs.c
@@ -55,12 +55,6 @@ ath9k_postprocess_radar_event(struct ath_softc *sc,
55 u8 rssi; 55 u8 rssi;
56 u16 dur; 56 u16 dur;
57 57
58 ath_dbg(ath9k_hw_common(sc->sc_ah), DFS,
59 "pulse_bw_info=0x%x, pri,ext len/rssi=(%u/%u, %u/%u)\n",
60 ard->pulse_bw_info,
61 ard->pulse_length_pri, ard->rssi,
62 ard->pulse_length_ext, ard->ext_rssi);
63
64 /* 58 /*
65 * Only the last 2 bits of the BW info are relevant, they indicate 59 * Only the last 2 bits of the BW info are relevant, they indicate
66 * which channel the radar was detected in. 60 * which channel the radar was detected in.
diff --git a/drivers/net/wireless/ath/ath9k/dfs_pattern_detector.c b/drivers/net/wireless/ath/ath9k/dfs_pattern_detector.c
index 467b60014b7b..18413123efd7 100644
--- a/drivers/net/wireless/ath/ath9k/dfs_pattern_detector.c
+++ b/drivers/net/wireless/ath/ath9k/dfs_pattern_detector.c
@@ -19,6 +19,7 @@
19 19
20#include "dfs_pattern_detector.h" 20#include "dfs_pattern_detector.h"
21#include "dfs_pri_detector.h" 21#include "dfs_pri_detector.h"
22#include "ath9k.h"
22 23
23/* 24/*
24 * tolerated deviation of radar time stamp in usecs on both sides 25 * tolerated deviation of radar time stamp in usecs on both sides
@@ -142,6 +143,7 @@ channel_detector_create(struct dfs_pattern_detector *dpd, u16 freq)
142{ 143{
143 u32 sz, i; 144 u32 sz, i;
144 struct channel_detector *cd; 145 struct channel_detector *cd;
146 struct ath_common *common = ath9k_hw_common(dpd->ah);
145 147
146 cd = kmalloc(sizeof(*cd), GFP_KERNEL); 148 cd = kmalloc(sizeof(*cd), GFP_KERNEL);
147 if (cd == NULL) 149 if (cd == NULL)
@@ -165,7 +167,8 @@ channel_detector_create(struct dfs_pattern_detector *dpd, u16 freq)
165 return cd; 167 return cd;
166 168
167fail: 169fail:
168 pr_err("failed to allocate channel_detector for freq=%d\n", freq); 170 ath_dbg(common, DFS,
171 "failed to allocate channel_detector for freq=%d\n", freq);
169 channel_detector_exit(dpd, cd); 172 channel_detector_exit(dpd, cd);
170 return NULL; 173 return NULL;
171} 174}
@@ -216,34 +219,34 @@ static bool
216dpd_add_pulse(struct dfs_pattern_detector *dpd, struct pulse_event *event) 219dpd_add_pulse(struct dfs_pattern_detector *dpd, struct pulse_event *event)
217{ 220{
218 u32 i; 221 u32 i;
219 bool ts_wraparound;
220 struct channel_detector *cd; 222 struct channel_detector *cd;
221 223
222 if (dpd->region == NL80211_DFS_UNSET) { 224 /*
223 /* 225 * pulses received for a non-supported or un-initialized
224 * pulses received for a non-supported or un-initialized 226 * domain are treated as detected radars for fail-safety
225 * domain are treated as detected radars 227 */
226 */ 228 if (dpd->region == NL80211_DFS_UNSET)
227 return true; 229 return true;
228 }
229 230
230 cd = channel_detector_get(dpd, event->freq); 231 cd = channel_detector_get(dpd, event->freq);
231 if (cd == NULL) 232 if (cd == NULL)
232 return false; 233 return false;
233 234
234 ts_wraparound = (event->ts < dpd->last_pulse_ts);
235 dpd->last_pulse_ts = event->ts; 235 dpd->last_pulse_ts = event->ts;
236 if (ts_wraparound) { 236 /* reset detector on time stamp wraparound, caused by TSF reset */
237 /* 237 if (event->ts < dpd->last_pulse_ts)
238 * reset detector on time stamp wraparound
239 * with monotonic time stamps, this should never happen
240 */
241 pr_warn("DFS: time stamp wraparound detected, resetting\n");
242 dpd_reset(dpd); 238 dpd_reset(dpd);
243 } 239
244 /* do type individual pattern matching */ 240 /* do type individual pattern matching */
245 for (i = 0; i < dpd->num_radar_types; i++) { 241 for (i = 0; i < dpd->num_radar_types; i++) {
246 if (cd->detectors[i]->add_pulse(cd->detectors[i], event) != 0) { 242 struct pri_detector *pd = cd->detectors[i];
243 struct pri_sequence *ps = pd->add_pulse(pd, event);
244 if (ps != NULL) {
245 ath_dbg(ath9k_hw_common(dpd->ah), DFS,
246 "DFS: radar found on freq=%d: id=%d, pri=%d, "
247 "count=%d, count_false=%d\n",
248 event->freq, pd->rs->type_id,
249 ps->pri, ps->count, ps->count_falses);
247 channel_detector_reset(dpd, cd); 250 channel_detector_reset(dpd, cd);
248 return true; 251 return true;
249 } 252 }
@@ -285,9 +288,10 @@ static struct dfs_pattern_detector default_dpd = {
285}; 288};
286 289
287struct dfs_pattern_detector * 290struct dfs_pattern_detector *
288dfs_pattern_detector_init(enum nl80211_dfs_regions region) 291dfs_pattern_detector_init(struct ath_hw *ah, enum nl80211_dfs_regions region)
289{ 292{
290 struct dfs_pattern_detector *dpd; 293 struct dfs_pattern_detector *dpd;
294 struct ath_common *common = ath9k_hw_common(ah);
291 295
292 dpd = kmalloc(sizeof(*dpd), GFP_KERNEL); 296 dpd = kmalloc(sizeof(*dpd), GFP_KERNEL);
293 if (dpd == NULL) 297 if (dpd == NULL)
@@ -296,10 +300,11 @@ dfs_pattern_detector_init(enum nl80211_dfs_regions region)
296 *dpd = default_dpd; 300 *dpd = default_dpd;
297 INIT_LIST_HEAD(&dpd->channel_detectors); 301 INIT_LIST_HEAD(&dpd->channel_detectors);
298 302
303 dpd->ah = ah;
299 if (dpd->set_dfs_domain(dpd, region)) 304 if (dpd->set_dfs_domain(dpd, region))
300 return dpd; 305 return dpd;
301 306
302 pr_err("Could not set DFS domain to %d. ", region); 307 ath_dbg(common, DFS,"Could not set DFS domain to %d", region);
303 kfree(dpd); 308 kfree(dpd);
304 return NULL; 309 return NULL;
305} 310}
diff --git a/drivers/net/wireless/ath/ath9k/dfs_pattern_detector.h b/drivers/net/wireless/ath/ath9k/dfs_pattern_detector.h
index cda52f39f28a..90a5abcc4265 100644
--- a/drivers/net/wireless/ath/ath9k/dfs_pattern_detector.h
+++ b/drivers/net/wireless/ath/ath9k/dfs_pattern_detector.h
@@ -80,6 +80,8 @@ struct dfs_pattern_detector {
80 enum nl80211_dfs_regions region; 80 enum nl80211_dfs_regions region;
81 u8 num_radar_types; 81 u8 num_radar_types;
82 u64 last_pulse_ts; 82 u64 last_pulse_ts;
83 /* needed for ath_dbg() */
84 struct ath_hw *ah;
83 85
84 const struct radar_detector_specs *radar_spec; 86 const struct radar_detector_specs *radar_spec;
85 struct list_head channel_detectors; 87 struct list_head channel_detectors;
@@ -92,10 +94,10 @@ struct dfs_pattern_detector {
92 */ 94 */
93#if defined(CONFIG_ATH9K_DFS_CERTIFIED) 95#if defined(CONFIG_ATH9K_DFS_CERTIFIED)
94extern struct dfs_pattern_detector * 96extern struct dfs_pattern_detector *
95dfs_pattern_detector_init(enum nl80211_dfs_regions region); 97dfs_pattern_detector_init(struct ath_hw *ah, enum nl80211_dfs_regions region);
96#else 98#else
97static inline struct dfs_pattern_detector * 99static inline struct dfs_pattern_detector *
98dfs_pattern_detector_init(enum nl80211_dfs_regions region) 100dfs_pattern_detector_init(struct ath_hw *ah, enum nl80211_dfs_regions region)
99{ 101{
100 return NULL; 102 return NULL;
101} 103}
diff --git a/drivers/net/wireless/ath/ath9k/dfs_pri_detector.c b/drivers/net/wireless/ath/ath9k/dfs_pri_detector.c
index 91b8dceeadb1..b3e7cf2da222 100644
--- a/drivers/net/wireless/ath/ath9k/dfs_pri_detector.c
+++ b/drivers/net/wireless/ath/ath9k/dfs_pri_detector.c
@@ -23,28 +23,6 @@
23#include "dfs_debug.h" 23#include "dfs_debug.h"
24 24
25/** 25/**
26 * struct pri_sequence - sequence of pulses matching one PRI
27 * @head: list_head
28 * @pri: pulse repetition interval (PRI) in usecs
29 * @dur: duration of sequence in usecs
30 * @count: number of pulses in this sequence
31 * @count_falses: number of not matching pulses in this sequence
32 * @first_ts: time stamp of first pulse in usecs
33 * @last_ts: time stamp of last pulse in usecs
34 * @deadline_ts: deadline when this sequence becomes invalid (first_ts + dur)
35 */
36struct pri_sequence {
37 struct list_head head;
38 u32 pri;
39 u32 dur;
40 u32 count;
41 u32 count_falses;
42 u64 first_ts;
43 u64 last_ts;
44 u64 deadline_ts;
45};
46
47/**
48 * struct pulse_elem - elements in pulse queue 26 * struct pulse_elem - elements in pulse queue
49 * @ts: time stamp in usecs 27 * @ts: time stamp in usecs
50 */ 28 */
@@ -393,8 +371,8 @@ static void pri_detector_exit(struct pri_detector *de)
393 kfree(de); 371 kfree(de);
394} 372}
395 373
396static bool pri_detector_add_pulse(struct pri_detector *de, 374static struct pri_sequence *pri_detector_add_pulse(struct pri_detector *de,
397 struct pulse_event *event) 375 struct pulse_event *event)
398{ 376{
399 u32 max_updated_seq; 377 u32 max_updated_seq;
400 struct pri_sequence *ps; 378 struct pri_sequence *ps;
@@ -403,35 +381,29 @@ static bool pri_detector_add_pulse(struct pri_detector *de,
403 381
404 /* ignore pulses not within width range */ 382 /* ignore pulses not within width range */
405 if ((rs->width_min > event->width) || (rs->width_max < event->width)) 383 if ((rs->width_min > event->width) || (rs->width_max < event->width))
406 return false; 384 return NULL;
407 385
408 if ((ts - de->last_ts) < rs->max_pri_tolerance) 386 if ((ts - de->last_ts) < rs->max_pri_tolerance)
409 /* if delta to last pulse is too short, don't use this pulse */ 387 /* if delta to last pulse is too short, don't use this pulse */
410 return false; 388 return NULL;
411 de->last_ts = ts; 389 de->last_ts = ts;
412 390
413 max_updated_seq = pseq_handler_add_to_existing_seqs(de, ts); 391 max_updated_seq = pseq_handler_add_to_existing_seqs(de, ts);
414 392
415 if (!pseq_handler_create_sequences(de, ts, max_updated_seq)) { 393 if (!pseq_handler_create_sequences(de, ts, max_updated_seq)) {
416 pr_err("failed to create pulse sequences\n");
417 pri_detector_reset(de, ts); 394 pri_detector_reset(de, ts);
418 return false; 395 return false;
419 } 396 }
420 397
421 ps = pseq_handler_check_detection(de); 398 ps = pseq_handler_check_detection(de);
422 399
423 if (ps != NULL) { 400 if (ps == NULL)
424 pr_info("DFS: radar found: pri=%d, count=%d, count_false=%d\n", 401 pulse_queue_enqueue(de, ts);
425 ps->pri, ps->count, ps->count_falses); 402
426 pri_detector_reset(de, ts); 403 return ps;
427 return true;
428 }
429 pulse_queue_enqueue(de, ts);
430 return false;
431} 404}
432 405
433struct pri_detector * 406struct pri_detector *pri_detector_init(const struct radar_detector_specs *rs)
434pri_detector_init(const struct radar_detector_specs *rs)
435{ 407{
436 struct pri_detector *de; 408 struct pri_detector *de;
437 de = kzalloc(sizeof(*de), GFP_KERNEL); 409 de = kzalloc(sizeof(*de), GFP_KERNEL);
diff --git a/drivers/net/wireless/ath/ath9k/dfs_pri_detector.h b/drivers/net/wireless/ath/ath9k/dfs_pri_detector.h
index 81cde9f28e44..723962d1abc6 100644
--- a/drivers/net/wireless/ath/ath9k/dfs_pri_detector.h
+++ b/drivers/net/wireless/ath/ath9k/dfs_pri_detector.h
@@ -20,9 +20,31 @@
20#include <linux/list.h> 20#include <linux/list.h>
21 21
22/** 22/**
23 * struct pri_sequence - sequence of pulses matching one PRI
24 * @head: list_head
25 * @pri: pulse repetition interval (PRI) in usecs
26 * @dur: duration of sequence in usecs
27 * @count: number of pulses in this sequence
28 * @count_falses: number of not matching pulses in this sequence
29 * @first_ts: time stamp of first pulse in usecs
30 * @last_ts: time stamp of last pulse in usecs
31 * @deadline_ts: deadline when this sequence becomes invalid (first_ts + dur)
32 */
33struct pri_sequence {
34 struct list_head head;
35 u32 pri;
36 u32 dur;
37 u32 count;
38 u32 count_falses;
39 u64 first_ts;
40 u64 last_ts;
41 u64 deadline_ts;
42};
43
44/**
23 * struct pri_detector - PRI detector element for a dedicated radar type 45 * struct pri_detector - PRI detector element for a dedicated radar type
24 * @exit(): destructor 46 * @exit(): destructor
25 * @add_pulse(): add pulse event, returns true if pattern was detected 47 * @add_pulse(): add pulse event, returns pri_sequence if pattern was detected
26 * @reset(): clear states and reset to given time stamp 48 * @reset(): clear states and reset to given time stamp
27 * @rs: detector specs for this detector element 49 * @rs: detector specs for this detector element
28 * @last_ts: last pulse time stamp considered for this element in usecs 50 * @last_ts: last pulse time stamp considered for this element in usecs
@@ -34,7 +56,8 @@
34 */ 56 */
35struct pri_detector { 57struct pri_detector {
36 void (*exit) (struct pri_detector *de); 58 void (*exit) (struct pri_detector *de);
37 bool (*add_pulse)(struct pri_detector *de, struct pulse_event *e); 59 struct pri_sequence *
60 (*add_pulse)(struct pri_detector *de, struct pulse_event *e);
38 void (*reset) (struct pri_detector *de, u64 ts); 61 void (*reset) (struct pri_detector *de, u64 ts);
39 62
40/* private: internal use only */ 63/* private: internal use only */
diff --git a/drivers/net/wireless/ath/ath9k/init.c b/drivers/net/wireless/ath/ath9k/init.c
index 3be2eb0da84a..6b275e0864b0 100644
--- a/drivers/net/wireless/ath/ath9k/init.c
+++ b/drivers/net/wireless/ath/ath9k/init.c
@@ -577,7 +577,7 @@ static int ath9k_init_softc(u16 devid, struct ath_softc *sc,
577 atomic_set(&ah->intr_ref_cnt, -1); 577 atomic_set(&ah->intr_ref_cnt, -1);
578 sc->sc_ah = ah; 578 sc->sc_ah = ah;
579 579
580 sc->dfs_detector = dfs_pattern_detector_init(NL80211_DFS_UNSET); 580 sc->dfs_detector = dfs_pattern_detector_init(ah, NL80211_DFS_UNSET);
581 581
582 if (!pdata) { 582 if (!pdata) {
583 ah->ah_flags |= AH_USE_EEPROM; 583 ah->ah_flags |= AH_USE_EEPROM;