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