qdf_event.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. /*
  2. * Copyright (c) 2014-2018, 2021 The Linux Foundation. All rights reserved.
  3. * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
  4. *
  5. * Permission to use, copy, modify, and/or distribute this software for
  6. * any purpose with or without fee is hereby granted, provided that the
  7. * above copyright notice and this permission notice appear in all
  8. * copies.
  9. *
  10. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
  11. * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
  12. * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
  13. * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  14. * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
  15. * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  16. * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  17. * PERFORMANCE OF THIS SOFTWARE.
  18. */
  19. /**
  20. * DOC: qdf_event.h
  21. * This file provides OS abstraction for event APIs.
  22. */
  23. #if !defined(__QDF_EVENT_H)
  24. #define __QDF_EVENT_H
  25. /* Include Files */
  26. #include "qdf_status.h"
  27. #include <qdf_types.h>
  28. #include <i_qdf_event.h>
  29. #include <qdf_trace.h>
  30. #include <qdf_list.h>
  31. /* Preprocessor definitions and constants */
  32. #ifdef __cplusplus
  33. extern "C" {
  34. #endif /* __cplusplus */
  35. typedef __qdf_event_t qdf_event_t;
  36. /* Function declarations and documentation */
  37. QDF_STATUS qdf_event_create(qdf_event_t *event);
  38. /**
  39. * qdf_event_set() - sets a QDF event for single waiting threads
  40. * @event: The event to set to the signalled state
  41. *
  42. * The state of the specified event is set to signalled by calling
  43. * qdf_event_set().
  44. *
  45. * Single thread waiting on the event as a result of a qdf_event_wait() will
  46. * be unblocked and available to be scheduled for execution when the event
  47. * is signaled by a call to qdf_event_set().
  48. *
  49. * Return: QDF status
  50. */
  51. QDF_STATUS qdf_event_set(qdf_event_t *event);
  52. /**
  53. * qdf_event_set_all() - sets a QDF event for all waiting threads
  54. * @event: The event to set to the signalled state
  55. *
  56. * The state of the specified event is set to signalled by calling
  57. * qdf_event_set_all().
  58. *
  59. * Any threads waiting on the event as a result of a qdf_event_wait() will
  60. * be unblocked and available to be scheduled for execution when the event
  61. * is signaled by a call to qdf_event_set().
  62. *
  63. * Return: QDF status
  64. */
  65. QDF_STATUS qdf_event_set_all(qdf_event_t *event);
  66. QDF_STATUS qdf_event_reset(qdf_event_t *event);
  67. QDF_STATUS qdf_event_destroy(qdf_event_t *event);
  68. QDF_STATUS qdf_wait_single_event(qdf_event_t *event,
  69. uint32_t timeout);
  70. /**
  71. * qdf_complete_wait_events() - Sets all the events which are in the list.
  72. *
  73. * This function traverses the list of events and sets all of them. It
  74. * sets the flag force_set as TRUE to indicate that these events have
  75. * been forcefully set.
  76. *
  77. * Return: None
  78. */
  79. void qdf_complete_wait_events(void);
  80. /**
  81. * qdf_wait_for_event_completion() - Waits for an event to be set.
  82. * @event: Pointer to an event to wait on.
  83. * @timeout: Timeout value (in milliseconds).
  84. *
  85. * This function adds the event in a list and waits on it until it
  86. * is set or the timeout duration elapses. The purpose of waiting
  87. * is considered complete only if the event is set and the flag
  88. * force_set is FALSE, it returns success in this case. In other
  89. * cases it returns appropriate error status.
  90. *
  91. * Return: QDF status
  92. */
  93. QDF_STATUS qdf_wait_for_event_completion(qdf_event_t *event,
  94. uint32_t timeout);
  95. /**
  96. * qdf_event_list_init() - Creates a list and spinlock for events.
  97. *
  98. * This function creates a list for maintaining events on which threads
  99. * wait for completion. A spinlock is also created to protect related
  100. * operations.
  101. *
  102. * Return: None
  103. */
  104. void qdf_event_list_init(void);
  105. /**
  106. * qdf_event_list_destroy() - Destroys list and spinlock created for events.
  107. *
  108. * This function destroys the list and spinlock created for events on which
  109. * threads wait for completion.
  110. *
  111. * Return: None
  112. */
  113. void qdf_event_list_destroy(void);
  114. #ifdef __cplusplus
  115. }
  116. #endif /* __cplusplus */
  117. #endif /* __QDF_EVENT_H */