xref: /wlan-dirver/qca-wifi-host-cmn/umac/regulatory/dispatcher/inc/wlan_reg_ucfg_api.h (revision 6d768494e5ce14eb1603a695c86739d12ecc6ec2)
1 /*
2  * Copyright (c) 2017-2020 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: wlan_reg_ucfg_api.h
22  * This file provides prototypes of the regulatory component user
23  * config interface routines
24  */
25 
26 #ifndef __WLAN_REG_UCFG_API_H
27 #define __WLAN_REG_UCFG_API_H
28 
29 #include <reg_services_public_struct.h>
30 
31 typedef QDF_STATUS (*reg_event_cb)(void *status_struct);
32 
33 /**
34  * ucfg_reg_set_band() - Sets the band information for the PDEV
35  * @pdev: The physical pdev to set the band for
36  * @band: The set band parameter to configure for the physical device
37  *
38  * Return: QDF_STATUS
39  */
40 QDF_STATUS ucfg_reg_set_band(struct wlan_objmgr_pdev *pdev,
41 			     enum band_info band);
42 
43 /**
44  * ucfg_reg_get_band() - Gets the band information for the PDEV
45  * @pdev: The physical pdev to get the band for
46  * @band: The band parameter of the physical device
47  *
48  * Return: QDF_STATUS
49  */
50 QDF_STATUS ucfg_reg_get_band(struct wlan_objmgr_pdev *pdev,
51 			     enum band_info *band);
52 
53 /**
54  * ucfg_reg_notify_sap_event() - Notify regulatory domain for sap event
55  * @pdev: The physical dev to set the band for
56  * @sap_state: true for sap start else false
57  *
58  * Return: QDF_STATUS
59  */
60 QDF_STATUS ucfg_reg_notify_sap_event(struct wlan_objmgr_pdev *pdev,
61 			bool sap_state);
62 
63 /**
64  * ucfg_reg_cache_channel_state() - Cache the current state of the channles
65  * @pdev: The physical dev to cache the channels for
66  * @channel_list: List of the channels for which states needs to be cached
67  * @num_channels: Number of channels in the list
68  *
69  * Return: QDF_STATUS
70  */
71 #if defined(DISABLE_CHANNEL_LIST) && defined(CONFIG_CHAN_NUM_API)
72 void ucfg_reg_cache_channel_state(struct wlan_objmgr_pdev *pdev,
73 				  uint32_t *channel_list,
74 				  uint32_t num_channels);
75 #else
76 static inline
77 void ucfg_reg_cache_channel_state(struct wlan_objmgr_pdev *pdev,
78 				  uint32_t *channel_list,
79 				  uint32_t num_channels)
80 {
81 }
82 #endif /* CONFIG_CHAN_NUM_API */
83 
84 /**
85  * ucfg_reg_cache_channel_freq_state() - Cache the current state of the
86  * channels based on the channel center frequency.
87  * @pdev: Pointer to pdev.
88  * @channel_list: List of the channels for which states need to be cached.
89  * @num_channels: Number of channels in the list.
90  *
91  * Return: QDF_STATUS
92  */
93 #if defined(DISABLE_CHANNEL_LIST) && defined(CONFIG_CHAN_FREQ_API)
94 void ucfg_reg_cache_channel_freq_state(struct wlan_objmgr_pdev *pdev,
95 				       uint32_t *channel_list,
96 				       uint32_t num_channels);
97 #else
98 static inline
99 void ucfg_reg_cache_channel_freq_state(struct wlan_objmgr_pdev *pdev,
100 				       uint32_t *channel_list,
101 				       uint32_t num_channels)
102 {
103 }
104 #endif /* CONFIG_CHAN_FREQ_API */
105 
106 /**
107  * ucfg_reg_restore_cached_channels() - Cache the current state of the channles
108  * @pdev: The physical dev to cache the channels for
109  *
110  * Return: QDF_STATUS
111  */
112 #ifdef DISABLE_CHANNEL_LIST
113 void ucfg_reg_restore_cached_channels(struct wlan_objmgr_pdev *pdev);
114 #else
115 static inline
116 void ucfg_reg_restore_cached_channels(struct wlan_objmgr_pdev *pdev)
117 {
118 }
119 #endif
120 
121 /**
122  * ucfg_reg_set_fcc_constraint() - apply fcc constraints on channels 12/13
123  * @pdev: The physical pdev to reduce tx power for
124  *
125  * This function adjusts the transmit power on channels 12 and 13, to comply
126  * with FCC regulations in the USA.
127  *
128  * Return: QDF_STATUS
129  */
130 QDF_STATUS ucfg_reg_set_fcc_constraint(struct wlan_objmgr_pdev *pdev,
131 		bool fcc_constraint);
132 
133 /**
134  * ucfg_reg_get_default_country() - Get the default regulatory country
135  * @psoc: The physical SoC to get default country from
136  * @country_code: the buffer to populate the country code into
137  *
138  * Return: QDF_STATUS
139  */
140 QDF_STATUS ucfg_reg_get_default_country(struct wlan_objmgr_psoc *psoc,
141 					       uint8_t *country_code);
142 
143 /**
144  * ucfg_reg_get_current_country() - Get the current regulatory country
145  * @psoc: The physical SoC to get current country from
146  * @country_code: the buffer to populate the country code into
147  *
148  * Return: QDF_STATUS
149  */
150 QDF_STATUS ucfg_reg_get_current_country(struct wlan_objmgr_psoc *psoc,
151 					       uint8_t *country_code);
152 /**
153  * ucfg_reg_set_default_country() - Set the default regulatory country
154  * @psoc: The physical SoC to set default country for
155  * @country_code: The country information to configure
156  *
157  * Return: QDF_STATUS
158  */
159 QDF_STATUS ucfg_reg_set_default_country(struct wlan_objmgr_psoc *psoc,
160 					       uint8_t *country_code);
161 
162 /**
163  * ucfg_reg_set_country() - Set the current regulatory country
164  * @pdev: The physical dev to set current country for
165  * @country_code: The country information to configure
166  *
167  * Return: QDF_STATUS
168  */
169 QDF_STATUS ucfg_reg_set_country(struct wlan_objmgr_pdev *dev,
170 				uint8_t *country_code);
171 
172 /**
173  * ucfg_reg_reset_country() - Reset the regulatory country to default
174  * @psoc: The physical SoC to reset country for
175  *
176  * Return: QDF_STATUS
177  */
178 QDF_STATUS ucfg_reg_reset_country(struct wlan_objmgr_psoc *psoc);
179 
180 /**
181  * ucfg_reg_get_curr_band() - Get the current band capability
182  * @pdev: The physical dev to get default country from
183  * @band: buffer to populate the band into
184  *
185  * Return: QDF_STATUS
186  */
187 QDF_STATUS ucfg_reg_get_curr_band(struct wlan_objmgr_pdev *pdev,
188 		enum band_info *band);
189 /**
190  * ucfg_reg_enable_dfs_channels() - Enable the use of DFS channels
191  * @pdev: The physical dev to enable DFS channels for
192  *
193  * Return: QDF_STATUS
194  */
195 QDF_STATUS ucfg_reg_enable_dfs_channels(struct wlan_objmgr_pdev *pdev,
196 		bool dfs_enable);
197 
198 QDF_STATUS ucfg_reg_register_event_handler(uint8_t vdev_id, reg_event_cb cb,
199 		void *arg);
200 QDF_STATUS ucfg_reg_unregister_event_handler(uint8_t vdev_id, reg_event_cb cb,
201 		void *arg);
202 QDF_STATUS ucfg_reg_init_handler(uint8_t pdev_id);
203 
204 QDF_STATUS ucfg_reg_program_default_cc(struct wlan_objmgr_pdev *pdev,
205 				       uint16_t regdmn);
206 
207 /**
208  * ucfg_reg_program_cc() - Program user country code or regdomain
209  * @pdev: The physical dev to program country code or regdomain
210  * @rd: User country code or regdomain
211  *
212  * Return: QDF_STATUS
213  */
214 QDF_STATUS ucfg_reg_program_cc(struct wlan_objmgr_pdev *pdev,
215 			       struct cc_regdmn_s *rd);
216 
217 /**
218  * ucfg_reg_get_current_cc() - get current country code or regdomain
219  * @pdev: The physical dev to program country code or regdomain
220  * @rd: Pointer to country code or regdomain
221  *
222  * Return: QDF_STATUS
223  */
224 QDF_STATUS ucfg_reg_get_current_cc(struct wlan_objmgr_pdev *pdev,
225 				   struct cc_regdmn_s *rd);
226 
227 /**
228  * ucfg_reg_set_config_vars () - Set the config vars in reg component
229  * @psoc: psoc ptr
230  * @config_vars: config variables structure
231  *
232  * Return: QDF_STATUS
233  */
234 QDF_STATUS ucfg_reg_set_config_vars(struct wlan_objmgr_psoc *psoc,
235 				    struct reg_config_vars config_vars);
236 
237 /**
238  * ucfg_reg_get_current_chan_list () - get current channel list
239  * @pdev: pdev ptr
240  * @chan_list: channel list
241  *
242  * Return: QDF_STATUS
243  */
244 QDF_STATUS ucfg_reg_get_current_chan_list(struct wlan_objmgr_pdev *pdev,
245 				    struct regulatory_channel *chan_list);
246 
247 /**
248  * ucfg_reg_modify_chan_144() - Enable/Disable channel 144
249  * @pdev: pdev pointer
250  * @enable_chan_144: flag to disable/enable channel 144
251  *
252  * Return: Success or Failure
253  */
254 QDF_STATUS ucfg_reg_modify_chan_144(struct wlan_objmgr_pdev *pdev,
255 				    bool enable_ch_144);
256 
257 /**
258  * ucfg_reg_get_en_chan_144() - get en_chan_144 flag value
259  * @pdev: pdev pointer
260  *
261  * Return: en_chan_144 flag value
262  */
263 bool ucfg_reg_get_en_chan_144(struct wlan_objmgr_pdev *pdev);
264 
265 /**
266  * ucfg_reg_is_regdb_offloaded () - is regulatory database offloaded
267  * @psoc: psoc ptr
268  *
269  * Return: bool
270  */
271 bool ucfg_reg_is_regdb_offloaded(struct wlan_objmgr_psoc *psoc);
272 
273 /**
274  * ucfg_reg_program_mas_chan_list () - program master channel list
275  * @psoc: psoc ptr
276  * @reg_channels: regulatory channels
277  * @alpha2: country code
278  * @dfs_region: dfs region
279  *
280  * Return: void
281  */
282 void ucfg_reg_program_mas_chan_list(struct wlan_objmgr_psoc *psoc,
283 				    struct regulatory_channel *reg_channels,
284 				    uint8_t *alpha2,
285 				    enum dfs_reg dfs_region);
286 
287 /**
288  * ucfg_reg_get_regd_rules() - provides the reg domain rules info pointer
289  * @pdev: pdev ptr
290  * @reg_rules: regulatory rules
291  *
292  * Return: QDF_STATUS
293  */
294 QDF_STATUS ucfg_reg_get_regd_rules(struct wlan_objmgr_pdev *pdev,
295 				   struct reg_rule_info *reg_rules);
296 
297 /**
298  * ucfg_reg_register_chan_change_callback () - add chan change cbk
299  * @psoc: psoc ptr
300  * @cbk: callback
301  * @arg: argument
302  *
303  * Return: void
304  */
305 void ucfg_reg_register_chan_change_callback(struct wlan_objmgr_psoc *psoc,
306 					    void *cbk, void *arg);
307 
308 /**
309  * ucfg_reg_unregister_chan_change_callback () - remove chan change cbk
310  * @psoc: psoc ptr
311  * @cbk: callback
312  *
313  * Return: void
314  */
315 void ucfg_reg_unregister_chan_change_callback(struct wlan_objmgr_psoc *psoc,
316 					      void *cbk);
317 
318 /**
319  * ucfg_reg_get_cc_and_src () - get country code and src
320  * @psoc: psoc ptr
321  * @alpha2: country code alpha2
322  *
323  * Return: void
324  */
325 enum country_src ucfg_reg_get_cc_and_src(struct wlan_objmgr_psoc *psoc,
326 					 uint8_t *alpha2);
327 
328 /**
329  * ucfg_reg_unit_simulate_ch_avoid () - fake a ch avoid event
330  * @psoc: psoc ptr
331  * @ch_avoid: ch_avoid_ind_type ranges
332  *
333  * This function inject a ch_avoid event for unit test sap chan switch.
334  *
335  * Return: void
336  */
337 void ucfg_reg_unit_simulate_ch_avoid(struct wlan_objmgr_psoc *psoc,
338 	struct ch_avoid_ind_type *ch_avoid);
339 
340 /**
341  * ucfg_reg_11d_vdev_delete_update() - update vdev delete to regulatory
342  * @vdev: vdev ptr
343  *
344  * Return: QDF_STATUS
345  */
346 QDF_STATUS ucfg_reg_11d_vdev_delete_update(struct wlan_objmgr_vdev *vdev);
347 
348 /**
349  * ucfg_reg_11d_vdev_created_update() - update vdev create to regulatory
350  * @vdev: vdev ptr
351  *
352  * Return: QDF_STATUS
353  */
354 QDF_STATUS ucfg_reg_11d_vdev_created_update(struct wlan_objmgr_vdev *vdev);
355 
356 /**
357  * ucfg_reg_get_hal_reg_cap() - return hal reg cap
358  * @psoc: psoc ptr
359  *
360  * Return: ptr to  wlan_psoc_host_hal_reg_capabilities_ext
361  */
362 struct wlan_psoc_host_hal_reg_capabilities_ext *ucfg_reg_get_hal_reg_cap(
363 				struct wlan_objmgr_psoc *psoc);
364 
365 /**
366  * ucfg_reg_set_hal_reg_cap() - update hal reg cap
367  * @psoc: psoc ptr
368  * @reg_cap: Regulatory cap array
369  * @phy_cnt: Number of phy
370  *
371  * Return: QDF_STATUS
372  */
373 QDF_STATUS ucfg_reg_set_hal_reg_cap(struct wlan_objmgr_psoc *psoc,
374 			struct wlan_psoc_host_hal_reg_capabilities_ext *reg_cap,
375 			uint16_t phy_cnt);
376 
377 /**
378  * ucfg_reg_update_hal_reg_cap() - update hal reg cap
379  * @psoc: psoc ptr
380  * @wireless_modes: 11AX wireless modes
381  * @phy_id: phy id
382  *
383  * Return: QDF_STATUS
384  */
385 QDF_STATUS ucfg_reg_update_hal_reg_cap(struct wlan_objmgr_psoc *psoc,
386 				       uint32_t wireless_modes, uint8_t phy_id);
387 
388 /**
389  * ucfg_set_ignore_fw_reg_offload_ind() - API to set ignore regdb offload ind
390  * @psoc: psoc ptr
391  *
392  * Return: QDF_STATUS
393  */
394 QDF_STATUS ucfg_set_ignore_fw_reg_offload_ind(struct wlan_objmgr_psoc *psoc);
395 
396 /**
397  * ucfg_reg_get_unii_5g_bitmap() - get unii_5g_bitmap value
398  * @pdev: pdev pointer
399  * @bitmap: Pointer to retrieve unii_5g_bitmap of enum reg_unii_band.
400  *
401  * Return: QDF_STATUS
402  */
403 #ifdef DISABLE_UNII_SHARED_BANDS
404 QDF_STATUS
405 ucfg_reg_get_unii_5g_bitmap(struct wlan_objmgr_pdev *pdev, uint8_t *bitmap);
406 #else
407 static inline QDF_STATUS
408 ucfg_reg_get_unii_5g_bitmap(struct wlan_objmgr_pdev *pdev, uint8_t *bitmap)
409 {
410 	*bitmap = 0;
411 	return QDF_STATUS_SUCCESS;
412 }
413 #endif
414 
415 #endif
416