Browse Source

Version 1.6.0_20180227-1100 released

Jenkins 7 years ago
parent
commit
5d97c2e871
36 changed files with 959 additions and 3496 deletions
  1. 7 7
      crypto/algif_skcipher.c
  2. 14 955
      drivers/misc/mediatek/connectivity/wlan/gen2/common/wlan_lib.c
  3. 9 3
      drivers/misc/mediatek/connectivity/wlan/gen2/include/CFG_Wifi_File.h
  4. 1 1
      drivers/misc/mediatek/connectivity/wlan/gen2/include/config.h
  5. 13 165
      drivers/misc/mediatek/connectivity/wlan/gen2/include/nic/nic_rx.h
  6. 25 2
      drivers/misc/mediatek/connectivity/wlan/gen2/include/nic/que_mgt.h
  7. 18 636
      drivers/misc/mediatek/connectivity/wlan/gen2/include/nic_cmd_event.h
  8. 1 1
      drivers/misc/mediatek/connectivity/wlan/gen2/include/p2p_precomp.h
  9. 2 1
      drivers/misc/mediatek/connectivity/wlan/gen2/include/precomp.h
  10. 2 3
      drivers/misc/mediatek/connectivity/wlan/gen2/include/typedef.h
  11. 39 2
      drivers/misc/mediatek/connectivity/wlan/gen2/mgmt/ais_fsm.c
  12. 72 803
      drivers/misc/mediatek/connectivity/wlan/gen2/nic/nic_rx.c
  13. 203 6
      drivers/misc/mediatek/connectivity/wlan/gen2/nic/que_mgt.c
  14. 11 6
      drivers/misc/mediatek/connectivity/wlan/gen2/os/linux/gl_cfg80211.c
  15. 26 24
      drivers/misc/mediatek/connectivity/wlan/gen2/os/linux/gl_init.c
  16. 155 703
      drivers/misc/mediatek/connectivity/wlan/gen2/os/linux/gl_kal.c
  17. 1 2
      drivers/misc/mediatek/connectivity/wlan/gen2/os/linux/include/gl_cfg80211.h
  18. 13 3
      drivers/misc/mediatek/connectivity/wlan/gen2/os/linux/include/gl_kal.h
  19. 13 0
      drivers/misc/mediatek/connectivity/wlan/gen2/os/linux/platform.c
  20. 7 1
      drivers/misc/mediatek/video/common/mtkfb.c
  21. 1 2
      drivers/misc/mediatek/video/mt6735/dispsys/ddp_irq.c
  22. 32 4
      drivers/misc/mediatek/video/mt6735/videox/mtk_disp_mgr.c
  23. 102 17
      drivers/misc/mediatek/video/mt6735/videox/primary_display.c
  24. 4 2
      drivers/misc/mediatek/video/mt6735/videox/primary_display.h
  25. 2 0
      drivers/staging/android/ashmem.c
  26. 8 0
      drivers/staging/android/binder.c
  27. 1 1
      drivers/staging/android/ion/ion.c
  28. 10 0
      drivers/usb/gadget/f_mtp.c
  29. 29 0
      fs/dcache.c
  30. 5 5
      fs/debugfs/inode.c
  31. 4 4
      fs/namei.c
  32. 6 2
      fs/notify/fsnotify.c
  33. 8 0
      include/linux/dcache.h
  34. 0 31
      include/linux/fsnotify.h
  35. 3 8
      mm/migrate.c
  36. 112 96
      sound/core/timer.c

+ 7 - 7
crypto/algif_skcipher.c

