Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1 | /* |
Kiet Lam | aa8e15a | 2014-02-11 23:30:06 -0800 | [diff] [blame^] | 2 | * Copyright (c) 2012-2013 Qualcomm Atheros, Inc. |
| 3 | * All Rights Reserved. |
| 4 | * Qualcomm Atheros Confidential and Proprietary. |
Gopichand Nakkala | 92f07d8 | 2013-01-08 21:16:34 -0800 | [diff] [blame] | 5 | */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6 | /** ------------------------------------------------------------------------- * |
| 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 | |
| 24 | typedef struct tagListElem |
| 25 | { |
| 26 | struct tagListElem *last; |
| 27 | struct tagListElem *next; |
| 28 | }tListElem; |
| 29 | |
| 30 | typedef enum |
| 31 | { |
| 32 | LIST_FLAG_CLOSE = 0, |
| 33 | LIST_FLAG_OPEN = 0xa1b2c4d7, |
| 34 | }tListFlag; |
| 35 | |
| 36 | //This is a circular double link list |
| 37 | typedef struct tagDblLinkList |
| 38 | { |
| 39 | tListElem ListHead; |
| 40 | vos_lock_t Lock; |
| 41 | tANI_U32 Count; |
| 42 | tHddHandle hHdd; |
| 43 | tListFlag Flag; |
Kalikinkar Dhara | a498897 | 2013-10-28 13:39:54 -0700 | [diff] [blame] | 44 | |
| 45 | /*command debugging */ |
| 46 | tANI_U32 cmdTimeoutDuration; /* command timeout duration */ |
| 47 | vos_timer_t *cmdTimeoutTimer; /*command timeout Timer */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 48 | }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 | |
| 68 | tANI_U32 csrLLCount( tDblLinkList *pList ); |
| 69 | |
| 70 | eHalStatus csrLLOpen( tHddHandle hHdd, tDblLinkList *pList ); |
| 71 | void csrLLClose( tDblLinkList *pList ); |
| 72 | |
| 73 | void csrLLLock( tDblLinkList *pList ); |
| 74 | void csrLLUnlock( tDblLinkList *pList ); |
| 75 | |
| 76 | tANI_BOOLEAN csrLLIsListEmpty( tDblLinkList *pList, tANI_BOOLEAN fInterlocked ); |
| 77 | |
| 78 | void csrLLInsertHead( tDblLinkList *pList, tListElem *pEntry, tANI_BOOLEAN fInterlocked ); |
| 79 | void csrLLInsertTail( tDblLinkList *pList, tListElem *pEntry, tANI_BOOLEAN fInterlocked ); |
| 80 | //This function put pNewEntry before pEntry. Caller should have found pEntry |
| 81 | void csrLLInsertEntry( tDblLinkList *pList, tListElem *pEntry, tListElem *pNewEntry, tANI_BOOLEAN fInterlocked ); |
| 82 | |
| 83 | tListElem *csrLLPeekHead( tDblLinkList *pList, tANI_BOOLEAN fInterlocked ); |
| 84 | tListElem *csrLLPeekTail( tDblLinkList *pList, tANI_BOOLEAN fInterlocked ); |
| 85 | |
| 86 | tListElem *csrLLRemoveHead( tDblLinkList *pList, tANI_BOOLEAN fInterlocked ); |
| 87 | tListElem *csrLLRemoveTail( tDblLinkList *pList, tANI_BOOLEAN fInterlocked ); |
| 88 | tANI_BOOLEAN csrLLRemoveEntry( tDblLinkList *pList, tListElem *pEntryToRemove, tANI_BOOLEAN fInterlocked ); |
| 89 | void csrLLPurge( tDblLinkList *pList, tANI_BOOLEAN fInterlocked ); |
| 90 | |
| 91 | //csrLLNext return NULL if reaching the end or list is empty |
| 92 | tListElem *csrLLNext( tDblLinkList *pList, tListElem *pEntry, tANI_BOOLEAN fInterlocked ); |
| 93 | |
| 94 | tListElem *csrLLPrevious( tDblLinkList *pList, tListElem *pEntry, tANI_BOOLEAN fInterlocked ); |
| 95 | |
| 96 | tANI_BOOLEAN csrLLFindEntry( tDblLinkList *pList, tListElem *pEntryToFind ); |
| 97 | |
| 98 | |
| 99 | #endif |
| 100 | |