⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rt_ate.c

📁 Linux下的RT系列无线网卡驱动,可以直接在x86平台上编译
💻 C
📖 第 1 页 / 共 5 页
字号:
								BbpValue |= 0x10;								ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R3, BbpValue);																break;						}					}										if (pAd->Antenna.field.TxPath == 1)					{						R2 |= 0x4000;	// If TXpath is 1, bit 14 = 1;					}										if (pAd->Antenna.field.RxPath == 2)					{						R2 |= 0x40;	// write 1 to off Rxpath.					}					else if (pAd->Antenna.field.RxPath == 1)					{						R2 |= 0x20040;	// write 1 to off RxPath					}										R3 = R3 | (RFRegTable[index].R3 & 0xffffc1ff); // set TX power0					R4 = (RFRegTable[index].R4 & (~0x001f87c0)) | (pAd->ate.RFFreqOffset << 15) | (TxPwer2 <<6);// Set freq Offset & TxPwr1					// Based on BBP current mode before changing RF channel.					if (pAd->ate.TxWI.BW == BW_40)					{						R4 |=0x200000;					}										// Update variables					pAd->LatchRfRegs.Channel = Channel;					pAd->LatchRfRegs.R1 = RFRegTable[index].R1;					pAd->LatchRfRegs.R2 = R2;					pAd->LatchRfRegs.R3 = R3;					pAd->LatchRfRegs.R4 = R4;					RtmpRfIoWrite(pAd);										break;				}			}			break;		default:			break;	}#else	switch (pAd->RfIcType)	{		case RFIC_2820:		case RFIC_2850:			for (index = 0; index < NUM_OF_2850_CHNL; index++)			{				if (Channel == RFRegTable[index].Channel)				{					R2 = RFRegTable[index].R2;					if (pAd->Antenna.field.TxPath == 1)					{						R2 |= 0x4000;	// If TXpath is 1, bit 14 = 1;					}					if (pAd->Antenna.field.RxPath == 2)					{						R2 |= 0x40;	// write 1 to off Rxpath.					}					else if (pAd->Antenna.field.RxPath == 1)					{						R2 |= 0x20040;	// write 1 to off RxPath					}					R3 = R3 | (RFRegTable[index].R3 & 0xffffc1ff); // set TX power0					R4 = (RFRegTable[index].R4 & (~0x001f87c0)) | (pAd->ate.RFFreqOffset << 15) | (TxPwer2 <<6);// Set freq Offset & TxPwr1					// Based on BBP current mode before changing RF channel.					if (pAd->ate.TxWI.BW == BW_40)					{						R4 |=0x200000;					}					// Update variables					pAd->LatchRfRegs.Channel = Channel;					pAd->LatchRfRegs.R1 = RFRegTable[index].R1;					pAd->LatchRfRegs.R2 = R2;					pAd->LatchRfRegs.R3 = R3;					pAd->LatchRfRegs.R4 = R4;					RtmpRfIoWrite(pAd);					break;				}			}			break;		default:			break;	}#endif	// Change BBP setting during switch from a->g, g->a	if (Channel <= 14)	{		ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R82, 0x62);		// 5G band selection PIN, bit1 and bit2 are complement		RTMP_IO_READ32(pAd, TX_BAND_CFG, &Value);		Value &= (~0x6);		Value |= (0x04);		RTMP_IO_WRITE32(pAd, TX_BAND_CFG, Value);	}	else	{		ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R82, 0xF2);		// 5G band selection PIN, bit1 and bit2 are complement		RTMP_IO_READ32(pAd, TX_BAND_CFG, &Value);		Value &= (~0x6);		Value |= (0x02);		RTMP_IO_WRITE32(pAd, TX_BAND_CFG, Value);	}	//	// On 11A, We should delay and wait RF/BBP to be stable	// and the appropriate time should be 1000 micro seconds 	// 2005/06/05 - On 11G, We also need this delay time. Otherwise it's difficult to pass the WHQL.	//	RTMPusecDelay(1000);  	DBGPRINT(RT_DEBUG_TRACE, ("SwitchChannel#%d(RF=%d, Pwr0=%lu, Pwr1=%lu, %dT) to , R1=0x%08lx, R2=0x%08lx, R3=0x%08lx, R4=0x%08lx\n",							  Channel, 							  pAd->RfIcType, 							  (R3 & 0x00003e00) >> 9,							  (R4 & 0x000007c0) >> 6,							  pAd->Antenna.field.TxPath,							  pAd->LatchRfRegs.R1, 							  pAd->LatchRfRegs.R2, 							  pAd->LatchRfRegs.R3, 							  pAd->LatchRfRegs.R4));}//// In fact, no one will call this routine !///*	==========================================================================	Description:		Gives CCK TX rate 2 more dB TX power.		This routine works only in ATE mode.		calculate desired Tx power in RF R3.Tx0~5,	should consider -		0. if current radio is a noisy environment (pAd->DrsCounters.fNoisyEnvironment)		1. TxPowerPercentage		2. auto calibration based on TSSI feedback		3. extra 2 db for CCK		4. -10 db upon very-short distance (AvgRSSI >= -40db) to AP	NOTE: Since this routine requires the value of (pAd->DrsCounters.fNoisyEnvironment),		it should be called AFTER MlmeDynamicTxRateSwitching()	========================================================================== */VOID ATEAsicAdjustTxPower(	IN PRTMP_ADAPTER pAd) {	INT			i, j;	CHAR		DeltaPwr = 0;	BOOLEAN		bAutoTxAgc = FALSE;	UCHAR		TssiRef, *pTssiMinusBoundary, *pTssiPlusBoundary, TxAgcStep;	UCHAR		BbpR49 = 0, idx;	PCHAR		pTxAgcCompensate;	ULONG		TxPwr[5];	CHAR		Value;	if (pAd->ate.TxWI.BW == BW_40)	{		if (pAd->ate.Channel > 14)// 0719 peter : pAd->CommonCfg.CentralChannel => pAd->ate.Channel		{			TxPwr[0] = pAd->Tx40MPwrCfgABand[0];			TxPwr[1] = pAd->Tx40MPwrCfgABand[1];			TxPwr[2] = pAd->Tx40MPwrCfgABand[2];			TxPwr[3] = pAd->Tx40MPwrCfgABand[3];			TxPwr[4] = pAd->Tx40MPwrCfgABand[4];		}		else		{			TxPwr[0] = pAd->Tx40MPwrCfgGBand[0];			TxPwr[1] = pAd->Tx40MPwrCfgGBand[1];			TxPwr[2] = pAd->Tx40MPwrCfgGBand[2];			TxPwr[3] = pAd->Tx40MPwrCfgGBand[3];			TxPwr[4] = pAd->Tx40MPwrCfgGBand[4];		}	}	else	{		TxPwr[0] = pAd->TxPwrCfg[0];		TxPwr[1] = pAd->TxPwrCfg[1];		TxPwr[2] = pAd->TxPwrCfg[2];		TxPwr[3] = pAd->TxPwrCfg[3];		TxPwr[4] = pAd->TxPwrCfg[4];	}	// TX power compensation for temperature variation based on TSSI. try every 4 second	if (pAd->Mlme.OneSecPeriodicRound % 4 == 0)	{		if (pAd->ate.Channel <= 14)		{			/* bg channel */			bAutoTxAgc         = pAd->bAutoTxAgcG;			TssiRef            = pAd->TssiRefG;			pTssiMinusBoundary = &pAd->TssiMinusBoundaryG[0];			pTssiPlusBoundary  = &pAd->TssiPlusBoundaryG[0];			TxAgcStep          = pAd->TxAgcStepG;			pTxAgcCompensate   = &pAd->TxAgcCompensateG;		}		else		{			/* a channel */			bAutoTxAgc         = pAd->bAutoTxAgcA;			TssiRef            = pAd->TssiRefA;			pTssiMinusBoundary = &pAd->TssiMinusBoundaryA[0];			pTssiPlusBoundary  = &pAd->TssiPlusBoundaryA[0];			TxAgcStep          = pAd->TxAgcStepA;			pTxAgcCompensate   = &pAd->TxAgcCompensateA;		}		if (bAutoTxAgc)		{			/* BbpR49 is unsigned char */			ATE_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R49, &BbpR49);						/* (p) TssiPlusBoundaryG[0] = 0 = (m) TssiMinusBoundaryG[0] */			/* compensate: +4     +3   +2   +1    0   -1   -2   -3   -4 * steps */			/* step value is defined in pAd->TxAgcStepG for tx power value */			/* [4]+1+[4]   p4     p3   p2   p1   o1   m1   m2   m3   m4 */			/* ex:         0x00 0x15 0x25 0x45 0x88 0xA0 0xB5 0xD0 0xF0			   above value are examined in mass factory production */			/*             [4]    [3]  [2]  [1]  [0]  [1]  [2]  [3]  [4] */			/* plus is 0x10 ~ 0x40, minus is 0x60 ~ 0x90 */			/* if value is between p1 ~ o1 or o1 ~ s1, no need to adjust tx power */			/* if value is 0x65, tx power will be -= TxAgcStep*(2-1) */			if (BbpR49 > pTssiMinusBoundary[1])			{				// Reading is larger than the reference value				// check for how large we need to decrease the Tx power				for (idx = 1; idx < 5; idx++)				{					// todo : peter : pAd->TssiMinusBoundaryG ? pTssiMinusBoundary ?					if (BbpR49 <= pTssiMinusBoundary[idx])  // Found the range						break;				}				// The index is the step we should decrease, idx = 0 means there is nothing to compensate//				if (R3 > (ULONG) (TxAgcStep * (idx-1)))					*pTxAgcCompensate = -(TxAgcStep * (idx-1));//				else//					*pTxAgcCompensate = -((UCHAR)R3);								DeltaPwr += (*pTxAgcCompensate);				DBGPRINT(RT_DEBUG_TRACE, ("-- Tx Power, BBP R1=%x, TssiRef=%x, TxAgcStep=%x, step = -%d\n",					BbpR49, TssiRef, TxAgcStep, idx-1));                    			}			else if (BbpR49 < pTssiPlusBoundary[1])			{				// Reading is smaller than the reference value				// check for how large we need to increase the Tx power				for (idx = 1; idx < 5; idx++)				{					if (BbpR49 >= pTssiPlusBoundary[idx])   // Found the range						break;				}				// The index is the step we should increase, idx = 0 means there is nothing to compensate				*pTxAgcCompensate = TxAgcStep * (idx-1);				DeltaPwr += (*pTxAgcCompensate);				DBGPRINT(RT_DEBUG_TRACE, ("++ Tx Power, BBP R1=%x, TssiRef=%x, TxAgcStep=%x, step = +%d\n",					BbpR49, TssiRef, TxAgcStep, idx-1));			}			else			{				*pTxAgcCompensate = 0;				DBGPRINT(RT_DEBUG_TRACE, ("   Tx Power, BBP R1=%x, TssiRef=%x, TxAgcStep=%x, step = +%d\n",					BbpR49, TssiRef, TxAgcStep, 0));			}		}	}	else	{		if (pAd->ate.Channel <= 14)		{			bAutoTxAgc         = pAd->bAutoTxAgcG;			pTxAgcCompensate   = &pAd->TxAgcCompensateG;		}		else		{			bAutoTxAgc         = pAd->bAutoTxAgcA;			pTxAgcCompensate   = &pAd->TxAgcCompensateA;		}		if (bAutoTxAgc)			DeltaPwr += (*pTxAgcCompensate);	}	/* calculate delta power based on the percentage specified from UI */	// E2PROM setting is calibrated for maximum TX power (i.e. 100%)	// We lower TX power here according to the percentage specified from UI	if (pAd->CommonCfg.TxPowerPercentage == 0xffffffff)       // AUTO TX POWER control		;	else if (pAd->CommonCfg.TxPowerPercentage > 90)  // 91 ~ 100% & AUTO, treat as 100% in terms of mW		;	else if (pAd->CommonCfg.TxPowerPercentage > 60)  // 61 ~ 90%, treat as 75% in terms of mW	{		DeltaPwr -= 1;	}	else if (pAd->CommonCfg.TxPowerPercentage > 30)  // 31 ~ 60%, treat as 50% in terms of mW	{		DeltaPwr -= 3;	}	else if (pAd->CommonCfg.TxPowerPercentage > 15)  // 16 ~ 30%, treat as 25% in terms of mW	{		DeltaPwr -= 6;	}	else if (pAd->CommonCfg.TxPowerPercentage > 9)   // 10 ~ 15%, treat as 12.5% in terms of mW	{		DeltaPwr -= 9;	}	else                                           // 0 ~ 9 %, treat as MIN(~3%) in terms of mW	{		DeltaPwr -= 12;	}	/* reset different new tx power for different TX rate */	for(i=0; i<5; i++)	{		if (TxPwr[i] != 0xffffffff)		{			for (j=0; j<8; j++)			{				Value = (CHAR)((TxPwr[i] >> j*4) & 0x0F); /* 0 ~ 15 */				if ((Value + DeltaPwr) < 0)				{					Value = 0; /* min */				}				else if ((Value + DeltaPwr) > 0xF)				{					Value = 0xF; /* max */				}				else				{					Value += DeltaPwr; /* temperature compensation */				}				/* fill new value to CSR offset */				TxPwr[i] = (TxPwr[i] & ~(0x0000000F << j*4)) | (Value << j*4);			}			/* write tx power value to CSR */			/* TX_PWR_CFG_0 (8 tx rate) for	TX power for OFDM 12M/18M											TX power for OFDM 6M/9M											TX power for CCK5.5M/11M											TX power for CCK1M/2M */			/* TX_PWR_CFG_1 ~ TX_PWR_CFG_4 */			RTMP_IO_WRITE32(pAd, TX_PWR_CFG_0 + i*4, TxPwr[i]);			DBGPRINT(RT_DEBUG_INFO, ("ATEAsicAdjustTxPower - DeltaPwr=%d, offset=0x%x, TxPwr=%lx, BbpR1=%x, round=%ld, pTxAgcCompensate=%d \n",				DeltaPwr, TX_PWR_CFG_0 + i*4, TxPwr[i], BbpR49, pAd->Mlme.OneSecPeriodicRound, *pTxAgcCompensate));		}	}	DBGPRINT(RT_DEBUG_INFO, ("<-- ATEAsicAdjustTxPower, DeltaPwr=%d\n", DeltaPwr));}/*	========================================================================		Routine Description:		Calculates the duration which is required to transmit out frames 	with given size and specified rate.					  	Arguments:		pTxWI		Pointer to head of each MPDU to HW.		Ack 		Setting for Ack requirement bit		Fragment	Setting for Fragment bit		RetryMode	Setting for retry mode		Ifs 		Setting for IFS gap		Rate		Setting for transmit rate		Service 	Setting for service		Length		Frame length		TxPreamble	Short or Long preamble when using CCK rates		QueIdx - 0-3, according to 802.11e/d4.4 June/2003			Return Value:		None			IRQL = PASSIVE_LEVEL	IRQL = DISPATCH_LEVEL	    See also : BASmartHardTransmit()    !!!		========================================================================*/static VOID ATEWriteTxWI(	IN	PRTMP_ADAPTER	pAd,	IN	PTXWI_STRUC 	pOutTxWI,		IN	BOOLEAN			FRAG,		IN	BOOLEAN			CFACK,	IN	BOOLEAN			InsTimestamp,	IN	BOOLEAN 		AMPDU,	IN	BOOLEAN 		Ack,	IN	BOOLEAN 		NSeq,		// HW new a sequence.	IN	UCHAR			BASize,	IN	UCHAR			WCID,	IN	ULONG			Length,	IN	UCHAR 			PID,	IN	UCHAR			TID,	IN	UCHAR			TxRate,	IN	UCHAR			Txopmode,		IN	BOOLEAN			CfAck,		IN	HTTRANSMIT_SETTING	*pTransmit){	TXWI_STRUC 		TxWI;	PTXWI_STRUC 	pTxWI;	//	// Always use Long preamble before verifiation short preamble functionality works well.	// Todo: remove the following line if short preamble functionality works	//	OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_SHORT_PREAMBLE_INUSED);	NdisZeroMemory(&TxWI, TXWI_SIZE);	pTxWI = &TxWI;	pTxWI->FRAG= FRAG;	pTxWI->CFACK = CFACK;	pTxWI->TS= InsTimestamp;	pTxWI->AMPDU = AMPDU;	pTxWI->ACK = Ack;	pTxWI->txop= Txopmode;		pTxWI->NSEQ = NSeq;	// John tune the performace with Intel Client in 20 MHz performance	if( BASize >7 )		BASize =7;			pTxWI->BAWinSize = BASize;		pTxWI->WirelessCliID = WCID;	pTxWI->MPDUtotalByteCount = Length; 	pTxWI->PacketId = PID; 		// If CCK or OFDM, BW must be 20	pTxWI->BW = (pTransmit->field.MODE <= MODE_OFDM) ? (BW_40) : (pTransmit->field.BW);	pTxWI->ShortGI = pTransmit->field.ShortGI;	pTxWI->STBC = pTransmit->field.STBC;		pTxWI->MCS = pTransmit->field.MCS;	pTxWI->PHYMODE = pTransmit->field.MODE;	pTxWI->CFACK = CfAck;	pTxWI->MIMOps = 0;	pTxWI->MpduDensity = 0;	pTxWI->PacketId = pTxWI->MCS;	NdisMoveMemory(pOutTxWI, &TxWI, sizeof(TXWI_STRUC));}/*	========================================================================	Routine Description:		Disable protection for ATE.	========================================================================*/VOID ATEDisableAsicProtect(	IN		PRTMP_ADAPTER	pAd){	PROT_CFG_STRUC	ProtCfg, ProtCfg4;	UINT32 Protect[6];	USHORT			offset;	UCHAR			i;	UINT32 MacReg;	// Config ASIC RTS threshold register	RTMP_IO_READ32(pAd, TX_RTS_CFG, &MacReg);	MacReg &= 0xFF0000FF;	MacReg |= (pAd->CommonCfg.RtsThreshold << 8);	RT

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -