blob: 7901b3100ef523ec6ce65957e8343817bffaecdd [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Kiet Lamaa8e15a2014-02-11 23:30:06 -08002 * Copyright (c) 2012-2013 Qualcomm Atheros, Inc.
3 * All Rights Reserved.
4 * Qualcomm Atheros Confidential and Proprietary.
Gopichand Nakkala92f07d82013-01-08 21:16:34 -08005 */
Jeff Johnson295189b2012-06-20 16:38:30 -07006/**=========================================================================
7
8 \file wlan_qct_pal_sync.c
9
10 \brief Implementation trace/logging APIs PAL exports. wpt = (Wlan Pal Type) wpal = (Wlan PAL)
11
12 Definitions for platform Windows and with legacy UMAC.
13
14 Copyright 2010 (c) Qualcomm, Incorporated. All Rights Reserved.
15
16 Qualcomm Confidential and Proprietary.
17
18 ========================================================================*/
19
20#include "wlan_qct_pal_sync.h"
21#include "wlan_qct_pal_trace.h"
22
23#include "wlan_qct_os_status.h"
24
25/**
26wpalMutexInit()
27
28@brief
29 This function initializes a mutex object
30
31@param pMutex: a pointer to caller allocated object of wpt_mutex
32
33@return eWLAN_PAL_STATUS_SUCCESS if success. Fail otherwise.
34
35*/
36wpt_status wpalMutexInit(wpt_mutex *pMutex)
37{
38 /* Not doing sanity checks since VOS does them anyways */
39
40 if( vos_lock_init( (vos_lock_t*)pMutex ) != VOS_STATUS_SUCCESS )
41 {
42 WPAL_TRACE(eWLAN_MODULE_PAL, eWLAN_PAL_TRACE_LEVEL_ERROR,
Arif Hussain9a5d5382013-11-17 22:05:35 -080043 " mutex init fail");
Jeff Johnson295189b2012-06-20 16:38:30 -070044 return eWLAN_PAL_STATUS_E_FAILURE;
45 }
46
47 return eWLAN_PAL_STATUS_SUCCESS;
48}
49
50/*---------------------------------------------------------------------------
51 @brief Invalidate a mutex object
52
53 \param pMutex - a pointer to caller allocated object of wpt_mutex
54
55 \return eWLAN_PAL_STATUS_SUCCESS if success. Fail otherwise.
56---------------------------------------------------------------------------*/
57wpt_status wpalMutexDelete(wpt_mutex *pMutex)
58{
59 /* Not doing sanity checks since VOS does them anyways */
60
61 if( vos_lock_destroy( (vos_lock_t*)pMutex ) != VOS_STATUS_SUCCESS )
62 {
63 WPAL_TRACE(eWLAN_MODULE_PAL, eWLAN_PAL_TRACE_LEVEL_ERROR,
Arif Hussain9a5d5382013-11-17 22:05:35 -080064 " mutex delete fail");
Jeff Johnson295189b2012-06-20 16:38:30 -070065 return eWLAN_PAL_STATUS_E_FAILURE;
66 }
67
68 return eWLAN_PAL_STATUS_SUCCESS;
69}
70
71/*---------------------------------------------------------------------------
72 @brief Acquire a mutex object. It is blocked until the object is acquired.
73
74 \param pMutex - a pointer to caller allocated object of wpt_mutex
75
76 \return eWLAN_PAL_STATUS_SUCCESS if success. Fail otherwise.
77---------------------------------------------------------------------------*/
78wpt_status wpalMutexAcquire(wpt_mutex *pMutex)
79{
80 /* Not doing sanity checks since VOS does them anyways */
81
82 if( vos_lock_acquire( (vos_lock_t*)pMutex ) != VOS_STATUS_SUCCESS )
83 {
84 WPAL_TRACE(eWLAN_MODULE_PAL, eWLAN_PAL_TRACE_LEVEL_ERROR,
Arif Hussain9a5d5382013-11-17 22:05:35 -080085 " mutex acquire fail");
Jeff Johnson295189b2012-06-20 16:38:30 -070086 return eWLAN_PAL_STATUS_E_FAILURE;
87 }
88
89 return eWLAN_PAL_STATUS_SUCCESS;
90}
91
92/*---------------------------------------------------------------------------
93 @brief Release a held mutex object
94
95 \param pMutex - a pointer to caller allocated object of wpt_mutex
96
97 \return eWLAN_PAL_STATUS_SUCCESS if success. Fail otherwise.
98---------------------------------------------------------------------------*/
99wpt_status wpalMutexRelease(wpt_mutex *pMutex)
100{
101 /* Not doing sanity checks since VOS does them anyways */
102
103 if( vos_lock_release( (vos_lock_t*)pMutex ) != VOS_STATUS_SUCCESS )
104 {
105 WPAL_TRACE(eWLAN_MODULE_PAL, eWLAN_PAL_TRACE_LEVEL_ERROR,
Arif Hussain9a5d5382013-11-17 22:05:35 -0800106 " mutex release");
Jeff Johnson295189b2012-06-20 16:38:30 -0700107 return eWLAN_PAL_STATUS_E_FAILURE;
108 }
109
110 return eWLAN_PAL_STATUS_SUCCESS;
111}
112
113/*---------------------------------------------------------------------------
114 @brief Initialize an event object
115
116 \param pEvent – a pointer to caller allocated object of wpt_event
117
118 \return eWLAN_PAL_STATUS_SUCCESS if success. Fail otherwise.
119------------------------------------------------------------------------*/
120wpt_status wpalEventInit(wpt_event *pEvent)
121{
122 /* Not doing sanity checks since VOS does them anyways */
123
124 if( vos_event_init( (vos_event_t*)pEvent ) != VOS_STATUS_SUCCESS )
125 {
126 WPAL_TRACE(eWLAN_MODULE_PAL, eWLAN_PAL_TRACE_LEVEL_ERROR,
Arif Hussain9a5d5382013-11-17 22:05:35 -0800127 " create event fail");
Jeff Johnson295189b2012-06-20 16:38:30 -0700128 return eWLAN_PAL_STATUS_E_FAILURE;
129 }
130
131 return eWLAN_PAL_STATUS_SUCCESS;
132}
133
134/*---------------------------------------------------------------------------
135 @brief Invalidate an event object
136
137 \param pEvent – a pointer to caller allocated object of wpt_event
138
139 \return eWLAN_PAL_STATUS_SUCCESS if success. Fail otherwise.
140------------------------------------------------------------------------*/
141
142wpt_status wpalEventDelete(wpt_event *pEvent)
143{
144 /* Not doing sanity checks since VOS does them anyways */
145
146 if( vos_event_destroy( (vos_event_t*)pEvent ) != VOS_STATUS_SUCCESS )
147 {
148 WPAL_TRACE(eWLAN_MODULE_PAL, eWLAN_PAL_TRACE_LEVEL_ERROR,
Arif Hussain9a5d5382013-11-17 22:05:35 -0800149 " delete event fail");
Jeff Johnson295189b2012-06-20 16:38:30 -0700150 return eWLAN_PAL_STATUS_E_FAILURE;
151 }
152
153 return eWLAN_PAL_STATUS_SUCCESS;
154}
155
156/*---------------------------------------------------------------------------
157 @brief wpalEventWait – Wait on an event object
158
159 \param
160 pEvent – a pointer to caller allocated object of wpt_event
161 timeout - timeout value at unit of milli-seconds.
162 0xffffffff means infinite wait
163
164 \return eWLAN_PAL_STATUS_SUCCESS - the wait was satisifed by one of the events
165 in the event array being set. The index into the event arry
166 that satisfied the wait can be found at *pEventIndex.
167
168 eWLAN_PALSTATUS_E_TIMEOUT - the timeout interval elapsed before any of
169 the events were set.
170
171 eWLAN_PAL_STATUS_E_INVAL - At least one of the values specified in
172 the event array refers to an uninitialized event object. The
173 invalid event is identified by the index in *pEventIndex. Note
174 that only the first uninitialized event is detected when this error
175 is returned.
176
177 eWLAN_PAL_STATUS_E_EMPTY - the events array is empty. This condition
178 is detected by numEvents being 0 on input.
179
180 eWLAN_PAL_STATUS_E_FAULT - event or pEventIndex is an invalid pointer.
181---------------------------------------------------------------------------*/
182wpt_status wpalEventWait(wpt_event *pEvent, wpt_uint32 timeout)
183{
184 /* Not doing sanity checks since VOS does them anyways */
185
186 wpt_status status = eWLAN_PAL_STATUS_E_FAILURE;
187 VOS_STATUS vos_status = VOS_STATUS_E_FAILURE;
188
189 /* In VOS timeout = 0 corresponds to infinite wait */
190 timeout = ( timeout == WLAN_PAL_WAIT_INFINITE ? 0 : timeout );
191
192 vos_status = vos_wait_single_event( (vos_event_t*)pEvent, timeout );
193
194 status = WPAL_VOS_TO_WPAL_STATUS( vos_status );
195
196 return status;
197}
198
199/*---------------------------------------------------------------------------
200 wpalEventSet – Set an event object to signaled state
201 Param:
202 pEvent – a pointer to caller allocated object of wpt_event
203 Return:
204 eWLAN_PAL_STATUS_SUCCESS – success. Fail otherwise.
205---------------------------------------------------------------------------*/
206wpt_status wpalEventSet(wpt_event *pEvent)
207{
208 /* Not doing sanity checks since VOS does them anyways */
209
210 return ( WPAL_VOS_TO_WPAL_STATUS(vos_event_set( (vos_event_t*)pEvent )) );
211}
212
213/*---------------------------------------------------------------------------
214 wpalEventReset – Set an event object to non-signaled state
215 Param:
216 pEvent – a pointer to caller allocated object of wpt_event
217 Return:
218 eWLAN_PAL_STATUS_SUCCESS – success. Fail otherwise.
219---------------------------------------------------------------------------*/
220wpt_status wpalEventReset(wpt_event *pEvent)
221{
222 /* Not doing sanity checks since VOS does them anyways */
223
224 return ( WPAL_VOS_TO_WPAL_STATUS(vos_event_reset( (vos_event_t*)pEvent )) );
225}
226
227