xref: /wlan-driver/qcacld-3.0/components/ftm_time_sync/dispatcher/inc/ftm_time_sync_ucfg_api.h (revision 5113495b16420b49004c444715d2daae2066e7dc)
1 /*
2  * Copyright (c) 2020, The Linux Foundation. All rights reserved.
3  * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
4  *
5  * Permission to use, copy, modify, and/or distribute this software for any
6  * purpose with or without fee is hereby granted, provided that the above
7  * copyright notice and this permission notice appear in all copies.
8  *
9  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16  */
17 
18 /**
19  * DOC: Declare public API related to the ftm time_sync called by north bound
20  * HDD/OSIF/LIM
21  */
22 
23 #ifndef _FTM_TIME_SYNC_UCFG_API_H_
24 #define _FTM_TIME_SYNC_UCFG_API_H_
25 
26 #include <qdf_status.h>
27 #include <qdf_types.h>
28 #include "ftm_time_sync_objmgr.h"
29 #include "wlan_ftm_time_sync_public_struct.h"
30 
31 #ifdef FEATURE_WLAN_TIME_SYNC_FTM
32 
33 /**
34  * ucfg_ftm_time_sync_init() - FTM time sync component initialization.
35  *
36  * This function initializes the ftm time sync component and registers
37  * the handlers which are invoked on vdev creation.
38  *
39  * Return: For successful registration - QDF_STATUS_SUCCESS,
40  *	   else QDF_STATUS error codes.
41  */
42 QDF_STATUS ucfg_ftm_time_sync_init(void);
43 
44 /**
45  * ucfg_ftm_time_sync_deinit() - FTM time sync component deinit.
46  *
47  * This function deinits ftm time sync component.
48  *
49  * Return: None
50  */
51 void ucfg_ftm_time_sync_deinit(void);
52 
53 /**
54  * ucfg_is_ftm_time_sync_enable() - FTM time sync feature enable/disable
55  * @psoc: psoc context
56  *
57  * This function advertises whether the ftm time sync feature is enabled or not
58  *
59  * Return: true if enable else false
60  */
61 bool ucfg_is_ftm_time_sync_enable(struct wlan_objmgr_psoc *psoc);
62 
63 /**
64  * ucfg_ftm_time_sync_set_enable() - FTM time sync feature set enable/disable
65  * @psoc: psoc context
66  * @value: value to be set
67  *
68  * This function enables/disables the feature.
69  *
70  * Return: None
71  */
72 void ucfg_ftm_time_sync_set_enable(struct wlan_objmgr_psoc *psoc, bool value);
73 
74 /**
75  * ucfg_ftm_time_sync_update_sta_connect_state() - Handler for STA state change
76  * @vdev: STA vdev
77  * @state: connected/disconnected state
78  * @bssid: bssid of connected AP
79  *
80  * This function triggers the FTM time sync feature in case of connection and
81  * stops the ftm sync feature in case of disconnection.
82  *
83  * Return: None
84  */
85 void
86 ucfg_ftm_time_sync_update_sta_connect_state(struct wlan_objmgr_vdev *vdev,
87 					    enum ftm_time_sync_sta_state state,
88 					    struct qdf_mac_addr bssid);
89 
90 /**
91  * ucfg_ftm_time_sync_update_bss_state() - Handler to notify bss start/stop
92  * @vdev: SAP vdev
93  * @ap_state: BSS start/stop state
94  *
95  * This function triggers the FTM time sync feature in case of bss start and
96  * stops the ftm sync feature in case of bss stop.
97  *
98  * Return: None.
99  */
100 void ucfg_ftm_time_sync_update_bss_state(struct wlan_objmgr_vdev *vdev,
101 					 enum ftm_time_sync_bss_state ap_state);
102 
103 /**
104  * ucfg_ftm_time_sync_show() - Show the ftm time sync offset values derived
105  * @vdev: vdev context
106  * @buf: buffer in which the values to be written
107  *
108  * This function prints the offset values derived after ftm time sync
109  * between the qtime of STA(target) and connected SAP(initiator).
110  *
111  * Return: number of bytes written in buffer
112  */
113 ssize_t ucfg_ftm_time_sync_show(struct wlan_objmgr_vdev *vdev, char *buf);
114 #else
115 
116 static inline
ucfg_ftm_time_sync_init(void)117 QDF_STATUS ucfg_ftm_time_sync_init(void)
118 {
119 	return QDF_STATUS_SUCCESS;
120 }
121 
122 static inline
ucfg_ftm_time_sync_deinit(void)123 void ucfg_ftm_time_sync_deinit(void)
124 {
125 }
126 
127 static inline
ucfg_is_ftm_time_sync_enable(struct wlan_objmgr_psoc * psoc)128 bool ucfg_is_ftm_time_sync_enable(struct wlan_objmgr_psoc *psoc)
129 {
130 	return false;
131 }
132 
133 static inline
ucfg_ftm_time_sync_set_enable(struct wlan_objmgr_psoc * psoc,bool value)134 void ucfg_ftm_time_sync_set_enable(struct wlan_objmgr_psoc *psoc, bool value)
135 {
136 }
137 
138 static inline void
ucfg_ftm_time_sync_update_sta_connect_state(struct wlan_objmgr_vdev * vdev,enum ftm_time_sync_sta_state state)139 ucfg_ftm_time_sync_update_sta_connect_state(struct wlan_objmgr_vdev *vdev,
140 					    enum ftm_time_sync_sta_state state)
141 {
142 }
143 
144 static inline void
ucfg_ftm_time_sync_update_bss_state(struct wlan_objmgr_vdev * vdev,enum ftm_time_sync_bss_state ap_state)145 ucfg_ftm_time_sync_update_bss_state(struct wlan_objmgr_vdev *vdev,
146 				    enum ftm_time_sync_bss_state ap_state)
147 {
148 }
149 
150 static inline
ucfg_ftm_time_sync_show(struct wlan_objmgr_vdev * vdev,char * buf)151 ssize_t ucfg_ftm_time_sync_show(struct wlan_objmgr_vdev *vdev, char *buf)
152 {
153 	return 0;
154 }
155 #endif /* FEATURE_WLAN_TIME_SYNC_FTM */
156 #endif /* _FTM_TIME_SYNC_UCFG_API_H_ */
157