xref: /wlan-dirver/qca-wifi-host-cmn/target_if/init_deinit/src/init_deinit_lmac.c (revision 1f55ed1a9f5050d8da228aa8dd3fff7c0242aa71)
1 /*
2  * Copyright (c) 2018 The Linux Foundation. All rights reserved.
3  *
4  * Permission to use, copy, modify, and/or distribute this software for
5  * any purpose with or without fee is hereby granted, provided that the
6  * above copyright notice and this permission notice appear in all
7  * copies.
8  *
9  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
10  * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
11  * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
12  * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
13  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
14  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
15  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
16  * PERFORMANCE OF THIS SOFTWARE.
17  */
18 
19 /**
20  * DOC: init_deinit_lmac.c
21  *
22  * APIs to get/set target_if params
23  */
24 #include <qdf_status.h>
25 #include <wlan_objmgr_psoc_obj.h>
26 #include <wlan_objmgr_pdev_obj.h>
27 #include <target_if.h>
28 #include <target_type.h>
29 #include <init_deinit_lmac.h>
30 #include <qdf_module.h>
31 
32 struct wlan_psoc_target_capability_info *lmac_get_target_cap(
33 				struct wlan_objmgr_psoc *psoc)
34 {
35 	struct target_psoc_info *tgt_hdl;
36 
37 	if (!psoc) {
38 		target_if_err("psoc is null");
39 		return NULL;
40 	}
41 
42 	tgt_hdl = wlan_psoc_get_tgt_if_handle(psoc);
43 	if (!tgt_hdl) {
44 		target_if_err("target_psoc_info is null");
45 		return NULL;
46 	}
47 
48 	return target_psoc_get_target_caps(tgt_hdl);
49 }
50 
51 target_resource_config *lmac_get_tgt_res_cfg(struct wlan_objmgr_psoc *psoc)
52 {
53 	struct target_psoc_info *tgt_hdl;
54 
55 	if (!psoc) {
56 		target_if_err("psoc is null");
57 		return NULL;
58 	}
59 
60 	tgt_hdl = wlan_psoc_get_tgt_if_handle(psoc);
61 	if (!tgt_hdl) {
62 		target_if_err("target_psoc_info is null");
63 		return NULL;
64 	}
65 
66 	return target_psoc_get_wlan_res_cfg(tgt_hdl);
67 }
68 
69 int32_t lmac_get_pdev_idx(struct wlan_objmgr_pdev *pdev)
70 {
71 	struct target_pdev_info *tgt_hdl;
72 
73 	if (!pdev) {
74 		target_if_err("pdev is null");
75 		return 0xffffffff;
76 	}
77 
78 	tgt_hdl = wlan_pdev_get_tgt_if_handle(pdev);
79 	if (!tgt_hdl) {
80 		target_if_err("target_pdev_info is null");
81 		return 0xffffffff;
82 	}
83 
84 	return target_pdev_get_pdev_idx(tgt_hdl);
85 }
86 
87 uint32_t lmac_get_tgt_type(struct wlan_objmgr_psoc *psoc)
88 {
89 	struct target_psoc_info *tgt_hdl;
90 
91 	if (!psoc) {
92 		target_if_err("psoc is null");
93 		return 0;
94 	}
95 
96 	tgt_hdl = wlan_psoc_get_tgt_if_handle(psoc);
97 	if (!tgt_hdl) {
98 		target_if_err("target_psoc_info is null");
99 		return 0;
100 	}
101 
102 	return target_psoc_get_target_type(tgt_hdl);
103 }
104 qdf_export_symbol(lmac_get_tgt_type);
105 
106 QDF_STATUS lmac_get_pdev_target_type(struct wlan_objmgr_pdev *pdev,
107 					uint32_t *target_type)
108 {
109 	struct wlan_objmgr_psoc *psoc;
110 
111 	psoc = wlan_pdev_get_psoc(pdev);
112 	if (!psoc) {
113 		target_if_err("psoc is NULL");
114 		return QDF_STATUS_E_FAILURE;
115 	}
116 
117 	*target_type = lmac_get_tgt_type(psoc);
118 	return QDF_STATUS_SUCCESS;
119 }
120 qdf_export_symbol(lmac_get_pdev_target_type);
121 
122 uint32_t lmac_get_tgt_version(struct wlan_objmgr_psoc *psoc)
123 {
124 	struct target_psoc_info *tgt_hdl;
125 
126 	if (!psoc) {
127 		target_if_err("psoc is null");
128 		return -EINVAL;
129 	}
130 
131 	tgt_hdl = wlan_psoc_get_tgt_if_handle(psoc);
132 	if (!tgt_hdl) {
133 		target_if_err("target_psoc_info is null");
134 		return -EINVAL;
135 	}
136 
137 	return target_psoc_get_target_ver(tgt_hdl);
138 }
139 qdf_export_symbol(lmac_get_tgt_version);
140 
141 uint32_t lmac_get_tgt_revision(struct wlan_objmgr_psoc *psoc)
142 {
143 	struct target_psoc_info *tgt_hdl;
144 
145 	if (!psoc) {
146 		target_if_err("psoc is null");
147 		return -EINVAL;
148 	}
149 
150 	tgt_hdl = wlan_psoc_get_tgt_if_handle(psoc);
151 	if (!tgt_hdl) {
152 		target_if_err("target_psoc_info is null");
153 		return -EINVAL;
154 	}
155 
156 	return target_psoc_get_target_rev(tgt_hdl);
157 }
158 qdf_export_symbol(lmac_get_tgt_revision);
159 
160 bool lmac_is_target_ar900b(struct wlan_objmgr_psoc *psoc)
161 {
162 	struct target_psoc_info *tgt_hdl;
163 	uint32_t target_type;
164 
165 	if (!psoc) {
166 		target_if_err("psoc is null\n");
167 		return false;
168 	}
169 
170 	tgt_hdl = wlan_psoc_get_tgt_if_handle(psoc);
171 	if (!tgt_hdl) {
172 		target_if_err("target_psoc_info is null");
173 		return false;
174 	}
175 	target_type = tgt_hdl->info.target_type;
176 
177 	switch (target_type) {
178 	case TARGET_TYPE_AR900B:
179 	case TARGET_TYPE_QCA9984:
180 	case TARGET_TYPE_IPQ4019:
181 	case TARGET_TYPE_QCA9888:
182 		return true;
183 	default:
184 		return false;
185 	}
186 	return false;
187 }
188 qdf_export_symbol(lmac_is_target_ar900b);
189 
190 struct common_wmi_handle *lmac_get_wmi_hdl(struct wlan_objmgr_psoc *psoc)
191 {
192 	struct target_psoc_info *tgt_hdl;
193 
194 	if (!psoc) {
195 		target_if_err("psoc is null");
196 		return NULL;
197 	}
198 
199 	tgt_hdl = wlan_psoc_get_tgt_if_handle(psoc);
200 	if (!tgt_hdl) {
201 		target_if_err("target_psoc_info is null");
202 		return NULL;
203 	}
204 
205 	return target_psoc_get_wmi_hdl(tgt_hdl);
206 }
207 qdf_export_symbol(lmac_get_wmi_hdl);
208 
209 wmi_unified_t lmac_get_wmi_unified_hdl(struct wlan_objmgr_psoc *psoc)
210 {
211 	return (wmi_unified_t)lmac_get_wmi_hdl(psoc);
212 }
213 qdf_export_symbol(lmac_get_wmi_unified_hdl);
214 
215 struct common_htc_handle *lmac_get_htc_hdl(struct wlan_objmgr_psoc *psoc)
216 {
217 	struct target_psoc_info *tgt_hdl;
218 
219 	if (!psoc) {
220 		target_if_err("psoc is null");
221 		return NULL;
222 	}
223 
224 	tgt_hdl = wlan_psoc_get_tgt_if_handle(psoc);
225 	if (!tgt_hdl) {
226 		target_if_err("target_psoc_info is null");
227 		return NULL;
228 	}
229 
230 	return target_psoc_get_htc_hdl(tgt_hdl);
231 }
232 qdf_export_symbol(lmac_get_htc_hdl);
233 
234 void lmac_set_htc_hdl(struct wlan_objmgr_psoc *psoc,
235 		struct common_htc_handle *htc_hdl)
236 {
237 	struct target_psoc_info *tgt_hdl;
238 
239 	if (!psoc) {
240 		target_if_err("psoc is null");
241 		return;
242 	}
243 	tgt_hdl = (struct target_psoc_info *)wlan_psoc_get_tgt_if_handle(psoc);
244 	if (!tgt_hdl) {
245 		target_if_err("target_psoc_info is null");
246 		return;
247 	}
248 
249 	target_psoc_set_htc_hdl(tgt_hdl, htc_hdl);
250 }
251 
252 struct common_hif_handle *lmac_get_hif_hdl(struct wlan_objmgr_psoc *psoc)
253 {
254 	struct target_psoc_info *tgt_hdl;
255 
256 	if (!psoc) {
257 		target_if_err("psoc is null");
258 		return NULL;
259 	}
260 
261 	tgt_hdl = wlan_psoc_get_tgt_if_handle(psoc);
262 	if (!tgt_hdl) {
263 		target_if_err("target_psoc_info is null");
264 		return NULL;
265 	}
266 
267 	return target_psoc_get_hif_hdl(tgt_hdl);
268 }
269 qdf_export_symbol(lmac_get_hif_hdl);
270 
271 struct hif_opaque_softc *lmac_get_ol_hif_hdl(struct wlan_objmgr_psoc *psoc)
272 {
273 	return (struct hif_opaque_softc *)lmac_get_hif_hdl(psoc);
274 }
275 qdf_export_symbol(lmac_get_ol_hif_hdl);
276 
277 struct common_wmi_handle *lmac_get_pdev_wmi_handle(
278 		struct wlan_objmgr_pdev *pdev)
279 {
280 	struct target_pdev_info *tgt_hdl;
281 
282 	if (!pdev) {
283 		target_if_err("pdev is null");
284 		return NULL;
285 	}
286 
287 	tgt_hdl = wlan_pdev_get_tgt_if_handle(pdev);
288 	if (!tgt_hdl) {
289 		target_if_err("target_pdev_info is null");
290 		return NULL;
291 	}
292 
293 	return target_pdev_get_wmi_handle(tgt_hdl);
294 }
295 qdf_export_symbol(lmac_get_pdev_wmi_handle);
296 
297 wmi_unified_t
298 lmac_get_pdev_wmi_unified_handle(struct wlan_objmgr_pdev *pdev)
299 {
300 	return (wmi_unified_t)lmac_get_pdev_wmi_handle(pdev);
301 }
302 
303 uint32_t lmac_get_num_radios(struct wlan_objmgr_psoc *psoc)
304 {
305 	struct target_psoc_info *tgt_hdl;
306 
307 	if (!psoc) {
308 		target_if_err("psoc is null");
309 		return 0;
310 	}
311 	tgt_hdl = wlan_psoc_get_tgt_if_handle(psoc);
312 	if (!tgt_hdl) {
313 		target_if_err("target_psoc_info is null");
314 		return 0;
315 	}
316 
317 	return target_psoc_get_num_radios(tgt_hdl);
318 }
319 qdf_export_symbol(lmac_get_num_radios);
320 
321 void *lmac_get_psoc_feature_ptr(struct wlan_objmgr_psoc *psoc)
322 {
323 	struct target_psoc_info *tgt_hdl;
324 
325 	if (!psoc) {
326 		target_if_err("psoc is null");
327 		return NULL;
328 	}
329 	tgt_hdl = wlan_psoc_get_tgt_if_handle(psoc);
330 	if (!tgt_hdl) {
331 		target_if_err("target_psoc_info is null");
332 		return NULL;
333 	}
334 
335 	return target_psoc_get_feature_ptr(tgt_hdl);
336 }
337 qdf_export_symbol(lmac_get_psoc_feature_ptr);
338 
339 void *lmac_get_pdev_feature_ptr(struct wlan_objmgr_pdev *pdev)
340 {
341 	struct target_pdev_info *tgt_hdl;
342 
343 	if (!pdev) {
344 		target_if_err("pdev is null");
345 		return NULL;
346 	}
347 	tgt_hdl = wlan_pdev_get_tgt_if_handle(pdev);
348 	if (!tgt_hdl) {
349 		target_if_err("target_pdev_info is null");
350 		return NULL;
351 	}
352 
353 	return target_pdev_get_feature_ptr(tgt_hdl);
354 }
355 qdf_export_symbol(lmac_get_pdev_feature_ptr);
356 
357 enum wmi_host_hw_mode_config_type lmac_get_preferred_hw_mode(
358 				struct wlan_objmgr_psoc *psoc)
359 {
360 	struct target_psoc_info *tgt_hdl;
361 
362 	if (!psoc) {
363 		target_if_err("psoc is null");
364 		return WMI_HOST_HW_MODE_MAX;
365 	}
366 	tgt_hdl = wlan_psoc_get_tgt_if_handle(psoc);
367 	if (!tgt_hdl) {
368 		target_if_err("target_psoc_info is null");
369 		return WMI_HOST_HW_MODE_MAX;
370 	}
371 
372 	return target_psoc_get_preferred_hw_mode(tgt_hdl);
373 }
374 
375 qdf_export_symbol(lmac_get_preferred_hw_mode);
376