import PULS_20160108
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / drivers / misc / mediatek / connectivity / combo / drv_wlan / mt6628 / wlan / include / nic / nic_rx.h
1 /*
2 ** $Id: //Department/DaVinci/BRANCHES/MT6620_WIFI_DRIVER_V2_3/include/nic/nic_rx.h#1 $
3 */
4
5 /*! \file "nic_rx.h"
6 \brief The declaration of the nic rx functions
7
8 */
9
10
11
12 /*
13 ** $Log: nic_rx.h $
14 *
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.
18 *
19 * 05 05 2011 cp.wu
20 * [WCXRP00000702] [MT5931][Driver] Modify initialization sequence for E1 ASIC
21 * add delay after whole-chip resetting for MT5931 E1 ASIC.
22 *
23 * 04 18 2011 terry.wu
24 * [WCXRP00000660] [MT6620 Wi-Fi][Driver] Remove flag CFG_WIFI_DIRECT_MOVED
25 * Remove flag CFG_WIFI_DIRECT_MOVED.
26 *
27 * 01 24 2011 cm.chang
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
30 *
31 * 09 08 2010 cp.wu
32 * NULL
33 * use static memory pool for storing IEs of scanning result.
34 *
35 * 09 07 2010 yuche.tsai
36 * NULL
37 * Change prototype of API of adding P2P device to scan result.
38 * Additional IE buffer is saved.
39 *
40 * 09 03 2010 kevin.huang
41 * NULL
42 * Refine #include sequence and solve recursive/nested #include issue
43 *
44 * 08 05 2010 yuche.tsai
45 * NULL
46 * Modify data structure for P2P Scan result.
47 *
48 * 08 03 2010 cp.wu
49 * NULL
50 * newly added P2P API should be declared in header file.
51 *
52 * 07 30 2010 cp.wu
53 * NULL
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
57 *
58 * 07 08 2010 cp.wu
59 *
60 * [WPD00003833] [MT6620 and MT5931] Driver migration - move to new repository.
61 *
62 * 06 14 2010 cp.wu
63 * [WPD00003833][MT6620 and MT5931] Driver migration
64 * saa_fsm.c is migrated.
65 *
66 * 06 14 2010 cp.wu
67 * [WPD00003833][MT6620 and MT5931] Driver migration
68 * add management dispatching function table.
69 *
70 * 06 11 2010 cp.wu
71 * [WPD00003833][MT6620 and MT5931] Driver migration
72 * 1) migrate assoc.c.
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
77 *
78 * 06 06 2010 kevin.huang
79 * [WPD00003832][MT6620 5931] Create driver base
80 * [MT6620 5931] Create driver base
81 *
82 * 03 30 2010 cp.wu
83 * [WPD00001943]Create WiFi test driver framework on WinXP
84 * remove driver-land statistics.
85 *
86 * 03 24 2010 cp.wu
87 * [WPD00001943]Create WiFi test driver framework on WinXP
88 * generate information for OID_GEN_RCV_OK & OID_GEN_XMIT_OK
89 * *
90 *
91 * 03 11 2010 cp.wu
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
94 *
95 * 03 10 2010 cp.wu
96 * [WPD00001943]Create WiFi test driver framework on WinXP
97 * code clean: removing unused variables and structure definitions
98 *
99 * 02 25 2010 cp.wu
100 * [WPD00001943]Create WiFi test driver framework on WinXP
101 * correct behavior to prevent duplicated RX handling for RX0_DONE and RX1_DONE
102 *
103 * 02 10 2010 cp.wu
104 * [WPD00001943]Create WiFi test driver framework on WinXP
105 * implement host-side firmware download logic
106 *
107 * 02 10 2010 cp.wu
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
115 *
116 * 12 30 2009 cp.wu
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
123 ** code clean
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
165 ** Init for develop
166 **
167 */
168
169 #ifndef _NIC_RX_H
170 #define _NIC_RX_H
171
172 /*******************************************************************************
173 * C O M P I L E R F L A G S
174 ********************************************************************************
175 */
176
177 /*******************************************************************************
178 * E X T E R N A L R E F E R E N C E S
179 ********************************************************************************
180 */
181
182 /*******************************************************************************
183 * C O N S T A N T S
184 ********************************************************************************
185 */
186 #define MAX_SEQ_NO 4095
187 #define MAX_SEQ_NO_COUNT 4096
188 #define HALF_SEQ_NO_CNOUT 2048
189
190 #define HALF_SEQ_NO_COUNT 2048
191
192 #define MT6620_FIXED_WIN_SIZE 64
193 #define CFG_RX_MAX_BA_ENTRY 4
194 #define CFG_RX_MAX_BA_TID_NUM 8
195
196 #define RX_STATUS_FLAG_MORE_PACKET BIT(30)
197 #define RX_STATUS_CHKSUM_MASK BITS(0, 10)
198
199 #define RX_RFB_LEN_FIELD_LEN 4
200 #define RX_HEADER_OFFSET 2
201
202
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) */
206 #else
207 #define SDIO_MAXIMUM_RX_LEN_NUM 0 /*!< 0~15 (0: un-limited) */
208 #endif
209
210 /*******************************************************************************
211 * D A T A T Y P E S
212 ********************************************************************************
213 */
214 typedef enum _ENUM_RX_STATISTIC_COUNTER_T {
215 RX_MPDU_TOTAL_COUNT = 0,
216 RX_SIZE_ERR_DROP_COUNT,
217
218 RX_DATA_INDICATION_COUNT,
219 RX_DATA_RETURNED_COUNT,
220 RX_DATA_RETAINED_COUNT,
221
222 RX_DROP_TOTAL_COUNT,
223 RX_TYPE_ERR_DROP_COUNT,
224 RX_CLASS_ERR_DROP_COUNT,
225 RX_DST_NULL_DROP_COUNT,
226
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,
236 RX_IP_V6_PKT_CCOUNT,
237 #endif
238 RX_STATISTIC_COUNTER_NUM
239 } ENUM_RX_STATISTIC_COUNTER_T;
240
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;
248
249 struct _SW_RFB_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;
255 PVOID pvHeader;
256 UINT_16 u2PacketLen;
257 UINT_16 u2HeaderLen;
258 UINT_16 u2SSN;
259 UINT_8 ucTid;
260 UINT_8 ucWlanIdx;
261 UINT_8 ucPacketType;
262 UINT_8 ucStaRecIdx;
263
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 */
267 };
268
269 /*! RX configuration type structure */
270 typedef struct _RX_CTRL_T {
271 UINT_32 u4RxCachedSize;
272 PUINT_8 pucRxCached;
273 QUE_T rFreeSwRfbList;
274 QUE_T rReceivedRfbList;
275 QUE_T rIndicatedRfbList;
276
277 #if CFG_SDIO_RX_AGG
278 PUINT_8 pucRxCoalescingBufPtr;
279 #endif
280
281 PVOID apvIndPacket[CFG_RX_MAX_PKT_NUM];
282 PVOID apvRetainedPacket[CFG_RX_MAX_PKT_NUM];
283
284 UINT_8 ucNumIndPacket;
285 UINT_8 ucNumRetainedPacket;
286 UINT_64 au8Statistics[RX_STATISTIC_COUNTER_NUM]; /*!< RX Counters */
287
288 #if CFG_HIF_STATISTICS
289 UINT_32 u4TotalRxAccessNum;
290 UINT_32 u4TotalRxPacketNum;
291 #endif
292
293 #if CFG_HIF_RX_STARVATION_WARNING
294 UINT_32 u4QueuedCnt;
295 UINT_32 u4DequeuedCnt;
296 #endif
297
298 #if CFG_RX_PKTS_DUMP
299 UINT_32 u4RxPktsDumpTypeMask;
300 #endif
301
302 } RX_CTRL_T, *P_RX_CTRL_T;
303
304 typedef struct _RX_MAILBOX_T {
305 UINT_32 u4RxMailbox[2]; /* for Device-to-Host Mailbox */
306 } RX_MAILBOX_T, *P_RX_MAILBOX_T;
307
308 typedef WLAN_STATUS(*PROCESS_RX_MGT_FUNCTION) (P_ADAPTER_T, P_SW_RFB_T);
309
310 /*******************************************************************************
311 * P U B L I C D A T A
312 ********************************************************************************
313 */
314
315 /*******************************************************************************
316 * P R I V A T E D A T A
317 ********************************************************************************
318 */
319
320 /*******************************************************************************
321 * M A C R O S
322 ********************************************************************************
323 */
324 #define RX_INC_CNT(prRxCtrl, eCounter) \
325 {((P_RX_CTRL_T)prRxCtrl)->au8Statistics[eCounter]++; }
326
327 #define RX_ADD_CNT(prRxCtrl, eCounter, u8Amount) \
328 {((P_RX_CTRL_T)prRxCtrl)->au8Statistics[eCounter] += (UINT_64)u8Amount; }
329
330 #define RX_GET_CNT(prRxCtrl, eCounter) \
331 (((P_RX_CTRL_T)prRxCtrl)->au8Statistics[eCounter])
332
333 #define RX_RESET_ALL_CNTS(prRxCtrl) \
334 {kalMemZero(&prRxCtrl->au8Statistics[0], sizeof(prRxCtrl->au8Statistics)); }
335
336 #define RX_STATUS_TEST_MORE_FLAG(flag) \
337 ((BOOL)((flag & RX_STATUS_FLAG_MORE_PACKET) ? TRUE : FALSE))
338
339 /*******************************************************************************
340 * F U N C T I O N D E C L A R A T I O N S
341 ********************************************************************************
342 */
343
344 VOID nicRxInitialize(IN P_ADAPTER_T prAdapter);
345
346 #if defined(MT5931)
347 VOID nicRxPostInitialize(IN P_ADAPTER_T prAdapter);
348 #endif
349
350 VOID nicRxUninitialize(IN P_ADAPTER_T prAdapter);
351
352 VOID nicRxProcessRFBs(IN P_ADAPTER_T prAdapter);
353
354 #if !CFG_SDIO_INTR_ENHANCE
355 VOID nicRxReceiveRFBs(IN P_ADAPTER_T prAdapter);
356
357 WLAN_STATUS nicRxReadBuffer(IN P_ADAPTER_T prAdapter, IN OUT P_SW_RFB_T prSwRfb);
358
359 #else
360 VOID nicRxSDIOReceiveRFBs(IN P_ADAPTER_T prAdapter);
361
362 WLAN_STATUS
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 */
366
367
368 #if CFG_SDIO_RX_AGG
369 VOID nicRxSDIOAggReceiveRFBs(IN P_ADAPTER_T prAdapter);
370 #endif
371
372 WLAN_STATUS nicRxSetupRFB(IN P_ADAPTER_T prAdapter, IN P_SW_RFB_T prRfb);
373
374 VOID nicRxReturnRFB(IN P_ADAPTER_T prAdapter, IN P_SW_RFB_T prRfb);
375
376 VOID nicProcessRxInterrupt(IN P_ADAPTER_T prAdapter);
377
378 VOID nicRxProcessPktWithoutReorder(IN P_ADAPTER_T prAdapter, IN P_SW_RFB_T prSwRfb);
379
380 VOID nicRxProcessForwardPkt(IN P_ADAPTER_T prAdapter, IN P_SW_RFB_T prSwRfb);
381
382 VOID nicRxProcessGOBroadcastPkt(IN P_ADAPTER_T prAdapter, IN P_SW_RFB_T prSwRfb);
383
384
385 VOID nicRxFillRFB(IN P_ADAPTER_T prAdapter, IN OUT P_SW_RFB_T prSwRfb);
386
387 VOID nicRxProcessDataPacket(IN P_ADAPTER_T prAdapter, IN OUT P_SW_RFB_T prSwRfb);
388
389 VOID nicRxProcessEventPacket(IN P_ADAPTER_T prAdapter, IN OUT P_SW_RFB_T prSwRfb);
390
391 VOID nicRxProcessMgmtPacket(IN P_ADAPTER_T prAdapter, IN OUT P_SW_RFB_T prSwRfb);
392
393 #if CFG_TCP_IP_CHKSUM_OFFLOAD
394 VOID
395 nicRxFillChksumStatus(IN P_ADAPTER_T prAdapter,
396 IN OUT P_SW_RFB_T prSwRfb, IN UINT_32 u4TcpUdpIpCksStatus);
397
398 VOID nicRxUpdateCSUMStatistics(IN P_ADAPTER_T prAdapter, IN const ENUM_CSUM_RESULT_T aeCSUM[]
399 );
400 #endif /* CFG_TCP_IP_CHKSUM_OFFLOAD */
401
402
403 VOID nicRxQueryStatus(IN P_ADAPTER_T prAdapter, IN PUINT_8 pucBuffer, OUT PUINT_32 pu4Count);
404
405 VOID nicRxClearStatistics(IN P_ADAPTER_T prAdapter);
406
407 VOID nicRxQueryStatistics(IN P_ADAPTER_T prAdapter, IN PUINT_8 pucBuffer, OUT PUINT_32 pu4Count);
408
409 WLAN_STATUS
410 nicRxWaitResponse(IN P_ADAPTER_T prAdapter,
411 IN UINT_8 ucPortIdx,
412 OUT PUINT_8 pucRspBuffer, IN UINT_32 u4MaxRespBufferLen, OUT PUINT_32 pu4Length);
413
414 VOID nicRxEnablePromiscuousMode(IN P_ADAPTER_T prAdapter);
415
416
417 VOID nicRxDisablePromiscuousMode(IN P_ADAPTER_T prAdapter);
418
419
420 WLAN_STATUS nicRxFlush(IN P_ADAPTER_T prAdapter);
421
422 WLAN_STATUS nicRxProcessActionFrame(IN P_ADAPTER_T prAdapter, IN P_SW_RFB_T prSwRfb);
423
424 #endif /* _NIC_RX_H */