1 /**************************************************************************** 2 **+-----------------------------------------------------------------------+** 3 **| |** 4 **| Copyright(c) 1998 - 2008 Texas Instruments. All rights reserved. |** 5 **| All rights reserved. |** 6 **| |** 7 **| Redistribution and use in source and binary forms, with or without |** 8 **| modification, are permitted provided that the following conditions |** 9 **| are met: |** 10 **| |** 11 **| * Redistributions of source code must retain the above copyright |** 12 **| notice, this list of conditions and the following disclaimer. |** 13 **| * Redistributions in binary form must reproduce the above copyright |** 14 **| notice, this list of conditions and the following disclaimer in |** 15 **| the documentation and/or other materials provided with the |** 16 **| distribution. |** 17 **| * Neither the name Texas Instruments nor the names of its |** 18 **| contributors may be used to endorse or promote products derived |** 19 **| from this software without specific prior written permission. |** 20 **| |** 21 **| THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |** 22 **| "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |** 23 **| LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |** 24 **| A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |** 25 **| OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |** 26 **| SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |** 27 **| LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |** 28 **| DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |** 29 **| THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |** 30 **| (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |** 31 **| OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |** 32 **| |** 33 **+-----------------------------------------------------------------------+** 34 ****************************************************************************/ 35 /***************************************************************************/ 36 /* */ 37 /* MODULE: Rx.c */ 38 /* PURPOSE: Rx module functions */ 39 /* */ 40 /***************************************************************************/ 41 #include "osTIType.h" 42 #include "paramIn.h" 43 #include "paramMng.h" 44 #include "paramOut.h" 45 #include "memMngrEx.h" 46 #include "rx.h" 47 #include "osApi.h" 48 #include "DataCtrl_Api.h" 49 #include "Ctrl.h" 50 #include "802_11Defs.h" 51 #include "Ethernet.h" 52 #include "report.h" 53 #include "utils.h" 54 #include "mlmeApi.h" 55 #include "rsnApi.h" 56 #include "smeApi.h" 57 #include "siteMgrApi.h" 58 #include "GeneralUtil.h" 59 #include "EvHandler.h" 60 #ifdef EXC_MODULE_INCLUDED 61 #include "excMngr.h" 62 #endif 63 #include "TNETW_Driver_api.h" 64 65 #define EAPOL_PACKET 0x8E88 66 #define IAPP_PACKET 0x0000 67 #define PREAUTH_EAPOL_PACKET 0xC788 68 69 /* CallBack for recieving packet from rxXfer */ 70 static void rxData_ReceivePacket ( TI_HANDLE hRxData,TI_STATUS aStatus,const void *aFrame, 71 UINT16 aLength,UINT32 aRate,UINT8 aRCPI, 72 UINT8 aChannel,void *Reserved,UINT32 aFlags); 73 74 static void *rxData_RequestForBuffer (TI_HANDLE hRxData,UINT16 aLength, UINT32 uEncryptionFlag); 75 76 #if 0 77 static TI_STATUS rxData_checkBssIdAndBssType(TI_HANDLE hRxData, dot11_header_t* dot11_header, 78 macAddress_t **rxBssid, bssType_e *currBssType, 79 macAddress_t *currBssId); 80 #endif 81 static TI_STATUS rxData_convertWlanToEthHeader (TI_HANDLE hRxData, mem_MSDU_T *pMsdu, UINT16 * etherType); 82 static void rxData_dataMsduDisptcher(TI_HANDLE hRxData, mem_MSDU_T *pMsdu, Rx_attr_t* pRxAttr); 83 static void rxData_discardMsdu(TI_HANDLE hRxData, mem_MSDU_T *pMsdu, Rx_attr_t* pRxAttr); 84 static void rxData_discardMsduVlan(TI_HANDLE hRxData, mem_MSDU_T *pMsdu, Rx_attr_t* pRxAttr); 85 static void rxData_rcvMsduInOpenNotify(TI_HANDLE hRxData, mem_MSDU_T *pMsdu, Rx_attr_t* pRxAttr); 86 static void rxData_rcvMsduEapol(TI_HANDLE hRxData, mem_MSDU_T *pMsdu, Rx_attr_t* pRxAttr); 87 static void rxData_rcvMsduData(TI_HANDLE hRxData, mem_MSDU_T *pMsdu, Rx_attr_t* pRxAttr); 88 static TI_STATUS rxData_enableDisableRxDataFilters(TI_HANDLE hRxData, BOOL enabled); 89 static TI_STATUS rxData_addRxDataFilter(TI_HANDLE hRxData, rxDataFilterRequest_t * request); 90 static TI_STATUS rxData_removeRxDataFilter(TI_HANDLE hRxData, rxDataFilterRequest_t * request); 91 92 #ifdef EXC_MODULE_INCLUDED 93 static void rxData_rcvMsduIapp(TI_HANDLE hRxData, mem_MSDU_T *pMsdu, Rx_attr_t* pRxAttr); 94 #endif 95 #ifdef TI_DBG 96 static void rxData_printRxThroughput(TI_HANDLE hRxData); 97 #endif 98 99 100 101 /************************************************************************* 102 * rxData_create * 103 ************************************************************************** 104 * DESCRIPTION: This function initializes the Rx data module. 105 * 106 * INPUT: hOs - handle to Os Abstraction Layer 107 * msduReceiveCB - call back function that return to 108 * configMngr in order to register in the Hal 109 * OUTPUT: 110 * 111 * RETURN: Handle to the allocated Rx data control block 112 ************************************************************************/ 113 TI_HANDLE rxData_create ( TI_HANDLE hOs) 114 { 115 rxData_t *hRxData; 116 117 /* check parameters validity */ 118 if( hOs == NULL) 119 { 120 WLAN_OS_REPORT(("FATAL ERROR: rxData_create(): OS handle Error - Aborting\n")); 121 return NULL; 122 } 123 124 125 /* alocate Rx module control block */ 126 hRxData = os_memoryAlloc(hOs, (sizeof(rxData_t))); 127 128 if( !hRxData ) 129 { 130 utils_nullMemoryFree(hOs, hRxData, sizeof(rxData_t)); 131 WLAN_OS_REPORT(("FATAL ERROR: rxData_create(): Error Creating Rx Module - Aborting\n")); 132 return(NULL); 133 } 134 135 /* reset Rx control block */ 136 os_memoryZero(hOs, hRxData, (sizeof(rxData_t))); 137 138 hRxData->RxEventDistributor = DistributorMgr_Create(hOs,MAX_RX_NOTIF_REQ_ELMENTS); 139 140 hRxData->hOs = hOs; 141 142 /* allocate timer for debug throughput */ 143 #ifdef TI_DBG 144 hRxData->hThroughputTimer = os_timerCreate (hOs, rxData_printRxThroughput, hRxData); 145 if (!hRxData->hThroughputTimer) 146 { 147 utils_nullMemoryFree (hOs, hRxData, sizeof(rxData_t)); 148 return NULL; 149 } 150 hRxData->rxThroughputTimerEnable = FALSE; 151 #endif 152 153 return(hRxData); 154 } 155 156 /*************************************************************************** 157 * rxData_config * 158 **************************************************************************** 159 * DESCRIPTION: This function configures the Rx Data module 160 * 161 * INPUTS: hRxData - The object 162 * hCtrlData - Handle to the Ctrl Data object 163 * hMlme - Handle to the Mlme object 164 * hRsn - Handle to the Rsn object 165 * hOs - Handle to the Os Abstraction Layer 166 * hReport - Handle to the Report object 167 * hMemMngr - Handle to the MemMngr object 168 * OUTPUT: 169 * 170 * RETURNS: OK - Configuration succesfull 171 * NOK - Configuration unsuccesfull 172 ***************************************************************************/ 173 174 TI_STATUS rxData_config(TI_HANDLE hRxData, 175 TI_HANDLE hCtrlData, 176 TI_HANDLE hTxData, 177 TI_HANDLE hTnetwDrv, 178 TI_HANDLE hHalCtrl, 179 TI_HANDLE hMlme, 180 TI_HANDLE hRsn, 181 TI_HANDLE hSiteMgr, 182 TI_HANDLE hExcMngr, 183 TI_HANDLE hOs, 184 TI_HANDLE hReport, 185 TI_HANDLE hMemMngr, 186 TI_HANDLE hEvHandler, 187 rxDataInitParams_t * rxDataInitParams) 188 { 189 rxData_t *pRxData = (rxData_t *)hRxData; 190 int i; 191 192 /* check parameters validity */ 193 if( hRxData == NULL || hCtrlData == NULL || hMlme == NULL || hRsn == NULL || hHalCtrl == NULL || 194 hSiteMgr == NULL || hOs == NULL || hReport == NULL || hTxData == NULL || hTnetwDrv == NULL) 195 { 196 WLAN_OS_REPORT(("FATAL ERROR: rxData_config(): Parameters Error - Aborting\n")); 197 return NOK; 198 } 199 pRxData->hCtrlData = hCtrlData; 200 pRxData->hTxData = hTxData; 201 pRxData->hTnetwDrv = hTnetwDrv; 202 pRxData->hHalCtrl = hHalCtrl; 203 pRxData->hMlme = hMlme; 204 pRxData->hRsn = hRsn; 205 pRxData->hSiteMgr = hSiteMgr; 206 pRxData->hOs = hOs; 207 pRxData->hReport = hReport; 208 pRxData->hMemMngr = hMemMngr; 209 pRxData->hExcMgr = hExcMngr; 210 pRxData->hEvHandler = hEvHandler; 211 212 pRxData->rxDataExcludeUnencrypted = DEF_EXCLUDE_UNENCYPTED; 213 pRxData->rxDataExludeBroadcastUnencrypted = DEF_EXCLUDE_UNENCYPTED; 214 pRxData->rxDataEapolDestination = DEF_EAPOL_DESTINATION; 215 pRxData->rxDataPortStatus = DEF_RX_PORT_STATUS; 216 217 /* 218 * configure rx data dispatcher 219 */ 220 221 222 /* port status close */ 223 pRxData->rxData_dispatchMsdu[CLOSE][DATA_DATA_PACKET] = &rxData_discardMsdu; /* data */ 224 pRxData->rxData_dispatchMsdu[CLOSE][DATA_EAPOL_PACKET] = &rxData_discardMsdu; /* eapol */ 225 pRxData->rxData_dispatchMsdu[CLOSE][DATA_IAPP_PACKET] = &rxData_discardMsdu; /* Iapp */ 226 pRxData->rxData_dispatchMsdu[CLOSE][DATA_VLAN_PACKET] = &rxData_discardMsduVlan; /* VLAN */ 227 228 /* port status open notify */ 229 pRxData->rxData_dispatchMsdu[OPEN_NOTIFY][DATA_DATA_PACKET] = &rxData_rcvMsduInOpenNotify; /* data */ 230 pRxData->rxData_dispatchMsdu[OPEN_NOTIFY][DATA_EAPOL_PACKET] = &rxData_rcvMsduInOpenNotify; /* eapol */ 231 pRxData->rxData_dispatchMsdu[OPEN_NOTIFY][DATA_IAPP_PACKET] = &rxData_rcvMsduInOpenNotify; /* Iapp */ 232 pRxData->rxData_dispatchMsdu[OPEN_NOTIFY][DATA_VLAN_PACKET] = &rxData_discardMsduVlan; /* VLAN */ 233 234 /* port status open eapol */ 235 pRxData->rxData_dispatchMsdu[OPEN_EAPOL][DATA_DATA_PACKET] = &rxData_discardMsdu; /* data */ 236 pRxData->rxData_dispatchMsdu[OPEN_EAPOL][DATA_EAPOL_PACKET] = &rxData_rcvMsduEapol; /* eapol */ 237 pRxData->rxData_dispatchMsdu[OPEN_EAPOL][DATA_IAPP_PACKET] = &rxData_discardMsdu; /* Iapp */ 238 pRxData->rxData_dispatchMsdu[OPEN_EAPOL][DATA_VLAN_PACKET] = &rxData_discardMsduVlan; /* VLAN */ 239 240 /* port status open */ 241 pRxData->rxData_dispatchMsdu[OPEN][DATA_DATA_PACKET] = &rxData_rcvMsduData; /* data */ 242 pRxData->rxData_dispatchMsdu[OPEN][DATA_EAPOL_PACKET] = &rxData_rcvMsduEapol; /* eapol */ 243 #ifdef EXC_MODULE_INCLUDED 244 pRxData->rxData_dispatchMsdu[OPEN][DATA_IAPP_PACKET] = &rxData_rcvMsduIapp; /* Iapp */ 245 #else 246 pRxData->rxData_dispatchMsdu[OPEN][DATA_IAPP_PACKET] = &rxData_rcvMsduData; /* Iapp */ 247 #endif 248 pRxData->rxData_dispatchMsdu[OPEN][DATA_VLAN_PACKET] = &rxData_discardMsduVlan;/* VLAN */ 249 250 /* register CB's for request buffer and receive CB to the lower layers */ 251 TnetwDrv_Register_CB(pRxData->hTnetwDrv,TNETW_DRIVER_RX_RECEIVE_PACKET,(void *)rxData_ReceivePacket,hRxData); 252 TnetwDrv_Register_CB(pRxData->hTnetwDrv,TNETW_DRIVER_RX_REQUEST_FOR_BUFFER,(void *)rxData_RequestForBuffer,hRxData); 253 254 /* init rx data filters */ 255 pRxData->filteringEnabled = rxDataInitParams->rxDataFiltersEnabled; 256 pRxData->filteringDefaultAction = rxDataInitParams->rxDataFiltersDefaultAction; 257 258 whalCtrl_setRxDataFiltersParams(pRxData->hHalCtrl, pRxData->filteringEnabled, pRxData->filteringDefaultAction); 259 260 for (i = 0; i < MAX_DATA_FILTERS; ++i) 261 { 262 if (rxDataInitParams->rxDataFilterRequests[i].maskLength > 0) 263 { 264 if (rxData_addRxDataFilter(hRxData, &rxDataInitParams->rxDataFilterRequests[i]) != OK) 265 { 266 WLAN_REPORT_ERROR(pRxData->hReport, RX_DATA_MODULE_LOG, 267 ("%s: Invalid Rx Data Filter configured at init stage (at index %d)!\n", __FUNCTION__, i)); 268 } 269 } 270 } 271 272 #ifdef TI_DBG 273 /* reset counters */ 274 rxData_resetCounters(pRxData); 275 rxData_resetDbgCounters(pRxData); 276 #endif 277 278 WLAN_REPORT_INIT(pRxData->hReport, RX_DATA_MODULE_LOG, 279 (".....Rx Data configured successfully\n")); 280 281 return OK; 282 283 } 284 285 /*************************************************************************** 286 * rxData_unLoad * 287 **************************************************************************** 288 * DESCRIPTION: This function unload the Rx data module. 289 * 290 * INPUTS: hRxData - the object 291 * 292 * OUTPUT: 293 * 294 * RETURNS: OK - Unload succesfull 295 * NOK - Unload unsuccesfull 296 ***************************************************************************/ 297 298 299 TI_STATUS rxData_unLoad(TI_HANDLE hRxData) 300 { 301 rxData_t *pRxData = (rxData_t *)hRxData; 302 303 /* check parameters validity */ 304 if( pRxData == NULL ) 305 { 306 WLAN_REPORT_ERROR(pRxData->hReport, RX_DATA_MODULE_LOG, 307 (" rxData_unLoad() : Illegal value for hRxData\n")); 308 return NOK; 309 } 310 311 DistributorMgr_Destroy(pRxData->RxEventDistributor); 312 313 /* destroy periodic rx throughput timer */ 314 #ifdef TI_DBG 315 utils_nullTimerDestroy (pRxData->hOs, pRxData->hThroughputTimer); 316 #endif 317 318 /* free Rx Data controll block */ 319 os_memoryFree(pRxData->hOs, pRxData, sizeof(rxData_t)); 320 321 return OK; 322 } 323 324 325 /*************************************************************************** 326 * rxData_stop * 327 **************************************************************************** 328 * DESCRIPTION: this function stop the rx data. 329 * 330 * INPUTS: hRxData - the object 331 * 332 * OUTPUT: 333 * 334 * RETURNS: OK - stop succesfull 335 * NOK - stop unsuccesfull 336 ***************************************************************************/ 337 338 TI_STATUS rxData_stop(TI_HANDLE hRxData) 339 { 340 rxData_t *pRxData = (rxData_t *)hRxData; 341 342 /* check parameters validity */ 343 if( pRxData == NULL ) 344 { 345 WLAN_REPORT_ERROR(pRxData->hReport, RX_DATA_MODULE_LOG, 346 (" rxData_stop() : Illegal value for hRxData\n")); 347 return NOK; 348 } 349 350 pRxData->rxDataExcludeUnencrypted = DEF_EXCLUDE_UNENCYPTED; 351 pRxData->rxDataExludeBroadcastUnencrypted = DEF_EXCLUDE_UNENCYPTED; 352 pRxData->rxDataEapolDestination = DEF_EAPOL_DESTINATION; 353 pRxData->rxDataPortStatus = DEF_RX_PORT_STATUS; 354 355 #ifdef TI_DBG 356 /* reset counters */ 357 /*rxData_resetCounters(pRxData);*/ 358 /*rxData_resetDbgCounters(pRxData);*/ 359 360 /* stop throughput timer */ 361 if (pRxData->rxThroughputTimerEnable) 362 { 363 os_timerStop (pRxData->hOs, pRxData->hThroughputTimer); 364 pRxData->rxThroughputTimerEnable = FALSE; 365 } 366 #endif 367 368 WLAN_REPORT_INFORMATION(pRxData->hReport, RX_DATA_MODULE_LOG, 369 (" rxData_stop() : Succeeded.\n")); 370 371 return OK; 372 373 } 374 375 /*************************************************************************** 376 * rxData_getParam * 377 **************************************************************************** 378 * DESCRIPTION: get a specific parameter 379 * 380 * INPUTS: hRxData - the object 381 * 382 * OUTPUT: pParamInfo - structure which include the value of 383 * the requested parameter 384 * 385 * RETURNS: OK 386 * NOK 387 ***************************************************************************/ 388 389 TI_STATUS rxData_getParam(TI_HANDLE hRxData, paramInfo_t *pParamInfo) 390 { 391 rxData_t *pRxData = (rxData_t *)hRxData; 392 393 /* check handle validity */ 394 if( pRxData == NULL ) 395 { 396 WLAN_REPORT_ERROR(pRxData->hReport, RX_DATA_MODULE_LOG, 397 (" rxData_getParam() : Illegal parametrs value \n")); 398 return NOK; 399 } 400 401 switch (pParamInfo->paramType) 402 { 403 case RX_DATA_EXCLUDE_UNENCRYPTED_PARAM: 404 pParamInfo->content.rxDataExcludeUnencrypted = pRxData->rxDataExcludeUnencrypted; 405 break; 406 407 case RX_DATA_EAPOL_DESTINATION_PARAM: 408 pParamInfo->content.rxDataEapolDestination = pRxData->rxDataEapolDestination; 409 break; 410 411 case RX_DATA_PORT_STATUS_PARAM: 412 pParamInfo->content.rxDataPortStatus = pRxData->rxDataPortStatus; 413 break; 414 415 case RX_DATA_COUNTERS_PARAM: 416 pParamInfo->content.siteMgrTiWlanCounters.RecvOk = pRxData->rxDataCounters.RecvOk; 417 pParamInfo->content.siteMgrTiWlanCounters.DirectedBytesRecv = pRxData->rxDataCounters.DirectedBytesRecv; 418 pParamInfo->content.siteMgrTiWlanCounters.DirectedFramesRecv = pRxData->rxDataCounters.DirectedFramesRecv; 419 pParamInfo->content.siteMgrTiWlanCounters.MulticastBytesRecv = pRxData->rxDataCounters.MulticastBytesRecv; 420 pParamInfo->content.siteMgrTiWlanCounters.MulticastFramesRecv = pRxData->rxDataCounters.MulticastFramesRecv; 421 pParamInfo->content.siteMgrTiWlanCounters.BroadcastBytesRecv = pRxData->rxDataCounters.BroadcastBytesRecv; 422 pParamInfo->content.siteMgrTiWlanCounters.BroadcastFramesRecv = pRxData->rxDataCounters.BroadcastFramesRecv; 423 break; 424 425 case RX_DATA_GET_RX_DATA_FILTERS_STATISTICS: 426 whalCtrl_getRxDataFiltersStatistics(pRxData->hHalCtrl, 427 pParamInfo->content.interogateCmdCBParams.CB_Func, 428 pParamInfo->content.interogateCmdCBParams.CB_handle, 429 pParamInfo->content.interogateCmdCBParams.CB_buf); 430 431 break; 432 433 434 default: 435 return (PARAM_NOT_SUPPORTED); 436 /* WLAN_REPORT_ERROR(pRxData->hReport, RX_DATA_MODULE_LOG, 437 (" rxData_getParam() : PARAMETER NOT SUPPORTED \n")); 438 return NOK; 439 break; - unreachable */ 440 } 441 442 443 return (OK); 444 445 } 446 447 /*************************************************************************** 448 * rxData_setParam * 449 **************************************************************************** 450 * DESCRIPTION: set a specific parameter 451 * 452 * INPUTS: hRxData - the object 453 * pParamInfo - structure which include the value to set for 454 * the requested parameter 455 * 456 * OUTPUT: 457 * 458 * RETURNS: OK 459 * NOK 460 ***************************************************************************/ 461 462 TI_STATUS rxData_setParam(TI_HANDLE hRxData, paramInfo_t *pParamInfo) 463 { 464 rxData_t *pRxData = (rxData_t *)hRxData; 465 466 /* check handle validity */ 467 if( pRxData == NULL ) 468 { 469 WLAN_REPORT_ERROR(pRxData->hReport, RX_DATA_MODULE_LOG, 470 (" rxData_setParam(): Illegal parametrs value \n")); 471 return NOK; 472 } 473 474 switch (pParamInfo->paramType) 475 { 476 case RX_DATA_EXCLUDE_UNENCRYPTED_PARAM: 477 pRxData->rxDataExcludeUnencrypted = pParamInfo->content.rxDataExcludeUnencrypted; 478 break; 479 case RX_DATA_EXCLUDE_BROADCAST_UNENCRYPTED_PARAM: 480 pRxData->rxDataExludeBroadcastUnencrypted = pParamInfo->content.rxDataExcludeUnencrypted; 481 break; 482 case RX_DATA_EAPOL_DESTINATION_PARAM: 483 pRxData->rxDataEapolDestination = pParamInfo->content.rxDataEapolDestination; 484 break; 485 486 case RX_DATA_PORT_STATUS_PARAM: 487 pRxData->rxDataPortStatus = pParamInfo->content.rxDataPortStatus; 488 break; 489 490 case RX_DATA_ENABLE_DISABLE_RX_DATA_FILTERS: 491 return rxData_enableDisableRxDataFilters(hRxData, pParamInfo->content.rxDataFilterEnableDisable); 492 493 case RX_DATA_ADD_RX_DATA_FILTER: 494 { 495 TIWLAN_DATA_FILTER_REQUEST * pRequest = &pParamInfo->content.rxDataFilterRequest; 496 rxDataFilterRequest_t filterRequest; 497 498 filterRequest.offset = pRequest->Offset; 499 filterRequest.maskLength = pRequest->MaskLength; 500 filterRequest.patternLength = pRequest->PatternLength; 501 502 os_memoryCopy(pRxData->hOs, (PVOID) filterRequest.mask, (PVOID) pRequest->Mask, sizeof(filterRequest.mask)); 503 os_memoryCopy(pRxData->hOs, (PVOID) filterRequest.pattern, (PVOID) pRequest->Pattern, sizeof(filterRequest.pattern)); 504 505 return rxData_addRxDataFilter(hRxData, &filterRequest); 506 } 507 508 case RX_DATA_REMOVE_RX_DATA_FILTER: 509 { 510 TIWLAN_DATA_FILTER_REQUEST * pRequest = &pParamInfo->content.rxDataFilterRequest; 511 rxDataFilterRequest_t filterRequest; 512 513 filterRequest.offset = pRequest->Offset; 514 filterRequest.maskLength = pRequest->MaskLength; 515 filterRequest.patternLength = pRequest->PatternLength; 516 517 os_memoryCopy(pRxData->hOs, (PVOID) filterRequest.mask, (PVOID) pRequest->Mask, sizeof(filterRequest.mask)); 518 os_memoryCopy(pRxData->hOs, (PVOID) filterRequest.pattern, (PVOID) pRequest->Pattern, sizeof(filterRequest.pattern)); 519 520 return rxData_removeRxDataFilter(hRxData, &filterRequest); 521 } 522 523 default: 524 return (PARAM_NOT_SUPPORTED); 525 /* WLAN_REPORT_ERROR(pRxData->hReport, RX_DATA_MODULE_LOG, 526 (" rxData_setParam() : PARAMETER NOT SUPPORTED \n")); 527 return NOK; 528 break; - unreachable */ 529 } 530 531 return (OK); 532 } 533 534 535 /*************************************************************************** 536 * rxData_enableDisableRxDataFilters * 537 **************************************************************************** 538 * DESCRIPTION: 539 * 540 * 541 * INPUTS: 542 * 543 * 544 * 545 * OUTPUT: 546 * 547 * RETURNS: 548 * 549 ***************************************************************************/ 550 static TI_STATUS rxData_enableDisableRxDataFilters(TI_HANDLE hRxData, BOOL enabled) 551 { 552 rxData_t * pRxData = (rxData_t *) hRxData; 553 554 /* assert 0 or 1 */ 555 if (enabled != 0) 556 enabled = 1; 557 558 if (enabled == pRxData->filteringEnabled) 559 return OK; 560 561 pRxData->filteringEnabled = enabled; 562 563 564 return (TI_STATUS) whalCtrl_setRxDataFiltersParams(pRxData->hHalCtrl, pRxData->filteringEnabled, pRxData->filteringDefaultAction); 565 } 566 567 /*************************************************************************** 568 * findFilterRequest * 569 **************************************************************************** 570 * DESCRIPTION: 571 * 572 * 573 * INPUTS: 574 * 575 * 576 * 577 * OUTPUT: 578 * 579 * RETURNS: 580 * 581 ***************************************************************************/ 582 static int findFilterRequest(TI_HANDLE hRxData, rxDataFilterRequest_t * request) 583 { 584 rxData_t * pRxData = (rxData_t *) hRxData; 585 int i; 586 587 for (i = 0; i < MAX_DATA_FILTERS; ++i) 588 { 589 if (pRxData->isFilterSet[i]) 590 { 591 if ((pRxData->filterRequests[i].offset == request->offset) && 592 (pRxData->filterRequests[i].maskLength == request->maskLength) && 593 (pRxData->filterRequests[i].patternLength == request->patternLength)) 594 { 595 if ((os_memoryCompare(pRxData->hOs, pRxData->filterRequests[i].mask, request->mask, request->maskLength) == 0) && 596 (os_memoryCompare(pRxData->hOs, pRxData->filterRequests[i].pattern, request->pattern, request->patternLength) == 0)) 597 return i; 598 } 599 } 600 } 601 602 return -1; 603 } 604 605 /*************************************************************************** 606 * closeFieldPattern * 607 **************************************************************************** 608 * DESCRIPTION: 609 * 610 * 611 * INPUTS: 612 * 613 * 614 * 615 * OUTPUT: 616 * 617 * RETURNS: 618 * 619 ***************************************************************************/ 620 static void closeFieldPattern(rxData_t * pRxData, rxDataFilterFieldPattern_t * fieldPattern, UINT8 * fieldPatterns, UINT8 * lenFieldPatterns) 621 { 622 fieldPatterns[*lenFieldPatterns] = fieldPattern->offset; 623 *lenFieldPatterns += sizeof(fieldPattern->offset); 624 625 fieldPatterns[*lenFieldPatterns] = fieldPattern->length; 626 *lenFieldPatterns += sizeof(fieldPattern->length); 627 628 fieldPatterns[*lenFieldPatterns] = fieldPattern->flag; 629 *lenFieldPatterns += sizeof(fieldPattern->flag); 630 631 os_memoryCopy(pRxData->hOs, fieldPatterns + *lenFieldPatterns, fieldPattern->pattern, fieldPattern->length); 632 *lenFieldPatterns += fieldPattern->length; 633 634 /* if the pattern bit mask is enabled add it to the end of the request */ 635 if ((fieldPattern->flag & RX_DATA_FILTER_FLAG_USE_BIT_MASK) == RX_DATA_FILTER_FLAG_USE_BIT_MASK) 636 { 637 os_memoryCopy(pRxData->hOs, fieldPatterns + *lenFieldPatterns, fieldPattern->mask, fieldPattern->length); 638 *lenFieldPatterns += fieldPattern->length; 639 } 640 641 WLAN_REPORT_INFORMATION(pRxData->hReport, RX_DATA_MODULE_LOG, ("%s: Closed field pattern, length = %d, total length = %d, pattern bit mask = %d.\n", __FUNCTION__, fieldPattern->length, *lenFieldPatterns, ((fieldPattern->flag & RX_DATA_FILTER_FLAG_USE_BIT_MASK) == RX_DATA_FILTER_FLAG_USE_BIT_MASK))); 642 } 643 644 645 /*************************************************************************** 646 * parseRxDataFilterRequest * 647 **************************************************************************** 648 * DESCRIPTION: 649 * 650 * 651 * INPUTS: 652 * 653 * 654 * 655 * OUTPUT: 656 * 657 * RETURNS: 658 * 659 ***************************************************************************/ 660 static int parseRxDataFilterRequest(TI_HANDLE hRxData, rxDataFilterRequest_t * request, UINT8 * numFieldPatterns, UINT8 * lenFieldPatterns, UINT8 * fieldPatterns) 661 { 662 rxData_t * pRxData = (rxData_t *) hRxData; 663 664 int maskIter; 665 int patternIter = 0; 666 667 /* used to store field patterns while they are built */ 668 BOOL isBuildingFieldPattern = FALSE; 669 rxDataFilterFieldPattern_t fieldPattern; 670 671 for (maskIter = 0; maskIter < request->maskLength * BIT_TO_BYTE_FACTOR; ++maskIter) 672 { 673 /* which byte in the mask and which bit in the byte we're at */ 674 int bit = maskIter % BIT_TO_BYTE_FACTOR; 675 int byte = maskIter / BIT_TO_BYTE_FACTOR; 676 677 /* is the bit in the mask set */ 678 BOOL isSet = ((request->mask[byte] & (1 << bit)) == (1 << bit)); 679 680 WLAN_REPORT_INFORMATION(pRxData->hReport, RX_DATA_MODULE_LOG, 681 ("%s: MaskIter = %d, Byte = %d, Bit = %d, isSet = %d\n", __FUNCTION__, maskIter, byte, bit, isSet)); 682 683 /* if we're in the midst of building a field pattern, we need to close in case */ 684 /* the current bit is not set or we've reached the ethernet header boundary */ 685 if (isBuildingFieldPattern) 686 { 687 if ((isSet == FALSE) || (request->offset + maskIter == RX_DATA_FILTER_ETHERNET_HEADER_BOUNDARY)) 688 { 689 closeFieldPattern(hRxData, &fieldPattern, fieldPatterns, lenFieldPatterns); 690 691 isBuildingFieldPattern = FALSE; 692 } 693 } 694 695 /* nothing to do in case the bit is not set */ 696 if (isSet) 697 { 698 /* if not already building a field pattern, create a new one */ 699 if (isBuildingFieldPattern == FALSE) 700 { 701 WLAN_REPORT_INFORMATION(pRxData->hReport, RX_DATA_MODULE_LOG, 702 ("%s: Creating a new field pattern.\n", __FUNCTION__)); 703 704 isBuildingFieldPattern = TRUE; 705 ++(*numFieldPatterns); 706 707 if (*numFieldPatterns > RX_DATA_FILTER_MAX_FIELD_PATTERNS) 708 { 709 WLAN_REPORT_ERROR(pRxData->hReport, RX_DATA_MODULE_LOG, 710 ("%s: Invalid filter, too many field patterns, maximum of %u is allowed!\n", __FUNCTION__, RX_DATA_FILTER_MAX_FIELD_PATTERNS)); 711 712 return NOK; 713 } 714 715 fieldPattern.offset = request->offset + maskIter; 716 fieldPattern.length = 0; 717 718 /* we don't support the mask per bit feature yet. */ 719 fieldPattern.flag = RX_DATA_FILTER_FLAG_NO_BIT_MASK; 720 721 /* first 14 bits are used for the Ethernet header, rest for the IP header */ 722 if (fieldPattern.offset < RX_DATA_FILTER_ETHERNET_HEADER_BOUNDARY) 723 { 724 fieldPattern.flag |= RX_DATA_FILTER_FLAG_ETHERNET_HEADER; 725 } 726 else 727 { 728 fieldPattern.flag |= RX_DATA_FILTER_FLAG_IP_HEADER; 729 fieldPattern.offset -= RX_DATA_FILTER_ETHERNET_HEADER_BOUNDARY; 730 } 731 732 WLAN_REPORT_INFORMATION(pRxData->hReport, RX_DATA_MODULE_LOG, 733 ("%s: offset = %d, flag = %d.\n", __FUNCTION__, fieldPattern.offset, fieldPattern.flag)); 734 } 735 736 /* check that the pattern is long enough */ 737 if (patternIter > request->patternLength) 738 { 739 WLAN_REPORT_ERROR(pRxData->hReport, RX_DATA_MODULE_LOG, 740 ("%s: Invalid filter, mask and pattern lengths are not consistent!\n", __FUNCTION__)); 741 742 return NOK; 743 } 744 745 /* add the current pattern byte to the field pattern */ 746 fieldPattern.pattern[fieldPattern.length++] = request->pattern[patternIter++]; 747 748 /* check pattern matching boundary */ 749 if (fieldPattern.offset + fieldPattern.length >= RX_DATA_FILTER_FILTER_BOUNDARY) 750 { 751 WLAN_REPORT_ERROR(pRxData->hReport, RX_DATA_MODULE_LOG, 752 ("%s: Invalid filter, pattern matching cannot exceed first %u characters.\n", __FUNCTION__, RX_DATA_FILTER_FILTER_BOUNDARY)); 753 754 return NOK; 755 } 756 } 757 } 758 759 /* check that the pattern is long enough */ 760 if (patternIter != request->patternLength) 761 { 762 WLAN_REPORT_ERROR(pRxData->hReport, RX_DATA_MODULE_LOG, 763 ("%s: Invalid filter, mask and pattern lengths are not consistent!\n", __FUNCTION__)); 764 765 return NOK; 766 } 767 768 /* close the last field pattern if needed */ 769 if (isBuildingFieldPattern) 770 { 771 closeFieldPattern(hRxData, &fieldPattern, fieldPatterns, lenFieldPatterns); 772 } 773 774 return OK; 775 } 776 777 778 /*************************************************************************** 779 * rxData_setRxDataFilter * 780 **************************************************************************** 781 * DESCRIPTION: 782 * 783 * 784 * INPUTS: 785 * 786 * 787 * 788 * OUTPUT: 789 * 790 * RETURNS: 791 * 792 ***************************************************************************/ 793 static TI_STATUS rxData_addRxDataFilter(TI_HANDLE hRxData, rxDataFilterRequest_t * request) 794 { 795 rxData_t * pRxData = (rxData_t *) hRxData; 796 797 /* firmware request fields */ 798 UINT8 index = 0; 799 UINT8 numFieldPatterns = 0; 800 UINT8 lenFieldPatterns = 0; 801 UINT8 fieldPatterns[MAX_DATA_FILTER_SIZE]; 802 803 WLAN_REPORT_INFORMATION(pRxData->hReport, RX_DATA_MODULE_LOG, 804 ("rxData_addRxDataFilter, offset=0x%x, maskLength=0x%x, patternLength=0x%x\n", 805 request->offset, 806 request->maskLength, 807 request->patternLength)); 808 809 WLAN_REPORT_HEX_INFORMATION(pRxData->hReport, RX_DATA_MODULE_LOG, request->mask, request->maskLength); 810 WLAN_REPORT_HEX_INFORMATION(pRxData->hReport, RX_DATA_MODULE_LOG, request->pattern, request->patternLength); 811 812 /* does the filter already exist? */ 813 if (findFilterRequest(hRxData, request) >= 0) 814 { 815 WLAN_REPORT_INFORMATION(pRxData->hReport, RX_DATA_MODULE_LOG, 816 ("%s: Filter already exists.\n", __FUNCTION__)); 817 818 return RX_FILTER_ALREADY_EXISTS; 819 } 820 821 /* find place for insertion */ 822 for (index = 0; index < MAX_DATA_FILTERS; ++index) 823 { 824 if (pRxData->isFilterSet[index] == FALSE) 825 break; 826 } 827 828 /* are all filter slots taken? */ 829 if (index == MAX_DATA_FILTERS) 830 { 831 WLAN_REPORT_ERROR(pRxData->hReport, RX_DATA_MODULE_LOG, 832 ("%s: No place to insert filter!\n", __FUNCTION__)); 833 834 return RX_NO_AVAILABLE_FILTERS; 835 } 836 837 WLAN_REPORT_INFORMATION(pRxData->hReport, RX_DATA_MODULE_LOG, 838 ("%s: Inserting filter at index %d.\n", __FUNCTION__, index)); 839 840 /* parse the filter request into discrete field patterns */ 841 if (parseRxDataFilterRequest(hRxData, request, &numFieldPatterns, &lenFieldPatterns, fieldPatterns) != OK) 842 return NOK; 843 844 if (numFieldPatterns == 0) 845 return NOK; 846 847 /* store configuration for future manipulation */ 848 pRxData->isFilterSet[index] = TRUE; 849 os_memoryCopy(pRxData->hOs, &pRxData->filterRequests[index], request, sizeof(pRxData->filterRequests[index])); 850 851 /* send configuration to firmware */ 852 return (TI_STATUS) whalCtrl_setRxDataFilter(pRxData->hHalCtrl, index, ADD_FILTER, FILTER_SIGNAL, 853 numFieldPatterns, lenFieldPatterns, fieldPatterns); 854 855 return OK; 856 857 } 858 859 /*************************************************************************** 860 * rxData_removeRxDataFilter * 861 **************************************************************************** 862 * DESCRIPTION: 863 * 864 * 865 * INPUTS: 866 * 867 * 868 * 869 * OUTPUT: 870 * 871 * RETURNS: 872 * 873 ***************************************************************************/ 874 static TI_STATUS rxData_removeRxDataFilter(TI_HANDLE hRxData, rxDataFilterRequest_t * request) 875 { 876 rxData_t * pRxData = (rxData_t *) hRxData; 877 878 int index = findFilterRequest(hRxData, request); 879 880 WLAN_REPORT_INFORMATION(pRxData->hOs, RX_DATA_MODULE_LOG, 881 ("rxData_removeRxDataFilter, offset=0x%x, maskLength=0x%x, patternLength=0x%x\n", 882 request->offset, 883 request->maskLength, 884 request->patternLength)); 885 886 WLAN_REPORT_HEX_INFORMATION(pRxData->hReport, RX_DATA_MODULE_LOG, request->mask, request->maskLength); 887 WLAN_REPORT_HEX_INFORMATION(pRxData->hReport, RX_DATA_MODULE_LOG, request->pattern, request->patternLength); 888 889 /* does the filter exist? */ 890 if (index < 0) 891 { 892 WLAN_REPORT_WARNING(pRxData->hOs, RX_DATA_MODULE_LOG, 893 ("%s: Remove data filter request received but the specified filter was not found!", __FUNCTION__)); 894 895 return RX_FILTER_DOES_NOT_EXIST; 896 } 897 898 WLAN_REPORT_INFORMATION(pRxData->hOs, RX_DATA_MODULE_LOG, 899 ("%s: Removing filter at index %d.", __FUNCTION__, index)); 900 901 pRxData->isFilterSet[index] = FALSE; 902 903 return (TI_STATUS) whalCtrl_setRxDataFilter(pRxData->hHalCtrl, index, REMOVE_FILTER, 904 FILTER_SIGNAL, 0, 0, NULL); 905 906 return OK; 907 908 909 } 910 911 /*************************************************************************** 912 * rxData_DistributorRxEvent * 913 **************************************************************************** 914 * DESCRIPTION: 915 * 916 * 917 * INPUTS: 918 * 919 * 920 * 921 * OUTPUT: 922 * 923 * RETURNS: 924 * 925 ***************************************************************************/ 926 static VOID rxData_DistributorRxEvent(rxData_t *pRxData,UINT16 Mask,int DataLen) 927 { 928 DistributorMgr_EventCall(pRxData->RxEventDistributor,Mask,DataLen); 929 } 930 931 /*************************************************************************** 932 * rxData_RegNotif * 933 ****************************************************************************/ 934 TI_HANDLE rxData_RegNotif(TI_HANDLE hRxData,UINT16 EventMask,GeneralEventCall_t CallBack,TI_HANDLE context,UINT32 Cookie) 935 { 936 rxData_t *pRxData = (rxData_t *)hRxData; 937 if (!hRxData) 938 return NULL; 939 return DistributorMgr_Reg(pRxData->RxEventDistributor,EventMask,(TI_HANDLE)CallBack,context,Cookie); 940 } 941 942 /*************************************************************************** 943 * rxData_AddToNotifMask * 944 ****************************************************************************/ 945 TI_STATUS rxData_AddToNotifMask(TI_HANDLE hRxData,TI_HANDLE Notifh,UINT16 EventMask) 946 { 947 rxData_t *pRxData = (rxData_t *)hRxData; 948 if (!hRxData) 949 return NOK; 950 return DistributorMgr_AddToMask(pRxData->RxEventDistributor,Notifh,EventMask); 951 } 952 953 954 /*************************************************************************** 955 * rxData_UnRegNotif * 956 ****************************************************************************/ 957 TI_STATUS rxData_UnRegNotif(TI_HANDLE hRxData,TI_HANDLE RegEventHandle) 958 { 959 TI_STATUS status; 960 rxData_t *pRxData = (rxData_t *)hRxData; 961 962 if (!hRxData) 963 return NOK; 964 965 status = DistributorMgr_UnReg(pRxData->RxEventDistributor,RegEventHandle); 966 return (status); 967 } 968 969 970 /*************************************************************************** 971 * rxData_receiveMsduFromWlan * 972 **************************************************************************** 973 * DESCRIPTION: this function is called by the GWSI for each received msdu. 974 * It filter and distribute the received msdu. 975 * 976 * INPUTS: hRxData - the object 977 * pMsdu - the received msdu. 978 * pRxAttr - Rx attributes 979 * 980 * OUTPUT: 981 * 982 * RETURNS: 983 ***************************************************************************/ 984 void rxData_receiveMsduFromWlan(TI_HANDLE hRxData, mem_MSDU_T *pMsdu, Rx_attr_t* pRxAttr) 985 { 986 rxData_t *pRxData = (rxData_t *)hRxData; 987 macAddress_t address3; 988 dot11_header_t *pDot11Hdr; 989 UINT16 tmpFCtrl; 990 991 WLAN_REPORT_INFORMATION(pRxData->hReport, RX_DATA_MODULE_LOG, 992 (" rxData_receiveMsduFromWlan() : pRxAttr->packetType = %d\n", pRxAttr->packetType)); 993 994 switch (pRxAttr->packetType) 995 { 996 case RX_PACKET_TYPE_MANAGEMENT: 997 998 WLAN_REPORT_INFORMATION(pRxData->hReport, RX_DATA_MODULE_LOG, 999 (" rxData_receiveMsduFromWlan() : Received management msdu len = %d\n", pMsdu->dataLen)); 1000 1001 /* update siteMngr 1002 * 1003 * the BSSID in mgmt frames is always addr3 in the header 1004 * must copy address3 since msdu is freed in mlmeParser_recv 1005 */ 1006 pDot11Hdr = (dot11_header_t*)(memMgr_BufData(pMsdu->firstBDPtr) 1007 +memMgr_BufOffset(pMsdu->firstBDPtr)); 1008 os_memoryCopy(pRxData->hOs, &address3, &pDot11Hdr->address3, sizeof(address3)); 1009 1010 tmpFCtrl = ((pDot11Hdr->fc & DOT11_FC_SUB_MASK) >> 4) ; 1011 if((tmpFCtrl == BEACON) || (tmpFCtrl == PROBE_RESPONSE)) 1012 { 1013 if (NOK == siteMgr_CheckRxSignalValidity(pRxData->hSiteMgr, pRxAttr->Rssi, pRxAttr->channel,&address3)) 1014 { 1015 wlan_memMngrFreeMSDU(pRxData->hMemMngr, memMgr_MsduHandle(pMsdu)); 1016 break; 1017 } 1018 } 1019 1020 /* distribute mgmt msdu to mlme */ 1021 wlan_memMngrChangeMsduOwner(pRxData->hMemMngr,MLME_RX_MODULE,pMsdu); 1022 1023 if( mlmeParser_recv(pRxData->hMlme, pMsdu, pRxAttr) != OK ) 1024 { 1025 WLAN_REPORT_WARNING(pRxData->hReport, RX_DATA_MODULE_LOG, 1026 (" rxData_receiveMsduFromWlan() : error sending msdu to MLME \n")); 1027 break; 1028 } 1029 1030 1031 if((tmpFCtrl == BEACON) || (tmpFCtrl == PROBE_RESPONSE)) 1032 { 1033 siteMgr_updateRxSignal(pRxData->hSiteMgr, pRxAttr->SNR, 1034 pRxAttr->Rssi, pRxAttr->Rate, &address3, FALSE); 1035 /*WLAN_REPORT_INFORMATION(pRxData->hReport, RX_DATA_MODULE_LOG, 1036 (" SIGNAL QUALITY :RX_LEVEL = %d :: SNR = %d \n", pRxAttr->RxLevel,pRxAttr->SNR)); */ 1037 } 1038 1039 break; 1040 1041 case RX_PACKET_TYPE_DATA: 1042 WLAN_REPORT_INFORMATION(pRxData->hReport, RX_DATA_MODULE_LOG, 1043 (" rxData_receiveMsduFromWlan() : Received Data MSDU len = %d\n", pMsdu->dataLen)); 1044 1045 /* send MSDU to data dispatcher */ 1046 rxData_dataMsduDisptcher(hRxData, pMsdu, pRxAttr); 1047 1048 break; 1049 1050 default: 1051 WLAN_REPORT_ERROR(pRxData->hReport, RX_DATA_MODULE_LOG, 1052 (" rxData_receiveMsduFromWlan() : Received unspecified packet type !!! \n")); 1053 1054 WLAN_REPORT_DEBUG_RX(pRxData->hReport, 1055 (" rxData_receiveMsduFromWlan() : Received unspecified packet type !!! \n")); 1056 1057 1058 wlan_memMngrFreeMSDU(pRxData->hMemMngr, memMgr_MsduHandle(pMsdu)); 1059 break; 1060 } 1061 } 1062 /*************************************************************************** 1063 * rxData_dataMsduDisptcher * 1064 **************************************************************************** 1065 * DESCRIPTION: this function is called upon receving data MSDU, 1066 * it dispatches the packet to the approciate function according to 1067 * data packet type and rx port status. 1068 * 1069 * INPUTS: hRxData - the object 1070 * pMsdu - the received msdu. 1071 * pRxAttr - Rx attributes 1072 * 1073 * OUTPUT: 1074 * 1075 * RETURNS: 1076 ***************************************************************************/ 1077 1078 static void rxData_dataMsduDisptcher(TI_HANDLE hRxData, mem_MSDU_T *pMsdu, Rx_attr_t* pRxAttr) 1079 { 1080 rxData_t *pRxData = (rxData_t *)hRxData; 1081 portStatus_e DataPortStatus; 1082 rxDataPacketType_e DataPacketType; 1083 1084 1085 /* get rx port status */ 1086 DataPortStatus = pRxData->rxDataPortStatus; 1087 1088 /* discard data packets received while rx data port is closed */ 1089 if (DataPortStatus == CLOSE) 1090 { 1091 WLAN_REPORT_INFORMATION(pRxData->hReport, RX_DATA_MODULE_LOG, 1092 (" rxData_dataMsduDisptcher() : Received Data msdu while Rx data port is closed \n", pMsdu->dataLen)); 1093 1094 rxData_discardMsdu(hRxData,pMsdu, pRxAttr); 1095 return; 1096 } 1097 1098 /* get data packet type */ 1099 1100 #ifdef EXC_MODULE_INCLUDED 1101 if (excMngr_isIappPacket(pRxData->hExcMgr, pMsdu) == TRUE) 1102 { 1103 WLAN_REPORT_INFORMATION(pRxData->hReport, RX_DATA_MODULE_LOG, 1104 (" rxData_dataMsduDisptcher() : Received Iapp msdu \n")); 1105 1106 DataPacketType = DATA_IAPP_PACKET; 1107 1108 } 1109 else 1110 #endif 1111 { 1112 UINT16 etherType; 1113 EthernetHeader_t * pEthernetHeader; 1114 1115 /* 1116 * if Host processes received packets, the header translation 1117 * from WLAN to ETH is done here. The conversion has been moved 1118 * here so that IAPP packets aren't converted. 1119 */ 1120 rxData_convertWlanToEthHeader(hRxData,pMsdu,ðerType); 1121 1122 pEthernetHeader = (EthernetHeader_t *)(memMgr_BufData(pMsdu->firstBDPtr) + memMgr_BufOffset(pMsdu->firstBDPtr)); 1123 1124 if (etherType == ETHERTYPE_802_1D) 1125 { 1126 WLAN_REPORT_INFORMATION(pRxData->hReport, RX_DATA_MODULE_LOG, 1127 (" rxData_dataMsduDisptcher() : Received VLAN msdu \n")); 1128 1129 DataPacketType = DATA_VLAN_PACKET; 1130 1131 } 1132 else if(pEthernetHeader->TypeLength == EAPOL_PACKET) 1133 { 1134 WLAN_REPORT_INFORMATION(pRxData->hReport, RX_DATA_MODULE_LOG, 1135 (" rxData_dataMsduDisptcher() : Received Eapol msdu \n")); 1136 1137 DataPacketType = DATA_EAPOL_PACKET; 1138 1139 } 1140 else 1141 { 1142 WLAN_REPORT_INFORMATION(pRxData->hReport, RX_DATA_MODULE_LOG, 1143 (" rxData_dataMsduDisptcher() : Received Data msdu \n")); 1144 1145 DataPacketType = DATA_DATA_PACKET; 1146 } 1147 } 1148 1149 /* dispatch Msdu according to packet type and current rx data port status */ 1150 pRxData->rxData_dispatchMsdu[DataPortStatus][DataPacketType](hRxData,pMsdu,pRxAttr); 1151 1152 } 1153 /*************************************************************************** 1154 * rxData_discardMsdu * 1155 **************************************************************************** 1156 * DESCRIPTION: this function is called to discard MSDU 1157 * 1158 * INPUTS: hRxData - the object 1159 * pMsdu - the received msdu. 1160 * pRxAttr - Rx attributes 1161 * 1162 * OUTPUT: 1163 * 1164 * RETURNS: 1165 ***************************************************************************/ 1166 static void rxData_discardMsdu(TI_HANDLE hRxData, mem_MSDU_T *pMsdu, Rx_attr_t* pRxAttr) 1167 { 1168 1169 rxData_t *pRxData = (rxData_t *)hRxData; 1170 1171 WLAN_REPORT_INFORMATION(pRxData->hReport, RX_DATA_MODULE_LOG, 1172 (" rxData_discardMsdu: rx port status = %d , Msdu status = %d \n",pRxData->rxDataPortStatus,pRxAttr->status)); 1173 1174 WLAN_REPORT_DEBUG_RX(pRxData->hReport, 1175 (" rxData_discardMsdu: rx port status = %d , Msdu status = %d \n",pRxData->rxDataPortStatus,pRxAttr->status)); 1176 1177 1178 pRxData->rxDataDbgCounters.excludedFrameCounter++; 1179 1180 1181 /* free Msdu */ 1182 wlan_memMngrFreeMSDU(pRxData->hMemMngr, memMgr_MsduHandle(pMsdu)); 1183 1184 1185 } 1186 1187 /*************************************************************************** 1188 * rxData_discardMsduVlan * 1189 **************************************************************************** 1190 * DESCRIPTION: this function is called to discard MSDU 1191 * 1192 * INPUTS: hRxData - the object 1193 * pMsdu - the received msdu. 1194 * pRxAttr - Rx attributes 1195 * 1196 * OUTPUT: 1197 * 1198 * RETURNS: 1199 ***************************************************************************/ 1200 static void rxData_discardMsduVlan(TI_HANDLE hRxData, mem_MSDU_T *pMsdu, Rx_attr_t* pRxAttr) 1201 { 1202 1203 rxData_t *pRxData = (rxData_t *)hRxData; 1204 1205 1206 WLAN_REPORT_WARNING(pRxData->hReport, RX_DATA_MODULE_LOG, 1207 (" rxData_discardMsduVlan : drop packet that contains VLAN tag\n")); 1208 1209 pRxData->rxDataDbgCounters.rxDroppedDueToVLANIncludedCnt++; 1210 1211 1212 /* free Msdu */ 1213 wlan_memMngrFreeMSDU(pRxData->hMemMngr, memMgr_MsduHandle(pMsdu)); 1214 } 1215 1216 /*************************************************************************** 1217 * rxData_rcvMsduInOpenNotify * 1218 **************************************************************************** 1219 * DESCRIPTION: this function is called upon receving data Eapol packet type 1220 * while rx port status is "open notify" 1221 * 1222 * INPUTS: hRxData - the object 1223 * pMsdu - the received msdu. 1224 * pRxAttr - Rx attributes 1225 * 1226 * OUTPUT: 1227 * 1228 * RETURNS: 1229 ***************************************************************************/ 1230 static void rxData_rcvMsduInOpenNotify(TI_HANDLE hRxData, mem_MSDU_T *pMsdu, Rx_attr_t* pRxAttr) 1231 { 1232 rxData_t *pRxData = (rxData_t *)hRxData; 1233 1234 WLAN_REPORT_INFORMATION(pRxData->hReport, RX_DATA_MODULE_LOG, 1235 (" rxData_rcvMsduInOpenNotify: receiving data packet while in rx port status is open notify\n")); 1236 1237 WLAN_REPORT_DEBUG_RX(pRxData->hReport, 1238 (" rxData_rcvMsduInOpenNotify: ERROR !!! receiving data packet while in rx port status is open notify\n")); 1239 1240 pRxData->rxDataDbgCounters.rcvUnicastFrameInOpenNotify++; 1241 1242 /* free msdu */ 1243 wlan_memMngrFreeMSDU(pRxData->hMemMngr, memMgr_MsduHandle(pMsdu)); 1244 1245 } 1246 /*************************************************************************** 1247 * rxData_rcvMsduEapol * 1248 **************************************************************************** 1249 * DESCRIPTION: this function is called upon receving data Eapol packet type 1250 * while rx port status is "open eapol" 1251 * 1252 * INPUTS: hRxData - the object 1253 * pMsdu - the received msdu. 1254 * pRxAttr - Rx attributes 1255 * 1256 * OUTPUT: 1257 * 1258 * RETURNS: 1259 ***************************************************************************/ 1260 static void rxData_rcvMsduEapol(TI_HANDLE hRxData, mem_MSDU_T *pMsdu, Rx_attr_t* pRxAttr) 1261 { 1262 rxData_t *pRxData = (rxData_t *)hRxData; 1263 1264 WLAN_REPORT_INFORMATION(pRxData->hReport, RX_DATA_MODULE_LOG, 1265 (" rxData_rcvMsduEapol() : Received an EAPOL frame tranferred to OS\n")); 1266 1267 WLAN_REPORT_DEBUG_RX(pRxData->hReport, 1268 (" rxData_rcvMsduEapol() : Received an EAPOL frame tranferred to OS\n")); 1269 1270 EvHandlerSendEvent(pRxData->hEvHandler, IPC_EVENT_EAPOL, 1271 (UINT8*)(pMsdu->firstBDPtr->data + pMsdu->firstBDPtr->dataOffset), 1272 pMsdu->firstBDPtr->length); 1273 1274 wlan_memMngrChangeMsduOwner(pRxData->hMemMngr,OS_ABS_RX_MODULE,pMsdu); 1275 1276 os_receivePacket(pRxData->hOs, pMsdu, (UINT16)pMsdu->dataLen); 1277 1278 } 1279 /*************************************************************************** 1280 * rxData_rcvMsduData * 1281 **************************************************************************** 1282 * DESCRIPTION: this function is called upon receving data "data" packet type 1283 * while rx port status is "open" 1284 * 1285 * INPUTS: hRxData - the object 1286 * pMsdu - the received msdu. 1287 * pRxAttr - Rx attributes 1288 * 1289 * OUTPUT: 1290 * 1291 * RETURNS: 1292 ***************************************************************************/ 1293 static void rxData_rcvMsduData(TI_HANDLE hRxData, mem_MSDU_T *pMsdu, Rx_attr_t* pRxAttr) 1294 { 1295 #if defined(CONFIG_TROUT_PWRSINK) || defined(CONFIG_HTC_PWRSINK) 1296 extern unsigned long num_rx_pkt_new; 1297 #endif 1298 rxData_t *pRxData = (rxData_t *)hRxData; 1299 EthernetHeader_t *pEthernetHeader; 1300 UINT16 EventMask = 0; 1301 ctrlData_t *pCtrlData; 1302 1303 WLAN_REPORT_INFORMATION(pRxData->hReport, RX_DATA_MODULE_LOG, 1304 (" rxData_rcvMsduData() : Received DATA frame tranferred to OS\n")); 1305 1306 WLAN_REPORT_DEBUG_RX(pRxData->hReport, 1307 (" rxData_rcvMsduData() : Received DATA frame tranferred to OS\n")); 1308 1309 /* check encryption status */ 1310 pEthernetHeader = (EthernetHeader_t *)(memMgr_BufData(pMsdu->firstBDPtr) + memMgr_BufOffset(pMsdu->firstBDPtr)); 1311 if (IsMacAddressDirected(&pEthernetHeader->DstAddr)) 1312 { /* unicast frame */ 1313 if((pRxData->rxDataExcludeUnencrypted) && (!(pRxAttr->packetInfo & RX_PACKET_FLAGS_ENCRYPTION))) 1314 { 1315 pRxData->rxDataDbgCounters.excludedFrameCounter++; 1316 /* free msdu */ 1317 WLAN_REPORT_WARNING(pRxData->hReport, RX_DATA_MODULE_LOG, 1318 (" rxData_rcvMsduData() : exclude unicast unencrypted is TRUE & packet encryption is OFF\n")); 1319 1320 wlan_memMngrFreeMSDU(pRxData->hMemMngr, memMgr_MsduHandle(pMsdu)); 1321 return; 1322 } 1323 1324 } 1325 else 1326 { /* broadcast frame */ 1327 if ((pRxData->rxDataExludeBroadcastUnencrypted) && (!(pRxAttr->packetInfo & RX_PACKET_FLAGS_ENCRYPTION))) 1328 { 1329 pRxData->rxDataDbgCounters.excludedFrameCounter++; 1330 /* free msdu */ 1331 WLAN_REPORT_WARNING(pRxData->hReport, RX_DATA_MODULE_LOG, 1332 (" rxData_receiveMsduFromWlan() : exclude broadcast unencrypted is TRUE & packet encryption is OFF\n")); 1333 1334 wlan_memMngrFreeMSDU(pRxData->hMemMngr, memMgr_MsduHandle(pMsdu)); 1335 return; 1336 } 1337 1338 /* 1339 * Discard multicast/broadcast frames that we sent ourselves. 1340 * Per IEEE 802.11-2007 section 9.2.7: "STAs shall filter out 1341 * broadcast/multicast messages that contain their address as 1342 * the source address." 1343 */ 1344 pCtrlData = (ctrlData_t *)pRxData->hCtrlData; 1345 if (IsMacAddressEqual(&pCtrlData->ctrlDataDeviceMacAddress, &pEthernetHeader->SrcAddr)) 1346 { 1347 pRxData->rxDataDbgCounters.excludedFrameCounter++; 1348 /* free msdu */ 1349 wlan_memMngrFreeMSDU(pRxData->hMemMngr, memMgr_MsduHandle(pMsdu)); 1350 return; 1351 } 1352 } 1353 1354 /* update traffic monitor parameters */ 1355 pRxData->rxDataCounters.RecvOk++; 1356 EventMask |= RECV_OK; 1357 if ( IsMacAddressDirected(&pEthernetHeader->DstAddr)) 1358 { 1359 /* Directed frame */ 1360 pRxData->rxDataCounters.DirectedFramesRecv++; 1361 pRxData->rxDataCounters.DirectedBytesRecv += pMsdu->dataLen; 1362 EventMask |= DIRECTED_BYTES_RECV; 1363 EventMask |= DIRECTED_FRAMES_RECV; 1364 #if defined(CONFIG_TROUT_PWRSINK) || defined(CONFIG_HTC_PWRSINK) 1365 num_rx_pkt_new++; 1366 #endif 1367 } 1368 else if ( IsMacAddressBroadcast(&pEthernetHeader->DstAddr)) 1369 { 1370 /* Broadcast frame */ 1371 pRxData->rxDataCounters.BroadcastFramesRecv++; 1372 pRxData->rxDataCounters.BroadcastBytesRecv += pMsdu->dataLen; 1373 EventMask |= BROADCAST_BYTES_RECV; 1374 EventMask |= BROADCAST_FRAMES_RECV; 1375 1376 } 1377 else 1378 { 1379 /* Multicast Address */ 1380 pRxData->rxDataCounters.MulticastFramesRecv++; 1381 pRxData->rxDataCounters.MulticastBytesRecv += pMsdu->dataLen; 1382 EventMask |= MULTICAST_BYTES_RECV; 1383 EventMask |= MULTICAST_FRAMES_RECV; 1384 #if defined(CONFIG_TROUT_PWRSINK) || defined(CONFIG_HTC_PWRSINK) 1385 num_rx_pkt_new++; 1386 #endif 1387 } 1388 pRxData->rxDataCounters.LastSecBytesRecv += pMsdu->dataLen; 1389 1390 /*Handle PREAUTH_EAPOL_PACKET*/ 1391 if(pEthernetHeader->TypeLength == PREAUTH_EAPOL_PACKET) 1392 { 1393 WLAN_REPORT_INFORMATION(pRxData->hReport, RX_DATA_MODULE_LOG, 1394 (" rxData_receiveMsduFromWlan() : Received an Pre-Auth EAPOL frame tranferred to OS\n")); 1395 1396 WLAN_REPORT_INFORMATION(pRxData->hReport, RX_DATA_MODULE_LOG, 1397 ("rxData_receiveMsduFromWlan(): Received an Pre-Auth EAPOL frame tranferred to OS\n")); 1398 EvHandlerSendEvent(pRxData->hEvHandler, IPC_EVENT_PREAUTH_EAPOL, 1399 (UINT8*)(pMsdu->firstBDPtr->data + pMsdu->firstBDPtr->dataOffset), 1400 pMsdu->firstBDPtr->length); 1401 } 1402 1403 1404 rxData_DistributorRxEvent(pRxData,EventMask,(int)pMsdu->dataLen); 1405 1406 /* deliver packet to os */ 1407 wlan_memMngrChangeMsduOwner(pRxData->hMemMngr,OS_ABS_RX_MODULE,pMsdu); 1408 os_receivePacket(pRxData->hOs, pMsdu, (UINT16)pMsdu->dataLen); 1409 } 1410 1411 1412 /*************************************************************************** 1413 * rxData_rcvMsduIapp * 1414 **************************************************************************** 1415 * DESCRIPTION: this function is called upon receving data IAPP packet type 1416 * while rx port status is "open" 1417 * 1418 * INPUTS: hRxData - the object 1419 * pMsdu - the received msdu. 1420 * pRxAttr - Rx attributes 1421 * 1422 * OUTPUT: 1423 * 1424 * RETURNS: 1425 ***************************************************************************/ 1426 #ifdef EXC_MODULE_INCLUDED 1427 1428 static void rxData_rcvMsduIapp(TI_HANDLE hRxData, mem_MSDU_T *pMsdu, Rx_attr_t* pRxAttr) 1429 { 1430 rxData_t *pRxData = (rxData_t *)hRxData; 1431 1432 WLAN_REPORT_INFORMATION(pRxData->hReport, RX_DATA_MODULE_LOG, 1433 (" rxData_rcvMsduIapp() : Received IAPP frame tranferred to excMgr\n")); 1434 1435 WLAN_REPORT_DEBUG_RX(pRxData->hReport, 1436 (" rxData_rcvMsduIapp() : Received IAPP frame tranferred to excMgr\n")); 1437 1438 /* tranfer packet to excMgr */ 1439 wlan_memMngrChangeMsduOwner(pRxData->hMemMngr,EXC_MANAGER_RX_MODULE,pMsdu); 1440 excMngr_recvIAPPPacket(pRxData->hExcMgr, pMsdu); 1441 1442 /* free msdu */ 1443 wlan_memMngrFreeMSDU(pRxData->hMemMngr, memMgr_MsduHandle(pMsdu)); 1444 1445 } 1446 1447 #endif 1448 1449 1450 /**************************************************************************** 1451 * rxData_convertWlanToEthHeader * 1452 ***************************************************************************** 1453 * DESCRIPTION: this function convert the msdu header from 802.11 header 1454 * format to ethernet format 1455 * 1456 * INPUTS: hRxData - the object 1457 * pMsdu - msdu in 802.11 format 1458 * 1459 * OUTPUT: pMsdu - msdu in ethernet format 1460 * 1461 * RETURNS: OK/NOK 1462 ***************************************************************************/ 1463 static TI_STATUS rxData_convertWlanToEthHeader (TI_HANDLE hRxData, mem_MSDU_T *pMsdu, UINT16 * etherType) 1464 { 1465 1466 EthernetHeader_t EthHeader; 1467 Wlan_LlcHeader_T *pWlanSnapHeader; 1468 UINT8 *dataBuf; 1469 dot11_header_t *pDot11Header; 1470 UINT32 lengthDelta; 1471 UINT8 createEtherIIHeader; 1472 UINT16 swapedTypeLength; 1473 UINT32 headerLength; 1474 rxData_t *pRxData = (rxData_t *)hRxData; 1475 1476 *etherType = 0; 1477 headerLength = pMsdu->headerLen; 1478 1479 dataBuf = (UINT8 *)memMgr_BufData(pMsdu->firstBDPtr)+memMgr_BufOffset(pMsdu->firstBDPtr); 1480 pDot11Header = (dot11_header_t*) dataBuf; 1481 1482 if(pMsdu->firstBDPtr->length == headerLength) 1483 { 1484 if (memMgr_BufNext(pMsdu->firstBDPtr)) 1485 { 1486 pWlanSnapHeader = (Wlan_LlcHeader_T*)(memMgr_BufData(pMsdu->firstBDPtr->nextBDPtr) 1487 +memMgr_BufOffset(pMsdu->firstBDPtr->nextBDPtr)); 1488 } 1489 else 1490 { 1491 return OK; 1492 } 1493 } 1494 else 1495 pWlanSnapHeader = (Wlan_LlcHeader_T*)((UINT32)dataBuf + (UINT32)headerLength); 1496 1497 1498 swapedTypeLength = wlan_ntohs(pWlanSnapHeader->Type); 1499 *etherType = swapedTypeLength; 1500 1501 /* See if the LLC header in the frame shows the SAP SNAP... */ 1502 if((SNAP_CHANNEL_ID == pWlanSnapHeader->DSAP) && 1503 (SNAP_CHANNEL_ID == pWlanSnapHeader->SSAP) && 1504 (LLC_CONTROL_UNNUMBERED_INFORMATION == pWlanSnapHeader->Control)) 1505 { 1506 /* Check for the Bridge Tunnel OUI in the SNAP Header... */ 1507 if((SNAP_OUI_802_1H_BYTE0 == pWlanSnapHeader->OUI[ 0 ]) && 1508 (SNAP_OUI_802_1H_BYTE1 == pWlanSnapHeader->OUI[ 1 ]) && 1509 (SNAP_OUI_802_1H_BYTE2 == pWlanSnapHeader->OUI[ 2 ])) 1510 { 1511 /* Strip the SNAP header by skipping over it. */ 1512 /* Start moving data from the Ethertype field in the SNAP */ 1513 /* header. Move to the TypeLength field in the 802.3 header. */ 1514 createEtherIIHeader = TRUE; 1515 } 1516 /* Check for the RFC 1042 OUI in the SNAP Header */ 1517 else 1518 { 1519 /* See if the Ethertype is in our selective translation table */ 1520 /* (Appletalk AARP and DIX II IPX are the two protocols in */ 1521 /* our 'table') */ 1522 if((ETHERTYPE_APPLE_AARP == swapedTypeLength) || 1523 (ETHERTYPE_DIX_II_IPX == swapedTypeLength)) 1524 { 1525 /* Strip the SNAP header by skipping over it. */ 1526 createEtherIIHeader = FALSE; 1527 } 1528 /* All the rest SNAP types are transformed to EthernetII format */ 1529 else 1530 { 1531 createEtherIIHeader = TRUE; 1532 } 1533 } 1534 } 1535 else 1536 { 1537 /* Non-SNAP packets strip out the WLAN header and create the dst,src,len header. */ 1538 createEtherIIHeader = FALSE; 1539 } 1540 1541 1542 1543 /* Prepare the Ethernet header. */ 1544 if(pDot11Header->fc & DOT11_FC_FROM_DS) 1545 { /* Infrastructure bss */ 1546 MAC_COPY(pRxData->hOs, (&EthHeader.DstAddr), (&pDot11Header->address1)); 1547 MAC_COPY(pRxData->hOs, (&EthHeader.SrcAddr), (&pDot11Header->address3)); 1548 } 1549 else 1550 { /* Independent bss */ 1551 MAC_COPY(pRxData->hOs, (&EthHeader.DstAddr), (&pDot11Header->address1)); 1552 MAC_COPY(pRxData->hOs, (&EthHeader.SrcAddr), (&pDot11Header->address2)); 1553 } 1554 1555 if( createEtherIIHeader == TRUE ) 1556 { 1557 EthHeader.TypeLength = pWlanSnapHeader->Type; 1558 1559 if(pMsdu->firstBDPtr->length == headerLength) 1560 { 1561 /* Replace the 802.11 header and the LLC with Ethernet packet. */ 1562 lengthDelta = (pMsdu->firstBDPtr->nextBDPtr->data 1563 + pMsdu->firstBDPtr->nextBDPtr->dataOffset 1564 - pMsdu->firstBDPtr->data) 1565 + WLAN_SNAP_HDR_LEN - ETHERNET_HDR_LEN; 1566 dataBuf += lengthDelta; 1567 os_memoryCopy(pRxData->hOs, dataBuf, (void*)&EthHeader, ETHERNET_HDR_LEN ); 1568 pMsdu->firstBDPtr->dataOffset = lengthDelta; 1569 pMsdu->dataLen -= headerLength + WLAN_SNAP_HDR_LEN - ETHERNET_HDR_LEN; 1570 pMsdu->firstBDPtr->length = pMsdu->dataLen; 1571 1572 /* UDI - modify code to release second BD to test NDIS */ 1573 wlan_memMngrFreeBD(pRxData->hMemMngr, pMsdu->firstBDPtr->nextBDPtr->handle); 1574 pMsdu->firstBDPtr->nextBDPtr = NULL; 1575 return OK; 1576 1577 } 1578 /* The LEN/TYPE bytes are set to TYPE, the entire WLAN+SNAP is removed.*/ 1579 lengthDelta = headerLength + WLAN_SNAP_HDR_LEN - ETHERNET_HDR_LEN; 1580 EthHeader.TypeLength = pWlanSnapHeader->Type; 1581 } 1582 else 1583 { 1584 /* The LEN/TYPE bytes are set to frame LEN, only the WLAN header is removed, */ 1585 /* the entire 802.3 or 802.2 header is not removed.*/ 1586 EthHeader.TypeLength = wlan_ntohs((UINT16)(pMsdu->dataLen - headerLength)); 1587 lengthDelta = headerLength - ETHERNET_HDR_LEN; 1588 } 1589 1590 /* Replace the 802.11 header and the LLC with Ethernet packet. */ 1591 dataBuf += lengthDelta; 1592 os_memoryCopy(pRxData->hOs, dataBuf, (void*)&EthHeader, ETHERNET_HDR_LEN ); 1593 memMgr_BufOffset(pMsdu->firstBDPtr) += lengthDelta; 1594 pMsdu->dataLen -= lengthDelta; 1595 pMsdu->firstBDPtr->length -= lengthDelta; 1596 pMsdu->headerLen = ETHERNET_HDR_LEN; 1597 return OK; 1598 1599 } 1600 1601 1602 /**************************************************************************************** 1603 * rxData_ReceivePacket * 1604 **************************************************************************************** 1605 DESCRIPTION: receive packet CB from RxXfer. 1606 parse the status and other parameters and forward the frame to 1607 rxData_receiveMsduFromWlan() 1608 1609 INPUT: Rx frame with its parameters 1610 1611 OUTPUT: 1612 1613 RETURN: 1614 1615 ************************************************************************/ 1616 static void rxData_ReceivePacket ( TI_HANDLE hRxData, 1617 TI_STATUS aStatus, 1618 const void *aFrame, 1619 UINT16 aLength, 1620 UINT32 aRate, 1621 UINT8 aRCPI, 1622 UINT8 aChannel, 1623 void *Reserved, 1624 UINT32 aFlags) 1625 { 1626 rxData_t *pRxData = (rxData_t *)hRxData; 1627 mem_MSDU_T *pMsdu = pRxData->pReqForBufMsdu; 1628 1629 if (pMsdu) 1630 { 1631 rxXfer_Reserved_t *pWhalReserved = (rxXfer_Reserved_t *)Reserved; 1632 Rx_attr_t RxAttr; 1633 dot11_header_t *pHdr; 1634 1635 /* 1636 * First thing we do is getting the dot11_header, and than we check the status, since the header is 1637 * needed for RX_MIC_FAILURE_ERROR 1638 */ 1639 1640 /* The next field includes the data only, excluding the TNETWIF_READ_OFFSET_BYTES */ 1641 pMsdu->dataLen = aLength; 1642 /* NOTE !!! the length field in the rx path exclude the TNETWIF_READ_OFFSET_BYTES !!! (while in the tx path its included) */ 1643 pMsdu->firstBDPtr->length = aLength; 1644 /* Actual data starts after the TNETWIF_READ_OFFSET_BYTES reserved for the bus txn */ 1645 pMsdu->firstBDPtr->dataOffset = TNETWIF_READ_OFFSET_BYTES ; 1646 1647 pHdr = (dot11_header_t *)(memMgr_BufData(pMsdu->firstBDPtr) + memMgr_BufOffset(pMsdu->firstBDPtr)); 1648 1649 /* Check status */ 1650 switch (aStatus) 1651 { 1652 case OK: 1653 break; 1654 1655 case RX_MIC_FAILURE_ERROR: 1656 { 1657 UINT8 uKeyType; 1658 paramInfo_t Param; 1659 macAddress_t* pMac = &pHdr->address1; /* hold the first mac address */ 1660 /* Get BSS type */ 1661 Param.paramType = SITE_MGR_CURRENT_BSS_TYPE_PARAM; 1662 siteMgr_getParam (pRxData->hSiteMgr, &Param); 1663 1664 /* For multicast/broadcast frames or in IBSS the key used is GROUP, else - it's Pairwise */ 1665 if (MAC_MULTICAST(pMac) || Param.content.siteMgrCurrentBSSType == BSS_INDEPENDENT) 1666 { 1667 uKeyType = (UINT8)KEY_TKIP_MIC_GROUP; 1668 } 1669 /* Unicast on infrastructure */ 1670 else 1671 { 1672 uKeyType = (UINT8)KEY_TKIP_MIC_PAIRWISE; 1673 } 1674 1675 WLAN_REPORT_ERROR(pRxData->hReport, RX_DATA_MODULE_LOG, 1676 ("rxData_ReceivePacket: Received MSDU MIC failure. Type = %s\n", 1677 ((uKeyType == KEY_TKIP_MIC_GROUP) ? "GROUP" : "PAIRWISE"))); 1678 1679 rsn_reportMicFailure (pRxData->hRsn, &uKeyType, sizeof(uKeyType)); 1680 wlan_memMngrFreeMSDU (pRxData->hMemMngr, memMgr_MsduHandle(pMsdu)); 1681 return; 1682 } 1683 1684 case RX_DECRYPT_FAILURE: 1685 /* This error is not important before the Connection, so we ignore it when portStatus is not OPEN */ 1686 if (pRxData->rxDataPortStatus == OPEN) 1687 { 1688 WLAN_REPORT_WARNING(pRxData->hReport, RX_DATA_MODULE_LOG, 1689 ("rxData_ReceivePacket: Received MSDU with RX_DECRYPT_FAILURE\n")); 1690 } 1691 1692 wlan_memMngrFreeMSDU (pRxData->hMemMngr, memMgr_MsduHandle(pMsdu)); 1693 return; 1694 1695 default: 1696 /* Unknown error - free packet and return */ 1697 WLAN_REPORT_ERROR(pRxData->hReport, RX_DATA_MODULE_LOG, 1698 ("rxData_ReceivePacket: Received MSDU with unknown status = %s\n", 1699 convertTI_STATUS_toString (aStatus))); 1700 1701 wlan_memMngrFreeMSDU (pRxData->hMemMngr, memMgr_MsduHandle(pMsdu)); 1702 return; 1703 } 1704 1705 WLAN_REPORT_INFORMATION (pRxData->hReport, RX_DATA_MODULE_LOG, ("ReceivePacket\n")); 1706 1707 /* 1708 * Set rx attributes 1709 */ 1710 RxAttr.channel = aChannel; 1711 RxAttr.packetInfo = aFlags; 1712 RxAttr.packetType = pWhalReserved->packetType; 1713 /* Rate is converted in RxXfer module */ 1714 RxAttr.Rate = (rate_e)aRate; 1715 RxAttr.Rssi = pWhalReserved->rssi; 1716 RxAttr.SNR = pWhalReserved->SNR; 1717 RxAttr.status = aStatus; 1718 RxAttr.band = pWhalReserved->band; 1719 RxAttr.TimeStamp = pWhalReserved->TimeStamp; 1720 1721 /* Setting the mac header len according to the received FrameControl field in the Mac Header */ 1722 GET_MAX_HEADER_SIZE (pHdr, &pMsdu->headerLen); 1723 1724 WLAN_REPORT_DEBUG_RX(pRxData->hReport, 1725 ("rxData_ReceivePacket: channel=%d, info=0x%x, type=%d, rate=0x%x, RSSI=%d, SNR=%d, status=%d\n", 1726 RxAttr.channel, 1727 RxAttr.packetInfo, 1728 RxAttr.packetType, 1729 RxAttr.Rate, 1730 RxAttr.Rssi, 1731 RxAttr.SNR, 1732 RxAttr.status)); 1733 1734 rxData_receiveMsduFromWlan (hRxData, pMsdu, &RxAttr); 1735 1736 /* MSDU MUST be freed until now */ 1737 if (pMsdu != NULL) 1738 { 1739 if (pMsdu->module != MODULE_FREE_MSDU && 1740 pMsdu->module != OS_ABS_TX_MODULE && 1741 pMsdu->module != TX_MODULE) 1742 { 1743 WLAN_REPORT_ERROR(pRxData->hReport, RX_DATA_MODULE_LOG, 1744 ("rxData_ReceivePacket: ERROR pMsdu->module != MODULE_FREE_MSDU, module = %d\n", pMsdu->module)); 1745 1746 HexDumpData ((UINT8*)(memMgr_MsduHdrAddr(pMsdu)), memMgr_MsduHdrLen(pMsdu)); 1747 } 1748 } 1749 } 1750 1751 else 1752 { 1753 WLAN_REPORT_ERROR (pRxData->hReport, RX_DATA_MODULE_LOG, 1754 ("rxData_ReceivePacket: null MSDU received")); 1755 } 1756 } 1757 1758 1759 /**************************************************************************************** 1760 * RequestForBuffer * 1761 **************************************************************************************** 1762 DESCRIPTION: RX request for buffer 1763 1764 INPUT: 1765 1766 OUTPUT: 1767 1768 RETURN: 1769 1770 ************************************************************************/ 1771 static void *rxData_RequestForBuffer (TI_HANDLE hRxData, 1772 UINT16 aLength, UINT32 uEncryptionflag) 1773 { 1774 rxData_t *pRxData = (rxData_t *)hRxData; 1775 1776 WLAN_REPORT_INFORMATION (pRxData->hReport, RX_DATA_MODULE_LOG, 1777 (" RequestForBuffer, length = %d \n",aLength)); 1778 1779 if (wlan_memMngrAllocMSDU(pRxData->hMemMngr, &pRxData->pReqForBufMsdu, aLength, HAL_RX_MODULE) != OK) 1780 { 1781 WLAN_REPORT_ERROR(pRxData->hReport, HAL_CTRL_MODULE_LOG, 1782 ("RequestForBuffer: wlan_memMngrAllocMSDU error\n")); 1783 return NULL; 1784 } 1785 1786 return memMgr_BufData (pRxData->pReqForBufMsdu->firstBDPtr); 1787 } 1788 1789 /*************************************************************************** 1790 * rxData_resetCounters * 1791 **************************************************************************** 1792 * DESCRIPTION: This function reset the Rx Data module counters 1793 * 1794 * INPUTS: hRxData - the object 1795 * 1796 * OUTPUT: 1797 * 1798 * RETURNS: void 1799 ***************************************************************************/ 1800 #ifdef TI_DBG 1801 void rxData_resetCounters(TI_HANDLE hRxData) 1802 { 1803 rxData_t *pRxData = (rxData_t *)hRxData; 1804 1805 os_memoryZero(pRxData->hOs, &pRxData->rxDataCounters, sizeof(rxDataCounters_t)); 1806 } 1807 1808 /*************************************************************************** 1809 * rxData_resetDbgCounters * 1810 **************************************************************************** 1811 * DESCRIPTION: This function reset the Rx Data module debug counters 1812 * 1813 * INPUTS: hRxData - the object 1814 * 1815 * OUTPUT: 1816 * 1817 * RETURNS: void 1818 ***************************************************************************/ 1819 1820 void rxData_resetDbgCounters(TI_HANDLE hRxData) 1821 { 1822 rxData_t *pRxData = (rxData_t *)hRxData; 1823 1824 os_memoryZero(pRxData->hOs, &pRxData->rxDataDbgCounters, sizeof(rxDataDbgCounters_t)); 1825 } 1826 1827 1828 /*************************************************************************** 1829 * test functions * 1830 ***************************************************************************/ 1831 void rxData_printRxCounters(TI_HANDLE hRxData) 1832 { 1833 rxData_t *pRxData = (rxData_t *)hRxData; 1834 1835 if(pRxData) 1836 { 1837 WLAN_OS_REPORT(("RecvOk = %d\n", pRxData->rxDataCounters.RecvOk)); 1838 WLAN_OS_REPORT(("DirectedBytesRecv = %d\n", pRxData->rxDataCounters.DirectedBytesRecv)); 1839 WLAN_OS_REPORT(("DirectedFramesRecv = %d\n", pRxData->rxDataCounters.DirectedFramesRecv)); 1840 WLAN_OS_REPORT(("MulticastBytesRecv = %d\n", pRxData->rxDataCounters.MulticastBytesRecv)); 1841 WLAN_OS_REPORT(("MulticastFramesRecv = %d\n", pRxData->rxDataCounters.MulticastFramesRecv)); 1842 WLAN_OS_REPORT(("BroadcastBytesRecv = %d\n", pRxData->rxDataCounters.BroadcastBytesRecv)); 1843 WLAN_OS_REPORT(("BroadcastFramesRecv = %d\n", pRxData->rxDataCounters.BroadcastFramesRecv)); 1844 1845 /* debug counters */ 1846 WLAN_OS_REPORT(("excludedFrameCounter = %d\n", pRxData->rxDataDbgCounters.excludedFrameCounter)); 1847 WLAN_OS_REPORT(("rxDroppedDueToVLANIncludedCnt = %d\n", pRxData->rxDataDbgCounters.rxDroppedDueToVLANIncludedCnt)); 1848 WLAN_OS_REPORT(("rxWrongBssTypeCounter = %d\n", pRxData->rxDataDbgCounters.rxWrongBssTypeCounter)); 1849 WLAN_OS_REPORT(("rxWrongBssIdCounter = %d\n", pRxData->rxDataDbgCounters.rxWrongBssIdCounter)); 1850 WLAN_OS_REPORT(("rcvUnicastFrameInOpenNotify = %d\n", pRxData->rxDataDbgCounters.rcvUnicastFrameInOpenNotify)); 1851 } 1852 } 1853 1854 1855 void rxData_printRxBlock(TI_HANDLE hRxData) 1856 { 1857 rxData_t *pRxData = (rxData_t *)hRxData; 1858 1859 WLAN_OS_REPORT(("hCtrlData = 0x%X\n", pRxData->hCtrlData)); 1860 WLAN_OS_REPORT(("hMlme = 0x%X\n", pRxData->hMlme)); 1861 WLAN_OS_REPORT(("hOs = 0x%X\n", pRxData->hOs)); 1862 WLAN_OS_REPORT(("hReport = 0x%X\n", pRxData->hReport)); 1863 WLAN_OS_REPORT(("hRsn = 0x%X\n", pRxData->hRsn)); 1864 WLAN_OS_REPORT(("hSiteMgr = 0x%X\n", pRxData->hSiteMgr)); 1865 WLAN_OS_REPORT(("hMemMngr = 0x%X\n", pRxData->hMemMngr)); 1866 1867 WLAN_OS_REPORT(("hCtrlData = 0x%X\n", pRxData->hCtrlData)); 1868 WLAN_OS_REPORT(("hMlme = 0x%X\n", pRxData->hMlme)); 1869 WLAN_OS_REPORT(("hOs = 0x%X\n", pRxData->hOs)); 1870 WLAN_OS_REPORT(("hReport = 0x%X\n", pRxData->hReport)); 1871 WLAN_OS_REPORT(("hRsn = 0x%X\n", pRxData->hRsn)); 1872 WLAN_OS_REPORT(("hSiteMgr = 0x%X\n", pRxData->hSiteMgr)); 1873 WLAN_OS_REPORT(("hMemMngr = 0x%X\n", pRxData->hMemMngr)); 1874 1875 WLAN_OS_REPORT(("rxDataPortStatus = %d\n", pRxData->rxDataPortStatus)); 1876 WLAN_OS_REPORT(("rxDataExcludeUnencrypted = %d\n", pRxData->rxDataExcludeUnencrypted)); 1877 WLAN_OS_REPORT(("rxDataEapolDestination = %d\n", pRxData->rxDataEapolDestination)); 1878 1879 } 1880 1881 1882 void rxData_startRxThroughputTimer (TI_HANDLE hRxData) 1883 { 1884 rxData_t *pRxData = (rxData_t *)hRxData; 1885 1886 if (!pRxData->rxThroughputTimerEnable) 1887 { 1888 /* reset throughput counter */ 1889 pRxData->rxDataCounters.LastSecBytesRecv = 0; 1890 pRxData->rxThroughputTimerEnable = TRUE; 1891 1892 /* start 1 sec throughput timer */ 1893 os_timerStart (pRxData->hOs, pRxData->hThroughputTimer, 1000, TRUE); 1894 } 1895 } 1896 1897 1898 void rxData_stopRxThroughputTimer (TI_HANDLE hRxData) 1899 { 1900 1901 rxData_t *pRxData = (rxData_t *)hRxData; 1902 1903 if (pRxData->rxThroughputTimerEnable) 1904 { 1905 os_timerStop (pRxData->hOs, pRxData->hThroughputTimer); 1906 pRxData->rxThroughputTimerEnable = FALSE; 1907 } 1908 } 1909 1910 1911 static void rxData_printRxThroughput (TI_HANDLE hRxData) 1912 { 1913 rxData_t *pRxData = (rxData_t *)hRxData; 1914 1915 WLAN_OS_REPORT (("\n")); 1916 WLAN_OS_REPORT (("-------------- Rx Throughput Statistics ---------------\n")); 1917 WLAN_OS_REPORT (("Throughput = %d KBits/sec\n", pRxData->rxDataCounters.LastSecBytesRecv * 8 / 1024)); 1918 1919 /* reset throughput counter */ 1920 pRxData->rxDataCounters.LastSecBytesRecv = 0; 1921 } 1922 1923 void rxData_printRxDataFilter (TI_HANDLE hRxData) 1924 { 1925 UINT32 index; 1926 rxData_t *pRxData = (rxData_t *)hRxData; 1927 1928 for (index=0; index<MAX_DATA_FILTERS; index++) 1929 { 1930 if (pRxData->isFilterSet[index]) 1931 { 1932 WLAN_OS_REPORT (("index=%d, pattern & mask\n", index)); 1933 HexDumpData(pRxData->filterRequests[index].pattern, pRxData->filterRequests[index].patternLength); 1934 HexDumpData(pRxData->filterRequests[index].mask, pRxData->filterRequests[index].maskLength); 1935 } 1936 else 1937 { 1938 WLAN_OS_REPORT (("No Filter defined for index-%d\n", index)); 1939 } 1940 } 1941 } 1942 1943 #endif /*TI_DBG*/ 1944