xref: /wlan-dirver/qca-wifi-host-cmn/umac/regulatory/core/src/reg_services_common.h (revision f28396d060cff5c6519f883cb28ae0116ce479f1)
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 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 #define REG_MIN_49GHZ_CH_FREQ channel_map[MIN_49GHZ_CHANNEL].center_freq
59 #define REG_MAX_49GHZ_CH_FREQ channel_map[MAX_49GHZ_CHANNEL].center_freq
60 
61 #define REG_IS_49GHZ_FREQ(freq) \
62 	(((freq) >= REG_MIN_49GHZ_CH_FREQ) &&   \
63 	((freq) <= REG_MAX_49GHZ_CH_FREQ))
64 
65 #ifdef CONFIG_CHAN_NUM_API
66 #define REG_IS_5GHZ_CH(chan_num) \
67 	(((chan_num) >= REG_MIN_5GHZ_CH_NUM) &&	\
68 	 ((chan_num) <= REG_MAX_5GHZ_CH_NUM))
69 #endif /* CONFIG_CHAN_NUM_API */
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 #ifdef CONFIG_BAND_6GHZ
76 #define FREQ_LEFT_SHIFT         55
77 #define SIXG_STARTING_FREQ      5940
78 #define NUM_80MHZ_BAND_IN_6G    16
79 #define NUM_PSC_FREQ            15
80 #define PSC_BAND_MHZ (FREQ_TO_CHAN_SCALE * NUM_80MHZ_BAND_IN_6G)
81 #define REG_MIN_6GHZ_CHAN_FREQ channel_map[MIN_6GHZ_CHANNEL].center_freq
82 #define REG_MAX_6GHZ_CHAN_FREQ channel_map[MAX_6GHZ_CHANNEL].center_freq
83 #else
84 #define FREQ_LEFT_SHIFT         0
85 #define SIXG_STARTING_FREQ      0
86 #define NUM_80MHZ_BAND_IN_6G    0
87 #define NUM_PSC_FREQ            0
88 #define PSC_BAND_MHZ (FREQ_TO_CHAN_SCALE * NUM_80MHZ_BAND_IN_6G)
89 #define REG_MIN_6GHZ_CHAN_FREQ  0
90 #define REG_MAX_6GHZ_CHAN_FREQ  0
91 #endif /*CONFIG_BAND_6GHZ*/
92 
93 #define REG_CH_NUM(ch_enum) channel_map[ch_enum].chan_num
94 #define REG_CH_TO_FREQ(ch_enum) channel_map[ch_enum].center_freq
95 
96 /* EEPROM setting is a country code */
97 #define    COUNTRY_ERD_FLAG     0x8000
98 #define MIN_6GHZ_OPER_CLASS 131
99 #define MAX_6GHZ_OPER_CLASS 135
100 
101 extern const struct chan_map *channel_map;
102 extern const struct chan_map channel_map_us[];
103 extern const struct chan_map channel_map_eu[];
104 extern const struct chan_map channel_map_jp[];
105 extern const struct chan_map channel_map_china[];
106 extern const struct chan_map channel_map_global[];
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(uint8_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 					 uint8_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, uint8_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 				   uint8_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 qdf_freq_t reg_get_channel_freq(struct wlan_objmgr_pdev *pdev,
232 				uint8_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(uint8_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, uint8_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 uint8_t reg_freq_to_chan(struct wlan_objmgr_pdev *pdev, qdf_freq_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 qdf_freq_t reg_chan_to_freq(struct wlan_objmgr_pdev *pdev, uint8_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 		       qdf_freq_t low_freq_2g, qdf_freq_t high_freq_2g,
435 		       qdf_freq_t low_freq_5g, qdf_freq_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 qdf_freq_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(qdf_freq_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 qdf_freq_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 qdf_freq_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(uint8_t chan_num1, uint8_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(uint8_t curchan, uint8_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 uint8_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 uint8_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 uint8_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 uint8_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 qdf_freq_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 qdf_freq_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 qdf_freq_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 qdf_freq_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 DISABLE_UNII_SHARED_BANDS
731 /**
732  * reg_disable_chan_coex() - Disable Coexisting channels based on the input
733  * bitmask.
734  * @pdev: pointer to wlan_objmgr_pdev.
735  * unii_5g_bitmap: UNII 5G bitmap.
736  *
737  * Return : QDF_STATUS
738  */
739 QDF_STATUS reg_disable_chan_coex(struct wlan_objmgr_pdev *pdev,
740 				 uint8_t unii_5g_bitmap);
741 #endif
742 
743 #ifdef CONFIG_CHAN_FREQ_API
744 /**
745  * reg_is_freq_present_in_cur_chan_list() - Check the input frequency
746  * @pdev: Pointer to pdev
747  * @freq: Channel center frequency in MHz
748  *
749  * Check if the input channel center frequency is present in the current
750  * channel list
751  *
752  * Return: Return true if channel center frequency is present in the current
753  * channel list, else return false.
754  */
755 bool
756 reg_is_freq_present_in_cur_chan_list(struct wlan_objmgr_pdev *pdev,
757 				     qdf_freq_t freq);
758 
759 /**
760  * reg_get_chan_enum_for_freq() - Get channel enum for given channel frequency
761  * @freq: Channel Frequency
762  *
763  * Return: Channel enum
764  */
765 enum channel_enum reg_get_chan_enum_for_freq(qdf_freq_t freq);
766 
767 /**
768  * reg_get_channel_list_with_power_for_freq() - Provides the channel list with
769  * power
770  * @pdev: Pointer to pdev
771  * @ch_list: Pointer to the channel list.
772  * @num_chan: Pointer to save number of channels
773  *
774  * Return: QDF_STATUS
775  */
776 QDF_STATUS
777 reg_get_channel_list_with_power_for_freq(struct wlan_objmgr_pdev *pdev,
778 					 struct channel_power *ch_list,
779 					 uint8_t *num_chan);
780 
781 /**
782  * reg_get_channel_state_for_freq() - Get channel state from regulatory
783  * @pdev: Pointer to pdev
784  * @freq: channel center frequency.
785  *
786  * Return: channel state
787  */
788 enum channel_state reg_get_channel_state_for_freq(struct wlan_objmgr_pdev *pdev,
789 						  qdf_freq_t freq);
790 
791 /**
792  * reg_get_5g_bonded_channel_state_for_freq() - Get channel state for
793  * 5G bonded channel using the channel frequency
794  * @pdev: Pointer to pdev
795  * @freq: channel center frequency.
796  * @bw: channel band width
797  *
798  * Return: channel state
799  */
800 enum channel_state
801 reg_get_5g_bonded_channel_state_for_freq(struct wlan_objmgr_pdev *pdev,
802 					 qdf_freq_t freq,
803 					 enum phy_ch_width bw);
804 
805 /**
806  * reg_get_2g_bonded_channel_state_for_freq() - Get channel state for 2G
807  * bonded channel
808  * @freq: channel center frequency.
809  * @pdev: Pointer to pdev
810  * @oper_ch_freq: Primary channel center frequency
811  * @sec_ch_freq: Secondary channel center frequency
812  * @bw: channel band width
813  *
814  * Return: channel state
815  */
816 enum channel_state
817 reg_get_2g_bonded_channel_state_for_freq(struct wlan_objmgr_pdev *pdev,
818 					 qdf_freq_t oper_ch_freq,
819 					 qdf_freq_t sec_ch_freq,
820 					 enum phy_ch_width bw);
821 
822 /**
823  * reg_set_channel_params_for_freq () - Sets channel parameteres for given
824  * bandwidth
825  * @pdev: Pointer to pdev
826  * @freq: Channel center frequency.
827  * @sec_ch_2g_freq: Secondary 2G channel frequency
828  * @ch_params: pointer to the channel parameters.
829  *
830  * Return: None
831  */
832 void reg_set_channel_params_for_freq(struct wlan_objmgr_pdev *pdev,
833 				     qdf_freq_t freq,
834 				     qdf_freq_t sec_ch_2g_freq,
835 				     struct ch_params *ch_params);
836 
837 /**
838  * reg_get_channel_reg_power_for_freq() - Get the txpower for the given channel
839  * @pdev: Pointer to pdev
840  * @freq: Channel frequency
841  *
842  * Return: txpower
843  */
844 uint8_t reg_get_channel_reg_power_for_freq(struct wlan_objmgr_pdev *pdev,
845 					   qdf_freq_t freq);
846 
847 /**
848  * reg_update_nol_ch_for_freq () - Updates NOL channels in current channel list
849  * @pdev: pointer to pdev object
850  * @chan_freq_list: pointer to NOL channel list
851  * @num_ch: No.of channels in list
852  * @update_nol: set/reset the NOL status
853  *
854  * Return: None
855  */
856 void reg_update_nol_ch_for_freq(struct wlan_objmgr_pdev *pdev,
857 				uint16_t *chan_freq_list,
858 				uint8_t num_chan,
859 				bool nol_chan);
860 /**
861  * reg_is_dfs_for_freq () - Checks the channel state for DFS
862  * @pdev: pdev ptr
863  * @freq: Channel center frequency
864  *
865  * Return: true or false
866  */
867 bool reg_is_dfs_for_freq(struct wlan_objmgr_pdev *pdev, qdf_freq_t freq);
868 
869 /**
870  * reg_chan_freq_is_49ghz() - Check if the input channel center frequency is
871  * 4.9GHz
872  * @pdev: Pdev pointer
873  * @chan_num: Input channel center frequency
874  *
875  * Return: true if the frequency is 4.9GHz else false.
876  */
877 bool reg_chan_freq_is_49ghz(qdf_freq_t freq);
878 
879 /**
880  * reg_update_nol_history_ch_for_freq() - Set nol-history flag for the channels
881  * in the list.
882  * @pdev: Pdev ptr.
883  * @chan_list: Input channel freqeuncy list.
884  * @num_ch: Number of channels.
885  * @nol_history_ch: NOL-History flag.
886  *
887  * Return: void
888  */
889 void reg_update_nol_history_ch_for_freq(struct wlan_objmgr_pdev *pdev,
890 					uint16_t *chan_list,
891 					uint8_t num_chan,
892 					bool nol_history_chan);
893 
894 /**
895  * reg_is_same_5g_band_freqs() - Check if given channel center
896  * frequencies have same band
897  * @freq1: Channel Center Frequency 1
898  * @freq2: Channel Center Frequency 2
899  *
900  * Return: true if both the frequencies has the same band.
901  */
902 bool reg_is_same_band_freqs(qdf_freq_t freq1, qdf_freq_t freq2);
903 
904 /**
905  * reg_is_frequency_valid_5g_sbs() Check if the given frequency is 5G SBS.
906  * @curfreq: current channel frequency
907  * @newfreq: new channel center frequency
908  *
909  * Return: true if the given center frequency is a valid 5G SBS
910  */
911 bool reg_is_frequency_valid_5g_sbs(qdf_freq_t curfreq, qdf_freq_t newfreq);
912 
913 /**
914  * reg_freq_to_band() - Get band from channel frequency
915  * @chan_num: channel frequency
916  *
917  * Return: wifi band
918  */
919 enum reg_wifi_band reg_freq_to_band(qdf_freq_t freq);
920 
921 /**
922  * reg_min_chan_freq() - minimum channel frequency supported
923  *
924  * Return: channel frequency
925  */
926 qdf_freq_t reg_min_chan_freq(void);
927 
928 /**
929  * reg_max_chan_freq() - maximum channel frequency supported
930  *
931  * Return: channel frequency
932  */
933 qdf_freq_t reg_max_chan_freq(void);
934 
935 /**
936  * reg_get_5g_bonded_channel_for_freq()- Return the channel state for a
937  * 5G or 6G channel frequency based on the channel width and bonded channel
938  * @pdev: Pointer to pdev.
939  * @freq: Channel center frequency.
940  * @ch_width: Channel Width.
941  * @bonded_chan_ptr_ptr: Pointer to bonded_channel_freq.
942  *
943  * Return: Channel State
944  */
945 enum channel_state
946 reg_get_5g_bonded_channel_for_freq(struct wlan_objmgr_pdev *pdev,
947 				   uint16_t freq,
948 				   enum phy_ch_width ch_width,
949 				   const struct bonded_channel_freq
950 				   **bonded_chan_ptr_ptr);
951 #endif /* CONFIG_CHAN_FREQ_API */
952 
953 /**
954  * reg_get_max_tx_power() - Get maximum tx power from the current channel list
955  * @pdev: Pointer to pdev
956  *
957  * Return: return the value of the maximum tx power in the current channel list
958  *
959  */
960 uint8_t reg_get_max_tx_power(struct wlan_objmgr_pdev *pdev);
961 
962 /**
963  * reg_set_ignore_fw_reg_offload_ind() - Set if regdb offload indication
964  * needs to be ignored
965  * @psoc: Pointer to psoc
966  *
967  * Return: QDF_STATUS
968  */
969 QDF_STATUS reg_set_ignore_fw_reg_offload_ind(struct wlan_objmgr_psoc *psoc);
970 
971 /**
972  * reg_get_ignore_fw_reg_offload_ind() - Check whether regdb offload indication
973  * needs to be ignored
974  *
975  * @psoc: Pointer to psoc
976  */
977 bool reg_get_ignore_fw_reg_offload_ind(struct wlan_objmgr_psoc *psoc);
978 
979 /**
980  * reg_set_6ghz_supported() - Set if 6ghz is supported
981  *
982  * @psoc: Pointer to psoc
983  * @val: value
984  */
985 QDF_STATUS reg_set_6ghz_supported(struct wlan_objmgr_psoc *psoc,
986 				  bool val);
987 
988 /**
989  * reg_is_6ghz_op_class() - Check whether 6ghz oper class
990  *
991  * @pdev: Pointer to pdev
992  * @op_class: oper class
993  */
994 bool reg_is_6ghz_op_class(struct wlan_objmgr_pdev *pdev,
995 			  uint8_t op_class);
996 
997 /**
998  * reg_is_6ghz_supported() - Whether 6ghz is supported
999  *
1000  * @pdev: pointer to pdev
1001  */
1002 bool reg_is_6ghz_supported(struct wlan_objmgr_pdev *pdev);
1003 
1004 /**
1005  * reg_get_unii_5g_bitmap() - get unii_5g_bitmap value
1006  * @pdev: pdev pointer
1007  * @bitmap: Pointer to retrieve the unii_5g_bitmap of enum reg_unii_band
1008  *
1009  * Return: QDF_STATUS
1010  */
1011 #ifdef DISABLE_UNII_SHARED_BANDS
1012 QDF_STATUS
1013 reg_get_unii_5g_bitmap(struct wlan_objmgr_pdev *pdev, uint8_t *bitmap);
1014 #endif
1015 
1016 #endif
1017