1 /* 2 * Copyright (c) 2017-2020 The Linux Foundation. All rights reserved. 3 * 4 * 5 * Permission to use, copy, modify, and/or distribute this software for 6 * any purpose with or without fee is hereby granted, provided that the 7 * above copyright notice and this permission notice appear in all 8 * copies. 9 * 10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 11 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 12 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 13 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL 14 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR 15 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER 16 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 17 * PERFORMANCE OF THIS SOFTWARE. 18 */ 19 20 /** 21 * DOC: reg_opclass.h 22 * This file provides prototypes of the regulatory opclass functions 23 */ 24 25 #ifndef __REG_OPCLASS_H__ 26 #define __REG_OPCLASS_H__ 27 28 #ifdef HOST_OPCLASS 29 /** 30 * reg_dmn_get_chanwidth_from_opclass() - Get channel width from opclass. 31 * @country: Country code 32 * @channel: Channel number 33 * @opclass: Operating class 34 * 35 * Return: Channel width 36 */ 37 uint16_t reg_dmn_get_chanwidth_from_opclass(uint8_t *country, uint8_t channel, 38 uint8_t opclass); 39 40 /** 41 * reg_dmn_get_opclass_from_channel() - Get operating class from channel. 42 * @country: Country code. 43 * @channel: Channel number. 44 * @offset: Operating class offset. 45 * 46 * Return: Error code. 47 */ 48 uint16_t reg_dmn_get_opclass_from_channel(uint8_t *country, uint8_t channel, 49 uint8_t offset); 50 51 /** 52 * reg_dmn_get_opclass_from_freq_width() - Get operating class from frequency 53 * @country: Country code. 54 * @freq: Channel center frequency. 55 * @ch_width: Channel width. 56 * @behav_limit: Behaviour limit. 57 * 58 * Return: Error code. 59 */ 60 uint8_t reg_dmn_get_opclass_from_freq_width(uint8_t *country, 61 qdf_freq_t freq, 62 uint8_t ch_width, 63 uint16_t behav_limit); 64 65 /** 66 * reg_get_band_cap_from_op_class() - Return band capability bitmap 67 * @country: Pointer to Country code. 68 * @num_of_opclass: Number of Operating class. 69 * @opclass: Pointer to opclass. 70 * 71 * Return supported band bitmap based on the input operating class list 72 * provided. 73 * 74 * Return: Return supported band capability 75 */ 76 uint8_t reg_get_band_cap_from_op_class(const uint8_t *country, 77 uint8_t num_of_opclass, 78 const uint8_t *opclass); 79 80 /** 81 * reg_dmn_get_opclass_from_channe() - Print channels in op class. 82 * @country: Country code. 83 * @opclass: opclass. 84 * 85 * Return: Void. 86 */ 87 void reg_dmn_print_channels_in_opclass(uint8_t *country, uint8_t op_class); 88 89 /** 90 * reg_dmn_set_curr_opclasses() - Set current operating class 91 * @num_classes: Number of classes 92 * @class: Pointer to operating class. 93 * 94 * Return: Error code. 95 */ 96 uint16_t reg_dmn_set_curr_opclasses(uint8_t num_classes, uint8_t *class); 97 98 /** 99 * reg_dmn_get_curr_opclasses() - Get current supported operating classes. 100 * @num_classes: Number of classes. 101 * @class: Pointer to operating class. 102 * 103 * Return: Error code. 104 */ 105 uint16_t reg_dmn_get_curr_opclasses(uint8_t *num_classes, uint8_t *class); 106 107 /** 108 * reg_get_opclass_details() - Get details about the current opclass table. 109 * @pdev: Pointer to pdev. 110 * @reg_ap_cap: Pointer to reg_ap_cap. 111 * @n_opclasses: Pointer to number of opclasses. 112 * @max_supp_op_class: Maximum number of operating classes supported. 113 * @global_tbl_lookup: Whether to lookup global op class table. 114 * 115 * Return: QDF_STATUS_SUCCESS if success, else return QDF_STATUS_FAILURE. 116 */ 117 QDF_STATUS reg_get_opclass_details(struct wlan_objmgr_pdev *pdev, 118 struct regdmn_ap_cap_opclass_t *reg_ap_cap, 119 uint8_t *n_opclasses, 120 uint8_t max_supp_op_class, 121 bool global_tbl_lookup); 122 #ifdef CONFIG_CHAN_FREQ_API 123 124 /** 125 * reg_freq_width_to_chan_op_class() - convert frequency to oper class, 126 * channel 127 * @pdev: pdev pointer 128 * @freq: channel frequency in mhz 129 * @chan_width: channel width 130 * @global_tbl_lookup: whether to lookup global op class tbl 131 * @behav_limit: behavior limit 132 * @op_class: operating class 133 * @chan_num: channel number 134 * 135 * Return: Void. 136 */ 137 void reg_freq_width_to_chan_op_class(struct wlan_objmgr_pdev *pdev, 138 qdf_freq_t freq, 139 uint16_t chan_width, 140 bool global_tbl_lookup, 141 uint16_t behav_limit, 142 uint8_t *op_class, 143 uint8_t *chan_num); 144 145 /** 146 * reg_freq_width_to_chan_op_class_auto() - convert frequency to operating 147 * class,channel after fixing up the global_tbl_lookup and behav_limit 148 * for 6G frequencies. 149 * @pdev: pdev pointer 150 * @freq: channel frequency in mhz 151 * @chan_width: channel width 152 * @global_tbl_lookup: whether to lookup global op class tbl 153 * @behav_limit: behavior limit 154 * @op_class: operating class 155 * @chan_num: channel number 156 * 157 * Return: Void. 158 */ 159 void reg_freq_width_to_chan_op_class_auto(struct wlan_objmgr_pdev *pdev, 160 qdf_freq_t freq, 161 uint16_t chan_width, 162 bool global_tbl_lookup, 163 uint16_t behav_limit, 164 uint8_t *op_class, 165 uint8_t *chan_num); 166 167 /** 168 * reg_freq_to_chan_op_class() - convert frequency to oper class, 169 * channel 170 * @pdev: pdev pointer 171 * @freq: channel frequency in mhz 172 * @global_tbl_lookup: whether to lookup global op class tbl 173 * @behav_limit: behavior limit 174 * @op_class: operating class 175 * @chan_num: channel number 176 * 177 * Return: Void. 178 */ 179 void reg_freq_to_chan_op_class(struct wlan_objmgr_pdev *pdev, 180 qdf_freq_t freq, 181 bool global_tbl_lookup, 182 uint16_t behav_limit, 183 uint8_t *op_class, 184 uint8_t *chan_num); 185 186 /** 187 * reg_is_freq_in_country_opclass() - check for frequency in (tbl, oper class) 188 * 189 * @pdev: pdev pointer 190 * @country: country from country IE 191 * @op_class: operating class 192 * @chan_freq: channel frequency in mhz 193 * 194 * Return: bool 195 */ 196 bool reg_is_freq_in_country_opclass(struct wlan_objmgr_pdev *pdev, 197 const uint8_t country[3], 198 uint8_t op_class, 199 qdf_freq_t chan_freq); 200 #endif 201 202 /** 203 * reg_get_op_class_width() - get oper class width 204 * 205 * @pdev: pdev pointer 206 * @global_tbl_lookup: whether to lookup global op class tbl 207 * @op_class: operating class 208 * Return: uint16 209 */ 210 uint16_t reg_get_op_class_width(struct wlan_objmgr_pdev *pdev, 211 uint8_t op_class, 212 bool global_tbl_lookup); 213 214 #ifdef HOST_OPCLASS_EXT 215 /** 216 * reg_country_chan_opclass_to_freq() - Convert channel number to frequency 217 * based on country code and op class 218 * @pdev: pdev object. 219 * @country: country code. 220 * @chan: IEEE Channel Number. 221 * @op_class: Opclass. 222 * @strict: flag to find channel from matched operating class code. 223 * 224 * Look up (channel, operating class) pair in country operating class tables 225 * and return the channel frequency. 226 * If not found and "strict" flag is false, try to get frequency (Mhz) by 227 * channel number only. 228 * 229 * Return: Channel center frequency else return 0. 230 */ 231 qdf_freq_t reg_country_chan_opclass_to_freq(struct wlan_objmgr_pdev *pdev, 232 const uint8_t country[3], 233 uint8_t chan, uint8_t op_class, 234 bool strict); 235 #endif 236 237 /** 238 * reg_chan_opclass_to_freq() - Convert channel number and opclass to frequency 239 * @chan: IEEE Channel Number. 240 * @op_class: Opclass. 241 * @global_tbl_lookup: Global table lookup. 242 * 243 * Return: Channel center frequency else return 0. 244 */ 245 uint16_t reg_chan_opclass_to_freq(uint8_t chan, 246 uint8_t op_class, 247 bool global_tbl_lookup); 248 249 /** 250 * reg_chan_opclass_to_freq_auto() - Convert channel number and opclass to 251 * frequency after fixing global_tbl_lookup 252 * @chan: IEEE Channel Number. 253 * @op_class: Opclass. 254 * @global_tbl_lookup: Global table lookup. 255 * 256 * Return: Channel center frequency else return 0. 257 */ 258 qdf_freq_t reg_chan_opclass_to_freq_auto(uint8_t chan, uint8_t op_class, 259 bool global_tbl_lookup); 260 261 #else 262 263 static inline uint16_t reg_dmn_get_chanwidth_from_opclass( 264 uint8_t *country, uint8_t channel, uint8_t opclass) 265 { 266 return 0; 267 } 268 269 static inline uint16_t reg_dmn_set_curr_opclasses( 270 uint8_t num_classes, uint8_t *class) 271 { 272 return 0; 273 } 274 275 static inline uint16_t reg_dmn_get_curr_opclasses( 276 uint8_t *num_classes, uint8_t *class) 277 { 278 return 0; 279 } 280 281 static inline uint16_t reg_dmn_get_opclass_from_channel( 282 uint8_t *country, uint8_t channel, uint8_t offset) 283 { 284 return 0; 285 } 286 287 static inline 288 uint8_t reg_dmn_get_opclass_from_freq_width(uint8_t *country, 289 qdf_freq_t freq, 290 uint8_t ch_width, 291 uint16_t behav_limit) 292 { 293 return 0; 294 } 295 296 static inline 297 uint8_t reg_get_band_cap_from_op_class(const uint8_t *country, 298 uint8_t num_of_opclass, 299 const uint8_t *opclass) 300 { 301 return 0; 302 } 303 304 static inline void reg_dmn_print_channels_in_opclass(uint8_t *country, 305 uint8_t op_class) 306 { 307 } 308 309 static inline 310 QDF_STATUS reg_get_opclass_details(struct wlan_objmgr_pdev *pdev, 311 struct regdmn_ap_cap_opclass_t *reg_ap_cap, 312 uint8_t *n_opclasses, 313 uint8_t max_supp_op_class, 314 bool global_tbl_lookup) 315 { 316 return QDF_STATUS_E_FAILURE; 317 } 318 319 #ifdef CONFIG_CHAN_FREQ_API 320 321 static inline void 322 reg_freq_width_to_chan_op_class(struct wlan_objmgr_pdev *pdev, 323 qdf_freq_t freq, 324 uint16_t chan_width, 325 bool global_tbl_lookup, 326 uint16_t behav_limit, 327 uint8_t *op_class, 328 uint8_t *chan_num) 329 { 330 } 331 332 static inline void 333 reg_freq_width_to_chan_op_class_auto(struct wlan_objmgr_pdev *pdev, 334 qdf_freq_t freq, 335 uint16_t chan_width, 336 bool global_tbl_lookup, 337 uint16_t behav_limit, 338 uint8_t *op_class, 339 uint8_t *chan_num) 340 { 341 } 342 343 static inline void 344 reg_freq_to_chan_op_class(struct wlan_objmgr_pdev *pdev, 345 qdf_freq_t freq, 346 bool global_tbl_lookup, 347 uint16_t behav_limit, 348 uint8_t *op_class, 349 uint8_t *chan_num) 350 { 351 } 352 353 static inline bool 354 reg_is_freq_in_country_opclass(struct wlan_objmgr_pdev *pdev, 355 const uint8_t country[3], 356 uint8_t op_class, 357 uint16_t chan_freq) 358 { 359 return false; 360 } 361 362 #endif 363 364 static inline uint16_t reg_get_op_class_width(struct wlan_objmgr_pdev *pdev, 365 uint8_t op_class, 366 bool global_tbl_lookup) 367 { 368 return 0; 369 } 370 371 #ifdef HOST_OPCLASS_EXT 372 static inline 373 qdf_freq_t reg_country_chan_opclass_to_freq(struct wlan_objmgr_pdev *pdev, 374 const uint8_t country[3], 375 uint8_t chan, uint8_t op_class, 376 bool strict) 377 { 378 return 0; 379 } 380 #endif 381 382 static inline uint16_t 383 reg_chan_opclass_to_freq(uint8_t chan, 384 uint8_t op_class, 385 bool global_tbl_lookup) 386 { 387 return 0; 388 } 389 390 static inline qdf_freq_t 391 reg_chan_opclass_to_freq_auto(uint8_t chan, uint8_t op_class, 392 bool global_tbl_lookup) 393 { 394 return 0; 395 } 396 397 #endif 398 #endif 399