These changes are the raw update to linux-4.4.6-rt14. Kernel sources
[kvmfornfv.git] / kernel / drivers / staging / vt6655 / device_main.c
index 376e4a0..fefbf82 100644 (file)
  *
  *   vt6655_probe - module initial (insmod) driver entry
  *   vt6655_remove - module remove entry
- *   vt6655_init_info - device structure resource allocation function
  *   device_free_info - device structure resource free function
- *   device_get_pci_info - get allocated pci io/mem resource
  *   device_print_info - print out resource
- *   device_intr - interrupt handle function
  *   device_rx_srv - rx service function
  *   device_alloc_rx_buf - rx buffer pre-allocated function
  *   device_free_tx_buf - free tx buffer function
@@ -129,113 +126,84 @@ DEVICE_PARAM(BasebandType, "baseband type");
 /*
  * Static vars definitions
  */
-static CHIP_INFO chip_info_table[] = {
-       { VT3253,       "VIA Networking Solomon-A/B/G Wireless LAN Adapter ",
-         256, 1,     DEVICE_FLAGS_IP_ALIGN|DEVICE_FLAGS_TX_ALIGN },
-       {0, NULL}
-};
-
 static const struct pci_device_id vt6655_pci_id_table[] = {
-       { PCI_VDEVICE(VIA, 0x3253), (kernel_ulong_t)chip_info_table},
+       { PCI_VDEVICE(VIA, 0x3253) },
        { 0, }
 };
 
 /*---------------------  Static Functions  --------------------------*/
 
 static int  vt6655_probe(struct pci_dev *pcid, const struct pci_device_id *ent);
-static void vt6655_init_info(struct pci_dev *pcid,
-                            struct vnt_private **ppDevice, PCHIP_INFO);
-static void device_free_info(struct vnt_private *pDevice);
-static bool device_get_pci_info(struct vnt_private *, struct pci_dev *pcid);
-static void device_print_info(struct vnt_private *pDevice);
-static  irqreturn_t  device_intr(int irq,  void *dev_instance);
-
-#ifdef CONFIG_PM
-static int device_notify_reboot(struct notifier_block *, unsigned long event, void *ptr);
-static struct notifier_block device_notifier = {
-       .notifier_call = device_notify_reboot,
-       .next = NULL,
-       .priority = 0,
-};
-#endif
-
-static void device_init_rd0_ring(struct vnt_private *pDevice);
-static void device_init_rd1_ring(struct vnt_private *pDevice);
-static void device_init_td0_ring(struct vnt_private *pDevice);
-static void device_init_td1_ring(struct vnt_private *pDevice);
-
-static int  device_rx_srv(struct vnt_private *pDevice, unsigned int uIdx);
-static int  device_tx_srv(struct vnt_private *pDevice, unsigned int uIdx);
-static bool device_alloc_rx_buf(struct vnt_private *pDevice, PSRxDesc pDesc);
-static void device_init_registers(struct vnt_private *pDevice);
-static void device_free_tx_buf(struct vnt_private *pDevice, PSTxDesc pDesc);
-static void device_free_td0_ring(struct vnt_private *pDevice);
-static void device_free_td1_ring(struct vnt_private *pDevice);
-static void device_free_rd0_ring(struct vnt_private *pDevice);
-static void device_free_rd1_ring(struct vnt_private *pDevice);
-static void device_free_rings(struct vnt_private *pDevice);
+static void device_free_info(struct vnt_private *priv);
+static void device_print_info(struct vnt_private *priv);
+
+static void device_init_rd0_ring(struct vnt_private *priv);
+static void device_init_rd1_ring(struct vnt_private *priv);
+static void device_init_td0_ring(struct vnt_private *priv);
+static void device_init_td1_ring(struct vnt_private *priv);
+
+static int  device_rx_srv(struct vnt_private *priv, unsigned int idx);
+static int  device_tx_srv(struct vnt_private *priv, unsigned int idx);
+static bool device_alloc_rx_buf(struct vnt_private *, struct vnt_rx_desc *);
+static void device_init_registers(struct vnt_private *priv);
+static void device_free_tx_buf(struct vnt_private *, struct vnt_tx_desc *);
+static void device_free_td0_ring(struct vnt_private *priv);
+static void device_free_td1_ring(struct vnt_private *priv);
+static void device_free_rd0_ring(struct vnt_private *priv);
+static void device_free_rd1_ring(struct vnt_private *priv);
+static void device_free_rings(struct vnt_private *priv);
 
 /*---------------------  Export Variables  --------------------------*/
 
 /*---------------------  Export Functions  --------------------------*/
 
-static char *get_chip_name(int chip_id)
-{
-       int i;
-
-       for (i = 0; chip_info_table[i].name != NULL; i++)
-               if (chip_info_table[i].chip_id == chip_id)
-                       break;
-       return chip_info_table[i].name;
-}
-
 static void vt6655_remove(struct pci_dev *pcid)
 {
-       struct vnt_private *pDevice = pci_get_drvdata(pcid);
+       struct vnt_private *priv = pci_get_drvdata(pcid);
 
-       if (pDevice == NULL)
+       if (priv == NULL)
                return;
-       device_free_info(pDevice);
+       device_free_info(priv);
 }
 
-static void device_get_options(struct vnt_private *pDevice)
+static void device_get_options(struct vnt_private *priv)
 {
-       POPTIONS pOpts = &(pDevice->sOpts);
+       struct vnt_options *opts = &priv->opts;
 
-       pOpts->nRxDescs0 = RX_DESC_DEF0;
-       pOpts->nRxDescs1 = RX_DESC_DEF1;
-       pOpts->nTxDescs[0] = TX_DESC_DEF0;
-       pOpts->nTxDescs[1] = TX_DESC_DEF1;
-       pOpts->int_works = INT_WORKS_DEF;
+       opts->rx_descs0 = RX_DESC_DEF0;
+       opts->rx_descs1 = RX_DESC_DEF1;
+       opts->tx_descs[0] = TX_DESC_DEF0;
+       opts->tx_descs[1] = TX_DESC_DEF1;
+       opts->int_works = INT_WORKS_DEF;
 
-       pOpts->short_retry = SHORT_RETRY_DEF;
-       pOpts->long_retry = LONG_RETRY_DEF;
-       pOpts->bbp_type = BBP_TYPE_DEF;
+       opts->short_retry = SHORT_RETRY_DEF;
+       opts->long_retry = LONG_RETRY_DEF;
+       opts->bbp_type = BBP_TYPE_DEF;
 }
 
 static void
-device_set_options(struct vnt_private *pDevice)
+device_set_options(struct vnt_private *priv)
 {
-       pDevice->byShortRetryLimit = pDevice->sOpts.short_retry;
-       pDevice->byLongRetryLimit = pDevice->sOpts.long_retry;
-       pDevice->byBBType = pDevice->sOpts.bbp_type;
-       pDevice->byPacketType = pDevice->byBBType;
-       pDevice->byAutoFBCtrl = AUTO_FB_0;
-       pDevice->bUpdateBBVGA = true;
-       pDevice->byPreambleType = 0;
-
-       pr_debug(" byShortRetryLimit= %d\n", (int)pDevice->byShortRetryLimit);
-       pr_debug(" byLongRetryLimit= %d\n", (int)pDevice->byLongRetryLimit);
-       pr_debug(" byPreambleType= %d\n", (int)pDevice->byPreambleType);
-       pr_debug(" byShortPreamble= %d\n", (int)pDevice->byShortPreamble);
-       pr_debug(" byBBType= %d\n", (int)pDevice->byBBType);
+       priv->byShortRetryLimit = priv->opts.short_retry;
+       priv->byLongRetryLimit = priv->opts.long_retry;
+       priv->byBBType = priv->opts.bbp_type;
+       priv->byPacketType = priv->byBBType;
+       priv->byAutoFBCtrl = AUTO_FB_0;
+       priv->bUpdateBBVGA = true;
+       priv->byPreambleType = 0;
+
+       pr_debug(" byShortRetryLimit= %d\n", (int)priv->byShortRetryLimit);
+       pr_debug(" byLongRetryLimit= %d\n", (int)priv->byLongRetryLimit);
+       pr_debug(" byPreambleType= %d\n", (int)priv->byPreambleType);
+       pr_debug(" byShortPreamble= %d\n", (int)priv->byShortPreamble);
+       pr_debug(" byBBType= %d\n", (int)priv->byBBType);
 }
 
 /*
  * Initialisation of MAC & BBP registers
  */
 
