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