5 #include <linux/vmalloc.h>
8 #define MAX_SIGNAL_NUM 64
10 SignalQ_t mgtQ
, txQ
, awakeQ
, psQ
[MAX_RECORD
];
11 SignalQ_t
*pMgtQ
= &mgtQ
, *pTxQ
, *pAwakeQ
, *pPsQ
[MAX_RECORD
];
13 Signal_t
*FreeSignalList
;
14 Signal_t
*SignalBuf
[MAX_SIGNAL_NUM
];
17 FrmDesc_t
*FreeFdescList
;
18 FrmDesc_t
*FdescBuf
[MAX_SIGNAL_NUM
];
19 U32 freeFdescCount
= MAX_SIGNAL_NUM
;
24 void initSigQue(SignalQ_t
*Q
)
28 flags
= pdot11Obj
->EnterCS();
32 pdot11Obj
->ExitCS(flags
);
35 void releaseSignalBuf(void)
39 for (i
=0; i
<MAX_SIGNAL_NUM
; i
++)
40 vfree((void *)SignalBuf
[i
]);
42 /* Point the the FreeSignalList to NULL */
43 FreeSignalList
= NULL
;
46 void initSignalBuf(void)
52 FreeSignalList
= NULL
;
53 freeSignalCount
= MAX_SIGNAL_NUM
;
55 for (i
=0; i
<MAX_SIGNAL_NUM
; i
++){
56 SignalBuf
[i
] = (Signal_t
*)vmalloc(sizeof(Signal_t
)); //can't use for DMA operation
59 FPRINT("80211: initSignalBuf failed");
60 //pdot11Obj->ExitCS(flags);
63 flags
= pdot11Obj
->EnterCS();
64 SignalBuf
[i
]->pNext
= FreeSignalList
;
65 FreeSignalList
= SignalBuf
[i
];
66 pdot11Obj
->ExitCS(flags
);
71 Signal_t
*allocSignal(void)
74 Signal_t
*signal
= NULL
;
76 flags
= pdot11Obj
->EnterCS();
77 if (FreeSignalList
!= NULL
){
78 signal
= FreeSignalList
;
79 FreeSignalList
= FreeSignalList
->pNext
;
82 signal
->frmInfo
.frmDesc
= NULL
;
86 pdot11Obj
->ExitCS(flags
);
90 void freeSignal(Signal_t
*signal
)
95 FPRINT("Free NULL signal");
99 flags
= pdot11Obj
->EnterCS();
103 signal
->frmInfo
.frmDesc
= NULL
;
104 signal
->pNext
= FreeSignalList
;
105 FreeSignalList
= signal
;
107 pdot11Obj
->ExitCS(flags
);
110 void re_initFdescBuf(void) {
112 for (i
=0; i
<MAX_SIGNAL_NUM
; i
++)
113 freeFdesc(FdescBuf
[i
]);
114 freeFdescCount
= MAX_SIGNAL_NUM
;
118 void initFdescBuf(void)
122 //FrmDesc_t *pFrmDesc;
124 flags
= pdot11Obj
->EnterCS();
125 FreeFdescList
= NULL
;
127 for (i
=0; i
<MAX_SIGNAL_NUM
; i
++){
128 FdescBuf
[i
] = (FrmDesc_t
*) kmalloc(sizeof (FrmDesc_t
), GFP_ATOMIC
); //may use for DMA operation
131 FPRINT("80211: initFdescBuf failed");
132 pdot11Obj
->ExitCS(flags
);
136 FdescBuf
[i
]->pNext
= FreeFdescList
;
137 FreeFdescList
= FdescBuf
[i
];
141 FPRINT_V("FreeFdescList", FreeFdescList
);
142 pFrmDesc
= FreeFdescList
;
143 for (i
=0; i
<MAX_SIGNAL_NUM
; i
++){
144 FPRINT_V("pFrmDesc", pFrmDesc
);
145 FPRINT_V("pFrmDesc->pNext", pFrmDesc
->pNext
);
146 pFrmDesc
= pFrmDesc
->pNext
;
150 pdot11Obj
->ExitCS(flags
);
154 void releaseFdescBuf(void)
158 for (i
=0; i
<MAX_SIGNAL_NUM
; i
++)
159 kfree((void *)FdescBuf
[i
]);
161 /* Point the the FreeFdescList to NULL */
162 FreeFdescList
= NULL
;
166 FrmDesc_t
*allocFdesc(void)
169 FrmDesc_t
*pfrmDesc
= NULL
;
171 flags
= pdot11Obj
->EnterCS();
173 if (FreeFdescList
!= NULL
){
174 pfrmDesc
= FreeFdescList
;
175 FreeFdescList
= FreeFdescList
->pNext
;
176 //memset(pfrmDesc,0,sizeof(FrmDesc_t));
177 //memset(pfrmDesc->mpdu,0,sizeof(Frame_t)*MAX_FRAG_NUM);
178 pfrmDesc
->pNext
= NULL
;
179 pfrmDesc
->ConfigSet
= 0;
180 //pfrmDesc->bDataFrm = 0;
181 pfrmDesc
->pHash
= NULL
;
182 pfrmDesc
->bValid
= TRUE
;
183 memset(pfrmDesc
->CalMIC
,0,sizeof(pfrmDesc
->CalMIC
));
187 if (FreeFdescList
== NULL
){
188 FPRINT("FreeFdescList == NULL");
189 FPRINT_V("freeFdescCount", (U32
)freeFdescCount
);
190 FPRINT_V("Cnt of MgtQ", pMgtQ
->cnt
);
194 pdot11Obj
->ExitCS(flags
);
195 //FPRINT_V("alloc pfrmDesc", (U32)pfrmDesc);
196 //FPRINT_V("FreeFdescList", (U32)FreeFdescList);
202 void freeFdesc(FrmDesc_t
*pfrmDesc
)
205 FrmDesc_t
*pOldFdesc
;
208 FPRINT("Free NULL pfrmDesc");
212 flags
= pdot11Obj
->EnterCS();
214 if (!pfrmDesc
->bValid
){
215 FPRINT_V("pfrmDesc->bValid", pfrmDesc
->bValid
);
216 pdot11Obj
->ExitCS(flags
);
221 //FPRINT_V("FreeFdescList", (U32)FreeFdescList);
222 pOldFdesc
= FreeFdescList
;
223 pfrmDesc
->ConfigSet
= 0;
224 //pfrmDesc->bDataFrm = 0;
225 pfrmDesc
->pHash
= NULL
;
226 pfrmDesc
->pNext
= FreeFdescList
;
227 FreeFdescList
= pfrmDesc
;
228 pfrmDesc
->bValid
= FALSE
;
231 //FPRINT_V("free pfrmDesc", (U32)pfrmDesc);
234 if (FreeFdescList
== 0){
235 FPRINT("xxxxxxxxxx");
236 FPRINT_V("free pfrmDesc", (U32
)pfrmDesc
);
237 FPRINT_V("freeFdescCount", (U32
)freeFdescCount
);
240 if (pfrmDesc
== pfrmDesc
->pNext
){
241 FPRINT("ooooooooooo");
242 FPRINT_V("pOldFdesc", (U32
)pOldFdesc
);
243 FPRINT_V("free pfrmDesc", (U32
)pfrmDesc
);
244 FPRINT_V("freeFdescCount", (U32
)freeFdescCount
);
247 pdot11Obj
->ExitCS(flags
);
251 Signal_t
*sigDeque(SignalQ_t
*Q
)
254 Signal_t
*signal
= NULL
;
256 flags
= pdot11Obj
->EnterCS();
257 if (Q
->first
!= NULL
){
260 Q
->first
= (Q
->first
)->pNext
;
261 if (Q
->first
== NULL
)
264 pdot11Obj
->ExitCS(flags
);
269 void sigEnque(SignalQ_t
*Q
, Signal_t
*signal
)
273 flags
= pdot11Obj
->EnterCS();
274 signal
->pNext
= NULL
;
275 if (Q
->last
== NULL
){
280 Q
->last
->pNext
= signal
;
286 pdot11Obj
->QueueFlag
|= MGT_QUEUE_SET
;
288 pdot11Obj
->QueueFlag
|= TX_QUEUE_SET
;
289 else if (Q
== pAwakeQ
)
290 pdot11Obj
->QueueFlag
|= AWAKE_QUEUE_SET
;
292 pdot11Obj
->ExitCS(flags
);
296 void sigEnqueFirst(SignalQ_t
*Q
, Signal_t
*signal
)
300 FPRINT("sigEnqueFirst");
302 i_state
= pdot11Obj
->EnterCS();
303 signal
->pNext
= Q
->first
;
305 if (Q
->last
== NULL
){
312 pdot11Obj
->ExitCS(i_state
);