-static void device_init_registers(struct vnt_private *pDevice)
+static void device_init_registers(struct vnt_private *priv)
 {
        unsigned long flags;
        unsigned int ii;
@@ -243,48 +211,45 @@ static void device_init_registers(struct vnt_private *pDevice)
        unsigned char byCCKPwrdBm = 0;
        unsigned char byOFDMPwrdBm = 0;
 
-       MACbShutdown(pDevice->PortOffset);
-       BBvSoftwareReset(pDevice);
+       MACbShutdown(priv->PortOffset);
+       BBvSoftwareReset(priv);
 
        /* Do MACbSoftwareReset in MACvInitialize */
-       MACbSoftwareReset(pDevice->PortOffset);
+       MACbSoftwareReset(priv->PortOffset);
 
-       pDevice->bAES = false;
+       priv->bAES = false;
 
        /* Only used in 11g type, sync with ERP IE */
-       pDevice->bProtectMode = false;
-
-       pDevice->bNonERPPresent = false;
-       pDevice->bBarkerPreambleMd = false;
-       pDevice->wCurrentRate = RATE_1M;
-       pDevice->byTopOFDMBasicRate = RATE_24M;
-       pDevice->byTopCCKBasicRate = RATE_1M;
+       priv->bProtectMode = false;
 
-       /* Target to IF pin while programming to RF chip. */
-       pDevice->byRevId = 0;
+       priv->bNonERPPresent = false;
+       priv->bBarkerPreambleMd = false;
+       priv->wCurrentRate = RATE_1M;
+       priv->byTopOFDMBasicRate = RATE_24M;
+       priv->byTopCCKBasicRate = RATE_1M;
 
        /* init MAC */
-       MACvInitialize(pDevice->PortOffset);
+       MACvInitialize(priv->PortOffset);
 
        /* Get Local ID */
-       VNSvInPortB(pDevice->PortOffset + MAC_REG_LOCALID, &pDevice->byLocalID);
+       VNSvInPortB(priv->PortOffset + MAC_REG_LOCALID, &priv->byLocalID);
 
-       spin_lock_irqsave(&pDevice->lock, flags);
+       spin_lock_irqsave(&priv->lock, flags);
 
-       SROMvReadAllContents(pDevice->PortOffset, pDevice->abyEEPROM);
+       SROMvReadAllContents(priv->PortOffset, priv->abyEEPROM);
 
-       spin_unlock_irqrestore(&pDevice->lock, flags);
+       spin_unlock_irqrestore(&priv->lock, flags);
 
        /* Get Channel range */
-       pDevice->byMinChannel = 1;
-       pDevice->byMaxChannel = CB_MAX_CHANNEL;
+       priv->byMinChannel = 1;
+       priv->byMaxChannel = CB_MAX_CHANNEL;
 
        /* Get Antena */
-       byValue = SROMbyReadEmbedded(pDevice->PortOffset, EEP_OFS_ANTENNA);
+       byValue = SROMbyReadEmbedded(priv->PortOffset, EEP_OFS_ANTENNA);
        if (byValue & EEP_ANTINV)
-               pDevice->bTxRxAntInv = true;
+               priv->bTxRxAntInv = true;
        else
-               pDevice->bTxRxAntInv = false;
+               priv->bTxRxAntInv = false;
 
        byValue &= (EEP_ANTENNA_AUX | EEP_ANTENNA_MAIN);
        /* if not set default is All */
@@ -292,560 +257,498 @@ static void device_init_registers(struct vnt_private *pDevice)
                byValue = (EEP_ANTENNA_AUX | EEP_ANTENNA_MAIN);
 
        if (byValue == (EEP_ANTENNA_AUX | EEP_ANTENNA_MAIN)) {
-               pDevice->byAntennaCount = 2;
-               pDevice->byTxAntennaMode = ANT_B;
-               pDevice->dwTxAntennaSel = 1;
-               pDevice->dwRxAntennaSel = 1;
+               priv->byAntennaCount = 2;
+               priv->byTxAntennaMode = ANT_B;
+               priv->dwTxAntennaSel = 1;
+               priv->dwRxAntennaSel = 1;
 
-               if (pDevice->bTxRxAntInv)
-                       pDevice->byRxAntennaMode = ANT_A;
+               if (priv->bTxRxAntInv)
+                       priv->byRxAntennaMode = ANT_A;
                else
-                       pDevice->byRxAntennaMode = ANT_B;
+                       priv->byRxAntennaMode = ANT_B;
        } else  {
-               pDevice->byAntennaCount = 1;
-               pDevice->dwTxAntennaSel = 0;
-               pDevice->dwRxAntennaSel = 0;
+               priv->byAntennaCount = 1;
+               priv->dwTxAntennaSel = 0;
+               priv->dwRxAntennaSel = 0;
 
                if (byValue & EEP_ANTENNA_AUX) {
-                       pDevice->byTxAntennaMode = ANT_A;
+                       priv->byTxAntennaMode = ANT_A;
 
-                       if (pDevice->bTxRxAntInv)
-                               pDevice->byRxAntennaMode = ANT_B;
+                       if (priv->bTxRxAntInv)
+                               priv->byRxAntennaMode = ANT_B;
                        else
-                               pDevice->byRxAntennaMode = ANT_A;
+                               priv->byRxAntennaMode = ANT_A;
                } else {
-                       pDevice->byTxAntennaMode = ANT_B;
+                       priv->byTxAntennaMode = ANT_B;
 
-                       if (pDevice->bTxRxAntInv)
-                               pDevice->byRxAntennaMode = ANT_A;
+                       if (priv->bTxRxAntInv)
+                               priv->byRxAntennaMode = ANT_A;
                        else
-                               pDevice->byRxAntennaMode = ANT_B;
+                               priv->byRxAntennaMode = ANT_B;
                }
        }
 
        /* Set initial antenna mode */
-       BBvSetTxAntennaMode(pDevice, pDevice->byTxAntennaMode);
-       BBvSetRxAntennaMode(pDevice, pDevice->byRxAntennaMode);
+       BBvSetTxAntennaMode(priv, priv->byTxAntennaMode);
+       BBvSetRxAntennaMode(priv, priv->byRxAntennaMode);
 
        /* zonetype initial */
-       pDevice->byOriginalZonetype = pDevice->abyEEPROM[EEP_OFS_ZONETYPE];
+       priv->byOriginalZonetype = priv->abyEEPROM[EEP_OFS_ZONETYPE];
 
-       if (!pDevice->bZoneRegExist)
-               pDevice->byZoneType = pDevice->abyEEPROM[EEP_OFS_ZONETYPE];
+       if (!priv->bZoneRegExist)
+               priv->byZoneType = priv->abyEEPROM[EEP_OFS_ZONETYPE];
 
-       pr_debug("pDevice->byZoneType = %x\n", pDevice->byZoneType);
+       pr_debug("priv->byZoneType = %x\n", priv->byZoneType);
 
        /* Init RF module */
-       RFbInit(pDevice);
+       RFbInit(priv);
 
        /* Get Desire Power Value */
-       pDevice->byCurPwr = 0xFF;
-       pDevice->byCCKPwr = SROMbyReadEmbedded(pDevice->PortOffset, EEP_OFS_PWR_CCK);
-       pDevice->byOFDMPwrG = SROMbyReadEmbedded(pDevice->PortOffset, EEP_OFS_PWR_OFDMG);
+       priv->byCurPwr = 0xFF;
+       priv->byCCKPwr = SROMbyReadEmbedded(priv->PortOffset, EEP_OFS_PWR_CCK);
+       priv->byOFDMPwrG = SROMbyReadEmbedded(priv->PortOffset, EEP_OFS_PWR_OFDMG);
 
        /* Load power Table */
        for (ii = 0; ii < CB_MAX_CHANNEL_24G; ii++) {
-               pDevice->abyCCKPwrTbl[ii + 1] =
-                       SROMbyReadEmbedded(pDevice->PortOffset,
+               priv->abyCCKPwrTbl[ii + 1] =
+                       SROMbyReadEmbedded(priv->PortOffset,
                                           (unsigned char)(ii + EEP_OFS_CCK_PWR_TBL));
-               if (pDevice->abyCCKPwrTbl[ii + 1] == 0)
-                       pDevice->abyCCKPwrTbl[ii+1] = pDevice->byCCKPwr;
+               if (priv->abyCCKPwrTbl[ii + 1] == 0)
+                       priv->abyCCKPwrTbl[ii+1] = priv->byCCKPwr;
 
-               pDevice->abyOFDMPwrTbl[ii + 1] =
-                       SROMbyReadEmbedded(pDevice->PortOffset,
+               priv->abyOFDMPwrTbl[ii + 1] =
+                       SROMbyReadEmbedded(priv->PortOffset,
                                           (unsigned char)(ii + EEP_OFS_OFDM_PWR_TBL));
-               if (pDevice->abyOFDMPwrTbl[ii + 1] == 0)
-                       pDevice->abyOFDMPwrTbl[ii + 1] = pDevice->byOFDMPwrG;
+               if (priv->abyOFDMPwrTbl[ii + 1] == 0)
+                       priv->abyOFDMPwrTbl[ii + 1] = priv->byOFDMPwrG;
 
-               pDevice->abyCCKDefaultPwr[ii + 1] = byCCKPwrdBm;
-               pDevice->abyOFDMDefaultPwr[ii + 1] = byOFDMPwrdBm;
+               priv->abyCCKDefaultPwr[ii + 1] = byCCKPwrdBm;
+               priv->abyOFDMDefaultPwr[ii + 1] = byOFDMPwrdBm;
        }
 
        /* recover 12,13 ,14channel for EUROPE by 11 channel */
        for (ii = 11; ii < 14; ii++) {
-               pDevice->abyCCKPwrTbl[ii] = pDevice->abyCCKPwrTbl[10];
-               pDevice->abyOFDMPwrTbl[ii] = pDevice->abyOFDMPwrTbl[10];
+               priv->abyCCKPwrTbl[ii] = priv->abyCCKPwrTbl[10];
+               priv->abyOFDMPwrTbl[ii] = priv->abyOFDMPwrTbl[10];
        }
 
        /* Load OFDM A Power Table */
        for (ii = 0; ii < CB_MAX_CHANNEL_5G; ii++) {
-               pDevice->abyOFDMPwrTbl[ii + CB_MAX_CHANNEL_24G + 1] =
-                       SROMbyReadEmbedded(pDevice->PortOffset,
+               priv->abyOFDMPwrTbl[ii + CB_MAX_CHANNEL_24G + 1] =
+                       SROMbyReadEmbedded(priv->PortOffset,
                                           (unsigned char)(ii + EEP_OFS_OFDMA_PWR_TBL));
 
-               pDevice->abyOFDMDefaultPwr[ii + CB_MAX_CHANNEL_24G + 1] =
-                       SROMbyReadEmbedded(pDevice->PortOffset,
+               priv->abyOFDMDefaultPwr[ii + CB_MAX_CHANNEL_24G + 1] =
+                       SROMbyReadEmbedded(priv->PortOffset,
                                           (unsigned char)(ii + EEP_OFS_OFDMA_PWR_dBm));
        }
 
-       if (pDevice->byLocalID > REV_ID_VT3253_B1) {
-               MACvSelectPage1(pDevice->PortOffset);
+       if (priv->byLocalID > REV_ID_VT3253_B1) {
+               MACvSelectPage1(priv->PortOffset);
 
-               VNSvOutPortB(pDevice->PortOffset + MAC_REG_MSRCTL + 1,
+               VNSvOutPortB(priv->PortOffset + MAC_REG_MSRCTL + 1,
                             (MSRCTL1_TXPWR | MSRCTL1_CSAPAREN));
 
-               MACvSelectPage0(pDevice->PortOffset);
+               MACvSelectPage0(priv->PortOffset);
        }
 
        /* use relative tx timeout and 802.11i D4 */
-       MACvWordRegBitsOn(pDevice->PortOffset,
+       MACvWordRegBitsOn(priv->PortOffset,
                          MAC_REG_CFG, (CFG_TKIPOPT | CFG_NOTXTIMEOUT));
 
        /* set performance parameter by registry */
-       MACvSetShortRetryLimit(pDevice->PortOffset, pDevice->byShortRetryLimit);
-       MACvSetLongRetryLimit(pDevice->PortOffset, pDevice->byLongRetryLimit);
+       MACvSetShortRetryLimit(priv->PortOffset, priv->byShortRetryLimit);
+       MACvSetLongRetryLimit(priv->PortOffset, priv->byLongRetryLimit);
 
        /* reset TSF counter */
-       VNSvOutPortB(pDevice->PortOffset + MAC_REG_TFTCTL, TFTCTL_TSFCNTRST);
+       VNSvOutPortB(priv->PortOffset + MAC_REG_TFTCTL, TFTCTL_TSFCNTRST);
        /* enable TSF counter */
-       VNSvOutPortB(pDevice->PortOffset + MAC_REG_TFTCTL, TFTCTL_TSFCNTREN);
+       VNSvOutPortB(priv->PortOffset + MAC_REG_TFTCTL, TFTCTL_TSFCNTREN);
 
        /* initialize BBP registers */
-       BBbVT3253Init(pDevice);
+       BBbVT3253Init(priv);
 
-       if (pDevice->bUpdateBBVGA) {
-               pDevice->byBBVGACurrent = pDevice->abyBBVGA[0];
-               pDevice->byBBVGANew = pDevice->byBBVGACurrent;
-               BBvSetVGAGainOffset(pDevice, pDevice->abyBBVGA[0]);
+       if (priv->bUpdateBBVGA) {
+               priv->byBBVGACurrent = priv->abyBBVGA[0];
+               priv->byBBVGANew = priv->byBBVGACurrent;
+               BBvSetVGAGainOffset(priv, priv->abyBBVGA[0]);
        }
 
-       BBvSetRxAntennaMode(pDevice, pDevice->byRxAntennaMode);
-       BBvSetTxAntennaMode(pDevice, pDevice->byTxAntennaMode);
+       BBvSetRxAntennaMode(priv, priv->byRxAntennaMode);
+       BBvSetTxAntennaMode(priv, priv->byTxAntennaMode);
 
        /* Set BB and packet type at the same time. */
        /* Set Short Slot Time, xIFS, and RSPINF. */
-       pDevice->wCurrentRate = RATE_54M;
+       priv->wCurrentRate = RATE_54M;
 
-       pDevice->bRadioOff = false;
+       priv->bRadioOff = false;
 
-       pDevice->byRadioCtl = SROMbyReadEmbedded(pDevice->PortOffset,
+       priv->byRadioCtl = SROMbyReadEmbedded(priv->PortOffset,
                                                 EEP_OFS_RADIOCTL);
-       pDevice->bHWRadioOff = false;
+       priv->bHWRadioOff = false;
 
-       if (pDevice->byRadioCtl & EEP_RADIOCTL_ENABLE) {
+       if (priv->byRadioCtl & EEP_RADIOCTL_ENABLE) {
                /* Get GPIO */
-               MACvGPIOIn(pDevice->PortOffset, &pDevice->byGPIO);
+               MACvGPIOIn(priv->PortOffset, &priv->byGPIO);
 
-               if (((pDevice->byGPIO & GPIO0_DATA) &&
-                    !(pDevice->byRadioCtl & EEP_RADIOCTL_INV)) ||
-                    (!(pDevice->byGPIO & GPIO0_DATA) &&
-                    (pDevice->byRadioCtl & EEP_RADIOCTL_INV)))
-                       pDevice->bHWRadioOff = true;
+               if (((priv->byGPIO & GPIO0_DATA) &&
+                    !(priv->byRadioCtl & EEP_RADIOCTL_INV)) ||
+                    (!(priv->byGPIO & GPIO0_DATA) &&
+                    (priv->byRadioCtl & EEP_RADIOCTL_INV)))
+                       priv->bHWRadioOff = true;
        }
 
-       if (pDevice->bHWRadioOff || pDevice->bRadioControlOff)
-               CARDbRadioPowerOff(pDevice);
+       if (priv->bHWRadioOff || priv->bRadioControlOff)
+               CARDbRadioPowerOff(priv);
 
        /* get Permanent network address */
-       SROMvReadEtherAddress(pDevice->PortOffset, pDevice->abyCurrentNetAddr);
-       pr_debug("Network address = %pM\n", pDevice->abyCurrentNetAddr);
+       SROMvReadEtherAddress(priv->PortOffset, priv->abyCurrentNetAddr);
+       pr_debug("Network address = %pM\n", priv->abyCurrentNetAddr);
 
        /* reset Tx pointer */
-       CARDvSafeResetRx(pDevice);
+       CARDvSafeResetRx(priv);
        /* reset Rx pointer */
-       CARDvSafeResetTx(pDevice);
+       CARDvSafeResetTx(priv);
 
-       if (pDevice->byLocalID <= REV_ID_VT3253_A1)
-               MACvRegBitsOn(pDevice->PortOffset, MAC_REG_RCR, RCR_WPAERR);
+       if (priv->byLocalID <= REV_ID_VT3253_A1)
+               MACvRegBitsOn(priv->PortOffset, MAC_REG_RCR, RCR_WPAERR);
 
        /* Turn On Rx DMA */
-       MACvReceive0(pDevice->PortOffset);
-       MACvReceive1(pDevice->PortOffset);
+       MACvReceive0(priv->PortOffset);
+       MACvReceive1(priv->PortOffset);
 
        /* start the adapter */
-       MACvStart(pDevice->PortOffset);
+       MACvStart(priv->PortOffset);
 }
 
-static void device_print_info(struct vnt_private *pDevice)
+static void device_print_info(struct vnt_private *priv)
 {
-       dev_info(&pDevice->pcid->dev, "%s\n", get_chip_name(pDevice->chip_id));
-
-       dev_info(&pDevice->pcid->dev, "MAC=%pM IO=0x%lx Mem=0x%lx IRQ=%d\n",
-                pDevice->abyCurrentNetAddr, (unsigned long)pDevice->ioaddr,
-                (unsigned long)pDevice->PortOffset, pDevice->pcid->irq);
+       dev_info(&priv->pcid->dev, "MAC=%pM IO=0x%lx Mem=0x%lx IRQ=%d\n",
+                priv->abyCurrentNetAddr, (unsigned long)priv->ioaddr,
+                (unsigned long)priv->PortOffset, priv->pcid->irq);
 }
 
-static void vt6655_init_info(struct pci_dev *pcid,
-                            struct vnt_private **ppDevice,
-                            PCHIP_INFO pChip_info)
+static void device_free_info(struct vnt_private *priv)
 {
-       memset(*ppDevice, 0, sizeof(**ppDevice));
-
-       (*ppDevice)->pcid = pcid;
-       (*ppDevice)->chip_id = pChip_info->chip_id;
-       (*ppDevice)->io_size = pChip_info->io_size;
-       (*ppDevice)->nTxQueues = pChip_info->nTxQueue;
-       (*ppDevice)->multicast_limit = 32;
-
-       spin_lock_init(&((*ppDevice)->lock));
-}
-
-static bool device_get_pci_info(struct vnt_private *pDevice,
-                               struct pci_dev *pcid)
-{
-       u16 pci_cmd;
-       u8  b;
-       unsigned int cis_addr;
-
-       pci_read_config_byte(pcid, PCI_REVISION_ID, &pDevice->byRevId);
-       pci_read_config_word(pcid, PCI_SUBSYSTEM_ID, &pDevice->SubSystemID);
-       pci_read_config_word(pcid, PCI_SUBSYSTEM_VENDOR_ID, &pDevice->SubVendorID);
-       pci_read_config_word(pcid, PCI_COMMAND, (u16 *)&(pci_cmd));
-
-       pci_set_master(pcid);
-
-       pDevice->memaddr = pci_resource_start(pcid, 0);
-       pDevice->ioaddr = pci_resource_start(pcid, 1);
-
-       cis_addr = pci_resource_start(pcid, 2);
-
-       pDevice->pcid = pcid;
-
-       pci_read_config_byte(pcid, PCI_COMMAND, &b);
-       pci_write_config_byte(pcid, PCI_COMMAND, (b|PCI_COMMAND_MASTER));
-
-       return true;
-}
-
-static void device_free_info(struct vnt_private *pDevice)
-{
-       if (!pDevice)
+       if (!priv)
                return;
 
-       if (pDevice->mac_hw)
-               ieee80211_unregister_hw(pDevice->hw);
+       if (priv->mac_hw)
+               ieee80211_unregister_hw(priv->hw);
 
-       if (pDevice->PortOffset)
-               iounmap(pDevice->PortOffset);
+       if (priv->PortOffset)
+               iounmap(priv->PortOffset);
 
-       if (pDevice->pcid)
-               pci_release_regions(pDevice->pcid);
+       if (priv->pcid)
+               pci_release_regions(priv->pcid);
 
-       if (pDevice->hw)
-               ieee80211_free_hw(pDevice->hw);
+       if (priv->hw)
+               ieee80211_free_hw(priv->hw);
 }
 
-static bool device_init_rings(struct vnt_private *pDevice)
+static bool device_init_rings(struct vnt_private *priv)
 {
        void *vir_pool;
 
        /*allocate all RD/TD rings a single pool*/
-       vir_pool = dma_zalloc_coherent(&pDevice->pcid->dev,
-                                        pDevice->sOpts.nRxDescs0 * sizeof(SRxDesc) +
-                                        pDevice->sOpts.nRxDescs1 * sizeof(SRxDesc) +
-                                        pDevice->sOpts.nTxDescs[0] * sizeof(STxDesc) +
-                                        pDevice->sOpts.nTxDescs[1] * sizeof(STxDesc),
-                                        &pDevice->pool_dma, GFP_ATOMIC);
+       vir_pool = dma_zalloc_coherent(&priv->pcid->dev,
+                                      priv->opts.rx_descs0 * sizeof(struct vnt_rx_desc) +
+                                      priv->opts.rx_descs1 * sizeof(struct vnt_rx_desc) +
+                                      priv->opts.tx_descs[0] * sizeof(struct vnt_tx_desc) +
+                                      priv->opts.tx_descs[1] * sizeof(struct vnt_tx_desc),
+                                      &priv->pool_dma, GFP_ATOMIC);
        if (vir_pool == NULL) {
-               dev_err(&pDevice->pcid->dev, "allocate desc dma memory failed\n");
+               dev_err(&priv->pcid->dev, "allocate desc dma memory failed\n");
                return false;
        }
 
-       pDevice->aRD0Ring = vir_pool;
-       pDevice->aRD1Ring = vir_pool +
-               pDevice->sOpts.nRxDescs0 * sizeof(SRxDesc);
-
-       pDevice->rd0_pool_dma = pDevice->pool_dma;
-       pDevice->rd1_pool_dma = pDevice->rd0_pool_dma +
-               pDevice->sOpts.nRxDescs0 * sizeof(SRxDesc);
-
-       pDevice->tx0_bufs = dma_zalloc_coherent(&pDevice->pcid->dev,
-                                                 pDevice->sOpts.nTxDescs[0] * PKT_BUF_SZ +
-                                                 pDevice->sOpts.nTxDescs[1] * PKT_BUF_SZ +
-                                                 CB_BEACON_BUF_SIZE +
-                                                 CB_MAX_BUF_SIZE,
-                                                 &pDevice->tx_bufs_dma0,
-                                                 GFP_ATOMIC);
-       if (pDevice->tx0_bufs == NULL) {
-               dev_err(&pDevice->pcid->dev, "allocate buf dma memory failed\n");
-
-               dma_free_coherent(&pDevice->pcid->dev,
-                                   pDevice->sOpts.nRxDescs0 * sizeof(SRxDesc) +
-                                   pDevice->sOpts.nRxDescs1 * sizeof(SRxDesc) +
-                                   pDevice->sOpts.nTxDescs[0] * sizeof(STxDesc) +
-                                   pDevice->sOpts.nTxDescs[1] * sizeof(STxDesc),
-                                   vir_pool, pDevice->pool_dma
-                       );
+       priv->aRD0Ring = vir_pool;
+       priv->aRD1Ring = vir_pool +
+               priv->opts.rx_descs0 * sizeof(struct vnt_rx_desc);
+
+       priv->rd0_pool_dma = priv->pool_dma;
+       priv->rd1_pool_dma = priv->rd0_pool_dma +
+               priv->opts.rx_descs0 * sizeof(struct vnt_rx_desc);
+
+       priv->tx0_bufs = dma_zalloc_coherent(&priv->pcid->dev,
+                                            priv->opts.tx_descs[0] * PKT_BUF_SZ +
+                                            priv->opts.tx_descs[1] * PKT_BUF_SZ +
+                                            CB_BEACON_BUF_SIZE +
+                                            CB_MAX_BUF_SIZE,
+                                            &priv->tx_bufs_dma0,
+                                            GFP_ATOMIC);
+       if (priv->tx0_bufs == NULL) {
+               dev_err(&priv->pcid->dev, "allocate buf dma memory failed\n");
+
+               dma_free_coherent(&priv->pcid->dev,
+                                 priv->opts.rx_descs0 * sizeof(struct vnt_rx_desc) +
+                                 priv->opts.rx_descs1 * sizeof(struct vnt_rx_desc) +
+                                 priv->opts.tx_descs[0] * sizeof(struct vnt_tx_desc) +
+                                 priv->opts.tx_descs[1] * sizeof(struct vnt_tx_desc),
+                                 vir_pool, priv->pool_dma);
                return false;
        }
 
-       pDevice->td0_pool_dma = pDevice->rd1_pool_dma +
-               pDevice->sOpts.nRxDescs1 * sizeof(SRxDesc);
+       priv->td0_pool_dma = priv->rd1_pool_dma +
+               priv->opts.rx_descs1 * sizeof(struct vnt_rx_desc);
 
-       pDevice->td1_pool_dma = pDevice->td0_pool_dma +
-               pDevice->sOpts.nTxDescs[0] * sizeof(STxDesc);
+       priv->td1_pool_dma = priv->td0_pool_dma +
+               priv->opts.tx_descs[0] * sizeof(struct vnt_tx_desc);
 
        /* vir_pool: pvoid type */
-       pDevice->apTD0Rings = vir_pool
-               + pDevice->sOpts.nRxDescs0 * sizeof(SRxDesc)
-               + pDevice->sOpts.nRxDescs1 * sizeof(SRxDesc);
+       priv->apTD0Rings = vir_pool
+               + priv->opts.rx_descs0 * sizeof(struct vnt_rx_desc)
+               + priv->opts.rx_descs1 * sizeof(struct vnt_rx_desc);
 
-       pDevice->apTD1Rings = vir_pool
-               + pDevice->sOpts.nRxDescs0 * sizeof(SRxDesc)
-               + pDevice->sOpts.nRxDescs1 * sizeof(SRxDesc)
-               + pDevice->sOpts.nTxDescs[0] * sizeof(STxDesc);
+       priv->apTD1Rings = vir_pool
+               + priv->opts.rx_descs0 * sizeof(struct vnt_rx_desc)
+               + priv->opts.rx_descs1 * sizeof(struct vnt_rx_desc)
+               + priv->opts.tx_descs[0] * sizeof(struct vnt_tx_desc);
 
-       pDevice->tx1_bufs = pDevice->tx0_bufs +
-               pDevice->sOpts.nTxDescs[0] * PKT_BUF_SZ;
+       priv->tx1_bufs = priv->tx0_bufs +
+               priv->opts.tx_descs[0] * PKT_BUF_SZ;
 
-       pDevice->tx_beacon_bufs = pDevice->tx1_bufs +
-               pDevice->sOpts.nTxDescs[1] * PKT_BUF_SZ;
+       priv->tx_beacon_bufs = priv->tx1_bufs +
+               priv->opts.tx_descs[1] * PKT_BUF_SZ;
 
-       pDevice->pbyTmpBuff = pDevice->tx_beacon_bufs +
+       priv->pbyTmpBuff = priv->tx_beacon_bufs +
                CB_BEACON_BUF_SIZE;
 
-       pDevice->tx_bufs_dma1 = pDevice->tx_bufs_dma0 +
-               pDevice->sOpts.nTxDescs[0] * PKT_BUF_SZ;
+       priv->tx_bufs_dma1 = priv->tx_bufs_dma0 +
+               priv->opts.tx_descs[0] * PKT_BUF_SZ;
 
-       pDevice->tx_beacon_dma = pDevice->tx_bufs_dma1 +
-               pDevice->sOpts.nTxDescs[1] * PKT_BUF_SZ;
+       priv->tx_beacon_dma = priv->tx_bufs_dma1 +
+               priv->opts.tx_descs[1] * PKT_BUF_SZ;
 
        return true;
 }
 
-static void device_free_rings(struct vnt_private *pDevice)
+static void device_free_rings(struct vnt_private *priv)
 {
-       dma_free_coherent(&pDevice->pcid->dev,
-                           pDevice->sOpts.nRxDescs0 * sizeof(SRxDesc) +
-                           pDevice->sOpts.nRxDescs1 * sizeof(SRxDesc) +
-                           pDevice->sOpts.nTxDescs[0] * sizeof(STxDesc) +
-                           pDevice->sOpts.nTxDescs[1] * sizeof(STxDesc)
-                           ,
-                           pDevice->aRD0Ring, pDevice->pool_dma
-               );
-
-       if (pDevice->tx0_bufs)
-               dma_free_coherent(&pDevice->pcid->dev,
-                                   pDevice->sOpts.nTxDescs[0] * PKT_BUF_SZ +
-                                   pDevice->sOpts.nTxDescs[1] * PKT_BUF_SZ +
-                                   CB_BEACON_BUF_SIZE +
-                                   CB_MAX_BUF_SIZE,
-                                   pDevice->tx0_bufs, pDevice->tx_bufs_dma0
-                       );
+       dma_free_coherent(&priv->pcid->dev,
+                         priv->opts.rx_descs0 * sizeof(struct vnt_rx_desc) +
+                         priv->opts.rx_descs1 * sizeof(struct vnt_rx_desc) +
+                         priv->opts.tx_descs[0] * sizeof(struct vnt_tx_desc) +
+                         priv->opts.tx_descs[1] * sizeof(struct vnt_tx_desc),
+                         priv->aRD0Ring, priv->pool_dma);
+
+       if (priv->tx0_bufs)
+               dma_free_coherent(&priv->pcid->dev,
+                                 priv->opts.tx_descs[0] * PKT_BUF_SZ +
+                                 priv->opts.tx_descs[1] * PKT_BUF_SZ +
+                                 CB_BEACON_BUF_SIZE +
+                                 CB_MAX_BUF_SIZE,
+                                 priv->tx0_bufs, priv->tx_bufs_dma0);
 }
 
-static void device_init_rd0_ring(struct vnt_private *pDevice)
+static void device_init_rd0_ring(struct vnt_private *priv)
 {
        int i;
-       dma_addr_t      curr = pDevice->rd0_pool_dma;
-       PSRxDesc        pDesc;
+       dma_addr_t      curr = priv->rd0_pool_dma;
+       struct vnt_rx_desc *desc;
 
        /* Init the RD0 ring entries */
-       for (i = 0; i < pDevice->sOpts.nRxDescs0; i ++, curr += sizeof(SRxDesc)) {
-               pDesc = &(pDevice->aRD0Ring[i]);
-               pDesc->pRDInfo = alloc_rd_info();
-               ASSERT(pDesc->pRDInfo);
-               if (!device_alloc_rx_buf(pDevice, pDesc))
-                       dev_err(&pDevice->pcid->dev, "can not alloc rx bufs\n");
-
-               pDesc->next = &(pDevice->aRD0Ring[(i+1) % pDevice->sOpts.nRxDescs0]);
-               pDesc->pRDInfo->curr_desc = cpu_to_le32(curr);
-               pDesc->next_desc = cpu_to_le32(curr + sizeof(SRxDesc));
+       for (i = 0; i < priv->opts.rx_descs0;
+            i ++, curr += sizeof(struct vnt_rx_desc)) {
+               desc = &priv->aRD0Ring[i];
+               desc->rd_info = kzalloc(sizeof(*desc->rd_info), GFP_ATOMIC);
+
+               if (!device_alloc_rx_buf(priv, desc))
+                       dev_err(&priv->pcid->dev, "can not alloc rx bufs\n");
+
+               desc->next = &(priv->aRD0Ring[(i+1) % priv->opts.rx_descs0]);
+               desc->next_desc = cpu_to_le32(curr + sizeof(struct vnt_rx_desc));
        }
 
        if (i > 0)
-               pDevice->aRD0Ring[i-1].next_desc = cpu_to_le32(pDevice->rd0_pool_dma);
-       pDevice->pCurrRD[0] = &(pDevice->aRD0Ring[0]);
+               priv->aRD0Ring[i-1].next_desc = cpu_to_le32(priv->rd0_pool_dma);
+       priv->pCurrRD[0] = &priv->aRD0Ring[0];
 }
 
-static void device_init_rd1_ring(struct vnt_private *pDevice)
+static void device_init_rd1_ring(struct vnt_private *priv)
 {
        int i;
-       dma_addr_t      curr = pDevice->rd1_pool_dma;
-       PSRxDesc        pDesc;
+       dma_addr_t      curr = priv->rd1_pool_dma;
+       struct vnt_rx_desc *desc;
 
        /* Init the RD1 ring entries */
-       for (i = 0; i < pDevice->sOpts.nRxDescs1; i ++, curr += sizeof(SRxDesc)) {
-               pDesc = &(pDevice->aRD1Ring[i]);
-               pDesc->pRDInfo = alloc_rd_info();
-               ASSERT(pDesc->pRDInfo);
-               if (!device_alloc_rx_buf(pDevice, pDesc))
-                       dev_err(&pDevice->pcid->dev, "can not alloc rx bufs\n");
-
-               pDesc->next = &(pDevice->aRD1Ring[(i+1) % pDevice->sOpts.nRxDescs1]);
-               pDesc->pRDInfo->curr_desc = cpu_to_le32(curr);
-               pDesc->next_desc = cpu_to_le32(curr + sizeof(SRxDesc));
+       for (i = 0; i < priv->opts.rx_descs1;
+            i ++, curr += sizeof(struct vnt_rx_desc)) {
+               desc = &priv->aRD1Ring[i];
+               desc->rd_info = kzalloc(sizeof(*desc->rd_info), GFP_ATOMIC);
+
+               if (!device_alloc_rx_buf(priv, desc))
+                       dev_err(&priv->pcid->dev, "can not alloc rx bufs\n");
+
+               desc->next = &(priv->aRD1Ring[(i+1) % priv->opts.rx_descs1]);
+               desc->next_desc = cpu_to_le32(curr + sizeof(struct vnt_rx_desc));
        }
 
        if (i > 0)
-               pDevice->aRD1Ring[i-1].next_desc = cpu_to_le32(pDevice->rd1_pool_dma);
-       pDevice->pCurrRD[1] = &(pDevice->aRD1Ring[0]);
+               priv->aRD1Ring[i-1].next_desc = cpu_to_le32(priv->rd1_pool_dma);
+       priv->pCurrRD[1] = &priv->aRD1Ring[0];
 }
 
-static void device_free_rd0_ring(struct vnt_private *pDevice)
+static void device_free_rd0_ring(struct vnt_private *priv)
 {
        int i;
 
-       for (i = 0; i < pDevice->sOpts.nRxDescs0; i++) {
-               PSRxDesc        pDesc = &(pDevice->aRD0Ring[i]);
-               PDEVICE_RD_INFO  pRDInfo = pDesc->pRDInfo;
+       for (i = 0; i < priv->opts.rx_descs0; i++) {
+               struct vnt_rx_desc *desc = &(priv->aRD0Ring[i]);
+               struct vnt_rd_info *rd_info = desc->rd_info;
 
-               dma_unmap_single(&pDevice->pcid->dev, pRDInfo->skb_dma,
-                                pDevice->rx_buf_sz, DMA_FROM_DEVICE);
+               dma_unmap_single(&priv->pcid->dev, rd_info->skb_dma,
+                                priv->rx_buf_sz, DMA_FROM_DEVICE);
 
-               dev_kfree_skb(pRDInfo->skb);
+               dev_kfree_skb(rd_info->skb);
 
-               kfree(pDesc->pRDInfo);
+               kfree(desc->rd_info);
        }
 }
 
-static void device_free_rd1_ring(struct vnt_private *pDevice)
+static void device_free_rd1_ring(struct vnt_private *priv)
 {
        int i;
 
-       for (i = 0; i < pDevice->sOpts.nRxDescs1; i++) {
-               PSRxDesc        pDesc = &(pDevice->aRD1Ring[i]);
-               PDEVICE_RD_INFO  pRDInfo = pDesc->pRDInfo;
+       for (i = 0; i < priv->opts.rx_descs1; i++) {
+               struct vnt_rx_desc *desc = &priv->aRD1Ring[i];
+               struct vnt_rd_info *rd_info = desc->rd_info;
 
-               dma_unmap_single(&pDevice->pcid->dev, pRDInfo->skb_dma,
-                                pDevice->rx_buf_sz, DMA_FROM_DEVICE);
+               dma_unmap_single(&priv->pcid->dev, rd_info->skb_dma,
+                                priv->rx_buf_sz, DMA_FROM_DEVICE);
 
-               dev_kfree_skb(pRDInfo->skb);
+               dev_kfree_skb(rd_info->skb);
 
-               kfree(pDesc->pRDInfo);
+               kfree(desc->rd_info);
        }
 }
 
-static void device_init_td0_ring(struct vnt_private *pDevice)
+static void device_init_td0_ring(struct vnt_private *priv)
 {
        int i;
        dma_addr_t  curr;
-       PSTxDesc        pDesc;
-
-       curr = pDevice->td0_pool_dma;
-       for (i = 0; i < pDevice->sOpts.nTxDescs[0]; i++, curr += sizeof(STxDesc)) {
-               pDesc = &(pDevice->apTD0Rings[i]);
-               pDesc->pTDInfo = alloc_td_info();
-               ASSERT(pDesc->pTDInfo);
-               if (pDevice->flags & DEVICE_FLAGS_TX_ALIGN) {
-                       pDesc->pTDInfo->buf = pDevice->tx0_bufs + (i)*PKT_BUF_SZ;
-                       pDesc->pTDInfo->buf_dma = pDevice->tx_bufs_dma0 + (i)*PKT_BUF_SZ;
-               }
-               pDesc->next = &(pDevice->apTD0Rings[(i+1) % pDevice->sOpts.nTxDescs[0]]);
-               pDesc->pTDInfo->curr_desc = cpu_to_le32(curr);
-               pDesc->next_desc = cpu_to_le32(curr+sizeof(STxDesc));
+       struct vnt_tx_desc *desc;
+
+       curr = priv->td0_pool_dma;
+       for (i = 0; i < priv->opts.tx_descs[0];
+            i++, curr += sizeof(struct vnt_tx_desc)) {
+               desc = &priv->apTD0Rings[i];
+               desc->td_info = kzalloc(sizeof(*desc->td_info), GFP_ATOMIC);
+
+               desc->td_info->buf = priv->tx0_bufs + i * PKT_BUF_SZ;
+               desc->td_info->buf_dma = priv->tx_bufs_dma0 + i * PKT_BUF_SZ;
+
+               desc->next = &(priv->apTD0Rings[(i+1) % priv->opts.tx_descs[0]]);
+               desc->next_desc = cpu_to_le32(curr + sizeof(struct vnt_tx_desc));
        }
 
        if (i > 0)
-               pDevice->apTD0Rings[i-1].next_desc = cpu_to_le32(pDevice->td0_pool_dma);
-       pDevice->apTailTD[0] = pDevice->apCurrTD[0] = &(pDevice->apTD0Rings[0]);
+               priv->apTD0Rings[i-1].next_desc = cpu_to_le32(priv->td0_pool_dma);
+       priv->apTailTD[0] = priv->apCurrTD[0] = &priv->apTD0Rings[0];
 }
 
-static void device_init_td1_ring(struct vnt_private *pDevice)
+static void device_init_td1_ring(struct vnt_private *priv)
 {
        int i;
        dma_addr_t  curr;
-       PSTxDesc    pDesc;
+       struct vnt_tx_desc *desc;
 
        /* Init the TD ring entries */
-       curr = pDevice->td1_pool_dma;
-       for (i = 0; i < pDevice->sOpts.nTxDescs[1]; i++, curr += sizeof(STxDesc)) {
-               pDesc = &(pDevice->apTD1Rings[i]);
-               pDesc->pTDInfo = alloc_td_info();
-               ASSERT(pDesc->pTDInfo);
-               if (pDevice->flags & DEVICE_FLAGS_TX_ALIGN) {
-                       pDesc->pTDInfo->buf = pDevice->tx1_bufs + (i) * PKT_BUF_SZ;
-                       pDesc->pTDInfo->buf_dma = pDevice->tx_bufs_dma1 + (i) * PKT_BUF_SZ;
-               }
-               pDesc->next = &(pDevice->apTD1Rings[(i + 1) % pDevice->sOpts.nTxDescs[1]]);
-               pDesc->pTDInfo->curr_desc = cpu_to_le32(curr);
-               pDesc->next_desc = cpu_to_le32(curr+sizeof(STxDesc));
+       curr = priv->td1_pool_dma;
+       for (i = 0; i < priv->opts.tx_descs[1];
+            i++, curr += sizeof(struct vnt_tx_desc)) {
+               desc = &priv->apTD1Rings[i];
+               desc->td_info = kzalloc(sizeof(*desc->td_info), GFP_ATOMIC);
+
+               desc->td_info->buf = priv->tx1_bufs + i * PKT_BUF_SZ;
+               desc->td_info->buf_dma = priv->tx_bufs_dma1 + i * PKT_BUF_SZ;
+
+               desc->next = &(priv->apTD1Rings[(i + 1) % priv->opts.tx_descs[1]]);
+               desc->next_desc = cpu_to_le32(curr + sizeof(struct vnt_tx_desc));
        }
 
        if (i > 0)
-               pDevice->apTD1Rings[i-1].next_desc = cpu_to_le32(pDevice->td1_pool_dma);
-       pDevice->apTailTD[1] = pDevice->apCurrTD[1] = &(pDevice->apTD1Rings[0]);
+               priv->apTD1Rings[i-1].next_desc = cpu_to_le32(priv->td1_pool_dma);
+       priv->apTailTD[1] = priv->apCurrTD[1] = &priv->apTD1Rings[0];
 }
 
-static void device_free_td0_ring(struct vnt_private *pDevice)
+static void device_free_td0_ring(struct vnt_private *priv)
 {
        int i;
 
-       for (i = 0; i < pDevice->sOpts.nTxDescs[0]; i++) {
-               PSTxDesc        pDesc = &(pDevice->apTD0Rings[i]);
-               PDEVICE_TD_INFO  pTDInfo = pDesc->pTDInfo;
+       for (i = 0; i < priv->opts.tx_descs[0]; i++) {
+               struct vnt_tx_desc *desc = &priv->apTD0Rings[i];
+               struct vnt_td_info *td_info = desc->td_info;
 
-               if (pTDInfo->skb_dma && (pTDInfo->skb_dma != pTDInfo->buf_dma))
-                       dma_unmap_single(&pDevice->pcid->dev, pTDInfo->skb_dma,
-                                        pTDInfo->skb->len, DMA_TO_DEVICE);
-
-               if (pTDInfo->skb)
-                       dev_kfree_skb(pTDInfo->skb);
-
-               kfree(pDesc->pTDInfo);
+               dev_kfree_skb(td_info->skb);
+               kfree(desc->td_info);
        }
 }
 
-static void device_free_td1_ring(struct vnt_private *pDevice)
+static void device_free_td1_ring(struct vnt_private *priv)
 {
        int i;
 
-       for (i = 0; i < pDevice->sOpts.nTxDescs[1]; i++) {
-               PSTxDesc        pDesc = &(pDevice->apTD1Rings[i]);
-               PDEVICE_TD_INFO  pTDInfo = pDesc->pTDInfo;
-
-               if (pTDInfo->skb_dma && (pTDInfo->skb_dma != pTDInfo->buf_dma))
-                       dma_unmap_single(&pDevice->pcid->dev, pTDInfo->skb_dma,
-                                        pTDInfo->skb->len, DMA_TO_DEVICE);
-
-               if (pTDInfo->skb)
-                       dev_kfree_skb(pTDInfo->skb);
+       for (i = 0; i < priv->opts.tx_descs[1]; i++) {
+               struct vnt_tx_desc *desc = &priv->apTD1Rings[i];
+               struct vnt_td_info *td_info = desc->td_info;
 
-               kfree(pDesc->pTDInfo);
+               dev_kfree_skb(td_info->skb);
+               kfree(desc->td_info);
        }
 }
 
 /*-----------------------------------------------------------------*/
 
-static int device_rx_srv(struct vnt_private *pDevice, unsigned int uIdx)
+static int device_rx_srv(struct vnt_private *priv, unsigned int idx)
 {
-       PSRxDesc    pRD;
+       struct vnt_rx_desc *rd;
        int works = 0;
 
-       for (pRD = pDevice->pCurrRD[uIdx];
-            pRD->m_rd0RD0.f1Owner == OWNED_BY_HOST;
-            pRD = pRD->next) {
+       for (rd = priv->pCurrRD[idx];
+            rd->rd0.owner == OWNED_BY_HOST;
+            rd = rd->next) {
                if (works++ > 15)
                        break;
 
-               if (!pRD->pRDInfo->skb)
+               if (!rd->rd_info->skb)
                        break;
 
-               if (vnt_receive_frame(pDevice, pRD)) {
-                       if (!device_alloc_rx_buf(pDevice, pRD)) {
-                               dev_err(&pDevice->pcid->dev,
+               if (vnt_receive_frame(priv, rd)) {
+                       if (!device_alloc_rx_buf(priv, rd)) {
+                               dev_err(&priv->pcid->dev,
                                        "can not allocate rx buf\n");
                                break;
                        }
                }
-               pRD->m_rd0RD0.f1Owner = OWNED_BY_NIC;
+               rd->rd0.owner = OWNED_BY_NIC;
        }
 
-       pDevice->pCurrRD[uIdx] = pRD;
+       priv->pCurrRD[idx] = rd;
 
        return works;
 }
 
-static bool device_alloc_rx_buf(struct vnt_private *pDevice, PSRxDesc pRD)
+static bool device_alloc_rx_buf(struct vnt_private *priv,
+                               struct vnt_rx_desc *rd)
 {
-       PDEVICE_RD_INFO pRDInfo = pRD->pRDInfo;
+       struct vnt_rd_info *rd_info = rd->rd_info;
 
-       pRDInfo->skb = dev_alloc_skb((int)pDevice->rx_buf_sz);
-       if (pRDInfo->skb == NULL)
+       rd_info->skb = dev_alloc_skb((int)priv->rx_buf_sz);
+       if (rd_info->skb == NULL)
                return false;
-       ASSERT(pRDInfo->skb);
 
-       pRDInfo->skb_dma =
-               dma_map_single(&pDevice->pcid->dev,
-                              skb_put(pRDInfo->skb, skb_tailroom(pRDInfo->skb)),
-                              pDevice->rx_buf_sz, DMA_FROM_DEVICE);
+       rd_info->skb_dma =
+               dma_map_single(&priv->pcid->dev,
+                              skb_put(rd_info->skb, skb_tailroom(rd_info->skb)),
+                              priv->rx_buf_sz, DMA_FROM_DEVICE);
 
-       *((unsigned int *)&(pRD->m_rd0RD0)) = 0; /* FIX cast */
+       *((unsigned int *)&rd->rd0) = 0; /* FIX cast */
 
-       pRD->m_rd0RD0.wResCount = cpu_to_le16(pDevice->rx_buf_sz);
-       pRD->m_rd0RD0.f1Owner = OWNED_BY_NIC;
-       pRD->m_rd1RD1.wReqCount = cpu_to_le16(pDevice->rx_buf_sz);
-       pRD->buff_addr = cpu_to_le32(pRDInfo->skb_dma);
+       rd->rd0.res_count = cpu_to_le16(priv->rx_buf_sz);
+       rd->rd0.owner = OWNED_BY_NIC;
+       rd->rd1.req_count = cpu_to_le16(priv->rx_buf_sz);
+       rd->buff_addr = cpu_to_le32(rd_info->skb_dma);
 
        return true;
 }
@@ -867,7 +770,7 @@ static const u8 fallback_rate1[5][5] = {
 };
 
 static int vnt_int_report_rate(struct vnt_private *priv,
-                              PDEVICE_TD_INFO context, u8 tsr0, u8 tsr1)
+                              struct vnt_td_info *context, u8 tsr0, u8 tsr1)
 {
        struct vnt_tx_fifo_head *fifo_head;
        struct ieee80211_tx_info *info;
@@ -926,83 +829,77 @@ static int vnt_int_report_rate(struct vnt_private *priv,
        return 0;
 }
 
-static int device_tx_srv(struct vnt_private *pDevice, unsigned int uIdx)
+static int device_tx_srv(struct vnt_private *priv, unsigned int idx)
 {
-       PSTxDesc                 pTD;
+       struct vnt_tx_desc *desc;
        int                      works = 0;
        unsigned char byTsr0;
        unsigned char byTsr1;
 
-       for (pTD = pDevice->apTailTD[uIdx]; pDevice->iTDUsed[uIdx] > 0; pTD = pTD->next) {
-               if (pTD->m_td0TD0.f1Owner == OWNED_BY_NIC)
+       for (desc = priv->apTailTD[idx]; priv->iTDUsed[idx] > 0; desc = desc->next) {
+               if (desc->td0.owner == OWNED_BY_NIC)
                        break;
                if (works++ > 15)
                        break;
 
-               byTsr0 = pTD->m_td0TD0.byTSR0;
-               byTsr1 = pTD->m_td0TD0.byTSR1;
+               byTsr0 = desc->td0.tsr0;
+               byTsr1 = desc->td0.tsr1;
 
                /* Only the status of first TD in the chain is correct */
-               if (pTD->m_td1TD1.byTCR & TCR_STP) {
-                       if ((pTD->pTDInfo->byFlags & TD_FLAGS_NETIF_SKB) != 0) {
+               if (desc->td1.tcr & TCR_STP) {
+                       if ((desc->td_info->flags & TD_FLAGS_NETIF_SKB) != 0) {
                                if (!(byTsr1 & TSR1_TERR)) {
                                        if (byTsr0 != 0) {
                                                pr_debug(" Tx[%d] OK but has error. tsr1[%02X] tsr0[%02X]\n",
-                                                        (int)uIdx, byTsr1,
+                                                        (int)idx, byTsr1,
                                                         byTsr0);
                                        }
                                } else {
                                        pr_debug(" Tx[%d] dropped & tsr1[%02X] tsr0[%02X]\n",
-                                                (int)uIdx, byTsr1, byTsr0);
+                                                (int)idx, byTsr1, byTsr0);
                                }
                        }
 
                        if (byTsr1 & TSR1_TERR) {
-                               if ((pTD->pTDInfo->byFlags & TD_FLAGS_PRIV_SKB) != 0) {
+                               if ((desc->td_info->flags & TD_FLAGS_PRIV_SKB) != 0) {
                                        pr_debug(" Tx[%d] fail has error. tsr1[%02X] tsr0[%02X]\n",
-                                                (int)uIdx, byTsr1, byTsr0);
+                                                (int)idx, byTsr1, byTsr0);
                                }
                        }
 
-                       vnt_int_report_rate(pDevice, pTD->pTDInfo, byTsr0, byTsr1);
+                       vnt_int_report_rate(priv, desc->td_info, byTsr0, byTsr1);
 
-                       device_free_tx_buf(pDevice, pTD);
-                       pDevice->iTDUsed[uIdx]--;
+                       device_free_tx_buf(priv, desc);
+                       priv->iTDUsed[idx]--;
                }
        }
 
-       pDevice->apTailTD[uIdx] = pTD;
+       priv->apTailTD[idx] = desc;
 
        return works;
 }
 
-static void device_error(struct vnt_private *pDevice, unsigned short status)
+static void device_error(struct vnt_private *priv, unsigned short status)
 {
        if (status & ISR_FETALERR) {
-               dev_err(&pDevice->pcid->dev, "Hardware fatal error\n");
+               dev_err(&priv->pcid->dev, "Hardware fatal error\n");
 
-               MACbShutdown(pDevice->PortOffset);
+               MACbShutdown(priv->PortOffset);
                return;
        }
 }
 
-static void device_free_tx_buf(struct vnt_private *pDevice, PSTxDesc pDesc)
+static void device_free_tx_buf(struct vnt_private *priv,
+                              struct vnt_tx_desc *desc)
 {
-       PDEVICE_TD_INFO  pTDInfo = pDesc->pTDInfo;
-       struct sk_buff *skb = pTDInfo->skb;
-
-       /* pre-allocated buf_dma can't be unmapped. */
-       if (pTDInfo->skb_dma && (pTDInfo->skb_dma != pTDInfo->buf_dma)) {
-               dma_unmap_single(&pDevice->pcid->dev, pTDInfo->skb_dma,
-                                skb->len, DMA_TO_DEVICE);
-       }
+       struct vnt_td_info *td_info = desc->td_info;
+       struct sk_buff *skb = td_info->skb;
 
        if (skb)
-               ieee80211_tx_status_irqsafe(pDevice->hw, skb);
+               ieee80211_tx_status_irqsafe(priv->hw, skb);
 
-       pTDInfo->skb_dma = 0;
-       pTDInfo->skb = NULL;
-       pTDInfo->byFlags = 0;
+       td_info->skb = NULL;
+       td_info->flags = 0;
 }
 
 static void vnt_check_bb_vga(struct vnt_private *priv)
@@ -1057,135 +954,141 @@ static void vnt_check_bb_vga(struct vnt_private *priv)
        }
 }
 
-static  irqreturn_t  device_intr(int irq,  void *dev_instance)
+static void vnt_interrupt_process(struct vnt_private *priv)
 {
-       struct vnt_private *pDevice = dev_instance;
+       struct ieee80211_low_level_stats *low_stats = &priv->low_stats;
        int             max_count = 0;
-       unsigned long dwMIBCounter = 0;
-       unsigned char byOrgPageSel = 0;
-       int             handled = 0;
+       u32 mib_counter;
+       u32 isr;
        unsigned long flags;
 
-       MACvReadISR(pDevice->PortOffset, &pDevice->dwIsr);
+       MACvReadISR(priv->PortOffset, &isr);
 
-       if (pDevice->dwIsr == 0)
-               return IRQ_RETVAL(handled);
+       if (isr == 0)
+               return;
 
-       if (pDevice->dwIsr == 0xffffffff) {
-               pr_debug("dwIsr = 0xffff\n");
-               return IRQ_RETVAL(handled);
+       if (isr == 0xffffffff) {
+               pr_debug("isr = 0xffff\n");
+               return;
        }
 
-       handled = 1;
-       MACvIntDisable(pDevice->PortOffset);
+       MACvIntDisable(priv->PortOffset);
 
-       spin_lock_irqsave(&pDevice->lock, flags);
+       spin_lock_irqsave(&priv->lock, flags);
 
-       /* Make sure current page is 0 */
-       VNSvInPortB(pDevice->PortOffset + MAC_REG_PAGE1SEL, &byOrgPageSel);
-       if (byOrgPageSel == 1)
-               MACvSelectPage0(pDevice->PortOffset);
-       else
-               byOrgPageSel = 0;
+       /* Read low level stats */
+       MACvReadMIBCounter(priv->PortOffset, &mib_counter);
+
+       low_stats->dot11RTSSuccessCount += mib_counter & 0xff;
+       low_stats->dot11RTSFailureCount += (mib_counter >> 8) & 0xff;
+       low_stats->dot11ACKFailureCount += (mib_counter >> 16) & 0xff;
+       low_stats->dot11FCSErrorCount += (mib_counter >> 24) & 0xff;
 
-       MACvReadMIBCounter(pDevice->PortOffset, &dwMIBCounter);
        /*
         * TBD....
         * Must do this after doing rx/tx, cause ISR bit is slow
         * than RD/TD write back
         * update ISR counter
         */
-       STAvUpdate802_11Counter(&pDevice->s802_11Counter, &pDevice->scStatistic, dwMIBCounter);
-       while (pDevice->dwIsr != 0) {
-               STAvUpdateIsrStatCounter(&pDevice->scStatistic, pDevice->dwIsr);
-               MACvWriteISR(pDevice->PortOffset, pDevice->dwIsr);
+       while (isr && priv->vif) {
+               MACvWriteISR(priv->PortOffset, isr);
 
-               if (pDevice->dwIsr & ISR_FETALERR) {
+               if (isr & ISR_FETALERR) {
                        pr_debug(" ISR_FETALERR\n");
-                       VNSvOutPortB(pDevice->PortOffset + MAC_REG_SOFTPWRCTL, 0);
-                       VNSvOutPortW(pDevice->PortOffset + MAC_REG_SOFTPWRCTL, SOFTPWRCTL_SWPECTI);
-                       device_error(pDevice, pDevice->dwIsr);
+                       VNSvOutPortB(priv->PortOffset + MAC_REG_SOFTPWRCTL, 0);
+                       VNSvOutPortW(priv->PortOffset +
+                                    MAC_REG_SOFTPWRCTL, SOFTPWRCTL_SWPECTI);
+                       device_error(priv, isr);
                }
 
-               if (pDevice->dwIsr & ISR_TBTT) {
-                       if (pDevice->vif &&
-                           pDevice->op_mode != NL80211_IFTYPE_ADHOC)
-                               vnt_check_bb_vga(pDevice);
+               if (isr & ISR_TBTT) {
+                       if (priv->op_mode != NL80211_IFTYPE_ADHOC)
+                               vnt_check_bb_vga(priv);
 
-                       pDevice->bBeaconSent = false;
-                       if (pDevice->bEnablePSMode)
-                               PSbIsNextTBTTWakeUp((void *)pDevice);
+                       priv->bBeaconSent = false;
+                       if (priv->bEnablePSMode)
+                               PSbIsNextTBTTWakeUp((void *)priv);
 
-                       if ((pDevice->op_mode == NL80211_IFTYPE_AP ||
-                           pDevice->op_mode == NL80211_IFTYPE_ADHOC) &&
-                           pDevice->vif->bss_conf.enable_beacon) {
-                               MACvOneShotTimer1MicroSec(pDevice->PortOffset,
-                                                         (pDevice->vif->bss_conf.beacon_int - MAKE_BEACON_RESERVED) << 10);
+                       if ((priv->op_mode == NL80211_IFTYPE_AP ||
+                           priv->op_mode == NL80211_IFTYPE_ADHOC) &&
+                           priv->vif->bss_conf.enable_beacon) {
+                               MACvOneShotTimer1MicroSec(priv->PortOffset,
+                                                         (priv->vif->bss_conf.beacon_int - MAKE_BEACON_RESERVED) << 10);
                        }
 
                        /* TODO: adhoc PS mode */
 
                }
 
-               if (pDevice->dwIsr & ISR_BNTX) {
-                       if (pDevice->op_mode == NL80211_IFTYPE_ADHOC) {
-                               pDevice->bIsBeaconBufReadySet = false;
-                               pDevice->cbBeaconBufReadySetCnt = 0;
+               if (isr & ISR_BNTX) {
+                       if (priv->op_mode == NL80211_IFTYPE_ADHOC) {
+                               priv->bIsBeaconBufReadySet = false;
+                               priv->cbBeaconBufReadySetCnt = 0;
                        }
 
-                       pDevice->bBeaconSent = true;
+                       priv->bBeaconSent = true;
                }
 
-               if (pDevice->dwIsr & ISR_RXDMA0)
-                       max_count += device_rx_srv(pDevice, TYPE_RXDMA0);
+               if (isr & ISR_RXDMA0)
+                       max_count += device_rx_srv(priv, TYPE_RXDMA0);
 
-               if (pDevice->dwIsr & ISR_RXDMA1)
-                       max_count += device_rx_srv(pDevice, TYPE_RXDMA1);
+               if (isr & ISR_RXDMA1)
+                       max_count += device_rx_srv(priv, TYPE_RXDMA1);
 
-               if (pDevice->dwIsr & ISR_TXDMA0)
-                       max_count += device_tx_srv(pDevice, TYPE_TXDMA0);
+               if (isr & ISR_TXDMA0)
+                       max_count += device_tx_srv(priv, TYPE_TXDMA0);
 
-               if (pDevice->dwIsr & ISR_AC0DMA)
-                       max_count += device_tx_srv(pDevice, TYPE_AC0DMA);
+               if (isr & ISR_AC0DMA)
+                       max_count += device_tx_srv(priv, TYPE_AC0DMA);
 
-               if (pDevice->dwIsr & ISR_SOFTTIMER1) {
-                       if (pDevice->vif) {
-                               if (pDevice->vif->bss_conf.enable_beacon)
-                                       vnt_beacon_make(pDevice, pDevice->vif);
-                       }
+               if (isr & ISR_SOFTTIMER1) {
+                       if (priv->vif->bss_conf.enable_beacon)
+                               vnt_beacon_make(priv, priv->vif);
                }
 
                /* If both buffers available wake the queue */
-               if (pDevice->vif) {
-                       if (AVAIL_TD(pDevice, TYPE_TXDMA0) &&
-                           AVAIL_TD(pDevice, TYPE_AC0DMA) &&
-                           ieee80211_queue_stopped(pDevice->hw, 0))
-                               ieee80211_wake_queues(pDevice->hw);
-               }
+               if (AVAIL_TD(priv, TYPE_TXDMA0) &&
+                   AVAIL_TD(priv, TYPE_AC0DMA) &&
+                   ieee80211_queue_stopped(priv->hw, 0))
+                       ieee80211_wake_queues(priv->hw);
 
-               MACvReadISR(pDevice->PortOffset, &pDevice->dwIsr);
+               MACvReadISR(priv->PortOffset, &isr);
 
-               MACvReceive0(pDevice->PortOffset);
-               MACvReceive1(pDevice->PortOffset);
+               MACvReceive0(priv->PortOffset);
+               MACvReceive1(priv->PortOffset);
 
-               if (max_count > pDevice->sOpts.int_works)
+               if (max_count > priv->opts.int_works)
                        break;
        }
 
-       if (byOrgPageSel == 1)
-               MACvSelectPage1(pDevice->PortOffset);
+       spin_unlock_irqrestore(&priv->lock, flags);
 
-       spin_unlock_irqrestore(&pDevice->lock, flags);
+       MACvIntEnable(priv->PortOffset, IMR_MASK_VALUE);
+}
 
-       MACvIntEnable(pDevice->PortOffset, IMR_MASK_VALUE);
+static void vnt_interrupt_work(struct work_struct *work)
+{
+       struct vnt_private *priv =
+               container_of(work, struct vnt_private, interrupt_work);
 
-       return IRQ_RETVAL(handled);
+       if (priv->vif)
+               vnt_interrupt_process(priv);
+}
+
+static irqreturn_t vnt_interrupt(int irq,  void *arg)
+{
+       struct vnt_private *priv = arg;
+
+       if (priv->vif)
+               schedule_work(&priv->interrupt_work);
+
+       return IRQ_HANDLED;
 }
 
 static int vnt_tx_packet(struct vnt_private *priv, struct sk_buff *skb)
 {
        struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
-       PSTxDesc head_td;
+       struct vnt_tx_desc *head_td;
        u32 dma_idx;
        unsigned long flags;
 
@@ -1198,17 +1101,18 @@ static int vnt_tx_packet(struct vnt_private *priv, struct sk_buff *skb)
 
        if (AVAIL_TD(priv, dma_idx) < 1) {
                spin_unlock_irqrestore(&priv->lock, flags);
+               ieee80211_stop_queues(priv->hw);
                return -ENOMEM;
        }
 
        head_td = priv->apCurrTD[dma_idx];
 
-       head_td->m_td1TD1.byTCR = 0;
+       head_td->td1.tcr = 0;
 
-       head_td->pTDInfo->skb = skb;
+       head_td->td_info->skb = skb;
 
        if (dma_idx == TYPE_AC0DMA)
-               head_td->pTDInfo->byFlags = TD_FLAGS_NETIF_SKB;
+               head_td->td_info->flags = TD_FLAGS_NETIF_SKB;
 
        priv->apCurrTD[dma_idx] = head_td->next;
 
@@ -1216,26 +1120,22 @@ static int vnt_tx_packet(struct vnt_private *priv, struct sk_buff *skb)
 
        vnt_generate_fifo_header(priv, dma_idx, head_td, skb);
 
-       if (MACbIsRegBitsOn(priv->PortOffset, MAC_REG_PSCTL, PSCTL_PS))
-               MACbPSWakeup(priv->PortOffset);
-
        spin_lock_irqsave(&priv->lock, flags);
 
        priv->bPWBitOn = false;
 
        /* Set TSR1 & ReqCount in TxDescHead */
-       head_td->m_td1TD1.byTCR |= (TCR_STP | TCR_EDP | EDMSDU);
-       head_td->m_td1TD1.wReqCount =
-                       cpu_to_le16((u16)head_td->pTDInfo->dwReqCount);
+       head_td->td1.tcr |= (TCR_STP | TCR_EDP | EDMSDU);
+       head_td->td1.req_count = cpu_to_le16(head_td->td_info->req_count);
 
-       head_td->buff_addr = cpu_to_le32(head_td->pTDInfo->skb_dma);
+       head_td->buff_addr = cpu_to_le32(head_td->td_info->buf_dma);
 
        /* Poll Transmit the adapter */
        wmb();
-       head_td->m_td0TD0.f1Owner = OWNED_BY_NIC;
+       head_td->td0.owner = OWNED_BY_NIC;
        wmb(); /* second memory barrier */
 
-       if (head_td->pTDInfo->byFlags & TD_FLAGS_NETIF_SKB)
+       if (head_td->td_info->flags & TD_FLAGS_NETIF_SKB)
                MACvTransmitAC0(priv->PortOffset);
        else
                MACvTransmit0(priv->PortOffset);
@@ -1253,13 +1153,8 @@ static void vnt_tx_80211(struct ieee80211_hw *hw,
 {
        struct vnt_private *priv = hw->priv;
 
-       ieee80211_stop_queues(hw);
-
-       if (vnt_tx_packet(priv, skb)) {
+       if (vnt_tx_packet(priv, skb))
                ieee80211_free_txskb(hw, skb);
-
-               ieee80211_wake_queues(hw);
-       }
 }
 
 static int vnt_start(struct ieee80211_hw *hw)
@@ -1271,7 +1166,7 @@ static int vnt_start(struct ieee80211_hw *hw)
        if (!device_init_rings(priv))
                return -ENOMEM;
 
-       ret = request_irq(priv->pcid->irq, &device_intr,
+       ret = request_irq(priv->pcid->irq, &vnt_interrupt,
                          IRQF_SHARED, "vt6655", priv);
        if (ret) {
                dev_dbg(&priv->pcid->dev, "failed to start irq\n");
@@ -1300,6 +1195,8 @@ static void vnt_stop(struct ieee80211_hw *hw)
 
        ieee80211_stop_queues(hw);
 
+       cancel_work_sync(&priv->interrupt_work);
+
        MACbShutdown(priv->PortOffset);
        MACbSoftwareReset(priv->PortOffset);
        CARDbRadioPowerOff(priv);
@@ -1529,21 +1426,12 @@ static void vnt_configure(struct ieee80211_hw *hw,
        struct vnt_private *priv = hw->priv;
        u8 rx_mode = 0;
 
-       *total_flags &= FIF_ALLMULTI | FIF_OTHER_BSS | FIF_PROMISC_IN_BSS |
-               FIF_BCN_PRBRESP_PROMISC;
+       *total_flags &= FIF_ALLMULTI | FIF_OTHER_BSS | FIF_BCN_PRBRESP_PROMISC;
 
        VNSvInPortB(priv->PortOffset + MAC_REG_RCR, &rx_mode);
 
        dev_dbg(&priv->pcid->dev, "rx mode in = %x\n", rx_mode);
 
-       if (changed_flags & FIF_PROMISC_IN_BSS) {
-               /* unconditionally log net taps */
-               if (*total_flags & FIF_PROMISC_IN_BSS)
-                       rx_mode |= RCR_UNICAST;
-               else
-                       rx_mode &= ~RCR_UNICAST;
-       }
-
        if (changed_flags & FIF_ALLMULTI) {
                if (*total_flags & FIF_ALLMULTI) {
                        unsigned long flags;
@@ -1614,6 +1502,16 @@ static int vnt_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
        return 0;
 }
 
+static int vnt_get_stats(struct ieee80211_hw *hw,
+                        struct ieee80211_low_level_stats *stats)
+{
+       struct vnt_private *priv = hw->priv;
+
+       memcpy(stats, &priv->low_stats, sizeof(*stats));
+
+       return 0;
+}
+
 static u64 vnt_get_tsf(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
 {
        struct vnt_private *priv = hw->priv;
@@ -1651,6 +1549,7 @@ static const struct ieee80211_ops vnt_mac_ops = {
        .prepare_multicast      = vnt_prepare_multicast,
        .configure_filter       = vnt_configure,
        .set_key                = vnt_set_key,
+       .get_stats              = vnt_get_stats,
        .get_tsf                = vnt_get_tsf,
        .set_tsf                = vnt_set_tsf,
        .reset_tsf              = vnt_reset_tsf,
@@ -1675,7 +1574,6 @@ static int vnt_init(struct vnt_private *priv)
 static int
 vt6655_probe(struct pci_dev *pcid, const struct pci_device_id *ent)
 {
-       PCHIP_INFO  pChip_info = (PCHIP_INFO)ent->driver_data;
        struct vnt_private *priv;
        struct ieee80211_hw *hw;
        struct wiphy *wiphy;
@@ -1694,8 +1592,9 @@ vt6655_probe(struct pci_dev *pcid, const struct pci_device_id *ent)
        }
 
        priv = hw->priv;
+       priv->pcid = pcid;
 
-       vt6655_init_info(pcid, &priv, pChip_info);
+       spin_lock_init(&priv->lock);
 
        priv->hw = hw;
 
@@ -1709,60 +1608,12 @@ vt6655_probe(struct pci_dev *pcid, const struct pci_device_id *ent)
        dev_dbg(&pcid->dev,
                "Before get pci_info memaddr is %x\n", priv->memaddr);
 
-       if (!device_get_pci_info(priv, pcid)) {
-               dev_err(&pcid->dev, ": Failed to find PCI device.\n");
-               device_free_info(priv);
-               return -ENODEV;
-       }
-
-#ifdef DEBUG
-       dev_dbg(&pcid->dev,
-               "after get pci_info memaddr is %x, io addr is %x,io_size is %d\n",
-               priv->memaddr, priv->ioaddr, priv->io_size);
-       {
-               int i;
-               u32 bar, len;
-               u32 address[] = {
-                       PCI_BASE_ADDRESS_0,
-                       PCI_BASE_ADDRESS_1,
-                       PCI_BASE_ADDRESS_2,
-                       PCI_BASE_ADDRESS_3,
-                       PCI_BASE_ADDRESS_4,
-                       PCI_BASE_ADDRESS_5,
-                       0};
-               for (i = 0; address[i]; i++) {
-                       pci_read_config_dword(pcid, address[i], &bar);
-
-                       dev_dbg(&pcid->dev, "bar %d is %x\n", i, bar);
-
-                       if (!bar) {
-                               dev_dbg(&pcid->dev,
-                                       "bar %d not implemented\n", i);
-                               continue;
-                       }
-
-                       if (bar & PCI_BASE_ADDRESS_SPACE_IO) {
-                               /* This is IO */
-
-                               len = bar & (PCI_BASE_ADDRESS_IO_MASK & 0xffff);
-                               len = len & ~(len - 1);
-
-                               dev_dbg(&pcid->dev,
-                                       "IO space:  len in IO %x, BAR %d\n",
-                                       len, i);
-                       } else {
-                               len = bar & 0xfffffff0;
-                               len = ~len + 1;
-
-                               dev_dbg(&pcid->dev,
-                                       "len in MEM %x, BAR %d\n", len, i);
-                       }
-               }
-       }
-#endif
+       pci_set_master(pcid);
 
+       priv->memaddr = pci_resource_start(pcid, 0);
+       priv->ioaddr = pci_resource_start(pcid, 1);
        priv->PortOffset = ioremap(priv->memaddr & PCI_BASE_ADDRESS_MEM_MASK,
-                                  priv->io_size);
+                                  256);
        if (!priv->PortOffset) {
                dev_err(&pcid->dev, ": Failed to IO remapping ..\n");
                device_free_info(priv);
@@ -1776,6 +1627,14 @@ vt6655_probe(struct pci_dev *pcid, const struct pci_device_id *ent)
                return -ENODEV;
        }
 
+       if (dma_set_mask(&pcid->dev, DMA_BIT_MASK(32))) {
+               dev_err(&pcid->dev, ": Failed to set dma 32 bit mask\n");
+               device_free_info(priv);
+               return -ENODEV;
+       }
+
+       INIT_WORK(&priv->interrupt_work, vnt_interrupt_work);
+
        /* do reset */
        if (!MACbSoftwareReset(priv->PortOffset)) {
                dev_err(&pcid->dev, ": Failed to access MAC hardware..\n");
@@ -1794,11 +1653,6 @@ vt6655_probe(struct pci_dev *pcid, const struct pci_device_id *ent)
 
        device_get_options(priv);
        device_set_options(priv);
-       /* Mask out the options cannot be set to the chip */
-       priv->sOpts.flags &= pChip_info->flags;
-
-       /* Enable the chip specified capabilities */
-       priv->flags = priv->sOpts.flags | (pChip_info->flags & 0xff000000UL);
 
        wiphy = priv->hw->wiphy;
 
@@ -1807,10 +1661,11 @@ vt6655_probe(struct pci_dev *pcid, const struct pci_device_id *ent)
        wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION) |
                BIT(NL80211_IFTYPE_ADHOC) | BIT(NL80211_IFTYPE_AP);
 
-       priv->hw->flags = IEEE80211_HW_RX_INCLUDES_FCS |
-               IEEE80211_HW_REPORTS_TX_ACK_STATUS |
-               IEEE80211_HW_SIGNAL_DBM |
-               IEEE80211_HW_TIMING_BEACON_ONLY;
+       ieee80211_hw_set(priv->hw, TIMING_BEACON_ONLY);
+       ieee80211_hw_set(priv->hw, SIGNAL_DBM);
+       ieee80211_hw_set(priv->hw, RX_INCLUDES_FCS);
+       ieee80211_hw_set(priv->hw, REPORTS_TX_ACK_STATUS);
+       ieee80211_hw_set(priv->hw, SUPPORTS_PS);
 
        priv->hw->max_signal = 100;
 
@@ -1869,47 +1724,4 @@ static struct pci_driver device_driver = {
 #endif
 };
 
-static int __init vt6655_init_module(void)
-{
-       int ret;
-
-       ret = pci_register_driver(&device_driver);
-#ifdef CONFIG_PM
-       if (ret >= 0)
-               register_reboot_notifier(&device_notifier);
-#endif
-
-       return ret;
-}
-
-static void __exit vt6655_cleanup_module(void)
-{
-#ifdef CONFIG_PM
-       unregister_reboot_notifier(&device_notifier);
-#endif
-       pci_unregister_driver(&device_driver);
-}
-
-module_init(vt6655_init_module);
-module_exit(vt6655_cleanup_module);
-
-#ifdef CONFIG_PM
-static int
-device_notify_reboot(struct notifier_block *nb, unsigned long event, void *p)
-{
-       struct pci_dev *pdev = NULL;
-
-       switch (event) {
-       case SYS_DOWN:
-       case SYS_HALT:
-       case SYS_POWER_OFF:
-               for_each_pci_dev(pdev) {
-                       if (pci_dev_driver(pdev) == &device_driver) {
-                               if (pci_get_drvdata(pdev))
-                                       vt6655_suspend(pdev, PMSG_HIBERNATE);
-                       }
-               }
-       }
-       return NOTIFY_DONE;
-}
-#endif
+module_pci_driver(device_driver);