From 14201bf72d1b5215e564a375d881a762e2f4d737 Mon Sep 17 00:00:00 2001 From: Houston Hoffman Date: Wed, 14 Dec 2016 18:17:47 -0800 Subject: [PATCH] qcacmn: support logtime conversion for qtimer The api qdf_get_log_timestamp is the fastest way to get a high resolution timestamp in the system, however its scaling is not consistent. This adds some conversion apis for logging time differences in human readible quantities. This also adds the reverse conversion. Change-Id: I6c22132514c2cebb67c850260214a7f734bf8670 CRs-Fixed: 1100505 --- qdf/inc/qdf_time.h | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/qdf/inc/qdf_time.h b/qdf/inc/qdf_time.h index 3faed02dde..c3bacd72db 100644 --- a/qdf/inc/qdf_time.h +++ b/qdf/inc/qdf_time.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014-2016 The Linux Foundation. All rights reserved. + * Copyright (c) 2014-2017 The Linux Foundation. All rights reserved. * * Previously licensed under the ISC license by Qualcomm Atheros, Inc. * @@ -167,10 +167,23 @@ enum qdf_timestamp_unit { #ifdef QCA_WIFI_3_0_ADRASTEA #define QDF_LOG_TIMESTAMP_UNIT QTIMER +#define QDF_LOG_TIMESTAMP_CYCLES_PER_10_US 192 #else #define QDF_LOG_TIMESTAMP_UNIT KERNEL_LOG +#define QDF_LOG_TIMESTAMP_CYCLES_PER_10_US 10 #endif +static inline unsigned long long qdf_log_timestamp_to_usecs(uint64_t time) +{ + if ((time * 10) < time) + return (time / QDF_LOG_TIMESTAMP_CYCLES_PER_10_US) * 10; + return (time * 10) / QDF_LOG_TIMESTAMP_CYCLES_PER_10_US; +} + +static inline uint64_t qdf_usecs_to_log_timestamp(uint64_t usecs) +{ + return (usecs * QDF_LOG_TIMESTAMP_CYCLES_PER_10_US) / 10; +} /** * qdf_get_log_timestamp - get time stamp for logging