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