Merge tag 'trace-v4.10' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt...
[linux-2.6-block.git] / drivers / net / wireless / ath / dfs_pattern_detector.h
CommitLineData
6ee159e2
ZK
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
44acedb0
PO
24/* tolerated deviation of radar time stamp in usecs on both sides
25 * TODO: this might need to be HW-dependent
26 */
27#define PRI_TOLERANCE 16
28
d265214b
JD
29/**
30 * struct ath_dfs_pool_stats - DFS Statistics for global pools
31 */
32struct ath_dfs_pool_stats {
33 u32 pool_reference;
34 u32 pulse_allocated;
35 u32 pulse_alloc_error;
36 u32 pulse_used;
37 u32 pseq_allocated;
38 u32 pseq_alloc_error;
39 u32 pseq_used;
40};
41
6ee159e2
ZK
42/**
43 * struct pulse_event - describing pulses reported by PHY
44 * @ts: pulse time stamp in us
45 * @freq: channel frequency in MHz
46 * @width: pulse duration in us
47 * @rssi: rssi of radar event
beb28edf 48 * @chirp: chirp detected in pulse
6ee159e2
ZK
49 */
50struct pulse_event {
51 u64 ts;
52 u16 freq;
53 u8 width;
54 u8 rssi;
beb28edf 55 bool chirp;
6ee159e2
ZK
56};
57
58/**
59 * struct radar_detector_specs - detector specs for a radar pattern type
60 * @type_id: pattern type, as defined by regulatory
61 * @width_min: minimum radar pulse width in [us]
62 * @width_max: maximum radar pulse width in [us]
63 * @pri_min: minimum pulse repetition interval in [us] (including tolerance)
64 * @pri_max: minimum pri in [us] (including tolerance)
65 * @num_pri: maximum number of different pri for this type
66 * @ppb: pulses per bursts for this type
67 * @ppb_thresh: number of pulses required to trigger detection
68 * @max_pri_tolerance: pulse time stamp tolerance on both sides [us]
beb28edf 69 * @chirp: chirp required for the radar pattern
6ee159e2
ZK
70 */
71struct radar_detector_specs {
72 u8 type_id;
73 u8 width_min;
74 u8 width_max;
75 u16 pri_min;
76 u16 pri_max;
77 u8 num_pri;
78 u8 ppb;
79 u8 ppb_thresh;
80 u8 max_pri_tolerance;
beb28edf 81 bool chirp;
6ee159e2
ZK
82};
83
84/**
85 * struct dfs_pattern_detector - DFS pattern detector
86 * @exit(): destructor
259bcf87 87 * @set_dfs_domain(): set DFS domain, resets detector lines upon domain changes
6ee159e2
ZK
88 * @add_pulse(): add radar pulse to detector, returns true on detection
89 * @region: active DFS region, NL80211_DFS_UNSET until set
90 * @num_radar_types: number of different radar types
91 * @last_pulse_ts: time stamp of last valid pulse in usecs
92 * @radar_detector_specs: array of radar detection specs
93 * @channel_detectors: list connecting channel_detector elements
94 */
95struct dfs_pattern_detector {
96 void (*exit)(struct dfs_pattern_detector *dpd);
259bcf87 97 bool (*set_dfs_domain)(struct dfs_pattern_detector *dpd,
6ee159e2
ZK
98 enum nl80211_dfs_regions region);
99 bool (*add_pulse)(struct dfs_pattern_detector *dpd,
100 struct pulse_event *pe);
101
d265214b 102 struct ath_dfs_pool_stats (*get_stats)(struct dfs_pattern_detector *dpd);
6ee159e2
ZK
103 enum nl80211_dfs_regions region;
104 u8 num_radar_types;
105 u64 last_pulse_ts;
ca21cfde 106 /* needed for ath_dbg() */
95a5992e 107 struct ath_common *common;
6ee159e2
ZK
108
109 const struct radar_detector_specs *radar_spec;
110 struct list_head channel_detectors;
111};
112
113/**
114 * dfs_pattern_detector_init() - constructor for pattern detector class
115 * @param region: DFS domain to be used, can be NL80211_DFS_UNSET at creation
116 * @return instance pointer on success, NULL otherwise
117 */
6ee159e2 118extern struct dfs_pattern_detector *
95a5992e
JD
119dfs_pattern_detector_init(struct ath_common *common,
120 enum nl80211_dfs_regions region);
6ee159e2 121#endif /* DFS_PATTERN_DETECTOR_H */