xref: /wlan-driver/qcacld-3.0/core/hdd/inc/wlan_hdd_tsf.h (revision 5113495b16420b49004c444715d2daae2066e7dc)
1*5113495bSYour Name /*
2*5113495bSYour Name  * Copyright (c) 2016-2021 The Linux Foundation. All rights reserved.
3*5113495bSYour Name  * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved.
4*5113495bSYour Name  *
5*5113495bSYour Name  * Permission to use, copy, modify, and/or distribute this software for
6*5113495bSYour Name  * any purpose with or without fee is hereby granted, provided that the
7*5113495bSYour Name  * above copyright notice and this permission notice appear in all
8*5113495bSYour Name  * copies.
9*5113495bSYour Name  *
10*5113495bSYour Name  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
11*5113495bSYour Name  * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
12*5113495bSYour Name  * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
13*5113495bSYour Name  * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
14*5113495bSYour Name  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
15*5113495bSYour Name  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
16*5113495bSYour Name  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
17*5113495bSYour Name  * PERFORMANCE OF THIS SOFTWARE.
18*5113495bSYour Name  */
19*5113495bSYour Name 
20*5113495bSYour Name #if !defined WLAN_HDD_TSF_H
21*5113495bSYour Name #define WLAN_HDD_TSF_H
22*5113495bSYour Name #include "wlan_hdd_cfg.h"
23*5113495bSYour Name #include "wlan_hdd_main.h"
24*5113495bSYour Name #ifdef WLAN_FEATURE_TSF_ACCURACY
25*5113495bSYour Name #include "qdf_hrtimer.h"
26*5113495bSYour Name #endif
27*5113495bSYour Name /**
28*5113495bSYour Name  * enum hdd_tsf_get_state - status of get tsf action
29*5113495bSYour Name  * @TSF_RETURN:                   get tsf
30*5113495bSYour Name  * @TSF_STA_NOT_CONNECTED_NO_TSF: sta not connected to ap
31*5113495bSYour Name  * @TSF_NOT_RETURNED_BY_FW:       fw not returned tsf
32*5113495bSYour Name  * @TSF_CURRENT_IN_CAP_STATE:     driver in capture state
33*5113495bSYour Name  * @TSF_CAPTURE_FAIL:             capture fail
34*5113495bSYour Name  * @TSF_GET_FAIL:                 get fail
35*5113495bSYour Name  * @TSF_RESET_GPIO_FAIL:          GPIO reset fail
36*5113495bSYour Name  * @TSF_SAP_NOT_STARTED_NO_TSF:   SAP not started
37*5113495bSYour Name  * @TSF_NOT_READY: TSF module is not initialized or init failed
38*5113495bSYour Name  * @TSF_DISABLED_BY_TSFPLUS: cap_tsf/get_tsf are disabled due to TSF_PLUS
39*5113495bSYour Name  */
40*5113495bSYour Name enum hdd_tsf_get_state {
41*5113495bSYour Name 	TSF_RETURN = 0,
42*5113495bSYour Name 	TSF_STA_NOT_CONNECTED_NO_TSF,
43*5113495bSYour Name 	TSF_NOT_RETURNED_BY_FW,
44*5113495bSYour Name 	TSF_CURRENT_IN_CAP_STATE,
45*5113495bSYour Name 	TSF_CAPTURE_FAIL,
46*5113495bSYour Name 	TSF_GET_FAIL,
47*5113495bSYour Name 	TSF_RESET_GPIO_FAIL,
48*5113495bSYour Name 	TSF_SAP_NOT_STARTED_NO_TSF,
49*5113495bSYour Name 	TSF_NOT_READY,
50*5113495bSYour Name 	TSF_DISABLED_BY_TSFPLUS
51*5113495bSYour Name };
52*5113495bSYour Name 
53*5113495bSYour Name /**
54*5113495bSYour Name  * enum hdd_tsf_capture_state - status of capture
55*5113495bSYour Name  * @TSF_IDLE:      idle
56*5113495bSYour Name  * @TSF_CAP_STATE: current is in capture state
57*5113495bSYour Name  */
58*5113495bSYour Name enum hdd_tsf_capture_state {
59*5113495bSYour Name 	TSF_IDLE = 0,
60*5113495bSYour Name 	TSF_CAP_STATE
61*5113495bSYour Name };
62*5113495bSYour Name 
63*5113495bSYour Name /**
64*5113495bSYour Name  * struct hdd_tsf_op_response - Store TSF sync parameters if TSF sync is active
65*5113495bSYour Name  * @status: TSF response status defined by enum hdd_tsf_get_state
66*5113495bSYour Name  * @time: TSF sync Target time. Time unit is microseconds.
67*5113495bSYour Name  * @soc_time: TSF sync SOC time. Time unit is microseconds.
68*5113495bSYour Name  */
69*5113495bSYour Name struct hdd_tsf_op_response {
70*5113495bSYour Name 	enum hdd_tsf_get_state status;
71*5113495bSYour Name 	uint64_t time;
72*5113495bSYour Name 	uint64_t soc_time;
73*5113495bSYour Name };
74*5113495bSYour Name 
75*5113495bSYour Name /**
76*5113495bSYour Name  * enum hdd_tsf_auto_rpt_source - trigger source of tsf auto report
77*5113495bSYour Name  * @HDD_TSF_AUTO_RPT_SOURCE_UPLINK_DELAY: uplink delay feature
78*5113495bSYour Name  * @HDD_TSF_AUTO_RPT_SOURCE_TX_LATENCY: transmit latency statistics
79*5113495bSYour Name  */
80*5113495bSYour Name enum hdd_tsf_auto_rpt_source {
81*5113495bSYour Name 	HDD_TSF_AUTO_RPT_SOURCE_UPLINK_DELAY,
82*5113495bSYour Name 	HDD_TSF_AUTO_RPT_SOURCE_TX_LATENCY,
83*5113495bSYour Name };
84*5113495bSYour Name 
85*5113495bSYour Name #ifdef WLAN_FEATURE_TSF_AUTO_REPORT
86*5113495bSYour Name /**
87*5113495bSYour Name  * hdd_set_tsf_auto_report() - enable or disable tsf auto report
88*5113495bSYour Name  * for an adapter
89*5113495bSYour Name  * @adapter: pointer to Adapter context
90*5113495bSYour Name  * @ena: requesting state (true or false)
91*5113495bSYour Name  * @source: source of the request
92*5113495bSYour Name  *
93*5113495bSYour Name  * Return: 0 for success or non-zero negative failure code
94*5113495bSYour Name  */
95*5113495bSYour Name int
96*5113495bSYour Name hdd_set_tsf_auto_report(struct hdd_adapter *adapter, bool ena,
97*5113495bSYour Name 			enum hdd_tsf_auto_rpt_source source);
98*5113495bSYour Name 
99*5113495bSYour Name /**
100*5113495bSYour Name  * hdd_tsf_auto_report_init() - initialize tsf auto report related
101*5113495bSYour Name  * structures for an adapter
102*5113495bSYour Name  * @adapter: pointer to Adapter context
103*5113495bSYour Name  *
104*5113495bSYour Name  * Return: None
105*5113495bSYour Name  */
106*5113495bSYour Name void hdd_tsf_auto_report_init(struct hdd_adapter *adapter);
107*5113495bSYour Name #else
108*5113495bSYour Name static inline int
hdd_set_tsf_auto_report(struct hdd_adapter * adapter,bool ena,enum hdd_tsf_auto_rpt_source source)109*5113495bSYour Name hdd_set_tsf_auto_report(struct hdd_adapter *adapter, bool ena,
110*5113495bSYour Name 			enum hdd_tsf_auto_rpt_source source)
111*5113495bSYour Name {
112*5113495bSYour Name 	return -ENOTSUPP;
113*5113495bSYour Name }
114*5113495bSYour Name 
hdd_tsf_auto_report_init(struct hdd_adapter * adapter)115*5113495bSYour Name static inline void hdd_tsf_auto_report_init(struct hdd_adapter *adapter)
116*5113495bSYour Name {
117*5113495bSYour Name }
118*5113495bSYour Name #endif
119*5113495bSYour Name 
120*5113495bSYour Name /**
121*5113495bSYour Name  * struct hdd_vdev_tsf - Adapter level tsf params
122*5113495bSYour Name  * @cur_target_time: tsf value received from firmware.
123*5113495bSYour Name  * @cur_tsf_sync_soc_time: Current SOC time.
124*5113495bSYour Name  * @last_tsf_sync_soc_time: Last SOC time when TSF was synced.
125*5113495bSYour Name  * @cur_target_global_tsf_time: Global Fw TSF time.
126*5113495bSYour Name  * @last_target_global_tsf_time: Last reported global Fw TSF time.
127*5113495bSYour Name  * @host_capture_req_timer: Host timer to capture TSF time.
128*5113495bSYour Name  * @tsf_id: TSF id as obtained from FW report.
129*5113495bSYour Name  * @tsf_mac_id: mac_id as obtained from FW report.
130*5113495bSYour Name  * @tsf_details_valid: flag indicating whether tsf details are valid.
131*5113495bSYour Name  * @host_target_sync_lock: spin lock for read/write timestamps.
132*5113495bSYour Name  * @host_target_sync_timer: Timer to Sync host target.
133*5113495bSYour Name  * @host_trigger_gpio_timer: A hrtimer used for TSF Accuracy Feature to
134*5113495bSYour Name  *                           indicate TSF cycle complete.
135*5113495bSYour Name  * @enable_dynamic_tsf_sync: Enable/Disable TSF sync through NL interface.
136*5113495bSYour Name  * @host_target_sync_force: Force update host to TSF mapping.
137*5113495bSYour Name  * @dynamic_tsf_sync_interval: TSF sync interval configure through NL interface.
138*5113495bSYour Name  * @cur_host_time: Current Host time.
139*5113495bSYour Name  * @last_host_time: Host time when TSF read was done.
140*5113495bSYour Name  * @last_target_time: Last Fw reported time when TSF read was done.
141*5113495bSYour Name  * @continuous_error_count: Store the count of continuous invalid tstamp-pair.
142*5113495bSYour Name  * @continuous_cap_retry_count: to store the count of continuous capture retry.
143*5113495bSYour Name  * @tsf_sync_ready_flag: to indicate whether tsf_sync has been initialized.
144*5113495bSYour Name  * @gpio_tsf_sync_work: work to sync send TSF CAP WMI command.
145*5113495bSYour Name  * @auto_rpt_src: bitmap to record trigger sources of TSF auto report
146*5113495bSYour Name  */
147*5113495bSYour Name struct hdd_vdev_tsf {
148*5113495bSYour Name 	uint64_t cur_target_time;
149*5113495bSYour Name 	uint64_t cur_tsf_sync_soc_time;
150*5113495bSYour Name 	uint64_t last_tsf_sync_soc_time;
151*5113495bSYour Name 	uint64_t cur_target_global_tsf_time;
152*5113495bSYour Name 	uint64_t last_target_global_tsf_time;
153*5113495bSYour Name 	qdf_mc_timer_t host_capture_req_timer;
154*5113495bSYour Name #ifdef QCA_GET_TSF_VIA_REG
155*5113495bSYour Name 	int tsf_id;
156*5113495bSYour Name 	int tsf_mac_id;
157*5113495bSYour Name 	qdf_atomic_t tsf_details_valid;
158*5113495bSYour Name #endif
159*5113495bSYour Name #ifdef WLAN_FEATURE_TSF_PLUS
160*5113495bSYour Name 	qdf_spinlock_t host_target_sync_lock;
161*5113495bSYour Name 	qdf_mc_timer_t host_target_sync_timer;
162*5113495bSYour Name #ifdef WLAN_FEATURE_TSF_ACCURACY
163*5113495bSYour Name 	qdf_hrtimer_data_t host_trigger_gpio_timer;
164*5113495bSYour Name #endif
165*5113495bSYour Name 	bool enable_dynamic_tsf_sync;
166*5113495bSYour Name 	bool host_target_sync_force;
167*5113495bSYour Name 	uint32_t dynamic_tsf_sync_interval;
168*5113495bSYour Name 	uint64_t cur_host_time;
169*5113495bSYour Name 	uint64_t last_host_time;
170*5113495bSYour Name 	uint64_t last_target_time;
171*5113495bSYour Name 	int continuous_error_count;
172*5113495bSYour Name 	int continuous_cap_retry_count;
173*5113495bSYour Name 	qdf_atomic_t tsf_sync_ready_flag;
174*5113495bSYour Name #ifdef WLAN_FEATURE_TSF_PLUS_EXT_GPIO_SYNC
175*5113495bSYour Name 	qdf_work_t gpio_tsf_sync_work;
176*5113495bSYour Name #endif
177*5113495bSYour Name #endif /* WLAN_FEATURE_TSF_PLUS */
178*5113495bSYour Name #ifdef WLAN_FEATURE_TSF_AUTO_REPORT
179*5113495bSYour Name 	unsigned long auto_rpt_src;
180*5113495bSYour Name 
181*5113495bSYour Name #endif /* WLAN_FEATURE_TSF_UPLINK_DELAY */
182*5113495bSYour Name };
183*5113495bSYour Name 
184*5113495bSYour Name /**
185*5113495bSYour Name  * struct hdd_ctx_tsf - Context level tsf params
186*5113495bSYour Name  * @tsf_ready_flag: indicate whether tsf has been initialized.
187*5113495bSYour Name  * @cap_tsf_flag: indicate whether it's now capturing tsf(updating tstamp-pair).
188*5113495bSYour Name  * @cap_tsf_context:  the context that is capturing tsf.
189*5113495bSYour Name  * @tsf_accuracy_context: the context that is capturing tsf accuracy.
190*5113495bSYour Name  * @ptp_cinfo: TSF PTP clock info.
191*5113495bSYour Name  * @ptp_clock: TSF PTP clock.
192*5113495bSYour Name  */
193*5113495bSYour Name struct hdd_ctx_tsf {
194*5113495bSYour Name 	qdf_atomic_t tsf_ready_flag;
195*5113495bSYour Name 	qdf_atomic_t cap_tsf_flag;
196*5113495bSYour Name 	struct hdd_adapter *cap_tsf_context;
197*5113495bSYour Name #ifdef WLAN_FEATURE_TSF_ACCURACY
198*5113495bSYour Name 	struct hdd_adapter *tsf_accuracy_context;
199*5113495bSYour Name #endif
200*5113495bSYour Name #ifdef WLAN_FEATURE_TSF_PTP
201*5113495bSYour Name 	struct ptp_clock_info ptp_cinfo;
202*5113495bSYour Name 	struct ptp_clock *ptp_clock;
203*5113495bSYour Name #endif
204*5113495bSYour Name };
205*5113495bSYour Name 
206*5113495bSYour Name #ifdef WLAN_FEATURE_TSF_UPLINK_DELAY
207*5113495bSYour Name /**
208*5113495bSYour Name  * hdd_get_uplink_delay_len() - get uplink delay length
209*5113495bSYour Name  * @adapter: pointer to the adapter
210*5113495bSYour Name  *
211*5113495bSYour Name  * Return: uplink delay length
212*5113495bSYour Name  */
213*5113495bSYour Name uint32_t hdd_get_uplink_delay_len(struct hdd_adapter *adapter);
214*5113495bSYour Name 
215*5113495bSYour Name /**
216*5113495bSYour Name  * hdd_add_uplink_delay() - add uplink delay
217*5113495bSYour Name  * @adapter: pointer to the adapter
218*5113495bSYour Name  * @skb: nbuf
219*5113495bSYour Name  *
220*5113495bSYour Name  * Return: status
221*5113495bSYour Name  */
222*5113495bSYour Name QDF_STATUS hdd_add_uplink_delay(struct hdd_adapter *adapter,
223*5113495bSYour Name 				struct sk_buff *skb);
224*5113495bSYour Name #else /* !WLAN_FEATURE_TSF_UPLINK_DELAY */
hdd_get_uplink_delay_len(struct hdd_adapter * adapter)225*5113495bSYour Name static inline uint32_t hdd_get_uplink_delay_len(struct hdd_adapter *adapter)
226*5113495bSYour Name {
227*5113495bSYour Name 	return 0;
228*5113495bSYour Name }
229*5113495bSYour Name 
hdd_add_uplink_delay(struct hdd_adapter * adapter,struct sk_buff * skb)230*5113495bSYour Name static inline QDF_STATUS hdd_add_uplink_delay(struct hdd_adapter *adapter,
231*5113495bSYour Name 					      struct sk_buff *skb)
232*5113495bSYour Name {
233*5113495bSYour Name 	return QDF_STATUS_SUCCESS;
234*5113495bSYour Name }
235*5113495bSYour Name #endif /* WLAN_FEATURE_TSF_UPLINK_DELAY */
236*5113495bSYour Name #ifdef WLAN_FEATURE_TSF
237*5113495bSYour Name /**
238*5113495bSYour Name  * wlan_hdd_tsf_init() - set gpio and callbacks for
239*5113495bSYour Name  *     capturing tsf and init tsf_plus
240*5113495bSYour Name  * @hdd_ctx: pointer to the struct hdd_context
241*5113495bSYour Name  *
242*5113495bSYour Name  * This function set the callback to sme module, the callback will be
243*5113495bSYour Name  * called when a tsf event is reported by firmware; set gpio number
244*5113495bSYour Name  * to FW, FW will toggle this gpio when received a CAP_TSF command;
245*5113495bSYour Name  * do tsf_plus init
246*5113495bSYour Name  *
247*5113495bSYour Name  * Return: nothing
248*5113495bSYour Name  */
249*5113495bSYour Name void wlan_hdd_tsf_init(struct hdd_context *hdd_ctx);
250*5113495bSYour Name 
251*5113495bSYour Name /**
252*5113495bSYour Name  * wlan_hdd_tsf_deinit() - reset callbacks for capturing tsf, deinit tsf_plus
253*5113495bSYour Name  * @hdd_ctx: pointer to the struct hdd_context
254*5113495bSYour Name  *
255*5113495bSYour Name  * This function reset the callback to sme module, and deinit tsf_plus
256*5113495bSYour Name  *
257*5113495bSYour Name  * Return: nothing
258*5113495bSYour Name  */
259*5113495bSYour Name void wlan_hdd_tsf_deinit(struct hdd_context *hdd_ctx);
260*5113495bSYour Name 
261*5113495bSYour Name /**
262*5113495bSYour Name  * hdd_capture_tsf() - capture tsf
263*5113495bSYour Name  * @adapter: pointer to adapter
264*5113495bSYour Name  * @buf: pointer to uplayer buf
265*5113495bSYour Name  * @len : the length of buf
266*5113495bSYour Name  *
267*5113495bSYour Name  * This function returns tsf value to uplayer.
268*5113495bSYour Name  *
269*5113495bSYour Name  * Return: 0 for success or non-zero negative failure code
270*5113495bSYour Name  */
271*5113495bSYour Name int hdd_capture_tsf(struct hdd_adapter *adapter, uint32_t *buf, int len);
272*5113495bSYour Name 
273*5113495bSYour Name /**
274*5113495bSYour Name  * hdd_indicate_tsf() - return tsf to uplayer
275*5113495bSYour Name  *
276*5113495bSYour Name  * @adapter: pointer to adapter
277*5113495bSYour Name  * @tsf_op_resp: pointer to struct hdd_tsf_op_response
278*5113495bSYour Name  *
279*5113495bSYour Name  * This function returns tsf value to uplayer.
280*5113495bSYour Name  *
281*5113495bSYour Name  * Return: Describe the execute result of this routine
282*5113495bSYour Name  */
283*5113495bSYour Name int hdd_indicate_tsf(struct hdd_adapter *adapter,
284*5113495bSYour Name 		     struct hdd_tsf_op_response *tsf_op_resp);
285*5113495bSYour Name 
286*5113495bSYour Name /**
287*5113495bSYour Name  * wlan_hdd_cfg80211_handle_tsf_cmd(): Setup TSF operations
288*5113495bSYour Name  * @wiphy: Pointer to wireless phy
289*5113495bSYour Name  * @wdev: Pointer to wireless device
290*5113495bSYour Name  * @data: Pointer to data
291*5113495bSYour Name  * @data_len: Data length
292*5113495bSYour Name  *
293*5113495bSYour Name  * Handle TSF SET / GET operation from userspace
294*5113495bSYour Name  *
295*5113495bSYour Name  * Return: 0 on success, negative errno on failure
296*5113495bSYour Name  */
297*5113495bSYour Name int wlan_hdd_cfg80211_handle_tsf_cmd(struct wiphy *wiphy,
298*5113495bSYour Name 					struct wireless_dev *wdev,
299*5113495bSYour Name 					const void *data,
300*5113495bSYour Name 					int data_len);
301*5113495bSYour Name 
302*5113495bSYour Name int hdd_get_tsf_cb(void *pcb_cxt, struct stsf *ptsf);
303*5113495bSYour Name 
304*5113495bSYour Name extern const struct nla_policy tsf_policy[QCA_WLAN_VENDOR_ATTR_TSF_MAX + 1];
305*5113495bSYour Name 
306*5113495bSYour Name #define FEATURE_HANDLE_TSF_VENDOR_COMMANDS \
307*5113495bSYour Name { \
308*5113495bSYour Name 	.info.vendor_id = QCA_NL80211_VENDOR_ID, \
309*5113495bSYour Name 	.info.subcmd = QCA_NL80211_VENDOR_SUBCMD_TSF, \
310*5113495bSYour Name 	.flags = WIPHY_VENDOR_CMD_NEED_WDEV | \
311*5113495bSYour Name 		WIPHY_VENDOR_CMD_NEED_NETDEV | \
312*5113495bSYour Name 		WIPHY_VENDOR_CMD_NEED_RUNNING, \
313*5113495bSYour Name 	.doit = wlan_hdd_cfg80211_handle_tsf_cmd, \
314*5113495bSYour Name 	vendor_command_policy(tsf_policy, QCA_WLAN_VENDOR_ATTR_TSF_MAX)\
315*5113495bSYour Name },
316*5113495bSYour Name #else
wlan_hdd_tsf_init(struct hdd_context * hdd_ctx)317*5113495bSYour Name static inline void wlan_hdd_tsf_init(struct hdd_context *hdd_ctx)
318*5113495bSYour Name {
319*5113495bSYour Name }
320*5113495bSYour Name 
wlan_hdd_tsf_deinit(struct hdd_context * hdd_ctx)321*5113495bSYour Name static inline void wlan_hdd_tsf_deinit(struct hdd_context *hdd_ctx)
322*5113495bSYour Name {
323*5113495bSYour Name }
324*5113495bSYour Name 
hdd_indicate_tsf(struct hdd_adapter * adapter,struct hdd_tsf_op_response * tsf_op_resp)325*5113495bSYour Name static inline int hdd_indicate_tsf(struct hdd_adapter *adapter,
326*5113495bSYour Name 				   struct hdd_tsf_op_response *tsf_op_resp)
327*5113495bSYour Name {
328*5113495bSYour Name 	return -ENOTSUPP;
329*5113495bSYour Name }
330*5113495bSYour Name 
331*5113495bSYour Name static inline int
hdd_capture_tsf(struct hdd_adapter * adapter,uint32_t * buf,int len)332*5113495bSYour Name hdd_capture_tsf(struct hdd_adapter *adapter, uint32_t *buf, int len)
333*5113495bSYour Name {
334*5113495bSYour Name 	return -ENOTSUPP;
335*5113495bSYour Name }
336*5113495bSYour Name 
wlan_hdd_cfg80211_handle_tsf_cmd(struct wiphy * wiphy,struct wireless_dev * wdev,const void * data,int data_len)337*5113495bSYour Name static inline int wlan_hdd_cfg80211_handle_tsf_cmd(struct wiphy *wiphy,
338*5113495bSYour Name 					struct wireless_dev *wdev,
339*5113495bSYour Name 					const void *data,
340*5113495bSYour Name 					int data_len)
341*5113495bSYour Name {
342*5113495bSYour Name 	return -ENOTSUPP;
343*5113495bSYour Name }
hdd_get_tsf_cb(void * pcb_cxt,struct stsf * ptsf)344*5113495bSYour Name static inline int hdd_get_tsf_cb(void *pcb_cxt, struct stsf *ptsf)
345*5113495bSYour Name {
346*5113495bSYour Name 	return -ENOTSUPP;
347*5113495bSYour Name }
348*5113495bSYour Name 
349*5113495bSYour Name #define FEATURE_HANDLE_TSF_VENDOR_COMMANDS
350*5113495bSYour Name #endif
351*5113495bSYour Name 
352*5113495bSYour Name #if defined(WLAN_FEATURE_TSF_PLUS) && defined(WLAN_FEATURE_TSF)
353*5113495bSYour Name /**
354*5113495bSYour Name  * hdd_tsf_is_tx_set() - check ini configuration
355*5113495bSYour Name  * @hdd: pointer to hdd context
356*5113495bSYour Name  *
357*5113495bSYour Name  * This function checks tsf configuration for ptp on tx
358*5113495bSYour Name  *
359*5113495bSYour Name  * Return: true on enable, false on disable
360*5113495bSYour Name  */
361*5113495bSYour Name 
362*5113495bSYour Name bool hdd_tsf_is_tx_set(struct hdd_context *hdd);
363*5113495bSYour Name /**
364*5113495bSYour Name  * hdd_tsf_is_rx_set() - check ini configuration
365*5113495bSYour Name  * @hdd: pointer to hdd context
366*5113495bSYour Name  *
367*5113495bSYour Name  * This function checks tsf configuration for ptp on rx
368*5113495bSYour Name  *
369*5113495bSYour Name  * Return: true on enable, false on disable
370*5113495bSYour Name  */
371*5113495bSYour Name bool hdd_tsf_is_rx_set(struct hdd_context *hdd);
372*5113495bSYour Name /**
373*5113495bSYour Name  * hdd_tsf_is_raw_set() - check ini configuration
374*5113495bSYour Name  * @hdd: pointer to hdd context
375*5113495bSYour Name  *
376*5113495bSYour Name  * This function checks tsf configuration for ptp on raw
377*5113495bSYour Name  *
378*5113495bSYour Name  * Return: true on enable, false on disable
379*5113495bSYour Name  */
380*5113495bSYour Name bool hdd_tsf_is_raw_set(struct hdd_context *hdd);
381*5113495bSYour Name /**
382*5113495bSYour Name  * hdd_tsf_is_dbg_fs_set() - check ini configuration
383*5113495bSYour Name  * @hdd: pointer to hdd context
384*5113495bSYour Name  *
385*5113495bSYour Name  * This function checks tsf configuration for ptp on dbg fs
386*5113495bSYour Name  *
387*5113495bSYour Name  * Return: true on enable, false on disable
388*5113495bSYour Name  */
389*5113495bSYour Name bool hdd_tsf_is_dbg_fs_set(struct hdd_context *hdd);
390*5113495bSYour Name 
391*5113495bSYour Name /**
392*5113495bSYour Name  * hdd_start_tsf_sync() - start tsf sync
393*5113495bSYour Name  * @adapter: pointer to adapter
394*5113495bSYour Name  *
395*5113495bSYour Name  * This function initialize and start TSF synchronization
396*5113495bSYour Name  *
397*5113495bSYour Name  * Return: Describe the execute result of this routine
398*5113495bSYour Name  */
399*5113495bSYour Name int hdd_start_tsf_sync(struct hdd_adapter *adapter);
400*5113495bSYour Name 
401*5113495bSYour Name /**
402*5113495bSYour Name  * hdd_restart_tsf_sync_post_wlan_resume() - restart host TSF sync
403*5113495bSYour Name  * @adapter: pointer to adapter
404*5113495bSYour Name  *
405*5113495bSYour Name  * This function restarts host TSF sync immediately after wlan resume
406*5113495bSYour Name  *
407*5113495bSYour Name  * Return: none
408*5113495bSYour Name  */
409*5113495bSYour Name void hdd_restart_tsf_sync_post_wlan_resume(struct hdd_adapter *adapter);
410*5113495bSYour Name 
411*5113495bSYour Name /**
412*5113495bSYour Name  * hdd_stop_tsf_sync() - stop tsf sync
413*5113495bSYour Name  * @adapter: pointer to adapter
414*5113495bSYour Name  *
415*5113495bSYour Name  * This function stop and de-initialize TSF synchronization
416*5113495bSYour Name  *
417*5113495bSYour Name  * Return: Describe the execute result of this routine
418*5113495bSYour Name  */
419*5113495bSYour Name int hdd_stop_tsf_sync(struct hdd_adapter *adapter);
420*5113495bSYour Name 
421*5113495bSYour Name /**
422*5113495bSYour Name  * hdd_capture_req_timer_expired_handler() - capture req timer handler
423*5113495bSYour Name  * @arg: pointer to a adapter
424*5113495bSYour Name  *
425*5113495bSYour Name  * This function set a timeout handler for TSF capture timer.
426*5113495bSYour Name  *
427*5113495bSYour Name  * Return: none
428*5113495bSYour Name  */
429*5113495bSYour Name 
430*5113495bSYour Name void hdd_capture_req_timer_expired_handler(void *arg);
431*5113495bSYour Name 
432*5113495bSYour Name /**
433*5113495bSYour Name  * hdd_tsf_is_tsf64_tx_set() - check ini configuration
434*5113495bSYour Name  * @hdd: pointer to hdd context
435*5113495bSYour Name  *
436*5113495bSYour Name  * This function checks tsf configuration for ptp on tsf64 tx
437*5113495bSYour Name  *
438*5113495bSYour Name  * Return: true on enable, false on disable
439*5113495bSYour Name  */
440*5113495bSYour Name bool hdd_tsf_is_tsf64_tx_set(struct hdd_context *hdd);
441*5113495bSYour Name 
442*5113495bSYour Name /**
443*5113495bSYour Name  * hdd_tsf_is_time_sync_enabled_cfg() - check ini configuration
444*5113495bSYour Name  * @hdd_ctx: pointer to hdd context
445*5113495bSYour Name  *
446*5113495bSYour Name  * This function checks tsf configuration for ptp for tsf
447*5113495bSYour Name  * sync period
448*5113495bSYour Name  * Return: true on enable, false on disable
449*5113495bSYour Name  */
450*5113495bSYour Name bool hdd_tsf_is_time_sync_enabled_cfg(struct hdd_context *hdd_ctx);
451*5113495bSYour Name 
452*5113495bSYour Name /**
453*5113495bSYour Name  * hdd_update_dynamic_tsf_sync - Configure TSF mode for vdev
454*5113495bSYour Name  * @adapter: pointer to hdd adapter
455*5113495bSYour Name  *
456*5113495bSYour Name  * This function configures TSF mode for vdev with ini parameter
457*5113495bSYour Name  */
458*5113495bSYour Name void hdd_update_dynamic_tsf_sync(struct hdd_adapter *adapter);
459*5113495bSYour Name 
460*5113495bSYour Name #ifdef WLAN_FEATURE_TSF_PLUS_SOCK_TS
461*5113495bSYour Name /**
462*5113495bSYour Name  * hdd_rx_timestamp() - time stamp RX netbuf
463*5113495bSYour Name  *
464*5113495bSYour Name  * @netbuf: pointer to a RX netbuf
465*5113495bSYour Name  * @target_time: RX time for the netbuf
466*5113495bSYour Name  *
467*5113495bSYour Name  * This function get corresponding host time from target time,
468*5113495bSYour Name  * and time stamp the RX netbuf with this time
469*5113495bSYour Name  *
470*5113495bSYour Name  * Return: Describe the execute result of this routine
471*5113495bSYour Name  */
472*5113495bSYour Name int hdd_rx_timestamp(qdf_nbuf_t netbuf, uint64_t target_time);
473*5113495bSYour Name #endif
474*5113495bSYour Name 
475*5113495bSYour Name /**
476*5113495bSYour Name  * hdd_get_tsf_time() - get tsf time for system time
477*5113495bSYour Name  *
478*5113495bSYour Name  * @adapter_ctx: adapter context
479*5113495bSYour Name  * @input_time: input system time
480*5113495bSYour Name  * @tsf_time: tsf time for system time
481*5113495bSYour Name  *
482*5113495bSYour Name  * Return: qdf status
483*5113495bSYour Name  */
484*5113495bSYour Name QDF_STATUS hdd_get_tsf_time(void *adapter_ctx, uint64_t input_time,
485*5113495bSYour Name 			    uint64_t *tsf_time);
486*5113495bSYour Name #else
hdd_start_tsf_sync(struct hdd_adapter * adapter)487*5113495bSYour Name static inline int hdd_start_tsf_sync(struct hdd_adapter *adapter)
488*5113495bSYour Name {
489*5113495bSYour Name 	return -ENOTSUPP;
490*5113495bSYour Name }
491*5113495bSYour Name 
hdd_stop_tsf_sync(struct hdd_adapter * adapter)492*5113495bSYour Name static inline int hdd_stop_tsf_sync(struct hdd_adapter *adapter)
493*5113495bSYour Name {
494*5113495bSYour Name 	return -ENOTSUPP;
495*5113495bSYour Name }
496*5113495bSYour Name 
497*5113495bSYour Name static inline
hdd_capture_req_timer_expired_handler(void * arg)498*5113495bSYour Name void hdd_capture_req_timer_expired_handler(void *arg)
499*5113495bSYour Name {
500*5113495bSYour Name }
501*5113495bSYour Name 
502*5113495bSYour Name static inline
hdd_tsf_is_tsf64_tx_set(struct hdd_context * hdd)503*5113495bSYour Name bool hdd_tsf_is_tsf64_tx_set(struct hdd_context *hdd)
504*5113495bSYour Name {
505*5113495bSYour Name 	return FALSE;
506*5113495bSYour Name }
507*5113495bSYour Name 
508*5113495bSYour Name static inline
hdd_tsf_is_time_sync_enabled_cfg(struct hdd_context * hdd_ctx)509*5113495bSYour Name bool hdd_tsf_is_time_sync_enabled_cfg(struct hdd_context *hdd_ctx)
510*5113495bSYour Name {
511*5113495bSYour Name 	return false;
512*5113495bSYour Name }
513*5113495bSYour Name 
514*5113495bSYour Name static inline
hdd_update_dynamic_tsf_sync(struct hdd_adapter * adapter)515*5113495bSYour Name void hdd_update_dynamic_tsf_sync(struct hdd_adapter *adapter)
516*5113495bSYour Name {
517*5113495bSYour Name }
518*5113495bSYour Name 
519*5113495bSYour Name static inline
hdd_restart_tsf_sync_post_wlan_resume(struct hdd_adapter * adapter)520*5113495bSYour Name void hdd_restart_tsf_sync_post_wlan_resume(struct hdd_adapter *adapter)
521*5113495bSYour Name {
522*5113495bSYour Name }
523*5113495bSYour Name 
524*5113495bSYour Name static inline
hdd_get_tsf_time(void * adapter_ctx,uint64_t input_time,uint64_t * tsf_time)525*5113495bSYour Name QDF_STATUS hdd_get_tsf_time(void *adapter_ctx, uint64_t input_time,
526*5113495bSYour Name 			    uint64_t *tsf_time)
527*5113495bSYour Name {
528*5113495bSYour Name 	*tsf_time = 0;
529*5113495bSYour Name 	return QDF_STATUS_E_NOSUPPORT;
530*5113495bSYour Name }
531*5113495bSYour Name #endif
532*5113495bSYour Name 
533*5113495bSYour Name #ifdef WLAN_FEATURE_TSF_PTP
534*5113495bSYour Name /**
535*5113495bSYour Name  * wlan_get_ts_info() - return ts info to uplayer
536*5113495bSYour Name  * @dev: pointer to net_device
537*5113495bSYour Name  * @info: pointer to ethtool_ts_info
538*5113495bSYour Name  *
539*5113495bSYour Name  * Return: Describe the execute result of this routine
540*5113495bSYour Name  */
541*5113495bSYour Name int wlan_get_ts_info(struct net_device *dev, struct ethtool_ts_info *info);
542*5113495bSYour Name 
543*5113495bSYour Name #endif
544*5113495bSYour Name #endif
545