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