qdf_event.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. /*
  2. * Copyright (c) 2014-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_event.h
  20. * This file provides OS abstraction for event APIs.
  21. */
  22. #if !defined(__QDF_EVENT_H)
  23. #define __QDF_EVENT_H
  24. /* Include Files */
  25. #include "qdf_status.h"
  26. #include <qdf_types.h>
  27. #include <i_qdf_event.h>
  28. #include <qdf_trace.h>
  29. #include <qdf_list.h>
  30. /* Preprocessor definitions and constants */
  31. #ifdef __cplusplus
  32. extern "C" {
  33. #endif /* __cplusplus */
  34. typedef __qdf_event_t qdf_event_t;
  35. /* Function declarations and documenation */
  36. QDF_STATUS qdf_event_create(qdf_event_t *event);
  37. /**
  38. * qdf_event_set() - sets a QDF event for single waiting threads
  39. * @event: The event to set to the signalled state
  40. *
  41. * The state of the specified event is set to signalled by calling
  42. * qdf_event_set().
  43. *
  44. * Single thread waiting on the event as a result of a qdf_event_wait() will
  45. * be unblocked and available to be scheduled for execution when the event
  46. * is signaled by a call to qdf_event_set().
  47. *
  48. * Return: QDF status
  49. */
  50. QDF_STATUS qdf_event_set(qdf_event_t *event);
  51. /**
  52. * qdf_event_set_all() - sets a QDF event for all waiting threads
  53. * @event: The event to set to the signalled state
  54. *
  55. * The state of the specified event is set to signalled by calling
  56. * qdf_event_set_all().
  57. *
  58. * Any threads waiting on the event as a result of a qdf_event_wait() will
  59. * be unblocked and available to be scheduled for execution when the event
  60. * is signaled by a call to qdf_event_set().
  61. *
  62. * Return: QDF status
  63. */
  64. QDF_STATUS qdf_event_set_all(qdf_event_t *event);
  65. QDF_STATUS qdf_event_reset(qdf_event_t *event);
  66. QDF_STATUS qdf_event_destroy(qdf_event_t *event);
  67. QDF_STATUS qdf_wait_single_event(qdf_event_t *event,
  68. uint32_t timeout);
  69. /**
  70. * qdf_complete_wait_events() - Sets all the events which are in the list.
  71. *
  72. * This function traverses the list of events and sets all of them. It
  73. * sets the flag force_set as TRUE to indicate that these events have
  74. * been forcefully set.
  75. *
  76. * Return: None
  77. */
  78. void qdf_complete_wait_events(void);
  79. /**
  80. * qdf_wait_for_event_completion() - Waits for an event to be set.
  81. * @event: Pointer to an event to wait on.
  82. * @timeout: Timeout value (in milliseconds).
  83. *
  84. * This function adds the event in a list and waits on it until it
  85. * is set or the timeout duration elapses. The purpose of waiting
  86. * is considered complete only if the event is set and the flag
  87. * force_set is FALSE, it returns success in this case. In other
  88. * cases it returns appropriate error status.
  89. *
  90. * Return: QDF status
  91. */
  92. QDF_STATUS qdf_wait_for_event_completion(qdf_event_t *event,
  93. uint32_t timeout);
  94. /**
  95. * qdf_event_list_init() - Creates a list and spinlock for events.
  96. *
  97. * This function creates a list for maintaining events on which threads
  98. * wait for completion. A spinlock is also created to protect related
  99. * operations.
  100. *
  101. * Return: None
  102. */
  103. void qdf_event_list_init(void);
  104. /**
  105. * qdf_event_list_destroy() - Destroys list and spinlock created for events.
  106. *
  107. * This function destroys the list and spinlock created for events on which
  108. * threads wait for completion.
  109. *
  110. * Return: None
  111. */
  112. void qdf_event_list_destroy(void);
  113. /**
  114. * qdf_exit_thread() - exit thread execution
  115. * @status: QDF status
  116. *
  117. * Return: QDF status
  118. */
  119. QDF_STATUS qdf_exit_thread(QDF_STATUS status);
  120. #ifdef __cplusplus
  121. }
  122. #endif /* __cplusplus */
  123. #endif /* __QDF_EVENT_H */