diff --git a/qdf/linux/src/i_qdf_time.h b/qdf/linux/src/i_qdf_time.h index 6c1133ee6d..80d3b4663d 100644 --- a/qdf/linux/src/i_qdf_time.h +++ b/qdf/linux/src/i_qdf_time.h @@ -252,11 +252,7 @@ static inline bool __qdf_system_time_after_eq(__qdf_time_t a, __qdf_time_t b) */ static inline uint64_t __qdf_get_monotonic_boottime(void) { - struct timespec ts; - - get_monotonic_boottime(&ts); - - return ((uint64_t) ts.tv_sec * 1000000) + (ts.tv_nsec / 1000); + return (uint64_t)ktime_to_us(ktime_get_boottime()); } #if defined (MSM_PLATFORM) @@ -308,7 +304,13 @@ static inline uint64_t __qdf_get_log_timestamp(void) * The time since system booted in nanoseconds */ -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 17, 0)) +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 3, 0)) +static inline uint64_t __qdf_get_bootbased_boottime_ns(void) +{ + return ktime_get_boottime_ns(); +} + +#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 17, 0)) static inline uint64_t __qdf_get_bootbased_boottime_ns(void) { return ktime_get_boot_ns(); diff --git a/qdf/linux/src/qdf_mc_timer.c b/qdf/linux/src/qdf_mc_timer.c index a26601b60d..e5c2ed2a7b 100644 --- a/qdf/linux/src/qdf_mc_timer.c +++ b/qdf/linux/src/qdf_mc_timer.c @@ -30,6 +30,7 @@ #include "qdf_mem.h" #include #include "qdf_timer.h" +#include /* Preprocessor definitions and constants */ #define LINUX_TIMER_COOKIE 0x12341234 @@ -822,6 +823,17 @@ qdf_export_symbol(qdf_mc_timer_get_system_ticks); * Return: * The current system time in milliseconds */ +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 0, 0)) +unsigned long qdf_mc_timer_get_system_time(void) +{ + struct timespec64 tv; + + ktime_get_real_ts64(&tv); + return tv.tv_sec * 1000 + tv.tv_nsec / 1000000; +} +qdf_export_symbol(qdf_mc_timer_get_system_time); + +#else unsigned long qdf_mc_timer_get_system_time(void) { struct timeval tv; @@ -830,17 +842,32 @@ unsigned long qdf_mc_timer_get_system_time(void) return tv.tv_sec * 1000 + tv.tv_usec / 1000; } qdf_export_symbol(qdf_mc_timer_get_system_time); +#endif s64 qdf_get_monotonic_boottime_ns(void) { - struct timespec ts; - - get_monotonic_boottime(&ts); - - return timespec_to_ns(&ts); + return ktime_to_ns(ktime_get_boottime()); } qdf_export_symbol(qdf_get_monotonic_boottime_ns); +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 0, 0)) +qdf_time_t qdf_get_time_of_the_day_ms(void) +{ + struct timespec64 tv; + qdf_time_t local_time; + struct rtc_time tm; + + ktime_get_real_ts64(&tv); + local_time = (qdf_time_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_nsec / 1000000); +} +qdf_export_symbol(qdf_get_time_of_the_day_ms); + +#else qdf_time_t qdf_get_time_of_the_day_ms(void) { struct timeval tv; @@ -856,6 +883,7 @@ qdf_time_t qdf_get_time_of_the_day_ms(void) (tv.tv_usec / 1000); } qdf_export_symbol(qdf_get_time_of_the_day_ms); +#endif /** * qdf_timer_module_deinit() - Deinitializes a QDF timer module. @@ -871,6 +899,25 @@ void qdf_timer_module_deinit(void) } qdf_export_symbol(qdf_timer_module_deinit); +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 0, 0)) +void qdf_get_time_of_the_day_in_hr_min_sec_usec(char *tbuf, int len) +{ + struct timespec64 tv; + struct rtc_time tm; + unsigned long local_time; + + /* Format the Log time R#: [hr:min:sec.microsec] */ + ktime_get_real_ts64(&tv); + /* Convert rtc to local time */ + local_time = (u32)(tv.tv_sec - (sys_tz.tz_minuteswest * 60)); + rtc_time_to_tm(local_time, &tm); + scnprintf(tbuf, len, + "[%02d:%02d:%02d.%06lu]", + tm.tm_hour, tm.tm_min, tm.tm_sec, tv.tv_nsec / 1000); +} +qdf_export_symbol(qdf_get_time_of_the_day_in_hr_min_sec_usec); + +#else void qdf_get_time_of_the_day_in_hr_min_sec_usec(char *tbuf, int len) { struct timeval tv; @@ -887,3 +934,4 @@ void qdf_get_time_of_the_day_in_hr_min_sec_usec(char *tbuf, int len) tm.tm_hour, tm.tm_min, tm.tm_sec, tv.tv_usec); } qdf_export_symbol(qdf_get_time_of_the_day_in_hr_min_sec_usec); +#endif