xref: /wlan-dirver/qca-wifi-host-cmn/umac/regulatory/core/src/reg_services_common.h (revision 8b3dca18206e1a0461492f082fa6e270b092c035)
1 /*
2  * Copyright (c) 2017-2021 The Linux Foundation. All rights reserved.
3  * Copyright (c) 2021-2022 Qualcomm Innovation Center, Inc. All rights reserved.
4  *
5  *
6  * Permission to use, copy, modify, and/or distribute this software for
7  * any purpose with or without fee is hereby granted, provided that the
8  * above copyright notice and this permission notice appear in all
9  * copies.
10  *
11  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
12  * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
13  * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
14  * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
15  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
16  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
17  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
18  * PERFORMANCE OF THIS SOFTWARE.
19  */
20 
21 /**
22  * DOC: reg_services.h
23  * This file provides prototypes of the regulatory component
24  * service functions
25  */
26 
27 #ifndef __REG_SERVICES_COMMON_H_
28 #define __REG_SERVICES_COMMON_H_
29 
30 #ifdef CONFIG_AFC_SUPPORT
31 #include <wlan_reg_afc.h>
32 #endif
33 
34 #define IS_VALID_PSOC_REG_OBJ(psoc_priv_obj) (psoc_priv_obj)
35 #define IS_VALID_PDEV_REG_OBJ(pdev_priv_obj) (pdev_priv_obj)
36 #define FREQ_TO_CHAN_SCALE     5
37 /* The distance between the 80Mhz center and the nearest 20Mhz channel */
38 #define NEAREST_20MHZ_CHAN_FREQ_OFFSET     10
39 #define NUM_20_MHZ_CHAN_IN_40_MHZ_CHAN     2
40 #define NUM_20_MHZ_CHAN_IN_80_MHZ_CHAN     4
41 #define NUM_20_MHZ_CHAN_IN_160_MHZ_CHAN    8
42 #define NUM_20_MHZ_CHAN_IN_320_MHZ_CHAN    16
43 
44 #define REG_MAX_5GHZ_CH_NUM channel_map[MAX_5GHZ_CHANNEL].chan_num
45 
46 #define REG_MIN_24GHZ_CH_FREQ channel_map[MIN_24GHZ_CHANNEL].center_freq
47 #define REG_MAX_24GHZ_CH_FREQ channel_map[MAX_24GHZ_CHANNEL].center_freq
48 
49 #define REG_IS_24GHZ_CH_FREQ(freq) \
50 	(((freq) >= REG_MIN_24GHZ_CH_FREQ) &&   \
51 	((freq) <= REG_MAX_24GHZ_CH_FREQ))
52 
53 #ifdef CONFIG_CHAN_FREQ_API
54 #define REG_MIN_5GHZ_CH_FREQ channel_map[MIN_5GHZ_CHANNEL].center_freq
55 #define REG_MAX_5GHZ_CH_FREQ channel_map[MAX_5GHZ_CHANNEL].center_freq
56 #endif /* CONFIG_CHAN_FREQ_API */
57 
58 #ifdef CONFIG_49GHZ_CHAN
59 #define REG_MIN_49GHZ_CH_FREQ channel_map[MIN_49GHZ_CHANNEL].center_freq
60 #define REG_MAX_49GHZ_CH_FREQ channel_map[MAX_49GHZ_CHANNEL].center_freq
61 #else
62 #define REG_MIN_49GHZ_CH_FREQ 0
63 #define REG_MAX_49GHZ_CH_FREQ 0
64 #endif /* CONFIG_49GHZ_CHAN */
65 
66 #define REG_IS_49GHZ_FREQ(freq) \
67 	(((freq) >= REG_MIN_49GHZ_CH_FREQ) &&   \
68 	((freq) <= REG_MAX_49GHZ_CH_FREQ))
69 
70 
71 #define REG_IS_5GHZ_FREQ(freq) \
72 	(((freq) >= channel_map[MIN_5GHZ_CHANNEL].center_freq) &&	\
73 	 ((freq) <= channel_map[MAX_5GHZ_CHANNEL].center_freq))
74 
75 /*
76  * It should be 2.5 MHz actually but since we are using integer use 2
77  * instead, which does not create any problem in the start edge calculation.
78  */
79 #define HALF_5MHZ_BW     2
80 #define HALF_20MHZ_BW    10
81 #define HALF_40MHZ_BW    20
82 #define HALF_80MHZ_BW    40
83 #define HALF_160MHZ_BW   80
84 
85 #define TWO_GIG_STARTING_EDGE_FREQ (channel_map_global[MIN_24GHZ_CHANNEL]. \
86 				  center_freq - HALF_20MHZ_BW)
87 #define TWO_GIG_ENDING_EDGE_FREQ   (channel_map_global[MAX_24GHZ_CHANNEL]. \
88 				  center_freq + HALF_20MHZ_BW)
89 #ifdef CONFIG_49GHZ_CHAN
90 #define FIVE_GIG_STARTING_EDGE_FREQ (channel_map_global[MIN_49GHZ_CHANNEL]. \
91 				  center_freq - HALF_5MHZ_BW)
92 #else
93 #define FIVE_GIG_STARTING_EDGE_FREQ (channel_map_global[MIN_5GHZ_CHANNEL]. \
94 				  center_freq - HALF_20MHZ_BW)
95 #endif /* CONFIG_49GHZ_CHAN */
96 #define FIVE_GIG_ENDING_EDGE_FREQ   (channel_map_global[MAX_5GHZ_CHANNEL]. \
97 				  center_freq + HALF_20MHZ_BW)
98 
99 #ifdef CONFIG_BAND_6GHZ
100 #define SIX_GIG_STARTING_EDGE_FREQ  (channel_map_global[MIN_6GHZ_CHANNEL]. \
101 				  center_freq - HALF_20MHZ_BW)
102 #define SIX_GIG_ENDING_EDGE_FREQ    (channel_map_global[MAX_6GHZ_CHANNEL]. \
103 				  center_freq + HALF_20MHZ_BW)
104 #define SIXG_START_FREQ         5950
105 #define FREQ_LEFT_SHIFT         55
106 #define SIX_GHZ_NON_ORPHAN_START_FREQ \
107 	(channel_map_global[MIN_6GHZ_NON_ORPHAN_CHANNEL].center_freq  - 5)
108 #define CHAN_FREQ_5935          5935
109 #define NUM_80MHZ_BAND_IN_6G    16
110 #define NUM_PSC_FREQ            15
111 #define PSC_BAND_MHZ (FREQ_TO_CHAN_SCALE * NUM_80MHZ_BAND_IN_6G)
112 #define REG_MIN_6GHZ_CHAN_FREQ channel_map[MIN_6GHZ_CHANNEL].center_freq
113 #define REG_MAX_6GHZ_CHAN_FREQ channel_map[MAX_6GHZ_CHANNEL].center_freq
114 #else
115 #define FREQ_LEFT_SHIFT         0
116 #define SIX_GHZ_NON_ORPHAN_START_FREQ       0
117 #define CHAN_FREQ_5935          0
118 #define NUM_80MHZ_BAND_IN_6G    0
119 #define NUM_PSC_FREQ            0
120 #define PSC_BAND_MHZ (FREQ_TO_CHAN_SCALE * NUM_80MHZ_BAND_IN_6G)
121 #define REG_MIN_6GHZ_CHAN_FREQ  0
122 #define REG_MAX_6GHZ_CHAN_FREQ  0
123 #endif /*CONFIG_BAND_6GHZ*/
124 
125 #define REG_CH_NUM(ch_enum) channel_map[ch_enum].chan_num
126 #define REG_CH_TO_FREQ(ch_enum) channel_map[ch_enum].center_freq
127 
128 /* EEPROM setting is a country code */
129 #define    COUNTRY_ERD_FLAG     0x8000
130 #define MIN_6GHZ_OPER_CLASS 131
131 #define MAX_6GHZ_OPER_CLASS 137
132 
133 #ifdef CONFIG_AFC_SUPPORT
134 #define DEFAULT_REQ_ID 11235813
135 /* default minimum power in dBm units */
136 #define DEFAULT_MIN_POWER    (-10)
137 #define DEFAULT_NUM_FREQS       1
138 
139 /* Have the entire 6Ghz band as single range */
140 #define DEFAULT_LOW_6GFREQ    5925
141 #define DEFAULT_HIGH_6GFREQ   7125
142 #endif
143 
144 #define SIXG_CHAN_2           2
145 #ifdef CONFIG_BAND_6GHZ
146 #define CHAN_ENUM_SIXG_2      CHAN_ENUM_5935
147 #else
148 #define CHAN_ENUM_SIXG_2      INVALID_CHANNEL
149 #endif
150 
151 /* The eirp power values are in 0.01dBm units */
152 #define EIRP_PWR_SCALE 100
153 
154 extern const struct chan_map *channel_map;
155 extern const struct chan_map channel_map_us[];
156 extern const struct chan_map channel_map_eu[];
157 extern const struct chan_map channel_map_jp[];
158 extern const struct chan_map channel_map_china[];
159 extern const struct chan_map channel_map_global[];
160 
161 #ifdef WLAN_FEATURE_11BE
162 #define ALL_SCHANS_PUNC 0xFFFF /* all subchannels punctured */
163 #endif
164 
165 #define CHAN_FREQ_5660 5660
166 #define CHAN_FREQ_5720 5720
167 
168 #define PRIM_SEG_IEEE_CENTER_240MHZ_5G_CHAN 146
169 #define PRIM_SEG_FREQ_CENTER_240MHZ_5G_CHAN 5730
170 
171 #ifdef CONFIG_AFC_SUPPORT
172 /**
173  * struct afc_cb_handler - defines structure for afc request received  event
174  * handler call back function and argument
175  * @func: handler function pointer
176  * @arg: argument to handler function
177  */
178 struct afc_cb_handler {
179 	afc_req_rx_evt_handler func;
180 	void *arg;
181 };
182 
183 /**
184  * struct afc_pow_evt_cb_handler - defines structure for afc power received
185  * event  handler call back function and argument
186  * @func: handler function pointer
187  * @arg: argument to handler function
188  */
189 struct afc_pow_evt_cb_handler {
190 	afc_power_tx_evt_handler func;
191 	void *arg;
192 };
193 
194 /**
195  * reg_init_freq_range() - Initialize a freq_range object
196  * @left: The left frequency range
197  * @right: The right frequency range
198  *
199  * Return: The initialized freq_range object
200  */
201 struct freq_range
202 reg_init_freq_range(qdf_freq_t left, qdf_freq_t right);
203 #endif
204 /**
205  * get_next_lower_bandwidth() - Get next lower bandwidth
206  * @ch_width: Channel width
207  *
208  * Return: Channel width
209  */
210 enum phy_ch_width get_next_lower_bandwidth(enum phy_ch_width ch_width);
211 
212 /**
213  * reg_read_default_country() - Get the default regulatory country
214  * @psoc: The physical SoC to get default country from
215  * @country_code: the buffer to populate the country code into
216  *
217  * Return: QDF_STATUS
218  */
219 QDF_STATUS reg_read_default_country(struct wlan_objmgr_psoc *psoc,
220 				    uint8_t *country_code);
221 
222 /**
223  * reg_get_ctry_idx_max_bw_from_country_code() - Get the max 5G bandwidth
224  * from country code
225  * @pdev: Pointer to pdev
226  * @cc: Country Code
227  * @max_bw_5g: Max 5G bandwidth supported by the country
228  *
229  * Return: QDF_STATUS
230  */
231 
232 QDF_STATUS reg_get_max_5g_bw_from_country_code(struct wlan_objmgr_pdev *pdev,
233 					       uint16_t cc,
234 					       uint16_t *max_bw_5g);
235 
236 /**
237  * reg_get_max_5g_bw_from_regdomain() - Get the max 5G bandwidth
238  * supported by the regdomain
239  * @pdev: Pointer to pdev
240  * @orig_regdmn: Regdomain pair value
241  * @max_bw_5g: Max 5G bandwidth supported by the country
242  *
243  * Return: QDF_STATUS
244  */
245 
246 QDF_STATUS reg_get_max_5g_bw_from_regdomain(struct wlan_objmgr_pdev *pdev,
247 					    uint16_t regdmn,
248 					    uint16_t *max_bw_5g);
249 
250 /**
251  * reg_get_current_dfs_region () - Get the current dfs region
252  * @pdev: Pointer to pdev
253  * @dfs_reg: pointer to dfs region
254  *
255  * Return: None
256  */
257 void reg_get_current_dfs_region(struct wlan_objmgr_pdev *pdev,
258 				enum dfs_reg *dfs_reg);
259 
260 /**
261  * reg_get_bw_value() - give bandwidth value
262  * bw: bandwidth enum
263  *
264  * Return: uint16_t
265  */
266 uint16_t reg_get_bw_value(enum phy_ch_width bw);
267 
268 /**
269  * reg_set_dfs_region () - Set the current dfs region
270  * @pdev: Pointer to pdev
271  * @dfs_reg: pointer to dfs region
272  *
273  * Return: None
274  */
275 void reg_set_dfs_region(struct wlan_objmgr_pdev *pdev,
276 			enum dfs_reg dfs_reg);
277 
278 /**
279  * reg_program_chan_list() - Set user country code and populate the channel list
280  * @pdev: Pointer to pdev
281  * @rd: Pointer to cc_regdmn_s structure
282  *
283  * Return: QDF_STATUS
284  */
285 QDF_STATUS reg_program_chan_list(struct wlan_objmgr_pdev *pdev,
286 				 struct cc_regdmn_s *rd);
287 
288 /**
289  * reg_freq_to_chan() - Get channel number from frequency.
290  * @pdev: Pointer to pdev
291  * @freq: Channel frequency
292  *
293  * Return: Channel number if success, otherwise 0
294  */
295 uint8_t reg_freq_to_chan(struct wlan_objmgr_pdev *pdev, qdf_freq_t freq);
296 
297 /**
298  * reg_legacy_chan_to_freq() - Get freq from chan noumber, for 2G and 5G
299  * @pdev: Pointer to pdev
300  * @chan_num: Channel number
301  *
302  * Return: Channel frequency if success, otherwise 0
303  */
304 uint16_t reg_legacy_chan_to_freq(struct wlan_objmgr_pdev *pdev,
305 				 uint8_t chan_num);
306 
307 /**
308  * reg_get_current_cc() - Get current country code
309  * @pdev: Pdev pointer
310  * @regdmn: Pointer to get current country values
311  *
312  * Return: QDF_STATUS
313  */
314 QDF_STATUS reg_get_current_cc(struct wlan_objmgr_pdev *pdev,
315 			      struct cc_regdmn_s *rd);
316 
317 /**
318  * reg_set_regdb_offloaded() - set/clear regulatory offloaded flag
319  *
320  * @psoc: psoc pointer
321  * Return: Success or Failure
322  */
323 QDF_STATUS reg_set_regdb_offloaded(struct wlan_objmgr_psoc *psoc, bool val);
324 
325 /**
326  * reg_get_curr_regdomain() - Get current regdomain in use
327  * @pdev: pdev pointer
328  * @cur_regdmn: Current regdomain info
329  *
330  * Return: QDF status
331  */
332 QDF_STATUS reg_get_curr_regdomain(struct wlan_objmgr_pdev *pdev,
333 				  struct cur_regdmn_info *cur_regdmn);
334 
335 /**
336  * reg_modify_chan_144() - Enable/Disable channel 144
337  * @pdev: pdev pointer
338  * @en_chan_144: flag to disable/enable channel 144
339  *
340  * Return: Success or Failure
341  */
342 QDF_STATUS reg_modify_chan_144(struct wlan_objmgr_pdev *pdev, bool en_chan_144);
343 
344 /**
345  * reg_get_en_chan_144() - get en_chan_144 flag value
346  * @pdev: pdev pointer
347  *
348  * Return: en_chan_144 flag value
349  */
350 bool reg_get_en_chan_144(struct wlan_objmgr_pdev *pdev);
351 
352 /**
353  * reg_get_hal_reg_cap() - Get HAL REG capabilities
354  * @psoc: psoc for country information
355  *
356  * Return: hal reg cap pointer
357  */
358 struct wlan_psoc_host_hal_reg_capabilities_ext *reg_get_hal_reg_cap(
359 		struct wlan_objmgr_psoc *psoc);
360 
361 /**
362  * reg_set_hal_reg_cap() - Set HAL REG capabilities
363  * @psoc: psoc for country information
364  * @reg_cap: Regulatory caps pointer
365  * @phy_cnt: number of phy
366  *
367  * Return: hal reg cap pointer
368  */
369 QDF_STATUS reg_set_hal_reg_cap(
370 		struct wlan_objmgr_psoc *psoc,
371 		struct wlan_psoc_host_hal_reg_capabilities_ext *reg_cap,
372 		uint16_t phy_cnt);
373 
374 /**
375  * reg_update_hal_reg_cap() - Update HAL REG capabilities
376  * @psoc: psoc pointer
377  * @wireless_modes: 11AX wireless modes
378  * @phy_id: phy id
379  *
380  * Return: QDF_STATUS
381  */
382 QDF_STATUS reg_update_hal_reg_cap(struct wlan_objmgr_psoc *psoc,
383 				  uint64_t wireless_modes, uint8_t phy_id);
384 
385 /**
386  * reg_chan_in_range() - Check if the given channel is in pdev's channel range
387  * @chan_list: Pointer to regulatory channel list.
388  * @low_freq_2g: Low frequency 2G.
389  * @high_freq_2g: High frequency 2G.
390  * @low_freq_5g: Low frequency 5G.
391  * @high_freq_5g: High frequency 5G.
392  * @ch_enum: Channel enum.
393  *
394  * Return: true if ch_enum is with in pdev's channel range, else false.
395  */
396 bool reg_chan_in_range(struct regulatory_channel *chan_list,
397 		       qdf_freq_t low_freq_2g, qdf_freq_t high_freq_2g,
398 		       qdf_freq_t low_freq_5g, qdf_freq_t high_freq_5g,
399 		       enum channel_enum ch_enum);
400 
401 /**
402  * reg_init_channel_map() - Initialize the channel list based on the dfs region.
403  * @dfs_region: Dfs region
404  */
405 void reg_init_channel_map(enum dfs_reg dfs_region);
406 
407 /**
408  * reg_get_psoc_tx_ops() - Get regdb tx ops
409  * @psoc: Pointer to psoc structure
410  */
411 struct wlan_lmac_if_reg_tx_ops *reg_get_psoc_tx_ops(
412 	struct wlan_objmgr_psoc *psoc);
413 
414 /**
415  * reg_is_24ghz_ch_freq() - Check if the given channel frequency is 2.4GHz
416  * @freq: Channel frequency
417  *
418  * Return: true if channel frequency is 2.4GHz, else false
419  */
420 bool reg_is_24ghz_ch_freq(uint32_t freq);
421 
422 /**
423  * reg_is_5ghz_ch_freq() - Check if the given channel frequency is 5GHz
424  * @freq: Channel frequency
425  *
426  * Return: true if channel frequency is 5GHz, else false
427  */
428 bool reg_is_5ghz_ch_freq(uint32_t freq);
429 
430 /**
431  * reg_is_range_overlap_2g() - Check if the given low_freq and high_freq
432  * is in the 2G range.
433  *
434  * @low_freq - Low frequency.
435  * @high_freq - High frequency.
436  *
437  * Return: Return true if given low_freq and high_freq overlaps 2G range,
438  * else false.
439  */
440 bool reg_is_range_overlap_2g(qdf_freq_t low_freq, qdf_freq_t high_freq);
441 
442 /**
443  * reg_is_range_overlap_5g() - Check if the given low_freq and high_freq
444  * is in the 5G range.
445  *
446  * @low_freq - Low frequency.
447  * @high_freq - High frequency.
448  *
449  * Return: Return true if given low_freq and high_freq overlaps 5G range,
450  * else false.
451  */
452 bool reg_is_range_overlap_5g(qdf_freq_t low_freq, qdf_freq_t high_freq);
453 
454 /**
455  * reg_is_freq_indoor() - Check if the input frequency is an indoor frequency.
456  * @pdev: Pointer to pdev.
457  * @freq: Channel frequency.
458  *
459  * Return: Return true if the input frequency is indoor, else false.
460  */
461 bool reg_is_freq_indoor(struct wlan_objmgr_pdev *pdev, qdf_freq_t freq);
462 
463 /**
464  * reg_get_min_chwidth() - Return min chanwidth supported by freq.
465  * @pdev: Pointer to pdev.
466  * @freq: Channel frequency.
467  *
468  * Return: Min chwidth supported by freq as per regulatory DB.
469  */
470 uint16_t reg_get_min_chwidth(struct wlan_objmgr_pdev *pdev, qdf_freq_t freq);
471 
472 /**
473  * reg_get_max_chwidth() - Return max chanwidth supported by freq.
474  * @pdev: Pointer to pdev.
475  * @freq: Channel frequency.
476  *
477  * Return: Max chwidth supported by freq as per regulatory DB.
478  */
479 uint16_t reg_get_max_chwidth(struct wlan_objmgr_pdev *pdev, qdf_freq_t freq);
480 
481 #ifdef CONFIG_REG_CLIENT
482 /**
483  * reg_is_freq_indoor_in_secondary_list() - Check if the input frequency is
484  * an indoor frequency in the secondary channel list
485  * @pdev: Pointer to pdev.
486  * @freq: Channel frequency.
487  *
488  * Return: Return true if the input frequency is indoor, else false.
489  */
490 bool reg_is_freq_indoor_in_secondary_list(struct wlan_objmgr_pdev *pdev,
491 					  qdf_freq_t freq);
492 #endif
493 
494 #ifdef CONFIG_BAND_6GHZ
495 /**
496  * reg_is_6ghz_chan_freq() - Check if the given channel frequency is 6GHz
497  * @freq: Channel frequency
498  *
499  * Return: true if channel frequency is 6GHz, else false
500  */
501 bool reg_is_6ghz_chan_freq(uint16_t freq);
502 
503 #ifdef CONFIG_6G_FREQ_OVERLAP
504 /**
505  * reg_is_range_only6g() - Check if the given low_freq and high_freq is only in
506  * the 6G range.
507  *
508  * @low_freq - Low frequency.
509  * @high_freq - High frequency.
510  *
511  * Return: Return true if given low_freq and high_freq overlaps only the 6G
512  * range, else false.
513  */
514 bool reg_is_range_only6g(qdf_freq_t low_freq, qdf_freq_t high_freq);
515 
516 /**
517  * reg_is_range_overlap_6g() - Check if the given low_freq and high_freq
518  * is in the 6G range.
519  *
520  * @low_freq - Low frequency.
521  * @high_freq - High frequency.
522  *
523  * Return: Return true if given low_freq and high_freq overlaps 6G range,
524  * else false.
525  */
526 bool reg_is_range_overlap_6g(qdf_freq_t low_freq, qdf_freq_t high_freq);
527 #endif
528 
529 /**
530  * REG_IS_6GHZ_FREQ() - Check if the given channel frequency is 6GHz
531  * @freq: Channel frequency
532  *
533  * Return: true if channel frequency is 6GHz, else false
534  */
535 static inline bool REG_IS_6GHZ_FREQ(uint16_t freq)
536 {
537 	return ((freq >= REG_MIN_6GHZ_CHAN_FREQ) &&
538 		(freq <= REG_MAX_6GHZ_CHAN_FREQ));
539 }
540 
541 /**
542  * reg_is_6ghz_psc_chan_freq() - Check if the given 6GHz channel frequency is
543  * preferred scanning channel frequency.
544  * @freq: Channel frequency
545  *
546  * Return: true if given 6GHz channel frequency is preferred scanning channel
547  * frequency, else false
548  */
549 bool reg_is_6ghz_psc_chan_freq(uint16_t freq);
550 
551 /**
552  * reg_is_6g_freq_indoor() - Check if a 6GHz frequency is indoor.
553  * @pdev: Pointer to pdev.
554  * @freq: Channel frequency.
555  *
556  * Return: Return true if a 6GHz frequency is indoor, else false.
557  */
558 bool reg_is_6g_freq_indoor(struct wlan_objmgr_pdev *pdev, qdf_freq_t freq);
559 
560 /**
561  * reg_get_max_txpower_for_6g_tpe() - Get max txpower for 6G TPE IE.
562  * @pdev: Pointer to pdev.
563  * @freq: Channel frequency.
564  * @bw: Channel bandwidth.
565  * @reg_ap: Regulatory 6G AP type.
566  * @reg_client: Regulatory 6G client type.
567  * @is_psd: True if txpower is needed in PSD format, and false if needed in EIRP
568  * format.
569  * @tx_power: Pointer to tx-power.
570  *
571  * Return: Return QDF_STATUS_SUCCESS, if tx_power is filled for 6G TPE IE
572  * else return QDF_STATUS_E_FAILURE.
573  */
574 QDF_STATUS reg_get_max_txpower_for_6g_tpe(struct wlan_objmgr_pdev *pdev,
575 					  qdf_freq_t freq, uint8_t bw,
576 					  enum reg_6g_ap_type reg_ap,
577 					  enum reg_6g_client_type reg_client,
578 					  bool is_psd,
579 					  uint8_t *tx_power);
580 
581 /**
582  * reg_min_6ghz_chan_freq() - Get minimum 6GHz channel center frequency
583  *
584  * Return: Minimum 6GHz channel center frequency
585  */
586 uint16_t reg_min_6ghz_chan_freq(void);
587 
588 /**
589  * reg_max_6ghz_chan_freq() - Get maximum 6GHz channel center frequency
590  *
591  * Return: Maximum 6GHz channel center frequency
592  */
593 uint16_t reg_max_6ghz_chan_freq(void);
594 #else
595 static inline bool reg_is_6ghz_chan_freq(uint16_t freq)
596 {
597 	return false;
598 }
599 
600 static inline bool
601 reg_is_6g_freq_indoor(struct wlan_objmgr_pdev *pdev, qdf_freq_t freq)
602 {
603 	return false;
604 }
605 
606 static inline QDF_STATUS
607 reg_get_max_txpower_for_6g_tpe(struct wlan_objmgr_pdev *pdev,
608 			       qdf_freq_t freq, uint8_t bw,
609 			       enum reg_6g_ap_type reg_ap,
610 			       enum reg_6g_client_type reg_client,
611 			       bool is_psd,
612 			       uint8_t *tx_power)
613 {
614 	return QDF_STATUS_E_FAILURE;
615 }
616 
617 #ifdef CONFIG_6G_FREQ_OVERLAP
618 static inline bool reg_is_range_overlap_6g(qdf_freq_t low_freq,
619 					   qdf_freq_t high_freq)
620 {
621 	return false;
622 }
623 
624 static inline bool reg_is_range_only6g(qdf_freq_t low_freq,
625 				       qdf_freq_t high_freq)
626 {
627 	return false;
628 }
629 #endif
630 
631 static inline bool REG_IS_6GHZ_FREQ(uint16_t freq)
632 {
633 	return false;
634 }
635 
636 static inline bool reg_is_6ghz_psc_chan_freq(uint16_t freq)
637 {
638 	return false;
639 }
640 
641 static inline uint16_t reg_min_6ghz_chan_freq(void)
642 {
643 	return 0;
644 }
645 
646 static inline uint16_t reg_max_6ghz_chan_freq(void)
647 {
648 	return 0;
649 }
650 #endif /* CONFIG_BAND_6GHZ */
651 
652 /**
653  * reg_get_band_channel_list() - Caller function to
654  * reg_get_band_from_cur_chan_list with primary current channel list
655  * @pdev: pdev ptr
656  * @band_mask: Input bitmap with band set
657  * @channel_list: Pointer to Channel List
658  *
659  * Caller function to reg_get_band_from_cur_chan_listto get the primary channel
660  * list and number of channels (for non-beaconing entities).
661  *
662  * Return: Number of channels, else 0 to indicate error
663  */
664 uint16_t reg_get_band_channel_list(struct wlan_objmgr_pdev *pdev,
665 				   uint8_t band_mask,
666 				   struct regulatory_channel *channel_list);
667 
668 #ifdef CONFIG_REG_6G_PWRMODE
669 /**
670  * reg_get_band_channel_list() - Caller function to
671  * reg_get_band_from_cur_chan_list with primary current channel list
672  * @pdev: pdev ptr
673  * @band_mask: Input bitmap with band set
674  * @channel_list: Pointer to Channel List
675  * @in_6g_pwr_type: 6g power type which decides 6G channel list lookup.
676  *
677  * Caller function to reg_get_band_from_cur_chan_listto get the primary channel
678  * list and number of channels (for non-beaconing entities).
679  *
680  * Return: Number of channels, else 0 to indicate error
681  */
682 uint16_t reg_get_band_channel_list_for_pwrmode(struct wlan_objmgr_pdev *pdev,
683 					       uint8_t band_mask,
684 					       struct regulatory_channel
685 					       *channel_list,
686 					       enum supported_6g_pwr_types
687 					       in_6g_pwr_type);
688 #endif
689 
690 #ifdef CONFIG_REG_CLIENT
691 /**
692  * reg_get_secondary_band_channel_list() - Caller function to
693  * reg_get_band_from_cur_chan_list with secondary current channel list
694  * @pdev: pdev ptr
695  * @band_mask: Input bitmap with band set
696  * @channel_list: Pointer to Channel List
697  *
698  * Caller function to reg_get_band_from_cur_chan_list to get the secondary
699  * channel list and number of channels (for beaconing entities).
700  *
701  * Return: Number of channels, else 0 to indicate error
702  */
703 uint16_t reg_get_secondary_band_channel_list(struct wlan_objmgr_pdev *pdev,
704 					     uint8_t band_mask,
705 					     struct regulatory_channel
706 					     *channel_list);
707 #endif
708 
709 /**
710  * reg_chan_band_to_freq - Return channel frequency based on the channel number
711  * and band.
712  * @pdev: pdev ptr
713  * @chan: Channel Number
714  * @band_mask: Bitmap for bands
715  *
716  * Return: Return channel frequency or return 0, if the channel is disabled or
717  * if the input channel number or band_mask is invalid. Composite bands are
718  * supported only for 2.4Ghz and 5Ghz bands. For other bands the following
719  * priority is given: 1) 6Ghz 2) 5Ghz 3) 2.4Ghz.
720  */
721 qdf_freq_t reg_chan_band_to_freq(struct wlan_objmgr_pdev *pdev,
722 				 uint8_t chan,
723 				 uint8_t band_mask);
724 
725 /**
726  * reg_is_49ghz_freq() - Check if the given channel frequency is 4.9GHz
727  * @freq: Channel frequency
728  *
729  * Return: true if channel frequency is 4.9GHz, else false
730  */
731 bool reg_is_49ghz_freq(qdf_freq_t freq);
732 
733 /**
734  * reg_ch_num() - Get channel number from channel enum
735  * @ch_enum: Channel enum
736  *
737  * Return: channel number
738  */
739 qdf_freq_t reg_ch_num(uint32_t ch_enum);
740 
741 /**
742  * reg_ch_to_freq() - Get channel frequency from channel enum
743  * @ch_enum: Channel enum
744  *
745  * Return: channel frequency
746  */
747 qdf_freq_t reg_ch_to_freq(uint32_t ch_enum);
748 
749 /**
750  * reg_max_5ghz_ch_num() - Get maximum 5GHz channel number
751  *
752  * Return: Maximum 5GHz channel number
753  */
754 uint8_t reg_max_5ghz_ch_num(void);
755 
756 #ifdef CONFIG_CHAN_FREQ_API
757 /**
758  * reg_min_24ghz_chan_freq() - Get minimum 2.4GHz channel frequency
759  *
760  * Return: Minimum 2.4GHz channel frequency
761  */
762 qdf_freq_t reg_min_24ghz_chan_freq(void);
763 
764 /**
765  * reg_max_24ghz_chan_freq() - Get maximum 2.4GHz channel frequency
766  *
767  * Return: Maximum 2.4GHz channel frequency
768  */
769 qdf_freq_t reg_max_24ghz_chan_freq(void);
770 
771 /**
772  * reg_min_5ghz_chan_freq() - Get minimum 5GHz channel frequency
773  *
774  * Return: Minimum 5GHz channel frequency
775  */
776 qdf_freq_t reg_min_5ghz_chan_freq(void);
777 
778 /**
779  * reg_max_5ghz_chan_freq() - Get maximum 5GHz channel frequency
780  *
781  * Return: Maximum 5GHz channel frequency
782  */
783 qdf_freq_t reg_max_5ghz_chan_freq(void);
784 #endif /* CONFIG_CHAN_FREQ_API */
785 
786 /**
787  * reg_enable_dfs_channels() - Enable the use of DFS channels
788  * @pdev: The physical dev to enable/disable DFS channels for
789  *
790  * Return: QDF_STATUS
791  */
792 QDF_STATUS reg_enable_dfs_channels(struct wlan_objmgr_pdev *pdev, bool enable);
793 
794 #ifdef WLAN_REG_PARTIAL_OFFLOAD
795 /**
796  * reg_program_default_cc() - Program default country code
797  * @pdev: Pdev pointer
798  * @regdmn: Regdomain value
799  *
800  * Return: QDF_STATUS
801  */
802 QDF_STATUS reg_program_default_cc(struct wlan_objmgr_pdev *pdev,
803 				  uint16_t regdmn);
804 
805 /**
806  * reg_is_regdmn_en302502_applicable() - Find if ETSI EN302_502 radar pattern
807  * is applicable in current regulatory domain.
808  * @pdev: Pdev object pointer.
809  *
810  * Return: True if en302_502 is applicable, else false.
811  */
812 bool reg_is_regdmn_en302502_applicable(struct wlan_objmgr_pdev *pdev);
813 #endif
814 
815 /**
816  * reg_update_channel_ranges() - Update the channel ranges with the new
817  * phy capabilities.
818  * @pdev: The physical dev for which channel ranges are to be updated.
819  *
820  * Return: QDF_STATUS.
821  */
822 QDF_STATUS reg_update_channel_ranges(struct wlan_objmgr_pdev *pdev);
823 
824 /**
825  * reg_modify_pdev_chan_range() - Compute current channel list
826  * in accordance with the modified reg caps.
827  * @pdev: The physical dev for which channel list must be built.
828  *
829  * Return: QDF_STATUS
830  */
831 QDF_STATUS reg_modify_pdev_chan_range(struct wlan_objmgr_pdev *pdev);
832 
833 /**
834  * reg_update_pdev_wireless_modes() - Update the wireless_modes in the
835  * pdev_priv_obj with the input wireless_modes
836  * @pdev: pointer to wlan_objmgr_pdev.
837  * @wireless_modes: Wireless modes.
838  *
839  * Return : QDF_STATUS
840  */
841 QDF_STATUS reg_update_pdev_wireless_modes(struct wlan_objmgr_pdev *pdev,
842 					  uint64_t wireless_modes);
843 
844 /**
845  * reg_get_phybitmap() - Get phybitmap from regulatory pdev_priv_obj
846  * @pdev: pdev pointer
847  * @phybitmap: pointer to phybitmap
848  *
849  * Return: QDF STATUS
850  */
851 QDF_STATUS reg_get_phybitmap(struct wlan_objmgr_pdev *pdev,
852 			     uint16_t *phybitmap);
853 #ifdef DISABLE_UNII_SHARED_BANDS
854 /**
855  * reg_disable_chan_coex() - Disable Coexisting channels based on the input
856  * bitmask.
857  * @pdev: pointer to wlan_objmgr_pdev.
858  * unii_5g_bitmap: UNII 5G bitmap.
859  *
860  * Return : QDF_STATUS
861  */
862 QDF_STATUS reg_disable_chan_coex(struct wlan_objmgr_pdev *pdev,
863 				 uint8_t unii_5g_bitmap);
864 #endif
865 
866 #ifdef CONFIG_CHAN_FREQ_API
867 /**
868  * reg_is_freq_present_in_cur_chan_list() - Check the input frequency
869  * @pdev: Pointer to pdev
870  * @freq: Channel center frequency in MHz
871  *
872  * Check if the input channel center frequency is present in the current
873  * channel list
874  *
875  * Return: Return true if channel center frequency is present in the current
876  * channel list, else return false.
877  */
878 bool
879 reg_is_freq_present_in_cur_chan_list(struct wlan_objmgr_pdev *pdev,
880 				     qdf_freq_t freq);
881 
882 /**
883  * reg_get_chan_enum_for_freq() - Get channel enum for given channel frequency
884  * @freq: Channel Frequency
885  *
886  * Return: Channel enum
887  */
888 enum channel_enum reg_get_chan_enum_for_freq(qdf_freq_t freq);
889 
890 /**
891  * reg_get_channel_list_with_power_for_freq() - Provides the channel list with
892  * power
893  * @pdev: Pointer to pdev
894  * @ch_list: Pointer to the channel list.
895  * @num_chan: Pointer to save number of channels
896  *
897  * Return: QDF_STATUS
898  */
899 QDF_STATUS
900 reg_get_channel_list_with_power_for_freq(struct wlan_objmgr_pdev *pdev,
901 					 struct channel_power *ch_list,
902 					 uint8_t *num_chan);
903 
904 /**
905  * reg_get_channel_state_for_freq() - Get channel state from regulatory
906  * @pdev: Pointer to pdev
907  * @freq: channel center frequency.
908  *
909  * Return: channel state
910  */
911 enum channel_state
912 reg_get_channel_state_for_freq(struct wlan_objmgr_pdev *pdev,
913 			       qdf_freq_t freq);
914 
915 #ifdef CONFIG_REG_6G_PWRMODE
916 /**
917  * reg_get_channel_state_for_freq() - Get channel state from regulatory
918  * @pdev: Pointer to pdev
919  * @freq: channel center frequency.
920  * @in_6g_pwr_type: 6g power type which decides 6G channel list lookup.
921  *
922  * Return: channel state
923  */
924 enum channel_state
925 reg_get_channel_state_for_pwrmode(struct wlan_objmgr_pdev *pdev,
926 				  qdf_freq_t freq,
927 				  enum supported_6g_pwr_types in_6g_pwr_type);
928 #endif
929 
930 #ifdef CONFIG_REG_CLIENT
931 /**
932  * reg_get_channel_state_from_secondary_list_for_freq() - Get channel state
933  * from secondary regulatory current channel list
934  * @pdev: Pointer to pdev
935  * @freq: channel center frequency.
936  *
937  * Return: channel state
938  */
939 enum channel_state reg_get_channel_state_from_secondary_list_for_freq(
940 						struct wlan_objmgr_pdev *pdev,
941 						qdf_freq_t freq);
942 
943 /**
944  * reg_get_channel_list_with_power() - Provides the channel list with power
945  * @pdev: Pointer to pdev
946  * @ch_list: Pointer to the channel list.
947  * @num_chan: Pointer to save number of channels
948  * @in_6g_pwr_type: 6G power type corresponding to which 6G channel list is
949  * required
950  *
951  * Return: QDF_STATUS
952  */
953 QDF_STATUS reg_get_channel_list_with_power(
954 				struct wlan_objmgr_pdev *pdev,
955 				struct channel_power *ch_list,
956 				uint8_t *num_chan,
957 				enum supported_6g_pwr_types in_6g_pwr_type);
958 #endif
959 
960 /**
961  * reg_get_5g_bonded_channel_state_for_freq() - Get channel state for
962  * 5G bonded channel using the channel frequency
963  * @pdev: Pointer to pdev
964  * @freq: channel center frequency.
965  * @ch_params: channel parameters
966  * @in_6g_pwr_type: 6g power type which decides 6G channel list lookup.
967  *
968  * Return: channel state
969  */
970 enum channel_state
971 reg_get_5g_bonded_channel_state_for_freq(struct wlan_objmgr_pdev *pdev,
972 					 qdf_freq_t freq,
973 					 struct ch_params *ch_params);
974 
975 #ifdef CONFIG_REG_6G_PWRMODE
976 enum channel_state
977 reg_get_5g_bonded_channel_state_for_pwrmode(struct wlan_objmgr_pdev *pdev,
978 					    qdf_freq_t freq,
979 					    struct ch_params *ch_params,
980 					    enum supported_6g_pwr_types
981 					    in_6g_pwr_mode);
982 #endif
983 
984 /**
985  * reg_get_2g_bonded_channel_state_for_freq() - Get channel state for 2G
986  * bonded channel
987  * @freq: channel center frequency.
988  * @pdev: Pointer to pdev
989  * @oper_ch_freq: Primary channel center frequency
990  * @sec_ch_freq: Secondary channel center frequency
991  * @bw: channel band width
992  *
993  * Return: channel state
994  */
995 enum channel_state
996 reg_get_2g_bonded_channel_state_for_freq(struct wlan_objmgr_pdev *pdev,
997 					 qdf_freq_t oper_ch_freq,
998 					 qdf_freq_t sec_ch_freq,
999 					 enum phy_ch_width bw);
1000 
1001 /**
1002  * reg_set_channel_params_for_freq () - Sets channel parameteres for given
1003  * bandwidth
1004  * @pdev: Pointer to pdev
1005  * @freq: Channel center frequency.
1006  * @sec_ch_2g_freq: Secondary 2G channel frequency
1007  * @ch_params: pointer to the channel parameters.
1008  * @treat_nol_chan_as_disabled: bool to treat nol channel as enabled or
1009  * disabled. If set to true, nol chan is considered as disabled in chan search.
1010  *
1011  * Return: None
1012  */
1013 void reg_set_channel_params_for_freq(struct wlan_objmgr_pdev *pdev,
1014 				     qdf_freq_t freq,
1015 				     qdf_freq_t sec_ch_2g_freq,
1016 				     struct ch_params *ch_params,
1017 				     bool treat_nol_chan_as_disabled);
1018 
1019 #ifdef CONFIG_REG_6G_PWRMODE
1020 /**
1021  * reg_set_channel_params_for_pwrmode () - Sets channel parameteres for given
1022  * bandwidth
1023  * @pdev: Pointer to pdev
1024  * @freq: Channel center frequency.
1025  * @sec_ch_2g_freq: Secondary 2G channel frequency
1026  * @ch_params: pointer to the channel parameters.
1027  * @in_6g_pwr_type: 6g power type which decides 6G channel list lookup.
1028  * @treat_nol_chan_as_disabled: bool to treat nol channel as enabled or
1029  * disabled. If set to true, nol chan is considered as disabled in chan search.
1030  *
1031  * Return: None
1032  */
1033 void reg_set_channel_params_for_pwrmode(struct wlan_objmgr_pdev *pdev,
1034 					qdf_freq_t freq,
1035 					qdf_freq_t sec_ch_2g_freq,
1036 					struct ch_params *ch_params,
1037 					enum supported_6g_pwr_types
1038 					in_6g_pwr_mode,
1039 					bool treat_nol_chan_as_disabled);
1040 #endif
1041 
1042 #ifdef WLAN_FEATURE_11BE
1043 /**
1044  * reg_fill_channel_list() - Fills an array of ch_params (list of
1045  * channels) for the given channel width and primary freq.
1046  * If 320 band_center is given, ch_params corresponding to the
1047  * given band_center is filled.
1048  *
1049  * @pdev: Pointer to pdev
1050  * @freq: Center frequency of the primary channel in MHz
1051  * @sec_ch_2g_freq: Secondary 2G channel frequency in MHZ
1052  * @ch_width: Input channel width.
1053  * @band_center: Center frequency of the 320MHZ channel.
1054  * @chan_list: Pointer to struct reg_channel_list to be filled (Output).
1055  * The caller is supposed to provide enough storage for the elements
1056  * in the list.
1057  * @in_6g_pwr_type: 6g power type which decides 6G channel list lookup.
1058  * @treat_nol_chan_as_disabled: bool to treat nol channel as enabled or
1059  * disabled. If set to true, nol chan is considered as disabled in chan search.
1060  *
1061  * Return: None
1062  */
1063 void
1064 reg_fill_channel_list(struct wlan_objmgr_pdev *pdev,
1065 		      qdf_freq_t freq,
1066 		      qdf_freq_t sec_ch_2g_freq,
1067 		      enum phy_ch_width ch_width,
1068 		      qdf_freq_t band_center_320,
1069 		      struct reg_channel_list *chan_list,
1070 		      bool treat_nol_chan_as_disabled);
1071 
1072 #ifdef CONFIG_REG_6G_PWRMODE
1073 /**
1074  * reg_fill_channel_list_for_pwrmode() - Fills an array of ch_params (list of
1075  * channels) for the given channel width and primary freq.
1076  * If 320 band_center is given, ch_params corresponding to the
1077  * given band_center is filled.
1078  *
1079  * @pdev: Pointer to pdev
1080  * @freq: Center frequency of the primary channel in MHz
1081  * @sec_ch_2g_freq: Secondary 2G channel frequency in MHZ
1082  * @ch_width: Input channel width.
1083  * @band_center: Center frequency of the 320MHZ channel.
1084  * @chan_list: Pointer to struct reg_channel_list to be filled (Output).
1085  * The caller is supposed to provide enough storage for the elements
1086  * in the list.
1087  * @in_6g_pwr_type: 6g power type which decides 6G channel list lookup.
1088  * @treat_nol_chan_as_disabled: bool to treat nol channel as enabled or
1089  * disabled. If set to true, nol chan is considered as disabled in chan search.
1090  *
1091  * Return: None
1092  */
1093 void
1094 reg_fill_channel_list_for_pwrmode(struct wlan_objmgr_pdev *pdev,
1095 				  qdf_freq_t freq,
1096 				  qdf_freq_t sec_ch_2g_freq,
1097 				  enum phy_ch_width ch_width,
1098 				  qdf_freq_t band_center_320,
1099 				  struct reg_channel_list *chan_list,
1100 				  enum supported_6g_pwr_types in_6g_pwr_mode,
1101 				  bool treat_nol_chan_as_disabled);
1102 #endif
1103 
1104 /**
1105  * reg_is_punc_bitmap_valid() - is puncture bitmap valid or not
1106  * @bw: Input channel width.
1107  * @puncture_bitmap Input puncture bitmap.
1108  *
1109  * Return: true if given puncture bitmap is valid
1110  */
1111 bool reg_is_punc_bitmap_valid(enum phy_ch_width bw, uint16_t puncture_bitmap);
1112 
1113 #ifdef QCA_DFS_BW_PUNCTURE
1114 /**
1115  * reg_find_nearest_puncture_pattern() - is generated bitmap is valid or not
1116  * @bw: Input channel width.
1117  * @proposed_bitmap: Input puncture bitmap.
1118  *
1119  * Return: Radar bitmap if it is valid.
1120  */
1121 uint16_t reg_find_nearest_puncture_pattern(enum phy_ch_width bw,
1122 					   uint16_t proposed_bitmap);
1123 #else
1124 static inline
1125 uint16_t reg_find_nearest_puncture_pattern(enum phy_ch_width bw,
1126 					   uint16_t proposed_bitmap)
1127 {
1128 	return 0;
1129 }
1130 #endif /* QCA_DFS_BW_PUNCTURE */
1131 
1132 /**
1133  * reg_extract_puncture_by_bw() - generate new puncture bitmap from original
1134  *                                puncture bitmap and bandwidth based on new
1135  *                                bandwidth
1136  * @ori_bw: original bandwidth
1137  * @ori_puncture_bitmap: original puncture bitmap
1138  * @freq: frequency of primary channel
1139  * @cen320_freq: center frequency of 320 MHZ if channel width is 320
1140  * @new_bw new bandwidth. It should be smaller than original bandwidth
1141  * @new_puncture_bitmap: output of puncture bitmap
1142  *
1143  * Example 1: ori_bw = CH_WIDTH_320MHZ (center 320 = 6105{IEEE31})
1144  * freq = 6075 ( Primary chan location: 0000_000P_0000_0000)
1145  * ori_puncture_bitmap = B1111 0000 0011 0000(binary)
1146  * If new_bw = CH_WIDTH_160MHZ, then new_puncture_bitmap = B0011 0000(binary)
1147  * If new_bw = CH_WIDTH_80MHZ, then new_puncture_bitmap = B0011(binary)
1148  *
1149  * Example 2: ori_bw = CH_WIDTH_320MHZ (center 320 = 6105{IEEE31})
1150  * freq = 6135 ( Primary chan location: 0000_0000_0P00_0000)
1151  * ori_puncture_bitmap = B1111 0000 0011 0000(binary)
1152  * If new_bw = CH_WIDTH_160MHZ, then new_puncture_bitmap = B1111 0000(binary)
1153  * If new_bw = CH_WIDTH_80MHZ, then new_puncture_bitmap = B0000(binary)
1154  *
1155  * Return: QDF_STATUS
1156  */
1157 QDF_STATUS reg_extract_puncture_by_bw(enum phy_ch_width ori_bw,
1158 				      uint16_t ori_puncture_bitmap,
1159 				      qdf_freq_t freq,
1160 				      qdf_freq_t cen320_freq,
1161 				      enum phy_ch_width new_bw,
1162 				      uint16_t *new_puncture_bitmap);
1163 
1164 /**
1165  * reg_set_create_punc_bitmap() - set is_create_punc_bitmap of ch_params
1166  * @ch_params: ch_params to set
1167  * @is_create_punc_bitmap: is create punc bitmap
1168  *
1169  * Return: NULL
1170  */
1171 void reg_set_create_punc_bitmap(struct ch_params *ch_params,
1172 				bool is_create_punc_bitmap);
1173 #else
1174 static inline
1175 QDF_STATUS reg_extract_puncture_by_bw(enum phy_ch_width ori_bw,
1176 				      uint16_t ori_puncture_bitmap,
1177 				      qdf_freq_t freq,
1178 				      qdf_freq_t cen320_freq,
1179 				      enum phy_ch_width new_bw,
1180 				      uint16_t *new_puncture_bitmap)
1181 {
1182 	return QDF_STATUS_SUCCESS;
1183 }
1184 
1185 static inline void reg_set_create_punc_bitmap(struct ch_params *ch_params,
1186 					      bool is_create_punc_bitmap)
1187 {
1188 }
1189 #endif
1190 /**
1191  * reg_get_channel_reg_power_for_freq() - Get the txpower for the given channel
1192  * @pdev: Pointer to pdev
1193  * @freq: Channel frequency
1194  *
1195  * Return: txpower
1196  */
1197 uint8_t reg_get_channel_reg_power_for_freq(struct wlan_objmgr_pdev *pdev,
1198 					   qdf_freq_t freq);
1199 
1200 /**
1201  * reg_update_nol_ch_for_freq () - Updates NOL channels in current channel list
1202  * @pdev: pointer to pdev object
1203  * @chan_freq_list: pointer to NOL channel list
1204  * @num_ch: No.of channels in list
1205  * @update_nol: set/reset the NOL status
1206  *
1207  * Return: None
1208  */
1209 void reg_update_nol_ch_for_freq(struct wlan_objmgr_pdev *pdev,
1210 				uint16_t *chan_freq_list,
1211 				uint8_t num_chan,
1212 				bool nol_chan);
1213 /**
1214  * reg_is_dfs_for_freq () - Checks the channel state for DFS
1215  * @pdev: pdev ptr
1216  * @freq: Channel center frequency
1217  *
1218  * Return: true or false
1219  */
1220 bool reg_is_dfs_for_freq(struct wlan_objmgr_pdev *pdev, qdf_freq_t freq);
1221 
1222 #ifdef CONFIG_REG_CLIENT
1223 /**
1224  * reg_is_dfs_in_secondary_list_for_freq() - Checks the channel state for DFS
1225  * from the secondary channel list
1226  * @pdev: pdev ptr
1227  * @freq: Channel center frequency
1228  *
1229  * Return: true or false
1230  */
1231 bool reg_is_dfs_in_secondary_list_for_freq(struct wlan_objmgr_pdev *pdev,
1232 					   qdf_freq_t freq);
1233 #endif
1234 
1235 /**
1236  * reg_chan_freq_is_49ghz() - Check if the input channel center frequency is
1237  * 4.9GHz
1238  * @pdev: Pdev pointer
1239  * @chan_num: Input channel center frequency
1240  *
1241  * Return: true if the frequency is 4.9GHz else false.
1242  */
1243 bool reg_chan_freq_is_49ghz(qdf_freq_t freq);
1244 
1245 /**
1246  * reg_update_nol_history_ch_for_freq() - Set nol-history flag for the channels
1247  * in the list.
1248  * @pdev: Pdev ptr.
1249  * @chan_list: Input channel freqeuncy list.
1250  * @num_ch: Number of channels.
1251  * @nol_history_ch: NOL-History flag.
1252  *
1253  * Return: void
1254  */
1255 void reg_update_nol_history_ch_for_freq(struct wlan_objmgr_pdev *pdev,
1256 					uint16_t *chan_list,
1257 					uint8_t num_chan,
1258 					bool nol_history_chan);
1259 
1260 /**
1261  * reg_is_same_5g_band_freqs() - Check if given channel center
1262  * frequencies have same band
1263  * @freq1: Channel Center Frequency 1
1264  * @freq2: Channel Center Frequency 2
1265  *
1266  * Return: true if both the frequencies has the same band.
1267  */
1268 bool reg_is_same_band_freqs(qdf_freq_t freq1, qdf_freq_t freq2);
1269 
1270 /**
1271  * reg_freq_to_band() - Get band from channel frequency
1272  * @chan_num: channel frequency
1273  *
1274  * Return: wifi band
1275  */
1276 enum reg_wifi_band reg_freq_to_band(qdf_freq_t freq);
1277 
1278 /**
1279  * reg_min_chan_freq() - minimum channel frequency supported
1280  *
1281  * Return: channel frequency
1282  */
1283 qdf_freq_t reg_min_chan_freq(void);
1284 
1285 /**
1286  * reg_max_chan_freq() - maximum channel frequency supported
1287  *
1288  * Return: channel frequency
1289  */
1290 qdf_freq_t reg_max_chan_freq(void);
1291 
1292 /**
1293  * reg_get_5g_bonded_channel_for_freq()- Return the channel state for a
1294  * 5G or 6G channel frequency based on the channel width and bonded channel
1295  * @pdev: Pointer to pdev.
1296  * @freq: Channel center frequency.
1297  * @ch_width: Channel Width.
1298  * @bonded_chan_ptr_ptr: Pointer to bonded_channel_freq.
1299  * @in_6g_pwr_type: 6g power type which decides 6G channel list lookup.
1300  *
1301  * Return: Channel State
1302  */
1303 enum channel_state
1304 reg_get_5g_bonded_channel_for_freq(struct wlan_objmgr_pdev *pdev,
1305 				   uint16_t freq,
1306 				   enum phy_ch_width ch_width,
1307 				   const struct bonded_channel_freq
1308 				   **bonded_chan_ptr_ptr);
1309 
1310 #ifdef CONFIG_REG_6G_PWRMODE
1311 /**
1312  * reg_get_5g_bonded_channel_for_pwrmode()- Return the channel state for a
1313  * 5G or 6G channel frequency based on the channel width and bonded channel
1314  * @pdev: Pointer to pdev.
1315  * @freq: Channel center frequency.
1316  * @ch_width: Channel Width.
1317  * @bonded_chan_ptr_ptr: Pointer to bonded_channel_freq.
1318  * @in_6g_pwr_type: 6g power type which decides 6G channel list lookup.
1319  *
1320  * Return: Channel State
1321  */
1322 enum channel_state
1323 reg_get_5g_bonded_channel_for_pwrmode(struct wlan_objmgr_pdev *pdev,
1324 				      uint16_t freq,
1325 				      enum phy_ch_width ch_width,
1326 				      const struct bonded_channel_freq
1327 				      **bonded_chan_ptr_ptr,
1328 				      enum supported_6g_pwr_types
1329 				      in_6g_pwr_mode);
1330 #endif
1331 
1332 #ifdef CONFIG_REG_6G_PWRMODE
1333 /**
1334  * reg_is_disable_for_pwrmode() - Check if the given channel frequency in
1335  * disable state
1336  * @pdev: Pointer to pdev
1337  * @freq: Channel frequency
1338  * @in_6g_pwr_type: 6g power type which decides 6G channel list lookup.
1339  *
1340  * Return: True if channel state is disabled, else false
1341  */
1342 bool reg_is_disable_for_pwrmode(struct wlan_objmgr_pdev *pdev, qdf_freq_t freq,
1343 				enum supported_6g_pwr_types in_6g_pwr_mode);
1344 #endif
1345 
1346 #ifdef CONFIG_REG_CLIENT
1347 /**
1348  * reg_is_disable_in_secondary_list_for_freq() - Check if the given channel
1349  * frequency is in disable state
1350  * @pdev: Pointer to pdev
1351  * @freq: Channel frequency
1352  *
1353  * Return: True if channel state is disabled, else false
1354  */
1355 bool reg_is_disable_in_secondary_list_for_freq(struct wlan_objmgr_pdev *pdev,
1356 					       qdf_freq_t freq);
1357 
1358 /**
1359  * reg_is_enable_in_secondary_list_for_freq() - Check if the given channel
1360  * frequency is in enable state
1361  * @pdev: Pointer to pdev
1362  * @freq: Channel frequency
1363  *
1364  * Return: True if channel state is enabled, else false
1365  */
1366 bool reg_is_enable_in_secondary_list_for_freq(struct wlan_objmgr_pdev *pdev,
1367 					      qdf_freq_t freq);
1368 
1369 /**
1370  * reg_get_max_tx_power_for_pwr_mode() - Get maximum tx power
1371  * @pdev: Pointer to pdev
1372  * @in_6g_pwr_type: 6 GHz power type for which 6GHz frequencies needs to be
1373  * considered while getting the max power
1374  *
1375  * Return: return the value of the maximum tx power for 2GHz/5GHz channels
1376  * from current channel list and for 6GHz channels from the super channel list
1377  * for the specified power mode
1378  *
1379  */
1380 uint8_t reg_get_max_tx_power_for_pwr_mode(
1381 				struct wlan_objmgr_pdev *pdev,
1382 				enum supported_6g_pwr_types in_6g_pwr_type);
1383 #endif
1384 
1385 /**
1386  * reg_is_passive_for_freq() - Check if the given channel frequency is in
1387  * passive state
1388  * @pdev: Pointer to pdev
1389  * @freq: Channel frequency
1390  *
1391  * Return: True if channel state is passive, else false
1392  */
1393 bool reg_is_passive_for_freq(struct wlan_objmgr_pdev *pdev, qdf_freq_t freq);
1394 #endif /* CONFIG_CHAN_FREQ_API */
1395 
1396 /**
1397  * reg_get_max_tx_power() - Get maximum tx power from the current channel list
1398  * @pdev: Pointer to pdev
1399  *
1400  * Return: return the value of the maximum tx power in the current channel list
1401  *
1402  */
1403 uint8_t reg_get_max_tx_power(struct wlan_objmgr_pdev *pdev);
1404 
1405 /**
1406  * reg_set_ignore_fw_reg_offload_ind() - Set if regdb offload indication
1407  * needs to be ignored
1408  * @psoc: Pointer to psoc
1409  *
1410  * Return: QDF_STATUS
1411  */
1412 QDF_STATUS reg_set_ignore_fw_reg_offload_ind(struct wlan_objmgr_psoc *psoc);
1413 
1414 /**
1415  * reg_get_ignore_fw_reg_offload_ind() - Check whether regdb offload indication
1416  * needs to be ignored
1417  *
1418  * @psoc: Pointer to psoc
1419  */
1420 bool reg_get_ignore_fw_reg_offload_ind(struct wlan_objmgr_psoc *psoc);
1421 
1422 /**
1423  * reg_set_6ghz_supported() - Set if 6ghz is supported
1424  *
1425  * @psoc: Pointer to psoc
1426  * @val: value
1427  */
1428 QDF_STATUS reg_set_6ghz_supported(struct wlan_objmgr_psoc *psoc,
1429 				  bool val);
1430 
1431 /**
1432  * reg_set_5dot9_ghz_supported() - Set if 5.9ghz is supported
1433  *
1434  * @psoc: Pointer to psoc
1435  * @val: value
1436  */
1437 QDF_STATUS reg_set_5dot9_ghz_supported(struct wlan_objmgr_psoc *psoc,
1438 				       bool val);
1439 
1440 /**
1441  * reg_is_6ghz_op_class() - Check whether 6ghz oper class
1442  *
1443  * @pdev: Pointer to pdev
1444  * @op_class: oper class
1445  */
1446 bool reg_is_6ghz_op_class(struct wlan_objmgr_pdev *pdev,
1447 			  uint8_t op_class);
1448 
1449 #ifdef CONFIG_REG_CLIENT
1450 /**
1451  * reg_is_6ghz_supported() - Whether 6ghz is supported
1452  *
1453  * @psoc: pointer to psoc
1454  */
1455 bool reg_is_6ghz_supported(struct wlan_objmgr_psoc *psoc);
1456 #endif
1457 
1458 /**
1459  * reg_is_5dot9_ghz_supported() - Whether 5.9ghz is supported
1460  *
1461  * @psoc: pointer to psoc
1462  */
1463 bool reg_is_5dot9_ghz_supported(struct wlan_objmgr_psoc *psoc);
1464 
1465 /**
1466  * reg_is_fcc_regdmn () - Checks if the current reg domain is FCC3/FCC8/FCC15/
1467  * FCC16 or not
1468  * @pdev: pdev ptr
1469  *
1470  * Return: true or false
1471  */
1472 bool reg_is_fcc_regdmn(struct wlan_objmgr_pdev *pdev);
1473 
1474 /**
1475  * reg_is_5dot9_ghz_freq () - Checks if the frequency is 5.9 GHz freq or not
1476  * @freq: frequency
1477  * @pdev: pdev ptr
1478  *
1479  * Return: true or false
1480  */
1481 bool reg_is_5dot9_ghz_freq(struct wlan_objmgr_pdev *pdev, qdf_freq_t freq);
1482 
1483 /**
1484  * reg_is_5dot9_ghz_chan_allowed_master_mode () - Checks if 5.9 GHz channels
1485  * are allowed in master mode or not.
1486  *
1487  * @pdev: pdev ptr
1488  *
1489  * Return: true or false
1490  */
1491 bool reg_is_5dot9_ghz_chan_allowed_master_mode(struct wlan_objmgr_pdev *pdev);
1492 
1493 /**
1494  * reg_get_unii_5g_bitmap() - get unii_5g_bitmap value
1495  * @pdev: pdev pointer
1496  * @bitmap: Pointer to retrieve the unii_5g_bitmap of enum reg_unii_band
1497  *
1498  * Return: QDF_STATUS
1499  */
1500 #ifdef DISABLE_UNII_SHARED_BANDS
1501 QDF_STATUS
1502 reg_get_unii_5g_bitmap(struct wlan_objmgr_pdev *pdev, uint8_t *bitmap);
1503 #endif
1504 
1505 #ifdef CHECK_REG_PHYMODE
1506 /**
1507  * reg_get_max_phymode() - Recursively find the best possible phymode given a
1508  * phymode, a frequency, and per-country regulations
1509  * @pdev: pdev pointer
1510  * @phy_in: phymode that the user requested
1511  * @freq: current operating center frequency
1512  *
1513  * Return: maximum phymode allowed in current country that is <= phy_in
1514  */
1515 enum reg_phymode reg_get_max_phymode(struct wlan_objmgr_pdev *pdev,
1516 				     enum reg_phymode phy_in,
1517 				     qdf_freq_t freq);
1518 #else
1519 static inline enum reg_phymode
1520 reg_get_max_phymode(struct wlan_objmgr_pdev *pdev,
1521 		    enum reg_phymode phy_in,
1522 		    qdf_freq_t freq)
1523 {
1524 	return REG_PHYMODE_INVALID;
1525 }
1526 #endif /* CHECK_REG_PHYMODE */
1527 
1528 #ifdef CONFIG_REG_CLIENT
1529 /**
1530  * reg_band_bitmap_to_band_info() - Convert the band_bitmap to a band_info enum.
1531  *	Since band_info enum only has combinations for 2G and 5G, 6G is not
1532  *	considered in this function.
1533  * @band_bitmap: bitmap on top of reg_wifi_band of bands enabled
1534  *
1535  * Return: BAND_ALL if both 2G and 5G band is enabled
1536  *	BAND_2G if 2G is enabled but 5G isn't
1537  *	BAND_5G if 5G is enabled but 2G isn't
1538  */
1539 enum band_info reg_band_bitmap_to_band_info(uint32_t band_bitmap);
1540 #endif
1541 
1542 #if defined(CONFIG_BAND_6GHZ)
1543 /**
1544  * reg_set_cur_6g_ap_pwr_type() - Set the current 6G regulatory AP power type.
1545  * @pdev: Pointer to PDEV object.
1546  * @reg_6g_ap_type: Regulatory 6G AP type ie VLPI/LPI/SP.
1547  *
1548  * Return: QDF_STATUS_E_INVAL if unable to set and QDF_STATUS_SUCCESS is set.
1549  */
1550 QDF_STATUS
1551 reg_set_cur_6g_ap_pwr_type(struct wlan_objmgr_pdev *pdev,
1552 			   enum reg_6g_ap_type reg_cur_6g_ap_pwr_type);
1553 
1554 /**
1555  * reg_get_cur_6g_ap_pwr_type() - Get the current 6G regulatory AP power type.
1556  * @reg_6g_ap_pwr_type: The current regulatory 6G AP type ie VLPI/LPI/SP.
1557  * subordinate.
1558  *
1559  * Return: QDF_STATUS.
1560  */
1561 QDF_STATUS
1562 reg_get_cur_6g_ap_pwr_type(struct wlan_objmgr_pdev *pdev,
1563 			   enum reg_6g_ap_type *reg_cur_6g_ap_pwr_type);
1564 
1565 #ifdef CONFIG_AFC_SUPPORT
1566 /**
1567  * reg_afc_start() - Start the AFC request from regulatory. This finally
1568  *                   sends the request to registered callbacks
1569  * @pdev: Pointer to pdev
1570  * @req_id: The AFC request ID
1571  *
1572  * Return: QDF_STATUS
1573  */
1574 QDF_STATUS reg_afc_start(struct wlan_objmgr_pdev *pdev, uint64_t req_id);
1575 
1576 /**
1577  * reg_get_partial_afc_req_info() - Get the AFC partial request information
1578  * @pdev: Pointer to pdev
1579  * @afc_req: Address of AFC request pointer
1580  *
1581  * NOTE:- The memory for AFC request is allocated by the function must be
1582  *        freed by the caller.
1583  * Return: QDF_STATUS
1584  */
1585 QDF_STATUS
1586 reg_get_partial_afc_req_info(struct wlan_objmgr_pdev *pdev,
1587 			     struct wlan_afc_host_partial_request **afc_req);
1588 
1589 /**
1590  * reg_print_partial_afc_req_info() - Print the AFC partial request
1591  *                                    information
1592  * @pdev: Pointer to pdev
1593  * @afc_req: Pointer to AFC request
1594  *
1595  * Return: Void
1596  */
1597 void
1598 reg_print_partial_afc_req_info(struct wlan_objmgr_pdev *pdev,
1599 			       struct wlan_afc_host_partial_request *afc_req);
1600 
1601 /**
1602  * reg_register_afc_req_rx_callback () - add AFC request received callback
1603  * @pdev: Pointer to pdev
1604  * @cbf: Pointer to callback handler
1605  * @arg: Pointer to opaque argument
1606  *
1607  * Return: QDF_STATUS
1608  */
1609 QDF_STATUS reg_register_afc_req_rx_callback(struct wlan_objmgr_pdev *pdev,
1610 					    afc_req_rx_evt_handler cbf,
1611 					    void *arg);
1612 
1613 /**
1614  * reg_unregister_afc_req_rx_callback () - remove AFC request received
1615  * callback
1616  * @pdev: Pointer to pdev
1617  * @cbf: Pointer to callback handler
1618  *
1619  * Return: QDF_STATUS
1620  */
1621 QDF_STATUS reg_unregister_afc_req_rx_callback(struct wlan_objmgr_pdev *pdev,
1622 					      afc_req_rx_evt_handler cbf);
1623 
1624 /**
1625  * reg_register_afc_power_event_callback() - add AFC power event received
1626  * @pdev: Pointer to pdev
1627  * @cbf: Pointer to callback function
1628  * @arg: Pointer to opaque argument
1629  *
1630  * Return: QDF_STATUS
1631  */
1632 QDF_STATUS
1633 reg_register_afc_power_event_callback(struct wlan_objmgr_pdev *pdev,
1634 				      afc_power_tx_evt_handler cbf,
1635 				      void *arg);
1636 /**
1637  * reg_unregister_afc_power_event_callback() - remove AFC power event received
1638  * callback
1639  * @pdev: Pointer to pdev
1640  * @cbf: Pointer to callback function
1641  *
1642  * Return: QDF_STATUS
1643  */
1644 QDF_STATUS
1645 reg_unregister_afc_power_event_callback(struct wlan_objmgr_pdev *pdev,
1646 					afc_power_tx_evt_handler cbf);
1647 
1648 /**
1649  * reg_send_afc_power_event() - Send AFC power event to registered
1650  * recipient
1651  * @pdev: Pointer to pdev
1652  * @power_info: Pointer to afc power info
1653  *
1654  * Return: QDF_STATUS
1655  */
1656 QDF_STATUS reg_send_afc_power_event(struct wlan_objmgr_pdev *pdev,
1657 				    struct reg_fw_afc_power_event *power_info);
1658 
1659 /**
1660  * reg_get_afc_dev_deploy_type() - Get AFC device deployment type
1661  * @pdev: Pointer to pdev
1662  * @reg_afc_dev_type: Pointer to afc device deployment type
1663  *
1664  * Return: QDF_STATUS
1665  */
1666 QDF_STATUS
1667 reg_get_afc_dev_deploy_type(struct wlan_objmgr_pdev *pdev,
1668 			    enum reg_afc_dev_deploy_type *reg_afc_dev_type);
1669 
1670 /**
1671  * reg_set_afc_soc_dev_deploy_type() - Set AFC soc device deployment type
1672  * @pdev: Pointer to psoc
1673  * @reg_afc_dev_type: afc device deployment type
1674  *
1675  * Return: QDF_STATUS
1676  */
1677 QDF_STATUS
1678 reg_set_afc_soc_dev_type(struct wlan_objmgr_psoc *psoc,
1679 			 enum reg_afc_dev_deploy_type reg_afc_dev_type);
1680 
1681 /**
1682  * reg_is_sta_connect_allowed() - Check if STA connection is allowed.
1683  * @pdev: Pointer to pdev
1684  * @root_ap_pwr_mode: power mode of the Root AP.
1685  *
1686  * Return: True if STA Vap is allowed to connect.
1687  */
1688 bool
1689 reg_is_sta_connect_allowed(struct wlan_objmgr_pdev *pdev,
1690 			   enum reg_6g_ap_type root_ap_pwr_mode);
1691 
1692 /**
1693  * reg_get_afc_soc_dev_deploy_type() - Get AFC soc device deployment type
1694  * @pdev: Pointer to psoc
1695  * @reg_afc_dev_type: Pointer to afc device deployment type
1696  *
1697  * Return: QDF_STATUS
1698  */
1699 QDF_STATUS
1700 reg_get_afc_soc_dev_type(struct wlan_objmgr_psoc *psoc,
1701 			 enum reg_afc_dev_deploy_type *reg_afc_dev_type);
1702 #endif /* CONFIG_AFC_SUPPORT */
1703 
1704 /**
1705  * reg_get_cur_6g_client_type() - Get the current 6G regulatory client Type.
1706  * @pdev: Pointer to PDEV object.
1707  * @reg_cur_6g_client_mobility_type: The current regulatory 6G client type ie.
1708  * default/subordinate.
1709  *
1710  * Return: QDF_STATUS.
1711  */
1712 QDF_STATUS
1713 reg_get_cur_6g_client_type(struct wlan_objmgr_pdev *pdev,
1714 			   enum reg_6g_client_type
1715 			   *reg_cur_6g_client_mobility_type);
1716 
1717 /**
1718  * reg_get_rnr_tpe_usable() - Tells if RNR IE is applicable for current domain.
1719  * @pdev: Pointer to PDEV object.
1720  * @reg_rnr_tpe_usable: Pointer to hold the bool value, true if RNR IE is
1721  * applicable, else false.
1722  *
1723  * Return: QDF_STATUS.
1724  */
1725 QDF_STATUS reg_get_rnr_tpe_usable(struct wlan_objmgr_pdev *pdev,
1726 				  bool *reg_rnr_tpe_usable);
1727 
1728 /**
1729  * reg_get_unspecified_ap_usable() - Tells if AP type unspecified by 802.11 can
1730  * be used or not.
1731  * @pdev: Pointer to PDEV object.
1732  * @reg_unspecified_ap_usable: Pointer to hold the bool value, true if
1733  * unspecified AP types can be used in the IE, else false.
1734  *
1735  * Return: QDF_STATUS.
1736  */
1737 QDF_STATUS reg_get_unspecified_ap_usable(struct wlan_objmgr_pdev *pdev,
1738 					 bool *reg_unspecified_ap_usable);
1739 
1740 /**
1741  * reg_is_6g_psd_power() - Checks if pdev has PSD power
1742  *
1743  * @pdev: pdev ptr
1744  *
1745  * Return: true if PSD power or false otherwise
1746  */
1747 bool reg_is_6g_psd_power(struct wlan_objmgr_pdev *pdev);
1748 
1749 /**
1750  * reg_get_6g_chan_ap_power() - Finds the TX power for the given channel
1751  *	frequency, taking the AP's current power level into account
1752  *
1753  * @pdev: pdev ptr
1754  * @chan_freq: channel frequency
1755  * @is_psd: is channel PSD or not
1756  * @tx_power: transmit power to fill for chan_freq
1757  * @eirp_psd_power: EIRP PSD power, will only be filled if is_psd is true
1758  *
1759  * Return: QDF_STATUS
1760  */
1761 QDF_STATUS reg_get_6g_chan_ap_power(struct wlan_objmgr_pdev *pdev,
1762 				    qdf_freq_t chan_freq, bool *is_psd,
1763 				    uint16_t *tx_power,
1764 				    uint16_t *eirp_psd_power);
1765 
1766 /**
1767  * reg_get_client_power_for_connecting_ap() - Find the channel information when
1768  *	device is operating as a client
1769  *
1770  * @pdev: pdev ptr
1771  * @ap_type: type of AP that device is connected to
1772  * @chan_freq: channel frequency
1773  * @is_psd: is channel PSD or not
1774  * @tx_power: transmit power to fill for chan_freq
1775  * @eirp_psd_power: EIRP power, will only be filled if is_psd is true
1776  *
1777  * This function is meant to be called to find the channel frequency power
1778  * information for a client when the device is operating as a client. It will
1779  * fill in the parameters tx_power and eirp_psd_power. eirp_psd_power
1780  * will only be filled if the channel is PSD.
1781  *
1782  * Return: QDF_STATUS
1783  */
1784 QDF_STATUS reg_get_client_power_for_connecting_ap(struct wlan_objmgr_pdev *pdev,
1785 						  enum reg_6g_ap_type ap_type,
1786 						  qdf_freq_t chan_freq,
1787 						  bool is_psd,
1788 						  uint16_t *tx_power,
1789 						  uint16_t *eirp_psd_power);
1790 
1791 /**
1792  * reg_get_client_power_for_6ghz_ap() - Find the channel information when
1793  *	device is operating as a 6GHz AP
1794  *
1795  * @pdev: pdev ptr
1796  * @client_type: type of client that is connected to our AP
1797  * @chan_freq: channel frequency
1798  * @is_psd: is channel PSD or not
1799  * @tx_power: transmit power to fill for chan_freq
1800  * @eirp_psd_power: EIRP power, will only be filled if is_psd is true
1801  *
1802  * This function is meant to be called to find the channel frequency power
1803  * information for a client when the device is operating as an AP. It will fill
1804  * in the parameter is_psd, tx_power, and eirp_psd_power. eirp_psd_power will
1805  * only be filled if the channel is PSD.
1806  *
1807  * Return: QDF_STATUS
1808  */
1809 QDF_STATUS reg_get_client_power_for_6ghz_ap(struct wlan_objmgr_pdev *pdev,
1810 					    enum reg_6g_client_type client_type,
1811 					    qdf_freq_t chan_freq,
1812 					    bool *is_psd, uint16_t *tx_power,
1813 					    uint16_t *eirp_psd_power);
1814 
1815 /**
1816  * reg_set_ap_pwr_and_update_chan_list() - Set the AP power mode and recompute
1817  * the current channel list
1818  *
1819  * @pdev: pdev ptr
1820  * @ap_pwr_type: the AP power type to update to
1821  *
1822  * Return: QDF_STATUS
1823  */
1824 QDF_STATUS reg_set_ap_pwr_and_update_chan_list(struct wlan_objmgr_pdev *pdev,
1825 					       enum reg_6g_ap_type ap_pwr_type);
1826 
1827 /**
1828  * reg_get_6g_chan_psd_eirp_power() - For a given frequency, get the max PSD
1829  * from the mas_chan_list
1830  * @freq: Channel frequency
1831  * @mas_chan_list: Pointer to mas_chan_list
1832  * @reg_psd: Pointer to reg_psd
1833  *
1834  * Return: QDF_STATUS
1835  */
1836 QDF_STATUS
1837 reg_get_6g_chan_psd_eirp_power(qdf_freq_t freq,
1838 			       struct regulatory_channel *mas_chan_list,
1839 			       uint16_t *reg_psd);
1840 
1841 /**
1842  * reg_find_txpower_from_6g_list() - For a given frequency, get the max EIRP
1843  * from the mas_chan_list
1844  * @freq: Channel frequency
1845  * @mas_chan_list: Pointer to mas_chan_list
1846  * @reg_eirp: Pointer to reg_eirp
1847  *
1848  * Return: QDF_STATUS
1849  */
1850 QDF_STATUS
1851 reg_find_txpower_from_6g_list(qdf_freq_t freq,
1852 			      struct regulatory_channel *chan_list,
1853 			      uint16_t *reg_eirp);
1854 #else
1855 static inline QDF_STATUS
1856 reg_set_cur_6g_ap_pwr_type(struct wlan_objmgr_pdev *pdev,
1857 			   enum reg_6g_ap_type reg_cur_6g_ap_pwr_type)
1858 {
1859 	return QDF_STATUS_E_NOSUPPORT;
1860 }
1861 
1862 static inline QDF_STATUS
1863 reg_get_cur_6g_ap_pwr_type(struct wlan_objmgr_pdev *pdev,
1864 			   enum reg_6g_ap_type *reg_cur_6g_ap_pwr_type)
1865 {
1866 	*reg_cur_6g_ap_pwr_type = REG_MAX_AP_TYPE;
1867 	return QDF_STATUS_E_NOSUPPORT;
1868 }
1869 
1870 static inline QDF_STATUS
1871 reg_get_cur_6g_client_type(struct wlan_objmgr_pdev *pdev,
1872 			   enum reg_6g_client_type
1873 			   *reg_cur_6g_client_mobility_type)
1874 {
1875 	*reg_cur_6g_client_mobility_type = REG_SUBORDINATE_CLIENT;
1876 	return QDF_STATUS_E_NOSUPPORT;
1877 }
1878 
1879 static inline
1880 QDF_STATUS reg_get_rnr_tpe_usable(struct wlan_objmgr_pdev *pdev,
1881 				  bool *reg_rnr_tpe_usable)
1882 {
1883 	*reg_rnr_tpe_usable = false;
1884 	return QDF_STATUS_E_NOSUPPORT;
1885 }
1886 
1887 static inline
1888 QDF_STATUS reg_get_unspecified_ap_usable(struct wlan_objmgr_pdev *pdev,
1889 					 bool *reg_unspecified_ap_usable)
1890 {
1891 	*reg_unspecified_ap_usable = false;
1892 	return QDF_STATUS_E_NOSUPPORT;
1893 }
1894 
1895 static inline
1896 bool reg_is_6g_psd_power(struct wlan_objmgr_pdev *pdev)
1897 {
1898 	return false;
1899 }
1900 
1901 static inline
1902 QDF_STATUS reg_get_6g_chan_ap_power(struct wlan_objmgr_pdev *pdev,
1903 				    qdf_freq_t chan_freq, bool *is_psd,
1904 				    uint16_t *tx_power,
1905 				    uint16_t *eirp_psd_power)
1906 {
1907 	*is_psd = false;
1908 	*eirp_psd_power = 0;
1909 	*tx_power = 0;
1910 	return QDF_STATUS_E_NOSUPPORT;
1911 }
1912 
1913 static inline
1914 QDF_STATUS reg_get_client_power_for_connecting_ap(struct wlan_objmgr_pdev *pdev,
1915 						  enum reg_6g_ap_type ap_type,
1916 						  qdf_freq_t chan_freq,
1917 						  bool is_psd,
1918 						  uint16_t *tx_power,
1919 						  uint16_t *eirp_psd_power)
1920 {
1921 	*tx_power = 0;
1922 	*eirp_psd_power = 0;
1923 	return QDF_STATUS_E_NOSUPPORT;
1924 }
1925 
1926 static inline
1927 QDF_STATUS reg_get_client_power_for_6ghz_ap(struct wlan_objmgr_pdev *pdev,
1928 					    enum reg_6g_client_type client_type,
1929 					    qdf_freq_t chan_freq,
1930 					    bool *is_psd, uint16_t *tx_power,
1931 					    uint16_t *eirp_psd_power)
1932 {
1933 	*is_psd = false;
1934 	*tx_power = 0;
1935 	*eirp_psd_power = 0;
1936 	return QDF_STATUS_E_NOSUPPORT;
1937 }
1938 
1939 static inline
1940 QDF_STATUS reg_set_ap_pwr_and_update_chan_list(struct wlan_objmgr_pdev *pdev,
1941 					       enum reg_6g_ap_type ap_pwr_type)
1942 {
1943 	return QDF_STATUS_E_NOSUPPORT;
1944 }
1945 
1946 static inline QDF_STATUS
1947 reg_get_6g_chan_psd_eirp_power(qdf_freq_t freq,
1948 			       struct regulatory_channel *mas_chan_list,
1949 			       uint16_t *eirp_psd_power)
1950 {
1951 	*eirp_psd_power = 0;
1952 	return QDF_STATUS_E_NOSUPPORT;
1953 }
1954 
1955 static inline QDF_STATUS
1956 reg_find_txpower_from_6g_list(qdf_freq_t freq,
1957 			      struct regulatory_channel *chan_list,
1958 			      uint16_t *reg_eirp)
1959 {
1960 	*reg_eirp = 0;
1961 	return QDF_STATUS_E_NOSUPPORT;
1962 }
1963 #endif
1964 
1965 #ifdef CONFIG_HOST_FIND_CHAN
1966 /**
1967  * reg_update_max_phymode_chwidth_for_pdev() - Update the maximum phymode
1968  * and the corresponding chwidth for the pdev.
1969  * @pdev: Pointer to PDEV object.
1970  *
1971  */
1972 void reg_update_max_phymode_chwidth_for_pdev(struct wlan_objmgr_pdev *pdev);
1973 
1974 /**
1975  * reg_modify_chan_list_for_max_chwidth_for_pwrmode() - Update the maximum
1976  * bandwidth for
1977  * each channel in the current channel list.
1978  * @pdev: Pointer to PDEV object.
1979  * @cur_chan_list: Pointer to the pdev current channel list.
1980  * @in_6g_pwr_type: 6g power type which decides 6G channel list lookup.
1981  *
1982  * In countries like DK, the channel 144 is not supported by the regulatory.
1983  * When we get the regulatory rules, the entire UNII-2E's max bandwidth is set
1984  * to 160MHz but this is only true for channel 100 to 128. Channels 132 and
1985  * and 136 will have maximum bandwidth of 40MHz and channel 140 will have a
1986  * max bandwidth value of 20MHz (since 144 is not available).
1987  * These values in the current channel list are not updated based on the
1988  * bonded channels and hence will have an incorrect value for particular
1989  * channels.
1990  * Use this API to update the maximum bandwidth based on the device
1991  * capabilities and the availability of adjacent channels.
1992  */
1993 void
1994 reg_modify_chan_list_for_max_chwidth_for_pwrmode(struct wlan_objmgr_pdev *pdev,
1995 						 struct regulatory_channel
1996 						 *cur_chan_list,
1997 						 enum supported_6g_pwr_types
1998 						 in_6g_pwr_mode);
1999 
2000 #else
2001 static inline void
2002 reg_update_max_phymode_chwidth_for_pdev(struct wlan_objmgr_pdev *pdev)
2003 {
2004 }
2005 
2006 static inline void
2007 reg_modify_chan_list_for_max_chwidth_for_pwrmode(struct wlan_objmgr_pdev *pdev,
2008 						 struct regulatory_channel
2009 						 *cur_chan_list,
2010 						 enum supported_6g_pwr_types
2011 						 in_6g_pwr_mode)
2012 {
2013 }
2014 #endif /* CONFIG_HOST_FIND_CHAN */
2015 
2016 /**
2017  * reg_is_phymode_unallowed() - Check if requested phymode is unallowed
2018  * @phy_in: phymode that the user requested
2019  * @phymode_bitmap: bitmap of unallowed phymodes for specific country
2020  *
2021  * Return: true if phymode is not allowed, else false
2022  */
2023 bool reg_is_phymode_unallowed(enum reg_phymode phy_in, uint32_t phymode_bitmap);
2024 
2025 /*
2026  * reg_is_regdb_offloaded() - is regdb offloaded
2027  * @psoc: Pointer to psoc object
2028  *
2029  * Return: true if regdb is offloaded, else false
2030  */
2031 bool reg_is_regdb_offloaded(struct wlan_objmgr_psoc *psoc);
2032 
2033 /**
2034  * reg_set_ext_tpc_supported() - Set if FW supports new WMI command for TPC
2035  * @psoc: Pointer to psoc
2036  * @val: value
2037  *
2038  * Return: QDF_STATUS
2039  */
2040 QDF_STATUS reg_set_ext_tpc_supported(struct wlan_objmgr_psoc *psoc,
2041 				     bool val);
2042 
2043 /**
2044  * reg_is_ext_tpc_supported() - Whether FW supports new WMI command for TPC
2045  *
2046  * @psoc: pointer to psoc
2047  *
2048  * Return: true if FW supports the new TPC command, else false
2049  */
2050 bool reg_is_ext_tpc_supported(struct wlan_objmgr_psoc *psoc);
2051 
2052 /**
2053  * reg_get_bonded_chan_entry() - Fetch the bonded channel pointer given a
2054  * frequency and channel width.
2055  * @freq: Input frequency.
2056  * @chwidth: Input channel width.
2057  * @cen320_freq: center frequency of 320. In 6G band 320Mhz channel are
2058  *               overlapping. The exact band should be therefore identified
2059  *               by the center frequency of the 320Mhz channel.
2060  * For example: Primary channel 6135 (IEEE37) can be part of either channel
2061  * (A) the 320Mhz channel with center 6105(IEEE31) or
2062  * (B) the 320Mhz channel with center 6265(IEEE63)
2063  * For (A) the start frequency is 5955(IEEE1) whereas for (B) the start
2064  * frequency is 6115(IEEE33)
2065  *
2066  * Return: A valid bonded channel pointer if found, else NULL.
2067  */
2068 const struct bonded_channel_freq *
2069 reg_get_bonded_chan_entry(qdf_freq_t freq, enum phy_ch_width chwidth,
2070 			  qdf_freq_t cen320_freq);
2071 
2072 /**
2073  * reg_set_2g_channel_params_for_freq() - set the 2.4G bonded channel parameters
2074  * @oper_freq: operating channel
2075  * @ch_params: channel parameters
2076  * @sec_ch_2g_freq: 2.4G secondary channel
2077  *
2078  * Return: void
2079  */
2080 void reg_set_2g_channel_params_for_freq(struct wlan_objmgr_pdev *pdev,
2081 					uint16_t oper_freq,
2082 					struct ch_params *ch_params,
2083 					uint16_t sec_ch_2g_freq);
2084 
2085 /**
2086  * reg_combine_channel_states() - Get minimum of channel state1 and state2
2087  * @chan_state1: Channel state1
2088  * @chan_state2: Channel state2
2089  *
2090  * Return: Channel state
2091  */
2092 enum channel_state reg_combine_channel_states(enum channel_state chan_state1,
2093 					      enum channel_state chan_state2);
2094 
2095 #if defined(CONFIG_BAND_6GHZ)
2096 /**
2097  * reg_set_lower_6g_edge_ch_supp() - Set if lower 6ghz edge channel is
2098  * supported by FW
2099  *
2100  * @psoc: Pointer to psoc
2101  * @val: value
2102  */
2103 QDF_STATUS reg_set_lower_6g_edge_ch_supp(struct wlan_objmgr_psoc *psoc,
2104 					 bool val);
2105 
2106 /**
2107  * reg_set_disable_upper_6g_edge_ch_supp() - Set if upper 6ghz edge channel is
2108  * disabled by FW
2109  *
2110  * @psoc: Pointer to psoc
2111  * @val: value
2112  */
2113 QDF_STATUS
2114 reg_set_disable_upper_6g_edge_ch_supp(struct wlan_objmgr_psoc *psoc,
2115 				      bool val);
2116 
2117 /**
2118  * reg_is_lower_6g_edge_ch_supp() - Check whether 6GHz lower edge channel
2119  * (5935 MHz) is supported.
2120  * @psoc: pointer to psoc
2121  *
2122  * Return: true if edge channels are supported, else false
2123  */
2124 bool reg_is_lower_6g_edge_ch_supp(struct wlan_objmgr_psoc *psoc);
2125 
2126 /**
2127  * reg_is_upper_6g_edge_ch_disabled() - Check whether 6GHz upper edge
2128  * channel (7115 MHz) is disabled.
2129  * @psoc: pointer to psoc
2130  *
2131  * Return: true if edge channels are supported, else false
2132  */
2133 bool reg_is_upper_6g_edge_ch_disabled(struct wlan_objmgr_psoc *psoc);
2134 
2135 /**
2136  * reg_convert_enum_to_6g_idx() - Convert a channel enum between
2137  * MIN_6GHZ_CHANNEL and MAX_6GHZ_CHANNEL, to an index between 0 and
2138  * NUM_6GHZ_CHANNELS
2139  * @ch_idx: Channel index
2140  *
2141  * Return: enum channel_enum
2142  */
2143 uint16_t reg_convert_enum_to_6g_idx(enum channel_enum ch_idx);
2144 
2145 /**
2146  * reg_get_superchan_entry() - Get the address of the super channel list
2147  * entry for a given input channel index.
2148  *
2149  * @pdev: pdev ptr
2150  * @chan_enum: Channel enum
2151  * @p_sup_chan_entry: Pointer to address of *p_sup_chan_entry
2152  *
2153  * Return: QDF_STATUS_SUCCESS if super channel entry is available for the input
2154  * chan_enum else QDF_STATUS_E_FAILURE
2155  */
2156 QDF_STATUS
2157 reg_get_superchan_entry(struct wlan_objmgr_pdev *pdev,
2158 			enum channel_enum chan_enum,
2159 			const struct super_chan_info **p_sup_chan_entry);
2160 #else
2161 static inline QDF_STATUS
2162 reg_set_lower_6g_edge_ch_supp(struct wlan_objmgr_psoc *psoc, bool val)
2163 {
2164 	return QDF_STATUS_E_NOSUPPORT;
2165 }
2166 
2167 static inline QDF_STATUS
2168 reg_set_disable_upper_6g_edge_ch_supp(struct wlan_objmgr_psoc *psoc,
2169 				      bool val)
2170 {
2171 	return QDF_STATUS_E_NOSUPPORT;
2172 }
2173 
2174 static inline bool reg_is_lower_6g_edge_ch_supp(struct wlan_objmgr_psoc *psoc)
2175 {
2176 	return false;
2177 }
2178 
2179 static inline bool
2180 reg_is_upper_6g_edge_ch_disabled(struct wlan_objmgr_psoc *psoc)
2181 {
2182 	return false;
2183 }
2184 
2185 static inline QDF_STATUS
2186 reg_get_superchan_entry(struct wlan_objmgr_pdev *pdev,
2187 			enum channel_enum chan_enum,
2188 			const struct super_chan_info **p_sup_chan_entry)
2189 {
2190 	return QDF_STATUS_E_NOSUPPORT;
2191 }
2192 
2193 static inline uint16_t reg_convert_enum_to_6g_idx(enum channel_enum ch_idx)
2194 {
2195 	return INVALID_CHANNEL;
2196 }
2197 #endif
2198 
2199 #ifdef FEATURE_WLAN_CH_AVOID_EXT
2200 /**
2201  * reg_process_ch_avoid_ext_event() - Process channel avoid extended event
2202  * @psoc: psoc for country information
2203  * @ch_avoid_event: channel avoid extended event buffer
2204  *
2205  * Return: QDF_STATUS
2206  */
2207 
2208 QDF_STATUS
2209 reg_process_ch_avoid_ext_event(struct wlan_objmgr_psoc *psoc,
2210 			       struct ch_avoid_ind_type *ch_avoid_event);
2211 /**
2212  * reg_check_coex_unsafe_nb_user_prefer() - get coex unsafe nb
2213  * user prefer ini
2214  * @psoc: pointer to psoc
2215  *
2216  * Return: bool
2217  */
2218 
2219 bool reg_check_coex_unsafe_nb_user_prefer(struct wlan_objmgr_psoc *psoc);
2220 
2221 /**
2222  * reg_disable_coex_unsafe_channel() - get reg channel disable for
2223  * for coex unsafe channels
2224  * @psoc: pointer to psoc
2225  *
2226  * Return: bool
2227  */
2228 
2229 bool reg_check_coex_unsafe_chan_reg_disable(struct wlan_objmgr_psoc *psoc);
2230 #else
2231 static inline QDF_STATUS
2232 reg_process_ch_avoid_ext_event(struct wlan_objmgr_psoc *psoc,
2233 			       struct ch_avoid_ind_type *ch_avoid_event)
2234 {
2235 	return QDF_STATUS_SUCCESS;
2236 }
2237 
2238 static inline
2239 bool reg_check_coex_unsafe_nb_user_prefer(struct wlan_objmgr_psoc *psoc)
2240 {
2241 	return false;
2242 }
2243 
2244 static inline
2245 bool reg_check_coex_unsafe_chan_reg_disable(struct wlan_objmgr_psoc *psoc)
2246 {
2247 	return false;
2248 }
2249 #endif
2250 
2251 #if defined(CONFIG_AFC_SUPPORT) && defined(CONFIG_BAND_6GHZ)
2252 /**
2253  * reg_send_afc_cmd() - Send AFC cmd to the FW
2254  * @pdev: pdev ptr
2255  * @afc_ind_obj: Pointer to hold AFC indication
2256  *
2257  * Return: QDF_STATUS_SUCCESS if the WMI command is sent or QDF_STATUS_E_FAILURE
2258  * otherwise
2259  */
2260 QDF_STATUS reg_send_afc_cmd(struct wlan_objmgr_pdev *pdev,
2261 			    struct reg_afc_resp_rx_ind_info *afc_ind_obj);
2262 
2263 /**
2264  * reg_is_afc_power_event_received() - Checks if AFC power event is
2265  * received from the FW.
2266  *
2267  * @pdev: pdev ptr
2268  *
2269  * Return: true if AFC power event is received from the FW or false otherwise
2270  */
2271 bool reg_is_afc_power_event_received(struct wlan_objmgr_pdev *pdev);
2272 
2273 /**
2274  * reg_is_afc_done() - Check is AFC response has been received enabling
2275  * the given frequency.
2276  * @pdev: pdev ptr
2277  * @freq: given frequency
2278  *
2279  * Return: True if frequency is enabled, false otherwise
2280  */
2281 bool reg_is_afc_done(struct wlan_objmgr_pdev *pdev, qdf_freq_t freq);
2282 
2283 /**
2284  * reg_get_afc_req_id() - Get the AFC request ID
2285  * @pdev: pdev pointer
2286  * @req_id: Pointer to request id
2287  *
2288  * Return: QDF_STATUS
2289  */
2290 QDF_STATUS reg_get_afc_req_id(struct wlan_objmgr_pdev *pdev, uint64_t *req_id);
2291 
2292 /**
2293  * reg_is_afc_expiry_event_received() - Checks if AFC power event is
2294  * received from the FW.
2295  *
2296  * @pdev: pdev ptr
2297  *
2298  * Return: true if AFC expiry event is received from the FW or false otherwise
2299  */
2300 bool reg_is_afc_expiry_event_received(struct wlan_objmgr_pdev *pdev);
2301 
2302 /**
2303  * reg_is_noaction_on_afc_pwr_evt() - Checks if the regulatory module
2304  * needs to take action when AFC power event is received.
2305  *
2306  * @pdev: pdev ptr
2307  *
2308  * Return: true if regulatory should not take any action or false otherwise
2309  */
2310 bool reg_is_noaction_on_afc_pwr_evt(struct wlan_objmgr_pdev *pdev);
2311 
2312 /**
2313  * reg_dmn_set_afc_req_id() - Set the request ID in the AFC partial request
2314  *                            object
2315  * @afc_req: pointer to AFC partial request
2316  * @req_id: AFC request ID
2317  *
2318  * Return: Void
2319  */
2320 void reg_dmn_set_afc_req_id(struct wlan_afc_host_partial_request *afc_req,
2321 			    uint64_t req_id);
2322 #endif
2323 
2324 /**
2325  * reg_is_chwidth_supported() - Check if given channel width is supported
2326  * on a given pdev
2327  * @pdev: pdev pointer
2328  * @ch_width: channel width.
2329  * @is_supported: whether the channel width is supported
2330  *
2331  * Return QDF_STATUS_SUCCESS of operation
2332  */
2333 QDF_STATUS reg_is_chwidth_supported(struct wlan_objmgr_pdev *pdev,
2334 				    enum phy_ch_width ch_width,
2335 				    bool *is_supported);
2336 
2337 /**
2338  * reg_is_state_allowed() - Check the state of the regulatory channel if it
2339  * is invalid or disabled.
2340  * @chan_state: Channel state.
2341  *
2342  * Return bool: true if the channel is not an invalid channel or disabled
2343  * channel.
2344  */
2345 bool reg_is_state_allowed(enum channel_state chan_state);
2346 
2347 /**
2348  * reg_is_freq_enabled() - Checks if the given frequency is enabled on the given
2349  * power mode or not. If the frequency is not a 6G frequency then the input
2350  * power mode is ignored and only current channel list is searched.
2351  *
2352  * @pdev: pdev pointer.
2353  * @freq: input frequency.
2354  * @in_6g_pwr_mode: Power mode on which the freq is enabled or not is to be
2355  * checked.
2356  *
2357  * Return: True if the frequency is present in the given power mode channel
2358  * list.
2359  */
2360 bool reg_is_freq_enabled(struct wlan_objmgr_pdev *pdev,
2361 			 qdf_freq_t freq,
2362 			 enum supported_6g_pwr_types in_6g_pwr_mode);
2363 
2364 /**
2365  * reg_is_freq_idx_enabled() - Checks if the given frequency index is enabled on
2366  * the given power mode or not. If the frequency index is not a 6G frequency
2367  * then the input power mode is ignored and only current channel list is
2368  * searched.
2369  *
2370  * @pdev: pdev pointer.
2371  * @freq_idx: input frequency index.
2372  * @in_6g_pwr_mode: Power mode on which the frequency index is enabled or not
2373  * is to be checked.
2374  *
2375  * Return: True if the frequency index is present in the given power mode
2376  * channel list.
2377  */
2378 bool reg_is_freq_idx_enabled(struct wlan_objmgr_pdev *pdev,
2379 			     enum channel_enum freq_idx,
2380 			     enum supported_6g_pwr_types in_6g_pwr_mode);
2381 
2382 /**
2383  * reg_get_best_6g_pwr_type() - Returns the best 6g power type supported for
2384  * a given frequency.
2385  * @pdev: pdev pointer
2386  * @freq: input frequency.
2387  *
2388  * Return: supported_6g_pwr_types enum.
2389  */
2390 enum supported_6g_pwr_types
2391 reg_get_best_6g_pwr_type(struct wlan_objmgr_pdev *pdev, qdf_freq_t freq);
2392 
2393 /**
2394  * reg_conv_6g_ap_type_to_supported_6g_pwr_types() - Converts the 6G AP power
2395  * type to 6g supported power type enum.
2396  * @ap_pwr_type: input 6G AP power type.
2397  *
2398  * Return: supported_6g_pwr_types enum.
2399  */
2400 enum supported_6g_pwr_types
2401 reg_conv_6g_ap_type_to_supported_6g_pwr_types(enum reg_6g_ap_type ap_pwr_type);
2402 
2403 /**
2404  * reg_find_chwidth_from_bw () - Gets channel width for given
2405  * bandwidth
2406  * @bw: Bandwidth
2407  *
2408  * Return: phy_ch_width
2409  */
2410 enum phy_ch_width reg_find_chwidth_from_bw(uint16_t bw);
2411 
2412 #ifdef CONFIG_BAND_6GHZ
2413 /**
2414  * reg_get_thresh_priority_freq() - Get the prioritized frequency value
2415  * @pdev: pdev pointer
2416  */
2417 qdf_freq_t reg_get_thresh_priority_freq(struct wlan_objmgr_pdev *pdev);
2418 
2419 /**
2420  * reg_get_best_pwr_mode() - Get the AP's primary channel center frequency and
2421  * AP's operating bandwidth to return the best power mode, which is calculated
2422  * based on the maximum EIRP power among the 3 AP types, i.e, LPI, SP and VLP
2423  * @pdev: Pointer to pdev
2424  * @freq: Primary channel center frequency in MHz
2425  * @cen320: Band center of 320 MHz. (For other BW, this param is ignored during
2426  * processing)
2427  * @bw: AP's operating bandwidth in mhz
2428  *
2429  * Return: Best power mode
2430  */
2431 enum reg_6g_ap_type reg_get_best_pwr_mode(struct wlan_objmgr_pdev *pdev,
2432 					  qdf_freq_t freq,
2433 					  qdf_freq_t cen320,
2434 					  uint16_t bw);
2435 
2436 /**
2437  * reg_get_eirp_pwr() - Get eirp power based on the AP power mode
2438  * @pdev: Pointer to pdev
2439  * @freq: Frequency in MHz
2440  * @cen320: 320 MHz Band center frequency
2441  * @bw: Bandwidth in MHz
2442  * @ap_pwr_type: AP power type
2443  *
2444  * Return: EIRP power
2445  */
2446 uint8_t reg_get_eirp_pwr(struct wlan_objmgr_pdev *pdev, qdf_freq_t freq,
2447 			 qdf_freq_t cen320,
2448 			 uint16_t bw, enum reg_6g_ap_type ap_pwr_type);
2449 #endif /* CONFIG_BAND_6GHZ */
2450 
2451 /**
2452  * reg_get_5g_chan_state() - Get channel state for
2453  * 5G bonded channel using the channel frequency
2454  * @pdev: Pointer to pdev
2455  * @freq: channel center frequency.
2456  * @bw: channel band width
2457  * @in_6g_pwr_mode: Input power mode which decides the 6G channel list to be
2458  * used.
2459  *
2460  * Return: channel state
2461  */
2462 enum channel_state
2463 reg_get_5g_chan_state(struct wlan_objmgr_pdev *pdev, qdf_freq_t freq,
2464 		      enum phy_ch_width bw,
2465 		      enum supported_6g_pwr_types in_6g_pwr_mode);
2466 
2467 /**
2468  * reg_get_320_bonded_channel_state_for_pwrmode() - Given a bonded channel
2469  * pointer and freq, determine if the subchannels of the bonded pair
2470  * are valid and supported by the current regulatory.
2471  *
2472  * @pdev: Pointer to struct wlan_objmgr_pdev.
2473  * @freq: Frequency in MHZ.
2474  * @bonded_chan_ptr: Pointer to const struct bonded_channel_freq.
2475  * @bw: channel bandwidth
2476  * @out_punc_bitmap: Output puncturing bitmap
2477  * @in_6g_pwr_type: Input 6g power type
2478  * @treat_nol_chan_as_disabled: Bool to treat nol as enabled/disabled
2479  *
2480  * Return - The channel state of the bonded pair.
2481  */
2482 #ifdef WLAN_FEATURE_11BE
2483 enum channel_state
2484 reg_get_320_bonded_channel_state_for_pwrmode(struct wlan_objmgr_pdev *pdev,
2485 					     qdf_freq_t freq,
2486 					     const struct bonded_channel_freq
2487 					     *bonded_chan_ptr,
2488 					     enum phy_ch_width bw,
2489 					     uint16_t *out_punc_bitmap,
2490 					     enum supported_6g_pwr_types
2491 					     in_6g_pwr_type,
2492 					     bool treat_nol_chan_as_disabled);
2493 #endif
2494 
2495 /**
2496  * reg_is_ch_width_320() - Given a channel width, find out if it is 320MHZ.
2497  * @ch_width: Channel width
2498  * Return - True if ch_width is 320, false otherwise.
2499  */
2500 bool reg_is_ch_width_320(enum phy_ch_width ch_width);
2501 
2502 /**
2503  * reg_get_ch_state_based_on_nol_flag() - Given a channel, find out the
2504  * state of the channel. If "treat_nol_chan_as_disabled" flag is set, nol channels
2505  * are considered disabled, else nol channels are considered enabled.
2506  * @pdev: Pointer to struct wlan_objmgr_pdev
2507  * @freq: Primary frequency
2508  * @treat_nol_chan_as_disabled: Flag to consider nol chan as enabled/disabled.
2509  * @ch_param: pointer to struct ch_params
2510  * @in_6g_pwr_mode: Input 6g power type
2511  *
2512  * Return - Channel state
2513  */
2514 enum channel_state
2515 reg_get_ch_state_based_on_nol_flag(struct wlan_objmgr_pdev *pdev,
2516 				   qdf_freq_t freq,
2517 				   struct ch_params *ch_param,
2518 				   enum supported_6g_pwr_types
2519 				   in_6g_pwr_mode,
2520 				   bool treat_nol_chan_as_disabled);
2521 
2522 /**
2523  * reg_get_min_max_bw_reg_chan_list() - Given a frequency index, find out the
2524  * min/max bw of the channel.
2525  *
2526  * @pdev: pdev pointer.
2527  * @freq_idx: input frequency index.
2528  * @in_6g_pwr_mode: Input 6g power type.
2529  * @min_bw: Min bandwidth.
2530  * @max_bw: Max bandwidth
2531  *
2532  * Return: true/false.
2533  */
2534 QDF_STATUS reg_get_min_max_bw_reg_chan_list(struct wlan_objmgr_pdev *pdev,
2535 					    enum channel_enum freq_idx,
2536 					    enum supported_6g_pwr_types
2537 					    in_6g_pwr_mode,
2538 					    uint16_t *min_bw,
2539 					    uint16_t *max_bw);
2540 
2541 /**
2542  * reg_get_chan_state() - Given a frequency index, find out the
2543  * state of the channel.
2544  *
2545  * @pdev: pdev pointer.
2546  * @freq_idx: input frequency index.
2547  * @in_6g_pwr_mode: Input 6g power type
2548  * @treat_nol_chan_as_disabled: Bool to treat NOL channels as
2549  * disabled/enabled.
2550  *
2551  * Return: Channel state.
2552  */
2553 enum channel_state reg_get_chan_state(struct wlan_objmgr_pdev *pdev,
2554 				      enum channel_enum freq_idx,
2555 				      enum supported_6g_pwr_types
2556 				      in_6g_pwr_mode,
2557 				      bool treat_nol_chan_as_disabled);
2558 
2559 /**
2560  * reg_is_chan_disabled() - Check if a chanel is disabled or not
2561  *
2562  * @chan_flags: Channel flags
2563  * @chan_state: Channel state
2564  *
2565  * Return: True if channel is disabled else false.
2566  */
2567 bool reg_is_chan_disabled(uint32_t chan_flags, enum channel_state chan_state);
2568 
2569 /**
2570  * reg_get_chan_state_for_320() - Get the channel state of a 320 MHz
2571  * bonded channel.
2572  * @pdev: Pointer to wlan_objmgr_pdev
2573  * @freq: Primary frequency
2574  * @center_320: Band center of 320 MHz
2575  * @ch_width: Channel width
2576  * @bonded_chan_ptr_ptr: Pointer to bonded channel pointer
2577  * @treat_nol_chan_as_disabled: Bool to treat nol chan as enabled/disabled
2578  * @in_pwr_type: Input 6g power type
2579  *
2580  * Return: Channel state
2581  */
2582 #ifdef WLAN_FEATURE_11BE
2583 enum channel_state
2584 reg_get_chan_state_for_320(struct wlan_objmgr_pdev *pdev,
2585 			   uint16_t freq,
2586 			   qdf_freq_t center_320,
2587 			   enum phy_ch_width ch_width,
2588 			   const struct bonded_channel_freq
2589 			   **bonded_chan_ptr_ptr,
2590 			   enum supported_6g_pwr_types in_pwr_type,
2591 			   bool treat_nol_chan_as_disabled);
2592 #else
2593 static inline enum channel_state
2594 reg_get_chan_state_for_320(struct wlan_objmgr_pdev *pdev,
2595 			   uint16_t freq,
2596 			   qdf_freq_t center_320,
2597 			   enum phy_ch_width ch_width,
2598 			   const struct bonded_channel_freq
2599 			   **bonded_chan_ptr_ptr,
2600 			   enum supported_6g_pwr_types in_pwr_type,
2601 			   bool treat_nol_chan_as_disabled)
2602 {
2603 	return CHANNEL_STATE_INVALID;
2604 }
2605 #endif
2606 
2607 /**
2608  * reg_get_regd_rules() - provides the reg domain rules info
2609  * @pdev: pdev pointer
2610  * @reg_rules: regulatory rules
2611  *
2612  * Return: QDF_STATUS
2613  */
2614 QDF_STATUS reg_get_regd_rules(struct wlan_objmgr_pdev *pdev,
2615 			      struct reg_rule_info *reg_rules);
2616 
2617 #if defined(CONFIG_AFC_SUPPORT) && defined(CONFIG_BAND_6GHZ)
2618 /**
2619  * reg_is_sup_chan_entry_afc_done() - Checks if the super chan entry of given
2620  * channel idx and power mode has REGULATORY_CHAN_AFC_NOT_DONE flag cleared.
2621  *
2622  * @pdev: pdev pointer.
2623  * @freq: input channel idx.
2624  * @in_6g_pwr_mode: input power mode
2625  *
2626  * Return: True if REGULATORY_CHAN_AFC_NOT_DONE flag is clear for the super
2627  * chan entry.
2628  */
2629 bool reg_is_sup_chan_entry_afc_done(struct wlan_objmgr_pdev *pdev,
2630 				    enum channel_enum chan_idx,
2631 				    enum supported_6g_pwr_types in_6g_pwr_mode);
2632 #else
2633 static inline bool
2634 reg_is_sup_chan_entry_afc_done(struct wlan_objmgr_pdev *pdev,
2635 			       enum channel_enum chan_idx,
2636 			       enum supported_6g_pwr_types in_6g_pwr_mode)
2637 {
2638 	return false;
2639 }
2640 #endif
2641 
2642 #ifdef CONFIG_BAND_6GHZ
2643 /**
2644  * reg_display_super_chan_list() - Display super channel list for all modes
2645  * @pdev: pdev pointer
2646  *
2647  * Return: QDF_STATUS
2648  */
2649 QDF_STATUS
2650 reg_display_super_chan_list(struct wlan_objmgr_pdev *pdev);
2651 #endif
2652 
2653 /**
2654  * reg_get_max_bw_5G_for_fo() - get max bw
2655  * @pdev: PDEV object
2656  *
2657  * API to get max bw from pdev.
2658  *
2659  * Return: max bw
2660  */
2661 uint16_t reg_get_max_bw_5G_for_fo(struct wlan_objmgr_pdev *pdev);
2662 #endif
2663