xref: /wlan-driver/qcacld-3.0/components/ftm_time_sync/core/inc/ftm_time_sync_main.h (revision 5113495b16420b49004c444715d2daae2066e7dc)
1 /*
2  * Copyright (c) 2020, The Linux Foundation. All rights reserved.
3  *
4  * Permission to use, copy, modify, and/or distribute this software for any
5  * purpose with or without fee is hereby granted, provided that the above
6  * copyright notice and this permission notice appear in all copies.
7  *
8  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15  */
16 
17 /**
18  * DOC: Declare private API which shall be used internally only
19  * in ftm_time_sync component. This file shall include prototypes of
20  * various notification handlers and logging functions.
21  *
22  * Note: This API should be never accessed out of ftm_time_sync component.
23  */
24 
25 #ifndef _FTM_TIME_SYNC_MAIN_H_
26 #define _FTM_TIME_SYNC_MAIN_H_
27 
28 #include <qdf_types.h>
29 #include <qdf_delayed_work.h>
30 #include "ftm_time_sync_priv.h"
31 #include "ftm_time_sync_objmgr.h"
32 
33 #define ftm_time_sync_log(level, args...) \
34 	QDF_TRACE(QDF_MODULE_ID_FTM_TIME_SYNC, level, ## args)
35 
36 #define ftm_time_sync_logfl(level, format, args...) \
37 	ftm_time_sync_log(level, FL(format), ## args)
38 
39 #define ftm_time_sync_fatal(format, args...) \
40 		ftm_time_sync_logfl(QDF_TRACE_LEVEL_FATAL, format, ## args)
41 #define ftm_time_sync_err(format, args...) \
42 		ftm_time_sync_logfl(QDF_TRACE_LEVEL_ERROR, format, ## args)
43 #define ftm_time_sync_warn(format, args...) \
44 		ftm_time_sync_logfl(QDF_TRACE_LEVEL_WARN, format, ## args)
45 #define ftm_time_sync_info(format, args...) \
46 		ftm_time_sync_logfl(QDF_TRACE_LEVEL_INFO, format, ## args)
47 #define ftm_time_sync_debug(format, args...) \
48 		ftm_time_sync_logfl(QDF_TRACE_LEVEL_DEBUG, format, ## args)
49 
50 #define FTM_TIME_SYNC_ENTER() ftm_time_sync_debug("enter")
51 #define FTM_TIME_SYNC_EXIT() ftm_time_sync_debug("exit")
52 
53 /**
54  * ftm_time_sync_vdev_create_notification() - Handler for vdev create notify.
55  * @vdev: vdev which is going to be created by objmgr
56  * @arg: argument for notification handler
57  *
58  * Allocate and attach vdev private object.
59  *
60  * Return: QDF_STATUS
61  */
62 QDF_STATUS ftm_time_sync_vdev_create_notification(struct wlan_objmgr_vdev *vdev,
63 						  void *arg);
64 
65 /**
66  * ftm_time_sync_vdev_destroy_notification() - Handler for vdev destroy notify.
67  * @vdev: vdev which is going to be destroyed by objmgr
68  * @arg: argument for notification handler.
69  *
70  * Deallocate and detach vdev private object.
71  *
72  * Return: QDF_STATUS
73  */
74 QDF_STATUS
75 ftm_time_sync_vdev_destroy_notification(struct wlan_objmgr_vdev *vdev,
76 					void *arg);
77 
78 /**
79  * ftm_time_sync_psoc_create_notification() - Handler for psoc create notify.
80  * @psoc: psoc which is going to be created by objmgr
81  * @arg: argument for notification handler.
82  *
83  * Allocate and attach psoc private object.
84  *
85  * Return: QDF_STATUS
86  */
87 QDF_STATUS
88 ftm_time_sync_psoc_create_notification(struct wlan_objmgr_psoc *psoc,
89 				       void *arg);
90 
91 /**
92  * ftm_time_sync_psoc_destroy_notification() -  Handler for psoc destroy notify.
93  * @psoc: psoc which is going to be destroyed by objmgr
94  * @arg: argument for notification handler.
95  *
96  * Deallocate and detach psoc private object.
97  *
98  * Return: QDF_STATUS
99  */
100 QDF_STATUS
101 ftm_time_sync_psoc_destroy_notification(struct wlan_objmgr_psoc *psoc,
102 					void *arg);
103 
104 /**
105  * ftm_time_sync_is_enable() - Function to advertise feature is enabled or not
106  * @psoc: psoc context
107  *
108  * This function advertises whether the feature is enabled or not.
109  *
110  * Return: true if enable, false if disable
111  */
112 bool ftm_time_sync_is_enable(struct wlan_objmgr_psoc *psoc);
113 
114 /**
115  * ftm_time_sync_set_enable() - Handler to enable the feature
116  * @psoc: psoc context
117  * @value: value to be set
118  *
119  * This function is used to enable the ftm time sync feature.
120  * The feature is enabled iff both ini and wmi service is advertised by
121  * firmware.
122  *
123  * Return: None
124  */
125 void ftm_time_sync_set_enable(struct wlan_objmgr_psoc *psoc, bool value);
126 
127 /**
128  * ftm_time_sync_get_mode() - API to get the ftm time sync mode
129  * @psoc: psoc context
130  *
131  * Return: enum ftm_time_sync_mode
132  */
133 enum ftm_time_sync_mode ftm_time_sync_get_mode(struct wlan_objmgr_psoc *psoc);
134 
135 /**
136  * ftm_time_sync_get_role() -  API to get the ftm time sync role
137  * @psoc: psoc context
138  *
139  * Return: enum ftm_time_sync_role
140  */
141 enum ftm_time_sync_role ftm_time_sync_get_role(struct wlan_objmgr_psoc *psoc);
142 
143 /**
144  * ftm_time_sync_send_trigger() - Handler for sending trigger cmd to FW
145  * @vdev: vdev for which FTM time_sync trigger cmd to be send
146  *
147  * This function sends the ftm trigger cmd to target.
148  *
149  * Return: QDF_STATUS
150  */
151 QDF_STATUS ftm_time_sync_send_trigger(struct wlan_objmgr_vdev *vdev);
152 
153 /**
154  * ftm_time_sync_stop() - Handler for stopping the FTM time sync
155  * @vdev: vdev for which FTM time_sync feature to be stopped
156  *
157  * This function stops the ftm time sync functionality.
158  *
159  * Return: QDF_STATUS
160  */
161 QDF_STATUS ftm_time_sync_stop(struct wlan_objmgr_vdev *vdev);
162 
163 /**
164  * ftm_time_sync_show() - Handler to print the offset derived
165  * @vdev: vdev for which offset is to be shown
166  * @buf: buffer in which the values to be printed
167  *
168  * Return: the number of bytes written in buf
169  */
170 ssize_t ftm_time_sync_show(struct wlan_objmgr_vdev *vdev, char *buf);
171 
172 /**
173  * ftm_time_sync_update_bssid() - Update the bssid info
174  * @vdev: vdev context
175  * @bssid: bssid of connected AP
176  *
177  * Return: None
178  */
179 void ftm_time_sync_update_bssid(struct wlan_objmgr_vdev *vdev,
180 				struct qdf_mac_addr bssid);
181 
182 #endif /* end of _FTM_TIME_SYNC_MAIN_H_ */
183