Răsfoiți Sursa

qcacmn: Add qdf wrapper for ktime, hrtimer related APIs

Add qdf wrapper for ktime, hrtimer related functions
and abstracts in qdf layer. The  wifi driver use the
qdf wrappers for the above APIs.

ktime APIs:
=========
ktime_to_ms
ktime_set
ktime_to_ns
ktime_add_ns
ktime_get
ktime_add
ns_to_ktime

hrtimer APIs:
=====
hrtimer_forward
hrtimer_active
hrtimer_callback_running
hrtimer_cancel
hrtimer_is_queued
hrtimer_get_remaining
tasklet_hrtimer_init
tasklet_hrtimer_cancel

CRs-Fixed: 2138717
Change-Id: Ic4655d6b342f2121a5acc9b1c6bda7aabd154f8f
Venkata krishna Sundararajan 7 ani în urmă
părinte
comite
e456cb8400

+ 199 - 0
qdf/inc/qdf_hrtimer.h

@@ -0,0 +1,199 @@
+/*
+ * Copyright (c) 2014-2018 The Linux Foundation. All rights reserved.
+ *
+ * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
+ *
+ *
+ * Permission to use, copy, modify, and/or distribute this software for
+ * any purpose with or without fee is hereby granted, provided that the
+ * above copyright notice and this permission notice appear in all
+ * copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
+ * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
+ * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+ * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+/*
+ * This file was originally distributed by Qualcomm Atheros, Inc.
+ * under proprietary terms before Copyright ownership was assigned
+ * to the Linux Foundation.
+ */
+
+/**
+ * DOC: qdf_hrtimer
+ * This file abstracts high resolution timers running in hardware context.
+ */
+
+#ifndef _QDF_HRTIMER_H
+#define _QDF_HRTIMER_H
+
+#include <qdf_types.h>
+#include <i_qdf_hrtimer.h>
+#include <qdf_time.h>
+
+/* Context independent hrtimer object */
+typedef __qdf_hrtimer_data_t qdf_hrtimer_data_t;
+
+/* Platform independent timer callback function */
+typedef enum qdf_hrtimer_restart_status(*qdf_hrtimer_func_t)
+					(qdf_hrtimer_data_t *timer);
+
+/**
+ * qdf_hrtimer_start() - Starts hrtimer in given context
+ * @timer: pointer to the qdf_hrtimer_data_t object
+ * @interval: interval to forward as qdf_ktime_t object
+ * @mode: mode of qdf_hrtimer_data_t
+ *
+ * Starts hrtimer in given context
+ *
+ * Return: void
+ */
+static inline
+void qdf_hrtimer_start(qdf_hrtimer_data_t *timer, qdf_ktime_t interval,
+		       enum qdf_hrtimer_mode mode)
+{
+	__qdf_hrtimer_start(timer, interval, mode);
+}
+
+/**
+ * qdf_hrtimer_cancel() - Cancels hrtimer in given context
+ * @timer: pointer to the qdf_hrtimer_data_t object
+ *
+ * Cancels hrtimer in given context
+ *
+ * Return: void
+ */
+static inline
+void qdf_hrtimer_cancel(qdf_hrtimer_data_t *timer)
+{
+	__qdf_hrtimer_cancel(timer);
+}
+
+/**
+ * qdf_hrtimer_init() - init hrtimer based on context
+ * @timer: pointer to the qdf_hrtimer_data_t object
+ * @callback: callback function to be fired
+ * @qdf_clock_id: clock type
+ * @qdf_hrtimer_mode: mode of qdf_hrtimer_data_t
+ * @qdf_context_mode: interrupt context mode
+ *
+ * starts hrtimer in a context passed as per qdf_context_mode
+ *
+ * Return: void
+ */
+static inline void qdf_hrtimer_init(qdf_hrtimer_data_t *timer,
+				    qdf_hrtimer_func_t callback,
+				    enum qdf_clock_id clock,
+				    enum qdf_hrtimer_mode mode,
+				    enum qdf_context_mode ctx)
+{
+	__qdf_hrtimer_init(timer, callback, clock, mode, ctx);
+}
+
+/**
+ * qdf_hrtimer_kill() - kills hrtimer in given context
+ * @timer: pointer to the hrtimer object
+ *
+ * kills hrtimer in given context
+ *
+ * Return: void
+ */
+static inline
+void qdf_hrtimer_kill(__qdf_hrtimer_data_t *timer)
+{
+	 __qdf_hrtimer_kill(timer);
+}
+
+/**
+ * qdf_hrtimer_get_remaining() - check remaining time in the timer
+ * @timer: pointer to the qdf_hrtimer_data_t object
+ *
+ * check whether the timer is on one of the queues
+ *
+ * Return: remaining time as qdf_ktime_t object
+ */
+static inline qdf_ktime_t qdf_hrtimer_get_remaining(qdf_hrtimer_data_t *timer)
+{
+	return __qdf_hrtimer_get_remaining(timer);
+}
+
+/**
+ * qdf_hrtimer_is_queued() - check whether the timer is on one of the queues
+ * @timer: pointer to the qdf_hrtimer_data_t object
+ *
+ * check whether the timer is on one of the queues
+ *
+ * Return: false when the timer was not in queue
+ *         true when the timer was in queue
+ */
+static inline bool qdf_hrtimer_is_queued(qdf_hrtimer_data_t *timer)
+{
+	return __qdf_hrtimer_is_queued(timer);
+}
+
+/**
+ * qdf_hrtimer_callback_running() - check if callback is running
+ * @timer: pointer to the qdf_hrtimer_data_t object
+ *
+ * check whether the timer is running the callback function
+ *
+ * Return: false when callback is not running
+ *         true when callback is running
+ */
+static inline bool qdf_hrtimer_callback_running(qdf_hrtimer_data_t *timer)
+{
+	return __qdf_hrtimer_callback_running(timer);
+}
+
+/**
+ * qdf_hrtimer_active() - check if timer is active
+ * @timer: pointer to the qdf_hrtimer_data_t object
+ *
+ * Check if timer is active. A timer is active, when it is enqueued into
+ * the rbtree or the callback function is running.
+ *
+ * Return: false if timer is not active
+ *         true if timer is active
+ */
+static inline bool qdf_hrtimer_active(qdf_hrtimer_data_t *timer)
+{
+	return __qdf_hrtimer_active(timer);
+}
+
+/**
+ * qdf_hrtimer_cb_get_time() - get remaining time in callback
+ * @timer: pointer to the qdf_hrtimer_data_t object
+ *
+ * Get remaining time in the hrtimer callback
+ *
+ * Return: time remaining as qdf_ktime_t object
+ */
+static inline qdf_ktime_t qdf_hrtimer_cb_get_time(qdf_hrtimer_data_t *timer)
+{
+	return __qdf_hrtimer_cb_get_time(timer);
+}
+
+/**
+ * qdf_hrtimer_forward() - forward the hrtimer
+ * @timer: pointer to the qdf_hrtimer_data_t object
+ * @now: current time as qdf_ktime_t object
+ * @interval: interval to forward as qdf_ktime_t object
+ *
+ * Forward the timer expiry so it will expire in the future
+ *
+ * Return: the number of overruns
+ */
+static inline uint64_t qdf_hrtimer_forward(qdf_hrtimer_data_t *timer,
+					   qdf_ktime_t now,
+					   qdf_ktime_t interval)
+{
+	return __qdf_hrtimer_forward(timer, now, interval);
+}
+
+#endif /* _QDF_HRTIMER_H */

