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