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