xref: /wlan-dirver/qca-wifi-host-cmn/umac/regulatory/dispatcher/src/wlan_reg_ucfg_api.c (revision 1b9674e21e24478fba4530f5ae7396b9555e9c6a)
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  * @file wlan_req_ucfg_api.c
22  * @brief contains regulatory user config interface definations
23  */
24 
25 #include <wlan_reg_ucfg_api.h>
26 #include "../../core/src/reg_services.h"
27 #include <qdf_module.h>
28 
29 QDF_STATUS ucfg_reg_register_event_handler(uint8_t vdev_id, reg_event_cb cb,
30 		void *arg)
31 {
32 	/* Register a event cb handler */
33 	return QDF_STATUS_SUCCESS;
34 }
35 
36 QDF_STATUS ucfg_reg_unregister_event_handler(uint8_t vdev_id, reg_event_cb cb,
37 		void *arg)
38 {
39 	/* unregister a event cb handler */
40 	return QDF_STATUS_SUCCESS;
41 }
42 
43 QDF_STATUS ucfg_reg_init_handler(uint8_t pdev_id)
44 {
45 	/* regulatory initialization handler */
46 	return QDF_STATUS_SUCCESS;
47 }
48 
49 QDF_STATUS ucfg_reg_get_current_chan_list(struct wlan_objmgr_pdev *pdev,
50 					  struct regulatory_channel *chan_list)
51 {
52 	return reg_get_current_chan_list(pdev, chan_list);
53 }
54 
55 QDF_STATUS ucfg_reg_modify_chan_144(struct wlan_objmgr_pdev *pdev,
56 				    bool enable_ch_144)
57 {
58 	return reg_modify_chan_144(pdev, enable_ch_144);
59 }
60 
61 bool ucfg_reg_get_en_chan_144(struct wlan_objmgr_pdev *pdev)
62 {
63 	return reg_get_en_chan_144(pdev);
64 }
65 
66 QDF_STATUS ucfg_reg_set_config_vars(struct wlan_objmgr_psoc *psoc,
67 				 struct reg_config_vars config_vars)
68 {
69 	return reg_set_config_vars(psoc, config_vars);
70 }
71 
72 bool ucfg_reg_is_regdb_offloaded(struct wlan_objmgr_psoc *psoc)
73 {
74 	return reg_is_regdb_offloaded(psoc);
75 }
76 
77 void ucfg_reg_program_mas_chan_list(struct wlan_objmgr_psoc *psoc,
78 				    struct regulatory_channel *reg_channels,
79 				    uint8_t *alpha2,
80 				    enum dfs_reg dfs_region)
81 {
82 	reg_program_mas_chan_list(psoc, reg_channels, alpha2, dfs_region);
83 }
84 
85 struct reg_rule_info *ucfg_reg_get_regd_rules(struct wlan_objmgr_pdev *pdev)
86 {
87 	return reg_get_regd_rules(pdev);
88 }
89 
90 QDF_STATUS ucfg_reg_program_default_cc(struct wlan_objmgr_pdev *pdev,
91 				       uint16_t regdmn)
92 {
93 	return reg_program_default_cc(pdev, regdmn);
94 }
95 
96 QDF_STATUS ucfg_reg_program_cc(struct wlan_objmgr_pdev *pdev,
97 			       struct cc_regdmn_s *rd)
98 {
99 	return reg_program_chan_list(pdev, rd);
100 }
101 
102 QDF_STATUS ucfg_reg_get_current_cc(struct wlan_objmgr_pdev *pdev,
103 				   struct cc_regdmn_s *rd)
104 {
105 	return reg_get_current_cc(pdev, rd);
106 }
107 
108 /**
109  * ucfg_reg_set_band() - Sets the band information for the PDEV
110  * @pdev: The physical pdev to set the band for
111  * @band: The set band parameter to configure for the pysical device
112  *
113  * Return: QDF_STATUS
114  */
115 QDF_STATUS ucfg_reg_set_band(struct wlan_objmgr_pdev *pdev,
116 			     enum band_info band)
117 {
118 	return reg_set_band(pdev, band);
119 }
120 
121 /**
122  * ucfg_reg_notify_sap_event() - Notify regulatory domain for sap event
123  * @pdev: The physical dev to set the band for
124  * @sap_state: true for sap start else false
125  *
126  * Return: QDF_STATUS
127  */
128 QDF_STATUS ucfg_reg_notify_sap_event(struct wlan_objmgr_pdev *pdev,
129 			bool sap_state)
130 {
131 	return reg_notify_sap_event(pdev, sap_state);
132 }
133 
134 #ifdef DISABLE_CHANNEL_LIST
135 /**
136  * ucfg_reg_cache_channel_state() - Cache the current state of the channles
137  * @pdev: The physical dev to cache the channels for
138  * @channel_list: List of the channels for which states needs to be cached
139  * @num_channels: Number of channels in the list
140  *
141  */
142 void ucfg_reg_cache_channel_state(struct wlan_objmgr_pdev *pdev,
143 				  uint32_t *channel_list, uint32_t num_channels)
144 {
145 	reg_cache_channel_state(pdev, channel_list, num_channels);
146 }
147 
148 /**
149  * ucfg_reg_restore_cached_channels() - Cache the current state of the channles
150  * @pdev: The physical dev to cache the channels for
151  */
152 void ucfg_reg_restore_cached_channels(struct wlan_objmgr_pdev *pdev)
153 {
154 	reg_restore_cached_channels(pdev);
155 }
156 #endif
157 
158 /**
159  * ucfg_reg_set_fcc_constraint() - apply fcc constraints on channels 12/13
160  * @pdev: The physical pdev to reduce tx power for
161  *
162  * This function adjusts the transmit power on channels 12 and 13, to comply
163  * with FCC regulations in the USA.
164  *
165  * Return: QDF_STATUS
166  */
167 QDF_STATUS ucfg_reg_set_fcc_constraint(struct wlan_objmgr_pdev *pdev,
168 				       bool fcc_constraint)
169 {
170 	return reg_set_fcc_constraint(pdev, fcc_constraint);
171 }
172 
173 
174 /**
175  * ucfg_reg_get_default_country() - Get the default regulatory country
176  * @psoc: The physical SoC to get default country from
177  * @country_code: the buffer to populate the country code into
178  *
179  * Return: QDF_STATUS
180  */
181 QDF_STATUS ucfg_reg_get_default_country(struct wlan_objmgr_psoc *psoc,
182 					       uint8_t *country_code)
183 {
184 	return reg_read_default_country(psoc, country_code);
185 }
186 
187 QDF_STATUS ucfg_reg_get_current_country(struct wlan_objmgr_psoc *psoc,
188 					       uint8_t *country_code)
189 {
190 	return reg_read_current_country(psoc, country_code);
191 }
192 /**
193  * ucfg_reg_set_default_country() - Set the default regulatory country
194  * @psoc: The physical SoC to set default country for
195  * @country: The country information to configure
196  *
197  * Return: QDF_STATUS
198  */
199 QDF_STATUS ucfg_reg_set_default_country(struct wlan_objmgr_psoc *psoc,
200 					uint8_t *country)
201 {
202 	return reg_set_default_country(psoc, country);
203 }
204 
205 /**
206  * ucfg_reg_set_country() - Set the current regulatory country
207  * @pdev: The physical dev to set current country for
208  * @country: The country information to configure
209  *
210  * Return: QDF_STATUS
211  */
212 QDF_STATUS ucfg_reg_set_country(struct wlan_objmgr_pdev *pdev,
213 				uint8_t *country)
214 {
215 	return reg_set_country(pdev, country);
216 }
217 
218 /**
219  * ucfg_reg_reset_country() - Reset the regulatory country to default
220  * @psoc: The physical SoC to reset country for
221  *
222  * Return: QDF_STATUS
223  */
224 QDF_STATUS ucfg_reg_reset_country(struct wlan_objmgr_psoc *psoc)
225 {
226 	return reg_reset_country(psoc);
227 }
228 
229 /**
230  * ucfg_reg_enable_dfs_channels() - Enable the use of DFS channels
231  * @pdev: The physical dev to enable DFS channels for
232  *
233  * Return: QDF_STATUS
234  */
235 QDF_STATUS ucfg_reg_enable_dfs_channels(struct wlan_objmgr_pdev *pdev,
236 					bool dfs_enable)
237 {
238 	return reg_enable_dfs_channels(pdev, dfs_enable);
239 }
240 
241 QDF_STATUS ucfg_reg_get_curr_band(struct wlan_objmgr_pdev *pdev,
242 				  enum band_info *band)
243 {
244 	return reg_get_curr_band(pdev, band);
245 
246 }
247 
248 void ucfg_reg_register_chan_change_callback(struct wlan_objmgr_psoc *psoc,
249 					    reg_chan_change_callback cbk,
250 					    void *arg)
251 {
252 	reg_register_chan_change_callback(psoc, cbk, arg);
253 }
254 
255 void ucfg_reg_unregister_chan_change_callback(struct wlan_objmgr_psoc *psoc,
256 					      reg_chan_change_callback cbk)
257 {
258 	reg_unregister_chan_change_callback(psoc, cbk);
259 }
260 
261 enum country_src ucfg_reg_get_cc_and_src(struct wlan_objmgr_psoc *psoc,
262 					 uint8_t *alpha2)
263 {
264 	return reg_get_cc_and_src(psoc, alpha2);
265 }
266 
267 void ucfg_reg_unit_simulate_ch_avoid(struct wlan_objmgr_psoc *psoc,
268 	struct ch_avoid_ind_type *ch_avoid)
269 {
270 	reg_process_ch_avoid_event(psoc, ch_avoid);
271 }
272 
273 QDF_STATUS ucfg_reg_11d_vdev_delete_update(struct wlan_objmgr_vdev *vdev)
274 {
275 	return reg_11d_vdev_delete_update(vdev);
276 }
277 
278 QDF_STATUS ucfg_reg_11d_vdev_created_update(struct wlan_objmgr_vdev *vdev)
279 {
280 	return reg_11d_vdev_created_update(vdev);
281 }
282 
283 struct wlan_psoc_host_hal_reg_capabilities_ext *ucfg_reg_get_hal_reg_cap(
284 				struct wlan_objmgr_psoc *psoc)
285 {
286 	return reg_get_hal_reg_cap(psoc);
287 }
288 qdf_export_symbol(ucfg_reg_get_hal_reg_cap);
289 
290 QDF_STATUS ucfg_reg_set_hal_reg_cap(struct wlan_objmgr_psoc *psoc,
291 		struct wlan_psoc_host_hal_reg_capabilities_ext *hal_reg_cap,
292 		uint16_t phy_cnt)
293 
294 {
295 	return reg_set_hal_reg_cap(psoc, hal_reg_cap, phy_cnt);
296 }
297 qdf_export_symbol(ucfg_reg_set_hal_reg_cap);
298