~ubuntu-branches/ubuntu/precise/linux-ti-omap4/precise

« back to all changes in this revision

Viewing changes to ubuntu/rtl8192se/rtllib/rtl819x_TSProc.c

  • Committer: Bazaar Package Importer
  • Author(s): Paolo Pisati
  • Date: 2011-06-29 15:23:51 UTC
  • mfrom: (26.1.1 natty-proposed)
  • Revision ID: james.westby@ubuntu.com-20110629152351-xs96tm303d95rpbk
Tags: 3.0.0-1200.2
* Rebased against 3.0.0-6.7
* BSP from TI based on 3.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/******************************************************************************
2
 
 * Copyright(c) 2008 - 2010 Realtek Corporation. All rights reserved.
3
 
 *
4
 
 * This program is distributed in the hope that it will be useful, but WITHOUT
5
 
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
6
 
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
7
 
 * more details.
8
 
 *
9
 
 * You should have received a copy of the GNU General Public License along with
10
 
 * this program; if not, write to the Free Software Foundation, Inc.,
11
 
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
12
 
 *
13
 
 * The full GNU General Public License is included in this distribution in the
14
 
 * file called LICENSE.
15
 
 *
16
 
 * Contact Information:
17
 
 * wlanfae <wlanfae@realtek.com>
18
 
******************************************************************************/
19
 
#include "rtllib.h"
20
 
#include <linux/etherdevice.h>
21
 
#include "rtl819x_TS.h"
22
 
extern void _setup_timer( struct timer_list*, void*, unsigned long);
23
 
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
24
 
#define list_for_each_entry_safe(pos, n, head, member) \
25
 
        for (pos = list_entry((head)->next, typeof(*pos), member), \
26
 
                n = list_entry(pos->member.next, typeof(*pos), member); \
27
 
                &pos->member != (head); \
28
 
                pos = n, n = list_entry(n->member.next, typeof(*n), member))
29
 
#endif
30
 
void TsSetupTimeOut(unsigned long data)
31
 
{
32
 
}
33
 
 
34
 
void TsInactTimeout(unsigned long data)
35
 
{
36
 
}
37
 
 
38
 
void RxPktPendingTimeout(unsigned long data)
39
 
