blob: 505ec9cafadaae3bc453536198b73128369b2e2b [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 csrLinkList.h
9
10 Exports and types for the Common link list interfaces.
11
12 Copyright (C) 2006 Airgo Networks, Incorporated
13
14 ========================================================================== */
15#ifndef CSR_LINK_LIST_H__
16#define CSR_LINK_LIST_H__
17
18#include "vos_lock.h"
19
20
21#define LL_ACCESS_LOCK eANI_BOOLEAN_TRUE
22#define LL_ACCESS_NOLOCK eANI_BOOLEAN_FALSE
23
24typedef struct tagListElem
25{
26 struct tagListElem *last;
27 struct tagListElem *next;
28}tListElem;
29
30typedef enum
31{
32 LIST_FLAG_CLOSE = 0,
33 LIST_FLAG_OPEN = 0xa1b2c4d7,
34}tListFlag;
35
36//This is a circular double link list
37typedef struct tagDblLinkList
38{
39 tListElem ListHead;
40 vos_lock_t Lock;
41 tANI_U32 Count;
42 tHddHandle hHdd;
43 tListFlag Flag;
Kalikinkar Dharaa4988972013-10-28 13:39:54 -070044
45 /*command debugging */
46 tANI_U32 cmdTimeoutDuration; /* command timeout duration */
47 vos_timer_t *cmdTimeoutTimer; /*command timeout Timer */
Jeff Johnson295189b2012-06-20 16:38:30 -070048}tDblLinkList;
49
50//To get the address of an object of (type) base on the (address) of one of its (field)
51#define GET_BASE_ADDR(address, type, field) ((type *)( \
52 (tANI_U8 *)(address) - \
53 (tANI_U8 *)(&((type *)0)->field)))
54
55//To get the offset of (field) inside structure (type)
56#define GET_FIELD_OFFSET(type, field) ((tANI_U32_OR_PTR)(&(((type *)0)->field)))
57
58#define GET_ROUND_UP( _Field, _Boundary ) (((_Field) + ((_Boundary) - 1)) & ~((_Boundary) - 1))
59#define BITS_ON( _Field, _Bitmask ) ( (_Field) |= (_Bitmask) )
60#define BITS_OFF( _Field, _Bitmask ) ( (_Field) &= ~(_Bitmask) )
61
62#define CSR_MAX(a, b) ((a) > (b) ? (a) : (b))
63#define CSR_MIN(a, b) ((a) < (b) ? (a) : (b))
64
65
66#define csrIsListEmpty(pHead) ((pHead)->next == (pHead))
67
68tANI_U32 csrLLCount( tDblLinkList *pList );
69
70eHalStatus csrLLOpen( tHddHandle hHdd, tDblLinkList *pList );
71void csrLLClose( tDblLinkList *pList );
72
73void csrLLLock( tDblLinkList *pList );
74void csrLLUnlock( tDblLinkList *pList );
75
76tANI_BOOLEAN csrLLIsListEmpty( tDblLinkList *pList, tANI_BOOLEAN fInterlocked );
77
78void csrLLInsertHead( tDblLinkList *pList, tListElem *pEntry, tANI_BOOLEAN fInterlocked );
79void csrLLInsertTail( tDblLinkList *pList, tListElem *pEntry, tANI_BOOLEAN fInterlocked );
80//This function put pNewEntry before pEntry. Caller should have found pEntry
81void csrLLInsertEntry( tDblLinkList *pList, tListElem *pEntry, tListElem *pNewEntry, tANI_BOOLEAN fInterlocked );
82
83tListElem *csrLLPeekHead( tDblLinkList *pList, tANI_BOOLEAN fInterlocked );
84tListElem *csrLLPeekTail( tDblLinkList *pList, tANI_BOOLEAN fInterlocked );
85
86tListElem *csrLLRemoveHead( tDblLinkList *pList, tANI_BOOLEAN fInterlocked );
87tListElem *csrLLRemoveTail( tDblLinkList *pList, tANI_BOOLEAN fInterlocked );
88tANI_BOOLEAN csrLLRemoveEntry( tDblLinkList *pList, tListElem *pEntryToRemove, tANI_BOOLEAN fInterlocked );
89void csrLLPurge( tDblLinkList *pList, tANI_BOOLEAN fInterlocked );
90
91//csrLLNext return NULL if reaching the end or list is empty
92tListElem *csrLLNext( tDblLinkList *pList, tListElem *pEntry, tANI_BOOLEAN fInterlocked );
93
94tListElem *csrLLPrevious( tDblLinkList *pList, tListElem *pEntry, tANI_BOOLEAN fInterlocked );
95
96tANI_BOOLEAN csrLLFindEntry( tDblLinkList *pList, tListElem *pEntryToFind );
97
98
99#endif
100