nic_rx.h 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420
  1. /*
  2. ** Id: //Department/DaVinci/BRANCHES/MT6620_WIFI_DRIVER_V2_3/include/nic/nic_rx.h#1
  3. */
  4. /*! \file "nic_rx.h"
  5. \brief The declaration of the nic rx functions
  6. */
  7. /*
  8. ** Log: nic_rx.h
  9. *
  10. * 11 07 2011 tsaiyuan.hsu
  11. * [WCXRP00001083] [MT6620 Wi-Fi][DRV]] dump debug counter or frames when debugging is triggered
  12. * add debug counters and periodically dump counters for debugging.
  13. *
  14. * 05 05 2011 cp.wu
  15. * [WCXRP00000702] [MT5931][Driver] Modify initialization sequence for E1 ASIC
  16. * add delay after whole-chip resetting for MT5931 E1 ASIC.
  17. *
  18. * 04 18 2011 terry.wu
  19. * [WCXRP00000660] [MT6620 Wi-Fi][Driver] Remove flag CFG_WIFI_DIRECT_MOVED
  20. * Remove flag CFG_WIFI_DIRECT_MOVED.
  21. *
  22. * 01 24 2011 cm.chang
  23. * [WCXRP00000384] [MT6620 Wi-Fi][Driver][FW] Handle 20/40 action frame in AP mode
  24. * and stop ampdu timer when sta_rec is freed
  25. * Process received 20/40 coexistence action frame for AP mode
  26. *
  27. * 09 08 2010 cp.wu
  28. * NULL
  29. * use static memory pool for storing IEs of scanning result.
  30. *
  31. * 09 07 2010 yuche.tsai
  32. * NULL
  33. * Change prototype of API of adding P2P device to scan result.
  34. * Additional IE buffer is saved.
  35. *
  36. * 09 03 2010 kevin.huang
  37. * NULL
  38. * Refine #include sequence and solve recursive/nested #include issue
  39. *
  40. * 08 05 2010 yuche.tsai
  41. * NULL
  42. * Modify data structure for P2P Scan result.
  43. *
  44. * 08 03 2010 cp.wu
  45. * NULL
  46. * newly added P2P API should be declared in header file.
  47. *
  48. * 07 30 2010 cp.wu
  49. * NULL
  50. * 1) BoW wrapper: use definitions instead of hard-coded constant for error code
  51. * 2) AIS-FSM: eliminate use of desired RF parameters, use prTargetBssDesc instead
  52. * 3) add handling for RX_PKT_DESTINATION_HOST_WITH_FORWARD for GO-broadcast frames
  53. *
  54. * 07 08 2010 cp.wu
  55. *
  56. * [WPD00003833] [MT6620 and MT5931] Driver migration - move to new repository.
  57. *
  58. * 06 14 2010 cp.wu
  59. * [WPD00003833][MT6620 and MT5931] Driver migration
  60. * saa_fsm.c is migrated.
  61. *
  62. * 06 14 2010 cp.wu
  63. * [WPD00003833][MT6620 and MT5931] Driver migration
  64. * add management dispatching function table.
  65. *
  66. * 06 11 2010 cp.wu
  67. * [WPD00003833][MT6620 and MT5931] Driver migration
  68. * 1) migrate assoc.c.
  69. * 2) add ucTxSeqNum for tracking frames which needs TX-DONE awareness
  70. * 3) add configuration options for CNM_MEM and RSN modules
  71. * 4) add data path for management frames
  72. * 5) eliminate rPacketInfo of MSDU_INFO_T
  73. *
  74. * 06 06 2010 kevin.huang
  75. * [WPD00003832][MT6620 5931] Create driver base
  76. * [MT6620 5931] Create driver base
  77. *
  78. * 03 30 2010 cp.wu
  79. * [WPD00001943]Create WiFi test driver framework on WinXP
  80. * remove driver-land statistics.
  81. *
  82. * 03 24 2010 cp.wu
  83. * [WPD00001943]Create WiFi test driver framework on WinXP
  84. * generate information for OID_GEN_RCV_OK & OID_GEN_XMIT_OK
  85. * *
  86. *
  87. * 03 11 2010 cp.wu
  88. * [WPD00003821][BUG] Host driver stops processing RX packets from HIF RX0
  89. * add RX starvation warning debug message controlled by CFG_HIF_RX_STARVATION_WARNING
  90. *
  91. * 03 10 2010 cp.wu
  92. * [WPD00001943]Create WiFi test driver framework on WinXP
  93. * code clean: removing unused variables and structure definitions
  94. *
  95. * 02 25 2010 cp.wu
  96. * [WPD00001943]Create WiFi test driver framework on WinXP
  97. * correct behavior to prevent duplicated RX handling for RX0_DONE and RX1_DONE
  98. *
  99. * 02 10 2010 cp.wu
  100. * [WPD00001943]Create WiFi test driver framework on WinXP
  101. * implement host-side firmware download logic
  102. *
  103. * 02 10 2010 cp.wu
  104. * [WPD00001943]Create WiFi test driver framework on WinXP
  105. * 1) remove unused function in nic_rx.c [which has been handled in que_mgt.c]
  106. * * 2) firmware image length is now retrieved via NdisFileOpen
  107. * * 3) firmware image is not structured by (P_IMG_SEC_HDR_T) anymore
  108. * * 4) nicRxWaitResponse() revised
  109. * * 5) another set of TQ counter default value is added for fw-download state
  110. * * 6) Wi-Fi load address is now retrieved from registry too
  111. *
  112. * 12 30 2009 cp.wu
  113. * [WPD00001943]Create WiFi test driver framework on WinXP
  114. * 1) According to CMD/EVENT documentation v0.8,
  115. * * * * OID_CUSTOM_TEST_RX_STATUS & OID_CUSTOM_TEST_TX_STATUS is no longer used,
  116. * * * * and result is retrieved by get ATInfo instead
  117. * * * * 2) add 4 counter for recording aggregation statistics
  118. ** \main\maintrunk.MT6620WiFiDriver_Prj\24 2009-12-10 16:49:09 GMT mtk02752
  119. ** code clean
  120. ** \main\maintrunk.MT6620WiFiDriver_Prj\23 2009-12-09 14:02:37 GMT MTK02468
  121. ** Added ucStaRecIdx in SW_RFB_T and HALF_SEQ_NO_COUNT definition (to replace HALF_SEQ_NO_CNOUT)
  122. ** \main\maintrunk.MT6620WiFiDriver_Prj\22 2009-11-27 11:07:54 GMT mtk02752
  123. ** add flush for reset
  124. ** \main\maintrunk.MT6620WiFiDriver_Prj\21 2009-11-25 18:18:09 GMT mtk02752
  125. ** modify nicRxAddScanResult()
  126. ** \main\maintrunk.MT6620WiFiDriver_Prj\20 2009-11-24 22:42:22 GMT mtk02752
  127. ** add nicRxAddScanResult() to prepare to handle SCAN_RESULT event
  128. ** \main\maintrunk.MT6620WiFiDriver_Prj\19 2009-11-24 19:57:06 GMT mtk02752
  129. ** adopt P_HIF_RX_HEADER_T
  130. ** \main\maintrunk.MT6620WiFiDriver_Prj\18 2009-11-16 21:43:04 GMT mtk02752
  131. ** correct ENUM_RX_PKT_DESTINATION_T definitions
  132. ** \main\maintrunk.MT6620WiFiDriver_Prj\17 2009-11-16 15:28:25 GMT mtk02752
  133. ** add ucQueuedPacketNum for indicating how many packet are queued by RX reordering buffer/forwarding path
  134. ** \main\maintrunk.MT6620WiFiDriver_Prj\16 2009-11-16 15:05:01 GMT mtk02752
  135. ** add eTC for SW_RFB_T and structure RX_MAILBOX
  136. ** \main\maintrunk.MT6620WiFiDriver_Prj\15 2009-11-13 21:16:57 GMT mtk02752
  137. ** \main\maintrunk.MT6620WiFiDriver_Prj\14 2009-11-13 16:59:30 GMT mtk02752
  138. ** add handler for event packet
  139. ** \main\maintrunk.MT6620WiFiDriver_Prj\13 2009-11-13 13:45:50 GMT mtk02752
  140. ** add port param for nicRxEnhanceReadBuffer()
  141. ** \main\maintrunk.MT6620WiFiDriver_Prj\12 2009-11-11 10:12:31 GMT mtk02752
  142. ** nicSDIOReadIntStatus() always read sizeof(ENHANCE_MODE_DATA_STRUCT_T) for int response,
  143. ** thus the number should be set to 0(:=16) instead of 10
  144. ** \main\maintrunk.MT6620WiFiDriver_Prj\11 2009-10-29 19:53:32 GMT mtk01084
  145. ** modify structure naming
  146. ** \main\maintrunk.MT6620WiFiDriver_Prj\10 2009-10-23 16:08:23 GMT mtk01084
  147. ** \main\maintrunk.MT6620WiFiDriver_Prj\9 2009-10-13 21:59:01 GMT mtk01084
  148. ** update for new HW architecture design
  149. ** \main\maintrunk.MT6620WiFiDriver_Prj\8 2009-05-20 12:23:33 GMT mtk01461
  150. ** Add u4MaxEventBufferLen parameter to nicRxWaitResponse()
  151. ** \main\maintrunk.MT6620WiFiDriver_Prj\7 2009-05-18 21:00:48 GMT mtk01426
  152. ** Update SDIO_MAXIMUM_RX_STATUS value
  153. ** \main\maintrunk.MT6620WiFiDriver_Prj\6 2009-04-28 10:36:15 GMT mtk01461
  154. ** Remove unused define - SDIO_MAXIMUM_TX_STATUS
  155. ** \main\maintrunk.MT6620WiFiDriver_Prj\5 2009-04-01 10:53:17 GMT mtk01461
  156. ** Add function for HIF_LOOPBACK_PRE_TEST
  157. ** \main\maintrunk.MT6620WiFiDriver_Prj\4 2009-03-18 20:56:19 GMT mtk01426
  158. ** Add to support CFG_HIF_LOOPBACK and CFG_SDIO_RX_ENHANCE
  159. ** \main\maintrunk.MT6620WiFiDriver_Prj\3 2009-03-17 20:19:56 GMT mtk01426
  160. ** Add nicRxWaitResponse function proto type
  161. ** \main\maintrunk.MT6620WiFiDriver_Prj\2 2009-03-10 20:16:35 GMT mtk01426
  162. ** Init for develop
  163. **
  164. */
  165. #ifndef _NIC_RX_H
  166. #define _NIC_RX_H
  167. /*******************************************************************************
  168. * C O M P I L E R F L A G S
  169. ********************************************************************************
  170. */
  171. /*******************************************************************************
  172. * E X T E R N A L R E F E R E N C E S
  173. ********************************************************************************
  174. */
  175. extern P_SW_RFB_T g_arGscnResultsTempBuffer[];
  176. extern UINT_8 g_GscanResultsTempBufferIndex;
  177. extern UINT_8 g_arGscanResultsIndicateNumber[];
  178. extern UINT_8 g_GetResultsBufferedCnt;
  179. extern UINT_8 g_GetResultsCmdCnt;
  180. extern void kalDevLoopbkRxHandle(IN P_ADAPTER_T prAdapter, IN OUT P_SW_RFB_T prSwRfb);
  181. /*******************************************************************************
  182. * C O N S T A N T S
  183. ********************************************************************************
  184. */
  185. #define MAX_SEQ_NO 4095
  186. #define MAX_SEQ_NO_COUNT 4096
  187. #define HALF_SEQ_NO_CNOUT 2048
  188. #define HALF_SEQ_NO_COUNT 2048
  189. #define MT6620_FIXED_WIN_SIZE 64
  190. #define CFG_RX_MAX_BA_ENTRY 4
  191. #define CFG_RX_MAX_BA_TID_NUM 8
  192. #define RX_STATUS_FLAG_MORE_PACKET BIT(30)
  193. #define RX_STATUS_CHKSUM_MASK BITS(0, 10)
  194. #define RX_RFB_LEN_FIELD_LEN 4
  195. #define RX_HEADER_OFFSET 2
  196. #define RX_RETURN_INDICATED_RFB_TIMEOUT_SEC 3
  197. #if defined(_HIF_SDIO) && defined(WINDOWS_DDK)
  198. /*! On XP, maximum Tx+Rx Statue <= 64-4(HISR)*/
  199. #define SDIO_MAXIMUM_RX_LEN_NUM 0 /*!< 0~15 (0: un-limited) */
  200. #else
  201. #define SDIO_MAXIMUM_RX_LEN_NUM 0 /*!< 0~15 (0: un-limited) */
  202. #endif
  203. /*******************************************************************************
  204. * D A T A T Y P E S
  205. ********************************************************************************
  206. */
  207. typedef enum _ENUM_RX_STATISTIC_COUNTER_T {
  208. RX_MPDU_TOTAL_COUNT = 0,
  209. RX_SIZE_ERR_DROP_COUNT,
  210. RX_DATA_INDICATION_COUNT,
  211. RX_DATA_RETURNED_COUNT,
  212. RX_DATA_RETAINED_COUNT,
  213. RX_DROP_TOTAL_COUNT,
  214. RX_TYPE_ERR_DROP_COUNT,
  215. RX_CLASS_ERR_DROP_COUNT,
  216. RX_DST_NULL_DROP_COUNT,
  217. #if CFG_TCP_IP_CHKSUM_OFFLOAD || CFG_TCP_IP_CHKSUM_OFFLOAD_NDIS_60
  218. RX_CSUM_TCP_FAILED_COUNT,
  219. RX_CSUM_UDP_FAILED_COUNT,
  220. RX_CSUM_IP_FAILED_COUNT,
  221. RX_CSUM_TCP_SUCCESS_COUNT,
  222. RX_CSUM_UDP_SUCCESS_COUNT,
  223. RX_CSUM_IP_SUCCESS_COUNT,
  224. RX_CSUM_UNKNOWN_L4_PKT_COUNT,
  225. RX_CSUM_UNKNOWN_L3_PKT_COUNT,
  226. RX_IP_V6_PKT_CCOUNT,
  227. #endif
  228. RX_STATISTIC_COUNTER_NUM
  229. } ENUM_RX_STATISTIC_COUNTER_T;
  230. typedef enum _ENUM_RX_PKT_DESTINATION_T {
  231. RX_PKT_DESTINATION_HOST, /* to OS */
  232. RX_PKT_DESTINATION_FORWARD, /* to TX queue for forward, AP mode */
  233. RX_PKT_DESTINATION_HOST_WITH_FORWARD, /* to both TX and OS, AP mode broadcast packet */
  234. RX_PKT_DESTINATION_NULL, /* packet to be freed */
  235. RX_PKT_DESTINATION_NUM
  236. } ENUM_RX_PKT_DESTINATION_T;
  237. struct _SW_RFB_T {
  238. QUE_ENTRY_T rQueEntry;
  239. PVOID pvPacket; /*!< ptr to rx Packet Descriptor */
  240. PUINT_8 pucRecvBuff; /*!< ptr to receive data buffer */
  241. P_HIF_RX_HEADER_T prHifRxHdr;
  242. UINT_32 u4HifRxHdrFlag;
  243. PVOID pvHeader;
  244. UINT_16 u2PacketLen;
  245. UINT_16 u2HeaderLen;
  246. UINT_16 u2SSN;
  247. UINT_8 ucTid;
  248. UINT_8 ucWlanIdx;
  249. UINT_8 ucPacketType;
  250. UINT_8 ucStaRecIdx;
  251. ENUM_CSUM_RESULT_T aeCSUM[CSUM_TYPE_NUM];
  252. ENUM_RX_PKT_DESTINATION_T eDst;
  253. ENUM_TRAFFIC_CLASS_INDEX_T eTC; /* only valid when eDst == FORWARD */
  254. UINT_64 rRxTime;
  255. };
  256. /*! RX configuration type structure */
  257. typedef struct _RX_CTRL_T {
  258. UINT_32 u4RxCachedSize;
  259. PUINT_8 pucRxCached;
  260. QUE_T rFreeSwRfbList;
  261. QUE_T rReceivedRfbList;
  262. QUE_T rIndicatedRfbList;
  263. #if CFG_SDIO_RX_AGG
  264. PUINT_8 pucRxCoalescingBufPtr;
  265. #endif
  266. PVOID apvIndPacket[CFG_RX_MAX_PKT_NUM];
  267. PVOID apvRetainedPacket[CFG_RX_MAX_PKT_NUM];
  268. UINT_8 ucNumIndPacket;
  269. UINT_8 ucNumRetainedPacket;
  270. UINT_64 au8Statistics[RX_STATISTIC_COUNTER_NUM]; /*!< RX Counters */
  271. #if CFG_HIF_STATISTICS
  272. UINT_32 u4TotalRxAccessNum;
  273. UINT_32 u4TotalRxPacketNum;
  274. #endif
  275. #if CFG_HIF_RX_STARVATION_WARNING
  276. UINT_32 u4QueuedCnt;
  277. UINT_32 u4DequeuedCnt;
  278. #endif
  279. #if CFG_RX_PKTS_DUMP
  280. UINT_32 u4RxPktsDumpTypeMask;
  281. #endif
  282. } RX_CTRL_T, *P_RX_CTRL_T;
  283. typedef struct _RX_MAILBOX_T {
  284. UINT_32 u4RxMailbox[2]; /* for Device-to-Host Mailbox */
  285. } RX_MAILBOX_T, *P_RX_MAILBOX_T;
  286. typedef WLAN_STATUS(*PROCESS_RX_MGT_FUNCTION) (P_ADAPTER_T, P_SW_RFB_T);
  287. /*******************************************************************************
  288. * P U B L I C D A T A
  289. ********************************************************************************
  290. */
  291. /*******************************************************************************
  292. * P R I V A T E D A T A
  293. ********************************************************************************
  294. */
  295. /*******************************************************************************
  296. * M A C R O S
  297. ********************************************************************************
  298. */
  299. #define RX_INC_CNT(prRxCtrl, eCounter) \
  300. {((P_RX_CTRL_T)prRxCtrl)->au8Statistics[eCounter]++; }
  301. #define RX_ADD_CNT(prRxCtrl, eCounter, u8Amount) \
  302. {((P_RX_CTRL_T)prRxCtrl)->au8Statistics[eCounter] += (UINT_64)u8Amount; }
  303. #define RX_GET_CNT(prRxCtrl, eCounter) \
  304. (((P_RX_CTRL_T)prRxCtrl)->au8Statistics[eCounter])
  305. #define RX_RESET_ALL_CNTS(prRxCtrl) \
  306. {kalMemZero(&prRxCtrl->au8Statistics[0], sizeof(prRxCtrl->au8Statistics)); }
  307. #define RX_STATUS_TEST_MORE_FLAG(flag) \
  308. ((BOOLEAN)((flag & RX_STATUS_FLAG_MORE_PACKET) ? TRUE : FALSE))
  309. /*******************************************************************************
  310. * F U N C T I O N D E C L A R A T I O N S
  311. ********************************************************************************
  312. */
  313. VOID nicRxInitialize(IN P_ADAPTER_T prAdapter);
  314. VOID nicRxUninitialize(IN P_ADAPTER_T prAdapter);
  315. VOID nicRxProcessRFBs(IN P_ADAPTER_T prAdapter);
  316. #if !CFG_SDIO_INTR_ENHANCE
  317. VOID nicRxReceiveRFBs(IN P_ADAPTER_T prAdapter);
  318. WLAN_STATUS nicRxReadBuffer(IN P_ADAPTER_T prAdapter, IN OUT P_SW_RFB_T prSwRfb);
  319. #else
  320. VOID nicRxSDIOReceiveRFBs(IN P_ADAPTER_T prAdapter);
  321. WLAN_STATUS
  322. nicRxEnhanceReadBuffer(IN P_ADAPTER_T prAdapter,
  323. IN UINT_32 u4DataPort, IN UINT_16 u2RxLength, IN OUT P_SW_RFB_T prSwRfb);
  324. #endif /* CFG_SDIO_INTR_ENHANCE */
  325. #if CFG_SDIO_RX_AGG
  326. VOID nicRxSDIOAggReceiveRFBs(IN P_ADAPTER_T prAdapter);
  327. #endif
  328. WLAN_STATUS nicRxSetupRFB(IN P_ADAPTER_T prAdapter, IN P_SW_RFB_T prRfb);
  329. VOID nicRxReturnRFB(IN P_ADAPTER_T prAdapter, IN P_SW_RFB_T prRfb);
  330. VOID nicProcessRxInterrupt(IN P_ADAPTER_T prAdapter);
  331. VOID nicRxProcessPktWithoutReorder(IN P_ADAPTER_T prAdapter, IN P_SW_RFB_T prSwRfb);
  332. VOID nicRxProcessForwardPkt(IN P_ADAPTER_T prAdapter, IN P_SW_RFB_T prSwRfb);
  333. VOID nicRxProcessGOBroadcastPkt(IN P_ADAPTER_T prAdapter, IN P_SW_RFB_T prSwRfb);
  334. VOID nicRxFillRFB(IN P_ADAPTER_T prAdapter, IN OUT P_SW_RFB_T prSwRfb);
  335. VOID nicRxProcessDataPacket(IN P_ADAPTER_T prAdapter, IN OUT P_SW_RFB_T prSwRfb);
  336. VOID nicRxProcessEventPacket(IN P_ADAPTER_T prAdapter, IN OUT P_SW_RFB_T prSwRfb);
  337. VOID nicRxProcessMgmtPacket(IN P_ADAPTER_T prAdapter, IN OUT P_SW_RFB_T prSwRfb);
  338. #if CFG_TCP_IP_CHKSUM_OFFLOAD
  339. VOID nicRxFillChksumStatus(IN P_ADAPTER_T prAdapter, IN OUT P_SW_RFB_T prSwRfb, IN UINT_32 u4TcpUdpIpCksStatus);
  340. VOID nicRxUpdateCSUMStatistics(IN P_ADAPTER_T prAdapter, IN const ENUM_CSUM_RESULT_T aeCSUM[]);
  341. #endif /* CFG_TCP_IP_CHKSUM_OFFLOAD */
  342. VOID nicRxQueryStatus(IN P_ADAPTER_T prAdapter, IN PUINT_8 pucBuffer, OUT PUINT_32 pu4Count);
  343. VOID nicRxClearStatistics(IN P_ADAPTER_T prAdapter);
  344. VOID nicRxQueryStatistics(IN P_ADAPTER_T prAdapter, IN PUINT_8 pucBuffer, OUT PUINT_32 pu4Count);
  345. WLAN_STATUS
  346. nicRxWaitResponse(IN P_ADAPTER_T prAdapter,
  347. IN UINT_8 ucPortIdx, OUT PUINT_8 pucRspBuffer, IN UINT_32 u4MaxRespBufferLen, OUT PUINT_32 pu4Length);
  348. VOID nicRxEnablePromiscuousMode(IN P_ADAPTER_T prAdapter);
  349. VOID nicRxDisablePromiscuousMode(IN P_ADAPTER_T prAdapter);
  350. WLAN_STATUS nicRxFlush(IN P_ADAPTER_T prAdapter);
  351. WLAN_STATUS nicRxProcessActionFrame(IN P_ADAPTER_T prAdapter, IN P_SW_RFB_T prSwRfb);
  352. #endif /* _NIC_RX_H */