1 /* 2 * Copyright (c) 2017-2021 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 #ifdef CONFIG_AFC_SUPPORT 30 #include <wlan_reg_afc.h> 31 #endif 32 33 #define IS_VALID_PSOC_REG_OBJ(psoc_priv_obj) (psoc_priv_obj) 34 #define IS_VALID_PDEV_REG_OBJ(pdev_priv_obj) (pdev_priv_obj) 35 #define FREQ_TO_CHAN_SCALE 5 36 /* The distance between the 80Mhz center and the nearest 20Mhz channel */ 37 #define NEAREST_20MHZ_CHAN_FREQ_OFFSET 10 38 #define NUM_20_MHZ_CHAN_IN_80_MHZ_CHAN 4 39 #define NUM_20_MHZ_CHAN_IN_160_MHZ_CHAN 8 40 41 #define REG_MAX_5GHZ_CH_NUM channel_map[MAX_5GHZ_CHANNEL].chan_num 42 43 #define REG_MIN_24GHZ_CH_FREQ channel_map[MIN_24GHZ_CHANNEL].center_freq 44 #define REG_MAX_24GHZ_CH_FREQ channel_map[MAX_24GHZ_CHANNEL].center_freq 45 46 #define REG_IS_24GHZ_CH_FREQ(freq) \ 47 (((freq) >= REG_MIN_24GHZ_CH_FREQ) && \ 48 ((freq) <= REG_MAX_24GHZ_CH_FREQ)) 49 50 #ifdef CONFIG_CHAN_FREQ_API 51 #define REG_MIN_5GHZ_CH_FREQ channel_map[MIN_5GHZ_CHANNEL].center_freq 52 #define REG_MAX_5GHZ_CH_FREQ channel_map[MAX_5GHZ_CHANNEL].center_freq 53 #endif /* CONFIG_CHAN_FREQ_API */ 54 55 #ifdef CONFIG_49GHZ_CHAN 56 #define REG_MIN_49GHZ_CH_FREQ channel_map[MIN_49GHZ_CHANNEL].center_freq 57 #define REG_MAX_49GHZ_CH_FREQ channel_map[MAX_49GHZ_CHANNEL].center_freq 58 #else 59 #define REG_MIN_49GHZ_CH_FREQ 0 60 #define REG_MAX_49GHZ_CH_FREQ 0 61 #endif /* CONFIG_49GHZ_CHAN */ 62 63 #define REG_IS_49GHZ_FREQ(freq) \ 64 (((freq) >= REG_MIN_49GHZ_CH_FREQ) && \ 65 ((freq) <= REG_MAX_49GHZ_CH_FREQ)) 66 67 68 #define REG_IS_5GHZ_FREQ(freq) \ 69 (((freq) >= channel_map[MIN_5GHZ_CHANNEL].center_freq) && \ 70 ((freq) <= channel_map[MAX_5GHZ_CHANNEL].center_freq)) 71 72 /* 73 * It should be 2.5 MHz actually but since we are using integer use 2 74 * instead, which does not create any problem in the start edge calculation. 75 */ 76 #define HALF_5MHZ_BW 2 77 #define HALF_20MHZ_BW 10 78 #define HALF_40MHZ_BW 20 79 #define HALF_80MHZ_BW 40 80 #define HALF_160MHZ_BW 80 81 82 #define TWO_GIG_STARTING_EDGE_FREQ (channel_map_global[MIN_24GHZ_CHANNEL]. \ 83 center_freq - HALF_20MHZ_BW) 84 #define TWO_GIG_ENDING_EDGE_FREQ (channel_map_global[MAX_24GHZ_CHANNEL]. \ 85 center_freq + HALF_20MHZ_BW) 86 #ifdef CONFIG_49GHZ_CHAN 87 #define FIVE_GIG_STARTING_EDGE_FREQ (channel_map_global[MIN_49GHZ_CHANNEL]. \ 88 center_freq - HALF_5MHZ_BW) 89 #else 90 #define FIVE_GIG_STARTING_EDGE_FREQ (channel_map_global[MIN_5GHZ_CHANNEL]. \ 91 center_freq - HALF_20MHZ_BW) 92 #endif /* CONFIG_49GHZ_CHAN */ 93 #define FIVE_GIG_ENDING_EDGE_FREQ (channel_map_global[MAX_5GHZ_CHANNEL]. \ 94 center_freq + HALF_20MHZ_BW) 95 96 #ifdef CONFIG_BAND_6GHZ 97 #define SIX_GIG_STARTING_EDGE_FREQ (channel_map_global[MIN_6GHZ_CHANNEL]. \ 98 center_freq - HALF_20MHZ_BW) 99 #define SIX_GIG_ENDING_EDGE_FREQ (channel_map_global[MAX_6GHZ_CHANNEL]. \ 100 center_freq + HALF_20MHZ_BW) 101 102 #define FREQ_LEFT_SHIFT 55 103 #define SIX_GHZ_NON_ORPHAN_START_FREQ \ 104 (channel_map_global[MIN_6GHZ_NON_ORPHAN_CHANNEL].center_freq - 5) 105 #define CHAN_FREQ_5935 5935 106 #define NUM_80MHZ_BAND_IN_6G 16 107 #define NUM_PSC_FREQ 15 108 #define PSC_BAND_MHZ (FREQ_TO_CHAN_SCALE * NUM_80MHZ_BAND_IN_6G) 109 #define REG_MIN_6GHZ_CHAN_FREQ channel_map[MIN_6GHZ_CHANNEL].center_freq 110 #define REG_MAX_6GHZ_CHAN_FREQ channel_map[MAX_6GHZ_CHANNEL].center_freq 111 #else 112 #define FREQ_LEFT_SHIFT 0 113 #define SIX_GHZ_NON_ORPHAN_START_FREQ 0 114 #define CHAN_FREQ_5935 0 115 #define NUM_80MHZ_BAND_IN_6G 0 116 #define NUM_PSC_FREQ 0 117 #define PSC_BAND_MHZ (FREQ_TO_CHAN_SCALE * NUM_80MHZ_BAND_IN_6G) 118 #define REG_MIN_6GHZ_CHAN_FREQ 0 119 #define REG_MAX_6GHZ_CHAN_FREQ 0 120 #endif /*CONFIG_BAND_6GHZ*/ 121 122 #define REG_CH_NUM(ch_enum) channel_map[ch_enum].chan_num 123 #define REG_CH_TO_FREQ(ch_enum) channel_map[ch_enum].center_freq 124 125 /* EEPROM setting is a country code */ 126 #define COUNTRY_ERD_FLAG 0x8000 127 #define MIN_6GHZ_OPER_CLASS 131 128 #define MAX_6GHZ_OPER_CLASS 136 129 130 #ifdef CONFIG_AFC_SUPPORT 131 #define DEFAULT_REQ_ID 11235813 132 /* default minimum power in dBm units */ 133 #define DEFAULT_MIN_POWER (-10) 134 #define DEFAULT_NUM_FREQS 1 135 136 /* Have the entire 6Ghz band as single range */ 137 #define DEFAULT_LOW_6GFREQ 5925 138 #define DEFAULT_HIGH_6GFREQ 7125 139 #endif 140 141 #define SIXG_CHAN_2 2 142 #ifdef CONFIG_BAND_6GHZ 143 #define CHAN_ENUM_SIXG_2 CHAN_ENUM_5935 144 #else 145 #define CHAN_ENUM_SIXG_2 INVALID_CHANNEL 146 #endif 147 148 extern const struct chan_map *channel_map; 149 extern const struct chan_map channel_map_us[]; 150 extern const struct chan_map channel_map_eu[]; 151 extern const struct chan_map channel_map_jp[]; 152 extern const struct chan_map channel_map_china[]; 153 extern const struct chan_map channel_map_global[]; 154 155 #ifdef WLAN_FEATURE_11BE 156 #define ALL_SCHANS_PUNC 0x0000 /* all subchannels punctured */ 157 #endif 158 159 #ifdef CONFIG_AFC_SUPPORT 160 /** 161 * struct afc_cb_handler - defines structure for afc request received event 162 * handler call back function and argument 163 * @func: handler function pointer 164 * @arg: argument to handler function 165 */ 166 struct afc_cb_handler { 167 afc_req_rx_evt_handler func; 168 void *arg; 169 }; 170 171 /** 172 * reg_init_freq_range() - Initialize a freq_range object 173 * @left: The left frequency range 174 * @right: The right frequency range 175 * 176 * Return: The initialized freq_range object 177 */ 178 struct freq_range 179 reg_init_freq_range(qdf_freq_t left, qdf_freq_t right); 180 #endif 181 /** 182 * get_next_lower_bandwidth() - Get next lower bandwidth 183 * @ch_width: Channel width 184 * 185 * Return: Channel width 186 */ 187 enum phy_ch_width get_next_lower_bandwidth(enum phy_ch_width ch_width); 188 189 /** 190 * reg_read_default_country() - Get the default regulatory country 191 * @psoc: The physical SoC to get default country from 192 * @country_code: the buffer to populate the country code into 193 * 194 * Return: QDF_STATUS 195 */ 196 QDF_STATUS reg_read_default_country(struct wlan_objmgr_psoc *psoc, 197 uint8_t *country_code); 198 199 /** 200 * reg_get_ctry_idx_max_bw_from_country_code() - Get the max 5G bandwidth 201 * from country code 202 * @cc : Country Code 203 * @max_bw_5g : Max 5G bandwidth supported by the country 204 * 205 * Return : QDF_STATUS 206 */ 207 208 QDF_STATUS reg_get_max_5g_bw_from_country_code(uint16_t cc, 209 uint16_t *max_bw_5g); 210 211 /** 212 * reg_get_max_5g_bw_from_regdomain() - Get the max 5G bandwidth 213 * supported by the regdomain 214 * @orig_regdmn : Regdomain pair value 215 * @max_bw_5g : Max 5G bandwidth supported by the country 216 * 217 * Return : QDF_STATUS 218 */ 219 220 QDF_STATUS reg_get_max_5g_bw_from_regdomain(uint16_t regdmn, 221 uint16_t *max_bw_5g); 222 223 /** 224 * reg_get_current_dfs_region () - Get the current dfs region 225 * @pdev: Pointer to pdev 226 * @dfs_reg: pointer to dfs region 227 * 228 * Return: None 229 */ 230 void reg_get_current_dfs_region(struct wlan_objmgr_pdev *pdev, 231 enum dfs_reg *dfs_reg); 232 233 /** 234 * reg_get_bw_value() - give bandwidth value 235 * bw: bandwidth enum 236 * 237 * Return: uint16_t 238 */ 239 uint16_t reg_get_bw_value(enum phy_ch_width bw); 240 241 /** 242 * reg_set_dfs_region () - Set the current dfs region 243 * @pdev: Pointer to pdev 244 * @dfs_reg: pointer to dfs region 245 * 246 * Return: None 247 */ 248 void reg_set_dfs_region(struct wlan_objmgr_pdev *pdev, 249 enum dfs_reg dfs_reg); 250 251 /** 252 * reg_program_chan_list() - Set user country code and populate the channel list 253 * @pdev: Pointer to pdev 254 * @rd: Pointer to cc_regdmn_s structure 255 * 256 * Return: QDF_STATUS 257 */ 258 QDF_STATUS reg_program_chan_list(struct wlan_objmgr_pdev *pdev, 259 struct cc_regdmn_s *rd); 260 261 /** 262 * reg_freq_to_chan() - Get channel number from frequency. 263 * @pdev: Pointer to pdev 264 * @freq: Channel frequency 265 * 266 * Return: Channel number if success, otherwise 0 267 */ 268 uint8_t reg_freq_to_chan(struct wlan_objmgr_pdev *pdev, qdf_freq_t freq); 269 270 /** 271 * reg_legacy_chan_to_freq() - Get freq from chan noumber, for 2G and 5G 272 * @pdev: Pointer to pdev 273 * @chan_num: Channel number 274 * 275 * Return: Channel frequency if success, otherwise 0 276 */ 277 uint16_t reg_legacy_chan_to_freq(struct wlan_objmgr_pdev *pdev, 278 uint8_t chan_num); 279 280 /** 281 * reg_program_default_cc() - Program default country code 282 * @pdev: Pdev pointer 283 * @regdmn: Regdomain value 284 * 285 * Return: QDF_STATUS 286 */ 287 QDF_STATUS reg_program_default_cc(struct wlan_objmgr_pdev *pdev, 288 uint16_t regdmn); 289 290 /** 291 * reg_get_current_cc() - Get current country code 292 * @pdev: Pdev pointer 293 * @regdmn: Pointer to get current country values 294 * 295 * Return: QDF_STATUS 296 */ 297 QDF_STATUS reg_get_current_cc(struct wlan_objmgr_pdev *pdev, 298 struct cc_regdmn_s *rd); 299 300 /** 301 * reg_set_regdb_offloaded() - set/clear regulatory offloaded flag 302 * 303 * @psoc: psoc pointer 304 * Return: Success or Failure 305 */ 306 QDF_STATUS reg_set_regdb_offloaded(struct wlan_objmgr_psoc *psoc, bool val); 307 308 /** 309 * reg_get_curr_regdomain() - Get current regdomain in use 310 * @pdev: pdev pointer 311 * @cur_regdmn: Current regdomain info 312 * 313 * Return: QDF status 314 */ 315 QDF_STATUS reg_get_curr_regdomain(struct wlan_objmgr_pdev *pdev, 316 struct cur_regdmn_info *cur_regdmn); 317 318 /** 319 * reg_modify_chan_144() - Enable/Disable channel 144 320 * @pdev: pdev pointer 321 * @en_chan_144: flag to disable/enable channel 144 322 * 323 * Return: Success or Failure 324 */ 325 QDF_STATUS reg_modify_chan_144(struct wlan_objmgr_pdev *pdev, bool en_chan_144); 326 327 /** 328 * reg_get_en_chan_144() - get en_chan_144 flag value 329 * @pdev: pdev pointer 330 * 331 * Return: en_chan_144 flag value 332 */ 333 bool reg_get_en_chan_144(struct wlan_objmgr_pdev *pdev); 334 335 /** 336 * reg_get_hal_reg_cap() - Get HAL REG capabilities 337 * @psoc: psoc for country information 338 * 339 * Return: hal reg cap pointer 340 */ 341 struct wlan_psoc_host_hal_reg_capabilities_ext *reg_get_hal_reg_cap( 342 struct wlan_objmgr_psoc *psoc); 343 344 /** 345 * reg_set_hal_reg_cap() - Set HAL REG capabilities 346 * @psoc: psoc for country information 347 * @reg_cap: Regulatory caps pointer 348 * @phy_cnt: number of phy 349 * 350 * Return: hal reg cap pointer 351 */ 352 QDF_STATUS reg_set_hal_reg_cap( 353 struct wlan_objmgr_psoc *psoc, 354 struct wlan_psoc_host_hal_reg_capabilities_ext *reg_cap, 355 uint16_t phy_cnt); 356 357 /** 358 * reg_update_hal_reg_cap() - Update HAL REG capabilities 359 * @psoc: psoc pointer 360 * @wireless_modes: 11AX wireless modes 361 * @phy_id: phy id 362 * 363 * Return: QDF_STATUS 364 */ 365 QDF_STATUS reg_update_hal_reg_cap(struct wlan_objmgr_psoc *psoc, 366 uint64_t wireless_modes, uint8_t phy_id); 367 368 /** 369 * reg_chan_in_range() - Check if the given channel is in pdev's channel range 370 * @chan_list: Pointer to regulatory channel list. 371 * @low_freq_2g: Low frequency 2G. 372 * @high_freq_2g: High frequency 2G. 373 * @low_freq_5g: Low frequency 5G. 374 * @high_freq_5g: High frequency 5G. 375 * @ch_enum: Channel enum. 376 * 377 * Return: true if ch_enum is with in pdev's channel range, else false. 378 */ 379 bool reg_chan_in_range(struct regulatory_channel *chan_list, 380 qdf_freq_t low_freq_2g, qdf_freq_t high_freq_2g, 381 qdf_freq_t low_freq_5g, qdf_freq_t high_freq_5g, 382 enum channel_enum ch_enum); 383 384 /** 385 * reg_init_channel_map() - Initialize the channel list based on the dfs region. 386 * @dfs_region: Dfs region 387 */ 388 void reg_init_channel_map(enum dfs_reg dfs_region); 389 390 /** 391 * reg_get_psoc_tx_ops() - Get regdb tx ops 392 * @psoc: Pointer to psoc structure 393 */ 394 struct wlan_lmac_if_reg_tx_ops *reg_get_psoc_tx_ops( 395 struct wlan_objmgr_psoc *psoc); 396 397 /** 398 * reg_is_24ghz_ch_freq() - Check if the given channel frequency is 2.4GHz 399 * @freq: Channel frequency 400 * 401 * Return: true if channel frequency is 2.4GHz, else false 402 */ 403 bool reg_is_24ghz_ch_freq(uint32_t freq); 404 405 /** 406 * reg_is_5ghz_ch_freq() - Check if the given channel frequency is 5GHz 407 * @freq: Channel frequency 408 * 409 * Return: true if channel frequency is 5GHz, else false 410 */ 411 bool reg_is_5ghz_ch_freq(uint32_t freq); 412 413 /** 414 * reg_is_range_overlap_2g() - Check if the given low_freq and high_freq 415 * is in the 2G range. 416 * 417 * @low_freq - Low frequency. 418 * @high_freq - High frequency. 419 * 420 * Return: Return true if given low_freq and high_freq overlaps 2G range, 421 * else false. 422 */ 423 bool reg_is_range_overlap_2g(qdf_freq_t low_freq, qdf_freq_t high_freq); 424 425 /** 426 * reg_is_range_overlap_5g() - Check if the given low_freq and high_freq 427 * is in the 5G range. 428 * 429 * @low_freq - Low frequency. 430 * @high_freq - High frequency. 431 * 432 * Return: Return true if given low_freq and high_freq overlaps 5G range, 433 * else false. 434 */ 435 bool reg_is_range_overlap_5g(qdf_freq_t low_freq, qdf_freq_t high_freq); 436 437 /** 438 * reg_is_freq_indoor() - Check if the input frequency is an indoor frequency. 439 * @pdev: Pointer to pdev. 440 * @freq: Channel frequency. 441 * 442 * Return: Return true if the input frequency is indoor, else false. 443 */ 444 bool reg_is_freq_indoor(struct wlan_objmgr_pdev *pdev, qdf_freq_t freq); 445 446 #ifdef CONFIG_REG_CLIENT 447 /** 448 * reg_is_freq_indoor_in_secondary_list() - Check if the input frequency is 449 * an indoor frequency in the secondary channel list 450 * @pdev: Pointer to pdev. 451 * @freq: Channel frequency. 452 * 453 * Return: Return true if the input frequency is indoor, else false. 454 */ 455 bool reg_is_freq_indoor_in_secondary_list(struct wlan_objmgr_pdev *pdev, 456 qdf_freq_t freq); 457 #endif 458 459 #ifdef CONFIG_BAND_6GHZ 460 /** 461 * reg_is_6ghz_chan_freq() - Check if the given channel frequency is 6GHz 462 * @freq: Channel frequency 463 * 464 * Return: true if channel frequency is 6GHz, else false 465 */ 466 bool reg_is_6ghz_chan_freq(uint16_t freq); 467 468 #ifdef CONFIG_6G_FREQ_OVERLAP 469 /** 470 * reg_is_range_only6g() - Check if the given low_freq and high_freq is only in 471 * the 6G range. 472 * 473 * @low_freq - Low frequency. 474 * @high_freq - High frequency. 475 * 476 * Return: Return true if given low_freq and high_freq overlaps only the 6G 477 * range, else false. 478 */ 479 bool reg_is_range_only6g(qdf_freq_t low_freq, qdf_freq_t high_freq); 480 481 /** 482 * reg_is_range_overlap_6g() - Check if the given low_freq and high_freq 483 * is in the 6G range. 484 * 485 * @low_freq - Low frequency. 486 * @high_freq - High frequency. 487 * 488 * Return: Return true if given low_freq and high_freq overlaps 6G range, 489 * else false. 490 */ 491 bool reg_is_range_overlap_6g(qdf_freq_t low_freq, qdf_freq_t high_freq); 492 #endif 493 494 /** 495 * REG_IS_6GHZ_FREQ() - Check if the given channel frequency is 6GHz 496 * @freq: Channel frequency 497 * 498 * Return: true if channel frequency is 6GHz, else false 499 */ 500 static inline bool REG_IS_6GHZ_FREQ(uint16_t freq) 501 { 502 return ((freq >= REG_MIN_6GHZ_CHAN_FREQ) && 503 (freq <= REG_MAX_6GHZ_CHAN_FREQ)); 504 } 505 506 /** 507 * reg_is_6ghz_psc_chan_freq() - Check if the given 6GHz channel frequency is 508 * preferred scanning channel frequency. 509 * @freq: Channel frequency 510 * 511 * Return: true if given 6GHz channel frequency is preferred scanning channel 512 * frequency, else false 513 */ 514 bool reg_is_6ghz_psc_chan_freq(uint16_t freq); 515 516 /** 517 * reg_is_6g_freq_indoor() - Check if a 6GHz frequency is indoor. 518 * @pdev: Pointer to pdev. 519 * @freq: Channel frequency. 520 * 521 * Return: Return true if a 6GHz frequency is indoor, else false. 522 */ 523 bool reg_is_6g_freq_indoor(struct wlan_objmgr_pdev *pdev, qdf_freq_t freq); 524 525 /** 526 * reg_get_max_txpower_for_6g_tpe() - Get max txpower for 6G TPE IE. 527 * @pdev: Pointer to pdev. 528 * @freq: Channel frequency. 529 * @bw: Channel bandwidth. 530 * @reg_ap: Regulatory 6G AP type. 531 * @reg_client: Regulatory 6G client type. 532 * @is_psd: True if txpower is needed in PSD format, and false if needed in EIRP 533 * format. 534 * @tx_power: Pointer to tx-power. 535 * 536 * Return: Return QDF_STATUS_SUCCESS, if tx_power is filled for 6G TPE IE 537 * else return QDF_STATUS_E_FAILURE. 538 */ 539 QDF_STATUS reg_get_max_txpower_for_6g_tpe(struct wlan_objmgr_pdev *pdev, 540 qdf_freq_t freq, uint8_t bw, 541 enum reg_6g_ap_type reg_ap, 542 enum reg_6g_client_type reg_client, 543 bool is_psd, 544 uint8_t *tx_power); 545 546 /** 547 * reg_min_6ghz_chan_freq() - Get minimum 6GHz channel center frequency 548 * 549 * Return: Minimum 6GHz channel center frequency 550 */ 551 uint16_t reg_min_6ghz_chan_freq(void); 552 553 /** 554 * reg_max_6ghz_chan_freq() - Get maximum 6GHz channel center frequency 555 * 556 * Return: Maximum 6GHz channel center frequency 557 */ 558 uint16_t reg_max_6ghz_chan_freq(void); 559 #else 560 static inline bool reg_is_6ghz_chan_freq(uint16_t freq) 561 { 562 return false; 563 } 564 565 static inline bool 566 reg_is_6g_freq_indoor(struct wlan_objmgr_pdev *pdev, qdf_freq_t freq) 567 { 568 return false; 569 } 570 571 static inline QDF_STATUS 572 reg_get_max_txpower_for_6g_tpe(struct wlan_objmgr_pdev *pdev, 573 qdf_freq_t freq, uint8_t bw, 574 enum reg_6g_ap_type reg_ap, 575 enum reg_6g_client_type reg_client, 576 bool is_psd, 577 uint8_t *tx_power) 578 { 579 return QDF_STATUS_E_FAILURE; 580 } 581 582 #ifdef CONFIG_6G_FREQ_OVERLAP 583 static inline bool reg_is_range_overlap_6g(qdf_freq_t low_freq, 584 qdf_freq_t high_freq) 585 { 586 return false; 587 } 588 589 static inline bool reg_is_range_only6g(qdf_freq_t low_freq, 590 qdf_freq_t high_freq) 591 { 592 return false; 593 } 594 #endif 595 596 static inline bool REG_IS_6GHZ_FREQ(uint16_t freq) 597 { 598 return false; 599 } 600 601 static inline bool reg_is_6ghz_psc_chan_freq(uint16_t freq) 602 { 603 return false; 604 } 605 606 static inline uint16_t reg_min_6ghz_chan_freq(void) 607 { 608 return 0; 609 } 610 611 static inline uint16_t reg_max_6ghz_chan_freq(void) 612 { 613 return 0; 614 } 615 #endif /* CONFIG_BAND_6GHZ */ 616 617 /** 618 * reg_get_band_channel_list() - Caller function to 619 * reg_get_band_from_cur_chan_list with primary current channel list 620 * @pdev: pdev ptr 621 * @band_mask: Input bitmap with band set 622 * @channel_list: Pointer to Channel List 623 * 624 * Caller function to reg_get_band_from_cur_chan_listto get the primary channel 625 * list and number of channels (for non-beaconing entities). 626 * 627 * Return: Number of channels, else 0 to indicate error 628 */ 629 uint16_t reg_get_band_channel_list(struct wlan_objmgr_pdev *pdev, 630 uint8_t band_mask, 631 struct regulatory_channel *channel_list); 632 633 #ifdef CONFIG_REG_CLIENT 634 /** 635 * reg_get_secondary_band_channel_list() - Caller function to 636 * reg_get_band_from_cur_chan_list with secondary current channel list 637 * @pdev: pdev ptr 638 * @band_mask: Input bitmap with band set 639 * @channel_list: Pointer to Channel List 640 * 641 * Caller function to reg_get_band_from_cur_chan_list to get the secondary 642 * channel list and number of channels (for beaconing entities). 643 * 644 * Return: Number of channels, else 0 to indicate error 645 */ 646 uint16_t reg_get_secondary_band_channel_list(struct wlan_objmgr_pdev *pdev, 647 uint8_t band_mask, 648 struct regulatory_channel 649 *channel_list); 650 #endif 651 652 /** 653 * reg_chan_band_to_freq - Return channel frequency based on the channel number 654 * and band. 655 * @pdev: pdev ptr 656 * @chan: Channel Number 657 * @band_mask: Bitmap for bands 658 * 659 * Return: Return channel frequency or return 0, if the channel is disabled or 660 * if the input channel number or band_mask is invalid. Composite bands are 661 * supported only for 2.4Ghz and 5Ghz bands. For other bands the following 662 * priority is given: 1) 6Ghz 2) 5Ghz 3) 2.4Ghz. 663 */ 664 qdf_freq_t reg_chan_band_to_freq(struct wlan_objmgr_pdev *pdev, 665 uint8_t chan, 666 uint8_t band_mask); 667 668 /** 669 * reg_is_49ghz_freq() - Check if the given channel frequency is 4.9GHz 670 * @freq: Channel frequency 671 * 672 * Return: true if channel frequency is 4.9GHz, else false 673 */ 674 bool reg_is_49ghz_freq(qdf_freq_t freq); 675 676 /** 677 * reg_ch_num() - Get channel number from channel enum 678 * @ch_enum: Channel enum 679 * 680 * Return: channel number 681 */ 682 qdf_freq_t reg_ch_num(uint32_t ch_enum); 683 684 /** 685 * reg_ch_to_freq() - Get channel frequency from channel enum 686 * @ch_enum: Channel enum 687 * 688 * Return: channel frequency 689 */ 690 qdf_freq_t reg_ch_to_freq(uint32_t ch_enum); 691 692 /** 693 * reg_max_5ghz_ch_num() - Get maximum 5GHz channel number 694 * 695 * Return: Maximum 5GHz channel number 696 */ 697 uint8_t reg_max_5ghz_ch_num(void); 698 699 #ifdef CONFIG_CHAN_FREQ_API 700 /** 701 * reg_min_24ghz_chan_freq() - Get minimum 2.4GHz channel frequency 702 * 703 * Return: Minimum 2.4GHz channel frequency 704 */ 705 qdf_freq_t reg_min_24ghz_chan_freq(void); 706 707 /** 708 * reg_max_24ghz_chan_freq() - Get maximum 2.4GHz channel frequency 709 * 710 * Return: Maximum 2.4GHz channel frequency 711 */ 712 qdf_freq_t reg_max_24ghz_chan_freq(void); 713 714 /** 715 * reg_min_5ghz_chan_freq() - Get minimum 5GHz channel frequency 716 * 717 * Return: Minimum 5GHz channel frequency 718 */ 719 qdf_freq_t reg_min_5ghz_chan_freq(void); 720 721 /** 722 * reg_max_5ghz_chan_freq() - Get maximum 5GHz channel frequency 723 * 724 * Return: Maximum 5GHz channel frequency 725 */ 726 qdf_freq_t reg_max_5ghz_chan_freq(void); 727 #endif /* CONFIG_CHAN_FREQ_API */ 728 729 /** 730 * reg_enable_dfs_channels() - Enable the use of DFS channels 731 * @pdev: The physical dev to enable/disable DFS channels for 732 * 733 * Return: QDF_STATUS 734 */ 735 QDF_STATUS reg_enable_dfs_channels(struct wlan_objmgr_pdev *pdev, bool enable); 736 737 /** 738 * reg_is_regdmn_en302502_applicable() - Find if ETSI EN302_502 radar pattern 739 * is applicable in current regulatory domain. 740 * @pdev: Pdev object pointer. 741 * 742 * Return: True if en302_502 is applicable, else false. 743 */ 744 bool reg_is_regdmn_en302502_applicable(struct wlan_objmgr_pdev *pdev); 745 746 /** 747 * reg_modify_pdev_chan_range() - Compute current channel list 748 * in accordance with the modified reg caps. 749 * @pdev: The physical dev for which channel list must be built. 750 * 751 * Return: QDF_STATUS 752 */ 753 QDF_STATUS reg_modify_pdev_chan_range(struct wlan_objmgr_pdev *pdev); 754 755 /** 756 * reg_update_pdev_wireless_modes() - Update the wireless_modes in the 757 * pdev_priv_obj with the input wireless_modes 758 * @pdev: pointer to wlan_objmgr_pdev. 759 * @wireless_modes: Wireless modes. 760 * 761 * Return : QDF_STATUS 762 */ 763 QDF_STATUS reg_update_pdev_wireless_modes(struct wlan_objmgr_pdev *pdev, 764 uint32_t wireless_modes); 765 766 /** 767 * reg_get_phybitmap() - Get phybitmap from regulatory pdev_priv_obj 768 * @pdev: pdev pointer 769 * @phybitmap: pointer to phybitmap 770 * 771 * Return: QDF STATUS 772 */ 773 QDF_STATUS reg_get_phybitmap(struct wlan_objmgr_pdev *pdev, 774 uint16_t *phybitmap); 775 #ifdef DISABLE_UNII_SHARED_BANDS 776 /** 777 * reg_disable_chan_coex() - Disable Coexisting channels based on the input 778 * bitmask. 779 * @pdev: pointer to wlan_objmgr_pdev. 780 * unii_5g_bitmap: UNII 5G bitmap. 781 * 782 * Return : QDF_STATUS 783 */ 784 QDF_STATUS reg_disable_chan_coex(struct wlan_objmgr_pdev *pdev, 785 uint8_t unii_5g_bitmap); 786 #endif 787 788 #ifdef CONFIG_CHAN_FREQ_API 789 /** 790 * reg_is_freq_present_in_cur_chan_list() - Check the input frequency 791 * @pdev: Pointer to pdev 792 * @freq: Channel center frequency in MHz 793 * 794 * Check if the input channel center frequency is present in the current 795 * channel list 796 * 797 * Return: Return true if channel center frequency is present in the current 798 * channel list, else return false. 799 */ 800 bool 801 reg_is_freq_present_in_cur_chan_list(struct wlan_objmgr_pdev *pdev, 802 qdf_freq_t freq); 803 804 /** 805 * reg_get_chan_enum_for_freq() - Get channel enum for given channel frequency 806 * @freq: Channel Frequency 807 * 808 * Return: Channel enum 809 */ 810 enum channel_enum reg_get_chan_enum_for_freq(qdf_freq_t freq); 811 812 /** 813 * reg_get_channel_list_with_power_for_freq() - Provides the channel list with 814 * power 815 * @pdev: Pointer to pdev 816 * @ch_list: Pointer to the channel list. 817 * @num_chan: Pointer to save number of channels 818 * 819 * Return: QDF_STATUS 820 */ 821 QDF_STATUS 822 reg_get_channel_list_with_power_for_freq(struct wlan_objmgr_pdev *pdev, 823 struct channel_power *ch_list, 824 uint8_t *num_chan); 825 826 /** 827 * reg_get_channel_state_for_freq() - Get channel state from regulatory 828 * @pdev: Pointer to pdev 829 * @freq: channel center frequency. 830 * 831 * Return: channel state 832 */ 833 enum channel_state reg_get_channel_state_for_freq(struct wlan_objmgr_pdev *pdev, 834 qdf_freq_t freq); 835 836 #ifdef CONFIG_REG_CLIENT 837 /** 838 * reg_get_channel_state_from_secondary_list_for_freq() - Get channel state 839 * from secondary regulatory current channel list 840 * @pdev: Pointer to pdev 841 * @freq: channel center frequency. 842 * 843 * Return: channel state 844 */ 845 enum channel_state reg_get_channel_state_from_secondary_list_for_freq( 846 struct wlan_objmgr_pdev *pdev, 847 qdf_freq_t freq); 848 #endif 849 850 /** 851 * reg_get_5g_bonded_channel_state_for_freq() - Get channel state for 852 * 5G bonded channel using the channel frequency 853 * @pdev: Pointer to pdev 854 * @freq: channel center frequency. 855 * @bw: channel band width 856 * 857 * Return: channel state 858 */ 859 enum channel_state 860 reg_get_5g_bonded_channel_state_for_freq(struct wlan_objmgr_pdev *pdev, 861 qdf_freq_t freq, 862 enum phy_ch_width bw); 863 864 /** 865 * reg_get_2g_bonded_channel_state_for_freq() - Get channel state for 2G 866 * bonded channel 867 * @freq: channel center frequency. 868 * @pdev: Pointer to pdev 869 * @oper_ch_freq: Primary channel center frequency 870 * @sec_ch_freq: Secondary channel center frequency 871 * @bw: channel band width 872 * 873 * Return: channel state 874 */ 875 enum channel_state 876 reg_get_2g_bonded_channel_state_for_freq(struct wlan_objmgr_pdev *pdev, 877 qdf_freq_t oper_ch_freq, 878 qdf_freq_t sec_ch_freq, 879 enum phy_ch_width bw); 880 881 /** 882 * reg_set_channel_params_for_freq () - Sets channel parameteres for given 883 * bandwidth 884 * @pdev: Pointer to pdev 885 * @freq: Channel center frequency. 886 * @sec_ch_2g_freq: Secondary 2G channel frequency 887 * @ch_params: pointer to the channel parameters. 888 * 889 * Return: None 890 */ 891 void reg_set_channel_params_for_freq(struct wlan_objmgr_pdev *pdev, 892 qdf_freq_t freq, 893 qdf_freq_t sec_ch_2g_freq, 894 struct ch_params *ch_params); 895 896 /** 897 * reg_fill_channel_list() - Fills an array of ch_params (list of 898 * channels) for the given channel width and primary freq. 899 * If 320 band_center is given, ch_params corresponding to the 900 * given band_center is filled. 901 * 902 * @pdev: Pointer to pdev 903 * @freq: Center frequency of the primary channel in MHz 904 * @sec_ch_2g_freq: Secondary 2G channel frequency in MHZ 905 * @ch_width: Input channel width. 906 * @band_center: Center frequency of the 320MHZ channel. 907 * @chan_list: Pointer to struct reg_channel_list to be filled (Output). 908 * The caller is supposed to provide enough storage for the elements 909 * in the list. 910 * 911 * Return: None 912 */ 913 #ifdef WLAN_FEATURE_11BE 914 void 915 reg_fill_channel_list(struct wlan_objmgr_pdev *pdev, 916 qdf_freq_t freq, 917 qdf_freq_t sec_ch_2g_freq, 918 enum phy_ch_width ch_width, 919 qdf_freq_t band_center_320, 920 struct reg_channel_list *chan_list); 921 #endif 922 /** 923 * reg_get_channel_reg_power_for_freq() - Get the txpower for the given channel 924 * @pdev: Pointer to pdev 925 * @freq: Channel frequency 926 * 927 * Return: txpower 928 */ 929 uint8_t reg_get_channel_reg_power_for_freq(struct wlan_objmgr_pdev *pdev, 930 qdf_freq_t freq); 931 932 /** 933 * reg_update_nol_ch_for_freq () - Updates NOL channels in current channel list 934 * @pdev: pointer to pdev object 935 * @chan_freq_list: pointer to NOL channel list 936 * @num_ch: No.of channels in list 937 * @update_nol: set/reset the NOL status 938 * 939 * Return: None 940 */ 941 void reg_update_nol_ch_for_freq(struct wlan_objmgr_pdev *pdev, 942 uint16_t *chan_freq_list, 943 uint8_t num_chan, 944 bool nol_chan); 945 /** 946 * reg_is_dfs_for_freq () - Checks the channel state for DFS 947 * @pdev: pdev ptr 948 * @freq: Channel center frequency 949 * 950 * Return: true or false 951 */ 952 bool reg_is_dfs_for_freq(struct wlan_objmgr_pdev *pdev, qdf_freq_t freq); 953 954 #ifdef CONFIG_REG_CLIENT 955 /** 956 * reg_is_dfs_in_secondary_list_for_freq() - Checks the channel state for DFS 957 * from the secondary channel list 958 * @pdev: pdev ptr 959 * @freq: Channel center frequency 960 * 961 * Return: true or false 962 */ 963 bool reg_is_dfs_in_secondary_list_for_freq(struct wlan_objmgr_pdev *pdev, 964 qdf_freq_t freq); 965 #endif 966 967 /** 968 * reg_chan_freq_is_49ghz() - Check if the input channel center frequency is 969 * 4.9GHz 970 * @pdev: Pdev pointer 971 * @chan_num: Input channel center frequency 972 * 973 * Return: true if the frequency is 4.9GHz else false. 974 */ 975 bool reg_chan_freq_is_49ghz(qdf_freq_t freq); 976 977 /** 978 * reg_update_nol_history_ch_for_freq() - Set nol-history flag for the channels 979 * in the list. 980 * @pdev: Pdev ptr. 981 * @chan_list: Input channel freqeuncy list. 982 * @num_ch: Number of channels. 983 * @nol_history_ch: NOL-History flag. 984 * 985 * Return: void 986 */ 987 void reg_update_nol_history_ch_for_freq(struct wlan_objmgr_pdev *pdev, 988 uint16_t *chan_list, 989 uint8_t num_chan, 990 bool nol_history_chan); 991 992 /** 993 * reg_is_same_5g_band_freqs() - Check if given channel center 994 * frequencies have same band 995 * @freq1: Channel Center Frequency 1 996 * @freq2: Channel Center Frequency 2 997 * 998 * Return: true if both the frequencies has the same band. 999 */ 1000 bool reg_is_same_band_freqs(qdf_freq_t freq1, qdf_freq_t freq2); 1001 1002 /** 1003 * reg_is_frequency_valid_5g_sbs() Check if the given frequency is 5G SBS. 1004 * @curfreq: current channel frequency 1005 * @newfreq: new channel center frequency 1006 * 1007 * Return: true if the given center frequency is a valid 5G SBS 1008 */ 1009 bool reg_is_frequency_valid_5g_sbs(qdf_freq_t curfreq, qdf_freq_t newfreq); 1010 1011 /** 1012 * reg_freq_to_band() - Get band from channel frequency 1013 * @chan_num: channel frequency 1014 * 1015 * Return: wifi band 1016 */ 1017 enum reg_wifi_band reg_freq_to_band(qdf_freq_t freq); 1018 1019 /** 1020 * reg_min_chan_freq() - minimum channel frequency supported 1021 * 1022 * Return: channel frequency 1023 */ 1024 qdf_freq_t reg_min_chan_freq(void); 1025 1026 /** 1027 * reg_max_chan_freq() - maximum channel frequency supported 1028 * 1029 * Return: channel frequency 1030 */ 1031 qdf_freq_t reg_max_chan_freq(void); 1032 1033 /** 1034 * reg_get_5g_bonded_channel_for_freq()- Return the channel state for a 1035 * 5G or 6G channel frequency based on the channel width and bonded channel 1036 * @pdev: Pointer to pdev. 1037 * @freq: Channel center frequency. 1038 * @ch_width: Channel Width. 1039 * @bonded_chan_ptr_ptr: Pointer to bonded_channel_freq. 1040 * 1041 * Return: Channel State 1042 */ 1043 enum channel_state 1044 reg_get_5g_bonded_channel_for_freq(struct wlan_objmgr_pdev *pdev, 1045 uint16_t freq, 1046 enum phy_ch_width ch_width, 1047 const struct bonded_channel_freq 1048 **bonded_chan_ptr_ptr); 1049 1050 /** 1051 * reg_is_disable_for_freq() - Check if the given channel frequency in 1052 * disable state 1053 * @pdev: Pointer to pdev 1054 * @freq: Channel frequency 1055 * 1056 * Return: True if channel state is disabled, else false 1057 */ 1058 bool reg_is_disable_for_freq(struct wlan_objmgr_pdev *pdev, qdf_freq_t freq); 1059 1060 #ifdef CONFIG_REG_CLIENT 1061 /** 1062 * reg_is_disable_in_secondary_list_for_freq() - Check if the given channel 1063 * frequency is in disable state 1064 * @pdev: Pointer to pdev 1065 * @freq: Channel frequency 1066 * 1067 * Return: True if channel state is disabled, else false 1068 */ 1069 bool reg_is_disable_in_secondary_list_for_freq(struct wlan_objmgr_pdev *pdev, 1070 qdf_freq_t freq); 1071 #endif 1072 1073 /** 1074 * reg_is_passive_for_freq() - Check if the given channel frequency is in 1075 * passive state 1076 * @pdev: Pointer to pdev 1077 * @freq: Channel frequency 1078 * 1079 * Return: True if channel state is passive, else false 1080 */ 1081 bool reg_is_passive_for_freq(struct wlan_objmgr_pdev *pdev, qdf_freq_t freq); 1082 #endif /* CONFIG_CHAN_FREQ_API */ 1083 1084 /** 1085 * reg_get_max_tx_power() - Get maximum tx power from the current channel list 1086 * @pdev: Pointer to pdev 1087 * 1088 * Return: return the value of the maximum tx power in the current channel list 1089 * 1090 */ 1091 uint8_t reg_get_max_tx_power(struct wlan_objmgr_pdev *pdev); 1092 1093 /** 1094 * reg_set_ignore_fw_reg_offload_ind() - Set if regdb offload indication 1095 * needs to be ignored 1096 * @psoc: Pointer to psoc 1097 * 1098 * Return: QDF_STATUS 1099 */ 1100 QDF_STATUS reg_set_ignore_fw_reg_offload_ind(struct wlan_objmgr_psoc *psoc); 1101 1102 /** 1103 * reg_get_ignore_fw_reg_offload_ind() - Check whether regdb offload indication 1104 * needs to be ignored 1105 * 1106 * @psoc: Pointer to psoc 1107 */ 1108 bool reg_get_ignore_fw_reg_offload_ind(struct wlan_objmgr_psoc *psoc); 1109 1110 /** 1111 * reg_set_6ghz_supported() - Set if 6ghz is supported 1112 * 1113 * @psoc: Pointer to psoc 1114 * @val: value 1115 */ 1116 QDF_STATUS reg_set_6ghz_supported(struct wlan_objmgr_psoc *psoc, 1117 bool val); 1118 1119 /** 1120 * reg_set_5dot9_ghz_supported() - Set if 5.9ghz is supported 1121 * 1122 * @psoc: Pointer to psoc 1123 * @val: value 1124 */ 1125 QDF_STATUS reg_set_5dot9_ghz_supported(struct wlan_objmgr_psoc *psoc, 1126 bool val); 1127 1128 /** 1129 * reg_is_6ghz_op_class() - Check whether 6ghz oper class 1130 * 1131 * @pdev: Pointer to pdev 1132 * @op_class: oper class 1133 */ 1134 bool reg_is_6ghz_op_class(struct wlan_objmgr_pdev *pdev, 1135 uint8_t op_class); 1136 1137 #ifdef CONFIG_REG_CLIENT 1138 /** 1139 * reg_is_6ghz_supported() - Whether 6ghz is supported 1140 * 1141 * @psoc: pointer to psoc 1142 */ 1143 bool reg_is_6ghz_supported(struct wlan_objmgr_psoc *psoc); 1144 #endif 1145 1146 /** 1147 * reg_is_5dot9_ghz_supported() - Whether 5.9ghz is supported 1148 * 1149 * @psoc: pointer to psoc 1150 */ 1151 bool reg_is_5dot9_ghz_supported(struct wlan_objmgr_psoc *psoc); 1152 1153 /** 1154 * reg_is_fcc_regdmn () - Checks if the current reg domain is FCC3/FCC8/FCC15/ 1155 * FCC16 or not 1156 * @pdev: pdev ptr 1157 * 1158 * Return: true or false 1159 */ 1160 bool reg_is_fcc_regdmn(struct wlan_objmgr_pdev *pdev); 1161 1162 /** 1163 * reg_is_5dot9_ghz_freq () - Checks if the frequency is 5.9 GHz freq or not 1164 * @freq: frequency 1165 * @pdev: pdev ptr 1166 * 1167 * Return: true or false 1168 */ 1169 bool reg_is_5dot9_ghz_freq(struct wlan_objmgr_pdev *pdev, qdf_freq_t freq); 1170 1171 /** 1172 * reg_is_5dot9_ghz_chan_allowed_master_mode () - Checks if 5.9 GHz channels 1173 * are allowed in master mode or not. 1174 * 1175 * @pdev: pdev ptr 1176 * 1177 * Return: true or false 1178 */ 1179 bool reg_is_5dot9_ghz_chan_allowed_master_mode(struct wlan_objmgr_pdev *pdev); 1180 1181 /** 1182 * reg_get_unii_5g_bitmap() - get unii_5g_bitmap value 1183 * @pdev: pdev pointer 1184 * @bitmap: Pointer to retrieve the unii_5g_bitmap of enum reg_unii_band 1185 * 1186 * Return: QDF_STATUS 1187 */ 1188 #ifdef DISABLE_UNII_SHARED_BANDS 1189 QDF_STATUS 1190 reg_get_unii_5g_bitmap(struct wlan_objmgr_pdev *pdev, uint8_t *bitmap); 1191 #endif 1192 1193 #ifdef CHECK_REG_PHYMODE 1194 /** 1195 * reg_get_max_phymode() - Recursively find the best possible phymode given a 1196 * phymode, a frequency, and per-country regulations 1197 * @pdev: pdev pointer 1198 * @phy_in: phymode that the user requested 1199 * @freq: current operating center frequency 1200 * 1201 * Return: maximum phymode allowed in current country that is <= phy_in 1202 */ 1203 enum reg_phymode reg_get_max_phymode(struct wlan_objmgr_pdev *pdev, 1204 enum reg_phymode phy_in, 1205 qdf_freq_t freq); 1206 #else 1207 static inline enum reg_phymode 1208 reg_get_max_phymode(struct wlan_objmgr_pdev *pdev, 1209 enum reg_phymode phy_in, 1210 qdf_freq_t freq) 1211 { 1212 return REG_PHYMODE_INVALID; 1213 } 1214 #endif /* CHECK_REG_PHYMODE */ 1215 1216 #ifdef CONFIG_REG_CLIENT 1217 /** 1218 * reg_band_bitmap_to_band_info() - Convert the band_bitmap to a band_info enum. 1219 * Since band_info enum only has combinations for 2G and 5G, 6G is not 1220 * considered in this function. 1221 * @band_bitmap: bitmap on top of reg_wifi_band of bands enabled 1222 * 1223 * Return: BAND_ALL if both 2G and 5G band is enabled 1224 * BAND_2G if 2G is enabled but 5G isn't 1225 * BAND_5G if 5G is enabled but 2G isn't 1226 */ 1227 enum band_info reg_band_bitmap_to_band_info(uint32_t band_bitmap); 1228 #endif 1229 1230 #if defined(CONFIG_BAND_6GHZ) 1231 /** 1232 * reg_set_cur_6g_ap_pwr_type() - Set the current 6G regulatory AP power type. 1233 * @pdev: Pointer to PDEV object. 1234 * @reg_6g_ap_type: Regulatory 6G AP type ie VLPI/LPI/SP. 1235 * 1236 * Return: QDF_STATUS_E_INVAL if unable to set and QDF_STATUS_SUCCESS is set. 1237 */ 1238 QDF_STATUS 1239 reg_set_cur_6g_ap_pwr_type(struct wlan_objmgr_pdev *pdev, 1240 enum reg_6g_ap_type reg_cur_6g_ap_pwr_type); 1241 1242 /** 1243 * reg_get_cur_6g_ap_pwr_type() - Get the current 6G regulatory AP power type. 1244 * @reg_6g_ap_pwr_type: The current regulatory 6G AP type ie VLPI/LPI/SP. 1245 * subordinate. 1246 * 1247 * Return: QDF_STATUS. 1248 */ 1249 QDF_STATUS 1250 reg_get_cur_6g_ap_pwr_type(struct wlan_objmgr_pdev *pdev, 1251 enum reg_6g_ap_type *reg_cur_6g_ap_pwr_type); 1252 1253 #ifdef CONFIG_AFC_SUPPORT 1254 /** 1255 * reg_afc_start() - Start the AFC request from regulatory. This finally 1256 * sends the request to registered callbacks 1257 * @pdev: Pointer to pdev 1258 * @req_id: The AFC request ID 1259 * 1260 * Return: QDF_STATUS 1261 */ 1262 QDF_STATUS reg_afc_start(struct wlan_objmgr_pdev *pdev, uint64_t req_id); 1263 1264 /** 1265 * reg_get_partial_afc_req_info() - Get the AFC partial request information 1266 * @pdev: Pointer to pdev 1267 * @afc_req: Address of AFC request pointer 1268 * 1269 * NOTE:- The memory for AFC request is allocated by the function must be 1270 * freed by the caller. 1271 * Return: QDF_STATUS 1272 */ 1273 QDF_STATUS 1274 reg_get_partial_afc_req_info(struct wlan_objmgr_pdev *pdev, 1275 struct wlan_afc_host_partial_request **afc_req); 1276 1277 /** 1278 * reg_print_partial_afc_req_info() - Print the AFC partial request 1279 * information 1280 * @pdev: Pointer to pdev 1281 * @afc_req: Pointer to AFC request 1282 * 1283 * Return: Void 1284 */ 1285 void 1286 reg_print_partial_afc_req_info(struct wlan_objmgr_pdev *pdev, 1287 struct wlan_afc_host_partial_request *afc_req); 1288 1289 /** 1290 * reg_register_afc_req_rx_callback () - add AFC request received callback 1291 * @pdev: Pointer to pdev 1292 * @cbf: Pointer to callback handler 1293 * @arg: Pointer to opaque argument 1294 * 1295 * Return: QDF_STATUS 1296 */ 1297 QDF_STATUS reg_register_afc_req_rx_callback(struct wlan_objmgr_pdev *pdev, 1298 afc_req_rx_evt_handler cbf, 1299 void *arg); 1300 1301 /** 1302 * reg_unregister_afc_req_rx_callback () - remove AFC request received 1303 * callback 1304 * @pdev: Pointer to pdev 1305 * @cbf: Pointer to callback handler 1306 * 1307 * Return: QDF_STATUS 1308 */ 1309 QDF_STATUS reg_unregister_afc_req_rx_callback(struct wlan_objmgr_pdev *pdev, 1310 afc_req_rx_evt_handler cbf); 1311 #endif 1312 1313 /** 1314 * reg_get_cur_6g_client_type() - Get the current 6G regulatory client Type. 1315 * @pdev: Pointer to PDEV object. 1316 * @reg_cur_6g_client_mobility_type: The current regulatory 6G client type ie. 1317 * default/subordinate. 1318 * 1319 * Return: QDF_STATUS. 1320 */ 1321 QDF_STATUS 1322 reg_get_cur_6g_client_type(struct wlan_objmgr_pdev *pdev, 1323 enum reg_6g_client_type 1324 *reg_cur_6g_client_mobility_type); 1325 1326 /** 1327 * reg_get_rnr_tpe_usable() - Tells if RNR IE is applicable for current domain. 1328 * @pdev: Pointer to PDEV object. 1329 * @reg_rnr_tpe_usable: Pointer to hold the bool value, true if RNR IE is 1330 * applicable, else false. 1331 * 1332 * Return: QDF_STATUS. 1333 */ 1334 QDF_STATUS reg_get_rnr_tpe_usable(struct wlan_objmgr_pdev *pdev, 1335 bool *reg_rnr_tpe_usable); 1336 1337 /** 1338 * reg_get_unspecified_ap_usable() - Tells if AP type unspecified by 802.11 can 1339 * be used or not. 1340 * @pdev: Pointer to PDEV object. 1341 * @reg_unspecified_ap_usable: Pointer to hold the bool value, true if 1342 * unspecified AP types can be used in the IE, else false. 1343 * 1344 * Return: QDF_STATUS. 1345 */ 1346 QDF_STATUS reg_get_unspecified_ap_usable(struct wlan_objmgr_pdev *pdev, 1347 bool *reg_unspecified_ap_usable); 1348 1349 /** 1350 * reg_is_6g_psd_power() - Checks if pdev has PSD power 1351 * 1352 * @pdev: pdev ptr 1353 * 1354 * Return: true if PSD power or false otherwise 1355 */ 1356 bool reg_is_6g_psd_power(struct wlan_objmgr_pdev *pdev); 1357 1358 /** 1359 * reg_get_6g_chan_ap_power() - Finds the TX power for the given channel 1360 * frequency, taking the AP's current power level into account 1361 * 1362 * @pdev: pdev ptr 1363 * @chan_freq: channel frequency 1364 * @is_psd: is channel PSD or not 1365 * @tx_power: transmit power to fill for chan_freq 1366 * @eirp_psd_power: EIRP PSD power, will only be filled if is_psd is true 1367 * 1368 * Return: QDF_STATUS 1369 */ 1370 QDF_STATUS reg_get_6g_chan_ap_power(struct wlan_objmgr_pdev *pdev, 1371 qdf_freq_t chan_freq, bool *is_psd, 1372 uint16_t *tx_power, 1373 uint16_t *eirp_psd_power); 1374 1375 /** 1376 * reg_get_client_power_for_connecting_ap() - Find the channel information when 1377 * device is operating as a client 1378 * 1379 * @pdev: pdev ptr 1380 * @ap_type: type of AP that device is connected to 1381 * @chan_freq: channel frequency 1382 * @is_psd: is channel PSD or not 1383 * @tx_power: transmit power to fill for chan_freq 1384 * @eirp_psd_power: EIRP power, will only be filled if is_psd is true 1385 * 1386 * This function is meant to be called to find the channel frequency power 1387 * information for a client when the device is operating as a client. It will 1388 * fill in the parameter is_psd, tx_power, and eirp_psd_power. eirp_psd_power 1389 * will only be filled if the channel is PSD. 1390 * 1391 * Return: QDF_STATUS 1392 */ 1393 QDF_STATUS reg_get_client_power_for_connecting_ap(struct wlan_objmgr_pdev *pdev, 1394 enum reg_6g_ap_type ap_type, 1395 qdf_freq_t chan_freq, 1396 bool *is_psd, 1397 uint16_t *tx_power, 1398 uint16_t *eirp_psd_power); 1399 1400 /** 1401 * reg_get_client_power_for_6ghz_ap() - Find the channel information when 1402 * device is operating as a 6GHz AP 1403 * 1404 * @pdev: pdev ptr 1405 * @client_type: type of client that is connected to our AP 1406 * @chan_freq: channel frequency 1407 * @is_psd: is channel PSD or not 1408 * @tx_power: transmit power to fill for chan_freq 1409 * @eirp_psd_power: EIRP power, will only be filled if is_psd is true 1410 * 1411 * This function is meant to be called to find the channel frequency power 1412 * information for a client when the device is operating as an AP. It will fill 1413 * in the parameter is_psd, tx_power, and eirp_psd_power. eirp_psd_power will 1414 * only be filled if the channel is PSD. 1415 * 1416 * Return: QDF_STATUS 1417 */ 1418 QDF_STATUS reg_get_client_power_for_6ghz_ap(struct wlan_objmgr_pdev *pdev, 1419 enum reg_6g_client_type client_type, 1420 qdf_freq_t chan_freq, 1421 bool *is_psd, uint16_t *tx_power, 1422 uint16_t *eirp_psd_power); 1423 1424 /** 1425 * reg_set_ap_pwr_and_update_chan_list() - Set the AP power mode and recompute 1426 * the current channel list 1427 * 1428 * @pdev: pdev ptr 1429 * @ap_pwr_type: the AP power type to update to 1430 * 1431 * Return: QDF_STATUS 1432 */ 1433 QDF_STATUS reg_set_ap_pwr_and_update_chan_list(struct wlan_objmgr_pdev *pdev, 1434 enum reg_6g_ap_type ap_pwr_type); 1435 1436 /** 1437 * reg_get_6g_chan_psd_eirp_power() - For a given frequency, get the max PSD 1438 * from the mas_chan_list 1439 * @freq: Channel frequency 1440 * @mas_chan_list: Pointer to mas_chan_list 1441 * @reg_psd: Pointer to reg_psd 1442 * 1443 * Return: QDF_STATUS 1444 */ 1445 QDF_STATUS 1446 reg_get_6g_chan_psd_eirp_power(qdf_freq_t freq, 1447 struct regulatory_channel *mas_chan_list, 1448 uint16_t *reg_psd); 1449 1450 /** 1451 * reg_find_txpower_from_6g_list() - For a given frequency, get the max EIRP 1452 * from the mas_chan_list 1453 * @freq: Channel frequency 1454 * @mas_chan_list: Pointer to mas_chan_list 1455 * @reg_eirp: Pointer to reg_eirp 1456 * 1457 * Return: QDF_STATUS 1458 */ 1459 QDF_STATUS 1460 reg_find_txpower_from_6g_list(qdf_freq_t freq, 1461 struct regulatory_channel *chan_list, 1462 uint16_t *reg_eirp); 1463 #else 1464 static inline QDF_STATUS 1465 reg_set_cur_6g_ap_pwr_type(struct wlan_objmgr_pdev *pdev, 1466 enum reg_6g_ap_type reg_cur_6g_ap_pwr_type) 1467 { 1468 return QDF_STATUS_E_NOSUPPORT; 1469 } 1470 1471 static inline QDF_STATUS 1472 reg_get_cur_6g_ap_pwr_type(struct wlan_objmgr_pdev *pdev, 1473 enum reg_6g_ap_type *reg_cur_6g_ap_pwr_type) 1474 { 1475 *reg_cur_6g_ap_pwr_type = REG_MAX_AP_TYPE; 1476 return QDF_STATUS_E_NOSUPPORT; 1477 } 1478 1479 static inline QDF_STATUS 1480 reg_get_cur_6g_client_type(struct wlan_objmgr_pdev *pdev, 1481 enum reg_6g_client_type 1482 *reg_cur_6g_client_mobility_type) 1483 { 1484 *reg_cur_6g_client_mobility_type = REG_SUBORDINATE_CLIENT; 1485 return QDF_STATUS_E_NOSUPPORT; 1486 } 1487 1488 static inline 1489 QDF_STATUS reg_get_rnr_tpe_usable(struct wlan_objmgr_pdev *pdev, 1490 bool *reg_rnr_tpe_usable) 1491 { 1492 *reg_rnr_tpe_usable = false; 1493 return QDF_STATUS_E_NOSUPPORT; 1494 } 1495 1496 static inline 1497 QDF_STATUS reg_get_unspecified_ap_usable(struct wlan_objmgr_pdev *pdev, 1498 bool *reg_unspecified_ap_usable) 1499 { 1500 *reg_unspecified_ap_usable = false; 1501 return QDF_STATUS_E_NOSUPPORT; 1502 } 1503 1504 static inline 1505 bool reg_is_6g_psd_power(struct wlan_objmgr_pdev *pdev) 1506 { 1507 return false; 1508 } 1509 1510 static inline 1511 QDF_STATUS reg_get_6g_chan_ap_power(struct wlan_objmgr_pdev *pdev, 1512 qdf_freq_t chan_freq, bool *is_psd, 1513 uint16_t *tx_power, 1514 uint16_t *eirp_psd_power) 1515 { 1516 *is_psd = false; 1517 *eirp_psd_power = 0; 1518 *tx_power = 0; 1519 return QDF_STATUS_E_NOSUPPORT; 1520 } 1521 1522 static inline 1523 QDF_STATUS reg_get_client_power_for_connecting_ap(struct wlan_objmgr_pdev *pdev, 1524 enum reg_6g_ap_type ap_type, 1525 qdf_freq_t chan_freq, 1526 bool *is_psd, 1527 uint16_t *tx_power, 1528 uint16_t *eirp_psd_power) 1529 { 1530 *is_psd = false; 1531 *tx_power = 0; 1532 *eirp_psd_power = 0; 1533 return QDF_STATUS_E_NOSUPPORT; 1534 } 1535 1536 static inline 1537 QDF_STATUS reg_get_client_power_for_6ghz_ap(struct wlan_objmgr_pdev *pdev, 1538 enum reg_6g_client_type client_type, 1539 qdf_freq_t chan_freq, 1540 bool *is_psd, uint16_t *tx_power, 1541 uint16_t *eirp_psd_power) 1542 { 1543 *is_psd = false; 1544 *tx_power = 0; 1545 *eirp_psd_power = 0; 1546 return QDF_STATUS_E_NOSUPPORT; 1547 } 1548 1549 static inline 1550 QDF_STATUS reg_set_ap_pwr_and_update_chan_list(struct wlan_objmgr_pdev *pdev, 1551 enum reg_6g_ap_type ap_pwr_type) 1552 { 1553 return QDF_STATUS_E_NOSUPPORT; 1554 } 1555 1556 static inline QDF_STATUS 1557 reg_get_6g_chan_psd_eirp_power(qdf_freq_t freq, 1558 struct regulatory_channel *mas_chan_list, 1559 uint16_t *eirp_psd_power) 1560 { 1561 *eirp_psd_power = 0; 1562 return QDF_STATUS_E_NOSUPPORT; 1563 } 1564 1565 static inline QDF_STATUS 1566 reg_find_txpower_from_6g_list(qdf_freq_t freq, 1567 struct regulatory_channel *chan_list, 1568 uint16_t *reg_eirp) 1569 { 1570 *reg_eirp = 0; 1571 return QDF_STATUS_E_NOSUPPORT; 1572 } 1573 #endif 1574 1575 #ifdef CONFIG_HOST_FIND_CHAN 1576 /** 1577 * reg_update_max_phymode_chwidth_for_pdev() - Update the maximum phymode 1578 * and the corresponding chwidth for the pdev. 1579 * @pdev: Pointer to PDEV object. 1580 * 1581 */ 1582 void reg_update_max_phymode_chwidth_for_pdev(struct wlan_objmgr_pdev *pdev); 1583 1584 /** 1585 * reg_modify_chan_list_for_max_chwidth() - Update the maximum bandwidth for 1586 * each channel in the current channel list. 1587 * @pdev: Pointer to PDEV object. 1588 * @cur_chan_list: Pointer to the pdev current channel list. 1589 * 1590 * In countries like DK, the channel 144 is not supported by the regulatory. 1591 * When we get the regulatory rules, the entire UNII-2E's max bandwidth is set 1592 * to 160MHz but this is only true for channel 100 to 128. Channels 132 and 1593 * and 136 will have maximum bandwidth of 40MHz and channel 140 will have a 1594 * max bandwidth value of 20MHz (since 144 is not available). 1595 * These values in the current channel list are not updated based on the 1596 * bonded channels and hence will have an incorrect value for particular 1597 * channels. 1598 * Use this API to update the maximum bandwidth based on the device 1599 * capabilities and the availability of adjacent channels. 1600 */ 1601 void 1602 reg_modify_chan_list_for_max_chwidth(struct wlan_objmgr_pdev *pdev, 1603 struct regulatory_channel *cur_chan_list); 1604 1605 #else 1606 static inline void 1607 reg_update_max_phymode_chwidth_for_pdev(struct wlan_objmgr_pdev *pdev) 1608 { 1609 } 1610 1611 static inline void 1612 reg_modify_chan_list_for_max_chwidth(struct wlan_objmgr_pdev *pdev, 1613 struct regulatory_channel *cur_chan_list) 1614 { 1615 } 1616 1617 #endif /* CONFIG_HOST_FIND_CHAN */ 1618 1619 /** 1620 * reg_is_phymode_unallowed() - Check if requested phymode is unallowed 1621 * @phy_in: phymode that the user requested 1622 * @phymode_bitmap: bitmap of unallowed phymodes for specific country 1623 * 1624 * Return: true if phymode is not allowed, else false 1625 */ 1626 bool reg_is_phymode_unallowed(enum reg_phymode phy_in, uint32_t phymode_bitmap); 1627 1628 /* 1629 * reg_is_regdb_offloaded() - is regdb offloaded 1630 * @psoc: Pointer to psoc object 1631 * 1632 * Return: true if regdb is offloaded, else false 1633 */ 1634 bool reg_is_regdb_offloaded(struct wlan_objmgr_psoc *psoc); 1635 1636 /** 1637 * reg_set_ext_tpc_supported() - Set if FW supports new WMI command for TPC 1638 * @psoc: Pointer to psoc 1639 * @val: value 1640 * 1641 * Return: QDF_STATUS 1642 */ 1643 QDF_STATUS reg_set_ext_tpc_supported(struct wlan_objmgr_psoc *psoc, 1644 bool val); 1645 1646 /** 1647 * reg_is_ext_tpc_supported() - Whether FW supports new WMI command for TPC 1648 * 1649 * @psoc: pointer to psoc 1650 * 1651 * Return: true if FW supports the new TPC command, else false 1652 */ 1653 bool reg_is_ext_tpc_supported(struct wlan_objmgr_psoc *psoc); 1654 1655 /** 1656 * reg_get_bonded_chan_entry() - Fetch the bonded channel pointer given a 1657 * frequency and channel width. 1658 * @freq: Input frequency. 1659 * @chwidth: Input channel width. 1660 * 1661 * Return: A valid bonded channel pointer if found, else NULL. 1662 */ 1663 const struct bonded_channel_freq * 1664 reg_get_bonded_chan_entry(qdf_freq_t freq, enum phy_ch_width chwidth); 1665 1666 /** 1667 * reg_set_2g_channel_params_for_freq() - set the 2.4G bonded channel parameters 1668 * @oper_freq: operating channel 1669 * @ch_params: channel parameters 1670 * @sec_ch_2g_freq: 2.4G secondary channel 1671 * 1672 * Return: void 1673 */ 1674 void reg_set_2g_channel_params_for_freq(struct wlan_objmgr_pdev *pdev, 1675 uint16_t oper_freq, 1676 struct ch_params *ch_params, 1677 uint16_t sec_ch_2g_freq); 1678 1679 /** 1680 * reg_combine_channel_states() - Get minimum of channel state1 and state2 1681 * @chan_state1: Channel state1 1682 * @chan_state2: Channel state2 1683 * 1684 * Return: Channel state 1685 */ 1686 enum channel_state reg_combine_channel_states(enum channel_state chan_state1, 1687 enum channel_state chan_state2); 1688 1689 #if defined(CONFIG_BAND_6GHZ) 1690 /** 1691 * reg_set_lower_6g_edge_ch_supp() - Set if lower 6ghz edge channel is 1692 * supported by FW 1693 * 1694 * @psoc: Pointer to psoc 1695 * @val: value 1696 */ 1697 QDF_STATUS reg_set_lower_6g_edge_ch_supp(struct wlan_objmgr_psoc *psoc, 1698 bool val); 1699 1700 /** 1701 * reg_set_disable_upper_6g_edge_ch_supp() - Set if upper 6ghz edge channel is 1702 * disabled by FW 1703 * 1704 * @psoc: Pointer to psoc 1705 * @val: value 1706 */ 1707 QDF_STATUS 1708 reg_set_disable_upper_6g_edge_ch_supp(struct wlan_objmgr_psoc *psoc, 1709 bool val); 1710 1711 /** 1712 * reg_is_lower_6g_edge_ch_supp() - Check whether 6GHz lower edge channel 1713 * (5935 MHz) is supported. 1714 * @psoc: pointer to psoc 1715 * 1716 * Return: true if edge channels are supported, else false 1717 */ 1718 bool reg_is_lower_6g_edge_ch_supp(struct wlan_objmgr_psoc *psoc); 1719 1720 /** 1721 * reg_is_upper_6g_edge_ch_disabled() - Check whether 6GHz upper edge 1722 * channel (7115 MHz) is disabled. 1723 * @psoc: pointer to psoc 1724 * 1725 * Return: true if edge channels are supported, else false 1726 */ 1727 bool reg_is_upper_6g_edge_ch_disabled(struct wlan_objmgr_psoc *psoc); 1728 #endif 1729 1730 #ifdef FEATURE_WLAN_CH_AVOID_EXT 1731 /** 1732 * reg_process_ch_avoid_ext_event() - Process channel avoid extended event 1733 * @psoc: psoc for country information 1734 * @ch_avoid_event: channel avoid extended event buffer 1735 * 1736 * Return: QDF_STATUS 1737 */ 1738 1739 QDF_STATUS 1740 reg_process_ch_avoid_ext_event(struct wlan_objmgr_psoc *psoc, 1741 struct ch_avoid_ind_type *ch_avoid_event); 1742 #else 1743 static inline QDF_STATUS 1744 reg_process_ch_avoid_ext_event(struct wlan_objmgr_psoc *psoc, 1745 struct ch_avoid_ind_type *ch_avoid_event) 1746 { 1747 return QDF_STATUS_SUCCESS; 1748 } 1749 #endif 1750 1751 #if defined(CONFIG_AFC_SUPPORT) && defined(CONFIG_BAND_6GHZ) 1752 /** 1753 * reg_send_afc_cmd() - Send AFC cmd to the FW 1754 * @pdev: pdev ptr 1755 * @afc_ind_obj: Pointer to hold AFC indication 1756 * 1757 * Return: QDF_STATUS_SUCCESS if the WMI command is sent or QDF_STATUS_E_FAILURE 1758 * otherwise 1759 */ 1760 QDF_STATUS reg_send_afc_cmd(struct wlan_objmgr_pdev *pdev, 1761 struct reg_afc_resp_rx_ind_info *afc_ind_obj); 1762 1763 /** 1764 * reg_is_afc_power_event_received() - Checks if AFC power event is 1765 * received from the FW. 1766 * 1767 * @pdev: pdev ptr 1768 * 1769 * Return: true if AFC power event is received from the FW or false otherwise 1770 */ 1771 bool reg_is_afc_power_event_received(struct wlan_objmgr_pdev *pdev); 1772 1773 /** 1774 * reg_get_afc_req_id() - Get the AFC request ID 1775 * @pdev: pdev pointer 1776 * @req_id: Pointer to request id 1777 * 1778 * Return: QDF_STATUS 1779 */ 1780 QDF_STATUS reg_get_afc_req_id(struct wlan_objmgr_pdev *pdev, uint64_t *req_id); 1781 1782 /** 1783 * reg_is_afc_expiry_event_received() - Checks if AFC power event is 1784 * received from the FW. 1785 * 1786 * @pdev: pdev ptr 1787 * 1788 * Return: true if AFC expiry event is received from the FW or false otherwise 1789 */ 1790 bool reg_is_afc_expiry_event_received(struct wlan_objmgr_pdev *pdev); 1791 1792 /** 1793 * reg_is_noaction_on_afc_pwr_evt() - Checks if the regulatory module 1794 * needs to take action when AFC power event is received. 1795 * 1796 * @pdev: pdev ptr 1797 * 1798 * Return: true if regulatory should not take any action or false otherwise 1799 */ 1800 bool reg_is_noaction_on_afc_pwr_evt(struct wlan_objmgr_pdev *pdev); 1801 1802 /** 1803 * reg_dmn_set_afc_req_id() - Set the request ID in the AFC partial request 1804 * object 1805 * @afc_req: pointer to AFC partial request 1806 * @req_id: AFC request ID 1807 * 1808 * Return: Void 1809 */ 1810 void reg_dmn_set_afc_req_id(struct wlan_afc_host_partial_request *afc_req, 1811 uint64_t req_id); 1812 #endif 1813 #endif 1814