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