xref: /wlan-dirver/qca-wifi-host-cmn/umac/regulatory/dispatcher/src/wlan_reg_ucfg_api.c (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  * @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 /**
135  * ucfg_reg_set_fcc_constraint() - apply fcc constraints on channels 12/13
136  * @pdev: The physical pdev to reduce tx power for
137  *
138  * This function adjusts the transmit power on channels 12 and 13, to comply
139  * with FCC regulations in the USA.
140  *
141  * Return: QDF_STATUS
142  */
143 QDF_STATUS ucfg_reg_set_fcc_constraint(struct wlan_objmgr_pdev *pdev,
144 				       bool fcc_constraint)
145 {
146 	return reg_set_fcc_constraint(pdev, fcc_constraint);
147 }
148 
149 
150 /**
151  * ucfg_reg_get_default_country() - Get the default regulatory country
152  * @psoc: The physical SoC to get default country from
153  * @country_code: the buffer to populate the country code into
154  *
155  * Return: QDF_STATUS
156  */
157 QDF_STATUS ucfg_reg_get_default_country(struct wlan_objmgr_psoc *psoc,
158 					       uint8_t *country_code)
159 {
160 	return reg_read_default_country(psoc, country_code);
161 }
162 
163 QDF_STATUS ucfg_reg_get_current_country(struct wlan_objmgr_psoc *psoc,
164 					       uint8_t *country_code)
165 {
166 	return reg_read_current_country(psoc, country_code);
167 }
168 /**
169  * ucfg_reg_set_default_country() - Set the default regulatory country
170  * @psoc: The physical SoC to set default country for
171  * @country: The country information to configure
172  *
173  * Return: QDF_STATUS
174  */
175 QDF_STATUS ucfg_reg_set_default_country(struct wlan_objmgr_psoc *psoc,
176 					uint8_t *country)
177 {
178 	return reg_set_default_country(psoc, country);
179 }
180 
181 /**
182  * ucfg_reg_set_country() - Set the current regulatory country
183  * @pdev: The physical dev to set current country for
184  * @country: The country information to configure
185  *
186  * Return: QDF_STATUS
187  */
188 QDF_STATUS ucfg_reg_set_country(struct wlan_objmgr_pdev *pdev,
189 				uint8_t *country)
190 {
191 	return reg_set_country(pdev, country);
192 }
193 
194 /**
195  * ucfg_reg_reset_country() - Reset the regulatory country to default
196  * @psoc: The physical SoC to reset country for
197  *
198  * Return: QDF_STATUS
199  */
200 QDF_STATUS ucfg_reg_reset_country(struct wlan_objmgr_psoc *psoc)
201 {
202 	return reg_reset_country(psoc);
203 }
204 
205 /**
206  * ucfg_reg_enable_dfs_channels() - Enable the use of DFS channels
207  * @pdev: The physical dev to enable DFS channels for
208  *
209  * Return: QDF_STATUS
210  */
211 QDF_STATUS ucfg_reg_enable_dfs_channels(struct wlan_objmgr_pdev *pdev,
212 					bool dfs_enable)
213 {
214 	return reg_enable_dfs_channels(pdev, dfs_enable);
215 }
216 
217 QDF_STATUS ucfg_reg_get_curr_band(struct wlan_objmgr_pdev *pdev,
218 				  enum band_info *band)
219 {
220 	return reg_get_curr_band(pdev, band);
221 
222 }
223 
224 void ucfg_reg_register_chan_change_callback(struct wlan_objmgr_psoc *psoc,
225 					    reg_chan_change_callback cbk,
226 					    void *arg)
227 {
228 	reg_register_chan_change_callback(psoc, cbk, arg);
229 }
230 
231 void ucfg_reg_unregister_chan_change_callback(struct wlan_objmgr_psoc *psoc,
232 					      reg_chan_change_callback cbk)
233 {
234 	reg_unregister_chan_change_callback(psoc, cbk);
235 }
236 
237 enum country_src ucfg_reg_get_cc_and_src(struct wlan_objmgr_psoc *psoc,
238 					 uint8_t *alpha2)
239 {
240 	return reg_get_cc_and_src(psoc, alpha2);
241 }
242 
243 void ucfg_reg_unit_simulate_ch_avoid(struct wlan_objmgr_psoc *psoc,
244 	struct ch_avoid_ind_type *ch_avoid)
245 {
246 	reg_process_ch_avoid_event(psoc, ch_avoid);
247 }
248 
249 QDF_STATUS ucfg_reg_11d_vdev_delete_update(struct wlan_objmgr_vdev *vdev)
250 {
251 	return reg_11d_vdev_delete_update(vdev);
252 }
253 
254 QDF_STATUS ucfg_reg_11d_vdev_created_update(struct wlan_objmgr_vdev *vdev)
255 {
256 	return reg_11d_vdev_created_update(vdev);
257 }
258 
259 struct wlan_psoc_host_hal_reg_capabilities_ext *ucfg_reg_get_hal_reg_cap(
260 				struct wlan_objmgr_psoc *psoc)
261 {
262 	return reg_get_hal_reg_cap(psoc);
263 }
264 qdf_export_symbol(ucfg_reg_get_hal_reg_cap);
265 
266 QDF_STATUS ucfg_reg_set_hal_reg_cap(struct wlan_objmgr_psoc *psoc,
267 		struct wlan_psoc_host_hal_reg_capabilities_ext *hal_reg_cap,
268 		uint16_t phy_cnt)
269 
270 {
271 	return reg_set_hal_reg_cap(psoc, hal_reg_cap, phy_cnt);
272 }
273 qdf_export_symbol(ucfg_reg_set_hal_reg_cap);
274