@@ -441,13 +441,6 @@ static int skcipher_recvmsg(struct kiocb *unused, struct socket *sock,
 		char __user *from = iov->iov_base;
 
 		while (seglen) {
-			sgl = list_first_entry(&ctx->tsgl,
-					       struct skcipher_sg_list, list);
-			sg = sgl->sg;
-
-			while (!sg->length)
-				sg++;
-
 			used = ctx->used;
 			if (!used) {
 				err = skcipher_wait_for_data(sk, flags);
@@ -469,6 +462,13 @@ static int skcipher_recvmsg(struct kiocb *unused, struct socket *sock,
 			if (!used)
 				goto free;
 
+			sgl = list_first_entry(&ctx->tsgl,
+					       struct skcipher_sg_list, list);
+			sg = sgl->sg;
+
+			while (!sg->length)
+				sg++;
+
 			ablkcipher_request_set_crypt(&ctx->req, sg,
 						     ctx->rsgl.sg, used,
 						     ctx->iv);

File diff suppressed because it is too large
+ 14 - 955
drivers/misc/mediatek/connectivity/wlan/gen2/common/wlan_lib.c


+ 9 - 3
drivers/misc/mediatek/connectivity/wlan/gen2/include/CFG_Wifi_File.h

@@ -174,7 +174,12 @@ typedef struct _MT6620_CFG_PARAM_STRUCT {
 	UINT_8 ucRegChannelListIndex;
 	UINT_8 aucRegSubbandInfo[36];
 
-	UINT_8 aucReserved2[256 - 240];
+	UINT_8 aucReserved2[256 - 246];
+	UINT_16 u2SizeOfNvram;
+	INT_8 bTxPowerLimitEnable2G;
+	INT_8 cTxBackOffMaxPower2G;
+	INT_8 bTxPowerLimitEnable5G;
+	INT_8 cTxBackOffMaxPower5G;
 
 	/* 256 bytes of function data */
 	UINT_16 u2Part2OwnVersion;
@@ -187,7 +192,7 @@ typedef struct _MT6620_CFG_PARAM_STRUCT {
 	UINT_8 uc5GRssiCompensation;
 	UINT_8 fgRssiCompensationValidbit;
 	UINT_8 ucRxAntennanumber;
-	UINT_8 aucTailReserved[256 - 12];
+	UINT_8 aucTailReserved[768 - 12];
 } MT6620_CFG_PARAM_STRUCT, *P_MT6620_CFG_PARAM_STRUCT, WIFI_CFG_PARAM_STRUCT, *P_WIFI_CFG_PARAM_STRUCT;
 
 /*******************************************************************************
@@ -207,6 +212,7 @@ typedef struct _MT6620_CFG_PARAM_STRUCT {
 #endif
 
 #define CFG_FILE_WIFI_REC_SIZE    sizeof(WIFI_CFG_PARAM_STRUCT)
+#define EXTEND_NVRAM_SIZE 1024
 
 /*******************************************************************************
 *                  F U N C T I O N   D E C L A R A T I O N S
@@ -227,7 +233,7 @@ static inline VOID nvramOffsetCheck(VOID)
 {
 	DATA_STRUCT_INSPECTING_ASSERT(OFFSET_OF(WIFI_CFG_PARAM_STRUCT, u2Part2OwnVersion) == 256);
 
-	DATA_STRUCT_INSPECTING_ASSERT(sizeof(WIFI_CFG_PARAM_STRUCT) == 512);
+	DATA_STRUCT_INSPECTING_ASSERT(sizeof(WIFI_CFG_PARAM_STRUCT) == EXTEND_NVRAM_SIZE);
 
 	DATA_STRUCT_INSPECTING_ASSERT((OFFSET_OF(WIFI_CFG_PARAM_STRUCT, aucEFUSE) & 0x0001) == 0);
 

+ 1 - 1
drivers/misc/mediatek/connectivity/wlan/gen2/include/config.h

@@ -968,7 +968,7 @@
 
 #define CFG_SUPPORT_PERSIST_NETDEV		0	/* create NETDEV when system bootup */
 
-#define CFG_FORCE_USE_20BW			1
+#define CFG_FORCE_USE_20BW			0
 /*------------------------------------------------------------------------------
  * SLT Option
  *------------------------------------------------------------------------------

+ 13 - 165
drivers/misc/mediatek/connectivity/wlan/gen2/include/nic/nic_rx.h

@@ -1,170 +1,14 @@
 /*
-** Id: //Department/DaVinci/BRANCHES/MT6620_WIFI_DRIVER_V2_3/include/nic/nic_rx.h#1
+* This program is free software; you can redistribute it and/or modify
+* it under the terms of the GNU General Public License version 2 as
+* published by the Free Software Foundation.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+* See http://www.gnu.org/licenses/gpl-2.0.html for more details.
 */
 
-/*! \file   "nic_rx.h"
-    \brief  The declaration of the nic rx functions
-
-*/
-
-/*
-** Log: nic_rx.h
- *
- * 11 07 2011 tsaiyuan.hsu
- * [WCXRP00001083] [MT6620 Wi-Fi][DRV]] dump debug counter or frames when debugging is triggered
- * add debug counters and periodically dump counters for debugging.
- *
- * 05 05 2011 cp.wu
- * [WCXRP00000702] [MT5931][Driver] Modify initialization sequence for E1 ASIC
- * add delay after whole-chip resetting for MT5931 E1 ASIC.
- *
- * 04 18 2011 terry.wu
- * [WCXRP00000660] [MT6620 Wi-Fi][Driver] Remove flag CFG_WIFI_DIRECT_MOVED
- * Remove flag CFG_WIFI_DIRECT_MOVED.
- *
- * 01 24 2011 cm.chang
- * [WCXRP00000384] [MT6620 Wi-Fi][Driver][FW] Handle 20/40 action frame in AP mode
- * and stop ampdu timer when sta_rec is freed
- * Process received 20/40 coexistence action frame for AP mode
- *
- * 09 08 2010 cp.wu
- * NULL
- * use static memory pool for storing IEs of scanning result.
- *
- * 09 07 2010 yuche.tsai
- * NULL
- * Change prototype of API of adding P2P device to scan result.
- * Additional IE buffer is saved.
- *
- * 09 03 2010 kevin.huang
- * NULL
- * Refine #include sequence and solve recursive/nested #include issue
- *
- * 08 05 2010 yuche.tsai
- * NULL
- * Modify data structure for P2P Scan result.
- *
- * 08 03 2010 cp.wu
- * NULL
- * newly added P2P API should be declared in header file.
- *
- * 07 30 2010 cp.wu
- * NULL
- * 1) BoW wrapper: use definitions instead of hard-coded constant for error code
- * 2) AIS-FSM: eliminate use of desired RF parameters, use prTargetBssDesc instead
- * 3) add handling for RX_PKT_DESTINATION_HOST_WITH_FORWARD for GO-broadcast frames
- *
- * 07 08 2010 cp.wu
- *
- * [WPD00003833] [MT6620 and MT5931] Driver migration - move to new repository.
- *
- * 06 14 2010 cp.wu
- * [WPD00003833][MT6620 and MT5931] Driver migration
- * saa_fsm.c is migrated.
- *
- * 06 14 2010 cp.wu
- * [WPD00003833][MT6620 and MT5931] Driver migration
- * add management dispatching function table.
- *
- * 06 11 2010 cp.wu
- * [WPD00003833][MT6620 and MT5931] Driver migration
- * 1) migrate assoc.c.
- * 2) add ucTxSeqNum for tracking frames which needs TX-DONE awareness
- * 3) add configuration options for CNM_MEM and RSN modules
- * 4) add data path for management frames
- * 5) eliminate rPacketInfo of MSDU_INFO_T
- *
- * 06 06 2010 kevin.huang
- * [WPD00003832][MT6620 5931] Create driver base
- * [MT6620 5931] Create driver base
- *
- * 03 30 2010 cp.wu
- * [WPD00001943]Create WiFi test driver framework on WinXP
- * remove driver-land statistics.
- *
- * 03 24 2010 cp.wu
- * [WPD00001943]Create WiFi test driver framework on WinXP
- * generate information for OID_GEN_RCV_OK & OID_GEN_XMIT_OK
- *  *
- *
- * 03 11 2010 cp.wu
- * [WPD00003821][BUG] Host driver stops processing RX packets from HIF RX0
- * add RX starvation warning debug message controlled by CFG_HIF_RX_STARVATION_WARNING
- *
- * 03 10 2010 cp.wu
- * [WPD00001943]Create WiFi test driver framework on WinXP
- * code clean: removing unused variables and structure definitions
- *
- * 02 25 2010 cp.wu
- * [WPD00001943]Create WiFi test driver framework on WinXP
- * correct behavior to prevent duplicated RX handling for RX0_DONE and RX1_DONE
- *
- * 02 10 2010 cp.wu
- * [WPD00001943]Create WiFi test driver framework on WinXP
- * implement host-side firmware download logic
- *
- * 02 10 2010 cp.wu
- * [WPD00001943]Create WiFi test driver framework on WinXP
- * 1) remove unused function in nic_rx.c [which has been handled in que_mgt.c]
- *  * 2) firmware image length is now retrieved via NdisFileOpen
- *  * 3) firmware image is not structured by (P_IMG_SEC_HDR_T) anymore
- *  * 4) nicRxWaitResponse() revised
- *  * 5) another set of TQ counter default value is added for fw-download state
- *  * 6) Wi-Fi load address is now retrieved from registry too
- *
- * 12 30 2009 cp.wu
- * [WPD00001943]Create WiFi test driver framework on WinXP
- * 1) According to CMD/EVENT documentation v0.8,
- *  *  *  * OID_CUSTOM_TEST_RX_STATUS & OID_CUSTOM_TEST_TX_STATUS is no longer used,
- *  *  *  * and result is retrieved by get ATInfo instead
- *  *  *  * 2) add 4 counter for recording aggregation statistics
-**  \main\maintrunk.MT6620WiFiDriver_Prj\24 2009-12-10 16:49:09 GMT mtk02752
-**  code clean
-**  \main\maintrunk.MT6620WiFiDriver_Prj\23 2009-12-09 14:02:37 GMT MTK02468
-**  Added ucStaRecIdx in SW_RFB_T and HALF_SEQ_NO_COUNT definition (to replace HALF_SEQ_NO_CNOUT)
-**  \main\maintrunk.MT6620WiFiDriver_Prj\22 2009-11-27 11:07:54 GMT mtk02752
-**  add flush for reset
-**  \main\maintrunk.MT6620WiFiDriver_Prj\21 2009-11-25 18:18:09 GMT mtk02752
-**  modify nicRxAddScanResult()
-**  \main\maintrunk.MT6620WiFiDriver_Prj\20 2009-11-24 22:42:22 GMT mtk02752
-**  add nicRxAddScanResult() to prepare to handle SCAN_RESULT event
-**  \main\maintrunk.MT6620WiFiDriver_Prj\19 2009-11-24 19:57:06 GMT mtk02752
-**  adopt P_HIF_RX_HEADER_T
-**  \main\maintrunk.MT6620WiFiDriver_Prj\18 2009-11-16 21:43:04 GMT mtk02752
-**  correct ENUM_RX_PKT_DESTINATION_T definitions
-**  \main\maintrunk.MT6620WiFiDriver_Prj\17 2009-11-16 15:28:25 GMT mtk02752
-**  add ucQueuedPacketNum for indicating how many packet are queued by RX reordering buffer/forwarding path
-**  \main\maintrunk.MT6620WiFiDriver_Prj\16 2009-11-16 15:05:01 GMT mtk02752
-**  add eTC for SW_RFB_T and structure RX_MAILBOX
-**  \main\maintrunk.MT6620WiFiDriver_Prj\15 2009-11-13 21:16:57 GMT mtk02752
-**  \main\maintrunk.MT6620WiFiDriver_Prj\14 2009-11-13 16:59:30 GMT mtk02752
-**  add handler for event packet
-**  \main\maintrunk.MT6620WiFiDriver_Prj\13 2009-11-13 13:45:50 GMT mtk02752
-**  add port param for nicRxEnhanceReadBuffer()
-**  \main\maintrunk.MT6620WiFiDriver_Prj\12 2009-11-11 10:12:31 GMT mtk02752
-**  nicSDIOReadIntStatus() always read sizeof(ENHANCE_MODE_DATA_STRUCT_T) for int response,
-**  thus the number should be set to 0(:=16) instead of 10
-**  \main\maintrunk.MT6620WiFiDriver_Prj\11 2009-10-29 19:53:32 GMT mtk01084
-**  modify structure naming
-**  \main\maintrunk.MT6620WiFiDriver_Prj\10 2009-10-23 16:08:23 GMT mtk01084
-**  \main\maintrunk.MT6620WiFiDriver_Prj\9 2009-10-13 21:59:01 GMT mtk01084
-**  update for new HW architecture design
-**  \main\maintrunk.MT6620WiFiDriver_Prj\8 2009-05-20 12:23:33 GMT mtk01461
-**  Add u4MaxEventBufferLen parameter to nicRxWaitResponse()
-**  \main\maintrunk.MT6620WiFiDriver_Prj\7 2009-05-18 21:00:48 GMT mtk01426
-**  Update SDIO_MAXIMUM_RX_STATUS value
-**  \main\maintrunk.MT6620WiFiDriver_Prj\6 2009-04-28 10:36:15 GMT mtk01461
-**  Remove unused define - SDIO_MAXIMUM_TX_STATUS
-**  \main\maintrunk.MT6620WiFiDriver_Prj\5 2009-04-01 10:53:17 GMT mtk01461
-**  Add function for HIF_LOOPBACK_PRE_TEST
-**  \main\maintrunk.MT6620WiFiDriver_Prj\4 2009-03-18 20:56:19 GMT mtk01426
-**  Add to support CFG_HIF_LOOPBACK and CFG_SDIO_RX_ENHANCE
-**  \main\maintrunk.MT6620WiFiDriver_Prj\3 2009-03-17 20:19:56 GMT mtk01426
-**  Add nicRxWaitResponse function proto type
-**  \main\maintrunk.MT6620WiFiDriver_Prj\2 2009-03-10 20:16:35 GMT mtk01426
-**  Init for develop
-**
-*/
 
 #ifndef _NIC_RX_H
 #define _NIC_RX_H
@@ -282,6 +126,7 @@ typedef struct _RX_CTRL_T {
 	QUE_T rFreeSwRfbList;
 	QUE_T rReceivedRfbList;
 	QUE_T rIndicatedRfbList;
+	QUE_T rUnInitializedRfbList;
 
 #if CFG_SDIO_RX_AGG
 	PUINT_8 pucRxCoalescingBufPtr;
@@ -375,7 +220,10 @@ VOID nicRxSDIOAggReceiveRFBs(IN P_ADAPTER_T prAdapter);
 
 WLAN_STATUS nicRxSetupRFB(IN P_ADAPTER_T prAdapter, IN P_SW_RFB_T prRfb);
 
-VOID nicRxReturnRFB(IN P_ADAPTER_T prAdapter, IN P_SW_RFB_T prRfb);
+VOID nicRxReturnRFB(IN P_ADAPTER_T prAdapter, IN P_SW_RFB_T prSwRfb);
+
+VOID nicRxReturnRFBwithUninit(IN P_ADAPTER_T prAdapter, IN P_SW_RFB_T prSwRfb
+	, IN BOOLEAN fgIsUninitRfb);
 
 VOID nicProcessRxInterrupt(IN P_ADAPTER_T prAdapter);
 

+ 25 - 2
drivers/misc/mediatek/connectivity/wlan/gen2/include/nic/que_mgt.h

@@ -439,6 +439,20 @@ typedef enum _ENUM_MAC_TX_QUEUE_INDEX_T {
 	MAC_TX_QUEUE_NUM
 } ENUM_MAC_TX_QUEUE_INDEX_T;
 
+typedef struct _EVENT_CHECK_REORDER_BUBBLE_T {
+	/* Event header */
+	UINT_16 u2Length;
+	UINT_16 u2Reserved1;	/* Must be filled with 0x0001 (EVENT Packet) */
+	UINT_8 ucEID;
+	UINT_8 ucSeqNum;
+	UINT_8 aucReserved2[2];
+
+	/* Event Body */
+	UINT_8 ucStaRecIdx;
+	UINT_8 ucTid;
+} EVENT_CHECK_REORDER_BUBBLE_T, *P_EVENT_CHECK_REORDER_BUBBLE_T;
+
+
 typedef struct _RX_BA_ENTRY_T {
 	BOOLEAN fgIsValid;
 	QUE_T rReOrderQue;
@@ -449,8 +463,11 @@ typedef struct _RX_BA_ENTRY_T {
 	/* For identifying the RX BA agreement */
 	UINT_8 ucStaRecIdx;
 	UINT_8 ucTid;
+	TIMER_T rReorderBubbleTimer;
+	UINT_16 u2FirstBubbleSn;
 
 	BOOLEAN fgIsWaitingForPktWithSsn;
+	BOOLEAN fgHasBubble;
 
 	/* UINT_8                  ucTxBufferSize; */
 	/* BOOL                    fgIsAcConstrain; */
@@ -884,9 +901,10 @@ qmInsertFallWithinReorderPkt(IN P_SW_RFB_T prSwRfb, IN P_RX_BA_ENTRY_T prReorder
 VOID qmInsertFallAheadReorderPkt(IN P_SW_RFB_T prSwRfb, IN P_RX_BA_ENTRY_T prReorderQueParm, OUT P_QUE_T prReturnedQue);
 
 BOOLEAN
-qmPopOutDueToFallWithin(IN P_RX_BA_ENTRY_T prReorderQueParm, OUT P_QUE_T prReturnedQue, OUT BOOLEAN *fgIsTimeout);
+qmPopOutDueToFallWithin(P_ADAPTER_T prAdapter, IN P_RX_BA_ENTRY_T prReorderQueParm, OUT P_QUE_T prReturnedQue,
+				OUT BOOLEAN *fgIsTimeout);
 
-VOID qmPopOutDueToFallAhead(IN P_RX_BA_ENTRY_T prReorderQueParm, OUT P_QUE_T prReturnedQue);
+VOID qmPopOutDueToFallAhead(P_ADAPTER_T prAdapter, IN P_RX_BA_ENTRY_T prReorderQueParm, OUT P_QUE_T prReturnedQue);
 
 VOID qmHandleMailboxRxMessage(IN MAILBOX_MSG_T prMailboxRxMsg);
 
@@ -949,11 +967,16 @@ VOID qmFreeAllByNetType(IN P_ADAPTER_T prAdapter, IN ENUM_NETWORK_TYPE_INDEX_T e
 
 UINT_32 qmGetRxReorderQueuedBufferCount(IN P_ADAPTER_T prAdapter);
 
+VOID qmHandleReorderBubbleTimeout(IN P_ADAPTER_T prAdapter, IN ULONG ulParamPtr);
+VOID qmHandleEventCheckReorderBubble(IN P_ADAPTER_T prAdapter, IN P_WIFI_EVENT_T prEvent);
+
 #if ARP_MONITER_ENABLE
 VOID qmDetectArpNoResponse(P_ADAPTER_T prAdapter, P_MSDU_INFO_T prMsduInfo);
 VOID qmResetArpDetect(VOID);
 VOID qmHandleRxArpPackets(P_ADAPTER_T prAdapter, P_SW_RFB_T prSwRfb);
 #endif
+VOID qmHandleRxIpPackets(P_ADAPTER_T prAdapter, P_SW_RFB_T prSwRfb, UINT_16 *flag);
+
 /*******************************************************************************
 *                              F U N C T I O N S
 ********************************************************************************

+ 18 - 636
drivers/misc/mediatek/connectivity/wlan/gen2/include/nic_cmd_event.h

@@ -1,641 +1,14 @@
 /*
-** Id: //Department/DaVinci/BRANCHES/MT6620_WIFI_DRIVER_V2_3/include/nic_cmd_event.h#1
+* This program is free software; you can redistribute it and/or modify
+* it under the terms of the GNU General Public License version 2 as
+* published by the Free Software Foundation.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+* See http://www.gnu.org/licenses/gpl-2.0.html for more details.
 */
 
-/*! \file   "nic_cmd_event.h"
-    \brief This file contains the declairation file of the WLAN OID processing routines
-	   of Windows driver for MediaTek Inc. 802.11 Wireless LAN Adapters.
-*/
-
-/*
-** Log: nic_cmd_event.h
- *
- * 03 29 2012 eason.tsai
- * [WCXRP00001216] [MT6628 Wi-Fi][Driver]add conditional define
- * add conditional define.
- *
- * 03 04 2012 eason.tsai
- * NULL
- * modify the cal fail report code.
- *
- * 01 06 2012 wh.su
- * [WCXRP00001153] [MT6620 Wi-Fi][Driver] Adding the get_ch_list and set_tx_power proto type function
- * redefine the CMD_ID_SET_TXPWR_CTRL value.
- *
- * 01 05 2012 wh.su
- * [WCXRP00001153] [MT6620 Wi-Fi][Driver] Adding the get_ch_list and set_tx_power proto type function
- * Adding the related ioctl / wlan oid function to set the Tx power cfg.
- *
- * 11 30 2011 cm.chang
- * [WCXRP00001128] [MT5931 Wi-Fi][FW] Update BB/RF setting based on RF doc v0.7 for LGE spec
- * 1. Add a new CMD for driver to set device mode
- * 2. Update calibration parameters
- *
- * 11 19 2011 yuche.tsai
- * NULL
- * Update RSSI for P2P.
- *
- * 11 18 2011 yuche.tsai
- * NULL
- * CONFIG P2P support RSSI query, default turned off.
- *
- * 11 10 2011 eddie.chen
- * [WCXRP00001096] [MT6620 Wi-Fi][Driver/FW] Enhance the log function (xlog)
- * Add TX_DONE status detail information.
- *
- * 11 08 2011 tsaiyuan.hsu
- * [WCXRP00001083] [MT6620 Wi-Fi][DRV]] dump debug counter or frames when debugging is triggered
- * check if CFG_SUPPORT_SWCR is defined to aoid compiler error.
- *
- * 11 07 2011 tsaiyuan.hsu
- * [WCXRP00001083] [MT6620 Wi-Fi][DRV]] dump debug counter or frames when debugging is triggered
- * add debug counters and periodically dump counters for debugging.
- *
- * 10 26 2011 cp.wu
- * [WCXRP00001065] [MT6620 Wi-Fi][MT5931][FW][DRV] Adding parameter for controlling
- * minimum channel dwell time for scanning
- * add interface for control minimum channel dwell time for scanning.
- *
- * 09 20 2011 cm.chang
- * [WCXRP00000997] [MT6620 Wi-Fi][Driver][FW] Handle change of BSS preamble type and slot time
- * New CMD definition about RLM parameters
- *
- * 08 31 2011 cm.chang
- * [WCXRP00000969] [MT6620 Wi-Fi][Driver][FW] Channel list for 5G band based on country code
- * .
- *
- * 08 25 2011 chinghwa.yu
- * [WCXRP00000612] [MT6620 Wi-Fi] [FW] CSD update SWRDD algorithm
- * Add DFS switch.
- *
- * 08 24 2011 chinghwa.yu
- * [WCXRP00000612] [MT6620 Wi-Fi] [FW] CSD update SWRDD algorithm
- * Update RDD test mode cases.
- *
- * 08 15 2011 cp.wu
- * [WCXRP00000851] [MT6628 Wi-Fi][Driver] Add HIFSYS related definition to driver source tree
- * add MT6628-specific definitions.
- *
- * 08 11 2011 cp.wu
- * [WCXRP00000830] [MT6620 Wi-Fi][Firmware] Use MDRDY counter to detect empty channel for shortening scan time
- * sparse channel detection:
- * driver: collect sparse channel information with scan-done event
- *
- * 08 09 2011 cp.wu
- * [WCXRP00000702] [MT5931][Driver] Modify initialization sequence for E1 ASIC
- * [WCXRP00000913] [MT6620 Wi-Fi] create repository of source code dedicated for MT6620 E6 ASIC
- * add CCK-DSSS TX-PWR control field in NVRAM and CMD definition for MT5931-MP
- *
- * 08 03 2011 terry.wu
- * [WCXRP00000899] [MT6620] [FW] Reply probe rsp in FW for hotspot mode
- * Reply Probe Rsp in FW for Hotspot Mode.
- *
- *
- *
- * 08 03 2011 terry.wu
- * [WCXRP00000899] [MT6620] [FW] Reply probe rsp in FW for hotspot mode
- * Reply Probe Rsp in FW for Hotspot Mode.
- *
- *
- * 08 03 2011 terry.wu
- * [WCXRP00000899] [MT6620] [FW] Reply probe rsp in FW for hotspot mode
- * Reply Probe Rsp in FW for Hotspot Mode.
- *
- * 08 03 2011 terry.wu
- * [WCXRP00000899] [MT6620] [FW] Reply probe rsp in FW for hotspot mode
- * Reply Probe Rsp in FW for Hotspot Mode.
- *
- * 07 28 2011 chinghwa.yu
- * [WCXRP00000063] Update BCM CoEx design and settings
- * Add BWCS cmd and event.
- *
- * 07 22 2011 jeffrey.chang
- * [WCXRP00000864] [MT5931] Add command to adjust OSC stable time
- * add osc stable time command structure
- *
- * 07 22 2011 jeffrey.chang
- * [WCXRP00000864] [MT5931] Add command to adjust OSC stable time
- * modify driver to set OSC stable time after f/w download
- *
- * 07 18 2011 chinghwa.yu
- * [WCXRP00000063] Update BCM CoEx design and settings[WCXRP00000612] [MT6620 Wi-Fi] [FW] CSD update SWRDD algorithm
- * Add CMD/Event for RDD and BWCS.
- *
- * 07 18 2011 cp.wu
- * [WCXRP00000858] [MT5931][Driver][Firmware] Add support for scan to search for more than
- * one SSID in a single scanning request
- * add framework in driver domain for supporting new SCAN_REQ_V2 for more than 1 SSID
- * support as well as uProbeDelay in NDIS 6.x driver model
- *
- * 06 23 2011 cp.wu
- * [WCXRP00000812] [MT6620 Wi-Fi][Driver] not show NVRAM when there is no valid MAC address in NVRAM content
- * check with firmware for valid MAC address.
- *
- * 06 23 2011 cp.wu
- * [WCXRP00000798] [MT6620 Wi-Fi][Firmware] Follow-ups for WAPI frequency offset workaround in firmware SCN module
- * change parameter name from PeerAddr to BSSID
- *
- * 06 20 2011 cp.wu
- * [WCXRP00000798] [MT6620 Wi-Fi][Firmware] Follow-ups for WAPI frequency offset workaround in firmware SCN module
- * 1. specify target's BSSID when requesting channel privilege.
- * 2. pass BSSID information to firmware domain
- *
- * 06 09 2011 tsaiyuan.hsu
- * [WCXRP00000760] [MT5931 Wi-Fi][FW] Refine rxmHandleMacRxDone to reduce code size
- * move send_auth at rxmHandleMacRxDone in firmware to driver to reduce code size.
- *
- * 05 27 2011 cp.wu
- * [WCXRP00000749] [MT6620 Wi-Fi][Driver] Add band edge tx power control to Wi-Fi NVRAM
- * invoke CMD_ID_SET_EDGE_TXPWR_LIMIT when there is valid data exist in NVRAM content.
- *
- * 04 18 2011 terry.wu
- * [WCXRP00000660] [MT6620 Wi-Fi][Driver] Remove flag CFG_WIFI_DIRECT_MOVED
- * Remove flag CFG_WIFI_DIRECT_MOVED.
- *
- * 03 31 2011 chinglan.wang
- * [WCXRP00000613] [MT6620 Wi-Fi] [FW] [Driver] BssInfo can get the security mode which is WPA/WPA2/WAPI or not.
- * .
- *
- * 03 18 2011 cm.chang
- * [WCXRP00000576] [MT6620 Wi-Fi][Driver][FW] Remove P2P compile option in scan req/cancel command
- * As CR title
- *
- * 03 17 2011 yarco.yang
- * [WCXRP00000569] [MT6620 Wi-Fi][F/W][Driver] Set multicast address support current network usage
- * .
- *
- * 03 07 2011 wh.su
- * [WCXRP00000506] [MT6620 Wi-Fi][Driver][FW] Add Security check related code
- * rename the define to anti_pviracy.
- *
- * 03 05 2011 wh.su
- * [WCXRP00000506] [MT6620 Wi-Fi][Driver][FW] Add Security check related code
- * add the code to get the check rsponse and indicate to app.
- *
- * 03 02 2011 wh.su
- * [WCXRP00000506] [MT6620 Wi-Fi][Driver][FW] Add Security check related code
- * Add Security check related code.
- *
- * 03 02 2011 george.huang
- * [WCXRP00000504] [MT6620 Wi-Fi][FW] Support Sigma CAPI for power saving related command
- * Support UAPSD/OppPS/NoA parameter setting
- *
- * 02 16 2011 cm.chang
- * [WCXRP00000447] [MT6620 Wi-Fi][FW] Support new NVRAM update mechanism
- * .
- *
- * 02 10 2011 cp.wu
- * [WCXRP00000434] [MT6620 Wi-Fi][Driver] Obsolete unused event packet handlers
- * EVENT_ID_CONNECTION_STATUS has been obsoleted and no need to handle.
- *
- * 02 08 2011 eddie.chen
- * [WCXRP00000426] [MT6620 Wi-Fi][FW/Driver] Add STA aging timeout and defualtHwRatein AP mode
- * Add event STA agint timeout
- *
- * 01 27 2011 tsaiyuan.hsu
- * [WCXRP00000392] [MT6620 Wi-Fi][Driver] Add Roaming Support
- * add roaming fsm
- * 1. not support 11r, only use strength of signal to determine roaming.
- * 2. not enable CFG_SUPPORT_ROAMING until completion of full test.
- * 3. in 6620, adopt work-around to avoid sign extension problem of cck of hw
- * 4. assume that change of link quality in smooth way.
- *
- * 01 25 2011 yuche.tsai
- * [WCXRP00000352] [Volunteer Patch][MT6620][Driver] P2P Statsion Record Client List Issue
- * Update cmd format of BSS INFO, always sync OwnMac to FW no matter P2P is enabled or not..
- *
- * 01 20 2011 eddie.chen
- * [WCXRP00000374] [MT6620 Wi-Fi][DRV] SW debug control
- * Add Oid for sw control debug command
- *
- * 01 15 2011 puff.wen
- * NULL
- * Add Stress test
- *
- * 01 12 2011 cm.chang
- * [WCXRP00000354] [MT6620 Wi-Fi][Driver][FW] Follow NVRAM bandwidth setting
- * Sync HT operation element information from host to FW
- *
- * 01 12 2011 cm.chang
- * [WCXRP00000354] [MT6620 Wi-Fi][Driver][FW] Follow NVRAM bandwidth setting
- * User-defined bandwidth is for 2.4G and 5G individually
- *
- * 12 29 2010 eddie.chen
- * [WCXRP00000322] Add WMM IE in beacon,
-
-Add per station flow control when STA is in PS
-
- * 1) PS flow control event
- *
- * 2) WMM IE in beacon, assoc resp, probe resp
- *
- * 12 28 2010 cp.wu
- * [WCXRP00000269] [MT6620 Wi-Fi][Driver][Firmware] Prepare for v1.1 branch release
- * report EEPROM used flag via NIC_CAPABILITY
- *
- * 12 28 2010 cp.wu
- * [WCXRP00000269] [MT6620 Wi-Fi][Driver][Firmware] Prepare for v1.1 branch release
- * integrate with 'EEPROM used' flag for reporting correct capability to Engineer Mode/META and other tools
- *
- * 12 23 2010 george.huang
- * [WCXRP00000152] [MT6620 Wi-Fi] AP mode power saving function
- * 1. update WMM IE parsing, with ASSOC REQ handling
- * 2. extend U-APSD parameter passing from driver to FW
- *
- * 12 07 2010 cm.chang
- * [WCXRP00000239] MT6620 Wi-Fi][Driver][FW] Merge concurrent branch back to maintrunk
- * 1. BSSINFO include RLM parameter
- * 2. free all sta records when network is disconnected
- *
- * 12 07 2010 cm.chang
- * [WCXRP00000238] MT6620 Wi-Fi][Driver][FW] Support regulation domain setting from NVRAM and supplicant
- * 1. Country code is from NVRAM or supplicant
- * 2. Change band definition in CMD/EVENT.
- *
- * 11 29 2010 cm.chang
- * [WCXRP00000210] [MT6620 Wi-Fi][Driver][FW] Set RCPI value in STA_REC for
- * initial TX rate selection of auto-rate algorithm
- * Sync RCPI of STA_REC to FW as reference of initial TX rate
- *
- * 11 08 2010 cm.chang
- * [WCXRP00000169] [MT6620 Wi-Fi][Driver][FW] Remove unused CNM recover message ID
- * Remove CNM channel reover message ID
- *
- * 11 01 2010 cp.wu
- * [WCXRP00000056] [MT6620 Wi-Fi][Driver] NVRAM implementation with Version Check
- * [WCXRP00000150] [MT6620 Wi-Fi][Driver] Add implementation for querying current TX rate from firmware auto rate module
- * 1) Query link speed (TX rate) from firmware directly with buffering mechanism to reduce overhead
- * 2) Remove CNM CH-RECOVER event handling
- * 3) cfg read/write API renamed with kal prefix for unified naming rules.
- *
- * 10 26 2010 cp.wu
- * [WCXRP00000056] [MT6620 Wi-Fi][Driver] NVRAM implementation with Version Check
- * [WCXRP00000137] [MT6620 Wi-Fi] [FW] Support NIC capability query command
- * 1) update NVRAM content template to ver 1.02
- * 2) add compile option for querying NIC capability (default: off)
- * 3) modify AIS 5GHz support to run-time option, which could be turned on by registry or NVRAM setting
- * 4) correct auto-rate compiler error under linux (treat warning as error)
- * 5) simplify usage of NVRAM and REG_INFO_T
- * 6) add version checking between driver and firmware
- *
- * 10 25 2010 cp.wu
- * [WCXRP00000133] [MT6620 Wi-Fi] [FW][Driver] Change TX power offset band definition
- * follow-up for CMD_5G_PWR_OFFSET_T definition change
- *
- * 10 20 2010 cp.wu
- * [WCXRP00000117] [MT6620 Wi-Fi][Driver] Add logic for suspending driver when MT6620 is not responding anymore
- * use OID_CUSTOM_TEST_MODE as indication for driver reset
- * by dropping pending TX packets
- *
- * 10 20 2010 wh.su
- * [WCXRP00000124] [MT6620 Wi-Fi] [Driver] Support the dissolve P2P Group
- * Add the code to support disconnect p2p group
- *
- * 09 15 2010 cm.chang
- * NULL
- * Add new CMD for TX power, 5G power offset and power parameters
- *
- * 09 07 2010 yuche.tsai
- * NULL
- * Add a pointer in P2P SCAN RESULT structure. This pointer
- * is pointed to a IE buffer for this P2p device.
- *
- * 09 07 2010 wh.su
- * NULL
- * adding the code for beacon/probe req/ probe rsp wsc ie at p2p.
- *
- * 09 03 2010 kevin.huang
- * NULL
- * Refine #include sequence and solve recursive/nested #include issue
- *
- * 08 23 2010 chinghwa.yu
- * NULL
- * Update for BOW.
- *
- * 08 20 2010 cm.chang
- * NULL
- * Migrate RLM code to host from FW
- *
- * 08 16 2010 george.huang
- * NULL
- * add new CMD ID definition
- *
- * 08 16 2010 yuche.tsai
- * NULL
- * Add a field in BSS INFO cmd to change interface address for P2P. (switching between Device Addr & Interface Addr)
- *
- * 08 12 2010 yuche.tsai
- * NULL
- * Add interface address indication when indicate connection status.
- * It is requested by supplicant to do 4 way handshake.
- *
- * 08 07 2010 wh.su
- * NULL
- * adding the privacy related code for P2P network
- *
- * 08 05 2010 yuche.tsai
- * NULL
- * Change data structure for P2P Device scan result, all channel time for scan command.
- *
- * 08 04 2010 george.huang
- * NULL
- * handle change PS mode OID/ CMD
- *
- * 08 04 2010 yarco.yang
- * NULL
- * Add TX_AMPDU and ADDBA_REJECT command
- *
- * 08 03 2010 george.huang
- * NULL
- * handle event for updating NOA parameters indicated from FW
- *
- * 08 02 2010 george.huang
- * NULL
- * add WMM-PS test related OID/ CMD handlers
- *
- * 07 28 2010 cp.wu
- * NULL
- * sync. CMD_BSS_INFO structure change to CMD-EVENT v0.15.
- *
- * 07 26 2010 yuche.tsai
- *
- * Add P2P Device Found Event.
- * Channel extension option in scan abort command.
- *
- * 07 23 2010 cp.wu
- *
- * add AIS-FSM handling for beacon timeout event.
- *
- * 07 21 2010 yuche.tsai
- *
- * Add for P2P Scan Result Parsing & Saving.
- *
- * 07 20 2010 george.huang
- *
- * DWORD align for the CMD data structure
- *
- * 07 20 2010 cp.wu
- *
- * pass band information for scan in an efficient way by mapping ENUM_BAND_T into UINT_8..
- *
- * 07 19 2010 wh.su
- *
- * update for security supporting.
- *
- * 07 19 2010 cm.chang
- *
- * Set RLM parameters and enable CNM channel manager
- *
- * 07 16 2010 yarco.yang
- *
- * 1. Support BSS Absence/Presence Event
- * 2. Support STA change PS mode Event
- * 3. Support BMC forwarding for AP mode.
- *
- * 07 14 2010 cp.wu
- *
- * [WPD00003833] [MT6620 and MT5931] Driver migration.
- * pass band with channel number information as scan parameter
- *
- * 07 14 2010 yarco.yang
- *
- * 1. Remove CFG_MQM_MIGRATION
- * 2. Add CMD_UPDATE_WMM_PARMS command
- *
- * 07 09 2010 cp.wu
- *
- * reorder members of CMD_SET_BSS_INFO.
- *
- * 07 08 2010 cp.wu
- *
- * [WPD00003833] [MT6620 and MT5931] Driver migration - move to new repository.
- *
- * 07 07 2010 cp.wu
- * [WPD00003833][MT6620 and MT5931] Driver migration
- * update prStaRecOfAP with BSS-INFO.
- *
- * 07 07 2010 cm.chang
- * [WPD00003841][LITE Driver] Migrate RLM/CNM to host driver
- * Support state of STA record change from 1 to 1
- *
- * 07 01 2010 cm.chang
- * [WPD00003841][LITE Driver] Migrate RLM/CNM to host driver
- * Support sync command of STA_REC
- *
- * 07 01 2010 cp.wu
- * [WPD00003833][MT6620 and MT5931] Driver migration
- * implementation of DRV-SCN and related mailbox message handling.
- *
- * 06 30 2010 cp.wu
- * [WPD00003833][MT6620 and MT5931] Driver migration
- * sync. with CMD/EVENT document ver0.07.
- *
- * 06 29 2010 cp.wu
- * [WPD00003833][MT6620 and MT5931] Driver migration
- * correct variable naming for 8-bit variable used in CMD_BEACON_TEMPLATE_UPDATE.
- *
- * 06 29 2010 cp.wu
- * [WPD00003833][MT6620 and MT5931] Driver migration
- * 1) sync to. CMD/EVENT document v0.03
- * 2) simplify DTIM period parsing in scan.c only, bss.c no longer parses it again.
- * 3) send command packet to indicate FW-PM after
- *     a) 1st beacon is received after AIS has connected to an AP
- *     b) IBSS-ALONE has been created
- *     c) IBSS-MERGE has occurred
- *
- * 06 28 2010 george.huang
- * [WPD00001556]Basic power managemenet function
- * Create beacon update path, with expose bssUpdateBeaconContent()
- *
- * 06 22 2010 cp.wu
- * [WPD00003833][MT6620 and MT5931] Driver migration
- * 1) add command warpper for STA-REC/BSS-INFO sync.
- * 2) enhance command packet sending procedure for non-oid part
- * 3) add command packet definitions for STA-REC/BSS-INFO sync.
- *
- * 06 21 2010 cp.wu
- * [WPD00003833][MT6620 and MT5931] Driver migration
- * add BSS/STA_REC commands for integration.
- *
- * 06 21 2010 yarco.yang
- * [WPD00003837][MT6620]Data Path Refine
- * Add TX Done Event handle entry
- *
- * 06 10 2010 cp.wu
- * [WPD00003833][MT6620 and MT5931] Driver migration
- * 1) eliminate CFG_CMD_EVENT_VERSION_0_9
- * 2) when disconnected, indicate nic directly (no event is needed)
- *
- * 06 06 2010 kevin.huang
- * [WPD00003832][MT6620 5931] Create driver base
- * [MT6620 5931] Create driver base
- *
- * 05 20 2010 cp.wu
- * [WPD00001943]Create WiFi test driver framework on WinXP
- * 1) integrate OID_GEN_NETWORK_LAYER_ADDRESSES with CMD_ID_SET_IP_ADDRESS
- * 2) buffer statistics data for 2 seconds
- * 3) use default value for adhoc parameters instead of 0
- *
- * 05 19 2010 cp.wu
- * [WPD00001943]Create WiFi test driver framework on WinXP
- * 1) do not take timeout mechanism for power mode oids
- * 2) retrieve network type from connection status
- * 3) after disassciation, set radio state to off
- * 4) TCP option over IPv6 is supported
- *
- * 05 17 2010 cp.wu
- * [WPD00001943]Create WiFi test driver framework on WinXP
- * correct OID_802_11_DISASSOCIATE handling.
- *
- * 05 17 2010 cp.wu
- * [WPD00003831][MT6620 Wi-Fi] Add framework for Wi-Fi Direct support
- * 1) add timeout handler mechanism for pending command packets
- * 2) add p2p add/removal key
- *
- * 04 13 2010 cp.wu
- * [WPD00003823][MT6620 Wi-Fi] Add Bluetooth-over-Wi-Fi support
- * add framework for BT-over-Wi-Fi support.
- *  *  *  *  *  *  *  *  *  * 1) prPendingCmdInfo is replaced by queue for multiple handler capability
- *  *  *  *  *  *  *  *  *  * 2) command sequence number is now increased atomically
- *  *  *  *  *  *  *  *  *  * 3) private data could be hold and taken use for other purpose
- *
- * 04 06 2010 cp.wu
- * [WPD00001943]Create WiFi test driver framework on WinXP
- * sync statistics data structure definition with firmware implementation
- *
- * 03 30 2010 cp.wu
- * [WPD00001943]Create WiFi test driver framework on WinXP
- * statistics information OIDs are now handled by querying from firmware domain
- *
- * 03 26 2010 cp.wu
- * [WPD00001943]Create WiFi test driver framework on WinXP
- * indicate media stream mode after set is done
- *
- * 03 26 2010 cp.wu
- * [WPD00001943]Create WiFi test driver framework on WinXP
- * add a temporary flag for integration with CMD/EVENT v0.9.
- *
- * 03 25 2010 cp.wu
- * [WPD00001943]Create WiFi test driver framework on WinXP
- * 1) correct OID_802_11_CONFIGURATION with frequency setting behavior.
- *  * the frequency is used for adhoc connection only
- *  * 2) update with SD1 v0.9 CMD/EVENT documentation
- *
- * 03 24 2010 jeffrey.chang
- * [WPD00003826]Initial import for Linux port
- * initial import for Linux port
- *
- * 03 22 2010 cp.wu
- * [WPD00003824][MT6620 Wi-Fi][New Feature] Add support of large scan list
- * Implement feature needed by CR: WPD00003824: refining association command by pasting scanning result
- *
- * 03 19 2010 cp.wu
- * [WPD00001943]Create WiFi test driver framework on WinXP
- * 1) add ACPI D0/D3 state switching support
- *  *  *  *  *  * 2) use more formal way to handle interrupt when the status is retrieved from enhanced RX response
- *
- * 03 15 2010 kevin.huang
- * [WPD00003820][MT6620 Wi-Fi] Modify the code for meet the WHQL test
- * Add event for activate STA_RECORD_T
- *
- * 03 03 2010 cp.wu
- * [WPD00001943]Create WiFi test driver framework on WinXP
- * implement custom OID: EEPROM read/write access
- *
- * 03 03 2010 cp.wu
- * [WPD00001943]Create WiFi test driver framework on WinXP
- * implement OID_802_3_MULTICAST_LIST oid handling
- *
- * 02 26 2010 cp.wu
- * [WPD00001943]Create WiFi test driver framework on WinXP
- * move EVENT_ID_ASSOC_INFO from nic_rx.c to gl_kal_ndis_51.c
- * 'cause it involves OS dependent data structure handling
- *
- * 02 25 2010 cp.wu
- * [WPD00001943]Create WiFi test driver framework on WinXP
- * send CMD_ID_INFRASTRUCTURE when handling OID_802_11_INFRASTRUCTURE_MODE set.
- *
- * 02 09 2010 cp.wu
- * [WPD00001943]Create WiFi test driver framework on WinXP
- * 1. Permanent and current MAC address are now retrieved by CMD/EVENT packets instead of hard-coded address
- *  *  *  *  * 2. follow MSDN defined behavior when associates to another AP
- *  *  *  *  * 3. for firmware download, packet size could be up to 2048 bytes
- *
- * 01 27 2010 wh.su
- * [WPD00003816][MT6620 Wi-Fi] Adding the security support
- * .
- *
- * 01 27 2010 cp.wu
- * [WPD00001943]Create WiFi test driver framework on WinXP
- * 1. eliminate improper variable in rHifInfo
- *  *  *  *  *  * 2. block TX/ordinary OID when RF test mode is engaged
- *  *  *  *  *  * 3. wait until firmware finish operation when entering into and leaving from RF test mode
- *  *  *  *  *  * 4. correct some HAL implementation
- *
- * 01 22 2010 cp.wu
- * [WPD00001943]Create WiFi test driver framework on WinXP
- * implement following 802.11 OIDs:
- *  *  * OID_802_11_RSSI,
- *  *  * OID_802_11_RSSI_TRIGGER,
- *  *  * OID_802_11_STATISTICS,
- *  *  * OID_802_11_DISASSOCIATE,
- *  *  * OID_802_11_POWER_MODE
- *
- * 01 21 2010 cp.wu
- * [WPD00001943]Create WiFi test driver framework on WinXP
- * implement OID_802_11_MEDIA_STREAM_MODE
- *
- * 01 21 2010 cp.wu
- * [WPD00001943]Create WiFi test driver framework on WinXP
- * implement OID_802_11_SUPPORTED_RATES / OID_802_11_DESIRED_RATES
- *
- * 12 30 2009 cp.wu
- * [WPD00001943]Create WiFi test driver framework on WinXP
- * 1) According to CMD/EVENT documentation v0.8,
- *  *  *  *  *  * OID_CUSTOM_TEST_RX_STATUS & OID_CUSTOM_TEST_TX_STATUS is no longer used,
- *  *  *  *  *  * and result is retrieved by get ATInfo instead
- *  *  *  *  *  * 2) add 4 counter for recording aggregation statistics
-**  \main\maintrunk.MT6620WiFiDriver_Prj\20 2009-12-11 18:35:07 GMT mtk02752
-**  add CMD added in CMD/EVEN document v0.8
-**  \main\maintrunk.MT6620WiFiDriver_Prj\19 2009-12-10 16:39:37 GMT mtk02752
-**  eliminate unused definitions
-**  \main\maintrunk.MT6620WiFiDriver_Prj\18 2009-12-10 09:55:11 GMT mtk02752
-**  command ID/event ID revised
-**  \main\maintrunk.MT6620WiFiDriver_Prj\17 2009-12-09 13:57:37 GMT MTK02468
-**  Added event ids (EVENT_ID_RX_ADDBA and EVENT_ID_RX_DELBA)
-**  \main\maintrunk.MT6620WiFiDriver_Prj\16 2009-12-08 17:35:39 GMT mtk02752
-**  + add event ID for EVENT_ID_TEST_STATUS (rf test)
-**  \main\maintrunk.MT6620WiFiDriver_Prj\15 2009-12-07 23:01:09 GMT mtk02752
-**  add data structure for RF_TEST
-**  \main\maintrunk.MT6620WiFiDriver_Prj\14 2009-12-03 16:22:56 GMT mtk01461
-**  Modify the element - i4RSSI in EVENT of SCAN RESULT
-**  \main\maintrunk.MT6620WiFiDriver_Prj\13 2009-11-30 10:54:44 GMT mtk02752
-**  1st DW of WIFI_CMD_T is shared with HIF_TX_HEADER_T, while 1st DW of WIFI_EVENT_T is shared with HIF_RX_HEADER_T
-**  \main\maintrunk.MT6620WiFiDriver_Prj\12 2009-11-26 10:16:58 GMT mtk02752
-**  resync EVENT_CONNECTION_STATUS
-**  \main\maintrunk.MT6620WiFiDriver_Prj\11 2009-11-25 21:34:01 GMT mtk02752
-**  sync. EVENT_SCAN_RESULT_T with firmware
-**  \main\maintrunk.MT6620WiFiDriver_Prj\10 2009-11-25 21:03:48 GMT mtk02752
-**  refine MGMT_FRAME
-**  \main\maintrunk.MT6620WiFiDriver_Prj\9 2009-11-25 18:17:47 GMT mtk02752
-**  refine GL_WLAN_INFO_T for buffering scan result and presume max. ie length = 600 bytes
-**  \main\maintrunk.MT6620WiFiDriver_Prj\8 2009-11-24 22:41:20 GMT mtk02752
-**  add EVENT_SCAN_RESULT_T definition
-**  \main\maintrunk.MT6620WiFiDriver_Prj\7 2009-11-23 20:29:16 GMT mtk02752
-**   fix typo
-**  \main\maintrunk.MT6620WiFiDriver_Prj\6 2009-11-23 14:46:01 GMT mtk02752
-**  add new command/event structure upon CM@SD1's documentation
-**  \main\maintrunk.MT6620WiFiDriver_Prj\5 2009-11-13 15:13:40 GMT mtk02752
-**  add command definition for CMD_BUILD_CONNECTION and EVENT_CONNECTION_STATUS
-**  \main\maintrunk.MT6620WiFiDriver_Prj\4 2009-05-20 12:22:22 GMT mtk01461
-**  Add SeqNum field to Event Header
-**  \main\maintrunk.MT6620WiFiDriver_Prj\3 2009-04-29 15:42:11 GMT mtk01461
-**  Update structure of HIF_EVENT_HEADER_T and EVENT_HDR_SIZE
-**  \main\maintrunk.MT6620WiFiDriver_Prj\2 2009-04-21 12:10:36 GMT mtk01461
-**  Add Common Set CMD Callback for MCR Write and other Set OID
-**  \main\maintrunk.MT6620WiFiDriver_Prj\1 2009-04-21 01:40:17 GMT mtk01461
-**  Command Done Handler
-*/
 #ifndef _NIC_CMD_EVENT_H
 #define _NIC_CMD_EVENT_H
 
@@ -661,6 +34,7 @@ Add per station flow control when STA is in PS
 
 #define MAX_IE_LENGTH       (600)
 #define MAX_WSC_IE_LENGTH   (400)
+#define MAX_FW_LOG_LENGTH   (896)
 
 /* Action field in structure CMD_CH_PRIVILEGE_T */
 #define CMD_CH_ACTION_REQ           0
@@ -752,6 +126,9 @@ typedef enum _ENUM_CMD_ID_T {
 	CMD_ID_SET_SYSTEM_SUSPEND = 0x60,	/* 0x60 (Set) */
 #if CFG_SUPPORT_FCC_DYNAMIC_TX_PWR_ADJUST
 	CMD_ID_SET_FCC_TX_PWR_CERT = 0x6F,	/* 0x6F (Set) */
+#endif
+#ifdef FW_CFG_SUPPORT
+	CMD_ID_GET_SET_CUSTOMER_CFG = 0x70,
 #endif
 	CMD_ID_GET_NIC_CAPABILITY = 0x80,	/* 0x80 (Query) */
 	CMD_ID_GET_LINK_QUALITY,	/* 0x81 (Query) */
@@ -780,6 +157,7 @@ typedef enum _ENUM_CMD_ID_T {
 	CMD_ID_SET_RDD_CH = 0xE1,
 #endif
 
+	CMD_ID_SET_NVRAM_SETTINGS = 0xEF,
 	CMD_ID_SET_BWCS = 0xF1,
 	CMD_ID_SET_ROAMING_INFO = 0xF3,
 
@@ -857,6 +235,7 @@ typedef enum _ENUM_EVENT_ID_T {
 	EVENT_ID_GSCAN_SCAN_AVAILABLE = 0x35,
 	EVENT_ID_GSCAN_RESULT = 0x36,
 	EVENT_ID_BATCH_RESULT = 0x37,
+	EVENT_ID_CHECK_REORDER_BUBBLE = 0x39,
 
 	EVENT_ID_TDLS = 0x80,
 	EVENT_ID_STATS_ENV = 0x81,
@@ -2012,7 +1391,7 @@ typedef struct _EVENT_FW_LOG_T {
 	UINT_8 fileName[64];
 	UINT_32 lineNo;
 	UINT_32 WifiUpTime;
-	UINT_8 log[896];	/* total size is aucBuffer in WIFI_EVENT_T */
+	UINT_8 log[MAX_FW_LOG_LENGTH];	/* total size is aucBuffer in WIFI_EVENT_T */
 } EVENT_FW_LOG_T, *P_EVENT_FW_LOG_T;
 
 typedef enum _ENUM_NLO_CIPHER_ALGORITHM {
@@ -2299,6 +1678,9 @@ VOID nicCmdEventBatchScanResult(IN P_ADAPTER_T prAdapter, IN P_CMD_INFO_T prCmdI
 
 VOID nicCmdEventGetBSSInfo(IN P_ADAPTER_T prAdapter, IN P_CMD_INFO_T prCmdInfo, IN PUINT_8 pucEventBuf);
 
+#ifdef FW_CFG_SUPPORT
+VOID nicCmdEventQueryCfgRead(IN P_ADAPTER_T prAdapter, IN P_CMD_INFO_T prCmdInfo, IN PUINT_8 pucEventBuf);
+#endif
 /*******************************************************************************
 *                              F U N C T I O N S
 ********************************************************************************

+ 1 - 1
drivers/misc/mediatek/connectivity/wlan/gen2/include/p2p_precomp.h

@@ -66,7 +66,6 @@
 /* Dependency:  hif_rx.h (P_HIF_RX_HEADER_T) */
 #include "nic_rx.h"
 
-#include "que_mgt.h"
 
 #if CFG_ENABLE_WIFI_DIRECT
 #include "p2p_typedef.h"
@@ -107,6 +106,7 @@
 #include "aa_fsm.h"
 
 #include "cnm_timer.h"
+#include "que_mgt.h"
 
 #if CFG_ENABLE_BT_OVER_WIFI
 #include "bow.h"

+ 2 - 1
drivers/misc/mediatek/connectivity/wlan/gen2/include/precomp.h

@@ -217,7 +217,6 @@
 /* Dependency:  hif_rx.h (P_HIF_RX_HEADER_T) */
 #include "nic_rx.h"
 
-#include "que_mgt.h"
 
 #if CFG_ENABLE_WIFI_DIRECT
 #include "p2p_typedef.h"
@@ -267,6 +266,8 @@
 
 #include "cnm_timer.h"
 
+#include "que_mgt.h"
+
 #if CFG_ENABLE_BT_OVER_WIFI
 #include "bow.h"
 #include "bow_fsm.h"

+ 2 - 3
drivers/misc/mediatek/connectivity/wlan/gen2/include/typedef.h

@@ -151,10 +151,9 @@
 #define WLAN_STATUS_INVALID_LENGTH              ((WLAN_STATUS) 0xC0010014L)
 #define WLAN_STATUS_INVALID_DATA                ((WLAN_STATUS) 0xC0010015L)
 #define WLAN_STATUS_BUFFER_TOO_SHORT            ((WLAN_STATUS) 0xC0010016L)
+#define WLAN_STATUS_BWCS_UPDATE                 ((WLAN_STATUS) 0xC0010017L)
 
-#define WLAN_STATUS_BWCS_UPDATE            ((WLAN_STATUS) 0xC0010017L)
-
-#define WLAN_STATUS_CONNECT_INDICATION          ((WLAN_STATUS) 0xC0010018L)
+#define WLAN_STATUS_JOIN_FAILURE                ((WLAN_STATUS) 0xC0010018L)
 
 /* NIC status flags */
 #define ADAPTER_FLAG_HW_ERR                     0x00400000

+ 39 - 2
drivers/misc/mediatek/connectivity/wlan/gen2/mgmt/ais_fsm.c

@@ -1957,6 +1957,23 @@ VOID aisFsmSteps(IN P_ADAPTER_T prAdapter, ENUM_AIS_STATE_T eNextState)
 					/* increase connection trial count for infrastructure connection */
 					if (prConnSettings->eOPMode == NET_TYPE_INFRA)
 						prAisFsmInfo->ucConnTrialCount++;
+
+					/* Join req timeout means Bss had lost and no need to looking for */
+					if (prAisFsmInfo->rJoinReqTime != 0 &&
+						   CHECK_FOR_TIMEOUT(kalGetTimeTick(),
+								     prAisFsmInfo->rJoinReqTime,
+								     SEC_TO_SYSTIME(AIS_JOIN_TIMEOUT))) {
+						UINT_16 u2StaTusCode = STATUS_CODE_JOIN_TIMEOUT;
+
+						prConnSettings->fgIsDisconnectedByNonRequest = TRUE;
+						eNextState = AIS_STATE_IDLE;
+						fgIsTransition = TRUE;
+						kalIndicateStatusAndComplete(prAdapter->prGlueInfo,
+									WLAN_STATUS_JOIN_FAILURE,
+									(PVOID)&u2StaTusCode, sizeof(u2StaTusCode));
+						break;
+					}
+
 					/* 4 <A> Try to SCAN */
 					if (prAisFsmInfo->fgTryScan) {
 						eNextState = AIS_STATE_LOOKING_FOR;
@@ -2671,6 +2688,8 @@ VOID aisFsmRunEventJoinComplete(IN P_ADAPTER_T prAdapter, IN P_MSG_HDR_T prMsgHd
 	P_BSS_INFO_T prAisBssInfo;
 	UINT_8 aucP2pSsid[] = CTIA_MAGIC_SSID;
 	OS_SYSTIME rCurrentTime;
+	P_CONNECTION_SETTINGS_T prConnSettings;
+	UINT_16 u2StatusCode = 0;
 
 	DEBUGFUNC("aisFsmRunEventJoinComplete()");
 
@@ -2683,6 +2702,7 @@ VOID aisFsmRunEventJoinComplete(IN P_ADAPTER_T prAdapter, IN P_MSG_HDR_T prMsgHd
 	prAssocRspSwRfb = prJoinCompMsg->prSwRfb;
 
 	eNextState = prAisFsmInfo->eCurrentState;
+	prConnSettings = &prAdapter->rWifiVar.rConnSettings;
 
 	DBGLOG(AIS, TRACE, "AISOK\n");
 
@@ -2803,8 +2823,16 @@ VOID aisFsmRunEventJoinComplete(IN P_ADAPTER_T prAdapter, IN P_MSG_HDR_T prMsgHd
 						*/
 						break;
 					}
+
+					DBGLOG(AIS, TRACE,
+					"ucJoinFailureCount=%d %d, Status=%d Reason=%d, eConnectionState=%d\n",
+					       prStaRec->ucJoinFailureCount, prBssDesc->ucJoinFailureCount,
+					       prStaRec->u2StatusCode, prStaRec->u2ReasonCode,
+					       prAisBssInfo->eConnectionState);
+
 					/* ASSERT(prBssDesc); */
 					/* ASSERT(prBssDesc->fgIsConnecting); */
+					u2StatusCode = prStaRec->u2StatusCode;
 					prBssDesc->ucJoinFailureCount++;
 					if (prBssDesc->ucJoinFailureCount >= SCN_BSS_JOIN_FAIL_THRESOLD) {
 						GET_CURRENT_SYSTIME(&prBssDesc->rJoinFailTime);
@@ -2833,7 +2861,9 @@ VOID aisFsmRunEventJoinComplete(IN P_ADAPTER_T prAdapter, IN P_MSG_HDR_T prMsgHd
 						prAdapter->rWifiVar.rConnSettings.fgIsConnReqIssued = FALSE;
 						prAdapter->rWifiVar.rConnSettings.eReConnectLevel = RECONNECT_LEVEL_MIN;
 						kalIndicateStatusAndComplete(prAdapter->prGlueInfo,
-								     WLAN_STATUS_CONNECT_INDICATION, NULL, 0);
+									     WLAN_STATUS_JOIN_FAILURE,
+									     (PVOID)&u2StatusCode,
+									     sizeof(u2StatusCode));
 
 						eNextState = AIS_STATE_IDLE;
 					} else {
@@ -3248,6 +3278,7 @@ VOID aisPostponedEventOfDisconnTimeout(IN P_ADAPTER_T prAdapter, IN P_AIS_FSM_IN
 {
 	P_BSS_INFO_T prAisBssInfo;
 	P_CONNECTION_SETTINGS_T prConnSettings;
+	P_SCAN_INFO_T prScanInfo;
 	BOOLEAN fgFound = TRUE;
 
 	/* firstly, check if we have started postpone indication.
@@ -3264,6 +3295,12 @@ VOID aisPostponedEventOfDisconnTimeout(IN P_ADAPTER_T prAdapter, IN P_AIS_FSM_IN
 		return;
 	}
 
+	prScanInfo = &(prAdapter->rWifiVar.rScanInfo);
+	if (prScanInfo->eCurrentState == SCAN_STATE_SCANNING) {
+		DBGLOG(AIS, INFO, "SCANNING, don't report disconnect\n");
+		return;
+	}
+
 	prAisBssInfo = &(prAdapter->rWifiVar.arBssInfo[NETWORK_TYPE_AIS_INDEX]);
 	prConnSettings = &(prAdapter->rWifiVar.rConnSettings);
 
@@ -4015,7 +4052,7 @@ VOID aisFsmRunEventJoinTimeout(IN P_ADAPTER_T prAdapter, ULONG ulParam)
 			eNextState = AIS_STATE_WAIT_FOR_NEXT_SCAN;
 		} else {
 			/* 3.4 Retreat to AIS_STATE_JOIN_FAILURE to terminate join operation */
-			kalIndicateStatusAndComplete(prAdapter->prGlueInfo, WLAN_STATUS_CONNECT_INDICATION, NULL, 0);
+			kalIndicateStatusAndComplete(prAdapter->prGlueInfo, WLAN_STATUS_JOIN_FAILURE, NULL, 0);
 			eNextState = AIS_STATE_IDLE;
 		}
 		break;

+ 72 - 803
drivers/misc/mediatek/connectivity/wlan/gen2/nic/nic_rx.c

@@ -1,804 +1,14 @@
 /*
-** Id: //Department/DaVinci/BRANCHES/MT6620_WIFI_DRIVER_V2_3/nic/nic_rx.c#3
+* This program is free software; you can redistribute it and/or modify
+* it under the terms of the GNU General Public License version 2 as
+* published by the Free Software Foundation.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+* See http://www.gnu.org/licenses/gpl-2.0.html for more details.
 */
 
-/*! \file   nic_rx.c
-    \brief  Functions that provide many rx-related functions
-
-    This file includes the functions used to process RFB and dispatch RFBs to
-    the appropriate related rx functions for protocols.
-*/
-
-/*
-** Log: nic_rx.c
-**
-** 08 31 2012 yuche.tsai
-** [ALPS00349585] [6577JB][WiFi direct][KE]Establish p2p connection while both device have connected to AP previously,
-** one device reboots automatically with KE
-** Fix possible KE when concurrent & disconnect.
- *
- * 07 17 2012 yuche.tsai
- * NULL
- * Let netdev bring up.
- *
- * 07 17 2012 yuche.tsai
- * NULL
- * Compile no error before trial run.
- *
- * 03 02 2012 terry.wu
- * NULL
- * Sync CFG80211 modification from branch 2,2.
- *
- * 02 14 2012 cp.wu
- * NULL
- * remove another assertion by error message dump
- *
- * 01 05 2012 tsaiyuan.hsu
- * [WCXRP00001157] [MT6620 Wi-Fi][FW][DRV] add timing measurement support for 802.11v
- * add timing measurement support for 802.11v.
- *
- * 11 19 2011 yuche.tsai
- * NULL
- * Update RSSI for P2P.
- *
- * 11 18 2011 yuche.tsai
- * NULL
- * CONFIG P2P support RSSI query, default turned off.
- *
- * 11 17 2011 tsaiyuan.hsu
- * [WCXRP00001115] [MT6620 Wi-Fi][DRV] avoid deactivating staRec when changing state 3 to 3.
- * avoid deactivating staRec when changing state from 3 to 3.
- *
- * 11 11 2011 wh.su
- * [WCXRP00001078] [MT6620 Wi-Fi][Driver] Adding the mediatek log improment support : XLOG
- * modify the xlog related code.
- *
- * 11 10 2011 eddie.chen
- * [WCXRP00001096] [MT6620 Wi-Fi][Driver/FW] Enhance the log function (xlog)
- * Modify the QM xlog level and remove LOG_FUNC.
- *
- * 11 09 2011 eddie.chen
- * [WCXRP00001096] [MT6620 Wi-Fi][Driver/FW] Enhance the log function (xlog)
- * Add xlog for beacon timeout and sta aging timeout.
- *
- * 11 08 2011 eddie.chen
- * [WCXRP00001096] [MT6620 Wi-Fi][Driver/FW] Enhance the log function (xlog)
- * Add xlog function.
- *
- * 11 07 2011 tsaiyuan.hsu
- * [WCXRP00001083] [MT6620 Wi-Fi][DRV]] dump debug counter or frames when debugging is triggered
- * add debug counters and periodically dump counters for debugging.
- *
- * 10 21 2011 eddie.chen
- * [WCXRP00001051] [MT6620 Wi-Fi][Driver/Fw] Adjust the STA aging timeout
- * Add switch to ignore the STA aging timeout.
- *
- * 10 12 2011 wh.su
- * [WCXRP00001036] [MT6620 Wi-Fi][Driver][FW] Adding the 802.11w code for MFP
- * adding the 802.11w related function and define .
- *
- * 08 26 2011 cp.wu
- * [WCXRP00000958] [MT6620 Wi-Fi][Driver] Extend polling timeout from 25ms to 1sec due to RF calibration might took
- * up to 600ms
- * extend polling RX response timeout period from 25ms to 1000ms.
- *
- * 08 11 2011 cp.wu
- * [WCXRP00000830] [MT6620 Wi-Fi][Firmware] Use MDRDY counter to detect empty channel for shortening scan time
- * sparse channel detection:
- * driver: collect sparse channel information with scan-done event
- *
- * 07 28 2011 chinghwa.yu
- * [WCXRP00000063] Update BCM CoEx design and settings
- * Add BWCS cmd and event.
- *
- * 07 27 2011 cp.wu
- * [WCXRP00000876] [MT5931][Drver] Decide to retain according to currently available RX counter and QUE_MGT used count
- * correct comment.
- *
- * 07 27 2011 cp.wu
- * [WCXRP00000876] [MT5931][Drver] Decide to retain according to currently available RX counter and QUE_MGT used count
- * take use of QUE_MGT exported function to estimate currently RX buffer usage count.
- *
- * 07 18 2011 chinghwa.yu
- * [WCXRP00000063] Update BCM CoEx design and settings[WCXRP00000612] [MT6620 Wi-Fi] [FW] CSD update SWRDD algorithm
- * Add CMD/Event for RDD and BWCS.
- *
- * 06 09 2011 tsaiyuan.hsu
- * [WCXRP00000760] [MT5931 Wi-Fi][FW] Refine rxmHandleMacRxDone to reduce code size
- * move send_auth at rxmHandleMacRxDone in firmware to driver to reduce code size.
- *
- * 05 11 2011 eddie.chen
- * [WCXRP00000709] [MT6620 Wi-Fi][Driver] Check free number before copying broadcast packet
- * Fix dest type when GO packet copying.
- *
- * 05 09 2011 eddie.chen
- * [WCXRP00000709] [MT6620 Wi-Fi][Driver] Check free number before copying broadcast packet
- * Check free number before copying broadcast packet.
- *
- * 05 05 2011 cp.wu
- * [WCXRP00000702] [MT5931][Driver] Modify initialization sequence for E1 ASIC
- * add delay after whole-chip resetting for MT5931 E1 ASIC.
- *
- * 04 18 2011 terry.wu
- * [WCXRP00000660] [MT6620 Wi-Fi][Driver] Remove flag CFG_WIFI_DIRECT_MOVED
- * Remove flag CFG_WIFI_DIRECT_MOVED.
- *
- * 04 12 2011 cm.chang
- * [WCXRP00000634] [MT6620 Wi-Fi][Driver][FW] 2nd BSS will not support 40MHz bandwidth for concurrency
- * .
- *
- * 04 08 2011 yuche.tsai
- * [WCXRP00000624] [Volunteer Patch][MT6620][Driver] Add device discoverability support for GO.
- * Add device discoverability support for GO.
- *
- * 04 01 2011 tsaiyuan.hsu
- * [WCXRP00000615] [MT 6620 Wi-Fi][Driver] Fix klocwork issues
- * fix the klocwork issues, 57500, 57501, 57502 and 57503.
- *
- * 03 19 2011 yuche.tsai
- * [WCXRP00000584] [Volunteer Patch][MT6620][Driver] Add beacon timeout support for WiFi Direct.
- * Add beacon timeout support for WiFi Direct Network.
- *
- * 03 18 2011 wh.su
- * [WCXRP00000530] [MT6620 Wi-Fi] [Driver] skip doing p2pRunEventAAAComplete after send assoc response Tx Done
- * enable the Anti_piracy check at driver .
- *
- * 03 17 2011 cp.wu
- * [WCXRP00000562] [MT6620 Wi-Fi][Driver] I/O buffer pre-allocation to avoid physically continuous memory shortage
- * after system running for a long period
- * use pre-allocated buffer for storing enhanced interrupt response as well
- *
- * 03 15 2011 cp.wu
- * [WCXRP00000559] [MT6620 Wi-Fi][Driver] Combine TX/RX DMA buffers into a single one to reduce physically continuous
- * memory consumption
- * 1. deprecate CFG_HANDLE_IST_IN_SDIO_CALLBACK
- * 2. Use common coalescing buffer for both TX/RX directions
- *
- *
- * 03 07 2011 wh.su
- * [WCXRP00000506] [MT6620 Wi-Fi][Driver][FW] Add Security check related code
- * rename the define to anti_pviracy.
- *
- * 03 05 2011 wh.su
- * [WCXRP00000506] [MT6620 Wi-Fi][Driver][FW] Add Security check related code
- * add the code to get the check rsponse and indicate to app.
- *
- * 03 02 2011 wh.su
- * [WCXRP00000506] [MT6620 Wi-Fi][Driver][FW] Add Security check related code
- * Add security check code.
- *
- * 03 02 2011 cp.wu
- * [WCXRP00000503] [MT6620 Wi-Fi][Driver] Take RCPI brought by association response as initial RSSI right after
- * connection is built.
- * use RCPI brought by ASSOC-RESP after connection is built as initial RCPI to avoid using a uninitialized MAC-RX RCPI.
- *
- * 02 10 2011 yuche.tsai
- * [WCXRP00000419] [Volunteer Patch][MT6620/MT5931][Driver] Provide function of disconnect to target station for AAA
- * module.
- * Remove Station Record after Aging timeout.
- *
- * 02 10 2011 cp.wu
- * [WCXRP00000434] [MT6620 Wi-Fi][Driver] Obsolete unused event packet handlers
- * EVENT_ID_CONNECTION_STATUS has been obsoleted and no need to handle.
- *
- * 02 09 2011 yuche.tsai
- * [WCXRP00000431] [Volunteer Patch][MT6620][Driver] Add MLME support for deauthentication under AP(Hot-Spot) mode.
- * Add MLME deauthentication support for Hot-Spot mode.
- *
- * 02 09 2011 eddie.chen
- * [WCXRP00000426] [MT6620 Wi-Fi][FW/Driver] Add STA aging timeout and defualtHwRatein AP mode
- * Adjust variable order.
- *
- * 02 08 2011 eddie.chen
- * [WCXRP00000426] [MT6620 Wi-Fi][FW/Driver] Add STA aging timeout and defualtHwRatein AP mode
- * Add event STA agint timeout
- *
- * 01 27 2011 tsaiyuan.hsu
- * [WCXRP00000392] [MT6620 Wi-Fi][Driver] Add Roaming Support
- * add roaming fsm
- * 1. not support 11r, only use strength of signal to determine roaming.
- * 2. not enable CFG_SUPPORT_ROAMING until completion of full test.
- * 3. in 6620, adopt work-around to avoid sign extension problem of cck of hw
- * 4. assume that change of link quality in smooth way.
- *
- * 01 26 2011 cm.chang
- * [WCXRP00000395] [MT6620 Wi-Fi][Driver][FW] Search STA_REC with additional net type index argument
- * .
- *
- * 01 24 2011 eddie.chen
- * [WCXRP00000385] [MT6620 Wi-Fi][DRV] Add destination decision for forwarding packets
- * Remove comments.
- *
- * 01 24 2011 eddie.chen
- * [WCXRP00000385] [MT6620 Wi-Fi][DRV] Add destination decision for forwarding packets
- * Add destination decision in AP mode.
- *
- * 01 24 2011 cm.chang
- * [WCXRP00000384] [MT6620 Wi-Fi][Driver][FW] Handle 20/40 action frame in AP mode and stop ampdu timer when sta_rec
- * is freed
- * Process received 20/40 coexistence action frame for AP mode
- *
- * 01 24 2011 cp.wu
- * [WCXRP00000382] [MT6620 Wi-Fi][Driver] Track forwarding packet number with notifying tx thread for serving
- * 1. add an extra counter for tracking pending forward frames.
- * 2. notify TX service thread as well when there is pending forward frame
- * 3. correct build errors leaded by introduction of Wi-Fi direct separation module
- *
- * 01 12 2011 cp.wu
- * [WCXRP00000357] [MT6620 Wi-Fi][Driver][Bluetooth over Wi-Fi] add another net device interface for BT AMP
- * implementation of separate BT_OVER_WIFI data path.
- *
- * 12 29 2010 eddie.chen
- * [WCXRP00000322] Add WMM IE in beacon,
-Add per station flow control when STA is in PS
-
- * 1) PS flow control event
- *
- * 2) WMM IE in beacon, assoc resp, probe resp
- *
- * 12 15 2010 george.huang
- * [WCXRP00000152] [MT6620 Wi-Fi] AP mode power saving function
- * update beacon for NoA
- *
- * 11 01 2010 cp.wu
- * [WCXRP00000056] [MT6620 Wi-Fi][Driver] NVRAM implementation with Version Check[WCXRP00000150] [MT6620 Wi-Fi][Driver]
- * Add implementation for querying current TX rate from firmware auto rate module
- * 1) Query link speed (TX rate) from firmware directly with buffering mechanism to reduce overhead
- * 2) Remove CNM CH-RECOVER event handling
- * 3) cfg read/write API renamed with kal prefix for unified naming rules.
- *
- * 10 27 2010 george.huang
- * [WCXRP00000127] [MT6620 Wi-Fi][Driver] Add a registry to disable Beacon Timeout function for SQA test by using E1 EVB
- * Support registry option for disable beacon lost detection.
- *
- * 10 20 2010 wh.su
- * NULL
- * add a cmd to reset the p2p key
- *
- * 10 20 2010 wh.su
- * [WCXRP00000124] [MT6620 Wi-Fi] [Driver] Support the dissolve P2P Group
- * Add the code to support disconnect p2p group
- *
- * 09 29 2010 wh.su
- * [WCXRP00000072] [MT6620 Wi-Fi][Driver] Fix TKIP Counter Measure EAPoL callback register issue
- * fixed compilier error.
- *
- * 09 29 2010 wh.su
- * [WCXRP00000072] [MT6620 Wi-Fi][Driver] Fix TKIP Counter Measure EAPoL callback register issue
- * [MT6620 Wi-Fi][Driver] Fix TKIP Counter Measure EAPoL callback register issue.
- *
- * 09 23 2010 cp.wu
- * [WCXRP00000052] [MT6620 Wi-Fi][Driver] Eliminate Linux Compile Warning
- * eliminate reference of CFG_RESPONSE_MAX_PKT_SIZE
- *
- * 09 21 2010 cp.wu
- * [WCXRP00000053] [MT6620 Wi-Fi][Driver] Reset incomplete and might leads to BSOD when entering RF test with AIS
- * associated
- * release RX packet to packet pool when in RF test mode
- *
- * 09 21 2010 cp.wu
- * [WCXRP00000053] [MT6620 Wi-Fi][Driver] Reset incomplete and might leads to BSOD when entering RF test with AIS
- @ associated
- * Do a complete reset with STA-REC null checking for RF test re-entry
- *
- * 09 08 2010 cp.wu
- * NULL
- * use static memory pool for storing IEs of scanning result.
- *
- * 09 07 2010 yuche.tsai
- * NULL
- * Add a common buffer, store the IE of a P2P device in this common buffer.
- *
- * 09 03 2010 kevin.huang
- * NULL
- * Refine #include sequence and solve recursive/nested #include issue
- *
- * 08 31 2010 kevin.huang
- * NULL
- * Use LINK LIST operation to process SCAN result
- *
- * 08 30 2010 cp.wu
- * NULL
- * eliminate klockwork errors
- *
- * 08 20 2010 cm.chang
- * NULL
- * Migrate RLM code to host from FW
- *
- * 08 20 2010 yuche.tsai
- * NULL
- * When enable WiFi Direct function, check each packet to tell which interface to indicate.
- *
- * 08 05 2010 yuche.tsai
- * NULL
- * Add P2P Device Discovery Function.
- *
- * 08 03 2010 cp.wu
- * NULL
- * surpress compilation warning.
- *
- * 08 03 2010 george.huang
- * NULL
- * handle event for updating NOA parameters indicated from FW
- *
- * 08 02 2010 yuche.tsai
- * NULL
- * Add support API for RX public action frame.
- *
- * 08 02 2010 jeffrey.chang
- * NULL
- * 1) modify tx service thread to avoid busy looping
- * 2) add spin lock declartion for linux build
- *
- * 07 30 2010 cp.wu
- * NULL
- * 1) BoW wrapper: use definitions instead of hard-coded constant for error code
- * 2) AIS-FSM: eliminate use of desired RF parameters, use prTargetBssDesc instead
- * 3) add handling for RX_PKT_DESTINATION_HOST_WITH_FORWARD for GO-broadcast frames
- *
- * 07 26 2010 yuche.tsai
- *
- * Update Device Capability Bitmap & Group Capability Bitmap from 16 bits to 8 bits.
- *
- * 07 24 2010 wh.su
- *
- * .support the Wi-Fi RSN
- *
- * 07 23 2010 cp.wu
- *
- * add AIS-FSM handling for beacon timeout event.
- *
- * 07 21 2010 yuche.tsai
- *
- * Add P2P Scan & Scan Result Parsing & Saving.
- *
- * 07 19 2010 cm.chang
- *
- * Set RLM parameters and enable CNM channel manager
- *
- * 07 19 2010 cp.wu
- *
- * [WPD00003833] [MT6620 and MT5931] Driver migration.
- * Add Ad-Hoc support to AIS-FSM
- *
- * 07 19 2010 jeffrey.chang
- *
- * Linux port modification
- *
- * 07 16 2010 yarco.yang
- *
- * 1. Support BSS Absence/Presence Event
- * 2. Support STA change PS mode Event
- * 3. Support BMC forwarding for AP mode.
- *
- * 07 15 2010 cp.wu
- *
- * sync. bluetooth-over-Wi-Fi interface to driver interface document v0.2.6.
- *
- * 07 08 2010 cp.wu
- *
- * [WPD00003833] [MT6620 and MT5931] Driver migration - move to new repository.
- *
- * 07 07 2010 cp.wu
- * [WPD00003833][MT6620 and MT5931] Driver migration
- * fill ucStaRecIdx into SW_RFB_T.
- *
- * 07 02 2010 cp.wu
- * [WPD00003833][MT6620 and MT5931] Driver migration
- * 1) for event packet, no need to fill RFB.
- * 2) when wlanAdapterStart() failed, no need to initialize state machines
- * 3) after Beacon/ProbeResp parsing, corresponding BSS_DESC_T should be marked as IE-parsed
- *
- * 07 01 2010 cp.wu
- * [WPD00003833][MT6620 and MT5931] Driver migration
- * implementation of DRV-SCN and related mailbox message handling.
- *
- * 06 29 2010 yarco.yang
- * [WPD00003837][MT6620]Data Path Refine
- * replace g_rQM with Adpater->rQM
- *
- * 06 23 2010 yarco.yang
- * [WPD00003837][MT6620]Data Path Refine
- * Merge g_arStaRec[] into adapter->arStaRec[]
- *
- * 06 22 2010 cp.wu
- * [WPD00003833][MT6620 and MT5931] Driver migration
- * 1) add command warpper for STA-REC/BSS-INFO sync.
- * 2) enhance command packet sending procedure for non-oid part
- * 3) add command packet definitions for STA-REC/BSS-INFO sync.
- *
- * 06 21 2010 cp.wu
- * [WPD00003833][MT6620 and MT5931] Driver migration
- * refine TX-DONE callback.
- *
- * 06 21 2010 cp.wu
- * [WPD00003833][MT6620 and MT5931] Driver migration
- * implement TX_DONE callback path.
- *
- * 06 21 2010 yarco.yang
- * [WPD00003837][MT6620]Data Path Refine
- * Add TX Done Event handle entry
- *
- * 06 21 2010 wh.su
- * [WPD00003840][MT6620 5931] Security migration
- * remove duplicate variable for migration.
- *
- * 06 15 2010 cp.wu
- * [WPD00003833][MT6620 and MT5931] Driver migration
- * .
- *
- * 06 15 2010 cp.wu
- * [WPD00003833][MT6620 and MT5931] Driver migration
- * .
- *
- * 06 14 2010 cp.wu
- * [WPD00003833][MT6620 and MT5931] Driver migration
- * saa_fsm.c is migrated.
- *
- * 06 14 2010 cp.wu
- * [WPD00003833][MT6620 and MT5931] Driver migration
- * add management dispatching function table.
- *
- * 06 11 2010 cp.wu
- * [WPD00003833][MT6620 and MT5931] Driver migration
- * 1) migrate assoc.c.
- * 2) add ucTxSeqNum for tracking frames which needs TX-DONE awareness
- * 3) add configuration options for CNM_MEM and RSN modules
- * 4) add data path for management frames
- * 5) eliminate rPacketInfo of MSDU_INFO_T
- *
- * 06 10 2010 cp.wu
- * [WPD00003833][MT6620 and MT5931] Driver migration
- * 1) eliminate CFG_CMD_EVENT_VERSION_0_9
- * 2) when disconnected, indicate nic directly (no event is needed)
- *
- * 06 08 2010 cp.wu
- * [WPD00003833][MT6620 and MT5931] Driver migration
- * cnm_timer has been migrated.
- *
- * 06 07 2010 cp.wu
- * [WPD00003833][MT6620 and MT5931] Driver migration
- * merge wlan_def.h.
- *
- * 06 07 2010 cp.wu
- * [WPD00003833][MT6620 and MT5931] Driver migration
- * sync with MT6620 driver for scan result replacement policy
- *
- * 06 06 2010 kevin.huang
- * [WPD00003832][MT6620 5931] Create driver base
- * [MT6620 5931] Create driver base
- *
- * 05 20 2010 cp.wu
- * [WPD00001943]Create WiFi test driver framework on WinXP
- * 1) integrate OID_GEN_NETWORK_LAYER_ADDRESSES with CMD_ID_SET_IP_ADDRESS
- * 2) buffer statistics data for 2 seconds
- * 3) use default value for adhoc parameters instead of 0
- *
- * 05 19 2010 cp.wu
- * [WPD00001943]Create WiFi test driver framework on WinXP
- * 1) do not take timeout mechanism for power mode oids
- * 2) retrieve network type from connection status
- * 3) after disassciation, set radio state to off
- * 4) TCP option over IPv6 is supported
- *
- * 04 29 2010 wh.su
- * [WPD00003816][MT6620 Wi-Fi] Adding the security support
- * fixing the PMKID candicate indicate code.
- *
- * 04 28 2010 cp.wu
- * [WPD00003823][MT6620 Wi-Fi] Add Bluetooth-over-Wi-Fi support
- * change prefix for data structure used to communicate with 802.11 PAL
- * to avoid ambiguous naming with firmware interface
- *
- * 04 27 2010 cp.wu
- * [WPD00003823][MT6620 Wi-Fi] Add Bluetooth-over-Wi-Fi support
- * basic implementation for EVENT_BT_OVER_WIFI
- *
- * 04 23 2010 cp.wu
- * [WPD00001943]Create WiFi test driver framework on WinXP
- * surpress compiler warning
- *
- * 04 22 2010 jeffrey.chang
- * [WPD00003826]Initial import for Linux port
- *
- * 1) modify rx path code for supporting Wi-Fi direct
- * 2) modify config.h since Linux dont need to consider retaining packet
- *
- * 04 16 2010 cp.wu
- * [WPD00001943]Create WiFi test driver framework on WinXP
- * treat BUS access failure as kind of card removal.
- *
- * 04 14 2010 cp.wu
- * [WPD00003823][MT6620 Wi-Fi] Add Bluetooth-over-Wi-Fi support
- * nicRxProcessEvent packet doesn't access spin-lock directly from now on.
- *
- * 04 14 2010 cp.wu
- * [WPD00003823][MT6620 Wi-Fi] Add Bluetooth-over-Wi-Fi support
- * do not need to release the spin lock due to it is done inside nicGetPendingCmdInfo()
- *
- * 04 13 2010 cp.wu
- * [WPD00003823][MT6620 Wi-Fi] Add Bluetooth-over-Wi-Fi support
- * add framework for BT-over-Wi-Fi support.
- *  *  *  *  *  *  *  *  *  *  *  *  *  *  * 1) prPendingCmdInfo is replaced by queue for multiple handler capability
- *  *  *  *  *  *  *  *  *  *  *  *  *  *  * 2) command sequence number is now increased atomically
- *  *  *  *  *  *  *  *  *  *  *  *  *  *  * 3) private data could be hold and taken use for other purpose
- *
- * 04 12 2010 cp.wu
- * [WPD00001943]Create WiFi test driver framework on WinXP
- * add channel frequency <-> number conversion
- *
- * 04 09 2010 jeffrey.chang
- * [WPD00003826]Initial import for Linux port
- * 1) add spinlock
- * 2) add KAPI for handling association info
- *
- * 04 07 2010 cp.wu
- * [WPD00001943]Create WiFi test driver framework on WinXP
- * rWlanInfo should be placed at adapter rather than glue due to most operations
- *  *  *  *  * are done in adapter layer.
- *
- * 04 07 2010 cp.wu
- * [WPD00001943]Create WiFi test driver framework on WinXP
- * eliminate direct access to prGlueInfo->eParamMediaStateIndicated from non-glue layer
- *
- * 04 06 2010 cp.wu
- * [WPD00001943]Create WiFi test driver framework on WinXP
- * eliminate direct access for prGlueInfo->fgIsCardRemoved in non-glue layer
- *
- * 04 01 2010 jeffrey.chang
- * [WPD00003826]Initial import for Linux port
- * improve Linux supplicant compliance
- *
- * 03 31 2010 jeffrey.chang
- * [WPD00003826]Initial import for Linux port
- * fix ioctl which may cause cmdinfo memory leak
- *
- * 03 30 2010 cp.wu
- * [WPD00001943]Create WiFi test driver framework on WinXP
- * remove driver-land statistics.
- *
- * 03 29 2010 jeffrey.chang
- * [WPD00003826]Initial import for Linux port
- * improve none-glue code portability
- *
- * 03 28 2010 jeffrey.chang
- * [WPD00003826]Initial import for Linux port
- * rWlanInfo is modified before data is indicated to OS
- *
- * 03 28 2010 jeffrey.chang
- * [WPD00003826]Initial import for Linux port
- * rWlanInfo is modified before data is indicated to OS
- *
- * 03 26 2010 cp.wu
- * [WPD00001943]Create WiFi test driver framework on WinXP
- * add a temporary flag for integration with CMD/EVENT v0.9.
- *
- * 03 25 2010 cp.wu
- * [WPD00001943]Create WiFi test driver framework on WinXP
- * 1) correct OID_802_11_CONFIGURATION with frequency setting behavior.
- *  *  * the frequency is used for adhoc connection only
- *  *  * 2) update with SD1 v0.9 CMD/EVENT documentation
- *
- * 03 24 2010 jeffrey.chang
- * [WPD00003826]Initial import for Linux port
- * initial import for Linux port
- *
- * 03 24 2010 cp.wu
- * [WPD00001943]Create WiFi test driver framework on WinXP
- * .
- *
- * 03 24 2010 cp.wu
- * [WPD00001943]Create WiFi test driver framework on WinXP
- * generate information for OID_GEN_RCV_OK & OID_GEN_XMIT_OK
- *  *  *  *
- *
- * 03 19 2010 cp.wu
- * [WPD00001943]Create WiFi test driver framework on WinXP
- * 1) add ACPI D0/D3 state switching support
- *  *  *  *  *  *  *  *  * 2) use more formal way to handle interrupt when the status is retrieved from enhanced RX
- * response
- *
- * 03 15 2010 kevin.huang
- * [WPD00003820][MT6620 Wi-Fi] Modify the code for meet the WHQL test
- * Add event for activate STA_RECORD_T
- *
- * 03 12 2010 cp.wu
- * [WPD00001943]Create WiFi test driver framework on WinXP
- * correct fgSetQuery/fgNeedResp check
- *
- * 03 11 2010 cp.wu
- * [WPD00003821][BUG] Host driver stops processing RX packets from HIF RX0
- * add RX starvation warning debug message controlled by CFG_HIF_RX_STARVATION_WARNING
- *
- * 03 10 2010 cp.wu
- * [WPD00001943]Create WiFi test driver framework on WinXP
- * code clean: removing unused variables and structure definitions
- *
- * 03 08 2010 cp.wu
- * [WPD00001943]Create WiFi test driver framework on WinXP
- * 1) add another spin-lock to protect MsduInfoList due to it might be accessed by different thread.
- *  *  * 2) change own-back acquiring procedure to wait for up to 16.67 seconds
- *
- * 03 02 2010 cp.wu
- * [WPD00001943]Create WiFi test driver framework on WinXP
- * 1) the use of prPendingOid revised, all accessing are now protected by spin lock
- *  *  *  * 2) ensure wlanReleasePendingOid will clear all command queues
- *
- * 03 02 2010 cp.wu
- * [WPD00001943]Create WiFi test driver framework on WinXP
- * add mutex to avoid multiple access to qmTxQueue simultaneously.
- *
- * 02 26 2010 cp.wu
- * [WPD00001943]Create WiFi test driver framework on WinXP
- * move EVENT_ID_ASSOC_INFO from nic_rx.c to gl_kal_ndis_51.c
- *  * 'cause it involves OS dependent data structure handling
- *
- * 02 25 2010 cp.wu
- * [WPD00001943]Create WiFi test driver framework on WinXP
- * correct behavior to prevent duplicated RX handling for RX0_DONE and RX1_DONE
- *
- * 02 24 2010 tehuang.liu
- * [WPD00001943]Create WiFi test driver framework on WinXP
- * Updated API interfaces for qmHandleEventRxAddBa() and qmHandleEventRxDelBa()
- *
- * 02 10 2010 cp.wu
- * [WPD00001943]Create WiFi test driver framework on WinXP
- * implement host-side firmware download logic
- *
- * 02 10 2010 cp.wu
- * [WPD00001943]Create WiFi test driver framework on WinXP
- * 1) remove unused function in nic_rx.c [which has been handled in que_mgt.c]
- *  *  *  *  * 2) firmware image length is now retrieved via NdisFileOpen
- *  *  *  *  * 3) firmware image is not structured by (P_IMG_SEC_HDR_T) anymore
- *  *  *  *  * 4) nicRxWaitResponse() revised
- *  *  *  *  * 5) another set of TQ counter default value is added for fw-download state
- *  *  *  *  * 6) Wi-Fi load address is now retrieved from registry too
- *
- * 02 09 2010 cp.wu
- * [WPD00001943]Create WiFi test driver framework on WinXP
- * 1. Permanent and current MAC address are now retrieved by CMD/EVENT packets instead of hard-coded address
- *  *  *  *  *  *  *  * 2. follow MSDN defined behavior when associates to another AP
- *  *  *  *  *  *  *  * 3. for firmware download, packet size could be up to 2048 bytes
- *
- * 01 27 2010 wh.su
- * [WPD00003816][MT6620 Wi-Fi] Adding the security support
- * .
- *
- * 01 22 2010 cp.wu
- * [WPD00001943]Create WiFi test driver framework on WinXP
- * implement following 802.11 OIDs:
- *  *  *  *  *  * OID_802_11_RSSI,
- *  *  *  *  *  * OID_802_11_RSSI_TRIGGER,
- *  *  *  *  *  * OID_802_11_STATISTICS,
- *  *  *  *  *  * OID_802_11_DISASSOCIATE,
- *  *  *  *  *  * OID_802_11_POWER_MODE
- *
- * 12 30 2009 cp.wu
- * [WPD00001943]Create WiFi test driver framework on WinXP
- * 1) According to CMD/EVENT documentation v0.8,
- *  *  *  *  *  *  *  *  * OID_CUSTOM_TEST_RX_STATUS & OID_CUSTOM_TEST_TX_STATUS is no longer used,
- *  *  *  *  *  *  *  *  * and result is retrieved by get ATInfo instead
- *  *  *  *  *  *  *  *  * 2) add 4 counter for recording aggregation statistics
- *
- * 12 23 2009 cp.wu
- * [WPD00001943]Create WiFi test driver framework on WinXP
- * add a precheck: if free sw rfb is not enough, do not invoke read transactionu1rwduu`wvpghlqg|fu+rp
- *
- * 12 22 2009 cp.wu
- * [WPD00003809][Bug] Host driver will crash when processing reordered MSDUs
- * The root cause is pointer accessing by mistake. After dequeued from reordering-buffer, handling logic should access
- * returned pointer instead of pointer which has been passed in before.
-**  \main\maintrunk.MT6620WiFiDriver_Prj\58 2009-12-17 13:40:33 GMT mtk02752
-**  always update prAdapter->rSDIOCtrl when enhanced response is read by RX
-**  \main\maintrunk.MT6620WiFiDriver_Prj\57 2009-12-16 18:01:38 GMT mtk02752
-**  if interrupt enhanced response is fetched by RX enhanced response, RX needs to invoke interrupt handlers too
-**  \main\maintrunk.MT6620WiFiDriver_Prj\56 2009-12-16 14:16:52 GMT mtk02752
-**  \main\maintrunk.MT6620WiFiDriver_Prj\55 2009-12-15 20:03:12 GMT mtk02752
-**  ASSERT when RX FreeSwRfb is not enough
-**  \main\maintrunk.MT6620WiFiDriver_Prj\54 2009-12-15 17:01:29 GMT mtk02752
-**  when CFG_SDIO_RX_ENHANCE is enabled, after enhanced response is read, rx procedure should process
-**  1) TX_DONE_INT 2) D2H INT as well
-**  \main\maintrunk.MT6620WiFiDriver_Prj\53 2009-12-14 20:45:28 GMT mtk02752
-**  when CFG_SDIO_RX_ENHANCE is set, TC counter must be updated each time RX enhance response is read
-**
-**  \main\maintrunk.MT6620WiFiDriver_Prj\52 2009-12-14 11:34:16 GMT mtk02752
-**  correct a trivial logic issue
-**  \main\maintrunk.MT6620WiFiDriver_Prj\51 2009-12-14 10:28:25 GMT mtk02752
-**  add a protection to avoid out-of-boundary access
-**  \main\maintrunk.MT6620WiFiDriver_Prj\50 2009-12-10 16:55:18 GMT mtk02752
-**  code clean
-**  \main\maintrunk.MT6620WiFiDriver_Prj\49 2009-12-09 14:06:47 GMT MTK02468
-**  Added parsing event packets with EVENT_ID_RX_ADDBA or EVENT_ID_RX_DELBA
-**  \main\maintrunk.MT6620WiFiDriver_Prj\48 2009-12-08 17:37:51 GMT mtk02752
-**  handle EVENT_ID_TEST_STATUS as well
-**  \main\maintrunk.MT6620WiFiDriver_Prj\47 2009-12-04 17:59:11 GMT mtk02752
-**  to pass free-build compilation check
-**  \main\maintrunk.MT6620WiFiDriver_Prj\46 2009-12-04 12:09:52 GMT mtk02752
-**  correct trivial mistake
-**  \main\maintrunk.MT6620WiFiDriver_Prj\45 2009-12-04 11:53:37 GMT mtk02752
-**  all API should be compilable under SD1_SD3_DATAPATH_INTEGRATION == 0
-**  \main\maintrunk.MT6620WiFiDriver_Prj\44 2009-12-03 16:19:48 GMT mtk01461
-**  Fix the Connected Event
-**  \main\maintrunk.MT6620WiFiDriver_Prj\43 2009-11-30 10:56:18 GMT mtk02752
-**  1st DW of WIFI_EVENT_T is shared with HIF_RX_HEADER_T
-**  \main\maintrunk.MT6620WiFiDriver_Prj\42 2009-11-30 10:11:27 GMT mtk02752
-**  implement replacement for bss scan result
-**  \main\maintrunk.MT6620WiFiDriver_Prj\41 2009-11-27 11:08:05 GMT mtk02752
-**  add flush for reset
-**  \main\maintrunk.MT6620WiFiDriver_Prj\40 2009-11-26 09:38:59 GMT mtk02752
-**  \main\maintrunk.MT6620WiFiDriver_Prj\39 2009-11-26 09:29:40 GMT mtk02752
-**  enable packet forwarding path (for AP mode)
-**  \main\maintrunk.MT6620WiFiDriver_Prj\38 2009-11-25 21:37:00 GMT mtk02752
-**  sync. with EVENT_SCAN_RESULT_T change, and add an assert for checking event size
-**  \main\maintrunk.MT6620WiFiDriver_Prj\37 2009-11-25 20:17:41 GMT mtk02752
-**  fill HIF_TX_HEADER_T.u2SeqNo
-**  \main\maintrunk.MT6620WiFiDriver_Prj\36 2009-11-25 18:18:57 GMT mtk02752
-**  buffer scan result to prGlueInfo->rWlanInfo.arScanResult directly.
-**  \main\maintrunk.MT6620WiFiDriver_Prj\35 2009-11-24 22:42:45 GMT mtk02752
-**  add nicRxAddScanResult() to prepare to handle SCAN_RESULT event (not implemented yet)
-**  \main\maintrunk.MT6620WiFiDriver_Prj\34 2009-11-24 20:51:41 GMT mtk02752
-**  integrate with SD1's data path API
-**  \main\maintrunk.MT6620WiFiDriver_Prj\33 2009-11-24 19:56:17 GMT mtk02752
-**  adopt P_HIF_RX_HEADER_T in new path
-**  \main\maintrunk.MT6620WiFiDriver_Prj\32 2009-11-23 20:31:21 GMT mtk02752
-**  payload to send into pfCmdDoneHandler() will not include WIFI_EVENT_T
-**  \main\maintrunk.MT6620WiFiDriver_Prj\31 2009-11-23 17:51:34 GMT mtk02752
-**  when event packet corresponding to some pendingOID is received, pendingOID should be cleared
-**  \main\maintrunk.MT6620WiFiDriver_Prj\30 2009-11-23 14:46:54 GMT mtk02752
-**  implement nicRxProcessEventPacket()
-**  \main\maintrunk.MT6620WiFiDriver_Prj\29 2009-11-17 22:40:54 GMT mtk01084
-**  \main\maintrunk.MT6620WiFiDriver_Prj\28 2009-11-16 21:48:22 GMT mtk02752
-**  add SD1_SD3_DATAPATH_INTEGRATION data path handling
-**  \main\maintrunk.MT6620WiFiDriver_Prj\27 2009-11-16 15:41:18 GMT mtk01084
-**  modify the length to be read in emu mode
-**  \main\maintrunk.MT6620WiFiDriver_Prj\26 2009-11-13 17:00:12 GMT mtk02752
-**  add blank function for event packet
-**  \main\maintrunk.MT6620WiFiDriver_Prj\25 2009-11-13 13:54:24 GMT mtk01084
-**  \main\maintrunk.MT6620WiFiDriver_Prj\24 2009-11-11 14:41:51 GMT mtk02752
-**  fix typo
-**  \main\maintrunk.MT6620WiFiDriver_Prj\23 2009-11-11 14:33:46 GMT mtk02752
-**  add protection when there is no packet avilable
-**  \main\maintrunk.MT6620WiFiDriver_Prj\22 2009-11-11 12:33:36 GMT mtk02752
-**  add RX1 read path for aggregated/enhanced/normal packet read procedures
-**  \main\maintrunk.MT6620WiFiDriver_Prj\21 2009-11-11 10:36:18 GMT mtk01084
-**  \main\maintrunk.MT6620WiFiDriver_Prj\20 2009-11-04 14:11:08 GMT mtk01084
-**  modify lines in RX aggregation
-**  \main\maintrunk.MT6620WiFiDriver_Prj\19 2009-10-30 18:17:23 GMT mtk01084
-**  modify RX aggregation handling
-**  \main\maintrunk.MT6620WiFiDriver_Prj\18 2009-10-29 19:56:12 GMT mtk01084
-**  modify HAL part
-**  \main\maintrunk.MT6620WiFiDriver_Prj\17 2009-10-23 16:08:34 GMT mtk01084
-**  \main\maintrunk.MT6620WiFiDriver_Prj\16 2009-10-13 21:59:20 GMT mtk01084
-**  update for new HW design
-**  \main\maintrunk.MT6620WiFiDriver_Prj\15 2009-10-02 13:59:08 GMT mtk01725
-**  \main\maintrunk.MT6620WiFiDriver_Prj\14 2009-05-21 23:39:05 GMT mtk01461
-**  Fix the paste error of RX STATUS in OOB of HIF Loopback CTRL
-**  \main\maintrunk.MT6620WiFiDriver_Prj\13 2009-05-20 12:25:32 GMT mtk01461
-**  Fix process of Read Done, and add u4MaxEventBufferLen to nicRxWaitResponse()
-**  \main\maintrunk.MT6620WiFiDriver_Prj\12 2009-05-18 21:13:18 GMT mtk01426
-**  Fixed compiler error
-**  \main\maintrunk.MT6620WiFiDriver_Prj\11 2009-05-18 21:05:29 GMT mtk01426
-**  Fixed nicRxSDIOAggReceiveRFBs() ASSERT issue
-**  \main\maintrunk.MT6620WiFiDriver_Prj\10 2009-04-28 10:38:43 GMT mtk01461
-**  Fix RX STATUS is DW align for SDIO_STATUS_ENHANCE mode and refine  nicRxSDIOAggeceiveRFBs() for RX Aggregation
-**  \main\maintrunk.MT6620WiFiDriver_Prj\9 2009-04-22 09:12:17 GMT mtk01461
-**  Fix nicRxProcessHIFLoopbackPacket(), the size of HIF CTRL LENGTH field is 1 byte
-**  \main\maintrunk.MT6620WiFiDriver_Prj\8 2009-04-14 15:51:26 GMT mtk01426
-**  Update RX OOB Setting
-**  \main\maintrunk.MT6620WiFiDriver_Prj\7 2009-04-03 14:58:58 GMT mtk01426
-**  Fixed logical error
-**  \main\maintrunk.MT6620WiFiDriver_Prj\6 2009-04-01 10:58:31 GMT mtk01461
-**  Rename the HIF_PKT_TYPE_DATA
-**  \main\maintrunk.MT6620WiFiDriver_Prj\5 2009-03-23 21:51:18 GMT mtk01461
-**  Fix u4HeaderOffset in nicRxProcessHIFLoopbackPacket()
-**  \main\maintrunk.MT6620WiFiDriver_Prj\4 2009-03-18 21:02:58 GMT mtk01426
-**  Add CFG_SDIO_RX_ENHANCE and CFG_HIF_LOOPBACK support
-**  \main\maintrunk.MT6620WiFiDriver_Prj\3 2009-03-17 20:20:59 GMT mtk01426
-**  Add nicRxWaitResponse function
-**  \main\maintrunk.MT6620WiFiDriver_Prj\2 2009-03-10 20:26:01 GMT mtk01426
-**  Init for develop
-**
-*/
 
 /*******************************************************************************
 *                         C O M P I L E R   F L A G S
@@ -923,6 +133,7 @@ VOID nicRxInitialize(IN P_ADAPTER_T prAdapter)
 	QUEUE_INITIALIZE(&prRxCtrl->rFreeSwRfbList);
 	QUEUE_INITIALIZE(&prRxCtrl->rReceivedRfbList);
 	QUEUE_INITIALIZE(&prRxCtrl->rIndicatedRfbList);
+	QUEUE_INITIALIZE(&prRxCtrl->rUnInitializedRfbList);
 
 	pucMemHandle = prRxCtrl->pucRxCached;
 	for (i = CFG_RX_MAX_PKT_NUM; i != 0; i--) {
@@ -990,6 +201,7 @@ VOID nicRxUninitialize(IN P_ADAPTER_T prAdapter)
 			if (prSwRfb->pvPacket)
 				kalPacketFree(prAdapter->prGlueInfo, prSwRfb->pvPacket);
 			prSwRfb->pvPacket = NULL;
+			prSwRfb->pucRecvBuff = NULL;
 		} else {
 			break;
 		}
@@ -1003,6 +215,21 @@ VOID nicRxUninitialize(IN P_ADAPTER_T prAdapter)
 			if (prSwRfb->pvPacket)
 				kalPacketFree(prAdapter->prGlueInfo, prSwRfb->pvPacket);
 			prSwRfb->pvPacket = NULL;
+			prSwRfb->pucRecvBuff = NULL;
+		} else {
+			break;
+		}
+	} while (TRUE);
+
+	do {
+		KAL_ACQUIRE_SPIN_LOCK(prAdapter, SPIN_LOCK_RX_QUE);
+		QUEUE_REMOVE_HEAD(&prRxCtrl->rUnInitializedRfbList, prSwRfb, P_SW_RFB_T);
+		KAL_RELEASE_SPIN_LOCK(prAdapter, SPIN_LOCK_RX_QUE);
+		if (prSwRfb) {
+			if (prSwRfb->pvPacket)
+				kalPacketFree(prAdapter->prGlueInfo, prSwRfb->pvPacket);
+			prSwRfb->pvPacket = NULL;
+			prSwRfb->pucRecvBuff = NULL;
 		} else {
 			break;
 		}
@@ -1177,6 +404,7 @@ VOID nicRxProcessPktWithoutReorder(IN P_ADAPTER_T prAdapter, IN P_SW_RFB_T prSwR
 	BOOLEAN fgIsRetained = FALSE;
 	UINT_32 u4CurrentRxBufferCount;
 	P_STA_RECORD_T prStaRec = (P_STA_RECORD_T) NULL;
+	BOOLEAN fgIsUninitRfb = FALSE;
 
 	DEBUGFUNC("nicRxProcessPktWithoutReorder");
 	/* DBGLOG(RX, TRACE, ("\n")); */
@@ -1243,11 +471,13 @@ VOID nicRxProcessPktWithoutReorder(IN P_ADAPTER_T prAdapter, IN P_SW_RFB_T prSwR
 		prRxCtrl->apvRetainedPacket[prRxCtrl->ucNumRetainedPacket] = prSwRfb->pvPacket;
 		prRxCtrl->ucNumRetainedPacket++;
 		/* TODO : error handling of nicRxSetupRFB */
-		nicRxSetupRFB(prAdapter, prSwRfb);
-		nicRxReturnRFB(prAdapter, prSwRfb);
+		if (nicRxSetupRFB(prAdapter, prSwRfb))
+			fgIsUninitRfb = TRUE;
+		nicRxReturnRFBwithUninit(prAdapter, prSwRfb, fgIsUninitRfb);
 	} else {
 		prSwRfb->pvPacket = NULL;
-		nicRxReturnRFB(prAdapter, prSwRfb);
+		prSwRfb->pucRecvBuff = NULL;
+		nicRxReturnRFBwithUninit(prAdapter, prSwRfb, fgIsUninitRfb);
 	}
 }
 
@@ -1298,6 +528,7 @@ VOID nicRxProcessForwardPkt(IN P_ADAPTER_T prAdapter, IN P_SW_RFB_T prSwRfb)
 
 		/* release RX buffer (to rIndicatedRfbList) */
 		prSwRfb->pvPacket = NULL;
+		prSwRfb->pucRecvBuff = NULL;
 		nicRxReturnRFB(prAdapter, prSwRfb);
 
 		/* increase forward frame counter */
@@ -2451,13 +1682,16 @@ VOID nicRxProcessEventPacket(IN P_ADAPTER_T prAdapter, IN OUT P_SW_RFB_T prSwRfb
 				 (UINT8 *) prEvent->aucBuffer, (UINT32) (prEvent->u2PacketLen - 8));
 		break;
 #endif /* CFG_SUPPORT_STATISTICS */
-
+	case EVENT_ID_CHECK_REORDER_BUBBLE:
+		qmHandleEventCheckReorderBubble(prAdapter, prEvent);
+		break;
 	case EVENT_ID_FW_LOG_ENV:
 		{
 			P_EVENT_FW_LOG_T prEventLog;
 
 			prEventLog = (P_EVENT_FW_LOG_T) (prEvent->aucBuffer);
-			DBGLOG(RX, EVENT, "[F-L]%s\n", prEventLog->log);
+			prEventLog->log[MAX_FW_LOG_LENGTH - 1] = '\0';
+			DBGLOG(RX, INFO, "[F-L]%s\n", prEventLog->log);
 		}
 		break;
 
@@ -3093,6 +2327,7 @@ VOID nicRxSDIOAggReceiveRFBs(IN P_ADAPTER_T prAdapter)
 	fgIsRxEnhanceMode = FALSE;
 #endif
 
+
 	do {
 #if CFG_SDIO_RX_ENHANCE
 		/* to limit maximum loop for RX */
@@ -3287,6 +2522,39 @@ WLAN_STATUS nicRxSetupRFB(IN P_ADAPTER_T prAdapter, IN P_SW_RFB_T prSwRfb)
 	return WLAN_STATUS_SUCCESS;
 
 }				/* end of nicRxSetupRFB() */
+VOID nicRxReturnRFBwithUninit(IN P_ADAPTER_T prAdapter, IN P_SW_RFB_T prSwRfb
+	, IN BOOLEAN fgIsUninitRfb)
+{
+	P_RX_CTRL_T prRxCtrl;
+	P_QUE_ENTRY_T prQueEntry;
+
+	KAL_SPIN_LOCK_DECLARATION();
+
+	ASSERT(prAdapter);
+	ASSERT(prSwRfb);
+	prRxCtrl = &prAdapter->rRxCtrl;
+	prQueEntry = &prSwRfb->rQueEntry;
+
+	ASSERT(prQueEntry);
+
+	if (fgIsUninitRfb) {
+		/*
+		 * The processing on this RFB is uninitiated, so put it back on the tail of
+		 * our list
+		 */
+		DBGLOG(RX, WARN,
+			   "wlanReturnPacket nicRxSetupRFB fail!\n");
+		/* insert initialized SwRfb block */
+		KAL_ACQUIRE_SPIN_LOCK(prAdapter, SPIN_LOCK_RX_QUE);
+		QUEUE_INSERT_TAIL(&prRxCtrl->rUnInitializedRfbList, prQueEntry);
+		KAL_RELEASE_SPIN_LOCK(prAdapter, SPIN_LOCK_RX_QUE);
+	} else {
+		nicRxReturnRFB(prAdapter, prSwRfb);
+	}
+
+
+
+}
 
 /*----------------------------------------------------------------------------*/
 /*!
@@ -3322,6 +2590,7 @@ VOID nicRxReturnRFB(IN P_ADAPTER_T prAdapter, IN P_SW_RFB_T prSwRfb)
 		QUEUE_INSERT_TAIL(&prRxCtrl->rFreeSwRfbList, prQueEntry);
 	} else {
 		/* QUEUE_INSERT_TAIL */
+		prSwRfb->pucRecvBuff = NULL;
 		QUEUE_INSERT_TAIL(&prRxCtrl->rIndicatedRfbList, prQueEntry);
 	}
 

+ 203 - 6
drivers/misc/mediatek/connectivity/wlan/gen2/nic/que_mgt.c

@@ -594,6 +594,11 @@ VOID qmInit(IN P_ADAPTER_T prAdapter)
 		prQM->arRxBaTable[u4QueArrayIdx].u2WinEnd = 0xFFFF;
 
 		prQM->arRxBaTable[u4QueArrayIdx].fgIsWaitingForPktWithSsn = FALSE;
+		prQM->arRxBaTable[u4QueArrayIdx].fgHasBubble = FALSE;
+		cnmTimerInitTimer(prAdapter,
+				&(prQM->arRxBaTable[u4QueArrayIdx].rReorderBubbleTimer),
+				(PFN_MGMT_TIMEOUT_FUNC) qmHandleReorderBubbleTimeout,
+				(ULONG) (&prQM->arRxBaTable[u4QueArrayIdx]));
 
 	}
 	prQM->ucRxBaCount = 0;
@@ -2935,7 +2940,7 @@ VOID qmProcessPktWithReordering(IN P_ADAPTER_T prAdapter, IN P_SW_RFB_T prSwRfb,
 		}
 #endif
 
-		if (qmPopOutDueToFallWithin(prReorderQueParm, prReturnedQue, &fgIsBaTimeout) == FALSE)
+		if (qmPopOutDueToFallWithin(prAdapter, prReorderQueParm, prReturnedQue, &fgIsBaTimeout) == FALSE)
 			STATS_RX_REORDER_HOLE_INC(prStaRec);	/* record hole count */
 		STATS_RX_REORDER_HOLE_TIMEOUT_INC(prStaRec, fgIsBaTimeout);
 	}
@@ -2967,7 +2972,7 @@ VOID qmProcessPktWithReordering(IN P_ADAPTER_T prAdapter, IN P_SW_RFB_T prSwRfb,
 		    (((prReorderQueParm->u2WinEnd) - (prReorderQueParm->u2WinSize) + MAX_SEQ_NO_COUNT + 1)
 		     % MAX_SEQ_NO_COUNT);
 
-		qmPopOutDueToFallAhead(prReorderQueParm, prReturnedQue);
+		qmPopOutDueToFallAhead(prAdapter, prReorderQueParm, prReturnedQue);
 
 		STATS_RX_REORDER_FALL_AHEAD_INC(prStaRec);
 
@@ -3065,7 +3070,7 @@ VOID qmProcessBarFrame(IN P_ADAPTER_T prAdapter, IN P_SW_RFB_T prSwRfb, OUT P_QU
 		DBGLOG(QM, TRACE,
 		       "QM:(BAR)[%d](%u){%d,%d}\n", prSwRfb->ucTid, u4SSN, prReorderQueParm->u2WinStart,
 			prReorderQueParm->u2WinEnd);
-		qmPopOutDueToFallAhead(prReorderQueParm, prReturnedQue);
+		qmPopOutDueToFallAhead(prAdapter, prReorderQueParm, prReturnedQue);
 	} else {
 		DBGLOG(QM, TRACE, "QM:(BAR)(%d)(%u){%u,%u}\n", prSwRfb->ucTid, u4SSN, u4WinStart, u4WinEnd);
 	}
@@ -3162,7 +3167,8 @@ VOID qmInsertFallAheadReorderPkt(IN P_SW_RFB_T prSwRfb, IN P_RX_BA_ENTRY_T prReo
 }
 
 BOOLEAN
-qmPopOutDueToFallWithin(IN P_RX_BA_ENTRY_T prReorderQueParm, OUT P_QUE_T prReturnedQue, OUT BOOLEAN *fgIsTimeout)
+qmPopOutDueToFallWithin(P_ADAPTER_T prAdapter, IN P_RX_BA_ENTRY_T prReorderQueParm,
+				OUT P_QUE_T prReturnedQue, OUT BOOLEAN *fgIsTimeout)
 {
 	P_SW_RFB_T prReorderedSwRfb;
 	P_QUE_T prReorderQue;
@@ -3197,6 +3203,20 @@ qmPopOutDueToFallWithin(IN P_RX_BA_ENTRY_T prReorderQueParm, OUT P_QUE_T prRetur
 		}
 		/* SN > WinStart, break to update WinEnd */
 		else {
+			/* Start bubble timer */
+			if (!prReorderQueParm->fgHasBubble) {
+				cnmTimerStartTimer(prAdapter,
+						   &(prReorderQueParm->rReorderBubbleTimer),
+						   QM_RX_BA_ENTRY_MISS_TIMEOUT_MS);
+				prReorderQueParm->fgHasBubble = TRUE;
+				prReorderQueParm->u2FirstBubbleSn = prReorderQueParm->u2WinStart;
+
+				DBGLOG(QM, TRACE,
+				       "QM:Bub Timer STA[%u] TID[%u] BubSN[%u] Win{%d, %d}\n",
+					prReorderQueParm->ucStaRecIdx, prReorderedSwRfb->ucTid,
+					prReorderQueParm->u2FirstBubbleSn,
+					prReorderQueParm->u2WinStart, prReorderQueParm->u2WinEnd);
+			}
 			if ((fgMissing == TRUE) &&
 			    CHECK_FOR_TIMEOUT(rCurrentTime, (*prMissTimeout),
 					      MSEC_TO_SYSTIME(QM_RX_BA_ENTRY_MISS_TIMEOUT_MS))) {
@@ -3244,7 +3264,7 @@ qmPopOutDueToFallWithin(IN P_RX_BA_ENTRY_T prReorderQueParm, OUT P_QUE_T prRetur
 	return QUEUE_IS_EMPTY(prReorderQue);
 }
 
-VOID qmPopOutDueToFallAhead(IN P_RX_BA_ENTRY_T prReorderQueParm, OUT P_QUE_T prReturnedQue)
+VOID qmPopOutDueToFallAhead(P_ADAPTER_T prAdapter, IN P_RX_BA_ENTRY_T prReorderQueParm, OUT P_QUE_T prReturnedQue)
 {
 	P_SW_RFB_T prReorderedSwRfb;
 	P_QUE_T prReorderQue;
@@ -3274,8 +3294,23 @@ VOID qmPopOutDueToFallAhead(IN P_RX_BA_ENTRY_T prReorderQueParm, OUT P_QUE_T prR
 			fgDequeuHead = TRUE;
 
 		/* SN > WinStart, break to update WinEnd */
-		else
+		else {
+			/* Start bubble timer */
+			if (!prReorderQueParm->fgHasBubble) {
+				cnmTimerStartTimer(prAdapter,
+						   &(prReorderQueParm->rReorderBubbleTimer),
+						   QM_RX_BA_ENTRY_MISS_TIMEOUT_MS);
+				prReorderQueParm->fgHasBubble = TRUE;
+				prReorderQueParm->u2FirstBubbleSn = prReorderQueParm->u2WinStart;
+
+				DBGLOG(QM, TRACE,
+				       "QM:(Bub Timer) STA[%u] TID[%u] BubSN[%u] Win{%d, %d}\n",
+					prReorderQueParm->ucStaRecIdx, prReorderedSwRfb->ucTid,
+					prReorderQueParm->u2FirstBubbleSn,
+					prReorderQueParm->u2WinStart, prReorderQueParm->u2WinEnd);
+			}
 			break;
+		}
 
 		/* Dequeue the head packet */
 		if (fgDequeuHead) {
@@ -3493,6 +3528,7 @@ qmAddRxBaEntry(IN P_ADAPTER_T prAdapter,
 		prRxBaEntry->u2WinEnd = ((u2WinStart + u2WinSize - 1) % MAX_SEQ_NO_COUNT);
 		prRxBaEntry->fgIsValid = TRUE;
 		prRxBaEntry->fgIsWaitingForPktWithSsn = TRUE;
+		prRxBaEntry->fgHasBubble = FALSE;
 
 		g_arMissTimeout[ucStaRecIdx][ucTid] = 0;
 
@@ -3556,6 +3592,13 @@ VOID qmDelRxBaEntry(IN P_ADAPTER_T prAdapter, IN UINT_8 ucStaRecIdx, IN UINT_8 u
 			}
 
 		}
+		if (prRxBaEntry->fgHasBubble) {
+			DBGLOG(QM, TRACE, "QM:(Bub Check Cancel) STA[%u] TID[%u], DELBA\n",
+					   prRxBaEntry->ucStaRecIdx, prRxBaEntry->ucTid);
+
+			cnmTimerStopTimer(prAdapter, &prRxBaEntry->rReorderBubbleTimer);
+			prRxBaEntry->fgHasBubble = FALSE;
+		}
 #if ((QM_TEST_MODE == 0) && (QM_TEST_STA_REC_DEACTIVATION == 0))
 		/* Update RX BA entry state. Note that RX queue flush is not done here */
 		prRxBaEntry->fgIsValid = FALSE;
@@ -5019,3 +5062,157 @@ VOID qmResetArpDetect(VOID)
 }
 #endif
 
+
+VOID qmHandleReorderBubbleTimeout(IN P_ADAPTER_T prAdapter, IN ULONG ulParamPtr)
+{
+	P_RX_BA_ENTRY_T prReorderQueParm = (P_RX_BA_ENTRY_T) ulParamPtr;
+	P_SW_RFB_T prSwRfb = (P_SW_RFB_T) NULL;
+	P_EVENT_CHECK_REORDER_BUBBLE_T prCheckReorderEvent;
+
+	if (!prReorderQueParm->fgIsValid) {
+		DBGLOG(QM, TRACE, "QM:Bub Check Cancel STA[%u] TID[%u], No Rx BA entry\n",
+				   prReorderQueParm->ucStaRecIdx, prReorderQueParm->ucTid);
+		return;
+	}
+
+	if (!prReorderQueParm->fgHasBubble) {
+		DBGLOG(QM, TRACE,
+		       "QM:Bub Check Cancel STA[%u] TID[%u], Bubble has been filled\n",
+			prReorderQueParm->ucStaRecIdx, prReorderQueParm->ucTid);
+		return;
+	}
+
+	DBGLOG(QM, TRACE, "QM:Bub Timeout STA[%u] TID[%u] BubSN[%u]\n",
+			   prReorderQueParm->ucStaRecIdx, prReorderQueParm->ucTid, prReorderQueParm->u2FirstBubbleSn);
+
+	/* Generate a self-inited event to Rx path */
+	QUEUE_REMOVE_HEAD(&prAdapter->rRxCtrl.rFreeSwRfbList, prSwRfb, P_SW_RFB_T);
+
+	if (prSwRfb) {
+		prCheckReorderEvent = (P_EVENT_CHECK_REORDER_BUBBLE_T) prSwRfb->pucRecvBuff;
+
+		prSwRfb->ucPacketType = HIF_RX_PKT_TYPE_EVENT;
+
+		prCheckReorderEvent->ucEID = EVENT_ID_CHECK_REORDER_BUBBLE;
+		prCheckReorderEvent->ucSeqNum = 0;
+
+		prCheckReorderEvent->ucStaRecIdx = prReorderQueParm->ucStaRecIdx;
+		prCheckReorderEvent->ucTid = prReorderQueParm->ucTid;
+		prCheckReorderEvent->u2Length = sizeof(EVENT_CHECK_REORDER_BUBBLE_T);
+
+		QUEUE_INSERT_TAIL(&prAdapter->rRxCtrl.rReceivedRfbList, &prSwRfb->rQueEntry);
+		RX_INC_CNT(&prAdapter->rRxCtrl, RX_MPDU_TOTAL_COUNT);
+
+		DBGLOG(QM, LOUD, "QM:Bub Check Event Sent STA[%u] TID[%u]\n",
+				  prReorderQueParm->ucStaRecIdx, prReorderQueParm->ucTid);
+
+		nicRxProcessRFBs(prAdapter);
+
+		DBGLOG(QM, LOUD, "QM:Bub Check Event Handled STA[%u] TID[%u]\n",
+				  prReorderQueParm->ucStaRecIdx, prReorderQueParm->ucTid);
+	} else {
+		DBGLOG(QM, TRACE,
+		       "QM:Bub Check Cancel STA[%u] TID[%u], Bub check event alloc failed\n",
+			prReorderQueParm->ucStaRecIdx, prReorderQueParm->ucTid);
+
+		cnmTimerStartTimer(prAdapter, &(prReorderQueParm->rReorderBubbleTimer), QM_RX_BA_ENTRY_MISS_TIMEOUT_MS);
+
+		DBGLOG(QM, TRACE, "QM:Bub Timer Restart STA[%u] TID[%u] BubSN[%u] Win{%d, %d}\n",
+				   prReorderQueParm->ucStaRecIdx,
+				   prReorderQueParm->ucTid,
+				   prReorderQueParm->u2FirstBubbleSn,
+				   prReorderQueParm->u2WinStart, prReorderQueParm->u2WinEnd);
+	}
+}
+
+VOID qmHandleEventCheckReorderBubble(IN P_ADAPTER_T prAdapter, IN P_WIFI_EVENT_T prEvent)
+{
+	P_EVENT_CHECK_REORDER_BUBBLE_T prCheckReorderEvent = (P_EVENT_CHECK_REORDER_BUBBLE_T) prEvent;
+	P_RX_BA_ENTRY_T prReorderQueParm;
+	P_QUE_T prReorderQue;
+	QUE_T rReturnedQue;
+	P_QUE_T prReturnedQue = &rReturnedQue;
+	P_SW_RFB_T prReorderedSwRfb, prSwRfb;
+
+	QUEUE_INITIALIZE(prReturnedQue);
+
+	/* Get target Rx BA entry */
+	prReorderQueParm = qmLookupRxBaEntry(prAdapter, prCheckReorderEvent->ucStaRecIdx, prCheckReorderEvent->ucTid);
+
+	/* Sanity Check */
+	if (!prReorderQueParm || !prReorderQueParm->fgIsValid || !prReorderQueParm->fgHasBubble) {
+		DBGLOG(QM, WARN, "QM:Bub Check Cancel STA[%u] TID[%u]. QueParm %p valid %d has bubble %d\n",
+				   prCheckReorderEvent->ucStaRecIdx, prCheckReorderEvent->ucTid, prReorderQueParm,
+				   prReorderQueParm->fgIsValid, prReorderQueParm->fgHasBubble);
+		return;
+	}
+
+	prReorderQue = &(prReorderQueParm->rReOrderQue);
+
+	if (QUEUE_IS_EMPTY(prReorderQue)) {
+		prReorderQueParm->fgHasBubble = FALSE;
+
+		DBGLOG(QM, WARN,
+		       "QM:Bub Check Cancel STA[%u] TID[%u], Bubble has been filled\n",
+			prReorderQueParm->ucStaRecIdx, prReorderQueParm->ucTid);
+
+		return;
+	}
+
+	DBGLOG(QM, TRACE, "QM:Bub Check Event Got STA[%u] TID[%u]\n",
+			   prReorderQueParm->ucStaRecIdx, prReorderQueParm->ucTid);
+
+	/* Expected bubble timeout => pop out packets before win_end */
+	if (prReorderQueParm->u2FirstBubbleSn == prReorderQueParm->u2WinStart) {
+
+		prReorderedSwRfb = (P_SW_RFB_T) QUEUE_GET_TAIL(prReorderQue);
+
+		prReorderQueParm->u2WinStart = prReorderedSwRfb->u2SSN + 1;
+		prReorderQueParm->u2WinEnd =
+		    ((prReorderQueParm->u2WinStart) + (prReorderQueParm->u2WinSize) - 1) % MAX_SEQ_NO_COUNT;
+
+		qmPopOutDueToFallAhead(prAdapter, prReorderQueParm, prReturnedQue);
+
+		DBGLOG(QM, TRACE, "QM:Bub Flush) STA[%u] TID[%u] BubSN[%u] Win{%d, %d}\n",
+				   prReorderQueParm->ucStaRecIdx,
+				   prReorderQueParm->ucTid,
+				   prReorderQueParm->u2FirstBubbleSn,
+				   prReorderQueParm->u2WinStart, prReorderQueParm->u2WinEnd);
+
+		if (QUEUE_IS_NOT_EMPTY(prReturnedQue)) {
+			QM_TX_SET_NEXT_MSDU_INFO((P_SW_RFB_T) QUEUE_GET_TAIL(prReturnedQue), NULL);
+
+			prSwRfb = (P_SW_RFB_T) QUEUE_GET_HEAD(prReturnedQue);
+			while (prSwRfb) {
+				DBGLOG(QM, TRACE,
+				       "QM:Bub Flush STA[%u] TID[%u] Pop Out SN[%u]\n",
+					prReorderQueParm->ucStaRecIdx, prReorderQueParm->ucTid, prSwRfb->u2SSN);
+
+				prSwRfb = (P_SW_RFB_T) QUEUE_GET_NEXT_ENTRY((P_QUE_ENTRY_T) prSwRfb);
+			}
+
+			wlanProcessQueuedSwRfb(prAdapter, (P_SW_RFB_T) QUEUE_GET_HEAD(prReturnedQue));
+		} else {
+			DBGLOG(QM, TRACE, "QM:Bub Flush STA[%u] TID[%u] Pop Out 0 packet\n",
+					   prReorderQueParm->ucStaRecIdx, prReorderQueParm->ucTid);
+		}
+
+		prReorderQueParm->fgHasBubble = FALSE;
+	}
+	/* First bubble has been filled but others exist */
+	else {
+		prReorderQueParm->u2FirstBubbleSn = prReorderQueParm->u2WinStart;
+		cnmTimerStartTimer(prAdapter, &(prReorderQueParm->rReorderBubbleTimer), QM_RX_BA_ENTRY_MISS_TIMEOUT_MS);
+
+		DBGLOG(QM, TRACE, "QM:Bub Timer STA[%u] TID[%u] BubSN[%u] Win{%d, %d}\n",
+				   prReorderQueParm->ucStaRecIdx,
+				   prReorderQueParm->ucTid,
+				   prReorderQueParm->u2FirstBubbleSn,
+				   prReorderQueParm->u2WinStart, prReorderQueParm->u2WinEnd);
+	}
+
+}
+
+
+
+

+ 11 - 6
drivers/misc/mediatek/connectivity/wlan/gen2/os/linux/gl_cfg80211.c

@@ -2900,15 +2900,18 @@ int	mtk_cfg80211_suspend(struct wiphy *wiphy, struct cfg80211_wowlan *wow)
 {
 	P_GLUE_INFO_T prGlueInfo = NULL;
 
-	down(&g_halt_sem);
-	if (g_u4HaltFlag || !wiphy)
+	if (kalHaltTryLock())
+		return 0;
+
+	if (kalIsHalted() || !wiphy)
 		goto end;
 
 	prGlueInfo = (P_GLUE_INFO_T) wiphy_priv(wiphy);
+
 	set_bit(SUSPEND_FLAG_FOR_WAKEUP_REASON, &prGlueInfo->prAdapter->ulSuspendFlag);
 	set_bit(SUSPEND_FLAG_CLEAR_WHEN_RESUME, &prGlueInfo->prAdapter->ulSuspendFlag);
 end:
-	up(&g_halt_sem);
+	kalHaltUnlock();
 	return 0;
 }
 
@@ -2929,8 +2932,10 @@ int mtk_cfg80211_resume(struct wiphy *wiphy)
 	P_ADAPTER_T prAdapter = NULL;
 	UINT_8 i = 0;
 
-	down(&g_halt_sem);
-	if (g_u4HaltFlag || !wiphy)
+	if (kalHaltTryLock())
+		return 0;
+
+	if (kalIsHalted() || !wiphy)
 		goto end;
 
 	prGlueInfo = (P_GLUE_INFO_T) wiphy_priv(wiphy);
@@ -2952,7 +2957,7 @@ int mtk_cfg80211_resume(struct wiphy *wiphy)
 	if (i > 0)
 		kalMemZero(&pprBssDesc[0], i * sizeof(P_BSS_DESC_T));
 end:
-	up(&g_halt_sem);
+	kalHaltUnlock();
 	return 0;
 }
 

+ 26 - 24
drivers/misc/mediatek/connectivity/wlan/gen2/os/linux/gl_init.c

@@ -689,8 +689,6 @@
 
 BOOLEAN fgIsUnderSuspend = false;
 
-struct semaphore g_halt_sem;
-int g_u4HaltFlag = 1;
 
 #if CFG_ENABLE_WIFI_DIRECT
 spinlock_t g_p2p_lock;
@@ -1125,7 +1123,7 @@ static void glLoadNvram(IN P_GLUE_INFO_T prGlueInfo, OUT P_REG_INFO_T prRegInfo)
 	if ((!prGlueInfo) || (!prRegInfo))
 		return;
 
-	if (kalCfgDataRead16(prGlueInfo, sizeof(WIFI_CFG_PARAM_STRUCT) - sizeof(UINT_16), (PUINT_16) aucTmp) == TRUE) {
+	if (kalCfgDataRead16(prGlueInfo, 0, (PUINT_16) aucTmp) == TRUE) {
 		prGlueInfo->fgNvramAvailable = TRUE;
 
 		/* load MAC Address */
@@ -1548,9 +1546,7 @@ static void createWirelessDevice(void)
 		return;
 	}
 
-	/* initialize semaphore for ioctl */
-	sema_init(&g_halt_sem, 1);
-	g_u4HaltFlag = 1;
+
 	/* <1.2> Create wiphy */
 	prWiphy = wiphy_new(&mtk_wlan_ops, sizeof(GLUE_INFO_T));
 	if (!prWiphy) {
@@ -1690,12 +1686,14 @@ static void wlanSetMulticastListWorkQueue(struct work_struct *work)
 
 	fgIsWorkMcStart = TRUE;
 
+
 	DBGLOG(INIT, INFO, "wlanSetMulticastListWorkQueue start...\n");
 
-	down(&g_halt_sem);
-	if (g_u4HaltFlag) {
+	if (kalHaltLock(KAL_HALT_LOCK_TIMEOUT_NORMAL_CASE))
+		return;
+	if (kalIsHalted()) {
 		fgIsWorkMcStart = FALSE;
-		up(&g_halt_sem);
+		kalHaltUnlock();
 		return;
 	}
 
@@ -1705,7 +1703,7 @@ static void wlanSetMulticastListWorkQueue(struct work_struct *work)
 	if (!prDev || !prGlueInfo) {
 		DBGLOG(INIT, WARN, "abnormal dev or skb: prDev(0x%p), prGlueInfo(0x%p)\n", prDev, prGlueInfo);
 		fgIsWorkMcStart = FALSE;
-		up(&g_halt_sem);
+		kalHaltUnlock();
 		return;
 	}
 
@@ -1725,7 +1723,7 @@ static void wlanSetMulticastListWorkQueue(struct work_struct *work)
 		}
 	}
 
-	up(&g_halt_sem);
+	kalHaltUnlock();
 
 	if (kalIoctl(prGlueInfo,
 		     wlanoidSetCurrentPacketFilter,
@@ -1741,10 +1739,12 @@ static void wlanSetMulticastListWorkQueue(struct work_struct *work)
 		PUINT_8 prMCAddrList = NULL;
 		UINT_32 i = 0;
 
-		down(&g_halt_sem);
-		if (g_u4HaltFlag) {
+		if (kalHaltLock(KAL_HALT_LOCK_TIMEOUT_NORMAL_CASE))
+			return;
+		if (kalIsHalted()) {
 			fgIsWorkMcStart = FALSE;
-			up(&g_halt_sem);
+			kalHaltUnlock();
+			/*DBGLOG(INIT, WARN, "wlanSetMulticastListWorkQueue g_u4HaltFlag=%d\n", g_u4HaltFlag);*/
 			return;
 		}
 
@@ -1757,7 +1757,7 @@ static void wlanSetMulticastListWorkQueue(struct work_struct *work)
 			}
 		}
 
-		up(&g_halt_sem);
+		kalHaltUnlock();
 
 		kalIoctl(prGlueInfo,
 			 wlanoidSetMulticastList,
@@ -2586,8 +2586,8 @@ void wlanHandleSystemSuspend(void)
 
 notify_suspend:
 	DBGLOG(INIT, INFO, "IP: %d.%d.%d.%d, rStatus: %u\n", ip[0], ip[1], ip[2], ip[3], rStatus);
-	if (rStatus != WLAN_STATUS_SUCCESS)
-		wlanNotifyFwSuspend(prGlueInfo, TRUE);
+	/* if (rStatus != WLAN_STATUS_SUCCESS) */
+	wlanNotifyFwSuspend(prGlueInfo, TRUE);
 }
 
 void wlanHandleSystemResume(void)
@@ -2698,9 +2698,8 @@ notify_resume:
 	DBGLOG(INIT, INFO, "Query BSS result: %d %d %d, IP: %d.%d.%d.%d, rStatus: %u\n",
 		       rParam.eConnectionState, rParam.eCurrentOPMode, rParam.fgIsNetActive,
 		       ip[0], ip[1], ip[2], ip[3], rStatus);
-	if (rStatus != WLAN_STATUS_SUCCESS) {
-		wlanNotifyFwSuspend(prGlueInfo, FALSE);
-	}
+	/* if (rStatus != WLAN_STATUS_SUCCESS) */
+	wlanNotifyFwSuspend(prGlueInfo, FALSE);
 }
 #endif /* ! CONFIG_X86 */
 
@@ -2997,9 +2996,11 @@ bailout:
 #endif
 		if (FALSE == prAdapter->fgEnable5GBand)
 			prWdev->wiphy->bands[IEEE80211_BAND_5GHZ] = NULL;
+		else
+			prWdev->wiphy->bands[IEEE80211_BAND_5GHZ] = &mtk_band_5ghz;
 
 		prGlueInfo->main_thread = kthread_run(tx_thread, prGlueInfo->prDevHandler, "tx_thread");
-		g_u4HaltFlag = 0;
+		kalSetHalted(FALSE);
 #if CFG_SUPPORT_ROAMING_ENC
 		/* adjust roaming threshold */
 		{
@@ -3216,6 +3217,7 @@ bailout:
 /*----------------------------------------------------------------------------*/
 static VOID wlanRemove(VOID)
 {
+#define KAL_WLAN_REMOVE_TIMEOUT_MSEC			3000
 	struct net_device *prDev = NULL;
 	P_WLANDEV_INFO_T prWlandevInfo = NULL;
 	P_GLUE_INFO_T prGlueInfo = NULL;
@@ -3295,7 +3297,7 @@ static VOID wlanRemove(VOID)
 
 	kalMemSet(&(prGlueInfo->prAdapter->rWlanInfo), 0, sizeof(WLAN_INFO_T));
 
-	g_u4HaltFlag = 1;	/* before flush_delayed_work() */
+	kalSetHalted(TRUE);	/* before flush_delayed_work() */
 	if (fgIsWorkMcStart == TRUE) {
 		DBGLOG(INIT, TRACE, "flush_delayed_work...\n");
 		flush_delayed_work(&workq);	/* flush_delayed_work_sync is deprecated */
@@ -3304,7 +3306,7 @@ static VOID wlanRemove(VOID)
 	flush_delayed_work(&sched_workq);
 
 	DBGLOG(INIT, INFO, "down g_halt_sem...\n");
-	down(&g_halt_sem);
+	kalHaltLock(KAL_WLAN_REMOVE_TIMEOUT_MSEC);
 #if CFG_SPM_WORKAROUND_FOR_HOTSPOT
 	if (glIsChipNeedWakelock(prGlueInfo))
 		KAL_WAKE_LOCK_DESTROY(prGlueInfo->prAdapter, &prGlueInfo->prAdapter->rApWakeLock);
@@ -3371,7 +3373,7 @@ static VOID wlanRemove(VOID)
 	/* 4 <5> Release the Bus */
 	glBusRelease(prDev);
 
-	up(&g_halt_sem);
+	kalHaltUnlock();
 	wlanDebugUninit();
 	/* 4 <6> Unregister the card */
 	wlanNetUnregister(prDev->ieee80211_ptr);

+ 155 - 703
drivers/misc/mediatek/connectivity/wlan/gen2/os/linux/gl_kal.c

@@ -1,691 +1,14 @@
 /*
-** Id: //Department/DaVinci/BRANCHES/MT6620_WIFI_DRIVER_V2_3/os/linux/gl_kal.c#3
+* This program is free software; you can redistribute it and/or modify
+* it under the terms of the GNU General Public License version 2 as
+* published by the Free Software Foundation.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+* See http://www.gnu.org/licenses/gpl-2.0.html for more details.
 */
 
-/*! \file   gl_kal.c
-    \brief  GLUE Layer will export the required procedures here for internal driver stack.
-
-    This file contains all routines which are exported from GLUE Layer to internal
-    driver stack.
-*/
-
-/*
-** Log: gl_kal.c
-**
-** 08 20 2012 yuche.tsai
-** NULL
-** Fix possible KE issue.
- *
- * 07 17 2012 yuche.tsai
- * NULL
- * Let netdev bring up.
- *
- * 07 17 2012 yuche.tsai
- * NULL
- * Compile no error before trial run.
- *
- * 06 13 2012 yuche.tsai
- * NULL
- * Update maintrunk driver.
- * Add support for driver compose assoc request frame.
- *
- * 05 31 2012 terry.wu
- * NULL
- * .
- *
- * 03 26 2012 cp.wu
- * [WCXRP00001187] [MT6620 Wi-Fi][Driver][Android] Add error handling while firmware image doesn't exist
- * invoke put_cred() after get_current_cred() calls.
- *
- * 03 07 2012 yuche.tsai
- * NULL
- * Fix compile error when WiFi Direct is off.
- *
- * 03 02 2012 terry.wu
- * NULL
- * Snc CFG80211 modification for ICS migration from branch 2.2.
- *
- * 02 20 2012 cp.wu
- * [WCXRP00001187] [MT6620 Wi-Fi][Driver][Android] Add error handling while firmware image doesn't exist
- * do not need to invoke free() while firmware image file doesn't exist
- *
- * 01 05 2012 wh.su
- * [WCXRP00001153] [MT6620 Wi-Fi][Driver] Adding the get_ch_list and set_tx_power proto type function
- * Adding the related ioctl / wlan oid function to set the Tx power cfg.
- *
- * 01 02 2012 wh.su
- * [WCXRP00001153] [MT6620 Wi-Fi][Driver] Adding the get_ch_list and set_tx_power proto type function
- * Adding the proto type function for set_int set_tx_power and get int get_ch_list.
- *
- * 11 21 2011 cp.wu
- * [WCXRP00001118] [MT6620 Wi-Fi][Driver] Corner case protections to pass Monkey testing
- * 1. wlanoidQueryBssIdList might be passed with a non-zero length but a NULL pointer of buffer
- * add more checking for such cases
- *
- * 2. kalSendComplete() might be invoked with a packet belongs to P2P network right after P2P is unregistered.
- * add some tweaking to protect such cases because that net device has become invalid.
- *
- * 11 18 2011 yuche.tsai
- * NULL
- * CONFIG P2P support RSSI query, default turned off.
- *
- * 11 16 2011 yuche.tsai
- * NULL
- * Avoid using work thread.
- *
- * 11 10 2011 cp.wu
- * [WCXRP00001098] [MT6620 Wi-Fi][Driver] Replace printk by DBG LOG macros in linux porting layer
- * 1. eliminaite direct calls to printk in porting layer.
- * 2. replaced by DBGLOG, which would be XLOG on ALPS platforms.
- *
- * 10 12 2011 wh.su
- * [WCXRP00001036] [MT6620 Wi-Fi][Driver][FW] Adding the 802.11w code for MFP
- * adding the 802.11w related function and define .
- *
- * 09 23 2011 yuche.tsai
- * [WCXRP00000998] [Volunteer Patch][WiFi Direct][FW] P2P Social Channel & country domain issue
- * Regulation domain feature check in.
- *
- * 08 12 2011 cp.wu
- * [WCXRP00000913] [MT6620 Wi-Fi] create repository of source code dedicated for MT6620 E6 ASIC
- * load WIFI_RAM_CODE_E6 for MT6620 E6 ASIC.
- *
- * 07 18 2011 chinghwa.yu
- * [WCXRP00000063] Update BCM CoEx design and settings[WCXRP00000612] [MT6620 Wi-Fi] [FW] CSD update SWRDD algorithm
- * Add CMD/Event for RDD and BWCS.
- *
- * 06 13 2011 eddie.chen
- * [WCXRP00000779] [MT6620 Wi-Fi][DRV]  Add tx rx statistics in linux and use netif_rx_ni
- * Add tx rx statistics and netif_rx_ni.
- *
- * 04 15 2011 chinghwa.yu
- * [WCXRP00000065] Update BoW design and settings
- * Add BOW short range mode.
- *
- * 04 12 2011 cp.wu
- * [WCXRP00000635] [MT6620 Wi-Fi][Driver] Clear pending security frames when QM clear pending data frames for dedicated
- * network type
- * clear pending security frames for dedicated network type when BSS is being deactivated/disconnected
- *
- * 04 08 2011 cp.wu
- * [WCXRP00000540] [MT5931][Driver] Add eHPI8/eHPI16 support to Linux Glue Layer
- * correct i4TxPendingFrameNum decreasing.
- *
- * 03 23 2011 cp.wu
- * [WCXRP00000540] [MT5931][Driver] Add eHPI8/eHPI16 support to Linux Glue Layer
- * apply multi-queue operation only for linux kernel > 2.6.26
- *
- * 03 21 2011 cp.wu
- * [WCXRP00000540] [MT5931][Driver] Add eHPI8/eHPI16 support to Linux Glue Layer
- * portability for compatible with linux 2.6.12.
- *
- * 03 21 2011 cp.wu
- * [WCXRP00000540] [MT5931][Driver] Add eHPI8/eHPI16 support to Linux Glue Layer
- * improve portability for awareness of early version of linux kernel and wireless extension.
- *
- * 03 18 2011 cp.wu
- * [WCXRP00000562] [MT6620 Wi-Fi][Driver] I/O buffer pre-allocation to avoid physically continuous memory shortage
- * after system running for a long period
- * refix ...
- *
- * 03 18 2011 cp.wu
- * [WCXRP00000562] [MT6620 Wi-Fi][Driver] I/O buffer pre-allocation to avoid physically continuous memory shortage
- * after system running for a long period
- * correct compiling warning/error.
- *
- * 03 18 2011 cp.wu
- * [WCXRP00000562] [MT6620 Wi-Fi][Driver] I/O buffer pre-allocation to avoid physically continuous memory shortage
- * after system running for a long period
- * add more robust fault tolerance design when pre-allocation failed. (rarely happen)
- *
- * 03 17 2011 cp.wu
- * [WCXRP00000562] [MT6620 Wi-Fi][Driver] I/O buffer pre-allocation to avoid physically continuous memory shortage
- * after system running for a long period
- * use pre-allocated buffer for storing enhanced interrupt response as well
- *
- * 03 16 2011 cp.wu
- * [WCXRP00000562] [MT6620 Wi-Fi][Driver] I/O buffer pre-allocation to avoid physically continuous memory shortage
- * after system running for a long period
- * 1. pre-allocate physical continuous buffer while module is being loaded
- * 2. use pre-allocated physical continuous buffer for TX/RX DMA transfer
- *
- * The windows part remained the same as before, but added similar APIs to hide the difference.
- *
- * 03 15 2011 cp.wu
- * [WCXRP00000559] [MT6620 Wi-Fi][Driver] Combine TX/RX DMA buffers into a single one to reduce physically continuous
- * memory consumption
- * 1. deprecate CFG_HANDLE_IST_IN_SDIO_CALLBACK
- * 2. Use common coalescing buffer for both TX/RX directions
- *
- *
- * 03 14 2011 jeffrey.chang
- * [WCXRP00000546] [MT6620 Wi-Fi][MT6620 Wi-Fi][Driver] fix kernel build warning message
- * fix kernel build warning message
- *
- * 03 07 2011 terry.wu
- * [WCXRP00000521] [MT6620 Wi-Fi][Driver] Remove non-standard debug message
- * Toggle non-standard debug messages to comments.
- *
- * 03 06 2011 chinghwa.yu
- * [WCXRP00000065] Update BoW design and settings
- * Sync BOW Driver to latest person development branch version..
- *
- * 03 03 2011 jeffrey.chang
- * [WCXRP00000512] [MT6620 Wi-Fi][Driver] modify the net device relative functions to support the H/W multiple queue
- * support concurrent network
- *
- * 03 03 2011 jeffrey.chang
- * [WCXRP00000512] [MT6620 Wi-Fi][Driver] modify the net device relative functions to support the H/W multiple queue
- * modify net device relative functions to support multiple H/W queues
- *
- * 03 02 2011 cp.wu
- * [WCXRP00000503] [MT6620 Wi-Fi][Driver] Take RCPI brought by association response as initial RSSI right after
- * connection is built.
- * use RCPI brought by ASSOC-RESP after connection is built as initial RCPI to avoid using a uninitialized MAC-RX RCPI.
- *
- * 02 21 2011 cp.wu
- * [WCXRP00000482] [MT6620 Wi-Fi][Driver] Simplify logic for checking NVRAM existence in driver domain
- * simplify logic for checking NVRAM existence only once.
- *
- * 01 24 2011 cp.wu
- * [WCXRP00000382] [MT6620 Wi-Fi][Driver] Track forwarding packet number with notifying tx thread for serving
- * 1. add an extra counter for tracking pending forward frames.
- * 2. notify TX service thread as well when there is pending forward frame
- * 3. correct build errors leaded by introduction of Wi-Fi direct separation module
- *
- * 01 19 2011 cp.wu
- * [WCXRP00000371] [MT6620 Wi-Fi][Driver] make linux glue layer portable for Android 2.3.1 with Linux 2.6.35.7
- * add compile option to check linux version 2.6.35 for different usage of system API to improve portability
- *
- * 01 12 2011 cp.wu
- * [WCXRP00000357] [MT6620 Wi-Fi][Driver][Bluetooth over Wi-Fi] add another net device interface for BT AMP
- * implementation of separate BT_OVER_WIFI data path.
- *
- * 01 10 2011 cp.wu
- * [WCXRP00000349] [MT6620 Wi-Fi][Driver] make kalIoctl() of linux port as a thread safe API to avoid potential issues
- * due to multiple access
- * use mutex to protect kalIoctl() for thread safe.
- *
- * 11 26 2010 cp.wu
- * [WCXRP00000209] [MT6620 Wi-Fi][Driver] Modify NVRAM checking mechanism to warning only with necessary data field
- * checking
- * 1. NVRAM error is now treated as warning only, thus normal operation is still available but extra scan result used
- * to indicate user is attached
- * 2. DPD and TX-PWR are needed fields from now on, if these 2 fields are not available then warning message is shown
- *
- * 11 04 2010 wh.su
- * [WCXRP00000164] [MT6620 Wi-Fi][Driver] Support the p2p random SSID
- * adding the p2p random ssid support.
- *
- * 11 02 2010 jeffrey.chang
- * [WCXRP00000145] [MT6620 Wi-Fi][Driver] fix issue of byte endian in packet classifier which discards BoW packets
- * .
- *
- * 11 01 2010 cp.wu
- * [WCXRP00000056] [MT6620 Wi-Fi][Driver] NVRAM implementation with Version Check[WCXRP00000150] [MT6620 Wi-Fi][Driver]
- * Add implementation for querying current TX rate from firmware auto rate module
- * 1) Query link speed (TX rate) from firmware directly with buffering mechanism to reduce overhead
- * 2) Remove CNM CH-RECOVER event handling
- * 3) cfg read/write API renamed with kal prefix for unified naming rules.
- *
- * 11 01 2010 yarco.yang
- * [WCXRP00000149] [MT6620 WI-Fi][Driver]Fine tune performance on MT6516 platform
- * Add code to run WlanIST in SDIO callback.
- *
- * 10 26 2010 cp.wu
- * [WCXRP00000056] [MT6620 Wi-Fi][Driver] NVRAM implementation with Version Check[WCXRP00000137] [MT6620 Wi-Fi] [FW]
- * Support NIC capability query command
- * 1) update NVRAM content template to ver 1.02
- * 2) add compile option for querying NIC capability (default: off)
- * 3) modify AIS 5GHz support to run-time option, which could be turned on by registry or NVRAM setting
- * 4) correct auto-rate compiler error under linux (treat warning as error)
- * 5) simplify usage of NVRAM and REG_INFO_T
- * 6) add version checking between driver and firmware
- *
- * 10 25 2010 jeffrey.chang
- * [WCXRP00000129] [MT6620] [Driver] Kernel panic when rmmod module on Andriod platform
- * Remove redundant code which cause mismatch of power control release
- *
- * 10 25 2010 jeffrey.chang
- * [WCXRP00000129] [MT6620] [Driver] Kernel panic when rmmod module on Andriod platform
- * Remove redundant GLUE_HALT condfition to avoid unmatched release of power control
- *
- * 10 18 2010 jeffrey.chang
- * [WCXRP00000116] [MT6620 Wi-Fi][Driver] Refine the set_scan ioctl to resolve the Android UI hanging issue
- * refine the scan ioctl to prevent hanging of Android UI
- *
- * 10 18 2010 cp.wu
- * [WCXRP00000056] [MT6620 Wi-Fi][Driver] NVRAM implementation with Version Check[WCXRP00000086] [MT6620 Wi-Fi][Driver]
- * The mac address is all zero at android
- * complete implementation of Android NVRAM access
- *
- * 10 06 2010 cp.wu
- * [WCXRP00000056] [MT6620 Wi-Fi][Driver] NVRAM implementation with Version Check
- * if there is NVRAM, then use MAC address on NVRAM as default MAC address.
- *
- * 10 06 2010 cp.wu
- * [WCXRP00000052] [MT6620 Wi-Fi][Driver] Eliminate Linux Compile Warning
- * code reorganization to improve isolation between GLUE and CORE layers.
- *
- * 10 05 2010 cp.wu
- * [WCXRP00000056] [MT6620 Wi-Fi][Driver] NVRAM implementation with Version Check
- * 1) add NVRAM access API
- * 2) fake scanning result when NVRAM doesn't exist and/or version mismatch. (off by compiler option)
- * 3) add OID implementation for NVRAM read/write service
- *
- * 09 21 2010 cp.wu
- * [WCXRP00000053] [MT6620 Wi-Fi][Driver] Reset incomplete and might leads to BSOD when entering RF test with AIS
- * associated
- * Do a complete reset with STA-REC null checking for RF test re-entry
- *
- * 09 21 2010 kevin.huang
- * [WCXRP00000052] [MT6620 Wi-Fi][Driver] Eliminate Linux Compile Warning
- * Eliminate Linux Compile Warning
- *
- * 09 07 2010 wh.su
- * NULL
- * adding the code for beacon/probe req/ probe rsp wsc ie at p2p.
- *
- * 09 03 2010 kevin.huang
- * NULL
- * Refine #include sequence and solve recursive/nested #include issue
- *
- * 08 30 2010 cp.wu
- * NULL
- * API added: nicTxPendingPackets(), for simplifying porting layer
- *
- * 08 20 2010 yuche.tsai
- * NULL
- * Support second interface indicate when enabling P2P.
- *
- * 08 18 2010 yarco.yang
- * NULL
- * 1. Fixed HW checksum offload function not work under Linux issue.
- * 2. Add debug message.
- *
- * 08 16 2010 jeffrey.chang
- * NULL
- * remove redundant code which cause kernel panic
- *
- * 08 16 2010 cp.wu
- * NULL
- * P2P packets are now marked when being queued into driver, and identified later without checking MAC address
- *
- * 08 02 2010 jeffrey.chang
- * NULL
- * 1) modify tx service thread to avoid busy looping
- * 2) add spin lock declartion for linux build
- *
- * 07 29 2010 cp.wu
- * NULL
- * simplify post-handling after TX_DONE interrupt is handled.
- *
- * 07 28 2010 jeffrey.chang
- * NULL
- * 1) remove unused spinlocks
- * 2) enable encyption ioctls
- * 3) fix scan ioctl which may cause supplicant to hang
- *
- * 07 23 2010 cp.wu
- *
- * 1) re-enable AIS-FSM beacon timeout handling.
- * 2) scan done API revised
- *
- * 07 23 2010 jeffrey.chang
- *
- * add new KAL api
- *
- * 07 23 2010 jeffrey.chang
- *
- * bug fix: allocate regInfo when disabling firmware download
- *
- * 07 23 2010 jeffrey.chang
- *
- * use glue layer api to decrease or increase counter atomically
- *
- * 07 22 2010 jeffrey.chang
- *
- * modify tx thread and remove some spinlock
- *
- * 07 22 2010 jeffrey.chang
- *
- * use different spin lock for security frame
- *
- * 07 22 2010 jeffrey.chang
- *
- * add new spinlock
- *
- * 07 19 2010 jeffrey.chang
- *
- * add spinlock for pending security frame count
- *
- * 07 19 2010 jeffrey.chang
- *
- * adjust the timer unit to microsecond
- *
- * 07 19 2010 jeffrey.chang
- *
- * timer should return value greater than zero
- *
- * 07 19 2010 jeffrey.chang
- *
- * add kal api for scanning done
- *
- * 07 19 2010 jeffrey.chang
- *
- * modify cmd/data path for new design
- *
- * 07 19 2010 jeffrey.chang
- *
- * add new kal api
- *
- * 07 19 2010 jeffrey.chang
- *
- * for linux driver migration
- *
- * 07 19 2010 jeffrey.chang
- *
- * Linux port modification
- *
- * 07 08 2010 cp.wu
- *
- * [WPD00003833] [MT6620 and MT5931] Driver migration - move to new repository.
- *
- * 06 23 2010 yarco.yang
- * [WPD00003837][MT6620]Data Path Refine
- * Merge g_arStaRec[] into adapter->arStaRec[]
- *
- * 06 21 2010 cp.wu
- * [WPD00003833][MT6620 and MT5931] Driver migration
- * change MAC address updating logic.
- *
- * 06 06 2010 kevin.huang
- * [WPD00003832][MT6620 5931] Create driver base
- * [MT6620 5931] Create driver base
- *
- * 06 01 2010 cp.wu
- * [WPD00001943]Create WiFi test driver framework on WinXP
- * remove unused files.
- *
- * 05 29 2010 jeffrey.chang
- * [WPD00003826]Initial import for Linux port
- * fix private ioctl for rftest
- *
- * 05 29 2010 jeffrey.chang
- * [WPD00003826]Initial import for Linux port
- * workaround for fixing request_firmware() failure on android 2.1
- *
- * 05 28 2010 jeffrey.chang
- * [WPD00003826]Initial import for Linux port
- * fix kernel panic when debug mode enabled
- *
- * 05 26 2010 jeffrey.chang
- * [WPD00003826]Initial import for Linux port
- * 1) Modify set mac address code
- * 2) remove power management macro
- *
- * 05 17 2010 cp.wu
- * [WPD00003831][MT6620 Wi-Fi] Add framework for Wi-Fi Direct support
- * 1) add timeout handler mechanism for pending command packets
- * 2) add p2p add/removal key
- *
- * 05 14 2010 jeffrey.chang
- * [WPD00003826]Initial import for Linux port
- * Disable network interface after disassociation
- *
- * 05 10 2010 cp.wu
- * [WPD00003831][MT6620 Wi-Fi] Add framework for Wi-Fi Direct support
- * fill network type field while doing frame identification.
- *
- * 05 07 2010 jeffrey.chang
- * [WPD00003826]Initial import for Linux port
- * prevent supplicant accessing driver during resume
- *
- * 04 27 2010 cp.wu
- * [WPD00003823][MT6620 Wi-Fi] Add Bluetooth-over-Wi-Fi support
- * identify BT Over Wi-Fi Security frame and mark it as 802.1X frame
- *
- * 04 27 2010 jeffrey.chang
- * [WPD00003826]Initial import for Linux port
- * 1) fix firmware download bug
- * 2) remove query statistics for acelerating firmware download
- *
- * 04 27 2010 jeffrey.chang
- * [WPD00003826]Initial import for Linux port
- * follow Linux's firmware framework, and remove unused kal API
- *
- * 04 22 2010 jeffrey.chang
- * [WPD00003826]Initial import for Linux port
- *
- * 1) modify rx path code for supporting Wi-Fi direct
- * 2) modify config.h since Linux dont need to consider retaining packet
- *
- * 04 21 2010 jeffrey.chang
- * [WPD00003826]Initial import for Linux port
- * add for private ioctl support
- *
- * 04 15 2010 jeffrey.chang
- * [WPD00003826]Initial import for Linux port
- * change firmware name
- *
- * 04 14 2010 jeffrey.chang
- * [WPD00003826]Initial import for Linux port
- * flush pending TX packets while unloading driver
- *
- * 04 14 2010 jeffrey.chang
- * [WPD00003826]Initial import for Linux port
- * Set driver own before handling cmd queue
- *
- * 04 14 2010 jeffrey.chang
- * [WPD00003826]Initial import for Linux port
- * 1) prGlueInfo->pvInformationBuffer and prGlueInfo->u4InformationBufferLength are no longer used
- * 2) fix ioctl
- *
- * 04 14 2010 cp.wu
- * [WPD00001943]Create WiFi test driver framework on WinXP
- * information buffer for query oid/ioctl is now buffered in prCmdInfo
- *  *  *  *  *  *  * instead of glue-layer variable to improve multiple oid/ioctl capability
- *
- * 04 13 2010 cp.wu
- * [WPD00003823][MT6620 Wi-Fi] Add Bluetooth-over-Wi-Fi support
- * add framework for BT-over-Wi-Fi support.
- *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  * 1) prPendingCmdInfo is replaced by queue for multiple handler
- *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *    capability
- *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  * 2) command sequence number is now increased atomically
- *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  * 3) private data could be hold and taken use for other purpose
- *
- * 04 09 2010 jeffrey.chang
- * [WPD00003826]Initial import for Linux port
- * fix spinlock usage
- *
- * 04 09 2010 jeffrey.chang
- * [WPD00003826]Initial import for Linux port
- * add spinlock for i4TxPendingFrameNum access
- *
- * 04 09 2010 jeffrey.chang
- * [WPD00003826]Initial import for Linux port
- * 1) add spinlock
- *  * 2) add KAPI for handling association info
- *
- * 04 09 2010 jeffrey.chang
- * [WPD00003826]Initial import for Linux port
- * fix spinlock usage
- *
- * 04 09 2010 jeffrey.chang
- * [WPD00003826]Initial import for Linux port
- * adding firmware download KAPI
- *
- * 04 07 2010 jeffrey.chang
- * [WPD00003826]Initial import for Linux port
- * Set MAC address from firmware
- *
- * 04 07 2010 cp.wu
- * [WPD00001943]Create WiFi test driver framework on WinXP
- * 1. free cmdinfo after command is emiited.
- * 2. for BoW frames, user priority is extracted from sk_buff directly.
- *
- * 04 07 2010 cp.wu
- * [WPD00001943]Create WiFi test driver framework on WinXP
- * finish non-glue layer access to glue variables
- *
- * 04 07 2010 cp.wu
- * [WPD00001943]Create WiFi test driver framework on WinXP
- * accessing to firmware load/start address, and access to OID handling information
- *  *  * are now handled in glue layer
- *
- * 04 07 2010 cp.wu
- * [WPD00001943]Create WiFi test driver framework on WinXP
- * rWlanInfo should be placed at adapter rather than glue due to most operations
- *  *  *  *  *  *  * are done in adapter layer.
- *
- * 04 07 2010 cp.wu
- * [WPD00001943]Create WiFi test driver framework on WinXP
- * eliminate direct access to prGlueInfo->eParamMediaStateIndicated from non-glue layer
- *
- * 04 06 2010 jeffrey.chang
- * [WPD00003826]Initial import for Linux port
- * (1)deliver the kalOidComplete status to upper layer
- * (2) fix spin lock
- *
- * 04 06 2010 cp.wu
- * [WPD00001943]Create WiFi test driver framework on WinXP
- * add KAL API: kalFlushPendingTxPackets(), and take use of the API
- *
- * 04 06 2010 cp.wu
- * [WPD00001943]Create WiFi test driver framework on WinXP
- * eliminate direct access to prGlueInfo->rWlanInfo.eLinkAttr.ucMediaStreamMode from non-glue layer.
- *
- * 04 06 2010 jeffrey.chang
- * [WPD00003826]Initial import for Linux port
- * add timeout check in the kalOidComplete
- *
- * 04 06 2010 jeffrey.chang
- * [WPD00003826]Initial import for Linux port
- * improve none-glue code portability
- *
- * 04 06 2010 cp.wu
- * [WPD00001943]Create WiFi test driver framework on WinXP
- * code refine: fgTestMode should be at adapter rather than glue due to the device/fw is also involved
- *
- * 04 06 2010 cp.wu
- * [WPD00001943]Create WiFi test driver framework on WinXP
- * eliminate direct access for prGlueInfo->fgIsCardRemoved in non-glue layer
- *
- * 04 06 2010 cp.wu
- * [WPD00001943]Create WiFi test driver framework on WinXP
- * 1) for some OID, never do timeout expiration
- *  *  * 2) add 2 kal API for later integration
- *
- * 04 06 2010 jeffrey.chang
- * [WPD00003826]Initial import for Linux port
- * raising the priority of processing interrupt
- *
- * 04 01 2010 jeffrey.chang
- * [WPD00003826]Initial import for Linux port
- * Bug fix: the tx thread will cause starvation of MMC thread, and the interrupt will never come in
- *
- * 03 30 2010 jeffrey.chang
- * [WPD00003826]Initial import for Linux port
- * emulate NDIS Pending OID facility
- *
- * 03 28 2010 jeffrey.chang
- * [WPD00003826]Initial import for Linux port
- * adding secondary command queue for improving non-glue code portability
- *
- * 03 26 2010 jeffrey.chang
- * [WPD00003826]Initial import for Linux port
- * [WPD00003826] Initial import for Linux port
- * adding firmware download kal api
- *
- * 03 25 2010 cp.wu
- * [WPD00003823][MT6620 Wi-Fi] Add Bluetooth-over-Wi-Fi support
- * add Bluetooth-over-Wifi frame header check
- *
- * 03 24 2010 jeffrey.chang
- * [WPD00003826]Initial import for Linux port
- * initial import for Linux port
-**  \main\maintrunk.MT5921\50 2009-09-28 20:19:08 GMT mtk01090
-**  Add private ioctl to carry OID structures. Restructure public/private ioctl interfaces to Linux kernel.
-**  \main\maintrunk.MT5921\49 2009-08-18 22:56:44 GMT mtk01090
-**  Add Linux SDIO (with mmc core) support.
-**  Add Linux 2.6.21, 2.6.25, 2.6.26.
-**  Fix compile warning in Linux.
-**  \main\maintrunk.MT5921\48 2009-06-23 23:18:58 GMT mtk01090
-**  Add build option BUILD_USE_EEPROM and compile option CFG_SUPPORT_EXT_CONFIG for NVRAM support
-**  \main\maintrunk.MT5921\47 2008-11-19 11:55:43 GMT mtk01088
-**  fixed some lint warning, and rename some variable with pre-fix to avoid the misunderstanding
-**  \main\maintrunk.MT5921\46 2008-09-02 21:07:42 GMT mtk01461
-**  Remove ASSERT(pvBuf) in kalIndicateStatusAndComplete(), this parameter can be NULL
-**  \main\maintrunk.MT5921\45 2008-08-29 16:03:21 GMT mtk01088
-**  remove non-used code for code review, add assert check
-**  \main\maintrunk.MT5921\44 2008-08-21 00:32:49 GMT mtk01461
-**  \main\maintrunk.MT5921\43 2008-05-30 20:27:02 GMT mtk01461
-**  Rename KAL function
-**  \main\maintrunk.MT5921\42 2008-05-30 15:47:29 GMT mtk01461
-**  \main\maintrunk.MT5921\41 2008-05-30 15:13:04 GMT mtk01084
-**  rename wlanoid
-**  \main\maintrunk.MT5921\40 2008-05-29 14:15:14 GMT mtk01084
-**  remove un-used KAL function
-**  \main\maintrunk.MT5921\39 2008-05-03 15:17:30 GMT mtk01461
-**  Move Query Media Status to GLUE
-**  \main\maintrunk.MT5921\38 2008-04-24 11:59:44 GMT mtk01461
-**  change awake queue threshold and remove code which mark #if 0
-**  \main\maintrunk.MT5921\37 2008-04-17 23:06:35 GMT mtk01461
-**  Add iwpriv support for AdHocMode setting
-**  \main\maintrunk.MT5921\36 2008-04-08 15:38:56 GMT mtk01084
-**  add KAL function to setting pattern search function enable/ disable
-**  \main\maintrunk.MT5921\35 2008-04-01 23:53:13 GMT mtk01461
-**  Add comment
-**  \main\maintrunk.MT5921\34 2008-03-26 15:36:48 GMT mtk01461
-**  Add update MAC Address for Linux
-**  \main\maintrunk.MT5921\33 2008-03-18 11:49:34 GMT mtk01084
-**  update function for initial value access
-**  \main\maintrunk.MT5921\32 2008-03-18 10:25:22 GMT mtk01088
-**  use kal update associate request at linux
-**  \main\maintrunk.MT5921\31 2008-03-06 23:43:08 GMT mtk01385
-**   1. add Query Registry Mac address function.
-**  \main\maintrunk.MT5921\30 2008-02-26 09:47:57 GMT mtk01084
-**  modify KAL set network address/ checksum offload part
-**  \main\maintrunk.MT5921\29 2008-02-12 23:26:53 GMT mtk01461
-**  Add debug option - Packet Order for Linux
-**  \main\maintrunk.MT5921\28 2008-01-09 17:54:43 GMT mtk01084
-**  modify the argument of kalQueryPacketInfo()
-**  \main\maintrunk.MT5921\27 2007-12-24 16:02:03 GMT mtk01425
-**  1. Revise csum offload
-**  \main\maintrunk.MT5921\26 2007-11-30 17:03:36 GMT mtk01425
-**  1. Fix bugs
-**
-**  \main\maintrunk.MT5921\25 2007-11-29 01:57:17 GMT mtk01461
-**  Fix Windows RX multiple packet retain problem
-**  \main\maintrunk.MT5921\24 2007-11-20 11:24:07 GMT mtk01088
-**  <workaround> CR90, not doing the netif_carrier_off to let supplicant 1x pkt can be rcv at hardstattXmit
-**  \main\maintrunk.MT5921\23 2007-11-09 16:36:44 GMT mtk01425
-**  1. Modify for CSUM offloading with Tx Fragment
-**  \main\maintrunk.MT5921\22 2007-11-07 18:37:39 GMT mtk01461
-**  Add Tx Fragmentation Support
-**  \main\maintrunk.MT5921\21 2007-11-06 19:34:06 GMT mtk01088
-**  add the WPS code, indicate the mgmt frame to upper layer
-**  \main\maintrunk.MT5921\20 2007-11-02 01:03:21 GMT mtk01461
-**  Unify TX Path for Normal and IBSS Power Save + IBSS neighbor learning
-**  \main\maintrunk.MT5921\19 2007-10-30 11:59:38 GMT MTK01425
-**  1. Update wlanQueryInformation
-**  \main\maintrunk.MT5921\18 2007-10-30 10:44:57 GMT mtk01425
-**  1. Refine multicast list code
-**  2. Refine TCP/IP csum offload code
-**
-** Revision 1.5  2007/07/17 13:01:18  MTK01088
-** add associate req and rsp function
-**
-** Revision 1.4  2007/07/13 05:19:19  MTK01084
-** provide timer set functions
-**
-** Revision 1.3  2007/06/27 02:18:51  MTK01461
-** Update SCAN_FSM, Initial(Can Load Module), Proc(Can do Reg R/W), TX API
-**
-** Revision 1.2  2007/06/25 06:16:24  MTK01461
-** Update illustrations, gl_init.c, gl_kal.c, gl_kal.h, gl_os.h and RX API
-**
-*/
 
 /*******************************************************************************
 *                         C O M P I L E R   F L A G S
@@ -747,6 +70,15 @@ static UINT_32 pvIoBufferUsage;
 static struct notifier_block wlan_fb_notifier;
 void *wlan_fb_notifier_priv_data = NULL;
 BOOLEAN wlan_fb_power_down = FALSE;
+
+static struct KAL_HALT_CTRL_T rHaltCtrl = {
+	.lock = __SEMAPHORE_INITIALIZER(rHaltCtrl.lock, 1),
+	.owner = NULL,
+	.fgHalt = TRUE,
+	.fgHeldByKalIoctl = FALSE,
+	.u4HoldStart = 0,
+};
+
 /*******************************************************************************
 *                                 M A C R O S
 ********************************************************************************
@@ -1306,6 +638,8 @@ PVOID kalPacketAlloc(IN P_GLUE_INFO_T prGlueInfo, IN UINT_32 u4Size, OUT PUINT_8
 
 	if (prSkb)
 		*ppucData = (PUINT_8) (prSkb->data);
+	else
+		DBGLOG(RX, WARN, "kalPacketAlloc fail!!\n");
 #if DBG
 	{
 		PUINT_32 pu4Head = (PUINT_32) &prSkb->cb[0];
@@ -1650,6 +984,7 @@ kalIndicateStatusAndComplete(IN P_GLUE_INFO_T prGlueInfo, IN WLAN_STATUS eStatus
 	struct cfg80211_bss *bss;
 	UINT_8 ucChannelNum;
 	P_BSS_DESC_T prBssDesc = NULL;
+	UINT_16 u2StatusCode = WLAN_STATUS_AUTH_TIMEOUT;
 
 	GLUE_SPIN_LOCK_DECLARATION();
 
@@ -1698,6 +1033,9 @@ kalIndicateStatusAndComplete(IN P_GLUE_INFO_T prGlueInfo, IN WLAN_STATUS eStatus
 											 IEEE80211_BAND_5GHZ));
 			}
 
+			if (!prChannel)
+				DBGLOG(SCN, ERROR, "prChannel is NULL and ucChannelNum is %d\n", ucChannelNum);
+
 			/* ensure BSS exists */
 			bss = cfg80211_get_bss(priv_to_wiphy(prGlueInfo), prChannel, arBssid,
 					       ssid.aucSsid, ssid.u4SsidLen, WLAN_CAPABILITY_ESS, WLAN_CAPABILITY_ESS);
@@ -1773,7 +1111,8 @@ kalIndicateStatusAndComplete(IN P_GLUE_INFO_T prGlueInfo, IN WLAN_STATUS eStatus
 			P_WIFI_VAR_T prWifiVar = &prGlueInfo->prAdapter->rWifiVar;
 			UINT_16 u2DeauthReason = prWifiVar->arBssInfo[NETWORK_TYPE_AIS_INDEX].u2DeauthReason;
 			/* CFG80211 Indication */
-			DBGLOG(AIS, INFO, "[wifi] %s cfg80211_disconnected\n", prGlueInfo->prDevHandler->name);
+			DBGLOG(AIS, INFO, "[wifi] %s cfg80211_disconnected: Reason=%d\n",
+				prGlueInfo->prDevHandler->name, u2DeauthReason);
 			cfg80211_disconnected(prGlueInfo->prDevHandler, u2DeauthReason, NULL, 0,
 			eStatus == WLAN_STATUS_MEDIA_DISCONNECT_LOCALLY, GFP_KERNEL);
 		}
@@ -1800,15 +1139,28 @@ kalIndicateStatusAndComplete(IN P_GLUE_INFO_T prGlueInfo, IN WLAN_STATUS eStatus
 		if (prScanRequest != NULL)
 			cfg80211_scan_done(prScanRequest, FALSE);
 		break;
-	case WLAN_STATUS_CONNECT_INDICATION:
+
+	case WLAN_STATUS_JOIN_FAILURE:
+		if (pvBuf)
+			u2StatusCode = *(UINT_16 *)pvBuf;
+
+		prBssDesc = prGlueInfo->prAdapter->rWifiVar.rAisFsmInfo.prTargetBssDesc;
+
+		DBGLOG(INIT, INFO, "JOIN Failure: u2StatusCode=%d", u2StatusCode);
+		if (prBssDesc)
+			COPY_MAC_ADDR(arBssid, prBssDesc->aucBSSID);
+		else
+			COPY_MAC_ADDR(arBssid, prGlueInfo->prAdapter->rWifiVar.rConnSettings.aucBSSID);
+
 		/* indicate AIS Jion fail  event
 		if (prGlueInfo->prDevHandler->ieee80211_ptr->sme_state == CFG80211_SME_CONNECTING) */
 		cfg80211_connect_result(prGlueInfo->prDevHandler,
-					prGlueInfo->prAdapter->rWifiVar.rAisFsmInfo.prTargetBssDesc->aucBSSID,
+					arBssid,
 					prGlueInfo->aucReqIe,
 					prGlueInfo->u4ReqIeLength,
 					prGlueInfo->aucRspIe,
-					prGlueInfo->u4RspIeLength, WLAN_STATUS_AUTH_TIMEOUT, GFP_KERNEL);
+					prGlueInfo->u4RspIeLength, u2StatusCode, GFP_KERNEL);
+		prGlueInfo->eParamMediaStateIndicated = PARAM_MEDIA_STATE_DISCONNECTED;
 		break;
 
 #if 0
@@ -2399,16 +1751,18 @@ kalIoctl(IN P_GLUE_INFO_T prGlueInfo,
 	/* return WLAN_STATUS_ADAPTER_NOT_READY; */
 	/* } */
 
-	if (down_interruptible(&g_halt_sem))
+	/* if wait longer than double OID timeout timer, then will show backtrace who held halt lock.
+		at this case, we will return kalIoctl failure because tx_thread may be hung */
+	if (kalHaltLock(2 * WLAN_OID_TIMEOUT_THRESHOLD))
 		return WLAN_STATUS_FAILURE;
 
-	if (g_u4HaltFlag) {
-		up(&g_halt_sem);
+	if (kalIsHalted()) {
+		kalHaltUnlock();
 		return WLAN_STATUS_ADAPTER_NOT_READY;
 	}
 
 	if (down_interruptible(&prGlueInfo->ioctl_sem)) {
-		up(&g_halt_sem);
+		kalHaltUnlock();
 		return WLAN_STATUS_FAILURE;
 	}
 
@@ -2472,7 +1826,7 @@ kalIoctl(IN P_GLUE_INFO_T prGlueInfo,
 #endif
 	DBGLOG(OID, TEMP, "kalIoctl: done\n");
 	up(&prGlueInfo->ioctl_sem);
-	up(&g_halt_sem);
+	kalHaltUnlock();
 
 	return ret;
 }
@@ -2683,10 +2037,13 @@ int tx_thread(void *data)
 	P_GL_IO_REQ_T prIoReq = NULL;
 	P_QUE_T prTxQueue = NULL;
 	P_QUE_T prCmdQue = NULL;
-
+	P_RX_CTRL_T prRxCtrl;
+	P_SW_RFB_T prSwRfb = NULL;
+	int i, u4UninitRfbNum = 0;
 	int ret = 0;
 
 	BOOLEAN fgNeedHwAccess = FALSE;
+	BOOLEAN fgIsUninitRfb = FALSE;
 
 	struct sk_buff *prSkb = NULL;
 
@@ -2695,6 +2052,7 @@ int tx_thread(void *data)
 
 	prTxQueue = &prGlueInfo->rTxQueue;
 	prCmdQue = &prGlueInfo->rCmdQueue;
+	prRxCtrl = &prGlueInfo->prAdapter->rRxCtrl;
 
 	current->flags |= PF_NOFREEZE;
 
@@ -2910,6 +2268,26 @@ int tx_thread(void *data)
 			}
 
 		}
+		/* Process unInitialized Rfb*/
+		if (prRxCtrl->rUnInitializedRfbList.u4NumElem > 0) {
+			u4UninitRfbNum = prRxCtrl->rUnInitializedRfbList.u4NumElem;
+			DBGLOG(INIT, INFO, "tx_thread :process uninitialziation RFB num=%d\n", u4UninitRfbNum);
+			for (i = 0; i < u4UninitRfbNum; i++) {
+				fgIsUninitRfb = FALSE;
+				KAL_ACQUIRE_SPIN_LOCK(prGlueInfo->prAdapter, SPIN_LOCK_RX_QUE);
+				QUEUE_REMOVE_HEAD(&prRxCtrl->rUnInitializedRfbList, prSwRfb, P_SW_RFB_T);
+				KAL_RELEASE_SPIN_LOCK(prGlueInfo->prAdapter, SPIN_LOCK_RX_QUE);
+				if (prSwRfb) {
+					if (nicRxSetupRFB(prGlueInfo->prAdapter, prSwRfb)) {
+						DBGLOG(INIT, ERROR, "Setup RFB Fail! insert uninit List!\n");
+						fgIsUninitRfb = TRUE;
+					}
+					nicRxReturnRFBwithUninit(prGlueInfo->prAdapter, prSwRfb, fgIsUninitRfb);
+				} else {
+					DBGLOG(INIT, ERROR, "prSwRfb is NULL!\n");
+				}
+			}
+		}
 
 		/* Process RX, In linux, we don't need to free sk_buff by ourself */
 
@@ -3904,7 +3282,7 @@ kalIndicateBssInfo(IN P_GLUE_INFO_T prGlueInfo,
 		    ieee80211_get_channel(wiphy, ieee80211_channel_to_frequency(ucChannelNum, IEEE80211_BAND_5GHZ));
 	}
 
-	if (prChannel != NULL && (prGlueInfo->prScanRequest != NULL || prGlueInfo->prSchedScanRequest != NULL)) {
+	if (prChannel != NULL && prGlueInfo->fgIsRegistered == TRUE) {
 		struct cfg80211_bss *bss;
 #if CFG_SUPPORT_TSF_USING_BOOTTIME
 		struct ieee80211_mgmt *prMgmtFrame = (struct ieee80211_mgmt *)pucBeaconProbeResp;
@@ -4476,6 +3854,73 @@ BOOLEAN kalIsWakeupByWlan(P_ADAPTER_T  prAdapter)
 }
 #endif
 
+INT_32 kalHaltLock(UINT_32 waitMs)
+{
+	INT_32 i4Ret = 0;
+
+	if (waitMs) {
+		i4Ret = down_timeout(&rHaltCtrl.lock, MSEC_TO_JIFFIES(waitMs));
+		if (!i4Ret)
+			goto success;
+		if (i4Ret != -ETIME)
+			return i4Ret;
+		if (rHaltCtrl.fgHeldByKalIoctl) {
+			P_GLUE_INFO_T prGlueInfo = NULL;
+
+			wlanExportGlueInfo(&prGlueInfo);
+
+			DBGLOG(INIT, ERROR,
+				"kalIoctl was executed longer than %u ms, show backtrace of tx_thread!\n",
+				kalGetTimeTick() - rHaltCtrl.u4HoldStart);
+			if (prGlueInfo)
+				show_stack(prGlueInfo->main_thread, NULL);
+		} else {
+			DBGLOG(INIT, ERROR, "halt lock held by %s pid %d longer than %u ms!\n",
+				rHaltCtrl.owner->comm, rHaltCtrl.owner->pid,
+				kalGetTimeTick() - rHaltCtrl.u4HoldStart);
+			show_stack(rHaltCtrl.owner, NULL);
+		}
+		return i4Ret;
+	}
+	down(&rHaltCtrl.lock);
+success:
+	rHaltCtrl.owner = current;
+	rHaltCtrl.u4HoldStart = kalGetTimeTick();
+	return 0;
+}
+
+INT_32 kalHaltTryLock(VOID)
+{
+	INT_32 i4Ret = 0;
+
+	i4Ret = down_trylock(&rHaltCtrl.lock);
+	if (i4Ret)
+		return i4Ret;
+	rHaltCtrl.owner = current;
+	rHaltCtrl.u4HoldStart = kalGetTimeTick();
+	return 0;
+}
+
+VOID kalHaltUnlock(VOID)
+{
+	if (kalGetTimeTick() - rHaltCtrl.u4HoldStart > WLAN_OID_TIMEOUT_THRESHOLD * 2 &&
+		rHaltCtrl.owner)
+		DBGLOG(INIT, ERROR, "process %s pid %d hold halt lock longer than 4s!\n",
+			rHaltCtrl.owner->comm, rHaltCtrl.owner->pid);
+	rHaltCtrl.owner = NULL;
+	up(&rHaltCtrl.lock);
+}
+
+VOID kalSetHalted(BOOLEAN fgHalt)
+{
+	rHaltCtrl.fgHalt = fgHalt;
+}
+
+BOOLEAN kalIsHalted(VOID)
+{
+	return rHaltCtrl.fgHalt;
+}
+
 VOID kalPerMonDump(IN P_GLUE_INFO_T prGlueInfo)
 {
 	struct PERF_MONITOR_T *prPerMonitor;
@@ -4715,35 +4160,42 @@ static int wlan_fb_notifier_callback(struct notifier_block *self, unsigned long
 {
 	struct fb_event *evdata = data;
 	INT_32 blank;
-	P_GLUE_INFO_T prGlueInfo = NULL;
+	P_GLUE_INFO_T prGlueInfo = (P_GLUE_INFO_T)wlan_fb_notifier_priv_data;
 
 
 	/* If we aren't interested in this event, skip it immediately ... */
 	if (event != FB_EVENT_BLANK)
 		return 0;
 
-	down(&g_halt_sem);
+	if (prGlueInfo == NULL)
+		return 0;
+
+	if (kalHaltTryLock())
+		return 0;
+
+	if (kalIsHalted())
+		goto end;
 
-	prGlueInfo = (P_GLUE_INFO_T)wlan_fb_notifier_priv_data;
 	blank = *(INT_32 *)evdata->data;
 
 	switch (blank) {
 	case FB_BLANK_UNBLANK:
-		if (!g_u4HaltFlag)
+		if (!kalIsHalted())
 			kalPerMonEnable(prGlueInfo);
 		wlan_fb_power_down = FALSE;
 		break;
 	case FB_BLANK_POWERDOWN:
 		wlan_fb_power_down = TRUE;
-		if (!g_u4HaltFlag)
+		if (!kalIsHalted())
 			kalPerMonDisable(prGlueInfo);
 		break;
 	default:
 		break;
 	}
-
-	up(&g_halt_sem);
+end:
+	kalHaltUnlock();
 	return 0;
+
 }
 
 INT_32 kalFbNotifierReg(IN P_GLUE_INFO_T prGlueInfo)

+ 1 - 2
drivers/misc/mediatek/connectivity/wlan/gen2/os/linux/include/gl_cfg80211.h

@@ -53,8 +53,7 @@ extern UINT_8 keyStructBuf[100];	/* add/remove key shared buffer */
 #endif
 
 extern struct delayed_work sched_workq;
-extern struct semaphore g_halt_sem;
-extern int g_u4HaltFlag;
+
 /*******************************************************************************
 *                              C O N S T A N T S
 ********************************************************************************

+ 13 - 3
drivers/misc/mediatek/connectivity/wlan/gen2/os/linux/include/gl_kal.h

@@ -564,8 +564,7 @@ extern UINT_32 TaskIsrCnt;
 extern BOOLEAN fgIsResetting;
 extern int wlanHardStartXmit(struct sk_buff *prSkb, struct net_device *prDev);
 extern UINT_32 u4MemAllocCnt, u4MemFreeCnt;
-extern struct semaphore g_halt_sem;
-extern int g_u4HaltFlag;
+
 
 extern struct delayed_work sched_workq;
 
@@ -670,6 +669,13 @@ typedef enum _ENUM_AGPS_EVENT {
 BOOLEAN kalIndicateAgpsNotify(P_ADAPTER_T prAdapter, UINT_8 cmd, PUINT_8 data, UINT_16 dataLen);
 #endif
 
+struct KAL_HALT_CTRL_T {
+	struct semaphore lock;
+	struct task_struct *owner;
+	BOOLEAN fgHalt;
+	BOOLEAN fgHeldByKalIoctl;
+	OS_SYSTIME u4HoldStart;
+};
 /*******************************************************************************
 *                            P U B L I C   D A T A
 ********************************************************************************
@@ -1224,6 +1230,9 @@ do { \
 #define USEC_TO_SYSTIME(_usec)      ((_usec) / USEC_PER_MSEC)
 #define MSEC_TO_SYSTIME(_msec)      (_msec)
 
+#define MSEC_TO_JIFFIES(_msec)      msecs_to_jiffies(_msec)
+
+#define KAL_HALT_LOCK_TIMEOUT_NORMAL_CASE		3000 /* 3s */
 /*******************************************************************************
 *                  F U N C T I O N   D E C L A R A T I O N S
 ********************************************************************************
@@ -1461,6 +1470,8 @@ BOOLEAN kalCfgDataRead16(IN P_GLUE_INFO_T prGlueInfo, IN UINT_32 u4Offset, OUT P
 
 BOOLEAN kalCfgDataWrite16(IN P_GLUE_INFO_T prGlueInfo, IN UINT_32 u4Offset, IN UINT_16 u2Data);
 
+BOOLEAN kalCfgDataRead(IN P_GLUE_INFO_T prGlueInfo, IN UINT_32 u4Offset, IN UINT_32 u4Len, OUT PUINT_16 pu2Data);
+
 /*----------------------------------------------------------------------------*/
 /* WSC Connection                                                     */
 /*----------------------------------------------------------------------------*/
@@ -1542,7 +1553,6 @@ INT_32 kalHaltTryLock(VOID);
 VOID kalHaltUnlock(VOID);
 VOID kalSetHalted(BOOLEAN fgHalt);
 BOOLEAN kalIsHalted(VOID);
-
 INT_32 kalPerMonInit(IN P_GLUE_INFO_T prGlueInfo);
 INT_32 kalPerMonDisable(IN P_GLUE_INFO_T prGlueInfo);
 INT_32 kalPerMonEnable(IN P_GLUE_INFO_T prGlueInfo);

+ 13 - 0
drivers/misc/mediatek/connectivity/wlan/gen2/os/linux/platform.c

@@ -539,3 +539,16 @@ BOOLEAN kalCfgDataWrite16(IN P_GLUE_INFO_T prGlueInfo, UINT_32 u4Offset, UINT_16
 		return TRUE;
 	}
 }
+
+BOOLEAN kalCfgDataRead(IN P_GLUE_INFO_T prGlueInfo, IN UINT_32 u4Offset,
+			 IN UINT_32 u4Len, OUT PUINT_16 pu2Data)
+{
+	if (pu2Data == NULL)
+		return FALSE;
+	if (nvram_read(WIFI_NVRAM_FILE_NAME,
+	   (char *)pu2Data, u4Len, u4Offset) != u4Len) {
+		return FALSE;
+	} else {
+		return TRUE;
+	}
+}

+ 7 - 1
drivers/misc/mediatek/video/common/mtkfb.c

@@ -990,6 +990,7 @@ static int mtkfb_ioctl(struct fb_info *info, unsigned int cmd, unsigned long arg
 		} else {
 			DISPERR("information for displayid: %d is not available now\n",
 				displayid);
+			return -EFAULT;
 		}
 
 		if (copy_to_user((void __user *)arg, &(dispif_info[displayid]), sizeof(mtk_dispif_info_t))) {
@@ -1183,6 +1184,7 @@ static int mtkfb_ioctl(struct fb_info *info, unsigned int cmd, unsigned long arg
 				MTKFB_LOG
 					("MTKFB_SET_OVERLAY_LAYER, layer_id invalid=%d\n",
 					 layerInfo.layer_id);
+				return -EFAULT;
 			} else {
 				input = &session_input.config[session_input.config_layer_num++];
 				_convert_fb_layer_to_disp_input(&layerInfo, input);
@@ -1762,7 +1764,8 @@ static int init_framebuffer(struct fb_info *info)
 
 	/*memset_io(buffer, 0, info->screen_size)*/;
 
-	if (info->var.yres + info->var.yoffset <= info->var.yres_virtual)
+	if ((info->var.yres + info->var.yoffset <= info->var.yres_virtual) &&
+		info->var.yoffset >= 0)
 		memset_io(buffer, 0, size);
 
 	return 0;
@@ -2385,6 +2388,9 @@ static int mtkfb_suspend(struct device *pdev, pm_message_t mesg)
 	/* NOT_REFERENCED(pdev); */
 	MSG_FUNC_ENTER();
 	MTKFB_LOG("[FB Driver] mtkfb_suspend(): 0x%x\n", mesg.event);
+#if defined(OVL_TIME_SHARING)
+	primary_display_disable_ovl2mem();
+#endif
 	ovl2mem_wait_done();
 
 	MSG_FUNC_LEAVE();

+ 1 - 2
drivers/misc/mediatek/video/mt6735/dispsys/ddp_irq.c

@@ -417,8 +417,7 @@ irqreturn_t disp_irq_handler(int irq, void *dev_id)
 			       cnt_wdma_underflow[index]++);
 			disp_irq_log_module |= 1 << module;
 		}
-		if (reg_val & (1 << 2))
-			DDPERR("IRQ: WDMA%d FIFO full!\n", index);
+
 		/* clear intr */
 		DISP_CPU_REG_SET(DISP_REG_WDMA_INTSTA + index * DISP_WDMA_INDEX_OFFSET,
 				 ~reg_val);

+ 32 - 4
drivers/misc/mediatek/video/mt6735/videox/mtk_disp_mgr.c

@@ -1,3 +1,16 @@
+/*
+ * Copyright (C) 2015 MediaTek Inc.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
 #include <linux/kernel.h>
 #include <linux/mm.h>
 #include <linux/mm_types.h>
@@ -482,6 +495,11 @@ int _ioctl_destroy_session(unsigned long arg)
 		)
 		primary_display_set_secondary_display(0, config.type);
 
+#if defined(OVL_TIME_SHARING)
+	if (config.type == DISP_SESSION_MEMORY)
+		primary_display_disable_ovl2mem();
+#endif
+
 	return ret;
 }
 
@@ -538,8 +556,7 @@ int _ioctl_trigger_session(unsigned long arg)
 			MMProfileLogEx(ddp_mmp_get_events()->present_fence_set, MMProfileFlagPulse,
 				       config.present_fence_idx, 0);
 		}
-		primary_display_merge_session_cmd(&config);
-		primary_display_trigger(0, NULL, 0);
+		primary_display_trigger_and_merge(&config, session_id);
 	} else if (DISP_SESSION_TYPE(session_id) == DISP_SESSION_EXTERNAL) {
 #if defined(CONFIG_MTK_HDMI_SUPPORT) || defined(CONFIG_MTK_EPD_SUPPORT)
 		mutex_lock(&disp_session_lock);
@@ -548,8 +565,7 @@ int _ioctl_trigger_session(unsigned long arg)
 #endif
 	} else if (DISP_SESSION_TYPE(session_id) == DISP_SESSION_MEMORY) {
 #if defined(OVL_TIME_SHARING)
-		primary_display_merge_session_cmd(&config);
-		primary_display_memory_trigger(0, NULL, 0);
+		primary_display_trigger_and_merge(&config, session_id);
 #else
 		ovl2mem_trigger(1, NULL, 0);
 #endif
@@ -1142,6 +1158,12 @@ static int set_memory_buffer(disp_session_input_config *input)
 
 	memset((void *)&input_params, 0, sizeof(input_params));
 
+	if (input->config_layer_num == 0 || input->config_layer_num > OVL_LAYER_NUM) {
+		DISPERR("set_memory_buffer, config_layer_num invalid = %d!\n",
+			input->config_layer_num);
+		return 0;
+	}
+
 	for (i = 0; i < input->config_layer_num; i++) {
 		dst_mva = 0;
 		layer_id = input->config[i].layer_id;
@@ -1236,6 +1258,12 @@ static int set_external_buffer(disp_session_input_config *input)
 	session_id = input->session_id;
 	session_info = disp_get_session_sync_info_for_debug(session_id);
 
+	if (input->config_layer_num == 0 || input->config_layer_num > OVL_LAYER_NUM) {
+		DISPERR("set_external_buffer, config_layer_num invalid = %d!\n",
+			input->config_layer_num);
+		return 0;
+	}
+
 	for (i = 0; i < input->config_layer_num; ++i) {
 		dst_mva = 0;
 		layer_id = input->config[i].layer_id;

+ 102 - 17
drivers/misc/mediatek/video/mt6735/videox/primary_display.c

@@ -6307,7 +6307,11 @@ static int primary_display_remove_output(void *callback, unsigned int userdata)
 
 static bool is_multipass_trigger;
 
-int primary_display_merge_session_cmd(disp_session_config *config)
+static int primary_display_config_input_multiple_nolock(disp_session_input_config *session_input);
+static int primary_display_config_output_nolock(disp_mem_output_config *output, unsigned int session_id);
+
+
+static int primary_display_merge_session_cmd(disp_session_config *config)
 {
 	disp_session_input_config *session_input;
 	disp_mem_output_config *primary_output;
@@ -6350,14 +6354,14 @@ int primary_display_merge_session_cmd(disp_session_config *config)
 		}
 	}
 
-	primary_display_config_input_multiple(session_input);
+	primary_display_config_input_multiple_nolock(session_input);
 	if (output_type == DISP_OUTPUT_MEMORY || pgc->session_mode == DISP_SESSION_DECOUPLE_MIRROR_MODE ||
 	    config->type == DISP_SESSION_MEMORY) {
 		mutex_lock(&session_config_mutex);
 		cached_session_output[config->type - 1] = captured_session_output[config->type - 1];
 		mutex_unlock(&session_config_mutex);
 		primary_output = &cached_session_output[config->type - 1];
-		primary_display_config_output(primary_output, config->session_id);
+		primary_display_config_output_nolock(primary_output, config->session_id);
 	}
 #endif
 	return 0;
@@ -6375,7 +6379,7 @@ void primary_display_update_present_fence(unsigned int fence_idx)
 static int config_wdma_output(disp_path_handle disp_handle, cmdqRecHandle cmdq_handle,
 			disp_mem_output_config *output, int is_multipass);
 
-int primary_display_trigger(int blocking, void *callback, unsigned int userdata)
+static int _primary_display_trigger(int blocking, void *callback, unsigned int userdata, int lock)
 {
 	int ret = 0;
 
@@ -6393,7 +6397,8 @@ int primary_display_trigger(int blocking, void *callback, unsigned int userdata)
 
 	primary_trigger_cnt++;
 
-	_primary_path_lock(__func__);
+	if (lock)
+		_primary_path_lock(__func__);
 
 	if (pgc->state == DISP_SLEPT) {
 		DISPMSG("%s, skip because primary dipslay is sleep\n", __func__);
@@ -6500,7 +6505,8 @@ int primary_display_trigger(int blocking, void *callback, unsigned int userdata)
 	dprec_logger_done(DPREC_LOGGER_PRIMARY_TRIGGER, 0, 0);
 
 done:
-	_primary_path_unlock(__func__);
+	if (lock)
+		_primary_path_unlock(__func__);
 	/* FIXME: find aee_kernel_Powerkey_is_press definitation */
 #ifndef DISP_NO_AEE
 	if ((primary_trigger_cnt > PRIMARY_DISPLAY_TRIGGER_CNT) && aee_kernel_Powerkey_is_press()) {
@@ -6514,11 +6520,19 @@ done:
 	return ret;
 }
 
-int primary_display_memory_trigger(int blocking, void *callback, unsigned int userdata)
+int primary_display_trigger(int blocking, void *callback, unsigned int userdata)
 {
-	int ret = 0;
+	return _primary_display_trigger(blocking, callback, userdata, 1);
+}
 
-	_primary_path_lock(__func__);
+int primary_display_trigger_nolock(int blocking, void *callback, unsigned int userdata)
+{
+	return _primary_display_trigger(blocking, callback, userdata, 0);
+}
+
+int primary_display_memory_trigger_nolock(int blocking, void *callback, unsigned int userdata)
+{
+	int ret = 0;
 
 	if (pgc->state == DISP_SLEPT) {
 		DISPMSG("%s, primary dipslay is sleep\n", __func__);
@@ -6541,11 +6555,23 @@ int primary_display_memory_trigger(int blocking, void *callback, unsigned int us
 		DISPMSG("Not support memory trigger using session_mode:%d\n", pgc->session_mode);
 	}
 
-	_primary_path_unlock(__func__);
-
 	return ret;
 }
 
+void primary_display_trigger_and_merge(disp_session_config *config, int session_id)
+{
+	_primary_path_lock(__func__);
+	primary_display_merge_session_cmd(config);
+
+	if (DISP_SESSION_TYPE(session_id) == DISP_SESSION_PRIMARY)
+		primary_display_trigger_nolock(0, NULL, 0);
+	else if (DISP_SESSION_TYPE(session_id) == DISP_SESSION_MEMORY)
+		primary_display_memory_trigger_nolock(0, NULL, 0);
+	else
+		DISPERR("Invalid session trigger\n");
+	_primary_path_unlock(__func__);
+}
+
 static int primary_display_ovl2mem_callback(unsigned int userdata)
 {
 	disp_ddp_path_config *data_config = NULL;
@@ -6710,14 +6736,15 @@ int primary_suspend_outputbuf_fence_release(void)
 }
 #endif
 
-int primary_display_config_output(disp_mem_output_config *output, unsigned int session_id)
+int _primary_display_config_output(disp_mem_output_config *output, unsigned int session_id, int lock)
 {
 	int ret = 0;
 	disp_path_handle disp_handle;
 	cmdqRecHandle cmdq_handle = NULL;
 
 	DISPFUNC();
-	_primary_path_lock(__func__);
+	if (lock)
+		_primary_path_lock(__func__);
 
 	if (pgc->state == DISP_SLEPT && DISP_SESSION_TYPE(session_id) != DISP_SESSION_MEMORY) {
 		DISPMSG("mem out is already slept or mode wrong(%d)\n", pgc->session_mode);
@@ -6779,13 +6806,24 @@ int primary_display_config_output(disp_mem_output_config *output, unsigned int s
 		       output->buff_idx, (unsigned int)output->addr);
 
 done:
-	_primary_path_unlock(__func__);
+	if (lock)
+		_primary_path_unlock(__func__);
 
 	/* dprec_logger_done(DPREC_LOGGER_PRIMARY_CONFIG, output->src_x, output->src_y); */
 	return ret;
 
 }
 
+int primary_display_config_output(disp_mem_output_config *output, unsigned int session_id)
+{
+	return _primary_display_config_output(output, session_id, 1);
+}
+
+static int primary_display_config_output_nolock(disp_mem_output_config *output, unsigned int session_id)
+{
+	return _primary_display_config_output(output, session_id, 0);
+}
+
 #if 0
 /**
  * Defined but not used, avoid build warning. (2015.1.30 Rynn Wu)
@@ -7032,7 +7070,7 @@ static int _config_rdma_input(disp_session_input_config *session_input, disp_pat
 	return ret;
 }
 
-int primary_display_config_input_multiple(disp_session_input_config *session_input)
+static int _primary_display_config_input_multiple(disp_session_input_config *session_input, int lock)
 {
 	int ret = 0;
 	disp_path_handle disp_handle;
@@ -7041,7 +7079,8 @@ int primary_display_config_input_multiple(disp_session_input_config *session_inp
 	if (gTriggerDispMode > 0)
 		return 0;
 
-	_primary_path_lock(__func__);
+	if (lock)
+		_primary_path_lock(__func__);
 
 	if (primary_get_state() == DISP_SLEPT && DISP_SESSION_TYPE(session_input->session_id) != DISP_SESSION_MEMORY) {
 		DISPMSG("%s, skip because primary dipslay is sleep\n", __func__);
@@ -7069,10 +7108,21 @@ int primary_display_config_input_multiple(disp_session_input_config *session_inp
 		_config_rdma_input(session_input, disp_handle);
 
 done:
-	_primary_path_unlock(__func__);
+	if (lock)
+		_primary_path_unlock(__func__);
 	return ret;
 }
 
+int primary_display_config_input_multiple(disp_session_input_config *session_input)
+{
+	return _primary_display_config_input_multiple(session_input, 1);
+}
+
+static int primary_display_config_input_multiple_nolock(disp_session_input_config *session_input)
+{
+	return _primary_display_config_input_multiple(session_input, 0);
+}
+
 int primary_display_config_interface_input(primary_disp_input_config *input)
 {
 	int ret = 0;
@@ -9510,3 +9560,38 @@ int display_exit_tui(void)
 
 	return 0;
 }
+
+#if defined(OVL_TIME_SHARING)
+int primary_display_disable_ovl2mem(void)
+{
+	DISPMSG("%s\n", __func__);
+
+	_primary_path_lock(__func__);
+
+	if (_is_decouple_mode(pgc->session_mode) &&
+		pgc->state == DISP_SLEPT &&
+		pgc->force_on_wdma_path == 1) {
+
+		/* msleep(16); */ /* wait last frame done */
+		usleep_range(16000, 17000);
+		if (dpmgr_path_is_busy(pgc->ovl2mem_path_handle))
+			dpmgr_wait_event_timeout(pgc->ovl2mem_path_handle, DISP_PATH_EVENT_FRAME_COMPLETE, HZ);
+
+		DISPCHECK("[POWER]stop cmdq[begin]\n");
+		_cmdq_stop_trigger_loop();
+		DISPCHECK("[POWER]stop cmdq[end]\n");
+
+		dpmgr_path_power_off(pgc->ovl2mem_path_handle, CMDQ_DISABLE);
+
+#ifndef CONFIG_MTK_CLKMGR
+		ddp_clk_unprepare(DISP_MTCMOS_CLK);
+#endif
+		DISPMSG("disable ovl power\n");
+		pgc->force_on_wdma_path = 0;
+	}
+
+	_primary_path_unlock(__func__);
+
+	return 1;
+}
+#endif

+ 4 - 2
drivers/misc/mediatek/video/mt6735/videox/primary_display.h

@@ -279,8 +279,7 @@ int primary_display_config_input(primary_disp_input_config *input);
 int primary_display_user_cmd(unsigned int cmd, unsigned long arg);
 int primary_display_trigger(int blocking, void *callback, unsigned int userdata);
 int primary_display_ext_trigger(int blocking, void *callback, unsigned int userdata);
-int primary_display_memory_trigger(int blocking, void *callback, unsigned int userdata);
-int primary_display_merge_session_cmd(disp_session_config *config);
+void primary_display_trigger_and_merge(disp_session_config *config, int session_id);
 int primary_display_config_output(disp_mem_output_config *output, unsigned int session_id);
 int primary_display_mem_out_trigger(int blocking, void *callback, unsigned int userdata);
 int primary_display_switch_mode(int sess_mode, unsigned int session, int force);
@@ -375,3 +374,6 @@ int primary_display_set_secondary_display(int add, DISP_SESSION_TYPE type);
 int init_ext_decouple_buffers(void);
 int deinit_ext_decouple_buffers(void);
 int primary_display_get_session_mode(void);
+#if defined(OVL_TIME_SHARING)
+int primary_display_disable_ovl2mem(void);
+#endif

+ 2 - 0
drivers/staging/android/ashmem.c

@@ -752,10 +752,12 @@ static long ashmem_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 		break;
 	case ASHMEM_SET_SIZE:
 		ret = -EINVAL;
+		mutex_lock(&ashmem_mutex);
 		if (!asma->file) {
 			ret = 0;
 			asma->size = (size_t) arg;
 		}
+		mutex_unlock(&ashmem_mutex);
 		break;
 	case ASHMEM_GET_SIZE:
 		ret = asma->size;

+ 8 - 0
drivers/staging/android/binder.c

@@ -66,6 +66,8 @@ static kuid_t binder_context_mgr_uid = INVALID_UID;
 static int binder_last_id;
 static struct workqueue_struct *binder_deferred_workqueue;
 
+#define BINDER_MIN_ALLOC (1 * PAGE_SIZE)
+
 #define RT_PRIO_INHERIT			"v1.7"
 #ifdef RT_PRIO_INHERIT
 #include <linux/sched/rt.h>
@@ -4308,6 +4310,11 @@ static int binder_mmap(struct file *filp, struct vm_area_struct *vma)
 		}
 	}
 #endif
+	if (vma->vm_end - vma->vm_start < BINDER_MIN_ALLOC) {
+		ret = -EINVAL;
+		failure_string = "VMA size < BINDER_MIN_ALLOC";
+		goto err_vma_too_small;
+	}
 	proc->pages =
 	    kzalloc(sizeof(proc->pages[0]) *
 		    ((vma->vm_end - vma->vm_start) / PAGE_SIZE), GFP_KERNEL);
@@ -4345,6 +4352,7 @@ err_alloc_small_buf_failed:
 	kfree(proc->pages);
 	proc->pages = NULL;
 err_alloc_pages_failed:
+err_vma_too_small:
 	mutex_lock(&binder_mmap_lock);
 	vfree(proc->buffer);
 	proc->buffer = NULL;

+ 1 - 1
drivers/staging/android/ion/ion.c

@@ -495,7 +495,7 @@ static struct ion_handle *pass_to_user(struct ion_handle *handle)
 /* Must hold the client lock */
 static int user_ion_handle_put_nolock(struct ion_handle *handle)
 {
-	int ret;
+	int ret = 0;
 
 	if (--handle->user_ref_count == 0)
 		ret = ion_handle_put_nolock(handle);

+ 10 - 0
drivers/usb/gadget/f_mtp.c

@@ -1128,6 +1128,11 @@ static void send_file_work(struct work_struct *data)
 	offset = dev->xfer_file_offset;
 	count = dev->xfer_file_length;
 
+	if (count < 0) {
+		dev->xfer_result = -EINVAL;
+		return;
+	}
+
 	DBG(cdev, "send_file_work(%lld %lld)\n", offset, count);
 
 	if (dev->xfer_send_header) {
@@ -1302,6 +1307,11 @@ static void receive_file_work(struct work_struct *data)
 	offset = dev->xfer_file_offset;
 	count = dev->xfer_file_length;
 
+	if (count < 0) {
+		dev->xfer_result = -EINVAL;
+		return;
+	}
+
 	DBG(cdev, "receive_file_work(%lld)\n", count);
 
 	while (count > 0 || write_req) {

+ 29 - 0
fs/dcache.c

@@ -267,6 +267,35 @@ static inline int dname_external(const struct dentry *dentry)
 	return dentry->d_name.name != dentry->d_iname;
 }
 
+void take_dentry_name_snapshot(struct name_snapshot *name, struct dentry *dentry)
+{
+	spin_lock(&dentry->d_lock);
+	if (unlikely(dname_external(dentry))) {
+		struct external_name *p = external_name(dentry);
+
+		atomic_inc(&p->u.count);
+		spin_unlock(&dentry->d_lock);
+		name->name = p->name;
+	} else {
+		memcpy(name->inline_name, dentry->d_iname, DNAME_INLINE_LEN);
+		spin_unlock(&dentry->d_lock);
+		name->name = name->inline_name;
+	}
+}
+EXPORT_SYMBOL(take_dentry_name_snapshot);
+
+void release_dentry_name_snapshot(struct name_snapshot *name)
+{
+	if (unlikely(name->name != name->inline_name)) {
+		struct external_name *p;
+
+		p = container_of(name->name, struct external_name, name[0]);
+		if (unlikely(atomic_dec_and_test(&p->u.count)))
+			kfree_rcu(p, u.head);
+	}
+}
+EXPORT_SYMBOL(release_dentry_name_snapshot);
+
 static void dentry_free(struct dentry *dentry)
 {
 	WARN_ON(!hlist_unhashed(&dentry->d_u.d_alias));

+ 5 - 5
fs/debugfs/inode.c

@@ -620,7 +620,7 @@ struct dentry *debugfs_rename(struct dentry *old_dir, struct dentry *old_dentry,
 {
 	int error;
 	struct dentry *dentry = NULL, *trap;
-	const char *old_name;
+	struct name_snapshot old_name;
 
 	trap = lock_rename(new_dir, old_dir);
 	/* Source or destination directories don't exist? */
@@ -635,19 +635,19 @@ struct dentry *debugfs_rename(struct dentry *old_dir, struct dentry *old_dentry,
 	if (IS_ERR(dentry) || dentry == trap || dentry->d_inode)
 		goto exit;
 
-	old_name = fsnotify_oldname_init(old_dentry->d_name.name);
+	take_dentry_name_snapshot(&old_name, old_dentry);
 
 	error = simple_rename(old_dir->d_inode, old_dentry, new_dir->d_inode,
 		dentry);
 	if (error) {
-		fsnotify_oldname_free(old_name);
+		release_dentry_name_snapshot(&old_name);
 		goto exit;
 	}
 	d_move(old_dentry, dentry);
-	fsnotify_move(old_dir->d_inode, new_dir->d_inode, old_name,
+	fsnotify_move(old_dir->d_inode, new_dir->d_inode, old_name.name,
 		S_ISDIR(old_dentry->d_inode->i_mode),
 		NULL, old_dentry);
-	fsnotify_oldname_free(old_name);
+	release_dentry_name_snapshot(&old_name);
 	unlock_rename(new_dir, old_dir);
 	dput(dentry);
 	return old_dentry;

+ 4 - 4
fs/namei.c

@@ -4071,11 +4071,11 @@ int vfs_rename(struct inode *old_dir, struct dentry *old_dentry,
 {
 	int error;
 	bool is_dir = d_is_dir(old_dentry);
-	const unsigned char *old_name;
 	struct inode *source = old_dentry->d_inode;
 	struct inode *target = new_dentry->d_inode;
 	bool new_is_dir = false;
 	unsigned max_links = new_dir->i_sb->s_max_links;
+	struct name_snapshot old_name;
 
 	if (source == target)
 		return 0;
@@ -4125,7 +4125,7 @@ int vfs_rename(struct inode *old_dir, struct dentry *old_dentry,
 	if (error)
 		return error;
 
-	old_name = fsnotify_oldname_init(old_dentry->d_name.name);
+	take_dentry_name_snapshot(&old_name, old_dentry);
 	dget(new_dentry);
 	if (!is_dir || (flags & RENAME_EXCHANGE))
 		lock_two_nondirectories(source, target);
@@ -4186,14 +4186,14 @@ out:
 		mutex_unlock(&target->i_mutex);
 	dput(new_dentry);
 	if (!error) {
-		fsnotify_move(old_dir, new_dir, old_name, is_dir,
+		fsnotify_move(old_dir, new_dir, old_name.name, is_dir,
 			      !(flags & RENAME_EXCHANGE) ? target : NULL, old_dentry);
 		if (flags & RENAME_EXCHANGE) {
 			fsnotify_move(new_dir, old_dir, old_dentry->d_name.name,
 				      new_is_dir, NULL, new_dentry);
 		}
 	}
-	fsnotify_oldname_free(old_name);
+	release_dentry_name_snapshot(&old_name);
 
 	return error;
 }

+ 6 - 2
fs/notify/fsnotify.c

@@ -105,16 +105,20 @@ int __fsnotify_parent(struct path *path, struct dentry *dentry, __u32 mask)
 	if (unlikely(!fsnotify_inode_watches_children(p_inode)))
 		__fsnotify_update_child_dentry_flags(p_inode);
 	else if (p_inode->i_fsnotify_mask & mask) {
+		struct name_snapshot name;
+
 		/* we are notifying a parent so come up with the new mask which
 		 * specifies these are events which came from a child. */
 		mask |= FS_EVENT_ON_CHILD;
 
+		take_dentry_name_snapshot(&name, dentry);
 		if (path)
 			ret = fsnotify(p_inode, mask, path, FSNOTIFY_EVENT_PATH,
-				       dentry->d_name.name, 0);
+				       name.name, 0);
 		else
 			ret = fsnotify(p_inode, mask, dentry->d_inode, FSNOTIFY_EVENT_INODE,
-				       dentry->d_name.name, 0);
+				       name.name, 0);
+		release_dentry_name_snapshot(&name);
 	}
 
 	dput(parent);

+ 8 - 0
include/linux/dcache.h

@@ -468,4 +468,12 @@ static inline unsigned long vfs_pressure_ratio(unsigned long val)
 {
 	return mult_frac(val, sysctl_vfs_cache_pressure, 100);
 }
+
+struct name_snapshot {
+	const char *name;
+	char inline_name[DNAME_INLINE_LEN];
+};
+void take_dentry_name_snapshot(struct name_snapshot *, struct dentry *);
+void release_dentry_name_snapshot(struct name_snapshot *);
+
 #endif	/* __LINUX_DCACHE_H */

+ 0 - 31
include/linux/fsnotify.h

@@ -310,35 +310,4 @@ static inline void fsnotify_change(struct dentry *dentry, unsigned int ia_valid)
 	}
 }
 
-#if defined(CONFIG_FSNOTIFY)	/* notify helpers */
-
-/*
- * fsnotify_oldname_init - save off the old filename before we change it
- */
-static inline const unsigned char *fsnotify_oldname_init(const unsigned char *name)
-{
-	return kstrdup(name, GFP_KERNEL);
-}
-
-/*
- * fsnotify_oldname_free - free the name we got from fsnotify_oldname_init
- */
-static inline void fsnotify_oldname_free(const unsigned char *old_name)
-{
-	kfree(old_name);
-}
-
-#else	/* CONFIG_FSNOTIFY */
-
-static inline const char *fsnotify_oldname_init(const unsigned char *name)
-{
-	return NULL;
-}
-
-static inline void fsnotify_oldname_free(const unsigned char *old_name)
-{
-}
-
-#endif	/*  CONFIG_FSNOTIFY */
-
 #endif	/* _LINUX_FS_NOTIFY_H */

+ 3 - 8
mm/migrate.c

@@ -37,6 +37,7 @@
 #include <linux/gfp.h>
 #include <linux/balloon_compaction.h>
 #include <linux/mmu_notifier.h>
+#include <linux/ptrace.h>
 
 #include <asm/tlbflush.h>
 
@@ -1466,7 +1467,6 @@ SYSCALL_DEFINE6(move_pages, pid_t, pid, unsigned long, nr_pages,
 		const int __user *, nodes,
 		int __user *, status, int, flags)
 {
-	const struct cred *cred = current_cred(), *tcred;
 	struct task_struct *task;
 	struct mm_struct *mm;
 	int err;
@@ -1490,14 +1490,9 @@ SYSCALL_DEFINE6(move_pages, pid_t, pid, unsigned long, nr_pages,
 
 	/*
 	 * Check if this process has the right to modify the specified
-	 * process. The right exists if the process has administrative
-	 * capabilities, superuser privileges or the same
-	 * userid as the target process.
+	 * process. Use the regular "ptrace_may_access()" checks.
 	 */
-	tcred = __task_cred(task);
-	if (!uid_eq(cred->euid, tcred->suid) && !uid_eq(cred->euid, tcred->uid) &&
-	    !uid_eq(cred->uid,  tcred->suid) && !uid_eq(cred->uid,  tcred->uid) &&
-	    !capable(CAP_SYS_NICE)) {
+	if (!ptrace_may_access(task, PTRACE_MODE_READ_REALCREDS)) {
 		rcu_read_unlock();
 		err = -EPERM;
 		goto out;

+ 112 - 96
sound/core/timer.c

@@ -301,9 +301,6 @@ int snd_timer_open(struct snd_timer_instance **ti,
 	return 0;
 }
 
-static int _snd_timer_stop(struct snd_timer_instance *timeri,
-			   int keep_flag, int event);
-
 /*
  * close a timer instance
  */
@@ -389,7 +386,6 @@ unsigned long snd_timer_resolution(struct snd_timer_instance *timeri)
 static void snd_timer_notify1(struct snd_timer_instance *ti, int event)
 {
 	struct snd_timer *timer;
-	unsigned long flags;
 	unsigned long resolution = 0;
 	struct snd_timer_instance *ts;
 	struct timespec tstamp;
@@ -413,34 +409,66 @@ static void snd_timer_notify1(struct snd_timer_instance *ti, int event)
 		return;
 	if (timer->hw.flags & SNDRV_TIMER_HW_SLAVE)
 		return;
-	spin_lock_irqsave(&timer->lock, flags);
 	list_for_each_entry(ts, &ti->slave_active_head, active_list)
 		if (ts->ccallback)
-			ts->ccallback(ti, event + 100, &tstamp, resolution);
-	spin_unlock_irqrestore(&timer->lock, flags);
+			ts->ccallback(ts, event + 100, &tstamp, resolution);
 }
 
-static int snd_timer_start1(struct snd_timer *timer, struct snd_timer_instance *timeri,
-			    unsigned long sticks)
+/* start/continue a master timer */
+static int snd_timer_start1(struct snd_timer_instance *timeri,
+			    bool start, unsigned long ticks)
 {
+	struct snd_timer *timer;
+	int result;
+	unsigned long flags;
+
+	timer = timeri->timer;
+	if (!timer)
+		return -EINVAL;
+
+	spin_lock_irqsave(&timer->lock, flags);
+	if (timer->card && timer->card->shutdown) {
+		result = -ENODEV;
+		goto unlock;
+	}
+	if (timeri->flags & (SNDRV_TIMER_IFLG_RUNNING |
+			     SNDRV_TIMER_IFLG_START)) {
+		result = -EBUSY;
+		goto unlock;
+	}
+
+	if (start)
+		timeri->ticks = timeri->cticks = ticks;
+	else if (!timeri->cticks)
+		timeri->cticks = 1;
+	timeri->pticks = 0;
+
 	list_move_tail(&timeri->active_list, &timer->active_list_head);
 	if (timer->running) {
 		if (timer->hw.flags & SNDRV_TIMER_HW_SLAVE)
 			goto __start_now;
 		timer->flags |= SNDRV_TIMER_FLG_RESCHED;
 		timeri->flags |= SNDRV_TIMER_IFLG_START;
-		return 1;	/* delayed start */
+		result = 1; /* delayed start */
 	} else {
-		timer->sticks = sticks;
+		if (start)
+			timer->sticks = ticks;
 		timer->hw.start(timer);
 	      __start_now:
 		timer->running++;
 		timeri->flags |= SNDRV_TIMER_IFLG_RUNNING;
-		return 0;
+		result = 0;
 	}
+	snd_timer_notify1(timeri, start ? SNDRV_TIMER_EVENT_START :
+			  SNDRV_TIMER_EVENT_CONTINUE);
+ unlock:
+	spin_unlock_irqrestore(&timer->lock, flags);
+	return result;
 }
 
-static int snd_timer_start_slave(struct snd_timer_instance *timeri)
+/* start/continue a slave timer */
+static int snd_timer_start_slave(struct snd_timer_instance *timeri,
+				 bool start)
 {
 	unsigned long flags;
 
@@ -450,65 +478,38 @@ static int snd_timer_start_slave(struct snd_timer_instance *timeri)
 		spin_lock(&timeri->timer->lock);
 		list_add_tail(&timeri->active_list,
 			      &timeri->master->slave_active_head);
+		snd_timer_notify1(timeri, start ? SNDRV_TIMER_EVENT_START :
+				  SNDRV_TIMER_EVENT_CONTINUE);
 		spin_unlock(&timeri->timer->lock);
 	}
 	spin_unlock_irqrestore(&slave_active_lock, flags);
 	return 1; /* delayed start */
 }
 
-/*
- *  start the timer instance
- */
-int snd_timer_start(struct snd_timer_instance *timeri, unsigned int ticks)
+/* stop/pause a master timer */
+static int snd_timer_stop1(struct snd_timer_instance *timeri, bool stop)
 {
 	struct snd_timer *timer;
-	int result = -EINVAL;
+	int result = 0;
 	unsigned long flags;
 
-	if (timeri == NULL || ticks < 1)
-		return -EINVAL;
-	if (timeri->flags & SNDRV_TIMER_IFLG_SLAVE) {
-		result = snd_timer_start_slave(timeri);
-		snd_timer_notify1(timeri, SNDRV_TIMER_EVENT_START);
-		return result;
-	}
-	timer = timeri->timer;
-	if (timer == NULL)
-		return -EINVAL;
-	spin_lock_irqsave(&timer->lock, flags);
-	timeri->ticks = timeri->cticks = ticks;
-	timeri->pticks = 0;
-	result = snd_timer_start1(timer, timeri, ticks);
-	spin_unlock_irqrestore(&timer->lock, flags);
-	snd_timer_notify1(timeri, SNDRV_TIMER_EVENT_START);
-	return result;
-}
-
-static int _snd_timer_stop(struct snd_timer_instance * timeri,
-			   int keep_flag, int event)
-{
-	struct snd_timer *timer;
-	unsigned long flags;
-
-	if (snd_BUG_ON(!timeri))
-		return -ENXIO;
-
-	if (timeri->flags & SNDRV_TIMER_IFLG_SLAVE) {
-		if (!keep_flag) {
-			spin_lock_irqsave(&slave_active_lock, flags);
-			timeri->flags &= ~SNDRV_TIMER_IFLG_RUNNING;
-			list_del_init(&timeri->ack_list);
-			list_del_init(&timeri->active_list);
-			spin_unlock_irqrestore(&slave_active_lock, flags);
-		}
-		goto __end;
-	}
 	timer = timeri->timer;
 	if (!timer)
 		return -EINVAL;
 	spin_lock_irqsave(&timer->lock, flags);
+	if (!(timeri->flags & (SNDRV_TIMER_IFLG_RUNNING |
+			       SNDRV_TIMER_IFLG_START))) {
+		result = -EBUSY;
+		goto unlock;
+	}
 	list_del_init(&timeri->ack_list);
 	list_del_init(&timeri->active_list);
+	if (timer->card && timer->card->shutdown)
+		goto unlock;
+	if (stop) {
+		timeri->cticks = timeri->ticks;
+		timeri->pticks = 0;
+	}
 	if ((timeri->flags & SNDRV_TIMER_IFLG_RUNNING) &&
 	    !(--timer->running)) {
 		timer->hw.stop(timer);
@@ -521,16 +522,50 @@ static int _snd_timer_stop(struct snd_timer_instance * timeri,
 			}
 		}
 	}
-	if (!keep_flag)
-		timeri->flags &=
-			~(SNDRV_TIMER_IFLG_RUNNING | SNDRV_TIMER_IFLG_START);
+	timeri->flags &= ~(SNDRV_TIMER_IFLG_RUNNING | SNDRV_TIMER_IFLG_START);
+	snd_timer_notify1(timeri, stop ? SNDRV_TIMER_EVENT_STOP :
+			  SNDRV_TIMER_EVENT_CONTINUE);
+ unlock:
 	spin_unlock_irqrestore(&timer->lock, flags);
-      __end:
-	if (event != SNDRV_TIMER_EVENT_RESOLUTION)
-		snd_timer_notify1(timeri, event);
+	return result;
+}
+
+/* stop/pause a slave timer */
+static int snd_timer_stop_slave(struct snd_timer_instance *timeri, bool stop)
+{
+	unsigned long flags;
+
+	spin_lock_irqsave(&slave_active_lock, flags);
+	if (!(timeri->flags & SNDRV_TIMER_IFLG_RUNNING)) {
+		spin_unlock_irqrestore(&slave_active_lock, flags);
+		return -EBUSY;
+	}
+	timeri->flags &= ~SNDRV_TIMER_IFLG_RUNNING;
+	if (timeri->timer) {
+		spin_lock(&timeri->timer->lock);
+		list_del_init(&timeri->ack_list);
+		list_del_init(&timeri->active_list);
+		snd_timer_notify1(timeri, stop ? SNDRV_TIMER_EVENT_STOP :
+				  SNDRV_TIMER_EVENT_CONTINUE);
+		spin_unlock(&timeri->timer->lock);
+	}
+	spin_unlock_irqrestore(&slave_active_lock, flags);
 	return 0;
 }
 
+/*
+ *  start the timer instance
+ */
+int snd_timer_start(struct snd_timer_instance *timeri, unsigned int ticks)
+{
+	if (timeri == NULL || ticks < 1)
+		return -EINVAL;
+	if (timeri->flags & SNDRV_TIMER_IFLG_SLAVE)
+		return snd_timer_start_slave(timeri, true);
+	else
+		return snd_timer_start1(timeri, true, ticks);
+}
+
 /*
  * stop the timer instance.
  *
@@ -538,21 +573,10 @@ static int _snd_timer_stop(struct snd_timer_instance * timeri,
  */
 int snd_timer_stop(struct snd_timer_instance *timeri)
 {
-	struct snd_timer *timer;
-	unsigned long flags;
-	int err;
-
-	err = _snd_timer_stop(timeri, 0, SNDRV_TIMER_EVENT_STOP);
-	if (err < 0)
-		return err;
-	timer = timeri->timer;
-	if (!timer)
-		return -EINVAL;
-	spin_lock_irqsave(&timer->lock, flags);
-	timeri->cticks = timeri->ticks;
-	timeri->pticks = 0;
-	spin_unlock_irqrestore(&timer->lock, flags);
-	return 0;
+	if (timeri->flags & SNDRV_TIMER_IFLG_SLAVE)
+		return snd_timer_stop_slave(timeri, true);
+	else
+		return snd_timer_stop1(timeri, true);
 }
 
 /*
@@ -560,25 +584,10 @@ int snd_timer_stop(struct snd_timer_instance *timeri)
  */
 int snd_timer_continue(struct snd_timer_instance *timeri)
 {
-	struct snd_timer *timer;
-	int result = -EINVAL;
-	unsigned long flags;
-
-	if (timeri == NULL)
-		return result;
 	if (timeri->flags & SNDRV_TIMER_IFLG_SLAVE)
-		return snd_timer_start_slave(timeri);
-	timer = timeri->timer;
-	if (! timer)
-		return -EINVAL;
-	spin_lock_irqsave(&timer->lock, flags);
-	if (!timeri->cticks)
-		timeri->cticks = 1;
-	timeri->pticks = 0;
-	result = snd_timer_start1(timer, timeri, timer->sticks);
-	spin_unlock_irqrestore(&timer->lock, flags);
-	snd_timer_notify1(timeri, SNDRV_TIMER_EVENT_CONTINUE);
-	return result;
+		return snd_timer_start_slave(timeri, false);
+	else
+		return snd_timer_start1(timeri, false, 0);
 }
 
 /*
@@ -586,7 +595,10 @@ int snd_timer_continue(struct snd_timer_instance *timeri)
  */
 int snd_timer_pause(struct snd_timer_instance * timeri)
 {
-	return _snd_timer_stop(timeri, 0, SNDRV_TIMER_EVENT_PAUSE);
+	if (timeri->flags & SNDRV_TIMER_IFLG_SLAVE)
+		return snd_timer_stop_slave(timeri, false);
+	else
+		return snd_timer_stop1(timeri, false);
 }
 
 /*
@@ -1869,6 +1881,7 @@ static ssize_t snd_timer_user_read(struct file *file, char __user *buffer,
 
 	tu = file->private_data;
 	unit = tu->tread ? sizeof(struct snd_timer_tread) : sizeof(struct snd_timer_read);
+	mutex_lock(&tu->ioctl_lock);
 	spin_lock_irq(&tu->qlock);
 	while ((long)count - result >= unit) {
 		while (!tu->qused) {
@@ -1884,7 +1897,9 @@ static ssize_t snd_timer_user_read(struct file *file, char __user *buffer,
 			add_wait_queue(&tu->qchange_sleep, &wait);
 
 			spin_unlock_irq(&tu->qlock);
+			mutex_unlock(&tu->ioctl_lock);
 			schedule();
+			mutex_lock(&tu->ioctl_lock);
 			spin_lock_irq(&tu->qlock);
 
 			remove_wait_queue(&tu->qchange_sleep, &wait);
@@ -1923,6 +1938,7 @@ static ssize_t snd_timer_user_read(struct file *file, char __user *buffer,
 	}
 	spin_unlock_irq(&tu->qlock);
  _error:
+	mutex_unlock(&tu->ioctl_lock);
 	return result > 0 ? result : err;
 }
 

Some files were not shown because too many files changed in this diff