PageRenderTime 74ms CodeModel.GetById 29ms RepoModel.GetById 0ms app.codeStats 1ms

/drivers/net/wireless/tiwlan1251/common/src/core/data_ctrl/Rx/rx.c

http://github.com/CyanogenMod/cm-kernel
C | 1799 lines | 972 code | 297 blank | 530 comment | 163 complexity | 75048e8dbad4a663d81d2270869eb8f9 MD5 | raw file
Possible License(s): AGPL-1.0, GPL-2.0, LGPL-2.0

Large files files are truncated, but you can click here to view the full file

  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. #define EAPOL_PACKET 0x8E88
  65. #define IAPP_PACKET 0x0000
  66. #define PREAUTH_EAPOL_PACKET 0xC788
  67. /* CallBack for recieving packet from rxXfer */
  68. static void rxData_ReceivePacket ( TI_HANDLE hRxData,TI_STATUS aStatus,const void *aFrame,
  69. UINT16 aLength,UINT32 aRate,UINT8 aRCPI,
  70. UINT8 aChannel,void *Reserved,UINT32 aFlags);
  71. static void *rxData_RequestForBuffer (TI_HANDLE hRxData,UINT16 aLength, UINT32 uEncryptionFlag);
  72. #if 0
  73. static TI_STATUS rxData_checkBssIdAndBssType(TI_HANDLE hRxData, dot11_header_t* dot11_header,
  74. macAddress_t **rxBssid, bssType_e *currBssType,
  75. macAddress_t *currBssId);
  76. #endif
  77. static TI_STATUS rxData_convertWlanToEthHeader (TI_HANDLE hRxData, mem_MSDU_T *pMsdu, UINT16 * etherType);
  78. static void rxData_dataMsduDisptcher(TI_HANDLE hRxData, mem_MSDU_T *pMsdu, Rx_attr_t* pRxAttr);
  79. static void rxData_discardMsdu(TI_HANDLE hRxData, mem_MSDU_T *pMsdu, Rx_attr_t* pRxAttr);
  80. static void rxData_discardMsduVlan(TI_HANDLE hRxData, mem_MSDU_T *pMsdu, Rx_attr_t* pRxAttr);
  81. static void rxData_rcvMsduInOpenNotify(TI_HANDLE hRxData, mem_MSDU_T *pMsdu, Rx_attr_t* pRxAttr);
  82. static void rxData_rcvMsduEapol(TI_HANDLE hRxData, mem_MSDU_T *pMsdu, Rx_attr_t* pRxAttr);
  83. static void rxData_rcvMsduData(TI_HANDLE hRxData, mem_MSDU_T *pMsdu, Rx_attr_t* pRxAttr);
  84. static TI_STATUS rxData_enableDisableRxDataFilters(TI_HANDLE hRxData, BOOL enabled);
  85. static TI_STATUS rxData_addRxDataFilter(TI_HANDLE hRxData, rxDataFilterRequest_t * request);
  86. static TI_STATUS rxData_removeRxDataFilter(TI_HANDLE hRxData, rxDataFilterRequest_t * request);
  87. #ifdef EXC_MODULE_INCLUDED
  88. static void rxData_rcvMsduIapp(TI_HANDLE hRxData, mem_MSDU_T *pMsdu, Rx_attr_t* pRxAttr);
  89. #endif
  90. #ifdef TI_DBG
  91. static void rxData_printRxThroughput(TI_HANDLE hRxData);
  92. #endif
  93. /*************************************************************************
  94. * rxData_create *
  95. **************************************************************************
  96. * DESCRIPTION: This function initializes the Rx data module.
  97. *
  98. * INPUT: hOs - handle to Os Abstraction Layer
  99. * msduReceiveCB - call back function that return to
  100. * configMngr in order to register in the Hal
  101. * OUTPUT:
  102. *
  103. * RETURN: Handle to the allocated Rx data control block
  104. ************************************************************************/
  105. TI_HANDLE rxData_create ( TI_HANDLE hOs)
  106. {
  107. rxData_t *hRxData;
  108. /* check parameters validity */
  109. if( hOs == NULL)
  110. {
  111. WLAN_OS_REPORT(("FATAL ERROR: rxData_create(): OS handle Error - Aborting\n"));
  112. return NULL;
  113. }
  114. /* alocate Rx module control block */
  115. hRxData = os_memoryAlloc(hOs, (sizeof(rxData_t)));
  116. if( !hRxData )
  117. {
  118. utils_nullMemoryFree(hOs, hRxData, sizeof(rxData_t));
  119. WLAN_OS_REPORT(("FATAL ERROR: rxData_create(): Error Creating Rx Module - Aborting\n"));
  120. return(NULL);
  121. }
  122. /* reset Rx control block */
  123. os_memoryZero(hOs, hRxData, (sizeof(rxData_t)));
  124. hRxData->RxEventDistributor = DistributorMgr_Create(hOs,MAX_RX_NOTIF_REQ_ELMENTS);
  125. hRxData->hOs = hOs;
  126. /* allocate timer for debug throughput */
  127. #ifdef TI_DBG
  128. hRxData->hThroughputTimer = os_timerCreate (hOs, rxData_printRxThroughput, hRxData);
  129. if (!hRxData->hThroughputTimer)
  130. {
  131. utils_nullMemoryFree (hOs, hRxData, sizeof(rxData_t));
  132. return NULL;
  133. }
  134. hRxData->rxThroughputTimerEnable = FALSE;
  135. #endif
  136. return(hRxData);
  137. }
  138. /***************************************************************************
  139. * rxData_config *
  140. ****************************************************************************
  141. * DESCRIPTION: This function configures the Rx Data module
  142. *
  143. * INPUTS: hRxData - The object
  144. * hCtrlData - Handle to the Ctrl Data object
  145. * hMlme - Handle to the Mlme object
  146. * hRsn - Handle to the Rsn object
  147. * hOs - Handle to the Os Abstraction Layer
  148. * hReport - Handle to the Report object
  149. * hMemMngr - Handle to the MemMngr object
  150. * OUTPUT:
  151. *
  152. * RETURNS: OK - Configuration succesfull
  153. * NOK - Configuration unsuccesfull
  154. ***************************************************************************/
  155. TI_STATUS rxData_config(TI_HANDLE hRxData,
  156. TI_HANDLE hCtrlData,
  157. TI_HANDLE hTxData,
  158. TI_HANDLE hTnetwDrv,
  159. TI_HANDLE hHalCtrl,
  160. TI_HANDLE hMlme,
  161. TI_HANDLE hRsn,
  162. TI_HANDLE hSiteMgr,
  163. TI_HANDLE hExcMngr,
  164. TI_HANDLE hOs,
  165. TI_HANDLE hReport,
  166. TI_HANDLE hMemMngr,
  167. TI_HANDLE hEvHandler,
  168. rxDataInitParams_t * rxDataInitParams)
  169. {
  170. rxData_t *pRxData = (rxData_t *)hRxData;
  171. int i;
  172. /* check parameters validity */
  173. if( hRxData == NULL || hCtrlData == NULL || hMlme == NULL || hRsn == NULL || hHalCtrl == NULL ||
  174. hSiteMgr == NULL || hOs == NULL || hReport == NULL || hTxData == NULL || hTnetwDrv == NULL)
  175. {
  176. WLAN_OS_REPORT(("FATAL ERROR: rxData_config(): Parameters Error - Aborting\n"));
  177. return NOK;
  178. }
  179. pRxData->hCtrlData = hCtrlData;
  180. pRxData->hTxData = hTxData;
  181. pRxData->hTnetwDrv = hTnetwDrv;
  182. pRxData->hHalCtrl = hHalCtrl;
  183. pRxData->hMlme = hMlme;
  184. pRxData->hRsn = hRsn;
  185. pRxData->hSiteMgr = hSiteMgr;
  186. pRxData->hOs = hOs;
  187. pRxData->hReport = hReport;
  188. pRxData->hMemMngr = hMemMngr;
  189. pRxData->hExcMgr = hExcMngr;
  190. pRxData->hEvHandler = hEvHandler;
  191. pRxData->rxDataExcludeUnencrypted = DEF_EXCLUDE_UNENCYPTED;
  192. pRxData->rxDataExludeBroadcastUnencrypted = DEF_EXCLUDE_UNENCYPTED;
  193. pRxData->rxDataEapolDestination = DEF_EAPOL_DESTINATION;
  194. pRxData->rxDataPortStatus = DEF_RX_PORT_STATUS;
  195. /*
  196. * configure rx data dispatcher
  197. */
  198. /* port status close */
  199. pRxData->rxData_dispatchMsdu[CLOSE][DATA_DATA_PACKET] = &rxData_discardMsdu; /* data */
  200. pRxData->rxData_dispatchMsdu[CLOSE][DATA_EAPOL_PACKET] = &rxData_discardMsdu; /* eapol */
  201. pRxData->rxData_dispatchMsdu[CLOSE][DATA_IAPP_PACKET] = &rxData_discardMsdu; /* Iapp */
  202. pRxData->rxData_dispatchMsdu[CLOSE][DATA_VLAN_PACKET] = &rxData_discardMsduVlan; /* VLAN */
  203. /* port status open notify */
  204. pRxData->rxData_dispatchMsdu[OPEN_NOTIFY][DATA_DATA_PACKET] = &rxData_rcvMsduInOpenNotify; /* data */
  205. pRxData->rxData_dispatchMsdu[OPEN_NOTIFY][DATA_EAPOL_PACKET] = &rxData_rcvMsduInOpenNotify; /* eapol */
  206. pRxData->rxData_dispatchMsdu[OPEN_NOTIFY][DATA_IAPP_PACKET] = &rxData_rcvMsduInOpenNotify; /* Iapp */
  207. pRxData->rxData_dispatchMsdu[OPEN_NOTIFY][DATA_VLAN_PACKET] = &rxData_discardMsduVlan; /* VLAN */
  208. /* port status open eapol */
  209. pRxData->rxData_dispatchMsdu[OPEN_EAPOL][DATA_DATA_PACKET] = &rxData_discardMsdu; /* data */
  210. pRxData->rxData_dispatchMsdu[OPEN_EAPOL][DATA_EAPOL_PACKET] = &rxData_rcvMsduEapol; /* eapol */
  211. pRxData->rxData_dispatchMsdu[OPEN_EAPOL][DATA_IAPP_PACKET] = &rxData_discardMsdu; /* Iapp */
  212. pRxData->rxData_dispatchMsdu[OPEN_EAPOL][DATA_VLAN_PACKET] = &rxData_discardMsduVlan; /* VLAN */
  213. /* port status open */
  214. pRxData->rxData_dispatchMsdu[OPEN][DATA_DATA_PACKET] = &rxData_rcvMsduData; /* data */
  215. pRxData->rxData_dispatchMsdu[OPEN][DATA_EAPOL_PACKET] = &rxData_rcvMsduEapol; /* eapol */
  216. #ifdef EXC_MODULE_INCLUDED
  217. pRxData->rxData_dispatchMsdu[OPEN][DATA_IAPP_PACKET] = &rxData_rcvMsduIapp; /* Iapp */
  218. #else
  219. pRxData->rxData_dispatchMsdu[OPEN][DATA_IAPP_PACKET] = &rxData_rcvMsduData; /* Iapp */
  220. #endif
  221. pRxData->rxData_dispatchMsdu[OPEN][DATA_VLAN_PACKET] = &rxData_discardMsduVlan;/* VLAN */
  222. /* register CB's for request buffer and receive CB to the lower layers */
  223. TnetwDrv_Register_CB(pRxData->hTnetwDrv,TNETW_DRIVER_RX_RECEIVE_PACKET,(void *)rxData_ReceivePacket,hRxData);
  224. TnetwDrv_Register_CB(pRxData->hTnetwDrv,TNETW_DRIVER_RX_REQUEST_FOR_BUFFER,(void *)rxData_RequestForBuffer,hRxData);
  225. /* init rx data filters */
  226. pRxData->filteringEnabled = rxDataInitParams->rxDataFiltersEnabled;
  227. pRxData->filteringDefaultAction = rxDataInitParams->rxDataFiltersDefaultAction;
  228. whalCtrl_setRxDataFiltersParams(pRxData->hHalCtrl, pRxData->filteringEnabled, pRxData->filteringDefaultAction);
  229. for (i = 0; i < MAX_DATA_FILTERS; ++i)
  230. {
  231. if (rxDataInitParams->rxDataFilterRequests[i].maskLength > 0)
  232. {
  233. if (rxData_addRxDataFilter(hRxData, &rxDataInitParams->rxDataFilterRequests[i]) != OK)
  234. {
  235. WLAN_REPORT_ERROR(pRxData->hReport, RX_DATA_MODULE_LOG,
  236. ("%s: Invalid Rx Data Filter configured at init stage (at index %d)!\n", __FUNCTION__, i));
  237. }
  238. }
  239. }
  240. #ifdef TI_DBG
  241. /* reset counters */
  242. rxData_resetCounters(pRxData);
  243. rxData_resetDbgCounters(pRxData);
  244. #endif
  245. WLAN_REPORT_INIT(pRxData->hReport, RX_DATA_MODULE_LOG,
  246. (".....Rx Data configured successfully\n"));
  247. return OK;
  248. }
  249. /***************************************************************************
  250. * rxData_unLoad *
  251. ****************************************************************************
  252. * DESCRIPTION: This function unload the Rx data module.
  253. *
  254. * INPUTS: hRxData - the object
  255. *
  256. * OUTPUT:
  257. *
  258. * RETURNS: OK - Unload succesfull
  259. * NOK - Unload unsuccesfull
  260. ***************************************************************************/
  261. TI_STATUS rxData_unLoad(TI_HANDLE hRxData)
  262. {
  263. rxData_t *pRxData = (rxData_t *)hRxData;
  264. /* check parameters validity */
  265. if( pRxData == NULL )
  266. {
  267. WLAN_REPORT_ERROR(pRxData->hReport, RX_DATA_MODULE_LOG,
  268. (" rxData_unLoad() : Illegal value for hRxData\n"));
  269. return NOK;
  270. }
  271. DistributorMgr_Destroy(pRxData->RxEventDistributor);
  272. /* destroy periodic rx throughput timer */
  273. #ifdef TI_DBG
  274. utils_nullTimerDestroy (pRxData->hOs, pRxData->hThroughputTimer);
  275. #endif
  276. /* free Rx Data controll block */
  277. os_memoryFree(pRxData->hOs, pRxData, sizeof(rxData_t));
  278. return OK;
  279. }
  280. /***************************************************************************
  281. * rxData_stop *
  282. ****************************************************************************
  283. * DESCRIPTION: this function stop the rx data.
  284. *
  285. * INPUTS: hRxData - the object
  286. *
  287. * OUTPUT:
  288. *
  289. * RETURNS: OK - stop succesfull
  290. * NOK - stop unsuccesfull
  291. ***************************************************************************/
  292. TI_STATUS rxData_stop(TI_HANDLE hRxData)
  293. {
  294. rxData_t *pRxData = (rxData_t *)hRxData;
  295. /* check parameters validity */
  296. if( pRxData == NULL )
  297. {
  298. WLAN_REPORT_ERROR(pRxData->hReport, RX_DATA_MODULE_LOG,
  299. (" rxData_stop() : Illegal value for hRxData\n"));
  300. return NOK;
  301. }
  302. pRxData->rxDataExcludeUnencrypted = DEF_EXCLUDE_UNENCYPTED;
  303. pRxData->rxDataExludeBroadcastUnencrypted = DEF_EXCLUDE_UNENCYPTED;
  304. pRxData->rxDataEapolDestination = DEF_EAPOL_DESTINATION;
  305. pRxData->rxDataPortStatus = DEF_RX_PORT_STATUS;
  306. #ifdef TI_DBG
  307. /* reset counters */
  308. /*rxData_resetCounters(pRxData);*/
  309. /*rxData_resetDbgCounters(pRxData);*/
  310. /* stop throughput timer */
  311. if (pRxData->rxThroughputTimerEnable)
  312. {
  313. os_timerStop (pRxData->hOs, pRxData->hThroughputTimer);
  314. pRxData->rxThroughputTimerEnable = FALSE;
  315. }
  316. #endif
  317. WLAN_REPORT_INFORMATION(pRxData->hReport, RX_DATA_MODULE_LOG,
  318. (" rxData_stop() : Succeeded.\n"));
  319. return OK;
  320. }
  321. /***************************************************************************
  322. * rxData_getParam *
  323. ****************************************************************************
  324. * DESCRIPTION: get a specific parameter
  325. *
  326. * INPUTS: hRxData - the object
  327. *
  328. * OUTPUT: pParamInfo - structure which include the value of
  329. * the requested parameter
  330. *
  331. * RETURNS: OK
  332. * NOK
  333. ***************************************************************************/
  334. TI_STATUS rxData_getParam(TI_HANDLE hRxData, paramInfo_t *pParamInfo)
  335. {
  336. rxData_t *pRxData = (rxData_t *)hRxData;
  337. /* check handle validity */
  338. if( pRxData == NULL )
  339. {
  340. WLAN_REPORT_ERROR(pRxData->hReport, RX_DATA_MODULE_LOG,
  341. (" rxData_getParam() : Illegal parametrs value \n"));
  342. return NOK;
  343. }
  344. switch (pParamInfo->paramType)
  345. {
  346. case RX_DATA_EXCLUDE_UNENCRYPTED_PARAM:
  347. pParamInfo->content.rxDataExcludeUnencrypted = pRxData->rxDataExcludeUnencrypted;
  348. break;
  349. case RX_DATA_EAPOL_DESTINATION_PARAM:
  350. pParamInfo->content.rxDataEapolDestination = pRxData->rxDataEapolDestination;
  351. break;
  352. case RX_DATA_PORT_STATUS_PARAM:
  353. pParamInfo->content.rxDataPortStatus = pRxData->rxDataPortStatus;
  354. break;
  355. case RX_DATA_COUNTERS_PARAM:
  356. pParamInfo->content.siteMgrTiWlanCounters.RecvOk = pRxData->rxDataCounters.RecvOk;
  357. pParamInfo->content.siteMgrTiWlanCounters.DirectedBytesRecv = pRxData->rxDataCounters.DirectedBytesRecv;
  358. pParamInfo->content.siteMgrTiWlanCounters.DirectedFramesRecv = pRxData->rxDataCounters.DirectedFramesRecv;
  359. pParamInfo->content.siteMgrTiWlanCounters.MulticastBytesRecv = pRxData->rxDataCounters.MulticastBytesRecv;
  360. pParamInfo->content.siteMgrTiWlanCounters.MulticastFramesRecv = pRxData->rxDataCounters.MulticastFramesRecv;
  361. pParamInfo->content.siteMgrTiWlanCounters.BroadcastBytesRecv = pRxData->rxDataCounters.BroadcastBytesRecv;
  362. pParamInfo->content.siteMgrTiWlanCounters.BroadcastFramesRecv = pRxData->rxDataCounters.BroadcastFramesRecv;
  363. break;
  364. case RX_DATA_GET_RX_DATA_FILTERS_STATISTICS:
  365. whalCtrl_getRxDataFiltersStatistics(pRxData->hHalCtrl,
  366. pParamInfo->content.interogateCmdCBParams.CB_Func,
  367. pParamInfo->content.interogateCmdCBParams.CB_handle,
  368. pParamInfo->content.interogateCmdCBParams.CB_buf);
  369. break;
  370. default:
  371. return (PARAM_NOT_SUPPORTED);
  372. /* WLAN_REPORT_ERROR(pRxData->hReport, RX_DATA_MODULE_LOG,
  373. (" rxData_getParam() : PARAMETER NOT SUPPORTED \n"));
  374. return NOK;
  375. break; - unreachable */
  376. }
  377. return (OK);
  378. }
  379. /***************************************************************************
  380. * rxData_setParam *
  381. ****************************************************************************
  382. * DESCRIPTION: set a specific parameter
  383. *
  384. * INPUTS: hRxData - the object
  385. * pParamInfo - structure which include the value to set for
  386. * the requested parameter
  387. *
  388. * OUTPUT:
  389. *
  390. * RETURNS: OK
  391. * NOK
  392. ***************************************************************************/
  393. TI_STATUS rxData_setParam(TI_HANDLE hRxData, paramInfo_t *pParamInfo)
  394. {
  395. rxData_t *pRxData = (rxData_t *)hRxData;
  396. /* check handle validity */
  397. if( pRxData == NULL )
  398. {
  399. WLAN_REPORT_ERROR(pRxData->hReport, RX_DATA_MODULE_LOG,
  400. (" rxData_setParam(): Illegal parametrs value \n"));
  401. return NOK;
  402. }
  403. switch (pParamInfo->paramType)
  404. {
  405. case RX_DATA_EXCLUDE_UNENCRYPTED_PARAM:
  406. pRxData->rxDataExcludeUnencrypted = pParamInfo->content.rxDataExcludeUnencrypted;
  407. break;
  408. case RX_DATA_EXCLUDE_BROADCAST_UNENCRYPTED_PARAM:
  409. pRxData->rxDataExludeBroadcastUnencrypted = pParamInfo->content.rxDataExcludeUnencrypted;
  410. break;
  411. case RX_DATA_EAPOL_DESTINATION_PARAM:
  412. pRxData->rxDataEapolDestination = pParamInfo->content.rxDataEapolDestination;
  413. break;
  414. case RX_DATA_PORT_STATUS_PARAM:
  415. pRxData->rxDataPortStatus = pParamInfo->content.rxDataPortStatus;
  416. break;
  417. case RX_DATA_ENABLE_DISABLE_RX_DATA_FILTERS:
  418. return rxData_enableDisableRxDataFilters(hRxData, pParamInfo->content.rxDataFilterEnableDisable);
  419. case RX_DATA_ADD_RX_DATA_FILTER:
  420. {
  421. TIWLAN_DATA_FILTER_REQUEST * pRequest = &pParamInfo->content.rxDataFilterRequest;
  422. rxDataFilterRequest_t filterRequest;
  423. filterRequest.offset = pRequest->Offset;
  424. filterRequest.maskLength = pRequest->MaskLength;
  425. filterRequest.patternLength = pRequest->PatternLength;
  426. os_memoryCopy(pRxData->hOs, (PVOID) filterRequest.mask, (PVOID) pRequest->Mask, sizeof(filterRequest.mask));
  427. os_memoryCopy(pRxData->hOs, (PVOID) filterRequest.pattern, (PVOID) pRequest->Pattern, sizeof(filterRequest.pattern));
  428. return rxData_addRxDataFilter(hRxData, &filterRequest);
  429. }
  430. case RX_DATA_REMOVE_RX_DATA_FILTER:
  431. {
  432. TIWLAN_DATA_FILTER_REQUEST * pRequest = &pParamInfo->content.rxDataFilterRequest;
  433. rxDataFilterRequest_t filterRequest;
  434. filterRequest.offset = pRequest->Offset;
  435. filterRequest.maskLength = pRequest->MaskLength;
  436. filterRequest.patternLength = pRequest->PatternLength;
  437. os_memoryCopy(pRxData->hOs, (PVOID) filterRequest.mask, (PVOID) pRequest->Mask, sizeof(filterRequest.mask));
  438. os_memoryCopy(pRxData->hOs, (PVOID) filterRequest.pattern, (PVOID) pRequest->Pattern, sizeof(filterRequest.pattern));
  439. return rxData_removeRxDataFilter(hRxData, &filterRequest);
  440. }
  441. default:
  442. return (PARAM_NOT_SUPPORTED);
  443. /* WLAN_REPORT_ERROR(pRxData->hReport, RX_DATA_MODULE_LOG,
  444. (" rxData_setParam() : PARAMETER NOT SUPPORTED \n"));
  445. return NOK;
  446. break; - unreachable */
  447. }
  448. return (OK);
  449. }
  450. /***************************************************************************
  451. * rxData_enableDisableRxDataFilters *
  452. ****************************************************************************
  453. * DESCRIPTION:
  454. *
  455. *
  456. * INPUTS:
  457. *
  458. *
  459. *
  460. * OUTPUT:
  461. *
  462. * RETURNS:
  463. *
  464. ***************************************************************************/
  465. static TI_STATUS rxData_enableDisableRxDataFilters(TI_HANDLE hRxData, BOOL enabled)
  466. {
  467. rxData_t * pRxData = (rxData_t *) hRxData;
  468. /* assert 0 or 1 */
  469. if (enabled != 0)
  470. enabled = 1;
  471. if (enabled == pRxData->filteringEnabled)
  472. return OK;
  473. pRxData->filteringEnabled = enabled;
  474. return (TI_STATUS) whalCtrl_setRxDataFiltersParams(pRxData->hHalCtrl, pRxData->filteringEnabled, pRxData->filteringDefaultAction);
  475. }
  476. /***************************************************************************
  477. * findFilterRequest *
  478. ****************************************************************************
  479. * DESCRIPTION:
  480. *
  481. *
  482. * INPUTS:
  483. *
  484. *
  485. *
  486. * OUTPUT:
  487. *
  488. * RETURNS:
  489. *
  490. ***************************************************************************/
  491. static int findFilterRequest(TI_HANDLE hRxData, rxDataFilterRequest_t * request)
  492. {
  493. rxData_t * pRxData = (rxData_t *) hRxData;
  494. int i;
  495. for (i = 0; i < MAX_DATA_FILTERS; ++i)
  496. {
  497. if (pRxData->isFilterSet[i])
  498. {
  499. if ((pRxData->filterRequests[i].offset == request->offset) &&
  500. (pRxData->filterRequests[i].maskLength == request->maskLength) &&
  501. (pRxData->filterRequests[i].patternLength == request->patternLength))
  502. {
  503. if ((os_memoryCompare(pRxData->hOs, pRxData->filterRequests[i].mask, request->mask, request->maskLength) == 0) &&
  504. (os_memoryCompare(pRxData->hOs, pRxData->filterRequests[i].pattern, request->pattern, request->patternLength) == 0))
  505. return i;
  506. }
  507. }
  508. }
  509. return -1;
  510. }
  511. /***************************************************************************
  512. * closeFieldPattern *
  513. ****************************************************************************
  514. * DESCRIPTION:
  515. *
  516. *
  517. * INPUTS:
  518. *
  519. *
  520. *
  521. * OUTPUT:
  522. *
  523. * RETURNS:
  524. *
  525. ***************************************************************************/
  526. static void closeFieldPattern(rxData_t * pRxData, rxDataFilterFieldPattern_t * fieldPattern, UINT8 * fieldPatterns, UINT8 * lenFieldPatterns)
  527. {
  528. fieldPatterns[*lenFieldPatterns] = fieldPattern->offset;
  529. *lenFieldPatterns += sizeof(fieldPattern->offset);
  530. fieldPatterns[*lenFieldPatterns] = fieldPattern->length;
  531. *lenFieldPatterns += sizeof(fieldPattern->length);
  532. fieldPatterns[*lenFieldPatterns] = fieldPattern->flag;
  533. *lenFieldPatterns += sizeof(fieldPattern->flag);
  534. os_memoryCopy(pRxData->hOs, fieldPatterns + *lenFieldPatterns, fieldPattern->pattern, fieldPattern->length);
  535. *lenFieldPatterns += fieldPattern->length;
  536. /* if the pattern bit mask is enabled add it to the end of the request */
  537. if ((fieldPattern->flag & RX_DATA_FILTER_FLAG_USE_BIT_MASK) == RX_DATA_FILTER_FLAG_USE_BIT_MASK)
  538. {
  539. os_memoryCopy(pRxData->hOs, fieldPatterns + *lenFieldPatterns, fieldPattern->mask, fieldPattern->length);
  540. *lenFieldPatterns += fieldPattern->length;
  541. }
  542. 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)));
  543. }
  544. /***************************************************************************
  545. * parseRxDataFilterRequest *
  546. ****************************************************************************
  547. * DESCRIPTION:
  548. *
  549. *
  550. * INPUTS:
  551. *
  552. *
  553. *
  554. * OUTPUT:
  555. *
  556. * RETURNS:
  557. *
  558. ***************************************************************************/
  559. static int parseRxDataFilterRequest(TI_HANDLE hRxData, rxDataFilterRequest_t * request, UINT8 * numFieldPatterns, UINT8 * lenFieldPatterns, UINT8 * fieldPatterns)
  560. {
  561. rxData_t * pRxData = (rxData_t *) hRxData;
  562. int maskIter;
  563. int patternIter = 0;
  564. /* used to store field patterns while they are built */
  565. BOOL isBuildingFieldPattern = FALSE;
  566. rxDataFilterFieldPattern_t fieldPattern;
  567. for (maskIter = 0; maskIter < request->maskLength * BIT_TO_BYTE_FACTOR; ++maskIter)
  568. {
  569. /* which byte in the mask and which bit in the byte we're at */
  570. int bit = maskIter % BIT_TO_BYTE_FACTOR;
  571. int byte = maskIter / BIT_TO_BYTE_FACTOR;
  572. /* is the bit in the mask set */
  573. BOOL isSet = ((request->mask[byte] & (1 << bit)) == (1 << bit));
  574. WLAN_REPORT_INFORMATION(pRxData->hReport, RX_DATA_MODULE_LOG,
  575. ("%s: MaskIter = %d, Byte = %d, Bit = %d, isSet = %d\n", __FUNCTION__, maskIter, byte, bit, isSet));
  576. /* if we're in the midst of building a field pattern, we need to close in case */
  577. /* the current bit is not set or we've reached the ethernet header boundary */
  578. if (isBuildingFieldPattern)
  579. {
  580. if ((isSet == FALSE) || (request->offset + maskIter == RX_DATA_FILTER_ETHERNET_HEADER_BOUNDARY))
  581. {
  582. closeFieldPattern(hRxData, &fieldPattern, fieldPatterns, lenFieldPatterns);
  583. isBuildingFieldPattern = FALSE;
  584. }
  585. }
  586. /* nothing to do in case the bit is not set */
  587. if (isSet)
  588. {
  589. /* if not already building a field pattern, create a new one */
  590. if (isBuildingFieldPattern == FALSE)
  591. {
  592. WLAN_REPORT_INFORMATION(pRxData->hReport, RX_DATA_MODULE_LOG,
  593. ("%s: Creating a new field pattern.\n", __FUNCTION__));
  594. isBuildingFieldPattern = TRUE;
  595. ++(*numFieldPatterns);
  596. if (*numFieldPatterns > RX_DATA_FILTER_MAX_FIELD_PATTERNS)
  597. {
  598. WLAN_REPORT_ERROR(pRxData->hReport, RX_DATA_MODULE_LOG,
  599. ("%s: Invalid filter, too many field patterns, maximum of %u is allowed!\n", __FUNCTION__, RX_DATA_FILTER_MAX_FIELD_PATTERNS));
  600. return NOK;
  601. }
  602. fieldPattern.offset = request->offset + maskIter;
  603. fieldPattern.length = 0;
  604. /* we don't support the mask per bit feature yet. */
  605. fieldPattern.flag = RX_DATA_FILTER_FLAG_NO_BIT_MASK;
  606. /* first 14 bits are used for the Ethernet header, rest for the IP header */
  607. if (fieldPattern.offset < RX_DATA_FILTER_ETHERNET_HEADER_BOUNDARY)
  608. {
  609. fieldPattern.flag |= RX_DATA_FILTER_FLAG_ETHERNET_HEADER;
  610. }
  611. else
  612. {
  613. fieldPattern.flag |= RX_DATA_FILTER_FLAG_IP_HEADER;
  614. fieldPattern.offset -= RX_DATA_FILTER_ETHERNET_HEADER_BOUNDARY;
  615. }
  616. WLAN_REPORT_INFORMATION(pRxData->hReport, RX_DATA_MODULE_LOG,
  617. ("%s: offset = %d, flag = %d.\n", __FUNCTION__, fieldPattern.offset, fieldPattern.flag));
  618. }
  619. /* check that the pattern is long enough */
  620. if (patternIter > request->patternLength)
  621. {
  622. WLAN_REPORT_ERROR(pRxData->hReport, RX_DATA_MODULE_LOG,
  623. ("%s: Invalid filter, mask and pattern lengths are not consistent!\n", __FUNCTION__));
  624. return NOK;
  625. }
  626. /* add the current pattern byte to the field pattern */
  627. fieldPattern.pattern[fieldPattern.length++] = request->pattern[patternIter++];
  628. /* check pattern matching boundary */
  629. if (fieldPattern.offset + fieldPattern.length >= RX_DATA_FILTER_FILTER_BOUNDARY)
  630. {
  631. WLAN_REPORT_ERROR(pRxData->hReport, RX_DATA_MODULE_LOG,
  632. ("%s: Invalid filter, pattern matching cannot exceed first %u characters.\n", __FUNCTION__, RX_DATA_FILTER_FILTER_BOUNDARY));
  633. return NOK;
  634. }
  635. }
  636. }
  637. /* check that the pattern is long enough */
  638. if (patternIter != request->patternLength)
  639. {
  640. WLAN_REPORT_ERROR(pRxData->hReport, RX_DATA_MODULE_LOG,
  641. ("%s: Invalid filter, mask and pattern lengths are not consistent!\n", __FUNCTION__));
  642. return NOK;
  643. }
  644. /* close the last field pattern if needed */
  645. if (isBuildingFieldPattern)
  646. {
  647. closeFieldPattern(hRxData, &fieldPattern, fieldPatterns, lenFieldPatterns);
  648. }
  649. return OK;
  650. }
  651. /***************************************************************************
  652. * rxData_setRxDataFilter *
  653. ****************************************************************************
  654. * DESCRIPTION:
  655. *
  656. *
  657. * INPUTS:
  658. *
  659. *
  660. *
  661. * OUTPUT:
  662. *
  663. * RETURNS:
  664. *
  665. ***************************************************************************/
  666. static TI_STATUS rxData_addRxDataFilter(TI_HANDLE hRxData, rxDataFilterRequest_t * request)
  667. {
  668. rxData_t * pRxData = (rxData_t *) hRxData;
  669. /* firmware request fields */
  670. UINT8 index = 0;
  671. UINT8 numFieldPatterns = 0;
  672. UINT8 lenFieldPatterns = 0;
  673. UINT8 fieldPatterns[MAX_DATA_FILTER_SIZE];
  674. WLAN_REPORT_INFORMATION(pRxData->hReport, RX_DATA_MODULE_LOG,
  675. ("rxData_addRxDataFilter, offset=0x%x, maskLength=0x%x, patternLength=0x%x\n",
  676. request->offset,
  677. request->maskLength,
  678. request->patternLength));
  679. WLAN_REPORT_HEX_INFORMATION(pRxData->hReport, RX_DATA_MODULE_LOG, request->mask, request->maskLength);
  680. WLAN_REPORT_HEX_INFORMATION(pRxData->hReport, RX_DATA_MODULE_LOG, request->pattern, request->patternLength);
  681. /* does the filter already exist? */
  682. if (findFilterRequest(hRxData, request) >= 0)
  683. {
  684. WLAN_REPORT_INFORMATION(pRxData->hReport, RX_DATA_MODULE_LOG,
  685. ("%s: Filter already exists.\n", __FUNCTION__));
  686. return RX_FILTER_ALREADY_EXISTS;
  687. }
  688. /* find place for insertion */
  689. for (index = 0; index < MAX_DATA_FILTERS; ++index)
  690. {
  691. if (pRxData->isFilterSet[index] == FALSE)
  692. break;
  693. }
  694. /* are all filter slots taken? */
  695. if (index == MAX_DATA_FILTERS)
  696. {
  697. WLAN_REPORT_ERROR(pRxData->hReport, RX_DATA_MODULE_LOG,
  698. ("%s: No place to insert filter!\n", __FUNCTION__));
  699. return RX_NO_AVAILABLE_FILTERS;
  700. }
  701. WLAN_REPORT_INFORMATION(pRxData->hReport, RX_DATA_MODULE_LOG,
  702. ("%s: Inserting filter at index %d.\n", __FUNCTION__, index));
  703. /* parse the filter request into discrete field patterns */
  704. if (parseRxDataFilterRequest(hRxData, request, &numFieldPatterns, &lenFieldPatterns, fieldPatterns) != OK)
  705. return NOK;
  706. if (numFieldPatterns == 0)
  707. return NOK;
  708. /* store configuration for future manipulation */
  709. pRxData->isFilterSet[index] = TRUE;
  710. os_memoryCopy(pRxData->hOs, &pRxData->filterRequests[index], request, sizeof(pRxData->filterRequests[index]));
  711. /* send configuration to firmware */
  712. return (TI_STATUS) whalCtrl_setRxDataFilter(pRxData->hHalCtrl, index, ADD_FILTER, FILTER_SIGNAL,
  713. numFieldPatterns, lenFieldPatterns, fieldPatterns);
  714. return OK;
  715. }
  716. /***************************************************************************
  717. * rxData_removeRxDataFilter *
  718. ****************************************************************************
  719. * DESCRIPTION:
  720. *
  721. *
  722. * INPUTS:
  723. *
  724. *
  725. *
  726. * OUTPUT:
  727. *
  728. * RETURNS:
  729. *
  730. ***************************************************************************/
  731. static TI_STATUS rxData_removeRxDataFilter(TI_HANDLE hRxData, rxDataFilterRequest_t * request)
  732. {
  733. rxData_t * pRxData = (rxData_t *) hRxData;
  734. int index = findFilterRequest(hRxData, request);
  735. WLAN_REPORT_INFORMATION(pRxData->hOs, RX_DATA_MODULE_LOG,
  736. ("rxData_removeRxDataFilter, offset=0x%x, maskLength=0x%x, patternLength=0x%x\n",
  737. request->offset,
  738. request->maskLength,
  739. request->patternLength));
  740. WLAN_REPORT_HEX_INFORMATION(pRxData->hReport, RX_DATA_MODULE_LOG, request->mask, request->maskLength);
  741. WLAN_REPORT_HEX_INFORMATION(pRxData->hReport, RX_DATA_MODULE_LOG, request->pattern, request->patternLength);
  742. /* does the filter exist? */
  743. if (index < 0)
  744. {
  745. WLAN_REPORT_WARNING(pRxData->hOs, RX_DATA_MODULE_LOG,
  746. ("%s: Remove data filter request received but the specified filter was not found!", __FUNCTION__));
  747. return RX_FILTER_DOES_NOT_EXIST;
  748. }
  749. WLAN_REPORT_INFORMATION(pRxData->hOs, RX_DATA_MODULE_LOG,
  750. ("%s: Removing filter at index %d.", __FUNCTION__, index));
  751. pRxData->isFilterSet[index] = FALSE;
  752. return (TI_STATUS) whalCtrl_setRxDataFilter(pRxData->hHalCtrl, index, REMOVE_FILTER,
  753. FILTER_SIGNAL, 0, 0, NULL);
  754. return OK;
  755. }
  756. /***************************************************************************
  757. * rxData_DistributorRxEvent *
  758. ****************************************************************************
  759. * DESCRIPTION:
  760. *
  761. *
  762. * INPUTS:
  763. *
  764. *
  765. *
  766. * OUTPUT:
  767. *
  768. * RETURNS:
  769. *
  770. ***************************************************************************/
  771. static VOID rxData_DistributorRxEvent(rxData_t *pRxData,UINT16 Mask,int DataLen)
  772. {
  773. DistributorMgr_EventCall(pRxData->RxEventDistributor,Mask,DataLen);
  774. }
  775. /***************************************************************************
  776. * rxData_RegNotif *
  777. ****************************************************************************/
  778. TI_HANDLE rxData_RegNotif(TI_HANDLE hRxData,UINT16 EventMask,GeneralEventCall_t CallBack,TI_HANDLE context,UINT32 Cookie)
  779. {
  780. rxData_t *pRxData = (rxData_t *)hRxData;
  781. if (!hRxData)
  782. return NULL;
  783. return DistributorMgr_Reg(pRxData->RxEventDistributor,EventMask,(TI_HANDLE)CallBack,context,Cookie);
  784. }
  785. /***************************************************************************
  786. * rxData_AddToNotifMask *
  787. ****************************************************************************/
  788. TI_STATUS rxData_AddToNotifMask(TI_HANDLE hRxData,TI_HANDLE Notifh,UINT16 EventMask)
  789. {
  790. rxData_t *pRxData = (rxData_t *)hRxData;
  791. if (!hRxData)
  792. return NOK;
  793. return DistributorMgr_AddToMask(pRxData->RxEventDistributor,Notifh,EventMask);
  794. }
  795. /***************************************************************************
  796. * rxData_UnRegNotif *
  797. ****************************************************************************/
  798. TI_STATUS rxData_UnRegNotif(TI_HANDLE hRxData,TI_HANDLE RegEventHandle)
  799. {
  800. TI_STATUS status;
  801. rxData_t *pRxData = (rxData_t *)hRxData;
  802. if (!hRxData)
  803. return NOK;
  804. status = DistributorMgr_UnReg(pRxData->RxEventDistributor,RegEventHandle);
  805. return (status);
  806. }
  807. /***************************************************************************
  808. * rxData_receiveMsduFromWlan *
  809. ****************************************************************************
  810. * DESCRIPTION: this function is called by the GWSI for each received msdu.
  811. * It filter and distribute the received msdu.
  812. *
  813. * INPUTS: hRxData - the object
  814. * pMsdu - the received msdu.
  815. * pRxAttr - Rx attributes
  816. *
  817. * OUTPUT:
  818. *
  819. * RETURNS:
  820. ***************************************************************************/
  821. void rxData_receiveMsduFromWlan(TI_HANDLE hRxData, mem_MSDU_T *pMsdu, Rx_attr_t* pRxAttr)
  822. {
  823. rxData_t *pRxData = (rxData_t *)hRxData;
  824. macAddress_t address3;
  825. dot11_header_t *pDot11Hdr;
  826. UINT16 tmpFCtrl;
  827. WLAN_REPORT_INFORMATION(pRxData->hReport, RX_DATA_MODULE_LOG,
  828. (" rxData_receiveMsduFromWlan() : pRxAttr->packetType = %d\n", pRxAttr->packetType));
  829. switch (pRxAttr->packetType)
  830. {
  831. case RX_PACKET_TYPE_MANAGEMENT:
  832. WLAN_REPORT_INFORMATION(pRxData->hReport, RX_DATA_MODULE_LOG,
  833. (" rxData_receiveMsduFromWlan() : Received management msdu len = %d\n", pMsdu->dataLen));
  834. /* update siteMngr
  835. *
  836. * the BSSID in mgmt frames is always addr3 in the header
  837. * must copy address3 since msdu is freed in mlmeParser_recv
  838. */
  839. pDot11Hdr = (dot11_header_t*)(memMgr_BufData(pMsdu->firstBDPtr)
  840. +memMgr_BufOffset(pMsdu->firstBDPtr));
  841. os_memoryCopy(pRxData->hOs, &address3, &pDot11Hdr->address3, sizeof(address3));
  842. tmpFCtrl = ((pDot11Hdr->fc & DOT11_FC_SUB_MASK) >> 4) ;
  843. if((tmpFCtrl == BEACON) || (tmpFCtrl == PROBE_RESPONSE))
  844. {
  845. if (NOK == siteMgr_CheckRxSignalValidity(pRxData->hSiteMgr, pRxAttr->Rssi, pRxAttr->channel,&address3))
  846. {
  847. wlan_memMngrFreeMSDU(pRxData->hMemMngr, memMgr_MsduHandle(pMsdu));
  848. break;
  849. }
  850. }
  851. /* distribute mgmt msdu to mlme */
  852. wlan_memMngrChangeMsduOwner(pRxData->hMemMngr,MLME_RX_MODULE,pMsdu);
  853. if( mlmeParser_recv(pRxData->hMlme, pMsdu, pRxAttr) != OK )
  854. {
  855. WLAN_REPORT_WARNING(pRxData->hReport, RX_DATA_MODULE_LOG,
  856. (" rxData_receiveMsduFromWlan() : error sending msdu to MLME \n"));
  857. break;
  858. }
  859. if((tmpFCtrl == BEACON) || (tmpFCtrl == PROBE_RESPONSE))
  860. {
  861. siteMgr_updateRxSignal(pRxData->hSiteMgr, pRxAttr->SNR,
  862. pRxAttr->Rssi, pRxAttr->Rate, &address3, FALSE);
  863. /*WLAN_REPORT_INFORMATION(pRxData->hReport, RX_DATA_MODULE_LOG,
  864. (" SIGNAL QUALITY :RX_LEVEL = %d :: SNR = %d \n", pRxAttr->RxLevel,pRxAttr->SNR)); */
  865. }
  866. break;
  867. case RX_PACKET_TYPE_DATA:
  868. WLAN_REPORT_INFORMATION(pRxData->hReport, RX_DATA_MODULE_LOG,
  869. (" rxData_receiveMsduFromWlan() : Received Data MSDU len = %d\n", pMsdu->dataLen));
  870. /* send MSDU to data dispatcher */
  871. rxData_dataMsduDisptcher(hRxData, pMsdu, pRxAttr);
  872. break;
  873. default:
  874. WLAN_REPORT_ERROR(pRxData->hReport, RX_DATA_MODULE_LOG,
  875. (" rxData_receiveMsduFromWlan() : Received unspecified packet type !!! \n"));
  876. WLAN_REPORT_DEBUG_RX(pRxData->hReport,
  877. (" rxData_receiveMsduFromWlan() : Received unspecified packet type !!! \n"));
  878. wlan_memMngrFreeMSDU(pRxData->hMemMngr, memMgr_MsduHandle(pMsdu));
  879. break;
  880. }
  881. }
  882. /***************************************************************************
  883. * rxData_dataMsduDisptcher *
  884. ****************************************************************************
  885. * DESCRIPTION: this function is called upon receving data MSDU,
  886. * it dispatches the packet to the approciate function according to
  887. * data packet type and rx port status.
  888. *
  889. * INPUTS: hRxData - the object
  890. * pMsdu - the received msdu.
  891. * pRxAttr - Rx attributes
  892. *
  893. * OUTPUT:
  894. *
  895. * RETURNS:
  896. ***************************************************************************/
  897. static void rxData_dataMsduDisptcher(TI_HANDLE hRxData, mem_MSDU_T *pMsdu, Rx_attr_t* pRxAttr)
  898. {
  899. rxData_t *pRxData = (rxData_t *)hRxData;
  900. portStatus_e DataPortStatus;
  901. rxDataPacketType_e DataPacketType;
  902. /* get rx port status */
  903. DataPortStatus = pRxData->rxDataPortStatus;
  904. /* discard data packets received while rx data port is closed */
  905. if (DataPortStatus == CLOSE)
  906. {
  907. WLAN_REPORT_INFORMATION(pRxData->hReport, RX_DATA_MODULE_LOG,
  908. (" rxData_dataMsduDisptcher() : Received Data msdu while Rx data port is closed \n", pMsdu->dataLen));
  909. rxData_discardMsdu(hRxData,pMsdu, pRxAttr);
  910. return;
  911. }
  912. /* get data packet type */
  913. #ifdef EXC_MODULE_INCLUDED
  914. if (excMngr_isIappPacket(pRxData->hExcMgr, pMsdu) == TRUE)
  915. {
  916. WLAN_REPORT_INFORMATION(pRxData->hReport, RX_DATA_MODULE_LOG,
  917. (" rxData_dataMsduDisptcher() : Received Iapp msdu \n"));
  918. DataPacketType = DATA_IAPP_PACKET;
  919. }
  920. else
  921. #endif
  922. {
  923. UINT16 etherType;
  924. EthernetHeader_t * pEthernetHeader;
  925. /*
  926. * if Host processes received packets, the header translation
  927. * from WLAN to ETH is done here. The conversion has been moved
  928. * here so that IAPP packets aren't converted.
  929. */
  930. rxData_convertWlanToEthHeader(hRxData,pMsdu,&etherType);
  931. pEthernetHeader = (EthernetHeader_t *)(memMgr_BufData(pMsdu->firstBDPtr) + memMgr_BufOffset(pMsdu->firstBDPtr));
  932. if (etherType == ETHERTYPE_802_1D)
  933. {
  934. WLAN_REPORT_INFORMATION(pRxData->hReport, RX_DATA_MODULE_LOG,
  935. (" rxData_dataMsduDisptcher() : Received VLAN msdu \n"));
  936. DataPacketType = DATA_VLAN_PACKET;
  937. }
  938. else if(pEthernetHeader->TypeLength == EAPOL_PACKET)
  939. {
  940. WLAN_REPORT_INFORMATION(pRxData->hReport, RX_DATA_MODULE_LOG,
  941. (" rxData_dataMsduDisptcher() : Received Eapol msdu \n"));
  942. DataPacketType = DATA_EAPOL_PACKET;
  943. }
  944. else
  945. {
  946. WLAN_REPORT_INFORMATION(pRxData->hReport, RX_DATA_MODULE_LOG,
  947. (" rxData_dataMsduDisptcher() : Received Data msdu \n"));
  948. DataPacketType = DATA_DATA_PACKET;
  949. }
  950. }
  951. /* dispatch Msdu according to packet type and current rx data port status */
  952. pRxData->rxData_dispatchMsdu[DataPortStatus][DataPacketType](hRxData,pMsdu,pRxAttr);
  953. }
  954. /***************************************************************************
  955. * rxData_discardMsdu *
  956. ****************************************************************************
  957. * DESCRIPTION: this function is called to discard MSDU
  958. *
  959. * INPUTS: hRxData - the object
  960. * pMsdu - the received msdu.
  961. * pRxAttr - Rx attributes
  962. *
  963. * OUTPUT:
  964. *
  965. * RETURNS:
  966. ***************************************************************************/
  967. static void rxData_discardMsdu(TI_HANDLE hRxData, mem_MSDU_T *pMsdu, Rx_attr_t* pRxAttr)
  968. {
  969. rxData_t *pRxData = (rxData_t *)hRxData;
  970. WLAN_REPORT_INFORMATION(pRxData->hReport, RX_DATA_MODULE_LOG,
  971. (" rxData_discardMsdu: rx port status = %d , Msdu status = %d \n",pRxData->rxDataPortStatus,pRxAttr->status));
  972. WLAN_REPORT_DEBUG_RX(pRxData->hReport,
  973. (" rxData_discardMsdu: rx port status = %d , Msdu status = %d \n",pRxData->rxDataPortStatus,pRxAttr->status));
  974. pRxData->rxDataDbgCounters.excludedFrameCounter++;
  975. /* free Msdu */
  976. wlan_memMngrFreeMSDU(pRxData->hMemMngr, memMgr_MsduHandle(pMsdu));
  977. }
  978. /***************************************************************************
  979. * rxData_discardMsduVlan *
  980. ****************************************************************************
  981. * DESCRIPTION: this function is called to discard MSDU
  982. *
  983. * INPUTS: hRxData - the object
  984. * pMsdu - the received msdu.
  985. * pRxAttr - Rx attributes
  986. *
  987. * OUTPUT:
  988. *
  989. * RETURNS:
  990. ***************************************************************************/
  991. static void rxData_discardMsduVlan(TI_HANDLE hRxData, mem_MSDU_T *pMsdu, Rx_attr_t* pRxAttr)
  992. {
  993. rxData_t *pRxData = (rxData_t *)hRxData;
  994. WLAN_REPORT_WARNING(pRxData->hReport, RX_DATA_MODULE_LOG,
  995. (" rxData_discardMsduVlan : drop packet that contains VLAN tag\n"));
  996. pRxData->rxDataDbgCounters.rxDroppedDueToVLANIncludedCnt++;
  997. /* free Msdu */
  998. wlan_memMngrFreeMSDU(pRxData->hMemMngr, memMgr_MsduHandle(pMsdu));
  999. }
  1000. /***************************************************************************
  1001. * rxData_rcvMsduInOpenNotify *
  1002. ****************************************************************************
  1003. * DESCRIPTION: this function is called upon receving data Eapol packet type
  1004. * while rx port status is "open notify"
  1005. *
  1006. * INPUTS: hRxData - the object
  1007. * pMsdu - the received msdu.
  1008. * pRxAttr - Rx attributes
  1009. *
  1010. * OUTPUT:
  1011. *
  1012. * RETURNS:
  1013. ***************************************************************************/
  1014. static void rxData_rcvMsduInOpenNotify(TI_HANDLE hRxData, mem_MSDU_T *pMsdu, Rx_attr_t* pRxAttr)
  1015. {
  1016. rxData_t *pRxData = (rxData_t *)hRxData;
  1017. WLAN_REPORT_INFORMATION(pRxData->hReport, RX_DATA_MODULE_LOG,
  1018. (" rxData_rcvMsduInOpenNotify: receiving data packet while in rx port status is open notify\n"));
  1019. WLAN_REPORT_DEBUG_RX(pRxData->hReport,
  1020. (" rxData_rcvMsduInOpenNotify: ERROR !!! receiving data packet while in rx port status is open notify\n"));
  1021. pRxData->rxDataDbgCounters.rcvUnicastFrameInOpenNotify++;
  1022. /* free msdu */
  1023. wlan_memMngrFreeMSDU(pRxData->hMemMngr, memMgr_MsduHandle(pMsdu));
  1024. }
  1025. /***************************************************************************
  1026. * rxData_rcvMsduEapol *
  1027. ****************************************************************************
  1028. * DESCRIPTION: this function is called upon receving data Eapol packet type
  1029. * while rx port status is "open eapol"
  1030. *
  1031. * INPUTS: hRxData - the object
  1032. * pMsdu - the received msdu.
  1033. * pRxAttr - Rx attributes
  1034. *
  1035. * OUTPUT:
  1036. *
  1037. * RETURNS:
  1038. ***************************************************************************/
  1039. static void rxData_rcvMsduEapol(TI_HANDLE hRxData, mem_MSDU_T *pMsdu, Rx_attr_t* pRxAttr)
  1040. {
  1041. rxData_t *pRxData = (rxData_t *)hRxData;
  1042. WLAN_REPORT_INFORMATION(pRxData->hReport, RX_DATA_MODULE_LOG,
  1043. (" rxData_rcvMsduEapol() : Received an EAPOL frame tranferred to OS\n"));
  1044. WLAN_REPORT_DEBUG_RX(pRxData->hReport,
  1045. (" rxData_rcvMsduEapol() : Received an EAPOL frame tranferred to OS\n"));
  1046. EvHandlerSendEvent(pRxData->hEvHandler, IPC_EVENT_EAPOL,
  1047. (UINT8*)(pMsdu->firstBDPtr->data + pMsdu->firstBDPtr->dataOffset),
  1048. pMsdu->firstBDPtr->length);
  1049. wlan_memMngrChangeMsduOwner(pRxData->hMemMngr,OS_ABS_RX_MODULE,pMsdu);
  1050. os_receivePacket(pRxData->hOs, pMsdu, (UINT16)pMsdu->dataLen);
  1051. }
  1052. /***************************************************************************
  1053. * rxData_rcvMsduData *
  1054. ****************************************************************************
  1055. * DESCRIPTION: this function is called upon receving data "data" packet type
  1056. * while rx port status is "open"
  1057. *
  1058. * INPUTS: hRxData - the object
  1059. * pMsdu - the received msdu.
  1060. * pRxAttr - Rx attributes
  1061. *
  1062. * OUTPUT:
  1063. *
  1064. * RETURNS:
  1065. ***************************************************************************/
  1066. static void rxData_rcvMsduData(TI_HANDLE hRxData, mem_MSDU_T *pMsdu, Rx_attr_t* pRxAttr)
  1067. {
  1068. #if defined(CONFIG_TROUT_PWRSINK) || defined(CONFIG_HTC_PWRSINK)
  1069. extern unsigned long num_rx_pkt_new;
  1070. #endif
  1071. rxData_t *pRxData = (rxData_t *)hRxData;
  1072. EthernetHeader_t *pEthernetHeader;
  1073. UINT16 EventMask = 0;
  1074. ctrlData_t *pCtrlData;
  1075. WLAN_REPORT_INFORMATION(pRxData->hReport, RX_DATA_MODULE_LOG,
  1076. (" rxData_rcvMsduData() : Received DATA frame tranferred to OS\n"));
  1077. WLAN_REPORT_DEBUG_RX(pRxData->hReport,
  1078. (" rxData_rcvMsduData() : Received DATA frame tranferred to OS\n"));
  1079. /* check encryption status */
  1080. pEthernetHeader = (EthernetHeader_t *)(memMgr_BufData(pMsdu->firstBDPtr) + memMgr_BufOffset(pMsdu->firstBDPtr));
  1081. if (IsMacAddressDirected(&pEthernetHeader->DstAddr))
  1082. { /* unicast frame */
  1083. if((pRxData->rxDataExcludeUnencrypted) && (!(pRxAttr->packetInfo & RX_PACKET_FLAGS_ENCRYPTION)))
  1084. {
  1085. pRxData->rxDataDbgCounters.excludedFrameCounter++;
  1086. /* free msdu */
  1087. WLAN_REPORT_WARNING(pRxData->hReport, RX_DATA_MODULE_LOG,
  1088. (" rxData_rcvMsduData() : exclude unicast unencrypted is TRUE & packet encryption is OFF\n"));
  1089. wlan_memMngrFreeMSDU(pRxData->hMemMngr, memMgr_MsduHandle(pMsdu));
  1090. return;
  1091. }
  1092. }
  1093. else
  1094. { /* broadcast frame */
  1095. if ((pRxData->rxDataExludeBroadcastUnencrypted) && (!(pRxAttr->packetInfo & RX_PACKET_FLAGS_ENCRYPTION)))
  1096. {
  1097. pRxData->rxDataDbgCounters.excludedFrameCounter++;
  1098. /* free msdu */
  1099. WLAN_REPORT_WARNING(pRxData->hReport, RX_DATA_MODULE_LOG,
  1100. (" rxData_receiveMsduFromWlan() : exclude broadcast unencrypted is TRUE & packet encryption is OFF\n"));
  1101. wlan_memMngrFreeMSDU(pRxData->hMemMngr, memMgr_MsduHandle(pMsdu));
  1102. return;
  1103. }
  1104. /*
  1105. * Discard multicast/broadcast frames that we sent ourselves.
  1106. * Per IEEE 802.11-2007 section 9.2.7: "STAs shall filter out
  1107. * broadcast/multicast messages that contain their address as
  1108. * the source address."
  1109. */
  1110. pCtrlData = (ctrlData_t *)pRxData->hCtrlData;
  1111. if (IsMacAddressEqual(&pCtrlData->ctrlDataDeviceMacAddress, &pEthernetHeader->SrcAddr))
  1112. {
  1113. pRxData->rxDataDbgCounters.excludedFrameCounter++;
  1114. /* free msdu */
  1115. wlan_memMngrFreeMSDU(pRxData->hMemMngr, memMgr_MsduHandle(pMsdu));
  1116. return;
  1117. }
  1118. }
  1119. /* update traffic monitor parameters */
  1120. pRxData->rxDataCounters.RecvOk++;
  1121. EventMask |= RECV_OK;
  1122. if ( IsMacAddressDirected(&pEthernetHeader->DstAddr))
  1123. {
  1124. /* Directed frame */
  1125. pRxData->rxDataCounters.DirectedFramesRecv++;
  1126. pRxData->rxDataCounters.DirectedBytesRecv += pMsdu->dataLen;
  1127. EventMask |= DIRECTED_BYTES_RECV;
  1128. EventMask |= DIRECTED_FRAMES_RECV;
  1129. #if defined(CONFIG_TROUT_PWRSINK) || defined(CONFIG_HTC_PWRSINK)
  1130. num_rx_pkt_new++;
  1131. #endif
  1132. }
  1133. else if ( IsMacAddressBroadcast(&pEthernetHeader->DstAddr))
  1134. {
  1135. /* Broadcast frame */
  1136. pRxData->rxDataCounters.BroadcastFramesRecv++;
  1137. pRxData->rxDataCounters.BroadcastBytesRecv += pMsdu->dataLen;
  1138. EventMask |= BROADCAST_BYTES_RECV;
  1139. EventMask |= BROADCAST_FRAMES_RECV;
  1140. }
  1141. else
  1142. {
  1143. /* Multicast Address */
  1144. pRxData->rxDataCounters.MulticastFramesRecv++;
  1145. pRxData->rxDataCounters.MulticastBytesRecv += pMsdu->

Large files files are truncated, but you can click here to view the full file