xref: /wlan-dirver/qca-wifi-host-cmn/umac/regulatory/core/src/reg_services_common.h (revision 11f5a63a6cbdda84849a730de22f0a71e635d58c)
1 /*
2  * Copyright (c) 2017-2019 The Linux Foundation. All rights reserved.
3  *
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: reg_services.h
22  * This file provides prototypes of the regulatory component
23  * service functions
24  */
25 
26 #ifndef __REG_SERVICES_COMMON_H_
27 #define __REG_SERVICES_COMMON_H_
28 
29 #define IS_VALID_PSOC_REG_OBJ(psoc_priv_obj) (psoc_priv_obj)
30 #define IS_VALID_PDEV_REG_OBJ(pdev_priv_obj) (pdev_priv_obj)
31 #define FREQ_TO_CHAN_SCALE     5
32 /* The distance between the 80Mhz center and the nearest 20Mhz channel */
33 #define NEAREST_20MHZ_CHAN_FREQ_OFFSET     10
34 
35 #ifdef CONFIG_CHAN_NUM_API
36 #define REG_MIN_24GHZ_CH_NUM channel_map[MIN_24GHZ_CHANNEL].chan_num
37 #define REG_MAX_24GHZ_CH_NUM channel_map[MAX_24GHZ_CHANNEL].chan_num
38 #define REG_MIN_5GHZ_CH_NUM channel_map[MIN_5GHZ_CHANNEL].chan_num
39 #define REG_MAX_5GHZ_CH_NUM channel_map[MAX_5GHZ_CHANNEL].chan_num
40 
41 #define REG_IS_24GHZ_CH(chan_num) \
42 	(((chan_num) >= REG_MIN_24GHZ_CH_NUM) &&	\
43 	 ((chan_num) <= REG_MAX_24GHZ_CH_NUM))
44 #endif /* CONFIG_CHAN_NUM_API */
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 FIVEG_STARTING_FREQ     5000
55 #define TWOG_STARTING_FREQ      2407
56 #define TWOG_CHAN_14_IN_MHZ     2484
57 #define TWOG_CHAN_1_IN_MHZ      2412
58 #define TWOG_CHAN_5_IN_MHZ      2432
59 #define TWOG_CHAN_6_IN_MHZ      2437
60 #define TWOG_CHAN_13_IN_MHZ     2472
61 #define REG_MIN_5GHZ_CH_FREQ channel_map[MIN_5GHZ_CHANNEL].center_freq
62 #define REG_MAX_5GHZ_CH_FREQ channel_map[MAX_5GHZ_CHANNEL].center_freq
63 #endif /* CONFIG_CHAN_FREQ_API */
64 
65 #define REG_MIN_49GHZ_CH_FREQ channel_map[MIN_49GHZ_CHANNEL].center_freq
66 #define REG_MAX_49GHZ_CH_FREQ channel_map[MAX_49GHZ_CHANNEL].center_freq
67 
68 #define REG_IS_49GHZ_FREQ(freq) \
69 	(((freq) >= REG_MIN_49GHZ_CH_FREQ) &&   \
70 	((freq) <= REG_MAX_49GHZ_CH_FREQ))
71 
72 #ifdef CONFIG_CHAN_NUM_API
73 #define REG_IS_5GHZ_CH(chan_num) \
74 	(((chan_num) >= REG_MIN_5GHZ_CH_NUM) &&	\
75 	 ((chan_num) <= REG_MAX_5GHZ_CH_NUM))
76 #endif /* CONFIG_CHAN_NUM_API */
77 
78 #define REG_IS_5GHZ_FREQ(freq) \
79 	(((freq) >= channel_map[MIN_5GHZ_CHANNEL].center_freq) &&	\
80 	 ((freq) <= channel_map[MAX_5GHZ_CHANNEL].center_freq))
81 
82 #ifdef CONFIG_BAND_6GHZ
83 #define FREQ_LEFT_SHIFT         55
84 #define SIXG_STARTING_FREQ      5940
85 #define NUM_80MHZ_BAND_IN_6G    16
86 #define NUM_PSC_FREQ            15
87 #define PSC_BAND_MHZ (FREQ_TO_CHAN_SCALE * NUM_80MHZ_BAND_IN_6G)
88 #define REG_MIN_6GHZ_CHAN_FREQ channel_map[MIN_6GHZ_CHANNEL].center_freq
89 #define REG_MAX_6GHZ_CHAN_FREQ channel_map[MAX_6GHZ_CHANNEL].center_freq
90 #else
91 #define FREQ_LEFT_SHIFT         0
92 #define SIXG_STARTING_FREQ      0
93 #define NUM_80MHZ_BAND_IN_6G    0
94 #define NUM_PSC_FREQ            0
95 #define PSC_BAND_MHZ (FREQ_TO_CHAN_SCALE * NUM_80MHZ_BAND_IN_6G)
96 #define REG_MIN_6GHZ_CHAN_FREQ  0
97 #define REG_MAX_6GHZ_CHAN_FREQ  0
98 #endif /*CONFIG_BAND_6GHZ*/
99 
100 #define REG_CH_NUM(ch_enum) channel_map[ch_enum].chan_num
101 #define REG_CH_TO_FREQ(ch_enum) channel_map[ch_enum].center_freq
102 
103 /* EEPROM setting is a country code */
104 #define    COUNTRY_ERD_FLAG     0x8000
105 
106 extern const struct chan_map *channel_map;
107 
108 #ifdef CONFIG_CHAN_NUM_API
109 /**
110  * reg_get_chan_enum() - Get channel enum for given channel number
111  * @chan_num: Channel number
112  *
113  * Return: Channel enum
114  */
115 enum channel_enum reg_get_chan_enum(uint32_t chan_num);
116 
117 /**
118  * reg_get_channel_list_with_power() - Provides the channel list with power
119  * @pdev: Pointer to pdev
120  * @ch_list: Pointer to the channel list.
121  * @num_chan: Pointer to save number of channels
122  *
123  * Return: QDF_STATUS
124  */
125 QDF_STATUS reg_get_channel_list_with_power(struct wlan_objmgr_pdev *pdev,
126 					   struct channel_power *ch_list,
127 					   uint8_t *num_chan);
128 
129 /**
130  * reg_get_channel_state() - Get channel state from regulatory
131  * @pdev: Pointer to pdev
132  * @ch: channel number.
133  *
134  * Return: channel state
135  */
136 enum channel_state reg_get_channel_state(struct wlan_objmgr_pdev *pdev,
137 					 uint32_t ch);
138 
139 /**
140  * reg_get_5g_bonded_channel() - get the 5G bonded channel state
141  * @pdev: Pointer to pdev structure
142  * @chan_num: channel number
143  * @ch_width: channel width
144  * @bonded_chan_ptr_ptr: bonded channel ptr ptr
145  *
146  * Return: channel state
147  */
148 enum channel_state reg_get_5g_bonded_channel(
149 		struct wlan_objmgr_pdev *pdev, uint32_t chan_num,
150 		enum phy_ch_width ch_width,
151 		const struct bonded_channel **bonded_chan_ptr_ptr);
152 
153 /**
154  * reg_get_5g_bonded_channel_state() - Get channel state for 5G bonded channel
155  * @pdev: Pointer to pdev
156  * @ch: channel number.
157  * @bw: channel band width
158  *
159  * Return: channel state
160  */
161 enum channel_state reg_get_5g_bonded_channel_state(
162 		struct wlan_objmgr_pdev *pdev, uint8_t ch,
163 		enum phy_ch_width bw);
164 
165 /**
166  * reg_get_2g_bonded_channel_state() - Get channel state for 2G bonded channel
167  * @ch: channel number.
168  * @pdev: Pointer to pdev
169  * @oper_ch: Primary channel number
170  * @sec_ch: Secondary channel number
171  * @bw: channel band width
172  *
173  * Return: channel state
174  */
175 enum channel_state reg_get_2g_bonded_channel_state(
176 		struct wlan_objmgr_pdev *pdev, uint8_t oper_ch, uint8_t sec_ch,
177 		enum phy_ch_width bw);
178 
179 /**
180  * reg_set_channel_params () - Sets channel parameteres for given bandwidth
181  * @pdev: Pointer to pdev
182  * @ch: channel number.
183  * @sec_ch_2g: Secondary 2G channel
184  * @ch_params: pointer to the channel parameters.
185  *
186  * Return: None
187  */
188 void reg_set_channel_params(struct wlan_objmgr_pdev *pdev,
189 			    uint8_t ch, uint8_t sec_ch_2g,
190 			    struct ch_params *ch_params);
191 #endif /* CONFIG_CHAN_NUM_API */
192 
193 /**
194  * reg_read_default_country() - Get the default regulatory country
195  * @psoc: The physical SoC to get default country from
196  * @country_code: the buffer to populate the country code into
197  *
198  * Return: QDF_STATUS
199  */
200 QDF_STATUS reg_read_default_country(struct wlan_objmgr_psoc *psoc,
201 				    uint8_t *country_code);
202 
203 /**
204  * reg_get_current_dfs_region () - Get the current dfs region
205  * @pdev: Pointer to pdev
206  * @dfs_reg: pointer to dfs region
207  *
208  * Return: None
209  */
210 void reg_get_current_dfs_region(struct wlan_objmgr_pdev *pdev,
211 				enum dfs_reg *dfs_reg);
212 
213 #ifdef CONFIG_CHAN_NUM_API
214 /**
215  * reg_get_channel_reg_power() - Get the txpower for the given channel
216  * @pdev: Pointer to pdev
217  * @chan_num: Channel number
218  *
219  * Return: txpower
220  */
221 uint32_t reg_get_channel_reg_power(struct wlan_objmgr_pdev *pdev,
222 				   uint32_t chan_num);
223 
224 /**
225  * reg_get_channel_freq() - Get the channel frequency
226  * @pdev: Pointer to pdev
227  * @chan_num: Channel number
228  *
229  * Return: frequency
230  */
231 uint32_t reg_get_channel_freq(struct wlan_objmgr_pdev *pdev,
232 			      uint32_t chan_num);
233 #endif /* CONFIG_CHAN_NUM_API */
234 
235 /**
236  * reg_get_bw_value() - give bandwidth value
237  * bw: bandwidth enum
238  *
239  * Return: uint16_t
240  */
241 uint16_t reg_get_bw_value(enum phy_ch_width bw);
242 
243 /**
244  * reg_set_dfs_region () - Set the current dfs region
245  * @pdev: Pointer to pdev
246  * @dfs_reg: pointer to dfs region
247  *
248  * Return: None
249  */
250 void reg_set_dfs_region(struct wlan_objmgr_pdev *pdev,
251 			enum dfs_reg dfs_reg);
252 
253 #ifdef CONFIG_CHAN_NUM_API
254 /**
255  * reg_chan_to_band() - Get band from channel number
256  * @chan_num: channel number
257  *
258  * Return: band info
259  */
260 enum band_info reg_chan_to_band(uint32_t chan_num);
261 #endif /* CONFIG_CHAN_NUM_API */
262 
263 /**
264  * reg_program_chan_list() - Set user country code and populate the channel list
265  * @pdev: Pointer to pdev
266  * @rd: Pointer to cc_regdmn_s structure
267  *
268  * Return: QDF_STATUS
269  */
270 QDF_STATUS reg_program_chan_list(struct wlan_objmgr_pdev *pdev,
271 				 struct cc_regdmn_s *rd);
272 
273 #ifdef CONFIG_CHAN_NUM_API
274 /**
275  * reg_update_nol_ch () - Updates NOL channels in current channel list
276  * @pdev: pointer to pdev object
277  * @ch_list: pointer to NOL channel list
278  * @num_ch: No.of channels in list
279  * @update_nol: set/reset the NOL status
280  *
281  * Return: None
282  */
283 void reg_update_nol_ch(struct wlan_objmgr_pdev *pdev, uint8_t *chan_list,
284 		       uint8_t num_chan, bool nol_chan);
285 
286 /**
287  * reg_is_dfs_ch () - Checks the channel state for DFS
288  * @pdev: pdev ptr
289  * @chan: channel
290  *
291  * Return: true or false
292  */
293 bool reg_is_dfs_ch(struct wlan_objmgr_pdev *pdev, uint32_t chan);
294 #endif /* CONFIG_CHAN_NUM_API */
295 
296 /**
297  * reg_freq_to_chan() - Get channel number from frequency.
298  * @pdev: Pointer to pdev
299  * @freq: Channel frequency
300  *
301  * Return: Channel number if success, otherwise 0
302  */
303 uint32_t reg_freq_to_chan(struct wlan_objmgr_pdev *pdev, uint32_t freq);
304 
305 #ifdef CONFIG_CHAN_NUM_API
306 /**
307  * reg_chan_to_freq() - Get frequency from channel number
308  * @pdev: Pointer to pdev
309  * @chan_num: Channel number
310  *
311  * Return: Channel frequency if success, otherwise 0
312  */
313 uint32_t reg_chan_to_freq(struct wlan_objmgr_pdev *pdev, uint32_t chan_num);
314 
315 /**
316  * reg_legacy_chan_to_freq() - Get freq from chan noumber, for 2G and 5G
317  * @pdev: Pointer to pdev
318  * @chan_num: Channel number
319  *
320  * Return: Channel frequency if success, otherwise 0
321  */
322 uint16_t reg_legacy_chan_to_freq(struct wlan_objmgr_pdev *pdev,
323 				 uint8_t chan_num);
324 
325 /**
326  * reg_chan_is_49ghz() - Check if the input channel number is 4.9GHz
327  * @pdev: Pdev pointer
328  * @chan_num: Input channel number
329  *
330  * Return: true if the channel is 4.9GHz else false.
331  */
332 bool reg_chan_is_49ghz(struct wlan_objmgr_pdev *pdev, uint8_t chan_num);
333 #endif /* CONFIG_CHAN_NUM_API */
334 
335 /**
336  * reg_program_default_cc() - Program default country code
337  * @pdev: Pdev pointer
338  * @regdmn: Regdomain value
339  *
340  * Return: QDF_STATUS
341  */
342 QDF_STATUS reg_program_default_cc(struct wlan_objmgr_pdev *pdev,
343 				  uint16_t regdmn);
344 
345 /**
346  * reg_get_current_cc() - Get current country code
347  * @pdev: Pdev pointer
348  * @regdmn: Pointer to get current country values
349  *
350  * Return: QDF_STATUS
351  */
352 QDF_STATUS reg_get_current_cc(struct wlan_objmgr_pdev *pdev,
353 			      struct cc_regdmn_s *rd);
354 
355 /**
356  * reg_get_curr_band() - Get current band
357  * @pdev: Pdev pointer
358  * @band: Pointer to save the current band
359  *
360  * Return: QDF_STATUS
361  */
362 QDF_STATUS reg_get_curr_band(struct wlan_objmgr_pdev *pdev,
363 			     enum band_info *band);
364 
365 /**
366  * reg_set_regdb_offloaded() - set/clear regulatory offloaded flag
367  *
368  * @psoc: psoc pointer
369  * Return: Success or Failure
370  */
371 QDF_STATUS reg_set_regdb_offloaded(struct wlan_objmgr_psoc *psoc, bool val);
372 
373 /**
374  * reg_get_curr_regdomain() - Get current regdomain in use
375  * @pdev: pdev pointer
376  * @cur_regdmn: Current regdomain info
377  *
378  * Return: QDF status
379  */
380 QDF_STATUS reg_get_curr_regdomain(struct wlan_objmgr_pdev *pdev,
381 				  struct cur_regdmn_info *cur_regdmn);
382 
383 /**
384  * reg_modify_chan_144() - Enable/Disable channel 144
385  * @pdev: pdev pointer
386  * @en_chan_144: flag to disable/enable channel 144
387  *
388  * Return: Success or Failure
389  */
390 QDF_STATUS reg_modify_chan_144(struct wlan_objmgr_pdev *pdev, bool en_chan_144);
391 
392 /**
393  * reg_get_en_chan_144() - get en_chan_144 flag value
394  * @pdev: pdev pointer
395  *
396  * Return: en_chan_144 flag value
397  */
398 bool reg_get_en_chan_144(struct wlan_objmgr_pdev *pdev);
399 
400 /**
401  * reg_get_hal_reg_cap() - Get HAL REG capabilities
402  * @psoc: psoc for country information
403  *
404  * Return: hal reg cap pointer
405  */
406 struct wlan_psoc_host_hal_reg_capabilities_ext *reg_get_hal_reg_cap(
407 		struct wlan_objmgr_psoc *psoc);
408 
409 /**
410  * reg_set_hal_reg_cap() - Set HAL REG capabilities
411  * @psoc: psoc for country information
412  * @reg_cap: Regulatory caps pointer
413  * @phy_cnt: number of phy
414  *
415  * Return: hal reg cap pointer
416  */
417 QDF_STATUS reg_set_hal_reg_cap(
418 		struct wlan_objmgr_psoc *psoc,
419 		struct wlan_psoc_host_hal_reg_capabilities_ext *reg_cap,
420 		uint16_t phy_cnt);
421 
422 /**
423  * reg_chan_in_range() - Check if the given channel is in pdev's channel range
424  * @chan_list: Pointer to regulatory channel list.
425  * @low_freq_2g: Low frequency 2G.
426  * @high_freq_2g: High frequency 2G.
427  * @low_freq_5g: Low frequency 5G.
428  * @high_freq_5g: High frequency 5G.
429  * @ch_enum: Channel enum.
430  *
431  * Return: true if ch_enum is with in pdev's channel range, else false.
432  */
433 bool reg_chan_in_range(struct regulatory_channel *chan_list,
434 		       uint32_t low_freq_2g, uint32_t high_freq_2g,
435 		       uint32_t low_freq_5g, uint32_t high_freq_5g,
436 		       enum channel_enum ch_enum);
437 
438 /**
439  * reg_init_channel_map() - Initialize the channel list based on the dfs region.
440  * @dfs_region: Dfs region
441  */
442 void reg_init_channel_map(enum dfs_reg dfs_region);
443 
444 /**
445  * reg_get_psoc_tx_ops() - Get regdb tx ops
446  * @psoc: Pointer to psoc structure
447  */
448 struct wlan_lmac_if_reg_tx_ops *reg_get_psoc_tx_ops(
449 	struct wlan_objmgr_psoc *psoc);
450 
451 #ifdef CONFIG_CHAN_NUM_API
452 /**
453  * reg_update_nol_history_ch() - Set nol-history flag for the channels in the
454  * list.
455  * @pdev: Pdev ptr.
456  * @ch_list: Input channel list.
457  * @num_ch: Number of channels.
458  * @nol_history_ch: NOL-History flag.
459  *
460  * Return: void
461  */
462 void reg_update_nol_history_ch(struct wlan_objmgr_pdev *pdev,
463 			       uint8_t *chan_list,
464 			       uint8_t num_chan,
465 			       bool nol_history_chan);
466 
467 /**
468  * reg_is_24ghz_ch() - Check if the given channel number is 2.4GHz
469  * @chan: Channel number
470  *
471  * Return: true if channel number is 2.4GHz, else false
472  */
473 bool reg_is_24ghz_ch(uint32_t chan);
474 
475 /**
476  * reg_is_5ghz_ch() - Check if the given channel number is 5GHz
477  * @chan: Channel number
478  *
479  * Return: true if channel number is 5GHz, else false
480  */
481 bool reg_is_5ghz_ch(uint32_t chan);
482 #endif /* CONFIG_CHAN_NUM_API */
483 
484 /**
485  * reg_is_24ghz_ch_freq() - Check if the given channel frequency is 2.4GHz
486  * @freq: Channel frequency
487  *
488  * Return: true if channel frequency is 2.4GHz, else false
489  */
490 bool reg_is_24ghz_ch_freq(uint32_t freq);
491 
492 /**
493  * reg_is_5ghz_ch_freq() - Check if the given channel frequency is 5GHz
494  * @freq: Channel frequency
495  *
496  * Return: true if channel frequency is 5GHz, else false
497  */
498 bool reg_is_5ghz_ch_freq(uint32_t freq);
499 
500 #ifdef CONFIG_BAND_6GHZ
501 /**
502  * reg_is_6ghz_chan_freq() - Check if the given channel frequency is 6GHz
503  * @freq: Channel frequency
504  *
505  * Return: true if channel frequency is 6GHz, else false
506  */
507 bool reg_is_6ghz_chan_freq(uint16_t freq);
508 
509 /**
510  * REG_IS_6GHZ_FREQ() - Check if the given channel frequency is 6GHz
511  * @freq: Channel frequency
512  *
513  * Return: true if channel frequency is 6GHz, else false
514  */
515 static inline bool REG_IS_6GHZ_FREQ(uint16_t freq)
516 {
517 	return ((freq >= REG_MIN_6GHZ_CHAN_FREQ) &&
518 		(freq <= REG_MAX_6GHZ_CHAN_FREQ));
519 }
520 
521 /**
522  * reg_is_6ghz_psc_chan_freq() - Check if the given 6GHz channel frequency is
523  * preferred scanning channel frequency.
524  * @freq: Channel frequency
525  *
526  * Return: true if given 6GHz channel frequency is preferred scanning channel
527  * frequency, else false
528  */
529 bool reg_is_6ghz_psc_chan_freq(uint16_t freq);
530 
531 /**
532  * reg_min_6ghz_chan_freq() - Get minimum 6GHz channel center frequency
533  *
534  * Return: Minimum 6GHz channel center frequency
535  */
536 uint16_t reg_min_6ghz_chan_freq(void);
537 
538 /**
539  * reg_max_6ghz_chan_freq() - Get maximum 6GHz channel center frequency
540  *
541  * Return: Maximum 6GHz channel center frequency
542  */
543 uint16_t reg_max_6ghz_chan_freq(void);
544 #else
545 static inline bool reg_is_6ghz_chan_freq(uint16_t freq)
546 {
547 	return false;
548 }
549 
550 static inline bool REG_IS_6GHZ_FREQ(uint16_t freq)
551 {
552 	return false;
553 }
554 
555 static inline bool reg_is_6ghz_psc_chan_freq(uint16_t freq)
556 {
557 	return false;
558 }
559 
560 static inline uint16_t reg_min_6ghz_chan_freq(void)
561 {
562 	return 0;
563 }
564 
565 static inline uint16_t reg_max_6ghz_chan_freq(void)
566 {
567 	return 0;
568 }
569 #endif /* CONFIG_BAND_6GHZ */
570 
571 /**
572  * reg_get_band_channel_list() - Get the channel list and number of channels
573  * @pdev: pdev ptr
574  * @band_mask: Input bitmap with band set
575  * @channel_list: Pointer to Channel List
576  *
577  * Get the given channel list and number of channels from the current channel
578  * list based on input band bitmap.
579  *
580  * Return: Number of channels, else 0 to indicate error
581  */
582 uint16_t reg_get_band_channel_list(struct wlan_objmgr_pdev *pdev,
583 				   uint8_t band_mask,
584 				   struct regulatory_channel *channel_list);
585 
586 /**
587  * reg_chan_band_to_freq - Return channel frequency based on the channel number
588  * and band.
589  * @pdev: pdev ptr
590  * @chan: Channel Number
591  * @band_mask: Bitmap for bands
592  *
593  * Return: Return channel frequency or return 0, if the channel is disabled or
594  * if the input channel number or band_mask is invalid. Composite bands are
595  * supported only for 2.4Ghz and 5Ghz bands. For other bands the following
596  * priority is given: 1) 6Ghz 2) 5Ghz 3) 2.4Ghz.
597  */
598 uint16_t reg_chan_band_to_freq(struct wlan_objmgr_pdev *pdev,
599 			       uint8_t chan,
600 			       uint8_t band_mask);
601 
602 /**
603  * reg_is_49ghz_freq() - Check if the given channel frequency is 4.9GHz
604  * @freq: Channel frequency
605  *
606  * Return: true if channel frequency is 4.9GHz, else false
607  */
608 bool reg_is_49ghz_freq(uint32_t freq);
609 
610 /**
611  * reg_ch_num() - Get channel number from channel enum
612  * @ch_enum: Channel enum
613  *
614  * Return: channel number
615  */
616 uint32_t reg_ch_num(uint32_t ch_enum);
617 
618 /**
619  * reg_ch_to_freq() - Get channel frequency from channel enum
620  * @ch_enum: Channel enum
621  *
622  * Return: channel frequency
623  */
624 uint32_t reg_ch_to_freq(uint32_t ch_enum);
625 
626 #ifdef CONFIG_CHAN_NUM_API
627 /**
628  * reg_is_same_band_channels() - Check if given channel numbers have same band
629  * @chan_num1: Channel number1
630  * @chan_num2: Channel number2
631  *
632  * Return: true if both the channels has the same band.
633  */
634 bool reg_is_same_band_channels(uint32_t chan_num1, uint32_t chan_num2);
635 
636 /**
637  * reg_is_channel_valid_5g_sbs() Check if the given channel is 5G SBS.
638  * @curchan: current channel
639  * @newchan:new channel
640  *
641  * Return: true if the given channel is a valid 5G SBS
642  */
643 bool reg_is_channel_valid_5g_sbs(uint32_t curchan, uint32_t newchan);
644 
645 /**
646  * reg_min_24ghz_ch_num() - Get minimum 2.4GHz channel number
647  *
648  * Return: Minimum 2.4GHz channel number
649  */
650 uint32_t reg_min_24ghz_ch_num(void);
651 
652 /**
653  * reg_max_24ghz_ch_num() - Get maximum 2.4GHz channel number
654  *
655  * Return: Maximum 2.4GHz channel number
656  */
657 uint32_t reg_max_24ghz_ch_num(void);
658 
659 /**
660  * reg_min_5ghz_ch_num() - Get minimum 5GHz channel number
661  *
662  * Return: Minimum 5GHz channel number
663  */
664 uint32_t reg_min_5ghz_ch_num(void);
665 
666 /**
667  * reg_max_5ghz_ch_num() - Get maximum 5GHz channel number
668  *
669  * Return: Maximum 5GHz channel number
670  */
671 uint32_t reg_max_5ghz_ch_num(void);
672 #endif /* CONFIG_CHAN_NUM_API */
673 
674 #ifdef CONFIG_CHAN_FREQ_API
675 /**
676  * reg_min_24ghz_chan_freq() - Get minimum 2.4GHz channel frequency
677  *
678  * Return: Minimum 2.4GHz channel frequency
679  */
680 uint16_t reg_min_24ghz_chan_freq(void);
681 
682 /**
683  * reg_max_24ghz_chan_freq() - Get maximum 2.4GHz channel frequency
684  *
685  * Return: Maximum 2.4GHz channel frequency
686  */
687 uint16_t reg_max_24ghz_chan_freq(void);
688 
689 /**
690  * reg_min_5ghz_chan_freq() - Get minimum 5GHz channel frequency
691  *
692  * Return: Minimum 5GHz channel frequency
693  */
694 uint16_t reg_min_5ghz_chan_freq(void);
695 
696 /**
697  * reg_max_5ghz_chan_freq() - Get maximum 5GHz channel frequency
698  *
699  * Return: Maximum 5GHz channel frequency
700  */
701 uint16_t reg_max_5ghz_chan_freq(void);
702 #endif /* CONFIG_CHAN_FREQ_API */
703 
704 /**
705  * reg_enable_dfs_channels() - Enable the use of DFS channels
706  * @pdev: The physical dev to enable/disable DFS channels for
707  *
708  * Return: QDF_STATUS
709  */
710 QDF_STATUS reg_enable_dfs_channels(struct wlan_objmgr_pdev *pdev, bool enable);
711 
712 /**
713  * reg_is_regdmn_en302502_applicable() - Find if ETSI EN302_502 radar pattern
714  * is applicable in current regulatory domain.
715  * @pdev: Pdev object pointer.
716  *
717  * Return: True if en302_502 is applicable, else false.
718  */
719 bool reg_is_regdmn_en302502_applicable(struct wlan_objmgr_pdev *pdev);
720 
721 /**
722  * reg_modify_pdev_chan_range() - Compute current channel list
723  * in accordance with the modified reg caps.
724  * @pdev: The physical dev for which channel list must be built.
725  *
726  * Return: QDF_STATUS
727  */
728 QDF_STATUS reg_modify_pdev_chan_range(struct wlan_objmgr_pdev *pdev);
729 
730 #ifdef CONFIG_CHAN_FREQ_API
731 /**
732  * reg_get_chan_enum_for_freq() - Get channel enum for given channel frequency
733  * @freq: Channel Frequency
734  *
735  * Return: Channel enum
736  */
737 enum channel_enum reg_get_chan_enum_for_freq(uint16_t freq);
738 
739 /**
740  * reg_get_channel_list_with_power_for_freq() - Provides the channel list with
741  * power
742  * @pdev: Pointer to pdev
743  * @ch_list: Pointer to the channel list.
744  * @num_chan: Pointer to save number of channels
745  *
746  * Return: QDF_STATUS
747  */
748 QDF_STATUS
749 reg_get_channel_list_with_power_for_freq(struct wlan_objmgr_pdev *pdev,
750 					 struct channel_power *ch_list,
751 					 uint8_t *num_chan);
752 
753 /**
754  * reg_get_channel_state_for_freq() - Get channel state from regulatory
755  * @pdev: Pointer to pdev
756  * @freq: channel center frequency.
757  *
758  * Return: channel state
759  */
760 enum channel_state reg_get_channel_state_for_freq(struct wlan_objmgr_pdev *pdev,
761 						  uint16_t freq);
762 
763 /**
764  * reg_get_5g_bonded_channel_state_for_freq() - Get channel state for
765  * 5G bonded channel using the channel frequency
766  * @pdev: Pointer to pdev
767  * @freq: channel center frequency.
768  * @bw: channel band width
769  *
770  * Return: channel state
771  */
772 enum channel_state
773 reg_get_5g_bonded_channel_state_for_freq(struct wlan_objmgr_pdev *pdev,
774 					 uint16_t freq,
775 					 enum phy_ch_width bw);
776 
777 /**
778  * reg_get_2g_bonded_channel_state_for_freq() - Get channel state for 2G
779  * bonded channel
780  * @freq: channel center frequency.
781  * @pdev: Pointer to pdev
782  * @oper_ch_freq: Primary channel center frequency
783  * @sec_ch_freq: Secondary channel center frequency
784  * @bw: channel band width
785  *
786  * Return: channel state
787  */
788 enum channel_state
789 reg_get_2g_bonded_channel_state_for_freq(struct wlan_objmgr_pdev *pdev,
790 					 uint16_t oper_ch_freq,
791 					 uint16_t sec_ch_freq,
792 					 enum phy_ch_width bw);
793 
794 /**
795  * reg_set_channel_params_for_freq () - Sets channel parameteres for given
796  * bandwidth
797  * @pdev: Pointer to pdev
798  * @freq: Channel center frequency.
799  * @sec_ch_2g_freq: Secondary 2G channel frequency
800  * @ch_params: pointer to the channel parameters.
801  *
802  * Return: None
803  */
804 void reg_set_channel_params_for_freq(struct wlan_objmgr_pdev *pdev,
805 				     uint16_t freq,
806 				     uint16_t sec_ch_2g_freq,
807 				     struct ch_params *ch_params);
808 
809 /**
810  * reg_get_channel_reg_power_for_freq() - Get the txpower for the given channel
811  * @pdev: Pointer to pdev
812  * @freq: Channel frequency
813  *
814  * Return: txpower
815  */
816 uint8_t reg_get_channel_reg_power_for_freq(struct wlan_objmgr_pdev *pdev,
817 					   uint16_t freq);
818 
819 /**
820  * reg_update_nol_ch_for_freq () - Updates NOL channels in current channel list
821  * @pdev: pointer to pdev object
822  * @chan_freq_list: pointer to NOL channel list
823  * @num_ch: No.of channels in list
824  * @update_nol: set/reset the NOL status
825  *
826  * Return: None
827  */
828 void reg_update_nol_ch_for_freq(struct wlan_objmgr_pdev *pdev,
829 				uint16_t *chan_freq_list,
830 				uint8_t num_chan,
831 				bool nol_chan);
832 /**
833  * reg_is_dfs_for_freq () - Checks the channel state for DFS
834  * @pdev: pdev ptr
835  * @freq: Channel center frequency
836  *
837  * Return: true or false
838  */
839 bool reg_is_dfs_for_freq(struct wlan_objmgr_pdev *pdev, uint16_t freq);
840 
841 /**
842  * reg_chan_freq_is_49ghz() - Check if the input channel center frequency is
843  * 4.9GHz
844  * @pdev: Pdev pointer
845  * @chan_num: Input channel center frequency
846  *
847  * Return: true if the frequency is 4.9GHz else false.
848  */
849 bool reg_chan_freq_is_49ghz(uint16_t freq);
850 
851 /**
852  * reg_update_nol_history_ch_for_freq() - Set nol-history flag for the channels
853  * in the list.
854  * @pdev: Pdev ptr.
855  * @chan_list: Input channel freqeuncy list.
856  * @num_ch: Number of channels.
857  * @nol_history_ch: NOL-History flag.
858  *
859  * Return: void
860  */
861 void reg_update_nol_history_ch_for_freq(struct wlan_objmgr_pdev *pdev,
862 					uint16_t *chan_list,
863 					uint8_t num_chan,
864 					bool nol_history_chan);
865 
866 /**
867  * reg_is_same_5g_band_freqs() - Check if given channel center
868  * frequencies have same band
869  * @freq1: Channel Center Frequency 1
870  * @freq2: Channel Center Frequency 2
871  *
872  * Return: true if both the frequencies has the same band.
873  */
874 bool reg_is_same_band_freqs(uint16_t freq1, uint16_t freq2);
875 
876 /**
877  * reg_is_frequency_valid_5g_sbs() Check if the given frequency is 5G SBS.
878  * @curfreq: current channel frequency
879  * @newfreq: new channel center frequency
880  *
881  * Return: true if the given center frequency is a valid 5G SBS
882  */
883 bool reg_is_frequency_valid_5g_sbs(uint16_t curfreq, uint16_t newfreq);
884 
885 /**
886  * reg_freq_to_band() - Get band from channel frequency
887  * @chan_num: channel frequency
888  *
889  * Return: wifi band
890  */
891 enum reg_wifi_band reg_freq_to_band(uint16_t freq);
892 
893 /**
894  * reg_min_chan_freq() - minimum channel frequency supported
895  *
896  * Return: channel frequency
897  */
898 uint16_t reg_min_chan_freq(void);
899 
900 /**
901  * reg_max_chan_freq() - maximum channel frequency supported
902  *
903  * Return: channel frequency
904  */
905 uint16_t reg_max_chan_freq(void);
906 
907 #endif /* CONFIG_CHAN_FREQ_API */
908 
909 /**
910  * reg_set_ignore_fw_reg_offload_ind() - Set if regdb offload indication
911  * needs to be ignored
912  * @psoc: Pointer to psoc
913  *
914  * Return: QDF_STATUS
915  */
916 QDF_STATUS reg_set_ignore_fw_reg_offload_ind(struct wlan_objmgr_psoc *psoc);
917 
918 /**
919  * reg_get_ignore_fw_reg_offload_ind() - Check whether regdb offload indication
920  * needs to be ignored
921  *
922  * @psoc: Pointer to psoc
923  */
924 bool reg_get_ignore_fw_reg_offload_ind(struct wlan_objmgr_psoc *psoc);
925 
926 #endif
927