2009-06-13 11:38:31 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*
|
|
|
|
* File: card.c
|
|
|
|
* Purpose: Provide functions to setup NIC operation mode
|
|
|
|
* Functions:
|
|
|
|
* s_vSafeResetTx - Rest Tx
|
2014-05-30 15:27:46 +00:00
|
|
|
* vnt_set_rspinf - Set RSPINF
|
2014-05-30 15:27:44 +00:00
|
|
|
* vnt_update_ifs - Update slotTime,SIFS,DIFS, and EIFS
|
2014-05-30 15:27:45 +00:00
|
|
|
* vnt_update_top_rates - Update BasicTopRate
|
2014-05-30 15:27:47 +00:00
|
|
|
* vnt_add_basic_rate - Add to BasicRateSet
|
2009-06-13 11:38:31 +00:00
|
|
|
* CARDbSetBasicRate - Set Basic Tx Rate
|
2014-05-30 15:27:48 +00:00
|
|
|
* vnt_ofdm_min_rate - Check if any OFDM rate is in BasicRateSet
|
2009-06-13 11:38:31 +00:00
|
|
|
* CARDvSetLoopbackMode - Set Loopback mode
|
|
|
|
* CARDbSoftwareReset - Sortware reset NIC
|
2014-05-30 15:27:50 +00:00
|
|
|
* vnt_get_tsf_offset - Calculate TSFOffset
|
2014-05-30 22:22:47 +00:00
|
|
|
* vnt_get_current_tsf - Read Current NIC TSF counter
|
2014-05-30 22:22:49 +00:00
|
|
|
* vnt_get_next_tbtt - Calculate Next Beacon TSF counter
|
2014-05-30 22:22:50 +00:00
|
|
|
* vnt_reset_next_tbtt - Set NIC Beacon time
|
2014-05-30 22:22:51 +00:00
|
|
|
* vnt_update_next_tbtt - Sync. NIC Beacon time
|
2014-05-30 22:22:52 +00:00
|
|
|
* vnt_radio_power_off - Turn Off NIC Radio Power
|
2009-06-13 11:38:31 +00:00
|
|
|
* CARDbRadioPowerOn - Turn On NIC Radio Power
|
|
|
|
* CARDbSetWEPMode - Set NIC Wep mode
|
|
|
|
* CARDbSetTxPower - Set NIC tx power
|
|
|
|
*
|
|
|
|
* Revision History:
|
|
|
|
* 06-10-2003 Bryan YC Fan: Re-write codes to support VT3253 spec.
|
2012-08-26 15:16:43 +00:00
|
|
|
* 08-26-2003 Kyle Hsu: Modify the definition type of dwIoBase.
|
2014-05-30 15:27:44 +00:00
|
|
|
* 09-01-2003 Bryan YC Fan: Add vnt_update_ifs().
|
2009-06-13 11:38:31 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2012-12-10 21:59:10 +00:00
|
|
|
#include "device.h"
|
2009-06-13 11:38:31 +00:00
|
|
|
#include "tmacro.h"
|
|
|
|
#include "card.h"
|
|
|
|
#include "baseband.h"
|
|
|
|
#include "mac.h"
|
|
|
|
#include "desc.h"
|
|
|
|
#include "rf.h"
|
|
|
|
#include "power.h"
|
|
|
|
#include "key.h"
|
|
|
|
#include "rc4.h"
|
|
|
|
#include "country.h"
|
|
|
|
#include "datarate.h"
|
2014-05-26 12:59:07 +00:00
|
|
|
#include "usbpipe.h"
|
2009-06-13 11:38:31 +00:00
|
|
|
|
2013-02-26 01:32:52 +00:00
|
|
|
//const u16 cwRXBCNTSFOff[MAX_RATE] =
|
2009-06-13 11:38:31 +00:00
|
|
|
//{17, 34, 96, 192, 34, 23, 17, 11, 8, 5, 4, 3};
|
|
|
|
|
2013-11-04 08:44:02 +00:00
|
|
|
static const u16 cwRXBCNTSFOff[MAX_RATE] =
|
2009-06-13 11:38:31 +00:00
|
|
|
{192, 96, 34, 17, 34, 23, 17, 11, 8, 5, 4, 3};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Description: Set NIC media channel
|
|
|
|
*
|
|
|
|
* Parameters:
|
|
|
|
* In:
|
|
|
|
* pDevice - The adapter to be set
|
2013-12-12 23:33:08 +00:00
|
|
|
* connection_channel - Channel to be set
|
2009-06-13 11:38:31 +00:00
|
|
|
* Out:
|
|
|
|
* none
|
|
|
|
*/
|
2014-05-30 15:27:40 +00:00
|
|
|
void vnt_set_channel(struct vnt_private *priv, u32 connection_channel)
|
2009-06-13 11:38:31 +00:00
|
|
|
{
|
|
|
|
|
2013-12-12 23:33:08 +00:00
|
|
|
if (priv->byBBType == BB_TYPE_11A) {
|
|
|
|
if ((connection_channel < (CB_MAX_CHANNEL_24G + 1)) ||
|
|
|
|
(connection_channel > CB_MAX_CHANNEL))
|
|
|
|
connection_channel = (CB_MAX_CHANNEL_24G + 1);
|
|
|
|
} else {
|
|
|
|
if ((connection_channel > CB_MAX_CHANNEL_24G) ||
|
|
|
|
(connection_channel == 0))
|
|
|
|
connection_channel = 1;
|
|
|
|
}
|
2009-06-13 11:38:31 +00:00
|
|
|
|
2013-12-12 23:33:08 +00:00
|
|
|
/* clear NAV */
|
|
|
|
MACvRegBitsOn(priv, MAC_REG_MACCR, MACCR_CLRNAV);
|
|
|
|
|
|
|
|
/* Set Channel[7] = 0 to tell H/W channel is changing now. */
|
|
|
|
MACvRegBitsOff(priv, MAC_REG_CHANNEL, 0xb0);
|
|
|
|
|
2014-05-26 12:59:01 +00:00
|
|
|
vnt_control_out(priv, MESSAGE_TYPE_SELECT_CHANNLE,
|
2013-12-12 23:33:08 +00:00
|
|
|
connection_channel, 0, 0, NULL);
|
|
|
|
|
|
|
|
if (priv->byBBType == BB_TYPE_11A) {
|
|
|
|
priv->byCurPwr = 0xff;
|
2014-05-27 20:05:22 +00:00
|
|
|
vnt_rf_set_txpower(priv,
|
2013-12-12 23:33:08 +00:00
|
|
|
priv->abyOFDMAPwrTbl[connection_channel-15], RATE_54M);
|
|
|
|
} else if (priv->byBBType == BB_TYPE_11G) {
|
|
|
|
priv->byCurPwr = 0xff;
|
2014-05-27 20:05:22 +00:00
|
|
|
vnt_rf_set_txpower(priv,
|
2013-12-12 23:33:08 +00:00
|
|
|
priv->abyOFDMPwrTbl[connection_channel-1], RATE_54M);
|
|
|
|
} else {
|
|
|
|
priv->byCurPwr = 0xff;
|
2014-05-27 20:05:22 +00:00
|
|
|
vnt_rf_set_txpower(priv,
|
2013-12-12 23:33:08 +00:00
|
|
|
priv->abyCCKPwrTbl[connection_channel-1], RATE_1M);
|
|
|
|
}
|
2009-06-13 11:38:31 +00:00
|
|
|
|
2014-05-26 12:59:03 +00:00
|
|
|
vnt_control_out_u8(priv, MESSAGE_REQUEST_MACREG, MAC_REG_CHANNEL,
|
2013-12-12 23:33:08 +00:00
|
|
|
(u8)(connection_channel|0x80));
|
2009-06-13 11:38:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Description: Get CCK mode basic rate
|
|
|
|
*
|
|
|
|
* Parameters:
|
|
|
|
* In:
|
2014-05-25 20:36:23 +00:00
|
|
|
* priv - The adapter to be set
|
|
|
|
* rate_idx - Receiving data rate
|
2009-06-13 11:38:31 +00:00
|
|
|
* Out:
|
|
|
|
* none
|
|
|
|
*
|
|
|
|
* Return Value: response Control frame rate
|
|
|
|
*
|
|
|
|
*/
|
2014-05-30 15:27:41 +00:00
|
|
|
static u16 vnt_get_cck_rate(struct vnt_private *priv, u16 rate_idx)
|
2009-06-13 11:38:31 +00:00
|
|
|
{
|
2014-05-25 20:36:23 +00:00
|
|
|
u16 ui = rate_idx;
|
2012-12-10 21:59:10 +00:00
|
|
|
|
|
|
|
while (ui > RATE_1M) {
|
2014-05-25 20:36:23 +00:00
|
|
|
if (priv->wBasicRate & (1 << ui))
|
2012-12-10 21:59:10 +00:00
|
|
|
return ui;
|
|
|
|
ui--;
|
|
|
|
}
|
|
|
|
|
|
|
|
return RATE_1M;
|
2009-06-13 11:38:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Description: Get OFDM mode basic rate
|
|
|
|
*
|
|
|
|
* Parameters:
|
|
|
|
* In:
|
2014-05-25 20:36:22 +00:00
|
|
|
* priv - The adapter to be set
|
|
|
|
* rate_idx - Receiving data rate
|
2009-06-13 11:38:31 +00:00
|
|
|
* Out:
|
|
|
|
* none
|
|
|
|
*
|
|
|
|
* Return Value: response Control frame rate
|
|
|
|
*
|
|
|
|
*/
|
2014-05-30 15:27:42 +00:00
|
|
|
static u16 vnt_get_ofdm_rate(struct vnt_private *priv, u16 rate_idx)
|
2009-06-13 11:38:31 +00:00
|
|
|
{
|
2014-05-25 20:36:22 +00:00
|
|
|
u16 ui = rate_idx;
|
2012-12-10 21:59:10 +00:00
|
|
|
|
2014-05-25 20:36:24 +00:00
|
|
|
dev_dbg(&priv->usb->dev, "%s basic rate: %d\n",
|
|
|
|
__func__, priv->wBasicRate);
|
2012-12-10 21:59:10 +00:00
|
|
|
|
2014-05-30 15:27:48 +00:00
|
|
|
if (!vnt_ofdm_min_rate(priv)) {
|
2014-05-25 20:36:24 +00:00
|
|
|
dev_dbg(&priv->usb->dev, "%s (NO OFDM) %d\n",
|
|
|
|
__func__, rate_idx);
|
2014-05-25 20:36:22 +00:00
|
|
|
if (rate_idx > RATE_24M)
|
|
|
|
rate_idx = RATE_24M;
|
|
|
|
return rate_idx;
|
2012-12-10 21:59:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
while (ui > RATE_11M) {
|
2014-05-25 20:36:22 +00:00
|
|
|
if (priv->wBasicRate & (1 << ui)) {
|
2014-05-25 20:36:24 +00:00
|
|
|
dev_dbg(&priv->usb->dev, "%s rate: %d\n",
|
|
|
|
__func__, ui);
|
2012-12-10 21:59:10 +00:00
|
|
|
return ui;
|
|
|
|
}
|
|
|
|
ui--;
|
|
|
|
}
|
|
|
|
|
2014-05-25 20:36:24 +00:00
|
|
|
dev_dbg(&priv->usb->dev, "%s basic rate: 24M\n", __func__);
|
2012-12-10 21:59:10 +00:00
|
|
|
|
|
|
|
return RATE_24M;
|
2009-06-13 11:38:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2012-08-26 15:16:43 +00:00
|
|
|
* Description: Calculate TxRate and RsvTime fields for RSPINF in OFDM mode.
|
2009-06-13 11:38:31 +00:00
|
|
|
*
|
|
|
|
* Parameters:
|
2014-05-23 17:00:15 +00:00
|
|
|
* In:
|
|
|
|
* rate - Tx Rate
|
|
|
|
* bb_type - Tx Packet type
|
|
|
|
* Out:
|
|
|
|
* tx_rate - pointer to RSPINF TxRate field
|
|
|
|
* rsv_time- pointer to RSPINF RsvTime field
|
2009-06-13 11:38:31 +00:00
|
|
|
*
|
|
|
|
* Return Value: none
|
|
|
|
*
|
|
|
|
*/
|
2014-05-30 15:27:43 +00:00
|
|
|
static void vnt_calculate_ofdm_rate(u16 rate, u8 bb_type,
|
2014-05-23 17:00:15 +00:00
|
|
|
u8 *tx_rate, u8 *rsv_time)
|
2009-06-13 11:38:31 +00:00
|
|
|
{
|
|
|
|
|
2014-05-23 17:00:15 +00:00
|
|
|
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;
|
2014-05-24 13:37:10 +00:00
|
|
|
*rsv_time = 10;
|
2014-05-23 17:00:15 +00:00
|
|
|
}
|
|
|
|
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;
|
|
|
|
}
|
2009-06-13 11:38:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Description: Set RSPINF
|
|
|
|
*
|
|
|
|
* Parameters:
|
|
|
|
* In:
|
|
|
|
* pDevice - The adapter to be set
|
|
|
|
* Out:
|
|
|
|
* none
|
|
|
|
*
|
|
|
|
* Return Value: None.
|
|
|
|
*
|
|
|
|
*/
|
2014-05-23 17:00:16 +00:00
|
|
|
|
2014-05-30 15:27:46 +00:00
|
|
|
void vnt_set_rspinf(struct vnt_private *priv, u8 bb_type)
|
2009-06-13 11:38:31 +00:00
|
|
|
{
|
2013-08-20 21:52:30 +00:00
|
|
|
struct vnt_phy_field phy[4];
|
2014-05-23 17:00:16 +00:00
|
|
|
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];
|
2012-12-10 21:59:10 +00:00
|
|
|
int i;
|
2009-06-13 11:38:31 +00:00
|
|
|
|
2014-05-23 17:00:16 +00:00
|
|
|
/*RSPINF_b_1*/
|
|
|
|
BBvCalculateParameter(priv, 14,
|
2014-05-30 15:27:41 +00:00
|
|
|
vnt_get_cck_rate(priv, RATE_1M), PK_TYPE_11B, &phy[0]);
|
2014-05-23 17:00:16 +00:00
|
|
|
|
|
|
|
/*RSPINF_b_2*/
|
|
|
|
BBvCalculateParameter(priv, 14,
|
2014-05-30 15:27:41 +00:00
|
|
|
vnt_get_cck_rate(priv, RATE_2M), PK_TYPE_11B, &phy[1]);
|
2014-05-23 17:00:16 +00:00
|
|
|
|
|
|
|
/*RSPINF_b_5*/
|
|
|
|
BBvCalculateParameter(priv, 14,
|
2014-05-30 15:27:41 +00:00
|
|
|
vnt_get_cck_rate(priv, RATE_5M), PK_TYPE_11B, &phy[2]);
|
2014-05-23 17:00:16 +00:00
|
|
|
|
|
|
|
/*RSPINF_b_11*/
|
|
|
|
BBvCalculateParameter(priv, 14,
|
2014-05-30 15:27:41 +00:00
|
|
|
vnt_get_cck_rate(priv, RATE_11M), PK_TYPE_11B, &phy[3]);
|
2014-05-23 17:00:16 +00:00
|
|
|
|
|
|
|
|
|
|
|
/*RSPINF_a_6*/
|
2014-05-30 15:27:43 +00:00
|
|
|
vnt_calculate_ofdm_rate(RATE_6M, bb_type, &tx_rate[0], &rsv_time[0]);
|
2014-05-23 17:00:16 +00:00
|
|
|
|
|
|
|
/*RSPINF_a_9*/
|
2014-05-30 15:27:43 +00:00
|
|
|
vnt_calculate_ofdm_rate(RATE_9M, bb_type, &tx_rate[1], &rsv_time[1]);
|
2014-05-23 17:00:16 +00:00
|
|
|
|
|
|
|
/*RSPINF_a_12*/
|
2014-05-30 15:27:43 +00:00
|
|
|
vnt_calculate_ofdm_rate(RATE_12M, bb_type, &tx_rate[2], &rsv_time[2]);
|
2014-05-23 17:00:16 +00:00
|
|
|
|
|
|
|
/*RSPINF_a_18*/
|
2014-05-30 15:27:43 +00:00
|
|
|
vnt_calculate_ofdm_rate(RATE_18M, bb_type, &tx_rate[3], &rsv_time[3]);
|
2009-06-13 11:38:31 +00:00
|
|
|
|
2014-05-23 17:00:16 +00:00
|
|
|
/*RSPINF_a_24*/
|
2014-05-30 15:27:43 +00:00
|
|
|
vnt_calculate_ofdm_rate(RATE_24M, bb_type, &tx_rate[4], &rsv_time[4]);
|
2014-05-23 17:00:16 +00:00
|
|
|
|
|
|
|
/*RSPINF_a_36*/
|
2014-05-30 15:27:43 +00:00
|
|
|
vnt_calculate_ofdm_rate(vnt_get_ofdm_rate(priv, RATE_36M),
|
2014-05-23 17:00:16 +00:00
|
|
|
bb_type, &tx_rate[5], &rsv_time[5]);
|
|
|
|
|
|
|
|
/*RSPINF_a_48*/
|
2014-05-30 15:27:43 +00:00
|
|
|
vnt_calculate_ofdm_rate(vnt_get_ofdm_rate(priv, RATE_48M),
|
2014-05-23 17:00:16 +00:00
|
|
|
bb_type, &tx_rate[6], &rsv_time[6]);
|
|
|
|
|
|
|
|
/*RSPINF_a_54*/
|
2014-05-30 15:27:43 +00:00
|
|
|
vnt_calculate_ofdm_rate(vnt_get_ofdm_rate(priv, RATE_54M),
|
2014-05-23 17:00:16 +00:00
|
|
|
bb_type, &tx_rate[7], &rsv_time[7]);
|
|
|
|
|
|
|
|
/*RSPINF_a_72*/
|
2014-05-30 15:27:43 +00:00
|
|
|
vnt_calculate_ofdm_rate(vnt_get_ofdm_rate(priv, RATE_54M),
|
2014-05-23 17:00:16 +00:00
|
|
|
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];
|
|
|
|
}
|
2009-06-13 11:38:31 +00:00
|
|
|
|
2014-05-26 12:59:01 +00:00
|
|
|
vnt_control_out(priv, MESSAGE_TYPE_WRITE,
|
2014-05-23 17:00:16 +00:00
|
|
|
MAC_REG_RSPINF_B_1, MESSAGE_REQUEST_MACREG, 34, &data[0]);
|
2009-06-13 11:38:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Description: Update IFS
|
|
|
|
*
|
|
|
|
* Parameters:
|
|
|
|
* In:
|
2014-05-23 17:00:17 +00:00
|
|
|
* priv - The adapter to be set
|
|
|
|
* Out:
|
|
|
|
* none
|
2009-06-13 11:38:31 +00:00
|
|
|
*
|
|
|
|
* Return Value: None.
|
|
|
|
*
|
|
|
|
*/
|
2014-05-30 15:27:44 +00:00
|
|
|
void vnt_update_ifs(struct vnt_private *priv)
|
2009-06-13 11:38:31 +00:00
|
|
|
{
|
2014-05-23 17:00:17 +00:00
|
|
|
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;
|
|
|
|
|
2014-05-26 12:59:01 +00:00
|
|
|
vnt_control_out(priv, MESSAGE_TYPE_WRITE, MAC_REG_SIFS,
|
2014-05-23 17:00:17 +00:00
|
|
|
MESSAGE_REQUEST_MACREG, 4, &data[0]);
|
|
|
|
|
|
|
|
max_min |= 0xa0;
|
|
|
|
|
2014-05-26 12:59:01 +00:00
|
|
|
vnt_control_out(priv, MESSAGE_TYPE_WRITE, MAC_REG_CWMAXMIN0,
|
2014-05-23 17:00:17 +00:00
|
|
|
MESSAGE_REQUEST_MACREG, 1, &max_min);
|
2009-06-13 11:38:31 +00:00
|
|
|
}
|
|
|
|
|
2014-05-30 15:27:45 +00:00
|
|
|
void vnt_update_top_rates(struct vnt_private *priv)
|
2009-06-13 11:38:31 +00:00
|
|
|
{
|
2014-05-23 17:00:18 +00:00
|
|
|
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;
|
2009-06-13 11:38:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Description: Set NIC Tx Basic Rate
|
|
|
|
*
|
|
|
|
* Parameters:
|
|
|
|
* In:
|
|
|
|
* pDevice - The adapter to be set
|
|
|
|
* wBasicRate - Basic Rate to be set
|
|
|
|
* Out:
|
|
|
|
* none
|
|
|
|
*
|
2013-02-13 01:36:30 +00:00
|
|
|
* Return Value: true if succeeded; false if failed.
|
2009-06-13 11:38:31 +00:00
|
|
|
*
|
|
|
|
*/
|
2014-05-30 15:27:47 +00:00
|
|
|
void vnt_add_basic_rate(struct vnt_private *priv, u16 rate_idx)
|
2009-06-13 11:38:31 +00:00
|
|
|
{
|
|
|
|
|
2014-05-23 17:00:19 +00:00
|
|
|
priv->wBasicRate |= (1 << rate_idx);
|
2009-06-13 11:38:31 +00:00
|
|
|
|
2014-05-23 17:00:19 +00:00
|
|
|
/*Determines the highest basic rate.*/
|
2014-05-30 15:27:45 +00:00
|
|
|
vnt_update_top_rates(priv);
|
2009-06-13 11:38:31 +00:00
|
|
|
}
|
|
|
|
|
2014-05-30 15:27:48 +00:00
|
|
|
int vnt_ofdm_min_rate(struct vnt_private *priv)
|
2009-06-13 11:38:31 +00:00
|
|
|
{
|
2012-12-10 21:59:10 +00:00
|
|
|
int ii;
|
2009-06-13 11:38:31 +00:00
|
|
|
|
2014-05-24 13:36:58 +00:00
|
|
|
for (ii = RATE_54M; ii >= RATE_6M; ii--) {
|
|
|
|
if ((priv->wBasicRate) & ((u16)(1 << ii)))
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
2009-06-13 11:38:31 +00:00
|
|
|
}
|
|
|
|
|
2014-05-30 15:27:49 +00:00
|
|
|
u8 vnt_get_pkt_type(struct vnt_private *priv)
|
2009-06-13 11:38:31 +00:00
|
|
|
{
|
|
|
|
|
2014-05-24 13:36:59 +00:00
|
|
|
if (priv->byBBType == BB_TYPE_11A || priv->byBBType == BB_TYPE_11B)
|
|
|
|
return (u8)priv->byBBType;
|
2014-05-30 15:27:48 +00:00
|
|
|
else if (vnt_ofdm_min_rate(priv))
|
2014-05-24 13:36:59 +00:00
|
|
|
return PK_TYPE_11GA;
|
|
|
|
else
|
|
|
|
return PK_TYPE_11GB;
|
2009-06-13 11:38:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2012-08-26 15:16:43 +00:00
|
|
|
* Description: Calculate TSF offset of two TSF input
|
2009-06-13 11:38:31 +00:00
|
|
|
* Get TSF Offset from RxBCN's TSF and local TSF
|
|
|
|
*
|
|
|
|
* Parameters:
|
|
|
|
* In:
|
2014-05-24 13:37:00 +00:00
|
|
|
* rx_rate - rx rate.
|
|
|
|
* tsf1 - Rx BCN's TSF
|
|
|
|
* tsf2 - Local TSF
|
2009-06-13 11:38:31 +00:00
|
|
|
* Out:
|
|
|
|
* none
|
|
|
|
*
|
|
|
|
* Return Value: TSF Offset value
|
|
|
|
*
|
|
|
|
*/
|
2014-05-30 15:27:50 +00:00
|
|
|
u64 vnt_get_tsf_offset(u8 rx_rate, u64 tsf1, u64 tsf2)
|
2009-06-13 11:38:31 +00:00
|
|
|
{
|
2014-05-24 13:37:00 +00:00
|
|
|
u64 tsf_offset = 0;
|
|
|
|
u16 rx_bcn_offset = 0;
|
2009-06-13 11:38:31 +00:00
|
|
|
|
2014-05-24 13:37:00 +00:00
|
|
|
rx_bcn_offset = cwRXBCNTSFOff[rx_rate % MAX_RATE];
|
2009-06-13 11:38:31 +00:00
|
|
|
|
2014-05-24 13:37:00 +00:00
|
|
|
tsf2 += (u64)rx_bcn_offset;
|
2012-11-28 21:11:02 +00:00
|
|
|
|
2014-05-24 13:37:00 +00:00
|
|
|
tsf_offset = tsf1 - tsf2;
|
2012-11-28 21:11:02 +00:00
|
|
|
|
2014-05-24 13:37:00 +00:00
|
|
|
return tsf_offset;
|
2009-06-13 11:38:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Description: Sync. TSF counter to BSS
|
|
|
|
* Get TSF offset and write to HW
|
|
|
|
*
|
|
|
|
* Parameters:
|
|
|
|
* In:
|
2014-05-24 13:37:01 +00:00
|
|
|
* priv - The adapter to be sync.
|
|
|
|
* time_stamp - Rx BCN's TSF
|
|
|
|
* local_tsf - Local TSF
|
2009-06-13 11:38:31 +00:00
|
|
|
* Out:
|
|
|
|
* none
|
|
|
|
*
|
|
|
|
* Return Value: none
|
|
|
|
*
|
|
|
|
*/
|
2014-05-30 15:27:51 +00:00
|
|
|
void vnt_adjust_tsf(struct vnt_private *priv, u8 rx_rate,
|
2014-05-24 13:37:01 +00:00
|
|
|
u64 time_stamp, u64 local_tsf)
|
2009-06-13 11:38:31 +00:00
|
|
|
{
|
2014-05-24 13:37:01 +00:00
|
|
|
u64 tsf_offset = 0;
|
|
|
|
u8 data[8];
|
|
|
|
|
2014-05-30 15:27:50 +00:00
|
|
|
tsf_offset = vnt_get_tsf_offset(rx_rate, time_stamp, local_tsf);
|
2014-05-24 13:37:01 +00:00
|
|
|
|
|
|
|
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);
|
2009-06-13 11:38:31 +00:00
|
|
|
|
2014-05-26 12:59:01 +00:00
|
|
|
vnt_control_out(priv, MESSAGE_TYPE_SET_TSFTBTT,
|
2014-05-24 13:37:01 +00:00
|
|
|
MESSAGE_REQUEST_TSF, 0, 8, data);
|
2009-06-13 11:38:31 +00:00
|
|
|
}
|
|
|
|
/*
|
|
|
|
* Description: Read NIC TSF counter
|
|
|
|
* Get local TSF counter
|
|
|
|
*
|
|
|
|
* Parameters:
|
|
|
|
* In:
|
2014-05-24 13:37:02 +00:00
|
|
|
* priv - The adapter to be read
|
2009-06-13 11:38:31 +00:00
|
|
|
* Out:
|
2014-05-24 13:37:02 +00:00
|
|
|
* current_tsf - Current TSF counter
|
2009-06-13 11:38:31 +00:00
|
|
|
*
|
2013-02-13 01:36:30 +00:00
|
|
|
* Return Value: true if success; otherwise false
|
2009-06-13 11:38:31 +00:00
|
|
|
*
|
|
|
|
*/
|
2014-05-30 22:22:47 +00:00
|
|
|
bool vnt_get_current_tsf(struct vnt_private *priv, u64 *current_tsf)
|
2009-06-13 11:38:31 +00:00
|
|
|
{
|
|
|
|
|
2014-05-24 13:37:02 +00:00
|
|
|
*current_tsf = priv->qwCurrTSF;
|
2009-06-13 11:38:31 +00:00
|
|
|
|
2013-02-13 01:36:30 +00:00
|
|
|
return true;
|
2009-06-13 11:38:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Description: Clear NIC TSF counter
|
|
|
|
* Clear local TSF counter
|
|
|
|
*
|
|
|
|
* Parameters:
|
|
|
|
* In:
|
2014-05-24 13:37:03 +00:00
|
|
|
* priv - The adapter to be read
|
2009-06-13 11:38:31 +00:00
|
|
|
*
|
2013-02-13 01:36:30 +00:00
|
|
|
* Return Value: true if success; otherwise false
|
2009-06-13 11:38:31 +00:00
|
|
|
*
|
|
|
|
*/
|
2014-05-30 22:22:48 +00:00
|
|
|
bool vnt_clear_current_tsf(struct vnt_private *priv)
|
2009-06-13 11:38:31 +00:00
|
|
|
{
|
|
|
|
|
2014-05-24 13:37:03 +00:00
|
|
|
MACvRegBitsOn(priv, MAC_REG_TFTCTL, TFTCTL_TSFCNTRST);
|
2009-06-13 11:38:31 +00:00
|
|
|
|
2014-05-24 13:37:03 +00:00
|
|
|
priv->qwCurrTSF = 0;
|
2009-06-13 11:38:31 +00:00
|
|
|
|
2013-02-13 01:36:30 +00:00
|
|
|
return true;
|
2009-06-13 11:38:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Description: Read NIC TSF counter
|
|
|
|
* Get NEXTTBTT from adjusted TSF and Beacon Interval
|
|
|
|
*
|
|
|
|
* Parameters:
|
|
|
|
* In:
|
2014-05-24 13:37:04 +00:00
|
|
|
* tsf - Current TSF counter
|
|
|
|
* beacon_interval - Beacon Interval
|
2009-06-13 11:38:31 +00:00
|
|
|
* Out:
|
2014-05-24 13:37:04 +00:00
|
|
|
* tsf - Current TSF counter
|
2009-06-13 11:38:31 +00:00
|
|
|
*
|
|
|
|
* Return Value: TSF value of next Beacon
|
|
|
|
*
|
|
|
|
*/
|
2014-05-30 22:22:49 +00:00
|
|
|
u64 vnt_get_next_tbtt(u64 tsf, u16 beacon_interval)
|
2009-06-13 11:38:31 +00:00
|
|
|
{
|
2014-05-24 13:37:04 +00:00
|
|
|
u32 beacon_int;
|
2009-06-13 11:38:31 +00:00
|
|
|
|
2014-05-24 13:37:04 +00:00
|
|
|
beacon_int = beacon_interval * 1024;
|
2009-06-13 11:38:31 +00:00
|
|
|
|
2014-01-01 19:20:40 +00:00
|
|
|
/* Next TBTT =
|
|
|
|
* ((local_current_TSF / beacon_interval) + 1) * beacon_interval
|
|
|
|
*/
|
2014-05-24 13:37:04 +00:00
|
|
|
if (beacon_int) {
|
|
|
|
do_div(tsf, beacon_int);
|
|
|
|
tsf += 1;
|
|
|
|
tsf *= beacon_int;
|
2014-01-01 19:20:40 +00:00
|
|
|
}
|
2009-06-13 11:38:31 +00:00
|
|
|
|
2014-05-24 13:37:04 +00:00
|
|
|
return tsf;
|
2009-06-13 11:38:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Description: Set NIC TSF counter for first Beacon time
|
|
|
|
* Get NEXTTBTT from adjusted TSF and Beacon Interval
|
|
|
|
*
|
|
|
|
* Parameters:
|
|
|
|
* In:
|
|
|
|
* dwIoBase - IO Base
|
2014-05-24 13:37:05 +00:00
|
|
|
* beacon_interval - Beacon Interval
|
2009-06-13 11:38:31 +00:00
|
|
|
* Out:
|
|
|
|
* none
|
|
|
|
*
|
|
|
|
* Return Value: none
|
|
|
|
*
|
|
|
|
*/
|
2014-05-30 22:22:50 +00:00
|
|
|
void vnt_reset_next_tbtt(struct vnt_private *priv, u16 beacon_interval)
|
2009-06-13 11:38:31 +00:00
|
|
|
{
|
2014-05-24 13:37:05 +00:00
|
|
|
u64 next_tbtt = 0;
|
|
|
|
u8 data[8];
|
|
|
|
|
2014-05-30 22:22:48 +00:00
|
|
|
vnt_clear_current_tsf(priv);
|
2014-05-24 13:37:05 +00:00
|
|
|
|
2014-05-30 22:22:49 +00:00
|
|
|
next_tbtt = vnt_get_next_tbtt(next_tbtt, beacon_interval);
|
2014-05-24 13:37:05 +00:00
|
|
|
|
|
|
|
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);
|
|
|
|
|
2014-05-26 12:59:01 +00:00
|
|
|
vnt_control_out(priv, MESSAGE_TYPE_SET_TSFTBTT,
|
2014-05-24 13:37:05 +00:00
|
|
|
MESSAGE_REQUEST_TBTT, 0, 8, data);
|
2009-06-13 11:38:31 +00:00
|
|
|
|
2014-05-24 13:37:05 +00:00
|
|
|
return;
|
2009-06-13 11:38:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Description: Sync NIC TSF counter for Beacon time
|
|
|
|
* Get NEXTTBTT and write to HW
|
|
|
|
*
|
|
|
|
* Parameters:
|
|
|
|
* In:
|
2014-05-24 13:37:06 +00:00
|
|
|
* priv - The adapter to be set
|
|
|
|
* tsf - Current TSF counter
|
|
|
|
* beacon_interval - Beacon Interval
|
2009-06-13 11:38:31 +00:00
|
|
|
* Out:
|
|
|
|
* none
|
|
|
|
*
|
|
|
|
* Return Value: none
|
|
|
|
*
|
|
|
|
*/
|
2014-05-30 22:22:51 +00:00
|
|
|
void vnt_update_next_tbtt(struct vnt_private *priv, u64 tsf,
|
2014-05-24 13:37:06 +00:00
|
|
|
u16 beacon_interval)
|
2009-06-13 11:38:31 +00:00
|
|
|
{
|
2014-05-24 13:37:06 +00:00
|
|
|
u8 data[8];
|
2009-06-13 11:38:31 +00:00
|
|
|
|
2014-05-30 22:22:49 +00:00
|
|
|
tsf = vnt_get_next_tbtt(tsf, beacon_interval);
|
2012-11-28 21:11:02 +00:00
|
|
|
|
2014-05-24 13:37:06 +00:00
|
|
|
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);
|
2009-06-13 11:38:31 +00:00
|
|
|
|
2014-05-26 12:59:01 +00:00
|
|
|
vnt_control_out(priv, MESSAGE_TYPE_SET_TSFTBTT,
|
2014-05-24 13:37:06 +00:00
|
|
|
MESSAGE_REQUEST_TBTT, 0, 8, data);
|
2009-06-13 11:38:31 +00:00
|
|
|
|
2014-05-25 20:36:24 +00:00
|
|
|
dev_dbg(&priv->usb->dev, "%s TBTT: %8llx\n", __func__, tsf);
|
2009-06-13 11:38:31 +00:00
|
|
|
|
2014-05-24 13:37:06 +00:00
|
|
|
return;
|
2009-06-13 11:38:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Description: Turn off Radio power
|
|
|
|
*
|
|
|
|
* Parameters:
|
|
|
|
* In:
|
2014-05-24 13:37:07 +00:00
|
|
|
* priv - The adapter to be turned off
|
2009-06-13 11:38:31 +00:00
|
|
|
* Out:
|
|
|
|
* none
|
|
|
|
*
|
2013-02-13 01:36:30 +00:00
|
|
|
* Return Value: true if success; otherwise false
|
2009-06-13 11:38:31 +00:00
|
|
|
*
|
|
|
|
*/
|
2014-05-30 22:22:52 +00:00
|
|
|
int vnt_radio_power_off(struct vnt_private *priv)
|
2009-06-13 11:38:31 +00:00
|
|
|
{
|
2014-05-24 13:37:07 +00:00
|
|
|
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;
|
|
|
|
}
|
2009-06-13 11:38:31 +00:00
|
|
|
|
2014-05-24 13:37:07 +00:00
|
|
|
MACvRegBitsOff(priv, MAC_REG_HOSTCR, HOSTCR_RXON);
|
2009-06-13 11:38:31 +00:00
|
|
|
|
2014-05-24 13:37:07 +00:00
|
|
|
BBvSetDeepSleep(priv);
|
2009-06-13 11:38:31 +00:00
|
|
|
|
2014-05-24 13:37:07 +00:00
|
|
|
return ret;
|
2009-06-13 11:38:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Description: Turn on Radio power
|
|
|
|
*
|
|
|
|
* Parameters:
|
|
|
|
* In:
|
2014-05-24 13:37:08 +00:00
|
|
|
* priv - The adapter to be turned on
|
2009-06-13 11:38:31 +00:00
|
|
|
* Out:
|
|
|
|
* none
|
|
|
|
*
|
2013-02-13 01:36:30 +00:00
|
|
|
* Return Value: true if success; otherwise false
|
2009-06-13 11:38:31 +00:00
|
|
|
*
|
|
|
|
*/
|
2014-05-24 13:37:08 +00:00
|
|
|
int CARDbRadioPowerOn(struct vnt_private *priv)
|
2009-06-13 11:38:31 +00:00
|
|
|
{
|
2014-05-24 13:37:08 +00:00
|
|
|
int ret = true;
|
2009-06-13 11:38:31 +00:00
|
|
|
|
2014-05-24 13:37:08 +00:00
|
|
|
if (priv->bHWRadioOff == true || priv->bRadioControlOff == true)
|
|
|
|
return false;
|
2009-06-13 11:38:31 +00:00
|
|
|
|
2014-05-24 13:37:08 +00:00
|
|
|
priv->bRadioOff = false;
|
2009-06-13 11:38:31 +00:00
|
|
|
|
2014-05-24 13:37:08 +00:00
|
|
|
BBvExitDeepSleep(priv);
|
2009-06-13 11:38:31 +00:00
|
|
|
|
2014-05-24 13:37:08 +00:00
|
|
|
MACvRegBitsOn(priv, MAC_REG_HOSTCR, HOSTCR_RXON);
|
2009-06-13 11:38:31 +00:00
|
|
|
|
2014-05-24 13:37:08 +00:00
|
|
|
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;
|
|
|
|
}
|
2009-06-13 11:38:31 +00:00
|
|
|
|
2014-05-24 13:37:08 +00:00
|
|
|
return ret;
|
2009-06-13 11:38:31 +00:00
|
|
|
}
|
|
|
|
|
2014-05-24 13:37:09 +00:00
|
|
|
void CARDvSetBSSMode(struct vnt_private *priv)
|
2009-06-13 11:38:31 +00:00
|
|
|
{
|
2014-05-24 13:37:09 +00:00
|
|
|
if (priv->byRFType == RF_AIROHA7230 && priv->byBBType == BB_TYPE_11A)
|
|
|
|
MACvSetBBType(priv, BB_TYPE_11G);
|
|
|
|
else
|
|
|
|
MACvSetBBType(priv, priv->byBBType);
|
|
|
|
|
2014-05-30 15:27:49 +00:00
|
|
|
priv->byPacketType = vnt_get_pkt_type(priv);
|
2014-05-24 13:37:09 +00:00
|
|
|
|
|
|
|
if (priv->byBBType == BB_TYPE_11A)
|
2014-05-26 12:59:03 +00:00
|
|
|
vnt_control_out_u8(priv, MESSAGE_REQUEST_BBREG, 0x88, 0x03);
|
2014-05-24 13:37:09 +00:00
|
|
|
else if (priv->byBBType == BB_TYPE_11B)
|
2014-05-26 12:59:03 +00:00
|
|
|
vnt_control_out_u8(priv, MESSAGE_REQUEST_BBREG, 0x88, 0x02);
|
2014-05-24 13:37:09 +00:00
|
|
|
else if (priv->byBBType == BB_TYPE_11G)
|
2014-05-26 12:59:03 +00:00
|
|
|
vnt_control_out_u8(priv, MESSAGE_REQUEST_BBREG, 0x88, 0x08);
|
2014-05-24 13:37:09 +00:00
|
|
|
|
2014-05-30 15:27:44 +00:00
|
|
|
vnt_update_ifs(priv);
|
2014-05-30 15:27:46 +00:00
|
|
|
vnt_set_rspinf(priv, (u8)priv->byBBType);
|
2014-05-24 13:37:09 +00:00
|
|
|
|
|
|
|
if (priv->byBBType == BB_TYPE_11A) {
|
|
|
|
if (priv->byRFType == RF_AIROHA7230) {
|
|
|
|
priv->abyBBVGA[0] = 0x20;
|
|
|
|
|
2014-05-26 12:59:03 +00:00
|
|
|
vnt_control_out_u8(priv, MESSAGE_REQUEST_BBREG,
|
2014-05-24 13:37:09 +00:00
|
|
|
0xe7, priv->abyBBVGA[0]);
|
|
|
|
}
|
|
|
|
|
|
|
|
priv->abyBBVGA[2] = 0x10;
|
|
|
|
priv->abyBBVGA[3] = 0x10;
|
|
|
|
} else {
|
|
|
|
if (priv->byRFType == RF_AIROHA7230) {
|
|
|
|
priv->abyBBVGA[0] = 0x1c;
|
|
|
|
|
2014-05-26 12:59:03 +00:00
|
|
|
vnt_control_out_u8(priv, MESSAGE_REQUEST_BBREG,
|
2014-05-24 13:37:09 +00:00
|
|
|
0xe7, priv->abyBBVGA[0]);
|
|
|
|
}
|
|
|
|
|
|
|
|
priv->abyBBVGA[2] = 0x0;
|
|
|
|
priv->abyBBVGA[3] = 0x0;
|
|
|
|
}
|
2009-06-13 11:38:31 +00:00
|
|
|
}
|