static const u16 awcFrameTime[MAX_RATE] =
{10, 20, 55, 110, 24, 36, 48, 72, 96, 144, 192, 216};
-/*
-static
-unsigned long
-s_ulGetLowSQ3(PSDevice pDevice);
-
-static
-unsigned long
-s_ulGetRatio(PSDevice pDevice);
-
-static
-void
-s_vClearSQ3Value(PSDevice pDevice);
-*/
-
/*
* Description: Calculate data frame transmitting time
*
ControlvWriteByte(priv, MESSAGE_REQUEST_BBREG, 0x0d, 0x01);/* CR13 */
}
-static unsigned long s_ulGetLowSQ3(struct vnt_private *pDevice)
-{
- int ii;
- unsigned long ulSQ3 = 0;
- unsigned long ulMaxPacket;
-
- ulMaxPacket = pDevice->aulPktNum[RATE_54M];
- if (pDevice->aulPktNum[RATE_54M] != 0)
- ulSQ3 = pDevice->aulSQ3Val[RATE_54M] / pDevice->aulPktNum[RATE_54M];
-
- for (ii = RATE_48M; ii >= RATE_6M; ii--)
- if (pDevice->aulPktNum[ii] > ulMaxPacket) {
- ulMaxPacket = pDevice->aulPktNum[ii];
- ulSQ3 = pDevice->aulSQ3Val[ii] / pDevice->aulPktNum[ii];
- }
-
- return ulSQ3;
-}
-
-static unsigned long s_ulGetRatio(struct vnt_private *pDevice)
-{
- int ii, jj;
- unsigned long ulRatio = 0;
- unsigned long ulMaxPacket;
- unsigned long ulPacketNum;
-
- //This is a thousand-ratio
- ulMaxPacket = pDevice->aulPktNum[RATE_54M];
- if ( pDevice->aulPktNum[RATE_54M] != 0 ) {
- ulPacketNum = pDevice->aulPktNum[RATE_54M];
- ulRatio = (ulPacketNum * 1000 / pDevice->uDiversityCnt);
- ulRatio += TOP_RATE_54M;
- }
- for (ii = RATE_48M; ii >= RATE_1M; ii--)
- if ( pDevice->aulPktNum[ii] > ulMaxPacket ) {
- ulPacketNum = 0;
- for ( jj=RATE_54M;jj>=ii;jj--)
- ulPacketNum += pDevice->aulPktNum[jj];
- ulRatio = (ulPacketNum * 1000 / pDevice->uDiversityCnt);
- ulRatio += TOP_RATE_48M;
- ulMaxPacket = pDevice->aulPktNum[ii];
- }
-
- return ulRatio;
-}
-
-static void s_vClearSQ3Value(struct vnt_private *pDevice)
-{
- int ii;
- pDevice->uDiversityCnt = 0;
-
- for ( ii=RATE_1M;ii<MAX_RATE;ii++) {
- pDevice->aulPktNum[ii] = 0;
- pDevice->aulSQ3Val[ii] = 0;
- }
-}
-
-/*
- * Description: Antenna Diversity
- *
- * Parameters:
- * In:
- * pDevice - Device Structure
- * byRSR - RSR from received packet
- * bySQ3 - SQ3 value from received packet
- * Out:
- * none
- *
- * Return Value: none
- *
- */
-
-void BBvAntennaDiversity(struct vnt_private *pDevice,
- u8 byRxRate, u8 bySQ3)
-{
-
- pDevice->uDiversityCnt++;
- DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pDevice->uDiversityCnt = %d\n", (int)pDevice->uDiversityCnt);
-
- if (byRxRate == 2) {
- pDevice->aulPktNum[RATE_1M]++;
- }
- else if (byRxRate==4) {
- pDevice->aulPktNum[RATE_2M]++;
- }
- else if (byRxRate==11) {
- pDevice->aulPktNum[RATE_5M]++;
- }
- else if (byRxRate==22) {
- pDevice->aulPktNum[RATE_11M]++;
- }
- else if(byRxRate==12){
- pDevice->aulPktNum[RATE_6M]++;
- pDevice->aulSQ3Val[RATE_6M] += bySQ3;
- }
- else if(byRxRate==18){
- pDevice->aulPktNum[RATE_9M]++;
- pDevice->aulSQ3Val[RATE_9M] += bySQ3;
- }
- else if(byRxRate==24){
- pDevice->aulPktNum[RATE_12M]++;
- pDevice->aulSQ3Val[RATE_12M] += bySQ3;
- }
- else if(byRxRate==36){
- pDevice->aulPktNum[RATE_18M]++;
- pDevice->aulSQ3Val[RATE_18M] += bySQ3;
- }
- else if(byRxRate==48){
- pDevice->aulPktNum[RATE_24M]++;
- pDevice->aulSQ3Val[RATE_24M] += bySQ3;
- }
- else if(byRxRate==72){
- pDevice->aulPktNum[RATE_36M]++;
- pDevice->aulSQ3Val[RATE_36M] += bySQ3;
- }
- else if(byRxRate==96){
- pDevice->aulPktNum[RATE_48M]++;
- pDevice->aulSQ3Val[RATE_48M] += bySQ3;
- }
- else if(byRxRate==108){
- pDevice->aulPktNum[RATE_54M]++;
- pDevice->aulSQ3Val[RATE_54M] += bySQ3;
- }
-
- if (pDevice->byAntennaState == 0) {
-
- if (pDevice->uDiversityCnt > pDevice->ulDiversityNValue) {
- DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"ulDiversityNValue=[%d],54M-[%d]\n",(int)pDevice->ulDiversityNValue, (int)pDevice->aulPktNum[RATE_54M]);
-
- pDevice->ulSQ3_State0 = s_ulGetLowSQ3(pDevice);
- pDevice->ulRatio_State0 = s_ulGetRatio(pDevice);
- DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"SQ3_State0, SQ3= [%08x] rate = [%08x]\n",(int)pDevice->ulSQ3_State0,(int)pDevice->ulRatio_State0);
-
- if ( ((pDevice->aulPktNum[RATE_54M] < pDevice->ulDiversityNValue/2) &&
- (pDevice->ulSQ3_State0 > pDevice->ulSQ3TH) ) ||
- (pDevice->ulSQ3_State0 == 0 ) ) {
-
- if ( pDevice->byTMax == 0 )
- return;
-
- bScheduleCommand((void *) pDevice,
- WLAN_CMD_CHANGE_ANTENNA,
- NULL);
-
- pDevice->byAntennaState = 1;
-
- del_timer(&pDevice->TimerSQ3Tmax3);
- del_timer(&pDevice->TimerSQ3Tmax2);
- pDevice->TimerSQ3Tmax1.expires = RUN_AT(pDevice->byTMax * HZ);
- add_timer(&pDevice->TimerSQ3Tmax1);
-
- } else {
- pDevice->TimerSQ3Tmax3.expires = RUN_AT(pDevice->byTMax3 * HZ);
- add_timer(&pDevice->TimerSQ3Tmax3);
- }
- s_vClearSQ3Value(pDevice);
-
- }
- } else { //byAntennaState == 1
-
- if (pDevice->uDiversityCnt > pDevice->ulDiversityMValue) {
-
- del_timer(&pDevice->TimerSQ3Tmax1);
- pDevice->ulSQ3_State1 = s_ulGetLowSQ3(pDevice);
- pDevice->ulRatio_State1 = s_ulGetRatio(pDevice);
- DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"SQ3_State1, rate0 = %08x,rate1 = %08x\n",(int)pDevice->ulRatio_State0,(int)pDevice->ulRatio_State1);
-
- if ( ((pDevice->ulSQ3_State1 == 0) && (pDevice->ulSQ3_State0 != 0)) ||
- ((pDevice->ulSQ3_State1 == 0) && (pDevice->ulSQ3_State0 == 0) && (pDevice->ulRatio_State1 < pDevice->ulRatio_State0)) ||
- ((pDevice->ulSQ3_State1 != 0) && (pDevice->ulSQ3_State0 != 0) && (pDevice->ulSQ3_State0 < pDevice->ulSQ3_State1))
- ) {
-
- bScheduleCommand((void *) pDevice,
- WLAN_CMD_CHANGE_ANTENNA,
- NULL);
-
- pDevice->TimerSQ3Tmax3.expires = RUN_AT(pDevice->byTMax3 * HZ);
- pDevice->TimerSQ3Tmax2.expires = RUN_AT(pDevice->byTMax2 * HZ);
- add_timer(&pDevice->TimerSQ3Tmax3);
- add_timer(&pDevice->TimerSQ3Tmax2);
-
- }
- pDevice->byAntennaState = 0;
- s_vClearSQ3Value(pDevice);
- }
- } //byAntennaState
-}
-
-/*+
- *
- * Description:
- * Timer for SQ3 antenna diversity
- *
- * Parameters:
- * In:
- * pvSysSpec1
- * hDeviceContext - Pointer to the adapter
- * pvSysSpec2
- * pvSysSpec3
- * Out:
- * none
- *
- * Return Value: none
- *
--*/
-
-void TimerSQ3CallBack(struct vnt_private *pDevice)
-{
-
- DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"TimerSQ3CallBack...");
- spin_lock_irq(&pDevice->lock);
-
- bScheduleCommand((void *) pDevice, WLAN_CMD_CHANGE_ANTENNA, NULL);
- pDevice->byAntennaState = 0;
- s_vClearSQ3Value(pDevice);
- pDevice->TimerSQ3Tmax3.expires = RUN_AT(pDevice->byTMax3 * HZ);
- pDevice->TimerSQ3Tmax2.expires = RUN_AT(pDevice->byTMax2 * HZ);
- add_timer(&pDevice->TimerSQ3Tmax3);
- add_timer(&pDevice->TimerSQ3Tmax2);
-
- spin_unlock_irq(&pDevice->lock);
-}
-
-/*+
- *
- * Description:
- * Timer for SQ3 antenna diversity
- *
- * Parameters:
- * In:
- * pvSysSpec1
- * hDeviceContext - Pointer to the adapter
- * pvSysSpec2
- * pvSysSpec3
- * Out:
- * none
- *
- * Return Value: none
- *
--*/
-
-void TimerSQ3Tmax3CallBack(struct vnt_private *pDevice)
-{
-
- DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"TimerSQ3Tmax3CallBack...");
- spin_lock_irq(&pDevice->lock);
-
- pDevice->ulRatio_State0 = s_ulGetRatio(pDevice);
- DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"SQ3_State0 = [%08x]\n",(int)pDevice->ulRatio_State0);
-
- s_vClearSQ3Value(pDevice);
- if ( pDevice->byTMax == 0 ) {
- pDevice->TimerSQ3Tmax3.expires = RUN_AT(pDevice->byTMax3 * HZ);
- add_timer(&pDevice->TimerSQ3Tmax3);
- spin_unlock_irq(&pDevice->lock);
- return;
- }
-
- bScheduleCommand((void *) pDevice, WLAN_CMD_CHANGE_ANTENNA, NULL);
- pDevice->byAntennaState = 1;
- del_timer(&pDevice->TimerSQ3Tmax3);
- del_timer(&pDevice->TimerSQ3Tmax2);
- pDevice->TimerSQ3Tmax1.expires = RUN_AT(pDevice->byTMax * HZ);
- add_timer(&pDevice->TimerSQ3Tmax1);
-
- spin_unlock_irq(&pDevice->lock);
-}
-
void BBvUpdatePreEDThreshold(struct vnt_private *priv, int scanning)
{
u8 cr_201 = 0x0, cr_206 = 0x0;
static int device_init_registers(struct vnt_private *pDevice);
static bool device_init_defrag_cb(struct vnt_private *pDevice);
-static void device_init_diversity_timer(struct vnt_private *pDevice);
static int ethtool_ioctl(struct net_device *dev, struct ifreq *);
static void device_free_tx_bufs(struct vnt_private *pDevice);
pDevice->byAutoFBCtrl = AUTO_FB_0;
pDevice->byPreambleType = 0;
pDevice->bExistSWNetAddr = false;
- /* pDevice->bDiversityRegCtlON = true; */
- pDevice->bDiversityRegCtlON = false;
-}
-
-static void device_init_diversity_timer(struct vnt_private *pDevice)
-{
- init_timer(&pDevice->TimerSQ3Tmax1);
- pDevice->TimerSQ3Tmax1.data = (unsigned long)pDevice;
- pDevice->TimerSQ3Tmax1.function = (TimerFunction)TimerSQ3CallBack;
- pDevice->TimerSQ3Tmax1.expires = RUN_AT(HZ);
-
- init_timer(&pDevice->TimerSQ3Tmax2);
- pDevice->TimerSQ3Tmax2.data = (unsigned long)pDevice;
- pDevice->TimerSQ3Tmax2.function = (TimerFunction)TimerSQ3CallBack;
- pDevice->TimerSQ3Tmax2.expires = RUN_AT(HZ);
-
- init_timer(&pDevice->TimerSQ3Tmax3);
- pDevice->TimerSQ3Tmax3.data = (unsigned long)pDevice;
- pDevice->TimerSQ3Tmax3.function = (TimerFunction)TimerSQ3Tmax3CallBack;
- pDevice->TimerSQ3Tmax3.expires = RUN_AT(HZ);
-
- return;
}
/*
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;
}
}
- 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;
pDevice->bRoaming = false;
pDevice->bIsRoaming = false;
pDevice->bEnableRoaming = false;
- if (pDevice->bDiversityRegCtlON) {
- device_init_diversity_timer(pDevice);
- }
vMgrObjectInit(pDevice);
cancel_delayed_work_sync(&pDevice->run_command_work);
cancel_delayed_work_sync(&pDevice->second_callback_work);
- if (pDevice->bDiversityRegCtlON) {
- del_timer(&pDevice->TimerSQ3Tmax1);
- del_timer(&pDevice->TimerSQ3Tmax2);
- del_timer(&pDevice->TimerSQ3Tmax3);
- }
-
cancel_work_sync(&pDevice->rx_mng_work_item);
cancel_work_sync(&pDevice->read_work_item);