TWD/Data_Service/RxQueue.c
changeset 0 10c42ec6c05f
equal deleted inserted replaced
-1:000000000000 0:10c42ec6c05f
       
     1 /*
       
     2  * RxQueue.c
       
     3  *
       
     4  * Copyright(c) 1998 - 2010 Texas Instruments. All rights reserved.      
       
     5  * All rights reserved.      
       
     6  * 
       
     7  * This program and the accompanying materials are made available under the 
       
     8  * terms of the Eclipse Public License v1.0 or BSD License which accompanies
       
     9  * this distribution. The Eclipse Public License is available at
       
    10  * http://www.eclipse.org/legal/epl-v10.html and the BSD License is as below.                                   
       
    11  *                                                                       
       
    12  * Redistribution and use in source and binary forms, with or without    
       
    13  * modification, are permitted provided that the following conditions    
       
    14  * are met:                                                              
       
    15  *                                                                       
       
    16  *  * Redistributions of source code must retain the above copyright     
       
    17  *    notice, this list of conditions and the following disclaimer.      
       
    18  *  * Redistributions in binary form must reproduce the above copyright  
       
    19  *    notice, this list of conditions and the following disclaimer in    
       
    20  *    the documentation and/or other materials provided with the         
       
    21  *    distribution.                                                      
       
    22  *  * Neither the name Texas Instruments nor the names of its            
       
    23  *    contributors may be used to endorse or promote products derived    
       
    24  *    from this software without specific prior written permission.      
       
    25  *                                                                       
       
    26  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS   
       
    27  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT     
       
    28  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 
       
    29  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT  
       
    30  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
       
    31  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT      
       
    32  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 
       
    33  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 
       
    34  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT   
       
    35  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
       
    36  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
       
    37  */
       
    38 
       
    39 
       
    40 /** \file   RxQueue.c 
       
    41  *  \brief  RX Queue module that responsible to support re-ordering of received packets to upper layers.
       
    42  *  
       
    43  *  \see    RxQueue.h
       
    44  */
       
    45 #define __FILE_ID__  FILE_ID_98
       
    46 #include "tidef.h"
       
    47 #include "osApi.h"
       
    48 #include "report.h" 
       
    49 #include "RxBuf.h"
       
    50 #include "TWDriver.h"
       
    51 #include "public_descriptors.h"
       
    52 
       
    53 /************************ static definition declaration *****************************/
       
    54 #define RX_QUEUE_ARRAY_SIZE		                            8
       
    55 #define RX_QUEUE_ARRAY_SIZE_BIT_MASK                        0x7 /* RX_QUEUE_ARRAY_SIZE -1 */
       
    56 #define RX_QUEUE_WIN_SIZE		                            RX_QUEUE_ARRAY_SIZE
       
    57 
       
    58 /*
       
    59  *explanation for this MACRO - it protects against wrap around
       
    60  * 
       
    61  *  if A = 0x0001   &   B = 0xFFFF  
       
    62  * 
       
    63  *                  (int16)(0x0001 - 0xFFFF) = 2 --> A > B
       
    64  */ 
       
    65 #define A_GREATER_THAN_B(A, B) ( (TI_INT16)( (TI_UINT16)A - (TI_UINT16)B) > 0)
       
    66 #define BA_SESSION_IS_A_BIGGER_THAN_B(A,B)       (((((A)-(B)) & 0xFFF) < 0x7FF) && ((A)!=(B)))
       
    67 #define BA_SESSION_IS_A_BIGGER_EQUAL_THAN_B(A,B) (((((A)-(B)) & 0xFFF) < 0x7FF))
       
    68 #define SEQ_NUM_WRAP 0x1000
       
    69 #define SEQ_NUM_MASK 0xFFF
       
    70 
       
    71 
       
    72 /************************ static structures declaration *****************************/
       
    73 /* structure describe one entry of save packet information in the packet queue array */
       
    74 typedef struct 
       
    75 {
       
    76     void                *pPacket;	/* Packet address of the packet */
       
    77     TI_STATUS	        tStatus;	/* RxXfer status. */
       
    78     TI_UINT16           uFrameSn;
       
    79 } TRxQueuePacketEntry;	
       
    80 
       
    81 /* structure describe set of data that one Tid, also including the arras himself */
       
    82 typedef struct 
       
    83 {
       
    84     /* array packets Entries */
       
    85     TRxQueuePacketEntry aPaketsQueue [RX_QUEUE_ARRAY_SIZE];	
       
    86     /* TID BA state */
       
    87     TI_BOOL	            aTidBaEstablished;	              
       
    88     /* index that winStar point on */
       
    89     TI_UINT32 	        aWinStartArrayInex;	                    
       
    90     /* windows size */
       
    91     TI_UINT32	        aTidWinSize;
       
    92 	/* expected sequence number (ESN) */ 
       
    93     TI_UINT16	        aTidExpectedSn;
       
    94 } TRxQueueTidDataBase;	
       
    95 
       
    96 /* structure describe set of data that assist of manage one SA RxQueue arrays */
       
    97 typedef struct 
       
    98 {
       
    99     TRxQueueTidDataBase tSa1ArrayMng [MAX_NUM_OF_802_1d_TAGS];
       
   100 } TRxQueueArraysMng;	
       
   101 
       
   102 /* main RxQueue structure in order to management the packets disordered array. */
       
   103 typedef struct 
       
   104 {
       
   105     TI_HANDLE           hOs;                        /* OS handler */
       
   106     TI_HANDLE           hReport;                    /* Report handler */
       
   107     TRxQueueArraysMng   tRxQueueArraysMng;          /* manage each Source Address RxQueue arrays */
       
   108     TPacketReceiveCb    tReceivePacketCB;           /* Receive packets CB address */
       
   109     TI_HANDLE           hReceivePacketCB_handle;    /* Receive packets CB handler */
       
   110 
       
   111 } TRxQueue;	
       
   112 
       
   113 /************************ static function declaration *****************************/
       
   114 static TI_STATUS RxQueue_PassPacket (TI_HANDLE hRxQueue, TI_STATUS tStatus, const void *pBuffer);
       
   115 
       
   116 /** 
       
   117  * \fn     RxQueue_Create() 
       
   118  * \brief  Create the RxQueue module.
       
   119  * 
       
   120  * Allocate and clear the RxQueue module object.
       
   121  * 
       
   122  * \param  hOs - Handle to Os Abstraction Layer
       
   123  * \return Handle of the allocated object 
       
   124  * \sa     RxQueue_Destroy
       
   125  */ 
       
   126 TI_HANDLE RxQueue_Create (TI_HANDLE hOs)
       
   127 {
       
   128 	TRxQueue *pRxQueue;
       
   129 
       
   130 	/* allocate module object */
       
   131 	pRxQueue = os_memoryAlloc (hOs, sizeof(TRxQueue),MemoryNormal);
       
   132 	
       
   133 	if (!pRxQueue)
       
   134 	{
       
   135 		WLAN_OS_REPORT (("RxQueue_Create():  Allocation failed!!\n"));
       
   136 		return NULL;
       
   137 	}
       
   138 	
       
   139     os_memoryZero (hOs, pRxQueue, (sizeof(TRxQueue)));
       
   140 
       
   141     pRxQueue->hOs = hOs;
       
   142 
       
   143 	return (pRxQueue);
       
   144 }
       
   145 
       
   146 
       
   147 /** 
       
   148  * \fn     RxQueue_Destroy()
       
   149  * \brief  Destroy the module. 
       
   150  * 
       
   151  * Free the module's queues and object.
       
   152  * 
       
   153  * \param  hRxQueue - The module object
       
   154  * \return TI_OK on success or TI_NOK on failure 
       
   155  * \sa     RxQueue_Create
       
   156  */ 
       
   157 TI_STATUS RxQueue_Destroy (TI_HANDLE hRxQueue)
       
   158 {
       
   159     TRxQueue *pRxQueue = (TRxQueue *)hRxQueue;
       
   160 
       
   161     /* free module object */
       
   162 	os_memoryFree (pRxQueue->hOs, pRxQueue, sizeof(TRxQueue));
       
   163 	
       
   164     return TI_OK;
       
   165 }
       
   166 
       
   167 
       
   168 /** 
       
   169  * \fn     RxQueue_Init() 
       
   170  * \brief  Init required handles 
       
   171  * 
       
   172  * Init required handles and module variables.
       
   173  * 
       
   174  * \note    
       
   175  * \param  hRxQueue - The module object
       
   176  * \param  hReport - Report module Handles
       
   177  * \return TI_OK on success or TI_NOK on failure  
       
   178  * \sa     
       
   179  */ 
       
   180 TI_STATUS RxQueue_Init (TI_HANDLE hRxQueue, TI_HANDLE hReport)
       
   181 {
       
   182 	TRxQueue *pRxQueue = (TRxQueue *)hRxQueue;
       
   183     
       
   184     pRxQueue->hReport   = hReport;
       
   185     
       
   186 	return TI_OK;
       
   187 }
       
   188 
       
   189 
       
   190 /** 
       
   191  * \fn     RxQueue_Register_CB()
       
   192  * \brief  Register the function to be called for received Rx.
       
   193  * 
       
   194  * \note   
       
   195  * \param  hRxQueue - The module object
       
   196  * \param  CallBackID - event ID
       
   197  * \param  CBFunc - function address.
       
   198  * \param  CBObj - function parameter.
       
   199  * \return TI_OK on success or TI_NOK on failure 
       
   200  * \sa     
       
   201  */ 
       
   202 void RxQueue_Register_CB (TI_HANDLE hRxQueue, TI_UINT32 uCallBackID, void *CBFunc, TI_HANDLE CBObj)
       
   203 {
       
   204     TRxQueue* pRxQueue = (TRxQueue *)hRxQueue;
       
   205 
       
   206     TRACE1(pRxQueue->hReport, REPORT_SEVERITY_INFORMATION , "RxQueue_Register_CB: CallBack ID = 0x%x\n", uCallBackID);
       
   207 
       
   208     switch(uCallBackID)
       
   209     {
       
   210     case TWD_INT_RECEIVE_PACKET:
       
   211         pRxQueue->tReceivePacketCB = (TPacketReceiveCb)CBFunc;
       
   212         pRxQueue->hReceivePacketCB_handle = CBObj;
       
   213         break;
       
   214 
       
   215     default:
       
   216         TRACE0(pRxQueue->hReport, REPORT_SEVERITY_ERROR , "RxQueue_Register_CB: Illegal value\n");
       
   217         break;
       
   218     }
       
   219 }
       
   220 
       
   221 /** 
       
   222  * \fn     RxQueue_CloseBaSession ()
       
   223  * \brief  Close BA session receiver and pass all packets in the TID queue to upper layer.
       
   224  *
       
   225  * \note   
       
   226  * \param  hRxQueue - RxQueue handle.
       
   227  * \param  uFrameTid - TID session.
       
   228  * \return None 
       
   229  * \sa     
       
   230  */ 
       
   231 void RxQueue_CloseBaSession(TI_HANDLE hRxQueue, TI_UINT8 uFrameTid)
       
   232 {
       
   233     TRxQueue            *pRxQueue     = (TRxQueue *)hRxQueue;
       
   234     TI_UINT32            i;
       
   235     /*set the SA Tid pointer */
       
   236     TRxQueueTidDataBase *pTidDataBase = &(pRxQueue->tRxQueueArraysMng.tSa1ArrayMng[uFrameTid]);
       
   237     
       
   238     /* TID illegal value ? */
       
   239     if (uFrameTid >= MAX_NUM_OF_802_1d_TAGS)
       
   240     {
       
   241         TRACE1(pRxQueue->hReport, REPORT_SEVERITY_ERROR , "RxQueue_CloseBaSession: BA event - DELBA frame with TID value too big, TID = %d\n", uFrameTid);
       
   242         
       
   243         return;
       
   244     }
       
   245 
       
   246     if(pTidDataBase->aTidBaEstablished == TI_TRUE)
       
   247     {
       
   248         /* clean BA session */
       
   249         pTidDataBase->aTidBaEstablished = TI_FALSE;
       
   250 
       
   251         /* pass all valid entries at the array */ 
       
   252         for (i = 0; (i < RX_QUEUE_ARRAY_SIZE) && (i < RX_QUEUE_WIN_SIZE); i++)
       
   253         {
       
   254             if (pTidDataBase->aPaketsQueue[pTidDataBase->aWinStartArrayInex].pPacket != NULL)
       
   255             {
       
   256                 RxQueue_PassPacket (pRxQueue, 
       
   257                                     pTidDataBase->aPaketsQueue[pTidDataBase->aWinStartArrayInex].tStatus,
       
   258                                     pTidDataBase->aPaketsQueue[pTidDataBase->aWinStartArrayInex].pPacket);
       
   259 
       
   260                 pTidDataBase->aPaketsQueue[pTidDataBase->aWinStartArrayInex].pPacket = NULL;
       
   261             }
       
   262 
       
   263             pTidDataBase->aWinStartArrayInex ++;
       
   264 
       
   265             /* aWinStartArrayInex % RX_QUEUE_ARRAY_SIZE */
       
   266             pTidDataBase->aWinStartArrayInex &= RX_QUEUE_ARRAY_SIZE_BIT_MASK;
       
   267         }
       
   268     }
       
   269 }
       
   270 
       
   271 
       
   272 /** 
       
   273  * \fn     RxQueue_PassPacket()
       
   274  * \brief  Responsible on decode packet parameters and pass it to upper layer.
       
   275  *
       
   276  * \note   
       
   277  * \param  hRxQueue - RxQueue handle.
       
   278  * \param  aStatus - RxXfer status that indicate if the upper layer should free the packet or use it.
       
   279  * \param  pFrame - paket address of the packet
       
   280  * \param  pRxParams - address to structure of the Rx Descriptor received by FW.
       
   281  * \return TI_OK on success or TI_NOK on failure 
       
   282  * \sa     
       
   283  */ 
       
   284 static TI_STATUS RxQueue_PassPacket (TI_HANDLE hRxQueue, TI_STATUS tStatus, const void *pBuffer)
       
   285 {
       
   286 
       
   287     TRxQueue            *pRxQueue   = (TRxQueue *)hRxQueue;
       
   288 
       
   289     if (tStatus == TI_OK)
       
   290     {
       
   291         /* Get the mac header location in the packet Buffer */
       
   292         dot11_header_t *pMacHdr = (dot11_header_t *)(TI_UINT8*)RX_BUF_DATA(pBuffer);
       
   293 
       
   294         /* Handle endian for the frame control fields */
       
   295         pMacHdr->fc  = ENDIAN_HANDLE_WORD(pMacHdr->fc);
       
   296         pMacHdr->duration = ENDIAN_HANDLE_WORD(pMacHdr->duration);
       
   297         pMacHdr->seqCtrl = ENDIAN_HANDLE_WORD(pMacHdr->seqCtrl);
       
   298     }
       
   299     else
       
   300     {
       
   301         RxIfDescriptor_t    *pRxParams  = (RxIfDescriptor_t*)pBuffer;
       
   302 
       
   303         pRxParams->status &= ~RX_DESC_STATUS_MASK;
       
   304         pRxParams->status |= RX_DESC_STATUS_DRIVER_RX_Q_FAIL;
       
   305     }
       
   306 
       
   307     TRACE0(pRxQueue->hReport, REPORT_SEVERITY_INFORMATION , "RxQueue_PassPacket: call TWD_OWNER_RX_QUEUE CB. In std rxData_ReceivePacket()\n");
       
   308 
       
   309     /* Set the packet to upper layer */
       
   310     /* if the packet status not success it will be discarded */
       
   311     pRxQueue->tReceivePacketCB (pRxQueue->hReceivePacketCB_handle, pBuffer);
       
   312 
       
   313     return TI_OK;
       
   314 }
       
   315 
       
   316 
       
   317 /** 
       
   318  * \fn     RxQueue_ReceivePacket()
       
   319  * \brief  Main function of the RxQueue module. 
       
   320  * Responsible on reorder of the packets from the RxXfer to the RX module.
       
   321  * Call from RxXfer in order to pass packet to uppers layers.
       
   322  * In order to save disordered packets the module use array of structures per TID 
       
   323  * that each entry describe a packet. The array elements is sorted in the way that 
       
   324  * the winStart array index represent always the winStar packet and the lowest SN. 
       
   325  * Each increment index represent index at the BA window. Array index winEnd  always 
       
   326  * represent winEnd packet. The indexes of winStart and winEnd handled in cyclic manner.
       
   327  * The function functionality devided to parts:
       
   328  *   Part 1: 
       
   329  * in case the modulo receive packet with SN equal to winStart: 
       
   330  * "	pass it to upper layers
       
   331  * "	increases winStart and array index winStart
       
   332  * "	validate that all sequential queue packet are pass to the upper layers.
       
   333  *   Part 2: 
       
   334  * in case the modulo receive packet that SN between winStart to winEnd: 
       
   335  * "	Save it sorted at the array at index: Save index = ((SN - winStart) + index array winStart) % arraySize.
       
   336  *   Part 3: 
       
   337  * in case the modulo receive packet that SN higher then winEnd: 
       
   338  * "	Update winStart and WinEnd. 
       
   339  * "	Save it sorted at the array in index winEnd index.
       
   340  * "	Pass to the upper layers all packets at the array indexes from old winStart index to the updated winStart index.
       
   341  *   Part 4 + 5: 
       
   342  * in case the modulo receive BA event packet: 
       
   343  * "	Update winStart and WinEnd 
       
   344  * "	Pass to the upper layers all packets at the array indexes from old winStart index to the updated winStart index.
       
   345  * "	Free BA event packet via pass it to upper layers with error status.
       
   346  *
       
   347  * \note   
       
   348  * \param  hRxQueue - RxQueue handle.
       
   349  * \param  aStatus - RxXfer status that indicate if the upper layer should free the packet or use it.
       
   350  * \param  pBuffer - paket address of the packet
       
   351  * \return None 
       
   352  * \sa     
       
   353  */ 
       
   354 void RxQueue_ReceivePacket (TI_HANDLE hRxQueue, const void * pBuffer)
       
   355 {
       
   356     TRxQueue            *pRxQueue   = (TRxQueue *)hRxQueue;
       
   357     RxIfDescriptor_t    *pRxParams  = (RxIfDescriptor_t*)pBuffer;
       
   358     TI_UINT8            *pFrame     = RX_BUF_DATA((TI_UINT8 *)pBuffer);
       
   359     TI_STATUS           tStatus     = TI_OK;
       
   360     dot11_header_t      *pHdr       = (dot11_header_t *)pFrame;
       
   361     TI_UINT16		    uQosControl;
       
   362 
       
   363     COPY_WLAN_WORD(&uQosControl, &pHdr->qosControl); /* copy with endianess handling. */
       
   364     TRACE2(pRxQueue->hReport, REPORT_SEVERITY_INFORMATION, "RxQueue_ReceivePacket: packet_class_tag = 0x%x(%d)",pRxParams->packet_class_tag,pRxParams->packet_class_tag);
       
   365 
       
   366     /* 
       
   367      * Retrieving the TAG from the packet itself and not from the Rx Descriptor since by now it is not correct  
       
   368      * Note: in the DR TAG_CLASS_EAPOL packet handled as TAG_CLASS_QOS_DATA   
       
   369      */
       
   370     if (IS_QOS_FRAME(*(TI_UINT16*)pFrame) && (pRxParams->packet_class_tag != TAG_CLASS_QOS_DATA) && (pRxParams->packet_class_tag != TAG_CLASS_AMSDU))
       
   371 	{
       
   372         TRACE1(pRxQueue->hReport, REPORT_SEVERITY_INFORMATION, "RxQueue_ReceivePacket: BAD CLASS TAG =0x%x from FW.\n", pRxParams->packet_class_tag);
       
   373 
       
   374 		
       
   375         /* Get AMSDU bit from frame */
       
   376         if( uQosControl & DOT11_QOS_CONTROL_FIELD_A_MSDU_BITS)
       
   377         {
       
   378             pRxParams->packet_class_tag = TAG_CLASS_AMSDU;
       
   379         }
       
   380         else
       
   381         {
       
   382             pRxParams->packet_class_tag = TAG_CLASS_QOS_DATA;
       
   383         }
       
   384 	}
       
   385 
       
   386     /* 
       
   387      * packet doesn't need reorder ? 
       
   388      */
       
   389     if ((pRxParams->packet_class_tag != TAG_CLASS_QOS_DATA) && (pRxParams->packet_class_tag != TAG_CLASS_BA_EVENT) && (pRxParams->packet_class_tag != TAG_CLASS_AMSDU))
       
   390     {
       
   391         TRACE0(pRxQueue->hReport, REPORT_SEVERITY_INFORMATION , "RxQueue_ReceivePacket: pass packet without reorder.\n");
       
   392 
       
   393         RxQueue_PassPacket (pRxQueue, tStatus, pBuffer);
       
   394 
       
   395         return;
       
   396     }
       
   397 
       
   398 
       
   399     /* 
       
   400      * pRxParams->type == TAG_CLASS_QOS_DATA ? 
       
   401      */
       
   402     if ((pRxParams->packet_class_tag == TAG_CLASS_QOS_DATA) || (pRxParams->packet_class_tag == TAG_CLASS_AMSDU))
       
   403     {
       
   404         TI_UINT8            uFrameTid;
       
   405         TI_UINT16           uFrameSn;
       
   406         TI_UINT16		    uSequenceControl;
       
   407         TRxQueueTidDataBase *pTidDataBase;
       
   408 
       
   409         /* Get TID from frame */
       
   410         uFrameTid = uQosControl & DOT11_QOS_CONTROL_FIELD_TID_BITS;
       
   411 
       
   412         TRACE0(pRxQueue->hReport, REPORT_SEVERITY_INFORMATION, "RxQueue_ReceivePacket: QoS Packet received");
       
   413         TRACE2(pRxQueue->hReport, REPORT_SEVERITY_INFORMATION, "RxQueue_ReceivePacket: uFrameTid = 0x%x(%d)",uFrameTid,uFrameTid);
       
   414 
       
   415         /* TID illegal value ? */
       
   416         if (uFrameTid >= MAX_NUM_OF_802_1d_TAGS)
       
   417         {
       
   418             TRACE1(pRxQueue->hReport, REPORT_SEVERITY_ERROR, "RxQueue_ReceivePacket: TID value too big, TID = %d. packet discarded!\n",uFrameTid);
       
   419 
       
   420             RxQueue_PassPacket (pRxQueue, TI_NOK, pBuffer);
       
   421 
       
   422             return;
       
   423         }
       
   424 
       
   425         /*set the SA Tid pointer */
       
   426         pTidDataBase = &(pRxQueue->tRxQueueArraysMng.tSa1ArrayMng[uFrameTid]);
       
   427 
       
   428         /* TID legal value */
       
   429         /* packet TID BA not established ? */ 
       
   430         if (pTidDataBase->aTidBaEstablished != TI_TRUE)
       
   431         {
       
   432             TRACE0(pRxQueue->hReport, REPORT_SEVERITY_INFORMATION, "RxQueue_ReceivePacket: pass packet without reorder.\n");
       
   433 
       
   434             RxQueue_PassPacket (pRxQueue, tStatus, pBuffer);
       
   435 
       
   436             return;
       
   437         }
       
   438 
       
   439         /* packet TID BA established */
       
   440         /* Get Sequence Number from frame */
       
   441         COPY_WLAN_WORD(&uSequenceControl, &pHdr->seqCtrl); /* copy with endianess handling. */
       
   442         uFrameSn = (uSequenceControl & DOT11_SC_SEQ_NUM_MASK) >> 4;
       
   443 
       
   444         TRACE2(pRxQueue->hReport, REPORT_SEVERITY_INFORMATION, "RxQueue_ReceivePacket: uFrameSn = 0x%x(%d)",uFrameSn,uFrameSn);
       
   445         TRACE2(pRxQueue->hReport, REPORT_SEVERITY_INFORMATION, "RxQueue_ReceivePacket: aTidExpectedSn = 0x%x(%d)",pTidDataBase->aTidExpectedSn,pTidDataBase->aTidExpectedSn);
       
   446 
       
   447         /* 
       
   448          * note: 
       
   449          * the FW never send paket, in establish TID BA, that the SN less then ESN !!! 
       
   450          */
       
   451 
       
   452         /* frame Sequence Number is the expected one ? */
       
   453         if (uFrameSn == pTidDataBase->aTidExpectedSn)
       
   454         {
       
   455             TRACE0(pRxQueue->hReport, REPORT_SEVERITY_INFORMATION, "RxQueue_ReceivePacket: frame Sequence Number == expected one Sequence Number.\n");
       
   456 
       
   457             /* pass the packet */
       
   458             RxQueue_PassPacket (pRxQueue, tStatus, pBuffer);
       
   459 
       
   460             pTidDataBase->aTidExpectedSn++;
       
   461 
       
   462             /* increase the ArrayInex to the next */
       
   463             pTidDataBase->aWinStartArrayInex++;
       
   464 
       
   465             /* aWinStartArrayInex % RX_QUEUE_ARRAY_SIZE */
       
   466             pTidDataBase->aWinStartArrayInex &= RX_QUEUE_ARRAY_SIZE_BIT_MASK;
       
   467 
       
   468             /* pass all saved queue packets with SN higher then the expected one */
       
   469             while (pTidDataBase->aPaketsQueue[pTidDataBase->aWinStartArrayInex].pPacket != NULL)
       
   470             {
       
   471                 TRACE0(pRxQueue->hReport, REPORT_SEVERITY_INFORMATION, "RxQueue_ReceivePacket: pass all saved queue packets with SN higher then the expected one");
       
   472                 TRACE2(pRxQueue->hReport, REPORT_SEVERITY_INFORMATION, "RxQueue_ReceivePacket: aTidExpectedSn = 0x%x(%d)",pTidDataBase->aTidExpectedSn,pTidDataBase->aTidExpectedSn);
       
   473                 TRACE2(pRxQueue->hReport, REPORT_SEVERITY_INFORMATION, "RxQueue_ReceivePacket: aWinStartArrayInex = 0x%x(%d)",pTidDataBase->aWinStartArrayInex,pTidDataBase->aWinStartArrayInex);
       
   474 
       
   475                 RxQueue_PassPacket (pRxQueue, 
       
   476                                     pTidDataBase->aPaketsQueue[pTidDataBase->aWinStartArrayInex].tStatus,
       
   477                                     pTidDataBase->aPaketsQueue[pTidDataBase->aWinStartArrayInex].pPacket);
       
   478 
       
   479                 pTidDataBase->aPaketsQueue[pTidDataBase->aWinStartArrayInex].pPacket = NULL;
       
   480 
       
   481                 pTidDataBase->aWinStartArrayInex++;
       
   482 
       
   483                 /* aWinStartArrayInex % RX_QUEUE_ARRAY_SIZE */
       
   484                 pTidDataBase->aWinStartArrayInex &= RX_QUEUE_ARRAY_SIZE_BIT_MASK;
       
   485 
       
   486                  pTidDataBase->aTidExpectedSn++;
       
   487             }
       
   488 
       
   489             /* aTidExpectedSn % 0xfff in order to tack care of wrap around */
       
   490             pTidDataBase->aTidExpectedSn &= 0xfff; 
       
   491 
       
   492             return;
       
   493         }
       
   494 
       
   495         /* frame Sequence Number is lower then Expected sequence number (ISN) ? */ 
       
   496         if (! BA_SESSION_IS_A_BIGGER_THAN_B (uFrameSn, pTidDataBase->aTidExpectedSn))
       
   497 
       
   498         {
       
   499             TRACE0(pRxQueue->hReport, REPORT_SEVERITY_INFORMATION, "RxQueue_ReceivePacket: frame Sequence Number is lower then expected sequence number.\n");
       
   500 
       
   501             RxQueue_PassPacket (pRxQueue, tStatus, pBuffer);
       
   502 
       
   503             return;
       
   504         }
       
   505 
       
   506         /* frame Sequence Number between winStart and winEnd ? */
       
   507         if ((BA_SESSION_IS_A_BIGGER_THAN_B (uFrameSn, pTidDataBase->aTidExpectedSn)) &&
       
   508             /* mean: uFrameSn <= pTidDataBase->aTidExpectedSn + pTidDataBase->aTidWinSize) */
       
   509             ( ! BA_SESSION_IS_A_BIGGER_THAN_B (uFrameSn,(pTidDataBase->aTidExpectedSn + pTidDataBase->aTidWinSize - 1))))
       
   510         {
       
   511             TI_UINT16 uSaveInex = pTidDataBase->aWinStartArrayInex + (TI_UINT16)((uFrameSn + SEQ_NUM_WRAP - pTidDataBase->aTidExpectedSn) & SEQ_NUM_MASK);  
       
   512             /* uSaveInex % RX_QUEUE_ARRAY_SIZE */
       
   513             uSaveInex &= RX_QUEUE_ARRAY_SIZE_BIT_MASK; 
       
   514 
       
   515             TRACE0(pRxQueue->hReport, REPORT_SEVERITY_INFORMATION, "RxQueue_ReceivePacket: frame Sequence Number between winStart and winEnd.\n");
       
   516             TRACE2(pRxQueue->hReport, REPORT_SEVERITY_INFORMATION, "RxQueue_ReceivePacket: uSaveInex = 0x%x(%d)",uSaveInex,uSaveInex);
       
   517             
       
   518 			if (pTidDataBase->aPaketsQueue[uSaveInex].pPacket == NULL)
       
   519 			{
       
   520                 TRACE0(pRxQueue->hReport, REPORT_SEVERITY_INFORMATION, "RxQueue_ReceivePacket: Enter packet to Reorder Queue");
       
   521                 
       
   522             /* save the packet in the queue */
       
   523             pTidDataBase->aPaketsQueue[uSaveInex].tStatus = tStatus;
       
   524             pTidDataBase->aPaketsQueue[uSaveInex].pPacket = (void *)pBuffer;
       
   525             pTidDataBase->aPaketsQueue[uSaveInex].uFrameSn = uFrameSn;
       
   526 			}
       
   527 			else
       
   528 			{
       
   529 				 TRACE1(pRxQueue->hReport, REPORT_SEVERITY_ERROR, "RxQueue_ReceivePacket: frame Sequence has allready saved. uFrameSn = %d\n",uFrameSn);
       
   530 				 RxQueue_PassPacket (pRxQueue, TI_NOK, pBuffer);
       
   531 				 return;
       
   532 			}
       
   533             return;
       
   534         }
       
   535 
       
   536 
       
   537         /* 
       
   538         frame Sequence Number higher then winEnd ? 
       
   539         */
       
   540         if ( BA_SESSION_IS_A_BIGGER_THAN_B (uFrameSn, (pTidDataBase->aTidExpectedSn + pTidDataBase->aTidWinSize - 1)) )
       
   541         {
       
   542             TI_UINT32 i;
       
   543             TI_UINT16 uNewWinStartSn = (uFrameSn + SEQ_NUM_WRAP - pTidDataBase->aTidWinSize + 1) & SEQ_NUM_MASK;
       
   544             TI_UINT16 uSaveInex;
       
   545             
       
   546             
       
   547             TRACE0(pRxQueue->hReport, REPORT_SEVERITY_INFORMATION, "RxQueue_ReceivePacket: frame Sequence Number higher then winEnd. \n");
       
   548             TRACE2(pRxQueue->hReport, REPORT_SEVERITY_INFORMATION, "RxQueue_ReceivePacket: uNewWinStartSn = 0x%x(%d)",uNewWinStartSn,uNewWinStartSn);
       
   549 
       
   550             /* increase the ArrayInex to the next */
       
   551             pTidDataBase->aWinStartArrayInex++;
       
   552 
       
   553             /* aWinStartArrayInex % RX_QUEUE_ARRAY_SIZE */
       
   554             pTidDataBase->aWinStartArrayInex &= RX_QUEUE_ARRAY_SIZE_BIT_MASK;
       
   555 
       
   556             /* update the Expected SN since the current one is lost */
       
   557             pTidDataBase->aTidExpectedSn++;
       
   558             pTidDataBase->aTidExpectedSn &= 0xFFF;
       
   559 
       
   560             /* pass all saved queue packets with SN lower then the new win start */
       
   561             for (i = 0;
       
   562                  BA_SESSION_IS_A_BIGGER_THAN_B(uNewWinStartSn,pTidDataBase->aTidExpectedSn) && 
       
   563                   (i < RX_QUEUE_ARRAY_SIZE) && 
       
   564                   (i < pTidDataBase->aTidWinSize);
       
   565                  i++)
       
   566             {
       
   567                 TRACE2(pRxQueue->hReport, REPORT_SEVERITY_INFORMATION, "RxQueue_ReceivePacket: aTidExpectedSn = 0x%x(%d)",pTidDataBase->aTidExpectedSn,pTidDataBase->aTidExpectedSn);
       
   568                 TRACE2(pRxQueue->hReport, REPORT_SEVERITY_INFORMATION, "RxQueue_ReceivePacket: aWinStartArrayInex = 0x%x(%d)",pTidDataBase->aWinStartArrayInex,pTidDataBase->aWinStartArrayInex);
       
   569 
       
   570                 if (pTidDataBase->aPaketsQueue[pTidDataBase->aWinStartArrayInex].pPacket != NULL)
       
   571                 {
       
   572                     TRACE0(pRxQueue->hReport, REPORT_SEVERITY_INFORMATION, "RxQueue_ReceivePacket: Send Packet to Upper layer");
       
   573                     RxQueue_PassPacket (pRxQueue, 
       
   574                                         pTidDataBase->aPaketsQueue[pTidDataBase->aWinStartArrayInex].tStatus,
       
   575                                         pTidDataBase->aPaketsQueue[pTidDataBase->aWinStartArrayInex].pPacket);
       
   576 
       
   577                     pTidDataBase->aPaketsQueue[pTidDataBase->aWinStartArrayInex].pPacket = NULL;
       
   578                 }
       
   579 
       
   580                 pTidDataBase->aWinStartArrayInex++;
       
   581 
       
   582                 /* aWinStartArrayInex % RX_QUEUE_ARRAY_SIZE */
       
   583                 pTidDataBase->aWinStartArrayInex &= RX_QUEUE_ARRAY_SIZE_BIT_MASK;
       
   584 
       
   585                 pTidDataBase->aTidExpectedSn++;
       
   586                 pTidDataBase->aTidExpectedSn &= 0xFFF;
       
   587 
       
   588             }
       
   589 
       
   590             TRACE2(pRxQueue->hReport, REPORT_SEVERITY_INFORMATION, "RxQueue_ReceivePacket: aTidExpectedSn = 0x%x(%d)",pTidDataBase->aTidExpectedSn,pTidDataBase->aTidExpectedSn);
       
   591             TRACE1(pRxQueue->hReport, REPORT_SEVERITY_INFORMATION, "RxQueue_ReceivePacket: i = %d",i);
       
   592 
       
   593             /* Calculate the new Expected SN */
       
   594             if (i == pTidDataBase->aTidWinSize)
       
   595             {
       
   596                 TRACE0(pRxQueue->hReport, REPORT_SEVERITY_INFORMATION, "RxQueue_ReceivePacket: Set aTidExpectedSn to uNewWinStartSn");
       
   597                 pTidDataBase->aTidExpectedSn = uNewWinStartSn;
       
   598             }
       
   599             else
       
   600             {
       
   601                 TRACE0(pRxQueue->hReport, REPORT_SEVERITY_INFORMATION, "RxQueue_ReceivePacket: Send all saved packets");
       
   602                 /* Incase the uWinStartDelta lower than aTidWinSize check if ther are packets stored in Array */
       
   603                 while (pTidDataBase->aPaketsQueue[pTidDataBase->aWinStartArrayInex].pPacket != NULL) {
       
   604                     TRACE2(pRxQueue->hReport, REPORT_SEVERITY_INFORMATION, "RxQueue_ReceivePacket: Send packet with SN = 0x%x(%d)",pTidDataBase->aTidExpectedSn,pTidDataBase->aTidExpectedSn);
       
   605                     RxQueue_PassPacket (pRxQueue, 
       
   606                                             pTidDataBase->aPaketsQueue[pTidDataBase->aWinStartArrayInex].tStatus,
       
   607                                             pTidDataBase->aPaketsQueue[pTidDataBase->aWinStartArrayInex].pPacket);
       
   608     
       
   609                     pTidDataBase->aPaketsQueue[pTidDataBase->aWinStartArrayInex].pPacket = NULL;
       
   610     
       
   611                     pTidDataBase->aWinStartArrayInex++;
       
   612     
       
   613                     /* aWinStartArrayInex % RX_QUEUE_ARRAY_SIZE */
       
   614                     pTidDataBase->aWinStartArrayInex &= RX_QUEUE_ARRAY_SIZE_BIT_MASK;
       
   615     
       
   616                     pTidDataBase->aTidExpectedSn++;
       
   617                     pTidDataBase->aTidExpectedSn &= 0xFFF;
       
   618                 }
       
   619             }
       
   620 
       
   621             TRACE2(pRxQueue->hReport, REPORT_SEVERITY_INFORMATION, "RxQueue_ReceivePacket: aTidExpectedSn = 0x%x(%d)",pTidDataBase->aTidExpectedSn,pTidDataBase->aTidExpectedSn);
       
   622 
       
   623             if(pTidDataBase->aTidExpectedSn == uFrameSn)
       
   624             {
       
   625                 TRACE0(pRxQueue->hReport, REPORT_SEVERITY_INFORMATION, "RxQueue_ReceivePacket: Send current packet to uper layer");
       
   626                 /* pass the packet */
       
   627                 RxQueue_PassPacket (pRxQueue, tStatus, pBuffer);
       
   628 
       
   629                 pTidDataBase->aTidExpectedSn++;
       
   630             }
       
   631             else
       
   632             {
       
   633                 uSaveInex = pTidDataBase->aWinStartArrayInex + (TI_UINT16)((uFrameSn + SEQ_NUM_WRAP - pTidDataBase->aTidExpectedSn) & SEQ_NUM_MASK);  
       
   634 
       
   635                 TRACE0(pRxQueue->hReport, REPORT_SEVERITY_INFORMATION, "RxQueue_ReceivePacket: Enter current packet to Reorder Queue");
       
   636                 TRACE2(pRxQueue->hReport, REPORT_SEVERITY_INFORMATION, "RxQueue_ReceivePacket: uSaveInex = 0x%x(%d)",uSaveInex,uSaveInex);
       
   637 
       
   638             /* uSaveInex % RX_QUEUE_ARRAY_SIZE */
       
   639             uSaveInex &= RX_QUEUE_ARRAY_SIZE_BIT_MASK; 
       
   640 
       
   641             /* save the packet in the last entry of the queue */
       
   642             pTidDataBase->aPaketsQueue[uSaveInex].tStatus = tStatus;
       
   643             pTidDataBase->aPaketsQueue[uSaveInex].pPacket = (void *)pBuffer;
       
   644                pTidDataBase->aPaketsQueue[uSaveInex].pPacket = (void *)pBuffer;
       
   645             }
       
   646 
       
   647             /* aTidExpectedSn % 0xfff in order to tack care of wrap around */
       
   648             pTidDataBase->aTidExpectedSn &= 0xfff; 
       
   649 
       
   650             return;
       
   651         }
       
   652     }
       
   653 
       
   654 
       
   655     /* 
       
   656      * BA event ? 
       
   657      */
       
   658     if (pRxParams->packet_class_tag == TAG_CLASS_BA_EVENT)
       
   659     {
       
   660         TRxQueueTidDataBase *pTidDataBase;
       
   661         TI_UINT8            *pDataFrameBody;
       
   662         TI_UINT16           ufc;
       
   663         TI_UINT8            uFrameTid;
       
   664         TI_UINT16           uStartingSequenceNumber;
       
   665         TI_UINT16           uWinStartDelta;
       
   666         TI_UINT16           uBarControlField;
       
   667         TI_UINT16           uBaStartingSequenceControlField;
       
   668         TI_UINT16           uBAParameterField;         
       
   669         TI_UINT32           i;
       
   670 
       
   671         /* Get sub type from frame */
       
   672         COPY_WLAN_WORD(&ufc, &pHdr->fc); /* copy with endianess handling. */
       
   673 
       
   674         /* get the type to BA event */
       
   675         switch ((dot11_Fc_Sub_Type_e)(ufc & DOT11_FC_SUB_MASK))
       
   676         {
       
   677         case DOT11_FC_SUB_BAR:
       
   678             TRACE0(pRxQueue->hReport, REPORT_SEVERITY_INFORMATION , "RxQueue_ReceivePacket: BA event - BAR frame.\n");
       
   679 
       
   680             /* get pointer to the frame body */
       
   681             pDataFrameBody = pFrame + sizeof(dot11_BarFrameHeader_t);
       
   682 
       
   683             /* Get TID from BAR frame */
       
   684             COPY_WLAN_WORD (&uBarControlField, (TI_UINT16 *)pDataFrameBody); /* copy with endianess handling. */
       
   685             uFrameTid = (uBarControlField & DOT11_BAR_CONTROL_FIELD_TID_BITS) >> 12;
       
   686 
       
   687             /* TID illegal value ? */
       
   688             if (uFrameTid >= MAX_NUM_OF_802_1d_TAGS)
       
   689             {
       
   690                 TRACE1(pRxQueue->hReport, REPORT_SEVERITY_ERROR , "RxQueue_ReceivePacket: BA event - BAR frame with TID value too big, TID = %d.\n",uFrameTid);
       
   691 
       
   692                 RxQueue_PassPacket (pRxQueue, TI_NOK, pBuffer);
       
   693 
       
   694                 return;
       
   695             }
       
   696 
       
   697             /* set the SA Tid pointer */
       
   698             pTidDataBase = &(pRxQueue->tRxQueueArraysMng.tSa1ArrayMng[uFrameTid]);
       
   699 
       
   700             /* TID legal value */
       
   701             /* packet TID BA not established ? */ 
       
   702             if (pTidDataBase->aTidBaEstablished != TI_TRUE)
       
   703             {
       
   704                 TRACE1(pRxQueue->hReport, REPORT_SEVERITY_ERROR , "RxQueue_ReceivePacket: BA event - BAR frame for TID not established, TID = %d.\n",uFrameTid);
       
   705 
       
   706                 RxQueue_PassPacket (pRxQueue, TI_NOK, pBuffer);
       
   707 
       
   708                 return;
       
   709             }
       
   710 
       
   711             /* Get Starting Sequence number from BAR frame */
       
   712             pDataFrameBody = pDataFrameBody + 2;
       
   713             COPY_WLAN_WORD (&uBaStartingSequenceControlField, (TI_UINT16 *)pDataFrameBody); /* copy with endianess handling. */
       
   714             uStartingSequenceNumber = (uBaStartingSequenceControlField & DOT11_SC_SEQ_NUM_MASK) >> 4;
       
   715 
       
   716             /* Starting Sequence Number is higher then winStart ? */
       
   717             if ( A_GREATER_THAN_B (uStartingSequenceNumber, pTidDataBase->aTidExpectedSn) )
       
   718             {
       
   719                 uWinStartDelta = uStartingSequenceNumber - pTidDataBase->aTidExpectedSn;
       
   720 
       
   721                 /* pass all saved queue packets with SN lower then the new win start */
       
   722                 for (i = 0;
       
   723                      ((i < uWinStartDelta) || (pTidDataBase->aPaketsQueue[pTidDataBase->aWinStartArrayInex].pPacket != NULL)) &&
       
   724                       (i < RX_QUEUE_ARRAY_SIZE) && 
       
   725                       (i < RX_QUEUE_WIN_SIZE);
       
   726                      i++)
       
   727                 {
       
   728                     if (pTidDataBase->aPaketsQueue[pTidDataBase->aWinStartArrayInex].pPacket != NULL)
       
   729                     {
       
   730                         RxQueue_PassPacket (pRxQueue, 
       
   731                                             pTidDataBase->aPaketsQueue[pTidDataBase->aWinStartArrayInex].tStatus,
       
   732                                             pTidDataBase->aPaketsQueue[pTidDataBase->aWinStartArrayInex].pPacket);
       
   733 
       
   734                         pTidDataBase->aPaketsQueue[pTidDataBase->aWinStartArrayInex].pPacket = NULL;
       
   735                     }
       
   736 
       
   737                     pTidDataBase->aWinStartArrayInex++;
       
   738 
       
   739                     /* aWinStartArrayInex % RX_QUEUE_ARRAY_SIZE */
       
   740                     pTidDataBase->aWinStartArrayInex &= RX_QUEUE_ARRAY_SIZE_BIT_MASK;
       
   741                 }
       
   742 
       
   743                 pTidDataBase->aTidExpectedSn = uStartingSequenceNumber;
       
   744             }
       
   745             break;
       
   746 
       
   747 
       
   748         case DOT11_FC_SUB_ACTION:
       
   749             /* get pointer to the frame body */
       
   750             pDataFrameBody = pFrame + sizeof(dot11_mgmtHeader_t);
       
   751 
       
   752             /* get Action field from BA action frame */
       
   753             pDataFrameBody++;
       
   754             switch(*pDataFrameBody)
       
   755             {
       
   756             case DOT11_BA_ACTION_ADDBA:
       
   757 
       
   758                 TRACE0( pRxQueue->hReport, REPORT_SEVERITY_INFORMATION, "RxQueue_ReceivePacket: BA event - ADDBA frame.\n");
       
   759 
       
   760                 /* get TID field and winSize from ADDBA action frame */
       
   761                 pDataFrameBody = pDataFrameBody + 2;
       
   762                 COPY_WLAN_WORD(&uBAParameterField, (TI_UINT16 *)pDataFrameBody); /* copy with endianess handling. */
       
   763                 uFrameTid = (uBAParameterField & DOT11_BA_PARAMETER_SET_FIELD_TID_BITS) >> 2;
       
   764 
       
   765                 /* TID illegal value ? */
       
   766                 if (uFrameTid >= MAX_NUM_OF_802_1d_TAGS)
       
   767                 {
       
   768                     TRACE1(pRxQueue->hReport, REPORT_SEVERITY_ERROR , "RxQueue_ReceivePacket: BA event - ADDBA frame with TID value too big, TID = %d.\n",uFrameTid);
       
   769 
       
   770                     RxQueue_PassPacket (pRxQueue, TI_NOK, pBuffer);
       
   771 
       
   772                     return;
       
   773                 }
       
   774 
       
   775                 /*set the SA Tid pointer */
       
   776                 pTidDataBase = &(pRxQueue->tRxQueueArraysMng.tSa1ArrayMng[uFrameTid]);
       
   777 
       
   778                 /* TID legal value */
       
   779                 /* packet TID BA established ? */ 
       
   780                 if (pTidDataBase->aTidBaEstablished == TI_TRUE)
       
   781                 {
       
   782                     TRACE1(pRxQueue->hReport, REPORT_SEVERITY_ERROR , "RxQueue_ReceivePacket: BA event - ADDBA frame for TID already established, TID = %d.\n",uFrameTid);
       
   783 
       
   784                     RxQueue_PassPacket (pRxQueue, TI_NOK, pBuffer);
       
   785 
       
   786                     return;
       
   787                 }
       
   788 
       
   789                 /* get winSize from ADDBA action frame */
       
   790                 pTidDataBase->aTidWinSize = (uBAParameterField & DOT11_BA_PARAMETER_SET_FIELD_WINSIZE_BITS) >> 6; 
       
   791 
       
   792                 /* winSize illegal value ? */ 
       
   793                 if (pTidDataBase->aTidWinSize > RX_QUEUE_WIN_SIZE)
       
   794                 {
       
   795                     /* In case the win Size is higher then 8 the driver and the FW set it to 8 and inform the AP in ADDBA respond */
       
   796                     pTidDataBase->aTidWinSize = RX_QUEUE_WIN_SIZE;
       
   797                 }
       
   798 
       
   799                 /* packet TID BA not yet established and winSize legal */
       
   800                 /* establishe BA TID */
       
   801                 pTidDataBase->aTidBaEstablished = TI_TRUE;
       
   802 
       
   803                 /* get initial sequence number (ISN) from ADDBA action frame */
       
   804                 pDataFrameBody = pDataFrameBody + 4;
       
   805                 COPY_WLAN_WORD (&uStartingSequenceNumber, (TI_UINT16 *)pDataFrameBody); /* copy with endianess handling. */
       
   806                 pTidDataBase->aTidExpectedSn = (uStartingSequenceNumber & DOT11_SC_SEQ_NUM_MASK) >> 4;
       
   807                 pTidDataBase->aWinStartArrayInex = 0;
       
   808                 os_memoryZero (pRxQueue->hOs, pTidDataBase->aPaketsQueue, sizeof (TRxQueuePacketEntry) * RX_QUEUE_ARRAY_SIZE);
       
   809                 break;
       
   810 
       
   811             case DOT11_BA_ACTION_DELBA:
       
   812 
       
   813                 TRACE0( pRxQueue->hReport, REPORT_SEVERITY_INFORMATION, "RxQueue_ReceivePacket: BA event - DELBA frame.\n");
       
   814 
       
   815                 /* get TID field and winSize from ADDBA action frame */
       
   816                 pDataFrameBody = pDataFrameBody + 2;
       
   817                 COPY_WLAN_WORD(&uBAParameterField, (TI_UINT16 *)pDataFrameBody); /* copy with endianess handling. */
       
   818                 uFrameTid = (uBAParameterField & DOT11_DELBA_PARAMETER_FIELD_TID_BITS) >> 12;
       
   819 
       
   820                 /* TID illegal value ? */
       
   821                 if (uFrameTid >= MAX_NUM_OF_802_1d_TAGS)
       
   822                 {
       
   823                     TRACE1(pRxQueue->hReport, REPORT_SEVERITY_ERROR , "RxQueue_ReceivePacket: BA event - DELBA frame with TID value too big, TID = %d.\n",uFrameTid);
       
   824 
       
   825                     RxQueue_PassPacket (pRxQueue, TI_NOK, pBuffer);
       
   826 
       
   827                     return;
       
   828                 }
       
   829 
       
   830                 /*set the SA Tid pointer */
       
   831                 pTidDataBase = &(pRxQueue->tRxQueueArraysMng.tSa1ArrayMng[uFrameTid]);
       
   832 
       
   833                 /* TID legal value */
       
   834                 /* packet TID BA not established ? */ 
       
   835                 if (pTidDataBase->aTidBaEstablished != TI_TRUE)
       
   836                 {
       
   837                     TRACE1(pRxQueue->hReport, REPORT_SEVERITY_ERROR , "RxQueue_ReceivePacket: BA event - DELBA frame for TID not established, TID = %d.\n",uFrameTid);
       
   838 
       
   839                     RxQueue_PassPacket (pRxQueue, TI_NOK, pBuffer);
       
   840 
       
   841                     return;
       
   842                 }
       
   843 
       
   844                 RxQueue_CloseBaSession(hRxQueue, uFrameTid);
       
   845                 break;
       
   846 
       
   847             default:
       
   848                 TRACE1(pRxQueue->hReport, REPORT_SEVERITY_ERROR , "RxQueue_ReceivePacket: BA event Action field from BA action frame illegal. action = 0x%x\n",*pDataFrameBody);
       
   849 
       
   850                 RxQueue_PassPacket (pRxQueue, TI_NOK, pBuffer);
       
   851 
       
   852                 return;
       
   853             }
       
   854             break;
       
   855 
       
   856         default:
       
   857             TRACE1(pRxQueue->hReport, REPORT_SEVERITY_ERROR , "RxQueue_ReceivePacket: BA event with Subtype illegal. Subtype = 0x%x\n",((ufc & DOT11_FC_SUB_MASK) >> 4));
       
   858 
       
   859             RxQueue_PassPacket (pRxQueue, TI_NOK, pBuffer);
       
   860 
       
   861             return;
       
   862         }
       
   863     }
       
   864 
       
   865     TRACE1(pRxQueue->hReport, REPORT_SEVERITY_ERROR, "RxQueue_ReceivePacket: unknow type tag. tag = %d\n", pRxParams->packet_class_tag);
       
   866 
       
   867     RxQueue_PassPacket (pRxQueue, tStatus, pBuffer);
       
   868 
       
   869     return;
       
   870 }
       
   871