diff options
author | Zefir Kurtisi <zefir.kurtisi@neratec.com> | 2012-04-03 11:15:51 -0400 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2012-04-11 16:23:54 -0400 |
commit | 56dc389f76e6f8276cdc4f5e59d531b23e0f449b (patch) | |
tree | 0b6696d303408a4f0f4e2232ce955533c63b7ecf /drivers/net/wireless/ath/ath9k/dfs.c | |
parent | 8e92d3f24234b467f95276db99a55e1244d14afb (diff) |
ath9k: update to DFS pattern detector interface
Follow updates in DFS pattern detector interface:
a) use given pulse event structure
b) adapt to boolean return value of add_pulse()
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/ath9k/dfs.c')
-rw-r--r-- | drivers/net/wireless/ath/ath9k/dfs.c | 80 |
1 files changed, 31 insertions, 49 deletions
diff --git a/drivers/net/wireless/ath/ath9k/dfs.c b/drivers/net/wireless/ath/ath9k/dfs.c index f4f56aff1e9..92891f5fd45 100644 --- a/drivers/net/wireless/ath/ath9k/dfs.c +++ b/drivers/net/wireless/ath/ath9k/dfs.c | |||
@@ -21,17 +21,6 @@ | |||
21 | #include "dfs.h" | 21 | #include "dfs.h" |
22 | #include "dfs_debug.h" | 22 | #include "dfs_debug.h" |
23 | 23 | ||
24 | /* | ||
25 | * TODO: move into or synchronize this with generic header | ||
26 | * as soon as IF is defined | ||
27 | */ | ||
28 | struct dfs_radar_pulse { | ||
29 | u16 freq; | ||
30 | u64 ts; | ||
31 | u32 width; | ||
32 | u8 rssi; | ||
33 | }; | ||
34 | |||
35 | /* internal struct to pass radar data */ | 24 | /* internal struct to pass radar data */ |
36 | struct ath_radar_data { | 25 | struct ath_radar_data { |
37 | u8 pulse_bw_info; | 26 | u8 pulse_bw_info; |
@@ -60,44 +49,44 @@ static u32 dur_to_usecs(struct ath_hw *ah, u32 dur) | |||
60 | #define EXT_CH_RADAR_FOUND 0x02 | 49 | #define EXT_CH_RADAR_FOUND 0x02 |
61 | static bool | 50 | static bool |
62 | ath9k_postprocess_radar_event(struct ath_softc *sc, | 51 | ath9k_postprocess_radar_event(struct ath_softc *sc, |
63 | struct ath_radar_data *are, | 52 | struct ath_radar_data *ard, |
64 | struct dfs_radar_pulse *drp) | 53 | struct pulse_event *pe) |
65 | { | 54 | { |
66 | u8 rssi; | 55 | u8 rssi; |
67 | u16 dur; | 56 | u16 dur; |
68 | 57 | ||
69 | ath_dbg(ath9k_hw_common(sc->sc_ah), DFS, | 58 | ath_dbg(ath9k_hw_common(sc->sc_ah), DFS, |
70 | "pulse_bw_info=0x%x, pri,ext len/rssi=(%u/%u, %u/%u)\n", | 59 | "pulse_bw_info=0x%x, pri,ext len/rssi=(%u/%u, %u/%u)\n", |
71 | are->pulse_bw_info, | 60 | ard->pulse_bw_info, |
72 | are->pulse_length_pri, are->rssi, | 61 | ard->pulse_length_pri, ard->rssi, |
73 | are->pulse_length_ext, are->ext_rssi); | 62 | ard->pulse_length_ext, ard->ext_rssi); |
74 | 63 | ||
75 | /* | 64 | /* |
76 | * Only the last 2 bits of the BW info are relevant, they indicate | 65 | * Only the last 2 bits of the BW info are relevant, they indicate |
77 | * which channel the radar was detected in. | 66 | * which channel the radar was detected in. |
78 | */ | 67 | */ |
79 | are->pulse_bw_info &= 0x03; | 68 | ard->pulse_bw_info &= 0x03; |
80 | 69 | ||
81 | switch (are->pulse_bw_info) { | 70 | switch (ard->pulse_bw_info) { |
82 | case PRI_CH_RADAR_FOUND: | 71 | case PRI_CH_RADAR_FOUND: |
83 | /* radar in ctrl channel */ | 72 | /* radar in ctrl channel */ |
84 | dur = are->pulse_length_pri; | 73 | dur = ard->pulse_length_pri; |
85 | DFS_STAT_INC(sc, pri_phy_errors); | 74 | DFS_STAT_INC(sc, pri_phy_errors); |
86 | /* | 75 | /* |
87 | * cannot use ctrl channel RSSI | 76 | * cannot use ctrl channel RSSI |
88 | * if extension channel is stronger | 77 | * if extension channel is stronger |
89 | */ | 78 | */ |
90 | rssi = (are->ext_rssi >= (are->rssi + 3)) ? 0 : are->rssi; | 79 | rssi = (ard->ext_rssi >= (ard->rssi + 3)) ? 0 : ard->rssi; |
91 | break; | 80 | break; |
92 | case EXT_CH_RADAR_FOUND: | 81 | case EXT_CH_RADAR_FOUND: |
93 | /* radar in extension channel */ | 82 | /* radar in extension channel */ |
94 | dur = are->pulse_length_ext; | 83 | dur = ard->pulse_length_ext; |
95 | DFS_STAT_INC(sc, ext_phy_errors); | 84 | DFS_STAT_INC(sc, ext_phy_errors); |
96 | /* | 85 | /* |
97 | * cannot use extension channel RSSI | 86 | * cannot use extension channel RSSI |
98 | * if control channel is stronger | 87 | * if control channel is stronger |
99 | */ | 88 | */ |
100 | rssi = (are->rssi >= (are->ext_rssi + 12)) ? 0 : are->ext_rssi; | 89 | rssi = (ard->rssi >= (ard->ext_rssi + 12)) ? 0 : ard->ext_rssi; |
101 | break; | 90 | break; |
102 | case (PRI_CH_RADAR_FOUND | EXT_CH_RADAR_FOUND): | 91 | case (PRI_CH_RADAR_FOUND | EXT_CH_RADAR_FOUND): |
103 | /* | 92 | /* |
@@ -107,14 +96,14 @@ ath9k_postprocess_radar_event(struct ath_softc *sc, | |||
107 | * Radiated testing, when pulse is on DC, different pri and | 96 | * Radiated testing, when pulse is on DC, different pri and |
108 | * ext durations are reported, so take the larger of the two | 97 | * ext durations are reported, so take the larger of the two |
109 | */ | 98 | */ |
110 | if (are->pulse_length_ext >= are->pulse_length_pri) | 99 | if (ard->pulse_length_ext >= ard->pulse_length_pri) |
111 | dur = are->pulse_length_ext; | 100 | dur = ard->pulse_length_ext; |
112 | else | 101 | else |
113 | dur = are->pulse_length_pri; | 102 | dur = ard->pulse_length_pri; |
114 | DFS_STAT_INC(sc, dc_phy_errors); | 103 | DFS_STAT_INC(sc, dc_phy_errors); |
115 | 104 | ||
116 | /* when both are present use stronger one */ | 105 | /* when both are present use stronger one */ |
117 | rssi = (are->rssi < are->ext_rssi) ? are->ext_rssi : are->rssi; | 106 | rssi = (ard->rssi < ard->ext_rssi) ? ard->ext_rssi : ard->rssi; |
118 | break; | 107 | break; |
119 | default: | 108 | default: |
120 | /* | 109 | /* |
@@ -137,8 +126,8 @@ ath9k_postprocess_radar_event(struct ath_softc *sc, | |||
137 | */ | 126 | */ |
138 | 127 | ||
139 | /* convert duration to usecs */ | 128 | /* convert duration to usecs */ |
140 | drp->width = dur_to_usecs(sc->sc_ah, dur); | 129 | pe->width = dur_to_usecs(sc->sc_ah, dur); |
141 | drp->rssi = rssi; | 130 | pe->rssi = rssi; |
142 | 131 | ||
143 | DFS_STAT_INC(sc, pulses_detected); | 132 | DFS_STAT_INC(sc, pulses_detected); |
144 | return true; | 133 | return true; |
@@ -155,12 +144,12 @@ void ath9k_dfs_process_phyerr(struct ath_softc *sc, void *data, | |||
155 | struct ath_radar_data ard; | 144 | struct ath_radar_data ard; |
156 | u16 datalen; | 145 | u16 datalen; |
157 | char *vdata_end; | 146 | char *vdata_end; |
158 | struct dfs_radar_pulse drp; | 147 | struct pulse_event pe; |
159 | struct ath_hw *ah = sc->sc_ah; | 148 | struct ath_hw *ah = sc->sc_ah; |
160 | struct ath_common *common = ath9k_hw_common(ah); | 149 | struct ath_common *common = ath9k_hw_common(ah); |
161 | 150 | ||
162 | if ((!(rs->rs_phyerr != ATH9K_PHYERR_RADAR)) && | 151 | if ((rs->rs_phyerr != ATH9K_PHYERR_RADAR) && |
163 | (!(rs->rs_phyerr != ATH9K_PHYERR_FALSE_RADAR_EXT))) { | 152 | (rs->rs_phyerr != ATH9K_PHYERR_FALSE_RADAR_EXT)) { |
164 | ath_dbg(common, DFS, | 153 | ath_dbg(common, DFS, |
165 | "Error: rs_phyer=0x%x not a radar error\n", | 154 | "Error: rs_phyer=0x%x not a radar error\n", |
166 | rs->rs_phyerr); | 155 | rs->rs_phyerr); |
@@ -189,27 +178,20 @@ void ath9k_dfs_process_phyerr(struct ath_softc *sc, void *data, | |||
189 | ard.pulse_bw_info = vdata_end[-1]; | 178 | ard.pulse_bw_info = vdata_end[-1]; |
190 | ard.pulse_length_ext = vdata_end[-2]; | 179 | ard.pulse_length_ext = vdata_end[-2]; |
191 | ard.pulse_length_pri = vdata_end[-3]; | 180 | ard.pulse_length_pri = vdata_end[-3]; |
192 | 181 | pe.freq = ah->curchan->channel; | |
193 | ath_dbg(common, DFS, | 182 | pe.ts = mactime; |
194 | "bw_info=%d, length_pri=%d, length_ext=%d, " | 183 | if (ath9k_postprocess_radar_event(sc, &ard, &pe)) { |
195 | "rssi_pri=%d, rssi_ext=%d\n", | 184 | struct dfs_pattern_detector *pd = sc->dfs_detector; |
196 | ard.pulse_bw_info, ard.pulse_length_pri, ard.pulse_length_ext, | ||
197 | ard.rssi, ard.ext_rssi); | ||
198 | |||
199 | drp.freq = ah->curchan->channel; | ||
200 | drp.ts = mactime; | ||
201 | if (ath9k_postprocess_radar_event(sc, &ard, &drp)) { | ||
202 | static u64 last_ts; | 185 | static u64 last_ts; |
203 | ath_dbg(common, DFS, | 186 | ath_dbg(common, DFS, |
204 | "ath9k_dfs_process_phyerr: channel=%d, ts=%llu, " | 187 | "ath9k_dfs_process_phyerr: channel=%d, ts=%llu, " |
205 | "width=%d, rssi=%d, delta_ts=%llu\n", | 188 | "width=%d, rssi=%d, delta_ts=%llu\n", |
206 | drp.freq, drp.ts, drp.width, drp.rssi, drp.ts-last_ts); | 189 | pe.freq, pe.ts, pe.width, pe.rssi, pe.ts-last_ts); |
207 | last_ts = drp.ts; | 190 | last_ts = pe.ts; |
208 | /* | 191 | if (pd != NULL && pd->add_pulse(pd, &pe)) { |
209 | * TODO: forward pulse to pattern detector | 192 | /* |
210 | * | 193 | * TODO: forward radar event to DFS management layer |
211 | * ieee80211_add_radar_pulse(drp.freq, drp.ts, | 194 | */ |
212 | * drp.width, drp.rssi); | 195 | } |
213 | */ | ||
214 | } | 196 | } |
215 | } | 197 | } |