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