Commit | Line | Data |
---|---|---|
ecdfa446 GKH |
1 | #include "ieee80211.h" |
2 | #include <linux/etherdevice.h> | |
5a0e3ad6 | 3 | #include <linux/slab.h> |
ecdfa446 GKH |
4 | #include "rtl819x_TS.h" |
5 | ||
6 | #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) | |
7 | #define list_for_each_entry_safe(pos, n, head, member) \ | |
8 | for (pos = list_entry((head)->next, typeof(*pos), member), \ | |
9 | n = list_entry(pos->member.next, typeof(*pos), member); \ | |
10 | &pos->member != (head); \ | |
11 | pos = n, n = list_entry(n->member.next, typeof(*n), member)) | |
12 | #endif | |
13 | void TsSetupTimeOut(unsigned long data) | |
14 | { | |
15 | // Not implement yet | |
16 | // This is used for WMMSA and ACM , that would send ADDTSReq frame. | |
17 | } | |
18 | ||
19 | void TsInactTimeout(unsigned long data) | |
20 | { | |
21 | // Not implement yet | |
22 | // This is used for WMMSA and ACM. | |
23 | // This function would be call when TS is no Tx/Rx for some period of time. | |
24 | } | |
25 | ||
26 | /******************************************************************************************************************** | |
27 | *function: I still not understand this function, so wait for further implementation | |
28 | * input: unsigned long data //acturally we send TX_TS_RECORD or RX_TS_RECORD to these timer | |
29 | * return: NULL | |
30 | * notice: | |
31 | ********************************************************************************************************************/ | |
32 | #if 1 | |
33 | void RxPktPendingTimeout(unsigned long data) | |
34 | { | |
35 | PRX_TS_RECORD pRxTs = (PRX_TS_RECORD)data; | |
36 | struct ieee80211_device *ieee = container_of(pRxTs, struct ieee80211_device, RxTsRecord[pRxTs->num]); | |
37 | ||
38 | PRX_REORDER_ENTRY pReorderEntry = NULL; | |
39 | ||
40 | //u32 flags = 0; | |
41 | unsigned long flags = 0; | |
42 | struct ieee80211_rxb *stats_IndicateArray[REORDER_WIN_SIZE]; | |
43 | u8 index = 0; | |
44 | bool bPktInBuf = false; | |
45 | ||
46 | ||
47 | spin_lock_irqsave(&(ieee->reorder_spinlock), flags); | |
48 | //PlatformAcquireSpinLock(Adapter, RT_RX_SPINLOCK); | |
49 | IEEE80211_DEBUG(IEEE80211_DL_REORDER,"==================>%s()\n",__FUNCTION__); | |
50 | if(pRxTs->RxTimeoutIndicateSeq != 0xffff) | |
51 | { | |
52 | // Indicate the pending packets sequentially according to SeqNum until meet the gap. | |
53 | while(!list_empty(&pRxTs->RxPendingPktList)) | |
54 | { | |
55 | pReorderEntry = (PRX_REORDER_ENTRY)list_entry(pRxTs->RxPendingPktList.prev,RX_REORDER_ENTRY,List); | |
56 | if(index == 0) | |
57 | pRxTs->RxIndicateSeq = pReorderEntry->SeqNum; | |
58 | ||
59 | if( SN_LESS(pReorderEntry->SeqNum, pRxTs->RxIndicateSeq) || | |
60 | SN_EQUAL(pReorderEntry->SeqNum, pRxTs->RxIndicateSeq) ) | |
61 | { | |
62 | list_del_init(&pReorderEntry->List); | |
63 | ||
64 | if(SN_EQUAL(pReorderEntry->SeqNum, pRxTs->RxIndicateSeq)) | |
65 | pRxTs->RxIndicateSeq = (pRxTs->RxIndicateSeq + 1) % 4096; | |
66 | ||
67 | IEEE80211_DEBUG(IEEE80211_DL_REORDER,"RxPktPendingTimeout(): IndicateSeq: %d\n", pReorderEntry->SeqNum); | |
68 | stats_IndicateArray[index] = pReorderEntry->prxb; | |
69 | index++; | |
70 | ||
71 | list_add_tail(&pReorderEntry->List, &ieee->RxReorder_Unused_List); | |
72 | } | |
73 | else | |
74 | { | |
75 | bPktInBuf = true; | |
76 | break; | |
77 | } | |
78 | } | |
79 | } | |
80 | ||
81 | if(index>0) | |
82 | { | |
83 | // Set RxTimeoutIndicateSeq to 0xffff to indicate no pending packets in buffer now. | |
84 | pRxTs->RxTimeoutIndicateSeq = 0xffff; | |
85 | ||
86 | // Indicate packets | |
87 | if(index > REORDER_WIN_SIZE){ | |
88 | IEEE80211_DEBUG(IEEE80211_DL_ERR, "RxReorderIndicatePacket(): Rx Reorer buffer full!! \n"); | |
89 | spin_unlock_irqrestore(&(ieee->reorder_spinlock), flags); | |
90 | return; | |
91 | } | |
92 | ieee80211_indicate_packets(ieee, stats_IndicateArray, index); | |
93 | bPktInBuf = false; | |
94 | } | |
95 | ||
96 | if(bPktInBuf && (pRxTs->RxTimeoutIndicateSeq==0xffff)) | |
97 | { | |
98 | pRxTs->RxTimeoutIndicateSeq = pRxTs->RxIndicateSeq; | |
99 | #if 0 | |
100 | if(timer_pending(&pRxTs->RxPktPendingTimer)) | |
101 | del_timer_sync(&pRxTs->RxPktPendingTimer); | |
102 | pRxTs->RxPktPendingTimer.expires = jiffies + ieee->pHTInfo->RxReorderPendingTime; | |
103 | add_timer(&pRxTs->RxPktPendingTimer); | |
104 | #else | |
105 | mod_timer(&pRxTs->RxPktPendingTimer, jiffies + MSECS(ieee->pHTInfo->RxReorderPendingTime)); | |
106 | #endif | |
107 | } | |
108 | spin_unlock_irqrestore(&(ieee->reorder_spinlock), flags); | |
109 | //PlatformReleaseSpinLock(Adapter, RT_RX_SPINLOCK); | |
110 | } | |
111 | #endif | |
112 | ||
113 | /******************************************************************************************************************** | |
114 | *function: Add BA timer function | |
115 | * input: unsigned long data //acturally we send TX_TS_RECORD or RX_TS_RECORD to these timer | |
116 | * return: NULL | |
117 | * notice: | |
118 | ********************************************************************************************************************/ | |
119 | void TsAddBaProcess(unsigned long data) | |
120 | { | |
121 | PTX_TS_RECORD pTxTs = (PTX_TS_RECORD)data; | |
122 | u8 num = pTxTs->num; | |
123 | struct ieee80211_device *ieee = container_of(pTxTs, struct ieee80211_device, TxTsRecord[num]); | |
124 | ||
125 | TsInitAddBA(ieee, pTxTs, BA_POLICY_IMMEDIATE, false); | |
126 | IEEE80211_DEBUG(IEEE80211_DL_BA, "TsAddBaProcess(): ADDBA Req is started!! \n"); | |
127 | } | |
128 | ||
129 | ||
130 | void ResetTsCommonInfo(PTS_COMMON_INFO pTsCommonInfo) | |
131 | { | |
132 | memset(pTsCommonInfo->Addr, 0, 6); | |
133 | memset(&pTsCommonInfo->TSpec, 0, sizeof(TSPEC_BODY)); | |
134 | memset(&pTsCommonInfo->TClass, 0, sizeof(QOS_TCLAS)*TCLAS_NUM); | |
135 | pTsCommonInfo->TClasProc = 0; | |
136 | pTsCommonInfo->TClasNum = 0; | |
137 | } | |
138 | ||
139 | void ResetTxTsEntry(PTX_TS_RECORD pTS) | |
140 | { | |
141 | ResetTsCommonInfo(&pTS->TsCommonInfo); | |
142 | pTS->TxCurSeq = 0; | |
143 | pTS->bAddBaReqInProgress = false; | |
144 | pTS->bAddBaReqDelayed = false; | |
145 | pTS->bUsingBa = false; | |
146 | ResetBaEntry(&pTS->TxAdmittedBARecord); //For BA Originator | |
147 | ResetBaEntry(&pTS->TxPendingBARecord); | |
148 | } | |
149 | ||
150 | void ResetRxTsEntry(PRX_TS_RECORD pTS) | |
151 | { | |
152 | ResetTsCommonInfo(&pTS->TsCommonInfo); | |
153 | pTS->RxIndicateSeq = 0xffff; // This indicate the RxIndicateSeq is not used now!! | |
154 | pTS->RxTimeoutIndicateSeq = 0xffff; // This indicate the RxTimeoutIndicateSeq is not used now!! | |
155 | ResetBaEntry(&pTS->RxAdmittedBARecord); // For BA Recepient | |
156 | } | |
157 | ||
158 | void TSInitialize(struct ieee80211_device *ieee) | |
159 | { | |
160 | PTX_TS_RECORD pTxTS = ieee->TxTsRecord; | |
161 | PRX_TS_RECORD pRxTS = ieee->RxTsRecord; | |
162 | PRX_REORDER_ENTRY pRxReorderEntry = ieee->RxReorderEntry; | |
163 | u8 count = 0; | |
164 | IEEE80211_DEBUG(IEEE80211_DL_TS, "==========>%s()\n", __FUNCTION__); | |
165 | // Initialize Tx TS related info. | |
166 | INIT_LIST_HEAD(&ieee->Tx_TS_Admit_List); | |
167 | INIT_LIST_HEAD(&ieee->Tx_TS_Pending_List); | |
168 | INIT_LIST_HEAD(&ieee->Tx_TS_Unused_List); | |
169 | ||
170 | for(count = 0; count < TOTAL_TS_NUM; count++) | |
171 | { | |
172 | // | |
173 | pTxTS->num = count; | |
174 | // The timers for the operation of Traffic Stream and Block Ack. | |
175 | // DLS related timer will be add here in the future!! | |
176 | init_timer(&pTxTS->TsCommonInfo.SetupTimer); | |
177 | pTxTS->TsCommonInfo.SetupTimer.data = (unsigned long)pTxTS; | |
178 | pTxTS->TsCommonInfo.SetupTimer.function = TsSetupTimeOut; | |
179 | ||
180 | init_timer(&pTxTS->TsCommonInfo.InactTimer); | |
181 | pTxTS->TsCommonInfo.InactTimer.data = (unsigned long)pTxTS; | |
182 | pTxTS->TsCommonInfo.InactTimer.function = TsInactTimeout; | |
183 | ||
184 | init_timer(&pTxTS->TsAddBaTimer); | |
185 | pTxTS->TsAddBaTimer.data = (unsigned long)pTxTS; | |
186 | pTxTS->TsAddBaTimer.function = TsAddBaProcess; | |
187 | ||
188 | init_timer(&pTxTS->TxPendingBARecord.Timer); | |
189 | pTxTS->TxPendingBARecord.Timer.data = (unsigned long)pTxTS; | |
190 | pTxTS->TxPendingBARecord.Timer.function = BaSetupTimeOut; | |
191 | ||
192 | init_timer(&pTxTS->TxAdmittedBARecord.Timer); | |
193 | pTxTS->TxAdmittedBARecord.Timer.data = (unsigned long)pTxTS; | |
194 | pTxTS->TxAdmittedBARecord.Timer.function = TxBaInactTimeout; | |
195 | ||
196 | ResetTxTsEntry(pTxTS); | |
197 | list_add_tail(&pTxTS->TsCommonInfo.List, &ieee->Tx_TS_Unused_List); | |
198 | pTxTS++; | |
199 | } | |
200 | ||
201 | // Initialize Rx TS related info. | |
202 | INIT_LIST_HEAD(&ieee->Rx_TS_Admit_List); | |
203 | INIT_LIST_HEAD(&ieee->Rx_TS_Pending_List); | |
204 | INIT_LIST_HEAD(&ieee->Rx_TS_Unused_List); | |
205 | for(count = 0; count < TOTAL_TS_NUM; count++) | |
206 | { | |
207 | pRxTS->num = count; | |
208 | INIT_LIST_HEAD(&pRxTS->RxPendingPktList); | |
209 | ||
210 | init_timer(&pRxTS->TsCommonInfo.SetupTimer); | |
211 | pRxTS->TsCommonInfo.SetupTimer.data = (unsigned long)pRxTS; | |
212 | pRxTS->TsCommonInfo.SetupTimer.function = TsSetupTimeOut; | |
213 | ||
214 | init_timer(&pRxTS->TsCommonInfo.InactTimer); | |
215 | pRxTS->TsCommonInfo.InactTimer.data = (unsigned long)pRxTS; | |
216 | pRxTS->TsCommonInfo.InactTimer.function = TsInactTimeout; | |
217 | ||
218 | init_timer(&pRxTS->RxAdmittedBARecord.Timer); | |
219 | pRxTS->RxAdmittedBARecord.Timer.data = (unsigned long)pRxTS; | |
220 | pRxTS->RxAdmittedBARecord.Timer.function = RxBaInactTimeout; | |
221 | ||
222 | init_timer(&pRxTS->RxPktPendingTimer); | |
223 | pRxTS->RxPktPendingTimer.data = (unsigned long)pRxTS; | |
224 | pRxTS->RxPktPendingTimer.function = RxPktPendingTimeout; | |
225 | ||
226 | ResetRxTsEntry(pRxTS); | |
227 | list_add_tail(&pRxTS->TsCommonInfo.List, &ieee->Rx_TS_Unused_List); | |
228 | pRxTS++; | |
229 | } | |
230 | // Initialize unused Rx Reorder List. | |
231 | INIT_LIST_HEAD(&ieee->RxReorder_Unused_List); | |
232 | //#ifdef TO_DO_LIST | |
233 | for(count = 0; count < REORDER_ENTRY_NUM; count++) | |
234 | { | |
235 | list_add_tail( &pRxReorderEntry->List,&ieee->RxReorder_Unused_List); | |
236 | if(count == (REORDER_ENTRY_NUM-1)) | |
237 | break; | |
238 | pRxReorderEntry = &ieee->RxReorderEntry[count+1]; | |
239 | } | |
240 | //#endif | |
241 | ||
242 | } | |
243 | ||
244 | void AdmitTS(struct ieee80211_device *ieee, PTS_COMMON_INFO pTsCommonInfo, u32 InactTime) | |
245 | { | |
246 | del_timer_sync(&pTsCommonInfo->SetupTimer); | |
247 | del_timer_sync(&pTsCommonInfo->InactTimer); | |
248 | ||
249 | if(InactTime!=0) | |
250 | mod_timer(&pTsCommonInfo->InactTimer, jiffies + MSECS(InactTime)); | |
251 | } | |
252 | ||
253 | ||
254 | PTS_COMMON_INFO SearchAdmitTRStream(struct ieee80211_device *ieee, u8* Addr, u8 TID, TR_SELECT TxRxSelect) | |
255 | { | |
256 | //DIRECTION_VALUE dir; | |
257 | u8 dir; | |
258 | bool search_dir[4] = {0, 0, 0, 0}; | |
259 | struct list_head* psearch_list; //FIXME | |
260 | PTS_COMMON_INFO pRet = NULL; | |
261 | if(ieee->iw_mode == IW_MODE_MASTER) //ap mode | |
262 | { | |
263 | if(TxRxSelect == TX_DIR) | |
264 | { | |
265 | search_dir[DIR_DOWN] = true; | |
266 | search_dir[DIR_BI_DIR]= true; | |
267 | } | |
268 | else | |
269 | { | |
270 | search_dir[DIR_UP] = true; | |
271 | search_dir[DIR_BI_DIR]= true; | |
272 | } | |
273 | } | |
274 | else if(ieee->iw_mode == IW_MODE_ADHOC) | |
275 | { | |
276 | if(TxRxSelect == TX_DIR) | |
277 | search_dir[DIR_UP] = true; | |
278 | else | |
279 | search_dir[DIR_DOWN] = true; | |
280 | } | |
281 | else | |
282 | { | |
283 | if(TxRxSelect == TX_DIR) | |
284 | { | |
285 | search_dir[DIR_UP] = true; | |
286 | search_dir[DIR_BI_DIR]= true; | |
287 | search_dir[DIR_DIRECT]= true; | |
288 | } | |
289 | else | |
290 | { | |
291 | search_dir[DIR_DOWN] = true; | |
292 | search_dir[DIR_BI_DIR]= true; | |
293 | search_dir[DIR_DIRECT]= true; | |
294 | } | |
295 | } | |
296 | ||
297 | if(TxRxSelect == TX_DIR) | |
298 | psearch_list = &ieee->Tx_TS_Admit_List; | |
299 | else | |
300 | psearch_list = &ieee->Rx_TS_Admit_List; | |
301 | ||
302 | //for(dir = DIR_UP; dir <= DIR_BI_DIR; dir++) | |
303 | for(dir = 0; dir <= DIR_BI_DIR; dir++) | |
304 | { | |
305 | if(search_dir[dir] ==false ) | |
306 | continue; | |
307 | list_for_each_entry(pRet, psearch_list, List){ | |
0ee9f67c | 308 | // IEEE80211_DEBUG(IEEE80211_DL_TS, "ADD:%pM, TID:%d, dir:%d\n", pRet->Addr, pRet->TSpec.f.TSInfo.field.ucTSID, pRet->TSpec.f.TSInfo.field.ucDirection); |
ecdfa446 GKH |
309 | if (memcmp(pRet->Addr, Addr, 6) == 0) |
310 | if (pRet->TSpec.f.TSInfo.field.ucTSID == TID) | |
311 | if(pRet->TSpec.f.TSInfo.field.ucDirection == dir) | |
312 | { | |
313 | // printk("Bingo! got it\n"); | |
314 | break; | |
315 | } | |
316 | ||
317 | } | |
318 | if(&pRet->List != psearch_list) | |
319 | break; | |
320 | } | |
321 | ||
322 | if(&pRet->List != psearch_list){ | |
323 | return pRet ; | |
324 | } | |
325 | else | |
326 | return NULL; | |
327 | } | |
328 | ||
329 | void MakeTSEntry( | |
330 | PTS_COMMON_INFO pTsCommonInfo, | |
331 | u8* Addr, | |
332 | PTSPEC_BODY pTSPEC, | |
333 | PQOS_TCLAS pTCLAS, | |
334 | u8 TCLAS_Num, | |
335 | u8 TCLAS_Proc | |
336 | ) | |
337 | { | |
338 | u8 count; | |
339 | ||
340 | if(pTsCommonInfo == NULL) | |
341 | return; | |
342 | ||
343 | memcpy(pTsCommonInfo->Addr, Addr, 6); | |
344 | ||
345 | if(pTSPEC != NULL) | |
346 | memcpy((u8*)(&(pTsCommonInfo->TSpec)), (u8*)pTSPEC, sizeof(TSPEC_BODY)); | |
347 | ||
348 | for(count = 0; count < TCLAS_Num; count++) | |
349 | memcpy((u8*)(&(pTsCommonInfo->TClass[count])), (u8*)pTCLAS, sizeof(QOS_TCLAS)); | |
350 | ||
351 | pTsCommonInfo->TClasProc = TCLAS_Proc; | |
352 | pTsCommonInfo->TClasNum = TCLAS_Num; | |
353 | } | |
354 | ||
355 | ||
356 | bool GetTs( | |
357 | struct ieee80211_device* ieee, | |
358 | PTS_COMMON_INFO *ppTS, | |
359 | u8* Addr, | |
360 | u8 TID, | |
361 | TR_SELECT TxRxSelect, //Rx:1, Tx:0 | |
362 | bool bAddNewTs | |
363 | ) | |
364 | { | |
365 | u8 UP = 0; | |
366 | // | |
367 | // We do not build any TS for Broadcast or Multicast stream. | |
368 | // So reject these kinds of search here. | |
369 | // | |
370 | if(is_broadcast_ether_addr(Addr) || is_multicast_ether_addr(Addr)) | |
371 | { | |
372 | IEEE80211_DEBUG(IEEE80211_DL_ERR, "get TS for Broadcast or Multicast\n"); | |
373 | return false; | |
374 | } | |
375 | #if 0 | |
376 | if(ieee->pStaQos->CurrentQosMode == QOS_DISABLE) | |
377 | { UP = 0; } //only use one TS | |
378 | else if(ieee->pStaQos->CurrentQosMode & QOS_WMM) | |
379 | { | |
380 | #else | |
381 | if (ieee->current_network.qos_data.supported == 0) | |
382 | UP = 0; | |
383 | else | |
384 | { | |
385 | #endif | |
386 | // In WMM case: we use 4 TID only | |
387 | if (!IsACValid(TID)) | |
388 | { | |
389 | IEEE80211_DEBUG(IEEE80211_DL_ERR, " in %s(), TID(%d) is not valid\n", __FUNCTION__, TID); | |
390 | return false; | |
391 | } | |
392 | ||
393 | switch(TID) | |
394 | { | |
395 | case 0: | |
396 | case 3: | |
397 | UP = 0; | |
398 | break; | |
399 | ||
400 | case 1: | |
401 | case 2: | |
402 | UP = 2; | |
403 | break; | |
404 | ||
405 | case 4: | |
406 | case 5: | |
407 | UP = 5; | |
408 | break; | |
409 | ||
410 | case 6: | |
411 | case 7: | |
412 | UP = 7; | |
413 | break; | |
414 | } | |
415 | } | |
416 | ||
417 | *ppTS = SearchAdmitTRStream( | |
418 | ieee, | |
419 | Addr, | |
420 | UP, | |
421 | TxRxSelect); | |
422 | if(*ppTS != NULL) | |
423 | { | |
424 | return true; | |
425 | } | |
426 | else | |
427 | { | |
428 | if(bAddNewTs == false) | |
429 | { | |
430 | IEEE80211_DEBUG(IEEE80211_DL_TS, "add new TS failed(tid:%d)\n", UP); | |
431 | return false; | |
432 | } | |
433 | else | |
434 | { | |
435 | // | |
436 | // Create a new Traffic stream for current Tx/Rx | |
437 | // This is for EDCA and WMM to add a new TS. | |
438 | // For HCCA or WMMSA, TS cannot be addmit without negotiation. | |
439 | // | |
440 | TSPEC_BODY TSpec; | |
441 | PQOS_TSINFO pTSInfo = &TSpec.f.TSInfo; | |
442 | struct list_head* pUnusedList = | |
443 | (TxRxSelect == TX_DIR)? | |
444 | (&ieee->Tx_TS_Unused_List): | |
445 | (&ieee->Rx_TS_Unused_List); | |
446 | ||
447 | struct list_head* pAddmitList = | |
448 | (TxRxSelect == TX_DIR)? | |
449 | (&ieee->Tx_TS_Admit_List): | |
450 | (&ieee->Rx_TS_Admit_List); | |
451 | ||
452 | DIRECTION_VALUE Dir = (ieee->iw_mode == IW_MODE_MASTER)? | |
453 | ((TxRxSelect==TX_DIR)?DIR_DOWN:DIR_UP): | |
454 | ((TxRxSelect==TX_DIR)?DIR_UP:DIR_DOWN); | |
455 | IEEE80211_DEBUG(IEEE80211_DL_TS, "to add Ts\n"); | |
456 | if(!list_empty(pUnusedList)) | |
457 | { | |
458 | (*ppTS) = list_entry(pUnusedList->next, TS_COMMON_INFO, List); | |
459 | list_del_init(&(*ppTS)->List); | |
460 | if(TxRxSelect==TX_DIR) | |
461 | { | |
462 | PTX_TS_RECORD tmp = container_of(*ppTS, TX_TS_RECORD, TsCommonInfo); | |
463 | ResetTxTsEntry(tmp); | |
464 | } | |
465 | else{ | |
466 | PRX_TS_RECORD tmp = container_of(*ppTS, RX_TS_RECORD, TsCommonInfo); | |
467 | ResetRxTsEntry(tmp); | |
468 | } | |
469 | ||
0ee9f67c | 470 | IEEE80211_DEBUG(IEEE80211_DL_TS, "to init current TS, UP:%d, Dir:%d, addr:%pM\n", UP, Dir, Addr); |
ecdfa446 GKH |
471 | // Prepare TS Info releated field |
472 | pTSInfo->field.ucTrafficType = 0; // Traffic type: WMM is reserved in this field | |
473 | pTSInfo->field.ucTSID = UP; // TSID | |
474 | pTSInfo->field.ucDirection = Dir; // Direction: if there is DirectLink, this need additional consideration. | |
475 | pTSInfo->field.ucAccessPolicy = 1; // Access policy | |
476 | pTSInfo->field.ucAggregation = 0; // Aggregation | |
477 | pTSInfo->field.ucPSB = 0; // Aggregation | |
478 | pTSInfo->field.ucUP = UP; // User priority | |
479 | pTSInfo->field.ucTSInfoAckPolicy = 0; // Ack policy | |
480 | pTSInfo->field.ucSchedule = 0; // Schedule | |
481 | ||
482 | MakeTSEntry(*ppTS, Addr, &TSpec, NULL, 0, 0); | |
483 | AdmitTS(ieee, *ppTS, 0); | |
484 | list_add_tail(&((*ppTS)->List), pAddmitList); | |
485 | // if there is DirectLink, we need to do additional operation here!! | |
486 | ||
487 | return true; | |
488 | } | |
489 | else | |
490 | { | |
491 | IEEE80211_DEBUG(IEEE80211_DL_ERR, "in function %s() There is not enough TS record to be used!!", __FUNCTION__); | |
492 | return false; | |
493 | } | |
494 | } | |
495 | } | |
496 | } | |
497 | ||
498 | void RemoveTsEntry( | |
499 | struct ieee80211_device* ieee, | |
500 | PTS_COMMON_INFO pTs, | |
501 | TR_SELECT TxRxSelect | |
502 | ) | |
503 | { | |
504 | //u32 flags = 0; | |
505 | unsigned long flags = 0; | |
506 | del_timer_sync(&pTs->SetupTimer); | |
507 | del_timer_sync(&pTs->InactTimer); | |
508 | TsInitDelBA(ieee, pTs, TxRxSelect); | |
509 | ||
510 | if(TxRxSelect == RX_DIR) | |
511 | { | |
512 | //#ifdef TO_DO_LIST | |
513 | PRX_REORDER_ENTRY pRxReorderEntry; | |
514 | PRX_TS_RECORD pRxTS = (PRX_TS_RECORD)pTs; | |
515 | if(timer_pending(&pRxTS->RxPktPendingTimer)) | |
516 | del_timer_sync(&pRxTS->RxPktPendingTimer); | |
517 | ||
518 | while(!list_empty(&pRxTS->RxPendingPktList)) | |
519 | { | |
520 | // PlatformAcquireSpinLock(Adapter, RT_RX_SPINLOCK); | |
521 | spin_lock_irqsave(&(ieee->reorder_spinlock), flags); | |
522 | //pRxReorderEntry = list_entry(&pRxTS->RxPendingPktList.prev,RX_REORDER_ENTRY,List); | |
523 | pRxReorderEntry = (PRX_REORDER_ENTRY)list_entry(pRxTS->RxPendingPktList.prev,RX_REORDER_ENTRY,List); | |
524 | list_del_init(&pRxReorderEntry->List); | |
525 | { | |
526 | int i = 0; | |
527 | struct ieee80211_rxb * prxb = pRxReorderEntry->prxb; | |
528 | if (unlikely(!prxb)) | |
529 | { | |
530 | spin_unlock_irqrestore(&(ieee->reorder_spinlock), flags); | |
531 | return; | |
532 | } | |
533 | for(i =0; i < prxb->nr_subframes; i++) { | |
534 | dev_kfree_skb(prxb->subframes[i]); | |
535 | } | |
536 | kfree(prxb); | |
537 | prxb = NULL; | |
538 | } | |
539 | list_add_tail(&pRxReorderEntry->List,&ieee->RxReorder_Unused_List); | |
540 | //PlatformReleaseSpinLock(Adapter, RT_RX_SPINLOCK); | |
541 | spin_unlock_irqrestore(&(ieee->reorder_spinlock), flags); | |
542 | } | |
543 | ||
544 | //#endif | |
545 | } | |
546 | else | |
547 | { | |
548 | PTX_TS_RECORD pTxTS = (PTX_TS_RECORD)pTs; | |
549 | del_timer_sync(&pTxTS->TsAddBaTimer); | |
550 | } | |
551 | } | |
552 | ||
553 | void RemovePeerTS(struct ieee80211_device* ieee, u8* Addr) | |
554 | { | |
555 | PTS_COMMON_INFO pTS, pTmpTS; | |
0ee9f67c | 556 | printk("===========>RemovePeerTS,%pM\n", Addr); |
ecdfa446 GKH |
557 | #if 1 |
558 | list_for_each_entry_safe(pTS, pTmpTS, &ieee->Tx_TS_Pending_List, List) | |
559 | { | |
560 | if (memcmp(pTS->Addr, Addr, 6) == 0) | |
561 | { | |
562 | RemoveTsEntry(ieee, pTS, TX_DIR); | |
563 | list_del_init(&pTS->List); | |
564 | list_add_tail(&pTS->List, &ieee->Tx_TS_Unused_List); | |
565 | } | |
566 | } | |
567 | ||
568 | list_for_each_entry_safe(pTS, pTmpTS, &ieee->Tx_TS_Admit_List, List) | |
569 | { | |
570 | if (memcmp(pTS->Addr, Addr, 6) == 0) | |
571 | { | |
572 | printk("====>remove Tx_TS_admin_list\n"); | |
573 | RemoveTsEntry(ieee, pTS, TX_DIR); | |
574 | list_del_init(&pTS->List); | |
575 | list_add_tail(&pTS->List, &ieee->Tx_TS_Unused_List); | |
576 | } | |
577 | } | |
578 | ||
579 | list_for_each_entry_safe(pTS, pTmpTS, &ieee->Rx_TS_Pending_List, List) | |
580 | { | |
581 | if (memcmp(pTS->Addr, Addr, 6) == 0) | |
582 | { | |
583 | RemoveTsEntry(ieee, pTS, RX_DIR); | |
584 | list_del_init(&pTS->List); | |
585 | list_add_tail(&pTS->List, &ieee->Rx_TS_Unused_List); | |
586 | } | |
587 | } | |
588 | ||
589 | list_for_each_entry_safe(pTS, pTmpTS, &ieee->Rx_TS_Admit_List, List) | |
590 | { | |
591 | if (memcmp(pTS->Addr, Addr, 6) == 0) | |
592 | { | |
593 | RemoveTsEntry(ieee, pTS, RX_DIR); | |
594 | list_del_init(&pTS->List); | |
595 | list_add_tail(&pTS->List, &ieee->Rx_TS_Unused_List); | |
596 | } | |
597 | } | |
598 | #endif | |
599 | } | |
600 | ||
601 | void RemoveAllTS(struct ieee80211_device* ieee) | |
602 | { | |
603 | PTS_COMMON_INFO pTS, pTmpTS; | |
604 | #if 1 | |
605 | list_for_each_entry_safe(pTS, pTmpTS, &ieee->Tx_TS_Pending_List, List) | |
606 | { | |
607 | RemoveTsEntry(ieee, pTS, TX_DIR); | |
608 | list_del_init(&pTS->List); | |
609 | list_add_tail(&pTS->List, &ieee->Tx_TS_Unused_List); | |
610 | } | |
611 | ||
612 | list_for_each_entry_safe(pTS, pTmpTS, &ieee->Tx_TS_Admit_List, List) | |
613 | { | |
614 | RemoveTsEntry(ieee, pTS, TX_DIR); | |
615 | list_del_init(&pTS->List); | |
616 | list_add_tail(&pTS->List, &ieee->Tx_TS_Unused_List); | |
617 | } | |
618 | ||
619 | list_for_each_entry_safe(pTS, pTmpTS, &ieee->Rx_TS_Pending_List, List) | |
620 | { | |
621 | RemoveTsEntry(ieee, pTS, RX_DIR); | |
622 | list_del_init(&pTS->List); | |
623 | list_add_tail(&pTS->List, &ieee->Rx_TS_Unused_List); | |
624 | } | |
625 | ||
626 | list_for_each_entry_safe(pTS, pTmpTS, &ieee->Rx_TS_Admit_List, List) | |
627 | { | |
628 | RemoveTsEntry(ieee, pTS, RX_DIR); | |
629 | list_del_init(&pTS->List); | |
630 | list_add_tail(&pTS->List, &ieee->Rx_TS_Unused_List); | |
631 | } | |
632 | #endif | |
633 | } | |
634 | ||
635 | void TsStartAddBaProcess(struct ieee80211_device* ieee, PTX_TS_RECORD pTxTS) | |
636 | { | |
637 | if(pTxTS->bAddBaReqInProgress == false) | |
638 | { | |
639 | pTxTS->bAddBaReqInProgress = true; | |
640 | #if 1 | |
641 | if(pTxTS->bAddBaReqDelayed) | |
642 | { | |
643 | IEEE80211_DEBUG(IEEE80211_DL_BA, "TsStartAddBaProcess(): Delayed Start ADDBA after 60 sec!!\n"); | |
644 | mod_timer(&pTxTS->TsAddBaTimer, jiffies + MSECS(TS_ADDBA_DELAY)); | |
645 | } | |
646 | else | |
647 | { | |
648 | IEEE80211_DEBUG(IEEE80211_DL_BA,"TsStartAddBaProcess(): Immediately Start ADDBA now!!\n"); | |
649 | mod_timer(&pTxTS->TsAddBaTimer, jiffies+10); //set 10 ticks | |
650 | } | |
651 | #endif | |
652 | } | |
653 | else | |
654 | IEEE80211_DEBUG(IEEE80211_DL_ERR, "%s()==>BA timer is already added\n", __FUNCTION__); | |
655 | } | |
656 | #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) | |
657 | EXPORT_SYMBOL_NOVERS(RemovePeerTS); | |
658 | #else | |
659 | //EXPORT_SYMBOL(RemovePeerTS); | |
660 | #endif |