+ 77 - 1
qdf/inc/qdf_time.h

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014-2017 The Linux Foundation. All rights reserved.
+ * Copyright (c) 2014-2018 The Linux Foundation. All rights reserved.
  *
  * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
  *
@@ -36,6 +36,82 @@
 #include <i_qdf_time.h>
 
 typedef __qdf_time_t qdf_time_t;
+typedef __qdf_ktime_t qdf_ktime_t;
+
+/**
+ * qdf_ns_to_ktime - Converts nanoseconds to a qdf_ktime_t object
+ * @ns: time in nanoseconds
+ *
+ * Return: nanoseconds as qdf_ktime_t object
+ */
+
+static inline qdf_ktime_t qdf_ns_to_ktime(uint64_t ns)
+{
+	return __qdf_ns_to_ktime(ns);
+}
+
+/**
+ * qdf_ktime_add - Adds two qdf_ktime_t objects and returns
+ * a qdf_ktime_t object
+ * @ktime1: time as qdf_ktime_t object
+ * @ktime2: time as qdf_ktime_t object
+ *
+ * Return: sum of both qdf_ktime_t as qdf_ktime_t object
+ */
+
+static inline qdf_ktime_t qdf_ktime_add(qdf_ktime_t ktime1, qdf_ktime_t ktime2)
+{
+	return __qdf_ktime_add(ktime1, ktime2);
+}
+
+/**
+ * qdf_ktime_get - Gets the current time as qdf_ktime_t object
+ *
+ * Return: current time as qdf_ktime_t object
+ */
+
+static inline qdf_ktime_t qdf_ktime_get(void)
+{
+	return __qdf_ktime_get();
+}
+
+/**
+ * qdf_ktime_add_ns - Adds qdf_ktime_t object and nanoseconds value and
+ * returns the qdf_ktime_t object
+ * @ktime: time as qdf_ktime_t object
+ * @ns: time in nanoseconds
+ *
+ * Return: qdf_ktime_t object
+ */
+
+static inline qdf_ktime_t qdf_ktime_add_ns(qdf_ktime_t ktime, int64_t ns)
+{
+	return __qdf_ktime_add_ns(ktime, ns);
+}
+
+/**
+ * qdf_ktime_to_ms - Convert the qdf_ktime_t object into milliseconds
+ * @ktime: time as qdf_ktime_t object
+ *
+ * Return: qdf_ktime_t in milliseconds
+ */
+
+static inline int64_t qdf_ktime_to_ms(qdf_ktime_t ktime)
+{
+	return __qdf_ktime_to_ms(ktime);
+}
+
+/**
+ * qdf_ktime_to_ns - Convert the qdf_ktime_t object into nanoseconds
+ * @ktime: time as qdf_ktime_t object
+ *
+ * Return: qdf_ktime_t in nanoseconds
+ */
+
+static inline int64_t qdf_ktime_to_ns(qdf_ktime_t ktime)
+{
+	return __qdf_ktime_to_ns(ktime);
+}
 
 /**
  * qdf_system_ticks - Count the number of ticks elapsed from the time when

+ 48 - 2
qdf/inc/qdf_types.h

@@ -1085,8 +1085,9 @@ enum qdf_hang_reason {
 	QDF_RESUME_TIMEOUT = 9,
 };
 
-/*
- * Verbosity levels for stats for which want to have different levels
+/**
+ * enum qdf_stats_verbosity_level - Verbosity levels for stats
+ * for which want to have different levels
  * @QDF_STATS_VERBOSITY_LEVEL_LOW: Stats verbosity level low
  * @QDF_STATS_VERBOSITY_LEVEL_HIGH: Stats verbosity level high
  */
