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