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