1 /* 2 * Copyright (c) 2016-2019 The Linux Foundation. All rights reserved. 3 * Copyright (c) 2011, Atheros Communications Inc. 4 * 5 * Permission to use, copy, modify, and/or distribute this software for any 6 * purpose with or without fee is hereby granted, provided that the above 7 * copyright notice and this permission notice appear in all copies. 8 * 9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 12 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 14 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 16 */ 17 18 /** 19 * DOC: This file has radar table and initialization function for Beeliner 20 * family of chipsets. 21 */ 22 23 #include "../dfs.h" 24 #include "wlan_dfs_mlme_api.h" 25 #include <wlan_objmgr_vdev_obj.h> 26 #include "wlan_dfs_utils_api.h" 27 #include "wlan_dfs_lmac_api.h" 28 #include "../dfs_internal.h" 29 #include "../dfs_partial_offload_radar.h" 30 #if defined(WLAN_DFS_PARTIAL_OFFLOAD) && defined(HOST_DFS_SPOOF_TEST) 31 #include "../dfs_process_radar_found_ind.h" 32 #endif 33 34 /** 35 * struct dfs_pulse dfs_fcc_radars - FCC radar table for Offload chipsets. 36 */ 37 static struct dfs_pulse dfs_fcc_radars[] = { 38 /* FCC TYPE 1 */ 39 {18, 1, 700, 700, 0, 4, 5, 0, 1, 18, 0, 3, 1, 5, 0, 0}, 40 {18, 1, 350, 350, 0, 4, 5, 0, 1, 18, 0, 3, 0, 5, 0, 0}, 41 42 /* FCC TYPE 6 */ 43 {9, 1, 3003, 3003, 1, 7, 5, 0, 1, 18, 0, 0, 1, 1000, 0, 1}, 44 45 /* FCC TYPE 2 */ 46 {23, 5, 4347, 6666, 0, 4, 11, 0, 7, 22, 0, 3, 0, 5, 0, 2}, 47 48 /* FCC TYPE 3 */ 49 {18, 10, 2000, 5000, 0, 4, 8, 6, 13, 22, 0, 3, 0, 5, 0, 5}, 50 51 /* FCC TYPE 4 */ 52 {16, 15, 2000, 5000, 0, 4, 7, 11, 23, 22, 0, 3, 0, 5, 0, 11}, 53 54 /* FCC NEW TYPE 1 */ 55 /* 518us to 938us pulses (min 56 pulses) */ 56 {57, 1, 1066, 1930, 0, 4, 20, 0, 1, 22, 0, 3, 0, 5, 0, 21}, 57 58 /* 938us to 2000 pulses (min 26 pulses) */ 59 {27, 1, 500, 1066, 0, 4, 13, 0, 1, 22, 0, 3, 0, 5, 0, 22}, 60 61 /* 2000 to 3067us pulses (min 17 pulses) */ 62 {18, 1, 325, 500, 0, 4, 9, 0, 1, 22, 0, 3, 0, 5, 0, 23}, 63 }; 64 65 /** 66 * struct dfs_pulse dfs_mkk4_radars - MKK4 radar table for Offload chipsets. 67 */ 68 static struct dfs_pulse dfs_mkk4_radars[] = { 69 70 /* following two filters are specific to Japan/MKK4 */ 71 /* 1389 +/- 6 us */ 72 {18, 1, 720, 720, 0, 4, 6, 0, 1, 18, 0, 3, 0, 5, 0, 17}, 73 74 /* 4000 +/- 6 us */ 75 {18, 4, 250, 250, 0, 4, 5, 1, 6, 18, 0, 3, 0, 5, 0, 18}, 76 77 /* 3846 +/- 7 us */ 78 {18, 5, 260, 260, 0, 4, 6, 1, 6, 18, 0, 3, 1, 5, 0, 19}, 79 80 /* following filters are common to both FCC and JAPAN */ 81 82 /* FCC TYPE 1 */ 83 {18, 1, 700, 700, 0, 4, 5, 0, 1, 18, 0, 3, 1, 5, 0, 0}, 84 {18, 1, 350, 350, 0, 4, 5, 0, 1, 18, 0, 3, 0, 5, 0, 0}, 85 86 /* FCC TYPE 6 */ 87 {9, 1, 3003, 3003, 1, 7, 5, 0, 1, 18, 0, 0, 1, 1000, 0, 1}, 88 89 /* FCC TYPE 2 */ 90 {23, 5, 4347, 6666, 0, 4, 11, 0, 7, 22, 0, 3, 0, 5, 0, 2}, 91 92 /* FCC TYPE 3 */ 93 {18, 10, 2000, 5000, 0, 4, 8, 6, 13, 22, 0, 3, 0, 5, 0, 5}, 94 95 /* FCC TYPE 4 */ 96 {16, 15, 2000, 5000, 0, 4, 7, 11, 23, 22, 0, 3, 0, 5, 0, 11}, 97 }; 98 99 /** 100 * struct dfs_pulse dfs_mkkn_radars - MKKN radar table for Offload chipsets. 101 */ 102 static struct dfs_pulse dfs_mkkn_radars[] = { 103 /** Since the table is empty no new radar type shall be detected. 104 * New filters shall be added to this tables after proper testing 105 * and verification. 106 */ 107 /* constant PRF based */ 108 /* Type 1 */ 109 /* 0.8-5us, 200 300 PRF, 10 pulses */ 110 {10, 5, 200, 400, 0, 4, 5, 0, 8, 15, 0, 0, 2, 5, 0, 91}, 111 {10, 5, 400, 600, 0, 4, 5, 0, 8, 15, 0, 0, 2, 5, 0, 92}, 112 {10, 5, 600, 800, 0, 4, 5, 0, 8, 15, 0, 0, 2, 5, 0, 93}, 113 {10, 5, 800, 1000, 0, 4, 5, 0, 8, 15, 0, 0, 2, 5, 0, 94}, 114 /* {10, 5, 200, 1000, 0, 6, 5, 0, 8, 15, 0, 0, 2, 5, 33}, */ 115 116 /* Type 2 */ 117 /* 0.8-15us, 200-1600 PRF, 15 pulses */ 118 {15, 15, 200, 1600, 0, 4, 8, 0, 18, 24, 0, 0, 0, 5, 0, 95}, 119 120 }; 121 122 /** 123 * struct dfs_bin5pulse dfs_fcc_bin5pulses - FCC BIN5 pulses for Offload 124 * chipsets. 125 */ 126 static struct dfs_bin5pulse dfs_fcc_bin5pulses[] = { 127 {6, 28, 105, 12, 18, 5}, 128 }; 129 130 /** 131 * struct dfs_bin5pulse dfs_jpn_bin5pulses - JAPAN BIN5 pulses for Offload 132 * chipsets. 133 */ 134 static struct dfs_bin5pulse dfs_jpn_bin5pulses[] = { 135 {5, 28, 105, 12, 22, 5}, 136 }; 137 138 /** 139 * dfs_bin5pulse dfs_fcc_bin5pulses_ar900b - FCC BIN5 pulses for AR9300 140 * chipsets. 141 * 142 * WAR : IR 42631 143 * Beeliner 2 is tested at -65dbm as opposed to -62 dbm. 144 * For FCC/JPN chirping pulses, HW reports RSSI value that is lower by 2dbm 145 * when we enable noise floor claibration. This is specially true for 146 * frequencies that are greater than center frequency and in VHT80 mode. 147 */ 148 149 static struct dfs_bin5pulse dfs_fcc_bin5pulses_ar900b[] = { 150 {5, 28, 105, 12, 20, 5}, 151 }; 152 153 /** 154 * dfs_bin5pulse dfs_jpn_bin5pulses_ar900b - JAPAN BIN5 pulses for AR9300 155 * chipsets. 156 */ 157 static struct dfs_bin5pulse dfs_jpn_bin5pulses_ar900b[] = { 158 {5, 28, 105, 12, 20, 5}, 159 }; 160 161 /** 162 * dfs_bin5pulse dfs_fcc_bin5pulses_qca9984 - FCC BIN5 pulses for QCA9984 163 * chipsets. 164 * WAR : IR-83400 165 * Cascade is tested at -65dbm as opposed to -62 dbm. 166 * For FCC/JPN chirping pulses, HW reports RSSI value that is significantly 167 * lower at left edge especially in HT80_80 mode. Also, duration may be 168 * significantly low. This can result in false detection and we may have to 169 * raise the threshold. 170 */ 171 static struct dfs_bin5pulse dfs_fcc_bin5pulses_qca9984[] = { 172 {5, 20, 105, 12, 20, 0}, 173 }; 174 175 /** 176 * dfs_bin5pulse dfs_jpn_bin5pulses_qca9984 - JAPAN BIN5 pulses for QCA9984 177 * chipsets. 178 */ 179 static struct dfs_bin5pulse dfs_jpn_bin5pulses_qca9984[] = { 180 {5, 20, 105, 12, 20, 0}, 181 }; 182 183 /** 184 * dfs_pulse dfs_etsi_radars - ETSI radar table. 185 */ 186 static struct dfs_pulse dfs_etsi_radars[] = { 187 188 /* EN 302 502 frequency hopping pulse */ 189 /* PRF 3000, 1us duration, 9 pulses per burst */ 190 {9, 1, 3000, 3000, 1, 4, 5, 0, 1, 18, 0, 0, 1, 1000, 0, 40}, 191 /* PRF 4500, 20us duration, 9 pulses per burst */ 192 {9, 20, 4500, 4500, 1, 4, 5, 19, 21, 18, 0, 0, 1, 1000, 0, 41}, 193 194 /* Type 3 */ 195 /* 10 15us, 200-1000 PRF, 15 pulses */ 196 {15, 15, 200, 1000, 0, 4, 5, 8, 18, 22, 0, 0, 0, 5, 0, 42}, 197 198 /* Type 4 */ 199 /* 1-15us, 1200-1600 PRF, 15 pulses */ 200 {15, 15, 1200, 1600, 0, 4, 5, 0, 18, 22, 0, 0, 0, 5, 0, 43}, 201 202 /* TYPE staggered pulse */ 203 /* Type 5*/ 204 /* 0.8-2us, 2-3 bursts,300-400 PRF, 10 pulses each */ 205 {30, 2, 300, 400, 2, 30, 3, 0, 5, 15, 0, 0, 1, 5, 0, 31}, 206 /* Type 6 */ 207 /* 0.8-2us, 2-3 bursts, 400-1200 PRF, 15 pulses each */ 208 {30, 2, 400, 1200, 2, 30, 7, 0, 5, 15, 0, 0, 0, 5, 0, 32}, 209 210 /* constant PRF based */ 211 /* Type 1 */ 212 /* 0.8-5us, 200 300 PRF, 10 pulses */ 213 {10, 5, 200, 400, 0, 4, 5, 0, 8, 15, 0, 0, 2, 5, 0, 33}, 214 {10, 5, 400, 600, 0, 4, 5, 0, 8, 15, 0, 0, 2, 5, 0, 37}, 215 {10, 5, 600, 800, 0, 4, 5, 0, 8, 15, 0, 0, 2, 5, 0, 38}, 216 {10, 5, 800, 1000, 0, 4, 5, 0, 8, 15, 0, 0, 2, 5, 0, 39}, 217 /* {10, 5, 200, 1000, 0, 6, 5, 0, 8, 15, 0, 0, 2, 5, 33}, */ 218 219 /* Type 2 */ 220 /* 0.8-15us, 200-1600 PRF, 15 pulses */ 221 {15, 15, 200, 1600, 0, 4, 8, 0, 18, 24, 0, 0, 0, 5, 0, 34}, 222 223 /* Type 3 */ 224 /* 0.8-15us, 2300-4000 PRF, 25 pulses*/ 225 {25, 15, 2300, 4000, 0, 4, 10, 0, 18, 24, 0, 0, 0, 5, 0, 35}, 226 227 /* Type 4 */ 228 /* 20-30us, 2000-4000 PRF, 20 pulses*/ 229 {20, 30, 2000, 4000, 0, 4, 6, 19, 33, 24, 0, 0, 0, 24, 1, 36}, 230 }; 231 232 /** 233 * dfs_pulse dfs_china_radars - CHINA radar table. 234 */ 235 static struct dfs_pulse dfs_china_radars[] = { 236 237 /* TYPE staggered pulse */ 238 /* Type 5*/ 239 /* 0.8-2us, 2-3 bursts,300-400 PRF, 12 pulses each */ 240 {36, 2, 300, 400, 2, 30, 3, 0, 5, 15, 0, 0, 1, 0, 0, 51}, 241 /* Type 6 */ 242 /* 0.8-2us, 2-3 bursts, 400-1200 PRF, 16 pulses each */ 243 {48, 2, 400, 1200, 2, 30, 7, 0, 5, 15, 0, 0, 0, 0, 0, 52}, 244 245 /* constant PRF based */ 246 /* Type 1 */ 247 /* 0.5-5us, 200 1000 PRF, 12 pulses */ 248 {12, 5, 200, 400, 0, 24, 5, 0, 8, 15, 0, 0, 2, 0, 0, 53}, 249 {12, 5, 400, 600, 0, 24, 5, 0, 8, 15, 0, 0, 2, 0, 0, 57}, 250 {12, 5, 600, 800, 0, 24, 5, 0, 8, 15, 0, 0, 2, 0, 0, 58}, 251 {12, 5, 800, 1000, 0, 24, 5, 0, 8, 15, 0, 0, 2, 0, 0, 59}, 252 253 /* Type 2 */ 254 /* 0.5-15us, 200-1600 PRF, 16 pulses */ 255 {16, 15, 200, 1600, 0, 24, 8, 0, 18, 24, 0, 0, 0, 0, 0, 54}, 256 257 /* Type 3 */ 258 /* 0.5-30us, 2300-4000 PRF, 24 pulses*/ 259 {24, 15, 2300, 4000, 0, 24, 10, 0, 33, 24, 0, 0, 0, 0, 0, 55}, 260 261 /* Type 4 */ 262 /* 20-30us, 2000-4000 PRF, 20 pulses*/ 263 {20, 30, 2000, 4000, 0, 24, 6, 19, 33, 24, 0, 0, 0, 0, 0, 56}, 264 265 /* 1us, 1000 PRF, 20 pulses */ 266 /* 1000 us PRI */ 267 {20, 1, 1000, 1000, 0, 6, 6, 0, 1, 18, 0, 3, 0, 0, 0, 50}, 268 }; 269 270 /** 271 * dfs_pulse dfs_korea_radars - KOREA radar table. 272 */ 273 static struct dfs_pulse dfs_korea_radars[] = { 274 /* Korea Type 1 */ 275 {18, 1, 700, 700, 0, 4, 5, 0, 1, 18, 0, 3, 1, 5, 0, 40}, 276 277 /* Korea Type 2 */ 278 {10, 1, 1800, 1800, 0, 4, 4, 0, 1, 18, 0, 3, 1, 5, 0, 41}, 279 280 /* Korea Type 3 */ 281 {70, 1, 330, 330, 0, 4, 20, 0, 3, 18, 0, 3, 1, 5, 0, 42}, 282 283 /* Korea Type 4 */ 284 {3, 1, 3003, 3003, 1, 7, 2, 0, 1, 18, 0, 0, 1, 1000, 0, 43}, 285 }; 286 287 #define RSSI_THERSH_AR900B 15 288 #define RSSI_THERSH_ADRASTEA 18 289 290 /** 291 * dfs_assign_fcc_pulse_table() - Assign FCC pulse table 292 * @rinfo: Pointer to wlan_dfs_radar_tab_info structure. 293 * @target_type: Target type. 294 * @tx_ops: target tx ops. 295 */ 296 static inline void dfs_assign_fcc_pulse_table( 297 struct wlan_dfs_radar_tab_info *rinfo, 298 uint32_t target_type, 299 struct wlan_lmac_if_target_tx_ops *tx_ops) 300 { 301 rinfo->dfs_radars = dfs_fcc_radars; 302 rinfo->numradars = QDF_ARRAY_SIZE(dfs_fcc_radars); 303 304 if (tx_ops->tgt_is_tgt_type_ar900b(target_type) || 305 tx_ops->tgt_is_tgt_type_ipq4019(target_type)) { 306 rinfo->b5pulses = dfs_fcc_bin5pulses_ar900b; 307 rinfo->numb5radars = QDF_ARRAY_SIZE(dfs_fcc_bin5pulses_ar900b); 308 } else if (tx_ops->tgt_is_tgt_type_qca9984(target_type) || 309 tx_ops->tgt_is_tgt_type_qca9888(target_type)) { 310 rinfo->b5pulses = dfs_fcc_bin5pulses_qca9984; 311 rinfo->numb5radars = 312 QDF_ARRAY_SIZE(dfs_fcc_bin5pulses_qca9984); 313 } else { 314 rinfo->b5pulses = dfs_fcc_bin5pulses; 315 rinfo->numb5radars = QDF_ARRAY_SIZE(dfs_fcc_bin5pulses); 316 } 317 } 318 319 #ifdef DFS_OVERRIDE_RF_THRESHOLD 320 static void dfs_set_adrastea_rf_thrshold( 321 struct wlan_objmgr_psoc *psoc, 322 int dfsdomain, 323 uint32_t target_type, 324 struct wlan_dfs_radar_tab_info *rinfo) 325 { 326 int i; 327 struct wlan_lmac_if_target_tx_ops *tx_ops; 328 329 tx_ops = &psoc->soc_cb.tx_ops.target_tx_ops; 330 331 if (tx_ops->tgt_is_tgt_type_adrastea(target_type) && 332 dfsdomain == DFS_ETSI_DOMAIN) { 333 for (i = 0; i < rinfo->numradars; i++) { 334 rinfo->dfs_radars[i].rp_rssithresh = 335 DFS_MIN(rinfo->dfs_radars[i].rp_rssithresh, 336 RSSI_THERSH_ADRASTEA); 337 } 338 } 339 } 340 #else 341 static inline void dfs_set_adrastea_rf_thrshold( 342 struct wlan_objmgr_psoc *psoc, 343 int dfsdomain, 344 uint32_t target_type, 345 struct wlan_dfs_radar_tab_info *rinfo) 346 { 347 } 348 #endif 349 350 void dfs_get_po_radars(struct wlan_dfs *dfs) 351 { 352 struct wlan_dfs_radar_tab_info rinfo; 353 struct wlan_objmgr_psoc *psoc; 354 struct wlan_lmac_if_target_tx_ops *tx_ops; 355 int i; 356 uint32_t target_type; 357 int dfsdomain = DFS_FCC_DOMAIN; 358 359 /* Fetch current radar patterns from the lmac */ 360 qdf_mem_zero(&rinfo, sizeof(rinfo)); 361 362 /* 363 * Look up the current DFS regulatory domain and decide 364 * which radar pulses to use. 365 */ 366 dfsdomain = utils_get_dfsdomain(dfs->dfs_pdev_obj); 367 target_type = lmac_get_target_type(dfs->dfs_pdev_obj); 368 369 psoc = wlan_pdev_get_psoc(dfs->dfs_pdev_obj); 370 if (!psoc) { 371 dfs_err(dfs, WLAN_DEBUG_DFS_ALWAYS, "psoc is NULL"); 372 return; 373 } 374 375 tx_ops = &(psoc->soc_cb.tx_ops.target_tx_ops); 376 switch (dfsdomain) { 377 case DFS_FCC_DOMAIN: 378 dfs_debug(dfs, WLAN_DEBUG_DFS_ALWAYS, "FCC domain"); 379 rinfo.dfsdomain = DFS_FCC_DOMAIN; 380 dfs_assign_fcc_pulse_table(&rinfo, target_type, tx_ops); 381 break; 382 case DFS_CN_DOMAIN: 383 dfs_info(dfs, WLAN_DEBUG_DFS_ALWAYS, 384 "FCC domain -- Country China(156) override FCC radar pattern" 385 ); 386 rinfo.dfsdomain = DFS_FCC_DOMAIN; 387 /* 388 * China uses a radar pattern that is similar to ETSI but it 389 * follows FCC in all other respect like transmit power, CCA 390 * threshold etc. 391 */ 392 rinfo.dfs_radars = dfs_china_radars; 393 rinfo.numradars = QDF_ARRAY_SIZE(dfs_china_radars); 394 rinfo.b5pulses = NULL; 395 rinfo.numb5radars = 0; 396 break; 397 case DFS_ETSI_DOMAIN: 398 dfs_info(dfs, WLAN_DEBUG_DFS_ALWAYS, "ETSI domain"); 399 rinfo.dfsdomain = DFS_ETSI_DOMAIN; 400 401 if (dfs_is_en302_502_applicable(dfs)) { 402 rinfo.dfs_radars = dfs_etsi_radars; 403 rinfo.numradars = QDF_ARRAY_SIZE(dfs_etsi_radars); 404 } else { 405 uint8_t offset = ETSI_LEGACY_PULSE_ARR_OFFSET; 406 407 rinfo.dfs_radars = &dfs_etsi_radars[offset]; 408 rinfo.numradars = 409 QDF_ARRAY_SIZE(dfs_etsi_radars) - offset; 410 } 411 rinfo.b5pulses = NULL; 412 rinfo.numb5radars = 0; 413 break; 414 case DFS_KR_DOMAIN: 415 dfs_info(dfs, WLAN_DEBUG_DFS_ALWAYS, 416 "ETSI domain -- Korea(412)"); 417 rinfo.dfsdomain = DFS_ETSI_DOMAIN; 418 419 /* 420 * So far we have treated Korea as part of ETSI and did not 421 * support any radar patters specific to Korea other than 422 * standard ETSI radar patterns. Ideally we would want to 423 * treat Korea as a different domain. This is something that 424 * we will address in the future. However, for now override 425 * ETSI tables for Korea. 426 */ 427 rinfo.dfs_radars = dfs_korea_radars; 428 rinfo.numradars = QDF_ARRAY_SIZE(dfs_korea_radars); 429 rinfo.b5pulses = NULL; 430 rinfo.numb5radars = 0; 431 break; 432 case DFS_MKKN_DOMAIN: 433 dfs_info(dfs, WLAN_DEBUG_DFS_ALWAYS, "MKKN domain"); 434 rinfo.dfsdomain = DFS_MKKN_DOMAIN; 435 rinfo.dfs_radars = dfs_mkkn_radars; 436 rinfo.numradars = QDF_ARRAY_SIZE(dfs_mkkn_radars); 437 rinfo.b5pulses = NULL; 438 rinfo.numb5radars = 0; 439 break; 440 case DFS_MKK4_DOMAIN: 441 dfs_info(dfs, WLAN_DEBUG_DFS_ALWAYS, "MKK4 domain"); 442 rinfo.dfsdomain = DFS_MKK4_DOMAIN; 443 rinfo.dfs_radars = dfs_mkk4_radars; 444 rinfo.numradars = QDF_ARRAY_SIZE(dfs_mkk4_radars); 445 446 if (tx_ops->tgt_is_tgt_type_ar900b(target_type) || 447 tx_ops->tgt_is_tgt_type_ipq4019(target_type)) { 448 rinfo.b5pulses = dfs_jpn_bin5pulses_ar900b; 449 rinfo.numb5radars = QDF_ARRAY_SIZE( 450 dfs_jpn_bin5pulses_ar900b); 451 } else if (tx_ops->tgt_is_tgt_type_qca9984(target_type) || 452 tx_ops->tgt_is_tgt_type_qca9888(target_type)) { 453 rinfo.b5pulses = dfs_jpn_bin5pulses_qca9984; 454 rinfo.numb5radars = QDF_ARRAY_SIZE 455 (dfs_jpn_bin5pulses_qca9984); 456 } else { 457 rinfo.b5pulses = dfs_jpn_bin5pulses; 458 rinfo.numb5radars = QDF_ARRAY_SIZE( 459 dfs_jpn_bin5pulses); 460 } 461 break; 462 default: 463 dfs_info(dfs, WLAN_DEBUG_DFS_ALWAYS, "UNINIT domain"); 464 rinfo.dfsdomain = DFS_UNINIT_DOMAIN; 465 rinfo.dfs_radars = NULL; 466 rinfo.numradars = 0; 467 rinfo.b5pulses = NULL; 468 rinfo.numb5radars = 0; 469 break; 470 } 471 472 if (tx_ops->tgt_is_tgt_type_ar900b(target_type) || 473 tx_ops->tgt_is_tgt_type_ipq4019(target_type) || 474 tx_ops->tgt_is_tgt_type_qca9984(target_type) || 475 tx_ops->tgt_is_tgt_type_qca9888(target_type)) { 476 /* Beeliner WAR: lower RSSI threshold to improve detection of 477 * certian radar types 478 */ 479 /* Cascade WAR: 480 * Cascade can report lower RSSI near the channel boundary then 481 * expected. It can also report significantly low RSSI at center 482 * (as low as 16) at center. So we are lowering threshold for 483 * all types of radar for * Cascade. 484 * This may increase the possibility of false radar detection. 485 * IR -- 083703, 083398, 083387 486 */ 487 488 for (i = 0; i < rinfo.numradars; i++) 489 rinfo.dfs_radars[i].rp_rssithresh = RSSI_THERSH_AR900B; 490 } 491 492 dfs_set_adrastea_rf_thrshold(psoc, dfsdomain, target_type, &rinfo); 493 494 WLAN_DFS_DATA_STRUCT_LOCK(dfs); 495 dfs_init_radar_filters(dfs, &rinfo); 496 WLAN_DFS_DATA_STRUCT_UNLOCK(dfs); 497 } 498 499 #if defined(WLAN_DFS_PARTIAL_OFFLOAD) && defined(HOST_DFS_SPOOF_TEST) 500 void dfs_send_avg_params_to_fw(struct wlan_dfs *dfs, 501 struct dfs_radar_found_params *params) 502 { 503 tgt_dfs_send_avg_params_to_fw(dfs->dfs_pdev_obj, params); 504 } 505 506 /** 507 * dfs_no_res_from_fw_task() - The timer function that is called if there is no 508 * response from fw after sending the average radar pulse parameters. 509 */ 510 static os_timer_func(dfs_no_res_from_fw_task) 511 { 512 struct wlan_dfs *dfs = NULL; 513 514 OS_GET_TIMER_ARG(dfs, struct wlan_dfs *); 515 516 if (!dfs) { 517 dfs_err(dfs, WLAN_DEBUG_DFS_ALWAYS, "dfs is NULL"); 518 return; 519 } 520 521 dfs_info(dfs, WLAN_DEBUG_DFS_ALWAYS, "Host wait timer expired"); 522 523 dfs->dfs_is_host_wait_running = 0; 524 dfs->dfs_no_res_from_fw = 1; 525 dfs_radarfound_action_generic(dfs, dfs->dfs_seg_id); 526 dfs->dfs_seg_id = 0; 527 } 528 529 void dfs_host_wait_timer_init(struct wlan_dfs *dfs) 530 { 531 qdf_timer_init(NULL, 532 &(dfs->dfs_host_wait_timer), 533 dfs_no_res_from_fw_task, 534 (void *)(dfs), 535 QDF_TIMER_TYPE_WAKE_APPS); 536 dfs->dfs_status_timeout_override = -1; 537 } 538 539 QDF_STATUS dfs_set_override_status_timeout(struct wlan_dfs *dfs, 540 int status_timeout) 541 { 542 if (!dfs) { 543 dfs_err(dfs, WLAN_DEBUG_DFS_ALWAYS, "dfs is NULL"); 544 return QDF_STATUS_E_FAILURE; 545 } 546 547 dfs->dfs_status_timeout_override = status_timeout; 548 549 dfs_info(dfs, WLAN_DEBUG_DFS_ALWAYS, 550 "Host wait status timeout is now %s : %d", 551 (status_timeout == -1) ? "default" : "overridden", 552 status_timeout); 553 554 return QDF_STATUS_SUCCESS; 555 } 556 557 QDF_STATUS dfs_get_override_status_timeout(struct wlan_dfs *dfs, 558 int *status_timeout) 559 { 560 if (!dfs) { 561 dfs_err(dfs, WLAN_DEBUG_DFS_ALWAYS, "dfs is NULL"); 562 return QDF_STATUS_E_FAILURE; 563 } 564 565 *status_timeout = dfs->dfs_status_timeout_override; 566 567 return QDF_STATUS_SUCCESS; 568 } 569 570 /** 571 * dfs_extract_radar_found_params() - Copy the contents of average radar 572 * parameters to dfs_radar_found_params parameter structure. 573 * 574 * @dfs: Pointer to wlan_dfs structure which contains the average radar 575 * parameters. 576 * @params: Pointer to dfs_radar_found_params structure. 577 */ 578 static 579 void dfs_extract_radar_found_params(struct wlan_dfs *dfs, 580 struct dfs_radar_found_params *params) 581 { 582 qdf_mem_zero(params, sizeof(*params)); 583 params->pri_min = dfs->dfs_average_pri; 584 params->pri_max = dfs->dfs_average_pri; 585 params->duration_min = dfs->dfs_average_duration; 586 params->duration_max = dfs->dfs_average_duration; 587 params->sidx_min = dfs->dfs_average_sidx; 588 params->sidx_max = dfs->dfs_average_sidx; 589 590 /* Bangradar will not populate any of these average 591 * parameters as pulse is not received. If these variables 592 * are not resetted here, these go as radar_found params 593 * for bangradar if bangradar is issued after real radar. 594 */ 595 dfs->dfs_average_sidx = 0; 596 dfs->dfs_average_duration = 0; 597 dfs->dfs_average_pri = 0; 598 } 599 600 void dfs_radarfound_action_fcc(struct wlan_dfs *dfs, uint8_t seg_id) 601 { 602 struct dfs_radar_found_params params; 603 604 qdf_mem_copy(&dfs->dfs_radar_found_chan, dfs->dfs_curchan, 605 sizeof(dfs->dfs_radar_found_chan)); 606 dfs_extract_radar_found_params(dfs, ¶ms); 607 dfs_send_avg_params_to_fw(dfs, ¶ms); 608 dfs->dfs_is_host_wait_running = 1; 609 dfs->dfs_seg_id = seg_id; 610 qdf_timer_mod(&dfs->dfs_host_wait_timer, 611 (dfs->dfs_status_timeout_override == 612 -1) ? HOST_DFS_STATUS_WAIT_TIMER_MS : 613 dfs->dfs_status_timeout_override); 614 } 615 616 void dfs_host_wait_timer_reset(struct wlan_dfs *dfs) 617 { 618 dfs->dfs_is_host_wait_running = 0; 619 qdf_timer_sync_cancel(&dfs->dfs_host_wait_timer); 620 } 621 622 /** 623 * dfs_action_on_spoof_success() - DFS action on spoof test pass 624 * @dfs: Pointer to DFS object 625 */ 626 static void dfs_action_on_spoof_success(struct wlan_dfs *dfs) 627 { 628 dfs->dfs_spoof_test_done = 1; 629 if (dfs->dfs_radar_found_chan.dfs_ch_freq == 630 dfs->dfs_curchan->dfs_ch_freq) { 631 dfs_info(dfs, WLAN_DEBUG_DFS_ALWAYS, 632 "cac timer started for channel %d", 633 dfs->dfs_curchan->dfs_ch_ieee); 634 dfs_start_cac_timer(dfs); 635 } else{ 636 dfs_remove_spoof_channel_from_nol(dfs); 637 } 638 } 639 640 void dfs_action_on_fw_radar_status_check(struct wlan_dfs *dfs, 641 uint32_t *status) 642 { 643 struct wlan_objmgr_pdev *dfs_pdev; 644 int no_chans_avail = 0; 645 int error_flag = 0; 646 647 dfs_host_wait_timer_reset(dfs); 648 dfs_info(dfs, WLAN_DEBUG_DFS_ALWAYS, "Host DFS status = %d", 649 *status); 650 651 dfs_pdev = dfs->dfs_pdev_obj; 652 if (!dfs_pdev) { 653 dfs_err(dfs, WLAN_DEBUG_DFS_ALWAYS, "dfs_pdev_obj is NULL"); 654 return; 655 } 656 657 switch (*status) { 658 case HOST_DFS_STATUS_CHECK_PASSED: 659 if (dfs->dfs_average_params_sent) 660 dfs_action_on_spoof_success(dfs); 661 else 662 error_flag = 1; 663 break; 664 case HOST_DFS_STATUS_CHECK_FAILED: 665 dfs->dfs_spoof_check_failed = 1; 666 no_chans_avail = 667 dfs_mlme_rebuild_chan_list_with_non_dfs_channels(dfs_pdev); 668 dfs_mlme_restart_vaps_with_non_dfs_chan(dfs_pdev, 669 no_chans_avail); 670 break; 671 case HOST_DFS_STATUS_CHECK_HW_RADAR: 672 if (dfs->dfs_average_params_sent) { 673 if (dfs->dfs_radar_found_chan.dfs_ch_freq == 674 dfs->dfs_curchan->dfs_ch_freq) { 675 dfs_radarfound_action_generic( 676 dfs, 677 dfs->dfs_seg_id); 678 } else { 679 /* Else of this case, no action is needed as 680 * dfs_action would have been done at timer 681 * expiry itself. 682 */ 683 dfs_info(dfs, WLAN_DEBUG_DFS_ALWAYS, 684 "DFS Action already taken"); 685 } 686 } else { 687 error_flag = 1; 688 } 689 break; 690 default: 691 dfs_info(dfs, WLAN_DEBUG_DFS_ALWAYS, 692 "Status event mismatch:%d, Ignoring it", 693 *status); 694 } 695 696 dfs->dfs_average_params_sent = 0; 697 qdf_mem_zero(&dfs->dfs_radar_found_chan, sizeof(struct dfs_channel)); 698 699 if (error_flag == 1) { 700 dfs_info(dfs, WLAN_DEBUG_DFS_ALWAYS, 701 "Received imroper response %d. Discarding it", 702 *status); 703 } 704 } 705 706 void dfs_reset_spoof_test(struct wlan_dfs *dfs) 707 { 708 dfs->dfs_spoof_test_done = 0; 709 dfs->dfs_spoof_check_failed = 0; 710 } 711 #endif 712