add rk3288 pinctrl dts code
[firefly-linux-kernel-4.4.55.git] / drivers / net / wireless / combo_mt66xx / mt6628 / 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
93 /*
94   * To resolve compiler warning of address check -Waddress
95   * Redefine a ASSERT dedicate for queue operation 
96   */
97 #if DBG
98     #define QUE_ASSERT ASSERT
99 #else
100     #define QUE_ASSERT(_exp)
101 #endif
102
103 #define QUEUE_INITIALIZE(prQueue) \
104         { \
105             (prQueue)->prHead = (P_QUE_ENTRY_T)NULL; \
106             (prQueue)->prTail = (P_QUE_ENTRY_T)NULL; \
107             (prQueue)->u4NumElem = 0; \
108         }
109
110 #define QUEUE_IS_EMPTY(prQueue)             (((P_QUE_T)(prQueue))->prHead == (P_QUE_ENTRY_T)NULL)
111
112 #define QUEUE_IS_NOT_EMPTY(prQueue)         ((prQueue)->u4NumElem > 0)
113
114 #define QUEUE_GET_HEAD(prQueue)             ((prQueue)->prHead)
115
116 #define QUEUE_GET_TAIL(prQueue)             ((prQueue)->prTail)
117
118 #define QUEUE_GET_NEXT_ENTRY(prQueueEntry)  ((prQueueEntry)->prNext)
119
120 #define QUEUE_INSERT_HEAD(prQueue, prQueueEntry) \
121         { \
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); \
128             } \
129             ((prQueue)->u4NumElem)++; \
130         }
131
132 #define QUEUE_INSERT_TAIL(prQueue, prQueueEntry) \
133         { \
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); \
139             } else { \
140                 (prQueue)->prHead = (prQueueEntry); \
141             } \
142             (prQueue)->prTail = (prQueueEntry); \
143             ((prQueue)->u4NumElem)++; \
144         }
145
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.
149  */
150 #define QUEUE_REMOVE_HEAD(prQueue, prQueueEntry, _P_TYPE) \
151         { \
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; \
158                 } \
159                 ((P_QUE_ENTRY_T)(prQueueEntry))->prNext = (P_QUE_ENTRY_T)NULL; \
160                 ((prQueue)->u4NumElem)--; \
161             } \
162         }
163
164 #define QUEUE_MOVE_ALL(prDestQueue, prSrcQueue) \
165         { \
166             QUE_ASSERT(prDestQueue); \
167             QUE_ASSERT(prSrcQueue); \
168             *(P_QUE_T)prDestQueue = *(P_QUE_T)prSrcQueue; \
169             QUEUE_INITIALIZE(prSrcQueue); \
170         }
171
172 #define QUEUE_CONCATENATE_QUEUES(prDestQueue, prSrcQueue) \
173         { \
174             QUE_ASSERT(prDestQueue); \
175             QUE_ASSERT(prSrcQueue); \
176             if (prSrcQueue->u4NumElem > 0) { \
177                 if ((prDestQueue)->prTail) { \
178                     ((prDestQueue)->prTail)->prNext = (prSrcQueue)->prHead; \
179                 } else { \
180                     (prDestQueue)->prHead = (prSrcQueue)->prHead; \
181                 } \
182                 (prDestQueue)->prTail = (prSrcQueue)->prTail; \
183                 ((prDestQueue)->u4NumElem) += ((prSrcQueue)->u4NumElem); \
184                 QUEUE_INITIALIZE(prSrcQueue); \
185             } \
186         }
187
188
189 /*******************************************************************************
190 *                  F U N C T I O N   D E C L A R A T I O N S
191 ********************************************************************************
192 */
193
194 /*******************************************************************************
195 *                              F U N C T I O N S
196 ********************************************************************************
197 */
198
199 #endif /* _QUEUE_H */
200