{
40
 
        PRX_TS_RECORD   pRxTs = (PRX_TS_RECORD)data;
41
 
        struct rtllib_device *ieee = container_of(pRxTs, struct rtllib_device, RxTsRecord[pRxTs->num]);
42
 
        
43
 
        PRX_REORDER_ENTRY       pReorderEntry = NULL;
44
 
 
45
 
        unsigned long flags = 0;
46
 
        struct rtllib_rxb *stats_IndicateArray[REORDER_WIN_SIZE];
47
 
        u8 index = 0;
48
 
        bool bPktInBuf = false;
49
 
 
50
 
        spin_lock_irqsave(&(ieee->reorder_spinlock), flags);
51
 
        if(pRxTs->RxTimeoutIndicateSeq != 0xffff)
52
 
        {
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
 
                                RTLLIB_DEBUG(RTLLIB_DL_REORDER,"%s(): Indicate SeqNum: %d\n",__func__, 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
 
                pRxTs->RxTimeoutIndicateSeq = 0xffff;
83
 
        
84
 
                if(index > REORDER_WIN_SIZE){
85
 
                        RTLLIB_DEBUG(RTLLIB_DL_ERR, "RxReorderIndicatePacket(): Rx Reorer buffer full!! \n");
86
 
                        spin_unlock_irqrestore(&(ieee->reorder_spinlock), flags);
87
 
                        return;
88
 
                }
89
 
                rtllib_indicate_packets(ieee, stats_IndicateArray, index);
90
 
                bPktInBuf = false;
91
 
        }
92
 
 
93
 
        if(bPktInBuf && (pRxTs->RxTimeoutIndicateSeq==0xffff)){
94
 
                pRxTs->RxTimeoutIndicateSeq = pRxTs->RxIndicateSeq;
95
 
                mod_timer(&pRxTs->RxPktPendingTimer,  jiffies + MSECS(ieee->pHTInfo->RxReorderPendingTime));
96
 
        }
97
 
        spin_unlock_irqrestore(&(ieee->reorder_spinlock), flags);
98
 
}
99
 
 
100
 
void TsAddBaProcess(unsigned long data)
101
 
{
102
 
        PTX_TS_RECORD   pTxTs = (PTX_TS_RECORD)data;
103
 
        u8 num = pTxTs->num;
104
 
        struct rtllib_device *ieee = container_of(pTxTs, struct rtllib_device, TxTsRecord[num]);
105
 
 
106
 
        TsInitAddBA(ieee, pTxTs, BA_POLICY_IMMEDIATE, false);
107
 
        RTLLIB_DEBUG(RTLLIB_DL_BA, "TsAddBaProcess(): ADDBA Req is started!! \n");
108
 
}
109
 
 
110
 
 
111
 
void ResetTsCommonInfo(PTS_COMMON_INFO  pTsCommonInfo)
112
 
{
113
 
        memset(pTsCommonInfo->Addr, 0, 6);
114
 
        memset(&pTsCommonInfo->TSpec, 0, sizeof(TSPEC_BODY));
115
 
        memset(&pTsCommonInfo->TClass, 0, sizeof(QOS_TCLAS)*TCLAS_NUM);
116
 
        pTsCommonInfo->TClasProc = 0;
117
 
        pTsCommonInfo->TClasNum = 0;
118
 
}
119
 
 
120
 
void ResetTxTsEntry(PTX_TS_RECORD pTS)
121
 
{
122
 
        ResetTsCommonInfo(&pTS->TsCommonInfo);
123
 
        pTS->TxCurSeq = 0;
124
 
        pTS->bAddBaReqInProgress = false;
125
 
        pTS->bAddBaReqDelayed = false;
126
 
        pTS->bUsingBa = false;
127
 
        pTS->bDisable_AddBa = false;
128
 
        ResetBaEntry(&pTS->TxAdmittedBARecord); 
129
 
        ResetBaEntry(&pTS->TxPendingBARecord);
130
 
}
131
 
 
132
 
void ResetRxTsEntry(PRX_TS_RECORD pTS)
133
 
{
134
 
        ResetTsCommonInfo(&pTS->TsCommonInfo);
135
 
        pTS->RxIndicateSeq = 0xffff; 
136
 
        pTS->RxTimeoutIndicateSeq = 0xffff; 
137
 
        ResetBaEntry(&pTS->RxAdmittedBARecord);   
138
 
}
139
 
#ifdef _RTL8192_EXT_PATCH_
140
 
void ResetAdmitTRStream(struct rtllib_device *ieee, u8 *Addr)
141
 
{
142
 
        u8      dir;
143
 
        bool                            search_dir[4] = {0, 0, 0, 0};
144
 
        struct list_head*               psearch_list; 
145
 
        PTS_COMMON_INFO pRet = NULL;
146
 
        PRX_TS_RECORD pRxTS = NULL;
147
 
        PTX_TS_RECORD pTxTS = NULL;
148
 
 
149
 
        if(ieee->iw_mode != IW_MODE_MESH) 
150
 
                return;
151
 
 
152
 
        search_dir[DIR_DOWN]    = true;
153
 
        psearch_list = &ieee->Rx_TS_Admit_List;
154
 
        for(dir = 0; dir <= DIR_BI_DIR; dir++)
155
 
        {
156
 
                if(search_dir[dir] ==false )
157
 
                        continue;
158
 
                list_for_each_entry(pRet, psearch_list, List){
159
 
                        if ((memcmp(pRet->Addr, Addr, 6) == 0) && (pRet->TSpec.f.TSInfo.field.ucDirection == dir))
160
 
                        {
161
 
                                pRxTS = (PRX_TS_RECORD)pRet;
162
 
                                pRxTS->RxIndicateSeq = 0xffff;
163
 
                                pRxTS->RxTimeoutIndicateSeq = 0xffff;
164
 
                        }
165
 
                                        
166
 
                }       
167
 
        }
168
 
        search_dir[DIR_UP]      = true;
169
 
        psearch_list = &ieee->Tx_TS_Admit_List;
170
 
        for(dir = 0; dir <= DIR_BI_DIR; dir++)
171
 
        {
172
 
                if(search_dir[dir] ==false )
173
 
                        continue;
174
 
                list_for_each_entry(pRet, psearch_list, List){
175
 
                        if ((memcmp(pRet->Addr, Addr, 6) == 0) && (pRet->TSpec.f.TSInfo.field.ucDirection == dir))
176
 
                        {
177
 
                                pTxTS = (PTX_TS_RECORD)pRet;
178
 
                                pTxTS->TxCurSeq = 0xffff;
179
 
                        }
180
 
                                        
181
 
                }       
182
 
        }
183
 
 
184
 
        return;
185
 
}
186
 
#endif
187
 
 
188
 
void TSInitialize(struct rtllib_device *ieee)
189
 
{
190
 
        PTX_TS_RECORD           pTxTS  = ieee->TxTsRecord;
191
 
        PRX_TS_RECORD           pRxTS  = ieee->RxTsRecord;
192
 
        PRX_REORDER_ENTRY       pRxReorderEntry = ieee->RxReorderEntry;
193
 
        u8                              count = 0;
194
 
        RTLLIB_DEBUG(RTLLIB_DL_TS, "==========>%s()\n", __FUNCTION__);
195
 
        INIT_LIST_HEAD(&ieee->Tx_TS_Admit_List);
196
 
        INIT_LIST_HEAD(&ieee->Tx_TS_Pending_List);
197
 
        INIT_LIST_HEAD(&ieee->Tx_TS_Unused_List);
198
 
 
199
 
        for(count = 0; count < TOTAL_TS_NUM; count++)
200
 
        {
201
 
                pTxTS->num = count;
202
 
                _setup_timer(&pTxTS->TsCommonInfo.SetupTimer,
203
 
                            TsSetupTimeOut,
204
 
                            (unsigned long) pTxTS);
205
 
 
206
 
                _setup_timer(&pTxTS->TsCommonInfo.InactTimer,
207
 
                            TsInactTimeout,
208
 
                            (unsigned long) pTxTS);
209
 
 
210
 
                _setup_timer(&pTxTS->TsAddBaTimer,
211
 
                            TsAddBaProcess,
212
 
                            (unsigned long) pTxTS);
213
 
                
214
 
                _setup_timer(&pTxTS->TxPendingBARecord.Timer,
215
 
                            BaSetupTimeOut, 
216
 
                            (unsigned long) pTxTS);
217
 
                _setup_timer(&pTxTS->TxAdmittedBARecord.Timer,
218
 
                            TxBaInactTimeout,
219
 
                            (unsigned long) pTxTS);
220
 
                
221
 
                ResetTxTsEntry(pTxTS);
222
 
                list_add_tail(&pTxTS->TsCommonInfo.List, 
223
 
                                &ieee->Tx_TS_Unused_List); 
224
 
                pTxTS++;
225
 
        }
226
 
 
227
 
        INIT_LIST_HEAD(&ieee->Rx_TS_Admit_List);
228
 
        INIT_LIST_HEAD(&ieee->Rx_TS_Pending_List);
229
 
        INIT_LIST_HEAD(&ieee->Rx_TS_Unused_List);
230
 
        for(count = 0; count < TOTAL_TS_NUM; count++)
231
 
        {
232
 
                pRxTS->num = count;
233
 
                INIT_LIST_HEAD(&pRxTS->RxPendingPktList);
234
 
                
235
 
                _setup_timer(&pRxTS->TsCommonInfo.SetupTimer,
236
 
                            TsSetupTimeOut,
237
 
                            (unsigned long) pRxTS);
238
 
        
239
 
                _setup_timer(&pRxTS->TsCommonInfo.InactTimer,
240
 
                            TsInactTimeout,
241
 
                            (unsigned long) pRxTS);
242
 
 
243
 
                _setup_timer(&pRxTS->RxAdmittedBARecord.Timer,
244
 
                            RxBaInactTimeout,
245
 
                            (unsigned long) pRxTS);
246
 
                
247
 
                _setup_timer(&pRxTS->RxPktPendingTimer,
248
 
                            RxPktPendingTimeout,
249
 
                            (unsigned long) pRxTS);
250
 
                
251
 
                ResetRxTsEntry(pRxTS);
252
 
                list_add_tail(&pRxTS->TsCommonInfo.List, &ieee->Rx_TS_Unused_List);
253
 
                pRxTS++;
254
 
        }
255
 
        INIT_LIST_HEAD(&ieee->RxReorder_Unused_List);
256
 
        for(count = 0; count < REORDER_ENTRY_NUM; count++)
257
 
        {
258
 
                list_add_tail( &pRxReorderEntry->List,&ieee->RxReorder_Unused_List);
259
 
                if(count == (REORDER_ENTRY_NUM-1))
260
 
                        break;
261
 
                pRxReorderEntry = &ieee->RxReorderEntry[count+1];
262
 
        }
263
 
 
264
 
}
265
 
 
266
 
void AdmitTS(struct rtllib_device *ieee, PTS_COMMON_INFO pTsCommonInfo, u32 InactTime)
267
 
{
268
 
        del_timer_sync(&pTsCommonInfo->SetupTimer);
269
 
        del_timer_sync(&pTsCommonInfo->InactTimer);
270
 
 
271
 
        if(InactTime!=0)
272
 
                mod_timer(&pTsCommonInfo->InactTimer, jiffies + MSECS(InactTime));
273
 
}
274
 
 
275
 
 
276
 
PTS_COMMON_INFO SearchAdmitTRStream(struct rtllib_device *ieee, u8*     Addr, u8 TID, TR_SELECT TxRxSelect)
277
 
{
278
 
        u8      dir;
279
 
        bool                            search_dir[4] = {0, 0, 0, 0};
280
 
        struct list_head*               psearch_list; 
281
 
        PTS_COMMON_INFO pRet = NULL;
282
 
        if(ieee->iw_mode == IW_MODE_MASTER) 
283
 
        {
284
 
                if(TxRxSelect == TX_DIR)
285
 
                {
286
 
                        search_dir[DIR_DOWN] = true;
287
 
                        search_dir[DIR_BI_DIR]= true;
288
 
                }
289
 
                else
290
 
                {
291
 
                        search_dir[DIR_UP]      = true;
292
 
                        search_dir[DIR_BI_DIR]= true;
293
 
                }
294
 
        }
295
 
        else if(ieee->iw_mode == IW_MODE_ADHOC)
296
 
        {
297
 
                if(TxRxSelect == TX_DIR)
298
 
                        search_dir[DIR_UP]      = true;
299
 
                else
300
 
                        search_dir[DIR_DOWN] = true;
301
 
        }
302
 
        else
303
 
        {
304
 
                if(TxRxSelect == TX_DIR)
305
 
                {
306
 
                        search_dir[DIR_UP]      = true;
307
 
                        search_dir[DIR_BI_DIR]= true;
308
 
                        search_dir[DIR_DIRECT]= true;
309
 
                }
310
 
                else
311
 
                {
312
 
                        search_dir[DIR_DOWN] = true;
313
 
                        search_dir[DIR_BI_DIR]= true;
314
 
                        search_dir[DIR_DIRECT]= true;
315
 
                }
316
 
        }
317
 
 
318
 
        if(TxRxSelect == TX_DIR)
319
 
                psearch_list = &ieee->Tx_TS_Admit_List;
320
 
        else
321
 
                psearch_list = &ieee->Rx_TS_Admit_List;
322
 
        
323
 
        for(dir = 0; dir <= DIR_BI_DIR; dir++)
324
 
        {
325
 
                if(search_dir[dir] ==false )
326
 
                        continue;
327
 
                list_for_each_entry(pRet, psearch_list, List){
328
 
                        if (memcmp(pRet->Addr, Addr, 6) == 0)
329
 
                                if (pRet->TSpec.f.TSInfo.field.ucTSID == TID)
330
 
                                        if(pRet->TSpec.f.TSInfo.field.ucDirection == dir)
331
 
                                        {
332
 
                                                break;
333
 
                                        }
334
 
                                        
335
 
                }       
336
 
                if(&pRet->List  != psearch_list)
337
 
                        break;
338
 
        }
339
 
 
340
 
        if(&pRet->List  != psearch_list){
341
 
                return pRet ;
342
 
        }
343
 
        else 
344
 
                return NULL;
345
 
}
346
 
 
347
 
void MakeTSEntry(
348
 
                PTS_COMMON_INFO pTsCommonInfo,
349
 
                u8*             Addr,
350
 
                PTSPEC_BODY     pTSPEC,
351
 
                PQOS_TCLAS      pTCLAS,
352
 
                u8              TCLAS_Num,
353
 
                u8              TCLAS_Proc
354
 
        )
355
 
{
356
 
        u8      count;
357
 
 
358
 
        if(pTsCommonInfo == NULL)
359
 
                return;
360
 
        
361
 
        memcpy(pTsCommonInfo->Addr, Addr, 6);
362
 
 
363
 
        if(pTSPEC != NULL)
364
 
                memcpy((u8*)(&(pTsCommonInfo->TSpec)), (u8*)pTSPEC, sizeof(TSPEC_BODY));
365
 
 
366
 
        for(count = 0; count < TCLAS_Num; count++)
367
 
                memcpy((u8*)(&(pTsCommonInfo->TClass[count])), (u8*)pTCLAS, sizeof(QOS_TCLAS));
368
 
 
369
 
        pTsCommonInfo->TClasProc = TCLAS_Proc;
370
 
        pTsCommonInfo->TClasNum = TCLAS_Num;
371
 
}
372
 
 
373
 
#ifdef _RTL8192_EXT_PATCH_
374
 
void dump_ts_list(struct list_head * ts_list)
375
 
{
376
 
        PTS_COMMON_INFO pRet = NULL;
377
 
        u8 i=0;
378
 
        list_for_each_entry(pRet, ts_list, List){
379
 
                printk("i=%d ADD:"MAC_FMT", TID:%d, dir:%d\n",i,MAC_ARG(pRet->Addr), pRet->TSpec.f.TSInfo.field.ucTSID, pRet->TSpec.f.TSInfo.field.ucDirection);
380
 
                i++;
381
 
        }
382
 
        
383
 
}
384
 
#endif
385
 
 
386
 
bool GetTs(
387
 
        struct rtllib_device*   ieee,
388
 
        PTS_COMMON_INFO                 *ppTS,
389
 
        u8*                             Addr,
390
 
        u8                              TID,
391
 
        TR_SELECT                       TxRxSelect,  
392
 
        bool                            bAddNewTs
393
 
        )
394
 
{
395
 
        u8      UP = 0;
396
 
        if(is_broadcast_ether_addr(Addr) || is_multicast_ether_addr(Addr))
397
 
        {
398
 
                RTLLIB_DEBUG(RTLLIB_DL_ERR, "ERR! get TS for Broadcast or Multicast\n");
399
 
                return false;
400
 
        }
401
 
#if 0
402
 
        if(ieee->pStaQos->CurrentQosMode == QOS_DISABLE)
403
 
        {       UP = 0; } 
404
 
        else if(ieee->pStaQos->CurrentQosMode & QOS_WMM)
405
 
        {
406
 
#else
407
 
        if (ieee->current_network.qos_data.supported == 0)
408
 
                UP = 0;
409
 
        else
410
 
        {
411
 
#endif
412
 
                if (!IsACValid(TID))
413
 
                {
414
 
                        RTLLIB_DEBUG(RTLLIB_DL_ERR, "ERR! in %s(), TID(%d) is not valid\n", __FUNCTION__, TID);
415
 
                        return false;
416
 
                }
417
 
 
418
 
                switch(TID)
419
 
                {
420
 
                case 0:
421
 
                case 3:
422
 
                        UP = 0;
423
 
                        break;
424
 
 
425
 
                case 1:
426
 
                case 2:
427
 
                        UP = 2;
428
 
                        break;
429
 
                        
430
 
                case 4:
431
 
                case 5:
432
 
                        UP = 5;
433
 
                        break;
434
 
                        
435
 
                case 6:
436
 
                case 7:
437
 
                        UP = 7;
438
 
                        break;
439
 
                }
440
 
        }
441
 
 
442
 
        *ppTS = SearchAdmitTRStream(
443
 
                        ieee, 
444
 
                        Addr,
445
 
                        UP, 
446
 
                        TxRxSelect);
447
 
        if(*ppTS != NULL)
448
 
        {
449
 
                return true;
450
 
        }
451
 
        else
452
 
        {
453
 
                if(bAddNewTs == false)
454
 
                {
455
 
                        RTLLIB_DEBUG(RTLLIB_DL_TS, "add new TS failed(tid:%d)\n", UP);
456
 
                        return false;
457
 
                }
458
 
                else
459
 
                {
460
 
                        TSPEC_BODY      TSpec;
461
 
                        PQOS_TSINFO             pTSInfo = &TSpec.f.TSInfo;
462
 
                        struct list_head*       pUnusedList = 
463
 
                                                                (TxRxSelect == TX_DIR)?
464
 
                                                                (&ieee->Tx_TS_Unused_List):
465
 
                                                                (&ieee->Rx_TS_Unused_List);
466
 
                                                                
467
 
                        struct list_head*       pAddmitList = 
468
 
                                                                (TxRxSelect == TX_DIR)?
469
 
                                                                (&ieee->Tx_TS_Admit_List):
470
 
                                                                (&ieee->Rx_TS_Admit_List);
471
 
 
472
 
                        DIRECTION_VALUE         Dir =           (ieee->iw_mode == IW_MODE_MASTER)? 
473
 
                                                                ((TxRxSelect==TX_DIR)?DIR_DOWN:DIR_UP):
474
 
                                                                ((TxRxSelect==TX_DIR)?DIR_UP:DIR_DOWN);
475
 
                        RTLLIB_DEBUG(RTLLIB_DL_TS, "to add Ts\n");
476
 
                        if(!list_empty(pUnusedList))
477
 
                        {
478
 
                                (*ppTS) = list_entry(pUnusedList->next, TS_COMMON_INFO, List);
479
 
                                list_del_init(&(*ppTS)->List);  
480
 
                                if(TxRxSelect==TX_DIR)
481
 
                                {
482
 
                                        PTX_TS_RECORD tmp = container_of(*ppTS, TX_TS_RECORD, TsCommonInfo);
483
 
                                        ResetTxTsEntry(tmp);
484
 
                                }
485
 
                                else{
486
 
                                        PRX_TS_RECORD tmp = container_of(*ppTS, RX_TS_RECORD, TsCommonInfo);    
487
 
                                        ResetRxTsEntry(tmp);
488
 
                                }
489
 
                                
490
 
                                RTLLIB_DEBUG(RTLLIB_DL_TS, "to init current TS, UP:%d, Dir:%d, addr:"MAC_FMT" ppTs=%p\n", UP, Dir, MAC_ARG(Addr), *ppTS);
491
 
                                pTSInfo->field.ucTrafficType = 0;                       
492
 
                                pTSInfo->field.ucTSID = UP;                     
493
 
                                pTSInfo->field.ucDirection = Dir;                       
494
 
                                pTSInfo->field.ucAccessPolicy = 1;              
495
 
                                pTSInfo->field.ucAggregation = 0;               
496
 
                                pTSInfo->field.ucPSB = 0;                               
497
 
                                pTSInfo->field.ucUP = UP;                               
498
 
                                pTSInfo->field.ucTSInfoAckPolicy = 0;           
499
 
                                pTSInfo->field.ucSchedule = 0;                  
500
 
                                        
501
 
                                MakeTSEntry(*ppTS, Addr, &TSpec, NULL, 0, 0);
502
 
                                AdmitTS(ieee, *ppTS, 0);
503
 
                                list_add_tail(&((*ppTS)->List), pAddmitList);
504
 
 
505
 
                                return true;
506
 
                        }
507
 
                        else
508
 
                        {
509
 
                                RTLLIB_DEBUG(RTLLIB_DL_ERR, "ERR!!in function %s() There is not enough dir=%d(0=up down=1) TS record to be used!!", __FUNCTION__,Dir);
510
 
                                return false;
511
 
                        }               
512
 
                }               
513
 
        }
514
 
}
515
 
 
516
 
void RemoveTsEntry(
517
 
        struct rtllib_device*   ieee,
518
 
        PTS_COMMON_INFO                 pTs,
519
 
        TR_SELECT                       TxRxSelect
520
 
        )
521
 
{
522
 
        del_timer_sync(&pTs->SetupTimer);
523
 
        del_timer_sync(&pTs->InactTimer);
524
 
        TsInitDelBA(ieee, pTs, TxRxSelect);
525
 
 
526
 
        if(TxRxSelect == RX_DIR)
527
 
        {
528
 
                PRX_REORDER_ENTRY       pRxReorderEntry;
529
 
                PRX_TS_RECORD           pRxTS = (PRX_TS_RECORD)pTs;
530
 
 
531
 
                if(timer_pending(&pRxTS->RxPktPendingTimer))    
532
 
                        del_timer_sync(&pRxTS->RxPktPendingTimer);
533
 
 
534
 
                while(!list_empty(&pRxTS->RxPendingPktList)){
535
 
                        pRxReorderEntry = (PRX_REORDER_ENTRY)list_entry(pRxTS->RxPendingPktList.prev,RX_REORDER_ENTRY,List);
536
 
                        RTLLIB_DEBUG(RTLLIB_DL_REORDER,"%s(): Delete SeqNum %d!\n",__FUNCTION__, pRxReorderEntry->SeqNum);
537
 
                        list_del_init(&pRxReorderEntry->List);
538
 
                        {
539
 
                                int i = 0;
540
 
                                struct rtllib_rxb * prxb = pRxReorderEntry->prxb;
541
 
                                if (unlikely(!prxb)){
542
 
                                        return;
543
 
                                }
544
 
                                for(i =0; i < prxb->nr_subframes; i++) {
545
 
                                        dev_kfree_skb(prxb->subframes[i]);
546
 
                                }
547
 
                                kfree(prxb);
548
 
                                prxb = NULL;
549
 
                        }
550
 
                        list_add_tail(&pRxReorderEntry->List,&ieee->RxReorder_Unused_List);
551
 
                }
552
 
        }
553
 
        else{
554
 
                PTX_TS_RECORD pTxTS = (PTX_TS_RECORD)pTs;
555
 
                del_timer_sync(&pTxTS->TsAddBaTimer);
556
 
        }
557
 
}
558
 
 
559
 
void RemovePeerTS(struct rtllib_device* ieee, u8* Addr)
560
 
{
561
 
        PTS_COMMON_INFO pTS, pTmpTS;
562
 
        printk("===========>RemovePeerTS,"MAC_FMT"\n", MAC_ARG(Addr));
563
 
#if 1
564
 
        list_for_each_entry_safe(pTS, pTmpTS, &ieee->Tx_TS_Pending_List, List)
565
 
        {
566
 
                if (memcmp(pTS->Addr, Addr, 6) == 0)
567
 
                {
568
 
                        RemoveTsEntry(ieee, pTS, TX_DIR);
569
 
                        list_del_init(&pTS->List);
570
 
                        list_add_tail(&pTS->List, &ieee->Tx_TS_Unused_List);
571
 
                }
572
 
        }
573
 
        
574
 
        list_for_each_entry_safe(pTS, pTmpTS, &ieee->Tx_TS_Admit_List, List)
575
 
        {
576
 
                if (memcmp(pTS->Addr, Addr, 6) == 0)
577
 
                {
578
 
                        printk("====>remove Tx_TS_admin_list\n");
579
 
                        RemoveTsEntry(ieee, pTS, TX_DIR);
580
 
                        list_del_init(&pTS->List);
581
 
                        list_add_tail(&pTS->List, &ieee->Tx_TS_Unused_List);
582
 
                }
583
 
        }
584
 
        
585
 
        list_for_each_entry_safe(pTS, pTmpTS, &ieee->Rx_TS_Pending_List, List)
586
 
        {
587
 
                if (memcmp(pTS->Addr, Addr, 6) == 0)
588
 
                {
589
 
                        RemoveTsEntry(ieee, pTS, RX_DIR);
590
 
                        list_del_init(&pTS->List);
591
 
                        list_add_tail(&pTS->List, &ieee->Rx_TS_Unused_List);
592
 
                }
593
 
        }
594
 
 
595
 
        list_for_each_entry_safe(pTS, pTmpTS, &ieee->Rx_TS_Admit_List, List)
596
 
        {
597
 
                if (memcmp(pTS->Addr, Addr, 6) == 0)
598
 
                {
599
 
                        RemoveTsEntry(ieee, pTS, RX_DIR);
600
 
                        list_del_init(&pTS->List);
601
 
                        list_add_tail(&pTS->List, &ieee->Rx_TS_Unused_List);
602
 
                }
603
 
        }
604
 
#endif
605
 
}
606
 
 
607
 
void RemoveAllTS(struct rtllib_device* ieee)
608
 
{
609
 
        PTS_COMMON_INFO pTS, pTmpTS;
610
 
#if 1   
611
 
        list_for_each_entry_safe(pTS, pTmpTS, &ieee->Tx_TS_Pending_List, List)
612
 
        {
613
 
                RemoveTsEntry(ieee, pTS, TX_DIR);
614
 
                list_del_init(&pTS->List);
615
 
                list_add_tail(&pTS->List, &ieee->Tx_TS_Unused_List);    
616
 
        }
617
 
 
618
 
        list_for_each_entry_safe(pTS, pTmpTS, &ieee->Tx_TS_Admit_List, List)
619
 
        {
620
 
                RemoveTsEntry(ieee, pTS, TX_DIR);
621
 
                list_del_init(&pTS->List);
622
 
                list_add_tail(&pTS->List, &ieee->Tx_TS_Unused_List);
623
 
        }
624
 
        
625
 
        list_for_each_entry_safe(pTS, pTmpTS, &ieee->Rx_TS_Pending_List, List)
626
 
        {
627
 
                RemoveTsEntry(ieee, pTS, RX_DIR);
628
 
                list_del_init(&pTS->List);
629
 
                list_add_tail(&pTS->List, &ieee->Rx_TS_Unused_List);
630
 
        }
631
 
 
632
 
        list_for_each_entry_safe(pTS, pTmpTS, &ieee->Rx_TS_Admit_List, List)
633
 
        {
634
 
                RemoveTsEntry(ieee, pTS, RX_DIR);
635
 
                list_del_init(&pTS->List);
636
 
                list_add_tail(&pTS->List, &ieee->Rx_TS_Unused_List);
637
 
        }
638
 
#endif
639
 
}
640
 
 
641
 
void TsStartAddBaProcess(struct rtllib_device* ieee, PTX_TS_RECORD      pTxTS)
642
 
{
643
 
        if(pTxTS->bAddBaReqInProgress == false)
644
 
        {
645
 
                pTxTS->bAddBaReqInProgress = true;
646
 
#if 1
647
 
                if(pTxTS->bAddBaReqDelayed)
648
 
                {
649
 
                        RTLLIB_DEBUG(RTLLIB_DL_BA, "TsStartAddBaProcess(): Delayed Start ADDBA after 60 sec!!\n");
650
 
                        mod_timer(&pTxTS->TsAddBaTimer, jiffies + MSECS(TS_ADDBA_DELAY));
651
 
                }
652
 
                else
653
 
                {
654
 
                        RTLLIB_DEBUG(RTLLIB_DL_BA,"TsStartAddBaProcess(): Immediately Start ADDBA now!!\n");
655
 
                        mod_timer(&pTxTS->TsAddBaTimer, jiffies+10); 
656
 
                }
657
 
#endif
658
 
        }
659
 
        else
660
 
                RTLLIB_DEBUG(RTLLIB_DL_ERR, "%s()==>BA timer is already added\n", __FUNCTION__);
661
 
}
662
 
 
663
 
#ifndef BUILT_IN_RTLLIB
664
 
EXPORT_SYMBOL_RSL(RemovePeerTS);
665
 
#ifdef _RTL8192_EXT_PATCH_
666
 
EXPORT_SYMBOL_RSL(ResetAdmitTRStream);
667
 
#endif
668
 
#endif