xref: /wlan-dirver/qca-wifi-host-cmn/umac/regulatory/dispatcher/inc/wlan_reg_services_api.h (revision 45a38684b07295822dc8eba39e293408f203eec8)
1 /*
2  * Copyright (c) 2017-2020 The Linux Foundation. All rights reserved.
3  *
4  * Permission to use, copy, modify, and/or distribute this software for
5  * any purpose with or without fee is hereby granted, provided that the
6  * above copyright notice and this permission notice appear in all
7  * copies.
8  *
9  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
10  * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
11  * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
12  * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
13  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
14  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
15  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
16  * PERFORMANCE OF THIS SOFTWARE.
17  */
18 
19 /**
20  * DOC: wlan_reg_services_api.h
21  * This file provides prototypes of the routines needed for the
22  * external components to utilize the services provided by the
23  * regulatory component.
24  */
25 
26 #ifndef __WLAN_REG_SERVICES_API_H
27 #define __WLAN_REG_SERVICES_API_H
28 
29 #include <reg_services_public_struct.h>
30 
31 #ifdef CONFIG_CHAN_NUM_API
32 /**
33  * wlan_reg_min_24ghz_ch_num() - Get minimum 2.4GHz channel number
34  *
35  * Return: Minimum 2.4GHz channel number
36  */
37 #define WLAN_REG_MIN_24GHZ_CH_NUM wlan_reg_min_24ghz_ch_num()
38 uint8_t wlan_reg_min_24ghz_ch_num(void);
39 
40 /**
41  * wlan_reg_max_24ghz_ch_num() - Get maximum 2.4GHz channel number
42  *
43  * Return: Maximum 2.4GHz channel number
44  */
45 #define WLAN_REG_MAX_24GHZ_CH_NUM wlan_reg_max_24ghz_ch_num()
46 uint8_t wlan_reg_max_24ghz_ch_num(void);
47 
48 /**
49  * wlan_reg_min_5ghz_ch_num() - Get minimum 5GHz channel number
50  *
51  * Return: Minimum 5GHz channel number
52  */
53 #define WLAN_REG_MIN_5GHZ_CH_NUM wlan_reg_min_5ghz_ch_num()
54 uint8_t wlan_reg_min_5ghz_ch_num(void);
55 
56 /**
57  * wlan_reg_max_5ghz_ch_num() - Get maximum 5GHz channel number
58  *
59  * Return: Maximum 5GHz channel number
60  */
61 #define WLAN_REG_MAX_5GHZ_CH_NUM wlan_reg_max_5ghz_ch_num()
62 uint8_t wlan_reg_max_5ghz_ch_num(void);
63 #endif /* CONFIG_CHAN_NUM_API */
64 
65 #ifdef CONFIG_CHAN_FREQ_API
66 /**
67  * wlan_reg_min_24ghz_chan_freq() - Get minimum 2.4GHz channel frequency
68  *
69  * Return: Minimum 2.4GHz channel frequency
70  */
71 #define WLAN_REG_MIN_24GHZ_CHAN_FREQ wlan_reg_min_24ghz_chan_freq()
72 qdf_freq_t wlan_reg_min_24ghz_chan_freq(void);
73 
74 /**
75  * wlan_reg_max_24ghz_chan_freq() - Get maximum 2.4GHz channel frequency
76  *
77  * Return: Maximum 2.4GHz channel frequency
78  */
79 #define WLAN_REG_MAX_24GHZ_CHAN_FREQ wlan_reg_max_24ghz_chan_freq()
80 qdf_freq_t wlan_reg_max_24ghz_chan_freq(void);
81 
82 /**
83  * wlan_reg_min_5ghz_chan_freq() - Get minimum 5GHz channel frequency
84  *
85  * Return: Minimum 5GHz channel frequency
86  */
87 #define WLAN_REG_MIN_5GHZ_CHAN_FREQ wlan_reg_min_5ghz_chan_freq()
88 qdf_freq_t wlan_reg_min_5ghz_chan_freq(void);
89 
90 /**
91  * wlan_reg_max_5ghz_chan_freq() - Get maximum 5GHz channel frequency
92  *
93  * Return: Maximum 5GHz channel frequency
94  */
95 #define WLAN_REG_MAX_5GHZ_CHAN_FREQ wlan_reg_max_5ghz_chan_freq()
96 qdf_freq_t wlan_reg_max_5ghz_chan_freq(void);
97 #endif /* CONFIG_CHAN_FREQ_API */
98 
99 #ifdef CONFIG_CHAN_NUM_API
100 /**
101  * wlan_reg_is_24ghz_ch() - Check if the given channel number is 2.4GHz
102  * @chan: Channel number
103  *
104  * Return: true if channel number is 2.4GHz, else false
105  */
106 #define WLAN_REG_IS_24GHZ_CH(chan) wlan_reg_is_24ghz_ch(chan)
107 bool wlan_reg_is_24ghz_ch(uint8_t chan);
108 
109 /**
110  * wlan_reg_is_5ghz_ch() - Check if the given channel number is 5GHz
111  * @chan: Channel number
112  *
113  * Return: true if channel number is 5GHz, else false
114  */
115 #define WLAN_REG_IS_5GHZ_CH(chan) wlan_reg_is_5ghz_ch(chan)
116 bool wlan_reg_is_5ghz_ch(uint8_t chan);
117 #endif /* CONFIG_CHAN_NUM_API */
118 
119 /**
120  * wlan_reg_is_24ghz_ch_freq() - Check if the given channel frequency is 2.4GHz
121  * @freq: Channel frequency
122  *
123  * Return: true if channel frequency is 2.4GHz, else false
124  */
125 #define WLAN_REG_IS_24GHZ_CH_FREQ(freq) wlan_reg_is_24ghz_ch_freq(freq)
126 bool wlan_reg_is_24ghz_ch_freq(qdf_freq_t freq);
127 
128 /**
129  * wlan_reg_is_5ghz_ch_freq() - Check if the given channel frequency is 5GHz
130  * @freq: Channel frequency
131  *
132  * Return: true if channel frequency is 5GHz, else false
133  */
134 #define WLAN_REG_IS_5GHZ_CH_FREQ(freq) wlan_reg_is_5ghz_ch_freq(freq)
135 bool wlan_reg_is_5ghz_ch_freq(qdf_freq_t freq);
136 
137 #ifdef CONFIG_BAND_6GHZ
138 /**
139  * wlan_reg_is_6ghz_chan_freq() - Check if the given channel frequency is 6GHz
140  * @freq: Channel frequency
141  *
142  * Return: true if channel frequency is 6GHz, else false
143  */
144 #define WLAN_REG_IS_6GHZ_CHAN_FREQ(freq) wlan_reg_is_6ghz_chan_freq(freq)
145 bool wlan_reg_is_6ghz_chan_freq(uint16_t freq);
146 
147 #ifdef CONFIG_6G_FREQ_OVERLAP
148 /**
149  * wlan_reg_is_range_only6g() - Check if the given low_freq and high_freq
150  * is in the 6G range.
151  * @low_freq - Low frequency.
152  * @high_freq - High frequency.
153  *
154  * Return: Return true if given low_freq and high_freq overlaps 6G range,
155  * else false.
156  */
157 bool wlan_reg_is_range_only6g(qdf_freq_t low_freq, qdf_freq_t high_freq);
158 #else
159 static inline bool wlan_reg_is_range_only6g(qdf_freq_t low_freq,
160 					    qdf_freq_t high_freq)
161 {
162 	return false;
163 }
164 #endif
165 
166 /**
167  * wlan_reg_is_6ghz_psc_chan_freq() - Check if the given 6GHz channel frequency
168  * is preferred scanning channel frequency.
169  * @freq: Channel frequency
170  *
171  * Return: true if given 6GHz channel frequency is preferred scanning channel
172  * frequency, else false
173  */
174 #define WLAN_REG_IS_6GHZ_PSC_CHAN_FREQ(freq) \
175 	wlan_reg_is_6ghz_psc_chan_freq(freq)
176 bool wlan_reg_is_6ghz_psc_chan_freq(uint16_t freq);
177 
178 /**
179  * wlan_reg_min_6ghz_chan_freq() - Get minimum 6GHz channel center frequency
180  *
181  * Return: Minimum 6GHz channel center frequency
182  */
183 #define WLAN_REG_MIN_6GHZ_CHAN_FREQ wlan_reg_min_6ghz_chan_freq()
184 uint16_t wlan_reg_min_6ghz_chan_freq(void);
185 
186 /**
187  * wlan_reg_max_6ghz_chan_freq() - Get maximum 6GHz channel center frequency
188  *
189  * Return: Maximum 6GHz channel center frequency
190  */
191 #define WLAN_REG_MAX_6GHZ_CHAN_FREQ wlan_reg_max_6ghz_chan_freq()
192 uint16_t wlan_reg_max_6ghz_chan_freq(void);
193 
194 /**
195  * wlan_reg_is_6g_freq_indoor() - Check if a 6GHz frequency is indoor.
196  * @pdev: Pointer to pdev.
197  * @freq: Channel frequency.
198  *
199  * Return: Return true if a 6GHz frequency is indoor, else false.
200  */
201 #define WLAN_REG_IS_6GHZ_FREQ_INDOOR(pdev, freq) \
202 					wlan_reg_is_6g_freq_indoor(pdev, freq)
203 bool wlan_reg_is_6g_freq_indoor(struct wlan_objmgr_pdev *pdev, qdf_freq_t freq);
204 
205 #else
206 
207 #define WLAN_REG_IS_6GHZ_CHAN_FREQ(freq) (false)
208 static inline bool wlan_reg_is_6ghz_chan_freq(uint16_t freq)
209 {
210 	return false;
211 }
212 
213 static inline bool wlan_reg_is_range_only6g(qdf_freq_t low_freq,
214 					    qdf_freq_t high_freq)
215 {
216 	return false;
217 }
218 
219 #define WLAN_REG_IS_6GHZ_PSC_CHAN_FREQ(freq) (false)
220 static inline bool wlan_reg_is_6ghz_psc_chan_freq(uint16_t freq)
221 {
222 	return false;
223 }
224 
225 #define WLAN_REG_MIN_6GHZ_CHAN_FREQ (false)
226 static inline uint16_t wlan_reg_min_6ghz_chan_freq(void)
227 {
228 	return 0;
229 }
230 
231 #define WLAN_REG_MAX_6GHZ_CHAN_FREQ (false)
232 static inline uint16_t wlan_reg_max_6ghz_chan_freq(void)
233 {
234 	return 0;
235 }
236 
237 #define WLAN_REG_IS_6GHZ_FREQ_INDOOR(pdev, freq) (false)
238 static inline bool
239 wlan_reg_is_6g_freq_indoor(struct wlan_objmgr_pdev *pdev, qdf_freq_t freq)
240 {
241 	return false;
242 }
243 #endif /* CONFIG_BAND_6GHZ */
244 
245 /**
246  * wlan_reg_get_band_channel_list() - Get channel list based on the band_mask
247  * @pdev: pdev ptr
248  * @band_mask: Input bitmap with band set
249  * @channel_list: Pointer to Channel List
250  *
251  * Get the given channel list and number of channels from the current channel
252  * list based on input band bitmap.
253  *
254  * Return: Number of channels, else 0 to indicate error
255  */
256 uint16_t
257 wlan_reg_get_band_channel_list(struct wlan_objmgr_pdev *pdev,
258 			       uint8_t band_mask,
259 			       struct regulatory_channel *channel_list);
260 
261 /**
262  * wlan_reg_chan_band_to_freq - Return channel frequency based on the channel
263  * number and band.
264  * @pdev: pdev ptr
265  * @chan: Channel Number
266  * @band_mask: Bitmap for bands
267  *
268  * Return: Return channel frequency or return 0, if the channel is disabled or
269  * if the input channel number or band_mask is invalid. Composite bands are
270  * supported only for 2.4Ghz and 5Ghz bands. For other bands the following
271  * priority is given: 1) 6Ghz 2) 5Ghz 3) 2.4Ghz.
272  */
273 qdf_freq_t wlan_reg_chan_band_to_freq(struct wlan_objmgr_pdev *pdev,
274 				      uint8_t chan,
275 				      uint8_t band_mask);
276 
277 /**
278  * wlan_reg_is_49ghz_freq() - Check if the given channel frequency is 4.9GHz
279  * @freq: Channel frequency
280  *
281  * Return: true if channel frequency is 4.9GHz, else false
282  */
283 #define WLAN_REG_IS_49GHZ_FREQ(freq) wlan_reg_is_49ghz_freq(freq)
284 bool wlan_reg_is_49ghz_freq(qdf_freq_t freq);
285 
286 /**
287  * wlan_reg_ch_num() - Get channel number from channel enum
288  * @ch_enum: Channel enum
289  *
290  * Return: channel number
291  */
292 #define WLAN_REG_CH_NUM(ch_enum) wlan_reg_ch_num(ch_enum)
293 uint8_t wlan_reg_ch_num(uint32_t ch_enum);
294 
295 /**
296  * wlan_reg_ch_to_freq() - Get channel frequency from channel enum
297  * @ch_enum: Channel enum
298  *
299  * Return: channel frequency
300  */
301 #define WLAN_REG_CH_TO_FREQ(ch_enum) wlan_reg_ch_to_freq(ch_enum)
302 qdf_freq_t wlan_reg_ch_to_freq(uint32_t ch_enum);
303 
304 #ifdef CONFIG_CHAN_NUM_API
305 /**
306  * wlan_reg_is_same_band_channels() - Check if given channel numbers have same
307  * band
308  * @chan_num1: Channel number1
309  * @chan_num2: Channel number2
310  *
311  * Return: true if both the channels has the same band.
312  */
313 #define WLAN_REG_IS_SAME_BAND_CHANNELS(chan_num1, chan_num2) \
314 	wlan_reg_is_same_band_channels(chan_num1, chan_num2)
315 bool wlan_reg_is_same_band_channels(uint8_t chan_num1, uint8_t chan_num2);
316 
317 /**
318  * wlan_reg_is_channel_valid_5g_sbs() Check if the given channel is 5G SBS.
319  * @curchan: current channel
320  * @newchan:new channel
321  *
322  * Return: true if the given channel is a valid 5G SBS
323  */
324 #define WLAN_REG_IS_CHANNEL_VALID_5G_SBS(curchan, newchan) \
325 	wlan_reg_is_channel_valid_5g_sbs(curchan, newchan)
326 bool wlan_reg_is_channel_valid_5g_sbs(uint8_t curchan, uint8_t newchan);
327 #endif /* CONFIG_CHAN_NUM_API */
328 
329 
330 #ifdef CONFIG_CHAN_NUM_API
331 /**
332  * wlan_reg_chan_to_band() - Get band from channel number
333  * @chan_num: channel number
334  *
335  * Return: band info
336  */
337 #define WLAN_REG_CHAN_TO_BAND(chan_num)  wlan_reg_chan_to_band(chan_num)
338 enum band_info wlan_reg_chan_to_band(uint8_t chan_num);
339 #endif /* CONFIG_CHAN_NUM_API */
340 
341 /**
342  * wlan_reg_get_channel_list_with_power() - Provide the channel list with power
343  * @ch_list: pointer to the channel list.
344  *
345  * Return: QDF_STATUS
346  */
347 QDF_STATUS wlan_reg_get_channel_list_with_power(struct wlan_objmgr_pdev *pdev,
348 						struct channel_power *ch_list,
349 						uint8_t *num_chan);
350 
351 /**
352  * wlan_reg_read_default_country() - Read the default country for the regdomain
353  * @country: pointer to the country code.
354  *
355  * Return: QDF_STATUS
356  */
357 QDF_STATUS wlan_reg_read_default_country(struct wlan_objmgr_psoc *psoc,
358 				   uint8_t *country);
359 
360 /**
361  * wlan_reg_get_ctry_idx_max_bw_from_country_code() - Get the max 5G
362  * bandwidth from country code
363  * @cc : Country Code
364  * @max_bw_5g : Max 5G bandwidth supported by the country
365  *
366  * Return : QDF_STATUS
367  */
368 
369 QDF_STATUS wlan_reg_get_max_5g_bw_from_country_code(uint16_t cc,
370 						    uint16_t *max_bw_5g);
371 
372 /**
373  * wlan_reg_get_max_5g_bw_from_regdomain() - Get the max 5G bandwidth
374  * supported by the regdomain
375  * @orig_regdmn : Regdomain Pair value
376  * @max_bw_5g : Max 5G bandwidth supported by the country
377  *
378  * Return : QDF_STATUS
379  */
380 QDF_STATUS wlan_reg_get_max_5g_bw_from_regdomain(uint16_t regdmn,
381 						 uint16_t *max_bw_5g);
382 
383 /**
384  * wlan_reg_get_fcc_constraint() - Check FCC constraint on given frequency
385  * @pdev: physical dev to get
386  * @freq: frequency to be checked
387  *
388  * Return: If FCC constraint is on applied given frequency return true
389  *	   else return false.
390  */
391 bool wlan_reg_get_fcc_constraint(struct wlan_objmgr_pdev *pdev, uint32_t freq);
392 
393 #ifdef CONFIG_REG_CLIENT
394 /**
395  * wlan_reg_read_current_country() - Read the current country for the regdomain
396  * @country: pointer to the country code.
397  *
398  * Return: QDF_STATUS
399  */
400 QDF_STATUS wlan_reg_read_current_country(struct wlan_objmgr_psoc *psoc,
401 				   uint8_t *country);
402 
403 #ifdef CONFIG_CHAN_NUM_API
404 /**
405  * wlan_reg_chan_has_dfs_attribute() - check channel has dfs attribute flag
406  * @ch: channel number.
407  *
408  * This API get chan initial dfs attribute from regdomain
409  *
410  * Return: true if chan is dfs, otherwise false
411  */
412 bool
413 wlan_reg_chan_has_dfs_attribute(struct wlan_objmgr_pdev *pdev, uint8_t ch);
414 
415 /**
416  * wlan_reg_is_etsi13_srd_chan () - Checks if the ch is ETSI13 srd ch or not
417  * @pdev: pdev ptr
418  * @chan_num: channel
419  *
420  * Return: true or false
421  */
422 bool wlan_reg_is_etsi13_srd_chan(struct wlan_objmgr_pdev *pdev,
423 				 uint8_t chan_num);
424 #endif /* CONFIG_CHAN_NUM_API */
425 
426 #ifdef CONFIG_CHAN_FREQ_API
427 /**
428  * wlan_reg_is_etsi13_srd_chan_for_freq () - Checks if the ch is ETSI13 srd ch
429  * or not
430  * @pdev: pdev ptr
431  * @freq: channel center frequency
432  *
433  * Return: true or false
434  */
435 bool wlan_reg_is_etsi13_srd_chan_for_freq(struct wlan_objmgr_pdev *pdev,
436 					  qdf_freq_t freq);
437 #endif /*CONFIG_CHAN_FREQ_API*/
438 
439 /**
440  * wlan_reg_is_etsi13_regdmn() - Checks if current reg domain is ETSI13 or not
441  * @pdev: pdev ptr
442  *
443  * Return: true or false
444  */
445 bool wlan_reg_is_etsi13_regdmn(struct wlan_objmgr_pdev *pdev);
446 
447 /**
448  * wlan_reg_is_etsi13_srd_chan_allowed_master_mode() - Checks if regdmn is
449  * ETSI13 and SRD channels are allowed in master mode or not.
450  *
451  * @pdev: pdev ptr
452  *
453  * Return: true or false
454  */
455 bool wlan_reg_is_etsi13_srd_chan_allowed_master_mode(struct wlan_objmgr_pdev
456 						     *pdev);
457 #endif
458 
459 /**
460  * wlan_reg_is_world() - reg is world mode
461  * @country: The country information
462  *
463  * Return: true or false
464  */
465 bool wlan_reg_is_world(uint8_t *country);
466 
467 #ifdef CONFIG_CHAN_NUM_API
468 /**
469  * wlan_reg_get_chan_enum() - Get channel enum for given channel number
470  * @chan_num: Channel number
471  *
472  * Return: Channel enum
473  */
474 enum channel_enum wlan_reg_get_chan_enum(uint8_t chan_num);
475 
476 /**
477  * wlan_reg_get_channel_state() - Get channel state from regulatory
478  * @ch: channel number.
479  *
480  * Return: channel state
481  */
482 enum channel_state wlan_reg_get_channel_state(struct wlan_objmgr_pdev *pdev,
483 					      uint8_t ch);
484 
485 /**
486  * wlan_reg_get_5g_bonded_channel_state() - Get 5G bonded channel state
487  * @pdev: The physical dev to program country code or regdomain
488  * @ch: channel number.
489  * @bw: channel band width
490  *
491  * Return: channel state
492  */
493 enum channel_state wlan_reg_get_5g_bonded_channel_state(
494 		struct wlan_objmgr_pdev *pdev, uint8_t ch,
495 		enum phy_ch_width bw);
496 
497 /**
498  * wlan_reg_get_2g_bonded_channel_state() - Get 2G bonded channel state
499  * @pdev: The physical dev to program country code or regdomain
500  * @ch: channel number.
501  * @sec_ch: Secondary channel.
502  * @bw: channel band width
503  *
504  * Return: channel state
505  */
506 enum channel_state wlan_reg_get_2g_bonded_channel_state(
507 		struct wlan_objmgr_pdev *pdev, uint8_t ch,
508 		uint8_t sec_ch, enum phy_ch_width bw);
509 
510 /**
511  * wlan_reg_set_channel_params () - Sets channel parameteres for given bandwidth
512  * @pdev: The physical dev to program country code or regdomain
513  * @ch: channel number.
514  * @sec_ch_2g: Secondary channel.
515  * @ch_params: pointer to the channel parameters.
516  *
517  * Return: None
518  */
519 void wlan_reg_set_channel_params(struct wlan_objmgr_pdev *pdev, uint8_t ch,
520 				 uint8_t sec_ch_2g,
521 				 struct ch_params *ch_params);
522 #endif /* CONFIG_CHAN_NUM_API */
523 /**
524  * wlan_reg_get_dfs_region () - Get the current dfs region
525  * @dfs_reg: pointer to dfs region
526  *
527  * Return: Status
528  */
529 QDF_STATUS wlan_reg_get_dfs_region(struct wlan_objmgr_pdev *pdev,
530 			     enum dfs_reg *dfs_reg);
531 
532 #ifdef CONFIG_CHAN_NUM_API
533 /**
534  * wlan_reg_get_channel_reg_power() - Provide the channel regulatory power
535  * @chan_num: channel number
536  *
537  * Return: int
538  */
539 uint32_t wlan_reg_get_channel_reg_power(struct wlan_objmgr_pdev *pdev,
540 					uint8_t chan_num);
541 
542 /**
543  * wlan_reg_get_channel_freq() - provide the channel center freq
544  * @chan_num: channel number
545  *
546  * Return: int
547  */
548 qdf_freq_t wlan_reg_get_channel_freq(struct wlan_objmgr_pdev *pdev,
549 				     uint8_t chan_num);
550 #endif /* CONFIG_CHAN_NUM_API */
551 
552 /**
553  * wlan_reg_get_current_chan_list() - provide the pdev current channel list
554  * @pdev: pdev pointer
555  * @chan_list: channel list pointer
556  *
557  * Return: QDF_STATUS
558  */
559 QDF_STATUS wlan_reg_get_current_chan_list(struct wlan_objmgr_pdev *pdev,
560 		struct regulatory_channel *chan_list);
561 
562 #ifdef CONFIG_CHAN_NUM_API
563 /**
564  * wlan_reg_get_bonded_channel_state() - get bonded channel state
565  * @pdev: pdev ptr
566  * @ch: chennal number
567  * @bw: chennal number
568  * @sec_ch: secondary channel
569  *
570  * Return: enum channel_state
571  */
572 enum channel_state wlan_reg_get_bonded_channel_state(
573 	struct wlan_objmgr_pdev *pdev, uint8_t ch,
574 	enum phy_ch_width bw, uint8_t sec_ch);
575 #endif /* CONFIG_CHAN_NUM_API */
576 
577 /**
578  * wlan_reg_get_bonded_channel_state_for_freq() - Get bonded channel freq state
579  * @freq: channel frequency
580  * @bw: channel band width
581  * @sec_freq: secondary frequency
582  *
583  * Return: channel state
584  */
585 enum channel_state
586 wlan_reg_get_bonded_channel_state_for_freq(struct wlan_objmgr_pdev *pdev,
587 					   qdf_freq_t freq,
588 					   enum phy_ch_width bw,
589 					   qdf_freq_t sec_freq);
590 
591 /**
592  * wlan_reg_set_dfs_region() - set the dfs region
593  * @pdev: pdev ptr
594  * @dfs_reg: dfs region
595  *
596  * Return: void
597  */
598 void wlan_reg_set_dfs_region(struct wlan_objmgr_pdev *pdev,
599 			     enum dfs_reg dfs_reg);
600 
601 /**
602  * wlan_reg_get_bw_value() - provide the channel center freq
603  * @chan_num: chennal number
604  *
605  * Return: int
606  */
607 uint16_t wlan_reg_get_bw_value(enum phy_ch_width bw);
608 
609 /**
610  * wlan_reg_get_domain_from_country_code() - provide the channel center freq
611  * @reg_domain_ptr: regulatory domain ptr
612  * @country_alpha2: country alpha2
613  * @source: alpha2 source
614  *
615  * Return: int
616  */
617 QDF_STATUS wlan_reg_get_domain_from_country_code(v_REGDOMAIN_t *reg_domain_ptr,
618 						 const uint8_t *country_alpha2,
619 						 enum country_src source);
620 
621 /**
622  * wlan_reg_dmn_get_opclass_from_channel() - provide the channel center freq
623  * @country: country alpha2
624  * @channel: channel number
625  * @offset: offset
626  *
627  * Return: int
628  */
629 uint16_t wlan_reg_dmn_get_opclass_from_channel(uint8_t *country,
630 					       uint8_t channel,
631 					       uint8_t offset);
632 
633 /**
634  * wlan_reg_get_opclass_from_freq_width() - Get operating class from frequency
635  * @country: Country code.
636  * @freq: Channel center frequency.
637  * @ch_width: Channel width.
638  * @behav_limit: Behaviour limit.
639  *
640  * Return: Error code.
641  */
642 uint8_t wlan_reg_get_opclass_from_freq_width(uint8_t *country,
643 					     qdf_freq_t freq,
644 					     uint8_t ch_width,
645 					     uint16_t behav_limit);
646 
647 /**
648  * wlan_reg_get_band_cap_from_op_class() - Return band capability bitmap
649  * @country: Pointer to Country code.
650  * @num_of_opclass: Number of Operating class.
651  * @opclass: Pointer to opclass.
652  *
653  * Return supported band bitmap based on the input operating class list
654  * provided.
655  *
656  * Return: Return supported band capability
657  */
658 uint8_t wlan_reg_get_band_cap_from_op_class(const uint8_t *country,
659 					    uint8_t num_of_opclass,
660 					    const uint8_t *opclass);
661 
662 /**
663  * wlan_reg_dmn_print_channels_in_opclass() - Print channels in op-class
664  * @country: country alpha2
665  * @opclass: oplcass
666  *
667  * Return: void
668  */
669 void wlan_reg_dmn_print_channels_in_opclass(uint8_t *country,
670 					    uint8_t opclass);
671 
672 
673 /**
674  * wlan_reg_dmn_get_chanwidth_from_opclass() - get channel width from
675  *                                             operating class
676  * @country: country alpha2
677  * @channel: channel number
678  * @opclass: operating class
679  *
680  * Return: int
681  */
682 uint16_t wlan_reg_dmn_get_chanwidth_from_opclass(uint8_t *country,
683 						 uint8_t channel,
684 						 uint8_t opclass);
685 /**
686  * wlan_reg_dmn_set_curr_opclasses() - set operating class
687  * @num_classes: number of classes
688  * @class: operating class
689  *
690  * Return: int
691  */
692 uint16_t wlan_reg_dmn_set_curr_opclasses(uint8_t num_classes,
693 					 uint8_t *class);
694 
695 /**
696  * wlan_reg_dmn_get_curr_opclasses() - get current oper classes
697  * @num_classes: number of classes
698  * @class: operating class
699  *
700  * Return: int
701  */
702 uint16_t wlan_reg_dmn_get_curr_opclasses(uint8_t *num_classes,
703 					 uint8_t *class);
704 
705 
706 /**
707  * wlan_reg_get_opclass_details() - Get details about the current opclass table.
708  * @pdev: Pointer to pdev.
709  * @reg_ap_cap: Pointer to reg_ap_cap.
710  * @n_opclasses: Pointer to number of opclasses.
711  * @max_supp_op_class: Maximum number of operating classes supported.
712  * @global_tbl_lookup: Whether to lookup global op class tbl.
713  *
714  * Return: QDF_STATUS_SUCCESS if success, else return QDF_STATUS_FAILURE.
715  */
716 QDF_STATUS
717 wlan_reg_get_opclass_details(struct wlan_objmgr_pdev *pdev,
718 			     struct regdmn_ap_cap_opclass_t *reg_ap_cap,
719 			     uint8_t *n_opclasses,
720 			     uint8_t max_supp_op_class,
721 			     bool global_tbl_lookup);
722 
723 /**
724  * wlan_reg_get_cc_and_src () - get country code and src
725  * @psoc: psoc ptr
726  * @alpha2: country code alpha2
727  *
728  * Return: country_src
729  */
730 enum country_src wlan_reg_get_cc_and_src(struct wlan_objmgr_psoc *psoc,
731 					 uint8_t *alpha);
732 
733 /**
734  * wlan_regulatory_init() - init regulatory component
735  *
736  * Return: Success or Failure
737  */
738 QDF_STATUS wlan_regulatory_init(void);
739 
740 /**
741  * wlan_regulatory_deinit() - deinit regulatory component
742  *
743  * Return: Success or Failure
744  */
745 QDF_STATUS wlan_regulatory_deinit(void);
746 
747 /**
748  * regulatory_psoc_open() - open regulatory component
749  *
750  * Return: Success or Failure
751  */
752 QDF_STATUS regulatory_psoc_open(struct wlan_objmgr_psoc *psoc);
753 
754 
755 /**
756  * regulatory_psoc_close() - close regulatory component
757  *
758  * Return: Success or Failure
759  */
760 QDF_STATUS regulatory_psoc_close(struct wlan_objmgr_psoc *psoc);
761 
762 /**
763  * regulatory_pdev_open() - Open regulatory component
764  * @pdev: Pointer to pdev structure
765  *
766  * Return: Success or Failure
767  */
768 QDF_STATUS regulatory_pdev_open(struct wlan_objmgr_pdev *pdev);
769 
770 /**
771  * regulatory_pdev_close() - Close regulatory component
772  * @pdev: Pointer to pdev structure.
773  *
774  * Return: Success or Failure
775  */
776 QDF_STATUS regulatory_pdev_close(struct wlan_objmgr_pdev *pdev);
777 
778 #ifdef CONFIG_CHAN_NUM_API
779 /**
780  * wlan_reg_update_nol_ch () - set nol channel
781  * @pdev: pdev ptr
782  * @ch_list: channel list to be returned
783  * @num_ch: number of channels
784  * @nol_ch: nol flag
785  *
786  * Return: void
787  */
788 void wlan_reg_update_nol_ch(struct wlan_objmgr_pdev *pdev,
789 			    uint8_t *ch_list,
790 			    uint8_t num_ch,
791 			    bool nol_ch);
792 
793 /**
794  * wlan_reg_is_dsrc_chan () - Checks if the channel is dsrc channel or not
795  * @pdev: pdev ptr
796  * @chan_num: channel
797  *
798  * Return: true or false
799  */
800 bool wlan_reg_is_dsrc_chan(struct wlan_objmgr_pdev *pdev, uint8_t chan_num);
801 
802 /**
803  * wlan_reg_is_passive_or_disable_ch () - Checks chan state for passive
804  * and disabled
805  * @pdev: pdev ptr
806  * @chan: channel
807  *
808  * Return: true or false
809  */
810 bool wlan_reg_is_passive_or_disable_ch(struct wlan_objmgr_pdev *pdev,
811 				       uint8_t chan);
812 
813 /**
814  * wlan_reg_is_disable_ch () - Checks chan state for disabled
815  * @pdev: pdev ptr
816  * @chan: channel
817  *
818  * Return: true or false
819  */
820 bool wlan_reg_is_disable_ch(struct wlan_objmgr_pdev *pdev, uint8_t chan);
821 #endif /* CONFIG_CHAN_NUM_API */
822 
823 /**
824  * wlan_reg_freq_to_chan () - convert channel freq to channel number
825  * @pdev: The physical dev to set current country for
826  * @freq: frequency
827  *
828  * Return: true or false
829  */
830 uint8_t wlan_reg_freq_to_chan(struct wlan_objmgr_pdev *pdev,
831 			      qdf_freq_t freq);
832 
833 /**
834  * wlan_reg_chan_to_freq () - convert channel number to frequency
835  * @chan: channel number
836  *
837  * Return: true or false
838  */
839 qdf_freq_t wlan_reg_chan_to_freq(struct wlan_objmgr_pdev *pdev,
840 				 uint8_t chan);
841 
842 /**
843  * wlan_reg_legacy_chan_to_freq () - convert chan to freq, for 2G and 5G
844  * @chan: channel number
845  *
846  * Return: frequency
847  */
848 qdf_freq_t wlan_reg_legacy_chan_to_freq(struct wlan_objmgr_pdev *pdev,
849 					uint8_t chan);
850 
851 /**
852  * wlan_reg_is_us() - reg is us country
853  * @country: The country information
854  *
855  * Return: true or false
856  */
857 bool wlan_reg_is_us(uint8_t *country);
858 
859 #ifdef CONFIG_CHAN_NUM_API
860 /**
861  * wlan_reg_chan_is_49ghz() - Check if the input channel number is 4.9GHz
862  * @pdev: Pdev pointer
863  * @chan_num: Input channel number
864  *
865  * Return: true if the channel is 4.9GHz else false.
866  */
867 bool wlan_reg_chan_is_49ghz(struct wlan_objmgr_pdev *pdev,
868 		uint8_t chan_num);
869 #endif /* CONFIG_CHAN_NUM_API */
870 
871 /**
872  * wlan_reg_set_country() - Set the current regulatory country
873  * @pdev: The physical dev to set current country for
874  * @country: The country information to configure
875  *
876  * Return: QDF_STATUS
877  */
878 QDF_STATUS wlan_reg_set_country(struct wlan_objmgr_pdev *pdev,
879 				uint8_t *country);
880 
881 /**
882  * wlan_reg_set_11d_country() - Set the 11d regulatory country
883  * @pdev: The physical dev to set current country for
884  * @country: The country information to configure
885  *
886  * Return: QDF_STATUS
887  */
888 QDF_STATUS wlan_reg_set_11d_country(struct wlan_objmgr_pdev *pdev,
889 				    uint8_t *country);
890 
891 /**
892  * wlan_reg_register_chan_change_callback () - add chan change cbk
893  * @psoc: psoc ptr
894  * @cbk: callback
895  * @arg: argument
896  *
897  * Return: true or false
898  */
899 void wlan_reg_register_chan_change_callback(struct wlan_objmgr_psoc *psoc,
900 					    void *cbk, void *arg);
901 
902 /**
903  * wlan_reg_unregister_chan_change_callback () - remove chan change cbk
904  * @psoc: psoc ptr
905  * @cbk:callback
906  *
907  * Return: true or false
908  */
909 void wlan_reg_unregister_chan_change_callback(struct wlan_objmgr_psoc *psoc,
910 					      void *cbk);
911 
912 /**
913  * wlan_reg_is_11d_offloaded() - 11d offloaded supported
914  * @psoc: psoc ptr
915  *
916  * Return: bool
917  */
918 bool wlan_reg_is_11d_offloaded(struct wlan_objmgr_psoc *psoc);
919 
920 /**
921  * wlan_reg_11d_enabled_on_host() - 11d enabled don host
922  * @psoc: psoc ptr
923  *
924  * Return: bool
925  */
926 bool wlan_reg_11d_enabled_on_host(struct wlan_objmgr_psoc *psoc);
927 
928 /**
929  * wlan_reg_get_chip_mode() - get supported chip mode
930  * @pdev: pdev pointer
931  * @chip_mode: chip mode
932  *
933  * Return: QDF STATUS
934  */
935 QDF_STATUS wlan_reg_get_chip_mode(struct wlan_objmgr_pdev *pdev,
936 		uint32_t *chip_mode);
937 
938 /**
939  * wlan_reg_is_11d_scan_inprogress() - checks 11d scan status
940  * @psoc: psoc ptr
941  *
942  * Return: bool
943  */
944 bool wlan_reg_is_11d_scan_inprogress(struct wlan_objmgr_psoc *psoc);
945 /**
946  * wlan_reg_get_freq_range() - Get 2GHz and 5GHz frequency range
947  * @pdev: pdev pointer
948  * @low_2g: low 2GHz frequency range
949  * @high_2g: high 2GHz frequency range
950  * @low_5g: low 5GHz frequency range
951  * @high_5g: high 5GHz frequency range
952  *
953  * Return: QDF status
954  */
955 QDF_STATUS wlan_reg_get_freq_range(struct wlan_objmgr_pdev *pdev,
956 		qdf_freq_t *low_2g,
957 		qdf_freq_t *high_2g,
958 		qdf_freq_t *low_5g,
959 		qdf_freq_t *high_5g);
960 /**
961  * wlan_reg_get_tx_ops () - get regulatory tx ops
962  * @psoc: psoc ptr
963  *
964  */
965 struct wlan_lmac_if_reg_tx_ops *
966 wlan_reg_get_tx_ops(struct wlan_objmgr_psoc *psoc);
967 
968 /**
969  * wlan_reg_get_curr_regdomain() - Get current regdomain in use
970  * @pdev: pdev pointer
971  * @cur_regdmn: Current regdomain info
972  *
973  * Return: QDF status
974  */
975 QDF_STATUS wlan_reg_get_curr_regdomain(struct wlan_objmgr_pdev *pdev,
976 		struct cur_regdmn_info *cur_regdmn);
977 
978 #ifdef CONFIG_CHAN_NUM_API
979 /**
980  * wlan_reg_update_nol_history_ch() - Set nol-history flag for the channels in
981  * the list.
982  *
983  * @pdev: Pdev ptr
984  * @ch_list: Input channel list.
985  * @num_ch: Number of channels.
986  * @nol_history_ch: Nol history value.
987  *
988  * Return: void
989  */
990 void wlan_reg_update_nol_history_ch(struct wlan_objmgr_pdev *pdev,
991 				    uint8_t *ch_list,
992 				    uint8_t num_ch,
993 				    bool nol_history_ch);
994 #endif /* CONFIG_CHAN_NUM_API */
995 /**
996  * wlan_reg_is_regdmn_en302502_applicable() - Find if ETSI EN302_502 radar
997  * pattern is applicable in the current regulatory domain.
998  * @pdev:    Pdev ptr.
999  *
1000  * Return: Boolean.
1001  * True:  If EN302_502 is applicable.
1002  * False: otherwise.
1003  */
1004 bool wlan_reg_is_regdmn_en302502_applicable(struct wlan_objmgr_pdev *pdev);
1005 
1006 /**
1007  * wlan_reg_modify_pdev_chan_range() - Compute current channel list for the
1008  * modified channel range in the regcap.
1009  * @pdev: pointer to wlan_objmgr_pdev.
1010  *
1011  * Return : QDF_STATUS
1012  */
1013 QDF_STATUS wlan_reg_modify_pdev_chan_range(struct wlan_objmgr_pdev *pdev);
1014 
1015 /**
1016  * wlan_reg_get_phybitmap() - Get phybitmap from regulatory pdev_priv_obj
1017  * @pdev: pdev pointer
1018  * @phybitmap: pointer to phybitmap
1019  *
1020  * Return: QDF STATUS
1021  */
1022 QDF_STATUS wlan_reg_get_phybitmap(struct wlan_objmgr_pdev *pdev,
1023 				  uint16_t *phybitmap);
1024 
1025 /**
1026  * wlan_reg_update_pdev_wireless_modes() - Update the wireless_modes in the
1027  * pdev_priv_obj with the input wireless_modes
1028  * @pdev: pointer to wlan_objmgr_pdev.
1029  * @wireless_modes: Wireless modes.
1030  *
1031  * Return : QDF_STATUS
1032  */
1033 QDF_STATUS wlan_reg_update_pdev_wireless_modes(struct wlan_objmgr_pdev *pdev,
1034 					       uint32_t wireless_modes);
1035 /**
1036  * wlan_reg_disable_chan_coex() - Disable Coexisting channels based on the input
1037  * bitmask
1038  * @pdev: pointer to wlan_objmgr_pdev.
1039  * unii_5g_bitmap: UNII 5G bitmap.
1040  *
1041  * Return : QDF_STATUS
1042  */
1043 #ifdef DISABLE_UNII_SHARED_BANDS
1044 QDF_STATUS wlan_reg_disable_chan_coex(struct wlan_objmgr_pdev *pdev,
1045 				      uint8_t unii_5g_bitmap);
1046 #else
1047 static inline QDF_STATUS
1048 wlan_reg_disable_chan_coex(struct wlan_objmgr_pdev *pdev,
1049 			   uint8_t unii_5g_bitmap)
1050 {
1051 	return QDF_STATUS_SUCCESS;
1052 }
1053 #endif
1054 
1055 #ifdef CONFIG_CHAN_FREQ_API
1056 /**
1057  * wlan_reg_is_same_band_freqs() - Check if two channel frequencies
1058  * have same band
1059  * @freq1: Frequency 1
1060  * @freq2: Frequency 2
1061  *
1062  * Return: true if both the channel frequency has the same band.
1063  */
1064 #define WLAN_REG_IS_SAME_BAND_FREQS(freq1, freq2) \
1065 	wlan_reg_is_same_band_freqs(freq1, freq2)
1066 bool wlan_reg_is_same_band_freqs(qdf_freq_t freq1, qdf_freq_t freq2);
1067 
1068 /**
1069  * wlan_reg_get_chan_enum_for_freq() - Get channel enum for given channel center
1070  * frequency
1071  * @freq: Channel center frequency
1072  *
1073  * Return: Channel enum
1074  */
1075 enum channel_enum wlan_reg_get_chan_enum_for_freq(qdf_freq_t freq);
1076 
1077 /**
1078  * wlan_reg_update_nol_history_ch_for_freq() - Set nol-history flag for the
1079  * channels in the list.
1080  *
1081  * @pdev: Pdev ptr
1082  * @ch_list: Input channel list.
1083  * @num_ch: Number of channels.
1084  * @nol_history_ch: Nol history value.
1085  *
1086  * Return: void
1087  */
1088 void wlan_reg_update_nol_history_ch_for_freq(struct wlan_objmgr_pdev *pdev,
1089 					     uint16_t *ch_list,
1090 					     uint8_t num_ch,
1091 					     bool nol_history_ch);
1092 /**
1093  * wlan_reg_is_frequency_valid_5g_sbs() Check if the given frequency is 5G SBS.
1094  * @curfreq: current channel center frequency
1095  * @newfreq:new channel center frequency
1096  *
1097  * Return: true if the given frequency is a valid 5G SBS
1098  */
1099 #define WLAN_REG_IS_FREQUENCY_VALID_5G_SBS(curfreq, newfreq) \
1100 	wlan_reg_is_frequency_valid_5g_sbs(curfreq, newfreq)
1101 bool wlan_reg_is_frequency_valid_5g_sbs(qdf_freq_t curfreq, qdf_freq_t newfreq);
1102 
1103 /**
1104  * wlan_reg_chan_has_dfs_attribute_for_freq() - check channel has dfs
1105  * attribute flag
1106  * @freq: channel center frequency.
1107  *
1108  * This API get chan initial dfs attribute from regdomain
1109  *
1110  * Return: true if chan is dfs, otherwise false
1111  */
1112 bool
1113 wlan_reg_chan_has_dfs_attribute_for_freq(struct wlan_objmgr_pdev *pdev,
1114 					 qdf_freq_t freq);
1115 
1116 /**
1117  * wlan_reg_get_channel_list_with_power_for_freq() - Provide the channel list
1118  * with power
1119  * @ch_list: pointer to the channel list.
1120  *
1121  * Return: QDF_STATUS
1122  */
1123 QDF_STATUS
1124 wlan_reg_get_channel_list_with_power_for_freq(struct wlan_objmgr_pdev *pdev,
1125 					      struct channel_power *ch_list,
1126 					      uint8_t *num_chan);
1127 
1128 /**
1129  * wlan_reg_get_5g_bonded_channel_state_for_freq() - Get 5G bonded channel state
1130  * @pdev: The physical dev to program country code or regdomain
1131  * @freq: channel frequency.
1132  * @bw: channel band width
1133  *
1134  * Return: channel state
1135  */
1136 enum channel_state
1137 wlan_reg_get_5g_bonded_channel_state_for_freq(struct wlan_objmgr_pdev *pdev,
1138 					      qdf_freq_t freq,
1139 					      enum phy_ch_width bw);
1140 /**
1141  * wlan_reg_get_2g_bonded_channel_state_for_freq() - Get 2G bonded channel state
1142  * @pdev: The physical dev to program country code or regdomain
1143  * @freq: channel center frequency.
1144  * @sec_ch_freq: Secondary channel center frequency.
1145  * @bw: channel band width
1146  *
1147  * Return: channel state
1148  */
1149 enum channel_state
1150 wlan_reg_get_2g_bonded_channel_state_for_freq(struct wlan_objmgr_pdev *pdev,
1151 					      qdf_freq_t freq,
1152 					      qdf_freq_t sec_ch_freq,
1153 					      enum phy_ch_width bw);
1154 
1155 /**
1156  * wlan_reg_get_channel_state_for_freq() - Get channel state from regulatory
1157  * @pdev: Pointer to pdev
1158  * @freq: channel center frequency.
1159  *
1160  * Return: channel state
1161  */
1162 enum channel_state
1163 wlan_reg_get_channel_state_for_freq(struct wlan_objmgr_pdev *pdev,
1164 				    qdf_freq_t freq);
1165 
1166 /**
1167  * wlan_reg_set_channel_params_for_freq() - Sets channel parameteres for
1168  * given bandwidth
1169  * @pdev: The physical dev to program country code or regdomain
1170  * @freq: channel center frequency.
1171  * @sec_ch_2g_freq: Secondary channel center frequency.
1172  * @ch_params: pointer to the channel parameters.
1173  *
1174  * Return: None
1175  */
1176 void wlan_reg_set_channel_params_for_freq(struct wlan_objmgr_pdev *pdev,
1177 					  qdf_freq_t freq,
1178 					  qdf_freq_t sec_ch_2g_freq,
1179 					  struct ch_params *ch_params);
1180 
1181 /**
1182  * wlan_reg_get_channel_cfreq_reg_power_for_freq() - Provide the channel
1183  * regulatory power
1184  * @freq: channel center frequency
1185  *
1186  * Return: int
1187  */
1188 uint8_t wlan_reg_get_channel_reg_power_for_freq(struct wlan_objmgr_pdev *pdev,
1189 						qdf_freq_t freq);
1190 
1191 /**
1192  * wlan_reg_update_nol_ch_for_freq () - set nol channel
1193  * @pdev: pdev ptr
1194  * @chan_freq_list: channel list to be returned
1195  * @num_ch: number of channels
1196  * @nol_ch: nol flag
1197  *
1198  * Return: void
1199  */
1200 void wlan_reg_update_nol_ch_for_freq(struct wlan_objmgr_pdev *pdev,
1201 				     uint16_t *chan_freq_list,
1202 				     uint8_t num_ch,
1203 				     bool nol_ch);
1204 
1205 /**
1206  * wlan_reg_is_dfs_freq() - Checks the channel state for DFS
1207  * @freq: Channel center frequency
1208  *
1209  * Return: true or false
1210  */
1211 bool wlan_reg_is_dfs_for_freq(struct wlan_objmgr_pdev *pdev, qdf_freq_t freq);
1212 
1213 /**
1214  * wlan_reg_is_dsrc_freq() - Checks if the channel is dsrc channel or not
1215  * @freq: Channel center frequency
1216  *
1217  * Return: true or false
1218  */
1219 bool wlan_reg_is_dsrc_freq(qdf_freq_t freq);
1220 
1221 /**
1222  * wlan_reg_is_passive_or_disable_for_freq() - Checks chan state for passive
1223  * and disabled
1224  * @pdev: pdev ptr
1225  * @freq: Channel center frequency
1226  *
1227  * Return: true or false
1228  */
1229 bool wlan_reg_is_passive_or_disable_for_freq(struct wlan_objmgr_pdev *pdev,
1230 					     qdf_freq_t freq);
1231 
1232 /**
1233  * wlan_reg_is_disable_for_freq() - Checks chan state for disabled
1234  * @pdev: pdev ptr
1235  * @freq: Channel center frequency
1236  *
1237  * Return: true or false
1238  */
1239 bool wlan_reg_is_disable_for_freq(struct wlan_objmgr_pdev *pdev,
1240 				  qdf_freq_t freq);
1241 
1242 /**
1243  * wlan_reg_chan_to_band() - Get band from channel number
1244  * @chan_num: channel number
1245  *
1246  * Return: wifi band
1247  */
1248 enum reg_wifi_band wlan_reg_freq_to_band(qdf_freq_t freq);
1249 
1250 /**
1251  * wlan_reg_min_chan_freq() - Minimum channel frequency supported
1252  *
1253  * Return: frequency
1254  */
1255 qdf_freq_t wlan_reg_min_chan_freq(void);
1256 
1257 /**
1258  * wlan_reg_max_chan_freq() - Return max. frequency
1259  *
1260  * Return: frequency
1261  */
1262 qdf_freq_t wlan_reg_max_chan_freq(void);
1263 
1264 /**
1265  * wlan_reg_freq_width_to_chan_op_class() -Get op class from freq
1266  * @pdev: pdev ptr
1267  * @freq: channel frequency
1268  * @chan_width: channel width
1269  * @global_tbl_lookup: whether to look up global table
1270  * @behav_limit: behavior limit
1271  * @op_class: operating class
1272  * @chan_num: channel number
1273  *
1274  * Return: void
1275  */
1276 void wlan_reg_freq_width_to_chan_op_class(struct wlan_objmgr_pdev *pdev,
1277 					  qdf_freq_t freq,
1278 					  uint16_t chan_width,
1279 					  bool global_tbl_lookup,
1280 					  uint16_t behav_limit,
1281 					  uint8_t *op_class,
1282 					  uint8_t *chan_num);
1283 
1284 /**
1285  * wlan_reg_freq_width_to_chan_op_class_auto() - convert frequency to
1286  * operating class,channel
1287  * @pdev: pdev pointer
1288  * @freq: channel frequency in mhz
1289  * @chan_width: channel width
1290  * @global_tbl_lookup: whether to lookup global op class tbl
1291  * @behav_limit: behavior limit
1292  * @op_class: operating class
1293  * @chan_num: channel number
1294  *
1295  * Return: Void.
1296  */
1297 void wlan_reg_freq_width_to_chan_op_class_auto(struct wlan_objmgr_pdev *pdev,
1298 					       qdf_freq_t freq,
1299 					       uint16_t chan_width,
1300 					       bool global_tbl_lookup,
1301 					       uint16_t behav_limit,
1302 					       uint8_t *op_class,
1303 					       uint8_t *chan_num);
1304 
1305 /**
1306  * wlan_reg_freq_to_chan_and_op_class() - Converts freq to oper class
1307  * @pdev: pdev ptr
1308  * @freq: channel frequency
1309  * @global_tbl_lookup: whether to look up global table
1310  * @behav_limit: behavior limit
1311  * @op_class: operating class
1312  * @chan_num: channel number
1313  *
1314  * Return: void
1315  */
1316 void wlan_reg_freq_to_chan_op_class(struct wlan_objmgr_pdev *pdev,
1317 				    qdf_freq_t freq,
1318 				    bool global_tbl_lookup,
1319 				    uint16_t behav_limit,
1320 				    uint8_t *op_class,
1321 				    uint8_t *chan_num);
1322 
1323 /**
1324  * wlan_reg_is_freq_in_country_opclass() - checks frequency in (ctry, op class)
1325  *                                         pair
1326  * @pdev: pdev ptr
1327  * @country: country information
1328  * @op_class: operating class
1329  * @chan_freq: channel frequency
1330  *
1331  * Return: bool
1332  */
1333 bool wlan_reg_is_freq_in_country_opclass(struct wlan_objmgr_pdev *pdev,
1334 					 const uint8_t country[3],
1335 					 uint8_t op_class,
1336 					 qdf_freq_t chan_freq);
1337 
1338 /**
1339  * wlan_reg_get_5g_bonded_channel_and_state_for_freq()- Return the channel
1340  * state for a 5G or 6G channel frequency based on the channel width and
1341  * bonded channel.
1342  * @pdev: Pointer to pdev.
1343  * @freq: Channel center frequency.
1344  * @bw Channel Width.
1345  * @bonded_chan_ptr_ptr: Pointer to bonded_channel_freq.
1346  *
1347  * Return: Channel State
1348  */
1349 enum channel_state
1350 wlan_reg_get_5g_bonded_channel_and_state_for_freq(struct wlan_objmgr_pdev *pdev,
1351 						  uint16_t freq,
1352 						  enum phy_ch_width bw,
1353 						  const
1354 						  struct bonded_channel_freq
1355 						  **bonded_chan_ptr_ptr);
1356 #endif /*CONFIG_CHAN_FREQ_API */
1357 
1358 /**
1359  * wlan_reg_get_op_class_width() - Get operating class chan width
1360  * @pdev: pdev ptr
1361  * @freq: channel frequency
1362  * @global_tbl_lookup: whether to look up global table
1363  * @op_class: operating class
1364  * @chan_num: channel number
1365  *
1366  * Return: channel width of op class
1367  */
1368 uint16_t wlan_reg_get_op_class_width(struct wlan_objmgr_pdev *pdev,
1369 				     uint8_t op_class,
1370 				     bool global_tbl_lookup);
1371 
1372 /**
1373  * wlan_reg_is_5ghz_op_class() - Check if the input opclass is a 5GHz opclass.
1374  * @country: Country code.
1375  * @op_class: Operating class.
1376  *
1377  * Return: Return true if input the opclass is a 5GHz opclass,
1378  * else return false.
1379  */
1380 bool wlan_reg_is_5ghz_op_class(const uint8_t *country, uint8_t op_class);
1381 
1382 /**
1383  * wlan_reg_is_2ghz_op_class() - Check if the input opclass is a 2.4GHz opclass.
1384  * @country: Country code.
1385  * @op_class: Operating class.
1386  *
1387  * Return: Return true if input the opclass is a 2.4GHz opclass,
1388  * else return false.
1389  */
1390 bool wlan_reg_is_2ghz_op_class(const uint8_t *country, uint8_t op_class);
1391 
1392 /**
1393  * wlan_reg_is_6ghz_op_class() - Whether 6ghz oper class
1394  * @pdev: pdev ptr
1395  * @op_class: operating class
1396  *
1397  * Return: bool
1398  */
1399 bool wlan_reg_is_6ghz_op_class(struct wlan_objmgr_pdev *pdev,
1400 			       uint8_t op_class);
1401 
1402 #ifdef CONFIG_REG_CLIENT
1403 /**
1404  * wlan_reg_is_6ghz_supported() - Whether 6ghz is supported
1405  * @psoc: psoc ptr
1406  *
1407  * Return: bool
1408  */
1409 bool wlan_reg_is_6ghz_supported(struct wlan_objmgr_psoc *psoc);
1410 #endif
1411 
1412 #ifdef HOST_OPCLASS_EXT
1413 /**
1414  * wlan_reg_country_chan_opclass_to_freq() - Convert channel number to
1415  * frequency based on country code and op class
1416  * @pdev: pdev object.
1417  * @country: country code.
1418  * @chan: IEEE Channel Number.
1419  * @op_class: Opclass.
1420  * @strict: flag to find channel from matched operating class code.
1421  *
1422  * Look up (channel, operating class) pair in country operating class tables
1423  * and return the channel frequency.
1424  * If not found and "strict" flag is false, try to get frequency (Mhz) by
1425  * channel number only.
1426  *
1427  * Return: Channel center frequency else return 0.
1428  */
1429 qdf_freq_t
1430 wlan_reg_country_chan_opclass_to_freq(struct wlan_objmgr_pdev *pdev,
1431 				      const uint8_t country[3],
1432 				      uint8_t chan, uint8_t op_class,
1433 				      bool strict);
1434 #endif
1435 
1436 /**
1437  * reg_chan_opclass_to_freq() - Convert channel number and opclass to frequency
1438  * @chan: IEEE Channel Number.
1439  * @op_class: Opclass.
1440  * @global_tbl_lookup: Global table lookup.
1441  *
1442  * Return: Channel center frequency else return 0.
1443  */
1444 uint16_t wlan_reg_chan_opclass_to_freq(uint8_t chan,
1445 				       uint8_t op_class,
1446 				       bool global_tbl_lookup);
1447 
1448 /**
1449  * wlan_reg_chan_opclass_to_freq_auto() - Convert channel number and opclass to
1450  * frequency
1451  * @chan: IEEE channel number
1452  * @op_class: Operating class of channel
1453  * @global_tbl_lookup: Flag to determine if global table has to be looked up
1454  *
1455  * Return: Channel center frequency if valid, else zero
1456  */
1457 
1458 qdf_freq_t wlan_reg_chan_opclass_to_freq_auto(uint8_t chan, uint8_t op_class,
1459 					      bool global_tbl_lookup);
1460 
1461 #ifdef CHECK_REG_PHYMODE
1462 /**
1463  * wlan_reg_get_max_phymode() - Find the best possible phymode given a
1464  * phymode, a frequency, and per-country regulations
1465  * @pdev: pdev pointer
1466  * @phy_in: phymode that the user requested
1467  * @freq: current operating center frequency
1468  *
1469  * Return: maximum phymode allowed in current country that is <= phy_in
1470  */
1471 enum reg_phymode wlan_reg_get_max_phymode(struct wlan_objmgr_pdev *pdev,
1472 					  enum reg_phymode phy_in,
1473 					  qdf_freq_t freq);
1474 #else
1475 static inline enum reg_phymode
1476 wlan_reg_get_max_phymode(struct wlan_objmgr_pdev *pdev,
1477 			 enum reg_phymode phy_in,
1478 			 qdf_freq_t freq)
1479 {
1480 	return REG_PHYMODE_INVALID;
1481 }
1482 #endif /* CHECK_REG_PHYMODE */
1483 
1484 #ifdef CONFIG_REG_CLIENT
1485 /**
1486  * wlan_reg_band_bitmap_to_band_info() - Convert the band_bitmap to a
1487  *	band_info enum
1488  * @band_bitmap: bitmap on top of reg_wifi_band of bands enabled
1489  *
1490  * Return: BAND_ALL if both 2G and 5G band is enabled
1491  *	BAND_2G if 2G is enabled but 5G isn't
1492  *	BAND_5G if 5G is enabled but 2G isn't
1493  */
1494 enum band_info wlan_reg_band_bitmap_to_band_info(uint32_t band_bitmap);
1495 #endif
1496 
1497 #endif
1498