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