@@ -1095,4 +1096,49 @@ enum qdf_stats_verbosity_level {
 	QDF_STATS_VERBOSITY_LEVEL_HIGH
 };
 
+/**
+ * enum qdf_clock_id - The clock IDs of the various system clocks
+ * @QDF_CLOCK_REALTIME: Clock is close to current time of day
+ * @QDF_CLOCK_MONOTONIC: Clock is absolute elapsed time
+ */
+enum qdf_clock_id {
+	QDF_CLOCK_REALTIME = __QDF_CLOCK_REALTIME,
+	QDF_CLOCK_MONOTONIC = __QDF_CLOCK_MONOTONIC
+};
+
+/**
+ * enum qdf_hrtimer_mode - Mode arguments of qdf_hrtimer_data_t
+ * related functions
+ * @QDF_HRTIMER_MODE_ABS: Time value is absolute
+ * @QDF_HRTIMER_MODE_REL: Time value is relative to now
+ * @QDF_HRTIMER_MODE_PINNED: Timer is bound to CPU
+ */
+enum qdf_hrtimer_mode {
+	QDF_HRTIMER_MODE_ABS = __QDF_HRTIMER_MODE_ABS,
+	QDF_HRTIMER_MODE_REL = __QDF_HRTIMER_MODE_REL,
+	QDF_HRTIMER_MODE_PINNED =  __QDF_HRTIMER_MODE_PINNED,
+};
+
+/**
+ * enum qdf_hrtimer_restart_status - Return values for the
+ * qdf_hrtimer_data_t callback function
+ * @QDF_HRTIMER_NORESTART: Timer is not restarted
+ * @QDF_HRTIMER_RESTART: Timer must be restarted
+ */
+enum qdf_hrtimer_restart_status {
+	QDF_HRTIMER_NORESTART = __QDF_HRTIMER_NORESTART,
+	QDF_HRTIMER_RESTART = __QDF_HRTIMER_RESTART,
+};
+
+/**
+ * enum qdf_context_mode - Values for the
+ * hrtimer context
+ * @QDF_CONTEXT_HARDWARE: Runs in hw interrupt context
+ * @QDF_CONTEXT_TASKLET: Runs in tasklet context
+ */
+enum qdf_context_mode {
+	QDF_CONTEXT_HARDWARE = 0,
+	QDF_CONTEXT_TASKLET = 1,
+};
+
 #endif /* __QDF_TYPES_H */

