xref: /wlan-dirver/qca-wifi-host-cmn/umac/regulatory/dispatcher/src/wlan_reg_ucfg_api.c (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  * @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 QDF_STATUS ucfg_reg_get_regd_rules(struct wlan_objmgr_pdev *pdev,
86 				   struct reg_rule_info *reg_rules)
87 {
88 	return reg_get_regd_rules(pdev, reg_rules);
89 }
90 
91 QDF_STATUS ucfg_reg_program_default_cc(struct wlan_objmgr_pdev *pdev,
92 				       uint16_t regdmn)
93 {
94 	return reg_program_default_cc(pdev, regdmn);
95 }
96 
97 QDF_STATUS ucfg_reg_program_cc(struct wlan_objmgr_pdev *pdev,
98 			       struct cc_regdmn_s *rd)
99 {
100 	return reg_program_chan_list(pdev, rd);
101 }
102 
103 QDF_STATUS ucfg_reg_get_current_cc(struct wlan_objmgr_pdev *pdev,
104 				   struct cc_regdmn_s *rd)
105 {
106 	return reg_get_current_cc(pdev, rd);
107 }
108 
109 /**
110  * ucfg_reg_set_band() - Sets the band information for the PDEV
111  * @pdev: The physical pdev to set the band for
112  * @band: The set band parameter to configure for the pysical device
113  *
114  * Return: QDF_STATUS
115  */
116 QDF_STATUS ucfg_reg_set_band(struct wlan_objmgr_pdev *pdev,
117 			     enum band_info band)
118 {
119 	return reg_set_band(pdev, band);
120 }
121 
122 /**
123  * ucfg_reg_notify_sap_event() - Notify regulatory domain for sap event
124  * @pdev: The physical dev to set the band for
125  * @sap_state: true for sap start else false
126  *
127  * Return: QDF_STATUS
128  */
129 QDF_STATUS ucfg_reg_notify_sap_event(struct wlan_objmgr_pdev *pdev,
130 			bool sap_state)
131 {
132 	return reg_notify_sap_event(pdev, sap_state);
133 }
134 
135 #ifdef DISABLE_CHANNEL_LIST
136 /**
137  * ucfg_reg_cache_channel_state() - Cache the current state of the channles
138  * @pdev: The physical dev to cache the channels for
139  * @channel_list: List of the channels for which states needs to be cached
140  * @num_channels: Number of channels in the list
141  *
142  */
143 void ucfg_reg_cache_channel_state(struct wlan_objmgr_pdev *pdev,
144 				  uint32_t *channel_list, uint32_t num_channels)
145 {
146 	reg_cache_channel_state(pdev, channel_list, num_channels);
147 }
148 
149 /**
150  * ucfg_reg_restore_cached_channels() - Cache the current state of the channles
151  * @pdev: The physical dev to cache the channels for
152  */
153 void ucfg_reg_restore_cached_channels(struct wlan_objmgr_pdev *pdev)
154 {
155 	reg_restore_cached_channels(pdev);
156 }
157 #endif
158 
159 /**
160  * ucfg_reg_set_fcc_constraint() - apply fcc constraints on channels 12/13
161  * @pdev: The physical pdev to reduce tx power for
162  *
163  * This function adjusts the transmit power on channels 12 and 13, to comply
164  * with FCC regulations in the USA.
165  *
166  * Return: QDF_STATUS
167  */
168 QDF_STATUS ucfg_reg_set_fcc_constraint(struct wlan_objmgr_pdev *pdev,
169 				       bool fcc_constraint)
170 {
171 	return reg_set_fcc_constraint(pdev, fcc_constraint);
172 }
173 
174 
175 /**
176  * ucfg_reg_get_default_country() - Get the default regulatory country
177  * @psoc: The physical SoC to get default country from
178  * @country_code: the buffer to populate the country code into
179  *
180  * Return: QDF_STATUS
181  */
182 QDF_STATUS ucfg_reg_get_default_country(struct wlan_objmgr_psoc *psoc,
183 					       uint8_t *country_code)
184 {
185 	return reg_read_default_country(psoc, country_code);
186 }
187 
188 QDF_STATUS ucfg_reg_get_current_country(struct wlan_objmgr_psoc *psoc,
189 					       uint8_t *country_code)
190 {
191 	return reg_read_current_country(psoc, country_code);
192 }
193 /**
194  * ucfg_reg_set_default_country() - Set the default regulatory country
195  * @psoc: The physical SoC to set default country for
196  * @country: The country information to configure
197  *
198  * Return: QDF_STATUS
199  */
200 QDF_STATUS ucfg_reg_set_default_country(struct wlan_objmgr_psoc *psoc,
201 					uint8_t *country)
202 {
203 	return reg_set_default_country(psoc, country);
204 }
205 
206 /**
207  * ucfg_reg_set_country() - Set the current regulatory country
208  * @pdev: The physical dev to set current country for
209  * @country: The country information to configure
210  *
211  * Return: QDF_STATUS
212  */
213 QDF_STATUS ucfg_reg_set_country(struct wlan_objmgr_pdev *pdev,
214 				uint8_t *country)
215 {
216 	return reg_set_country(pdev, country);
217 }
218 
219 /**
220  * ucfg_reg_reset_country() - Reset the regulatory country to default
221  * @psoc: The physical SoC to reset country for
222  *
223  * Return: QDF_STATUS
224  */
225 QDF_STATUS ucfg_reg_reset_country(struct wlan_objmgr_psoc *psoc)
226 {
227 	return reg_reset_country(psoc);
228 }
229 
230 /**
231  * ucfg_reg_enable_dfs_channels() - Enable the use of DFS channels
232  * @pdev: The physical dev to enable DFS channels for
233  *
234  * Return: QDF_STATUS
235  */
236 QDF_STATUS ucfg_reg_enable_dfs_channels(struct wlan_objmgr_pdev *pdev,
237 					bool dfs_enable)
238 {
239 	return reg_enable_dfs_channels(pdev, dfs_enable);
240 }
241 
242 QDF_STATUS ucfg_reg_get_curr_band(struct wlan_objmgr_pdev *pdev,
243 				  enum band_info *band)
244 {
245 	return reg_get_curr_band(pdev, band);
246 
247 }
248 
249 void ucfg_reg_register_chan_change_callback(struct wlan_objmgr_psoc *psoc,
250 					    reg_chan_change_callback cbk,
251 					    void *arg)
252 {
253 	reg_register_chan_change_callback(psoc, cbk, arg);
254 }
255 
256 void ucfg_reg_unregister_chan_change_callback(struct wlan_objmgr_psoc *psoc,
257 					      reg_chan_change_callback cbk)
258 {
259 	reg_unregister_chan_change_callback(psoc, cbk);
260 }
261 
262 enum country_src ucfg_reg_get_cc_and_src(struct wlan_objmgr_psoc *psoc,
263 					 uint8_t *alpha2)
264 {
265 	return reg_get_cc_and_src(psoc, alpha2);
266 }
267 
268 void ucfg_reg_unit_simulate_ch_avoid(struct wlan_objmgr_psoc *psoc,
269 	struct ch_avoid_ind_type *ch_avoid)
270 {
271 	reg_process_ch_avoid_event(psoc, ch_avoid);
272 }
273 
274 QDF_STATUS ucfg_reg_11d_vdev_delete_update(struct wlan_objmgr_vdev *vdev)
275 {
276 	return reg_11d_vdev_delete_update(vdev);
277 }
278 
279 QDF_STATUS ucfg_reg_11d_vdev_created_update(struct wlan_objmgr_vdev *vdev)
280 {
281 	return reg_11d_vdev_created_update(vdev);
282 }
283 
284 struct wlan_psoc_host_hal_reg_capabilities_ext *ucfg_reg_get_hal_reg_cap(
285 				struct wlan_objmgr_psoc *psoc)
286 {
287 	return reg_get_hal_reg_cap(psoc);
288 }
289 qdf_export_symbol(ucfg_reg_get_hal_reg_cap);
290 
291 QDF_STATUS ucfg_reg_set_hal_reg_cap(struct wlan_objmgr_psoc *psoc,
292 		struct wlan_psoc_host_hal_reg_capabilities_ext *hal_reg_cap,
293 		uint16_t phy_cnt)
294 
295 {
296 	return reg_set_hal_reg_cap(psoc, hal_reg_cap, phy_cnt);
297 }
298 qdf_export_symbol(ucfg_reg_set_hal_reg_cap);
299