import PULS_20160108
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / drivers / misc / mediatek / connectivity / conn_soc / drv_wlan / mt_wifi / wlan / include / nic / nic_rx.h
CommitLineData
6fa3eb70
S
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#define RX_RETURN_INDICATED_RFB_TIMEOUT_SEC 3
203
204#if defined(_HIF_SDIO) && defined (WINDOWS_DDK)
205/*! On XP, maximum Tx+Rx Statue <= 64-4(HISR)*/
206 #define SDIO_MAXIMUM_RX_LEN_NUM 0 /*!< 0~15 (0: un-limited) */
207#else
208 #define SDIO_MAXIMUM_RX_LEN_NUM 0 /*!< 0~15 (0: un-limited) */
209#endif
210
211/*******************************************************************************
212* D A T A T Y P E S
213********************************************************************************
214*/
215typedef enum _ENUM_RX_STATISTIC_COUNTER_T {
216 RX_MPDU_TOTAL_COUNT = 0,
217 RX_SIZE_ERR_DROP_COUNT,
218
219 RX_DATA_INDICATION_COUNT,
220 RX_DATA_RETURNED_COUNT,
221 RX_DATA_RETAINED_COUNT,
222
223 RX_DROP_TOTAL_COUNT,
224 RX_TYPE_ERR_DROP_COUNT,
225 RX_CLASS_ERR_DROP_COUNT,
226 RX_DST_NULL_DROP_COUNT,
227
228#if CFG_TCP_IP_CHKSUM_OFFLOAD || CFG_TCP_IP_CHKSUM_OFFLOAD_NDIS_60
229 RX_CSUM_TCP_FAILED_COUNT,
230 RX_CSUM_UDP_FAILED_COUNT,
231 RX_CSUM_IP_FAILED_COUNT,
232 RX_CSUM_TCP_SUCCESS_COUNT,
233 RX_CSUM_UDP_SUCCESS_COUNT,
234 RX_CSUM_IP_SUCCESS_COUNT,
235 RX_CSUM_UNKNOWN_L4_PKT_COUNT,
236 RX_CSUM_UNKNOWN_L3_PKT_COUNT,
237 RX_IP_V6_PKT_CCOUNT,
238#endif
239 RX_STATISTIC_COUNTER_NUM
240} ENUM_RX_STATISTIC_COUNTER_T;
241
242typedef enum _ENUM_RX_PKT_DESTINATION_T {
243 RX_PKT_DESTINATION_HOST, /* to OS */
244 RX_PKT_DESTINATION_FORWARD, /* to TX queue for forward, AP mode */
245 RX_PKT_DESTINATION_HOST_WITH_FORWARD, /* to both TX and OS, AP mode broadcast packet */
246 RX_PKT_DESTINATION_NULL, /* packet to be freed */
247 RX_PKT_DESTINATION_NUM
248} ENUM_RX_PKT_DESTINATION_T;
249
250struct _SW_RFB_T {
251 QUE_ENTRY_T rQueEntry;
252 PVOID pvPacket; /*!< ptr to rx Packet Descriptor */
253 PUINT_8 pucRecvBuff; /*!< ptr to receive data buffer */
254 P_HIF_RX_HEADER_T prHifRxHdr;
255 UINT_32 u4HifRxHdrFlag;
256 PVOID pvHeader;
257 UINT_16 u2PacketLen;
258 UINT_16 u2HeaderLen;
259 UINT_16 u2SSN;
260 UINT_8 ucTid;
261 UINT_8 ucWlanIdx;
262 UINT_8 ucPacketType;
263 UINT_8 ucStaRecIdx;
264
265 ENUM_CSUM_RESULT_T aeCSUM[CSUM_TYPE_NUM];
266 ENUM_RX_PKT_DESTINATION_T eDst;
267 ENUM_TRAFFIC_CLASS_INDEX_T eTC; /* only valid when eDst == FORWARD */
268
269 UINT_64 rRxTime;
270};
271
272/*! RX configuration type structure */
273typedef struct _RX_CTRL_T {
274 UINT_32 u4RxCachedSize;
275 PUINT_8 pucRxCached;
276 QUE_T rFreeSwRfbList;
277 QUE_T rReceivedRfbList;
278 QUE_T rIndicatedRfbList;
279
280#if CFG_SDIO_RX_AGG
281 PUINT_8 pucRxCoalescingBufPtr;
282#endif
283
284 PVOID apvIndPacket[CFG_RX_MAX_PKT_NUM];
285 PVOID apvRetainedPacket[CFG_RX_MAX_PKT_NUM];
286
287 UINT_8 ucNumIndPacket;
288 UINT_8 ucNumRetainedPacket;
289 UINT_64 au8Statistics[RX_STATISTIC_COUNTER_NUM]; /*!< RX Counters */
290
291#if CFG_HIF_STATISTICS
292 UINT_32 u4TotalRxAccessNum;
293 UINT_32 u4TotalRxPacketNum;
294#endif
295
296#if CFG_HIF_RX_STARVATION_WARNING
297 UINT_32 u4QueuedCnt;
298 UINT_32 u4DequeuedCnt;
299#endif
300
301#if CFG_RX_PKTS_DUMP
302 UINT_32 u4RxPktsDumpTypeMask;
303#endif
304
305} RX_CTRL_T, *P_RX_CTRL_T;
306
307typedef struct _RX_MAILBOX_T {
308 UINT_32 u4RxMailbox[2]; /* for Device-to-Host Mailbox */
309} RX_MAILBOX_T, *P_RX_MAILBOX_T;
310
311typedef WLAN_STATUS (*PROCESS_RX_MGT_FUNCTION)(P_ADAPTER_T, P_SW_RFB_T);
312
313/*******************************************************************************
314* P U B L I C D A T A
315********************************************************************************
316*/
317
318/*******************************************************************************
319* P R I V A T E D A T A
320********************************************************************************
321*/
322
323/*******************************************************************************
324* M A C R O S
325********************************************************************************
326*/
327#define RX_INC_CNT(prRxCtrl, eCounter) \
328 {((P_RX_CTRL_T)prRxCtrl)->au8Statistics[eCounter]++;}
329
330#define RX_ADD_CNT(prRxCtrl, eCounter, u8Amount) \
331 {((P_RX_CTRL_T)prRxCtrl)->au8Statistics[eCounter] += (UINT_64)u8Amount;}
332
333#define RX_GET_CNT(prRxCtrl, eCounter) \
334 (((P_RX_CTRL_T)prRxCtrl)->au8Statistics[eCounter])
335
336#define RX_RESET_ALL_CNTS(prRxCtrl) \
337 {kalMemZero(&prRxCtrl->au8Statistics[0], sizeof(prRxCtrl->au8Statistics));}
338
339#define RX_STATUS_TEST_MORE_FLAG(flag) \
340 ((BOOLEAN)((flag & RX_STATUS_FLAG_MORE_PACKET) ? TRUE : FALSE))
341
342/*******************************************************************************
343* F U N C T I O N D E C L A R A T I O N S
344********************************************************************************
345*/
346
347VOID
348nicRxInitialize (
349 IN P_ADAPTER_T prAdapter
350 );
351
352#if defined(MT5931)
353VOID
354nicRxPostInitialize (
355 IN P_ADAPTER_T prAdapter
356 );
357#endif
358
359VOID
360nicRxUninitialize (
361 IN P_ADAPTER_T prAdapter
362 );
363
364VOID
365nicRxProcessRFBs (
366 IN P_ADAPTER_T prAdapter
367 );
368
369#if !CFG_SDIO_INTR_ENHANCE
370VOID
371nicRxReceiveRFBs (
372 IN P_ADAPTER_T prAdapter
373 );
374
375WLAN_STATUS
376nicRxReadBuffer (
377 IN P_ADAPTER_T prAdapter,
378 IN OUT P_SW_RFB_T prSwRfb
379 );
380
381#else
382VOID
383nicRxSDIOReceiveRFBs (
384 IN P_ADAPTER_T prAdapter
385 );
386
387WLAN_STATUS
388nicRxEnhanceReadBuffer (
389 IN P_ADAPTER_T prAdapter,
390 IN UINT_32 u4DataPort,
391 IN UINT_16 u2RxLength,
392 IN OUT P_SW_RFB_T prSwRfb
393 );
394#endif /* CFG_SDIO_INTR_ENHANCE */
395
396
397#if CFG_SDIO_RX_AGG
398VOID
399nicRxSDIOAggReceiveRFBs (
400 IN P_ADAPTER_T prAdapter
401 );
402#endif
403
404WLAN_STATUS
405nicRxSetupRFB (
406 IN P_ADAPTER_T prAdapter,
407 IN P_SW_RFB_T prRfb
408 );
409
410VOID
411nicRxReturnRFB (
412 IN P_ADAPTER_T prAdapter,
413 IN P_SW_RFB_T prRfb
414 );
415
416VOID
417nicProcessRxInterrupt (
418 IN P_ADAPTER_T prAdapter
419 );
420
421VOID
422nicRxProcessPktWithoutReorder (
423 IN P_ADAPTER_T prAdapter,
424 IN P_SW_RFB_T prSwRfb
425 );
426
427VOID
428nicRxProcessForwardPkt (
429 IN P_ADAPTER_T prAdapter,
430 IN P_SW_RFB_T prSwRfb
431 );
432
433VOID
434nicRxProcessGOBroadcastPkt (
435 IN P_ADAPTER_T prAdapter,
436 IN P_SW_RFB_T prSwRfb
437 );
438
439
440VOID
441nicRxFillRFB (
442 IN P_ADAPTER_T prAdapter,
443 IN OUT P_SW_RFB_T prSwRfb
444 );
445
446VOID
447nicRxProcessDataPacket (
448 IN P_ADAPTER_T prAdapter,
449 IN OUT P_SW_RFB_T prSwRfb
450 );
451
452VOID
453nicRxProcessEventPacket (
454 IN P_ADAPTER_T prAdapter,
455 IN OUT P_SW_RFB_T prSwRfb
456 );
457
458VOID
459nicRxProcessMgmtPacket (
460 IN P_ADAPTER_T prAdapter,
461 IN OUT P_SW_RFB_T prSwRfb
462 );
463
464#if CFG_TCP_IP_CHKSUM_OFFLOAD
465VOID
466nicRxFillChksumStatus(
467 IN P_ADAPTER_T prAdapter,
468 IN OUT P_SW_RFB_T prSwRfb,
469 IN UINT_32 u4TcpUdpIpCksStatus
470 );
471
472VOID
473nicRxUpdateCSUMStatistics (
474 IN P_ADAPTER_T prAdapter,
475 IN const ENUM_CSUM_RESULT_T aeCSUM[]
476 );
477#endif /* CFG_TCP_IP_CHKSUM_OFFLOAD */
478
479
480VOID
481nicRxQueryStatus (
482 IN P_ADAPTER_T prAdapter,
483 IN PUINT_8 pucBuffer,
484 OUT PUINT_32 pu4Count
485 );
486
487VOID
488nicRxClearStatistics (
489 IN P_ADAPTER_T prAdapter
490 );
491
492VOID
493nicRxQueryStatistics (
494 IN P_ADAPTER_T prAdapter,
495 IN PUINT_8 pucBuffer,
496 OUT PUINT_32 pu4Count
497 );
498
499WLAN_STATUS
500nicRxWaitResponse (
501 IN P_ADAPTER_T prAdapter,
502 IN UINT_8 ucPortIdx,
503 OUT PUINT_8 pucRspBuffer,
504 IN UINT_32 u4MaxRespBufferLen,
505 OUT PUINT_32 pu4Length
506 );
507
508VOID
509nicRxEnablePromiscuousMode (
510 IN P_ADAPTER_T prAdapter
511 );
512
513
514VOID
515nicRxDisablePromiscuousMode (
516 IN P_ADAPTER_T prAdapter
517 );
518
519
520WLAN_STATUS
521nicRxFlush (
522 IN P_ADAPTER_T prAdapter
523 );
524
525WLAN_STATUS
526nicRxProcessActionFrame (
527 IN P_ADAPTER_T prAdapter,
528 IN P_SW_RFB_T prSwRfb
529 );
530
531#endif /* _NIC_RX_H */
532