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