blob: 841e90647c07110927bbd52358be38d605cdcc2f [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#if !defined( __WLAN_QCT_OS_LIST_H )
7#define __WLAN_QCT_OS_LIST_H
8
9/**=========================================================================
10
11 \file wlan_qct_pal_list.h
12
13 \brief define linked list PAL exports. wpt = (Wlan Pal Type) wpal = (Wlan PAL)
14
15 Definitions for platform dependent. It is with VOSS support.
16
17 Copyright 2010 (c) Qualcomm, Incorporated. All Rights Reserved.
18
19 Qualcomm Confidential and Proprietary.
20
21 ========================================================================*/
22
23#include "wlan_qct_pal_type.h"
24#include "wlan_qct_pal_status.h"
25//Include vos_list.h here. For non-VOSS PAL, it needs to provide its own definition.
26#include "vos_list.h"
27
28typedef vos_list_t wpt_list;
29typedef vos_list_node_t wpt_list_node;
30
31#define WPAL_LIST_STATUS_BASIC_CHECK(status) ( VOS_IS_STATUS_SUCCESS(status) ? \
32 eWLAN_PAL_STATUS_SUCCESS : eWLAN_PAL_STATUS_E_FAILURE )
33
34#define WPAL_LIST_IS_VOS_STATUS_BUSY(status) (VOS_STATUS_E_BUSY == (status))
35#define WPAL_LIST_STATUS_BUSY_CHECK(status) ( VOS_IS_STATUS_SUCCESS(status) ? \
36 eWLAN_PAL_STATUS_SUCCESS : (WPAL_LIST_IS_VOS_STATUS_BUSY(status) ? \
37 eWLAN_PAL_STATUS_E_BUSY : eWLAN_PAL_STATUS_E_FAILURE) )
38
39/**---------------------------------------------------------------------------
40
41 \brief wpal_list_init() - initialize a wpt_list Linked List
42
43 The \a wpal_list_init() function initializes the specified linked list
44 'object'. Upon successful initialization, the state of the list
45 becomes initialized and available for use through the other wpt_list_xxx
46 APIs.
47
48 A list must be initialized by calling wpal_list_init() before it
49 may be used in any other lock functions.
50
51 Attempting to initialize an already initialized list results in
52 a failure.
53
54 \param pList - pointer to the opaque list object to initialize
55
56 \return eWLAN_PAL_STATUS_SUCCESS - list was successfully initialized and
57 is ready to be used.
58
59 eWLAN_PAL_STATUS_E_RESOURCES - System resources (other than memory)
60 are unavailable to initilize the list
61
62 eWLAN_PAL_STATUS_E_NOMEM - insufficient memory exists to initialize
63 the list
64
65 eWLAN_PAL_STATUS_E_BUSY - The implementation has detected an attempt
66 to reinitialize the object referenced by list, a previously
67 initialized, but not yet destroyed, list.
68
69 eWLAN_PAL_STATUS_E_FAULT - pList is an invalid pointer.
70
71 \sa
72
73 --------------------------------------------------------------------------*/
74#define wpal_list_init(pList) \
75 WPAL_LIST_STATUS_BASIC_CHECK( vos_list_init( (vos_list_t *)(pList) ) )
76
77
78/**-------------------------------------------------------------------------
79
80 \brief wpal_list_destroy() - Destroy a wpt_list List
81
82 The \a wpal_list_destroy() function shall destroy the list object
83 referenced by pList. After a successful return from \a wpal_list_destroy()
84 the list object becomes, in effect, uninitialized.
85
86 A destroyed lock object can be reinitialized using wpal_list_init();
87 the results of otherwise referencing the object after it has been destroyed
88 are undefined. Calls to wpt_list functions to manipulate the list such
89 will fail if the list or has not been initialized or is destroyed.
90 Therefore, don't use the list after it has been destroyed until it has
91 been re-initialized.
92
93 \param pLlist - pointer to the list object to be destroyed.
94
95 \return eWLAN_PAL_STATUS_SUCCESS - list was successfully destroyed.
96
97 eWLAN_PAL_STATUS_E_BUSY - The implementation has detected an attempt
98 to destroy the object referenced by pList that is still has
99 nodes. The list must be empty before it can be destroyed.
100
101 eWLAN_PAL_STATUS_E_INVAL - The value specified by pList is not a valid,
102 initialized list object.
103
104 eWLAN_PAL_STATUS_E_FAULT - pList is an invalid pointer.
105 \sa
106
107 ----------------------------------------------------------------------------*/
108#define wpal_list_destroy(pList) \
109 WPAL_LIST_STATUS_BUSY_CHECK( vos_list_destroy( (vos_list_t *)(pList) ) )
110
111/**---------------------------------------------------------------------------
112
113 \brief wpal_list_insert_front() - insert node at front of a linked list
114
115 The wpal_list_insert_front() API will insert a node at the front of
116 a properly initialized wpt_list object.
117
118 \param pList - Pointer to list object where the node will be inserted
119
120 \param pNode - Pointer to the list node to be inserted into the list.
121
122 \return eWLAN_PAL_STATUS_SUCCESS - list node was successfully inserted onto
123 the front of the list.
124
125 eWLAN_PAL_STATUS_E_FAILURE - Failure.
126
127 \sa
128
129 --------------------------------------------------------------------------*/
130//wpt_status wpal_list_insert_front( wpt_list *pList, wpt_list_node *pNode );
131#define wpal_list_insert_front(pList, pNode) \
132 WPAL_LIST_STATUS_BASIC_CHECK( vos_list_insert_front( (vos_list_t *)(pList), (vos_list_node_t *)(pNode) ) )
133
134
135/**---------------------------------------------------------------------------
136
137 \brief wpal_list_insert_back() - insert node at back of a linked list
138
139 The wpal_list_insert_back() API will insert a node at the back of
140 a properly initialized wpt_list object.
141
142 \param pList - Pointer to list object where the node will be inserted
143
144 \param pNode - Pointer to the list node to be inserted into the list.
145
146 \return eWLAN_PAL__STATUS_SUCCESS - list node was successfully inserted onto
147 the back of the list.
148
149 eWLAN_PAL_STATUS_E_FAILURE - Failure.
150
151 \sa
152
153 --------------------------------------------------------------------------*/
154//wpt_status wpal_list_insert_back( wpt_list *pList, wpt_list_node *pNode );
155#define wpal_list_insert_back(pList, pNode) \
156 WPAL_LIST_STATUS_BASIC_CHECK( vos_list_insert_back( (vos_list_t *)(pList), (vos_list_node_t *)(pNode) ) )
157
158
159/**---------------------------------------------------------------------------
160
161 \brief wpal_list_remove_front() - remove node at front of a linked list
162
163 The wpal_list_remove_front() API will remove a node at the front of
164 a properly initialized wpt_ist object.
165
166 \param pList - Pointer to list object where the node will be removed
167
168 \param ppNode - Pointer to a pointer to the list node to be removed
169 from the list.
170
171 \return eWLAN_PAL_STATUS_SUCCESS - list node was successfully removed from
172 the front of the list.
173
174 eWLAN_PAL_STATUS_E_INVAL - The value specified by pList is not a valid,
175 initialized list object.
176
177 eWLAN_PAL_STATUS_E_EMPTY - The specified is empty so nodes cannot be
178 removed.
179
180 eWLAN_PAL_STATUS_E_FAULT - pList is an invalid pointer or ppNode is an
181 invalid pointer.
182
183 \sa
184
185 --------------------------------------------------------------------------*/
186//wpt_status wpal_list_remove_front( wpt_list *pList, wpt_list_node **ppNode );
187#define wpal_list_remove_front(pList, ppNode) \
Madan Mohan Koyyalamudia53c4dc2012-11-13 10:35:42 -0800188 ((wpt_status)vos_list_remove_front( (vos_list_t *)(pList), (vos_list_node_t **)(ppNode) ))
Jeff Johnson295189b2012-06-20 16:38:30 -0700189
190
191/**---------------------------------------------------------------------------
192
193 \brief wpal_list_remove_back() - remove node at back of a linked list
194
195 The wpal_list_remove_back() API will remove a node at the back of
196 a properly initialized wpt_list object.
197
198 \param pList - Pointer to list object where the node will be removed
199
200 \param ppNode - Pointer to a pointer to the list node to be removed
201 from the list.
202
203 \return eWLAN_PAL_STATUS_SUCCESS - list node was successfully removed from
204 the back of the list.
205
206 eWLAN_PAL_STATUS_E_FAILURE - Failure.
207
208 \sa
209
210 --------------------------------------------------------------------------*/
211//wpt_status wpal_list_remove_back( wpt_list *pList, wpt_list_node **ppNode );
212#define wpal_list_remove_back(pList, ppNode) \
213 WPAL_LIST_STATUS_BASIC_CHECK( vos_list_remove_back( (vos_list_t *)(pList), (vos_list_node_t **)(ppNode) ) )
214
215
216/*----------------------------------------------------------------------------
217
218 \brief wpal_list_size() - return the size of of a linked list
219
220 The wpal_list_size() API will return the number of nodes on the
221 given wpt_list object.
222
223 \param pList - Pointer to list object where the node will be counted
224
225 \param pSize - Pointer to a size variable, where the size of the
226 list will be returned.
227
228 \return eWLAN_PAL_STATUS_SUCCESS - list size of the properly initialized
229 wpt_list object has been returned.
230
231 eWLAN_PAL_STATUS_E_FAILURE - Failure
232
233 \sa
234
235 --------------------------------------------------------------------------*/
236//wpt_status wpal_list_size( wpt_list *pList, wpt_uint32 *pSize );
237#define wpal_list_size(pList, pSize) \
238 WPAL_LIST_STATUS_BASIC_CHECK( vos_list_size( (vos_list_t *)(pList), (v_SIZE_t *)(pSize) ) )
239
240/**---------------------------------------------------------------------------
241
242 \brief wpal_list_peek_front() - peek at the node at front of a linked list
243
244 The wpal_list_peek_front() API will return a pointer to the node at the
245 front of a properly initialized wpt_list object. The node will *not* be
246 removed from the list.
247
248 \param pList - Pointer to list object of the list to be 'peeked'
249
250 \param ppNode - Pointer to a pointer to the list node that exists at
251 the front of the list.
252
253 \return eWLAN_PAL_STATUS_SUCCESS - list node at the front of the list was
254 successfully returned.
255
256 eWLAN_PAL_STATUS_E_Failure.
257
258 \sa
259
260 --------------------------------------------------------------------------*/
261//wpt_status wpal_list_peek_front( wpt_list *pList, wpt_list_node **ppNode );
262#define wpal_list_peek_front(pList, ppNode) \
263 WPAL_LIST_STATUS_BASIC_CHECK( vos_list_peek_front( (vos_list_t *)(pList), (vos_list_node_t **)(ppNode) ) )
264
265/**---------------------------------------------------------------------------
266
267 \brief wpal_list_peek_back() - peek at the node at back of a linked list
268
269 The wpal_list_peek_back() API will return a pointer to the node at the
270 back of a properly initialized wpt_list object. The node will *not* be
271 removed from the list.
272
273 \param pList - Pointer to list object of the list to be 'peeked'
274
275 \param ppNode - Pointer to a pointer to the list node that exists at
276 the back of the list.
277
278 \return eWLAN_PAL_STATUS_SUCCESS - list node at the back of the list was
279 successfully returned.
280
281 eWLAN_PAL_STATUS_E_FAILURE - Failure.
282
283 \sa
284
285 --------------------------------------------------------------------------*/
286//wpt_status wpal_list_peek_back( wpal_list *pList, wpt_list_node **ppNode );
287#define wpal_list_peek_back(pList, ppNode) \
288 WPAL_LIST_STATUS_BASIC_CHECK( vos_list_peek_back( (vos_list_t *)(pList), (vos_list_node_t **)(ppNode) ) )
289
290/**---------------------------------------------------------------------------
291
292 \brief wpal_list_peek_next() - peek at the node after the specified node
293
294 The wpal_list_peek_next() API will return a pointer to the node following the
295 specified node on a properly initialized wpt_list object. The node will
296 *not* be removed from the list.
297
298 \param pList - Pointer to list object of the list to be 'peeked'
299
300 \param pNode - Pointer to the node that is being 'peeked'
301
302 \param ppNode - Pointer to a pointer to the list node that follows the
303 pNode node on the list.
304
305 \return eWLAN_PAL_STATUS_SUCCESS - list node following pNode on the properly
306 initialized list is successfully returned.
307
308 eWLAN_PAL_STATUS_E_FAILURE - Failure.
309
310 \sa
311
312 --------------------------------------------------------------------------*/
313//wpt_status wpal_list_peek_next( wpt_list *pList, wpt_list_node *pNode,
314// wpt_list_node **ppNode );
315#define wpal_list_peek_next(pList, pNode, ppNode) \
316 WPAL_LIST_STATUS_BASIC_CHECK( vos_list_peek_next( (vos_list_t *)(pList), (vos_list_node_t *)(pNode), (vos_list_node_t **)(ppNode) ) )
317
318/**---------------------------------------------------------------------------
319
320 \brief wpal_list_peek_prev() - peek at the node before the specified node
321
322 The wpal_list_peek_prev() API will return a pointer to the node before the
323 specified node on a properly initialized wpt_list object. The node will
324 *not* be removed from the list.
325
326 \param pList - Pointer to list object of the list to be 'peeked'
327
328 \param pNode - Pointer to the node that is being 'peeked'
329
330 \param ppNode - Pointer to a pointer to the list node before the
331 pNode node on the list.
332
333 \return eWLAN_PAL_STATUS_SUCCESS - list node before pNode on the properly
334 initialized list is successfully returned.
335
336 eWLAN_PAL_STATUS_E_FAILURE - Failure.
337
338 \sa
339
340 --------------------------------------------------------------------------*/
341//wpt_status wpal_list_peek_prev( wpt_list *pList, wpt_list_node *pNode,
342// wpt_list_node **ppNode );
343#define wpal_list_peek_prev(pList, pNode, ppNode) \
344 WPAL_LIST_STATUS_BASIC_CHECK( vos_list_peek_prev( (vos_list_t *)(pList), (vos_list_node_t *)(pNode), (vos_list_node_t **)(ppNode) ) )
345
346/**---------------------------------------------------------------------------
347
348 \brief wpal_list_insert_before() - insert node at front of a specified
349 list node
350
351 The wpal_list_insert_before() API will insert a node onto a properly
352 initialized wpt_list object in front of the specified list node.
353
354 \param pList - Pointer to list object where the node will be inserted
355
356 \param pNodeToInsert - Pointer to the list node to be inserted into the list.
357
358 \param pNode - Pointer to the list node where pNodeToInsert will be inserted
359 in front of.
360
361 \return eWLAN_PAL_STATUS_SUCCESS - list node was successfully inserted onto
362 the front of the list.
363
364 eWLAN_PAL_STATUS_FAILURE - Failure.
365
366 \sa
367
368 --------------------------------------------------------------------------*/
369//wpt_status wpal_list_insert_before( wpt_list *pList,
370// wpt_list_node *pNodeToInsert,
371// wpt_list_node *pNode );
372#define wpal_list_insert_before(pList, pNodeToInsert, pNode) \
373 WPAL_LIST_STATUS_BASIC_CHECK( vos_list_insert_before( (vos_list_t *)(pList), \
374 (vos_list_node_t *)(pNodeToInsert), (vos_list_node_t *)(pNode) ) )
375
376/**---------------------------------------------------------------------------
377
378 \brief wpal_list_insert_after() - insert node behind a specified list node
379
380 The wpal_list_insert_after() API will insert a node onto a properly
381 initialized wpt_list object after the specified list node.
382
383 \param pList - Pointer to list object where the node will be inserted
384
385 \param pNodeToInsert - Pointer to the list node to be inserted into the list.
386
387 \param pNode - Pointer to the list node where pNodeToInsert will be inserted
388 after.
389
390 \return eWLAN_PAL_STATUS_SUCCESS - list node was successfully inserted onto
391 the front of the list.
392
393 eWLAN_PAL_STATUS_E_FAILURE - Failure
394
395 \sa
396
397 --------------------------------------------------------------------------*/
398//wpt_status wpal_list_insert_after( wpt_list *pList,
399// wpt_list_node *pNodeToInsert,
400// wpt_list_node *pNode );
401#define wpal_list_insert_after(pList, pNodeToInsert, pNode) \
Madan Mohan Koyyalamudia53c4dc2012-11-13 10:35:42 -0800402 (WPAL_LIST_STATUS_BASIC_CHECK( vos_list_insert_after((vos_list_t *)(pList), \
403 (vos_list_node_t *)(pNodeToInsert), (vos_list_node_t *)(pNode) ))
Jeff Johnson295189b2012-06-20 16:38:30 -0700404
405
406/**---------------------------------------------------------------------------
407
408 \brief wpal_list_remove_node() - remove specified node from wpt_list list
409
410 The wpal_list_remove_node() API will remove a specified node from the
411 properly initialized wpt_list object.
412
413 \param pList - Pointer to list object where the node will be removed
414
415 \param ppNode - Pointer to the node to be removed from the list.
416
417 \return eWLAN_PAL_STATUS_SUCCESS - list node was successfully removed from
418 the list.
419
420 eWLAN_PAL_STATUS_E_FAILURE - Failure.
421
422 \sa
423
424 --------------------------------------------------------------------------*/
425//wpt_status wpal_list_remove_node( wpt_list *pList, wpt_list_node *pNodeToRemove );
426#define wpal_list_remove_node(pList, pNodeToRemove) \
427 WPAL_LIST_STATUS_BASIC_CHECK( vos_list_remove_node( (vos_list_t *)(pList), \
428 (vos_list_node_t *)(pNodeToRemove) ) )
429
430
431#endif // __WLAN_QCT_OS_LIST_H