+ 258 - 0
qdf/linux/src/i_qdf_hrtimer.h

@@ -0,0 +1,258 @@
+/*
+ * Copyright (c) 2014-2018 The Linux Foundation. All rights reserved.
+ *
+ * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
+ *
+ *
+ * Permission to use, copy, modify, and/or distribute this software for
+ * any purpose with or without fee is hereby granted, provided that the
+ * above copyright notice and this permission notice appear in all
+ * copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
+ * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
+ * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+ * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+/*
+ * This file was originally distributed by Qualcomm Atheros, Inc.
+ * under proprietary terms before Copyright ownership was assigned
+ * to the Linux Foundation.
+ */
+
+/**
+ * DOC: i_qdf_hrtimer
+ * This file provides OS dependent timer API's.
+ */
+
+#ifndef _I_QDF_HRTIMER_H
+#define _I_QDF_HRTIMER_H
+
+#include <linux/version.h>
+#include <linux/delay.h>
+#include <linux/timer.h>
+#include <linux/jiffies.h>
+#include <qdf_types.h>
+
+/* hrtimer data type */
+typedef struct {
+	union {
+		struct hrtimer hrtimer;
+		struct tasklet_hrtimer tasklet_hrtimer;
+	} u;
+	enum qdf_context_mode ctx;
+} __qdf_hrtimer_data_t;
+
+/**
+ * __qdf_hrtimer_start() - Starts hrtimer in given context
+ * @timer: pointer to the hrtimer object
+ * @interval: interval to forward as qdf_ktime_t object
+ * @mode: mode of hrtimer
+ *
+ * Starts hrtimer in given context
+ *
+ * Return: void
+ */
+static inline
+void __qdf_hrtimer_start(__qdf_hrtimer_data_t *timer, ktime_t interval,
+			 enum qdf_hrtimer_mode mode)
+{
+	if (timer->ctx == QDF_CONTEXT_HARDWARE)
+		hrtimer_start(&timer->u.hrtimer, interval, mode);
+	else if (timer->ctx == QDF_CONTEXT_TASKLET)
+		tasklet_hrtimer_start(&timer->u.tasklet_hrtimer,
+				      interval, mode);
+}
+
+/**
+ * __qdf_hrtimer_cancel() - cancels hrtimer in given context
+ * @timer: pointer to the hrtimer object
+ *
+ * cancels hrtimer in given context
+ *
+ * Return: void
+ */
+static inline
+void __qdf_hrtimer_cancel(__qdf_hrtimer_data_t *timer)
+{
+	if (timer->ctx == QDF_CONTEXT_HARDWARE)
+		hrtimer_cancel(&timer->u.hrtimer);
+	else if (timer->ctx == QDF_CONTEXT_TASKLET)
+		hrtimer_cancel(&timer->u.tasklet_hrtimer.timer);
+}
+
+/**
+ * __qdf_hrtimer_init() - init hrtimer in a given context
+ * @timer: pointer to the hrtimer object
+ * @cback: callback function to be fired
+ * @clock: clock id
+ * @hrtimer_mode: mode of hrtimer
+ *
+ * starts hrtimer in a context passed as per the context
+ *
+ * Return: void
+ */
+static inline void  __qdf_hrtimer_init(__qdf_hrtimer_data_t *timer,
+				       void *cback,
+				       enum qdf_clock_id clock,
+				       enum qdf_hrtimer_mode mode,
+				       enum qdf_context_mode ctx)
+{
+	struct hrtimer *hrtimer = &timer->u.hrtimer;
+	struct tasklet_hrtimer *tasklet_hrtimer = &timer->u.tasklet_hrtimer;
+
+	timer->ctx = ctx;
+
+	if (timer->ctx == QDF_CONTEXT_HARDWARE) {
+		hrtimer_init(hrtimer, clock, mode);
+		hrtimer->function = cback;
+	} else if (timer->ctx == QDF_CONTEXT_TASKLET) {
+		tasklet_hrtimer_init(tasklet_hrtimer, cback, clock, mode);
+	}
+}
+
+/**
+ * __qdf_hrtimer_kill() - kills hrtimer in given context
+ * @timer: pointer to the hrtimer object
+ *
+ * kills hrtimer in given context
+ *
+ * Return: void
+ */
+static inline
+void __qdf_hrtimer_kill(__qdf_hrtimer_data_t *timer)
+{
+	if (timer->ctx == QDF_CONTEXT_HARDWARE)
+		hrtimer_cancel(&timer->u.hrtimer);
+	else if (timer->ctx == QDF_CONTEXT_TASKLET)
+		tasklet_hrtimer_cancel(&timer->u.tasklet_hrtimer);
+}
+
+/**
+ * __qdf_hrtimer_get_remaining() - check remaining time in the timer
+ * @timer: pointer to the hrtimer object
+ *
+ * check whether the timer is on one of the queues
+ *
+ * Return: remaining time as ktime object
+ */
+static inline ktime_t __qdf_hrtimer_get_remaining(__qdf_hrtimer_data_t *timer)
+{
+	struct hrtimer *hrtimer = &timer->u.hrtimer;
+	struct tasklet_hrtimer *tasklet_hrtimer = &timer->u.tasklet_hrtimer;
+
+	if (timer->ctx == QDF_CONTEXT_HARDWARE)
+		return hrtimer_get_remaining(hrtimer);
+	else
+		return hrtimer_get_remaining(&tasklet_hrtimer->timer);
+}
+
+/**
+ * __qdf_hrtimer_is_queued() - check whether the timer is on one of the queues
+ * @timer: pointer to the hrtimer object
+ *
+ * check whether the timer is on one of the queues
+ *
+ * Return: false when the timer was not in queue
+ *         true when the timer was in queue
+ */
+static inline bool __qdf_hrtimer_is_queued(__qdf_hrtimer_data_t *timer)
+{
+	struct hrtimer *hrtimer = &timer->u.hrtimer;
+	struct tasklet_hrtimer *tasklet_hrtimer = &timer->u.tasklet_hrtimer;
+
+	if (timer->ctx == QDF_CONTEXT_HARDWARE)
+		return hrtimer_is_queued(hrtimer);
+	else
+		return hrtimer_is_queued(&tasklet_hrtimer->timer);
+}
+
+/**
+ * __qdf_hrtimer_callback_running() - check if callback is running
+ * @timer: pointer to the hrtimer object
+ *
+ * check whether the timer is running the callback function
+ *
+ * Return: false when callback is not running
+ *         true when callback is running
+ */
+static inline bool __qdf_hrtimer_callback_running(__qdf_hrtimer_data_t *timer)
+{
+	struct hrtimer *hrtimer = &timer->u.hrtimer;
+	struct tasklet_hrtimer *tasklet_hrtimer = &timer->u.tasklet_hrtimer;
+
+	if (timer->ctx == QDF_CONTEXT_HARDWARE)
+		return hrtimer_callback_running(hrtimer);
+	else
+		return hrtimer_callback_running(&tasklet_hrtimer->timer);
+}
+
+/**
+ * __qdf_hrtimer_active() - check if timer is active
+ * @timer: pointer to the hrtimer object
+ *
+ * Check if timer is active. A timer is active, when it is enqueued into
+ * the rbtree or the callback function is running.
+ *
+ * Return: false if timer is not active
+ *         true if timer is active
+ */
+static inline bool __qdf_hrtimer_active(__qdf_hrtimer_data_t *timer)
+{
+	struct hrtimer *hrtimer = &timer->u.hrtimer;
+	struct tasklet_hrtimer *tasklet_hrtimer = &timer->u.tasklet_hrtimer;
+
+	if (timer->ctx == QDF_CONTEXT_HARDWARE)
+		return hrtimer_active(hrtimer);
+	else
+		return hrtimer_active(&tasklet_hrtimer->timer);
+}
+
+/**
+ * __qdf_hrtimer_cb_get_time() - get remaining time in callback
+ * @timer: pointer to the hrtimer object
+ *
+ * Get remaining time in the hrtimer callback
+ *
+ * Return: time remaining as ktime object
+ */
+static inline ktime_t __qdf_hrtimer_cb_get_time(__qdf_hrtimer_data_t *timer)
+{
+	struct hrtimer *hrtimer = &timer->u.hrtimer;
+	struct tasklet_hrtimer *tasklet_hrtimer = &timer->u.tasklet_hrtimer;
+
+	if (timer->ctx == QDF_CONTEXT_HARDWARE)
+		return hrtimer_cb_get_time(hrtimer);
+	else
+		return hrtimer_cb_get_time(&tasklet_hrtimer->timer);
+}
+
+/**
+ * __qdf_hrtimer_forward() - forward the hrtimer
+ * @timer: pointer to the hrtimer object
+ * @now: current ktime
+ * @interval: interval to forward as ktime object
+ *
+ * Forward the timer expiry so it will expire in the future
+ *
+ * Return:the number of overruns
+ */
+static inline uint64_t __qdf_hrtimer_forward(__qdf_hrtimer_data_t *timer,
+					     ktime_t now,
+					     ktime_t interval)
+{
+	struct hrtimer *hrtimer = &timer->u.hrtimer;
+	struct tasklet_hrtimer *tasklet_hrtimer = &timer->u.tasklet_hrtimer;
+
+	if (timer->ctx == QDF_CONTEXT_HARDWARE)
+		return hrtimer_forward(hrtimer, now, interval);
+	else
+		return hrtimer_forward(&tasklet_hrtimer->timer, now, interval);
+}
+
+#endif /* _I_QDF_HRTIMER_H */

