/*+ * * Description: * Parsing the highest basic & support rate in rate field of frame. * * Parameters: * In: * pDevice - Pointer to the adapter * pItemRates - Pointer to Rate field defined in 802.11 spec. * pItemExtRates - Pointer to Extended Rate field defined in 802.11 spec. * Out: * pwMaxBasicRate - Maximum Basic Rate * pwMaxSuppRate - Maximum Supported Rate * pbyTopCCKRate - Maximum Basic Rate in CCK mode * pbyTopOFDMRate - Maximum Basic Rate in OFDM mode * * Return Value: none * -*/ void RATEvParseMaxRate( void *pDeviceHandler, PWLAN_IE_SUPP_RATES pItemRates, PWLAN_IE_SUPP_RATES pItemExtRates, BOOL bUpdateBasicRate, PWORD pwMaxBasicRate, PWORD pwMaxSuppRate, PWORD pwSuppRate, PBYTE pbyTopCCKRate, PBYTE pbyTopOFDMRate ) { PSDevice pDevice = (PSDevice) pDeviceHandler; unsigned int ii; BYTE byHighSuppRate = 0; BYTE byRate = 0; WORD wOldBasicRate = pDevice->wBasicRate; unsigned int uRateLen; if (pItemRates == NULL) return; *pwSuppRate = 0; uRateLen = pItemRates->len; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"ParseMaxRate Len: %d\n", uRateLen); if (pDevice->byBBType != BB_TYPE_11B) { if (uRateLen > WLAN_RATES_MAXLEN) uRateLen = WLAN_RATES_MAXLEN; } else { if (uRateLen > WLAN_RATES_MAXLEN_11B) uRateLen = WLAN_RATES_MAXLEN_11B; } for (ii = 0; ii < uRateLen; ii++) { byRate = (BYTE)(pItemRates->abyRates[ii]); if (WLAN_MGMT_IS_BASICRATE(byRate) && (bUpdateBasicRate == TRUE)) { // Add to basic rate set, update pDevice->byTopCCKBasicRate and pDevice->byTopOFDMBasicRate CARDbAddBasicRate((void *)pDevice, RATEwGetRateIdx(byRate)); DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"ParseMaxRate AddBasicRate: %d\n", RATEwGetRateIdx(byRate)); } byRate = (BYTE)(pItemRates->abyRates[ii]&0x7F); if (byHighSuppRate == 0) byHighSuppRate = byRate; if (byRate > byHighSuppRate) byHighSuppRate = byRate; *pwSuppRate |= (1<<RATEwGetRateIdx(byRate)); } if ((pItemExtRates != NULL) && (pItemExtRates->byElementID == WLAN_EID_EXTSUPP_RATES) && (pDevice->byBBType != BB_TYPE_11B)) { unsigned int uExtRateLen = pItemExtRates->len; if (uExtRateLen > WLAN_RATES_MAXLEN) uExtRateLen = WLAN_RATES_MAXLEN; for (ii = 0; ii < uExtRateLen ; ii++) { byRate = (BYTE)(pItemExtRates->abyRates[ii]); // select highest basic rate if (WLAN_MGMT_IS_BASICRATE(pItemExtRates->abyRates[ii])) { // Add to basic rate set, update pDevice->byTopCCKBasicRate and pDevice->byTopOFDMBasicRate CARDbAddBasicRate((void *)pDevice, RATEwGetRateIdx(byRate)); DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"ParseMaxRate AddBasicRate: %d\n", RATEwGetRateIdx(byRate)); } byRate = (BYTE)(pItemExtRates->abyRates[ii]&0x7F); if (byHighSuppRate == 0) byHighSuppRate = byRate; if (byRate > byHighSuppRate) byHighSuppRate = byRate; *pwSuppRate |= (1<<RATEwGetRateIdx(byRate)); //DBG_PRN_GRP09(("ParseMaxRate : HighSuppRate: %d, %X\n", RATEwGetRateIdx(byRate), byRate)); } } //if(pItemExtRates != NULL) if ((pDevice->byPacketType == PK_TYPE_11GB) && CARDbIsOFDMinBasicRate((void *)pDevice)) { pDevice->byPacketType = PK_TYPE_11GA; } *pbyTopCCKRate = pDevice->byTopCCKBasicRate; *pbyTopOFDMRate = pDevice->byTopOFDMBasicRate; *pwMaxSuppRate = RATEwGetRateIdx(byHighSuppRate); if ((pDevice->byPacketType==PK_TYPE_11B) || (pDevice->byPacketType==PK_TYPE_11GB)) *pwMaxBasicRate = pDevice->byTopCCKBasicRate; else *pwMaxBasicRate = pDevice->byTopOFDMBasicRate; if (wOldBasicRate != pDevice->wBasicRate) CARDvSetRSPINF((void *)pDevice, pDevice->byBBType); DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Exit ParseMaxRate\n"); }
/* * initialization of MAC & BBP registers */ static int device_init_registers(struct vnt_private *pDevice) { struct vnt_manager *pMgmt = &pDevice->vnt_mgmt; struct vnt_cmd_card_init *init_cmd = &pDevice->init_command; struct vnt_rsp_card_init *init_rsp = &pDevice->init_response; u8 abyBroadcastAddr[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; u8 abySNAP_RFC1042[ETH_ALEN] = {0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00}; u8 abySNAP_Bridgetunnel[ETH_ALEN] = {0xaa, 0xaa, 0x03, 0x00, 0x00, 0xf8}; u8 byAntenna; int ii; int ntStatus = STATUS_SUCCESS; u8 byTmp; u8 byCalibTXIQ = 0, byCalibTXDC = 0, byCalibRXIQ = 0; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "---->INIbInitAdapter. [%d][%d]\n", DEVICE_INIT_COLD, pDevice->byPacketType); spin_lock_irq(&pDevice->lock); memcpy(pDevice->abyBroadcastAddr, abyBroadcastAddr, ETH_ALEN); memcpy(pDevice->abySNAP_RFC1042, abySNAP_RFC1042, ETH_ALEN); memcpy(pDevice->abySNAP_Bridgetunnel, abySNAP_Bridgetunnel, ETH_ALEN); if (!FIRMWAREbCheckVersion(pDevice)) { if (FIRMWAREbDownload(pDevice) == true) { if (FIRMWAREbBrach2Sram(pDevice) == false) { DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " FIRMWAREbBrach2Sram fail\n"); spin_unlock_irq(&pDevice->lock); return false; } } else { DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " FIRMWAREbDownload fail\n"); spin_unlock_irq(&pDevice->lock); return false; } } if (!BBbVT3184Init(pDevice)) { DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" BBbVT3184Init fail\n"); spin_unlock_irq(&pDevice->lock); return false; } init_cmd->init_class = DEVICE_INIT_COLD; init_cmd->exist_sw_net_addr = (u8) pDevice->bExistSWNetAddr; for (ii = 0; ii < 6; ii++) init_cmd->sw_net_addr[ii] = pDevice->abyCurrentNetAddr[ii]; init_cmd->short_retry_limit = pDevice->byShortRetryLimit; init_cmd->long_retry_limit = pDevice->byLongRetryLimit; /* issue card_init command to device */ ntStatus = CONTROLnsRequestOut(pDevice, MESSAGE_TYPE_CARDINIT, 0, 0, sizeof(struct vnt_cmd_card_init), (u8 *)init_cmd); if (ntStatus != STATUS_SUCCESS) { DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" Issue Card init fail\n"); spin_unlock_irq(&pDevice->lock); return false; } ntStatus = CONTROLnsRequestIn(pDevice, MESSAGE_TYPE_INIT_RSP, 0, 0, sizeof(struct vnt_rsp_card_init), (u8 *)init_rsp); if (ntStatus != STATUS_SUCCESS) { DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Cardinit request in status fail!\n"); spin_unlock_irq(&pDevice->lock); return false; } /* local ID for AES functions */ ntStatus = CONTROLnsRequestIn(pDevice, MESSAGE_TYPE_READ, MAC_REG_LOCALID, MESSAGE_REQUEST_MACREG, 1, &pDevice->byLocalID); if (ntStatus != STATUS_SUCCESS) { spin_unlock_irq(&pDevice->lock); return false; } /* do MACbSoftwareReset in MACvInitialize */ /* force CCK */ pDevice->bCCK = true; pDevice->bProtectMode = false; /* only used in 11g type, sync with ERP IE */ pDevice->bNonERPPresent = false; pDevice->bBarkerPreambleMd = false; if (pDevice->bFixRate) { pDevice->wCurrentRate = (u16)pDevice->uConnectionRate; } else { if (pDevice->byBBType == BB_TYPE_11B) pDevice->wCurrentRate = RATE_11M; else pDevice->wCurrentRate = RATE_54M; } CHvInitChannelTable(pDevice); pDevice->byTopOFDMBasicRate = RATE_24M; pDevice->byTopCCKBasicRate = RATE_1M; pDevice->byRevId = 0; /* target to IF pin while programming to RF chip */ pDevice->byCurPwr = 0xFF; pDevice->byCCKPwr = pDevice->abyEEPROM[EEP_OFS_PWR_CCK]; pDevice->byOFDMPwrG = pDevice->abyEEPROM[EEP_OFS_PWR_OFDMG]; /* load power table */ for (ii = 0; ii < 14; ii++) { pDevice->abyCCKPwrTbl[ii] = pDevice->abyEEPROM[ii + EEP_OFS_CCK_PWR_TBL]; if (pDevice->abyCCKPwrTbl[ii] == 0) pDevice->abyCCKPwrTbl[ii] = pDevice->byCCKPwr; pDevice->abyOFDMPwrTbl[ii] = pDevice->abyEEPROM[ii + EEP_OFS_OFDM_PWR_TBL]; if (pDevice->abyOFDMPwrTbl[ii] == 0) pDevice->abyOFDMPwrTbl[ii] = pDevice->byOFDMPwrG; } /* * original zonetype is USA, but custom zonetype is Europe, * then need to recover 12, 13, 14 channels with 11 channel */ if (((pDevice->abyEEPROM[EEP_OFS_ZONETYPE] == ZoneType_Japan) || (pDevice->abyEEPROM[EEP_OFS_ZONETYPE] == ZoneType_Europe)) && (pDevice->byOriginalZonetype == ZoneType_USA)) { for (ii = 11; ii < 14; ii++) { pDevice->abyCCKPwrTbl[ii] = pDevice->abyCCKPwrTbl[10]; pDevice->abyOFDMPwrTbl[ii] = pDevice->abyOFDMPwrTbl[10]; } } pDevice->byOFDMPwrA = 0x34; /* same as RFbMA2829SelectChannel */ /* load OFDM A power table */ for (ii = 0; ii < CB_MAX_CHANNEL_5G; ii++) { pDevice->abyOFDMAPwrTbl[ii] = pDevice->abyEEPROM[ii + EEP_OFS_OFDMA_PWR_TBL]; if (pDevice->abyOFDMAPwrTbl[ii] == 0) pDevice->abyOFDMAPwrTbl[ii] = pDevice->byOFDMPwrA; } byAntenna = pDevice->abyEEPROM[EEP_OFS_ANTENNA]; if (byAntenna & EEP_ANTINV) pDevice->bTxRxAntInv = true; else pDevice->bTxRxAntInv = false; byAntenna &= (EEP_ANTENNA_AUX | EEP_ANTENNA_MAIN); if (byAntenna == 0) /* if not set default is both */ byAntenna = (EEP_ANTENNA_AUX | EEP_ANTENNA_MAIN); if (byAntenna == (EEP_ANTENNA_AUX | EEP_ANTENNA_MAIN)) { pDevice->byAntennaCount = 2; pDevice->byTxAntennaMode = ANT_B; pDevice->dwTxAntennaSel = 1; pDevice->dwRxAntennaSel = 1; if (pDevice->bTxRxAntInv == true) pDevice->byRxAntennaMode = ANT_A; else pDevice->byRxAntennaMode = ANT_B; if (pDevice->bDiversityRegCtlON) pDevice->bDiversityEnable = true; else pDevice->bDiversityEnable = false; } else { pDevice->bDiversityEnable = false; pDevice->byAntennaCount = 1; pDevice->dwTxAntennaSel = 0; pDevice->dwRxAntennaSel = 0; if (byAntenna & EEP_ANTENNA_AUX) { pDevice->byTxAntennaMode = ANT_A; if (pDevice->bTxRxAntInv == true) pDevice->byRxAntennaMode = ANT_B; else pDevice->byRxAntennaMode = ANT_A; } else { pDevice->byTxAntennaMode = ANT_B; if (pDevice->bTxRxAntInv == true) pDevice->byRxAntennaMode = ANT_A; else pDevice->byRxAntennaMode = ANT_B; } } pDevice->ulDiversityNValue = 100 * 255; pDevice->ulDiversityMValue = 100 * 16; pDevice->byTMax = 1; pDevice->byTMax2 = 4; pDevice->ulSQ3TH = 0; pDevice->byTMax3 = 64; /* get Auto Fall Back type */ pDevice->byAutoFBCtrl = AUTO_FB_0; /* set SCAN Time */ pDevice->uScanTime = WLAN_SCAN_MINITIME; /* default Auto Mode */ /* pDevice->NetworkType = Ndis802_11Automode; */ pDevice->eConfigPHYMode = PHY_TYPE_AUTO; pDevice->byBBType = BB_TYPE_11G; /* initialize BBP registers */ pDevice->ulTxPower = 25; /* get channel range */ pDevice->byMinChannel = 1; pDevice->byMaxChannel = CB_MAX_CHANNEL; /* get RFType */ pDevice->byRFType = init_rsp->rf_type; if ((pDevice->byRFType & RF_EMU) != 0) { /* force change RevID for VT3253 emu */ pDevice->byRevId = 0x80; } /* load vt3266 calibration parameters in EEPROM */ if (pDevice->byRFType == RF_VT3226D0) { if ((pDevice->abyEEPROM[EEP_OFS_MAJOR_VER] == 0x1) && (pDevice->abyEEPROM[EEP_OFS_MINOR_VER] >= 0x4)) { byCalibTXIQ = pDevice->abyEEPROM[EEP_OFS_CALIB_TX_IQ]; byCalibTXDC = pDevice->abyEEPROM[EEP_OFS_CALIB_TX_DC]; byCalibRXIQ = pDevice->abyEEPROM[EEP_OFS_CALIB_RX_IQ]; if (byCalibTXIQ || byCalibTXDC || byCalibRXIQ) { /* CR255, enable TX/RX IQ and DC compensation mode */ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xff, 0x03); /* CR251, TX I/Q Imbalance Calibration */ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xfb, byCalibTXIQ); /* CR252, TX DC-Offset Calibration */ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xfC, byCalibTXDC); /* CR253, RX I/Q Imbalance Calibration */ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xfd, byCalibRXIQ); } else { /* CR255, turn off BB Calibration compensation */ ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xff, 0x0); } } } pMgmt->eScanType = WMAC_SCAN_PASSIVE; pMgmt->uCurrChannel = pDevice->uChannel; pMgmt->uIBSSChannel = pDevice->uChannel; CARDbSetMediaChannel(pDevice, pMgmt->uCurrChannel); /* get permanent network address */ memcpy(pDevice->abyPermanentNetAddr, init_rsp->net_addr, 6); memcpy(pDevice->abyCurrentNetAddr, pDevice->abyPermanentNetAddr, ETH_ALEN); /* if exist SW network address, use it */ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Network address = %pM\n", pDevice->abyCurrentNetAddr); /* * set BB and packet type at the same time * set Short Slot Time, xIFS, and RSPINF */ if (pDevice->byBBType == BB_TYPE_11A) { CARDbAddBasicRate(pDevice, RATE_6M); pDevice->bShortSlotTime = true; } else { CARDbAddBasicRate(pDevice, RATE_1M); pDevice->bShortSlotTime = false; } BBvSetShortSlotTime(pDevice); CARDvSetBSSMode(pDevice); if (pDevice->bUpdateBBVGA) { pDevice->byBBVGACurrent = pDevice->abyBBVGA[0]; pDevice->byBBVGANew = pDevice->byBBVGACurrent; BBvSetVGAGainOffset(pDevice, pDevice->abyBBVGA[0]); } pDevice->byRadioCtl = pDevice->abyEEPROM[EEP_OFS_RADIOCTL]; pDevice->bHWRadioOff = false; if ((pDevice->byRadioCtl & EEP_RADIOCTL_ENABLE) != 0) { ntStatus = CONTROLnsRequestIn(pDevice, MESSAGE_TYPE_READ, MAC_REG_GPIOCTL1, MESSAGE_REQUEST_MACREG, 1, &byTmp); if (ntStatus != STATUS_SUCCESS) { spin_unlock_irq(&pDevice->lock); return false; } if ((byTmp & GPIO3_DATA) == 0) { pDevice->bHWRadioOff = true; MACvRegBitsOn(pDevice, MAC_REG_GPIOCTL1, GPIO3_INTMD); } else { MACvRegBitsOff(pDevice, MAC_REG_GPIOCTL1, GPIO3_INTMD); pDevice->bHWRadioOff = false; } } ControlvMaskByte(pDevice, MESSAGE_REQUEST_MACREG, MAC_REG_PAPEDELAY, LEDSTS_TMLEN, 0x38); ControlvMaskByte(pDevice, MESSAGE_REQUEST_MACREG, MAC_REG_PAPEDELAY, LEDSTS_STS, LEDSTS_SLOW); MACvRegBitsOn(pDevice, MAC_REG_GPIOCTL0, 0x01); if ((pDevice->bHWRadioOff == true) || (pDevice->bRadioControlOff == true)) { CARDbRadioPowerOff(pDevice); } else { CARDbRadioPowerOn(pDevice); } spin_unlock_irq(&pDevice->lock); DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"<----INIbInitAdapter Exit\n"); return true; }
VOID RATEvParseMaxRate ( IN PVOID pDeviceHandler, IN PWLAN_IE_SUPP_RATES pItemRates, IN PWLAN_IE_SUPP_RATES pItemExtRates, IN BOOL bUpdateBasicRate, OUT PWORD pwMaxBasicRate, OUT PWORD pwMaxSuppRate, OUT PWORD pwSuppRate, OUT PBYTE pbyTopCCKRate, OUT PBYTE pbyTopOFDMRate ) { PSDevice pDevice = (PSDevice) pDeviceHandler; UINT ii; BYTE byHighSuppRate = 0; BYTE byRate = 0; WORD wOldBasicRate = pDevice->wBasicRate; UINT uRateLen; if (pItemRates == NULL) return; *pwSuppRate = 0; uRateLen = pItemRates->len; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"ParseMaxRate Len: %d\n", uRateLen); if (pDevice->eCurrentPHYType != PHY_TYPE_11B) { if (uRateLen > WLAN_RATES_MAXLEN) uRateLen = WLAN_RATES_MAXLEN; } else { if (uRateLen > WLAN_RATES_MAXLEN_11B) uRateLen = WLAN_RATES_MAXLEN_11B; } for (ii = 0; ii < uRateLen; ii++) { byRate = (BYTE)(pItemRates->abyRates[ii]); if (WLAN_MGMT_IS_BASICRATE(byRate) && (bUpdateBasicRate == TRUE)) { CARDbAddBasicRate((PVOID)pDevice, wGetRateIdx(byRate)); DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"ParseMaxRate AddBasicRate: %d\n", wGetRateIdx(byRate)); } byRate = (BYTE)(pItemRates->abyRates[ii]&0x7F); if (byHighSuppRate == 0) byHighSuppRate = byRate; if (byRate > byHighSuppRate) byHighSuppRate = byRate; *pwSuppRate |= (1<<wGetRateIdx(byRate)); } if ((pItemExtRates != NULL) && (pItemExtRates->byElementID == WLAN_EID_EXTSUPP_RATES) && (pDevice->eCurrentPHYType != PHY_TYPE_11B)) { UINT uExtRateLen = pItemExtRates->len; if (uExtRateLen > WLAN_RATES_MAXLEN) uExtRateLen = WLAN_RATES_MAXLEN; for (ii = 0; ii < uExtRateLen ; ii++) { byRate = (BYTE)(pItemExtRates->abyRates[ii]); if (WLAN_MGMT_IS_BASICRATE(pItemExtRates->abyRates[ii])) { CARDbAddBasicRate((PVOID)pDevice, wGetRateIdx(byRate)); DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"ParseMaxRate AddBasicRate: %d\n", wGetRateIdx(byRate)); } byRate = (BYTE)(pItemExtRates->abyRates[ii]&0x7F); if (byHighSuppRate == 0) byHighSuppRate = byRate; if (byRate > byHighSuppRate) byHighSuppRate = byRate; *pwSuppRate |= (1<<wGetRateIdx(byRate)); } } if ((pDevice->byPacketType == PK_TYPE_11GB) && CARDbIsOFDMinBasicRate((PVOID)pDevice)) { pDevice->byPacketType = PK_TYPE_11GA; } *pbyTopCCKRate = pDevice->byTopCCKBasicRate; *pbyTopOFDMRate = pDevice->byTopOFDMBasicRate; *pwMaxSuppRate = wGetRateIdx(byHighSuppRate); if ((pDevice->byPacketType==PK_TYPE_11B) || (pDevice->byPacketType==PK_TYPE_11GB)) *pwMaxBasicRate = pDevice->byTopCCKBasicRate; else *pwMaxBasicRate = pDevice->byTopOFDMBasicRate; if (wOldBasicRate != pDevice->wBasicRate) CARDvSetRSPINF((PVOID)pDevice, pDevice->eCurrentPHYType); DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Exit ParseMaxRate\n"); }