Zefir Kurtisi | 6ee159e | 2012-04-03 17:15:49 +0200 | [diff] [blame] | 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 | #include <linux/slab.h> |
| 18 | #include <linux/export.h> |
| 19 | |
| 20 | #include "dfs_pattern_detector.h" |
| 21 | #include "dfs_pri_detector.h" |
Janusz Dziedzic | ad40d3d | 2013-10-14 11:06:06 +0200 | [diff] [blame] | 22 | #include "ath.h" |
Zefir Kurtisi | 6ee159e | 2012-04-03 17:15:49 +0200 | [diff] [blame] | 23 | |
| 24 | /* |
| 25 | * tolerated deviation of radar time stamp in usecs on both sides |
| 26 | * TODO: this might need to be HW-dependent |
| 27 | */ |
| 28 | #define PRI_TOLERANCE 16 |
| 29 | |
| 30 | /** |
| 31 | * struct radar_types - contains array of patterns defined for one DFS domain |
| 32 | * @domain: DFS regulatory domain |
| 33 | * @num_radar_types: number of radar types to follow |
| 34 | * @radar_types: radar types array |
| 35 | */ |
| 36 | struct radar_types { |
| 37 | enum nl80211_dfs_regions region; |
| 38 | u32 num_radar_types; |
| 39 | const struct radar_detector_specs *radar_types; |
| 40 | }; |
| 41 | |
| 42 | /* percentage on ppb threshold to trigger detection */ |
| 43 | #define MIN_PPB_THRESH 50 |
| 44 | #define PPB_THRESH(PPB) ((PPB * MIN_PPB_THRESH + 50) / 100) |
| 45 | #define PRF2PRI(PRF) ((1000000 + PRF / 2) / PRF) |
Zefir Kurtisi | a695228 | 2012-10-31 12:23:01 +0100 | [diff] [blame] | 46 | /* percentage of pulse width tolerance */ |
| 47 | #define WIDTH_TOLERANCE 5 |
| 48 | #define WIDTH_LOWER(X) ((X*(100-WIDTH_TOLERANCE)+50)/100) |
| 49 | #define WIDTH_UPPER(X) ((X*(100+WIDTH_TOLERANCE)+50)/100) |
Zefir Kurtisi | 6ee159e | 2012-04-03 17:15:49 +0200 | [diff] [blame] | 50 | |
Peter Oh | beb28ed | 2015-03-04 15:43:45 +0200 | [diff] [blame] | 51 | #define ETSI_PATTERN(ID, WMIN, WMAX, PMIN, PMAX, PRF, PPB, CHIRP) \ |
Zefir Kurtisi | 6ee159e | 2012-04-03 17:15:49 +0200 | [diff] [blame] | 52 | { \ |
Zefir Kurtisi | a695228 | 2012-10-31 12:23:01 +0100 | [diff] [blame] | 53 | ID, WIDTH_LOWER(WMIN), WIDTH_UPPER(WMAX), \ |
| 54 | (PRF2PRI(PMAX) - PRI_TOLERANCE), \ |
Zefir Kurtisi | 6ee159e | 2012-04-03 17:15:49 +0200 | [diff] [blame] | 55 | (PRF2PRI(PMIN) * PRF + PRI_TOLERANCE), PRF, PPB * PRF, \ |
Peter Oh | beb28ed | 2015-03-04 15:43:45 +0200 | [diff] [blame] | 56 | PPB_THRESH(PPB), PRI_TOLERANCE, CHIRP \ |
Zefir Kurtisi | 6ee159e | 2012-04-03 17:15:49 +0200 | [diff] [blame] | 57 | } |
| 58 | |
| 59 | /* radar types as defined by ETSI EN-301-893 v1.5.1 */ |
| 60 | static const struct radar_detector_specs etsi_radar_ref_types_v15[] = { |
Peter Oh | beb28ed | 2015-03-04 15:43:45 +0200 | [diff] [blame] | 61 | ETSI_PATTERN(0, 0, 1, 700, 700, 1, 18, false), |
| 62 | ETSI_PATTERN(1, 0, 5, 200, 1000, 1, 10, false), |
| 63 | ETSI_PATTERN(2, 0, 15, 200, 1600, 1, 15, false), |
| 64 | ETSI_PATTERN(3, 0, 15, 2300, 4000, 1, 25, false), |
| 65 | ETSI_PATTERN(4, 20, 30, 2000, 4000, 1, 20, false), |
| 66 | ETSI_PATTERN(5, 0, 2, 300, 400, 3, 10, false), |
| 67 | ETSI_PATTERN(6, 0, 2, 400, 1200, 3, 15, false), |
Zefir Kurtisi | 6ee159e | 2012-04-03 17:15:49 +0200 | [diff] [blame] | 68 | }; |
| 69 | |
| 70 | static const struct radar_types etsi_radar_types_v15 = { |
| 71 | .region = NL80211_DFS_ETSI, |
| 72 | .num_radar_types = ARRAY_SIZE(etsi_radar_ref_types_v15), |
| 73 | .radar_types = etsi_radar_ref_types_v15, |
| 74 | }; |
| 75 | |
Peter Oh | beb28ed | 2015-03-04 15:43:45 +0200 | [diff] [blame] | 76 | #define FCC_PATTERN(ID, WMIN, WMAX, PMIN, PMAX, PRF, PPB, CHIRP) \ |
Janusz Dziedzic | f12e3e0 | 2014-05-13 12:32:05 +0200 | [diff] [blame] | 77 | { \ |
| 78 | ID, WIDTH_LOWER(WMIN), WIDTH_UPPER(WMAX), \ |
| 79 | PMIN - PRI_TOLERANCE, \ |
| 80 | PMAX * PRF + PRI_TOLERANCE, PRF, PPB * PRF, \ |
Peter Oh | beb28ed | 2015-03-04 15:43:45 +0200 | [diff] [blame] | 81 | PPB_THRESH(PPB), PRI_TOLERANCE, CHIRP \ |
Janusz Dziedzic | f12e3e0 | 2014-05-13 12:32:05 +0200 | [diff] [blame] | 82 | } |
| 83 | |
Peter Oh | 694c0e0 | 2015-04-09 18:50:10 +0300 | [diff] [blame^] | 84 | /* radar types released on August 14, 2014 |
| 85 | * type 1 PRI values randomly selected within the range of 518 and 3066. |
| 86 | * divide it to 3 groups is good enough for both of radar detection and |
| 87 | * avoiding false detection based on practical test results |
| 88 | * collected for more than a year. |
| 89 | */ |
Janusz Dziedzic | f12e3e0 | 2014-05-13 12:32:05 +0200 | [diff] [blame] | 90 | static const struct radar_detector_specs fcc_radar_ref_types[] = { |
Peter Oh | beb28ed | 2015-03-04 15:43:45 +0200 | [diff] [blame] | 91 | FCC_PATTERN(0, 0, 1, 1428, 1428, 1, 18, false), |
Peter Oh | 694c0e0 | 2015-04-09 18:50:10 +0300 | [diff] [blame^] | 92 | FCC_PATTERN(101, 0, 1, 518, 938, 1, 57, false), |
| 93 | FCC_PATTERN(102, 0, 1, 938, 2000, 1, 27, false), |
| 94 | FCC_PATTERN(103, 0, 1, 2000, 3066, 1, 18, false), |
| 95 | FCC_PATTERN(2, 0, 5, 150, 230, 1, 23, false), |
| 96 | FCC_PATTERN(3, 6, 10, 200, 500, 1, 16, false), |
| 97 | FCC_PATTERN(4, 11, 20, 200, 500, 1, 12, false), |
| 98 | FCC_PATTERN(5, 50, 100, 1000, 2000, 1, 1, true), |
| 99 | FCC_PATTERN(6, 0, 1, 333, 333, 1, 9, false), |
Janusz Dziedzic | f12e3e0 | 2014-05-13 12:32:05 +0200 | [diff] [blame] | 100 | }; |
| 101 | |
| 102 | static const struct radar_types fcc_radar_types = { |
| 103 | .region = NL80211_DFS_FCC, |
| 104 | .num_radar_types = ARRAY_SIZE(fcc_radar_ref_types), |
| 105 | .radar_types = fcc_radar_ref_types, |
| 106 | }; |
| 107 | |
Janusz Dziedzic | 89ce4f6 | 2014-05-13 12:32:06 +0200 | [diff] [blame] | 108 | #define JP_PATTERN FCC_PATTERN |
| 109 | static const struct radar_detector_specs jp_radar_ref_types[] = { |
Peter Oh | beb28ed | 2015-03-04 15:43:45 +0200 | [diff] [blame] | 110 | JP_PATTERN(0, 0, 1, 1428, 1428, 1, 18, false), |
| 111 | JP_PATTERN(1, 2, 3, 3846, 3846, 1, 18, false), |
| 112 | JP_PATTERN(2, 0, 1, 1388, 1388, 1, 18, false), |
| 113 | JP_PATTERN(3, 1, 2, 4000, 4000, 1, 18, false), |
| 114 | JP_PATTERN(4, 0, 5, 150, 230, 1, 23, false), |
| 115 | JP_PATTERN(5, 6, 10, 200, 500, 1, 16, false), |
| 116 | JP_PATTERN(6, 11, 20, 200, 500, 1, 12, false), |
| 117 | JP_PATTERN(7, 50, 100, 1000, 2000, 1, 20, false), |
| 118 | JP_PATTERN(5, 0, 1, 333, 333, 1, 9, false), |
Janusz Dziedzic | 89ce4f6 | 2014-05-13 12:32:06 +0200 | [diff] [blame] | 119 | }; |
| 120 | |
| 121 | static const struct radar_types jp_radar_types = { |
| 122 | .region = NL80211_DFS_JP, |
| 123 | .num_radar_types = ARRAY_SIZE(jp_radar_ref_types), |
| 124 | .radar_types = jp_radar_ref_types, |
| 125 | }; |
| 126 | |
Zefir Kurtisi | 6ee159e | 2012-04-03 17:15:49 +0200 | [diff] [blame] | 127 | static const struct radar_types *dfs_domains[] = { |
| 128 | &etsi_radar_types_v15, |
Janusz Dziedzic | f12e3e0 | 2014-05-13 12:32:05 +0200 | [diff] [blame] | 129 | &fcc_radar_types, |
Janusz Dziedzic | 89ce4f6 | 2014-05-13 12:32:06 +0200 | [diff] [blame] | 130 | &jp_radar_types, |
Zefir Kurtisi | 6ee159e | 2012-04-03 17:15:49 +0200 | [diff] [blame] | 131 | }; |
| 132 | |
| 133 | /** |
| 134 | * get_dfs_domain_radar_types() - get radar types for a given DFS domain |
| 135 | * @param domain DFS domain |
| 136 | * @return radar_types ptr on success, NULL if DFS domain is not supported |
| 137 | */ |
| 138 | static const struct radar_types * |
| 139 | get_dfs_domain_radar_types(enum nl80211_dfs_regions region) |
| 140 | { |
| 141 | u32 i; |
| 142 | for (i = 0; i < ARRAY_SIZE(dfs_domains); i++) { |
| 143 | if (dfs_domains[i]->region == region) |
| 144 | return dfs_domains[i]; |
| 145 | } |
| 146 | return NULL; |
| 147 | } |
| 148 | |
| 149 | /** |
| 150 | * struct channel_detector - detector elements for a DFS channel |
| 151 | * @head: list_head |
| 152 | * @freq: frequency for this channel detector in MHz |
| 153 | * @detectors: array of dynamically created detector elements for this freq |
| 154 | * |
| 155 | * Channel detectors are required to provide multi-channel DFS detection, e.g. |
| 156 | * to support off-channel scanning. A pattern detector has a list of channels |
| 157 | * radar pulses have been reported for in the past. |
| 158 | */ |
| 159 | struct channel_detector { |
| 160 | struct list_head head; |
| 161 | u16 freq; |
| 162 | struct pri_detector **detectors; |
| 163 | }; |
| 164 | |
| 165 | /* channel_detector_reset() - reset detector lines for a given channel */ |
| 166 | static void channel_detector_reset(struct dfs_pattern_detector *dpd, |
| 167 | struct channel_detector *cd) |
| 168 | { |
| 169 | u32 i; |
| 170 | if (cd == NULL) |
| 171 | return; |
| 172 | for (i = 0; i < dpd->num_radar_types; i++) |
| 173 | cd->detectors[i]->reset(cd->detectors[i], dpd->last_pulse_ts); |
| 174 | } |
| 175 | |
| 176 | /* channel_detector_exit() - destructor */ |
| 177 | static void channel_detector_exit(struct dfs_pattern_detector *dpd, |
| 178 | struct channel_detector *cd) |
| 179 | { |
| 180 | u32 i; |
| 181 | if (cd == NULL) |
| 182 | return; |
| 183 | list_del(&cd->head); |
| 184 | for (i = 0; i < dpd->num_radar_types; i++) { |
| 185 | struct pri_detector *de = cd->detectors[i]; |
| 186 | if (de != NULL) |
| 187 | de->exit(de); |
| 188 | } |
| 189 | kfree(cd->detectors); |
| 190 | kfree(cd); |
| 191 | } |
| 192 | |
| 193 | static struct channel_detector * |
| 194 | channel_detector_create(struct dfs_pattern_detector *dpd, u16 freq) |
| 195 | { |
| 196 | u32 sz, i; |
| 197 | struct channel_detector *cd; |
| 198 | |
Zefir Kurtisi | 5d8cd3b | 2013-04-02 12:51:48 +0200 | [diff] [blame] | 199 | cd = kmalloc(sizeof(*cd), GFP_ATOMIC); |
Zefir Kurtisi | 6ee159e | 2012-04-03 17:15:49 +0200 | [diff] [blame] | 200 | if (cd == NULL) |
| 201 | goto fail; |
| 202 | |
| 203 | INIT_LIST_HEAD(&cd->head); |
| 204 | cd->freq = freq; |
| 205 | sz = sizeof(cd->detectors) * dpd->num_radar_types; |
Zefir Kurtisi | 5d8cd3b | 2013-04-02 12:51:48 +0200 | [diff] [blame] | 206 | cd->detectors = kzalloc(sz, GFP_ATOMIC); |
Zefir Kurtisi | 6ee159e | 2012-04-03 17:15:49 +0200 | [diff] [blame] | 207 | if (cd->detectors == NULL) |
| 208 | goto fail; |
| 209 | |
| 210 | for (i = 0; i < dpd->num_radar_types; i++) { |
| 211 | const struct radar_detector_specs *rs = &dpd->radar_spec[i]; |
| 212 | struct pri_detector *de = pri_detector_init(rs); |
| 213 | if (de == NULL) |
| 214 | goto fail; |
| 215 | cd->detectors[i] = de; |
| 216 | } |
| 217 | list_add(&cd->head, &dpd->channel_detectors); |
| 218 | return cd; |
| 219 | |
| 220 | fail: |
Janusz Dziedzic | 95a5992 | 2013-10-14 11:06:03 +0200 | [diff] [blame] | 221 | ath_dbg(dpd->common, DFS, |
Zefir Kurtisi | ca21cfd | 2013-04-15 11:29:06 +0200 | [diff] [blame] | 222 | "failed to allocate channel_detector for freq=%d\n", freq); |
Zefir Kurtisi | 6ee159e | 2012-04-03 17:15:49 +0200 | [diff] [blame] | 223 | channel_detector_exit(dpd, cd); |
| 224 | return NULL; |
| 225 | } |
| 226 | |
| 227 | /** |
| 228 | * channel_detector_get() - get channel detector for given frequency |
| 229 | * @param dpd instance pointer |
| 230 | * @param freq frequency in MHz |
| 231 | * @return pointer to channel detector on success, NULL otherwise |
| 232 | * |
| 233 | * Return existing channel detector for the given frequency or return a |
| 234 | * newly create one. |
| 235 | */ |
| 236 | static struct channel_detector * |
| 237 | channel_detector_get(struct dfs_pattern_detector *dpd, u16 freq) |
| 238 | { |
| 239 | struct channel_detector *cd; |
| 240 | list_for_each_entry(cd, &dpd->channel_detectors, head) { |
| 241 | if (cd->freq == freq) |
| 242 | return cd; |
| 243 | } |
| 244 | return channel_detector_create(dpd, freq); |
| 245 | } |
| 246 | |
| 247 | /* |
| 248 | * DFS Pattern Detector |
| 249 | */ |
| 250 | |
| 251 | /* dpd_reset(): reset all channel detectors */ |
| 252 | static void dpd_reset(struct dfs_pattern_detector *dpd) |
| 253 | { |
| 254 | struct channel_detector *cd; |
| 255 | if (!list_empty(&dpd->channel_detectors)) |
| 256 | list_for_each_entry(cd, &dpd->channel_detectors, head) |
| 257 | channel_detector_reset(dpd, cd); |
| 258 | |
| 259 | } |
| 260 | static void dpd_exit(struct dfs_pattern_detector *dpd) |
| 261 | { |
| 262 | struct channel_detector *cd, *cd0; |
| 263 | if (!list_empty(&dpd->channel_detectors)) |
| 264 | list_for_each_entry_safe(cd, cd0, &dpd->channel_detectors, head) |
| 265 | channel_detector_exit(dpd, cd); |
| 266 | kfree(dpd); |
| 267 | } |
| 268 | |
| 269 | static bool |
| 270 | dpd_add_pulse(struct dfs_pattern_detector *dpd, struct pulse_event *event) |
| 271 | { |
| 272 | u32 i; |
Zefir Kurtisi | 6ee159e | 2012-04-03 17:15:49 +0200 | [diff] [blame] | 273 | struct channel_detector *cd; |
| 274 | |
Zefir Kurtisi | ca21cfd | 2013-04-15 11:29:06 +0200 | [diff] [blame] | 275 | /* |
| 276 | * pulses received for a non-supported or un-initialized |
| 277 | * domain are treated as detected radars for fail-safety |
| 278 | */ |
| 279 | if (dpd->region == NL80211_DFS_UNSET) |
Zefir Kurtisi | 6ee159e | 2012-04-03 17:15:49 +0200 | [diff] [blame] | 280 | return true; |
Zefir Kurtisi | 6ee159e | 2012-04-03 17:15:49 +0200 | [diff] [blame] | 281 | |
| 282 | cd = channel_detector_get(dpd, event->freq); |
| 283 | if (cd == NULL) |
| 284 | return false; |
| 285 | |
Zefir Kurtisi | 6ee159e | 2012-04-03 17:15:49 +0200 | [diff] [blame] | 286 | dpd->last_pulse_ts = event->ts; |
Zefir Kurtisi | ca21cfd | 2013-04-15 11:29:06 +0200 | [diff] [blame] | 287 | /* reset detector on time stamp wraparound, caused by TSF reset */ |
| 288 | if (event->ts < dpd->last_pulse_ts) |
Zefir Kurtisi | 6ee159e | 2012-04-03 17:15:49 +0200 | [diff] [blame] | 289 | dpd_reset(dpd); |
Zefir Kurtisi | ca21cfd | 2013-04-15 11:29:06 +0200 | [diff] [blame] | 290 | |
Zefir Kurtisi | 6ee159e | 2012-04-03 17:15:49 +0200 | [diff] [blame] | 291 | /* do type individual pattern matching */ |
| 292 | for (i = 0; i < dpd->num_radar_types; i++) { |
Zefir Kurtisi | ca21cfd | 2013-04-15 11:29:06 +0200 | [diff] [blame] | 293 | struct pri_detector *pd = cd->detectors[i]; |
| 294 | struct pri_sequence *ps = pd->add_pulse(pd, event); |
| 295 | if (ps != NULL) { |
Janusz Dziedzic | 95a5992 | 2013-10-14 11:06:03 +0200 | [diff] [blame] | 296 | ath_dbg(dpd->common, DFS, |
Zefir Kurtisi | ca21cfd | 2013-04-15 11:29:06 +0200 | [diff] [blame] | 297 | "DFS: radar found on freq=%d: id=%d, pri=%d, " |
| 298 | "count=%d, count_false=%d\n", |
| 299 | event->freq, pd->rs->type_id, |
| 300 | ps->pri, ps->count, ps->count_falses); |
Zefir Kurtisi | 6ee159e | 2012-04-03 17:15:49 +0200 | [diff] [blame] | 301 | channel_detector_reset(dpd, cd); |
| 302 | return true; |
| 303 | } |
| 304 | } |
| 305 | return false; |
| 306 | } |
| 307 | |
Janusz Dziedzic | d265214 | 2013-10-14 11:06:04 +0200 | [diff] [blame] | 308 | static struct ath_dfs_pool_stats |
| 309 | dpd_get_stats(struct dfs_pattern_detector *dpd) |
| 310 | { |
| 311 | return global_dfs_pool_stats; |
| 312 | } |
| 313 | |
Zefir Kurtisi | 6ee159e | 2012-04-03 17:15:49 +0200 | [diff] [blame] | 314 | static bool dpd_set_domain(struct dfs_pattern_detector *dpd, |
| 315 | enum nl80211_dfs_regions region) |
| 316 | { |
| 317 | const struct radar_types *rt; |
| 318 | struct channel_detector *cd, *cd0; |
| 319 | |
| 320 | if (dpd->region == region) |
| 321 | return true; |
| 322 | |
| 323 | dpd->region = NL80211_DFS_UNSET; |
| 324 | |
| 325 | rt = get_dfs_domain_radar_types(region); |
| 326 | if (rt == NULL) |
| 327 | return false; |
| 328 | |
| 329 | /* delete all channel detectors for previous DFS domain */ |
| 330 | if (!list_empty(&dpd->channel_detectors)) |
| 331 | list_for_each_entry_safe(cd, cd0, &dpd->channel_detectors, head) |
| 332 | channel_detector_exit(dpd, cd); |
| 333 | dpd->radar_spec = rt->radar_types; |
| 334 | dpd->num_radar_types = rt->num_radar_types; |
| 335 | |
| 336 | dpd->region = region; |
| 337 | return true; |
| 338 | } |
| 339 | |
| 340 | static struct dfs_pattern_detector default_dpd = { |
| 341 | .exit = dpd_exit, |
Zefir Kurtisi | 259bcf8 | 2012-10-31 12:21:56 +0100 | [diff] [blame] | 342 | .set_dfs_domain = dpd_set_domain, |
Zefir Kurtisi | 6ee159e | 2012-04-03 17:15:49 +0200 | [diff] [blame] | 343 | .add_pulse = dpd_add_pulse, |
Janusz Dziedzic | d265214 | 2013-10-14 11:06:04 +0200 | [diff] [blame] | 344 | .get_stats = dpd_get_stats, |
Zefir Kurtisi | 6ee159e | 2012-04-03 17:15:49 +0200 | [diff] [blame] | 345 | .region = NL80211_DFS_UNSET, |
| 346 | }; |
| 347 | |
| 348 | struct dfs_pattern_detector * |
Janusz Dziedzic | 95a5992 | 2013-10-14 11:06:03 +0200 | [diff] [blame] | 349 | dfs_pattern_detector_init(struct ath_common *common, |
| 350 | enum nl80211_dfs_regions region) |
Zefir Kurtisi | 6ee159e | 2012-04-03 17:15:49 +0200 | [diff] [blame] | 351 | { |
| 352 | struct dfs_pattern_detector *dpd; |
Joe Perches | 0d2e7a5 | 2013-02-03 17:28:14 +0000 | [diff] [blame] | 353 | |
Janusz Dziedzic | 379ce86 | 2013-10-14 11:06:05 +0200 | [diff] [blame] | 354 | if (!config_enabled(CONFIG_CFG80211_CERTIFICATION_ONUS)) |
| 355 | return NULL; |
| 356 | |
Zefir Kurtisi | 6ee159e | 2012-04-03 17:15:49 +0200 | [diff] [blame] | 357 | dpd = kmalloc(sizeof(*dpd), GFP_KERNEL); |
Joe Perches | 0d2e7a5 | 2013-02-03 17:28:14 +0000 | [diff] [blame] | 358 | if (dpd == NULL) |
Zefir Kurtisi | 6ee159e | 2012-04-03 17:15:49 +0200 | [diff] [blame] | 359 | return NULL; |
Joe Perches | 0d2e7a5 | 2013-02-03 17:28:14 +0000 | [diff] [blame] | 360 | |
Zefir Kurtisi | 6ee159e | 2012-04-03 17:15:49 +0200 | [diff] [blame] | 361 | *dpd = default_dpd; |
| 362 | INIT_LIST_HEAD(&dpd->channel_detectors); |
| 363 | |
Janusz Dziedzic | 95a5992 | 2013-10-14 11:06:03 +0200 | [diff] [blame] | 364 | dpd->common = common; |
Zefir Kurtisi | 259bcf8 | 2012-10-31 12:21:56 +0100 | [diff] [blame] | 365 | if (dpd->set_dfs_domain(dpd, region)) |
Zefir Kurtisi | 6ee159e | 2012-04-03 17:15:49 +0200 | [diff] [blame] | 366 | return dpd; |
| 367 | |
Zefir Kurtisi | ca21cfd | 2013-04-15 11:29:06 +0200 | [diff] [blame] | 368 | ath_dbg(common, DFS,"Could not set DFS domain to %d", region); |
Zefir Kurtisi | 70bf870 | 2012-10-31 12:22:34 +0100 | [diff] [blame] | 369 | kfree(dpd); |
Zefir Kurtisi | 6ee159e | 2012-04-03 17:15:49 +0200 | [diff] [blame] | 370 | return NULL; |
| 371 | } |
| 372 | EXPORT_SYMBOL(dfs_pattern_detector_init); |