1 /* 2 * Copyright (c) 2017-2019 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: reg_services.h 22 * This file provides prototypes of the regulatory component 23 * service functions 24 */ 25 26 #ifndef __REG_SERVICES_COMMON_H_ 27 #define __REG_SERVICES_COMMON_H_ 28 29 #define IS_VALID_PSOC_REG_OBJ(psoc_priv_obj) (psoc_priv_obj) 30 #define IS_VALID_PDEV_REG_OBJ(pdev_priv_obj) (pdev_priv_obj) 31 #define FREQ_TO_CHAN_SCALE 5 32 /* The distance between the 80Mhz center and the nearest 20Mhz channel */ 33 #define NEAREST_20MHZ_CHAN_FREQ_OFFSET 10 34 35 #ifdef CONFIG_CHAN_NUM_API 36 #define REG_MIN_24GHZ_CH_NUM channel_map[MIN_24GHZ_CHANNEL].chan_num 37 #define REG_MAX_24GHZ_CH_NUM channel_map[MAX_24GHZ_CHANNEL].chan_num 38 #define REG_MIN_5GHZ_CH_NUM channel_map[MIN_5GHZ_CHANNEL].chan_num 39 #define REG_MAX_5GHZ_CH_NUM channel_map[MAX_5GHZ_CHANNEL].chan_num 40 41 #define REG_IS_24GHZ_CH(chan_num) \ 42 (((chan_num) >= REG_MIN_24GHZ_CH_NUM) && \ 43 ((chan_num) <= REG_MAX_24GHZ_CH_NUM)) 44 #endif /* CONFIG_CHAN_NUM_API */ 45 46 #define REG_MIN_24GHZ_CH_FREQ channel_map[MIN_24GHZ_CHANNEL].center_freq 47 #define REG_MAX_24GHZ_CH_FREQ channel_map[MAX_24GHZ_CHANNEL].center_freq 48 49 #define REG_IS_24GHZ_CH_FREQ(freq) \ 50 (((freq) >= REG_MIN_24GHZ_CH_FREQ) && \ 51 ((freq) <= REG_MAX_24GHZ_CH_FREQ)) 52 53 #ifdef CONFIG_CHAN_FREQ_API 54 #define REG_MIN_5GHZ_CH_FREQ channel_map[MIN_5GHZ_CHANNEL].center_freq 55 #define REG_MAX_5GHZ_CH_FREQ channel_map[MAX_5GHZ_CHANNEL].center_freq 56 #endif /* CONFIG_CHAN_FREQ_API */ 57 58 #define REG_MIN_49GHZ_CH_FREQ channel_map[MIN_49GHZ_CHANNEL].center_freq 59 #define REG_MAX_49GHZ_CH_FREQ channel_map[MAX_49GHZ_CHANNEL].center_freq 60 61 #define REG_IS_49GHZ_FREQ(freq) \ 62 (((freq) >= REG_MIN_49GHZ_CH_FREQ) && \ 63 ((freq) <= REG_MAX_49GHZ_CH_FREQ)) 64 65 #ifdef CONFIG_CHAN_NUM_API 66 #define REG_IS_5GHZ_CH(chan_num) \ 67 (((chan_num) >= REG_MIN_5GHZ_CH_NUM) && \ 68 ((chan_num) <= REG_MAX_5GHZ_CH_NUM)) 69 #endif /* CONFIG_CHAN_NUM_API */ 70 71 #define REG_IS_5GHZ_FREQ(freq) \ 72 (((freq) >= channel_map[MIN_5GHZ_CHANNEL].center_freq) && \ 73 ((freq) <= channel_map[MAX_5GHZ_CHANNEL].center_freq)) 74 75 #ifdef CONFIG_BAND_6GHZ 76 #define FREQ_LEFT_SHIFT 55 77 #define SIXG_STARTING_FREQ 5940 78 #define NUM_80MHZ_BAND_IN_6G 16 79 #define NUM_PSC_FREQ 15 80 #define PSC_BAND_MHZ (FREQ_TO_CHAN_SCALE * NUM_80MHZ_BAND_IN_6G) 81 #define REG_MIN_6GHZ_CHAN_FREQ channel_map[MIN_6GHZ_CHANNEL].center_freq 82 #define REG_MAX_6GHZ_CHAN_FREQ channel_map[MAX_6GHZ_CHANNEL].center_freq 83 #else 84 #define FREQ_LEFT_SHIFT 0 85 #define SIXG_STARTING_FREQ 0 86 #define NUM_80MHZ_BAND_IN_6G 0 87 #define NUM_PSC_FREQ 0 88 #define PSC_BAND_MHZ (FREQ_TO_CHAN_SCALE * NUM_80MHZ_BAND_IN_6G) 89 #define REG_MIN_6GHZ_CHAN_FREQ 0 90 #define REG_MAX_6GHZ_CHAN_FREQ 0 91 #endif /*CONFIG_BAND_6GHZ*/ 92 93 #define REG_CH_NUM(ch_enum) channel_map[ch_enum].chan_num 94 #define REG_CH_TO_FREQ(ch_enum) channel_map[ch_enum].center_freq 95 96 /* EEPROM setting is a country code */ 97 #define COUNTRY_ERD_FLAG 0x8000 98 #define MIN_6GHZ_OPER_CLASS 131 99 #define MAX_6GHZ_OPER_CLASS 135 100 101 extern const struct chan_map *channel_map; 102 extern const struct chan_map channel_map_us[]; 103 extern const struct chan_map channel_map_eu[]; 104 extern const struct chan_map channel_map_jp[]; 105 extern const struct chan_map channel_map_china[]; 106 extern const struct chan_map channel_map_global[]; 107 108 #ifdef CONFIG_CHAN_NUM_API 109 /** 110 * reg_get_chan_enum() - Get channel enum for given channel number 111 * @chan_num: Channel number 112 * 113 * Return: Channel enum 114 */ 115 enum channel_enum reg_get_chan_enum(uint8_t chan_num); 116 117 /** 118 * reg_get_channel_list_with_power() - Provides the channel list with power 119 * @pdev: Pointer to pdev 120 * @ch_list: Pointer to the channel list. 121 * @num_chan: Pointer to save number of channels 122 * 123 * Return: QDF_STATUS 124 */ 125 QDF_STATUS reg_get_channel_list_with_power(struct wlan_objmgr_pdev *pdev, 126 struct channel_power *ch_list, 127 uint8_t *num_chan); 128 129 /** 130 * reg_get_channel_state() - Get channel state from regulatory 131 * @pdev: Pointer to pdev 132 * @ch: channel number. 133 * 134 * Return: channel state 135 */ 136 enum channel_state reg_get_channel_state(struct wlan_objmgr_pdev *pdev, 137 uint8_t ch); 138 139 /** 140 * reg_get_5g_bonded_channel() - get the 5G bonded channel state 141 * @pdev: Pointer to pdev structure 142 * @chan_num: channel number 143 * @ch_width: channel width 144 * @bonded_chan_ptr_ptr: bonded channel ptr ptr 145 * 146 * Return: channel state 147 */ 148 enum channel_state reg_get_5g_bonded_channel( 149 struct wlan_objmgr_pdev *pdev, uint8_t chan_num, 150 enum phy_ch_width ch_width, 151 const struct bonded_channel **bonded_chan_ptr_ptr); 152 153 /** 154 * reg_get_5g_bonded_channel_state() - Get channel state for 5G bonded channel 155 * @pdev: Pointer to pdev 156 * @ch: channel number. 157 * @bw: channel band width 158 * 159 * Return: channel state 160 */ 161 enum channel_state reg_get_5g_bonded_channel_state( 162 struct wlan_objmgr_pdev *pdev, uint8_t ch, 163 enum phy_ch_width bw); 164 165 /** 166 * reg_get_2g_bonded_channel_state() - Get channel state for 2G bonded channel 167 * @ch: channel number. 168 * @pdev: Pointer to pdev 169 * @oper_ch: Primary channel number 170 * @sec_ch: Secondary channel number 171 * @bw: channel band width 172 * 173 * Return: channel state 174 */ 175 enum channel_state reg_get_2g_bonded_channel_state( 176 struct wlan_objmgr_pdev *pdev, uint8_t oper_ch, uint8_t sec_ch, 177 enum phy_ch_width bw); 178 179 /** 180 * reg_set_channel_params () - Sets channel parameteres for given bandwidth 181 * @pdev: Pointer to pdev 182 * @ch: channel number. 183 * @sec_ch_2g: Secondary 2G channel 184 * @ch_params: pointer to the channel parameters. 185 * 186 * Return: None 187 */ 188 void reg_set_channel_params(struct wlan_objmgr_pdev *pdev, 189 uint8_t ch, uint8_t sec_ch_2g, 190 struct ch_params *ch_params); 191 #endif /* CONFIG_CHAN_NUM_API */ 192 193 /** 194 * reg_read_default_country() - Get the default regulatory country 195 * @psoc: The physical SoC to get default country from 196 * @country_code: the buffer to populate the country code into 197 * 198 * Return: QDF_STATUS 199 */ 200 QDF_STATUS reg_read_default_country(struct wlan_objmgr_psoc *psoc, 201 uint8_t *country_code); 202 203 /** 204 * reg_get_current_dfs_region () - Get the current dfs region 205 * @pdev: Pointer to pdev 206 * @dfs_reg: pointer to dfs region 207 * 208 * Return: None 209 */ 210 void reg_get_current_dfs_region(struct wlan_objmgr_pdev *pdev, 211 enum dfs_reg *dfs_reg); 212 213 #ifdef CONFIG_CHAN_NUM_API 214 /** 215 * reg_get_channel_reg_power() - Get the txpower for the given channel 216 * @pdev: Pointer to pdev 217 * @chan_num: Channel number 218 * 219 * Return: txpower 220 */ 221 uint32_t reg_get_channel_reg_power(struct wlan_objmgr_pdev *pdev, 222 uint8_t chan_num); 223 224 /** 225 * reg_get_channel_freq() - Get the channel frequency 226 * @pdev: Pointer to pdev 227 * @chan_num: Channel number 228 * 229 * Return: frequency 230 */ 231 qdf_freq_t reg_get_channel_freq(struct wlan_objmgr_pdev *pdev, 232 uint8_t chan_num); 233 #endif /* CONFIG_CHAN_NUM_API */ 234 235 /** 236 * reg_get_bw_value() - give bandwidth value 237 * bw: bandwidth enum 238 * 239 * Return: uint16_t 240 */ 241 uint16_t reg_get_bw_value(enum phy_ch_width bw); 242 243 /** 244 * reg_set_dfs_region () - Set the current dfs region 245 * @pdev: Pointer to pdev 246 * @dfs_reg: pointer to dfs region 247 * 248 * Return: None 249 */ 250 void reg_set_dfs_region(struct wlan_objmgr_pdev *pdev, 251 enum dfs_reg dfs_reg); 252 253 #ifdef CONFIG_CHAN_NUM_API 254 /** 255 * reg_chan_to_band() - Get band from channel number 256 * @chan_num: channel number 257 * 258 * Return: band info 259 */ 260 enum band_info reg_chan_to_band(uint8_t chan_num); 261 #endif /* CONFIG_CHAN_NUM_API */ 262 263 /** 264 * reg_program_chan_list() - Set user country code and populate the channel list 265 * @pdev: Pointer to pdev 266 * @rd: Pointer to cc_regdmn_s structure 267 * 268 * Return: QDF_STATUS 269 */ 270 QDF_STATUS reg_program_chan_list(struct wlan_objmgr_pdev *pdev, 271 struct cc_regdmn_s *rd); 272 273 #ifdef CONFIG_CHAN_NUM_API 274 /** 275 * reg_update_nol_ch () - Updates NOL channels in current channel list 276 * @pdev: pointer to pdev object 277 * @ch_list: pointer to NOL channel list 278 * @num_ch: No.of channels in list 279 * @update_nol: set/reset the NOL status 280 * 281 * Return: None 282 */ 283 void reg_update_nol_ch(struct wlan_objmgr_pdev *pdev, uint8_t *chan_list, 284 uint8_t num_chan, bool nol_chan); 285 286 /** 287 * reg_is_dfs_ch () - Checks the channel state for DFS 288 * @pdev: pdev ptr 289 * @chan: channel 290 * 291 * Return: true or false 292 */ 293 bool reg_is_dfs_ch(struct wlan_objmgr_pdev *pdev, uint8_t chan); 294 #endif /* CONFIG_CHAN_NUM_API */ 295 296 /** 297 * reg_freq_to_chan() - Get channel number from frequency. 298 * @pdev: Pointer to pdev 299 * @freq: Channel frequency 300 * 301 * Return: Channel number if success, otherwise 0 302 */ 303 uint8_t reg_freq_to_chan(struct wlan_objmgr_pdev *pdev, qdf_freq_t freq); 304 305 #ifdef CONFIG_CHAN_NUM_API 306 /** 307 * reg_chan_to_freq() - Get frequency from channel number 308 * @pdev: Pointer to pdev 309 * @chan_num: Channel number 310 * 311 * Return: Channel frequency if success, otherwise 0 312 */ 313 qdf_freq_t reg_chan_to_freq(struct wlan_objmgr_pdev *pdev, uint8_t chan_num); 314 315 /** 316 * reg_legacy_chan_to_freq() - Get freq from chan noumber, for 2G and 5G 317 * @pdev: Pointer to pdev 318 * @chan_num: Channel number 319 * 320 * Return: Channel frequency if success, otherwise 0 321 */ 322 uint16_t reg_legacy_chan_to_freq(struct wlan_objmgr_pdev *pdev, 323 uint8_t chan_num); 324 325 /** 326 * reg_chan_is_49ghz() - Check if the input channel number is 4.9GHz 327 * @pdev: Pdev pointer 328 * @chan_num: Input channel number 329 * 330 * Return: true if the channel is 4.9GHz else false. 331 */ 332 bool reg_chan_is_49ghz(struct wlan_objmgr_pdev *pdev, uint8_t chan_num); 333 #endif /* CONFIG_CHAN_NUM_API */ 334 335 /** 336 * reg_program_default_cc() - Program default country code 337 * @pdev: Pdev pointer 338 * @regdmn: Regdomain value 339 * 340 * Return: QDF_STATUS 341 */ 342 QDF_STATUS reg_program_default_cc(struct wlan_objmgr_pdev *pdev, 343 uint16_t regdmn); 344 345 /** 346 * reg_get_current_cc() - Get current country code 347 * @pdev: Pdev pointer 348 * @regdmn: Pointer to get current country values 349 * 350 * Return: QDF_STATUS 351 */ 352 QDF_STATUS reg_get_current_cc(struct wlan_objmgr_pdev *pdev, 353 struct cc_regdmn_s *rd); 354 355 /** 356 * reg_get_curr_band() - Get current band 357 * @pdev: Pdev pointer 358 * @band: Pointer to save the current band 359 * 360 * Return: QDF_STATUS 361 */ 362 QDF_STATUS reg_get_curr_band(struct wlan_objmgr_pdev *pdev, 363 enum band_info *band); 364 365 /** 366 * reg_set_regdb_offloaded() - set/clear regulatory offloaded flag 367 * 368 * @psoc: psoc pointer 369 * Return: Success or Failure 370 */ 371 QDF_STATUS reg_set_regdb_offloaded(struct wlan_objmgr_psoc *psoc, bool val); 372 373 /** 374 * reg_get_curr_regdomain() - Get current regdomain in use 375 * @pdev: pdev pointer 376 * @cur_regdmn: Current regdomain info 377 * 378 * Return: QDF status 379 */ 380 QDF_STATUS reg_get_curr_regdomain(struct wlan_objmgr_pdev *pdev, 381 struct cur_regdmn_info *cur_regdmn); 382 383 /** 384 * reg_modify_chan_144() - Enable/Disable channel 144 385 * @pdev: pdev pointer 386 * @en_chan_144: flag to disable/enable channel 144 387 * 388 * Return: Success or Failure 389 */ 390 QDF_STATUS reg_modify_chan_144(struct wlan_objmgr_pdev *pdev, bool en_chan_144); 391 392 /** 393 * reg_get_en_chan_144() - get en_chan_144 flag value 394 * @pdev: pdev pointer 395 * 396 * Return: en_chan_144 flag value 397 */ 398 bool reg_get_en_chan_144(struct wlan_objmgr_pdev *pdev); 399 400 /** 401 * reg_get_hal_reg_cap() - Get HAL REG capabilities 402 * @psoc: psoc for country information 403 * 404 * Return: hal reg cap pointer 405 */ 406 struct wlan_psoc_host_hal_reg_capabilities_ext *reg_get_hal_reg_cap( 407 struct wlan_objmgr_psoc *psoc); 408 409 /** 410 * reg_set_hal_reg_cap() - Set HAL REG capabilities 411 * @psoc: psoc for country information 412 * @reg_cap: Regulatory caps pointer 413 * @phy_cnt: number of phy 414 * 415 * Return: hal reg cap pointer 416 */ 417 QDF_STATUS reg_set_hal_reg_cap( 418 struct wlan_objmgr_psoc *psoc, 419 struct wlan_psoc_host_hal_reg_capabilities_ext *reg_cap, 420 uint16_t phy_cnt); 421 422 /** 423 * reg_chan_in_range() - Check if the given channel is in pdev's channel range 424 * @chan_list: Pointer to regulatory channel list. 425 * @low_freq_2g: Low frequency 2G. 426 * @high_freq_2g: High frequency 2G. 427 * @low_freq_5g: Low frequency 5G. 428 * @high_freq_5g: High frequency 5G. 429 * @ch_enum: Channel enum. 430 * 431 * Return: true if ch_enum is with in pdev's channel range, else false. 432 */ 433 bool reg_chan_in_range(struct regulatory_channel *chan_list, 434 qdf_freq_t low_freq_2g, qdf_freq_t high_freq_2g, 435 qdf_freq_t low_freq_5g, qdf_freq_t high_freq_5g, 436 enum channel_enum ch_enum); 437 438 /** 439 * reg_init_channel_map() - Initialize the channel list based on the dfs region. 440 * @dfs_region: Dfs region 441 */ 442 void reg_init_channel_map(enum dfs_reg dfs_region); 443 444 /** 445 * reg_get_psoc_tx_ops() - Get regdb tx ops 446 * @psoc: Pointer to psoc structure 447 */ 448 struct wlan_lmac_if_reg_tx_ops *reg_get_psoc_tx_ops( 449 struct wlan_objmgr_psoc *psoc); 450 451 #ifdef CONFIG_CHAN_NUM_API 452 /** 453 * reg_update_nol_history_ch() - Set nol-history flag for the channels in the 454 * list. 455 * @pdev: Pdev ptr. 456 * @ch_list: Input channel list. 457 * @num_ch: Number of channels. 458 * @nol_history_ch: NOL-History flag. 459 * 460 * Return: void 461 */ 462 void reg_update_nol_history_ch(struct wlan_objmgr_pdev *pdev, 463 uint8_t *chan_list, 464 uint8_t num_chan, 465 bool nol_history_chan); 466 467 /** 468 * reg_is_24ghz_ch() - Check if the given channel number is 2.4GHz 469 * @chan: Channel number 470 * 471 * Return: true if channel number is 2.4GHz, else false 472 */ 473 bool reg_is_24ghz_ch(uint32_t chan); 474 475 /** 476 * reg_is_5ghz_ch() - Check if the given channel number is 5GHz 477 * @chan: Channel number 478 * 479 * Return: true if channel number is 5GHz, else false 480 */ 481 bool reg_is_5ghz_ch(uint32_t chan); 482 #endif /* CONFIG_CHAN_NUM_API */ 483 484 /** 485 * reg_is_24ghz_ch_freq() - Check if the given channel frequency is 2.4GHz 486 * @freq: Channel frequency 487 * 488 * Return: true if channel frequency is 2.4GHz, else false 489 */ 490 bool reg_is_24ghz_ch_freq(uint32_t freq); 491 492 /** 493 * reg_is_5ghz_ch_freq() - Check if the given channel frequency is 5GHz 494 * @freq: Channel frequency 495 * 496 * Return: true if channel frequency is 5GHz, else false 497 */ 498 bool reg_is_5ghz_ch_freq(uint32_t freq); 499 500 #ifdef CONFIG_BAND_6GHZ 501 /** 502 * reg_is_6ghz_chan_freq() - Check if the given channel frequency is 6GHz 503 * @freq: Channel frequency 504 * 505 * Return: true if channel frequency is 6GHz, else false 506 */ 507 bool reg_is_6ghz_chan_freq(uint16_t freq); 508 509 /** 510 * REG_IS_6GHZ_FREQ() - Check if the given channel frequency is 6GHz 511 * @freq: Channel frequency 512 * 513 * Return: true if channel frequency is 6GHz, else false 514 */ 515 static inline bool REG_IS_6GHZ_FREQ(uint16_t freq) 516 { 517 return ((freq >= REG_MIN_6GHZ_CHAN_FREQ) && 518 (freq <= REG_MAX_6GHZ_CHAN_FREQ)); 519 } 520 521 /** 522 * reg_is_6ghz_psc_chan_freq() - Check if the given 6GHz channel frequency is 523 * preferred scanning channel frequency. 524 * @freq: Channel frequency 525 * 526 * Return: true if given 6GHz channel frequency is preferred scanning channel 527 * frequency, else false 528 */ 529 bool reg_is_6ghz_psc_chan_freq(uint16_t freq); 530 531 /** 532 * reg_min_6ghz_chan_freq() - Get minimum 6GHz channel center frequency 533 * 534 * Return: Minimum 6GHz channel center frequency 535 */ 536 uint16_t reg_min_6ghz_chan_freq(void); 537 538 /** 539 * reg_max_6ghz_chan_freq() - Get maximum 6GHz channel center frequency 540 * 541 * Return: Maximum 6GHz channel center frequency 542 */ 543 uint16_t reg_max_6ghz_chan_freq(void); 544 #else 545 static inline bool reg_is_6ghz_chan_freq(uint16_t freq) 546 { 547 return false; 548 } 549 550 static inline bool REG_IS_6GHZ_FREQ(uint16_t freq) 551 { 552 return false; 553 } 554 555 static inline bool reg_is_6ghz_psc_chan_freq(uint16_t freq) 556 { 557 return false; 558 } 559 560 static inline uint16_t reg_min_6ghz_chan_freq(void) 561 { 562 return 0; 563 } 564 565 static inline uint16_t reg_max_6ghz_chan_freq(void) 566 { 567 return 0; 568 } 569 #endif /* CONFIG_BAND_6GHZ */ 570 571 /** 572 * reg_get_band_channel_list() - Get the channel list and number of channels 573 * @pdev: pdev ptr 574 * @band_mask: Input bitmap with band set 575 * @channel_list: Pointer to Channel List 576 * 577 * Get the given channel list and number of channels from the current channel 578 * list based on input band bitmap. 579 * 580 * Return: Number of channels, else 0 to indicate error 581 */ 582 uint16_t reg_get_band_channel_list(struct wlan_objmgr_pdev *pdev, 583 uint8_t band_mask, 584 struct regulatory_channel *channel_list); 585 586 /** 587 * reg_chan_band_to_freq - Return channel frequency based on the channel number 588 * and band. 589 * @pdev: pdev ptr 590 * @chan: Channel Number 591 * @band_mask: Bitmap for bands 592 * 593 * Return: Return channel frequency or return 0, if the channel is disabled or 594 * if the input channel number or band_mask is invalid. Composite bands are 595 * supported only for 2.4Ghz and 5Ghz bands. For other bands the following 596 * priority is given: 1) 6Ghz 2) 5Ghz 3) 2.4Ghz. 597 */ 598 qdf_freq_t reg_chan_band_to_freq(struct wlan_objmgr_pdev *pdev, 599 uint8_t chan, 600 uint8_t band_mask); 601 602 /** 603 * reg_is_49ghz_freq() - Check if the given channel frequency is 4.9GHz 604 * @freq: Channel frequency 605 * 606 * Return: true if channel frequency is 4.9GHz, else false 607 */ 608 bool reg_is_49ghz_freq(qdf_freq_t freq); 609 610 /** 611 * reg_ch_num() - Get channel number from channel enum 612 * @ch_enum: Channel enum 613 * 614 * Return: channel number 615 */ 616 qdf_freq_t reg_ch_num(uint32_t ch_enum); 617 618 /** 619 * reg_ch_to_freq() - Get channel frequency from channel enum 620 * @ch_enum: Channel enum 621 * 622 * Return: channel frequency 623 */ 624 qdf_freq_t reg_ch_to_freq(uint32_t ch_enum); 625 626 #ifdef CONFIG_CHAN_NUM_API 627 /** 628 * reg_is_same_band_channels() - Check if given channel numbers have same band 629 * @chan_num1: Channel number1 630 * @chan_num2: Channel number2 631 * 632 * Return: true if both the channels has the same band. 633 */ 634 bool reg_is_same_band_channels(uint8_t chan_num1, uint8_t chan_num2); 635 636 /** 637 * reg_is_channel_valid_5g_sbs() Check if the given channel is 5G SBS. 638 * @curchan: current channel 639 * @newchan:new channel 640 * 641 * Return: true if the given channel is a valid 5G SBS 642 */ 643 bool reg_is_channel_valid_5g_sbs(uint8_t curchan, uint8_t newchan); 644 645 /** 646 * reg_min_24ghz_ch_num() - Get minimum 2.4GHz channel number 647 * 648 * Return: Minimum 2.4GHz channel number 649 */ 650 uint8_t reg_min_24ghz_ch_num(void); 651 652 /** 653 * reg_max_24ghz_ch_num() - Get maximum 2.4GHz channel number 654 * 655 * Return: Maximum 2.4GHz channel number 656 */ 657 uint8_t reg_max_24ghz_ch_num(void); 658 659 /** 660 * reg_min_5ghz_ch_num() - Get minimum 5GHz channel number 661 * 662 * Return: Minimum 5GHz channel number 663 */ 664 uint8_t reg_min_5ghz_ch_num(void); 665 666 /** 667 * reg_max_5ghz_ch_num() - Get maximum 5GHz channel number 668 * 669 * Return: Maximum 5GHz channel number 670 */ 671 uint8_t reg_max_5ghz_ch_num(void); 672 #endif /* CONFIG_CHAN_NUM_API */ 673 674 #ifdef CONFIG_CHAN_FREQ_API 675 /** 676 * reg_min_24ghz_chan_freq() - Get minimum 2.4GHz channel frequency 677 * 678 * Return: Minimum 2.4GHz channel frequency 679 */ 680 qdf_freq_t reg_min_24ghz_chan_freq(void); 681 682 /** 683 * reg_max_24ghz_chan_freq() - Get maximum 2.4GHz channel frequency 684 * 685 * Return: Maximum 2.4GHz channel frequency 686 */ 687 qdf_freq_t reg_max_24ghz_chan_freq(void); 688 689 /** 690 * reg_min_5ghz_chan_freq() - Get minimum 5GHz channel frequency 691 * 692 * Return: Minimum 5GHz channel frequency 693 */ 694 qdf_freq_t reg_min_5ghz_chan_freq(void); 695 696 /** 697 * reg_max_5ghz_chan_freq() - Get maximum 5GHz channel frequency 698 * 699 * Return: Maximum 5GHz channel frequency 700 */ 701 qdf_freq_t reg_max_5ghz_chan_freq(void); 702 #endif /* CONFIG_CHAN_FREQ_API */ 703 704 /** 705 * reg_enable_dfs_channels() - Enable the use of DFS channels 706 * @pdev: The physical dev to enable/disable DFS channels for 707 * 708 * Return: QDF_STATUS 709 */ 710 QDF_STATUS reg_enable_dfs_channels(struct wlan_objmgr_pdev *pdev, bool enable); 711 712 /** 713 * reg_is_regdmn_en302502_applicable() - Find if ETSI EN302_502 radar pattern 714 * is applicable in current regulatory domain. 715 * @pdev: Pdev object pointer. 716 * 717 * Return: True if en302_502 is applicable, else false. 718 */ 719 bool reg_is_regdmn_en302502_applicable(struct wlan_objmgr_pdev *pdev); 720 721 /** 722 * reg_modify_pdev_chan_range() - Compute current channel list 723 * in accordance with the modified reg caps. 724 * @pdev: The physical dev for which channel list must be built. 725 * 726 * Return: QDF_STATUS 727 */ 728 QDF_STATUS reg_modify_pdev_chan_range(struct wlan_objmgr_pdev *pdev); 729 730 #ifdef DISABLE_UNII_SHARED_BANDS 731 /** 732 * reg_disable_chan_coex() - Disable Coexisting channels based on the input 733 * bitmask. 734 * @pdev: pointer to wlan_objmgr_pdev. 735 * unii_5g_bitmap: UNII 5G bitmap. 736 * 737 * Return : QDF_STATUS 738 */ 739 QDF_STATUS reg_disable_chan_coex(struct wlan_objmgr_pdev *pdev, 740 uint8_t unii_5g_bitmap); 741 #endif 742 743 #ifdef CONFIG_CHAN_FREQ_API 744 /** 745 * reg_get_chan_enum_for_freq() - Get channel enum for given channel frequency 746 * @freq: Channel Frequency 747 * 748 * Return: Channel enum 749 */ 750 enum channel_enum reg_get_chan_enum_for_freq(qdf_freq_t freq); 751 752 /** 753 * reg_get_channel_list_with_power_for_freq() - Provides the channel list with 754 * power 755 * @pdev: Pointer to pdev 756 * @ch_list: Pointer to the channel list. 757 * @num_chan: Pointer to save number of channels 758 * 759 * Return: QDF_STATUS 760 */ 761 QDF_STATUS 762 reg_get_channel_list_with_power_for_freq(struct wlan_objmgr_pdev *pdev, 763 struct channel_power *ch_list, 764 uint8_t *num_chan); 765 766 /** 767 * reg_get_channel_state_for_freq() - Get channel state from regulatory 768 * @pdev: Pointer to pdev 769 * @freq: channel center frequency. 770 * 771 * Return: channel state 772 */ 773 enum channel_state reg_get_channel_state_for_freq(struct wlan_objmgr_pdev *pdev, 774 qdf_freq_t freq); 775 776 /** 777 * reg_get_5g_bonded_channel_state_for_freq() - Get channel state for 778 * 5G bonded channel using the channel frequency 779 * @pdev: Pointer to pdev 780 * @freq: channel center frequency. 781 * @bw: channel band width 782 * 783 * Return: channel state 784 */ 785 enum channel_state 786 reg_get_5g_bonded_channel_state_for_freq(struct wlan_objmgr_pdev *pdev, 787 qdf_freq_t freq, 788 enum phy_ch_width bw); 789 790 /** 791 * reg_get_2g_bonded_channel_state_for_freq() - Get channel state for 2G 792 * bonded channel 793 * @freq: channel center frequency. 794 * @pdev: Pointer to pdev 795 * @oper_ch_freq: Primary channel center frequency 796 * @sec_ch_freq: Secondary channel center frequency 797 * @bw: channel band width 798 * 799 * Return: channel state 800 */ 801 enum channel_state 802 reg_get_2g_bonded_channel_state_for_freq(struct wlan_objmgr_pdev *pdev, 803 qdf_freq_t oper_ch_freq, 804 qdf_freq_t sec_ch_freq, 805 enum phy_ch_width bw); 806 807 /** 808 * reg_set_channel_params_for_freq () - Sets channel parameteres for given 809 * bandwidth 810 * @pdev: Pointer to pdev 811 * @freq: Channel center frequency. 812 * @sec_ch_2g_freq: Secondary 2G channel frequency 813 * @ch_params: pointer to the channel parameters. 814 * 815 * Return: None 816 */ 817 void reg_set_channel_params_for_freq(struct wlan_objmgr_pdev *pdev, 818 qdf_freq_t freq, 819 qdf_freq_t sec_ch_2g_freq, 820 struct ch_params *ch_params); 821 822 /** 823 * reg_get_channel_reg_power_for_freq() - Get the txpower for the given channel 824 * @pdev: Pointer to pdev 825 * @freq: Channel frequency 826 * 827 * Return: txpower 828 */ 829 uint8_t reg_get_channel_reg_power_for_freq(struct wlan_objmgr_pdev *pdev, 830 qdf_freq_t freq); 831 832 /** 833 * reg_update_nol_ch_for_freq () - Updates NOL channels in current channel list 834 * @pdev: pointer to pdev object 835 * @chan_freq_list: pointer to NOL channel list 836 * @num_ch: No.of channels in list 837 * @update_nol: set/reset the NOL status 838 * 839 * Return: None 840 */ 841 void reg_update_nol_ch_for_freq(struct wlan_objmgr_pdev *pdev, 842 uint16_t *chan_freq_list, 843 uint8_t num_chan, 844 bool nol_chan); 845 /** 846 * reg_is_dfs_for_freq () - Checks the channel state for DFS 847 * @pdev: pdev ptr 848 * @freq: Channel center frequency 849 * 850 * Return: true or false 851 */ 852 bool reg_is_dfs_for_freq(struct wlan_objmgr_pdev *pdev, qdf_freq_t freq); 853 854 /** 855 * reg_chan_freq_is_49ghz() - Check if the input channel center frequency is 856 * 4.9GHz 857 * @pdev: Pdev pointer 858 * @chan_num: Input channel center frequency 859 * 860 * Return: true if the frequency is 4.9GHz else false. 861 */ 862 bool reg_chan_freq_is_49ghz(qdf_freq_t freq); 863 864 /** 865 * reg_update_nol_history_ch_for_freq() - Set nol-history flag for the channels 866 * in the list. 867 * @pdev: Pdev ptr. 868 * @chan_list: Input channel freqeuncy list. 869 * @num_ch: Number of channels. 870 * @nol_history_ch: NOL-History flag. 871 * 872 * Return: void 873 */ 874 void reg_update_nol_history_ch_for_freq(struct wlan_objmgr_pdev *pdev, 875 uint16_t *chan_list, 876 uint8_t num_chan, 877 bool nol_history_chan); 878 879 /** 880 * reg_is_same_5g_band_freqs() - Check if given channel center 881 * frequencies have same band 882 * @freq1: Channel Center Frequency 1 883 * @freq2: Channel Center Frequency 2 884 * 885 * Return: true if both the frequencies has the same band. 886 */ 887 bool reg_is_same_band_freqs(qdf_freq_t freq1, qdf_freq_t freq2); 888 889 /** 890 * reg_is_frequency_valid_5g_sbs() Check if the given frequency is 5G SBS. 891 * @curfreq: current channel frequency 892 * @newfreq: new channel center frequency 893 * 894 * Return: true if the given center frequency is a valid 5G SBS 895 */ 896 bool reg_is_frequency_valid_5g_sbs(qdf_freq_t curfreq, qdf_freq_t newfreq); 897 898 /** 899 * reg_freq_to_band() - Get band from channel frequency 900 * @chan_num: channel frequency 901 * 902 * Return: wifi band 903 */ 904 enum reg_wifi_band reg_freq_to_band(qdf_freq_t freq); 905 906 /** 907 * reg_min_chan_freq() - minimum channel frequency supported 908 * 909 * Return: channel frequency 910 */ 911 qdf_freq_t reg_min_chan_freq(void); 912 913 /** 914 * reg_max_chan_freq() - maximum channel frequency supported 915 * 916 * Return: channel frequency 917 */ 918 qdf_freq_t reg_max_chan_freq(void); 919 920 /** 921 * reg_get_5g_bonded_channel_for_freq()- Return the channel state for a 922 * 5G or 6G channel frequency based on the channel width and bonded channel 923 * @pdev: Pointer to pdev. 924 * @freq: Channel center frequency. 925 * @ch_width: Channel Width. 926 * @bonded_chan_ptr_ptr: Pointer to bonded_channel_freq. 927 * 928 * Return: Channel State 929 */ 930 enum channel_state 931 reg_get_5g_bonded_channel_for_freq(struct wlan_objmgr_pdev *pdev, 932 uint16_t freq, 933 enum phy_ch_width ch_width, 934 const struct bonded_channel_freq 935 **bonded_chan_ptr_ptr); 936 #endif /* CONFIG_CHAN_FREQ_API */ 937 938 /** 939 * reg_set_ignore_fw_reg_offload_ind() - Set if regdb offload indication 940 * needs to be ignored 941 * @psoc: Pointer to psoc 942 * 943 * Return: QDF_STATUS 944 */ 945 QDF_STATUS reg_set_ignore_fw_reg_offload_ind(struct wlan_objmgr_psoc *psoc); 946 947 /** 948 * reg_get_ignore_fw_reg_offload_ind() - Check whether regdb offload indication 949 * needs to be ignored 950 * 951 * @psoc: Pointer to psoc 952 */ 953 bool reg_get_ignore_fw_reg_offload_ind(struct wlan_objmgr_psoc *psoc); 954 955 /** 956 * reg_set_6ghz_supported() - Set if 6ghz is supported 957 * 958 * @psoc: Pointer to psoc 959 * @val: value 960 */ 961 QDF_STATUS reg_set_6ghz_supported(struct wlan_objmgr_psoc *psoc, 962 bool val); 963 964 /** 965 * reg_is_6ghz_op_class() - Check whether 6ghz oper class 966 * 967 * @pdev: Pointer to pdev 968 * @op_class: oper class 969 */ 970 bool reg_is_6ghz_op_class(struct wlan_objmgr_pdev *pdev, 971 uint8_t op_class); 972 973 /** 974 * reg_is_6ghz_supported() - Whether 6ghz is supported 975 * 976 * @pdev: pointer to pdev 977 */ 978 bool reg_is_6ghz_supported(struct wlan_objmgr_pdev *pdev); 979 980 /** 981 * reg_get_unii_5g_bitmap() - get unii_5g_bitmap value 982 * @pdev: pdev pointer 983 * @bitmap: Pointer to retrieve the unii_5g_bitmap of enum reg_unii_band 984 * 985 * Return: QDF_STATUS 986 */ 987 #ifdef DISABLE_UNII_SHARED_BANDS 988 QDF_STATUS 989 reg_get_unii_5g_bitmap(struct wlan_objmgr_pdev *pdev, uint8_t *bitmap); 990 #endif 991 992 #endif 993