diff options
Diffstat (limited to 'drivers/staging/vt6656/card.c')
-rw-r--r-- | drivers/staging/vt6656/card.c | 1045 |
1 files changed, 484 insertions, 561 deletions
diff --git a/drivers/staging/vt6656/card.c b/drivers/staging/vt6656/card.c index 0d8772858f09..d662e5431dad 100644 --- a/drivers/staging/vt6656/card.c +++ b/drivers/staging/vt6656/card.c @@ -57,11 +57,7 @@ #include "rc4.h" #include "country.h" #include "datarate.h" -#include "rndis.h" -#include "control.h" - -//static int msglevel =MSG_LEVEL_DEBUG; -static int msglevel =MSG_LEVEL_INFO; +#include "usbpipe.h" //const u16 cwRXBCNTSFOff[MAX_RATE] = //{17, 34, 96, 192, 34, 23, 17, 11, 8, 5, 4, 3}; @@ -98,24 +94,24 @@ void CARDbSetMediaChannel(struct vnt_private *priv, u32 connection_channel) /* Set Channel[7] = 0 to tell H/W channel is changing now. */ MACvRegBitsOff(priv, MAC_REG_CHANNEL, 0xb0); - CONTROLnsRequestOut(priv, MESSAGE_TYPE_SELECT_CHANNLE, + vnt_control_out(priv, MESSAGE_TYPE_SELECT_CHANNLE, connection_channel, 0, 0, NULL); if (priv->byBBType == BB_TYPE_11A) { priv->byCurPwr = 0xff; - RFbRawSetPower(priv, + vnt_rf_set_txpower(priv, priv->abyOFDMAPwrTbl[connection_channel-15], RATE_54M); } else if (priv->byBBType == BB_TYPE_11G) { priv->byCurPwr = 0xff; - RFbRawSetPower(priv, + vnt_rf_set_txpower(priv, priv->abyOFDMPwrTbl[connection_channel-1], RATE_54M); } else { priv->byCurPwr = 0xff; - RFbRawSetPower(priv, + vnt_rf_set_txpower(priv, priv->abyCCKPwrTbl[connection_channel-1], RATE_1M); } - ControlvWriteByte(priv, MESSAGE_REQUEST_MACREG, MAC_REG_CHANNEL, + vnt_control_out_u8(priv, MESSAGE_REQUEST_MACREG, MAC_REG_CHANNEL, (u8)(connection_channel|0x80)); } @@ -124,20 +120,20 @@ void CARDbSetMediaChannel(struct vnt_private *priv, u32 connection_channel) * * Parameters: * In: - * pDevice - The adapter to be set - * wRateIdx - Receiving data rate + * priv - The adapter to be set + * rate_idx - Receiving data rate * Out: * none * * Return Value: response Control frame rate * */ -static u16 swGetCCKControlRate(struct vnt_private *pDevice, u16 wRateIdx) +static u16 swGetCCKControlRate(struct vnt_private *priv, u16 rate_idx) { - u16 ui = wRateIdx; + u16 ui = rate_idx; while (ui > RATE_1M) { - if (pDevice->wBasicRate & (1 << ui)) + if (priv->wBasicRate & (1 << ui)) return ui; ui--; } @@ -150,39 +146,39 @@ static u16 swGetCCKControlRate(struct vnt_private *pDevice, u16 wRateIdx) * * Parameters: * In: - * pDevice - The adapter to be set - * wRateIdx - Receiving data rate + * priv - The adapter to be set + * rate_idx - Receiving data rate * Out: * none * * Return Value: response Control frame rate * */ -static u16 swGetOFDMControlRate(struct vnt_private *pDevice, u16 wRateIdx) +static u16 swGetOFDMControlRate(struct vnt_private *priv, u16 rate_idx) { - u16 ui = wRateIdx; + u16 ui = rate_idx; - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"BASIC RATE: %X\n", - pDevice->wBasicRate); + dev_dbg(&priv->usb->dev, "%s basic rate: %d\n", + __func__, priv->wBasicRate); - if (!CARDbIsOFDMinBasicRate(pDevice)) { - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO - "swGetOFDMControlRate:(NO OFDM) %d\n", wRateIdx); - if (wRateIdx > RATE_24M) - wRateIdx = RATE_24M; - return wRateIdx; + if (!CARDbIsOFDMinBasicRate(priv)) { + dev_dbg(&priv->usb->dev, "%s (NO OFDM) %d\n", + __func__, rate_idx); + if (rate_idx > RATE_24M) + rate_idx = RATE_24M; + return rate_idx; } while (ui > RATE_11M) { - if (pDevice->wBasicRate & (1 << ui)) { - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO - "swGetOFDMControlRate: %d\n", ui); + if (priv->wBasicRate & (1 << ui)) { + dev_dbg(&priv->usb->dev, "%s rate: %d\n", + __func__, ui); return ui; } ui--; } - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"swGetOFDMControlRate: 6M\n"); + dev_dbg(&priv->usb->dev, "%s basic rate: 24M\n", __func__); return RATE_24M; } @@ -191,114 +187,95 @@ static u16 swGetOFDMControlRate(struct vnt_private *pDevice, u16 wRateIdx) * Description: Calculate TxRate and RsvTime fields for RSPINF in OFDM mode. * * Parameters: - * In: - * wRate - Tx Rate - * byPktType - Tx Packet type - * Out: - * pbyTxRate - pointer to RSPINF TxRate field - * pbyRsvTime - pointer to RSPINF RsvTime field + * In: + * rate - Tx Rate + * bb_type - Tx Packet type + * Out: + * tx_rate - pointer to RSPINF TxRate field + * rsv_time- pointer to RSPINF RsvTime field * * Return Value: none * */ -static void -CARDvCalculateOFDMRParameter ( - u16 wRate, - u8 byBBType, - u8 * pbyTxRate, - u8 * pbyRsvTime - ) +static void CARDvCalculateOFDMRParameter(u16 rate, u8 bb_type, + u8 *tx_rate, u8 *rsv_time) { - switch (wRate) { - case RATE_6M : - if (byBBType == BB_TYPE_11A) {//5GHZ - *pbyTxRate = 0x9B; - *pbyRsvTime = 24; - } - else { - *pbyTxRate = 0x8B; - *pbyRsvTime = 30; - } - break; - - case RATE_9M : - if (byBBType == BB_TYPE_11A) {//5GHZ - *pbyTxRate = 0x9F; - *pbyRsvTime = 16; - } - else { - *pbyTxRate = 0x8F; - *pbyRsvTime = 22; - } - break; - - case RATE_12M : - if (byBBType == BB_TYPE_11A) {//5GHZ - *pbyTxRate = 0x9A; - *pbyRsvTime = 12; - } - else { - *pbyTxRate = 0x8A; - *pbyRsvTime = 18; - } - break; - - case RATE_18M : - if (byBBType == BB_TYPE_11A) {//5GHZ - *pbyTxRate = 0x9E; - *pbyRsvTime = 8; - } - else { - *pbyTxRate = 0x8E; - *pbyRsvTime = 14; - } - break; - - case RATE_36M : - if (byBBType == BB_TYPE_11A) {//5GHZ - *pbyTxRate = 0x9D; - *pbyRsvTime = 4; - } - else { - *pbyTxRate = 0x8D; - *pbyRsvTime = 10; - } - break; - - case RATE_48M : - if (byBBType == BB_TYPE_11A) {//5GHZ - *pbyTxRate = 0x98; - *pbyRsvTime = 4; - } - else { - *pbyTxRate = 0x88; - *pbyRsvTime = 10; - } - break; - - case RATE_54M : - if (byBBType == BB_TYPE_11A) {//5GHZ - *pbyTxRate = 0x9C; - *pbyRsvTime = 4; - } - else { - *pbyTxRate = 0x8C; - *pbyRsvTime = 10; - } - break; - - case RATE_24M : - default : - if (byBBType == BB_TYPE_11A) {//5GHZ - *pbyTxRate = 0x99; - *pbyRsvTime = 8; - } - else { - *pbyTxRate = 0x89; - *pbyRsvTime = 14; - } - break; - } + + switch (rate) { + case RATE_6M: + if (bb_type == BB_TYPE_11A) { + *tx_rate = 0x9b; + *rsv_time = 24; + } else { + *tx_rate = 0x8b; + *rsv_time = 30; + } + break; + case RATE_9M: + if (bb_type == BB_TYPE_11A) { + *tx_rate = 0x9f; + *rsv_time = 16; + } else { + *tx_rate = 0x8f; + *rsv_time = 22; + } + break; + case RATE_12M: + if (bb_type == BB_TYPE_11A) { + *tx_rate = 0x9a; + *rsv_time = 12; + } else { + *tx_rate = 0x8a; + *rsv_time = 18; + } + break; + case RATE_18M: + if (bb_type == BB_TYPE_11A) { + *tx_rate = 0x9e; + *rsv_time = 8; + } else { + *tx_rate = 0x8e; + *rsv_time = 14; + } + break; + case RATE_36M: + if (bb_type == BB_TYPE_11A) { + *tx_rate = 0x9d; + *rsv_time = 4; + } else { + *tx_rate = 0x8d; + *rsv_time = 10; + } + break; + case RATE_48M: + if (bb_type == BB_TYPE_11A) { + *tx_rate = 0x98; + *rsv_time = 4; + } else { + *tx_rate = 0x88; + *rsv_time = 10; + } + break; + case RATE_54M: + if (bb_type == BB_TYPE_11A) { + *tx_rate = 0x9c; + *rsv_time = 4; + } else { + *tx_rate = 0x8c; + *rsv_time = 10; + } + break; + case RATE_24M: + default: + if (bb_type == BB_TYPE_11A) { + *tx_rate = 0x99; + *rsv_time = 8; + } else { + *tx_rate = 0x89; + *rsv_time = 14; + } + break; + } } /* @@ -313,112 +290,91 @@ CARDvCalculateOFDMRParameter ( * Return Value: None. * */ -void CARDvSetRSPINF(struct vnt_private *pDevice, u8 byBBType) + +void CARDvSetRSPINF(struct vnt_private *priv, u8 bb_type) { struct vnt_phy_field phy[4]; - u8 abyTxRate[9] = {0, 0, 0, 0, 0, 0, 0, 0, 0}; /* For OFDM */ - u8 abyRsvTime[9] = {0, 0, 0, 0, 0, 0, 0, 0, 0}; - u8 abyData[34]; + u8 tx_rate[9] = {0, 0, 0, 0, 0, 0, 0, 0, 0}; /* For OFDM */ + u8 rsv_time[9] = {0, 0, 0, 0, 0, 0, 0, 0, 0}; + u8 data[34]; int i; - //RSPINF_b_1 - BBvCalculateParameter(pDevice, 14, - swGetCCKControlRate(pDevice, RATE_1M), PK_TYPE_11B, &phy[0]); - - ///RSPINF_b_2 - BBvCalculateParameter(pDevice, 14, - swGetCCKControlRate(pDevice, RATE_2M), PK_TYPE_11B, &phy[1]); - - //RSPINF_b_5 - BBvCalculateParameter(pDevice, 14, - swGetCCKControlRate(pDevice, RATE_5M), PK_TYPE_11B, &phy[2]); - - //RSPINF_b_11 - BBvCalculateParameter(pDevice, 14, - swGetCCKControlRate(pDevice, RATE_11M), PK_TYPE_11B, &phy[3]); - - //RSPINF_a_6 - CARDvCalculateOFDMRParameter (RATE_6M, - byBBType, - &abyTxRate[0], - &abyRsvTime[0]); - - //RSPINF_a_9 - CARDvCalculateOFDMRParameter (RATE_9M, - byBBType, - &abyTxRate[1], - &abyRsvTime[1]); - - //RSPINF_a_12 - CARDvCalculateOFDMRParameter (RATE_12M, - byBBType, - &abyTxRate[2], - &abyRsvTime[2]); - - //RSPINF_a_18 - CARDvCalculateOFDMRParameter (RATE_18M, - byBBType, - &abyTxRate[3], - &abyRsvTime[3]); - - //RSPINF_a_24 - CARDvCalculateOFDMRParameter (RATE_24M, - byBBType, - &abyTxRate[4], - &abyRsvTime[4]); - - //RSPINF_a_36 - CARDvCalculateOFDMRParameter (swGetOFDMControlRate(pDevice, RATE_36M), - byBBType, - &abyTxRate[5], - &abyRsvTime[5]); - - //RSPINF_a_48 - CARDvCalculateOFDMRParameter (swGetOFDMControlRate(pDevice, RATE_48M), - byBBType, - &abyTxRate[6], - &abyRsvTime[6]); - - //RSPINF_a_54 - CARDvCalculateOFDMRParameter (swGetOFDMControlRate(pDevice, RATE_54M), - byBBType, - &abyTxRate[7], - &abyRsvTime[7]); - - //RSPINF_a_72 - CARDvCalculateOFDMRParameter (swGetOFDMControlRate(pDevice, RATE_54M), - byBBType, - &abyTxRate[8], - &abyRsvTime[8]); - - put_unaligned(phy[0].len, (u16 *)&abyData[0]); - abyData[2] = phy[0].signal; - abyData[3] = phy[0].service; - - put_unaligned(phy[1].len, (u16 *)&abyData[4]); - abyData[6] = phy[1].signal; - abyData[7] = phy[1].service; - - put_unaligned(phy[2].len, (u16 *)&abyData[8]); - abyData[10] = phy[2].signal; - abyData[11] = phy[2].service; - - put_unaligned(phy[3].len, (u16 *)&abyData[12]); - abyData[14] = phy[3].signal; - abyData[15] = phy[3].service; - - for (i = 0; i < 9; i++) { - abyData[16+i*2] = abyTxRate[i]; - abyData[16+i*2+1] = abyRsvTime[i]; - } - - CONTROLnsRequestOut(pDevice, - MESSAGE_TYPE_WRITE, - MAC_REG_RSPINF_B_1, - MESSAGE_REQUEST_MACREG, - 34, - &abyData[0]); + /*RSPINF_b_1*/ + BBvCalculateParameter(priv, 14, + swGetCCKControlRate(priv, RATE_1M), PK_TYPE_11B, &phy[0]); + + /*RSPINF_b_2*/ + BBvCalculateParameter(priv, 14, + swGetCCKControlRate(priv, RATE_2M), PK_TYPE_11B, &phy[1]); + + /*RSPINF_b_5*/ + BBvCalculateParameter(priv, 14, + swGetCCKControlRate(priv, RATE_5M), PK_TYPE_11B, &phy[2]); + + /*RSPINF_b_11*/ + BBvCalculateParameter(priv, 14, + swGetCCKControlRate(priv, RATE_11M), PK_TYPE_11B, &phy[3]); + + + /*RSPINF_a_6*/ + CARDvCalculateOFDMRParameter(RATE_6M, bb_type, + &tx_rate[0], &rsv_time[0]); + /*RSPINF_a_9*/ + CARDvCalculateOFDMRParameter(RATE_9M, bb_type, + &tx_rate[1], &rsv_time[1]); + + /*RSPINF_a_12*/ + CARDvCalculateOFDMRParameter(RATE_12M, bb_type, + &tx_rate[2], &rsv_time[2]); + + /*RSPINF_a_18*/ + CARDvCalculateOFDMRParameter(RATE_18M, bb_type, + &tx_rate[3], &rsv_time[3]); + + /*RSPINF_a_24*/ + CARDvCalculateOFDMRParameter(RATE_24M, bb_type, + &tx_rate[4], &rsv_time[4]); + + /*RSPINF_a_36*/ + CARDvCalculateOFDMRParameter(swGetOFDMControlRate(priv, RATE_36M), + bb_type, &tx_rate[5], &rsv_time[5]); + + /*RSPINF_a_48*/ + CARDvCalculateOFDMRParameter(swGetOFDMControlRate(priv, RATE_48M), + bb_type, &tx_rate[6], &rsv_time[6]); + + /*RSPINF_a_54*/ + CARDvCalculateOFDMRParameter(swGetOFDMControlRate(priv, RATE_54M), + bb_type, &tx_rate[7], &rsv_time[7]); + + /*RSPINF_a_72*/ + CARDvCalculateOFDMRParameter(swGetOFDMControlRate(priv, RATE_54M), + bb_type, &tx_rate[8], &rsv_time[8]); + + put_unaligned(phy[0].len, (u16 *)&data[0]); + data[2] = phy[0].signal; + data[3] = phy[0].service; + + put_unaligned(phy[1].len, (u16 *)&data[4]); + data[6] = phy[1].signal; + data[7] = phy[1].service; + + put_unaligned(phy[2].len, (u16 *)&data[8]); + data[10] = phy[2].signal; + data[11] = phy[2].service; + + put_unaligned(phy[3].len, (u16 *)&data[12]); + data[14] = phy[3].signal; + data[15] = phy[3].service; + + for (i = 0; i < 9; i++) { + data[16 + i * 2] = tx_rate[i]; + data[16 + i * 2 + 1] = rsv_time[i]; + } + + vnt_control_out(priv, MESSAGE_TYPE_WRITE, + MAC_REG_RSPINF_B_1, MESSAGE_REQUEST_MACREG, 34, &data[0]); } /* @@ -426,120 +382,119 @@ void CARDvSetRSPINF(struct vnt_private *pDevice, u8 byBBType) * * Parameters: * In: - * pDevice - The adapter to be set - * Out: - * none + * priv - The adapter to be set + * Out: + * none * * Return Value: None. * */ -void vUpdateIFS(struct vnt_private *pDevice) +void vUpdateIFS(struct vnt_private *priv) { - u8 byMaxMin = 0; - u8 byData[4]; - - if (pDevice->byPacketType==PK_TYPE_11A) {//0000 0000 0000 0000,11a - pDevice->uSlot = C_SLOT_SHORT; - pDevice->uSIFS = C_SIFS_A; - pDevice->uDIFS = C_SIFS_A + 2*C_SLOT_SHORT; - pDevice->uCwMin = C_CWMIN_A; - byMaxMin = 4; - } - else if (pDevice->byPacketType==PK_TYPE_11B) {//0000 0001 0000 0000,11b - pDevice->uSlot = C_SLOT_LONG; - pDevice->uSIFS = C_SIFS_BG; - pDevice->uDIFS = C_SIFS_BG + 2*C_SLOT_LONG; - pDevice->uCwMin = C_CWMIN_B; - byMaxMin = 5; - } - else {// PK_TYPE_11GA & PK_TYPE_11GB - u8 byRate = 0; - bool bOFDMRate = false; - unsigned int ii = 0; - PWLAN_IE_SUPP_RATES pItemRates = NULL; - - pDevice->uSIFS = C_SIFS_BG; - if (pDevice->bShortSlotTime) { - pDevice->uSlot = C_SLOT_SHORT; - } else { - pDevice->uSlot = C_SLOT_LONG; - } - pDevice->uDIFS = C_SIFS_BG + 2*pDevice->uSlot; - - pItemRates = (PWLAN_IE_SUPP_RATES)pDevice->vnt_mgmt.abyCurrSuppRates; - for (ii = 0; ii < pItemRates->len; ii++) { - byRate = (u8)(pItemRates->abyRates[ii]&0x7F); - if (RATEwGetRateIdx(byRate) > RATE_11M) { - bOFDMRate = true; - break; - } - } - if (bOFDMRate == false) { - pItemRates = (PWLAN_IE_SUPP_RATES)pDevice->vnt_mgmt - .abyCurrExtSuppRates; - for (ii = 0; ii < pItemRates->len; ii++) { - byRate = (u8)(pItemRates->abyRates[ii]&0x7F); - if (RATEwGetRateIdx(byRate) > RATE_11M) { - bOFDMRate = true; - break; - } - } - } - if (bOFDMRate == true) { - pDevice->uCwMin = C_CWMIN_A; - byMaxMin = 4; - } else { - pDevice->uCwMin = C_CWMIN_B; - byMaxMin = 5; - } - } - - pDevice->uCwMax = C_CWMAX; - pDevice->uEIFS = C_EIFS; - - byData[0] = (u8)pDevice->uSIFS; - byData[1] = (u8)pDevice->uDIFS; - byData[2] = (u8)pDevice->uEIFS; - byData[3] = (u8)pDevice->uSlot; - CONTROLnsRequestOut(pDevice, - MESSAGE_TYPE_WRITE, - MAC_REG_SIFS, - MESSAGE_REQUEST_MACREG, - 4, - &byData[0]); - - byMaxMin |= 0xA0;//1010 1111,C_CWMAX = 1023 - CONTROLnsRequestOut(pDevice, - MESSAGE_TYPE_WRITE, - MAC_REG_CWMAXMIN0, - MESSAGE_REQUEST_MACREG, - 1, - &byMaxMin); + u8 max_min = 0; + u8 data[4]; + + if (priv->byPacketType == PK_TYPE_11A) { + priv->uSlot = C_SLOT_SHORT; + priv->uSIFS = C_SIFS_A; + priv->uDIFS = C_SIFS_A + 2 * C_SLOT_SHORT; + priv->uCwMin = C_CWMIN_A; + max_min = 4; + } else if (priv->byPacketType == PK_TYPE_11B) { + priv->uSlot = C_SLOT_LONG; + priv->uSIFS = C_SIFS_BG; + priv->uDIFS = C_SIFS_BG + 2 * C_SLOT_LONG; + priv->uCwMin = C_CWMIN_B; + max_min = 5; + } else {/* PK_TYPE_11GA & PK_TYPE_11GB */ + u8 rate = 0; + bool ofdm_rate = false; + unsigned int ii = 0; + PWLAN_IE_SUPP_RATES item_rates = NULL; + + priv->uSIFS = C_SIFS_BG; + + if (priv->bShortSlotTime) + priv->uSlot = C_SLOT_SHORT; + else + priv->uSlot = C_SLOT_LONG; + + priv->uDIFS = C_SIFS_BG + 2 * priv->uSlot; + + item_rates = + (PWLAN_IE_SUPP_RATES)priv->vnt_mgmt.abyCurrSuppRates; + + for (ii = 0; ii < item_rates->len; ii++) { + rate = (u8)(item_rates->abyRates[ii] & 0x7f); + if (RATEwGetRateIdx(rate) > RATE_11M) { + ofdm_rate = true; + break; + } + } + + if (ofdm_rate == false) { + item_rates = (PWLAN_IE_SUPP_RATES)priv->vnt_mgmt + .abyCurrExtSuppRates; + for (ii = 0; ii < item_rates->len; ii++) { + rate = (u8)(item_rates->abyRates[ii] & 0x7f); + if (RATEwGetRateIdx(rate) > RATE_11M) { + ofdm_rate = true; + break; + } + } + } + + if (ofdm_rate == true) { + priv->uCwMin = C_CWMIN_A; + max_min = 4; + } else { + priv->uCwMin = C_CWMIN_B; + max_min = 5; + } + } + + priv->uCwMax = C_CWMAX; + priv->uEIFS = C_EIFS; + + data[0] = (u8)priv->uSIFS; + data[1] = (u8)priv->uDIFS; + data[2] = (u8)priv->uEIFS; + data[3] = (u8)priv->uSlot; + + vnt_control_out(priv, MESSAGE_TYPE_WRITE, MAC_REG_SIFS, + MESSAGE_REQUEST_MACREG, 4, &data[0]); + + max_min |= 0xa0; + + vnt_control_out(priv, MESSAGE_TYPE_WRITE, MAC_REG_CWMAXMIN0, + MESSAGE_REQUEST_MACREG, 1, &max_min); } -void CARDvUpdateBasicTopRate(struct vnt_private *pDevice) +void CARDvUpdateBasicTopRate(struct vnt_private *priv) { - u8 byTopOFDM = RATE_24M, byTopCCK = RATE_1M; - u8 ii; - - //Determines the highest basic rate. - for (ii = RATE_54M; ii >= RATE_6M; ii --) { - if ( (pDevice->wBasicRate) & ((u16)(1<<ii)) ) { - byTopOFDM = ii; - break; - } - } - pDevice->byTopOFDMBasicRate = byTopOFDM; - - for (ii = RATE_11M;; ii --) { - if ( (pDevice->wBasicRate) & ((u16)(1<<ii)) ) { - byTopCCK = ii; - break; - } - if (ii == RATE_1M) - break; - } - pDevice->byTopCCKBasicRate = byTopCCK; + u8 top_ofdm = RATE_24M, top_cck = RATE_1M; + u8 i; + + /*Determines the highest basic rate.*/ + for (i = RATE_54M; i >= RATE_6M; i--) { + if (priv->wBasicRate & (u16)(1 << i)) { + top_ofdm = i; + break; + } + } + + priv->byTopOFDMBasicRate = top_ofdm; + + for (i = RATE_11M;; i--) { + if (priv->wBasicRate & (u16)(1 << i)) { + top_cck = i; + break; + } + if (i == RATE_1M) + break; + } + + priv->byTopCCKBasicRate = top_cck; } /* @@ -555,39 +510,36 @@ void CARDvUpdateBasicTopRate(struct vnt_private *pDevice) * Return Value: true if succeeded; false if failed. * */ -void CARDbAddBasicRate(struct vnt_private *pDevice, u16 wRateIdx) +void CARDbAddBasicRate(struct vnt_private *priv, u16 rate_idx) { - u16 wRate = (1 << wRateIdx); - pDevice->wBasicRate |= wRate; + priv->wBasicRate |= (1 << rate_idx); - //Determines the highest basic rate. - CARDvUpdateBasicTopRate(pDevice); + /*Determines the highest basic rate.*/ + CARDvUpdateBasicTopRate(priv); } -int CARDbIsOFDMinBasicRate(struct vnt_private *pDevice) +int CARDbIsOFDMinBasicRate(struct vnt_private *priv) { int ii; - for (ii = RATE_54M; ii >= RATE_6M; ii --) { - if ((pDevice->wBasicRate) & ((u16)(1<<ii))) - return true; - } - return false; + for (ii = RATE_54M; ii >= RATE_6M; ii--) { + if ((priv->wBasicRate) & ((u16)(1 << ii))) + return true; + } + + return false; } -u8 CARDbyGetPktType(struct vnt_private *pDevice) +u8 CARDbyGetPktType(struct vnt_private *priv) { - if (pDevice->byBBType == BB_TYPE_11A || pDevice->byBBType == BB_TYPE_11B) { - return (u8)pDevice->byBBType; - } - else if (CARDbIsOFDMinBasicRate(pDevice)) { - return PK_TYPE_11GA; - } - else { - return PK_TYPE_11GB; - } + if (priv->byBBType == BB_TYPE_11A || priv->byBBType == BB_TYPE_11B) + return (u8)priv->byBBType; + else if (CARDbIsOFDMinBasicRate(priv)) + return PK_TYPE_11GA; + else + return PK_TYPE_11GB; } /* @@ -596,27 +548,27 @@ u8 CARDbyGetPktType(struct vnt_private *pDevice) * * Parameters: * In: - * pDevice - The adapter to be sync. - * qwTSF1 - Rx BCN's TSF - * qwTSF2 - Local TSF + * rx_rate - rx rate. + * tsf1 - Rx BCN's TSF + * tsf2 - Local TSF * Out: * none * * Return Value: TSF Offset value * */ -u64 CARDqGetTSFOffset(u8 byRxRate, u64 qwTSF1, u64 qwTSF2) +u64 CARDqGetTSFOffset(u8 rx_rate, u64 tsf1, u64 tsf2) { - u64 qwTSFOffset = 0; - u16 wRxBcnTSFOffst = 0; + u64 tsf_offset = 0; + u16 rx_bcn_offset = 0; - wRxBcnTSFOffst = cwRXBCNTSFOff[byRxRate % MAX_RATE]; + rx_bcn_offset = cwRXBCNTSFOff[rx_rate % MAX_RATE]; - qwTSF2 += (u64)wRxBcnTSFOffst; + tsf2 += (u64)rx_bcn_offset; - qwTSFOffset = qwTSF1 - qwTSF2; + tsf_offset = tsf1 - tsf2; - return qwTSFOffset; + return tsf_offset; } /* @@ -625,42 +577,34 @@ u64 CARDqGetTSFOffset(u8 byRxRate, u64 qwTSF1, u64 qwTSF2) * * Parameters: * In: - * pDevice - The adapter to be sync. - * qwBSSTimestamp - Rx BCN's TSF - * qwLocalTSF - Local TSF + * priv - The adapter to be sync. + * time_stamp - Rx BCN's TSF + * local_tsf - Local TSF * Out: * none * * Return Value: none * */ -void CARDvAdjustTSF(struct vnt_private *pDevice, u8 byRxRate, - u64 qwBSSTimestamp, u64 qwLocalTSF) +void CARDvAdjustTSF(struct vnt_private *priv, u8 rx_rate, + u64 time_stamp, u64 local_tsf) { - u64 qwTSFOffset = 0; - u8 pbyData[8]; - - qwTSFOffset = CARDqGetTSFOffset(byRxRate, qwBSSTimestamp, qwLocalTSF); - // adjust TSF - // HW's TSF add TSF Offset reg - - pbyData[0] = (u8)qwTSFOffset; - pbyData[1] = (u8)(qwTSFOffset >> 8); - pbyData[2] = (u8)(qwTSFOffset >> 16); - pbyData[3] = (u8)(qwTSFOffset >> 24); - pbyData[4] = (u8)(qwTSFOffset >> 32); - pbyData[5] = (u8)(qwTSFOffset >> 40); - pbyData[6] = (u8)(qwTSFOffset >> 48); - pbyData[7] = (u8)(qwTSFOffset >> 56); - - CONTROLnsRequestOut(pDevice, - MESSAGE_TYPE_SET_TSFTBTT, - MESSAGE_REQUEST_TSF, - 0, - 8, - pbyData - ); - + u64 tsf_offset = 0; + u8 data[8]; + + tsf_offset = CARDqGetTSFOffset(rx_rate, time_stamp, local_tsf); + + data[0] = (u8)tsf_offset; + data[1] = (u8)(tsf_offset >> 8); + data[2] = (u8)(tsf_offset >> 16); + data[3] = (u8)(tsf_offset >> 24); + data[4] = (u8)(tsf_offset >> 32); + data[5] = (u8)(tsf_offset >> 40); + data[6] = (u8)(tsf_offset >> 48); + data[7] = (u8)(tsf_offset >> 56); + + vnt_control_out(priv, MESSAGE_TYPE_SET_TSFTBTT, + MESSAGE_REQUEST_TSF, 0, 8, data); } /* * Description: Read NIC TSF counter @@ -668,17 +612,17 @@ void CARDvAdjustTSF(struct vnt_private *pDevice, u8 byRxRate, * * Parameters: * In: - * pDevice - The adapter to be read + * priv - The adapter to be read * Out: - * qwCurrTSF - Current TSF counter + * current_tsf - Current TSF counter * * Return Value: true if success; otherwise false * */ -bool CARDbGetCurrentTSF(struct vnt_private *pDevice, u64 *pqwCurrTSF) +bool CARDbGetCurrentTSF(struct vnt_private *priv, u64 *current_tsf) { - *pqwCurrTSF = pDevice->qwCurrTSF; + *current_tsf = priv->qwCurrTSF; return true; } @@ -689,17 +633,17 @@ bool CARDbGetCurrentTSF(struct vnt_private *pDevice, u64 *pqwCurrTSF) * * Parameters: * In: - * pDevice - The adapter to be read + * priv - The adapter to be read * * Return Value: true if success; otherwise false * */ -bool CARDbClearCurrentTSF(struct vnt_private *pDevice) +bool CARDbClearCurrentTSF(struct vnt_private *priv) { - MACvRegBitsOn(pDevice, MAC_REG_TFTCTL, TFTCTL_TSFCNTRST); + MACvRegBitsOn(priv, MAC_REG_TFTCTL, TFTCTL_TSFCNTRST); - pDevice->qwCurrTSF = 0; + priv->qwCurrTSF = 0; return true; } @@ -710,30 +654,30 @@ bool CARDbClearCurrentTSF(struct vnt_private *pDevice) * * Parameters: * In: - * qwTSF - Current TSF counter - * wbeaconInterval - Beacon Interval + * tsf - Current TSF counter + * beacon_interval - Beacon Interval * Out: - * qwCurrTSF - Current TSF counter + * tsf - Current TSF counter * * Return Value: TSF value of next Beacon * */ -u64 CARDqGetNextTBTT(u64 qwTSF, u16 wBeaconInterval) +u64 CARDqGetNextTBTT(u64 tsf, u16 beacon_interval) { - u32 uBeaconInterval; + u32 beacon_int; - uBeaconInterval = wBeaconInterval * 1024; + beacon_int = beacon_interval * 1024; /* Next TBTT = * ((local_current_TSF / beacon_interval) + 1) * beacon_interval */ - if (uBeaconInterval) { - do_div(qwTSF, uBeaconInterval); - qwTSF += 1; - qwTSF *= uBeaconInterval; + if (beacon_int) { + do_div(tsf, beacon_int); + tsf += 1; + tsf *= beacon_int; } - return qwTSF; + return tsf; } /* @@ -743,41 +687,35 @@ u64 CARDqGetNextTBTT(u64 qwTSF, u16 wBeaconInterval) * Parameters: * In: * dwIoBase - IO Base - * wBeaconInterval - Beacon Interval + * beacon_interval - Beacon Interval * Out: * none * * Return Value: none * */ -void CARDvSetFirstNextTBTT(struct vnt_private *pDevice, u16 wBeaconInterval) +void CARDvSetFirstNextTBTT(struct vnt_private *priv, u16 beacon_interval) { - u64 qwNextTBTT = 0; - u8 pbyData[8]; - - CARDbClearCurrentTSF(pDevice); - //CARDbGetCurrentTSF(pDevice, &qwNextTBTT); //Get Local TSF counter - qwNextTBTT = CARDqGetNextTBTT(qwNextTBTT, wBeaconInterval); - // Set NextTBTT - - pbyData[0] = (u8)qwNextTBTT; - pbyData[1] = (u8)(qwNextTBTT >> 8); - pbyData[2] = (u8)(qwNextTBTT >> 16); - pbyData[3] = (u8)(qwNextTBTT >> 24); - pbyData[4] = (u8)(qwNextTBTT >> 32); - pbyData[5] = (u8)(qwNextTBTT >> 40); - pbyData[6] = (u8)(qwNextTBTT >> 48); - pbyData[7] = (u8)(qwNextTBTT >> 56); - - CONTROLnsRequestOut(pDevice, - MESSAGE_TYPE_SET_TSFTBTT, - MESSAGE_REQUEST_TBTT, - 0, - 8, - pbyData - ); - - return; + u64 next_tbtt = 0; + u8 data[8]; + + CARDbClearCurrentTSF(priv); + + next_tbtt = CARDqGetNextTBTT(next_tbtt, beacon_interval); + + data[0] = (u8)next_tbtt; + data[1] = (u8)(next_tbtt >> 8); + data[2] = (u8)(next_tbtt >> 16); + data[3] = (u8)(next_tbtt >> 24); + data[4] = (u8)(next_tbtt >> 32); + data[5] = (u8)(next_tbtt >> 40); + data[6] = (u8)(next_tbtt >> 48); + data[7] = (u8)(next_tbtt >> 56); + + vnt_control_out(priv, MESSAGE_TYPE_SET_TSFTBTT, + MESSAGE_REQUEST_TBTT, 0, 8, data); + + return; } /* @@ -786,45 +724,37 @@ void CARDvSetFirstNextTBTT(struct vnt_private *pDevice, u16 wBeaconInterval) * * Parameters: * In: - * pDevice - The adapter to be set - * qwTSF - Current TSF counter - * wBeaconInterval - Beacon Interval + * priv - The adapter to be set + * tsf - Current TSF counter + * beacon_interval - Beacon Interval * Out: * none * * Return Value: none * */ -void CARDvUpdateNextTBTT(struct vnt_private *pDevice, u64 qwTSF, - u16 wBeaconInterval) +void CARDvUpdateNextTBTT(struct vnt_private *priv, u64 tsf, + u16 beacon_interval) { - u8 pbyData[8]; - - qwTSF = CARDqGetNextTBTT(qwTSF, wBeaconInterval); + u8 data[8]; - // Set NextTBTT + tsf = CARDqGetNextTBTT(tsf, beacon_interval); - pbyData[0] = (u8)qwTSF; - pbyData[1] = (u8)(qwTSF >> 8); - pbyData[2] = (u8)(qwTSF >> 16); - pbyData[3] = (u8)(qwTSF >> 24); - pbyData[4] = (u8)(qwTSF >> 32); - pbyData[5] = (u8)(qwTSF >> 40); - pbyData[6] = (u8)(qwTSF >> 48); - pbyData[7] = (u8)(qwTSF >> 56); + data[0] = (u8)tsf; + data[1] = (u8)(tsf >> 8); + data[2] = (u8)(tsf >> 16); + data[3] = (u8)(tsf >> 24); + data[4] = (u8)(tsf >> 32); + data[5] = (u8)(tsf >> 40); + data[6] = (u8)(tsf >> 48); + data[7] = (u8)(tsf >> 56); - CONTROLnsRequestOut(pDevice, - MESSAGE_TYPE_SET_TSFTBTT, - MESSAGE_REQUEST_TBTT, - 0, - 8, - pbyData - ); + vnt_control_out(priv, MESSAGE_TYPE_SET_TSFTBTT, + MESSAGE_REQUEST_TBTT, 0, 8, data); - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO - "Card:Update Next TBTT[%8lx]\n", (unsigned long)qwTSF); + dev_dbg(&priv->usb->dev, "%s TBTT: %8llx\n", __func__, tsf); - return; + return; } /* @@ -832,38 +762,36 @@ void CARDvUpdateNextTBTT(struct vnt_private *pDevice, u64 qwTSF, * * 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 * */ -int CARDbRadioPowerOff(struct vnt_private *pDevice) +int CARDbRadioPowerOff(struct vnt_private *priv) { - int bResult = true; - - //if (pDevice->bRadioOff == true) - // return true; - - pDevice->bRadioOff = true; - - switch (pDevice->byRFType) { - case RF_AL2230: - case RF_AL2230S: - case RF_AIROHA7230: - case RF_VT3226: //RobertYu:20051111 - case RF_VT3226D0: - case RF_VT3342A0: //RobertYu:20060609 - MACvRegBitsOff(pDevice, MAC_REG_SOFTPWRCTL, (SOFTPWRCTL_SWPE2 | SOFTPWRCTL_SWPE3)); - break; - } + int ret = true; + + priv->bRadioOff = true; + + switch (priv->byRFType) { + case RF_AL2230: + case RF_AL2230S: + case RF_AIROHA7230: + case RF_VT3226: + case RF_VT3226D0: + case RF_VT3342A0: + MACvRegBitsOff(priv, MAC_REG_SOFTPWRCTL, + (SOFTPWRCTL_SWPE2 | SOFTPWRCTL_SWPE3)); + break; + } - MACvRegBitsOff(pDevice, MAC_REG_HOSTCR, HOSTCR_RXON); + MACvRegBitsOff(priv, MAC_REG_HOSTCR, HOSTCR_RXON); - BBvSetDeepSleep(pDevice); + BBvSetDeepSleep(priv); - return bResult; + return ret; } /* @@ -871,84 +799,79 @@ int 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 * */ -int CARDbRadioPowerOn(struct vnt_private *pDevice) +int CARDbRadioPowerOn(struct vnt_private *priv) { - int bResult = true; + int ret = true; - if ((pDevice->bHWRadioOff == true) || (pDevice->bRadioControlOff == true)) { - return false; - } + if (priv->bHWRadioOff == true || priv->bRadioControlOff == true) + return false; - //if (pDevice->bRadioOff == false) - // return true; + priv->bRadioOff = false; - pDevice->bRadioOff = false; + BBvExitDeepSleep(priv); - BBvExitDeepSleep(pDevice); + MACvRegBitsOn(priv, MAC_REG_HOSTCR, HOSTCR_RXON); - MACvRegBitsOn(pDevice, MAC_REG_HOSTCR, HOSTCR_RXON); - - switch (pDevice->byRFType) { - case RF_AL2230: - case RF_AL2230S: - case RF_AIROHA7230: - case RF_VT3226: //RobertYu:20051111 - case RF_VT3226D0: - case RF_VT3342A0: //RobertYu:20060609 - MACvRegBitsOn(pDevice, MAC_REG_SOFTPWRCTL, (SOFTPWRCTL_SWPE2 | SOFTPWRCTL_SWPE3)); - break; - } + switch (priv->byRFType) { + case RF_AL2230: + case RF_AL2230S: + case RF_AIROHA7230: + case RF_VT3226: + case RF_VT3226D0: + case RF_VT3342A0: + MACvRegBitsOn(priv, MAC_REG_SOFTPWRCTL, + (SOFTPWRCTL_SWPE2 | SOFTPWRCTL_SWPE3)); + break; + } - return bResult; + return ret; } -void CARDvSetBSSMode(struct vnt_private *pDevice) +void CARDvSetBSSMode(struct vnt_private *priv) { - // Set BB and packet type at the same time.//{{RobertYu:20050222, AL7230 have two TX PA output, only connet to b/g now - // so in 11a mode need to set the MAC Reg0x4C to 11b/g mode to turn on PA - if( (pDevice->byRFType == RF_AIROHA7230 ) && (pDevice->byBBType == BB_TYPE_11A) ) - { - MACvSetBBType(pDevice, BB_TYPE_11G); - } - else - { - MACvSetBBType(pDevice, pDevice->byBBType); - } - pDevice->byPacketType = CARDbyGetPktType(pDevice); - - if (pDevice->byBBType == BB_TYPE_11A) { - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0x88, 0x03); - } else if (pDevice->byBBType == BB_TYPE_11B) { - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0x88, 0x02); - } else if (pDevice->byBBType == BB_TYPE_11G) { - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0x88, 0x08); - } - - vUpdateIFS(pDevice); - CARDvSetRSPINF(pDevice, (u8)pDevice->byBBType); - - if ( pDevice->byBBType == BB_TYPE_11A ) { - //request by Jack 2005-04-26 - if (pDevice->byRFType == RF_AIROHA7230) { - pDevice->abyBBVGA[0] = 0x20; - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xE7, pDevice->abyBBVGA[0]); - } - pDevice->abyBBVGA[2] = 0x10; - pDevice->abyBBVGA[3] = 0x10; - } else { - //request by Jack 2005-04-26 - if (pDevice->byRFType == RF_AIROHA7230) { - pDevice->abyBBVGA[0] = 0x1C; - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xE7, pDevice->abyBBVGA[0]); - } - pDevice->abyBBVGA[2] = 0x0; - pDevice->abyBBVGA[3] = 0x0; - } + if (priv->byRFType == RF_AIROHA7230 && priv->byBBType == BB_TYPE_11A) + MACvSetBBType(priv, BB_TYPE_11G); + else + MACvSetBBType(priv, priv->byBBType); + + priv->byPacketType = CARDbyGetPktType(priv); + + if (priv->byBBType == BB_TYPE_11A) + vnt_control_out_u8(priv, MESSAGE_REQUEST_BBREG, 0x88, 0x03); + else if (priv->byBBType == BB_TYPE_11B) + vnt_control_out_u8(priv, MESSAGE_REQUEST_BBREG, 0x88, 0x02); + else if (priv->byBBType == BB_TYPE_11G) + vnt_control_out_u8(priv, MESSAGE_REQUEST_BBREG, 0x88, 0x08); + + vUpdateIFS(priv); + CARDvSetRSPINF(priv, (u8)priv->byBBType); + + if (priv->byBBType == BB_TYPE_11A) { + if (priv->byRFType == RF_AIROHA7230) { + priv->abyBBVGA[0] = 0x20; + + vnt_control_out_u8(priv, MESSAGE_REQUEST_BBREG, + 0xe7, priv->abyBBVGA[0]); + } + + priv->abyBBVGA[2] = 0x10; + priv->abyBBVGA[3] = 0x10; + } else { + if (priv->byRFType == RF_AIROHA7230) { + priv->abyBBVGA[0] = 0x1c; + + vnt_control_out_u8(priv, MESSAGE_REQUEST_BBREG, + 0xe7, priv->abyBBVGA[0]); + } + + priv->abyBBVGA[2] = 0x0; + priv->abyBBVGA[3] = 0x0; + } } |