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