1 /* 2 * Copyright (c) 2017-2018 The Linux Foundation. All rights reserved. 3 * 4 * Permission to use, copy, modify, and/or distribute this software for 5 * any purpose with or without fee is hereby granted, provided that the 6 * above copyright notice and this permission notice appear in all 7 * copies. 8 * 9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 10 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 11 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 12 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL 13 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR 14 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER 15 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 16 * PERFORMANCE OF THIS SOFTWARE. 17 */ 18 19 /** 20 * DOC: wlan_reg_services_api.h 21 * This file provides prototypes of the routines needed for the 22 * external components to utilize the services provided by the 23 * regulatory component. 24 */ 25 26 #ifndef __WLAN_REG_SERVICES_API_H 27 #define __WLAN_REG_SERVICES_API_H 28 29 #include "../../core/src/reg_services.h" 30 #include <reg_services_public_struct.h> 31 32 33 #define WLAN_REG_MIN_24GHZ_CH_NUM REG_MIN_24GHZ_CH_NUM 34 #define WLAN_REG_MAX_24GHZ_CH_NUM REG_MAX_24GHZ_CH_NUM 35 #define WLAN_REG_MIN_5GHZ_CH_NUM REG_MIN_5GHZ_CH_NUM 36 #define WLAN_REG_MAX_5GHZ_CH_NUM REG_MAX_5GHZ_CH_NUM 37 #define WLAN_REG_MIN_11P_CH_NUM REG_MIN_11P_CH_NUM 38 #define WLAN_REG_MAX_11P_CH_NUM REG_MAX_11P_CH_NUM 39 40 #define WLAN_REG_IS_24GHZ_CH(chan) REG_IS_24GHZ_CH(chan) 41 #define WLAN_REG_IS_5GHZ_CH(chan) REG_IS_5GHZ_CH(chan) 42 #define WLAN_REG_IS_11P_CH(chan) REG_IS_11P_CH(chan) 43 44 #define WLAN_REG_IS_24GHZ_CH_FREQ(freq) REG_IS_24GHZ_CH_FREQ(freq) 45 46 #ifndef CONFIG_LEGACY_CHAN_ENUM 47 #define WLAN_REG_IS_49GHZ_FREQ(freq) REG_IS_49GHZ_FREQ(freq) 48 #endif 49 50 #define WLAN_REG_CH_NUM(ch_enum) REG_CH_NUM(ch_enum) 51 #define WLAN_REG_CH_TO_FREQ(ch_enum) REG_CH_TO_FREQ(ch_enum) 52 53 #define WLAN_REG_IS_SAME_BAND_CHANNELS(chan_num1, chan_num2) \ 54 (chan_num1 && chan_num2 && \ 55 (WLAN_REG_IS_5GHZ_CH(chan_num1) == WLAN_REG_IS_5GHZ_CH(chan_num2))) 56 57 58 #define WLAN_REG_IS_CHANNEL_VALID_5G_SBS(curchan, newchan) \ 59 (curchan > newchan ? \ 60 REG_CH_TO_FREQ(reg_get_chan_enum(curchan)) \ 61 - REG_CH_TO_FREQ(reg_get_chan_enum(newchan)) \ 62 > REG_SBS_SEPARATION_THRESHOLD : \ 63 REG_CH_TO_FREQ(reg_get_chan_enum(newchan)) \ 64 - REG_CH_TO_FREQ(reg_get_chan_enum(curchan)) \ 65 > REG_SBS_SEPARATION_THRESHOLD) 66 67 #define WLAN_REG_INVALID_CHANNEL_ID 68 #define WLAN_REG_GET_24_END_CHAN_NUM 14 69 70 #define WLAN_REG_CHAN_TO_BAND(chan_num) reg_chan_to_band(chan_num) 71 72 /** 73 * wlan_reg_get_channel_list_with_power() - Provide the channel list with power 74 * @ch_list: pointer to the channel list. 75 * 76 * Return: QDF_STATUS 77 */ 78 QDF_STATUS wlan_reg_get_channel_list_with_power(struct wlan_objmgr_pdev *pdev, 79 struct channel_power *ch_list, 80 uint8_t *num_chan); 81 82 /** 83 * wlan_reg_read_default_country() - Read the default country for the regdomain 84 * @country: pointer to the country code. 85 * 86 * Return: QDF_STATUS 87 */ 88 QDF_STATUS wlan_reg_read_default_country(struct wlan_objmgr_psoc *psoc, 89 uint8_t *country); 90 91 /** 92 * wlan_reg_read_current_country() - Read the current country for the regdomain 93 * @country: pointer to the country code. 94 * 95 * Return: QDF_STATUS 96 */ 97 QDF_STATUS wlan_reg_read_current_country(struct wlan_objmgr_psoc *psoc, 98 uint8_t *country); 99 100 /** 101 * wlan_reg_get_channel_state() - Get channel state from regulatory 102 * @ch: channel number. 103 * 104 * Return: channel state 105 */ 106 enum channel_state wlan_reg_get_channel_state(struct wlan_objmgr_pdev *pdev, 107 uint32_t ch); 108 109 /** 110 * wlan_reg_get_5g_bonded_channel_state() - Get 5G bonded channel state 111 * @pdev: The physical dev to program country code or regdomain 112 * @ch: channel number. 113 * @bw: channel band width 114 * 115 * Return: channel state 116 */ 117 enum channel_state wlan_reg_get_5g_bonded_channel_state( 118 struct wlan_objmgr_pdev *pdev, uint8_t ch, 119 enum phy_ch_width bw); 120 121 /** 122 * wlan_reg_get_2g_bonded_channel_state() - Get 2G bonded channel state 123 * @pdev: The physical dev to program country code or regdomain 124 * @ch: channel number. 125 * @sec_ch: Secondary channel. 126 * @bw: channel band width 127 * 128 * Return: channel state 129 */ 130 enum channel_state wlan_reg_get_2g_bonded_channel_state( 131 struct wlan_objmgr_pdev *pdev, uint8_t ch, 132 uint8_t sec_ch, enum phy_ch_width bw); 133 134 /** 135 * wlan_reg_set_channel_params () - Sets channel parameteres for given bandwidth 136 * @pdev: The physical dev to program country code or regdomain 137 * @ch: channel number. 138 * @sec_ch_2g: Secondary channel. 139 * @ch_params: pointer to the channel parameters. 140 * 141 * Return: None 142 */ 143 void wlan_reg_set_channel_params(struct wlan_objmgr_pdev *pdev, uint8_t ch, 144 uint8_t sec_ch_2g, 145 struct ch_params *ch_params); 146 147 /** 148 * wlan_reg_get_dfs_region () - Get the current dfs region 149 * @dfs_reg: pointer to dfs region 150 * 151 * Return: Status 152 */ 153 QDF_STATUS wlan_reg_get_dfs_region(struct wlan_objmgr_pdev *pdev, 154 enum dfs_reg *dfs_reg); 155 156 /** 157 * wlan_reg_get_channel_reg_power() - Provide the channel regulatory power 158 * @chan_num: chennal number 159 * 160 * Return: int 161 */ 162 uint32_t wlan_reg_get_channel_reg_power(struct wlan_objmgr_pdev *pdev, 163 uint32_t chan_num); 164 165 /** 166 * wlan_reg_get_channel_freq() - provide the channel center freq 167 * @chan_num: chennal number 168 * 169 * Return: int 170 */ 171 uint32_t wlan_reg_get_channel_freq(struct wlan_objmgr_pdev *pdev, 172 uint32_t chan_num); 173 174 /** 175 * wlan_reg_get_current_chan_list() - provide the pdev current channel list 176 * @pdev: pdev pointer 177 * @chan_list: channel list pointer 178 * 179 * Return: QDF_STATUS 180 */ 181 QDF_STATUS wlan_reg_get_current_chan_list(struct wlan_objmgr_pdev *pdev, 182 struct regulatory_channel *chan_list); 183 /** 184 * wlan_reg_get_bonded_channel_state() - get bonded channel state 185 * @pdev: pdev ptr 186 * @ch: chennal number 187 * @bw: chennal number 188 * @sec_ch: secondary channel 189 * 190 * Return: enum channel_state 191 */ 192 enum channel_state wlan_reg_get_bonded_channel_state( 193 struct wlan_objmgr_pdev *pdev, uint8_t ch, 194 enum phy_ch_width bw, uint8_t sec_ch); 195 196 /** 197 * wlan_reg_set_dfs_region() - set the dfs region 198 * @pdev: pdev ptr 199 * @dfs_reg: dfs region 200 * 201 * Return: void 202 */ 203 void wlan_reg_set_dfs_region(struct wlan_objmgr_pdev *pdev, 204 enum dfs_reg dfs_reg); 205 206 /** 207 * wlan_reg_get_bw_value() - provide the channel center freq 208 * @chan_num: chennal number 209 * 210 * Return: int 211 */ 212 uint16_t wlan_reg_get_bw_value(enum phy_ch_width bw); 213 214 /** 215 * wlan_reg_get_domain_from_country_code() - provide the channel center freq 216 * @reg_domain_ptr: regulatory domain ptr 217 * @country_alpha2: country alpha2 218 * @source: alpha2 source 219 * 220 * Return: int 221 */ 222 QDF_STATUS wlan_reg_get_domain_from_country_code(v_REGDOMAIN_t *reg_domain_ptr, 223 const uint8_t *country_alpha2, 224 enum country_src source); 225 226 /** 227 * wlan_reg_dmn_get_opclass_from_channel() - provide the channel center freq 228 * @country: country alpha2 229 * @channel: channel number 230 * @offset: offset 231 * 232 * Return: int 233 */ 234 uint16_t wlan_reg_dmn_get_opclass_from_channel(uint8_t *country, 235 uint8_t channel, 236 uint8_t offset); 237 238 /** 239 * wlan_reg_dmn_get_chanwidth_from_opclass() - get channel width from 240 * operating class 241 * @country: country alpha2 242 * @channel: channel number 243 * @opclass: operating class 244 * 245 * Return: int 246 */ 247 uint16_t wlan_reg_dmn_get_chanwidth_from_opclass(uint8_t *country, 248 uint8_t channel, 249 uint8_t opclass); 250 /** 251 * wlan_reg_dmn_set_curr_opclasses() - set operating class 252 * @num_classes: number of classes 253 * @class: operating class 254 * 255 * Return: int 256 */ 257 uint16_t wlan_reg_dmn_set_curr_opclasses(uint8_t num_classes, 258 uint8_t *class); 259 260 /** 261 * wlan_reg_dmn_get_curr_opclasses() - get current oper classes 262 * @num_classes: number of classes 263 * @class: operating class 264 * 265 * Return: int 266 */ 267 uint16_t wlan_reg_dmn_get_curr_opclasses(uint8_t *num_classes, 268 uint8_t *class); 269 270 271 /** 272 * wlan_regulatory_init() - init regulatory component 273 * 274 * Return: Success or Failure 275 */ 276 QDF_STATUS wlan_regulatory_init(void); 277 278 /** 279 * wlan_regulatory_deinit() - deinit regulatory component 280 * 281 * Return: Success or Failure 282 */ 283 QDF_STATUS wlan_regulatory_deinit(void); 284 285 /** 286 * regulatory_psoc_open() - open regulatory component 287 * 288 * Return: Success or Failure 289 */ 290 QDF_STATUS regulatory_psoc_open(struct wlan_objmgr_psoc *psoc); 291 292 293 /** 294 * regulatory_psoc_close() - close regulatory component 295 * 296 * Return: Success or Failure 297 */ 298 QDF_STATUS regulatory_psoc_close(struct wlan_objmgr_psoc *psoc); 299 300 /** 301 * regulatory_pdev_open() - Open regulatory component 302 * @pdev: Pointer to pdev structure. 303 * 304 * Return: Success or Failure 305 */ 306 QDF_STATUS regulatory_pdev_open(struct wlan_objmgr_pdev *pdev); 307 308 /** 309 * regulatory_pdev_close() - Close regulatory component 310 * @pdev: Pointer to pdev structure. 311 * 312 * Return: Success or Failure 313 */ 314 QDF_STATUS regulatory_pdev_close(struct wlan_objmgr_pdev *pdev); 315 316 /** 317 * wlan_reg_update_nol_ch () - set nol channel 318 * @pdev: pdev ptr 319 * @ch_list: channel list to be returned 320 * @num_ch: number of channels 321 * @nol_ch: nol flag 322 * 323 * Return: void 324 */ 325 void wlan_reg_update_nol_ch(struct wlan_objmgr_pdev *pdev, 326 uint8_t *ch_list, 327 uint8_t num_ch, 328 bool nol_ch); 329 330 /** 331 * wlan_reg_is_dfs_ch () - Checks the channel state for DFS 332 * @pdev: pdev ptr 333 * @chan: channel 334 * 335 * Return: true or false 336 */ 337 bool wlan_reg_is_dfs_ch(struct wlan_objmgr_pdev *pdev, uint32_t chan); 338 339 /** 340 * wlan_reg_is_passive_or_disable_ch () - Checks chan state for passive 341 * and disabled 342 * @pdev: pdev ptr 343 * @chan: channel 344 * 345 * Return: true or false 346 */ 347 bool wlan_reg_is_passive_or_disable_ch(struct wlan_objmgr_pdev *pdev, 348 uint32_t chan); 349 350 /** 351 * wlan_reg_is_disable_ch () - Checks chan state for disabled 352 * @pdev: pdev ptr 353 * @chan: channel 354 * 355 * Return: true or false 356 */ 357 bool wlan_reg_is_disable_ch(struct wlan_objmgr_pdev *pdev, uint32_t chan); 358 359 /** 360 * wlan_reg_freq_to_chan () - convert channel freq to channel number 361 * @pdev: The physical dev to set current country for 362 * @freq: frequency 363 * 364 * Return: true or false 365 */ 366 uint32_t wlan_reg_freq_to_chan(struct wlan_objmgr_pdev *pdev, 367 uint32_t freq); 368 369 /** 370 * wlan_reg_chan_to_freq () - convert channel number to frequency 371 * @chan: channel number 372 * 373 * Return: true or false 374 */ 375 uint32_t wlan_reg_chan_to_freq(struct wlan_objmgr_pdev *pdev, 376 uint32_t chan); 377 /** 378 * wlan_reg_is_world() - reg is world mode 379 * @country: The country information 380 * 381 * Return: true or false 382 */ 383 bool wlan_reg_is_world(uint8_t *country); 384 385 /** 386 * wlan_reg_is_us() - reg is us country 387 * @country: The country information 388 * 389 * Return: true or false 390 */ 391 bool wlan_reg_is_us(uint8_t *country); 392 393 /** 394 * wlan_reg_chan_is_49ghz() - Check if the input channel number is 4.9GHz 395 * @pdev: Pdev pointer 396 * @chan_num: Input channel number 397 * 398 * Return: true if the channel is 4.9GHz else false. 399 */ 400 401 bool wlan_reg_chan_is_49ghz(struct wlan_objmgr_pdev *pdev, 402 uint8_t chan_num); 403 404 /** 405 * wlan_reg_set_country() - Set the current regulatory country 406 * @pdev: The physical dev to set current country for 407 * @country: The country information to configure 408 * 409 * Return: QDF_STATUS 410 */ 411 QDF_STATUS wlan_reg_set_country(struct wlan_objmgr_pdev *pdev, 412 uint8_t *country); 413 414 /** 415 * wlan_reg_set_11d_country() - Set the 11d regulatory country 416 * @pdev: The physical dev to set current country for 417 * @country: The country information to configure 418 * 419 * Return: QDF_STATUS 420 */ 421 QDF_STATUS wlan_reg_set_11d_country(struct wlan_objmgr_pdev *pdev, 422 uint8_t *country); 423 424 /** 425 * wlan_reg_register_chan_change_callback () - add chan change cbk 426 * @psoc: psoc ptr 427 * @cbk: callback 428 * @arg: argument 429 * 430 * Return: true or false 431 */ 432 void wlan_reg_register_chan_change_callback(struct wlan_objmgr_psoc *psoc, 433 reg_chan_change_callback cbk, 434 void *arg); 435 436 /** 437 * wlan_reg_unregister_chan_change_callback () - remove chan change cbk 438 * @psoc: psoc ptr 439 * @cbk:callback 440 * 441 * Return: true or false 442 */ 443 void wlan_reg_unregister_chan_change_callback(struct wlan_objmgr_psoc *psoc, 444 reg_chan_change_callback cbk); 445 446 /** 447 * wlan_reg_11d_original_enabled_on_host() - 11d original enabled don host 448 * @psoc: psoc ptr 449 * 450 * Return: bool 451 */ 452 bool wlan_reg_11d_original_enabled_on_host(struct wlan_objmgr_psoc *psoc); 453 454 /** 455 * wlan_reg_11d_enabled_on_host() - 11d enabled don host 456 * @psoc: psoc ptr 457 * 458 * Return: bool 459 */ 460 bool wlan_reg_11d_enabled_on_host(struct wlan_objmgr_psoc *psoc); 461 462 /** 463 * wlan_reg_get_chip_mode() - get supported chip mode 464 * @pdev: pdev pointer 465 * @chip_mode: chip mode 466 * 467 * Return: QDF STATUS 468 */ 469 QDF_STATUS wlan_reg_get_chip_mode(struct wlan_objmgr_pdev *pdev, 470 uint32_t *chip_mode); 471 472 /** 473 * wlan_reg_is_11d_scan_inprogress() - checks 11d scan status 474 * @psoc: psoc ptr 475 * 476 * Return: bool 477 */ 478 bool wlan_reg_is_11d_scan_inprogress(struct wlan_objmgr_psoc *psoc); 479 /** 480 * wlan_reg_get_freq_range() - Get 2GHz and 5GHz frequency range 481 * @pdev: pdev pointer 482 * @low_2g: low 2GHz frequency range 483 * @high_2g: high 2GHz frequency range 484 * @low_5g: low 5GHz frequency range 485 * @high_5g: high 5GHz frequency range 486 * 487 * Return: QDF status 488 */ 489 QDF_STATUS wlan_reg_get_freq_range(struct wlan_objmgr_pdev *pdev, 490 uint32_t *low_2g, 491 uint32_t *high_2g, 492 uint32_t *low_5g, 493 uint32_t *high_5g); 494 /** 495 * wlan_reg_get_tx_ops () - get regulatory tx ops 496 * @psoc: psoc ptr 497 * 498 */ 499 struct wlan_lmac_if_reg_tx_ops * 500 wlan_reg_get_tx_ops(struct wlan_objmgr_psoc *psoc); 501 502 /** 503 * wlan_reg_get_curr_regdomain() - Get current regdomain in use 504 * @pdev: pdev pointer 505 * @cur_regdmn: Current regdomain info 506 * 507 * Return: QDF status 508 */ 509 QDF_STATUS wlan_reg_get_curr_regdomain(struct wlan_objmgr_pdev *pdev, 510 struct cur_regdmn_info *cur_regdmn); 511 #endif 512