2 ** $Id: //Department/DaVinci/BRANCHES/MT6620_WIFI_DRIVER_V2_3/include/queue.h#1 $
6 \brief Definition for singly queue operations.
8 In this file we define the singly queue data structure and its
9 queue operation MACROs.
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
27 * [WPD00003833] [MT6620 and MT5931] Driver migration - move to new repository.
29 * 06 06 2010 kevin.huang
30 * [WPD00003832][MT6620 5931] Create driver base
31 * [MT6620 5931] Create driver base
34 * [WPD00001943]Create WiFi test driver framework on WinXP
36 ** \main\maintrunk.MT6620WiFiDriver_Prj\2 2009-03-10 20:11:46 GMT mtk01426
44 /*******************************************************************************
45 * C O M P I L E R F L A G S
46 ********************************************************************************
49 /*******************************************************************************
50 * E X T E R N A L R E F E R E N C E S
51 ********************************************************************************
53 #include "gl_typedef.h"
55 /*******************************************************************************
57 ********************************************************************************
60 /*******************************************************************************
62 ********************************************************************************
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;
70 /* Singly Queue Structures - Queue Part */
71 typedef struct _QUE_T {
78 /*******************************************************************************
80 ********************************************************************************
83 /*******************************************************************************
84 * P R I V A T E D A T A
85 ********************************************************************************
88 /*******************************************************************************
90 ********************************************************************************
94 * To resolve compiler warning of address check -Waddress
95 * Redefine a ASSERT dedicate for queue operation
98 #define QUE_ASSERT ASSERT
100 #define QUE_ASSERT(_exp)
103 #define QUEUE_INITIALIZE(prQueue) \
105 (prQueue)->prHead = (P_QUE_ENTRY_T)NULL; \
106 (prQueue)->prTail = (P_QUE_ENTRY_T)NULL; \
107 (prQueue)->u4NumElem = 0; \
110 #define QUEUE_IS_EMPTY(prQueue) (((P_QUE_T)(prQueue))->prHead == (P_QUE_ENTRY_T)NULL)
112 #define QUEUE_IS_NOT_EMPTY(prQueue) ((prQueue)->u4NumElem > 0)
114 #define QUEUE_GET_HEAD(prQueue) ((prQueue)->prHead)
116 #define QUEUE_GET_TAIL(prQueue) ((prQueue)->prTail)
118 #define QUEUE_GET_NEXT_ENTRY(prQueueEntry) ((prQueueEntry)->prNext)
120 #define QUEUE_INSERT_HEAD(prQueue, prQueueEntry) \
122 QUE_ASSERT(prQueue); \
123 QUE_ASSERT(prQueueEntry); \
124 (prQueueEntry)->prNext = (prQueue)->prHead; \
125 (prQueue)->prHead = (prQueueEntry); \
126 if ((prQueue)->prTail == (P_QUE_ENTRY_T)NULL) { \
127 (prQueue)->prTail = (prQueueEntry); \
129 ((prQueue)->u4NumElem)++; \
132 #define QUEUE_INSERT_TAIL(prQueue, prQueueEntry) \
134 QUE_ASSERT(prQueue); \
135 QUE_ASSERT(prQueueEntry); \
136 (prQueueEntry)->prNext = (P_QUE_ENTRY_T)NULL; \
137 if ((prQueue)->prTail) { \
138 ((prQueue)->prTail)->prNext = (prQueueEntry); \
140 (prQueue)->prHead = (prQueueEntry); \
142 (prQueue)->prTail = (prQueueEntry); \
143 ((prQueue)->u4NumElem)++; \
146 /* NOTE: We assume the queue entry located at the beginning of "prQueueEntry Type",
147 * so that we can cast the queue entry to other data type without doubts.
148 * And this macro also decrease the total entry count at the same time.
150 #define QUEUE_REMOVE_HEAD(prQueue, prQueueEntry, _P_TYPE) \
152 QUE_ASSERT(prQueue); \
153 prQueueEntry = (_P_TYPE)((prQueue)->prHead); \
154 if (prQueueEntry) { \
155 (prQueue)->prHead = ((P_QUE_ENTRY_T)(prQueueEntry))->prNext; \
156 if ((prQueue)->prHead == (P_QUE_ENTRY_T)NULL){ \
157 (prQueue)->prTail = (P_QUE_ENTRY_T)NULL; \
159 ((P_QUE_ENTRY_T)(prQueueEntry))->prNext = (P_QUE_ENTRY_T)NULL; \
160 ((prQueue)->u4NumElem)--; \
164 #define QUEUE_MOVE_ALL(prDestQueue, prSrcQueue) \
166 QUE_ASSERT(prDestQueue); \
167 QUE_ASSERT(prSrcQueue); \
168 *(P_QUE_T)prDestQueue = *(P_QUE_T)prSrcQueue; \
169 QUEUE_INITIALIZE(prSrcQueue); \
172 #define QUEUE_CONCATENATE_QUEUES(prDestQueue, prSrcQueue) \
174 QUE_ASSERT(prDestQueue); \
175 QUE_ASSERT(prSrcQueue); \
176 if (prSrcQueue->u4NumElem > 0) { \
177 if ((prDestQueue)->prTail) { \
178 ((prDestQueue)->prTail)->prNext = (prSrcQueue)->prHead; \
180 (prDestQueue)->prHead = (prSrcQueue)->prHead; \
182 (prDestQueue)->prTail = (prSrcQueue)->prTail; \
183 ((prDestQueue)->u4NumElem) += ((prSrcQueue)->u4NumElem); \
184 QUEUE_INITIALIZE(prSrcQueue); \
189 /*******************************************************************************
190 * F U N C T I O N D E C L A R A T I O N S
191 ********************************************************************************
194 /*******************************************************************************
196 ********************************************************************************
199 #endif /* _QUEUE_H */