diff options
| author | Abhishek Singh <absingh@qti.qualcomm.com> | 2016-05-11 16:05:50 +0530 |
|---|---|---|
| committer | Anjaneedevi Kapparapu <akappa@codeaurora.org> | 2016-05-25 17:29:04 +0530 |
| commit | 2ed1a8624e800f81e36051e7058f97faaa6bf837 (patch) | |
| tree | 77daa46b0132b60f3cf4fdae4c6d6a029d316f34 | |
| parent | 0177b64e2fd539297e25fc6330b0c1eb0c7fb195 (diff) | |
qcacld-2.0: Periodically update host time stamp to firmware for sync
Send host timestamp to firmware, so that firmware can print the
logs timestamp in sync with host.
Change-Id: Ia26d06faa7878fcb198186b60b07ab66bff99e54
CRs-Fixed: 1014605
| -rw-r--r-- | CORE/SERVICES/WMA/wma.c | 79 | ||||
| -rw-r--r-- | CORE/SERVICES/WMA/wma.h | 2 | ||||
| -rw-r--r-- | CORE/VOSS/inc/vos_timer.h | 4 | ||||
| -rw-r--r-- | CORE/VOSS/src/vos_timer.c | 22 |
4 files changed, 104 insertions, 3 deletions
diff --git a/CORE/SERVICES/WMA/wma.c b/CORE/SERVICES/WMA/wma.c index c9365daa47ee..6d6aaae36d15 100644 --- a/CORE/SERVICES/WMA/wma.c +++ b/CORE/SERVICES/WMA/wma.c @@ -208,6 +208,9 @@ #define WMA_LOG_COMPLETION_TIMER 10000 /* 10 seconds */ +#define WMA_FW_TIME_SYNC_TIMER 60000 /* 1 min */ +#define WMA_FW_TIME_STAMP_LOW_MASK 0xffffffff + #define WMI_TLV_HEADROOM 128 #define WMA_SUSPEND_TIMEOUT_IN_SSR 1 @@ -32323,6 +32326,11 @@ VOS_STATUS wma_stop(v_VOID_t *vos_ctx, tANI_U8 reason) WMA_LOGE("Failed to destroy the log completion timer"); } + /* Destroy firmware time stamp sync timer */ + vos_status = vos_timer_destroy(&wma_handle->wma_fw_time_sync_timer); + if (vos_status != VOS_STATUS_SUCCESS) + WMA_LOGE(FL("Failed to destroy the fw time sync timer")); + /* There's no need suspend target which is already down during SSR. */ if (!vos_is_logp_in_progress(VOS_MODULE_ID_HIF, NULL)) { #ifdef HIF_USB @@ -33051,6 +33059,65 @@ static wmi_buf_t wma_setup_wmi_init_msg(tp_wma_handle wma_handle, return buf; } +/** + * wma_send_time_stamp_sync_cmd() - timer callback send timestamp to + * firmware to sync with host. + * @wma_handle: wma handle + * + * Return: void + */ +static void wma_send_time_stamp_sync_cmd(void *data) +{ + tp_wma_handle wma_handle; + wmi_buf_t buf; + WMI_DBGLOG_TIME_STAMP_SYNC_CMD_fixed_param *time_stamp; + A_STATUS status = A_OK; + int len; + VOS_STATUS vos_status; + unsigned long time_ms; + + wma_handle = (tp_wma_handle) data; + len = sizeof(*time_stamp); + buf = wmi_buf_alloc(wma_handle->wmi_handle, len); + if (!buf) { + WMA_LOGP(FL("wmi_buf_alloc failed")); + return; + } + + time_stamp = + (WMI_DBGLOG_TIME_STAMP_SYNC_CMD_fixed_param *) + (wmi_buf_data(buf)); + WMITLV_SET_HDR(&time_stamp->tlv_header, + WMITLV_TAG_STRUC_wmi_dbglog_time_stamp_sync_cmd_fixed_param, + WMITLV_GET_STRUCT_TLVLEN( + WMI_DBGLOG_TIME_STAMP_SYNC_CMD_fixed_param)); + + time_ms = vos_get_time_of_the_day_ms(); + time_stamp->mode = WMI_TIME_STAMP_SYNC_MODE_MS; + time_stamp->time_stamp_low = time_ms & + WMA_FW_TIME_STAMP_LOW_MASK; + /* + * Send time_stamp_high 0 as the time converted from HR:MIN:SEC:MS to ms + * wont exceed 27 bit + */ + time_stamp->time_stamp_high = 0; + WMA_LOGD(FL("WMA --> DBGLOG_TIME_STAMP_SYNC_CMDID mode %d time_stamp low %d high %d"), + time_stamp->mode, time_stamp->time_stamp_low, + time_stamp->time_stamp_high); + status = wmi_unified_cmd_send(wma_handle->wmi_handle, buf, + len, WMI_DBGLOG_TIME_STAMP_SYNC_CMDID); + if (status != EOK) { + WMA_LOGE("Failed to send WMI_DBGLOG_TIME_STAMP_SYNC_CMDID command"); + wmi_buf_free(buf); + } + + /* Start/Restart the timer */ + vos_status = vos_timer_start(&wma_handle->wma_fw_time_sync_timer, + WMA_FW_TIME_SYNC_TIMER); + if (vos_status != VOS_STATUS_SUCCESS) + WMA_LOGE("Failed to start the firmware time sync timer"); +} + /* Process service ready event and send wmi_init command */ v_VOID_t wma_rx_service_ready_event(WMA_HANDLE handle, void *cmd_param_info) { @@ -33060,6 +33127,7 @@ v_VOID_t wma_rx_service_ready_event(WMA_HANDLE handle, void *cmd_param_info) struct wma_target_cap target_cap; WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf; wmi_service_ready_event_fixed_param *ev; + VOS_STATUS vos_status; int status; WMA_LOGD("%s: Enter", __func__); @@ -33221,6 +33289,17 @@ v_VOID_t wma_rx_service_ready_event(WMA_HANDLE handle, void *cmd_param_info) wmi_buf_free(buf); return; } + + /* Initialize firmware time stamp sync timer */ + vos_status = vos_timer_init(&wma_handle->wma_fw_time_sync_timer, + VOS_TIMER_TYPE_SW, + wma_send_time_stamp_sync_cmd, + wma_handle); + if (vos_status != VOS_STATUS_SUCCESS) + WMA_LOGE(FL("Failed to initialize firmware time stamp sync timer")); + + /* Start firmware time stamp sync timer */ + wma_send_time_stamp_sync_cmd(wma_handle); } /* function : wma_rx_ready_event diff --git a/CORE/SERVICES/WMA/wma.h b/CORE/SERVICES/WMA/wma.h index 9bd3dee0e2ab..7d3e0bcfd624 100644 --- a/CORE/SERVICES/WMA/wma.h +++ b/CORE/SERVICES/WMA/wma.h @@ -873,7 +873,7 @@ typedef struct wma_handle { /* NAN datapath support enabled in firmware */ bool nan_datapath_enabled; tSirLLStatsResults *link_stats_results; - + vos_timer_t wma_fw_time_sync_timer; struct sir_allowed_action_frames allowed_action_frames; }t_wma_handle, *tp_wma_handle; diff --git a/CORE/VOSS/inc/vos_timer.h b/CORE/VOSS/inc/vos_timer.h index 48805865e894..8e42742f1e4a 100644 --- a/CORE/VOSS/inc/vos_timer.h +++ b/CORE/VOSS/inc/vos_timer.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 The Linux Foundation. All rights reserved. + * Copyright (c) 2014, 2016 The Linux Foundation. All rights reserved. * * Previously licensed under the ISC license by Qualcomm Atheros, Inc. * @@ -350,5 +350,5 @@ static inline uint32_t vos_system_ticks_to_msecs(vos_time_t ticks) return __vos_system_ticks_to_msecs(ticks); } - +unsigned long vos_get_time_of_the_day_ms(void); #endif // #if !defined __VOSS_TIMER_H diff --git a/CORE/VOSS/src/vos_timer.c b/CORE/VOSS/src/vos_timer.c index f0e28a05af0e..48e3d57f439c 100644 --- a/CORE/VOSS/src/vos_timer.c +++ b/CORE/VOSS/src/vos_timer.c @@ -45,6 +45,7 @@ #include <vos_api.h> #include "wlan_qct_sys.h" #include "vos_sched.h" +#include <linux/rtc.h> /*-------------------------------------------------------------------------- Preprocessor definitions and constants @@ -847,3 +848,24 @@ v_TIME_t vos_timer_get_system_time( v_VOID_t ) do_gettimeofday(&tv); return tv.tv_sec*1000 + tv.tv_usec/1000; } + +/** + * vos_get_time_of_the_day_ms() - get time in milisec + * + * Return: time of the day in ms + */ +unsigned long vos_get_time_of_the_day_ms(void) +{ + struct timeval tv; + unsigned long local_time; + struct rtc_time tm; + + do_gettimeofday(&tv); + + local_time = (uint32_t)(tv.tv_sec - + (sys_tz.tz_minuteswest * 60)); + rtc_time_to_tm(local_time, &tm); + return ((tm.tm_hour * 60 * 60 * 1000) + + (tm.tm_min *60 * 1000) + (tm.tm_sec * 1000)+ + (tv.tv_usec/1000)); +} |
