]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blob - drivers/net/wireless/ath/ath9k/dfs_pattern_detector.h
Merge tag 'disintegrate-cris-20121009' of git://git.infradead.org/users/dhowells...
[mirror_ubuntu-artful-kernel.git] / drivers / net / wireless / ath / ath9k / dfs_pattern_detector.h
1 /*
2 * Copyright (c) 2012 Neratec Solutions AG
3 *
4 * Permission to use, copy, modify, and/or distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
7 *
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 */
16
17 #ifndef DFS_PATTERN_DETECTOR_H
18 #define DFS_PATTERN_DETECTOR_H
19
20 #include <linux/types.h>
21 #include <linux/list.h>
22 #include <linux/nl80211.h>
23
24 /**
25 * struct pulse_event - describing pulses reported by PHY
26 * @ts: pulse time stamp in us
27 * @freq: channel frequency in MHz
28 * @width: pulse duration in us
29 * @rssi: rssi of radar event
30 */
31 struct pulse_event {
32 u64 ts;
33 u16 freq;
34 u8 width;
35 u8 rssi;
36 };
37
38 /**
39 * struct radar_detector_specs - detector specs for a radar pattern type
40 * @type_id: pattern type, as defined by regulatory
41 * @width_min: minimum radar pulse width in [us]
42 * @width_max: maximum radar pulse width in [us]
43 * @pri_min: minimum pulse repetition interval in [us] (including tolerance)
44 * @pri_max: minimum pri in [us] (including tolerance)
45 * @num_pri: maximum number of different pri for this type
46 * @ppb: pulses per bursts for this type
47 * @ppb_thresh: number of pulses required to trigger detection
48 * @max_pri_tolerance: pulse time stamp tolerance on both sides [us]
49 */
50 struct radar_detector_specs {
51 u8 type_id;
52 u8 width_min;
53 u8 width_max;
54 u16 pri_min;
55 u16 pri_max;
56 u8 num_pri;
57 u8 ppb;
58 u8 ppb_thresh;
59 u8 max_pri_tolerance;
60 };
61
62 /**
63 * struct dfs_pattern_detector - DFS pattern detector
64 * @exit(): destructor
65 * @set_dfs_domain(): set DFS domain, resets detector lines upon domain changes
66 * @add_pulse(): add radar pulse to detector, returns true on detection
67 * @region: active DFS region, NL80211_DFS_UNSET until set
68 * @num_radar_types: number of different radar types
69 * @last_pulse_ts: time stamp of last valid pulse in usecs
70 * @radar_detector_specs: array of radar detection specs
71 * @channel_detectors: list connecting channel_detector elements
72 */
73 struct dfs_pattern_detector {
74 void (*exit)(struct dfs_pattern_detector *dpd);
75 bool (*set_dfs_domain)(struct dfs_pattern_detector *dpd,
76 enum nl80211_dfs_regions region);
77 bool (*add_pulse)(struct dfs_pattern_detector *dpd,
78 struct pulse_event *pe);
79
80 enum nl80211_dfs_regions region;
81 u8 num_radar_types;
82 u64 last_pulse_ts;
83
84 const struct radar_detector_specs *radar_spec;
85 struct list_head channel_detectors;
86 };
87
88 /**
89 * dfs_pattern_detector_init() - constructor for pattern detector class
90 * @param region: DFS domain to be used, can be NL80211_DFS_UNSET at creation
91 * @return instance pointer on success, NULL otherwise
92 */
93 #if defined(CONFIG_ATH9K_DFS_CERTIFIED)
94 extern struct dfs_pattern_detector *
95 dfs_pattern_detector_init(enum nl80211_dfs_regions region);
96 #else
97 static inline struct dfs_pattern_detector *
98 dfs_pattern_detector_init(enum nl80211_dfs_regions region)
99 {
100 return NULL;
101 }
102 #endif /* CONFIG_ATH9K_DFS_CERTIFIED */
103
104 #endif /* DFS_PATTERN_DETECTOR_H */