1 /* 2 * Copyright (c) 2017-2019 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 #ifdef CONFIG_CHAN_NUM_API 30 /** 31 * wlan_reg_min_24ghz_ch_num() - Get minimum 2.4GHz channel number 32 * 33 * Return: Minimum 2.4GHz channel number 34 */ 35 #define WLAN_REG_MIN_24GHZ_CH_NUM wlan_reg_min_24ghz_ch_num() 36 uint32_t wlan_reg_min_24ghz_ch_num(void); 37 38 /** 39 * wlan_reg_max_24ghz_ch_num() - Get maximum 2.4GHz channel number 40 * 41 * Return: Maximum 2.4GHz channel number 42 */ 43 #define WLAN_REG_MAX_24GHZ_CH_NUM wlan_reg_max_24ghz_ch_num() 44 uint32_t wlan_reg_max_24ghz_ch_num(void); 45 46 /** 47 * wlan_reg_min_5ghz_ch_num() - Get minimum 5GHz channel number 48 * 49 * Return: Minimum 5GHz channel number 50 */ 51 #define WLAN_REG_MIN_5GHZ_CH_NUM wlan_reg_min_5ghz_ch_num() 52 uint32_t wlan_reg_min_5ghz_ch_num(void); 53 54 /** 55 * wlan_reg_max_5ghz_ch_num() - Get maximum 5GHz channel number 56 * 57 * Return: Maximum 5GHz channel number 58 */ 59 #define WLAN_REG_MAX_5GHZ_CH_NUM wlan_reg_max_5ghz_ch_num() 60 uint32_t wlan_reg_max_5ghz_ch_num(void); 61 #endif /* CONFIG_CHAN_NUM_API */ 62 63 #ifdef CONFIG_CHAN_FREQ_API 64 /** 65 * wlan_reg_min_24ghz_chan_freq() - Get minimum 2.4GHz channel frequency 66 * 67 * Return: Minimum 2.4GHz channel frequency 68 */ 69 #define WLAN_REG_MIN_24GHZ_CHAN_FREQ wlan_reg_min_24ghz_chan_freq() 70 uint16_t wlan_reg_min_24ghz_chan_freq(void); 71 72 /** 73 * wlan_reg_max_24ghz_chan_freq() - Get maximum 2.4GHz channel frequency 74 * 75 * Return: Maximum 2.4GHz channel frequency 76 */ 77 #define WLAN_REG_MAX_24GHZ_CHAN_FREQ wlan_reg_max_24ghz_chan_freq() 78 uint16_t wlan_reg_max_24ghz_chan_freq(void); 79 80 /** 81 * wlan_reg_min_5ghz_chan_freq() - Get minimum 5GHz channel frequency 82 * 83 * Return: Minimum 5GHz channel frequency 84 */ 85 #define WLAN_REG_MIN_5GHZ_CHAN_FREQ wlan_reg_min_5ghz_chan_freq() 86 uint16_t wlan_reg_min_5ghz_chan_freq(void); 87 88 /** 89 * wlan_reg_max_5ghz_chan_freq() - Get maximum 5GHz channel frequency 90 * 91 * Return: Maximum 5GHz channel frequency 92 */ 93 #define WLAN_REG_MAX_5GHZ_CHAN_FREQ wlan_reg_max_5ghz_chan_freq() 94 uint16_t wlan_reg_max_5ghz_chan_freq(void); 95 #endif /* CONFIG_CHAN_FREQ_API */ 96 97 #ifdef CONFIG_CHAN_NUM_API 98 /** 99 * wlan_reg_is_24ghz_ch() - Check if the given channel number is 2.4GHz 100 * @chan: Channel number 101 * 102 * Return: true if channel number is 2.4GHz, else false 103 */ 104 #define WLAN_REG_IS_24GHZ_CH(chan) wlan_reg_is_24ghz_ch(chan) 105 bool wlan_reg_is_24ghz_ch(uint32_t chan); 106 107 /** 108 * wlan_reg_is_5ghz_ch() - Check if the given channel number is 5GHz 109 * @chan: Channel number 110 * 111 * Return: true if channel number is 5GHz, else false 112 */ 113 #define WLAN_REG_IS_5GHZ_CH(chan) wlan_reg_is_5ghz_ch(chan) 114 bool wlan_reg_is_5ghz_ch(uint32_t chan); 115 #endif /* CONFIG_CHAN_NUM_API */ 116 117 /** 118 * wlan_reg_is_24ghz_ch_freq() - Check if the given channel frequency is 2.4GHz 119 * @freq: Channel frequency 120 * 121 * Return: true if channel frequency is 2.4GHz, else false 122 */ 123 #define WLAN_REG_IS_24GHZ_CH_FREQ(freq) wlan_reg_is_24ghz_ch_freq(freq) 124 bool wlan_reg_is_24ghz_ch_freq(uint32_t freq); 125 126 /** 127 * wlan_reg_is_5ghz_ch_freq() - Check if the given channel frequency is 5GHz 128 * @freq: Channel frequency 129 * 130 * Return: true if channel frequency is 5GHz, else false 131 */ 132 #define WLAN_REG_IS_5GHZ_CH_FREQ(freq) wlan_reg_is_5ghz_ch_freq(freq) 133 bool wlan_reg_is_5ghz_ch_freq(uint32_t freq); 134 135 #ifdef CONFIG_BAND_6GHZ 136 /** 137 * wlan_reg_is_6ghz_chan_freq() - Check if the given channel frequency is 6GHz 138 * @freq: Channel frequency 139 * 140 * Return: true if channel frequency is 6GHz, else false 141 */ 142 #define WLAN_REG_IS_6GHZ_CHAN_FREQ(freq) wlan_reg_is_6ghz_chan_freq(freq) 143 bool wlan_reg_is_6ghz_chan_freq(uint16_t freq); 144 145 /** 146 * wlan_reg_is_6ghz_psc_chan_freq() - Check if the given 6GHz channel frequency 147 * is preferred scanning channel frequency. 148 * @freq: Channel frequency 149 * 150 * Return: true if given 6GHz channel frequency is preferred scanning channel 151 * frequency, else false 152 */ 153 #define WLAN_REG_IS_6GHZ_PSC_CHAN_FREQ(freq) \ 154 wlan_reg_is_6ghz_psc_chan_freq(freq) 155 bool wlan_reg_is_6ghz_psc_chan_freq(uint16_t freq); 156 157 /** 158 * wlan_reg_min_6ghz_chan_freq() - Get minimum 6GHz channel center frequency 159 * 160 * Return: Minimum 6GHz channel center frequency 161 */ 162 #define WLAN_REG_MIN_6GHZ_CHAN_FREQ wlan_reg_min_6ghz_chan_freq() 163 uint16_t wlan_reg_min_6ghz_chan_freq(void); 164 165 /** 166 * wlan_reg_max_6ghz_chan_freq() - Get maximum 6GHz channel center frequency 167 * 168 * Return: Maximum 6GHz channel center frequency 169 */ 170 #define WLAN_REG_MAX_6GHZ_CHAN_FREQ wlan_reg_max_6ghz_chan_freq() 171 uint16_t wlan_reg_max_6ghz_chan_freq(void); 172 173 #else 174 175 #define WLAN_REG_IS_6GHZ_CHAN_FREQ(freq) (false) 176 static inline bool wlan_reg_is_6ghz_chan_freq(uint16_t freq) 177 { 178 return false; 179 } 180 181 #define WLAN_REG_IS_6GHZ_PSC_CHAN_FREQ(freq) (false) 182 static inline bool wlan_reg_is_6ghz_psc_chan_freq(uint16_t freq) 183 { 184 return false; 185 } 186 187 #define WLAN_REG_MIN_6GHZ_CHAN_FREQ (false) 188 static inline uint16_t wlan_reg_min_6ghz_chan_freq(void) 189 { 190 return 0; 191 } 192 193 #define WLAN_REG_MAX_6GHZ_CHAN_FREQ (false) 194 static inline uint16_t wlan_reg_max_6ghz_chan_freq(void) 195 { 196 return 0; 197 } 198 #endif /* CONFIG_BAND_6GHZ */ 199 200 /** 201 * wlan_reg_get_band_channel_list() - Get channel list based on the band_mask 202 * @pdev: pdev ptr 203 * @band_mask: Input bitmap with band set 204 * @channel_list: Pointer to Channel List 205 * 206 * Get the given channel list and number of channels from the current channel 207 * list based on input band bitmap. 208 * 209 * Return: Number of channels, else 0 to indicate error 210 */ 211 uint16_t 212 wlan_reg_get_band_channel_list(struct wlan_objmgr_pdev *pdev, 213 uint8_t band_mask, 214 struct regulatory_channel *channel_list); 215 216 /** 217 * wlan_reg_chan_band_to_freq - Return channel frequency based on the channel 218 * number and band. 219 * @pdev: pdev ptr 220 * @chan: Channel Number 221 * @band_mask: Bitmap for bands 222 * 223 * Return: Return channel frequency or return 0, if the channel is disabled or 224 * if the input channel number or band_mask is invalid. Composite bands are 225 * supported only for 2.4Ghz and 5Ghz bands. For other bands the following 226 * priority is given: 1) 6Ghz 2) 5Ghz 3) 2.4Ghz. 227 */ 228 uint16_t wlan_reg_chan_band_to_freq(struct wlan_objmgr_pdev *pdev, 229 uint8_t chan, 230 uint8_t band_mask); 231 232 /** 233 * wlan_reg_is_49ghz_freq() - Check if the given channel frequency is 4.9GHz 234 * @freq: Channel frequency 235 * 236 * Return: true if channel frequency is 4.9GHz, else false 237 */ 238 #define WLAN_REG_IS_49GHZ_FREQ(freq) wlan_reg_is_49ghz_freq(freq) 239 bool wlan_reg_is_49ghz_freq(uint32_t freq); 240 241 /** 242 * wlan_reg_ch_num() - Get channel number from channel enum 243 * @ch_enum: Channel enum 244 * 245 * Return: channel number 246 */ 247 #define WLAN_REG_CH_NUM(ch_enum) wlan_reg_ch_num(ch_enum) 248 uint32_t wlan_reg_ch_num(uint32_t ch_enum); 249 250 /** 251 * wlan_reg_ch_to_freq() - Get channel frequency from channel enum 252 * @ch_enum: Channel enum 253 * 254 * Return: channel frequency 255 */ 256 #define WLAN_REG_CH_TO_FREQ(ch_enum) wlan_reg_ch_to_freq(ch_enum) 257 uint32_t wlan_reg_ch_to_freq(uint32_t ch_enum); 258 259 #ifdef CONFIG_CHAN_NUM_API 260 /** 261 * wlan_reg_is_same_band_channels() - Check if given channel numbers have same 262 * band 263 * @chan_num1: Channel number1 264 * @chan_num2: Channel number2 265 * 266 * Return: true if both the channels has the same band. 267 */ 268 #define WLAN_REG_IS_SAME_BAND_CHANNELS(chan_num1, chan_num2) \ 269 wlan_reg_is_same_band_channels(chan_num1, chan_num2) 270 bool wlan_reg_is_same_band_channels(uint32_t chan_num1, uint32_t chan_num2); 271 272 /** 273 * wlan_reg_is_channel_valid_5g_sbs() Check if the given channel is 5G SBS. 274 * @curchan: current channel 275 * @newchan:new channel 276 * 277 * Return: true if the given channel is a valid 5G SBS 278 */ 279 #define WLAN_REG_IS_CHANNEL_VALID_5G_SBS(curchan, newchan) \ 280 wlan_reg_is_channel_valid_5g_sbs(curchan, newchan) 281 bool wlan_reg_is_channel_valid_5g_sbs(uint32_t curchan, uint32_t newchan); 282 #endif /* CONFIG_CHAN_NUM_API */ 283 284 285 #ifdef CONFIG_CHAN_NUM_API 286 /** 287 * wlan_reg_chan_to_band() - Get band from channel number 288 * @chan_num: channel number 289 * 290 * Return: band info 291 */ 292 #define WLAN_REG_CHAN_TO_BAND(chan_num) wlan_reg_chan_to_band(chan_num) 293 enum band_info wlan_reg_chan_to_band(uint32_t chan_num); 294 295 /** 296 * wlan_reg_get_channel_list_with_power() - Provide the channel list with power 297 * @ch_list: pointer to the channel list. 298 * 299 * Return: QDF_STATUS 300 */ 301 QDF_STATUS wlan_reg_get_channel_list_with_power(struct wlan_objmgr_pdev *pdev, 302 struct channel_power *ch_list, 303 uint8_t *num_chan); 304 #endif /* CONFIG_CHAN_NUM_API */ 305 /** 306 * wlan_reg_read_default_country() - Read the default country for the regdomain 307 * @country: pointer to the country code. 308 * 309 * Return: QDF_STATUS 310 */ 311 QDF_STATUS wlan_reg_read_default_country(struct wlan_objmgr_psoc *psoc, 312 uint8_t *country); 313 314 /** 315 * wlan_reg_get_fcc_constraint() - Check FCC constraint on given frequency 316 * @pdev: physical dev to get 317 * @freq: frequency to be checked 318 * 319 * Return: If FCC constraint is on applied given frequency return true 320 * else return false. 321 */ 322 bool wlan_reg_get_fcc_constraint(struct wlan_objmgr_pdev *pdev, uint32_t freq); 323 324 #ifdef CONFIG_REG_CLIENT 325 /** 326 * wlan_reg_read_current_country() - Read the current country for the regdomain 327 * @country: pointer to the country code. 328 * 329 * Return: QDF_STATUS 330 */ 331 QDF_STATUS wlan_reg_read_current_country(struct wlan_objmgr_psoc *psoc, 332 uint8_t *country); 333 334 #ifdef CONFIG_CHAN_NUM_API 335 /** 336 * wlan_reg_chan_has_dfs_attribute() - check channel has dfs attribute flag 337 * @ch: channel number. 338 * 339 * This API get chan initial dfs attribute from regdomain 340 * 341 * Return: true if chan is dfs, otherwise false 342 */ 343 bool 344 wlan_reg_chan_has_dfs_attribute(struct wlan_objmgr_pdev *pdev, uint32_t ch); 345 346 /** 347 * wlan_reg_is_etsi13_srd_chan () - Checks if the ch is ETSI13 srd ch or not 348 * @pdev: pdev ptr 349 * @chan_num: channel 350 * 351 * Return: true or false 352 */ 353 bool wlan_reg_is_etsi13_srd_chan(struct wlan_objmgr_pdev *pdev, 354 uint8_t chan_num); 355 #endif /* CONFIG_CHAN_NUM_API */ 356 357 #ifdef CONFIG_CHAN_FREQ_API 358 /** 359 * wlan_reg_is_etsi13_srd_chan_for_freq () - Checks if the ch is ETSI13 srd ch 360 * or not 361 * @pdev: pdev ptr 362 * @freq: channel center frequency 363 * 364 * Return: true or false 365 */ 366 bool wlan_reg_is_etsi13_srd_chan_for_freq(struct wlan_objmgr_pdev *pdev, 367 uint16_t freq); 368 #endif /*CONFIG_CHAN_FREQ_API*/ 369 370 /** 371 * wlan_reg_is_etsi13_regdmn() - Checks if current reg domain is ETSI13 or not 372 * @pdev: pdev ptr 373 * 374 * Return: true or false 375 */ 376 bool wlan_reg_is_etsi13_regdmn(struct wlan_objmgr_pdev *pdev); 377 378 /** 379 * wlan_reg_is_etsi13_srd_chan_allowed_master_mode() - Checks if regdmn is 380 * ETSI13 and SRD channels are allowed in master mode or not. 381 * 382 * @pdev: pdev ptr 383 * 384 * Return: true or false 385 */ 386 bool wlan_reg_is_etsi13_srd_chan_allowed_master_mode(struct wlan_objmgr_pdev 387 *pdev); 388 #endif 389 390 /** 391 * wlan_reg_is_world() - reg is world mode 392 * @country: The country information 393 * 394 * Return: true or false 395 */ 396 bool wlan_reg_is_world(uint8_t *country); 397 398 #ifdef CONFIG_CHAN_NUM_API 399 /** 400 * wlan_reg_get_chan_enum() - Get channel enum for given channel number 401 * @chan_num: Channel number 402 * 403 * Return: Channel enum 404 */ 405 enum channel_enum wlan_reg_get_chan_enum(uint32_t chan_num); 406 407 /** 408 * wlan_reg_get_channel_state() - Get channel state from regulatory 409 * @ch: channel number. 410 * 411 * Return: channel state 412 */ 413 enum channel_state wlan_reg_get_channel_state(struct wlan_objmgr_pdev *pdev, 414 uint32_t ch); 415 416 /** 417 * wlan_reg_get_5g_bonded_channel_and_state() - Get 5G bonded channel and state 418 * @ch: channel number. 419 * @bw: channel band width 420 * @bonded_chan_ptr_ptr: bonded channel ptr ptr 421 * 422 * Return: channel state 423 */ 424 enum channel_state wlan_reg_get_5g_bonded_channel_and_state( 425 struct wlan_objmgr_pdev *pdev, uint8_t ch, 426 enum phy_ch_width bw, 427 const struct bonded_channel **bonded_chan_ptr_ptr); 428 429 /** 430 * wlan_reg_get_5g_bonded_channel_state() - Get 5G bonded channel state 431 * @pdev: The physical dev to program country code or regdomain 432 * @ch: channel number. 433 * @bw: channel band width 434 * 435 * Return: channel state 436 */ 437 enum channel_state wlan_reg_get_5g_bonded_channel_state( 438 struct wlan_objmgr_pdev *pdev, uint8_t ch, 439 enum phy_ch_width bw); 440 441 /** 442 * wlan_reg_get_2g_bonded_channel_state() - Get 2G bonded channel state 443 * @pdev: The physical dev to program country code or regdomain 444 * @ch: channel number. 445 * @sec_ch: Secondary channel. 446 * @bw: channel band width 447 * 448 * Return: channel state 449 */ 450 enum channel_state wlan_reg_get_2g_bonded_channel_state( 451 struct wlan_objmgr_pdev *pdev, uint8_t ch, 452 uint8_t sec_ch, enum phy_ch_width bw); 453 454 /** 455 * wlan_reg_set_channel_params () - Sets channel parameteres for given bandwidth 456 * @pdev: The physical dev to program country code or regdomain 457 * @ch: channel number. 458 * @sec_ch_2g: Secondary channel. 459 * @ch_params: pointer to the channel parameters. 460 * 461 * Return: None 462 */ 463 void wlan_reg_set_channel_params(struct wlan_objmgr_pdev *pdev, uint8_t ch, 464 uint8_t sec_ch_2g, 465 struct ch_params *ch_params); 466 #endif /* CONFIG_CHAN_NUM_API */ 467 /** 468 * wlan_reg_get_dfs_region () - Get the current dfs region 469 * @dfs_reg: pointer to dfs region 470 * 471 * Return: Status 472 */ 473 QDF_STATUS wlan_reg_get_dfs_region(struct wlan_objmgr_pdev *pdev, 474 enum dfs_reg *dfs_reg); 475 476 #ifdef CONFIG_CHAN_NUM_API 477 /** 478 * wlan_reg_get_channel_reg_power() - Provide the channel regulatory power 479 * @chan_num: channel number 480 * 481 * Return: int 482 */ 483 uint32_t wlan_reg_get_channel_reg_power(struct wlan_objmgr_pdev *pdev, 484 uint32_t chan_num); 485 486 /** 487 * wlan_reg_get_channel_freq() - provide the channel center freq 488 * @chan_num: channel number 489 * 490 * Return: int 491 */ 492 uint32_t wlan_reg_get_channel_freq(struct wlan_objmgr_pdev *pdev, 493 uint32_t chan_num); 494 #endif /* CONFIG_CHAN_NUM_API */ 495 496 /** 497 * wlan_reg_get_current_chan_list() - provide the pdev current channel list 498 * @pdev: pdev pointer 499 * @chan_list: channel list pointer 500 * 501 * Return: QDF_STATUS 502 */ 503 QDF_STATUS wlan_reg_get_current_chan_list(struct wlan_objmgr_pdev *pdev, 504 struct regulatory_channel *chan_list); 505 506 #ifdef CONFIG_CHAN_NUM_API 507 /** 508 * wlan_reg_get_bonded_channel_state() - get bonded channel state 509 * @pdev: pdev ptr 510 * @ch: chennal number 511 * @bw: chennal number 512 * @sec_ch: secondary channel 513 * 514 * Return: enum channel_state 515 */ 516 enum channel_state wlan_reg_get_bonded_channel_state( 517 struct wlan_objmgr_pdev *pdev, uint8_t ch, 518 enum phy_ch_width bw, uint8_t sec_ch); 519 #endif /* CONFIG_CHAN_NUM_API */ 520 521 /** 522 * wlan_reg_set_dfs_region() - set the dfs region 523 * @pdev: pdev ptr 524 * @dfs_reg: dfs region 525 * 526 * Return: void 527 */ 528 void wlan_reg_set_dfs_region(struct wlan_objmgr_pdev *pdev, 529 enum dfs_reg dfs_reg); 530 531 /** 532 * wlan_reg_get_bw_value() - provide the channel center freq 533 * @chan_num: chennal number 534 * 535 * Return: int 536 */ 537 uint16_t wlan_reg_get_bw_value(enum phy_ch_width bw); 538 539 /** 540 * wlan_reg_get_domain_from_country_code() - provide the channel center freq 541 * @reg_domain_ptr: regulatory domain ptr 542 * @country_alpha2: country alpha2 543 * @source: alpha2 source 544 * 545 * Return: int 546 */ 547 QDF_STATUS wlan_reg_get_domain_from_country_code(v_REGDOMAIN_t *reg_domain_ptr, 548 const uint8_t *country_alpha2, 549 enum country_src source); 550 551 /** 552 * wlan_reg_dmn_get_opclass_from_channel() - provide the channel center freq 553 * @country: country alpha2 554 * @channel: channel number 555 * @offset: offset 556 * 557 * Return: int 558 */ 559 uint16_t wlan_reg_dmn_get_opclass_from_channel(uint8_t *country, 560 uint8_t channel, 561 uint8_t offset); 562 /** 563 * wlan_reg_dmn_print_channels_in_opclass() - Print channels in op-class 564 * @country: country alpha2 565 * @opclass: oplcass 566 * 567 * Return: void 568 */ 569 void wlan_reg_dmn_print_channels_in_opclass(uint8_t *country, 570 uint8_t opclass); 571 572 573 /** 574 * wlan_reg_dmn_get_chanwidth_from_opclass() - get channel width from 575 * operating class 576 * @country: country alpha2 577 * @channel: channel number 578 * @opclass: operating class 579 * 580 * Return: int 581 */ 582 uint16_t wlan_reg_dmn_get_chanwidth_from_opclass(uint8_t *country, 583 uint8_t channel, 584 uint8_t opclass); 585 /** 586 * wlan_reg_dmn_set_curr_opclasses() - set operating class 587 * @num_classes: number of classes 588 * @class: operating class 589 * 590 * Return: int 591 */ 592 uint16_t wlan_reg_dmn_set_curr_opclasses(uint8_t num_classes, 593 uint8_t *class); 594 595 /** 596 * wlan_reg_dmn_get_curr_opclasses() - get current oper classes 597 * @num_classes: number of classes 598 * @class: operating class 599 * 600 * Return: int 601 */ 602 uint16_t wlan_reg_dmn_get_curr_opclasses(uint8_t *num_classes, 603 uint8_t *class); 604 605 606 /** 607 * wlan_regulatory_init() - init regulatory component 608 * 609 * Return: Success or Failure 610 */ 611 QDF_STATUS wlan_regulatory_init(void); 612 613 /** 614 * wlan_regulatory_deinit() - deinit regulatory component 615 * 616 * Return: Success or Failure 617 */ 618 QDF_STATUS wlan_regulatory_deinit(void); 619 620 /** 621 * regulatory_psoc_open() - open regulatory component 622 * 623 * Return: Success or Failure 624 */ 625 QDF_STATUS regulatory_psoc_open(struct wlan_objmgr_psoc *psoc); 626 627 628 /** 629 * regulatory_psoc_close() - close regulatory component 630 * 631 * Return: Success or Failure 632 */ 633 QDF_STATUS regulatory_psoc_close(struct wlan_objmgr_psoc *psoc); 634 635 /** 636 * regulatory_pdev_open() - Open regulatory component 637 * @pdev: Pointer to pdev structure. 638 * 639 * Return: Success or Failure 640 */ 641 QDF_STATUS regulatory_pdev_open(struct wlan_objmgr_pdev *pdev); 642 643 /** 644 * regulatory_pdev_close() - Close regulatory component 645 * @pdev: Pointer to pdev structure. 646 * 647 * Return: Success or Failure 648 */ 649 QDF_STATUS regulatory_pdev_close(struct wlan_objmgr_pdev *pdev); 650 651 #ifdef CONFIG_CHAN_NUM_API 652 /** 653 * wlan_reg_update_nol_ch () - set nol channel 654 * @pdev: pdev ptr 655 * @ch_list: channel list to be returned 656 * @num_ch: number of channels 657 * @nol_ch: nol flag 658 * 659 * Return: void 660 */ 661 void wlan_reg_update_nol_ch(struct wlan_objmgr_pdev *pdev, 662 uint8_t *ch_list, 663 uint8_t num_ch, 664 bool nol_ch); 665 666 /** 667 * wlan_reg_is_dfs_ch () - Checks the channel state for DFS 668 * @pdev: pdev ptr 669 * @chan: channel 670 * 671 * Return: true or false 672 */ 673 bool wlan_reg_is_dfs_ch(struct wlan_objmgr_pdev *pdev, uint32_t chan); 674 675 /** 676 * wlan_reg_is_dsrc_chan () - Checks if the channel is dsrc channel or not 677 * @pdev: pdev ptr 678 * @chan_num: channel 679 * 680 * Return: true or false 681 */ 682 bool wlan_reg_is_dsrc_chan(struct wlan_objmgr_pdev *pdev, uint8_t chan_num); 683 684 /** 685 * wlan_reg_is_passive_or_disable_ch () - Checks chan state for passive 686 * and disabled 687 * @pdev: pdev ptr 688 * @chan: channel 689 * 690 * Return: true or false 691 */ 692 bool wlan_reg_is_passive_or_disable_ch(struct wlan_objmgr_pdev *pdev, 693 uint32_t chan); 694 695 /** 696 * wlan_reg_is_disable_ch () - Checks chan state for disabled 697 * @pdev: pdev ptr 698 * @chan: channel 699 * 700 * Return: true or false 701 */ 702 bool wlan_reg_is_disable_ch(struct wlan_objmgr_pdev *pdev, uint32_t chan); 703 #endif /* CONFIG_CHAN_NUM_API */ 704 705 /** 706 * wlan_reg_freq_to_chan () - convert channel freq to channel number 707 * @pdev: The physical dev to set current country for 708 * @freq: frequency 709 * 710 * Return: true or false 711 */ 712 uint32_t wlan_reg_freq_to_chan(struct wlan_objmgr_pdev *pdev, 713 uint32_t freq); 714 715 /** 716 * wlan_reg_chan_to_freq () - convert channel number to frequency 717 * @chan: channel number 718 * 719 * Return: true or false 720 */ 721 uint32_t wlan_reg_chan_to_freq(struct wlan_objmgr_pdev *pdev, 722 uint32_t chan); 723 724 /** 725 * wlan_reg_legacy_chan_to_freq () - convert chan to freq, for 2G and 5G 726 * @chan: channel number 727 * 728 * Return: frequency 729 */ 730 uint16_t wlan_reg_legacy_chan_to_freq(struct wlan_objmgr_pdev *pdev, 731 uint8_t chan); 732 733 /** 734 * wlan_reg_is_us() - reg is us country 735 * @country: The country information 736 * 737 * Return: true or false 738 */ 739 bool wlan_reg_is_us(uint8_t *country); 740 741 #ifdef CONFIG_CHAN_NUM_API 742 /** 743 * wlan_reg_chan_is_49ghz() - Check if the input channel number is 4.9GHz 744 * @pdev: Pdev pointer 745 * @chan_num: Input channel number 746 * 747 * Return: true if the channel is 4.9GHz else false. 748 */ 749 bool wlan_reg_chan_is_49ghz(struct wlan_objmgr_pdev *pdev, 750 uint8_t chan_num); 751 #endif /* CONFIG_CHAN_NUM_API */ 752 753 /** 754 * wlan_reg_set_country() - Set the current regulatory country 755 * @pdev: The physical dev to set current country for 756 * @country: The country information to configure 757 * 758 * Return: QDF_STATUS 759 */ 760 QDF_STATUS wlan_reg_set_country(struct wlan_objmgr_pdev *pdev, 761 uint8_t *country); 762 763 /** 764 * wlan_reg_set_11d_country() - Set the 11d regulatory country 765 * @pdev: The physical dev to set current country for 766 * @country: The country information to configure 767 * 768 * Return: QDF_STATUS 769 */ 770 QDF_STATUS wlan_reg_set_11d_country(struct wlan_objmgr_pdev *pdev, 771 uint8_t *country); 772 773 /** 774 * wlan_reg_register_chan_change_callback () - add chan change cbk 775 * @psoc: psoc ptr 776 * @cbk: callback 777 * @arg: argument 778 * 779 * Return: true or false 780 */ 781 void wlan_reg_register_chan_change_callback(struct wlan_objmgr_psoc *psoc, 782 void *cbk, void *arg); 783 784 /** 785 * wlan_reg_unregister_chan_change_callback () - remove chan change cbk 786 * @psoc: psoc ptr 787 * @cbk:callback 788 * 789 * Return: true or false 790 */ 791 void wlan_reg_unregister_chan_change_callback(struct wlan_objmgr_psoc *psoc, 792 void *cbk); 793 794 /** 795 * wlan_reg_is_11d_offloaded() - 11d offloaded supported 796 * @psoc: psoc ptr 797 * 798 * Return: bool 799 */ 800 bool wlan_reg_is_11d_offloaded(struct wlan_objmgr_psoc *psoc); 801 802 /** 803 * wlan_reg_11d_enabled_on_host() - 11d enabled don host 804 * @psoc: psoc ptr 805 * 806 * Return: bool 807 */ 808 bool wlan_reg_11d_enabled_on_host(struct wlan_objmgr_psoc *psoc); 809 810 /** 811 * wlan_reg_get_chip_mode() - get supported chip mode 812 * @pdev: pdev pointer 813 * @chip_mode: chip mode 814 * 815 * Return: QDF STATUS 816 */ 817 QDF_STATUS wlan_reg_get_chip_mode(struct wlan_objmgr_pdev *pdev, 818 uint32_t *chip_mode); 819 820 /** 821 * wlan_reg_is_11d_scan_inprogress() - checks 11d scan status 822 * @psoc: psoc ptr 823 * 824 * Return: bool 825 */ 826 bool wlan_reg_is_11d_scan_inprogress(struct wlan_objmgr_psoc *psoc); 827 /** 828 * wlan_reg_get_freq_range() - Get 2GHz and 5GHz frequency range 829 * @pdev: pdev pointer 830 * @low_2g: low 2GHz frequency range 831 * @high_2g: high 2GHz frequency range 832 * @low_5g: low 5GHz frequency range 833 * @high_5g: high 5GHz frequency range 834 * 835 * Return: QDF status 836 */ 837 QDF_STATUS wlan_reg_get_freq_range(struct wlan_objmgr_pdev *pdev, 838 uint32_t *low_2g, 839 uint32_t *high_2g, 840 uint32_t *low_5g, 841 uint32_t *high_5g); 842 /** 843 * wlan_reg_get_tx_ops () - get regulatory tx ops 844 * @psoc: psoc ptr 845 * 846 */ 847 struct wlan_lmac_if_reg_tx_ops * 848 wlan_reg_get_tx_ops(struct wlan_objmgr_psoc *psoc); 849 850 /** 851 * wlan_reg_get_curr_regdomain() - Get current regdomain in use 852 * @pdev: pdev pointer 853 * @cur_regdmn: Current regdomain info 854 * 855 * Return: QDF status 856 */ 857 QDF_STATUS wlan_reg_get_curr_regdomain(struct wlan_objmgr_pdev *pdev, 858 struct cur_regdmn_info *cur_regdmn); 859 860 #ifdef CONFIG_CHAN_NUM_API 861 /** 862 * wlan_reg_update_nol_history_ch() - Set nol-history flag for the channels in 863 * the list. 864 * 865 * @pdev: Pdev ptr 866 * @ch_list: Input channel list. 867 * @num_ch: Number of channels. 868 * @nol_history_ch: Nol history value. 869 * 870 * Return: void 871 */ 872 void wlan_reg_update_nol_history_ch(struct wlan_objmgr_pdev *pdev, 873 uint8_t *ch_list, 874 uint8_t num_ch, 875 bool nol_history_ch); 876 #endif /* CONFIG_CHAN_NUM_API */ 877 /** 878 * wlan_reg_is_regdmn_en302502_applicable() - Find if ETSI EN302_502 radar 879 * pattern is applicable in the current regulatory domain. 880 * @pdev: Pdev ptr. 881 * 882 * Return: Boolean. 883 * True: If EN302_502 is applicable. 884 * False: otherwise. 885 */ 886 bool wlan_reg_is_regdmn_en302502_applicable(struct wlan_objmgr_pdev *pdev); 887 888 /** 889 * wlan_reg_modify_pdev_chan_range() - Compute current channel list for the 890 * modified channel range in the regcap. 891 * @pdev: pointer to wlan_objmgr_pdev. 892 * 893 * Return : QDF_STATUS 894 */ 895 QDF_STATUS wlan_reg_modify_pdev_chan_range(struct wlan_objmgr_pdev *pdev); 896 897 #ifdef CONFIG_CHAN_FREQ_API 898 /** 899 * wlan_reg_is_same_band_freqs() - Check if two channel frequencies 900 * have same band 901 * @freq1: Frequency 1 902 * @freq2: Frequency 2 903 * 904 * Return: true if both the channel frequency has the same band. 905 */ 906 #define WLAN_REG_IS_SAME_BAND_FREQS(freq1, freq2) \ 907 wlan_reg_is_same_band_freqs(freq1, freq2) 908 bool wlan_reg_is_same_band_freqs(uint16_t freq1, uint16_t freq2); 909 910 /** 911 * wlan_reg_get_chan_enum_for_freq() - Get channel enum for given channel center 912 * frequency 913 * @freq: Channel center frequency 914 * 915 * Return: Channel enum 916 */ 917 enum channel_enum wlan_reg_get_chan_enum_for_freq(uint16_t freq); 918 919 /** 920 * wlan_reg_update_nol_history_ch_for_freq() - Set nol-history flag for the 921 * channels in the list. 922 * 923 * @pdev: Pdev ptr 924 * @ch_list: Input channel list. 925 * @num_ch: Number of channels. 926 * @nol_history_ch: Nol history value. 927 * 928 * Return: void 929 */ 930 void wlan_reg_update_nol_history_ch_for_freq(struct wlan_objmgr_pdev *pdev, 931 uint16_t *ch_list, 932 uint8_t num_ch, 933 bool nol_history_ch); 934 /** 935 * wlan_reg_is_frequency_valid_5g_sbs() Check if the given frequency is 5G SBS. 936 * @curfreq: current channel center frequency 937 * @newfreq:new channel center frequency 938 * 939 * Return: true if the given frequency is a valid 5G SBS 940 */ 941 #define WLAN_REG_IS_FREQUENCY_VALID_5G_SBS(curfreq, newfreq) \ 942 wlan_reg_is_frequency_valid_5g_sbs(curfreq, newfreq) 943 bool wlan_reg_is_frequency_valid_5g_sbs(uint16_t curfreq, uint16_t newfreq); 944 945 /** 946 * wlan_reg_chan_has_dfs_attribute_for_freq() - check channel has dfs 947 * attribute flag 948 * @freq: channel center frequency. 949 * 950 * This API get chan initial dfs attribute from regdomain 951 * 952 * Return: true if chan is dfs, otherwise false 953 */ 954 bool 955 wlan_reg_chan_has_dfs_attribute_for_freq(struct wlan_objmgr_pdev *pdev, 956 uint16_t freq); 957 958 /** 959 * wlan_reg_get_channel_list_with_power_for_freq() - Provide the channel list 960 * with power 961 * @ch_list: pointer to the channel list. 962 * 963 * Return: QDF_STATUS 964 */ 965 QDF_STATUS 966 wlan_reg_get_channel_list_with_power_for_freq(struct wlan_objmgr_pdev *pdev, 967 struct channel_power *ch_list, 968 uint8_t *num_chan); 969 970 /** 971 * wlan_reg_get_5g_bonded_channel_state_for_freq() - Get 5G bonded channel state 972 * @pdev: The physical dev to program country code or regdomain 973 * @freq: channel frequency. 974 * @bw: channel band width 975 * 976 * Return: channel state 977 */ 978 enum channel_state 979 wlan_reg_get_5g_bonded_channel_state_for_freq(struct wlan_objmgr_pdev *pdev, 980 uint16_t freq, 981 enum phy_ch_width bw); 982 /** 983 * wlan_reg_get_2g_bonded_channel_state_for_freq() - Get 2G bonded channel state 984 * @pdev: The physical dev to program country code or regdomain 985 * @freq: channel center frequency. 986 * @sec_ch_freq: Secondary channel center frequency. 987 * @bw: channel band width 988 * 989 * Return: channel state 990 */ 991 enum channel_state 992 wlan_reg_get_2g_bonded_channel_state_for_freq(struct wlan_objmgr_pdev *pdev, 993 uint16_t freq, 994 uint16_t sec_ch_freq, 995 enum phy_ch_width bw); 996 997 /** 998 * wlan_reg_get_channel_state_for_freq() - Get channel state from regulatory 999 * @pdev: Pointer to pdev 1000 * @freq: channel center frequency. 1001 * 1002 * Return: channel state 1003 */ 1004 enum channel_state 1005 wlan_reg_get_channel_state_for_freq(struct wlan_objmgr_pdev *pdev, 1006 uint16_t freq); 1007 1008 /** 1009 * wlan_reg_set_channel_params_for_freq () - Sets channel parameteres for 1010 * given bandwidth 1011 * @pdev: The physical dev to program country code or regdomain 1012 * @freq: channel center frequency. 1013 * @sec_ch_2g_freq: Secondary channel center frequency. 1014 * @ch_params: pointer to the channel parameters. 1015 * 1016 * Return: None 1017 */ 1018 void wlan_reg_set_channel_params_for_freq(struct wlan_objmgr_pdev *pdev, 1019 uint16_t freq, 1020 uint16_t sec_ch_2g_freq, 1021 struct ch_params *ch_params); 1022 1023 /** 1024 * wlan_reg_get_channel_cfreq_reg_power_for_freq() - Provide the channel 1025 * regulatory power 1026 * @freq: channel center frequency 1027 * 1028 * Return: int 1029 */ 1030 uint8_t wlan_reg_get_channel_reg_power_for_freq(struct wlan_objmgr_pdev *pdev, 1031 uint16_t freq); 1032 1033 /** 1034 * wlan_reg_update_nol_ch_for_freq () - set nol channel 1035 * @pdev: pdev ptr 1036 * @chan_freq_list: channel list to be returned 1037 * @num_ch: number of channels 1038 * @nol_ch: nol flag 1039 * 1040 * Return: void 1041 */ 1042 void wlan_reg_update_nol_ch_for_freq(struct wlan_objmgr_pdev *pdev, 1043 uint16_t *chan_freq_list, 1044 uint8_t num_ch, 1045 bool nol_ch); 1046 1047 /** 1048 * wlan_reg_is_dfs_freq () - Checks the channel state for DFS 1049 * @freq: Channel center frequency 1050 * 1051 * Return: true or false 1052 */ 1053 bool wlan_reg_is_dfs_for_freq(struct wlan_objmgr_pdev *pdev, uint16_t freq); 1054 1055 /** 1056 * wlan_reg_is_dsrc_freq () - Checks if the channel is dsrc channel or not 1057 * @freq: Channel center frequency 1058 * 1059 * Return: true or false 1060 */ 1061 bool wlan_reg_is_dsrc_freq(uint16_t freq); 1062 1063 /** 1064 * wlan_reg_is_passive_or_disable_for_freq () - Checks chan state for passive 1065 * and disabled 1066 * @pdev: pdev ptr 1067 * @freq: Channel center frequency 1068 * 1069 * Return: true or false 1070 */ 1071 bool wlan_reg_is_passive_or_disable_for_freq(struct wlan_objmgr_pdev *pdev, 1072 uint16_t freq); 1073 1074 /** 1075 * wlan_reg_is_disable_for_freq () - Checks chan state for disabled 1076 * @pdev: pdev ptr 1077 * @freq: Channel center frequency 1078 * 1079 * Return: true or false 1080 */ 1081 bool wlan_reg_is_disable_for_freq(struct wlan_objmgr_pdev *pdev, uint16_t freq); 1082 1083 /** 1084 * wlan_reg_chan_to_band() - Get band from channel number 1085 * @chan_num: channel number 1086 * 1087 * Return: wifi band 1088 */ 1089 enum reg_wifi_band wlan_reg_freq_to_band(uint16_t freq); 1090 1091 /** 1092 * wlan_reg_min_chan_freq () - minimum channel frequency supported 1093 * 1094 * Return: frequency 1095 */ 1096 uint16_t wlan_reg_min_chan_freq(void); 1097 1098 /** 1099 * wlan_reg_max_chan_freq () - Checks chan state f 1100 * 1101 * Return: frequency 1102 */ 1103 uint16_t wlan_reg_max_chan_freq(void); 1104 1105 #endif /*CONFIG_CHAN_FREQ_API */ 1106 #endif 1107