Staging: rt{28,30}70: merge rt{28,30}70/*.[ch]
authorBartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Sun, 26 Apr 2009 14:06:19 +0000 (16:06 +0200)
committerGreg Kroah-Hartman <gregkh@suse.de>
Fri, 19 Jun 2009 18:00:49 +0000 (11:00 -0700)
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
25 files changed:
drivers/staging/rt3070/2870_main_dev.c
drivers/staging/rt3070/action.h
drivers/staging/rt3070/aironet.h
drivers/staging/rt3070/ap.h
drivers/staging/rt3070/chlist.h
drivers/staging/rt3070/dfs.h
drivers/staging/rt3070/link_list.h
drivers/staging/rt3070/md5.h
drivers/staging/rt3070/mlme.h
drivers/staging/rt3070/oid.h
drivers/staging/rt3070/rt2870.h
drivers/staging/rt3070/rt28xx.h
drivers/staging/rt3070/rt_config.h
drivers/staging/rt3070/rt_linux.c
drivers/staging/rt3070/rt_linux.h
drivers/staging/rt3070/rt_main_dev.c
drivers/staging/rt3070/rt_profile.c
drivers/staging/rt3070/rtmp.h
drivers/staging/rt3070/rtmp_ckipmic.h
drivers/staging/rt3070/rtmp_def.h
drivers/staging/rt3070/rtmp_type.h
drivers/staging/rt3070/spectrum.h
drivers/staging/rt3070/spectrum_def.h
drivers/staging/rt3070/sta_ioctl.c
drivers/staging/rt3070/wpa.h

index 93f112765fbc54f4c698fa44c7edd715b0b69d74..32427c0bb3b90960f814a41da0da090094aeb9a9 100644 (file)
@@ -1,1447 +1 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify  *
- * it under the terms of the GNU General Public License as published by  *
- * the Free Software Foundation; either version 2 of the License, or     *
- * (at your option) any later version.                                   *
- *                                                                       *
- * 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.                          *
- *                                                                       *
- * You should have received a copy of the GNU General Public License     *
- * along with this program; if not, write to the                         *
- * Free Software Foundation, Inc.,                                       *
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- *                                                                       *
- *************************************************************************
-
-    Module Name:
-    rtmp_main.c
-
-    Abstract:
-    main initialization routines
-
-    Revision History:
-    Who         When            What
-    --------    ----------      ----------------------------------------------
-    Name        Date            Modification logs
-    Jan Lee            01-10-2005          modified
-       Sample          Jun/01/07               Merge RT2870 and RT2860 drivers.
-*/
-
-#include "rt_config.h"
-
-
-// Following information will be show when you run 'modinfo'
-// *** If you have a solution for the bug in current version of driver, please mail to me.
-// Otherwise post to forum in ralinktech's web site(www.ralinktech.com) and let all users help you. ***
-MODULE_AUTHOR("Paul Lin <paul_lin@ralinktech.com>");
-MODULE_DESCRIPTION("RT2870 Wireless Lan Linux Driver");
-MODULE_LICENSE("GPL");
-#ifdef MODULE_VERSION
-MODULE_VERSION(STA_DRIVER_VERSION);
-#endif
-
-/* Kernel thread and vars, which handles packets that are completed. Only
- * packets that have a "complete" function are sent here. This way, the
- * completion is run out of kernel context, and doesn't block the rest of
- * the stack. */
-
-extern INT __devinit rt28xx_probe(IN void *_dev_p, IN void *_dev_id_p,
-                                                                       IN UINT argc, OUT PRTMP_ADAPTER *ppAd);
-
-
-/* module table */
-struct usb_device_id    rtusb_usb_id[] = RT2870_USB_DEVICES;
-INT const               rtusb_usb_id_len = sizeof(rtusb_usb_id) / sizeof(struct usb_device_id);
-MODULE_DEVICE_TABLE(usb, rtusb_usb_id);
-
-#ifndef PF_NOFREEZE
-#define PF_NOFREEZE  0
-#endif
-
-
-#ifdef CONFIG_PM
-static int rt2870_suspend(struct usb_interface *intf, pm_message_t state);
-static int rt2870_resume(struct usb_interface *intf);
-#endif // CONFIG_PM //
-
-/**************************************************************************/
-/**************************************************************************/
-//tested for kernel 2.6series
-/**************************************************************************/
-/**************************************************************************/
-static int rtusb_probe (struct usb_interface *intf,
-                                               const struct usb_device_id *id);
-static void rtusb_disconnect(struct usb_interface *intf);
-
-struct usb_driver rtusb_driver = {
-       .name="rt2870",
-       .probe=rtusb_probe,
-       .disconnect=rtusb_disconnect,
-       .id_table=rtusb_usb_id,
-
-#ifdef CONFIG_PM
-       suspend:        rt2870_suspend,
-       resume:         rt2870_resume,
-#endif
-       };
-
-#ifdef CONFIG_PM
-
-VOID RT2860RejectPendingPackets(
-       IN      PRTMP_ADAPTER   pAd)
-{
-       // clear PS packets
-       // clear TxSw packets
-}
-
-static int rt2870_suspend(
-       struct usb_interface *intf,
-       pm_message_t state)
-{
-       struct net_device *net_dev;
-       PRTMP_ADAPTER pAd = usb_get_intfdata(intf);
-
-
-       DBGPRINT(RT_DEBUG_TRACE, ("===> rt2870_suspend()\n"));
-       net_dev = pAd->net_dev;
-                       netif_device_detach(net_dev);
-
-       pAd->PM_FlgSuspend = 1;
-       if (netif_running(net_dev)) {
-               RTUSBCancelPendingBulkInIRP(pAd);
-               RTUSBCancelPendingBulkOutIRP(pAd);
-       }
-       DBGPRINT(RT_DEBUG_TRACE, ("<=== rt2870_suspend()\n"));
-       return 0;
-}
-
-static int rt2870_resume(
-       struct usb_interface *intf)
-{
-       struct net_device *net_dev;
-       PRTMP_ADAPTER pAd = usb_get_intfdata(intf);
-
-
-       DBGPRINT(RT_DEBUG_TRACE, ("===> rt2870_resume()\n"));
-
-       pAd->PM_FlgSuspend = 0;
-       net_dev = pAd->net_dev;
-                       netif_device_attach(net_dev);
-                       netif_start_queue(net_dev);
-                       netif_carrier_on(net_dev);
-                       netif_wake_queue(net_dev);
-
-       DBGPRINT(RT_DEBUG_TRACE, ("<=== rt2870_resume()\n"));
-       return 0;
-}
-#endif // CONFIG_PM //
-
-
-// Init driver module
-INT __init rtusb_init(void)
-{
-       printk("rtusb init --->\n");
-       return usb_register(&rtusb_driver);
-}
-
-// Deinit driver module
-VOID __exit rtusb_exit(void)
-{
-       usb_deregister(&rtusb_driver);
-       printk("<--- rtusb exit\n");
-}
-
-module_init(rtusb_init);
-module_exit(rtusb_exit);
-
-
-
-
-/*---------------------------------------------------------------------        */
-/* function declarations                                                                                               */
-/*---------------------------------------------------------------------        */
-
-/*
-========================================================================
-Routine Description:
-    MLME kernel thread.
-
-Arguments:
-       *Context                        the pAd, driver control block pointer
-
-Return Value:
-    0                                  close the thread
-
-Note:
-========================================================================
-*/
-INT MlmeThread(
-       IN void *Context)
-{
-       PRTMP_ADAPTER   pAd = (PRTMP_ADAPTER)Context;
-       POS_COOKIE      pObj;
-       int status;
-
-       pObj = (POS_COOKIE)pAd->OS_Cookie;
-
-       rtmp_os_thread_init("rt2870MlmeThread", (PVOID)&(pAd->mlmeComplete));
-
-       while (pAd->mlme_kill == 0)
-       {
-               /* lock the device pointers */
-               //down(&(pAd->mlme_semaphore));
-               status = down_interruptible(&(pAd->mlme_semaphore));
-
-               /* lock the device pointers , need to check if required*/
-               //down(&(pAd->usbdev_semaphore));
-
-               if (!pAd->PM_FlgSuspend)
-               MlmeHandler(pAd);
-
-               /* unlock the device pointers */
-               //up(&(pAd->usbdev_semaphore));
-               if (status != 0)
-               {
-                       RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS);
-                       break;
-               }
-       }
-
-       /* notify the exit routine that we're actually exiting now
-        *
-        * complete()/wait_for_completion() is similar to up()/down(),
-        * except that complete() is safe in the case where the structure
-        * is getting deleted in a parallel mode of execution (i.e. just
-        * after the down() -- that's necessary for the thread-shutdown
-        * case.
-        *
-        * complete_and_exit() goes even further than this -- it is safe in
-        * the case that the thread of the caller is going away (not just
-        * the structure) -- this is necessary for the module-remove case.
-        * This is important in preemption kernels, which transfer the flow
-        * of execution immediately upon a complete().
-        */
-       DBGPRINT(RT_DEBUG_TRACE,( "<---%s\n",__func__));
-
-       pObj->MLMEThr_pid = NULL;
-
-       complete_and_exit (&pAd->mlmeComplete, 0);
-       return 0;
-
-}
-
-
-/*
-========================================================================
-Routine Description:
-    USB command kernel thread.
-
-Arguments:
-       *Context                        the pAd, driver control block pointer
-
-Return Value:
-    0                                  close the thread
-
-Note:
-========================================================================
-*/
-INT RTUSBCmdThread(
-       IN void * Context)
-{
-       PRTMP_ADAPTER   pAd = (PRTMP_ADAPTER)Context;
-       POS_COOKIE              pObj;
-       int status;
-
-       pObj = (POS_COOKIE)pAd->OS_Cookie;
-
-       rtmp_os_thread_init("rt2870CmdThread", (PVOID)&(pAd->CmdQComplete));
-
-       NdisAcquireSpinLock(&pAd->CmdQLock);
-       pAd->CmdQ.CmdQState = RT2870_THREAD_RUNNING;
-       NdisReleaseSpinLock(&pAd->CmdQLock);
-
-       while (pAd->CmdQ.CmdQState == RT2870_THREAD_RUNNING)
-       {
-               /* lock the device pointers */
-               //down(&(pAd->RTUSBCmd_semaphore));
-               status = down_interruptible(&(pAd->RTUSBCmd_semaphore));
-
-               if (pAd->CmdQ.CmdQState == RT2870_THREAD_STOPED)
-                       break;
-
-               if (status != 0)
-               {
-                       RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS);
-                       break;
-               }
-               /* lock the device pointers , need to check if required*/
-               //down(&(pAd->usbdev_semaphore));
-
-               if (!pAd->PM_FlgSuspend)
-               CMDHandler(pAd);
-
-               /* unlock the device pointers */
-               //up(&(pAd->usbdev_semaphore));
-       }
-
-       if (!pAd->PM_FlgSuspend)
-       {       // Clear the CmdQElements.
-               CmdQElmt        *pCmdQElmt = NULL;
-
-               NdisAcquireSpinLock(&pAd->CmdQLock);
-               pAd->CmdQ.CmdQState = RT2870_THREAD_STOPED;
-               while(pAd->CmdQ.size)
-               {
-                       RTUSBDequeueCmd(&pAd->CmdQ, &pCmdQElmt);
-                       if (pCmdQElmt)
-                       {
-                               if (pCmdQElmt->CmdFromNdis == TRUE)
-                               {
-                                       if (pCmdQElmt->buffer != NULL)
-                                               NdisFreeMemory(pCmdQElmt->buffer, pCmdQElmt->bufferlength, 0);
-
-                                       NdisFreeMemory(pCmdQElmt, sizeof(CmdQElmt), 0);
-                               }
-                               else
-                               {
-                                       if ((pCmdQElmt->buffer != NULL) && (pCmdQElmt->bufferlength != 0))
-                                               NdisFreeMemory(pCmdQElmt->buffer, pCmdQElmt->bufferlength, 0);
-                           {
-                                               NdisFreeMemory(pCmdQElmt, sizeof(CmdQElmt), 0);
-                                       }
-                               }
-                       }
-               }
-
-               NdisReleaseSpinLock(&pAd->CmdQLock);
-       }
-       /* notify the exit routine that we're actually exiting now
-        *
-        * complete()/wait_for_completion() is similar to up()/down(),
-        * except that complete() is safe in the case where the structure
-        * is getting deleted in a parallel mode of execution (i.e. just
-        * after the down() -- that's necessary for the thread-shutdown
-        * case.
-        *
-        * complete_and_exit() goes even further than this -- it is safe in
-        * the case that the thread of the caller is going away (not just
-        * the structure) -- this is necessary for the module-remove case.
-        * This is important in preemption kernels, which transfer the flow
-        * of execution immediately upon a complete().
-        */
-       DBGPRINT(RT_DEBUG_TRACE,( "<---RTUSBCmdThread\n"));
-
-       pObj->RTUSBCmdThr_pid = NULL;
-
-       complete_and_exit (&pAd->CmdQComplete, 0);
-       return 0;
-
-}
-
-
-static void RT2870_TimerQ_Handle(RTMP_ADAPTER *pAd)
-{
-       int status;
-       RALINK_TIMER_STRUCT     *pTimer;
-       RT2870_TIMER_ENTRY      *pEntry;
-       unsigned long   irqFlag;
-
-       while(!pAd->TimerFunc_kill)
-       {
-//             printk("waiting for event!\n");
-               pTimer = NULL;
-
-               status = down_interruptible(&(pAd->RTUSBTimer_semaphore));
-
-               if (pAd->TimerQ.status == RT2870_THREAD_STOPED)
-                       break;
-
-               // event happened.
-               while(pAd->TimerQ.pQHead)
-               {
-                       RTMP_IRQ_LOCK(&pAd->TimerQLock, irqFlag);
-                       pEntry = pAd->TimerQ.pQHead;
-                       if (pEntry)
-                       {
-                               pTimer = pEntry->pRaTimer;
-
-                               // update pQHead
-                               pAd->TimerQ.pQHead = pEntry->pNext;
-                               if (pEntry == pAd->TimerQ.pQTail)
-                                       pAd->TimerQ.pQTail = NULL;
-
-                               // return this queue entry to timerQFreeList.
-                               pEntry->pNext = pAd->TimerQ.pQPollFreeList;
-                               pAd->TimerQ.pQPollFreeList = pEntry;
-                       }
-                       RTMP_IRQ_UNLOCK(&pAd->TimerQLock, irqFlag);
-
-                       if (pTimer)
-                       {
-                               if (pTimer->handle != NULL)
-                               if (!pAd->PM_FlgSuspend)
-                                       pTimer->handle(NULL, (PVOID) pTimer->cookie, NULL, pTimer);
-                               if ((pTimer->Repeat) && (pTimer->State == FALSE))
-                                       RTMP_OS_Add_Timer(&pTimer->TimerObj, pTimer->TimerValue);
-                       }
-               }
-
-               if (status != 0)
-               {
-                       pAd->TimerQ.status = RT2870_THREAD_STOPED;
-                       RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS);
-                       break;
-               }
-       }
-}
-
-
-INT TimerQThread(
-       IN OUT PVOID Context)
-{
-       PRTMP_ADAPTER   pAd;
-       POS_COOKIE      pObj;
-
-       pAd = (PRTMP_ADAPTER)Context;
-       pObj = (POS_COOKIE) pAd->OS_Cookie;
-
-       rtmp_os_thread_init("rt2870TimerQHandle", (PVOID)&(pAd->TimerQComplete));
-
-       RT2870_TimerQ_Handle(pAd);
-
-       /* notify the exit routine that we're actually exiting now
-        *
-        * complete()/wait_for_completion() is similar to up()/down(),
-        * except that complete() is safe in the case where the structure
-        * is getting deleted in a parallel mode of execution (i.e. just
-        * after the down() -- that's necessary for the thread-shutdown
-        * case.
-        *
-        * complete_and_exit() goes even further than this -- it is safe in
-        * the case that the thread of the caller is going away (not just
-        * the structure) -- this is necessary for the module-remove case.
-        * This is important in preemption kernels, which transfer the flow
-        * of execution immediately upon a complete().
-        */
-       DBGPRINT(RT_DEBUG_TRACE,( "<---%s\n",__func__));
-
-       pObj->TimerQThr_pid = NULL;
-
-       complete_and_exit(&pAd->TimerQComplete, 0);
-       return 0;
-
-}
-
-
-RT2870_TIMER_ENTRY *RT2870_TimerQ_Insert(
-       IN RTMP_ADAPTER *pAd,
-       IN RALINK_TIMER_STRUCT *pTimer)
-{
-       RT2870_TIMER_ENTRY *pQNode = NULL, *pQTail;
-       unsigned long irqFlags;
-
-
-       RTMP_IRQ_LOCK(&pAd->TimerQLock, irqFlags);
-       if (pAd->TimerQ.status & RT2870_THREAD_CAN_DO_INSERT)
-       {
-               if(pAd->TimerQ.pQPollFreeList)
-               {
-                       pQNode = pAd->TimerQ.pQPollFreeList;
-                       pAd->TimerQ.pQPollFreeList = pQNode->pNext;
-
-                       pQNode->pRaTimer = pTimer;
-                       pQNode->pNext = NULL;
-
-                       pQTail = pAd->TimerQ.pQTail;
-                       if (pAd->TimerQ.pQTail != NULL)
-                               pQTail->pNext = pQNode;
-                       pAd->TimerQ.pQTail = pQNode;
-                       if (pAd->TimerQ.pQHead == NULL)
-                               pAd->TimerQ.pQHead = pQNode;
-               }
-               RTMP_IRQ_UNLOCK(&pAd->TimerQLock, irqFlags);
-
-               if (pQNode)
-                       up(&pAd->RTUSBTimer_semaphore);
-                       //wake_up(&timerWaitQ);
-       }
-       else
-       {
-               RTMP_IRQ_UNLOCK(&pAd->TimerQLock, irqFlags);
-       }
-       return pQNode;
-}
-
-
-BOOLEAN RT2870_TimerQ_Remove(
-       IN RTMP_ADAPTER *pAd,
-       IN RALINK_TIMER_STRUCT *pTimer)
-{
-       RT2870_TIMER_ENTRY *pNode, *pPrev = NULL;
-       unsigned long irqFlags;
-
-       RTMP_IRQ_LOCK(&pAd->TimerQLock, irqFlags);
-       if (pAd->TimerQ.status >= RT2870_THREAD_INITED)
-       {
-               pNode = pAd->TimerQ.pQHead;
-               while (pNode)
-               {
-                       if (pNode->pRaTimer == pTimer)
-                               break;
-                       pPrev = pNode;
-                       pNode = pNode->pNext;
-               }
-
-               // Now move it to freeList queue.
-               if (pNode)
-               {
-                       if (pNode == pAd->TimerQ.pQHead)
-                               pAd->TimerQ.pQHead = pNode->pNext;
-                       if (pNode == pAd->TimerQ.pQTail)
-                               pAd->TimerQ.pQTail = pPrev;
-                       if (pPrev != NULL)
-                               pPrev->pNext = pNode->pNext;
-
-                       // return this queue entry to timerQFreeList.
-                       pNode->pNext = pAd->TimerQ.pQPollFreeList;
-                       pAd->TimerQ.pQPollFreeList = pNode;
-               }
-       }
-       RTMP_IRQ_UNLOCK(&pAd->TimerQLock, irqFlags);
-
-       return TRUE;
-}
-
-
-void RT2870_TimerQ_Exit(RTMP_ADAPTER *pAd)
-{
-       RT2870_TIMER_ENTRY *pTimerQ;
-       unsigned long irqFlags;
-
-       RTMP_IRQ_LOCK(&pAd->TimerQLock, irqFlags);
-       while (pAd->TimerQ.pQHead)
-       {
-               pTimerQ = pAd->TimerQ.pQHead;
-               pAd->TimerQ.pQHead = pTimerQ->pNext;
-               // remove the timeQ
-       }
-       pAd->TimerQ.pQPollFreeList = NULL;
-       os_free_mem(pAd, pAd->TimerQ.pTimerQPoll);
-       pAd->TimerQ.pQTail = NULL;
-       pAd->TimerQ.pQHead = NULL;
-       pAd->TimerQ.status = RT2870_THREAD_STOPED;
-       RTMP_IRQ_UNLOCK(&pAd->TimerQLock, irqFlags);
-
-}
-
-
-void RT2870_TimerQ_Init(RTMP_ADAPTER *pAd)
-{
-       int     i;
-       RT2870_TIMER_ENTRY *pQNode, *pEntry;
-       unsigned long irqFlags;
-
-       NdisAllocateSpinLock(&pAd->TimerQLock);
-
-       RTMP_IRQ_LOCK(&pAd->TimerQLock, irqFlags);
-       NdisZeroMemory(&pAd->TimerQ, sizeof(pAd->TimerQ));
-       //InterlockedExchange(&pAd->TimerQ.count, 0);
-
-       /* Initialise the wait q head */
-       //init_waitqueue_head(&timerWaitQ);
-
-       os_alloc_mem(pAd, &pAd->TimerQ.pTimerQPoll, sizeof(RT2870_TIMER_ENTRY) * TIMER_QUEUE_SIZE_MAX);
-       if (pAd->TimerQ.pTimerQPoll)
-       {
-               pEntry = NULL;
-               pQNode = (RT2870_TIMER_ENTRY *)pAd->TimerQ.pTimerQPoll;
-               for (i = 0 ;i <TIMER_QUEUE_SIZE_MAX; i++)
-               {
-                       pQNode->pNext = pEntry;
-                       pEntry = pQNode;
-                       pQNode++;
-               }
-               pAd->TimerQ.pQPollFreeList = pEntry;
-               pAd->TimerQ.pQHead = NULL;
-               pAd->TimerQ.pQTail = NULL;
-               pAd->TimerQ.status = RT2870_THREAD_INITED;
-       }
-       RTMP_IRQ_UNLOCK(&pAd->TimerQLock, irqFlags);
-}
-
-
-VOID RT2870_WatchDog(IN RTMP_ADAPTER *pAd)
-{
-       PHT_TX_CONTEXT          pHTTXContext;
-       int                                     idx;
-       ULONG                           irqFlags;
-       PURB                            pUrb;
-       BOOLEAN                         needDumpSeq = FALSE;
-       UINT32                  MACValue;
-
-
-       idx = 0;
-       RTMP_IO_READ32(pAd, TXRXQ_PCNT, &MACValue);
-       if ((MACValue & 0xff) !=0 )
-       {
-               DBGPRINT(RT_DEBUG_TRACE, ("TX QUEUE 0 Not EMPTY(Value=0x%0x). !!!!!!!!!!!!!!!\n", MACValue));
-               RTMP_IO_WRITE32(pAd, PBF_CFG, 0xf40012);
-               while((MACValue &0xff) != 0 && (idx++ < 10))
-               {
-                       RTMP_IO_READ32(pAd, TXRXQ_PCNT, &MACValue);
-                       NdisMSleep(1);
-               }
-               RTMP_IO_WRITE32(pAd, PBF_CFG, 0xf40006);
-       }
-
-//PS packets use HCCA queue when dequeue from PS unicast queue (WiFi WPA2 MA9_DT1 for Marvell B STA)
-       {
-               idx = 0;
-               if ((MACValue & 0xff00) !=0 )
-               {
-                       DBGPRINT(RT_DEBUG_TRACE, ("TX QUEUE 1 Not EMPTY(Value=0x%0x). !!!!!!!!!!!!!!!\n", MACValue));
-                       RTMP_IO_WRITE32(pAd, PBF_CFG, 0xf4000a);
-                       while((MACValue &0xff00) != 0 && (idx++ < 10))
-                       {
-                               RTMP_IO_READ32(pAd, TXRXQ_PCNT, &MACValue);
-                               NdisMSleep(1);
-                       }
-                       RTMP_IO_WRITE32(pAd, PBF_CFG, 0xf40006);
-               }
-       }
-
-       if (pAd->watchDogRxOverFlowCnt >= 2)
-       {
-               DBGPRINT(RT_DEBUG_TRACE, ("Maybe the Rx Bulk-In hanged! Cancel the pending Rx bulks request!\n"));
-               if ((!RTMP_TEST_FLAG(pAd, (fRTMP_ADAPTER_RESET_IN_PROGRESS |
-                                                                       fRTMP_ADAPTER_BULKIN_RESET |
-                                                                       fRTMP_ADAPTER_HALT_IN_PROGRESS |
-                                                                       fRTMP_ADAPTER_NIC_NOT_EXIST))))
-               {
-                       DBGPRINT(RT_DEBUG_TRACE, ("Call CMDTHREAD_RESET_BULK_IN to cancel the pending Rx Bulk!\n"));
-                       RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_BULKIN_RESET);
-                       RTUSBEnqueueInternalCmd(pAd, CMDTHREAD_RESET_BULK_IN, NULL, 0);
-                       needDumpSeq = TRUE;
-               }
-               pAd->watchDogRxOverFlowCnt = 0;
-       }
-
-
-       for (idx = 0; idx < NUM_OF_TX_RING; idx++)
-       {
-               pUrb = NULL;
-
-               RTMP_IRQ_LOCK(&pAd->BulkOutLock[idx], irqFlags);
-               if ((pAd->BulkOutPending[idx] == TRUE) && pAd->watchDogTxPendingCnt)
-               {
-                       pAd->watchDogTxPendingCnt[idx]++;
-
-                       if ((pAd->watchDogTxPendingCnt[idx] > 2) &&
-                                (!RTMP_TEST_FLAG(pAd, (fRTMP_ADAPTER_RESET_IN_PROGRESS | fRTMP_ADAPTER_HALT_IN_PROGRESS | fRTMP_ADAPTER_NIC_NOT_EXIST | fRTMP_ADAPTER_BULKOUT_RESET)))
-                               )
-                       {
-                               // FIXME: Following code just support single bulk out. If you wanna support multiple bulk out. Modify it!
-                               pHTTXContext = (PHT_TX_CONTEXT)(&pAd->TxContext[idx]);
-                               if (pHTTXContext->IRPPending)
-                               {       // Check TxContext.
-                                       pUrb = pHTTXContext->pUrb;
-                               }
-                               else if (idx == MGMTPIPEIDX)
-                               {
-                                       PTX_CONTEXT pMLMEContext, pNULLContext, pPsPollContext;
-
-                                       //Check MgmtContext.
-                                       pMLMEContext = (PTX_CONTEXT)(pAd->MgmtRing.Cell[pAd->MgmtRing.TxDmaIdx].AllocVa);
-                                       pPsPollContext = (PTX_CONTEXT)(&pAd->PsPollContext);
-                                       pNULLContext = (PTX_CONTEXT)(&pAd->NullContext);
-
-                                       if (pMLMEContext->IRPPending)
-                                       {
-                                               ASSERT(pMLMEContext->IRPPending);
-                                               pUrb = pMLMEContext->pUrb;
-                                       }
-                                       else if (pNULLContext->IRPPending)
-                                       {
-                                               ASSERT(pNULLContext->IRPPending);
-                                               pUrb = pNULLContext->pUrb;
-                                       }
-                                       else if (pPsPollContext->IRPPending)
-                                       {
-                                               ASSERT(pPsPollContext->IRPPending);
-                                               pUrb = pPsPollContext->pUrb;
-                                       }
-                               }
-
-                               RTMP_IRQ_UNLOCK(&pAd->BulkOutLock[idx], irqFlags);
-
-                               DBGPRINT(RT_DEBUG_TRACE, ("Maybe the Tx Bulk-Out hanged! Cancel the pending Tx bulks request of idx(%d)!\n", idx));
-                               if (pUrb)
-                               {
-                                       DBGPRINT(RT_DEBUG_TRACE, ("Unlink the pending URB!\n"));
-                                       // unlink it now
-                                       RTUSB_UNLINK_URB(pUrb);
-                                       // Sleep 200 microseconds to give cancellation time to work
-                                       RTMPusecDelay(200);
-                                       needDumpSeq = TRUE;
-                               }
-                               else
-                               {
-                                       DBGPRINT(RT_DEBUG_ERROR, ("Unkonw bulkOut URB maybe hanged!!!!!!!!!!!!\n"));
-                               }
-                       }
-                       else
-                       {
-                               RTMP_IRQ_UNLOCK(&pAd->BulkOutLock[idx], irqFlags);
-                       }
-               }
-               else
-               {
-                       RTMP_IRQ_UNLOCK(&pAd->BulkOutLock[idx], irqFlags);
-               }
-       }
-
-       // For Sigma debug, dump the ba_reordering sequence.
-       if((needDumpSeq == TRUE) && (pAd->CommonCfg.bDisableReordering == 0))
-       {
-               USHORT                          Idx;
-               PBA_REC_ENTRY           pBAEntry = NULL;
-               UCHAR                           count = 0;
-               struct reordering_mpdu *mpdu_blk;
-
-               Idx = pAd->MacTab.Content[BSSID_WCID].BARecWcidArray[0];
-
-               pBAEntry = &pAd->BATable.BARecEntry[Idx];
-               if((pBAEntry->list.qlen > 0) && (pBAEntry->list.next != NULL))
-               {
-                       DBGPRINT(RT_DEBUG_TRACE, ("NICUpdateRawCounters():The Queueing pkt in reordering buffer:\n"));
-                       NdisAcquireSpinLock(&pBAEntry->RxReRingLock);
-                       mpdu_blk = pBAEntry->list.next;
-                       while (mpdu_blk)
-                       {
-                               DBGPRINT(RT_DEBUG_TRACE, ("\t%d:Seq-%d, bAMSDU-%d!\n", count, mpdu_blk->Sequence, mpdu_blk->bAMSDU));
-                               mpdu_blk = mpdu_blk->next;
-                               count++;
-                       }
-
-                       DBGPRINT(RT_DEBUG_TRACE, ("\npBAEntry->LastIndSeq=%d!\n", pBAEntry->LastIndSeq));
-                       NdisReleaseSpinLock(&pBAEntry->RxReRingLock);
-               }
-       }
-}
-
-/*
-========================================================================
-Routine Description:
-    Release allocated resources.
-
-Arguments:
-    *dev                               Point to the PCI or USB device
-       pAd                                     driver control block pointer
-
-Return Value:
-    None
-
-Note:
-========================================================================
-*/
-static void _rtusb_disconnect(struct usb_device *dev, PRTMP_ADAPTER pAd)
-{
-       struct net_device       *net_dev = NULL;
-
-
-       DBGPRINT(RT_DEBUG_ERROR, ("rtusb_disconnect: unregister usbnet usb-%s-%s\n",
-                               dev->bus->bus_name, dev->devpath));
-       if (!pAd)
-       {
-               usb_put_dev(dev);
-
-               printk("rtusb_disconnect: pAd == NULL!\n");
-               return;
-       }
-       RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_NIC_NOT_EXIST);
-
-
-
-       // for debug, wait to show some messages to /proc system
-       udelay(1);
-
-
-
-
-       net_dev = pAd->net_dev;
-       if (pAd->net_dev != NULL)
-       {
-               printk("rtusb_disconnect: unregister_netdev(), dev->name=%s!\n", net_dev->name);
-               unregister_netdev (pAd->net_dev);
-       }
-       udelay(1);
-       flush_scheduled_work();
-       udelay(1);
-
-       // free net_device memory
-       free_netdev(net_dev);
-
-       // free adapter memory
-       RTMPFreeAdapter(pAd);
-
-       // release a use of the usb device structure
-       usb_put_dev(dev);
-       udelay(1);
-
-       DBGPRINT(RT_DEBUG_ERROR, (" RTUSB disconnect successfully\n"));
-}
-
-
-/*
-========================================================================
-Routine Description:
-    Probe RT28XX chipset.
-
-Arguments:
-    *dev                               Point to the PCI or USB device
-       interface
-       *id_table                       Point to the PCI or USB device ID
-
-Return Value:
-    None
-
-Note:
-========================================================================
-*/
-static int rtusb_probe (struct usb_interface *intf,
-                                               const struct usb_device_id *id)
-{
-       PRTMP_ADAPTER pAd;
-       return (int)rt28xx_probe((void *)intf, (void *)id, 0, &pAd);
-}
-
-
-static void rtusb_disconnect(struct usb_interface *intf)
-{
-       struct usb_device   *dev = interface_to_usbdev(intf);
-       PRTMP_ADAPTER       pAd;
-
-
-       pAd = usb_get_intfdata(intf);
-       usb_set_intfdata(intf, NULL);
-
-       _rtusb_disconnect(dev, pAd);
-}
-
-
-/*
-========================================================================
-Routine Description:
-    Close kernel threads.
-
-Arguments:
-       *pAd                            the raxx interface data pointer
-
-Return Value:
-    NONE
-
-Note:
-========================================================================
-*/
-VOID RT28xxThreadTerminate(
-       IN RTMP_ADAPTER *pAd)
-{
-       POS_COOKIE      pObj = (POS_COOKIE) pAd->OS_Cookie;
-       INT                     ret;
-
-
-       // Sleep 50 milliseconds so pending io might finish normally
-       RTMPusecDelay(50000);
-
-       // We want to wait until all pending receives and sends to the
-       // device object. We cancel any
-       // irps. Wait until sends and receives have stopped.
-       RTUSBCancelPendingIRPs(pAd);
-
-       // Terminate Threads
-       if (pObj->MLMEThr_pid)
-       {
-               printk("Terminate the MLMEThr_pid=%d!\n", pid_nr(pObj->MLMEThr_pid));
-               mb();
-               pAd->mlme_kill = 1;
-               //RT28XX_MLME_HANDLER(pAd);
-               mb();
-               ret = kill_pid(pObj->MLMEThr_pid, SIGTERM, 1);
-               if (ret)
-               {
-                       printk (KERN_WARNING "%s: unable to Mlme thread, pid=%d, ret=%d!\n",
-                                       pAd->net_dev->name, pid_nr(pObj->MLMEThr_pid), ret);
-               }
-               else
-               {
-                       //wait_for_completion (&pAd->notify);
-                       wait_for_completion (&pAd->mlmeComplete);
-                       pObj->MLMEThr_pid = NULL;
-               }
-       }
-
-       if (pObj->RTUSBCmdThr_pid >= 0)
-       {
-               printk("Terminate the RTUSBCmdThr_pid=%d!\n", pid_nr(pObj->RTUSBCmdThr_pid));
-               mb();
-               NdisAcquireSpinLock(&pAd->CmdQLock);
-               pAd->CmdQ.CmdQState = RT2870_THREAD_STOPED;
-               NdisReleaseSpinLock(&pAd->CmdQLock);
-               mb();
-               //RTUSBCMDUp(pAd);
-               ret = kill_pid(pObj->RTUSBCmdThr_pid, SIGTERM, 1);
-               if (ret)
-               {
-                       printk(KERN_WARNING "%s: unable to RTUSBCmd thread, pid=%d, ret=%d!\n",
-                                       pAd->net_dev->name, pid_nr(pObj->RTUSBCmdThr_pid), ret);
-               }
-               else
-               {
-                       //wait_for_completion (&pAd->notify);
-                       wait_for_completion (&pAd->CmdQComplete);
-                       pObj->RTUSBCmdThr_pid = NULL;
-               }
-       }
-       if (pObj->TimerQThr_pid >= 0)
-       {
-               POS_COOKIE pObj = (POS_COOKIE)pAd->OS_Cookie;
-
-               printk("Terminate the TimerQThr_pid=%d!\n", pid_nr(pObj->TimerQThr_pid));
-               mb();
-               pAd->TimerFunc_kill = 1;
-               mb();
-               ret = kill_pid(pObj->TimerQThr_pid, SIGTERM, 1);
-               if (ret)
-               {
-                       printk(KERN_WARNING "%s: unable to stop TimerQThread, pid=%d, ret=%d!\n",
-                                       pAd->net_dev->name, pid_nr(pObj->TimerQThr_pid), ret);
-               }
-               else
-               {
-                       printk("wait_for_completion TimerQThr\n");
-                       wait_for_completion(&pAd->TimerQComplete);
-                       pObj->TimerQThr_pid = NULL;
-               }
-       }
-       // Kill tasklets
-       pAd->mlme_kill = 0;
-       pAd->CmdQ.CmdQState = RT2870_THREAD_UNKNOWN;
-       pAd->TimerFunc_kill = 0;
-}
-
-
-void kill_thread_task(IN PRTMP_ADAPTER pAd)
-{
-       POS_COOKIE pObj;
-
-       pObj = (POS_COOKIE) pAd->OS_Cookie;
-
-       tasklet_kill(&pObj->rx_done_task);
-       tasklet_kill(&pObj->mgmt_dma_done_task);
-       tasklet_kill(&pObj->ac0_dma_done_task);
-       tasklet_kill(&pObj->ac1_dma_done_task);
-       tasklet_kill(&pObj->ac2_dma_done_task);
-       tasklet_kill(&pObj->ac3_dma_done_task);
-       tasklet_kill(&pObj->hcca_dma_done_task);
-       tasklet_kill(&pObj->tbtt_task);
-
-}
-
-
-/*
-========================================================================
-Routine Description:
-    Check the chipset vendor/product ID.
-
-Arguments:
-    _dev_p                             Point to the PCI or USB device
-
-Return Value:
-    TRUE                               Check ok
-       FALSE                           Check fail
-
-Note:
-========================================================================
-*/
-BOOLEAN RT28XXChipsetCheck(
-       IN void *_dev_p)
-{
-       struct usb_interface *intf = (struct usb_interface *)_dev_p;
-       struct usb_device *dev_p = interface_to_usbdev(intf);
-       UINT32 i;
-
-
-       for(i=0; i<rtusb_usb_id_len; i++)
-       {
-               if (dev_p->descriptor.idVendor == rtusb_usb_id[i].idVendor &&
-                       dev_p->descriptor.idProduct == rtusb_usb_id[i].idProduct)
-               {
-                       printk("rt2870: idVendor = 0x%x, idProduct = 0x%x\n",
-                                       dev_p->descriptor.idVendor, dev_p->descriptor.idProduct);
-                       break;
-               }
-       }
-
-       if (i == rtusb_usb_id_len)
-       {
-               printk("rt2870: Error! Device Descriptor not matching!\n");
-               return FALSE;
-       }
-
-       return TRUE;
-}
-
-
-/*
-========================================================================
-Routine Description:
-    Init net device structure.
-
-Arguments:
-    _dev_p                             Point to the PCI or USB device
-    *net_dev                   Point to the net device
-       *pAd                            the raxx interface data pointer
-
-Return Value:
-    TRUE                               Init ok
-       FALSE                           Init fail
-
-Note:
-========================================================================
-*/
-BOOLEAN RT28XXNetDevInit(
-       IN void                                 *_dev_p,
-       IN struct  net_device   *net_dev,
-       IN RTMP_ADAPTER                 *pAd)
-{
-       struct usb_interface *intf = (struct usb_interface *)_dev_p;
-       struct usb_device *dev_p = interface_to_usbdev(intf);
-
-
-       pAd->config = &dev_p->config->desc;
-       return TRUE;
-}
-
-
-/*
-========================================================================
-Routine Description:
-    Init net device structure.
-
-Arguments:
-    _dev_p                             Point to the PCI or USB device
-       *pAd                            the raxx interface data pointer
-
-Return Value:
-    TRUE                               Config ok
-       FALSE                           Config fail
-
-Note:
-========================================================================
-*/
-BOOLEAN RT28XXProbePostConfig(
-       IN void                                 *_dev_p,
-       IN RTMP_ADAPTER                 *pAd,
-       IN INT32                                interface)
-{
-       struct usb_interface *intf = (struct usb_interface *)_dev_p;
-       struct usb_host_interface *iface_desc;
-       ULONG BulkOutIdx;
-       UINT32 i;
-
-
-       /* get the active interface descriptor */
-       iface_desc = intf->cur_altsetting;
-
-       /* get # of enpoints  */
-       pAd->NumberOfPipes = iface_desc->desc.bNumEndpoints;
-       DBGPRINT(RT_DEBUG_TRACE,
-                       ("NumEndpoints=%d\n", iface_desc->desc.bNumEndpoints));
-
-       /* Configure Pipes */
-       BulkOutIdx = 0;
-
-       for(i=0; i<pAd->NumberOfPipes; i++)
-       {
-               if ((iface_desc->endpoint[i].desc.bmAttributes ==
-                               USB_ENDPOINT_XFER_BULK) &&
-                       ((iface_desc->endpoint[i].desc.bEndpointAddress &
-                               USB_ENDPOINT_DIR_MASK) == USB_DIR_IN))
-               {
-                       pAd->BulkInEpAddr = iface_desc->endpoint[i].desc.bEndpointAddress;
-                       pAd->BulkInMaxPacketSize = iface_desc->endpoint[i].desc.wMaxPacketSize;
-
-                       DBGPRINT_RAW(RT_DEBUG_TRACE,
-                               ("BULK IN MaximumPacketSize = %d\n", pAd->BulkInMaxPacketSize));
-                       DBGPRINT_RAW(RT_DEBUG_TRACE,
-                               ("EP address = 0x%2x\n", iface_desc->endpoint[i].desc.bEndpointAddress));
-               }
-               else if ((iface_desc->endpoint[i].desc.bmAttributes ==
-                                       USB_ENDPOINT_XFER_BULK) &&
-                               ((iface_desc->endpoint[i].desc.bEndpointAddress &
-                                       USB_ENDPOINT_DIR_MASK) == USB_DIR_OUT))
-               {
-                       // there are 6 bulk out EP. EP6 highest priority.
-                       // EP1-4 is EDCA.  EP5 is HCCA.
-                       pAd->BulkOutEpAddr[BulkOutIdx++] = iface_desc->endpoint[i].desc.bEndpointAddress;
-                       pAd->BulkOutMaxPacketSize = iface_desc->endpoint[i].desc.wMaxPacketSize;
-
-                       DBGPRINT_RAW(RT_DEBUG_TRACE,
-                               ("BULK OUT MaximumPacketSize = %d\n", pAd->BulkOutMaxPacketSize));
-                       DBGPRINT_RAW(RT_DEBUG_TRACE,
-                               ("EP address = 0x%2x  \n", iface_desc->endpoint[i].desc.bEndpointAddress));
-               }
-       }
-
-       if (!(pAd->BulkInEpAddr && pAd->BulkOutEpAddr[0]))
-       {
-               printk("%s: Could not find both bulk-in and bulk-out endpoints\n", __func__);
-               return FALSE;
-       }
-
-       return TRUE;
-}
-
-
-/*
-========================================================================
-Routine Description:
-    Disable DMA.
-
-Arguments:
-       *pAd                            the raxx interface data pointer
-
-Return Value:
-       None
-
-Note:
-========================================================================
-*/
-VOID RT28XXDMADisable(
-       IN RTMP_ADAPTER                 *pAd)
-{
-       // no use
-}
-
-
-
-/*
-========================================================================
-Routine Description:
-    Enable DMA.
-
-Arguments:
-       *pAd                            the raxx interface data pointer
-
-Return Value:
-       None
-
-Note:
-========================================================================
-*/
-VOID RT28XXDMAEnable(
-       IN RTMP_ADAPTER                 *pAd)
-{
-       WPDMA_GLO_CFG_STRUC     GloCfg;
-       USB_DMA_CFG_STRUC       UsbCfg;
-       int                                     i = 0;
-
-
-       RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, 0x4);
-       do
-       {
-               RTMP_IO_READ32(pAd, WPDMA_GLO_CFG, &GloCfg.word);
-               if ((GloCfg.field.TxDMABusy == 0)  && (GloCfg.field.RxDMABusy == 0))
-                       break;
-
-               DBGPRINT(RT_DEBUG_TRACE, ("==>  DMABusy\n"));
-               RTMPusecDelay(1000);
-               i++;
-       }while ( i <200);
-
-
-       RTMPusecDelay(50);
-       GloCfg.field.EnTXWriteBackDDONE = 1;
-       GloCfg.field.EnableRxDMA = 1;
-       GloCfg.field.EnableTxDMA = 1;
-       DBGPRINT(RT_DEBUG_TRACE, ("<== WRITE DMA offset 0x208 = 0x%x\n", GloCfg.word));
-       RTMP_IO_WRITE32(pAd, WPDMA_GLO_CFG, GloCfg.word);
-
-       UsbCfg.word = 0;
-       UsbCfg.field.phyclear = 0;
-       /* usb version is 1.1,do not use bulk in aggregation */
-       if (pAd->BulkInMaxPacketSize == 512)
-                       UsbCfg.field.RxBulkAggEn = 1;
-       /* for last packet, PBF might use more than limited, so minus 2 to prevent from error */
-       UsbCfg.field.RxBulkAggLmt = (MAX_RXBULK_SIZE /1024)-3;
-       UsbCfg.field.RxBulkAggTOut = 0x80; /* 2006-10-18 */
-       UsbCfg.field.RxBulkEn = 1;
-       UsbCfg.field.TxBulkEn = 1;
-
-       RTUSBWriteMACRegister(pAd, USB_DMA_CFG, UsbCfg.word);
-
-}
-
-/*
-========================================================================
-Routine Description:
-    Write Beacon buffer to Asic.
-
-Arguments:
-       *pAd                            the raxx interface data pointer
-
-Return Value:
-       None
-
-Note:
-========================================================================
-*/
-VOID RT28xx_UpdateBeaconToAsic(
-       IN RTMP_ADAPTER         *pAd,
-       IN INT                          apidx,
-       IN ULONG                        FrameLen,
-       IN ULONG                        UpdatePos)
-{
-       PUCHAR          pBeaconFrame = NULL;
-       UCHAR                   *ptr;
-       UINT                    i, padding;
-       BEACON_SYNC_STRUCT      *pBeaconSync = pAd->CommonCfg.pBeaconSync;
-       UINT32                  longValue;
-       BOOLEAN                 bBcnReq = FALSE;
-       UCHAR                   bcn_idx = 0;
-
-
-       if (pBeaconFrame == NULL)
-       {
-               DBGPRINT(RT_DEBUG_ERROR,("pBeaconFrame is NULL!\n"));
-               return;
-       }
-
-       if (pBeaconSync == NULL)
-       {
-               DBGPRINT(RT_DEBUG_ERROR,("pBeaconSync is NULL!\n"));
-               return;
-       }
-
-       //if ((pAd->WdsTab.Mode == WDS_BRIDGE_MODE) ||
-       //      ((pAd->ApCfg.MBSSID[apidx].MSSIDDev == NULL) || !(pAd->ApCfg.MBSSID[apidx].MSSIDDev->flags & IFF_UP))
-       //      )
-       if (bBcnReq == FALSE)
-       {
-               /* when the ra interface is down, do not send its beacon frame */
-               /* clear all zero */
-               for(i=0; i<TXWI_SIZE; i+=4) {
-                       RTMP_IO_WRITE32(pAd, pAd->BeaconOffset[bcn_idx] + i, 0x00);
-               }
-               pBeaconSync->BeaconBitMap &= (~(BEACON_BITMAP_MASK & (1 << bcn_idx)));
-               NdisZeroMemory(pBeaconSync->BeaconTxWI[bcn_idx], TXWI_SIZE);
-       }
-       else
-       {
-               ptr = (PUCHAR)&pAd->BeaconTxWI;
-
-               if (NdisEqualMemory(pBeaconSync->BeaconTxWI[bcn_idx], &pAd->BeaconTxWI, TXWI_SIZE) == FALSE)
-               {       // If BeaconTxWI changed, we need to rewrite the TxWI for the Beacon frames.
-                       pBeaconSync->BeaconBitMap &= (~(BEACON_BITMAP_MASK & (1 << bcn_idx)));
-                       NdisMoveMemory(pBeaconSync->BeaconTxWI[bcn_idx], &pAd->BeaconTxWI, TXWI_SIZE);
-               }
-
-               if ((pBeaconSync->BeaconBitMap & (1 << bcn_idx)) != (1 << bcn_idx))
-               {
-                       for (i=0; i<TXWI_SIZE; i+=4)  // 16-byte TXWI field
-                       {
-                               longValue =  *ptr + (*(ptr+1)<<8) + (*(ptr+2)<<16) + (*(ptr+3)<<24);
-                               RTMP_IO_WRITE32(pAd, pAd->BeaconOffset[bcn_idx] + i, longValue);
-                               ptr += 4;
-                       }
-               }
-
-               ptr = pBeaconSync->BeaconBuf[bcn_idx];
-               padding = (FrameLen & 0x01);
-               NdisZeroMemory((PUCHAR)(pBeaconFrame + FrameLen), padding);
-               FrameLen += padding;
-               for (i = 0 ; i < FrameLen /*HW_BEACON_OFFSET*/; i += 2)
-               {
-                       if (NdisEqualMemory(ptr, pBeaconFrame, 2) == FALSE)
-                       {
-                               NdisMoveMemory(ptr, pBeaconFrame, 2);
-                               //shortValue = *ptr + (*(ptr+1)<<8);
-                               //RTMP_IO_WRITE8(pAd, pAd->BeaconOffset[bcn_idx] + TXWI_SIZE + i, shortValue);
-                               RTUSBMultiWrite(pAd, pAd->BeaconOffset[bcn_idx] + TXWI_SIZE + i, ptr, 2);
-                       }
-                       ptr +=2;
-                       pBeaconFrame += 2;
-               }
-
-               pBeaconSync->BeaconBitMap |= (1 << bcn_idx);
-
-               // For AP interface, set the DtimBitOn so that we can send Bcast/Mcast frame out after this beacon frame.
-       }
-
-}
-
-
-VOID RT2870_BssBeaconStop(
-       IN RTMP_ADAPTER *pAd)
-{
-       BEACON_SYNC_STRUCT      *pBeaconSync;
-       int i, offset;
-       BOOLEAN Cancelled = TRUE;
-
-       pBeaconSync = pAd->CommonCfg.pBeaconSync;
-       if (pBeaconSync && pBeaconSync->EnableBeacon)
-       {
-               INT NumOfBcn;
-
-               NumOfBcn = MAX_MESH_NUM;
-
-               RTMPCancelTimer(&pAd->CommonCfg.BeaconUpdateTimer, &Cancelled);
-
-               for(i=0; i<NumOfBcn; i++)
-               {
-                       NdisZeroMemory(pBeaconSync->BeaconBuf[i], HW_BEACON_OFFSET);
-                       NdisZeroMemory(pBeaconSync->BeaconTxWI[i], TXWI_SIZE);
-
-                       for (offset=0; offset<HW_BEACON_OFFSET; offset+=4)
-                               RTMP_IO_WRITE32(pAd, pAd->BeaconOffset[i] + offset, 0x00);
-
-                       pBeaconSync->CapabilityInfoLocationInBeacon[i] = 0;
-                       pBeaconSync->TimIELocationInBeacon[i] = 0;
-               }
-               pBeaconSync->BeaconBitMap = 0;
-               pBeaconSync->DtimBitOn = 0;
-       }
-}
-
-
-VOID RT2870_BssBeaconStart(
-       IN RTMP_ADAPTER *pAd)
-{
-       int apidx;
-       BEACON_SYNC_STRUCT      *pBeaconSync;
-//     LARGE_INTEGER   tsfTime, deltaTime;
-
-       pBeaconSync = pAd->CommonCfg.pBeaconSync;
-       if (pBeaconSync && pBeaconSync->EnableBeacon)
-       {
-               INT NumOfBcn;
-
-               NumOfBcn = MAX_MESH_NUM;
-
-               for(apidx=0; apidx<NumOfBcn; apidx++)
-               {
-                       UCHAR CapabilityInfoLocationInBeacon = 0;
-                       UCHAR TimIELocationInBeacon = 0;
-
-                       NdisZeroMemory(pBeaconSync->BeaconBuf[apidx], HW_BEACON_OFFSET);
-                       pBeaconSync->CapabilityInfoLocationInBeacon[apidx] = CapabilityInfoLocationInBeacon;
-                       pBeaconSync->TimIELocationInBeacon[apidx] = TimIELocationInBeacon;
-                       NdisZeroMemory(pBeaconSync->BeaconTxWI[apidx], TXWI_SIZE);
-               }
-               pBeaconSync->BeaconBitMap = 0;
-               pBeaconSync->DtimBitOn = 0;
-               pAd->CommonCfg.BeaconUpdateTimer.Repeat = TRUE;
-
-               pAd->CommonCfg.BeaconAdjust = 0;
-               pAd->CommonCfg.BeaconFactor = 0xffffffff / (pAd->CommonCfg.BeaconPeriod << 10);
-               pAd->CommonCfg.BeaconRemain = (0xffffffff % (pAd->CommonCfg.BeaconPeriod << 10)) + 1;
-               printk("RT2870_BssBeaconStart:BeaconFactor=%d, BeaconRemain=%d!\n", pAd->CommonCfg.BeaconFactor, pAd->CommonCfg.BeaconRemain);
-               RTMPSetTimer(&pAd->CommonCfg.BeaconUpdateTimer, pAd->CommonCfg.BeaconPeriod);
-
-       }
-}
-
-
-VOID RT2870_BssBeaconInit(
-       IN RTMP_ADAPTER *pAd)
-{
-       BEACON_SYNC_STRUCT      *pBeaconSync;
-       int i;
-
-       NdisAllocMemory(pAd->CommonCfg.pBeaconSync, sizeof(BEACON_SYNC_STRUCT), MEM_ALLOC_FLAG);
-       if (pAd->CommonCfg.pBeaconSync)
-       {
-               pBeaconSync = pAd->CommonCfg.pBeaconSync;
-               NdisZeroMemory(pBeaconSync, sizeof(BEACON_SYNC_STRUCT));
-               for(i=0; i < HW_BEACON_MAX_COUNT; i++)
-               {
-                       NdisZeroMemory(pBeaconSync->BeaconBuf[i], HW_BEACON_OFFSET);
-                       pBeaconSync->CapabilityInfoLocationInBeacon[i] = 0;
-                       pBeaconSync->TimIELocationInBeacon[i] = 0;
-                       NdisZeroMemory(pBeaconSync->BeaconTxWI[i], TXWI_SIZE);
-               }
-               pBeaconSync->BeaconBitMap = 0;
-
-               //RTMPInitTimer(pAd, &pAd->CommonCfg.BeaconUpdateTimer, GET_TIMER_FUNCTION(BeaconUpdateExec), pAd, TRUE);
-               pBeaconSync->EnableBeacon = TRUE;
-       }
-}
-
-
-VOID RT2870_BssBeaconExit(
-       IN RTMP_ADAPTER *pAd)
-{
-       BEACON_SYNC_STRUCT      *pBeaconSync;
-       BOOLEAN Cancelled = TRUE;
-       int i;
-
-       if (pAd->CommonCfg.pBeaconSync)
-       {
-               pBeaconSync = pAd->CommonCfg.pBeaconSync;
-               pBeaconSync->EnableBeacon = FALSE;
-               RTMPCancelTimer(&pAd->CommonCfg.BeaconUpdateTimer, &Cancelled);
-               pBeaconSync->BeaconBitMap = 0;
-
-               for(i=0; i<HW_BEACON_MAX_COUNT; i++)
-               {
-                       NdisZeroMemory(pBeaconSync->BeaconBuf[i], HW_BEACON_OFFSET);
-                       pBeaconSync->CapabilityInfoLocationInBeacon[i] = 0;
-                       pBeaconSync->TimIELocationInBeacon[i] = 0;
-                       NdisZeroMemory(pBeaconSync->BeaconTxWI[i], TXWI_SIZE);
-               }
-
-               NdisFreeMemory(pAd->CommonCfg.pBeaconSync, HW_BEACON_OFFSET * HW_BEACON_MAX_COUNT, 0);
-               pAd->CommonCfg.pBeaconSync = NULL;
-       }
-}
-
-VOID BeaconUpdateExec(
-    IN PVOID SystemSpecific1,
-    IN PVOID FunctionContext,
-    IN PVOID SystemSpecific2,
-    IN PVOID SystemSpecific3)
-{
-       PRTMP_ADAPTER   pAd = (PRTMP_ADAPTER)FunctionContext;
-       LARGE_INTEGER   tsfTime_a;//, tsfTime_b, deltaTime_exp, deltaTime_ab;
-       UINT32                  delta, remain, remain_low, remain_high;
-//     BOOLEAN                 positive;
-
-       ReSyncBeaconTime(pAd);
-
-
-
-       RTMP_IO_READ32(pAd, TSF_TIMER_DW0, &tsfTime_a.u.LowPart);
-       RTMP_IO_READ32(pAd, TSF_TIMER_DW1, &tsfTime_a.u.HighPart);
-
-
-       //positive=getDeltaTime(tsfTime_a, expectedTime, &deltaTime_exp);
-       remain_high = pAd->CommonCfg.BeaconRemain * tsfTime_a.u.HighPart;
-       remain_low = tsfTime_a.u.LowPart % (pAd->CommonCfg.BeaconPeriod << 10);
-       remain = (remain_high + remain_low)%(pAd->CommonCfg.BeaconPeriod << 10);
-       delta = (pAd->CommonCfg.BeaconPeriod << 10) - remain;
-
-       pAd->CommonCfg.BeaconUpdateTimer.TimerValue = (delta >> 10) + 10;
-
-}
-
+#include "../rt2870/2870_main_dev.c"
index cfc2a5f8d1aa41eb73333a762c243a9ccae004d9..345fa8922ed313c36a837dfe47898481f4290c57 100644 (file)
@@ -1,61 +1 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify  *
- * it under the terms of the GNU General Public License as published by  *
- * the Free Software Foundation; either version 2 of the License, or     *
- * (at your option) any later version.                                   *
- *                                                                       *
- * 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.                          *
- *                                                                       *
- * You should have received a copy of the GNU General Public License     *
- * along with this program; if not, write to the                         *
- * Free Software Foundation, Inc.,                                       *
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- *                                                                       *
- *************************************************************************
-
-       Module Name:
-       aironet.h
-
-       Abstract:
-
-       Revision History:
-       Who                     When                    What
-       --------        ----------              ----------------------------------------------
-       Name            Date                    Modification logs
-       Paul Lin        04-06-15                Initial
-*/
-
-#ifndef        __ACTION_H__
-#define        __ACTION_H__
-
-typedef struct PACKED __HT_INFO_OCTET
-{
-       UCHAR   Request:1;
-       UCHAR   Forty_MHz_Intolerant:1;
-       UCHAR   STA_Channel_Width:1;
-       UCHAR   Reserved:5;
-} HT_INFORMATION_OCTET;
-
-
-typedef struct PACKED __FRAME_HT_INFO
-{
-       HEADER_802_11                   Hdr;
-       UCHAR                                   Category;
-       UCHAR                                   Action;
-       HT_INFORMATION_OCTET    HT_Info;
-}   FRAME_HT_INFO, *PFRAME_HT_INFO;
-
-#endif /* __ACTION_H__ */
-
-
+#include "../rt2870/common/action.h"
index 1e07b19b8cdc945f8eee7f1ebad729db27ab3c02..78088f2087efdc5ff72acb57cc565fc20a3837f2 100644 (file)
@@ -1,210 +1 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify  *
- * it under the terms of the GNU General Public License as published by  *
- * the Free Software Foundation; either version 2 of the License, or     *
- * (at your option) any later version.                                   *
- *                                                                       *
- * 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.                          *
- *                                                                       *
- * You should have received a copy of the GNU General Public License     *
- * along with this program; if not, write to the                         *
- * Free Software Foundation, Inc.,                                       *
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- *                                                                       *
- *************************************************************************
-
-       Module Name:
-       aironet.h
-
-       Abstract:
-
-       Revision History:
-       Who                     When                    What
-       --------        ----------              ----------------------------------------------
-       Name            Date                    Modification logs
-       Paul Lin        04-06-15                Initial
-*/
-
-#ifndef        __AIRONET_H__
-#define        __AIRONET_H__
-
-// Measurement Type definition
-#define        MSRN_TYPE_UNUSED                                0
-#define        MSRN_TYPE_CHANNEL_LOAD_REQ              1
-#define        MSRN_TYPE_NOISE_HIST_REQ                2
-#define        MSRN_TYPE_BEACON_REQ                    3
-#define        MSRN_TYPE_FRAME_REQ                             4
-
-// Scan Mode in Beacon Request
-#define        MSRN_SCAN_MODE_PASSIVE                  0
-#define        MSRN_SCAN_MODE_ACTIVE                   1
-#define        MSRN_SCAN_MODE_BEACON_TABLE             2
-
-// PHY type definition for Aironet beacon report, CCX 2 table 36-9
-#define        PHY_FH                                                  1
-#define        PHY_DSS                                                 2
-#define        PHY_UNUSED                                              3
-#define        PHY_OFDM                                                4
-#define        PHY_HR_DSS                                              5
-#define        PHY_ERP                                                 6
-
-// RPI table in dBm
-#define        RPI_0                   0                       //      Power <= -87
-#define        RPI_1                   1                       //      -87 < Power <= -82
-#define        RPI_2                   2                       //      -82 < Power <= -77
-#define        RPI_3                   3                       //      -77 < Power <= -72
-#define        RPI_4                   4                       //      -72 < Power <= -67
-#define        RPI_5                   5                       //      -67 < Power <= -62
-#define        RPI_6                   6                       //      -62 < Power <= -57
-#define        RPI_7                   7                       //      -57 < Power
-
-// Cisco Aironet IAPP definetions
-#define        AIRONET_IAPP_TYPE                                       0x32
-#define        AIRONET_IAPP_SUBTYPE_REQUEST            0x01
-#define        AIRONET_IAPP_SUBTYPE_REPORT                     0x81
-
-// Measurement Request detail format
-typedef        struct  _MEASUREMENT_REQUEST    {
-       UCHAR   Channel;
-       UCHAR   ScanMode;                       // Use only in beacon request, other requests did not use this field
-       USHORT  Duration;
-}      MEASUREMENT_REQUEST, *PMEASUREMENT_REQUEST;
-
-// Beacon Measurement Report
-// All these field might change to UCHAR, because we didn't do anything to these report.
-// We copy all these beacons and report to CCX 2 AP.
-typedef        struct  _BEACON_REPORT  {
-       UCHAR   Channel;
-       UCHAR   Spare;
-       USHORT  Duration;
-       UCHAR   PhyType;                        // Definiation is listed above table 36-9
-       UCHAR   RxPower;
-       UCHAR   BSSID[6];
-       UCHAR   ParentTSF[4];
-       UCHAR   TargetTSF[8];
-       USHORT  BeaconInterval;
-       USHORT  CapabilityInfo;
-}      BEACON_REPORT, *PBEACON_REPORT;
-
-// Frame Measurement Report (Optional)
-typedef        struct  _FRAME_REPORT   {
-       UCHAR   Channel;
-       UCHAR   Spare;
-       USHORT  Duration;
-       UCHAR   TA;
-       UCHAR   BSSID[6];
-       UCHAR   RSSI;
-       UCHAR   Count;
-}      FRAME_REPORT, *PFRAME_REPORT;
-
-#pragma pack(1)
-// Channel Load Report
-typedef        struct  _CHANNEL_LOAD_REPORT    {
-       UCHAR   Channel;
-       UCHAR   Spare;
-       USHORT  Duration;
-       UCHAR   CCABusy;
-}      CHANNEL_LOAD_REPORT, *PCHANNEL_LOAD_REPORT;
-#pragma pack()
-
-// Nosie Histogram Report
-typedef        struct  _NOISE_HIST_REPORT      {
-       UCHAR   Channel;
-       UCHAR   Spare;
-       USHORT  Duration;
-       UCHAR   Density[8];
-}      NOISE_HIST_REPORT, *PNOISE_HIST_REPORT;
-
-// Radio Management Capability element
-typedef        struct  _RADIO_MANAGEMENT_CAPABILITY    {
-       UCHAR   Eid;                            // TODO: Why the Eid is 1 byte, not normal 2 bytes???
-       UCHAR   Length;
-       UCHAR   AironetOui[3];          // AIronet OUI (00 40 96)
-       UCHAR   Type;                           // Type / Version
-       USHORT  Status;                         // swap16 required
-}      RADIO_MANAGEMENT_CAPABILITY, *PRADIO_MANAGEMENT_CAPABILITY;
-
-// Measurement Mode Bit definition
-typedef        struct  _MEASUREMENT_MODE       {
-       UCHAR   Rsvd:4;
-       UCHAR   Report:1;
-       UCHAR   NotUsed:1;
-       UCHAR   Enable:1;
-       UCHAR   Parallel:1;
-}      MEASUREMENT_MODE, *PMEASUREMENT_MODE;
-
-// Measurement Request element, This is little endian mode
-typedef        struct  _MEASUREMENT_REQUEST_ELEMENT    {
-       USHORT                          Eid;
-       USHORT                          Length;                         // swap16 required
-       USHORT                          Token;                          // non-zero unique token
-       UCHAR                           Mode;                           // Measurement Mode
-       UCHAR                           Type;                           // Measurement type
-}      MEASUREMENT_REQUEST_ELEMENT, *PMEASUREMENT_REQUEST_ELEMENT;
-
-// Measurement Report element, This is little endian mode
-typedef        struct  _MEASUREMENT_REPORT_ELEMENT     {
-       USHORT                          Eid;
-       USHORT                          Length;                         // swap16 required
-       USHORT                          Token;                          // non-zero unique token
-       UCHAR                           Mode;                           // Measurement Mode
-       UCHAR                           Type;                           // Measurement type
-}      MEASUREMENT_REPORT_ELEMENT, *PMEASUREMENT_REPORT_ELEMENT;
-
-// Cisco Aironet IAPP Frame Header, Network byte order used
-typedef        struct  _AIRONET_IAPP_HEADER {
-       UCHAR   CiscoSnapHeader[8];     // 8 bytes Cisco snap header
-       USHORT  Length;                         // IAPP ID & length, remember to swap16 in LE system
-       UCHAR   Type;                           // IAPP type
-       UCHAR   SubType;                        // IAPP subtype
-       UCHAR   DA[6];                          // Destination MAC address
-       UCHAR   SA[6];                          // Source MAC address
-       USHORT  Token;                          // Dialog token, no need to swap16 since it is for yoken usage only
-}      AIRONET_IAPP_HEADER, *PAIRONET_IAPP_HEADER;
-
-// Radio Measurement Request frame
-typedef        struct  _AIRONET_RM_REQUEST_FRAME       {
-    AIRONET_IAPP_HEADER        IAPP;                   // Common header
-       UCHAR                           Delay;                  // Activation Delay
-       UCHAR                           Offset;                 // Measurement offset
-}      AIRONET_RM_REQUEST_FRAME, *PAIRONET_RM_REQUEST_FRAME;
-
-// Radio Measurement Report frame
-typedef        struct  _AIRONET_RM_REPORT_FRAME        {
-    AIRONET_IAPP_HEADER        IAPP;                   // Common header
-}      AIRONET_RM_REPORT_FRAME, *PAIRONET_RM_REPORT_FRAME;
-
-// Saved element request actions which will saved in StaCfg.
-typedef        struct  _RM_REQUEST_ACTION      {
-       MEASUREMENT_REQUEST_ELEMENT     ReqElem;                // Saved request element
-       MEASUREMENT_REQUEST                     Measurement;    // Saved measurement within the request element
-}      RM_REQUEST_ACTION, *PRM_REQUEST_ACTION;
-
-// CCX administration control
-typedef        union   _CCX_CONTROL    {
-       struct  {
-               UINT32          Enable:1;                       // Enable CCX2
-               UINT32          LeapEnable:1;           // Enable LEAP at CCX2
-               UINT32          RMEnable:1;                     // Radio Measurement Enable
-               UINT32          DCRMEnable:1;           // Non serving channel Radio Measurement enable
-               UINT32          QOSEnable:1;            // Enable QOS for CCX 2.0 support
-               UINT32          FastRoamEnable:1;       // Enable fast roaming
-               UINT32          Rsvd:2;                         // Not used
-               UINT32          dBmToRoam:8;            // the condition to roam when receiving Rssi less than this value. It's negative value.
-               UINT32          TuLimit:16;                     // Limit for different channel scan
-       }       field;
-       UINT32                  word;
-}      CCX_CONTROL, *PCCX_CONTROL;
-
-#endif // __AIRONET_H__
+#include "../rt2870/aironet.h"
index 92818845f8480a63dac2f3be168e673216bb608f..ab8de4bbad04f0c247c07ed3c6dda975fa3c488f 100644 (file)
@@ -1,532 +1 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify  *
- * it under the terms of the GNU General Public License as published by  *
- * the Free Software Foundation; either version 2 of the License, or     *
- * (at your option) any later version.                                   *
- *                                                                       *
- * 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.                          *
- *                                                                       *
- * You should have received a copy of the GNU General Public License     *
- * along with this program; if not, write to the                         *
- * Free Software Foundation, Inc.,                                       *
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- *                                                                       *
- *************************************************************************
-
-    Module Name:
-    ap.h
-
-    Abstract:
-    Miniport generic portion header file
-
-    Revision History:
-    Who         When          What
-    --------    ----------    ----------------------------------------------
-    Paul Lin    08-01-2002    created
-    James Tan   09-06-2002    modified (Revise NTCRegTable)
-    John Chang  12-22-2004    modified for RT2561/2661. merge with STA driver
-*/
-#ifndef __AP_H__
-#define __AP_H__
-
-
-
-// ========================= AP RTMP.h ================================
-
-
-
-// =============================================================
-//      Function Prototypes
-// =============================================================
-
-// ap_data.c
-
-BOOLEAN APBridgeToWirelessSta(
-    IN  PRTMP_ADAPTER   pAd,
-    IN  PUCHAR          pHeader,
-    IN  UINT            HdrLen,
-    IN  PUCHAR          pData,
-    IN  UINT            DataLen,
-    IN  ULONG           fromwdsidx);
-
-BOOLEAN APHandleRxDoneInterrupt(
-    IN  PRTMP_ADAPTER   pAd);
-
-VOID   APSendPackets(
-       IN      NDIS_HANDLE             MiniportAdapterContext,
-       IN      PPNDIS_PACKET   ppPacketArray,
-       IN      UINT                    NumberOfPackets);
-
-NDIS_STATUS APSendPacket(
-    IN  PRTMP_ADAPTER   pAd,
-    IN  PNDIS_PACKET    pPacket);
-
-
-NDIS_STATUS APHardTransmit(
-       IN      PRTMP_ADAPTER   pAd,
-       IN      TX_BLK                  *pTxBlk,
-       IN      UCHAR                   QueIdx);
-
-VOID APRxEAPOLFrameIndicate(
-       IN      PRTMP_ADAPTER   pAd,
-       IN      MAC_TABLE_ENTRY *pEntry,
-       IN      RX_BLK                  *pRxBlk,
-       IN      UCHAR                   FromWhichBSSID);
-
-NDIS_STATUS APCheckRxError(
-       IN      PRTMP_ADAPTER   pAd,
-       IN      PRT28XX_RXD_STRUC               pRxD,
-       IN      UCHAR                   Wcid);
-
-BOOLEAN APCheckClass2Class3Error(
-    IN  PRTMP_ADAPTER   pAd,
-       IN ULONG Wcid,
-       IN  PHEADER_802_11  pHeader);
-
-VOID APHandleRxPsPoll(
-       IN      PRTMP_ADAPTER   pAd,
-       IN      PUCHAR                  pAddr,
-       IN      USHORT                  Aid,
-    IN BOOLEAN                 isActive);
-
-VOID    RTMPDescriptorEndianChange(
-    IN  PUCHAR          pData,
-    IN  ULONG           DescriptorType);
-
-VOID    RTMPFrameEndianChange(
-    IN  PRTMP_ADAPTER   pAd,
-    IN  PUCHAR          pData,
-    IN  ULONG           Dir,
-    IN  BOOLEAN         FromRxDoneInt);
-
-// ap_assoc.c
-
-VOID APAssocStateMachineInit(
-    IN  PRTMP_ADAPTER   pAd,
-    IN  STATE_MACHINE *S,
-    OUT STATE_MACHINE_FUNC Trans[]);
-
-VOID  APPeerAssocReqAction(
-    IN  PRTMP_ADAPTER   pAd,
-    IN  MLME_QUEUE_ELEM *Elem);
-
-VOID  APPeerReassocReqAction(
-    IN  PRTMP_ADAPTER   pAd,
-    IN  MLME_QUEUE_ELEM *Elem);
-
-VOID  APPeerDisassocReqAction(
-    IN  PRTMP_ADAPTER   pAd,
-    IN  MLME_QUEUE_ELEM *Elem);
-
-VOID MbssKickOutStas(
-       IN PRTMP_ADAPTER pAd,
-       IN INT apidx,
-       IN USHORT Reason);
-
-VOID APMlmeKickOutSta(
-    IN PRTMP_ADAPTER pAd,
-       IN PUCHAR pStaAddr,
-       IN UCHAR Wcid,
-       IN USHORT Reason);
-
-VOID APMlmeDisassocReqAction(
-    IN PRTMP_ADAPTER pAd,
-    IN MLME_QUEUE_ELEM *Elem);
-
-VOID  APCls3errAction(
-    IN  PRTMP_ADAPTER   pAd,
-       IN      ULONG Wcid,
-    IN PHEADER_802_11  pHeader);
-
-
-USHORT APBuildAssociation(
-    IN PRTMP_ADAPTER pAd,
-    IN MAC_TABLE_ENTRY *pEntry,
-    IN USHORT CapabilityInfo,
-    IN UCHAR  MaxSupportedRateIn500Kbps,
-    IN UCHAR  *RSN,
-    IN UCHAR  *pRSNLen,
-    IN BOOLEAN bWmmCapable,
-    IN ULONG  RalinkIe,
-       IN HT_CAPABILITY_IE             *pHtCapability,
-       IN UCHAR                 HtCapabilityLen,
-    OUT USHORT *pAid);
-
-// ap_auth.c
-
-void APAuthStateMachineInit(
-    IN PRTMP_ADAPTER pAd,
-    IN STATE_MACHINE *Sm,
-    OUT STATE_MACHINE_FUNC Trans[]);
-
-VOID APMlmeDeauthReqAction(
-    IN PRTMP_ADAPTER pAd,
-    IN MLME_QUEUE_ELEM *Elem);
-
-VOID APCls2errAction(
-    IN PRTMP_ADAPTER pAd,
-       IN      ULONG Wcid,
-    IN PHEADER_802_11  pHeader);
-
-// ap_authrsp.c
-
-VOID APAuthRspStateMachineInit(
-    IN PRTMP_ADAPTER pAd,
-    IN PSTATE_MACHINE Sm,
-    IN STATE_MACHINE_FUNC Trans[]);
-
-VOID APPeerAuthAtAuthRspIdleAction(
-    IN  PRTMP_ADAPTER   pAd,
-    IN  MLME_QUEUE_ELEM *Elem);
-
-VOID APPeerDeauthReqAction(
-    IN PRTMP_ADAPTER   pAd,
-    IN MLME_QUEUE_ELEM *Elem);
-
-VOID APPeerAuthSimpleRspGenAndSend(
-    IN  PRTMP_ADAPTER   pAd,
-    IN  PHEADER_802_11 pHdr80211,
-    IN  USHORT Alg,
-    IN  USHORT Seq,
-    IN  USHORT StatusCode);
-
-// ap_connect.c
-
-BOOLEAN BeaconTransmitRequired(
-       IN PRTMP_ADAPTER        pAd,
-       IN INT                          apidx);
-
-VOID APMakeBssBeacon(
-    IN  PRTMP_ADAPTER   pAd,
-       IN      INT                             apidx);
-
-VOID  APUpdateBeaconFrame(
-    IN  PRTMP_ADAPTER   pAd,
-       IN      INT                             apidx);
-
-VOID APMakeAllBssBeacon(
-    IN  PRTMP_ADAPTER   pAd);
-
-VOID  APUpdateAllBeaconFrame(
-    IN  PRTMP_ADAPTER   pAd);
-
-
-// ap_sync.c
-
-VOID APSyncStateMachineInit(
-    IN PRTMP_ADAPTER pAd,
-    IN STATE_MACHINE *Sm,
-    OUT STATE_MACHINE_FUNC Trans[]);
-
-VOID APScanTimeout(
-       IN PVOID SystemSpecific1,
-       IN PVOID FunctionContext,
-       IN PVOID SystemSpecific2,
-       IN PVOID SystemSpecific3);
-
-VOID APInvalidStateWhenScan(
-       IN PRTMP_ADAPTER pAd,
-       IN MLME_QUEUE_ELEM *Elem);
-
-VOID APScanTimeoutAction(
-       IN PRTMP_ADAPTER pAd,
-       IN MLME_QUEUE_ELEM *Elem);
-
-VOID APPeerProbeReqAction(
-    IN  PRTMP_ADAPTER pAd,
-    IN  MLME_QUEUE_ELEM *Elem);
-
-VOID APPeerBeaconAction(
-    IN PRTMP_ADAPTER pAd,
-    IN MLME_QUEUE_ELEM *Elem);
-
-VOID APMlmeScanReqAction(
-       IN PRTMP_ADAPTER pAd,
-       IN MLME_QUEUE_ELEM *Elem);
-
-VOID APPeerBeaconAtScanAction(
-       IN PRTMP_ADAPTER pAd,
-       IN MLME_QUEUE_ELEM *Elem);
-
-VOID APScanCnclAction(
-       IN PRTMP_ADAPTER pAd,
-       IN MLME_QUEUE_ELEM *Elem);
-
-VOID ApSiteSurvey(
-       IN PRTMP_ADAPTER pAd);
-
-VOID SupportRate(
-       IN PUCHAR SupRate,
-       IN UCHAR SupRateLen,
-       IN PUCHAR ExtRate,
-       IN UCHAR ExtRateLen,
-       OUT PUCHAR *Rates,
-       OUT PUCHAR RatesLen,
-       OUT PUCHAR pMaxSupportRate);
-
-
-BOOLEAN ApScanRunning(
-       IN PRTMP_ADAPTER pAd);
-
-// ap_wpa.c
-
-VOID APWpaStateMachineInit(
-    IN  PRTMP_ADAPTER   pAd,
-    IN  STATE_MACHINE *Sm,
-    OUT STATE_MACHINE_FUNC Trans[]);
-
-// ap_mlme.c
-
-VOID APMlmePeriodicExec(
-    IN  PRTMP_ADAPTER   pAd);
-
-VOID APMlmeSelectTxRateTable(
-       IN PRTMP_ADAPTER                pAd,
-       IN PMAC_TABLE_ENTRY             pEntry,
-       IN PUCHAR                               *ppTable,
-       IN PUCHAR                               pTableSize,
-       IN PUCHAR                               pInitTxRateIdx);
-
-VOID APMlmeSetTxRate(
-       IN PRTMP_ADAPTER                pAd,
-       IN PMAC_TABLE_ENTRY             pEntry,
-       IN PRTMP_TX_RATE_SWITCH pTxRate);
-
-VOID APMlmeDynamicTxRateSwitching(
-    IN PRTMP_ADAPTER pAd);
-
-VOID APQuickResponeForRateUpExec(
-    IN PVOID SystemSpecific1,
-    IN PVOID FunctionContext,
-    IN PVOID SystemSpecific2,
-    IN PVOID SystemSpecific3);
-
-BOOLEAN APMsgTypeSubst(
-    IN PRTMP_ADAPTER pAd,
-    IN PFRAME_802_11 pFrame,
-    OUT INT *Machine,
-    OUT INT *MsgType);
-
-VOID APQuickResponeForRateUpExec(
-    IN PVOID SystemSpecific1,
-    IN PVOID FunctionContext,
-    IN PVOID SystemSpecific2,
-    IN PVOID SystemSpecific3);
-
-#ifdef RT2870
-VOID BeaconUpdateExec(
-    IN PVOID SystemSpecific1,
-    IN PVOID FunctionContext,
-    IN PVOID SystemSpecific2,
-    IN PVOID SystemSpecific3);
-#endif // RT2870 //
-
-VOID RTMPSetPiggyBack(
-       IN PRTMP_ADAPTER        pAd,
-       IN BOOLEAN                      bPiggyBack);
-
-VOID APAsicEvaluateRxAnt(
-       IN PRTMP_ADAPTER        pAd);
-
-VOID APAsicRxAntEvalTimeout(
-       IN PRTMP_ADAPTER        pAd);
-
-// ap.c
-
-VOID APSwitchChannel(
-       IN PRTMP_ADAPTER pAd,
-       IN INT Channel);
-
-NDIS_STATUS APInitialize(
-    IN  PRTMP_ADAPTER   pAd);
-
-VOID APShutdown(
-    IN PRTMP_ADAPTER    pAd);
-
-VOID APStartUp(
-    IN  PRTMP_ADAPTER   pAd);
-
-VOID APStop(
-    IN  PRTMP_ADAPTER   pAd);
-
-VOID APCleanupPsQueue(
-    IN  PRTMP_ADAPTER   pAd,
-    IN  PQUEUE_HEADER   pQueue);
-
-VOID MacTableReset(
-    IN  PRTMP_ADAPTER   pAd);
-
-MAC_TABLE_ENTRY *MacTableInsertEntry(
-    IN  PRTMP_ADAPTER   pAd,
-    IN  PUCHAR          pAddr,
-       IN      UCHAR                   apidx,
-       IN BOOLEAN      CleanAll);
-
-BOOLEAN MacTableDeleteEntry(
-    IN  PRTMP_ADAPTER   pAd,
-       IN USHORT wcid,
-    IN  PUCHAR          pAddr);
-
-MAC_TABLE_ENTRY *MacTableLookup(
-    IN  PRTMP_ADAPTER   pAd,
-    IN  PUCHAR          pAddr);
-
-VOID MacTableMaintenance(
-    IN PRTMP_ADAPTER pAd);
-
-UINT32 MacTableAssocStaNumGet(
-       IN PRTMP_ADAPTER pAd);
-
-MAC_TABLE_ENTRY *APSsPsInquiry(
-    IN  PRTMP_ADAPTER   pAd,
-    IN  PUCHAR          pAddr,
-    OUT SST             *Sst,
-    OUT USHORT          *Aid,
-    OUT UCHAR           *PsMode,
-    OUT UCHAR           *Rate);
-
-BOOLEAN APPsIndicate(
-    IN  PRTMP_ADAPTER   pAd,
-    IN  PUCHAR          pAddr,
-       IN ULONG Wcid,
-    IN  UCHAR           Psm);
-
-VOID ApLogEvent(
-    IN PRTMP_ADAPTER    pAd,
-    IN PUCHAR           pAddr,
-    IN USHORT           Event);
-
-VOID APUpdateOperationMode(
-    IN PRTMP_ADAPTER pAd);
-
-VOID APUpdateCapabilityAndErpIe(
-       IN PRTMP_ADAPTER pAd);
-
-BOOLEAN ApCheckAccessControlList(
-       IN PRTMP_ADAPTER pAd,
-       IN PUCHAR        pAddr,
-       IN UCHAR         Apidx);
-
-VOID ApUpdateAccessControlList(
-    IN PRTMP_ADAPTER pAd,
-    IN UCHAR         Apidx);
-
-VOID ApEnqueueNullFrame(
-       IN PRTMP_ADAPTER pAd,
-       IN PUCHAR        pAddr,
-       IN UCHAR         TxRate,
-       IN UCHAR         PID,
-       IN UCHAR         apidx,
-    IN BOOLEAN       bQosNull,
-    IN BOOLEAN       bEOSP,
-    IN UCHAR         OldUP);
-
-VOID ApSendFrame(
-    IN  PRTMP_ADAPTER   pAd,
-    IN  PVOID           pBuffer,
-    IN  ULONG           Length,
-    IN  UCHAR           TxRate,
-    IN  UCHAR           PID);
-
-VOID ApEnqueueAckFrame(
-    IN PRTMP_ADAPTER pAd,
-    IN PUCHAR        pAddr,
-    IN UCHAR         TxRate,
-       IN UCHAR         apidx);
-
-UCHAR APAutoSelectChannel(
-       IN PRTMP_ADAPTER pAd,
-       IN BOOLEAN Optimal);
-
-// ap_sanity.c
-
-
-BOOLEAN PeerAssocReqCmmSanity(
-    IN PRTMP_ADAPTER pAd,
-       IN BOOLEAN isRessoc,
-    IN VOID *Msg,
-    IN ULONG MsgLen,
-    OUT PUCHAR pAddr2,
-    OUT USHORT *pCapabilityInfo,
-    OUT USHORT *pListenInterval,
-    OUT PUCHAR pApAddr,
-    OUT UCHAR *pSsidLen,
-    OUT char *Ssid,
-    OUT UCHAR *pRatesLen,
-    OUT UCHAR Rates[],
-    OUT UCHAR *RSN,
-    OUT UCHAR *pRSNLen,
-    OUT BOOLEAN *pbWmmCapable,
-    OUT ULONG  *pRalinkIe,
-    OUT UCHAR           *pHtCapabilityLen,
-    OUT HT_CAPABILITY_IE *pHtCapability);
-
-
-BOOLEAN PeerDisassocReqSanity(
-    IN PRTMP_ADAPTER pAd,
-    IN VOID *Msg,
-    IN ULONG MsgLen,
-    OUT PUCHAR pAddr2,
-    OUT USHORT *Reason);
-
-BOOLEAN PeerDeauthReqSanity(
-    IN PRTMP_ADAPTER pAd,
-    IN VOID *Msg,
-    IN ULONG MsgLen,
-    OUT PUCHAR pAddr2,
-    OUT USHORT *Reason);
-
-BOOLEAN APPeerAuthSanity(
-    IN PRTMP_ADAPTER pAd,
-    IN VOID *Msg,
-    IN ULONG MsgLen,
-       OUT PUCHAR pAddr1,
-    OUT PUCHAR pAddr2,
-    OUT USHORT *Alg,
-    OUT USHORT *Seq,
-    OUT USHORT *Status,
-    CHAR *ChlgText);
-
-BOOLEAN APPeerProbeReqSanity(
-    IN PRTMP_ADAPTER pAd,
-    IN VOID *Msg,
-    IN ULONG MsgLen,
-    OUT PUCHAR pAddr2,
-    OUT CHAR Ssid[],
-    OUT UCHAR *SsidLen);
-
-BOOLEAN APPeerBeaconAndProbeRspSanity(
-    IN PRTMP_ADAPTER pAd,
-    IN VOID *Msg,
-    IN ULONG MsgLen,
-    OUT PUCHAR pAddr2,
-    OUT PUCHAR pBssid,
-    OUT CHAR Ssid[],
-    OUT UCHAR *SsidLen,
-    OUT UCHAR *BssType,
-    OUT USHORT *BeaconPeriod,
-    OUT UCHAR *Channel,
-    OUT LARGE_INTEGER *Timestamp,
-    OUT USHORT *CapabilityInfo,
-    OUT UCHAR Rate[],
-    OUT UCHAR *RateLen,
-    OUT BOOLEAN *ExtendedRateIeExist,
-    OUT UCHAR *Erp);
-
-
-// ================== end of AP RTMP.h ========================
-
-
-#endif  // __AP_H__
-
+#include "../rt2870/ap.h"
index 3527b0dfb2204278d0e734a1489580c10d77f713..8ee1ff527f5d3b3175088e48b38c1e4a69d9ba54 100644 (file)
@@ -1,1245 +1 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify  *
- * it under the terms of the GNU General Public License as published by  *
- * the Free Software Foundation; either version 2 of the License, or     *
- * (at your option) any later version.                                   *
- *                                                                       *
- * 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.                          *
- *                                                                       *
- * You should have received a copy of the GNU General Public License     *
- * along with this program; if not, write to the                         *
- * Free Software Foundation, Inc.,                                       *
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- *                                                                       *
- *************************************************************************
-
-       Module Name:
-       chlist.c
-
-       Abstract:
-
-       Revision History:
-       Who         When          What
-       --------    ----------    ----------------------------------------------
-       Fonchi Wu   2007-12-19    created
-*/
-
-#ifndef __CHLIST_H__
-#define __CHLIST_H__
-
-#include "rtmp_type.h"
-#include "rtmp_def.h"
-
-
-#define ODOR                   0
-#define IDOR                   1
-#define BOTH                   2
-
-#define BAND_5G         0
-#define BAND_24G        1
-#define BAND_BOTH       2
-
-typedef struct _CH_DESP {
-       UCHAR FirstChannel;
-       UCHAR NumOfCh;
-       CHAR MaxTxPwr;                  // dBm
-       UCHAR Geography;                        // 0:out door, 1:in door, 2:both
-       BOOLEAN DfsReq;                 // Dfs require, 0: No, 1: yes.
-} CH_DESP, *PCH_DESP;
-
-typedef struct _CH_REGION {
-       UCHAR CountReg[3];
-       UCHAR DfsType;                  // 0: CE, 1: FCC, 2: JAP, 3:JAP_W53, JAP_W56
-       CH_DESP ChDesp[10];
-} CH_REGION, *PCH_REGION;
-
-static CH_REGION ChRegion[] =
-{
-               {       // Antigua and Berbuda
-                       "AG",
-                       CE,
-                       {
-                               { 1,   13, 20, BOTH, FALSE},    // 2.4 G, ch 1~13
-                               { 36,  4,  23, BOTH, FALSE},    // 5G, ch 36~48
-                               { 52,  4,  23, BOTH, FALSE},    // 5G, ch 52~64
-                               { 100, 11, 30, BOTH, FALSE},    // 5G, ch 100~140
-                               { 0},                                                   // end
-                       }
-               },
-
-               {       // Argentina
-                       "AR",
-                       CE,
-                       {
-                               { 1,   13, 20, BOTH, FALSE},    // 2.4 G, ch 1~13
-                               { 52,  4,  24, BOTH, FALSE},    // 5G, ch 52~64
-                               { 149, 4,  30, BOTH, FALSE},    // 5G, ch 149~161
-                               { 0},                                                   // end
-                       }
-               },
-
-               {       // Aruba
-                       "AW",
-                       CE,
-                       {
-                               { 1,   13, 20, BOTH, FALSE},    // 2.4 G, ch 1~13
-                               { 36,  4,  23, BOTH, FALSE},    // 5G, ch 36~48
-                               { 52,  4,  23, BOTH, FALSE},    // 5G, ch 52~64
-                               { 100, 11, 30, BOTH, FALSE},    // 5G, ch 100~140
-                               { 0},                                                   // end
-                       }
-               },
-
-               {       // Australia
-                       "AU",
-                       CE,
-                       {
-                               { 1,   13, 20, BOTH, FALSE},    // 2.4 G, ch 1~13
-                               { 36,  4,  23, BOTH, FALSE},    // 5G, ch 36~48
-                               { 52,  4,  24, BOTH, FALSE},    // 5G, ch 52~64
-                               { 149, 5,  30, BOTH, FALSE},    // 5G, ch 149~165
-                               { 0},                                                   // end
-                       }
-               },
-
-               {       // Austria
-                       "AT",
-                       CE,
-                       {
-                               { 1,   13, 20, BOTH, FALSE},    // 2.4 G, ch 1~13
-                               { 36,  4,  23, IDOR, TRUE},             // 5G, ch 36~48
-                               { 52,  4,  23, IDOR, TRUE},             // 5G, ch 52~64
-                               { 100, 11, 30, BOTH, TRUE},             // 5G, ch 100~140
-                               { 0},                                                   // end
-                       }
-               },
-
-               {       // Bahamas
-                       "BS",
-                       CE,
-                       {
-                               { 1,   13, 20, BOTH, FALSE},    // 2.4 G, ch 1~13
-                               { 36,  4,  23, BOTH, FALSE},    // 5G, ch 36~48
-                               { 52,  4,  24, BOTH, FALSE},    // 5G, ch 52~64
-                               { 149, 5,  30, BOTH, FALSE},    // 5G, ch 149~165
-                               { 0},                                                   // end
-                       }
-               },
-
-               {       // Barbados
-                       "BB",
-                       CE,
-                       {
-                               { 1,   13, 20, BOTH, FALSE},    // 2.4 G, ch 1~13
-                               { 36,  4,  23, BOTH, FALSE},    // 5G, ch 36~48
-                               { 52,  4,  24, BOTH, FALSE},    // 5G, ch 52~64
-                               { 100, 11, 30, BOTH, FALSE},    // 5G, ch 100~140
-                               { 0},                                                   // end
-                       }
-               },
-
-               {       // Bermuda
-                       "BM",
-                       CE,
-                       {
-                               { 1,   13, 20, BOTH, FALSE},    // 2.4 G, ch 1~13
-                               { 36,  4,  23, BOTH, FALSE},    // 5G, ch 36~48
-                               { 52,  4,  24, BOTH, FALSE},    // 5G, ch 52~64
-                               { 100, 11, 30, BOTH, FALSE},    // 5G, ch 100~140
-                               { 0},                                                   // end
-                       }
-               },
-
-               {       // Brazil
-                       "BR",
-                       CE,
-                       {
-                               { 1,   13, 20, BOTH, FALSE},    // 2.4 G, ch 1~13
-                               { 36,  4,  23, BOTH, FALSE},    // 5G, ch 36~48
-                               { 52,  4,  24, BOTH, FALSE},    // 5G, ch 52~64
-                               { 100, 11, 24, BOTH, FALSE},    // 5G, ch 100~140
-                               { 149, 5,  30, BOTH, FALSE},    // 5G, ch 100~140
-                               { 0},                                                   // end
-                       }
-               },
-
-               {       // Belgium
-                       "BE",
-                       CE,
-                       {
-                               { 1,   13, 20, BOTH, FALSE},    // 2.4 G, ch 1~13
-                               { 36,  4,  18, IDOR, FALSE},    // 5G, ch 36~48
-                               { 52,  4,  18, IDOR, FALSE},    // 5G, ch 52~64
-                               { 0},                                                   // end
-                       }
-               },
-
-               {       // Bulgaria
-                       "BG",
-                       CE,
-                       {
-                               { 1,   13, 20, BOTH, FALSE},    // 2.4 G, ch 1~13
-                               { 36,  4,  23, IDOR, FALSE},    // 5G, ch 36~48
-                               { 52,  4,  23, IDOR, TRUE},     // 5G, ch 52~64
-                               { 100, 11, 30, ODOR, TRUE},     // 5G, ch 100~140
-                               { 0},                                                   // end
-                       }
-               },
-
-               {       // Canada
-                       "CA",
-                       CE,
-                       {
-                               { 1,   13, 20, BOTH, FALSE},    // 2.4 G, ch 1~13
-                               { 36,  4,  23, BOTH, FALSE},    // 5G, ch 36~48
-                               { 52,  4,  23, BOTH, FALSE},    // 5G, ch 52~64
-                               { 149, 5,  30, BOTH, FALSE},    // 5G, ch 149~165
-                               { 0},                                                   // end
-                       }
-               },
-
-               {       // Cayman IsLands
-                       "KY",
-                       CE,
-                       {
-                               { 1,   13, 20, BOTH, FALSE},    // 2.4 G, ch 1~13
-                               { 36,  4,  23, BOTH, FALSE},    // 5G, ch 36~48
-                               { 52,  4,  24, BOTH, FALSE},    // 5G, ch 52~64
-                               { 100, 11, 30, BOTH, FALSE},    // 5G, ch 100~140
-                               { 0},                                                   // end
-                       }
-               },
-
-               {       // Chile
-                       "CL",
-                       CE,
-                       {
-                               { 1,   13, 20, BOTH, FALSE},    // 2.4 G, ch 1~13
-                               { 36,  4,  20, BOTH, FALSE},    // 5G, ch 36~48
-                               { 52,  4,  20, BOTH, FALSE},    // 5G, ch 52~64
-                               { 149, 5,  20, BOTH, FALSE},    // 5G, ch 149~165
-                               { 0},                                                   // end
-                       }
-               },
-
-               {       // China
-                       "CN",
-                       CE,
-                       {
-                               { 1,   13, 20, BOTH, FALSE},    // 2.4 G, ch 1~13
-                               { 149, 4,  27, BOTH, FALSE},    // 5G, ch 149~161
-                               { 0},                                                   // end
-                       }
-               },
-
-               {       // Colombia
-                       "CO",
-                       CE,
-                       {
-                               { 1,   13, 20, BOTH, FALSE},    // 2.4 G, ch 1~13
-                               { 36,  4,  17, BOTH, FALSE},    // 5G, ch 36~48
-                               { 52,  4,  24, BOTH, FALSE},    // 5G, ch 52~64
-                               { 100, 11, 30, BOTH, FALSE},    // 5G, ch 100~140
-                               { 149, 5,  30, BOTH, FALSE},    // 5G, ch 149~165
-                               { 0},                                                   // end
-                       }
-               },
-
-               {       // Costa Rica
-                       "CR",
-                       CE,
-                       {
-                               { 1,   13, 20, BOTH, FALSE},    // 2.4 G, ch 1~13
-                               { 36,  4,  17, BOTH, FALSE},    // 5G, ch 36~48
-                               { 52,  4,  24, BOTH, FALSE},    // 5G, ch 52~64
-                               { 149, 4,  30, BOTH, FALSE},    // 5G, ch 149~161
-                               { 0},                                                   // end
-                       }
-               },
-
-               {       // Cyprus
-                       "CY",
-                       CE,
-                       {
-                               { 1,   13, 20, BOTH, FALSE},    // 2.4 G, ch 1~13
-                               { 36,  4,  23, IDOR, FALSE},    // 5G, ch 36~48
-                               { 52,  4,  24, IDOR, TRUE},             // 5G, ch 52~64
-                               { 100, 11, 30, BOTH, TRUE},             // 5G, ch 100~140
-                               { 0},                                                   // end
-                       }
-               },
-
-               {       // Czech_Republic
-                       "CZ",
-                       CE,
-                       {
-                               { 1,   13, 20, BOTH, FALSE},    // 2.4 G, ch 1~13
-                               { 36,  4,  23, IDOR, FALSE},    // 5G, ch 36~48
-                               { 52,  4,  23, IDOR, TRUE},             // 5G, ch 52~64
-                               { 0},                                                   // end
-                       }
-               },
-
-               {       // Denmark
-                       "DK",
-                       CE,
-                       {
-                               { 1,   13, 20, BOTH, FALSE},    // 2.4 G, ch 1~13
-                               { 36,  4,  23, IDOR, FALSE},    // 5G, ch 36~48
-                               { 52,  4,  23, IDOR, TRUE},             // 5G, ch 52~64
-                               { 100, 11, 30, BOTH, TRUE},             // 5G, ch 100~140
-                               { 0},                                                   // end
-                       }
-               },
-
-               {       // Dominican Republic
-                       "DO",
-                       CE,
-                       {
-                               { 1,   0,  20, BOTH, FALSE},    // 2.4 G, ch 0
-                               { 149, 4,  20, BOTH, FALSE},    // 5G, ch 149~161
-                               { 0},                                                   // end
-                       }
-               },
-
-               {       // Equador
-                       "EC",
-                       CE,
-                       {
-                               { 1,   13,  20, BOTH, FALSE},   // 2.4 G, ch 1~13
-                               { 100, 11,  27, BOTH, FALSE},   // 5G, ch 100~140
-                               { 0},                                                   // end
-                       }
-               },
-
-               {       // El Salvador
-                       "SV",
-                       CE,
-                       {
-                               { 1,   13,  20, BOTH, FALSE},   // 2.4 G, ch 1~13
-                               { 36,  4,   23, IDOR, FALSE},   // 5G, ch 36~48
-                               { 52,  4,   30, BOTH, TRUE},    // 5G, ch 52~64
-                               { 149, 4,   36, BOTH, TRUE},    // 5G, ch 149~165
-                               { 0},                                                   // end
-                       }
-               },
-
-               {       // Finland
-                       "FI",
-                       CE,
-                       {
-                               { 1,   13,  20, BOTH, FALSE},   // 2.4 G, ch 1~13
-                               { 36,  4,   23, IDOR, FALSE},   // 5G, ch 36~48
-                               { 52,  4,   23, IDOR, TRUE},    // 5G, ch 52~64
-                               { 100, 11,  30, BOTH, TRUE},    // 5G, ch 100~140
-                               { 0},                                                   // end
-                       }
-               },
-
-               {       // France
-                       "FR",
-                       CE,
-                       {
-                               { 1,   13,  20, BOTH, FALSE},   // 2.4 G, ch 1~13
-                               { 36,  4,   23, IDOR, FALSE},   // 5G, ch 36~48
-                               { 52,  4,   23, IDOR, TRUE},    // 5G, ch 52~64
-                               { 0},                                                   // end
-                       }
-               },
-
-               {       // Germany
-                       "DE",
-                       CE,
-                       {
-                               { 1,   13,  20, BOTH, FALSE},   // 2.4 G, ch 1~13
-                               { 36,  4,   23, IDOR, FALSE},   // 5G, ch 36~48
-                               { 52,  4,   23, IDOR, TRUE},    // 5G, ch 52~64
-                               { 100, 11,  30, BOTH, TRUE},    // 5G, ch 100~140
-                               { 0},                                                   // end
-                       }
-               },
-
-               {       // Greece
-                       "GR",
-                       CE,
-                       {
-                               { 1,   13,  20, BOTH, FALSE},   // 2.4 G, ch 1~13
-                               { 36,  4,   23, IDOR, FALSE},   // 5G, ch 36~48
-                               { 52,  4,   23, IDOR, TRUE},    // 5G, ch 52~64
-                               { 100, 11,  30, ODOR, TRUE},    // 5G, ch 100~140
-                               { 0},                                                   // end
-                       }
-               },
-
-               {       // Guam
-                       "GU",
-                       CE,
-                       {
-                               { 1,   11,  20, BOTH, FALSE},   // 2.4 G, ch 1~11
-                               { 36,  4,   17, BOTH, FALSE},   // 5G, ch 36~48
-                               { 52,  4,   24, BOTH, FALSE},   // 5G, ch 52~64
-                               { 100, 11,  30, BOTH, FALSE},   // 5G, ch 100~140
-                               { 149,  5,  30, BOTH, FALSE},   // 5G, ch 149~165
-                               { 0},                                                   // end
-                       }
-               },
-
-               {       // Guatemala
-                       "GT",
-                       CE,
-                       {
-                               { 1,   13,  20, BOTH, FALSE},   // 2.4 G, ch 1~13
-                               { 36,  4,   17, BOTH, FALSE},   // 5G, ch 36~48
-                               { 52,  4,   24, BOTH, FALSE},   // 5G, ch 52~64
-                               { 149,  4,  30, BOTH, FALSE},   // 5G, ch 149~161
-                               { 0},                                                   // end
-                       }
-               },
-
-               {       // Haiti
-                       "HT",
-                       CE,
-                       {
-                               { 1,   13,  20, BOTH, FALSE},   // 2.4 G, ch 1~13
-                               { 36,  4,   17, BOTH, FALSE},   // 5G, ch 36~48
-                               { 52,  4,   24, BOTH, FALSE},   // 5G, ch 52~64
-                               { 149,  4,  30, BOTH, FALSE},   // 5G, ch 149~161
-                               { 0},                                                   // end
-                       }
-               },
-
-               {       // Honduras
-                       "HN",
-                       CE,
-                       {
-                               { 1,   13,  20, BOTH, FALSE},   // 2.4 G, ch 1~13
-                               { 149,  4,  27, BOTH, FALSE},   // 5G, ch 149~161
-                               { 0},                                                   // end
-                       }
-               },
-
-               {       // Hong Kong
-                       "HK",
-                       CE,
-                       {
-                               { 1,   13,  20, BOTH, FALSE},   // 2.4 G, ch 1~13
-                               { 36,   4,  23, IDOR, FALSE},   // 5G, ch 36~48
-                               { 52,   4,  23, IDOR, FALSE},   // 5G, ch 52~64
-                               { 149,  4,  30, BOTH, FALSE},   // 5G, ch 149~161
-                               { 0},                                                   // end
-                       }
-               },
-
-               {       // Hungary
-                       "HU",
-                       CE,
-                       {
-                               { 1,   13,  20, BOTH, FALSE},   // 2.4 G, ch 1~13
-                               { 36,   4,  23, IDOR, FALSE},   // 5G, ch 36~48
-                               { 52,   4,  23, IDOR, TRUE},    // 5G, ch 52~64
-                               { 0},                                                   // end
-                       }
-               },
-
-               {       // Iceland
-                       "IS",
-                       CE,
-                       {
-                               { 1,   13,  20, BOTH, FALSE},   // 2.4 G, ch 1~13
-                               { 36,   4,  23, IDOR, FALSE},   // 5G, ch 36~48
-                               { 52,   4,  23, IDOR, TRUE},    // 5G, ch 52~64
-                               { 100, 11,  30, BOTH, TRUE},    // 5G, ch 100~140
-                               { 0},                                                   // end
-                       }
-               },
-
-               {       // India
-                       "IN",
-                       CE,
-                       {
-                               { 1,   13,  20, BOTH, FALSE},   // 2.4 G, ch 1~13
-                               { 149,  4,  24, IDOR, FALSE},   // 5G, ch 149~161
-                               { 0},                                                   // end
-                       }
-               },
-
-               {       // Indonesia
-                       "ID",
-                       CE,
-                       {
-                               { 1,   13,  20, BOTH, FALSE},   // 2.4 G, ch 1~13
-                               { 149,  4,  27, BOTH, FALSE},   // 5G, ch 149~161
-                               { 0},                                                   // end
-                       }
-               },
-
-               {       // Ireland
-                       "IE",
-                       CE,
-                       {
-                               { 1,   13,  20, BOTH, FALSE},   // 2.4 G, ch 1~13
-                               { 36,   4,  23, IDOR, FALSE},   // 5G, ch 36~48
-                               { 52,   4,  23, IDOR, TRUE},    // 5G, ch 52~64
-                               { 100, 11,  30, ODOR, TRUE},    // 5G, ch 100~140
-                               { 0},                                                   // end
-                       }
-               },
-
-               {       // Israel
-                       "IL",
-                       CE,
-                       {
-                               { 1,    3,  20, IDOR, FALSE},   // 2.4 G, ch 1~3
-                               { 4,    6,  20, BOTH, FALSE},   // 2.4 G, ch 4~9
-                               { 10,   4,  20, IDOR, FALSE},   // 2.4 G, ch 10~13
-                               { 0},                                                   // end
-                       }
-               },
-
-               {       // Italy
-                       "IT",
-                       CE,
-                       {
-                               { 1,   13,  20, BOTH, FALSE},   // 2.4 G, ch 1~13
-                               { 36,   4,  23, IDOR, FALSE},   // 5G, ch 36~48
-                               { 52,   4,  23, IDOR, TRUE},    // 5G, ch 52~64
-                               { 100, 11,  30, ODOR, TRUE},    // 5G, ch 100~140
-                               { 0},                                                   // end
-                       }
-               },
-
-               {       // Japan
-                       "JP",
-                       JAP,
-                       {
-                               { 1,   14,  20, BOTH, FALSE},   // 2.4 G, ch 1~14
-                               { 34,   4,  23, IDOR, FALSE},   // 5G, ch 34~46
-                               { 0},                                                   // end
-                       }
-               },
-
-               {       // Jordan
-                       "JO",
-                       CE,
-                       {
-                               { 1,   13,  20, IDOR, FALSE},   // 2.4 G, ch 1~13
-                               { 36,   4,  23, IDOR, FALSE},   // 5G, ch 36~48
-                               { 149,  4,  23, IDOR, FALSE},   // 5G, ch 149~161
-                               { 0},                                                   // end
-                       }
-               },
-
-               {       // Latvia
-                       "LV",
-                       CE,
-                       {
-                               { 1,   13,  20, BOTH, FALSE},   // 2.4 G, ch 1~13
-                               { 36,   4,  23, IDOR, FALSE},   // 5G, ch 36~48
-                               { 52,   4,  23, IDOR, TRUE},    // 5G, ch 52~64
-                               { 100, 11,  30, BOTH, TRUE},    // 5G, ch 100~140
-                               { 0},                                                   // end
-                       }
-               },
-
-               {       // Liechtenstein
-                       "LI",
-                       CE,
-                       {
-                               { 1,   13,  20, BOTH, FALSE},   // 2.4 G, ch 1~13
-                               { 52,   4,  23, IDOR, TRUE},    // 5G, ch 52~64
-                               { 100, 11,  30, BOTH, TRUE},    // 5G, ch 100~140
-                               { 0},                                                   // end
-                       }
-               },
-
-               {       // Lithuania
-                       "LT",
-                       CE,
-                       {
-                               { 1,   13,  20, BOTH, FALSE},   // 2.4 G, ch 1~13
-                               { 36,   4,  23, IDOR, FALSE},   // 5G, ch 36~48
-                               { 52,   4,  23, IDOR, TRUE},    // 5G, ch 52~64
-                               { 100, 11,  30, BOTH, TRUE},    // 5G, ch 100~140
-                               { 0},                                                   // end
-                       }
-               },
-
-               {       // Luxemburg
-                       "LU",
-                       CE,
-                       {
-                               { 1,   13,  20, BOTH, FALSE},   // 2.4 G, ch 1~13
-                               { 36,   4,  23, IDOR, FALSE},   // 5G, ch 36~48
-                               { 52,   4,  23, IDOR, TRUE},    // 5G, ch 52~64
-                               { 100, 11,  30, BOTH, TRUE},    // 5G, ch 100~140
-                               { 0},                                                   // end
-                       }
-               },
-
-               {       // Malaysia
-                       "MY",
-                       CE,
-                       {
-                               { 36,   4,  23, BOTH, FALSE},   // 5G, ch 36~48
-                               { 52,   4,  23, BOTH, FALSE},   // 5G, ch 52~64
-                               { 149,  5,  20, BOTH, FALSE},   // 5G, ch 149~165
-                               { 0},                                                   // end
-                       }
-               },
-
-               {       // Malta
-                       "MT",
-                       CE,
-                       {
-                               { 1,   13,  20, BOTH, FALSE},   // 2.4 G, ch 1~13
-                               { 36,   4,  23, IDOR, FALSE},   // 5G, ch 36~48
-                               { 52,   4,  23, IDOR, TRUE},    // 5G, ch 52~64
-                               { 100, 11,  30, BOTH, TRUE},    // 5G, ch 100~140
-                               { 0},                                                   // end
-                       }
-               },
-
-               {       // Marocco
-                       "MA",
-                       CE,
-                       {
-                               { 1,   13,  20, BOTH, FALSE},   // 2.4 G, ch 1~13
-                               { 36,   4,  24, IDOR, FALSE},   // 5G, ch 36~48
-                               { 0},                                                   // end
-                       }
-               },
-
-               {       // Mexico
-                       "MX",
-                       CE,
-                       {
-                               { 1,   13,  20, BOTH, FALSE},   // 2.4 G, ch 1~13
-                               { 36,   4,  23, BOTH, FALSE},   // 5G, ch 36~48
-                               { 52,   4,  24, BOTH, FALSE},   // 5G, ch 52~64
-                               { 149,  5,  30, IDOR, FALSE},   // 5G, ch 149~165
-                               { 0},                                                   // end
-                       }
-               },
-
-               {       // Netherlands
-                       "NL",
-                       CE,
-                       {
-                               { 1,   13,  20, BOTH, FALSE},   // 2.4 G, ch 1~13
-                               { 36,   4,  23, IDOR, FALSE},   // 5G, ch 36~48
-                               { 52,   4,  24, IDOR, TRUE},    // 5G, ch 52~64
-                               { 100, 11,  30, BOTH, TRUE},    // 5G, ch 100~140
-                               { 0},                                                   // end
-                       }
-               },
-
-               {       // New Zealand
-                       "NZ",
-                       CE,
-                       {
-                               { 1,   13,  20, BOTH, FALSE},   // 2.4 G, ch 1~13
-                               { 36,   4,  24, BOTH, FALSE},   // 5G, ch 36~48
-                               { 52,   4,  24, BOTH, FALSE},   // 5G, ch 52~64
-                               { 149,  4,  30, BOTH, FALSE},   // 5G, ch 149~161
-                               { 0},                                                   // end
-                       }
-               },
-
-               {       // Norway
-                       "NO",
-                       CE,
-                       {
-                               { 1,   13,  20, BOTH, FALSE},   // 2.4 G, ch 1~13
-                               { 36,   4,  24, IDOR, FALSE},   // 5G, ch 36~48
-                               { 52,   4,  24, IDOR, TRUE},    // 5G, ch 52~64
-                               { 100, 11,  30, BOTH, TRUE},    // 5G, ch 149~161
-                               { 0},                                                   // end
-                       }
-               },
-
-               {       // Peru
-                       "PE",
-                       CE,
-                       {
-                               { 1,   13,  20, BOTH, FALSE},   // 2.4 G, ch 1~13
-                               { 149,  4,  27, BOTH, FALSE},   // 5G, ch 149~161
-                               { 0},                                                   // end
-                       }
-               },
-
-               {       // Portugal
-                       "PT",
-                       CE,
-                       {
-                               { 1,   13,  20, BOTH, FALSE},   // 2.4 G, ch 1~13
-                               { 36,   4,  23, IDOR, FALSE},   // 5G, ch 36~48
-                               { 52,   4,  23, IDOR, TRUE},    // 5G, ch 52~64
-                               { 100, 11,  30, BOTH, TRUE},    // 5G, ch 100~140
-                               { 0},                                                   // end
-                       }
-               },
-
-               {       // Poland
-                       "PL",
-                       CE,
-                       {
-                               { 1,   13,  20, BOTH, FALSE},   // 2.4 G, ch 1~13
-                               { 36,   4,  23, IDOR, FALSE},   // 5G, ch 36~48
-                               { 52,   4,  23, IDOR, TRUE},    // 5G, ch 52~64
-                               { 100, 11,  30, BOTH, TRUE},    // 5G, ch 100~140
-                               { 0},                                                   // end
-                       }
-               },
-
-               {       // Romania
-                       "RO",
-                       CE,
-                       {
-                               { 1,   13,  20, BOTH, FALSE},   // 2.4 G, ch 1~13
-                               { 36,   4,  23, IDOR, FALSE},   // 5G, ch 36~48
-                               { 52,   4,  23, IDOR, TRUE},    // 5G, ch 52~64
-                               { 100, 11,  30, BOTH, TRUE},    // 5G, ch 100~140
-                               { 0},                                                   // end
-                       }
-               },
-
-               {       // Russia
-                       "RU",
-                       CE,
-                       {
-                               { 1,   13,  20, BOTH, FALSE},   // 2.4 G, ch 1~13
-                               { 149,  4,  20, IDOR, FALSE},   // 5G, ch 149~161
-                               { 0},                                                   // end
-                       }
-               },
-
-               {       // Saudi Arabia
-                       "SA",
-                       CE,
-                       {
-                               { 1,   13,  20, BOTH, FALSE},   // 2.4 G, ch 1~13
-                               { 36,   4,  23, BOTH, FALSE},   // 5G, ch 36~48
-                               { 52,   4,  23, BOTH, FALSE},   // 5G, ch 52~64
-                               { 149,  4,  23, BOTH, FALSE},   // 5G, ch 149~161
-                               { 0},                                                   // end
-                       }
-               },
-
-               {       // Serbia_and_Montenegro
-                       "CS",
-                       CE,
-                       {
-                               { 1,   13,  20, BOTH, FALSE},   // 2.4 G, ch 1~13
-                               { 0},                                                   // end
-                       }
-               },
-
-               {       // Singapore
-                       "SG",
-                       CE,
-                       {
-                               { 1,   13,  20, BOTH, FALSE},   // 2.4 G, ch 1~13
-                               { 36,   4,  23, BOTH, FALSE},   // 5G, ch 36~48
-                               { 52,   4,  23, BOTH, FALSE},   // 5G, ch 52~64
-                               { 149,  4,  20, BOTH, FALSE},   // 5G, ch 149~161
-                               { 0},                                                   // end
-                       }
-               },
-
-               {       // Slovakia
-                       "SK",
-                       CE,
-                       {
-                               { 1,   13,  20, BOTH, FALSE},   // 2.4 G, ch 1~13
-                               { 36,   4,  23, IDOR, FALSE},   // 5G, ch 36~48
-                               { 52,   4,  23, IDOR, TRUE},    // 5G, ch 52~64
-                               { 100, 11,  30, BOTH, TRUE},    // 5G, ch 100~140
-                               { 0},                                                   // end
-                       }
-               },
-
-               {       // Slovenia
-                       "SI",
-                       CE,
-                       {
-                               { 1,   13,  20, BOTH, FALSE},   // 2.4 G, ch 1~13
-                               { 36,   4,  23, IDOR, FALSE},   // 5G, ch 36~48
-                               { 52,   4,  23, IDOR, TRUE},    // 5G, ch 52~64
-                               { 0},                                                   // end
-                       }
-               },
-
-               {       // South Africa
-                       "ZA",
-                       CE,
-                       {
-                               { 1,   13,  20, BOTH, FALSE},   // 2.4 G, ch 1~13
-                               { 36,   4,  23, BOTH, FALSE},   // 5G, ch 36~48
-                               { 52,   4,  23, IDOR, FALSE},   // 5G, ch 52~64
-                               { 100, 11,  30, BOTH, TRUE},    // 5G, ch 100~140
-                               { 149,  4,  30, BOTH, FALSE},   // 5G, ch 149~161
-                               { 0},                                                   // end
-                       }
-               },
-
-               {       // South Korea
-                       "KR",
-                       CE,
-                       {
-                               { 1,   13,  20, BOTH, FALSE},   // 2.4 G, ch 1~13
-                               { 36,   4,  20, BOTH, FALSE},   // 5G, ch 36~48
-                               { 52,   4,  20, BOTH, FALSE},   // 5G, ch 52~64
-                               { 100,  8,  20, BOTH, FALSE},   // 5G, ch 100~128
-                               { 149,  4,  20, BOTH, FALSE},   // 5G, ch 149~161
-                               { 0},                                                   // end
-                       }
-               },
-
-               {       // Spain
-                       "ES",
-                       CE,
-                       {
-                               { 1,   13,  20, BOTH, FALSE},   // 2.4 G, ch 1~13
-                               { 36,   4,  17, IDOR, FALSE},   // 5G, ch 36~48
-                               { 52,   4,  23, IDOR, TRUE},    // 5G, ch 52~64
-                               { 100, 11,  30, BOTH, TRUE},    // 5G, ch 100~140
-                               { 0},                                                   // end
-                       }
-               },
-
-               {       // Sweden
-                       "SE",
-                       CE,
-                       {
-                               { 1,   13,  20, BOTH, FALSE},   // 2.4 G, ch 1~13
-                               { 36,   4,  23, IDOR, FALSE},   // 5G, ch 36~48
-                               { 52,   4,  23, IDOR, TRUE},    // 5G, ch 52~64
-                               { 100, 11,  30, BOTH, TRUE},    // 5G, ch 100~140
-                               { 0},                                                   // end
-                       }
-               },
-
-               {       // Switzerland
-                       "CH",
-                       CE,
-                       {
-                               { 1,   13,  20, BOTH, FALSE},   // 2.4 G, ch 1~13
-                               { 36,   4,  23, IDOR, TRUE},    // 5G, ch 36~48
-                               { 52,   4,  23, IDOR, TRUE},    // 5G, ch 52~64
-                               { 0},                                                   // end
-                       }
-               },
-
-               {       // Taiwan
-                       "TW",
-                       CE,
-                       {
-                               { 1,   11,  30, BOTH, FALSE},   // 2.4 G, ch 1~11
-                               { 52,   4,  23, IDOR, FALSE},   // 5G, ch 52~64
-                               { 0},                                                   // end
-                       }
-               },
-
-               {       // Turkey
-                       "TR",
-                       CE,
-                       {
-                               { 1,   13,  20, BOTH, FALSE},   // 2.4 G, ch 1~11
-                               { 36,   4,  23, BOTH, FALSE},   // 5G, ch 36~48
-                               { 52,   4,  23, BOTH, FALSE},   // 5G, ch 52~64
-                               { 0},                                                   // end
-                       }
-               },
-
-               {       // UK
-                       "GB",
-                       CE,
-                       {
-                               { 1,   13,  20, BOTH, FALSE},   // 2.4 G, ch 1~11
-                               { 36,   4,  23, IDOR, FALSE},   // 5G, ch 52~64
-                               { 52,   4,  23, IDOR, TRUE},    // 5G, ch 52~64
-                               { 100, 11,  30, BOTH, TRUE},    // 5G, ch 100~140
-                               { 0},                                                   // end
-                       }
-               },
-
-               {       // Ukraine
-                       "UA",
-                       CE,
-                       {
-                               { 1,   13,  20, BOTH, FALSE},   // 2.4 G, ch 1~11
-                               { 0},                                                   // end
-                       }
-               },
-
-               {       // United_Arab_Emirates
-                       "AE",
-                       CE,
-                       {
-                               { 1,   13,  20, BOTH, FALSE},   // 2.4 G, ch 1~11
-                               { 0},                                                   // end
-                       }
-               },
-
-               {       // United_States
-                       "US",
-                       CE,
-                       {
-                               { 1,   11,  30, BOTH, FALSE},   // 2.4 G, ch 1~11
-                               { 36,   4,  17, IDOR, FALSE},   // 5G, ch 52~64
-                               { 52,   4,  24, BOTH, TRUE},    // 5G, ch 52~64
-                               { 100, 11,  30, BOTH, TRUE},    // 5G, ch 100~140
-                               { 149,  5,  30, BOTH, FALSE},   // 5G, ch 149~165
-                               { 0},                                                   // end
-                       }
-               },
-
-               {       // Venezuela
-                       "VE",
-                       CE,
-                       {
-                               { 1,   13,  20, BOTH, FALSE},   // 2.4 G, ch 1~11
-                               { 149,  4,  27, BOTH, FALSE},   // 5G, ch 149~161
-                               { 0},                                                   // end
-                       }
-               },
-
-               {       // Default
-                       "",
-                       CE,
-                       {
-                               { 1,   11,  20, BOTH, FALSE},   // 2.4 G, ch 1~11
-                               { 36,   4,  20, BOTH, FALSE},   // 5G, ch 52~64
-                               { 52,   4,  20, BOTH, FALSE},   // 5G, ch 52~64
-                               { 100, 11,  20, BOTH, FALSE},   // 5G, ch 100~140
-                               { 149,  5,  20, BOTH, FALSE},   // 5G, ch 149~165
-                               { 0},                                                   // end
-                       }
-               },
-};
-
-static inline PCH_REGION GetChRegion(
-       IN PUCHAR CntryCode)
-{
-       INT loop = 0;
-       PCH_REGION pChRegion = NULL;
-
-       while (strcmp(ChRegion[loop].CountReg, "") != 0)
-       {
-               if (strncmp(ChRegion[loop].CountReg, CntryCode, 2) == 0)
-               {
-                       pChRegion = &ChRegion[loop];
-                       break;
-               }
-               loop++;
-       }
-
-       if (pChRegion == NULL)
-               pChRegion = &ChRegion[loop];
-       return pChRegion;
-}
-
-static inline VOID ChBandCheck(
-       IN UCHAR PhyMode,
-       OUT PUCHAR pChType)
-{
-       switch(PhyMode)
-       {
-               case PHY_11A:
-               case PHY_11AN_MIXED:
-                       *pChType = BAND_5G;
-                       break;
-               case PHY_11ABG_MIXED:
-               case PHY_11AGN_MIXED:
-               case PHY_11ABGN_MIXED:
-                       *pChType = BAND_BOTH;
-                       break;
-
-               default:
-                       *pChType = BAND_24G;
-                       break;
-       }
-}
-
-static inline UCHAR FillChList(
-       IN PRTMP_ADAPTER pAd,
-       IN PCH_DESP pChDesp,
-       IN UCHAR Offset,
-       IN UCHAR increment)
-{
-       INT i, j, l;
-       UCHAR channel;
-
-       j = Offset;
-       for (i = 0; i < pChDesp->NumOfCh; i++)
-       {
-               channel = pChDesp->FirstChannel + i * increment;
-               for (l=0; l<MAX_NUM_OF_CHANNELS; l++)
-               {
-                       if (channel == pAd->TxPower[l].Channel)
-                       {
-                               pAd->ChannelList[j].Power = pAd->TxPower[l].Power;
-                               pAd->ChannelList[j].Power2 = pAd->TxPower[l].Power2;
-                               break;
-                       }
-               }
-               if (l == MAX_NUM_OF_CHANNELS)
-                       continue;
-
-               pAd->ChannelList[j].Channel = pChDesp->FirstChannel + i * increment;
-               pAd->ChannelList[j].MaxTxPwr = pChDesp->MaxTxPwr;
-               pAd->ChannelList[j].DfsReq = pChDesp->DfsReq;
-               j++;
-       }
-       pAd->ChannelListNum = j;
-
-       return j;
-}
-
-static inline VOID CreateChList(
-       IN PRTMP_ADAPTER pAd,
-       IN PCH_REGION pChRegion,
-       IN UCHAR Geography)
-{
-       INT i;
-       UCHAR offset = 0;
-       PCH_DESP pChDesp;
-       UCHAR ChType;
-       UCHAR increment;
-
-       if (pChRegion == NULL)
-               return;
-
-       ChBandCheck(pAd->CommonCfg.PhyMode, &ChType);
-
-       for (i=0; i<10; i++)
-       {
-               pChDesp = &pChRegion->ChDesp[i];
-               if (pChDesp->FirstChannel == 0)
-                       break;
-
-               if (ChType == BAND_5G)
-               {
-                       if (pChDesp->FirstChannel <= 14)
-                               continue;
-               }
-               else if (ChType == BAND_24G)
-               {
-                       if (pChDesp->FirstChannel > 14)
-                               continue;
-               }
-
-               if ((pChDesp->Geography == BOTH)
-                       || (pChDesp->Geography == Geography))
-        {
-                       if (pChDesp->FirstChannel > 14)
-                increment = 4;
-            else
-                increment = 1;
-                       offset = FillChList(pAd, pChDesp, offset, increment);
-        }
-       }
-}
-
-static inline VOID BuildChannelListEx(
-       IN PRTMP_ADAPTER pAd)
-{
-       PCH_REGION pChReg;
-
-       pChReg = GetChRegion(pAd->CommonCfg.CountryCode);
-       CreateChList(pAd, pChReg, pAd->CommonCfg.Geography);
-}
-
-static inline VOID BuildBeaconChList(
-       IN PRTMP_ADAPTER pAd,
-       OUT PUCHAR pBuf,
-       OUT     PULONG pBufLen)
-{
-       INT i;
-       ULONG TmpLen;
-       PCH_REGION pChRegion;
-       PCH_DESP pChDesp;
-       UCHAR ChType;
-
-       pChRegion = GetChRegion(pAd->CommonCfg.CountryCode);
-
-       if (pChRegion == NULL)
-               return;
-
-       ChBandCheck(pAd->CommonCfg.PhyMode, &ChType);
-       *pBufLen = 0;
-
-       for (i=0; i<10; i++)
-       {
-               pChDesp = &pChRegion->ChDesp[i];
-               if (pChDesp->FirstChannel == 0)
-                       break;
-
-               if (ChType == BAND_5G)
-               {
-                       if (pChDesp->FirstChannel <= 14)
-                               continue;
-               }
-               else if (ChType == BAND_24G)
-               {
-                       if (pChDesp->FirstChannel > 14)
-                               continue;
-               }
-
-               if ((pChDesp->Geography == BOTH)
-                       || (pChDesp->Geography == pAd->CommonCfg.Geography))
-               {
-                       MakeOutgoingFrame(pBuf + *pBufLen,              &TmpLen,
-                                                               1,                      &pChDesp->FirstChannel,
-                                                               1,                      &pChDesp->NumOfCh,
-                                                               1,                      &pChDesp->MaxTxPwr,
-                                                               END_OF_ARGS);
-                       *pBufLen += TmpLen;
-               }
-       }
-}
-
-static inline BOOLEAN IsValidChannel(
-       IN PRTMP_ADAPTER pAd,
-       IN UCHAR channel)
-
-{
-       INT i;
-
-       for (i = 0; i < pAd->ChannelListNum; i++)
-       {
-               if (pAd->ChannelList[i].Channel == channel)
-                       break;
-       }
-
-       if (i == pAd->ChannelListNum)
-               return FALSE;
-       else
-               return TRUE;
-}
-
-
-static inline UCHAR GetExtCh(
-       IN UCHAR Channel,
-       IN UCHAR Direction)
-{
-       CHAR ExtCh;
-
-       if (Direction == EXTCHA_ABOVE)
-               ExtCh = Channel + 4;
-       else
-               ExtCh = (Channel - 4) > 0 ? (Channel - 4) : 0;
-
-       return ExtCh;
-}
-
-
-static inline VOID N_ChannelCheck(
-       IN PRTMP_ADAPTER pAd)
-{
-       //UCHAR ChannelNum = pAd->ChannelListNum;
-       UCHAR Channel = pAd->CommonCfg.Channel;
-
-       if ((pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED) && (pAd->CommonCfg.RegTransmitSetting.field.BW  == BW_40))
-       {
-               if (Channel > 14)
-               {
-                       if ((Channel == 36) || (Channel == 44) || (Channel == 52) || (Channel == 60) || (Channel == 100) || (Channel == 108) ||
-                           (Channel == 116) || (Channel == 124) || (Channel == 132) || (Channel == 149) || (Channel == 157))
-                       {
-                               pAd->CommonCfg.RegTransmitSetting.field.EXTCHA = EXTCHA_ABOVE;
-                       }
-                       else if ((Channel == 40) || (Channel == 48) || (Channel == 56) || (Channel == 64) || (Channel == 104) || (Channel == 112) ||
-                                       (Channel == 120) || (Channel == 128) || (Channel == 136) || (Channel == 153) || (Channel == 161))
-                       {
-                               pAd->CommonCfg.RegTransmitSetting.field.EXTCHA = EXTCHA_BELOW;
-                       }
-                       else
-                       {
-                               pAd->CommonCfg.RegTransmitSetting.field.BW  = BW_20;
-                       }
-               }
-               else
-               {
-                       do
-                       {
-                               UCHAR ExtCh;
-                               UCHAR Dir = pAd->CommonCfg.RegTransmitSetting.field.EXTCHA;
-                               ExtCh = GetExtCh(Channel, Dir);
-                               if (IsValidChannel(pAd, ExtCh))
-                                       break;
-
-                               Dir = (Dir == EXTCHA_ABOVE) ? EXTCHA_BELOW : EXTCHA_ABOVE;
-                               ExtCh = GetExtCh(Channel, Dir);
-                               if (IsValidChannel(pAd, ExtCh))
-                               {
-                                       pAd->CommonCfg.RegTransmitSetting.field.EXTCHA = Dir;
-                                       break;
-                               }
-                               pAd->CommonCfg.RegTransmitSetting.field.BW  = BW_20;
-                       } while(FALSE);
-
-                       if (Channel == 14)
-                       {
-                               pAd->CommonCfg.RegTransmitSetting.field.BW  = BW_20;
-                               //pAd->CommonCfg.RegTransmitSetting.field.EXTCHA = EXTCHA_NONE; // We didn't set the ExtCh as NONE due to it'll set in RTMPSetHT()
-                       }
-               }
-       }
-
-
-}
-
-
-static inline VOID N_SetCenCh(
-       IN PRTMP_ADAPTER pAd)
-{
-       if (pAd->CommonCfg.RegTransmitSetting.field.BW == BW_40)
-       {
-               if (pAd->CommonCfg.RegTransmitSetting.field.EXTCHA == EXTCHA_ABOVE)
-               {
-                       pAd->CommonCfg.CentralChannel = pAd->CommonCfg.Channel + 2;
-               }
-               else
-               {
-                       if (pAd->CommonCfg.Channel == 14)
-                               pAd->CommonCfg.CentralChannel = pAd->CommonCfg.Channel - 1;
-                       else
-                               pAd->CommonCfg.CentralChannel = pAd->CommonCfg.Channel - 2;
-               }
-       }
-       else
-       {
-               pAd->CommonCfg.CentralChannel = pAd->CommonCfg.Channel;
-       }
-}
-
-static inline UINT8 GetCuntryMaxTxPwr(
-       IN PRTMP_ADAPTER pAd,
-       IN UINT8 channel)
-{
-       int i;
-       for (i = 0; i < pAd->ChannelListNum; i++)
-       {
-               if (pAd->ChannelList[i].Channel == channel)
-                       break;
-       }
-
-       if (i == pAd->ChannelListNum)
-               return 0xff;
-       else
-               return pAd->ChannelList[i].MaxTxPwr;
-}
-#endif // __CHLIST_H__
-
+#include "../rt2870/chlist.h"
index 752a6352d9dd5ac4b92b39335fc5058d2051cc19..b9c92e354f2098978b543196ad0cc73db176a72f 100644 (file)
@@ -1,100 +1 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify  *
- * it under the terms of the GNU General Public License as published by  *
- * the Free Software Foundation; either version 2 of the License, or     *
- * (at your option) any later version.                                   *
- *                                                                       *
- * 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.                          *
- *                                                                       *
- * You should have received a copy of the GNU General Public License     *
- * along with this program; if not, write to the                         *
- * Free Software Foundation, Inc.,                                       *
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- *                                                                       *
- *************************************************************************
-
-    Module Name:
-    dfs.h
-
-    Abstract:
-    Support DFS function.
-
-    Revision History:
-    Who       When            What
-    --------  ----------      ----------------------------------------------
-    Fonchi    03-12-2007      created
-*/
-
-#define RADAR_PULSE 1
-#define RADAR_WIDTH 2
-
-#define WIDTH_RD_IDLE 0
-#define WIDTH_RD_CHECK 1
-
-
-VOID BbpRadarDetectionStart(
-       IN PRTMP_ADAPTER pAd);
-
-VOID BbpRadarDetectionStop(
-       IN PRTMP_ADAPTER pAd);
-
-VOID RadarDetectionStart(
-       IN PRTMP_ADAPTER pAd,
-       IN BOOLEAN CTS_Protect,
-       IN UINT8 CTSPeriod);
-
-VOID RadarDetectionStop(
-       IN PRTMP_ADAPTER        pAd);
-
-VOID RadarDetectPeriodic(
-       IN PRTMP_ADAPTER        pAd);
-
-
-BOOLEAN RadarChannelCheck(
-       IN PRTMP_ADAPTER        pAd,
-       IN UCHAR                        Ch);
-
-ULONG JapRadarType(
-       IN PRTMP_ADAPTER pAd);
-
-ULONG RTMPBbpReadRadarDuration(
-       IN PRTMP_ADAPTER        pAd);
-
-ULONG RTMPReadRadarDuration(
-       IN PRTMP_ADAPTER        pAd);
-
-VOID RTMPCleanRadarDuration(
-       IN PRTMP_ADAPTER        pAd);
-
-VOID RTMPPrepareRDCTSFrame(
-       IN      PRTMP_ADAPTER   pAd,
-       IN      PUCHAR                  pDA,
-       IN      ULONG                   Duration,
-       IN  UCHAR           RTSRate,
-       IN  ULONG           CTSBaseAddr,
-       IN  UCHAR                       FrameGap);
-
-VOID RTMPPrepareRadarDetectParams(
-       IN PRTMP_ADAPTER        pAd);
-
-
-INT Set_ChMovingTime_Proc(
-       IN PRTMP_ADAPTER pAd,
-       IN PUCHAR arg);
-
-INT Set_LongPulseRadarTh_Proc(
-       IN PRTMP_ADAPTER pAd,
-       IN PUCHAR arg);
-
-
+#include "../rt2870/dfs.h"
index f6521133fd5ec097a47f0fac1e612fd538df89dd..5550b2f451644471c0a27eb99176d175ce35a4ea 100644 (file)
@@ -1,134 +1 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify  *
- * it under the terms of the GNU General Public License as published by  *
- * the Free Software Foundation; either version 2 of the License, or     *
- * (at your option) any later version.                                   *
- *                                                                       *
- * 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.                          *
- *                                                                       *
- * You should have received a copy of the GNU General Public License     *
- * along with this program; if not, write to the                         *
- * Free Software Foundation, Inc.,                                       *
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- *                                                                       *
- *************************************************************************
- */
-
-#ifndef __LINK_LIST_H__
-#define __LINK_LIST_H__
-
-typedef struct _LIST_ENTRY
-{
-       struct _LIST_ENTRY *pNext;
-} LIST_ENTRY, *PLIST_ENTRY;
-
-typedef struct _LIST_HEADR
-{
-       PLIST_ENTRY pHead;
-       PLIST_ENTRY pTail;
-       UCHAR size;
-} LIST_HEADER, *PLIST_HEADER;
-
-static inline VOID initList(
-       IN PLIST_HEADER pList)
-{
-       pList->pHead = pList->pTail = NULL;
-       pList->size = 0;
-       return;
-}
-
-static inline VOID insertTailList(
-       IN PLIST_HEADER pList,
-       IN PLIST_ENTRY pEntry)
-{
-       pEntry->pNext = NULL;
-       if (pList->pTail)
-               pList->pTail->pNext = pEntry;
-       else
-               pList->pHead = pEntry;
-       pList->pTail = pEntry;
-       pList->size++;
-
-       return;
-}
-
-static inline PLIST_ENTRY removeHeadList(
-       IN PLIST_HEADER pList)
-{
-       PLIST_ENTRY pNext;
-       PLIST_ENTRY pEntry;
-
-       pEntry = pList->pHead;
-       if (pList->pHead != NULL)
-       {
-               pNext = pList->pHead->pNext;
-               pList->pHead = pNext;
-               if (pNext == NULL)
-                       pList->pTail = NULL;
-               pList->size--;
-       }
-       return pEntry;
-}
-
-static inline int getListSize(
-       IN PLIST_HEADER pList)
-{
-       return pList->size;
-}
-
-static inline PLIST_ENTRY delEntryList(
-       IN PLIST_HEADER pList,
-       IN PLIST_ENTRY pEntry)
-{
-       PLIST_ENTRY pCurEntry;
-       PLIST_ENTRY pPrvEntry;
-
-       if(pList->pHead == NULL)
-               return NULL;
-
-       if(pEntry == pList->pHead)
-       {
-               pCurEntry = pList->pHead;
-               pList->pHead = pCurEntry->pNext;
-
-               if(pList->pHead == NULL)
-                       pList->pTail = NULL;
-
-               pList->size--;
-               return pCurEntry;
-       }
-
-       pPrvEntry = pList->pHead;
-       pCurEntry = pPrvEntry->pNext;
-       while(pCurEntry != NULL)
-       {
-               if (pEntry == pCurEntry)
-               {
-                       pPrvEntry->pNext = pCurEntry->pNext;
-
-                       if(pEntry == pList->pTail)
-                               pList->pTail = pPrvEntry;
-
-                       pList->size--;
-                       break;
-               }
-               pPrvEntry = pCurEntry;
-               pCurEntry = pPrvEntry->pNext;
-       }
-
-       return pCurEntry;
-}
-
-#endif // ___LINK_LIST_H__ //
-
+#include "../rt2870/link_list.h"
index d85db12170d5d102acc8bdcdc51e7cfd5fef9346..1042a994dc726c4a0d66c45a93bf81acb1050d8d 100644 (file)
@@ -1,107 +1 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify  *
- * it under the terms of the GNU General Public License as published by  *
- * the Free Software Foundation; either version 2 of the License, or     *
- * (at your option) any later version.                                   *
- *                                                                       *
- * 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.                          *
- *                                                                       *
- * You should have received a copy of the GNU General Public License     *
- * along with this program; if not, write to the                         *
- * Free Software Foundation, Inc.,                                       *
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- *                                                                       *
- *************************************************************************
-
-       Module Name:
-       md5.h
-
-       Abstract:
-
-       Revision History:
-       Who                     When                    What
-       --------        ----------              ----------------------------------------------
-       Name            Date                    Modification logs
-       jan                     10-28-03                Initial
-       Rita            11-23-04                Modify MD5 and SHA-1
-*/
-
-#ifndef        uint8
-#define        uint8  unsigned char
-#endif
-
-#ifndef        uint32
-#define        uint32 unsigned long int
-#endif
-
-
-#ifndef        __MD5_H__
-#define        __MD5_H__
-
-#define MD5_MAC_LEN 16
-
-typedef struct _MD5_CTX {
-    UINT32   Buf[4];             // buffers of four states
-       UCHAR   Input[64];          // input message
-       UINT32   LenInBitCount[2];   // length counter for input message, 0 up to 64 bits
-}   MD5_CTX;
-
-VOID MD5Init(MD5_CTX *pCtx);
-VOID MD5Update(MD5_CTX *pCtx, UCHAR *pData, UINT32 LenInBytes);
-VOID MD5Final(UCHAR Digest[16], MD5_CTX *pCtx);
-VOID MD5Transform(UINT32 Buf[4], UINT32 Mes[16]);
-
-void md5_mac(u8 *key, size_t key_len, u8 *data, size_t data_len, u8 *mac);
-void hmac_md5(u8 *key, size_t key_len, u8 *data, size_t data_len, u8 *mac);
-
-//
-// SHA context
-//
-typedef        struct _SHA_CTX
-{
-       UINT32   Buf[5];             // buffers of five states
-       UCHAR   Input[80];          // input message
-       UINT32   LenInBitCount[2];   // length counter for input message, 0 up to 64 bits
-
-}      SHA_CTX;
-
-VOID SHAInit(SHA_CTX *pCtx);
-UCHAR SHAUpdate(SHA_CTX *pCtx, UCHAR *pData, UINT32 LenInBytes);
-VOID SHAFinal(SHA_CTX *pCtx, UCHAR Digest[20]);
-VOID SHATransform(UINT32 Buf[5], UINT32 Mes[20]);
-
-#define SHA_DIGEST_LEN 20
-#endif // __MD5_H__
-
-/******************************************************************************/
-#ifndef        _AES_H
-#define        _AES_H
-
-typedef        struct
-{
-       uint32 erk[64];         /* encryption round     keys */
-       uint32 drk[64];         /* decryption round     keys */
-       int     nr;                             /* number of rounds     */
-}
-aes_context;
-
-int     rtmp_aes_set_key( aes_context *ctx,    uint8 *key,     int     nbits );
-void rtmp_aes_encrypt( aes_context *ctx,       uint8 input[16], uint8 output[16] );
-void rtmp_aes_decrypt( aes_context *ctx,       uint8 input[16], uint8 output[16] );
-
-void F(char *password, unsigned char *ssid, int ssidlength, int iterations, int count, unsigned char *output);
-int PasswordHash(char *password, unsigned char *ssid, int ssidlength, unsigned char *output);
-
-#endif /* aes.h        */
-
+#include "../rt2870/md5.h"
index 3d1a8284fbd4f92235c59d952a54fa7bf13470a4..773c0edfcea925df6d31925d409abacd6f0fa236 100644 (file)
@@ -1,1138 +1 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify  *
- * it under the terms of the GNU General Public License as published by  *
- * the Free Software Foundation; either version 2 of the License, or     *
- * (at your option) any later version.                                   *
- *                                                                       *
- * 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.                          *
- *                                                                       *
- * You should have received a copy of the GNU General Public License     *
- * along with this program; if not, write to the                         *
- * Free Software Foundation, Inc.,                                       *
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- *                                                                       *
- *************************************************************************
-
-       Module Name:
-       mlme.h
-
-       Abstract:
-
-       Revision History:
-       Who                     When                    What
-       --------        ----------              ----------------------------------------------
-       John Chang      2003-08-28              Created
-       John Chang  2004-09-06      modified for RT2600
-
-*/
-#ifndef __MLME_H__
-#define __MLME_H__
-
-// maximum supported capability information -
-// ESS, IBSS, Privacy, Short Preamble, Spectrum mgmt, Short Slot
-#define SUPPORTED_CAPABILITY_INFO   0x0533
-
-#define END_OF_ARGS                 -1
-#define LFSR_MASK                   0x80000057
-#define MLME_TASK_EXEC_INTV         100/*200*/       //
-#define LEAD_TIME                   5
-#define MLME_TASK_EXEC_MULTIPLE       10  /*5*/       // MLME_TASK_EXEC_MULTIPLE * MLME_TASK_EXEC_INTV = 1 sec
-#define REORDER_EXEC_INTV              100       // 0.1 sec
-
-// The definition of Radar detection duration region
-#define CE             0
-#define FCC            1
-#define JAP            2
-#define JAP_W53        3
-#define JAP_W56        4
-#define MAX_RD_REGION 5
-
-#ifdef NDIS51_MINIPORT
-#define BEACON_LOST_TIME            4000       // 2048 msec = 2 sec
-#else
-#define BEACON_LOST_TIME            4 * OS_HZ    // 2048 msec = 2 sec
-#endif
-
-#define DLS_TIMEOUT                 1200      // unit: msec
-#define AUTH_TIMEOUT                300       // unit: msec
-#define ASSOC_TIMEOUT               300       // unit: msec
-#define JOIN_TIMEOUT                2 * OS_HZ      // unit: msec
-#define SHORT_CHANNEL_TIME          90        // unit: msec
-#define MIN_CHANNEL_TIME            110        // unit: msec, for dual band scan
-#define MAX_CHANNEL_TIME            140       // unit: msec, for single band scan
-#define        FAST_ACTIVE_SCAN_TIME       30            // Active scan waiting for probe response time
-#define CW_MIN_IN_BITS              4         // actual CwMin = 2^CW_MIN_IN_BITS - 1
-#define CW_MAX_IN_BITS              10        // actual CwMax = 2^CW_MAX_IN_BITS - 1
-
-// Note: RSSI_TO_DBM_OFFSET has been changed to variable for new RF (2004-0720).
-// SHould not refer to this constant anymore
-//#define RSSI_TO_DBM_OFFSET          120 // for RT2530 RSSI-115 = dBm
-#define RSSI_FOR_MID_TX_POWER       -55  // -55 db is considered mid-distance
-#define RSSI_FOR_LOW_TX_POWER       -45  // -45 db is considered very short distance and
-                                        // eligible to use a lower TX power
-#define RSSI_FOR_LOWEST_TX_POWER    -30
-//#define MID_TX_POWER_DELTA          0   // 0 db from full TX power upon mid-distance to AP
-#define LOW_TX_POWER_DELTA          6    // -3 db from full TX power upon very short distance. 1 grade is 0.5 db
-#define LOWEST_TX_POWER_DELTA       16   // -8 db from full TX power upon shortest distance. 1 grade is 0.5 db
-
-#define RSSI_TRIGGERED_UPON_BELOW_THRESHOLD     0
-#define RSSI_TRIGGERED_UPON_EXCCEED_THRESHOLD   1
-#define RSSI_THRESHOLD_FOR_ROAMING              25
-#define RSSI_DELTA                              5
-
-// Channel Quality Indication
-#define CQI_IS_GOOD(cqi)            ((cqi) >= 50)
-//#define CQI_IS_FAIR(cqi)          (((cqi) >= 20) && ((cqi) < 50))
-#define CQI_IS_POOR(cqi)            (cqi < 50)  //(((cqi) >= 5) && ((cqi) < 20))
-#define CQI_IS_BAD(cqi)             (cqi < 5)
-#define CQI_IS_DEAD(cqi)            (cqi == 0)
-
-// weighting factor to calculate Channel quality, total should be 100%
-#define RSSI_WEIGHTING                   50
-#define TX_WEIGHTING                     30
-#define RX_WEIGHTING                     20
-
-#define BSS_NOT_FOUND                    0xFFFFFFFF
-
-#define MAX_LEN_OF_MLME_QUEUE            40 //10
-
-#define SCAN_PASSIVE                     18            // scan with no probe request, only wait beacon and probe response
-#define SCAN_ACTIVE                      19            // scan with probe request, and wait beacon and probe response
-#define        SCAN_CISCO_PASSIVE                               20             // Single channel passive scan
-#define        SCAN_CISCO_ACTIVE                                21             // Single channel active scan
-#define        SCAN_CISCO_NOISE                                 22             // Single channel passive scan for noise histogram collection
-#define        SCAN_CISCO_CHANNEL_LOAD                  23             // Single channel passive scan for channel load collection
-#define FAST_SCAN_ACTIVE                 24            // scan with probe request, and wait beacon and probe response
-
-#define MAC_ADDR_IS_GROUP(Addr)       (((Addr[0]) & 0x01))
-#define MAC_ADDR_HASH(Addr)            (Addr[0] ^ Addr[1] ^ Addr[2] ^ Addr[3] ^ Addr[4] ^ Addr[5])
-#define MAC_ADDR_HASH_INDEX(Addr)      (MAC_ADDR_HASH(Addr) % HASH_TABLE_SIZE)
-#define TID_MAC_HASH(Addr,TID)            (TID^Addr[0] ^ Addr[1] ^ Addr[2] ^ Addr[3] ^ Addr[4] ^ Addr[5])
-#define TID_MAC_HASH_INDEX(Addr,TID)      (TID_MAC_HASH(Addr,TID) % HASH_TABLE_SIZE)
-
-// LED Control
-// assoiation ON. one LED ON. another blinking when TX, OFF when idle
-// no association, both LED off
-#define ASIC_LED_ACT_ON(pAd)        RTMP_IO_WRITE32(pAd, MAC_CSR14, 0x00031e46)
-#define ASIC_LED_ACT_OFF(pAd)       RTMP_IO_WRITE32(pAd, MAC_CSR14, 0x00001e46)
-
-// bit definition of the 2-byte pBEACON->Capability field
-#define CAP_IS_ESS_ON(x)                 (((x) & 0x0001) != 0)
-#define CAP_IS_IBSS_ON(x)                (((x) & 0x0002) != 0)
-#define CAP_IS_CF_POLLABLE_ON(x)         (((x) & 0x0004) != 0)
-#define CAP_IS_CF_POLL_REQ_ON(x)         (((x) & 0x0008) != 0)
-#define CAP_IS_PRIVACY_ON(x)             (((x) & 0x0010) != 0)
-#define CAP_IS_SHORT_PREAMBLE_ON(x)      (((x) & 0x0020) != 0)
-#define CAP_IS_PBCC_ON(x)                (((x) & 0x0040) != 0)
-#define CAP_IS_AGILITY_ON(x)             (((x) & 0x0080) != 0)
-#define CAP_IS_SPECTRUM_MGMT(x)          (((x) & 0x0100) != 0)  // 802.11e d9
-#define CAP_IS_QOS(x)                    (((x) & 0x0200) != 0)  // 802.11e d9
-#define CAP_IS_SHORT_SLOT(x)             (((x) & 0x0400) != 0)
-#define CAP_IS_APSD(x)                   (((x) & 0x0800) != 0)  // 802.11e d9
-#define CAP_IS_IMMED_BA(x)               (((x) & 0x1000) != 0)  // 802.11e d9
-#define CAP_IS_DSSS_OFDM(x)              (((x) & 0x2000) != 0)
-#define CAP_IS_DELAY_BA(x)               (((x) & 0x4000) != 0)  // 802.11e d9
-
-#define CAP_GENERATE(ess,ibss,priv,s_pre,s_slot,spectrum)  (((ess) ? 0x0001 : 0x0000) | ((ibss) ? 0x0002 : 0x0000) | ((priv) ? 0x0010 : 0x0000) | ((s_pre) ? 0x0020 : 0x0000) | ((s_slot) ? 0x0400 : 0x0000) | ((spectrum) ? 0x0100 : 0x0000))
-
-#define ERP_IS_NON_ERP_PRESENT(x)        (((x) & 0x01) != 0)    // 802.11g
-#define ERP_IS_USE_PROTECTION(x)         (((x) & 0x02) != 0)    // 802.11g
-#define ERP_IS_USE_BARKER_PREAMBLE(x)    (((x) & 0x04) != 0)    // 802.11g
-
-#define DRS_TX_QUALITY_WORST_BOUND       8// 3  // just test by gary
-#define DRS_PENALTY                      8
-
-#define BA_NOTUSE      2
-//BA Policy subfiled value in ADDBA frame
-#define IMMED_BA       1
-#define DELAY_BA       0
-
-// BA Initiator subfield in DELBA frame
-#define ORIGINATOR     1
-#define RECIPIENT      0
-
-// ADDBA Status Code
-#define ADDBA_RESULTCODE_SUCCESS                                       0
-#define ADDBA_RESULTCODE_REFUSED                                       37
-#define ADDBA_RESULTCODE_INVALID_PARAMETERS                    38
-
-// DELBA Reason Code
-#define DELBA_REASONCODE_QSTA_LEAVING                          36
-#define DELBA_REASONCODE_END_BA                                                37
-#define DELBA_REASONCODE_UNKNOWN_BA                                    38
-#define DELBA_REASONCODE_TIMEOUT                                       39
-
-// reset all OneSecTx counters
-#define RESET_ONE_SEC_TX_CNT(__pEntry) \
-if (((__pEntry)) != NULL) \
-{ \
-       (__pEntry)->OneSecTxRetryOkCount = 0; \
-       (__pEntry)->OneSecTxFailCount = 0; \
-       (__pEntry)->OneSecTxNoRetryOkCount = 0; \
-}
-
-//
-// 802.11 frame formats
-//
-//  HT Capability INFO field in HT Cap IE .
-typedef struct PACKED {
-       USHORT  AdvCoding:1;
-       USHORT  ChannelWidth:1;
-       USHORT  MimoPs:2;//momi power safe
-       USHORT  GF:1;   //green field
-       USHORT  ShortGIfor20:1;
-       USHORT  ShortGIfor40:1; //for40MHz
-       USHORT  TxSTBC:1;
-       USHORT  RxSTBC:2;
-       USHORT  DelayedBA:1;    //rt2860c not support
-       USHORT  AMsduSize:1;    // only support as zero
-       USHORT  CCKmodein40:1;
-       USHORT  PSMP:1;
-       USHORT  Forty_Mhz_Intolerant:1;
-       USHORT  LSIGTxopProSup:1;
-} HT_CAP_INFO, *PHT_CAP_INFO;
-
-//  HT Capability INFO field in HT Cap IE .
-typedef struct PACKED {
-       UCHAR   MaxRAmpduFactor:2;
-       UCHAR   MpduDensity:3;
-       UCHAR   rsv:3;//momi power safe
-} HT_CAP_PARM, *PHT_CAP_PARM;
-
-//  HT Capability INFO field in HT Cap IE .
-typedef struct PACKED {
-       UCHAR   MCSSet[10];
-       UCHAR   SupRate[2];  // unit : 1Mbps
-       UCHAR   TxMCSSetDefined:1;
-       UCHAR   TxRxNotEqual:1;
-       UCHAR   TxStream:2;
-       UCHAR   MpduDensity:1;
-       UCHAR   rsv:3;
-       UCHAR   rsv3[3];
-} HT_MCS_SET, *PHT_MCS_SET;
-
-//  HT Capability INFO field in HT Cap IE .
-typedef struct PACKED {
-       USHORT  Pco:1;
-       USHORT  TranTime:2;
-       USHORT  rsv:5;//momi power safe
-       USHORT  MCSFeedback:2;  //0:no MCS feedback, 2:unsolicited MCS feedback, 3:Full MCS feedback,  1:rsv.
-       USHORT  PlusHTC:1;      //+HTC control field support
-       USHORT  RDGSupport:1;   //reverse Direction Grant  support
-       USHORT  rsv2:4;
-} EXT_HT_CAP_INFO, *PEXT_HT_CAP_INFO;
-
-//  HT Beamforming field in HT Cap IE .
-typedef struct PACKED _HT_BF_CAP{
-       ULONG   TxBFRecCapable:1;
-       ULONG   RxSoundCapable:1;
-       ULONG   TxSoundCapable:1;
-       ULONG   RxNDPCapable:1;
-       ULONG   TxNDPCapable:1;
-       ULONG   ImpTxBFCapable:1;
-       ULONG   Calibration:2;
-       ULONG   ExpCSICapable:1;
-       ULONG   ExpNoComSteerCapable:1;
-       ULONG   ExpComSteerCapable:1;
-       ULONG   ExpCSIFbk:2;
-       ULONG   ExpNoComBF:2;
-       ULONG   ExpComBF:2;
-       ULONG   MinGrouping:2;
-       ULONG   CSIBFAntSup:2;
-       ULONG   NoComSteerBFAntSup:2;
-       ULONG   ComSteerBFAntSup:2;
-       ULONG   CSIRowBFSup:2;
-       ULONG   ChanEstimation:2;
-       ULONG   rsv:3;
-} HT_BF_CAP, *PHT_BF_CAP;
-
-//  HT antenna selection field in HT Cap IE .
-typedef struct PACKED _HT_AS_CAP{
-       UCHAR   AntSelect:1;
-       UCHAR   ExpCSIFbkTxASEL:1;
-       UCHAR   AntIndFbkTxASEL:1;
-       UCHAR   ExpCSIFbk:1;
-       UCHAR   AntIndFbk:1;
-       UCHAR   RxASel:1;
-       UCHAR   TxSoundPPDU:1;
-       UCHAR   rsv:1;
-} HT_AS_CAP, *PHT_AS_CAP;
-
-// Draft 1.0 set IE length 26, but is extensible..
-#define SIZE_HT_CAP_IE         26
-// The structure for HT Capability IE.
-typedef struct PACKED _HT_CAPABILITY_IE{
-       HT_CAP_INFO             HtCapInfo;
-       HT_CAP_PARM             HtCapParm;
-//     HT_MCS_SET              HtMCSSet;
-       UCHAR                   MCSSet[16];
-       EXT_HT_CAP_INFO ExtHtCapInfo;
-       HT_BF_CAP               TxBFCap;        // beamforming cap. rt2860c not support beamforming.
-       HT_AS_CAP               ASCap;  //antenna selection.
-} HT_CAPABILITY_IE, *PHT_CAPABILITY_IE;
-
-
-// 802.11n draft3 related structure definitions.
-// 7.3.2.60
-#define dot11OBSSScanPassiveDwell                                                      20      // in TU. min amount of time that the STA continously scans each channel when performing an active OBSS scan.
-#define dot11OBSSScanActiveDwell                                                       10      // in TU.min amount of time that the STA continously scans each channel when performing an passive OBSS scan.
-#define dot11BSSWidthTriggerScanInterval                                       300  // in sec. max interval between scan operations to be performed to detect BSS channel width trigger events.
-#define dot11OBSSScanPassiveTotalPerChannel                                    200     // in TU. min total amount of time that the STA scans each channel when performing a passive OBSS scan.
-#define dot11OBSSScanActiveTotalPerChannel                                     20      //in TU. min total amount of time that the STA scans each channel when performing a active OBSS scan
-#define dot11BSSWidthChannelTransactionDelayFactor                     5       // min ratio between the delay time in performing a switch from 20MHz BSS to 20/40 BSS operation and the maxima
-                                                                                                                               //      interval between overlapping BSS scan operations.
-#define dot11BSSScanActivityThreshold                                          25      // in %%, max total time that a STA may be active on the medium during a period of
-                                                                                                                               //      (dot11BSSWidthChannelTransactionDelayFactor * dot11BSSWidthTriggerScanInterval) seconds without
-                                                                                                                               //      being obligated to perform OBSS Scan operations. default is 25(== 0.25%)
-
-typedef struct PACKED _OVERLAP_BSS_SCAN_IE{
-       USHORT          ScanPassiveDwell;
-       USHORT          ScanActiveDwell;
-       USHORT          TriggerScanInt;                         // Trigger scan interval
-       USHORT          PassiveTalPerChannel;           // passive total per channel
-       USHORT          ActiveTalPerChannel;            // active total per channel
-       USHORT          DelayFactor;                            // BSS width channel transition delay factor
-       USHORT          ScanActThre;                            // Scan Activity threshold
-}OVERLAP_BSS_SCAN_IE, *POVERLAP_BSS_SCAN_IE;
-
-
-//  7.3.2.56. 20/40 Coexistence element used in  Element ID = 72 = IE_2040_BSS_COEXIST
-typedef union PACKED _BSS_2040_COEXIST_IE{
- struct PACKED {
-       UCHAR   InfoReq:1;
-       UCHAR   Intolerant40:1;                 // Inter-BSS. set 1 when prohibits a receiving BSS from operating as a 20/40 Mhz BSS.
-       UCHAR   BSS20WidthReq:1;                // Intra-BSS set 1 when prohibits a receiving AP from operating its BSS as a 20/40MHz BSS.
-       UCHAR   rsv:5;
-    } field;
- UCHAR   word;
-} BSS_2040_COEXIST_IE, *PBSS_2040_COEXIST_IE;
-
-
-typedef struct  _TRIGGER_EVENTA{
-       BOOLEAN                 bValid;
-       UCHAR   BSSID[6];
-       UCHAR   RegClass;       // Regulatory Class
-       USHORT  Channel;
-       ULONG   CDCounter;   // Maintain a seperate count down counter for each Event A.
-} TRIGGER_EVENTA, *PTRIGGER_EVENTA;
-
-// 20/40 trigger event table
-// If one Event A delete or created, or if Event B is detected or not detected, STA should send 2040BSSCoexistence to AP.
-#define MAX_TRIGGER_EVENT              64
-typedef struct  _TRIGGER_EVENT_TAB{
-       UCHAR   EventANo;
-       TRIGGER_EVENTA  EventA[MAX_TRIGGER_EVENT];
-       ULONG                   EventBCountDown;        // Count down counter for Event B.
-} TRIGGER_EVENT_TAB, *PTRIGGER_EVENT_TAB;
-
-// 7.3.27 20/40 Bss Coexistence Mgmt capability used in extended capabilities information IE( ID = 127 = IE_EXT_CAPABILITY).
-//     This is the first octet and was defined in 802.11n D3.03 and 802.11yD9.0
-typedef struct PACKED _EXT_CAP_INFO_ELEMENT{
-       UCHAR   BssCoexistMgmtSupport:1;
-       UCHAR   rsv:1;
-       UCHAR   ExtendChannelSwitch:1;
-       UCHAR   rsv2:5;
-}EXT_CAP_INFO_ELEMENT, *PEXT_CAP_INFO_ELEMENT;
-
-
-// 802.11n 7.3.2.61
-typedef struct PACKED _BSS_2040_COEXIST_ELEMENT{
-       UCHAR                                   ElementID;              // ID = IE_2040_BSS_COEXIST = 72
-       UCHAR                                   Len;
-       BSS_2040_COEXIST_IE             BssCoexistIe;
-}BSS_2040_COEXIST_ELEMENT, *PBSS_2040_COEXIST_ELEMENT;
-
-
-//802.11n 7.3.2.59
-typedef struct PACKED _BSS_2040_INTOLERANT_CH_REPORT{
-       UCHAR                           ElementID;              // ID = IE_2040_BSS_INTOLERANT_REPORT = 73
-       UCHAR                           Len;
-       UCHAR                           RegulatoryClass;
-       UCHAR                           ChList[0];
-}BSS_2040_INTOLERANT_CH_REPORT, *PBSS_2040_INTOLERANT_CH_REPORT;
-
-
-// The structure for channel switch annoucement IE. This is in 802.11n D3.03
-typedef struct PACKED _CHA_SWITCH_ANNOUNCE_IE{
-       UCHAR                   SwitchMode;     //channel switch mode
-       UCHAR                   NewChannel;     //
-       UCHAR                   SwitchCount;    //
-} CHA_SWITCH_ANNOUNCE_IE, *PCHA_SWITCH_ANNOUNCE_IE;
-
-
-// The structure for channel switch annoucement IE. This is in 802.11n D3.03
-typedef struct PACKED _SEC_CHA_OFFSET_IE{
-       UCHAR                   SecondaryChannelOffset;  // 1: Secondary above, 3: Secondary below, 0: no Secondary
-} SEC_CHA_OFFSET_IE, *PSEC_CHA_OFFSET_IE;
-
-
-// This structure is extracted from struct RT_HT_CAPABILITY
-typedef struct {
-       BOOLEAN                 bHtEnable;       // If we should use ht rate.
-       BOOLEAN                 bPreNHt;         // If we should use ht rate.
-       //Substract from HT Capability IE
-       UCHAR                   MCSSet[16];     //only supoort MCS=0-15,32 ,
-} RT_HT_PHY_INFO, *PRT_HT_PHY_INFO;
-
-//This structure substracts ralink supports from all 802.11n-related features.
-//Features not listed here but contained in 802.11n spec are not supported in rt2860.
-typedef struct {
-       USHORT  ChannelWidth:1;
-       USHORT  MimoPs:2;//mimo power safe MMPS_
-       USHORT  GF:1;   //green field
-       USHORT  ShortGIfor20:1;
-       USHORT  ShortGIfor40:1; //for40MHz
-       USHORT  TxSTBC:1;
-       USHORT  RxSTBC:2;       // 2 bits
-       USHORT  AmsduEnable:1;  // Enable to transmit A-MSDU. Suggest disable. We should use A-MPDU to gain best benifit of 802.11n
-       USHORT  AmsduSize:1;    // Max receiving A-MSDU size
-       USHORT  rsv:5;
-
-       //Substract from Addiont HT INFO IE
-       UCHAR   MaxRAmpduFactor:2;
-       UCHAR   MpduDensity:3;
-       UCHAR   ExtChanOffset:2;        // Please not the difference with following     UCHAR   NewExtChannelOffset; from 802.11n
-       UCHAR   RecomWidth:1;
-
-       USHORT  OperaionMode:2;
-       USHORT  NonGfPresent:1;
-       USHORT  rsv3:1;
-       USHORT  OBSS_NonHTExist:1;
-       USHORT  rsv2:11;
-
-       // New Extension Channel Offset IE
-       UCHAR   NewExtChannelOffset;
-       // Extension Capability IE = 127
-       UCHAR   BSSCoexist2040;
-} RT_HT_CAPABILITY, *PRT_HT_CAPABILITY;
-
-//   field in Addtional HT Information IE .
-typedef struct PACKED {
-       UCHAR   ExtChanOffset:2;
-       UCHAR   RecomWidth:1;
-       UCHAR   RifsMode:1;
-       UCHAR   S_PSMPSup:1;     //Indicate support for scheduled PSMP
-       UCHAR   SerInterGranu:3;         //service interval granularity
-} ADD_HTINFO, *PADD_HTINFO;
-
-typedef struct PACKED{
-       USHORT  OperaionMode:2;
-       USHORT  NonGfPresent:1;
-       USHORT  rsv:1;
-       USHORT  OBSS_NonHTExist:1;
-       USHORT  rsv2:11;
-} ADD_HTINFO2, *PADD_HTINFO2;
-
-
-// TODO: Need sync with spec about the definition of StbcMcs. In Draft 3.03, it's reserved.
-typedef struct PACKED{
-       USHORT  StbcMcs:6;
-       USHORT  DualBeacon:1;
-       USHORT  DualCTSProtect:1;
-       USHORT  STBCBeacon:1;
-       USHORT  LsigTxopProt:1; // L-SIG TXOP protection full support
-       USHORT  PcoActive:1;
-       USHORT  PcoPhase:1;
-       USHORT  rsv:4;
-} ADD_HTINFO3, *PADD_HTINFO3;
-
-#define SIZE_ADD_HT_INFO_IE            22
-typedef struct  PACKED{
-       UCHAR                           ControlChan;
-       ADD_HTINFO                      AddHtInfo;
-       ADD_HTINFO2                     AddHtInfo2;
-       ADD_HTINFO3                     AddHtInfo3;
-       UCHAR                           MCSSet[16];             // Basic MCS set
-} ADD_HT_INFO_IE, *PADD_HT_INFO_IE;
-
-typedef struct  PACKED{
-       UCHAR                           NewExtChanOffset;
-} NEW_EXT_CHAN_IE, *PNEW_EXT_CHAN_IE;
-
-
-// 4-byte HTC field.  maybe included in any frame except non-QOS data frame.  The Order bit must set 1.
-typedef struct PACKED {
-    UINT32             MA:1;   //management action payload exist in (QoS Null+HTC)
-    UINT32             TRQ:1;  //sounding request
-    UINT32             MRQ:1;  //MCS feedback. Request for a MCS feedback
-    UINT32             MRSorASI:3;     // MRQ Sequence identifier. unchanged during entire procedure. 0x000-0x110.
-    UINT32             MFS:3;  //SET to the received value of MRS. 0x111 for unsolicited MFB.
-    UINT32             MFBorASC:7;     //Link adaptation feedback containing recommended MCS. 0x7f for no feedback or not available
-    UINT32             CalPos:2;       // calibration position
-    UINT32             CalSeq:2;  //calibration sequence
-    UINT32             FBKReq:2;       //feedback request
-    UINT32             CSISTEERING:2;  //CSI/ STEERING
-    UINT32             ZLFAnnouce:1;   // ZLF announcement
-    UINT32             rsv:5;  //calibration sequence
-    UINT32             ACConstraint:1; //feedback request
-    UINT32             RDG:1;  //RDG / More PPDU
-} HT_CONTROL, *PHT_CONTROL;
-
-// 2-byte QOS CONTROL field
-typedef struct PACKED {
-    USHORT      TID:4;
-    USHORT      EOSP:1;
-    USHORT      AckPolicy:2;  //0: normal ACK 1:No ACK 2:scheduled under MTBA/PSMP  3: BA
-    USHORT      AMsduPresent:1;
-    USHORT      Txop_QueueSize:8;
-} QOS_CONTROL, *PQOS_CONTROL;
-
-// 2-byte Frame control field
-typedef        struct  PACKED {
-       USHORT          Ver:2;                          // Protocol version
-       USHORT          Type:2;                         // MSDU type
-       USHORT          SubType:4;                      // MSDU subtype
-       USHORT          ToDs:1;                         // To DS indication
-       USHORT          FrDs:1;                         // From DS indication
-       USHORT          MoreFrag:1;                     // More fragment bit
-       USHORT          Retry:1;                        // Retry status bit
-       USHORT          PwrMgmt:1;                      // Power management bit
-       USHORT          MoreData:1;                     // More data bit
-       USHORT          Wep:1;                          // Wep data
-       USHORT          Order:1;                        // Strict order expected
-} FRAME_CONTROL, *PFRAME_CONTROL;
-
-typedef        struct  PACKED _HEADER_802_11   {
-    FRAME_CONTROL   FC;
-    USHORT          Duration;
-    UCHAR           Addr1[MAC_ADDR_LEN];
-    UCHAR           Addr2[MAC_ADDR_LEN];
-       UCHAR                   Addr3[MAC_ADDR_LEN];
-       USHORT                  Frag:4;
-       USHORT                  Sequence:12;
-       UCHAR                   Octet[0];
-}      HEADER_802_11, *PHEADER_802_11;
-
-typedef struct PACKED _FRAME_802_11 {
-    HEADER_802_11   Hdr;
-    UCHAR            Octet[1];
-}   FRAME_802_11, *PFRAME_802_11;
-
-// QoSNull embedding of management action. When HT Control MA field set to 1.
-typedef struct PACKED _MA_BODY {
-    UCHAR            Category;
-    UCHAR            Action;
-    UCHAR            Octet[1];
-}   MA_BODY, *PMA_BODY;
-
-typedef        struct  PACKED _HEADER_802_3    {
-    UCHAR           DAAddr1[MAC_ADDR_LEN];
-    UCHAR           SAAddr2[MAC_ADDR_LEN];
-    UCHAR           Octet[2];
-}      HEADER_802_3, *PHEADER_802_3;
-////Block ACK related format
-// 2-byte BA Parameter  field  in      DELBA frames to terminate an already set up bA
-typedef struct PACKED{
-    USHORT      Rsv:11;        // always set to 0
-    USHORT      Initiator:1;   // 1: originator    0:recipient
-    USHORT      TID:4; // value of TC os TS
-} DELBA_PARM, *PDELBA_PARM;
-
-// 2-byte BA Parameter Set field  in ADDBA frames to signal parm for setting up a BA
-typedef struct PACKED {
-    USHORT      AMSDUSupported:1;      // 0: not permitted             1: permitted
-    USHORT      BAPolicy:1;    // 1: immediately BA    0:delayed BA
-    USHORT      TID:4; // value of TC os TS
-    USHORT      BufSize:10;    // number of buffe of size 2304 octetsr
-} BA_PARM, *PBA_PARM;
-
-// 2-byte BA Starting Seq CONTROL field
-typedef union PACKED {
-    struct PACKED {
-    USHORT      FragNum:4;     // always set to 0
-       USHORT      StartSeq:12;   // sequence number of the 1st MSDU for which this BAR is sent
-    }   field;
-    USHORT           word;
-} BASEQ_CONTROL, *PBASEQ_CONTROL;
-
-//BAControl and BARControl are the same
-// 2-byte BA CONTROL field in BA frame
-typedef struct PACKED {
-    USHORT      ACKPolicy:1; // only related to N-Delayed BA. But not support in RT2860b. 0:NormalACK  1:No ACK
-    USHORT      MTID:1;                //EWC V1.24
-    USHORT      Compressed:1;
-    USHORT      Rsv:9;
-    USHORT      TID:4;
-} BA_CONTROL, *PBA_CONTROL;
-
-// 2-byte BAR CONTROL field in BAR frame
-typedef struct PACKED {
-    USHORT      ACKPolicy:1; // 0:normal ack,  1:no ack.
-    USHORT      MTID:1;                //if this bit1, use  FRAME_MTBA_REQ,  if 0, use FRAME_BA_REQ
-    USHORT      Compressed:1;
-    USHORT      Rsv1:9;
-    USHORT      TID:4;
-} BAR_CONTROL, *PBAR_CONTROL;
-
-// BARControl in MTBAR frame
-typedef struct PACKED {
-    USHORT      ACKPolicy:1;
-    USHORT      MTID:1;
-    USHORT      Compressed:1;
-    USHORT      Rsv1:9;
-    USHORT      NumTID:4;
-} MTBAR_CONTROL, *PMTBAR_CONTROL;
-
-typedef struct PACKED {
-    USHORT      Rsv1:12;
-    USHORT      TID:4;
-} PER_TID_INFO, *PPER_TID_INFO;
-
-typedef struct {
-       PER_TID_INFO      PerTID;
-       BASEQ_CONTROL    BAStartingSeq;
-} EACH_TID, *PEACH_TID;
-
-
-typedef struct PACKED _PSPOLL_FRAME {
-    FRAME_CONTROL   FC;
-    USHORT          Aid;
-    UCHAR           Bssid[MAC_ADDR_LEN];
-    UCHAR           Ta[MAC_ADDR_LEN];
-}   PSPOLL_FRAME, *PPSPOLL_FRAME;
-
-typedef        struct  PACKED _RTS_FRAME       {
-    FRAME_CONTROL   FC;
-    USHORT          Duration;
-    UCHAR           Addr1[MAC_ADDR_LEN];
-    UCHAR           Addr2[MAC_ADDR_LEN];
-}RTS_FRAME, *PRTS_FRAME;
-
-// BAREQ AND MTBAREQ have the same subtype BAR, 802.11n BAR use compressed bitmap.
-typedef struct PACKED _FRAME_BA_REQ {
-       FRAME_CONTROL   FC;
-       USHORT          Duration;
-       UCHAR           Addr1[MAC_ADDR_LEN];
-       UCHAR           Addr2[MAC_ADDR_LEN];
-       BAR_CONTROL  BARControl;
-       BASEQ_CONTROL    BAStartingSeq;
-}   FRAME_BA_REQ, *PFRAME_BA_REQ;
-
-typedef struct PACKED _FRAME_MTBA_REQ {
-       FRAME_CONTROL   FC;
-       USHORT          Duration;
-       UCHAR           Addr1[MAC_ADDR_LEN];
-       UCHAR           Addr2[MAC_ADDR_LEN];
-       MTBAR_CONTROL  MTBARControl;
-       PER_TID_INFO    PerTIDInfo;
-       BASEQ_CONTROL    BAStartingSeq;
-}   FRAME_MTBA_REQ, *PFRAME_MTBA_REQ;
-
-// Compressed format is mandantory in HT STA
-typedef struct PACKED _FRAME_MTBA {
-       FRAME_CONTROL   FC;
-       USHORT          Duration;
-       UCHAR           Addr1[MAC_ADDR_LEN];
-       UCHAR           Addr2[MAC_ADDR_LEN];
-       BA_CONTROL  BAControl;
-       BASEQ_CONTROL    BAStartingSeq;
-       UCHAR           BitMap[8];
-}   FRAME_MTBA, *PFRAME_MTBA;
-
-typedef struct PACKED _FRAME_PSMP_ACTION {
-       HEADER_802_11   Hdr;
-       UCHAR   Category;
-       UCHAR   Action;
-       UCHAR   Psmp;   // 7.3.1.25
-}   FRAME_PSMP_ACTION, *PFRAME_PSMP_ACTION;
-
-typedef struct PACKED _FRAME_ACTION_HDR {
-       HEADER_802_11   Hdr;
-       UCHAR   Category;
-       UCHAR   Action;
-}   FRAME_ACTION_HDR, *PFRAME_ACTION_HDR;
-
-//Action Frame
-//Action Frame  Category:Spectrum,  Action:Channel Switch. 7.3.2.20
-typedef struct PACKED _CHAN_SWITCH_ANNOUNCE {
-       UCHAR                                   ElementID;      // ID = IE_CHANNEL_SWITCH_ANNOUNCEMENT = 37
-       UCHAR                                   Len;
-       CHA_SWITCH_ANNOUNCE_IE  CSAnnounceIe;
-}   CHAN_SWITCH_ANNOUNCE, *PCHAN_SWITCH_ANNOUNCE;
-
-
-//802.11n : 7.3.2.20a
-typedef struct PACKED _SECOND_CHAN_OFFSET {
-       UCHAR                           ElementID;              // ID = IE_SECONDARY_CH_OFFSET = 62
-       UCHAR                           Len;
-       SEC_CHA_OFFSET_IE       SecChOffsetIe;
-}   SECOND_CHAN_OFFSET, *PSECOND_CHAN_OFFSET;
-
-
-typedef struct PACKED _FRAME_SPETRUM_CS {
-       HEADER_802_11   Hdr;
-       UCHAR   Category;
-       UCHAR   Action;
-       CHAN_SWITCH_ANNOUNCE    CSAnnounce;
-       SECOND_CHAN_OFFSET              SecondChannel;
-}   FRAME_SPETRUM_CS, *PFRAME_SPETRUM_CS;
-
-
-typedef struct PACKED _FRAME_ADDBA_REQ {
-       HEADER_802_11   Hdr;
-       UCHAR   Category;
-       UCHAR   Action;
-       UCHAR   Token;  // 1
-       BA_PARM         BaParm;       //  2 - 10
-       USHORT          TimeOutValue;   // 0 - 0
-       BASEQ_CONTROL   BaStartSeq; // 0-0
-}   FRAME_ADDBA_REQ, *PFRAME_ADDBA_REQ;
-
-typedef struct PACKED _FRAME_ADDBA_RSP {
-       HEADER_802_11   Hdr;
-       UCHAR   Category;
-       UCHAR   Action;
-       UCHAR   Token;
-       USHORT  StatusCode;
-       BA_PARM         BaParm; //0 - 2
-       USHORT          TimeOutValue;
-}   FRAME_ADDBA_RSP, *PFRAME_ADDBA_RSP;
-
-typedef struct PACKED _FRAME_DELBA_REQ {
-       HEADER_802_11   Hdr;
-       UCHAR   Category;
-       UCHAR   Action;
-       DELBA_PARM              DelbaParm;
-       USHORT  ReasonCode;
-}   FRAME_DELBA_REQ, *PFRAME_DELBA_REQ;
-
-
-//7.2.1.7
-typedef struct PACKED _FRAME_BAR {
-       FRAME_CONTROL   FC;
-       USHORT          Duration;
-       UCHAR           Addr1[MAC_ADDR_LEN];
-       UCHAR           Addr2[MAC_ADDR_LEN];
-       BAR_CONTROL             BarControl;
-       BASEQ_CONTROL   StartingSeq;
-}   FRAME_BAR, *PFRAME_BAR;
-
-//7.2.1.7
-typedef struct PACKED _FRAME_BA {
-       FRAME_CONTROL   FC;
-       USHORT          Duration;
-       UCHAR           Addr1[MAC_ADDR_LEN];
-       UCHAR           Addr2[MAC_ADDR_LEN];
-       BAR_CONTROL             BarControl;
-       BASEQ_CONTROL   StartingSeq;
-       UCHAR           bitmask[8];
-}   FRAME_BA, *PFRAME_BA;
-
-
-// Radio Measuement Request Frame Format
-typedef struct PACKED _FRAME_RM_REQ_ACTION {
-       HEADER_802_11   Hdr;
-       UCHAR   Category;
-       UCHAR   Action;
-       UCHAR   Token;
-       USHORT  Repetition;
-       UCHAR   data[0];
-}   FRAME_RM_REQ_ACTION, *PFRAME_RM_REQ_ACTION;
-
-typedef struct PACKED {
-       UCHAR           ID;
-       UCHAR           Length;
-       UCHAR           ChannelSwitchMode;
-       UCHAR           NewRegClass;
-       UCHAR           NewChannelNum;
-       UCHAR           ChannelSwitchCount;
-} HT_EXT_CHANNEL_SWITCH_ANNOUNCEMENT_IE, *PHT_EXT_CHANNEL_SWITCH_ANNOUNCEMENT_IE;
-
-
-//
-// _Limit must be the 2**n - 1
-// _SEQ1 , _SEQ2 must be within 0 ~ _Limit
-//
-#define SEQ_STEPONE(_SEQ1, _SEQ2, _Limit)      ((_SEQ1 == ((_SEQ2+1) & _Limit)))
-#define SEQ_SMALLER(_SEQ1, _SEQ2, _Limit)      (((_SEQ1-_SEQ2) & ((_Limit+1)>>1)))
-#define SEQ_LARGER(_SEQ1, _SEQ2, _Limit)       ((_SEQ1 != _SEQ2) && !(((_SEQ1-_SEQ2) & ((_Limit+1)>>1))))
-#define SEQ_WITHIN_WIN(_SEQ1, _SEQ2, _WIN, _Limit) (SEQ_LARGER(_SEQ1, _SEQ2, _Limit) &&  \
-                                                                                               SEQ_SMALLER(_SEQ1, ((_SEQ2+_WIN+1)&_Limit), _Limit))
-
-//
-// Contention-free parameter (without ID and Length)
-//
-typedef struct PACKED {
-    BOOLEAN     bValid;         // 1: variable contains valid value
-    UCHAR       CfpCount;
-    UCHAR       CfpPeriod;
-    USHORT      CfpMaxDuration;
-    USHORT      CfpDurRemaining;
-} CF_PARM, *PCF_PARM;
-
-typedef        struct  _CIPHER_SUITE   {
-       NDIS_802_11_ENCRYPTION_STATUS   PairCipher;             // Unicast cipher 1, this one has more secured cipher suite
-       NDIS_802_11_ENCRYPTION_STATUS   PairCipherAux;  // Unicast cipher 2 if AP announce two unicast cipher suite
-       NDIS_802_11_ENCRYPTION_STATUS   GroupCipher;    // Group cipher
-       USHORT                                                  RsnCapability;  // RSN capability from beacon
-       BOOLEAN                                                 bMixMode;               // Indicate Pair & Group cipher might be different
-}      CIPHER_SUITE, *PCIPHER_SUITE;
-
-// EDCA configuration from AP's BEACON/ProbeRsp
-typedef struct {
-    BOOLEAN     bValid;         // 1: variable contains valid value
-    BOOLEAN     bAdd;         // 1: variable contains valid value
-    BOOLEAN     bQAck;
-    BOOLEAN     bQueueRequest;
-    BOOLEAN     bTxopRequest;
-    BOOLEAN     bAPSDCapable;
-//  BOOLEAN     bMoreDataAck;
-    UCHAR       EdcaUpdateCount;
-    UCHAR       Aifsn[4];       // 0:AC_BK, 1:AC_BE, 2:AC_VI, 3:AC_VO
-    UCHAR       Cwmin[4];
-    UCHAR       Cwmax[4];
-    USHORT      Txop[4];      // in unit of 32-us
-    BOOLEAN     bACM[4];      // 1: Admission Control of AC_BK is mandattory
-} EDCA_PARM, *PEDCA_PARM;
-
-// QBSS LOAD information from QAP's BEACON/ProbeRsp
-typedef struct {
-    BOOLEAN     bValid;                     // 1: variable contains valid value
-    USHORT      StaNum;
-    UCHAR       ChannelUtilization;
-    USHORT      RemainingAdmissionControl;  // in unit of 32-us
-} QBSS_LOAD_PARM, *PQBSS_LOAD_PARM;
-
-// QBSS Info field in QSTA's assoc req
-typedef struct PACKED {
-    UCHAR              UAPSD_AC_VO:1;
-       UCHAR           UAPSD_AC_VI:1;
-       UCHAR           UAPSD_AC_BK:1;
-       UCHAR           UAPSD_AC_BE:1;
-       UCHAR           Rsv1:1;
-       UCHAR           MaxSPLength:2;
-       UCHAR           Rsv2:1;
-} QBSS_STA_INFO_PARM, *PQBSS_STA_INFO_PARM;
-
-// QBSS Info field in QAP's Beacon/ProbeRsp
-typedef struct PACKED {
-    UCHAR              ParamSetCount:4;
-       UCHAR           Rsv:3;
-       UCHAR           UAPSD:1;
-} QBSS_AP_INFO_PARM, *PQBSS_AP_INFO_PARM;
-
-// QOS Capability reported in QAP's BEACON/ProbeRsp
-// QOS Capability sent out in QSTA's AssociateReq/ReAssociateReq
-typedef struct {
-    BOOLEAN     bValid;                     // 1: variable contains valid value
-    BOOLEAN     bQAck;
-    BOOLEAN     bQueueRequest;
-    BOOLEAN     bTxopRequest;
-//  BOOLEAN     bMoreDataAck;
-    UCHAR       EdcaUpdateCount;
-} QOS_CAPABILITY_PARM, *PQOS_CAPABILITY_PARM;
-
-typedef struct {
-    UCHAR       IELen;
-    UCHAR       IE[MAX_CUSTOM_LEN];
-} WPA_IE_;
-
-typedef struct {
-    UCHAR   Bssid[MAC_ADDR_LEN];
-    UCHAR   Channel;
-       UCHAR   CentralChannel; //Store the wide-band central channel for 40MHz.  .used in 40MHz AP. Or this is the same as Channel.
-    UCHAR   BssType;
-    USHORT  AtimWin;
-    USHORT  BeaconPeriod;
-
-    UCHAR   SupRate[MAX_LEN_OF_SUPPORTED_RATES];
-    UCHAR   SupRateLen;
-    UCHAR   ExtRate[MAX_LEN_OF_SUPPORTED_RATES];
-    UCHAR   ExtRateLen;
-       HT_CAPABILITY_IE HtCapability;
-       UCHAR                   HtCapabilityLen;
-       ADD_HT_INFO_IE AddHtInfo;       // AP might use this additional ht info IE
-       UCHAR                   AddHtInfoLen;
-       UCHAR                   NewExtChanOffset;
-       CHAR    Rssi;
-    UCHAR   Privacy;                   // Indicate security function ON/OFF. Don't mess up with auth mode.
-       UCHAR   Hidden;
-
-    USHORT  DtimPeriod;
-    USHORT  CapabilityInfo;
-
-    USHORT  CfpCount;
-    USHORT  CfpPeriod;
-    USHORT  CfpMaxDuration;
-    USHORT  CfpDurRemaining;
-    UCHAR   SsidLen;
-    CHAR    Ssid[MAX_LEN_OF_SSID];
-
-    ULONG   LastBeaconRxTime; // OS's timestamp
-
-       BOOLEAN bSES;
-
-       // New for WPA2
-       CIPHER_SUITE                                    WPA;                    // AP announced WPA cipher suite
-       CIPHER_SUITE                                    WPA2;                   // AP announced WPA2 cipher suite
-
-       // New for microsoft WPA support
-       NDIS_802_11_FIXED_IEs   FixIEs;
-       NDIS_802_11_AUTHENTICATION_MODE AuthModeAux;    // Addition mode for WPA2 / WPA capable AP
-       NDIS_802_11_AUTHENTICATION_MODE AuthMode;
-       NDIS_802_11_WEP_STATUS  WepStatus;                              // Unicast Encryption Algorithm extract from VAR_IE
-       USHORT                                  VarIELen;                               // Length of next VIE include EID & Length
-       UCHAR                                   VarIEs[MAX_VIE_LEN];
-
-       // CCX Ckip information
-    UCHAR   CkipFlag;
-
-       // CCX 2 TSF
-       UCHAR   PTSF[4];                // Parent TSF
-       UCHAR   TTSF[8];                // Target TSF
-
-    // 802.11e d9, and WMM
-       EDCA_PARM           EdcaParm;
-       QOS_CAPABILITY_PARM QosCapability;
-       QBSS_LOAD_PARM      QbssLoad;
-    WPA_IE_     WpaIE;
-    WPA_IE_     RsnIE;
-} BSS_ENTRY, *PBSS_ENTRY;
-
-typedef struct {
-    UCHAR           BssNr;
-    UCHAR           BssOverlapNr;
-    BSS_ENTRY       BssEntry[MAX_LEN_OF_BSS_TABLE];
-} BSS_TABLE, *PBSS_TABLE;
-
-
-typedef struct _MLME_QUEUE_ELEM {
-    ULONG             Machine;
-    ULONG             MsgType;
-    ULONG             MsgLen;
-    UCHAR             Msg[MGMT_DMA_BUFFER_SIZE];
-    LARGE_INTEGER     TimeStamp;
-    UCHAR             Rssi0;
-    UCHAR             Rssi1;
-    UCHAR             Rssi2;
-    UCHAR             Signal;
-    UCHAR             Channel;
-    UCHAR             Wcid;
-    BOOLEAN           Occupied;
-} MLME_QUEUE_ELEM, *PMLME_QUEUE_ELEM;
-
-typedef struct _MLME_QUEUE {
-    ULONG             Num;
-    ULONG             Head;
-    ULONG             Tail;
-    NDIS_SPIN_LOCK   Lock;
-    MLME_QUEUE_ELEM  Entry[MAX_LEN_OF_MLME_QUEUE];
-} MLME_QUEUE, *PMLME_QUEUE;
-
-typedef VOID (*STATE_MACHINE_FUNC)(VOID *Adaptor, MLME_QUEUE_ELEM *Elem);
-
-typedef struct _STATE_MACHINE {
-    ULONG                           Base;
-    ULONG                           NrState;
-    ULONG                           NrMsg;
-    ULONG                           CurrState;
-    STATE_MACHINE_FUNC             *TransFunc;
-} STATE_MACHINE, *PSTATE_MACHINE;
-
-
-// MLME AUX data structure that hold temporarliy settings during a connection attempt.
-// Once this attemp succeeds, all settings will be copy to pAd->StaActive.
-// A connection attempt (user set OID, roaming, CCX fast roaming,..) consists of
-// several steps (JOIN, AUTH, ASSOC or REASSOC) and may fail at any step. We purposely
-// separate this under-trial settings away from pAd->StaActive so that once
-// this new attempt failed, driver can auto-recover back to the active settings.
-typedef struct _MLME_AUX {
-    UCHAR               BssType;
-    UCHAR               Ssid[MAX_LEN_OF_SSID];
-    UCHAR               SsidLen;
-    UCHAR               Bssid[MAC_ADDR_LEN];
-       UCHAR                           AutoReconnectSsid[MAX_LEN_OF_SSID];
-       UCHAR                           AutoReconnectSsidLen;
-    USHORT              Alg;
-    UCHAR               ScanType;
-    UCHAR               Channel;
-       UCHAR               CentralChannel;
-    USHORT              Aid;
-    USHORT              CapabilityInfo;
-    USHORT              BeaconPeriod;
-    USHORT              CfpMaxDuration;
-    USHORT              CfpPeriod;
-    USHORT              AtimWin;
-
-       // Copy supported rate from desired AP's beacon. We are trying to match
-       // AP's supported and extended rate settings.
-       UCHAR                   SupRate[MAX_LEN_OF_SUPPORTED_RATES];
-       UCHAR                   ExtRate[MAX_LEN_OF_SUPPORTED_RATES];
-       UCHAR                   SupRateLen;
-       UCHAR                   ExtRateLen;
-       HT_CAPABILITY_IE                HtCapability;
-       UCHAR                           HtCapabilityLen;
-       ADD_HT_INFO_IE          AddHtInfo;      // AP might use this additional ht info IE
-       UCHAR                   NewExtChannelOffset;
-       //RT_HT_CAPABILITY      SupportedHtPhy;
-
-    // new for QOS
-    QOS_CAPABILITY_PARM APQosCapability;    // QOS capability of the current associated AP
-    EDCA_PARM           APEdcaParm;         // EDCA parameters of the current associated AP
-    QBSS_LOAD_PARM      APQbssLoad;         // QBSS load of the current associated AP
-
-    // new to keep Ralink specific feature
-    ULONG               APRalinkIe;
-
-    BSS_TABLE           SsidBssTab;     // AP list for the same SSID
-    BSS_TABLE           RoamTab;        // AP list eligible for roaming
-    ULONG               BssIdx;
-    ULONG               RoamIdx;
-
-       BOOLEAN                         CurrReqIsFromNdis;
-
-    RALINK_TIMER_STRUCT BeaconTimer, ScanTimer;
-    RALINK_TIMER_STRUCT AuthTimer;
-    RALINK_TIMER_STRUCT AssocTimer, ReassocTimer, DisassocTimer;
-} MLME_AUX, *PMLME_AUX;
-
-typedef struct _MLME_ADDBA_REQ_STRUCT{
-       UCHAR   Wcid;   //
-       UCHAR   pAddr[MAC_ADDR_LEN];
-       UCHAR   BaBufSize;
-       USHORT  TimeOutValue;
-       UCHAR   TID;
-       UCHAR   Token;
-       USHORT  BaStartSeq;
-} MLME_ADDBA_REQ_STRUCT, *PMLME_ADDBA_REQ_STRUCT;
-
-
-typedef struct _MLME_DELBA_REQ_STRUCT{
-       UCHAR   Wcid;   //
-       UCHAR     Addr[MAC_ADDR_LEN];
-       UCHAR   TID;
-       UCHAR   Initiator;
-} MLME_DELBA_REQ_STRUCT, *PMLME_DELBA_REQ_STRUCT;
-
-// assoc struct is equal to reassoc
-typedef struct _MLME_ASSOC_REQ_STRUCT{
-    UCHAR     Addr[MAC_ADDR_LEN];
-    USHORT    CapabilityInfo;
-    USHORT    ListenIntv;
-    ULONG     Timeout;
-} MLME_ASSOC_REQ_STRUCT, *PMLME_ASSOC_REQ_STRUCT, MLME_REASSOC_REQ_STRUCT, *PMLME_REASSOC_REQ_STRUCT;
-
-typedef struct _MLME_DISASSOC_REQ_STRUCT{
-    UCHAR     Addr[MAC_ADDR_LEN];
-    USHORT    Reason;
-} MLME_DISASSOC_REQ_STRUCT, *PMLME_DISASSOC_REQ_STRUCT;
-
-typedef struct _MLME_AUTH_REQ_STRUCT {
-    UCHAR        Addr[MAC_ADDR_LEN];
-    USHORT       Alg;
-    ULONG        Timeout;
-} MLME_AUTH_REQ_STRUCT, *PMLME_AUTH_REQ_STRUCT;
-
-typedef struct _MLME_DEAUTH_REQ_STRUCT {
-    UCHAR        Addr[MAC_ADDR_LEN];
-    USHORT       Reason;
-} MLME_DEAUTH_REQ_STRUCT, *PMLME_DEAUTH_REQ_STRUCT;
-
-typedef struct {
-    ULONG      BssIdx;
-} MLME_JOIN_REQ_STRUCT;
-
-typedef struct _MLME_SCAN_REQ_STRUCT {
-    UCHAR      Bssid[MAC_ADDR_LEN];
-    UCHAR      BssType;
-    UCHAR      ScanType;
-    UCHAR      SsidLen;
-    CHAR       Ssid[MAX_LEN_OF_SSID];
-} MLME_SCAN_REQ_STRUCT, *PMLME_SCAN_REQ_STRUCT;
-
-typedef struct _MLME_START_REQ_STRUCT {
-    CHAR        Ssid[MAX_LEN_OF_SSID];
-    UCHAR       SsidLen;
-} MLME_START_REQ_STRUCT, *PMLME_START_REQ_STRUCT;
-
-typedef struct PACKED {
-    UCHAR   Eid;
-    UCHAR   Len;
-    CHAR   Octet[1];
-} EID_STRUCT,*PEID_STRUCT, BEACON_EID_STRUCT, *PBEACON_EID_STRUCT;
-
-typedef struct PACKED _RTMP_TX_RATE_SWITCH
-{
-       UCHAR   ItemNo;
-       UCHAR   STBC:1;
-       UCHAR   ShortGI:1;
-       UCHAR   BW:1;
-       UCHAR   Rsv1:1;
-       UCHAR   Mode:2;
-       UCHAR   Rsv2:2;
-       UCHAR   CurrMCS;
-       UCHAR   TrainUp;
-       UCHAR   TrainDown;
-} RRTMP_TX_RATE_SWITCH, *PRTMP_TX_RATE_SWITCH;
-
-// ========================== AP mlme.h ===============================
-#define TBTT_PRELOAD_TIME       384        // usec. LomgPreamble + 24-byte at 1Mbps
-#define DEFAULT_DTIM_PERIOD     1
-
-#define MAC_TABLE_AGEOUT_TIME                  300                     // unit: sec
-#define MAC_TABLE_ASSOC_TIMEOUT                        5                       // unit: sec
-#define MAC_TABLE_FULL(Tab)                            ((Tab).size == MAX_LEN_OF_MAC_TABLE)
-
-// AP shall drop the sta if contine Tx fail count reach it.
-#define MAC_ENTRY_LIFE_CHECK_CNT               20                      // packet cnt.
-
-// Value domain of pMacEntry->Sst
-typedef enum _Sst {
-    SST_NOT_AUTH,   // 0: equivalent to IEEE 802.11/1999 state 1
-    SST_AUTH,       // 1: equivalent to IEEE 802.11/1999 state 2
-    SST_ASSOC       // 2: equivalent to IEEE 802.11/1999 state 3
-} SST;
-
-// value domain of pMacEntry->AuthState
-typedef enum _AuthState {
-    AS_NOT_AUTH,
-    AS_AUTH_OPEN,       // STA has been authenticated using OPEN SYSTEM
-    AS_AUTH_KEY,        // STA has been authenticated using SHARED KEY
-    AS_AUTHENTICATING   // STA is waiting for AUTH seq#3 using SHARED KEY
-} AUTH_STATE;
-
-//for-wpa value domain of pMacEntry->WpaState  802.1i D3   p.114
-typedef enum _ApWpaState {
-    AS_NOTUSE,              // 0
-    AS_DISCONNECT,          // 1
-    AS_DISCONNECTED,        // 2
-    AS_INITIALIZE,          // 3
-    AS_AUTHENTICATION,      // 4
-    AS_AUTHENTICATION2,     // 5
-    AS_INITPMK,             // 6
-    AS_INITPSK,             // 7
-    AS_PTKSTART,            // 8
-    AS_PTKINIT_NEGOTIATING, // 9
-    AS_PTKINITDONE,         // 10
-    AS_UPDATEKEYS,          // 11
-    AS_INTEGRITY_FAILURE,   // 12
-    AS_KEYUPDATE,           // 13
-} AP_WPA_STATE;
-
-// for-wpa value domain of pMacEntry->WpaState  802.1i D3   p.114
-typedef enum _GTKState {
-    REKEY_NEGOTIATING,
-    REKEY_ESTABLISHED,
-    KEYERROR,
-} GTK_STATE;
-
-//  for-wpa  value domain of pMacEntry->WpaState  802.1i D3   p.114
-typedef enum _WpaGTKState {
-    SETKEYS,
-    SETKEYS_DONE,
-} WPA_GTK_STATE;
-// ====================== end of AP mlme.h ============================
-
-
-#endif // MLME_H__
+#include "../rt2870/mlme.h"
index 329b91bcba472d67c93d948da8c7bd85fdbc2264..cbf16a8ae61506ee826c2e9acbc68ec3b56f8841 100644 (file)
@@ -1,940 +1 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify  *
- * it under the terms of the GNU General Public License as published by  *
- * the Free Software Foundation; either version 2 of the License, or     *
- * (at your option) any later version.                                   *
- *                                                                       *
- * 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.                          *
- *                                                                       *
- * You should have received a copy of the GNU General Public License     *
- * along with this program; if not, write to the                         *
- * Free Software Foundation, Inc.,                                       *
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- *                                                                       *
- *************************************************************************
-
-       Module Name:
-       oid.h
-
-       Abstract:
-
-       Revision History:
-       Who                     When                    What
-       --------        ----------              ----------------------------------------------
-       Name            Date                    Modification logs
-*/
-#ifndef _OID_H_
-#define _OID_H_
-
-#define TRUE                           1
-#define FALSE                          0
-//
-// IEEE 802.11 Structures and definitions
-//
-#define MAX_TX_POWER_LEVEL              100   /* mW */
-#define MAX_RSSI_TRIGGER                -10    /* dBm */
-#define MIN_RSSI_TRIGGER                -200   /* dBm */
-#define MAX_FRAG_THRESHOLD              2346  /* byte count */
-#define MIN_FRAG_THRESHOLD              256   /* byte count */
-#define MAX_RTS_THRESHOLD               2347  /* byte count */
-
-// new types for Media Specific Indications
-// Extension channel offset
-#define EXTCHA_NONE                    0
-#define EXTCHA_ABOVE           0x1
-#define EXTCHA_BELOW           0x3
-
-// BW
-#define BAND_WIDTH_20          0
-#define BAND_WIDTH_40          1
-#define BAND_WIDTH_BOTH                2
-#define BAND_WIDTH_10          3       // 802.11j has 10MHz. This definition is for internal usage. doesn't fill in the IE or other field.
-// SHORTGI
-#define GAP_INTERVAL_400       1       // only support in HT mode
-#define GAP_INTERVAL_800       0
-#define GAP_INTERVAL_BOTH      2
-
-#define NdisMediaStateConnected                        1
-#define NdisMediaStateDisconnected             0
-
-#define NDIS_802_11_LENGTH_SSID         32
-#define NDIS_802_11_LENGTH_RATES        8
-#define NDIS_802_11_LENGTH_RATES_EX     16
-#define MAC_ADDR_LENGTH                 6
-#define MAX_NUM_OF_CHS                                 49 // 14 channels @2.4G +  12@UNII + 4 @MMAC + 11 @HiperLAN2 + 7 @Japan + 1 as NULL terminationc
-#define MAX_NUMBER_OF_EVENT                            10  // entry # in EVENT table
-#define MAX_NUMBER_OF_MAC                              32 // if MAX_MBSSID_NUM is 8, this value can't be larger than 211
-#define MAX_NUMBER_OF_ACL                              64
-#define MAX_LENGTH_OF_SUPPORT_RATES            12    // 1, 2, 5.5, 11, 6, 9, 12, 18, 24, 36, 48, 54
-#define MAX_NUMBER_OF_DLS_ENTRY                        4
-
-#define OID_GEN_MACHINE_NAME               0x0001021A
-
-#define RT_QUERY_SIGNAL_CONTEXT                                0x0402
-#define RT_SET_IAPP_PID                        0x0404
-#define RT_SET_APD_PID                                         0x0405
-#define RT_SET_DEL_MAC_ENTRY                           0x0406
-
-//
-// IEEE 802.11 OIDs
-//
-#define        OID_GET_SET_TOGGLE                      0x8000
-
-#define        OID_802_11_NETWORK_TYPES_SUPPORTED                      0x0103
-#define        OID_802_11_NETWORK_TYPE_IN_USE                          0x0104
-#define        OID_802_11_RSSI_TRIGGER                                         0x0107
-#define        RT_OID_802_11_RSSI                                                      0x0108 //rt2860 only , kathy
-#define        RT_OID_802_11_RSSI_1                                            0x0109 //rt2860 only , kathy
-#define        RT_OID_802_11_RSSI_2                                            0x010A //rt2860 only , kathy
-#define        OID_802_11_NUMBER_OF_ANTENNAS                           0x010B
-#define        OID_802_11_RX_ANTENNA_SELECTED                          0x010C
-#define        OID_802_11_TX_ANTENNA_SELECTED                          0x010D
-#define        OID_802_11_SUPPORTED_RATES                                      0x010E
-#define        OID_802_11_ADD_WEP                                                      0x0112
-#define        OID_802_11_REMOVE_WEP                                           0x0113
-#define        OID_802_11_DISASSOCIATE                                         0x0114
-#define        OID_802_11_PRIVACY_FILTER                                       0x0118
-#define        OID_802_11_ASSOCIATION_INFORMATION                      0x011E
-#define        OID_802_11_TEST                                                         0x011F
-#define        RT_OID_802_11_COUNTRY_REGION                            0x0507
-#define        OID_802_11_BSSID_LIST_SCAN                                      0x0508
-#define        OID_802_11_SSID                                                         0x0509
-#define        OID_802_11_BSSID                                                        0x050A
-#define        RT_OID_802_11_RADIO                                                     0x050B
-#define        RT_OID_802_11_PHY_MODE                                          0x050C
-#define        RT_OID_802_11_STA_CONFIG                                        0x050D
-#define        OID_802_11_DESIRED_RATES                                        0x050E
-#define        RT_OID_802_11_PREAMBLE                                          0x050F
-#define        OID_802_11_WEP_STATUS                                           0x0510
-#define        OID_802_11_AUTHENTICATION_MODE                          0x0511
-#define        OID_802_11_INFRASTRUCTURE_MODE                          0x0512
-#define        RT_OID_802_11_RESET_COUNTERS                            0x0513
-#define        OID_802_11_RTS_THRESHOLD                                        0x0514
-#define        OID_802_11_FRAGMENTATION_THRESHOLD                      0x0515
-#define        OID_802_11_POWER_MODE                                           0x0516
-#define        OID_802_11_TX_POWER_LEVEL                                       0x0517
-#define        RT_OID_802_11_ADD_WPA                                           0x0518
-#define        OID_802_11_REMOVE_KEY                                           0x0519
-#define        OID_802_11_ADD_KEY                                                      0x0520
-#define        OID_802_11_CONFIGURATION                                        0x0521
-#define        OID_802_11_TX_PACKET_BURST                                      0x0522
-#define        RT_OID_802_11_QUERY_NOISE_LEVEL                         0x0523
-#define        RT_OID_802_11_EXTRA_INFO                                        0x0524
-#ifdef DBG
-#define        RT_OID_802_11_HARDWARE_REGISTER                         0x0525
-#endif
-#define OID_802_11_ENCRYPTION_STATUS            OID_802_11_WEP_STATUS
-#define OID_802_11_DEAUTHENTICATION                 0x0526
-#define OID_802_11_DROP_UNENCRYPTED                 0x0527
-#define OID_802_11_MIC_FAILURE_REPORT_FRAME         0x0528
-
-// For 802.1x daemin using to require current driver configuration
-#define OID_802_11_RADIUS_QUERY_SETTING                                0x0540
-
-#define        RT_OID_DEVICE_NAME                                                      0x0607
-#define        RT_OID_VERSION_INFO                                                     0x0608
-#define        OID_802_11_BSSID_LIST                                           0x0609
-#define        OID_802_3_CURRENT_ADDRESS                                       0x060A
-#define        OID_GEN_MEDIA_CONNECT_STATUS                            0x060B
-#define        RT_OID_802_11_QUERY_LINK_STATUS                         0x060C
-#define        OID_802_11_RSSI                                                         0x060D
-#define        OID_802_11_STATISTICS                                           0x060E
-#define        OID_GEN_RCV_OK                                                          0x060F
-#define        OID_GEN_RCV_NO_BUFFER                                           0x0610
-#define        RT_OID_802_11_QUERY_EEPROM_VERSION                      0x0611
-#define        RT_OID_802_11_QUERY_FIRMWARE_VERSION            0x0612
-#define        RT_OID_802_11_QUERY_LAST_RX_RATE                        0x0613
-#define        RT_OID_802_11_TX_POWER_LEVEL_1                          0x0614
-#define        RT_OID_802_11_QUERY_PIDVID                                      0x0615
-
-#define OID_SET_COUNTERMEASURES                     0x0616
-#define OID_802_11_SET_IEEE8021X                    0x0617
-#define OID_802_11_SET_IEEE8021X_REQUIRE_KEY        0x0618
-#define OID_802_11_PMKID                            0x0620
-#define RT_OID_WPA_SUPPLICANT_SUPPORT               0x0621
-#define RT_OID_WE_VERSION_COMPILED                  0x0622
-#define RT_OID_NEW_DRIVER                           0x0623
-
-
-//rt2860 , kathy
-#define        RT_OID_802_11_SNR_0                                                     0x0630
-#define        RT_OID_802_11_SNR_1                                                     0x0631
-#define        RT_OID_802_11_QUERY_LAST_TX_RATE                        0x0632
-#define        RT_OID_802_11_QUERY_HT_PHYMODE                          0x0633
-#define        RT_OID_802_11_SET_HT_PHYMODE                            0x0634
-#define        OID_802_11_RELOAD_DEFAULTS                                      0x0635
-#define        RT_OID_802_11_QUERY_APSD_SETTING                        0x0636
-#define        RT_OID_802_11_SET_APSD_SETTING                          0x0637
-#define        RT_OID_802_11_QUERY_APSD_PSM                            0x0638
-#define        RT_OID_802_11_SET_APSD_PSM                                      0x0639
-#define        RT_OID_802_11_QUERY_DLS                                         0x063A
-#define        RT_OID_802_11_SET_DLS                                           0x063B
-#define        RT_OID_802_11_QUERY_DLS_PARAM                           0x063C
-#define        RT_OID_802_11_SET_DLS_PARAM                                     0x063D
-#define RT_OID_802_11_QUERY_WMM                        0x063E
-#define RT_OID_802_11_SET_WMM                                          0x063F
-#define RT_OID_802_11_QUERY_IMME_BA_CAP                                0x0640
-#define RT_OID_802_11_SET_IMME_BA_CAP                          0x0641
-#define RT_OID_802_11_QUERY_BATABLE                                    0x0642
-#define RT_OID_802_11_ADD_IMME_BA                                      0x0643
-#define RT_OID_802_11_TEAR_IMME_BA                                     0x0644
-#define RT_OID_DRIVER_DEVICE_NAME                   0x0645
-#define RT_OID_802_11_QUERY_DAT_HT_PHYMODE          0x0646
-#define RT_OID_QUERY_MULTIPLE_CARD_SUPPORT          0x0647
-
-// Ralink defined OIDs
-// Dennis Lee move to platform specific
-
-#define        RT_OID_802_11_BSSID                                       (OID_GET_SET_TOGGLE | OID_802_11_BSSID)
-#define        RT_OID_802_11_SSID                                        (OID_GET_SET_TOGGLE | OID_802_11_SSID)
-#define        RT_OID_802_11_INFRASTRUCTURE_MODE         (OID_GET_SET_TOGGLE | OID_802_11_INFRASTRUCTURE_MODE)
-#define        RT_OID_802_11_ADD_WEP                             (OID_GET_SET_TOGGLE | OID_802_11_ADD_WEP)
-#define        RT_OID_802_11_ADD_KEY                             (OID_GET_SET_TOGGLE | OID_802_11_ADD_KEY)
-#define        RT_OID_802_11_REMOVE_WEP                          (OID_GET_SET_TOGGLE | OID_802_11_REMOVE_WEP)
-#define        RT_OID_802_11_REMOVE_KEY                          (OID_GET_SET_TOGGLE | OID_802_11_REMOVE_KEY)
-#define        RT_OID_802_11_DISASSOCIATE                        (OID_GET_SET_TOGGLE | OID_802_11_DISASSOCIATE)
-#define        RT_OID_802_11_AUTHENTICATION_MODE         (OID_GET_SET_TOGGLE | OID_802_11_AUTHENTICATION_MODE)
-#define        RT_OID_802_11_PRIVACY_FILTER              (OID_GET_SET_TOGGLE | OID_802_11_PRIVACY_FILTER)
-#define        RT_OID_802_11_BSSID_LIST_SCAN             (OID_GET_SET_TOGGLE | OID_802_11_BSSID_LIST_SCAN)
-#define        RT_OID_802_11_WEP_STATUS                          (OID_GET_SET_TOGGLE | OID_802_11_WEP_STATUS)
-#define        RT_OID_802_11_RELOAD_DEFAULTS             (OID_GET_SET_TOGGLE | OID_802_11_RELOAD_DEFAULTS)
-#define        RT_OID_802_11_NETWORK_TYPE_IN_USE         (OID_GET_SET_TOGGLE | OID_802_11_NETWORK_TYPE_IN_USE)
-#define        RT_OID_802_11_TX_POWER_LEVEL              (OID_GET_SET_TOGGLE | OID_802_11_TX_POWER_LEVEL)
-#define        RT_OID_802_11_RSSI_TRIGGER                        (OID_GET_SET_TOGGLE | OID_802_11_RSSI_TRIGGER)
-#define        RT_OID_802_11_FRAGMENTATION_THRESHOLD (OID_GET_SET_TOGGLE |     OID_802_11_FRAGMENTATION_THRESHOLD)
-#define        RT_OID_802_11_RTS_THRESHOLD                       (OID_GET_SET_TOGGLE | OID_802_11_RTS_THRESHOLD)
-#define        RT_OID_802_11_RX_ANTENNA_SELECTED         (OID_GET_SET_TOGGLE | OID_802_11_RX_ANTENNA_SELECTED)
-#define        RT_OID_802_11_TX_ANTENNA_SELECTED         (OID_GET_SET_TOGGLE | OID_802_11_TX_ANTENNA_SELECTED)
-#define        RT_OID_802_11_SUPPORTED_RATES             (OID_GET_SET_TOGGLE | OID_802_11_SUPPORTED_RATES)
-#define        RT_OID_802_11_DESIRED_RATES                       (OID_GET_SET_TOGGLE | OID_802_11_DESIRED_RATES)
-#define        RT_OID_802_11_CONFIGURATION                       (OID_GET_SET_TOGGLE | OID_802_11_CONFIGURATION)
-#define        RT_OID_802_11_POWER_MODE                          (OID_GET_SET_TOGGLE | OID_802_11_POWER_MODE)
-
-
-
-typedef enum _NDIS_802_11_STATUS_TYPE
-{
-    Ndis802_11StatusType_Authentication,
-    Ndis802_11StatusType_MediaStreamMode,
-    Ndis802_11StatusType_PMKID_CandidateList,
-    Ndis802_11StatusTypeMax    // not a real type, defined as an upper bound
-} NDIS_802_11_STATUS_TYPE, *PNDIS_802_11_STATUS_TYPE;
-
-typedef UCHAR   NDIS_802_11_MAC_ADDRESS[6];
-
-typedef struct _NDIS_802_11_STATUS_INDICATION
-{
-    NDIS_802_11_STATUS_TYPE StatusType;
-} NDIS_802_11_STATUS_INDICATION, *PNDIS_802_11_STATUS_INDICATION;
-
-// mask for authentication/integrity fields
-#define NDIS_802_11_AUTH_REQUEST_AUTH_FIELDS        0x0f
-
-#define NDIS_802_11_AUTH_REQUEST_REAUTH             0x01
-#define NDIS_802_11_AUTH_REQUEST_KEYUPDATE          0x02
-#define NDIS_802_11_AUTH_REQUEST_PAIRWISE_ERROR     0x06
-#define NDIS_802_11_AUTH_REQUEST_GROUP_ERROR        0x0E
-
-typedef struct _NDIS_802_11_AUTHENTICATION_REQUEST
-{
-    ULONG Length;            // Length of structure
-    NDIS_802_11_MAC_ADDRESS Bssid;
-    ULONG Flags;
-} NDIS_802_11_AUTHENTICATION_REQUEST, *PNDIS_802_11_AUTHENTICATION_REQUEST;
-
-//Added new types for PMKID Candidate lists.
-typedef struct _PMKID_CANDIDATE {
-    NDIS_802_11_MAC_ADDRESS BSSID;
-    ULONG Flags;
-} PMKID_CANDIDATE, *PPMKID_CANDIDATE;
-
-typedef struct _NDIS_802_11_PMKID_CANDIDATE_LIST
-{
-    ULONG Version;       // Version of the structure
-    ULONG NumCandidates; // No. of pmkid candidates
-    PMKID_CANDIDATE CandidateList[1];
-} NDIS_802_11_PMKID_CANDIDATE_LIST, *PNDIS_802_11_PMKID_CANDIDATE_LIST;
-
-//Flags for PMKID Candidate list structure
-#define NDIS_802_11_PMKID_CANDIDATE_PREAUTH_ENABLED    0x01
-
-// Added new types for OFDM 5G and 2.4G
-typedef enum _NDIS_802_11_NETWORK_TYPE
-{
-   Ndis802_11FH,
-   Ndis802_11DS,
-    Ndis802_11OFDM5,
-    Ndis802_11OFDM5_N,
-    Ndis802_11OFDM24,
-    Ndis802_11OFDM24_N,
-   Ndis802_11Automode,
-    Ndis802_11NetworkTypeMax    // not a real type, defined as an upper bound
-} NDIS_802_11_NETWORK_TYPE, *PNDIS_802_11_NETWORK_TYPE;
-
-typedef struct _NDIS_802_11_NETWORK_TYPE_LIST
-{
-    UINT                       NumberOfItems;  // in list below, at least 1
-   NDIS_802_11_NETWORK_TYPE    NetworkType [1];
-} NDIS_802_11_NETWORK_TYPE_LIST, *PNDIS_802_11_NETWORK_TYPE_LIST;
-
-typedef enum _NDIS_802_11_POWER_MODE
-{
-    Ndis802_11PowerModeCAM,
-    Ndis802_11PowerModeMAX_PSP,
-    Ndis802_11PowerModeFast_PSP,
-    Ndis802_11PowerModeLegacy_PSP,
-    Ndis802_11PowerModeMax      // not a real mode, defined as an upper bound
-} NDIS_802_11_POWER_MODE, *PNDIS_802_11_POWER_MODE;
-
-typedef ULONG   NDIS_802_11_TX_POWER_LEVEL; // in milliwatts
-
-//
-// Received Signal Strength Indication
-//
-typedef LONG    NDIS_802_11_RSSI;           // in dBm
-
-typedef struct _NDIS_802_11_CONFIGURATION_FH
-{
-   ULONG           Length;            // Length of structure
-   ULONG           HopPattern;        // As defined by 802.11, MSB set
-   ULONG           HopSet;            // to one if non-802.11
-   ULONG           DwellTime;         // units are Kusec
-} NDIS_802_11_CONFIGURATION_FH, *PNDIS_802_11_CONFIGURATION_FH;
-
-typedef struct _NDIS_802_11_CONFIGURATION
-{
-   ULONG                           Length;             // Length of structure
-   ULONG                           BeaconPeriod;       // units are Kusec
-   ULONG                           ATIMWindow;         // units are Kusec
-   ULONG                           DSConfig;           // Frequency, units are kHz
-   NDIS_802_11_CONFIGURATION_FH    FHConfig;
-} NDIS_802_11_CONFIGURATION, *PNDIS_802_11_CONFIGURATION;
-
-typedef struct _NDIS_802_11_STATISTICS
-{
-   ULONG           Length;             // Length of structure
-   LARGE_INTEGER   TransmittedFragmentCount;
-   LARGE_INTEGER   MulticastTransmittedFrameCount;
-   LARGE_INTEGER   FailedCount;
-   LARGE_INTEGER   RetryCount;
-   LARGE_INTEGER   MultipleRetryCount;
-   LARGE_INTEGER   RTSSuccessCount;
-   LARGE_INTEGER   RTSFailureCount;
-   LARGE_INTEGER   ACKFailureCount;
-   LARGE_INTEGER   FrameDuplicateCount;
-   LARGE_INTEGER   ReceivedFragmentCount;
-   LARGE_INTEGER   MulticastReceivedFrameCount;
-   LARGE_INTEGER   FCSErrorCount;
-   LARGE_INTEGER   TKIPLocalMICFailures;
-   LARGE_INTEGER   TKIPRemoteMICErrors;
-   LARGE_INTEGER   TKIPICVErrors;
-   LARGE_INTEGER   TKIPCounterMeasuresInvoked;
-   LARGE_INTEGER   TKIPReplays;
-   LARGE_INTEGER   CCMPFormatErrors;
-   LARGE_INTEGER   CCMPReplays;
-   LARGE_INTEGER   CCMPDecryptErrors;
-   LARGE_INTEGER   FourWayHandshakeFailures;
-} NDIS_802_11_STATISTICS, *PNDIS_802_11_STATISTICS;
-
-typedef  ULONG  NDIS_802_11_KEY_INDEX;
-typedef ULONGLONG   NDIS_802_11_KEY_RSC;
-
-#define MAX_RADIUS_SRV_NUM                     2         // 802.1x failover number
-
-typedef struct PACKED _RADIUS_SRV_INFO {
-       UINT32                  radius_ip;
-       UINT32                  radius_port;
-       UCHAR                   radius_key[64];
-       UCHAR                   radius_key_len;
-} RADIUS_SRV_INFO, *PRADIUS_SRV_INFO;
-
-typedef struct PACKED _RADIUS_KEY_INFO
-{
-       UCHAR                   radius_srv_num;
-       RADIUS_SRV_INFO radius_srv_info[MAX_RADIUS_SRV_NUM];
-       UCHAR                   ieee8021xWEP;            // dynamic WEP
-    UCHAR           key_index;
-    UCHAR           key_length;          // length of key in bytes
-    UCHAR           key_material[13];
-} RADIUS_KEY_INFO, *PRADIUS_KEY_INFO;
-
-// It's used by 802.1x daemon to require relative configuration
-typedef struct PACKED _RADIUS_CONF
-{
-    UINT32          Length;             // Length of this structure
-    UCHAR                      mbss_num;                       // indicate multiple BSS number
-       UINT32                  own_ip_addr;
-       UINT32                  retry_interval;
-       UINT32                  session_timeout_interval;
-       UCHAR                   EAPifname[IFNAMSIZ];
-       UCHAR                   EAPifname_len;
-       UCHAR                   PreAuthifname[IFNAMSIZ];
-       UCHAR                   PreAuthifname_len;
-       RADIUS_KEY_INFO RadiusInfo[8/*MAX_MBSSID_NUM*/];
-} RADIUS_CONF, *PRADIUS_CONF;
-
-// Key mapping keys require a BSSID
-typedef struct _NDIS_802_11_KEY
-{
-    UINT           Length;             // Length of this structure
-    UINT           KeyIndex;
-    UINT           KeyLength;          // length of key in bytes
-    NDIS_802_11_MAC_ADDRESS BSSID;
-    NDIS_802_11_KEY_RSC KeyRSC;
-    UCHAR           KeyMaterial[1];     // variable length depending on above field
-} NDIS_802_11_KEY, *PNDIS_802_11_KEY;
-
-typedef struct _NDIS_802_11_REMOVE_KEY
-{
-    UINT           Length;             // Length of this structure
-    UINT           KeyIndex;
-    NDIS_802_11_MAC_ADDRESS BSSID;
-} NDIS_802_11_REMOVE_KEY, *PNDIS_802_11_REMOVE_KEY;
-
-typedef struct _NDIS_802_11_WEP
-{
-   UINT     Length;        // Length of this structure
-   UINT     KeyIndex;           // 0 is the per-client key, 1-N are the
-                                        // global keys
-   UINT     KeyLength;     // length of key in bytes
-   UCHAR     KeyMaterial[1];// variable length depending on above field
-} NDIS_802_11_WEP, *PNDIS_802_11_WEP;
-
-
-typedef enum _NDIS_802_11_NETWORK_INFRASTRUCTURE
-{
-   Ndis802_11IBSS,
-   Ndis802_11Infrastructure,
-   Ndis802_11AutoUnknown,
-   Ndis802_11Monitor,
-   Ndis802_11InfrastructureMax     // Not a real value, defined as upper bound
-} NDIS_802_11_NETWORK_INFRASTRUCTURE, *PNDIS_802_11_NETWORK_INFRASTRUCTURE;
-
-// Add new authentication modes
-typedef enum _NDIS_802_11_AUTHENTICATION_MODE
-{
-   Ndis802_11AuthModeOpen,
-   Ndis802_11AuthModeShared,
-   Ndis802_11AuthModeAutoSwitch,
-    Ndis802_11AuthModeWPA,
-    Ndis802_11AuthModeWPAPSK,
-    Ndis802_11AuthModeWPANone,
-   Ndis802_11AuthModeWPA2,
-   Ndis802_11AuthModeWPA2PSK,
-       Ndis802_11AuthModeWPA1WPA2,
-       Ndis802_11AuthModeWPA1PSKWPA2PSK,
-   Ndis802_11AuthModeMax           // Not a real mode, defined as upper bound
-} NDIS_802_11_AUTHENTICATION_MODE, *PNDIS_802_11_AUTHENTICATION_MODE;
-
-typedef UCHAR   NDIS_802_11_RATES[NDIS_802_11_LENGTH_RATES];        // Set of 8 data rates
-typedef UCHAR   NDIS_802_11_RATES_EX[NDIS_802_11_LENGTH_RATES_EX];  // Set of 16 data rates
-
-typedef struct PACKED _NDIS_802_11_SSID
-{
-    UINT   SsidLength;         // length of SSID field below, in bytes;
-                                // this can be zero.
-    UCHAR   Ssid[NDIS_802_11_LENGTH_SSID];           // SSID information field
-} NDIS_802_11_SSID, *PNDIS_802_11_SSID;
-
-
-typedef struct PACKED _NDIS_WLAN_BSSID
-{
-   ULONG                               Length;     // Length of this structure
-   NDIS_802_11_MAC_ADDRESS             MacAddress; // BSSID
-   UCHAR                               Reserved[2];
-   NDIS_802_11_SSID                    Ssid;       // SSID
-   ULONG                               Privacy;    // WEP encryption requirement
-   NDIS_802_11_RSSI                    Rssi;       // receive signal strength in dBm
-   NDIS_802_11_NETWORK_TYPE            NetworkTypeInUse;
-   NDIS_802_11_CONFIGURATION           Configuration;
-   NDIS_802_11_NETWORK_INFRASTRUCTURE  InfrastructureMode;
-   NDIS_802_11_RATES                   SupportedRates;
-} NDIS_WLAN_BSSID, *PNDIS_WLAN_BSSID;
-
-typedef struct PACKED _NDIS_802_11_BSSID_LIST
-{
-   UINT           NumberOfItems;      // in list below, at least 1
-   NDIS_WLAN_BSSID Bssid[1];
-} NDIS_802_11_BSSID_LIST, *PNDIS_802_11_BSSID_LIST;
-
-// Added Capabilities, IELength and IEs for each BSSID
-typedef struct PACKED _NDIS_WLAN_BSSID_EX
-{
-    ULONG                               Length;             // Length of this structure
-    NDIS_802_11_MAC_ADDRESS             MacAddress;         // BSSID
-    UCHAR                               Reserved[2];
-    NDIS_802_11_SSID                    Ssid;               // SSID
-    UINT                                Privacy;            // WEP encryption requirement
-    NDIS_802_11_RSSI                    Rssi;               // receive signal
-                                                            // strength in dBm
-    NDIS_802_11_NETWORK_TYPE            NetworkTypeInUse;
-    NDIS_802_11_CONFIGURATION           Configuration;
-    NDIS_802_11_NETWORK_INFRASTRUCTURE  InfrastructureMode;
-    NDIS_802_11_RATES_EX                SupportedRates;
-    ULONG                               IELength;
-    UCHAR                               IEs[1];
-} NDIS_WLAN_BSSID_EX, *PNDIS_WLAN_BSSID_EX;
-
-typedef struct PACKED _NDIS_802_11_BSSID_LIST_EX
-{
-    UINT                   NumberOfItems;      // in list below, at least 1
-    NDIS_WLAN_BSSID_EX      Bssid[1];
-} NDIS_802_11_BSSID_LIST_EX, *PNDIS_802_11_BSSID_LIST_EX;
-
-typedef struct PACKED _NDIS_802_11_FIXED_IEs
-{
-    UCHAR Timestamp[8];
-    USHORT BeaconInterval;
-    USHORT Capabilities;
-} NDIS_802_11_FIXED_IEs, *PNDIS_802_11_FIXED_IEs;
-
-typedef struct _NDIS_802_11_VARIABLE_IEs
-{
-    UCHAR ElementID;
-    UCHAR Length;    // Number of bytes in data field
-    UCHAR data[1];
-} NDIS_802_11_VARIABLE_IEs, *PNDIS_802_11_VARIABLE_IEs;
-
-typedef  ULONG   NDIS_802_11_FRAGMENTATION_THRESHOLD;
-
-typedef  ULONG   NDIS_802_11_RTS_THRESHOLD;
-
-typedef  ULONG   NDIS_802_11_ANTENNA;
-
-typedef enum _NDIS_802_11_PRIVACY_FILTER
-{
-   Ndis802_11PrivFilterAcceptAll,
-   Ndis802_11PrivFilter8021xWEP
-} NDIS_802_11_PRIVACY_FILTER, *PNDIS_802_11_PRIVACY_FILTER;
-
-// Added new encryption types
-// Also aliased typedef to new name
-typedef enum _NDIS_802_11_WEP_STATUS
-{
-   Ndis802_11WEPEnabled,
-    Ndis802_11Encryption1Enabled = Ndis802_11WEPEnabled,
-   Ndis802_11WEPDisabled,
-    Ndis802_11EncryptionDisabled = Ndis802_11WEPDisabled,
-   Ndis802_11WEPKeyAbsent,
-    Ndis802_11Encryption1KeyAbsent = Ndis802_11WEPKeyAbsent,
-   Ndis802_11WEPNotSupported,
-    Ndis802_11EncryptionNotSupported = Ndis802_11WEPNotSupported,
-    Ndis802_11Encryption2Enabled,
-    Ndis802_11Encryption2KeyAbsent,
-    Ndis802_11Encryption3Enabled,
-    Ndis802_11Encryption3KeyAbsent,
-    Ndis802_11Encryption4Enabled,      // TKIP or AES mix
-    Ndis802_11Encryption4KeyAbsent,
-} NDIS_802_11_WEP_STATUS, *PNDIS_802_11_WEP_STATUS,
-  NDIS_802_11_ENCRYPTION_STATUS, *PNDIS_802_11_ENCRYPTION_STATUS;
-
-typedef enum _NDIS_802_11_RELOAD_DEFAULTS
-{
-   Ndis802_11ReloadWEPKeys
-} NDIS_802_11_RELOAD_DEFAULTS, *PNDIS_802_11_RELOAD_DEFAULTS;
-
-#define NDIS_802_11_AI_REQFI_CAPABILITIES      1
-#define NDIS_802_11_AI_REQFI_LISTENINTERVAL    2
-#define NDIS_802_11_AI_REQFI_CURRENTAPADDRESS  4
-
-#define NDIS_802_11_AI_RESFI_CAPABILITIES      1
-#define NDIS_802_11_AI_RESFI_STATUSCODE        2
-#define NDIS_802_11_AI_RESFI_ASSOCIATIONID     4
-
-typedef struct _NDIS_802_11_AI_REQFI
-{
-    USHORT Capabilities;
-    USHORT ListenInterval;
-    NDIS_802_11_MAC_ADDRESS  CurrentAPAddress;
-} NDIS_802_11_AI_REQFI, *PNDIS_802_11_AI_REQFI;
-
-typedef struct _NDIS_802_11_AI_RESFI
-{
-    USHORT Capabilities;
-    USHORT StatusCode;
-    USHORT AssociationId;
-} NDIS_802_11_AI_RESFI, *PNDIS_802_11_AI_RESFI;
-
-typedef struct _NDIS_802_11_ASSOCIATION_INFORMATION
-{
-    ULONG                   Length;
-    USHORT                  AvailableRequestFixedIEs;
-    NDIS_802_11_AI_REQFI    RequestFixedIEs;
-    ULONG                   RequestIELength;
-    ULONG                   OffsetRequestIEs;
-    USHORT                  AvailableResponseFixedIEs;
-    NDIS_802_11_AI_RESFI    ResponseFixedIEs;
-    ULONG                   ResponseIELength;
-    ULONG                   OffsetResponseIEs;
-} NDIS_802_11_ASSOCIATION_INFORMATION, *PNDIS_802_11_ASSOCIATION_INFORMATION;
-
-typedef struct _NDIS_802_11_AUTHENTICATION_EVENT
-{
-    NDIS_802_11_STATUS_INDICATION       Status;
-    NDIS_802_11_AUTHENTICATION_REQUEST  Request[1];
-} NDIS_802_11_AUTHENTICATION_EVENT, *PNDIS_802_11_AUTHENTICATION_EVENT;
-
-// 802.11 Media stream constraints, associated with OID_802_11_MEDIA_STREAM_MODE
-typedef enum _NDIS_802_11_MEDIA_STREAM_MODE
-{
-    Ndis802_11MediaStreamOff,
-    Ndis802_11MediaStreamOn,
-} NDIS_802_11_MEDIA_STREAM_MODE, *PNDIS_802_11_MEDIA_STREAM_MODE;
-
-// PMKID Structures
-typedef UCHAR   NDIS_802_11_PMKID_VALUE[16];
-
-typedef struct _BSSID_INFO
-{
-    NDIS_802_11_MAC_ADDRESS BSSID;
-    NDIS_802_11_PMKID_VALUE PMKID;
-} BSSID_INFO, *PBSSID_INFO;
-
-typedef struct _NDIS_802_11_PMKID
-{
-    UINT    Length;
-    UINT    BSSIDInfoCount;
-    BSSID_INFO BSSIDInfo[1];
-} NDIS_802_11_PMKID, *PNDIS_802_11_PMKID;
-
-typedef struct _NDIS_802_11_AUTHENTICATION_ENCRYPTION
-{
-    NDIS_802_11_AUTHENTICATION_MODE AuthModeSupported;
-    NDIS_802_11_ENCRYPTION_STATUS EncryptStatusSupported;
-} NDIS_802_11_AUTHENTICATION_ENCRYPTION, *PNDIS_802_11_AUTHENTICATION_ENCRYPTION;
-
-typedef struct _NDIS_802_11_CAPABILITY
-{
-     ULONG Length;
-     ULONG Version;
-     ULONG NoOfPMKIDs;
-     ULONG NoOfAuthEncryptPairsSupported;
-     NDIS_802_11_AUTHENTICATION_ENCRYPTION AuthenticationEncryptionSupported[1];
-} NDIS_802_11_CAPABILITY, *PNDIS_802_11_CAPABILITY;
-
-#if WIRELESS_EXT <= 11
-#ifndef SIOCDEVPRIVATE
-#define SIOCDEVPRIVATE                              0x8BE0
-#endif
-#define SIOCIWFIRSTPRIV                                                                SIOCDEVPRIVATE
-#endif
-
-#define RT_PRIV_IOCTL_EXT                                                      (SIOCIWFIRSTPRIV + 0x01) // Sync. with AP for wsc upnp daemon
-#define RTPRIV_IOCTL_SET                                                       (SIOCIWFIRSTPRIV + 0x02)
-
-#ifdef DBG
-#define RTPRIV_IOCTL_BBP                            (SIOCIWFIRSTPRIV + 0x03)
-#define RTPRIV_IOCTL_MAC                            (SIOCIWFIRSTPRIV + 0x05)
-#define RTPRIV_IOCTL_RF                             (SIOCIWFIRSTPRIV + 0x13)
-#define RTPRIV_IOCTL_E2P                            (SIOCIWFIRSTPRIV + 0x07)
-#endif
-
-#define RTPRIV_IOCTL_STATISTICS                     (SIOCIWFIRSTPRIV + 0x09)
-#define RTPRIV_IOCTL_ADD_PMKID_CACHE                (SIOCIWFIRSTPRIV + 0x0A)
-#define RTPRIV_IOCTL_RADIUS_DATA                    (SIOCIWFIRSTPRIV + 0x0C)
-#define RTPRIV_IOCTL_GSITESURVEY                                       (SIOCIWFIRSTPRIV + 0x0D)
-#define RT_PRIV_IOCTL                                                          (SIOCIWFIRSTPRIV + 0x0E) // Sync. with RT61 (for wpa_supplicant)
-#define RTPRIV_IOCTL_GET_MAC_TABLE                                     (SIOCIWFIRSTPRIV + 0x0F)
-
-#define RTPRIV_IOCTL_SHOW                                                      (SIOCIWFIRSTPRIV + 0x11)
-enum {
-    SHOW_CONN_STATUS = 4,
-    SHOW_DRVIER_VERION = 5,
-    SHOW_BA_INFO = 6,
-       SHOW_DESC_INFO = 7,
-#ifdef RT2870
-       SHOW_RXBULK_INFO = 8,
-       SHOW_TXBULK_INFO = 9,
-#endif // RT2870 //
-    RAIO_OFF = 10,
-    RAIO_ON = 11,
-       SHOW_CFG_VALUE = 20,
-};
-
-#define OID_802_11_BUILD_CHANNEL_EX                            0x0714
-#define OID_802_11_GET_CH_LIST                                 0x0715
-#define OID_802_11_GET_COUNTRY_CODE                            0x0716
-#define OID_802_11_GET_CHANNEL_GEOGRAPHY               0x0717
-
-#define RT_OID_WSC_SET_PASSPHRASE                   0x0740 // passphrase for wpa(2)-psk
-#define RT_OID_WSC_DRIVER_AUTO_CONNECT              0x0741
-#define RT_OID_WSC_QUERY_DEFAULT_PROFILE            0x0742
-#define RT_OID_WSC_SET_CONN_BY_PROFILE_INDEX        0x0743
-#define RT_OID_WSC_SET_ACTION                       0x0744
-#define RT_OID_WSC_SET_SSID                         0x0745
-#define RT_OID_WSC_SET_PIN_CODE                     0x0746
-#define RT_OID_WSC_SET_MODE                         0x0747 // PIN or PBC
-#define RT_OID_WSC_SET_CONF_MODE                    0x0748 // Enrollee or Registrar
-#define RT_OID_WSC_SET_PROFILE                      0x0749
-
-#define RT_OID_802_11_WSC_QUERY_PROFILE                                0x0750
-// for consistency with RT61
-#define RT_OID_WSC_QUERY_STATUS                                                0x0751
-#define RT_OID_WSC_PIN_CODE                                                    0x0752
-#define RT_OID_WSC_UUID                                                                0x0753
-#define RT_OID_WSC_SET_SELECTED_REGISTRAR                      0x0754
-#define RT_OID_WSC_EAPMSG                                                      0x0755
-#define RT_OID_WSC_MANUFACTURER                                                0x0756
-#define RT_OID_WSC_MODEL_NAME                                          0x0757
-#define RT_OID_WSC_MODEL_NO                                                    0x0758
-#define RT_OID_WSC_SERIAL_NO                                           0x0759
-#define RT_OID_WSC_MAC_ADDRESS                                         0x0760
-
-#ifdef LLTD_SUPPORT
-// for consistency with RT61
-#define RT_OID_GET_PHY_MODE                         0x761
-#endif // LLTD_SUPPORT //
-
-// New for MeetingHouse Api support
-#define OID_MH_802_1X_SUPPORTED               0xFFEDC100
-
-// MIMO Tx parameter, ShortGI, MCS, STBC, etc.  these are fields in TXWI. Don't change this definition!!!
-typedef union  _HTTRANSMIT_SETTING {
-       struct  {
-       USHORT          MCS:7;                 // MCS
-       USHORT          BW:1;   //channel bandwidth 20MHz or 40 MHz
-       USHORT          ShortGI:1;
-       USHORT          STBC:2; //SPACE
-       USHORT          rsv:2;
-       USHORT          TxBF:1;
-       USHORT          MODE:2; // Use definition MODE_xxx.
-       }       field;
-       USHORT          word;
- } HTTRANSMIT_SETTING, *PHTTRANSMIT_SETTING;
-
-typedef enum _RT_802_11_PREAMBLE {
-    Rt802_11PreambleLong,
-    Rt802_11PreambleShort,
-    Rt802_11PreambleAuto
-} RT_802_11_PREAMBLE, *PRT_802_11_PREAMBLE;
-
-// Only for STA, need to sync with AP
-typedef enum _RT_802_11_PHY_MODE {
-       PHY_11BG_MIXED = 0,
-       PHY_11B,
-       PHY_11A,
-       PHY_11ABG_MIXED,
-       PHY_11G,
-       PHY_11ABGN_MIXED,       // both band   5
-       PHY_11N_2_4G,           // 11n-only with 2.4G band      6
-       PHY_11GN_MIXED, // 2.4G band      7
-       PHY_11AN_MIXED, // 5G  band       8
-       PHY_11BGN_MIXED,        // if check 802.11b.      9
-       PHY_11AGN_MIXED,        // if check 802.11b.      10
-       PHY_11N_5G,                     // 11n-only with 5G band                11
-} RT_802_11_PHY_MODE;
-
-// put all proprietery for-query objects here to reduce # of Query_OID
-typedef struct _RT_802_11_LINK_STATUS {
-    ULONG   CurrTxRate;         // in units of 0.5Mbps
-    ULONG   ChannelQuality;     // 0..100 %
-    ULONG   TxByteCount;        // both ok and fail
-    ULONG   RxByteCount;        // both ok and fail
-    ULONG      CentralChannel;         // 40MHz central channel number
-} RT_802_11_LINK_STATUS, *PRT_802_11_LINK_STATUS;
-
-typedef struct _RT_802_11_EVENT_LOG {
-    LARGE_INTEGER   SystemTime;  // timestammp via NdisGetCurrentSystemTime()
-    UCHAR           Addr[MAC_ADDR_LENGTH];
-    USHORT          Event;       // EVENT_xxx
-} RT_802_11_EVENT_LOG, *PRT_802_11_EVENT_LOG;
-
-typedef struct _RT_802_11_EVENT_TABLE {
-    ULONG       Num;
-    ULONG       Rsv;     // to align Log[] at LARGE_INEGER boundary
-    RT_802_11_EVENT_LOG   Log[MAX_NUMBER_OF_EVENT];
-} RT_802_11_EVENT_TABLE, PRT_802_11_EVENT_TABLE;
-
-// MIMO Tx parameter, ShortGI, MCS, STBC, etc.  these are fields in TXWI. Don't change this definition!!!
-typedef union  _MACHTTRANSMIT_SETTING {
-       struct  {
-       USHORT          MCS:7;                 // MCS
-       USHORT          BW:1;   //channel bandwidth 20MHz or 40 MHz
-       USHORT          ShortGI:1;
-       USHORT          STBC:2; //SPACE
-       USHORT          rsv:3;
-       USHORT          MODE:2; // Use definition MODE_xxx.
-       }       field;
-       USHORT          word;
- } MACHTTRANSMIT_SETTING, *PMACHTTRANSMIT_SETTING;
-
-typedef struct _RT_802_11_MAC_ENTRY {
-    UCHAR       Addr[MAC_ADDR_LENGTH];
-    UCHAR       Aid;
-    UCHAR       Psm;     // 0:PWR_ACTIVE, 1:PWR_SAVE
-    UCHAR              MimoPs;  // 0:MMPS_STATIC, 1:MMPS_DYNAMIC, 3:MMPS_Enabled
-    CHAR               AvgRssi0;
-       CHAR            AvgRssi1;
-       CHAR            AvgRssi2;
-       UINT32          ConnectedTime;
-    MACHTTRANSMIT_SETTING      TxRate;
-} RT_802_11_MAC_ENTRY, *PRT_802_11_MAC_ENTRY;
-
-typedef struct _RT_802_11_MAC_TABLE {
-    ULONG       Num;
-    RT_802_11_MAC_ENTRY Entry[MAX_NUMBER_OF_MAC];
-} RT_802_11_MAC_TABLE, *PRT_802_11_MAC_TABLE;
-
-// structure for query/set hardware register - MAC, BBP, RF register
-typedef struct _RT_802_11_HARDWARE_REGISTER {
-    ULONG   HardwareType;       // 0:MAC, 1:BBP, 2:RF register, 3:EEPROM
-    ULONG   Offset;             // Q/S register offset addr
-    ULONG   Data;               // R/W data buffer
-} RT_802_11_HARDWARE_REGISTER, *PRT_802_11_HARDWARE_REGISTER;
-
-typedef struct _RT_802_11_AP_CONFIG {
-    ULONG   EnableTxBurst;      // 0-disable, 1-enable
-    ULONG   EnableTurboRate;    // 0-disable, 1-enable 72/100mbps turbo rate
-    ULONG   IsolateInterStaTraffic;     // 0-disable, 1-enable isolation
-    ULONG   HideSsid;           // 0-disable, 1-enable hiding
-    ULONG   UseBGProtection;    // 0-AUTO, 1-always ON, 2-always OFF
-    ULONG   UseShortSlotTime;   // 0-no use, 1-use 9-us short slot time
-    ULONG   Rsv1;               // must be 0
-    ULONG   SystemErrorBitmap;  // ignore upon SET, return system error upon QUERY
-} RT_802_11_AP_CONFIG, *PRT_802_11_AP_CONFIG;
-
-// structure to query/set STA_CONFIG
-typedef struct _RT_802_11_STA_CONFIG {
-    ULONG   EnableTxBurst;      // 0-disable, 1-enable
-    ULONG   EnableTurboRate;    // 0-disable, 1-enable 72/100mbps turbo rate
-    ULONG   UseBGProtection;    // 0-AUTO, 1-always ON, 2-always OFF
-    ULONG   UseShortSlotTime;   // 0-no use, 1-use 9-us short slot time when applicable
-    ULONG   AdhocMode;                         // 0-11b rates only (WIFI spec), 1 - b/g mixed, 2 - g only
-    ULONG   HwRadioStatus;      // 0-OFF, 1-ON, default is 1, Read-Only
-    ULONG   Rsv1;               // must be 0
-    ULONG   SystemErrorBitmap;  // ignore upon SET, return system error upon QUERY
-} RT_802_11_STA_CONFIG, *PRT_802_11_STA_CONFIG;
-
-//
-//  For OID Query or Set about BA structure
-//
-typedef        struct  _OID_BACAP_STRUC        {
-               UCHAR           RxBAWinLimit;
-               UCHAR           TxBAWinLimit;
-               UCHAR           Policy; // 0: DELAY_BA 1:IMMED_BA  (//BA Policy subfiled value in ADDBA frame)   2:BA-not use. other value invalid
-               UCHAR           MpduDensity;    // 0: DELAY_BA 1:IMMED_BA  (//BA Policy subfiled value in ADDBA frame)   2:BA-not use. other value invalid
-               UCHAR           AmsduEnable;    //Enable AMSDU transmisstion
-               UCHAR           AmsduSize;      // 0:3839, 1:7935 bytes. UINT  MSDUSizeToBytes[]        = { 3839, 7935};
-               UCHAR           MMPSmode;       // MIMO power save more, 0:static, 1:dynamic, 2:rsv, 3:mimo enable
-               BOOLEAN         AutoBA; // Auto BA will automatically
-} OID_BACAP_STRUC, *POID_BACAP_STRUC;
-
-typedef struct _RT_802_11_ACL_ENTRY {
-    UCHAR   Addr[MAC_ADDR_LENGTH];
-    USHORT  Rsv;
-} RT_802_11_ACL_ENTRY, *PRT_802_11_ACL_ENTRY;
-
-typedef struct PACKED _RT_802_11_ACL {
-    ULONG   Policy;             // 0-disable, 1-positive list, 2-negative list
-    ULONG   Num;
-    RT_802_11_ACL_ENTRY Entry[MAX_NUMBER_OF_ACL];
-} RT_802_11_ACL, *PRT_802_11_ACL;
-
-typedef struct _RT_802_11_WDS {
-    ULONG                                              Num;
-    NDIS_802_11_MAC_ADDRESS            Entry[24/*MAX_NUM_OF_WDS_LINK*/];
-       ULONG                                           KeyLength;
-       UCHAR                                           KeyMaterial[32];
-} RT_802_11_WDS, *PRT_802_11_WDS;
-
-typedef struct _RT_802_11_TX_RATES_ {
-    UCHAR       SupRateLen;
-    UCHAR       SupRate[MAX_LENGTH_OF_SUPPORT_RATES];
-    UCHAR       ExtRateLen;
-    UCHAR       ExtRate[MAX_LENGTH_OF_SUPPORT_RATES];
-} RT_802_11_TX_RATES, *PRT_802_11_TX_RATES;
-
-
-// Definition of extra information code
-#define        GENERAL_LINK_UP                 0x0                     // Link is Up
-#define        GENERAL_LINK_DOWN               0x1                     // Link is Down
-#define        HW_RADIO_OFF                    0x2                     // Hardware radio off
-#define        SW_RADIO_OFF                    0x3                     // Software radio off
-#define        AUTH_FAIL                               0x4                     // Open authentication fail
-#define        AUTH_FAIL_KEYS                  0x5                     // Shared authentication fail
-#define        ASSOC_FAIL                              0x6                     // Association failed
-#define        EAP_MIC_FAILURE                 0x7                     // Deauthencation because MIC failure
-#define        EAP_4WAY_TIMEOUT                0x8                     // Deauthencation on 4-way handshake timeout
-#define        EAP_GROUP_KEY_TIMEOUT   0x9                     // Deauthencation on group key handshake timeout
-#define        EAP_SUCCESS                             0xa                     // EAP succeed
-#define        DETECT_RADAR_SIGNAL             0xb         // Radar signal occur in current channel
-#define EXTRA_INFO_MAX                 0xb                     // Indicate Last OID
-
-#define EXTRA_INFO_CLEAR               0xffffffff
-
-// This is OID setting structure. So only GF or MM as Mode. This is valid when our wirelss mode has 802.11n in use.
-typedef struct {
-       RT_802_11_PHY_MODE              PhyMode;        //
-       UCHAR           TransmitNo;
-       UCHAR           HtMode;         //HTMODE_GF or HTMODE_MM
-       UCHAR           ExtOffset;      //extension channel above or below
-       UCHAR           MCS;
-       UCHAR           BW;
-       UCHAR           STBC;
-       UCHAR           SHORTGI;
-       UCHAR           rsv;
-} OID_SET_HT_PHYMODE, *POID_SET_HT_PHYMODE;
-
-#ifdef LLTD_SUPPORT
-typedef struct _RT_LLTD_ASSOICATION_ENTRY {
-    UCHAR           Addr[ETH_LENGTH_OF_ADDRESS];
-    unsigned short  MOR;        // maximum operational rate
-    UCHAR           phyMode;
-} RT_LLTD_ASSOICATION_ENTRY, *PRT_LLTD_ASSOICATION_ENTRY;
-
-typedef struct _RT_LLTD_ASSOICATION_TABLE {
-    unsigned int                Num;
-    RT_LLTD_ASSOICATION_ENTRY   Entry[MAX_NUMBER_OF_MAC];
-} RT_LLTD_ASSOICATION_TABLE, *PRT_LLTD_ASSOICATION_TABLE;
-#endif // LLTD_SUPPORT //
-
-#define MAX_CUSTOM_LEN 128
-
-typedef enum _RT_802_11_D_CLIENT_MODE
-{
-   Rt802_11_D_None,
-   Rt802_11_D_Flexible,
-   Rt802_11_D_Strict,
-} RT_802_11_D_CLIENT_MODE, *PRT_802_11_D_CLIENT_MODE;
-
-typedef struct _RT_CHANNEL_LIST_INFO
-{
-       UCHAR ChannelList[MAX_NUM_OF_CHS];   // list all supported channels for site survey
-       UCHAR ChannelListNum; // number of channel in ChannelList[]
-} RT_CHANNEL_LIST_INFO, *PRT_CHANNEL_LIST_INFO;
-
-// WSC configured credential
-typedef        struct  _WSC_CREDENTIAL
-{
-       NDIS_802_11_SSID        SSID;                           // mandatory
-       USHORT                          AuthType;                       // mandatory, 1: open, 2: wpa-psk, 4: shared, 8:wpa, 0x10: wpa2, 0x20: wpa2-psk
-       USHORT                          EncrType;                       // mandatory, 1: none, 2: wep, 4: tkip, 8: aes
-       UCHAR                           Key[64];                        // mandatory, Maximum 64 byte
-       USHORT                          KeyLength;
-       UCHAR                           MacAddr[6];                     // mandatory, AP MAC address
-       UCHAR                           KeyIndex;                       // optional, default is 1
-       UCHAR                           Rsvd[3];                        // Make alignment
-}      WSC_CREDENTIAL, *PWSC_CREDENTIAL;
-
-// WSC configured profiles
-typedef        struct  _WSC_PROFILE
-{
-       UINT                    ProfileCnt;
-       WSC_CREDENTIAL  Profile[8];                             // Support up to 8 profiles
-}      WSC_PROFILE, *PWSC_PROFILE;
-
-
-
-#endif // _OID_H_
-
+#include "../rt2870/oid.h"
index 5b3053d0520d9a9e3521eff3ea31ae406fc3f836..16d8717b9dbddfdcfdc5daa8ba6bf10e223d1b9b 100644 (file)
@@ -1,681 +1 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify  *
- * it under the terms of the GNU General Public License as published by  *
- * the Free Software Foundation; either version 2 of the License, or     *
- * (at your option) any later version.                                   *
- *                                                                       *
- * 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.                          *
- *                                                                       *
- * You should have received a copy of the GNU General Public License     *
- * along with this program; if not, write to the                         *
- * Free Software Foundation, Inc.,                                       *
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- *                                                                       *
- *************************************************************************
- */
-
-#ifndef __RT2870_H__
-#define __RT2870_H__
-
-//usb header files
-#include <linux/usb.h>
-
-/* rtmp_def.h */
-//
-#define BULKAGGRE_ZISE          100
-#define RT28XX_DRVDATA_SET(_a)                                             usb_set_intfdata(_a, pAd);
-#define RT28XX_PUT_DEVICE                                                  usb_put_dev
-#define RTUSB_ALLOC_URB(iso)                                               usb_alloc_urb(iso, GFP_ATOMIC)
-#define RTUSB_SUBMIT_URB(pUrb)                                             usb_submit_urb(pUrb, GFP_ATOMIC)
-#define        RTUSB_URB_ALLOC_BUFFER(pUsb_Dev, BufSize, pDma_addr)               usb_buffer_alloc(pUsb_Dev, BufSize, GFP_ATOMIC, pDma_addr)
-#define        RTUSB_URB_FREE_BUFFER(pUsb_Dev, BufSize, pTransferBuf, Dma_addr)   usb_buffer_free(pUsb_Dev, BufSize, pTransferBuf, Dma_addr)
-
-#define RXBULKAGGRE_ZISE        12
-#define MAX_TXBULK_LIMIT        (LOCAL_TXBUF_SIZE*(BULKAGGRE_ZISE-1))
-#define MAX_TXBULK_SIZE         (LOCAL_TXBUF_SIZE*BULKAGGRE_ZISE)
-#define MAX_RXBULK_SIZE         (LOCAL_TXBUF_SIZE*RXBULKAGGRE_ZISE)
-#define MAX_MLME_HANDLER_MEMORY 20
-#define BUFFER_SIZE                            2400    //2048
-#define        TX_RING                                 0xa
-#define        PRIO_RING                               0xc
-
-
-// Flags for Bulkflags control for bulk out data
-//
-#define        fRTUSB_BULK_OUT_DATA_NULL                               0x00000001
-#define fRTUSB_BULK_OUT_RTS                                            0x00000002
-#define        fRTUSB_BULK_OUT_MLME                                    0x00000004
-
-#define        fRTUSB_BULK_OUT_DATA_NORMAL                             0x00010000
-#define        fRTUSB_BULK_OUT_DATA_NORMAL_2                   0x00020000
-#define        fRTUSB_BULK_OUT_DATA_NORMAL_3                   0x00040000
-#define        fRTUSB_BULK_OUT_DATA_NORMAL_4                   0x00080000
-#define        fRTUSB_BULK_OUT_DATA_NORMAL_5                   0x00100000
-
-#define        fRTUSB_BULK_OUT_PSPOLL                                  0x00000020
-#define        fRTUSB_BULK_OUT_DATA_FRAG                               0x00000040
-#define        fRTUSB_BULK_OUT_DATA_FRAG_2                             0x00000080
-#define        fRTUSB_BULK_OUT_DATA_FRAG_3                             0x00000100
-#define        fRTUSB_BULK_OUT_DATA_FRAG_4                             0x00000200
-
-#define RT2870_USB_DEVICES     \
-{      \
-       {USB_DEVICE(0x148F,0x2770)}, /* Ralink */               \
-       {USB_DEVICE(0x148F,0x2870)}, /* Ralink */               \
-       {USB_DEVICE(0x148F,0x3070)}, /* Ralink 3070 */  \
-       {USB_DEVICE(0x148F,0x3071)}, /* Ralink 3071 */  \
-       {USB_DEVICE(0x148F,0x3072)}, /* Ralink 3072 */  \
-       {USB_DEVICE(0x0B05,0x1731)}, /* Asus */                 \
-       {USB_DEVICE(0x0B05,0x1732)}, /* Asus */                 \
-       {USB_DEVICE(0x0B05,0x1742)}, /* Asus */                 \
-       {USB_DEVICE(0x0DF6,0x0017)}, /* Sitecom */              \
-       {USB_DEVICE(0x0DF6,0x002B)}, /* Sitecom */              \
-       {USB_DEVICE(0x0DF6,0x002C)}, /* Sitecom */              \
-       {USB_DEVICE(0x0DF6,0x003E)}, /* Sitecom 3070 */ \
-       {USB_DEVICE(0x0DF6,0x002D)}, /* Sitecom */              \
-       {USB_DEVICE(0x0DF6,0x0039)}, /* Sitecom 2770 */ \
-       {USB_DEVICE(0x14B2,0x3C06)}, /* Conceptronic */ \
-       {USB_DEVICE(0x14B2,0x3C28)}, /* Conceptronic */ \
-       {USB_DEVICE(0x2019,0xED06)}, /* Planex Communications, Inc. */          \
-       {USB_DEVICE(0x2019,0xAB25)}, /* Planex Communications, Inc. RT3070 */           \
-       {USB_DEVICE(0x07D1,0x3C09)}, /* D-Link */               \
-       {USB_DEVICE(0x07D1,0x3C11)}, /* D-Link */               \
-       {USB_DEVICE(0x2001,0x3C09)}, /* D-Link */               \
-       {USB_DEVICE(0x2001,0x3C0A)}, /* D-Link 3072*/   \
-       {USB_DEVICE(0x14B2,0x3C07)}, /* AL */                   \
-       {USB_DEVICE(0x14B2,0x3C12)}, /* AL 3070 */              \
-       {USB_DEVICE(0x050D,0x8053)}, /* Belkin */               \
-       {USB_DEVICE(0x14B2,0x3C23)}, /* Airlink */              \
-       {USB_DEVICE(0x14B2,0x3C27)}, /* Airlink */              \
-       {USB_DEVICE(0x07AA,0x002F)}, /* Corega */               \
-       {USB_DEVICE(0x07AA,0x003C)}, /* Corega */               \
-       {USB_DEVICE(0x07AA,0x003F)}, /* Corega */               \
-       {USB_DEVICE(0x18C5,0x0012)}, /* Corega 3070 */  \
-       {USB_DEVICE(0x1044,0x800B)}, /* Gigabyte */             \
-       {USB_DEVICE(0x1044,0x800D)}, /* Gigabyte GN-WB32L 3070 */               \
-       {USB_DEVICE(0x15A9,0x0006)}, /* Sparklan */             \
-       {USB_DEVICE(0x083A,0xB522)}, /* SMC */                  \
-       {USB_DEVICE(0x083A,0xA618)}, /* SMC */                  \
-       {USB_DEVICE(0x083A,0x8522)}, /* Arcadyan */             \
-       {USB_DEVICE(0x083A,0x7512)}, /* Arcadyan 2770 */                \
-       {USB_DEVICE(0x083A,0x7522)}, /* Arcadyan */             \
-       {USB_DEVICE(0x083A,0x7511)}, /* Arcadyan 3070 */ \
-       {USB_DEVICE(0x0CDE,0x0022)}, /* ZCOM */                 \
-       {USB_DEVICE(0x0586,0x3416)}, /* Zyxel */                \
-       {USB_DEVICE(0x0CDE,0x0025)}, /* Zyxel */                \
-       {USB_DEVICE(0x1740,0x9701)}, /* EnGenius */             \
-       {USB_DEVICE(0x1740,0x9702)}, /* EnGenius */             \
-       {USB_DEVICE(0x1740,0x9703)}, /* EnGenius 3070 */                \
-       {USB_DEVICE(0x0471,0x200f)}, /* Philips */              \
-       {USB_DEVICE(0x14B2,0x3C25)}, /* Draytek */              \
-       {USB_DEVICE(0x13D3,0x3247)}, /* AzureWave */    \
-       {USB_DEVICE(0x13D3,0x3273)}, /* AzureWave 3070*/        \
-       {USB_DEVICE(0x083A,0x6618)}, /* Accton */               \
-       {USB_DEVICE(0x15c5,0x0008)}, /* Amit */                 \
-       {USB_DEVICE(0x0E66,0x0001)}, /* Hawking */              \
-       {USB_DEVICE(0x0E66,0x0003)}, /* Hawking */              \
-       {USB_DEVICE(0x129B,0x1828)}, /* Siemens */              \
-       {USB_DEVICE(0x157E,0x300E)}, /* U-Media */              \
-       {USB_DEVICE(0x050d,0x805c)},                                    \
-       {USB_DEVICE(0x1482,0x3C09)}, /* Abocom*/                \
-       {USB_DEVICE(0x14B2,0x3C09)}, /* Alpha */                \
-       {USB_DEVICE(0x04E8,0x2018)}, /* samsung */      \
-       {USB_DEVICE(0x07B8,0x3070)}, /* AboCom 3070 */  \
-       {USB_DEVICE(0x07B8,0x3071)}, /* AboCom 3071 */  \
-       {USB_DEVICE(0x07B8,0x3072)}, /* Abocom 3072 */  \
-       {USB_DEVICE(0x7392,0x7711)}, /* Edimax 3070 */  \
-       {USB_DEVICE(0x5A57,0x0280)}, /* Zinwell */              \
-       {USB_DEVICE(0x5A57,0x0282)}, /* Zinwell */              \
-       {USB_DEVICE(0x1A32,0x0304)}, /* Quanta 3070 */          \
-       {USB_DEVICE(0x0789,0x0162)}, /* Logitec 2870 */         \
-       {USB_DEVICE(0x0789,0x0163)}, /* Logitec 2870 */         \
-       {USB_DEVICE(0x0789,0x0164)}, /* Logitec 2870 */         \
-       {USB_DEVICE(0x1EDA,0x2310)}, /* AirTies 3070 */         \
-       { }/* Terminating entry */                      \
-}
-
-#define        FREE_HTTX_RING(_p, _b, _t)                      \
-{                                                                              \
-       if ((_t)->ENextBulkOutPosition == (_t)->CurWritePosition)                               \
-       {                                                                                                                                       \
-               (_t)->bRingEmpty = TRUE;                        \
-       }                                                                                                                                       \
-       /*NdisInterlockedDecrement(&(_p)->TxCount); */\
-}
-
-//
-// RXINFO appends at the end of each rx packet.
-//
-typedef        struct  PACKED _RXINFO_STRUC {
-       UINT32          BA:1;
-       UINT32          DATA:1;
-       UINT32          NULLDATA:1;
-       UINT32          FRAG:1;
-       UINT32          U2M:1;              // 1: this RX frame is unicast to me
-       UINT32          Mcast:1;            // 1: this is a multicast frame
-       UINT32          Bcast:1;            // 1: this is a broadcast frame
-       UINT32          MyBss:1;        // 1: this frame belongs to the same BSSID
-       UINT32          Crc:1;              // 1: CRC error
-       UINT32          CipherErr:2;        // 0: decryption okay, 1:ICV error, 2:MIC error, 3:KEY not valid
-       UINT32          AMSDU:1;                // rx with 802.3 header, not 802.11 header.
-       UINT32          HTC:1;
-       UINT32          RSSI:1;
-       UINT32          L2PAD:1;
-       UINT32          AMPDU:1;                // To be moved
-       UINT32          Decrypted:1;
-       UINT32          PlcpRssil:1;
-       UINT32          CipherAlg:1;
-       UINT32          LastAMSDU:1;
-       UINT32          PlcpSignal:12;
-}      RXINFO_STRUC, *PRXINFO_STRUC, RT28XX_RXD_STRUC, *PRT28XX_RXD_STRUC;
-
-//
-// TXINFO
-//
-typedef        struct  _TXINFO_STRUC {
-       // Word 0
-       UINT32          USBDMATxPktLen:16;      //used ONLY in USB bulk Aggregation,  Total byte counts of all sub-frame.
-       UINT32          rsv:8;
-       UINT32          WIV:1;  // Wireless Info Valid. 1 if Driver already fill WI,  o if DMA needs to copy WI to correctposition
-       UINT32          QSEL:2; // select on-chip FIFO ID for 2nd-stage output scheduler.0:MGMT, 1:HCCA 2:EDCA
-       UINT32          SwUseLastRound:1; // Software use.
-       UINT32          rsv2:2;  // Software use.
-       UINT32          USBDMANextVLD:1;        //used ONLY in USB bulk Aggregation, NextValid
-       UINT32          USBDMATxburst:1;//used ONLY in USB bulk Aggre. Force USB DMA transmit frame from current selected endpoint
-}      TXINFO_STRUC, *PTXINFO_STRUC;
-
-#define TXINFO_SIZE                            4
-#define RXINFO_SIZE                            4
-#define TXPADDING_SIZE                 11
-
-//
-// Management ring buffer format
-//
-typedef        struct  _MGMT_STRUC     {
-       BOOLEAN         Valid;
-       PUCHAR          pBuffer;
-       ULONG           Length;
-}      MGMT_STRUC, *PMGMT_STRUC;
-
-
-/* ----------------- EEPROM Related MACRO ----------------- */
-#ifdef RT30xx
-#define RT28xx_EEPROM_READ16(pAd, offset, var)                                 \
-       do {                                                                                                            \
-               RTUSBReadEEPROM(pAd, offset, (PUCHAR)&(var), 2);                \
-               if(!pAd->bUseEfuse)                                                                             \
-                       var = le2cpu16(var);                                                            \
-       }while(0)
-
-#define RT28xx_EEPROM_WRITE16(pAd, offset, var)                                        \
-       do{                                                                                                                     \
-               USHORT _tmpVar=var;                                                                             \
-               if(!pAd->bUseEfuse)                                                                     \
-               _tmpVar = cpu2le16(var);                                                                \
-               RTUSBWriteEEPROM(pAd, offset, (PUCHAR)&(_tmpVar), 2);   \
-       }while(0)
-#endif // RT30xx //
-#ifndef RT30xx
-#define RT28xx_EEPROM_READ16(pAd, offset, var)                                 \
-       do {                                                                                                            \
-               RTUSBReadEEPROM(pAd, offset, (PUCHAR)&(var), 2);                \
-                       var = le2cpu16(var);                                                            \
-       }while(0)
-
-#define RT28xx_EEPROM_WRITE16(pAd, offset, var)                                        \
-       do{                                                                                                                     \
-               USHORT _tmpVar=var;                                                                             \
-               _tmpVar = cpu2le16(var);                                                                \
-               RTUSBWriteEEPROM(pAd, offset, (PUCHAR)&(_tmpVar), 2);   \
-       }while(0)
-#endif // RT30xx //
-
-/* ----------------- TASK/THREAD Related MACRO ----------------- */
-#define RT28XX_TASK_THREAD_INIT(pAd, Status)           \
-       Status = CreateThreads(net_dev);
-
-
-/* ----------------- Frimware Related MACRO ----------------- */
-#define RT28XX_WRITE_FIRMWARE(_pAd, _pFwImage, _FwLen)         \
-       RTUSBFirmwareWrite(_pAd, _pFwImage, _FwLen)
-
-/* ----------------- TX Related MACRO ----------------- */
-#define RT28XX_START_DEQUEUE(pAd, QueIdx, irqFlags)                            \
-                       {                                                                                                       \
-                               RTMP_IRQ_LOCK(&pAd->DeQueueLock[QueIdx], irqFlags);             \
-                               if (pAd->DeQueueRunning[QueIdx])                                                \
-                               {                                                                                                               \
-                                       RTMP_IRQ_UNLOCK(&pAd->DeQueueLock[QueIdx], irqFlags);\
-                                       printk("DeQueueRunning[%d]= TRUE!\n", QueIdx);          \
-                                       continue;                                                                                       \
-                               }                                                                                                               \
-                               else                                                                                                    \
-                               {                                                                                                               \
-                                       pAd->DeQueueRunning[QueIdx] = TRUE;                                     \
-                                       RTMP_IRQ_UNLOCK(&pAd->DeQueueLock[QueIdx], irqFlags);\
-                               }                                                                                                               \
-                       }
-#define RT28XX_STOP_DEQUEUE(pAd, QueIdx, irqFlags)                                             \
-                       do{                                                                                                                     \
-                               RTMP_IRQ_LOCK(&pAd->DeQueueLock[QueIdx], irqFlags);             \
-                               pAd->DeQueueRunning[QueIdx] = FALSE;                                    \
-                               RTMP_IRQ_UNLOCK(&pAd->DeQueueLock[QueIdx], irqFlags);   \
-                       }while(0)
-
-
-#define        RT28XX_HAS_ENOUGH_FREE_DESC(pAd, pTxBlk, freeNum, pPacket) \
-               (RTUSBFreeDescriptorRequest(pAd, pTxBlk->QueIdx, (pTxBlk->TotalFrameLen + GET_OS_PKT_LEN(pPacket))) == NDIS_STATUS_SUCCESS)
-
-#define RT28XX_RELEASE_DESC_RESOURCE(pAd, QueIdx)                      \
-               do{}while(0)
-
-#define NEED_QUEUE_BACK_FOR_AGG(_pAd, _QueIdx, _freeNum, _TxFrameType)                 \
-               ((_TxFrameType == TX_RALINK_FRAME) && (RTUSBNeedQueueBackForAgg(_pAd, _QueIdx)))
-
-
-
-#define fRTMP_ADAPTER_NEED_STOP_TX             \
-               (fRTMP_ADAPTER_NIC_NOT_EXIST | fRTMP_ADAPTER_HALT_IN_PROGRESS | \
-                fRTMP_ADAPTER_RESET_IN_PROGRESS | fRTMP_ADAPTER_BULKOUT_RESET | \
-                fRTMP_ADAPTER_RADIO_OFF | fRTMP_ADAPTER_REMOVE_IN_PROGRESS)
-
-
-#define HAL_WriteSubTxResource(pAd, pTxBlk, bIsLast, pFreeNumber)      \
-                       RtmpUSB_WriteSubTxResource(pAd, pTxBlk, bIsLast, pFreeNumber)
-
-#define HAL_WriteTxResource(pAd, pTxBlk,bIsLast, pFreeNumber)  \
-                       RtmpUSB_WriteSingleTxResource(pAd, pTxBlk,bIsLast, pFreeNumber)
-
-#define HAL_WriteFragTxResource(pAd, pTxBlk, fragNum, pFreeNumber) \
-                       RtmpUSB_WriteFragTxResource(pAd, pTxBlk, fragNum, pFreeNumber)
-
-#define HAL_WriteMultiTxResource(pAd, pTxBlk,frameNum, pFreeNumber)    \
-                       RtmpUSB_WriteMultiTxResource(pAd, pTxBlk,frameNum, pFreeNumber)
-
-#define HAL_FinalWriteTxResource(pAd, pTxBlk, totalMPDUSize, TxIdx)    \
-                       RtmpUSB_FinalWriteTxResource(pAd, pTxBlk, totalMPDUSize, TxIdx)
-
-#define HAL_LastTxIdx(pAd, QueIdx,TxIdx) \
-                       /*RtmpUSBDataLastTxIdx(pAd, QueIdx,TxIdx)*/
-
-#define HAL_KickOutTx(pAd, pTxBlk, QueIdx)     \
-                       RtmpUSBDataKickOut(pAd, pTxBlk, QueIdx)
-
-
-#define HAL_KickOutMgmtTx(pAd, QueIdx, pPacket, pSrcBufVA, SrcBufLen)  \
-                       RtmpUSBMgmtKickOut(pAd, QueIdx, pPacket, pSrcBufVA, SrcBufLen)
-
-#define HAL_KickOutNullFrameTx(_pAd, _QueIdx, _pNullFrame, _frameLen)  \
-                       RtmpUSBNullFrameKickOut(_pAd, _QueIdx, _pNullFrame, _frameLen)
-
-#define RTMP_PKT_TAIL_PADDING  11 // 3(max 4 byte padding) + 4 (last packet padding) + 4 (MaxBulkOutsize align padding)
-
-extern UCHAR EpToQueue[6];
-
-
-#ifdef RT2870
-#define GET_TXRING_FREENO(_pAd, _QueIdx)       (_QueIdx) //(_pAd->TxRing[_QueIdx].TxSwFreeIdx)
-#define GET_MGMTRING_FREENO(_pAd)                      (_pAd->MgmtRing.TxSwFreeIdx)
-#endif // RT2870 //
-
-
-/* ----------------- RX Related MACRO ----------------- */
-//#define RT28XX_RX_ERROR_CHECK                                RTMPCheckRxWI
-
-#define RT28XX_RV_ALL_BUF_END(bBulkReceive)            \
-       /* We return STATUS_MORE_PROCESSING_REQUIRED so that the completion */  \
-       /* routine (IofCompleteRequest) will stop working on the irp. */                \
-       if (bBulkReceive == TRUE)       RTUSBBulkReceive(pAd);
-
-
-/* ----------------- ASIC Related MACRO ----------------- */
-// reset MAC of a station entry to 0xFFFFFFFFFFFF
-#define RT28XX_STA_ENTRY_MAC_RESET(pAd, Wcid)                                  \
-       {       RT_SET_ASIC_WCID        SetAsicWcid;                                            \
-               SetAsicWcid.WCID = Wcid;                                                                \
-               SetAsicWcid.SetTid = 0xffffffff;                                                \
-               SetAsicWcid.DeleteTid = 0xffffffff;                                             \
-               RTUSBEnqueueInternalCmd(pAd, CMDTHREAD_SET_ASIC_WCID,   \
-                               &SetAsicWcid, sizeof(RT_SET_ASIC_WCID));        }
-
-// add this entry into ASIC RX WCID search table
-#define RT28XX_STA_ENTRY_ADD(pAd, pEntry)                                                      \
-       RTUSBEnqueueInternalCmd(pAd, CMDTHREAD_SET_CLIENT_MAC_ENTRY,    \
-                                                       pEntry, sizeof(MAC_TABLE_ENTRY));
-
-// add by johnli, fix "in_interrupt" error when call "MacTableDeleteEntry" in Rx tasklet
-// Set MAC register value according operation mode
-#define RT28XX_UPDATE_PROTECT(pAd)     \
-       RTUSBEnqueueInternalCmd(pAd, CMDTHREAD_UPDATE_PROTECT, NULL, 0);
-// end johnli
-
-// remove Pair-wise key material from ASIC
-// yet implement
-#define RT28XX_STA_ENTRY_KEY_DEL(pAd, BssIdx, Wcid)
-
-// add Client security information into ASIC WCID table and IVEIV table
-#define RT28XX_STA_SECURITY_INFO_ADD(pAd, apidx, KeyID, pEntry)                                                \
-       {       RT28XX_STA_ENTRY_MAC_RESET(pAd, pEntry->Aid);                                                           \
-               if (pEntry->Aid >= 1) {                                                                                                         \
-                       RT_SET_ASIC_WCID_ATTRI  SetAsicWcidAttri;                                                               \
-                       SetAsicWcidAttri.WCID = pEntry->Aid;                                                                    \
-                       if ((pEntry->AuthMode <= Ndis802_11AuthModeAutoSwitch) &&                               \
-                               (pEntry->WepStatus == Ndis802_11Encryption1Enabled))                            \
-                       {                                                                                                                                               \
-                               SetAsicWcidAttri.Cipher = pAd->SharedKey[apidx][KeyID].CipherAlg;       \
-                       }                                                                                                                                               \
-                       else if (pEntry->AuthMode == Ndis802_11AuthModeWPANone)                                 \
-                       {                                                                                                                                               \
-                               SetAsicWcidAttri.Cipher = pAd->SharedKey[apidx][KeyID].CipherAlg;       \
-                       }                                                                                                                                               \
-                       else SetAsicWcidAttri.Cipher = 0;                                                                               \
-            DBGPRINT(RT_DEBUG_TRACE, ("aid cipher = %ld\n",SetAsicWcidAttri.Cipher));       \
-                       RTUSBEnqueueInternalCmd(pAd, CMDTHREAD_SET_ASIC_WCID_CIPHER,                    \
-                                                       &SetAsicWcidAttri, sizeof(RT_SET_ASIC_WCID_ATTRI)); } }
-
-// Insert the BA bitmap to ASIC for the Wcid entry
-#define RT28XX_ADD_BA_SESSION_TO_ASIC(_pAd, _Aid, _TID)                                        \
-               do{                                                                                                                             \
-                       RT_SET_ASIC_WCID        SetAsicWcid;                                                    \
-                       SetAsicWcid.WCID = (_Aid);                                                                      \
-                       SetAsicWcid.SetTid = (0x10000<<(_TID));                                         \
-                       SetAsicWcid.DeleteTid = 0xffffffff;                                                     \
-                       RTUSBEnqueueInternalCmd((_pAd), CMDTHREAD_SET_ASIC_WCID, &SetAsicWcid, sizeof(RT_SET_ASIC_WCID));       \
-               }while(0)
-
-// Remove the BA bitmap from ASIC for the Wcid entry
-#define RT28XX_DEL_BA_SESSION_FROM_ASIC(_pAd, _Wcid, _TID)                             \
-               do{                                                                                                                             \
-                       RT_SET_ASIC_WCID        SetAsicWcid;                                                    \
-                       SetAsicWcid.WCID = (_Wcid);                                                                     \
-                       SetAsicWcid.SetTid = (0xffffffff);                                                      \
-                       SetAsicWcid.DeleteTid = (0x10000<<(_TID) );                                     \
-                       RTUSBEnqueueInternalCmd((_pAd), CMDTHREAD_SET_ASIC_WCID, &SetAsicWcid, sizeof(RT_SET_ASIC_WCID));       \
-               }while(0)
-
-
-/* ----------------- PCI/USB Related MACRO ----------------- */
-#define RT28XX_HANDLE_DEV_ASSIGN(handle, dev_p)                        \
-       ((POS_COOKIE)handle)->pUsb_Dev = dev_p;
-
-// no use
-#define RT28XX_UNMAP()
-#define RT28XX_IRQ_REQUEST(net_dev)
-#define RT28XX_IRQ_RELEASE(net_dev)
-#define RT28XX_IRQ_INIT(pAd)
-#define RT28XX_IRQ_ENABLE(pAd)
-
-
-/* ----------------- MLME Related MACRO ----------------- */
-#define RT28XX_MLME_HANDLER(pAd)                       RTUSBMlmeUp(pAd)
-
-#define RT28XX_MLME_PRE_SANITY_CHECK(pAd)                                                              \
-       {       if ((pAd->CommonCfg.bHardwareRadio == TRUE) &&                                  \
-                       (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NIC_NOT_EXIST)) &&          \
-                       (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS))) {       \
-                       RTUSBEnqueueInternalCmd(pAd, CMDTHREAD_CHECK_GPIO, NULL, 0); } }
-
-#define RT28XX_MLME_STA_QUICK_RSP_WAKE_UP(pAd) \
-       {       RTUSBEnqueueInternalCmd(pAd, CMDTHREAD_QKERIODIC_EXECUT, NULL, 0);      \
-               RTUSBMlmeUp(pAd); }
-
-#define RT28XX_MLME_RESET_STATE_MACHINE(pAd)   \
-                       MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_RESET_CONF, 0, NULL);     \
-                       RTUSBMlmeUp(pAd);
-
-#define RT28XX_HANDLE_COUNTER_MEASURE(_pAd, _pEntry)           \
-       {       RTUSBEnqueueInternalCmd(_pAd, CMDTHREAD_802_11_COUNTER_MEASURE, _pEntry, sizeof(MAC_TABLE_ENTRY));      \
-               RTUSBMlmeUp(_pAd);                                                                      \
-       }
-
-
-/* ----------------- Power Save Related MACRO ----------------- */
-#define RT28XX_PS_POLL_ENQUEUE(pAd)                                            \
-       {       RTUSB_SET_BULK_FLAG(pAd, fRTUSB_BULK_OUT_PSPOLL);       \
-               RTUSBKickBulkOut(pAd); }
-
-#define RT28xx_CHIP_NAME            "RT2870"
-#define USB_CYC_CFG                 0x02a4
-#define NT_SUCCESS(status)                     (((status) > 0) ? (1):(0))
-#define InterlockedIncrement           atomic_inc
-#define NdisInterlockedIncrement       atomic_inc
-#define InterlockedDecrement           atomic_dec
-#define NdisInterlockedDecrement       atomic_dec
-#define InterlockedExchange                    atomic_set
-//#define NdisMSendComplete                    RTMP_SendComplete
-#define NdisMCancelTimer                       RTMPCancelTimer
-#define NdisAllocMemory(_ptr, _size, _flag)    \
-                                                                       do{_ptr = kmalloc((_size),(_flag));}while(0)
-#define NdisFreeMemory(a, b, c)        kfree((a))
-#define NdisMSleep                                     RTMPusecDelay           /* unit: microsecond */
-
-
-#define USBD_TRANSFER_DIRECTION_OUT            0
-#define USBD_TRANSFER_DIRECTION_IN             0
-#define USBD_SHORT_TRANSFER_OK                 0
-#define PURB                   purbb_t
-
-#define RTUSB_FREE_URB(pUrb)   usb_free_urb(pUrb)
-
-//#undef MlmeAllocateMemory
-//#undef MlmeFreeMemory
-
-typedef struct usb_device      * PUSB_DEV;
-
-/* MACRO for linux usb */
-typedef struct urb *purbb_t;
-typedef struct usb_ctrlrequest devctrlrequest;
-#define PIRP           PVOID
-#define PMDL           PVOID
-#define NDIS_OID       UINT
-#ifndef USB_ST_NOERROR
-#define USB_ST_NOERROR     0
-#endif
-
-// vendor-specific control operations
-#define CONTROL_TIMEOUT_JIFFIES ( (100 * HZ) / 1000)
-#define UNLINK_TIMEOUT_MS              3
-
-/* unlink urb  */
-#define RTUSB_UNLINK_URB(pUrb)         usb_kill_urb(pUrb)
-
-// Prototypes of completion funuc.
-VOID RTUSBBulkOutDataPacketComplete(purbb_t purb, struct pt_regs *pt_regs);
-VOID RTUSBBulkOutMLMEPacketComplete(purbb_t pUrb, struct pt_regs *pt_regs);
-VOID RTUSBBulkOutNullFrameComplete(purbb_t pUrb, struct pt_regs *pt_regs);
-VOID RTUSBBulkOutRTSFrameComplete(purbb_t pUrb, struct pt_regs *pt_regs);
-VOID RTUSBBulkOutPsPollComplete(purbb_t pUrb, struct pt_regs *pt_regs);
-VOID RTUSBBulkRxComplete(purbb_t pUrb, struct pt_regs *pt_regs);
-
-
-#define RTUSBMlmeUp(pAd)               \
-{                                                                  \
-       POS_COOKIE pObj = (POS_COOKIE) pAd->OS_Cookie;  \
-       if(pObj->MLMEThr_pid>0)             \
-        up(&(pAd->mlme_semaphore)); \
-}
-
-#define RTUSBCMDUp(pAd)                        \
-{                                                                          \
-       POS_COOKIE pObj = (POS_COOKIE) pAd->OS_Cookie;  \
-       if(pObj->RTUSBCmdThr_pid>0)                 \
-           up(&(pAd->RTUSBCmd_semaphore)); \
-}
-
-
-static inline NDIS_STATUS RTMPAllocateMemory(
-       OUT PVOID *ptr,
-       IN size_t size)
-{
-       *ptr = kmalloc(size, GFP_ATOMIC);
-       if(*ptr)
-               return NDIS_STATUS_SUCCESS;
-       else
-               return NDIS_STATUS_RESOURCES;
-}
-
-/* rtmp.h */
-#define        BEACON_RING_SIZE                2
-#define DEVICE_VENDOR_REQUEST_OUT       0x40
-#define DEVICE_VENDOR_REQUEST_IN        0xc0
-#define INTERFACE_VENDOR_REQUEST_OUT    0x41
-#define INTERFACE_VENDOR_REQUEST_IN     0xc1
-#define MGMTPIPEIDX                                            0       // EP6 is highest priority
-
-#define BULKOUT_MGMT_RESET_FLAG                                0x80
-
-#define RTUSB_SET_BULK_FLAG(_M, _F)                            ((_M)->BulkFlags |= (_F))
-#define RTUSB_CLEAR_BULK_FLAG(_M, _F)                  ((_M)->BulkFlags &= ~(_F))
-#define RTUSB_TEST_BULK_FLAG(_M, _F)                   (((_M)->BulkFlags & (_F)) != 0)
-
-#define EnqueueCmd(cmdq, cmdqelmt)             \
-{                                                                              \
-       if (cmdq->size == 0)                            \
-               cmdq->head = cmdqelmt;                  \
-       else                                                            \
-               cmdq->tail->next = cmdqelmt;    \
-       cmdq->tail = cmdqelmt;                          \
-       cmdqelmt->next = NULL;                          \
-       cmdq->size++;                                           \
-}
-
-typedef struct   _RT_SET_ASIC_WCID {
-       ULONG WCID;          // mechanism for rekeying: 0:disable, 1: time-based, 2: packet-based
-       ULONG SetTid;        // time-based: seconds, packet-based: kilo-packets
-       ULONG DeleteTid;        // time-based: seconds, packet-based: kilo-packets
-} RT_SET_ASIC_WCID,*PRT_SET_ASIC_WCID;
-
-typedef struct   _RT_SET_ASIC_WCID_ATTRI {
-       ULONG   WCID;          // mechanism for rekeying: 0:disable, 1: time-based, 2: packet-based
-       ULONG   Cipher;        // ASIC Cipher definition
-       UCHAR   Addr[ETH_LENGTH_OF_ADDRESS];
-} RT_SET_ASIC_WCID_ATTRI,*PRT_SET_ASIC_WCID_ATTRI;
-
-typedef struct _MLME_MEMORY_STRUCT {
-       PVOID                           AllocVa;    //Pointer to the base virtual address of the allocated memory
-       struct _MLME_MEMORY_STRUCT      *Next;      //Pointer to the next virtual address of the allocated memory
-}   MLME_MEMORY_STRUCT, *PMLME_MEMORY_STRUCT;
-
-typedef struct  _MLME_MEMORY_HANDLER {
-       BOOLEAN                 MemRunning;         //The flag of the Mlme memory handler's status
-       UINT                    MemoryCount;        //Total nonpaged system-space memory not size
-       UINT                    InUseCount;         //Nonpaged system-space memory in used counts
-       UINT                    UnUseCount;         //Nonpaged system-space memory available counts
-       INT                    PendingCount;       //Nonpaged system-space memory for free counts
-       PMLME_MEMORY_STRUCT     pInUseHead;         //Pointer to the first nonpaed memory not used
-       PMLME_MEMORY_STRUCT     pInUseTail;         //Pointer to the last nonpaged memory not used
-       PMLME_MEMORY_STRUCT     pUnUseHead;         //Pointer to the first nonpaged memory in used
-       PMLME_MEMORY_STRUCT     pUnUseTail;         //Pointer to the last nonpaged memory in used
-       PULONG                  MemFreePending[MAX_MLME_HANDLER_MEMORY];   //an array to keep pending free-memory's pointer (32bits)
-}   MLME_MEMORY_HANDLER, *PMLME_MEMORY_HANDLER;
-
-typedef        struct _CmdQElmt        {
-       UINT                            command;
-       PVOID                           buffer;
-       ULONG                           bufferlength;
-       BOOLEAN                         CmdFromNdis;
-       BOOLEAN                         SetOperation;
-       struct _CmdQElmt        *next;
-}      CmdQElmt, *PCmdQElmt;
-
-typedef        struct  _CmdQ   {
-       UINT            size;
-       CmdQElmt        *head;
-       CmdQElmt        *tail;
-       UINT32          CmdQState;
-}CmdQ, *PCmdQ;
-
-/* oid.h */
-// Cipher suite type for mixed mode group cipher, P802.11i-2004
-typedef enum _RT_802_11_CIPHER_SUITE_TYPE {
-       Cipher_Type_NONE,
-       Cipher_Type_WEP40,
-       Cipher_Type_TKIP,
-       Cipher_Type_RSVD,
-       Cipher_Type_CCMP,
-       Cipher_Type_WEP104
-} RT_802_11_CIPHER_SUITE_TYPE, *PRT_802_11_CIPHER_SUITE_TYPE;
-
-//CMDTHREAD_MULTI_READ_MAC
-//CMDTHREAD_MULTI_WRITE_MAC
-//CMDTHREAD_VENDOR_EEPROM_READ
-//CMDTHREAD_VENDOR_EEPROM_WRITE
-typedef        struct  _CMDHandler_TLV {
-       USHORT          Offset;
-       USHORT          Length;
-       UCHAR           DataFirst;
-}      CMDHandler_TLV, *PCMDHandler_TLV;
-
-// New for MeetingHouse Api support
-#define CMDTHREAD_VENDOR_RESET                      0x0D730101 // cmd
-#define CMDTHREAD_VENDOR_UNPLUG                     0x0D730102 // cmd
-#define CMDTHREAD_VENDOR_SWITCH_FUNCTION            0x0D730103 // cmd
-#define CMDTHREAD_MULTI_WRITE_MAC                   0x0D730107 // cmd
-#define CMDTHREAD_MULTI_READ_MAC                    0x0D730108 // cmd
-#define CMDTHREAD_VENDOR_EEPROM_WRITE               0x0D73010A // cmd
-#define CMDTHREAD_VENDOR_EEPROM_READ                0x0D73010B // cmd
-#define CMDTHREAD_VENDOR_ENTER_TESTMODE             0x0D73010C // cmd
-#define CMDTHREAD_VENDOR_EXIT_TESTMODE              0x0D73010D // cmd
-#define CMDTHREAD_VENDOR_WRITE_BBP                  0x0D730119 // cmd
-#define CMDTHREAD_VENDOR_READ_BBP                   0x0D730118 // cmd
-#define CMDTHREAD_VENDOR_WRITE_RF                   0x0D73011A // cmd
-#define CMDTHREAD_VENDOR_FLIP_IQ                    0x0D73011D // cmd
-#define CMDTHREAD_RESET_BULK_OUT                    0x0D730210 // cmd
-#define CMDTHREAD_RESET_BULK_IN                     0x0D730211 // cmd
-#define CMDTHREAD_SET_PSM_BIT_SAVE                  0x0D730212 // cmd
-#define CMDTHREAD_SET_RADIO                         0x0D730214 // cmd
-#define CMDTHREAD_UPDATE_TX_RATE                    0x0D730216 // cmd
-#define CMDTHREAD_802_11_ADD_KEY_WEP                0x0D730218 // cmd
-#define CMDTHREAD_RESET_FROM_ERROR                  0x0D73021A // cmd
-#define CMDTHREAD_LINK_DOWN                         0x0D73021B // cmd
-#define CMDTHREAD_RESET_FROM_NDIS                   0x0D73021C // cmd
-#define CMDTHREAD_CHECK_GPIO                        0x0D730215 // cmd
-#define CMDTHREAD_FORCE_WAKE_UP                     0x0D730222 // cmd
-#define CMDTHREAD_SET_BW                            0x0D730225 // cmd
-#define CMDTHREAD_SET_ASIC_WCID                     0x0D730226 // cmd
-#define CMDTHREAD_SET_ASIC_WCID_CIPHER              0x0D730227 // cmd
-#define CMDTHREAD_QKERIODIC_EXECUT                  0x0D73023D // cmd
-#define RT_CMD_SET_KEY_TABLE                        0x0D730228  // cmd
-#define RT_CMD_SET_RX_WCID_TABLE                    0x0D730229  // cmd
-#define CMDTHREAD_SET_CLIENT_MAC_ENTRY              0x0D73023E // cmd
-#define CMDTHREAD_802_11_QUERY_HARDWARE_REGISTER    0x0D710105 // cmd
-#define CMDTHREAD_802_11_SET_PHY_MODE               0x0D79010C // cmd
-#define CMDTHREAD_802_11_SET_STA_CONFIG             0x0D790111 // cmd
-#define CMDTHREAD_802_11_SET_PREAMBLE               0x0D790101 // cmd
-#define CMDTHREAD_802_11_COUNTER_MEASURE                       0x0D790102      // cmd
-// add by johnli, fix "in_interrupt" error when call "MacTableDeleteEntry" in Rx tasklet
-#define CMDTHREAD_UPDATE_PROTECT                                       0x0D790103      // cmd
-// end johnli
-
-#define WPA1AKMBIT         0x01
-#define WPA2AKMBIT         0x02
-#define WPA1PSKAKMBIT   0x04
-#define WPA2PSKAKMBIT   0x08
-#define TKIPBIT         0x01
-#define CCMPBIT         0x02
-
-
-#define RT28XX_STA_FORCE_WAKEUP(pAd, bFromTx) \
-    RT28xxUsbStaAsicForceWakeup(pAd, bFromTx);
-
-#define RT28XX_STA_SLEEP_THEN_AUTO_WAKEUP(pAd, TbttNumToNextWakeUp) \
-    RT28xxUsbStaAsicSleepThenAutoWakeup(pAd, TbttNumToNextWakeUp);
-
-#define RT28XX_MLME_RADIO_ON(pAd) \
-    RT28xxUsbMlmeRadioOn(pAd);
-
-#define RT28XX_MLME_RADIO_OFF(pAd) \
-    RT28xxUsbMlmeRadioOFF(pAd);
-
-#endif //__RT2870_H__
+#include "../rt2870/rt2870.h"
index c935efb40113bee7ce0f34b3a3ebe870a1ffd4cb..c47ddc8bd9e9c20b5434d212d09327f118676456 100644 (file)
@@ -1,1654 +1 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify  *
- * it under the terms of the GNU General Public License as published by  *
- * the Free Software Foundation; either version 2 of the License, or     *
- * (at your option) any later version.                                   *
- *                                                                       *
- * 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.                          *
- *                                                                       *
- * You should have received a copy of the GNU General Public License     *
- * along with this program; if not, write to the                         *
- * Free Software Foundation, Inc.,                                       *
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- *                                                                       *
- *************************************************************************
-
-       Module Name:
-       rt28xx.h
-
-       Abstract:
-       RT28xx ASIC related definition & structures
-
-       Revision History:
-       Who                     When              What
-       --------        ----------        ----------------------------------------------
-       Jan Lee           Jan-3-2006     created for RT2860c
-*/
-
-#ifndef        __RT28XX_H__
-#define        __RT28XX_H__
-
-
-//
-// PCI registers - base address 0x0000
-//
-#define PCI_CFG                        0x0000
-#define PCI_EECTRL                     0x0004
-#define PCI_MCUCTRL                    0x0008
-
-#define        OPT_14                  0x114
-
-typedef int                            NTSTATUS;
-#define        RETRY_LIMIT             10
-#define STATUS_SUCCESS                         0x00
-#define STATUS_UNSUCCESSFUL            0x01
-
-//
-// SCH/DMA registers - base address 0x0200
-//
-// INT_SOURCE_CSR: Interrupt source register. Write one to clear corresponding bit
-//
-#define DMA_CSR0      0x200
-#define INT_SOURCE_CSR      0x200
-typedef        union   _INT_SOURCE_CSR_STRUC   {
-       struct  {
-               UINT32          RxDelayINT:1;
-               UINT32          TxDelayINT:1;
-               UINT32          RxDone:1;
-               UINT32          Ac0DmaDone:1;//4
-               UINT32          Ac1DmaDone:1;
-               UINT32          Ac2DmaDone:1;
-               UINT32          Ac3DmaDone:1;
-               UINT32          HccaDmaDone:1; // bit7
-               UINT32          MgmtDmaDone:1;
-               UINT32          MCUCommandINT:1;//bit 9
-               UINT32          RxTxCoherent:1;
-               UINT32          TBTTInt:1;
-               UINT32          PreTBTT:1;
-               UINT32          TXFifoStatusInt:1;//FIFO Statistics is full, sw should read 0x171c
-               UINT32          AutoWakeup:1;//bit14
-               UINT32          GPTimer:1;
-               UINT32          RxCoherent:1;//bit16
-               UINT32          TxCoherent:1;
-               UINT32          :14;
-       }       field;
-       UINT32                  word;
-} INT_SOURCE_CSR_STRUC, *PINT_SOURCE_CSR_STRUC;
-
-//
-// INT_MASK_CSR:   Interrupt MASK register.   1: the interrupt is mask OFF
-//
-#define INT_MASK_CSR        0x204
-typedef        union   _INT_MASK_CSR_STRUC     {
-       struct  {
-               UINT32          RXDelay_INT_MSK:1;
-               UINT32          TxDelay:1;
-               UINT32          RxDone:1;
-               UINT32          Ac0DmaDone:1;
-               UINT32          Ac1DmaDone:1;
-               UINT32          Ac2DmaDone:1;
-               UINT32          Ac3DmaDone:1;
-               UINT32          HccaDmaDone:1;
-               UINT32          MgmtDmaDone:1;
-               UINT32          MCUCommandINT:1;
-               UINT32          :20;
-               UINT32          RxCoherent:1;
-               UINT32          TxCoherent:1;
-       }       field;
-       UINT32                  word;
-} INT_MASK_CSR_STRUC, *PINT_MASK_CSR_STRUC;
-
-#define WPDMA_GLO_CFG  0x208
-typedef        union   _WPDMA_GLO_CFG_STRUC    {
-       struct  {
-               UINT32          EnableTxDMA:1;
-               UINT32          TxDMABusy:1;
-               UINT32          EnableRxDMA:1;
-               UINT32          RxDMABusy:1;
-               UINT32          WPDMABurstSIZE:2;
-               UINT32          EnTXWriteBackDDONE:1;
-               UINT32          BigEndian:1;
-               UINT32          RXHdrScater:8;
-               UINT32          HDR_SEG_LEN:16;
-       }       field;
-       UINT32                  word;
-} WPDMA_GLO_CFG_STRUC, *PWPDMA_GLO_CFG_STRUC;
-
-#define WPDMA_RST_IDX  0x20c
-typedef        union   _WPDMA_RST_IDX_STRUC    {
-       struct  {
-               UINT32          RST_DTX_IDX0:1;
-               UINT32          RST_DTX_IDX1:1;
-               UINT32          RST_DTX_IDX2:1;
-               UINT32          RST_DTX_IDX3:1;
-               UINT32          RST_DTX_IDX4:1;
-               UINT32          RST_DTX_IDX5:1;
-               UINT32          rsv:10;
-               UINT32          RST_DRX_IDX0:1;
-               UINT32          :15;
-       }       field;
-       UINT32                  word;
-} WPDMA_RST_IDX_STRUC, *PWPDMA_RST_IDX_STRUC;
-
-#define DELAY_INT_CFG  0x0210
-typedef        union   _DELAY_INT_CFG_STRUC    {
-       struct  {
-               UINT32          RXMAX_PTIME:8;
-               UINT32          RXMAX_PINT:7;
-               UINT32          RXDLY_INT_EN:1;
-               UINT32          TXMAX_PTIME:8;
-               UINT32          TXMAX_PINT:7;
-               UINT32          TXDLY_INT_EN:1;
-       }       field;
-       UINT32                  word;
-} DELAY_INT_CFG_STRUC, *PDELAY_INT_CFG_STRUC;
-
-#define WMM_AIFSN_CFG   0x0214
-typedef        union   _AIFSN_CSR_STRUC        {
-       struct  {
-           UINT32   Aifsn0:4;       // for AC_BE
-           UINT32   Aifsn1:4;       // for AC_BK
-           UINT32   Aifsn2:4;       // for AC_VI
-           UINT32   Aifsn3:4;       // for AC_VO
-           UINT32   Rsv:16;
-       }       field;
-       UINT32                  word;
-}      AIFSN_CSR_STRUC, *PAIFSN_CSR_STRUC;
-
-//
-// CWMIN_CSR: CWmin for each EDCA AC
-//
-#define WMM_CWMIN_CFG   0x0218
-typedef        union   _CWMIN_CSR_STRUC        {
-       struct  {
-           UINT32   Cwmin0:4;       // for AC_BE
-           UINT32   Cwmin1:4;       // for AC_BK
-           UINT32   Cwmin2:4;       // for AC_VI
-           UINT32   Cwmin3:4;       // for AC_VO
-           UINT32   Rsv:16;
-       }       field;
-       UINT32                  word;
-}      CWMIN_CSR_STRUC, *PCWMIN_CSR_STRUC;
-
-//
-// CWMAX_CSR: CWmin for each EDCA AC
-//
-#define WMM_CWMAX_CFG   0x021c
-typedef        union   _CWMAX_CSR_STRUC        {
-       struct  {
-           UINT32   Cwmax0:4;       // for AC_BE
-           UINT32   Cwmax1:4;       // for AC_BK
-           UINT32   Cwmax2:4;       // for AC_VI
-           UINT32   Cwmax3:4;       // for AC_VO
-           UINT32   Rsv:16;
-       }       field;
-       UINT32                  word;
-}      CWMAX_CSR_STRUC, *PCWMAX_CSR_STRUC;
-
-//
-// AC_TXOP_CSR0: AC_BK/AC_BE TXOP register
-//
-#define WMM_TXOP0_CFG    0x0220
-typedef        union   _AC_TXOP_CSR0_STRUC     {
-       struct  {
-           USHORT  Ac0Txop;        // for AC_BK, in unit of 32us
-           USHORT  Ac1Txop;        // for AC_BE, in unit of 32us
-       }       field;
-       UINT32                  word;
-}      AC_TXOP_CSR0_STRUC, *PAC_TXOP_CSR0_STRUC;
-
-//
-// AC_TXOP_CSR1: AC_VO/AC_VI TXOP register
-//
-#define WMM_TXOP1_CFG    0x0224
-typedef        union   _AC_TXOP_CSR1_STRUC     {
-       struct  {
-           USHORT  Ac2Txop;        // for AC_VI, in unit of 32us
-           USHORT  Ac3Txop;        // for AC_VO, in unit of 32us
-       }       field;
-       UINT32                  word;
-}      AC_TXOP_CSR1_STRUC, *PAC_TXOP_CSR1_STRUC;
-
-#define RINGREG_DIFF                   0x10
-#define GPIO_CTRL_CFG    0x0228        //MAC_CSR13
-#define MCU_CMD_CFG    0x022c
-#define TX_BASE_PTR0     0x0230        //AC_BK base address
-#define TX_MAX_CNT0      0x0234
-#define TX_CTX_IDX0       0x0238
-#define TX_DTX_IDX0      0x023c
-#define TX_BASE_PTR1     0x0240        //AC_BE base address
-#define TX_MAX_CNT1      0x0244
-#define TX_CTX_IDX1       0x0248
-#define TX_DTX_IDX1      0x024c
-#define TX_BASE_PTR2     0x0250        //AC_VI base address
-#define TX_MAX_CNT2      0x0254
-#define TX_CTX_IDX2       0x0258
-#define TX_DTX_IDX2      0x025c
-#define TX_BASE_PTR3     0x0260        //AC_VO base address
-#define TX_MAX_CNT3      0x0264
-#define TX_CTX_IDX3       0x0268
-#define TX_DTX_IDX3      0x026c
-#define TX_BASE_PTR4     0x0270        //HCCA base address
-#define TX_MAX_CNT4      0x0274
-#define TX_CTX_IDX4       0x0278
-#define TX_DTX_IDX4      0x027c
-#define TX_BASE_PTR5     0x0280        //MGMT base address
-#define  TX_MAX_CNT5     0x0284
-#define TX_CTX_IDX5       0x0288
-#define TX_DTX_IDX5      0x028c
-#define TX_MGMTMAX_CNT      TX_MAX_CNT5
-#define TX_MGMTCTX_IDX       TX_CTX_IDX5
-#define TX_MGMTDTX_IDX      TX_DTX_IDX5
-#define RX_BASE_PTR     0x0290         //RX base address
-#define RX_MAX_CNT      0x0294
-#define RX_CRX_IDX       0x0298
-#define RX_DRX_IDX      0x029c
-#define USB_DMA_CFG      0x02a0
-
-typedef        union   _USB_DMA_CFG_STRUC      {
-       struct  {
-           UINT32  RxBulkAggTOut:8;        //Rx Bulk Aggregation TimeOut  in unit of 33ns
-           UINT32  RxBulkAggLmt:8;        //Rx Bulk Aggregation Limit  in unit of 256 bytes
-           UINT32  phyclear:1;                 //phy watch dog enable. write 1
-           UINT32  rsv:2;
-           UINT32  TxClear:1;        //Clear USB DMA TX path
-           UINT32  TxopHalt:1;        //Halt TXOP count down when TX buffer is full.
-           UINT32  RxBulkAggEn:1;        //Enable Rx Bulk Aggregation
-           UINT32  RxBulkEn:1;        //Enable USB DMA Rx
-           UINT32  TxBulkEn:1;        //Enable USB DMA Tx
-           UINT32  EpoutValid:6;        //OUT endpoint data valid
-           UINT32  RxBusy:1;        //USB DMA RX FSM busy
-           UINT32  TxBusy:1;           //USB DMA TX FSM busy
-       }       field;
-       UINT32                  word;
-}      USB_DMA_CFG_STRUC, *PUSB_DMA_CFG_STRUC;
-
-//
-//  3  PBF  registers
-//
-//
-// Most are for debug. Driver doesn't touch PBF register.
-#define        PBF_SYS_CTRL     0x0400
-#define     PBF_CFG                 0x0408
-#define        PBF_MAX_PCNT     0x040C
-#define        PBF_CTRL                0x0410
-#define        PBF_INT_STA      0x0414
-#define        PBF_INT_ENA      0x0418
-#define        TXRXQ_PCNT       0x0438
-#define        PBF_DBG                  0x043c
-#define     PBF_CAP_CTRL     0x0440
-
-
-// eFuse registers
-#define EFUSE_CTRL              0x0580
-#define EFUSE_DATA0             0x0590
-#define EFUSE_DATA1             0x0594
-#define EFUSE_DATA2             0x0598
-#define EFUSE_DATA3             0x059c
-#define EFUSE_USAGE_MAP_START   0x2d0
-#define EFUSE_USAGE_MAP_END     0x2fc
-#define EFUSE_TAG               0x2fe
-#define EFUSE_USAGE_MAP_SIZE    45
-
-typedef        union   _EFUSE_CTRL_STRUC {
-       struct  {
-               UINT32            EFSROM_AOUT:6;
-               UINT32            EFSROM_MODE:2;
-               UINT32            EFSROM_LDO_OFF_TIME:6;
-               UINT32            EFSROM_LDO_ON_TIME:2;
-               UINT32            EFSROM_AIN:10;
-               UINT32            RESERVED:4;
-               UINT32            EFSROM_KICK:1;
-               UINT32            SEL_EFUSE:1;
-       }       field;
-       UINT32                  word;
-}      EFUSE_CTRL_STRUC, *PEFUSE_CTRL_STRUC;
-
-#define LDO_CFG0                               0x05d4
-#define GPIO_SWITCH                            0x05dc
-
-//
-//  4  MAC  registers
-//
-//
-//  4.1 MAC SYSTEM  configuration registers (offset:0x1000)
-//
-#define MAC_CSR0            0x1000
-typedef        union   _ASIC_VER_ID_STRUC      {
-       struct  {
-           USHORT  ASICRev;        // reversion  : 0
-           USHORT  ASICVer;        // version : 2860
-       }       field;
-       UINT32                  word;
-}      ASIC_VER_ID_STRUC, *PASIC_VER_ID_STRUC;
-
-#define MAC_SYS_CTRL            0x1004         //MAC_CSR1
-#define MAC_ADDR_DW0                           0x1008          // MAC ADDR DW0
-#define MAC_ADDR_DW1                            0x100c         // MAC ADDR DW1
-//
-// MAC_CSR2: STA MAC register 0
-//
-typedef        union   _MAC_DW0_STRUC  {
-       struct  {
-               UCHAR           Byte0;          // MAC address byte 0
-               UCHAR           Byte1;          // MAC address byte 1
-               UCHAR           Byte2;          // MAC address byte 2
-               UCHAR           Byte3;          // MAC address byte 3
-       }       field;
-       UINT32                  word;
-}      MAC_DW0_STRUC, *PMAC_DW0_STRUC;
-
-//
-// MAC_CSR3: STA MAC register 1
-//
-typedef        union   _MAC_DW1_STRUC  {
-       struct  {
-               UCHAR           Byte4;          // MAC address byte 4
-               UCHAR           Byte5;          // MAC address byte 5
-               UCHAR           U2MeMask;
-               UCHAR           Rsvd1;
-       }       field;
-       UINT32                  word;
-}      MAC_DW1_STRUC, *PMAC_DW1_STRUC;
-
-#define MAC_BSSID_DW0                          0x1010          // MAC BSSID DW0
-#define MAC_BSSID_DW1                          0x1014          // MAC BSSID DW1
-
-//
-// MAC_CSR5: BSSID register 1
-//
-typedef        union   _MAC_CSR5_STRUC {
-       struct  {
-               UCHAR           Byte4;           // BSSID byte 4
-               UCHAR           Byte5;           // BSSID byte 5
-               USHORT          BssIdMask:2; // 0: one BSSID, 10: 4 BSSID,  01: 2 BSSID , 11: 8BSSID
-               USHORT          MBssBcnNum:3;
-               USHORT          Rsvd:11;
-       }       field;
-       UINT32                  word;
-}      MAC_CSR5_STRUC, *PMAC_CSR5_STRUC;
-
-#define MAX_LEN_CFG              0x1018                // rt2860b max 16k bytes. bit12:13 Maximum PSDU length (power factor) 0:2^13, 1:2^14, 2:2^15, 3:2^16
-#define BBP_CSR_CFG                            0x101c          //
-//
-// BBP_CSR_CFG: BBP serial control register
-//
-typedef        union   _BBP_CSR_CFG_STRUC      {
-       struct  {
-               UINT32          Value:8;                        // Register     value to program into BBP
-               UINT32          RegNum:8;                       // Selected     BBP     register
-               UINT32          fRead:1;                    // 0: Write BBP, 1: Read BBP
-               UINT32          Busy:1;                         // 1: ASIC is busy execute BBP programming.
-               UINT32          BBP_PAR_DUR:1;               // 0: 4 MAC clock cycles  1: 8 MAC clock cycles
-               UINT32          BBP_RW_MODE:1;          // 0: use serial mode  1:parallel
-               UINT32          :12;
-       }       field;
-       UINT32                  word;
-}      BBP_CSR_CFG_STRUC, *PBBP_CSR_CFG_STRUC;
-
-#define RF_CSR_CFG0                            0x1020
-//
-// RF_CSR_CFG: RF control register
-//
-typedef        union   _RF_CSR_CFG0_STRUC      {
-       struct  {
-               UINT32          RegIdAndContent:24;                     // Register     value to program into BBP
-               UINT32          bitwidth:5;                     // Selected     BBP     register
-               UINT32          StandbyMode:1;              // 0: high when stand by 1: low when standby
-               UINT32          Sel:1;                          // 0:RF_LE0 activate  1:RF_LE1 activate
-               UINT32          Busy:1;             // 0: idle 1: 8busy
-       }       field;
-       UINT32                  word;
-}      RF_CSR_CFG0_STRUC, *PRF_CSR_CFG0_STRUC;
-
-#define RF_CSR_CFG1                    0x1024
-typedef        union   _RF_CSR_CFG1_STRUC      {
-       struct  {
-               UINT32          RegIdAndContent:24;                     // Register     value to program into BBP
-               UINT32          RFGap:5;                        // Gap between BB_CONTROL_RF and RF_LE. 0: 3 system clock cycle (37.5usec) 1: 5 system clock cycle (62.5usec)
-               UINT32          rsv:7;              // 0: idle 1: 8busy
-       }       field;
-       UINT32                  word;
-}      RF_CSR_CFG1_STRUC, *PRF_CSR_CFG1_STRUC;
-
-#define RF_CSR_CFG2                    0x1028          //
-typedef        union   _RF_CSR_CFG2_STRUC      {
-       struct  {
-               UINT32          RegIdAndContent:24;                     // Register     value to program into BBP
-               UINT32          rsv:8;              // 0: idle 1: 8busy
-       }       field;
-       UINT32                  word;
-}      RF_CSR_CFG2_STRUC, *PRF_CSR_CFG2_STRUC;
-
-#define LED_CFG                        0x102c          //  MAC_CSR14
-typedef        union   _LED_CFG_STRUC  {
-       struct  {
-               UINT32          OnPeriod:8;                     // blinking on period unit 1ms
-               UINT32          OffPeriod:8;                    // blinking off period unit 1ms
-               UINT32          SlowBlinkPeriod:6;                      // slow blinking period. unit:1ms
-               UINT32          rsv:2;
-               UINT32          RLedMode:2;                     // red Led Mode    0: off1: blinking upon TX2: periodic slow blinking3: always on
-               UINT32          GLedMode:2;                     // green Led Mode
-               UINT32          YLedMode:2;                     // yellow Led Mode
-               UINT32          LedPolar:1;                     // Led Polarity.  0: active low1: active high
-               UINT32          :1;
-       }       field;
-       UINT32                  word;
-}      LED_CFG_STRUC, *PLED_CFG_STRUC;
-
-//
-//  4.2 MAC TIMING  configuration registers (offset:0x1100)
-//
-#define XIFS_TIME_CFG             0x1100                // MAC_CSR8  MAC_CSR9
-typedef        union   _IFS_SLOT_CFG_STRUC     {
-       struct  {
-           UINT32  CckmSifsTime:8;        //  unit 1us. Applied after CCK RX/TX
-           UINT32  OfdmSifsTime:8;        //  unit 1us. Applied after OFDM RX/TX
-           UINT32  OfdmXifsTime:4;        //OFDM SIFS. unit 1us. Applied after OFDM RX when MAC doesn't reference BBP signal BBRXEND
-           UINT32  EIFS:9;        //  unit 1us
-           UINT32  BBRxendEnable:1;        //  reference RXEND signal to begin XIFS defer
-           UINT32  rsv:2;
-       }       field;
-       UINT32                  word;
-}      IFS_SLOT_CFG_STRUC, *PIFS_SLOT_CFG_STRUC;
-
-#define BKOFF_SLOT_CFG             0x1104               //  mac_csr9 last 8 bits
-#define NAV_TIME_CFG             0x1108                 // NAV  (MAC_CSR15)
-#define CH_TIME_CFG             0x110C                 // Count as channel busy
-#define PBF_LIFE_TIMER             0x1110               //TX/RX MPDU timestamp timer (free run)Unit: 1us
-#define BCN_TIME_CFG             0x1114                 // TXRX_CSR9
-
-#define BCN_OFFSET0                            0x042C
-#define BCN_OFFSET1                            0x0430
-
-//
-// BCN_TIME_CFG : Synchronization control register
-//
-typedef        union   _BCN_TIME_CFG_STRUC     {
-       struct  {
-               UINT32       BeaconInterval:16;  // in unit of 1/16 TU
-               UINT32          bTsfTicking:1;          // Enable TSF auto counting
-               UINT32          TsfSyncMode:2;          // Enable TSF sync, 00: disable, 01: infra mode, 10: ad-hoc mode
-        UINT32       bTBTTEnable:1;
-               UINT32          bBeaconGen:1;           // Enable beacon generator
-        UINT32       :3;
-               UINT32          TxTimestampCompensate:8;
-       }       field;
-       UINT32                  word;
-}      BCN_TIME_CFG_STRUC, *PBCN_TIME_CFG_STRUC;
-
-#define TBTT_SYNC_CFG            0x1118                // txrx_csr10
-#define TSF_TIMER_DW0             0x111C               // Local TSF timer lsb 32 bits. Read-only
-#define TSF_TIMER_DW1             0x1120               // msb 32 bits. Read-only.
-#define TBTT_TIMER                     0x1124                  // TImer remains till next TBTT. Read-only.  TXRX_CSR14
-#define INT_TIMER_CFG                  0x1128                  //
-#define INT_TIMER_EN                   0x112c                  //  GP-timer and pre-tbtt Int enable
-#define CH_IDLE_STA                    0x1130                  //  channel idle time
-#define CH_BUSY_STA                    0x1134                  //  channle busy time
-//
-//  4.2 MAC POWER  configuration registers (offset:0x1200)
-//
-#define MAC_STATUS_CFG             0x1200               // old MAC_CSR12
-#define PWR_PIN_CFG             0x1204          // old MAC_CSR12
-#define AUTO_WAKEUP_CFG             0x1208              // old MAC_CSR10
-//
-// AUTO_WAKEUP_CFG: Manual power control / status register
-//
-typedef        union   _AUTO_WAKEUP_STRUC      {
-       struct  {
-               UINT32       AutoLeadTime:8;
-               UINT32       NumofSleepingTbtt:7;          // ForceWake has high privilege than PutToSleep when both set
-               UINT32          EnableAutoWakeup:1;     // 0:sleep, 1:awake
-               UINT32          :16;
-       }       field;
-       UINT32                  word;
-}      AUTO_WAKEUP_STRUC, *PAUTO_WAKEUP_STRUC;
-
-//
-//  4.3 MAC TX  configuration registers (offset:0x1300)
-//
-
-#define EDCA_AC0_CFG   0x1300          //AC_TXOP_CSR0 0x3474
-#define EDCA_AC1_CFG   0x1304
-#define EDCA_AC2_CFG   0x1308
-#define EDCA_AC3_CFG   0x130c
-typedef        union   _EDCA_AC_CFG_STRUC      {
-       struct  {
-           UINT32  AcTxop:8;        //  in unit of 32us
-           UINT32  Aifsn:4;        // # of slot time
-           UINT32  Cwmin:4;        //
-           UINT32  Cwmax:4;        //unit power of 2
-           UINT32  :12;       //
-       }       field;
-       UINT32                  word;
-}      EDCA_AC_CFG_STRUC, *PEDCA_AC_CFG_STRUC;
-
-#define EDCA_TID_AC_MAP        0x1310
-#define TX_PWR_CFG_0   0x1314
-#define TX_PWR_CFG_1   0x1318
-#define TX_PWR_CFG_2   0x131C
-#define TX_PWR_CFG_3   0x1320
-#define TX_PWR_CFG_4   0x1324
-#define TX_PIN_CFG             0x1328
-#define TX_BAND_CFG    0x132c          // 0x1 use upper 20MHz. 0 juse lower 20MHz
-#define TX_SW_CFG0             0x1330
-#define TX_SW_CFG1             0x1334
-#define TX_SW_CFG2             0x1338
-#define TXOP_THRES_CFG         0x133c
-#define TXOP_CTRL_CFG          0x1340
-#define TX_RTS_CFG             0x1344
-
-typedef        union   _TX_RTS_CFG_STRUC       {
-       struct  {
-           UINT32       AutoRtsRetryLimit:8;
-           UINT32       RtsThres:16;    // unit:byte
-           UINT32       RtsFbkEn:1;    // enable rts rate fallback
-           UINT32       rsv:7;     // 1: HT non-STBC control frame enable
-       }       field;
-       UINT32                  word;
-}      TX_RTS_CFG_STRUC, *PTX_RTS_CFG_STRUC;
-
-#define TX_TIMEOUT_CFG 0x1348
-typedef        union   _TX_TIMEOUT_CFG_STRUC   {
-       struct  {
-           UINT32       rsv:4;
-           UINT32       MpduLifeTime:4;    //  expiration time = 2^(9+MPDU LIFE TIME)  us
-           UINT32       RxAckTimeout:8;        // unit:slot. Used for TX precedure
-           UINT32       TxopTimeout:8; //TXOP timeout value for TXOP truncation.  It is recommended that (SLOT_TIME) > (TX_OP_TIMEOUT) > (RX_ACK_TIMEOUT)
-           UINT32       rsv2:8;     // 1: HT non-STBC control frame enable
-       }       field;
-       UINT32                  word;
-}      TX_TIMEOUT_CFG_STRUC, *PTX_TIMEOUT_CFG_STRUC;
-
-#define TX_RTY_CFG     0x134c
-typedef        union PACKED _TX_RTY_CFG_STRUC  {
-       struct  {
-           UINT32       ShortRtyLimit:8;       //  short retry limit
-           UINT32       LongRtyLimit:8;        //long retry limit
-           UINT32       LongRtyThre:12;        // Long retry threshoold
-           UINT32       NonAggRtyMode:1;       // Non-Aggregate MPDU retry mode.  0:expired by retry limit, 1: expired by mpdu life timer
-           UINT32       AggRtyMode:1;  // Aggregate MPDU retry mode.  0:expired by retry limit, 1: expired by mpdu life timer
-           UINT32       TxautoFBEnable:1;    // Tx retry PHY rate auto fallback enable
-           UINT32       rsv:1;     // 1: HT non-STBC control frame enable
-       }       field;
-       UINT32                  word;
-}      TX_RTY_CFG_STRUC, *PTX_RTY_CFG_STRUC;
-
-#define TX_LINK_CFG    0x1350
-typedef        union   PACKED _TX_LINK_CFG_STRUC       {
-       struct PACKED {
-           UINT32       RemoteMFBLifeTime:8;   //remote MFB life time. unit : 32us
-           UINT32       MFBEnable:1;   //  TX apply remote MFB 1:enable
-           UINT32       RemoteUMFSEnable:1;    //  remote unsolicit  MFB enable.  0: not apply remote remote unsolicit (MFS=7)
-           UINT32       TxMRQEn:1;     //  MCS request TX enable
-           UINT32       TxRDGEn:1;     // RDG TX enable
-           UINT32       TxCFAckEn:1;   //   Piggyback CF-ACK enable
-           UINT32       rsv:3; //
-           UINT32       RemotMFB:8;    //  remote MCS feedback
-           UINT32       RemotMFS:8;    //remote MCS feedback sequence number
-       }       field;
-       UINT32                  word;
-}      TX_LINK_CFG_STRUC, *PTX_LINK_CFG_STRUC;
-
-#define HT_FBK_CFG0    0x1354
-typedef        union PACKED _HT_FBK_CFG0_STRUC {
-       struct  {
-           UINT32       HTMCS0FBK:4;
-           UINT32       HTMCS1FBK:4;
-           UINT32       HTMCS2FBK:4;
-           UINT32       HTMCS3FBK:4;
-           UINT32       HTMCS4FBK:4;
-           UINT32       HTMCS5FBK:4;
-           UINT32       HTMCS6FBK:4;
-           UINT32       HTMCS7FBK:4;
-       }       field;
-       UINT32                  word;
-}      HT_FBK_CFG0_STRUC, *PHT_FBK_CFG0_STRUC;
-
-#define HT_FBK_CFG1    0x1358
-typedef        union   _HT_FBK_CFG1_STRUC      {
-       struct  {
-           UINT32       HTMCS8FBK:4;
-           UINT32       HTMCS9FBK:4;
-           UINT32       HTMCS10FBK:4;
-           UINT32       HTMCS11FBK:4;
-           UINT32       HTMCS12FBK:4;
-           UINT32       HTMCS13FBK:4;
-           UINT32       HTMCS14FBK:4;
-           UINT32       HTMCS15FBK:4;
-       }       field;
-       UINT32                  word;
-}      HT_FBK_CFG1_STRUC, *PHT_FBK_CFG1_STRUC;
-
-#define LG_FBK_CFG0    0x135c
-typedef        union   _LG_FBK_CFG0_STRUC      {
-       struct  {
-           UINT32       OFDMMCS0FBK:4; //initial value is 0
-           UINT32       OFDMMCS1FBK:4; //initial value is 0
-           UINT32       OFDMMCS2FBK:4; //initial value is 1
-           UINT32       OFDMMCS3FBK:4; //initial value is 2
-           UINT32       OFDMMCS4FBK:4; //initial value is 3
-           UINT32       OFDMMCS5FBK:4; //initial value is 4
-           UINT32       OFDMMCS6FBK:4; //initial value is 5
-           UINT32       OFDMMCS7FBK:4; //initial value is 6
-       }       field;
-       UINT32                  word;
-}      LG_FBK_CFG0_STRUC, *PLG_FBK_CFG0_STRUC;
-
-#define LG_FBK_CFG1            0x1360
-typedef        union   _LG_FBK_CFG1_STRUC      {
-       struct  {
-           UINT32       CCKMCS0FBK:4;  //initial value is 0
-           UINT32       CCKMCS1FBK:4;  //initial value is 0
-           UINT32       CCKMCS2FBK:4;  //initial value is 1
-           UINT32       CCKMCS3FBK:4;  //initial value is 2
-           UINT32       rsv:16;
-       }       field;
-       UINT32                  word;
-}      LG_FBK_CFG1_STRUC, *PLG_FBK_CFG1_STRUC;
-
-//=======================================================
-//================ Protection Paramater================================
-//=======================================================
-#define CCK_PROT_CFG   0x1364          //CCK Protection
-#define ASIC_SHORTNAV          1
-#define ASIC_LONGNAV           2
-#define ASIC_RTS               1
-#define ASIC_CTS               2
-typedef        union   _PROT_CFG_STRUC {
-       struct  {
-           UINT32       ProtectRate:16;        //Protection control frame rate for CCK TX(RTS/CTS/CFEnd).
-           UINT32       ProtectCtrl:2; //Protection control frame type for CCK TX. 1:RTS/CTS, 2:CTS-to-self, 0:None, 3:rsv
-           UINT32       ProtectNav:2;  //TXOP protection type for CCK TX. 0:None, 1:ShortNAVprotect,  2:LongNAVProtect, 3:rsv
-           UINT32       TxopAllowCck:1;        //CCK TXOP allowance.0:disallow.
-           UINT32       TxopAllowOfdm:1;       //CCK TXOP allowance.0:disallow.
-           UINT32       TxopAllowMM20:1;       //CCK TXOP allowance. 0:disallow.
-           UINT32       TxopAllowMM40:1;       //CCK TXOP allowance.0:disallow.
-           UINT32       TxopAllowGF20:1;       //CCK TXOP allowance.0:disallow.
-           UINT32       TxopAllowGF40:1;       //CCK TXOP allowance.0:disallow.
-           UINT32       RTSThEn:1;     //RTS threshold enable on CCK TX
-           UINT32       rsv:5;
-       }       field;
-       UINT32                  word;
-}      PROT_CFG_STRUC, *PPROT_CFG_STRUC;
-
-#define OFDM_PROT_CFG  0x1368          //OFDM Protection
-#define MM20_PROT_CFG  0x136C          //MM20 Protection
-#define MM40_PROT_CFG  0x1370          //MM40 Protection
-#define GF20_PROT_CFG  0x1374          //GF20 Protection
-#define GF40_PROT_CFG  0x1378          //GR40 Protection
-#define EXP_CTS_TIME   0x137C          //
-#define EXP_ACK_TIME   0x1380          //
-
-//
-//  4.4 MAC RX configuration registers (offset:0x1400)
-//
-#define RX_FILTR_CFG   0x1400                  //TXRX_CSR0
-#define AUTO_RSP_CFG   0x1404                  //TXRX_CSR4
-//
-// TXRX_CSR4: Auto-Responder/
-//
-typedef union _AUTO_RSP_CFG_STRUC {
- struct {
-     UINT32       AutoResponderEnable:1;
-     UINT32       BACAckPolicyEnable:1;    // 0:long, 1:short preamble
-     UINT32       CTS40MMode:1;  // Response CTS 40MHz duplicate mode
-     UINT32       CTS40MRef:1;  // Response CTS 40MHz duplicate mode
-     UINT32       AutoResponderPreamble:1;    // 0:long, 1:short preamble
-     UINT32       rsv:1;   // Power bit value in conrtrol frame
-     UINT32       DualCTSEn:1;   // Power bit value in conrtrol frame
-     UINT32       AckCtsPsmBit:1;   // Power bit value in conrtrol frame
-     UINT32        :24;
- } field;
- UINT32   word;
-} AUTO_RSP_CFG_STRUC, *PAUTO_RSP_CFG_STRUC;
-
-#define LEGACY_BASIC_RATE      0x1408  //  TXRX_CSR5           0x3054
-#define HT_BASIC_RATE          0x140c
-#define HT_CTRL_CFG            0x1410
-#define SIFS_COST_CFG          0x1414
-#define RX_PARSER_CFG          0x1418  //Set NAV for all received frames
-
-//
-//  4.5 MAC Security configuration (offset:0x1500)
-//
-#define TX_SEC_CNT0            0x1500          //
-#define RX_SEC_CNT0            0x1504          //
-#define CCMP_FC_MUTE           0x1508          //
-//
-//  4.6 HCCA/PSMP (offset:0x1600)
-//
-#define TXOP_HLDR_ADDR0                0x1600
-#define TXOP_HLDR_ADDR1                0x1604
-#define TXOP_HLDR_ET           0x1608
-#define QOS_CFPOLL_RA_DW0              0x160c
-#define QOS_CFPOLL_A1_DW1              0x1610
-#define QOS_CFPOLL_QC          0x1614
-//
-//  4.7 MAC Statistis registers (offset:0x1700)
-//
-#define RX_STA_CNT0            0x1700          //
-#define RX_STA_CNT1            0x1704          //
-#define RX_STA_CNT2            0x1708          //
-
-//
-// RX_STA_CNT0_STRUC: RX PLCP error count & RX CRC error count
-//
-typedef        union   _RX_STA_CNT0_STRUC      {
-       struct  {
-           USHORT  CrcErr;
-           USHORT  PhyErr;
-       }       field;
-       UINT32                  word;
-}      RX_STA_CNT0_STRUC, *PRX_STA_CNT0_STRUC;
-
-//
-// RX_STA_CNT1_STRUC: RX False CCA count & RX LONG frame count
-//
-typedef        union   _RX_STA_CNT1_STRUC      {
-       struct  {
-           USHORT  FalseCca;
-           USHORT  PlcpErr;
-       }       field;
-       UINT32                  word;
-}      RX_STA_CNT1_STRUC, *PRX_STA_CNT1_STRUC;
-
-//
-// RX_STA_CNT2_STRUC:
-//
-typedef        union   _RX_STA_CNT2_STRUC      {
-       struct  {
-           USHORT  RxDupliCount;
-           USHORT  RxFifoOverflowCount;
-       }       field;
-       UINT32                  word;
-}      RX_STA_CNT2_STRUC, *PRX_STA_CNT2_STRUC;
-
-#define TX_STA_CNT0            0x170C          //
-//
-// STA_CSR3: TX Beacon count
-//
-typedef        union   _TX_STA_CNT0_STRUC      {
-       struct  {
-           USHORT  TxFailCount;
-           USHORT  TxBeaconCount;
-       }       field;
-       UINT32                  word;
-}      TX_STA_CNT0_STRUC, *PTX_STA_CNT0_STRUC;
-
-#define TX_STA_CNT1            0x1710          //
-//
-// TX_STA_CNT1: TX tx count
-//
-typedef        union   _TX_STA_CNT1_STRUC      {
-       struct  {
-           USHORT  TxSuccess;
-           USHORT  TxRetransmit;
-       }       field;
-       UINT32                  word;
-}      TX_STA_CNT1_STRUC, *PTX_STA_CNT1_STRUC;
-
-#define TX_STA_CNT2            0x1714          //
-//
-// TX_STA_CNT2: TX tx count
-//
-typedef        union   _TX_STA_CNT2_STRUC      {
-       struct  {
-           USHORT  TxZeroLenCount;
-           USHORT  TxUnderFlowCount;
-       }       field;
-       UINT32                  word;
-}      TX_STA_CNT2_STRUC, *PTX_STA_CNT2_STRUC;
-
-#define TX_STA_FIFO            0x1718          //
-//
-// TX_STA_FIFO_STRUC: TX Result for specific PID status fifo register
-//
-typedef        union PACKED _TX_STA_FIFO_STRUC {
-       struct  {
-               UINT32          bValid:1;   // 1:This register contains a valid TX result
-               UINT32          PidType:4;
-               UINT32          TxSuccess:1;   // Tx No retry success
-               UINT32          TxAggre:1;    // Tx Retry Success
-               UINT32          TxAckRequired:1;    // Tx fail
-               UINT32          wcid:8;         //wireless client index
-//             UINT32          SuccessRate:16; //include MCS, mode ,shortGI, BW settingSame format as TXWI Word 0 Bit 31-16.
-               UINT32          SuccessRate:13; //include MCS, mode ,shortGI, BW settingSame format as TXWI Word 0 Bit 31-16.
-               UINT32          TxBF:1;
-               UINT32          Reserve:2;
-       }       field;
-       UINT32                  word;
-}      TX_STA_FIFO_STRUC, *PTX_STA_FIFO_STRUC;
-
-// Debug counter
-#define TX_AGG_CNT     0x171c
-typedef        union   _TX_AGG_CNT_STRUC       {
-       struct  {
-           USHORT  NonAggTxCount;
-           USHORT  AggTxCount;
-       }       field;
-       UINT32                  word;
-}      TX_AGG_CNT_STRUC, *PTX_AGG_CNT_STRUC;
-
-// Debug counter
-#define TX_AGG_CNT0    0x1720
-typedef        union   _TX_AGG_CNT0_STRUC      {
-       struct  {
-           USHORT  AggSize1Count;
-           USHORT  AggSize2Count;
-       }       field;
-       UINT32                  word;
-}      TX_AGG_CNT0_STRUC, *PTX_AGG_CNT0_STRUC;
-
-// Debug counter
-#define TX_AGG_CNT1    0x1724
-typedef        union   _TX_AGG_CNT1_STRUC      {
-       struct  {
-           USHORT  AggSize3Count;
-           USHORT  AggSize4Count;
-       }       field;
-       UINT32                  word;
-}      TX_AGG_CNT1_STRUC, *PTX_AGG_CNT1_STRUC;
-
-#define TX_AGG_CNT2    0x1728
-typedef        union   _TX_AGG_CNT2_STRUC      {
-       struct  {
-           USHORT  AggSize5Count;
-           USHORT  AggSize6Count;
-       }       field;
-       UINT32                  word;
-}      TX_AGG_CNT2_STRUC, *PTX_AGG_CNT2_STRUC;
-
-// Debug counter
-#define TX_AGG_CNT3    0x172c
-typedef        union   _TX_AGG_CNT3_STRUC      {
-       struct  {
-           USHORT  AggSize7Count;
-           USHORT  AggSize8Count;
-       }       field;
-       UINT32                  word;
-}      TX_AGG_CNT3_STRUC, *PTX_AGG_CNT3_STRUC;
-
-// Debug counter
-#define TX_AGG_CNT4    0x1730
-typedef        union   _TX_AGG_CNT4_STRUC      {
-       struct  {
-           USHORT  AggSize9Count;
-           USHORT  AggSize10Count;
-       }       field;
-       UINT32                  word;
-}      TX_AGG_CNT4_STRUC, *PTX_AGG_CNT4_STRUC;
-
-#define TX_AGG_CNT5    0x1734
-typedef        union   _TX_AGG_CNT5_STRUC      {
-       struct  {
-           USHORT  AggSize11Count;
-           USHORT  AggSize12Count;
-       }       field;
-       UINT32                  word;
-}      TX_AGG_CNT5_STRUC, *PTX_AGG_CNT5_STRUC;
-
-#define TX_AGG_CNT6            0x1738
-typedef        union   _TX_AGG_CNT6_STRUC      {
-       struct  {
-           USHORT  AggSize13Count;
-           USHORT  AggSize14Count;
-       }       field;
-       UINT32                  word;
-}      TX_AGG_CNT6_STRUC, *PTX_AGG_CNT6_STRUC;
-
-#define TX_AGG_CNT7            0x173c
-typedef        union   _TX_AGG_CNT7_STRUC      {
-       struct  {
-           USHORT  AggSize15Count;
-           USHORT  AggSize16Count;
-       }       field;
-       UINT32                  word;
-}      TX_AGG_CNT7_STRUC, *PTX_AGG_CNT7_STRUC;
-
-#define MPDU_DENSITY_CNT               0x1740
-typedef        union   _MPDU_DEN_CNT_STRUC     {
-       struct  {
-           USHORT  TXZeroDelCount;     //TX zero length delimiter count
-           USHORT  RXZeroDelCount;     //RX zero length delimiter count
-       }       field;
-       UINT32                  word;
-}      MPDU_DEN_CNT_STRUC, *PMPDU_DEN_CNT_STRUC;
-
-//
-// TXRX control registers - base address 0x3000
-//
-// rt2860b  UNKNOWN reg use R/O Reg Addr 0x77d0 first..
-#define TXRX_CSR1           0x77d0
-
-//
-// Security key table memory, base address = 0x1000
-//
-#define MAC_WCID_BASE          0x1800 //8-bytes(use only 6-bytes) * 256 entry =
-#define HW_WCID_ENTRY_SIZE   8
-#define PAIRWISE_KEY_TABLE_BASE     0x4000      // 32-byte * 256-entry =  -byte
-#define HW_KEY_ENTRY_SIZE           0x20
-#define PAIRWISE_IVEIV_TABLE_BASE     0x6000      // 8-byte * 256-entry =  -byte
-#define MAC_IVEIV_TABLE_BASE     0x6000      // 8-byte * 256-entry =  -byte
-#define HW_IVEIV_ENTRY_SIZE   8
-#define MAC_WCID_ATTRIBUTE_BASE     0x6800      // 4-byte * 256-entry =  -byte
-#define HW_WCID_ATTRI_SIZE   4
-#define WCID_RESERVED                          0x6bfc
-#define SHARED_KEY_TABLE_BASE       0x6c00      // 32-byte * 16-entry = 512-byte
-#define SHARED_KEY_MODE_BASE       0x7000      // 32-byte * 16-entry = 512-byte
-#define HW_SHARED_KEY_MODE_SIZE   4
-#define SHAREDKEYTABLE                 0
-#define PAIRWISEKEYTABLE                       1
-
-typedef        union   _SHAREDKEY_MODE_STRUC   {
-       struct  {
-               UINT32       Bss0Key0CipherAlg:3;
-               UINT32       :1;
-               UINT32       Bss0Key1CipherAlg:3;
-               UINT32       :1;
-               UINT32       Bss0Key2CipherAlg:3;
-               UINT32       :1;
-               UINT32       Bss0Key3CipherAlg:3;
-               UINT32       :1;
-               UINT32       Bss1Key0CipherAlg:3;
-               UINT32       :1;
-               UINT32       Bss1Key1CipherAlg:3;
-               UINT32       :1;
-               UINT32       Bss1Key2CipherAlg:3;
-               UINT32       :1;
-               UINT32       Bss1Key3CipherAlg:3;
-               UINT32       :1;
-       }       field;
-       UINT32                  word;
-}      SHAREDKEY_MODE_STRUC, *PSHAREDKEY_MODE_STRUC;
-
-// 64-entry for pairwise key table
-typedef struct _HW_WCID_ENTRY {  // 8-byte per entry
-    UCHAR   Address[6];
-    UCHAR   Rsv[2];
-} HW_WCID_ENTRY, PHW_WCID_ENTRY;
-
-
-
-//
-// Other on-chip shared memory space, base = 0x2000
-//
-
-// CIS space - base address = 0x2000
-#define HW_CIS_BASE             0x2000
-
-// Carrier-sense CTS frame base address. It's where mac stores carrier-sense frame for carrier-sense function.
-#define HW_CS_CTS_BASE                 0x7700
-// DFS CTS frame base address. It's where mac stores CTS frame for DFS.
-#define HW_DFS_CTS_BASE                        0x7780
-#define HW_CTS_FRAME_SIZE              0x80
-
-// 2004-11-08 john - since NULL frame won't be that long (256 byte). We steal 16 tail bytes
-// to save debugging settings
-#define HW_DEBUG_SETTING_BASE   0x77f0  // 0x77f0~0x77ff total 16 bytes
-#define HW_DEBUG_SETTING_BASE2   0x7770  // 0x77f0~0x77ff total 16 bytes
-
-// In order to support maximum 8 MBSS and its maximum length is 512 for each beacon
-// Three section discontinue memory segments will be used.
-// 1. The original region for BCN 0~3
-// 2. Extract memory from FCE table for BCN 4~5
-// 3. Extract memory from Pair-wise key table for BCN 6~7
-//       It occupied those memory of wcid 238~253 for BCN 6
-//                                                   and wcid 222~237 for BCN 7
-#define HW_BEACON_MAX_SIZE      0x1000 /* unit: byte */
-#define HW_BEACON_BASE0         0x7800
-#define HW_BEACON_BASE1         0x7A00
-#define HW_BEACON_BASE2         0x7C00
-#define HW_BEACON_BASE3         0x7E00
-#define HW_BEACON_BASE4         0x7200
-#define HW_BEACON_BASE5         0x7400
-#define HW_BEACON_BASE6         0x5DC0
-#define HW_BEACON_BASE7         0x5BC0
-
-#define HW_BEACON_MAX_COUNT     8
-#define HW_BEACON_OFFSET               0x0200
-#define HW_BEACON_CONTENT_LEN  (HW_BEACON_OFFSET - TXWI_SIZE)
-
-// HOST-MCU shared memory - base address = 0x2100
-#define HOST_CMD_CSR           0x404
-#define H2M_MAILBOX_CSR         0x7010
-#define H2M_MAILBOX_CID         0x7014
-#define H2M_MAILBOX_STATUS      0x701c
-#define H2M_INT_SRC             0x7024
-#define H2M_BBP_AGENT           0x7028
-#define M2H_CMD_DONE_CSR        0x000c
-#define MCU_TXOP_ARRAY_BASE     0x000c   // TODO: to be provided by Albert
-#define MCU_TXOP_ENTRY_SIZE     32       // TODO: to be provided by Albert
-#define MAX_NUM_OF_TXOP_ENTRY   16       // TODO: must be same with 8051 firmware
-#define MCU_MBOX_VERSION        0x01     // TODO: to be confirmed by Albert
-#define MCU_MBOX_VERSION_OFFSET 5        // TODO: to be provided by Albert
-
-//
-// Host DMA registers - base address 0x200 .  TX0-3=EDCAQid0-3, TX4=HCCA, TX5=MGMT,
-//
-//
-//  DMA RING DESCRIPTOR
-//
-#define E2PROM_CSR          0x0004
-#define IO_CNTL_CSR         0x77d0
-
-#ifdef RT2870
-// 8051 firmware image for usb - use last-half base address = 0x3000
-#define FIRMWARE_IMAGE_BASE     0x3000
-#define MAX_FIRMWARE_IMAGE_SIZE 0x1000    // 4kbyte
-#endif // RT2870 //
-
-// ================================================================
-// Tx /        Rx / Mgmt ring descriptor definition
-// ================================================================
-
-// the following PID values are used to mark outgoing frame type in TXD->PID so that
-// proper TX statistics can be collected based on these categories
-// b3-2 of PID field -
-#define PID_MGMT                       0x05
-#define PID_BEACON                     0x0c
-#define PID_DATA_NORMALUCAST           0x02
-#define PID_DATA_AMPDU         0x04
-#define PID_DATA_NO_ACK        0x08
-#define PID_DATA_NOT_NORM_ACK          0x03
-// value domain of pTxD->HostQId (4-bit: 0~15)
-#define QID_AC_BK               1   // meet ACI definition in 802.11e
-#define QID_AC_BE               0   // meet ACI definition in 802.11e
-#define QID_AC_VI               2
-#define QID_AC_VO               3
-#define QID_HCCA                4
-#define NUM_OF_TX_RING          5
-#define QID_MGMT                13
-#define QID_RX                  14
-#define QID_OTHER               15
-
-
-// ------------------------------------------------------
-// BBP & RF    definition
-// ------------------------------------------------------
-#define        BUSY                            1
-#define        IDLE                            0
-
-#define        RF_R00                                      0
-#define        RF_R01                                      1
-#define        RF_R02                                      2
-#define        RF_R03                                      3
-#define        RF_R04                                      4
-#define        RF_R05                                      5
-#define        RF_R06                                      6
-#define        RF_R07                                      7
-#define        RF_R08                                      8
-#define        RF_R09                                      9
-#define        RF_R10                                      10
-#define        RF_R11                                      11
-#define        RF_R12                                      12
-#define        RF_R13                                      13
-#define        RF_R14                                      14
-#define        RF_R15                                      15
-#define        RF_R16                                      16
-#define        RF_R17                                      17
-#define        RF_R18                                      18
-#define        RF_R19                                      19
-#define        RF_R20                                      20
-#define        RF_R21                                      21
-#define        RF_R22                                      22
-#define        RF_R23                                      23
-#define        RF_R24                                      24
-#define        RF_R25                                      25
-#define        RF_R26                                      26
-#define        RF_R27                                      27
-#define        RF_R28                                      28
-#define        RF_R29                                      29
-#define        RF_R30                                      30
-#define        RF_R31                                      31
-
-#define        BBP_R0                                      0  // version
-#define        BBP_R1                                  1  // TSSI
-#define        BBP_R2                                  2  // TX configure
-#define BBP_R3                      3
-#define BBP_R4                      4
-#define BBP_R5                      5
-#define BBP_R6                      6
-#define        BBP_R14                             14 // RX configure
-#define BBP_R16                     16
-#define BBP_R17                     17 // RX sensibility
-#define BBP_R18                     18
-#define BBP_R21                     21
-#define BBP_R22                     22
-#define BBP_R24                     24
-#define BBP_R25                     25
-#define BBP_R31                     31
-#define BBP_R49                     49 //TSSI
-#define BBP_R50                     50
-#define BBP_R51                     51
-#define BBP_R52                     52
-#define BBP_R55                     55
-#define BBP_R62                     62 // Rx SQ0 Threshold HIGH
-#define BBP_R63                     63
-#define BBP_R64                     64
-#define BBP_R65                     65
-#define BBP_R66                     66
-#define BBP_R67                     67
-#define BBP_R68                     68
-#define BBP_R69                     69
-#define BBP_R70                     70 // Rx AGC SQ CCK Xcorr threshold
-#define BBP_R73                     73
-#define BBP_R75                                                75
-#define BBP_R77                     77
-#define BBP_R79                     79
-#define BBP_R80                     80
-#define BBP_R81                     81
-#define BBP_R82                     82
-#define BBP_R83                     83
-#define BBP_R84                     84
-#define BBP_R86                                                86
-#define BBP_R91                                                91
-#define BBP_R92                                                92
-#define BBP_R94                     94 // Tx Gain Control
-#define BBP_R103                    103
-#define BBP_R105                    105
-#define BBP_R113                    113
-#define BBP_R114                    114
-#define BBP_R115                    115
-#define BBP_R116                    116
-#define BBP_R117                    117
-#define BBP_R118                    118
-#define BBP_R119                    119
-#define BBP_R120                    120
-#define BBP_R121                    121
-#define BBP_R122                    122
-#define BBP_R123                    123
-#ifdef RT30xx
-#define BBP_R138                    138 // add by johnli, RF power sequence setup, ADC dynamic on/off control
-#endif // RT30xx //
-
-
-#define BBPR94_DEFAULT              0x06 // Add 1 value will gain 1db
-
-#define RSSI_FOR_VERY_LOW_SENSIBILITY -35
-#define RSSI_FOR_LOW_SENSIBILITY      -58
-#define RSSI_FOR_MID_LOW_SENSIBILITY  -80
-#define RSSI_FOR_MID_SENSIBILITY      -90
-
-//-------------------------------------------------------------------------
-// EEPROM definition
-//-------------------------------------------------------------------------
-#define EEDO                        0x08
-#define EEDI                        0x04
-#define EECS                        0x02
-#define EESK                        0x01
-#define EERL                        0x80
-
-#define EEPROM_WRITE_OPCODE         0x05
-#define EEPROM_READ_OPCODE          0x06
-#define EEPROM_EWDS_OPCODE          0x10
-#define EEPROM_EWEN_OPCODE          0x13
-
-#define        NUM_EEPROM_BBP_PARMS            19                      // Include NIC Config 0, 1, CR, TX ALC step, BBPs
-#define        NUM_EEPROM_TX_G_PARMS           7
-#define        EEPROM_NIC1_OFFSET          0x34                // The address is from NIC config 0, not BBP register ID
-#define        EEPROM_NIC2_OFFSET          0x36                // The address is from NIC config 0, not BBP register ID
-#define        EEPROM_BBP_BASE_OFFSET          0xf0            // The address is from NIC config 0, not BBP register ID
-#define        EEPROM_G_TX_PWR_OFFSET          0x52
-#define        EEPROM_G_TX2_PWR_OFFSET         0x60
-#define EEPROM_LED1_OFFSET                     0x3c
-#define EEPROM_LED2_OFFSET                     0x3e
-#define EEPROM_LED3_OFFSET                     0x40
-#define EEPROM_LNA_OFFSET                      0x44
-#define EEPROM_RSSI_BG_OFFSET          0x46
-#define EEPROM_RSSI_A_OFFSET           0x4a
-#define EEPROM_DEFINE_MAX_TXPWR                0x4e
-#define EEPROM_TXPOWER_BYRATE_20MHZ_2_4G       0xde    // 20MHZ 2.4G tx power.
-#define EEPROM_TXPOWER_BYRATE_40MHZ_2_4G       0xee    // 40MHZ 2.4G tx power.
-#define EEPROM_TXPOWER_BYRATE_20MHZ_5G         0xfa    // 20MHZ 5G tx power.
-#define EEPROM_TXPOWER_BYRATE_40MHZ_5G         0x10a   // 40MHZ 5G tx power.
-#define EEPROM_A_TX_PWR_OFFSET      0x78
-#define EEPROM_A_TX2_PWR_OFFSET      0xa6
-#define EEPROM_VERSION_OFFSET       0x02
-#define        EEPROM_FREQ_OFFSET                      0x3a
-#define EEPROM_TXPOWER_BYRATE  0xde    // 20MHZ power.
-#define EEPROM_TXPOWER_DELTA           0x50    // 20MHZ AND 40 MHZ use different power. This is delta in 40MHZ.
-#define VALID_EEPROM_VERSION        1
-
-// PairKeyMode definition
-#define PKMODE_NONE                 0
-#define PKMODE_WEP64                1
-#define PKMODE_WEP128               2
-#define PKMODE_TKIP                 3
-#define PKMODE_AES                  4
-#define PKMODE_CKIP64               5
-#define PKMODE_CKIP128              6
-#define PKMODE_TKIP_NO_MIC          7       // MIC appended by driver: not a valid value in hardware key table
-
-// =================================================================================
-// WCID  format
-// =================================================================================
-//7.1  WCID  ENTRY  format  : 8bytes
-typedef        struct  _WCID_ENTRY_STRUC {
-       UCHAR           RXBABitmap7;    // bit0 for TID8, bit7 for TID 15
-       UCHAR           RXBABitmap0;    // bit0 for TID0, bit7 for TID 7
-       UCHAR           MAC[6]; // 0 for shared key table.  1 for pairwise key table
-}      WCID_ENTRY_STRUC, *PWCID_ENTRY_STRUC;
-
-//8.1.1        SECURITY  KEY  format  : 8DW
-// 32-byte per entry, total 16-entry for shared key table, 64-entry for pairwise key table
-typedef struct _HW_KEY_ENTRY {          // 32-byte per entry
-    UCHAR   Key[16];
-    UCHAR   TxMic[8];
-    UCHAR   RxMic[8];
-} HW_KEY_ENTRY, *PHW_KEY_ENTRY;
-
-//8.1.2        IV/EIV  format  : 2DW
-
-//8.1.3        RX attribute entry format  : 1DW
-typedef        struct  _MAC_ATTRIBUTE_STRUC {
-       UINT32          KeyTab:1;       // 0 for shared key table.  1 for pairwise key table
-       UINT32          PairKeyMode:3;
-       UINT32          BSSIDIdx:3; //multipleBSS index for the WCID
-       UINT32          RXWIUDF:3;
-       UINT32          rsv:22;
-}      MAC_ATTRIBUTE_STRUC, *PMAC_ATTRIBUTE_STRUC;
-
-// =================================================================================
-// TX / RX ring descriptor format
-// =================================================================================
-
-// the first 24-byte in TXD is called TXINFO and will be DMAed to MAC block through TXFIFO.
-// MAC block use this TXINFO to control the transmission behavior of this frame.
-#define FIFO_MGMT                 0
-#define FIFO_HCCA                 1
-#define FIFO_EDCA                 2
-
-//
-// TX descriptor format, Tx    ring, Mgmt Ring
-//
-typedef        struct  PACKED _TXD_STRUC {
-       // Word 0
-       UINT32          SDPtr0;
-       // Word 1
-       UINT32          SDLen1:14;
-       UINT32          LastSec1:1;
-       UINT32          Burst:1;
-       UINT32          SDLen0:14;
-       UINT32          LastSec0:1;
-       UINT32          DMADONE:1;
-       //Word2
-       UINT32          SDPtr1;
-       //Word3
-       UINT32          rsv2:24;
-       UINT32          WIV:1;  // Wireless Info Valid. 1 if Driver already fill WI,  o if DMA needs to copy WI to correctposition
-       UINT32          QSEL:2; // select on-chip FIFO ID for 2nd-stage output scheduler.0:MGMT, 1:HCCA 2:EDCA
-       UINT32          rsv:2;
-       UINT32          TCO:1;  //
-       UINT32          UCO:1;  //
-       UINT32          ICO:1;  //
-}      TXD_STRUC, *PTXD_STRUC;
-
-//
-// TXD Wireless Information format for Tx ring and Mgmt Ring
-//
-//txop : for txop mode
-// 0:txop for the MPDU frame will be handles by ASIC by register
-// 1/2/3:the MPDU frame is send after PIFS/backoff/SIFS
-typedef        struct  PACKED _TXWI_STRUC {
-       // Word 0
-       UINT32          FRAG:1;         // 1 to inform TKIP engine this is a fragment.
-       UINT32          MIMOps:1;       // the remote peer is in dynamic MIMO-PS mode
-       UINT32          CFACK:1;
-       UINT32          TS:1;
-
-       UINT32          AMPDU:1;
-       UINT32          MpduDensity:3;
-       UINT32          txop:2; //FOR "THIS" frame. 0:HT TXOP rule , 1:PIFS TX ,2:Backoff, 3:sifs only when previous frame exchange is successful.
-       UINT32          rsv:6;
-
-       UINT32          MCS:7;
-       UINT32          BW:1;   //channel bandwidth 20MHz or 40 MHz
-       UINT32          ShortGI:1;
-       UINT32          STBC:2; // 1: STBC support MCS =0-7,   2,3 : RESERVE
-       UINT32          Ifs:1;  //
-       UINT32          rsv2:1;
-       UINT32          TxBF:1; // 3*3
-       UINT32          PHYMODE:2;
-       // Word 1
-       UINT32          ACK:1;
-       UINT32          NSEQ:1;
-       UINT32          BAWinSize:6;
-       UINT32          WirelessCliID:8;
-       UINT32          MPDUtotalByteCount:12;
-       UINT32          PacketId:4;
-       //Word2
-       UINT32          IV;
-       //Word3
-       UINT32          EIV;
-}      TXWI_STRUC, *PTXWI_STRUC;
-
-//
-// Rx descriptor format, Rx    Ring
-//
-//
-// RXWI wireless information format, in PBF. invisible in driver.
-//
-typedef        struct  PACKED _RXWI_STRUC {
-       // Word 0
-       UINT32          WirelessCliID:8;
-       UINT32          KeyIndex:2;
-       UINT32          BSSID:3;
-       UINT32          UDF:3;
-       UINT32          MPDUtotalByteCount:12;
-       UINT32          TID:4;
-       // Word 1
-       UINT32          FRAG:4;
-       UINT32          SEQUENCE:12;
-       UINT32          MCS:7;
-       UINT32          BW:1;
-       UINT32          ShortGI:1;
-       UINT32          STBC:2;
-       UINT32          rsv:3;
-       UINT32          PHYMODE:2;              // 1: this RX frame is unicast to me
-       //Word2
-       UINT32          RSSI0:8;
-       UINT32          RSSI1:8;
-       UINT32          RSSI2:8;
-       UINT32          rsv1:8;
-       //Word3
-       UINT32          SNR0:8;
-       UINT32          SNR1:8;
-       UINT32          rsv2:16;
-}      RXWI_STRUC, *PRXWI_STRUC;
-
-// =================================================================================
-// HOST-MCU communication data structure
-// =================================================================================
-
-//
-// H2M_MAILBOX_CSR: Host-to-MCU Mailbox
-//
-typedef union  _H2M_MAILBOX_STRUC {
-    struct {
-        UINT32       LowByte:8;
-        UINT32       HighByte:8;
-        UINT32       CmdToken:8;
-        UINT32       Owner:8;
-    }   field;
-    UINT32           word;
-} H2M_MAILBOX_STRUC, *PH2M_MAILBOX_STRUC;
-
-//
-// M2H_CMD_DONE_CSR: MCU-to-Host command complete indication
-//
-typedef union _M2H_CMD_DONE_STRUC {
-    struct  {
-        UINT32       CmdToken0;
-        UINT32       CmdToken1;
-        UINT32       CmdToken2;
-        UINT32       CmdToken3;
-    } field;
-    UINT32           word;
-} M2H_CMD_DONE_STRUC, *PM2H_CMD_DONE_STRUC;
-
-//
-// MCU_LEDCS: MCU LED Control Setting.
-//
-typedef union  _MCU_LEDCS_STRUC {
-       struct  {
-               UCHAR           LedMode:7;
-               UCHAR           Polarity:1;
-       } field;
-       UCHAR                   word;
-} MCU_LEDCS_STRUC, *PMCU_LEDCS_STRUC;
-
-// =================================================================================
-// Register format
-// =================================================================================
-
-
-
-//NAV_TIME_CFG :NAV
-typedef        union   _NAV_TIME_CFG_STRUC     {
-       struct  {
-               UCHAR           Sifs;               // in unit of 1-us
-               UCHAR       SlotTime;    // in unit of 1-us
-               USHORT          Eifs:9;               // in unit of 1-us
-               USHORT          ZeroSifs:1;               // Applied zero SIFS timer after OFDM RX 0: disable
-               USHORT          rsv:6;
-       }       field;
-       UINT32                  word;
-}      NAV_TIME_CFG_STRUC, *PNAV_TIME_CFG_STRUC;
-
-//
-// RX_FILTR_CFG:  /RX configuration register
-//
-typedef        union   _RX_FILTR_CFG_STRUC     {
-       struct  {
-               UINT32          DropCRCErr:1;           // Drop CRC error
-               UINT32          DropPhyErr:1;           // Drop physical error
-               UINT32          DropNotToMe:1;          // Drop not to me unicast frame
-               UINT32          DropNotMyBSSID:1;                       // Drop fram ToDs bit is true
-
-               UINT32          DropVerErr:1;       // Drop version error frame
-               UINT32          DropMcast:1;            // Drop multicast frames
-               UINT32          DropBcast:1;            // Drop broadcast frames
-               UINT32          DropDuplicate:1;                // Drop duplicate frame
-
-               UINT32          DropCFEndAck:1;         // Drop Ps-Poll
-               UINT32          DropCFEnd:1;            // Drop Ps-Poll
-               UINT32          DropAck:1;              // Drop Ps-Poll
-               UINT32          DropCts:1;              // Drop Ps-Poll
-
-               UINT32          DropRts:1;              // Drop Ps-Poll
-               UINT32          DropPsPoll:1;           // Drop Ps-Poll
-               UINT32          DropBA:1;               //
-               UINT32          DropBAR:1;       //
-
-               UINT32          DropRsvCntlType:1;
-               UINT32          :15;
-       }       field;
-       UINT32                  word;
-}      RX_FILTR_CFG_STRUC, *PRX_FILTR_CFG_STRUC;
-
-//
-// PHY_CSR4: RF serial control register
-//
-typedef        union   _PHY_CSR4_STRUC {
-       struct  {
-               UINT32          RFRegValue:24;          // Register     value (include register id)     serial out to RF/IF     chip.
-               UINT32          NumberOfBits:5;         // Number of bits used in RFRegValue (I:20,     RFMD:22)
-               UINT32          IFSelect:1;                     // 1: select IF to program,     0: select RF to program
-               UINT32          PLL_LD:1;                       // RF PLL_LD status
-               UINT32          Busy:1;                         // 1: ASIC is busy execute RF programming.
-       }       field;
-       UINT32                  word;
-}      PHY_CSR4_STRUC, *PPHY_CSR4_STRUC;
-
-//
-// SEC_CSR5: shared key table security mode register
-//
-typedef        union   _SEC_CSR5_STRUC {
-       struct  {
-        UINT32       Bss2Key0CipherAlg:3;
-        UINT32       :1;
-        UINT32       Bss2Key1CipherAlg:3;
-        UINT32       :1;
-        UINT32       Bss2Key2CipherAlg:3;
-        UINT32       :1;
-        UINT32       Bss2Key3CipherAlg:3;
-        UINT32       :1;
-        UINT32       Bss3Key0CipherAlg:3;
-        UINT32       :1;
-        UINT32       Bss3Key1CipherAlg:3;
-        UINT32       :1;
-        UINT32       Bss3Key2CipherAlg:3;
-        UINT32       :1;
-        UINT32       Bss3Key3CipherAlg:3;
-        UINT32       :1;
-       }       field;
-       UINT32                  word;
-}      SEC_CSR5_STRUC, *PSEC_CSR5_STRUC;
-
-//
-// HOST_CMD_CSR: For HOST to interrupt embedded processor
-//
-typedef        union   _HOST_CMD_CSR_STRUC     {
-       struct  {
-           UINT32   HostCommand:8;
-           UINT32   Rsv:24;
-       }       field;
-       UINT32                  word;
-}      HOST_CMD_CSR_STRUC, *PHOST_CMD_CSR_STRUC;
-
-//
-// AIFSN_CSR: AIFSN for each EDCA AC
-//
-
-
-
-//
-// E2PROM_CSR: EEPROM control register
-//
-typedef        union   _E2PROM_CSR_STRUC       {
-       struct  {
-               UINT32          Reload:1;               // Reload EEPROM content, write one to reload, self-cleared.
-               UINT32          EepromSK:1;
-               UINT32          EepromCS:1;
-               UINT32          EepromDI:1;
-               UINT32          EepromDO:1;
-               UINT32          Type:1;                 // 1: 93C46, 0:93C66
-               UINT32       LoadStatus:1;   // 1:loading, 0:done
-               UINT32          Rsvd:25;
-       }       field;
-       UINT32                  word;
-}      E2PROM_CSR_STRUC, *PE2PROM_CSR_STRUC;
-
-// -------------------------------------------------------------------
-//  E2PROM data layout
-// -------------------------------------------------------------------
-
-//
-// EEPROM antenna select format
-//
-typedef        union   _EEPROM_ANTENNA_STRUC   {
-       struct  {
-               USHORT          RxPath:4;       // 1: 1R, 2: 2R, 3: 3R
-               USHORT          TxPath:4;       // 1: 1T, 2: 2T
-               USHORT      RfIcType:4;             // see E2PROM document
-               USHORT      Rsv:4;
-       }       field;
-       USHORT                  word;
-}      EEPROM_ANTENNA_STRUC, *PEEPROM_ANTENNA_STRUC;
-
-typedef        union _EEPROM_NIC_CINFIG2_STRUC {
-       struct {
-               USHORT          HardwareRadioControl:1; // 1:enable, 0:disable
-               USHORT          DynamicTxAgcControl:1;                  //
-               USHORT          ExternalLNAForG:1;                              //
-               USHORT          ExternalLNAForA:1;                      // external LNA enable for 2.4G
-               USHORT          CardbusAcceleration:1;  // !!! NOTE: 0 - enable, 1 - disable
-               USHORT          BW40MSidebandForG:1;
-               USHORT          BW40MSidebandForA:1;
-               USHORT          EnableWPSPBC:1;                 // WPS PBC Control bit
-               USHORT          BW40MAvailForG:1;                       // 0:enable, 1:disable
-               USHORT          BW40MAvailForA:1;                       // 0:enable, 1:disable
-               USHORT          Rsv1:1;                                 // must be 0
-               USHORT          AntDiversity:1;                 // Antenna diversity
-               USHORT          Rsv2:3;                                 // must be 0
-               USHORT          DACTestBit:1;                   // control if driver should patch the DAC issue
-       }       field;
-       USHORT                  word;
-}      EEPROM_NIC_CONFIG2_STRUC, *PEEPROM_NIC_CONFIG2_STRUC;
-
-//
-// TX_PWR Value valid range 0xFA(-6) ~ 0x24(36)
-//
-typedef        union   _EEPROM_TX_PWR_STRUC    {
-       struct  {
-               CHAR    Byte0;                          // Low Byte
-               CHAR    Byte1;                          // High Byte
-       }       field;
-       USHORT  word;
-}      EEPROM_TX_PWR_STRUC, *PEEPROM_TX_PWR_STRUC;
-
-typedef        union   _EEPROM_VERSION_STRUC   {
-       struct  {
-               UCHAR   FaeReleaseNumber;       // Low Byte
-               UCHAR   Version;                        // High Byte
-       }       field;
-       USHORT  word;
-}      EEPROM_VERSION_STRUC, *PEEPROM_VERSION_STRUC;
-
-typedef        union   _EEPROM_LED_STRUC       {
-       struct  {
-               USHORT  PolarityRDY_G:1;                // Polarity RDY_G setting.
-               USHORT  PolarityRDY_A:1;                // Polarity RDY_A setting.
-               USHORT  PolarityACT:1;          // Polarity ACT setting.
-               USHORT  PolarityGPIO_0:1;       // Polarity GPIO#0 setting.
-               USHORT  PolarityGPIO_1:1;       // Polarity GPIO#1 setting.
-               USHORT  PolarityGPIO_2:1;       // Polarity GPIO#2 setting.
-               USHORT  PolarityGPIO_3:1;       // Polarity GPIO#3 setting.
-               USHORT  PolarityGPIO_4:1;       // Polarity GPIO#4 setting.
-               USHORT  LedMode:5;                      // Led mode.
-               USHORT  Rsvd:3;                         // Reserved
-       }       field;
-       USHORT  word;
-}      EEPROM_LED_STRUC, *PEEPROM_LED_STRUC;
-
-typedef        union   _EEPROM_TXPOWER_DELTA_STRUC     {
-       struct  {
-               UCHAR   DeltaValue:6;   // Tx Power dalta value (MAX=4)
-               UCHAR   Type:1;                 // 1: plus the delta value, 0: minus the delta value
-               UCHAR   TxPowerEnable:1;// Enable
-       }       field;
-       UCHAR   value;
-}      EEPROM_TXPOWER_DELTA_STRUC, *PEEPROM_TXPOWER_DELTA_STRUC;
-
-//
-// QOS_CSR0: TXOP holder address0 register
-//
-typedef        union   _QOS_CSR0_STRUC {
-       struct  {
-               UCHAR           Byte0;          // MAC address byte 0
-               UCHAR           Byte1;          // MAC address byte 1
-               UCHAR           Byte2;          // MAC address byte 2
-               UCHAR           Byte3;          // MAC address byte 3
-       }       field;
-       UINT32                  word;
-}      QOS_CSR0_STRUC, *PQOS_CSR0_STRUC;
-
-//
-// QOS_CSR1: TXOP holder address1 register
-//
-typedef        union   _QOS_CSR1_STRUC {
-       struct  {
-               UCHAR           Byte4;          // MAC address byte 4
-               UCHAR           Byte5;          // MAC address byte 5
-               UCHAR           Rsvd0;
-               UCHAR           Rsvd1;
-       }       field;
-       UINT32                  word;
-}      QOS_CSR1_STRUC, *PQOS_CSR1_STRUC;
-
-#define        RF_CSR_CFG      0x500
-typedef        union   _RF_CSR_CFG_STRUC       {
-       struct  {
-               UINT    RF_CSR_DATA:8;                  // DATA
-               UINT    TESTCSR_RFACC_REGNUM:5; // RF register ID
-               UINT    Rsvd2:3;                                // Reserved
-               UINT    RF_CSR_WR:1;                    // 0: read  1: write
-               UINT    RF_CSR_KICK:1;                  // kick RF register read/write
-               UINT    Rsvd1:14;                               // Reserved
-       }       field;
-       UINT    word;
-}      RF_CSR_CFG_STRUC, *PRF_CSR_CFG_STRUC;
-
-#endif // __RT28XX_H__
+#include "../rt2870/rt28xx.h"
index 3fb30c6df143c889b24dc6f90badbd894509b782..3e8fcbdd57946a0da0621a7f67250b30cda3962a 100644 (file)
@@ -1,74 +1 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify  *
- * it under the terms of the GNU General Public License as published by  *
- * the Free Software Foundation; either version 2 of the License, or     *
- * (at your option) any later version.                                   *
- *                                                                       *
- * 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.                          *
- *                                                                       *
- * You should have received a copy of the GNU General Public License     *
- * along with this program; if not, write to the                         *
- * Free Software Foundation, Inc.,                                       *
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- *                                                                       *
- *************************************************************************
-
-       Module Name:
-       rt_config.h
-
-       Abstract:
-       Central header file to maintain all include files for all NDIS
-       miniport driver routines.
-
-       Revision History:
-       Who         When          What
-       --------    ----------    ----------------------------------------------
-       Paul Lin    08-01-2002    created
-
-*/
-#ifndef        __RT_CONFIG_H__
-#define        __RT_CONFIG_H__
-
-#include    "rtmp_type.h"
-#ifdef LINUX
-#include       "rt_linux.h"
-#endif
-#include    "rtmp_def.h"
-#include    "rt28xx.h"
-
-
-#ifdef RT2870
-#include       "rt2870.h"
-#endif // RT2870 //
-
-#include    "oid.h"
-#include    "mlme.h"
-#include    "wpa.h"
-#include    "md5.h"
-#include    "rtmp.h"
-#include       "ap.h"
-#include       "dfs.h"
-#include       "chlist.h"
-#include       "spectrum.h"
-
-#ifdef IGMP_SNOOP_SUPPORT
-#include "igmp_snoop.h"
-#endif // IGMP_SNOOP_SUPPORT //
-
-#ifdef IKANOS_VX_1X0
-#include       "vr_ikans.h"
-#endif // IKANOS_VX_1X0 //
-
-#endif // __RT_CONFIG_H__
-
+#include "../rt2870/rt_config.h"
index 4d8b6f38a240d4e1a16e58e1b8f86751b16b04ce..6185f2e999241c00844f206d1c7624382417046c 100644 (file)
@@ -1,1009 +1 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify  *
- * it under the terms of the GNU General Public License as published by  *
- * the Free Software Foundation; either version 2 of the License, or     *
- * (at your option) any later version.                                   *
- *                                                                       *
- * 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.                          *
- *                                                                       *
- * You should have received a copy of the GNU General Public License     *
- * along with this program; if not, write to the                         *
- * Free Software Foundation, Inc.,                                       *
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- *                                                                       *
- *************************************************************************
- */
-
-#include "rt_config.h"
-
-ULONG  RTDebugLevel = RT_DEBUG_ERROR;
-
-BUILD_TIMER_FUNCTION(MlmePeriodicExec);
-BUILD_TIMER_FUNCTION(AsicRxAntEvalTimeout);
-BUILD_TIMER_FUNCTION(APSDPeriodicExec);
-BUILD_TIMER_FUNCTION(AsicRfTuningExec);
-#ifdef RT2870
-BUILD_TIMER_FUNCTION(BeaconUpdateExec);
-#endif // RT2870 //
-
-BUILD_TIMER_FUNCTION(BeaconTimeout);
-BUILD_TIMER_FUNCTION(ScanTimeout);
-BUILD_TIMER_FUNCTION(AuthTimeout);
-BUILD_TIMER_FUNCTION(AssocTimeout);
-BUILD_TIMER_FUNCTION(ReassocTimeout);
-BUILD_TIMER_FUNCTION(DisassocTimeout);
-BUILD_TIMER_FUNCTION(LinkDownExec);
-BUILD_TIMER_FUNCTION(StaQuickResponeForRateUpExec);
-BUILD_TIMER_FUNCTION(WpaDisassocApAndBlockAssoc);
-
-
-
-
-// for wireless system event message
-char const *pWirelessSysEventText[IW_SYS_EVENT_TYPE_NUM] = {
-       // system status event
-    "had associated successfully",                                                     /* IW_ASSOC_EVENT_FLAG */
-    "had disassociated",                                                                       /* IW_DISASSOC_EVENT_FLAG */
-    "had deauthenticated",                                                                     /* IW_DEAUTH_EVENT_FLAG */
-    "had been aged-out and disassociated",                                     /* IW_AGEOUT_EVENT_FLAG */
-    "occurred CounterMeasures attack",                                         /* IW_COUNTER_MEASURES_EVENT_FLAG */
-    "occurred replay counter different in Key Handshaking",    /* IW_REPLAY_COUNTER_DIFF_EVENT_FLAG */
-    "occurred RSNIE different in Key Handshaking",                     /* IW_RSNIE_DIFF_EVENT_FLAG */
-    "occurred MIC different in Key Handshaking",                       /* IW_MIC_DIFF_EVENT_FLAG */
-    "occurred ICV error in RX",                                                                /* IW_ICV_ERROR_EVENT_FLAG */
-    "occurred MIC error in RX",                                                                /* IW_MIC_ERROR_EVENT_FLAG */
-       "Group Key Handshaking timeout",                                                /* IW_GROUP_HS_TIMEOUT_EVENT_FLAG */
-       "Pairwise Key Handshaking timeout",                                             /* IW_PAIRWISE_HS_TIMEOUT_EVENT_FLAG */
-       "RSN IE sanity check failure",                                                  /* IW_RSNIE_SANITY_FAIL_EVENT_FLAG */
-       "set key done in WPA/WPAPSK",                                                   /* IW_SET_KEY_DONE_WPA1_EVENT_FLAG */
-       "set key done in WPA2/WPA2PSK",                         /* IW_SET_KEY_DONE_WPA2_EVENT_FLAG */
-       "connects with our wireless client",                    /* IW_STA_LINKUP_EVENT_FLAG */
-       "disconnects with our wireless client",                 /* IW_STA_LINKDOWN_EVENT_FLAG */
-       "scan completed"                                                                                /* IW_SCAN_COMPLETED_EVENT_FLAG */
-       "scan terminate!! Busy!! Enqueue fail!!"                                /* IW_SCAN_ENQUEUE_FAIL_EVENT_FLAG */
-       };
-
-// for wireless IDS_spoof_attack event message
-char const *pWirelessSpoofEventText[IW_SPOOF_EVENT_TYPE_NUM] = {
-    "detected conflict SSID",                                                          /* IW_CONFLICT_SSID_EVENT_FLAG */
-    "detected spoofed association response",                           /* IW_SPOOF_ASSOC_RESP_EVENT_FLAG */
-    "detected spoofed reassociation responses",                                /* IW_SPOOF_REASSOC_RESP_EVENT_FLAG */
-    "detected spoofed probe response",                                         /* IW_SPOOF_PROBE_RESP_EVENT_FLAG */
-    "detected spoofed beacon",                                                         /* IW_SPOOF_BEACON_EVENT_FLAG */
-    "detected spoofed disassociation",                                         /* IW_SPOOF_DISASSOC_EVENT_FLAG */
-    "detected spoofed authentication",                                         /* IW_SPOOF_AUTH_EVENT_FLAG */
-    "detected spoofed deauthentication",                                       /* IW_SPOOF_DEAUTH_EVENT_FLAG */
-    "detected spoofed unknown management frame",                       /* IW_SPOOF_UNKNOWN_MGMT_EVENT_FLAG */
-       "detected replay attack"                                                                /* IW_REPLAY_ATTACK_EVENT_FLAG */
-       };
-
-// for wireless IDS_flooding_attack event message
-char const *pWirelessFloodEventText[IW_FLOOD_EVENT_TYPE_NUM] = {
-       "detected authentication flooding",                                             /* IW_FLOOD_AUTH_EVENT_FLAG */
-    "detected association request flooding",                           /* IW_FLOOD_ASSOC_REQ_EVENT_FLAG */
-    "detected reassociation request flooding",                         /* IW_FLOOD_REASSOC_REQ_EVENT_FLAG */
-    "detected probe request flooding",                                         /* IW_FLOOD_PROBE_REQ_EVENT_FLAG */
-    "detected disassociation flooding",                                                /* IW_FLOOD_DISASSOC_EVENT_FLAG */
-    "detected deauthentication flooding",                                      /* IW_FLOOD_DEAUTH_EVENT_FLAG */
-    "detected 802.1x eap-request flooding"                                     /* IW_FLOOD_EAP_REQ_EVENT_FLAG */
-       };
-
-
-/* timeout -- ms */
-VOID RTMP_SetPeriodicTimer(
-       IN      NDIS_MINIPORT_TIMER *pTimer,
-       IN      unsigned long timeout)
-{
-       timeout = ((timeout*HZ) / 1000);
-       pTimer->expires = jiffies + timeout;
-       add_timer(pTimer);
-}
-
-/* convert NdisMInitializeTimer --> RTMP_OS_Init_Timer */
-VOID RTMP_OS_Init_Timer(
-       IN      PRTMP_ADAPTER pAd,
-       IN      NDIS_MINIPORT_TIMER *pTimer,
-       IN      TIMER_FUNCTION function,
-       IN      PVOID data)
-{
-       init_timer(pTimer);
-    pTimer->data = (unsigned long)data;
-    pTimer->function = function;
-}
-
-
-VOID RTMP_OS_Add_Timer(
-       IN      NDIS_MINIPORT_TIMER             *pTimer,
-       IN      unsigned long timeout)
-{
-       if (timer_pending(pTimer))
-               return;
-
-       timeout = ((timeout*HZ) / 1000);
-       pTimer->expires = jiffies + timeout;
-       add_timer(pTimer);
-}
-
-VOID RTMP_OS_Mod_Timer(
-       IN      NDIS_MINIPORT_TIMER             *pTimer,
-       IN      unsigned long timeout)
-{
-       timeout = ((timeout*HZ) / 1000);
-       mod_timer(pTimer, jiffies + timeout);
-}
-
-VOID RTMP_OS_Del_Timer(
-       IN      NDIS_MINIPORT_TIMER             *pTimer,
-       OUT     BOOLEAN                                 *pCancelled)
-{
-       if (timer_pending(pTimer))
-       {
-               *pCancelled = del_timer_sync(pTimer);
-       }
-       else
-       {
-               *pCancelled = TRUE;
-       }
-
-}
-
-VOID RTMP_OS_Release_Packet(
-       IN      PRTMP_ADAPTER pAd,
-       IN      PQUEUE_ENTRY  pEntry)
-{
-       //RTMPFreeNdisPacket(pAd, (struct sk_buff *)pEntry);
-}
-
-// Unify all delay routine by using udelay
-VOID RTMPusecDelay(
-       IN      ULONG   usec)
-{
-       ULONG   i;
-
-       for (i = 0; i < (usec / 50); i++)
-               udelay(50);
-
-       if (usec % 50)
-               udelay(usec % 50);
-}
-
-void RTMP_GetCurrentSystemTime(LARGE_INTEGER *time)
-{
-       time->u.LowPart = jiffies;
-}
-
-// pAd MUST allow to be NULL
-NDIS_STATUS os_alloc_mem(
-       IN      PRTMP_ADAPTER pAd,
-       OUT     PUCHAR *mem,
-       IN      ULONG  size)
-{
-       *mem = (PUCHAR) kmalloc(size, GFP_ATOMIC);
-       if (*mem)
-               return (NDIS_STATUS_SUCCESS);
-       else
-               return (NDIS_STATUS_FAILURE);
-}
-
-// pAd MUST allow to be NULL
-NDIS_STATUS os_free_mem(
-       IN      PRTMP_ADAPTER pAd,
-       IN      PUCHAR mem)
-{
-
-       ASSERT(mem);
-       kfree(mem);
-       return (NDIS_STATUS_SUCCESS);
-}
-
-
-PNDIS_PACKET RTMP_AllocateFragPacketBuffer(
-       IN      PRTMP_ADAPTER pAd,
-       IN      ULONG   Length)
-{
-       struct sk_buff *pkt;
-
-       pkt = dev_alloc_skb(Length);
-
-       if (pkt == NULL)
-       {
-               DBGPRINT(RT_DEBUG_ERROR, ("can't allocate frag rx %ld size packet\n",Length));
-       }
-
-       if (pkt)
-       {
-               RTMP_SET_PACKET_SOURCE(OSPKT_TO_RTPKT(pkt), PKTSRC_NDIS);
-       }
-
-       return (PNDIS_PACKET) pkt;
-}
-
-
-PNDIS_PACKET RTMP_AllocateTxPacketBuffer(
-       IN      PRTMP_ADAPTER pAd,
-       IN      ULONG   Length,
-       IN      BOOLEAN Cached,
-       OUT     PVOID   *VirtualAddress)
-{
-       struct sk_buff *pkt;
-
-       pkt = dev_alloc_skb(Length);
-
-       if (pkt == NULL)
-       {
-               DBGPRINT(RT_DEBUG_ERROR, ("can't allocate tx %ld size packet\n",Length));
-       }
-
-       if (pkt)
-       {
-               RTMP_SET_PACKET_SOURCE(OSPKT_TO_RTPKT(pkt), PKTSRC_NDIS);
-               *VirtualAddress = (PVOID) pkt->data;
-       }
-       else
-       {
-               *VirtualAddress = (PVOID) NULL;
-       }
-
-       return (PNDIS_PACKET) pkt;
-}
-
-
-VOID build_tx_packet(
-       IN      PRTMP_ADAPTER   pAd,
-       IN      PNDIS_PACKET    pPacket,
-       IN      PUCHAR  pFrame,
-       IN      ULONG   FrameLen)
-{
-
-       struct sk_buff  *pTxPkt;
-
-       ASSERT(pPacket);
-       pTxPkt = RTPKT_TO_OSPKT(pPacket);
-
-       NdisMoveMemory(skb_put(pTxPkt, FrameLen), pFrame, FrameLen);
-}
-
-VOID   RTMPFreeAdapter(
-       IN      PRTMP_ADAPTER   pAd)
-{
-    POS_COOKIE os_cookie;
-       int index;
-
-       os_cookie=(POS_COOKIE)pAd->OS_Cookie;
-
-       kfree(pAd->BeaconBuf);
-
-
-       NdisFreeSpinLock(&pAd->MgmtRingLock);
-
-
-       for (index =0 ; index < NUM_OF_TX_RING; index++)
-       {
-       NdisFreeSpinLock(&pAd->TxSwQueueLock[index]);
-               NdisFreeSpinLock(&pAd->DeQueueLock[index]);
-               pAd->DeQueueRunning[index] = FALSE;
-       }
-
-       NdisFreeSpinLock(&pAd->irq_lock);
-
-
-       vfree(pAd); // pci_free_consistent(os_cookie->pci_dev,sizeof(RTMP_ADAPTER),pAd,os_cookie->pAd_pa);
-       kfree(os_cookie);
-}
-
-BOOLEAN OS_Need_Clone_Packet(void)
-{
-       return (FALSE);
-}
-
-
-
-/*
-       ========================================================================
-
-       Routine Description:
-               clone an input NDIS PACKET to another one. The new internally created NDIS PACKET
-               must have only one NDIS BUFFER
-               return - byte copied. 0 means can't create NDIS PACKET
-               NOTE: internally created NDIS_PACKET should be destroyed by RTMPFreeNdisPacket
-
-       Arguments:
-               pAd     Pointer to our adapter
-               pInsAMSDUHdr    EWC A-MSDU format has extra 14-bytes header. if TRUE, insert this 14-byte hdr in front of MSDU.
-               *pSrcTotalLen                   return total packet length. This lenght is calculated with 802.3 format packet.
-
-       Return Value:
-               NDIS_STATUS_SUCCESS
-               NDIS_STATUS_FAILURE
-
-       Note:
-
-       ========================================================================
-*/
-NDIS_STATUS RTMPCloneNdisPacket(
-       IN      PRTMP_ADAPTER   pAd,
-       IN      BOOLEAN                 pInsAMSDUHdr,
-       IN      PNDIS_PACKET    pInPacket,
-       OUT PNDIS_PACKET   *ppOutPacket)
-{
-
-       struct sk_buff *pkt;
-
-       ASSERT(pInPacket);
-       ASSERT(ppOutPacket);
-
-       // 1. Allocate a packet
-       pkt = dev_alloc_skb(2048);
-
-       if (pkt == NULL)
-       {
-               return NDIS_STATUS_FAILURE;
-       }
-
-       skb_put(pkt, GET_OS_PKT_LEN(pInPacket));
-       NdisMoveMemory(pkt->data, GET_OS_PKT_DATAPTR(pInPacket), GET_OS_PKT_LEN(pInPacket));
-       *ppOutPacket = OSPKT_TO_RTPKT(pkt);
-
-
-       RTMP_SET_PACKET_SOURCE(OSPKT_TO_RTPKT(pkt), PKTSRC_NDIS);
-
-       printk("###Clone###\n");
-
-       return NDIS_STATUS_SUCCESS;
-}
-
-
-// the allocated NDIS PACKET must be freed via RTMPFreeNdisPacket()
-NDIS_STATUS RTMPAllocateNdisPacket(
-       IN      PRTMP_ADAPTER   pAd,
-       OUT PNDIS_PACKET   *ppPacket,
-       IN      PUCHAR                  pHeader,
-       IN      UINT                    HeaderLen,
-       IN      PUCHAR                  pData,
-       IN      UINT                    DataLen)
-{
-       PNDIS_PACKET    pPacket;
-       ASSERT(pData);
-       ASSERT(DataLen);
-
-       // 1. Allocate a packet
-       pPacket = (PNDIS_PACKET *) dev_alloc_skb(HeaderLen + DataLen + TXPADDING_SIZE);
-       if (pPacket == NULL)
-       {
-               *ppPacket = NULL;
-#ifdef DEBUG
-               printk("RTMPAllocateNdisPacket Fail\n\n");
-#endif
-               return NDIS_STATUS_FAILURE;
-       }
-
-       // 2. clone the frame content
-       if (HeaderLen > 0)
-               NdisMoveMemory(GET_OS_PKT_DATAPTR(pPacket), pHeader, HeaderLen);
-       if (DataLen > 0)
-               NdisMoveMemory(GET_OS_PKT_DATAPTR(pPacket) + HeaderLen, pData, DataLen);
-
-       // 3. update length of packet
-       skb_put(GET_OS_PKT_TYPE(pPacket), HeaderLen+DataLen);
-
-       RTMP_SET_PACKET_SOURCE(pPacket, PKTSRC_NDIS);
-//     printk("%s : pPacket = %p, len = %d\n", __func__, pPacket, GET_OS_PKT_LEN(pPacket));
-       *ppPacket = pPacket;
-       return NDIS_STATUS_SUCCESS;
-}
-
-/*
-  ========================================================================
-  Description:
-       This routine frees a miniport internally allocated NDIS_PACKET and its
-       corresponding NDIS_BUFFER and allocated memory.
-  ========================================================================
-*/
-VOID RTMPFreeNdisPacket(
-       IN PRTMP_ADAPTER pAd,
-       IN PNDIS_PACKET  pPacket)
-{
-       dev_kfree_skb_any(RTPKT_TO_OSPKT(pPacket));
-}
-
-
-// IRQL = DISPATCH_LEVEL
-// NOTE: we do have an assumption here, that Byte0 and Byte1 always reasid at the same
-//                      scatter gather buffer
-NDIS_STATUS Sniff2BytesFromNdisBuffer(
-       IN      PNDIS_BUFFER    pFirstBuffer,
-       IN      UCHAR                   DesiredOffset,
-       OUT PUCHAR                      pByte0,
-       OUT PUCHAR                      pByte1)
-{
-    *pByte0 = *(PUCHAR)(pFirstBuffer + DesiredOffset);
-    *pByte1 = *(PUCHAR)(pFirstBuffer + DesiredOffset + 1);
-
-       return NDIS_STATUS_SUCCESS;
-}
-
-
-void RTMP_QueryPacketInfo(
-       IN  PNDIS_PACKET pPacket,
-       OUT PACKET_INFO  *pPacketInfo,
-       OUT PUCHAR               *pSrcBufVA,
-       OUT     UINT             *pSrcBufLen)
-{
-       pPacketInfo->BufferCount = 1;
-       pPacketInfo->pFirstBuffer = GET_OS_PKT_DATAPTR(pPacket);
-       pPacketInfo->PhysicalBufferCount = 1;
-       pPacketInfo->TotalPacketLength = GET_OS_PKT_LEN(pPacket);
-
-       *pSrcBufVA = GET_OS_PKT_DATAPTR(pPacket);
-       *pSrcBufLen = GET_OS_PKT_LEN(pPacket);
-}
-
-void RTMP_QueryNextPacketInfo(
-       IN  PNDIS_PACKET *ppPacket,
-       OUT PACKET_INFO  *pPacketInfo,
-       OUT PUCHAR               *pSrcBufVA,
-       OUT     UINT             *pSrcBufLen)
-{
-       PNDIS_PACKET pPacket = NULL;
-
-       if (*ppPacket)
-               pPacket = GET_OS_PKT_NEXT(*ppPacket);
-
-       if (pPacket)
-       {
-               pPacketInfo->BufferCount = 1;
-               pPacketInfo->pFirstBuffer = GET_OS_PKT_DATAPTR(pPacket);
-               pPacketInfo->PhysicalBufferCount = 1;
-               pPacketInfo->TotalPacketLength = GET_OS_PKT_LEN(pPacket);
-
-               *pSrcBufVA = GET_OS_PKT_DATAPTR(pPacket);
-               *pSrcBufLen = GET_OS_PKT_LEN(pPacket);
-               *ppPacket = GET_OS_PKT_NEXT(pPacket);
-       }
-       else
-       {
-               pPacketInfo->BufferCount = 0;
-               pPacketInfo->pFirstBuffer = NULL;
-               pPacketInfo->PhysicalBufferCount = 0;
-               pPacketInfo->TotalPacketLength = 0;
-
-               *pSrcBufVA = NULL;
-               *pSrcBufLen = 0;
-               *ppPacket = NULL;
-       }
-}
-
-// not yet support MBSS
-PNET_DEV get_netdev_from_bssid(
-       IN      PRTMP_ADAPTER   pAd,
-       IN      UCHAR                   FromWhichBSSID)
-{
-    PNET_DEV dev_p = NULL;
-
-       dev_p = pAd->net_dev;
-
-       ASSERT(dev_p);
-       return dev_p; /* return one of MBSS */
-}
-
-PNDIS_PACKET DuplicatePacket(
-       IN      PRTMP_ADAPTER   pAd,
-       IN      PNDIS_PACKET    pPacket,
-       IN      UCHAR                   FromWhichBSSID)
-{
-       struct sk_buff  *skb;
-       PNDIS_PACKET    pRetPacket = NULL;
-       USHORT                  DataSize;
-       UCHAR                   *pData;
-
-       DataSize = (USHORT) GET_OS_PKT_LEN(pPacket);
-       pData = (PUCHAR) GET_OS_PKT_DATAPTR(pPacket);
-
-
-       skb = skb_clone(RTPKT_TO_OSPKT(pPacket), MEM_ALLOC_FLAG);
-       if (skb)
-       {
-               skb->dev = get_netdev_from_bssid(pAd, FromWhichBSSID);
-               pRetPacket = OSPKT_TO_RTPKT(skb);
-       }
-
-       return pRetPacket;
-
-}
-
-PNDIS_PACKET duplicate_pkt(
-       IN      PRTMP_ADAPTER   pAd,
-       IN      PUCHAR                  pHeader802_3,
-    IN  UINT            HdrLen,
-       IN      PUCHAR                  pData,
-       IN      ULONG                   DataSize,
-       IN      UCHAR                   FromWhichBSSID)
-{
-       struct sk_buff  *skb;
-       PNDIS_PACKET    pPacket = NULL;
-
-
-       if ((skb = __dev_alloc_skb(HdrLen + DataSize + 2, MEM_ALLOC_FLAG)) != NULL)
-       {
-               skb_reserve(skb, 2);
-               NdisMoveMemory(skb->tail, pHeader802_3, HdrLen);
-               skb_put(skb, HdrLen);
-               NdisMoveMemory(skb->tail, pData, DataSize);
-               skb_put(skb, DataSize);
-               skb->dev = get_netdev_from_bssid(pAd, FromWhichBSSID);
-               pPacket = OSPKT_TO_RTPKT(skb);
-       }
-
-       return pPacket;
-}
-
-
-#define TKIP_TX_MIC_SIZE               8
-PNDIS_PACKET duplicate_pkt_with_TKIP_MIC(
-       IN      PRTMP_ADAPTER   pAd,
-       IN      PNDIS_PACKET    pPacket)
-{
-       struct sk_buff  *skb, *newskb;
-
-
-       skb = RTPKT_TO_OSPKT(pPacket);
-       if (skb_tailroom(skb) < TKIP_TX_MIC_SIZE)
-       {
-               // alloc a new skb and copy the packet
-               newskb = skb_copy_expand(skb, skb_headroom(skb), TKIP_TX_MIC_SIZE, GFP_ATOMIC);
-               dev_kfree_skb_any(skb);
-               if (newskb == NULL)
-               {
-                       DBGPRINT(RT_DEBUG_ERROR, ("Extend Tx.MIC for packet failed!, dropping packet!\n"));
-                       return NULL;
-               }
-               skb = newskb;
-       }
-
-       return OSPKT_TO_RTPKT(skb);
-}
-
-
-
-
-PNDIS_PACKET ClonePacket(
-       IN      PRTMP_ADAPTER   pAd,
-       IN      PNDIS_PACKET    pPacket,
-       IN      PUCHAR                  pData,
-       IN      ULONG                   DataSize)
-{
-       struct sk_buff  *pRxPkt;
-       struct sk_buff  *pClonedPkt;
-
-       ASSERT(pPacket);
-       pRxPkt = RTPKT_TO_OSPKT(pPacket);
-
-       // clone the packet
-       pClonedPkt = skb_clone(pRxPkt, MEM_ALLOC_FLAG);
-
-       if (pClonedPkt)
-       {
-       // set the correct dataptr and data len
-       pClonedPkt->dev = pRxPkt->dev;
-       pClonedPkt->data = pData;
-       pClonedPkt->len = DataSize;
-       pClonedPkt->tail = pClonedPkt->data + pClonedPkt->len;
-               ASSERT(DataSize < 1530);
-       }
-       return pClonedPkt;
-}
-
-//
-// change OS packet DataPtr and DataLen
-//
-void  update_os_packet_info(
-       IN      PRTMP_ADAPTER   pAd,
-       IN      RX_BLK                  *pRxBlk,
-       IN  UCHAR                       FromWhichBSSID)
-{
-       struct sk_buff  *pOSPkt;
-
-       ASSERT(pRxBlk->pRxPacket);
-       pOSPkt = RTPKT_TO_OSPKT(pRxBlk->pRxPacket);
-
-       pOSPkt->dev = get_netdev_from_bssid(pAd, FromWhichBSSID);
-       pOSPkt->data = pRxBlk->pData;
-       pOSPkt->len = pRxBlk->DataSize;
-       pOSPkt->tail = pOSPkt->data + pOSPkt->len;
-}
-
-
-void wlan_802_11_to_802_3_packet(
-       IN      PRTMP_ADAPTER   pAd,
-       IN      RX_BLK                  *pRxBlk,
-       IN      PUCHAR                  pHeader802_3,
-       IN  UCHAR                       FromWhichBSSID)
-{
-       struct sk_buff  *pOSPkt;
-
-       ASSERT(pRxBlk->pRxPacket);
-       ASSERT(pHeader802_3);
-
-       pOSPkt = RTPKT_TO_OSPKT(pRxBlk->pRxPacket);
-
-       pOSPkt->dev = get_netdev_from_bssid(pAd, FromWhichBSSID);
-       pOSPkt->data = pRxBlk->pData;
-       pOSPkt->len = pRxBlk->DataSize;
-       pOSPkt->tail = pOSPkt->data + pOSPkt->len;
-
-       //
-       // copy 802.3 header
-       //
-       //
-
-       NdisMoveMemory(skb_push(pOSPkt, LENGTH_802_3), pHeader802_3, LENGTH_802_3);
-}
-
-void announce_802_3_packet(
-       IN      PRTMP_ADAPTER   pAd,
-       IN      PNDIS_PACKET    pPacket)
-{
-
-       struct sk_buff  *pRxPkt;
-
-       ASSERT(pPacket);
-
-       pRxPkt = RTPKT_TO_OSPKT(pPacket);
-
-    /* Push up the protocol stack */
-#ifdef IKANOS_VX_1X0
-       IKANOS_DataFrameRx(pAd, pRxPkt->dev, pRxPkt, pRxPkt->len);
-#else
-       pRxPkt->protocol = eth_type_trans(pRxPkt, pRxPkt->dev);
-
-       netif_rx(pRxPkt);
-#endif // IKANOS_VX_1X0 //
-}
-
-
-PRTMP_SCATTER_GATHER_LIST
-rt_get_sg_list_from_packet(PNDIS_PACKET pPacket, RTMP_SCATTER_GATHER_LIST *sg)
-{
-       sg->NumberOfElements = 1;
-       sg->Elements[0].Address =  GET_OS_PKT_DATAPTR(pPacket);
-       sg->Elements[0].Length = GET_OS_PKT_LEN(pPacket);
-       return (sg);
-}
-
-void hex_dump(char *str, unsigned char *pSrcBufVA, unsigned int SrcBufLen)
-{
-       unsigned char *pt;
-       int x;
-
-       if (RTDebugLevel < RT_DEBUG_TRACE)
-               return;
-
-       pt = pSrcBufVA;
-       printk("%s: %p, len = %d\n",str,  pSrcBufVA, SrcBufLen);
-       for (x=0; x<SrcBufLen; x++)
-       {
-               if (x % 16 == 0)
-                       printk("0x%04x : ", x);
-               printk("%02x ", ((unsigned char)pt[x]));
-               if (x%16 == 15) printk("\n");
-       }
-       printk("\n");
-}
-
-/*
-       ========================================================================
-
-       Routine Description:
-               Send log message through wireless event
-
-               Support standard iw_event with IWEVCUSTOM. It is used below.
-
-               iwreq_data.data.flags is used to store event_flag that is defined by user.
-               iwreq_data.data.length is the length of the event log.
-
-               The format of the event log is composed of the entry's MAC address and
-               the desired log message (refer to pWirelessEventText).
-
-                       ex: 11:22:33:44:55:66 has associated successfully
-
-               p.s. The requirement of Wireless Extension is v15 or newer.
-
-       ========================================================================
-*/
-VOID RTMPSendWirelessEvent(
-       IN      PRTMP_ADAPTER   pAd,
-       IN      USHORT                  Event_flag,
-       IN      PUCHAR                  pAddr,
-       IN      UCHAR                   BssIdx,
-       IN      CHAR                    Rssi)
-{
-#if WIRELESS_EXT >= 15
-
-       union   iwreq_data      wrqu;
-       PUCHAR  pBuf = NULL, pBufPtr = NULL;
-       USHORT  event, type, BufLen;
-       UCHAR   event_table_len = 0;
-
-       type = Event_flag & 0xFF00;
-       event = Event_flag & 0x00FF;
-
-       switch (type)
-       {
-               case IW_SYS_EVENT_FLAG_START:
-                       event_table_len = IW_SYS_EVENT_TYPE_NUM;
-                       break;
-
-               case IW_SPOOF_EVENT_FLAG_START:
-                       event_table_len = IW_SPOOF_EVENT_TYPE_NUM;
-                       break;
-
-               case IW_FLOOD_EVENT_FLAG_START:
-                       event_table_len = IW_FLOOD_EVENT_TYPE_NUM;
-                       break;
-       }
-
-       if (event_table_len == 0)
-       {
-               DBGPRINT(RT_DEBUG_ERROR, ("%s : The type(%0x02x) is not valid.\n", __func__, type));
-               return;
-       }
-
-       if (event >= event_table_len)
-       {
-               DBGPRINT(RT_DEBUG_ERROR, ("%s : The event(%0x02x) is not valid.\n", __func__, event));
-               return;
-       }
-
-       //Allocate memory and copy the msg.
-       if((pBuf = kmalloc(IW_CUSTOM_MAX_LEN, GFP_ATOMIC)) != NULL)
-       {
-               //Prepare the payload
-               memset(pBuf, 0, IW_CUSTOM_MAX_LEN);
-
-               pBufPtr = pBuf;
-
-               if (pAddr)
-                       pBufPtr += sprintf(pBufPtr, "(RT2860) STA(%02x:%02x:%02x:%02x:%02x:%02x) ", PRINT_MAC(pAddr));
-               else if (BssIdx < MAX_MBSSID_NUM)
-                       pBufPtr += sprintf(pBufPtr, "(RT2860) BSS(ra%d) ", BssIdx);
-               else
-                       pBufPtr += sprintf(pBufPtr, "(RT2860) ");
-
-               if (type == IW_SYS_EVENT_FLAG_START)
-                       pBufPtr += sprintf(pBufPtr, "%s", pWirelessSysEventText[event]);
-               else if (type == IW_SPOOF_EVENT_FLAG_START)
-                       pBufPtr += sprintf(pBufPtr, "%s (RSSI=%d)", pWirelessSpoofEventText[event], Rssi);
-               else if (type == IW_FLOOD_EVENT_FLAG_START)
-                       pBufPtr += sprintf(pBufPtr, "%s", pWirelessFloodEventText[event]);
-               else
-                       pBufPtr += sprintf(pBufPtr, "%s", "unknown event");
-
-               pBufPtr[pBufPtr - pBuf] = '\0';
-               BufLen = pBufPtr - pBuf;
-
-               memset(&wrqu, 0, sizeof(wrqu));
-           wrqu.data.flags = Event_flag;
-               wrqu.data.length = BufLen;
-
-               //send wireless event
-           wireless_send_event(pAd->net_dev, IWEVCUSTOM, &wrqu, pBuf);
-
-               //DBGPRINT(RT_DEBUG_TRACE, ("%s : %s\n", __func__, pBuf));
-
-               kfree(pBuf);
-       }
-       else
-               DBGPRINT(RT_DEBUG_ERROR, ("%s : Can't allocate memory for wireless event.\n", __func__));
-#else
-       DBGPRINT(RT_DEBUG_ERROR, ("%s : The Wireless Extension MUST be v15 or newer.\n", __func__));
-#endif  /* WIRELESS_EXT >= 15 */
-}
-
-void send_monitor_packets(
-       IN      PRTMP_ADAPTER   pAd,
-       IN      RX_BLK                  *pRxBlk)
-{
-    struct sk_buff     *pOSPkt;
-    wlan_ng_prism2_header *ph;
-    int rate_index = 0;
-    USHORT header_len = 0;
-    UCHAR temp_header[40] = {0};
-
-    u_int32_t ralinkrate[256] = {2,4,11,22, 12,18,24,36,48,72,96,  108,   109, 110, 111, 112, 13, 26, 39, 52,78,104, 117, 130, 26, 52, 78,104, 156, 208, 234, 260, 27, 54,81,108,162, 216, 243, 270, // Last 38
-       54, 108, 162, 216, 324, 432, 486, 540,  14, 29, 43, 57, 87, 115, 130, 144, 29, 59,87,115, 173, 230,260, 288, 30, 60,90,120,180,240,270,300,60,120,180,240,360,480,540,600, 0,1,2,3,4,5,6,7,8,9,10,
-       11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80};
-
-
-    ASSERT(pRxBlk->pRxPacket);
-    if (pRxBlk->DataSize < 10)
-    {
-        DBGPRINT(RT_DEBUG_ERROR, ("%s : Size is too small! (%d)\n", __func__, pRxBlk->DataSize));
-               goto err_free_sk_buff;
-    }
-
-    if (pRxBlk->DataSize + sizeof(wlan_ng_prism2_header) > RX_BUFFER_AGGRESIZE)
-    {
-        DBGPRINT(RT_DEBUG_ERROR, ("%s : Size is too large! (%d)\n", __func__, pRxBlk->DataSize + sizeof(wlan_ng_prism2_header)));
-               goto err_free_sk_buff;
-    }
-
-    pOSPkt = RTPKT_TO_OSPKT(pRxBlk->pRxPacket);
-       pOSPkt->dev = get_netdev_from_bssid(pAd, BSS0);
-    if (pRxBlk->pHeader->FC.Type == BTYPE_DATA)
-    {
-        pRxBlk->DataSize -= LENGTH_802_11;
-        if ((pRxBlk->pHeader->FC.ToDs == 1) &&
-            (pRxBlk->pHeader->FC.FrDs == 1))
-            header_len = LENGTH_802_11_WITH_ADDR4;
-        else
-            header_len = LENGTH_802_11;
-
-        // QOS
-       if (pRxBlk->pHeader->FC.SubType & 0x08)
-       {
-           header_len += 2;
-               // Data skip QOS contorl field
-               pRxBlk->DataSize -=2;
-       }
-
-       // Order bit: A-Ralink or HTC+
-       if (pRxBlk->pHeader->FC.Order)
-       {
-           header_len += 4;
-                       // Data skip HTC contorl field
-                       pRxBlk->DataSize -= 4;
-       }
-
-        // Copy Header
-        if (header_len <= 40)
-            NdisMoveMemory(temp_header, pRxBlk->pData, header_len);
-
-        // skip HW padding
-       if (pRxBlk->RxD.L2PAD)
-           pRxBlk->pData += (header_len + 2);
-        else
-            pRxBlk->pData += header_len;
-    } //end if
-
-
-       if (pRxBlk->DataSize < pOSPkt->len) {
-        skb_trim(pOSPkt,pRxBlk->DataSize);
-    } else {
-        skb_put(pOSPkt,(pRxBlk->DataSize - pOSPkt->len));
-    } //end if
-
-    if ((pRxBlk->pData - pOSPkt->data) > 0) {
-           skb_put(pOSPkt,(pRxBlk->pData - pOSPkt->data));
-           skb_pull(pOSPkt,(pRxBlk->pData - pOSPkt->data));
-    } //end if
-
-    if (skb_headroom(pOSPkt) < (sizeof(wlan_ng_prism2_header)+ header_len)) {
-        if (pskb_expand_head(pOSPkt, (sizeof(wlan_ng_prism2_header) + header_len), 0, GFP_ATOMIC)) {
-               DBGPRINT(RT_DEBUG_ERROR, ("%s : Reallocate header size of sk_buff fail!\n", __func__));
-                       goto err_free_sk_buff;
-           } //end if
-    } //end if
-
-    if (header_len > 0)
-        NdisMoveMemory(skb_push(pOSPkt, header_len), temp_header, header_len);
-
-    ph = (wlan_ng_prism2_header *) skb_push(pOSPkt, sizeof(wlan_ng_prism2_header));
-       NdisZeroMemory(ph, sizeof(wlan_ng_prism2_header));
-
-    ph->msgcode                    = DIDmsg_lnxind_wlansniffrm;
-       ph->msglen                  = sizeof(wlan_ng_prism2_header);
-       strcpy(ph->devname, pAd->net_dev->name);
-
-    ph->hosttime.did = DIDmsg_lnxind_wlansniffrm_hosttime;
-       ph->hosttime.status = 0;
-       ph->hosttime.len = 4;
-       ph->hosttime.data = jiffies;
-
-       ph->mactime.did = DIDmsg_lnxind_wlansniffrm_mactime;
-       ph->mactime.status = 0;
-       ph->mactime.len = 0;
-       ph->mactime.data = 0;
-
-    ph->istx.did = DIDmsg_lnxind_wlansniffrm_istx;
-       ph->istx.status = 0;
-       ph->istx.len = 0;
-       ph->istx.data = 0;
-
-    ph->channel.did = DIDmsg_lnxind_wlansniffrm_channel;
-       ph->channel.status = 0;
-       ph->channel.len = 4;
-
-    ph->channel.data = (u_int32_t)pAd->CommonCfg.Channel;
-
-    ph->rssi.did = DIDmsg_lnxind_wlansniffrm_rssi;
-       ph->rssi.status = 0;
-       ph->rssi.len = 4;
-    ph->rssi.data = (u_int32_t)RTMPMaxRssi(pAd, ConvertToRssi(pAd, pRxBlk->pRxWI->RSSI0, RSSI_0), ConvertToRssi(pAd, pRxBlk->pRxWI->RSSI1, RSSI_1), ConvertToRssi(pAd, pRxBlk->pRxWI->RSSI2, RSSI_2));;
-
-       ph->signal.did = DIDmsg_lnxind_wlansniffrm_signal;
-       ph->signal.status = 0;
-       ph->signal.len = 4;
-       ph->signal.data = 0; //rssi + noise;
-
-       ph->noise.did = DIDmsg_lnxind_wlansniffrm_noise;
-       ph->noise.status = 0;
-       ph->noise.len = 4;
-       ph->noise.data = 0;
-
-    if (pRxBlk->pRxWI->PHYMODE >= MODE_HTMIX)
-    {
-       rate_index = 16 + ((UCHAR)pRxBlk->pRxWI->BW *16) + ((UCHAR)pRxBlk->pRxWI->ShortGI *32) + ((UCHAR)pRxBlk->pRxWI->MCS);
-    }
-    else
-       if (pRxBlk->pRxWI->PHYMODE == MODE_OFDM)
-       rate_index = (UCHAR)(pRxBlk->pRxWI->MCS) + 4;
-    else
-       rate_index = (UCHAR)(pRxBlk->pRxWI->MCS);
-    if (rate_index < 0)
-        rate_index = 0;
-    if (rate_index > 255)
-        rate_index = 255;
-
-       ph->rate.did = DIDmsg_lnxind_wlansniffrm_rate;
-       ph->rate.status = 0;
-       ph->rate.len = 4;
-    ph->rate.data = ralinkrate[rate_index];
-
-       ph->frmlen.did = DIDmsg_lnxind_wlansniffrm_frmlen;
-    ph->frmlen.status = 0;
-       ph->frmlen.len = 4;
-       ph->frmlen.data = (u_int32_t)pRxBlk->DataSize;
-
-
-    pOSPkt->pkt_type = PACKET_OTHERHOST;
-    pOSPkt->protocol = eth_type_trans(pOSPkt, pOSPkt->dev);
-    pOSPkt->ip_summed = CHECKSUM_NONE;
-    netif_rx(pOSPkt);
-
-    return;
-
-err_free_sk_buff:
-       RELEASE_NDIS_PACKET(pAd, pRxBlk->pRxPacket, NDIS_STATUS_FAILURE);
-       return;
-
-}
-
-void rtmp_os_thread_init(PUCHAR pThreadName, PVOID pNotify)
-{
-       daemonize(pThreadName /*"%s",pAd->net_dev->name*/);
-
-       allow_signal(SIGTERM);
-       allow_signal(SIGKILL);
-       current->flags |= PF_NOFREEZE;
-
-       /* signal that we've started the thread */
-       complete(pNotify);
-}
-
-void RTMP_IndicateMediaState(
-       IN      PRTMP_ADAPTER   pAd)
-{
-       if (pAd->CommonCfg.bWirelessEvent)
-       {
-               if (pAd->IndicateMediaState == NdisMediaStateConnected)
-               {
-                       RTMPSendWirelessEvent(pAd, IW_STA_LINKUP_EVENT_FLAG, pAd->MacTab.Content[BSSID_WCID].Addr, BSS0, 0);
-               }
-               else
-               {
-                       RTMPSendWirelessEvent(pAd, IW_STA_LINKDOWN_EVENT_FLAG, pAd->MacTab.Content[BSSID_WCID].Addr, BSS0, 0);
-               }
-       }
-}
-
+#include "../rt2870/rt_linux.c"
index 87bffefa704edf7442037cdd332e05d19eeaa5ec..9f7efee3d6096e304d8b37022467e34b926c4b16 100644 (file)
@@ -1,815 +1 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify  *
- * it under the terms of the GNU General Public License as published by  *
- * the Free Software Foundation; either version 2 of the License, or     *
- * (at your option) any later version.                                   *
- *                                                                       *
- * 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.                          *
- *                                                                       *
- * You should have received a copy of the GNU General Public License     *
- * along with this program; if not, write to the                         *
- * Free Software Foundation, Inc.,                                       *
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- *                                                                       *
- *************************************************************************
- */
-
-/***********************************************************************/
-/*                                                                     */
-/*   Program:    rt_linux.c                                            */
-/*   Created:    4/21/2006 1:17:38 PM                                  */
-/*   Author:     Wu Xi-Kun                                             */
-/*   Comments:   `description`                                         */
-/*                                                                     */
-/*---------------------------------------------------------------------*/
-/*                                                                     */
-/* History:                                                            */
-/*    Revision 1.1 4/21/2006 1:17:38 PM  xsikun                        */
-/*    Initial revision                                                 */
-/*                                                                     */
-/***********************************************************************/
-
-#include "rtmp_type.h"
-#include <linux/module.h>
-#include <linux/version.h>
-#include <linux/kernel.h>
-
-#include <linux/spinlock.h>
-#include <linux/init.h>
-#include <linux/string.h>
-#include <linux/timer.h>
-#include <linux/errno.h>
-#include <linux/slab.h>
-#include <linux/interrupt.h>
-#include <linux/pci.h>
-#include <linux/netdevice.h>
-#include <linux/etherdevice.h>
-#include <linux/skbuff.h>
-#include <linux/ethtool.h>
-#include <linux/wireless.h>
-#include <linux/proc_fs.h>
-#include <linux/delay.h>
-#include <linux/if_arp.h>
-#include <linux/ctype.h>
-#include <linux/vmalloc.h>
-
-
-#include <net/iw_handler.h>
-
-// load firmware
-#define __KERNEL_SYSCALLS__
-#include <linux/unistd.h>
-#include <asm/uaccess.h>
-
-
-#define MEM_ALLOC_FLAG      (GFP_ATOMIC) //(GFP_DMA | GFP_ATOMIC)
-
-#ifndef IFNAMSIZ
-#define IFNAMSIZ 16
-#endif
-
-//#define CONFIG_CKIP_SUPPORT
-
-#undef __inline
-#define __inline          static inline
-
-typedef int (*HARD_START_XMIT_FUNC)(struct sk_buff *skb, struct net_device *net_dev);
-
-// add by kathy
-
-#ifdef RT2870
-#define STA_PROFILE_PATH                       "/etc/Wireless/RT2870STA/RT2870STA.dat"
-#define STA_RT2870_IMAGE_FILE_NAME  "/etc/Wireless/RT2870STA/rt2870.bin"
-#define STA_NIC_DEVICE_NAME                    "RT2870STA"
-#define STA_DRIVER_VERSION                     "2.0.1.0"
-#endif // RT2870 //
-
-#define RTMP_TIME_AFTER(a,b)           \
-       (typecheck(unsigned long, (unsigned long)a) && \
-        typecheck(unsigned long, (unsigned long)b) && \
-        ((long)(b) - (long)(a) < 0))
-
-#define RTMP_TIME_AFTER_EQ(a,b)        \
-       (typecheck(unsigned long, (unsigned long)a) && \
-        typecheck(unsigned long, (unsigned long)b) && \
-        ((long)(a) - (long)(b) >= 0))
-#define RTMP_TIME_BEFORE(a,b)  RTMP_TIME_AFTER_EQ(b,a)
-
-#define RT_MOD_INC_USE_COUNT() \
-       if (!try_module_get(THIS_MODULE)) \
-       { \
-               DBGPRINT(RT_DEBUG_ERROR, ("%s: cannot reserve module\n", __func__)); \
-               return -1; \
-       }
-
-#define RT_MOD_DEC_USE_COUNT() module_put(THIS_MODULE);
-
-#define OS_HZ                  HZ
-
-#define ETH_LENGTH_OF_ADDRESS  6
-
-#define IN
-#define OUT
-
-#define NDIS_STATUS                             INT
-#define NDIS_STATUS_SUCCESS                     0x00
-#define NDIS_STATUS_FAILURE                     0x01
-#define NDIS_STATUS_INVALID_DATA                               0x02
-#define NDIS_STATUS_RESOURCES                   0x03
-
-#define MIN_NET_DEVICE_FOR_AID                 0x00            //0x00~0x3f
-#define MIN_NET_DEVICE_FOR_MBSSID              0x00            //0x00,0x10,0x20,0x30
-#define MIN_NET_DEVICE_FOR_WDS                 0x10            //0x40,0x50,0x60,0x70
-#define MIN_NET_DEVICE_FOR_APCLI               0x20
-#define MIN_NET_DEVICE_FOR_MESH                        0x30
-#define MIN_NET_DEVICE_FOR_DLS                 0x40
-
-#define NDIS_PACKET_TYPE_DIRECTED              0
-#define NDIS_PACKET_TYPE_MULTICAST             1
-#define NDIS_PACKET_TYPE_BROADCAST             2
-#define NDIS_PACKET_TYPE_ALL_MULTICAST 3
-
-struct os_lock  {
-       spinlock_t              lock;
-       unsigned long   flags;
-};
-
-
-struct os_cookie {
-
-#ifdef RT2870
-       struct usb_device               *pUsb_Dev;
-
-       struct pid *            MLMEThr_pid;
-       struct pid *            RTUSBCmdThr_pid;
-       struct pid *            TimerQThr_pid;
-#endif // RT2870 //
-
-       struct tasklet_struct   rx_done_task;
-       struct tasklet_struct   mgmt_dma_done_task;
-       struct tasklet_struct   ac0_dma_done_task;
-       struct tasklet_struct   ac1_dma_done_task;
-       struct tasklet_struct   ac2_dma_done_task;
-       struct tasklet_struct   ac3_dma_done_task;
-       struct tasklet_struct   hcca_dma_done_task;
-       struct tasklet_struct   tbtt_task;
-#ifdef RT2870
-       struct tasklet_struct   null_frame_complete_task;
-       struct tasklet_struct   rts_frame_complete_task;
-       struct tasklet_struct   pspoll_frame_complete_task;
-#endif // RT2870 //
-
-
-       unsigned long                   apd_pid; //802.1x daemon pid
-       INT                                             ioctl_if_type;
-       INT                                     ioctl_if;
-};
-
-typedef struct _VIRTUAL_ADAPTER
-{
-       struct net_device               *RtmpDev;
-       struct net_device               *VirtualDev;
-} VIRTUAL_ADAPTER, PVIRTUAL_ADAPTER;
-
-#undef  ASSERT
-#define ASSERT(x)
-
-typedef struct os_cookie       * POS_COOKIE;
-typedef struct pci_dev                 * PPCI_DEV;
-typedef struct net_device      * PNET_DEV;
-typedef void                           * PNDIS_PACKET;
-typedef char                           NDIS_PACKET;
-typedef PNDIS_PACKET           * PPNDIS_PACKET;
-typedef        dma_addr_t                      NDIS_PHYSICAL_ADDRESS;
-typedef        dma_addr_t                      * PNDIS_PHYSICAL_ADDRESS;
-typedef spinlock_t                     NDIS_SPIN_LOCK;
-typedef struct timer_list      NDIS_MINIPORT_TIMER;
-typedef void                           * NDIS_HANDLE;
-typedef char                           * PNDIS_BUFFER;
-
-
-
-void hex_dump(char *str, unsigned char *pSrcBufVA, unsigned int SrcBufLen);
-
-dma_addr_t linux_pci_map_single(void *handle, void *ptr, size_t size, int sd_idx, int direction);
-void linux_pci_unmap_single(void *handle, dma_addr_t dma_addr, size_t size, int direction);
-
-
-////////////////////////////////////////
-// MOVE TO rtmp.h ?
-/////////////////////////////////////////
-#define PKTSRC_NDIS             0x7f
-#define PKTSRC_DRIVER           0x0f
-#define PRINT_MAC(addr)        \
-       addr[0], addr[1], addr[2], addr[3], addr[4], addr[5]
-
-
-#define RT2860_PCI_DEVICE_ID           0x0601
-
-#ifdef RT2870
-#define PCI_MAP_SINGLE(_handle, _ptr, _size, _dir) (ULONG)0
-
-#define PCI_UNMAP_SINGLE(_handle, _ptr, _size, _dir)
-#endif // RT2870 //
-
-
-#define BEACON_FRAME_DMA_CACHE_WBACK(_ptr, _size)      \
-       dma_cache_wback(_ptr, _size)
-
-
-//////////////////////////////////////////
-//
-//////////////////////////////////////////
-
-
-#define NdisMIndicateStatus(_w, _x, _y, _z)
-
-
-typedef struct timer_list      RTMP_OS_TIMER;
-
-#ifdef RT2870
-/* ----------------- Timer Related MARCO ---------------*/
-// In RT2870, we have a lot of timer functions and will read/write register, it's
-//     not allowed in Linux USB sub-system to do it ( because of sleep issue when submit
-//  to ctrl pipe). So we need a wrapper function to take care it.
-
-typedef VOID (*RT2870_TIMER_HANDLE)(
-       IN  PVOID   SystemSpecific1,
-       IN  PVOID   FunctionContext,
-       IN  PVOID   SystemSpecific2,
-       IN  PVOID   SystemSpecific3);
-#endif // RT2870 //
-
-
-typedef struct  _RALINK_TIMER_STRUCT    {
-    RTMP_OS_TIMER              TimerObj;       // Ndis Timer object
-       BOOLEAN                         Valid;                  // Set to True when call RTMPInitTimer
-    BOOLEAN             State;          // True if timer cancelled
-    BOOLEAN                    PeriodicType;   // True if timer is periodic timer
-    BOOLEAN             Repeat;         // True if periodic timer
-    ULONG               TimerValue;     // Timer value in milliseconds
-       ULONG                           cookie;                 // os specific object
-#ifdef RT2870
-       RT2870_TIMER_HANDLE     handle;
-       void                            *pAd;
-#endif // RT2870 //
-}   RALINK_TIMER_STRUCT, *PRALINK_TIMER_STRUCT;
-
-
-#ifdef RT2870
-
-typedef enum _RT2870_KERNEL_THREAD_STATUS_
-{
-       RT2870_THREAD_UNKNOWN = 0,
-       RT2870_THREAD_INITED = 1,
-       RT2870_THREAD_RUNNING = 2,
-       RT2870_THREAD_STOPED = 4,
-}RT2870_KERNEL_THREAD_STATUS;
-
-#define RT2870_THREAD_CAN_DO_INSERT            (RT2870_THREAD_INITED |RT2870_THREAD_RUNNING)
-
-typedef struct _RT2870_TIMER_ENTRY_
-{
-       RALINK_TIMER_STRUCT                     *pRaTimer;
-       struct _RT2870_TIMER_ENTRY_     *pNext;
-}RT2870_TIMER_ENTRY;
-
-
-#define TIMER_QUEUE_SIZE_MAX   128
-typedef struct _RT2870_TIMER_QUEUE_
-{
-       unsigned int            status;
-       UCHAR                           *pTimerQPoll;
-       RT2870_TIMER_ENTRY      *pQPollFreeList;
-       RT2870_TIMER_ENTRY      *pQHead;
-       RT2870_TIMER_ENTRY      *pQTail;
-}RT2870_TIMER_QUEUE;
-#endif // RT2870 //
-
-
-//#define DBG  1
-
-//
-//  MACRO for debugging information
-//
-
-#ifdef DBG
-extern ULONG    RTDebugLevel;
-
-#define DBGPRINT_RAW(Level, Fmt)    \
-{                                   \
-    if (Level <= RTDebugLevel)      \
-    {                               \
-        printk Fmt;               \
-    }                               \
-}
-
-#define DBGPRINT(Level, Fmt)    DBGPRINT_RAW(Level, Fmt)
-
-
-#define DBGPRINT_ERR(Fmt)           \
-{                                   \
-    printk("ERROR!!! ");          \
-    printk Fmt;                  \
-}
-
-#define DBGPRINT_S(Status, Fmt)                \
-{                                                                      \
-       printk Fmt;                                     \
-}
-
-
-#else
-#define DBGPRINT(Level, Fmt)
-#define DBGPRINT_RAW(Level, Fmt)
-#define DBGPRINT_S(Status, Fmt)
-#define DBGPRINT_ERR(Fmt)
-#endif
-
-
-//
-//  spin_lock enhanced for Nested spin lock
-//
-#define NdisAllocateSpinLock(__lock)      \
-{                                       \
-    spin_lock_init((spinlock_t *)(__lock));               \
-}
-
-#define NdisFreeSpinLock(lock)          \
-{                                       \
-}
-
-
-#define RTMP_SEM_LOCK(__lock)                                  \
-{                                                                                              \
-       spin_lock_bh((spinlock_t *)(__lock));                           \
-}
-
-#define RTMP_SEM_UNLOCK(__lock)                                        \
-{                                                                                              \
-       spin_unlock_bh((spinlock_t *)(__lock));                         \
-}
-
-// sample, use semaphore lock to replace IRQ lock, 2007/11/15
-#define RTMP_IRQ_LOCK(__lock, __irqflags)                      \
-{                                                                                                      \
-       __irqflags = 0;                                                                 \
-       spin_lock_bh((spinlock_t *)(__lock));                   \
-       pAd->irq_disabled |= 1; \
-}
-
-#define RTMP_IRQ_UNLOCK(__lock, __irqflag)                     \
-{                                                                                                      \
-       pAd->irq_disabled &= 0; \
-       spin_unlock_bh((spinlock_t *)(__lock));                 \
-}
-
-#define RTMP_INT_LOCK(__lock, __irqflags)                      \
-{                                                                                                      \
-       spin_lock_irqsave((spinlock_t *)__lock, __irqflags);    \
-}
-
-#define RTMP_INT_UNLOCK(__lock, __irqflag)                     \
-{                                                                                                      \
-       spin_unlock_irqrestore((spinlock_t *)(__lock), ((unsigned long)__irqflag));     \
-}
-
-#ifdef RT2870
-#define RTMP_IO_READ32(_A, _R, _pV)                                                            \
-       RTUSBReadMACRegister(_A, _R, _pV)
-
-#define RTMP_IO_READ8(_A, _R, _pV)                                                             \
-{                                                                                                                              \
-}
-
-#define RTMP_IO_WRITE32(_A, _R, _V)                                                            \
-       RTUSBWriteMACRegister(_A, _R, _V)
-
-
-#define RTMP_IO_WRITE8(_A, _R, _V)                                                             \
-{                                                                                                                              \
-       USHORT  _Val = _V;                                                                                      \
-       RTUSBSingleWrite(_A, _R, _Val);                                                         \
-}
-
-
-#define RTMP_IO_WRITE16(_A, _R, _V)                                                            \
-{                                                                                                                              \
-       RTUSBSingleWrite(_A, _R, _V);                                                           \
-}
-#endif // RT2870 //
-
-#ifndef wait_event_interruptible_timeout
-#define __wait_event_interruptible_timeout(wq, condition, ret) \
-do { \
-        wait_queue_t __wait; \
-        init_waitqueue_entry(&__wait, current); \
-        add_wait_queue(&wq, &__wait); \
-        for (;;) { \
-                set_current_state(TASK_INTERRUPTIBLE); \
-                if (condition) \
-                        break; \
-                if (!signal_pending(current)) { \
-                        ret = schedule_timeout(ret); \
-                        if (!ret) \
-                                break; \
-                        continue; \
-                } \
-                ret = -ERESTARTSYS; \
-                break; \
-        } \
-        current->state = TASK_RUNNING; \
-        remove_wait_queue(&wq, &__wait); \
-} while (0)
-
-#define wait_event_interruptible_timeout(wq, condition, timeout) \
-({ \
-        long __ret = timeout; \
-        if (!(condition)) \
-                __wait_event_interruptible_timeout(wq, condition, __ret); \
-        __ret; \
-})
-#endif
-#define ONE_TICK 1
-#define OS_WAIT(_time) \
-{      int _i; \
-       long _loop = ((_time)/(1000/OS_HZ)) > 0 ? ((_time)/(1000/OS_HZ)) : 1;\
-       wait_queue_head_t _wait; \
-       init_waitqueue_head(&_wait); \
-       for (_i=0; _i<(_loop); _i++) \
-               wait_event_interruptible_timeout(_wait, 0, ONE_TICK); }
-
-
-typedef void (*TIMER_FUNCTION)(unsigned long);
-
-#define COPY_MAC_ADDR(Addr1, Addr2)             memcpy((Addr1), (Addr2), MAC_ADDR_LEN)
-
-#define MlmeAllocateMemory(_pAd, _ppVA) os_alloc_mem(_pAd, _ppVA, MGMT_DMA_BUFFER_SIZE)
-#define MlmeFreeMemory(_pAd, _pVA)     os_free_mem(_pAd, _pVA)
-
-
-#ifdef RT2870
-#define BUILD_TIMER_FUNCTION(_func)                                                                                                    \
-void linux_##_func(unsigned long data)                                                                                         \
-{                                                                                                                                                                      \
-       PRALINK_TIMER_STRUCT    _pTimer = (PRALINK_TIMER_STRUCT)data;                                   \
-       RT2870_TIMER_ENTRY              *_pQNode;                                                                                               \
-       RTMP_ADAPTER                    *_pAd;                                                                                                  \
-                                                                                                                                                               \
-       _pTimer->handle = _func;                                                                                                                        \
-       _pAd = (RTMP_ADAPTER *)_pTimer->pAd;                                                                                            \
-       _pQNode = RT2870_TimerQ_Insert(_pAd, _pTimer);                                                                  \
-       if ((_pQNode == NULL) && (_pAd->TimerQ.status & RT2870_THREAD_CAN_DO_INSERT))   \
-               RTMP_OS_Add_Timer(&_pTimer->TimerObj, HZ);                                                      \
-}
-#endif // RT2870 //
-
-
-#define DECLARE_TIMER_FUNCTION(_func)                  \
-void linux_##_func(unsigned long data)
-
-#define GET_TIMER_FUNCTION(_func)                              \
-               linux_##_func
-
-DECLARE_TIMER_FUNCTION(MlmePeriodicExec);
-DECLARE_TIMER_FUNCTION(MlmeRssiReportExec);
-DECLARE_TIMER_FUNCTION(AsicRxAntEvalTimeout);
-DECLARE_TIMER_FUNCTION(APSDPeriodicExec);
-DECLARE_TIMER_FUNCTION(AsicRfTuningExec);
-#ifdef RT2870
-DECLARE_TIMER_FUNCTION(BeaconUpdateExec);
-#endif // RT2870 //
-
-DECLARE_TIMER_FUNCTION(BeaconTimeout);
-DECLARE_TIMER_FUNCTION(ScanTimeout);
-DECLARE_TIMER_FUNCTION(AuthTimeout);
-DECLARE_TIMER_FUNCTION(AssocTimeout);
-DECLARE_TIMER_FUNCTION(ReassocTimeout);
-DECLARE_TIMER_FUNCTION(DisassocTimeout);
-DECLARE_TIMER_FUNCTION(LinkDownExec);
-DECLARE_TIMER_FUNCTION(StaQuickResponeForRateUpExec);
-DECLARE_TIMER_FUNCTION(WpaDisassocApAndBlockAssoc);
-DECLARE_TIMER_FUNCTION(PsPollWakeExec);
-DECLARE_TIMER_FUNCTION(RadioOnExec);
-
-void RTMP_GetCurrentSystemTime(LARGE_INTEGER *time);
-
-
-/*
- * packet helper
- *     - convert internal rt packet to os packet or
- *             os packet to rt packet
- */
-#define RTPKT_TO_OSPKT(_p)             ((struct sk_buff *)(_p))
-#define OSPKT_TO_RTPKT(_p)             ((PNDIS_PACKET)(_p))
-
-#define GET_OS_PKT_DATAPTR(_pkt) \
-               (RTPKT_TO_OSPKT(_pkt)->data)
-
-#define GET_OS_PKT_LEN(_pkt) \
-               (RTPKT_TO_OSPKT(_pkt)->len)
-
-#define GET_OS_PKT_DATATAIL(_pkt) \
-               (RTPKT_TO_OSPKT(_pkt)->tail)
-
-#define GET_OS_PKT_HEAD(_pkt) \
-               (RTPKT_TO_OSPKT(_pkt)->head)
-
-#define GET_OS_PKT_END(_pkt) \
-               (RTPKT_TO_OSPKT(_pkt)->end)
-
-#define GET_OS_PKT_NETDEV(_pkt) \
-               (RTPKT_TO_OSPKT(_pkt)->dev)
-
-#define GET_OS_PKT_TYPE(_pkt) \
-               (RTPKT_TO_OSPKT(_pkt))
-
-#define GET_OS_PKT_NEXT(_pkt) \
-               (RTPKT_TO_OSPKT(_pkt)->next)
-
-
-#define OS_NTOHS(_Val) \
-               (ntohs(_Val))
-#define OS_HTONS(_Val) \
-               (htons(_Val))
-#define OS_NTOHL(_Val) \
-               (ntohl(_Val))
-#define OS_HTONL(_Val) \
-               (htonl(_Val))
-
-/* statistics counter */
-#define STATS_INC_RX_PACKETS(_pAd, _dev)
-#define STATS_INC_TX_PACKETS(_pAd, _dev)
-
-#define STATS_INC_RX_BYTESS(_pAd, _dev, len)
-#define STATS_INC_TX_BYTESS(_pAd, _dev, len)
-
-#define STATS_INC_RX_ERRORS(_pAd, _dev)
-#define STATS_INC_TX_ERRORS(_pAd, _dev)
-
-#define STATS_INC_RX_DROPPED(_pAd, _dev)
-#define STATS_INC_TX_DROPPED(_pAd, _dev)
-
-
-#define CB_OFF  10
-
-
-//   check DDK NDIS_PACKET data structure and find out only MiniportReservedEx[0..7] can be used by our driver without
-//   ambiguity. Fields after pPacket->MiniportReservedEx[8] may be used by other wrapper layer thus crashes the driver
-//
-
-// User Priority
-#define RTMP_SET_PACKET_UP(_p, _prio)                  (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+0] = _prio)
-#define RTMP_GET_PACKET_UP(_p)                                 (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+0])
-
-// Fragment #
-#define RTMP_SET_PACKET_FRAGMENTS(_p, _num)            (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+1] = _num)
-#define RTMP_GET_PACKET_FRAGMENTS(_p)                  (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+1])
-
-// 0x0 ~0x7f: TX to AP's own BSS which has the specified AID. if AID>127, set bit 7 in RTMP_SET_PACKET_EMACTAB too.
-//(this value also as MAC(on-chip WCID) table index)
-// 0x80~0xff: TX to a WDS link. b0~6: WDS index
-#define RTMP_SET_PACKET_WCID(_p, _wdsidx)              (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+2] = _wdsidx)
-#define RTMP_GET_PACKET_WCID(_p)                       ((UCHAR)(RTPKT_TO_OSPKT(_p)->cb[CB_OFF+2]))
-
-// 0xff: PKTSRC_NDIS, others: local TX buffer index. This value affects how to a packet
-#define RTMP_SET_PACKET_SOURCE(_p, _pktsrc)            (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+3] = _pktsrc)
-#define RTMP_GET_PACKET_SOURCE(_p)                     (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+3])
-
-// RTS/CTS-to-self protection method
-#define RTMP_SET_PACKET_RTS(_p, _num)                  (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+4] = _num)
-#define RTMP_GET_PACKET_RTS(_p)                        (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+4])
-// see RTMP_S(G)ET_PACKET_EMACTAB
-
-// TX rate index
-#define RTMP_SET_PACKET_TXRATE(_p, _rate)              (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+5] = _rate)
-#define RTMP_GET_PACKET_TXRATE(_p)                             (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+5])
-
-// From which Interface
-#define RTMP_SET_PACKET_IF(_p, _ifdx)          (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+6] = _ifdx)
-#define RTMP_GET_PACKET_IF(_p)                         (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+6])
-#define RTMP_SET_PACKET_NET_DEVICE_MBSSID(_p, _bss)            RTMP_SET_PACKET_IF((_p), (_bss))
-#define RTMP_SET_PACKET_NET_DEVICE_WDS(_p, _bss)               RTMP_SET_PACKET_IF((_p), ((_bss) + MIN_NET_DEVICE_FOR_WDS))
-#define RTMP_SET_PACKET_NET_DEVICE_APCLI(_p, _idx)     RTMP_SET_PACKET_IF((_p), ((_idx) + MIN_NET_DEVICE_FOR_APCLI))
-#define RTMP_SET_PACKET_NET_DEVICE_MESH(_p, _idx)      RTMP_SET_PACKET_IF((_p), ((_idx) + MIN_NET_DEVICE_FOR_MESH))
-#define RTMP_GET_PACKET_NET_DEVICE_MBSSID(_p)                  RTMP_GET_PACKET_IF((_p))
-#define RTMP_GET_PACKET_NET_DEVICE(_p)                                 RTMP_GET_PACKET_IF((_p))
-
-#define RTMP_SET_PACKET_MOREDATA(_p, _morebit)         (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+7] = _morebit)
-#define RTMP_GET_PACKET_MOREDATA(_p)                           (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+7])
-
-
-//
-//     Sepcific Pakcet Type definition
-//
-#define RTMP_PACKET_SPECIFIC_CB_OFFSET 11
-
-#define RTMP_PACKET_SPECIFIC_DHCP              0x01
-#define RTMP_PACKET_SPECIFIC_EAPOL             0x02
-#define RTMP_PACKET_SPECIFIC_IPV4              0x04
-#define RTMP_PACKET_SPECIFIC_WAI               0x08
-#define RTMP_PACKET_SPECIFIC_VLAN              0x10
-#define RTMP_PACKET_SPECIFIC_LLCSNAP   0x20
-
-//Specific
-#define RTMP_SET_PACKET_SPECIFIC(_p, _flg)             (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11] = _flg)
-
-//DHCP
-#define RTMP_SET_PACKET_DHCP(_p, _flg)                                                                                                         \
-                       do{                                                                                                                                                             \
-                               if (_flg)                                                                                                                                       \
-                                       (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11]) |= (RTMP_PACKET_SPECIFIC_DHCP);             \
-                               else                                                                                                                                            \
-                                       (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11]) &= (!RTMP_PACKET_SPECIFIC_DHCP);    \
-                       }while(0)
-#define RTMP_GET_PACKET_DHCP(_p)               (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11] & RTMP_PACKET_SPECIFIC_DHCP)
-
-//EAPOL
-#define RTMP_SET_PACKET_EAPOL(_p, _flg)                                                                                                        \
-                       do{                                                                                                                                                             \
-                               if (_flg)                                                                                                                                       \
-                                       (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11]) |= (RTMP_PACKET_SPECIFIC_EAPOL);            \
-                               else                                                                                                                                            \
-                                       (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11]) &= (!RTMP_PACKET_SPECIFIC_EAPOL);   \
-                       }while(0)
-#define RTMP_GET_PACKET_EAPOL(_p)              (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11] & RTMP_PACKET_SPECIFIC_EAPOL)
-
-//WAI
-#define RTMP_SET_PACKET_WAI(_p, _flg)                                                                                                          \
-                       do{                                                                                                                                                             \
-                               if (_flg)                                                                                                                                       \
-                                       (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11]) |= (RTMP_PACKET_SPECIFIC_WAI);              \
-                               else                                                                                                                                            \
-                                       (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11]) &= (!RTMP_PACKET_SPECIFIC_WAI);     \
-                       }while(0)
-#define RTMP_GET_PACKET_WAI(_p)                (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11] & RTMP_PACKET_SPECIFIC_WAI)
-
-#define RTMP_GET_PACKET_LOWRATE(_p)            (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11] & (RTMP_PACKET_SPECIFIC_EAPOL | RTMP_PACKET_SPECIFIC_DHCP | RTMP_PACKET_SPECIFIC_WAI))
-
-//VLAN
-#define RTMP_SET_PACKET_VLAN(_p, _flg)                                                                                                         \
-                       do{                                                                                                                                                             \
-                               if (_flg)                                                                                                                                       \
-                                       (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11]) |= (RTMP_PACKET_SPECIFIC_VLAN);             \
-                               else                                                                                                                                            \
-                                       (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11]) &= (!RTMP_PACKET_SPECIFIC_VLAN);    \
-                       }while(0)
-#define RTMP_GET_PACKET_VLAN(_p)               (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11] & RTMP_PACKET_SPECIFIC_VLAN)
-
-//LLC/SNAP
-#define RTMP_SET_PACKET_LLCSNAP(_p, _flg)                                                                                                      \
-                       do{                                                                                                                                                             \
-                               if (_flg)                                                                                                                                       \
-                                       (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11]) |= (RTMP_PACKET_SPECIFIC_LLCSNAP);          \
-                               else                                                                                                                                            \
-                                       (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11]) &= (!RTMP_PACKET_SPECIFIC_LLCSNAP);         \
-                       }while(0)
-
-#define RTMP_GET_PACKET_LLCSNAP(_p)            (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11] & RTMP_PACKET_SPECIFIC_LLCSNAP)
-
-// IP
-#define RTMP_SET_PACKET_IPV4(_p, _flg)                                                                                                         \
-                       do{                                                                                                                                                             \
-                               if (_flg)                                                                                                                                       \
-                                       (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11]) |= (RTMP_PACKET_SPECIFIC_IPV4);             \
-                               else                                                                                                                                            \
-                                       (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11]) &= (!RTMP_PACKET_SPECIFIC_IPV4);    \
-                       }while(0)
-
-#define RTMP_GET_PACKET_IPV4(_p)               (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11] & RTMP_PACKET_SPECIFIC_IPV4)
-
-// If this flag is set, it indicates that this EAPoL frame MUST be clear.
-#define RTMP_SET_PACKET_CLEAR_EAP_FRAME(_p, _flg)   (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+12] = _flg)
-#define RTMP_GET_PACKET_CLEAR_EAP_FRAME(_p)         (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+12])
-
-#define RTMP_SET_PACKET_5VT(_p, _flg)   (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+22] = _flg)
-#define RTMP_GET_PACKET_5VT(_p)         (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+22])
-
-#ifdef CONFIG_5VT_ENHANCE
-#define BRIDGE_TAG 0x35564252    // depends on 5VT define in br_input.c
-#endif
-
-
-#define NDIS_SET_PACKET_STATUS(_p, _status)
-
-
-#define GET_SG_LIST_FROM_PACKET(_p, _sc)       \
-    rt_get_sg_list_from_packet(_p, _sc)
-
-#define NdisMoveMemory(Destination, Source, Length) memmove(Destination, Source, Length)
-#define NdisZeroMemory(Destination, Length)         memset(Destination, 0, Length)
-#define NdisFillMemory(Destination, Length, Fill)   memset(Destination, Fill, Length)
-#define NdisEqualMemory(Source1, Source2, Length)   (!memcmp(Source1, Source2, Length))
-#define RTMPEqualMemory(Source1, Source2, Length)      (!memcmp(Source1, Source2, Length))
-
-
-#define RTMP_INC_REF(_A)               0
-#define RTMP_DEC_REF(_A)               0
-#define RTMP_GET_REF(_A)               0
-
-
-
-/*
- * ULONG
- * RTMP_GetPhysicalAddressLow(
- *   IN NDIS_PHYSICAL_ADDRESS  PhysicalAddress);
- */
-#define RTMP_GetPhysicalAddressLow(PhysicalAddress)            (PhysicalAddress)
-
-/*
- * ULONG
- * RTMP_GetPhysicalAddressHigh(
- *   IN NDIS_PHYSICAL_ADDRESS  PhysicalAddress);
- */
-#define RTMP_GetPhysicalAddressHigh(PhysicalAddress)           (0)
-
-/*
- * VOID
- * RTMP_SetPhysicalAddressLow(
- *   IN NDIS_PHYSICAL_ADDRESS  PhysicalAddress,
- *   IN ULONG  Value);
- */
-#define RTMP_SetPhysicalAddressLow(PhysicalAddress, Value)     \
-                       PhysicalAddress = Value;
-
-/*
- * VOID
- * RTMP_SetPhysicalAddressHigh(
- *   IN NDIS_PHYSICAL_ADDRESS  PhysicalAddress,
- *   IN ULONG  Value);
- */
-#define RTMP_SetPhysicalAddressHigh(PhysicalAddress, Value)
-
-
-//CONTAINING_RECORD(pEntry, NDIS_PACKET, MiniportReservedEx);
-#define QUEUE_ENTRY_TO_PACKET(pEntry) \
-       (PNDIS_PACKET)(pEntry)
-
-#define PACKET_TO_QUEUE_ENTRY(pPacket) \
-       (PQUEUE_ENTRY)(pPacket)
-
-
-#ifndef CONTAINING_RECORD
-#define CONTAINING_RECORD(address, type, field)                        \
-((type *)((PCHAR)(address) - offsetof(type, field)))
-#endif
-
-
-#define RELEASE_NDIS_PACKET(_pAd, _pPacket, _Status)                    \
-{                                                                       \
-        RTMPFreeNdisPacket(_pAd, _pPacket);                             \
-}
-
-
-#define SWITCH_PhyAB(_pAA, _pBB)    \
-{                                                                           \
-    ULONG      AABasePaHigh;                           \
-    ULONG      AABasePaLow;                           \
-    ULONG      BBBasePaHigh;                           \
-    ULONG      BBBasePaLow;                           \
-    BBBasePaHigh = RTMP_GetPhysicalAddressHigh(_pBB);                                                 \
-    BBBasePaLow = RTMP_GetPhysicalAddressLow(_pBB);                                                 \
-    AABasePaHigh = RTMP_GetPhysicalAddressHigh(_pAA);                                                 \
-    AABasePaLow = RTMP_GetPhysicalAddressLow(_pAA);                                                 \
-    RTMP_SetPhysicalAddressHigh(_pAA, BBBasePaHigh);                                                 \
-    RTMP_SetPhysicalAddressLow(_pAA, BBBasePaLow);                                                 \
-    RTMP_SetPhysicalAddressHigh(_pBB, AABasePaHigh);                                                 \
-    RTMP_SetPhysicalAddressLow(_pBB, AABasePaLow);                                                 \
-}
-
-
-#define NdisWriteErrorLogEntry(_a, _b, _c, _d)
-#define NdisMAllocateMapRegisters(_a, _b, _c, _d, _e)          NDIS_STATUS_SUCCESS
-
-
-#define NdisAcquireSpinLock            RTMP_SEM_LOCK
-#define NdisReleaseSpinLock            RTMP_SEM_UNLOCK
-
-static inline void NdisGetSystemUpTime(ULONG *time)
-{
-       *time = jiffies;
-}
-
-//pPacket = CONTAINING_RECORD(pEntry, NDIS_PACKET, MiniportReservedEx);
-#define QUEUE_ENTRY_TO_PKT(pEntry) \
-               ((PNDIS_PACKET) (pEntry))
-
-int rt28xx_packet_xmit(struct sk_buff *skb);
-
-
-
-void rtmp_os_thread_init(PUCHAR pThreadName, PVOID pNotify);
-
-
-
+#include "../../rt2870/rt_linux.h"
index 33e3c5b72ef1049c850f372c99cabeb3a4d736f5..c8bcd4029c3c529f22161b7943e69c9953fd6d4e 100644 (file)
@@ -1,1040 +1 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify  *
- * it under the terms of the GNU General Public License as published by  *
- * the Free Software Foundation; either version 2 of the License, or     *
- * (at your option) any later version.                                   *
- *                                                                       *
- * 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.                          *
- *                                                                       *
- * You should have received a copy of the GNU General Public License     *
- * along with this program; if not, write to the                         *
- * Free Software Foundation, Inc.,                                       *
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- *                                                                       *
- *************************************************************************
-
-    Module Name:
-    rt_main_dev.c
-
-    Abstract:
-    Create and register network interface.
-
-    Revision History:
-    Who         When            What
-    --------    ----------      ----------------------------------------------
-       Sample          Mar/21/07               Merge RT2870 and RT2860 drivers.
-*/
-
-#include "rt_config.h"
-
-#define FORTY_MHZ_INTOLERANT_INTERVAL  (60*1000) // 1 min
-
-/*---------------------------------------------------------------------*/
-/* Private Variables Used                                              */
-/*---------------------------------------------------------------------*/
-//static RALINK_TIMER_STRUCT     PeriodicTimer;
-
-char *mac = "";                   // default 00:00:00:00:00:00
-char *hostname = "";
-module_param (mac, charp, 0);
-MODULE_PARM_DESC (mac, "rt28xx: wireless mac addr");
-
-
-/*---------------------------------------------------------------------*/
-/* Prototypes of Functions Used                                        */
-/*---------------------------------------------------------------------*/
-extern BOOLEAN ba_reordering_resource_init(PRTMP_ADAPTER pAd, int num);
-extern void ba_reordering_resource_release(PRTMP_ADAPTER pAd);
-extern NDIS_STATUS NICLoadRateSwitchingParams(IN PRTMP_ADAPTER pAd);
-
-
-// public function prototype
-INT __devinit rt28xx_probe(IN void *_dev_p, IN void *_dev_id_p,
-                                                       IN UINT argc, OUT PRTMP_ADAPTER *ppAd);
-
-// private function prototype
-static int rt28xx_init(IN struct net_device *net_dev);
-INT rt28xx_send_packets(IN struct sk_buff *skb_p, IN struct net_device *net_dev);
-
-static void CfgInitHook(PRTMP_ADAPTER pAd);
-
-extern const struct iw_handler_def rt28xx_iw_handler_def;
-
-#if WIRELESS_EXT >= 12
-// This function will be called when query /proc
-struct iw_statistics *rt28xx_get_wireless_stats(
-    IN struct net_device *net_dev);
-#endif
-
-struct net_device_stats *RT28xx_get_ether_stats(
-    IN  struct net_device *net_dev);
-
-/*
-========================================================================
-Routine Description:
-    Close raxx interface.
-
-Arguments:
-       *net_dev                        the raxx interface pointer
-
-Return Value:
-    0                                  Open OK
-       otherwise                       Open Fail
-
-Note:
-       1. if open fail, kernel will not call the close function.
-       2. Free memory for
-               (1) Mlme Memory Handler:                MlmeHalt()
-               (2) TX & RX:                                    RTMPFreeTxRxRingMemory()
-               (3) BA Reordering:                              ba_reordering_resource_release()
-========================================================================
-*/
-int MainVirtualIF_close(IN struct net_device *net_dev)
-{
-    RTMP_ADAPTER *pAd = net_dev->ml_priv;
-
-       // Sanity check for pAd
-       if (pAd == NULL)
-               return 0; // close ok
-
-       netif_carrier_off(pAd->net_dev);
-       netif_stop_queue(pAd->net_dev);
-
-
-
-       VIRTUAL_IF_DOWN(pAd);
-
-       RT_MOD_DEC_USE_COUNT();
-
-       return 0; // close ok
-}
-
-/*
-========================================================================
-Routine Description:
-    Open raxx interface.
-
-Arguments:
-       *net_dev                        the raxx interface pointer
-
-Return Value:
-    0                                  Open OK
-       otherwise                       Open Fail
-
-Note:
-       1. if open fail, kernel will not call the close function.
-       2. Free memory for
-               (1) Mlme Memory Handler:                MlmeHalt()
-               (2) TX & RX:                                    RTMPFreeTxRxRingMemory()
-               (3) BA Reordering:                              ba_reordering_resource_release()
-========================================================================
-*/
-int MainVirtualIF_open(IN struct net_device *net_dev)
-{
-    RTMP_ADAPTER *pAd = net_dev->ml_priv;
-
-       // Sanity check for pAd
-       if (pAd == NULL)
-               return 0; // close ok
-
-       if (VIRTUAL_IF_UP(pAd) != 0)
-               return -1;
-
-       // increase MODULE use count
-       RT_MOD_INC_USE_COUNT();
-
-       netif_start_queue(net_dev);
-       netif_carrier_on(net_dev);
-       netif_wake_queue(net_dev);
-
-       return 0;
-}
-
-/*
-========================================================================
-Routine Description:
-    Close raxx interface.
-
-Arguments:
-       *net_dev                        the raxx interface pointer
-
-Return Value:
-    0                                  Open OK
-       otherwise                       Open Fail
-
-Note:
-       1. if open fail, kernel will not call the close function.
-       2. Free memory for
-               (1) Mlme Memory Handler:                MlmeHalt()
-               (2) TX & RX:                                    RTMPFreeTxRxRingMemory()
-               (3) BA Reordering:                              ba_reordering_resource_release()
-========================================================================
-*/
-int rt28xx_close(IN PNET_DEV dev)
-{
-       struct net_device * net_dev = (struct net_device *)dev;
-    RTMP_ADAPTER       *pAd = net_dev->ml_priv;
-       BOOLEAN                 Cancelled = FALSE;
-       UINT32                  i = 0;
-#ifdef RT2870
-       DECLARE_WAIT_QUEUE_HEAD(unlink_wakeup);
-       DECLARE_WAITQUEUE(wait, current);
-
-       //RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_REMOVE_IN_PROGRESS);
-#endif // RT2870 //
-
-
-    DBGPRINT(RT_DEBUG_TRACE, ("===> rt28xx_close\n"));
-
-       // Sanity check for pAd
-       if (pAd == NULL)
-               return 0; // close ok
-
-       {
-
-               // If dirver doesn't wake up firmware here,
-               // NICLoadFirmware will hang forever when interface is up again.
-               if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_DOZE))
-        {
-                   AsicForceWakeup(pAd, TRUE);
-        }
-
-               if (INFRA_ON(pAd) &&
-                       (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NIC_NOT_EXIST)))
-               {
-                       MLME_DISASSOC_REQ_STRUCT        DisReq;
-                       MLME_QUEUE_ELEM *MsgElem = (MLME_QUEUE_ELEM *) kmalloc(sizeof(MLME_QUEUE_ELEM), MEM_ALLOC_FLAG);
-
-                       COPY_MAC_ADDR(DisReq.Addr, pAd->CommonCfg.Bssid);
-                       DisReq.Reason =  REASON_DEAUTH_STA_LEAVING;
-
-                       MsgElem->Machine = ASSOC_STATE_MACHINE;
-                       MsgElem->MsgType = MT2_MLME_DISASSOC_REQ;
-                       MsgElem->MsgLen = sizeof(MLME_DISASSOC_REQ_STRUCT);
-                       NdisMoveMemory(MsgElem->Msg, &DisReq, sizeof(MLME_DISASSOC_REQ_STRUCT));
-
-                       // Prevent to connect AP again in STAMlmePeriodicExec
-                       pAd->MlmeAux.AutoReconnectSsidLen= 32;
-                       NdisZeroMemory(pAd->MlmeAux.AutoReconnectSsid, pAd->MlmeAux.AutoReconnectSsidLen);
-
-                       pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_OID_DISASSOC;
-                       MlmeDisassocReqAction(pAd, MsgElem);
-                       kfree(MsgElem);
-
-                       RTMPusecDelay(1000);
-               }
-
-#ifdef RT2870
-       RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_REMOVE_IN_PROGRESS);
-#endif // RT2870 //
-
-#ifdef CCX_SUPPORT
-               RTMPCancelTimer(&pAd->StaCfg.LeapAuthTimer, &Cancelled);
-#endif
-
-               RTMPCancelTimer(&pAd->StaCfg.StaQuickResponeForRateUpTimer, &Cancelled);
-               RTMPCancelTimer(&pAd->StaCfg.WpaDisassocAndBlockAssocTimer, &Cancelled);
-
-               MlmeRadioOff(pAd);
-       }
-
-       RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS);
-
-       for (i = 0 ; i < NUM_OF_TX_RING; i++)
-       {
-               while (pAd->DeQueueRunning[i] == TRUE)
-               {
-                       printk("Waiting for TxQueue[%d] done..........\n", i);
-                       RTMPusecDelay(1000);
-               }
-       }
-
-#ifdef RT2870
-       // ensure there are no more active urbs.
-       add_wait_queue (&unlink_wakeup, &wait);
-       pAd->wait = &unlink_wakeup;
-
-       // maybe wait for deletions to finish.
-       i = 0;
-       //while((i < 25) && atomic_read(&pAd->PendingRx) > 0)
-       while(i < 25)
-       {
-               unsigned long IrqFlags;
-
-               RTMP_IRQ_LOCK(&pAd->BulkInLock, IrqFlags);
-               if (pAd->PendingRx == 0)
-               {
-                       RTMP_IRQ_UNLOCK(&pAd->BulkInLock, IrqFlags);
-                       break;
-               }
-               RTMP_IRQ_UNLOCK(&pAd->BulkInLock, IrqFlags);
-
-               msleep(UNLINK_TIMEOUT_MS);      //Time in millisecond
-               i++;
-       }
-       pAd->wait = NULL;
-       remove_wait_queue (&unlink_wakeup, &wait);
-#endif // RT2870 //
-
-#ifdef RT2870
-       // We need clear timerQ related structure before exits of the timer thread.
-       RT2870_TimerQ_Exit(pAd);
-       // Close kernel threads or tasklets
-       RT28xxThreadTerminate(pAd);
-#endif // RT2870 //
-
-       // Stop Mlme state machine
-       MlmeHalt(pAd);
-
-       // Close kernel threads or tasklets
-       kill_thread_task(pAd);
-
-       MacTableReset(pAd);
-
-
-       MeasureReqTabExit(pAd);
-       TpcReqTabExit(pAd);
-
-
-
-
-       // Free Ring or USB buffers
-       RTMPFreeTxRxRingMemory(pAd);
-
-       RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS);
-
-       // Free BA reorder resource
-       ba_reordering_resource_release(pAd);
-
-       RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_START_UP);
-
-       return 0; // close ok
-} /* End of rt28xx_close */
-
-static int rt28xx_init(IN struct net_device *net_dev)
-{
-       PRTMP_ADAPTER                   pAd = net_dev->ml_priv;
-       UINT                                    index;
-       UCHAR                                   TmpPhy;
-       NDIS_STATUS                             Status;
-       UINT32          MacCsr0 = 0;
-
-       // Allocate BA Reordering memory
-       ba_reordering_resource_init(pAd, MAX_REORDERING_MPDU_NUM);
-
-       // Make sure MAC gets ready.
-       index = 0;
-       do
-       {
-               RTMP_IO_READ32(pAd, MAC_CSR0, &MacCsr0);
-               pAd->MACVersion = MacCsr0;
-
-               if ((pAd->MACVersion != 0x00) && (pAd->MACVersion != 0xFFFFFFFF))
-                       break;
-
-               RTMPusecDelay(10);
-       } while (index++ < 100);
-
-       DBGPRINT(RT_DEBUG_TRACE, ("MAC_CSR0  [ Ver:Rev=0x%08x]\n", pAd->MACVersion));
-/*Iverson patch PCIE L1 issue */
-
-       // Disable DMA
-       RT28XXDMADisable(pAd);
-
-
-       // Load 8051 firmware
-       Status = NICLoadFirmware(pAd);
-       if (Status != NDIS_STATUS_SUCCESS)
-       {
-               DBGPRINT_ERR(("NICLoadFirmware failed, Status[=0x%08x]\n", Status));
-               goto err1;
-       }
-
-       NICLoadRateSwitchingParams(pAd);
-
-       // Disable interrupts here which is as soon as possible
-       // This statement should never be true. We might consider to remove it later
-
-       Status = RTMPAllocTxRxRingMemory(pAd);
-       if (Status != NDIS_STATUS_SUCCESS)
-       {
-               DBGPRINT_ERR(("RTMPAllocDMAMemory failed, Status[=0x%08x]\n", Status));
-               goto err1;
-       }
-
-       RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_IN_USE);
-
-       // initialize MLME
-       //
-
-       Status = MlmeInit(pAd);
-       if (Status != NDIS_STATUS_SUCCESS)
-       {
-               DBGPRINT_ERR(("MlmeInit failed, Status[=0x%08x]\n", Status));
-               goto err2;
-       }
-
-       // Initialize pAd->StaCfg, pAd->ApCfg, pAd->CommonCfg to manufacture default
-       //
-       UserCfgInit(pAd);
-
-#ifdef RT2870
-       // We need init timerQ related structure before create the timer thread.
-       RT2870_TimerQ_Init(pAd);
-#endif // RT2870 //
-
-       RT28XX_TASK_THREAD_INIT(pAd, Status);
-       if (Status != NDIS_STATUS_SUCCESS)
-               goto err1;
-
-       CfgInitHook(pAd);
-
-       NdisAllocateSpinLock(&pAd->MacTabLock);
-
-       MeasureReqTabInit(pAd);
-       TpcReqTabInit(pAd);
-
-       //
-       // Init the hardware, we need to init asic before read registry, otherwise mac register will be reset
-       //
-       Status = NICInitializeAdapter(pAd, TRUE);
-       if (Status != NDIS_STATUS_SUCCESS)
-       {
-               DBGPRINT_ERR(("NICInitializeAdapter failed, Status[=0x%08x]\n", Status));
-               if (Status != NDIS_STATUS_SUCCESS)
-               goto err3;
-       }
-
-       // Read parameters from Config File
-       Status = RTMPReadParametersHook(pAd);
-
-       printk("1. Phy Mode = %d\n", pAd->CommonCfg.PhyMode);
-       if (Status != NDIS_STATUS_SUCCESS)
-       {
-               DBGPRINT_ERR(("NICReadRegParameters failed, Status[=0x%08x]\n",Status));
-               goto err4;
-       }
-
-#ifdef RT2870
-       pAd->CommonCfg.bMultipleIRP = FALSE;
-
-       if (pAd->CommonCfg.bMultipleIRP)
-               pAd->CommonCfg.NumOfBulkInIRP = RX_RING_SIZE;
-       else
-               pAd->CommonCfg.NumOfBulkInIRP = 1;
-#endif // RT2870 //
-
-
-       //Init Ba Capability parameters.
-//     RT28XX_BA_INIT(pAd);
-       pAd->CommonCfg.DesiredHtPhy.MpduDensity = (UCHAR)pAd->CommonCfg.BACapability.field.MpduDensity;
-       pAd->CommonCfg.DesiredHtPhy.AmsduEnable = (USHORT)pAd->CommonCfg.BACapability.field.AmsduEnable;
-       pAd->CommonCfg.DesiredHtPhy.AmsduSize = (USHORT)pAd->CommonCfg.BACapability.field.AmsduSize;
-       pAd->CommonCfg.DesiredHtPhy.MimoPs = (USHORT)pAd->CommonCfg.BACapability.field.MMPSmode;
-       // UPdata to HT IE
-       pAd->CommonCfg.HtCapability.HtCapInfo.MimoPs = (USHORT)pAd->CommonCfg.BACapability.field.MMPSmode;
-       pAd->CommonCfg.HtCapability.HtCapInfo.AMsduSize = (USHORT)pAd->CommonCfg.BACapability.field.AmsduSize;
-       pAd->CommonCfg.HtCapability.HtCapParm.MpduDensity = (UCHAR)pAd->CommonCfg.BACapability.field.MpduDensity;
-
-       printk("2. Phy Mode = %d\n", pAd->CommonCfg.PhyMode);
-
-       // We should read EEPROM for all cases.  rt2860b
-       NICReadEEPROMParameters(pAd, mac);
-
-       printk("3. Phy Mode = %d\n", pAd->CommonCfg.PhyMode);
-
-       NICInitAsicFromEEPROM(pAd); //rt2860b
-
-       // Set PHY to appropriate mode
-       TmpPhy = pAd->CommonCfg.PhyMode;
-       pAd->CommonCfg.PhyMode = 0xff;
-       RTMPSetPhyMode(pAd, TmpPhy);
-       SetCommonHT(pAd);
-
-       // No valid channels.
-       if (pAd->ChannelListNum == 0)
-       {
-               printk("Wrong configuration. No valid channel found. Check \"ContryCode\" and \"ChannelGeography\" setting.\n");
-               goto err4;
-       }
-
-       printk("MCS Set = %02x %02x %02x %02x %02x\n", pAd->CommonCfg.HtCapability.MCSSet[0],
-           pAd->CommonCfg.HtCapability.MCSSet[1], pAd->CommonCfg.HtCapability.MCSSet[2],
-           pAd->CommonCfg.HtCapability.MCSSet[3], pAd->CommonCfg.HtCapability.MCSSet[4]);
-
-#ifdef RT30xx
-    //Init RT30xx RFRegisters after read RFIC type from EEPROM
-       NICInitRT30xxRFRegisters(pAd);
-#endif // RT30xx //
-
-#ifdef IKANOS_VX_1X0
-       VR_IKANOS_FP_Init(pAd->ApCfg.BssidNum, pAd->PermanentAddress);
-#endif // IKANOS_VX_1X0 //
-
-               //
-       // Initialize RF register to default value
-       //
-       AsicSwitchChannel(pAd, pAd->CommonCfg.Channel, FALSE);
-       AsicLockChannel(pAd, pAd->CommonCfg.Channel);
-
-       if (pAd && (Status != NDIS_STATUS_SUCCESS))
-       {
-               //
-               // Undo everything if it failed
-               //
-               if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_IN_USE))
-               {
-                       RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_IN_USE);
-               }
-       }
-       else if (pAd)
-       {
-               // Microsoft HCT require driver send a disconnect event after driver initialization.
-               OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED);
-               RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_MEDIA_STATE_CHANGE);
-
-               DBGPRINT(RT_DEBUG_TRACE, ("NDIS_STATUS_MEDIA_DISCONNECT Event B!\n"));
-
-
-#ifdef RT2870
-               RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_RESET_IN_PROGRESS);
-               RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_REMOVE_IN_PROGRESS);
-
-               //
-               // Support multiple BulkIn IRP,
-               // the value on pAd->CommonCfg.NumOfBulkInIRP may be large than 1.
-               //
-               for(index=0; index<pAd->CommonCfg.NumOfBulkInIRP; index++)
-               {
-                       RTUSBBulkReceive(pAd);
-                       DBGPRINT(RT_DEBUG_TRACE, ("RTUSBBulkReceive!\n" ));
-               }
-#endif // RT2870 //
-       }// end of else
-
-
-       DBGPRINT_S(Status, ("<==== RTMPInitialize, Status=%x\n", Status));
-
-       return TRUE;
-
-
-err4:
-err3:
-       MlmeHalt(pAd);
-err2:
-       RTMPFreeTxRxRingMemory(pAd);
-err1:
-       os_free_mem(pAd, pAd->mpdu_blk_pool.mem); // free BA pool
-       RT28XX_IRQ_RELEASE(net_dev);
-
-       // shall not set priv to NULL here because the priv didn't been free yet.
-       //net_dev->ml_priv = 0;
-
-       printk("!!! %s Initialized fail !!!\n", RT28xx_CHIP_NAME);
-       return FALSE;
-} /* End of rt28xx_init */
-
-
-/*
-========================================================================
-Routine Description:
-    Open raxx interface.
-
-Arguments:
-       *net_dev                        the raxx interface pointer
-
-Return Value:
-    0                                  Open OK
-       otherwise                       Open Fail
-
-Note:
-========================================================================
-*/
-int rt28xx_open(IN PNET_DEV dev)
-{
-       struct net_device * net_dev = (struct net_device *)dev;
-       PRTMP_ADAPTER pAd = net_dev->ml_priv;
-       int retval = 0;
-       POS_COOKIE pObj;
-
-
-       // Sanity check for pAd
-       if (pAd == NULL)
-       {
-               /* if 1st open fail, pAd will be free;
-                  So the net_dev->ml_priv will be NULL in 2rd open */
-               return -1;
-       }
-
-       // Init
-       pObj = (POS_COOKIE)pAd->OS_Cookie;
-
-       // reset Adapter flags
-       RTMP_CLEAR_FLAGS(pAd);
-
-       // Request interrupt service routine for PCI device
-       // register the interrupt routine with the os
-       RT28XX_IRQ_REQUEST(net_dev);
-
-
-       // Init BssTab & ChannelInfo tabbles for auto channel select.
-
-
-       // Chip & other init
-       if (rt28xx_init(net_dev) == FALSE)
-               goto err;
-
-       NdisZeroMemory(pAd->StaCfg.dev_name, 16);
-       NdisMoveMemory(pAd->StaCfg.dev_name, net_dev->name, strlen(net_dev->name));
-
-       // Set up the Mac address
-       NdisMoveMemory(net_dev->dev_addr, (void *) pAd->CurrentAddress, 6);
-
-       // Init IRQ parameters
-       RT28XX_IRQ_INIT(pAd);
-
-       // Various AP function init
-
-
-
-       // Enable Interrupt
-       RT28XX_IRQ_ENABLE(pAd);
-
-       // Now Enable RxTx
-       RTMPEnableRxTx(pAd);
-       RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_START_UP);
-
-       {
-       UINT32 reg = 0;
-       RTMP_IO_READ32(pAd, 0x1300, &reg);  // clear garbage interrupts
-       printk("0x1300 = %08x\n", reg);
-       }
-
-       return (retval);
-
-err:
-       return (-1);
-} /* End of rt28xx_open */
-
-static const struct net_device_ops rt3070_netdev_ops = {
-       .ndo_open               = MainVirtualIF_open,
-       .ndo_stop               = MainVirtualIF_close,
-       .ndo_do_ioctl           = rt28xx_ioctl,
-       .ndo_get_stats          = RT28xx_get_ether_stats,
-       .ndo_validate_addr      = NULL,
-       .ndo_set_mac_address    = eth_mac_addr,
-       .ndo_change_mtu         = eth_change_mtu,
-#ifdef IKANOS_VX_1X0
-       .ndo_start_xmit         = IKANOS_DataFramesTx,
-#else
-       .ndo_start_xmit         = rt28xx_send_packets,
-#endif
-};
-
-/* Must not be called for mdev and apdev */
-static NDIS_STATUS rt_ieee80211_if_setup(struct net_device *dev, PRTMP_ADAPTER pAd)
-{
-       NDIS_STATUS Status;
-       INT     i=0;
-       CHAR    slot_name[IFNAMSIZ];
-       struct net_device   *device;
-
-#if WIRELESS_EXT >= 12
-       if (pAd->OpMode == OPMODE_STA)
-       {
-               dev->wireless_handlers = &rt28xx_iw_handler_def;
-       }
-#endif //WIRELESS_EXT >= 12
-
-#if WIRELESS_EXT < 21
-               dev->get_wireless_stats = rt28xx_get_wireless_stats;
-#endif
-       dev->priv_flags = INT_MAIN;
-       dev->netdev_ops = &rt3070_netdev_ops;
-       // find available device name
-       for (i = 0; i < 8; i++)
-       {
-               sprintf(slot_name, "ra%d", i);
-
-               device = dev_get_by_name(dev_net(dev), slot_name);
-               if (device != NULL)
-                       dev_put(device);
-
-               if (device == NULL)
-                       break;
-       }
-
-       if(i == 8)
-       {
-               DBGPRINT(RT_DEBUG_ERROR, ("No available slot name\n"));
-               Status = NDIS_STATUS_FAILURE;
-       }
-       else
-       {
-               sprintf(dev->name, "ra%d", i);
-               Status = NDIS_STATUS_SUCCESS;
-       }
-
-       return Status;
-
-}
-
-/*
-========================================================================
-Routine Description:
-    Probe RT28XX chipset.
-
-Arguments:
-    _dev_p                             Point to the PCI or USB device
-       _dev_id_p                       Point to the PCI or USB device ID
-
-Return Value:
-    0                                  Probe OK
-       -ENODEV                         Probe Fail
-
-Note:
-========================================================================
-*/
-INT __devinit   rt28xx_probe(
-    IN  void *_dev_p,
-    IN  void *_dev_id_p,
-       IN  UINT argc,
-       OUT PRTMP_ADAPTER *ppAd)
-{
-    struct  net_device *net_dev;
-    PRTMP_ADAPTER       pAd = (PRTMP_ADAPTER) NULL;
-    INT                 status;
-       PVOID                           handle;
-#ifdef RT2870
-       struct usb_interface *intf = (struct usb_interface *)_dev_p;
-       struct usb_device *dev_p = interface_to_usbdev(intf);
-
-       dev_p = usb_get_dev(dev_p);
-#endif // RT2870 //
-
-
-    DBGPRINT(RT_DEBUG_TRACE, ("STA Driver version-%s\n", STA_DRIVER_VERSION));
-
-    net_dev = alloc_etherdev(sizeof(PRTMP_ADAPTER));
-    if (net_dev == NULL)
-    {
-        printk("alloc_netdev failed\n");
-
-        goto err_out;
-    }
-
-       netif_stop_queue(net_dev);
-
-/* for supporting Network Manager */
-/* Set the sysfs physical device reference for the network logical device
- * if set prior to registration will cause a symlink during initialization.
- */
-    SET_NETDEV_DEV(net_dev, &(dev_p->dev));
-
-       // Allocate RTMP_ADAPTER miniport adapter structure
-       handle = kmalloc(sizeof(struct os_cookie), GFP_KERNEL);
-       RT28XX_HANDLE_DEV_ASSIGN(handle, dev_p);
-
-       status = RTMPAllocAdapterBlock(handle, &pAd);
-       if (status != NDIS_STATUS_SUCCESS)
-               goto err_out_free_netdev;
-
-       net_dev->ml_priv = (PVOID)pAd;
-    pAd->net_dev = net_dev; // must be before RT28XXNetDevInit()
-
-       RT28XXNetDevInit(_dev_p, net_dev, pAd);
-
-    pAd->StaCfg.OriDevType = net_dev->type;
-
-       // Post config
-       if (RT28XXProbePostConfig(_dev_p, pAd, 0) == FALSE)
-               goto err_out_unmap;
-
-       pAd->OpMode = OPMODE_STA;
-
-       // sample move
-       if (rt_ieee80211_if_setup(net_dev, pAd) != NDIS_STATUS_SUCCESS)
-               goto err_out_unmap;
-
-    // Register this device
-    status = register_netdev(net_dev);
-    if (status)
-        goto err_out_unmap;
-
-    // Set driver data
-       RT28XX_DRVDATA_SET(_dev_p);
-
-
-
-       *ppAd = pAd;
-    return 0; // probe ok
-
-
-       /* --------------------------- ERROR HANDLE --------------------------- */
-err_out_unmap:
-       RTMPFreeAdapter(pAd);
-       RT28XX_UNMAP();
-
-err_out_free_netdev:
-       free_netdev(net_dev);
-
-err_out:
-       RT28XX_PUT_DEVICE(dev_p);
-
-       return -ENODEV; /* probe fail */
-} /* End of rt28xx_probe */
-
-
-/*
-========================================================================
-Routine Description:
-    The entry point for Linux kernel sent packet to our driver.
-
-Arguments:
-    sk_buff *skb               the pointer refer to a sk_buffer.
-
-Return Value:
-    0
-
-Note:
-       This function is the entry point of Tx Path for Os delivery packet to
-       our driver. You only can put OS-depened & STA/AP common handle procedures
-       in here.
-========================================================================
-*/
-int rt28xx_packet_xmit(struct sk_buff *skb)
-{
-       struct net_device *net_dev = skb->dev;
-       PRTMP_ADAPTER pAd = net_dev->ml_priv;
-       int status = 0;
-       PNDIS_PACKET pPacket = (PNDIS_PACKET) skb;
-
-       {
-               // Drop send request since we are in monitor mode
-               if (MONITOR_ON(pAd))
-               {
-                       RELEASE_NDIS_PACKET(pAd, pPacket, NDIS_STATUS_FAILURE);
-                       goto done;
-               }
-       }
-
-        // EapolStart size is 18
-       if (skb->len < 14)
-       {
-               //printk("bad packet size: %d\n", pkt->len);
-               hex_dump("bad packet", skb->data, skb->len);
-               RELEASE_NDIS_PACKET(pAd, pPacket, NDIS_STATUS_FAILURE);
-               goto done;
-       }
-
-       RTMP_SET_PACKET_5VT(pPacket, 0);
-#ifdef CONFIG_5VT_ENHANCE
-    if (*(int*)(skb->cb) == BRIDGE_TAG) {
-               RTMP_SET_PACKET_5VT(pPacket, 1);
-    }
-#endif
-
-       STASendPackets((NDIS_HANDLE)pAd, (PPNDIS_PACKET) &pPacket, 1);
-
-       status = 0;
-done:
-
-       return status;
-}
-
-
-/*
-========================================================================
-Routine Description:
-    Send a packet to WLAN.
-
-Arguments:
-    skb_p           points to our adapter
-    dev_p           which WLAN network interface
-
-Return Value:
-    0: transmit successfully
-    otherwise: transmit fail
-
-Note:
-========================================================================
-*/
-INT rt28xx_send_packets(
-       IN struct sk_buff               *skb_p,
-       IN struct net_device    *net_dev)
-{
-    RTMP_ADAPTER *pAd = net_dev->ml_priv;
-
-       if (!(net_dev->flags & IFF_UP))
-       {
-               RELEASE_NDIS_PACKET(pAd, (PNDIS_PACKET)skb_p, NDIS_STATUS_FAILURE);
-               return 0;
-       }
-
-       NdisZeroMemory((PUCHAR)&skb_p->cb[CB_OFF], 15);
-       RTMP_SET_PACKET_NET_DEVICE_MBSSID(skb_p, MAIN_MBSSID);
-
-       return rt28xx_packet_xmit(skb_p);
-} /* End of MBSS_VirtualIF_PacketSend */
-
-
-
-
-void CfgInitHook(PRTMP_ADAPTER pAd)
-{
-       pAd->bBroadComHT = TRUE;
-} /* End of CfgInitHook */
-
-
-#if WIRELESS_EXT >= 12
-// This function will be called when query /proc
-struct iw_statistics *rt28xx_get_wireless_stats(
-    IN struct net_device *net_dev)
-{
-       PRTMP_ADAPTER pAd = net_dev->ml_priv;
-
-
-       DBGPRINT(RT_DEBUG_TRACE, ("rt28xx_get_wireless_stats --->\n"));
-
-       pAd->iw_stats.status = 0; // Status - device dependent for now
-
-       // link quality
-       pAd->iw_stats.qual.qual = ((pAd->Mlme.ChannelQuality * 12)/10 + 10);
-       if(pAd->iw_stats.qual.qual > 100)
-               pAd->iw_stats.qual.qual = 100;
-
-       if (pAd->OpMode == OPMODE_STA)
-               pAd->iw_stats.qual.level = RTMPMaxRssi(pAd, pAd->StaCfg.RssiSample.LastRssi0, pAd->StaCfg.RssiSample.LastRssi1, pAd->StaCfg.RssiSample.LastRssi2);
-
-       pAd->iw_stats.qual.noise = pAd->BbpWriteLatch[66]; // noise level (dBm)
-
-       pAd->iw_stats.qual.noise += 256 - 143;
-       pAd->iw_stats.qual.updated = 1;     // Flags to know if updated
-#ifdef IW_QUAL_DBM
-       pAd->iw_stats.qual.updated |= IW_QUAL_DBM;      // Level + Noise are dBm
-#endif // IW_QUAL_DBM //
-
-       pAd->iw_stats.discard.nwid = 0;     // Rx : Wrong nwid/essid
-       pAd->iw_stats.miss.beacon = 0;      // Missed beacons/superframe
-
-       DBGPRINT(RT_DEBUG_TRACE, ("<--- rt28xx_get_wireless_stats\n"));
-       return &pAd->iw_stats;
-} /* End of rt28xx_get_wireless_stats */
-#endif // WIRELESS_EXT //
-
-
-
-void tbtt_tasklet(unsigned long data)
-{
-#define MAX_TX_IN_TBTT         (16)
-
-}
-
-INT rt28xx_ioctl(
-       IN      struct net_device       *net_dev,
-       IN      OUT     struct ifreq    *rq,
-       IN      INT                                     cmd)
-{
-       VIRTUAL_ADAPTER *pVirtualAd = NULL;
-       RTMP_ADAPTER    *pAd = NULL;
-       INT                             ret = 0;
-
-       if (net_dev->priv_flags == INT_MAIN)
-       {
-               pAd = net_dev->ml_priv;
-       }
-       else
-       {
-               pVirtualAd = net_dev->ml_priv;
-               pAd = pVirtualAd->RtmpDev->ml_priv;
-       }
-
-       if (pAd == NULL)
-       {
-               /* if 1st open fail, pAd will be free;
-                  So the net_dev->ml_priv will be NULL in 2rd open */
-               return -ENETDOWN;
-       }
-
-       ret = rt28xx_sta_ioctl(net_dev, rq, cmd);
-
-       return ret;
-}
-
-/*
-    ========================================================================
-
-    Routine Description:
-        return ethernet statistics counter
-
-    Arguments:
-        net_dev                     Pointer to net_device
-
-    Return Value:
-        net_device_stats*
-
-    Note:
-
-    ========================================================================
-*/
-struct net_device_stats *RT28xx_get_ether_stats(
-    IN  struct net_device *net_dev)
-{
-    RTMP_ADAPTER *pAd = NULL;
-
-       if (net_dev)
-               pAd = net_dev->ml_priv;
-
-       if (pAd)
-       {
-
-               pAd->stats.rx_packets = pAd->WlanCounters.ReceivedFragmentCount.QuadPart;
-               pAd->stats.tx_packets = pAd->WlanCounters.TransmittedFragmentCount.QuadPart;
-
-               pAd->stats.rx_bytes = pAd->RalinkCounters.ReceivedByteCount;
-               pAd->stats.tx_bytes = pAd->RalinkCounters.TransmittedByteCount;
-
-               pAd->stats.rx_errors = pAd->Counters8023.RxErrors;
-               pAd->stats.tx_errors = pAd->Counters8023.TxErrors;
-
-               pAd->stats.rx_dropped = 0;
-               pAd->stats.tx_dropped = 0;
-
-           pAd->stats.multicast = pAd->WlanCounters.MulticastReceivedFrameCount.QuadPart;   // multicast packets received
-           pAd->stats.collisions = pAd->Counters8023.OneCollision + pAd->Counters8023.MoreCollisions;  // Collision packets
-
-           pAd->stats.rx_length_errors = 0;
-           pAd->stats.rx_over_errors = pAd->Counters8023.RxNoBuffer;                   // receiver ring buff overflow
-           pAd->stats.rx_crc_errors = 0;//pAd->WlanCounters.FCSErrorCount;     // recved pkt with crc error
-           pAd->stats.rx_frame_errors = pAd->Counters8023.RcvAlignmentErrors;          // recv'd frame alignment error
-           pAd->stats.rx_fifo_errors = pAd->Counters8023.RxNoBuffer;                   // recv'r fifo overrun
-           pAd->stats.rx_missed_errors = 0;                                            // receiver missed packet
-
-           // detailed tx_errors
-           pAd->stats.tx_aborted_errors = 0;
-           pAd->stats.tx_carrier_errors = 0;
-           pAd->stats.tx_fifo_errors = 0;
-           pAd->stats.tx_heartbeat_errors = 0;
-           pAd->stats.tx_window_errors = 0;
-
-           // for cslip etc
-           pAd->stats.rx_compressed = 0;
-           pAd->stats.tx_compressed = 0;
-
-               return &pAd->stats;
-       }
-       else
-       return NULL;
-}
-
+#include "../rt2870/rt_main_dev.c"
index 47ad183b77da63b756ec0fdb6bf4abcd37119743..ab9eb1d55bb16fbf221e2c68e8e694149eab6ba6 100644 (file)
@@ -1,1880 +1 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify  *
- * it under the terms of the GNU General Public License as published by  *
- * the Free Software Foundation; either version 2 of the License, or     *
- * (at your option) any later version.                                   *
- *                                                                       *
- * 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.                          *
- *                                                                       *
- * You should have received a copy of the GNU General Public License     *
- * along with this program; if not, write to the                         *
- * Free Software Foundation, Inc.,                                       *
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- *                                                                       *
- *************************************************************************
- */
-
-#include "rt_config.h"
-
-static void HTParametersHook(
-       IN      PRTMP_ADAPTER pAd,
-       IN      CHAR              *pValueStr,
-       IN      CHAR              *pInput);
-
-#define ETH_MAC_ADDR_STR_LEN 17  // in format of xx:xx:xx:xx:xx:xx
-
-// We assume the s1 is a sting, s2 is a memory space with 6 bytes. and content of s1 will be changed.
-BOOLEAN rtstrmactohex(char *s1, char *s2)
-{
-       int i = 0;
-       char *ptokS = s1, *ptokE = s1;
-
-       if (strlen(s1) != ETH_MAC_ADDR_STR_LEN)
-               return FALSE;
-
-       while((*ptokS) != '\0')
-       {
-               if((ptokE = strchr(ptokS, ':')) != NULL)
-                       *ptokE++ = '\0';
-               if ((strlen(ptokS) != 2) || (!isxdigit(*ptokS)) || (!isxdigit(*(ptokS+1))))
-                       break; // fail
-               AtoH(ptokS, &s2[i++], 1);
-               ptokS = ptokE;
-               if (i == 6)
-                       break; // parsing finished
-       }
-
-       return ( i == 6 ? TRUE : FALSE);
-
-}
-
-
-// we assume the s1 and s2 both are strings.
-BOOLEAN rtstrcasecmp(char *s1, char *s2)
-{
-       char *p1 = s1, *p2 = s2;
-
-       if (strlen(s1) != strlen(s2))
-               return FALSE;
-
-       while(*p1 != '\0')
-       {
-               if((*p1 != *p2) && ((*p1 ^ *p2) != 0x20))
-                       return FALSE;
-               p1++;
-               p2++;
-       }
-
-       return TRUE;
-}
-
-// we assume the s1 (buffer) and s2 (key) both are strings.
-char * rtstrstruncasecmp(char * s1, char * s2)
-{
-       INT l1, l2, i;
-       char temp1, temp2;
-
-       l2 = strlen(s2);
-       if (!l2)
-               return (char *) s1;
-
-       l1 = strlen(s1);
-
-       while (l1 >= l2)
-       {
-               l1--;
-
-               for(i=0; i<l2; i++)
-               {
-                       temp1 = *(s1+i);
-                       temp2 = *(s2+i);
-
-                       if (('a' <= temp1) && (temp1 <= 'z'))
-                               temp1 = 'A'+(temp1-'a');
-                       if (('a' <= temp2) && (temp2 <= 'z'))
-                               temp2 = 'A'+(temp2-'a');
-
-                       if (temp1 != temp2)
-                               break;
-               }
-
-               if (i == l2)
-                       return (char *) s1;
-
-               s1++;
-       }
-
-       return NULL; // not found
-}
-
-//add by kathy
-
- /**
-  * strstr - Find the first substring in a %NUL terminated string
-  * @s1: The string to be searched
-  * @s2: The string to search for
-  */
-char * rtstrstr(const char * s1,const char * s2)
-{
-       INT l1, l2;
-
-       l2 = strlen(s2);
-       if (!l2)
-               return (char *) s1;
-
-       l1 = strlen(s1);
-
-       while (l1 >= l2)
-       {
-               l1--;
-               if (!memcmp(s1,s2,l2))
-                       return (char *) s1;
-               s1++;
-       }
-
-       return NULL;
-}
-
-/**
- * rstrtok - Split a string into tokens
- * @s: The string to be searched
- * @ct: The characters to search for
- * * WARNING: strtok is deprecated, use strsep instead. However strsep is not compatible with old architecture.
- */
-char * __rstrtok;
-char * rstrtok(char * s,const char * ct)
-{
-       char *sbegin, *send;
-
-       sbegin  = s ? s : __rstrtok;
-       if (!sbegin)
-       {
-               return NULL;
-       }
-
-       sbegin += strspn(sbegin,ct);
-       if (*sbegin == '\0')
-       {
-               __rstrtok = NULL;
-               return( NULL );
-       }
-
-       send = strpbrk( sbegin, ct);
-       if (send && *send != '\0')
-               *send++ = '\0';
-
-       __rstrtok = send;
-
-       return (sbegin);
-}
-
-/**
- * delimitcnt - return the count of a given delimiter in a given string.
- * @s: The string to be searched.
- * @ct: The delimiter to search for.
- * Notice : We suppose the delimiter is a single-char string(for example : ";").
- */
-INT delimitcnt(char * s,const char * ct)
-{
-       INT count = 0;
-       /* point to the beginning of the line */
-       const char *token = s;
-
-       for ( ;; )
-       {
-               token = strpbrk(token, ct); /* search for delimiters */
-
-        if ( token == NULL )
-               {
-                       /* advanced to the terminating null character */
-                       break;
-               }
-               /* skip the delimiter */
-           ++token;
-
-               /*
-                * Print the found text: use len with %.*s to specify field width.
-                */
-
-               /* accumulate delimiter count */
-           ++count;
-       }
-    return count;
-}
-
-/*
-  * converts the Internet host address from the standard numbers-and-dots notation
-  * into binary data.
-  * returns nonzero if the address is valid, zero if not.
-  */
-int rtinet_aton(const char *cp, unsigned int *addr)
-{
-       unsigned int    val;
-       int             base, n;
-       char            c;
-       unsigned int    parts[4];
-       unsigned int    *pp = parts;
-
-       for (;;)
-    {
-         /*
-          * Collect number up to ``.''.
-          * Values are specified as for C:
-          *    0x=hex, 0=octal, other=decimal.
-          */
-         val = 0;
-         base = 10;
-         if (*cp == '0')
-         {
-             if (*++cp == 'x' || *cp == 'X')
-                 base = 16, cp++;
-             else
-                 base = 8;
-         }
-         while ((c = *cp) != '\0')
-         {
-             if (isdigit((unsigned char) c))
-             {
-                 val = (val * base) + (c - '0');
-                 cp++;
-                 continue;
-             }
-             if (base == 16 && isxdigit((unsigned char) c))
-             {
-                 val = (val << 4) +
-                     (c + 10 - (islower((unsigned char) c) ? 'a' : 'A'));
-                 cp++;
-                 continue;
-             }
-             break;
-         }
-         if (*cp == '.')
-         {
-             /*
-              * Internet format: a.b.c.d a.b.c   (with c treated as 16-bits)
-              * a.b     (with b treated as 24 bits)
-              */
-             if (pp >= parts + 3 || val > 0xff)
-                 return 0;
-             *pp++ = val, cp++;
-         }
-         else
-             break;
-     }
-
-     /*
-      * Check for trailing junk.
-      */
-     while (*cp)
-         if (!isspace((unsigned char) *cp++))
-             return 0;
-
-     /*
-      * Concoct the address according to the number of parts specified.
-      */
-     n = pp - parts + 1;
-     switch (n)
-     {
-
-         case 1:         /* a -- 32 bits */
-             break;
-
-         case 2:         /* a.b -- 8.24 bits */
-             if (val > 0xffffff)
-                 return 0;
-             val |= parts[0] << 24;
-             break;
-
-         case 3:         /* a.b.c -- 8.8.16 bits */
-             if (val > 0xffff)
-                 return 0;
-             val |= (parts[0] << 24) | (parts[1] << 16);
-             break;
-
-         case 4:         /* a.b.c.d -- 8.8.8.8 bits */
-             if (val > 0xff)
-                 return 0;
-             val |= (parts[0] << 24) | (parts[1] << 16) | (parts[2] << 8);
-             break;
-     }
-
-     *addr = htonl(val);
-     return 1;
-
-}
-
-/*
-    ========================================================================
-
-    Routine Description:
-        Find key section for Get key parameter.
-
-    Arguments:
-        buffer                      Pointer to the buffer to start find the key section
-        section                     the key of the secion to be find
-
-    Return Value:
-        NULL                        Fail
-        Others                      Success
-    ========================================================================
-*/
-PUCHAR  RTMPFindSection(
-    IN  PCHAR   buffer)
-{
-    CHAR temp_buf[32];
-    PUCHAR  ptr;
-
-    strcpy(temp_buf, "Default");
-
-    if((ptr = rtstrstr(buffer, temp_buf)) != NULL)
-            return (ptr+strlen("\n"));
-        else
-            return NULL;
-}
-
-/*
-    ========================================================================
-
-    Routine Description:
-        Get key parameter.
-
-    Arguments:
-        key                         Pointer to key string
-        dest                        Pointer to destination
-        destsize                    The datasize of the destination
-        buffer                      Pointer to the buffer to start find the key
-
-    Return Value:
-        TRUE                        Success
-        FALSE                       Fail
-
-    Note:
-        This routine get the value with the matched key (case case-sensitive)
-    ========================================================================
-*/
-INT RTMPGetKeyParameter(
-    IN  PCHAR   key,
-    OUT PCHAR   dest,
-    IN  INT     destsize,
-    IN  PCHAR   buffer)
-{
-    UCHAR *temp_buf1 = NULL;
-    UCHAR *temp_buf2 = NULL;
-    CHAR *start_ptr;
-    CHAR *end_ptr;
-    CHAR *ptr;
-    CHAR *offset = 0;
-    INT  len;
-
-       //temp_buf1 = kmalloc(MAX_PARAM_BUFFER_SIZE, MEM_ALLOC_FLAG);
-       os_alloc_mem(NULL, &temp_buf1, MAX_PARAM_BUFFER_SIZE);
-
-       if(temp_buf1 == NULL)
-        return (FALSE);
-
-       //temp_buf2 = kmalloc(MAX_PARAM_BUFFER_SIZE, MEM_ALLOC_FLAG);
-       os_alloc_mem(NULL, &temp_buf2, MAX_PARAM_BUFFER_SIZE);
-       if(temp_buf2 == NULL)
-       {
-               os_free_mem(NULL, temp_buf1);
-        return (FALSE);
-       }
-
-    //find section
-    if((offset = RTMPFindSection(buffer)) == NULL)
-    {
-       os_free_mem(NULL, temp_buf1);
-       os_free_mem(NULL, temp_buf2);
-        return (FALSE);
-    }
-
-    strcpy(temp_buf1, "\n");
-    strcat(temp_buf1, key);
-    strcat(temp_buf1, "=");
-
-    //search key
-    if((start_ptr=rtstrstr(offset, temp_buf1))==NULL)
-    {
-               os_free_mem(NULL, temp_buf1);
-       os_free_mem(NULL, temp_buf2);
-        return (FALSE);
-    }
-
-    start_ptr+=strlen("\n");
-    if((end_ptr=rtstrstr(start_ptr, "\n"))==NULL)
-       end_ptr=start_ptr+strlen(start_ptr);
-
-    if (end_ptr<start_ptr)
-    {
-               os_free_mem(NULL, temp_buf1);
-       os_free_mem(NULL, temp_buf2);
-        return (FALSE);
-    }
-
-    NdisMoveMemory(temp_buf2, start_ptr, end_ptr-start_ptr);
-    temp_buf2[end_ptr-start_ptr]='\0';
-    len = strlen(temp_buf2);
-    strcpy(temp_buf1, temp_buf2);
-    if((start_ptr=rtstrstr(temp_buf1, "=")) == NULL)
-    {
-               os_free_mem(NULL, temp_buf1);
-       os_free_mem(NULL, temp_buf2);
-        return (FALSE);
-    }
-
-    strcpy(temp_buf2, start_ptr+1);
-    ptr = temp_buf2;
-    //trim space or tab
-    while(*ptr != 0x00)
-    {
-        if( (*ptr == ' ') || (*ptr == '\t') )
-            ptr++;
-        else
-           break;
-    }
-
-    len = strlen(ptr);
-    memset(dest, 0x00, destsize);
-    strncpy(dest, ptr, len >= destsize ?  destsize: len);
-
-       os_free_mem(NULL, temp_buf1);
-    os_free_mem(NULL, temp_buf2);
-    return TRUE;
-}
-
-/*
-    ========================================================================
-
-    Routine Description:
-        Get key parameter.
-
-    Arguments:
-        key                         Pointer to key string
-        dest                        Pointer to destination
-        destsize                    The datasize of the destination
-        buffer                      Pointer to the buffer to start find the key
-
-    Return Value:
-        TRUE                        Success
-        FALSE                       Fail
-
-    Note:
-        This routine get the value with the matched key (case case-sensitive).
-        It is called for parsing SSID and any key string.
-    ========================================================================
-*/
-INT RTMPGetCriticalParameter(
-    IN  PCHAR   key,
-    OUT PCHAR   dest,
-    IN  INT     destsize,
-    IN  PCHAR   buffer)
-{
-    UCHAR *temp_buf1 = NULL;
-    UCHAR *temp_buf2 = NULL;
-    CHAR *start_ptr;
-    CHAR *end_ptr;
-    CHAR *ptr;
-    CHAR *offset = 0;
-    INT  len;
-
-       //temp_buf1 = kmalloc(MAX_PARAM_BUFFER_SIZE, MEM_ALLOC_FLAG);
-       os_alloc_mem(NULL, &temp_buf1, MAX_PARAM_BUFFER_SIZE);
-
-       if(temp_buf1 == NULL)
-        return (FALSE);
-
-       //temp_buf2 = kmalloc(MAX_PARAM_BUFFER_SIZE, MEM_ALLOC_FLAG);
-       os_alloc_mem(NULL, &temp_buf2, MAX_PARAM_BUFFER_SIZE);
-       if(temp_buf2 == NULL)
-       {
-               os_free_mem(NULL, temp_buf1);
-        return (FALSE);
-       }
-
-    //find section
-    if((offset = RTMPFindSection(buffer)) == NULL)
-    {
-       os_free_mem(NULL, temp_buf1);
-       os_free_mem(NULL, temp_buf2);
-        return (FALSE);
-    }
-
-    strcpy(temp_buf1, "\n");
-    strcat(temp_buf1, key);
-    strcat(temp_buf1, "=");
-
-    //search key
-    if((start_ptr=rtstrstr(offset, temp_buf1))==NULL)
-    {
-               os_free_mem(NULL, temp_buf1);
-       os_free_mem(NULL, temp_buf2);
-        return (FALSE);
-    }
-
-    start_ptr+=strlen("\n");
-    if((end_ptr=rtstrstr(start_ptr, "\n"))==NULL)
-       end_ptr=start_ptr+strlen(start_ptr);
-
-    if (end_ptr<start_ptr)
-    {
-               os_free_mem(NULL, temp_buf1);
-       os_free_mem(NULL, temp_buf2);
-        return (FALSE);
-    }
-
-    NdisMoveMemory(temp_buf2, start_ptr, end_ptr-start_ptr);
-    temp_buf2[end_ptr-start_ptr]='\0';
-    len = strlen(temp_buf2);
-    strcpy(temp_buf1, temp_buf2);
-    if((start_ptr=rtstrstr(temp_buf1, "=")) == NULL)
-    {
-               os_free_mem(NULL, temp_buf1);
-       os_free_mem(NULL, temp_buf2);
-        return (FALSE);
-    }
-
-    strcpy(temp_buf2, start_ptr+1);
-    ptr = temp_buf2;
-
-    //trim tab
-    /* We cannot trim space(' ') for SSID and key string. */
-    while(*ptr != 0x00)
-    {
-        //if( (*ptr == ' ') || (*ptr == '\t') )
-        if( (*ptr == '\t') )
-            ptr++;
-        else
-           break;
-    }
-
-    len = strlen(ptr);
-    memset(dest, 0x00, destsize);
-    strncpy(dest, ptr, len >= destsize ?  destsize: len);
-
-       os_free_mem(NULL, temp_buf1);
-    os_free_mem(NULL, temp_buf2);
-    return TRUE;
-}
-
-/*
-    ========================================================================
-
-    Routine Description:
-        Get multiple key parameter.
-
-    Arguments:
-        key                         Pointer to key string
-        dest                        Pointer to destination
-        destsize                    The datasize of the destination
-        buffer                      Pointer to the buffer to start find the key
-
-    Return Value:
-        TRUE                        Success
-        FALSE                       Fail
-
-    Note:
-        This routine get the value with the matched key (case case-sensitive)
-    ========================================================================
-*/
-INT RTMPGetKeyParameterWithOffset(
-    IN  PCHAR   key,
-    OUT PCHAR   dest,
-    OUT        USHORT  *end_offset,
-    IN  INT     destsize,
-    IN  PCHAR   buffer,
-    IN BOOLEAN bTrimSpace)
-{
-    UCHAR *temp_buf1 = NULL;
-    UCHAR *temp_buf2 = NULL;
-    CHAR *start_ptr;
-    CHAR *end_ptr;
-    CHAR *ptr;
-    CHAR *offset = 0;
-    INT  len;
-
-       if (*end_offset >= MAX_INI_BUFFER_SIZE)
-               return (FALSE);
-
-       os_alloc_mem(NULL, &temp_buf1, MAX_PARAM_BUFFER_SIZE);
-
-       if(temp_buf1 == NULL)
-        return (FALSE);
-
-       os_alloc_mem(NULL, &temp_buf2, MAX_PARAM_BUFFER_SIZE);
-       if(temp_buf2 == NULL)
-       {
-               os_free_mem(NULL, temp_buf1);
-        return (FALSE);
-       }
-
-    //find section
-       if(*end_offset == 0)
-    {
-               if ((offset = RTMPFindSection(buffer)) == NULL)
-               {
-                       os_free_mem(NULL, temp_buf1);
-               os_free_mem(NULL, temp_buf2);
-           return (FALSE);
-               }
-    }
-       else
-               offset = buffer + (*end_offset);
-
-    strcpy(temp_buf1, "\n");
-    strcat(temp_buf1, key);
-    strcat(temp_buf1, "=");
-
-    //search key
-    if((start_ptr=rtstrstr(offset, temp_buf1))==NULL)
-    {
-               os_free_mem(NULL, temp_buf1);
-       os_free_mem(NULL, temp_buf2);
-        return (FALSE);
-    }
-
-    start_ptr+=strlen("\n");
-    if((end_ptr=rtstrstr(start_ptr, "\n"))==NULL)
-       end_ptr=start_ptr+strlen(start_ptr);
-
-    if (end_ptr<start_ptr)
-    {
-               os_free_mem(NULL, temp_buf1);
-       os_free_mem(NULL, temp_buf2);
-        return (FALSE);
-    }
-
-       *end_offset = end_ptr - buffer;
-
-    NdisMoveMemory(temp_buf2, start_ptr, end_ptr-start_ptr);
-    temp_buf2[end_ptr-start_ptr]='\0';
-    len = strlen(temp_buf2);
-    strcpy(temp_buf1, temp_buf2);
-    if((start_ptr=rtstrstr(temp_buf1, "=")) == NULL)
-    {
-               os_free_mem(NULL, temp_buf1);
-       os_free_mem(NULL, temp_buf2);
-        return (FALSE);
-    }
-
-    strcpy(temp_buf2, start_ptr+1);
-    ptr = temp_buf2;
-    //trim space or tab
-    while(*ptr != 0x00)
-    {
-        if((bTrimSpace && (*ptr == ' ')) || (*ptr == '\t') )
-            ptr++;
-        else
-           break;
-    }
-
-    len = strlen(ptr);
-    memset(dest, 0x00, destsize);
-    strncpy(dest, ptr, len >= destsize ?  destsize: len);
-
-       os_free_mem(NULL, temp_buf1);
-    os_free_mem(NULL, temp_buf2);
-    return TRUE;
-}
-
-
-static int rtmp_parse_key_buffer_from_file(IN  PRTMP_ADAPTER pAd,IN  char *buffer,IN  ULONG KeyType,IN  INT BSSIdx,IN  INT KeyIdx)
-{
-       PUCHAR          keybuff;
-       INT                     i = BSSIdx, idx = KeyIdx;
-       ULONG           KeyLen;
-       UCHAR           CipherAlg = CIPHER_WEP64;
-
-       keybuff = buffer;
-       KeyLen = strlen(keybuff);
-
-       if (KeyType == 1)
-       {//Ascii
-               if( (KeyLen == 5) || (KeyLen == 13))
-               {
-                       pAd->SharedKey[i][idx].KeyLen = KeyLen;
-                       NdisMoveMemory(pAd->SharedKey[i][idx].Key, keybuff, KeyLen);
-                       if (KeyLen == 5)
-                               CipherAlg = CIPHER_WEP64;
-                       else
-                               CipherAlg = CIPHER_WEP128;
-                       pAd->SharedKey[i][idx].CipherAlg = CipherAlg;
-
-                       DBGPRINT(RT_DEBUG_TRACE, ("I/F(ra%d) Key%dStr=%s and type=%s\n", i, idx+1, keybuff, (KeyType == 0) ? "Hex":"Ascii"));
-                       return 1;
-               }
-               else
-               {//Invalid key length
-                       DBGPRINT(RT_DEBUG_ERROR, ("Key%dStr is Invalid key length! KeyLen = %ld!\n", idx+1, KeyLen));
-                       return 0;
-               }
-       }
-       else
-       {//Hex type
-               if( (KeyLen == 10) || (KeyLen == 26))
-               {
-                       pAd->SharedKey[i][idx].KeyLen = KeyLen / 2;
-                       AtoH(keybuff, pAd->SharedKey[i][idx].Key, KeyLen / 2);
-                       if (KeyLen == 10)
-                               CipherAlg = CIPHER_WEP64;
-                       else
-                               CipherAlg = CIPHER_WEP128;
-                       pAd->SharedKey[i][idx].CipherAlg = CipherAlg;
-
-                       DBGPRINT(RT_DEBUG_TRACE, ("I/F(ra%d) Key%dStr=%s and type=%s\n", i, idx+1, keybuff, (KeyType == 0) ? "Hex":"Ascii"));
-                       return 1;
-               }
-               else
-               {//Invalid key length
-                       DBGPRINT(RT_DEBUG_ERROR, ("I/F(ra%d) Key%dStr is Invalid key length! KeyLen = %ld!\n", i, idx+1, KeyLen));
-                       return 0;
-               }
-       }
-}
-static void rtmp_read_key_parms_from_file(IN  PRTMP_ADAPTER pAd, char *tmpbuf, char *buffer)
-{
-       char            tok_str[16];
-       PUCHAR          macptr;
-       INT                     i = 0, idx;
-       ULONG           KeyType[MAX_MBSSID_NUM];
-       ULONG           KeyIdx;
-
-       NdisZeroMemory(KeyType, MAX_MBSSID_NUM);
-
-       //DefaultKeyID
-       if(RTMPGetKeyParameter("DefaultKeyID", tmpbuf, 25, buffer))
-       {
-               {
-                       KeyIdx = simple_strtol(tmpbuf, 0, 10);
-                       if((KeyIdx >= 1 ) && (KeyIdx <= 4))
-                               pAd->StaCfg.DefaultKeyId = (UCHAR) (KeyIdx - 1);
-                       else
-                               pAd->StaCfg.DefaultKeyId = 0;
-
-                       DBGPRINT(RT_DEBUG_TRACE, ("DefaultKeyID(0~3)=%d\n", pAd->StaCfg.DefaultKeyId));
-               }
-       }
-
-
-       for (idx = 0; idx < 4; idx++)
-       {
-               sprintf(tok_str, "Key%dType", idx + 1);
-               //Key1Type
-               if (RTMPGetKeyParameter(tok_str, tmpbuf, 128, buffer))
-               {
-                   for (i = 0, macptr = rstrtok(tmpbuf,";"); macptr; macptr = rstrtok(NULL,";"), i++)
-                   {
-                           KeyType[i] = simple_strtol(macptr, 0, 10);
-                   }
-
-                       {
-                               sprintf(tok_str, "Key%dStr", idx + 1);
-                               if (RTMPGetCriticalParameter(tok_str, tmpbuf, 128, buffer))
-                               {
-                                       rtmp_parse_key_buffer_from_file(pAd, tmpbuf, KeyType[BSS0], BSS0, idx);
-                               }
-                       }
-               }
-       }
-}
-
-static void rtmp_read_sta_wmm_parms_from_file(IN  PRTMP_ADAPTER pAd, char *tmpbuf, char *buffer)
-{
-       PUCHAR                                  macptr;
-       INT                                             i=0;
-       BOOLEAN                                 bWmmEnable = FALSE;
-
-       //WmmCapable
-       if(RTMPGetKeyParameter("WmmCapable", tmpbuf, 32, buffer))
-       {
-               if(simple_strtol(tmpbuf, 0, 10) != 0) //Enable
-               {
-                       pAd->CommonCfg.bWmmCapable = TRUE;
-                       bWmmEnable = TRUE;
-               }
-               else //Disable
-               {
-                       pAd->CommonCfg.bWmmCapable = FALSE;
-               }
-
-               DBGPRINT(RT_DEBUG_TRACE, ("WmmCapable=%d\n", pAd->CommonCfg.bWmmCapable));
-       }
-
-       //AckPolicy for AC_BK, AC_BE, AC_VI, AC_VO
-       if(RTMPGetKeyParameter("AckPolicy", tmpbuf, 32, buffer))
-       {
-               for (i = 0, macptr = rstrtok(tmpbuf,";"); macptr; macptr = rstrtok(NULL,";"), i++)
-               {
-                       pAd->CommonCfg.AckPolicy[i] = (UCHAR)simple_strtol(macptr, 0, 10);
-
-                       DBGPRINT(RT_DEBUG_TRACE, ("AckPolicy[%d]=%d\n", i, pAd->CommonCfg.AckPolicy[i]));
-               }
-       }
-
-       if (bWmmEnable)
-       {
-               //APSDCapable
-               if(RTMPGetKeyParameter("APSDCapable", tmpbuf, 10, buffer))
-               {
-                       if(simple_strtol(tmpbuf, 0, 10) != 0)  //Enable
-                               pAd->CommonCfg.bAPSDCapable = TRUE;
-                       else
-                               pAd->CommonCfg.bAPSDCapable = FALSE;
-
-                       DBGPRINT(RT_DEBUG_TRACE, ("APSDCapable=%d\n", pAd->CommonCfg.bAPSDCapable));
-               }
-
-               //APSDAC for AC_BE, AC_BK, AC_VI, AC_VO
-               if(RTMPGetKeyParameter("APSDAC", tmpbuf, 32, buffer))
-               {
-                       BOOLEAN apsd_ac[4];
-
-                       for (i = 0, macptr = rstrtok(tmpbuf,";"); macptr; macptr = rstrtok(NULL,";"), i++)
-                       {
-                               apsd_ac[i] = (BOOLEAN)simple_strtol(macptr, 0, 10);
-
-                               DBGPRINT(RT_DEBUG_TRACE, ("APSDAC%d  %d\n", i,  apsd_ac[i]));
-                       }
-
-                       pAd->CommonCfg.bAPSDAC_BE = apsd_ac[0];
-                       pAd->CommonCfg.bAPSDAC_BK = apsd_ac[1];
-                       pAd->CommonCfg.bAPSDAC_VI = apsd_ac[2];
-                       pAd->CommonCfg.bAPSDAC_VO = apsd_ac[3];
-               }
-       }
-
-}
-
-NDIS_STATUS    RTMPReadParametersHook(
-       IN      PRTMP_ADAPTER pAd)
-{
-       PUCHAR                                  src = NULL;
-       struct file                             *srcf;
-       INT                                     retval, orgfsuid, orgfsgid;
-       mm_segment_t                    orgfs;
-       CHAR                                    *buffer;
-       CHAR                                    *tmpbuf;
-       ULONG                                   RtsThresh;
-       ULONG                                   FragThresh;
-       UCHAR                   keyMaterial[40];
-
-       PUCHAR                                  macptr;
-       INT                                             i = 0;
-
-       buffer = kmalloc(MAX_INI_BUFFER_SIZE, MEM_ALLOC_FLAG);
-       if(buffer == NULL)
-        return NDIS_STATUS_FAILURE;
-
-       tmpbuf = kmalloc(MAX_PARAM_BUFFER_SIZE, MEM_ALLOC_FLAG);
-       if(tmpbuf == NULL)
-       {
-               kfree(buffer);
-        return NDIS_STATUS_FAILURE;
-       }
-
-       src = STA_PROFILE_PATH;
-
-       // Save uid and gid used for filesystem access.
-       // Set user and group to 0 (root)
-    orgfs = get_fs();
-    set_fs(KERNEL_DS);
-
-       if (src && *src)
-       {
-               srcf = filp_open(src, O_RDONLY, 0);
-               if (IS_ERR(srcf))
-               {
-                       DBGPRINT(RT_DEBUG_ERROR, ("--> Error %ld opening %s\n", -PTR_ERR(srcf),src));
-               }
-               else
-               {
-                       // The object must have a read method
-                       if (srcf->f_op && srcf->f_op->read)
-                       {
-                               memset(buffer, 0x00, MAX_INI_BUFFER_SIZE);
-                               retval=srcf->f_op->read(srcf, buffer, MAX_INI_BUFFER_SIZE, &srcf->f_pos);
-                               if (retval < 0)
-                               {
-                                       DBGPRINT(RT_DEBUG_TRACE, ("--> Read %s error %d\n", src, -retval));
-                               }
-                               else
-                               {
-                                       // set file parameter to portcfg
-                                       //CountryRegion
-                                       if(RTMPGetKeyParameter("CountryRegion", tmpbuf, 25, buffer))
-                                       {
-                                               pAd->CommonCfg.CountryRegion = (UCHAR) simple_strtol(tmpbuf, 0, 10);
-                                               DBGPRINT(RT_DEBUG_TRACE, ("CountryRegion=%d\n", pAd->CommonCfg.CountryRegion));
-                                       }
-                                       //CountryRegionABand
-                                       if(RTMPGetKeyParameter("CountryRegionABand", tmpbuf, 25, buffer))
-                                       {
-                                               pAd->CommonCfg.CountryRegionForABand= (UCHAR) simple_strtol(tmpbuf, 0, 10);
-                                               DBGPRINT(RT_DEBUG_TRACE, ("CountryRegionABand=%d\n", pAd->CommonCfg.CountryRegionForABand));
-                                       }
-                                       //CountryCode
-                                       if(RTMPGetKeyParameter("CountryCode", tmpbuf, 25, buffer))
-                                       {
-                                               NdisMoveMemory(pAd->CommonCfg.CountryCode, tmpbuf , 2);
-
-                                               if (strlen(pAd->CommonCfg.CountryCode) != 0)
-                                               {
-                                                       pAd->CommonCfg.bCountryFlag = TRUE;
-                                               }
-                                               DBGPRINT(RT_DEBUG_TRACE, ("CountryCode=%s\n", pAd->CommonCfg.CountryCode));
-                                       }
-                                       //ChannelGeography
-                                       if(RTMPGetKeyParameter("ChannelGeography", tmpbuf, 25, buffer))
-                                       {
-                                               UCHAR Geography = (UCHAR) simple_strtol(tmpbuf, 0, 10);
-                                               if (Geography <= BOTH)
-                                               {
-                                                       pAd->CommonCfg.Geography = Geography;
-                                                       pAd->CommonCfg.CountryCode[2] =
-                                                               (pAd->CommonCfg.Geography == BOTH) ? ' ' : ((pAd->CommonCfg.Geography == IDOR) ? 'I' : 'O');
-                                                       DBGPRINT(RT_DEBUG_TRACE, ("ChannelGeography=%d\n", pAd->CommonCfg.Geography));
-                                               }
-                                       }
-                                       else
-                                       {
-                                               pAd->CommonCfg.Geography = BOTH;
-                                               pAd->CommonCfg.CountryCode[2] = ' ';
-                                       }
-
-                                       {
-                                               //SSID
-                                               if (RTMPGetCriticalParameter("SSID", tmpbuf, 256, buffer))
-                                               {
-                                                       if (strlen(tmpbuf) <= 32)
-                                                       {
-                                                               pAd->CommonCfg.SsidLen = (UCHAR) strlen(tmpbuf);
-                                                               NdisZeroMemory(pAd->CommonCfg.Ssid, NDIS_802_11_LENGTH_SSID);
-                                                               NdisMoveMemory(pAd->CommonCfg.Ssid, tmpbuf, pAd->CommonCfg.SsidLen);
-                                                               pAd->MlmeAux.AutoReconnectSsidLen = pAd->CommonCfg.SsidLen;
-                                                               NdisZeroMemory(pAd->MlmeAux.AutoReconnectSsid, NDIS_802_11_LENGTH_SSID);
-                                                               NdisMoveMemory(pAd->MlmeAux.AutoReconnectSsid, tmpbuf, pAd->MlmeAux.AutoReconnectSsidLen);
-                                                               pAd->MlmeAux.SsidLen = pAd->CommonCfg.SsidLen;
-                                                               NdisZeroMemory(pAd->MlmeAux.Ssid, NDIS_802_11_LENGTH_SSID);
-                                                               NdisMoveMemory(pAd->MlmeAux.Ssid, tmpbuf, pAd->MlmeAux.SsidLen);
-                                                               DBGPRINT(RT_DEBUG_TRACE, ("%s::(SSID=%s)\n", __func__, tmpbuf));
-                                                       }
-                                               }
-                                       }
-
-                                       {
-                                               //NetworkType
-                                               if (RTMPGetKeyParameter("NetworkType", tmpbuf, 25, buffer))
-                                               {
-                                                       pAd->bConfigChanged = TRUE;
-                                                       if (strcmp(tmpbuf, "Adhoc") == 0)
-                                                               pAd->StaCfg.BssType = BSS_ADHOC;
-                                                       else //Default Infrastructure mode
-                                                               pAd->StaCfg.BssType = BSS_INFRA;
-                                                       // Reset Ralink supplicant to not use, it will be set to start when UI set PMK key
-                                                       pAd->StaCfg.WpaState = SS_NOTUSE;
-                                                       DBGPRINT(RT_DEBUG_TRACE, ("%s::(NetworkType=%d)\n", __func__, pAd->StaCfg.BssType));
-                                               }
-                                       }
-
-                                       //Channel
-                                       if(RTMPGetKeyParameter("Channel", tmpbuf, 10, buffer))
-                                       {
-                                               pAd->CommonCfg.Channel = (UCHAR) simple_strtol(tmpbuf, 0, 10);
-                                               DBGPRINT(RT_DEBUG_TRACE, ("Channel=%d\n", pAd->CommonCfg.Channel));
-                                       }
-                                       //WirelessMode
-                                       if(RTMPGetKeyParameter("WirelessMode", tmpbuf, 10, buffer))
-                                       {
-                                               int value  = 0, maxPhyMode = PHY_11G;
-
-                                               maxPhyMode = PHY_11N_5G;
-
-                                               value = simple_strtol(tmpbuf, 0, 10);
-
-                                               if (value <= maxPhyMode)
-                                               {
-                                                       pAd->CommonCfg.PhyMode = value;
-                                               }
-                                               DBGPRINT(RT_DEBUG_TRACE, ("PhyMode=%d\n", pAd->CommonCfg.PhyMode));
-                                       }
-                    //BasicRate
-                                       if(RTMPGetKeyParameter("BasicRate", tmpbuf, 10, buffer))
-                                       {
-                                               pAd->CommonCfg.BasicRateBitmap = (ULONG) simple_strtol(tmpbuf, 0, 10);
-                                               DBGPRINT(RT_DEBUG_TRACE, ("BasicRate=%ld\n", pAd->CommonCfg.BasicRateBitmap));
-                                       }
-                                       //BeaconPeriod
-                                       if(RTMPGetKeyParameter("BeaconPeriod", tmpbuf, 10, buffer))
-                                       {
-                                               pAd->CommonCfg.BeaconPeriod = (USHORT) simple_strtol(tmpbuf, 0, 10);
-                                               DBGPRINT(RT_DEBUG_TRACE, ("BeaconPeriod=%d\n", pAd->CommonCfg.BeaconPeriod));
-                                       }
-                    //TxPower
-                                       if(RTMPGetKeyParameter("TxPower", tmpbuf, 10, buffer))
-                                       {
-                                               pAd->CommonCfg.TxPowerPercentage = (ULONG) simple_strtol(tmpbuf, 0, 10);
-
-                                               pAd->CommonCfg.TxPowerDefault = pAd->CommonCfg.TxPowerPercentage;
-
-                                               DBGPRINT(RT_DEBUG_TRACE, ("TxPower=%ld\n", pAd->CommonCfg.TxPowerPercentage));
-                                       }
-                                       //BGProtection
-                                       if(RTMPGetKeyParameter("BGProtection", tmpbuf, 10, buffer))
-                                       {
-                                               switch (simple_strtol(tmpbuf, 0, 10))
-                                               {
-                                                       case 1: //Always On
-                                                               pAd->CommonCfg.UseBGProtection = 1;
-                                                               break;
-                                                       case 2: //Always OFF
-                                                               pAd->CommonCfg.UseBGProtection = 2;
-                                                               break;
-                                                       case 0: //AUTO
-                                                       default:
-                                                               pAd->CommonCfg.UseBGProtection = 0;
-                                                               break;
-                                               }
-                                               DBGPRINT(RT_DEBUG_TRACE, ("BGProtection=%ld\n", pAd->CommonCfg.UseBGProtection));
-                                       }
-                                       //OLBCDetection
-                                       if(RTMPGetKeyParameter("DisableOLBC", tmpbuf, 10, buffer))
-                                       {
-                                               switch (simple_strtol(tmpbuf, 0, 10))
-                                               {
-                                                       case 1: //disable OLBC Detection
-                                                               pAd->CommonCfg.DisableOLBCDetect = 1;
-                                                               break;
-                                                       case 0: //enable OLBC Detection
-                                                               pAd->CommonCfg.DisableOLBCDetect = 0;
-                                                               break;
-                                                       default:
-                                                               pAd->CommonCfg.DisableOLBCDetect= 0;
-                                                               break;
-                                               }
-                                               DBGPRINT(RT_DEBUG_TRACE, ("OLBCDetection=%ld\n", pAd->CommonCfg.DisableOLBCDetect));
-                                       }
-                                       //TxPreamble
-                                       if(RTMPGetKeyParameter("TxPreamble", tmpbuf, 10, buffer))
-                                       {
-                                               switch (simple_strtol(tmpbuf, 0, 10))
-                                               {
-                                                       case Rt802_11PreambleShort:
-                                                               pAd->CommonCfg.TxPreamble = Rt802_11PreambleShort;
-                                                               break;
-                                                       case Rt802_11PreambleLong:
-                                                       default:
-                                                               pAd->CommonCfg.TxPreamble = Rt802_11PreambleLong;
-                                                               break;
-                                               }
-                                               DBGPRINT(RT_DEBUG_TRACE, ("TxPreamble=%ld\n", pAd->CommonCfg.TxPreamble));
-                                       }
-                                       //RTSThreshold
-                                       if(RTMPGetKeyParameter("RTSThreshold", tmpbuf, 10, buffer))
-                                       {
-                                               RtsThresh = simple_strtol(tmpbuf, 0, 10);
-                                               if( (RtsThresh >= 1) && (RtsThresh <= MAX_RTS_THRESHOLD) )
-                                                       pAd->CommonCfg.RtsThreshold  = (USHORT)RtsThresh;
-                                               else
-                                                       pAd->CommonCfg.RtsThreshold = MAX_RTS_THRESHOLD;
-
-                                               DBGPRINT(RT_DEBUG_TRACE, ("RTSThreshold=%d\n", pAd->CommonCfg.RtsThreshold));
-                                       }
-                                       //FragThreshold
-                                       if(RTMPGetKeyParameter("FragThreshold", tmpbuf, 10, buffer))
-                                       {
-                                               FragThresh = simple_strtol(tmpbuf, 0, 10);
-                                               pAd->CommonCfg.bUseZeroToDisableFragment = FALSE;
-
-                                               if (FragThresh > MAX_FRAG_THRESHOLD || FragThresh < MIN_FRAG_THRESHOLD)
-                                               { //illegal FragThresh so we set it to default
-                                                       pAd->CommonCfg.FragmentThreshold = MAX_FRAG_THRESHOLD;
-                                                       pAd->CommonCfg.bUseZeroToDisableFragment = TRUE;
-                                               }
-                                               else if (FragThresh % 2 == 1)
-                                               {
-                                                       // The length of each fragment shall always be an even number of octets, except for the last fragment
-                                                       // of an MSDU or MMPDU, which may be either an even or an odd number of octets.
-                                                       pAd->CommonCfg.FragmentThreshold = (USHORT)(FragThresh - 1);
-                                               }
-                                               else
-                                               {
-                                                       pAd->CommonCfg.FragmentThreshold = (USHORT)FragThresh;
-                                               }
-                                               //pAd->CommonCfg.AllowFragSize = (pAd->CommonCfg.FragmentThreshold) - LENGTH_802_11 - LENGTH_CRC;
-                                               DBGPRINT(RT_DEBUG_TRACE, ("FragThreshold=%d\n", pAd->CommonCfg.FragmentThreshold));
-                                       }
-                                       //TxBurst
-                                       if(RTMPGetKeyParameter("TxBurst", tmpbuf, 10, buffer))
-                                       {
-                                               if(simple_strtol(tmpbuf, 0, 10) != 0)  //Enable
-                                                       pAd->CommonCfg.bEnableTxBurst = TRUE;
-                                               else //Disable
-                                                       pAd->CommonCfg.bEnableTxBurst = FALSE;
-                                               DBGPRINT(RT_DEBUG_TRACE, ("TxBurst=%d\n", pAd->CommonCfg.bEnableTxBurst));
-                                       }
-
-#ifdef AGGREGATION_SUPPORT
-                                       //PktAggregate
-                                       if(RTMPGetKeyParameter("PktAggregate", tmpbuf, 10, buffer))
-                                       {
-                                               if(simple_strtol(tmpbuf, 0, 10) != 0)  //Enable
-                                                       pAd->CommonCfg.bAggregationCapable = TRUE;
-                                               else //Disable
-                                                       pAd->CommonCfg.bAggregationCapable = FALSE;
-#ifdef PIGGYBACK_SUPPORT
-                                               pAd->CommonCfg.bPiggyBackCapable = pAd->CommonCfg.bAggregationCapable;
-#endif // PIGGYBACK_SUPPORT //
-                                               DBGPRINT(RT_DEBUG_TRACE, ("PktAggregate=%d\n", pAd->CommonCfg.bAggregationCapable));
-                                       }
-#else
-                                       pAd->CommonCfg.bAggregationCapable = FALSE;
-                                       pAd->CommonCfg.bPiggyBackCapable = FALSE;
-#endif // AGGREGATION_SUPPORT //
-
-                                       // WmmCapable
-                                       rtmp_read_sta_wmm_parms_from_file(pAd, tmpbuf, buffer);
-
-                                       //ShortSlot
-                                       if(RTMPGetKeyParameter("ShortSlot", tmpbuf, 10, buffer))
-                                       {
-                                               if(simple_strtol(tmpbuf, 0, 10) != 0)  //Enable
-                                                       pAd->CommonCfg.bUseShortSlotTime = TRUE;
-                                               else //Disable
-                                                       pAd->CommonCfg.bUseShortSlotTime = FALSE;
-
-                                               DBGPRINT(RT_DEBUG_TRACE, ("ShortSlot=%d\n", pAd->CommonCfg.bUseShortSlotTime));
-                                       }
-                                       //IEEE80211H
-                                       if(RTMPGetKeyParameter("IEEE80211H", tmpbuf, 10, buffer))
-                                       {
-                                           for (i = 0, macptr = rstrtok(tmpbuf,";"); macptr; macptr = rstrtok(NULL,";"), i++)
-                                           {
-                                               if(simple_strtol(macptr, 0, 10) != 0)  //Enable
-                                                       pAd->CommonCfg.bIEEE80211H = TRUE;
-                                               else //Disable
-                                                       pAd->CommonCfg.bIEEE80211H = FALSE;
-
-                                               DBGPRINT(RT_DEBUG_TRACE, ("IEEE80211H=%d\n", pAd->CommonCfg.bIEEE80211H));
-                                           }
-                                       }
-                                       //CSPeriod
-                                       if(RTMPGetKeyParameter("CSPeriod", tmpbuf, 10, buffer))
-                                       {
-                                           if(simple_strtol(tmpbuf, 0, 10) != 0)
-                                                       pAd->CommonCfg.RadarDetect.CSPeriod = simple_strtol(tmpbuf, 0, 10);
-                                               else
-                                                       pAd->CommonCfg.RadarDetect.CSPeriod = 0;
-
-                                               DBGPRINT(RT_DEBUG_TRACE, ("CSPeriod=%d\n", pAd->CommonCfg.RadarDetect.CSPeriod));
-                                       }
-
-                                       //RDRegion
-                                       if(RTMPGetKeyParameter("RDRegion", tmpbuf, 128, buffer))
-                                       {
-                                               if ((strncmp(tmpbuf, "JAP_W53", 7) == 0) || (strncmp(tmpbuf, "jap_w53", 7) == 0))
-                                               {
-                                                       pAd->CommonCfg.RadarDetect.RDDurRegion = JAP_W53;
-                                                       pAd->CommonCfg.RadarDetect.DfsSessionTime = 15;
-                                               }
-                                               else if ((strncmp(tmpbuf, "JAP_W56", 7) == 0) || (strncmp(tmpbuf, "jap_w56", 7) == 0))
-                                               {
-                                                       pAd->CommonCfg.RadarDetect.RDDurRegion = JAP_W56;
-                                                       pAd->CommonCfg.RadarDetect.DfsSessionTime = 13;
-                                               }
-                                               else if ((strncmp(tmpbuf, "JAP", 3) == 0) || (strncmp(tmpbuf, "jap", 3) == 0))
-                                               {
-                                                       pAd->CommonCfg.RadarDetect.RDDurRegion = JAP;
-                                                       pAd->CommonCfg.RadarDetect.DfsSessionTime = 5;
-                                               }
-                                               else  if ((strncmp(tmpbuf, "FCC", 3) == 0) || (strncmp(tmpbuf, "fcc", 3) == 0))
-                                               {
-                                                       pAd->CommonCfg.RadarDetect.RDDurRegion = FCC;
-                                                       pAd->CommonCfg.RadarDetect.DfsSessionTime = 5;
-                                               }
-                                               else if ((strncmp(tmpbuf, "CE", 2) == 0) || (strncmp(tmpbuf, "ce", 2) == 0))
-                                               {
-                                                       pAd->CommonCfg.RadarDetect.RDDurRegion = CE;
-                                                       pAd->CommonCfg.RadarDetect.DfsSessionTime = 13;
-                                               }
-                                               else
-                                               {
-                                                       pAd->CommonCfg.RadarDetect.RDDurRegion = CE;
-                                                       pAd->CommonCfg.RadarDetect.DfsSessionTime = 13;
-                                               }
-
-                                               DBGPRINT(RT_DEBUG_TRACE, ("RDRegion=%d\n", pAd->CommonCfg.RadarDetect.RDDurRegion));
-                                       }
-                                       else
-                                       {
-                                               pAd->CommonCfg.RadarDetect.RDDurRegion = CE;
-                                               pAd->CommonCfg.RadarDetect.DfsSessionTime = 13;
-                                       }
-
-                                       //WirelessEvent
-                                       if(RTMPGetKeyParameter("WirelessEvent", tmpbuf, 10, buffer))
-                                       {
-#if WIRELESS_EXT >= 15
-                                           if(simple_strtol(tmpbuf, 0, 10) != 0)
-                                                       pAd->CommonCfg.bWirelessEvent = simple_strtol(tmpbuf, 0, 10);
-                                               else
-                                                       pAd->CommonCfg.bWirelessEvent = 0;      // disable
-#else
-                                               pAd->CommonCfg.bWirelessEvent = 0;      // disable
-#endif
-                                               DBGPRINT(RT_DEBUG_TRACE, ("WirelessEvent=%d\n", pAd->CommonCfg.bWirelessEvent));
-                                       }
-                                       if(RTMPGetKeyParameter("WiFiTest", tmpbuf, 10, buffer))
-                                       {
-                                           if(simple_strtol(tmpbuf, 0, 10) != 0)
-                                                       pAd->CommonCfg.bWiFiTest= simple_strtol(tmpbuf, 0, 10);
-                                               else
-                                                       pAd->CommonCfg.bWiFiTest = 0;   // disable
-
-                                               DBGPRINT(RT_DEBUG_TRACE, ("WiFiTest=%d\n", pAd->CommonCfg.bWiFiTest));
-                                       }
-                                       //AuthMode
-                                       if(RTMPGetKeyParameter("AuthMode", tmpbuf, 128, buffer))
-                                       {
-                                               {
-                                                       if ((strcmp(tmpbuf, "WEPAUTO") == 0) || (strcmp(tmpbuf, "wepauto") == 0))
-                                                           pAd->StaCfg.AuthMode = Ndis802_11AuthModeAutoSwitch;
-                                                       else if ((strcmp(tmpbuf, "SHARED") == 0) || (strcmp(tmpbuf, "shared") == 0))
-                                                           pAd->StaCfg.AuthMode = Ndis802_11AuthModeShared;
-                                                       else if ((strcmp(tmpbuf, "WPAPSK") == 0) || (strcmp(tmpbuf, "wpapsk") == 0))
-                                                           pAd->StaCfg.AuthMode = Ndis802_11AuthModeWPAPSK;
-                                                       else if ((strcmp(tmpbuf, "WPANONE") == 0) || (strcmp(tmpbuf, "wpanone") == 0))
-                                                           pAd->StaCfg.AuthMode = Ndis802_11AuthModeWPANone;
-                                                       else if ((strcmp(tmpbuf, "WPA2PSK") == 0) || (strcmp(tmpbuf, "wpa2psk") == 0))
-                                                           pAd->StaCfg.AuthMode = Ndis802_11AuthModeWPA2PSK;
-                                                       else if ((strcmp(tmpbuf, "WPA") == 0) || (strcmp(tmpbuf, "wpa") == 0))
-                                                           pAd->StaCfg.AuthMode = Ndis802_11AuthModeWPA;
-                                                       else if ((strcmp(tmpbuf, "WPA2") == 0) || (strcmp(tmpbuf, "wpa2") == 0))
-                                                           pAd->StaCfg.AuthMode = Ndis802_11AuthModeWPA2;
-                                                       else
-                                                           pAd->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
-
-                                                       pAd->StaCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED;
-
-                                                       DBGPRINT(RT_DEBUG_TRACE, ("%s::(EncrypType=%d)\n", __func__, pAd->StaCfg.WepStatus));
-                                               }
-                                       }
-                                       //EncrypType
-                                       if(RTMPGetKeyParameter("EncrypType", tmpbuf, 128, buffer))
-                                       {
-                                               {
-                                                       if ((strcmp(tmpbuf, "WEP") == 0) || (strcmp(tmpbuf, "wep") == 0))
-                                                               pAd->StaCfg.WepStatus   = Ndis802_11WEPEnabled;
-                                                       else if ((strcmp(tmpbuf, "TKIP") == 0) || (strcmp(tmpbuf, "tkip") == 0))
-                                                               pAd->StaCfg.WepStatus   = Ndis802_11Encryption2Enabled;
-                                                       else if ((strcmp(tmpbuf, "AES") == 0) || (strcmp(tmpbuf, "aes") == 0))
-                                                               pAd->StaCfg.WepStatus   = Ndis802_11Encryption3Enabled;
-                                                       else
-                                                               pAd->StaCfg.WepStatus   = Ndis802_11WEPDisabled;
-
-                                                       // Update all wepstatus related
-                                                       pAd->StaCfg.PairCipher          = pAd->StaCfg.WepStatus;
-                                                       pAd->StaCfg.GroupCipher         = pAd->StaCfg.WepStatus;
-                                                       pAd->StaCfg.OrigWepStatus       = pAd->StaCfg.WepStatus;
-                                                       pAd->StaCfg.bMixCipher          = FALSE;
-
-                                                       DBGPRINT(RT_DEBUG_TRACE, ("%s::(EncrypType=%d)\n", __func__, pAd->StaCfg.WepStatus));
-                                               }
-                                       }
-
-                                       {
-                                               if(RTMPGetCriticalParameter("WPAPSK", tmpbuf, 512, buffer))
-                                               {
-                                                       int     err=0;
-
-                                                       tmpbuf[strlen(tmpbuf)] = '\0'; // make STA can process .$^& for WPAPSK input
-
-                                                       if ((pAd->StaCfg.AuthMode != Ndis802_11AuthModeWPAPSK) &&
-                                                               (pAd->StaCfg.AuthMode != Ndis802_11AuthModeWPA2PSK) &&
-                                                               (pAd->StaCfg.AuthMode != Ndis802_11AuthModeWPANone)
-                                                               )
-                                                       {
-                                                               err = 1;
-                                                       }
-                                                       else if ((strlen(tmpbuf) >= 8) && (strlen(tmpbuf) < 64))
-                                                       {
-                                                               PasswordHash((char *)tmpbuf, pAd->CommonCfg.Ssid, pAd->CommonCfg.SsidLen, keyMaterial);
-                                                               NdisMoveMemory(pAd->StaCfg.PMK, keyMaterial, 32);
-
-                                                       }
-                                                       else if (strlen(tmpbuf) == 64)
-                                                       {
-                                                               AtoH(tmpbuf, keyMaterial, 32);
-                                                               NdisMoveMemory(pAd->StaCfg.PMK, keyMaterial, 32);
-                                                       }
-                                                       else
-                                                       {
-                                                               err = 1;
-                                                               DBGPRINT(RT_DEBUG_ERROR, ("%s::(WPAPSK key-string required 8 ~ 64 characters!)\n", __func__));
-                                                       }
-
-                                                       if (err == 0)
-                                                       {
-                                                               if ((pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK) ||
-                                                                       (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK))
-                                                               {
-                                                                       // Start STA supplicant state machine
-                                                                       pAd->StaCfg.WpaState = SS_START;
-                                                               }
-                                                               else if (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPANone)
-                                                               {
-                                                                       pAd->StaCfg.WpaState = SS_NOTUSE;
-                                                               }
-
-                                                               DBGPRINT(RT_DEBUG_TRACE, ("%s::(WPAPSK=%s)\n", __func__, tmpbuf));
-                                                       }
-                                               }
-                                       }
-
-                                       //DefaultKeyID, KeyType, KeyStr
-                                       rtmp_read_key_parms_from_file(pAd, tmpbuf, buffer);
-
-                                       HTParametersHook(pAd, tmpbuf, buffer);
-
-                                       {
-                                               //PSMode
-                                               if (RTMPGetKeyParameter("PSMode", tmpbuf, 10, buffer))
-                                               {
-                                                       if (pAd->StaCfg.BssType == BSS_INFRA)
-                                                       {
-                                                               if ((strcmp(tmpbuf, "MAX_PSP") == 0) || (strcmp(tmpbuf, "max_psp") == 0))
-                                                               {
-                                                                       // do NOT turn on PSM bit here, wait until MlmeCheckForPsmChange()
-                                                                       // to exclude certain situations.
-                                                                       //         MlmeSetPsm(pAd, PWR_SAVE);
-                                                                       OPSTATUS_SET_FLAG(pAd, fOP_STATUS_RECEIVE_DTIM);
-                                                                       if (pAd->StaCfg.bWindowsACCAMEnable == FALSE)
-                                                                               pAd->StaCfg.WindowsPowerMode = Ndis802_11PowerModeMAX_PSP;
-                                                                       pAd->StaCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeMAX_PSP;
-                                                                       pAd->StaCfg.DefaultListenCount = 5;
-                                                               }
-                                                               else if ((strcmp(tmpbuf, "Fast_PSP") == 0) || (strcmp(tmpbuf, "fast_psp") == 0)
-                                                                       || (strcmp(tmpbuf, "FAST_PSP") == 0))
-                                                               {
-                                                                       // do NOT turn on PSM bit here, wait until MlmeCheckForPsmChange()
-                                                                       // to exclude certain situations.
-                                                                       //         MlmeSetPsmBit(pAd, PWR_SAVE);
-                                                                       OPSTATUS_SET_FLAG(pAd, fOP_STATUS_RECEIVE_DTIM);
-                                                                       if (pAd->StaCfg.bWindowsACCAMEnable == FALSE)
-                                                                               pAd->StaCfg.WindowsPowerMode = Ndis802_11PowerModeFast_PSP;
-                                                                       pAd->StaCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeFast_PSP;
-                                                                       pAd->StaCfg.DefaultListenCount = 3;
-                                                               }
-                                                               else if ((strcmp(tmpbuf, "Legacy_PSP") == 0) || (strcmp(tmpbuf, "legacy_psp") == 0)
-                                                                       || (strcmp(tmpbuf, "LEGACY_PSP") == 0))
-                                                               {
-                                                                       // do NOT turn on PSM bit here, wait until MlmeCheckForPsmChange()
-                                                                       // to exclude certain situations.
-                                                                       //         MlmeSetPsmBit(pAd, PWR_SAVE);
-                                                                       OPSTATUS_SET_FLAG(pAd, fOP_STATUS_RECEIVE_DTIM);
-                                                                       if (pAd->StaCfg.bWindowsACCAMEnable == FALSE)
-                                                                               pAd->StaCfg.WindowsPowerMode = Ndis802_11PowerModeLegacy_PSP;
-                                                                       pAd->StaCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeLegacy_PSP;
-                                                                       pAd->StaCfg.DefaultListenCount = 3;
-                                                               }
-                                                               else
-                                                               { //Default Ndis802_11PowerModeCAM
-                                                                       // clear PSM bit immediately
-                                                                       MlmeSetPsmBit(pAd, PWR_ACTIVE);
-                                                                       OPSTATUS_SET_FLAG(pAd, fOP_STATUS_RECEIVE_DTIM);
-                                                                       if (pAd->StaCfg.bWindowsACCAMEnable == FALSE)
-                                                                               pAd->StaCfg.WindowsPowerMode = Ndis802_11PowerModeCAM;
-                                                                       pAd->StaCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeCAM;
-                                                               }
-                                                               DBGPRINT(RT_DEBUG_TRACE, ("PSMode=%ld\n", pAd->StaCfg.WindowsPowerMode));
-                                                       }
-                                               }
-                                               // FastRoaming
-                                               if (RTMPGetKeyParameter("FastRoaming", tmpbuf, 32, buffer))
-                                               {
-                                                       if (simple_strtol(tmpbuf, 0, 10) == 0)
-                                                               pAd->StaCfg.bFastRoaming = FALSE;
-                                                       else
-                                                               pAd->StaCfg.bFastRoaming = TRUE;
-
-                                                       DBGPRINT(RT_DEBUG_TRACE, ("FastRoaming=%d\n", pAd->StaCfg.bFastRoaming));
-                                               }
-                                               // RoamThreshold
-                                               if (RTMPGetKeyParameter("RoamThreshold", tmpbuf, 32, buffer))
-                                               {
-                                                       long lInfo = simple_strtol(tmpbuf, 0, 10);
-
-                                                       if (lInfo > 90 || lInfo < 60)
-                                                               pAd->StaCfg.dBmToRoam = -70;
-                                                       else
-                                                               pAd->StaCfg.dBmToRoam = (CHAR)(-1)*lInfo;
-
-                                                       DBGPRINT(RT_DEBUG_TRACE, ("RoamThreshold=%d  dBm\n", pAd->StaCfg.dBmToRoam));
-                                               }
-
-                                               if(RTMPGetKeyParameter("TGnWifiTest", tmpbuf, 10, buffer))
-                                               {
-                                                       if(simple_strtol(tmpbuf, 0, 10) == 0)
-                                                               pAd->StaCfg.bTGnWifiTest = FALSE;
-                                                       else
-                                                               pAd->StaCfg.bTGnWifiTest = TRUE;
-                                                               DBGPRINT(RT_DEBUG_TRACE, ("TGnWifiTest=%d\n", pAd->StaCfg.bTGnWifiTest));
-                                               }
-                                       }
-
-#ifdef RT30xx
-                                               {
-                                                       if(RTMPGetKeyParameter("AntDiversity", tmpbuf, 10, buffer))
-                                                       {
-                                                               for (i = 0, macptr = rstrtok(tmpbuf,";"); macptr; macptr = rstrtok(NULL,";"), i++)
-                                                               {
-                                                                       if(simple_strtol(macptr, 0, 10) != 0)  //Enable
-                                                                               pAd->CommonCfg.bRxAntDiversity = TRUE;
-                                                                       else //Disable
-                                                                               pAd->CommonCfg.bRxAntDiversity = FALSE;
-
-                                                                       DBGPRINT(RT_DEBUG_ERROR, ("AntDiversity=%d\n", pAd->CommonCfg.bRxAntDiversity));
-                                                               }
-                                                       }
-                                               }
-#endif // RT30xx //
-                               }
-                       }
-                       else
-                       {
-                               DBGPRINT(RT_DEBUG_TRACE, ("--> %s does not have a write method\n", src));
-                       }
-
-                       retval=filp_close(srcf,NULL);
-
-                       if (retval)
-                       {
-                               DBGPRINT(RT_DEBUG_TRACE, ("--> Error %d closing %s\n", -retval, src));
-                       }
-               }
-       }
-
-       set_fs(orgfs);
-
-       kfree(buffer);
-       kfree(tmpbuf);
-
-       return (NDIS_STATUS_SUCCESS);
-}
-
-static void    HTParametersHook(
-       IN      PRTMP_ADAPTER pAd,
-       IN      CHAR              *pValueStr,
-       IN      CHAR              *pInput)
-{
-
-       INT Value;
-
-    if (RTMPGetKeyParameter("HT_PROTECT", pValueStr, 25, pInput))
-    {
-        Value = simple_strtol(pValueStr, 0, 10);
-        if (Value == 0)
-        {
-            pAd->CommonCfg.bHTProtect = FALSE;
-        }
-        else
-        {
-            pAd->CommonCfg.bHTProtect = TRUE;
-        }
-        DBGPRINT(RT_DEBUG_TRACE, ("HT: Protection  = %s\n", (Value==0) ? "Disable" : "Enable"));
-    }
-
-    if (RTMPGetKeyParameter("HT_MIMOPSEnable", pValueStr, 25, pInput))
-    {
-        Value = simple_strtol(pValueStr, 0, 10);
-        if (Value == 0)
-        {
-            pAd->CommonCfg.bMIMOPSEnable = FALSE;
-        }
-        else
-        {
-            pAd->CommonCfg.bMIMOPSEnable = TRUE;
-        }
-        DBGPRINT(RT_DEBUG_TRACE, ("HT: MIMOPSEnable  = %s\n", (Value==0) ? "Disable" : "Enable"));
-    }
-
-
-    if (RTMPGetKeyParameter("HT_MIMOPSMode", pValueStr, 25, pInput))
-    {
-        Value = simple_strtol(pValueStr, 0, 10);
-        if (Value > MMPS_ENABLE)
-        {
-                       pAd->CommonCfg.BACapability.field.MMPSmode = MMPS_ENABLE;
-        }
-        else
-        {
-            //TODO: add mimo power saving mechanism
-            pAd->CommonCfg.BACapability.field.MMPSmode = MMPS_ENABLE;
-                       //pAd->CommonCfg.BACapability.field.MMPSmode = Value;
-        }
-        DBGPRINT(RT_DEBUG_TRACE, ("HT: MIMOPS Mode  = %d\n", Value));
-    }
-
-    if (RTMPGetKeyParameter("HT_BADecline", pValueStr, 25, pInput))
-    {
-        Value = simple_strtol(pValueStr, 0, 10);
-        if (Value == 0)
-        {
-            pAd->CommonCfg.bBADecline = FALSE;
-        }
-        else
-        {
-            pAd->CommonCfg.bBADecline = TRUE;
-        }
-        DBGPRINT(RT_DEBUG_TRACE, ("HT: BA Decline  = %s\n", (Value==0) ? "Disable" : "Enable"));
-    }
-
-
-    if (RTMPGetKeyParameter("HT_DisableReordering", pValueStr, 25, pInput))
-    {
-        Value = simple_strtol(pValueStr, 0, 10);
-        if (Value == 0)
-        {
-            pAd->CommonCfg.bDisableReordering = FALSE;
-        }
-        else
-        {
-            pAd->CommonCfg.bDisableReordering = TRUE;
-        }
-        DBGPRINT(RT_DEBUG_TRACE, ("HT: DisableReordering  = %s\n", (Value==0) ? "Disable" : "Enable"));
-    }
-
-    if (RTMPGetKeyParameter("HT_AutoBA", pValueStr, 25, pInput))
-    {
-        Value = simple_strtol(pValueStr, 0, 10);
-        if (Value == 0)
-        {
-            pAd->CommonCfg.BACapability.field.AutoBA = FALSE;
-           pAd->CommonCfg.BACapability.field.Policy = BA_NOTUSE;
-        }
-        else
-        {
-            pAd->CommonCfg.BACapability.field.AutoBA = TRUE;
-           pAd->CommonCfg.BACapability.field.Policy = IMMED_BA;
-        }
-        pAd->CommonCfg.REGBACapability.field.AutoBA = pAd->CommonCfg.BACapability.field.AutoBA;
-       pAd->CommonCfg.REGBACapability.field.Policy = pAd->CommonCfg.BACapability.field.Policy;
-        DBGPRINT(RT_DEBUG_TRACE, ("HT: Auto BA  = %s\n", (Value==0) ? "Disable" : "Enable"));
-    }
-
-       // Tx_+HTC frame
-    if (RTMPGetKeyParameter("HT_HTC", pValueStr, 25, pInput))
-       {
-               Value = simple_strtol(pValueStr, 0, 10);
-               if (Value == 0)
-               {
-                       pAd->HTCEnable = FALSE;
-               }
-               else
-               {
-                       pAd->HTCEnable = TRUE;
-               }
-               DBGPRINT(RT_DEBUG_TRACE, ("HT: Tx +HTC frame = %s\n", (Value==0) ? "Disable" : "Enable"));
-       }
-
-       // Enable HT Link Adaptation Control
-       if (RTMPGetKeyParameter("HT_LinkAdapt", pValueStr, 25, pInput))
-       {
-               Value = simple_strtol(pValueStr, 0, 10);
-               if (Value == 0)
-               {
-                       pAd->bLinkAdapt = FALSE;
-               }
-               else
-               {
-                       pAd->HTCEnable = TRUE;
-                       pAd->bLinkAdapt = TRUE;
-               }
-               DBGPRINT(RT_DEBUG_TRACE, ("HT: Link Adaptation Control = %s\n", (Value==0) ? "Disable" : "Enable(+HTC)"));
-       }
-
-       // Reverse Direction Mechanism
-    if (RTMPGetKeyParameter("HT_RDG", pValueStr, 25, pInput))
-       {
-               Value = simple_strtol(pValueStr, 0, 10);
-               if (Value == 0)
-               {
-                       pAd->CommonCfg.bRdg = FALSE;
-               }
-               else
-               {
-                       pAd->HTCEnable = TRUE;
-            pAd->CommonCfg.bRdg = TRUE;
-               }
-               DBGPRINT(RT_DEBUG_TRACE, ("HT: RDG = %s\n", (Value==0) ? "Disable" : "Enable(+HTC)"));
-       }
-
-
-
-
-       // Tx A-MSUD ?
-    if (RTMPGetKeyParameter("HT_AMSDU", pValueStr, 25, pInput))
-       {
-               Value = simple_strtol(pValueStr, 0, 10);
-               if (Value == 0)
-               {
-                       pAd->CommonCfg.BACapability.field.AmsduEnable = FALSE;
-               }
-               else
-               {
-            pAd->CommonCfg.BACapability.field.AmsduEnable = TRUE;
-               }
-               DBGPRINT(RT_DEBUG_TRACE, ("HT: Tx A-MSDU = %s\n", (Value==0) ? "Disable" : "Enable"));
-       }
-
-       // MPDU Density
-    if (RTMPGetKeyParameter("HT_MpduDensity", pValueStr, 25, pInput))
-       {
-               Value = simple_strtol(pValueStr, 0, 10);
-               if (Value <=7 && Value >= 0)
-               {
-                       pAd->CommonCfg.BACapability.field.MpduDensity = Value;
-                       DBGPRINT(RT_DEBUG_TRACE, ("HT: MPDU Density = %d\n", Value));
-               }
-               else
-               {
-                       pAd->CommonCfg.BACapability.field.MpduDensity = 4;
-                       DBGPRINT(RT_DEBUG_TRACE, ("HT: MPDU Density = %d (Default)\n", 4));
-               }
-       }
-
-       // Max Rx BA Window Size
-    if (RTMPGetKeyParameter("HT_BAWinSize", pValueStr, 25, pInput))
-       {
-               Value = simple_strtol(pValueStr, 0, 10);
-
-               if (Value >=1 && Value <= 64)
-               {
-                       pAd->CommonCfg.REGBACapability.field.RxBAWinLimit = Value;
-                       pAd->CommonCfg.BACapability.field.RxBAWinLimit = Value;
-                       DBGPRINT(RT_DEBUG_TRACE, ("HT: BA Windw Size = %d\n", Value));
-               }
-               else
-               {
-            pAd->CommonCfg.REGBACapability.field.RxBAWinLimit = 64;
-                       pAd->CommonCfg.BACapability.field.RxBAWinLimit = 64;
-                       DBGPRINT(RT_DEBUG_TRACE, ("HT: BA Windw Size = 64 (Defualt)\n"));
-               }
-
-       }
-
-       // Guard Interval
-       if (RTMPGetKeyParameter("HT_GI", pValueStr, 25, pInput))
-       {
-               Value = simple_strtol(pValueStr, 0, 10);
-
-               if (Value == GI_400)
-               {
-                       pAd->CommonCfg.RegTransmitSetting.field.ShortGI = GI_400;
-               }
-               else
-               {
-                       pAd->CommonCfg.RegTransmitSetting.field.ShortGI = GI_800;
-               }
-
-               DBGPRINT(RT_DEBUG_TRACE, ("HT: Guard Interval = %s\n", (Value==GI_400) ? "400" : "800" ));
-       }
-
-       // HT Operation Mode : Mixed Mode , Green Field
-       if (RTMPGetKeyParameter("HT_OpMode", pValueStr, 25, pInput))
-       {
-               Value = simple_strtol(pValueStr, 0, 10);
-
-               if (Value == HTMODE_GF)
-               {
-
-                       pAd->CommonCfg.RegTransmitSetting.field.HTMODE  = HTMODE_GF;
-               }
-               else
-               {
-                       pAd->CommonCfg.RegTransmitSetting.field.HTMODE  = HTMODE_MM;
-               }
-
-               DBGPRINT(RT_DEBUG_TRACE, ("HT: Operate Mode = %s\n", (Value==HTMODE_GF) ? "Green Field" : "Mixed Mode" ));
-       }
-
-       // Fixed Tx mode : CCK, OFDM
-       if (RTMPGetKeyParameter("FixedTxMode", pValueStr, 25, pInput))
-       {
-               UCHAR   fix_tx_mode;
-
-               {
-                       fix_tx_mode = FIXED_TXMODE_HT;
-
-                       if (strcmp(pValueStr, "OFDM") == 0 || strcmp(pValueStr, "ofdm") == 0)
-                       {
-                               fix_tx_mode = FIXED_TXMODE_OFDM;
-                       }
-                       else if (strcmp(pValueStr, "CCK") == 0 || strcmp(pValueStr, "cck") == 0)
-                       {
-                       fix_tx_mode = FIXED_TXMODE_CCK;
-                       }
-                       else if (strcmp(pValueStr, "HT") == 0 || strcmp(pValueStr, "ht") == 0)
-                       {
-                       fix_tx_mode = FIXED_TXMODE_HT;
-               }
-               else
-               {
-                               Value = simple_strtol(pValueStr, 0, 10);
-                               // 1 : CCK
-                               // 2 : OFDM
-                               // otherwise : HT
-                               if (Value == FIXED_TXMODE_CCK || Value == FIXED_TXMODE_OFDM)
-                                       fix_tx_mode = Value;
-                               else
-                                       fix_tx_mode = FIXED_TXMODE_HT;
-               }
-
-                       pAd->StaCfg.DesiredTransmitSetting.field.FixedTxMode = fix_tx_mode;
-                       DBGPRINT(RT_DEBUG_TRACE, ("Fixed Tx Mode = %d\n", fix_tx_mode));
-
-               }
-       }
-
-
-       // Channel Width
-       if (RTMPGetKeyParameter("HT_BW", pValueStr, 25, pInput))
-       {
-               Value = simple_strtol(pValueStr, 0, 10);
-
-               if (Value == BW_40)
-               {
-                       pAd->CommonCfg.RegTransmitSetting.field.BW  = BW_40;
-               }
-               else
-               {
-            pAd->CommonCfg.RegTransmitSetting.field.BW  = BW_20;
-               }
-
-#ifdef MCAST_RATE_SPECIFIC
-               pAd->CommonCfg.MCastPhyMode.field.BW = pAd->CommonCfg.RegTransmitSetting.field.BW;
-#endif // MCAST_RATE_SPECIFIC //
-
-               DBGPRINT(RT_DEBUG_TRACE, ("HT: Channel Width = %s\n", (Value==BW_40) ? "40 MHz" : "20 MHz" ));
-       }
-
-       if (RTMPGetKeyParameter("HT_EXTCHA", pValueStr, 25, pInput))
-       {
-               Value = simple_strtol(pValueStr, 0, 10);
-
-               if (Value == 0)
-               {
-
-                       pAd->CommonCfg.RegTransmitSetting.field.EXTCHA  = EXTCHA_BELOW;
-               }
-               else
-               {
-            pAd->CommonCfg.RegTransmitSetting.field.EXTCHA = EXTCHA_ABOVE;
-               }
-
-               DBGPRINT(RT_DEBUG_TRACE, ("HT: Ext Channel = %s\n", (Value==0) ? "BELOW" : "ABOVE" ));
-       }
-
-       // MSC
-       if (RTMPGetKeyParameter("HT_MCS", pValueStr, 50, pInput))
-       {
-               {
-                       Value = simple_strtol(pValueStr, 0, 10);
-
-                       if ((Value >= 0 && Value <= 23) || (Value == 32)) // 3*3
-               {
-                               pAd->StaCfg.DesiredTransmitSetting.field.MCS  = Value;
-                               pAd->StaCfg.bAutoTxRateSwitch = FALSE;
-                               DBGPRINT(RT_DEBUG_TRACE, ("HT: MCS = %d\n", pAd->StaCfg.DesiredTransmitSetting.field.MCS));
-               }
-               else
-               {
-                               pAd->StaCfg.DesiredTransmitSetting.field.MCS  = MCS_AUTO;
-                               pAd->StaCfg.bAutoTxRateSwitch = TRUE;
-                               DBGPRINT(RT_DEBUG_TRACE, ("HT: MCS = AUTO\n"));
-               }
-       }
-       }
-
-       // STBC
-    if (RTMPGetKeyParameter("HT_STBC", pValueStr, 25, pInput))
-       {
-               Value = simple_strtol(pValueStr, 0, 10);
-               if (Value == STBC_USE)
-               {
-                       pAd->CommonCfg.RegTransmitSetting.field.STBC = STBC_USE;
-               }
-               else
-               {
-                       pAd->CommonCfg.RegTransmitSetting.field.STBC = STBC_NONE;
-               }
-               DBGPRINT(RT_DEBUG_TRACE, ("HT: STBC = %d\n", pAd->CommonCfg.RegTransmitSetting.field.STBC));
-       }
-
-       // 40_Mhz_Intolerant
-       if (RTMPGetKeyParameter("HT_40MHZ_INTOLERANT", pValueStr, 25, pInput))
-       {
-               Value = simple_strtol(pValueStr, 0, 10);
-               if (Value == 0)
-               {
-                       pAd->CommonCfg.bForty_Mhz_Intolerant = FALSE;
-               }
-               else
-               {
-                       pAd->CommonCfg.bForty_Mhz_Intolerant = TRUE;
-               }
-               DBGPRINT(RT_DEBUG_TRACE, ("HT: 40MHZ INTOLERANT = %d\n", pAd->CommonCfg.bForty_Mhz_Intolerant));
-       }
-       //HT_TxStream
-       if(RTMPGetKeyParameter("HT_TxStream", pValueStr, 10, pInput))
-       {
-               switch (simple_strtol(pValueStr, 0, 10))
-               {
-                       case 1:
-                               pAd->CommonCfg.TxStream = 1;
-                               break;
-                       case 2:
-                               pAd->CommonCfg.TxStream = 2;
-                               break;
-                       case 3: // 3*3
-                       default:
-                               pAd->CommonCfg.TxStream = 3;
-
-                               if (pAd->MACVersion < RALINK_2883_VERSION)
-                                       pAd->CommonCfg.TxStream = 2; // only 2 tx streams for RT2860 series
-                               break;
-               }
-               DBGPRINT(RT_DEBUG_TRACE, ("HT: Tx Stream = %d\n", pAd->CommonCfg.TxStream));
-       }
-       //HT_RxStream
-       if(RTMPGetKeyParameter("HT_RxStream", pValueStr, 10, pInput))
-       {
-               switch (simple_strtol(pValueStr, 0, 10))
-               {
-                       case 1:
-                               pAd->CommonCfg.RxStream = 1;
-                               break;
-                       case 2:
-                               pAd->CommonCfg.RxStream = 2;
-                               break;
-                       case 3:
-                       default:
-                               pAd->CommonCfg.RxStream = 3;
-
-                               if (pAd->MACVersion < RALINK_2883_VERSION)
-                                       pAd->CommonCfg.RxStream = 2; // only 2 rx streams for RT2860 series
-                               break;
-               }
-               DBGPRINT(RT_DEBUG_TRACE, ("HT: Rx Stream = %d\n", pAd->CommonCfg.RxStream));
-       }
-
-}
+#include "../rt2870/rt_profile.c"
index a21db456a13fc37be70b41070308cc0b38786a90..5390ca3eb27aab60e8f359b91096f10e1a1306d3 100644 (file)
@@ -1,6674 +1 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify  *
- * it under the terms of the GNU General Public License as published by  *
- * the Free Software Foundation; either version 2 of the License, or     *
- * (at your option) any later version.                                   *
- *                                                                       *
- * 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.                          *
- *                                                                       *
- * You should have received a copy of the GNU General Public License     *
- * along with this program; if not, write to the                         *
- * Free Software Foundation, Inc.,                                       *
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- *                                                                       *
- *************************************************************************
-
-    Module Name:
-    rtmp.h
-
-    Abstract:
-    Miniport generic portion header file
-
-    Revision History:
-    Who         When          What
-    --------    ----------    ----------------------------------------------
-    Paul Lin    2002-08-01    created
-    James Tan   2002-09-06    modified (Revise NTCRegTable)
-    John Chang  2004-09-06    modified for RT2600
-*/
-#ifndef __RTMP_H__
-#define __RTMP_H__
-
-#include "link_list.h"
-#include "spectrum_def.h"
-
-#include "aironet.h"
-
-//#define DBG          1
-
-//#define DBG_DIAGNOSE         1
-
-#define VIRTUAL_IF_INC(__pAd) ((__pAd)->VirtualIfCnt++)
-#define VIRTUAL_IF_DEC(__pAd) ((__pAd)->VirtualIfCnt--)
-#define VIRTUAL_IF_NUM(__pAd) ((__pAd)->VirtualIfCnt)
-
-#ifdef RT2870
-////////////////////////////////////////////////////////////////////////////
-// The TX_BUFFER structure forms the transmitted USB packet to the device
-////////////////////////////////////////////////////////////////////////////
-typedef struct __TX_BUFFER{
-       union   {
-               UCHAR                   WirelessPacket[TX_BUFFER_NORMSIZE];
-               HEADER_802_11   NullFrame;
-               PSPOLL_FRAME    PsPollPacket;
-               RTS_FRAME               RTSFrame;
-       }field;
-       UCHAR                   Aggregation[4];  //Buffer for save Aggregation size.
-} TX_BUFFER, *PTX_BUFFER;
-
-typedef struct __HTTX_BUFFER{
-       union   {
-               UCHAR                   WirelessPacket[MAX_TXBULK_SIZE];
-               HEADER_802_11   NullFrame;
-               PSPOLL_FRAME    PsPollPacket;
-               RTS_FRAME               RTSFrame;
-       }field;
-       UCHAR                   Aggregation[4];  //Buffer for save Aggregation size.
-} HTTX_BUFFER, *PHTTX_BUFFER;
-
-
-// used to track driver-generated write irps
-typedef struct _TX_CONTEXT
-{
-       PVOID                   pAd;            //Initialized in MiniportInitialize
-       PURB                    pUrb;                   //Initialized in MiniportInitialize
-       PIRP                    pIrp;                   //used to cancel pending bulk out.
-                                                                       //Initialized in MiniportInitialize
-       PTX_BUFFER              TransferBuffer; //Initialized in MiniportInitialize
-       ULONG                   BulkOutSize;
-       UCHAR                   BulkOutPipeId;
-       UCHAR                   SelfIdx;
-       BOOLEAN                 InUse;
-       BOOLEAN                 bWaitingBulkOut; // at least one packet is in this TxContext, ready for making IRP anytime.
-       BOOLEAN                 bFullForBulkOut; // all tx buffer are full , so waiting for tx bulkout.
-       BOOLEAN                 IRPPending;
-       BOOLEAN                 LastOne;
-       BOOLEAN                 bAggregatible;
-       UCHAR                   Header_802_3[LENGTH_802_3];
-       UCHAR                   Rsv[2];
-       ULONG                   DataOffset;
-       UINT                    TxRate;
-       dma_addr_t              data_dma;               // urb dma on linux
-
-}      TX_CONTEXT, *PTX_CONTEXT, **PPTX_CONTEXT;
-
-
-// used to track driver-generated write irps
-typedef struct _HT_TX_CONTEXT
-{
-       PVOID                   pAd;            //Initialized in MiniportInitialize
-       PURB                    pUrb;                   //Initialized in MiniportInitialize
-       PIRP                    pIrp;                   //used to cancel pending bulk out.
-                                                                       //Initialized in MiniportInitialize
-       PHTTX_BUFFER    TransferBuffer; //Initialized in MiniportInitialize
-       ULONG                   BulkOutSize;    // Indicate the total bulk-out size in bytes in one bulk-transmission
-       UCHAR                   BulkOutPipeId;
-       BOOLEAN                 IRPPending;
-       BOOLEAN                 LastOne;
-       BOOLEAN                 bCurWriting;
-       BOOLEAN                 bRingEmpty;
-       BOOLEAN                 bCopySavePad;
-       UCHAR                   SavedPad[8];
-       UCHAR                   Header_802_3[LENGTH_802_3];
-       ULONG                   CurWritePosition;               // Indicate the buffer offset which packet will be inserted start from.
-       ULONG                   CurWriteRealPos;                // Indicate the buffer offset which packet now are writing to.
-       ULONG                   NextBulkOutPosition;    // Indicate the buffer start offset of a bulk-transmission
-       ULONG                   ENextBulkOutPosition;   // Indicate the buffer end offset of a bulk-transmission
-       UINT                    TxRate;
-       dma_addr_t              data_dma;               // urb dma on linux
-}      HT_TX_CONTEXT, *PHT_TX_CONTEXT, **PPHT_TX_CONTEXT;
-
-
-//
-// Structure to keep track of receive packets and buffers to indicate
-// receive data to the protocol.
-//
-typedef struct _RX_CONTEXT
-{
-       PUCHAR                          TransferBuffer;
-       PVOID                           pAd;
-       PIRP                            pIrp;//used to cancel pending bulk in.
-       PURB                            pUrb;
-       //These 2 Boolean shouldn't both be 1 at the same time.
-       ULONG                           BulkInOffset;   // number of packets waiting for reordering .
-       BOOLEAN                         bRxHandling;    // Notify this packet is being process now.
-       BOOLEAN                         InUse;                  // USB Hardware Occupied. Wait for USB HW to put packet.
-       BOOLEAN                         Readable;               // Receive Complete back. OK for driver to indicate receiving packet.
-       BOOLEAN                         IRPPending;             // TODO: To be removed
-       atomic_t                        IrpLock;
-       NDIS_SPIN_LOCK          RxContextLock;
-       dma_addr_t                      data_dma;               // urb dma on linux
-}      RX_CONTEXT, *PRX_CONTEXT;
-#endif // RT2870 //
-
-
-//
-//  NDIS Version definitions
-//
-#ifdef  NDIS50_MINIPORT
-#define RTMP_NDIS_MAJOR_VERSION     5
-#define RTMP_NDIS_MINOR_VERSION     0
-#endif
-
-#ifdef  NDIS51_MINIPORT
-#define RTMP_NDIS_MAJOR_VERSION     5
-#define RTMP_NDIS_MINOR_VERSION     1
-#endif
-
-extern  char    NIC_VENDOR_DESC[];
-extern  int     NIC_VENDOR_DESC_LEN;
-
-extern  unsigned char   SNAP_AIRONET[];
-extern  unsigned char   CipherSuiteCiscoCCKM[];
-extern  unsigned char   CipherSuiteCiscoCCKMLen;
-extern unsigned char   CipherSuiteCiscoCCKM24[];
-extern unsigned char   CipherSuiteCiscoCCKM24Len;
-extern  unsigned char   CipherSuiteCCXTkip[];
-extern  unsigned char   CipherSuiteCCXTkipLen;
-extern  unsigned char   CISCO_OUI[];
-extern  UCHAR  BaSizeArray[4];
-
-extern UCHAR BROADCAST_ADDR[MAC_ADDR_LEN];
-extern UCHAR MULTICAST_ADDR[MAC_ADDR_LEN];
-extern UCHAR ZERO_MAC_ADDR[MAC_ADDR_LEN];
-extern ULONG BIT32[32];
-extern UCHAR BIT8[8];
-extern char* CipherName[];
-extern char* MCSToMbps[];
-extern UCHAR    RxwiMCSToOfdmRate[12];
-extern UCHAR SNAP_802_1H[6];
-extern UCHAR SNAP_BRIDGE_TUNNEL[6];
-extern UCHAR SNAP_AIRONET[8];
-extern UCHAR CKIP_LLC_SNAP[8];
-extern UCHAR EAPOL_LLC_SNAP[8];
-extern UCHAR EAPOL[2];
-extern UCHAR IPX[2];
-extern UCHAR APPLE_TALK[2];
-extern UCHAR RateIdToPlcpSignal[12]; // see IEEE802.11a-1999 p.14
-extern UCHAR    OfdmRateToRxwiMCS[];
-extern UCHAR OfdmSignalToRateId[16] ;
-extern UCHAR default_cwmin[4];
-extern UCHAR default_cwmax[4];
-extern UCHAR default_sta_aifsn[4];
-extern UCHAR MapUserPriorityToAccessCategory[8];
-
-extern USHORT RateUpPER[];
-extern USHORT RateDownPER[];
-extern UCHAR  Phy11BNextRateDownward[];
-extern UCHAR  Phy11BNextRateUpward[];
-extern UCHAR  Phy11BGNextRateDownward[];
-extern UCHAR  Phy11BGNextRateUpward[];
-extern UCHAR  Phy11ANextRateDownward[];
-extern UCHAR  Phy11ANextRateUpward[];
-extern CHAR   RssiSafeLevelForTxRate[];
-extern UCHAR  RateIdToMbps[];
-extern USHORT RateIdTo500Kbps[];
-
-extern UCHAR  CipherSuiteWpaNoneTkip[];
-extern UCHAR  CipherSuiteWpaNoneTkipLen;
-
-extern UCHAR  CipherSuiteWpaNoneAes[];
-extern UCHAR  CipherSuiteWpaNoneAesLen;
-
-extern UCHAR  SsidIe;
-extern UCHAR  SupRateIe;
-extern UCHAR  ExtRateIe;
-
-extern UCHAR  HtCapIe;
-extern UCHAR  AddHtInfoIe;
-extern UCHAR  NewExtChanIe;
-
-extern UCHAR  ErpIe;
-extern UCHAR  DsIe;
-extern UCHAR  TimIe;
-extern UCHAR  WpaIe;
-extern UCHAR  Wpa2Ie;
-extern UCHAR  IbssIe;
-extern UCHAR  Ccx2Ie;
-extern UCHAR  WapiIe;
-
-extern UCHAR  WPA_OUI[];
-extern UCHAR  RSN_OUI[];
-extern UCHAR  WAPI_OUI[];
-extern UCHAR  WME_INFO_ELEM[];
-extern UCHAR  WME_PARM_ELEM[];
-extern UCHAR  Ccx2QosInfo[];
-extern UCHAR  Ccx2IeInfo[];
-extern UCHAR  RALINK_OUI[];
-extern UCHAR  PowerConstraintIE[];
-
-
-extern UCHAR  RateSwitchTable[];
-extern UCHAR  RateSwitchTable11B[];
-extern UCHAR  RateSwitchTable11G[];
-extern UCHAR  RateSwitchTable11BG[];
-
-extern UCHAR  RateSwitchTable11BGN1S[];
-extern UCHAR  RateSwitchTable11BGN2S[];
-extern UCHAR  RateSwitchTable11BGN2SForABand[];
-extern UCHAR  RateSwitchTable11N1S[];
-extern UCHAR  RateSwitchTable11N2S[];
-extern UCHAR  RateSwitchTable11N2SForABand[];
-
-extern UCHAR  PRE_N_HT_OUI[];
-
-#define        MAXSEQ          (0xFFF)
-
-struct reordering_mpdu
-{
-       struct reordering_mpdu  *next;
-       PNDIS_PACKET                    pPacket;                /* coverted to 802.3 frame */
-       int                                             Sequence;               /* sequence number of MPDU */
-       BOOLEAN                                 bAMSDU;
-};
-
-struct reordering_list
-{
-       struct reordering_mpdu *next;
-       int     qlen;
-};
-
-struct reordering_mpdu_pool
-{
-       PVOID                                   mem;
-       NDIS_SPIN_LOCK                  lock;
-       struct reordering_list  freelist;
-};
-
-typedef struct         _RSSI_SAMPLE {
-       CHAR                    LastRssi0;             // last received RSSI
-       CHAR                    LastRssi1;             // last received RSSI
-       CHAR                    LastRssi2;             // last received RSSI
-       CHAR                    AvgRssi0;
-       CHAR                    AvgRssi1;
-       CHAR                    AvgRssi2;
-       SHORT                   AvgRssi0X8;
-       SHORT                   AvgRssi1X8;
-       SHORT                   AvgRssi2X8;
-} RSSI_SAMPLE;
-
-//
-//  Queue structure and macros
-//
-typedef struct  _QUEUE_ENTRY    {
-       struct _QUEUE_ENTRY     *Next;
-}   QUEUE_ENTRY, *PQUEUE_ENTRY;
-
-// Queue structure
-typedef struct  _QUEUE_HEADER   {
-       PQUEUE_ENTRY    Head;
-       PQUEUE_ENTRY    Tail;
-       ULONG           Number;
-}   QUEUE_HEADER, *PQUEUE_HEADER;
-
-#define InitializeQueueHeader(QueueHeader)              \
-{                                                       \
-       (QueueHeader)->Head = (QueueHeader)->Tail = NULL;   \
-       (QueueHeader)->Number = 0;                          \
-}
-
-#define RemoveHeadQueue(QueueHeader)                \
-(QueueHeader)->Head;                                \
-{                                                   \
-       PQUEUE_ENTRY pNext;                             \
-       if ((QueueHeader)->Head != NULL)                                \
-       {                                                                                               \
-               pNext = (QueueHeader)->Head->Next;          \
-               (QueueHeader)->Head = pNext;                \
-               if (pNext == NULL)                          \
-                       (QueueHeader)->Tail = NULL;             \
-               (QueueHeader)->Number--;                    \
-       }                                                                                               \
-}
-
-#define InsertHeadQueue(QueueHeader, QueueEntry)            \
-{                                                           \
-               ((PQUEUE_ENTRY)QueueEntry)->Next = (QueueHeader)->Head; \
-               (QueueHeader)->Head = (PQUEUE_ENTRY)(QueueEntry);       \
-               if ((QueueHeader)->Tail == NULL)                        \
-                       (QueueHeader)->Tail = (PQUEUE_ENTRY)(QueueEntry);   \
-               (QueueHeader)->Number++;                                \
-}
-
-#define InsertTailQueue(QueueHeader, QueueEntry)                \
-{                                                               \
-       ((PQUEUE_ENTRY)QueueEntry)->Next = NULL;                    \
-       if ((QueueHeader)->Tail)                                    \
-               (QueueHeader)->Tail->Next = (PQUEUE_ENTRY)(QueueEntry); \
-       else                                                        \
-               (QueueHeader)->Head = (PQUEUE_ENTRY)(QueueEntry);       \
-       (QueueHeader)->Tail = (PQUEUE_ENTRY)(QueueEntry);           \
-       (QueueHeader)->Number++;                                    \
-}
-
-//
-//  Macros for flag and ref count operations
-//
-#define RTMP_SET_FLAG(_M, _F)       ((_M)->Flags |= (_F))
-#define RTMP_CLEAR_FLAG(_M, _F)     ((_M)->Flags &= ~(_F))
-#define RTMP_CLEAR_FLAGS(_M)        ((_M)->Flags = 0)
-#define RTMP_TEST_FLAG(_M, _F)      (((_M)->Flags & (_F)) != 0)
-#define RTMP_TEST_FLAGS(_M, _F)     (((_M)->Flags & (_F)) == (_F))
-
-#define OPSTATUS_SET_FLAG(_pAd, _F)     ((_pAd)->CommonCfg.OpStatusFlags |= (_F))
-#define OPSTATUS_CLEAR_FLAG(_pAd, _F)   ((_pAd)->CommonCfg.OpStatusFlags &= ~(_F))
-#define OPSTATUS_TEST_FLAG(_pAd, _F)    (((_pAd)->CommonCfg.OpStatusFlags & (_F)) != 0)
-
-#define CLIENT_STATUS_SET_FLAG(_pEntry,_F)      ((_pEntry)->ClientStatusFlags |= (_F))
-#define CLIENT_STATUS_CLEAR_FLAG(_pEntry,_F)    ((_pEntry)->ClientStatusFlags &= ~(_F))
-#define CLIENT_STATUS_TEST_FLAG(_pEntry,_F)     (((_pEntry)->ClientStatusFlags & (_F)) != 0)
-
-#define RX_FILTER_SET_FLAG(_pAd, _F)    ((_pAd)->CommonCfg.PacketFilter |= (_F))
-#define RX_FILTER_CLEAR_FLAG(_pAd, _F)  ((_pAd)->CommonCfg.PacketFilter &= ~(_F))
-#define RX_FILTER_TEST_FLAG(_pAd, _F)   (((_pAd)->CommonCfg.PacketFilter & (_F)) != 0)
-
-#define STA_NO_SECURITY_ON(_p)          (_p->StaCfg.WepStatus == Ndis802_11EncryptionDisabled)
-#define STA_WEP_ON(_p)                  (_p->StaCfg.WepStatus == Ndis802_11Encryption1Enabled)
-#define STA_TKIP_ON(_p)                 (_p->StaCfg.WepStatus == Ndis802_11Encryption2Enabled)
-#define STA_AES_ON(_p)                  (_p->StaCfg.WepStatus == Ndis802_11Encryption3Enabled)
-
-#define STA_TGN_WIFI_ON(_p)             (_p->StaCfg.bTGnWifiTest == TRUE)
-
-#define CKIP_KP_ON(_p)                         ((((_p)->StaCfg.CkipFlag) & 0x10) && ((_p)->StaCfg.bCkipCmicOn == TRUE))
-#define CKIP_CMIC_ON(_p)                       ((((_p)->StaCfg.CkipFlag) & 0x08) && ((_p)->StaCfg.bCkipCmicOn == TRUE))
-
-
-#define INC_RING_INDEX(_idx, _RingSize)    \
-{                                          \
-    (_idx) = (_idx+1) % (_RingSize);       \
-}
-
-// We will have a cost down version which mac version is 0x3090xxxx
-#define IS_RT3090(_pAd)                                ((((_pAd)->MACVersion & 0xffff0000) == 0x30710000) || (((_pAd)->MACVersion & 0xffff0000) == 0x30900000))
-
-#define IS_RT3070(_pAd)                                (((_pAd)->MACVersion & 0xffff0000) == 0x30700000)
-#define IS_RT3071(_pAd)                                (((_pAd)->MACVersion & 0xffff0000) == 0x30710000)
-#define IS_RT2070(_pAd)                                (((_pAd)->RfIcType == RFIC_2020) || ((_pAd)->EFuseTag == 0x27))
-
-#define IS_RT30xx(_pAd)                                (((_pAd)->MACVersion & 0xfff00000) == 0x30700000)
-
-#define RING_PACKET_INIT(_TxRing, _idx)    \
-{                                          \
-    _TxRing->Cell[_idx].pNdisPacket = NULL;                              \
-    _TxRing->Cell[_idx].pNextNdisPacket = NULL;                              \
-}
-
-#define TXDT_INIT(_TxD)    \
-{                                          \
-       NdisZeroMemory(_TxD, TXD_SIZE); \
-       _TxD->DMADONE = 1;                              \
-}
-
-//Set last data segment
-#define RING_SET_LASTDS(_TxD, _IsSD0)    \
-{                                          \
-    if (_IsSD0) {_TxD->LastSec0 = 1;}     \
-    else {_TxD->LastSec1 = 1;}     \
-}
-
-// Increase TxTsc value for next transmission
-// TODO:
-// When i==6, means TSC has done one full cycle, do re-keying stuff follow specs
-// Should send a special event microsoft defined to request re-key
-#define INC_TX_TSC(_tsc)                                \
-{                                                       \
-    int i=0;                                            \
-    while (++_tsc[i] == 0x0)                            \
-    {                                                   \
-        i++;                                            \
-        if (i == 6)                                     \
-            break;                                      \
-    }                                                   \
-}
-
-// StaActive.SupportedHtPhy.MCSSet is copied from AP beacon.  Don't need to update here.
-#define COPY_HTSETTINGS_FROM_MLME_AUX_TO_ACTIVE_CFG(_pAd)                                 \
-{                                                                                       \
-       _pAd->StaActive.SupportedHtPhy.ChannelWidth = _pAd->MlmeAux.HtCapability.HtCapInfo.ChannelWidth;      \
-       _pAd->StaActive.SupportedHtPhy.MimoPs = _pAd->MlmeAux.HtCapability.HtCapInfo.MimoPs;      \
-       _pAd->StaActive.SupportedHtPhy.GF = _pAd->MlmeAux.HtCapability.HtCapInfo.GF;      \
-       _pAd->StaActive.SupportedHtPhy.ShortGIfor20 = _pAd->MlmeAux.HtCapability.HtCapInfo.ShortGIfor20;      \
-       _pAd->StaActive.SupportedHtPhy.ShortGIfor40 = _pAd->MlmeAux.HtCapability.HtCapInfo.ShortGIfor40;      \
-       _pAd->StaActive.SupportedHtPhy.TxSTBC = _pAd->MlmeAux.HtCapability.HtCapInfo.TxSTBC;      \
-       _pAd->StaActive.SupportedHtPhy.RxSTBC = _pAd->MlmeAux.HtCapability.HtCapInfo.RxSTBC;      \
-       _pAd->StaActive.SupportedHtPhy.ExtChanOffset = _pAd->MlmeAux.AddHtInfo.AddHtInfo.ExtChanOffset;      \
-       _pAd->StaActive.SupportedHtPhy.RecomWidth = _pAd->MlmeAux.AddHtInfo.AddHtInfo.RecomWidth;      \
-       _pAd->StaActive.SupportedHtPhy.OperaionMode = _pAd->MlmeAux.AddHtInfo.AddHtInfo2.OperaionMode;      \
-       _pAd->StaActive.SupportedHtPhy.NonGfPresent = _pAd->MlmeAux.AddHtInfo.AddHtInfo2.NonGfPresent;      \
-       NdisMoveMemory((_pAd)->MacTab.Content[BSSID_WCID].HTCapability.MCSSet, (_pAd)->StaActive.SupportedPhyInfo.MCSSet, sizeof(UCHAR) * 16);\
-}
-
-#define COPY_AP_HTSETTINGS_FROM_BEACON(_pAd, _pHtCapability)                                 \
-{                                                                                       \
-       _pAd->MacTab.Content[BSSID_WCID].AMsduSize = (UCHAR)(_pHtCapability->HtCapInfo.AMsduSize);      \
-       _pAd->MacTab.Content[BSSID_WCID].MmpsMode= (UCHAR)(_pHtCapability->HtCapInfo.MimoPs);   \
-       _pAd->MacTab.Content[BSSID_WCID].MaxRAmpduFactor = (UCHAR)(_pHtCapability->HtCapParm.MaxRAmpduFactor);  \
-}
-
-//
-// BBP & RF are using indirect access. Before write any value into it.
-// We have to make sure there is no outstanding command pending via checking busy bit.
-//
-#define MAX_BUSY_COUNT  100         // Number of retry before failing access BBP & RF indirect register
-//
-
-#ifdef RT2870
-#define RTMP_RF_IO_WRITE32(_A, _V)                 RTUSBWriteRFRegister(_A, _V)
-#define RTMP_BBP_IO_READ8_BY_REG_ID(_A, _I, _pV)   RTUSBReadBBPRegister(_A, _I, _pV)
-#define RTMP_BBP_IO_WRITE8_BY_REG_ID(_A, _I, _V)   RTUSBWriteBBPRegister(_A, _I, _V)
-
-#define BBP_IO_WRITE8_BY_REG_ID(_A, _I, _V)                    RTUSBWriteBBPRegister(_A, _I, _V)
-#define BBP_IO_READ8_BY_REG_ID(_A, _I, _pV)            RTUSBReadBBPRegister(_A, _I, _pV)
-#endif // RT2870 //
-
-#ifdef RT30xx
-#define RTMP_RF_IO_READ8_BY_REG_ID(_A, _I, _pV)    RT30xxReadRFRegister(_A, _I, _pV)
-#define RTMP_RF_IO_WRITE8_BY_REG_ID(_A, _I, _V)    RT30xxWriteRFRegister(_A, _I, _V)
-#endif // RT30xx //
-
-#define     MAP_CHANNEL_ID_TO_KHZ(ch, khz)  {               \
-                switch (ch)                                 \
-                {                                           \
-                    case 1:     khz = 2412000;   break;     \
-                    case 2:     khz = 2417000;   break;     \
-                    case 3:     khz = 2422000;   break;     \
-                    case 4:     khz = 2427000;   break;     \
-                    case 5:     khz = 2432000;   break;     \
-                    case 6:     khz = 2437000;   break;     \
-                    case 7:     khz = 2442000;   break;     \
-                    case 8:     khz = 2447000;   break;     \
-                    case 9:     khz = 2452000;   break;     \
-                    case 10:    khz = 2457000;   break;     \
-                    case 11:    khz = 2462000;   break;     \
-                    case 12:    khz = 2467000;   break;     \
-                    case 13:    khz = 2472000;   break;     \
-                    case 14:    khz = 2484000;   break;     \
-                    case 36:  /* UNII */  khz = 5180000;   break;     \
-                    case 40:  /* UNII */  khz = 5200000;   break;     \
-                    case 44:  /* UNII */  khz = 5220000;   break;     \
-                    case 48:  /* UNII */  khz = 5240000;   break;     \
-                    case 52:  /* UNII */  khz = 5260000;   break;     \
-                    case 56:  /* UNII */  khz = 5280000;   break;     \
-                    case 60:  /* UNII */  khz = 5300000;   break;     \
-                    case 64:  /* UNII */  khz = 5320000;   break;     \
-                    case 149: /* UNII */  khz = 5745000;   break;     \
-                    case 153: /* UNII */  khz = 5765000;   break;     \
-                    case 157: /* UNII */  khz = 5785000;   break;     \
-                    case 161: /* UNII */  khz = 5805000;   break;     \
-                    case 165: /* UNII */  khz = 5825000;   break;     \
-                    case 100: /* HiperLAN2 */  khz = 5500000;   break;     \
-                    case 104: /* HiperLAN2 */  khz = 5520000;   break;     \
-                    case 108: /* HiperLAN2 */  khz = 5540000;   break;     \
-                    case 112: /* HiperLAN2 */  khz = 5560000;   break;     \
-                    case 116: /* HiperLAN2 */  khz = 5580000;   break;     \
-                    case 120: /* HiperLAN2 */  khz = 5600000;   break;     \
-                    case 124: /* HiperLAN2 */  khz = 5620000;   break;     \
-                    case 128: /* HiperLAN2 */  khz = 5640000;   break;     \
-                    case 132: /* HiperLAN2 */  khz = 5660000;   break;     \
-                    case 136: /* HiperLAN2 */  khz = 5680000;   break;     \
-                    case 140: /* HiperLAN2 */  khz = 5700000;   break;     \
-                    case 34:  /* Japan MMAC */   khz = 5170000;   break;   \
-                    case 38:  /* Japan MMAC */   khz = 5190000;   break;   \
-                    case 42:  /* Japan MMAC */   khz = 5210000;   break;   \
-                    case 46:  /* Japan MMAC */   khz = 5230000;   break;   \
-                    case 184: /* Japan */   khz = 4920000;   break;   \
-                    case 188: /* Japan */   khz = 4940000;   break;   \
-                    case 192: /* Japan */   khz = 4960000;   break;   \
-                    case 196: /* Japan */   khz = 4980000;   break;   \
-                    case 208: /* Japan, means J08 */   khz = 5040000;   break;   \
-                    case 212: /* Japan, means J12 */   khz = 5060000;   break;   \
-                    case 216: /* Japan, means J16 */   khz = 5080000;   break;   \
-                    default:    khz = 2412000;   break;     \
-                }                                           \
-            }
-
-#define     MAP_KHZ_TO_CHANNEL_ID(khz, ch)  {               \
-                switch (khz)                                \
-                {                                           \
-                    case 2412000:    ch = 1;     break;     \
-                    case 2417000:    ch = 2;     break;     \
-                    case 2422000:    ch = 3;     break;     \
-                    case 2427000:    ch = 4;     break;     \
-                    case 2432000:    ch = 5;     break;     \
-                    case 2437000:    ch = 6;     break;     \
-                    case 2442000:    ch = 7;     break;     \
-                    case 2447000:    ch = 8;     break;     \
-                    case 2452000:    ch = 9;     break;     \
-                    case 2457000:    ch = 10;    break;     \
-                    case 2462000:    ch = 11;    break;     \
-                    case 2467000:    ch = 12;    break;     \
-                    case 2472000:    ch = 13;    break;     \
-                    case 2484000:    ch = 14;    break;     \
-                    case 5180000:    ch = 36;  /* UNII */  break;     \
-                    case 5200000:    ch = 40;  /* UNII */  break;     \
-                    case 5220000:    ch = 44;  /* UNII */  break;     \
-                    case 5240000:    ch = 48;  /* UNII */  break;     \
-                    case 5260000:    ch = 52;  /* UNII */  break;     \
-                    case 5280000:    ch = 56;  /* UNII */  break;     \
-                    case 5300000:    ch = 60;  /* UNII */  break;     \
-                    case 5320000:    ch = 64;  /* UNII */  break;     \
-                    case 5745000:    ch = 149; /* UNII */  break;     \
-                    case 5765000:    ch = 153; /* UNII */  break;     \
-                    case 5785000:    ch = 157; /* UNII */  break;     \
-                    case 5805000:    ch = 161; /* UNII */  break;     \
-                    case 5825000:    ch = 165; /* UNII */  break;     \
-                    case 5500000:    ch = 100; /* HiperLAN2 */  break;     \
-                    case 5520000:    ch = 104; /* HiperLAN2 */  break;     \
-                    case 5540000:    ch = 108; /* HiperLAN2 */  break;     \
-                    case 5560000:    ch = 112; /* HiperLAN2 */  break;     \
-                    case 5580000:    ch = 116; /* HiperLAN2 */  break;     \
-                    case 5600000:    ch = 120; /* HiperLAN2 */  break;     \
-                    case 5620000:    ch = 124; /* HiperLAN2 */  break;     \
-                    case 5640000:    ch = 128; /* HiperLAN2 */  break;     \
-                    case 5660000:    ch = 132; /* HiperLAN2 */  break;     \
-                    case 5680000:    ch = 136; /* HiperLAN2 */  break;     \
-                    case 5700000:    ch = 140; /* HiperLAN2 */  break;     \
-                    case 5170000:    ch = 34;  /* Japan MMAC */   break;   \
-                    case 5190000:    ch = 38;  /* Japan MMAC */   break;   \
-                    case 5210000:    ch = 42;  /* Japan MMAC */   break;   \
-                    case 5230000:    ch = 46;  /* Japan MMAC */   break;   \
-                    case 4920000:    ch = 184; /* Japan */  break;   \
-                    case 4940000:    ch = 188; /* Japan */  break;   \
-                    case 4960000:    ch = 192; /* Japan */  break;   \
-                    case 4980000:    ch = 196; /* Japan */  break;   \
-                    case 5040000:    ch = 208; /* Japan, means J08 */  break;   \
-                    case 5060000:    ch = 212; /* Japan, means J12 */  break;   \
-                    case 5080000:    ch = 216; /* Japan, means J16 */  break;   \
-                    default:         ch = 1;     break;     \
-                }                                           \
-            }
-
-//
-// Common fragment list structure -  Identical to the scatter gather frag list structure
-//
-#define NIC_MAX_PHYS_BUF_COUNT              8
-
-typedef struct _RTMP_SCATTER_GATHER_ELEMENT {
-    PVOID              Address;
-    ULONG              Length;
-    PULONG             Reserved;
-} RTMP_SCATTER_GATHER_ELEMENT, *PRTMP_SCATTER_GATHER_ELEMENT;
-
-
-typedef struct _RTMP_SCATTER_GATHER_LIST {
-    ULONG  NumberOfElements;
-    PULONG Reserved;
-    RTMP_SCATTER_GATHER_ELEMENT Elements[NIC_MAX_PHYS_BUF_COUNT];
-} RTMP_SCATTER_GATHER_LIST, *PRTMP_SCATTER_GATHER_LIST;
-
-//
-//  Some utility macros
-//
-#ifndef min
-#define min(_a, _b)     (((_a) < (_b)) ? (_a) : (_b))
-#endif
-
-#ifndef max
-#define max(_a, _b)     (((_a) > (_b)) ? (_a) : (_b))
-#endif
-
-#define GET_LNA_GAIN(_pAd)     ((_pAd->LatchRfRegs.Channel <= 14) ? (_pAd->BLNAGain) : ((_pAd->LatchRfRegs.Channel <= 64) ? (_pAd->ALNAGain0) : ((_pAd->LatchRfRegs.Channel <= 128) ? (_pAd->ALNAGain1) : (_pAd->ALNAGain2))))
-
-#define INC_COUNTER64(Val)          (Val.QuadPart++)
-
-#define INFRA_ON(_p)                (OPSTATUS_TEST_FLAG(_p, fOP_STATUS_INFRA_ON))
-#define ADHOC_ON(_p)                (OPSTATUS_TEST_FLAG(_p, fOP_STATUS_ADHOC_ON))
-#define MONITOR_ON(_p)              (((_p)->StaCfg.BssType) == BSS_MONITOR)
-#define IDLE_ON(_p)                 (!INFRA_ON(_p) && !ADHOC_ON(_p))
-
-// Check LEAP & CCKM flags
-#define LEAP_ON(_p)                 (((_p)->StaCfg.LeapAuthMode) == CISCO_AuthModeLEAP)
-#define LEAP_CCKM_ON(_p)            ((((_p)->StaCfg.LeapAuthMode) == CISCO_AuthModeLEAP) && ((_p)->StaCfg.LeapAuthInfo.CCKM == TRUE))
-
-// if orginal Ethernet frame contains no LLC/SNAP, then an extra LLC/SNAP encap is required
-#define EXTRA_LLCSNAP_ENCAP_FROM_PKT_START(_pBufVA, _pExtraLlcSnapEncap)               \
-{                                                                                                                              \
-       if (((*(_pBufVA + 12) << 8) + *(_pBufVA + 13)) > 1500)          \
-       {                                                                                                                       \
-               _pExtraLlcSnapEncap = SNAP_802_1H;                                              \
-               if (NdisEqualMemory(IPX, _pBufVA + 12, 2) ||                    \
-                       NdisEqualMemory(APPLE_TALK, _pBufVA + 12, 2))           \
-               {                                                                                                               \
-                       _pExtraLlcSnapEncap = SNAP_BRIDGE_TUNNEL;                       \
-               }                                                                                                               \
-       }                                                                                                                       \
-       else                                                                                                            \
-       {                                                                                                                       \
-               _pExtraLlcSnapEncap = NULL;                                                             \
-       }                                                                                                                       \
-}
-
-// New Define for new Tx Path.
-#define EXTRA_LLCSNAP_ENCAP_FROM_PKT_OFFSET(_pBufVA, _pExtraLlcSnapEncap)      \
-{                                                                                                                              \
-       if (((*(_pBufVA) << 8) + *(_pBufVA + 1)) > 1500)                        \
-       {                                                                                                                       \
-               _pExtraLlcSnapEncap = SNAP_802_1H;                                              \
-               if (NdisEqualMemory(IPX, _pBufVA, 2) ||                                 \
-                       NdisEqualMemory(APPLE_TALK, _pBufVA, 2))                        \
-               {                                                                                                               \
-                       _pExtraLlcSnapEncap = SNAP_BRIDGE_TUNNEL;                       \
-               }                                                                                                               \
-       }                                                                                                                       \
-       else                                                                                                            \
-       {                                                                                                                       \
-               _pExtraLlcSnapEncap = NULL;                                                             \
-       }                                                                                                                       \
-}
-
-
-#define MAKE_802_3_HEADER(_p, _pMac1, _pMac2, _pType)                   \
-{                                                                       \
-    NdisMoveMemory(_p, _pMac1, MAC_ADDR_LEN);                           \
-    NdisMoveMemory((_p + MAC_ADDR_LEN), _pMac2, MAC_ADDR_LEN);          \
-    NdisMoveMemory((_p + MAC_ADDR_LEN * 2), _pType, LENGTH_802_3_TYPE); \
-}
-
-// if pData has no LLC/SNAP (neither RFC1042 nor Bridge tunnel), keep it that way.
-// else if the received frame is LLC/SNAP-encaped IPX or APPLETALK, preserve the LLC/SNAP field
-// else remove the LLC/SNAP field from the result Ethernet frame
-// Patch for WHQL only, which did not turn on Netbios but use IPX within its payload
-// Note:
-//     _pData & _DataSize may be altered (remove 8-byte LLC/SNAP) by this MACRO
-//     _pRemovedLLCSNAP: pointer to removed LLC/SNAP; NULL is not removed
-#define CONVERT_TO_802_3(_p8023hdr, _pDA, _pSA, _pData, _DataSize, _pRemovedLLCSNAP)      \
-{                                                                       \
-    char LLC_Len[2];                                                    \
-                                                                        \
-    _pRemovedLLCSNAP = NULL;                                            \
-    if (NdisEqualMemory(SNAP_802_1H, _pData, 6)  ||                     \
-        NdisEqualMemory(SNAP_BRIDGE_TUNNEL, _pData, 6))                 \
-    {                                                                   \
-        PUCHAR pProto = _pData + 6;                                     \
-                                                                        \
-        if ((NdisEqualMemory(IPX, pProto, 2) || NdisEqualMemory(APPLE_TALK, pProto, 2)) &&  \
-            NdisEqualMemory(SNAP_802_1H, _pData, 6))                    \
-        {                                                               \
-            LLC_Len[0] = (UCHAR)(_DataSize / 256);                      \
-            LLC_Len[1] = (UCHAR)(_DataSize % 256);                      \
-            MAKE_802_3_HEADER(_p8023hdr, _pDA, _pSA, LLC_Len);          \
-        }                                                               \
-        else                                                            \
-        {                                                               \
-            MAKE_802_3_HEADER(_p8023hdr, _pDA, _pSA, pProto);           \
-            _pRemovedLLCSNAP = _pData;                                  \
-            _DataSize -= LENGTH_802_1_H;                                \
-            _pData += LENGTH_802_1_H;                                   \
-        }                                                               \
-    }                                                                   \
-    else                                                                \
-    {                                                                   \
-        LLC_Len[0] = (UCHAR)(_DataSize / 256);                          \
-        LLC_Len[1] = (UCHAR)(_DataSize % 256);                          \
-        MAKE_802_3_HEADER(_p8023hdr, _pDA, _pSA, LLC_Len);              \
-    }                                                                   \
-}
-
-#define SWITCH_AB( _pAA, _pBB)    \
-{                                                                           \
-    PVOID pCC;                                                          \
-    pCC = _pBB;                                                 \
-    _pBB = _pAA;                                                 \
-    _pAA = pCC;                                                 \
-}
-
-// Enqueue this frame to MLME engine
-// We need to enqueue the whole frame because MLME need to pass data type
-// information from 802.11 header
-#ifdef RT2870
-#define REPORT_MGMT_FRAME_TO_MLME(_pAd, Wcid, _pFrame, _FrameSize, _Rssi0, _Rssi1, _Rssi2, _PlcpSignal)        \
-{                                                                                       \
-    UINT32 High32TSF=0, Low32TSF=0;                                                          \
-    MlmeEnqueueForRecv(_pAd, Wcid, High32TSF, Low32TSF, (UCHAR)_Rssi0, (UCHAR)_Rssi1,(UCHAR)_Rssi2,_FrameSize, _pFrame, (UCHAR)_PlcpSignal);   \
-}
-#endif // RT2870 //
-
-#ifdef RT30xx
-//Need to collect each ant's rssi concurrently
-//rssi1 is report to pair2 Ant and rss2 is reprot to pair1 Ant when 4 Ant
-#define COLLECT_RX_ANTENNA_AVERAGE_RSSI(_pAd, _rssi1, _rssi2)                                  \
-{                                                                                                                                                              \
-       SHORT   AvgRssi;                                                                                                                        \
-       UCHAR   UsedAnt;                                                                                                                        \
-       if (_pAd->RxAnt.EvaluatePeriod == 0)                                                                    \
-       {                                                                                                                                               \
-               UsedAnt = _pAd->RxAnt.Pair1PrimaryRxAnt;                                                        \
-               AvgRssi = _pAd->RxAnt.Pair1AvgRssi[UsedAnt];                                            \
-               if (AvgRssi < 0)                                                                                                        \
-                       AvgRssi = AvgRssi - (AvgRssi >> 3) + _rssi1;                                    \
-               else                                                                                                                            \
-                       AvgRssi = _rssi1 << 3;                                                                                  \
-               _pAd->RxAnt.Pair1AvgRssi[UsedAnt] = AvgRssi;                                            \
-       }                                                                                                                                               \
-       else                                                                                                                                    \
-       {                                                                                                                                               \
-               UsedAnt = _pAd->RxAnt.Pair1SecondaryRxAnt;                                                      \
-               AvgRssi = _pAd->RxAnt.Pair1AvgRssi[UsedAnt];                                            \
-               if ((AvgRssi < 0) && (_pAd->RxAnt.FirstPktArrivedWhenEvaluate))         \
-                       AvgRssi = AvgRssi - (AvgRssi >> 3) + _rssi1;                                    \
-               else                                                                                                                            \
-               {                                                                                                                                       \
-                       _pAd->RxAnt.FirstPktArrivedWhenEvaluate = TRUE;                                 \
-                       AvgRssi = _rssi1 << 3;                                                                                  \
-               }                                                                                                                                       \
-               _pAd->RxAnt.Pair1AvgRssi[UsedAnt] = AvgRssi;                                            \
-               _pAd->RxAnt.RcvPktNumWhenEvaluate++;                                                            \
-       }                                                                                                                                               \
-}
-#endif // RT30xx //
-
-
-#define NDIS_QUERY_BUFFER(_NdisBuf, _ppVA, _pBufLen)                    \
-    NdisQueryBuffer(_NdisBuf, _ppVA, _pBufLen)
-
-#define MAC_ADDR_EQUAL(pAddr1,pAddr2)           RTMPEqualMemory((PVOID)(pAddr1), (PVOID)(pAddr2), MAC_ADDR_LEN)
-#define SSID_EQUAL(ssid1, len1, ssid2, len2)    ((len1==len2) && (RTMPEqualMemory(ssid1, ssid2, len1)))
-
-//
-// Check if it is Japan W53(ch52,56,60,64) channel.
-//
-#define JapanChannelCheck(channel)  ((channel == 52) || (channel == 56) || (channel == 60) || (channel == 64))
-
-#define STA_PORT_SECURED(_pAd) \
-{ \
-       _pAd->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED; \
-       NdisAcquireSpinLock(&_pAd->MacTabLock); \
-       _pAd->MacTab.Content[BSSID_WCID].PortSecured = _pAd->StaCfg.PortSecured; \
-       NdisReleaseSpinLock(&_pAd->MacTabLock); \
-}
-
-//
-// Register set pair for initialzation register set definition
-//
-typedef struct  _RTMP_REG_PAIR
-{
-       ULONG   Register;
-       ULONG   Value;
-} RTMP_REG_PAIR, *PRTMP_REG_PAIR;
-
-typedef struct  _REG_PAIR
-{
-       UCHAR   Register;
-       UCHAR   Value;
-} REG_PAIR, *PREG_PAIR;
-
-//
-// Register set pair for initialzation register set definition
-//
-typedef struct  _RTMP_RF_REGS
-{
-       UCHAR   Channel;
-       ULONG   R1;
-       ULONG   R2;
-       ULONG   R3;
-       ULONG   R4;
-} RTMP_RF_REGS, *PRTMP_RF_REGS;
-
-typedef struct _FREQUENCY_ITEM {
-       UCHAR   Channel;
-       UCHAR   N;
-       UCHAR   R;
-       UCHAR   K;
-} FREQUENCY_ITEM, *PFREQUENCY_ITEM;
-
-//
-//  Data buffer for DMA operation, the buffer must be contiguous physical memory
-//  Both DMA to / from CPU use the same structure.
-//
-typedef struct  _RTMP_DMABUF
-{
-       ULONG                   AllocSize;
-       PVOID                   AllocVa;            // TxBuf virtual address
-       NDIS_PHYSICAL_ADDRESS   AllocPa;            // TxBuf physical address
-} RTMP_DMABUF, *PRTMP_DMABUF;
-
-
-typedef        union   _HEADER_802_11_SEQ{
-    struct {
-       USHORT                  Frag:4;
-       USHORT                  Sequence:12;
-    }   field;
-    USHORT           value;
-}      HEADER_802_11_SEQ, *PHEADER_802_11_SEQ;
-
-//
-//  Data buffer for DMA operation, the buffer must be contiguous physical memory
-//  Both DMA to / from CPU use the same structure.
-//
-typedef struct  _RTMP_REORDERBUF
-{
-       BOOLEAN                 IsFull;
-       PVOID                   AllocVa;            // TxBuf virtual address
-       UCHAR                   Header802_3[14];
-       HEADER_802_11_SEQ                       Sequence;       //support compressed bitmap BA, so no consider fragment in BA
-       UCHAR           DataOffset;
-       USHORT          Datasize;
-       ULONG                   AllocSize;
-#ifdef RT2870
-       PUCHAR                                  AllocPa;
-#endif // RT2870 //
-}   RTMP_REORDERBUF, *PRTMP_REORDERBUF;
-
-//
-// Control block (Descriptor) for all ring descriptor DMA operation, buffer must be
-// contiguous physical memory. NDIS_PACKET stored the binding Rx packet descriptor
-// which won't be released, driver has to wait until upper layer return the packet
-// before giveing up this rx ring descriptor to ASIC. NDIS_BUFFER is assocaited pair
-// to describe the packet buffer. For Tx, NDIS_PACKET stored the tx packet descriptor
-// which driver should ACK upper layer when the tx is physically done or failed.
-//
-typedef struct _RTMP_DMACB
-{
-       ULONG                   AllocSize;          // Control block size
-       PVOID                   AllocVa;            // Control block virtual address
-       NDIS_PHYSICAL_ADDRESS   AllocPa;            // Control block physical address
-       PNDIS_PACKET pNdisPacket;
-       PNDIS_PACKET pNextNdisPacket;
-
-       RTMP_DMABUF             DmaBuf;             // Associated DMA buffer structure
-} RTMP_DMACB, *PRTMP_DMACB;
-
-typedef struct _RTMP_TX_BUF
-{
-       PQUEUE_ENTRY    Next;
-       UCHAR           Index;
-       ULONG                   AllocSize;          // Control block size
-       PVOID                   AllocVa;            // Control block virtual address
-       NDIS_PHYSICAL_ADDRESS   AllocPa;            // Control block physical address
-} RTMP_TXBUF, *PRTMP_TXBUF;
-
-typedef struct _RTMP_RX_BUF
-{
-       BOOLEAN           InUse;
-       ULONG                   ByBaRecIndex;
-       RTMP_REORDERBUF MAP_RXBuf[MAX_RX_REORDERBUF];
-} RTMP_RXBUF, *PRTMP_RXBUF;
-typedef struct _RTMP_TX_RING
-{
-       RTMP_DMACB  Cell[TX_RING_SIZE];
-       UINT32          TxCpuIdx;
-       UINT32          TxDmaIdx;
-       UINT32          TxSwFreeIdx;    // software next free tx index
-} RTMP_TX_RING, *PRTMP_TX_RING;
-
-typedef struct _RTMP_RX_RING
-{
-       RTMP_DMACB  Cell[RX_RING_SIZE];
-       UINT32          RxCpuIdx;
-       UINT32          RxDmaIdx;
-       INT32           RxSwReadIdx;    // software next read index
-} RTMP_RX_RING, *PRTMP_RX_RING;
-
-typedef struct _RTMP_MGMT_RING
-{
-       RTMP_DMACB  Cell[MGMT_RING_SIZE];
-       UINT32          TxCpuIdx;
-       UINT32          TxDmaIdx;
-       UINT32          TxSwFreeIdx; // software next free tx index
-} RTMP_MGMT_RING, *PRTMP_MGMT_RING;
-
-//
-//  Statistic counter structure
-//
-typedef struct _COUNTER_802_3
-{
-       // General Stats
-       ULONG       GoodTransmits;
-       ULONG       GoodReceives;
-       ULONG       TxErrors;
-       ULONG       RxErrors;
-       ULONG       RxNoBuffer;
-
-       // Ethernet Stats
-       ULONG       RcvAlignmentErrors;
-       ULONG       OneCollision;
-       ULONG       MoreCollisions;
-
-} COUNTER_802_3, *PCOUNTER_802_3;
-
-typedef struct _COUNTER_802_11 {
-       ULONG           Length;
-       LARGE_INTEGER   LastTransmittedFragmentCount;
-       LARGE_INTEGER   TransmittedFragmentCount;
-       LARGE_INTEGER   MulticastTransmittedFrameCount;
-       LARGE_INTEGER   FailedCount;
-       LARGE_INTEGER   RetryCount;
-       LARGE_INTEGER   MultipleRetryCount;
-       LARGE_INTEGER   RTSSuccessCount;
-       LARGE_INTEGER   RTSFailureCount;
-       LARGE_INTEGER   ACKFailureCount;
-       LARGE_INTEGER   FrameDuplicateCount;
-       LARGE_INTEGER   ReceivedFragmentCount;
-       LARGE_INTEGER   MulticastReceivedFrameCount;
-       LARGE_INTEGER   FCSErrorCount;
-} COUNTER_802_11, *PCOUNTER_802_11;
-
-typedef struct _COUNTER_RALINK {
-       ULONG           TransmittedByteCount;   // both successful and failure, used to calculate TX throughput
-       ULONG           ReceivedByteCount;      // both CRC okay and CRC error, used to calculate RX throughput
-       ULONG           BeenDisassociatedCount;
-       ULONG           BadCQIAutoRecoveryCount;
-       ULONG           PoorCQIRoamingCount;
-       ULONG           MgmtRingFullCount;
-       ULONG           RxCountSinceLastNULL;
-       ULONG           RxCount;
-       ULONG           RxRingErrCount;
-       ULONG           KickTxCount;
-       ULONG           TxRingErrCount;
-       LARGE_INTEGER   RealFcsErrCount;
-       ULONG           PendingNdisPacketCount;
-
-       ULONG           OneSecOsTxCount[NUM_OF_TX_RING];
-       ULONG           OneSecDmaDoneCount[NUM_OF_TX_RING];
-       UINT32          OneSecTxDoneCount;
-       ULONG           OneSecRxCount;
-       UINT32          OneSecTxAggregationCount;
-       UINT32          OneSecRxAggregationCount;
-
-       UINT32                  OneSecFrameDuplicateCount;
-
-#ifdef RT2870
-       ULONG           OneSecTransmittedByteCount;   // both successful and failure, used to calculate TX throughput
-#endif // RT2870 //
-
-       UINT32          OneSecTxNoRetryOkCount;
-       UINT32          OneSecTxRetryOkCount;
-       UINT32          OneSecTxFailCount;
-       UINT32          OneSecFalseCCACnt;      // CCA error count, for debug purpose, might move to global counter
-       UINT32          OneSecRxOkCnt;          // RX without error
-       UINT32          OneSecRxOkDataCnt;      // unicast-to-me DATA frame count
-       UINT32          OneSecRxFcsErrCnt;      // CRC error
-       UINT32          OneSecBeaconSentCnt;
-       UINT32          LastOneSecTotalTxCount; // OneSecTxNoRetryOkCount + OneSecTxRetryOkCount + OneSecTxFailCount
-       UINT32          LastOneSecRxOkDataCnt;  // OneSecRxOkDataCnt
-       ULONG           DuplicateRcv;
-       ULONG           TxAggCount;
-       ULONG           TxNonAggCount;
-       ULONG           TxAgg1MPDUCount;
-       ULONG           TxAgg2MPDUCount;
-       ULONG           TxAgg3MPDUCount;
-       ULONG           TxAgg4MPDUCount;
-       ULONG           TxAgg5MPDUCount;
-       ULONG           TxAgg6MPDUCount;
-       ULONG           TxAgg7MPDUCount;
-       ULONG           TxAgg8MPDUCount;
-       ULONG           TxAgg9MPDUCount;
-       ULONG           TxAgg10MPDUCount;
-       ULONG           TxAgg11MPDUCount;
-       ULONG           TxAgg12MPDUCount;
-       ULONG           TxAgg13MPDUCount;
-       ULONG           TxAgg14MPDUCount;
-       ULONG           TxAgg15MPDUCount;
-       ULONG           TxAgg16MPDUCount;
-
-       LARGE_INTEGER       TransmittedOctetsInAMSDU;
-       LARGE_INTEGER       TransmittedAMSDUCount;
-       LARGE_INTEGER       ReceivedOctesInAMSDUCount;
-       LARGE_INTEGER       ReceivedAMSDUCount;
-       LARGE_INTEGER       TransmittedAMPDUCount;
-       LARGE_INTEGER       TransmittedMPDUsInAMPDUCount;
-       LARGE_INTEGER       TransmittedOctetsInAMPDUCount;
-       LARGE_INTEGER       MPDUInReceivedAMPDUCount;
-} COUNTER_RALINK, *PCOUNTER_RALINK;
-
-typedef struct _PID_COUNTER {
-       ULONG           TxAckRequiredCount;      // CRC error
-       ULONG           TxAggreCount;
-       ULONG           TxSuccessCount; // OneSecTxNoRetryOkCount + OneSecTxRetryOkCount + OneSecTxFailCount
-       ULONG           LastSuccessRate;
-} PID_COUNTER, *PPID_COUNTER;
-
-typedef struct _COUNTER_DRS {
-       // to record the each TX rate's quality. 0 is best, the bigger the worse.
-       USHORT          TxQuality[MAX_STEP_OF_TX_RATE_SWITCH];
-       UCHAR           PER[MAX_STEP_OF_TX_RATE_SWITCH];
-       UCHAR           TxRateUpPenalty;      // extra # of second penalty due to last unstable condition
-       ULONG           CurrTxRateStableTime; // # of second in current TX rate
-       BOOLEAN         fNoisyEnvironment;
-       BOOLEAN         fLastSecAccordingRSSI;
-       UCHAR           LastSecTxRateChangeAction; // 0: no change, 1:rate UP, 2:rate down
-       UCHAR                   LastTimeTxRateChangeAction; //Keep last time value of LastSecTxRateChangeAction
-       ULONG                   LastTxOkCount;
-} COUNTER_DRS, *PCOUNTER_DRS;
-
-//
-//  Arcfour Structure Added by PaulWu
-//
-typedef struct  _ARCFOUR
-{
-       UINT            X;
-       UINT            Y;
-       UCHAR           STATE[256];
-} ARCFOURCONTEXT, *PARCFOURCONTEXT;
-
-// MIMO Tx parameter, ShortGI, MCS, STBC, etc.  these are fields in TXWI too. just copy to TXWI.
-typedef struct  _RECEIVE_SETTING {
-       USHORT          NumOfRX:2;                 // MIMO. WE HAVE 3R
-       USHORT          Mode:2; //channel bandwidth 20MHz or 40 MHz
-       USHORT          ShortGI:1;
-       USHORT          STBC:2; //SPACE
-       USHORT          rsv:3;
-       USHORT          OFDM:1;
-       USHORT          MIMO:1;
- } RECEIVE_SETTING, *PRECEIVE_SETTING;
-
-// Shared key data structure
-typedef struct  _WEP_KEY {
-       UCHAR   KeyLen;                     // Key length for each key, 0: entry is invalid
-       UCHAR   Key[MAX_LEN_OF_KEY];        // right now we implement 4 keys, 128 bits max
-} WEP_KEY, *PWEP_KEY;
-
-typedef struct _CIPHER_KEY {
-       UCHAR   Key[16];            // right now we implement 4 keys, 128 bits max
-       UCHAR   RxMic[8];                       // make alignment
-       UCHAR   TxMic[8];
-       UCHAR   TxTsc[6];           // 48bit TSC value
-       UCHAR   RxTsc[6];           // 48bit TSC value
-       UCHAR   CipherAlg;          // 0-none, 1:WEP64, 2:WEP128, 3:TKIP, 4:AES, 5:CKIP64, 6:CKIP128
-       UCHAR   KeyLen;
-       UCHAR   BssId[6];
-            // Key length for each key, 0: entry is invalid
-       UCHAR   Type;               // Indicate Pairwise/Group when reporting MIC error
-} CIPHER_KEY, *PCIPHER_KEY;
-
-typedef struct _BBP_TUNING_STRUCT {
-       BOOLEAN     Enable;
-       UCHAR       FalseCcaCountUpperBound;  // 100 per sec
-       UCHAR       FalseCcaCountLowerBound;  // 10 per sec
-       UCHAR       R17LowerBound;            // specified in E2PROM
-       UCHAR       R17UpperBound;            // 0x68 according to David Tung
-       UCHAR       CurrentR17Value;
-} BBP_TUNING, *PBBP_TUNING;
-
-typedef struct _SOFT_RX_ANT_DIVERSITY_STRUCT {
-       UCHAR     EvaluatePeriod;                // 0:not evalute status, 1: evaluate status, 2: switching status
-       UCHAR     EvaluateStableCnt;
-       UCHAR     Pair1PrimaryRxAnt;     // 0:Ant-E1, 1:Ant-E2
-       UCHAR     Pair1SecondaryRxAnt;   // 0:Ant-E1, 1:Ant-E2
-       UCHAR     Pair2PrimaryRxAnt;     // 0:Ant-E3, 1:Ant-E4
-       UCHAR     Pair2SecondaryRxAnt;   // 0:Ant-E3, 1:Ant-E4
-       SHORT     Pair1AvgRssi[2];       // AvgRssi[0]:E1, AvgRssi[1]:E2
-       SHORT     Pair2AvgRssi[2];       // AvgRssi[0]:E3, AvgRssi[1]:E4
-       SHORT     Pair1LastAvgRssi;      //
-       SHORT     Pair2LastAvgRssi;      //
-       ULONG     RcvPktNumWhenEvaluate;
-       BOOLEAN   FirstPktArrivedWhenEvaluate;
-       RALINK_TIMER_STRUCT    RxAntDiversityTimer;
-} SOFT_RX_ANT_DIVERSITY, *PSOFT_RX_ANT_DIVERSITY;
-
-typedef struct _LEAP_AUTH_INFO {
-       BOOLEAN         Enabled;        //Ture: Enable LEAP Authentication
-       BOOLEAN         CCKM;           //Ture: Use Fast Reauthentication with CCKM
-       UCHAR           Reserve[2];
-       UCHAR           UserName[256];  //LEAP, User name
-       ULONG           UserNameLen;
-       UCHAR           Password[256];  //LEAP, User Password
-       ULONG           PasswordLen;
-} LEAP_AUTH_INFO, *PLEAP_AUTH_INFO;
-
-typedef struct {
-       UCHAR        Addr[MAC_ADDR_LEN];
-       UCHAR        ErrorCode[2];  //00 01-Invalid authentication type
-                                                               //00 02-Authentication timeout
-                                                               //00 03-Challenge from AP failed
-                                                               //00 04-Challenge to AP failed
-       BOOLEAN      Reported;
-} ROGUEAP_ENTRY, *PROGUEAP_ENTRY;
-
-typedef struct {
-       UCHAR               RogueApNr;
-       ROGUEAP_ENTRY       RogueApEntry[MAX_LEN_OF_BSS_TABLE];
-} ROGUEAP_TABLE, *PROGUEAP_TABLE;
-
-typedef struct {
-       BOOLEAN     Enable;
-       UCHAR       Delta;
-       BOOLEAN     PlusSign;
-} CCK_TX_POWER_CALIBRATE, *PCCK_TX_POWER_CALIBRATE;
-
-//
-// Receive Tuple Cache Format
-//
-typedef struct  _TUPLE_CACHE    {
-       BOOLEAN         Valid;
-       UCHAR           MacAddress[MAC_ADDR_LEN];
-       USHORT          Sequence;
-       USHORT          Frag;
-} TUPLE_CACHE, *PTUPLE_CACHE;
-
-//
-// Fragment Frame structure
-//
-typedef struct  _FRAGMENT_FRAME {
-       PNDIS_PACKET    pFragPacket;
-       ULONG       RxSize;
-       USHORT      Sequence;
-       USHORT      LastFrag;
-       ULONG       Flags;          // Some extra frame information. bit 0: LLC presented
-} FRAGMENT_FRAME, *PFRAGMENT_FRAME;
-
-
-//
-// Packet information for NdisQueryPacket
-//
-typedef struct  _PACKET_INFO    {
-       UINT            PhysicalBufferCount;    // Physical breaks of buffer descripor chained
-       UINT            BufferCount ;           // Number of Buffer descriptor chained
-       UINT            TotalPacketLength ;     // Self explained
-       PNDIS_BUFFER    pFirstBuffer;           // Pointer to first buffer descriptor
-} PACKET_INFO, *PPACKET_INFO;
-
-//
-// Tkip Key structure which RC4 key & MIC calculation
-//
-typedef struct  _TKIP_KEY_INFO  {
-       UINT        nBytesInM;  // # bytes in M for MICKEY
-       ULONG       IV16;
-       ULONG       IV32;
-       ULONG       K0;         // for MICKEY Low
-       ULONG       K1;         // for MICKEY Hig
-       ULONG       L;          // Current state for MICKEY
-       ULONG       R;          // Current state for MICKEY
-       ULONG       M;          // Message accumulator for MICKEY
-       UCHAR       RC4KEY[16];
-       UCHAR       MIC[8];
-} TKIP_KEY_INFO, *PTKIP_KEY_INFO;
-
-//
-// Private / Misc data, counters for driver internal use
-//
-typedef struct  __PRIVATE_STRUC {
-       UINT       SystemResetCnt;         // System reset counter
-       UINT       TxRingFullCnt;          // Tx ring full occurrance number
-       UINT       PhyRxErrCnt;            // PHY Rx error count, for debug purpose, might move to global counter
-       // Variables for WEP encryption / decryption in rtmp_wep.c
-       UINT       FCSCRC32;
-       ARCFOURCONTEXT  WEPCONTEXT;
-       // Tkip stuff
-       TKIP_KEY_INFO   Tx;
-       TKIP_KEY_INFO   Rx;
-} PRIVATE_STRUC, *PPRIVATE_STRUC;
-
-// structure to tune BBP R66 (BBP TUNING)
-typedef struct _BBP_R66_TUNING {
-       BOOLEAN     bEnable;
-       USHORT      FalseCcaLowerThreshold;  // default 100
-       USHORT      FalseCcaUpperThreshold;  // default 512
-       UCHAR       R66Delta;
-       UCHAR       R66CurrentValue;
-       BOOLEAN         R66LowerUpperSelect; //Before LinkUp, Used LowerBound or UpperBound as R66 value.
-} BBP_R66_TUNING, *PBBP_R66_TUNING;
-
-// structure to store channel TX power
-typedef struct _CHANNEL_TX_POWER {
-       USHORT     RemainingTimeForUse;         //unit: sec
-       UCHAR      Channel;
-       CHAR       Power;
-       CHAR       Power2;
-       UCHAR      MaxTxPwr;
-       UCHAR      DfsReq;
-} CHANNEL_TX_POWER, *PCHANNEL_TX_POWER;
-
-// structure to store 802.11j channel TX power
-typedef struct _CHANNEL_11J_TX_POWER {
-       UCHAR      Channel;
-       UCHAR      BW;  // BW_10 or BW_20
-       CHAR       Power;
-       CHAR       Power2;
-       USHORT     RemainingTimeForUse;         //unit: sec
-} CHANNEL_11J_TX_POWER, *PCHANNEL_11J_TX_POWER;
-
-typedef enum _ABGBAND_STATE_ {
-       UNKNOWN_BAND,
-       BG_BAND,
-       A_BAND,
-} ABGBAND_STATE;
-
-typedef struct _MLME_STRUCT {
-       // STA state machines
-       STATE_MACHINE           CntlMachine;
-       STATE_MACHINE           AssocMachine;
-       STATE_MACHINE           AuthMachine;
-       STATE_MACHINE           AuthRspMachine;
-       STATE_MACHINE           SyncMachine;
-       STATE_MACHINE           WpaPskMachine;
-       STATE_MACHINE           LeapMachine;
-       STATE_MACHINE           AironetMachine;
-       STATE_MACHINE_FUNC      AssocFunc[ASSOC_FUNC_SIZE];
-       STATE_MACHINE_FUNC      AuthFunc[AUTH_FUNC_SIZE];
-       STATE_MACHINE_FUNC      AuthRspFunc[AUTH_RSP_FUNC_SIZE];
-       STATE_MACHINE_FUNC      SyncFunc[SYNC_FUNC_SIZE];
-       STATE_MACHINE_FUNC      WpaPskFunc[WPA_PSK_FUNC_SIZE];
-       STATE_MACHINE_FUNC      AironetFunc[AIRONET_FUNC_SIZE];
-       STATE_MACHINE_FUNC      ActFunc[ACT_FUNC_SIZE];
-       // Action
-       STATE_MACHINE           ActMachine;
-
-       ULONG                   ChannelQuality;  // 0..100, Channel Quality Indication for Roaming
-       ULONG                   Now32;           // latch the value of NdisGetSystemUpTime()
-       ULONG                   LastSendNULLpsmTime;
-
-       BOOLEAN                 bRunning;
-       NDIS_SPIN_LOCK          TaskLock;
-       MLME_QUEUE              Queue;
-
-       UINT                    ShiftReg;
-
-       RALINK_TIMER_STRUCT     PeriodicTimer;
-       RALINK_TIMER_STRUCT     APSDPeriodicTimer;
-       RALINK_TIMER_STRUCT     LinkDownTimer;
-       RALINK_TIMER_STRUCT     LinkUpTimer;
-       ULONG                   PeriodicRound;
-       ULONG                   OneSecPeriodicRound;
-
-       UCHAR                                   RealRxPath;
-       BOOLEAN                                 bLowThroughput;
-       BOOLEAN                                 bEnableAutoAntennaCheck;
-       RALINK_TIMER_STRUCT             RxAntEvalTimer;
-
-#ifdef RT30xx
-       UCHAR CaliBW40RfR24;
-       UCHAR CaliBW20RfR24;
-#endif // RT30xx //
-
-} MLME_STRUCT, *PMLME_STRUCT;
-
-// structure for radar detection and channel switch
-typedef struct _RADAR_DETECT_STRUCT {
-       UCHAR           CSCount;                        //Channel switch counter
-       UCHAR           CSPeriod;                       //Channel switch period (beacon count)
-       UCHAR           RDCount;                        //Radar detection counter
-       UCHAR           RDMode;                         //Radar Detection mode
-       UCHAR           RDDurRegion;            //Radar detection duration region
-       UCHAR           BBPR16;
-       UCHAR           BBPR17;
-       UCHAR           BBPR18;
-       UCHAR           BBPR21;
-       UCHAR           BBPR22;
-       UCHAR           BBPR64;
-       ULONG           InServiceMonitorCount; // unit: sec
-       UINT8           DfsSessionTime;
-       BOOLEAN         bFastDfs;
-       UINT8           ChMovingTime;
-       UINT8           LongPulseRadarTh;
-} RADAR_DETECT_STRUCT, *PRADAR_DETECT_STRUCT;
-
-typedef enum _REC_BLOCKACK_STATUS
-{
-    Recipient_NONE=0,
-       Recipient_USED,
-       Recipient_HandleRes,
-    Recipient_Accept
-} REC_BLOCKACK_STATUS, *PREC_BLOCKACK_STATUS;
-
-typedef enum _ORI_BLOCKACK_STATUS
-{
-    Originator_NONE=0,
-       Originator_USED,
-    Originator_WaitRes,
-    Originator_Done
-} ORI_BLOCKACK_STATUS, *PORI_BLOCKACK_STATUS;
-
-typedef struct _BA_ORI_ENTRY{
-       UCHAR   Wcid;
-       UCHAR   TID;
-       UCHAR   BAWinSize;
-       UCHAR   Token;
-// Sequence is to fill every outgoing QoS DATA frame's sequence field in 802.11 header.
-       USHORT  Sequence;
-       USHORT  TimeOutValue;
-       ORI_BLOCKACK_STATUS  ORI_BA_Status;
-       RALINK_TIMER_STRUCT ORIBATimer;
-       PVOID   pAdapter;
-} BA_ORI_ENTRY, *PBA_ORI_ENTRY;
-
-typedef struct _BA_REC_ENTRY {
-       UCHAR   Wcid;
-       UCHAR   TID;
-       UCHAR   BAWinSize;      // 7.3.1.14. each buffer is capable of holding a max AMSDU or MSDU.
-       USHORT          LastIndSeq;
-       USHORT          TimeOutValue;
-       RALINK_TIMER_STRUCT RECBATimer;
-       ULONG           LastIndSeqAtTimer;
-       ULONG           nDropPacket;
-       ULONG           rcvSeq;
-       REC_BLOCKACK_STATUS  REC_BA_Status;
-       NDIS_SPIN_LOCK          RxReRingLock;                 // Rx Ring spinlock
-       PVOID   pAdapter;
-       struct reordering_list  list;
-} BA_REC_ENTRY, *PBA_REC_ENTRY;
-
-
-typedef struct {
-       ULONG           numAsRecipient;         // I am recipient of numAsRecipient clients. These client are in the BARecEntry[]
-       ULONG           numAsOriginator;        // I am originator of   numAsOriginator clients. These clients are in the BAOriEntry[]
-       BA_ORI_ENTRY       BAOriEntry[MAX_LEN_OF_BA_ORI_TABLE];
-       BA_REC_ENTRY       BARecEntry[MAX_LEN_OF_BA_REC_TABLE];
-} BA_TABLE, *PBA_TABLE;
-
-//For QureyBATableOID use;
-typedef struct  PACKED _OID_BA_REC_ENTRY{
-       UCHAR   MACAddr[MAC_ADDR_LEN];
-       UCHAR   BaBitmap;   // if (BaBitmap&(1<<TID)), this session with{MACAddr, TID}exists, so read BufSize[TID] for BufferSize
-       UCHAR   rsv;
-       UCHAR   BufSize[8];
-       REC_BLOCKACK_STATUS     REC_BA_Status[8];
-} OID_BA_REC_ENTRY, *POID_BA_REC_ENTRY;
-
-//For QureyBATableOID use;
-typedef struct  PACKED _OID_BA_ORI_ENTRY{
-       UCHAR   MACAddr[MAC_ADDR_LEN];
-       UCHAR   BaBitmap;  // if (BaBitmap&(1<<TID)), this session with{MACAddr, TID}exists, so read BufSize[TID] for BufferSize, read ORI_BA_Status[TID] for status
-       UCHAR   rsv;
-       UCHAR   BufSize[8];
-       ORI_BLOCKACK_STATUS  ORI_BA_Status[8];
-} OID_BA_ORI_ENTRY, *POID_BA_ORI_ENTRY;
-
-typedef struct _QUERYBA_TABLE{
-       OID_BA_ORI_ENTRY       BAOriEntry[32];
-       OID_BA_REC_ENTRY       BARecEntry[32];
-       UCHAR   OriNum;// Number of below BAOriEntry
-       UCHAR   RecNum;// Number of below BARecEntry
-} QUERYBA_TABLE, *PQUERYBA_TABLE;
-
-typedef        union   _BACAP_STRUC    {
-       struct  {
-               UINT32          RxBAWinLimit:8;
-               UINT32          TxBAWinLimit:8;
-               UINT32          AutoBA:1;       // automatically BA
-               UINT32          Policy:2;       // 0: DELAY_BA 1:IMMED_BA  (//BA Policy subfiled value in ADDBA frame)   2:BA-not use
-               UINT32          MpduDensity:3;
-               UINT32          AmsduEnable:1;  //Enable AMSDU transmisstion
-               UINT32          AmsduSize:1;    // 0:3839, 1:7935 bytes. UINT  MSDUSizeToBytes[]        = { 3839, 7935};
-               UINT32          MMPSmode:2;     // MIMO power save more, 0:static, 1:dynamic, 2:rsv, 3:mimo enable
-               UINT32          bHtAdhoc:1;                     // adhoc can use ht rate.
-               UINT32          b2040CoexistScanSup:1;          //As Sta, support do 2040 coexistence scan for AP. As Ap, support monitor trigger event to check if can use BW 40MHz.
-               UINT32          :4;
-       }       field;
-       UINT32                  word;
-} BACAP_STRUC, *PBACAP_STRUC;
-
-//This structure is for all 802.11n card InterOptibilityTest action. Reset all Num every n second.  (Details see MLMEPeriodic)
-typedef        struct  _IOT_STRUC      {
-       UCHAR                   Threshold[2];
-       UCHAR                   ReorderTimeOutNum[MAX_LEN_OF_BA_REC_TABLE];     // compare with threshold[0]
-       UCHAR                   RefreshNum[MAX_LEN_OF_BA_REC_TABLE];    // compare with threshold[1]
-       ULONG                   OneSecInWindowCount;
-       ULONG                   OneSecFrameDuplicateCount;
-       ULONG                   OneSecOutWindowCount;
-       UCHAR                   DelOriAct;
-       UCHAR                   DelRecAct;
-       UCHAR                   RTSShortProt;
-       UCHAR                   RTSLongProt;
-       BOOLEAN                 bRTSLongProtOn;
-       BOOLEAN                 bLastAtheros;
-    BOOLEAN                    bCurrentAtheros;
-    BOOLEAN         bNowAtherosBurstOn;
-       BOOLEAN                 bNextDisableRxBA;
-    BOOLEAN                    bToggle;
-} IOT_STRUC, *PIOT_STRUC;
-
-// This is the registry setting for 802.11n transmit setting.  Used in advanced page.
-typedef union _REG_TRANSMIT_SETTING {
- struct {
-                UINT32  rsv0:10;
-                UINT32  TxBF:1;
-         UINT32  BW:1; //channel bandwidth 20MHz or 40 MHz
-         UINT32  ShortGI:1;
-         UINT32  STBC:1; //SPACE
-         UINT32  TRANSNO:2;
-         UINT32  HTMODE:1;
-         UINT32  EXTCHA:2;
-         UINT32  rsv:13;
-    } field;
- UINT32   word;
-} REG_TRANSMIT_SETTING, *PREG_TRANSMIT_SETTING;
-
-typedef union  _DESIRED_TRANSMIT_SETTING {
-       struct  {
-                       USHORT          MCS:7;                  // MCS
-                       USHORT          PhyMode:4;
-                       USHORT          FixedTxMode:2;                  // If MCS isn't AUTO, fix rate in CCK, OFDM or HT mode.
-                       USHORT          rsv:3;
-       }       field;
-       USHORT          word;
- } DESIRED_TRANSMIT_SETTING, *PDESIRED_TRANSMIT_SETTING;
-
-typedef struct {
-       BOOLEAN         IsRecipient;
-       UCHAR   MACAddr[MAC_ADDR_LEN];
-       UCHAR   TID;
-       UCHAR   nMSDU;
-       USHORT   TimeOut;
-       BOOLEAN bAllTid;  // If True, delete all TID for BA sessions with this MACaddr.
-} OID_ADD_BA_ENTRY, *POID_ADD_BA_ENTRY;
-
-//
-// Multiple SSID structure
-//
-#define WLAN_MAX_NUM_OF_TIM                    ((MAX_LEN_OF_MAC_TABLE >> 3) + 1) /* /8 + 1 */
-#define WLAN_CT_TIM_BCMC_OFFSET                0 /* unit: 32B */
-
-/* clear bcmc TIM bit */
-#define WLAN_MR_TIM_BCMC_CLEAR(apidx) \
-       pAd->ApCfg.MBSSID[apidx].TimBitmaps[WLAN_CT_TIM_BCMC_OFFSET] &= ~BIT8[0];
-
-/* set bcmc TIM bit */
-#define WLAN_MR_TIM_BCMC_SET(apidx) \
-       pAd->ApCfg.MBSSID[apidx].TimBitmaps[WLAN_CT_TIM_BCMC_OFFSET] |= BIT8[0];
-
-/* clear a station PS TIM bit */
-#define WLAN_MR_TIM_BIT_CLEAR(ad_p, apidx, wcid) \
-       {       UCHAR tim_offset = wcid >> 3; \
-               UCHAR bit_offset = wcid & 0x7; \
-               ad_p->ApCfg.MBSSID[apidx].TimBitmaps[tim_offset] &= (~BIT8[bit_offset]); }
-
-/* set a station PS TIM bit */
-#define WLAN_MR_TIM_BIT_SET(ad_p, apidx, wcid) \
-       {       UCHAR tim_offset = wcid >> 3; \
-               UCHAR bit_offset = wcid & 0x7; \
-               ad_p->ApCfg.MBSSID[apidx].TimBitmaps[tim_offset] |= BIT8[bit_offset]; }
-
-#ifdef RT2870
-#define BEACON_BITMAP_MASK             0xff
-typedef struct _BEACON_SYNC_STRUCT_
-{
-       UCHAR                           BeaconBuf[HW_BEACON_MAX_COUNT][HW_BEACON_OFFSET];
-       UCHAR                                   BeaconTxWI[HW_BEACON_MAX_COUNT][TXWI_SIZE];
-       ULONG                                   TimIELocationInBeacon[HW_BEACON_MAX_COUNT];
-       ULONG                                   CapabilityInfoLocationInBeacon[HW_BEACON_MAX_COUNT];
-       BOOLEAN                                 EnableBeacon;           // trigger to enable beacon transmission.
-       UCHAR                                   BeaconBitMap;           // NOTE: If the MAX_MBSSID_NUM is larger than 8, this parameter need to change.
-       UCHAR                                   DtimBitOn;                      // NOTE: If the MAX_MBSSID_NUM is larger than 8, this parameter need to change.
-}BEACON_SYNC_STRUCT;
-#endif // RT2870 //
-
-typedef struct _MULTISSID_STRUCT {
-       UCHAR                                                           Bssid[MAC_ADDR_LEN];
-    UCHAR                               SsidLen;
-    CHAR                                Ssid[MAX_LEN_OF_SSID];
-    USHORT                              CapabilityInfo;
-
-    PNET_DEV                                           MSSIDDev;
-
-       NDIS_802_11_AUTHENTICATION_MODE     AuthMode;
-       NDIS_802_11_WEP_STATUS              WepStatus;
-       NDIS_802_11_WEP_STATUS                          GroupKeyWepStatus;
-       WPA_MIX_PAIR_CIPHER                                     WpaMixPairCipher;
-
-       ULONG                                                           TxCount;
-       ULONG                                                           RxCount;
-       ULONG                                                           ReceivedByteCount;
-       ULONG                                                           TransmittedByteCount;
-       ULONG                                                           RxErrorCount;
-       ULONG                                                           RxDropCount;
-
-       HTTRANSMIT_SETTING                                      HTPhyMode, MaxHTPhyMode, MinHTPhyMode;// For transmit phy setting in TXWI.
-       RT_HT_PHY_INFO                                          DesiredHtPhyInfo;
-       DESIRED_TRANSMIT_SETTING                DesiredTransmitSetting; // Desired transmit setting. this is for reading registry setting only. not useful.
-       BOOLEAN                                                         bAutoTxRateSwitch;
-
-       UCHAR                               DefaultKeyId;
-
-       UCHAR                                                           TxRate;       // RATE_1, RATE_2, RATE_5_5, RATE_11, ...
-       UCHAR                                                           DesiredRates[MAX_LEN_OF_SUPPORTED_RATES];// OID_802_11_DESIRED_RATES
-       UCHAR                                                           DesiredRatesIndex;
-       UCHAR                                                           MaxTxRate;            // RATE_1, RATE_2, RATE_5_5, RATE_11
-
-       UCHAR                                                           TimBitmaps[WLAN_MAX_NUM_OF_TIM];
-
-    // WPA
-    UCHAR                               GMK[32];
-    UCHAR                               PMK[32];
-       UCHAR                                                           GTK[32];
-    BOOLEAN                             IEEE8021X;
-    BOOLEAN                             PreAuth;
-    UCHAR                               GNonce[32];
-    UCHAR                               PortSecured;
-    NDIS_802_11_PRIVACY_FILTER          PrivacyFilter;
-    UCHAR                               BANClass3Data;
-    ULONG                               IsolateInterStaTraffic;
-
-    UCHAR                               RSNIE_Len[2];
-    UCHAR                               RSN_IE[2][MAX_LEN_OF_RSNIE];
-
-
-    UCHAR                                      TimIELocationInBeacon;
-    UCHAR                                      CapabilityInfoLocationInBeacon;
-    // outgoing BEACON frame buffer and corresponding TXWI
-       // PTXWI_STRUC                           BeaconTxWI; //
-    CHAR                                BeaconBuf[MAX_BEACON_SIZE]; // NOTE: BeaconBuf should be 4-byte aligned
-
-    BOOLEAN                             bHideSsid;
-       UINT16                                                          StationKeepAliveTime; // unit: second
-
-    USHORT                              VLAN_VID;
-    USHORT                              VLAN_Priority;
-
-    RT_802_11_ACL                                              AccessControlList;
-
-       // EDCA Qos
-    BOOLEAN                                                            bWmmCapable;    // 0:disable WMM, 1:enable WMM
-    BOOLEAN                                                            bDLSCapable;    // 0:disable DLS, 1:enable DLS
-
-       UCHAR                                                   DlsPTK[64];             // Due to windows dirver count on meetinghouse to handle 4-way shake
-
-       // For 802.1x daemon setting per BSS
-       UCHAR                                                           radius_srv_num;
-       RADIUS_SRV_INFO                                         radius_srv_info[MAX_RADIUS_SRV_NUM];
-
-#ifdef RTL865X_SOC
-       unsigned int                                            mylinkid;
-#endif
-
-
-       UINT32                                  RcvdConflictSsidCount;
-       UINT32                                  RcvdSpoofedAssocRespCount;
-       UINT32                                  RcvdSpoofedReassocRespCount;
-       UINT32                                  RcvdSpoofedProbeRespCount;
-       UINT32                                  RcvdSpoofedBeaconCount;
-       UINT32                                  RcvdSpoofedDisassocCount;
-       UINT32                                  RcvdSpoofedAuthCount;
-       UINT32                                  RcvdSpoofedDeauthCount;
-       UINT32                                  RcvdSpoofedUnknownMgmtCount;
-       UINT32                                  RcvdReplayAttackCount;
-
-       CHAR                                    RssiOfRcvdConflictSsid;
-       CHAR                                    RssiOfRcvdSpoofedAssocResp;
-       CHAR                                    RssiOfRcvdSpoofedReassocResp;
-       CHAR                                    RssiOfRcvdSpoofedProbeResp;
-       CHAR                                    RssiOfRcvdSpoofedBeacon;
-       CHAR                                    RssiOfRcvdSpoofedDisassoc;
-       CHAR                                    RssiOfRcvdSpoofedAuth;
-       CHAR                                    RssiOfRcvdSpoofedDeauth;
-       CHAR                                    RssiOfRcvdSpoofedUnknownMgmt;
-       CHAR                                    RssiOfRcvdReplayAttack;
-
-       BOOLEAN                                 bBcnSntReq;
-       UCHAR                                   BcnBufIdx;
-} MULTISSID_STRUCT, *PMULTISSID_STRUCT;
-
-// configuration common to OPMODE_AP as well as OPMODE_STA
-typedef struct _COMMON_CONFIG {
-
-       BOOLEAN         bCountryFlag;
-       UCHAR           CountryCode[3];
-       UCHAR           Geography;
-       UCHAR       CountryRegion;      // Enum of country region, 0:FCC, 1:IC, 2:ETSI, 3:SPAIN, 4:France, 5:MKK, 6:MKK1, 7:Israel
-       UCHAR       CountryRegionForABand;      // Enum of country region for A band
-       UCHAR       PhyMode;            // PHY_11A, PHY_11B, PHY_11BG_MIXED, PHY_ABG_MIXED
-       USHORT      Dsifs;              // in units of usec
-       ULONG       PacketFilter;       // Packet filter for receiving
-
-       CHAR        Ssid[MAX_LEN_OF_SSID]; // NOT NULL-terminated
-       UCHAR       SsidLen;               // the actual ssid length in used
-       UCHAR       LastSsidLen;               // the actual ssid length in used
-       CHAR        LastSsid[MAX_LEN_OF_SSID]; // NOT NULL-terminated
-       UCHAR           LastBssid[MAC_ADDR_LEN];
-
-       UCHAR       Bssid[MAC_ADDR_LEN];
-       USHORT      BeaconPeriod;
-       UCHAR       Channel;
-       UCHAR       CentralChannel;     // Central Channel when using 40MHz is indicating. not real channel.
-
-       UCHAR       SupRate[MAX_LEN_OF_SUPPORTED_RATES];
-       UCHAR       SupRateLen;
-       UCHAR       ExtRate[MAX_LEN_OF_SUPPORTED_RATES];
-       UCHAR       ExtRateLen;
-       UCHAR       DesireRate[MAX_LEN_OF_SUPPORTED_RATES];      // OID_802_11_DESIRED_RATES
-       UCHAR       MaxDesiredRate;
-       UCHAR       ExpectedACKRate[MAX_LEN_OF_SUPPORTED_RATES];
-
-       ULONG       BasicRateBitmap;        // backup basic ratebitmap
-
-       BOOLEAN         bAPSDCapable;
-       BOOLEAN         bInServicePeriod;
-       BOOLEAN         bAPSDAC_BE;
-       BOOLEAN         bAPSDAC_BK;
-       BOOLEAN         bAPSDAC_VI;
-       BOOLEAN         bAPSDAC_VO;
-       BOOLEAN         bNeedSendTriggerFrame;
-       BOOLEAN         bAPSDForcePowerSave;    // Force power save mode, should only use in APSD-STAUT
-       ULONG           TriggerTimerCount;
-       UCHAR           MaxSPLength;
-       UCHAR           BBPCurrentBW;   // BW_10,       BW_20, BW_40
-       REG_TRANSMIT_SETTING        RegTransmitSetting; //registry transmit setting. this is for reading registry setting only. not useful.
-       UCHAR       TxRate;                 // Same value to fill in TXD. TxRate is 6-bit
-       UCHAR       MaxTxRate;              // RATE_1, RATE_2, RATE_5_5, RATE_11
-       UCHAR       TxRateIndex;            // Tx rate index in RateSwitchTable
-       UCHAR       TxRateTableSize;        // Valid Tx rate table size in RateSwitchTable
-       UCHAR       MinTxRate;              // RATE_1, RATE_2, RATE_5_5, RATE_11
-       UCHAR       RtsRate;                // RATE_xxx
-       HTTRANSMIT_SETTING      MlmeTransmit;   // MGMT frame PHY rate setting when operatin at Ht rate.
-       UCHAR       MlmeRate;               // RATE_xxx, used to send MLME frames
-       UCHAR       BasicMlmeRate;          // Default Rate for sending MLME frames
-
-       USHORT      RtsThreshold;           // in unit of BYTE
-       USHORT      FragmentThreshold;      // in unit of BYTE
-
-       UCHAR       TxPower;                // in unit of mW
-       ULONG       TxPowerPercentage;      // 0~100 %
-       ULONG       TxPowerDefault;         // keep for TxPowerPercentage
-
-       BACAP_STRUC        BACapability; //   NO USE = 0XFF  ;  IMMED_BA =1  ;  DELAY_BA=0
-       BACAP_STRUC        REGBACapability; //   NO USE = 0XFF  ;  IMMED_BA =1  ;  DELAY_BA=0
-
-       IOT_STRUC               IOTestParm;     // 802.11n InterOpbility Test Parameter;
-       ULONG       TxPreamble;             // Rt802_11PreambleLong, Rt802_11PreambleShort, Rt802_11PreambleAuto
-       BOOLEAN     bUseZeroToDisableFragment;     // Microsoft use 0 as disable
-       ULONG       UseBGProtection;        // 0: auto, 1: always use, 2: always not use
-       BOOLEAN     bUseShortSlotTime;      // 0: disable, 1 - use short slot (9us)
-       BOOLEAN     bEnableTxBurst;         // 1: enble TX PACKET BURST, 0: disable TX PACKET BURST
-       BOOLEAN     bAggregationCapable;      // 1: enable TX aggregation when the peer supports it
-       BOOLEAN     bPiggyBackCapable;          // 1: enable TX piggy-back according MAC's version
-       BOOLEAN     bIEEE80211H;                        // 1: enable IEEE802.11h spec.
-       ULONG           DisableOLBCDetect;              // 0: enable OLBC detect; 1 disable OLBC detect
-
-       BOOLEAN                         bRdg;
-
-       BOOLEAN             bWmmCapable;        // 0:disable WMM, 1:enable WMM
-       QOS_CAPABILITY_PARM APQosCapability;    // QOS capability of the current associated AP
-       EDCA_PARM           APEdcaParm;         // EDCA parameters of the current associated AP
-       QBSS_LOAD_PARM      APQbssLoad;         // QBSS load of the current associated AP
-       UCHAR               AckPolicy[4];       // ACK policy of the specified AC. see ACK_xxx
-       BOOLEAN                         bDLSCapable;            // 0:disable DLS, 1:enable DLS
-       // a bitmap of BOOLEAN flags. each bit represent an operation status of a particular
-       // BOOLEAN control, either ON or OFF. These flags should always be accessed via
-       // OPSTATUS_TEST_FLAG(), OPSTATUS_SET_FLAG(), OP_STATUS_CLEAR_FLAG() macros.
-       // see fOP_STATUS_xxx in RTMP_DEF.C for detail bit definition
-       ULONG               OpStatusFlags;
-
-       BOOLEAN                         NdisRadioStateOff; //For HCT 12.0, set this flag to TRUE instead of called MlmeRadioOff.
-       ABGBAND_STATE           BandState;              // For setting BBP used on B/G or A mode.
-       BOOLEAN                         bRxAntDiversity; // 0:disable, 1:enable Software Rx Antenna Diversity.
-
-       // IEEE802.11H--DFS.
-       RADAR_DETECT_STRUCT     RadarDetect;
-
-       // HT
-       UCHAR                   BASize;         // USer desired BAWindowSize. Should not exceed our max capability
-       //RT_HT_CAPABILITY      SupportedHtPhy;
-       RT_HT_CAPABILITY        DesiredHtPhy;
-       HT_CAPABILITY_IE                HtCapability;
-       ADD_HT_INFO_IE          AddHTInfo;      // Useful as AP.
-       //This IE is used with channel switch announcement element when changing to a new 40MHz.
-       //This IE is included in channel switch ammouncement frames 7.4.1.5, beacons, probe Rsp.
-       NEW_EXT_CHAN_IE NewExtChanOffset;       //7.3.2.20A, 1 if extension channel is above the control channel, 3 if below, 0 if not present
-
-    BOOLEAN                 bHTProtect;
-    BOOLEAN                 bMIMOPSEnable;
-    BOOLEAN                                    bBADecline;
-       BOOLEAN                                 bDisableReordering;
-       BOOLEAN                                 bForty_Mhz_Intolerant;
-       BOOLEAN                                 bExtChannelSwitchAnnouncement;
-       BOOLEAN                                 bRcvBSSWidthTriggerEvents;
-       ULONG                                   LastRcvBSSWidthTriggerEventsTime;
-
-       UCHAR                                   TxBASize;
-
-       // Enable wireless event
-       BOOLEAN                         bWirelessEvent;
-       BOOLEAN                         bWiFiTest;                              // Enable this parameter for WiFi test
-
-       // Tx & Rx Stream number selection
-       UCHAR                           TxStream;
-       UCHAR                           RxStream;
-
-       // transmit phy mode, trasmit rate for Multicast.
-#ifdef MCAST_RATE_SPECIFIC
-       UCHAR                           McastTransmitMcs;
-       UCHAR                           McastTransmitPhyMode;
-#endif // MCAST_RATE_SPECIFIC //
-
-       BOOLEAN                 bHardwareRadio;     // Hardware controlled Radio enabled
-
-#ifdef RT2870
-       BOOLEAN                 bMultipleIRP;       // Multiple Bulk IN flag
-       UCHAR                   NumOfBulkInIRP;     // if bMultipleIRP == TRUE, NumOfBulkInIRP will be 4 otherwise be 1
-       RT_HT_CAPABILITY        SupportedHtPhy;
-       ULONG                           MaxPktOneTxBulk;
-       UCHAR                           TxBulkFactor;
-       UCHAR                           RxBulkFactor;
-
-       BEACON_SYNC_STRUCT      *pBeaconSync;
-       RALINK_TIMER_STRUCT     BeaconUpdateTimer;
-       UINT32                          BeaconAdjust;
-       UINT32                          BeaconFactor;
-       UINT32                          BeaconRemain;
-#endif // RT2870 //
-
-
-       NDIS_SPIN_LOCK                  MeasureReqTabLock;
-       PMEASURE_REQ_TAB                pMeasureReqTab;
-
-       NDIS_SPIN_LOCK                  TpcReqTabLock;
-       PTPC_REQ_TAB                    pTpcReqTab;
-
-       // transmit phy mode, trasmit rate for Multicast.
-#ifdef MCAST_RATE_SPECIFIC
-       HTTRANSMIT_SETTING              MCastPhyMode;
-#endif // MCAST_RATE_SPECIFIC //
-} COMMON_CONFIG, *PCOMMON_CONFIG;
-
-/* Modified by Wu Xi-Kun 4/21/2006 */
-// STA configuration and status
-typedef struct _STA_ADMIN_CONFIG {
-       // GROUP 1 -
-       //   User configuration loaded from Registry, E2PROM or OID_xxx. These settings describe
-       //   the user intended configuration, but not necessary fully equal to the final
-       //   settings in ACTIVE BSS after negotiation/compromize with the BSS holder (either
-       //   AP or IBSS holder).
-       //   Once initialized, user configuration can only be changed via OID_xxx
-       UCHAR       BssType;              // BSS_INFRA or BSS_ADHOC
-       USHORT      AtimWin;          // used when starting a new IBSS
-
-       // GROUP 2 -
-       //   User configuration loaded from Registry, E2PROM or OID_xxx. These settings describe
-       //   the user intended configuration, and should be always applied to the final
-       //   settings in ACTIVE BSS without compromising with the BSS holder.
-       //   Once initialized, user configuration can only be changed via OID_xxx
-       UCHAR       RssiTrigger;
-       UCHAR       RssiTriggerMode;      // RSSI_TRIGGERED_UPON_BELOW_THRESHOLD or RSSI_TRIGGERED_UPON_EXCCEED_THRESHOLD
-       USHORT      DefaultListenCount;   // default listen count;
-       ULONG       WindowsPowerMode;           // Power mode for AC power
-       ULONG       WindowsBatteryPowerMode;    // Power mode for battery if exists
-       BOOLEAN     bWindowsACCAMEnable;        // Enable CAM power mode when AC on
-       BOOLEAN     bAutoReconnect;         // Set to TRUE when setting OID_802_11_SSID with no matching BSSID
-       ULONG       WindowsPowerProfile;    // Windows power profile, for NDIS5.1 PnP
-
-       // MIB:ieee802dot11.dot11smt(1).dot11StationConfigTable(1)
-       USHORT      Psm;                  // power management mode   (PWR_ACTIVE|PWR_SAVE)
-       USHORT      DisassocReason;
-       UCHAR       DisassocSta[MAC_ADDR_LEN];
-       USHORT      DeauthReason;
-       UCHAR       DeauthSta[MAC_ADDR_LEN];
-       USHORT      AuthFailReason;
-       UCHAR       AuthFailSta[MAC_ADDR_LEN];
-
-       NDIS_802_11_PRIVACY_FILTER          PrivacyFilter;  // PrivacyFilter enum for 802.1X
-       NDIS_802_11_AUTHENTICATION_MODE     AuthMode;       // This should match to whatever microsoft defined
-       NDIS_802_11_WEP_STATUS              WepStatus;
-       NDIS_802_11_WEP_STATUS                          OrigWepStatus;  // Original wep status set from OID
-
-       // Add to support different cipher suite for WPA2/WPA mode
-       NDIS_802_11_ENCRYPTION_STATUS           GroupCipher;            // Multicast cipher suite
-       NDIS_802_11_ENCRYPTION_STATUS           PairCipher;                     // Unicast cipher suite
-       BOOLEAN                                                         bMixCipher;                     // Indicate current Pair & Group use different cipher suites
-       USHORT                                                          RsnCapability;
-
-       NDIS_802_11_WEP_STATUS              GroupKeyWepStatus;
-
-       UCHAR           PMK[32];                // WPA PSK mode PMK
-       UCHAR       PTK[64];                // WPA PSK mode PTK
-       UCHAR           GTK[32];                                // GTK from authenticator
-       BSSID_INFO      SavedPMK[PMKID_NO];
-       UINT            SavedPMKNum;                    // Saved PMKID number
-
-       UCHAR           DefaultKeyId;
-
-
-       // WPA 802.1x port control, WPA_802_1X_PORT_SECURED, WPA_802_1X_PORT_NOT_SECURED
-       UCHAR       PortSecured;
-
-       // For WPA countermeasures
-       ULONG       LastMicErrorTime;   // record last MIC error time
-       ULONG       MicErrCnt;          // Should be 0, 1, 2, then reset to zero (after disassoiciation).
-       BOOLEAN     bBlockAssoc;        // Block associate attempt for 60 seconds after counter measure occurred.
-       // For WPA-PSK supplicant state
-       WPA_STATE   WpaState;           // Default is SS_NOTUSE and handled by microsoft 802.1x
-       UCHAR       ReplayCounter[8];
-       UCHAR       ANonce[32];         // ANonce for WPA-PSK from aurhenticator
-       UCHAR       SNonce[32];         // SNonce for WPA-PSK
-
-       UCHAR       LastSNR0;             // last received BEACON's SNR
-       UCHAR       LastSNR1;            // last received BEACON's SNR for 2nd  antenna
-       RSSI_SAMPLE RssiSample;
-       ULONG       NumOfAvgRssiSample;
-
-       ULONG       LastBeaconRxTime;     // OS's timestamp of the last BEACON RX time
-       ULONG       Last11bBeaconRxTime;  // OS's timestamp of the last 11B BEACON RX time
-       ULONG           Last11gBeaconRxTime;    // OS's timestamp of the last 11G BEACON RX time
-       ULONG           Last20NBeaconRxTime;    // OS's timestamp of the last 20MHz N BEACON RX time
-
-       ULONG       LastScanTime;       // Record last scan time for issue BSSID_SCAN_LIST
-       ULONG       ScanCnt;            // Scan counts since most recent SSID, BSSID, SCAN OID request
-       BOOLEAN     bSwRadio;           // Software controlled Radio On/Off, TRUE: On
-       BOOLEAN     bHwRadio;           // Hardware controlled Radio On/Off, TRUE: On
-       BOOLEAN     bRadio;             // Radio state, And of Sw & Hw radio state
-       BOOLEAN     bHardwareRadio;     // Hardware controlled Radio enabled
-       BOOLEAN     bShowHiddenSSID;    // Show all known SSID in SSID list get operation
-
-
-       // New for WPA, windows want us to to keep association information and
-       // Fixed IEs from last association response
-       NDIS_802_11_ASSOCIATION_INFORMATION     AssocInfo;
-       USHORT       ReqVarIELen;                // Length of next VIE include EID & Length
-       UCHAR       ReqVarIEs[MAX_VIE_LEN];             // The content saved here should be little-endian format.
-       USHORT       ResVarIELen;                // Length of next VIE include EID & Length
-       UCHAR       ResVarIEs[MAX_VIE_LEN];
-
-       UCHAR       RSNIE_Len;
-       UCHAR       RSN_IE[MAX_LEN_OF_RSNIE];   // The content saved here should be little-endian format.
-
-       // New variables used for CCX 1.0
-       BOOLEAN             bCkipOn;
-       BOOLEAN             bCkipCmicOn;
-       UCHAR               CkipFlag;
-       UCHAR               GIV[3];  //for CCX iv
-       UCHAR               RxSEQ[4];
-       UCHAR               TxSEQ[4];
-       UCHAR               CKIPMIC[4];
-       UCHAR               LeapAuthMode;
-       LEAP_AUTH_INFO      LeapAuthInfo;
-       UCHAR               HashPwd[16];
-       UCHAR               NetworkChallenge[8];
-       UCHAR               NetworkChallengeResponse[24];
-       UCHAR               PeerChallenge[8];
-
-       UCHAR               PeerChallengeResponse[24];
-       UCHAR               SessionKey[16]; //Network session keys (NSK)
-       RALINK_TIMER_STRUCT LeapAuthTimer;
-       ROGUEAP_TABLE       RogueApTab;   //Cisco CCX1 Rogue AP Detection
-
-       // New control flags for CCX
-       CCX_CONTROL         CCXControl;                 // Master administration state
-       BOOLEAN             CCXEnable;                  // Actual CCX state
-       UCHAR               CCXScanChannel;             // Selected channel for CCX beacon request
-       USHORT              CCXScanTime;                // Time out to wait for beacon and probe response
-       UCHAR               CCXReqType;                 // Current processing CCX request type
-       BSS_TABLE           CCXBssTab;                  // BSS Table
-       UCHAR               FrameReportBuf[2048];       // Buffer for creating frame report
-       USHORT              FrameReportLen;             // Current Frame report length
-       ULONG               CLBusyBytes;                // Save the total bytes received durning channel load scan time
-       USHORT              RPIDensity[8];              // Array for RPI density collection
-       // Start address of each BSS table within FrameReportBuf
-       // It's important to update the RxPower of the corresponding Bss
-       USHORT              BssReportOffset[MAX_LEN_OF_BSS_TABLE];
-       USHORT              BeaconToken;                // Token for beacon report
-       ULONG               LastBssIndex;               // Most current reported Bss index
-       RM_REQUEST_ACTION   MeasurementRequest[16];     // Saved measurement request
-       UCHAR               RMReqCnt;                   // Number of measurement request saved.
-       UCHAR               CurrentRMReqIdx;            // Number of measurement request saved.
-       BOOLEAN             ParallelReq;                // Parallel measurement, only one request performed,
-                                                                                                       // It must be the same channel with maximum duration
-       USHORT              ParallelDuration;           // Maximum duration for parallel measurement
-       UCHAR               ParallelChannel;            // Only one channel with parallel measurement
-       USHORT              IAPPToken;                  // IAPP dialog token
-       UCHAR               CCXQosECWMin;               // Cisco QOS ECWMin for AC 0
-       UCHAR               CCXQosECWMax;               // Cisco QOS ECWMax for AC 0
-       // Hack for channel load and noise histogram parameters
-       UCHAR               NHFactor;                   // Parameter for Noise histogram
-       UCHAR               CLFactor;                   // Parameter for channel load
-
-       UCHAR               KRK[16];        //Key Refresh Key.
-       UCHAR               BTK[32];        //Base Transient Key
-       BOOLEAN             CCKMLinkUpFlag;
-       ULONG               CCKMRN;    //(Re)Association request number.
-       LARGE_INTEGER       CCKMBeaconAtJoinTimeStamp;  //TSF timer for Re-assocaite to the new AP
-       UCHAR               AironetCellPowerLimit;      //in dBm
-       UCHAR               AironetIPAddress[4];        //eg. 192.168.1.1
-       BOOLEAN             CCXAdjacentAPReportFlag;    //flag for determining report Assoc Lost time
-       CHAR                CCXAdjacentAPSsid[MAX_LEN_OF_SSID]; //Adjacent AP's SSID report
-       UCHAR               CCXAdjacentAPSsidLen;               // the actual ssid length in used
-       UCHAR               CCXAdjacentAPBssid[MAC_ADDR_LEN];         //Adjacent AP's BSSID report
-       USHORT              CCXAdjacentAPChannel;
-       ULONG               CCXAdjacentAPLinkDownTime;  //for Spec S32.
-
-       RALINK_TIMER_STRUCT     StaQuickResponeForRateUpTimer;
-       BOOLEAN                         StaQuickResponeForRateUpTimerRunning;
-
-       UCHAR                   DtimCount;      // 0.. DtimPeriod-1
-       UCHAR                   DtimPeriod;     // default = 3
-
-       ////////////////////////////////////////////////////////////////////////////////////////
-       // This is only for WHQL test.
-       BOOLEAN                         WhqlTest;
-       ////////////////////////////////////////////////////////////////////////////////////////
-
-    RALINK_TIMER_STRUCT WpaDisassocAndBlockAssocTimer;
-    // Fast Roaming
-       BOOLEAN                 bFastRoaming;       // 0:disable fast roaming, 1:enable fast roaming
-       CHAR                    dBmToRoam;          // the condition to roam when receiving Rssi less than this value. It's negative value.
-
-    BOOLEAN             IEEE8021X;
-    BOOLEAN             IEEE8021x_required_keys;
-    CIPHER_KEY         DesireSharedKey[4];     // Record user desired WEP keys
-    UCHAR               DesireSharedKeyId;
-
-    // 0: driver ignores wpa_supplicant
-    // 1: wpa_supplicant initiates scanning and AP selection
-    // 2: driver takes care of scanning, AP selection, and IEEE 802.11 association parameters
-    UCHAR               WpaSupplicantUP;
-       UCHAR                           WpaSupplicantScanCount;
-
-    CHAR                dev_name[16];
-    USHORT              OriDevType;
-
-    BOOLEAN             bTGnWifiTest;
-       BOOLEAN                     bScanReqIsFromWebUI;
-
-       HTTRANSMIT_SETTING                              HTPhyMode, MaxHTPhyMode, MinHTPhyMode;// For transmit phy setting in TXWI.
-       DESIRED_TRANSMIT_SETTING        DesiredTransmitSetting;
-       RT_HT_PHY_INFO                                  DesiredHtPhyInfo;
-       BOOLEAN                                                 bAutoTxRateSwitch;
-} STA_ADMIN_CONFIG, *PSTA_ADMIN_CONFIG;
-
-// This data structure keep the current active BSS/IBSS's configuration that this STA
-// had agreed upon joining the network. Which means these parameters are usually decided
-// by the BSS/IBSS creator instead of user configuration. Data in this data structurre
-// is valid only when either ADHOC_ON(pAd) or INFRA_ON(pAd) is TRUE.
-// Normally, after SCAN or failed roaming attempts, we need to recover back to
-// the current active settings.
-typedef struct _STA_ACTIVE_CONFIG {
-       USHORT      Aid;
-       USHORT      AtimWin;                // in kusec; IBSS parameter set element
-       USHORT      CapabilityInfo;
-       USHORT      CfpMaxDuration;
-       USHORT      CfpPeriod;
-
-       // Copy supported rate from desired AP's beacon. We are trying to match
-       // AP's supported and extended rate settings.
-       UCHAR       SupRate[MAX_LEN_OF_SUPPORTED_RATES];
-       UCHAR       ExtRate[MAX_LEN_OF_SUPPORTED_RATES];
-       UCHAR       SupRateLen;
-       UCHAR       ExtRateLen;
-       // Copy supported ht from desired AP's beacon. We are trying to match
-       RT_HT_PHY_INFO          SupportedPhyInfo;
-       RT_HT_CAPABILITY        SupportedHtPhy;
-} STA_ACTIVE_CONFIG, *PSTA_ACTIVE_CONFIG;
-
-#ifdef RT2870
-typedef struct   RT_ADD_PAIRWISE_KEY_ENTRY {
-        NDIS_802_11_MAC_ADDRESS         MacAddr;
-        USHORT                          MacTabMatchWCID;        // ASIC
-        CIPHER_KEY      CipherKey;
-} RT_ADD_PAIRWISE_KEY_ENTRY,*PRT_ADD_PAIRWISE_KEY_ENTRY;
-#endif // RT2870 //
-
-// ----------- start of AP --------------------------
-// AUTH-RSP State Machine Aux data structure
-typedef struct _AP_MLME_AUX {
-       UCHAR               Addr[MAC_ADDR_LEN];
-       USHORT              Alg;
-       CHAR                Challenge[CIPHER_TEXT_LEN];
-} AP_MLME_AUX, *PAP_MLME_AUX;
-
-// structure to define WPA Group Key Rekey Interval
-typedef struct PACKED _RT_802_11_WPA_REKEY {
-       ULONG ReKeyMethod;          // mechanism for rekeying: 0:disable, 1: time-based, 2: packet-based
-       ULONG ReKeyInterval;        // time-based: seconds, packet-based: kilo-packets
-} RT_WPA_REKEY,*PRT_WPA_REKEY, RT_802_11_WPA_REKEY, *PRT_802_11_WPA_REKEY;
-
-typedef struct _MAC_TABLE_ENTRY {
-       //Choose 1 from ValidAsWDS and ValidAsCLI  to validize.
-       BOOLEAN         ValidAsCLI;             // Sta mode, set this TRUE after Linkup,too.
-       BOOLEAN         ValidAsWDS;     // This is WDS Entry. only for AP mode.
-       BOOLEAN         ValidAsApCli;   //This is a AP-Client entry, only for AP mode which enable AP-Client functions.
-       BOOLEAN         ValidAsMesh;
-       BOOLEAN         ValidAsDls;     // This is DLS Entry. only for STA mode.
-       BOOLEAN         isCached;
-       BOOLEAN         bIAmBadAtheros;
-
-       UCHAR           EnqueueEapolStartTimerRunning;  // Enqueue EAPoL-Start for triggering EAP SM
-       //jan for wpa
-       // record which entry revoke MIC Failure , if it leaves the BSS itself, AP won't update aMICFailTime MIB
-       UCHAR           CMTimerRunning;
-       UCHAR           apidx;                  // MBSS number
-       UCHAR           RSNIE_Len;
-       UCHAR           RSN_IE[MAX_LEN_OF_RSNIE];
-       UCHAR           ANonce[LEN_KEY_DESC_NONCE];
-       UCHAR           R_Counter[LEN_KEY_DESC_REPLAY];
-       UCHAR           PTK[64];
-       UCHAR           ReTryCounter;
-       RALINK_TIMER_STRUCT                 RetryTimer;
-       RALINK_TIMER_STRUCT                                     EnqueueStartForPSKTimer;        // A timer which enqueue EAPoL-Start for triggering PSK SM
-       NDIS_802_11_AUTHENTICATION_MODE     AuthMode;   // This should match to whatever microsoft defined
-       NDIS_802_11_WEP_STATUS              WepStatus;
-       AP_WPA_STATE    WpaState;
-       GTK_STATE       GTKState;
-       USHORT          PortSecured;
-       NDIS_802_11_PRIVACY_FILTER  PrivacyFilter;      // PrivacyFilter enum for 802.1X
-       CIPHER_KEY      PairwiseKey;
-       PVOID           pAd;
-    INT                                PMKID_CacheIdx;
-    UCHAR                      PMKID[LEN_PMKID];
-
-
-       UCHAR           Addr[MAC_ADDR_LEN];
-       UCHAR           PsMode;
-       SST             Sst;
-       AUTH_STATE      AuthState; // for SHARED KEY authentication state machine used only
-       BOOLEAN                 IsReassocSta;   // Indicate whether this is a reassociation procedure
-       USHORT          Aid;
-       USHORT          CapabilityInfo;
-       UCHAR           LastRssi;
-       ULONG           NoDataIdleCount;
-       UINT16                  StationKeepAliveCount; // unit: second
-       ULONG           PsQIdleCount;
-       QUEUE_HEADER    PsQueue;
-
-       UINT32                  StaConnectTime;         // the live time of this station since associated with AP
-
-       BOOLEAN                 bSendBAR;
-       USHORT                  NoBADataCountDown;
-
-       UINT32                  CachedBuf[16];          // UINT (4 bytes) for alignment
-       UINT                    TxBFCount; // 3*3
-       UINT                    FIFOCount;
-       UINT                    DebugFIFOCount;
-       UINT                    DebugTxCount;
-    BOOLEAN                    bDlsInit;
-
-
-//====================================================
-//WDS entry needs these
-// rt2860 add this. if ValidAsWDS==TRUE, MatchWDSTabIdx is the index in WdsTab.MacTab
-       UINT                    MatchWDSTabIdx;
-       UCHAR           MaxSupportedRate;
-       UCHAR           CurrTxRate;
-       UCHAR           CurrTxRateIndex;
-       // to record the each TX rate's quality. 0 is best, the bigger the worse.
-       USHORT          TxQuality[MAX_STEP_OF_TX_RATE_SWITCH];
-       UINT32                  OneSecTxNoRetryOkCount;
-       UINT32          OneSecTxRetryOkCount;
-       UINT32          OneSecTxFailCount;
-       UINT32                  ContinueTxFailCnt;
-       UINT32          CurrTxRateStableTime; // # of second in current TX rate
-       UCHAR           TxRateUpPenalty;      // extra # of second penalty due to last unstable condition
-//====================================================
-
-       BOOLEAN         fNoisyEnvironment;
-       BOOLEAN                 fLastSecAccordingRSSI;
-       UCHAR           LastSecTxRateChangeAction; // 0: no change, 1:rate UP, 2:rate down
-       CHAR                    LastTimeTxRateChangeAction; //Keep last time value of LastSecTxRateChangeAction
-       ULONG                   LastTxOkCount;
-       UCHAR           PER[MAX_STEP_OF_TX_RATE_SWITCH];
-
-       // a bitmap of BOOLEAN flags. each bit represent an operation status of a particular
-       // BOOLEAN control, either ON or OFF. These flags should always be accessed via
-       // CLIENT_STATUS_TEST_FLAG(), CLIENT_STATUS_SET_FLAG(), CLIENT_STATUS_CLEAR_FLAG() macros.
-       // see fOP_STATUS_xxx in RTMP_DEF.C for detail bit definition. fCLIENT_STATUS_AMSDU_INUSED
-       ULONG           ClientStatusFlags;
-
-       HTTRANSMIT_SETTING      HTPhyMode, MaxHTPhyMode, MinHTPhyMode;// For transmit phy setting in TXWI.
-
-       // HT EWC MIMO-N used parameters
-       USHORT          RXBAbitmap;     // fill to on-chip  RXWI_BA_BITMASK in 8.1.3RX attribute entry format
-       USHORT          TXBAbitmap;     // This bitmap as originator, only keep in software used to mark AMPDU bit in TXWI
-       USHORT          TXAutoBAbitmap;
-       USHORT          BADeclineBitmap;
-       USHORT          BARecWcidArray[NUM_OF_TID];     // The mapping wcid of recipient session. if RXBAbitmap bit is masked
-       USHORT          BAOriWcidArray[NUM_OF_TID]; // The mapping wcid of originator session. if TXBAbitmap bit is masked
-       USHORT          BAOriSequence[NUM_OF_TID]; // The mapping wcid of originator session. if TXBAbitmap bit is masked
-
-       // 802.11n features.
-       UCHAR           MpduDensity;
-       UCHAR           MaxRAmpduFactor;
-       UCHAR           AMsduSize;
-       UCHAR           MmpsMode;       // MIMO power save more.
-
-       HT_CAPABILITY_IE                HTCapability;
-
-       BOOLEAN         bAutoTxRateSwitch;
-
-       UCHAR       RateLen;
-       struct _MAC_TABLE_ENTRY *pNext;
-    USHORT      TxSeq[NUM_OF_TID];
-       USHORT          NonQosDataSeq;
-
-       RSSI_SAMPLE     RssiSample;
-
-       UINT32                  TXMCSExpected[16];
-       UINT32                  TXMCSSuccessful[16];
-       UINT32                  TXMCSFailed[16];
-       UINT32                  TXMCSAutoFallBack[16][16];
-
-        ULONG                   LastBeaconRxTime;
-} MAC_TABLE_ENTRY, *PMAC_TABLE_ENTRY;
-
-typedef struct _MAC_TABLE {
-       USHORT                  Size;
-       MAC_TABLE_ENTRY *Hash[HASH_TABLE_SIZE];
-       MAC_TABLE_ENTRY Content[MAX_LEN_OF_MAC_TABLE];
-       QUEUE_HEADER    McastPsQueue;
-       ULONG           PsQIdleCount;
-       BOOLEAN         fAnyStationInPsm;
-       BOOLEAN         fAnyStationBadAtheros;  // Check if any Station is atheros 802.11n Chip.  We need to use RTS/CTS with Atheros 802,.11n chip.
-       BOOLEAN                 fAnyTxOPForceDisable;   // Check if it is necessary to disable BE TxOP
-       BOOLEAN                 fAllStationAsRalink;    // Check if all stations are ralink-chipset
-       BOOLEAN         fAnyStationIsLegacy;    // Check if I use legacy rate to transmit to my BSS Station/
-       BOOLEAN         fAnyStationNonGF;               // Check if any Station can't support GF.
-       BOOLEAN         fAnyStation20Only;              // Check if any Station can't support GF.
-       BOOLEAN                 fAnyStationMIMOPSDynamic; // Check if any Station is MIMO Dynamic
-       BOOLEAN         fAnyBASession;   // Check if there is BA session.  Force turn on RTS/CTS
-} MAC_TABLE, *PMAC_TABLE;
-
-#define IS_HT_STA(_pMacEntry)  \
-       (_pMacEntry->MaxHTPhyMode.field.MODE >= MODE_HTMIX)
-
-#define IS_HT_RATE(_pMacEntry) \
-       (_pMacEntry->HTPhyMode.field.MODE >= MODE_HTMIX)
-
-#define PEER_IS_HT_RATE(_pMacEntry)    \
-       (_pMacEntry->HTPhyMode.field.MODE >= MODE_HTMIX)
-
-typedef struct _WDS_ENTRY {
-       BOOLEAN         Valid;
-       UCHAR           Addr[MAC_ADDR_LEN];
-       ULONG           NoDataIdleCount;
-       struct _WDS_ENTRY *pNext;
-} WDS_ENTRY, *PWDS_ENTRY;
-
-typedef struct  _WDS_TABLE_ENTRY {
-       USHORT                  Size;
-       UCHAR           WdsAddr[MAC_ADDR_LEN];
-       WDS_ENTRY       *Hash[HASH_TABLE_SIZE];
-       WDS_ENTRY       Content[MAX_LEN_OF_MAC_TABLE];
-       UCHAR           MaxSupportedRate;
-       UCHAR           CurrTxRate;
-       USHORT          TxQuality[MAX_LEN_OF_SUPPORTED_RATES];
-       USHORT          OneSecTxOkCount;
-       USHORT          OneSecTxRetryOkCount;
-       USHORT          OneSecTxFailCount;
-       ULONG           CurrTxRateStableTime; // # of second in current TX rate
-       UCHAR           TxRateUpPenalty;      // extra # of second penalty due to last unstable condition
-} WDS_TABLE_ENTRY, *PWDS_TABLE_ENTRY;
-
-typedef struct _RT_802_11_WDS_ENTRY {
-       PNET_DEV                        dev;
-       UCHAR                           Valid;
-       UCHAR                           PhyMode;
-       UCHAR                           PeerWdsAddr[MAC_ADDR_LEN];
-       UCHAR                           MacTabMatchWCID;        // ASIC
-       NDIS_802_11_WEP_STATUS  WepStatus;
-       UCHAR                                   KeyIdx;
-       CIPHER_KEY              WdsKey;
-       HTTRANSMIT_SETTING                              HTPhyMode, MaxHTPhyMode, MinHTPhyMode;
-       RT_HT_PHY_INFO                                  DesiredHtPhyInfo;
-       BOOLEAN                                                 bAutoTxRateSwitch;
-       DESIRED_TRANSMIT_SETTING        DesiredTransmitSetting; // Desired transmit setting.
-} RT_802_11_WDS_ENTRY, *PRT_802_11_WDS_ENTRY;
-
-typedef struct _WDS_TABLE {
-       UCHAR               Mode;
-       ULONG               Size;
-       RT_802_11_WDS_ENTRY     WdsEntry[MAX_WDS_ENTRY];
-} WDS_TABLE, *PWDS_TABLE;
-
-typedef struct _APCLI_STRUCT {
-       PNET_DEV                                dev;
-#ifdef RTL865X_SOC
-       unsigned int            mylinkid;
-#endif
-       BOOLEAN                 Enable; // Set it as 1 if the apcli interface was configured to "1"  or by iwpriv cmd "ApCliEnable"
-       BOOLEAN                 Valid;  // Set it as 1 if the apcli interface associated success to remote AP.
-       UCHAR                                   MacTabWCID;     //WCID value, which point to the entry of ASIC Mac table.
-       UCHAR                   SsidLen;
-       CHAR                    Ssid[MAX_LEN_OF_SSID];
-
-       UCHAR                   CfgSsidLen;
-       CHAR                    CfgSsid[MAX_LEN_OF_SSID];
-       UCHAR                   CfgApCliBssid[ETH_LENGTH_OF_ADDRESS];
-       UCHAR                   CurrentAddress[ETH_LENGTH_OF_ADDRESS];
-
-       ULONG                   ApCliRcvBeaconTime;
-
-       ULONG                   CtrlCurrState;
-       ULONG                   SyncCurrState;
-       ULONG                   AuthCurrState;
-       ULONG                   AssocCurrState;
-       ULONG                                   WpaPskCurrState;
-
-       USHORT                  AuthReqCnt;
-       USHORT                  AssocReqCnt;
-
-       ULONG                   ClientStatusFlags;
-       UCHAR                   MpduDensity;
-
-       NDIS_802_11_AUTHENTICATION_MODE     AuthMode;   // This should match to whatever microsoft defined
-       NDIS_802_11_WEP_STATUS              WepStatus;
-
-       // Add to support different cipher suite for WPA2/WPA mode
-       NDIS_802_11_ENCRYPTION_STATUS           GroupCipher;            // Multicast cipher suite
-       NDIS_802_11_ENCRYPTION_STATUS           PairCipher;                     // Unicast cipher suite
-       BOOLEAN                                                         bMixCipher;                     // Indicate current Pair & Group use different cipher suites
-       USHORT                                                          RsnCapability;
-
-       UCHAR           PSK[100];                               // reserve PSK key material
-       UCHAR       PSKLen;
-       UCHAR       PMK[32];                // WPA PSK mode PMK
-       UCHAR           GTK[32];                                // GTK from authenticator
-
-       CIPHER_KEY      SharedKey[SHARE_KEY_NUM];
-       UCHAR           DefaultKeyId;
-
-       // store RSN_IE built by driver
-       UCHAR           RSN_IE[MAX_LEN_OF_RSNIE];  // The content saved here should be convert to little-endian format.
-       UCHAR           RSNIE_Len;
-
-       // For WPA countermeasures
-       ULONG       LastMicErrorTime;   // record last MIC error time
-       BOOLEAN                 bBlockAssoc; // Block associate attempt for 60 seconds after counter measure occurred.
-
-       // For WPA-PSK supplicant state
-       UCHAR           SNonce[32];         // SNonce for WPA-PSK
-       UCHAR                   GNonce[32];                     // GNonce for WPA-PSK from authenticator
-
-       HTTRANSMIT_SETTING                              HTPhyMode, MaxHTPhyMode, MinHTPhyMode;
-       RT_HT_PHY_INFO                                  DesiredHtPhyInfo;
-       BOOLEAN                                                 bAutoTxRateSwitch;
-       DESIRED_TRANSMIT_SETTING        DesiredTransmitSetting; // Desired transmit setting.
-} APCLI_STRUCT, *PAPCLI_STRUCT;
-
-// ----------- end of AP ----------------------------
-
-struct wificonf
-{
-       BOOLEAN bShortGI;
-       BOOLEAN bGreenField;
-};
-
-
-
-
-typedef struct _INF_PCI_CONFIG
-{
-       PUCHAR                  CSRBaseAddress;     // PCI MMIO Base Address, all access will use
-}INF_PCI_CONFIG;
-
-typedef struct _INF_USB_CONFIG
-{
-       UINT                BulkInEpAddr;               // bulk-in endpoint address
-       UINT                BulkOutEpAddr[6];   // bulk-out endpoint address
-
-}INF_USB_CONFIG;
-
-#ifdef IKANOS_VX_1X0
-       typedef void (*IkanosWlanTxCbFuncP)(void *, void *);
-
-       struct IKANOS_TX_INFO
-       {
-               struct net_device *netdev;
-               IkanosWlanTxCbFuncP *fp;
-       };
-#endif // IKANOS_VX_1X0 //
-
-#ifdef DBG_DIAGNOSE
-#define DIAGNOSE_TIME  10   // 10 sec
-typedef struct _RtmpDiagStrcut_
-{      // Diagnosis Related element
-       unsigned char           inited;
-       unsigned char   qIdx;
-       unsigned char   ArrayStartIdx;
-       unsigned char           ArrayCurIdx;
-       // Tx Related Count
-       USHORT                  TxDataCnt[DIAGNOSE_TIME];
-       USHORT                  TxFailCnt[DIAGNOSE_TIME];
-       USHORT                  TxDescCnt[DIAGNOSE_TIME][24]; // 3*3    // TxDesc queue length in scale of 0~14, >=15
-       USHORT                  TxMcsCnt[DIAGNOSE_TIME][24]; // 3*3
-       USHORT                  TxSWQueCnt[DIAGNOSE_TIME][9];           // TxSwQueue length in scale of 0, 1, 2, 3, 4, 5, 6, 7, >=8
-
-       USHORT                  TxAggCnt[DIAGNOSE_TIME];
-       USHORT                  TxNonAggCnt[DIAGNOSE_TIME];
-       USHORT                  TxAMPDUCnt[DIAGNOSE_TIME][24]; // 3*3 // 10 sec, TxDMA APMDU Aggregation count in range from 0 to 15, in setp of 1.
-       USHORT                  TxRalinkCnt[DIAGNOSE_TIME];                     // TxRalink Aggregation Count in 1 sec scale.
-       USHORT                  TxAMSDUCnt[DIAGNOSE_TIME];                      // TxAMSUD Aggregation Count in 1 sec scale.
-
-       // Rx Related Count
-       USHORT                  RxDataCnt[DIAGNOSE_TIME];                       // Rx Total Data count.
-       USHORT                  RxCrcErrCnt[DIAGNOSE_TIME];
-       USHORT                  RxMcsCnt[DIAGNOSE_TIME][24]; // 3*3
-}RtmpDiagStruct;
-#endif // DBG_DIAGNOSE //
-
-
-//
-//  The miniport adapter structure
-//
-typedef struct _RTMP_ADAPTER
-{
-       PVOID                                   OS_Cookie;      // save specific structure relative to OS
-       PNET_DEV                                net_dev;
-       ULONG                                   VirtualIfCnt;
-
-
-
-       NDIS_SPIN_LOCK          irq_lock;
-       UCHAR                   irq_disabled;
-
-#ifdef RT2870
-/*****************************************************************************************/
-/*      USB related parameters                                                           */
-/*****************************************************************************************/
-       struct usb_config_descriptor            *config;
-       UINT                                                            BulkInEpAddr;           // bulk-in endpoint address
-       UINT                                                            BulkOutEpAddr[6];       // bulk-out endpoint address
-
-       UINT                                                            NumberOfPipes;
-       USHORT                                                          BulkOutMaxPacketSize;
-       USHORT                                                          BulkInMaxPacketSize;
-
-       //======Control Flags
-       LONG                            PendingIoCount;
-       ULONG                                           BulkFlags;
-       BOOLEAN                     bUsbTxBulkAggre;    // Flags for bulk out data priority
-
-
-       //======Timer Thread
-       RT2870_TIMER_QUEUE              TimerQ;
-       NDIS_SPIN_LOCK                  TimerQLock;
-
-
-       //======Cmd Thread
-       CmdQ                                    CmdQ;
-       NDIS_SPIN_LOCK                  CmdQLock;                               // CmdQLock spinlock
-
-       BOOLEAN                                 TimerFunc_kill;
-       BOOLEAN                                 mlme_kill;
-
-
-       //======Semaphores (event)
-       struct semaphore                        mlme_semaphore;                 /* to sleep thread on   */
-       struct semaphore                        RTUSBCmd_semaphore;             /* to sleep thread on   */
-       struct semaphore                        RTUSBTimer_semaphore;
-
-       struct completion                       TimerQComplete;
-       struct completion                       mlmeComplete;
-       struct completion                       CmdQComplete;
-       wait_queue_head_t                       *wait;
-#endif // RT2870 //
-
-
-/*****************************************************************************************/
-       /*      Both PCI/USB related parameters                                                  */
-/*****************************************************************************************/
-
-
-/*****************************************************************************************/
-/*      Tx related parameters                                                           */
-/*****************************************************************************************/
-       BOOLEAN                 DeQueueRunning[NUM_OF_TX_RING];  // for ensuring RTUSBDeQueuePacket get call once
-       NDIS_SPIN_LOCK          DeQueueLock[NUM_OF_TX_RING];
-
-#ifdef RT2870
-       // Data related context and AC specified, 4 AC supported
-       NDIS_SPIN_LOCK                  BulkOutLock[6];                 // BulkOut spinlock for 4 ACs
-       NDIS_SPIN_LOCK                  MLMEBulkOutLock;        // MLME BulkOut lock
-
-       HT_TX_CONTEXT                   TxContext[NUM_OF_TX_RING];
-       NDIS_SPIN_LOCK                  TxContextQueueLock[NUM_OF_TX_RING];             // TxContextQueue spinlock
-
-       // 4 sets of Bulk Out index and pending flag
-       UCHAR                                   NextBulkOutIndex[4];    // only used for 4 EDCA bulkout pipe
-
-       BOOLEAN                                 BulkOutPending[6];      // used for total 6 bulkout pipe
-       UCHAR                                   bulkResetPipeid;
-       BOOLEAN                                 MgmtBulkPending;
-       ULONG                                   bulkResetReq[6];
-#endif // RT2870 //
-
-       // resource for software backlog queues
-       QUEUE_HEADER            TxSwQueue[NUM_OF_TX_RING];  // 4 AC + 1 HCCA
-       NDIS_SPIN_LOCK          TxSwQueueLock[NUM_OF_TX_RING];  // TxSwQueue spinlock
-
-       RTMP_DMABUF             MgmtDescRing;                   // Shared memory for MGMT descriptors
-       RTMP_MGMT_RING          MgmtRing;
-       NDIS_SPIN_LOCK          MgmtRingLock;                   // Prio Ring spinlock
-
-
-/*****************************************************************************************/
-/*      Rx related parameters                                                           */
-/*****************************************************************************************/
-
-
-#ifdef RT2870
-       RX_CONTEXT                              RxContext[RX_RING_SIZE];  // 1 for redundant multiple IRP bulk in.
-       NDIS_SPIN_LOCK                  BulkInLock;                             // BulkIn spinlock for 4 ACs
-       UCHAR                                   PendingRx;                              // The Maxima pending Rx value should be        RX_RING_SIZE.
-       UCHAR                                   NextRxBulkInIndex;              // Indicate the current RxContext Index which hold by Host controller.
-       UCHAR                                   NextRxBulkInReadIndex;  // Indicate the current RxContext Index which driver can read & process it.
-       ULONG                                   NextRxBulkInPosition;   // Want to contatenate 2 URB buffer while 1st is bulkin failed URB. This Position is 1st URB TransferLength.
-       ULONG                                   TransferBufferLength;   // current length of the packet buffer
-       ULONG                                   ReadPosition;                   // current read position in a packet buffer
-#endif // RT2870 //
-
-
-/*****************************************************************************************/
-/*      ASIC related parameters                                                          */
-/*****************************************************************************************/
-       UINT32                  MACVersion;             // MAC version. Record rt2860C(0x28600100) or rt2860D (0x28600101)..
-
-       // ---------------------------
-       // E2PROM
-       // ---------------------------
-       ULONG                   EepromVersion;          // byte 0: version, byte 1: revision, byte 2~3: unused
-       UCHAR                   EEPROMAddressNum;       // 93c46=6  93c66=8
-       USHORT                  EEPROMDefaultValue[NUM_EEPROM_BBP_PARMS];
-       BOOLEAN                 EepromAccess;
-       UCHAR                   EFuseTag;
-       ULONG                   FirmwareVersion;        // byte 0: Minor version, byte 1: Major version, otherwise unused.
-
-       // ---------------------------
-       // BBP Control
-       // ---------------------------
-       UCHAR                   BbpWriteLatch[140];     // record last BBP register value written via BBP_IO_WRITE/BBP_IO_WRITE_VY_REG_ID
-       UCHAR                   BbpRssiToDbmDelta;
-       BBP_R66_TUNING          BbpTuning;
-
-       // ----------------------------
-       // RFIC control
-       // ----------------------------
-       UCHAR                   RfIcType;       // RFIC_xxx
-       ULONG                   RfFreqOffset;   // Frequency offset for channel switching
-       RTMP_RF_REGS            LatchRfRegs;    // latch th latest RF programming value since RF IC doesn't support READ
-
-       EEPROM_ANTENNA_STRUC    Antenna;                            // Since ANtenna definition is different for a & g. We need to save it for future reference.
-       EEPROM_NIC_CONFIG2_STRUC    NicConfig2;
-
-       // This soft Rx Antenna Diversity mechanism is used only when user set
-       // RX Antenna = DIVERSITY ON
-       SOFT_RX_ANT_DIVERSITY   RxAnt;
-
-       UCHAR                   RFProgSeq;
-       CHANNEL_TX_POWER        TxPower[MAX_NUM_OF_CHANNELS];       // Store Tx power value for all channels.
-       CHANNEL_TX_POWER        ChannelList[MAX_NUM_OF_CHANNELS];   // list all supported channels for site survey
-       CHANNEL_11J_TX_POWER    TxPower11J[MAX_NUM_OF_11JCHANNELS];       // 802.11j channel and bw
-       CHANNEL_11J_TX_POWER    ChannelList11J[MAX_NUM_OF_11JCHANNELS];   // list all supported channels for site survey
-
-       UCHAR                   ChannelListNum;                     // number of channel in ChannelList[]
-       UCHAR                                   Bbp94;
-       BOOLEAN                                 BbpForCCK;
-       ULONG           Tx20MPwrCfgABand[5];
-       ULONG           Tx20MPwrCfgGBand[5];
-       ULONG           Tx40MPwrCfgABand[5];
-       ULONG           Tx40MPwrCfgGBand[5];
-
-       BOOLEAN     bAutoTxAgcA;                // Enable driver auto Tx Agc control
-       UCHAR       TssiRefA;                                   // Store Tssi reference value as 25 temperature.
-       UCHAR       TssiPlusBoundaryA[5];               // Tssi boundary for increase Tx power to compensate.
-       UCHAR       TssiMinusBoundaryA[5];              // Tssi boundary for decrease Tx power to compensate.
-       UCHAR       TxAgcStepA;                                 // Store Tx TSSI delta increment / decrement value
-       CHAR            TxAgcCompensateA;                       // Store the compensation (TxAgcStep * (idx-1))
-
-       BOOLEAN     bAutoTxAgcG;                // Enable driver auto Tx Agc control
-       UCHAR       TssiRefG;                                   // Store Tssi reference value as 25 temperature.
-       UCHAR       TssiPlusBoundaryG[5];               // Tssi boundary for increase Tx power to compensate.
-       UCHAR       TssiMinusBoundaryG[5];              // Tssi boundary for decrease Tx power to compensate.
-       UCHAR       TxAgcStepG;                                 // Store Tx TSSI delta increment / decrement value
-       CHAR            TxAgcCompensateG;                       // Store the compensation (TxAgcStep * (idx-1))
-
-       //+++For RT2870, the parameteres is start from BGRssiOffset1 ~ BGRssiOffset3
-       CHAR            BGRssiOffset0;                          // Store B/G RSSI#0 Offset value on EEPROM 0x46h
-       CHAR            BGRssiOffset1;                          // Store B/G RSSI#1 Offset value
-       CHAR            BGRssiOffset2;                          // Store B/G RSSI#2 Offset value
-       //---
-
-       //+++For RT2870, the parameteres is start from ARssiOffset1 ~ ARssiOffset3
-       CHAR            ARssiOffset0;                           // Store A RSSI#0 Offset value on EEPROM 0x4Ah
-       CHAR            ARssiOffset1;                           // Store A RSSI#1 Offset value
-       CHAR            ARssiOffset2;                           // Store A RSSI#2 Offset value
-       //---
-
-       CHAR            BLNAGain;                                       // Store B/G external LNA#0 value on EEPROM 0x44h
-       CHAR            ALNAGain0;                                      // Store A external LNA#0 value for ch36~64
-       CHAR            ALNAGain1;                                      // Store A external LNA#1 value for ch100~128
-       CHAR            ALNAGain2;                                      // Store A external LNA#2 value for ch132~165
-
-       // ----------------------------
-       // LED control
-       // ----------------------------
-       MCU_LEDCS_STRUC         LedCntl;
-       USHORT                          Led1;   // read from EEPROM 0x3c
-       USHORT                          Led2;   // EEPROM 0x3e
-       USHORT                          Led3;   // EEPROM 0x40
-       UCHAR                           LedIndicatorStregth;
-       UCHAR                           RssiSingalstrengthOffet;
-    BOOLEAN                            bLedOnScanning;
-       UCHAR                           LedStatus;
-
-/*****************************************************************************************/
-/*      802.11 related parameters                                                        */
-/*****************************************************************************************/
-       // outgoing BEACON frame buffer and corresponding TXD
-       TXWI_STRUC                      BeaconTxWI;
-       PUCHAR                                          BeaconBuf;
-       USHORT                                          BeaconOffset[HW_BEACON_MAX_COUNT];
-
-       // pre-build PS-POLL and NULL frame upon link up. for efficiency purpose.
-       PSPOLL_FRAME                    PsPollFrame;
-       HEADER_802_11                   NullFrame;
-
-#ifdef RT2870
-       TX_CONTEXT                              BeaconContext[BEACON_RING_SIZE];
-       TX_CONTEXT                              NullContext;
-       TX_CONTEXT                              PsPollContext;
-       TX_CONTEXT                              RTSContext;
-#endif // RT2870 //
-
-
-
-//=========AP===========
-
-
-//=======STA===========
-/* Modified by Wu Xi-Kun 4/21/2006 */
-       // -----------------------------------------------
-       // STA specific configuration & operation status
-       // used only when pAd->OpMode == OPMODE_STA
-       // -----------------------------------------------
-       STA_ADMIN_CONFIG        StaCfg;           // user desired settings
-       STA_ACTIVE_CONFIG       StaActive;         // valid only when ADHOC_ON(pAd) || INFRA_ON(pAd)
-       CHAR                    nickname[IW_ESSID_MAX_SIZE+1]; // nickname, only used in the iwconfig i/f
-       NDIS_MEDIA_STATE        PreMediaState;
-
-//=======Common===========
-       // OP mode: either AP or STA
-       UCHAR                   OpMode;                     // OPMODE_STA, OPMODE_AP
-
-       NDIS_MEDIA_STATE        IndicateMediaState;                     // Base on Indication state, default is NdisMediaStateDisConnected
-
-
-       // configuration: read from Registry & E2PROM
-       BOOLEAN                 bLocalAdminMAC;             // Use user changed MAC
-       UCHAR                   PermanentAddress[MAC_ADDR_LEN];    // Factory default MAC address
-       UCHAR                   CurrentAddress[MAC_ADDR_LEN];      // User changed MAC address
-
-       // ------------------------------------------------------
-       // common configuration to both OPMODE_STA and OPMODE_AP
-       // ------------------------------------------------------
-       COMMON_CONFIG           CommonCfg;
-       MLME_STRUCT             Mlme;
-
-       // AP needs those vaiables for site survey feature.
-       MLME_AUX                MlmeAux;           // temporary settings used during MLME state machine
-       BSS_TABLE               ScanTab;           // store the latest SCAN result
-
-       //About MacTab, the sta driver will use #0 and #1 for multicast and AP.
-       MAC_TABLE                 MacTab;     // ASIC on-chip WCID entry table.  At TX, ASIC always use key according to this on-chip table.
-       NDIS_SPIN_LOCK          MacTabLock;
-
-       BA_TABLE                        BATable;
-
-       NDIS_SPIN_LOCK          BATabLock;
-       RALINK_TIMER_STRUCT RECBATimer;
-
-       // encryption/decryption KEY tables
-       CIPHER_KEY              SharedKey[MAX_MBSSID_NUM][4]; // STA always use SharedKey[BSS0][0..3]
-
-               // RX re-assembly buffer for fragmentation
-       FRAGMENT_FRAME          FragFrame;                  // Frame storage for fragment frame
-
-       // various Counters
-       COUNTER_802_3           Counters8023;               // 802.3 counters
-       COUNTER_802_11          WlanCounters;               // 802.11 MIB counters
-       COUNTER_RALINK          RalinkCounters;             // Ralink propriety counters
-       COUNTER_DRS             DrsCounters;                // counters for Dynamic TX Rate Switching
-       PRIVATE_STRUC           PrivateInfo;                // Private information & counters
-
-       // flags, see fRTMP_ADAPTER_xxx flags
-       ULONG                   Flags;                      // Represent current device status
-
-       // current TX sequence #
-       USHORT                  Sequence;
-
-       // Control disconnect / connect event generation
-       //+++Didn't used anymore
-       ULONG                   LinkDownTime;
-       //---
-       ULONG                   LastRxRate;
-       ULONG                   LastTxRate;
-       //+++Used only for Station
-       BOOLEAN                 bConfigChanged;         // Config Change flag for the same SSID setting
-       //---
-
-       ULONG                   ExtraInfo;              // Extra information for displaying status
-       ULONG                   SystemErrorBitmap;      // b0: E2PROM version error
-
-       //+++Didn't used anymore
-       ULONG                   MacIcVersion;           // MAC/BBP serial interface issue solved after ver.D
-       //---
-
-       // ---------------------------
-       // System event log
-       // ---------------------------
-       RT_802_11_EVENT_TABLE   EventTab;
-
-
-       BOOLEAN         HTCEnable;
-
-       /*****************************************************************************************/
-       /*      Statistic related parameters                                                     */
-       /*****************************************************************************************/
-#ifdef RT2870
-       ULONG                                           BulkOutDataOneSecCount;
-       ULONG                                           BulkInDataOneSecCount;
-       ULONG                                           BulkLastOneSecCount; // BulkOutDataOneSecCount + BulkInDataOneSecCount
-       ULONG                                           watchDogRxCnt;
-       ULONG                                           watchDogRxOverFlowCnt;
-       ULONG                                           watchDogTxPendingCnt[NUM_OF_TX_RING];
-#endif // RT2870 //
-
-       BOOLEAN                                         bUpdateBcnCntDone;
-       ULONG                                           watchDogMacDeadlock;    // prevent MAC/BBP into deadlock condition
-       // ----------------------------
-       // DEBUG paramerts
-       // ----------------------------
-       BOOLEAN         bBanAllBaSetup;
-       BOOLEAN         bPromiscuous;
-
-       // ----------------------------
-       // rt2860c emulation-use Parameters
-       // ----------------------------
-       ULONG           rtsaccu[30];
-       ULONG           ctsaccu[30];
-       ULONG           cfendaccu[30];
-       ULONG           bacontent[16];
-       ULONG           rxint[RX_RING_SIZE+1];
-       UCHAR           rcvba[60];
-       BOOLEAN         bLinkAdapt;
-       BOOLEAN         bForcePrintTX;
-       BOOLEAN         bForcePrintRX;
-       BOOLEAN         bDisablescanning;               //defined in RT2870 USB
-       BOOLEAN         bStaFifoTest;
-       BOOLEAN         bProtectionTest;
-       BOOLEAN         bHCCATest;
-       BOOLEAN         bGenOneHCCA;
-       BOOLEAN         bBroadComHT;
-       //+++Following add from RT2870 USB.
-       ULONG           BulkOutReq;
-       ULONG           BulkOutComplete;
-       ULONG           BulkOutCompleteOther;
-       ULONG           BulkOutCompleteCancel;  // seems not use now?
-       ULONG           BulkInReq;
-       ULONG           BulkInComplete;
-       ULONG           BulkInCompleteFail;
-       //---
-
-    struct wificonf                    WIFItestbed;
-
-       struct reordering_mpdu_pool mpdu_blk_pool;
-
-       ULONG                                   OneSecondnonBEpackets;          // record non BE packets per second
-
-#if WIRELESS_EXT >= 12
-    struct iw_statistics    iw_stats;
-#endif
-
-       struct net_device_stats stats;
-
-       ULONG                                   TbttTickCount;
-#ifdef PCI_MSI_SUPPORT
-       BOOLEAN                                 HaveMsi;
-#endif // PCI_MSI_SUPPORT //
-
-
-       UCHAR                                   is_on;
-
-#define TIME_BASE                      (1000000/OS_HZ)
-#define TIME_ONE_SECOND                (1000000/TIME_BASE)
-       UCHAR                                   flg_be_adjust;
-       ULONG                                   be_adjust_last_time;
-
-#ifdef IKANOS_VX_1X0
-       struct IKANOS_TX_INFO   IkanosTxInfo;
-       struct IKANOS_TX_INFO   IkanosRxInfo[MAX_MBSSID_NUM + MAX_WDS_ENTRY + MAX_APCLI_NUM + MAX_MESH_NUM];
-#endif // IKANOS_VX_1X0 //
-
-
-#ifdef DBG_DIAGNOSE
-       RtmpDiagStruct  DiagStruct;
-#endif // DBG_DIAGNOSE //
-
-
-       UINT8                                   PM_FlgSuspend;
-
-#ifdef RT30xx
-//======efuse
-       BOOLEAN         bUseEfuse;
-       BOOLEAN         bEEPROMFile;
-#endif // RT30xx //
-
-} RTMP_ADAPTER, *PRTMP_ADAPTER;
-
-//
-// Cisco IAPP format
-//
-typedef struct  _CISCO_IAPP_CONTENT_
-{
-       USHORT     Length;        //IAPP Length
-       UCHAR      MessageType;      //IAPP type
-       UCHAR      FunctionCode;     //IAPP function type
-       UCHAR      DestinaionMAC[MAC_ADDR_LEN];
-       UCHAR      SourceMAC[MAC_ADDR_LEN];
-       USHORT     Tag;           //Tag(element IE) - Adjacent AP report
-       USHORT     TagLength;     //Length of element not including 4 byte header
-       UCHAR      OUI[4];           //0x00, 0x40, 0x96, 0x00
-       UCHAR      PreviousAP[MAC_ADDR_LEN];       //MAC Address of access point
-       USHORT     Channel;
-       USHORT     SsidLen;
-       UCHAR      Ssid[MAX_LEN_OF_SSID];
-       USHORT     Seconds;          //Seconds that the client has been disassociated.
-} CISCO_IAPP_CONTENT, *PCISCO_IAPP_CONTENT;
-
-#define DELAYINTMASK           0x0003fffb
-#define INTMASK                                0x0003fffb
-#define IndMask                                0x0003fffc
-#define RxINT                          0x00000005      // Delayed Rx or indivi rx
-#define TxDataInt                      0x000000fa      // Delayed Tx or indivi tx
-#define TxMgmtInt                      0x00000102      // Delayed Tx or indivi tx
-#define TxCoherent                     0x00020000      // tx coherent
-#define RxCoherent                     0x00010000      // rx coherent
-#define McuCommand                     0x00000200      // mcu
-#define PreTBTTInt                     0x00001000      // Pre-TBTT interrupt
-#define TBTTInt                                0x00000800              // TBTT interrupt
-#define GPTimeOutInt                   0x00008000              // GPtimeout interrupt
-#define AutoWakeupInt          0x00004000              // AutoWakeupInt interrupt
-#define FifoStaFullInt                 0x00002000      //  fifo statistics full interrupt
-
-
-typedef struct _RX_BLK_
-{
-       RT28XX_RXD_STRUC        RxD;
-       PRXWI_STRUC                     pRxWI;
-       PHEADER_802_11          pHeader;
-       PNDIS_PACKET            pRxPacket;
-       UCHAR                           *pData;
-       USHORT                          DataSize;
-       USHORT                          Flags;
-       UCHAR                           UserPriority;   // for calculate TKIP MIC using
-} RX_BLK;
-
-
-#define RX_BLK_SET_FLAG(_pRxBlk, _flag)                (_pRxBlk->Flags |= _flag)
-#define RX_BLK_TEST_FLAG(_pRxBlk, _flag)       (_pRxBlk->Flags & _flag)
-#define RX_BLK_CLEAR_FLAG(_pRxBlk, _flag)      (_pRxBlk->Flags &= ~(_flag))
-
-
-#define fRX_WDS                        0x0001
-#define fRX_AMSDU       0x0002
-#define fRX_ARALINK     0x0004
-#define fRX_HTC         0x0008
-#define fRX_PAD         0x0010
-#define fRX_AMPDU       0x0020
-#define fRX_QOS                        0x0040
-#define fRX_INFRA              0x0080
-#define fRX_EAP                        0x0100
-#define fRX_MESH               0x0200
-#define fRX_APCLI              0x0400
-#define fRX_DLS                        0x0800
-#define fRX_WPI                        0x1000
-
-#define LENGTH_AMSDU_SUBFRAMEHEAD      14
-#define LENGTH_ARALINK_SUBFRAMEHEAD    14
-#define LENGTH_ARALINK_HEADER_FIELD     2
-
-#define TX_UNKOWN_FRAME                        0x00
-#define TX_MCAST_FRAME                 0x01
-#define TX_LEGACY_FRAME                        0x02
-#define TX_AMPDU_FRAME                 0x04
-#define TX_AMSDU_FRAME                 0x08
-#define TX_RALINK_FRAME                        0x10
-#define TX_FRAG_FRAME                  0x20
-
-
-//     Currently the sizeof(TX_BLK) is 148 bytes.
-typedef struct _TX_BLK_
-{
-       UCHAR                           QueIdx;
-       UCHAR                           TxFrameType;                            // Indicate the Transmission type of the all frames in one batch
-       UCHAR                           TotalFrameNum;                          // Total frame number want to send-out in one batch
-       USHORT                          TotalFragNum;                           // Total frame fragments required in one batch
-       USHORT                          TotalFrameLen;                          // Total length of all frames want to send-out in one batch
-
-       QUEUE_HEADER            TxPacketList;
-       MAC_TABLE_ENTRY         *pMacEntry;                                     // NULL: packet with 802.11 RA field is multicast/broadcast address
-       HTTRANSMIT_SETTING      *pTransmit;
-
-       // Following structure used for the characteristics of a specific packet.
-       PNDIS_PACKET            pPacket;
-       PUCHAR                          pSrcBufHeader;                          // Reference to the head of sk_buff->data
-       PUCHAR                          pSrcBufData;                            // Reference to the sk_buff->data, will changed depends on hanlding progresss
-       UINT                            SrcBufLen;                                      // Length of packet payload which not including Layer 2 header
-       PUCHAR                          pExtraLlcSnapEncap;                     // NULL means no extra LLC/SNAP is required
-       UCHAR                           HeaderBuf[80];                          // TempBuffer for TX_INFO + TX_WI + 802.11 Header + padding + AMSDU SubHeader + LLC/SNAP
-       UCHAR                           MpduHeaderLen;                          // 802.11 header length NOT including the padding
-       UCHAR                           HdrPadLen;                                      // recording Header Padding Length;
-       UCHAR                           apidx;                                          // The interface associated to this packet
-       UCHAR                           Wcid;                                           // The MAC entry associated to this packet
-       UCHAR                           UserPriority;                           // priority class of packet
-       UCHAR                           FrameGap;                                       // what kind of IFS this packet use
-       UCHAR                           MpduReqNum;                                     // number of fragments of this frame
-       UCHAR                           TxRate;                                         // TODO: Obsoleted? Should change to MCS?
-       UCHAR                           CipherAlg;                                      // cipher alogrithm
-       PCIPHER_KEY                     pKey;
-
-
-
-       USHORT                          Flags;                                          //See following definitions for detail.
-
-       //YOU SHOULD NOT TOUCH IT! Following parameters are used for hardware-depended layer.
-       ULONG                           Priv;                                           // Hardware specific value saved in here.
-} TX_BLK, *PTX_BLK;
-
-
-#define fTX_bRtsRequired               0x0001  // Indicate if need send RTS frame for protection. Not used in RT2860/RT2870.
-#define fTX_bAckRequired               0x0002  // the packet need ack response
-#define fTX_bPiggyBack                 0x0004  // Legacy device use Piggback or not
-#define fTX_bHTRate            0x0008  // allow to use HT rate
-#define fTX_bForceNonQoS               0x0010  // force to transmit frame without WMM-QoS in HT mode
-#define fTX_bAllowFrag         0x0020  // allow to fragment the packet, A-MPDU, A-MSDU, A-Ralink is not allowed to fragment
-#define fTX_bMoreData                  0x0040  // there are more data packets in PowerSave Queue
-#define fTX_bWMM                               0x0080  // QOS Data
-
-#define fTX_bClearEAPFrame             0x0100
-
-#define TX_BLK_ASSIGN_FLAG(_pTxBlk, _flag, value)      \
-               do {                                                                            \
-                       if (value)                                                              \
-                               (_pTxBlk->Flags |= _flag)                       \
-                       else                                                                    \
-                               (_pTxBlk->Flags &= ~(_flag))            \
-               }while(0)
-
-#define TX_BLK_SET_FLAG(_pTxBlk, _flag)                (_pTxBlk->Flags |= _flag)
-#define TX_BLK_TEST_FLAG(_pTxBlk, _flag)       (((_pTxBlk->Flags & _flag) == _flag) ? 1 : 0)
-#define TX_BLK_CLEAR_FLAG(_pTxBlk, _flag)      (_pTxBlk->Flags &= ~(_flag))
-
-
-
-
-
-//------------------------------------------------------------------------------------------
-
-static inline VOID ConvertMulticastIP2MAC(
-       IN PUCHAR pIpAddr,
-       IN PUCHAR *ppMacAddr,
-       IN UINT16 ProtoType)
-{
-       if (pIpAddr == NULL)
-               return;
-
-       if (ppMacAddr == NULL || *ppMacAddr == NULL)
-               return;
-
-       switch (ProtoType)
-       {
-               case ETH_P_IPV6:
-//                     memset(*ppMacAddr, 0, ETH_LENGTH_OF_ADDRESS);
-                       *(*ppMacAddr) = 0x33;
-                       *(*ppMacAddr + 1) = 0x33;
-                       *(*ppMacAddr + 2) = pIpAddr[12];
-                       *(*ppMacAddr + 3) = pIpAddr[13];
-                       *(*ppMacAddr + 4) = pIpAddr[14];
-                       *(*ppMacAddr + 5) = pIpAddr[15];
-                       break;
-
-               case ETH_P_IP:
-               default:
-//                     memset(*ppMacAddr, 0, ETH_LENGTH_OF_ADDRESS);
-                       *(*ppMacAddr) = 0x01;
-                       *(*ppMacAddr + 1) = 0x00;
-                       *(*ppMacAddr + 2) = 0x5e;
-                       *(*ppMacAddr + 3) = pIpAddr[1] & 0x7f;
-                       *(*ppMacAddr + 4) = pIpAddr[2];
-                       *(*ppMacAddr + 5) = pIpAddr[3];
-                       break;
-       }
-
-       return;
-}
-
-BOOLEAN RTMPCheckForHang(
-       IN  NDIS_HANDLE MiniportAdapterContext
-       );
-
-VOID  RTMPHalt(
-       IN  NDIS_HANDLE MiniportAdapterContext
-       );
-
-//
-//  Private routines in rtmp_init.c
-//
-NDIS_STATUS RTMPAllocAdapterBlock(
-       IN PVOID                        handle,
-       OUT PRTMP_ADAPTER   *ppAdapter
-       );
-
-NDIS_STATUS RTMPAllocTxRxRingMemory(
-       IN  PRTMP_ADAPTER   pAd
-       );
-
-NDIS_STATUS RTMPFindAdapter(
-       IN  PRTMP_ADAPTER   pAd,
-       IN  NDIS_HANDLE     WrapperConfigurationContext
-       );
-
-NDIS_STATUS    RTMPReadParametersHook(
-       IN      PRTMP_ADAPTER pAd
-       );
-
-VOID RTMPFreeAdapter(
-       IN  PRTMP_ADAPTER   pAd
-       );
-
-NDIS_STATUS NICReadRegParameters(
-       IN  PRTMP_ADAPTER       pAd,
-       IN  NDIS_HANDLE         WrapperConfigurationContext
-       );
-
-#ifdef RT30xx
-VOID NICInitRT30xxRFRegisters(
-       IN PRTMP_ADAPTER pAd);
-#endif // RT30xx //
-
-VOID NICReadEEPROMParameters(
-       IN  PRTMP_ADAPTER       pAd,
-       IN      PUCHAR                          mac_addr);
-
-VOID NICInitAsicFromEEPROM(
-       IN  PRTMP_ADAPTER       pAd);
-
-VOID NICInitTxRxRingAndBacklogQueue(
-       IN  PRTMP_ADAPTER   pAd);
-
-NDIS_STATUS NICInitializeAdapter(
-       IN  PRTMP_ADAPTER   pAd,
-       IN   BOOLEAN    bHardReset);
-
-NDIS_STATUS NICInitializeAsic(
-       IN  PRTMP_ADAPTER   pAd,
-       IN  BOOLEAN             bHardReset);
-
-VOID NICIssueReset(
-       IN  PRTMP_ADAPTER   pAd);
-
-VOID RTMPRingCleanUp(
-       IN  PRTMP_ADAPTER   pAd,
-       IN  UCHAR           RingType);
-
-VOID RxTest(
-       IN  PRTMP_ADAPTER   pAd);
-
-NDIS_STATUS DbgSendPacket(
-       IN  PRTMP_ADAPTER   pAd,
-       IN  PNDIS_PACKET    pPacket);
-
-VOID UserCfgInit(
-       IN  PRTMP_ADAPTER   pAd);
-
-VOID NICResetFromError(
-       IN  PRTMP_ADAPTER   pAd);
-
-VOID NICEraseFirmware(
-       IN PRTMP_ADAPTER pAd);
-
-NDIS_STATUS NICLoadFirmware(
-       IN  PRTMP_ADAPTER   pAd);
-
-NDIS_STATUS NICLoadRateSwitchingParams(
-       IN PRTMP_ADAPTER pAd);
-
-BOOLEAN NICCheckForHang(
-       IN  PRTMP_ADAPTER   pAd);
-
-VOID NICUpdateFifoStaCounters(
-       IN PRTMP_ADAPTER pAd);
-
-VOID NICUpdateRawCounters(
-       IN  PRTMP_ADAPTER   pAd);
-
-ULONG  RTMPNotAllZero(
-       IN      PVOID   pSrc1,
-       IN      ULONG   Length);
-
-VOID RTMPZeroMemory(
-       IN  PVOID   pSrc,
-       IN  ULONG   Length);
-
-ULONG RTMPCompareMemory(
-       IN  PVOID   pSrc1,
-       IN  PVOID   pSrc2,
-       IN  ULONG   Length);
-
-VOID RTMPMoveMemory(
-       OUT PVOID   pDest,
-       IN  PVOID   pSrc,
-       IN  ULONG   Length);
-
-VOID AtoH(
-       char    *src,
-       UCHAR   *dest,
-       int             destlen);
-
-UCHAR BtoH(
-       char ch);
-
-VOID RTMPPatchMacBbpBug(
-       IN  PRTMP_ADAPTER   pAd);
-
-VOID RTMPPatchCardBus(
-       IN      PRTMP_ADAPTER   pAdapter);
-
-VOID RTMPPatchRalinkCardBus(
-       IN      PRTMP_ADAPTER   pAdapter,
-       IN      ULONG                   Bus);
-
-ULONG RTMPReadCBConfig(
-       IN      ULONG   Bus,
-       IN      ULONG   Slot,
-       IN      ULONG   Func,
-       IN      ULONG   Offset);
-
-VOID RTMPWriteCBConfig(
-       IN      ULONG   Bus,
-       IN      ULONG   Slot,
-       IN      ULONG   Func,
-       IN      ULONG   Offset,
-       IN      ULONG   Value);
-
-VOID RTMPInitTimer(
-       IN  PRTMP_ADAPTER           pAd,
-       IN  PRALINK_TIMER_STRUCT    pTimer,
-       IN  PVOID                   pTimerFunc,
-       IN      PVOID                                   pData,
-       IN  BOOLEAN                 Repeat);
-
-VOID RTMPSetTimer(
-       IN  PRALINK_TIMER_STRUCT    pTimer,
-       IN  ULONG                   Value);
-
-
-VOID RTMPModTimer(
-       IN      PRALINK_TIMER_STRUCT    pTimer,
-       IN      ULONG                                   Value);
-
-VOID RTMPCancelTimer(
-       IN  PRALINK_TIMER_STRUCT    pTimer,
-       OUT BOOLEAN                 *pCancelled);
-
-VOID RTMPSetLED(
-       IN PRTMP_ADAPTER        pAd,
-       IN UCHAR                        Status);
-
-VOID RTMPSetSignalLED(
-       IN PRTMP_ADAPTER        pAd,
-       IN NDIS_802_11_RSSI Dbm);
-
-VOID RTMPEnableRxTx(
-       IN PRTMP_ADAPTER        pAd);
-
-//
-// prototype in action.c
-//
-VOID ActionStateMachineInit(
-    IN PRTMP_ADAPTER   pAd,
-    IN  STATE_MACHINE *S,
-    OUT STATE_MACHINE_FUNC Trans[]);
-
-VOID MlmeADDBAAction(
-    IN PRTMP_ADAPTER pAd,
-    IN MLME_QUEUE_ELEM *Elem);
-
-VOID MlmeDELBAAction(
-    IN PRTMP_ADAPTER pAd,
-    IN MLME_QUEUE_ELEM *Elem);
-
-VOID MlmeDLSAction(
-    IN PRTMP_ADAPTER pAd,
-    IN MLME_QUEUE_ELEM *Elem);
-
-VOID MlmeInvalidAction(
-    IN PRTMP_ADAPTER pAd,
-    IN MLME_QUEUE_ELEM *Elem);
-
-VOID MlmeQOSAction(
-    IN PRTMP_ADAPTER pAd,
-    IN MLME_QUEUE_ELEM *Elem);
-
-VOID PeerAddBAReqAction(
-       IN PRTMP_ADAPTER pAd,
-       IN MLME_QUEUE_ELEM *Elem);
-
-VOID PeerAddBARspAction(
-       IN PRTMP_ADAPTER pAd,
-       IN MLME_QUEUE_ELEM *Elem);
-
-VOID PeerDelBAAction(
-       IN PRTMP_ADAPTER pAd,
-       IN MLME_QUEUE_ELEM *Elem);
-
-VOID PeerBAAction(
-    IN PRTMP_ADAPTER pAd,
-    IN MLME_QUEUE_ELEM *Elem);
-
-VOID SendPSMPAction(
-       IN PRTMP_ADAPTER        pAd,
-       IN UCHAR                        Wcid,
-       IN UCHAR                        Psmp);
-
-VOID PeerRMAction(
-       IN PRTMP_ADAPTER pAd,
-       IN MLME_QUEUE_ELEM *Elem);
-
-VOID PeerPublicAction(
-       IN PRTMP_ADAPTER pAd,
-       IN MLME_QUEUE_ELEM *Elem);
-
-VOID StaPublicAction(
-       IN PRTMP_ADAPTER pAd,
-       IN UCHAR Bss2040Coexist);
-
-VOID PeerBSSTranAction(
-       IN PRTMP_ADAPTER pAd,
-       IN MLME_QUEUE_ELEM *Elem);
-
-VOID PeerHTAction(
-       IN PRTMP_ADAPTER pAd,
-       IN MLME_QUEUE_ELEM *Elem);
-
-VOID PeerQOSAction(
-    IN PRTMP_ADAPTER pAd,
-    IN MLME_QUEUE_ELEM *Elem);
-
-VOID RECBATimerTimeout(
-    IN PVOID SystemSpecific1,
-    IN PVOID FunctionContext,
-    IN PVOID SystemSpecific2,
-    IN PVOID SystemSpecific3);
-
-VOID ORIBATimerTimeout(
-       IN      PRTMP_ADAPTER   pAd);
-
-VOID SendRefreshBAR(
-       IN      PRTMP_ADAPTER   pAd,
-       IN      MAC_TABLE_ENTRY *pEntry);
-
-VOID ActHeaderInit(
-    IN PRTMP_ADAPTER   pAd,
-    IN OUT PHEADER_802_11 pHdr80211,
-    IN PUCHAR Addr1,
-    IN PUCHAR Addr2,
-    IN PUCHAR Addr3);
-
-VOID BarHeaderInit(
-       IN      PRTMP_ADAPTER   pAd,
-       IN OUT PFRAME_BAR pCntlBar,
-       IN PUCHAR pDA,
-       IN PUCHAR pSA);
-
-VOID InsertActField(
-       IN PRTMP_ADAPTER pAd,
-       OUT PUCHAR pFrameBuf,
-       OUT PULONG pFrameLen,
-       IN UINT8 Category,
-       IN UINT8 ActCode);
-
-BOOLEAN QosBADataParse(
-       IN PRTMP_ADAPTER        pAd,
-       IN BOOLEAN bAMSDU,
-       IN PUCHAR p8023Header,
-       IN UCHAR        WCID,
-       IN UCHAR        TID,
-       IN USHORT Sequence,
-       IN UCHAR DataOffset,
-       IN USHORT Datasize,
-       IN UINT   CurRxIndex);
-
-BOOLEAN CntlEnqueueForRecv(
-    IN PRTMP_ADAPTER   pAd,
-       IN ULONG Wcid,
-    IN ULONG MsgLen,
-       IN PFRAME_BA_REQ pMsg);
-
-VOID BaAutoManSwitch(
-       IN      PRTMP_ADAPTER   pAd);
-
-VOID HTIOTCheck(
-       IN      PRTMP_ADAPTER   pAd,
-       IN    UCHAR     BatRecIdx);
-
-//
-// Private routines in rtmp_data.c
-//
-BOOLEAN RTMPHandleRxDoneInterrupt(
-       IN  PRTMP_ADAPTER   pAd);
-
-VOID RTMPHandleTxDoneInterrupt(
-       IN  PRTMP_ADAPTER   pAd);
-
-BOOLEAN RTMPHandleTxRingDmaDoneInterrupt(
-       IN  PRTMP_ADAPTER   pAd,
-       IN  INT_SOURCE_CSR_STRUC TxRingBitmap);
-
-VOID RTMPHandleMgmtRingDmaDoneInterrupt(
-       IN  PRTMP_ADAPTER   pAd);
-
-VOID RTMPHandleTBTTInterrupt(
-       IN  PRTMP_ADAPTER   pAd);
-
-VOID RTMPHandlePreTBTTInterrupt(
-       IN  PRTMP_ADAPTER   pAd);
-
-void RTMPHandleTwakeupInterrupt(
-       IN PRTMP_ADAPTER pAd);
-
-VOID   RTMPHandleRxCoherentInterrupt(
-       IN      PRTMP_ADAPTER   pAd);
-
-BOOLEAN TxFrameIsAggregatible(
-       IN  PRTMP_ADAPTER   pAd,
-       IN  PUCHAR          pPrevAddr1,
-       IN  PUCHAR          p8023hdr);
-
-BOOLEAN PeerIsAggreOn(
-    IN  PRTMP_ADAPTER   pAd,
-    IN  ULONG          TxRate,
-    IN  PMAC_TABLE_ENTRY pMacEntry);
-
-NDIS_STATUS Sniff2BytesFromNdisBuffer(
-       IN  PNDIS_BUFFER    pFirstBuffer,
-       IN  UCHAR           DesiredOffset,
-       OUT PUCHAR          pByte0,
-       OUT PUCHAR          pByte1);
-
-NDIS_STATUS STASendPacket(
-       IN  PRTMP_ADAPTER   pAd,
-       IN  PNDIS_PACKET    pPacket);
-
-VOID STASendPackets(
-       IN  NDIS_HANDLE     MiniportAdapterContext,
-       IN  PPNDIS_PACKET   ppPacketArray,
-       IN  UINT            NumberOfPackets);
-
-VOID RTMPDeQueuePacket(
-       IN  PRTMP_ADAPTER   pAd,
-       IN      BOOLEAN                 bIntContext,
-       IN  UCHAR                       QueIdx,
-       IN      UCHAR                   Max_Tx_Packets);
-
-NDIS_STATUS    RTMPHardTransmit(
-       IN PRTMP_ADAPTER        pAd,
-       IN PNDIS_PACKET         pPacket,
-       IN  UCHAR                       QueIdx,
-       OUT     PULONG                  pFreeTXDLeft);
-
-NDIS_STATUS    STAHardTransmit(
-       IN PRTMP_ADAPTER        pAd,
-       IN TX_BLK                       *pTxBlk,
-       IN  UCHAR                       QueIdx);
-
-VOID STARxEAPOLFrameIndicate(
-       IN      PRTMP_ADAPTER   pAd,
-       IN      MAC_TABLE_ENTRY *pEntry,
-       IN      RX_BLK                  *pRxBlk,
-       IN      UCHAR                   FromWhichBSSID);
-
-NDIS_STATUS RTMPFreeTXDRequest(
-       IN  PRTMP_ADAPTER   pAd,
-       IN  UCHAR           RingType,
-       IN  UCHAR           NumberRequired,
-       IN      PUCHAR          FreeNumberIs);
-
-NDIS_STATUS MlmeHardTransmit(
-       IN  PRTMP_ADAPTER   pAd,
-       IN  UCHAR       QueIdx,
-       IN  PNDIS_PACKET    pPacket);
-
-NDIS_STATUS MlmeHardTransmitMgmtRing(
-       IN  PRTMP_ADAPTER   pAd,
-       IN  UCHAR       QueIdx,
-       IN  PNDIS_PACKET    pPacket);
-
-NDIS_STATUS MlmeHardTransmitTxRing(
-       IN  PRTMP_ADAPTER   pAd,
-       IN  UCHAR       QueIdx,
-       IN  PNDIS_PACKET    pPacket);
-
-USHORT  RTMPCalcDuration(
-       IN  PRTMP_ADAPTER   pAd,
-       IN  UCHAR           Rate,
-       IN  ULONG           Size);
-
-VOID RTMPWriteTxWI(
-       IN      PRTMP_ADAPTER   pAd,
-       IN      PTXWI_STRUC             pTxWI,
-       IN  BOOLEAN             FRAG,
-       IN  BOOLEAN             CFACK,
-       IN  BOOLEAN             InsTimestamp,
-       IN      BOOLEAN                 AMPDU,
-       IN      BOOLEAN                 Ack,
-       IN      BOOLEAN                 NSeq,           // HW new a sequence.
-       IN      UCHAR                   BASize,
-       IN      UCHAR                   WCID,
-       IN      ULONG                   Length,
-       IN  UCHAR               PID,
-       IN      UCHAR                   TID,
-       IN      UCHAR                   TxRate,
-       IN      UCHAR                   Txopmode,
-       IN      BOOLEAN                 CfAck,
-       IN      HTTRANSMIT_SETTING      *pTransmit);
-
-
-VOID RTMPWriteTxWI_Data(
-       IN      PRTMP_ADAPTER           pAd,
-       IN      OUT PTXWI_STRUC         pTxWI,
-       IN      TX_BLK                          *pTxBlk);
-
-
-VOID RTMPWriteTxWI_Cache(
-       IN      PRTMP_ADAPTER           pAd,
-       IN      OUT PTXWI_STRUC         pTxWI,
-       IN      TX_BLK                          *pTxBlk);
-
-VOID RTMPWriteTxDescriptor(
-       IN      PRTMP_ADAPTER   pAd,
-       IN      PTXD_STRUC              pTxD,
-       IN      BOOLEAN                 bWIV,
-       IN      UCHAR                   QSEL);
-
-VOID RTMPSuspendMsduTransmission(
-       IN  PRTMP_ADAPTER   pAd);
-
-VOID RTMPResumeMsduTransmission(
-       IN  PRTMP_ADAPTER   pAd);
-
-NDIS_STATUS MiniportMMRequest(
-       IN  PRTMP_ADAPTER   pAd,
-       IN      UCHAR                   QueIdx,
-       IN      PUCHAR                  pData,
-       IN  UINT            Length);
-
-NDIS_STATUS MiniportDataMMRequest(
-        IN  PRTMP_ADAPTER   pAd,
-        IN  UCHAR           QueIdx,
-        IN  PUCHAR          pData,
-        IN  UINT            Length);
-
-VOID RTMPSendNullFrame(
-       IN  PRTMP_ADAPTER   pAd,
-       IN  UCHAR           TxRate,
-       IN      BOOLEAN                 bQosNull);
-
-VOID RTMPSendDisassociationFrame(
-       IN      PRTMP_ADAPTER   pAd);
-
-VOID RTMPSendRTSFrame(
-       IN  PRTMP_ADAPTER   pAd,
-       IN  PUCHAR          pDA,
-       IN      unsigned int    NextMpduSize,
-       IN  UCHAR           TxRate,
-       IN  UCHAR           RTSRate,
-       IN  USHORT          AckDuration,
-       IN  UCHAR           QueIdx,
-       IN  UCHAR                       FrameGap);
-
-
-NDIS_STATUS RTMPApplyPacketFilter(
-       IN  PRTMP_ADAPTER   pAd,
-       IN  PRT28XX_RXD_STRUC      pRxD,
-       IN  PHEADER_802_11  pHeader);
-
-PQUEUE_HEADER   RTMPCheckTxSwQueue(
-       IN  PRTMP_ADAPTER   pAd,
-       OUT UCHAR           *QueIdx);
-
-VOID RTMPReportMicError(
-       IN  PRTMP_ADAPTER   pAd,
-       IN  PCIPHER_KEY     pWpaKey);
-
-VOID   WpaMicFailureReportFrame(
-       IN  PRTMP_ADAPTER    pAd,
-       IN  MLME_QUEUE_ELEM *Elem);
-
-VOID    WpaDisassocApAndBlockAssoc(
-    IN  PVOID SystemSpecific1,
-    IN  PVOID FunctionContext,
-    IN  PVOID SystemSpecific2,
-    IN  PVOID SystemSpecific3);
-
-NDIS_STATUS RTMPCloneNdisPacket(
-       IN  PRTMP_ADAPTER   pAd,
-       IN      BOOLEAN    pInsAMSDUHdr,
-       IN  PNDIS_PACKET    pInPacket,
-       OUT PNDIS_PACKET   *ppOutPacket);
-
-NDIS_STATUS RTMPAllocateNdisPacket(
-       IN  PRTMP_ADAPTER   pAd,
-       IN  PNDIS_PACKET    *pPacket,
-       IN  PUCHAR          pHeader,
-       IN  UINT            HeaderLen,
-       IN  PUCHAR          pData,
-       IN  UINT            DataLen);
-
-VOID RTMPFreeNdisPacket(
-       IN  PRTMP_ADAPTER   pAd,
-       IN  PNDIS_PACKET    pPacket);
-
-BOOLEAN RTMPFreeTXDUponTxDmaDone(
-       IN PRTMP_ADAPTER    pAd,
-       IN UCHAR            QueIdx);
-
-BOOLEAN RTMPCheckDHCPFrame(
-       IN      PRTMP_ADAPTER   pAd,
-       IN      PNDIS_PACKET    pPacket);
-
-
-BOOLEAN RTMPCheckEtherType(
-       IN      PRTMP_ADAPTER   pAd,
-       IN      PNDIS_PACKET    pPacket);
-
-
-VOID RTMPCckBbpTuning(
-       IN      PRTMP_ADAPTER   pAd,
-       IN      UINT                    TxRate);
-
-//
-// Private routines in rtmp_wep.c
-//
-VOID RTMPInitWepEngine(
-       IN  PRTMP_ADAPTER   pAd,
-       IN  PUCHAR          pKey,
-       IN  UCHAR           KeyId,
-       IN  UCHAR           KeyLen,
-       IN  PUCHAR          pDest);
-
-VOID RTMPEncryptData(
-       IN  PRTMP_ADAPTER   pAd,
-       IN  PUCHAR          pSrc,
-       IN  PUCHAR          pDest,
-       IN  UINT            Len);
-
-BOOLEAN        RTMPDecryptData(
-       IN      PRTMP_ADAPTER   pAdapter,
-       IN      PUCHAR                  pSrc,
-       IN      UINT                    Len,
-       IN      UINT                    idx);
-
-BOOLEAN        RTMPSoftDecryptWEP(
-       IN PRTMP_ADAPTER        pAd,
-       IN PUCHAR                       pData,
-       IN ULONG                        DataByteCnt,
-       IN PCIPHER_KEY          pGroupKey);
-
-VOID RTMPSetICV(
-       IN  PRTMP_ADAPTER   pAd,
-       IN  PUCHAR          pDest);
-
-VOID ARCFOUR_INIT(
-       IN  PARCFOURCONTEXT Ctx,
-       IN  PUCHAR          pKey,
-       IN  UINT            KeyLen);
-
-UCHAR   ARCFOUR_BYTE(
-       IN  PARCFOURCONTEXT     Ctx);
-
-VOID ARCFOUR_DECRYPT(
-       IN  PARCFOURCONTEXT Ctx,
-       IN  PUCHAR          pDest,
-       IN  PUCHAR          pSrc,
-       IN  UINT            Len);
-
-VOID ARCFOUR_ENCRYPT(
-       IN  PARCFOURCONTEXT Ctx,
-       IN  PUCHAR          pDest,
-       IN  PUCHAR          pSrc,
-       IN  UINT            Len);
-
-VOID WPAARCFOUR_ENCRYPT(
-       IN  PARCFOURCONTEXT Ctx,
-       IN  PUCHAR          pDest,
-       IN  PUCHAR          pSrc,
-       IN  UINT            Len);
-
-UINT RTMP_CALC_FCS32(
-       IN  UINT   Fcs,
-       IN  PUCHAR  Cp,
-       IN  INT     Len);
-
-//
-// MLME routines
-//
-
-// Asic/RF/BBP related functions
-
-VOID AsicAdjustTxPower(
-       IN PRTMP_ADAPTER pAd);
-
-VOID   AsicUpdateProtect(
-       IN              PRTMP_ADAPTER   pAd,
-       IN              USHORT                  OperaionMode,
-       IN              UCHAR                   SetMask,
-       IN              BOOLEAN                 bDisableBGProtect,
-       IN              BOOLEAN                 bNonGFExist);
-
-VOID AsicSwitchChannel(
-       IN  PRTMP_ADAPTER   pAd,
-       IN      UCHAR                   Channel,
-       IN      BOOLEAN                 bScan);
-
-VOID AsicLockChannel(
-       IN PRTMP_ADAPTER pAd,
-       IN UCHAR Channel) ;
-
-VOID AsicAntennaSelect(
-       IN  PRTMP_ADAPTER   pAd,
-       IN  UCHAR           Channel);
-
-VOID AsicAntennaSetting(
-       IN      PRTMP_ADAPTER   pAd,
-       IN      ABGBAND_STATE   BandState);
-
-VOID AsicRfTuningExec(
-       IN PVOID SystemSpecific1,
-       IN PVOID FunctionContext,
-       IN PVOID SystemSpecific2,
-       IN PVOID SystemSpecific3);
-
-VOID AsicSleepThenAutoWakeup(
-       IN  PRTMP_ADAPTER   pAd,
-       IN  USHORT TbttNumToNextWakeUp);
-
-VOID AsicForceSleep(
-       IN PRTMP_ADAPTER pAd);
-
-VOID AsicForceWakeup(
-       IN PRTMP_ADAPTER pAd,
-       IN BOOLEAN    bFromTx);
-
-VOID AsicSetBssid(
-       IN  PRTMP_ADAPTER   pAd,
-       IN  PUCHAR pBssid);
-
-VOID AsicSetMcastWC(
-       IN PRTMP_ADAPTER pAd);
-
-VOID AsicDelWcidTab(
-       IN PRTMP_ADAPTER pAd,
-       IN UCHAR        Wcid);
-
-VOID AsicEnableRDG(
-       IN PRTMP_ADAPTER pAd);
-
-VOID AsicDisableRDG(
-       IN PRTMP_ADAPTER pAd);
-
-VOID AsicDisableSync(
-       IN  PRTMP_ADAPTER   pAd);
-
-VOID AsicEnableBssSync(
-       IN  PRTMP_ADAPTER   pAd);
-
-VOID AsicEnableIbssSync(
-       IN  PRTMP_ADAPTER   pAd);
-
-VOID AsicSetEdcaParm(
-       IN PRTMP_ADAPTER pAd,
-       IN PEDCA_PARM    pEdcaParm);
-
-VOID AsicSetSlotTime(
-       IN PRTMP_ADAPTER pAd,
-       IN BOOLEAN bUseShortSlotTime);
-
-VOID AsicAddSharedKeyEntry(
-       IN PRTMP_ADAPTER pAd,
-       IN UCHAR         BssIndex,
-       IN UCHAR         KeyIdx,
-       IN UCHAR         CipherAlg,
-       IN PUCHAR        pKey,
-       IN PUCHAR        pTxMic,
-       IN PUCHAR        pRxMic);
-
-VOID AsicRemoveSharedKeyEntry(
-       IN PRTMP_ADAPTER pAd,
-       IN UCHAR         BssIndex,
-       IN UCHAR         KeyIdx);
-
-VOID AsicUpdateWCIDAttribute(
-       IN PRTMP_ADAPTER pAd,
-       IN USHORT               WCID,
-       IN UCHAR                BssIndex,
-       IN UCHAR        CipherAlg,
-       IN BOOLEAN              bUsePairewiseKeyTable);
-
-VOID AsicUpdateWCIDIVEIV(
-       IN PRTMP_ADAPTER pAd,
-       IN USHORT               WCID,
-       IN ULONG        uIV,
-       IN ULONG        uEIV);
-
-VOID AsicUpdateRxWCIDTable(
-       IN PRTMP_ADAPTER pAd,
-       IN USHORT               WCID,
-       IN PUCHAR        pAddr);
-
-VOID AsicAddKeyEntry(
-       IN PRTMP_ADAPTER pAd,
-       IN USHORT               WCID,
-       IN UCHAR                BssIndex,
-       IN UCHAR                KeyIdx,
-       IN PCIPHER_KEY  pCipherKey,
-       IN BOOLEAN              bUsePairewiseKeyTable,
-       IN BOOLEAN              bTxKey);
-
-VOID AsicAddPairwiseKeyEntry(
-       IN PRTMP_ADAPTER pAd,
-       IN PUCHAR        pAddr,
-       IN UCHAR                WCID,
-       IN CIPHER_KEY            *pCipherKey);
-
-VOID AsicRemovePairwiseKeyEntry(
-       IN PRTMP_ADAPTER  pAd,
-       IN UCHAR                 BssIdx,
-       IN UCHAR                 Wcid);
-
-BOOLEAN AsicSendCommandToMcu(
-       IN PRTMP_ADAPTER pAd,
-       IN UCHAR         Command,
-       IN UCHAR         Token,
-       IN UCHAR         Arg0,
-       IN UCHAR         Arg1);
-
-
-VOID MacAddrRandomBssid(
-       IN  PRTMP_ADAPTER   pAd,
-       OUT PUCHAR pAddr);
-
-VOID MgtMacHeaderInit(
-       IN  PRTMP_ADAPTER     pAd,
-       IN OUT PHEADER_802_11 pHdr80211,
-       IN UCHAR SubType,
-       IN UCHAR ToDs,
-       IN PUCHAR pDA,
-       IN PUCHAR pBssid);
-
-VOID MlmeRadioOff(
-       IN PRTMP_ADAPTER pAd);
-
-VOID MlmeRadioOn(
-       IN PRTMP_ADAPTER pAd);
-
-
-VOID BssTableInit(
-       IN BSS_TABLE *Tab);
-
-VOID BATableInit(
-       IN PRTMP_ADAPTER pAd,
-    IN BA_TABLE *Tab);
-
-ULONG BssTableSearch(
-       IN BSS_TABLE *Tab,
-       IN PUCHAR pBssid,
-       IN UCHAR Channel);
-
-ULONG BssSsidTableSearch(
-       IN BSS_TABLE *Tab,
-       IN PUCHAR    pBssid,
-       IN PUCHAR    pSsid,
-       IN UCHAR     SsidLen,
-       IN UCHAR     Channel);
-
-ULONG BssTableSearchWithSSID(
-       IN BSS_TABLE *Tab,
-       IN PUCHAR    Bssid,
-       IN PUCHAR    pSsid,
-       IN UCHAR     SsidLen,
-       IN UCHAR     Channel);
-
-VOID BssTableDeleteEntry(
-       IN OUT  PBSS_TABLE pTab,
-       IN      PUCHAR pBssid,
-       IN      UCHAR Channel);
-
-VOID BATableDeleteORIEntry(
-       IN OUT  PRTMP_ADAPTER pAd,
-       IN              BA_ORI_ENTRY    *pBAORIEntry);
-
-VOID BATableDeleteRECEntry(
-       IN OUT  PRTMP_ADAPTER pAd,
-       IN              BA_REC_ENTRY    *pBARECEntry);
-
-VOID BATableTearORIEntry(
-       IN OUT  PRTMP_ADAPTER pAd,
-       IN              UCHAR TID,
-       IN              UCHAR Wcid,
-       IN              BOOLEAN bForceDelete,
-       IN              BOOLEAN ALL);
-
-VOID BATableTearRECEntry(
-       IN OUT  PRTMP_ADAPTER pAd,
-       IN              UCHAR TID,
-       IN              UCHAR WCID,
-       IN              BOOLEAN ALL);
-
-VOID  BssEntrySet(
-       IN  PRTMP_ADAPTER   pAd,
-       OUT PBSS_ENTRY pBss,
-       IN PUCHAR pBssid,
-       IN CHAR Ssid[],
-       IN UCHAR SsidLen,
-       IN UCHAR BssType,
-       IN USHORT BeaconPeriod,
-       IN PCF_PARM CfParm,
-       IN USHORT AtimWin,
-       IN USHORT CapabilityInfo,
-       IN UCHAR SupRate[],
-       IN UCHAR SupRateLen,
-       IN UCHAR ExtRate[],
-       IN UCHAR ExtRateLen,
-       IN HT_CAPABILITY_IE *pHtCapability,
-       IN ADD_HT_INFO_IE *pAddHtInfo,  // AP might use this additional ht info IE
-       IN UCHAR                        HtCapabilityLen,
-       IN UCHAR                        AddHtInfoLen,
-       IN UCHAR                        NewExtChanOffset,
-       IN UCHAR Channel,
-       IN CHAR Rssi,
-       IN LARGE_INTEGER TimeStamp,
-       IN UCHAR CkipFlag,
-       IN PEDCA_PARM pEdcaParm,
-       IN PQOS_CAPABILITY_PARM pQosCapability,
-       IN PQBSS_LOAD_PARM pQbssLoad,
-       IN USHORT LengthVIE,
-       IN PNDIS_802_11_VARIABLE_IEs pVIE);
-
-ULONG  BssTableSetEntry(
-       IN  PRTMP_ADAPTER   pAd,
-       OUT PBSS_TABLE pTab,
-       IN PUCHAR pBssid,
-       IN CHAR Ssid[],
-       IN UCHAR SsidLen,
-       IN UCHAR BssType,
-       IN USHORT BeaconPeriod,
-       IN CF_PARM *CfParm,
-       IN USHORT AtimWin,
-       IN USHORT CapabilityInfo,
-       IN UCHAR SupRate[],
-       IN UCHAR SupRateLen,
-       IN UCHAR ExtRate[],
-       IN UCHAR ExtRateLen,
-       IN HT_CAPABILITY_IE *pHtCapability,
-       IN ADD_HT_INFO_IE *pAddHtInfo,  // AP might use this additional ht info IE
-       IN UCHAR                        HtCapabilityLen,
-       IN UCHAR                        AddHtInfoLen,
-       IN UCHAR                        NewExtChanOffset,
-       IN UCHAR Channel,
-       IN CHAR Rssi,
-       IN LARGE_INTEGER TimeStamp,
-       IN UCHAR CkipFlag,
-       IN PEDCA_PARM pEdcaParm,
-       IN PQOS_CAPABILITY_PARM pQosCapability,
-       IN PQBSS_LOAD_PARM pQbssLoad,
-       IN USHORT LengthVIE,
-       IN PNDIS_802_11_VARIABLE_IEs pVIE);
-
-VOID BATableInsertEntry(
-    IN PRTMP_ADAPTER   pAd,
-       IN USHORT Aid,
-    IN USHORT          TimeOutValue,
-       IN USHORT               StartingSeq,
-    IN UCHAR TID,
-       IN UCHAR BAWinSize,
-       IN UCHAR OriginatorStatus,
-    IN BOOLEAN IsRecipient);
-
-VOID BssTableSsidSort(
-       IN  PRTMP_ADAPTER   pAd,
-       OUT BSS_TABLE *OutTab,
-       IN  CHAR Ssid[],
-       IN  UCHAR SsidLen);
-
-VOID  BssTableSortByRssi(
-       IN OUT BSS_TABLE *OutTab);
-
-VOID BssCipherParse(
-       IN OUT  PBSS_ENTRY  pBss);
-
-NDIS_STATUS  MlmeQueueInit(
-       IN MLME_QUEUE *Queue);
-
-VOID  MlmeQueueDestroy(
-       IN MLME_QUEUE *Queue);
-
-BOOLEAN MlmeEnqueue(
-       IN PRTMP_ADAPTER pAd,
-       IN ULONG Machine,
-       IN ULONG MsgType,
-       IN ULONG MsgLen,
-       IN VOID *Msg);
-
-BOOLEAN MlmeEnqueueForRecv(
-       IN  PRTMP_ADAPTER   pAd,
-       IN ULONG Wcid,
-       IN ULONG TimeStampHigh,
-       IN ULONG TimeStampLow,
-       IN UCHAR Rssi0,
-       IN UCHAR Rssi1,
-       IN UCHAR Rssi2,
-       IN ULONG MsgLen,
-       IN PVOID Msg,
-       IN UCHAR Signal);
-
-
-BOOLEAN MlmeDequeue(
-       IN MLME_QUEUE *Queue,
-       OUT MLME_QUEUE_ELEM **Elem);
-
-VOID    MlmeRestartStateMachine(
-       IN  PRTMP_ADAPTER   pAd);
-
-BOOLEAN  MlmeQueueEmpty(
-       IN MLME_QUEUE *Queue);
-
-BOOLEAN  MlmeQueueFull(
-       IN MLME_QUEUE *Queue);
-
-BOOLEAN  MsgTypeSubst(
-       IN PRTMP_ADAPTER pAd,
-       IN PFRAME_802_11 pFrame,
-       OUT INT *Machine,
-       OUT INT *MsgType);
-
-VOID StateMachineInit(
-       IN STATE_MACHINE *Sm,
-       IN STATE_MACHINE_FUNC Trans[],
-       IN ULONG StNr,
-       IN ULONG MsgNr,
-       IN STATE_MACHINE_FUNC DefFunc,
-       IN ULONG InitState,
-       IN ULONG Base);
-
-VOID StateMachineSetAction(
-       IN STATE_MACHINE *S,
-       IN ULONG St,
-       ULONG Msg,
-       IN STATE_MACHINE_FUNC F);
-
-VOID StateMachinePerformAction(
-       IN  PRTMP_ADAPTER   pAd,
-       IN STATE_MACHINE *S,
-       IN MLME_QUEUE_ELEM *Elem);
-
-VOID Drop(
-       IN  PRTMP_ADAPTER   pAd,
-       IN MLME_QUEUE_ELEM *Elem);
-
-VOID AssocStateMachineInit(
-       IN  PRTMP_ADAPTER   pAd,
-       IN  STATE_MACHINE *Sm,
-       OUT STATE_MACHINE_FUNC Trans[]);
-
-VOID ReassocTimeout(
-       IN PVOID SystemSpecific1,
-       IN PVOID FunctionContext,
-       IN PVOID SystemSpecific2,
-       IN PVOID SystemSpecific3);
-
-VOID AssocTimeout(
-       IN PVOID SystemSpecific1,
-       IN PVOID FunctionContext,
-       IN PVOID SystemSpecific2,
-       IN PVOID SystemSpecific3);
-
-VOID DisassocTimeout(
-       IN PVOID SystemSpecific1,
-       IN PVOID FunctionContext,
-       IN PVOID SystemSpecific2,
-       IN PVOID SystemSpecific3);
-
-//----------------------------------------------
-VOID MlmeDisassocReqAction(
-       IN  PRTMP_ADAPTER   pAd,
-       IN  MLME_QUEUE_ELEM *Elem);
-
-VOID MlmeAssocReqAction(
-       IN  PRTMP_ADAPTER   pAd,
-       IN  MLME_QUEUE_ELEM *Elem);
-
-VOID MlmeReassocReqAction(
-       IN  PRTMP_ADAPTER   pAd,
-       IN  MLME_QUEUE_ELEM *Elem);
-
-VOID MlmeDisassocReqAction(
-       IN  PRTMP_ADAPTER   pAd,
-       IN  MLME_QUEUE_ELEM *Elem);
-
-VOID PeerAssocRspAction(
-       IN  PRTMP_ADAPTER   pAd,
-       IN  MLME_QUEUE_ELEM *Elem);
-
-VOID PeerReassocRspAction(
-       IN  PRTMP_ADAPTER   pAd,
-       IN  MLME_QUEUE_ELEM *Elem);
-
-VOID PeerDisassocAction(
-       IN  PRTMP_ADAPTER   pAd,
-       IN  MLME_QUEUE_ELEM *Elem);
-
-VOID DisassocTimeoutAction(
-       IN  PRTMP_ADAPTER   pAd,
-       IN  MLME_QUEUE_ELEM *Elem);
-
-VOID AssocTimeoutAction(
-       IN  PRTMP_ADAPTER   pAd,
-       IN  MLME_QUEUE_ELEM *Elem);
-
-VOID  ReassocTimeoutAction(
-       IN  PRTMP_ADAPTER   pAd,
-       IN  MLME_QUEUE_ELEM *Elem);
-
-VOID  Cls3errAction(
-       IN  PRTMP_ADAPTER   pAd,
-       IN  PUCHAR pAddr);
-
-VOID SwitchBetweenWepAndCkip(
-       IN PRTMP_ADAPTER pAd);
-
-VOID  InvalidStateWhenAssoc(
-       IN  PRTMP_ADAPTER   pAd,
-       IN  MLME_QUEUE_ELEM *Elem);
-
-VOID  InvalidStateWhenReassoc(
-       IN  PRTMP_ADAPTER   pAd,
-       IN  MLME_QUEUE_ELEM *Elem);
-
-VOID InvalidStateWhenDisassociate(
-       IN  PRTMP_ADAPTER pAd,
-       IN  MLME_QUEUE_ELEM *Elem);
-
-#ifdef RT2870
-VOID MlmeCntlConfirm(
-       IN PRTMP_ADAPTER pAd,
-       IN ULONG MsgType,
-       IN USHORT Msg);
-#endif // RT2870 //
-
-VOID  ComposePsPoll(
-       IN  PRTMP_ADAPTER   pAd);
-
-VOID  ComposeNullFrame(
-       IN  PRTMP_ADAPTER pAd);
-
-VOID  AssocPostProc(
-       IN  PRTMP_ADAPTER   pAd,
-       IN  PUCHAR pAddr2,
-       IN  USHORT CapabilityInfo,
-       IN  USHORT Aid,
-       IN  UCHAR SupRate[],
-       IN  UCHAR SupRateLen,
-       IN  UCHAR ExtRate[],
-       IN  UCHAR ExtRateLen,
-       IN PEDCA_PARM pEdcaParm,
-       IN HT_CAPABILITY_IE             *pHtCapability,
-       IN  UCHAR HtCapabilityLen,
-       IN ADD_HT_INFO_IE               *pAddHtInfo);
-
-VOID AuthStateMachineInit(
-       IN  PRTMP_ADAPTER   pAd,
-       IN PSTATE_MACHINE sm,
-       OUT STATE_MACHINE_FUNC Trans[]);
-
-VOID AuthTimeout(
-       IN PVOID SystemSpecific1,
-       IN PVOID FunctionContext,
-       IN PVOID SystemSpecific2,
-       IN PVOID SystemSpecific3);
-
-VOID MlmeAuthReqAction(
-       IN  PRTMP_ADAPTER   pAd,
-       IN  MLME_QUEUE_ELEM *Elem);
-
-VOID PeerAuthRspAtSeq2Action(
-       IN  PRTMP_ADAPTER   pAd,
-       IN  MLME_QUEUE_ELEM *Elem);
-
-VOID PeerAuthRspAtSeq4Action(
-       IN  PRTMP_ADAPTER   pAd,
-       IN  MLME_QUEUE_ELEM *Elem);
-
-VOID AuthTimeoutAction(
-       IN  PRTMP_ADAPTER   pAd,
-       IN  MLME_QUEUE_ELEM *Elem);
-
-VOID Cls2errAction(
-       IN  PRTMP_ADAPTER   pAd,
-       IN  PUCHAR pAddr);
-
-VOID MlmeDeauthReqAction(
-       IN  PRTMP_ADAPTER   pAd,
-       IN  MLME_QUEUE_ELEM *Elem);
-
-VOID InvalidStateWhenAuth(
-       IN  PRTMP_ADAPTER   pAd,
-       IN  MLME_QUEUE_ELEM *Elem);
-
-//=============================================
-
-VOID AuthRspStateMachineInit(
-       IN  PRTMP_ADAPTER   pAd,
-       IN  PSTATE_MACHINE Sm,
-       IN  STATE_MACHINE_FUNC Trans[]);
-
-VOID PeerDeauthAction(
-       IN PRTMP_ADAPTER pAd,
-       IN MLME_QUEUE_ELEM *Elem);
-
-VOID PeerAuthSimpleRspGenAndSend(
-       IN  PRTMP_ADAPTER   pAd,
-       IN  PHEADER_802_11  pHdr80211,
-       IN  USHORT Alg,
-       IN  USHORT Seq,
-       IN  USHORT Reason,
-       IN  USHORT Status);
-
-//
-// Private routines in dls.c
-//
-
-//========================================
-
-VOID SyncStateMachineInit(
-       IN  PRTMP_ADAPTER   pAd,
-       IN  STATE_MACHINE *Sm,
-       OUT STATE_MACHINE_FUNC Trans[]);
-
-VOID BeaconTimeout(
-       IN PVOID SystemSpecific1,
-       IN PVOID FunctionContext,
-       IN PVOID SystemSpecific2,
-       IN PVOID SystemSpecific3);
-
-VOID ScanTimeout(
-       IN PVOID SystemSpecific1,
-       IN PVOID FunctionContext,
-       IN PVOID SystemSpecific2,
-       IN PVOID SystemSpecific3);
-
-VOID MlmeScanReqAction(
-       IN  PRTMP_ADAPTER   pAd,
-       IN  MLME_QUEUE_ELEM *Elem);
-
-VOID InvalidStateWhenScan(
-       IN  PRTMP_ADAPTER   pAd,
-       IN  MLME_QUEUE_ELEM *Elem);
-
-VOID InvalidStateWhenJoin(
-       IN  PRTMP_ADAPTER   pAd,
-       IN  MLME_QUEUE_ELEM *Elem);
-
-VOID InvalidStateWhenStart(
-       IN  PRTMP_ADAPTER   pAd,
-       IN  MLME_QUEUE_ELEM *Elem);
-
-VOID PeerBeacon(
-       IN  PRTMP_ADAPTER   pAd,
-       IN  MLME_QUEUE_ELEM *Elem);
-
-VOID EnqueueProbeRequest(
-       IN PRTMP_ADAPTER pAd);
-
-BOOLEAN ScanRunning(
-               IN PRTMP_ADAPTER pAd);
-//=========================================
-
-VOID MlmeCntlInit(
-       IN  PRTMP_ADAPTER   pAd,
-       IN  STATE_MACHINE *S,
-       OUT STATE_MACHINE_FUNC Trans[]);
-
-VOID MlmeCntlMachinePerformAction(
-       IN  PRTMP_ADAPTER   pAd,
-       IN  STATE_MACHINE *S,
-       IN  MLME_QUEUE_ELEM *Elem);
-
-VOID CntlIdleProc(
-       IN  PRTMP_ADAPTER   pAd,
-       IN  MLME_QUEUE_ELEM *Elem);
-
-VOID CntlOidScanProc(
-       IN  PRTMP_ADAPTER pAd,
-       IN  MLME_QUEUE_ELEM *Elem);
-
-VOID CntlOidSsidProc(
-       IN  PRTMP_ADAPTER   pAd,
-       IN  MLME_QUEUE_ELEM * Elem);
-
-VOID CntlOidRTBssidProc(
-       IN  PRTMP_ADAPTER   pAd,
-       IN  MLME_QUEUE_ELEM * Elem);
-
-VOID CntlMlmeRoamingProc(
-       IN  PRTMP_ADAPTER   pAd,
-       IN  MLME_QUEUE_ELEM * Elem);
-
-VOID CntlWaitDisassocProc(
-       IN  PRTMP_ADAPTER   pAd,
-       IN  MLME_QUEUE_ELEM *Elem);
-
-VOID CntlWaitJoinProc(
-       IN  PRTMP_ADAPTER   pAd,
-       IN  MLME_QUEUE_ELEM *Elem);
-
-VOID CntlWaitReassocProc(
-       IN  PRTMP_ADAPTER   pAd,
-       IN  MLME_QUEUE_ELEM *Elem);
-
-VOID CntlWaitStartProc(
-       IN  PRTMP_ADAPTER   pAd,
-       IN  MLME_QUEUE_ELEM *Elem);
-
-VOID CntlWaitAuthProc(
-       IN  PRTMP_ADAPTER   pAd,
-       IN  MLME_QUEUE_ELEM *Elem);
-
-VOID CntlWaitAuthProc2(
-       IN  PRTMP_ADAPTER pAd,
-       IN  MLME_QUEUE_ELEM *Elem);
-
-VOID CntlWaitAssocProc(
-       IN  PRTMP_ADAPTER   pAd,
-       IN  MLME_QUEUE_ELEM *Elem);
-
-VOID LinkUp(
-       IN  PRTMP_ADAPTER   pAd,
-       IN  UCHAR BssType);
-
-VOID LinkDown(
-       IN  PRTMP_ADAPTER   pAd,
-       IN  BOOLEAN         IsReqFromAP);
-
-VOID IterateOnBssTab(
-       IN  PRTMP_ADAPTER   pAd);
-
-VOID IterateOnBssTab2(
-       IN  PRTMP_ADAPTER   pAd);;
-
-VOID JoinParmFill(
-       IN  PRTMP_ADAPTER   pAd,
-       IN  OUT MLME_JOIN_REQ_STRUCT *JoinReq,
-       IN  ULONG BssIdx);
-
-VOID AssocParmFill(
-       IN  PRTMP_ADAPTER   pAd,
-       IN OUT MLME_ASSOC_REQ_STRUCT *AssocReq,
-       IN  PUCHAR pAddr,
-       IN  USHORT CapabilityInfo,
-       IN  ULONG Timeout,
-       IN  USHORT ListenIntv);
-
-VOID ScanParmFill(
-       IN  PRTMP_ADAPTER   pAd,
-       IN  OUT MLME_SCAN_REQ_STRUCT *ScanReq,
-       IN  CHAR Ssid[],
-       IN  UCHAR SsidLen,
-       IN  UCHAR BssType,
-       IN  UCHAR ScanType);
-
-VOID DisassocParmFill(
-       IN  PRTMP_ADAPTER   pAd,
-       IN  OUT MLME_DISASSOC_REQ_STRUCT *DisassocReq,
-       IN  PUCHAR pAddr,
-       IN  USHORT Reason);
-
-VOID StartParmFill(
-       IN  PRTMP_ADAPTER   pAd,
-       IN  OUT MLME_START_REQ_STRUCT *StartReq,
-       IN  CHAR Ssid[],
-       IN  UCHAR SsidLen);
-
-VOID AuthParmFill(
-       IN  PRTMP_ADAPTER   pAd,
-       IN  OUT MLME_AUTH_REQ_STRUCT *AuthReq,
-       IN  PUCHAR pAddr,
-       IN  USHORT Alg);
-
-VOID EnqueuePsPoll(
-       IN  PRTMP_ADAPTER   pAd);
-
-VOID EnqueueBeaconFrame(
-       IN  PRTMP_ADAPTER   pAd);
-
-VOID MlmeJoinReqAction(
-       IN  PRTMP_ADAPTER   pAd,
-       IN  MLME_QUEUE_ELEM *Elem);
-
-VOID MlmeScanReqAction(
-       IN  PRTMP_ADAPTER   pAd,
-       IN  MLME_QUEUE_ELEM *Elem);
-
-VOID MlmeStartReqAction(
-       IN  PRTMP_ADAPTER   pAd,
-       IN  MLME_QUEUE_ELEM *Elem);
-
-VOID ScanTimeoutAction(
-       IN  PRTMP_ADAPTER   pAd,
-       IN  MLME_QUEUE_ELEM *Elem);
-
-VOID BeaconTimeoutAtJoinAction(
-       IN  PRTMP_ADAPTER   pAd,
-       IN  MLME_QUEUE_ELEM *Elem);
-
-VOID PeerBeaconAtScanAction(
-       IN  PRTMP_ADAPTER   pAd,
-       IN  MLME_QUEUE_ELEM *Elem);
-
-VOID PeerBeaconAtJoinAction(
-       IN  PRTMP_ADAPTER   pAd,
-       IN  MLME_QUEUE_ELEM *Elem);
-
-VOID PeerBeacon(
-       IN  PRTMP_ADAPTER   pAd,
-       IN  MLME_QUEUE_ELEM *Elem);
-
-VOID PeerProbeReqAction(
-       IN  PRTMP_ADAPTER pAd,
-       IN  MLME_QUEUE_ELEM *Elem);
-
-VOID ScanNextChannel(
-       IN  PRTMP_ADAPTER   pAd);
-
-ULONG MakeIbssBeacon(
-       IN  PRTMP_ADAPTER   pAd);
-
-VOID CCXAdjacentAPReport(
-       IN  PRTMP_ADAPTER   pAd);
-
-BOOLEAN MlmeScanReqSanity(
-       IN  PRTMP_ADAPTER   pAd,
-       IN  VOID *Msg,
-       IN  ULONG MsgLen,
-       OUT UCHAR *BssType,
-       OUT CHAR ssid[],
-       OUT UCHAR *SsidLen,
-       OUT UCHAR *ScanType);
-
-BOOLEAN PeerBeaconAndProbeRspSanity(
-       IN  PRTMP_ADAPTER   pAd,
-       IN  VOID *Msg,
-       IN  ULONG MsgLen,
-       IN  UCHAR MsgChannel,
-       OUT PUCHAR pAddr2,
-       OUT PUCHAR pBssid,
-       OUT CHAR Ssid[],
-       OUT UCHAR *pSsidLen,
-       OUT UCHAR *pBssType,
-       OUT USHORT *pBeaconPeriod,
-       OUT UCHAR *pChannel,
-       OUT UCHAR *pNewChannel,
-       OUT LARGE_INTEGER *pTimestamp,
-       OUT CF_PARM *pCfParm,
-       OUT USHORT *pAtimWin,
-       OUT USHORT *pCapabilityInfo,
-       OUT UCHAR *pErp,
-       OUT UCHAR *pDtimCount,
-       OUT UCHAR *pDtimPeriod,
-       OUT UCHAR *pBcastFlag,
-       OUT UCHAR *pMessageToMe,
-       OUT UCHAR SupRate[],
-       OUT UCHAR *pSupRateLen,
-       OUT UCHAR ExtRate[],
-       OUT UCHAR *pExtRateLen,
-       OUT     UCHAR *pCkipFlag,
-       OUT     UCHAR *pAironetCellPowerLimit,
-       OUT PEDCA_PARM       pEdcaParm,
-       OUT PQBSS_LOAD_PARM  pQbssLoad,
-       OUT PQOS_CAPABILITY_PARM pQosCapability,
-       OUT ULONG *pRalinkIe,
-       OUT UCHAR                *pHtCapabilityLen,
-       OUT UCHAR                *pPreNHtCapabilityLen,
-       OUT HT_CAPABILITY_IE *pHtCapability,
-       OUT UCHAR                *AddHtInfoLen,
-       OUT ADD_HT_INFO_IE *AddHtInfo,
-       OUT UCHAR *NewExtChannel,
-       OUT USHORT *LengthVIE,
-       OUT PNDIS_802_11_VARIABLE_IEs pVIE);
-
-BOOLEAN PeerAddBAReqActionSanity(
-    IN PRTMP_ADAPTER pAd,
-    IN VOID *pMsg,
-    IN ULONG MsgLen,
-       OUT PUCHAR pAddr2);
-
-BOOLEAN PeerAddBARspActionSanity(
-    IN PRTMP_ADAPTER pAd,
-    IN VOID *pMsg,
-    IN ULONG MsgLen);
-
-BOOLEAN PeerDelBAActionSanity(
-    IN PRTMP_ADAPTER pAd,
-    IN UCHAR Wcid,
-    IN VOID *pMsg,
-    IN ULONG MsgLen);
-
-BOOLEAN MlmeAssocReqSanity(
-       IN  PRTMP_ADAPTER   pAd,
-       IN  VOID *Msg,
-       IN  ULONG MsgLen,
-       OUT PUCHAR pApAddr,
-       OUT USHORT *CapabilityInfo,
-       OUT ULONG *Timeout,
-       OUT USHORT *ListenIntv);
-
-BOOLEAN MlmeAuthReqSanity(
-       IN  PRTMP_ADAPTER   pAd,
-       IN  VOID *Msg,
-       IN  ULONG MsgLen,
-       OUT PUCHAR pAddr,
-       OUT ULONG *Timeout,
-       OUT USHORT *Alg);
-
-BOOLEAN MlmeStartReqSanity(
-       IN  PRTMP_ADAPTER   pAd,
-       IN  VOID *Msg,
-       IN  ULONG MsgLen,
-       OUT CHAR Ssid[],
-       OUT UCHAR *Ssidlen);
-
-BOOLEAN PeerAuthSanity(
-       IN  PRTMP_ADAPTER   pAd,
-       IN  VOID *Msg,
-       IN  ULONG MsgLen,
-       OUT PUCHAR pAddr,
-       OUT USHORT *Alg,
-       OUT USHORT *Seq,
-       OUT USHORT *Status,
-       OUT CHAR ChlgText[]);
-
-BOOLEAN PeerAssocRspSanity(
-       IN  PRTMP_ADAPTER   pAd,
-    IN VOID *pMsg,
-       IN  ULONG MsgLen,
-       OUT PUCHAR pAddr2,
-       OUT USHORT *pCapabilityInfo,
-       OUT USHORT *pStatus,
-       OUT USHORT *pAid,
-       OUT UCHAR SupRate[],
-       OUT UCHAR *pSupRateLen,
-       OUT UCHAR ExtRate[],
-       OUT UCHAR *pExtRateLen,
-    OUT HT_CAPABILITY_IE               *pHtCapability,
-    OUT ADD_HT_INFO_IE         *pAddHtInfo,    // AP might use this additional ht info IE
-    OUT UCHAR                  *pHtCapabilityLen,
-    OUT UCHAR                  *pAddHtInfoLen,
-    OUT UCHAR                  *pNewExtChannelOffset,
-       OUT PEDCA_PARM pEdcaParm,
-       OUT UCHAR *pCkipFlag);
-
-BOOLEAN PeerDisassocSanity(
-       IN  PRTMP_ADAPTER   pAd,
-       IN  VOID *Msg,
-       IN  ULONG MsgLen,
-       OUT PUCHAR pAddr2,
-       OUT USHORT *Reason);
-
-BOOLEAN PeerWpaMessageSanity(
-    IN         PRTMP_ADAPTER           pAd,
-    IN         PEAPOL_PACKET           pMsg,
-    IN         ULONG                           MsgLen,
-    IN         UCHAR                           MsgType,
-    IN         MAC_TABLE_ENTRY         *pEntry);
-
-BOOLEAN PeerDeauthSanity(
-       IN  PRTMP_ADAPTER   pAd,
-       IN  VOID *Msg,
-       IN  ULONG MsgLen,
-       OUT PUCHAR pAddr2,
-       OUT USHORT *Reason);
-
-BOOLEAN PeerProbeReqSanity(
-       IN  PRTMP_ADAPTER   pAd,
-       IN  VOID *Msg,
-       IN  ULONG MsgLen,
-       OUT PUCHAR pAddr2,
-       OUT CHAR Ssid[],
-       OUT UCHAR *pSsidLen);
-
-BOOLEAN GetTimBit(
-       IN  CHAR *Ptr,
-       IN  USHORT Aid,
-       OUT UCHAR *TimLen,
-       OUT UCHAR *BcastFlag,
-       OUT UCHAR *DtimCount,
-       OUT UCHAR *DtimPeriod,
-       OUT UCHAR *MessageToMe);
-
-UCHAR ChannelSanity(
-       IN PRTMP_ADAPTER pAd,
-       IN UCHAR channel);
-
-NDIS_802_11_NETWORK_TYPE NetworkTypeInUseSanity(
-       IN PBSS_ENTRY pBss);
-
-BOOLEAN MlmeDelBAReqSanity(
-    IN PRTMP_ADAPTER pAd,
-    IN VOID *Msg,
-    IN ULONG MsgLen);
-
-BOOLEAN MlmeAddBAReqSanity(
-    IN PRTMP_ADAPTER pAd,
-    IN VOID *Msg,
-    IN ULONG MsgLen,
-    OUT PUCHAR pAddr2);
-
-ULONG MakeOutgoingFrame(
-       OUT CHAR *Buffer,
-       OUT ULONG *Length, ...);
-
-VOID  LfsrInit(
-       IN  PRTMP_ADAPTER   pAd,
-       IN  ULONG Seed);
-
-UCHAR RandomByte(
-       IN  PRTMP_ADAPTER   pAd);
-
-VOID AsicUpdateAutoFallBackTable(
-       IN      PRTMP_ADAPTER   pAd,
-       IN      PUCHAR                  pTxRate);
-
-VOID  MlmePeriodicExec(
-       IN PVOID SystemSpecific1,
-       IN PVOID FunctionContext,
-       IN PVOID SystemSpecific2,
-       IN PVOID SystemSpecific3);
-
-VOID LinkDownExec(
-       IN PVOID SystemSpecific1,
-       IN PVOID FunctionContext,
-       IN PVOID SystemSpecific2,
-       IN PVOID SystemSpecific3);
-
-VOID LinkUpExec(
-       IN PVOID SystemSpecific1,
-       IN PVOID FunctionContext,
-       IN PVOID SystemSpecific2,
-       IN PVOID SystemSpecific3);
-
-VOID STAMlmePeriodicExec(
-       PRTMP_ADAPTER pAd);
-
-VOID MlmeAutoScan(
-       IN PRTMP_ADAPTER pAd);
-
-VOID MlmeAutoReconnectLastSSID(
-       IN PRTMP_ADAPTER pAd);
-
-BOOLEAN MlmeValidateSSID(
-       IN PUCHAR pSsid,
-       IN UCHAR  SsidLen);
-
-VOID MlmeCheckForRoaming(
-       IN PRTMP_ADAPTER pAd,
-       IN ULONG    Now32);
-
-VOID MlmeCheckForFastRoaming(
-       IN  PRTMP_ADAPTER   pAd,
-       IN  ULONG           Now);
-
-VOID MlmeDynamicTxRateSwitching(
-       IN PRTMP_ADAPTER pAd);
-
-VOID MlmeSetTxRate(
-       IN PRTMP_ADAPTER                pAd,
-       IN PMAC_TABLE_ENTRY             pEntry,
-       IN PRTMP_TX_RATE_SWITCH pTxRate);
-
-VOID MlmeSelectTxRateTable(
-       IN PRTMP_ADAPTER                pAd,
-       IN PMAC_TABLE_ENTRY             pEntry,
-       IN PUCHAR                               *ppTable,
-       IN PUCHAR                               pTableSize,
-       IN PUCHAR                               pInitTxRateIdx);
-
-VOID MlmeCalculateChannelQuality(
-       IN PRTMP_ADAPTER pAd,
-       IN ULONG Now);
-
-VOID MlmeCheckPsmChange(
-       IN PRTMP_ADAPTER pAd,
-       IN ULONG    Now32);
-
-VOID MlmeSetPsmBit(
-       IN PRTMP_ADAPTER pAd,
-       IN USHORT psm);
-
-VOID MlmeSetTxPreamble(
-       IN PRTMP_ADAPTER pAd,
-       IN USHORT TxPreamble);
-
-VOID UpdateBasicRateBitmap(
-       IN      PRTMP_ADAPTER   pAd);
-
-VOID MlmeUpdateTxRates(
-       IN PRTMP_ADAPTER        pAd,
-       IN      BOOLEAN                 bLinkUp,
-       IN      UCHAR                   apidx);
-
-VOID MlmeUpdateHtTxRates(
-       IN PRTMP_ADAPTER                pAd,
-       IN      UCHAR                           apidx);
-
-VOID    RTMPCheckRates(
-       IN      PRTMP_ADAPTER   pAd,
-       IN OUT  UCHAR           SupRate[],
-       IN OUT  UCHAR           *SupRateLen);
-
-BOOLEAN RTMPCheckChannel(
-       IN PRTMP_ADAPTER pAd,
-       IN UCHAR                CentralChannel,
-       IN UCHAR                Channel);
-
-BOOLEAN        RTMPCheckHt(
-       IN              PRTMP_ADAPTER   pAd,
-       IN              UCHAR   Wcid,
-       IN OUT  HT_CAPABILITY_IE                        *pHtCapability,
-       IN OUT  ADD_HT_INFO_IE                  *pAddHtInfo);
-
-VOID StaQuickResponeForRateUpExec(
-       IN PVOID SystemSpecific1,
-       IN PVOID FunctionContext,
-       IN PVOID SystemSpecific2,
-       IN PVOID SystemSpecific3);
-
-VOID AsicBbpTuning1(
-       IN PRTMP_ADAPTER pAd);
-
-VOID AsicBbpTuning2(
-       IN PRTMP_ADAPTER pAd);
-
-VOID RTMPUpdateMlmeRate(
-       IN PRTMP_ADAPTER        pAd);
-
-CHAR RTMPMaxRssi(
-       IN PRTMP_ADAPTER        pAd,
-       IN CHAR                         Rssi0,
-       IN CHAR                         Rssi1,
-       IN CHAR                         Rssi2);
-
-VOID AsicSetRxAnt(
-       IN PRTMP_ADAPTER        pAd,
-       IN UCHAR                        Ant);
-
-VOID AsicEvaluateRxAnt(
-       IN PRTMP_ADAPTER        pAd);
-
-VOID AsicRxAntEvalTimeout(
-       IN PVOID SystemSpecific1,
-       IN PVOID FunctionContext,
-       IN PVOID SystemSpecific2,
-       IN PVOID SystemSpecific3);
-
-VOID APSDPeriodicExec(
-       IN PVOID SystemSpecific1,
-       IN PVOID FunctionContext,
-       IN PVOID SystemSpecific2,
-       IN PVOID SystemSpecific3);
-
-BOOLEAN RTMPCheckEntryEnableAutoRateSwitch(
-       IN PRTMP_ADAPTER    pAd,
-       IN PMAC_TABLE_ENTRY     pEntry);
-
-UCHAR RTMPStaFixedTxMode(
-       IN PRTMP_ADAPTER    pAd,
-       IN PMAC_TABLE_ENTRY     pEntry);
-
-VOID RTMPUpdateLegacyTxSetting(
-               UCHAR                           fixed_tx_mode,
-               PMAC_TABLE_ENTRY        pEntry);
-
-BOOLEAN RTMPAutoRateSwitchCheck(
-       IN PRTMP_ADAPTER    pAd);
-
-NDIS_STATUS MlmeInit(
-       IN  PRTMP_ADAPTER   pAd);
-
-VOID MlmeHandler(
-       IN  PRTMP_ADAPTER   pAd);
-
-VOID MlmeHalt(
-       IN  PRTMP_ADAPTER   pAd);
-
-VOID MlmeResetRalinkCounters(
-       IN  PRTMP_ADAPTER   pAd);
-
-VOID BuildChannelList(
-       IN PRTMP_ADAPTER pAd);
-
-UCHAR FirstChannel(
-       IN  PRTMP_ADAPTER   pAd);
-
-UCHAR NextChannel(
-       IN  PRTMP_ADAPTER   pAd,
-       IN  UCHAR channel);
-
-VOID ChangeToCellPowerLimit(
-       IN PRTMP_ADAPTER pAd,
-       IN UCHAR         AironetCellPowerLimit);
-
-VOID RaiseClock(
-       IN  PRTMP_ADAPTER   pAd,
-       IN  UINT32 *x);
-
-VOID LowerClock(
-       IN  PRTMP_ADAPTER   pAd,
-       IN  UINT32 *x);
-
-USHORT ShiftInBits(
-       IN  PRTMP_ADAPTER   pAd);
-
-VOID ShiftOutBits(
-       IN  PRTMP_ADAPTER   pAd,
-       IN  USHORT data,
-       IN  USHORT count);
-
-VOID EEpromCleanup(
-       IN  PRTMP_ADAPTER   pAd);
-
-VOID EWDS(
-       IN  PRTMP_ADAPTER   pAd);
-
-VOID EWEN(
-       IN  PRTMP_ADAPTER   pAd);
-
-USHORT RTMP_EEPROM_READ16(
-       IN  PRTMP_ADAPTER   pAd,
-       IN  USHORT Offset);
-
-VOID RTMP_EEPROM_WRITE16(
-       IN  PRTMP_ADAPTER   pAd,
-       IN  USHORT Offset,
-       IN  USHORT Data);
-
-//
-// Prototypes of function definition in rtmp_tkip.c
-//
-VOID    RTMPInitTkipEngine(
-       IN  PRTMP_ADAPTER   pAd,
-       IN  PUCHAR          pTKey,
-       IN  UCHAR           KeyId,
-       IN  PUCHAR          pTA,
-       IN  PUCHAR          pMICKey,
-       IN  PUCHAR          pTSC,
-       OUT PULONG          pIV16,
-       OUT PULONG          pIV32);
-
-VOID    RTMPInitMICEngine(
-       IN  PRTMP_ADAPTER   pAd,
-       IN  PUCHAR          pKey,
-       IN  PUCHAR          pDA,
-       IN  PUCHAR          pSA,
-       IN  UCHAR           UserPriority,
-       IN  PUCHAR          pMICKey);
-
-BOOLEAN RTMPTkipCompareMICValue(
-       IN  PRTMP_ADAPTER   pAd,
-       IN  PUCHAR          pSrc,
-       IN  PUCHAR          pDA,
-       IN  PUCHAR          pSA,
-       IN  PUCHAR          pMICKey,
-       IN      UCHAR                   UserPriority,
-       IN  UINT            Len);
-
-VOID    RTMPCalculateMICValue(
-       IN  PRTMP_ADAPTER   pAd,
-       IN  PNDIS_PACKET    pPacket,
-       IN  PUCHAR          pEncap,
-       IN  PCIPHER_KEY     pKey,
-       IN      UCHAR                   apidx);
-
-BOOLEAN RTMPTkipCompareMICValueWithLLC(
-       IN  PRTMP_ADAPTER   pAd,
-       IN  PUCHAR          pLLC,
-       IN  PUCHAR          pSrc,
-       IN  PUCHAR          pDA,
-       IN  PUCHAR          pSA,
-       IN  PUCHAR          pMICKey,
-       IN  UINT            Len);
-
-VOID    RTMPTkipAppendByte(
-       IN  PTKIP_KEY_INFO  pTkip,
-       IN  UCHAR           uChar);
-
-VOID    RTMPTkipAppend(
-       IN  PTKIP_KEY_INFO  pTkip,
-       IN  PUCHAR          pSrc,
-       IN  UINT            nBytes);
-
-VOID    RTMPTkipGetMIC(
-       IN  PTKIP_KEY_INFO  pTkip);
-
-BOOLEAN RTMPSoftDecryptTKIP(
-       IN PRTMP_ADAPTER pAd,
-       IN PUCHAR       pData,
-       IN ULONG        DataByteCnt,
-       IN UCHAR    UserPriority,
-       IN PCIPHER_KEY  pWpaKey);
-
-BOOLEAN RTMPSoftDecryptAES(
-       IN PRTMP_ADAPTER pAd,
-       IN PUCHAR       pData,
-       IN ULONG        DataByteCnt,
-       IN PCIPHER_KEY  pWpaKey);
-
-//
-// Prototypes of function definition in cmm_info.c
-//
-NDIS_STATUS RTMPWPARemoveKeyProc(
-       IN  PRTMP_ADAPTER   pAd,
-       IN  PVOID           pBuf);
-
-VOID    RTMPWPARemoveAllKeys(
-       IN  PRTMP_ADAPTER   pAd);
-
-BOOLEAN RTMPCheckStrPrintAble(
-    IN  CHAR *pInPutStr,
-    IN  UCHAR strLen);
-
-VOID    RTMPSetPhyMode(
-       IN  PRTMP_ADAPTER   pAd,
-       IN  ULONG phymode);
-
-VOID   RTMPUpdateHTIE(
-       IN      RT_HT_CAPABILITY        *pRtHt,
-       IN              UCHAR                           *pMcsSet,
-       OUT             HT_CAPABILITY_IE *pHtCapability,
-       OUT             ADD_HT_INFO_IE          *pAddHtInfo);
-
-VOID   RTMPAddWcidAttributeEntry(
-       IN      PRTMP_ADAPTER   pAd,
-       IN      UCHAR                   BssIdx,
-       IN      UCHAR                   KeyIdx,
-       IN      UCHAR                   CipherAlg,
-       IN      MAC_TABLE_ENTRY *pEntry);
-
-CHAR *GetEncryptType(
-       CHAR enc);
-
-CHAR *GetAuthMode(
-       CHAR auth);
-
-VOID RTMPIoctlGetSiteSurvey(
-       IN      PRTMP_ADAPTER   pAdapter,
-       IN      struct iwreq    *wrq);
-
-VOID RTMPIoctlGetMacTable(
-       IN PRTMP_ADAPTER pAd,
-       IN struct iwreq *wrq);
-
-VOID RTMPIndicateWPA2Status(
-       IN  PRTMP_ADAPTER  pAdapter);
-
-VOID   RTMPOPModeSwitching(
-       IN      PRTMP_ADAPTER   pAd);
-
-VOID    RTMPAddBSSIDCipher(
-    IN  PRTMP_ADAPTER   pAd,
-       IN      UCHAR   Aid,
-    IN  PNDIS_802_11_KEY    pKey,
-    IN  UCHAR   CipherAlg);
-
-VOID   RTMPSetHT(
-       IN      PRTMP_ADAPTER   pAd,
-       IN      OID_SET_HT_PHYMODE *pHTPhyMode);
-
-VOID   RTMPSetIndividualHT(
-       IN      PRTMP_ADAPTER           pAd,
-       IN      UCHAR                           apidx);
-
-VOID RTMPSendWirelessEvent(
-       IN      PRTMP_ADAPTER   pAd,
-       IN      USHORT                  Event_flag,
-       IN      PUCHAR                  pAddr,
-       IN  UCHAR                       BssIdx,
-       IN      CHAR                    Rssi);
-
-VOID   NICUpdateCntlCounters(
-       IN      PRTMP_ADAPTER   pAd,
-       IN      PHEADER_802_11  pHeader,
-       IN    UCHAR                     SubType,
-       IN      PRXWI_STRUC     pRxWI);
-//
-// prototype in wpa.c
-//
-BOOLEAN WpaMsgTypeSubst(
-       IN  UCHAR   EAPType,
-       OUT INT         *MsgType);
-
-VOID WpaPskStateMachineInit(
-       IN  PRTMP_ADAPTER       pAd,
-       IN  STATE_MACHINE       *S,
-       OUT STATE_MACHINE_FUNC Trans[]);
-
-VOID WpaEAPOLKeyAction(
-       IN  PRTMP_ADAPTER   pAd,
-       IN  MLME_QUEUE_ELEM *Elem);
-
-VOID    WpaPairMsg1Action(
-       IN  PRTMP_ADAPTER   pAd,
-       IN  MLME_QUEUE_ELEM *Elem);
-
-VOID    WpaPairMsg3Action(
-       IN  PRTMP_ADAPTER   pAd,
-       IN  MLME_QUEUE_ELEM *Elem);
-
-VOID    WpaGroupMsg1Action(
-       IN  PRTMP_ADAPTER   pAd,
-       IN  MLME_QUEUE_ELEM *Elem);
-
-VOID    WpaMacHeaderInit(
-       IN      PRTMP_ADAPTER   pAd,
-       IN OUT  PHEADER_802_11  pHdr80211,
-       IN      UCHAR           wep,
-       IN      PUCHAR          pAddr1);
-
-VOID    Wpa2PairMsg1Action(
-    IN  PRTMP_ADAPTER   pAd,
-    IN  MLME_QUEUE_ELEM *Elem);
-
-VOID    Wpa2PairMsg3Action(
-    IN  PRTMP_ADAPTER   pAd,
-    IN  MLME_QUEUE_ELEM *Elem);
-
-BOOLEAN ParseKeyData(
-    IN  PRTMP_ADAPTER   pAd,
-    IN  PUCHAR          pKeyData,
-    IN  UCHAR           KeyDataLen,
-       IN      UCHAR                   bPairewise);
-
-VOID    RTMPToWirelessSta(
-       IN  PRTMP_ADAPTER   pAd,
-       IN  PUCHAR          pHeader802_3,
-    IN  UINT            HdrLen,
-       IN  PUCHAR          pData,
-    IN  UINT            DataLen,
-    IN BOOLEAN                 is4wayFrame);
-
-VOID    HMAC_SHA1(
-       IN  UCHAR   *text,
-       IN  UINT    text_len,
-       IN  UCHAR   *key,
-       IN  UINT    key_len,
-       IN  UCHAR   *digest);
-
-VOID    PRF(
-       IN  UCHAR   *key,
-       IN  INT     key_len,
-       IN  UCHAR   *prefix,
-       IN  INT     prefix_len,
-       IN  UCHAR   *data,
-       IN  INT     data_len,
-       OUT UCHAR   *output,
-       IN  INT     len);
-
-VOID    CCKMPRF(
-       IN  UCHAR   *key,
-       IN  INT     key_len,
-       IN  UCHAR   *data,
-       IN  INT     data_len,
-       OUT UCHAR   *output,
-       IN  INT     len);
-
-VOID WpaCountPTK(
-       IN  PRTMP_ADAPTER   pAd,
-       IN  UCHAR   *PMK,
-       IN  UCHAR   *ANonce,
-       IN  UCHAR   *AA,
-       IN  UCHAR   *SNonce,
-       IN  UCHAR   *SA,
-       OUT UCHAR   *output,
-       IN  UINT    len);
-
-VOID    GenRandom(
-       IN  PRTMP_ADAPTER   pAd,
-       IN      UCHAR                   *macAddr,
-       OUT     UCHAR                   *random);
-
-//
-// prototype in aironet.c
-//
-VOID    AironetStateMachineInit(
-       IN  PRTMP_ADAPTER       pAd,
-       IN  STATE_MACHINE       *S,
-       OUT STATE_MACHINE_FUNC  Trans[]);
-
-VOID    AironetMsgAction(
-       IN  PRTMP_ADAPTER   pAd,
-       IN  MLME_QUEUE_ELEM *Elem);
-
-VOID    AironetRequestAction(
-       IN  PRTMP_ADAPTER   pAd,
-       IN  MLME_QUEUE_ELEM *Elem);
-
-VOID    ChannelLoadRequestAction(
-       IN  PRTMP_ADAPTER   pAd,
-       IN  UCHAR           Index);
-
-VOID    NoiseHistRequestAction(
-       IN  PRTMP_ADAPTER   pAd,
-       IN  UCHAR           Index);
-
-VOID    BeaconRequestAction(
-       IN  PRTMP_ADAPTER   pAd,
-       IN  UCHAR           Index);
-
-VOID    AironetReportAction(
-       IN  PRTMP_ADAPTER   pAd,
-       IN  MLME_QUEUE_ELEM *Elem);
-
-VOID    ChannelLoadReportAction(
-       IN  PRTMP_ADAPTER   pAd,
-       IN  UCHAR           Index);
-
-VOID    NoiseHistReportAction(
-       IN  PRTMP_ADAPTER   pAd,
-       IN  UCHAR           Index);
-
-VOID    AironetFinalReportAction(
-       IN  PRTMP_ADAPTER   pAd);
-
-VOID    BeaconReportAction(
-       IN  PRTMP_ADAPTER   pAd,
-       IN  UCHAR           Index);
-
-VOID    AironetAddBeaconReport(
-       IN  PRTMP_ADAPTER       pAd,
-       IN  ULONG               Index,
-       IN  PMLME_QUEUE_ELEM    pElem);
-
-VOID    AironetCreateBeaconReportFromBssTable(
-       IN  PRTMP_ADAPTER       pAd);
-
-VOID    DBGPRINT_TX_RING(
-       IN PRTMP_ADAPTER  pAd,
-       IN UCHAR          QueIdx);
-
-VOID DBGPRINT_RX_RING(
-       IN PRTMP_ADAPTER  pAd);
-
-CHAR    ConvertToRssi(
-       IN PRTMP_ADAPTER  pAd,
-       IN CHAR                         Rssi,
-       IN UCHAR    RssiNumber);
-
-VOID APAsicEvaluateRxAnt(
-       IN PRTMP_ADAPTER        pAd);
-
-
-VOID APAsicRxAntEvalTimeout(
-       IN PRTMP_ADAPTER        pAd);
-
-//
-// function prototype in cmm_wpa.c
-//
-BOOLEAN RTMPCheckWPAframe(
-       IN PRTMP_ADAPTER pAd,
-       IN PMAC_TABLE_ENTRY     pEntry,
-       IN PUCHAR                       pData,
-       IN ULONG                        DataByteCount,
-       IN UCHAR                        FromWhichBSSID);
-
-VOID AES_GTK_KEY_UNWRAP(
-       IN  UCHAR   *key,
-       OUT UCHAR   *plaintext,
-       IN      UCHAR   c_len,
-       IN  UCHAR   *ciphertext);
-
-BOOLEAN RTMPCheckRSNIE(
-       IN  PRTMP_ADAPTER   pAd,
-       IN  PUCHAR          pData,
-       IN  UCHAR           DataLen,
-       IN  MAC_TABLE_ENTRY *pEntry,
-       OUT     UCHAR                   *Offset);
-
-BOOLEAN RTMPParseEapolKeyData(
-       IN  PRTMP_ADAPTER   pAd,
-       IN  PUCHAR          pKeyData,
-       IN  UCHAR           KeyDataLen,
-       IN      UCHAR                   GroupKeyIndex,
-       IN      UCHAR                   MsgType,
-       IN      BOOLEAN                 bWPA2,
-       IN  MAC_TABLE_ENTRY *pEntry);
-
-VOID   ConstructEapolMsg(
-       IN      PRTMP_ADAPTER           pAd,
-    IN         UCHAR                           PeerAuthMode,
-    IN         UCHAR                           PeerWepStatus,
-    IN         UCHAR                           MyGroupKeyWepStatus,
-    IN         UCHAR                           MsgType,
-    IN UCHAR                           DefaultKeyIdx,
-    IN         UCHAR                           *ReplayCounter,
-       IN      UCHAR                           *KeyNonce,
-       IN      UCHAR                           *TxRSC,
-       IN      UCHAR                           *PTK,
-       IN      UCHAR                           *GTK,
-       IN      UCHAR                           *RSNIE,
-       IN      UCHAR                           RSNIE_Len,
-    OUT PEAPOL_PACKET       pMsg);
-
-VOID   CalculateMIC(
-       IN      PRTMP_ADAPTER   pAd,
-       IN      UCHAR                   PeerWepStatus,
-       IN      UCHAR                   *PTK,
-       OUT PEAPOL_PACKET   pMsg);
-
-NDIS_STATUS    RTMPSoftDecryptBroadCastData(
-       IN      PRTMP_ADAPTER                                   pAd,
-       IN      RX_BLK                                                  *pRxBlk,
-       IN  NDIS_802_11_ENCRYPTION_STATUS       GroupCipher,
-       IN  PCIPHER_KEY                                         pShard_key);
-
-VOID   ConstructEapolKeyData(
-       IN      PRTMP_ADAPTER   pAd,
-       IN      UCHAR                   PeerAuthMode,
-       IN      UCHAR                   PeerWepStatus,
-       IN      UCHAR                   GroupKeyWepStatus,
-       IN      UCHAR                   MsgType,
-       IN      UCHAR                   DefaultKeyIdx,
-       IN      BOOLEAN                 bWPA2Capable,
-       IN      UCHAR                   *PTK,
-       IN      UCHAR                   *GTK,
-       IN      UCHAR                   *RSNIE,
-       IN      UCHAR                   RSNIE_LEN,
-       OUT PEAPOL_PACKET   pMsg);
-
-VOID RTMPMakeRSNIE(
-       IN  PRTMP_ADAPTER   pAd,
-       IN  UINT            AuthMode,
-       IN  UINT            WepStatus,
-       IN      UCHAR                   apidx);
-
-//
-// function prototype in ap_wpa.c
-//
-
-BOOLEAN APWpaMsgTypeSubst(
-       IN UCHAR    EAPType,
-       OUT INT *MsgType) ;
-
-MAC_TABLE_ENTRY *PACInquiry(
-       IN  PRTMP_ADAPTER   pAd,
-       IN  ULONG           Wcid);
-
-BOOLEAN RTMPCheckMcast(
-       IN PRTMP_ADAPTER pAd,
-       IN PEID_STRUCT      eid_ptr,
-       IN MAC_TABLE_ENTRY  *pEntry);
-
-BOOLEAN RTMPCheckUcast(
-       IN PRTMP_ADAPTER pAd,
-       IN PEID_STRUCT      eid_ptr,
-       IN MAC_TABLE_ENTRY  *pEntry);
-
-BOOLEAN RTMPCheckAUTH(
-       IN PRTMP_ADAPTER pAd,
-       IN PEID_STRUCT      eid_ptr,
-       IN MAC_TABLE_ENTRY  *pEntry);
-
-VOID WPAStart4WayHS(
-       IN  PRTMP_ADAPTER   pAd,
-       IN  MAC_TABLE_ENTRY *pEntry,
-       IN      ULONG                   TimeInterval);
-
-VOID WPAStart2WayGroupHS(
-       IN  PRTMP_ADAPTER   pAd,
-       IN  MAC_TABLE_ENTRY *pEntry);
-
-VOID APWpaEAPPacketAction(
-       IN PRTMP_ADAPTER pAd,
-       IN MLME_QUEUE_ELEM *Elem);
-
-VOID APWpaEAPOLStartAction(
-       IN PRTMP_ADAPTER pAd,
-       IN MLME_QUEUE_ELEM *Elem);
-
-VOID APWpaEAPOLLogoffAction(
-       IN PRTMP_ADAPTER pAd,
-       IN MLME_QUEUE_ELEM *Elem);
-
-VOID APWpaEAPOLKeyAction(
-       IN PRTMP_ADAPTER pAd,
-       IN MLME_QUEUE_ELEM *Elem);
-
-VOID APWpaEAPOLASFAlertAction(
-       IN  PRTMP_ADAPTER    pAd,
-       IN  MLME_QUEUE_ELEM  *Elem);
-
-VOID HandleCounterMeasure(
-       IN PRTMP_ADAPTER pAd,
-       IN MAC_TABLE_ENTRY  *pEntry);
-
-VOID PeerPairMsg2Action(
-       IN PRTMP_ADAPTER pAd,
-       IN MAC_TABLE_ENTRY  *pEntry,
-       IN MLME_QUEUE_ELEM *Elem);
-
-VOID PeerPairMsg4Action(
-       IN PRTMP_ADAPTER pAd,
-       IN MAC_TABLE_ENTRY  *pEntry,
-       IN MLME_QUEUE_ELEM *Elem);
-
-VOID CMTimerExec(
-       IN PVOID SystemSpecific1,
-       IN PVOID FunctionContext,
-       IN PVOID SystemSpecific2,
-       IN PVOID SystemSpecific3);
-
-VOID WPARetryExec(
-       IN PVOID SystemSpecific1,
-       IN PVOID FunctionContext,
-       IN PVOID SystemSpecific2,
-       IN PVOID SystemSpecific3);
-
-VOID EnqueueStartForPSKExec(
-    IN PVOID SystemSpecific1,
-    IN PVOID FunctionContext,
-    IN PVOID SystemSpecific2,
-    IN PVOID SystemSpecific3);
-
-VOID RTMPHandleSTAKey(
-    IN PRTMP_ADAPTER    pAdapter,
-    IN MAC_TABLE_ENTRY  *pEntry,
-    IN MLME_QUEUE_ELEM  *Elem);
-
-VOID PeerGroupMsg2Action(
-       IN  PRTMP_ADAPTER    pAd,
-       IN  PMAC_TABLE_ENTRY pEntry,
-       IN  VOID             *Msg,
-       IN  UINT             MsgLen);
-
-VOID PairDisAssocAction(
-       IN  PRTMP_ADAPTER    pAd,
-       IN  PMAC_TABLE_ENTRY pEntry,
-       IN  USHORT           Reason);
-
-VOID MlmeDeAuthAction(
-       IN  PRTMP_ADAPTER    pAd,
-       IN  PMAC_TABLE_ENTRY pEntry,
-       IN  USHORT           Reason);
-
-VOID GREKEYPeriodicExec(
-       IN  PVOID   SystemSpecific1,
-       IN  PVOID   FunctionContext,
-       IN  PVOID   SystemSpecific2,
-       IN  PVOID   SystemSpecific3);
-
-VOID CountGTK(
-       IN  UCHAR   *PMK,
-       IN  UCHAR   *GNonce,
-       IN  UCHAR   *AA,
-       OUT UCHAR   *output,
-       IN  UINT    len);
-
-VOID    GetSmall(
-       IN  PVOID   pSrc1,
-       IN  PVOID   pSrc2,
-       OUT PUCHAR  out,
-       IN  ULONG   Length);
-
-VOID    GetLarge(
-       IN  PVOID   pSrc1,
-       IN  PVOID   pSrc2,
-       OUT PUCHAR  out,
-       IN  ULONG   Length);
-
-VOID APGenRandom(
-       IN PRTMP_ADAPTER pAd,
-       OUT UCHAR       *random);
-
-VOID AES_GTK_KEY_WRAP(
-       IN UCHAR *key,
-       IN UCHAR *plaintext,
-       IN UCHAR p_len,
-       OUT UCHAR *ciphertext);
-
-VOID    WpaSend(
-    IN  PRTMP_ADAPTER   pAdapter,
-    IN  PUCHAR          pPacket,
-    IN  ULONG           Len);
-
-VOID    APToWirelessSta(
-       IN  PRTMP_ADAPTER   pAd,
-       IN  MAC_TABLE_ENTRY *pEntry,
-       IN  PUCHAR          pHeader802_3,
-       IN  UINT            HdrLen,
-       IN  PUCHAR          pData,
-       IN  UINT            DataLen,
-    IN BOOLEAN                 bClearFrame);
-
-VOID RTMPAddPMKIDCache(
-       IN  PRTMP_ADAPTER               pAd,
-       IN      INT                                             apidx,
-       IN      PUCHAR                          pAddr,
-       IN      UCHAR                                   *PMKID,
-       IN      UCHAR                                   *PMK);
-
-INT RTMPSearchPMKIDCache(
-       IN  PRTMP_ADAPTER   pAd,
-       IN      INT                             apidx,
-       IN      PUCHAR          pAddr);
-
-VOID RTMPDeletePMKIDCache(
-       IN  PRTMP_ADAPTER   pAd,
-       IN      INT                             apidx,
-       IN  INT                         idx);
-
-VOID RTMPMaintainPMKIDCache(
-       IN  PRTMP_ADAPTER   pAd);
-
-VOID   RTMPSendTriggerFrame(
-       IN      PRTMP_ADAPTER   pAd,
-       IN      PVOID                   pBuffer,
-       IN      ULONG                   Length,
-       IN  UCHAR           TxRate,
-       IN      BOOLEAN                 bQosNull);
-
-#ifdef RT30xx
-VOID RTMPFilterCalibration(
-       IN PRTMP_ADAPTER pAd);
-#endif // RT30xx //
-
-/* timeout -- ms */
-VOID RTMP_SetPeriodicTimer(
-       IN      NDIS_MINIPORT_TIMER *pTimer,
-       IN      unsigned long timeout);
-
-VOID RTMP_OS_Init_Timer(
-       IN      PRTMP_ADAPTER pAd,
-       IN      NDIS_MINIPORT_TIMER *pTimer,
-       IN      TIMER_FUNCTION function,
-       IN      PVOID data);
-
-VOID RTMP_OS_Add_Timer(
-       IN      NDIS_MINIPORT_TIMER     *pTimer,
-       IN      unsigned long timeout);
-
-VOID RTMP_OS_Mod_Timer(
-       IN      NDIS_MINIPORT_TIMER     *pTimer,
-       IN      unsigned long timeout);
-
-
-VOID RTMP_OS_Del_Timer(
-       IN      NDIS_MINIPORT_TIMER     *pTimer,
-       OUT     BOOLEAN                          *pCancelled);
-
-
-VOID RTMP_OS_Release_Packet(
-       IN      PRTMP_ADAPTER pAd,
-       IN      PQUEUE_ENTRY  pEntry);
-
-VOID RTMPusecDelay(
-       IN      ULONG   usec);
-
-NDIS_STATUS os_alloc_mem(
-       IN      PRTMP_ADAPTER pAd,
-       OUT     PUCHAR *mem,
-       IN      ULONG  size);
-
-NDIS_STATUS os_free_mem(
-       IN      PRTMP_ADAPTER pAd,
-       IN      PUCHAR mem);
-
-
-void RTMP_AllocateSharedMemory(
-       IN      PRTMP_ADAPTER pAd,
-       IN      ULONG   Length,
-       IN      BOOLEAN Cached,
-       OUT     PVOID   *VirtualAddress,
-       OUT     PNDIS_PHYSICAL_ADDRESS PhysicalAddress);
-
-VOID RTMPFreeTxRxRingMemory(
-    IN  PRTMP_ADAPTER   pAd);
-
-NDIS_STATUS AdapterBlockAllocateMemory(
-       IN PVOID        handle,
-       OUT     PVOID   *ppAd);
-
-void RTMP_AllocateTxDescMemory(
-       IN      PRTMP_ADAPTER pAd,
-       IN      UINT    Index,
-       IN      ULONG   Length,
-       IN      BOOLEAN Cached,
-       OUT     PVOID   *VirtualAddress,
-       OUT     PNDIS_PHYSICAL_ADDRESS PhysicalAddress);
-
-void RTMP_AllocateFirstTxBuffer(
-       IN      PRTMP_ADAPTER pAd,
-       IN      UINT    Index,
-       IN      ULONG   Length,
-       IN      BOOLEAN Cached,
-       OUT     PVOID   *VirtualAddress,
-       OUT     PNDIS_PHYSICAL_ADDRESS PhysicalAddress);
-
-void RTMP_AllocateMgmtDescMemory(
-       IN      PRTMP_ADAPTER pAd,
-       IN      ULONG   Length,
-       IN      BOOLEAN Cached,
-       OUT     PVOID   *VirtualAddress,
-       OUT     PNDIS_PHYSICAL_ADDRESS PhysicalAddress);
-
-void RTMP_AllocateRxDescMemory(
-       IN      PRTMP_ADAPTER pAd,
-       IN      ULONG   Length,
-       IN      BOOLEAN Cached,
-       OUT     PVOID   *VirtualAddress,
-       OUT     PNDIS_PHYSICAL_ADDRESS PhysicalAddress);
-
-PNDIS_PACKET RTMP_AllocateRxPacketBuffer(
-       IN      PRTMP_ADAPTER pAd,
-       IN      ULONG   Length,
-       IN      BOOLEAN Cached,
-       OUT     PVOID   *VirtualAddress,
-       OUT     PNDIS_PHYSICAL_ADDRESS PhysicalAddress);
-
-PNDIS_PACKET RTMP_AllocateTxPacketBuffer(
-       IN      PRTMP_ADAPTER pAd,
-       IN      ULONG   Length,
-       IN      BOOLEAN Cached,
-       OUT     PVOID   *VirtualAddress);
-
-PNDIS_PACKET RTMP_AllocateFragPacketBuffer(
-       IN      PRTMP_ADAPTER pAd,
-       IN      ULONG   Length);
-
-void RTMP_QueryPacketInfo(
-       IN  PNDIS_PACKET pPacket,
-       OUT PACKET_INFO  *pPacketInfo,
-       OUT PUCHAR               *pSrcBufVA,
-       OUT     UINT             *pSrcBufLen);
-
-void RTMP_QueryNextPacketInfo(
-       IN  PNDIS_PACKET *ppPacket,
-       OUT PACKET_INFO  *pPacketInfo,
-       OUT PUCHAR               *pSrcBufVA,
-       OUT     UINT             *pSrcBufLen);
-
-
-BOOLEAN RTMP_FillTxBlkInfo(
-       IN RTMP_ADAPTER *pAd,
-       IN TX_BLK *pTxBlk);
-
-
-PRTMP_SCATTER_GATHER_LIST
-rt_get_sg_list_from_packet(PNDIS_PACKET pPacket, RTMP_SCATTER_GATHER_LIST *sg);
-
-
- void announce_802_3_packet(
-       IN      PRTMP_ADAPTER   pAd,
-       IN      PNDIS_PACKET    pPacket);
-
-
-UINT BA_Reorder_AMSDU_Annnounce(
-       IN      PRTMP_ADAPTER   pAd,
-       IN      PNDIS_PACKET    pPacket);
-
-
-UINT Handle_AMSDU_Packet(
-       IN      PRTMP_ADAPTER   pAd,
-       IN      PUCHAR                  pData,
-       IN      ULONG                   DataSize,
-       IN  UCHAR                       FromWhichBSSID);
-
-
-void convert_802_11_to_802_3_packet(
-       IN      PRTMP_ADAPTER   pAd,
-       IN      PNDIS_PACKET    pPacket,
-       IN      PUCHAR                  p8023hdr,
-       IN      PUCHAR                  pData,
-       IN      ULONG                   DataSize,
-       IN  UCHAR                       FromWhichBSSID);
-
-
-PNET_DEV get_netdev_from_bssid(
-       IN      PRTMP_ADAPTER   pAd,
-       IN      UCHAR                   FromWhichBSSID);
-
-
-PNDIS_PACKET duplicate_pkt(
-       IN      PRTMP_ADAPTER   pAd,
-       IN      PUCHAR                  pHeader802_3,
-    IN  UINT            HdrLen,
-       IN      PUCHAR                  pData,
-       IN      ULONG                   DataSize,
-       IN      UCHAR                   FromWhichBSSID);
-
-
-PNDIS_PACKET duplicate_pkt_with_TKIP_MIC(
-       IN      PRTMP_ADAPTER   pAd,
-       IN      PNDIS_PACKET    pOldPkt);
-
-PNDIS_PACKET duplicate_pkt_with_VLAN(
-       IN      PRTMP_ADAPTER   pAd,
-       IN      PUCHAR                  pHeader802_3,
-    IN  UINT            HdrLen,
-       IN      PUCHAR                  pData,
-       IN      ULONG                   DataSize,
-       IN      UCHAR                   FromWhichBSSID);
-
-PNDIS_PACKET duplicate_pkt_with_WPI(
-       IN      PRTMP_ADAPTER   pAd,
-       IN      PNDIS_PACKET    pPacket,
-       IN      UINT32                  ext_head_len,
-       IN      UINT32                  ext_tail_len);
-
-UCHAR VLAN_8023_Header_Copy(
-       IN      PRTMP_ADAPTER   pAd,
-       IN      PUCHAR                  pHeader802_3,
-       IN      UINT            HdrLen,
-       OUT PUCHAR                      pData,
-       IN      UCHAR                   FromWhichBSSID);
-
-void ba_flush_reordering_timeout_mpdus(
-       IN PRTMP_ADAPTER        pAd,
-       IN PBA_REC_ENTRY        pBAEntry,
-       IN ULONG                        Now32);
-
-
-VOID BAOriSessionSetUp(
-                       IN PRTMP_ADAPTER    pAd,
-                       IN MAC_TABLE_ENTRY      *pEntry,
-                       IN UCHAR                        TID,
-                       IN USHORT                       TimeOut,
-                       IN ULONG                        DelayTime,
-                       IN BOOLEAN              isForced);
-
-VOID BASessionTearDownALL(
-       IN OUT  PRTMP_ADAPTER pAd,
-       IN              UCHAR Wcid);
-
-BOOLEAN OS_Need_Clone_Packet(void);
-
-
-VOID build_tx_packet(
-       IN      PRTMP_ADAPTER   pAd,
-       IN      PNDIS_PACKET    pPacket,
-       IN      PUCHAR  pFrame,
-       IN      ULONG   FrameLen);
-
-
-VOID BAOriSessionTearDown(
-       IN OUT  PRTMP_ADAPTER   pAd,
-       IN              UCHAR                   Wcid,
-       IN              UCHAR                   TID,
-       IN              BOOLEAN                 bPassive,
-       IN              BOOLEAN                 bForceSend);
-
-VOID BARecSessionTearDown(
-       IN OUT  PRTMP_ADAPTER   pAd,
-       IN              UCHAR                   Wcid,
-       IN              UCHAR                   TID,
-       IN              BOOLEAN                 bPassive);
-
-BOOLEAN ba_reordering_resource_init(PRTMP_ADAPTER pAd, int num);
-void ba_reordering_resource_release(PRTMP_ADAPTER pAd);
-
-ULONG AutoChBssInsertEntry(
-       IN PRTMP_ADAPTER pAd,
-       IN PUCHAR pBssid,
-       IN CHAR Ssid[],
-       IN UCHAR SsidLen,
-       IN UCHAR ChannelNo,
-       IN CHAR Rssi);
-
-void AutoChBssTableInit(
-       IN PRTMP_ADAPTER pAd);
-
-void ChannelInfoInit(
-       IN PRTMP_ADAPTER pAd);
-
-void AutoChBssTableDestroy(
-       IN PRTMP_ADAPTER pAd);
-
-void ChannelInfoDestroy(
-       IN PRTMP_ADAPTER pAd);
-
-UCHAR New_ApAutoSelectChannel(
-       IN PRTMP_ADAPTER pAd);
-
-BOOLEAN rtstrmactohex(
-       IN char *s1,
-       IN char *s2);
-
-BOOLEAN rtstrcasecmp(
-       IN char *s1,
-       IN char *s2);
-
-char *rtstrstruncasecmp(
-       IN char *s1,
-       IN char *s2);
-
-char    *rtstrstr(
-       IN      const char * s1,
-       IN      const char * s2);
-
-char *rstrtok(
-       IN char * s,
-       IN const char * ct);
-
-int rtinet_aton(
-       const char *cp,
-       unsigned int *addr);
-
-////////// common ioctl functions //////////
-INT Set_DriverVersion_Proc(
-       IN      PRTMP_ADAPTER   pAd,
-       IN      PUCHAR                  arg);
-
-INT Set_CountryRegion_Proc(
-       IN      PRTMP_ADAPTER   pAd,
-       IN      PUCHAR                  arg);
-
-INT Set_CountryRegionABand_Proc(
-       IN      PRTMP_ADAPTER   pAd,
-       IN      PUCHAR                  arg);
-
-INT Set_WirelessMode_Proc(
-       IN      PRTMP_ADAPTER   pAd,
-       IN      PUCHAR                  arg);
-
-INT Set_Channel_Proc(
-       IN      PRTMP_ADAPTER   pAd,
-       IN      PUCHAR                  arg);
-
-INT    Set_ShortSlot_Proc(
-       IN      PRTMP_ADAPTER   pAd,
-       IN      PUCHAR                  arg);
-
-INT    Set_TxPower_Proc(
-       IN      PRTMP_ADAPTER   pAd,
-       IN      PUCHAR                  arg);
-
-INT Set_BGProtection_Proc(
-       IN  PRTMP_ADAPTER               pAd,
-       IN  PUCHAR                      arg);
-
-INT Set_TxPreamble_Proc(
-       IN  PRTMP_ADAPTER               pAd,
-       IN  PUCHAR                      arg);
-
-INT Set_RTSThreshold_Proc(
-       IN  PRTMP_ADAPTER               pAd,
-       IN  PUCHAR                      arg);
-
-INT Set_FragThreshold_Proc(
-       IN  PRTMP_ADAPTER               pAd,
-       IN  PUCHAR                      arg);
-
-INT Set_TxBurst_Proc(
-       IN  PRTMP_ADAPTER               pAd,
-       IN  PUCHAR                      arg);
-
-#ifdef AGGREGATION_SUPPORT
-INT    Set_PktAggregate_Proc(
-       IN  PRTMP_ADAPTER               pAd,
-       IN  PUCHAR                      arg);
-#endif
-
-INT    Set_IEEE80211H_Proc(
-       IN      PRTMP_ADAPTER   pAd,
-       IN      PUCHAR                  arg);
-
-#ifdef DBG
-INT    Set_Debug_Proc(
-       IN      PRTMP_ADAPTER   pAd,
-       IN      PUCHAR                  arg);
-#endif
-
-INT    Show_DescInfo_Proc(
-       IN      PRTMP_ADAPTER   pAd,
-       IN      PUCHAR                  arg);
-
-INT    Set_ResetStatCounter_Proc(
-       IN      PRTMP_ADAPTER   pAd,
-       IN      PUCHAR                  arg);
-
-INT    Set_BASetup_Proc(
-       IN      PRTMP_ADAPTER   pAd,
-       IN      PUCHAR                  arg);
-
-INT    Set_BADecline_Proc(
-       IN      PRTMP_ADAPTER   pAd,
-       IN      PUCHAR                  arg);
-
-INT    Set_BAOriTearDown_Proc(
-       IN      PRTMP_ADAPTER   pAd,
-       IN      PUCHAR                  arg);
-
-INT    Set_BARecTearDown_Proc(
-       IN      PRTMP_ADAPTER   pAd,
-       IN      PUCHAR                  arg);
-
-INT    Set_HtBw_Proc(
-       IN      PRTMP_ADAPTER   pAd,
-       IN      PUCHAR                  arg);
-
-INT    Set_HtMcs_Proc(
-       IN      PRTMP_ADAPTER   pAd,
-       IN      PUCHAR                  arg);
-
-INT    Set_HtGi_Proc(
-       IN      PRTMP_ADAPTER   pAd,
-       IN      PUCHAR                  arg);
-
-INT    Set_HtOpMode_Proc(
-       IN      PRTMP_ADAPTER   pAd,
-       IN      PUCHAR                  arg);
-
-INT    Set_HtStbc_Proc(
-       IN      PRTMP_ADAPTER   pAd,
-       IN      PUCHAR                  arg);
-
-INT    Set_HtHtc_Proc(
-       IN      PRTMP_ADAPTER   pAd,
-       IN      PUCHAR                  arg);
-
-INT    Set_HtExtcha_Proc(
-       IN      PRTMP_ADAPTER   pAd,
-       IN      PUCHAR                  arg);
-
-INT    Set_HtMpduDensity_Proc(
-       IN      PRTMP_ADAPTER   pAd,
-       IN      PUCHAR                  arg);
-
-INT    Set_HtBaWinSize_Proc(
-       IN      PRTMP_ADAPTER   pAd,
-       IN      PUCHAR                  arg);
-
-INT    Set_HtRdg_Proc(
-       IN      PRTMP_ADAPTER   pAd,
-       IN      PUCHAR                  arg);
-
-INT    Set_HtLinkAdapt_Proc(
-       IN      PRTMP_ADAPTER   pAd,
-       IN      PUCHAR                  arg);
-
-INT    Set_HtAmsdu_Proc(
-       IN      PRTMP_ADAPTER   pAd,
-       IN      PUCHAR                  arg);
-
-INT    Set_HtAutoBa_Proc(
-       IN      PRTMP_ADAPTER   pAd,
-       IN      PUCHAR                  arg);
-
-INT    Set_HtProtect_Proc(
-       IN      PRTMP_ADAPTER   pAd,
-       IN      PUCHAR                  arg);
-
-INT    Set_HtMimoPs_Proc(
-       IN      PRTMP_ADAPTER   pAd,
-       IN      PUCHAR                  arg);
-
-
-INT    Set_ForceShortGI_Proc(
-       IN      PRTMP_ADAPTER   pAd,
-       IN      PUCHAR                  arg);
-
-INT    Set_ForceGF_Proc(
-       IN      PRTMP_ADAPTER   pAd,
-       IN      PUCHAR                  arg);
-
-INT    SetCommonHT(
-       IN      PRTMP_ADAPTER   pAd);
-
-INT    Set_SendPSMPAction_Proc(
-       IN      PRTMP_ADAPTER   pAd,
-       IN      PUCHAR                  arg);
-
-INT    Set_HtMIMOPSmode_Proc(
-       IN      PRTMP_ADAPTER   pAd,
-       IN      PUCHAR                  arg);
-
-
-INT    Set_HtTxBASize_Proc(
-       IN      PRTMP_ADAPTER   pAd,
-       IN      PUCHAR                  arg);
-
-//Dls ,        kathy
-VOID RTMPSendDLSTearDownFrame(
-       IN      PRTMP_ADAPTER   pAd,
-       IN      PUCHAR                  pDA);
-
-//Block ACK
-VOID QueryBATABLE(
-       IN  PRTMP_ADAPTER pAd,
-       OUT PQUERYBA_TABLE pBAT);
-
-INT        WpaCheckEapCode(
-       IN  PRTMP_ADAPTER       pAd,
-       IN  PUCHAR                              pFrame,
-       IN  USHORT                              FrameLen,
-       IN  USHORT                              OffSet);
-
-VOID    WpaSendMicFailureToWpaSupplicant(
-    IN  PRTMP_ADAPTER       pAd,
-    IN  BOOLEAN             bUnicast);
-
-VOID    SendAssocIEsToWpaSupplicant(
-    IN  PRTMP_ADAPTER       pAd);
-
-int wext_notify_event_assoc(
-       IN  RTMP_ADAPTER *pAd);
-
-VOID Handle_BSS_Width_Trigger_Events(
-       IN PRTMP_ADAPTER pAd);
-
-void build_ext_channel_switch_ie(
-       IN PRTMP_ADAPTER pAd,
-       IN HT_EXT_CHANNEL_SWITCH_ANNOUNCEMENT_IE *pIE);
-
-BOOLEAN APRxDoneInterruptHandle(
-       IN      PRTMP_ADAPTER   pAd);
-
-BOOLEAN STARxDoneInterruptHandle(
-       IN      PRTMP_ADAPTER   pAd,
-       IN      BOOLEAN                 argc);
-
-// AMPDU packet indication
-VOID Indicate_AMPDU_Packet(
-       IN      PRTMP_ADAPTER   pAd,
-       IN      RX_BLK                  *pRxBlk,
-       IN      UCHAR                   FromWhichBSSID);
-
-// AMSDU packet indication
-VOID Indicate_AMSDU_Packet(
-       IN      PRTMP_ADAPTER   pAd,
-       IN      RX_BLK                  *pRxBlk,
-       IN      UCHAR                   FromWhichBSSID);
-
-// Normal legacy Rx packet indication
-VOID Indicate_Legacy_Packet(
-       IN      PRTMP_ADAPTER   pAd,
-       IN      RX_BLK                  *pRxBlk,
-       IN      UCHAR                   FromWhichBSSID);
-
-VOID Indicate_EAPOL_Packet(
-       IN      PRTMP_ADAPTER   pAd,
-       IN      RX_BLK                  *pRxBlk,
-       IN      UCHAR                   FromWhichBSSID);
-
-void  update_os_packet_info(
-       IN      PRTMP_ADAPTER   pAd,
-       IN      RX_BLK                  *pRxBlk,
-       IN      UCHAR                   FromWhichBSSID);
-
-void wlan_802_11_to_802_3_packet(
-       IN      PRTMP_ADAPTER   pAd,
-       IN      RX_BLK                  *pRxBlk,
-       IN      PUCHAR                  pHeader802_3,
-       IN  UCHAR                       FromWhichBSSID);
-
-UINT deaggregate_AMSDU_announce(
-       IN      PRTMP_ADAPTER   pAd,
-       PNDIS_PACKET            pPacket,
-       IN      PUCHAR                  pData,
-       IN      ULONG                   DataSize);
-
-// remove LLC and get 802_3 Header
-#define  RTMP_802_11_REMOVE_LLC_AND_CONVERT_TO_802_3(_pRxBlk, _pHeader802_3)   \
-{                                                                                                                                                              \
-       PUCHAR _pRemovedLLCSNAP = NULL, _pDA, _pSA;                                 \
-                                                                                                                                                               \
-       if (RX_BLK_TEST_FLAG(_pRxBlk, fRX_MESH))                                    \
-       {                                                                           \
-               _pDA = _pRxBlk->pHeader->Addr3;                                         \
-               _pSA = (PUCHAR)_pRxBlk->pHeader + sizeof(HEADER_802_11);                \
-       }                                                                           \
-       else                                                                        \
-       {                                                                           \
-               if (RX_BLK_TEST_FLAG(_pRxBlk, fRX_INFRA))                               \
-               {                                                                       \
-                       _pDA = _pRxBlk->pHeader->Addr1;                                     \
-               if (RX_BLK_TEST_FLAG(_pRxBlk, fRX_DLS))                                                                 \
-                       _pSA = _pRxBlk->pHeader->Addr2;                                                                         \
-               else                                                                                                                                    \
-                       _pSA = _pRxBlk->pHeader->Addr3;                                     \
-               }                                                                       \
-               else                                                                    \
-               {                                                                       \
-                       _pDA = _pRxBlk->pHeader->Addr1;                                     \
-                       _pSA = _pRxBlk->pHeader->Addr2;                                     \
-               }                                                                       \
-       }                                                                           \
-                                                                                                                                                               \
-       CONVERT_TO_802_3(_pHeader802_3, _pDA, _pSA, _pRxBlk->pData,                             \
-               _pRxBlk->DataSize, _pRemovedLLCSNAP);                                   \
-}
-
-BOOLEAN APFowardWirelessStaToWirelessSta(
-       IN      PRTMP_ADAPTER   pAd,
-       IN      PNDIS_PACKET    pPacket,
-       IN      ULONG                   FromWhichBSSID);
-
-VOID Announce_or_Forward_802_3_Packet(
-       IN      PRTMP_ADAPTER   pAd,
-       IN      PNDIS_PACKET    pPacket,
-       IN      UCHAR                   FromWhichBSSID);
-
-VOID Sta_Announce_or_Forward_802_3_Packet(
-       IN      PRTMP_ADAPTER   pAd,
-       IN      PNDIS_PACKET    pPacket,
-       IN      UCHAR                   FromWhichBSSID);
-
-#define ANNOUNCE_OR_FORWARD_802_3_PACKET(_pAd, _pPacket, _FromWhichBSS)\
-                       Sta_Announce_or_Forward_802_3_Packet(_pAd, _pPacket, _FromWhichBSS);
-                       //announce_802_3_packet(_pAd, _pPacket);
-
-PNDIS_PACKET DuplicatePacket(
-       IN      PRTMP_ADAPTER   pAd,
-       IN      PNDIS_PACKET    pPacket,
-       IN      UCHAR                   FromWhichBSSID);
-
-
-PNDIS_PACKET ClonePacket(
-       IN      PRTMP_ADAPTER   pAd,
-       IN      PNDIS_PACKET    pPacket,
-       IN      PUCHAR                  pData,
-       IN      ULONG                   DataSize);
-
-
-// Normal, AMPDU or AMSDU
-VOID CmmRxnonRalinkFrameIndicate(
-       IN      PRTMP_ADAPTER   pAd,
-       IN      RX_BLK                  *pRxBlk,
-       IN      UCHAR                   FromWhichBSSID);
-
-VOID CmmRxRalinkFrameIndicate(
-       IN      PRTMP_ADAPTER   pAd,
-       IN      MAC_TABLE_ENTRY *pEntry,
-       IN      RX_BLK                  *pRxBlk,
-       IN      UCHAR                   FromWhichBSSID);
-
-VOID Update_Rssi_Sample(
-       IN PRTMP_ADAPTER        pAd,
-       IN RSSI_SAMPLE          *pRssi,
-       IN PRXWI_STRUC          pRxWI);
-
-PNDIS_PACKET GetPacketFromRxRing(
-       IN              PRTMP_ADAPTER   pAd,
-       OUT             PRT28XX_RXD_STRUC               pSaveRxD,
-       OUT             BOOLEAN                 *pbReschedule,
-       IN OUT  UINT32                  *pRxPending);
-
-PNDIS_PACKET RTMPDeFragmentDataFrame(
-       IN      PRTMP_ADAPTER   pAd,
-       IN      RX_BLK                  *pRxBlk);
-
-////////////////////////////////////////
-enum {
-       DIDmsg_lnxind_wlansniffrm               = 0x00000044,
-       DIDmsg_lnxind_wlansniffrm_hosttime      = 0x00010044,
-       DIDmsg_lnxind_wlansniffrm_mactime       = 0x00020044,
-       DIDmsg_lnxind_wlansniffrm_channel       = 0x00030044,
-       DIDmsg_lnxind_wlansniffrm_rssi          = 0x00040044,
-       DIDmsg_lnxind_wlansniffrm_sq            = 0x00050044,
-       DIDmsg_lnxind_wlansniffrm_signal        = 0x00060044,
-       DIDmsg_lnxind_wlansniffrm_noise         = 0x00070044,
-       DIDmsg_lnxind_wlansniffrm_rate          = 0x00080044,
-       DIDmsg_lnxind_wlansniffrm_istx          = 0x00090044,
-       DIDmsg_lnxind_wlansniffrm_frmlen        = 0x000A0044
-};
-enum {
-       P80211ENUM_msgitem_status_no_value      = 0x00
-};
-enum {
-       P80211ENUM_truth_false                  = 0x00,
-       P80211ENUM_truth_true                   = 0x01
-};
-
-/* Definition from madwifi */
-typedef struct {
-        UINT32 did;
-        UINT16 status;
-        UINT16 len;
-        UINT32 data;
-} p80211item_uint32_t;
-
-typedef struct {
-        UINT32 msgcode;
-        UINT32 msglen;
-#define WLAN_DEVNAMELEN_MAX 16
-        UINT8 devname[WLAN_DEVNAMELEN_MAX];
-        p80211item_uint32_t hosttime;
-        p80211item_uint32_t mactime;
-        p80211item_uint32_t channel;
-        p80211item_uint32_t rssi;
-        p80211item_uint32_t sq;
-        p80211item_uint32_t signal;
-        p80211item_uint32_t noise;
-        p80211item_uint32_t rate;
-        p80211item_uint32_t istx;
-        p80211item_uint32_t frmlen;
-} wlan_ng_prism2_header;
-
-/* The radio capture header precedes the 802.11 header. */
-typedef struct PACKED _ieee80211_radiotap_header {
-    UINT8      it_version;     /* Version 0. Only increases
-                                * for drastic changes,
-                                * introduction of compatible
-                                * new fields does not count.
-                                */
-    UINT8      it_pad;
-    UINT16     it_len;         /* length of the whole
-                                * header in bytes, including
-                                * it_version, it_pad,
-                                * it_len, and data fields.
-                                */
-    UINT32   it_present;       /* A bitmap telling which
-                                        * fields are present. Set bit 31
-                                        * (0x80000000) to extend the
-                                        * bitmap by another 32 bits.
-                                        * Additional extensions are made
-                                        * by setting bit 31.
-                                        */
-}ieee80211_radiotap_header ;
-
-enum ieee80211_radiotap_type {
-    IEEE80211_RADIOTAP_TSFT = 0,
-    IEEE80211_RADIOTAP_FLAGS = 1,
-    IEEE80211_RADIOTAP_RATE = 2,
-    IEEE80211_RADIOTAP_CHANNEL = 3,
-    IEEE80211_RADIOTAP_FHSS = 4,
-    IEEE80211_RADIOTAP_DBM_ANTSIGNAL = 5,
-    IEEE80211_RADIOTAP_DBM_ANTNOISE = 6,
-    IEEE80211_RADIOTAP_LOCK_QUALITY = 7,
-    IEEE80211_RADIOTAP_TX_ATTENUATION = 8,
-    IEEE80211_RADIOTAP_DB_TX_ATTENUATION = 9,
-    IEEE80211_RADIOTAP_DBM_TX_POWER = 10,
-    IEEE80211_RADIOTAP_ANTENNA = 11,
-    IEEE80211_RADIOTAP_DB_ANTSIGNAL = 12,
-    IEEE80211_RADIOTAP_DB_ANTNOISE = 13
-};
-
-#define WLAN_RADIOTAP_PRESENT (                        \
-       (1 << IEEE80211_RADIOTAP_TSFT)  |       \
-       (1 << IEEE80211_RADIOTAP_FLAGS) |       \
-       (1 << IEEE80211_RADIOTAP_RATE)  |       \
-        0)
-
-typedef struct _wlan_radiotap_header {
-       ieee80211_radiotap_header wt_ihdr;
-       INT64 wt_tsft;
-       UINT8 wt_flags;
-       UINT8 wt_rate;
-} wlan_radiotap_header;
-/* Definition from madwifi */
-
-void send_monitor_packets(
-       IN      PRTMP_ADAPTER   pAd,
-       IN      RX_BLK                  *pRxBlk);
-
-#if WIRELESS_EXT >= 12
-// This function will be called when query /proc
-struct iw_statistics *rt28xx_get_wireless_stats(
-    IN struct net_device *net_dev);
-#endif
-
-VOID    RTMPSetDesiredRates(
-    IN  PRTMP_ADAPTER   pAdapter,
-    IN  LONG            Rates);
-
-INT    Set_FixedTxMode_Proc(
-       IN      PRTMP_ADAPTER   pAd,
-       IN      PUCHAR                  arg);
-
-static inline char* GetPhyMode(
-       int Mode)
-{
-       switch(Mode)
-       {
-               case MODE_CCK:
-                       return "CCK";
-
-               case MODE_OFDM:
-                       return "OFDM";
-               case MODE_HTMIX:
-                       return "HTMIX";
-
-               case MODE_HTGREENFIELD:
-                       return "GREEN";
-               default:
-                       return "N/A";
-       }
-}
-
-
-static inline char* GetBW(
-       int BW)
-{
-       switch(BW)
-       {
-               case BW_10:
-                       return "10M";
-
-               case BW_20:
-                       return "20M";
-               case BW_40:
-                       return "40M";
-               default:
-                       return "N/A";
-       }
-}
-
-
-VOID RT28xxThreadTerminate(
-       IN RTMP_ADAPTER *pAd);
-
-BOOLEAN RT28XXChipsetCheck(
-       IN void *_dev_p);
-
-BOOLEAN RT28XXNetDevInit(
-       IN void                                 *_dev_p,
-       IN struct  net_device   *net_dev,
-       IN RTMP_ADAPTER                 *pAd);
-
-BOOLEAN RT28XXProbePostConfig(
-       IN void                                 *_dev_p,
-       IN RTMP_ADAPTER                 *pAd,
-       IN INT32                                argc);
-
-VOID RT28XXDMADisable(
-       IN RTMP_ADAPTER                 *pAd);
-
-VOID RT28XXDMAEnable(
-       IN RTMP_ADAPTER                 *pAd);
-
-VOID RT28xx_UpdateBeaconToAsic(
-       IN RTMP_ADAPTER * pAd,
-       IN INT apidx,
-       IN ULONG BeaconLen,
-       IN ULONG UpdatePos);
-
-INT rt28xx_ioctl(
-       IN      struct net_device       *net_dev,
-       IN      OUT     struct ifreq    *rq,
-       IN      INT                     cmd);
-
-INT rt28xx_sta_ioctl(
-       IN      struct net_device       *net_dev,
-       IN      OUT     struct ifreq    *rq,
-       IN      INT                     cmd);
-
-BOOLEAN RT28XXSecurityKeyAdd(
-       IN              PRTMP_ADAPTER           pAd,
-       IN              ULONG                           apidx,
-       IN              ULONG                           KeyIdx,
-       IN              MAC_TABLE_ENTRY         *pEntry);
-
-////////////////////////////////////////
-PNDIS_PACKET GetPacketFromRxRing(
-       IN              PRTMP_ADAPTER   pAd,
-       OUT             PRT28XX_RXD_STRUC       pSaveRxD,
-       OUT             BOOLEAN                 *pbReschedule,
-       IN OUT  UINT32                  *pRxPending);
-
-
-void kill_thread_task(PRTMP_ADAPTER pAd);
-
-void tbtt_tasklet(unsigned long data);
-
-
-VOID AsicTurnOffRFClk(
-       IN PRTMP_ADAPTER    pAd,
-       IN      UCHAR           Channel);
-
-VOID AsicTurnOnRFClk(
-       IN PRTMP_ADAPTER        pAd,
-       IN      UCHAR                   Channel);
-
-#ifdef RT30xx
-NTSTATUS RT30xxWriteRFRegister(
-       IN      PRTMP_ADAPTER   pAd,
-       IN      UCHAR                   RegID,
-       IN      UCHAR                   Value);
-
-NTSTATUS RT30xxReadRFRegister(
-       IN      PRTMP_ADAPTER   pAd,
-       IN      UCHAR                   RegID,
-       IN      PUCHAR                  pValue);
-
-//2008/09/11:KH add to support efuse<--
-UCHAR eFuseReadRegisters(
-       IN      PRTMP_ADAPTER   pAd,
-       IN      USHORT Offset,
-       IN      USHORT Length,
-       OUT     USHORT* pData);
-
-VOID eFuseReadPhysical(
-       IN      PRTMP_ADAPTER   pAd,
-       IN      PUSHORT lpInBuffer,
-       IN      ULONG nInBufferSize,
-       OUT     PUSHORT lpOutBuffer,
-       IN      ULONG nOutBufferSize
-);
-
-NTSTATUS eFuseRead(
-       IN      PRTMP_ADAPTER   pAd,
-       IN      USHORT                  Offset,
-       OUT     PUCHAR                  pData,
-       IN      USHORT                  Length);
-
-VOID eFusePhysicalWriteRegisters(
-       IN      PRTMP_ADAPTER   pAd,
-       IN      USHORT Offset,
-       IN      USHORT Length,
-       OUT     USHORT* pData);
-
-NTSTATUS eFuseWriteRegisters(
-       IN      PRTMP_ADAPTER   pAd,
-       IN      USHORT Offset,
-       IN      USHORT Length,
-       IN      USHORT* pData);
-
-VOID eFuseWritePhysical(
-       IN      PRTMP_ADAPTER   pAd,
-       PUSHORT lpInBuffer,
-       ULONG nInBufferSize,
-       PUCHAR lpOutBuffer,
-       ULONG nOutBufferSize
-);
-
-NTSTATUS eFuseWrite(
-       IN      PRTMP_ADAPTER   pAd,
-       IN      USHORT                  Offset,
-       IN      PUCHAR                  pData,
-       IN      USHORT                  length);
-
-INT set_eFuseGetFreeBlockCount_Proc(
-       IN      PRTMP_ADAPTER   pAd,
-       IN      PUCHAR                  arg);
-
-INT set_eFusedump_Proc(
-       IN      PRTMP_ADAPTER   pAd,
-       IN      PUCHAR                  arg);
-
-INT set_eFuseLoadFromBin_Proc(
-       IN      PRTMP_ADAPTER   pAd,
-       IN      PUCHAR                  arg);
-
-NTSTATUS eFuseWriteRegistersFromBin(
-       IN      PRTMP_ADAPTER   pAd,
-       IN      USHORT Offset,
-       IN      USHORT Length,
-       IN      USHORT* pData);
-
-VOID eFusePhysicalReadRegisters(
-       IN      PRTMP_ADAPTER   pAd,
-       IN      USHORT Offset,
-       IN      USHORT Length,
-       OUT     USHORT* pData);
-
-NDIS_STATUS NICLoadEEPROM(
-       IN PRTMP_ADAPTER pAd);
-
-BOOLEAN bNeedLoadEEPROM(
-       IN      PRTMP_ADAPTER   pAd);
-//2008/09/11:KH add to support efuse-->
-#endif // RT30xx //
-
-#ifdef RT30xx
-// add by johnli, RF power sequence setup
-VOID RT30xxLoadRFNormalModeSetup(
-       IN PRTMP_ADAPTER        pAd);
-
-VOID RT30xxLoadRFSleepModeSetup(
-       IN PRTMP_ADAPTER        pAd);
-
-VOID RT30xxReverseRFSleepModeSetup(
-       IN PRTMP_ADAPTER        pAd);
-// end johnli
-#endif // RT30xx //
-
-#ifdef RT2870
-//
-// Function Prototype in rtusb_bulk.c
-//
-VOID   RTUSBInitTxDesc(
-       IN      PRTMP_ADAPTER   pAd,
-       IN      PTX_CONTEXT             pTxContext,
-       IN      UCHAR                   BulkOutPipeId,
-       IN      usb_complete_t  Func);
-
-VOID   RTUSBInitHTTxDesc(
-       IN      PRTMP_ADAPTER   pAd,
-       IN      PHT_TX_CONTEXT  pTxContext,
-       IN      UCHAR                   BulkOutPipeId,
-       IN      ULONG                   BulkOutSize,
-       IN      usb_complete_t  Func);
-
-VOID   RTUSBInitRxDesc(
-       IN      PRTMP_ADAPTER   pAd,
-       IN      PRX_CONTEXT             pRxContext);
-
-VOID RTUSBCleanUpDataBulkOutQueue(
-       IN      PRTMP_ADAPTER   pAd);
-
-VOID RTUSBCancelPendingBulkOutIRP(
-       IN      PRTMP_ADAPTER   pAd);
-
-VOID RTUSBBulkOutDataPacket(
-       IN      PRTMP_ADAPTER   pAd,
-       IN      UCHAR                   BulkOutPipeId,
-       IN      UCHAR                   Index);
-
-VOID RTUSBBulkOutNullFrame(
-       IN      PRTMP_ADAPTER   pAd);
-
-VOID RTUSBBulkOutRTSFrame(
-       IN      PRTMP_ADAPTER   pAd);
-
-VOID RTUSBCancelPendingBulkInIRP(
-       IN      PRTMP_ADAPTER   pAd);
-
-VOID RTUSBCancelPendingIRPs(
-       IN      PRTMP_ADAPTER   pAd);
-
-VOID RTUSBBulkOutMLMEPacket(
-       IN      PRTMP_ADAPTER   pAd,
-       IN      UCHAR                   Index);
-
-VOID RTUSBBulkOutPsPoll(
-       IN      PRTMP_ADAPTER   pAd);
-
-VOID RTUSBCleanUpMLMEBulkOutQueue(
-       IN      PRTMP_ADAPTER   pAd);
-
-VOID RTUSBKickBulkOut(
-       IN      PRTMP_ADAPTER pAd);
-
-VOID   RTUSBBulkReceive(
-       IN      PRTMP_ADAPTER   pAd);
-
-VOID DoBulkIn(
-       IN RTMP_ADAPTER *pAd);
-
-VOID RTUSBInitRxDesc(
-       IN      PRTMP_ADAPTER   pAd,
-       IN  PRX_CONTEXT         pRxContext);
-
-VOID RTUSBBulkRxHandle(
-       IN unsigned long data);
-
-//
-// Function Prototype in rtusb_io.c
-//
-NTSTATUS RTUSBMultiRead(
-       IN      PRTMP_ADAPTER   pAd,
-       IN      USHORT                  Offset,
-       OUT     PUCHAR                  pData,
-       IN      USHORT                  length);
-
-NTSTATUS RTUSBMultiWrite(
-       IN      PRTMP_ADAPTER   pAd,
-       IN      USHORT                  Offset,
-       IN      PUCHAR                  pData,
-       IN      USHORT                  length);
-
-NTSTATUS RTUSBMultiWrite_OneByte(
-       IN      PRTMP_ADAPTER   pAd,
-       IN      USHORT                  Offset,
-       IN      PUCHAR                  pData);
-
-NTSTATUS RTUSBReadBBPRegister(
-       IN      PRTMP_ADAPTER   pAd,
-       IN      UCHAR                   Id,
-       IN      PUCHAR                  pValue);
-
-NTSTATUS RTUSBWriteBBPRegister(
-       IN      PRTMP_ADAPTER   pAd,
-       IN      UCHAR                   Id,
-       IN      UCHAR                   Value);
-
-NTSTATUS RTUSBWriteRFRegister(
-       IN      PRTMP_ADAPTER   pAd,
-       IN      UINT32                  Value);
-
-NTSTATUS RTUSB_VendorRequest(
-       IN      PRTMP_ADAPTER   pAd,
-       IN      UINT32                  TransferFlags,
-       IN      UCHAR                   ReservedBits,
-       IN      UCHAR                   Request,
-       IN      USHORT                  Value,
-       IN      USHORT                  Index,
-       IN      PVOID                   TransferBuffer,
-       IN      UINT32                  TransferBufferLength);
-
-NTSTATUS RTUSBReadEEPROM(
-       IN      PRTMP_ADAPTER   pAd,
-       IN      USHORT                  Offset,
-       OUT     PUCHAR                  pData,
-       IN      USHORT                  length);
-
-NTSTATUS RTUSBWriteEEPROM(
-       IN      PRTMP_ADAPTER   pAd,
-       IN      USHORT                  Offset,
-       IN      PUCHAR                  pData,
-       IN      USHORT                  length);
-
-VOID RTUSBPutToSleep(
-       IN      PRTMP_ADAPTER   pAd);
-
-NTSTATUS RTUSBWakeUp(
-       IN      PRTMP_ADAPTER   pAd);
-
-VOID RTUSBInitializeCmdQ(
-       IN      PCmdQ   cmdq);
-
-NDIS_STATUS    RTUSBEnqueueCmdFromNdis(
-       IN      PRTMP_ADAPTER   pAd,
-       IN      NDIS_OID                Oid,
-       IN      BOOLEAN                 SetInformation,
-       IN      PVOID                   pInformationBuffer,
-       IN      UINT32                  InformationBufferLength);
-
-NDIS_STATUS RTUSBEnqueueInternalCmd(
-       IN      PRTMP_ADAPTER   pAd,
-       IN NDIS_OID                     Oid,
-       IN PVOID                        pInformationBuffer,
-       IN UINT32                       InformationBufferLength);
-
-VOID RTUSBDequeueCmd(
-       IN      PCmdQ           cmdq,
-       OUT     PCmdQElmt       *pcmdqelmt);
-
-INT RTUSBCmdThread(
-       IN OUT PVOID Context);
-
-INT TimerQThread(
-       IN OUT PVOID Context);
-
-RT2870_TIMER_ENTRY *RT2870_TimerQ_Insert(
-       IN RTMP_ADAPTER *pAd,
-       IN RALINK_TIMER_STRUCT *pTimer);
-
-BOOLEAN RT2870_TimerQ_Remove(
-       IN RTMP_ADAPTER *pAd,
-       IN RALINK_TIMER_STRUCT *pTimer);
-
-void RT2870_TimerQ_Exit(
-       IN RTMP_ADAPTER *pAd);
-
-void RT2870_TimerQ_Init(
-       IN RTMP_ADAPTER *pAd);
-
-VOID RT2870_BssBeaconExit(
-       IN RTMP_ADAPTER *pAd);
-
-VOID RT2870_BssBeaconStop(
-       IN RTMP_ADAPTER *pAd);
-
-VOID RT2870_BssBeaconStart(
-       IN RTMP_ADAPTER * pAd);
-
-VOID RT2870_BssBeaconInit(
-       IN RTMP_ADAPTER *pAd);
-
-VOID RT2870_WatchDog(
-       IN RTMP_ADAPTER *pAd);
-
-NTSTATUS RTUSBWriteMACRegister(
-       IN      PRTMP_ADAPTER   pAd,
-       IN      USHORT                  Offset,
-       IN      UINT32                  Value);
-
-NTSTATUS RTUSBReadMACRegister(
-       IN      PRTMP_ADAPTER   pAd,
-       IN      USHORT                  Offset,
-       OUT     PUINT32                 pValue);
-
-NTSTATUS RTUSBSingleWrite(
-       IN      RTMP_ADAPTER    *pAd,
-       IN      USHORT                  Offset,
-       IN      USHORT                  Value);
-
-NTSTATUS RTUSBFirmwareRun(
-       IN      PRTMP_ADAPTER   pAd);
-
-NTSTATUS RTUSBFirmwareWrite(
-       IN PRTMP_ADAPTER pAd,
-       IN PUCHAR               pFwImage,
-       IN ULONG                FwLen);
-
-NTSTATUS       RTUSBFirmwareOpmode(
-       IN      PRTMP_ADAPTER   pAd,
-       OUT     PUINT32                 pValue);
-
-NTSTATUS       RTUSBVenderReset(
-       IN      PRTMP_ADAPTER   pAd);
-
-NDIS_STATUS RTUSBSetHardWareRegister(
-       IN      PRTMP_ADAPTER   pAdapter,
-       IN      PVOID                   pBuf);
-
-NDIS_STATUS RTUSBQueryHardWareRegister(
-       IN      PRTMP_ADAPTER   pAdapter,
-       IN      PVOID                   pBuf);
-
-VOID CMDHandler(
-    IN PRTMP_ADAPTER pAd);
-
-
-NDIS_STATUS     CreateThreads(
-       IN      struct net_device *net_dev );
-
-
-VOID MacTableInitialize(
-       IN  PRTMP_ADAPTER   pAd);
-
-VOID MlmeSetPsm(
-       IN PRTMP_ADAPTER pAd,
-       IN USHORT psm);
-
-NDIS_STATUS RTMPWPAAddKeyProc(
-       IN  PRTMP_ADAPTER   pAd,
-       IN  PVOID           pBuf);
-
-VOID AsicRxAntEvalAction(
-       IN PRTMP_ADAPTER pAd);
-
-void append_pkt(
-       IN      PRTMP_ADAPTER   pAd,
-       IN      PUCHAR                  pHeader802_3,
-    IN  UINT            HdrLen,
-       IN      PUCHAR                  pData,
-       IN      ULONG                   DataSize,
-       OUT  PNDIS_PACKET       *ppPacket);
-
-UINT deaggregate_AMSDU_announce(
-       IN      PRTMP_ADAPTER   pAd,
-       PNDIS_PACKET            pPacket,
-       IN      PUCHAR                  pData,
-       IN      ULONG                   DataSize);
-
-NDIS_STATUS    RTMPCheckRxError(
-       IN      PRTMP_ADAPTER   pAd,
-       IN      PHEADER_802_11  pHeader,
-       IN      PRXWI_STRUC     pRxWI,
-       IN      PRT28XX_RXD_STRUC       pRxINFO);
-
-
-VOID RTUSBMlmeHardTransmit(
-       IN      PRTMP_ADAPTER   pAd,
-       IN      PMGMT_STRUC             pMgmt);
-
-INT MlmeThread(
-       IN PVOID Context);
-
-//
-// Function Prototype in rtusb_data.c
-//
-NDIS_STATUS    RTUSBFreeDescriptorRequest(
-       IN      PRTMP_ADAPTER   pAd,
-       IN      UCHAR                   BulkOutPipeId,
-       IN      UINT32                  NumberRequired);
-
-
-BOOLEAN        RTUSBNeedQueueBackForAgg(
-       IN RTMP_ADAPTER *pAd,
-       IN UCHAR                BulkOutPipeId);
-
-
-VOID RTMPWriteTxInfo(
-       IN      PRTMP_ADAPTER   pAd,
-       IN      PTXINFO_STRUC   pTxInfo,
-       IN        USHORT                USBDMApktLen,
-       IN        BOOLEAN               bWiv,
-       IN        UCHAR                 QueueSel,
-       IN        UCHAR                 NextValid,
-       IN        UCHAR                 TxBurst);
-
-//
-// Function Prototype in cmm_data_2870.c
-//
-USHORT RtmpUSB_WriteSubTxResource(
-       IN      PRTMP_ADAPTER   pAd,
-       IN      TX_BLK                  *pTxBlk,
-       IN      BOOLEAN                 bIsLast,
-       OUT     USHORT                  *FreeNumber);
-
-USHORT RtmpUSB_WriteSingleTxResource(
-       IN      PRTMP_ADAPTER   pAd,
-       IN      TX_BLK                  *pTxBlk,
-       IN      BOOLEAN                 bIsLast,
-       OUT     USHORT                  *FreeNumber);
-
-USHORT RtmpUSB_WriteFragTxResource(
-       IN      PRTMP_ADAPTER   pAd,
-       IN      TX_BLK                  *pTxBlk,
-       IN      UCHAR                   fragNum,
-       OUT     USHORT                  *FreeNumber);
-
-USHORT RtmpUSB_WriteMultiTxResource(
-       IN      PRTMP_ADAPTER   pAd,
-       IN      TX_BLK                  *pTxBlk,
-       IN      UCHAR                   frameNum,
-       OUT     USHORT                  *FreeNumber);
-
-VOID RtmpUSB_FinalWriteTxResource(
-       IN      PRTMP_ADAPTER   pAd,
-       IN      TX_BLK                  *pTxBlk,
-       IN      USHORT                  totalMPDUSize,
-       IN      USHORT                  TxIdx);
-
-VOID RtmpUSBDataLastTxIdx(
-       IN      PRTMP_ADAPTER   pAd,
-       IN      UCHAR                   QueIdx,
-       IN      USHORT                  TxIdx);
-
-VOID RtmpUSBDataKickOut(
-       IN      PRTMP_ADAPTER   pAd,
-       IN      TX_BLK                  *pTxBlk,
-       IN      UCHAR                   QueIdx);
-
-
-int RtmpUSBMgmtKickOut(
-       IN RTMP_ADAPTER         *pAd,
-       IN UCHAR                        QueIdx,
-       IN PNDIS_PACKET         pPacket,
-       IN PUCHAR                       pSrcBufVA,
-       IN UINT                         SrcBufLen);
-
-VOID RtmpUSBNullFrameKickOut(
-       IN RTMP_ADAPTER *pAd,
-       IN UCHAR                QueIdx,
-       IN UCHAR                *pNullFrame,
-       IN UINT32               frameLen);
-
-VOID RT28xxUsbStaAsicForceWakeup(
-       IN PRTMP_ADAPTER pAd,
-       IN BOOLEAN       bFromTx);
-
-VOID RT28xxUsbStaAsicSleepThenAutoWakeup(
-       IN PRTMP_ADAPTER pAd,
-       IN USHORT TbttNumToNextWakeUp);
-
-VOID RT28xxUsbMlmeRadioOn(
-       IN PRTMP_ADAPTER pAd);
-
-VOID RT28xxUsbMlmeRadioOFF(
-       IN PRTMP_ADAPTER pAd);
-#endif // RT2870 //
-
-////////////////////////////////////////
-
-VOID QBSS_LoadInit(
-       IN              RTMP_ADAPTER    *pAd);
-
-UINT32 QBSS_LoadElementAppend(
-       IN              RTMP_ADAPTER    *pAd,
-       OUT             UINT8                   *buf_p);
-
-VOID QBSS_LoadUpdate(
-       IN              RTMP_ADAPTER    *pAd);
-
-///////////////////////////////////////
-INT RTMPShowCfgValue(
-       IN      PRTMP_ADAPTER   pAd,
-       IN      PUCHAR                  pName,
-       IN      PUCHAR                  pBuf);
-
-PCHAR   RTMPGetRalinkAuthModeStr(
-    IN  NDIS_802_11_AUTHENTICATION_MODE authMode);
-
-PCHAR   RTMPGetRalinkEncryModeStr(
-    IN  USHORT encryMode);
-//////////////////////////////////////
-
-VOID AsicStaBbpTuning(
-       IN PRTMP_ADAPTER pAd);
-
-BOOLEAN StaAddMacTableEntry(
-       IN  PRTMP_ADAPTER               pAd,
-       IN  PMAC_TABLE_ENTRY    pEntry,
-       IN  UCHAR                               MaxSupportedRateIn500Kbps,
-       IN  HT_CAPABILITY_IE    *pHtCapability,
-       IN  UCHAR                               HtCapabilityLen,
-       IN  USHORT                      CapabilityInfo);
-
-void RTMP_IndicateMediaState(
-       IN      PRTMP_ADAPTER   pAd);
-
-VOID ReSyncBeaconTime(
-       IN  PRTMP_ADAPTER   pAd);
-
-VOID RTMPSetAGCInitValue(
-       IN PRTMP_ADAPTER        pAd,
-       IN UCHAR                        BandWidth);
-
-int rt28xx_close(IN PNET_DEV dev);
-int rt28xx_open(IN PNET_DEV dev);
-
-__inline INT VIRTUAL_IF_UP(PRTMP_ADAPTER pAd)
-{
-extern VOID MeshMakeBeacon(IN PRTMP_ADAPTER pAd, IN UCHAR idx);
-extern VOID MeshUpdateBeaconFrame(IN PRTMP_ADAPTER pAd, IN UCHAR idx);
-
-       if (VIRTUAL_IF_NUM(pAd) == 0)
-       {
-               if (rt28xx_open(pAd->net_dev) != 0)
-                       return -1;
-       }
-       else
-       {
-       }
-       VIRTUAL_IF_INC(pAd);
-       return 0;
-}
-
-__inline VOID VIRTUAL_IF_DOWN(PRTMP_ADAPTER pAd)
-{
-       VIRTUAL_IF_DEC(pAd);
-       if (VIRTUAL_IF_NUM(pAd) == 0)
-               rt28xx_close(pAd->net_dev);
-       return;
-}
-
-
-#endif  // __RTMP_H__
-
+#include "../rt2870/rtmp.h"
index a3d949a39d3908a3234f97b385ddfff67166aeb6..4956093f4751175c729f6dc9846cbffa9ae77e56 100644 (file)
@@ -1,113 +1 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify  *
- * it under the terms of the GNU General Public License as published by  *
- * the Free Software Foundation; either version 2 of the License, or     *
- * (at your option) any later version.                                   *
- *                                                                       *
- * 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.                          *
- *                                                                       *
- * You should have received a copy of the GNU General Public License     *
- * along with this program; if not, write to the                         *
- * Free Software Foundation, Inc.,                                       *
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- *                                                                       *
- *************************************************************************
-
-       Module Name:
-       rtmp_ckipmic.h
-
-       Abstract:
-
-       Revision History:
-       Who                     When                    What
-       --------        ----------              ----------------------------------------------
-       Name            Date                    Modification logs
-*/
-#ifndef        __RTMP_CKIPMIC_H__
-#define        __RTMP_CKIPMIC_H__
-
-typedef        struct  _MIC_CONTEXT    {
-       /* --- MMH context                            */
-       UCHAR           CK[16];                         /* the key                                    */
-       UCHAR           coefficient[16];        /* current aes counter mode coefficients      */
-       ULONGLONG       accum;                          /* accumulated mic, reduced to u32 in final() */
-       UINT            position;                       /* current position (byte offset) in message  */
-       UCHAR           part[4];                        /* for conversion of message to u32 for mmh   */
-}      MIC_CONTEXT, *PMIC_CONTEXT;
-
-VOID   CKIP_key_permute(
-       OUT     UCHAR   *PK,                    /* output permuted key */
-       IN      UCHAR   *CK,                    /* input CKIP key */
-       IN      UCHAR   toDsFromDs,             /* input toDs/FromDs bits */
-       IN      UCHAR   *piv);                  /* input pointer to IV */
-
-VOID   RTMPCkipMicInit(
-       IN      PMIC_CONTEXT            pContext,
-       IN      PUCHAR                          CK);
-
-VOID RTMPMicUpdate(
-    IN  PMIC_CONTEXT        pContext,
-    IN  PUCHAR              pOctets,
-    IN  INT                 len);
-
-ULONG RTMPMicGetCoefficient(
-    IN  PMIC_CONTEXT         pContext);
-
-VOID xor_128(
-    IN  PUCHAR              a,
-    IN  PUCHAR              b,
-    OUT PUCHAR              out);
-
-UCHAR RTMPCkipSbox(
-    IN  UCHAR               a);
-
-VOID xor_32(
-    IN  PUCHAR              a,
-    IN  PUCHAR              b,
-    OUT PUCHAR              out);
-
-VOID next_key(
-    IN  PUCHAR              key,
-    IN  INT                 round);
-
-VOID byte_sub(
-    IN  PUCHAR              in,
-    OUT PUCHAR              out);
-
-VOID shift_row(
-    IN  PUCHAR              in,
-    OUT PUCHAR              out);
-
-VOID mix_column(
-    IN  PUCHAR              in,
-    OUT PUCHAR              out);
-
-VOID RTMPAesEncrypt(
-    IN  PUCHAR              key,
-    IN  PUCHAR              data,
-    IN  PUCHAR              ciphertext);
-
-VOID RTMPMicFinal(
-    IN  PMIC_CONTEXT        pContext,
-    OUT UCHAR               digest[4]);
-
-VOID RTMPCkipInsertCMIC(
-    IN  PRTMP_ADAPTER   pAd,
-    OUT PUCHAR          pMIC,
-    IN  PUCHAR          p80211hdr,
-    IN  PNDIS_PACKET    pPacket,
-    IN  PCIPHER_KEY     pKey,
-    IN  PUCHAR          mic_snap);
-
-#endif //__RTMP_CKIPMIC_H__
+#include "../rt2870/rtmp_ckipmic.h"
index 99df45c119293e8c35e75a5fe632175bacbafb06..fa3b6b55cfee0075a1a099c947f7303493bf3cc0 100644 (file)
@@ -1,1440 +1 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify  *
- * it under the terms of the GNU General Public License as published by  *
- * the Free Software Foundation; either version 2 of the License, or     *
- * (at your option) any later version.                                   *
- *                                                                       *
- * 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.                          *
- *                                                                       *
- * You should have received a copy of the GNU General Public License     *
- * along with this program; if not, write to the                         *
- * Free Software Foundation, Inc.,                                       *
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- *                                                                       *
- *************************************************************************
-
-    Module Name:
-    rtmp_def.h
-
-    Abstract:
-    Miniport related definition header
-
-    Revision History:
-    Who         When          What
-    --------    ----------    ----------------------------------------------
-    Paul Lin    08-01-2002    created
-    John Chang  08-05-2003    add definition for 11g & other drafts
-*/
-#ifndef __RTMP_DEF_H__
-#define __RTMP_DEF_H__
-
-#include "oid.h"
-
-//
-//  Debug information verbosity: lower values indicate higher urgency
-//
-#define RT_DEBUG_OFF        0
-#define RT_DEBUG_ERROR      1
-#define RT_DEBUG_WARN       2
-#define RT_DEBUG_TRACE      3
-#define RT_DEBUG_INFO       4
-#define RT_DEBUG_LOUD       5
-
-#define NIC_TAG             ((ULONG)'0682')
-#define NIC_DBG_STRING      ("**RT28xx**")
-
-#define RALINK_2883_VERSION            ((UINT32)0x28830300)
-#define RALINK_2880E_VERSION   ((UINT32)0x28720200)
-#define RALINK_3070_VERSION            ((UINT32)0x30700200)
-
-//
-// NDIS version in use by the NIC driver.
-// The high byte is the major version. The low byte is the minor version.
-//
-#ifdef  NDIS51_MINIPORT
-#define NIC_DRIVER_VERSION      0x0501
-#else
-#define NIC_DRIVER_VERSION      0x0500
-#endif
-
-//
-// NDIS media type, current is ethernet, change if native wireless supported
-//
-#define NIC_MEDIA_TYPE          NdisMedium802_3
-#define NIC_PCI_HDR_LENGTH      0xe2
-#define NIC_MAX_PACKET_SIZE     2304
-#define NIC_HEADER_SIZE         14
-#define MAX_MAP_REGISTERS_NEEDED 32
-#define MIN_MAP_REGISTERS_NEEDED 2   //Todo: should consider fragment issue.
-
-//
-// interface type, we use PCI
-//
-#define NIC_INTERFACE_TYPE      NdisInterfacePci
-#define NIC_INTERRUPT_MODE      NdisInterruptLevelSensitive
-
-//
-// buffer size passed in NdisMQueryAdapterResources
-// We should only need three adapter resources (IO, interrupt and memory),
-// Some devices get extra resources, so have room for 10 resources
-//                    UF_SIZE   (sizeof(NDIS_RESOURCE_LIST) + (10*sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR)))
-
-
-#define NIC_RESOURCE_B//
-// IO space length
-//
-#define NIC_MAP_IOSPACE_LENGTH  sizeof(CSR_STRUC)
-
-#define MAX_RX_PKT_LEN 1520
-
-//
-// Entry number for each DMA descriptor ring
-//
-
-
-#ifdef RT2870
-#define TX_RING_SIZE            8 // 1
-#define PRIO_RING_SIZE          8
-#define MGMT_RING_SIZE       32 // PRIO_RING_SIZE
-#define RX_RING_SIZE            8
-#define MAX_TX_PROCESS          4
-#define LOCAL_TXBUF_SIZE        2048
-#endif // RT2870 //
-
-#define MAX_RX_PROCESS          128 //64 //32
-#define NUM_OF_LOCAL_TXBUF      2
-#define TXD_SIZE                16
-#define TXWI_SIZE               16
-#define RXD_SIZE                       16
-#define RXWI_SIZE              16
-// TXINFO_SIZE + TXWI_SIZE + 802.11 Header Size + AMSDU sub frame header
-#define TX_DMA_1ST_BUFFER_SIZE  96    // only the 1st physical buffer is pre-allocated
-#define MGMT_DMA_BUFFER_SIZE    1536 //2048
-#define RX_BUFFER_AGGRESIZE     3840 //3904 //3968 //4096 //2048 //4096
-#define RX_BUFFER_NORMSIZE      3840 //3904 //3968 //4096 //2048 //4096
-#define TX_BUFFER_NORMSIZE             RX_BUFFER_NORMSIZE
-#define MAX_FRAME_SIZE          2346                    // Maximum 802.11 frame size
-#define MAX_AGGREGATION_SIZE    3840 //3904 //3968 //4096
-#define MAX_NUM_OF_TUPLE_CACHE  2
-#define MAX_MCAST_LIST_SIZE     32
-#define MAX_LEN_OF_VENDOR_DESC  64
-//#define MAX_SIZE_OF_MCAST_PSQ   (NUM_OF_LOCAL_TXBUF >> 2) // AP won't spend more than 1/4 of total buffers on M/BCAST PSQ
-#define MAX_SIZE_OF_MCAST_PSQ               32
-
-#define MAX_RX_PROCESS_CNT     (RX_RING_SIZE)
-
-
-#define MAX_PACKETS_IN_QUEUE                           (512) //(512)    // to pass WMM A5-WPAPSK
-#define MAX_PACKETS_IN_MCAST_PS_QUEUE          32
-#define MAX_PACKETS_IN_PS_QUEUE                                128     //32
-#define WMM_NUM_OF_AC                       4  /* AC0, AC1, AC2, and AC3 */
-
-
-//2008/09/11:KH add to support efuse<--
-#define MAX_EEPROM_BIN_FILE_SIZE                                       1024
-//2008/09/11:KH add to support efuse-->
-
-// RxFilter
-#define STANORMAL       0x17f97
-#define APNORMAL        0x15f97
-//
-//  RTMP_ADAPTER flags
-//
-#define fRTMP_ADAPTER_MAP_REGISTER          0x00000001
-#define fRTMP_ADAPTER_INTERRUPT_IN_USE      0x00000002
-#define fRTMP_ADAPTER_HARDWARE_ERROR        0x00000004
-#define fRTMP_ADAPTER_SCATTER_GATHER        0x00000008
-#define fRTMP_ADAPTER_SEND_PACKET_ERROR     0x00000010
-#define fRTMP_ADAPTER_MLME_RESET_IN_PROGRESS 0x00000020
-#define fRTMP_ADAPTER_HALT_IN_PROGRESS      0x00000040
-#define fRTMP_ADAPTER_RESET_IN_PROGRESS     0x00000080
-#define fRTMP_ADAPTER_NIC_NOT_EXIST         0x00000100
-#define fRTMP_ADAPTER_TX_RING_ALLOCATED     0x00000200
-#define fRTMP_ADAPTER_REMOVE_IN_PROGRESS    0x00000400
-#define fRTMP_ADAPTER_MIMORATE_INUSED       0x00000800
-#define fRTMP_ADAPTER_RX_RING_ALLOCATED     0x00001000
-#define fRTMP_ADAPTER_INTERRUPT_ACTIVE      0x00002000
-#define fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS  0x00004000
-#define        fRTMP_ADAPTER_REASSOC_IN_PROGRESS       0x00008000
-#define        fRTMP_ADAPTER_MEDIA_STATE_PENDING       0x00010000
-#define        fRTMP_ADAPTER_RADIO_OFF                         0x00020000
-#define fRTMP_ADAPTER_BULKOUT_RESET                    0x00040000
-#define        fRTMP_ADAPTER_BULKIN_RESET                      0x00080000
-#define fRTMP_ADAPTER_RDG_ACTIVE                       0x00100000
-#define fRTMP_ADAPTER_DYNAMIC_BE_TXOP_ACTIVE 0x00200000
-#define fRTMP_ADAPTER_SCAN_2040                        0x04000000
-#define        fRTMP_ADAPTER_RADIO_MEASUREMENT         0x08000000
-
-#define fRTMP_ADAPTER_START_UP                         0x10000000      //Devive already initialized and enabled Tx/Rx.
-#define fRTMP_ADAPTER_MEDIA_STATE_CHANGE    0x20000000
-#define fRTMP_ADAPTER_IDLE_RADIO_OFF        0x40000000
-
-//
-//  STA operation status flags
-//
-#define fOP_STATUS_INFRA_ON                 0x00000001
-#define fOP_STATUS_ADHOC_ON                 0x00000002
-#define fOP_STATUS_BG_PROTECTION_INUSED     0x00000004
-#define fOP_STATUS_SHORT_SLOT_INUSED        0x00000008
-#define fOP_STATUS_SHORT_PREAMBLE_INUSED    0x00000010
-#define fOP_STATUS_RECEIVE_DTIM             0x00000020
-#define fOP_STATUS_MEDIA_STATE_CONNECTED    0x00000080
-#define fOP_STATUS_WMM_INUSED               0x00000100
-#define fOP_STATUS_AGGREGATION_INUSED       0x00000200
-#define fOP_STATUS_DOZE                     0x00000400  // debug purpose
-#define fOP_STATUS_PIGGYBACK_INUSED         0x00000800  // piggy-back, and aggregation
-#define fOP_STATUS_APSD_INUSED                         0x00001000
-#define fOP_STATUS_TX_AMSDU_INUSED                     0x00002000
-#define fOP_STATUS_MAX_RETRY_ENABLED           0x00004000
-#define fOP_STATUS_WAKEUP_NOW               0x00008000
-#define fOP_STATUS_ADVANCE_POWER_SAVE_PCIE_DEVICE       0x00020000
-
-#define CCKSETPROTECT          0x1
-#define OFDMSETPROTECT         0x2
-#define MM20SETPROTECT         0x4
-#define MM40SETPROTECT         0x8
-#define GF20SETPROTECT         0x10
-#define GR40SETPROTECT         0x20
-#define ALLN_SETPROTECT                (GR40SETPROTECT | GF20SETPROTECT | MM40SETPROTECT | MM20SETPROTECT)
-
-//
-//  AP's client table operation status flags
-//
-#define fCLIENT_STATUS_WMM_CAPABLE          0x00000001  // CLIENT can parse QOS DATA frame
-#define fCLIENT_STATUS_AGGREGATION_CAPABLE  0x00000002  // CLIENT can receive Ralink's proprietary TX aggregation frame
-#define fCLIENT_STATUS_PIGGYBACK_CAPABLE    0x00000004  // CLIENT support piggy-back
-#define fCLIENT_STATUS_AMSDU_INUSED                    0x00000008
-#define fCLIENT_STATUS_SGI20_CAPABLE           0x00000010
-#define fCLIENT_STATUS_SGI40_CAPABLE           0x00000020
-#define fCLIENT_STATUS_TxSTBC_CAPABLE          0x00000040
-#define fCLIENT_STATUS_RxSTBC_CAPABLE          0x00000080
-#define fCLIENT_STATUS_HTC_CAPABLE                     0x00000100
-#define fCLIENT_STATUS_RDG_CAPABLE                     0x00000200
-#define fCLIENT_STATUS_MCSFEEDBACK_CAPABLE  0x00000400
-#define fCLIENT_STATUS_APSD_CAPABLE         0x00000800  /* UAPSD STATION */
-
-#define fCLIENT_STATUS_RALINK_CHIPSET          0x00100000
-//
-//  STA configuration flags
-//
-
-// 802.11n Operating Mode Definition. 0-3 also used in ASICUPdateProtect switch case
-#define HT_NO_PROTECT  0
-#define HT_LEGACY_PROTECT      1
-#define HT_40_PROTECT  2
-#define HT_2040_PROTECT        3
-#define HT_RTSCTS_6M   7
-//following is our own definition in order to turn on our ASIC protection register in INFRASTRUCTURE.
-#define HT_ATHEROS     8
-#define HT_FORCERTSCTS 9       // Force turn on RTS/CTS first. then go to evaluate if this force RTS is necessary.
-
-//
-// RX Packet Filter control flags. Apply on pAd->PacketFilter
-//
-#define fRX_FILTER_ACCEPT_DIRECT            NDIS_PACKET_TYPE_DIRECTED
-#define fRX_FILTER_ACCEPT_MULTICAST         NDIS_PACKET_TYPE_MULTICAST
-#define fRX_FILTER_ACCEPT_BROADCAST         NDIS_PACKET_TYPE_BROADCAST
-#define fRX_FILTER_ACCEPT_ALL_MULTICAST     NDIS_PACKET_TYPE_ALL_MULTICAST
-
-//
-// Error code section
-//
-// NDIS_ERROR_CODE_ADAPTER_NOT_FOUND
-#define ERRLOG_READ_PCI_SLOT_FAILED     0x00000101L
-#define ERRLOG_WRITE_PCI_SLOT_FAILED    0x00000102L
-#define ERRLOG_VENDOR_DEVICE_NOMATCH    0x00000103L
-
-// NDIS_ERROR_CODE_ADAPTER_DISABLED
-#define ERRLOG_BUS_MASTER_DISABLED      0x00000201L
-
-// NDIS_ERROR_CODE_UNSUPPORTED_CONFIGURATION
-#define ERRLOG_INVALID_SPEED_DUPLEX     0x00000301L
-#define ERRLOG_SET_SECONDARY_FAILED     0x00000302L
-
-// NDIS_ERROR_CODE_OUT_OF_RESOURCES
-#define ERRLOG_OUT_OF_MEMORY            0x00000401L
-#define ERRLOG_OUT_OF_SHARED_MEMORY     0x00000402L
-#define ERRLOG_OUT_OF_MAP_REGISTERS     0x00000403L
-#define ERRLOG_OUT_OF_BUFFER_POOL       0x00000404L
-#define ERRLOG_OUT_OF_NDIS_BUFFER       0x00000405L
-#define ERRLOG_OUT_OF_PACKET_POOL       0x00000406L
-#define ERRLOG_OUT_OF_NDIS_PACKET       0x00000407L
-#define ERRLOG_OUT_OF_LOOKASIDE_MEMORY  0x00000408L
-
-// NDIS_ERROR_CODE_HARDWARE_FAILURE
-#define ERRLOG_SELFTEST_FAILED          0x00000501L
-#define ERRLOG_INITIALIZE_ADAPTER       0x00000502L
-#define ERRLOG_REMOVE_MINIPORT          0x00000503L
-
-// NDIS_ERROR_CODE_RESOURCE_CONFLICT
-#define ERRLOG_MAP_IO_SPACE             0x00000601L
-#define ERRLOG_QUERY_ADAPTER_RESOURCES  0x00000602L
-#define ERRLOG_NO_IO_RESOURCE           0x00000603L
-#define ERRLOG_NO_INTERRUPT_RESOURCE    0x00000604L
-#define ERRLOG_NO_MEMORY_RESOURCE       0x00000605L
-
-
-// WDS definition
-#define        MAX_WDS_ENTRY               4
-#define WDS_PAIRWISE_KEY_OFFSET     60    // WDS links uses pairwise key#60 ~ 63 in ASIC pairwise key table
-
-#define        WDS_DISABLE_MODE            0
-#define        WDS_RESTRICT_MODE           1
-#define        WDS_BRIDGE_MODE             2
-#define        WDS_REPEATER_MODE           3
-#define        WDS_LAZY_MODE               4
-
-
-#define MAX_MESH_NUM                           0
-
-#define MAX_APCLI_NUM                          0
-
-#define MAX_MBSSID_NUM                         1
-#ifdef MBSS_SUPPORT
-#undef MAX_MBSSID_NUM
-#define MAX_MBSSID_NUM                         (8 - MAX_MESH_NUM - MAX_APCLI_NUM)
-#endif // MBSS_SUPPORT //
-
-/* sanity check for apidx */
-#define MBSS_MR_APIDX_SANITY_CHECK(apidx) \
-    { if (apidx > MAX_MBSSID_NUM) { \
-          printk("%s> Error! apidx = %d > MAX_MBSSID_NUM!\n", __func__, apidx); \
-         apidx = MAIN_MBSSID; } }
-
-#define VALID_WCID(_wcid)      ((_wcid) > 0 && (_wcid) < MAX_LEN_OF_MAC_TABLE )
-
-#define MAIN_MBSSID                 0
-#define FIRST_MBSSID                1
-
-
-#define MAX_BEACON_SIZE                                512
-// If the MAX_MBSSID_NUM is larger than 6,
-// it shall reserve some WCID space(wcid 222~253) for beacon frames.
-// -   these wcid 238~253 are reserved for beacon#6(ra6).
-// -   these wcid 222~237 are reserved for beacon#7(ra7).
-#if defined(MAX_MBSSID_NUM) && (MAX_MBSSID_NUM == 8)
-#define HW_RESERVED_WCID       222
-#elif defined(MAX_MBSSID_NUM) && (MAX_MBSSID_NUM == 7)
-#define HW_RESERVED_WCID       238
-#else
-#define HW_RESERVED_WCID       255
-#endif
-
-// Then dedicate wcid of DFS and Carrier-Sense.
-#define DFS_CTS_WCID           (HW_RESERVED_WCID - 1)
-#define CS_CTS_WCID            (HW_RESERVED_WCID - 2)
-#define LAST_SPECIFIC_WCID     (HW_RESERVED_WCID - 2)
-
-// If MAX_MBSSID_NUM is 8, the maximum available wcid for the associated STA is 211.
-// If MAX_MBSSID_NUM is 7, the maximum available wcid for the associated STA is 228.
-#define MAX_AVAILABLE_CLIENT_WCID      (LAST_SPECIFIC_WCID - MAX_MBSSID_NUM - 1)
-
-// TX need WCID to find Cipher Key
-// these wcid 212 ~ 219 are reserved for bc/mc packets if MAX_MBSSID_NUM is 8.
-#define GET_GroupKey_WCID(__wcid, __bssidx) \
-       {                                                                               \
-               __wcid = LAST_SPECIFIC_WCID - (MAX_MBSSID_NUM) + __bssidx;      \
-       }
-
-#define IsGroupKeyWCID(__wcid) (((__wcid) < LAST_SPECIFIC_WCID) && ((__wcid) >= (LAST_SPECIFIC_WCID - (MAX_MBSSID_NUM))))
-
-
-// definition to support multiple BSSID
-#define BSS0                            0
-#define BSS1                            1
-#define BSS2                            2
-#define BSS3                            3
-#define BSS4                            4
-#define BSS5                            5
-#define BSS6                            6
-#define BSS7                            7
-
-
-//============================================================
-// Length definitions
-#define PEER_KEY_NO                     2
-#define MAC_ADDR_LEN                    6
-#define TIMESTAMP_LEN                   8
-#define MAX_LEN_OF_SUPPORTED_RATES      MAX_LENGTH_OF_SUPPORT_RATES // 1, 2, 5.5, 11, 6, 9, 12, 18, 24, 36, 48, 54
-#define MAX_LEN_OF_KEY                  32      // 32 octets == 256 bits, Redefine for WPA
-#define MAX_NUM_OF_CHANNELS             MAX_NUM_OF_CHS      // 14 channels @2.4G +  12@UNII + 4 @MMAC + 11 @HiperLAN2 + 7 @Japan + 1 as NULL termination
-#define MAX_NUM_OF_11JCHANNELS             20      // 14 channels @2.4G +  12@UNII + 4 @MMAC + 11 @HiperLAN2 + 7 @Japan + 1 as NULL termination
-#define MAX_LEN_OF_SSID                 32
-#define CIPHER_TEXT_LEN                 128
-#define HASH_TABLE_SIZE                 256
-#define MAX_VIE_LEN                     1024   // New for WPA cipher suite variable IE sizes.
-#define MAX_SUPPORT_MCS             32
-
-//============================================================
-// ASIC WCID Table definition.
-//============================================================
-#define BSSID_WCID             1       // in infra mode, always put bssid with this WCID
-#define MCAST_WCID     0x0
-#define BSS0Mcast_WCID 0x0
-#define BSS1Mcast_WCID 0xf8
-#define BSS2Mcast_WCID 0xf9
-#define BSS3Mcast_WCID 0xfa
-#define BSS4Mcast_WCID 0xfb
-#define BSS5Mcast_WCID 0xfc
-#define BSS6Mcast_WCID 0xfd
-#define BSS7Mcast_WCID 0xfe
-#define RESERVED_WCID          0xff
-
-#define MAX_NUM_OF_ACL_LIST                            MAX_NUMBER_OF_ACL
-
-#define MAX_LEN_OF_MAC_TABLE            MAX_NUMBER_OF_MAC // if MAX_MBSSID_NUM is 8, this value can't be larger than 211
-
-#if MAX_LEN_OF_MAC_TABLE>MAX_AVAILABLE_CLIENT_WCID
-#error MAX_LEN_OF_MAC_TABLE can not be larger than MAX_AVAILABLE_CLIENT_WCID!!!!
-#endif
-
-#define MAX_NUM_OF_WDS_LINK_PERBSSID               3
-#define MAX_NUM_OF_WDS_LINK                (MAX_NUM_OF_WDS_LINK_PERBSSID*MAX_MBSSID_NUM)
-#define MAX_NUM_OF_EVENT                MAX_NUMBER_OF_EVENT
-#define WDS_LINK_START_WCID                            (MAX_LEN_OF_MAC_TABLE-1)
-
-#define NUM_OF_TID                     8
-#define MAX_AID_BA                    4
-#define MAX_LEN_OF_BA_REC_TABLE          ((NUM_OF_TID * MAX_LEN_OF_MAC_TABLE)/2)//   (NUM_OF_TID*MAX_AID_BA + 32)       //Block ACK recipient
-#define MAX_LEN_OF_BA_ORI_TABLE          ((NUM_OF_TID * MAX_LEN_OF_MAC_TABLE)/2)//   (NUM_OF_TID*MAX_AID_BA + 32)   // Block ACK originator
-#define MAX_LEN_OF_BSS_TABLE             64
-#define MAX_REORDERING_MPDU_NUM                         512
-
-// key related definitions
-#define SHARE_KEY_NUM                   4
-#define MAX_LEN_OF_SHARE_KEY            16    // byte count
-#define MAX_LEN_OF_PEER_KEY             16    // byte count
-#define PAIRWISE_KEY_NUM                64    // in MAC ASIC pairwise key table
-#define GROUP_KEY_NUM                   4
-#define PMK_LEN                         32
-#define WDS_PAIRWISE_KEY_OFFSET         60    // WDS links uses pairwise key#60 ~ 63 in ASIC pairwise key table
-#define        PMKID_NO                        4     // Number of PMKID saved supported
-#define MAX_LEN_OF_MLME_BUFFER          2048
-
-// power status related definitions
-#define PWR_ACTIVE                      0
-#define PWR_SAVE                        1
-#define PWR_MMPS                        2                      //MIMO power save
-
-// Auth and Assoc mode related definitions
-#define AUTH_MODE_OPEN                  0x00
-#define AUTH_MODE_KEY                   0x01
-
-// BSS Type definitions
-#define BSS_ADHOC                       0  // = Ndis802_11IBSS
-#define BSS_INFRA                       1  // = Ndis802_11Infrastructure
-#define BSS_ANY                         2  // = Ndis802_11AutoUnknown
-#define BSS_MONITOR                                3  // = Ndis802_11Monitor
-
-
-// Reason code definitions
-#define REASON_RESERVED                 0
-#define REASON_UNSPECIFY                1
-#define REASON_NO_LONGER_VALID          2
-#define REASON_DEAUTH_STA_LEAVING       3
-#define REASON_DISASSOC_INACTIVE        4
-#define REASON_DISASSPC_AP_UNABLE       5
-#define REASON_CLS2ERR                  6
-#define REASON_CLS3ERR                  7
-#define REASON_DISASSOC_STA_LEAVING     8
-#define REASON_STA_REQ_ASSOC_NOT_AUTH   9
-#define REASON_INVALID_IE               13
-#define REASON_MIC_FAILURE              14
-#define REASON_4_WAY_TIMEOUT            15
-#define REASON_GROUP_KEY_HS_TIMEOUT     16
-#define REASON_IE_DIFFERENT             17
-#define REASON_MCIPHER_NOT_VALID        18
-#define REASON_UCIPHER_NOT_VALID        19
-#define REASON_AKMP_NOT_VALID           20
-#define REASON_UNSUPPORT_RSNE_VER       21
-#define REASON_INVALID_RSNE_CAP         22
-#define REASON_8021X_AUTH_FAIL          23
-#define REASON_CIPHER_SUITE_REJECTED    24
-#define REASON_DECLINED                 37
-
-#define REASON_QOS_UNSPECIFY              32
-#define REASON_QOS_LACK_BANDWIDTH         33
-#define REASON_POOR_CHANNEL_CONDITION     34
-#define REASON_QOS_OUTSIDE_TXOP_LIMITION  35
-#define REASON_QOS_QSTA_LEAVING_QBSS      36
-#define REASON_QOS_UNWANTED_MECHANISM     37
-#define REASON_QOS_MECH_SETUP_REQUIRED    38
-#define REASON_QOS_REQUEST_TIMEOUT        39
-#define REASON_QOS_CIPHER_NOT_SUPPORT     45
-
-// Status code definitions
-#define MLME_SUCCESS                    0
-#define MLME_UNSPECIFY_FAIL             1
-#define MLME_CANNOT_SUPPORT_CAP         10
-#define MLME_REASSOC_DENY_ASSOC_EXIST   11
-#define MLME_ASSOC_DENY_OUT_SCOPE       12
-#define MLME_ALG_NOT_SUPPORT            13
-#define MLME_SEQ_NR_OUT_OF_SEQUENCE     14
-#define MLME_REJ_CHALLENGE_FAILURE      15
-#define MLME_REJ_TIMEOUT                  16
-#define MLME_ASSOC_REJ_UNABLE_HANDLE_STA  17
-#define MLME_ASSOC_REJ_DATA_RATE          18
-
-#define MLME_ASSOC_REJ_NO_EXT_RATE        22
-#define MLME_ASSOC_REJ_NO_EXT_RATE_PBCC   23
-#define MLME_ASSOC_REJ_NO_CCK_OFDM        24
-
-#define MLME_QOS_UNSPECIFY                32
-#define MLME_REQUEST_DECLINED             37
-#define MLME_REQUEST_WITH_INVALID_PARAM   38
-#define MLME_DLS_NOT_ALLOW_IN_QBSS        48
-#define MLME_DEST_STA_NOT_IN_QBSS         49
-#define MLME_DEST_STA_IS_NOT_A_QSTA       50
-
-#define MLME_INVALID_FORMAT             0x51
-#define MLME_FAIL_NO_RESOURCE           0x52
-#define MLME_STATE_MACHINE_REJECT       0x53
-#define MLME_MAC_TABLE_FAIL             0x54
-
-// IE code
-#define IE_SSID                         0
-#define IE_SUPP_RATES                   1
-#define IE_FH_PARM                      2
-#define IE_DS_PARM                      3
-#define IE_CF_PARM                      4
-#define IE_TIM                          5
-#define IE_IBSS_PARM                    6
-#define IE_COUNTRY                      7     // 802.11d
-#define IE_802_11D_REQUEST              10    // 802.11d
-#define IE_QBSS_LOAD                    11    // 802.11e d9
-#define IE_EDCA_PARAMETER               12    // 802.11e d9
-#define IE_TSPEC                        13    // 802.11e d9
-#define IE_TCLAS                        14    // 802.11e d9
-#define IE_SCHEDULE                     15    // 802.11e d9
-#define IE_CHALLENGE_TEXT               16
-#define IE_POWER_CONSTRAINT             32    // 802.11h d3.3
-#define IE_POWER_CAPABILITY             33    // 802.11h d3.3
-#define IE_TPC_REQUEST                  34    // 802.11h d3.3
-#define IE_TPC_REPORT                   35    // 802.11h d3.3
-#define IE_SUPP_CHANNELS                36    // 802.11h d3.3
-#define IE_CHANNEL_SWITCH_ANNOUNCEMENT  37    // 802.11h d3.3
-#define IE_MEASUREMENT_REQUEST          38    // 802.11h d3.3
-#define IE_MEASUREMENT_REPORT           39    // 802.11h d3.3
-#define IE_QUIET                        40    // 802.11h d3.3
-#define IE_IBSS_DFS                     41    // 802.11h d3.3
-#define IE_ERP                          42    // 802.11g
-#define IE_TS_DELAY                     43    // 802.11e d9
-#define IE_TCLAS_PROCESSING             44    // 802.11e d9
-#define IE_QOS_CAPABILITY               46    // 802.11e d6
-#define IE_HT_CAP                       45    // 802.11n d1. HT CAPABILITY. ELEMENT ID TBD
-#define IE_AP_CHANNEL_REPORT                   51    // 802.11k d6
-#define IE_HT_CAP2                         52    // 802.11n d1. HT CAPABILITY. ELEMENT ID TBD
-#define IE_RSN                          48    // 802.11i d3.0
-#define IE_WPA2                         48    // WPA2
-#define IE_EXT_SUPP_RATES               50    // 802.11g
-#define IE_SUPP_REG_CLASS               59    // 802.11y. Supported regulatory classes.
-#define IE_EXT_CHANNEL_SWITCH_ANNOUNCEMENT     60      // 802.11n
-#define IE_ADD_HT                         61    // 802.11n d1. ADDITIONAL HT CAPABILITY. ELEMENT ID TBD
-#define IE_ADD_HT2                        53    // 802.11n d1. ADDITIONAL HT CAPABILITY. ELEMENT ID TBD
-
-
-// For 802.11n D3.03
-//#define IE_NEW_EXT_CHA_OFFSET             62    // 802.11n d1. New extension channel offset elemet
-#define IE_SECONDARY_CH_OFFSET         62      // 802.11n D3.03        Secondary Channel Offset element
-#define IE_WAPI                                                        68              // WAPI information element
-#define IE_2040_BSS_COEXIST               72    // 802.11n D3.0.3
-#define IE_2040_BSS_INTOLERANT_REPORT     73    // 802.11n D3.03
-#define IE_OVERLAPBSS_SCAN_PARM           74    // 802.11n D3.03
-#define IE_EXT_CAPABILITY                127   // 802.11n D3.03
-
-
-#define IE_WPA                          221   // WPA
-#define IE_VENDOR_SPECIFIC              221   // Wifi WMM (WME)
-
-#define OUI_BROADCOM_HT              51   //
-#define OUI_BROADCOM_HTADD              52   //
-#define OUI_PREN_HT_CAP              51   //
-#define OUI_PREN_ADD_HT              52   //
-
-// CCX information
-#define IE_AIRONET_CKIP                 133   // CCX1.0 ID 85H for CKIP
-#define IE_AP_TX_POWER                  150   // CCX 2.0 for AP transmit power
-#define IE_MEASUREMENT_CAPABILITY       221   // CCX 2.0
-#define IE_CCX_V2                       221
-#define IE_AIRONET_IPADDRESS            149   // CCX ID 95H for IP Address
-#define IE_AIRONET_CCKMREASSOC          156   // CCX ID 9CH for CCKM Reassociation Request element
-#define CKIP_NEGOTIATION_LENGTH         30
-#define AIRONET_IPADDRESS_LENGTH        10
-#define AIRONET_CCKMREASSOC_LENGTH      24
-
-// ========================================================
-// MLME state machine definition
-// ========================================================
-
-// STA MLME state mahcines
-#define ASSOC_STATE_MACHINE             1
-#define AUTH_STATE_MACHINE              2
-#define AUTH_RSP_STATE_MACHINE          3
-#define SYNC_STATE_MACHINE              4
-#define MLME_CNTL_STATE_MACHINE         5
-#define WPA_PSK_STATE_MACHINE           6
-#define LEAP_STATE_MACHINE              7
-#define AIRONET_STATE_MACHINE           8
-#define ACTION_STATE_MACHINE           9
-
-// AP MLME state machines
-#define AP_ASSOC_STATE_MACHINE          11
-#define AP_AUTH_STATE_MACHINE           12
-#define AP_AUTH_RSP_STATE_MACHINE       13
-#define AP_SYNC_STATE_MACHINE           14
-#define AP_CNTL_STATE_MACHINE           15
-#define AP_WPA_STATE_MACHINE            16
-
-#define WSC_STATE_MACHINE            17
-#define WSC_UPNP_STATE_MACHINE             18
-
-
-
-//
-// STA's CONTROL/CONNECT state machine: states, events, total function #
-//
-#define CNTL_IDLE                       0
-#define CNTL_WAIT_DISASSOC              1
-#define CNTL_WAIT_JOIN                  2
-#define CNTL_WAIT_REASSOC               3
-#define CNTL_WAIT_START                 4
-#define CNTL_WAIT_AUTH                  5
-#define CNTL_WAIT_ASSOC                 6
-#define CNTL_WAIT_AUTH2                 7
-#define CNTL_WAIT_OID_LIST_SCAN         8
-#define CNTL_WAIT_OID_DISASSOC          9
-#ifdef RT2870
-#define CNTL_WAIT_SCAN_FOR_CONNECT      10
-#endif // RT2870 //
-
-#define MT2_ASSOC_CONF                  34
-#define MT2_AUTH_CONF                   35
-#define MT2_DEAUTH_CONF                 36
-#define MT2_DISASSOC_CONF               37
-#define MT2_REASSOC_CONF                38
-#define MT2_PWR_MGMT_CONF               39
-#define MT2_JOIN_CONF                   40
-#define MT2_SCAN_CONF                   41
-#define MT2_START_CONF                  42
-#define MT2_GET_CONF                    43
-#define MT2_SET_CONF                    44
-#define MT2_RESET_CONF                  45
-#define MT2_MLME_ROAMING_REQ            52
-
-#define CNTL_FUNC_SIZE                  1
-
-//
-// STA's ASSOC state machine: states, events, total function #
-//
-#define ASSOC_IDLE                      0
-#define ASSOC_WAIT_RSP                  1
-#define REASSOC_WAIT_RSP                2
-#define DISASSOC_WAIT_RSP               3
-#define MAX_ASSOC_STATE                 4
-
-#define ASSOC_MACHINE_BASE              0
-#define MT2_MLME_ASSOC_REQ              0
-#define MT2_MLME_REASSOC_REQ            1
-#define MT2_MLME_DISASSOC_REQ           2
-#define MT2_PEER_DISASSOC_REQ           3
-#define MT2_PEER_ASSOC_REQ              4
-#define MT2_PEER_ASSOC_RSP              5
-#define MT2_PEER_REASSOC_REQ            6
-#define MT2_PEER_REASSOC_RSP            7
-#define MT2_DISASSOC_TIMEOUT            8
-#define MT2_ASSOC_TIMEOUT               9
-#define MT2_REASSOC_TIMEOUT             10
-#define MAX_ASSOC_MSG                   11
-
-#define ASSOC_FUNC_SIZE                 (MAX_ASSOC_STATE * MAX_ASSOC_MSG)
-
-//
-// ACT state machine: states, events, total function #
-//
-#define ACT_IDLE                      0
-#define MAX_ACT_STATE                 1
-
-#define ACT_MACHINE_BASE              0
-
-//Those PEER_xx_CATE number is based on real Categary value in IEEE spec. Please don'es modify it by your self.
-//Category
-#define MT2_PEER_SPECTRUM_CATE              0
-#define MT2_PEER_QOS_CATE              1
-#define MT2_PEER_DLS_CATE             2
-#define MT2_PEER_BA_CATE             3
-#define MT2_PEER_PUBLIC_CATE             4
-#define MT2_PEER_RM_CATE             5
-#define MT2_PEER_HT_CATE             7 //      7.4.7
-#define MAX_PEER_CATE_MSG                   7
-#define MT2_MLME_ADD_BA_CATE             8
-#define MT2_MLME_ORI_DELBA_CATE             9
-#define MT2_MLME_REC_DELBA_CATE             10
-#define MT2_MLME_QOS_CATE              11
-#define MT2_MLME_DLS_CATE             12
-#define MT2_ACT_INVALID             13
-#define MAX_ACT_MSG                   14
-
-//Category field
-#define CATEGORY_SPECTRUM              0
-#define CATEGORY_QOS                   1
-#define CATEGORY_DLS                   2
-#define CATEGORY_BA                    3
-#define CATEGORY_PUBLIC                4
-#define CATEGORY_RM                    5
-#define CATEGORY_HT                    7
-
-
-// DLS Action frame definition
-#define ACTION_DLS_REQUEST                     0
-#define ACTION_DLS_RESPONSE                    1
-#define ACTION_DLS_TEARDOWN                    2
-
-//Spectrum  Action field value 802.11h 7.4.1
-#define SPEC_MRQ       0       // Request
-#define SPEC_MRP       1       //Report
-#define SPEC_TPCRQ     2
-#define SPEC_TPCRP     3
-#define SPEC_CHANNEL_SWITCH    4
-
-
-//BA  Action field value
-#define ADDBA_REQ      0
-#define ADDBA_RESP     1
-#define DELBA   2
-
-//Public's  Action field value in Public Category.  Some in 802.11y and some in 11n
-#define ACTION_BSS_2040_COEXIST                                0       // 11n
-#define ACTION_DSE_ENABLEMENT                                  1       // 11y D9.0
-#define ACTION_DSE_DEENABLEMENT                                2       // 11y D9.0
-#define ACTION_DSE_REG_LOCATION_ANNOUNCE       3       // 11y D9.0
-#define ACTION_EXT_CH_SWITCH_ANNOUNCE          4       // 11y D9.0
-#define ACTION_DSE_MEASUREMENT_REQ                     5       // 11y D9.0
-#define ACTION_DSE_MEASUREMENT_REPORT          6       // 11y D9.0
-#define ACTION_MEASUREMENT_PILOT_ACTION                7       // 11y D9.0
-#define ACTION_DSE_POWER_CONSTRAINT                    8       // 11y D9.0
-
-
-//HT  Action field value
-#define NOTIFY_BW_ACTION                               0
-#define SMPS_ACTION                                            1
-#define PSMP_ACTION                                    2
-#define SETPCO_ACTION                                  3
-#define MIMO_CHA_MEASURE_ACTION                        4
-#define MIMO_N_BEACONFORM                              5
-#define MIMO_BEACONFORM                                        6
-#define ANTENNA_SELECT                                 7
-#define HT_INFO_EXCHANGE                               8
-
-#define ACT_FUNC_SIZE                 (MAX_ACT_STATE * MAX_ACT_MSG)
-//
-// STA's AUTHENTICATION state machine: states, evvents, total function #
-//
-#define AUTH_REQ_IDLE                   0
-#define AUTH_WAIT_SEQ2                  1
-#define AUTH_WAIT_SEQ4                  2
-#define MAX_AUTH_STATE                  3
-
-#define AUTH_MACHINE_BASE               0
-#define MT2_MLME_AUTH_REQ               0
-#define MT2_PEER_AUTH_EVEN              1
-#define MT2_AUTH_TIMEOUT                2
-#define MAX_AUTH_MSG                    3
-
-#define AUTH_FUNC_SIZE                  (MAX_AUTH_STATE * MAX_AUTH_MSG)
-
-//
-// STA's AUTH_RSP state machine: states, events, total function #
-//
-#define AUTH_RSP_IDLE                   0
-#define AUTH_RSP_WAIT_CHAL              1
-#define MAX_AUTH_RSP_STATE              2
-
-#define AUTH_RSP_MACHINE_BASE           0
-#define MT2_AUTH_CHALLENGE_TIMEOUT      0
-#define MT2_PEER_AUTH_ODD               1
-#define MT2_PEER_DEAUTH                 2
-#define MAX_AUTH_RSP_MSG                3
-
-#define AUTH_RSP_FUNC_SIZE              (MAX_AUTH_RSP_STATE * MAX_AUTH_RSP_MSG)
-
-//
-// STA's SYNC state machine: states, events, total function #
-//
-#define SYNC_IDLE                       0  // merge NO_BSS,IBSS_IDLE,IBSS_ACTIVE and BSS in to 1 state
-#define JOIN_WAIT_BEACON                1
-#define SCAN_LISTEN                     2
-#define MAX_SYNC_STATE                  3
-
-#define SYNC_MACHINE_BASE               0
-#define MT2_MLME_SCAN_REQ               0
-#define MT2_MLME_JOIN_REQ               1
-#define MT2_MLME_START_REQ              2
-#define MT2_PEER_BEACON                 3
-#define MT2_PEER_PROBE_RSP              4
-#define MT2_PEER_ATIM                   5
-#define MT2_SCAN_TIMEOUT                6
-#define MT2_BEACON_TIMEOUT              7
-#define MT2_ATIM_TIMEOUT                8
-#define MT2_PEER_PROBE_REQ              9
-#define MAX_SYNC_MSG                    10
-
-#define SYNC_FUNC_SIZE                  (MAX_SYNC_STATE * MAX_SYNC_MSG)
-
-//Messages for the DLS state machine
-#define DLS_IDLE                                               0
-#define MAX_DLS_STATE                                  1
-
-#define DLS_MACHINE_BASE                               0
-#define MT2_MLME_DLS_REQ                           0
-#define MT2_PEER_DLS_REQ                           1
-#define MT2_PEER_DLS_RSP                           2
-#define MT2_MLME_DLS_TEAR_DOWN             3
-#define MT2_PEER_DLS_TEAR_DOWN             4
-#define MAX_DLS_MSG                                    5
-
-#define DLS_FUNC_SIZE                                  (MAX_DLS_STATE * MAX_DLS_MSG)
-
-//
-// STA's WPA-PSK State machine: states, events, total function #
-//
-#define WPA_PSK_IDLE                                   0
-#define MAX_WPA_PSK_STATE                              1
-
-#define WPA_MACHINE_BASE                0
-#define MT2_EAPPacket                   0
-#define MT2_EAPOLStart                  1
-#define MT2_EAPOLLogoff                 2
-#define MT2_EAPOLKey                    3
-#define MT2_EAPOLASFAlert               4
-#define MAX_WPA_PSK_MSG                 5
-
-#define        WPA_PSK_FUNC_SIZE                               (MAX_WPA_PSK_STATE * MAX_WPA_PSK_MSG)
-
-//
-// STA's CISCO-AIRONET State machine: states, events, total function #
-//
-#define AIRONET_IDLE                                   0
-#define        AIRONET_SCANNING                                1
-#define MAX_AIRONET_STATE                              2
-
-#define AIRONET_MACHINE_BASE               0
-#define MT2_AIRONET_MSG                                    0
-#define MT2_AIRONET_SCAN_REQ               1
-#define MT2_AIRONET_SCAN_DONE              2
-#define MAX_AIRONET_MSG                                    3
-
-#define        AIRONET_FUNC_SIZE                               (MAX_AIRONET_STATE * MAX_AIRONET_MSG)
-
-//
-// AP's CONTROL/CONNECT state machine: states, events, total function #
-//
-#define AP_CNTL_FUNC_SIZE               1
-
-//
-// AP's ASSOC state machine: states, events, total function #
-//
-#define AP_ASSOC_IDLE                   0
-#define AP_MAX_ASSOC_STATE              1
-
-#define AP_ASSOC_MACHINE_BASE           0
-#define APMT2_MLME_DISASSOC_REQ         0
-#define APMT2_PEER_DISASSOC_REQ         1
-#define APMT2_PEER_ASSOC_REQ            2
-#define APMT2_PEER_REASSOC_REQ          3
-#define APMT2_CLS3ERR                   4
-#define AP_MAX_ASSOC_MSG                5
-
-#define AP_ASSOC_FUNC_SIZE              (AP_MAX_ASSOC_STATE * AP_MAX_ASSOC_MSG)
-
-//
-// AP's AUTHENTICATION state machine: states, events, total function #
-//
-#define AP_AUTH_REQ_IDLE                0
-#define AP_MAX_AUTH_STATE               1
-
-#define AP_AUTH_MACHINE_BASE            0
-#define APMT2_MLME_DEAUTH_REQ           0
-#define APMT2_CLS2ERR                   1
-#define AP_MAX_AUTH_MSG                 2
-
-#define AP_AUTH_FUNC_SIZE               (AP_MAX_AUTH_STATE * AP_MAX_AUTH_MSG)
-
-//
-// AP's AUTH-RSP state machine: states, events, total function #
-//
-#define AP_AUTH_RSP_IDLE                0
-#define AP_MAX_AUTH_RSP_STATE           1
-
-#define AP_AUTH_RSP_MACHINE_BASE        0
-#define APMT2_AUTH_CHALLENGE_TIMEOUT    0
-#define APMT2_PEER_AUTH_ODD             1
-#define APMT2_PEER_DEAUTH               2
-#define AP_MAX_AUTH_RSP_MSG             3
-
-#define AP_AUTH_RSP_FUNC_SIZE           (AP_MAX_AUTH_RSP_STATE * AP_MAX_AUTH_RSP_MSG)
-
-//
-// AP's SYNC state machine: states, events, total function #
-//
-#define AP_SYNC_IDLE                    0
-#define AP_SCAN_LISTEN                                 1
-#define AP_MAX_SYNC_STATE               2
-
-#define AP_SYNC_MACHINE_BASE            0
-#define APMT2_PEER_PROBE_REQ            0
-#define APMT2_PEER_BEACON               1
-#define APMT2_MLME_SCAN_REQ                            2
-#define APMT2_PEER_PROBE_RSP                   3
-#define APMT2_SCAN_TIMEOUT                             4
-#define APMT2_MLME_SCAN_CNCL                   5
-#define AP_MAX_SYNC_MSG                 6
-
-#define AP_SYNC_FUNC_SIZE               (AP_MAX_SYNC_STATE * AP_MAX_SYNC_MSG)
-
-//
-// AP's WPA state machine: states, events, total function #
-//
-#define AP_WPA_PTK                      0
-#define AP_MAX_WPA_PTK_STATE            1
-
-#define AP_WPA_MACHINE_BASE             0
-#define APMT2_EAPPacket                 0
-#define APMT2_EAPOLStart                1
-#define APMT2_EAPOLLogoff               2
-#define APMT2_EAPOLKey                  3
-#define APMT2_EAPOLASFAlert             4
-#define AP_MAX_WPA_MSG                  5
-
-#define AP_WPA_FUNC_SIZE                (AP_MAX_WPA_PTK_STATE * AP_MAX_WPA_MSG)
-
-
-
-// =============================================================================
-
-// value domain of 802.11 header FC.Tyte, which is b3..b2 of the 1st-byte of MAC header
-#define BTYPE_MGMT                  0
-#define BTYPE_CNTL                  1
-#define BTYPE_DATA                  2
-
-// value domain of 802.11 MGMT frame's FC.subtype, which is b7..4 of the 1st-byte of MAC header
-#define SUBTYPE_ASSOC_REQ           0
-#define SUBTYPE_ASSOC_RSP           1
-#define SUBTYPE_REASSOC_REQ         2
-#define SUBTYPE_REASSOC_RSP         3
-#define SUBTYPE_PROBE_REQ           4
-#define SUBTYPE_PROBE_RSP           5
-#define SUBTYPE_BEACON              8
-#define SUBTYPE_ATIM                9
-#define SUBTYPE_DISASSOC            10
-#define SUBTYPE_AUTH                11
-#define SUBTYPE_DEAUTH              12
-#define SUBTYPE_ACTION              13
-#define SUBTYPE_ACTION_NO_ACK              14
-
-// value domain of 802.11 CNTL frame's FC.subtype, which is b7..4 of the 1st-byte of MAC header
-#define SUBTYPE_WRAPPER        7
-#define SUBTYPE_BLOCK_ACK_REQ       8
-#define SUBTYPE_BLOCK_ACK           9
-#define SUBTYPE_PS_POLL             10
-#define SUBTYPE_RTS                 11
-#define SUBTYPE_CTS                 12
-#define SUBTYPE_ACK                 13
-#define SUBTYPE_CFEND               14
-#define SUBTYPE_CFEND_CFACK         15
-
-// value domain of 802.11 DATA frame's FC.subtype, which is b7..4 of the 1st-byte of MAC header
-#define SUBTYPE_DATA                0
-#define SUBTYPE_DATA_CFACK          1
-#define SUBTYPE_DATA_CFPOLL         2
-#define SUBTYPE_DATA_CFACK_CFPOLL   3
-#define SUBTYPE_NULL_FUNC           4
-#define SUBTYPE_CFACK               5
-#define SUBTYPE_CFPOLL              6
-#define SUBTYPE_CFACK_CFPOLL        7
-#define SUBTYPE_QDATA               8
-#define SUBTYPE_QDATA_CFACK         9
-#define SUBTYPE_QDATA_CFPOLL        10
-#define SUBTYPE_QDATA_CFACK_CFPOLL  11
-#define SUBTYPE_QOS_NULL            12
-#define SUBTYPE_QOS_CFACK           13
-#define SUBTYPE_QOS_CFPOLL          14
-#define SUBTYPE_QOS_CFACK_CFPOLL    15
-
-// ACK policy of QOS Control field bit 6:5
-#define NORMAL_ACK                  0x00  // b6:5 = 00
-#define NO_ACK                      0x20  // b6:5 = 01
-#define NO_EXPLICIT_ACK             0x40  // b6:5 = 10
-#define BLOCK_ACK                   0x60  // b6:5 = 11
-
-//
-// rtmp_data.c use these definition
-//
-#define LENGTH_802_11               24
-#define LENGTH_802_11_AND_H         30
-#define LENGTH_802_11_CRC_H         34
-#define LENGTH_802_11_CRC           28
-#define LENGTH_802_11_WITH_ADDR4    30
-#define LENGTH_802_3                14
-#define LENGTH_802_3_TYPE           2
-#define LENGTH_802_1_H              8
-#define LENGTH_EAPOL_H              4
-#define LENGTH_WMMQOS_H                                2
-#define LENGTH_CRC                  4
-#define MAX_SEQ_NUMBER              0x0fff
-#define LENGTH_802_3_NO_TYPE           12
-#define LENGTH_802_1Q                          4 /* VLAN related */
-
-// STA_CSR4.field.TxResult
-#define TX_RESULT_SUCCESS           0
-#define TX_RESULT_ZERO_LENGTH       1
-#define TX_RESULT_UNDER_RUN         2
-#define TX_RESULT_OHY_ERROR         4
-#define TX_RESULT_RETRY_FAIL        6
-
-// All PHY rate summary in TXD
-// Preamble MODE in TxD
-#define MODE_CCK       0
-#define MODE_OFDM   1
-#define MODE_HTMIX     2
-#define MODE_HTGREENFIELD      3
-
-// MCS for CCK.  BW.SGI.STBC are reserved
-#define MCS_LONGP_RATE_1                      0         // long preamble CCK 1Mbps
-#define MCS_LONGP_RATE_2                      1        // long preamble CCK 1Mbps
-#define MCS_LONGP_RATE_5_5                    2
-#define MCS_LONGP_RATE_11                     3
-#define MCS_SHORTP_RATE_1                      4        // long preamble CCK 1Mbps. short is forbidden in 1Mbps
-#define MCS_SHORTP_RATE_2                      5       // short preamble CCK 2Mbps
-#define MCS_SHORTP_RATE_5_5                    6
-#define MCS_SHORTP_RATE_11                     7
-// To send duplicate legacy OFDM. set BW=BW_40.  SGI.STBC are reserved
-#define MCS_RATE_6                      0   // legacy OFDM
-#define MCS_RATE_9                      1   // OFDM
-#define MCS_RATE_12                     2   // OFDM
-#define MCS_RATE_18                     3   // OFDM
-#define MCS_RATE_24                     4  // OFDM
-#define MCS_RATE_36                     5   // OFDM
-#define MCS_RATE_48                     6  // OFDM
-#define MCS_RATE_54                     7 // OFDM
-// HT
-#define MCS_0          0       // 1S
-#define MCS_1          1
-#define MCS_2          2
-#define MCS_3          3
-#define MCS_4          4
-#define MCS_5          5
-#define MCS_6          6
-#define MCS_7          7
-#define MCS_8          8       // 2S
-#define MCS_9          9
-#define MCS_10         10
-#define MCS_11         11
-#define MCS_12         12
-#define MCS_13         13
-#define MCS_14         14
-#define MCS_15         15
-#define MCS_16         16      // 3*3
-#define MCS_17         17
-#define MCS_18         18
-#define MCS_19         19
-#define MCS_20         20
-#define MCS_21         21
-#define MCS_22         22
-#define MCS_23         23
-#define MCS_32         32
-#define MCS_AUTO               33
-
-// OID_HTPHYMODE
-// MODE
-#define HTMODE_MM      0
-#define HTMODE_GF      1
-
-// Fixed Tx MODE - HT, CCK or OFDM
-#define FIXED_TXMODE_HT                0
-#define FIXED_TXMODE_CCK       1
-#define FIXED_TXMODE_OFDM      2
-// BW
-#define BW_20          BAND_WIDTH_20
-#define BW_40          BAND_WIDTH_40
-#define BW_BOTH                BAND_WIDTH_BOTH
-#define BW_10          BAND_WIDTH_10   // 802.11j has 10MHz. This definition is for internal usage. doesn't fill in the IE or other field.
-
-// SHORTGI
-#define GI_400         GAP_INTERVAL_400        // only support in HT mode
-#define GI_BOTH                GAP_INTERVAL_BOTH
-#define GI_800         GAP_INTERVAL_800
-// STBC
-#define STBC_NONE      0
-#define STBC_USE       1       // limited use in rt2860b phy
-#define RXSTBC_ONE     1       // rx support of one spatial stream
-#define RXSTBC_TWO     2       // rx support of 1 and 2 spatial stream
-#define RXSTBC_THR     3       // rx support of 1~3 spatial stream
-// MCS FEEDBACK
-#define MCSFBK_NONE    0  // not support mcs feedback /
-#define MCSFBK_RSV     1       // reserved
-#define MCSFBK_UNSOLICIT       2       // only support unsolict mcs feedback
-#define MCSFBK_MRQ     3       // response to both MRQ and unsolict mcs feedback
-
-// MIMO power safe
-#define        MMPS_STATIC     0
-#define        MMPS_DYNAMIC            1
-#define   MMPS_RSV             2
-#define MMPS_ENABLE            3
-
-
-// A-MSDU size
-#define        AMSDU_0 0
-#define        AMSDU_1         1
-
-// MCS use 7 bits
-#define TXRATEMIMO             0x80
-#define TXRATEMCS              0x7F
-#define TXRATEOFDM             0x7F
-#define RATE_1                      0
-#define RATE_2                      1
-#define RATE_5_5                    2
-#define RATE_11                     3
-#define RATE_6                      4   // OFDM
-#define RATE_9                      5   // OFDM
-#define RATE_12                     6   // OFDM
-#define RATE_18                     7   // OFDM
-#define RATE_24                     8   // OFDM
-#define RATE_36                     9   // OFDM
-#define RATE_48                     10  // OFDM
-#define RATE_54                     11  // OFDM
-#define RATE_FIRST_OFDM_RATE        RATE_6
-#define RATE_LAST_OFDM_RATE            RATE_54
-#define RATE_6_5                    12  // HT mix
-#define RATE_13                     13  // HT mix
-#define RATE_19_5                   14  // HT mix
-#define RATE_26                     15  // HT mix
-#define RATE_39                     16  // HT mix
-#define RATE_52                     17  // HT mix
-#define RATE_58_5                   18  // HT mix
-#define RATE_65                     19  // HT mix
-#define RATE_78                     20  // HT mix
-#define RATE_104                    21  // HT mix
-#define RATE_117                    22  // HT mix
-#define RATE_130                    23  // HT mix
-//#define RATE_AUTO_SWITCH            255 // for StaCfg.FixedTxRate only
-#define HTRATE_0                      12
-#define RATE_FIRST_MM_RATE        HTRATE_0
-#define RATE_FIRST_HT_RATE        HTRATE_0
-#define RATE_LAST_HT_RATE        HTRATE_0
-
-// pTxWI->txop
-#define IFS_HTTXOP                 0   // The txop will be handles by ASIC.
-#define IFS_PIFS                    1
-#define IFS_SIFS                    2
-#define IFS_BACKOFF                 3
-
-// pTxD->RetryMode
-#define LONG_RETRY                  1
-#define SHORT_RETRY                 0
-
-// Country Region definition
-#define REGION_MINIMUM_BG_BAND            0
-#define REGION_0_BG_BAND                  0       // 1-11
-#define REGION_1_BG_BAND                  1       // 1-13
-#define REGION_2_BG_BAND                  2       // 10-11
-#define REGION_3_BG_BAND                  3       // 10-13
-#define REGION_4_BG_BAND                  4       // 14
-#define REGION_5_BG_BAND                  5       // 1-14
-#define REGION_6_BG_BAND                  6       // 3-9
-#define REGION_7_BG_BAND                  7       // 5-13
-#define REGION_31_BG_BAND                 31       // 5-13
-#define REGION_MAXIMUM_BG_BAND            7
-
-#define REGION_MINIMUM_A_BAND             0
-#define REGION_0_A_BAND                   0       // 36, 40, 44, 48, 52, 56, 60, 64, 149, 153, 157, 161, 165
-#define REGION_1_A_BAND                   1       // 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140
-#define REGION_2_A_BAND                   2       // 36, 40, 44, 48, 52, 56, 60, 64
-#define REGION_3_A_BAND                   3       // 52, 56, 60, 64, 149, 153, 157, 161
-#define REGION_4_A_BAND                   4       // 149, 153, 157, 161, 165
-#define REGION_5_A_BAND                   5       // 149, 153, 157, 161
-#define REGION_6_A_BAND                   6       // 36, 40, 44, 48
-#define REGION_7_A_BAND                   7       // 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140, 149, 153, 157, 161, 165
-#define REGION_8_A_BAND                   8       // 52, 56, 60, 64
-#define REGION_9_A_BAND                   9       // 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 132, 136, 140, 149, 153, 157, 161, 165
-#define REGION_10_A_BAND                  10     // 36, 40, 44, 48, 149, 153, 157, 161, 165
-#define REGION_11_A_BAND                  11     // 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 149, 153, 157, 161
-#define REGION_MAXIMUM_A_BAND             11
-
-// pTxD->CipherAlg
-#define CIPHER_NONE                 0
-#define CIPHER_WEP64                1
-#define CIPHER_WEP128               2
-#define CIPHER_TKIP                 3
-#define CIPHER_AES                  4
-#define CIPHER_CKIP64               5
-#define CIPHER_CKIP128              6
-#define CIPHER_TKIP_NO_MIC          7       // MIC appended by driver: not a valid value in hardware key table
-#define CIPHER_SMS4                                    8
-
-// value domain of pAd->RfIcType
-#define RFIC_2820                   1       // 2.4G 2T3R
-#define RFIC_2850                   2       // 2.4G/5G 2T3R
-#define RFIC_2720                   3       // 2.4G 1T2R
-#define RFIC_2750                   4       // 2.4G/5G 1T2R
-#define RFIC_3020                   5       // 2.4G 1T1R
-#define RFIC_2020                   6       // 2.4G B/G
-#define RFIC_3021                   7       // 2.4G 1T2R
-#define RFIC_3022                   8       // 2.4G 2T2R
-
-// LED Status.
-#define LED_LINK_DOWN               0
-#define LED_LINK_UP                 1
-#define LED_RADIO_OFF               2
-#define LED_RADIO_ON                3
-#define LED_HALT                    4
-#define LED_WPS                     5
-#define LED_ON_SITE_SURVEY          6
-#define LED_POWER_UP                7
-
-// value domain of pAd->LedCntl.LedMode and E2PROM
-#define LED_MODE_DEFAULT            0
-#define LED_MODE_TWO_LED                       1
-#define LED_MODE_SIGNAL_STREGTH                8  // EEPROM define =8
-
-// RC4 init value, used fro WEP & TKIP
-#define PPPINITFCS32                0xffffffff   /* Initial FCS value */
-
-// value domain of pAd->StaCfg.PortSecured. 802.1X controlled port definition
-#define WPA_802_1X_PORT_SECURED     1
-#define WPA_802_1X_PORT_NOT_SECURED 2
-
-#define PAIRWISE_KEY                1
-#define GROUP_KEY                   2
-
-//definition of DRS
-#define MAX_STEP_OF_TX_RATE_SWITCH     32
-
-
-// pre-allocated free NDIS PACKET/BUFFER poll for internal usage
-#define MAX_NUM_OF_FREE_NDIS_PACKET 128
-
-//Block ACK
-#define MAX_TX_REORDERBUF   64
-#define MAX_RX_REORDERBUF   64
-#define DEFAULT_TX_TIMEOUT   30
-#define DEFAULT_RX_TIMEOUT   30
-
-// definition of Recipient or Originator
-#define I_RECIPIENT                  TRUE
-#define I_ORIGINATOR                   FALSE
-
-#define DEFAULT_BBP_TX_POWER        0
-#define DEFAULT_RF_TX_POWER         5
-
-#define MAX_INI_BUFFER_SIZE                    4096
-#define MAX_PARAM_BUFFER_SIZE          (2048) // enough for ACL (18*64)
-                                                                                       //18 : the length of Mac address acceptable format "01:02:03:04:05:06;")
-                                                                                       //64 : MAX_NUM_OF_ACL_LIST
-// definition of pAd->OpMode
-#define OPMODE_STA                  0
-#define OPMODE_AP                   1
-//#define OPMODE_L3_BRG               2       // as AP and STA at the same time
-
-// ========================= AP rtmp_def.h ===========================
-// value domain for pAd->EventTab.Log[].Event
-#define EVENT_RESET_ACCESS_POINT    0 // Log = "hh:mm:ss   Restart Access Point"
-#define EVENT_ASSOCIATED            1 // Log = "hh:mm:ss   STA 00:01:02:03:04:05 associated"
-#define EVENT_DISASSOCIATED         2 // Log = "hh:mm:ss   STA 00:01:02:03:04:05 left this BSS"
-#define EVENT_AGED_OUT              3 // Log = "hh:mm:ss   STA 00:01:02:03:04:05 was aged-out and removed from this BSS"
-#define EVENT_COUNTER_M             4
-#define EVENT_INVALID_PSK           5
-#define EVENT_MAX_EVENT_TYPE        6
-// ==== end of AP rtmp_def.h ============
-
-// definition RSSI Number
-#define RSSI_0                                 0
-#define RSSI_1                                 1
-#define RSSI_2                                 2
-
-// definition of radar detection
-#define RD_NORMAL_MODE                         0       // Not found radar signal
-#define RD_SWITCHING_MODE                      1       // Found radar signal, and doing channel switch
-#define RD_SILENCE_MODE                                2       // After channel switch, need to be silence a while to ensure radar not found
-
-//Driver defined cid for mapping status and command.
-#define  SLEEPCID      0x11
-#define  WAKECID       0x22
-#define  QUERYPOWERCID 0x33
-#define  OWNERMCU      0x1
-#define  OWNERCPU      0x0
-
-// MBSSID definition
-#define ENTRY_NOT_FOUND             0xFF
-
-
-/* After Linux 2.6.9,
- * VLAN module use Private (from user) interface flags (netdevice->priv_flags).
- * #define IFF_802_1Q_VLAN 0x1         --    802.1Q VLAN device.  in if.h
- * ref to ip_sabotage_out() [ out->priv_flags & IFF_802_1Q_VLAN ] in br_netfilter.c
- *
- * For this reason, we MUST use EVEN value in priv_flags
- */
-#define INT_MAIN                    0x0100
-#define INT_MBSSID                  0x0200
-#define INT_WDS                     0x0300
-#define INT_APCLI                   0x0400
-#define INT_MESH                       0x0500
-
-// Use bitmap to allow coexist of ATE_TXFRAME and ATE_RXFRAME(i.e.,to support LoopBack mode)
-
-// WEP Key TYPE
-#define WEP_HEXADECIMAL_TYPE    0
-#define WEP_ASCII_TYPE          1
-
-
-
-// WIRELESS EVENTS definition
-/* Max number of char in custom event, refer to wireless_tools.28/wireless.20.h */
-#define IW_CUSTOM_MAX_LEN                                                      255     /* In bytes */
-
-// For system event - start
-#define        IW_SYS_EVENT_FLAG_START                     0x0200
-#define        IW_ASSOC_EVENT_FLAG                         0x0200
-#define        IW_DISASSOC_EVENT_FLAG                      0x0201
-#define        IW_DEAUTH_EVENT_FLAG                            0x0202
-#define        IW_AGEOUT_EVENT_FLAG                            0x0203
-#define        IW_COUNTER_MEASURES_EVENT_FLAG              0x0204
-#define        IW_REPLAY_COUNTER_DIFF_EVENT_FLAG           0x0205
-#define        IW_RSNIE_DIFF_EVENT_FLAG                                0x0206
-#define        IW_MIC_DIFF_EVENT_FLAG                                  0x0207
-#define IW_ICV_ERROR_EVENT_FLAG                                                0x0208
-#define IW_MIC_ERROR_EVENT_FLAG                                                0x0209
-#define IW_GROUP_HS_TIMEOUT_EVENT_FLAG                         0x020A
-#define        IW_PAIRWISE_HS_TIMEOUT_EVENT_FLAG                       0x020B
-#define IW_RSNIE_SANITY_FAIL_EVENT_FLAG                                0x020C
-#define IW_SET_KEY_DONE_WPA1_EVENT_FLAG                                0x020D
-#define IW_SET_KEY_DONE_WPA2_EVENT_FLAG                                0x020E
-#define IW_STA_LINKUP_EVENT_FLAG                                       0x020F
-#define IW_STA_LINKDOWN_EVENT_FLAG                                     0x0210
-#define IW_SCAN_COMPLETED_EVENT_FLAG                           0x0211
-#define IW_SCAN_ENQUEUE_FAIL_EVENT_FLAG                                0x0212
-// if add new system event flag, please upadte the IW_SYS_EVENT_FLAG_END
-#define        IW_SYS_EVENT_FLAG_END                       0x0212
-#define        IW_SYS_EVENT_TYPE_NUM                                           (IW_SYS_EVENT_FLAG_END - IW_SYS_EVENT_FLAG_START + 1)
-// For system event - end
-
-// For spoof attack event - start
-#define        IW_SPOOF_EVENT_FLAG_START                   0x0300
-#define IW_CONFLICT_SSID_EVENT_FLAG                                    0x0300
-#define IW_SPOOF_ASSOC_RESP_EVENT_FLAG                         0x0301
-#define IW_SPOOF_REASSOC_RESP_EVENT_FLAG                       0x0302
-#define IW_SPOOF_PROBE_RESP_EVENT_FLAG                         0x0303
-#define IW_SPOOF_BEACON_EVENT_FLAG                                     0x0304
-#define IW_SPOOF_DISASSOC_EVENT_FLAG                           0x0305
-#define IW_SPOOF_AUTH_EVENT_FLAG                                       0x0306
-#define IW_SPOOF_DEAUTH_EVENT_FLAG                                     0x0307
-#define IW_SPOOF_UNKNOWN_MGMT_EVENT_FLAG                       0x0308
-#define IW_REPLAY_ATTACK_EVENT_FLAG                                    0x0309
-// if add new spoof attack event flag, please upadte the IW_SPOOF_EVENT_FLAG_END
-#define        IW_SPOOF_EVENT_FLAG_END                     0x0309
-#define        IW_SPOOF_EVENT_TYPE_NUM                                         (IW_SPOOF_EVENT_FLAG_END - IW_SPOOF_EVENT_FLAG_START + 1)
-// For spoof attack event - end
-
-// For flooding attack event - start
-#define        IW_FLOOD_EVENT_FLAG_START                   0x0400
-#define IW_FLOOD_AUTH_EVENT_FLAG                                       0x0400
-#define IW_FLOOD_ASSOC_REQ_EVENT_FLAG                          0x0401
-#define IW_FLOOD_REASSOC_REQ_EVENT_FLAG                                0x0402
-#define IW_FLOOD_PROBE_REQ_EVENT_FLAG                          0x0403
-#define IW_FLOOD_DISASSOC_EVENT_FLAG                           0x0404
-#define IW_FLOOD_DEAUTH_EVENT_FLAG                                     0x0405
-#define IW_FLOOD_EAP_REQ_EVENT_FLAG                                    0x0406
-// if add new flooding attack event flag, please upadte the IW_FLOOD_EVENT_FLAG_END
-#define        IW_FLOOD_EVENT_FLAG_END                         0x0406
-#define        IW_FLOOD_EVENT_TYPE_NUM                                         (IW_FLOOD_EVENT_FLAG_END - IW_FLOOD_EVENT_FLAG_START + 1)
-// For flooding attack - end
-
-// End - WIRELESS EVENTS definition
-
-// definition for DLS, kathy
-#define        MAX_NUM_OF_INIT_DLS_ENTRY   1
-#define        MAX_NUM_OF_DLS_ENTRY        MAX_NUMBER_OF_DLS_ENTRY
-
-//Block ACK , rt2860, kathy
-#define MAX_TX_REORDERBUF              64
-#define MAX_RX_REORDERBUF              64
-#define DEFAULT_TX_TIMEOUT             30
-#define DEFAULT_RX_TIMEOUT             30
-#define MAX_BARECI_SESSION             8
-
-#ifndef IW_ESSID_MAX_SIZE
-/* Maximum size of the ESSID and pAd->nickname strings */
-#define IW_ESSID_MAX_SIZE              32
-#endif
-
-#ifdef MCAST_RATE_SPECIFIC
-#define MCAST_DISABLE  0
-#define MCAST_CCK              1
-#define MCAST_OFDM             2
-#define MCAST_HTMIX            3
-#endif // MCAST_RATE_SPECIFIC //
-
-// For AsicRadioOff/AsicRadioOn function
-#define DOT11POWERSAVE         0
-#define GUIRADIO_OFF           1
-#define RTMP_HALT                  2
-#define GUI_IDLE_POWER_SAVE            3
-// --
-
-
-// definition for WpaSupport flag
-#define WPA_SUPPLICANT_DISABLE                         0
-#define WPA_SUPPLICANT_ENABLE                          1
-#define        WPA_SUPPLICANT_ENABLE_WITH_WEB_UI       2
-
-// Endian byte swapping codes
-#define SWAP16(x) \
-    ((UINT16)( \
-    (((UINT16)(x) & (UINT16) 0x00ffU) << 8) | \
-    (((UINT16)(x) & (UINT16) 0xff00U) >> 8) ))
-
-#define SWAP32(x) \
-    ((UINT32)( \
-    (((UINT32)(x) & (UINT32) 0x000000ffUL) << 24) | \
-    (((UINT32)(x) & (UINT32) 0x0000ff00UL) <<  8) | \
-    (((UINT32)(x) & (UINT32) 0x00ff0000UL) >>  8) | \
-    (((UINT32)(x) & (UINT32) 0xff000000UL) >> 24) ))
-
-#define SWAP64(x) \
-    ((UINT64)( \
-    (UINT64)(((UINT64)(x) & (UINT64) 0x00000000000000ffULL) << 56) | \
-    (UINT64)(((UINT64)(x) & (UINT64) 0x000000000000ff00ULL) << 40) | \
-    (UINT64)(((UINT64)(x) & (UINT64) 0x0000000000ff0000ULL) << 24) | \
-    (UINT64)(((UINT64)(x) & (UINT64) 0x00000000ff000000ULL) <<  8) | \
-    (UINT64)(((UINT64)(x) & (UINT64) 0x000000ff00000000ULL) >>  8) | \
-    (UINT64)(((UINT64)(x) & (UINT64) 0x0000ff0000000000ULL) >> 24) | \
-    (UINT64)(((UINT64)(x) & (UINT64) 0x00ff000000000000ULL) >> 40) | \
-    (UINT64)(((UINT64)(x) & (UINT64) 0xff00000000000000ULL) >> 56) ))
-
-#define cpu2le64(x) ((UINT64)(x))
-#define le2cpu64(x) ((UINT64)(x))
-#define cpu2le32(x) ((UINT32)(x))
-#define le2cpu32(x) ((UINT32)(x))
-#define cpu2le16(x) ((UINT16)(x))
-#define le2cpu16(x) ((UINT16)(x))
-#define cpu2be64(x) SWAP64((x))
-#define be2cpu64(x) SWAP64((x))
-#define cpu2be32(x) SWAP32((x))
-#define be2cpu32(x) SWAP32((x))
-#define cpu2be16(x) SWAP16((x))
-#define be2cpu16(x) SWAP16((x))
-
-#endif  // __RTMP_DEF_H__
-
-
+#include "../rt2870/rtmp_def.h"
index 4e4b168b9e92c5eba7eadf6057a5b4fed41a8121..42384e50679f3a89955d45c63098e35c30c6b5b8 100644 (file)
@@ -1,95 +1 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify  *
- * it under the terms of the GNU General Public License as published by  *
- * the Free Software Foundation; either version 2 of the License, or     *
- * (at your option) any later version.                                   *
- *                                                                       *
- * 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.                          *
- *                                                                       *
- * You should have received a copy of the GNU General Public License     *
- * along with this program; if not, write to the                         *
- * Free Software Foundation, Inc.,                                       *
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- *                                                                       *
- *************************************************************************
-
-    Module Name:
-    rtmp_type.h
-
-    Abstract:
-
-    Revision History:
-    Who         When            What
-    --------    ----------      ----------------------------------------------
-    Name        Date            Modification logs
-    Paul Lin    1-2-2004
-*/
-#ifndef __RTMP_TYPE_H__
-#define __RTMP_TYPE_H__
-
-
-#define PACKED  __attribute__ ((packed))
-
-// Put platform dependent declaration here
-// For example, linux type definition
-typedef unsigned char          UINT8;
-typedef unsigned short         UINT16;
-typedef unsigned int           UINT32;
-typedef unsigned long long     UINT64;
-typedef int                                    INT32;
-typedef long long                      INT64;
-
-typedef unsigned char *                        PUINT8;
-typedef unsigned short *               PUINT16;
-typedef unsigned int *                 PUINT32;
-typedef unsigned long long *   PUINT64;
-typedef int    *                                       PINT32;
-typedef long long *                    PINT64;
-
-typedef signed char                    CHAR;
-typedef signed short           SHORT;
-typedef signed int                     INT;
-typedef signed long                    LONG;
-typedef signed long long       LONGLONG;
-
-
-typedef unsigned char          UCHAR;
-typedef unsigned short         USHORT;
-typedef unsigned int           UINT;
-typedef unsigned long          ULONG;
-typedef unsigned long long     ULONGLONG;
-
-typedef unsigned char          BOOLEAN;
-typedef void                           VOID;
-
-typedef VOID *                         PVOID;
-typedef CHAR *                         PCHAR;
-typedef UCHAR *                        PUCHAR;
-typedef USHORT *                       PUSHORT;
-typedef LONG *                         PLONG;
-typedef ULONG *                                PULONG;
-typedef UINT *                         PUINT;
-
-typedef unsigned int   NDIS_MEDIA_STATE;
-
-typedef union _LARGE_INTEGER {
-    struct {
-        UINT LowPart;
-        INT32 HighPart;
-    } u;
-    INT64 QuadPart;
-} LARGE_INTEGER;
-
-#endif  // __RTMP_TYPE_H__
-
+#include "../rt2870/rtmp_type.h"
index 95e0b0ebfe9bb691a3af5fc3432aebc955374681..1ca9c2584bffe3deda28671c578b3987a59af7b0 100644 (file)
@@ -1,292 +1 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify  *
- * it under the terms of the GNU General Public License as published by  *
- * the Free Software Foundation; either version 2 of the License, or     *
- * (at your option) any later version.                                   *
- *                                                                       *
- * 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.                          *
- *                                                                       *
- * You should have received a copy of the GNU General Public License     *
- * along with this program; if not, write to the                         *
- * Free Software Foundation, Inc.,                                       *
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- *                                                                       *
- *************************************************************************
- */
-
-#ifndef __SPECTRUM_H__
-#define __SPECTRUM_H__
-
-#include "rtmp_type.h"
-#include "spectrum_def.h"
-
-typedef struct PACKED _TPC_REPORT_INFO
-{
-       UINT8 TxPwr;
-       UINT8 LinkMargin;
-} TPC_REPORT_INFO, *PTPC_REPORT_INFO;
-
-typedef struct PACKED _CH_SW_ANN_INFO
-{
-       UINT8 ChSwMode;
-       UINT8 Channel;
-       UINT8 ChSwCnt;
-} CH_SW_ANN_INFO, *PCH_SW_ANN_INFO;
-
-typedef union PACKED _MEASURE_REQ_MODE
-{
-       struct PACKED
-       {
-               UINT8 Rev0:1;
-               UINT8 Enable:1;
-               UINT8 Request:1;
-               UINT8 Report:1;
-               UINT8 Rev1:4;
-       } field;
-       UINT8 word;
-} MEASURE_REQ_MODE, *PMEASURE_REQ_MODE;
-
-typedef struct PACKED _MEASURE_REQ
-{
-       UINT8 ChNum;
-       UINT64 MeasureStartTime;
-       UINT16 MeasureDuration;
-} MEASURE_REQ, *PMEASURE_REQ;
-
-typedef struct PACKED _MEASURE_REQ_INFO
-{
-       UINT8 Token;
-       MEASURE_REQ_MODE ReqMode;
-       UINT8 ReqType;
-       MEASURE_REQ MeasureReq;
-} MEASURE_REQ_INFO, *PMEASURE_REQ_INFO;
-
-typedef union PACKED _MEASURE_BASIC_REPORT_MAP
-{
-       struct PACKED
-       {
-               UINT8 BSS:1;
-               UINT8 OfdmPreamble:1;
-               UINT8 UnidentifiedSignal:1;
-               UINT8 Radar:1;
-               UINT8 Unmeasure:1;
-               UINT8 Rev:3;
-       } field;
-       UINT8 word;
-} MEASURE_BASIC_REPORT_MAP, *PMEASURE_BASIC_REPORT_MAP;
-
-typedef struct PACKED _MEASURE_BASIC_REPORT
-{
-       UINT8 ChNum;
-       UINT64 MeasureStartTime;
-       UINT16 MeasureDuration;
-       MEASURE_BASIC_REPORT_MAP Map;
-} MEASURE_BASIC_REPORT, *PMEASURE_BASIC_REPORT;
-
-typedef struct PACKED _MEASURE_CCA_REPORT
-{
-       UINT8 ChNum;
-       UINT64 MeasureStartTime;
-       UINT16 MeasureDuration;
-       UINT8 CCA_Busy_Fraction;
-} MEASURE_CCA_REPORT, *PMEASURE_CCA_REPORT;
-
-typedef struct PACKED _MEASURE_RPI_REPORT
-{
-       UINT8 ChNum;
-       UINT64 MeasureStartTime;
-       UINT16 MeasureDuration;
-       UINT8 RPI_Density[8];
-} MEASURE_RPI_REPORT, *PMEASURE_RPI_REPORT;
-
-typedef union PACKED _MEASURE_REPORT_MODE
-{
-       struct PACKED
-       {
-               UINT8 Late:1;
-               UINT8 Incapable:1;
-               UINT8 Refused:1;
-               UINT8 Rev:5;
-       } field;
-       UINT8 word;
-} MEASURE_REPORT_MODE, *PMEASURE_REPORT_MODE;
-
-typedef struct PACKED _MEASURE_REPORT_INFO
-{
-       UINT8 Token;
-       MEASURE_REPORT_MODE ReportMode;
-       UINT8 ReportType;
-       UINT8 Octect[0];
-} MEASURE_REPORT_INFO, *PMEASURE_REPORT_INFO;
-
-typedef struct PACKED _QUIET_INFO
-{
-       UINT8 QuietCnt;
-       UINT8 QuietPeriod;
-       UINT8 QuietDuration;
-       UINT8 QuietOffset;
-} QUIET_INFO, *PQUIET_INFO;
-
-/*
-       ==========================================================================
-       Description:
-               Prepare Measurement request action frame and enqueue it into
-               management queue waiting for transmition.
-
-       Parametrs:
-               1. the destination mac address of the frame.
-
-       Return  : None.
-       ==========================================================================
- */
-VOID EnqueueMeasurementReq(
-       IN PRTMP_ADAPTER pAd,
-       IN PUCHAR pDA,
-       IN UINT8 MeasureToken,
-       IN UINT8 MeasureReqMode,
-       IN UINT8 MeasureReqType,
-       IN UINT8 MeasureCh,
-       IN UINT16 MeasureDuration);
-
-/*
-       ==========================================================================
-       Description:
-               Prepare Measurement report action frame and enqueue it into
-               management queue waiting for transmition.
-
-       Parametrs:
-               1. the destination mac address of the frame.
-
-       Return  : None.
-       ==========================================================================
- */
-VOID EnqueueMeasurementRep(
-       IN PRTMP_ADAPTER pAd,
-       IN PUCHAR pDA,
-       IN UINT8 DialogToken,
-       IN UINT8 MeasureToken,
-       IN UINT8 MeasureReqMode,
-       IN UINT8 MeasureReqType,
-       IN UINT8 ReportInfoLen,
-       IN PUINT8 pReportInfo);
-
-/*
-       ==========================================================================
-       Description:
-               Prepare TPC Request action frame and enqueue it into
-               management queue waiting for transmition.
-
-       Parametrs:
-               1. the destination mac address of the frame.
-
-       Return  : None.
-       ==========================================================================
- */
-VOID EnqueueTPCReq(
-       IN PRTMP_ADAPTER pAd,
-       IN PUCHAR pDA,
-       IN UCHAR DialogToken);
-
-/*
-       ==========================================================================
-       Description:
-               Prepare TPC Report action frame and enqueue it into
-               management queue waiting for transmition.
-
-       Parametrs:
-               1. the destination mac address of the frame.
-
-       Return  : None.
-       ==========================================================================
- */
-VOID EnqueueTPCRep(
-       IN PRTMP_ADAPTER pAd,
-       IN PUCHAR pDA,
-       IN UINT8 DialogToken,
-       IN UINT8 TxPwr,
-       IN UINT8 LinkMargin);
-
-/*
-       ==========================================================================
-       Description:
-               Prepare Channel Switch Announcement action frame and enqueue it into
-               management queue waiting for transmition.
-
-       Parametrs:
-               1. the destination mac address of the frame.
-               2. Channel switch announcement mode.
-               2. a New selected channel.
-
-       Return  : None.
-       ==========================================================================
- */
-VOID EnqueueChSwAnn(
-       IN PRTMP_ADAPTER pAd,
-       IN PUCHAR pDA,
-       IN UINT8 ChSwMode,
-       IN UINT8 NewCh);
-
-/*
-       ==========================================================================
-       Description:
-               Spectrun action frames Handler such as channel switch annoucement,
-               measurement report, measurement request actions frames.
-
-       Parametrs:
-               Elme - MLME message containing the received frame
-
-       Return  : None.
-       ==========================================================================
- */
-VOID PeerSpectrumAction(
-    IN PRTMP_ADAPTER pAd,
-    IN MLME_QUEUE_ELEM *Elem);
-
-/*
-       ==========================================================================
-       Description:
-
-       Parametrs:
-
-       Return  : None.
-       ==========================================================================
- */
-INT Set_MeasureReq_Proc(
-       IN      PRTMP_ADAPTER   pAd,
-       IN      PUCHAR                  arg);
-
-INT Set_TpcReq_Proc(
-       IN      PRTMP_ADAPTER   pAd,
-       IN      PUCHAR                  arg);
-
-VOID MeasureReqTabInit(
-       IN PRTMP_ADAPTER pAd);
-
-VOID MeasureReqTabExit(
-       IN PRTMP_ADAPTER pAd);
-
-VOID TpcReqTabInit(
-       IN PRTMP_ADAPTER pAd);
-
-VOID TpcReqTabExit(
-       IN PRTMP_ADAPTER pAd);
-
-VOID NotifyChSwAnnToPeerAPs(
-       IN PRTMP_ADAPTER pAd,
-       IN PUCHAR pRA,
-       IN PUCHAR pTA,
-       IN UINT8 ChSwMode,
-       IN UINT8 Channel);
-#endif // __SPECTRUM_H__ //
-
+#include "../rt2870/spectrum.h"
index 4ca4817bba050ba716a3e605f58385eef68330a6..892bc88c65f5d5db91fe0c82bf6ae25fa733d850 100644 (file)
@@ -1,95 +1 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify  *
- * it under the terms of the GNU General Public License as published by  *
- * the Free Software Foundation; either version 2 of the License, or     *
- * (at your option) any later version.                                   *
- *                                                                       *
- * 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.                          *
- *                                                                       *
- * You should have received a copy of the GNU General Public License     *
- * along with this program; if not, write to the                         *
- * Free Software Foundation, Inc.,                                       *
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- *                                                                       *
- *************************************************************************
-
-    Module Name:
-       spectrum_def.h
-
-    Abstract:
-    Handle association related requests either from WSTA or from local MLME
-
-    Revision History:
-    Who          When          What
-    ---------    ----------    ----------------------------------------------
-       Fonchi Wu    2008                  created for 802.11h
- */
-
-#ifndef __SPECTRUM_DEF_H__
-#define __SPECTRUM_DEF_H__
-
-#define MAX_MEASURE_REQ_TAB_SIZE               3
-#define MAX_HASH_MEASURE_REQ_TAB_SIZE  MAX_MEASURE_REQ_TAB_SIZE
-
-#define MAX_TPC_REQ_TAB_SIZE                   3
-#define MAX_HASH_TPC_REQ_TAB_SIZE              MAX_TPC_REQ_TAB_SIZE
-
-#define MIN_RCV_PWR                            100             /* Negative value ((dBm) */
-
-#define RM_TPC_REQ                             0
-#define RM_MEASURE_REQ                 1
-
-#define RM_BASIC                               0
-#define RM_CCA                                 1
-#define RM_RPI_HISTOGRAM               2
-
-#define TPC_REQ_AGE_OUT                        500             /* ms */
-#define MQ_REQ_AGE_OUT                 500             /* ms */
-
-#define TPC_DIALOGTOKEN_HASH_INDEX(_DialogToken)       ((_DialogToken) % MAX_HASH_TPC_REQ_TAB_SIZE)
-#define MQ_DIALOGTOKEN_HASH_INDEX(_DialogToken)                ((_DialogToken) % MAX_MEASURE_REQ_TAB_SIZE)
-
-typedef struct _MEASURE_REQ_ENTRY
-{
-       struct _MEASURE_REQ_ENTRY *pNext;
-       ULONG lastTime;
-       BOOLEAN Valid;
-       UINT8 DialogToken;
-       UINT8 MeasureDialogToken[3];    // 0:basic measure, 1: CCA measure, 2: RPI_Histogram measure.
-} MEASURE_REQ_ENTRY, *PMEASURE_REQ_ENTRY;
-
-typedef struct _MEASURE_REQ_TAB
-{
-       UCHAR Size;
-       PMEASURE_REQ_ENTRY Hash[MAX_HASH_MEASURE_REQ_TAB_SIZE];
-       MEASURE_REQ_ENTRY Content[MAX_MEASURE_REQ_TAB_SIZE];
-} MEASURE_REQ_TAB, *PMEASURE_REQ_TAB;
-
-typedef struct _TPC_REQ_ENTRY
-{
-       struct _TPC_REQ_ENTRY *pNext;
-       ULONG lastTime;
-       BOOLEAN Valid;
-       UINT8 DialogToken;
-} TPC_REQ_ENTRY, *PTPC_REQ_ENTRY;
-
-typedef struct _TPC_REQ_TAB
-{
-       UCHAR Size;
-       PTPC_REQ_ENTRY Hash[MAX_HASH_TPC_REQ_TAB_SIZE];
-       TPC_REQ_ENTRY Content[MAX_TPC_REQ_TAB_SIZE];
-} TPC_REQ_TAB, *PTPC_REQ_TAB;
-
-#endif // __SPECTRUM_DEF_H__ //
-
+#include "../rt2870/spectrum_def.h"
index 40405ea7c5f08ae16eebfac70a83c9af1b97163f..ac56507e3c8fdbf66113f425db02b11e2348f893 100644 (file)
@@ -1,6520 +1 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify  *
- * it under the terms of the GNU General Public License as published by  *
- * the Free Software Foundation; either version 2 of the License, or     *
- * (at your option) any later version.                                   *
- *                                                                       *
- * 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.                          *
- *                                                                       *
- * You should have received a copy of the GNU General Public License     *
- * along with this program; if not, write to the                         *
- * Free Software Foundation, Inc.,                                       *
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- *                                                                       *
- *************************************************************************
-
-    Module Name:
-    sta_ioctl.c
-
-    Abstract:
-    IOCTL related subroutines
-
-    Revision History:
-    Who         When          What
-    --------    ----------    ----------------------------------------------
-    Rory Chen   01-03-2003    created
-       Rory Chen   02-14-2005    modify to support RT61
-*/
-
-#include       "rt_config.h"
-
-#ifdef DBG
-extern ULONG    RTDebugLevel;
-#endif
-
-#define NR_WEP_KEYS                            4
-#define WEP_SMALL_KEY_LEN                      (40/8)
-#define WEP_LARGE_KEY_LEN                      (104/8)
-
-#define GROUP_KEY_NO                4
-
-extern UCHAR    CipherWpa2Template[];
-extern UCHAR    CipherWpaPskTkip[];
-extern UCHAR    CipherWpaPskTkipLen;
-
-typedef struct PACKED _RT_VERSION_INFO{
-    UCHAR       DriverVersionW;
-    UCHAR       DriverVersionX;
-    UCHAR       DriverVersionY;
-    UCHAR       DriverVersionZ;
-    UINT        DriverBuildYear;
-    UINT        DriverBuildMonth;
-    UINT        DriverBuildDay;
-} RT_VERSION_INFO, *PRT_VERSION_INFO;
-
-struct iw_priv_args privtab[] = {
-{ RTPRIV_IOCTL_SET,
-  IW_PRIV_TYPE_CHAR | 1024, 0,
-  "set"},
-
-{ RTPRIV_IOCTL_SHOW, 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK,
-  ""},
-{ RTPRIV_IOCTL_SHOW, IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK,
-  ""},
-/* --- sub-ioctls definitions --- */
-    { SHOW_CONN_STATUS,
-         0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "connStatus" },
-       { SHOW_DRVIER_VERION,
-         0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "driverVer" },
-    { SHOW_BA_INFO,
-         0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "bainfo" },
-       { SHOW_DESC_INFO,
-         0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "descinfo" },
-    { RAIO_OFF,
-         0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "radio_off" },
-       { RAIO_ON,
-         0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "radio_on" },
-       { SHOW_CFG_VALUE,
-         IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "show" },
-/* --- sub-ioctls relations --- */
-
-#ifdef DBG
-{ RTPRIV_IOCTL_BBP,
-  IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK,
-  "bbp"},
-{ RTPRIV_IOCTL_MAC,
-  IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | 1024,
-  "mac"},
-#ifdef RT30xx
-{ RTPRIV_IOCTL_RF,
-  IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK,
-  "rf"},
-#endif // RT30xx //
-{ RTPRIV_IOCTL_E2P,
-  IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | 1024,
-  "e2p"},
-#endif  /* DBG */
-
-{ RTPRIV_IOCTL_STATISTICS,
-  0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK,
-  "stat"},
-{ RTPRIV_IOCTL_GSITESURVEY,
-  0, IW_PRIV_TYPE_CHAR | 1024,
-  "get_site_survey"},
-
-
-};
-
-INT Set_SSID_Proc(
-    IN  PRTMP_ADAPTER   pAdapter,
-    IN  PUCHAR          arg);
-
-#ifdef WMM_SUPPORT
-INT    Set_WmmCapable_Proc(
-       IN      PRTMP_ADAPTER   pAd,
-       IN      PUCHAR                  arg);
-#endif
-
-INT Set_NetworkType_Proc(
-    IN  PRTMP_ADAPTER   pAdapter,
-    IN  PUCHAR          arg);
-
-INT Set_AuthMode_Proc(
-    IN  PRTMP_ADAPTER   pAdapter,
-    IN  PUCHAR          arg);
-
-INT Set_EncrypType_Proc(
-    IN  PRTMP_ADAPTER   pAdapter,
-    IN  PUCHAR          arg);
-
-INT Set_DefaultKeyID_Proc(
-    IN  PRTMP_ADAPTER   pAdapter,
-    IN  PUCHAR          arg);
-
-INT Set_Key1_Proc(
-    IN  PRTMP_ADAPTER   pAdapter,
-    IN  PUCHAR          arg);
-
-INT Set_Key2_Proc(
-    IN  PRTMP_ADAPTER   pAdapter,
-    IN  PUCHAR          arg);
-
-INT Set_Key3_Proc(
-    IN  PRTMP_ADAPTER   pAdapter,
-    IN  PUCHAR          arg);
-
-INT Set_Key4_Proc(
-    IN  PRTMP_ADAPTER   pAdapter,
-    IN  PUCHAR          arg);
-
-INT Set_WPAPSK_Proc(
-    IN  PRTMP_ADAPTER   pAdapter,
-    IN  PUCHAR          arg);
-
-
-INT Set_PSMode_Proc(
-    IN  PRTMP_ADAPTER   pAdapter,
-    IN  PUCHAR          arg);
-
-INT Set_Wpa_Support(
-    IN PRTMP_ADAPTER   pAd,
-       IN      PUCHAR                  arg);
-
-#ifdef DBG
-
-VOID RTMPIoctlMAC(
-       IN      PRTMP_ADAPTER   pAdapter,
-       IN      struct iwreq    *wrq);
-
-VOID RTMPIoctlE2PROM(
-    IN  PRTMP_ADAPTER   pAdapter,
-    IN  struct iwreq    *wrq);
-
-#ifdef RT30xx
-VOID RTMPIoctlRF(
-    IN  PRTMP_ADAPTER   pAdapter,
-    IN  struct iwreq    *wrq);
-#endif // RT30xx //
-#endif // DBG //
-
-
-NDIS_STATUS RTMPWPANoneAddKeyProc(
-    IN  PRTMP_ADAPTER   pAd,
-    IN PVOID                   pBuf);
-
-INT Set_FragTest_Proc(
-    IN  PRTMP_ADAPTER   pAdapter,
-    IN  PUCHAR          arg);
-
-INT Set_TGnWifiTest_Proc(
-    IN  PRTMP_ADAPTER   pAd,
-    IN  PUCHAR          arg);
-
-INT Set_LongRetryLimit_Proc(
-       IN      PRTMP_ADAPTER   pAdapter,
-       IN      PUCHAR                  arg);
-
-INT Set_ShortRetryLimit_Proc(
-       IN      PRTMP_ADAPTER   pAdapter,
-       IN      PUCHAR                  arg);
-
-static struct {
-       CHAR *name;
-       INT (*set_proc)(PRTMP_ADAPTER pAdapter, PUCHAR arg);
-} *PRTMP_PRIVATE_SET_PROC, RTMP_PRIVATE_SUPPORT_PROC[] = {
-       {"DriverVersion",                               Set_DriverVersion_Proc},
-       {"CountryRegion",                               Set_CountryRegion_Proc},
-       {"CountryRegionABand",                  Set_CountryRegionABand_Proc},
-       {"SSID",                                                Set_SSID_Proc},
-       {"WirelessMode",                                Set_WirelessMode_Proc},
-       {"TxBurst",                                     Set_TxBurst_Proc},
-       {"TxPreamble",                          Set_TxPreamble_Proc},
-       {"TxPower",                                     Set_TxPower_Proc},
-       {"Channel",                                     Set_Channel_Proc},
-       {"BGProtection",                                Set_BGProtection_Proc},
-       {"RTSThreshold",                                Set_RTSThreshold_Proc},
-       {"FragThreshold",                               Set_FragThreshold_Proc},
-       {"HtBw",                                Set_HtBw_Proc},
-       {"HtMcs",                               Set_HtMcs_Proc},
-       {"HtGi",                                Set_HtGi_Proc},
-       {"HtOpMode",                        Set_HtOpMode_Proc},
-       {"HtExtcha",                        Set_HtExtcha_Proc},
-       {"HtMpduDensity",                       Set_HtMpduDensity_Proc},
-       {"HtBaWinSize",                         Set_HtBaWinSize_Proc},
-       {"HtRdg",                                       Set_HtRdg_Proc},
-       {"HtAmsdu",                                     Set_HtAmsdu_Proc},
-       {"HtAutoBa",                            Set_HtAutoBa_Proc},
-       {"HtBaDecline",                                 Set_BADecline_Proc},
-       {"HtProtect",                           Set_HtProtect_Proc},
-       {"HtMimoPs",                            Set_HtMimoPs_Proc},
-#ifdef AGGREGATION_SUPPORT
-       {"PktAggregate",                                Set_PktAggregate_Proc},
-#endif
-
-#ifdef WMM_SUPPORT
-       {"WmmCapable",                                  Set_WmmCapable_Proc},
-#endif
-       {"IEEE80211H",                                  Set_IEEE80211H_Proc},
-    {"NetworkType",                 Set_NetworkType_Proc},
-       {"AuthMode",                                    Set_AuthMode_Proc},
-       {"EncrypType",                                  Set_EncrypType_Proc},
-       {"DefaultKeyID",                                Set_DefaultKeyID_Proc},
-       {"Key1",                                                Set_Key1_Proc},
-       {"Key2",                                                Set_Key2_Proc},
-       {"Key3",                                                Set_Key3_Proc},
-       {"Key4",                                                Set_Key4_Proc},
-       {"WPAPSK",                                              Set_WPAPSK_Proc},
-       {"ResetCounter",                                Set_ResetStatCounter_Proc},
-       {"PSMode",                      Set_PSMode_Proc},
-#ifdef DBG
-       {"Debug",                                               Set_Debug_Proc},
-#endif
-    {"WpaSupport",                  Set_Wpa_Support},
-       {"FixedTxMode",                 Set_FixedTxMode_Proc},
-    {"TGnWifiTest",                 Set_TGnWifiTest_Proc},
-    {"ForceGF",                                        Set_ForceGF_Proc},
-       {"LongRetry",                           Set_LongRetryLimit_Proc},
-       {"ShortRetry",                          Set_ShortRetryLimit_Proc},
-//2008/09/11:KH add to support efuse<--
-#ifdef RT30xx
-       {"efuseFreeNumber",                             set_eFuseGetFreeBlockCount_Proc},
-       {"efuseDump",                                   set_eFusedump_Proc},
-       {"efuseLoadFromBin",                            set_eFuseLoadFromBin_Proc},
-#endif // RT30xx //
-//2008/09/11:KH add to support efuse-->
-       {NULL,}
-};
-
-
-VOID RTMPAddKey(
-       IN      PRTMP_ADAPTER       pAd,
-       IN      PNDIS_802_11_KEY    pKey)
-{
-       ULONG                           KeyIdx;
-       MAC_TABLE_ENTRY         *pEntry;
-
-    DBGPRINT(RT_DEBUG_TRACE, ("RTMPAddKey ------>\n"));
-
-       if (pAd->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
-       {
-               if (pKey->KeyIndex & 0x80000000)
-               {
-                   if (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPANone)
-            {
-                NdisZeroMemory(pAd->StaCfg.PMK, 32);
-                NdisMoveMemory(pAd->StaCfg.PMK, pKey->KeyMaterial, pKey->KeyLength);
-                goto end;
-            }
-                   // Update PTK
-                   NdisZeroMemory(&pAd->SharedKey[BSS0][0], sizeof(CIPHER_KEY));
-            pAd->SharedKey[BSS0][0].KeyLen = LEN_TKIP_EK;
-            NdisMoveMemory(pAd->SharedKey[BSS0][0].Key, pKey->KeyMaterial, LEN_TKIP_EK);
-
-            if (pAd->StaCfg.PairCipher == Ndis802_11Encryption2Enabled)
-            {
-                NdisMoveMemory(pAd->SharedKey[BSS0][0].RxMic, pKey->KeyMaterial + LEN_TKIP_EK, LEN_TKIP_TXMICK);
-                NdisMoveMemory(pAd->SharedKey[BSS0][0].TxMic, pKey->KeyMaterial + LEN_TKIP_EK + LEN_TKIP_TXMICK, LEN_TKIP_RXMICK);
-            }
-            else
-            {
-               NdisMoveMemory(pAd->SharedKey[BSS0][0].TxMic, pKey->KeyMaterial + LEN_TKIP_EK, LEN_TKIP_TXMICK);
-                NdisMoveMemory(pAd->SharedKey[BSS0][0].RxMic, pKey->KeyMaterial + LEN_TKIP_EK + LEN_TKIP_TXMICK, LEN_TKIP_RXMICK);
-            }
-
-            // Decide its ChiperAlg
-               if (pAd->StaCfg.PairCipher == Ndis802_11Encryption2Enabled)
-                       pAd->SharedKey[BSS0][0].CipherAlg = CIPHER_TKIP;
-               else if (pAd->StaCfg.PairCipher == Ndis802_11Encryption3Enabled)
-                       pAd->SharedKey[BSS0][0].CipherAlg = CIPHER_AES;
-               else
-                       pAd->SharedKey[BSS0][0].CipherAlg = CIPHER_NONE;
-
-            // Update these related information to MAC_TABLE_ENTRY
-               pEntry = &pAd->MacTab.Content[BSSID_WCID];
-            NdisMoveMemory(pEntry->PairwiseKey.Key, pAd->SharedKey[BSS0][0].Key, LEN_TKIP_EK);
-               NdisMoveMemory(pEntry->PairwiseKey.RxMic, pAd->SharedKey[BSS0][0].RxMic, LEN_TKIP_RXMICK);
-               NdisMoveMemory(pEntry->PairwiseKey.TxMic, pAd->SharedKey[BSS0][0].TxMic, LEN_TKIP_TXMICK);
-               pEntry->PairwiseKey.CipherAlg = pAd->SharedKey[BSS0][0].CipherAlg;
-
-               // Update pairwise key information to ASIC Shared Key Table
-               AsicAddSharedKeyEntry(pAd,
-                                                         BSS0,
-                                                         0,
-                                                         pAd->SharedKey[BSS0][0].CipherAlg,
-                                                         pAd->SharedKey[BSS0][0].Key,
-                                                         pAd->SharedKey[BSS0][0].TxMic,
-                                                         pAd->SharedKey[BSS0][0].RxMic);
-
-               // Update ASIC WCID attribute table and IVEIV table
-               RTMPAddWcidAttributeEntry(pAd,
-                                                                 BSS0,
-                                                                 0,
-                                                                 pAd->SharedKey[BSS0][0].CipherAlg,
-                                                                 pEntry);
-
-            if (pAd->StaCfg.AuthMode >= Ndis802_11AuthModeWPA2)
-            {
-                // set 802.1x port control
-                               STA_PORT_SECURED(pAd);
-
-                // Indicate Connected for GUI
-                pAd->IndicateMediaState = NdisMediaStateConnected;
-            }
-               }
-        else
-        {
-            // Update GTK
-            pAd->StaCfg.DefaultKeyId = (pKey->KeyIndex & 0xFF);
-            NdisZeroMemory(&pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId], sizeof(CIPHER_KEY));
-            pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].KeyLen = LEN_TKIP_EK;
-            NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].Key, pKey->KeyMaterial, LEN_TKIP_EK);
-
-            if (pAd->StaCfg.GroupCipher == Ndis802_11Encryption2Enabled)
-            {
-                NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].RxMic, pKey->KeyMaterial + LEN_TKIP_EK, LEN_TKIP_TXMICK);
-                NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].TxMic, pKey->KeyMaterial + LEN_TKIP_EK + LEN_TKIP_TXMICK, LEN_TKIP_RXMICK);
-            }
-            else
-            {
-               NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].TxMic, pKey->KeyMaterial + LEN_TKIP_EK, LEN_TKIP_TXMICK);
-                NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].RxMic, pKey->KeyMaterial + LEN_TKIP_EK + LEN_TKIP_TXMICK, LEN_TKIP_RXMICK);
-            }
-
-            // Update Shared Key CipherAlg
-               pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg = CIPHER_NONE;
-               if (pAd->StaCfg.GroupCipher == Ndis802_11Encryption2Enabled)
-                       pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg = CIPHER_TKIP;
-               else if (pAd->StaCfg.GroupCipher == Ndis802_11Encryption3Enabled)
-                       pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg = CIPHER_AES;
-
-            // Update group key information to ASIC Shared Key Table
-               AsicAddSharedKeyEntry(pAd,
-                                                         BSS0,
-                                                         pAd->StaCfg.DefaultKeyId,
-                                                         pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg,
-                                                         pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].Key,
-                                                         pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].TxMic,
-                                                         pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].RxMic);
-
-               // Update ASIC WCID attribute table and IVEIV table
-               RTMPAddWcidAttributeEntry(pAd,
-                                                                 BSS0,
-                                                                 pAd->StaCfg.DefaultKeyId,
-                                                                 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg,
-                                                                 NULL);
-
-            // set 802.1x port control
-                       STA_PORT_SECURED(pAd);
-
-            // Indicate Connected for GUI
-            pAd->IndicateMediaState = NdisMediaStateConnected;
-        }
-       }
-       else    // dynamic WEP from wpa_supplicant
-       {
-               UCHAR   CipherAlg;
-       PUCHAR  Key;
-
-               if(pKey->KeyLength == 32)
-                       goto end;
-
-               KeyIdx = pKey->KeyIndex & 0x0fffffff;
-
-               if (KeyIdx < 4)
-               {
-                       // it is a default shared key, for Pairwise key setting
-                       if (pKey->KeyIndex & 0x80000000)
-                       {
-                               pEntry = MacTableLookup(pAd, pKey->BSSID);
-
-                               if (pEntry)
-                               {
-                                       DBGPRINT(RT_DEBUG_TRACE, ("RTMPAddKey: Set Pair-wise Key\n"));
-
-                                       // set key material and key length
-                                       pEntry->PairwiseKey.KeyLen = (UCHAR)pKey->KeyLength;
-                                       NdisMoveMemory(pEntry->PairwiseKey.Key, &pKey->KeyMaterial, pKey->KeyLength);
-
-                                       // set Cipher type
-                                       if (pKey->KeyLength == 5)
-                                               pEntry->PairwiseKey.CipherAlg = CIPHER_WEP64;
-                                       else
-                                               pEntry->PairwiseKey.CipherAlg = CIPHER_WEP128;
-
-                                       // Add Pair-wise key to Asic
-                                       AsicAddPairwiseKeyEntry(
-                                               pAd,
-                                               pEntry->Addr,
-                                               (UCHAR)pEntry->Aid,
-                               &pEntry->PairwiseKey);
-
-                                       // update WCID attribute table and IVEIV table for this entry
-                                       RTMPAddWcidAttributeEntry(
-                                               pAd,
-                                               BSS0,
-                                               KeyIdx, // The value may be not zero
-                                               pEntry->PairwiseKey.CipherAlg,
-                                               pEntry);
-
-                               }
-                       }
-                       else
-            {
-                               // Default key for tx (shared key)
-                               pAd->StaCfg.DefaultKeyId = (UCHAR) KeyIdx;
-
-                               // set key material and key length
-                               pAd->SharedKey[BSS0][KeyIdx].KeyLen = (UCHAR) pKey->KeyLength;
-                               NdisMoveMemory(pAd->SharedKey[BSS0][KeyIdx].Key, &pKey->KeyMaterial, pKey->KeyLength);
-
-                               // Set Ciper type
-                               if (pKey->KeyLength == 5)
-                                       pAd->SharedKey[BSS0][KeyIdx].CipherAlg = CIPHER_WEP64;
-                               else
-                                       pAd->SharedKey[BSS0][KeyIdx].CipherAlg = CIPHER_WEP128;
-
-                       CipherAlg = pAd->SharedKey[BSS0][KeyIdx].CipherAlg;
-                       Key = pAd->SharedKey[BSS0][KeyIdx].Key;
-
-                               // Set Group key material to Asic
-                       AsicAddSharedKeyEntry(pAd, BSS0, KeyIdx, CipherAlg, Key, NULL, NULL);
-
-                               // Update WCID attribute table and IVEIV table for this group key table
-                               RTMPAddWcidAttributeEntry(pAd, BSS0, KeyIdx, CipherAlg, NULL);
-
-                       }
-               }
-       }
-end:
-       return;
-}
-
-char * rtstrchr(const char * s, int c)
-{
-    for(; *s != (char) c; ++s)
-        if (*s == '\0')
-            return NULL;
-    return (char *) s;
-}
-
-/*
-This is required for LinEX2004/kernel2.6.7 to provide iwlist scanning function
-*/
-
-int
-rt_ioctl_giwname(struct net_device *dev,
-                  struct iw_request_info *info,
-                  char *name, char *extra)
-{
-//     PRTMP_ADAPTER pAdapter = dev->ml_priv;
-
-#ifdef RT2870
-       strncpy(name, "RT2870 Wireless", IFNAMSIZ);
-#endif // RT2870 //
-       return 0;
-}
-
-int rt_ioctl_siwfreq(struct net_device *dev,
-                       struct iw_request_info *info,
-                       struct iw_freq *freq, char *extra)
-{
-       PRTMP_ADAPTER pAdapter = dev->ml_priv;
-       int     chan = -1;
-
-    //check if the interface is down
-    if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
-    {
-        DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
-        return -ENETDOWN;
-    }
-
-
-       if (freq->e > 1)
-               return -EINVAL;
-
-       if((freq->e == 0) && (freq->m <= 1000))
-               chan = freq->m; // Setting by channel number
-       else
-               MAP_KHZ_TO_CHANNEL_ID( (freq->m /100) , chan); // Setting by frequency - search the table , like 2.412G, 2.422G,
-
-    if (ChannelSanity(pAdapter, chan) == TRUE)
-    {
-       pAdapter->CommonCfg.Channel = chan;
-       DBGPRINT(RT_DEBUG_ERROR, ("==>rt_ioctl_siwfreq::SIOCSIWFREQ[cmd=0x%x] (Channel=%d)\n", SIOCSIWFREQ, pAdapter->CommonCfg.Channel));
-    }
-    else
-        return -EINVAL;
-
-       return 0;
-}
-int rt_ioctl_giwfreq(struct net_device *dev,
-                  struct iw_request_info *info,
-                  struct iw_freq *freq, char *extra)
-{
-    VIRTUAL_ADAPTER *pVirtualAd = NULL;
-       PRTMP_ADAPTER pAdapter;
-       UCHAR ch;
-       ULONG   m;
-
-       if (dev->priv_flags == INT_MAIN)
-       {
-               pAdapter = dev->ml_priv;
-       }
-       else
-       {
-               pVirtualAd = dev->ml_priv;
-               pAdapter = pVirtualAd->RtmpDev->ml_priv;
-       }
-
-       if (pAdapter == NULL)
-       {
-               /* if 1st open fail, pAd will be free;
-                  So the net_dev->ml_priv will be NULL in 2rd open */
-               return -ENETDOWN;
-       }
-
-               ch = pAdapter->CommonCfg.Channel;
-
-       DBGPRINT(RT_DEBUG_TRACE,("==>rt_ioctl_giwfreq  %d\n", ch));
-
-    MAP_CHANNEL_ID_TO_KHZ(ch, m);
-       freq->m = m * 100;
-       freq->e = 1;
-       return 0;
-}
-
-int rt_ioctl_siwmode(struct net_device *dev,
-                  struct iw_request_info *info,
-                  __u32 *mode, char *extra)
-{
-       PRTMP_ADAPTER pAdapter = dev->ml_priv;
-
-       //check if the interface is down
-    if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
-    {
-       DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
-               return -ENETDOWN;
-    }
-
-       switch (*mode)
-       {
-               case IW_MODE_ADHOC:
-                       Set_NetworkType_Proc(pAdapter, "Adhoc");
-                       break;
-               case IW_MODE_INFRA:
-                       Set_NetworkType_Proc(pAdapter, "Infra");
-                       break;
-        case IW_MODE_MONITOR:
-                       Set_NetworkType_Proc(pAdapter, "Monitor");
-                       break;
-               default:
-                       DBGPRINT(RT_DEBUG_TRACE, ("===>rt_ioctl_siwmode::SIOCSIWMODE (unknown %d)\n", *mode));
-                       return -EINVAL;
-       }
-
-       // Reset Ralink supplicant to not use, it will be set to start when UI set PMK key
-       pAdapter->StaCfg.WpaState = SS_NOTUSE;
-
-       return 0;
-}
-
-int rt_ioctl_giwmode(struct net_device *dev,
-                  struct iw_request_info *info,
-                  __u32 *mode, char *extra)
-{
-       PRTMP_ADAPTER pAdapter = dev->ml_priv;
-
-       if (ADHOC_ON(pAdapter))
-               *mode = IW_MODE_ADHOC;
-    else if (INFRA_ON(pAdapter))
-               *mode = IW_MODE_INFRA;
-    else if (MONITOR_ON(pAdapter))
-    {
-        *mode = IW_MODE_MONITOR;
-    }
-    else
-        *mode = IW_MODE_AUTO;
-
-       DBGPRINT(RT_DEBUG_TRACE, ("==>rt_ioctl_giwmode(mode=%d)\n", *mode));
-       return 0;
-}
-
-int rt_ioctl_siwsens(struct net_device *dev,
-                  struct iw_request_info *info,
-                  char *name, char *extra)
-{
-       PRTMP_ADAPTER pAdapter = dev->ml_priv;
-
-       //check if the interface is down
-       if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
-       {
-               DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
-               return -ENETDOWN;
-       }
-
-       return 0;
-}
-
-int rt_ioctl_giwsens(struct net_device *dev,
-                  struct iw_request_info *info,
-                  char *name, char *extra)
-{
-       return 0;
-}
-
-int rt_ioctl_giwrange(struct net_device *dev,
-                  struct iw_request_info *info,
-                  struct iw_point *data, char *extra)
-{
-       PRTMP_ADAPTER pAdapter = dev->ml_priv;
-
-       struct iw_range *range = (struct iw_range *) extra;
-       u16 val;
-       int i;
-
-       DBGPRINT(RT_DEBUG_TRACE ,("===>rt_ioctl_giwrange\n"));
-       data->length = sizeof(struct iw_range);
-       memset(range, 0, sizeof(struct iw_range));
-
-       range->txpower_capa = IW_TXPOW_DBM;
-
-       if (INFRA_ON(pAdapter)||ADHOC_ON(pAdapter))
-       {
-               range->min_pmp = 1 * 1024;
-               range->max_pmp = 65535 * 1024;
-               range->min_pmt = 1 * 1024;
-               range->max_pmt = 1000 * 1024;
-               range->pmp_flags = IW_POWER_PERIOD;
-               range->pmt_flags = IW_POWER_TIMEOUT;
-               range->pm_capa = IW_POWER_PERIOD | IW_POWER_TIMEOUT |
-                       IW_POWER_UNICAST_R | IW_POWER_ALL_R;
-       }
-
-       range->we_version_compiled = WIRELESS_EXT;
-       range->we_version_source = 14;
-
-       range->retry_capa = IW_RETRY_LIMIT;
-       range->retry_flags = IW_RETRY_LIMIT;
-       range->min_retry = 0;
-       range->max_retry = 255;
-
-       range->num_channels =  pAdapter->ChannelListNum;
-
-       val = 0;
-       for (i = 1; i <= range->num_channels; i++)
-       {
-               u32 m;
-               range->freq[val].i = pAdapter->ChannelList[i-1].Channel;
-               MAP_CHANNEL_ID_TO_KHZ(pAdapter->ChannelList[i-1].Channel, m);
-               range->freq[val].m = m * 100; /* HZ */
-
-               range->freq[val].e = 1;
-               val++;
-               if (val == IW_MAX_FREQUENCIES)
-                       break;
-       }
-       range->num_frequency = val;
-
-       range->max_qual.qual = 100; /* what is correct max? This was not
-                                       * documented exactly. At least
-                                       * 69 has been observed. */
-       range->max_qual.level = 0; /* dB */
-       range->max_qual.noise = 0; /* dB */
-
-       /* What would be suitable values for "average/typical" qual? */
-       range->avg_qual.qual = 20;
-       range->avg_qual.level = -60;
-       range->avg_qual.noise = -95;
-       range->sensitivity = 3;
-
-       range->max_encoding_tokens = NR_WEP_KEYS;
-       range->num_encoding_sizes = 2;
-       range->encoding_size[0] = 5;
-       range->encoding_size[1] = 13;
-
-       range->min_rts = 0;
-       range->max_rts = 2347;
-       range->min_frag = 256;
-       range->max_frag = 2346;
-
-#if WIRELESS_EXT > 17
-       /* IW_ENC_CAPA_* bit field */
-       range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 |
-                                       IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP;
-#endif
-
-       return 0;
-}
-
-int rt_ioctl_siwap(struct net_device *dev,
-                     struct iw_request_info *info,
-                     struct sockaddr *ap_addr, char *extra)
-{
-       PRTMP_ADAPTER pAdapter = dev->ml_priv;
-    NDIS_802_11_MAC_ADDRESS Bssid;
-
-       //check if the interface is down
-       if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
-       {
-               DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
-               return -ENETDOWN;
-    }
-
-       if (pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE)
-    {
-        RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
-        DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
-    }
-
-    // tell CNTL state machine to call NdisMSetInformationComplete() after completing
-    // this request, because this request is initiated by NDIS.
-    pAdapter->MlmeAux.CurrReqIsFromNdis = FALSE;
-       // Prevent to connect AP again in STAMlmePeriodicExec
-       pAdapter->MlmeAux.AutoReconnectSsidLen= 32;
-
-    memset(Bssid, 0, MAC_ADDR_LEN);
-    memcpy(Bssid, ap_addr->sa_data, MAC_ADDR_LEN);
-    MlmeEnqueue(pAdapter,
-                MLME_CNTL_STATE_MACHINE,
-                OID_802_11_BSSID,
-                sizeof(NDIS_802_11_MAC_ADDRESS),
-                (VOID *)&Bssid);
-
-    DBGPRINT(RT_DEBUG_TRACE, ("IOCTL::SIOCSIWAP %02x:%02x:%02x:%02x:%02x:%02x\n",
-        Bssid[0], Bssid[1], Bssid[2], Bssid[3], Bssid[4], Bssid[5]));
-
-       return 0;
-}
-
-int rt_ioctl_giwap(struct net_device *dev,
-                     struct iw_request_info *info,
-                     struct sockaddr *ap_addr, char *extra)
-{
-       PRTMP_ADAPTER pAdapter = dev->ml_priv;
-
-       if (INFRA_ON(pAdapter) || ADHOC_ON(pAdapter))
-       {
-               ap_addr->sa_family = ARPHRD_ETHER;
-               memcpy(ap_addr->sa_data, &pAdapter->CommonCfg.Bssid, ETH_ALEN);
-       }
-    // Add for RT2870
-    else if (pAdapter->StaCfg.WpaSupplicantUP != WPA_SUPPLICANT_DISABLE)
-    {
-        ap_addr->sa_family = ARPHRD_ETHER;
-        memcpy(ap_addr->sa_data, &pAdapter->MlmeAux.Bssid, ETH_ALEN);
-    }
-       else
-       {
-               DBGPRINT(RT_DEBUG_TRACE, ("IOCTL::SIOCGIWAP(=EMPTY)\n"));
-               return -ENOTCONN;
-       }
-
-       return 0;
-}
-
-/*
- * Units are in db above the noise floor. That means the
- * rssi values reported in the tx/rx descriptors in the
- * driver are the SNR expressed in db.
- *
- * If you assume that the noise floor is -95, which is an
- * excellent assumption 99.5 % of the time, then you can
- * derive the absolute signal level (i.e. -95 + rssi).
- * There are some other slight factors to take into account
- * depending on whether the rssi measurement is from 11b,
- * 11g, or 11a.   These differences are at most 2db and
- * can be documented.
- *
- * NB: various calculations are based on the orinoco/wavelan
- *     drivers for compatibility
- */
-static void set_quality(PRTMP_ADAPTER pAdapter,
-                        struct iw_quality *iq,
-                        signed char rssi)
-{
-       __u8 ChannelQuality;
-
-       // Normalize Rssi
-       if (rssi >= -50)
-               ChannelQuality = 100;
-       else if (rssi >= -80) // between -50 ~ -80dbm
-               ChannelQuality = (__u8)(24 + ((rssi + 80) * 26)/10);
-       else if (rssi >= -90)   // between -80 ~ -90dbm
-        ChannelQuality = (__u8)((rssi + 90) * 26)/10;
-       else
-               ChannelQuality = 0;
-
-    iq->qual = (__u8)ChannelQuality;
-
-    iq->level = (__u8)(rssi);
-    iq->noise = (pAdapter->BbpWriteLatch[66] > pAdapter->BbpTuning.FalseCcaUpperThreshold) ? ((__u8)pAdapter->BbpTuning.FalseCcaUpperThreshold) : ((__u8) pAdapter->BbpWriteLatch[66]);        // noise level (dBm)
-    iq->noise += 256 - 143;
-    iq->updated = pAdapter->iw_stats.qual.updated;
-}
-
-int rt_ioctl_iwaplist(struct net_device *dev,
-                       struct iw_request_info *info,
-                       struct iw_point *data, char *extra)
-{
-       PRTMP_ADAPTER pAdapter = dev->ml_priv;
-
-       struct sockaddr addr[IW_MAX_AP];
-       struct iw_quality qual[IW_MAX_AP];
-       int i;
-
-       //check if the interface is down
-    if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
-    {
-               DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
-               data->length = 0;
-               return 0;
-        //return -ENETDOWN;
-       }
-
-       for (i = 0; i <IW_MAX_AP ; i++)
-       {
-               if (i >=  pAdapter->ScanTab.BssNr)
-                       break;
-               addr[i].sa_family = ARPHRD_ETHER;
-                       memcpy(addr[i].sa_data, &pAdapter->ScanTab.BssEntry[i].Bssid, MAC_ADDR_LEN);
-               set_quality(pAdapter, &qual[i], pAdapter->ScanTab.BssEntry[i].Rssi);
-       }
-       data->length = i;
-       memcpy(extra, &addr, i*sizeof(addr[0]));
-       data->flags = 1;                /* signal quality present (sort of) */
-       memcpy(extra + i*sizeof(addr[0]), &qual, i*sizeof(qual[i]));
-
-       return 0;
-}
-
-#ifdef SIOCGIWSCAN
-int rt_ioctl_siwscan(struct net_device *dev,
-                       struct iw_request_info *info,
-                       struct iw_point *data, char *extra)
-{
-       PRTMP_ADAPTER pAdapter = dev->ml_priv;
-
-       ULONG                                                           Now;
-       int Status = NDIS_STATUS_SUCCESS;
-
-       //check if the interface is down
-       if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
-       {
-               DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
-               return -ENETDOWN;
-       }
-
-       if (MONITOR_ON(pAdapter))
-    {
-        DBGPRINT(RT_DEBUG_TRACE, ("!!! Driver is in Monitor Mode now !!!\n"));
-        return -EINVAL;
-    }
-
-
-       if (pAdapter->StaCfg.WpaSupplicantUP == WPA_SUPPLICANT_ENABLE)
-       {
-               pAdapter->StaCfg.WpaSupplicantScanCount++;
-       }
-
-    pAdapter->StaCfg.bScanReqIsFromWebUI = TRUE;
-       if (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
-               return 0;
-       do{
-               Now = jiffies;
-
-               if ((pAdapter->StaCfg.WpaSupplicantUP == WPA_SUPPLICANT_ENABLE) &&
-                       (pAdapter->StaCfg.WpaSupplicantScanCount > 3))
-               {
-                       DBGPRINT(RT_DEBUG_TRACE, ("!!! WpaSupplicantScanCount > 3\n"));
-                       Status = NDIS_STATUS_SUCCESS;
-                       break;
-               }
-
-               if ((OPSTATUS_TEST_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED)) &&
-                       ((pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA) ||
-                       (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK)) &&
-                       (pAdapter->StaCfg.PortSecured == WPA_802_1X_PORT_NOT_SECURED))
-               {
-                       DBGPRINT(RT_DEBUG_TRACE, ("!!! Link UP, Port Not Secured! ignore this set::OID_802_11_BSSID_LIST_SCAN\n"));
-                       Status = NDIS_STATUS_SUCCESS;
-                       break;
-               }
-
-               if (pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE)
-               {
-                       RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
-                       DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
-               }
-
-               // tell CNTL state machine to call NdisMSetInformationComplete() after completing
-               // this request, because this request is initiated by NDIS.
-               pAdapter->MlmeAux.CurrReqIsFromNdis = FALSE;
-               // Reset allowed scan retries
-               pAdapter->StaCfg.ScanCnt = 0;
-               pAdapter->StaCfg.LastScanTime = Now;
-
-               MlmeEnqueue(pAdapter,
-                       MLME_CNTL_STATE_MACHINE,
-                       OID_802_11_BSSID_LIST_SCAN,
-                       0,
-                       NULL);
-
-               Status = NDIS_STATUS_SUCCESS;
-               RT28XX_MLME_HANDLER(pAdapter);
-       }while(0);
-       return 0;
-}
-
-int rt_ioctl_giwscan(struct net_device *dev,
-                       struct iw_request_info *info,
-                       struct iw_point *data, char *extra)
-{
-
-       PRTMP_ADAPTER pAdapter = dev->ml_priv;
-       int i=0;
-       char *current_ev = extra, *previous_ev = extra;
-       char *end_buf;
-       char *current_val, custom[MAX_CUSTOM_LEN] = {0};
-#ifndef IWEVGENIE
-       char idx;
-#endif // IWEVGENIE //
-       struct iw_event iwe;
-
-       if (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
-    {
-               /*
-                * Still scanning, indicate the caller should try again.
-                */
-               return -EAGAIN;
-       }
-
-       if (pAdapter->StaCfg.WpaSupplicantUP == WPA_SUPPLICANT_ENABLE)
-       {
-               pAdapter->StaCfg.WpaSupplicantScanCount = 0;
-       }
-
-       if (pAdapter->ScanTab.BssNr == 0)
-       {
-               data->length = 0;
-               return 0;
-       }
-
-#if WIRELESS_EXT >= 17
-    if (data->length > 0)
-        end_buf = extra + data->length;
-    else
-        end_buf = extra + IW_SCAN_MAX_DATA;
-#else
-    end_buf = extra + IW_SCAN_MAX_DATA;
-#endif
-
-       for (i = 0; i < pAdapter->ScanTab.BssNr; i++)
-       {
-               if (current_ev >= end_buf)
-        {
-#if WIRELESS_EXT >= 17
-            return -E2BIG;
-#else
-                       break;
-#endif
-        }
-
-               //MAC address
-               //================================
-               memset(&iwe, 0, sizeof(iwe));
-               iwe.cmd = SIOCGIWAP;
-               iwe.u.ap_addr.sa_family = ARPHRD_ETHER;
-                               memcpy(iwe.u.ap_addr.sa_data, &pAdapter->ScanTab.BssEntry[i].Bssid, ETH_ALEN);
-
-        previous_ev = current_ev;
-                       current_ev = iwe_stream_add_event(info, current_ev, end_buf, &iwe, IW_EV_ADDR_LEN);
-        if (current_ev == previous_ev)
-#if WIRELESS_EXT >= 17
-            return -E2BIG;
-#else
-                       break;
-#endif
-
-               /*
-               Protocol:
-                       it will show scanned AP's WirelessMode .
-                       it might be
-                                       802.11a
-                                       802.11a/n
-                                       802.11g/n
-                                       802.11b/g/n
-                                       802.11g
-                                       802.11b/g
-               */
-               memset(&iwe, 0, sizeof(iwe));
-               iwe.cmd = SIOCGIWNAME;
-
-
-       {
-               PBSS_ENTRY pBssEntry=&pAdapter->ScanTab.BssEntry[i];
-               BOOLEAN isGonly=FALSE;
-               int rateCnt=0;
-
-               if (pBssEntry->Channel>14)
-               {
-                       if (pBssEntry->HtCapabilityLen!=0)
-                               strcpy(iwe.u.name,"802.11a/n");
-                       else
-                               strcpy(iwe.u.name,"802.11a");
-               }
-               else
-               {
-                       /*
-                               if one of non B mode rate is set supported rate . it mean G only.
-                       */
-                       for (rateCnt=0;rateCnt<pBssEntry->SupRateLen;rateCnt++)
-                       {
-                               /*
-                                       6Mbps(140) 9Mbps(146) and >=12Mbps(152) are supported rate , it mean G only.
-                               */
-                               if (pBssEntry->SupRate[rateCnt]==140 || pBssEntry->SupRate[rateCnt]==146 || pBssEntry->SupRate[rateCnt]>=152)
-                                       isGonly=TRUE;
-                       }
-
-                       for (rateCnt=0;rateCnt<pBssEntry->ExtRateLen;rateCnt++)
-                       {
-                               if (pBssEntry->ExtRate[rateCnt]==140 || pBssEntry->ExtRate[rateCnt]==146 || pBssEntry->ExtRate[rateCnt]>=152)
-                                       isGonly=TRUE;
-                       }
-
-
-                       if (pBssEntry->HtCapabilityLen!=0)
-                       {
-                               if (isGonly==TRUE)
-                                       strcpy(iwe.u.name,"802.11g/n");
-                               else
-                                       strcpy(iwe.u.name,"802.11b/g/n");
-                       }
-                       else
-                       {
-                               if (isGonly==TRUE)
-                                       strcpy(iwe.u.name,"802.11g");
-                               else
-                               {
-                                       if (pBssEntry->SupRateLen==4 && pBssEntry->ExtRateLen==0)
-                                               strcpy(iwe.u.name,"802.11b");
-                                       else
-                                               strcpy(iwe.u.name,"802.11b/g");
-                               }
-                       }
-               }
-       }
-
-               previous_ev = current_ev;
-               current_ev       = iwe_stream_add_event(info, current_ev, end_buf, &iwe, IW_EV_ADDR_LEN);
-               if (current_ev == previous_ev)
-#if WIRELESS_EXT >= 17
-                       return -E2BIG;
-#else
-                       break;
-#endif
-
-               //ESSID
-               //================================
-               memset(&iwe, 0, sizeof(iwe));
-               iwe.cmd = SIOCGIWESSID;
-               iwe.u.data.length = pAdapter->ScanTab.BssEntry[i].SsidLen;
-               iwe.u.data.flags = 1;
-
-        previous_ev = current_ev;
-               current_ev = iwe_stream_add_point(info, current_ev, end_buf, &iwe, pAdapter->ScanTab.BssEntry[i].Ssid);
-        if (current_ev == previous_ev)
-#if WIRELESS_EXT >= 17
-            return -E2BIG;
-#else
-                       break;
-#endif
-
-               //Network Type
-               //================================
-               memset(&iwe, 0, sizeof(iwe));
-               iwe.cmd = SIOCGIWMODE;
-               if (pAdapter->ScanTab.BssEntry[i].BssType == Ndis802_11IBSS)
-               {
-                       iwe.u.mode = IW_MODE_ADHOC;
-               }
-               else if (pAdapter->ScanTab.BssEntry[i].BssType == Ndis802_11Infrastructure)
-               {
-                       iwe.u.mode = IW_MODE_INFRA;
-               }
-               else
-               {
-                       iwe.u.mode = IW_MODE_AUTO;
-               }
-               iwe.len = IW_EV_UINT_LEN;
-
-        previous_ev = current_ev;
-               current_ev = iwe_stream_add_event(info, current_ev, end_buf, &iwe,  IW_EV_UINT_LEN);
-        if (current_ev == previous_ev)
-#if WIRELESS_EXT >= 17
-            return -E2BIG;
-#else
-                       break;
-#endif
-
-               //Channel and Frequency
-               //================================
-               memset(&iwe, 0, sizeof(iwe));
-               iwe.cmd = SIOCGIWFREQ;
-               if (INFRA_ON(pAdapter) || ADHOC_ON(pAdapter))
-                       iwe.u.freq.m = pAdapter->ScanTab.BssEntry[i].Channel;
-               else
-                       iwe.u.freq.m = pAdapter->ScanTab.BssEntry[i].Channel;
-               iwe.u.freq.e = 0;
-               iwe.u.freq.i = 0;
-
-               previous_ev = current_ev;
-               current_ev = iwe_stream_add_event(info, current_ev, end_buf, &iwe, IW_EV_FREQ_LEN);
-        if (current_ev == previous_ev)
-#if WIRELESS_EXT >= 17
-            return -E2BIG;
-#else
-                       break;
-#endif
-
-        //Add quality statistics
-        //================================
-        memset(&iwe, 0, sizeof(iwe));
-       iwe.cmd = IWEVQUAL;
-       iwe.u.qual.level = 0;
-       iwe.u.qual.noise = 0;
-        set_quality(pAdapter, &iwe.u.qual, pAdapter->ScanTab.BssEntry[i].Rssi);
-       current_ev = iwe_stream_add_event(info, current_ev, end_buf, &iwe, IW_EV_QUAL_LEN);
-        if (current_ev == previous_ev)
-#if WIRELESS_EXT >= 17
-            return -E2BIG;
-#else
-                       break;
-#endif
-
-               //Encyption key
-               //================================
-               memset(&iwe, 0, sizeof(iwe));
-               iwe.cmd = SIOCGIWENCODE;
-               if (CAP_IS_PRIVACY_ON (pAdapter->ScanTab.BssEntry[i].CapabilityInfo ))
-                       iwe.u.data.flags =IW_ENCODE_ENABLED | IW_ENCODE_NOKEY;
-               else
-                       iwe.u.data.flags = IW_ENCODE_DISABLED;
-
-        previous_ev = current_ev;
-        current_ev = iwe_stream_add_point(info, current_ev, end_buf,&iwe, (char *)pAdapter->SharedKey[BSS0][(iwe.u.data.flags & IW_ENCODE_INDEX)-1].Key);
-        if (current_ev == previous_ev)
-#if WIRELESS_EXT >= 17
-            return -E2BIG;
-#else
-                       break;
-#endif
-
-               //Bit Rate
-               //================================
-               if (pAdapter->ScanTab.BssEntry[i].SupRateLen)
-        {
-            UCHAR tmpRate = pAdapter->ScanTab.BssEntry[i].SupRate[pAdapter->ScanTab.BssEntry[i].SupRateLen-1];
-                       memset(&iwe, 0, sizeof(iwe));
-                       iwe.cmd = SIOCGIWRATE;
-               current_val = current_ev + IW_EV_LCP_LEN;
-            if (tmpRate == 0x82)
-                iwe.u.bitrate.value =  1 * 1000000;
-            else if (tmpRate == 0x84)
-                iwe.u.bitrate.value =  2 * 1000000;
-            else if (tmpRate == 0x8B)
-                iwe.u.bitrate.value =  5.5 * 1000000;
-            else if (tmpRate == 0x96)
-                iwe.u.bitrate.value =  11 * 1000000;
-            else
-                   iwe.u.bitrate.value =  (tmpRate/2) * 1000000;
-
-                       iwe.u.bitrate.disabled = 0;
-                       current_val = iwe_stream_add_value(info, current_ev,
-                               current_val, end_buf, &iwe,
-                       IW_EV_PARAM_LEN);
-
-               if((current_val-current_ev)>IW_EV_LCP_LEN)
-               current_ev = current_val;
-               else
-#if WIRELESS_EXT >= 17
-                return -E2BIG;
-#else
-                           break;
-#endif
-        }
-
-#ifdef IWEVGENIE
-               //WPA IE
-               if (pAdapter->ScanTab.BssEntry[i].WpaIE.IELen > 0)
-               {
-                       memset(&iwe, 0, sizeof(iwe));
-                       memset(&custom[0], 0, MAX_CUSTOM_LEN);
-                       memcpy(custom, &(pAdapter->ScanTab.BssEntry[i].WpaIE.IE[0]),
-                                                  pAdapter->ScanTab.BssEntry[i].WpaIE.IELen);
-                       iwe.cmd = IWEVGENIE;
-                       iwe.u.data.length = pAdapter->ScanTab.BssEntry[i].WpaIE.IELen;
-                       current_ev = iwe_stream_add_point(info, current_ev, end_buf, &iwe, custom);
-                       if (current_ev == previous_ev)
-#if WIRELESS_EXT >= 17
-                return -E2BIG;
-#else
-                           break;
-#endif
-               }
-
-               //WPA2 IE
-        if (pAdapter->ScanTab.BssEntry[i].RsnIE.IELen > 0)
-        {
-               memset(&iwe, 0, sizeof(iwe));
-                       memset(&custom[0], 0, MAX_CUSTOM_LEN);
-                       memcpy(custom, &(pAdapter->ScanTab.BssEntry[i].RsnIE.IE[0]),
-                                                  pAdapter->ScanTab.BssEntry[i].RsnIE.IELen);
-                       iwe.cmd = IWEVGENIE;
-                       iwe.u.data.length = pAdapter->ScanTab.BssEntry[i].RsnIE.IELen;
-                       current_ev = iwe_stream_add_point(info, current_ev, end_buf, &iwe, custom);
-                       if (current_ev == previous_ev)
-#if WIRELESS_EXT >= 17
-                return -E2BIG;
-#else
-                           break;
-#endif
-        }
-#else
-        //WPA IE
-               //================================
-        if (pAdapter->ScanTab.BssEntry[i].WpaIE.IELen > 0)
-        {
-               NdisZeroMemory(&iwe, sizeof(iwe));
-                       memset(&custom[0], 0, MAX_CUSTOM_LEN);
-               iwe.cmd = IWEVCUSTOM;
-            iwe.u.data.length = (pAdapter->ScanTab.BssEntry[i].WpaIE.IELen * 2) + 7;
-            NdisMoveMemory(custom, "wpa_ie=", 7);
-            for (idx = 0; idx < pAdapter->ScanTab.BssEntry[i].WpaIE.IELen; idx++)
-                sprintf(custom, "%s%02x", custom, pAdapter->ScanTab.BssEntry[i].WpaIE.IE[idx]);
-            previous_ev = current_ev;
-               current_ev = iwe_stream_add_point(current_ev, end_buf, &iwe,  custom);
-            if (current_ev == previous_ev)
-#if WIRELESS_EXT >= 17
-                return -E2BIG;
-#else
-                           break;
-#endif
-        }
-
-        //WPA2 IE
-        if (pAdapter->ScanTab.BssEntry[i].RsnIE.IELen > 0)
-        {
-               NdisZeroMemory(&iwe, sizeof(iwe));
-                       memset(&custom[0], 0, MAX_CUSTOM_LEN);
-               iwe.cmd = IWEVCUSTOM;
-            iwe.u.data.length = (pAdapter->ScanTab.BssEntry[i].RsnIE.IELen * 2) + 7;
-            NdisMoveMemory(custom, "rsn_ie=", 7);
-                       for (idx = 0; idx < pAdapter->ScanTab.BssEntry[i].RsnIE.IELen; idx++)
-                sprintf(custom, "%s%02x", custom, pAdapter->ScanTab.BssEntry[i].RsnIE.IE[idx]);
-            previous_ev = current_ev;
-               current_ev = iwe_stream_add_point(current_ev, end_buf, &iwe,  custom);
-            if (current_ev == previous_ev)
-#if WIRELESS_EXT >= 17
-                return -E2BIG;
-#else
-                           break;
-#endif
-        }
-#endif // IWEVGENIE //
-       }
-
-       data->length = current_ev - extra;
-    pAdapter->StaCfg.bScanReqIsFromWebUI = FALSE;
-       DBGPRINT(RT_DEBUG_ERROR ,("===>rt_ioctl_giwscan. %d(%d) BSS returned, data->length = %d\n",i , pAdapter->ScanTab.BssNr, data->length));
-       return 0;
-}
-#endif
-
-int rt_ioctl_siwessid(struct net_device *dev,
-                        struct iw_request_info *info,
-                        struct iw_point *data, char *essid)
-{
-       PRTMP_ADAPTER pAdapter = dev->ml_priv;
-
-       //check if the interface is down
-    if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
-    {
-               DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
-               return -ENETDOWN;
-    }
-
-       if (data->flags)
-       {
-               PCHAR   pSsidString = NULL;
-
-               // Includes null character.
-               if (data->length > (IW_ESSID_MAX_SIZE + 1))
-                       return -E2BIG;
-
-               pSsidString = (CHAR *) kmalloc(MAX_LEN_OF_SSID+1, MEM_ALLOC_FLAG);
-               if (pSsidString)
-               {
-                       NdisZeroMemory(pSsidString, MAX_LEN_OF_SSID+1);
-                       NdisMoveMemory(pSsidString, essid, data->length);
-                       if (Set_SSID_Proc(pAdapter, pSsidString) == FALSE)
-                               return -EINVAL;
-               }
-               else
-                       return -ENOMEM;
-       }
-       else
-       {
-               // ANY ssid
-               if (Set_SSID_Proc(pAdapter, "") == FALSE)
-                       return -EINVAL;
-    }
-       return 0;
-}
-
-int rt_ioctl_giwessid(struct net_device *dev,
-                        struct iw_request_info *info,
-                        struct iw_point *data, char *essid)
-{
-       PRTMP_ADAPTER pAdapter = dev->ml_priv;
-
-       data->flags = 1;
-    if (MONITOR_ON(pAdapter))
-    {
-        data->length  = 0;
-        return 0;
-    }
-
-       if (OPSTATUS_TEST_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED))
-       {
-               DBGPRINT(RT_DEBUG_TRACE ,("MediaState is connected\n"));
-               data->length = pAdapter->CommonCfg.SsidLen;
-               memcpy(essid, pAdapter->CommonCfg.Ssid, pAdapter->CommonCfg.SsidLen);
-       }
-#ifdef RT2870
-    // Add for RT2870
-    else if (pAdapter->StaCfg.WpaSupplicantUP != WPA_SUPPLICANT_DISABLE)
-    {
-        data->length = pAdapter->CommonCfg.SsidLen;
-               memcpy(essid, pAdapter->CommonCfg.Ssid, pAdapter->CommonCfg.SsidLen);
-       }
-#endif // RT2870 //
-       else
-       {//the ANY ssid was specified
-               data->length  = 0;
-               DBGPRINT(RT_DEBUG_TRACE ,("MediaState is not connected, ess\n"));
-       }
-
-       return 0;
-
-}
-
-int rt_ioctl_siwnickn(struct net_device *dev,
-                        struct iw_request_info *info,
-                        struct iw_point *data, char *nickname)
-{
-       PRTMP_ADAPTER pAdapter = dev->ml_priv;
-
-    //check if the interface is down
-    if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
-    {
-        DBGPRINT(RT_DEBUG_TRACE ,("INFO::Network is down!\n"));
-        return -ENETDOWN;
-    }
-
-       if (data->length > IW_ESSID_MAX_SIZE)
-               return -EINVAL;
-
-       memset(pAdapter->nickname, 0, IW_ESSID_MAX_SIZE + 1);
-       memcpy(pAdapter->nickname, nickname, data->length);
-
-
-       return 0;
-}
-
-int rt_ioctl_giwnickn(struct net_device *dev,
-                        struct iw_request_info *info,
-                        struct iw_point *data, char *nickname)
-{
-       PRTMP_ADAPTER pAdapter = dev->ml_priv;
-
-       if (data->length > strlen(pAdapter->nickname) + 1)
-               data->length = strlen(pAdapter->nickname) + 1;
-       if (data->length > 0) {
-               memcpy(nickname, pAdapter->nickname, data->length-1);
-               nickname[data->length-1] = '\0';
-       }
-       return 0;
-}
-
-int rt_ioctl_siwrts(struct net_device *dev,
-                      struct iw_request_info *info,
-                      struct iw_param *rts, char *extra)
-{
-       PRTMP_ADAPTER pAdapter = dev->ml_priv;
-       u16 val;
-
-    //check if the interface is down
-    if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
-    {
-        DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
-        return -ENETDOWN;
-    }
-
-       if (rts->disabled)
-               val = MAX_RTS_THRESHOLD;
-       else if (rts->value < 0 || rts->value > MAX_RTS_THRESHOLD)
-               return -EINVAL;
-       else if (rts->value == 0)
-           val = MAX_RTS_THRESHOLD;
-       else
-               val = rts->value;
-
-       if (val != pAdapter->CommonCfg.RtsThreshold)
-               pAdapter->CommonCfg.RtsThreshold = val;
-
-       return 0;
-}
-
-int rt_ioctl_giwrts(struct net_device *dev,
-                      struct iw_request_info *info,
-                      struct iw_param *rts, char *extra)
-{
-       PRTMP_ADAPTER pAdapter = dev->ml_priv;
-
-       //check if the interface is down
-       if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
-       {
-               DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
-               return -ENETDOWN;
-       }
-
-       rts->value = pAdapter->CommonCfg.RtsThreshold;
-       rts->disabled = (rts->value == MAX_RTS_THRESHOLD);
-       rts->fixed = 1;
-
-       return 0;
-}
-
-int rt_ioctl_siwfrag(struct net_device *dev,
-                       struct iw_request_info *info,
-                       struct iw_param *frag, char *extra)
-{
-       PRTMP_ADAPTER pAdapter = dev->ml_priv;
-       u16 val;
-
-       //check if the interface is down
-       if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
-       {
-               DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
-               return -ENETDOWN;
-       }
-
-       if (frag->disabled)
-               val = MAX_FRAG_THRESHOLD;
-       else if (frag->value >= MIN_FRAG_THRESHOLD || frag->value <= MAX_FRAG_THRESHOLD)
-        val = __cpu_to_le16(frag->value & ~0x1); /* even numbers only */
-       else if (frag->value == 0)
-           val = MAX_FRAG_THRESHOLD;
-       else
-               return -EINVAL;
-
-       pAdapter->CommonCfg.FragmentThreshold = val;
-       return 0;
-}
-
-int rt_ioctl_giwfrag(struct net_device *dev,
-                       struct iw_request_info *info,
-                       struct iw_param *frag, char *extra)
-{
-       PRTMP_ADAPTER pAdapter = dev->ml_priv;
-
-       //check if the interface is down
-       if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
-       {
-               DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
-               return -ENETDOWN;
-       }
-
-       frag->value = pAdapter->CommonCfg.FragmentThreshold;
-       frag->disabled = (frag->value == MAX_FRAG_THRESHOLD);
-       frag->fixed = 1;
-
-       return 0;
-}
-
-#define MAX_WEP_KEY_SIZE 13
-#define MIN_WEP_KEY_SIZE 5
-int rt_ioctl_siwencode(struct net_device *dev,
-                         struct iw_request_info *info,
-                         struct iw_point *erq, char *extra)
-{
-       PRTMP_ADAPTER pAdapter = dev->ml_priv;
-
-       //check if the interface is down
-       if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
-       {
-               DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
-               return -ENETDOWN;
-       }
-
-       if ((erq->length == 0) &&
-        (erq->flags & IW_ENCODE_DISABLED))
-       {
-               pAdapter->StaCfg.PairCipher = Ndis802_11WEPDisabled;
-               pAdapter->StaCfg.GroupCipher = Ndis802_11WEPDisabled;
-               pAdapter->StaCfg.WepStatus = Ndis802_11WEPDisabled;
-        pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
-        pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
-        goto done;
-       }
-       else if (erq->flags & IW_ENCODE_RESTRICTED || erq->flags & IW_ENCODE_OPEN)
-       {
-               STA_PORT_SECURED(pAdapter);
-               pAdapter->StaCfg.PairCipher = Ndis802_11WEPEnabled;
-               pAdapter->StaCfg.GroupCipher = Ndis802_11WEPEnabled;
-               pAdapter->StaCfg.WepStatus = Ndis802_11WEPEnabled;
-        pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
-               if (erq->flags & IW_ENCODE_RESTRICTED)
-                       pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeShared;
-       else
-                       pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
-       }
-
-    if (erq->length > 0)
-       {
-               int keyIdx = (erq->flags & IW_ENCODE_INDEX) - 1;
-               /* Check the size of the key */
-               if (erq->length > MAX_WEP_KEY_SIZE)
-               {
-                       return -EINVAL;
-               }
-               /* Check key index */
-               if ((keyIdx < 0) || (keyIdx >= NR_WEP_KEYS))
-        {
-            DBGPRINT(RT_DEBUG_TRACE ,("==>rt_ioctl_siwencode::Wrong keyIdx=%d! Using default key instead (%d)\n",
-                                        keyIdx, pAdapter->StaCfg.DefaultKeyId));
-
-            //Using default key
-                       keyIdx = pAdapter->StaCfg.DefaultKeyId;
-        }
-               else
-               {
-                       pAdapter->StaCfg.DefaultKeyId=keyIdx;
-               }
-
-        NdisZeroMemory(pAdapter->SharedKey[BSS0][keyIdx].Key,  16);
-
-               if (erq->length == MAX_WEP_KEY_SIZE)
-        {
-                       pAdapter->SharedKey[BSS0][keyIdx].KeyLen = MAX_WEP_KEY_SIZE;
-            pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CIPHER_WEP128;
-               }
-               else if (erq->length == MIN_WEP_KEY_SIZE)
-        {
-            pAdapter->SharedKey[BSS0][keyIdx].KeyLen = MIN_WEP_KEY_SIZE;
-            pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CIPHER_WEP64;
-               }
-               else
-                       /* Disable the key */
-                       pAdapter->SharedKey[BSS0][keyIdx].KeyLen = 0;
-
-               /* Check if the key is not marked as invalid */
-               if(!(erq->flags & IW_ENCODE_NOKEY))
-               {
-                       /* Copy the key in the driver */
-                       NdisMoveMemory(pAdapter->SharedKey[BSS0][keyIdx].Key, extra, erq->length);
-        }
-       }
-    else
-                       {
-               /* Do we want to just set the transmit key index ? */
-               int index = (erq->flags & IW_ENCODE_INDEX) - 1;
-               if ((index >= 0) && (index < 4))
-        {
-                       pAdapter->StaCfg.DefaultKeyId = index;
-            }
-        else
-                       /* Don't complain if only change the mode */
-               if (!(erq->flags & IW_ENCODE_MODE))
-                               return -EINVAL;
-       }
-
-done:
-    DBGPRINT(RT_DEBUG_TRACE ,("==>rt_ioctl_siwencode::erq->flags=%x\n",erq->flags));
-       DBGPRINT(RT_DEBUG_TRACE ,("==>rt_ioctl_siwencode::AuthMode=%x\n",pAdapter->StaCfg.AuthMode));
-       DBGPRINT(RT_DEBUG_TRACE ,("==>rt_ioctl_siwencode::DefaultKeyId=%x, KeyLen = %d\n",pAdapter->StaCfg.DefaultKeyId , pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].KeyLen));
-       DBGPRINT(RT_DEBUG_TRACE ,("==>rt_ioctl_siwencode::WepStatus=%x\n",pAdapter->StaCfg.WepStatus));
-       return 0;
-}
-
-int
-rt_ioctl_giwencode(struct net_device *dev,
-                         struct iw_request_info *info,
-                         struct iw_point *erq, char *key)
-{
-       PRTMP_ADAPTER pAdapter = dev->ml_priv;
-       int kid;
-
-       //check if the interface is down
-       if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
-       {
-               DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
-       return -ENETDOWN;
-       }
-
-       kid = erq->flags & IW_ENCODE_INDEX;
-       DBGPRINT(RT_DEBUG_TRACE, ("===>rt_ioctl_giwencode %d\n", erq->flags & IW_ENCODE_INDEX));
-
-       if (pAdapter->StaCfg.WepStatus == Ndis802_11WEPDisabled)
-       {
-               erq->length = 0;
-               erq->flags = IW_ENCODE_DISABLED;
-       }
-       else if ((kid > 0) && (kid <=4))
-       {
-               // copy wep key
-               erq->flags = kid ;                      /* NB: base 1 */
-               if (erq->length > pAdapter->SharedKey[BSS0][kid-1].KeyLen)
-                       erq->length = pAdapter->SharedKey[BSS0][kid-1].KeyLen;
-               memcpy(key, pAdapter->SharedKey[BSS0][kid-1].Key, erq->length);
-               //if ((kid == pAdapter->PortCfg.DefaultKeyId))
-               //erq->flags |= IW_ENCODE_ENABLED;      /* XXX */
-               if (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeShared)
-                       erq->flags |= IW_ENCODE_RESTRICTED;             /* XXX */
-               else
-                       erq->flags |= IW_ENCODE_OPEN;           /* XXX */
-
-       }
-       else if (kid == 0)
-       {
-               if (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeShared)
-                       erq->flags |= IW_ENCODE_RESTRICTED;             /* XXX */
-               else
-                       erq->flags |= IW_ENCODE_OPEN;           /* XXX */
-               erq->length = pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].KeyLen;
-               memcpy(key, pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].Key, erq->length);
-               // copy default key ID
-               if (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeShared)
-                       erq->flags |= IW_ENCODE_RESTRICTED;             /* XXX */
-               else
-                       erq->flags |= IW_ENCODE_OPEN;           /* XXX */
-               erq->flags = pAdapter->StaCfg.DefaultKeyId + 1;                 /* NB: base 1 */
-               erq->flags |= IW_ENCODE_ENABLED;        /* XXX */
-       }
-
-       return 0;
-
-}
-
-static int
-rt_ioctl_setparam(struct net_device *dev, struct iw_request_info *info,
-                        void *w, char *extra)
-{
-    VIRTUAL_ADAPTER    *pVirtualAd = NULL;
-       PRTMP_ADAPTER pAdapter;
-       POS_COOKIE pObj;
-       char *this_char = extra;
-       char *value;
-       int  Status=0;
-
-       if (dev->priv_flags == INT_MAIN)
-       {
-               pAdapter = dev->ml_priv;
-       }
-       else
-       {
-               pVirtualAd = dev->ml_priv;
-               pAdapter = pVirtualAd->RtmpDev->ml_priv;
-       }
-       pObj = (POS_COOKIE) pAdapter->OS_Cookie;
-
-       if (pAdapter == NULL)
-       {
-               /* if 1st open fail, pAd will be free;
-                  So the net_dev->ml_priv will be NULL in 2rd open */
-               return -ENETDOWN;
-       }
-
-       {
-               pObj->ioctl_if_type = INT_MAIN;
-        pObj->ioctl_if = MAIN_MBSSID;
-       }
-
-       //check if the interface is down
-       if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
-       {
-               DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
-                       return -ENETDOWN;
-       }
-
-       if (!*this_char)
-               return -EINVAL;
-
-       if ((value = rtstrchr(this_char, '=')) != NULL)
-           *value++ = 0;
-
-       if (!value)
-           return -EINVAL;
-
-       // reject setting nothing besides ANY ssid(ssidLen=0)
-    if (!*value && (strcmp(this_char, "SSID") != 0))
-        return -EINVAL;
-
-       for (PRTMP_PRIVATE_SET_PROC = RTMP_PRIVATE_SUPPORT_PROC; PRTMP_PRIVATE_SET_PROC->name; PRTMP_PRIVATE_SET_PROC++)
-       {
-           if (strcmp(this_char, PRTMP_PRIVATE_SET_PROC->name) == 0)
-           {
-               if(!PRTMP_PRIVATE_SET_PROC->set_proc(pAdapter, value))
-               {       //FALSE:Set private failed then return Invalid argument
-                           Status = -EINVAL;
-               }
-                   break;      //Exit for loop.
-           }
-       }
-
-       if(PRTMP_PRIVATE_SET_PROC->name == NULL)
-       {  //Not found argument
-           Status = -EINVAL;
-           DBGPRINT(RT_DEBUG_TRACE, ("===>rt_ioctl_setparam:: (iwpriv) Not Support Set Command [%s=%s]\n", this_char, value));
-       }
-
-    return Status;
-}
-
-
-static int
-rt_private_get_statistics(struct net_device *dev, struct iw_request_info *info,
-               struct iw_point *wrq, char *extra)
-{
-       INT                             Status = 0;
-    PRTMP_ADAPTER   pAd = dev->ml_priv;
-
-    if (extra == NULL)
-    {
-        wrq->length = 0;
-        return -EIO;
-    }
-
-    memset(extra, 0x00, IW_PRIV_SIZE_MASK);
-    sprintf(extra, "\n\n");
-
-       {
-    sprintf(extra+strlen(extra), "Tx success                      = %ld\n", (ULONG)pAd->WlanCounters.TransmittedFragmentCount.QuadPart);
-    sprintf(extra+strlen(extra), "Tx success without retry        = %ld\n", (ULONG)pAd->WlanCounters.TransmittedFragmentCount.QuadPart - (ULONG)pAd->WlanCounters.RetryCount.QuadPart);
-       }
-    sprintf(extra+strlen(extra), "Tx success after retry          = %ld\n", (ULONG)pAd->WlanCounters.RetryCount.QuadPart);
-    sprintf(extra+strlen(extra), "Tx fail to Rcv ACK after retry  = %ld\n", (ULONG)pAd->WlanCounters.FailedCount.QuadPart);
-    sprintf(extra+strlen(extra), "RTS Success Rcv CTS             = %ld\n", (ULONG)pAd->WlanCounters.RTSSuccessCount.QuadPart);
-    sprintf(extra+strlen(extra), "RTS Fail Rcv CTS                = %ld\n", (ULONG)pAd->WlanCounters.RTSFailureCount.QuadPart);
-
-    sprintf(extra+strlen(extra), "Rx success                      = %ld\n", (ULONG)pAd->WlanCounters.ReceivedFragmentCount.QuadPart);
-    sprintf(extra+strlen(extra), "Rx with CRC                     = %ld\n", (ULONG)pAd->WlanCounters.FCSErrorCount.QuadPart);
-    sprintf(extra+strlen(extra), "Rx drop due to out of resource  = %ld\n", (ULONG)pAd->Counters8023.RxNoBuffer);
-    sprintf(extra+strlen(extra), "Rx duplicate frame              = %ld\n", (ULONG)pAd->WlanCounters.FrameDuplicateCount.QuadPart);
-
-    sprintf(extra+strlen(extra), "False CCA (one second)          = %ld\n", (ULONG)pAd->RalinkCounters.OneSecFalseCCACnt);
-       {
-       sprintf(extra+strlen(extra), "RSSI-A                          = %ld\n", (LONG)(pAd->StaCfg.RssiSample.LastRssi0 - pAd->BbpRssiToDbmDelta));
-        sprintf(extra+strlen(extra), "RSSI-B (if available)           = %ld\n", (LONG)(pAd->StaCfg.RssiSample.LastRssi1 - pAd->BbpRssiToDbmDelta));
-        sprintf(extra+strlen(extra), "RSSI-C (if available)           = %ld\n\n", (LONG)(pAd->StaCfg.RssiSample.LastRssi2 - pAd->BbpRssiToDbmDelta));
-       }
-    sprintf(extra+strlen(extra), "WpaSupplicantUP                 = %d\n\n", pAd->StaCfg.WpaSupplicantUP);
-
-    wrq->length = strlen(extra) + 1; // 1: size of '\0'
-    DBGPRINT(RT_DEBUG_TRACE, ("<== rt_private_get_statistics, wrq->length = %d\n", wrq->length));
-
-    return Status;
-}
-
-void   getBaInfo(
-       IN      PRTMP_ADAPTER   pAd,
-       IN      PUCHAR                  pOutBuf)
-{
-       INT i, j;
-       BA_ORI_ENTRY *pOriBAEntry;
-       BA_REC_ENTRY *pRecBAEntry;
-
-       for (i=0; i<MAX_LEN_OF_MAC_TABLE; i++)
-       {
-               PMAC_TABLE_ENTRY pEntry = &pAd->MacTab.Content[i];
-               if (((pEntry->ValidAsCLI || pEntry->ValidAsApCli) && (pEntry->Sst == SST_ASSOC))
-                       || (pEntry->ValidAsWDS) || (pEntry->ValidAsMesh))
-               {
-                       sprintf(pOutBuf, "%s\n%02X:%02X:%02X:%02X:%02X:%02X (Aid = %d) (AP) -\n",
-                pOutBuf,
-                               pEntry->Addr[0], pEntry->Addr[1], pEntry->Addr[2],
-                               pEntry->Addr[3], pEntry->Addr[4], pEntry->Addr[5], pEntry->Aid);
-
-                       sprintf(pOutBuf, "%s[Recipient]\n", pOutBuf);
-                       for (j=0; j < NUM_OF_TID; j++)
-                       {
-                               if (pEntry->BARecWcidArray[j] != 0)
-                               {
-                                       pRecBAEntry =&pAd->BATable.BARecEntry[pEntry->BARecWcidArray[j]];
-                                       sprintf(pOutBuf, "%sTID=%d, BAWinSize=%d, LastIndSeq=%d, ReorderingPkts=%d\n", pOutBuf, j, pRecBAEntry->BAWinSize, pRecBAEntry->LastIndSeq, pRecBAEntry->list.qlen);
-                               }
-                       }
-                       sprintf(pOutBuf, "%s\n", pOutBuf);
-
-                       sprintf(pOutBuf, "%s[Originator]\n", pOutBuf);
-                       for (j=0; j < NUM_OF_TID; j++)
-                       {
-                               if (pEntry->BAOriWcidArray[j] != 0)
-                               {
-                                       pOriBAEntry =&pAd->BATable.BAOriEntry[pEntry->BAOriWcidArray[j]];
-                                       sprintf(pOutBuf, "%sTID=%d, BAWinSize=%d, StartSeq=%d, CurTxSeq=%d\n", pOutBuf, j, pOriBAEntry->BAWinSize, pOriBAEntry->Sequence, pEntry->TxSeq[j]);
-                               }
-                       }
-                       sprintf(pOutBuf, "%s\n\n", pOutBuf);
-               }
-        if (strlen(pOutBuf) > (IW_PRIV_SIZE_MASK - 30))
-                break;
-       }
-
-       return;
-}
-
-static int
-rt_private_show(struct net_device *dev, struct iw_request_info *info,
-               struct iw_point *wrq, char *extra)
-{
-    INT                                Status = 0;
-    VIRTUAL_ADAPTER    *pVirtualAd = NULL;
-    PRTMP_ADAPTER   pAd;
-       POS_COOKIE              pObj;
-    u32             subcmd = wrq->flags;
-
-       if (dev->priv_flags == INT_MAIN)
-               pAd = dev->ml_priv;
-       else
-       {
-               pVirtualAd = dev->ml_priv;
-               pAd = pVirtualAd->RtmpDev->ml_priv;
-       }
-       pObj = (POS_COOKIE) pAd->OS_Cookie;
-
-       if (pAd == NULL)
-       {
-               /* if 1st open fail, pAd will be free;
-                  So the net_dev->ml_priv will be NULL in 2rd open */
-               return -ENETDOWN;
-       }
-
-    if (extra == NULL)
-    {
-        wrq->length = 0;
-        return -EIO;
-    }
-    memset(extra, 0x00, IW_PRIV_SIZE_MASK);
-
-       {
-               pObj->ioctl_if_type = INT_MAIN;
-        pObj->ioctl_if = MAIN_MBSSID;
-       }
-
-    switch(subcmd)
-    {
-
-        case SHOW_CONN_STATUS:
-            if (MONITOR_ON(pAd))
-            {
-                if (pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED &&
-                    pAd->CommonCfg.RegTransmitSetting.field.BW)
-                    sprintf(extra, "Monitor Mode(CentralChannel %d)\n", pAd->CommonCfg.CentralChannel);
-                else
-                    sprintf(extra, "Monitor Mode(Channel %d)\n", pAd->CommonCfg.Channel);
-            }
-            else
-            {
-                if (pAd->IndicateMediaState == NdisMediaStateConnected)
-               {
-                   if (INFRA_ON(pAd))
-                    {
-                    sprintf(extra, "Connected(AP: %s[%02X:%02X:%02X:%02X:%02X:%02X])\n",
-                                    pAd->CommonCfg.Ssid,
-                                    pAd->CommonCfg.Bssid[0],
-                                    pAd->CommonCfg.Bssid[1],
-                                    pAd->CommonCfg.Bssid[2],
-                                    pAd->CommonCfg.Bssid[3],
-                                    pAd->CommonCfg.Bssid[4],
-                                    pAd->CommonCfg.Bssid[5]);
-                       DBGPRINT(RT_DEBUG_TRACE ,("Ssid=%s ,Ssidlen = %d\n",pAd->CommonCfg.Ssid, pAd->CommonCfg.SsidLen));
-               }
-                    else if (ADHOC_ON(pAd))
-                        sprintf(extra, "Connected\n");
-               }
-               else
-               {
-                   sprintf(extra, "Disconnected\n");
-                       DBGPRINT(RT_DEBUG_TRACE ,("ConnStatus is not connected\n"));
-               }
-            }
-            wrq->length = strlen(extra) + 1; // 1: size of '\0'
-            break;
-        case SHOW_DRVIER_VERION:
-            sprintf(extra, "Driver version-%s, %s %s\n", STA_DRIVER_VERSION, __DATE__, __TIME__ );
-            wrq->length = strlen(extra) + 1; // 1: size of '\0'
-            break;
-        case SHOW_BA_INFO:
-            getBaInfo(pAd, extra);
-            wrq->length = strlen(extra) + 1; // 1: size of '\0'
-            break;
-               case SHOW_DESC_INFO:
-                       {
-                               Show_DescInfo_Proc(pAd, NULL);
-                               wrq->length = 0; // 1: size of '\0'
-                       }
-                       break;
-        case RAIO_OFF:
-            if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
-            {
-                sprintf(extra, "Scanning\n");
-                wrq->length = strlen(extra) + 1; // 1: size of '\0'
-                break;
-            }
-            pAd->StaCfg.bSwRadio = FALSE;
-            if (pAd->StaCfg.bRadio != (pAd->StaCfg.bHwRadio && pAd->StaCfg.bSwRadio))
-            {
-                pAd->StaCfg.bRadio = (pAd->StaCfg.bHwRadio && pAd->StaCfg.bSwRadio);
-                if (pAd->StaCfg.bRadio == FALSE)
-                {
-                    MlmeRadioOff(pAd);
-                    // Update extra information
-                                       pAd->ExtraInfo = SW_RADIO_OFF;
-                }
-            }
-            sprintf(extra, "Radio Off\n");
-            wrq->length = strlen(extra) + 1; // 1: size of '\0'
-            break;
-        case RAIO_ON:
-            if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
-            {
-                sprintf(extra, "Scanning\n");
-                wrq->length = strlen(extra) + 1; // 1: size of '\0'
-                break;
-            }
-            pAd->StaCfg.bSwRadio = TRUE;
-            //if (pAd->StaCfg.bRadio != (pAd->StaCfg.bHwRadio && pAd->StaCfg.bSwRadio))
-            {
-                pAd->StaCfg.bRadio = (pAd->StaCfg.bHwRadio && pAd->StaCfg.bSwRadio);
-                if (pAd->StaCfg.bRadio == TRUE)
-                {
-                    MlmeRadioOn(pAd);
-                    // Update extra information
-                                       pAd->ExtraInfo = EXTRA_INFO_CLEAR;
-                }
-            }
-            sprintf(extra, "Radio On\n");
-            wrq->length = strlen(extra) + 1; // 1: size of '\0'
-            break;
-
-               case SHOW_CFG_VALUE:
-                       {
-                               Status = RTMPShowCfgValue(pAd, wrq->pointer, extra);
-                               if (Status == 0)
-                                       wrq->length = strlen(extra) + 1; // 1: size of '\0'
-                       }
-                       break;
-        default:
-            DBGPRINT(RT_DEBUG_TRACE, ("%s - unknow subcmd = %d\n", __func__, subcmd));
-            break;
-    }
-
-    return Status;
-}
-
-#ifdef SIOCSIWMLME
-int rt_ioctl_siwmlme(struct net_device *dev,
-                          struct iw_request_info *info,
-                          union iwreq_data *wrqu,
-                          char *extra)
-{
-       PRTMP_ADAPTER   pAd = dev->ml_priv;
-       struct iw_mlme *pMlme = (struct iw_mlme *)wrqu->data.pointer;
-       MLME_QUEUE_ELEM                         MsgElem;
-       MLME_DISASSOC_REQ_STRUCT        DisAssocReq;
-       MLME_DEAUTH_REQ_STRUCT      DeAuthReq;
-
-       DBGPRINT(RT_DEBUG_TRACE, ("====> %s\n", __func__));
-
-       if (pMlme == NULL)
-               return -EINVAL;
-
-       switch(pMlme->cmd)
-       {
-#ifdef IW_MLME_DEAUTH
-               case IW_MLME_DEAUTH:
-                       DBGPRINT(RT_DEBUG_TRACE, ("====> %s - IW_MLME_DEAUTH\n", __func__));
-                       COPY_MAC_ADDR(DeAuthReq.Addr, pAd->CommonCfg.Bssid);
-                       DeAuthReq.Reason = pMlme->reason_code;
-                       MsgElem.MsgLen = sizeof(MLME_DEAUTH_REQ_STRUCT);
-                       NdisMoveMemory(MsgElem.Msg, &DeAuthReq, sizeof(MLME_DEAUTH_REQ_STRUCT));
-                       MlmeDeauthReqAction(pAd, &MsgElem);
-                       if (INFRA_ON(pAd))
-                       {
-                           LinkDown(pAd, FALSE);
-                           pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
-                       }
-                       break;
-#endif // IW_MLME_DEAUTH //
-#ifdef IW_MLME_DISASSOC
-               case IW_MLME_DISASSOC:
-                       DBGPRINT(RT_DEBUG_TRACE, ("====> %s - IW_MLME_DISASSOC\n", __func__));
-                       COPY_MAC_ADDR(DisAssocReq.Addr, pAd->CommonCfg.Bssid);
-                       DisAssocReq.Reason =  pMlme->reason_code;
-
-                       MsgElem.Machine = ASSOC_STATE_MACHINE;
-                       MsgElem.MsgType = MT2_MLME_DISASSOC_REQ;
-                       MsgElem.MsgLen = sizeof(MLME_DISASSOC_REQ_STRUCT);
-                       NdisMoveMemory(MsgElem.Msg, &DisAssocReq, sizeof(MLME_DISASSOC_REQ_STRUCT));
-
-                       pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_OID_DISASSOC;
-                       MlmeDisassocReqAction(pAd, &MsgElem);
-                       break;
-#endif // IW_MLME_DISASSOC //
-               default:
-                       DBGPRINT(RT_DEBUG_TRACE, ("====> %s - Unknow Command\n", __func__));
-                       break;
-       }
-
-       return 0;
-}
-#endif // SIOCSIWMLME //
-
-#if WIRELESS_EXT > 17
-int rt_ioctl_siwauth(struct net_device *dev,
-                         struct iw_request_info *info,
-                         union iwreq_data *wrqu, char *extra)
-{
-       PRTMP_ADAPTER   pAdapter = dev->ml_priv;
-       struct iw_param *param = &wrqu->param;
-
-    //check if the interface is down
-       if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
-       {
-               DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
-       return -ENETDOWN;
-       }
-       switch (param->flags & IW_AUTH_INDEX) {
-       case IW_AUTH_WPA_VERSION:
-            if (param->value == IW_AUTH_WPA_VERSION_WPA)
-            {
-                pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPAPSK;
-                               if (pAdapter->StaCfg.BssType == BSS_ADHOC)
-                                       pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPANone;
-            }
-            else if (param->value == IW_AUTH_WPA_VERSION_WPA2)
-                pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA2PSK;
-
-            DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_WPA_VERSION - param->value = %d!\n", __func__, param->value));
-            break;
-       case IW_AUTH_CIPHER_PAIRWISE:
-            if (param->value == IW_AUTH_CIPHER_NONE)
-            {
-                pAdapter->StaCfg.WepStatus = Ndis802_11WEPDisabled;
-                pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
-                pAdapter->StaCfg.PairCipher = Ndis802_11WEPDisabled;
-            }
-            else if (param->value == IW_AUTH_CIPHER_WEP40 ||
-                     param->value == IW_AUTH_CIPHER_WEP104)
-            {
-                pAdapter->StaCfg.WepStatus = Ndis802_11WEPEnabled;
-                pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
-                pAdapter->StaCfg.PairCipher = Ndis802_11WEPEnabled;
-                pAdapter->StaCfg.IEEE8021X = FALSE;
-            }
-            else if (param->value == IW_AUTH_CIPHER_TKIP)
-            {
-                pAdapter->StaCfg.WepStatus = Ndis802_11Encryption2Enabled;
-                pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
-                pAdapter->StaCfg.PairCipher = Ndis802_11Encryption2Enabled;
-            }
-            else if (param->value == IW_AUTH_CIPHER_CCMP)
-            {
-                pAdapter->StaCfg.WepStatus = Ndis802_11Encryption3Enabled;
-                pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
-                pAdapter->StaCfg.PairCipher = Ndis802_11Encryption3Enabled;
-            }
-            DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_CIPHER_PAIRWISE - param->value = %d!\n", __func__, param->value));
-            break;
-       case IW_AUTH_CIPHER_GROUP:
-            if (param->value == IW_AUTH_CIPHER_NONE)
-            {
-                pAdapter->StaCfg.GroupCipher = Ndis802_11WEPDisabled;
-            }
-            else if (param->value == IW_AUTH_CIPHER_WEP40 ||
-                     param->value == IW_AUTH_CIPHER_WEP104)
-            {
-                pAdapter->StaCfg.GroupCipher = Ndis802_11WEPEnabled;
-            }
-            else if (param->value == IW_AUTH_CIPHER_TKIP)
-            {
-                pAdapter->StaCfg.GroupCipher = Ndis802_11Encryption2Enabled;
-            }
-            else if (param->value == IW_AUTH_CIPHER_CCMP)
-            {
-                pAdapter->StaCfg.GroupCipher = Ndis802_11Encryption3Enabled;
-            }
-            DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_CIPHER_GROUP - param->value = %d!\n", __func__, param->value));
-            break;
-       case IW_AUTH_KEY_MGMT:
-            if (param->value == IW_AUTH_KEY_MGMT_802_1X)
-            {
-                if (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK)
-                {
-                    pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA;
-                    pAdapter->StaCfg.IEEE8021X = FALSE;
-                }
-                else if (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK)
-                {
-                    pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA2;
-                    pAdapter->StaCfg.IEEE8021X = FALSE;
-                }
-                else
-                    // WEP 1x
-                    pAdapter->StaCfg.IEEE8021X = TRUE;
-            }
-            else if (param->value == 0)
-            {
-                               STA_PORT_SECURED(pAdapter);
-            }
-            DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_KEY_MGMT - param->value = %d!\n", __func__, param->value));
-            break;
-       case IW_AUTH_RX_UNENCRYPTED_EAPOL:
-            break;
-       case IW_AUTH_PRIVACY_INVOKED:
-            DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_PRIVACY_INVOKED - param->value = %d!\n", __func__, param->value));
-               break;
-       case IW_AUTH_DROP_UNENCRYPTED:
-            if (param->value != 0)
-                pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED;
-                       else
-                       {
-                               STA_PORT_SECURED(pAdapter);
-                       }
-            DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_WPA_VERSION - param->value = %d!\n", __func__, param->value));
-               break;
-       case IW_AUTH_80211_AUTH_ALG:
-                       if (param->value & IW_AUTH_ALG_SHARED_KEY)
-            {
-                               pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeShared;
-                       }
-            else if (param->value & IW_AUTH_ALG_OPEN_SYSTEM)
-            {
-                               pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
-                       }
-            else
-                               return -EINVAL;
-            DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_80211_AUTH_ALG - param->value = %d!\n", __func__, param->value));
-                       break;
-       case IW_AUTH_WPA_ENABLED:
-                       DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_WPA_ENABLED - Driver supports WPA!(param->value = %d)\n", __func__, param->value));
-               break;
-       default:
-               return -EOPNOTSUPP;
-}
-
-       return 0;
-}
-
-int rt_ioctl_giwauth(struct net_device *dev,
-                              struct iw_request_info *info,
-                              union iwreq_data *wrqu, char *extra)
-{
-       PRTMP_ADAPTER   pAdapter = dev->ml_priv;
-       struct iw_param *param = &wrqu->param;
-
-    //check if the interface is down
-       if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
-    {
-               DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
-       return -ENETDOWN;
-    }
-
-       switch (param->flags & IW_AUTH_INDEX) {
-       case IW_AUTH_DROP_UNENCRYPTED:
-        param->value = (pAdapter->StaCfg.WepStatus == Ndis802_11WEPDisabled) ? 0 : 1;
-               break;
-
-       case IW_AUTH_80211_AUTH_ALG:
-        param->value = (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeShared) ? IW_AUTH_ALG_SHARED_KEY : IW_AUTH_ALG_OPEN_SYSTEM;
-               break;
-
-       case IW_AUTH_WPA_ENABLED:
-               param->value = (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA) ? 1 : 0;
-               break;
-
-       default:
-               return -EOPNOTSUPP;
-       }
-    DBGPRINT(RT_DEBUG_TRACE, ("rt_ioctl_giwauth::param->value = %d!\n", param->value));
-       return 0;
-}
-
-void fnSetCipherKey(
-    IN  PRTMP_ADAPTER   pAdapter,
-    IN  INT             keyIdx,
-    IN  UCHAR           CipherAlg,
-    IN  BOOLEAN         bGTK,
-    IN  struct iw_encode_ext *ext)
-{
-    NdisZeroMemory(&pAdapter->SharedKey[BSS0][keyIdx], sizeof(CIPHER_KEY));
-    pAdapter->SharedKey[BSS0][keyIdx].KeyLen = LEN_TKIP_EK;
-    NdisMoveMemory(pAdapter->SharedKey[BSS0][keyIdx].Key, ext->key, LEN_TKIP_EK);
-    NdisMoveMemory(pAdapter->SharedKey[BSS0][keyIdx].TxMic, ext->key + LEN_TKIP_EK, LEN_TKIP_TXMICK);
-    NdisMoveMemory(pAdapter->SharedKey[BSS0][keyIdx].RxMic, ext->key + LEN_TKIP_EK + LEN_TKIP_TXMICK, LEN_TKIP_RXMICK);
-    pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CipherAlg;
-
-    // Update group key information to ASIC Shared Key Table
-       AsicAddSharedKeyEntry(pAdapter,
-                                                 BSS0,
-                                                 keyIdx,
-                                                 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg,
-                                                 pAdapter->SharedKey[BSS0][keyIdx].Key,
-                                                 pAdapter->SharedKey[BSS0][keyIdx].TxMic,
-                                                 pAdapter->SharedKey[BSS0][keyIdx].RxMic);
-
-    if (bGTK)
-        // Update ASIC WCID attribute table and IVEIV table
-       RTMPAddWcidAttributeEntry(pAdapter,
-                                                         BSS0,
-                                                         keyIdx,
-                                                         pAdapter->SharedKey[BSS0][keyIdx].CipherAlg,
-                                                         NULL);
-    else
-        // Update ASIC WCID attribute table and IVEIV table
-       RTMPAddWcidAttributeEntry(pAdapter,
-                                                         BSS0,
-                                                         keyIdx,
-                                                         pAdapter->SharedKey[BSS0][keyIdx].CipherAlg,
-                                                         &pAdapter->MacTab.Content[BSSID_WCID]);
-}
-
-int rt_ioctl_siwencodeext(struct net_device *dev,
-                          struct iw_request_info *info,
-                          union iwreq_data *wrqu,
-                          char *extra)
-                       {
-    PRTMP_ADAPTER   pAdapter = dev->ml_priv;
-       struct iw_point *encoding = &wrqu->encoding;
-       struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
-    int keyIdx, alg = ext->alg;
-
-    //check if the interface is down
-       if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
-       {
-               DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
-       return -ENETDOWN;
-       }
-
-    if (encoding->flags & IW_ENCODE_DISABLED)
-       {
-        keyIdx = (encoding->flags & IW_ENCODE_INDEX) - 1;
-        // set BSSID wcid entry of the Pair-wise Key table as no-security mode
-           AsicRemovePairwiseKeyEntry(pAdapter, BSS0, BSSID_WCID);
-        pAdapter->SharedKey[BSS0][keyIdx].KeyLen = 0;
-               pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CIPHER_NONE;
-               AsicRemoveSharedKeyEntry(pAdapter, 0, (UCHAR)keyIdx);
-        NdisZeroMemory(&pAdapter->SharedKey[BSS0][keyIdx], sizeof(CIPHER_KEY));
-        DBGPRINT(RT_DEBUG_TRACE, ("%s::Remove all keys!(encoding->flags = %x)\n", __func__, encoding->flags));
-    }
-                                       else
-    {
-        // Get Key Index and convet to our own defined key index
-       keyIdx = (encoding->flags & IW_ENCODE_INDEX) - 1;
-       if((keyIdx < 0) || (keyIdx >= NR_WEP_KEYS))
-               return -EINVAL;
-
-        if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
-        {
-            pAdapter->StaCfg.DefaultKeyId = keyIdx;
-            DBGPRINT(RT_DEBUG_TRACE, ("%s::DefaultKeyId = %d\n", __func__, pAdapter->StaCfg.DefaultKeyId));
-        }
-
-        switch (alg) {
-               case IW_ENCODE_ALG_NONE:
-                DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_ENCODE_ALG_NONE\n", __func__));
-                       break;
-               case IW_ENCODE_ALG_WEP:
-                DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_ENCODE_ALG_WEP - ext->key_len = %d, keyIdx = %d\n", __func__, ext->key_len, keyIdx));
-                       if (ext->key_len == MAX_WEP_KEY_SIZE)
-                {
-                               pAdapter->SharedKey[BSS0][keyIdx].KeyLen = MAX_WEP_KEY_SIZE;
-                    pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CIPHER_WEP128;
-                               }
-                       else if (ext->key_len == MIN_WEP_KEY_SIZE)
-                {
-                    pAdapter->SharedKey[BSS0][keyIdx].KeyLen = MIN_WEP_KEY_SIZE;
-                    pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CIPHER_WEP64;
-                       }
-                       else
-                    return -EINVAL;
-
-                NdisZeroMemory(pAdapter->SharedKey[BSS0][keyIdx].Key,  16);
-                           NdisMoveMemory(pAdapter->SharedKey[BSS0][keyIdx].Key, ext->key, ext->key_len);
-                       break;
-            case IW_ENCODE_ALG_TKIP:
-                DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_ENCODE_ALG_TKIP - keyIdx = %d, ext->key_len = %d\n", __func__, keyIdx, ext->key_len));
-                if (ext->key_len == 32)
-                {
-                    if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
-                    {
-                        fnSetCipherKey(pAdapter, keyIdx, CIPHER_TKIP, FALSE, ext);
-                        if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA2)
-                        {
-                            STA_PORT_SECURED(pAdapter);
-                        }
-               }
-                    else if (ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY)
-                    {
-                        fnSetCipherKey(pAdapter, keyIdx, CIPHER_TKIP, TRUE, ext);
-
-                        // set 802.1x port control
-                       STA_PORT_SECURED(pAdapter);
-                    }
-                }
-                else
-                    return -EINVAL;
-                break;
-            case IW_ENCODE_ALG_CCMP:
-                if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
-               {
-                    fnSetCipherKey(pAdapter, keyIdx, CIPHER_AES, FALSE, ext);
-                    if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA2)
-                       STA_PORT_SECURED(pAdapter);
-                }
-                else if (ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY)
-                {
-                    fnSetCipherKey(pAdapter, keyIdx, CIPHER_AES, TRUE, ext);
-
-                    // set 802.1x port control
-                       STA_PORT_SECURED(pAdapter);
-                }
-                break;
-               default:
-                       return -EINVAL;
-               }
-    }
-
-    return 0;
-}
-
-int
-rt_ioctl_giwencodeext(struct net_device *dev,
-                         struct iw_request_info *info,
-                         union iwreq_data *wrqu, char *extra)
-{
-       PRTMP_ADAPTER pAd = dev->ml_priv;
-       PCHAR pKey = NULL;
-       struct iw_point *encoding = &wrqu->encoding;
-       struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
-       int idx, max_key_len;
-
-       DBGPRINT(RT_DEBUG_TRACE ,("===> rt_ioctl_giwencodeext\n"));
-
-       max_key_len = encoding->length - sizeof(*ext);
-       if (max_key_len < 0)
-               return -EINVAL;
-
-       idx = encoding->flags & IW_ENCODE_INDEX;
-       if (idx)
-       {
-               if (idx < 1 || idx > 4)
-                       return -EINVAL;
-               idx--;
-
-               if ((pAd->StaCfg.WepStatus == Ndis802_11Encryption2Enabled) ||
-                       (pAd->StaCfg.WepStatus == Ndis802_11Encryption3Enabled))
-               {
-                       if (idx != pAd->StaCfg.DefaultKeyId)
-                       {
-                               ext->key_len = 0;
-                               return 0;
-                       }
-               }
-       }
-       else
-               idx = pAd->StaCfg.DefaultKeyId;
-
-       encoding->flags = idx + 1;
-       memset(ext, 0, sizeof(*ext));
-
-       ext->key_len = 0;
-       switch(pAd->StaCfg.WepStatus) {
-               case Ndis802_11WEPDisabled:
-                       ext->alg = IW_ENCODE_ALG_NONE;
-                       encoding->flags |= IW_ENCODE_DISABLED;
-                       break;
-               case Ndis802_11WEPEnabled:
-                       ext->alg = IW_ENCODE_ALG_WEP;
-                       if (pAd->SharedKey[BSS0][idx].KeyLen > max_key_len)
-                               return -E2BIG;
-                       else
-                       {
-                               ext->key_len = pAd->SharedKey[BSS0][idx].KeyLen;
-                               pKey = &(pAd->SharedKey[BSS0][idx].Key[0]);
-                       }
-                       break;
-               case Ndis802_11Encryption2Enabled:
-               case Ndis802_11Encryption3Enabled:
-                       if (pAd->StaCfg.WepStatus == Ndis802_11Encryption2Enabled)
-                               ext->alg = IW_ENCODE_ALG_TKIP;
-                       else
-                               ext->alg = IW_ENCODE_ALG_CCMP;
-
-                       if (max_key_len < 32)
-                               return -E2BIG;
-                       else
-                       {
-                               ext->key_len = 32;
-                               pKey = &pAd->StaCfg.PMK[0];
-                       }
-                       break;
-               default:
-                       return -EINVAL;
-       }
-
-       if (ext->key_len && pKey)
-       {
-               encoding->flags |= IW_ENCODE_ENABLED;
-               memcpy(ext->key, pKey, ext->key_len);
-       }
-
-       return 0;
-}
-
-#ifdef SIOCSIWGENIE
-int rt_ioctl_siwgenie(struct net_device *dev,
-                         struct iw_request_info *info,
-                         union iwreq_data *wrqu, char *extra)
-{
-       PRTMP_ADAPTER   pAd = dev->ml_priv;
-
-       if (wrqu->data.length > MAX_LEN_OF_RSNIE ||
-           (wrqu->data.length && extra == NULL))
-               return -EINVAL;
-
-       if (wrqu->data.length)
-       {
-               pAd->StaCfg.RSNIE_Len = wrqu->data.length;
-               NdisMoveMemory(&pAd->StaCfg.RSN_IE[0], extra, pAd->StaCfg.RSNIE_Len);
-       }
-       else
-       {
-               pAd->StaCfg.RSNIE_Len = 0;
-               NdisZeroMemory(&pAd->StaCfg.RSN_IE[0], MAX_LEN_OF_RSNIE);
-       }
-
-       return 0;
-}
-#endif // SIOCSIWGENIE //
-
-int rt_ioctl_giwgenie(struct net_device *dev,
-                              struct iw_request_info *info,
-                              union iwreq_data *wrqu, char *extra)
-{
-       PRTMP_ADAPTER   pAd = dev->ml_priv;
-
-       if ((pAd->StaCfg.RSNIE_Len == 0) ||
-               (pAd->StaCfg.AuthMode < Ndis802_11AuthModeWPA))
-       {
-               wrqu->data.length = 0;
-               return 0;
-       }
-
-#ifdef SIOCSIWGENIE
-       if (pAd->StaCfg.WpaSupplicantUP == WPA_SUPPLICANT_ENABLE)
-       {
-       if (wrqu->data.length < pAd->StaCfg.RSNIE_Len)
-               return -E2BIG;
-
-       wrqu->data.length = pAd->StaCfg.RSNIE_Len;
-       memcpy(extra, &pAd->StaCfg.RSN_IE[0], pAd->StaCfg.RSNIE_Len);
-       }
-       else
-#endif // SIOCSIWGENIE //
-       {
-               UCHAR RSNIe = IE_WPA;
-
-               if (wrqu->data.length < (pAd->StaCfg.RSNIE_Len + 2)) // ID, Len
-                       return -E2BIG;
-               wrqu->data.length = pAd->StaCfg.RSNIE_Len + 2;
-
-               if ((pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK) ||
-            (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2))
-                       RSNIe = IE_RSN;
-
-               extra[0] = (char)RSNIe;
-               extra[1] = pAd->StaCfg.RSNIE_Len;
-               memcpy(extra+2, &pAd->StaCfg.RSN_IE[0], pAd->StaCfg.RSNIE_Len);
-       }
-
-       return 0;
-}
-
-int rt_ioctl_siwpmksa(struct net_device *dev,
-                          struct iw_request_info *info,
-                          union iwreq_data *wrqu,
-                          char *extra)
-{
-       PRTMP_ADAPTER   pAd = dev->ml_priv;
-       struct iw_pmksa *pPmksa = (struct iw_pmksa *)wrqu->data.pointer;
-       INT     CachedIdx = 0, idx = 0;
-
-       if (pPmksa == NULL)
-               return -EINVAL;
-
-       DBGPRINT(RT_DEBUG_TRACE ,("===> rt_ioctl_siwpmksa\n"));
-       switch(pPmksa->cmd)
-       {
-               case IW_PMKSA_FLUSH:
-                       NdisZeroMemory(pAd->StaCfg.SavedPMK, sizeof(BSSID_INFO)*PMKID_NO);
-                       DBGPRINT(RT_DEBUG_TRACE ,("rt_ioctl_siwpmksa - IW_PMKSA_FLUSH\n"));
-                       break;
-               case IW_PMKSA_REMOVE:
-                       for (CachedIdx = 0; CachedIdx < pAd->StaCfg.SavedPMKNum; CachedIdx++)
-                       {
-                       // compare the BSSID
-                       if (NdisEqualMemory(pPmksa->bssid.sa_data, pAd->StaCfg.SavedPMK[CachedIdx].BSSID, MAC_ADDR_LEN))
-                       {
-                               NdisZeroMemory(pAd->StaCfg.SavedPMK[CachedIdx].BSSID, MAC_ADDR_LEN);
-                                       NdisZeroMemory(pAd->StaCfg.SavedPMK[CachedIdx].PMKID, 16);
-                                       for (idx = CachedIdx; idx < (pAd->StaCfg.SavedPMKNum - 1); idx++)
-                                       {
-                                               NdisMoveMemory(&pAd->StaCfg.SavedPMK[idx].BSSID[0], &pAd->StaCfg.SavedPMK[idx+1].BSSID[0], MAC_ADDR_LEN);
-                                               NdisMoveMemory(&pAd->StaCfg.SavedPMK[idx].PMKID[0], &pAd->StaCfg.SavedPMK[idx+1].PMKID[0], 16);
-                                       }
-                                       pAd->StaCfg.SavedPMKNum--;
-                               break;
-                       }
-               }
-
-                       DBGPRINT(RT_DEBUG_TRACE ,("rt_ioctl_siwpmksa - IW_PMKSA_REMOVE\n"));
-                       break;
-               case IW_PMKSA_ADD:
-                       for (CachedIdx = 0; CachedIdx < pAd->StaCfg.SavedPMKNum; CachedIdx++)
-                       {
-                       // compare the BSSID
-                       if (NdisEqualMemory(pPmksa->bssid.sa_data, pAd->StaCfg.SavedPMK[CachedIdx].BSSID, MAC_ADDR_LEN))
-                               break;
-               }
-
-               // Found, replace it
-               if (CachedIdx < PMKID_NO)
-               {
-                       DBGPRINT(RT_DEBUG_OFF, ("Update PMKID, idx = %d\n", CachedIdx));
-                       NdisMoveMemory(&pAd->StaCfg.SavedPMK[CachedIdx].BSSID[0], pPmksa->bssid.sa_data, MAC_ADDR_LEN);
-                               NdisMoveMemory(&pAd->StaCfg.SavedPMK[CachedIdx].PMKID[0], pPmksa->pmkid, 16);
-                       pAd->StaCfg.SavedPMKNum++;
-               }
-               // Not found, replace the last one
-               else
-               {
-                       // Randomly replace one
-                       CachedIdx = (pPmksa->bssid.sa_data[5] % PMKID_NO);
-                       DBGPRINT(RT_DEBUG_OFF, ("Update PMKID, idx = %d\n", CachedIdx));
-                       NdisMoveMemory(&pAd->StaCfg.SavedPMK[CachedIdx].BSSID[0], pPmksa->bssid.sa_data, MAC_ADDR_LEN);
-                               NdisMoveMemory(&pAd->StaCfg.SavedPMK[CachedIdx].PMKID[0], pPmksa->pmkid, 16);
-               }
-
-                       DBGPRINT(RT_DEBUG_TRACE ,("rt_ioctl_siwpmksa - IW_PMKSA_ADD\n"));
-                       break;
-               default:
-                       DBGPRINT(RT_DEBUG_TRACE ,("rt_ioctl_siwpmksa - Unknow Command!!\n"));
-                       break;
-       }
-
-       return 0;
-}
-#endif // #if WIRELESS_EXT > 17
-
-#ifdef DBG
-static int
-rt_private_ioctl_bbp(struct net_device *dev, struct iw_request_info *info,
-               struct iw_point *wrq, char *extra)
-                       {
-       CHAR                            *this_char;
-       CHAR                            *value = NULL;
-       UCHAR                           regBBP = 0;
-       UINT32                          bbpId;
-       UINT32                          bbpValue;
-       BOOLEAN                         bIsPrintAllBBP = FALSE;
-       INT                                     Status = 0;
-    PRTMP_ADAPTER       pAdapter = dev->ml_priv;
-
-
-       memset(extra, 0x00, IW_PRIV_SIZE_MASK);
-
-       if (wrq->length > 1) //No parameters.
-                               {
-               sprintf(extra, "\n");
-
-               //Parsing Read or Write
-               this_char = wrq->pointer;
-               DBGPRINT(RT_DEBUG_TRACE, ("this_char=%s\n", this_char));
-               if (!*this_char)
-                       goto next;
-
-               if ((value = rtstrchr(this_char, '=')) != NULL)
-                       *value++ = 0;
-
-               if (!value || !*value)
-               { //Read
-                       DBGPRINT(RT_DEBUG_TRACE, ("this_char=%s, value=%s\n", this_char, value));
-                       if (sscanf(this_char, "%d", &(bbpId)) == 1)
-                       {
-#ifndef RT30xx
-                               if (bbpId <= 136)
-#endif // RT30xx //
-#ifdef RT30xx
-                               if (bbpId <= 138)  // edit by johnli, RF power sequence setup, add BBP R138 for ADC dynamic on/off control
-#endif // RT30xx //
-                               {
-                                       {
-                                       RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, &regBBP);
-                                       }
-                                       sprintf(extra+strlen(extra), "R%02d[0x%02X]:%02X\n", bbpId, bbpId*2, regBBP);
-                    wrq->length = strlen(extra) + 1; // 1: size of '\0'
-                                       DBGPRINT(RT_DEBUG_TRACE, ("msg=%s\n", extra));
-                               }
-                               else
-                               {//Invalid parametes, so default printk all bbp
-                                       bIsPrintAllBBP = TRUE;
-                                       goto next;
-                               }
-                       }
-                       else
-                       { //Invalid parametes, so default printk all bbp
-                               bIsPrintAllBBP = TRUE;
-                               goto next;
-                       }
-               }
-               else
-               { //Write
-                       if ((sscanf(this_char, "%d", &(bbpId)) == 1) && (sscanf(value, "%x", &(bbpValue)) == 1))
-                       {
-#ifndef RT30xx
-                               if (bbpId <= 136)
-#endif // RT30xx //
-#ifdef RT30xx
-                               if (bbpId <= 138)  // edit by johnli, RF power sequence setup, add BBP R138 for ADC dynamic on/off control
-#endif // RT30xx //
-                               {
-                                       {
-                                           RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, bbpId, bbpValue);
-                                       //Read it back for showing
-                                       RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, &regBBP);
-                       }
-                                       sprintf(extra+strlen(extra), "R%02d[0x%02X]:%02X\n", bbpId, bbpId*2, regBBP);
-                    wrq->length = strlen(extra) + 1; // 1: size of '\0'
-                                       DBGPRINT(RT_DEBUG_TRACE, ("msg=%s\n", extra));
-                               }
-                               else
-                               {//Invalid parametes, so default printk all bbp
-                                       bIsPrintAllBBP = TRUE;
-                                       goto next;
-                               }
-                       }
-                       else
-                       { //Invalid parametes, so default printk all bbp
-                               bIsPrintAllBBP = TRUE;
-                               goto next;
-                       }
-               }
-               }
-       else
-               bIsPrintAllBBP = TRUE;
-
-next:
-       if (bIsPrintAllBBP)
-       {
-               memset(extra, 0x00, IW_PRIV_SIZE_MASK);
-               sprintf(extra, "\n");
-#ifndef RT30xx
-               for (bbpId = 0; bbpId <= 136; bbpId++)
-#endif // RT30xx //
-#ifdef RT30xx
-               for (bbpId = 0; bbpId <= 138; bbpId++)  // edit by johnli, RF power sequence setup, add BBP R138 for ADC dynamic on/off control
-#endif // RT30xx //
-               {
-                   if (strlen(extra) >= (IW_PRIV_SIZE_MASK - 10))
-                break;
-                       RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, &regBBP);
-/*
-                       sprintf(extra+strlen(extra), "R%02d[0x%02X]:%02X    ", bbpId, bbpId*2, regBBP);
-                       if (bbpId%5 == 4)
-                               sprintf(extra+strlen(extra), "\n");
-*/
-                       sprintf(extra+strlen(extra), "%03d = %02X\n", bbpId, regBBP);  // edit by johnli, change display format
-               }
-
-        wrq->length = strlen(extra) + 1; // 1: size of '\0'
-        DBGPRINT(RT_DEBUG_TRACE, ("wrq->length = %d\n", wrq->length));
-       }
-
-       DBGPRINT(RT_DEBUG_TRACE, ("<==rt_private_ioctl_bbp\n\n"));
-
-    return Status;
-}
-#endif // DBG //
-
-int rt_ioctl_siwrate(struct net_device *dev,
-                       struct iw_request_info *info,
-                       union iwreq_data *wrqu, char *extra)
-{
-    PRTMP_ADAPTER   pAd = dev->ml_priv;
-    UINT32          rate = wrqu->bitrate.value, fixed = wrqu->bitrate.fixed;
-
-    //check if the interface is down
-       if(!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_IN_USE))
-       {
-               DBGPRINT(RT_DEBUG_TRACE, ("rt_ioctl_siwrate::Network is down!\n"));
-       return -ENETDOWN;
-       }
-
-    DBGPRINT(RT_DEBUG_TRACE, ("rt_ioctl_siwrate::(rate = %d, fixed = %d)\n", rate, fixed));
-    /* rate = -1 => auto rate
-       rate = X, fixed = 1 => (fixed rate X)
-    */
-    if (rate == -1)
-    {
-               //Auto Rate
-               pAd->StaCfg.DesiredTransmitSetting.field.MCS = MCS_AUTO;
-               pAd->StaCfg.bAutoTxRateSwitch = TRUE;
-               if ((pAd->CommonCfg.PhyMode <= PHY_11G) ||
-                   (pAd->MacTab.Content[BSSID_WCID].HTPhyMode.field.MODE <= MODE_OFDM))
-                       RTMPSetDesiredRates(pAd, -1);
-
-               SetCommonHT(pAd);
-    }
-    else
-    {
-        if (fixed)
-        {
-               pAd->StaCfg.bAutoTxRateSwitch = FALSE;
-            if ((pAd->CommonCfg.PhyMode <= PHY_11G) ||
-                (pAd->MacTab.Content[BSSID_WCID].HTPhyMode.field.MODE <= MODE_OFDM))
-                RTMPSetDesiredRates(pAd, rate);
-            else
-            {
-                pAd->StaCfg.DesiredTransmitSetting.field.MCS = MCS_AUTO;
-                SetCommonHT(pAd);
-            }
-            DBGPRINT(RT_DEBUG_TRACE, ("rt_ioctl_siwrate::(HtMcs=%d)\n",pAd->StaCfg.DesiredTransmitSetting.field.MCS));
-        }
-        else
-        {
-            // TODO: rate = X, fixed = 0 => (rates <= X)
-            return -EOPNOTSUPP;
-        }
-    }
-
-    return 0;
-}
-
-int rt_ioctl_giwrate(struct net_device *dev,
-                              struct iw_request_info *info,
-                              union iwreq_data *wrqu, char *extra)
-{
-    PRTMP_ADAPTER   pAd = dev->ml_priv;
-    int rate_index = 0, rate_count = 0;
-    HTTRANSMIT_SETTING ht_setting;
-    __s32 ralinkrate[] =
-       {2,  4,   11,  22, // CCK
-       12, 18,   24,  36, 48, 72, 96, 108, // OFDM
-       13, 26,   39,  52,  78, 104, 117, 130, 26,  52,  78, 104, 156, 208, 234, 260, // 20MHz, 800ns GI, MCS: 0 ~ 15
-       39, 78,  117, 156, 234, 312, 351, 390,                                                                            // 20MHz, 800ns GI, MCS: 16 ~ 23
-       27, 54,   81, 108, 162, 216, 243, 270, 54, 108, 162, 216, 324, 432, 486, 540, // 40MHz, 800ns GI, MCS: 0 ~ 15
-       81, 162, 243, 324, 486, 648, 729, 810,                                                                            // 40MHz, 800ns GI, MCS: 16 ~ 23
-       14, 29,   43,  57,  87, 115, 130, 144, 29, 59,   87, 115, 173, 230, 260, 288, // 20MHz, 400ns GI, MCS: 0 ~ 15
-       43, 87,  130, 173, 260, 317, 390, 433,                                                                            // 20MHz, 400ns GI, MCS: 16 ~ 23
-       30, 60,   90, 120, 180, 240, 270, 300, 60, 120, 180, 240, 360, 480, 540, 600, // 40MHz, 400ns GI, MCS: 0 ~ 15
-       90, 180, 270, 360, 540, 720, 810, 900};                                                                           // 40MHz, 400ns GI, MCS: 16 ~ 23
-
-    rate_count = sizeof(ralinkrate)/sizeof(__s32);
-    //check if the interface is down
-       if(!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_IN_USE))
-       {
-               DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
-       return -ENETDOWN;
-       }
-
-    if ((pAd->StaCfg.bAutoTxRateSwitch == FALSE) &&
-        (INFRA_ON(pAd)) &&
-        ((pAd->CommonCfg.PhyMode <= PHY_11G) || (pAd->MacTab.Content[BSSID_WCID].HTPhyMode.field.MODE <= MODE_OFDM)))
-        ht_setting.word = pAd->StaCfg.HTPhyMode.word;
-    else
-        ht_setting.word = pAd->MacTab.Content[BSSID_WCID].HTPhyMode.word;
-
-    if (ht_setting.field.MODE >= MODE_HTMIX)
-    {
-       rate_index = 12 + ((UCHAR)ht_setting.field.BW *24) + ((UCHAR)ht_setting.field.ShortGI *48) + ((UCHAR)ht_setting.field.MCS);
-    }
-    else
-    if (ht_setting.field.MODE == MODE_OFDM)
-       rate_index = (UCHAR)(ht_setting.field.MCS) + 4;
-    else if (ht_setting.field.MODE == MODE_CCK)
-       rate_index = (UCHAR)(ht_setting.field.MCS);
-
-    if (rate_index < 0)
-        rate_index = 0;
-
-    if (rate_index > rate_count)
-        rate_index = rate_count;
-
-    wrqu->bitrate.value = ralinkrate[rate_index] * 500000;
-    wrqu->bitrate.disabled = 0;
-
-    return 0;
-}
-
-static const iw_handler rt_handler[] =
-{
-       (iw_handler) NULL,                                  /* SIOCSIWCOMMIT */
-       (iw_handler) rt_ioctl_giwname,                  /* SIOCGIWNAME   */
-       (iw_handler) NULL,                                  /* SIOCSIWNWID   */
-       (iw_handler) NULL,                                  /* SIOCGIWNWID   */
-       (iw_handler) rt_ioctl_siwfreq,              /* SIOCSIWFREQ   */
-       (iw_handler) rt_ioctl_giwfreq,              /* SIOCGIWFREQ   */
-       (iw_handler) rt_ioctl_siwmode,              /* SIOCSIWMODE   */
-       (iw_handler) rt_ioctl_giwmode,              /* SIOCGIWMODE   */
-       (iw_handler) NULL,                              /* SIOCSIWSENS   */
-       (iw_handler) NULL,                              /* SIOCGIWSENS   */
-       (iw_handler) NULL /* not used */,               /* SIOCSIWRANGE  */
-       (iw_handler) rt_ioctl_giwrange,             /* SIOCGIWRANGE  */
-       (iw_handler) NULL /* not used */,               /* SIOCSIWPRIV   */
-       (iw_handler) NULL /* kernel code */,    /* SIOCGIWPRIV   */
-       (iw_handler) NULL /* not used */,               /* SIOCSIWSTATS  */
-       (iw_handler) rt28xx_get_wireless_stats /* kernel code */,    /* SIOCGIWSTATS  */
-       (iw_handler) NULL,                              /* SIOCSIWSPY    */
-       (iw_handler) NULL,                              /* SIOCGIWSPY    */
-       (iw_handler) NULL,                                      /* SIOCSIWTHRSPY */
-       (iw_handler) NULL,                                      /* SIOCGIWTHRSPY */
-       (iw_handler) rt_ioctl_siwap,            /* SIOCSIWAP     */
-       (iw_handler) rt_ioctl_giwap,                /* SIOCGIWAP     */
-#ifdef SIOCSIWMLME
-       (iw_handler) rt_ioctl_siwmlme,          /* SIOCSIWMLME   */
-#else
-       (iw_handler) NULL,                                      /* SIOCSIWMLME */
-#endif // SIOCSIWMLME //
-       (iw_handler) rt_ioctl_iwaplist,             /* SIOCGIWAPLIST */
-#ifdef SIOCGIWSCAN
-       (iw_handler) rt_ioctl_siwscan,              /* SIOCSIWSCAN   */
-       (iw_handler) rt_ioctl_giwscan,              /* SIOCGIWSCAN   */
-#else
-       (iw_handler) NULL,                                      /* SIOCSIWSCAN   */
-       (iw_handler) NULL,                                      /* SIOCGIWSCAN   */
-#endif /* SIOCGIWSCAN */
-       (iw_handler) rt_ioctl_siwessid,             /* SIOCSIWESSID  */
-       (iw_handler) rt_ioctl_giwessid,             /* SIOCGIWESSID  */
-       (iw_handler) rt_ioctl_siwnickn,             /* SIOCSIWNICKN  */
-       (iw_handler) rt_ioctl_giwnickn,             /* SIOCGIWNICKN  */
-       (iw_handler) NULL,                                      /* -- hole --    */
-       (iw_handler) NULL,                                      /* -- hole --    */
-       (iw_handler) rt_ioctl_siwrate,          /* SIOCSIWRATE   */
-       (iw_handler) rt_ioctl_giwrate,          /* SIOCGIWRATE   */
-       (iw_handler) rt_ioctl_siwrts,               /* SIOCSIWRTS    */
-       (iw_handler) rt_ioctl_giwrts,               /* SIOCGIWRTS    */
-       (iw_handler) rt_ioctl_siwfrag,              /* SIOCSIWFRAG   */
-       (iw_handler) rt_ioctl_giwfrag,              /* SIOCGIWFRAG   */
-       (iw_handler) NULL,                              /* SIOCSIWTXPOW  */
-       (iw_handler) NULL,                              /* SIOCGIWTXPOW  */
-       (iw_handler) NULL,                              /* SIOCSIWRETRY  */
-       (iw_handler) NULL,                              /* SIOCGIWRETRY  */
-       (iw_handler) rt_ioctl_siwencode,                /* SIOCSIWENCODE */
-       (iw_handler) rt_ioctl_giwencode,                /* SIOCGIWENCODE */
-       (iw_handler) NULL,                              /* SIOCSIWPOWER  */
-       (iw_handler) NULL,                              /* SIOCGIWPOWER  */
-       (iw_handler) NULL,                                              /* -- hole -- */
-       (iw_handler) NULL,                                              /* -- hole -- */
-#if WIRELESS_EXT > 17
-    (iw_handler) rt_ioctl_siwgenie,         /* SIOCSIWGENIE  */
-       (iw_handler) rt_ioctl_giwgenie,         /* SIOCGIWGENIE  */
-       (iw_handler) rt_ioctl_siwauth,              /* SIOCSIWAUTH   */
-       (iw_handler) rt_ioctl_giwauth,              /* SIOCGIWAUTH   */
-       (iw_handler) rt_ioctl_siwencodeext,         /* SIOCSIWENCODEEXT */
-       (iw_handler) rt_ioctl_giwencodeext,             /* SIOCGIWENCODEEXT */
-       (iw_handler) rt_ioctl_siwpmksa,         /* SIOCSIWPMKSA  */
-#endif
-};
-
-static const iw_handler rt_priv_handlers[] = {
-       (iw_handler) NULL, /* + 0x00 */
-       (iw_handler) NULL, /* + 0x01 */
-       (iw_handler) rt_ioctl_setparam, /* + 0x02 */
-#ifdef DBG
-       (iw_handler) rt_private_ioctl_bbp, /* + 0x03 */
-#else
-       (iw_handler) NULL, /* + 0x03 */
-#endif
-       (iw_handler) NULL, /* + 0x04 */
-       (iw_handler) NULL, /* + 0x05 */
-       (iw_handler) NULL, /* + 0x06 */
-       (iw_handler) NULL, /* + 0x07 */
-       (iw_handler) NULL, /* + 0x08 */
-       (iw_handler) rt_private_get_statistics, /* + 0x09 */
-       (iw_handler) NULL, /* + 0x0A */
-       (iw_handler) NULL, /* + 0x0B */
-       (iw_handler) NULL, /* + 0x0C */
-       (iw_handler) NULL, /* + 0x0D */
-       (iw_handler) NULL, /* + 0x0E */
-       (iw_handler) NULL, /* + 0x0F */
-       (iw_handler) NULL, /* + 0x10 */
-       (iw_handler) rt_private_show, /* + 0x11 */
-    (iw_handler) NULL, /* + 0x12 */
-       (iw_handler) NULL, /* + 0x13 */
-       (iw_handler) NULL, /* + 0x15 */
-       (iw_handler) NULL, /* + 0x17 */
-       (iw_handler) NULL, /* + 0x18 */
-};
-
-const struct iw_handler_def rt28xx_iw_handler_def =
-{
-#define        N(a)    (sizeof (a) / sizeof (a[0]))
-       .standard       = (iw_handler *) rt_handler,
-       .num_standard   = sizeof(rt_handler) / sizeof(iw_handler),
-       .private        = (iw_handler *) rt_priv_handlers,
-       .num_private            = N(rt_priv_handlers),
-       .private_args   = (struct iw_priv_args *) privtab,
-       .num_private_args       = N(privtab),
-#if IW_HANDLER_VERSION >= 7
-    .get_wireless_stats = rt28xx_get_wireless_stats,
-#endif
-};
-
-INT RTMPSetInformation(
-    IN  PRTMP_ADAPTER pAdapter,
-    IN  OUT struct ifreq    *rq,
-    IN  INT                 cmd)
-{
-    struct iwreq                        *wrq = (struct iwreq *) rq;
-    NDIS_802_11_SSID                    Ssid;
-    NDIS_802_11_MAC_ADDRESS             Bssid;
-    RT_802_11_PHY_MODE                  PhyMode;
-    RT_802_11_STA_CONFIG                StaConfig;
-    NDIS_802_11_RATES                   aryRates;
-    RT_802_11_PREAMBLE                  Preamble;
-    NDIS_802_11_WEP_STATUS              WepStatus;
-    NDIS_802_11_AUTHENTICATION_MODE     AuthMode = Ndis802_11AuthModeMax;
-    NDIS_802_11_NETWORK_INFRASTRUCTURE  BssType;
-    NDIS_802_11_RTS_THRESHOLD           RtsThresh;
-    NDIS_802_11_FRAGMENTATION_THRESHOLD FragThresh;
-    NDIS_802_11_POWER_MODE              PowerMode;
-    PNDIS_802_11_KEY                    pKey = NULL;
-    PNDIS_802_11_WEP                           pWepKey =NULL;
-    PNDIS_802_11_REMOVE_KEY             pRemoveKey = NULL;
-    NDIS_802_11_CONFIGURATION           Config, *pConfig = NULL;
-    NDIS_802_11_NETWORK_TYPE            NetType;
-    ULONG                               Now;
-    UINT                                KeyIdx = 0;
-    INT                                 Status = NDIS_STATUS_SUCCESS, MaxPhyMode = PHY_11G;
-    ULONG                               PowerTemp;
-    BOOLEAN                             RadioState;
-    BOOLEAN                             StateMachineTouched = FALSE;
-       OID_SET_HT_PHYMODE                                      HT_PhyMode;     //11n ,kathy
-    PNDIS_802_11_PMKID                  pPmkId = NULL;
-    BOOLEAN                                            IEEE8021xState = FALSE;
-    BOOLEAN                                            IEEE8021x_required_keys = FALSE;
-    UCHAR                               wpa_supplicant_enable = 0;
-
-       MaxPhyMode = PHY_11N_5G;
-
-       DBGPRINT(RT_DEBUG_TRACE, ("-->RTMPSetInformation(),     0x%08x\n", cmd&0x7FFF));
-    switch(cmd & 0x7FFF) {
-        case RT_OID_802_11_COUNTRY_REGION:
-            if (wrq->u.data.length < sizeof(UCHAR))
-                Status = -EINVAL;
-                       // Only avaliable when EEPROM not programming
-            else if (!(pAdapter->CommonCfg.CountryRegion & 0x80) && !(pAdapter->CommonCfg.CountryRegionForABand & 0x80))
-            {
-                ULONG   Country;
-                UCHAR  TmpPhy;
-
-                               Status = copy_from_user(&Country, wrq->u.data.pointer, wrq->u.data.length);
-                               pAdapter->CommonCfg.CountryRegion = (UCHAR)(Country & 0x000000FF);
-                               pAdapter->CommonCfg.CountryRegionForABand = (UCHAR)((Country >> 8) & 0x000000FF);
-                TmpPhy = pAdapter->CommonCfg.PhyMode;
-                               pAdapter->CommonCfg.PhyMode = 0xff;
-                               // Build all corresponding channel information
-                               RTMPSetPhyMode(pAdapter, TmpPhy);
-                               SetCommonHT(pAdapter);
-                               DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_COUNTRY_REGION (A:%d  B/G:%d)\n", pAdapter->CommonCfg.CountryRegionForABand,
-                                   pAdapter->CommonCfg.CountryRegion));
-            }
-            break;
-        case OID_802_11_BSSID_LIST_SCAN:
-            Now = jiffies;
-                       DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_BSSID_LIST_SCAN, TxCnt = %d \n", pAdapter->RalinkCounters.LastOneSecTotalTxCount));
-
-            if (MONITOR_ON(pAdapter))
-            {
-                DBGPRINT(RT_DEBUG_TRACE, ("!!! Driver is in Monitor Mode now !!!\n"));
-                break;
-            }
-
-                       //Benson add 20080527, when radio off, sta don't need to scan
-                       if (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_RADIO_OFF))
-                               break;
-
-                       if (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
-                       {
-                DBGPRINT(RT_DEBUG_TRACE, ("!!! Driver is scanning now !!!\n"));
-                               pAdapter->StaCfg.bScanReqIsFromWebUI = TRUE;
-                               Status = NDIS_STATUS_SUCCESS;
-                break;
-            }
-
-                       if (pAdapter->RalinkCounters.LastOneSecTotalTxCount > 100)
-            {
-                DBGPRINT(RT_DEBUG_TRACE, ("!!! Link UP, ignore this set::OID_802_11_BSSID_LIST_SCAN\n"));
-                               Status = NDIS_STATUS_SUCCESS;
-                               pAdapter->StaCfg.ScanCnt = 99;          // Prevent auto scan triggered by this OID
-                               break;
-            }
-
-            if ((OPSTATUS_TEST_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED)) &&
-                               ((pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA) ||
-                               (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK) ||
-                               (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA2) ||
-                               (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK)) &&
-                (pAdapter->StaCfg.PortSecured == WPA_802_1X_PORT_NOT_SECURED))
-            {
-                DBGPRINT(RT_DEBUG_TRACE, ("!!! Link UP, Port Not Secured! ignore this set::OID_802_11_BSSID_LIST_SCAN\n"));
-                               Status = NDIS_STATUS_SUCCESS;
-                               pAdapter->StaCfg.ScanCnt = 99;          // Prevent auto scan triggered by this OID
-                               break;
-            }
-
-
-            if (pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE)
-            {
-                RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
-                DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
-            }
-
-            // tell CNTL state machine to call NdisMSetInformationComplete() after completing
-            // this request, because this request is initiated by NDIS.
-            pAdapter->MlmeAux.CurrReqIsFromNdis = FALSE;
-            // Reset allowed scan retries
-            pAdapter->StaCfg.ScanCnt = 0;
-            pAdapter->StaCfg.LastScanTime = Now;
-
-                       pAdapter->StaCfg.bScanReqIsFromWebUI = TRUE;
-            RTMP_SET_FLAG(pAdapter, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS);
-            MlmeEnqueue(pAdapter,
-                        MLME_CNTL_STATE_MACHINE,
-                        OID_802_11_BSSID_LIST_SCAN,
-                        0,
-                        NULL);
-
-            Status = NDIS_STATUS_SUCCESS;
-            StateMachineTouched = TRUE;
-            break;
-        case OID_802_11_SSID:
-            if (wrq->u.data.length != sizeof(NDIS_802_11_SSID))
-                Status = -EINVAL;
-            else
-            {
-               PCHAR pSsidString = NULL;
-                Status = copy_from_user(&Ssid, wrq->u.data.pointer, wrq->u.data.length);
-
-                               DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_SSID (Len=%d,Ssid=%s)\n", Ssid.SsidLength, Ssid.Ssid));
-                if (Ssid.SsidLength > MAX_LEN_OF_SSID)
-                    Status = -EINVAL;
-                else
-                {
-                       if (Ssid.SsidLength == 0)
-                       {
-                               Set_SSID_Proc(pAdapter, "");
-                       }
-                                       else
-                       {
-                               pSsidString = (CHAR *) kmalloc(MAX_LEN_OF_SSID+1, MEM_ALLOC_FLAG);
-                                               if (pSsidString)
-                                               {
-                                                       NdisZeroMemory(pSsidString, MAX_LEN_OF_SSID+1);
-                                                       NdisMoveMemory(pSsidString, Ssid.Ssid, Ssid.SsidLength);
-                                       Set_SSID_Proc(pAdapter, pSsidString);
-                                                       kfree(pSsidString);
-                                               }
-                                               else
-                                                       Status = -ENOMEM;
-                       }
-                }
-            }
-            break;
-        case OID_802_11_BSSID:
-            if (wrq->u.data.length != sizeof(NDIS_802_11_MAC_ADDRESS))
-                Status  = -EINVAL;
-            else
-            {
-                Status = copy_from_user(&Bssid, wrq->u.data.pointer, wrq->u.data.length);
-
-                // tell CNTL state machine to call NdisMSetInformationComplete() after completing
-                // this request, because this request is initiated by NDIS.
-                pAdapter->MlmeAux.CurrReqIsFromNdis = FALSE;
-
-                               // Prevent to connect AP again in STAMlmePeriodicExec
-                               pAdapter->MlmeAux.AutoReconnectSsidLen= 32;
-
-                // Reset allowed scan retries
-                               pAdapter->StaCfg.ScanCnt = 0;
-
-                if (pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE)
-                {
-                    RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
-                    DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
-                }
-                MlmeEnqueue(pAdapter,
-                            MLME_CNTL_STATE_MACHINE,
-                            OID_802_11_BSSID,
-                            sizeof(NDIS_802_11_MAC_ADDRESS),
-                            (VOID *)&Bssid);
-                Status = NDIS_STATUS_SUCCESS;
-                StateMachineTouched = TRUE;
-
-                DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_BSSID %02x:%02x:%02x:%02x:%02x:%02x\n",
-                                        Bssid[0], Bssid[1], Bssid[2], Bssid[3], Bssid[4], Bssid[5]));
-            }
-            break;
-        case RT_OID_802_11_RADIO:
-            if (wrq->u.data.length != sizeof(BOOLEAN))
-                Status  = -EINVAL;
-            else
-            {
-                Status = copy_from_user(&RadioState, wrq->u.data.pointer, wrq->u.data.length);
-                DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_RADIO (=%d)\n", RadioState));
-                if (pAdapter->StaCfg.bSwRadio != RadioState)
-                {
-                    pAdapter->StaCfg.bSwRadio = RadioState;
-                    if (pAdapter->StaCfg.bRadio != (pAdapter->StaCfg.bHwRadio && pAdapter->StaCfg.bSwRadio))
-                    {
-                        pAdapter->StaCfg.bRadio = (pAdapter->StaCfg.bHwRadio && pAdapter->StaCfg.bSwRadio);
-                        if (pAdapter->StaCfg.bRadio == TRUE)
-                        {
-                            MlmeRadioOn(pAdapter);
-                            // Update extra information
-                                                       pAdapter->ExtraInfo = EXTRA_INFO_CLEAR;
-                        }
-                        else
-                        {
-                            MlmeRadioOff(pAdapter);
-                            // Update extra information
-                                                       pAdapter->ExtraInfo = SW_RADIO_OFF;
-                        }
-                    }
-                }
-            }
-            break;
-        case RT_OID_802_11_PHY_MODE:
-            if (wrq->u.data.length != sizeof(RT_802_11_PHY_MODE))
-                Status  = -EINVAL;
-            else
-            {
-                Status = copy_from_user(&PhyMode, wrq->u.data.pointer, wrq->u.data.length);
-                               if (PhyMode <= MaxPhyMode)
-                               {
-                       RTMPSetPhyMode(pAdapter, PhyMode);
-                                       SetCommonHT(pAdapter);
-                               }
-                DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_PHY_MODE (=%d)\n", PhyMode));
-            }
-            break;
-        case RT_OID_802_11_STA_CONFIG:
-            if (wrq->u.data.length != sizeof(RT_802_11_STA_CONFIG))
-                Status  = -EINVAL;
-            else
-            {
-                Status = copy_from_user(&StaConfig, wrq->u.data.pointer, wrq->u.data.length);
-                pAdapter->CommonCfg.bEnableTxBurst = StaConfig.EnableTxBurst;
-                pAdapter->CommonCfg.UseBGProtection = StaConfig.UseBGProtection;
-                pAdapter->CommonCfg.bUseShortSlotTime = 1; // 2003-10-30 always SHORT SLOT capable
-                if ((pAdapter->CommonCfg.PhyMode != StaConfig.AdhocMode) &&
-                                       (StaConfig.AdhocMode <= MaxPhyMode))
-                {
-                    // allow dynamic change of "USE OFDM rate or not" in ADHOC mode
-                    // if setting changed, need to reset current TX rate as well as BEACON frame format
-                    pAdapter->CommonCfg.PhyMode = StaConfig.AdhocMode;
-                    if (pAdapter->StaCfg.BssType == BSS_ADHOC)
-                    {
-                       RTMPSetPhyMode(pAdapter, PhyMode);
-                        MlmeUpdateTxRates(pAdapter, FALSE, 0);
-                        MakeIbssBeacon(pAdapter);           // re-build BEACON frame
-                        AsicEnableIbssSync(pAdapter);   // copy to on-chip memory
-                    }
-                }
-                DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_SET_STA_CONFIG (Burst=%d, Protection=%ld,ShortSlot=%d\n",
-                                        pAdapter->CommonCfg.bEnableTxBurst,
-                                        pAdapter->CommonCfg.UseBGProtection,
-                                        pAdapter->CommonCfg.bUseShortSlotTime));
-            }
-            break;
-        case OID_802_11_DESIRED_RATES:
-            if (wrq->u.data.length != sizeof(NDIS_802_11_RATES))
-                Status  = -EINVAL;
-            else
-            {
-                Status = copy_from_user(&aryRates, wrq->u.data.pointer, wrq->u.data.length);
-                NdisZeroMemory(pAdapter->CommonCfg.DesireRate, MAX_LEN_OF_SUPPORTED_RATES);
-                NdisMoveMemory(pAdapter->CommonCfg.DesireRate, &aryRates, sizeof(NDIS_802_11_RATES));
-                DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_DESIRED_RATES (%02x,%02x,%02x,%02x,%02x,%02x,%02x,%02x)\n",
-                    pAdapter->CommonCfg.DesireRate[0],pAdapter->CommonCfg.DesireRate[1],
-                    pAdapter->CommonCfg.DesireRate[2],pAdapter->CommonCfg.DesireRate[3],
-                    pAdapter->CommonCfg.DesireRate[4],pAdapter->CommonCfg.DesireRate[5],
-                    pAdapter->CommonCfg.DesireRate[6],pAdapter->CommonCfg.DesireRate[7] ));
-                // Changing DesiredRate may affect the MAX TX rate we used to TX frames out
-                MlmeUpdateTxRates(pAdapter, FALSE, 0);
-            }
-            break;
-        case RT_OID_802_11_PREAMBLE:
-            if (wrq->u.data.length != sizeof(RT_802_11_PREAMBLE))
-                Status  = -EINVAL;
-            else
-            {
-                Status = copy_from_user(&Preamble, wrq->u.data.pointer, wrq->u.data.length);
-                if (Preamble == Rt802_11PreambleShort)
-                {
-                    pAdapter->CommonCfg.TxPreamble = Preamble;
-                    MlmeSetTxPreamble(pAdapter, Rt802_11PreambleShort);
-                }
-                else if ((Preamble == Rt802_11PreambleLong) || (Preamble == Rt802_11PreambleAuto))
-                {
-                    // if user wants AUTO, initialize to LONG here, then change according to AP's
-                    // capability upon association.
-                    pAdapter->CommonCfg.TxPreamble = Preamble;
-                    MlmeSetTxPreamble(pAdapter, Rt802_11PreambleLong);
-                }
-                else
-                {
-                    Status = -EINVAL;
-                    break;
-                }
-                DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_PREAMBLE (=%d)\n", Preamble));
-            }
-            break;
-        case OID_802_11_WEP_STATUS:
-            if (wrq->u.data.length != sizeof(NDIS_802_11_WEP_STATUS))
-                Status  = -EINVAL;
-            else
-            {
-                Status = copy_from_user(&WepStatus, wrq->u.data.pointer, wrq->u.data.length);
-                // Since TKIP, AES, WEP are all supported. It should not have any invalid setting
-                if (WepStatus <= Ndis802_11Encryption3KeyAbsent)
-                {
-                    if (pAdapter->StaCfg.WepStatus != WepStatus)
-                    {
-                        // Config has changed
-                        pAdapter->bConfigChanged = TRUE;
-                    }
-                    pAdapter->StaCfg.WepStatus     = WepStatus;
-                    pAdapter->StaCfg.OrigWepStatus = WepStatus;
-                    pAdapter->StaCfg.PairCipher    = WepStatus;
-                       pAdapter->StaCfg.GroupCipher   = WepStatus;
-                }
-                else
-                {
-                    Status  = -EINVAL;
-                    break;
-                }
-                DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_WEP_STATUS (=%d)\n",WepStatus));
-            }
-            break;
-        case OID_802_11_AUTHENTICATION_MODE:
-            if (wrq->u.data.length != sizeof(NDIS_802_11_AUTHENTICATION_MODE))
-                Status  = -EINVAL;
-            else
-            {
-                Status = copy_from_user(&AuthMode, wrq->u.data.pointer, wrq->u.data.length);
-                if (AuthMode > Ndis802_11AuthModeMax)
-                {
-                    Status  = -EINVAL;
-                    break;
-                }
-                else
-                {
-                    if (pAdapter->StaCfg.AuthMode != AuthMode)
-                    {
-                        // Config has changed
-                        pAdapter->bConfigChanged = TRUE;
-                    }
-                    pAdapter->StaCfg.AuthMode = AuthMode;
-                }
-                pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED;
-                DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_AUTHENTICATION_MODE (=%d) \n",pAdapter->StaCfg.AuthMode));
-            }
-            break;
-        case OID_802_11_INFRASTRUCTURE_MODE:
-            if (wrq->u.data.length != sizeof(NDIS_802_11_NETWORK_INFRASTRUCTURE))
-                Status  = -EINVAL;
-            else
-            {
-                Status = copy_from_user(&BssType, wrq->u.data.pointer, wrq->u.data.length);
-
-                               if (BssType == Ndis802_11IBSS)
-                                       Set_NetworkType_Proc(pAdapter, "Adhoc");
-                               else if (BssType == Ndis802_11Infrastructure)
-                                       Set_NetworkType_Proc(pAdapter, "Infra");
-                               else if (BssType == Ndis802_11Monitor)
-                                       Set_NetworkType_Proc(pAdapter, "Monitor");
-                               else
-                               {
-                                       Status  = -EINVAL;
-                                       DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_INFRASTRUCTURE_MODE (unknown)\n"));
-                               }
-                       }
-                       break;
-        case OID_802_11_REMOVE_WEP:
-            DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_WEP\n"));
-            if (wrq->u.data.length != sizeof(NDIS_802_11_KEY_INDEX))
-            {
-                               Status = -EINVAL;
-            }
-            else
-            {
-                               KeyIdx = *(NDIS_802_11_KEY_INDEX *) wrq->u.data.pointer;
-
-                               if (KeyIdx & 0x80000000)
-                               {
-                                       // Should never set default bit when remove key
-                                       Status = -EINVAL;
-                               }
-                               else
-                               {
-                                       KeyIdx = KeyIdx & 0x0fffffff;
-                                       if (KeyIdx >= 4){
-                                               Status = -EINVAL;
-                                       }
-                                       else
-                                       {
-                                               pAdapter->SharedKey[BSS0][KeyIdx].KeyLen = 0;
-                                               pAdapter->SharedKey[BSS0][KeyIdx].CipherAlg = CIPHER_NONE;
-                                               AsicRemoveSharedKeyEntry(pAdapter, 0, (UCHAR)KeyIdx);
-                                       }
-                               }
-            }
-            break;
-        case RT_OID_802_11_RESET_COUNTERS:
-            NdisZeroMemory(&pAdapter->WlanCounters, sizeof(COUNTER_802_11));
-            NdisZeroMemory(&pAdapter->Counters8023, sizeof(COUNTER_802_3));
-            NdisZeroMemory(&pAdapter->RalinkCounters, sizeof(COUNTER_RALINK));
-            pAdapter->Counters8023.RxNoBuffer   = 0;
-                       pAdapter->Counters8023.GoodReceives = 0;
-                       pAdapter->Counters8023.RxNoBuffer   = 0;
-#ifdef RT2870
-                       pAdapter->BulkOutComplete       = 0;
-                       pAdapter->BulkOutCompleteOther= 0;
-                       pAdapter->BulkOutCompleteCancel = 0;
-                       pAdapter->BulkOutReq = 0;
-                       pAdapter->BulkInReq= 0;
-                       pAdapter->BulkInComplete = 0;
-                       pAdapter->BulkInCompleteFail = 0;
-#endif // RT2870 //
-            DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_RESET_COUNTERS \n"));
-            break;
-        case OID_802_11_RTS_THRESHOLD:
-            if (wrq->u.data.length != sizeof(NDIS_802_11_RTS_THRESHOLD))
-                Status  = -EINVAL;
-            else
-            {
-                Status = copy_from_user(&RtsThresh, wrq->u.data.pointer, wrq->u.data.length);
-                if (RtsThresh > MAX_RTS_THRESHOLD)
-                    Status  = -EINVAL;
-                else
-                    pAdapter->CommonCfg.RtsThreshold = (USHORT)RtsThresh;
-            }
-            DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_RTS_THRESHOLD (=%ld)\n",RtsThresh));
-            break;
-        case OID_802_11_FRAGMENTATION_THRESHOLD:
-            if (wrq->u.data.length != sizeof(NDIS_802_11_FRAGMENTATION_THRESHOLD))
-                Status  = -EINVAL;
-            else
-            {
-                Status = copy_from_user(&FragThresh, wrq->u.data.pointer, wrq->u.data.length);
-                pAdapter->CommonCfg.bUseZeroToDisableFragment = FALSE;
-                if (FragThresh > MAX_FRAG_THRESHOLD || FragThresh < MIN_FRAG_THRESHOLD)
-                {
-                    if (FragThresh == 0)
-                    {
-                        pAdapter->CommonCfg.FragmentThreshold = MAX_FRAG_THRESHOLD;
-                        pAdapter->CommonCfg.bUseZeroToDisableFragment = TRUE;
-                    }
-                    else
-                        Status  = -EINVAL;
-                }
-                else
-                    pAdapter->CommonCfg.FragmentThreshold = (USHORT)FragThresh;
-            }
-            DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_FRAGMENTATION_THRESHOLD (=%ld) \n",FragThresh));
-            break;
-        case OID_802_11_POWER_MODE:
-            if (wrq->u.data.length != sizeof(NDIS_802_11_POWER_MODE))
-                Status = -EINVAL;
-            else
-            {
-                Status = copy_from_user(&PowerMode, wrq->u.data.pointer, wrq->u.data.length);
-                if (PowerMode == Ndis802_11PowerModeCAM)
-                       Set_PSMode_Proc(pAdapter, "CAM");
-                else if (PowerMode == Ndis802_11PowerModeMAX_PSP)
-                       Set_PSMode_Proc(pAdapter, "Max_PSP");
-                else if (PowerMode == Ndis802_11PowerModeFast_PSP)
-                                       Set_PSMode_Proc(pAdapter, "Fast_PSP");
-                else if (PowerMode == Ndis802_11PowerModeLegacy_PSP)
-                                       Set_PSMode_Proc(pAdapter, "Legacy_PSP");
-                else
-                    Status = -EINVAL;
-            }
-            DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_POWER_MODE (=%d)\n",PowerMode));
-            break;
-         case RT_OID_802_11_TX_POWER_LEVEL_1:
-                       if (wrq->u.data.length  < sizeof(ULONG))
-                               Status = -EINVAL;
-                       else
-                       {
-                               Status = copy_from_user(&PowerTemp, wrq->u.data.pointer, wrq->u.data.length);
-                               if (PowerTemp > 100)
-                                       PowerTemp = 0xffffffff;  // AUTO
-                               pAdapter->CommonCfg.TxPowerDefault = PowerTemp; //keep current setting.
-                                       pAdapter->CommonCfg.TxPowerPercentage = pAdapter->CommonCfg.TxPowerDefault;
-                DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_TX_POWER_LEVEL_1 (=%ld)\n", pAdapter->CommonCfg.TxPowerPercentage));
-                       }
-               break;
-               case OID_802_11_NETWORK_TYPE_IN_USE:
-                       if (wrq->u.data.length != sizeof(NDIS_802_11_NETWORK_TYPE))
-                               Status = -EINVAL;
-                       else
-                       {
-                               Status = copy_from_user(&NetType, wrq->u.data.pointer, wrq->u.data.length);
-
-                               if (NetType == Ndis802_11DS)
-                                       RTMPSetPhyMode(pAdapter, PHY_11B);
-                               else if (NetType == Ndis802_11OFDM24)
-                                       RTMPSetPhyMode(pAdapter, PHY_11BG_MIXED);
-                               else if (NetType == Ndis802_11OFDM5)
-                                       RTMPSetPhyMode(pAdapter, PHY_11A);
-                               else
-                                       Status = -EINVAL;
-
-                               if (Status == NDIS_STATUS_SUCCESS)
-                                       SetCommonHT(pAdapter);
-
-                DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_NETWORK_TYPE_IN_USE (=%d)\n",NetType));
-                   }
-                       break;
-        // For WPA PSK PMK key
-        case RT_OID_802_11_ADD_WPA:
-            pKey = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
-            if(pKey == NULL)
-            {
-                Status = -ENOMEM;
-                break;
-            }
-
-            Status = copy_from_user(pKey, wrq->u.data.pointer, wrq->u.data.length);
-            if (pKey->Length != wrq->u.data.length)
-            {
-                Status  = -EINVAL;
-                DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_ADD_WPA, Failed!!\n"));
-            }
-            else
-            {
-                if ((pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPAPSK) &&
-                                   (pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPA2PSK) &&
-                                   (pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPANone) )
-                {
-                    Status = -EOPNOTSUPP;
-                    DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_ADD_WPA, Failed!! [AuthMode != WPAPSK/WPA2PSK/WPANONE]\n"));
-                }
-                else if ((pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK) ||
-                                                (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK) ||
-                                                (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPANone) )     // Only for WPA PSK mode
-                               {
-                    NdisMoveMemory(pAdapter->StaCfg.PMK, &pKey->KeyMaterial, pKey->KeyLength);
-                    // Use RaConfig as PSK agent.
-                    // Start STA supplicant state machine
-                    if (pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPANone)
-                        pAdapter->StaCfg.WpaState = SS_START;
-
-                    DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_ADD_WPA (id=0x%x, Len=%d-byte)\n", pKey->KeyIndex, pKey->KeyLength));
-                }
-                else
-                {
-                    pAdapter->StaCfg.WpaState = SS_NOTUSE;
-                    DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_ADD_WPA (id=0x%x, Len=%d-byte)\n", pKey->KeyIndex, pKey->KeyLength));
-                }
-            }
-            kfree(pKey);
-            break;
-        case OID_802_11_REMOVE_KEY:
-            pRemoveKey = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
-            if(pRemoveKey == NULL)
-            {
-                Status = -ENOMEM;
-                break;
-            }
-
-            Status = copy_from_user(pRemoveKey, wrq->u.data.pointer, wrq->u.data.length);
-            if (pRemoveKey->Length != wrq->u.data.length)
-            {
-                Status  = -EINVAL;
-                DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_KEY, Failed!!\n"));
-            }
-            else
-            {
-                if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
-                {
-                    RTMPWPARemoveKeyProc(pAdapter, pRemoveKey);
-                    DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_KEY, Remove WPA Key!!\n"));
-                }
-                else
-                {
-                    KeyIdx = pRemoveKey->KeyIndex;
-
-                    if (KeyIdx & 0x80000000)
-                    {
-                        // Should never set default bit when remove key
-                        Status  = -EINVAL;
-                        DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_KEY, Failed!!(Should never set default bit when remove key)\n"));
-                    }
-                    else
-                    {
-                        KeyIdx = KeyIdx & 0x0fffffff;
-                        if (KeyIdx > 3)
-                        {
-                            Status  = -EINVAL;
-                            DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_KEY, Failed!!(KeyId[%d] out of range)\n", KeyIdx));
-                        }
-                        else
-                        {
-                            pAdapter->SharedKey[BSS0][KeyIdx].KeyLen = 0;
-                            pAdapter->SharedKey[BSS0][KeyIdx].CipherAlg = CIPHER_NONE;
-                            AsicRemoveSharedKeyEntry(pAdapter, 0, (UCHAR)KeyIdx);
-                            DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_KEY (id=0x%x, Len=%d-byte)\n", pRemoveKey->KeyIndex, pRemoveKey->Length));
-                        }
-                    }
-                }
-            }
-            kfree(pRemoveKey);
-            break;
-        // New for WPA
-        case OID_802_11_ADD_KEY:
-            pKey = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
-            if(pKey == NULL)
-            {
-                Status = -ENOMEM;
-                break;
-            }
-            Status = copy_from_user(pKey, wrq->u.data.pointer, wrq->u.data.length);
-            if (pKey->Length != wrq->u.data.length)
-            {
-                Status  = -EINVAL;
-                DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_KEY, Failed!!\n"));
-            }
-            else
-            {
-                RTMPAddKey(pAdapter, pKey);
-                DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_KEY (id=0x%x, Len=%d-byte)\n", pKey->KeyIndex, pKey->KeyLength));
-            }
-            kfree(pKey);
-            break;
-        case OID_802_11_CONFIGURATION:
-            if (wrq->u.data.length != sizeof(NDIS_802_11_CONFIGURATION))
-                Status  = -EINVAL;
-            else
-            {
-                Status = copy_from_user(&Config, wrq->u.data.pointer, wrq->u.data.length);
-                pConfig = &Config;
-
-                if ((pConfig->BeaconPeriod >= 20) && (pConfig->BeaconPeriod <=400))
-                     pAdapter->CommonCfg.BeaconPeriod = (USHORT) pConfig->BeaconPeriod;
-
-                pAdapter->StaActive.AtimWin = (USHORT) pConfig->ATIMWindow;
-                MAP_KHZ_TO_CHANNEL_ID(pConfig->DSConfig, pAdapter->CommonCfg.Channel);
-                //
-                               // Save the channel on MlmeAux for CntlOidRTBssidProc used.
-                               //
-                               pAdapter->MlmeAux.Channel = pAdapter->CommonCfg.Channel;
-
-                DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_CONFIGURATION (BeacnPeriod=%ld,AtimW=%ld,Ch=%d)\n",
-                    pConfig->BeaconPeriod, pConfig->ATIMWindow, pAdapter->CommonCfg.Channel));
-                // Config has changed
-                pAdapter->bConfigChanged = TRUE;
-            }
-            break;
-               case RT_OID_802_11_SET_HT_PHYMODE:
-                       if (wrq->u.data.length  != sizeof(OID_SET_HT_PHYMODE))
-                               Status = -EINVAL;
-                       else
-                       {
-                           POID_SET_HT_PHYMODE pHTPhyMode = &HT_PhyMode;
-
-                               Status = copy_from_user(&HT_PhyMode, wrq->u.data.pointer, wrq->u.data.length);
-                               DBGPRINT(RT_DEBUG_TRACE, ("Set::pHTPhyMode      (PhyMode = %d,TransmitNo = %d, HtMode = %d,     ExtOffset =     %d , MCS = %d, BW =     %d,     STBC = %d, SHORTGI = %d) \n",
-                               pHTPhyMode->PhyMode, pHTPhyMode->TransmitNo,pHTPhyMode->HtMode,pHTPhyMode->ExtOffset,
-                               pHTPhyMode->MCS, pHTPhyMode->BW, pHTPhyMode->STBC,      pHTPhyMode->SHORTGI));
-                               if (pAdapter->CommonCfg.PhyMode >= PHY_11ABGN_MIXED)
-                                       RTMPSetHT(pAdapter,     pHTPhyMode);
-                       }
-                       DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_SET_HT_PHYMODE(MCS=%d,BW=%d,SGI=%d,STBC=%d)\n",
-                               pAdapter->StaCfg.HTPhyMode.field.MCS, pAdapter->StaCfg.HTPhyMode.field.BW, pAdapter->StaCfg.HTPhyMode.field.ShortGI,
-                               pAdapter->StaCfg.HTPhyMode.field.STBC));
-                       break;
-               case RT_OID_802_11_SET_APSD_SETTING:
-                       if (wrq->u.data.length != sizeof(ULONG))
-                               Status = -EINVAL;
-                       else
-                       {
-                               ULONG apsd ;
-                               Status = copy_from_user(&apsd, wrq->u.data.pointer,     wrq->u.data.length);
-
-                               /*-------------------------------------------------------------------
-                               |B31~B7 |       B6~B5    |       B4      |       B3      |      B2       |      B1       |         B0           |
-                               ---------------------------------------------------------------------
-                               | Rsvd  | Max SP Len | AC_VO | AC_VI | AC_BK | AC_BE | APSD     Capable |
-                               ---------------------------------------------------------------------*/
-                               pAdapter->CommonCfg.bAPSDCapable = (apsd & 0x00000001) ? TRUE : FALSE;
-                               pAdapter->CommonCfg.bAPSDAC_BE = ((apsd & 0x00000002) >> 1)     ? TRUE : FALSE;
-                               pAdapter->CommonCfg.bAPSDAC_BK = ((apsd & 0x00000004) >> 2)     ? TRUE : FALSE;
-                               pAdapter->CommonCfg.bAPSDAC_VI = ((apsd & 0x00000008) >> 3)     ? TRUE : FALSE;
-                               pAdapter->CommonCfg.bAPSDAC_VO = ((apsd & 0x00000010) >> 4)     ? TRUE : FALSE;
-                               pAdapter->CommonCfg.MaxSPLength = (UCHAR)((apsd & 0x00000060) >> 5);
-
-                               DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_SET_APSD_SETTING (apsd=0x%lx, APSDCap=%d, [BE,BK,VI,VO]=[%d/%d/%d/%d],    MaxSPLen=%d)\n", apsd, pAdapter->CommonCfg.bAPSDCapable,
-                                       pAdapter->CommonCfg.bAPSDAC_BE, pAdapter->CommonCfg.bAPSDAC_BK, pAdapter->CommonCfg.bAPSDAC_VI, pAdapter->CommonCfg.bAPSDAC_VO, pAdapter->CommonCfg.MaxSPLength));
-                       }
-                       break;
-
-               case RT_OID_802_11_SET_APSD_PSM:
-                       if (wrq->u.data.length  != sizeof(ULONG))
-                               Status = -EINVAL;
-                       else
-                       {
-                               // Driver needs to notify AP when PSM changes
-                               Status = copy_from_user(&pAdapter->CommonCfg.bAPSDForcePowerSave, wrq->u.data.pointer, wrq->u.data.length);
-                               if (pAdapter->CommonCfg.bAPSDForcePowerSave     != pAdapter->StaCfg.Psm)
-                               {
-                                       MlmeSetPsmBit(pAdapter, pAdapter->CommonCfg.bAPSDForcePowerSave);
-                                       RTMPSendNullFrame(pAdapter,     pAdapter->CommonCfg.TxRate,     TRUE);
-                               }
-                               DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_SET_APSD_PSM (bAPSDForcePowerSave:%d)\n", pAdapter->CommonCfg.bAPSDForcePowerSave));
-                       }
-                       break;
-
-               case RT_OID_802_11_SET_WMM:
-                       if (wrq->u.data.length  != sizeof(BOOLEAN))
-                               Status = -EINVAL;
-                       else
-                       {
-                               Status = copy_from_user(&pAdapter->CommonCfg.bWmmCapable, wrq->u.data.pointer, wrq->u.data.length);
-                               DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_SET_WMM (=%d)     \n", pAdapter->CommonCfg.bWmmCapable));
-                       }
-                       break;
-
-               case OID_802_11_DISASSOCIATE:
-                       //
-                       // Set NdisRadioStateOff to     TRUE, instead of called MlmeRadioOff.
-                       // Later on, NDIS_802_11_BSSID_LIST_EX->NumberOfItems should be 0
-                       // when query OID_802_11_BSSID_LIST.
-                       //
-                       // TRUE:  NumberOfItems will set to     0.
-                       // FALSE: NumberOfItems no change.
-                       //
-                       pAdapter->CommonCfg.NdisRadioStateOff = TRUE;
-                       // Set to immediately send the media disconnect event
-                       pAdapter->MlmeAux.CurrReqIsFromNdis     = TRUE;
-                       DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_DISASSOCIATE \n"));
-
-                       if (INFRA_ON(pAdapter))
-                       {
-                               if (pAdapter->Mlme.CntlMachine.CurrState !=     CNTL_IDLE)
-                               {
-                                       RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
-                                       DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME     busy, reset     MLME state machine !!!\n"));
-                               }
-
-                               MlmeEnqueue(pAdapter,
-                                       MLME_CNTL_STATE_MACHINE,
-                                       OID_802_11_DISASSOCIATE,
-                                       0,
-                                       NULL);
-
-                               StateMachineTouched     = TRUE;
-                       }
-                       break;
-               case RT_OID_802_11_SET_IMME_BA_CAP:
-                               if (wrq->u.data.length != sizeof(OID_BACAP_STRUC))
-                                       Status = -EINVAL;
-                               else
-                               {
-                                       OID_BACAP_STRUC Orde ;
-                                       Status = copy_from_user(&Orde, wrq->u.data.pointer, wrq->u.data.length);
-                                       if (Orde.Policy > BA_NOTUSE)
-                                       {
-                                               Status = NDIS_STATUS_INVALID_DATA;
-                                       }
-                                       else if (Orde.Policy == BA_NOTUSE)
-                                       {
-                                               pAdapter->CommonCfg.BACapability.field.Policy = BA_NOTUSE;
-                                               pAdapter->CommonCfg.BACapability.field.MpduDensity = Orde.MpduDensity;
-                                               pAdapter->CommonCfg.DesiredHtPhy.MpduDensity = Orde.MpduDensity;
-                                               pAdapter->CommonCfg.DesiredHtPhy.AmsduEnable = Orde.AmsduEnable;
-                                               pAdapter->CommonCfg.DesiredHtPhy.AmsduSize= Orde.AmsduSize;
-                                               pAdapter->CommonCfg.DesiredHtPhy.MimoPs= Orde.MMPSmode;
-                                               pAdapter->CommonCfg.BACapability.field.MMPSmode = Orde.MMPSmode;
-                                               // UPdata to HT IE
-                                               pAdapter->CommonCfg.HtCapability.HtCapInfo.MimoPs = Orde.MMPSmode;
-                                               pAdapter->CommonCfg.HtCapability.HtCapInfo.AMsduSize = Orde.AmsduSize;
-                                               pAdapter->CommonCfg.HtCapability.HtCapParm.MpduDensity = Orde.MpduDensity;
-                                       }
-                                       else
-                                       {
-                        pAdapter->CommonCfg.BACapability.field.AutoBA = Orde.AutoBA;
-                                               pAdapter->CommonCfg.BACapability.field.Policy = IMMED_BA; // we only support immediate BA.
-                                               pAdapter->CommonCfg.BACapability.field.MpduDensity = Orde.MpduDensity;
-                                               pAdapter->CommonCfg.DesiredHtPhy.MpduDensity = Orde.MpduDensity;
-                                               pAdapter->CommonCfg.DesiredHtPhy.AmsduEnable = Orde.AmsduEnable;
-                                               pAdapter->CommonCfg.DesiredHtPhy.AmsduSize= Orde.AmsduSize;
-                                               pAdapter->CommonCfg.DesiredHtPhy.MimoPs = Orde.MMPSmode;
-                                               pAdapter->CommonCfg.BACapability.field.MMPSmode = Orde.MMPSmode;
-
-                                               // UPdata to HT IE
-                                               pAdapter->CommonCfg.HtCapability.HtCapInfo.MimoPs = Orde.MMPSmode;
-                                               pAdapter->CommonCfg.HtCapability.HtCapInfo.AMsduSize = Orde.AmsduSize;
-                                               pAdapter->CommonCfg.HtCapability.HtCapParm.MpduDensity = Orde.MpduDensity;
-
-                                               if (pAdapter->CommonCfg.BACapability.field.RxBAWinLimit > MAX_RX_REORDERBUF)
-                                                       pAdapter->CommonCfg.BACapability.field.RxBAWinLimit = MAX_RX_REORDERBUF;
-
-                                       }
-
-                                       pAdapter->CommonCfg.REGBACapability.word = pAdapter->CommonCfg.BACapability.word;
-                                       DBGPRINT(RT_DEBUG_TRACE, ("Set::(Orde.AutoBA = %d) (Policy=%d)(ReBAWinLimit=%d)(TxBAWinLimit=%d)(AutoMode=%d)\n",Orde.AutoBA, pAdapter->CommonCfg.BACapability.field.Policy,
-                                               pAdapter->CommonCfg.BACapability.field.RxBAWinLimit,pAdapter->CommonCfg.BACapability.field.TxBAWinLimit, pAdapter->CommonCfg.BACapability.field.AutoBA));
-                                       DBGPRINT(RT_DEBUG_TRACE, ("Set::(MimoPs = %d)(AmsduEnable = %d) (AmsduSize=%d)(MpduDensity=%d)\n",pAdapter->CommonCfg.DesiredHtPhy.MimoPs, pAdapter->CommonCfg.DesiredHtPhy.AmsduEnable,
-                                               pAdapter->CommonCfg.DesiredHtPhy.AmsduSize, pAdapter->CommonCfg.DesiredHtPhy.MpduDensity));
-                               }
-
-                               break;
-               case RT_OID_802_11_ADD_IMME_BA:
-                       DBGPRINT(RT_DEBUG_TRACE, (" Set :: RT_OID_802_11_ADD_IMME_BA \n"));
-                       if (wrq->u.data.length != sizeof(OID_ADD_BA_ENTRY))
-                                       Status = -EINVAL;
-                       else
-                       {
-                               UCHAR                   index;
-                               OID_ADD_BA_ENTRY    BA;
-                               MAC_TABLE_ENTRY     *pEntry;
-
-                               Status = copy_from_user(&BA, wrq->u.data.pointer, wrq->u.data.length);
-                               if (BA.TID > 15)
-                               {
-                                       Status = NDIS_STATUS_INVALID_DATA;
-                                       break;
-                               }
-                               else
-                               {
-                                       //BATableInsertEntry
-                                       //As ad-hoc mode, BA pair is not limited to only BSSID. so add via OID.
-                                       index = BA.TID;
-                                       // in ad hoc mode, when adding BA pair, we should insert this entry into MACEntry too
-                                       pEntry = MacTableLookup(pAdapter, BA.MACAddr);
-                                       if (!pEntry)
-                                       {
-                                               DBGPRINT(RT_DEBUG_TRACE, ("RT_OID_802_11_ADD_IMME_BA. break on no connection.----:%x:%x\n", BA.MACAddr[4], BA.MACAddr[5]));
-                                               break;
-                                       }
-                                       if (BA.IsRecipient == FALSE)
-                                       {
-                                           if (pEntry->bIAmBadAtheros == TRUE)
-                                                       pAdapter->CommonCfg.BACapability.field.RxBAWinLimit = 0x10;
-
-                                               BAOriSessionSetUp(pAdapter, pEntry, index, 0, 100, TRUE);
-                                       }
-                                       else
-                                       {
-                                               //BATableInsertEntry(pAdapter, pEntry->Aid, BA.MACAddr, 0, 0xffff, BA.TID, BA.nMSDU, BA.IsRecipient);
-                                       }
-
-                                       DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_ADD_IMME_BA. Rec = %d. Mac = %x:%x:%x:%x:%x:%x . \n",
-                                               BA.IsRecipient, BA.MACAddr[0], BA.MACAddr[1], BA.MACAddr[2], BA.MACAddr[2]
-                                               , BA.MACAddr[4], BA.MACAddr[5]));
-                               }
-                       }
-                       break;
-
-               case RT_OID_802_11_TEAR_IMME_BA:
-                       DBGPRINT(RT_DEBUG_TRACE, ("Set :: RT_OID_802_11_TEAR_IMME_BA \n"));
-                       if (wrq->u.data.length != sizeof(OID_ADD_BA_ENTRY))
-                                       Status = -EINVAL;
-                       else
-                       {
-                               POID_ADD_BA_ENTRY       pBA;
-                               MAC_TABLE_ENTRY *pEntry;
-
-                               pBA = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
-
-                               if (pBA == NULL)
-                               {
-                                       DBGPRINT(RT_DEBUG_TRACE, ("Set :: RT_OID_802_11_TEAR_IMME_BA kmalloc() can't allocate enough memory\n"));
-                                       Status = NDIS_STATUS_FAILURE;
-                               }
-                               else
-                               {
-                                       Status = copy_from_user(pBA, wrq->u.data.pointer, wrq->u.data.length);
-                                       DBGPRINT(RT_DEBUG_TRACE, ("Set :: RT_OID_802_11_TEAR_IMME_BA(TID=%d, bAllTid=%d)\n", pBA->TID, pBA->bAllTid));
-
-                                       if (!pBA->bAllTid && (pBA->TID > NUM_OF_TID))
-                                       {
-                                               Status = NDIS_STATUS_INVALID_DATA;
-                                               break;
-                                       }
-
-                                       if (pBA->IsRecipient == FALSE)
-                                       {
-                                               pEntry = MacTableLookup(pAdapter, pBA->MACAddr);
-                                               DBGPRINT(RT_DEBUG_TRACE, (" pBA->IsRecipient == FALSE\n"));
-                                               if (pEntry)
-                                               {
-                                                       DBGPRINT(RT_DEBUG_TRACE, (" pBA->pEntry\n"));
-                                                       BAOriSessionTearDown(pAdapter, pEntry->Aid, pBA->TID, FALSE, TRUE);
-                                               }
-                                               else
-                                                       DBGPRINT(RT_DEBUG_TRACE, ("Set :: Not found pEntry \n"));
-                                       }
-                                       else
-                                       {
-                                               pEntry = MacTableLookup(pAdapter, pBA->MACAddr);
-                                               if (pEntry)
-                                               {
-                                                       BARecSessionTearDown( pAdapter, (UCHAR)pEntry->Aid, pBA->TID, TRUE);
-                                               }
-                                               else
-                                                       DBGPRINT(RT_DEBUG_TRACE, ("Set :: Not found pEntry \n"));
-                                       }
-                                       kfree(pBA);
-                               }
-            }
-            break;
-        // For WPA_SUPPLICANT to set static wep key
-       case OID_802_11_ADD_WEP:
-           pWepKey = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
-
-           if(pWepKey == NULL)
-            {
-                Status = -ENOMEM;
-                               DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_WEP, Failed!!\n"));
-                break;
-            }
-            Status = copy_from_user(pWepKey, wrq->u.data.pointer, wrq->u.data.length);
-            if (Status)
-            {
-                Status  = -EINVAL;
-                DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_WEP, Failed (length mismatch)!!\n"));
-            }
-            else
-            {
-                       KeyIdx = pWepKey->KeyIndex & 0x0fffffff;
-                // KeyIdx must be 0 ~ 3
-                if (KeyIdx > 4)
-                       {
-                    Status  = -EINVAL;
-                    DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_WEP, Failed (KeyIdx must be smaller than 4)!!\n"));
-                }
-                else
-                {
-                    UCHAR CipherAlg = 0;
-                    PUCHAR Key;
-
-                    // set key material and key length
-                    NdisZeroMemory(pAdapter->SharedKey[BSS0][KeyIdx].Key, 16);
-                    pAdapter->SharedKey[BSS0][KeyIdx].KeyLen = (UCHAR) pWepKey->KeyLength;
-                    NdisMoveMemory(pAdapter->SharedKey[BSS0][KeyIdx].Key, &pWepKey->KeyMaterial, pWepKey->KeyLength);
-
-                    switch(pWepKey->KeyLength)
-                    {
-                        case 5:
-                            CipherAlg = CIPHER_WEP64;
-                            break;
-                        case 13:
-                            CipherAlg = CIPHER_WEP128;
-                            break;
-                        default:
-                            DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_WEP, only support CIPHER_WEP64(len:5) & CIPHER_WEP128(len:13)!!\n"));
-                            Status = -EINVAL;
-                            break;
-                    }
-                    pAdapter->SharedKey[BSS0][KeyIdx].CipherAlg = CipherAlg;
-
-                    // Default key for tx (shared key)
-                    if (pWepKey->KeyIndex & 0x80000000)
-                    {
-                        // set key material and key length
-                        NdisZeroMemory(pAdapter->StaCfg.DesireSharedKey[KeyIdx].Key, 16);
-                        pAdapter->StaCfg.DesireSharedKey[KeyIdx].KeyLen = (UCHAR) pWepKey->KeyLength;
-                        NdisMoveMemory(pAdapter->StaCfg.DesireSharedKey[KeyIdx].Key, &pWepKey->KeyMaterial, pWepKey->KeyLength);
-                        pAdapter->StaCfg.DesireSharedKeyId = KeyIdx;
-                        pAdapter->StaCfg.DesireSharedKey[KeyIdx].CipherAlg = CipherAlg;
-                        pAdapter->StaCfg.DefaultKeyId = (UCHAR) KeyIdx;
-                    }
-
-                    if (pAdapter->StaCfg.PortSecured == WPA_802_1X_PORT_SECURED)
-                    {
-                        Key = pAdapter->SharedKey[BSS0][KeyIdx].Key;
-
-                        // Set key material and cipherAlg to Asic
-                                       AsicAddSharedKeyEntry(pAdapter, BSS0, KeyIdx, CipherAlg, Key, NULL, NULL);
-
-                        if (pWepKey->KeyIndex & 0x80000000)
-                        {
-                            PMAC_TABLE_ENTRY pEntry = &pAdapter->MacTab.Content[BSSID_WCID];
-                            // Assign group key info
-                                               RTMPAddWcidAttributeEntry(pAdapter, BSS0, KeyIdx, CipherAlg, NULL);
-                                               // Assign pairwise key info
-                                               RTMPAddWcidAttributeEntry(pAdapter, BSS0, KeyIdx, CipherAlg, pEntry);
-                        }
-                    }
-                                       DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_WEP (id=0x%x, Len=%d-byte), %s\n", pWepKey->KeyIndex, pWepKey->KeyLength, (pAdapter->StaCfg.PortSecured == WPA_802_1X_PORT_SECURED) ? "Port Secured":"Port NOT Secured"));
-                               }
-            }
-            kfree(pWepKey);
-            break;
-           case OID_SET_COUNTERMEASURES:
-            if (wrq->u.data.length != sizeof(int))
-                Status  = -EINVAL;
-            else
-            {
-                int enabled = 0;
-                Status = copy_from_user(&enabled, wrq->u.data.pointer, wrq->u.data.length);
-                if (enabled == 1)
-                    pAdapter->StaCfg.bBlockAssoc = TRUE;
-                else
-                    // WPA MIC error should block association attempt for 60 seconds
-                    pAdapter->StaCfg.bBlockAssoc = FALSE;
-                DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_SET_COUNTERMEASURES bBlockAssoc=%s\n", pAdapter->StaCfg.bBlockAssoc ? "TRUE":"FALSE"));
-            }
-               break;
-        case RT_OID_WPA_SUPPLICANT_SUPPORT:
-                       if (wrq->u.data.length != sizeof(UCHAR))
-                Status  = -EINVAL;
-            else
-            {
-                Status = copy_from_user(&wpa_supplicant_enable, wrq->u.data.pointer, wrq->u.data.length);
-                       pAdapter->StaCfg.WpaSupplicantUP = wpa_supplicant_enable;
-                       DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_WPA_SUPPLICANT_SUPPORT (=%d)\n", pAdapter->StaCfg.WpaSupplicantUP));
-                       }
-            break;
-        case OID_802_11_DEAUTHENTICATION:
-            if (wrq->u.data.length != sizeof(MLME_DEAUTH_REQ_STRUCT))
-                Status  = -EINVAL;
-            else
-            {
-                MLME_DEAUTH_REQ_STRUCT      *pInfo;
-                               MLME_QUEUE_ELEM *MsgElem = (MLME_QUEUE_ELEM *) kmalloc(sizeof(MLME_QUEUE_ELEM), MEM_ALLOC_FLAG);
-
-                pInfo = (MLME_DEAUTH_REQ_STRUCT *) MsgElem->Msg;
-                Status = copy_from_user(pInfo, wrq->u.data.pointer, wrq->u.data.length);
-                MlmeDeauthReqAction(pAdapter, MsgElem);
-                               kfree(MsgElem);
-
-                if (INFRA_ON(pAdapter))
-                {
-                    LinkDown(pAdapter, FALSE);
-                    pAdapter->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
-                }
-                DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_DEAUTHENTICATION (Reason=%d)\n", pInfo->Reason));
-            }
-            break;
-        case OID_802_11_DROP_UNENCRYPTED:
-            if (wrq->u.data.length != sizeof(int))
-                Status  = -EINVAL;
-            else
-            {
-                int enabled = 0;
-                Status = copy_from_user(&enabled, wrq->u.data.pointer, wrq->u.data.length);
-                if (enabled == 1)
-                    pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED;
-                else
-                    pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
-                               NdisAcquireSpinLock(&pAdapter->MacTabLock);
-                               pAdapter->MacTab.Content[BSSID_WCID].PortSecured = pAdapter->StaCfg.PortSecured;
-                               NdisReleaseSpinLock(&pAdapter->MacTabLock);
-                DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_DROP_UNENCRYPTED (=%d)\n", enabled));
-            }
-            break;
-        case OID_802_11_SET_IEEE8021X:
-            if (wrq->u.data.length != sizeof(BOOLEAN))
-                Status  = -EINVAL;
-            else
-            {
-                Status = copy_from_user(&IEEE8021xState, wrq->u.data.pointer, wrq->u.data.length);
-                       pAdapter->StaCfg.IEEE8021X = IEEE8021xState;
-                DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_SET_IEEE8021X (=%d)\n", IEEE8021xState));
-            }
-            break;
-        case OID_802_11_SET_IEEE8021X_REQUIRE_KEY:
-                       if (wrq->u.data.length != sizeof(BOOLEAN))
-                                Status  = -EINVAL;
-            else
-            {
-                Status = copy_from_user(&IEEE8021x_required_keys, wrq->u.data.pointer, wrq->u.data.length);
-                               pAdapter->StaCfg.IEEE8021x_required_keys = IEEE8021x_required_keys;
-                               DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_SET_IEEE8021X_REQUIRE_KEY (%d)\n", IEEE8021x_required_keys));
-                       }
-                       break;
-        case OID_802_11_PMKID:
-               pPmkId = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
-
-               if(pPmkId == NULL) {
-                Status = -ENOMEM;
-                break;
-            }
-            Status = copy_from_user(pPmkId, wrq->u.data.pointer, wrq->u.data.length);
-
-               // check the PMKID information
-               if (pPmkId->BSSIDInfoCount == 0)
-                NdisZeroMemory(pAdapter->StaCfg.SavedPMK, sizeof(BSSID_INFO)*PMKID_NO);
-               else
-               {
-                       PBSSID_INFO     pBssIdInfo;
-                       UINT            BssIdx;
-                       UINT            CachedIdx;
-
-                       for (BssIdx = 0; BssIdx < pPmkId->BSSIDInfoCount; BssIdx++)
-                       {
-                               // point to the indexed BSSID_INFO structure
-                               pBssIdInfo = (PBSSID_INFO) ((PUCHAR) pPmkId + 2 * sizeof(UINT) + BssIdx * sizeof(BSSID_INFO));
-                               // Find the entry in the saved data base.
-                               for (CachedIdx = 0; CachedIdx < pAdapter->StaCfg.SavedPMKNum; CachedIdx++)
-                               {
-                                       // compare the BSSID
-                                       if (NdisEqualMemory(pBssIdInfo->BSSID, pAdapter->StaCfg.SavedPMK[CachedIdx].BSSID, sizeof(NDIS_802_11_MAC_ADDRESS)))
-                                               break;
-                               }
-
-                               // Found, replace it
-                               if (CachedIdx < PMKID_NO)
-                               {
-                                       DBGPRINT(RT_DEBUG_OFF, ("Update OID_802_11_PMKID, idx = %d\n", CachedIdx));
-                                       NdisMoveMemory(&pAdapter->StaCfg.SavedPMK[CachedIdx], pBssIdInfo, sizeof(BSSID_INFO));
-                                       pAdapter->StaCfg.SavedPMKNum++;
-                               }
-                               // Not found, replace the last one
-                               else
-                               {
-                                       // Randomly replace one
-                                       CachedIdx = (pBssIdInfo->BSSID[5] % PMKID_NO);
-                                       DBGPRINT(RT_DEBUG_OFF, ("Update OID_802_11_PMKID, idx = %d\n", CachedIdx));
-                                       NdisMoveMemory(&pAdapter->StaCfg.SavedPMK[CachedIdx], pBssIdInfo, sizeof(BSSID_INFO));
-                               }
-                       }
-                       }
-                       if(pPmkId)
-                               kfree(pPmkId);
-               break;
-        default:
-            DBGPRINT(RT_DEBUG_TRACE, ("Set::unknown IOCTL's subcmd = 0x%08x\n", cmd));
-            Status = -EOPNOTSUPP;
-            break;
-    }
-
-
-    return Status;
-}
-
-INT RTMPQueryInformation(
-    IN  PRTMP_ADAPTER pAdapter,
-    IN  OUT struct ifreq    *rq,
-    IN  INT                 cmd)
-{
-    struct iwreq                        *wrq = (struct iwreq *) rq;
-    NDIS_802_11_BSSID_LIST_EX           *pBssidList = NULL;
-    PNDIS_WLAN_BSSID_EX                 pBss;
-    NDIS_802_11_SSID                    Ssid;
-    NDIS_802_11_CONFIGURATION           *pConfiguration = NULL;
-    RT_802_11_LINK_STATUS               *pLinkStatus = NULL;
-    RT_802_11_STA_CONFIG                *pStaConfig = NULL;
-    NDIS_802_11_STATISTICS              *pStatistics = NULL;
-    NDIS_802_11_RTS_THRESHOLD           RtsThresh;
-    NDIS_802_11_FRAGMENTATION_THRESHOLD FragThresh;
-    NDIS_802_11_POWER_MODE              PowerMode;
-    NDIS_802_11_NETWORK_INFRASTRUCTURE  BssType;
-    RT_802_11_PREAMBLE                  PreamType;
-    NDIS_802_11_AUTHENTICATION_MODE     AuthMode;
-    NDIS_802_11_WEP_STATUS              WepStatus;
-    NDIS_MEDIA_STATE                    MediaState;
-    ULONG                               BssBufSize, ulInfo=0, NetworkTypeList[4], apsd = 0;
-    USHORT                              BssLen = 0;
-    PUCHAR                              pBuf = NULL, pPtr;
-    INT                                 Status = NDIS_STATUS_SUCCESS;
-    UINT                                we_version_compiled;
-    UCHAR                               i, Padding = 0;
-    BOOLEAN                             RadioState;
-       UCHAR   driverVersion[8];
-    OID_SET_HT_PHYMODE                         *pHTPhyMode = NULL;
-
-    switch(cmd)
-    {
-        case RT_OID_DEVICE_NAME:
-            wrq->u.data.length = sizeof(STA_NIC_DEVICE_NAME);
-            Status = copy_to_user(wrq->u.data.pointer, STA_NIC_DEVICE_NAME, wrq->u.data.length);
-            break;
-        case RT_OID_VERSION_INFO:
-                       DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_VERSION_INFO \n"));
-                       wrq->u.data.length = 8*sizeof(UCHAR);
-                       sprintf(&driverVersion[0], "%s", STA_DRIVER_VERSION);
-                       driverVersion[7] = '\0';
-                       if (copy_to_user(wrq->u.data.pointer, &driverVersion, wrq->u.data.length))
-            {
-                               Status = -EFAULT;
-            }
-            break;
-        case OID_802_11_BSSID_LIST:
-            if (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
-            {
-               /*
-                * Still scanning, indicate the caller should try again.
-                */
-               DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_BSSID_LIST (Still scanning)\n"));
-                               return -EAGAIN;
-            }
-            DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_BSSID_LIST (%d BSS returned)\n",pAdapter->ScanTab.BssNr));
-                       pAdapter->StaCfg.bScanReqIsFromWebUI = FALSE;
-            // Claculate total buffer size required
-            BssBufSize = sizeof(ULONG);
-
-            for (i = 0; i < pAdapter->ScanTab.BssNr; i++)
-            {
-                // Align pointer to 4 bytes boundary.
-                //Padding = 4 - (pAdapter->ScanTab.BssEntry[i].VarIELen & 0x0003);
-                //if (Padding == 4)
-                //    Padding = 0;
-                BssBufSize += (sizeof(NDIS_WLAN_BSSID_EX) - 1 + sizeof(NDIS_802_11_FIXED_IEs) + pAdapter->ScanTab.BssEntry[i].VarIELen + Padding);
-            }
-
-            // For safety issue, we add 256 bytes just in case
-            BssBufSize += 256;
-            // Allocate the same size as passed from higher layer
-            pBuf = kmalloc(BssBufSize, MEM_ALLOC_FLAG);
-            if(pBuf == NULL)
-            {
-                Status = -ENOMEM;
-                break;
-            }
-            // Init 802_11_BSSID_LIST_EX structure
-            NdisZeroMemory(pBuf, BssBufSize);
-            pBssidList = (PNDIS_802_11_BSSID_LIST_EX) pBuf;
-            pBssidList->NumberOfItems = pAdapter->ScanTab.BssNr;
-
-            // Calculate total buffer length
-            BssLen = 4; // Consist of NumberOfItems
-            // Point to start of NDIS_WLAN_BSSID_EX
-            // pPtr = pBuf + sizeof(ULONG);
-            pPtr = (PUCHAR) &pBssidList->Bssid[0];
-            for (i = 0; i < pAdapter->ScanTab.BssNr; i++)
-            {
-                pBss = (PNDIS_WLAN_BSSID_EX) pPtr;
-                NdisMoveMemory(&pBss->MacAddress, &pAdapter->ScanTab.BssEntry[i].Bssid, MAC_ADDR_LEN);
-                if ((pAdapter->ScanTab.BssEntry[i].Hidden == 1) && (pAdapter->StaCfg.bShowHiddenSSID == FALSE))
-                {
-                    //
-                                       // We must return this SSID during 4way handshaking, otherwise Aegis will failed to parse WPA infomation
-                                       // and then failed to send EAPOl farame.
-                                       //
-                                       if ((pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA) && (pAdapter->StaCfg.PortSecured != WPA_802_1X_PORT_SECURED))
-                                       {
-                                               pBss->Ssid.SsidLength = pAdapter->ScanTab.BssEntry[i].SsidLen;
-                                               NdisMoveMemory(pBss->Ssid.Ssid, pAdapter->ScanTab.BssEntry[i].Ssid, pAdapter->ScanTab.BssEntry[i].SsidLen);
-                                       }
-                                       else
-                       pBss->Ssid.SsidLength = 0;
-                }
-                else
-                {
-                    pBss->Ssid.SsidLength = pAdapter->ScanTab.BssEntry[i].SsidLen;
-                    NdisMoveMemory(pBss->Ssid.Ssid, pAdapter->ScanTab.BssEntry[i].Ssid, pAdapter->ScanTab.BssEntry[i].SsidLen);
-                }
-                pBss->Privacy = pAdapter->ScanTab.BssEntry[i].Privacy;
-                pBss->Rssi = pAdapter->ScanTab.BssEntry[i].Rssi - pAdapter->BbpRssiToDbmDelta;
-                pBss->NetworkTypeInUse = NetworkTypeInUseSanity(&pAdapter->ScanTab.BssEntry[i]);
-                pBss->Configuration.Length = sizeof(NDIS_802_11_CONFIGURATION);
-                pBss->Configuration.BeaconPeriod = pAdapter->ScanTab.BssEntry[i].BeaconPeriod;
-                pBss->Configuration.ATIMWindow = pAdapter->ScanTab.BssEntry[i].AtimWin;
-
-                MAP_CHANNEL_ID_TO_KHZ(pAdapter->ScanTab.BssEntry[i].Channel, pBss->Configuration.DSConfig);
-
-                if (pAdapter->ScanTab.BssEntry[i].BssType == BSS_INFRA)
-                    pBss->InfrastructureMode = Ndis802_11Infrastructure;
-                else
-                    pBss->InfrastructureMode = Ndis802_11IBSS;
-
-                NdisMoveMemory(pBss->SupportedRates, pAdapter->ScanTab.BssEntry[i].SupRate, pAdapter->ScanTab.BssEntry[i].SupRateLen);
-                NdisMoveMemory(pBss->SupportedRates + pAdapter->ScanTab.BssEntry[i].SupRateLen,
-                               pAdapter->ScanTab.BssEntry[i].ExtRate,
-                               pAdapter->ScanTab.BssEntry[i].ExtRateLen);
-
-                if (pAdapter->ScanTab.BssEntry[i].VarIELen == 0)
-                {
-                    pBss->IELength = sizeof(NDIS_802_11_FIXED_IEs);
-                    NdisMoveMemory(pBss->IEs, &pAdapter->ScanTab.BssEntry[i].FixIEs, sizeof(NDIS_802_11_FIXED_IEs));
-                    pPtr = pPtr + sizeof(NDIS_WLAN_BSSID_EX) - 1 + sizeof(NDIS_802_11_FIXED_IEs);
-                }
-                else
-                {
-                    pBss->IELength = (ULONG)(sizeof(NDIS_802_11_FIXED_IEs) + pAdapter->ScanTab.BssEntry[i].VarIELen);
-                    pPtr = pPtr + sizeof(NDIS_WLAN_BSSID_EX) - 1 + sizeof(NDIS_802_11_FIXED_IEs);
-                    NdisMoveMemory(pBss->IEs, &pAdapter->ScanTab.BssEntry[i].FixIEs, sizeof(NDIS_802_11_FIXED_IEs));
-                    NdisMoveMemory(pBss->IEs + sizeof(NDIS_802_11_FIXED_IEs), pAdapter->ScanTab.BssEntry[i].VarIEs, pAdapter->ScanTab.BssEntry[i].VarIELen);
-                    pPtr += pAdapter->ScanTab.BssEntry[i].VarIELen;
-                }
-                pBss->Length = (ULONG)(sizeof(NDIS_WLAN_BSSID_EX) - 1 + sizeof(NDIS_802_11_FIXED_IEs) + pAdapter->ScanTab.BssEntry[i].VarIELen + Padding);
-
-#if WIRELESS_EXT < 17
-                if ((BssLen + pBss->Length) < wrq->u.data.length)
-                BssLen += pBss->Length;
-                else
-                {
-                    pBssidList->NumberOfItems = i;
-                    break;
-                }
-#else
-                BssLen += pBss->Length;
-#endif
-            }
-
-#if WIRELESS_EXT < 17
-            wrq->u.data.length = BssLen;
-#else
-            if (BssLen > wrq->u.data.length)
-            {
-                kfree(pBssidList);
-                return -E2BIG;
-            }
-            else
-                wrq->u.data.length = BssLen;
-#endif
-            Status = copy_to_user(wrq->u.data.pointer, pBssidList, BssLen);
-            kfree(pBssidList);
-            break;
-        case OID_802_3_CURRENT_ADDRESS:
-            wrq->u.data.length = MAC_ADDR_LEN;
-            Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CurrentAddress, wrq->u.data.length);
-            break;
-        case OID_GEN_MEDIA_CONNECT_STATUS:
-            if (pAdapter->IndicateMediaState == NdisMediaStateConnected)
-                MediaState = NdisMediaStateConnected;
-            else
-                MediaState = NdisMediaStateDisconnected;
-
-            wrq->u.data.length = sizeof(NDIS_MEDIA_STATE);
-            Status = copy_to_user(wrq->u.data.pointer, &MediaState, wrq->u.data.length);
-            break;
-        case OID_802_11_BSSID:
-            if (INFRA_ON(pAdapter) || ADHOC_ON(pAdapter))
-            {
-                Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.Bssid, sizeof(NDIS_802_11_MAC_ADDRESS));
-
-            }
-            else
-            {
-                DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_BSSID(=EMPTY)\n"));
-                Status = -ENOTCONN;
-            }
-            break;
-        case OID_802_11_SSID:
-                       NdisZeroMemory(&Ssid, sizeof(NDIS_802_11_SSID));
-                       NdisZeroMemory(Ssid.Ssid, MAX_LEN_OF_SSID);
-            Ssid.SsidLength = pAdapter->CommonCfg.SsidLen;
-                       memcpy(Ssid.Ssid, pAdapter->CommonCfg.Ssid,     Ssid.SsidLength);
-            wrq->u.data.length = sizeof(NDIS_802_11_SSID);
-            Status = copy_to_user(wrq->u.data.pointer, &Ssid, wrq->u.data.length);
-            DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_SSID (Len=%d, ssid=%s)\n", Ssid.SsidLength,Ssid.Ssid));
-            break;
-        case RT_OID_802_11_QUERY_LINK_STATUS:
-            pLinkStatus = (RT_802_11_LINK_STATUS *) kmalloc(sizeof(RT_802_11_LINK_STATUS), MEM_ALLOC_FLAG);
-            if (pLinkStatus)
-            {
-                pLinkStatus->CurrTxRate = RateIdTo500Kbps[pAdapter->CommonCfg.TxRate];   // unit : 500 kbps
-                pLinkStatus->ChannelQuality = pAdapter->Mlme.ChannelQuality;
-                pLinkStatus->RxByteCount = pAdapter->RalinkCounters.ReceivedByteCount;
-                pLinkStatus->TxByteCount = pAdapter->RalinkCounters.TransmittedByteCount;
-                       pLinkStatus->CentralChannel = pAdapter->CommonCfg.CentralChannel;
-                wrq->u.data.length = sizeof(RT_802_11_LINK_STATUS);
-                Status = copy_to_user(wrq->u.data.pointer, pLinkStatus, wrq->u.data.length);
-                kfree(pLinkStatus);
-                DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_LINK_STATUS\n"));
-            }
-            else
-            {
-                DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_LINK_STATUS(kmalloc failed)\n"));
-                Status = -EFAULT;
-            }
-            break;
-        case OID_802_11_CONFIGURATION:
-            pConfiguration = (NDIS_802_11_CONFIGURATION *) kmalloc(sizeof(NDIS_802_11_CONFIGURATION), MEM_ALLOC_FLAG);
-            if (pConfiguration)
-            {
-                pConfiguration->Length = sizeof(NDIS_802_11_CONFIGURATION);
-                pConfiguration->BeaconPeriod = pAdapter->CommonCfg.BeaconPeriod;
-                pConfiguration->ATIMWindow = pAdapter->StaActive.AtimWin;
-                MAP_CHANNEL_ID_TO_KHZ(pAdapter->CommonCfg.Channel, pConfiguration->DSConfig);
-                wrq->u.data.length = sizeof(NDIS_802_11_CONFIGURATION);
-                Status = copy_to_user(wrq->u.data.pointer, pConfiguration, wrq->u.data.length);
-                DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_CONFIGURATION(BeaconPeriod=%ld,AtimW=%ld,Channel=%d) \n",
-                                        pConfiguration->BeaconPeriod, pConfiguration->ATIMWindow, pAdapter->CommonCfg.Channel));
-                               kfree(pConfiguration);
-            }
-            else
-            {
-                DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_CONFIGURATION(kmalloc failed)\n"));
-                Status = -EFAULT;
-            }
-            break;
-               case RT_OID_802_11_SNR_0:
-                       if ((pAdapter->StaCfg.LastSNR0 > 0))
-                       {
-                               ulInfo = ((0xeb - pAdapter->StaCfg.LastSNR0) * 3) /     16 ;
-                               wrq->u.data.length = sizeof(ulInfo);
-                               Status = copy_to_user(wrq->u.data.pointer, &ulInfo,     wrq->u.data.length);
-                               DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_SNR_0(0x=%lx)\n", ulInfo));
-                       }
-            else
-                           Status = -EFAULT;
-                       break;
-               case RT_OID_802_11_SNR_1:
-                       if ((pAdapter->Antenna.field.RxPath     > 1) &&
-                (pAdapter->StaCfg.LastSNR1 > 0))
-                       {
-                               ulInfo = ((0xeb - pAdapter->StaCfg.LastSNR1) * 3) /     16 ;
-                               wrq->u.data.length = sizeof(ulInfo);
-                               Status = copy_to_user(wrq->u.data.pointer, &ulInfo,     wrq->u.data.length);
-                               DBGPRINT(RT_DEBUG_TRACE,("Query::RT_OID_802_11_SNR_1(0x=%lx)\n",ulInfo));
-                       }
-                       else
-                               Status = -EFAULT;
-            DBGPRINT(RT_DEBUG_TRACE,("Query::RT_OID_802_11_SNR_1(pAdapter->StaCfg.LastSNR1=%d)\n",pAdapter->StaCfg.LastSNR1));
-                       break;
-        case OID_802_11_RSSI_TRIGGER:
-            ulInfo = pAdapter->StaCfg.RssiSample.LastRssi0 - pAdapter->BbpRssiToDbmDelta;
-            wrq->u.data.length = sizeof(ulInfo);
-            Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
-            DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_RSSI_TRIGGER(=%ld)\n", ulInfo));
-            break;
-               case OID_802_11_RSSI:
-        case RT_OID_802_11_RSSI:
-                       ulInfo = pAdapter->StaCfg.RssiSample.LastRssi0;
-                       wrq->u.data.length = sizeof(ulInfo);
-                       Status = copy_to_user(wrq->u.data.pointer, &ulInfo,     wrq->u.data.length);
-                       break;
-               case RT_OID_802_11_RSSI_1:
-            ulInfo = pAdapter->StaCfg.RssiSample.LastRssi1;
-                       wrq->u.data.length = sizeof(ulInfo);
-                       Status = copy_to_user(wrq->u.data.pointer, &ulInfo,     wrq->u.data.length);
-                       break;
-        case RT_OID_802_11_RSSI_2:
-            ulInfo = pAdapter->StaCfg.RssiSample.LastRssi2;
-                       wrq->u.data.length = sizeof(ulInfo);
-                       Status = copy_to_user(wrq->u.data.pointer, &ulInfo,     wrq->u.data.length);
-                       break;
-        case OID_802_11_STATISTICS:
-            pStatistics = (NDIS_802_11_STATISTICS *) kmalloc(sizeof(NDIS_802_11_STATISTICS), MEM_ALLOC_FLAG);
-            if (pStatistics)
-            {
-                DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_STATISTICS \n"));
-                // add the most up-to-date h/w raw counters into software counters
-                           NICUpdateRawCounters(pAdapter);
-
-                // Sanity check for calculation of sucessful count
-                if (pAdapter->WlanCounters.TransmittedFragmentCount.QuadPart < pAdapter->WlanCounters.RetryCount.QuadPart)
-                    pAdapter->WlanCounters.TransmittedFragmentCount.QuadPart = pAdapter->WlanCounters.RetryCount.QuadPart;
-
-                pStatistics->TransmittedFragmentCount.QuadPart = pAdapter->WlanCounters.TransmittedFragmentCount.QuadPart;
-                pStatistics->MulticastTransmittedFrameCount.QuadPart = pAdapter->WlanCounters.MulticastTransmittedFrameCount.QuadPart;
-                pStatistics->FailedCount.QuadPart = pAdapter->WlanCounters.FailedCount.QuadPart;
-                pStatistics->RetryCount.QuadPart = pAdapter->WlanCounters.RetryCount.QuadPart;
-                pStatistics->MultipleRetryCount.QuadPart = pAdapter->WlanCounters.MultipleRetryCount.QuadPart;
-                pStatistics->RTSSuccessCount.QuadPart = pAdapter->WlanCounters.RTSSuccessCount.QuadPart;
-                pStatistics->RTSFailureCount.QuadPart = pAdapter->WlanCounters.RTSFailureCount.QuadPart;
-                pStatistics->ACKFailureCount.QuadPart = pAdapter->WlanCounters.ACKFailureCount.QuadPart;
-                pStatistics->FrameDuplicateCount.QuadPart = pAdapter->WlanCounters.FrameDuplicateCount.QuadPart;
-                pStatistics->ReceivedFragmentCount.QuadPart = pAdapter->WlanCounters.ReceivedFragmentCount.QuadPart;
-                pStatistics->MulticastReceivedFrameCount.QuadPart = pAdapter->WlanCounters.MulticastReceivedFrameCount.QuadPart;
-#ifdef DBG
-                pStatistics->FCSErrorCount = pAdapter->RalinkCounters.RealFcsErrCount;
-#else
-                pStatistics->FCSErrorCount.QuadPart = pAdapter->WlanCounters.FCSErrorCount.QuadPart;
-                pStatistics->FrameDuplicateCount.u.LowPart = pAdapter->WlanCounters.FrameDuplicateCount.u.LowPart / 100;
-#endif
-                wrq->u.data.length = sizeof(NDIS_802_11_STATISTICS);
-                Status = copy_to_user(wrq->u.data.pointer, pStatistics, wrq->u.data.length);
-                kfree(pStatistics);
-            }
-            else
-            {
-                DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_STATISTICS(kmalloc failed)\n"));
-                Status = -EFAULT;
-            }
-            break;
-        case OID_GEN_RCV_OK:
-            ulInfo = pAdapter->Counters8023.GoodReceives;
-            wrq->u.data.length = sizeof(ulInfo);
-            Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
-            break;
-        case OID_GEN_RCV_NO_BUFFER:
-            ulInfo = pAdapter->Counters8023.RxNoBuffer;
-            wrq->u.data.length = sizeof(ulInfo);
-            Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
-            break;
-        case RT_OID_802_11_PHY_MODE:
-            ulInfo = (ULONG)pAdapter->CommonCfg.PhyMode;
-            wrq->u.data.length = sizeof(ulInfo);
-            Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
-            DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_PHY_MODE (=%ld)\n", ulInfo));
-            break;
-        case RT_OID_802_11_STA_CONFIG:
-            pStaConfig = (RT_802_11_STA_CONFIG *) kmalloc(sizeof(RT_802_11_STA_CONFIG), MEM_ALLOC_FLAG);
-            if (pStaConfig)
-            {
-                DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_STA_CONFIG\n"));
-                pStaConfig->EnableTxBurst = pAdapter->CommonCfg.bEnableTxBurst;
-                pStaConfig->EnableTurboRate = 0;
-                pStaConfig->UseBGProtection = pAdapter->CommonCfg.UseBGProtection;
-                pStaConfig->UseShortSlotTime = pAdapter->CommonCfg.bUseShortSlotTime;
-                //pStaConfig->AdhocMode = pAdapter->StaCfg.AdhocMode;
-                pStaConfig->HwRadioStatus = (pAdapter->StaCfg.bHwRadio == TRUE) ? 1 : 0;
-                pStaConfig->Rsv1 = 0;
-                pStaConfig->SystemErrorBitmap = pAdapter->SystemErrorBitmap;
-                wrq->u.data.length = sizeof(RT_802_11_STA_CONFIG);
-                Status = copy_to_user(wrq->u.data.pointer, pStaConfig, wrq->u.data.length);
-                kfree(pStaConfig);
-            }
-            else
-            {
-                DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_STA_CONFIG(kmalloc failed)\n"));
-                Status = -EFAULT;
-            }
-            break;
-        case OID_802_11_RTS_THRESHOLD:
-            RtsThresh = pAdapter->CommonCfg.RtsThreshold;
-            wrq->u.data.length = sizeof(RtsThresh);
-            Status = copy_to_user(wrq->u.data.pointer, &RtsThresh, wrq->u.data.length);
-            DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_RTS_THRESHOLD(=%ld)\n", RtsThresh));
-            break;
-        case OID_802_11_FRAGMENTATION_THRESHOLD:
-            FragThresh = pAdapter->CommonCfg.FragmentThreshold;
-            if (pAdapter->CommonCfg.bUseZeroToDisableFragment == TRUE)
-                FragThresh = 0;
-            wrq->u.data.length = sizeof(FragThresh);
-            Status = copy_to_user(wrq->u.data.pointer, &FragThresh, wrq->u.data.length);
-            DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_FRAGMENTATION_THRESHOLD(=%ld)\n", FragThresh));
-            break;
-        case OID_802_11_POWER_MODE:
-            PowerMode = pAdapter->StaCfg.WindowsPowerMode;
-            wrq->u.data.length = sizeof(PowerMode);
-            Status = copy_to_user(wrq->u.data.pointer, &PowerMode, wrq->u.data.length);
-            DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_POWER_MODE(=%d)\n", PowerMode));
-            break;
-        case RT_OID_802_11_RADIO:
-            RadioState = (BOOLEAN) pAdapter->StaCfg.bSwRadio;
-            wrq->u.data.length = sizeof(RadioState);
-            Status = copy_to_user(wrq->u.data.pointer, &RadioState, wrq->u.data.length);
-            DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_RADIO (=%d)\n", RadioState));
-            break;
-        case OID_802_11_INFRASTRUCTURE_MODE:
-            if (pAdapter->StaCfg.BssType == BSS_ADHOC)
-                BssType = Ndis802_11IBSS;
-            else if (pAdapter->StaCfg.BssType == BSS_INFRA)
-                BssType = Ndis802_11Infrastructure;
-            else if (pAdapter->StaCfg.BssType == BSS_MONITOR)
-                BssType = Ndis802_11Monitor;
-            else
-                BssType = Ndis802_11AutoUnknown;
-
-            wrq->u.data.length = sizeof(BssType);
-            Status = copy_to_user(wrq->u.data.pointer, &BssType, wrq->u.data.length);
-            DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_INFRASTRUCTURE_MODE(=%d)\n", BssType));
-            break;
-        case RT_OID_802_11_PREAMBLE:
-            PreamType = pAdapter->CommonCfg.TxPreamble;
-            wrq->u.data.length = sizeof(PreamType);
-            Status = copy_to_user(wrq->u.data.pointer, &PreamType, wrq->u.data.length);
-            DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_PREAMBLE(=%d)\n", PreamType));
-            break;
-        case OID_802_11_AUTHENTICATION_MODE:
-            AuthMode = pAdapter->StaCfg.AuthMode;
-            wrq->u.data.length = sizeof(AuthMode);
-            Status = copy_to_user(wrq->u.data.pointer, &AuthMode, wrq->u.data.length);
-            DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_AUTHENTICATION_MODE(=%d)\n", AuthMode));
-            break;
-        case OID_802_11_WEP_STATUS:
-            WepStatus = pAdapter->StaCfg.WepStatus;
-            wrq->u.data.length = sizeof(WepStatus);
-            Status = copy_to_user(wrq->u.data.pointer, &WepStatus, wrq->u.data.length);
-            DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_WEP_STATUS(=%d)\n", WepStatus));
-            break;
-        case OID_802_11_TX_POWER_LEVEL:
-                       wrq->u.data.length = sizeof(ULONG);
-                       Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.TxPower, wrq->u.data.length);
-                       DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_TX_POWER_LEVEL %x\n",pAdapter->CommonCfg.TxPower));
-                       break;
-        case RT_OID_802_11_TX_POWER_LEVEL_1:
-            wrq->u.data.length = sizeof(ULONG);
-            Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.TxPowerPercentage, wrq->u.data.length);
-                       DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_TX_POWER_LEVEL_1 (=%ld)\n", pAdapter->CommonCfg.TxPowerPercentage));
-                       break;
-        case OID_802_11_NETWORK_TYPES_SUPPORTED:
-                       if ((pAdapter->RfIcType == RFIC_2850) || (pAdapter->RfIcType == RFIC_2750))
-                       {
-                               NetworkTypeList[0] = 3;                 // NumberOfItems = 3
-                               NetworkTypeList[1] = Ndis802_11DS;      // NetworkType[1] = 11b
-                               NetworkTypeList[2] = Ndis802_11OFDM24;  // NetworkType[2] = 11g
-                               NetworkTypeList[3] = Ndis802_11OFDM5;   // NetworkType[3] = 11a
-                wrq->u.data.length = 16;
-                               Status = copy_to_user(wrq->u.data.pointer, &NetworkTypeList[0], wrq->u.data.length);
-                       }
-                       else
-                       {
-                               NetworkTypeList[0] = 2;                 // NumberOfItems = 2
-                               NetworkTypeList[1] = Ndis802_11DS;      // NetworkType[1] = 11b
-                               NetworkTypeList[2] = Ndis802_11OFDM24;  // NetworkType[2] = 11g
-                           wrq->u.data.length = 12;
-                               Status = copy_to_user(wrq->u.data.pointer, &NetworkTypeList[0], wrq->u.data.length);
-                       }
-                       DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_NETWORK_TYPES_SUPPORTED\n"));
-                               break;
-           case OID_802_11_NETWORK_TYPE_IN_USE:
-            wrq->u.data.length = sizeof(ULONG);
-                       if (pAdapter->CommonCfg.PhyMode == PHY_11A)
-                               ulInfo = Ndis802_11OFDM5;
-                       else if ((pAdapter->CommonCfg.PhyMode == PHY_11BG_MIXED) || (pAdapter->CommonCfg.PhyMode == PHY_11G))
-                               ulInfo = Ndis802_11OFDM24;
-                       else
-                               ulInfo = Ndis802_11DS;
-            Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
-                       break;
-        case RT_OID_802_11_QUERY_LAST_RX_RATE:
-            ulInfo = (ULONG)pAdapter->LastRxRate;
-            wrq->u.data.length = sizeof(ulInfo);
-                       Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
-                       DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_LAST_RX_RATE (=%ld)\n", ulInfo));
-                       break;
-               case RT_OID_802_11_QUERY_LAST_TX_RATE:
-                       //ulInfo = (ULONG)pAdapter->LastTxRate;
-                       ulInfo = (ULONG)pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.word;
-                       wrq->u.data.length = sizeof(ulInfo);
-                       Status = copy_to_user(wrq->u.data.pointer, &ulInfo,     wrq->u.data.length);
-                       DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_LAST_TX_RATE (=%lx)\n", ulInfo));
-                       break;
-        case RT_OID_802_11_QUERY_EEPROM_VERSION:
-            wrq->u.data.length = sizeof(ULONG);
-            Status = copy_to_user(wrq->u.data.pointer, &pAdapter->EepromVersion, wrq->u.data.length);
-            break;
-        case RT_OID_802_11_QUERY_FIRMWARE_VERSION:
-            wrq->u.data.length = sizeof(ULONG);
-            Status = copy_to_user(wrq->u.data.pointer, &pAdapter->FirmwareVersion, wrq->u.data.length);
-                       break;
-           case RT_OID_802_11_QUERY_NOISE_LEVEL:
-                       wrq->u.data.length = sizeof(UCHAR);
-                       Status = copy_to_user(wrq->u.data.pointer, &pAdapter->BbpWriteLatch[66], wrq->u.data.length);
-                       DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_NOISE_LEVEL (=%d)\n", pAdapter->BbpWriteLatch[66]));
-                       break;
-           case RT_OID_802_11_EXTRA_INFO:
-                       wrq->u.data.length = sizeof(ULONG);
-                       Status = copy_to_user(wrq->u.data.pointer, &pAdapter->ExtraInfo, wrq->u.data.length);
-               DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_EXTRA_INFO (=%ld)\n", pAdapter->ExtraInfo));
-               break;
-           case RT_OID_WE_VERSION_COMPILED:
-               wrq->u.data.length = sizeof(UINT);
-               we_version_compiled = WIRELESS_EXT;
-               Status = copy_to_user(wrq->u.data.pointer, &we_version_compiled, wrq->u.data.length);
-               break;
-               case RT_OID_802_11_QUERY_APSD_SETTING:
-                       apsd = (pAdapter->CommonCfg.bAPSDCapable | (pAdapter->CommonCfg.bAPSDAC_BE << 1) | (pAdapter->CommonCfg.bAPSDAC_BK << 2)
-                               | (pAdapter->CommonCfg.bAPSDAC_VI << 3) | (pAdapter->CommonCfg.bAPSDAC_VO << 4) | (pAdapter->CommonCfg.MaxSPLength << 5));
-
-                       wrq->u.data.length = sizeof(ULONG);
-                       Status = copy_to_user(wrq->u.data.pointer, &apsd, wrq->u.data.length);
-                       DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_APSD_SETTING (=0x%lx,APSDCap=%d,AC_BE=%d,AC_BK=%d,AC_VI=%d,AC_VO=%d,MAXSPLen=%d)\n",
-                               apsd,pAdapter->CommonCfg.bAPSDCapable,pAdapter->CommonCfg.bAPSDAC_BE,pAdapter->CommonCfg.bAPSDAC_BK,pAdapter->CommonCfg.bAPSDAC_VI,pAdapter->CommonCfg.bAPSDAC_VO,pAdapter->CommonCfg.MaxSPLength));
-                       break;
-               case RT_OID_802_11_QUERY_APSD_PSM:
-                       wrq->u.data.length = sizeof(ULONG);
-                       Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.bAPSDForcePowerSave, wrq->u.data.length);
-                       DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_APSD_PSM (=%d)\n", pAdapter->CommonCfg.bAPSDForcePowerSave));
-                       break;
-               case RT_OID_802_11_QUERY_WMM:
-                       wrq->u.data.length = sizeof(BOOLEAN);
-                       Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.bWmmCapable, wrq->u.data.length);
-                       DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_WMM (=%d)\n",     pAdapter->CommonCfg.bWmmCapable));
-                       break;
-        case RT_OID_NEW_DRIVER:
-            {
-                UCHAR enabled = 1;
-               wrq->u.data.length = sizeof(UCHAR);
-               Status = copy_to_user(wrq->u.data.pointer, &enabled, wrq->u.data.length);
-                DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_NEW_DRIVER (=%d)\n", enabled));
-            }
-               break;
-        case RT_OID_WPA_SUPPLICANT_SUPPORT:
-               wrq->u.data.length = sizeof(UCHAR);
-               Status = copy_to_user(wrq->u.data.pointer, &pAdapter->StaCfg.WpaSupplicantUP, wrq->u.data.length);
-            DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_WPA_SUPPLICANT_SUPPORT (=%d)\n", pAdapter->StaCfg.WpaSupplicantUP));
-               break;
-        case RT_OID_DRIVER_DEVICE_NAME:
-            DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_DRIVER_DEVICE_NAME \n"));
-                       wrq->u.data.length = 16;
-                       if (copy_to_user(wrq->u.data.pointer, pAdapter->StaCfg.dev_name, wrq->u.data.length))
-                       {
-                               Status = -EFAULT;
-                       }
-            break;
-        case RT_OID_802_11_QUERY_HT_PHYMODE:
-            pHTPhyMode = (OID_SET_HT_PHYMODE *) kmalloc(sizeof(OID_SET_HT_PHYMODE), MEM_ALLOC_FLAG);
-            if (pHTPhyMode)
-            {
-                pHTPhyMode->PhyMode = pAdapter->CommonCfg.PhyMode;
-                       pHTPhyMode->HtMode = (UCHAR)pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.field.MODE;
-                       pHTPhyMode->BW = (UCHAR)pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.field.BW;
-                       pHTPhyMode->MCS= (UCHAR)pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.field.MCS;
-                       pHTPhyMode->SHORTGI= (UCHAR)pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.field.ShortGI;
-                       pHTPhyMode->STBC= (UCHAR)pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.field.STBC;
-
-                       pHTPhyMode->ExtOffset = ((pAdapter->CommonCfg.CentralChannel < pAdapter->CommonCfg.Channel) ? (EXTCHA_BELOW) : (EXTCHA_ABOVE));
-                wrq->u.data.length = sizeof(OID_SET_HT_PHYMODE);
-                if (copy_to_user(wrq->u.data.pointer, pHTPhyMode, wrq->u.data.length))
-                       {
-                               Status = -EFAULT;
-                       }
-                       DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_HT_PHYMODE (PhyMode = %d, MCS =%d, BW = %d, STBC = %d, ExtOffset=%d)\n",
-                               pHTPhyMode->HtMode, pHTPhyMode->MCS, pHTPhyMode->BW, pHTPhyMode->STBC, pHTPhyMode->ExtOffset));
-                       DBGPRINT(RT_DEBUG_TRACE, (" MlmeUpdateTxRates (.word = %x )\n", pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.word));
-            }
-            else
-            {
-                DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_STA_CONFIG(kmalloc failed)\n"));
-                Status = -EFAULT;
-            }
-            break;
-        case RT_OID_802_11_COUNTRY_REGION:
-            DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_COUNTRY_REGION \n"));
-                       wrq->u.data.length = sizeof(ulInfo);
-            ulInfo = pAdapter->CommonCfg.CountryRegionForABand;
-            ulInfo = (ulInfo << 8)|(pAdapter->CommonCfg.CountryRegion);
-                       if (copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length))
-            {
-                               Status = -EFAULT;
-            }
-            break;
-        case RT_OID_802_11_QUERY_DAT_HT_PHYMODE:
-            pHTPhyMode = (OID_SET_HT_PHYMODE *) kmalloc(sizeof(OID_SET_HT_PHYMODE), MEM_ALLOC_FLAG);
-            if (pHTPhyMode)
-            {
-                pHTPhyMode->PhyMode = pAdapter->CommonCfg.PhyMode;
-                       pHTPhyMode->HtMode = (UCHAR)pAdapter->CommonCfg.RegTransmitSetting.field.HTMODE;
-                       pHTPhyMode->BW = (UCHAR)pAdapter->CommonCfg.RegTransmitSetting.field.BW;
-                       pHTPhyMode->MCS= (UCHAR)pAdapter->StaCfg.DesiredTransmitSetting.field.MCS;
-                       pHTPhyMode->SHORTGI= (UCHAR)pAdapter->CommonCfg.RegTransmitSetting.field.ShortGI;
-                       pHTPhyMode->STBC= (UCHAR)pAdapter->CommonCfg.RegTransmitSetting.field.STBC;
-
-                wrq->u.data.length = sizeof(OID_SET_HT_PHYMODE);
-                if (copy_to_user(wrq->u.data.pointer, pHTPhyMode, wrq->u.data.length))
-                       {
-                               Status = -EFAULT;
-                       }
-                       DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_HT_PHYMODE (PhyMode = %d, MCS =%d, BW = %d, STBC = %d, ExtOffset=%d)\n",
-                               pHTPhyMode->HtMode, pHTPhyMode->MCS, pHTPhyMode->BW, pHTPhyMode->STBC, pHTPhyMode->ExtOffset));
-                       DBGPRINT(RT_DEBUG_TRACE, (" MlmeUpdateTxRates (.word = %x )\n", pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.word));
-            }
-            else
-            {
-                DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_STA_CONFIG(kmalloc failed)\n"));
-                Status = -EFAULT;
-            }
-            break;
-        case RT_OID_QUERY_MULTIPLE_CARD_SUPPORT:
-                       wrq->u.data.length = sizeof(UCHAR);
-            i = 0;
-                       if (copy_to_user(wrq->u.data.pointer, &i, wrq->u.data.length))
-            {
-                               Status = -EFAULT;
-            }
-            DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_QUERY_MULTIPLE_CARD_SUPPORT(=%d) \n", i));
-            break;
-
-               case OID_802_11_BUILD_CHANNEL_EX:
-                       {
-                               UCHAR value;
-                               DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_BUILD_CHANNEL_EX \n"));
-                               wrq->u.data.length = sizeof(UCHAR);
-                               DBGPRINT(RT_DEBUG_TRACE, ("Doesn't support EXT_BUILD_CHANNEL_LIST.\n"));
-                               value = 0;
-                               Status = copy_to_user(wrq->u.data.pointer, &value, 1);
-                               DBGPRINT(RT_DEBUG_TRACE, ("Status=%d\n", Status));
-                       }
-                       break;
-
-               case OID_802_11_GET_CH_LIST:
-                       {
-                               PRT_CHANNEL_LIST_INFO pChListBuf;
-
-                               DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_GET_CH_LIST \n"));
-                               if (pAdapter->ChannelListNum == 0)
-                               {
-                                       wrq->u.data.length = 0;
-                                       break;
-                               }
-
-                               pChListBuf = (RT_CHANNEL_LIST_INFO *) kmalloc(sizeof(RT_CHANNEL_LIST_INFO), MEM_ALLOC_FLAG);
-                               if (pChListBuf == NULL)
-                               {
-                                       wrq->u.data.length = 0;
-                                       break;
-                               }
-
-                               pChListBuf->ChannelListNum = pAdapter->ChannelListNum;
-                               for (i = 0; i < pChListBuf->ChannelListNum; i++)
-                                       pChListBuf->ChannelList[i] = pAdapter->ChannelList[i].Channel;
-
-                               wrq->u.data.length = sizeof(RT_CHANNEL_LIST_INFO);
-                               Status = copy_to_user(wrq->u.data.pointer, pChListBuf, sizeof(RT_CHANNEL_LIST_INFO));
-                               DBGPRINT(RT_DEBUG_TRACE, ("Status=%d\n", Status));
-
-                               if (pChListBuf)
-                                       kfree(pChListBuf);
-                       }
-                       break;
-
-               case OID_802_11_GET_COUNTRY_CODE:
-                       DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_GET_COUNTRY_CODE \n"));
-                       wrq->u.data.length = 2;
-                       Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.CountryCode, 2);
-                       DBGPRINT(RT_DEBUG_TRACE, ("Status=%d\n", Status));
-                       break;
-
-               case OID_802_11_GET_CHANNEL_GEOGRAPHY:
-                       DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_GET_CHANNEL_GEOGRAPHY \n"));
-                       wrq->u.data.length = 1;
-                       Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.Geography, 1);
-                       DBGPRINT(RT_DEBUG_TRACE, ("Status=%d\n", Status));
-                       break;
-
-        default:
-            DBGPRINT(RT_DEBUG_TRACE, ("Query::unknown IOCTL's subcmd = 0x%08x\n", cmd));
-            Status = -EOPNOTSUPP;
-            break;
-    }
-    return Status;
-}
-
-INT rt28xx_sta_ioctl(
-       IN      struct net_device       *net_dev,
-       IN      OUT     struct ifreq    *rq,
-       IN      INT                                     cmd)
-{
-       POS_COOKIE                      pObj;
-       VIRTUAL_ADAPTER         *pVirtualAd = NULL;
-       RTMP_ADAPTER        *pAd = NULL;
-       struct iwreq        *wrq = (struct iwreq *) rq;
-       BOOLEAN                         StateMachineTouched = FALSE;
-       INT                                     Status = NDIS_STATUS_SUCCESS;
-       USHORT                          subcmd;
-
-       if (net_dev->priv_flags == INT_MAIN)
-       {
-               pAd = net_dev->ml_priv;
-       }
-       else
-       {
-               pVirtualAd = net_dev->ml_priv;
-               pAd = pVirtualAd->RtmpDev->ml_priv;
-       }
-       pObj = (POS_COOKIE) pAd->OS_Cookie;
-
-       if (pAd == NULL)
-       {
-               /* if 1st open fail, pAd will be free;
-                  So the net_dev->ml_priv will be NULL in 2rd open */
-               return -ENETDOWN;
-       }
-
-    //check if the interface is down
-    if(!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_IN_USE))
-    {
-        {
-            DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
-                   return -ENETDOWN;
-        }
-    }
-
-       {       // determine this ioctl command is comming from which interface.
-               pObj->ioctl_if_type = INT_MAIN;
-               pObj->ioctl_if = MAIN_MBSSID;
-       }
-
-       switch(cmd)
-       {
-        case SIOCGIFHWADDR:
-                       DBGPRINT(RT_DEBUG_TRACE, ("IOCTL::SIOCGIFHWADDR\n"));
-                       memcpy(wrq->u.name, pAd->CurrentAddress, ETH_ALEN);
-                       break;
-               case SIOCGIWNAME:
-        {
-               char *name=&wrq->u.name[0];
-               rt_ioctl_giwname(net_dev, NULL, name, NULL);
-                       break;
-               }
-               case SIOCGIWESSID:  //Get ESSID
-        {
-               struct iw_point *essid=&wrq->u.essid;
-               rt_ioctl_giwessid(net_dev, NULL, essid, essid->pointer);
-                       break;
-               }
-               case SIOCSIWESSID:  //Set ESSID
-        {
-               struct iw_point *essid=&wrq->u.essid;
-               rt_ioctl_siwessid(net_dev, NULL, essid, essid->pointer);
-                       break;
-               }
-               case SIOCSIWNWID:   // set network id (the cell)
-               case SIOCGIWNWID:   // get network id
-                       Status = -EOPNOTSUPP;
-                       break;
-               case SIOCSIWFREQ:   //set channel/frequency (Hz)
-        {
-               struct iw_freq *freq=&wrq->u.freq;
-               rt_ioctl_siwfreq(net_dev, NULL, freq, NULL);
-                       break;
-               }
-               case SIOCGIWFREQ:   // get channel/frequency (Hz)
-        {
-               struct iw_freq *freq=&wrq->u.freq;
-               rt_ioctl_giwfreq(net_dev, NULL, freq, NULL);
-                       break;
-               }
-               case SIOCSIWNICKN: //set node name/nickname
-        {
-               struct iw_point *data=&wrq->u.data;
-               rt_ioctl_siwnickn(net_dev, NULL, data, NULL);
-                       break;
-               }
-               case SIOCGIWNICKN: //get node name/nickname
-        {
-               struct iw_point *data=&wrq->u.data;
-               rt_ioctl_giwnickn(net_dev, NULL, data, NULL);
-                       break;
-               }
-               case SIOCGIWRATE:   //get default bit rate (bps)
-                   rt_ioctl_giwrate(net_dev, NULL, &wrq->u, NULL);
-            break;
-           case SIOCSIWRATE:  //set default bit rate (bps)
-               rt_ioctl_siwrate(net_dev, NULL, &wrq->u, NULL);
-            break;
-        case SIOCGIWRTS:  // get RTS/CTS threshold (bytes)
-        {
-               struct iw_param *rts=&wrq->u.rts;
-               rt_ioctl_giwrts(net_dev, NULL, rts, NULL);
-                       break;
-               }
-        case SIOCSIWRTS:  //set RTS/CTS threshold (bytes)
-        {
-               struct iw_param *rts=&wrq->u.rts;
-               rt_ioctl_siwrts(net_dev, NULL, rts, NULL);
-                       break;
-               }
-        case SIOCGIWFRAG:  //get fragmentation thr (bytes)
-        {
-               struct iw_param *frag=&wrq->u.frag;
-               rt_ioctl_giwfrag(net_dev, NULL, frag, NULL);
-                       break;
-               }
-        case SIOCSIWFRAG:  //set fragmentation thr (bytes)
-        {
-               struct iw_param *frag=&wrq->u.frag;
-               rt_ioctl_siwfrag(net_dev, NULL, frag, NULL);
-                       break;
-               }
-        case SIOCGIWENCODE:  //get encoding token & mode
-        {
-               struct iw_point *erq=&wrq->u.encoding;
-               if(erq->pointer)
-                       rt_ioctl_giwencode(net_dev, NULL, erq, erq->pointer);
-                       break;
-               }
-        case SIOCSIWENCODE:  //set encoding token & mode
-        {
-               struct iw_point *erq=&wrq->u.encoding;
-               if(erq->pointer)
-                       rt_ioctl_siwencode(net_dev, NULL, erq, erq->pointer);
-                       break;
-               }
-               case SIOCGIWAP:     //get access point MAC addresses
-        {
-               struct sockaddr *ap_addr=&wrq->u.ap_addr;
-               rt_ioctl_giwap(net_dev, NULL, ap_addr, ap_addr->sa_data);
-                       break;
-               }
-           case SIOCSIWAP:  //set access point MAC addresses
-        {
-               struct sockaddr *ap_addr=&wrq->u.ap_addr;
-               rt_ioctl_siwap(net_dev, NULL, ap_addr, ap_addr->sa_data);
-                       break;
-               }
-               case SIOCGIWMODE:   //get operation mode
-        {
-               __u32 *mode=&wrq->u.mode;
-               rt_ioctl_giwmode(net_dev, NULL, mode, NULL);
-                       break;
-               }
-               case SIOCSIWMODE:   //set operation mode
-        {
-               __u32 *mode=&wrq->u.mode;
-               rt_ioctl_siwmode(net_dev, NULL, mode, NULL);
-                       break;
-               }
-               case SIOCGIWSENS:   //get sensitivity (dBm)
-               case SIOCSIWSENS:       //set sensitivity (dBm)
-               case SIOCGIWPOWER:  //get Power Management settings
-               case SIOCSIWPOWER:  //set Power Management settings
-               case SIOCGIWTXPOW:  //get transmit power (dBm)
-               case SIOCSIWTXPOW:  //set transmit power (dBm)
-               case SIOCGIWRANGE:      //Get range of parameters
-               case SIOCGIWRETRY:      //get retry limits and lifetime
-               case SIOCSIWRETRY:      //set retry limits and lifetime
-                       Status = -EOPNOTSUPP;
-                       break;
-               case RT_PRIV_IOCTL:
-        case RT_PRIV_IOCTL_EXT:
-                       subcmd = wrq->u.data.flags;
-                       if( subcmd & OID_GET_SET_TOGGLE)
-                               Status = RTMPSetInformation(pAd, rq, subcmd);
-                       else
-                               Status = RTMPQueryInformation(pAd, rq, subcmd);
-                       break;
-               case SIOCGIWPRIV:
-                       if (wrq->u.data.pointer)
-                       {
-                               if ( access_ok(VERIFY_WRITE, wrq->u.data.pointer, sizeof(privtab)) != TRUE)
-                                       break;
-                               wrq->u.data.length = sizeof(privtab) / sizeof(privtab[0]);
-                               if (copy_to_user(wrq->u.data.pointer, privtab, sizeof(privtab)))
-                                       Status = -EFAULT;
-                       }
-                       break;
-               case RTPRIV_IOCTL_SET:
-                       if(access_ok(VERIFY_READ, wrq->u.data.pointer, wrq->u.data.length) != TRUE)
-                               break;
-                       rt_ioctl_setparam(net_dev, NULL, NULL, wrq->u.data.pointer);
-                       break;
-               case RTPRIV_IOCTL_GSITESURVEY:
-                       RTMPIoctlGetSiteSurvey(pAd, wrq);
-                   break;
-#ifdef DBG
-               case RTPRIV_IOCTL_MAC:
-                       RTMPIoctlMAC(pAd, wrq);
-                       break;
-               case RTPRIV_IOCTL_E2P:
-                       RTMPIoctlE2PROM(pAd, wrq);
-                       break;
-#ifdef RT30xx
-               case RTPRIV_IOCTL_RF:
-                       RTMPIoctlRF(pAd, wrq);
-                       break;
-#endif // RT30xx //
-#endif // DBG //
-        case SIOCETHTOOL:
-                break;
-               default:
-                       DBGPRINT(RT_DEBUG_ERROR, ("IOCTL::unknown IOCTL's cmd = 0x%08x\n", cmd));
-                       Status = -EOPNOTSUPP;
-                       break;
-       }
-
-    if(StateMachineTouched) // Upper layer sent a MLME-related operations
-       RT28XX_MLME_HANDLER(pAd);
-
-       return Status;
-}
-
-/*
-    ==========================================================================
-    Description:
-        Set SSID
-    Return:
-        TRUE if all parameters are OK, FALSE otherwise
-    ==========================================================================
-*/
-INT Set_SSID_Proc(
-    IN  PRTMP_ADAPTER   pAdapter,
-    IN  PUCHAR          arg)
-{
-    NDIS_802_11_SSID                    Ssid, *pSsid=NULL;
-    BOOLEAN                             StateMachineTouched = FALSE;
-    int                                 success = TRUE;
-
-    if( strlen(arg) <= MAX_LEN_OF_SSID)
-    {
-        NdisZeroMemory(&Ssid, sizeof(NDIS_802_11_SSID));
-        if (strlen(arg) != 0)
-        {
-            NdisMoveMemory(Ssid.Ssid, arg, strlen(arg));
-            Ssid.SsidLength = strlen(arg);
-        }
-        else   //ANY ssid
-        {
-            Ssid.SsidLength = 0;
-                   memcpy(Ssid.Ssid, "", 0);
-                       pAdapter->StaCfg.BssType = BSS_INFRA;
-                       pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
-               pAdapter->StaCfg.WepStatus  = Ndis802_11EncryptionDisabled;
-               }
-        pSsid = &Ssid;
-
-        if (pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE)
-        {
-            RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
-            DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
-        }
-
-        pAdapter->MlmeAux.CurrReqIsFromNdis = TRUE;
-        pAdapter->StaCfg.bScanReqIsFromWebUI = FALSE;
-               pAdapter->bConfigChanged = TRUE;
-
-        MlmeEnqueue(pAdapter,
-                    MLME_CNTL_STATE_MACHINE,
-                    OID_802_11_SSID,
-                    sizeof(NDIS_802_11_SSID),
-                    (VOID *)pSsid);
-
-        StateMachineTouched = TRUE;
-        DBGPRINT(RT_DEBUG_TRACE, ("Set_SSID_Proc::(Len=%d,Ssid=%s)\n", Ssid.SsidLength, Ssid.Ssid));
-    }
-    else
-        success = FALSE;
-
-    if (StateMachineTouched) // Upper layer sent a MLME-related operations
-       RT28XX_MLME_HANDLER(pAdapter);
-
-    return success;
-}
-
-#ifdef WMM_SUPPORT
-/*
-    ==========================================================================
-    Description:
-        Set WmmCapable Enable or Disable
-    Return:
-        TRUE if all parameters are OK, FALSE otherwise
-    ==========================================================================
-*/
-INT    Set_WmmCapable_Proc(
-       IN      PRTMP_ADAPTER   pAd,
-       IN      PUCHAR                  arg)
-{
-       BOOLEAN bWmmCapable;
-
-       bWmmCapable = simple_strtol(arg, 0, 10);
-
-       if ((bWmmCapable == 1)
-#ifdef RT2870
-               && (pAd->NumberOfPipes >= 5)
-#endif // RT2870 //
-               )
-               pAd->CommonCfg.bWmmCapable = TRUE;
-       else if (bWmmCapable == 0)
-               pAd->CommonCfg.bWmmCapable = FALSE;
-       else
-               return FALSE;  //Invalid argument
-
-       DBGPRINT(RT_DEBUG_TRACE, ("Set_WmmCapable_Proc::(bWmmCapable=%d)\n",
-               pAd->CommonCfg.bWmmCapable));
-
-       return TRUE;
-}
-#endif // WMM_SUPPORT //
-
-/*
-    ==========================================================================
-    Description:
-        Set Network Type(Infrastructure/Adhoc mode)
-    Return:
-        TRUE if all parameters are OK, FALSE otherwise
-    ==========================================================================
-*/
-INT Set_NetworkType_Proc(
-    IN  PRTMP_ADAPTER   pAdapter,
-    IN  PUCHAR          arg)
-{
-    UINT32     Value = 0;
-
-    if (strcmp(arg, "Adhoc") == 0)
-       {
-               if (pAdapter->StaCfg.BssType != BSS_ADHOC)
-               {
-                       // Config has changed
-                       pAdapter->bConfigChanged = TRUE;
-            if (MONITOR_ON(pAdapter))
-            {
-                RTMP_IO_WRITE32(pAdapter, RX_FILTR_CFG, STANORMAL);
-                RTMP_IO_READ32(pAdapter, MAC_SYS_CTRL, &Value);
-                               Value &= (~0x80);
-                               RTMP_IO_WRITE32(pAdapter, MAC_SYS_CTRL, Value);
-                OPSTATUS_CLEAR_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED);
-                pAdapter->StaCfg.bAutoReconnect = TRUE;
-                LinkDown(pAdapter, FALSE);
-            }
-                       if (INFRA_ON(pAdapter))
-                       {
-                               //BOOLEAN Cancelled;
-                               // Set the AutoReconnectSsid to prevent it reconnect to old SSID
-                               // Since calling this indicate user don't want to connect to that SSID anymore.
-                               pAdapter->MlmeAux.AutoReconnectSsidLen= 32;
-                               NdisZeroMemory(pAdapter->MlmeAux.AutoReconnectSsid, pAdapter->MlmeAux.AutoReconnectSsidLen);
-
-                               LinkDown(pAdapter, FALSE);
-
-                               DBGPRINT(RT_DEBUG_TRACE, ("NDIS_STATUS_MEDIA_DISCONNECT Event BB!\n"));
-                       }
-               }
-               pAdapter->StaCfg.BssType = BSS_ADHOC;
-        pAdapter->net_dev->type = pAdapter->StaCfg.OriDevType;
-               DBGPRINT(RT_DEBUG_TRACE, ("===>Set_NetworkType_Proc::(AD-HOC)\n"));
-       }
-    else if (strcmp(arg, "Infra") == 0)
-       {
-               if (pAdapter->StaCfg.BssType != BSS_INFRA)
-               {
-                       // Config has changed
-                       pAdapter->bConfigChanged = TRUE;
-            if (MONITOR_ON(pAdapter))
-            {
-                RTMP_IO_WRITE32(pAdapter, RX_FILTR_CFG, STANORMAL);
-                RTMP_IO_READ32(pAdapter, MAC_SYS_CTRL, &Value);
-                               Value &= (~0x80);
-                               RTMP_IO_WRITE32(pAdapter, MAC_SYS_CTRL, Value);
-                OPSTATUS_CLEAR_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED);
-                pAdapter->StaCfg.bAutoReconnect = TRUE;
-                LinkDown(pAdapter, FALSE);
-            }
-                       if (ADHOC_ON(pAdapter))
-                       {
-                               // Set the AutoReconnectSsid to prevent it reconnect to old SSID
-                               // Since calling this indicate user don't want to connect to that SSID anymore.
-                               pAdapter->MlmeAux.AutoReconnectSsidLen= 32;
-                               NdisZeroMemory(pAdapter->MlmeAux.AutoReconnectSsid, pAdapter->MlmeAux.AutoReconnectSsidLen);
-
-                               LinkDown(pAdapter, FALSE);
-                       }
-               }
-               pAdapter->StaCfg.BssType = BSS_INFRA;
-        pAdapter->net_dev->type = pAdapter->StaCfg.OriDevType;
-               DBGPRINT(RT_DEBUG_TRACE, ("===>Set_NetworkType_Proc::(INFRA)\n"));
-
-        pAdapter->StaCfg.BssType = BSS_INFRA;
-       }
-    else if (strcmp(arg, "Monitor") == 0)
-    {
-               UCHAR   bbpValue = 0;
-               BCN_TIME_CFG_STRUC csr;
-               OPSTATUS_CLEAR_FLAG(pAdapter, fOP_STATUS_INFRA_ON);
-        OPSTATUS_CLEAR_FLAG(pAdapter, fOP_STATUS_ADHOC_ON);
-               OPSTATUS_SET_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED);
-               // disable all periodic state machine
-               pAdapter->StaCfg.bAutoReconnect = FALSE;
-               // reset all mlme state machine
-               RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
-               DBGPRINT(RT_DEBUG_TRACE, ("fOP_STATUS_MEDIA_STATE_CONNECTED \n"));
-        if (pAdapter->CommonCfg.CentralChannel == 0)
-        {
-            if (pAdapter->CommonCfg.PhyMode == PHY_11AN_MIXED)
-                pAdapter->CommonCfg.CentralChannel = 36;
-            else
-                pAdapter->CommonCfg.CentralChannel = 6;
-        }
-        else
-            N_ChannelCheck(pAdapter);
-
-       if (pAdapter->CommonCfg.PhyMode >= PHY_11ABGN_MIXED &&
-            pAdapter->CommonCfg.RegTransmitSetting.field.BW == BW_40 &&
-            pAdapter->CommonCfg.RegTransmitSetting.field.EXTCHA == EXTCHA_ABOVE)
-               {
-                       // 40MHz ,control channel at lower
-                       RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, BBP_R4, &bbpValue);
-                       bbpValue &= (~0x18);
-                       bbpValue |= 0x10;
-                       RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R4, bbpValue);
-                       pAdapter->CommonCfg.BBPCurrentBW = BW_40;
-                       //  RX : control channel at lower
-                       RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, BBP_R3, &bbpValue);
-                       bbpValue &= (~0x20);
-                       RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R3, bbpValue);
-
-                       RTMP_IO_READ32(pAdapter, TX_BAND_CFG, &Value);
-                       Value &= 0xfffffffe;
-                       RTMP_IO_WRITE32(pAdapter, TX_BAND_CFG, Value);
-                       pAdapter->CommonCfg.CentralChannel = pAdapter->CommonCfg.Channel + 2;
-            AsicSwitchChannel(pAdapter, pAdapter->CommonCfg.CentralChannel, FALSE);
-                   AsicLockChannel(pAdapter, pAdapter->CommonCfg.CentralChannel);
-            DBGPRINT(RT_DEBUG_TRACE, ("BW_40 ,control_channel(%d), CentralChannel(%d) \n",
-                                       pAdapter->CommonCfg.Channel,
-                                       pAdapter->CommonCfg.CentralChannel));
-               }
-               else if (pAdapter->CommonCfg.PhyMode >= PHY_11ABGN_MIXED &&
-                 pAdapter->CommonCfg.RegTransmitSetting.field.BW == BW_40 &&
-                 pAdapter->CommonCfg.RegTransmitSetting.field.EXTCHA == EXTCHA_BELOW)
-               {
-                       // 40MHz ,control channel at upper
-                       RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, BBP_R4, &bbpValue);
-                       bbpValue &= (~0x18);
-                       bbpValue |= 0x10;
-                       RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R4, bbpValue);
-                       pAdapter->CommonCfg.BBPCurrentBW = BW_40;
-                       RTMP_IO_READ32(pAdapter, TX_BAND_CFG, &Value);
-                       Value |= 0x1;
-                       RTMP_IO_WRITE32(pAdapter, TX_BAND_CFG, Value);
-
-                       RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, BBP_R3, &bbpValue);
-                       bbpValue |= (0x20);
-                       RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R3, bbpValue);
-                       pAdapter->CommonCfg.CentralChannel = pAdapter->CommonCfg.Channel - 2;
-            AsicSwitchChannel(pAdapter, pAdapter->CommonCfg.CentralChannel, FALSE);
-                   AsicLockChannel(pAdapter, pAdapter->CommonCfg.CentralChannel);
-            DBGPRINT(RT_DEBUG_TRACE, ("BW_40 ,control_channel(%d), CentralChannel(%d) \n",
-                                       pAdapter->CommonCfg.Channel,
-                                       pAdapter->CommonCfg.CentralChannel));
-               }
-               else
-               {
-                       // 20MHz
-                       RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, BBP_R4, &bbpValue);
-                       bbpValue &= (~0x18);
-                       RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R4, bbpValue);
-                       pAdapter->CommonCfg.BBPCurrentBW = BW_20;
-                       AsicSwitchChannel(pAdapter, pAdapter->CommonCfg.Channel, FALSE);
-                       AsicLockChannel(pAdapter, pAdapter->CommonCfg.Channel);
-                       DBGPRINT(RT_DEBUG_TRACE, ("BW_20, Channel(%d)\n", pAdapter->CommonCfg.Channel));
-               }
-               // Enable Rx with promiscuous reception
-               RTMP_IO_WRITE32(pAdapter, RX_FILTR_CFG, 0x3);
-               // ASIC supporsts sniffer function with replacing RSSI with timestamp.
-               //RTMP_IO_READ32(pAdapter, MAC_SYS_CTRL, &Value);
-               //Value |= (0x80);
-               //RTMP_IO_WRITE32(pAdapter, MAC_SYS_CTRL, Value);
-               // disable sync
-               RTMP_IO_READ32(pAdapter, BCN_TIME_CFG, &csr.word);
-               csr.field.bBeaconGen = 0;
-               csr.field.bTBTTEnable = 0;
-               csr.field.TsfSyncMode = 0;
-               RTMP_IO_WRITE32(pAdapter, BCN_TIME_CFG, csr.word);
-
-               pAdapter->StaCfg.BssType = BSS_MONITOR;
-        pAdapter->net_dev->type = ARPHRD_IEEE80211_PRISM; //ARPHRD_IEEE80211; // IEEE80211
-               DBGPRINT(RT_DEBUG_TRACE, ("===>Set_NetworkType_Proc::(MONITOR)\n"));
-    }
-
-    // Reset Ralink supplicant to not use, it will be set to start when UI set PMK key
-    pAdapter->StaCfg.WpaState = SS_NOTUSE;
-
-    DBGPRINT(RT_DEBUG_TRACE, ("Set_NetworkType_Proc::(NetworkType=%d)\n", pAdapter->StaCfg.BssType));
-
-    return TRUE;
-}
-
-/*
-    ==========================================================================
-    Description:
-        Set Authentication mode
-    Return:
-        TRUE if all parameters are OK, FALSE otherwise
-    ==========================================================================
-*/
-INT Set_AuthMode_Proc(
-    IN  PRTMP_ADAPTER   pAdapter,
-    IN  PUCHAR          arg)
-{
-    if ((strcmp(arg, "WEPAUTO") == 0) || (strcmp(arg, "wepauto") == 0))
-        pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeAutoSwitch;
-    else if ((strcmp(arg, "OPEN") == 0) || (strcmp(arg, "open") == 0))
-        pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
-    else if ((strcmp(arg, "SHARED") == 0) || (strcmp(arg, "shared") == 0))
-        pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeShared;
-    else if ((strcmp(arg, "WPAPSK") == 0) || (strcmp(arg, "wpapsk") == 0))
-        pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPAPSK;
-    else if ((strcmp(arg, "WPANONE") == 0) || (strcmp(arg, "wpanone") == 0))
-        pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPANone;
-    else if ((strcmp(arg, "WPA2PSK") == 0) || (strcmp(arg, "wpa2psk") == 0))
-        pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA2PSK;
-    else if ((strcmp(arg, "WPA") == 0) || (strcmp(arg, "wpa") == 0))
-        pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA;
-    else if ((strcmp(arg, "WPA2") == 0) || (strcmp(arg, "wpa2") == 0))
-        pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA2;
-    else
-        return FALSE;
-
-    pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED;
-
-    DBGPRINT(RT_DEBUG_TRACE, ("Set_AuthMode_Proc::(AuthMode=%d)\n", pAdapter->StaCfg.AuthMode));
-
-    return TRUE;
-}
-
-/*
-    ==========================================================================
-    Description:
-        Set Encryption Type
-    Return:
-        TRUE if all parameters are OK, FALSE otherwise
-    ==========================================================================
-*/
-INT Set_EncrypType_Proc(
-    IN  PRTMP_ADAPTER   pAdapter,
-    IN  PUCHAR          arg)
-{
-    if ((strcmp(arg, "NONE") == 0) || (strcmp(arg, "none") == 0))
-    {
-        if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
-            return TRUE;    // do nothing
-
-        pAdapter->StaCfg.WepStatus     = Ndis802_11WEPDisabled;
-        pAdapter->StaCfg.PairCipher    = Ndis802_11WEPDisabled;
-           pAdapter->StaCfg.GroupCipher   = Ndis802_11WEPDisabled;
-    }
-    else if ((strcmp(arg, "WEP") == 0) || (strcmp(arg, "wep") == 0))
-    {
-        if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
-            return TRUE;    // do nothing
-
-        pAdapter->StaCfg.WepStatus     = Ndis802_11WEPEnabled;
-        pAdapter->StaCfg.PairCipher    = Ndis802_11WEPEnabled;
-           pAdapter->StaCfg.GroupCipher   = Ndis802_11WEPEnabled;
-    }
-    else if ((strcmp(arg, "TKIP") == 0) || (strcmp(arg, "tkip") == 0))
-    {
-        if (pAdapter->StaCfg.AuthMode < Ndis802_11AuthModeWPA)
-            return TRUE;    // do nothing
-
-        pAdapter->StaCfg.WepStatus     = Ndis802_11Encryption2Enabled;
-        pAdapter->StaCfg.PairCipher    = Ndis802_11Encryption2Enabled;
-           pAdapter->StaCfg.GroupCipher   = Ndis802_11Encryption2Enabled;
-    }
-    else if ((strcmp(arg, "AES") == 0) || (strcmp(arg, "aes") == 0))
-    {
-        if (pAdapter->StaCfg.AuthMode < Ndis802_11AuthModeWPA)
-            return TRUE;    // do nothing
-
-        pAdapter->StaCfg.WepStatus     = Ndis802_11Encryption3Enabled;
-        pAdapter->StaCfg.PairCipher    = Ndis802_11Encryption3Enabled;
-           pAdapter->StaCfg.GroupCipher   = Ndis802_11Encryption3Enabled;
-    }
-    else
-        return FALSE;
-
-    pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
-
-    DBGPRINT(RT_DEBUG_TRACE, ("Set_EncrypType_Proc::(EncrypType=%d)\n", pAdapter->StaCfg.WepStatus));
-
-    return TRUE;
-}
-
-/*
-    ==========================================================================
-    Description:
-        Set Default Key ID
-    Return:
-        TRUE if all parameters are OK, FALSE otherwise
-    ==========================================================================
-*/
-INT Set_DefaultKeyID_Proc(
-    IN  PRTMP_ADAPTER   pAdapter,
-    IN  PUCHAR          arg)
-{
-    ULONG                               KeyIdx;
-
-    KeyIdx = simple_strtol(arg, 0, 10);
-    if((KeyIdx >= 1 ) && (KeyIdx <= 4))
-        pAdapter->StaCfg.DefaultKeyId = (UCHAR) (KeyIdx - 1 );
-    else
-        return FALSE;  //Invalid argument
-
-    DBGPRINT(RT_DEBUG_TRACE, ("Set_DefaultKeyID_Proc::(DefaultKeyID=%d)\n", pAdapter->StaCfg.DefaultKeyId));
-
-    return TRUE;
-}
-
-/*
-    ==========================================================================
-    Description:
-        Set WEP KEY1
-    Return:
-        TRUE if all parameters are OK, FALSE otherwise
-    ==========================================================================
-*/
-INT Set_Key1_Proc(
-    IN  PRTMP_ADAPTER   pAdapter,
-    IN  PUCHAR          arg)
-{
-    int                                 KeyLen;
-    int                                 i;
-    UCHAR                               CipherAlg=CIPHER_WEP64;
-
-    if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
-        return TRUE;    // do nothing
-
-    KeyLen = strlen(arg);
-
-    switch (KeyLen)
-    {
-        case 5: //wep 40 Ascii type
-            pAdapter->SharedKey[BSS0][0].KeyLen = KeyLen;
-            memcpy(pAdapter->SharedKey[BSS0][0].Key, arg, KeyLen);
-            CipherAlg = CIPHER_WEP64;
-            DBGPRINT(RT_DEBUG_TRACE, ("Set_Key1_Proc::(Key1=%s and type=%s)\n", arg, "Ascii"));
-            break;
-        case 10: //wep 40 Hex type
-            for(i=0; i < KeyLen; i++)
-            {
-                if( !isxdigit(*(arg+i)) )
-                    return FALSE;  //Not Hex value;
-            }
-            pAdapter->SharedKey[BSS0][0].KeyLen = KeyLen / 2 ;
-            AtoH(arg, pAdapter->SharedKey[BSS0][0].Key, KeyLen / 2);
-            CipherAlg = CIPHER_WEP64;
-            DBGPRINT(RT_DEBUG_TRACE, ("Set_Key1_Proc::(Key1=%s and type=%s)\n", arg, "Hex"));
-            break;
-        case 13: //wep 104 Ascii type
-            pAdapter->SharedKey[BSS0][0].KeyLen = KeyLen;
-            memcpy(pAdapter->SharedKey[BSS0][0].Key, arg, KeyLen);
-            CipherAlg = CIPHER_WEP128;
-            DBGPRINT(RT_DEBUG_TRACE, ("Set_Key1_Proc::(Key1=%s and type=%s)\n", arg, "Ascii"));
-            break;
-        case 26: //wep 104 Hex type
-            for(i=0; i < KeyLen; i++)
-            {
-                if( !isxdigit(*(arg+i)) )
-                    return FALSE;  //Not Hex value;
-            }
-            pAdapter->SharedKey[BSS0][0].KeyLen = KeyLen / 2 ;
-            AtoH(arg, pAdapter->SharedKey[BSS0][0].Key, KeyLen / 2);
-            CipherAlg = CIPHER_WEP128;
-            DBGPRINT(RT_DEBUG_TRACE, ("Set_Key1_Proc::(Key1=%s and type=%s)\n", arg, "Hex"));
-            break;
-        default: //Invalid argument
-            DBGPRINT(RT_DEBUG_TRACE, ("Set_Key1_Proc::Invalid argument (=%s)\n", arg));
-            return FALSE;
-    }
-
-    pAdapter->SharedKey[BSS0][0].CipherAlg = CipherAlg;
-
-    // Set keys (into ASIC)
-    if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
-        ;   // not support
-    else    // Old WEP stuff
-    {
-        AsicAddSharedKeyEntry(pAdapter,
-                              0,
-                              0,
-                              pAdapter->SharedKey[BSS0][0].CipherAlg,
-                              pAdapter->SharedKey[BSS0][0].Key,
-                              NULL,
-                              NULL);
-    }
-
-    return TRUE;
-}
-/*
-    ==========================================================================
-
-    Description:
-        Set WEP KEY2
-    Return:
-        TRUE if all parameters are OK, FALSE otherwise
-    ==========================================================================
-*/
-INT Set_Key2_Proc(
-    IN  PRTMP_ADAPTER   pAdapter,
-    IN  PUCHAR          arg)
-{
-    int                                 KeyLen;
-    int                                 i;
-    UCHAR                               CipherAlg=CIPHER_WEP64;
-
-    if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
-        return TRUE;    // do nothing
-
-    KeyLen = strlen(arg);
-
-    switch (KeyLen)
-    {
-        case 5: //wep 40 Ascii type
-            pAdapter->SharedKey[BSS0][1].KeyLen = KeyLen;
-            memcpy(pAdapter->SharedKey[BSS0][1].Key, arg, KeyLen);
-            CipherAlg = CIPHER_WEP64;
-            DBGPRINT(RT_DEBUG_TRACE, ("Set_Key2_Proc::(Key2=%s and type=%s)\n", arg, "Ascii"));
-            break;
-        case 10: //wep 40 Hex type
-            for(i=0; i < KeyLen; i++)
-            {
-                if( !isxdigit(*(arg+i)) )
-                    return FALSE;  //Not Hex value;
-            }
-            pAdapter->SharedKey[BSS0][1].KeyLen = KeyLen / 2 ;
-            AtoH(arg, pAdapter->SharedKey[BSS0][1].Key, KeyLen / 2);
-            CipherAlg = CIPHER_WEP64;
-            DBGPRINT(RT_DEBUG_TRACE, ("Set_Key2_Proc::(Key2=%s and type=%s)\n", arg, "Hex"));
-            break;
-        case 13: //wep 104 Ascii type
-            pAdapter->SharedKey[BSS0][1].KeyLen = KeyLen;
-            memcpy(pAdapter->SharedKey[BSS0][1].Key, arg, KeyLen);
-            CipherAlg = CIPHER_WEP128;
-            DBGPRINT(RT_DEBUG_TRACE, ("Set_Key2_Proc::(Key2=%s and type=%s)\n", arg, "Ascii"));
-            break;
-        case 26: //wep 104 Hex type
-            for(i=0; i < KeyLen; i++)
-            {
-                if( !isxdigit(*(arg+i)) )
-                    return FALSE;  //Not Hex value;
-            }
-            pAdapter->SharedKey[BSS0][1].KeyLen = KeyLen / 2 ;
-            AtoH(arg, pAdapter->SharedKey[BSS0][1].Key, KeyLen / 2);
-            CipherAlg = CIPHER_WEP128;
-            DBGPRINT(RT_DEBUG_TRACE, ("Set_Key2_Proc::(Key2=%s and type=%s)\n", arg, "Hex"));
-            break;
-        default: //Invalid argument
-            DBGPRINT(RT_DEBUG_TRACE, ("Set_Key2_Proc::Invalid argument (=%s)\n", arg));
-            return FALSE;
-    }
-    pAdapter->SharedKey[BSS0][1].CipherAlg = CipherAlg;
-
-    // Set keys (into ASIC)
-    if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
-        ;   // not support
-    else    // Old WEP stuff
-    {
-        AsicAddSharedKeyEntry(pAdapter,
-                              0,
-                              1,
-                              pAdapter->SharedKey[BSS0][1].CipherAlg,
-                              pAdapter->SharedKey[BSS0][1].Key,
-                              NULL,
-                              NULL);
-    }
-
-    return TRUE;
-}
-/*
-    ==========================================================================
-    Description:
-        Set WEP KEY3
-    Return:
-        TRUE if all parameters are OK, FALSE otherwise
-    ==========================================================================
-*/
-INT Set_Key3_Proc(
-    IN  PRTMP_ADAPTER   pAdapter,
-    IN  PUCHAR          arg)
-{
-    int                                 KeyLen;
-    int                                 i;
-    UCHAR                               CipherAlg=CIPHER_WEP64;
-
-    if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
-        return TRUE;    // do nothing
-
-    KeyLen = strlen(arg);
-
-    switch (KeyLen)
-    {
-        case 5: //wep 40 Ascii type
-            pAdapter->SharedKey[BSS0][2].KeyLen = KeyLen;
-            memcpy(pAdapter->SharedKey[BSS0][2].Key, arg, KeyLen);
-            CipherAlg = CIPHER_WEP64;
-            DBGPRINT(RT_DEBUG_TRACE, ("Set_Key3_Proc::(Key3=%s and type=Ascii)\n", arg));
-            break;
-        case 10: //wep 40 Hex type
-            for(i=0; i < KeyLen; i++)
-            {
-                if( !isxdigit(*(arg+i)) )
-                    return FALSE;  //Not Hex value;
-            }
-            pAdapter->SharedKey[BSS0][2].KeyLen = KeyLen / 2 ;
-            AtoH(arg, pAdapter->SharedKey[BSS0][2].Key, KeyLen / 2);
-            CipherAlg = CIPHER_WEP64;
-            DBGPRINT(RT_DEBUG_TRACE, ("Set_Key3_Proc::(Key3=%s and type=Hex)\n", arg));
-            break;
-        case 13: //wep 104 Ascii type
-            pAdapter->SharedKey[BSS0][2].KeyLen = KeyLen;
-            memcpy(pAdapter->SharedKey[BSS0][2].Key, arg, KeyLen);
-            CipherAlg = CIPHER_WEP128;
-            DBGPRINT(RT_DEBUG_TRACE, ("Set_Key3_Proc::(Key3=%s and type=Ascii)\n", arg));
-            break;
-        case 26: //wep 104 Hex type
-            for(i=0; i < KeyLen; i++)
-            {
-                if( !isxdigit(*(arg+i)) )
-                    return FALSE;  //Not Hex value;
-            }
-            pAdapter->SharedKey[BSS0][2].KeyLen = KeyLen / 2 ;
-            AtoH(arg, pAdapter->SharedKey[BSS0][2].Key, KeyLen / 2);
-            CipherAlg = CIPHER_WEP128;
-            DBGPRINT(RT_DEBUG_TRACE, ("Set_Key3_Proc::(Key3=%s and type=Hex)\n", arg));
-            break;
-        default: //Invalid argument
-            DBGPRINT(RT_DEBUG_TRACE, ("Set_Key3_Proc::Invalid argument (=%s)\n", arg));
-            return FALSE;
-    }
-    pAdapter->SharedKey[BSS0][2].CipherAlg = CipherAlg;
-
-    // Set keys (into ASIC)
-    if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
-        ;   // not support
-    else    // Old WEP stuff
-    {
-        AsicAddSharedKeyEntry(pAdapter,
-                              0,
-                              2,
-                              pAdapter->SharedKey[BSS0][2].CipherAlg,
-                              pAdapter->SharedKey[BSS0][2].Key,
-                              NULL,
-                              NULL);
-    }
-
-    return TRUE;
-}
-/*
-    ==========================================================================
-    Description:
-        Set WEP KEY4
-    Return:
-        TRUE if all parameters are OK, FALSE otherwise
-    ==========================================================================
-*/
-INT Set_Key4_Proc(
-    IN  PRTMP_ADAPTER   pAdapter,
-    IN  PUCHAR          arg)
-{
-    int                                 KeyLen;
-    int                                 i;
-    UCHAR                               CipherAlg=CIPHER_WEP64;
-
-    if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
-        return TRUE;    // do nothing
-
-    KeyLen = strlen(arg);
-
-    switch (KeyLen)
-    {
-        case 5: //wep 40 Ascii type
-            pAdapter->SharedKey[BSS0][3].KeyLen = KeyLen;
-            memcpy(pAdapter->SharedKey[BSS0][3].Key, arg, KeyLen);
-            CipherAlg = CIPHER_WEP64;
-            DBGPRINT(RT_DEBUG_TRACE, ("Set_Key4_Proc::(Key4=%s and type=%s)\n", arg, "Ascii"));
-            break;
-        case 10: //wep 40 Hex type
-            for(i=0; i < KeyLen; i++)
-            {
-                if( !isxdigit(*(arg+i)) )
-                    return FALSE;  //Not Hex value;
-            }
-            pAdapter->SharedKey[BSS0][3].KeyLen = KeyLen / 2 ;
-            AtoH(arg, pAdapter->SharedKey[BSS0][3].Key, KeyLen / 2);
-            CipherAlg = CIPHER_WEP64;
-            DBGPRINT(RT_DEBUG_TRACE, ("Set_Key4_Proc::(Key4=%s and type=%s)\n", arg, "Hex"));
-            break;
-        case 13: //wep 104 Ascii type
-            pAdapter->SharedKey[BSS0][3].KeyLen = KeyLen;
-            memcpy(pAdapter->SharedKey[BSS0][3].Key, arg, KeyLen);
-            CipherAlg = CIPHER_WEP128;
-            DBGPRINT(RT_DEBUG_TRACE, ("Set_Key4_Proc::(Key4=%s and type=%s)\n", arg, "Ascii"));
-            break;
-        case 26: //wep 104 Hex type
-            for(i=0; i < KeyLen; i++)
-            {
-                if( !isxdigit(*(arg+i)) )
-                    return FALSE;  //Not Hex value;
-            }
-            pAdapter->SharedKey[BSS0][3].KeyLen = KeyLen / 2 ;
-            AtoH(arg, pAdapter->SharedKey[BSS0][3].Key, KeyLen / 2);
-            CipherAlg = CIPHER_WEP128;
-            DBGPRINT(RT_DEBUG_TRACE, ("Set_Key4_Proc::(Key4=%s and type=%s)\n", arg, "Hex"));
-            break;
-        default: //Invalid argument
-            DBGPRINT(RT_DEBUG_TRACE, ("Set_Key4_Proc::Invalid argument (=%s)\n", arg));
-            return FALSE;
-    }
-    pAdapter->SharedKey[BSS0][3].CipherAlg = CipherAlg;
-
-    // Set keys (into ASIC)
-    if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
-        ;   // not support
-    else    // Old WEP stuff
-    {
-        AsicAddSharedKeyEntry(pAdapter,
-                              0,
-                              3,
-                              pAdapter->SharedKey[BSS0][3].CipherAlg,
-                              pAdapter->SharedKey[BSS0][3].Key,
-                              NULL,
-                              NULL);
-    }
-
-    return TRUE;
-}
-
-/*
-    ==========================================================================
-    Description:
-        Set WPA PSK key
-    Return:
-        TRUE if all parameters are OK, FALSE otherwise
-    ==========================================================================
-*/
-INT Set_WPAPSK_Proc(
-    IN  PRTMP_ADAPTER   pAdapter,
-    IN  PUCHAR          arg)
-{
-    UCHAR                   keyMaterial[40];
-
-    if ((pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPAPSK) &&
-        (pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPA2PSK) &&
-           (pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPANone)
-               )
-        return TRUE;    // do nothing
-
-    DBGPRINT(RT_DEBUG_TRACE, ("Set_WPAPSK_Proc::(WPAPSK=%s)\n", arg));
-
-    NdisZeroMemory(keyMaterial, 40);
-
-    if ((strlen(arg) < 8) || (strlen(arg) > 64))
-    {
-        DBGPRINT(RT_DEBUG_TRACE, ("Set failed!!(WPAPSK=%s), WPAPSK key-string required 8 ~ 64 characters \n", arg));
-        return FALSE;
-    }
-
-    if (strlen(arg) == 64)
-    {
-        AtoH(arg, keyMaterial, 32);
-        NdisMoveMemory(pAdapter->StaCfg.PMK, keyMaterial, 32);
-
-    }
-    else
-    {
-        PasswordHash((char *)arg, pAdapter->MlmeAux.Ssid, pAdapter->MlmeAux.SsidLen, keyMaterial);
-        NdisMoveMemory(pAdapter->StaCfg.PMK, keyMaterial, 32);
-    }
-
-
-
-    if(pAdapter->StaCfg.BssType == BSS_ADHOC &&
-       pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPANone)
-    {
-         pAdapter->StaCfg.WpaState = SS_NOTUSE;
-    }
-    else
-    {
-        // Start STA supplicant state machine
-        pAdapter->StaCfg.WpaState = SS_START;
-    }
-
-    return TRUE;
-}
-
-/*
-    ==========================================================================
-    Description:
-        Set Power Saving mode
-    Return:
-        TRUE if all parameters are OK, FALSE otherwise
-    ==========================================================================
-*/
-INT Set_PSMode_Proc(
-    IN  PRTMP_ADAPTER   pAdapter,
-    IN  PUCHAR          arg)
-{
-    if (pAdapter->StaCfg.BssType == BSS_INFRA)
-    {
-        if ((strcmp(arg, "Max_PSP") == 0) ||
-                       (strcmp(arg, "max_psp") == 0) ||
-                       (strcmp(arg, "MAX_PSP") == 0))
-        {
-            // do NOT turn on PSM bit here, wait until MlmeCheckForPsmChange()
-            // to exclude certain situations.
-            if (pAdapter->StaCfg.bWindowsACCAMEnable == FALSE)
-                pAdapter->StaCfg.WindowsPowerMode = Ndis802_11PowerModeMAX_PSP;
-            pAdapter->StaCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeMAX_PSP;
-            OPSTATUS_SET_FLAG(pAdapter, fOP_STATUS_RECEIVE_DTIM);
-            pAdapter->StaCfg.DefaultListenCount = 5;
-
-        }
-        else if ((strcmp(arg, "Fast_PSP") == 0) ||
-                                (strcmp(arg, "fast_psp") == 0) ||
-                 (strcmp(arg, "FAST_PSP") == 0))
-        {
-            // do NOT turn on PSM bit here, wait until MlmeCheckForPsmChange()
-            // to exclude certain situations.
-            OPSTATUS_SET_FLAG(pAdapter, fOP_STATUS_RECEIVE_DTIM);
-            if (pAdapter->StaCfg.bWindowsACCAMEnable == FALSE)
-                pAdapter->StaCfg.WindowsPowerMode = Ndis802_11PowerModeFast_PSP;
-            pAdapter->StaCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeFast_PSP;
-            pAdapter->StaCfg.DefaultListenCount = 3;
-        }
-        else if ((strcmp(arg, "Legacy_PSP") == 0) ||
-                 (strcmp(arg, "legacy_psp") == 0) ||
-                 (strcmp(arg, "LEGACY_PSP") == 0))
-        {
-            // do NOT turn on PSM bit here, wait until MlmeCheckForPsmChange()
-            // to exclude certain situations.
-            OPSTATUS_SET_FLAG(pAdapter, fOP_STATUS_RECEIVE_DTIM);
-            if (pAdapter->StaCfg.bWindowsACCAMEnable == FALSE)
-                pAdapter->StaCfg.WindowsPowerMode = Ndis802_11PowerModeLegacy_PSP;
-            pAdapter->StaCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeLegacy_PSP;
-            pAdapter->StaCfg.DefaultListenCount = 3;
-        }
-        else
-        {
-            //Default Ndis802_11PowerModeCAM
-            // clear PSM bit immediately
-            MlmeSetPsmBit(pAdapter, PWR_ACTIVE);
-            OPSTATUS_SET_FLAG(pAdapter, fOP_STATUS_RECEIVE_DTIM);
-            if (pAdapter->StaCfg.bWindowsACCAMEnable == FALSE)
-                pAdapter->StaCfg.WindowsPowerMode = Ndis802_11PowerModeCAM;
-            pAdapter->StaCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeCAM;
-        }
-
-        DBGPRINT(RT_DEBUG_TRACE, ("Set_PSMode_Proc::(PSMode=%ld)\n", pAdapter->StaCfg.WindowsPowerMode));
-    }
-    else
-        return FALSE;
-
-
-    return TRUE;
-}
-
-/*
-    ==========================================================================
-    Description:
-        Set WpaSupport flag.
-    Value:
-        0: Driver ignore wpa_supplicant.
-        1: wpa_supplicant initiates scanning and AP selection.
-        2: driver takes care of scanning, AP selection, and IEEE 802.11 association parameters.
-    Return:
-        TRUE if all parameters are OK, FALSE otherwise
-    ==========================================================================
-*/
-INT Set_Wpa_Support(
-    IN PRTMP_ADAPTER   pAd,
-       IN      PUCHAR                  arg)
-{
-
-    if ( simple_strtol(arg, 0, 10) == 0)
-        pAd->StaCfg.WpaSupplicantUP = WPA_SUPPLICANT_DISABLE;
-    else if ( simple_strtol(arg, 0, 10) == 1)
-        pAd->StaCfg.WpaSupplicantUP = WPA_SUPPLICANT_ENABLE;
-    else if ( simple_strtol(arg, 0, 10) == 2)
-        pAd->StaCfg.WpaSupplicantUP = WPA_SUPPLICANT_ENABLE_WITH_WEB_UI;
-    else
-        pAd->StaCfg.WpaSupplicantUP = WPA_SUPPLICANT_DISABLE;
-
-    DBGPRINT(RT_DEBUG_TRACE, ("Set_Wpa_Support::(WpaSupplicantUP=%d)\n", pAd->StaCfg.WpaSupplicantUP));
-
-    return TRUE;
-}
-
-#ifdef DBG
-/*
-    ==========================================================================
-    Description:
-        Read / Write MAC
-    Arguments:
-        pAdapter                    Pointer to our adapter
-        wrq                         Pointer to the ioctl argument
-
-    Return Value:
-        None
-
-    Note:
-        Usage:
-               1.) iwpriv ra0 mac 0        ==> read MAC where Addr=0x0
-               2.) iwpriv ra0 mac 0=12     ==> write MAC where Addr=0x0, value=12
-    ==========================================================================
-*/
-VOID RTMPIoctlMAC(
-       IN      PRTMP_ADAPTER   pAdapter,
-       IN      struct iwreq    *wrq)
-{
-       CHAR                            *this_char;
-       CHAR                            *value;
-       INT                                     j = 0, k = 0;
-       CHAR                            msg[1024];
-       CHAR                            arg[255];
-       ULONG                           macAddr = 0;
-       UCHAR                           temp[16], temp2[16];
-       UINT32                          macValue = 0;
-       INT                                     Status;
-       BOOLEAN                         bIsPrintAllMAC = FALSE;
-
-
-       memset(msg, 0x00, 1024);
-       if (wrq->u.data.length > 1) //No parameters.
-       {
-           Status = copy_from_user(arg, wrq->u.data.pointer, (wrq->u.data.length > 255) ? 255 : wrq->u.data.length);
-               sprintf(msg, "\n");
-
-               //Parsing Read or Write
-           this_char = arg;
-               if (!*this_char)
-                       goto next;
-
-               if ((value = rtstrchr(this_char, '=')) != NULL)
-                       *value++ = 0;
-
-               if (!value || !*value)
-               { //Read
-                       // Sanity check
-                       if(strlen(this_char) > 4)
-                               goto next;
-
-                       j = strlen(this_char);
-                       while(j-- > 0)
-                       {
-                               if(this_char[j] > 'f' || this_char[j] < '0')
-                                       return;
-                       }
-
-                       // Mac Addr
-                       k = j = strlen(this_char);
-                       while(j-- > 0)
-                       {
-                               this_char[4-k+j] = this_char[j];
-                       }
-
-                       while(k < 4)
-                               this_char[3-k++]='0';
-                       this_char[4]='\0';
-
-                       if(strlen(this_char) == 4)
-                       {
-                               AtoH(this_char, temp, 2);
-                               macAddr = *temp*256 + temp[1];
-                               if (macAddr < 0xFFFF)
-                               {
-                                       RTMP_IO_READ32(pAdapter, macAddr, &macValue);
-                                       DBGPRINT(RT_DEBUG_TRACE, ("MacAddr=%lx, MacValue=%x\n", macAddr, macValue));
-                                       sprintf(msg+strlen(msg), "[0x%08lX]:%08X  ", macAddr , macValue);
-                               }
-                               else
-                               {//Invalid parametes, so default printk all mac
-                                       bIsPrintAllMAC = TRUE;
-                                       goto next;
-                               }
-                       }
-               }
-               else
-               { //Write
-                       memcpy(&temp2, value, strlen(value));
-                       temp2[strlen(value)] = '\0';
-
-                       // Sanity check
-                       if((strlen(this_char) > 4) || strlen(temp2) > 8)
-                               goto next;
-
-                       j = strlen(this_char);
-                       while(j-- > 0)
-                       {
-                               if(this_char[j] > 'f' || this_char[j] < '0')
-                                       return;
-                       }
-
-                       j = strlen(temp2);
-                       while(j-- > 0)
-                       {
-                               if(temp2[j] > 'f' || temp2[j] < '0')
-                                       return;
-                       }
-
-                       //MAC Addr
-                       k = j = strlen(this_char);
-                       while(j-- > 0)
-                       {
-                               this_char[4-k+j] = this_char[j];
-                       }
-
-                       while(k < 4)
-                               this_char[3-k++]='0';
-                       this_char[4]='\0';
-
-                       //MAC value
-                       k = j = strlen(temp2);
-                       while(j-- > 0)
-                       {
-                               temp2[8-k+j] = temp2[j];
-                       }
-
-                       while(k < 8)
-                               temp2[7-k++]='0';
-                       temp2[8]='\0';
-
-                       {
-                               AtoH(this_char, temp, 2);
-                               macAddr = *temp*256 + temp[1];
-
-                               AtoH(temp2, temp, 4);
-                               macValue = *temp*256*256*256 + temp[1]*256*256 + temp[2]*256 + temp[3];
-
-                               // debug mode
-                               if (macAddr == (HW_DEBUG_SETTING_BASE + 4))
-                               {
-                                       // 0x2bf4: byte0 non-zero: enable R17 tuning, 0: disable R17 tuning
-                    if (macValue & 0x000000ff)
-                    {
-                        pAdapter->BbpTuning.bEnable = TRUE;
-                        DBGPRINT(RT_DEBUG_TRACE,("turn on R17 tuning\n"));
-                    }
-                    else
-                    {
-                        UCHAR R66;
-                        pAdapter->BbpTuning.bEnable = FALSE;
-                        R66 = 0x26 + GET_LNA_GAIN(pAdapter);
-                                               RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R66, (0x26 + GET_LNA_GAIN(pAdapter)));
-                        DBGPRINT(RT_DEBUG_TRACE,("turn off R17 tuning, restore to 0x%02x\n", R66));
-                    }
-                                       return;
-                               }
-
-                               DBGPRINT(RT_DEBUG_TRACE, ("MacAddr=%02lx, MacValue=0x%x\n", macAddr, macValue));
-
-                               RTMP_IO_WRITE32(pAdapter, macAddr, macValue);
-                               sprintf(msg+strlen(msg), "[0x%08lX]:%08X  ", macAddr, macValue);
-                       }
-               }
-       }
-       else
-               bIsPrintAllMAC = TRUE;
-next:
-       if (bIsPrintAllMAC)
-       {
-               struct file             *file_w;
-               PCHAR                   fileName = "MacDump.txt";
-               mm_segment_t    orig_fs;
-
-               orig_fs = get_fs();
-               set_fs(KERNEL_DS);
-
-               // open file
-               file_w = filp_open(fileName, O_WRONLY|O_CREAT, 0);
-               if (IS_ERR(file_w))
-               {
-                       DBGPRINT(RT_DEBUG_TRACE, ("-->2) %s: Error %ld opening %s\n", __func__, -PTR_ERR(file_w), fileName));
-               }
-               else
-               {
-                       if (file_w->f_op && file_w->f_op->write)
-                       {
-                               file_w->f_pos = 0;
-                               macAddr = 0x1000;
-
-                               while (macAddr <= 0x1800)
-                               {
-                                       RTMP_IO_READ32(pAdapter, macAddr, &macValue);
-                                       sprintf(msg, "%08lx = %08X\n", macAddr, macValue);
-
-                                       // write data to file
-                                       file_w->f_op->write(file_w, msg, strlen(msg), &file_w->f_pos);
-
-                                       printk("%s", msg);
-                                       macAddr += 4;
-                               }
-                               sprintf(msg, "\nDump all MAC values to %s\n", fileName);
-                       }
-                       filp_close(file_w, NULL);
-               }
-               set_fs(orig_fs);
-       }
-       if(strlen(msg) == 1)
-               sprintf(msg+strlen(msg), "===>Error command format!");
-
-       // Copy the information into the user buffer
-       wrq->u.data.length = strlen(msg);
-       Status = copy_to_user(wrq->u.data.pointer, msg, wrq->u.data.length);
-
-       DBGPRINT(RT_DEBUG_TRACE, ("<==RTMPIoctlMAC\n\n"));
-}
-
-/*
-    ==========================================================================
-    Description:
-        Read / Write E2PROM
-    Arguments:
-        pAdapter                    Pointer to our adapter
-        wrq                         Pointer to the ioctl argument
-
-    Return Value:
-        None
-
-    Note:
-        Usage:
-               1.) iwpriv ra0 e2p 0            ==> read E2PROM where Addr=0x0
-               2.) iwpriv ra0 e2p 0=1234    ==> write E2PROM where Addr=0x0, value=1234
-    ==========================================================================
-*/
-VOID RTMPIoctlE2PROM(
-       IN      PRTMP_ADAPTER   pAdapter,
-       IN      struct iwreq    *wrq)
-{
-       CHAR                            *this_char;
-       CHAR                            *value;
-       INT                                     j = 0, k = 0;
-       CHAR                            msg[1024];
-       CHAR                            arg[255];
-       USHORT                          eepAddr = 0;
-       UCHAR                           temp[16], temp2[16];
-       USHORT                          eepValue;
-       int                                     Status;
-       BOOLEAN                         bIsPrintAllE2P = FALSE;
-
-
-       memset(msg, 0x00, 1024);
-       if (wrq->u.data.length > 1) //No parameters.
-       {
-           Status = copy_from_user(arg, wrq->u.data.pointer, (wrq->u.data.length > 255) ? 255 : wrq->u.data.length);
-               sprintf(msg, "\n");
-
-           //Parsing Read or Write
-               this_char = arg;
-
-
-               if (!*this_char)
-                       goto next;
-
-               if ((value = rtstrchr(this_char, '=')) != NULL)
-                       *value++ = 0;
-
-               if (!value || !*value)
-               { //Read
-
-                       // Sanity check
-                       if(strlen(this_char) > 4)
-                               goto next;
-
-                       j = strlen(this_char);
-                       while(j-- > 0)
-                       {
-                               if(this_char[j] > 'f' || this_char[j] < '0')
-                                       return;
-                       }
-
-                       // E2PROM addr
-                       k = j = strlen(this_char);
-                       while(j-- > 0)
-                       {
-                               this_char[4-k+j] = this_char[j];
-                       }
-
-                       while(k < 4)
-                               this_char[3-k++]='0';
-                       this_char[4]='\0';
-
-                       if(strlen(this_char) == 4)
-                       {
-                               AtoH(this_char, temp, 2);
-                               eepAddr = *temp*256 + temp[1];
-                               if (eepAddr < 0xFFFF)
-                               {
-                                       RT28xx_EEPROM_READ16(pAdapter, eepAddr, eepValue);
-                                       sprintf(msg+strlen(msg), "[0x%04X]:0x%04X  ", eepAddr , eepValue);
-                               }
-                               else
-                               {//Invalid parametes, so default printk all bbp
-                                       bIsPrintAllE2P = TRUE;
-                                       goto next;
-                               }
-                       }
-               }
-               else
-               { //Write
-                       memcpy(&temp2, value, strlen(value));
-                       temp2[strlen(value)] = '\0';
-
-                       // Sanity check
-                       if((strlen(this_char) > 4) || strlen(temp2) > 8)
-                               goto next;
-
-                       j = strlen(this_char);
-                       while(j-- > 0)
-                       {
-                               if(this_char[j] > 'f' || this_char[j] < '0')
-                                       return;
-                       }
-                       j = strlen(temp2);
-                       while(j-- > 0)
-                       {
-                               if(temp2[j] > 'f' || temp2[j] < '0')
-                                       return;
-                       }
-
-                       //MAC Addr
-                       k = j = strlen(this_char);
-                       while(j-- > 0)
-                       {
-                               this_char[4-k+j] = this_char[j];
-                       }
-
-                       while(k < 4)
-                               this_char[3-k++]='0';
-                       this_char[4]='\0';
-
-                       //MAC value
-                       k = j = strlen(temp2);
-                       while(j-- > 0)
-                       {
-                               temp2[4-k+j] = temp2[j];
-                       }
-
-                       while(k < 4)
-                               temp2[3-k++]='0';
-                       temp2[4]='\0';
-
-                       AtoH(this_char, temp, 2);
-                       eepAddr = *temp*256 + temp[1];
-
-                       AtoH(temp2, temp, 2);
-                       eepValue = *temp*256 + temp[1];
-
-                       RT28xx_EEPROM_WRITE16(pAdapter, eepAddr, eepValue);
-                       sprintf(msg+strlen(msg), "[0x%02X]:%02X  ", eepAddr, eepValue);
-               }
-       }
-       else
-               bIsPrintAllE2P = TRUE;
-next:
-       if (bIsPrintAllE2P)
-       {
-               struct file             *file_w;
-               PCHAR                   fileName = "EEPROMDump.txt";
-               mm_segment_t    orig_fs;
-
-               orig_fs = get_fs();
-               set_fs(KERNEL_DS);
-
-               // open file
-               file_w = filp_open(fileName, O_WRONLY|O_CREAT, 0);
-               if (IS_ERR(file_w))
-               {
-                       DBGPRINT(RT_DEBUG_TRACE, ("-->2) %s: Error %ld opening %s\n", __func__, -PTR_ERR(file_w), fileName));
-               }
-               else
-               {
-                       if (file_w->f_op && file_w->f_op->write)
-                       {
-                               file_w->f_pos = 0;
-                               eepAddr = 0x00;
-
-                               while (eepAddr <= 0xFE)
-                               {
-                                       RT28xx_EEPROM_READ16(pAdapter, eepAddr, eepValue);
-                                       sprintf(msg, "%08x = %04x\n", eepAddr , eepValue);
-
-                                       // write data to file
-                                       file_w->f_op->write(file_w, msg, strlen(msg), &file_w->f_pos);
-
-                                       printk("%s", msg);
-                                       eepAddr += 2;
-                               }
-                               sprintf(msg, "\nDump all EEPROM values to %s\n", fileName);
-                       }
-                       filp_close(file_w, NULL);
-               }
-               set_fs(orig_fs);
-       }
-       if(strlen(msg) == 1)
-               sprintf(msg+strlen(msg), "===>Error command format!");
-
-
-       // Copy the information into the user buffer
-       wrq->u.data.length = strlen(msg);
-       Status = copy_to_user(wrq->u.data.pointer, msg, wrq->u.data.length);
-
-       DBGPRINT(RT_DEBUG_TRACE, ("<==RTMPIoctlE2PROM\n"));
-}
-#ifdef RT30xx
-/*
-    ==========================================================================
-    Description:
-        Read / Write RF register
-Arguments:
-    pAdapter                    Pointer to our adapter
-    wrq                         Pointer to the ioctl argument
-
-    Return Value:
-        None
-
-    Note:
-        Usage:
-               1.) iwpriv ra0 rf                ==> read all RF registers
-               2.) iwpriv ra0 rf 1              ==> read RF where RegID=1
-               3.) iwpriv ra0 rf 1=10              ==> write RF R1=0x10
-    ==========================================================================
-*/
-VOID RTMPIoctlRF(
-       IN      PRTMP_ADAPTER   pAdapter,
-       IN      struct iwreq    *wrq)
-{
-       CHAR                            *this_char;
-       CHAR                            *value;
-       UCHAR                           regRF = 0;
-       CHAR                            msg[2048];
-       CHAR                            arg[255];
-       INT                                     rfId;
-       LONG                            rfValue;
-       int                                     Status;
-       BOOLEAN                         bIsPrintAllRF = FALSE;
-
-
-       memset(msg, 0x00, 2048);
-       if (wrq->u.data.length > 1) //No parameters.
-       {
-           Status = copy_from_user(arg, wrq->u.data.pointer, (wrq->u.data.length > 255) ? 255 : wrq->u.data.length);
-               sprintf(msg, "\n");
-
-           //Parsing Read or Write
-               this_char = arg;
-               if (!*this_char)
-                       goto next;
-
-               if ((value = strchr(this_char, '=')) != NULL)
-                       *value++ = 0;
-
-               if (!value || !*value)
-               { //Read
-                       if (sscanf(this_char, "%d", &(rfId)) == 1)
-                       {
-                               if (rfId <= 31)
-                               {
-                                       // In RT2860 ATE mode, we do not load 8051 firmware.
-                                            //We must access RF directly.
-                    // For RT2870 ATE mode, ATE_RF_IO_WRITE8(/READ8)_BY_REG_ID are redefined.
-                                       // according to Andy, Gary, David require.
-                                       // the command rf shall read rf register directly for dubug.
-                                       // BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, &regBBP);
-                                       RT30xxReadRFRegister(pAdapter, rfId, &regRF);
-
-                                       sprintf(msg+strlen(msg), "R%02d[0x%02x]:%02X  ", rfId, rfId*2, regRF);
-                               }
-                               else
-                               {//Invalid parametes, so default printk all RF
-                                       bIsPrintAllRF = TRUE;
-                                       goto next;
-                               }
-                       }
-                       else
-                       { //Invalid parametes, so default printk all RF
-                               bIsPrintAllRF = TRUE;
-                               goto next;
-                       }
-               }
-               else
-               { //Write
-                       if ((sscanf(this_char, "%d", &(rfId)) == 1) && (sscanf(value, "%lx", &(rfValue)) == 1))
-                       {
-                               if (rfId <= 31)
-                               {
-                                       // In RT2860 ATE mode, we do not load 8051 firmware.
-                                       // We should access RF registers directly.
-                    // For RT2870 ATE mode, ATE_RF_IO_WRITE8/READ8_BY_REG_ID are redefined.
-                                               {
-                                                       // according to Andy, Gary, David require.
-                                                       // the command RF shall read/write RF register directly for dubug.
-                                                       //BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, &regBBP);
-                                                       //BBP_IO_WRITE8_BY_REG_ID(pAdapter, (UCHAR)bbpId,(UCHAR) bbpValue);
-                                                       RT30xxReadRFRegister(pAdapter, rfId, &regRF);
-                                                       RT30xxWriteRFRegister(pAdapter, (UCHAR)rfId,(UCHAR) rfValue);
-                                                       //Read it back for showing
-                                                       //BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, &regBBP);
-                                                       RT30xxReadRFRegister(pAdapter, rfId, &regRF);
-                                                       sprintf(msg+strlen(msg), "R%02d[0x%02X]:%02X\n", rfId, rfId*2, regRF);
-                                               }
-                               }
-                               else
-                               {//Invalid parametes, so default printk all RF
-                                       bIsPrintAllRF = TRUE;
-                               }
-                       }
-                       else
-                       { //Invalid parametes, so default printk all RF
-                               bIsPrintAllRF = TRUE;
-                       }
-               }
-       }
-       else
-               bIsPrintAllRF = TRUE;
-next:
-       if (bIsPrintAllRF)
-       {
-               memset(msg, 0x00, 2048);
-               sprintf(msg, "\n");
-               for (rfId = 0; rfId <= 31; rfId++)
-               {
-                       // according to Andy, Gary, David require.
-                       // the command RF shall read/write RF register directly for dubug.
-                       RT30xxReadRFRegister(pAdapter, rfId, &regRF);
-                       sprintf(msg+strlen(msg), "%03d = %02X\n", rfId, regRF);
-               }
-               // Copy the information into the user buffer
-               DBGPRINT(RT_DEBUG_TRACE, ("strlen(msg)=%d\n", (UINT32)strlen(msg)));
-               wrq->u.data.length = strlen(msg);
-               if (copy_to_user(wrq->u.data.pointer, msg, wrq->u.data.length))
-               {
-                       DBGPRINT(RT_DEBUG_TRACE, ("%s: copy_to_user() fail\n", __func__));
-               }
-       }
-       else
-       {
-               if(strlen(msg) == 1)
-                       sprintf(msg+strlen(msg), "===>Error command format!");
-
-               DBGPRINT(RT_DEBUG_TRACE, ("copy to user [msg=%s]\n", msg));
-               // Copy the information into the user buffer
-               DBGPRINT(RT_DEBUG_TRACE, ("strlen(msg) =%d\n", (UINT32)strlen(msg)));
-
-               // Copy the information into the user buffer
-               wrq->u.data.length = strlen(msg);
-               Status = copy_to_user(wrq->u.data.pointer, msg, wrq->u.data.length);
-       }
-
-       DBGPRINT(RT_DEBUG_TRACE, ("<==RTMPIoctlRF\n\n"));
-}
-#endif // RT30xx //
-#endif // DBG //
-
-
-
-
-INT Set_TGnWifiTest_Proc(
-    IN  PRTMP_ADAPTER   pAd,
-    IN  PUCHAR          arg)
-{
-    if (simple_strtol(arg, 0, 10) == 0)
-        pAd->StaCfg.bTGnWifiTest = FALSE;
-    else
-        pAd->StaCfg.bTGnWifiTest = TRUE;
-
-    DBGPRINT(RT_DEBUG_TRACE, ("IF Set_TGnWifiTest_Proc::(bTGnWifiTest=%d)\n", pAd->StaCfg.bTGnWifiTest));
-       return TRUE;
-}
-
-INT Set_LongRetryLimit_Proc(
-       IN      PRTMP_ADAPTER   pAdapter,
-       IN      PUCHAR                  arg)
-{
-       TX_RTY_CFG_STRUC        tx_rty_cfg;
-       UCHAR                           LongRetryLimit = (UCHAR)simple_strtol(arg, 0, 10);
-
-       RTMP_IO_READ32(pAdapter, TX_RTY_CFG, &tx_rty_cfg.word);
-       tx_rty_cfg.field.LongRtyLimit = LongRetryLimit;
-       RTMP_IO_WRITE32(pAdapter, TX_RTY_CFG, tx_rty_cfg.word);
-       DBGPRINT(RT_DEBUG_TRACE, ("IF Set_LongRetryLimit_Proc::(tx_rty_cfg=0x%x)\n", tx_rty_cfg.word));
-       return TRUE;
-}
-
-INT Set_ShortRetryLimit_Proc(
-       IN      PRTMP_ADAPTER   pAdapter,
-       IN      PUCHAR                  arg)
-{
-       TX_RTY_CFG_STRUC        tx_rty_cfg;
-       UCHAR                           ShortRetryLimit = (UCHAR)simple_strtol(arg, 0, 10);
-
-       RTMP_IO_READ32(pAdapter, TX_RTY_CFG, &tx_rty_cfg.word);
-       tx_rty_cfg.field.ShortRtyLimit = ShortRetryLimit;
-       RTMP_IO_WRITE32(pAdapter, TX_RTY_CFG, tx_rty_cfg.word);
-       DBGPRINT(RT_DEBUG_TRACE, ("IF Set_ShortRetryLimit_Proc::(tx_rty_cfg=0x%x)\n", tx_rty_cfg.word));
-       return TRUE;
-}
+#include "../rt2870/sta_ioctl.c"
index 7006e389e3233afd52d0e3e6fbe019eebbb4b70a..94bb232794007ff92e8f948f36358460f0c994d0 100644 (file)
@@ -1,327 +1 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify  *
- * it under the terms of the GNU General Public License as published by  *
- * the Free Software Foundation; either version 2 of the License, or     *
- * (at your option) any later version.                                   *
- *                                                                       *
- * 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.                          *
- *                                                                       *
- * You should have received a copy of the GNU General Public License     *
- * along with this program; if not, write to the                         *
- * Free Software Foundation, Inc.,                                       *
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- *                                                                       *
- *************************************************************************
-
-       Module Name:
-       wpa.h
-
-       Abstract:
-
-       Revision History:
-       Who                     When                    What
-       --------        ----------              ----------------------------------------------
-       Name            Date                    Modification logs
-*/
-
-#ifndef        __WPA_H__
-#define        __WPA_H__
-
-// EAPOL Key descripter frame format related length
-#define LEN_KEY_DESC_NONCE                     32
-#define LEN_KEY_DESC_IV                                16
-#define LEN_KEY_DESC_RSC                       8
-#define LEN_KEY_DESC_ID                                8
-#define LEN_KEY_DESC_REPLAY                    8
-#define LEN_KEY_DESC_MIC                       16
-
-// The length is the EAPoL-Key frame except key data field.
-// Please refer to 802.11i-2004 ,Figure 43u in p.78
-#define LEN_EAPOL_KEY_MSG                      (sizeof(KEY_DESCRIPTER) - MAX_LEN_OF_RSNIE)
-
-// EAP Code Type.
-#define EAP_CODE_REQUEST       1
-#define EAP_CODE_RESPONSE      2
-#define EAP_CODE_SUCCESS    3
-#define EAP_CODE_FAILURE    4
-
-// EAPOL frame Protocol Version
-#define        EAPOL_VER                                       1
-#define        EAPOL_VER2                                      2
-
-// EAPOL-KEY Descriptor Type
-#define        WPA1_KEY_DESC                           0xfe
-#define WPA2_KEY_DESC               0x02
-
-// Key Descriptor Version of Key Information
-#define        DESC_TYPE_TKIP                          1
-#define        DESC_TYPE_AES                           2
-#define DESC_TYPE_MESH                         3
-
-#define LEN_MSG1_2WAY               0x7f
-#define MAX_LEN_OF_EAP_HS           256
-
-#define LEN_MASTER_KEY                         32
-
-// EAPOL EK, MK
-#define LEN_EAP_EK                                     16
-#define LEN_EAP_MICK                           16
-#define LEN_EAP_KEY                                    ((LEN_EAP_EK)+(LEN_EAP_MICK))
-// TKIP key related
-#define LEN_PMKID                                      16
-#define LEN_TKIP_EK                                    16
-#define LEN_TKIP_RXMICK                                8
-#define LEN_TKIP_TXMICK                                8
-#define LEN_AES_EK                                     16
-#define LEN_AES_KEY                                    LEN_AES_EK
-#define LEN_TKIP_KEY                           ((LEN_TKIP_EK)+(LEN_TKIP_RXMICK)+(LEN_TKIP_TXMICK))
-#define TKIP_AP_TXMICK_OFFSET          ((LEN_EAP_KEY)+(LEN_TKIP_EK))
-#define TKIP_AP_RXMICK_OFFSET          (TKIP_AP_TXMICK_OFFSET+LEN_TKIP_TXMICK)
-#define TKIP_GTK_LENGTH                                ((LEN_TKIP_EK)+(LEN_TKIP_RXMICK)+(LEN_TKIP_TXMICK))
-#define LEN_PTK                                                ((LEN_EAP_KEY)+(LEN_TKIP_KEY))
-
-// RSN IE Length definition
-#define MAX_LEN_OF_RSNIE               90
-#define MIN_LEN_OF_RSNIE               8
-
-//EAP Packet Type
-#define        EAPPacket               0
-#define        EAPOLStart              1
-#define        EAPOLLogoff             2
-#define        EAPOLKey                3
-#define        EAPOLASFAlert   4
-#define        EAPTtypeMax             5
-
-#define        EAPOL_MSG_INVALID       0
-#define        EAPOL_PAIR_MSG_1        1
-#define        EAPOL_PAIR_MSG_2        2
-#define        EAPOL_PAIR_MSG_3        3
-#define        EAPOL_PAIR_MSG_4        4
-#define        EAPOL_GROUP_MSG_1       5
-#define        EAPOL_GROUP_MSG_2       6
-
-#define PAIRWISEKEY                                    1
-#define GROUPKEY                                       0
-
-// Retry timer counter initial value
-#define PEER_MSG1_RETRY_TIMER_CTR           0
-#define PEER_MSG3_RETRY_TIMER_CTR           10
-#define GROUP_MSG1_RETRY_TIMER_CTR          20
-
-
-#define EAPOL_START_DISABLE                                    0
-#define EAPOL_START_PSK                                                1
-#define EAPOL_START_1X                                         2
-
-#define MIX_CIPHER_WPA_TKIP_ON(x)       (((x) & 0x08) != 0)
-#define MIX_CIPHER_WPA_AES_ON(x)        (((x) & 0x04) != 0)
-#define MIX_CIPHER_WPA2_TKIP_ON(x)      (((x) & 0x02) != 0)
-#define MIX_CIPHER_WPA2_AES_ON(x)       (((x) & 0x01) != 0)
-
-#define ROUND_UP(__x, __y) \
-       (((ULONG)((__x)+((__y)-1))) & ((ULONG)~((__y)-1)))
-
-#define        ADD_ONE_To_64BIT_VAR(_V)                \
-{                                                                              \
-       UCHAR   cnt = LEN_KEY_DESC_REPLAY;      \
-       do                                                                      \
-       {                                                                       \
-               cnt--;                                                  \
-               _V[cnt]++;                                              \
-               if (cnt == 0)                                   \
-                       break;                                          \
-       }while (_V[cnt] == 0);                          \
-}
-
-#define IS_WPA_CAPABILITY(a)       (((a) >= Ndis802_11AuthModeWPA) && ((a) <= Ndis802_11AuthModeWPA1PSKWPA2PSK))
-
-// EAPOL Key Information definition within Key descriptor format
-typedef        struct PACKED _KEY_INFO
-{
-       UCHAR   KeyMic:1;
-       UCHAR   Secure:1;
-       UCHAR   Error:1;
-       UCHAR   Request:1;
-       UCHAR   EKD_DL:1;       // EKD for AP; DL for STA
-       UCHAR   Rsvd:3;
-       UCHAR   KeyDescVer:3;
-       UCHAR   KeyType:1;
-       UCHAR   KeyIndex:2;
-       UCHAR   Install:1;
-       UCHAR   KeyAck:1;
-}      KEY_INFO, *PKEY_INFO;
-
-// EAPOL Key descriptor format
-typedef        struct PACKED _KEY_DESCRIPTER
-{
-       UCHAR           Type;
-       KEY_INFO        KeyInfo;
-       UCHAR           KeyLength[2];
-       UCHAR           ReplayCounter[LEN_KEY_DESC_REPLAY];
-       UCHAR           KeyNonce[LEN_KEY_DESC_NONCE];
-       UCHAR           KeyIv[LEN_KEY_DESC_IV];
-       UCHAR           KeyRsc[LEN_KEY_DESC_RSC];
-       UCHAR           KeyId[LEN_KEY_DESC_ID];
-       UCHAR           KeyMic[LEN_KEY_DESC_MIC];
-       UCHAR           KeyDataLen[2];
-       UCHAR           KeyData[MAX_LEN_OF_RSNIE];
-}      KEY_DESCRIPTER, *PKEY_DESCRIPTER;
-
-typedef        struct PACKED _EAPOL_PACKET
-{
-       UCHAR                           ProVer;
-       UCHAR                           ProType;
-       UCHAR                           Body_Len[2];
-       KEY_DESCRIPTER          KeyDesc;
-}      EAPOL_PACKET, *PEAPOL_PACKET;
-
-//802.11i D10 page 83
-typedef struct PACKED _GTK_ENCAP
-{
-    UCHAR               Kid:2;
-    UCHAR               tx:1;
-    UCHAR               rsv:5;
-    UCHAR               rsv1;
-    UCHAR               GTK[TKIP_GTK_LENGTH];
-}   GTK_ENCAP, *PGTK_ENCAP;
-
-typedef struct PACKED _KDE_ENCAP
-{
-    UCHAR               Type;
-    UCHAR               Len;
-    UCHAR               OUI[3];
-    UCHAR               DataType;
-    GTK_ENCAP      GTKEncap;
-}   KDE_ENCAP, *PKDE_ENCAP;
-
-// For WPA1
-typedef struct PACKED _RSNIE {
-    UCHAR   oui[4];
-    USHORT  version;
-    UCHAR   mcast[4];
-    USHORT  ucount;
-    struct PACKED {
-        UCHAR oui[4];
-    }ucast[1];
-} RSNIE, *PRSNIE;
-
-// For WPA2
-typedef struct PACKED _RSNIE2 {
-    USHORT  version;
-    UCHAR   mcast[4];
-    USHORT  ucount;
-    struct PACKED {
-        UCHAR oui[4];
-    }ucast[1];
-} RSNIE2, *PRSNIE2;
-
-// AKM Suite
-typedef struct PACKED _RSNIE_AUTH {
-    USHORT acount;
-    struct PACKED {
-        UCHAR oui[4];
-    }auth[1];
-} RSNIE_AUTH,*PRSNIE_AUTH;
-
-typedef        union PACKED _RSN_CAPABILITIES  {
-       struct  PACKED {
-        USHORT         PreAuth:1;
-               USHORT          No_Pairwise:1;
-               USHORT          PTKSA_R_Counter:2;
-               USHORT          GTKSA_R_Counter:2;
-               USHORT          Rsvd:10;
-       }       field;
-       USHORT                  word;
-}      RSN_CAPABILITIES, *PRSN_CAPABILITIES;
-
-typedef struct PACKED _EAP_HDR {
-    UCHAR   ProVer;
-    UCHAR   ProType;
-    UCHAR   Body_Len[2];
-    UCHAR   code;
-    UCHAR   identifier;
-    UCHAR   length[2]; // including code and identifier, followed by length-2 octets of data
-} EAP_HDR, *PEAP_HDR;
-
-// For supplicant state machine states. 802.11i Draft 4.1, p. 97
-// We simplified it
-typedef        enum    _WpaState
-{
-       SS_NOTUSE,                              // 0
-       SS_START,                               // 1
-       SS_WAIT_MSG_3,                  // 2
-       SS_WAIT_GROUP,                  // 3
-       SS_FINISH,                      // 4
-       SS_KEYUPDATE,                   // 5
-}      WPA_STATE;
-
-//
-//     The definition of the cipher combination
-//
-//      bit3   bit2  bit1   bit0
-//     +------------+------------+
-//     |         WPA    |         WPA2   |
-//     +------+-----+------+-----+
-//     | TKIP | AES | TKIP | AES |
-//     |       0  |  1  |   1  |  0  | -> 0x06
-//     |       0  |  1  |   1  |  1  | -> 0x07
-//     |       1  |  0  |   0  |  1  | -> 0x09
-//     |       1  |  0  |   1  |  1  | -> 0x0B
-//     |       1  |  1  |   0  |  1  | -> 0x0D
-//     |       1  |  1  |   1  |  0  | -> 0x0E
-//     |       1  |  1  |   1  |  1  | -> 0x0F
-//     +------+-----+------+-----+
-//
-typedef        enum    _WpaMixPairCipher
-{
-       MIX_CIPHER_NOTUSE                       = 0x00,
-       WPA_NONE_WPA2_TKIPAES           = 0x03,         // WPA2-TKIPAES
-       WPA_AES_WPA2_TKIP                       = 0x06,
-       WPA_AES_WPA2_TKIPAES            = 0x07,
-       WPA_TKIP_WPA2_AES                       = 0x09,
-       WPA_TKIP_WPA2_TKIPAES           = 0x0B,
-       WPA_TKIPAES_WPA2_NONE           = 0x0C,         // WPA-TKIPAES
-       WPA_TKIPAES_WPA2_AES            = 0x0D,
-       WPA_TKIPAES_WPA2_TKIP           = 0x0E,
-       WPA_TKIPAES_WPA2_TKIPAES        = 0x0F,
-}      WPA_MIX_PAIR_CIPHER;
-
-typedef struct PACKED _RSN_IE_HEADER_STRUCT    {
-       UCHAR           Eid;
-       UCHAR           Length;
-       USHORT          Version;        // Little endian format
-}      RSN_IE_HEADER_STRUCT, *PRSN_IE_HEADER_STRUCT;
-
-// Cipher suite selector types
-typedef struct PACKED _CIPHER_SUITE_STRUCT     {
-       UCHAR           Oui[3];
-       UCHAR           Type;
-}      CIPHER_SUITE_STRUCT, *PCIPHER_SUITE_STRUCT;
-
-// Authentication and Key Management suite selector
-typedef struct PACKED _AKM_SUITE_STRUCT        {
-       UCHAR           Oui[3];
-       UCHAR           Type;
-}      AKM_SUITE_STRUCT, *PAKM_SUITE_STRUCT;
-
-// RSN capability
-typedef struct PACKED _RSN_CAPABILITY  {
-       USHORT          Rsv:10;
-       USHORT          GTKSAReplayCnt:2;
-       USHORT          PTKSAReplayCnt:2;
-       USHORT          NoPairwise:1;
-       USHORT          PreAuth:1;
-}      RSN_CAPABILITY, *PRSN_CAPABILITY;
-
-#endif
+#include "../rt2870/wpa.h"