qdf_timer.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. /*
  2. * Copyright (c) 2014-2016, 2018-2021 The Linux Foundation. All rights reserved.
  3. *
  4. * Permission to use, copy, modify, and/or distribute this software for
  5. * any purpose with or without fee is hereby granted, provided that the
  6. * above copyright notice and this permission notice appear in all
  7. * copies.
  8. *
  9. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
  10. * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
  11. * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
  12. * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  13. * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
  14. * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  15. * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  16. * PERFORMANCE OF THIS SOFTWARE.
  17. */
  18. /**
  19. * DOC: qdf_timer
  20. * This file abstracts OS timers running in soft IRQ context.
  21. */
  22. #ifndef _QDF_TIMER_H
  23. #define _QDF_TIMER_H
  24. #include <qdf_types.h>
  25. #include <i_qdf_timer.h>
  26. typedef struct __qdf_timer_t qdf_timer_t;
  27. /**
  28. * qdf_timer_init() - initialize a timer
  29. * @hdl: OS handle
  30. * @timer: Timer object pointer
  31. * @func: Timer function
  32. * @arg: Argument of timer function
  33. * @type: deferrable or non deferrable timer type
  34. *
  35. * Timer type QDF_TIMER_TYPE_SW means its a deferrable sw timer which will
  36. * not cause CPU wake upon expiry
  37. * Timer type QDF_TIMER_TYPE_WAKE_APPS means its a non-deferrable timer which
  38. * will cause CPU wake up on expiry
  39. *
  40. * Return: QDF_STATUS
  41. */
  42. static inline QDF_STATUS
  43. qdf_timer_init(qdf_handle_t hdl, qdf_timer_t *timer, qdf_timer_func_t func,
  44. void *arg, QDF_TIMER_TYPE type)
  45. {
  46. return __qdf_timer_init(timer, func, arg, type);
  47. }
  48. /**
  49. * qdf_timer_start() - start a timer
  50. * @timer: timer to start
  51. * @msec: Expiration period in milliseconds
  52. *
  53. * If QDF timer multiplier is set, the timeout value may get scaled.
  54. *
  55. * Return: none
  56. */
  57. static inline void qdf_timer_start(qdf_timer_t *timer, int msec)
  58. {
  59. __qdf_timer_start(timer, msec);
  60. }
  61. /**
  62. * qdf_timer_start_on() - start a timer on assigned cpu
  63. * @timer: timer to start
  64. * @msec: Expiration period in milliseconds
  65. * @cpu: cpu to attach timer
  66. *
  67. *
  68. * Return: none
  69. */
  70. static inline void qdf_timer_start_on(qdf_timer_t *timer, int msec, int cpu)
  71. {
  72. __qdf_timer_start_on(timer, msec, cpu);
  73. }
  74. /**
  75. * qdf_timer_mod() - modify the timeout on a timer
  76. * @timer: timer to modify
  77. * @msec: Expiration period in milliseconds
  78. *
  79. * If @timer is not active, it will be activated.
  80. *
  81. * If QDF timer multiplier is set, the timeout value may get scaled.
  82. *
  83. * Return: true if @timer is already active, false if @timer was not active
  84. */
  85. static inline bool qdf_timer_mod(qdf_timer_t *timer, int msec)
  86. {
  87. return __qdf_timer_mod(timer, msec);
  88. }
  89. /**
  90. * qdf_timer_stop() - cancel a timer
  91. * @timer: timer to cancel
  92. *
  93. * Note! The timer callback may be executing when this function call returns.
  94. * If you want to ensure that it is not, use qdf_timer_sync_cancel() instead.
  95. *
  96. * Return: true if @timer was deactivated, false if @timer was not active
  97. */
  98. static inline bool qdf_timer_stop(qdf_timer_t *timer)
  99. {
  100. return __qdf_timer_stop(timer);
  101. }
  102. /**
  103. * qdf_timer_sync_cancel - Cancel a timer synchronously
  104. * @timer: timer to cancel
  105. *
  106. * If the timer callback is already running, this function blocks until it
  107. * completes.
  108. *
  109. * Return: true if @timer was deactivated, false if @timer was not active
  110. */
  111. static inline bool qdf_timer_sync_cancel(qdf_timer_t *timer)
  112. {
  113. return __qdf_timer_sync_cancel(timer);
  114. }
  115. /**
  116. * qdf_timer_free() - free a timer
  117. * @timer: timer to free
  118. *
  119. * If the timer callback is already running, this function blocks until it
  120. * completes.
  121. *
  122. * Return: none
  123. */
  124. static inline void qdf_timer_free(qdf_timer_t *timer)
  125. {
  126. __qdf_timer_free(timer);
  127. }
  128. #endif /* _QDF_TIMER_H */