import PULS_20160108
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / drivers / misc / mediatek / connectivity / combo / drv_wlan / mt6620 / wlan / include / queue.h
1 /*
2 ** $Id: //Department/DaVinci/BRANCHES/MT6620_WIFI_DRIVER_V2_3/include/queue.h#1 $
3 */
4
5 /*! \file queue.h
6 \brief Definition for singly queue operations.
7
8 In this file we define the singly queue data structure and its
9 queue operation MACROs.
10 */
11
12
13
14 /*
15 ** $Log: queue.h $
16 *
17 * 07 16 2010 cp.wu
18 *
19 * [WPD00003833] [MT6620 and MT5931] Driver migration.
20 * bugfix for SCN migration
21 * 1) modify QUEUE_CONCATENATE_QUEUES() so it could be used to concatence with an empty queue
22 * 2) before AIS issues scan request, network(BSS) needs to be activated first
23 * 3) only invoke COPY_SSID when using specified SSID for scan
24 *
25 * 07 08 2010 cp.wu
26 *
27 * [WPD00003833] [MT6620 and MT5931] Driver migration - move to new repository.
28 *
29 * 06 06 2010 kevin.huang
30 * [WPD00003832][MT6620 5931] Create driver base
31 * [MT6620 5931] Create driver base
32 *
33 * 04 20 2010 cp.wu
34 * [WPD00001943]Create WiFi test driver framework on WinXP
35 * .
36 ** \main\maintrunk.MT6620WiFiDriver_Prj\2 2009-03-10 20:11:46 GMT mtk01426
37 ** Init for develop
38 **
39 */
40
41 #ifndef _QUEUE_H
42 #define _QUEUE_H
43
44 /*******************************************************************************
45 * C O M P I L E R F L A G S
46 ********************************************************************************
47 */
48
49 /*******************************************************************************
50 * E X T E R N A L R E F E R E N C E S
51 ********************************************************************************
52 */
53 #include "gl_typedef.h"
54
55 /*******************************************************************************
56 * C O N S T A N T S
57 ********************************************************************************
58 */
59
60 /*******************************************************************************
61 * D A T A T Y P E S
62 ********************************************************************************
63 */
64 /* Singly Queue Structures - Entry Part */
65 typedef struct _QUE_ENTRY_T {
66 struct _QUE_ENTRY_T *prNext;
67 struct _QUE_ENTRY_T *prPrev; /* For Rx buffer reordering used only */
68 } QUE_ENTRY_T, *P_QUE_ENTRY_T;
69
70 /* Singly Queue Structures - Queue Part */
71 typedef struct _QUE_T {
72 P_QUE_ENTRY_T prHead;
73 P_QUE_ENTRY_T prTail;
74 UINT_32 u4NumElem;
75 } QUE_T, *P_QUE_T;
76
77
78 /*******************************************************************************
79 * P U B L I C D A T A
80 ********************************************************************************
81 */
82
83 /*******************************************************************************
84 * P R I V A T E D A T A
85 ********************************************************************************
86 */
87
88 /*******************************************************************************
89 * M A C R O S
90 ********************************************************************************
91 */
92 #define QUEUE_INITIALIZE(prQueue) \
93 { \
94 (prQueue)->prHead = (P_QUE_ENTRY_T)NULL; \
95 (prQueue)->prTail = (P_QUE_ENTRY_T)NULL; \
96 (prQueue)->u4NumElem = 0; \
97 }
98
99 #define QUEUE_IS_EMPTY(prQueue) (((P_QUE_T)(prQueue))->prHead == (P_QUE_ENTRY_T)NULL)
100
101 #define QUEUE_IS_NOT_EMPTY(prQueue) ((prQueue)->u4NumElem > 0)
102
103 #define QUEUE_GET_HEAD(prQueue) ((prQueue)->prHead)
104
105 #define QUEUE_GET_TAIL(prQueue) ((prQueue)->prTail)
106
107 #define QUEUE_GET_NEXT_ENTRY(prQueueEntry) ((prQueueEntry)->prNext)
108
109 #define QUEUE_INSERT_HEAD(prQueue, prQueueEntry) \
110 { \
111 ASSERT(prQueue); \
112 ASSERT(prQueueEntry); \
113 (prQueueEntry)->prNext = (prQueue)->prHead; \
114 (prQueue)->prHead = (prQueueEntry); \
115 if ((prQueue)->prTail == (P_QUE_ENTRY_T)NULL) { \
116 (prQueue)->prTail = (prQueueEntry); \
117 } \
118 ((prQueue)->u4NumElem)++; \
119 }
120
121 #define QUEUE_INSERT_TAIL(prQueue, prQueueEntry) \
122 { \
123 ASSERT(prQueue); \
124 ASSERT(prQueueEntry); \
125 (prQueueEntry)->prNext = (P_QUE_ENTRY_T)NULL; \
126 if ((prQueue)->prTail) { \
127 ((prQueue)->prTail)->prNext = (prQueueEntry); \
128 } else { \
129 (prQueue)->prHead = (prQueueEntry); \
130 } \
131 (prQueue)->prTail = (prQueueEntry); \
132 ((prQueue)->u4NumElem)++; \
133 }
134
135 /* NOTE: We assume the queue entry located at the beginning of "prQueueEntry Type",
136 * so that we can cast the queue entry to other data type without doubts.
137 * And this macro also decrease the total entry count at the same time.
138 */
139 #define QUEUE_REMOVE_HEAD(prQueue, prQueueEntry, _P_TYPE) \
140 { \
141 ASSERT(prQueue); \
142 prQueueEntry = (_P_TYPE)((prQueue)->prHead); \
143 if (prQueueEntry) { \
144 (prQueue)->prHead = ((P_QUE_ENTRY_T)(prQueueEntry))->prNext; \
145 if ((prQueue)->prHead == (P_QUE_ENTRY_T)NULL) { \
146 (prQueue)->prTail = (P_QUE_ENTRY_T)NULL; \
147 } \
148 ((P_QUE_ENTRY_T)(prQueueEntry))->prNext = (P_QUE_ENTRY_T)NULL; \
149 ((prQueue)->u4NumElem)--; \
150 } \
151 }
152
153 #define QUEUE_MOVE_ALL(prDestQueue, prSrcQueue) \
154 { \
155 ASSERT(prDestQueue); \
156 ASSERT(prSrcQueue); \
157 *(P_QUE_T)prDestQueue = *(P_QUE_T)prSrcQueue; \
158 QUEUE_INITIALIZE(prSrcQueue); \
159 }
160
161 #define QUEUE_CONCATENATE_QUEUES(prDestQueue, prSrcQueue) \
162 { \
163 ASSERT(prDestQueue); \
164 ASSERT(prSrcQueue); \
165 if (prSrcQueue->u4NumElem > 0) { \
166 if ((prDestQueue)->prTail) { \
167 ((prDestQueue)->prTail)->prNext = (prSrcQueue)->prHead; \
168 } else { \
169 (prDestQueue)->prHead = (prSrcQueue)->prHead; \
170 } \
171 (prDestQueue)->prTail = (prSrcQueue)->prTail; \
172 ((prDestQueue)->u4NumElem) += ((prSrcQueue)->u4NumElem); \
173 QUEUE_INITIALIZE(prSrcQueue); \
174 } \
175 }
176
177
178 /*******************************************************************************
179 * F U N C T I O N D E C L A R A T I O N S
180 ********************************************************************************
181 */
182
183 /*******************************************************************************
184 * F U N C T I O N S
185 ********************************************************************************
186 */
187
188 #endif /* _QUEUE_H */