xref: /wlan-dirver/qca-wifi-host-cmn/umac/regulatory/dispatcher/inc/wlan_reg_services_api.h (revision 748fe0b6d71d93f0e1777af1e28fd8466e72c72a)
1 /*
2  * Copyright (c) 2017-2021 The Linux Foundation. All rights reserved.
3  * Copyright (c) 2021-2023 Qualcomm Innovation Center, Inc. All rights reserved.
4  *
5  * Permission to use, copy, modify, and/or distribute this software for
6  * any purpose with or without fee is hereby granted, provided that the
7  * above copyright notice and this permission notice appear in all
8  * copies.
9  *
10  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
11  * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
12  * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
13  * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
14  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
15  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
16  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
17  * PERFORMANCE OF THIS SOFTWARE.
18  */
19 
20 /**
21  * DOC: wlan_reg_services_api.h
22  * This file provides prototypes of the routines needed for the
23  * external components to utilize the services provided by the
24  * regulatory component.
25  */
26 
27 #ifndef __WLAN_REG_SERVICES_API_H
28 #define __WLAN_REG_SERVICES_API_H
29 
30 #include <reg_services_public_struct.h>
31 
32 /**
33  * wlan_reg_max_5ghz_ch_num() - Get maximum 5GHz channel number
34  *
35  * Return: Maximum 5GHz channel number
36  */
37 uint8_t wlan_reg_max_5ghz_ch_num(void);
38 #define WLAN_REG_MAX_5GHZ_CH_NUM wlan_reg_max_5ghz_ch_num()
39 
40 #ifdef CONFIG_CHAN_FREQ_API
41 /**
42  * wlan_reg_min_24ghz_chan_freq() - Get minimum 2.4GHz channel frequency
43  *
44  * Return: Minimum 2.4GHz channel frequency
45  */
46 qdf_freq_t wlan_reg_min_24ghz_chan_freq(void);
47 #define WLAN_REG_MIN_24GHZ_CHAN_FREQ wlan_reg_min_24ghz_chan_freq()
48 
49 /**
50  * wlan_reg_max_24ghz_chan_freq() - Get maximum 2.4GHz channel frequency
51  *
52  * Return: Maximum 2.4GHz channel frequency
53  */
54 qdf_freq_t wlan_reg_max_24ghz_chan_freq(void);
55 #define WLAN_REG_MAX_24GHZ_CHAN_FREQ wlan_reg_max_24ghz_chan_freq()
56 
57 /**
58  * wlan_reg_min_5ghz_chan_freq() - Get minimum 5GHz channel frequency
59  *
60  * Return: Minimum 5GHz channel frequency
61  */
62 qdf_freq_t wlan_reg_min_5ghz_chan_freq(void);
63 #define WLAN_REG_MIN_5GHZ_CHAN_FREQ wlan_reg_min_5ghz_chan_freq()
64 
65 /**
66  * wlan_reg_max_5ghz_chan_freq() - Get maximum 5GHz channel frequency
67  *
68  * Return: Maximum 5GHz channel frequency
69  */
70 qdf_freq_t wlan_reg_max_5ghz_chan_freq(void);
71 #define WLAN_REG_MAX_5GHZ_CHAN_FREQ wlan_reg_max_5ghz_chan_freq()
72 #endif /* CONFIG_CHAN_FREQ_API */
73 
74 /**
75  * wlan_reg_is_24ghz_ch_freq() - Check if the given channel frequency is 2.4GHz
76  * @freq: Channel frequency
77  *
78  * Return: true if channel frequency is 2.4GHz, else false
79  */
80 bool wlan_reg_is_24ghz_ch_freq(qdf_freq_t freq);
81 #define WLAN_REG_IS_24GHZ_CH_FREQ(freq) wlan_reg_is_24ghz_ch_freq(freq)
82 
83 /**
84  * wlan_reg_is_5ghz_ch_freq() - Check if the given channel frequency is 5GHz
85  * @freq: Channel frequency
86  *
87  * Return: true if channel frequency is 5GHz, else false
88  */
89 bool wlan_reg_is_5ghz_ch_freq(qdf_freq_t freq);
90 #define WLAN_REG_IS_5GHZ_CH_FREQ(freq) wlan_reg_is_5ghz_ch_freq(freq)
91 
92 /**
93  * wlan_reg_is_range_overlap_2g() - Check if the given low_freq and high_freq
94  * is in the 2G range.
95  *
96  * @low_freq: Low frequency.
97  * @high_freq: High frequency.
98  *
99  * Return: Return true if given low_freq and high_freq overlaps 2G range,
100  * else false.
101  */
102 bool wlan_reg_is_range_overlap_2g(qdf_freq_t low_freq, qdf_freq_t high_freq);
103 
104 /**
105  * wlan_reg_is_range_overlap_5g() - Check if the given low_freq and high_freq
106  * is in the 5G range.
107  *
108  * @low_freq: Low frequency.
109  * @high_freq: High frequency.
110  *
111  * Return: Return true if given low_freq and high_freq overlaps 5G range,
112  * else false.
113  */
114 bool wlan_reg_is_range_overlap_5g(qdf_freq_t low_freq, qdf_freq_t high_freq);
115 
116 /**
117  * wlan_reg_is_freq_indoor() - Check if a frequency is indoor.
118  * @pdev: Pointer to pdev.
119  * @freq: Channel frequency.
120  *
121  * Return: Return true if a frequency is indoor, else false.
122  */
123 bool wlan_reg_is_freq_indoor(struct wlan_objmgr_pdev *pdev, qdf_freq_t freq);
124 
125 /**
126  * wlan_reg_get_min_chwidth() - Return min chanwidth supported by freq.
127  * @pdev: Pointer to pdev.
128  * @freq: Channel frequency.
129  *
130  * Return: Min chwidth supported by freq as per regulatory DB.
131  */
132 uint16_t wlan_reg_get_min_chwidth(struct wlan_objmgr_pdev *pdev,
133 				  qdf_freq_t freq);
134 
135 /**
136  * wlan_reg_get_max_chwidth() - Return max chanwidth supported by freq.
137  * @pdev: Pointer to pdev.
138  * @freq: Channel frequency.
139  *
140  * Return: Max chwidth supported by freq as per regulatory DB.
141  */
142 uint16_t wlan_reg_get_max_chwidth(struct wlan_objmgr_pdev *pdev,
143 				  qdf_freq_t freq);
144 
145 /**
146  * wlan_reg_get_next_lower_bandwidth() - Get next lower bandwdith
147  * @ch_width: channel bandwdith
148  *
149  * Return: Return next lower bandwidth of input channel bandwidth
150  */
151 enum phy_ch_width
152 wlan_reg_get_next_lower_bandwidth(enum phy_ch_width ch_width);
153 
154 #ifdef CONFIG_REG_CLIENT
155 /**
156  * wlan_reg_is_freq_indoor_in_secondary_list() - Check if the input frequency is
157  * an indoor frequency in the secondary list
158  * @pdev: Pointer to pdev.
159  * @freq: Channel frequency.
160  *
161  * Return: Return true if a frequency is indoor, else false.
162  */
163 bool wlan_reg_is_freq_indoor_in_secondary_list(struct wlan_objmgr_pdev *pdev,
164 					       qdf_freq_t freq);
165 #endif
166 
167 #ifdef CONFIG_BAND_6GHZ
168 /**
169  * wlan_reg_is_6ghz_chan_freq() - Check if the given channel frequency is 6GHz
170  * @freq: Channel frequency
171  *
172  * Return: true if channel frequency is 6GHz, else false
173  */
174 bool wlan_reg_is_6ghz_chan_freq(uint16_t freq);
175 #define WLAN_REG_IS_6GHZ_CHAN_FREQ(freq) wlan_reg_is_6ghz_chan_freq(freq)
176 
177 #ifdef CONFIG_6G_FREQ_OVERLAP
178 /**
179  * wlan_reg_is_range_only6g() - Check if the given low_freq and high_freq
180  * is in the 6G range.
181  * @low_freq: Low frequency.
182  * @high_freq: High frequency.
183  *
184  * Return: Return true if given low_freq and high_freq overlaps 6G range,
185  * else false.
186  */
187 bool wlan_reg_is_range_only6g(qdf_freq_t low_freq, qdf_freq_t high_freq);
188 
189 /**
190  * wlan_reg_is_range_overlap_6g() - Check if the given low_freq and high_freq
191  * is in the 6G range.
192  *
193  * @low_freq: Low frequency.
194  * @high_freq: High frequency.
195  *
196  * Return: Return true if given low_freq and high_freq overlaps 6G range,
197  * else false.
198  */
199 bool wlan_reg_is_range_overlap_6g(qdf_freq_t low_freq, qdf_freq_t high_freq);
200 #else
201 static inline bool wlan_reg_is_range_only6g(qdf_freq_t low_freq,
202 					    qdf_freq_t high_freq)
203 {
204 	return false;
205 }
206 
207 static inline bool wlan_reg_is_range_overlap_6g(qdf_freq_t low_freq,
208 						qdf_freq_t high_freq)
209 {
210 	return false;
211 }
212 #endif
213 
214 /**
215  * wlan_reg_get_6g_ap_master_chan_list() - provide  the appropriate ap master
216  * channel list
217  * @pdev: pdev pointer
218  * @ap_pwr_type: The ap power type (LPI/VLP/SP)
219  * @chan_list: channel list pointer
220  *
221  * Return: QDF_STATUS
222  */
223 QDF_STATUS wlan_reg_get_6g_ap_master_chan_list(
224 					struct wlan_objmgr_pdev *pdev,
225 					enum reg_6g_ap_type ap_pwr_type,
226 					struct regulatory_channel *chan_list);
227 
228 #ifdef CONFIG_REG_CLIENT
229 /**
230  * wlan_reg_get_power_string() - wlan reg get power type string
231  * @power_type: power type enum
232  *
233  * Return: power type string
234  */
235 const char *wlan_reg_get_power_string(enum reg_6g_ap_type power_type);
236 #endif
237 
238 /**
239  * wlan_reg_is_6ghz_psc_chan_freq() - Check if the given 6GHz channel frequency
240  * is preferred scanning channel frequency.
241  * @freq: Channel frequency
242  *
243  * Return: true if given 6GHz channel frequency is preferred scanning channel
244  * frequency, else false
245  */
246 bool wlan_reg_is_6ghz_psc_chan_freq(uint16_t freq);
247 #define WLAN_REG_IS_6GHZ_PSC_CHAN_FREQ(freq) \
248 	wlan_reg_is_6ghz_psc_chan_freq(freq)
249 
250 /**
251  * wlan_reg_min_6ghz_chan_freq() - Get minimum 6GHz channel center frequency
252  *
253  * Return: Minimum 6GHz channel center frequency
254  */
255 uint16_t wlan_reg_min_6ghz_chan_freq(void);
256 #define WLAN_REG_MIN_6GHZ_CHAN_FREQ wlan_reg_min_6ghz_chan_freq()
257 
258 /**
259  * wlan_reg_max_6ghz_chan_freq() - Get maximum 6GHz channel center frequency
260  *
261  * Return: Maximum 6GHz channel center frequency
262  */
263 uint16_t wlan_reg_max_6ghz_chan_freq(void);
264 #define WLAN_REG_MAX_6GHZ_CHAN_FREQ wlan_reg_max_6ghz_chan_freq()
265 
266 /**
267  * wlan_reg_is_6g_freq_indoor() - Check if a 6GHz frequency is indoor.
268  * @pdev: Pointer to pdev.
269  * @freq: Channel frequency.
270  *
271  * Return: Return true if a 6GHz frequency is indoor, else false.
272  */
273 bool wlan_reg_is_6g_freq_indoor(struct wlan_objmgr_pdev *pdev, qdf_freq_t freq);
274 #define WLAN_REG_IS_6GHZ_FREQ_INDOOR(pdev, freq) \
275 					wlan_reg_is_6g_freq_indoor(pdev, freq)
276 
277 /**
278  * wlan_reg_get_max_txpower_for_6g_tpe() - Get max txpower for 6G TPE IE.
279  * @pdev: Pointer to pdev.
280  * @freq: Channel frequency.
281  * @bw: Channel bandwidth.
282  * @reg_ap: Regulatory 6G AP type.
283  * @reg_client: Regulatory client type.
284  * @is_psd: True if txpower is needed in PSD format, and false if needed in EIRP
285  * format.
286  * @tx_power: Pointer to tx-power.
287  *
288  * Return: Return QDF_STATUS_SUCCESS, if tx_power is filled for 6G TPE IE
289  * else return QDF_STATUS_E_FAILURE.
290  */
291 QDF_STATUS
292 wlan_reg_get_max_txpower_for_6g_tpe(struct wlan_objmgr_pdev *pdev,
293 				    qdf_freq_t freq, uint8_t bw,
294 				    enum reg_6g_ap_type reg_ap,
295 				    enum reg_6g_client_type reg_client,
296 				    bool is_psd,
297 				    uint8_t *tx_power);
298 
299 /**
300  * wlan_reg_get_superchan_entry() - Get the address of the super channel list
301  * entry for a given input channel index.
302  *
303  * @pdev: pdev ptr
304  * @chan_enum: Channel enum
305  * @p_sup_chan_entry: Pointer to address of *p_sup_chan_entry
306  *
307  * Return: QDF_STATUS_SUCCESS if super channel entry is available for the input
308  * chan_enum else QDF_STATUS_E_FAILURE
309  */
310 QDF_STATUS wlan_reg_get_superchan_entry(
311 		struct wlan_objmgr_pdev *pdev,
312 		enum channel_enum chan_enum,
313 		const struct super_chan_info **p_sup_chan_entry);
314 /**
315  * wlan_reg_is_6ghz_unii5_chan_freq() - Check if the given 6GHz channel freq
316  * is UNII-5 band or not.
317  * @freq: Channel frequency
318  *
319  * Return: true if given 6GHz channel frequency is UNII-5 band, else false
320  */
321 bool wlan_reg_is_6ghz_unii5_chan_freq(qdf_freq_t freq);
322 #define WLAN_REG_IS_6GHZ_UNII5_CHAN_FREQ(freq) \
323 	wlan_reg_is_6ghz_unii5_chan_freq(freq)
324 #else
325 
326 #define WLAN_REG_IS_6GHZ_CHAN_FREQ(freq) (false)
327 static inline bool wlan_reg_is_6ghz_chan_freq(uint16_t freq)
328 {
329 	return false;
330 }
331 
332 static inline bool wlan_reg_is_range_only6g(qdf_freq_t low_freq,
333 					    qdf_freq_t high_freq)
334 {
335 	return false;
336 }
337 
338 #define WLAN_REG_IS_6GHZ_PSC_CHAN_FREQ(freq) (false)
339 static inline bool wlan_reg_is_6ghz_psc_chan_freq(uint16_t freq)
340 {
341 	return false;
342 }
343 
344 #define WLAN_REG_MIN_6GHZ_CHAN_FREQ (false)
345 static inline uint16_t wlan_reg_min_6ghz_chan_freq(void)
346 {
347 	return 0;
348 }
349 
350 #define WLAN_REG_MAX_6GHZ_CHAN_FREQ (false)
351 static inline uint16_t wlan_reg_max_6ghz_chan_freq(void)
352 {
353 	return 0;
354 }
355 
356 #define WLAN_REG_IS_6GHZ_FREQ_INDOOR(pdev, freq) (false)
357 static inline bool
358 wlan_reg_is_6g_freq_indoor(struct wlan_objmgr_pdev *pdev, qdf_freq_t freq)
359 {
360 	return false;
361 }
362 
363 static inline bool wlan_reg_is_range_overlap_6g(qdf_freq_t low_freq,
364 						qdf_freq_t high_freq)
365 {
366 	return false;
367 }
368 
369 static inline QDF_STATUS
370 wlan_reg_get_max_txpower_for_6g_tpe(struct wlan_objmgr_pdev *pdev,
371 				    qdf_freq_t freq, uint8_t bw,
372 				    enum reg_6g_ap_type reg_ap,
373 				    enum reg_6g_client_type reg_client,
374 				    bool is_psd,
375 				    uint8_t *tx_power)
376 {
377 	return QDF_STATUS_E_FAILURE;
378 }
379 
380 static inline QDF_STATUS
381 wlan_reg_get_6g_ap_master_chan_list(struct wlan_objmgr_pdev *pdev,
382 				    enum reg_6g_ap_type ap_pwr_type,
383 				    struct regulatory_channel *chan_list)
384 {
385 	return QDF_STATUS_E_FAILURE;
386 }
387 
388 static inline
389 QDF_STATUS wlan_reg_get_superchan_entry(
390 		struct wlan_objmgr_pdev *pdev,
391 		enum channel_enum chan_enum,
392 		const struct super_chan_info **p_sup_chan_entry)
393 {
394 	*p_sup_chan_entry = NULL;
395 	return QDF_STATUS_E_NOSUPPORT;
396 }
397 
398 static inline
399 const char *wlan_reg_get_power_string(enum reg_6g_ap_type power_type)
400 {
401 	return "INVALID";
402 }
403 
404 #define WLAN_REG_IS_6GHZ_UNII5_CHAN_FREQ(freq) (false)
405 static inline bool wlan_reg_is_6ghz_unii5_chan_freq(qdf_freq_t freq)
406 {
407 	return false;
408 }
409 #endif /* CONFIG_BAND_6GHZ */
410 
411 /**
412  * wlan_reg_get_band_channel_list() - Get channel list based on the band_mask
413  * @pdev: pdev ptr
414  * @band_mask: Input bitmap with band set
415  * @channel_list: Pointer to Channel List
416  *
417  * Get the given channel list and number of channels from the current channel
418  * list based on input band bitmap.
419  *
420  * Return: Number of channels, else 0 to indicate error
421  */
422 uint16_t
423 wlan_reg_get_band_channel_list(struct wlan_objmgr_pdev *pdev,
424 			       uint8_t band_mask,
425 			       struct regulatory_channel *channel_list);
426 
427 #ifdef CONFIG_REG_6G_PWRMODE
428 /**
429  * wlan_reg_get_band_channel_list_for_pwrmode() - Get channel list based on the
430  * band_mask and input 6G power mode.
431  * @pdev: pdev ptr
432  * @band_mask: Input bitmap with band set
433  * @channel_list: Pointer to Channel List
434  * @in_6g_pwr_type: 6g power type which decides 6G channel list lookup.
435  *
436  * Get the given channel list and number of channels from the current channel
437  * list based on input band bitmap.
438  *
439  * Return: Number of channels, else 0 to indicate error
440  */
441 uint16_t
442 wlan_reg_get_band_channel_list_for_pwrmode(struct wlan_objmgr_pdev *pdev,
443 					   uint8_t band_mask,
444 					   struct regulatory_channel
445 					   *channel_list,
446 					   enum supported_6g_pwr_types
447 					   in_6g_pwr_type);
448 #endif
449 
450 #ifdef CONFIG_REG_CLIENT
451 /**
452  * wlan_reg_get_secondary_band_channel_list() - Get secondary channel list for
453  * SAP based on the band_mask
454  * @pdev: pdev ptr
455  * @band_mask: Input bitmap with band set
456  * @channel_list: Pointer to Channel List
457  *
458  * Get the given channel list and number of channels from the secondary current
459  * channel list based on input band bitmap.
460  *
461  * Return: Number of channels, else 0 to indicate error
462  */
463 uint16_t
464 wlan_reg_get_secondary_band_channel_list(struct wlan_objmgr_pdev *pdev,
465 					 uint8_t band_mask,
466 					 struct regulatory_channel
467 					 *channel_list);
468 #endif
469 
470 /**
471  * wlan_reg_chan_band_to_freq - Return channel frequency based on the channel
472  * number and band.
473  * @pdev: pdev ptr
474  * @chan: Channel Number
475  * @band_mask: Bitmap for bands
476  *
477  * Return: Return channel frequency or return 0, if the channel is disabled or
478  * if the input channel number or band_mask is invalid. Composite bands are
479  * supported only for 2.4Ghz and 5Ghz bands. For other bands the following
480  * priority is given: 1) 6Ghz 2) 5Ghz 3) 2.4Ghz.
481  */
482 qdf_freq_t wlan_reg_chan_band_to_freq(struct wlan_objmgr_pdev *pdev,
483 				      uint8_t chan,
484 				      uint8_t band_mask);
485 
486 #ifdef CONFIG_49GHZ_CHAN
487 /**
488  * wlan_reg_is_49ghz_freq() - Check if the given channel frequency is 4.9GHz
489  * @freq: Channel frequency
490  *
491  * Return: true if channel frequency is 4.9GHz, else false
492  */
493 bool wlan_reg_is_49ghz_freq(qdf_freq_t freq);
494 
495 #else
496 
497 static inline bool wlan_reg_is_49ghz_freq(qdf_freq_t freq)
498 {
499 	return false;
500 }
501 #endif /* CONFIG_49GHZ_CHAN */
502 #define WLAN_REG_IS_49GHZ_FREQ(freq) wlan_reg_is_49ghz_freq(freq)
503 
504 /**
505  * wlan_reg_ch_num() - Get channel number from channel enum
506  * @ch_enum: Channel enum
507  *
508  * Return: channel number
509  */
510 uint8_t wlan_reg_ch_num(uint32_t ch_enum);
511 #define WLAN_REG_CH_NUM(ch_enum) wlan_reg_ch_num(ch_enum)
512 
513 /**
514  * wlan_reg_ch_to_freq() - Get channel frequency from channel enum
515  * @ch_enum: Channel enum
516  *
517  * Return: channel frequency
518  */
519 qdf_freq_t wlan_reg_ch_to_freq(uint32_t ch_enum);
520 #define WLAN_REG_CH_TO_FREQ(ch_enum) wlan_reg_ch_to_freq(ch_enum)
521 
522 /**
523  * wlan_reg_read_default_country() - Read the default country for the regdomain
524  * @psoc: Psoc object
525  * @country: pointer to the country code.
526  *
527  * Return: QDF_STATUS
528  */
529 QDF_STATUS wlan_reg_read_default_country(struct wlan_objmgr_psoc *psoc,
530 				   uint8_t *country);
531 
532 /**
533  * wlan_reg_get_max_5g_bw_from_country_code() - Get the max 5G
534  * bandwidth from country code
535  * @pdev: pdev pointer
536  * @cc: Country Code
537  * @max_bw_5g: Max 5G bandwidth supported by the country
538  *
539  * Return: QDF_STATUS
540  */
541 
542 QDF_STATUS wlan_reg_get_max_5g_bw_from_country_code(
543 					struct wlan_objmgr_pdev *pdev,
544 					uint16_t cc,
545 					uint16_t *max_bw_5g);
546 
547 /**
548  * wlan_reg_get_max_5g_bw_from_regdomain() - Get the max 5G bandwidth
549  * supported by the regdomain
550  * @pdev: pdev pointer
551  * @regdmn: Regdomain Pair value
552  * @max_bw_5g: Max 5G bandwidth supported by the country
553  *
554  * Return: QDF_STATUS
555  */
556 QDF_STATUS wlan_reg_get_max_5g_bw_from_regdomain(
557 					struct wlan_objmgr_pdev *pdev,
558 					uint16_t regdmn,
559 					uint16_t *max_bw_5g);
560 
561 /**
562  * wlan_reg_get_max_bw_5G_for_fo() - get max_5g_bw for FullOffload
563  * @pdev: PDEV object
564  *
565  * API to get max_bw_5g from pdev object
566  *
567  * Return: @max_bw_5g
568  */
569 QDF_STATUS wlan_reg_get_max_bw_5G_for_fo(struct wlan_objmgr_pdev *pdev);
570 
571 /**
572  * wlan_reg_is_regdb_offloaded() - get offload_enabled
573  * @psoc: Psoc object
574  *
575  * API to get offload_enabled from psoc.
576  *
577  * Return: true if offload enabled
578  */
579 
580 bool wlan_reg_is_regdb_offloaded(struct wlan_objmgr_psoc *psoc);
581 
582 /**
583  * wlan_reg_get_fcc_constraint() - Check FCC constraint on given frequency
584  * @pdev: physical dev to get
585  * @freq: frequency to be checked
586  *
587  * Return: If FCC constraint is on applied given frequency return true
588  *	   else return false.
589  */
590 bool wlan_reg_get_fcc_constraint(struct wlan_objmgr_pdev *pdev, uint32_t freq);
591 
592 /**
593  * wlan_reg_is_6ghz_band_set - Check if 6 GHz band set
594  * @pdev: Pointer to pdev
595  *
596  * Return: True if 6 GHz band set else return flase
597  */
598 bool wlan_reg_is_6ghz_band_set(struct wlan_objmgr_pdev *pdev);
599 
600 /**
601  * wlan_reg_get_keep_6ghz_sta_cli_connection() - Get keep 6ghz sta cli
602  *                                               connection flag
603  * @pdev: Pointer to pdev
604  *
605  * Return: Return true if keep 6ghz sta cli connection set else return false
606  */
607 bool wlan_reg_get_keep_6ghz_sta_cli_connection(struct wlan_objmgr_pdev *pdev);
608 #ifdef CONFIG_REG_CLIENT
609 /**
610  * wlan_reg_read_current_country() - Read the current country for the regdomain
611  * @psoc: pointer to psoc
612  * @country: pointer to the country code.
613  *
614  * Return: QDF_STATUS
615  */
616 QDF_STATUS wlan_reg_read_current_country(struct wlan_objmgr_psoc *psoc,
617 					 uint8_t *country);
618 
619 #ifdef CONFIG_REG_CLIENT
620 /**
621  * wlan_reg_get_best_6g_power_type() - Return best power type for 6GHz
622  * connection
623  * @psoc: pointer to psoc
624  * @pdev: pointer to pdev
625  * @pwr_type_6g: pointer to 6G power type
626  * @ap_pwr_type: AP's power type for 6G as advertised in HE ops IE
627  * @chan_freq: Connection channel frequency
628  *
629  * Return: QDF_STATUS
630  */
631 QDF_STATUS
632 wlan_reg_get_best_6g_power_type(struct wlan_objmgr_psoc *psoc,
633 				struct wlan_objmgr_pdev *pdev,
634 				enum reg_6g_ap_type *pwr_type_6g,
635 				enum reg_6g_ap_type ap_pwr_type,
636 				uint32_t chan_freq);
637 #endif
638 
639 #ifdef CONFIG_CHAN_FREQ_API
640 /**
641  * wlan_reg_is_etsi13_srd_chan_for_freq() - Checks if the ch is ETSI13 srd ch
642  * or not
643  * @pdev: pdev ptr
644  * @freq: channel center frequency
645  *
646  * Return: true or false
647  */
648 bool wlan_reg_is_etsi13_srd_chan_for_freq(struct wlan_objmgr_pdev *pdev,
649 					  qdf_freq_t freq);
650 #endif /*CONFIG_CHAN_FREQ_API*/
651 
652 /**
653  * wlan_reg_is_etsi13_regdmn() - Checks if current reg domain is ETSI13 or not
654  * @pdev: pdev ptr
655  *
656  * Return: true or false
657  */
658 bool wlan_reg_is_etsi13_regdmn(struct wlan_objmgr_pdev *pdev);
659 
660 /**
661  * wlan_reg_is_etsi13_srd_chan_allowed_master_mode() - Checks if regdmn is
662  * ETSI13 and SRD channels are allowed in master mode or not.
663  *
664  * @pdev: pdev ptr
665  *
666  * Return: true or false
667  */
668 bool wlan_reg_is_etsi13_srd_chan_allowed_master_mode(struct wlan_objmgr_pdev
669 						     *pdev);
670 #endif
671 
672 /**
673  * wlan_reg_is_world() - reg is world mode
674  * @country: The country information
675  *
676  * Return: true or false
677  */
678 bool wlan_reg_is_world(uint8_t *country);
679 
680 /**
681  * wlan_reg_get_dfs_region() - Get the current dfs region
682  * @pdev: pdev pointer
683  * @dfs_reg: pointer to dfs region
684  *
685  * Return: Status
686  */
687 QDF_STATUS wlan_reg_get_dfs_region(struct wlan_objmgr_pdev *pdev,
688 			     enum dfs_reg *dfs_reg);
689 
690 /**
691  * wlan_reg_is_chan_disabled_and_not_nol() - In the regulatory channel list, a
692  * channel may be disabled by the regulatory/device or by radar. Radar is
693  * temporary and a radar disabled channel does not mean that the channel is
694  * permanently disabled. The API checks if the channel is disabled, but not due
695  * to radar.
696  * @chan: Regulatory channel object
697  *
698  * Return: True,  the channel is disabled, but not due to radar, else false.
699  */
700 bool wlan_reg_is_chan_disabled_and_not_nol(struct regulatory_channel *chan);
701 
702 /**
703  * wlan_reg_get_current_chan_list() - provide the pdev current channel list
704  * @pdev: pdev pointer
705  * @chan_list: channel list pointer
706  *
707  * Return: QDF_STATUS
708  */
709 QDF_STATUS wlan_reg_get_current_chan_list(struct wlan_objmgr_pdev *pdev,
710 		struct regulatory_channel *chan_list);
711 
712 /**
713  * wlan_reg_is_freq_enabled() - Checks if the given frequency is enabled on the
714  * given power mode or not. If the frequency is not a 6G frequency then the
715  * input power mode is ignored and only current channel list is searched.
716  *
717  * @pdev: pdev pointer.
718  * @freq: input frequency.
719  * @in_6g_pwr_mode: Power mode on which the freq is enabled or not is to be
720  * checked.
721  *
722  * Return: True if the frequency is present in the given power mode channel
723  * list.
724  */
725 bool wlan_reg_is_freq_enabled(struct wlan_objmgr_pdev *pdev,
726 			      qdf_freq_t freq,
727 			      enum supported_6g_pwr_types in_6g_pwr_mode);
728 
729 /**
730  * wlan_reg_is_freq_idx_enabled() - Checks if the given frequency index is
731  * enabled on the given power mode or not. If the frequency index is not a 6G
732  * frequency then the input power mode is ignored and only current channel list
733  * is searched.
734  *
735  * @pdev: pdev pointer.
736  * @freq_idx: input frequency index.
737  * @in_6g_pwr_mode: Power mode on which the frequency index is enabled or not
738  * is to be checked.
739  *
740  * Return: True if the frequency index is present in the given power mode
741  * channel list.
742  */
743 bool wlan_reg_is_freq_idx_enabled(struct wlan_objmgr_pdev *pdev,
744 				  enum channel_enum freq_idx,
745 				  enum supported_6g_pwr_types in_6g_pwr_mode);
746 
747 /**
748  * wlan_reg_get_pwrmode_chan_list() - Get the modified channel list. A modified
749  * current channel list consists of 2G and 5G portions of the current channel
750  * list and the 6G portion of the current channel list is derived from the input
751  * 6g power type.
752  * @pdev: Pointer to pdev
753  * @chan_list: Pointer to buffer which stores list of regulatory_channels.
754  * @in_6g_pwr_mode: 6GHz power type
755  *
756  * Return:
757  * QDF_STATUS_SUCCESS: Success
758  * QDF_STATUS_E_INVAL: Failed to get channel list
759  */
760 QDF_STATUS wlan_reg_get_pwrmode_chan_list(struct wlan_objmgr_pdev *pdev,
761 					  struct regulatory_channel *chan_list,
762 					  enum supported_6g_pwr_types
763 					  in_6g_pwr_mode);
764 
765 #ifdef CONFIG_REG_CLIENT
766 /**
767  * wlan_reg_get_secondary_current_chan_list() - provide the pdev secondary
768  * current channel list
769  * @pdev: pdev pointer
770  * @chan_list: channel list pointer
771  *
772  * Return: QDF_STATUS
773  */
774 QDF_STATUS wlan_reg_get_secondary_current_chan_list(
775 					struct wlan_objmgr_pdev *pdev,
776 					struct regulatory_channel *chan_list);
777 #endif
778 
779 #if defined(CONFIG_AFC_SUPPORT) && defined(CONFIG_BAND_6GHZ)
780 /**
781  * wlan_reg_get_6g_afc_chan_list() - provide the pdev afc channel list
782  * @pdev: pdev pointer
783  * @chan_list: channel list pointer
784  *
785  * Return: QDF_STATUS
786  */
787 QDF_STATUS wlan_reg_get_6g_afc_chan_list(struct wlan_objmgr_pdev *pdev,
788 					 struct regulatory_channel *chan_list);
789 
790 /**
791  * wlan_reg_get_6g_afc_mas_chan_list() - provide the pdev afc master channel
792  * list
793  * @pdev: pdev pointer
794  * @chan_list: channel list pointer
795  *
796  * Return: QDF_STATUS
797  */
798 QDF_STATUS
799 wlan_reg_get_6g_afc_mas_chan_list(struct wlan_objmgr_pdev *pdev,
800 				  struct regulatory_channel *chan_list);
801 
802 /**
803  * wlan_reg_is_afc_power_event_received() - Checks if AFC power event is
804  * received from the FW.
805  *
806  * @pdev: pdev ptr
807  *
808  * Return: true if AFC power event is received from the FW or false otherwise
809  */
810 bool wlan_reg_is_afc_power_event_received(struct wlan_objmgr_pdev *pdev);
811 
812 /**
813  * wlan_reg_is_afc_done() - Check if AFC response enables the given frequency.
814  * @pdev: pdev ptr
815  * @freq: given frequency.
816  *
817  * Return: True if frequency is enabled, false otherwise.
818  */
819 bool wlan_reg_is_afc_done(struct wlan_objmgr_pdev *pdev, qdf_freq_t freq);
820 
821 /**
822  * wlan_reg_get_afc_req_id() - Get the AFC request ID
823  * @pdev: pdev pointer
824  * @req_id: Pointer to request id
825  *
826  * Return: QDF_STATUS
827  */
828 QDF_STATUS wlan_reg_get_afc_req_id(struct wlan_objmgr_pdev *pdev,
829 				   uint64_t *req_id);
830 
831 /**
832  * wlan_reg_is_afc_expiry_event_received() - Checks if AFC power event is
833  * received from the FW.
834  *
835  * @pdev: pdev ptr
836  *
837  * Return: true if AFC exipry event is received from the FW or false otherwise
838  */
839 bool wlan_reg_is_afc_expiry_event_received(struct wlan_objmgr_pdev *pdev);
840 
841 /**
842  * wlan_reg_is_noaction_on_afc_pwr_evt() - Checks whether driver needs to
843  * take action for AFC action or the response should be handled by the
844  * user application.
845  *
846  * @pdev: pdev ptr
847  *
848  * Return: true if driver need not take action for AFC resp, false otherwise.
849  */
850 bool
851 wlan_reg_is_noaction_on_afc_pwr_evt(struct wlan_objmgr_pdev *pdev);
852 
853 /**
854  * wlan_reg_get_afc_dev_deploy_type() - Get AFC device deployment type
855  * @pdev: pdev pointer
856  * @afc_dev_type: Pointer to afc device deployment type
857  *
858  * Return: QDF_STATUS
859  */
860 QDF_STATUS
861 wlan_reg_get_afc_dev_deploy_type(struct wlan_objmgr_pdev *pdev,
862 				 enum reg_afc_dev_deploy_type *afc_dev_type);
863 
864 /**
865  * wlan_reg_is_sta_connect_allowed() - Check if STA connection allowed
866  * @pdev: pdev pointer
867  * @root_ap_pwr_mode: power mode of the Root AP.
868  *
869  * Return : True if STA Vap connection is allowed.
870  */
871 bool
872 wlan_reg_is_sta_connect_allowed(struct wlan_objmgr_pdev *pdev,
873 				enum reg_6g_ap_type root_ap_pwr_mode);
874 
875 /**
876  * wlan_reg_is_6ghz_freq_txable() - Check if the given frequency is tx-able.
877  * @pdev: Pointer to pdev
878  * @freq: Frequency in MHz
879  * @in_6ghz_pwr_mode: Input AP power type
880  *
881  * An SP channel is tx-able if the channel is present in the AFC response.
882  * In case of non-OUTDOOR mode a channel is always tx-able (Assuming it is
883  * enabled by regulatory).
884  *
885  * Return: True if the frequency is tx-able, else false.
886  */
887 bool
888 wlan_reg_is_6ghz_freq_txable(struct wlan_objmgr_pdev *pdev,
889 			     qdf_freq_t freq,
890 			     enum supported_6g_pwr_types in_6ghz_pwr_mode);
891 #else
892 static inline bool
893 wlan_reg_is_afc_power_event_received(struct wlan_objmgr_pdev *pdev)
894 {
895 	return false;
896 }
897 
898 static inline bool
899 wlan_reg_is_afc_done(struct wlan_objmgr_pdev *pdev, qdf_freq_t freq)
900 {
901 	return true;
902 }
903 
904 static inline QDF_STATUS
905 wlan_reg_get_6g_afc_chan_list(struct wlan_objmgr_pdev *pdev,
906 			      struct regulatory_channel *chan_list)
907 {
908 	return QDF_STATUS_E_NOSUPPORT;
909 }
910 
911 static inline bool
912 wlan_reg_is_sta_connect_allowed(struct wlan_objmgr_pdev *pdev,
913 				enum reg_6g_ap_type root_ap_pwr_mode)
914 {
915 	return true;
916 }
917 
918 static inline bool
919 wlan_reg_is_6ghz_freq_txable(struct wlan_objmgr_pdev *pdev,
920 			     qdf_freq_t freq,
921 			     enum supported_6g_pwr_types in_6ghz_pwr_mode)
922 {
923 	return false;
924 }
925 #endif
926 
927 #if defined(WLAN_FEATURE_11BE) && defined(CONFIG_REG_CLIENT)
928 /**
929  * wlan_reg_get_bonded_channel_state_for_pwrmode() - Get bonded channel freq
930  * state
931  * @pdev: pdev ptr
932  * @freq: channel frequency
933  * @bw: channel band width
934  * @sec_freq: secondary frequency
935  * @in_6g_pwr_mode: 6g power type which decides 6G channel list lookup.
936  *
937  * Return: channel state
938  */
939 enum channel_state
940 wlan_reg_get_bonded_channel_state_for_pwrmode(struct wlan_objmgr_pdev *pdev,
941 					      qdf_freq_t freq,
942 					      enum phy_ch_width bw,
943 					      qdf_freq_t sec_freq,
944 					      enum supported_6g_pwr_types
945 					      in_6g_pwr_mode);
946 #else
947 static inline enum channel_state
948 wlan_reg_get_bonded_channel_state_for_pwrmode(struct wlan_objmgr_pdev *pdev,
949 					      qdf_freq_t freq,
950 					      enum phy_ch_width bw,
951 					      qdf_freq_t sec_freq,
952 					      enum supported_6g_pwr_types
953 					      in_6g_pwr_mode)
954 {
955 	return CHANNEL_STATE_INVALID;
956 }
957 #endif
958 
959 /**
960  * wlan_reg_set_dfs_region() - set the dfs region
961  * @pdev: pdev ptr
962  * @dfs_reg: dfs region
963  *
964  * Return: void
965  */
966 void wlan_reg_set_dfs_region(struct wlan_objmgr_pdev *pdev,
967 			     enum dfs_reg dfs_reg);
968 
969 /**
970  * wlan_reg_get_bw_value() - get bandwidth value from enum
971  * @bw: channel width enum
972  *
973  * Return: channel width in MHz
974  */
975 uint16_t wlan_reg_get_bw_value(enum phy_ch_width bw);
976 
977 /**
978  * wlan_reg_get_domain_from_country_code() - provide the channel center freq
979  * @reg_domain_ptr: regulatory domain ptr
980  * @country_alpha2: country alpha2
981  * @source: alpha2 source
982  *
983  * Return: int
984  */
985 QDF_STATUS wlan_reg_get_domain_from_country_code(v_REGDOMAIN_t *reg_domain_ptr,
986 						 const uint8_t *country_alpha2,
987 						 enum country_src source);
988 
989 /**
990  * wlan_reg_dmn_get_opclass_from_channel() - provide the channel center freq
991  * @country: country alpha2
992  * @channel: channel number
993  * @offset: offset
994  *
995  * Return: int
996  */
997 uint16_t wlan_reg_dmn_get_opclass_from_channel(uint8_t *country,
998 					       uint8_t channel,
999 					       uint8_t offset);
1000 
1001 /**
1002  * wlan_reg_get_opclass_from_freq_width() - Get operating class from frequency
1003  * @country: Country code.
1004  * @freq: Channel center frequency.
1005  * @ch_width: Channel width.
1006  * @behav_limit: Behaviour limit.
1007  *
1008  * Return: Error code.
1009  */
1010 uint8_t wlan_reg_get_opclass_from_freq_width(uint8_t *country,
1011 					     qdf_freq_t freq,
1012 					     uint16_t ch_width,
1013 					     uint16_t behav_limit);
1014 
1015 /**
1016  * wlan_reg_get_band_cap_from_op_class() - Return band capability bitmap
1017  * @country: Pointer to Country code.
1018  * @num_of_opclass: Number of Operating class.
1019  * @opclass: Pointer to opclass.
1020  *
1021  * Return supported band bitmap based on the input operating class list
1022  * provided.
1023  *
1024  * Return: Return supported band capability
1025  */
1026 uint8_t wlan_reg_get_band_cap_from_op_class(const uint8_t *country,
1027 					    uint8_t num_of_opclass,
1028 					    const uint8_t *opclass);
1029 
1030 /**
1031  * wlan_reg_dmn_print_channels_in_opclass() - Print channels in op-class
1032  * @country: country alpha2
1033  * @opclass: oplcass
1034  *
1035  * Return: void
1036  */
1037 void wlan_reg_dmn_print_channels_in_opclass(uint8_t *country,
1038 					    uint8_t opclass);
1039 
1040 
1041 /**
1042  * wlan_reg_dmn_get_chanwidth_from_opclass() - get channel width from
1043  *                                             operating class
1044  * @country: country alpha2
1045  * @channel: channel number
1046  * @opclass: operating class
1047  *
1048  * Return: int
1049  */
1050 uint16_t wlan_reg_dmn_get_chanwidth_from_opclass(uint8_t *country,
1051 						 uint8_t channel,
1052 						 uint8_t opclass);
1053 
1054 /**
1055  * wlan_reg_dmn_get_chanwidth_from_opclass_auto() - get channel width from
1056  * operating class. If opclass not found then search in global opclass.
1057  * @country: country alpha2
1058  * @channel: channel number
1059  * @opclass: operating class
1060  *
1061  * Return: int
1062  */
1063 uint16_t wlan_reg_dmn_get_chanwidth_from_opclass_auto(uint8_t *country,
1064 						      uint8_t channel,
1065 						      uint8_t opclass);
1066 
1067 /**
1068  * wlan_reg_dmn_set_curr_opclasses() - set operating class
1069  * @num_classes: number of classes
1070  * @class: operating class
1071  *
1072  * Return: int
1073  */
1074 uint16_t wlan_reg_dmn_set_curr_opclasses(uint8_t num_classes,
1075 					 uint8_t *class);
1076 
1077 /**
1078  * wlan_reg_dmn_get_curr_opclasses() - get current oper classes
1079  * @num_classes: number of classes
1080  * @class: operating class
1081  *
1082  * Return: int
1083  */
1084 uint16_t wlan_reg_dmn_get_curr_opclasses(uint8_t *num_classes,
1085 					 uint8_t *class);
1086 
1087 
1088 /**
1089  * wlan_reg_get_opclass_details() - Get details about the current opclass table.
1090  * @pdev: Pointer to pdev.
1091  * @reg_ap_cap: Pointer to reg_ap_cap.
1092  * @n_opclasses: Pointer to number of opclasses.
1093  * @max_supp_op_class: Maximum number of operating classes supported.
1094  * @global_tbl_lookup: Whether to lookup global op class tbl.
1095  * @in_6g_pwr_mode: 6g power type which decides 6G channel list lookup.
1096  *
1097  * Return: QDF_STATUS_SUCCESS if success, else return QDF_STATUS_FAILURE.
1098  */
1099 QDF_STATUS
1100 wlan_reg_get_opclass_details(struct wlan_objmgr_pdev *pdev,
1101 			     struct regdmn_ap_cap_opclass_t *reg_ap_cap,
1102 			     uint8_t *n_opclasses,
1103 			     uint8_t max_supp_op_class,
1104 			     bool global_tbl_lookup,
1105 			     enum supported_6g_pwr_types in_6g_pwr_mode);
1106 
1107 /**
1108  * wlan_reg_get_opclass_for_cur_hwmode() - Get details about the
1109  * opclass table for the current hwmode.
1110  * @pdev: Pointer to pdev.
1111  * @reg_ap_cap: Pointer to reg_ap_cap.
1112  * @n_opclasses: Pointer to number of opclasses.
1113  * @max_supp_op_class: Maximum number of operating classes supported.
1114  * @global_tbl_lookup: Whether to lookup global op class tbl.
1115  * @max_chwidth: Maximum channel width supported by cur hwmode
1116  * @is_80p80_supp: Bool to indicate if 80p80 is supported.
1117  * @in_6g_pwr_mode: 6g power type which decides 6G channel list lookup.
1118  *
1119  * Return: QDF_STATUS_SUCCESS if success, else return QDF_STATUS_FAILURE.
1120  */
1121 QDF_STATUS
1122 wlan_reg_get_opclass_for_cur_hwmode(struct wlan_objmgr_pdev *pdev,
1123 				    struct regdmn_ap_cap_opclass_t *reg_ap_cap,
1124 				    uint8_t *n_opclasses,
1125 				    uint8_t max_supp_op_class,
1126 				    bool global_tbl_lookup,
1127 				    enum phy_ch_width max_chwidth,
1128 				    bool is_80p80_supp,
1129 				    enum supported_6g_pwr_types in_6g_pwr_mode);
1130 
1131 /**
1132  * wlan_reg_get_cc_and_src() - get country code and src
1133  * @psoc: psoc ptr
1134  * @alpha: country code alpha2
1135  *
1136  * Return: country_src
1137  */
1138 enum country_src wlan_reg_get_cc_and_src(struct wlan_objmgr_psoc *psoc,
1139 					 uint8_t *alpha);
1140 
1141 /**
1142  * wlan_regulatory_init() - init regulatory component
1143  *
1144  * Return: Success or Failure
1145  */
1146 QDF_STATUS wlan_regulatory_init(void);
1147 
1148 /**
1149  * wlan_regulatory_deinit() - deinit regulatory component
1150  *
1151  * Return: Success or Failure
1152  */
1153 QDF_STATUS wlan_regulatory_deinit(void);
1154 
1155 /**
1156  * regulatory_psoc_open() - open regulatory component
1157  * @psoc: Pointer to psoc structure
1158  *
1159  * Return: Success or Failure
1160  */
1161 QDF_STATUS regulatory_psoc_open(struct wlan_objmgr_psoc *psoc);
1162 
1163 
1164 /**
1165  * regulatory_psoc_close() - close regulatory component
1166  * @psoc: Pointer to psoc structure
1167  *
1168  * Return: Success or Failure
1169  */
1170 QDF_STATUS regulatory_psoc_close(struct wlan_objmgr_psoc *psoc);
1171 
1172 /**
1173  * regulatory_pdev_open() - Open regulatory component
1174  * @pdev: Pointer to pdev structure
1175  *
1176  * Return: Success or Failure
1177  */
1178 QDF_STATUS regulatory_pdev_open(struct wlan_objmgr_pdev *pdev);
1179 
1180 /**
1181  * regulatory_pdev_close() - Close regulatory component
1182  * @pdev: Pointer to pdev structure.
1183  *
1184  * Return: Success or Failure
1185  */
1186 QDF_STATUS regulatory_pdev_close(struct wlan_objmgr_pdev *pdev);
1187 
1188 /**
1189  * wlan_reg_freq_to_chan() - convert channel freq to channel number
1190  * @pdev: The physical dev to set current country for
1191  * @freq: frequency
1192  *
1193  * Return: true or false
1194  */
1195 uint8_t wlan_reg_freq_to_chan(struct wlan_objmgr_pdev *pdev,
1196 			      qdf_freq_t freq);
1197 
1198 /**
1199  * wlan_reg_legacy_chan_to_freq() - convert chan to freq, for 2G and 5G
1200  * @pdev: pdev pointer
1201  * @chan: channel number
1202  *
1203  * Return: frequency
1204  */
1205 qdf_freq_t wlan_reg_legacy_chan_to_freq(struct wlan_objmgr_pdev *pdev,
1206 					uint8_t chan);
1207 
1208 /**
1209  * wlan_reg_is_us() - reg is us country
1210  * @country: The country information
1211  *
1212  * Return: true or false
1213  */
1214 bool wlan_reg_is_us(uint8_t *country);
1215 
1216 /**
1217  * wlan_reg_is_etsi() - reg is a country in EU
1218  * @country: The country information
1219  *
1220  * Return: true or false
1221  */
1222 bool wlan_reg_is_etsi(uint8_t *country);
1223 
1224 
1225 /**
1226  * wlan_reg_ctry_support_vlp() - Country supports VLP or not
1227  * @country: The country information
1228  *
1229  * Return: true or false
1230  */
1231 bool wlan_reg_ctry_support_vlp(uint8_t *country);
1232 
1233 /**
1234  * wlan_reg_set_country() - Set the current regulatory country
1235  * @pdev: The physical dev to set current country for
1236  * @country: The country information to configure
1237  *
1238  * Return: QDF_STATUS
1239  */
1240 QDF_STATUS wlan_reg_set_country(struct wlan_objmgr_pdev *pdev,
1241 				uint8_t *country);
1242 
1243 /**
1244  * wlan_reg_set_11d_country() - Set the 11d regulatory country
1245  * @pdev: The physical dev to set current country for
1246  * @country: The country information to configure
1247  *
1248  * Return: QDF_STATUS
1249  */
1250 QDF_STATUS wlan_reg_set_11d_country(struct wlan_objmgr_pdev *pdev,
1251 				    uint8_t *country);
1252 
1253 /**
1254  * wlan_reg_register_chan_change_callback() - add chan change cbk
1255  * @psoc: psoc ptr
1256  * @cbk: callback
1257  * @arg: argument
1258  *
1259  * Return: true or false
1260  */
1261 void wlan_reg_register_chan_change_callback(struct wlan_objmgr_psoc *psoc,
1262 					    void *cbk, void *arg);
1263 
1264 /**
1265  * wlan_reg_unregister_chan_change_callback() - remove chan change cbk
1266  * @psoc: psoc ptr
1267  * @cbk:callback
1268  *
1269  * Return: true or false
1270  */
1271 void wlan_reg_unregister_chan_change_callback(struct wlan_objmgr_psoc *psoc,
1272 					      void *cbk);
1273 
1274 /**
1275  * wlan_reg_register_ctry_change_callback() - add country change cbk
1276  * @psoc: psoc ptr
1277  * @cbk: callback
1278  *
1279  * Return: None
1280  */
1281 void wlan_reg_register_ctry_change_callback(struct wlan_objmgr_psoc *psoc,
1282 					    void *cbk);
1283 
1284 /**
1285  * wlan_reg_unregister_ctry_change_callback() - remove country change cbk
1286  * @psoc: psoc ptr
1287  * @cbk:callback
1288  *
1289  * Return: None
1290  */
1291 void wlan_reg_unregister_ctry_change_callback(struct wlan_objmgr_psoc *psoc,
1292 					      void *cbk);
1293 
1294 /**
1295  * wlan_reg_is_11d_offloaded() - 11d offloaded supported
1296  * @psoc: psoc ptr
1297  *
1298  * Return: bool
1299  */
1300 bool wlan_reg_is_11d_offloaded(struct wlan_objmgr_psoc *psoc);
1301 
1302 /**
1303  * wlan_reg_11d_enabled_on_host() - 11d enabled don host
1304  * @psoc: psoc ptr
1305  *
1306  * Return: bool
1307  */
1308 bool wlan_reg_11d_enabled_on_host(struct wlan_objmgr_psoc *psoc);
1309 
1310 /**
1311  * wlan_reg_get_chip_mode() - get supported chip mode
1312  * @pdev: pdev pointer
1313  * @chip_mode: chip mode
1314  *
1315  * Return: QDF STATUS
1316  */
1317 QDF_STATUS wlan_reg_get_chip_mode(struct wlan_objmgr_pdev *pdev,
1318 		uint64_t *chip_mode);
1319 
1320 /**
1321  * wlan_reg_is_11d_scan_inprogress() - checks 11d scan status
1322  * @psoc: psoc ptr
1323  *
1324  * Return: bool
1325  */
1326 bool wlan_reg_is_11d_scan_inprogress(struct wlan_objmgr_psoc *psoc);
1327 /**
1328  * wlan_reg_get_freq_range() - Get 2GHz and 5GHz frequency range
1329  * @pdev: pdev pointer
1330  * @low_2g: low 2GHz frequency range
1331  * @high_2g: high 2GHz frequency range
1332  * @low_5g: low 5GHz frequency range
1333  * @high_5g: high 5GHz frequency range
1334  *
1335  * Return: QDF status
1336  */
1337 QDF_STATUS wlan_reg_get_freq_range(struct wlan_objmgr_pdev *pdev,
1338 		qdf_freq_t *low_2g,
1339 		qdf_freq_t *high_2g,
1340 		qdf_freq_t *low_5g,
1341 		qdf_freq_t *high_5g);
1342 /**
1343  * wlan_reg_get_tx_ops() - get regulatory tx ops
1344  * @psoc: psoc ptr
1345  *
1346  */
1347 struct wlan_lmac_if_reg_tx_ops *
1348 wlan_reg_get_tx_ops(struct wlan_objmgr_psoc *psoc);
1349 
1350 /**
1351  * wlan_reg_get_curr_regdomain() - Get current regdomain in use
1352  * @pdev: pdev pointer
1353  * @cur_regdmn: Current regdomain info
1354  *
1355  * Return: QDF status
1356  */
1357 QDF_STATUS wlan_reg_get_curr_regdomain(struct wlan_objmgr_pdev *pdev,
1358 		struct cur_regdmn_info *cur_regdmn);
1359 
1360 #ifdef WLAN_REG_PARTIAL_OFFLOAD
1361 /**
1362  * wlan_reg_is_regdmn_en302502_applicable() - Find if ETSI EN302_502 radar
1363  * pattern is applicable in the current regulatory domain.
1364  * @pdev:    Pdev ptr.
1365  *
1366  * Return: Boolean.
1367  * True:  If EN302_502 is applicable.
1368  * False: otherwise.
1369  */
1370 bool wlan_reg_is_regdmn_en302502_applicable(struct wlan_objmgr_pdev *pdev);
1371 #endif
1372 
1373 /**
1374  * wlan_reg_modify_pdev_chan_range() - Compute current channel list for the
1375  * modified channel range in the regcap.
1376  * @pdev: pointer to wlan_objmgr_pdev.
1377  *
1378  * Return : QDF_STATUS
1379  */
1380 QDF_STATUS wlan_reg_modify_pdev_chan_range(struct wlan_objmgr_pdev *pdev);
1381 
1382 /**
1383  * wlan_reg_get_phybitmap() - Get phybitmap from regulatory pdev_priv_obj
1384  * @pdev: pdev pointer
1385  * @phybitmap: pointer to phybitmap
1386  *
1387  * Return: QDF STATUS
1388  */
1389 QDF_STATUS wlan_reg_get_phybitmap(struct wlan_objmgr_pdev *pdev,
1390 				  uint16_t *phybitmap);
1391 
1392 /**
1393  * wlan_reg_update_pdev_wireless_modes() - Update the wireless_modes in the
1394  * pdev_priv_obj with the input wireless_modes
1395  * @pdev: pointer to wlan_objmgr_pdev.
1396  * @wireless_modes: Wireless modes.
1397  *
1398  * Return : QDF_STATUS
1399  */
1400 QDF_STATUS wlan_reg_update_pdev_wireless_modes(struct wlan_objmgr_pdev *pdev,
1401 					       uint64_t wireless_modes);
1402 /**
1403  * wlan_reg_disable_chan_coex() - Disable Coexisting channels based on the input
1404  * bitmask
1405  * @pdev: pointer to wlan_objmgr_pdev.
1406  * @unii_5g_bitmap: UNII 5G bitmap.
1407  *
1408  * Return : QDF_STATUS
1409  */
1410 #ifdef DISABLE_UNII_SHARED_BANDS
1411 QDF_STATUS wlan_reg_disable_chan_coex(struct wlan_objmgr_pdev *pdev,
1412 				      uint8_t unii_5g_bitmap);
1413 #else
1414 static inline QDF_STATUS
1415 wlan_reg_disable_chan_coex(struct wlan_objmgr_pdev *pdev,
1416 			   uint8_t unii_5g_bitmap)
1417 {
1418 	return QDF_STATUS_SUCCESS;
1419 }
1420 #endif
1421 
1422 #ifdef WLAN_FEATURE_GET_USABLE_CHAN_LIST
1423 /**
1424  * wlan_reg_get_usable_channel() - Get usable channels
1425  * @pdev: Pointer to pdev
1426  * @req_msg: Request msg
1427  * @res_msg: Response msg
1428  * @count: no of usable channels
1429  * @in_6g_pwr_mode: Input 6GHz power mode
1430  *
1431  * Return: qdf status
1432  */
1433 QDF_STATUS
1434 wlan_reg_get_usable_channel(struct wlan_objmgr_pdev *pdev,
1435 			    struct get_usable_chan_req_params req_msg,
1436 			    struct get_usable_chan_res_params *res_msg,
1437 			    uint32_t *count,
1438 			    enum supported_6g_pwr_types in_6g_pwr_mode);
1439 #endif
1440 
1441 #ifdef CONFIG_CHAN_FREQ_API
1442 /**
1443  * wlan_reg_is_same_band_freqs() - Check if two channel frequencies
1444  * have same band
1445  * @freq1: Frequency 1
1446  * @freq2: Frequency 2
1447  *
1448  * Return: true if both the channel frequency has the same band.
1449  */
1450 bool wlan_reg_is_same_band_freqs(qdf_freq_t freq1, qdf_freq_t freq2);
1451 
1452 #define WLAN_REG_IS_SAME_BAND_FREQS(freq1, freq2) \
1453 	wlan_reg_is_same_band_freqs(freq1, freq2)
1454 
1455 /**
1456  * wlan_reg_get_chan_enum_for_freq() - Get channel enum for given channel center
1457  * frequency
1458  * @freq: Channel center frequency
1459  *
1460  * Return: Channel enum
1461  */
1462 enum channel_enum wlan_reg_get_chan_enum_for_freq(qdf_freq_t freq);
1463 
1464 /**
1465  * wlan_reg_get_min_max_bw_for_chan_index() - To get min and max BW supported
1466  * by channel enum
1467  * @pdev: pointer to pdev
1468  * @chan_idx: enum channel_enum
1469  * @min_bw: min bw
1470  * @max_bw: max bw
1471  *
1472  * Return: SUCCESS/FAILURE
1473  */
1474 QDF_STATUS
1475 wlan_reg_get_min_max_bw_for_chan_index(struct wlan_objmgr_pdev *pdev,
1476 				       enum channel_enum chan_idx,
1477 				       uint16_t *min_bw, uint16_t *max_bw);
1478 
1479 /**
1480  * wlan_reg_is_freq_present_in_cur_chan_list() - Check if channel is present
1481  * in the current channel list
1482  * @pdev: pdev pointer
1483  * @freq: Channel center frequency
1484  *
1485  * Return: true if channel is present in current channel list
1486  */
1487 bool wlan_reg_is_freq_present_in_cur_chan_list(struct wlan_objmgr_pdev *pdev,
1488 					       qdf_freq_t freq);
1489 
1490 /**
1491  * wlan_reg_update_nol_history_ch_for_freq() - Set nol-history flag for the
1492  * channels in the list.
1493  *
1494  * @pdev: Pdev ptr
1495  * @ch_list: Input channel list.
1496  * @num_ch: Number of channels.
1497  * @nol_history_ch: Nol history value.
1498  *
1499  * Return: void
1500  */
1501 void wlan_reg_update_nol_history_ch_for_freq(struct wlan_objmgr_pdev *pdev,
1502 					     uint16_t *ch_list,
1503 					     uint8_t num_ch,
1504 					     bool nol_history_ch);
1505 
1506 /**
1507  * wlan_reg_chan_has_dfs_attribute_for_freq() - check channel has dfs
1508  * attribute flag
1509  * @pdev: Pointer to pdev
1510  * @freq: channel center frequency.
1511  *
1512  * This API get chan initial dfs attribute from regdomain
1513  *
1514  * Return: true if chan is dfs, otherwise false
1515  */
1516 bool
1517 wlan_reg_chan_has_dfs_attribute_for_freq(struct wlan_objmgr_pdev *pdev,
1518 					 qdf_freq_t freq);
1519 
1520 /**
1521  * wlan_reg_get_channel_list_with_power_for_freq() - Provide the channel list
1522  * with power
1523  * @pdev: Pointer to pdev
1524  * @ch_list: pointer to the channel list.
1525  * @num_chan: return number of channels
1526  *
1527  * Return: QDF_STATUS
1528  */
1529 QDF_STATUS
1530 wlan_reg_get_channel_list_with_power_for_freq(struct wlan_objmgr_pdev *pdev,
1531 					      struct channel_power *ch_list,
1532 					      uint8_t *num_chan);
1533 
1534 #ifdef CONFIG_REG_6G_PWRMODE
1535 /**
1536  * wlan_reg_get_5g_bonded_channel_state_for_pwrmode() - Get 5G bonded channel
1537  * state.
1538  * @pdev: The physical dev to program country code or regdomain
1539  * @freq: channel frequency.
1540  * @ch_params: channel parameters
1541  * @in_6g_pwr_type: 6g power type which decides 6G channel list lookup.
1542  *
1543  * Return: channel state
1544  */
1545 enum channel_state
1546 wlan_reg_get_5g_bonded_channel_state_for_pwrmode(struct wlan_objmgr_pdev *pdev,
1547 						 qdf_freq_t freq,
1548 						 struct ch_params *ch_params,
1549 						 enum supported_6g_pwr_types
1550 						 in_6g_pwr_type);
1551 #endif
1552 
1553 /**
1554  * wlan_reg_get_2g_bonded_channel_state_for_freq() - Get 2G bonded channel state
1555  * @pdev: The physical dev to program country code or regdomain
1556  * @freq: channel center frequency.
1557  * @sec_ch_freq: Secondary channel center frequency.
1558  * @bw: channel band width
1559  *
1560  * Return: channel state
1561  */
1562 enum channel_state
1563 wlan_reg_get_2g_bonded_channel_state_for_freq(struct wlan_objmgr_pdev *pdev,
1564 					      qdf_freq_t freq,
1565 					      qdf_freq_t sec_ch_freq,
1566 					      enum phy_ch_width bw);
1567 
1568 #ifdef CONFIG_REG_6G_PWRMODE
1569 /**
1570  * wlan_reg_get_channel_state_for_pwrmode() - Get channel state from regulatory
1571  * @pdev: Pointer to pdev
1572  * @freq: channel center frequency.
1573  * @in_6g_pwr_type: 6g power type which decides 6G channel list lookup.
1574  *
1575  * Return: channel state
1576  */
1577 enum channel_state
1578 wlan_reg_get_channel_state_for_pwrmode(
1579 				    struct wlan_objmgr_pdev *pdev,
1580 				    qdf_freq_t freq,
1581 				    enum supported_6g_pwr_types in_6g_pwr_type);
1582 #endif
1583 
1584 #ifdef CONFIG_REG_CLIENT
1585 /**
1586  * wlan_reg_get_channel_state_from_secondary_list_for_freq() - Get channel state
1587  * from secondary regulatory current channel list
1588  * @pdev: Pointer to pdev
1589  * @freq: channel center frequency.
1590  *
1591  * Return: channel state
1592  */
1593 enum channel_state wlan_reg_get_channel_state_from_secondary_list_for_freq(
1594 						struct wlan_objmgr_pdev *pdev,
1595 						qdf_freq_t freq);
1596 
1597 /**
1598  * wlan_reg_get_channel_list_with_power() - Provide channel list with tx power
1599  * @pdev: Pointer to pdev
1600  * @ch_list: pointer to the channel list.
1601  * @num_chan: Number of channels which has been filed in ch_list
1602  * @in_6g_pwr_type: 6G power type corresponding to which 6G channels needs to
1603  * be provided
1604  *
1605  * Return: QDF_STATUS
1606  */
1607 QDF_STATUS
1608 wlan_reg_get_channel_list_with_power(
1609 				struct wlan_objmgr_pdev *pdev,
1610 				struct channel_power *ch_list,
1611 				uint8_t *num_chan,
1612 				enum supported_6g_pwr_types in_6g_pwr_type);
1613 #endif
1614 
1615 #ifdef WLAN_FEATURE_11BE
1616 /**
1617  * wlan_reg_is_punc_bitmap_valid() - is puncture bitmap valid or not
1618  * @bw: Input channel width.
1619  * @puncture_bitmap: Input puncture bitmap.
1620  *
1621  * Return: true if given puncture bitmap is valid
1622  */
1623 bool wlan_reg_is_punc_bitmap_valid(enum phy_ch_width bw,
1624 				   uint16_t puncture_bitmap);
1625 
1626 /**
1627  * wlan_reg_find_nearest_puncture_pattern() - is proposed bitmap valid or not
1628  * @bw: Input channel width.
1629  * @proposed_bitmap: Input puncture bitmap.
1630  *
1631  * Return: Radar bitmap if it is valid.
1632  */
1633 uint16_t wlan_reg_find_nearest_puncture_pattern(enum phy_ch_width bw,
1634 						uint16_t proposed_bitmap);
1635 
1636 /**
1637  * wlan_reg_extract_puncture_by_bw() - generate new puncture bitmap from
1638  *                                     original puncture bitmap and bandwidth
1639  *                                     based on new bandwidth
1640  * @ori_bw: original bandwidth
1641  * @ori_puncture_bitmap: original puncture bitmap
1642  * @freq: frequency of primary channel
1643  * @cen320_freq: center frequency of 320 MHZ if channel width is 320
1644  * @new_bw: new bandwidth
1645  * @new_puncture_bitmap: output of puncture bitmap
1646  *
1647  * Return: QDF_STATUS
1648  */
1649 QDF_STATUS wlan_reg_extract_puncture_by_bw(enum phy_ch_width ori_bw,
1650 					   uint16_t ori_puncture_bitmap,
1651 					   qdf_freq_t freq,
1652 					   qdf_freq_t cen320_freq,
1653 					   enum phy_ch_width new_bw,
1654 					   uint16_t *new_puncture_bitmap);
1655 
1656 /**
1657  * wlan_reg_set_create_punc_bitmap() - set is_create_punc_bitmap of ch_params
1658  * @ch_params: ch_params to set
1659  * @is_create_punc_bitmap: is create punc bitmap
1660  *
1661  * Return: NULL
1662  */
1663 void wlan_reg_set_create_punc_bitmap(struct ch_params *ch_params,
1664 				     bool is_create_punc_bitmap);
1665 
1666 #ifdef CONFIG_REG_CLIENT
1667 /**
1668  * wlan_reg_apply_puncture() - apply puncture to regulatory
1669  * @pdev: pdev
1670  * @puncture_bitmap: puncture bitmap
1671  * @freq: sap operation freq
1672  * @bw: band width
1673  * @cen320_freq: 320 MHz center freq
1674  *
1675  * When start ap, apply puncture to regulatory, set static puncture flag
1676  * for all 20 MHz sub channels of current bonded channel in master channel list
1677  * of pdev, and disable 20 MHz sub channel in current channel list if static
1678  * puncture flag is set.
1679  *
1680  * Return: QDF_STATUS
1681  */
1682 QDF_STATUS wlan_reg_apply_puncture(struct wlan_objmgr_pdev *pdev,
1683 				   uint16_t puncture_bitmap,
1684 				   qdf_freq_t freq,
1685 				   enum phy_ch_width bw,
1686 				   qdf_freq_t cen320_freq);
1687 
1688 /**
1689  * wlan_reg_remove_puncture() - Remove puncture from regulatory
1690  * @pdev: pdev
1691  *
1692  * When stop ap, remove puncture from regulatory, clear static puncture flag
1693  * for all 20 MHz sub channels in master channel list of pdev, and don't disable
1694  * 20 MHz sub channel in current channel list if static puncture flag is not
1695  * set.
1696  *
1697  * Return: QDF_STATUS
1698  */
1699 QDF_STATUS wlan_reg_remove_puncture(struct wlan_objmgr_pdev *pdev);
1700 #else
1701 static inline
1702 QDF_STATUS wlan_reg_apply_puncture(struct wlan_objmgr_pdev *pdev,
1703 				   uint16_t puncture_bitmap,
1704 				   qdf_freq_t freq,
1705 				   enum phy_ch_width bw,
1706 				   qdf_freq_t cen320_freq)
1707 {
1708 	return QDF_STATUS_SUCCESS;
1709 }
1710 
1711 static inline
1712 QDF_STATUS wlan_reg_remove_puncture(struct wlan_objmgr_pdev *pdev)
1713 {
1714 	return QDF_STATUS_SUCCESS;
1715 }
1716 #endif
1717 #ifdef CONFIG_REG_6G_PWRMODE
1718 /**
1719  * wlan_reg_fill_channel_list_for_pwrmode() - Fills the reg_channel_list
1720  * (list of channels)
1721  * @pdev: Pointer to struct wlan_objmgr_pdev.
1722  * @freq: Center frequency of the primary channel in MHz
1723  * @sec_ch_2g_freq: Secondary channel center frequency.
1724  * @ch_width: Channel width of type 'enum phy_ch_width'.
1725  * @band_center_320: Center frequency of 320MHZ channel.
1726  * @chan_list: Pointer to struct reg_channel_list to be filled (Output param).
1727  * @in_6g_pwr_type: 6g power type which decides 6G channel list lookup.
1728  * @treat_nol_chan_as_disabled: bool to treat nol channel as enabled or
1729  * disabled. If set to true, nol chan is considered as disabled in chan search.
1730  *
1731  * Return: None
1732  */
1733 void wlan_reg_fill_channel_list_for_pwrmode(
1734 				struct wlan_objmgr_pdev *pdev,
1735 				qdf_freq_t freq,
1736 				qdf_freq_t sec_ch_2g_freq,
1737 				enum phy_ch_width ch_width,
1738 				qdf_freq_t band_center_320,
1739 				struct reg_channel_list *chan_list,
1740 				enum supported_6g_pwr_types in_6g_pwr_type,
1741 				bool treat_nol_chan_as_disabled);
1742 #endif
1743 #else
1744 static inline
1745 QDF_STATUS wlan_reg_extract_puncture_by_bw(enum phy_ch_width ori_bw,
1746 					   uint16_t ori_puncture_bitmap,
1747 					   qdf_freq_t freq,
1748 					   qdf_freq_t cen320_freq,
1749 					   enum phy_ch_width new_bw,
1750 					   uint16_t *new_puncture_bitmap)
1751 {
1752 	return QDF_STATUS_SUCCESS;
1753 }
1754 
1755 static inline void wlan_reg_set_create_punc_bitmap(struct ch_params *ch_params,
1756 						   bool is_create_punc_bitmap)
1757 {
1758 }
1759 
1760 static inline
1761 QDF_STATUS wlan_reg_apply_puncture(struct wlan_objmgr_pdev *pdev,
1762 				   uint16_t puncture_bitmap,
1763 				   qdf_freq_t freq,
1764 				   enum phy_ch_width bw,
1765 				   qdf_freq_t cen320_freq)
1766 {
1767 	return QDF_STATUS_SUCCESS;
1768 }
1769 
1770 static inline
1771 QDF_STATUS wlan_reg_remove_puncture(struct wlan_objmgr_pdev *pdev)
1772 {
1773 	return QDF_STATUS_SUCCESS;
1774 }
1775 
1776 static inline
1777 uint16_t wlan_reg_find_nearest_puncture_pattern(enum phy_ch_width bw,
1778 						uint16_t proposed_bitmap)
1779 {
1780 	return 0;
1781 }
1782 #endif
1783 
1784 #ifdef CONFIG_REG_6G_PWRMODE
1785 /**
1786  * wlan_reg_set_channel_params_for_pwrmode() - Sets channel parameters for
1787  * given bandwidth
1788  * @pdev: The physical dev to program country code or regdomain
1789  * @freq: channel center frequency.
1790  * @sec_ch_2g_freq: Secondary channel center frequency.
1791  * @ch_params: pointer to the channel parameters.
1792  * @in_6g_pwr_mode: 6g power type which decides 6G channel list lookup.
1793  *
1794  * Return: None
1795  */
1796 void wlan_reg_set_channel_params_for_pwrmode(struct wlan_objmgr_pdev *pdev,
1797 					     qdf_freq_t freq,
1798 					     qdf_freq_t sec_ch_2g_freq,
1799 					     struct ch_params *ch_params,
1800 					     enum supported_6g_pwr_types
1801 					     in_6g_pwr_mode);
1802 #endif
1803 
1804 /**
1805  * wlan_reg_get_channel_reg_power_for_freq() - Provide the channel
1806  * regulatory power
1807  * @pdev: pdev ptr
1808  * @freq: channel center frequency
1809  *
1810  * Return: int
1811  */
1812 uint8_t wlan_reg_get_channel_reg_power_for_freq(struct wlan_objmgr_pdev *pdev,
1813 						qdf_freq_t freq);
1814 
1815 /**
1816  * wlan_reg_get_bonded_chan_entry() - Fetch the bonded channel pointer given a
1817  * frequency and channel width.
1818  * @freq: Input frequency in MHz.
1819  * @chwidth: Input channel width of enum phy_ch_width.
1820  * @cen320_freq: 320 MHz center frequency in MHz. In 6GHz band 320 MHz channel
1821  *               are overlapping. The exact band should be therefore identified
1822  *               by the center frequency of the 320 Mhz channel.
1823  *
1824  * Return: A valid bonded channel pointer if found, else NULL.
1825  */
1826 const struct bonded_channel_freq *
1827 wlan_reg_get_bonded_chan_entry(qdf_freq_t freq, enum phy_ch_width chwidth,
1828 			       qdf_freq_t cen320_freq);
1829 
1830 /**
1831  * wlan_reg_update_nol_ch_for_freq() - set nol channel
1832  * @pdev: pdev ptr
1833  * @chan_freq_list: channel list to be returned
1834  * @num_ch: number of channels
1835  * @nol_ch: nol flag
1836  *
1837  * Return: void
1838  */
1839 void wlan_reg_update_nol_ch_for_freq(struct wlan_objmgr_pdev *pdev,
1840 				     uint16_t *chan_freq_list,
1841 				     uint8_t num_ch,
1842 				     bool nol_ch);
1843 
1844 /**
1845  * wlan_reg_is_dfs_for_freq() - Checks the channel state for DFS
1846  * @pdev: pdev ptr
1847  * @freq: Channel center frequency
1848  *
1849  * Return: true or false
1850  */
1851 bool wlan_reg_is_dfs_for_freq(struct wlan_objmgr_pdev *pdev, qdf_freq_t freq);
1852 
1853 /**
1854  * wlan_reg_is_dsrc_freq() - Checks if the channel is dsrc channel or not
1855  * @freq: Channel center frequency
1856  *
1857  * Return: true or false
1858  */
1859 bool wlan_reg_is_dsrc_freq(qdf_freq_t freq);
1860 
1861 /**
1862  * wlan_reg_is_passive_or_disable_for_pwrmode() - Checks chan state for passive
1863  * and disabled
1864  * @pdev: pdev ptr
1865  * @freq: Channel center frequency
1866  * @in_6g_pwr_mode: Input 6GHz power mode
1867  *
1868  * Return: true or false
1869  */
1870 bool wlan_reg_is_passive_or_disable_for_pwrmode(
1871 				struct wlan_objmgr_pdev *pdev,
1872 				qdf_freq_t freq,
1873 				enum supported_6g_pwr_types in_6g_pwr_mode);
1874 
1875 #ifdef CONFIG_REG_6G_PWRMODE
1876 /**
1877  * wlan_reg_is_disable_for_pwrmode() - Checks chan state for disabled
1878  * @pdev: pdev ptr
1879  * @freq: Channel center frequency
1880  * @in_6g_pwr_mode: 6g power type which decides 6G channel list lookup.
1881  *
1882  * Return: true or false
1883  */
1884 bool wlan_reg_is_disable_for_pwrmode(
1885 				  struct wlan_objmgr_pdev *pdev,
1886 				  qdf_freq_t freq,
1887 				  enum supported_6g_pwr_types in_6g_pwr_mode);
1888 #endif
1889 
1890 #ifdef CONFIG_REG_CLIENT
1891 /**
1892  * wlan_reg_is_disable_in_secondary_list_for_freq() - Checks in the secondary
1893  * channel list to see if chan state is disabled
1894  * @pdev: pdev ptr
1895  * @freq: Channel center frequency
1896  *
1897  * Return: true or false
1898  */
1899 bool wlan_reg_is_disable_in_secondary_list_for_freq(
1900 						struct wlan_objmgr_pdev *pdev,
1901 						qdf_freq_t freq);
1902 
1903 /**
1904  * wlan_reg_is_enable_in_secondary_list_for_freq() - Checks in the secondary
1905  * channel list to see if chan state is enabled
1906  * @pdev: pdev ptr
1907  * @freq: Channel center frequency
1908  *
1909  * Return: true or false
1910  */
1911 bool wlan_reg_is_enable_in_secondary_list_for_freq(
1912 						struct wlan_objmgr_pdev *pdev,
1913 						qdf_freq_t freq);
1914 
1915 /**
1916  * wlan_reg_is_dfs_in_secondary_list_for_freq() - hecks the channel state for
1917  * DFS from the secondary channel list
1918  * @pdev: pdev ptr
1919  * @freq: Channel center frequency
1920  *
1921  * Return: true or false
1922  */
1923 bool wlan_reg_is_dfs_in_secondary_list_for_freq(struct wlan_objmgr_pdev *pdev,
1924 						qdf_freq_t freq);
1925 
1926 /**
1927  * wlan_reg_get_chan_pwr_attr_from_secondary_list_for_freq() - get channel
1928  * power attributions from secondary channel list
1929  * @pdev: pdev ptr
1930  * @freq: channel center frequency
1931  * @is_psd: pointer to retrieve value whether channel power is psd
1932  * @tx_power: pointer to retrieve value of channel eirp tx power
1933  * @psd_eirp: pointer to retrieve value of channel psd eirp power
1934  * @flags: pointer to retrieve value of channel flags
1935  *
1936  * Return: QDF STATUS
1937  */
1938 QDF_STATUS
1939 wlan_reg_get_chan_pwr_attr_from_secondary_list_for_freq(
1940 				struct wlan_objmgr_pdev *pdev, qdf_freq_t freq,
1941 				bool *is_psd, uint16_t *tx_power,
1942 				uint16_t *psd_eirp, uint32_t *flags);
1943 
1944 /**
1945  * wlan_reg_decide_6ghz_power_within_bw_for_freq() - decide minimum tx power in
1946  * bandwidth and 6 GHz power type
1947  * @pdev: pdev ptr
1948  * @freq: channel center frequency
1949  * @bw: channel bandwidth
1950  * @is_psd: pointer to retrieve value whether channel power is psd
1951  * @min_tx_power: pointer to retrieve minimum tx power in bandwidth
1952  * @min_psd_eirp: pointer to retrieve minimum psd eirp in bandwidth
1953  * @power_type: pointer to retrieve 6 GHz power type
1954  * @pwr_mode: 6g power type which decides 6G channel list lookup.
1955  * @input_punc_bitmap: Input  puncture bitmap
1956  *
1957  * Return: QDF STATUS
1958  */
1959 QDF_STATUS
1960 wlan_reg_decide_6ghz_power_within_bw_for_freq(struct wlan_objmgr_pdev *pdev,
1961 					      qdf_freq_t freq,
1962 					      enum phy_ch_width bw,
1963 					      bool *is_psd,
1964 					      uint16_t *min_tx_power,
1965 					      int16_t *min_psd_eirp,
1966 					      enum reg_6g_ap_type *power_type,
1967 					      enum supported_6g_pwr_types pwr_mode,
1968 					      uint16_t input_punc_bitmap);
1969 #endif
1970 
1971 /**
1972  * wlan_reg_is_passive_for_freq() - Check the channel flags to see if the
1973  * passive flag is set
1974  * @pdev: pdev ptr
1975  * @freq: Channel center frequency
1976  *
1977  * Return: true or false
1978  */
1979 bool wlan_reg_is_passive_for_freq(struct wlan_objmgr_pdev *pdev,
1980 				  qdf_freq_t freq);
1981 
1982 /**
1983  * wlan_reg_freq_to_band() - Get band from channel number
1984  * @freq:Channel frequency in MHz
1985  *
1986  * Return: wifi band
1987  */
1988 enum reg_wifi_band wlan_reg_freq_to_band(qdf_freq_t freq);
1989 
1990 /**
1991  * wlan_reg_min_chan_freq() - Minimum channel frequency supported
1992  *
1993  * Return: frequency
1994  */
1995 qdf_freq_t wlan_reg_min_chan_freq(void);
1996 
1997 /**
1998  * wlan_reg_max_chan_freq() - Return max. frequency
1999  *
2000  * Return: frequency
2001  */
2002 qdf_freq_t wlan_reg_max_chan_freq(void);
2003 
2004 /**
2005  * wlan_reg_freq_width_to_chan_op_class() -Get op class from freq
2006  * @pdev: pdev ptr
2007  * @freq: channel frequency
2008  * @chan_width: channel width
2009  * @global_tbl_lookup: whether to look up global table
2010  * @behav_limit: behavior limit
2011  * @op_class: operating class
2012  * @chan_num: channel number
2013  *
2014  * Return: void
2015  */
2016 void wlan_reg_freq_width_to_chan_op_class(struct wlan_objmgr_pdev *pdev,
2017 					  qdf_freq_t freq,
2018 					  uint16_t chan_width,
2019 					  bool global_tbl_lookup,
2020 					  uint16_t behav_limit,
2021 					  uint8_t *op_class,
2022 					  uint8_t *chan_num);
2023 
2024 /**
2025  * wlan_reg_freq_width_to_chan_op_class_auto() - convert frequency to
2026  * operating class,channel
2027  * @pdev: pdev pointer
2028  * @freq: channel frequency in mhz
2029  * @chan_width: channel width
2030  * @global_tbl_lookup: whether to lookup global op class tbl
2031  * @behav_limit: behavior limit
2032  * @op_class: operating class
2033  * @chan_num: channel number
2034  *
2035  * Return: Void.
2036  */
2037 void wlan_reg_freq_width_to_chan_op_class_auto(struct wlan_objmgr_pdev *pdev,
2038 					       qdf_freq_t freq,
2039 					       uint16_t chan_width,
2040 					       bool global_tbl_lookup,
2041 					       uint16_t behav_limit,
2042 					       uint8_t *op_class,
2043 					       uint8_t *chan_num);
2044 
2045 /**
2046  * wlan_reg_freq_to_chan_op_class() - Converts freq to oper class
2047  * @pdev: pdev ptr
2048  * @freq: channel frequency
2049  * @global_tbl_lookup: whether to look up global table
2050  * @behav_limit: behavior limit
2051  * @op_class: operating class
2052  * @chan_num: channel number
2053  *
2054  * Return: void
2055  */
2056 void wlan_reg_freq_to_chan_op_class(struct wlan_objmgr_pdev *pdev,
2057 				    qdf_freq_t freq,
2058 				    bool global_tbl_lookup,
2059 				    uint16_t behav_limit,
2060 				    uint8_t *op_class,
2061 				    uint8_t *chan_num);
2062 
2063 /**
2064  * wlan_reg_is_freq_in_country_opclass() - checks frequency in (ctry, op class)
2065  *                                         pair
2066  * @pdev: pdev ptr
2067  * @country: country information
2068  * @op_class: operating class
2069  * @chan_freq: channel frequency
2070  *
2071  * Return: bool
2072  */
2073 bool wlan_reg_is_freq_in_country_opclass(struct wlan_objmgr_pdev *pdev,
2074 					 const uint8_t country[3],
2075 					 uint8_t op_class,
2076 					 qdf_freq_t chan_freq);
2077 /**
2078  * wlan_reg_get_5g_bonded_channel_and_state_for_pwrmode()- Return the channel
2079  * state for a 5G or 6G channel frequency based on the channel width and
2080  * bonded channel.
2081  * @pdev: Pointer to pdev.
2082  * @freq: Channel center frequency.
2083  * @bw: Channel Width.
2084  * @bonded_chan_ptr_ptr: Pointer to bonded_channel_freq.
2085  * @in_6g_pwr_mode: 6g power type which decides 6G channel list lookup.
2086  * @input_puncture_bitmap: Input puncture bitmap
2087  *
2088  * Return: Channel State
2089  */
2090 enum channel_state
2091 wlan_reg_get_5g_bonded_channel_and_state_for_pwrmode(
2092 					struct wlan_objmgr_pdev *pdev,
2093 					uint16_t freq,
2094 					enum phy_ch_width bw,
2095 					const
2096 					struct bonded_channel_freq
2097 					**bonded_chan_ptr_ptr,
2098 					enum supported_6g_pwr_types
2099 					in_6g_pwr_mode,
2100 					uint16_t input_puncture_bitmap);
2101 #endif /*CONFIG_CHAN_FREQ_API */
2102 
2103 /**
2104  * wlan_reg_get_op_class_width() - Get operating class chan width
2105  * @pdev: pdev ptr
2106  * @op_class: operating class
2107  * @global_tbl_lookup: whether to look up global table
2108  *
2109  * Return: channel width of op class
2110  */
2111 uint16_t wlan_reg_get_op_class_width(struct wlan_objmgr_pdev *pdev,
2112 				     uint8_t op_class,
2113 				     bool global_tbl_lookup);
2114 
2115 /**
2116  * wlan_reg_is_5ghz_op_class() - Check if the input opclass is a 5GHz opclass.
2117  * @country: Country code.
2118  * @op_class: Operating class.
2119  *
2120  * Return: Return true if input the opclass is a 5GHz opclass,
2121  * else return false.
2122  */
2123 bool wlan_reg_is_5ghz_op_class(const uint8_t *country, uint8_t op_class);
2124 
2125 /**
2126  * wlan_reg_is_2ghz_op_class() - Check if the input opclass is a 2.4GHz opclass.
2127  * @country: Country code.
2128  * @op_class: Operating class.
2129  *
2130  * Return: Return true if input the opclass is a 2.4GHz opclass,
2131  * else return false.
2132  */
2133 bool wlan_reg_is_2ghz_op_class(const uint8_t *country, uint8_t op_class);
2134 
2135 /**
2136  * wlan_reg_is_6ghz_op_class() - Whether 6ghz oper class
2137  * @pdev: pdev ptr
2138  * @op_class: operating class
2139  *
2140  * Return: bool
2141  */
2142 bool wlan_reg_is_6ghz_op_class(struct wlan_objmgr_pdev *pdev,
2143 			       uint8_t op_class);
2144 
2145 #ifdef CONFIG_REG_CLIENT
2146 /**
2147  * wlan_reg_is_6ghz_supported() - Whether 6ghz is supported
2148  * @psoc: psoc ptr
2149  *
2150  * Return: bool
2151  */
2152 bool wlan_reg_is_6ghz_supported(struct wlan_objmgr_psoc *psoc);
2153 #endif
2154 
2155 #ifdef HOST_OPCLASS_EXT
2156 /**
2157  * wlan_reg_country_chan_opclass_to_freq() - Convert channel number to
2158  * frequency based on country code and op class
2159  * @pdev: pdev object.
2160  * @country: country code.
2161  * @chan: IEEE Channel Number.
2162  * @op_class: Opclass.
2163  * @strict: flag to find channel from matched operating class code.
2164  *
2165  * Look up (channel, operating class) pair in country operating class tables
2166  * and return the channel frequency.
2167  * If not found and "strict" flag is false, try to get frequency (Mhz) by
2168  * channel number only.
2169  *
2170  * Return: Channel center frequency else return 0.
2171  */
2172 qdf_freq_t
2173 wlan_reg_country_chan_opclass_to_freq(struct wlan_objmgr_pdev *pdev,
2174 				      const uint8_t country[3],
2175 				      uint8_t chan, uint8_t op_class,
2176 				      bool strict);
2177 #endif
2178 
2179 /**
2180  * wlan_reg_chan_opclass_to_freq() - Convert channel number and opclass to frequency
2181  * @chan: IEEE Channel Number.
2182  * @op_class: Opclass.
2183  * @global_tbl_lookup: Global table lookup.
2184  *
2185  * Return: Channel center frequency else return 0.
2186  */
2187 uint16_t wlan_reg_chan_opclass_to_freq(uint8_t chan,
2188 				       uint8_t op_class,
2189 				       bool global_tbl_lookup);
2190 
2191 /**
2192  * wlan_reg_chan_opclass_to_freq_auto() - Convert channel number and opclass to
2193  * frequency
2194  * @chan: IEEE channel number
2195  * @op_class: Operating class of channel
2196  * @global_tbl_lookup: Flag to determine if global table has to be looked up
2197  *
2198  * Return: Channel center frequency if valid, else zero
2199  */
2200 
2201 qdf_freq_t wlan_reg_chan_opclass_to_freq_auto(uint8_t chan, uint8_t op_class,
2202 					      bool global_tbl_lookup);
2203 
2204 #ifdef CHECK_REG_PHYMODE
2205 /**
2206  * wlan_reg_get_max_phymode() - Find the best possible phymode given a
2207  * phymode, a frequency, and per-country regulations
2208  * @pdev: pdev pointer
2209  * @phy_in: phymode that the user requested
2210  * @freq: current operating center frequency
2211  *
2212  * Return: maximum phymode allowed in current country that is <= phy_in
2213  */
2214 enum reg_phymode wlan_reg_get_max_phymode(struct wlan_objmgr_pdev *pdev,
2215 					  enum reg_phymode phy_in,
2216 					  qdf_freq_t freq);
2217 #else
2218 static inline enum reg_phymode
2219 wlan_reg_get_max_phymode(struct wlan_objmgr_pdev *pdev,
2220 			 enum reg_phymode phy_in,
2221 			 qdf_freq_t freq)
2222 {
2223 	return REG_PHYMODE_INVALID;
2224 }
2225 #endif /* CHECK_REG_PHYMODE */
2226 
2227 #ifdef CONFIG_REG_CLIENT
2228 /**
2229  * wlan_reg_band_bitmap_to_band_info() - Convert the band_bitmap to a
2230  *	band_info enum
2231  * @band_bitmap: bitmap on top of reg_wifi_band of bands enabled
2232  *
2233  * Return: BAND_ALL if both 2G and 5G band is enabled
2234  *	BAND_2G if 2G is enabled but 5G isn't
2235  *	BAND_5G if 5G is enabled but 2G isn't
2236  */
2237 enum band_info wlan_reg_band_bitmap_to_band_info(uint32_t band_bitmap);
2238 
2239 /**
2240  * wlan_reg_update_tx_power_on_ctry_change() - Update tx power during
2241  * country code change (without channel change) OR if fcc constraint is set
2242  * @pdev: Pointer to pdev
2243  * @vdev_id: vdev ID
2244  *
2245  * Return: QDF_STATUS
2246  */
2247 QDF_STATUS
2248 wlan_reg_update_tx_power_on_ctry_change(struct wlan_objmgr_pdev *pdev,
2249 					uint8_t vdev_id);
2250 
2251 /**
2252  * wlan_reg_modify_indoor_concurrency() - Update the indoor concurrency list
2253  * in regulatory pdev context
2254  *
2255  * @pdev: pointer to pdev
2256  * @vdev_id: vdev id
2257  * @freq: frequency
2258  * @width: channel width
2259  * @add: add or delete entry
2260  *
2261  * Return: QDF_STATUS
2262  */
2263 QDF_STATUS
2264 wlan_reg_modify_indoor_concurrency(struct wlan_objmgr_pdev *pdev,
2265 				   uint8_t vdev_id, uint32_t freq,
2266 				   enum phy_ch_width width, bool add);
2267 #endif
2268 /**
2269  * wlan_reg_recompute_current_chan_list() - Recompute the current channel list
2270  * based on the regulatory change
2271  *
2272  * @psoc: pointer to psoc
2273  * @pdev: pointer to pdev
2274  *
2275  * Return: QDF_STATUS
2276  */
2277 QDF_STATUS
2278 wlan_reg_recompute_current_chan_list(struct wlan_objmgr_psoc *psoc,
2279 				     struct wlan_objmgr_pdev *pdev);
2280 
2281 #if defined(CONFIG_BAND_6GHZ)
2282 /**
2283  * wlan_reg_get_cur_6g_ap_pwr_type() - Get the current 6G regulatory AP power
2284  * type.
2285  * @pdev: Pointer to PDEV object.
2286  * @reg_cur_6g_ap_pwr_type: The current regulatory 6G AP power type ie.
2287  * LPI/SP/VLP.
2288  *
2289  * Return: QDF_STATUS.
2290  */
2291 QDF_STATUS
2292 wlan_reg_get_cur_6g_ap_pwr_type(struct wlan_objmgr_pdev *pdev,
2293 				enum reg_6g_ap_type *reg_cur_6g_ap_pwr_type);
2294 
2295 /**
2296  * wlan_reg_get_cur_6g_client_type() - Get the current 6G regulatory client
2297  * type.
2298  * @pdev: Pointer to PDEV object.
2299  * @reg_cur_6g_client_mobility_type: The current regulatory 6G client type ie.
2300  * default/subordinate.
2301  *
2302  * Return: QDF_STATUS.
2303  */
2304 QDF_STATUS
2305 wlan_reg_get_cur_6g_client_type(struct wlan_objmgr_pdev *pdev,
2306 				enum reg_6g_client_type
2307 				*reg_cur_6g_client_mobility_type);
2308 
2309 /**
2310  * wlan_reg_set_cur_6ghz_client_type() - Set the cur 6 GHz regulatory client
2311  * type to the given value.
2312  * @pdev: Pointer to PDEV object.
2313  * @in_6ghz_client_type: Input Client type to be set ie. default/subordinate.
2314  *
2315  * Return: QDF_STATUS.
2316  */
2317 QDF_STATUS
2318 wlan_reg_set_cur_6ghz_client_type(struct wlan_objmgr_pdev *pdev,
2319 				  enum reg_6g_client_type in_6ghz_client_type);
2320 
2321 /**
2322  * wlan_reg_set_6ghz_client_type_from_target() - Set the current 6 GHz
2323  * regulatory client type to the value received from target.
2324  * @pdev: Pointer to PDEV object.
2325  *
2326  * Return: QDF_STATUS.
2327  */
2328 QDF_STATUS
2329 wlan_reg_set_6ghz_client_type_from_target(struct wlan_objmgr_pdev *pdev);
2330 
2331 /**
2332  * wlan_reg_get_rnr_tpe_usable() - Tells if RNR IE is applicable for current
2333  * domain.
2334  * @pdev: Pointer to PDEV object.
2335  * @reg_rnr_tpe_usable: Pointer to hold the bool value, true if RNR IE is
2336  * applicable, else false.
2337  *
2338  * Return: QDF_STATUS.
2339  */
2340 QDF_STATUS wlan_reg_get_rnr_tpe_usable(struct wlan_objmgr_pdev *pdev,
2341 				       bool *reg_rnr_tpe_usable);
2342 
2343 /**
2344  * wlan_reg_get_unspecified_ap_usable() - Tells if AP type unspecified by 802.11
2345  * can be used or not.
2346  * @pdev: Pointer to PDEV object.
2347  * @reg_unspecified_ap_usable: Pointer to hold the bool value, true if
2348  * unspecified AP types can be used in the IE, else false.
2349  *
2350  * Return: QDF_STATUS.
2351  */
2352 QDF_STATUS wlan_reg_get_unspecified_ap_usable(struct wlan_objmgr_pdev *pdev,
2353 					      bool *reg_unspecified_ap_usable);
2354 
2355 /**
2356  * wlan_reg_is_6g_psd_power() - Checks if given pdev is PSD power
2357  * @pdev: pdev ptr
2358  *
2359  * Return: true if pdev is PSD power or false otherwise
2360  */
2361 bool wlan_reg_is_6g_psd_power(struct wlan_objmgr_pdev *pdev);
2362 
2363 /**
2364  * wlan_reg_get_6g_chan_ap_power() - Finds the AP TX power for the given channel
2365  *	frequency
2366  *
2367  * @pdev: pdev ptr
2368  * @chan_freq: channel frequency
2369  * @is_psd: is channel PSD or not
2370  * @tx_power: transmit power to fill for chan_freq
2371  * @eirp_psd_power: EIRP power, will only be filled if is_psd is true
2372  *
2373  * Return: QDF_STATUS
2374  */
2375 QDF_STATUS wlan_reg_get_6g_chan_ap_power(struct wlan_objmgr_pdev *pdev,
2376 					 qdf_freq_t chan_freq, bool *is_psd,
2377 					 uint16_t *tx_power,
2378 					 uint16_t *eirp_psd_power);
2379 
2380 /**
2381  * wlan_reg_get_client_power_for_connecting_ap() - Find the channel information
2382  *	when device is operating as a client
2383  *
2384  * @pdev: pdev ptr
2385  * @ap_type: type of AP that device is connected to
2386  * @chan_freq: channel frequency
2387  * @is_psd: is channel PSD or not
2388  * @tx_power: transmit power to fill for chan_freq
2389  * @eirp_psd_power: EIRP power, will only be filled if is_psd is true
2390  *
2391  * This function is meant to be called to find the channel frequency power
2392  * information for a client when the device is operating as a client. It will
2393  * fill in the parameters tx_power and eirp_psd_power. eirp_psd_power will
2394  * only be filled if the channel is PSD.
2395  *
2396  * Return: QDF_STATUS
2397  */
2398 QDF_STATUS
2399 wlan_reg_get_client_power_for_connecting_ap(struct wlan_objmgr_pdev *pdev,
2400 					    enum reg_6g_ap_type ap_type,
2401 					    qdf_freq_t chan_freq,
2402 					    bool is_psd, uint16_t *tx_power,
2403 					    uint16_t *eirp_psd_power);
2404 
2405 /**
2406  * wlan_reg_get_client_power_for_6ghz_ap() - Find the channel information when
2407  *	device is operating as a 6GHz AP
2408  *
2409  * @pdev: pdev ptr
2410  * @client_type: type of client that is connected to our AP
2411  * @chan_freq: channel frequency
2412  * @is_psd: is channel PSD or not
2413  * @tx_power: transmit power to fill for chan_freq
2414  * @eirp_psd_power: EIRP power, will only be filled if is_psd is true
2415  *
2416  * This function is meant to be called to find the channel frequency power
2417  * information for a client when the device is operating as an AP. It will fill
2418  * in the parameter is_psd, tx_power, and eirp_psd_power. eirp_psd_power will
2419  * only be filled if the channel is PSD.
2420  *
2421  * Return: QDF_STATUS
2422  */
2423 QDF_STATUS
2424 wlan_reg_get_client_power_for_6ghz_ap(struct wlan_objmgr_pdev *pdev,
2425 				      enum reg_6g_client_type client_type,
2426 				      qdf_freq_t chan_freq,
2427 				      bool *is_psd, uint16_t *tx_power,
2428 				      uint16_t *eirp_psd_power);
2429 
2430 /**
2431  * wlan_reg_decide_6g_ap_pwr_type() - Decide which power mode AP should operate
2432  * in
2433  *
2434  * @pdev: pdev ptr
2435  *
2436  * Return: AP power type
2437  */
2438 enum reg_6g_ap_type
2439 wlan_reg_decide_6g_ap_pwr_type(struct wlan_objmgr_pdev *pdev);
2440 
2441 /**
2442  * wlan_reg_set_ap_pwr_and_update_chan_list() - Set the AP power mode and
2443  * recompute the current channel list
2444  *
2445  * @pdev: pdev ptr
2446  * @ap_pwr_type: the AP power type to update to
2447  *
2448  * Return: QDF_STATUS
2449  */
2450 QDF_STATUS
2451 wlan_reg_set_ap_pwr_and_update_chan_list(struct wlan_objmgr_pdev *pdev,
2452 					 enum reg_6g_ap_type ap_pwr_type);
2453 
2454 /**
2455  * wlan_reg_get_best_6g_pwr_type() - Returns the best 6g power type supported
2456  * for a given frequency.
2457  * @pdev: pdev pointer
2458  * @freq: input frequency.
2459  *
2460  * Return: supported_6g_pwr_types enum.
2461  */
2462 enum supported_6g_pwr_types
2463 wlan_reg_get_best_6g_pwr_type(struct wlan_objmgr_pdev *pdev, qdf_freq_t freq);
2464 
2465 /**
2466  * wlan_reg_conv_6g_ap_type_to_supported_6g_pwr_types() - Converts the 6G AP
2467  * power type to 6g supported power type enum.
2468  * @ap_pwr_type: input 6G AP power type.
2469  *
2470  * Return: supported_6g_pwr_types enum.
2471  */
2472 enum supported_6g_pwr_types
2473 wlan_reg_conv_6g_ap_type_to_supported_6g_pwr_types(enum reg_6g_ap_type
2474 						   ap_pwr_type);
2475 
2476 /**
2477  * wlan_reg_conv_supported_6g_pwr_type_to_ap_pwr_type() - The supported 6G power
2478  * type is a combination of AP and client power types. This API return the 6G AP
2479  * power type portion of the supported 6G power type.
2480  * @in_6g_pwr_type: input 6G supported power type.
2481  *
2482  * Return: 6G AP power type.
2483  */
2484 enum reg_6g_ap_type
2485 wlan_reg_conv_supported_6g_pwr_type_to_ap_pwr_type(enum supported_6g_pwr_types
2486 						  in_6g_pwr_type);
2487 #else /* !CONFIG_BAND_6GHZ */
2488 static inline QDF_STATUS
2489 wlan_reg_get_cur_6g_ap_pwr_type(struct wlan_objmgr_pdev *pdev,
2490 				enum reg_6g_ap_type *reg_cur_6g_ap_pwr_type)
2491 {
2492 	*reg_cur_6g_ap_pwr_type = REG_CURRENT_MAX_AP_TYPE;
2493 	return QDF_STATUS_E_NOSUPPORT;
2494 }
2495 
2496 static inline QDF_STATUS
2497 wlan_reg_get_cur_6g_client_type(struct wlan_objmgr_pdev *pdev,
2498 				enum reg_6g_client_type
2499 				*reg_cur_6g_client_mobility_type)
2500 {
2501 	*reg_cur_6g_client_mobility_type = REG_SUBORDINATE_CLIENT;
2502 	return QDF_STATUS_E_NOSUPPORT;
2503 }
2504 
2505 static inline QDF_STATUS
2506 wlan_reg_set_cur_6ghz_client_type(struct wlan_objmgr_pdev *pdev,
2507 				  enum reg_6g_client_type in_6ghz_client_type)
2508 {
2509 	return QDF_STATUS_E_NOSUPPORT;
2510 }
2511 
2512 static inline QDF_STATUS
2513 wlan_reg_set_6ghz_client_type_from_target(struct wlan_objmgr_pdev *pdev)
2514 {
2515 	return QDF_STATUS_E_NOSUPPORT;
2516 }
2517 
2518 static inline
2519 QDF_STATUS wlan_reg_get_rnr_tpe_usable(struct wlan_objmgr_pdev *pdev,
2520 				       bool *reg_rnr_tpe_usable)
2521 {
2522 	*reg_rnr_tpe_usable = false;
2523 	return QDF_STATUS_E_NOSUPPORT;
2524 }
2525 
2526 static inline
2527 QDF_STATUS wlan_reg_get_unspecified_ap_usable(struct wlan_objmgr_pdev *pdev,
2528 					      bool *reg_unspecified_ap_usable)
2529 {
2530 	*reg_unspecified_ap_usable = false;
2531 	return QDF_STATUS_E_NOSUPPORT;
2532 }
2533 
2534 static inline
2535 bool wlan_reg_is_6g_psd_power(struct wlan_objmgr_pdev *pdev)
2536 {
2537 	return false;
2538 }
2539 
2540 static inline
2541 QDF_STATUS wlan_reg_get_6g_chan_ap_power(struct wlan_objmgr_pdev *pdev,
2542 					 qdf_freq_t chan_freq, bool *is_psd,
2543 					 uint16_t *tx_power,
2544 					 uint16_t *eirp_psd_power)
2545 {
2546 	*is_psd = false;
2547 	*tx_power = 0;
2548 	*eirp_psd_power = 0;
2549 	return QDF_STATUS_E_NOSUPPORT;
2550 }
2551 
2552 static inline QDF_STATUS
2553 wlan_reg_get_client_power_for_connecting_ap(struct wlan_objmgr_pdev *pdev,
2554 					    enum reg_6g_ap_type ap_type,
2555 					    qdf_freq_t chan_freq,
2556 					    bool is_psd, uint16_t *tx_power,
2557 					    uint16_t *eirp_psd_power)
2558 {
2559 	*tx_power = 0;
2560 	*eirp_psd_power = 0;
2561 	return QDF_STATUS_E_NOSUPPORT;
2562 }
2563 
2564 static inline QDF_STATUS
2565 wlan_reg_get_client_power_for_6ghz_ap(struct wlan_objmgr_pdev *pdev,
2566 				      enum reg_6g_client_type client_type,
2567 				      qdf_freq_t chan_freq,
2568 				      bool *is_psd, uint16_t *tx_power,
2569 				      uint16_t *eirp_psd_power)
2570 {
2571 	*is_psd = false;
2572 	*tx_power = 0;
2573 	*eirp_psd_power = 0;
2574 	return QDF_STATUS_E_NOSUPPORT;
2575 }
2576 
2577 static inline enum reg_6g_ap_type
2578 wlan_reg_decide_6g_ap_pwr_type(struct wlan_objmgr_pdev *pdev)
2579 {
2580 	return REG_INDOOR_AP;
2581 }
2582 
2583 static inline QDF_STATUS
2584 wlan_reg_set_ap_pwr_and_update_chan_list(struct wlan_objmgr_pdev *pdev,
2585 					 enum reg_6g_ap_type ap_pwr_type)
2586 {
2587 	return QDF_STATUS_E_NOSUPPORT;
2588 }
2589 
2590 static inline enum supported_6g_pwr_types
2591 wlan_reg_get_best_6g_pwr_type(struct wlan_objmgr_pdev *pdev, qdf_freq_t freq)
2592 {
2593 	return REG_INVALID_PWR_MODE;
2594 }
2595 
2596 static inline enum supported_6g_pwr_types
2597 wlan_reg_conv_6g_ap_type_to_supported_6g_pwr_types(enum reg_6g_ap_type
2598 						   ap_pwr_type)
2599 {
2600 	return REG_INVALID_PWR_MODE;
2601 }
2602 
2603 static inline enum reg_6g_ap_type
2604 wlan_reg_conv_supported_6g_pwr_type_to_ap_pwr_type(enum supported_6g_pwr_types
2605 						   in_6g_pwr_type)
2606 {
2607 	return REG_MAX_AP_TYPE;
2608 }
2609 #endif /* CONFIG_BAND_6GHZ */
2610 
2611 /**
2612  * wlan_reg_is_ext_tpc_supported() - Checks if FW supports new WMI cmd for TPC
2613  *
2614  * @psoc: psoc ptr
2615  *
2616  * Return: true if FW supports new command or false otherwise
2617  */
2618 bool wlan_reg_is_ext_tpc_supported(struct wlan_objmgr_psoc *psoc);
2619 
2620 /**
2621  * wlan_reg_is_chwidth_supported() - Check if given channel width is supported
2622  * on a given pdev
2623  * @pdev: pdev pointer
2624  * @ch_width: channel width.
2625  * @is_supported: whether the channel width is supported
2626  *
2627  * Return QDF_STATUS_SUCCESS of operation
2628  */
2629 QDF_STATUS wlan_reg_is_chwidth_supported(struct wlan_objmgr_pdev *pdev,
2630 					 enum phy_ch_width ch_width,
2631 					 bool *is_supported);
2632 
2633 #ifdef CONFIG_BAND_6GHZ
2634 /**
2635  * wlan_reg_get_thresh_priority_freq() - Get the prioritized frequency value
2636  * @pdev: pdev pointer
2637  */
2638 qdf_freq_t wlan_reg_get_thresh_priority_freq(struct wlan_objmgr_pdev *pdev);
2639 
2640 /**
2641  * wlan_reg_psd_2_eirp() - Calculate EIRP from PSD and bandwidth
2642  * channel list
2643  * @pdev: pdev pointer
2644  * @psd: Power Spectral Density in dBm/MHz
2645  * @ch_bw: Bandwidth of a channel in MHz (20/40/80/160/320 etc)
2646  * @eirp:  EIRP power  in dBm
2647  *
2648  * Return: QDF_STATUS
2649  */
2650 QDF_STATUS wlan_reg_psd_2_eirp(struct wlan_objmgr_pdev *pdev,
2651 			       int16_t psd,
2652 			       uint16_t ch_bw,
2653 			       int16_t *eirp);
2654 
2655 /**
2656  * wlan_reg_eirp_2_psd() - Calculate PSD poewr from EIRP and bandwidth
2657  * @pdev: pdev pointer
2658  * @ch_bw: Bandwidth of a channel in MHz (20/40/80/160/320 etc)
2659  * @eirp:  EIRP power  in dBm
2660  * @psd: Power Spectral Density in dBm/MHz
2661  *
2662  * Return: QDF_STATUS
2663  */
2664 QDF_STATUS wlan_reg_eirp_2_psd(struct wlan_objmgr_pdev *pdev,
2665 			       uint16_t ch_bw,
2666 			       int16_t eirp,
2667 			       int16_t *psd);
2668 
2669 /**
2670  * wlan_reg_get_best_pwr_mode() - Get the best power mode based on input freq
2671  * and bandwidth. The mode that provides the best EIRP is the best power mode.
2672  * @pdev: Pointer to pdev
2673  * @freq: Frequency in MHz
2674  * @cen320: 320 MHz band center frequency. For other BW, this param is
2675  * ignored while processing
2676  * @bw: Bandwidth in MHz
2677  * @in_punc_pattern: input puncture pattern
2678  *
2679  * Return: Best power mode
2680  */
2681 enum reg_6g_ap_type
2682 wlan_reg_get_best_pwr_mode(struct wlan_objmgr_pdev *pdev, qdf_freq_t freq,
2683 			   qdf_freq_t cen320, uint16_t bw,
2684 			   uint16_t in_punc_pattern);
2685 
2686 /**
2687  * wlan_reg_get_eirp_pwr() - Get eirp power based on the AP power mode
2688  * @pdev: Pointer to pdev
2689  * @freq: Frequency in MHz
2690  * @cen320: 320 MHz Band center frequency
2691  * @bw: Bandwidth in MHz
2692  * @ap_pwr_type: AP power type
2693  * @in_punc_pattern: Input puncture pattern
2694  * @is_client_list_lookup_needed: Boolean to indicate if client list lookup is
2695  * needed
2696  * @client_type: Client power type
2697  *
2698  * Return: EIRP power
2699  */
2700 uint8_t wlan_reg_get_eirp_pwr(struct wlan_objmgr_pdev *pdev, qdf_freq_t freq,
2701 			      qdf_freq_t cen320, uint16_t bw,
2702 			      enum reg_6g_ap_type ap_pwr_type,
2703 			      uint16_t in_punc_pattern,
2704 			      bool is_client_list_lookup_needed,
2705 			      enum reg_6g_client_type client_type);
2706 #else
2707 static inline
2708 qdf_freq_t wlan_reg_get_thresh_priority_freq(struct wlan_objmgr_pdev *pdev)
2709 {
2710 	return 0;
2711 }
2712 
2713 static inline enum reg_6g_ap_type
2714 wlan_reg_get_best_pwr_mode(struct wlan_objmgr_pdev *pdev, qdf_freq_t freq,
2715 			   qdf_freq_t cen320,
2716 			   uint16_t bw,
2717 			   uint16_t in_punc_pattern)
2718 {
2719 	return REG_MAX_AP_TYPE;
2720 }
2721 
2722 static inline QDF_STATUS wlan_reg_psd_2_eirp(struct wlan_objmgr_pdev *pdev,
2723 					     int16_t psd,
2724 					     uint16_t ch_bw,
2725 					     int16_t *eirp)
2726 {
2727 	return QDF_STATUS_E_FAILURE;
2728 }
2729 
2730 static inline QDF_STATUS wlan_reg_eirp_2_psd(struct wlan_objmgr_pdev *pdev,
2731 					     uint16_t ch_bw,
2732 					     int16_t eirp,
2733 					     int16_t *psd)
2734 {
2735 	return QDF_STATUS_E_FAILURE;
2736 }
2737 
2738 static inline uint8_t
2739 wlan_reg_get_eirp_pwr(struct wlan_objmgr_pdev *pdev,
2740 		      qdf_freq_t freq,
2741 		      qdf_freq_t cen320, uint16_t bw,
2742 		      enum reg_6g_ap_type ap_pwr_type,
2743 		      uint16_t in_punc_pattern,
2744 		      bool is_client_list_lookup_needed,
2745 		      enum reg_6g_client_type client_type)
2746 {
2747 	return 0;
2748 }
2749 #endif /* CONFIG_BAND_6GHZ */
2750 /**
2751  * wlan_reg_find_chwidth_from_bw() - Gets channel width for given
2752  * bandwidth
2753  * @bw: Bandwidth
2754  *
2755  * Return: phy_ch_width
2756  */
2757 enum phy_ch_width wlan_reg_find_chwidth_from_bw(uint16_t bw);
2758 
2759 /**
2760  * wlan_reg_get_chan_state_for_320() - Get the channel state of a 320 MHz
2761  * bonded channel.
2762  * @pdev: Pointer to wlan_objmgr_pdev
2763  * @freq: Primary frequency
2764  * @center_320: Band center of 320 MHz
2765  * @ch_width: Channel width
2766  * @bonded_chan_ptr_ptr: Pointer to bonded channel pointer
2767  * @in_6g_pwr_type: Input 6g power type
2768  * @treat_nol_chan_as_disabled: Bool to treat nol chan as enabled/disabled
2769  * @input_puncture_bitmap: Input puncture bitmap
2770  *
2771  * Return: Channel state
2772  */
2773 #ifdef WLAN_FEATURE_11BE
2774 enum channel_state
2775 wlan_reg_get_chan_state_for_320(struct wlan_objmgr_pdev *pdev,
2776 				uint16_t freq,
2777 				qdf_freq_t center_320,
2778 				enum phy_ch_width ch_width,
2779 				const struct bonded_channel_freq
2780 				**bonded_chan_ptr_ptr,
2781 				enum supported_6g_pwr_types in_6g_pwr_type,
2782 				bool treat_nol_chan_as_disabled,
2783 				uint16_t input_puncture_bitmap);
2784 #else
2785 static inline enum channel_state
2786 wlan_reg_get_chan_state_for_320(struct wlan_objmgr_pdev *pdev,
2787 				uint16_t freq,
2788 				qdf_freq_t center_320,
2789 				enum phy_ch_width ch_width,
2790 				const struct bonded_channel_freq
2791 				**bonded_chan_ptr_ptr,
2792 				enum supported_6g_pwr_types in_6g_pwr_type,
2793 				bool treat_nol_chan_as_disabled,
2794 				uint16_t input_puncture_bitmap)
2795 {
2796 	return CHANNEL_STATE_INVALID;
2797 }
2798 #endif
2799 
2800 #ifdef CONFIG_BAND_6GHZ
2801 /**
2802  * wlan_is_sup_chan_entry_afc_done() - Checks if the super chan entry of given
2803  * channel idx and power mode has REGULATORY_CHAN_AFC_NOT_DONE flag cleared.
2804  *
2805  * @pdev: pdev pointer
2806  * @chan_idx: input channel idx
2807  * @in_6g_pwr_mode: input power mode
2808  *
2809  * Return: True if REGULATORY_CHAN_AFC_NOT_DONE flag is clear for the super
2810  * chan entry.
2811  */
2812 bool
2813 wlan_is_sup_chan_entry_afc_done(struct wlan_objmgr_pdev *pdev,
2814 				enum channel_enum chan_idx,
2815 				enum supported_6g_pwr_types in_6g_pwr_mode);
2816 
2817 /**
2818  * wlan_reg_display_super_chan_list() - Display super channel list for all modes
2819  * @pdev: Pointer to pdev
2820  *
2821  * Return: QDF_STATUS
2822  */
2823 QDF_STATUS
2824 wlan_reg_display_super_chan_list(struct wlan_objmgr_pdev *pdev);
2825 
2826 #if defined(CONFIG_AFC_SUPPORT) && defined(CONFIG_BAND_6GHZ)
2827 /**
2828  * wlan_reg_get_afc_freq_range_and_psd_limits() - Get freq range and psd
2829  * limits from afc server response.
2830  *
2831  * @pdev: Pointer to pdev
2832  * @num_freq_obj: Number of frequency objects
2833  * @afc_obj: Pointer to struct afc_freq_obj
2834  *
2835  * Return: QDF_STATUS
2836  */
2837 
2838 QDF_STATUS
2839 wlan_reg_get_afc_freq_range_and_psd_limits(struct wlan_objmgr_pdev *pdev,
2840 					   uint8_t num_freq_obj,
2841 					   struct afc_freq_obj *afc_obj);
2842 
2843 /**
2844  * wlan_reg_get_num_afc_freq_obj() - Get number of afc frequency objects
2845  *
2846  * @pdev: Pointer to pdev
2847  * @num_freq_obj: Number of frequency objects
2848  *
2849  * Return: QDF_STATUS
2850  */
2851 QDF_STATUS
2852 wlan_reg_get_num_afc_freq_obj(struct wlan_objmgr_pdev *pdev,
2853 			      uint8_t *num_freq_obj);
2854 
2855 /**
2856  * wlan_reg_set_afc_power_event_received() - Set power event received flag with
2857  * given val.
2858  * @pdev: pdev pointer.
2859  * @val: value to be set
2860  *
2861  * Return: QDF_STATUS
2862  */
2863 QDF_STATUS wlan_reg_set_afc_power_event_received(struct wlan_objmgr_pdev *pdev,
2864 						 bool val);
2865 #endif
2866 
2867 #else
2868 static inline bool
2869 wlan_is_sup_chan_entry_afc_done(struct wlan_objmgr_pdev *pdev,
2870 				enum channel_enum chan_idx,
2871 				enum supported_6g_pwr_types in_6g_pwr_mode)
2872 {
2873 	return false;
2874 }
2875 
2876 static inline QDF_STATUS
2877 wlan_reg_display_super_chan_list(struct wlan_objmgr_pdev *pdev)
2878 {
2879 	return QDF_STATUS_E_NOSUPPORT;
2880 }
2881 
2882 #endif
2883 
2884 /**
2885  * wlan_reg_get_num_rules_of_ap_pwr_type() - Get the number of reg rules
2886  * present for a given ap power type
2887  * @pdev: Pointer to pdev
2888  * @ap_pwr_type: AP power type
2889  *
2890  * Return: Return the number of reg rules for a given ap power type
2891  */
2892 uint8_t
2893 wlan_reg_get_num_rules_of_ap_pwr_type(struct wlan_objmgr_pdev *pdev,
2894 				      enum reg_6g_ap_type ap_pwr_type);
2895 
2896 /**
2897  * wlan_reg_register_is_chan_connected_callback() - Register callback to check
2898  *                                                  if channel is connected.
2899  * @psoc: Pointer to global psoc structure.
2900  * @cbk: Pointer to callback function.
2901  *
2902  * Return: None
2903  */
2904 void
2905 wlan_reg_register_is_chan_connected_callback(struct wlan_objmgr_psoc *psoc,
2906 					     void *cbk);
2907 
2908 /**
2909  * wlan_reg_unregister_is_chan_connected_callback() - Unregister callback to
2910  * check if channel is connected.
2911  * @psoc: Pointer to global psoc structure.
2912  * @cbk: Pointer to callback function.
2913  *
2914  * Return: None
2915  */
2916 void
2917 wlan_reg_unregister_is_chan_connected_callback(struct wlan_objmgr_psoc *psoc,
2918 					       void *cbk);
2919 #endif
2920