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