+ 70 - 0
qdf/linux/src/i_qdf_time.h

@@ -48,6 +48,76 @@
 #include <linux/version.h>
 
 typedef unsigned long __qdf_time_t;
+typedef ktime_t  __qdf_ktime_t;
+
+/**
+ * __qdf_ns_to_ktime() - Converts nanoseconds to a ktime object
+ * @ns: time in nanoseconds
+ *
+ * Return: nanoseconds as ktime object
+ */
+static inline ktime_t __qdf_ns_to_ktime(uint64_t ns)
+{
+	return ns_to_ktime(ns);
+}
+
+/**
+ * __qdf_ktime_add() - Adds two ktime objects and returns
+ * a ktime object
+ * @time1: time as ktime object
+ * @time2: time as ktime object
+ *
+ * Return: sum of ktime objects as ktime object
+ */
+static inline ktime_t __qdf_ktime_add(ktime_t ktime1, ktime_t ktime2)
+{
+	return ktime_add(ktime1, ktime2);
+}
+
+/**
+ * __qdf_ktime_get() - Gets the current time as ktime object
+ *
+ * Return: current time as ktime object
+ */
+static inline ktime_t __qdf_ktime_get(void)
+{
+	return ktime_get();
+}
+
+/**
+ * __qdf_ktime_add_ns() - Adds ktime object and nanoseconds value and
+ * returns the ktime object
+ *
+ * Return: ktime object
+ */
+static inline ktime_t __qdf_ktime_add_ns(ktime_t ktime, int64_t ns)
+{
+	return ktime_add_ns(ktime, ns);
+}
+
+/**
+ * __qdf_ktime_to_ns() - convert ktime to nanoseconds
+ * @ktime: time as ktime object
+ * @ns: time in nanoseconds
+ *
+ * Return: ktime in nanoseconds
+ */
+static inline int64_t __qdf_ktime_to_ns(ktime_t ktime)
+{
+	return ktime_to_ns(ktime);
+}
+
+/**
+ * __qdf_ktime_to_ms() - convert ktime to milliseconds
+ * @ktime: time as ktime object
+ *
+ * Return: ktime in milliseconds
+ */
+static inline int64_t __qdf_ktime_to_ms(ktime_t ktime)
+{
+	return ktime_to_ms(ktime);
+}
+
 
 /**
  * __qdf_system_ticks() - get system ticks

+ 6 - 6
qdf/linux/src/i_qdf_timer.h

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014-2017 The Linux Foundation. All rights reserved.
+ * Copyright (c) 2014-2018 The Linux Foundation. All rights reserved.
  *
  * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
  *
@@ -47,7 +47,7 @@
 /* timer data type */
 typedef struct timer_list __qdf_timer_t;
 
