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