1 /* 2 * Copyright (c) 2014-2017 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 #ifdef CONFIG_MCL 43 typedef void (*qdf_self_recovery_callback)(enum qdf_hang_reason); 44 #endif 45 46 QDF_STATUS qdf_event_create(qdf_event_t *event); 47 48 QDF_STATUS qdf_event_set(qdf_event_t *event); 49 50 QDF_STATUS qdf_event_reset(qdf_event_t *event); 51 52 QDF_STATUS qdf_event_destroy(qdf_event_t *event); 53 54 QDF_STATUS qdf_wait_single_event(qdf_event_t *event, 55 uint32_t timeout); 56 57 /** 58 * qdf_complete_wait_events() - Sets all the events which are in the list. 59 * 60 * This function traverses the list of events and sets all of them. It 61 * sets the flag force_set as TRUE to indicate that these events have 62 * been forcefully set. 63 * 64 * Return: None 65 */ 66 void qdf_complete_wait_events(void); 67 68 /** 69 * qdf_wait_for_event_completion() - Waits for an event to be set. 70 * @event: Pointer to an event to wait on. 71 * @timeout: Timeout value (in milliseconds). 72 * 73 * This function adds the event in a list and waits on it until it 74 * is set or the timeout duration elapses. The purpose of waiting 75 * is considered complete only if the event is set and the flag 76 * force_set is FALSE, it returns success in this case. In other 77 * cases it returns appropriate error status. 78 * 79 * Return: QDF status 80 */ 81 QDF_STATUS qdf_wait_for_event_completion(qdf_event_t *event, 82 uint32_t timeout); 83 84 /** 85 * qdf_event_list_init() - Creates a list and spinlock for events. 86 * 87 * This function creates a list for maintaining events on which threads 88 * wait for completion. A spinlock is also created to protect related 89 * operations. 90 * 91 * Return: None 92 */ 93 void qdf_event_list_init(void); 94 95 /** 96 * qdf_event_list_destroy() - Destroys list and spinlock created for events. 97 * 98 * This function destroys the list and spinlock created for events on which 99 * threads wait for completion. 100 * 101 * Return: None 102 */ 103 void qdf_event_list_destroy(void); 104 105 /** 106 * qdf_exit_thread() - exit thread execution 107 * @status: QDF status 108 * 109 * Return: QDF status 110 */ 111 QDF_STATUS qdf_exit_thread(QDF_STATUS status); 112 113 #ifdef CONFIG_MCL 114 /** 115 * qdf_register_self_recovery_callback () - register self recovery callback 116 * @callback: self recovery callback 117 * 118 * Return: None 119 */ 120 void qdf_register_self_recovery_callback(qdf_self_recovery_callback callback); 121 122 /** 123 * qdf_trigger_self_recovery () - tirgger self recovery 124 * 125 * Return: None 126 */ 127 void qdf_trigger_self_recovery(void); 128 #endif 129 130 #ifdef __cplusplus 131 } 132 #endif /* __cplusplus */ 133 #endif /* __QDF_EVENT_H */ 134