1 /* 2 * Copyright (c) 2017-2021 The Linux Foundation. All rights reserved. 3 * Copyright (c) 2021-2022 Qualcomm Innovation Center, Inc. All rights reserved. 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: wlan_reg_services_api.h 22 * This file provides prototypes of the routines needed for the 23 * external components to utilize the services provided by the 24 * regulatory component. 25 */ 26 27 #ifndef __WLAN_REG_SERVICES_API_H 28 #define __WLAN_REG_SERVICES_API_H 29 30 #include <reg_services_public_struct.h> 31 32 /** 33 * wlan_reg_max_5ghz_ch_num() - Get maximum 5GHz channel number 34 * 35 * Return: Maximum 5GHz channel number 36 */ 37 #define WLAN_REG_MAX_5GHZ_CH_NUM wlan_reg_max_5ghz_ch_num() 38 uint8_t wlan_reg_max_5ghz_ch_num(void); 39 40 #ifdef CONFIG_CHAN_FREQ_API 41 /** 42 * wlan_reg_min_24ghz_chan_freq() - Get minimum 2.4GHz channel frequency 43 * 44 * Return: Minimum 2.4GHz channel frequency 45 */ 46 #define WLAN_REG_MIN_24GHZ_CHAN_FREQ wlan_reg_min_24ghz_chan_freq() 47 qdf_freq_t wlan_reg_min_24ghz_chan_freq(void); 48 49 /** 50 * wlan_reg_max_24ghz_chan_freq() - Get maximum 2.4GHz channel frequency 51 * 52 * Return: Maximum 2.4GHz channel frequency 53 */ 54 #define WLAN_REG_MAX_24GHZ_CHAN_FREQ wlan_reg_max_24ghz_chan_freq() 55 qdf_freq_t wlan_reg_max_24ghz_chan_freq(void); 56 57 /** 58 * wlan_reg_min_5ghz_chan_freq() - Get minimum 5GHz channel frequency 59 * 60 * Return: Minimum 5GHz channel frequency 61 */ 62 #define WLAN_REG_MIN_5GHZ_CHAN_FREQ wlan_reg_min_5ghz_chan_freq() 63 qdf_freq_t wlan_reg_min_5ghz_chan_freq(void); 64 65 /** 66 * wlan_reg_max_5ghz_chan_freq() - Get maximum 5GHz channel frequency 67 * 68 * Return: Maximum 5GHz channel frequency 69 */ 70 #define WLAN_REG_MAX_5GHZ_CHAN_FREQ wlan_reg_max_5ghz_chan_freq() 71 qdf_freq_t wlan_reg_max_5ghz_chan_freq(void); 72 #endif /* CONFIG_CHAN_FREQ_API */ 73 74 /** 75 * wlan_reg_is_24ghz_ch_freq() - Check if the given channel frequency is 2.4GHz 76 * @freq: Channel frequency 77 * 78 * Return: true if channel frequency is 2.4GHz, else false 79 */ 80 #define WLAN_REG_IS_24GHZ_CH_FREQ(freq) wlan_reg_is_24ghz_ch_freq(freq) 81 bool wlan_reg_is_24ghz_ch_freq(qdf_freq_t freq); 82 83 /** 84 * wlan_reg_is_5ghz_ch_freq() - Check if the given channel frequency is 5GHz 85 * @freq: Channel frequency 86 * 87 * Return: true if channel frequency is 5GHz, else false 88 */ 89 #define WLAN_REG_IS_5GHZ_CH_FREQ(freq) wlan_reg_is_5ghz_ch_freq(freq) 90 bool wlan_reg_is_5ghz_ch_freq(qdf_freq_t freq); 91 92 /** 93 * wlan_reg_is_range_overlap_2g() - Check if the given low_freq and high_freq 94 * is in the 2G range. 95 * 96 * @low_freq - Low frequency. 97 * @high_freq - High frequency. 98 * 99 * Return: Return true if given low_freq and high_freq overlaps 2G range, 100 * else false. 101 */ 102 bool wlan_reg_is_range_overlap_2g(qdf_freq_t low_freq, qdf_freq_t high_freq); 103 104 /** 105 * wlan_reg_is_range_overlap_5g() - Check if the given low_freq and high_freq 106 * is in the 5G range. 107 * 108 * @low_freq - Low frequency. 109 * @high_freq - High frequency. 110 * 111 * Return: Return true if given low_freq and high_freq overlaps 5G range, 112 * else false. 113 */ 114 bool wlan_reg_is_range_overlap_5g(qdf_freq_t low_freq, qdf_freq_t high_freq); 115 116 /** 117 * wlan_reg_is_freq_indoor() - Check if a frequency is indoor. 118 * @pdev: Pointer to pdev. 119 * @freq: Channel frequency. 120 * 121 * Return: Return true if a frequency is indoor, else false. 122 */ 123 bool wlan_reg_is_freq_indoor(struct wlan_objmgr_pdev *pdev, qdf_freq_t freq); 124 125 /** 126 * wlan_reg_get_min_chwidth() - Return min chanwidth supported by freq. 127 * @pdev: Pointer to pdev. 128 * @freq: Channel frequency. 129 * 130 * Return: Min chwidth supported by freq as per regulatory DB. 131 */ 132 uint16_t wlan_reg_get_min_chwidth(struct wlan_objmgr_pdev *pdev, 133 qdf_freq_t freq); 134 135 /** 136 * wlan_reg_get_max_chwidth() - Return max chanwidth supported by freq. 137 * @pdev: Pointer to pdev. 138 * @freq: Channel frequency. 139 * 140 * Return: Max chwidth supported by freq as per regulatory DB. 141 */ 142 uint16_t wlan_reg_get_max_chwidth(struct wlan_objmgr_pdev *pdev, 143 qdf_freq_t freq); 144 145 /** 146 * wlan_reg_get_next_lower_bandwidth() - Get next lower bandwdith 147 * @ch_width: channel bandwdith 148 * 149 * Return: Return next lower bandwidth of input channel bandwidth 150 */ 151 enum phy_ch_width 152 wlan_reg_get_next_lower_bandwidth(enum phy_ch_width ch_width); 153 154 #ifdef CONFIG_REG_CLIENT 155 /** 156 * wlan_reg_is_freq_indoor_in_secondary_list() - Check if the input frequency is 157 * an indoor frequency in the secondary list 158 * @pdev: Pointer to pdev. 159 * @freq: Channel frequency. 160 * 161 * Return: Return true if a frequency is indoor, else false. 162 */ 163 bool wlan_reg_is_freq_indoor_in_secondary_list(struct wlan_objmgr_pdev *pdev, 164 qdf_freq_t freq); 165 #endif 166 167 #ifdef CONFIG_BAND_6GHZ 168 /** 169 * wlan_reg_is_6ghz_chan_freq() - Check if the given channel frequency is 6GHz 170 * @freq: Channel frequency 171 * 172 * Return: true if channel frequency is 6GHz, else false 173 */ 174 #define WLAN_REG_IS_6GHZ_CHAN_FREQ(freq) wlan_reg_is_6ghz_chan_freq(freq) 175 bool wlan_reg_is_6ghz_chan_freq(uint16_t freq); 176 177 #ifdef CONFIG_6G_FREQ_OVERLAP 178 /** 179 * wlan_reg_is_range_only6g() - Check if the given low_freq and high_freq 180 * is in the 6G range. 181 * @low_freq - Low frequency. 182 * @high_freq - High frequency. 183 * 184 * Return: Return true if given low_freq and high_freq overlaps 6G range, 185 * else false. 186 */ 187 bool wlan_reg_is_range_only6g(qdf_freq_t low_freq, qdf_freq_t high_freq); 188 189 /** 190 * wlan_reg_is_range_overlap_6g() - Check if the given low_freq and high_freq 191 * is in the 6G range. 192 * 193 * @low_freq - Low frequency. 194 * @high_freq - High frequency. 195 * 196 * Return: Return true if given low_freq and high_freq overlaps 6G range, 197 * else false. 198 */ 199 bool wlan_reg_is_range_overlap_6g(qdf_freq_t low_freq, qdf_freq_t high_freq); 200 #else 201 static inline bool wlan_reg_is_range_only6g(qdf_freq_t low_freq, 202 qdf_freq_t high_freq) 203 { 204 return false; 205 } 206 207 static inline bool wlan_reg_is_range_overlap_6g(qdf_freq_t low_freq, 208 qdf_freq_t high_freq) 209 { 210 return false; 211 } 212 #endif 213 214 /** 215 * wlan_reg_get_6g_ap_master_chan_list() - provide the appropriate ap master 216 * channel list 217 * @pdev: pdev pointer 218 * @ap_pwr_type: The ap power type (LPI/VLP/SP) 219 * @chan_list: channel list pointer 220 * 221 * Return: QDF_STATUS 222 */ 223 QDF_STATUS wlan_reg_get_6g_ap_master_chan_list( 224 struct wlan_objmgr_pdev *pdev, 225 enum reg_6g_ap_type ap_pwr_type, 226 struct regulatory_channel *chan_list); 227 228 #ifdef CONFIG_REG_CLIENT 229 /** 230 * wlan_reg_get_power_string () - wlan reg get power type string 231 * @power_type: power type enum 232 * 233 * Return: power type string 234 */ 235 const char *wlan_reg_get_power_string(enum reg_6g_ap_type power_type); 236 #endif 237 238 /** 239 * wlan_reg_is_6ghz_psc_chan_freq() - Check if the given 6GHz channel frequency 240 * is preferred scanning channel frequency. 241 * @freq: Channel frequency 242 * 243 * Return: true if given 6GHz channel frequency is preferred scanning channel 244 * frequency, else false 245 */ 246 #define WLAN_REG_IS_6GHZ_PSC_CHAN_FREQ(freq) \ 247 wlan_reg_is_6ghz_psc_chan_freq(freq) 248 bool wlan_reg_is_6ghz_psc_chan_freq(uint16_t freq); 249 250 /** 251 * wlan_reg_min_6ghz_chan_freq() - Get minimum 6GHz channel center frequency 252 * 253 * Return: Minimum 6GHz channel center frequency 254 */ 255 #define WLAN_REG_MIN_6GHZ_CHAN_FREQ wlan_reg_min_6ghz_chan_freq() 256 uint16_t wlan_reg_min_6ghz_chan_freq(void); 257 258 /** 259 * wlan_reg_max_6ghz_chan_freq() - Get maximum 6GHz channel center frequency 260 * 261 * Return: Maximum 6GHz channel center frequency 262 */ 263 #define WLAN_REG_MAX_6GHZ_CHAN_FREQ wlan_reg_max_6ghz_chan_freq() 264 uint16_t wlan_reg_max_6ghz_chan_freq(void); 265 266 /** 267 * wlan_reg_is_6g_freq_indoor() - Check if a 6GHz frequency is indoor. 268 * @pdev: Pointer to pdev. 269 * @freq: Channel frequency. 270 * 271 * Return: Return true if a 6GHz frequency is indoor, else false. 272 */ 273 #define WLAN_REG_IS_6GHZ_FREQ_INDOOR(pdev, freq) \ 274 wlan_reg_is_6g_freq_indoor(pdev, freq) 275 bool wlan_reg_is_6g_freq_indoor(struct wlan_objmgr_pdev *pdev, qdf_freq_t freq); 276 277 /** 278 * wlan_reg_get_max_txpower_for_6g_tpe() - Get max txpower for 6G TPE IE. 279 * @pdev: Pointer to pdev. 280 * @freq: Channel frequency. 281 * @bw: Channel bandwidth. 282 * @reg_ap: Regulatory 6G AP type. 283 * @reg_client: Regulatory client type. 284 * @is_psd: True if txpower is needed in PSD format, and false if needed in EIRP 285 * format. 286 * @tx_power: Pointer to tx-power. 287 * 288 * Return: Return QDF_STATUS_SUCCESS, if tx_power is filled for 6G TPE IE 289 * else return QDF_STATUS_E_FAILURE. 290 */ 291 QDF_STATUS 292 wlan_reg_get_max_txpower_for_6g_tpe(struct wlan_objmgr_pdev *pdev, 293 qdf_freq_t freq, uint8_t bw, 294 enum reg_6g_ap_type reg_ap, 295 enum reg_6g_client_type reg_client, 296 bool is_psd, 297 uint8_t *tx_power); 298 299 /** 300 * wlan_reg_get_superchan_entry() - Get the address of the super channel list 301 * entry for a given input channel index. 302 * 303 * @pdev: pdev ptr 304 * @chan_enum: Channel enum 305 * @p_sup_chan_entry: Pointer to address of *p_sup_chan_entry 306 * 307 * Return: QDF_STATUS_SUCCESS if super channel entry is available for the input 308 * chan_enum else QDF_STATUS_E_FAILURE 309 */ 310 QDF_STATUS wlan_reg_get_superchan_entry( 311 struct wlan_objmgr_pdev *pdev, 312 enum channel_enum chan_enum, 313 const struct super_chan_info **p_sup_chan_entry); 314 #else 315 316 #define WLAN_REG_IS_6GHZ_CHAN_FREQ(freq) (false) 317 static inline bool wlan_reg_is_6ghz_chan_freq(uint16_t freq) 318 { 319 return false; 320 } 321 322 static inline bool wlan_reg_is_range_only6g(qdf_freq_t low_freq, 323 qdf_freq_t high_freq) 324 { 325 return false; 326 } 327 328 #define WLAN_REG_IS_6GHZ_PSC_CHAN_FREQ(freq) (false) 329 static inline bool wlan_reg_is_6ghz_psc_chan_freq(uint16_t freq) 330 { 331 return false; 332 } 333 334 #define WLAN_REG_MIN_6GHZ_CHAN_FREQ (false) 335 static inline uint16_t wlan_reg_min_6ghz_chan_freq(void) 336 { 337 return 0; 338 } 339 340 #define WLAN_REG_MAX_6GHZ_CHAN_FREQ (false) 341 static inline uint16_t wlan_reg_max_6ghz_chan_freq(void) 342 { 343 return 0; 344 } 345 346 #define WLAN_REG_IS_6GHZ_FREQ_INDOOR(pdev, freq) (false) 347 static inline bool 348 wlan_reg_is_6g_freq_indoor(struct wlan_objmgr_pdev *pdev, qdf_freq_t freq) 349 { 350 return false; 351 } 352 353 static inline bool wlan_reg_is_range_overlap_6g(qdf_freq_t low_freq, 354 qdf_freq_t high_freq) 355 { 356 return false; 357 } 358 359 static inline QDF_STATUS 360 wlan_reg_get_max_txpower_for_6g_tpe(struct wlan_objmgr_pdev *pdev, 361 qdf_freq_t freq, uint8_t bw, 362 enum reg_6g_ap_type reg_ap, 363 enum reg_6g_client_type reg_client, 364 bool is_psd, 365 uint8_t *tx_power) 366 { 367 return QDF_STATUS_E_FAILURE; 368 } 369 370 static inline QDF_STATUS 371 wlan_reg_get_6g_ap_master_chan_list(struct wlan_objmgr_pdev *pdev, 372 enum reg_6g_ap_type ap_pwr_type, 373 struct regulatory_channel *chan_list) 374 { 375 return QDF_STATUS_E_FAILURE; 376 } 377 378 static inline 379 QDF_STATUS wlan_reg_get_superchan_entry( 380 struct wlan_objmgr_pdev *pdev, 381 enum channel_enum chan_enum, 382 const struct super_chan_info **p_sup_chan_entry) 383 { 384 *p_sup_chan_entry = NULL; 385 return QDF_STATUS_E_NOSUPPORT; 386 } 387 #endif /* CONFIG_BAND_6GHZ */ 388 389 /** 390 * wlan_reg_get_band_channel_list() - Get channel list based on the band_mask 391 * @pdev: pdev ptr 392 * @band_mask: Input bitmap with band set 393 * @channel_list: Pointer to Channel List 394 * 395 * Get the given channel list and number of channels from the current channel 396 * list based on input band bitmap. 397 * 398 * Return: Number of channels, else 0 to indicate error 399 */ 400 uint16_t 401 wlan_reg_get_band_channel_list(struct wlan_objmgr_pdev *pdev, 402 uint8_t band_mask, 403 struct regulatory_channel *channel_list); 404 405 #ifdef CONFIG_REG_CLIENT 406 /** 407 * wlan_reg_get_secondary_band_channel_list() - Get secondary channel list for 408 * SAP based on the band_mask 409 * @pdev: pdev ptr 410 * @band_mask: Input bitmap with band set 411 * @channel_list: Pointer to Channel List 412 * 413 * Get the given channel list and number of channels from the secondary current 414 * channel list based on input band bitmap. 415 * 416 * Return: Number of channels, else 0 to indicate error 417 */ 418 uint16_t 419 wlan_reg_get_secondary_band_channel_list(struct wlan_objmgr_pdev *pdev, 420 uint8_t band_mask, 421 struct regulatory_channel 422 *channel_list); 423 #endif 424 425 /** 426 * wlan_reg_chan_band_to_freq - Return channel frequency based on the channel 427 * number and band. 428 * @pdev: pdev ptr 429 * @chan: Channel Number 430 * @band_mask: Bitmap for bands 431 * 432 * Return: Return channel frequency or return 0, if the channel is disabled or 433 * if the input channel number or band_mask is invalid. Composite bands are 434 * supported only for 2.4Ghz and 5Ghz bands. For other bands the following 435 * priority is given: 1) 6Ghz 2) 5Ghz 3) 2.4Ghz. 436 */ 437 qdf_freq_t wlan_reg_chan_band_to_freq(struct wlan_objmgr_pdev *pdev, 438 uint8_t chan, 439 uint8_t band_mask); 440 441 #ifdef CONFIG_49GHZ_CHAN 442 /** 443 * wlan_reg_is_49ghz_freq() - Check if the given channel frequency is 4.9GHz 444 * @freq: Channel frequency 445 * 446 * Return: true if channel frequency is 4.9GHz, else false 447 */ 448 #define WLAN_REG_IS_49GHZ_FREQ(freq) wlan_reg_is_49ghz_freq(freq) 449 bool wlan_reg_is_49ghz_freq(qdf_freq_t freq); 450 451 #else 452 453 #define WLAN_REG_IS_49GHZ_FREQ(freq) (false) 454 static inline bool wlan_reg_is_49ghz_freq(qdf_freq_t freq) 455 { 456 return false; 457 } 458 #endif /* CONFIG_49GHZ_CHAN */ 459 460 /** 461 * wlan_reg_ch_num() - Get channel number from channel enum 462 * @ch_enum: Channel enum 463 * 464 * Return: channel number 465 */ 466 #define WLAN_REG_CH_NUM(ch_enum) wlan_reg_ch_num(ch_enum) 467 uint8_t wlan_reg_ch_num(uint32_t ch_enum); 468 469 /** 470 * wlan_reg_ch_to_freq() - Get channel frequency from channel enum 471 * @ch_enum: Channel enum 472 * 473 * Return: channel frequency 474 */ 475 #define WLAN_REG_CH_TO_FREQ(ch_enum) wlan_reg_ch_to_freq(ch_enum) 476 qdf_freq_t wlan_reg_ch_to_freq(uint32_t ch_enum); 477 478 /** 479 * wlan_reg_read_default_country() - Read the default country for the regdomain 480 * @country: pointer to the country code. 481 * 482 * Return: QDF_STATUS 483 */ 484 QDF_STATUS wlan_reg_read_default_country(struct wlan_objmgr_psoc *psoc, 485 uint8_t *country); 486 487 /** 488 * wlan_reg_get_ctry_idx_max_bw_from_country_code() - Get the max 5G 489 * bandwidth from country code 490 * @pdev: pdev pointer 491 * @cc: Country Code 492 * @max_bw_5g: Max 5G bandwidth supported by the country 493 * 494 * Return: QDF_STATUS 495 */ 496 497 QDF_STATUS wlan_reg_get_max_5g_bw_from_country_code( 498 struct wlan_objmgr_pdev *pdev, 499 uint16_t cc, 500 uint16_t *max_bw_5g); 501 502 /** 503 * wlan_reg_get_max_5g_bw_from_regdomain() - Get the max 5G bandwidth 504 * supported by the regdomain 505 * @pdev: pdev pointer 506 * @orig_regdmn: Regdomain Pair value 507 * @max_bw_5g: Max 5G bandwidth supported by the country 508 * 509 * Return: QDF_STATUS 510 */ 511 QDF_STATUS wlan_reg_get_max_5g_bw_from_regdomain( 512 struct wlan_objmgr_pdev *pdev, 513 uint16_t regdmn, 514 uint16_t *max_bw_5g); 515 516 /** 517 * wlan_reg_get_fcc_constraint() - Check FCC constraint on given frequency 518 * @pdev: physical dev to get 519 * @freq: frequency to be checked 520 * 521 * Return: If FCC constraint is on applied given frequency return true 522 * else return false. 523 */ 524 bool wlan_reg_get_fcc_constraint(struct wlan_objmgr_pdev *pdev, uint32_t freq); 525 526 #ifdef CONFIG_REG_CLIENT 527 /** 528 * wlan_reg_read_current_country() - Read the current country for the regdomain 529 * @country: pointer to the country code. 530 * 531 * Return: QDF_STATUS 532 */ 533 QDF_STATUS wlan_reg_read_current_country(struct wlan_objmgr_psoc *psoc, 534 uint8_t *country); 535 536 #ifdef CONFIG_REG_CLIENT 537 /** 538 * wlan_reg_get_6g_power_type_for_ctry() - Return power type for 6G based 539 * on country IE 540 * @ap_ctry: ptr to country string in country IE 541 * @sta_ctry: ptr to sta programmed country 542 * @pwr_type_6g: ptr to 6G power type 543 * @ctry_code_match: Check for country IE and sta country code match 544 * @ap_pwr_type: AP's power type for 6G as advertised in HE ops IE 545 * Return: QDF_STATUS 546 */ 547 QDF_STATUS 548 wlan_reg_get_6g_power_type_for_ctry(struct wlan_objmgr_psoc *psoc, 549 uint8_t *ap_ctry, uint8_t *sta_ctry, 550 enum reg_6g_ap_type *pwr_type_6g, 551 bool *ctry_code_match, 552 enum reg_6g_ap_type ap_pwr_type); 553 #endif 554 555 #ifdef CONFIG_CHAN_FREQ_API 556 /** 557 * wlan_reg_is_etsi13_srd_chan_for_freq () - Checks if the ch is ETSI13 srd ch 558 * or not 559 * @pdev: pdev ptr 560 * @freq: channel center frequency 561 * 562 * Return: true or false 563 */ 564 bool wlan_reg_is_etsi13_srd_chan_for_freq(struct wlan_objmgr_pdev *pdev, 565 qdf_freq_t freq); 566 #endif /*CONFIG_CHAN_FREQ_API*/ 567 568 /** 569 * wlan_reg_is_etsi13_regdmn() - Checks if current reg domain is ETSI13 or not 570 * @pdev: pdev ptr 571 * 572 * Return: true or false 573 */ 574 bool wlan_reg_is_etsi13_regdmn(struct wlan_objmgr_pdev *pdev); 575 576 /** 577 * wlan_reg_is_etsi13_srd_chan_allowed_master_mode() - Checks if regdmn is 578 * ETSI13 and SRD channels are allowed in master mode or not. 579 * 580 * @pdev: pdev ptr 581 * 582 * Return: true or false 583 */ 584 bool wlan_reg_is_etsi13_srd_chan_allowed_master_mode(struct wlan_objmgr_pdev 585 *pdev); 586 #endif 587 588 /** 589 * wlan_reg_is_world() - reg is world mode 590 * @country: The country information 591 * 592 * Return: true or false 593 */ 594 bool wlan_reg_is_world(uint8_t *country); 595 596 /** 597 * wlan_reg_get_dfs_region () - Get the current dfs region 598 * @dfs_reg: pointer to dfs region 599 * 600 * Return: Status 601 */ 602 QDF_STATUS wlan_reg_get_dfs_region(struct wlan_objmgr_pdev *pdev, 603 enum dfs_reg *dfs_reg); 604 605 /** 606 * wlan_reg_is_chan_disabled_and_not_nol() - In the regulatory channel list, a 607 * channel may be disabled by the regulatory/device or by radar. Radar is 608 * temporary and a radar disabled channel does not mean that the channel is 609 * permanently disabled. The API checks if the channel is disabled, but not due 610 * to radar. 611 * @chan - Regulatory channel object 612 * 613 * Return - True, the channel is disabled, but not due to radar, else false. 614 */ 615 bool wlan_reg_is_chan_disabled_and_not_nol(struct regulatory_channel *chan); 616 617 /** 618 * wlan_reg_get_current_chan_list() - provide the pdev current channel list 619 * @pdev: pdev pointer 620 * @chan_list: channel list pointer 621 * 622 * Return: QDF_STATUS 623 */ 624 QDF_STATUS wlan_reg_get_current_chan_list(struct wlan_objmgr_pdev *pdev, 625 struct regulatory_channel *chan_list); 626 627 /** 628 * wlan_reg_is_freq_enabled() - Checks if the given frequency is enabled on the 629 * given power mode or not. If the frequency is not a 6G frequency then the 630 * input power mode is ignored and only current channel list is searched. 631 * 632 * @pdev: pdev pointer. 633 * @freq: input frequency. 634 * @in_6g_pwr_mode: Power mode on which the freq is enabled or not is to be 635 * checked. 636 * 637 * Return: True if the frequency is present in the given power mode channel 638 * list. 639 */ 640 bool wlan_reg_is_freq_enabled(struct wlan_objmgr_pdev *pdev, 641 qdf_freq_t freq, 642 enum supported_6g_pwr_types in_6g_pwr_mode); 643 644 /** 645 * wlan_reg_is_freq_idx_enabled() - Checks if the given frequency index is 646 * enabled on the given power mode or not. If the frequency index is not a 6G 647 * frequency then the input power mode is ignored and only current channel list 648 * is searched. 649 * 650 * @pdev: pdev pointer. 651 * @freq_idx: input frequency index. 652 * @in_6g_pwr_mode: Power mode on which the frequency index is enabled or not 653 * is to be checked. 654 * 655 * Return: True if the frequency index is present in the given power mode 656 * channel list. 657 */ 658 bool wlan_reg_is_freq_idx_enabled(struct wlan_objmgr_pdev *pdev, 659 enum channel_enum freq_idx, 660 enum supported_6g_pwr_types in_6g_pwr_mode); 661 662 /** 663 * wlan_reg_get_pwrmode_chan_list() - Get the modified channel list. A modified 664 * current channel list consists of 2G and 5G portions of the current channel 665 * list and the 6G portion of the current channel list is derived from the input 666 * 6g power type. 667 * @pdev: Pointer to pdev 668 * @chan_list: Pointer to buffer which stores list of regulatory_channels. 669 * @in_6g_pwr_mode: 6GHz power type 670 * 671 * Return: 672 * QDF_STATUS_SUCCESS: Success 673 * QDF_STATUS_E_INVAL: Failed to get channel list 674 */ 675 QDF_STATUS wlan_reg_get_pwrmode_chan_list(struct wlan_objmgr_pdev *pdev, 676 struct regulatory_channel *chan_list, 677 enum supported_6g_pwr_types 678 in_6g_pwr_mode); 679 680 #ifdef CONFIG_REG_CLIENT 681 /** 682 * wlan_reg_get_secondary_current_chan_list() - provide the pdev secondary 683 * current channel list 684 * @pdev: pdev pointer 685 * @chan_list: channel list pointer 686 * 687 * Return: QDF_STATUS 688 */ 689 QDF_STATUS wlan_reg_get_secondary_current_chan_list( 690 struct wlan_objmgr_pdev *pdev, 691 struct regulatory_channel *chan_list); 692 #endif 693 694 #if defined(CONFIG_AFC_SUPPORT) && defined(CONFIG_BAND_6GHZ) 695 /** 696 * wlan_reg_get_6g_afc_chan_list() - provide the pdev afc channel list 697 * @pdev: pdev pointer 698 * @chan_list: channel list pointer 699 * 700 * Return: QDF_STATUS 701 */ 702 QDF_STATUS wlan_reg_get_6g_afc_chan_list(struct wlan_objmgr_pdev *pdev, 703 struct regulatory_channel *chan_list); 704 705 /** 706 * wlan_reg_get_6g_afc_mas_chan_list() - provide the pdev afc master channel 707 * list 708 * @pdev: pdev pointer 709 * @chan_list: channel list pointer 710 * 711 * Return: QDF_STATUS 712 */ 713 QDF_STATUS 714 wlan_reg_get_6g_afc_mas_chan_list(struct wlan_objmgr_pdev *pdev, 715 struct regulatory_channel *chan_list); 716 717 /** 718 * wlan_reg_psd_2_eirp() - Calculate EIRP from PSD and bandwidth 719 * channel list 720 * @pdev: pdev pointer 721 * @psd: Power Spectral Density in dBm/MHz 722 * @ch_bw: Bandwidth of a channel in MHz (20/40/80/160/320 etc) 723 * @eirp: EIRP power in dBm 724 * 725 * Return: QDF_STATUS 726 */ 727 QDF_STATUS wlan_reg_psd_2_eirp(struct wlan_objmgr_pdev *pdev, 728 int16_t psd, 729 uint16_t ch_bw, 730 int16_t *eirp); 731 732 /** 733 * wlan_reg_is_afc_power_event_received() - Checks if AFC power event is 734 * received from the FW. 735 * 736 * @pdev: pdev ptr 737 * 738 * Return: true if AFC power event is received from the FW or false otherwise 739 */ 740 bool wlan_reg_is_afc_power_event_received(struct wlan_objmgr_pdev *pdev); 741 742 /** 743 * wlan_reg_get_afc_req_id() - Get the AFC request ID 744 * @pdev: pdev pointer 745 * @req_id: Pointer to request id 746 * 747 * Return: QDF_STATUS 748 */ 749 QDF_STATUS wlan_reg_get_afc_req_id(struct wlan_objmgr_pdev *pdev, 750 uint64_t *req_id); 751 752 /** 753 * wlan_reg_is_afc_expiry_event_received() - Checks if AFC power event is 754 * received from the FW. 755 * 756 * @pdev: pdev ptr 757 * 758 * Return: true if AFC exipry event is received from the FW or false otherwise 759 */ 760 bool wlan_reg_is_afc_expiry_event_received(struct wlan_objmgr_pdev *pdev); 761 762 /** 763 * wlan_reg_is_noaction_on_afc_pwr_evt() - Checks whether driver needs to 764 * take action for AFC action or the response should be handled by the 765 * user application. 766 * 767 * @pdev: pdev ptr 768 * 769 * Return: true if driver need not take action for AFC resp, false otherwise. 770 */ 771 bool 772 wlan_reg_is_noaction_on_afc_pwr_evt(struct wlan_objmgr_pdev *pdev); 773 #else 774 static inline bool 775 wlan_reg_is_afc_power_event_received(struct wlan_objmgr_pdev *pdev) 776 { 777 return false; 778 } 779 780 static inline QDF_STATUS 781 wlan_reg_get_6g_afc_chan_list(struct wlan_objmgr_pdev *pdev, 782 struct regulatory_channel *chan_list) 783 { 784 return QDF_STATUS_E_NOSUPPORT; 785 } 786 #endif 787 788 /** 789 * wlan_reg_get_bonded_channel_state_for_freq() - Get bonded channel freq state 790 * @freq: channel frequency 791 * @bw: channel band width 792 * @sec_freq: secondary frequency 793 * 794 * Return: channel state 795 */ 796 enum channel_state 797 wlan_reg_get_bonded_channel_state_for_freq(struct wlan_objmgr_pdev *pdev, 798 qdf_freq_t freq, 799 enum phy_ch_width bw, 800 qdf_freq_t sec_freq); 801 802 #ifdef CONFIG_REG_6G_PWRMODE 803 /** 804 * wlan_reg_get_bonded_channel_state_for_pwrmode() - Get bonded channel freq 805 * state 806 * @freq: channel frequency 807 * @bw: channel band width 808 * @sec_freq: secondary frequency 809 * @in_6g_pwr_type: 6g power type which decides 6G channel list lookup. 810 * 811 * Return: channel state 812 */ 813 enum channel_state 814 wlan_reg_get_bonded_channel_state_for_pwrmode(struct wlan_objmgr_pdev *pdev, 815 qdf_freq_t freq, 816 enum phy_ch_width bw, 817 qdf_freq_t sec_freq, 818 enum supported_6g_pwr_types 819 in_6g_pwr_mode); 820 #endif 821 822 /** 823 * wlan_reg_set_dfs_region() - set the dfs region 824 * @pdev: pdev ptr 825 * @dfs_reg: dfs region 826 * 827 * Return: void 828 */ 829 void wlan_reg_set_dfs_region(struct wlan_objmgr_pdev *pdev, 830 enum dfs_reg dfs_reg); 831 832 /** 833 * wlan_reg_get_bw_value() - provide the channel center freq 834 * @chan_num: chennal number 835 * 836 * Return: int 837 */ 838 uint16_t wlan_reg_get_bw_value(enum phy_ch_width bw); 839 840 /** 841 * wlan_reg_get_domain_from_country_code() - provide the channel center freq 842 * @reg_domain_ptr: regulatory domain ptr 843 * @country_alpha2: country alpha2 844 * @source: alpha2 source 845 * 846 * Return: int 847 */ 848 QDF_STATUS wlan_reg_get_domain_from_country_code(v_REGDOMAIN_t *reg_domain_ptr, 849 const uint8_t *country_alpha2, 850 enum country_src source); 851 852 /** 853 * wlan_reg_dmn_get_opclass_from_channel() - provide the channel center freq 854 * @country: country alpha2 855 * @channel: channel number 856 * @offset: offset 857 * 858 * Return: int 859 */ 860 uint16_t wlan_reg_dmn_get_opclass_from_channel(uint8_t *country, 861 uint8_t channel, 862 uint8_t offset); 863 864 /** 865 * wlan_reg_get_opclass_from_freq_width() - Get operating class from frequency 866 * @country: Country code. 867 * @freq: Channel center frequency. 868 * @ch_width: Channel width. 869 * @behav_limit: Behaviour limit. 870 * 871 * Return: Error code. 872 */ 873 uint8_t wlan_reg_get_opclass_from_freq_width(uint8_t *country, 874 qdf_freq_t freq, 875 uint16_t ch_width, 876 uint16_t behav_limit); 877 878 /** 879 * wlan_reg_get_band_cap_from_op_class() - Return band capability bitmap 880 * @country: Pointer to Country code. 881 * @num_of_opclass: Number of Operating class. 882 * @opclass: Pointer to opclass. 883 * 884 * Return supported band bitmap based on the input operating class list 885 * provided. 886 * 887 * Return: Return supported band capability 888 */ 889 uint8_t wlan_reg_get_band_cap_from_op_class(const uint8_t *country, 890 uint8_t num_of_opclass, 891 const uint8_t *opclass); 892 893 /** 894 * wlan_reg_dmn_print_channels_in_opclass() - Print channels in op-class 895 * @country: country alpha2 896 * @opclass: oplcass 897 * 898 * Return: void 899 */ 900 void wlan_reg_dmn_print_channels_in_opclass(uint8_t *country, 901 uint8_t opclass); 902 903 904 /** 905 * wlan_reg_dmn_get_chanwidth_from_opclass() - get channel width from 906 * operating class 907 * @country: country alpha2 908 * @channel: channel number 909 * @opclass: operating class 910 * 911 * Return: int 912 */ 913 uint16_t wlan_reg_dmn_get_chanwidth_from_opclass(uint8_t *country, 914 uint8_t channel, 915 uint8_t opclass); 916 917 /** 918 * wlan_reg_dmn_get_chanwidth_from_opclass_auto() - get channel width from 919 * operating class. If opclass not found then search in global opclass. 920 * @country: country alpha2 921 * @channel: channel number 922 * @opclass: operating class 923 * 924 * Return: int 925 */ 926 uint16_t wlan_reg_dmn_get_chanwidth_from_opclass_auto(uint8_t *country, 927 uint8_t channel, 928 uint8_t opclass); 929 930 /** 931 * wlan_reg_dmn_set_curr_opclasses() - set operating class 932 * @num_classes: number of classes 933 * @class: operating class 934 * 935 * Return: int 936 */ 937 uint16_t wlan_reg_dmn_set_curr_opclasses(uint8_t num_classes, 938 uint8_t *class); 939 940 /** 941 * wlan_reg_dmn_get_curr_opclasses() - get current oper classes 942 * @num_classes: number of classes 943 * @class: operating class 944 * 945 * Return: int 946 */ 947 uint16_t wlan_reg_dmn_get_curr_opclasses(uint8_t *num_classes, 948 uint8_t *class); 949 950 951 /** 952 * wlan_reg_get_opclass_details() - Get details about the current opclass table. 953 * @pdev: Pointer to pdev. 954 * @reg_ap_cap: Pointer to reg_ap_cap. 955 * @n_opclasses: Pointer to number of opclasses. 956 * @max_supp_op_class: Maximum number of operating classes supported. 957 * @global_tbl_lookup: Whether to lookup global op class tbl. 958 * 959 * Return: QDF_STATUS_SUCCESS if success, else return QDF_STATUS_FAILURE. 960 */ 961 QDF_STATUS 962 wlan_reg_get_opclass_details(struct wlan_objmgr_pdev *pdev, 963 struct regdmn_ap_cap_opclass_t *reg_ap_cap, 964 uint8_t *n_opclasses, 965 uint8_t max_supp_op_class, 966 bool global_tbl_lookup); 967 968 /** 969 * wlan_reg_get_cc_and_src () - get country code and src 970 * @psoc: psoc ptr 971 * @alpha2: country code alpha2 972 * 973 * Return: country_src 974 */ 975 enum country_src wlan_reg_get_cc_and_src(struct wlan_objmgr_psoc *psoc, 976 uint8_t *alpha); 977 978 /** 979 * wlan_regulatory_init() - init regulatory component 980 * 981 * Return: Success or Failure 982 */ 983 QDF_STATUS wlan_regulatory_init(void); 984 985 /** 986 * wlan_regulatory_deinit() - deinit regulatory component 987 * 988 * Return: Success or Failure 989 */ 990 QDF_STATUS wlan_regulatory_deinit(void); 991 992 /** 993 * regulatory_psoc_open() - open regulatory component 994 * 995 * Return: Success or Failure 996 */ 997 QDF_STATUS regulatory_psoc_open(struct wlan_objmgr_psoc *psoc); 998 999 1000 /** 1001 * regulatory_psoc_close() - close regulatory component 1002 * 1003 * Return: Success or Failure 1004 */ 1005 QDF_STATUS regulatory_psoc_close(struct wlan_objmgr_psoc *psoc); 1006 1007 /** 1008 * regulatory_pdev_open() - Open regulatory component 1009 * @pdev: Pointer to pdev structure 1010 * 1011 * Return: Success or Failure 1012 */ 1013 QDF_STATUS regulatory_pdev_open(struct wlan_objmgr_pdev *pdev); 1014 1015 /** 1016 * regulatory_pdev_close() - Close regulatory component 1017 * @pdev: Pointer to pdev structure. 1018 * 1019 * Return: Success or Failure 1020 */ 1021 QDF_STATUS regulatory_pdev_close(struct wlan_objmgr_pdev *pdev); 1022 1023 /** 1024 * wlan_reg_freq_to_chan () - convert channel freq to channel number 1025 * @pdev: The physical dev to set current country for 1026 * @freq: frequency 1027 * 1028 * Return: true or false 1029 */ 1030 uint8_t wlan_reg_freq_to_chan(struct wlan_objmgr_pdev *pdev, 1031 qdf_freq_t freq); 1032 1033 /** 1034 * wlan_reg_legacy_chan_to_freq () - convert chan to freq, for 2G and 5G 1035 * @chan: channel number 1036 * 1037 * Return: frequency 1038 */ 1039 qdf_freq_t wlan_reg_legacy_chan_to_freq(struct wlan_objmgr_pdev *pdev, 1040 uint8_t chan); 1041 1042 /** 1043 * wlan_reg_is_us() - reg is us country 1044 * @country: The country information 1045 * 1046 * Return: true or false 1047 */ 1048 bool wlan_reg_is_us(uint8_t *country); 1049 1050 /** 1051 * wlan_reg_is_etsi() - reg is a country in EU 1052 * @country: The country information 1053 * 1054 * Return: true or false 1055 */ 1056 bool wlan_reg_is_etsi(uint8_t *country); 1057 1058 1059 /** 1060 * wlan_reg_set_country() - Set the current regulatory country 1061 * @pdev: The physical dev to set current country for 1062 * @country: The country information to configure 1063 * 1064 * Return: QDF_STATUS 1065 */ 1066 QDF_STATUS wlan_reg_set_country(struct wlan_objmgr_pdev *pdev, 1067 uint8_t *country); 1068 1069 /** 1070 * wlan_reg_set_11d_country() - Set the 11d regulatory country 1071 * @pdev: The physical dev to set current country for 1072 * @country: The country information to configure 1073 * 1074 * Return: QDF_STATUS 1075 */ 1076 QDF_STATUS wlan_reg_set_11d_country(struct wlan_objmgr_pdev *pdev, 1077 uint8_t *country); 1078 1079 /** 1080 * wlan_reg_register_chan_change_callback () - add chan change cbk 1081 * @psoc: psoc ptr 1082 * @cbk: callback 1083 * @arg: argument 1084 * 1085 * Return: true or false 1086 */ 1087 void wlan_reg_register_chan_change_callback(struct wlan_objmgr_psoc *psoc, 1088 void *cbk, void *arg); 1089 1090 /** 1091 * wlan_reg_unregister_chan_change_callback () - remove chan change cbk 1092 * @psoc: psoc ptr 1093 * @cbk:callback 1094 * 1095 * Return: true or false 1096 */ 1097 void wlan_reg_unregister_chan_change_callback(struct wlan_objmgr_psoc *psoc, 1098 void *cbk); 1099 1100 /** 1101 * wlan_reg_is_11d_offloaded() - 11d offloaded supported 1102 * @psoc: psoc ptr 1103 * 1104 * Return: bool 1105 */ 1106 bool wlan_reg_is_11d_offloaded(struct wlan_objmgr_psoc *psoc); 1107 1108 /** 1109 * wlan_reg_11d_enabled_on_host() - 11d enabled don host 1110 * @psoc: psoc ptr 1111 * 1112 * Return: bool 1113 */ 1114 bool wlan_reg_11d_enabled_on_host(struct wlan_objmgr_psoc *psoc); 1115 1116 /** 1117 * wlan_reg_get_chip_mode() - get supported chip mode 1118 * @pdev: pdev pointer 1119 * @chip_mode: chip mode 1120 * 1121 * Return: QDF STATUS 1122 */ 1123 QDF_STATUS wlan_reg_get_chip_mode(struct wlan_objmgr_pdev *pdev, 1124 uint64_t *chip_mode); 1125 1126 /** 1127 * wlan_reg_is_11d_scan_inprogress() - checks 11d scan status 1128 * @psoc: psoc ptr 1129 * 1130 * Return: bool 1131 */ 1132 bool wlan_reg_is_11d_scan_inprogress(struct wlan_objmgr_psoc *psoc); 1133 /** 1134 * wlan_reg_get_freq_range() - Get 2GHz and 5GHz frequency range 1135 * @pdev: pdev pointer 1136 * @low_2g: low 2GHz frequency range 1137 * @high_2g: high 2GHz frequency range 1138 * @low_5g: low 5GHz frequency range 1139 * @high_5g: high 5GHz frequency range 1140 * 1141 * Return: QDF status 1142 */ 1143 QDF_STATUS wlan_reg_get_freq_range(struct wlan_objmgr_pdev *pdev, 1144 qdf_freq_t *low_2g, 1145 qdf_freq_t *high_2g, 1146 qdf_freq_t *low_5g, 1147 qdf_freq_t *high_5g); 1148 /** 1149 * wlan_reg_get_tx_ops () - get regulatory tx ops 1150 * @psoc: psoc ptr 1151 * 1152 */ 1153 struct wlan_lmac_if_reg_tx_ops * 1154 wlan_reg_get_tx_ops(struct wlan_objmgr_psoc *psoc); 1155 1156 /** 1157 * wlan_reg_get_curr_regdomain() - Get current regdomain in use 1158 * @pdev: pdev pointer 1159 * @cur_regdmn: Current regdomain info 1160 * 1161 * Return: QDF status 1162 */ 1163 QDF_STATUS wlan_reg_get_curr_regdomain(struct wlan_objmgr_pdev *pdev, 1164 struct cur_regdmn_info *cur_regdmn); 1165 1166 #ifdef WLAN_REG_PARTIAL_OFFLOAD 1167 /** 1168 * wlan_reg_is_regdmn_en302502_applicable() - Find if ETSI EN302_502 radar 1169 * pattern is applicable in the current regulatory domain. 1170 * @pdev: Pdev ptr. 1171 * 1172 * Return: Boolean. 1173 * True: If EN302_502 is applicable. 1174 * False: otherwise. 1175 */ 1176 bool wlan_reg_is_regdmn_en302502_applicable(struct wlan_objmgr_pdev *pdev); 1177 #endif 1178 1179 /** 1180 * wlan_reg_modify_pdev_chan_range() - Compute current channel list for the 1181 * modified channel range in the regcap. 1182 * @pdev: pointer to wlan_objmgr_pdev. 1183 * 1184 * Return : QDF_STATUS 1185 */ 1186 QDF_STATUS wlan_reg_modify_pdev_chan_range(struct wlan_objmgr_pdev *pdev); 1187 1188 /** 1189 * wlan_reg_get_phybitmap() - Get phybitmap from regulatory pdev_priv_obj 1190 * @pdev: pdev pointer 1191 * @phybitmap: pointer to phybitmap 1192 * 1193 * Return: QDF STATUS 1194 */ 1195 QDF_STATUS wlan_reg_get_phybitmap(struct wlan_objmgr_pdev *pdev, 1196 uint16_t *phybitmap); 1197 1198 /** 1199 * wlan_reg_update_pdev_wireless_modes() - Update the wireless_modes in the 1200 * pdev_priv_obj with the input wireless_modes 1201 * @pdev: pointer to wlan_objmgr_pdev. 1202 * @wireless_modes: Wireless modes. 1203 * 1204 * Return : QDF_STATUS 1205 */ 1206 QDF_STATUS wlan_reg_update_pdev_wireless_modes(struct wlan_objmgr_pdev *pdev, 1207 uint64_t wireless_modes); 1208 /** 1209 * wlan_reg_disable_chan_coex() - Disable Coexisting channels based on the input 1210 * bitmask 1211 * @pdev: pointer to wlan_objmgr_pdev. 1212 * unii_5g_bitmap: UNII 5G bitmap. 1213 * 1214 * Return : QDF_STATUS 1215 */ 1216 #ifdef DISABLE_UNII_SHARED_BANDS 1217 QDF_STATUS wlan_reg_disable_chan_coex(struct wlan_objmgr_pdev *pdev, 1218 uint8_t unii_5g_bitmap); 1219 #else 1220 static inline QDF_STATUS 1221 wlan_reg_disable_chan_coex(struct wlan_objmgr_pdev *pdev, 1222 uint8_t unii_5g_bitmap) 1223 { 1224 return QDF_STATUS_SUCCESS; 1225 } 1226 #endif 1227 1228 #ifdef WLAN_FEATURE_GET_USABLE_CHAN_LIST 1229 /** 1230 * wlan_reg_get_usable_channel() - Get usable channels 1231 * @pdev: Pointer to pdev 1232 * @req_msg: Request msg 1233 * @res_msg: Response msg 1234 * @count: no of usable channels 1235 * 1236 * Return: qdf status 1237 */ 1238 QDF_STATUS 1239 wlan_reg_get_usable_channel(struct wlan_objmgr_pdev *pdev, 1240 struct get_usable_chan_req_params req_msg, 1241 struct get_usable_chan_res_params *res_msg, 1242 uint32_t *count); 1243 #endif 1244 1245 #ifdef CONFIG_CHAN_FREQ_API 1246 /** 1247 * wlan_reg_is_same_band_freqs() - Check if two channel frequencies 1248 * have same band 1249 * @freq1: Frequency 1 1250 * @freq2: Frequency 2 1251 * 1252 * Return: true if both the channel frequency has the same band. 1253 */ 1254 #define WLAN_REG_IS_SAME_BAND_FREQS(freq1, freq2) \ 1255 wlan_reg_is_same_band_freqs(freq1, freq2) 1256 bool wlan_reg_is_same_band_freqs(qdf_freq_t freq1, qdf_freq_t freq2); 1257 1258 /** 1259 * wlan_reg_get_chan_enum_for_freq() - Get channel enum for given channel center 1260 * frequency 1261 * @freq: Channel center frequency 1262 * 1263 * Return: Channel enum 1264 */ 1265 enum channel_enum wlan_reg_get_chan_enum_for_freq(qdf_freq_t freq); 1266 1267 /** 1268 * wlan_reg_is_freq_present_in_cur_chan_list() - Check if channel is present 1269 * in the current channel list 1270 * @pdev: pdev pointer 1271 * @freq: Channel center frequency 1272 * 1273 * Return: true if channel is present in current channel list 1274 */ 1275 bool wlan_reg_is_freq_present_in_cur_chan_list(struct wlan_objmgr_pdev *pdev, 1276 qdf_freq_t freq); 1277 1278 /** 1279 * wlan_reg_update_nol_history_ch_for_freq() - Set nol-history flag for the 1280 * channels in the list. 1281 * 1282 * @pdev: Pdev ptr 1283 * @ch_list: Input channel list. 1284 * @num_ch: Number of channels. 1285 * @nol_history_ch: Nol history value. 1286 * 1287 * Return: void 1288 */ 1289 void wlan_reg_update_nol_history_ch_for_freq(struct wlan_objmgr_pdev *pdev, 1290 uint16_t *ch_list, 1291 uint8_t num_ch, 1292 bool nol_history_ch); 1293 1294 /** 1295 * wlan_reg_chan_has_dfs_attribute_for_freq() - check channel has dfs 1296 * attribute flag 1297 * @freq: channel center frequency. 1298 * 1299 * This API get chan initial dfs attribute from regdomain 1300 * 1301 * Return: true if chan is dfs, otherwise false 1302 */ 1303 bool 1304 wlan_reg_chan_has_dfs_attribute_for_freq(struct wlan_objmgr_pdev *pdev, 1305 qdf_freq_t freq); 1306 1307 /** 1308 * wlan_reg_get_channel_list_with_power_for_freq() - Provide the channel list 1309 * with power 1310 * @ch_list: pointer to the channel list. 1311 * 1312 * Return: QDF_STATUS 1313 */ 1314 QDF_STATUS 1315 wlan_reg_get_channel_list_with_power_for_freq(struct wlan_objmgr_pdev *pdev, 1316 struct channel_power *ch_list, 1317 uint8_t *num_chan); 1318 /** 1319 * wlan_reg_get_5g_bonded_channel_state_for_freq() - Get 5G bonded channel state 1320 * @pdev: The physical dev to program country code or regdomain 1321 * @freq: channel frequency. 1322 * @bw: channel band width 1323 * 1324 * Return: channel state 1325 */ 1326 enum channel_state 1327 wlan_reg_get_5g_bonded_channel_state_for_freq(struct wlan_objmgr_pdev *pdev, 1328 qdf_freq_t freq, 1329 enum phy_ch_width bw); 1330 1331 #ifdef CONFIG_REG_6G_PWRMODE 1332 /** 1333 * wlan_reg_get_5g_bonded_channel_state_for_pwrmode() - Get 5G bonded channel 1334 * state. 1335 * @pdev: The physical dev to program country code or regdomain 1336 * @freq: channel frequency. 1337 * @bw: channel band width 1338 * @in_6g_pwr_type: 6g power type which decides 6G channel list lookup. 1339 * 1340 * Return: channel state 1341 */ 1342 enum channel_state 1343 wlan_reg_get_5g_bonded_channel_state_for_pwrmode(struct wlan_objmgr_pdev *pdev, 1344 qdf_freq_t freq, 1345 enum phy_ch_width bw, 1346 enum supported_6g_pwr_types 1347 in_6g_pwr_type); 1348 #endif 1349 1350 /** 1351 * wlan_reg_get_2g_bonded_channel_state_for_freq() - Get 2G bonded channel state 1352 * @pdev: The physical dev to program country code or regdomain 1353 * @freq: channel center frequency. 1354 * @sec_ch_freq: Secondary channel center frequency. 1355 * @bw: channel band width 1356 * 1357 * Return: channel state 1358 */ 1359 enum channel_state 1360 wlan_reg_get_2g_bonded_channel_state_for_freq(struct wlan_objmgr_pdev *pdev, 1361 qdf_freq_t freq, 1362 qdf_freq_t sec_ch_freq, 1363 enum phy_ch_width bw); 1364 1365 /** 1366 * wlan_reg_get_channel_state_for_freq() - Get channel state from regulatory 1367 * @pdev: Pointer to pdev 1368 * @freq: channel center frequency. 1369 * 1370 * Return: channel state 1371 */ 1372 enum channel_state 1373 wlan_reg_get_channel_state_for_freq(struct wlan_objmgr_pdev *pdev, 1374 qdf_freq_t freq); 1375 1376 #ifdef CONFIG_REG_6G_PWRMODE 1377 /** 1378 * wlan_reg_get_channel_state_for_pwrmode() - Get channel state from regulatory 1379 * @pdev: Pointer to pdev 1380 * @freq: channel center frequency. 1381 * @in_6g_pwr_type: 6g power type which decides 6G channel list lookup. 1382 * 1383 * Return: channel state 1384 */ 1385 enum channel_state 1386 wlan_reg_get_channel_state_for_pwrmode( 1387 struct wlan_objmgr_pdev *pdev, 1388 qdf_freq_t freq, 1389 enum supported_6g_pwr_types in_6g_pwr_type); 1390 #endif 1391 1392 #ifdef CONFIG_REG_CLIENT 1393 /** 1394 * wlan_reg_get_channel_state_from_secondary_list_for_freq() - Get channel state 1395 * from secondary regulatory current channel list 1396 * @pdev: Pointer to pdev 1397 * @freq: channel center frequency. 1398 * 1399 * Return: channel state 1400 */ 1401 enum channel_state wlan_reg_get_channel_state_from_secondary_list_for_freq( 1402 struct wlan_objmgr_pdev *pdev, 1403 qdf_freq_t freq); 1404 #endif 1405 1406 #ifdef WLAN_FEATURE_11BE 1407 /** 1408 * wlan_reg_fill_channel_list() - Fills the reg_channel_list (list of channels) 1409 * @pdev: Pointer to struct wlan_objmgr_pdev. 1410 * @freq: Center frequency of the primary channel in MHz 1411 * @sec_ch_2g_freq: Secondary channel center frequency. 1412 * @ch_width: Channel width of type 'enum phy_ch_width'. 1413 * @band_center_320: Center frequency of 320MHZ channel. 1414 * @chan_list: Pointer to struct reg_channel_list to be filled (Output param). 1415 * 1416 * Return: None 1417 */ 1418 void wlan_reg_fill_channel_list(struct wlan_objmgr_pdev *pdev, 1419 qdf_freq_t freq, 1420 qdf_freq_t sec_ch_2g_freq, 1421 enum phy_ch_width ch_width, 1422 qdf_freq_t band_center_320, 1423 struct reg_channel_list *chan_list); 1424 1425 /** 1426 * wlan_reg_is_punc_bitmap_valid() - is puncture bitmap valid or not 1427 * @bw: Input channel width. 1428 * @puncture_bitmap Input puncture bitmap. 1429 * 1430 * Return: true if given puncture bitmap is valid 1431 */ 1432 bool wlan_reg_is_punc_bitmap_valid(enum phy_ch_width bw, 1433 uint16_t puncture_bitmap); 1434 1435 /** 1436 * wlan_reg_set_create_punc_bitmap() - set is_create_punc_bitmap of ch_params 1437 * @ch_params: ch_params to set 1438 * @is_create_punc_bitmap: is create punc bitmap 1439 * 1440 * Return: NULL 1441 */ 1442 void wlan_reg_set_create_punc_bitmap(struct ch_params *ch_params, 1443 bool is_create_punc_bitmap); 1444 #ifdef CONFIG_REG_6G_PWRMODE 1445 /** 1446 * wlan_reg_fill_channel_list_for_pwrmode() - Fills the reg_channel_list 1447 * (list of channels) 1448 * @pdev: Pointer to struct wlan_objmgr_pdev. 1449 * @freq: Center frequency of the primary channel in MHz 1450 * @sec_ch_2g_freq: Secondary channel center frequency. 1451 * @ch_width: Channel width of type 'enum phy_ch_width'. 1452 * @band_center_320: Center frequency of 320MHZ channel. 1453 * @chan_list: Pointer to struct reg_channel_list to be filled (Output param). 1454 * @in_6g_pwr_type: 6g power type which decides 6G channel list lookup. 1455 * 1456 * Return: None 1457 */ 1458 void wlan_reg_fill_channel_list_for_pwrmode( 1459 struct wlan_objmgr_pdev *pdev, 1460 qdf_freq_t freq, 1461 qdf_freq_t sec_ch_2g_freq, 1462 enum phy_ch_width ch_width, 1463 qdf_freq_t band_center_320, 1464 struct reg_channel_list *chan_list, 1465 enum supported_6g_pwr_types in_6g_pwr_type); 1466 #endif 1467 #else 1468 static inline void wlan_reg_set_create_punc_bitmap(struct ch_params *ch_params, 1469 bool is_create_punc_bitmap) 1470 { 1471 } 1472 #endif 1473 1474 /** 1475 * wlan_reg_set_channel_params_for_freq() - Sets channel parameteres for 1476 * given bandwidth 1477 * @pdev: The physical dev to program country code or regdomain 1478 * @freq: channel center frequency. 1479 * @sec_ch_2g_freq: Secondary channel center frequency. 1480 * @ch_params: pointer to the channel parameters. 1481 * 1482 * Return: None 1483 */ 1484 void wlan_reg_set_channel_params_for_freq(struct wlan_objmgr_pdev *pdev, 1485 qdf_freq_t freq, 1486 qdf_freq_t sec_ch_2g_freq, 1487 struct ch_params *ch_params); 1488 1489 #ifdef CONFIG_REG_6G_PWRMODE 1490 /** 1491 * wlan_reg_set_channel_params_for_pwrmode() - Sets channel parameteres for 1492 * given bandwidth 1493 * @pdev: The physical dev to program country code or regdomain 1494 * @freq: channel center frequency. 1495 * @sec_ch_2g_freq: Secondary channel center frequency. 1496 * @ch_params: pointer to the channel parameters. 1497 * @in_6g_pwr_type: 6g power type which decides 6G channel list lookup. 1498 * 1499 * Return: None 1500 */ 1501 void wlan_reg_set_channel_params_for_pwrmode(struct wlan_objmgr_pdev *pdev, 1502 qdf_freq_t freq, 1503 qdf_freq_t sec_ch_2g_freq, 1504 struct ch_params *ch_params, 1505 enum supported_6g_pwr_types 1506 in_6g_pwr_mode); 1507 #endif 1508 1509 /** 1510 * wlan_reg_get_channel_cfreq_reg_power_for_freq() - Provide the channel 1511 * regulatory power 1512 * @freq: channel center frequency 1513 * 1514 * Return: int 1515 */ 1516 uint8_t wlan_reg_get_channel_reg_power_for_freq(struct wlan_objmgr_pdev *pdev, 1517 qdf_freq_t freq); 1518 1519 /** 1520 * wlan_reg_update_nol_ch_for_freq () - set nol channel 1521 * @pdev: pdev ptr 1522 * @chan_freq_list: channel list to be returned 1523 * @num_ch: number of channels 1524 * @nol_ch: nol flag 1525 * 1526 * Return: void 1527 */ 1528 void wlan_reg_update_nol_ch_for_freq(struct wlan_objmgr_pdev *pdev, 1529 uint16_t *chan_freq_list, 1530 uint8_t num_ch, 1531 bool nol_ch); 1532 1533 /** 1534 * wlan_reg_is_dfs_freq() - Checks the channel state for DFS 1535 * @freq: Channel center frequency 1536 * 1537 * Return: true or false 1538 */ 1539 bool wlan_reg_is_dfs_for_freq(struct wlan_objmgr_pdev *pdev, qdf_freq_t freq); 1540 1541 /** 1542 * wlan_reg_is_dsrc_freq() - Checks if the channel is dsrc channel or not 1543 * @freq: Channel center frequency 1544 * 1545 * Return: true or false 1546 */ 1547 bool wlan_reg_is_dsrc_freq(qdf_freq_t freq); 1548 1549 /** 1550 * wlan_reg_is_passive_or_disable_for_freq() - Checks chan state for passive 1551 * and disabled 1552 * @pdev: pdev ptr 1553 * @freq: Channel center frequency 1554 * 1555 * Return: true or false 1556 */ 1557 bool wlan_reg_is_passive_or_disable_for_freq(struct wlan_objmgr_pdev *pdev, 1558 qdf_freq_t freq); 1559 1560 /** 1561 * wlan_reg_is_disable_for_freq() - Checks chan state for disabled 1562 * @pdev: pdev ptr 1563 * @freq: Channel center frequency 1564 * 1565 * Return: true or false 1566 */ 1567 bool wlan_reg_is_disable_for_freq(struct wlan_objmgr_pdev *pdev, 1568 qdf_freq_t freq); 1569 #ifdef CONFIG_REG_6G_PWRMODE 1570 /** 1571 * wlan_reg_is_disable_for_pwrmode() - Checks chan state for disabled 1572 * @pdev: pdev ptr 1573 * @freq: Channel center frequency 1574 * @in_6g_pwr_type: 6g power type which decides 6G channel list lookup. 1575 * 1576 * Return: true or false 1577 */ 1578 bool wlan_reg_is_disable_for_pwrmode( 1579 struct wlan_objmgr_pdev *pdev, 1580 qdf_freq_t freq, 1581 enum supported_6g_pwr_types in_6g_pwr_mode); 1582 #endif 1583 1584 #ifdef CONFIG_REG_CLIENT 1585 /** 1586 * wlan_reg_is_disable_in_secondary_list_for_freq() - Checks in the secondary 1587 * channel list to see if chan state is disabled 1588 * @pdev: pdev ptr 1589 * @freq: Channel center frequency 1590 * 1591 * Return: true or false 1592 */ 1593 bool wlan_reg_is_disable_in_secondary_list_for_freq( 1594 struct wlan_objmgr_pdev *pdev, 1595 qdf_freq_t freq); 1596 1597 /** 1598 * wlan_reg_is_enable_in_secondary_list_for_freq() - Checks in the secondary 1599 * channel list to see if chan state is enabled 1600 * @pdev: pdev ptr 1601 * @freq: Channel center frequency 1602 * 1603 * Return: true or false 1604 */ 1605 bool wlan_reg_is_enable_in_secondary_list_for_freq( 1606 struct wlan_objmgr_pdev *pdev, 1607 qdf_freq_t freq); 1608 1609 /** 1610 * wlan_reg_is_dfs_in_secondary_list_for_freq() - hecks the channel state for 1611 * DFS from the secondary channel list 1612 * @pdev: pdev ptr 1613 * @freq: Channel center frequency 1614 * 1615 * Return: true or false 1616 */ 1617 bool wlan_reg_is_dfs_in_secondary_list_for_freq(struct wlan_objmgr_pdev *pdev, 1618 qdf_freq_t freq); 1619 #endif 1620 1621 /** 1622 * wlan_reg_is_passive_for_freq() - Check the channel flags to see if the 1623 * passive flag is set 1624 * @pdev: pdev ptr 1625 * @freq: Channel center frequency 1626 * 1627 * Return: true or false 1628 */ 1629 bool wlan_reg_is_passive_for_freq(struct wlan_objmgr_pdev *pdev, 1630 qdf_freq_t freq); 1631 1632 /** 1633 * wlan_reg_freq_to_band() - Get band from channel number 1634 * @freq:Channel frequency in MHz 1635 * 1636 * Return: wifi band 1637 */ 1638 enum reg_wifi_band wlan_reg_freq_to_band(qdf_freq_t freq); 1639 1640 /** 1641 * wlan_reg_min_chan_freq() - Minimum channel frequency supported 1642 * 1643 * Return: frequency 1644 */ 1645 qdf_freq_t wlan_reg_min_chan_freq(void); 1646 1647 /** 1648 * wlan_reg_max_chan_freq() - Return max. frequency 1649 * 1650 * Return: frequency 1651 */ 1652 qdf_freq_t wlan_reg_max_chan_freq(void); 1653 1654 /** 1655 * wlan_reg_freq_width_to_chan_op_class() -Get op class from freq 1656 * @pdev: pdev ptr 1657 * @freq: channel frequency 1658 * @chan_width: channel width 1659 * @global_tbl_lookup: whether to look up global table 1660 * @behav_limit: behavior limit 1661 * @op_class: operating class 1662 * @chan_num: channel number 1663 * 1664 * Return: void 1665 */ 1666 void wlan_reg_freq_width_to_chan_op_class(struct wlan_objmgr_pdev *pdev, 1667 qdf_freq_t freq, 1668 uint16_t chan_width, 1669 bool global_tbl_lookup, 1670 uint16_t behav_limit, 1671 uint8_t *op_class, 1672 uint8_t *chan_num); 1673 1674 /** 1675 * wlan_reg_freq_width_to_chan_op_class_auto() - convert frequency to 1676 * operating class,channel 1677 * @pdev: pdev pointer 1678 * @freq: channel frequency in mhz 1679 * @chan_width: channel width 1680 * @global_tbl_lookup: whether to lookup global op class tbl 1681 * @behav_limit: behavior limit 1682 * @op_class: operating class 1683 * @chan_num: channel number 1684 * 1685 * Return: Void. 1686 */ 1687 void wlan_reg_freq_width_to_chan_op_class_auto(struct wlan_objmgr_pdev *pdev, 1688 qdf_freq_t freq, 1689 uint16_t chan_width, 1690 bool global_tbl_lookup, 1691 uint16_t behav_limit, 1692 uint8_t *op_class, 1693 uint8_t *chan_num); 1694 1695 /** 1696 * wlan_reg_freq_to_chan_and_op_class() - Converts freq to oper class 1697 * @pdev: pdev ptr 1698 * @freq: channel frequency 1699 * @global_tbl_lookup: whether to look up global table 1700 * @behav_limit: behavior limit 1701 * @op_class: operating class 1702 * @chan_num: channel number 1703 * 1704 * Return: void 1705 */ 1706 void wlan_reg_freq_to_chan_op_class(struct wlan_objmgr_pdev *pdev, 1707 qdf_freq_t freq, 1708 bool global_tbl_lookup, 1709 uint16_t behav_limit, 1710 uint8_t *op_class, 1711 uint8_t *chan_num); 1712 1713 /** 1714 * wlan_reg_is_freq_in_country_opclass() - checks frequency in (ctry, op class) 1715 * pair 1716 * @pdev: pdev ptr 1717 * @country: country information 1718 * @op_class: operating class 1719 * @chan_freq: channel frequency 1720 * 1721 * Return: bool 1722 */ 1723 bool wlan_reg_is_freq_in_country_opclass(struct wlan_objmgr_pdev *pdev, 1724 const uint8_t country[3], 1725 uint8_t op_class, 1726 qdf_freq_t chan_freq); 1727 /** 1728 * wlan_reg_get_5g_bonded_channel_and_state_for_freq()- Return the channel 1729 * state for a 5G or 6G channel frequency based on the channel width and 1730 * bonded channel. 1731 * @pdev: Pointer to pdev. 1732 * @freq: Channel center frequency. 1733 * @bw Channel Width. 1734 * @bonded_chan_ptr_ptr: Pointer to bonded_channel_freq. 1735 * 1736 * Return: Channel State 1737 */ 1738 enum channel_state 1739 wlan_reg_get_5g_bonded_channel_and_state_for_freq(struct wlan_objmgr_pdev *pdev, 1740 uint16_t freq, 1741 enum phy_ch_width bw, 1742 const 1743 struct bonded_channel_freq 1744 **bonded_chan_ptr_ptr); 1745 1746 #ifdef CONFIG_REG_6G_PWRMODE 1747 /** 1748 * wlan_reg_get_5g_bonded_channel_and_state_for_pwrmode()- Return the channel 1749 * state for a 5G or 6G channel frequency based on the channel width and 1750 * bonded channel. 1751 * @pdev: Pointer to pdev. 1752 * @freq: Channel center frequency. 1753 * @bw Channel Width. 1754 * @bonded_chan_ptr_ptr: Pointer to bonded_channel_freq. 1755 * @in_6g_pwr_type: 6g power type which decides 6G channel list lookup. 1756 * 1757 * Return: Channel State 1758 */ 1759 enum channel_state 1760 wlan_reg_get_5g_bonded_channel_and_state_for_pwrmode( 1761 struct wlan_objmgr_pdev *pdev, 1762 uint16_t freq, 1763 enum phy_ch_width bw, 1764 const 1765 struct bonded_channel_freq 1766 **bonded_chan_ptr_ptr, 1767 enum supported_6g_pwr_types 1768 in_6g_pwr_mode); 1769 #endif 1770 #endif /*CONFIG_CHAN_FREQ_API */ 1771 1772 /** 1773 * wlan_reg_get_op_class_width() - Get operating class chan width 1774 * @pdev: pdev ptr 1775 * @freq: channel frequency 1776 * @global_tbl_lookup: whether to look up global table 1777 * @op_class: operating class 1778 * @chan_num: channel number 1779 * 1780 * Return: channel width of op class 1781 */ 1782 uint16_t wlan_reg_get_op_class_width(struct wlan_objmgr_pdev *pdev, 1783 uint8_t op_class, 1784 bool global_tbl_lookup); 1785 1786 /** 1787 * wlan_reg_is_5ghz_op_class() - Check if the input opclass is a 5GHz opclass. 1788 * @country: Country code. 1789 * @op_class: Operating class. 1790 * 1791 * Return: Return true if input the opclass is a 5GHz opclass, 1792 * else return false. 1793 */ 1794 bool wlan_reg_is_5ghz_op_class(const uint8_t *country, uint8_t op_class); 1795 1796 /** 1797 * wlan_reg_is_2ghz_op_class() - Check if the input opclass is a 2.4GHz opclass. 1798 * @country: Country code. 1799 * @op_class: Operating class. 1800 * 1801 * Return: Return true if input the opclass is a 2.4GHz opclass, 1802 * else return false. 1803 */ 1804 bool wlan_reg_is_2ghz_op_class(const uint8_t *country, uint8_t op_class); 1805 1806 /** 1807 * wlan_reg_is_6ghz_op_class() - Whether 6ghz oper class 1808 * @pdev: pdev ptr 1809 * @op_class: operating class 1810 * 1811 * Return: bool 1812 */ 1813 bool wlan_reg_is_6ghz_op_class(struct wlan_objmgr_pdev *pdev, 1814 uint8_t op_class); 1815 1816 #ifdef CONFIG_REG_CLIENT 1817 /** 1818 * wlan_reg_is_6ghz_supported() - Whether 6ghz is supported 1819 * @psoc: psoc ptr 1820 * 1821 * Return: bool 1822 */ 1823 bool wlan_reg_is_6ghz_supported(struct wlan_objmgr_psoc *psoc); 1824 #endif 1825 1826 #ifdef HOST_OPCLASS_EXT 1827 /** 1828 * wlan_reg_country_chan_opclass_to_freq() - Convert channel number to 1829 * frequency based on country code and op class 1830 * @pdev: pdev object. 1831 * @country: country code. 1832 * @chan: IEEE Channel Number. 1833 * @op_class: Opclass. 1834 * @strict: flag to find channel from matched operating class code. 1835 * 1836 * Look up (channel, operating class) pair in country operating class tables 1837 * and return the channel frequency. 1838 * If not found and "strict" flag is false, try to get frequency (Mhz) by 1839 * channel number only. 1840 * 1841 * Return: Channel center frequency else return 0. 1842 */ 1843 qdf_freq_t 1844 wlan_reg_country_chan_opclass_to_freq(struct wlan_objmgr_pdev *pdev, 1845 const uint8_t country[3], 1846 uint8_t chan, uint8_t op_class, 1847 bool strict); 1848 #endif 1849 1850 /** 1851 * reg_chan_opclass_to_freq() - Convert channel number and opclass to frequency 1852 * @chan: IEEE Channel Number. 1853 * @op_class: Opclass. 1854 * @global_tbl_lookup: Global table lookup. 1855 * 1856 * Return: Channel center frequency else return 0. 1857 */ 1858 uint16_t wlan_reg_chan_opclass_to_freq(uint8_t chan, 1859 uint8_t op_class, 1860 bool global_tbl_lookup); 1861 1862 /** 1863 * wlan_reg_chan_opclass_to_freq_auto() - Convert channel number and opclass to 1864 * frequency 1865 * @chan: IEEE channel number 1866 * @op_class: Operating class of channel 1867 * @global_tbl_lookup: Flag to determine if global table has to be looked up 1868 * 1869 * Return: Channel center frequency if valid, else zero 1870 */ 1871 1872 qdf_freq_t wlan_reg_chan_opclass_to_freq_auto(uint8_t chan, uint8_t op_class, 1873 bool global_tbl_lookup); 1874 1875 #ifdef CHECK_REG_PHYMODE 1876 /** 1877 * wlan_reg_get_max_phymode() - Find the best possible phymode given a 1878 * phymode, a frequency, and per-country regulations 1879 * @pdev: pdev pointer 1880 * @phy_in: phymode that the user requested 1881 * @freq: current operating center frequency 1882 * 1883 * Return: maximum phymode allowed in current country that is <= phy_in 1884 */ 1885 enum reg_phymode wlan_reg_get_max_phymode(struct wlan_objmgr_pdev *pdev, 1886 enum reg_phymode phy_in, 1887 qdf_freq_t freq); 1888 #else 1889 static inline enum reg_phymode 1890 wlan_reg_get_max_phymode(struct wlan_objmgr_pdev *pdev, 1891 enum reg_phymode phy_in, 1892 qdf_freq_t freq) 1893 { 1894 return REG_PHYMODE_INVALID; 1895 } 1896 #endif /* CHECK_REG_PHYMODE */ 1897 1898 #ifdef CONFIG_REG_CLIENT 1899 /** 1900 * wlan_reg_band_bitmap_to_band_info() - Convert the band_bitmap to a 1901 * band_info enum 1902 * @band_bitmap: bitmap on top of reg_wifi_band of bands enabled 1903 * 1904 * Return: BAND_ALL if both 2G and 5G band is enabled 1905 * BAND_2G if 2G is enabled but 5G isn't 1906 * BAND_5G if 5G is enabled but 2G isn't 1907 */ 1908 enum band_info wlan_reg_band_bitmap_to_band_info(uint32_t band_bitmap); 1909 #endif 1910 1911 #if defined(CONFIG_BAND_6GHZ) 1912 /** 1913 * wlan_reg_get_cur_6g_ap_pwr_type() - Get the current 6G regulatory AP power 1914 * type. 1915 * @pdev: Pointer to PDEV object. 1916 * @reg_cur_6g_ap_pwr_type: The current regulatory 6G AP power type ie. 1917 * LPI/SP/VLP. 1918 * 1919 * Return: QDF_STATUS. 1920 */ 1921 QDF_STATUS 1922 wlan_reg_get_cur_6g_ap_pwr_type(struct wlan_objmgr_pdev *pdev, 1923 enum reg_6g_ap_type *reg_cur_6g_ap_pwr_type); 1924 1925 /** 1926 * wlan_reg_get_cur_6g_client_type() - Get the current 6G regulatory client 1927 * type. 1928 * @pdev: Pointer to PDEV object. 1929 * @reg_cur_6g_client_mobility_type: The current regulatory 6G client type ie. 1930 * default/subordinate. 1931 * 1932 * Return: QDF_STATUS. 1933 */ 1934 QDF_STATUS 1935 wlan_reg_get_cur_6g_client_type(struct wlan_objmgr_pdev *pdev, 1936 enum reg_6g_client_type 1937 *reg_cur_6g_client_mobility_type); 1938 /** 1939 * wlan_reg_get_rnr_tpe_usable() - Tells if RNR IE is applicable for current 1940 * domain. 1941 * @pdev: Pointer to PDEV object. 1942 * @reg_rnr_tpe_usable: Pointer to hold the bool value, true if RNR IE is 1943 * applicable, else false. 1944 * 1945 * Return: QDF_STATUS. 1946 */ 1947 QDF_STATUS wlan_reg_get_rnr_tpe_usable(struct wlan_objmgr_pdev *pdev, 1948 bool *reg_rnr_tpe_usable); 1949 1950 /** 1951 * wlan_reg_get_unspecified_ap_usable() - Tells if AP type unspecified by 802.11 1952 * can be used or not. 1953 * @pdev: Pointer to PDEV object. 1954 * @reg_unspecified_ap_usable: Pointer to hold the bool value, true if 1955 * unspecified AP types can be used in the IE, else false. 1956 * 1957 * Return: QDF_STATUS. 1958 */ 1959 QDF_STATUS wlan_reg_get_unspecified_ap_usable(struct wlan_objmgr_pdev *pdev, 1960 bool *reg_unspecified_ap_usable); 1961 1962 /** 1963 * wlan_reg_is_6g_psd_power() - Checks if given freq is PSD power 1964 * 1965 * @pdev: pdev ptr 1966 * @freq: channel frequency 1967 * 1968 * Return: true if channel is PSD power or false otherwise 1969 */ 1970 bool wlan_reg_is_6g_psd_power(struct wlan_objmgr_pdev *pdev); 1971 1972 /** 1973 * wlan_reg_get_6g_chan_ap_power() - Finds the AP TX power for the given channel 1974 * frequency 1975 * 1976 * @pdev: pdev ptr 1977 * @chan_freq: channel frequency 1978 * @is_psd: is channel PSD or not 1979 * @tx_power: transmit power to fill for chan_freq 1980 * @eirp_psd_power: EIRP power, will only be filled if is_psd is true 1981 * 1982 * Return: QDF_STATUS 1983 */ 1984 QDF_STATUS wlan_reg_get_6g_chan_ap_power(struct wlan_objmgr_pdev *pdev, 1985 qdf_freq_t chan_freq, bool *is_psd, 1986 uint16_t *tx_power, 1987 uint16_t *eirp_psd_power); 1988 1989 /** 1990 * wlan_reg_get_client_power_for_connecting_ap() - Find the channel information 1991 * when device is operating as a client 1992 * 1993 * @pdev: pdev ptr 1994 * @ap_type: type of AP that device is connected to 1995 * @chan_freq: channel frequency 1996 * @is_psd: is channel PSD or not 1997 * @tx_power: transmit power to fill for chan_freq 1998 * @eirp_psd_power: EIRP power, will only be filled if is_psd is true 1999 * 2000 * This function is meant to be called to find the channel frequency power 2001 * information for a client when the device is operating as a client. It will 2002 * fill in the parameter is_psd, tx_power, and eirp_psd_power. eirp_psd_power 2003 * will only be filled if the channel is PSD. 2004 * 2005 * Return: QDF_STATUS 2006 */ 2007 QDF_STATUS 2008 wlan_reg_get_client_power_for_connecting_ap(struct wlan_objmgr_pdev *pdev, 2009 enum reg_6g_ap_type ap_type, 2010 qdf_freq_t chan_freq, 2011 bool *is_psd, uint16_t *tx_power, 2012 uint16_t *eirp_psd_power); 2013 2014 /** 2015 * wlan_reg_get_client_power_for_6ghz_ap() - Find the channel information when 2016 * device is operating as a 6GHz AP 2017 * 2018 * @pdev: pdev ptr 2019 * @client_type: type of client that is connected to our AP 2020 * @chan_freq: channel frequency 2021 * @is_psd: is channel PSD or not 2022 * @tx_power: transmit power to fill for chan_freq 2023 * @eirp_psd_power: EIRP power, will only be filled if is_psd is true 2024 * 2025 * This function is meant to be called to find the channel frequency power 2026 * information for a client when the device is operating as an AP. It will fill 2027 * in the parameter is_psd, tx_power, and eirp_psd_power. eirp_psd_power will 2028 * only be filled if the channel is PSD. 2029 * 2030 * Return: QDF_STATUS 2031 */ 2032 QDF_STATUS 2033 wlan_reg_get_client_power_for_6ghz_ap(struct wlan_objmgr_pdev *pdev, 2034 enum reg_6g_client_type client_type, 2035 qdf_freq_t chan_freq, 2036 bool *is_psd, uint16_t *tx_power, 2037 uint16_t *eirp_psd_power); 2038 2039 /** 2040 * wlan_reg_decide_6g_ap_pwr_type() - Decide which power mode AP should operate 2041 * in 2042 * 2043 * @pdev: pdev ptr 2044 * 2045 * Return: AP power type 2046 */ 2047 enum reg_6g_ap_type 2048 wlan_reg_decide_6g_ap_pwr_type(struct wlan_objmgr_pdev *pdev); 2049 2050 /** 2051 * wlan_reg_set_ap_pwr_and_update_chan_list() - Set the AP power mode and 2052 * recompute the current channel list 2053 * 2054 * @pdev: pdev ptr 2055 * @ap_pwr_type: the AP power type to update to 2056 * 2057 * Return: QDF_STATUS 2058 */ 2059 QDF_STATUS 2060 wlan_reg_set_ap_pwr_and_update_chan_list(struct wlan_objmgr_pdev *pdev, 2061 enum reg_6g_ap_type ap_pwr_type); 2062 #else 2063 static inline QDF_STATUS 2064 wlan_reg_get_cur_6g_ap_pwr_type(struct wlan_objmgr_pdev *pdev, 2065 enum reg_6g_ap_type *reg_cur_6g_ap_pwr_type) 2066 { 2067 *reg_cur_6g_ap_pwr_type = REG_CURRENT_MAX_AP_TYPE; 2068 return QDF_STATUS_E_NOSUPPORT; 2069 } 2070 2071 static inline QDF_STATUS 2072 wlan_reg_get_cur_6g_client_type(struct wlan_objmgr_pdev *pdev, 2073 enum reg_6g_client_type 2074 *reg_cur_6g_client_mobility_type) 2075 { 2076 *reg_cur_6g_client_mobility_type = REG_SUBORDINATE_CLIENT; 2077 return QDF_STATUS_E_NOSUPPORT; 2078 } 2079 2080 static inline 2081 QDF_STATUS wlan_reg_get_rnr_tpe_usable(struct wlan_objmgr_pdev *pdev, 2082 bool *reg_rnr_tpe_usable) 2083 { 2084 *reg_rnr_tpe_usable = false; 2085 return QDF_STATUS_E_NOSUPPORT; 2086 } 2087 2088 static inline 2089 QDF_STATUS wlan_reg_get_unspecified_ap_usable(struct wlan_objmgr_pdev *pdev, 2090 bool *reg_unspecified_ap_usable) 2091 { 2092 *reg_unspecified_ap_usable = false; 2093 return QDF_STATUS_E_NOSUPPORT; 2094 } 2095 2096 static inline 2097 bool wlan_reg_is_6g_psd_power(struct wlan_objmgr_pdev *pdev) 2098 { 2099 return false; 2100 } 2101 2102 static inline 2103 QDF_STATUS wlan_reg_get_6g_chan_ap_power(struct wlan_objmgr_pdev *pdev, 2104 qdf_freq_t chan_freq, bool *is_psd, 2105 uint16_t *tx_power, 2106 uint16_t *eirp_psd_power) 2107 { 2108 *is_psd = false; 2109 *tx_power = 0; 2110 *eirp_psd_power = 0; 2111 return QDF_STATUS_E_NOSUPPORT; 2112 } 2113 2114 static inline QDF_STATUS 2115 wlan_reg_get_client_power_for_connecting_ap(struct wlan_objmgr_pdev *pdev, 2116 enum reg_6g_ap_type ap_type, 2117 qdf_freq_t chan_freq, 2118 bool *is_psd, uint16_t *tx_power, 2119 uint16_t *eirp_psd_power) 2120 { 2121 *is_psd = false; 2122 *tx_power = 0; 2123 *eirp_psd_power = 0; 2124 return QDF_STATUS_E_NOSUPPORT; 2125 } 2126 2127 static inline QDF_STATUS 2128 wlan_reg_get_client_power_for_6ghz_ap(struct wlan_objmgr_pdev *pdev, 2129 enum reg_6g_client_type client_type, 2130 qdf_freq_t chan_freq, 2131 bool *is_psd, uint16_t *tx_power, 2132 uint16_t *eirp_psd_power) 2133 { 2134 *is_psd = false; 2135 *tx_power = 0; 2136 *eirp_psd_power = 0; 2137 return QDF_STATUS_E_NOSUPPORT; 2138 } 2139 2140 static inline enum reg_6g_ap_type 2141 wlan_reg_decide_6g_ap_pwr_type(struct wlan_objmgr_pdev *pdev) 2142 { 2143 return REG_INDOOR_AP; 2144 } 2145 2146 static inline QDF_STATUS 2147 wlan_reg_set_ap_pwr_and_update_chan_list(struct wlan_objmgr_pdev *pdev, 2148 enum reg_6g_ap_type ap_pwr_type) 2149 { 2150 return QDF_STATUS_E_NOSUPPORT; 2151 } 2152 #endif 2153 2154 /** 2155 * wlan_reg_is_ext_tpc_supported() - Checks if FW supports new WMI cmd for TPC 2156 * 2157 * @psoc: psoc ptr 2158 * 2159 * Return: true if FW supports new command or false otherwise 2160 */ 2161 bool wlan_reg_is_ext_tpc_supported(struct wlan_objmgr_psoc *psoc); 2162 2163 /** 2164 * wlan_reg_is_chwidth_supported() - Check if given channel width is supported 2165 * on a given pdev 2166 * @pdev: pdev pointer 2167 * @ch_width: channel width. 2168 * @is_supported: whether the channel width is supported 2169 * 2170 * Return QDF_STATUS_SUCCESS of operation 2171 */ 2172 QDF_STATUS wlan_reg_is_chwidth_supported(struct wlan_objmgr_pdev *pdev, 2173 enum phy_ch_width ch_width, 2174 bool *is_supported); 2175 #endif 2176