blob: 9f67ed0a9c2c624a1c4520ac25ac8d03957d7dd2 [file] [log] [blame]
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07001/*
Srinivas Girigowdaad005ab2017-03-25 00:47:37 -07002 * Copyright (c) 2016-2017 The Linux Foundation. All rights reserved.
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07003 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21
22/*
23 * This file was originally distributed by Qualcomm Atheros, Inc.
24 * under proprietary terms before Copyright ownership was assigned
25 * to the Linux Foundation.
26 */
27
28#if !defined WLAN_HDD_TSF_H
29#define WLAN_HDD_TSF_H
30
31/**
32 * enum hdd_tsf_get_state - status of get tsf action
33 * @TSF_RETURN: get tsf
34 * @TSF_STA_NOT_CONNECTED_NO_TSF: sta not connected to ap
35 * @TSF_NOT_RETURNED_BY_FW: fw not returned tsf
36 * @TSF_CURRENT_IN_CAP_STATE: driver in capture state
37 * @TSF_CAPTURE_FAIL: capture fail
38 * @TSF_GET_FAIL: get fail
39 * @TSF_RESET_GPIO_FAIL: GPIO reset fail
40 * @TSF_SAP_NOT_STARTED_NO_TSF SAP not started
Yu Wangf5d5b5f2017-05-25 22:38:32 +080041 * @TSF_NOT_READY: TSF module is not initialized or init failed
Yu Wang000dc2f2017-05-26 17:38:48 +080042 * @TSF_DISABLED_BY_TSFPLUS: cap_tsf/get_tsf are disabled due to TSF_PLUS
Manikandan Mohandcc21ba2016-03-15 14:31:56 -070043 */
44enum hdd_tsf_get_state {
45 TSF_RETURN = 0,
46 TSF_STA_NOT_CONNECTED_NO_TSF,
47 TSF_NOT_RETURNED_BY_FW,
48 TSF_CURRENT_IN_CAP_STATE,
49 TSF_CAPTURE_FAIL,
50 TSF_GET_FAIL,
51 TSF_RESET_GPIO_FAIL,
Yu Wangf5d5b5f2017-05-25 22:38:32 +080052 TSF_SAP_NOT_STARTED_NO_TSF,
Yu Wang000dc2f2017-05-26 17:38:48 +080053 TSF_NOT_READY,
54 TSF_DISABLED_BY_TSFPLUS
Manikandan Mohandcc21ba2016-03-15 14:31:56 -070055};
56
57/**
58 * enum hdd_tsf_capture_state - status of capture
59 * @TSF_IDLE: idle
60 * @TSF_CAP_STATE: current is in capture state
61 */
62enum hdd_tsf_capture_state {
63 TSF_IDLE = 0,
64 TSF_CAP_STATE
65};
66
67#ifdef WLAN_FEATURE_TSF
Yu Wangf5d5b5f2017-05-25 22:38:32 +080068/**
69 * wlan_hdd_tsf_init() - set gpio and callbacks for
70 * capturing tsf and init tsf_plus
71 * @hdd_ctx: pointer to the hdd_context_t
72 *
73 * This function set the callback to sme module, the callback will be
74 * called when a tsf event is reported by firmware; set gpio number
75 * to FW, FW will toggle this gpio when received a CAP_TSF command;
76 * do tsf_plus init
77 *
78 * Return: nothing
79 */
Jeff Johnsondde34492016-10-05 16:28:04 -070080void wlan_hdd_tsf_init(struct hdd_context_s *hdd_ctx);
Yu Wangf5d5b5f2017-05-25 22:38:32 +080081
82/**
83 * wlan_hdd_tsf_deinit() - reset callbacks for capturing tsf, deinit tsf_plus
84 * @hdd_ctx: pointer to the hdd_context_t
85 *
86 * This function reset the callback to sme module, and deinit tsf_plus
87 *
88 * Return: nothing
89 */
90void wlan_hdd_tsf_deinit(hdd_context_t *hdd_ctx);
91
92/**
93 * hdd_capture_tsf() - capture tsf
94 * @adapter: pointer to adapter
95 * @buf: pointer to uplayer buf
96 * @len : the length of buf
97 *
98 * This function returns tsf value to uplayer.
99 *
100 * Return: 0 for success or non-zero negative failure code
101 */
Manikandan Mohandcc21ba2016-03-15 14:31:56 -0700102int hdd_capture_tsf(struct hdd_adapter_s *adapter, uint32_t *buf, int len);
Yu Wangf5d5b5f2017-05-25 22:38:32 +0800103
104/**
105 * hdd_indicate_tsf() - return tsf to uplayer
106 *
107 * @adapter: pointer to adapter
108 * @buf: pointer to uplayer buf
109 * @len : the length of buf
110 *
111 * This function returns tsf value to uplayer.
112 *
113 * Return: Describe the execute result of this routine
114 */
Manikandan Mohandcc21ba2016-03-15 14:31:56 -0700115int hdd_indicate_tsf(struct hdd_adapter_s *adapter, uint32_t *buf, int len);
Yu Wangf5d5b5f2017-05-25 22:38:32 +0800116
117/**
118 * wlan_hdd_cfg80211_handle_tsf_cmd(): Setup TSF operations
119 * @wiphy: Pointer to wireless phy
120 * @wdev: Pointer to wireless device
121 * @data: Pointer to data
122 * @data_len: Data length
123 *
124 * Handle TSF SET / GET operation from userspace
125 *
126 * Return: 0 on success, negative errno on failure
127 */
Manikandan Mohan5356c2b2016-04-03 15:51:35 -0700128int wlan_hdd_cfg80211_handle_tsf_cmd(struct wiphy *wiphy,
129 struct wireless_dev *wdev,
130 const void *data,
131 int data_len);
Yu Wangf5d5b5f2017-05-25 22:38:32 +0800132
Arun Khandavalli4b55da72016-07-19 19:55:01 +0530133int hdd_get_tsf_cb(void *pcb_cxt, struct stsf *ptsf);
Manikandan Mohandcc21ba2016-03-15 14:31:56 -0700134#else
135static inline void wlan_hdd_tsf_init(struct hdd_context_s *hdd_ctx)
136{
Manikandan Mohandcc21ba2016-03-15 14:31:56 -0700137}
138
Yu Wangf5d5b5f2017-05-25 22:38:32 +0800139static inline void wlan_hdd_tsf_deinit(hdd_context_t *hdd_ctx)
140{
141}
142
Manikandan Mohandcc21ba2016-03-15 14:31:56 -0700143static inline int hdd_indicate_tsf(struct hdd_adapter_s *adapter, uint32_t *buf,
144 int len)
145{
146 return -ENOTSUPP;
147}
148
149static inline int
150hdd_capture_tsf(struct hdd_adapter_s *adapter, uint32_t *buf, int len)
151{
152 return -ENOTSUPP;
153}
Manikandan Mohan5356c2b2016-04-03 15:51:35 -0700154
155static inline int wlan_hdd_cfg80211_handle_tsf_cmd(struct wiphy *wiphy,
156 struct wireless_dev *wdev,
157 const void *data,
158 int data_len)
159{
160 return -ENOTSUPP;
161}
Arun Khandavalli4b55da72016-07-19 19:55:01 +0530162static inline int hdd_get_tsf_cb(void *pcb_cxt, struct stsf *ptsf)
163{
164 return -ENOTSUPP;
165}
166
Manikandan Mohandcc21ba2016-03-15 14:31:56 -0700167#endif
168
Yu Wang000dc2f2017-05-26 17:38:48 +0800169#if defined(WLAN_FEATURE_TSF_PLUS) && defined(WLAN_FEATURE_TSF)
170
171/**
172 * hdd_start_tsf_sync() - start tsf sync
173 * @adapter: pointer to adapter
174 *
175 * This function initialize and start TSF synchronization
176 *
177 * Return: Describe the execute result of this routine
178 */
179int hdd_start_tsf_sync(hdd_adapter_t *adapter);
180
181/**
182 * hdd_stop_tsf_sync() - stop tsf sync
183 * @adapter: pointer to adapter
184 *
185 * This function stop and de-initialize TSF synchronization
186 *
187 * Return: Describe the execute result of this routine
188 */
189int hdd_stop_tsf_sync(hdd_adapter_t *adapter);
190
191/**
192 * hdd_tsf_notify_wlan_state_change() -
193 * notify tsf module of wlan connection state
194 * @old_state: old wlan state
195 * @new_state: new wlan state
196 *
197 * This function check the old and new connection state, determine whether
198 * to start or stop tsf sync
199 *
200 * Return: nothing
201 */
202void hdd_tsf_notify_wlan_state_change(hdd_adapter_t *adapter,
203 eConnectionState old_state,
204 eConnectionState new_state);
205
206#else
207static inline int hdd_start_tsf_sync(hdd_adapter_t *adapter)
208{
209 return -ENOTSUPP;
210}
211
212static inline int hdd_stop_tsf_sync(hdd_adapter_t *adapter)
213{
214 return -ENOTSUPP;
215}
216
217static inline
218void hdd_tsf_notify_wlan_state_change(hdd_adapter_t *adapter,
219 eConnectionState old_state,
220 eConnectionState new_state)
221
222{
223}
224#endif
225
Manikandan Mohandcc21ba2016-03-15 14:31:56 -0700226#endif