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 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_dfs_ch () - Checks the channel state for DFS 687 * @pdev: pdev ptr 688 * @chan: channel 689 * 690 * Return: true or false 691 */ 692 bool wlan_reg_is_dfs_ch(struct wlan_objmgr_pdev *pdev, uint8_t chan); 693 694 /** 695 * wlan_reg_is_dsrc_chan () - Checks if the channel is dsrc channel or not 696 * @pdev: pdev ptr 697 * @chan_num: channel 698 * 699 * Return: true or false 700 */ 701 bool wlan_reg_is_dsrc_chan(struct wlan_objmgr_pdev *pdev, uint8_t chan_num); 702 703 /** 704 * wlan_reg_is_passive_or_disable_ch () - Checks chan state for passive 705 * and disabled 706 * @pdev: pdev ptr 707 * @chan: channel 708 * 709 * Return: true or false 710 */ 711 bool wlan_reg_is_passive_or_disable_ch(struct wlan_objmgr_pdev *pdev, 712 uint8_t chan); 713 714 /** 715 * wlan_reg_is_disable_ch () - Checks chan state for disabled 716 * @pdev: pdev ptr 717 * @chan: channel 718 * 719 * Return: true or false 720 */ 721 bool wlan_reg_is_disable_ch(struct wlan_objmgr_pdev *pdev, uint8_t chan); 722 #endif /* CONFIG_CHAN_NUM_API */ 723 724 /** 725 * wlan_reg_freq_to_chan () - convert channel freq to channel number 726 * @pdev: The physical dev to set current country for 727 * @freq: frequency 728 * 729 * Return: true or false 730 */ 731 uint8_t wlan_reg_freq_to_chan(struct wlan_objmgr_pdev *pdev, 732 qdf_freq_t freq); 733 734 /** 735 * wlan_reg_chan_to_freq () - convert channel number to frequency 736 * @chan: channel number 737 * 738 * Return: true or false 739 */ 740 qdf_freq_t wlan_reg_chan_to_freq(struct wlan_objmgr_pdev *pdev, 741 uint8_t chan); 742 743 /** 744 * wlan_reg_legacy_chan_to_freq () - convert chan to freq, for 2G and 5G 745 * @chan: channel number 746 * 747 * Return: frequency 748 */ 749 qdf_freq_t wlan_reg_legacy_chan_to_freq(struct wlan_objmgr_pdev *pdev, 750 uint8_t chan); 751 752 /** 753 * wlan_reg_is_us() - reg is us country 754 * @country: The country information 755 * 756 * Return: true or false 757 */ 758 bool wlan_reg_is_us(uint8_t *country); 759 760 #ifdef CONFIG_CHAN_NUM_API 761 /** 762 * wlan_reg_chan_is_49ghz() - Check if the input channel number is 4.9GHz 763 * @pdev: Pdev pointer 764 * @chan_num: Input channel number 765 * 766 * Return: true if the channel is 4.9GHz else false. 767 */ 768 bool wlan_reg_chan_is_49ghz(struct wlan_objmgr_pdev *pdev, 769 uint8_t chan_num); 770 #endif /* CONFIG_CHAN_NUM_API */ 771 772 /** 773 * wlan_reg_set_country() - Set the current regulatory country 774 * @pdev: The physical dev to set current country for 775 * @country: The country information to configure 776 * 777 * Return: QDF_STATUS 778 */ 779 QDF_STATUS wlan_reg_set_country(struct wlan_objmgr_pdev *pdev, 780 uint8_t *country); 781 782 /** 783 * wlan_reg_set_11d_country() - Set the 11d regulatory country 784 * @pdev: The physical dev to set current country for 785 * @country: The country information to configure 786 * 787 * Return: QDF_STATUS 788 */ 789 QDF_STATUS wlan_reg_set_11d_country(struct wlan_objmgr_pdev *pdev, 790 uint8_t *country); 791 792 /** 793 * wlan_reg_register_chan_change_callback () - add chan change cbk 794 * @psoc: psoc ptr 795 * @cbk: callback 796 * @arg: argument 797 * 798 * Return: true or false 799 */ 800 void wlan_reg_register_chan_change_callback(struct wlan_objmgr_psoc *psoc, 801 void *cbk, void *arg); 802 803 /** 804 * wlan_reg_unregister_chan_change_callback () - remove chan change cbk 805 * @psoc: psoc ptr 806 * @cbk:callback 807 * 808 * Return: true or false 809 */ 810 void wlan_reg_unregister_chan_change_callback(struct wlan_objmgr_psoc *psoc, 811 void *cbk); 812 813 /** 814 * wlan_reg_is_11d_offloaded() - 11d offloaded supported 815 * @psoc: psoc ptr 816 * 817 * Return: bool 818 */ 819 bool wlan_reg_is_11d_offloaded(struct wlan_objmgr_psoc *psoc); 820 821 /** 822 * wlan_reg_11d_enabled_on_host() - 11d enabled don host 823 * @psoc: psoc ptr 824 * 825 * Return: bool 826 */ 827 bool wlan_reg_11d_enabled_on_host(struct wlan_objmgr_psoc *psoc); 828 829 /** 830 * wlan_reg_get_chip_mode() - get supported chip mode 831 * @pdev: pdev pointer 832 * @chip_mode: chip mode 833 * 834 * Return: QDF STATUS 835 */ 836 QDF_STATUS wlan_reg_get_chip_mode(struct wlan_objmgr_pdev *pdev, 837 uint32_t *chip_mode); 838 839 /** 840 * wlan_reg_is_11d_scan_inprogress() - checks 11d scan status 841 * @psoc: psoc ptr 842 * 843 * Return: bool 844 */ 845 bool wlan_reg_is_11d_scan_inprogress(struct wlan_objmgr_psoc *psoc); 846 /** 847 * wlan_reg_get_freq_range() - Get 2GHz and 5GHz frequency range 848 * @pdev: pdev pointer 849 * @low_2g: low 2GHz frequency range 850 * @high_2g: high 2GHz frequency range 851 * @low_5g: low 5GHz frequency range 852 * @high_5g: high 5GHz frequency range 853 * 854 * Return: QDF status 855 */ 856 QDF_STATUS wlan_reg_get_freq_range(struct wlan_objmgr_pdev *pdev, 857 qdf_freq_t *low_2g, 858 qdf_freq_t *high_2g, 859 qdf_freq_t *low_5g, 860 qdf_freq_t *high_5g); 861 /** 862 * wlan_reg_get_tx_ops () - get regulatory tx ops 863 * @psoc: psoc ptr 864 * 865 */ 866 struct wlan_lmac_if_reg_tx_ops * 867 wlan_reg_get_tx_ops(struct wlan_objmgr_psoc *psoc); 868 869 /** 870 * wlan_reg_get_curr_regdomain() - Get current regdomain in use 871 * @pdev: pdev pointer 872 * @cur_regdmn: Current regdomain info 873 * 874 * Return: QDF status 875 */ 876 QDF_STATUS wlan_reg_get_curr_regdomain(struct wlan_objmgr_pdev *pdev, 877 struct cur_regdmn_info *cur_regdmn); 878 879 #ifdef CONFIG_CHAN_NUM_API 880 /** 881 * wlan_reg_update_nol_history_ch() - Set nol-history flag for the channels in 882 * the list. 883 * 884 * @pdev: Pdev ptr 885 * @ch_list: Input channel list. 886 * @num_ch: Number of channels. 887 * @nol_history_ch: Nol history value. 888 * 889 * Return: void 890 */ 891 void wlan_reg_update_nol_history_ch(struct wlan_objmgr_pdev *pdev, 892 uint8_t *ch_list, 893 uint8_t num_ch, 894 bool nol_history_ch); 895 #endif /* CONFIG_CHAN_NUM_API */ 896 /** 897 * wlan_reg_is_regdmn_en302502_applicable() - Find if ETSI EN302_502 radar 898 * pattern is applicable in the current regulatory domain. 899 * @pdev: Pdev ptr. 900 * 901 * Return: Boolean. 902 * True: If EN302_502 is applicable. 903 * False: otherwise. 904 */ 905 bool wlan_reg_is_regdmn_en302502_applicable(struct wlan_objmgr_pdev *pdev); 906 907 /** 908 * wlan_reg_modify_pdev_chan_range() - Compute current channel list for the 909 * modified channel range in the regcap. 910 * @pdev: pointer to wlan_objmgr_pdev. 911 * 912 * Return : QDF_STATUS 913 */ 914 QDF_STATUS wlan_reg_modify_pdev_chan_range(struct wlan_objmgr_pdev *pdev); 915 916 /** 917 * wlan_reg_disable_chan_coex() - Disable Coexisting channels based on the input 918 * bitmask 919 * @pdev: pointer to wlan_objmgr_pdev. 920 * unii_5g_bitmap: UNII 5G bitmap. 921 * 922 * Return : QDF_STATUS 923 */ 924 #ifdef DISABLE_UNII_SHARED_BANDS 925 QDF_STATUS wlan_reg_disable_chan_coex(struct wlan_objmgr_pdev *pdev, 926 uint8_t unii_5g_bitmap); 927 #else 928 static inline QDF_STATUS 929 wlan_reg_disable_chan_coex(struct wlan_objmgr_pdev *pdev, 930 uint8_t unii_5g_bitmap) 931 { 932 return QDF_STATUS_SUCCESS; 933 } 934 #endif 935 936 #ifdef CONFIG_CHAN_FREQ_API 937 /** 938 * wlan_reg_is_same_band_freqs() - Check if two channel frequencies 939 * have same band 940 * @freq1: Frequency 1 941 * @freq2: Frequency 2 942 * 943 * Return: true if both the channel frequency has the same band. 944 */ 945 #define WLAN_REG_IS_SAME_BAND_FREQS(freq1, freq2) \ 946 wlan_reg_is_same_band_freqs(freq1, freq2) 947 bool wlan_reg_is_same_band_freqs(qdf_freq_t freq1, qdf_freq_t freq2); 948 949 /** 950 * wlan_reg_get_chan_enum_for_freq() - Get channel enum for given channel center 951 * frequency 952 * @freq: Channel center frequency 953 * 954 * Return: Channel enum 955 */ 956 enum channel_enum wlan_reg_get_chan_enum_for_freq(qdf_freq_t freq); 957 958 /** 959 * wlan_reg_update_nol_history_ch_for_freq() - Set nol-history flag for the 960 * channels in the list. 961 * 962 * @pdev: Pdev ptr 963 * @ch_list: Input channel list. 964 * @num_ch: Number of channels. 965 * @nol_history_ch: Nol history value. 966 * 967 * Return: void 968 */ 969 void wlan_reg_update_nol_history_ch_for_freq(struct wlan_objmgr_pdev *pdev, 970 uint16_t *ch_list, 971 uint8_t num_ch, 972 bool nol_history_ch); 973 /** 974 * wlan_reg_is_frequency_valid_5g_sbs() Check if the given frequency is 5G SBS. 975 * @curfreq: current channel center frequency 976 * @newfreq:new channel center frequency 977 * 978 * Return: true if the given frequency is a valid 5G SBS 979 */ 980 #define WLAN_REG_IS_FREQUENCY_VALID_5G_SBS(curfreq, newfreq) \ 981 wlan_reg_is_frequency_valid_5g_sbs(curfreq, newfreq) 982 bool wlan_reg_is_frequency_valid_5g_sbs(qdf_freq_t curfreq, qdf_freq_t newfreq); 983 984 /** 985 * wlan_reg_chan_has_dfs_attribute_for_freq() - check channel has dfs 986 * attribute flag 987 * @freq: channel center frequency. 988 * 989 * This API get chan initial dfs attribute from regdomain 990 * 991 * Return: true if chan is dfs, otherwise false 992 */ 993 bool 994 wlan_reg_chan_has_dfs_attribute_for_freq(struct wlan_objmgr_pdev *pdev, 995 qdf_freq_t freq); 996 997 /** 998 * wlan_reg_get_channel_list_with_power_for_freq() - Provide the channel list 999 * with power 1000 * @ch_list: pointer to the channel list. 1001 * 1002 * Return: QDF_STATUS 1003 */ 1004 QDF_STATUS 1005 wlan_reg_get_channel_list_with_power_for_freq(struct wlan_objmgr_pdev *pdev, 1006 struct channel_power *ch_list, 1007 uint8_t *num_chan); 1008 1009 /** 1010 * wlan_reg_get_5g_bonded_channel_state_for_freq() - Get 5G bonded channel state 1011 * @pdev: The physical dev to program country code or regdomain 1012 * @freq: channel frequency. 1013 * @bw: channel band width 1014 * 1015 * Return: channel state 1016 */ 1017 enum channel_state 1018 wlan_reg_get_5g_bonded_channel_state_for_freq(struct wlan_objmgr_pdev *pdev, 1019 qdf_freq_t freq, 1020 enum phy_ch_width bw); 1021 /** 1022 * wlan_reg_get_2g_bonded_channel_state_for_freq() - Get 2G bonded channel state 1023 * @pdev: The physical dev to program country code or regdomain 1024 * @freq: channel center frequency. 1025 * @sec_ch_freq: Secondary channel center frequency. 1026 * @bw: channel band width 1027 * 1028 * Return: channel state 1029 */ 1030 enum channel_state 1031 wlan_reg_get_2g_bonded_channel_state_for_freq(struct wlan_objmgr_pdev *pdev, 1032 qdf_freq_t freq, 1033 qdf_freq_t sec_ch_freq, 1034 enum phy_ch_width bw); 1035 1036 /** 1037 * wlan_reg_get_channel_state_for_freq() - Get channel state from regulatory 1038 * @pdev: Pointer to pdev 1039 * @freq: channel center frequency. 1040 * 1041 * Return: channel state 1042 */ 1043 enum channel_state 1044 wlan_reg_get_channel_state_for_freq(struct wlan_objmgr_pdev *pdev, 1045 qdf_freq_t freq); 1046 1047 /** 1048 * wlan_reg_set_channel_params_for_freq() - Sets channel parameteres for 1049 * given bandwidth 1050 * @pdev: The physical dev to program country code or regdomain 1051 * @freq: channel center frequency. 1052 * @sec_ch_2g_freq: Secondary channel center frequency. 1053 * @ch_params: pointer to the channel parameters. 1054 * 1055 * Return: None 1056 */ 1057 void wlan_reg_set_channel_params_for_freq(struct wlan_objmgr_pdev *pdev, 1058 qdf_freq_t freq, 1059 qdf_freq_t sec_ch_2g_freq, 1060 struct ch_params *ch_params); 1061 1062 /** 1063 * wlan_reg_get_channel_cfreq_reg_power_for_freq() - Provide the channel 1064 * regulatory power 1065 * @freq: channel center frequency 1066 * 1067 * Return: int 1068 */ 1069 uint8_t wlan_reg_get_channel_reg_power_for_freq(struct wlan_objmgr_pdev *pdev, 1070 qdf_freq_t freq); 1071 1072 /** 1073 * wlan_reg_update_nol_ch_for_freq () - set nol channel 1074 * @pdev: pdev ptr 1075 * @chan_freq_list: channel list to be returned 1076 * @num_ch: number of channels 1077 * @nol_ch: nol flag 1078 * 1079 * Return: void 1080 */ 1081 void wlan_reg_update_nol_ch_for_freq(struct wlan_objmgr_pdev *pdev, 1082 uint16_t *chan_freq_list, 1083 uint8_t num_ch, 1084 bool nol_ch); 1085 1086 /** 1087 * wlan_reg_is_dfs_freq() - Checks the channel state for DFS 1088 * @freq: Channel center frequency 1089 * 1090 * Return: true or false 1091 */ 1092 bool wlan_reg_is_dfs_for_freq(struct wlan_objmgr_pdev *pdev, qdf_freq_t freq); 1093 1094 /** 1095 * wlan_reg_is_dsrc_freq() - Checks if the channel is dsrc channel or not 1096 * @freq: Channel center frequency 1097 * 1098 * Return: true or false 1099 */ 1100 bool wlan_reg_is_dsrc_freq(qdf_freq_t freq); 1101 1102 /** 1103 * wlan_reg_is_passive_or_disable_for_freq() - Checks chan state for passive 1104 * and disabled 1105 * @pdev: pdev ptr 1106 * @freq: Channel center frequency 1107 * 1108 * Return: true or false 1109 */ 1110 bool wlan_reg_is_passive_or_disable_for_freq(struct wlan_objmgr_pdev *pdev, 1111 qdf_freq_t freq); 1112 1113 /** 1114 * wlan_reg_is_disable_for_freq() - Checks chan state for disabled 1115 * @pdev: pdev ptr 1116 * @freq: Channel center frequency 1117 * 1118 * Return: true or false 1119 */ 1120 bool wlan_reg_is_disable_for_freq(struct wlan_objmgr_pdev *pdev, 1121 qdf_freq_t freq); 1122 1123 /** 1124 * wlan_reg_chan_to_band() - Get band from channel number 1125 * @chan_num: channel number 1126 * 1127 * Return: wifi band 1128 */ 1129 enum reg_wifi_band wlan_reg_freq_to_band(qdf_freq_t freq); 1130 1131 /** 1132 * wlan_reg_min_chan_freq() - Minimum channel frequency supported 1133 * 1134 * Return: frequency 1135 */ 1136 qdf_freq_t wlan_reg_min_chan_freq(void); 1137 1138 /** 1139 * wlan_reg_max_chan_freq() - Return max. frequency 1140 * 1141 * Return: frequency 1142 */ 1143 qdf_freq_t wlan_reg_max_chan_freq(void); 1144 1145 /** 1146 * wlan_reg_freq_width_to_chan_op_class() -Get op class from freq 1147 * @pdev: pdev ptr 1148 * @freq: channel frequency 1149 * @chan_width: channel width 1150 * @global_tbl_lookup: whether to look up global table 1151 * @behav_limit: behavior limit 1152 * @op_class: operating class 1153 * @chan_num: channel number 1154 * 1155 * Return: void 1156 */ 1157 void wlan_reg_freq_width_to_chan_op_class(struct wlan_objmgr_pdev *pdev, 1158 qdf_freq_t freq, 1159 uint16_t chan_width, 1160 bool global_tbl_lookup, 1161 uint16_t behav_limit, 1162 uint8_t *op_class, 1163 uint8_t *chan_num); 1164 1165 /** 1166 * wlan_reg_freq_to_chan_and_op_class() - Converts freq to oper class 1167 * @pdev: pdev ptr 1168 * @freq: channel frequency 1169 * @global_tbl_lookup: whether to look up global table 1170 * @behav_limit: behavior limit 1171 * @op_class: operating class 1172 * @chan_num: channel number 1173 * 1174 * Return: void 1175 */ 1176 void wlan_reg_freq_to_chan_op_class(struct wlan_objmgr_pdev *pdev, 1177 qdf_freq_t freq, 1178 bool global_tbl_lookup, 1179 uint16_t behav_limit, 1180 uint8_t *op_class, 1181 uint8_t *chan_num); 1182 1183 /** 1184 * wlan_reg_get_5g_bonded_channel_and_state_for_freq()- Return the channel 1185 * state for a 5G or 6G channel frequency based on the channel width and 1186 * bonded channel. 1187 * @pdev: Pointer to pdev. 1188 * @freq: Channel center frequency. 1189 * @bw Channel Width. 1190 * @bonded_chan_ptr_ptr: Pointer to bonded_channel_freq. 1191 * 1192 * Return: Channel State 1193 */ 1194 enum channel_state 1195 wlan_reg_get_5g_bonded_channel_and_state_for_freq(struct wlan_objmgr_pdev *pdev, 1196 uint16_t freq, 1197 enum phy_ch_width bw, 1198 const 1199 struct bonded_channel_freq 1200 **bonded_chan_ptr_ptr); 1201 #endif /*CONFIG_CHAN_FREQ_API */ 1202 1203 /** 1204 * wlan_reg_get_op_class_width() - Get operating class chan width 1205 * @pdev: pdev ptr 1206 * @freq: channel frequency 1207 * @global_tbl_lookup: whether to look up global table 1208 * @op_class: operating class 1209 * @chan_num: channel number 1210 * 1211 * Return: channel width of op class 1212 */ 1213 uint16_t wlan_reg_get_op_class_width(struct wlan_objmgr_pdev *pdev, 1214 uint8_t op_class, 1215 bool global_tbl_lookup); 1216 1217 /** 1218 * wlan_reg_is_6ghz_op_class() - Whether 6ghz oper class 1219 * @pdev: pdev ptr 1220 * @op_class: operating class 1221 * 1222 * Return: bool 1223 */ 1224 bool wlan_reg_is_6ghz_op_class(struct wlan_objmgr_pdev *pdev, 1225 uint8_t op_class); 1226 1227 /** 1228 * wlan_reg_is_6ghz_supported() - Whether 6ghz is supported 1229 * @pdev: pdev ptr 1230 * 1231 * Return: bool 1232 */ 1233 bool wlan_reg_is_6ghz_supported(struct wlan_objmgr_pdev *pdev); 1234 1235 /** 1236 * reg_chan_opclass_to_freq() - Convert channel number and opclass to frequency 1237 * @chan: IEEE Channel Number. 1238 * @op_class: Opclass. 1239 * @global_tbl_lookup: Global table lookup. 1240 * 1241 * Return: Channel center frequency else return 0. 1242 */ 1243 uint16_t wlan_reg_chan_opclass_to_freq(uint8_t chan, 1244 uint8_t op_class, 1245 bool global_tbl_lookup); 1246 #endif 1247