-typedef void (*qdf_dummy_timer_func_t)(unsigned long arg);
+typedef void (*__qdf_dummy_timer_func_t)(unsigned long arg);
 
 /**
  * __qdf_timer_init() - initialize a softirq timer
@@ -72,19 +72,19 @@ static inline QDF_STATUS __qdf_timer_init(qdf_handle_t hdl,
 	if (type == QDF_TIMER_TYPE_SW) {
 		if (object_is_on_stack(timer))
 			setup_deferrable_timer_on_stack(
-			    timer, (qdf_dummy_timer_func_t)func,
+			    timer, (__qdf_dummy_timer_func_t)func,
 			    (unsigned long)arg);
 		else
 			setup_deferrable_timer(timer,
-					       (qdf_dummy_timer_func_t)func,
+					       (__qdf_dummy_timer_func_t)func,
 					       (unsigned long)arg);
 	} else {
 		if (object_is_on_stack(timer))
 			setup_timer_on_stack(timer,
-					     (qdf_dummy_timer_func_t)func,
+					     (__qdf_dummy_timer_func_t)func,
 					     (unsigned long)arg);
 		else
-			setup_timer(timer, (qdf_dummy_timer_func_t)func,
+			setup_timer(timer, (__qdf_dummy_timer_func_t)func,
 				    (unsigned long)arg);
 	}
 

+ 27 - 0
qdf/linux/src/i_qdf_types.h

@@ -72,6 +72,26 @@
 #endif
 
 typedef struct sg_table __sgtable_t;
+
+/*
+ * The IDs of the various system clocks
+ */
+#define __QDF_CLOCK_REALTIME CLOCK_REALTIME
+#define __QDF_CLOCK_MONOTONIC CLOCK_MONOTONIC
+
+/*
+ * Return values for the qdf_hrtimer_data_t callback function
+ */
+#define __QDF_HRTIMER_NORESTART HRTIMER_NORESTART
+#define __QDF_HRTIMER_RESTART HRTIMER_RESTART
+
+/*
+ * Mode arguments of qdf_hrtimer_data_t related functions
+ */
+#define __QDF_HRTIMER_MODE_ABS HRTIMER_MODE_ABS
+#define __QDF_HRTIMER_MODE_REL HRTIMER_MODE_REL
+#define __QDF_HRTIMER_MODE_PINNED HRTIMER_MODE_PINNED
+
 #else
 
 /*
@@ -95,6 +115,13 @@ typedef unsigned long __sgtable_t;
 #define DMA_TO_DEVICE   0
 #define DMA_BIDIRECTIONAL 0
 #define DMA_FROM_DEVICE 0
+#define __QDF_CLOCK_REALTIME 0
+#define __QDF_CLOCK_MONOTONIC 0
+#define __QDF_HRTIMER_MODE_ABS 0
+#define __QDF_HRTIMER_MODE_REL 0
+#define __QDF_HRTIMER_MODE_PINNED 0
+#define __QDF_HRTIMER_NORESTART 0
+#define __QDF_HRTIMER_RESTART 0
 #define __iomem
 #endif /* __KERNEL__ */