1 /* 2 * Copyright (c) 2016-2018 The Linux Foundation. All rights reserved. 3 * 4 * 5 * Permission to use, copy, modify, and/or distribute this software for 6 * any purpose with or without fee is hereby granted, provided that the 7 * above copyright notice and this permission notice appear in all 8 * copies. 9 * 10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 11 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 12 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 13 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL 14 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR 15 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER 16 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 17 * PERFORMANCE OF THIS SOFTWARE. 18 */ 19 20 /** 21 * DOC: This file has the DFS dispatcher API which is exposed to outside of DFS 22 * component. 23 */ 24 25 #ifndef _WLAN_DFS_UTILS_API_H_ 26 #define _WLAN_DFS_UTILS_API_H_ 27 28 #include "wlan_dfs_ucfg_api.h" 29 #include "wlan_reg_services_api.h" 30 31 /* Add channel to nol */ 32 #define DFS_NOL_SET 1 33 34 /* Remove channel from nol */ 35 #define DFS_NOL_RESET 0 36 37 /* Max nol channels */ 38 #define DFS_MAX_NOL_CHANNEL 80 39 40 /* WLAN 2.4GHz start freq */ 41 #define DFS_24_GHZ_BASE_FREQ (2407) 42 43 /* WLAN 5GHz start freq */ 44 #define DFS_5_GHZ_BASE_FREQ (5000) 45 46 /* WLAN 2.4 GHz channel number 6 */ 47 #define DFS_24_GHZ_CHANNEL_6 (6) 48 49 /* WLAN 2.4 GHz channel number 14 */ 50 #define DFS_24_GHZ_CHANNEL_14 (14) 51 52 /* WLAN 2.4 GHz channel number 15 */ 53 #define DFS_24_GHZ_CHANNEL_15 (15) 54 55 /* WLAN 2.4 GHz channel number 27 */ 56 #define DFS_24_GHZ_CHANNEL_27 (27) 57 58 /* WLAN 5GHz channel number 170 */ 59 #define DFS_5_GHZ_CHANNEL_170 (170) 60 61 /* WLAN 5MHz channel spacing */ 62 #define DFS_CHAN_SPACING_5MHZ (5) 63 64 /* WLAN 20Hz channel spacing */ 65 #define DFS_CHAN_SPACING_20MHZ (20) 66 67 /* WLAN 2.4GHz channel number 14 freq */ 68 #define DFS_CHAN_14_FREQ (2484) 69 70 /* WLAN 2.4GHz channel number 15 freq */ 71 #define DFS_CHAN_15_FREQ (2512) 72 73 /* WLAN 5GHz channel number 170 freq */ 74 #define DFS_CHAN_170_FREQ (5852) 75 76 77 78 extern struct dfs_to_mlme global_dfs_to_mlme; 79 80 /** 81 * utils_dfs_cac_valid_reset() - Cancels the dfs_cac_valid_timer timer. 82 * @pdev: Pointer to DFS pdev object. 83 * @prevchan_ieee: Prevchan number. 84 * @prevchan_flags: Prevchan flags. 85 * 86 * Wrapper function for dfs_cac_valid_reset(). This function called from 87 * outside of DFS component. 88 */ 89 90 QDF_STATUS utils_dfs_cac_valid_reset(struct wlan_objmgr_pdev *pdev, 91 uint8_t prevchan_ieee, 92 uint32_t prevchan_flags); 93 94 /** 95 * utils_dfs_reset() - Reset DFS members. 96 * @pdev: Pointer to DFS pdev object. 97 */ 98 QDF_STATUS utils_dfs_reset(struct wlan_objmgr_pdev *pdev); 99 100 /** 101 * utils_dfs_reset_precaclists() - Clears and initiakizes precac_required_list, 102 * precac_done_list and precac_nol_list. 103 * @pdev: Pointer to DFS pdev object. 104 * 105 * Wrapper function for dfs_reset_precaclists(). This function called from 106 * outside of DFS component. 107 */ 108 QDF_STATUS utils_dfs_reset_precaclists(struct wlan_objmgr_pdev *pdev); 109 110 /** 111 * utils_dfs_reset_etsi_precaclists() - Clears and initializes etsi 112 * precac_required_list, 113 * etsi precac_done_list and 114 * etsi precac_nol_list. 115 * @pdev: Pointer to DFS pdev object. 116 * 117 * Wrapper function for dfs_reset_etsiprecaclists(). This function called from 118 * outside of DFS component. 119 */ 120 #ifdef QCA_SUPPORT_ETSI_PRECAC_DFS 121 QDF_STATUS utils_dfs_reset_etsi_precaclists(struct wlan_objmgr_pdev *pdev); 122 #else 123 static inline QDF_STATUS utils_dfs_reset_etsi_precaclists( 124 struct wlan_objmgr_pdev *pdev) 125 { 126 return QDF_STATUS_SUCCESS; 127 } 128 #endif 129 130 /** 131 * utils_dfs_cancel_precac_timer() - Cancel the precac timer. 132 * @pdev: Pointer to DFS pdev object. 133 * 134 * wrapper function for dfs_cancel_precac_timer(). this function called from 135 * outside of dfs component. 136 */ 137 QDF_STATUS utils_dfs_cancel_precac_timer(struct wlan_objmgr_pdev *pdev); 138 139 /** 140 * utils_dfs_start_precac_timer() - Start the precac timer. 141 * @pdev: Pointer to DFS pdev object. 142 * 143 * Wrapper function for dfs_start_precac_timer(). This function called from 144 * outside of dfs component. 145 * 146 * Return: 147 * * QDF_STATUS_E_FAILURE: Failed to start timer. 148 * * QDF_STATUS_SUCCESS: Timer started successfully. 149 */ 150 QDF_STATUS utils_dfs_start_precac_timer(struct wlan_objmgr_pdev *pdev); 151 152 /** 153 * utils_dfs_is_precac_done() - Is precac done. 154 * @pdev: Pointer to DFS pdev object. 155 * 156 * wrapper function for dfs_is_precac_done(). this 157 * function called from outside of dfs component. 158 */ 159 QDF_STATUS utils_dfs_is_precac_done(struct wlan_objmgr_pdev *pdev, 160 bool *is_precac_done); 161 162 #ifdef WLAN_DFS_PRECAC_AUTO_CHAN_SUPPORT 163 /** 164 * utils_dfs_precac_decide_pref_chan() - Choose preferred channel 165 * @pdev: Pointer to DFS pdev object. 166 * @ch_ieee: Pointer to channel number 167 168 * Wrapper function for dfs_decide_precac_preferred_chan(). This 169 * function called from outside of dfs component. 170 * 171 * Return: 172 * * QDF_STATUS_E_FAILURE: Failed to decide preferred channel. 173 * * QDF_STATUS_SUCCESS: Set preferred channel successfully. 174 */ 175 QDF_STATUS utils_dfs_precac_decide_pref_chan(struct wlan_objmgr_pdev *pdev, 176 uint8_t *ch_ieee); 177 #endif 178 179 /** 180 * utils_dfs_is_esti_precac_done() - Is ETSI precac done. 181 * @pdev: Pointer to DFS pdev object. 182 * 183 * wrapper function for dfs_is_etsi_precac_done(). This 184 * function called from outside of dfs component. 185 */ 186 #ifdef QCA_SUPPORT_ETSI_PRECAC_DFS 187 QDF_STATUS utils_dfs_is_etsi_precac_done(struct wlan_objmgr_pdev *pdev, 188 bool *is_etsi_precac_done); 189 #else 190 static inline QDF_STATUS utils_dfs_is_etsi_precac_done( 191 struct wlan_objmgr_pdev *pdev, 192 bool *is_etsi_precac_done) 193 { 194 return QDF_STATUS_SUCCESS; 195 } 196 #endif 197 198 /** 199 * utils_dfs_cancel_cac_timer() - Cancels the CAC timer. 200 * @pdev: Pointer to DFS pdev object. 201 * 202 * wrapper function for dfs_cancel_cac_timer(). this 203 * function called from outside of dfs component. 204 */ 205 QDF_STATUS utils_dfs_cancel_cac_timer(struct wlan_objmgr_pdev *pdev); 206 207 /** 208 * utils_dfs_start_cac_timer() - Starts the CAC timer. 209 * @pdev: Pointer to DFS pdev object. 210 * 211 * wrapper function for dfs_start_cac_timer(). this 212 * function called from outside of dfs component. 213 */ 214 QDF_STATUS utils_dfs_start_cac_timer(struct wlan_objmgr_pdev *pdev); 215 216 /** 217 * utils_dfs_cac_stop() - Clear the AP CAC timer. 218 * @pdev: Pointer to DFS pdev object. 219 * 220 * wrapper function for dfs_cac_stop(). this 221 * function called from outside of dfs component. 222 */ 223 QDF_STATUS utils_dfs_cac_stop(struct wlan_objmgr_pdev *pdev); 224 225 /** 226 * utils_dfs_stacac_stop() - Clear the STA CAC timer. 227 * @pdev: Pointer to DFS pdev object. 228 * 229 * wrapper function for dfs_stacac_stop(). this 230 * function called from outside of dfs component. 231 */ 232 QDF_STATUS utils_dfs_stacac_stop(struct wlan_objmgr_pdev *pdev); 233 234 /** 235 * utils_dfs_get_usenol() - Returns use_nol flag. 236 * @pdev: Pointer to DFS pdev object. 237 * @usenol: Pointer to usenol value. 238 * 239 * wrapper function for dfs_get_usenol(). this 240 * function called from outside of dfs component. 241 */ 242 QDF_STATUS utils_dfs_get_usenol(struct wlan_objmgr_pdev *pdev, 243 uint16_t *usenol); 244 245 /** 246 * utils_dfs_radar_disable() - Disables the radar. 247 * @pdev: Pointer to DFS pdev object. 248 * 249 * wrapper function for dfs_radar_disable(). this 250 * function called from outside of dfs component. 251 */ 252 QDF_STATUS utils_dfs_radar_disable(struct wlan_objmgr_pdev *pdev); 253 254 /** 255 * utils_dfs_set_update_nol_flag() - Sets update_nol flag. 256 * @pdev: Pointer to DFS pdev object. 257 * @val: update_nol flag. 258 * 259 * wrapper function for dfs_set_update_nol_flag(). this 260 * function called from outside of dfs component. 261 */ 262 QDF_STATUS utils_dfs_set_update_nol_flag(struct wlan_objmgr_pdev *pdev, 263 bool val); 264 265 /** 266 * utils_dfs_get_update_nol_flag() - Returns update_nol flag. 267 * @pdev: Pointer to DFS pdev object. 268 * @nol_flag: Fill nol_flag in this variable. 269 * 270 * wrapper function for dfs_get_update_nol_flag(). this 271 * function called from outside of dfs component. 272 */ 273 QDF_STATUS utils_dfs_get_update_nol_flag(struct wlan_objmgr_pdev *pdev, 274 bool *nol_flag); 275 276 /** 277 * utils_dfs_get_dfs_use_nol() - Get usenol. 278 * @pdev: Pointer to DFS pdev object. 279 * @dfs_use_nol: Pointer to dfs_use_nol. 280 * 281 * wrapper function for dfs_get_dfs_use_nol(). this 282 * function called from outside of dfs component. 283 */ 284 QDF_STATUS utils_dfs_get_dfs_use_nol(struct wlan_objmgr_pdev *pdev, 285 int *dfs_use_nol); 286 287 /** 288 * utils_dfs_get_nol_timeout() - Get NOL timeout. 289 * @pdev: Pointer to DFS pdev object. 290 * @dfs_nol_timeout: Pointer to dfs_nol_timeout. 291 * 292 * wrapper function for dfs_get_nol_timeout(). this 293 * function called from outside of dfs component. 294 */ 295 QDF_STATUS utils_dfs_get_nol_timeout(struct wlan_objmgr_pdev *pdev, 296 int *dfs_nol_timeout); 297 298 /** 299 * utils_dfs_nol_addchan() - Add channel to NOL. 300 * @pdev: Pointer to DFS pdev object. 301 * @chan: channel t o add NOL. 302 * @dfs_nol_timeout: NOL timeout. 303 * 304 * wrapper function for dfs_nol_addchan(). this 305 * function called from outside of dfs component. 306 */ 307 QDF_STATUS utils_dfs_nol_addchan(struct wlan_objmgr_pdev *pdev, 308 uint16_t freq, 309 uint32_t dfs_nol_timeout); 310 311 /** 312 * utils_dfs_nol_update() - NOL update 313 * @pdev: Pointer to DFS pdev object. 314 * 315 * wrapper function for dfs_nol_update(). this 316 * function called from outside of dfs component. 317 */ 318 QDF_STATUS utils_dfs_nol_update(struct wlan_objmgr_pdev *pdev); 319 320 /** 321 * utils_dfs_second_segment_radar_disable() - Disables the second segment radar. 322 * @pdev: Pointer to DFS pdev object. 323 * 324 * This is called when AP detects the radar, to (potentially) disable 325 * the radar code. 326 */ 327 QDF_STATUS utils_dfs_second_segment_radar_disable( 328 struct wlan_objmgr_pdev *pdev); 329 330 /** 331 * utils_dfs_is_ignore_dfs() - Get Ignore DFS value. 332 * @pdev: Pointer to DFS pdev object. 333 * @ignore_dfs: Fill ignore_dfs value in this variable. 334 */ 335 QDF_STATUS utils_dfs_is_ignore_dfs(struct wlan_objmgr_pdev *pdev, 336 bool *ignore_dfs); 337 338 /** 339 * utils_dfs_is_cac_valid() - Gets the value of is_cac_valid. 340 * @pdev: Pointer to DFS pdev object. 341 * @is_cac_valid: Fill is_cac_valid in this variable. 342 */ 343 QDF_STATUS utils_dfs_is_cac_valid(struct wlan_objmgr_pdev *pdev, 344 bool *is_cac_valid); 345 346 /** 347 * utils_dfs_is_ignore_cac() - Gets the value of is_ignore_cac. 348 * @pdev: Pointer to DFS pdev object. 349 * @ignore_cac: Fill ignore_cac value in this variable. 350 */ 351 QDF_STATUS utils_dfs_is_ignore_cac(struct wlan_objmgr_pdev *pdev, 352 bool *ignore_cac); 353 354 /** 355 * utils_dfs_set_cac_timer_running() - Sets the cac timer running. 356 * @pdev: Pointer to DFS pdev object. 357 * @val: Set this value to dfs_cac_timer_running variable. 358 */ 359 QDF_STATUS utils_dfs_set_cac_timer_running(struct wlan_objmgr_pdev *pdev, 360 int val); 361 362 /** 363 * utils_dfs_get_nol_chfreq_and_chwidth() - Sets the cac timer running. 364 * @pdev: Pointer to DFS pdev object. 365 * @nollist: Pointer to NOL channel entry. 366 * @nol_chfreq: Pointer to save channel frequency. 367 * @nol_chwidth: Pointer to save channel width. 368 * @index: Index into nol list. 369 */ 370 QDF_STATUS utils_dfs_get_nol_chfreq_and_chwidth(struct wlan_objmgr_pdev *pdev, 371 void *nollist, 372 uint32_t *nol_chfreq, 373 uint32_t *nol_chwidth, 374 int index); 375 376 /** 377 * utils_dfs_get_random_channel() - Get random channel. 378 * @pdev: Pointer to DFS pdev object. 379 * @flags: random channel selection flags. 380 * @ch_params: current channel params. 381 * @hw_mode: current operating mode. 382 * @target_chan: Pointer to target_chan. 383 * @acs_info: acs range info. 384 * 385 * wrapper function for get_random_chan(). this 386 * function called from outside of dfs component. 387 * 388 * Return: QDF_STATUS 389 */ 390 QDF_STATUS utils_dfs_get_random_channel(struct wlan_objmgr_pdev *pdev, 391 uint16_t flags, struct ch_params *ch_params, 392 uint32_t *hw_mode, uint8_t *target_chan, 393 struct dfs_acs_info *acs_info); 394 395 /** 396 * utils_dfs_init_nol() - Initialize nol from platform driver. 397 * @pdev: pdev handler. 398 * 399 * Initialize nol from platform driver. 400 * 401 * Return: None 402 */ 403 #ifdef QCA_DFS_NOL_PLATFORM_DRV_SUPPORT 404 void utils_dfs_init_nol(struct wlan_objmgr_pdev *pdev); 405 #else 406 static inline void utils_dfs_init_nol(struct wlan_objmgr_pdev *pdev) 407 { 408 } 409 #endif 410 /** 411 * utils_dfs_save_nol() - save nol list to platform driver. 412 * @pdev: pdev handler. 413 * 414 * Save nol list to platform driver. 415 * 416 * Return: None 417 */ 418 void utils_dfs_save_nol(struct wlan_objmgr_pdev *pdev); 419 420 /** 421 * utils_dfs_print_nol_channels() - log nol channels. 422 * @pdev: pdev handler. 423 * 424 * log nol channels. 425 * 426 * Return: None 427 */ 428 #ifdef DFS_COMPONENT_ENABLE 429 void utils_dfs_print_nol_channels(struct wlan_objmgr_pdev *pdev); 430 #else 431 static inline void utils_dfs_print_nol_channels(struct wlan_objmgr_pdev *pdev) 432 { 433 } 434 #endif 435 436 /** 437 * utils_dfs_clear_nol_channels() - clear nol list. 438 * @pdev: pdev handler. 439 * 440 * log nol channels. 441 * 442 * Return: None 443 */ 444 void utils_dfs_clear_nol_channels(struct wlan_objmgr_pdev *pdev); 445 446 /** 447 * utils_is_dfs_ch() - is channel dfs. 448 * @pdev: pdev handler. 449 * 450 * is channel dfs. 451 * 452 * Return: True if channel dfs, else false. 453 */ 454 static inline bool utils_is_dfs_ch(struct wlan_objmgr_pdev *pdev, uint32_t chan) 455 { 456 return wlan_reg_is_dfs_ch(pdev, chan); 457 } 458 /** 459 * utils_dfs_reg_update_nol_ch() - set nol channel 460 * 461 * @pdev: pdev ptr 462 * @ch_list: channel list to be returned 463 * @num_ch: number of channels 464 * @nol_ch: nol flag 465 * 466 * Return: void 467 */ 468 void utils_dfs_reg_update_nol_ch(struct wlan_objmgr_pdev *pdev, 469 uint8_t *ch_list, 470 uint8_t num_ch, 471 bool nol_ch); 472 473 /** 474 * utils_dfs_freq_to_chan () - convert channel freq to channel number 475 * @freq: frequency 476 * 477 * Return: channel number 478 */ 479 uint8_t utils_dfs_freq_to_chan(uint32_t freq); 480 481 /** 482 * utils_dfs_chan_to_freq () - convert channel number to frequency 483 * @chan: channel number 484 * 485 * Return: frequency 486 */ 487 #ifdef DFS_COMPONENT_ENABLE 488 uint32_t utils_dfs_chan_to_freq(uint8_t chan); 489 #else 490 static inline uint32_t utils_dfs_chan_to_freq(uint8_t chan) 491 { 492 return 0; 493 } 494 #endif 495 /** 496 * utils_dfs_update_cur_chan_flags() - Update DFS channel flag and flagext. 497 * @pdev: Pointer to DFS pdev object. 498 * @flags: New channel flags 499 * @flagext: New Extended flags 500 * 501 * Return: QDF_STATUS 502 */ 503 QDF_STATUS utils_dfs_update_cur_chan_flags(struct wlan_objmgr_pdev *pdev, 504 uint64_t flags, 505 uint16_t flagext); 506 507 #ifdef QCA_MCL_DFS_SUPPORT 508 /** 509 * utils_dfs_mark_leaking_ch() - to mark channel leaking in to nol 510 * @pdev: Pointer to pdev structure. 511 * @ch_width: channel width 512 * @temp_ch_lst_sz: the target channel list 513 * @temp_ch_lst: the target channel list 514 * 515 * This function removes the channels from temp channel list that 516 * (if selected as target channel) will cause leakage in one of 517 * the NOL channels 518 * 519 * Return: QDF_STATUS 520 */ 521 QDF_STATUS utils_dfs_mark_leaking_ch(struct wlan_objmgr_pdev *pdev, 522 enum phy_ch_width ch_width, 523 uint8_t temp_ch_lst_sz, 524 uint8_t *temp_ch_lst); 525 #else 526 static inline QDF_STATUS utils_dfs_mark_leaking_ch 527 (struct wlan_objmgr_pdev *pdev, 528 enum phy_ch_width ch_width, 529 uint8_t temp_ch_lst_sz, 530 uint8_t *temp_ch_lst) 531 { 532 return QDF_STATUS_SUCCESS; 533 } 534 #endif 535 /** 536 * utils_get_dfsdomain() - Get DFS domain. 537 * @pdev: Pointer to PDEV structure. 538 * 539 * Return: DFS domain. 540 */ 541 int utils_get_dfsdomain(struct wlan_objmgr_pdev *pdev); 542 543 /** 544 * utils_dfs_get_cur_rd() - Get current regdomain. 545 * @pdev: pdev ptr 546 * 547 * Return: Regdomain pair id. 548 */ 549 uint16_t utils_dfs_get_cur_rd(struct wlan_objmgr_pdev *pdev); 550 551 /** 552 * utils_dfs_is_spoof_check_failed() - get spoof check status. 553 * @pdev: pdev ptr 554 * @is_spoof_check_failed: pointer containing the status. 555 * 556 * Return: QDF_STATUS. 557 */ 558 #if defined(WLAN_DFS_PARTIAL_OFFLOAD) && defined(HOST_DFS_SPOOF_TEST) 559 QDF_STATUS utils_dfs_is_spoof_check_failed(struct wlan_objmgr_pdev *pdev, 560 bool *is_spoof_check_failed); 561 #else 562 static inline 563 QDF_STATUS utils_dfs_is_spoof_check_failed(struct wlan_objmgr_pdev *pdev, 564 bool *is_spoof_check_failed) 565 { 566 return QDF_STATUS_SUCCESS; 567 } 568 #endif 569 #endif /* _WLAN_DFS_UTILS_API_H_ */ 570