xref: /wlan-dirver/qca-wifi-host-cmn/umac/wifi_pos/inc/wifi_pos_api.h (revision 11f5a63a6cbdda84849a730de22f0a71e635d58c)
1 /*
2  * Copyright (c) 2012-2019 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: wifi_pos_api.h
21  * This file declares public APIs of wifi positioning component
22  */
23 #ifndef _WIFI_POS_API_H_
24 #define _WIFI_POS_API_H_
25 
26 /* Include files */
27 #include "qdf_types.h"
28 #include "qdf_status.h"
29 #include "qdf_trace.h"
30 
31 /* forward reference */
32 struct wlan_objmgr_psoc;
33 struct wifi_pos_driver_caps;
34 
35 /**
36  * struct wifi_pos_field - wifi positioning field element
37  * @id: RTT field id
38  * @offset: data offset in field info buffer
39  * @length: length of related data in field info buffer
40  */
41 struct wifi_pos_field {
42 	uint32_t id;
43 	uint32_t offset;
44 	uint32_t length;
45 };
46 
47 /**
48  * struct wifi_pos_field_info - wifi positioning field info buffer
49  * @count: number of @wifi_pos_field elements
50  * @fields: buffer to hold @wifi_pos_field elements
51  */
52 struct wifi_pos_field_info {
53 	uint32_t count;
54 	struct wifi_pos_field fields[1];
55 };
56 
57 #ifdef WIFI_POS_CONVERGED
58 /**
59  * enum oem_err_msg - err msg returned to user space
60  * @OEM_ERR_NULL_CONTEXT: NULL context
61  * @OEM_ERR_APP_NOT_REGISTERED: OEM App is not registered
62  * @OEM_ERR_INVALID_SIGNATURE: Invalid signature
63  * @OEM_ERR_NULL_MESSAGE_HEADER: Invalid message header
64  * @OEM_ERR_INVALID_MESSAGE_TYPE: Invalid message type
65  * @OEM_ERR_INVALID_MESSAGE_LENGTH: Invalid length in message body
66  */
67 enum oem_err_msg {
68 	OEM_ERR_NULL_CONTEXT = 1,
69 	OEM_ERR_APP_NOT_REGISTERED,
70 	OEM_ERR_INVALID_SIGNATURE,
71 	OEM_ERR_NULL_MESSAGE_HEADER,
72 	OEM_ERR_INVALID_MESSAGE_TYPE,
73 	OEM_ERR_INVALID_MESSAGE_LENGTH
74 };
75 
76 /* this struct is needed since MLME is not converged yet */
77 struct wifi_pos_ch_info {
78 	uint8_t chan_id;
79 	uint32_t mhz;
80 	uint32_t band_center_freq1;
81 	uint32_t band_center_freq2;
82 	uint32_t info;
83 	uint32_t reg_info_1;
84 	uint32_t reg_info_2;
85 	uint8_t nss;
86 	uint32_t rate_flags;
87 	uint8_t sec_ch_offset;
88 	uint32_t ch_width;
89 };
90 
91 /**
92  * typedef wifi_pos_ch_info_rsp - Channel information
93  * @chan_id: channel id
94  * @reserved0: reserved for padding and future use
95  * @mhz: primary 20 MHz channel frequency in mhz
96  * @band_center_freq1: Center frequency 1 in MHz
97  * @band_center_freq2: Center frequency 2 in MHz, valid only for 11ac
98  *      VHT 80+80 mode
99  * @info: channel info
100  * @reg_info_1: regulatory information field 1 which contains min power,
101  *      max power, reg power and reg class id
102  * @reg_info_2: regulatory information field 2 which contains antennamax
103  */
104 struct qdf_packed wifi_pos_ch_info_rsp {
105 	uint32_t chan_id;
106 	uint32_t reserved0;
107 	uint32_t mhz;
108 	uint32_t band_center_freq1;
109 	uint32_t band_center_freq2;
110 	uint32_t info;
111 	uint32_t reg_info_1;
112 	uint32_t reg_info_2;
113 };
114 
115 /**
116  * struct wmi_pos_peer_status_info - Status information for a given peer
117  * @peer_mac_addr: peer mac address
118  * @peer_status: peer status: 1: CONNECTED, 2: DISCONNECTED
119  * @vdev_id: vdev_id for the peer mac
120  * @peer_capability: peer capability: 0: RTT/RTT2, 1: RTT3. Default is 0
121  * @reserved0: reserved0
122  * @peer_chan_info: channel info on which peer is connected
123  */
124 struct qdf_packed wmi_pos_peer_status_info {
125 	uint8_t peer_mac_addr[ETH_ALEN];
126 	uint8_t peer_status;
127 	uint8_t vdev_id;
128 	uint32_t peer_capability;
129 	uint32_t reserved0;
130 	struct wifi_pos_ch_info_rsp peer_chan_info;
131 };
132 
133 /**
134  * struct wifi_pos_req_msg - wifi pos request struct
135  * @msg_type: message type
136  * @pid: process id
137  * @buf: request buffer
138  * @buf_len: request buffer length
139  * @field_info_buf: buffer containing field info
140  * @field_info_buf_len: length of field info buffer
141  *
142  */
143 struct wifi_pos_req_msg {
144 	uint32_t msg_type;
145 	uint32_t pid;
146 	uint8_t *buf;
147 	uint32_t buf_len;
148 	struct wifi_pos_field_info *field_info_buf;
149 	uint32_t field_info_buf_len;
150 };
151 
152 /**
153  * ucfg_wifi_pos_process_req: ucfg API to be called from HDD/OS_IF to process a
154  * wifi_pos request from userspace
155  * @psoc: pointer to psoc object
156  * @req: wifi_pos request msg
157  * @send_rsp_cb: callback pointer required to send msg to userspace
158  *
159  * Return: status of operation
160  */
161 QDF_STATUS ucfg_wifi_pos_process_req(struct wlan_objmgr_psoc *psoc,
162 		struct wifi_pos_req_msg *req,
163 		void (*send_rsp_cb)(uint32_t, uint32_t, uint32_t, uint8_t *));
164 
165 /**
166  * wifi_pos_init: initializes WIFI POS component, called by dispatcher init
167  *
168  * Return: status of operation
169  */
170 QDF_STATUS wifi_pos_init(void);
171 
172 /**
173  * wifi_pos_deinit: de-initializes WIFI POS component, called by dispatcher init
174  *
175  * Return: status of operation
176  */
177 QDF_STATUS wifi_pos_deinit(void);
178 
179 /**
180  * wifi_pos_psoc_enable: psoc enable API for wifi positioning component
181  * @psoc: pointer to PSOC
182  *
183  * Return: status of operation
184  */
185 QDF_STATUS wifi_pos_psoc_enable(struct wlan_objmgr_psoc *psoc);
186 
187 /**
188  * wifi_pos_psoc_disable: psoc disable API for wifi positioning component
189  * @psoc: pointer to PSOC
190  *
191  * Return: status of operation
192  */
193 QDF_STATUS wifi_pos_psoc_disable(struct wlan_objmgr_psoc *psoc);
194 
195 /**
196  * wifi_pos_set_oem_target_type: public API to set param in wifi_pos private
197  * object
198  * @psoc: pointer to PSOC
199  * @val: value to set
200  *
201  * Return: None
202  */
203 void wifi_pos_set_oem_target_type(struct wlan_objmgr_psoc *psoc, uint32_t val);
204 
205 /**
206  * wifi_pos_set_oem_fw_version: public API to set param in wifi_pos private
207  * object
208  * @psoc: pointer to PSOC
209  * @val: value to set
210  *
211  * Return: None
212  */
213 void wifi_pos_set_oem_fw_version(struct wlan_objmgr_psoc *psoc, uint32_t val);
214 
215 /**
216  * wifi_pos_set_drv_ver_major: public API to set param in wifi_pos private
217  * object
218  * @psoc: pointer to PSOC
219  * @val: value to set
220  *
221  * Return: None
222  */
223 void wifi_pos_set_drv_ver_major(struct wlan_objmgr_psoc *psoc, uint8_t val);
224 
225 /**
226  * wifi_pos_set_drv_ver_minor: public API to set param in wifi_pos private
227  * object
228  * @psoc: pointer to PSOC
229  * @val: value to set
230  *
231  * Return: None
232  */
233 void wifi_pos_set_drv_ver_minor(struct wlan_objmgr_psoc *psoc, uint8_t val);
234 
235 /**
236  * wifi_pos_set_drv_ver_patch: public API to set param in wifi_pos private
237  * object
238  * @psoc: pointer to PSOC
239  * @val: value to set
240  *
241  * Return: None
242  */
243 void wifi_pos_set_drv_ver_patch(struct wlan_objmgr_psoc *psoc, uint8_t val);
244 
245 /**
246  * wifi_pos_set_drv_ver_build: public API to set param in wifi_pos private
247  * object
248  * @psoc: pointer to PSOC
249  * @val: value to set
250  *
251  * Return: None
252  */
253 void wifi_pos_set_drv_ver_build(struct wlan_objmgr_psoc *psoc, uint8_t val);
254 
255 /**
256  * wifi_pos_set_dwell_time_min: public API to set param in wifi_pos private
257  * object
258  * @psoc: pointer to PSOC
259  * @val: value to set
260  *
261  * Return: None
262  */
263 void wifi_pos_set_dwell_time_min(struct wlan_objmgr_psoc *psoc, uint16_t val);
264 
265 /**
266  * wifi_pos_set_dwell_time_max: public API to set param in wifi_pos private
267  * object
268  * @psoc: pointer to PSOC
269  * @val: value to set
270  *
271  * Return: None
272  */
273 void wifi_pos_set_dwell_time_max(struct wlan_objmgr_psoc *psoc, uint16_t val);
274 
275 /**
276  * wifi_pos_set_current_dwell_time_min: public API to set param in wifi_pos
277  * private object
278  * @psoc: pointer to PSOC
279  * @val: value to set
280  *
281  * Return: None
282  */
283 void wifi_pos_set_current_dwell_time_min(struct wlan_objmgr_psoc *psoc,
284 					 uint16_t val);
285 
286 /**
287  * wifi_pos_set_current_dwell_time_max: public API to set param in wifi_pos
288  * private object
289  * @psoc: pointer to PSOC
290  * @val: value to set
291  *
292  * Return: None
293  */
294 void wifi_pos_set_current_dwell_time_max(struct wlan_objmgr_psoc *psoc,
295 					 uint16_t val);
296 
297 /**
298  * wifi_pos_populate_caps() - populate oem capabilities
299  * @psoc: psoc object
300  * @caps: pointer to populate the capabilities
301  *
302  * Return: error code
303  */
304 QDF_STATUS wifi_pos_populate_caps(struct wlan_objmgr_psoc *psoc,
305 			   struct wifi_pos_driver_caps *caps);
306 
307 struct wlan_lmac_if_rx_ops;
308 /**
309  * wifi_pos_register_rx_ops: function to register with lmac rx ops
310  * @rx_ops: lmac rx ops struct object
311  *
312  * Return: None
313  */
314 void wifi_pos_register_rx_ops(struct wlan_lmac_if_rx_ops *rx_ops);
315 
316 /**
317  * ucfg_wifi_pos_get_ftm_cap: API to get fine timing measurement caps
318  * @psoc: psoc object
319  *
320  * Return: FTM value
321  */
322 uint32_t ucfg_wifi_pos_get_ftm_cap(struct wlan_objmgr_psoc *psoc);
323 
324 /**
325  * ucfg_wifi_pos_set_ftm_cap: API to set fine timing measurement caps
326  * @psoc: psoc object
327  * @val: value to set
328  *
329  * Return: None
330  */
331 void ucfg_wifi_pos_set_ftm_cap(struct wlan_objmgr_psoc *psoc, uint32_t val);
332 
333 /**
334  * wifi_pos_get_app_pid: returns oem app pid.
335  * @psoc: pointer to psoc object
336  *
337  * Return: oem app pid
338  */
339 uint32_t wifi_pos_get_app_pid(struct wlan_objmgr_psoc *psoc);
340 
341 /**
342  * wifi_pos_is_app_registered: indicates if oem app is registered.
343  * @psoc: pointer to psoc object
344  *
345  * Return: true if app is registered, false otherwise
346  */
347 bool wifi_pos_is_app_registered(struct wlan_objmgr_psoc *psoc);
348 
349 /**
350  * wifi_pos_get_psoc: API to get global PSOC object
351  *
352  * Since request from userspace is not associated with any vdev/pdev/psoc, this
353  * API is used to get global psoc object.
354  * Return: global psoc object.
355  */
356 struct wlan_objmgr_psoc *wifi_pos_get_psoc(void);
357 
358 #else
359 static inline QDF_STATUS wifi_pos_init(void)
360 {
361 	return QDF_STATUS_SUCCESS;
362 }
363 
364 static inline QDF_STATUS wifi_pos_deinit(void)
365 {
366 	return QDF_STATUS_SUCCESS;
367 }
368 
369 static inline QDF_STATUS wifi_pos_psoc_enable(struct wlan_objmgr_psoc *psoc)
370 {
371 	return QDF_STATUS_SUCCESS;
372 }
373 
374 static inline QDF_STATUS wifi_pos_psoc_disable(struct wlan_objmgr_psoc *psoc)
375 {
376 	return QDF_STATUS_SUCCESS;
377 }
378 #endif
379 
380 #if defined(WLAN_FEATURE_CIF_CFR) && defined(WIFI_POS_CONVERGED)
381 /**
382  * wifi_pos_init_cir_cfr_rings: API to set DMA ring cap in wifi pos psoc private
383  * object
384  * @psoc: pointer to psoc object
385  * @hal_soc: hal soc pointer
386  * @num_mac: number of macs
387  * @buf: buffer containing dma ring cap
388  *
389  * Return: status of operation.
390  */
391 QDF_STATUS wifi_pos_init_cir_cfr_rings(struct wlan_objmgr_psoc *psoc,
392 				   void *hal_soc, uint8_t num_mac, void *buf);
393 #else
394 static inline QDF_STATUS wifi_pos_init_cir_cfr_rings(
395 				struct wlan_objmgr_psoc *psoc,
396 				void *hal_soc, uint8_t num_mac, void *buf)
397 {
398 	return QDF_STATUS_SUCCESS;
399 }
400 #endif
401 
402 /**
403  * wifi_pos_register_get_phy_mode_cb: API to register callback to get
404  * current PHY mode
405  * @psoc: pointer to psoc object
406  * @handler: callback to be registered
407  *
408  * Return: QDF_STATUS_SUCCESS in case of success, error codes in
409  * case of failure
410  */
411 QDF_STATUS wifi_pos_register_get_phy_mode_cb(
412 			struct wlan_objmgr_psoc *psoc,
413 			void (*handler)(uint8_t, uint32_t, uint32_t *));
414 
415 /**
416  * wifi_pos_register_send_action: API to register callback to send
417  * action frames
418  * @psoc: pointer to psoc object
419  * @handler: callback to be registered
420  *
421  * Return: QDF_STATUS_SUCCESS in case of success, error codes in
422  * case of failure
423  */
424 QDF_STATUS wifi_pos_register_send_action(
425 				struct wlan_objmgr_psoc *psoc,
426 				void (*handler)(struct wlan_objmgr_psoc *psoc,
427 						uint32_t sub_type,
428 						uint8_t *buf,
429 						uint32_t buf_len));
430 
431 /**
432  * wifi_pos_send_report_resp: Send report to osif
433  * @psoc: pointer to psoc object
434  * @req_id: Request id
435  * @dest_mac: destination mac address
436  * @err_code: Error code to be sent
437  *
438  * Return: QDF_STATUS_SUCCESS in case of success, error codes in
439  * case of failure
440  */
441 QDF_STATUS wifi_pos_send_report_resp(struct wlan_objmgr_psoc *psoc,
442 				     int req_id, uint8_t *dest_mac,
443 				     int err_code);
444 #endif
445