diff options
Diffstat (limited to 'drivers/staging/vt6655')
-rw-r--r-- | drivers/staging/vt6655/baseband.c | 14 | ||||
-rw-r--r-- | drivers/staging/vt6655/card.c | 398 | ||||
-rw-r--r-- | drivers/staging/vt6655/desc.h | 58 | ||||
-rw-r--r-- | drivers/staging/vt6655/device.h | 149 | ||||
-rw-r--r-- | drivers/staging/vt6655/device_main.c | 866 | ||||
-rw-r--r-- | drivers/staging/vt6655/dpc.c | 8 | ||||
-rw-r--r-- | drivers/staging/vt6655/dpc.h | 2 | ||||
-rw-r--r-- | drivers/staging/vt6655/mac.c | 3 | ||||
-rw-r--r-- | drivers/staging/vt6655/rf.c | 12 | ||||
-rw-r--r-- | drivers/staging/vt6655/rf.h | 4 | ||||
-rw-r--r-- | drivers/staging/vt6655/rxtx.c | 6 |
11 files changed, 638 insertions, 882 deletions
diff --git a/drivers/staging/vt6655/baseband.c b/drivers/staging/vt6655/baseband.c index 9e61f2df3..1e6c0c4a0 100644 --- a/drivers/staging/vt6655/baseband.c +++ b/drivers/staging/vt6655/baseband.c @@ -2089,9 +2089,19 @@ bool BBbVT3253Init(struct vnt_private *priv) byVT3253B0_UW2451[ii][0], byVT3253B0_UW2451[ii][1]); - /* Init ANT B select,TX Config CR09 = 0x61->0x45, 0x45->0x41(VC1/VC2 define, make the ANT_A, ANT_B inverted) */ + /* Init ANT B select, + * TX Config CR09 = 0x61->0x45, + * 0x45->0x41(VC1/VC2 define, make the ANT_A, ANT_B inverted) + */ + /*bResult &= BBbWriteEmbedded(dwIoBase,0x09,0x41);*/ - /* Init ANT B select,RX Config CR10 = 0x28->0x2A, 0x2A->0x28(VC1/VC2 define, make the ANT_A, ANT_B inverted) */ + + /* Init ANT B select, + * RX Config CR10 = 0x28->0x2A, + * 0x2A->0x28(VC1/VC2 define, + * make the ANT_A, ANT_B inverted) + */ + /*bResult &= BBbWriteEmbedded(dwIoBase,0x0a,0x28);*/ /* Select VC1/VC2, CR215 = 0x02->0x06 */ bResult &= BBbWriteEmbedded(priv, 0xd7, 0x06); diff --git a/drivers/staging/vt6655/card.c b/drivers/staging/vt6655/card.c index c7b75dfc2..b6730a806 100644 --- a/drivers/staging/vt6655/card.c +++ b/drivers/staging/vt6655/card.c @@ -197,13 +197,13 @@ s_vCalculateOFDMRParameter( * * Parameters: * In: - * pDevice - The adapter to be set + * priv - The adapter to be set * Out: * none * * Return Value: None. */ -bool CARDbSetPhyParameter(struct vnt_private *pDevice, u8 bb_type) +bool CARDbSetPhyParameter(struct vnt_private *priv, u8 bb_type) { unsigned char byCWMaxMin = 0; unsigned char bySlot = 0; @@ -214,79 +214,79 @@ bool CARDbSetPhyParameter(struct vnt_private *pDevice, u8 bb_type) /* Set SIFS, DIFS, EIFS, SlotTime, CwMin */ if (bb_type == BB_TYPE_11A) { - if (pDevice->byRFType == RF_AIROHA7230) { + if (priv->byRFType == RF_AIROHA7230) { /* AL7230 use single PAPE and connect to PAPE_2.4G */ - MACvSetBBType(pDevice->PortOffset, BB_TYPE_11G); - pDevice->abyBBVGA[0] = 0x20; - pDevice->abyBBVGA[2] = 0x10; - pDevice->abyBBVGA[3] = 0x10; - BBbReadEmbedded(pDevice, 0xE7, &byData); + MACvSetBBType(priv->PortOffset, BB_TYPE_11G); + priv->abyBBVGA[0] = 0x20; + priv->abyBBVGA[2] = 0x10; + priv->abyBBVGA[3] = 0x10; + BBbReadEmbedded(priv, 0xE7, &byData); if (byData == 0x1C) - BBbWriteEmbedded(pDevice, 0xE7, pDevice->abyBBVGA[0]); + BBbWriteEmbedded(priv, 0xE7, priv->abyBBVGA[0]); - } else if (pDevice->byRFType == RF_UW2452) { - MACvSetBBType(pDevice->PortOffset, BB_TYPE_11A); - pDevice->abyBBVGA[0] = 0x18; - BBbReadEmbedded(pDevice, 0xE7, &byData); + } else if (priv->byRFType == RF_UW2452) { + MACvSetBBType(priv->PortOffset, BB_TYPE_11A); + priv->abyBBVGA[0] = 0x18; + BBbReadEmbedded(priv, 0xE7, &byData); if (byData == 0x14) { - BBbWriteEmbedded(pDevice, 0xE7, pDevice->abyBBVGA[0]); - BBbWriteEmbedded(pDevice, 0xE1, 0x57); + BBbWriteEmbedded(priv, 0xE7, priv->abyBBVGA[0]); + BBbWriteEmbedded(priv, 0xE1, 0x57); } } else { - MACvSetBBType(pDevice->PortOffset, BB_TYPE_11A); + MACvSetBBType(priv->PortOffset, BB_TYPE_11A); } - BBbWriteEmbedded(pDevice, 0x88, 0x03); + BBbWriteEmbedded(priv, 0x88, 0x03); bySlot = C_SLOT_SHORT; bySIFS = C_SIFS_A; - byDIFS = C_SIFS_A + 2*C_SLOT_SHORT; + byDIFS = C_SIFS_A + 2 * C_SLOT_SHORT; byCWMaxMin = 0xA4; } else if (bb_type == BB_TYPE_11B) { - MACvSetBBType(pDevice->PortOffset, BB_TYPE_11B); - if (pDevice->byRFType == RF_AIROHA7230) { - pDevice->abyBBVGA[0] = 0x1C; - pDevice->abyBBVGA[2] = 0x00; - pDevice->abyBBVGA[3] = 0x00; - BBbReadEmbedded(pDevice, 0xE7, &byData); + MACvSetBBType(priv->PortOffset, BB_TYPE_11B); + if (priv->byRFType == RF_AIROHA7230) { + priv->abyBBVGA[0] = 0x1C; + priv->abyBBVGA[2] = 0x00; + priv->abyBBVGA[3] = 0x00; + BBbReadEmbedded(priv, 0xE7, &byData); if (byData == 0x20) - BBbWriteEmbedded(pDevice, 0xE7, pDevice->abyBBVGA[0]); + BBbWriteEmbedded(priv, 0xE7, priv->abyBBVGA[0]); - } else if (pDevice->byRFType == RF_UW2452) { - pDevice->abyBBVGA[0] = 0x14; - BBbReadEmbedded(pDevice, 0xE7, &byData); + } else if (priv->byRFType == RF_UW2452) { + priv->abyBBVGA[0] = 0x14; + BBbReadEmbedded(priv, 0xE7, &byData); if (byData == 0x18) { - BBbWriteEmbedded(pDevice, 0xE7, pDevice->abyBBVGA[0]); - BBbWriteEmbedded(pDevice, 0xE1, 0xD3); + BBbWriteEmbedded(priv, 0xE7, priv->abyBBVGA[0]); + BBbWriteEmbedded(priv, 0xE1, 0xD3); } } - BBbWriteEmbedded(pDevice, 0x88, 0x02); + BBbWriteEmbedded(priv, 0x88, 0x02); bySlot = C_SLOT_LONG; bySIFS = C_SIFS_BG; byDIFS = C_SIFS_BG + 2*C_SLOT_LONG; byCWMaxMin = 0xA5; } else { /* PK_TYPE_11GA & PK_TYPE_11GB */ - MACvSetBBType(pDevice->PortOffset, BB_TYPE_11G); - if (pDevice->byRFType == RF_AIROHA7230) { - pDevice->abyBBVGA[0] = 0x1C; - pDevice->abyBBVGA[2] = 0x00; - pDevice->abyBBVGA[3] = 0x00; - BBbReadEmbedded(pDevice, 0xE7, &byData); + MACvSetBBType(priv->PortOffset, BB_TYPE_11G); + if (priv->byRFType == RF_AIROHA7230) { + priv->abyBBVGA[0] = 0x1C; + priv->abyBBVGA[2] = 0x00; + priv->abyBBVGA[3] = 0x00; + BBbReadEmbedded(priv, 0xE7, &byData); if (byData == 0x20) - BBbWriteEmbedded(pDevice, 0xE7, pDevice->abyBBVGA[0]); + BBbWriteEmbedded(priv, 0xE7, priv->abyBBVGA[0]); - } else if (pDevice->byRFType == RF_UW2452) { - pDevice->abyBBVGA[0] = 0x14; - BBbReadEmbedded(pDevice, 0xE7, &byData); + } else if (priv->byRFType == RF_UW2452) { + priv->abyBBVGA[0] = 0x14; + BBbReadEmbedded(priv, 0xE7, &byData); if (byData == 0x18) { - BBbWriteEmbedded(pDevice, 0xE7, pDevice->abyBBVGA[0]); - BBbWriteEmbedded(pDevice, 0xE1, 0xD3); + BBbWriteEmbedded(priv, 0xE7, priv->abyBBVGA[0]); + BBbWriteEmbedded(priv, 0xE1, 0xD3); } } - BBbWriteEmbedded(pDevice, 0x88, 0x08); + BBbWriteEmbedded(priv, 0x88, 0x08); bySIFS = C_SIFS_BG; - if (pDevice->bShortSlotTime) { + if (priv->bShortSlotTime) { bySlot = C_SLOT_SHORT; - byDIFS = C_SIFS_BG + 2*C_SLOT_SHORT; + byDIFS = C_SIFS_BG + 2 * C_SLOT_SHORT; } else { bySlot = C_SLOT_LONG; byDIFS = C_SIFS_BG + 2*C_SLOT_LONG; @@ -295,14 +295,14 @@ bool CARDbSetPhyParameter(struct vnt_private *pDevice, u8 bb_type) byCWMaxMin = 0xa4; for (i = RATE_54M; i >= RATE_6M; i--) { - if (pDevice->basic_rates & ((u32)(0x1 << i))) { + if (priv->basic_rates & ((u32)(0x1 << i))) { byCWMaxMin |= 0x1; break; } } } - if (pDevice->byRFType == RF_RFMD2959) { + if (priv->byRFType == RF_RFMD2959) { /* * bcs TX_PE will reserve 3 us hardware's processing * time here is 2 us. @@ -316,32 +316,32 @@ bool CARDbSetPhyParameter(struct vnt_private *pDevice, u8 bb_type) */ } - if (pDevice->bySIFS != bySIFS) { - pDevice->bySIFS = bySIFS; - VNSvOutPortB(pDevice->PortOffset + MAC_REG_SIFS, pDevice->bySIFS); + if (priv->bySIFS != bySIFS) { + priv->bySIFS = bySIFS; + VNSvOutPortB(priv->PortOffset + MAC_REG_SIFS, priv->bySIFS); } - if (pDevice->byDIFS != byDIFS) { - pDevice->byDIFS = byDIFS; - VNSvOutPortB(pDevice->PortOffset + MAC_REG_DIFS, pDevice->byDIFS); + if (priv->byDIFS != byDIFS) { + priv->byDIFS = byDIFS; + VNSvOutPortB(priv->PortOffset + MAC_REG_DIFS, priv->byDIFS); } - if (pDevice->byEIFS != C_EIFS) { - pDevice->byEIFS = C_EIFS; - VNSvOutPortB(pDevice->PortOffset + MAC_REG_EIFS, pDevice->byEIFS); + if (priv->byEIFS != C_EIFS) { + priv->byEIFS = C_EIFS; + VNSvOutPortB(priv->PortOffset + MAC_REG_EIFS, priv->byEIFS); } - if (pDevice->bySlot != bySlot) { - pDevice->bySlot = bySlot; - VNSvOutPortB(pDevice->PortOffset + MAC_REG_SLOT, pDevice->bySlot); + if (priv->bySlot != bySlot) { + priv->bySlot = bySlot; + VNSvOutPortB(priv->PortOffset + MAC_REG_SLOT, priv->bySlot); - BBvSetShortSlotTime(pDevice); + BBvSetShortSlotTime(priv); } - if (pDevice->byCWMaxMin != byCWMaxMin) { - pDevice->byCWMaxMin = byCWMaxMin; - VNSvOutPortB(pDevice->PortOffset + MAC_REG_CWMAXMIN0, pDevice->byCWMaxMin); + if (priv->byCWMaxMin != byCWMaxMin) { + priv->byCWMaxMin = byCWMaxMin; + VNSvOutPortB(priv->PortOffset + MAC_REG_CWMAXMIN0, priv->byCWMaxMin); } - pDevice->byPacketType = CARDbyGetPktType(pDevice); + priv->byPacketType = CARDbyGetPktType(priv); - CARDvSetRSPINF(pDevice, bb_type); + CARDvSetRSPINF(priv, bb_type); return true; } @@ -352,7 +352,7 @@ bool CARDbSetPhyParameter(struct vnt_private *pDevice, u8 bb_type) * * Parameters: * In: - * pDevice - The adapter to be sync. + * priv - The adapter to be sync. * byRxRate - data rate of receive beacon * qwBSSTimestamp - Rx BCN's TSF * qwLocalTSF - Local TSF @@ -361,21 +361,21 @@ bool CARDbSetPhyParameter(struct vnt_private *pDevice, u8 bb_type) * * Return Value: none */ -bool CARDbUpdateTSF(struct vnt_private *pDevice, unsigned char byRxRate, +bool CARDbUpdateTSF(struct vnt_private *priv, unsigned char byRxRate, u64 qwBSSTimestamp) { u64 local_tsf; u64 qwTSFOffset = 0; - CARDbGetCurrentTSF(pDevice, &local_tsf); + CARDbGetCurrentTSF(priv, &local_tsf); if (qwBSSTimestamp != local_tsf) { qwTSFOffset = CARDqGetTSFOffset(byRxRate, qwBSSTimestamp, local_tsf); /* adjust TSF, HW's TSF add TSF Offset reg */ - VNSvOutPortD(pDevice->PortOffset + MAC_REG_TSFOFST, (u32)qwTSFOffset); - VNSvOutPortD(pDevice->PortOffset + MAC_REG_TSFOFST + 4, (u32)(qwTSFOffset >> 32)); - MACvRegBitsOn(pDevice->PortOffset, MAC_REG_TFTCTL, TFTCTL_TSFSYNCEN); + VNSvOutPortD(priv->PortOffset + MAC_REG_TSFOFST, (u32)qwTSFOffset); + VNSvOutPortD(priv->PortOffset + MAC_REG_TSFOFST + 4, (u32)(qwTSFOffset >> 32)); + MACvRegBitsOn(priv->PortOffset, MAC_REG_TFTCTL, TFTCTL_TSFSYNCEN); } return true; } @@ -386,29 +386,29 @@ bool CARDbUpdateTSF(struct vnt_private *pDevice, unsigned char byRxRate, * * Parameters: * In: - * pDevice - The adapter to be set. + * priv - The adapter to be set. * wBeaconInterval - Beacon Interval * Out: * none * * Return Value: true if succeed; otherwise false */ -bool CARDbSetBeaconPeriod(struct vnt_private *pDevice, +bool CARDbSetBeaconPeriod(struct vnt_private *priv, unsigned short wBeaconInterval) { u64 qwNextTBTT = 0; - CARDbGetCurrentTSF(pDevice, &qwNextTBTT); /* Get Local TSF counter */ + CARDbGetCurrentTSF(priv, &qwNextTBTT); /* Get Local TSF counter */ qwNextTBTT = CARDqGetNextTBTT(qwNextTBTT, wBeaconInterval); /* set HW beacon interval */ - VNSvOutPortW(pDevice->PortOffset + MAC_REG_BI, wBeaconInterval); - pDevice->wBeaconInterval = wBeaconInterval; + VNSvOutPortW(priv->PortOffset + MAC_REG_BI, wBeaconInterval); + priv->wBeaconInterval = wBeaconInterval; /* Set NextTBTT */ - VNSvOutPortD(pDevice->PortOffset + MAC_REG_NEXTTBTT, (u32)qwNextTBTT); - VNSvOutPortD(pDevice->PortOffset + MAC_REG_NEXTTBTT + 4, (u32)(qwNextTBTT >> 32)); - MACvRegBitsOn(pDevice->PortOffset, MAC_REG_TFTCTL, TFTCTL_TBTTSYNCEN); + VNSvOutPortD(priv->PortOffset + MAC_REG_NEXTTBTT, (u32)qwNextTBTT); + VNSvOutPortD(priv->PortOffset + MAC_REG_NEXTTBTT + 4, (u32)(qwNextTBTT >> 32)); + MACvRegBitsOn(priv->PortOffset, MAC_REG_TFTCTL, TFTCTL_TBTTSYNCEN); return true; } @@ -418,41 +418,41 @@ bool CARDbSetBeaconPeriod(struct vnt_private *pDevice, * * Parameters: * In: - * pDevice - The adapter to be turned off + * priv - The adapter to be turned off * Out: * none * * Return Value: true if success; otherwise false */ -bool CARDbRadioPowerOff(struct vnt_private *pDevice) +bool CARDbRadioPowerOff(struct vnt_private *priv) { bool bResult = true; - if (pDevice->bRadioOff == true) + if (priv->bRadioOff) return true; - switch (pDevice->byRFType) { + switch (priv->byRFType) { case RF_RFMD2959: - MACvWordRegBitsOff(pDevice->PortOffset, MAC_REG_SOFTPWRCTL, SOFTPWRCTL_TXPEINV); - MACvWordRegBitsOn(pDevice->PortOffset, MAC_REG_SOFTPWRCTL, SOFTPWRCTL_SWPE1); + MACvWordRegBitsOff(priv->PortOffset, MAC_REG_SOFTPWRCTL, SOFTPWRCTL_TXPEINV); + MACvWordRegBitsOn(priv->PortOffset, MAC_REG_SOFTPWRCTL, SOFTPWRCTL_SWPE1); break; case RF_AIROHA: case RF_AL2230S: case RF_AIROHA7230: - MACvWordRegBitsOff(pDevice->PortOffset, MAC_REG_SOFTPWRCTL, SOFTPWRCTL_SWPE2); - MACvWordRegBitsOff(pDevice->PortOffset, MAC_REG_SOFTPWRCTL, SOFTPWRCTL_SWPE3); + MACvWordRegBitsOff(priv->PortOffset, MAC_REG_SOFTPWRCTL, SOFTPWRCTL_SWPE2); + MACvWordRegBitsOff(priv->PortOffset, MAC_REG_SOFTPWRCTL, SOFTPWRCTL_SWPE3); break; } - MACvRegBitsOff(pDevice->PortOffset, MAC_REG_HOSTCR, HOSTCR_RXON); + MACvRegBitsOff(priv->PortOffset, MAC_REG_HOSTCR, HOSTCR_RXON); - BBvSetDeepSleep(pDevice, pDevice->byLocalID); + BBvSetDeepSleep(priv, priv->byLocalID); - pDevice->bRadioOff = true; + priv->bRadioOff = true; pr_debug("chester power off\n"); - MACvRegBitsOn(pDevice->PortOffset, MAC_REG_GPIOCTL0, LED_ACTSET); /* LED issue */ + MACvRegBitsOn(priv->PortOffset, MAC_REG_GPIOCTL0, LED_ACTSET); /* LED issue */ return bResult; } @@ -461,89 +461,89 @@ bool CARDbRadioPowerOff(struct vnt_private *pDevice) * * Parameters: * In: - * pDevice - The adapter to be turned on + * priv - The adapter to be turned on * Out: * none * * Return Value: true if success; otherwise false */ -bool CARDbRadioPowerOn(struct vnt_private *pDevice) +bool CARDbRadioPowerOn(struct vnt_private *priv) { bool bResult = true; pr_debug("chester power on\n"); - if (pDevice->bRadioControlOff == true) { - if (pDevice->bHWRadioOff == true) + if (priv->bRadioControlOff) { + if (priv->bHWRadioOff) pr_debug("chester bHWRadioOff\n"); - if (pDevice->bRadioControlOff == true) + if (priv->bRadioControlOff) pr_debug("chester bRadioControlOff\n"); return false; } - if (pDevice->bRadioOff == false) { + if (!priv->bRadioOff) { pr_debug("chester pbRadioOff\n"); return true; } - BBvExitDeepSleep(pDevice, pDevice->byLocalID); + BBvExitDeepSleep(priv, priv->byLocalID); - MACvRegBitsOn(pDevice->PortOffset, MAC_REG_HOSTCR, HOSTCR_RXON); + MACvRegBitsOn(priv->PortOffset, MAC_REG_HOSTCR, HOSTCR_RXON); - switch (pDevice->byRFType) { + switch (priv->byRFType) { case RF_RFMD2959: - MACvWordRegBitsOn(pDevice->PortOffset, MAC_REG_SOFTPWRCTL, SOFTPWRCTL_TXPEINV); - MACvWordRegBitsOff(pDevice->PortOffset, MAC_REG_SOFTPWRCTL, SOFTPWRCTL_SWPE1); + MACvWordRegBitsOn(priv->PortOffset, MAC_REG_SOFTPWRCTL, SOFTPWRCTL_TXPEINV); + MACvWordRegBitsOff(priv->PortOffset, MAC_REG_SOFTPWRCTL, SOFTPWRCTL_SWPE1); break; case RF_AIROHA: case RF_AL2230S: case RF_AIROHA7230: - MACvWordRegBitsOn(pDevice->PortOffset, MAC_REG_SOFTPWRCTL, (SOFTPWRCTL_SWPE2 | + MACvWordRegBitsOn(priv->PortOffset, MAC_REG_SOFTPWRCTL, (SOFTPWRCTL_SWPE2 | SOFTPWRCTL_SWPE3)); break; } - pDevice->bRadioOff = false; + priv->bRadioOff = false; pr_debug("chester power on\n"); - MACvRegBitsOff(pDevice->PortOffset, MAC_REG_GPIOCTL0, LED_ACTSET); /* LED issue */ + MACvRegBitsOff(priv->PortOffset, MAC_REG_GPIOCTL0, LED_ACTSET); /* LED issue */ return bResult; } void CARDvSafeResetTx( - struct vnt_private *pDevice + struct vnt_private *priv ) { unsigned int uu; struct vnt_tx_desc *pCurrTD; /* initialize TD index */ - pDevice->apTailTD[0] = pDevice->apCurrTD[0] = &(pDevice->apTD0Rings[0]); - pDevice->apTailTD[1] = pDevice->apCurrTD[1] = &(pDevice->apTD1Rings[0]); + priv->apTailTD[0] = priv->apCurrTD[0] = &(priv->apTD0Rings[0]); + priv->apTailTD[1] = priv->apCurrTD[1] = &(priv->apTD1Rings[0]); for (uu = 0; uu < TYPE_MAXTD; uu++) - pDevice->iTDUsed[uu] = 0; + priv->iTDUsed[uu] = 0; - for (uu = 0; uu < pDevice->sOpts.nTxDescs[0]; uu++) { - pCurrTD = &(pDevice->apTD0Rings[uu]); + for (uu = 0; uu < priv->opts.tx_descs[0]; uu++) { + pCurrTD = &(priv->apTD0Rings[uu]); pCurrTD->td0.owner = OWNED_BY_HOST; /* init all Tx Packet pointer to NULL */ } - for (uu = 0; uu < pDevice->sOpts.nTxDescs[1]; uu++) { - pCurrTD = &(pDevice->apTD1Rings[uu]); + for (uu = 0; uu < priv->opts.tx_descs[1]; uu++) { + pCurrTD = &(priv->apTD1Rings[uu]); pCurrTD->td0.owner = OWNED_BY_HOST; /* init all Tx Packet pointer to NULL */ } /* set MAC TD pointer */ - MACvSetCurrTXDescAddr(TYPE_TXDMA0, pDevice->PortOffset, - (pDevice->td0_pool_dma)); + MACvSetCurrTXDescAddr(TYPE_TXDMA0, priv->PortOffset, + (priv->td0_pool_dma)); - MACvSetCurrTXDescAddr(TYPE_AC0DMA, pDevice->PortOffset, - (pDevice->td1_pool_dma)); + MACvSetCurrTXDescAddr(TYPE_AC0DMA, priv->PortOffset, + (priv->td1_pool_dma)); /* set MAC Beacon TX pointer */ - MACvSetCurrBCNTxDescAddr(pDevice->PortOffset, - (pDevice->tx_beacon_dma)); + MACvSetCurrBCNTxDescAddr(priv->PortOffset, + (priv->tx_beacon_dma)); } /* @@ -552,7 +552,7 @@ CARDvSafeResetTx( * * Parameters: * In: - * pDevice - Pointer to the adapter + * priv - Pointer to the adapter * Out: * none * @@ -560,41 +560,41 @@ CARDvSafeResetTx( */ void CARDvSafeResetRx( - struct vnt_private *pDevice + struct vnt_private *priv ) { unsigned int uu; - PSRxDesc pDesc; + struct vnt_rx_desc *pDesc; /* initialize RD index */ - pDevice->pCurrRD[0] = &(pDevice->aRD0Ring[0]); - pDevice->pCurrRD[1] = &(pDevice->aRD1Ring[0]); + priv->pCurrRD[0] = &(priv->aRD0Ring[0]); + priv->pCurrRD[1] = &(priv->aRD1Ring[0]); /* init state, all RD is chip's */ - for (uu = 0; uu < pDevice->sOpts.nRxDescs0; uu++) { - pDesc = &(pDevice->aRD0Ring[uu]); - pDesc->m_rd0RD0.wResCount = cpu_to_le16(pDevice->rx_buf_sz); - pDesc->m_rd0RD0.f1Owner = OWNED_BY_NIC; - pDesc->m_rd1RD1.wReqCount = cpu_to_le16(pDevice->rx_buf_sz); + for (uu = 0; uu < priv->opts.rx_descs0; uu++) { + pDesc = &(priv->aRD0Ring[uu]); + pDesc->rd0.res_count = cpu_to_le16(priv->rx_buf_sz); + pDesc->rd0.owner = OWNED_BY_NIC; + pDesc->rd1.req_count = cpu_to_le16(priv->rx_buf_sz); } /* init state, all RD is chip's */ - for (uu = 0; uu < pDevice->sOpts.nRxDescs1; uu++) { - pDesc = &(pDevice->aRD1Ring[uu]); - pDesc->m_rd0RD0.wResCount = cpu_to_le16(pDevice->rx_buf_sz); - pDesc->m_rd0RD0.f1Owner = OWNED_BY_NIC; - pDesc->m_rd1RD1.wReqCount = cpu_to_le16(pDevice->rx_buf_sz); + for (uu = 0; uu < priv->opts.rx_descs1; uu++) { + pDesc = &(priv->aRD1Ring[uu]); + pDesc->rd0.res_count = cpu_to_le16(priv->rx_buf_sz); + pDesc->rd0.owner = OWNED_BY_NIC; + pDesc->rd1.req_count = cpu_to_le16(priv->rx_buf_sz); } /* set perPkt mode */ - MACvRx0PerPktMode(pDevice->PortOffset); - MACvRx1PerPktMode(pDevice->PortOffset); + MACvRx0PerPktMode(priv->PortOffset); + MACvRx1PerPktMode(priv->PortOffset); /* set MAC RD pointer */ - MACvSetCurrRx0DescAddr(pDevice->PortOffset, - pDevice->rd0_pool_dma); + MACvSetCurrRx0DescAddr(priv->PortOffset, + priv->rd0_pool_dma); - MACvSetCurrRx1DescAddr(pDevice->PortOffset, - pDevice->rd1_pool_dma); + MACvSetCurrRx1DescAddr(priv->PortOffset, + priv->rd1_pool_dma); } /* @@ -602,20 +602,20 @@ CARDvSafeResetRx( * * Parameters: * In: - * pDevice - The adapter to be set + * priv - The adapter to be set * wRateIdx - Receiving data rate * Out: * none * * Return Value: response Control frame rate */ -static unsigned short CARDwGetCCKControlRate(struct vnt_private *pDevice, +static unsigned short CARDwGetCCKControlRate(struct vnt_private *priv, unsigned short wRateIdx) { unsigned int ui = (unsigned int) wRateIdx; while (ui > RATE_1M) { - if (pDevice->basic_rates & ((u32)0x1 << ui)) + if (priv->basic_rates & ((u32)0x1 << ui)) return (unsigned short)ui; ui--; @@ -628,28 +628,28 @@ static unsigned short CARDwGetCCKControlRate(struct vnt_private *pDevice, * * Parameters: * In: - * pDevice - The adapter to be set + * priv - The adapter to be set * wRateIdx - Receiving data rate * Out: * none * * Return Value: response Control frame rate */ -static unsigned short CARDwGetOFDMControlRate(struct vnt_private *pDevice, +static unsigned short CARDwGetOFDMControlRate(struct vnt_private *priv, unsigned short wRateIdx) { unsigned int ui = (unsigned int) wRateIdx; - pr_debug("BASIC RATE: %X\n", pDevice->basic_rates); + pr_debug("BASIC RATE: %X\n", priv->basic_rates); - if (!CARDbIsOFDMinBasicRate((void *)pDevice)) { + if (!CARDbIsOFDMinBasicRate((void *)priv)) { pr_debug("CARDwGetOFDMControlRate:(NO OFDM) %d\n", wRateIdx); if (wRateIdx > RATE_24M) wRateIdx = RATE_24M; return wRateIdx; } while (ui > RATE_11M) { - if (pDevice->basic_rates & ((u32)0x1 << ui)) { + if (priv->basic_rates & ((u32)0x1 << ui)) { pr_debug("CARDwGetOFDMControlRate : %d\n", ui); return (unsigned short)ui; } @@ -664,162 +664,162 @@ static unsigned short CARDwGetOFDMControlRate(struct vnt_private *pDevice, * * Parameters: * In: - * pDevice - The adapter to be set + * priv - The adapter to be set * Out: * none * * Return Value: None. */ -void CARDvSetRSPINF(struct vnt_private *pDevice, u8 bb_type) +void CARDvSetRSPINF(struct vnt_private *priv, u8 bb_type) { union vnt_phy_field_swap phy; unsigned char byTxRate, byRsvTime; /* For OFDM */ unsigned long flags; - spin_lock_irqsave(&pDevice->lock, flags); + spin_lock_irqsave(&priv->lock, flags); /* Set to Page1 */ - MACvSelectPage1(pDevice->PortOffset); + MACvSelectPage1(priv->PortOffset); /* RSPINF_b_1 */ - vnt_get_phy_field(pDevice, 14, - CARDwGetCCKControlRate(pDevice, RATE_1M), + vnt_get_phy_field(priv, 14, + CARDwGetCCKControlRate(priv, RATE_1M), PK_TYPE_11B, &phy.field_read); /* swap over to get correct write order */ swap(phy.swap[0], phy.swap[1]); - VNSvOutPortD(pDevice->PortOffset + MAC_REG_RSPINF_B_1, phy.field_write); + VNSvOutPortD(priv->PortOffset + MAC_REG_RSPINF_B_1, phy.field_write); /* RSPINF_b_2 */ - vnt_get_phy_field(pDevice, 14, - CARDwGetCCKControlRate(pDevice, RATE_2M), + vnt_get_phy_field(priv, 14, + CARDwGetCCKControlRate(priv, RATE_2M), PK_TYPE_11B, &phy.field_read); swap(phy.swap[0], phy.swap[1]); - VNSvOutPortD(pDevice->PortOffset + MAC_REG_RSPINF_B_2, phy.field_write); + VNSvOutPortD(priv->PortOffset + MAC_REG_RSPINF_B_2, phy.field_write); /* RSPINF_b_5 */ - vnt_get_phy_field(pDevice, 14, - CARDwGetCCKControlRate(pDevice, RATE_5M), + vnt_get_phy_field(priv, 14, + CARDwGetCCKControlRate(priv, RATE_5M), PK_TYPE_11B, &phy.field_read); swap(phy.swap[0], phy.swap[1]); - VNSvOutPortD(pDevice->PortOffset + MAC_REG_RSPINF_B_5, phy.field_write); + VNSvOutPortD(priv->PortOffset + MAC_REG_RSPINF_B_5, phy.field_write); /* RSPINF_b_11 */ - vnt_get_phy_field(pDevice, 14, - CARDwGetCCKControlRate(pDevice, RATE_11M), + vnt_get_phy_field(priv, 14, + CARDwGetCCKControlRate(priv, RATE_11M), PK_TYPE_11B, &phy.field_read); swap(phy.swap[0], phy.swap[1]); - VNSvOutPortD(pDevice->PortOffset + MAC_REG_RSPINF_B_11, phy.field_write); + VNSvOutPortD(priv->PortOffset + MAC_REG_RSPINF_B_11, phy.field_write); /* RSPINF_a_6 */ s_vCalculateOFDMRParameter(RATE_6M, bb_type, &byTxRate, &byRsvTime); - VNSvOutPortW(pDevice->PortOffset + MAC_REG_RSPINF_A_6, MAKEWORD(byTxRate, byRsvTime)); + VNSvOutPortW(priv->PortOffset + MAC_REG_RSPINF_A_6, MAKEWORD(byTxRate, byRsvTime)); /* RSPINF_a_9 */ s_vCalculateOFDMRParameter(RATE_9M, bb_type, &byTxRate, &byRsvTime); - VNSvOutPortW(pDevice->PortOffset + MAC_REG_RSPINF_A_9, MAKEWORD(byTxRate, byRsvTime)); + VNSvOutPortW(priv->PortOffset + MAC_REG_RSPINF_A_9, MAKEWORD(byTxRate, byRsvTime)); /* RSPINF_a_12 */ s_vCalculateOFDMRParameter(RATE_12M, bb_type, &byTxRate, &byRsvTime); - VNSvOutPortW(pDevice->PortOffset + MAC_REG_RSPINF_A_12, MAKEWORD(byTxRate, byRsvTime)); + VNSvOutPortW(priv->PortOffset + MAC_REG_RSPINF_A_12, MAKEWORD(byTxRate, byRsvTime)); /* RSPINF_a_18 */ s_vCalculateOFDMRParameter(RATE_18M, bb_type, &byTxRate, &byRsvTime); - VNSvOutPortW(pDevice->PortOffset + MAC_REG_RSPINF_A_18, MAKEWORD(byTxRate, byRsvTime)); + VNSvOutPortW(priv->PortOffset + MAC_REG_RSPINF_A_18, MAKEWORD(byTxRate, byRsvTime)); /* RSPINF_a_24 */ s_vCalculateOFDMRParameter(RATE_24M, bb_type, &byTxRate, &byRsvTime); - VNSvOutPortW(pDevice->PortOffset + MAC_REG_RSPINF_A_24, MAKEWORD(byTxRate, byRsvTime)); + VNSvOutPortW(priv->PortOffset + MAC_REG_RSPINF_A_24, MAKEWORD(byTxRate, byRsvTime)); /* RSPINF_a_36 */ - s_vCalculateOFDMRParameter(CARDwGetOFDMControlRate((void *)pDevice, RATE_36M), + s_vCalculateOFDMRParameter(CARDwGetOFDMControlRate((void *)priv, RATE_36M), bb_type, &byTxRate, &byRsvTime); - VNSvOutPortW(pDevice->PortOffset + MAC_REG_RSPINF_A_36, MAKEWORD(byTxRate, byRsvTime)); + VNSvOutPortW(priv->PortOffset + MAC_REG_RSPINF_A_36, MAKEWORD(byTxRate, byRsvTime)); /* RSPINF_a_48 */ - s_vCalculateOFDMRParameter(CARDwGetOFDMControlRate((void *)pDevice, RATE_48M), + s_vCalculateOFDMRParameter(CARDwGetOFDMControlRate((void *)priv, RATE_48M), bb_type, &byTxRate, &byRsvTime); - VNSvOutPortW(pDevice->PortOffset + MAC_REG_RSPINF_A_48, MAKEWORD(byTxRate, byRsvTime)); + VNSvOutPortW(priv->PortOffset + MAC_REG_RSPINF_A_48, MAKEWORD(byTxRate, byRsvTime)); /* RSPINF_a_54 */ - s_vCalculateOFDMRParameter(CARDwGetOFDMControlRate((void *)pDevice, RATE_54M), + s_vCalculateOFDMRParameter(CARDwGetOFDMControlRate((void *)priv, RATE_54M), bb_type, &byTxRate, &byRsvTime); - VNSvOutPortW(pDevice->PortOffset + MAC_REG_RSPINF_A_54, MAKEWORD(byTxRate, byRsvTime)); + VNSvOutPortW(priv->PortOffset + MAC_REG_RSPINF_A_54, MAKEWORD(byTxRate, byRsvTime)); /* RSPINF_a_72 */ - s_vCalculateOFDMRParameter(CARDwGetOFDMControlRate((void *)pDevice, RATE_54M), + s_vCalculateOFDMRParameter(CARDwGetOFDMControlRate((void *)priv, RATE_54M), bb_type, &byTxRate, &byRsvTime); - VNSvOutPortW(pDevice->PortOffset + MAC_REG_RSPINF_A_72, MAKEWORD(byTxRate, byRsvTime)); + VNSvOutPortW(priv->PortOffset + MAC_REG_RSPINF_A_72, MAKEWORD(byTxRate, byRsvTime)); /* Set to Page0 */ - MACvSelectPage0(pDevice->PortOffset); + MACvSelectPage0(priv->PortOffset); - spin_unlock_irqrestore(&pDevice->lock, flags); + spin_unlock_irqrestore(&priv->lock, flags); } -void CARDvUpdateBasicTopRate(struct vnt_private *pDevice) +void CARDvUpdateBasicTopRate(struct vnt_private *priv) { unsigned char byTopOFDM = RATE_24M, byTopCCK = RATE_1M; unsigned char ii; /* Determines the highest basic rate. */ for (ii = RATE_54M; ii >= RATE_6M; ii--) { - if ((pDevice->basic_rates) & ((u32)(1 << ii))) { + if ((priv->basic_rates) & ((u32)(1 << ii))) { byTopOFDM = ii; break; } } - pDevice->byTopOFDMBasicRate = byTopOFDM; + priv->byTopOFDMBasicRate = byTopOFDM; for (ii = RATE_11M;; ii--) { - if ((pDevice->basic_rates) & ((u32)(1 << ii))) { + if ((priv->basic_rates) & ((u32)(1 << ii))) { byTopCCK = ii; break; } if (ii == RATE_1M) break; } - pDevice->byTopCCKBasicRate = byTopCCK; + priv->byTopCCKBasicRate = byTopCCK; } -bool CARDbIsOFDMinBasicRate(struct vnt_private *pDevice) +bool CARDbIsOFDMinBasicRate(struct vnt_private *priv) { int ii; for (ii = RATE_54M; ii >= RATE_6M; ii--) { - if ((pDevice->basic_rates) & ((u32)(1 << ii))) + if ((priv->basic_rates) & ((u32)BIT(ii))) return true; } return false; } -unsigned char CARDbyGetPktType(struct vnt_private *pDevice) +unsigned char CARDbyGetPktType(struct vnt_private *priv) { - if (pDevice->byBBType == BB_TYPE_11A || pDevice->byBBType == BB_TYPE_11B) - return (unsigned char)pDevice->byBBType; - else if (CARDbIsOFDMinBasicRate((void *)pDevice)) + if (priv->byBBType == BB_TYPE_11A || priv->byBBType == BB_TYPE_11B) + return (unsigned char)priv->byBBType; + else if (CARDbIsOFDMinBasicRate((void *)priv)) return PK_TYPE_11GA; else return PK_TYPE_11GB; @@ -830,7 +830,7 @@ unsigned char CARDbyGetPktType(struct vnt_private *pDevice) * * Parameters: * In: - * pDevice - The adapter to be set + * priv - The adapter to be set * wLoopbackMode - Loopback mode to be set * Out: * none @@ -859,17 +859,17 @@ void CARDvSetLoopbackMode(struct vnt_private *priv, unsigned short wLoopbackMode * * Parameters: * In: - * pDevice - The adapter to be reset + * priv - The adapter to be reset * Out: * none * * Return Value: none */ -bool CARDbSoftwareReset(struct vnt_private *pDevice) +bool CARDbSoftwareReset(struct vnt_private *priv) { /* reset MAC */ - if (!MACbSafeSoftwareReset(pDevice->PortOffset)) + if (!MACbSafeSoftwareReset(priv->PortOffset)) return false; return true; @@ -881,7 +881,7 @@ bool CARDbSoftwareReset(struct vnt_private *pDevice) * * Parameters: * In: - * pDevice - The adapter to be sync. + * priv - The adapter to be sync. * qwTSF1 - Rx BCN's TSF * qwTSF2 - Local TSF * Out: @@ -892,7 +892,7 @@ bool CARDbSoftwareReset(struct vnt_private *pDevice) u64 CARDqGetTSFOffset(unsigned char byRxRate, u64 qwTSF1, u64 qwTSF2) { u64 qwTSFOffset = 0; - unsigned short wRxBcnTSFOffst = 0; + unsigned short wRxBcnTSFOffst; wRxBcnTSFOffst = cwRXBCNTSFOff[byRxRate%MAX_RATE]; @@ -909,7 +909,7 @@ u64 CARDqGetTSFOffset(unsigned char byRxRate, u64 qwTSF1, u64 qwTSF2) * * Parameters: * In: - * pDevice - The adapter to be read + * priv - The adapter to be read * Out: * qwCurrTSF - Current TSF counter * @@ -995,7 +995,7 @@ void CARDvSetFirstNextTBTT(struct vnt_private *priv, unsigned short wBeaconInter * * Parameters: * In: - * pDevice - The adapter to be set + * priv - The adapter to be set * qwTSF - Current TSF counter * wBeaconInterval - Beacon Interval * Out: diff --git a/drivers/staging/vt6655/desc.h b/drivers/staging/vt6655/desc.h index 3c9007e34..9fbc71724 100644 --- a/drivers/staging/vt6655/desc.h +++ b/drivers/staging/vt6655/desc.h @@ -167,54 +167,42 @@ * leads error. */ -typedef struct tagDEVICE_RD_INFO { +struct vnt_rd_info { struct sk_buff *skb; dma_addr_t skb_dma; -} DEVICE_RD_INFO, *PDEVICE_RD_INFO; +}; +struct vnt_rdes0 { + volatile __le16 res_count; #ifdef __BIG_ENDIAN - -typedef struct tagRDES0 { - volatile __le16 wResCount; union { - volatile u16 f15Reserved; + volatile u16 f15_reserved; struct { - volatile u8 f8Reserved1; - volatile u8 f1Owner:1; - volatile u8 f7Reserved:7; - } __attribute__ ((__packed__)); - } __attribute__ ((__packed__)); -} __attribute__ ((__packed__)) -SRDES0, *PSRDES0; - + volatile u8 f8_reserved1; + volatile u8 owner:1; + volatile u8 f7_reserved:7; + } __packed; + } __packed; #else - -typedef struct tagRDES0 { - __le16 wResCount; - unsigned short f15Reserved:15; - unsigned short f1Owner:1; -} __attribute__ ((__packed__)) -SRDES0; - + u16 f15_reserved:15; + u16 owner:1; #endif +} __packed; -typedef struct tagRDES1 { - __le16 wReqCount; - unsigned short wReserved; -} __attribute__ ((__packed__)) -SRDES1; +struct vnt_rdes1 { + __le16 req_count; + u16 reserved; +} __packed; /* Rx descriptor*/ -typedef struct tagSRxDesc { - volatile SRDES0 m_rd0RD0; - volatile SRDES1 m_rd1RD1; +struct vnt_rx_desc { + volatile struct vnt_rdes0 rd0; + volatile struct vnt_rdes1 rd1; volatile __le32 buff_addr; volatile __le32 next_desc; - struct tagSRxDesc *next __aligned(8); - volatile PDEVICE_RD_INFO pRDInfo __aligned(8); -} __attribute__ ((__packed__)) -SRxDesc, *PSRxDesc; -typedef const SRxDesc *PCSRxDesc; + struct vnt_rx_desc *next __aligned(8); + struct vnt_rd_info *rd_info __aligned(8); +} __packed; struct vnt_tdes0 { volatile u8 tsr0; diff --git a/drivers/staging/vt6655/device.h b/drivers/staging/vt6655/device.h index c9fa6ef42..55405e058 100644 --- a/drivers/staging/vt6655/device.h +++ b/drivers/staging/vt6655/device.h @@ -31,38 +31,12 @@ #include <linux/module.h> #include <linux/types.h> -#include <linux/mm.h> -#include <linux/errno.h> -#include <linux/ioport.h> #include <linux/pci.h> -#include <linux/kernel.h> -#include <linux/netdevice.h> #include <linux/etherdevice.h> #include <linux/skbuff.h> -#include <linux/delay.h> -#include <linux/timer.h> -#include <linux/slab.h> #include <linux/interrupt.h> -#include <linux/string.h> -#include <linux/wait.h> -#include <linux/if_arp.h> -#include <linux/sched.h> -#include <linux/io.h> -#include <linux/if.h> #include <linux/crc32.h> -#include <linux/uaccess.h> -#include <linux/proc_fs.h> -#include <linux/inetdevice.h> -#include <linux/reboot.h> -#include <linux/ethtool.h> -/* Include Wireless Extension definition and check version - Jean II */ #include <net/mac80211.h> -#include <linux/wireless.h> -#include <net/iw_handler.h> /* New driver API */ - -#ifndef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT -#define WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT -#endif /* device specific */ @@ -87,30 +61,8 @@ #define RATE_36M 9 #define RATE_48M 10 #define RATE_54M 11 -#define RATE_AUTO 12 #define MAX_RATE 12 -#define MAC_MAX_CONTEXT_REG (256+128) - -#define MAX_MULTICAST_ADDRESS_NUM 32 -#define MULTICAST_ADDRESS_LIST_SIZE (MAX_MULTICAST_ADDRESS_NUM * ETH_ALEN) - -#define DUPLICATE_RX_CACHE_LENGTH 5 - -#define NUM_KEY_ENTRY 11 - -#define TX_WEP_NONE 0 -#define TX_WEP_OTF 1 -#define TX_WEP_SW 2 -#define TX_WEP_SWOTP 3 -#define TX_WEP_OTPSW 4 -#define TX_WEP_SW232 5 - -#define KEYSEL_WEP40 0 -#define KEYSEL_WEP104 1 -#define KEYSEL_TKIP 2 -#define KEYSEL_CCMP 3 - #define AUTO_FB_NONE 0 #define AUTO_FB_0 1 #define AUTO_FB_1 2 @@ -126,25 +78,14 @@ #define ANT_RXD_TXB 4 #define ANT_UNKNOWN 0xFF -#define MAXCHECKHANGCNT 4 - #define BB_VGA_LEVEL 4 #define BB_VGA_CHANGE_THRESHOLD 16 -#ifndef RUN_AT -#define RUN_AT(x) (jiffies+(x)) -#endif - #define MAKE_BEACON_RESERVED 10 /* (us) */ -/* DMA related */ -#define RESERV_AC0DMA 4 - /* BUILD OBJ mode */ -#define AVAIL_TD(p, q) ((p)->sOpts.nTxDescs[(q)] - ((p)->iTDUsed[(q)])) - -#define NUM 64 +#define AVAIL_TD(p, q) ((p)->opts.tx_descs[(q)] - ((p)->iTDUsed[(q)])) /* 0:11A 1:11B 2:11G */ #define BB_TYPE_11A 0 @@ -157,56 +98,19 @@ #define PK_TYPE_11GB 2 #define PK_TYPE_11GA 3 -typedef struct __chip_info_tbl { - CHIP_TYPE chip_id; - char *name; - int io_size; - int nTxQueue; - u32 flags; -} CHIP_INFO, *PCHIP_INFO; - -typedef enum { - OWNED_BY_HOST = 0, - OWNED_BY_NIC = 1 -} DEVICE_OWNER_TYPE, *PDEVICE_OWNER_TYPE; - -/* flags for options */ -#define DEVICE_FLAGS_IP_ALIGN 0x00000001UL -#define DEVICE_FLAGS_PREAMBLE_TYPE 0x00000002UL -#define DEVICE_FLAGS_OP_MODE 0x00000004UL -#define DEVICE_FLAGS_PS_MODE 0x00000008UL -#define DEVICE_FLAGS_80211h_MODE 0x00000010UL -#define DEVICE_FLAGS_DiversityANT 0x00000020UL - -/* flags for driver status */ -#define DEVICE_FLAGS_OPENED 0x00010000UL -#define DEVICE_FLAGS_WOL_ENABLED 0x00080000UL -/* flags for capabilities */ -#define DEVICE_FLAGS_TX_ALIGN 0x01000000UL -#define DEVICE_FLAGS_HAVE_CAM 0x02000000UL -#define DEVICE_FLAGS_FLOW_CTRL 0x04000000UL - -/* flags for MII status */ -#define DEVICE_LINK_FAIL 0x00000001UL -#define DEVICE_SPEED_10 0x00000002UL -#define DEVICE_SPEED_100 0x00000004UL -#define DEVICE_SPEED_1000 0x00000008UL -#define DEVICE_DUPLEX_FULL 0x00000010UL -#define DEVICE_AUTONEG_ENABLE 0x00000020UL -#define DEVICE_FORCED_BY_EEPROM 0x00000040UL -/* for device_set_media_duplex */ -#define DEVICE_LINK_CHANGE 0x00000001UL - -typedef struct __device_opt { - int nRxDescs0; /* Number of RX descriptors0 */ - int nRxDescs1; /* Number of RX descriptors1 */ - int nTxDescs[2]; /* Number of TX descriptors 0, 1 */ - int int_works; /* interrupt limits */ - int short_retry; - int long_retry; - int bbp_type; - u32 flags; -} OPTIONS, *POPTIONS; +#define OWNED_BY_HOST 0 +#define OWNED_BY_NIC 1 + +struct vnt_options { + int rx_descs0; /* Number of RX descriptors0 */ + int rx_descs1; /* Number of RX descriptors1 */ + int tx_descs[2]; /* Number of TX descriptors 0, 1 */ + int int_works; /* interrupt limits */ + int short_retry; + int long_retry; + int bbp_type; + u32 flags; +}; struct vnt_private { struct pci_dev *pcid; @@ -235,21 +139,14 @@ struct vnt_private { unsigned char *tx1_bufs; unsigned char *tx_beacon_bufs; - CHIP_TYPE chip_id; - void __iomem *PortOffset; u32 memaddr; u32 ioaddr; - u32 io_size; - unsigned char byRevId; unsigned char byRxMode; - unsigned short SubSystemID; - unsigned short SubVendorID; spinlock_t lock; - int nTxQueues; volatile int iTDUsed[TYPE_MAXTD]; struct vnt_tx_desc *apCurrTD[TYPE_MAXTD]; @@ -258,17 +155,16 @@ struct vnt_private { struct vnt_tx_desc *apTD0Rings; struct vnt_tx_desc *apTD1Rings; - volatile PSRxDesc aRD0Ring; - volatile PSRxDesc aRD1Ring; - volatile PSRxDesc pCurrRD[TYPE_MAXRD]; + struct vnt_rx_desc *aRD0Ring; + struct vnt_rx_desc *aRD1Ring; + struct vnt_rx_desc *pCurrRD[TYPE_MAXRD]; - OPTIONS sOpts; + struct vnt_options opts; u32 flags; u32 rx_buf_sz; u8 rx_rate; - int multicast_limit; u32 rx_bytes; @@ -410,13 +306,4 @@ struct vnt_private { struct ieee80211_low_level_stats low_stats; }; -static inline PDEVICE_RD_INFO alloc_rd_info(void) -{ - return kzalloc(sizeof(DEVICE_RD_INFO), GFP_ATOMIC); -} - -static inline struct vnt_td_info *alloc_td_info(void) -{ - return kzalloc(sizeof(struct vnt_td_info), GFP_ATOMIC); -} #endif diff --git a/drivers/staging/vt6655/device_main.c b/drivers/staging/vt6655/device_main.c index 0d8f123c5..fefbf826c 100644 --- a/drivers/staging/vt6655/device_main.c +++ b/drivers/staging/vt6655/device_main.c @@ -28,9 +28,7 @@ * * 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_rx_srv - rx service function * device_alloc_rx_buf - rx buffer pre-allocated function @@ -128,103 +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 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_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 *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_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; @@ -232,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 */ @@ -281,545 +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); -} - -static void device_print_info(struct vnt_private *pDevice) -{ - 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); + MACvStart(priv->PortOffset); } -static void vt6655_init_info(struct pci_dev *pcid, - struct vnt_private **ppDevice, - PCHIP_INFO pChip_info) +static void device_print_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; + 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 device_free_info(struct vnt_private *pDevice) +static void device_free_info(struct vnt_private *priv) { - 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(struct vnt_tx_desc) + - pDevice->sOpts.nTxDescs[1] * sizeof(struct vnt_tx_desc), - &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(struct vnt_tx_desc) + - pDevice->sOpts.nTxDescs[1] * sizeof(struct vnt_tx_desc), - 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(struct vnt_tx_desc); + 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(struct vnt_tx_desc); + 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(struct vnt_tx_desc) + - pDevice->sOpts.nTxDescs[1] * sizeof(struct vnt_tx_desc) - , - 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(); + 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(pDevice, pDesc)) - dev_err(&pDevice->pcid->dev, "can not alloc rx bufs\n"); + if (!device_alloc_rx_buf(priv, desc)) + dev_err(&priv->pcid->dev, "can not alloc rx bufs\n"); - pDesc->next = &(pDevice->aRD0Ring[(i+1) % pDevice->sOpts.nRxDescs0]); - pDesc->next_desc = cpu_to_le32(curr + sizeof(SRxDesc)); + 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(); + 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(pDevice, pDesc)) - dev_err(&pDevice->pcid->dev, "can not alloc rx bufs\n"); + if (!device_alloc_rx_buf(priv, desc)) + dev_err(&priv->pcid->dev, "can not alloc rx bufs\n"); - pDesc->next = &(pDevice->aRD1Ring[(i+1) % pDevice->sOpts.nRxDescs1]); - pDesc->next_desc = cpu_to_le32(curr + sizeof(SRxDesc)); + 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; - struct vnt_tx_desc *pDesc; + struct vnt_tx_desc *desc; - curr = pDevice->td0_pool_dma; - for (i = 0; i < pDevice->sOpts.nTxDescs[0]; + curr = priv->td0_pool_dma; + for (i = 0; i < priv->opts.tx_descs[0]; i++, curr += sizeof(struct vnt_tx_desc)) { - pDesc = &(pDevice->apTD0Rings[i]); - pDesc->td_info = alloc_td_info(); + desc = &priv->apTD0Rings[i]; + desc->td_info = kzalloc(sizeof(*desc->td_info), GFP_ATOMIC); - if (pDevice->flags & DEVICE_FLAGS_TX_ALIGN) { - pDesc->td_info->buf = pDevice->tx0_bufs + (i)*PKT_BUF_SZ; - pDesc->td_info->buf_dma = pDevice->tx_bufs_dma0 + (i)*PKT_BUF_SZ; - } - pDesc->next = &(pDevice->apTD0Rings[(i+1) % pDevice->sOpts.nTxDescs[0]]); - pDesc->next_desc = cpu_to_le32(curr + sizeof(struct vnt_tx_desc)); + 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; - struct vnt_tx_desc *pDesc; + struct vnt_tx_desc *desc; /* Init the TD ring entries */ - curr = pDevice->td1_pool_dma; - for (i = 0; i < pDevice->sOpts.nTxDescs[1]; + curr = priv->td1_pool_dma; + for (i = 0; i < priv->opts.tx_descs[1]; i++, curr += sizeof(struct vnt_tx_desc)) { - pDesc = &(pDevice->apTD1Rings[i]); - pDesc->td_info = alloc_td_info(); + desc = &priv->apTD1Rings[i]; + desc->td_info = kzalloc(sizeof(*desc->td_info), GFP_ATOMIC); - if (pDevice->flags & DEVICE_FLAGS_TX_ALIGN) { - pDesc->td_info->buf = pDevice->tx1_bufs + (i) * PKT_BUF_SZ; - pDesc->td_info->buf_dma = pDevice->tx_bufs_dma1 + (i) * PKT_BUF_SZ; - } - pDesc->next = &(pDevice->apTD1Rings[(i + 1) % pDevice->sOpts.nTxDescs[1]]); - pDesc->next_desc = cpu_to_le32(curr + sizeof(struct vnt_tx_desc)); + 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++) { - struct vnt_tx_desc *pDesc = &pDevice->apTD0Rings[i]; - struct vnt_td_info *pTDInfo = pDesc->td_info; + 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; - dev_kfree_skb(pTDInfo->skb); - kfree(pDesc->td_info); + 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++) { - struct vnt_tx_desc *pDesc = &pDevice->apTD1Rings[i]; - struct vnt_td_info *pTDInfo = pDesc->td_info; + 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; - dev_kfree_skb(pTDInfo->skb); - kfree(pDesc->td_info); + 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; - 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; } @@ -900,77 +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) { - struct vnt_tx_desc *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->td0.owner == 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->td0.tsr0; - byTsr1 = pTD->td0.tsr1; + byTsr0 = desc->td0.tsr0; + byTsr1 = desc->td0.tsr1; /* Only the status of first TD in the chain is correct */ - if (pTD->td1.tcr & TCR_STP) { - if ((pTD->td_info->flags & 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->td_info->flags & 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->td_info, 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, - struct vnt_tx_desc *pDesc) +static void device_free_tx_buf(struct vnt_private *priv, + struct vnt_tx_desc *desc) { - struct vnt_td_info *pTDInfo = pDesc->td_info; - struct sk_buff *skb = pTDInfo->skb; + 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 = NULL; - pTDInfo->flags = 0; + td_info->skb = NULL; + td_info->flags = 0; } static void vnt_check_bb_vga(struct vnt_private *priv) @@ -1128,7 +1057,7 @@ static void vnt_interrupt_process(struct vnt_private *priv) MACvReceive0(priv->PortOffset); MACvReceive1(priv->PortOffset); - if (max_count > priv->sOpts.int_works) + if (max_count > priv->opts.int_works) break; } @@ -1172,6 +1101,7 @@ 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; } @@ -1223,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) @@ -1649,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; @@ -1668,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; @@ -1683,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,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; diff --git a/drivers/staging/vt6655/dpc.c b/drivers/staging/vt6655/dpc.c index e14eed160..700032e9c 100644 --- a/drivers/staging/vt6655/dpc.c +++ b/drivers/staging/vt6655/dpc.c @@ -132,9 +132,9 @@ static bool vnt_rx_data(struct vnt_private *priv, struct sk_buff *skb, return true; } -bool vnt_receive_frame(struct vnt_private *priv, PSRxDesc curr_rd) +bool vnt_receive_frame(struct vnt_private *priv, struct vnt_rx_desc *curr_rd) { - PDEVICE_RD_INFO rd_info = curr_rd->pRDInfo; + struct vnt_rd_info *rd_info = curr_rd->rd_info; struct sk_buff *skb; u16 frame_size; @@ -143,8 +143,8 @@ bool vnt_receive_frame(struct vnt_private *priv, PSRxDesc curr_rd) dma_unmap_single(&priv->pcid->dev, rd_info->skb_dma, priv->rx_buf_sz, DMA_FROM_DEVICE); - frame_size = le16_to_cpu(curr_rd->m_rd1RD1.wReqCount) - - le16_to_cpu(curr_rd->m_rd0RD0.wResCount); + frame_size = le16_to_cpu(curr_rd->rd1.req_count) + - le16_to_cpu(curr_rd->rd0.res_count); if ((frame_size > 2364) || (frame_size < 33)) { /* Frame Size error drop this packet.*/ diff --git a/drivers/staging/vt6655/dpc.h b/drivers/staging/vt6655/dpc.h index ad495719a..e80b30816 100644 --- a/drivers/staging/vt6655/dpc.h +++ b/drivers/staging/vt6655/dpc.h @@ -31,6 +31,6 @@ #include "device.h" -bool vnt_receive_frame(struct vnt_private *priv, PSRxDesc curr_rd); +bool vnt_receive_frame(struct vnt_private *priv, struct vnt_rx_desc *curr_rd); #endif /* __RXTX_H__ */ diff --git a/drivers/staging/vt6655/mac.c b/drivers/staging/vt6655/mac.c index 3dfd33347..688c3be16 100644 --- a/drivers/staging/vt6655/mac.c +++ b/drivers/staging/vt6655/mac.c @@ -689,9 +689,8 @@ void MACvSetCurrAC0DescAddrEx(void __iomem *dwIoBase, if (!(byData & DMACTL_RUN)) break; } - if (ww == W_MAX_TIMEOUT) { + if (ww == W_MAX_TIMEOUT) pr_debug(" DBG_PORT80(0x26)\n"); - } VNSvOutPortD(dwIoBase + MAC_REG_AC0DMAPTR, dwCurrDescAddr); if (byOrgDMACtl & DMACTL_RUN) VNSvOutPortB(dwIoBase + MAC_REG_AC0DMACTL, DMACTL_RUN); diff --git a/drivers/staging/vt6655/rf.c b/drivers/staging/vt6655/rf.c index c53732144..4c22bb318 100644 --- a/drivers/staging/vt6655/rf.c +++ b/drivers/staging/vt6655/rf.c @@ -768,7 +768,7 @@ bool RFvWriteWakeProgSyn(struct vnt_private *priv, unsigned char byRFType, */ bool RFbSetPower( struct vnt_private *priv, - unsigned int uRATE, + unsigned int rate, u16 uCH ) { @@ -782,7 +782,7 @@ bool RFbSetPower( if ((uCH < 1) || (uCH > CB_MAX_CHANNEL)) return false; - switch (uRATE) { + switch (rate) { case RATE_1M: case RATE_2M: case RATE_5M: @@ -818,7 +818,7 @@ bool RFbSetPower( if (priv->byCurPwr == byPwr) return true; - bResult = RFbRawSetPower(priv, byPwr, uRATE); + bResult = RFbRawSetPower(priv, byPwr, rate); if (bResult) priv->byCurPwr = byPwr; @@ -842,7 +842,7 @@ bool RFbSetPower( bool RFbRawSetPower( struct vnt_private *priv, unsigned char byPwr, - unsigned int uRATE + unsigned int rate ) { bool bResult = true; @@ -854,7 +854,7 @@ bool RFbRawSetPower( switch (priv->byRFType) { case RF_AIROHA: bResult &= IFRFbWriteEmbedded(priv, dwAL2230PowerTable[byPwr]); - if (uRATE <= RATE_11M) + if (rate <= RATE_11M) bResult &= IFRFbWriteEmbedded(priv, 0x0001B400+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW); else bResult &= IFRFbWriteEmbedded(priv, 0x0005A400+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW); @@ -863,7 +863,7 @@ bool RFbRawSetPower( case RF_AL2230S: bResult &= IFRFbWriteEmbedded(priv, dwAL2230PowerTable[byPwr]); - if (uRATE <= RATE_11M) { + if (rate <= RATE_11M) { bResult &= IFRFbWriteEmbedded(priv, 0x040C1400+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW); bResult &= IFRFbWriteEmbedded(priv, 0x00299B00+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW); } else { diff --git a/drivers/staging/vt6655/rf.h b/drivers/staging/vt6655/rf.h index b5fc3eed0..e9c786995 100644 --- a/drivers/staging/vt6655/rf.h +++ b/drivers/staging/vt6655/rf.h @@ -79,11 +79,11 @@ bool RFbInit( struct vnt_private * ); bool RFvWriteWakeProgSyn(struct vnt_private *, unsigned char byRFType, u16); -bool RFbSetPower(struct vnt_private *, unsigned int uRATE, u16); +bool RFbSetPower(struct vnt_private *, unsigned int rate, u16); bool RFbRawSetPower( struct vnt_private *, unsigned char byPwr, - unsigned int uRATE + unsigned int rate ); void diff --git a/drivers/staging/vt6655/rxtx.c b/drivers/staging/vt6655/rxtx.c index 5875d655d..b668db6a4 100644 --- a/drivers/staging/vt6655/rxtx.c +++ b/drivers/staging/vt6655/rxtx.c @@ -78,7 +78,7 @@ static const unsigned short wFB_Opt0[2][5] = { }; static const unsigned short wFB_Opt1[2][5] = { {RATE_12M, RATE_18M, RATE_24M, RATE_24M, RATE_36M}, /* fallback_rate0 */ - {RATE_6M , RATE_6M, RATE_12M, RATE_12M, RATE_18M}, /* fallback_rate1 */ + {RATE_6M, RATE_6M, RATE_12M, RATE_12M, RATE_18M}, /* fallback_rate1 */ }; #define RTSDUR_BB 0 @@ -566,7 +566,7 @@ s_uFillDataHead( return buf->duration_a; } /* if (byFBOption == AUTO_FB_NONE) */ } else if (byPktType == PK_TYPE_11A) { - if ((byFBOption != AUTO_FB_NONE)) { + if (byFBOption != AUTO_FB_NONE) { /* Auto Fallback */ struct vnt_tx_datahead_a_fb *buf = pTxDataHead; /* Get SignalField, ServiceField & Length */ @@ -1008,7 +1008,7 @@ s_vGenerateTxParameter( buf->rrv_time = vnt_rxtx_rsvtime_le16(pDevice, PK_TYPE_11A, cbFrameSize, wCurrentRate, bNeedACK); } } else if (byPktType == PK_TYPE_11B) { - if ((pvRTS != NULL)) {/* RTS_need, non PCF mode */ + if (pvRTS != NULL) {/* RTS_need, non PCF mode */ struct vnt_rrv_time_ab *buf = pvRrvTime; buf->rts_rrv_time = s_uGetRTSCTSRsvTime(pDevice, 0, byPktType, cbFrameSize, wCurrentRate); |