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_freq_is_in_nol() - check if given channel in nol list 102 * @pdev: Pointer to DFS pdev object 103 * @freq: channel frequency 104 * 105 * check if given channel in nol list. 106 * 107 * Return: true if channel in nol, false else 108 */ 109 bool utils_dfs_freq_is_in_nol(struct wlan_objmgr_pdev *pdev, uint32_t freq); 110 111 /** 112 * utils_dfs_reset_precaclists() - Clears and initiakizes precac_required_list, 113 * precac_done_list and precac_nol_list. 114 * @pdev: Pointer to DFS pdev object. 115 * 116 * Wrapper function for dfs_reset_precaclists(). This function called from 117 * outside of DFS component. 118 */ 119 QDF_STATUS utils_dfs_reset_precaclists(struct wlan_objmgr_pdev *pdev); 120 121 /** 122 * utils_dfs_reset_etsi_precaclists() - Clears and initializes etsi 123 * precac_required_list, 124 * etsi precac_done_list and 125 * etsi precac_nol_list. 126 * @pdev: Pointer to DFS pdev object. 127 * 128 * Wrapper function for dfs_reset_etsiprecaclists(). This function called from 129 * outside of DFS component. 130 */ 131 #ifdef QCA_SUPPORT_ETSI_PRECAC_DFS 132 QDF_STATUS utils_dfs_reset_etsi_precaclists(struct wlan_objmgr_pdev *pdev); 133 #else 134 static inline QDF_STATUS utils_dfs_reset_etsi_precaclists( 135 struct wlan_objmgr_pdev *pdev) 136 { 137 return QDF_STATUS_SUCCESS; 138 } 139 #endif 140 141 /** 142 * utils_dfs_cancel_precac_timer() - Cancel the precac timer. 143 * @pdev: Pointer to DFS pdev object. 144 * 145 * wrapper function for dfs_cancel_precac_timer(). this function called from 146 * outside of dfs component. 147 */ 148 QDF_STATUS utils_dfs_cancel_precac_timer(struct wlan_objmgr_pdev *pdev); 149 150 /** 151 * utils_dfs_start_precac_timer() - Start the precac timer. 152 * @pdev: Pointer to DFS pdev object. 153 * 154 * Wrapper function for dfs_start_precac_timer(). This function called from 155 * outside of dfs component. 156 * 157 * Return: 158 * * QDF_STATUS_E_FAILURE: Failed to start timer. 159 * * QDF_STATUS_SUCCESS: Timer started successfully. 160 */ 161 QDF_STATUS utils_dfs_start_precac_timer(struct wlan_objmgr_pdev *pdev); 162 163 #ifdef WLAN_DFS_PRECAC_AUTO_CHAN_SUPPORT 164 /** 165 * utils_dfs_precac_decide_pref_chan() - Choose preferred channel 166 * @pdev: Pointer to DFS pdev object. 167 * @ch_ieee: Pointer to channel number 168 169 * Wrapper function for dfs_decide_precac_preferred_chan(). This 170 * function called from outside of dfs component. 171 * 172 * Return: 173 * * QDF_STATUS_E_FAILURE: Failed to decide preferred channel. 174 * * QDF_STATUS_SUCCESS: Set preferred channel successfully. 175 */ 176 QDF_STATUS utils_dfs_precac_decide_pref_chan(struct wlan_objmgr_pdev *pdev, 177 uint8_t *ch_ieee); 178 #endif 179 180 /** 181 * utils_dfs_cancel_cac_timer() - Cancels the CAC timer. 182 * @pdev: Pointer to DFS pdev object. 183 * 184 * wrapper function for dfs_cancel_cac_timer(). this 185 * function called from outside of dfs component. 186 */ 187 QDF_STATUS utils_dfs_cancel_cac_timer(struct wlan_objmgr_pdev *pdev); 188 189 /** 190 * utils_dfs_start_cac_timer() - Starts the CAC timer. 191 * @pdev: Pointer to DFS pdev object. 192 * 193 * wrapper function for dfs_start_cac_timer(). this 194 * function called from outside of dfs component. 195 */ 196 QDF_STATUS utils_dfs_start_cac_timer(struct wlan_objmgr_pdev *pdev); 197 198 /** 199 * utils_dfs_cac_stop() - Clear the AP CAC timer. 200 * @pdev: Pointer to DFS pdev object. 201 * 202 * wrapper function for dfs_cac_stop(). this 203 * function called from outside of dfs component. 204 */ 205 QDF_STATUS utils_dfs_cac_stop(struct wlan_objmgr_pdev *pdev); 206 207 /** 208 * utils_dfs_stacac_stop() - Clear the STA CAC timer. 209 * @pdev: Pointer to DFS pdev object. 210 * 211 * wrapper function for dfs_stacac_stop(). this 212 * function called from outside of dfs component. 213 */ 214 QDF_STATUS utils_dfs_stacac_stop(struct wlan_objmgr_pdev *pdev); 215 216 /** 217 * utils_dfs_get_usenol() - Returns use_nol flag. 218 * @pdev: Pointer to DFS pdev object. 219 * @usenol: Pointer to usenol value. 220 * 221 * wrapper function for dfs_get_usenol(). this 222 * function called from outside of dfs component. 223 */ 224 QDF_STATUS utils_dfs_get_usenol(struct wlan_objmgr_pdev *pdev, 225 uint16_t *usenol); 226 227 /** 228 * utils_dfs_radar_disable() - Disables the radar. 229 * @pdev: Pointer to DFS pdev object. 230 * 231 * wrapper function for dfs_radar_disable(). this 232 * function called from outside of dfs component. 233 */ 234 QDF_STATUS utils_dfs_radar_disable(struct wlan_objmgr_pdev *pdev); 235 236 /** 237 * utils_dfs_set_update_nol_flag() - Sets update_nol flag. 238 * @pdev: Pointer to DFS pdev object. 239 * @val: update_nol flag. 240 * 241 * wrapper function for dfs_set_update_nol_flag(). this 242 * function called from outside of dfs component. 243 */ 244 QDF_STATUS utils_dfs_set_update_nol_flag(struct wlan_objmgr_pdev *pdev, 245 bool val); 246 247 /** 248 * utils_dfs_get_update_nol_flag() - Returns update_nol flag. 249 * @pdev: Pointer to DFS pdev object. 250 * @nol_flag: Fill nol_flag in this variable. 251 * 252 * wrapper function for dfs_get_update_nol_flag(). this 253 * function called from outside of dfs component. 254 */ 255 QDF_STATUS utils_dfs_get_update_nol_flag(struct wlan_objmgr_pdev *pdev, 256 bool *nol_flag); 257 258 /** 259 * utils_dfs_get_dfs_use_nol() - Get usenol. 260 * @pdev: Pointer to DFS pdev object. 261 * @dfs_use_nol: Pointer to dfs_use_nol. 262 * 263 * wrapper function for dfs_get_dfs_use_nol(). this 264 * function called from outside of dfs component. 265 */ 266 QDF_STATUS utils_dfs_get_dfs_use_nol(struct wlan_objmgr_pdev *pdev, 267 int *dfs_use_nol); 268 269 /** 270 * utils_dfs_get_nol_timeout() - Get NOL timeout. 271 * @pdev: Pointer to DFS pdev object. 272 * @dfs_nol_timeout: Pointer to dfs_nol_timeout. 273 * 274 * wrapper function for dfs_get_nol_timeout(). this 275 * function called from outside of dfs component. 276 */ 277 QDF_STATUS utils_dfs_get_nol_timeout(struct wlan_objmgr_pdev *pdev, 278 int *dfs_nol_timeout); 279 280 /** 281 * utils_dfs_nol_addchan() - Add channel to NOL. 282 * @pdev: Pointer to DFS pdev object. 283 * @chan: channel t o add NOL. 284 * @dfs_nol_timeout: NOL timeout. 285 * 286 * wrapper function for dfs_nol_addchan(). this 287 * function called from outside of dfs component. 288 */ 289 QDF_STATUS utils_dfs_nol_addchan(struct wlan_objmgr_pdev *pdev, 290 uint16_t freq, 291 uint32_t dfs_nol_timeout); 292 293 /** 294 * utils_dfs_nol_update() - NOL update 295 * @pdev: Pointer to DFS pdev object. 296 * 297 * wrapper function for dfs_nol_update(). this 298 * function called from outside of dfs component. 299 */ 300 QDF_STATUS utils_dfs_nol_update(struct wlan_objmgr_pdev *pdev); 301 302 /** 303 * utils_dfs_second_segment_radar_disable() - Disables the second segment radar. 304 * @pdev: Pointer to DFS pdev object. 305 * 306 * This is called when AP detects the radar, to (potentially) disable 307 * the radar code. 308 */ 309 QDF_STATUS utils_dfs_second_segment_radar_disable( 310 struct wlan_objmgr_pdev *pdev); 311 312 /** 313 * utils_dfs_set_cac_timer_running() - Sets the cac timer running. 314 * @pdev: Pointer to DFS pdev object. 315 * @val: Set this value to dfs_cac_timer_running variable. 316 */ 317 QDF_STATUS utils_dfs_set_cac_timer_running(struct wlan_objmgr_pdev *pdev, 318 int val); 319 320 /** 321 * utils_dfs_get_nol_chfreq_and_chwidth() - Sets the cac timer running. 322 * @pdev: Pointer to DFS pdev object. 323 * @nollist: Pointer to NOL channel entry. 324 * @nol_chfreq: Pointer to save channel frequency. 325 * @nol_chwidth: Pointer to save channel width. 326 * @index: Index into nol list. 327 */ 328 QDF_STATUS utils_dfs_get_nol_chfreq_and_chwidth(struct wlan_objmgr_pdev *pdev, 329 void *nollist, 330 uint32_t *nol_chfreq, 331 uint32_t *nol_chwidth, 332 int index); 333 334 /** 335 * utils_dfs_get_random_channel() - Get random channel. 336 * @pdev: Pointer to DFS pdev object. 337 * @flags: random channel selection flags. 338 * @ch_params: current channel params. 339 * @hw_mode: current operating mode. 340 * @target_chan: Pointer to target_chan. 341 * @acs_info: acs range info. 342 * 343 * wrapper function for get_random_chan(). this 344 * function called from outside of dfs component. 345 * 346 * Return: QDF_STATUS 347 */ 348 QDF_STATUS utils_dfs_get_random_channel(struct wlan_objmgr_pdev *pdev, 349 uint16_t flags, struct ch_params *ch_params, 350 uint32_t *hw_mode, uint8_t *target_chan, 351 struct dfs_acs_info *acs_info); 352 353 /** 354 * utils_dfs_bw_reduced_channel() - Get BW reduced channel. 355 * @pdev: Pointer to DFS pdev object. 356 * @flags: Reduced bandwidth channel flags. 357 * @ch_params: current channel params. 358 * @hw_mode: current operating mode. 359 * @target_chan: Pointer to target_chan. 360 * 361 * wrapper function for get bw_reduced_channel. this 362 * function called from outside of dfs component. 363 * 364 * Return: QDF_STATUS 365 */ 366 QDF_STATUS utils_dfs_bw_reduced_channel(struct wlan_objmgr_pdev *pdev, 367 uint16_t flags, 368 struct ch_params *ch_params, 369 uint32_t *hw_mode, 370 uint8_t *target_chan); 371 /** 372 * utils_dfs_init_nol() - Initialize nol from platform driver. 373 * @pdev: pdev handler. 374 * 375 * Initialize nol from platform driver. 376 * 377 * Return: None 378 */ 379 #ifdef QCA_DFS_NOL_PLATFORM_DRV_SUPPORT 380 void utils_dfs_init_nol(struct wlan_objmgr_pdev *pdev); 381 #else 382 static inline void utils_dfs_init_nol(struct wlan_objmgr_pdev *pdev) 383 { 384 } 385 #endif 386 /** 387 * utils_dfs_save_nol() - save nol list to platform driver. 388 * @pdev: pdev handler. 389 * 390 * Save nol list to platform driver. 391 * 392 * Return: None 393 */ 394 void utils_dfs_save_nol(struct wlan_objmgr_pdev *pdev); 395 396 /** 397 * utils_dfs_print_nol_channels() - log nol channels. 398 * @pdev: pdev handler. 399 * 400 * log nol channels. 401 * 402 * Return: None 403 */ 404 #ifdef DFS_COMPONENT_ENABLE 405 void utils_dfs_print_nol_channels(struct wlan_objmgr_pdev *pdev); 406 #else 407 static inline void utils_dfs_print_nol_channels(struct wlan_objmgr_pdev *pdev) 408 { 409 } 410 #endif 411 412 /** 413 * utils_dfs_clear_nol_channels() - clear nol list. 414 * @pdev: pdev handler. 415 * 416 * log nol channels. 417 * 418 * Return: None 419 */ 420 void utils_dfs_clear_nol_channels(struct wlan_objmgr_pdev *pdev); 421 422 /** 423 * utils_is_dfs_ch() - is channel dfs. 424 * @pdev: pdev handler. 425 * 426 * is channel dfs. 427 * 428 * Return: True if channel dfs, else false. 429 */ 430 static inline bool utils_is_dfs_ch(struct wlan_objmgr_pdev *pdev, uint32_t chan) 431 { 432 return wlan_reg_is_dfs_ch(pdev, chan); 433 } 434 /** 435 * utils_dfs_reg_update_nol_ch() - set nol channel 436 * 437 * @pdev: pdev ptr 438 * @ch_list: channel list to be returned 439 * @num_ch: number of channels 440 * @nol_ch: nol flag 441 * 442 * Return: void 443 */ 444 void utils_dfs_reg_update_nol_ch(struct wlan_objmgr_pdev *pdev, 445 uint8_t *ch_list, 446 uint8_t num_ch, 447 bool nol_ch); 448 449 /** 450 * utils_dfs_freq_to_chan () - convert channel freq to channel number 451 * @freq: frequency 452 * 453 * Return: channel number 454 */ 455 uint8_t utils_dfs_freq_to_chan(uint32_t freq); 456 457 /** 458 * utils_dfs_chan_to_freq () - convert channel number to frequency 459 * @chan: channel number 460 * 461 * Return: frequency 462 */ 463 #ifdef DFS_COMPONENT_ENABLE 464 uint32_t utils_dfs_chan_to_freq(uint8_t chan); 465 #else 466 static inline uint32_t utils_dfs_chan_to_freq(uint8_t chan) 467 { 468 return 0; 469 } 470 #endif 471 /** 472 * utils_dfs_update_cur_chan_flags() - Update DFS channel flag and flagext. 473 * @pdev: Pointer to DFS pdev object. 474 * @flags: New channel flags 475 * @flagext: New Extended flags 476 * 477 * Return: QDF_STATUS 478 */ 479 QDF_STATUS utils_dfs_update_cur_chan_flags(struct wlan_objmgr_pdev *pdev, 480 uint64_t flags, 481 uint16_t flagext); 482 483 #ifdef QCA_MCL_DFS_SUPPORT 484 /** 485 * utils_dfs_mark_leaking_ch() - to mark channel leaking in to nol 486 * @pdev: Pointer to pdev structure. 487 * @ch_width: channel width 488 * @temp_ch_lst_sz: the target channel list 489 * @temp_ch_lst: the target channel list 490 * 491 * This function removes the channels from temp channel list that 492 * (if selected as target channel) will cause leakage in one of 493 * the NOL channels 494 * 495 * Return: QDF_STATUS 496 */ 497 QDF_STATUS utils_dfs_mark_leaking_ch(struct wlan_objmgr_pdev *pdev, 498 enum phy_ch_width ch_width, 499 uint8_t temp_ch_lst_sz, 500 uint8_t *temp_ch_lst); 501 #else 502 static inline QDF_STATUS utils_dfs_mark_leaking_ch 503 (struct wlan_objmgr_pdev *pdev, 504 enum phy_ch_width ch_width, 505 uint8_t temp_ch_lst_sz, 506 uint8_t *temp_ch_lst) 507 { 508 return QDF_STATUS_SUCCESS; 509 } 510 #endif 511 /** 512 * utils_get_dfsdomain() - Get DFS domain. 513 * @pdev: Pointer to PDEV structure. 514 * 515 * Return: DFS domain. 516 */ 517 int utils_get_dfsdomain(struct wlan_objmgr_pdev *pdev); 518 519 /** 520 * utils_dfs_get_cur_rd() - Get current regdomain. 521 * @pdev: pdev ptr 522 * 523 * Return: Regdomain pair id. 524 */ 525 uint16_t utils_dfs_get_cur_rd(struct wlan_objmgr_pdev *pdev); 526 527 /** 528 * utils_dfs_is_spoof_check_failed() - get spoof check status. 529 * @pdev: pdev ptr 530 * @is_spoof_check_failed: pointer containing the status. 531 * 532 * Return: QDF_STATUS. 533 */ 534 #if defined(WLAN_DFS_PARTIAL_OFFLOAD) && defined(HOST_DFS_SPOOF_TEST) 535 QDF_STATUS utils_dfs_is_spoof_check_failed(struct wlan_objmgr_pdev *pdev, 536 bool *is_spoof_check_failed); 537 #else 538 static inline 539 QDF_STATUS utils_dfs_is_spoof_check_failed(struct wlan_objmgr_pdev *pdev, 540 bool *is_spoof_check_failed) 541 { 542 return QDF_STATUS_SUCCESS; 543 } 544 #endif 545 546 /** 547 * dfs_get_num_chans() - Get the number of channels supported by the regulatory. 548 * 549 * Return: Number of supported channels. 550 */ 551 int dfs_get_num_chans(void); 552 553 /** 554 * utils_dfs_get_chan_list() - Get channel list from regdb. 555 * @pdev: Pointer to DFS pdev object. 556 * @clist: Pointer to current channel list 557 * @num_chan: number of channels in the current channel list. 558 */ 559 void utils_dfs_get_chan_list(struct wlan_objmgr_pdev *pdev, 560 void *clist, 561 uint32_t *num_chan); 562 563 /** 564 * utils_dfs_check_for_cac_start() - Check for DFS CAC start conditions. 565 * @pdev: pdev ptr 566 * @continue_current_cac: If AP can start CAC then this variable indicates 567 * whether to continue with the current CAC or restart the CAC. This variable 568 * is valid only if this function returns true. 569 * 570 * Return: true if AP can start or continue the current CAC, else false. 571 */ 572 bool utils_dfs_check_for_cac_start(struct wlan_objmgr_pdev *pdev, 573 bool *continue_current_cac); 574 #endif /* _WLAN_DFS_UTILS_API_H_ */ 575