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 #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 uint8_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 uint8_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 uint8_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 uint8_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 qdf_freq_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 qdf_freq_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 qdf_freq_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 qdf_freq_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(uint8_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(uint8_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(qdf_freq_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(qdf_freq_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 qdf_freq_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(qdf_freq_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 uint8_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 qdf_freq_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(uint8_t chan_num1, uint8_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(uint8_t curchan, uint8_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(uint8_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, uint8_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 qdf_freq_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(uint8_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 uint8_t ch); 415 416 /** 417 * wlan_reg_get_5g_bonded_channel_state() - Get 5G bonded channel state 418 * @pdev: The physical dev to program country code or regdomain 419 * @ch: channel number. 420 * @bw: channel band width 421 * 422 * Return: channel state 423 */ 424 enum channel_state wlan_reg_get_5g_bonded_channel_state( 425 struct wlan_objmgr_pdev *pdev, uint8_t ch, 426 enum phy_ch_width bw); 427 428 /** 429 * wlan_reg_get_2g_bonded_channel_state() - Get 2G bonded channel state 430 * @pdev: The physical dev to program country code or regdomain 431 * @ch: channel number. 432 * @sec_ch: Secondary channel. 433 * @bw: channel band width 434 * 435 * Return: channel state 436 */ 437 enum channel_state wlan_reg_get_2g_bonded_channel_state( 438 struct wlan_objmgr_pdev *pdev, uint8_t ch, 439 uint8_t sec_ch, enum phy_ch_width bw); 440 441 /** 442 * wlan_reg_set_channel_params () - Sets channel parameteres for given bandwidth 443 * @pdev: The physical dev to program country code or regdomain 444 * @ch: channel number. 445 * @sec_ch_2g: Secondary channel. 446 * @ch_params: pointer to the channel parameters. 447 * 448 * Return: None 449 */ 450 void wlan_reg_set_channel_params(struct wlan_objmgr_pdev *pdev, uint8_t ch, 451 uint8_t sec_ch_2g, 452 struct ch_params *ch_params); 453 #endif /* CONFIG_CHAN_NUM_API */ 454 /** 455 * wlan_reg_get_dfs_region () - Get the current dfs region 456 * @dfs_reg: pointer to dfs region 457 * 458 * Return: Status 459 */ 460 QDF_STATUS wlan_reg_get_dfs_region(struct wlan_objmgr_pdev *pdev, 461 enum dfs_reg *dfs_reg); 462 463 #ifdef CONFIG_CHAN_NUM_API 464 /** 465 * wlan_reg_get_channel_reg_power() - Provide the channel regulatory power 466 * @chan_num: channel number 467 * 468 * Return: int 469 */ 470 uint32_t wlan_reg_get_channel_reg_power(struct wlan_objmgr_pdev *pdev, 471 uint8_t chan_num); 472 473 /** 474 * wlan_reg_get_channel_freq() - provide the channel center freq 475 * @chan_num: channel number 476 * 477 * Return: int 478 */ 479 qdf_freq_t wlan_reg_get_channel_freq(struct wlan_objmgr_pdev *pdev, 480 uint8_t chan_num); 481 #endif /* CONFIG_CHAN_NUM_API */ 482 483 /** 484 * wlan_reg_get_current_chan_list() - provide the pdev current channel list 485 * @pdev: pdev pointer 486 * @chan_list: channel list pointer 487 * 488 * Return: QDF_STATUS 489 */ 490 QDF_STATUS wlan_reg_get_current_chan_list(struct wlan_objmgr_pdev *pdev, 491 struct regulatory_channel *chan_list); 492 493 #ifdef CONFIG_CHAN_NUM_API 494 /** 495 * wlan_reg_get_bonded_channel_state() - get bonded channel state 496 * @pdev: pdev ptr 497 * @ch: chennal number 498 * @bw: chennal number 499 * @sec_ch: secondary channel 500 * 501 * Return: enum channel_state 502 */ 503 enum channel_state wlan_reg_get_bonded_channel_state( 504 struct wlan_objmgr_pdev *pdev, uint8_t ch, 505 enum phy_ch_width bw, uint8_t sec_ch); 506 #endif /* CONFIG_CHAN_NUM_API */ 507 508 /** 509 * wlan_reg_set_dfs_region() - set the dfs region 510 * @pdev: pdev ptr 511 * @dfs_reg: dfs region 512 * 513 * Return: void 514 */ 515 void wlan_reg_set_dfs_region(struct wlan_objmgr_pdev *pdev, 516 enum dfs_reg dfs_reg); 517 518 /** 519 * wlan_reg_get_bw_value() - provide the channel center freq 520 * @chan_num: chennal number 521 * 522 * Return: int 523 */ 524 uint16_t wlan_reg_get_bw_value(enum phy_ch_width bw); 525 526 /** 527 * wlan_reg_get_domain_from_country_code() - provide the channel center freq 528 * @reg_domain_ptr: regulatory domain ptr 529 * @country_alpha2: country alpha2 530 * @source: alpha2 source 531 * 532 * Return: int 533 */ 534 QDF_STATUS wlan_reg_get_domain_from_country_code(v_REGDOMAIN_t *reg_domain_ptr, 535 const uint8_t *country_alpha2, 536 enum country_src source); 537 538 /** 539 * wlan_reg_dmn_get_opclass_from_channel() - provide the channel center freq 540 * @country: country alpha2 541 * @channel: channel number 542 * @offset: offset 543 * 544 * Return: int 545 */ 546 uint16_t wlan_reg_dmn_get_opclass_from_channel(uint8_t *country, 547 uint8_t channel, 548 uint8_t offset); 549 550 /** 551 * wlan_reg_get_opclass_from_freq_width() - Get operating class from frequency 552 * @country: Country code. 553 * @freq: Channel center frequency. 554 * @ch_width: Channel width. 555 * @behav_limit: Behaviour limit. 556 * 557 * Return: Error code. 558 */ 559 uint8_t wlan_reg_get_opclass_from_freq_width(uint8_t *country, 560 qdf_freq_t freq, 561 uint8_t ch_width, 562 uint16_t behav_limit); 563 564 /** 565 * wlan_reg_dmn_print_channels_in_opclass() - Print channels in op-class 566 * @country: country alpha2 567 * @opclass: oplcass 568 * 569 * Return: void 570 */ 571 void wlan_reg_dmn_print_channels_in_opclass(uint8_t *country, 572 uint8_t opclass); 573 574 575 /** 576 * wlan_reg_dmn_get_chanwidth_from_opclass() - get channel width from 577 * operating class 578 * @country: country alpha2 579 * @channel: channel number 580 * @opclass: operating class 581 * 582 * Return: int 583 */ 584 uint16_t wlan_reg_dmn_get_chanwidth_from_opclass(uint8_t *country, 585 uint8_t channel, 586 uint8_t opclass); 587 /** 588 * wlan_reg_dmn_set_curr_opclasses() - set operating class 589 * @num_classes: number of classes 590 * @class: operating class 591 * 592 * Return: int 593 */ 594 uint16_t wlan_reg_dmn_set_curr_opclasses(uint8_t num_classes, 595 uint8_t *class); 596 597 /** 598 * wlan_reg_dmn_get_curr_opclasses() - get current oper classes 599 * @num_classes: number of classes 600 * @class: operating class 601 * 602 * Return: int 603 */ 604 uint16_t wlan_reg_dmn_get_curr_opclasses(uint8_t *num_classes, 605 uint8_t *class); 606 607 608 /** 609 * wlan_reg_get_opclass_details() - Get details about the current opclass table. 610 * @pdev: Pointer to pdev. 611 * @reg_ap_cap: Pointer to reg_ap_cap. 612 * @n_opclasses: Pointer to number of opclasses. 613 * @max_supp_op_class: Maximum number of operating classes supported. 614 * @global_tbl_lookup: Whether to lookup global op class tbl. 615 * 616 * Return: QDF_STATUS_SUCCESS if success, else return QDF_STATUS_FAILURE. 617 */ 618 QDF_STATUS 619 wlan_reg_get_opclass_details(struct wlan_objmgr_pdev *pdev, 620 struct regdmn_ap_cap_opclass_t *reg_ap_cap, 621 uint8_t *n_opclasses, 622 uint8_t max_supp_op_class, 623 bool global_tbl_lookup); 624 625 /** 626 * wlan_regulatory_init() - init regulatory component 627 * 628 * Return: Success or Failure 629 */ 630 QDF_STATUS wlan_regulatory_init(void); 631 632 /** 633 * wlan_regulatory_deinit() - deinit regulatory component 634 * 635 * Return: Success or Failure 636 */ 637 QDF_STATUS wlan_regulatory_deinit(void); 638 639 /** 640 * regulatory_psoc_open() - open regulatory component 641 * 642 * Return: Success or Failure 643 */ 644 QDF_STATUS regulatory_psoc_open(struct wlan_objmgr_psoc *psoc); 645 646 647 /** 648 * regulatory_psoc_close() - close regulatory component 649 * 650 * Return: Success or Failure 651 */ 652 QDF_STATUS regulatory_psoc_close(struct wlan_objmgr_psoc *psoc); 653 654 /** 655 * regulatory_pdev_open() - Open regulatory component 656 * @pdev: Pointer to pdev structure 657 * 658 * Return: Success or Failure 659 */ 660 QDF_STATUS regulatory_pdev_open(struct wlan_objmgr_pdev *pdev); 661 662 /** 663 * regulatory_pdev_close() - Close regulatory component 664 * @pdev: Pointer to pdev structure. 665 * 666 * Return: Success or Failure 667 */ 668 QDF_STATUS regulatory_pdev_close(struct wlan_objmgr_pdev *pdev); 669 670 #ifdef CONFIG_CHAN_NUM_API 671 /** 672 * wlan_reg_update_nol_ch () - set nol channel 673 * @pdev: pdev ptr 674 * @ch_list: channel list to be returned 675 * @num_ch: number of channels 676 * @nol_ch: nol flag 677 * 678 * Return: void 679 */ 680 void wlan_reg_update_nol_ch(struct wlan_objmgr_pdev *pdev, 681 uint8_t *ch_list, 682 uint8_t num_ch, 683 bool nol_ch); 684 685 /** 686 * wlan_reg_is_dsrc_chan () - Checks if the channel is dsrc channel or not 687 * @pdev: pdev ptr 688 * @chan_num: channel 689 * 690 * Return: true or false 691 */ 692 bool wlan_reg_is_dsrc_chan(struct wlan_objmgr_pdev *pdev, uint8_t chan_num); 693 694 /** 695 * wlan_reg_is_passive_or_disable_ch () - Checks chan state for passive 696 * and disabled 697 * @pdev: pdev ptr 698 * @chan: channel 699 * 700 * Return: true or false 701 */ 702 bool wlan_reg_is_passive_or_disable_ch(struct wlan_objmgr_pdev *pdev, 703 uint8_t chan); 704 705 /** 706 * wlan_reg_is_disable_ch () - Checks chan state for disabled 707 * @pdev: pdev ptr 708 * @chan: channel 709 * 710 * Return: true or false 711 */ 712 bool wlan_reg_is_disable_ch(struct wlan_objmgr_pdev *pdev, uint8_t chan); 713 #endif /* CONFIG_CHAN_NUM_API */ 714 715 /** 716 * wlan_reg_freq_to_chan () - convert channel freq to channel number 717 * @pdev: The physical dev to set current country for 718 * @freq: frequency 719 * 720 * Return: true or false 721 */ 722 uint8_t wlan_reg_freq_to_chan(struct wlan_objmgr_pdev *pdev, 723 qdf_freq_t freq); 724 725 /** 726 * wlan_reg_chan_to_freq () - convert channel number to frequency 727 * @chan: channel number 728 * 729 * Return: true or false 730 */ 731 qdf_freq_t wlan_reg_chan_to_freq(struct wlan_objmgr_pdev *pdev, 732 uint8_t chan); 733 734 /** 735 * wlan_reg_legacy_chan_to_freq () - convert chan to freq, for 2G and 5G 736 * @chan: channel number 737 * 738 * Return: frequency 739 */ 740 qdf_freq_t wlan_reg_legacy_chan_to_freq(struct wlan_objmgr_pdev *pdev, 741 uint8_t chan); 742 743 /** 744 * wlan_reg_is_us() - reg is us country 745 * @country: The country information 746 * 747 * Return: true or false 748 */ 749 bool wlan_reg_is_us(uint8_t *country); 750 751 #ifdef CONFIG_CHAN_NUM_API 752 /** 753 * wlan_reg_chan_is_49ghz() - Check if the input channel number is 4.9GHz 754 * @pdev: Pdev pointer 755 * @chan_num: Input channel number 756 * 757 * Return: true if the channel is 4.9GHz else false. 758 */ 759 bool wlan_reg_chan_is_49ghz(struct wlan_objmgr_pdev *pdev, 760 uint8_t chan_num); 761 #endif /* CONFIG_CHAN_NUM_API */ 762 763 /** 764 * wlan_reg_set_country() - Set the current 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_country(struct wlan_objmgr_pdev *pdev, 771 uint8_t *country); 772 773 /** 774 * wlan_reg_set_11d_country() - Set the 11d regulatory country 775 * @pdev: The physical dev to set current country for 776 * @country: The country information to configure 777 * 778 * Return: QDF_STATUS 779 */ 780 QDF_STATUS wlan_reg_set_11d_country(struct wlan_objmgr_pdev *pdev, 781 uint8_t *country); 782 783 /** 784 * wlan_reg_register_chan_change_callback () - add chan change cbk 785 * @psoc: psoc ptr 786 * @cbk: callback 787 * @arg: argument 788 * 789 * Return: true or false 790 */ 791 void wlan_reg_register_chan_change_callback(struct wlan_objmgr_psoc *psoc, 792 void *cbk, void *arg); 793 794 /** 795 * wlan_reg_unregister_chan_change_callback () - remove chan change cbk 796 * @psoc: psoc ptr 797 * @cbk:callback 798 * 799 * Return: true or false 800 */ 801 void wlan_reg_unregister_chan_change_callback(struct wlan_objmgr_psoc *psoc, 802 void *cbk); 803 804 /** 805 * wlan_reg_is_11d_offloaded() - 11d offloaded supported 806 * @psoc: psoc ptr 807 * 808 * Return: bool 809 */ 810 bool wlan_reg_is_11d_offloaded(struct wlan_objmgr_psoc *psoc); 811 812 /** 813 * wlan_reg_11d_enabled_on_host() - 11d enabled don host 814 * @psoc: psoc ptr 815 * 816 * Return: bool 817 */ 818 bool wlan_reg_11d_enabled_on_host(struct wlan_objmgr_psoc *psoc); 819 820 /** 821 * wlan_reg_get_chip_mode() - get supported chip mode 822 * @pdev: pdev pointer 823 * @chip_mode: chip mode 824 * 825 * Return: QDF STATUS 826 */ 827 QDF_STATUS wlan_reg_get_chip_mode(struct wlan_objmgr_pdev *pdev, 828 uint32_t *chip_mode); 829 830 /** 831 * wlan_reg_is_11d_scan_inprogress() - checks 11d scan status 832 * @psoc: psoc ptr 833 * 834 * Return: bool 835 */ 836 bool wlan_reg_is_11d_scan_inprogress(struct wlan_objmgr_psoc *psoc); 837 /** 838 * wlan_reg_get_freq_range() - Get 2GHz and 5GHz frequency range 839 * @pdev: pdev pointer 840 * @low_2g: low 2GHz frequency range 841 * @high_2g: high 2GHz frequency range 842 * @low_5g: low 5GHz frequency range 843 * @high_5g: high 5GHz frequency range 844 * 845 * Return: QDF status 846 */ 847 QDF_STATUS wlan_reg_get_freq_range(struct wlan_objmgr_pdev *pdev, 848 qdf_freq_t *low_2g, 849 qdf_freq_t *high_2g, 850 qdf_freq_t *low_5g, 851 qdf_freq_t *high_5g); 852 /** 853 * wlan_reg_get_tx_ops () - get regulatory tx ops 854 * @psoc: psoc ptr 855 * 856 */ 857 struct wlan_lmac_if_reg_tx_ops * 858 wlan_reg_get_tx_ops(struct wlan_objmgr_psoc *psoc); 859 860 /** 861 * wlan_reg_get_curr_regdomain() - Get current regdomain in use 862 * @pdev: pdev pointer 863 * @cur_regdmn: Current regdomain info 864 * 865 * Return: QDF status 866 */ 867 QDF_STATUS wlan_reg_get_curr_regdomain(struct wlan_objmgr_pdev *pdev, 868 struct cur_regdmn_info *cur_regdmn); 869 870 #ifdef CONFIG_CHAN_NUM_API 871 /** 872 * wlan_reg_update_nol_history_ch() - Set nol-history flag for the channels in 873 * the list. 874 * 875 * @pdev: Pdev ptr 876 * @ch_list: Input channel list. 877 * @num_ch: Number of channels. 878 * @nol_history_ch: Nol history value. 879 * 880 * Return: void 881 */ 882 void wlan_reg_update_nol_history_ch(struct wlan_objmgr_pdev *pdev, 883 uint8_t *ch_list, 884 uint8_t num_ch, 885 bool nol_history_ch); 886 #endif /* CONFIG_CHAN_NUM_API */ 887 /** 888 * wlan_reg_is_regdmn_en302502_applicable() - Find if ETSI EN302_502 radar 889 * pattern is applicable in the current regulatory domain. 890 * @pdev: Pdev ptr. 891 * 892 * Return: Boolean. 893 * True: If EN302_502 is applicable. 894 * False: otherwise. 895 */ 896 bool wlan_reg_is_regdmn_en302502_applicable(struct wlan_objmgr_pdev *pdev); 897 898 /** 899 * wlan_reg_modify_pdev_chan_range() - Compute current channel list for the 900 * modified channel range in the regcap. 901 * @pdev: pointer to wlan_objmgr_pdev. 902 * 903 * Return : QDF_STATUS 904 */ 905 QDF_STATUS wlan_reg_modify_pdev_chan_range(struct wlan_objmgr_pdev *pdev); 906 907 /** 908 * wlan_reg_disable_chan_coex() - Disable Coexisting channels based on the input 909 * bitmask 910 * @pdev: pointer to wlan_objmgr_pdev. 911 * unii_5g_bitmap: UNII 5G bitmap. 912 * 913 * Return : QDF_STATUS 914 */ 915 #ifdef DISABLE_UNII_SHARED_BANDS 916 QDF_STATUS wlan_reg_disable_chan_coex(struct wlan_objmgr_pdev *pdev, 917 uint8_t unii_5g_bitmap); 918 #else 919 static inline QDF_STATUS 920 wlan_reg_disable_chan_coex(struct wlan_objmgr_pdev *pdev, 921 uint8_t unii_5g_bitmap) 922 { 923 return QDF_STATUS_SUCCESS; 924 } 925 #endif 926 927 #ifdef CONFIG_CHAN_FREQ_API 928 /** 929 * wlan_reg_is_same_band_freqs() - Check if two channel frequencies 930 * have same band 931 * @freq1: Frequency 1 932 * @freq2: Frequency 2 933 * 934 * Return: true if both the channel frequency has the same band. 935 */ 936 #define WLAN_REG_IS_SAME_BAND_FREQS(freq1, freq2) \ 937 wlan_reg_is_same_band_freqs(freq1, freq2) 938 bool wlan_reg_is_same_band_freqs(qdf_freq_t freq1, qdf_freq_t freq2); 939 940 /** 941 * wlan_reg_get_chan_enum_for_freq() - Get channel enum for given channel center 942 * frequency 943 * @freq: Channel center frequency 944 * 945 * Return: Channel enum 946 */ 947 enum channel_enum wlan_reg_get_chan_enum_for_freq(qdf_freq_t freq); 948 949 /** 950 * wlan_reg_update_nol_history_ch_for_freq() - Set nol-history flag for the 951 * channels in the list. 952 * 953 * @pdev: Pdev ptr 954 * @ch_list: Input channel list. 955 * @num_ch: Number of channels. 956 * @nol_history_ch: Nol history value. 957 * 958 * Return: void 959 */ 960 void wlan_reg_update_nol_history_ch_for_freq(struct wlan_objmgr_pdev *pdev, 961 uint16_t *ch_list, 962 uint8_t num_ch, 963 bool nol_history_ch); 964 /** 965 * wlan_reg_is_frequency_valid_5g_sbs() Check if the given frequency is 5G SBS. 966 * @curfreq: current channel center frequency 967 * @newfreq:new channel center frequency 968 * 969 * Return: true if the given frequency is a valid 5G SBS 970 */ 971 #define WLAN_REG_IS_FREQUENCY_VALID_5G_SBS(curfreq, newfreq) \ 972 wlan_reg_is_frequency_valid_5g_sbs(curfreq, newfreq) 973 bool wlan_reg_is_frequency_valid_5g_sbs(qdf_freq_t curfreq, qdf_freq_t newfreq); 974 975 /** 976 * wlan_reg_chan_has_dfs_attribute_for_freq() - check channel has dfs 977 * attribute flag 978 * @freq: channel center frequency. 979 * 980 * This API get chan initial dfs attribute from regdomain 981 * 982 * Return: true if chan is dfs, otherwise false 983 */ 984 bool 985 wlan_reg_chan_has_dfs_attribute_for_freq(struct wlan_objmgr_pdev *pdev, 986 qdf_freq_t freq); 987 988 /** 989 * wlan_reg_get_channel_list_with_power_for_freq() - Provide the channel list 990 * with power 991 * @ch_list: pointer to the channel list. 992 * 993 * Return: QDF_STATUS 994 */ 995 QDF_STATUS 996 wlan_reg_get_channel_list_with_power_for_freq(struct wlan_objmgr_pdev *pdev, 997 struct channel_power *ch_list, 998 uint8_t *num_chan); 999 1000 /** 1001 * wlan_reg_get_5g_bonded_channel_state_for_freq() - Get 5G bonded channel state 1002 * @pdev: The physical dev to program country code or regdomain 1003 * @freq: channel frequency. 1004 * @bw: channel band width 1005 * 1006 * Return: channel state 1007 */ 1008 enum channel_state 1009 wlan_reg_get_5g_bonded_channel_state_for_freq(struct wlan_objmgr_pdev *pdev, 1010 qdf_freq_t freq, 1011 enum phy_ch_width bw); 1012 /** 1013 * wlan_reg_get_2g_bonded_channel_state_for_freq() - Get 2G bonded channel state 1014 * @pdev: The physical dev to program country code or regdomain 1015 * @freq: channel center frequency. 1016 * @sec_ch_freq: Secondary channel center frequency. 1017 * @bw: channel band width 1018 * 1019 * Return: channel state 1020 */ 1021 enum channel_state 1022 wlan_reg_get_2g_bonded_channel_state_for_freq(struct wlan_objmgr_pdev *pdev, 1023 qdf_freq_t freq, 1024 qdf_freq_t sec_ch_freq, 1025 enum phy_ch_width bw); 1026 1027 /** 1028 * wlan_reg_get_channel_state_for_freq() - Get channel state from regulatory 1029 * @pdev: Pointer to pdev 1030 * @freq: channel center frequency. 1031 * 1032 * Return: channel state 1033 */ 1034 enum channel_state 1035 wlan_reg_get_channel_state_for_freq(struct wlan_objmgr_pdev *pdev, 1036 qdf_freq_t freq); 1037 1038 /** 1039 * wlan_reg_set_channel_params_for_freq() - Sets channel parameteres for 1040 * given bandwidth 1041 * @pdev: The physical dev to program country code or regdomain 1042 * @freq: channel center frequency. 1043 * @sec_ch_2g_freq: Secondary channel center frequency. 1044 * @ch_params: pointer to the channel parameters. 1045 * 1046 * Return: None 1047 */ 1048 void wlan_reg_set_channel_params_for_freq(struct wlan_objmgr_pdev *pdev, 1049 qdf_freq_t freq, 1050 qdf_freq_t sec_ch_2g_freq, 1051 struct ch_params *ch_params); 1052 1053 /** 1054 * wlan_reg_get_channel_cfreq_reg_power_for_freq() - Provide the channel 1055 * regulatory power 1056 * @freq: channel center frequency 1057 * 1058 * Return: int 1059 */ 1060 uint8_t wlan_reg_get_channel_reg_power_for_freq(struct wlan_objmgr_pdev *pdev, 1061 qdf_freq_t freq); 1062 1063 /** 1064 * wlan_reg_update_nol_ch_for_freq () - set nol channel 1065 * @pdev: pdev ptr 1066 * @chan_freq_list: channel list to be returned 1067 * @num_ch: number of channels 1068 * @nol_ch: nol flag 1069 * 1070 * Return: void 1071 */ 1072 void wlan_reg_update_nol_ch_for_freq(struct wlan_objmgr_pdev *pdev, 1073 uint16_t *chan_freq_list, 1074 uint8_t num_ch, 1075 bool nol_ch); 1076 1077 /** 1078 * wlan_reg_is_dfs_freq() - Checks the channel state for DFS 1079 * @freq: Channel center frequency 1080 * 1081 * Return: true or false 1082 */ 1083 bool wlan_reg_is_dfs_for_freq(struct wlan_objmgr_pdev *pdev, qdf_freq_t freq); 1084 1085 /** 1086 * wlan_reg_is_dsrc_freq() - Checks if the channel is dsrc channel or not 1087 * @freq: Channel center frequency 1088 * 1089 * Return: true or false 1090 */ 1091 bool wlan_reg_is_dsrc_freq(qdf_freq_t freq); 1092 1093 /** 1094 * wlan_reg_is_passive_or_disable_for_freq() - Checks chan state for passive 1095 * and disabled 1096 * @pdev: pdev ptr 1097 * @freq: Channel center frequency 1098 * 1099 * Return: true or false 1100 */ 1101 bool wlan_reg_is_passive_or_disable_for_freq(struct wlan_objmgr_pdev *pdev, 1102 qdf_freq_t freq); 1103 1104 /** 1105 * wlan_reg_is_disable_for_freq() - Checks chan state for disabled 1106 * @pdev: pdev ptr 1107 * @freq: Channel center frequency 1108 * 1109 * Return: true or false 1110 */ 1111 bool wlan_reg_is_disable_for_freq(struct wlan_objmgr_pdev *pdev, 1112 qdf_freq_t freq); 1113 1114 /** 1115 * wlan_reg_chan_to_band() - Get band from channel number 1116 * @chan_num: channel number 1117 * 1118 * Return: wifi band 1119 */ 1120 enum reg_wifi_band wlan_reg_freq_to_band(qdf_freq_t freq); 1121 1122 /** 1123 * wlan_reg_min_chan_freq() - Minimum channel frequency supported 1124 * 1125 * Return: frequency 1126 */ 1127 qdf_freq_t wlan_reg_min_chan_freq(void); 1128 1129 /** 1130 * wlan_reg_max_chan_freq() - Return max. frequency 1131 * 1132 * Return: frequency 1133 */ 1134 qdf_freq_t wlan_reg_max_chan_freq(void); 1135 1136 /** 1137 * wlan_reg_freq_width_to_chan_op_class() -Get op class from freq 1138 * @pdev: pdev ptr 1139 * @freq: channel frequency 1140 * @chan_width: channel width 1141 * @global_tbl_lookup: whether to look up global table 1142 * @behav_limit: behavior limit 1143 * @op_class: operating class 1144 * @chan_num: channel number 1145 * 1146 * Return: void 1147 */ 1148 void wlan_reg_freq_width_to_chan_op_class(struct wlan_objmgr_pdev *pdev, 1149 qdf_freq_t freq, 1150 uint16_t chan_width, 1151 bool global_tbl_lookup, 1152 uint16_t behav_limit, 1153 uint8_t *op_class, 1154 uint8_t *chan_num); 1155 1156 /** 1157 * wlan_reg_freq_to_chan_and_op_class() - Converts freq to oper class 1158 * @pdev: pdev ptr 1159 * @freq: channel frequency 1160 * @global_tbl_lookup: whether to look up global table 1161 * @behav_limit: behavior limit 1162 * @op_class: operating class 1163 * @chan_num: channel number 1164 * 1165 * Return: void 1166 */ 1167 void wlan_reg_freq_to_chan_op_class(struct wlan_objmgr_pdev *pdev, 1168 qdf_freq_t freq, 1169 bool global_tbl_lookup, 1170 uint16_t behav_limit, 1171 uint8_t *op_class, 1172 uint8_t *chan_num); 1173 1174 /** 1175 * wlan_reg_get_5g_bonded_channel_and_state_for_freq()- Return the channel 1176 * state for a 5G or 6G channel frequency based on the channel width and 1177 * bonded channel. 1178 * @pdev: Pointer to pdev. 1179 * @freq: Channel center frequency. 1180 * @bw Channel Width. 1181 * @bonded_chan_ptr_ptr: Pointer to bonded_channel_freq. 1182 * 1183 * Return: Channel State 1184 */ 1185 enum channel_state 1186 wlan_reg_get_5g_bonded_channel_and_state_for_freq(struct wlan_objmgr_pdev *pdev, 1187 uint16_t freq, 1188 enum phy_ch_width bw, 1189 const 1190 struct bonded_channel_freq 1191 **bonded_chan_ptr_ptr); 1192 #endif /*CONFIG_CHAN_FREQ_API */ 1193 1194 /** 1195 * wlan_reg_get_op_class_width() - Get operating class chan width 1196 * @pdev: pdev ptr 1197 * @freq: channel frequency 1198 * @global_tbl_lookup: whether to look up global table 1199 * @op_class: operating class 1200 * @chan_num: channel number 1201 * 1202 * Return: channel width of op class 1203 */ 1204 uint16_t wlan_reg_get_op_class_width(struct wlan_objmgr_pdev *pdev, 1205 uint8_t op_class, 1206 bool global_tbl_lookup); 1207 1208 /** 1209 * wlan_reg_is_6ghz_op_class() - Whether 6ghz oper class 1210 * @pdev: pdev ptr 1211 * @op_class: operating class 1212 * 1213 * Return: bool 1214 */ 1215 bool wlan_reg_is_6ghz_op_class(struct wlan_objmgr_pdev *pdev, 1216 uint8_t op_class); 1217 1218 /** 1219 * wlan_reg_is_6ghz_supported() - Whether 6ghz is supported 1220 * @pdev: pdev ptr 1221 * 1222 * Return: bool 1223 */ 1224 bool wlan_reg_is_6ghz_supported(struct wlan_objmgr_pdev *pdev); 1225 1226 /** 1227 * reg_chan_opclass_to_freq() - Convert channel number and opclass to frequency 1228 * @chan: IEEE Channel Number. 1229 * @op_class: Opclass. 1230 * @global_tbl_lookup: Global table lookup. 1231 * 1232 * Return: Channel center frequency else return 0. 1233 */ 1234 uint16_t wlan_reg_chan_opclass_to_freq(uint8_t chan, 1235 uint8_t op_class, 1236 bool global_tbl_lookup); 1237 #endif 1238