VOID
CHNL_SetChnlInfoFromDestPort(
	IN	PADAPTER			pDestAdapter,
	IN	PADAPTER			pSrcAdapter
)
{
	PMGNT_INFO			pDestMgntInfo = &pDestAdapter->MgntInfo;
	PRT_CHANNEL_INFO	pDestChnlInfo = GET_CHNL_INFO(pDestMgntInfo);
	PMGNT_INFO			pSrcMgntInfo = &pSrcAdapter->MgntInfo;
	PRT_CHANNEL_INFO 	pSrcChnlInfo = GET_CHNL_INFO(pSrcMgntInfo);

	pDestMgntInfo->dot11CurrentChannelNumber = pSrcMgntInfo->dot11CurrentChannelNumber;
	pDestMgntInfo->dot11CurrentChannelBandWidth = pSrcMgntInfo->dot11CurrentChannelBandWidth;

	// Best way is restart AP mode. 2012.01.08 lanhsin. 
	//pDestMgntInfo->CurrentBssWirelessMode = pDestMgntInfo->dot11CurrentWirelessMode = pSrcMgntInfo->dot11CurrentWirelessMode;
	
	pDestChnlInfo->PrimaryChannelNumber = pSrcChnlInfo->PrimaryChannelNumber;
	pDestChnlInfo->CurrentChannelBandWidth =  pSrcChnlInfo->CurrentChannelBandWidth;
	pDestChnlInfo->CurrentChannelCenterFrequency = pSrcChnlInfo->CurrentChannelCenterFrequency;

	pDestChnlInfo->Ext20MHzChnlOffsetOf40MHz = pSrcChnlInfo->Ext20MHzChnlOffsetOf40MHz;
	pDestChnlInfo->Ext40MHzChnlOffsetOf80MHz = pSrcChnlInfo->Ext40MHzChnlOffsetOf80MHz;

	RT_DISP(FCHNL, FCHNL_FUN, ("%s: pDestChnlInfo->CurrentChannelCenterFrequency=%d, pSrcChnlInfo->CurrentChannelCenterFrequency=%d\n", 
		__FUNCTION__, pDestChnlInfo->CurrentChannelCenterFrequency, pSrcChnlInfo->CurrentChannelCenterFrequency));
}
Exemple #2
0
VOID
halTxbf8814A_FwTxBFCmd(
	IN	PADAPTER	Adapter
)
{
	u1Byte	Idx, Period = 0;
	u1Byte	PageNum0 = 0xFF, PageNum1 = 0xFF;
	u1Byte	u1TxBFParm[3] = {0};

	PMGNT_INFO				pMgntInfo = &(Adapter->MgntInfo);
	PRT_BEAMFORMING_INFO	pBeamInfo = GET_BEAMFORM_INFO(Adapter);

	for (Idx = 0; Idx < BEAMFORMEE_ENTRY_NUM; Idx++) {
		if (pBeamInfo->BeamformeeEntry[Idx].bUsed && pBeamInfo->BeamformeeEntry[Idx].BeamformEntryState == BEAMFORMING_ENTRY_STATE_PROGRESSED) {
			if (pBeamInfo->BeamformeeEntry[Idx].bSound) {
				PageNum0 = 0xFE;
				PageNum1 = 0x07;
				Period = (u1Byte)(pBeamInfo->BeamformeeEntry[Idx].SoundPeriod);
			} else if (PageNum0 == 0xFF) {
				PageNum0 = 0xFF; /*stop sounding*/
				PageNum1 = 0x0F;
			}
		}
	}

	u1TxBFParm[0] = PageNum0;
	u1TxBFParm[1] = PageNum1;
	u1TxBFParm[2] = Period;
	FillH2CCmd(Adapter, PHYDM_H2C_TXBF, 3, u1TxBFParm);

	RT_DISP(FBEAM, FBEAM_FUN, ("@%s End, PageNum0 = 0x%x, PageNum1 = 0x%x Period = %d", __func__, PageNum0, PageNum1, Period));
}
//sherry added 20130207
//to check switch channel and bandwidth in progress
BOOLEAN
CHNL_SwChnlAndSetBwInProgress(
	PADAPTER	Adapter
)
{
	PADAPTER			pDefAdapter = GetDefaultAdapter(Adapter);
	PMGNT_INFO			pDefMgntInfo = &pDefAdapter->MgntInfo;
	PRT_CHANNEL_INFO	pDefChnlInfo = GET_CHNL_INFO(pDefMgntInfo);

	if(pDefChnlInfo->bSwBwInProgress)
	{
		RT_DISP(FCHNL, FCHNL_INFO, ("%s: return TRUE \n", __FUNCTION__));
		return TRUE;
	}
	else
	{
		RT_DISP(FCHNL, FCHNL_INFO, ("%s: return FALSE \n", __FUNCTION__));
		return FALSE;
	}
}
EXTCHNL_OFFSET
CHNL_GetExt20OffsetOf5G(
	IN u1Byte		channel
	)
{
	u1Byte			i;
	EXTCHNL_OFFSET	ExtChnlOffset = EXTCHNL_OFFSET_LOWER;
	u1Byte			UpperChannelList_5G[11] = {36,44,52,60,100,108,116,124,132,149,157};

	for(i =0; i < 11;i++)
	{
		if(channel == UpperChannelList_5G[i])
			break;
	}
	if(i < 11)
			ExtChnlOffset = EXTCHNL_OFFSET_UPPER;

	RT_DISP(FCHNL, FCHNL_INFO,  ("%s channel=%d, ExtChnlOffset=%d\n", __FUNCTION__, channel, ExtChnlOffset));
	
	return ExtChnlOffset;
}
Exemple #5
0
VOID
halTxbf8814A_DownloadNDPA(
	IN	PADAPTER			Adapter,
	IN	u1Byte				Idx
)
{
	u1Byte			u1bTmp = 0, tmpReg422 = 0;
	u1Byte			BcnValidReg = 0, count = 0, DLBcnCount = 0;
	u2Byte			Head_Page = 0x7FE;
	BOOLEAN			bSendBeacon = FALSE;
	HAL_DATA_TYPE	*pHalData = GET_HAL_DATA(Adapter);
	u2Byte			TxPageBndy = LAST_ENTRY_OF_TX_PKT_BUFFER_8814A; /*default reseved 1 page for the IC type which is undefined.*/
	PRT_BEAMFORMING_INFO	pBeamInfo = GET_BEAMFORM_INFO(Adapter);
	PRT_BEAMFORMEE_ENTRY	pBeamEntry = pBeamInfo->BeamformeeEntry + Idx;

	pHalData->bFwDwRsvdPageInProgress = TRUE;
	Adapter->HalFunc.GetHalDefVarHandler(Adapter, HAL_DEF_TX_PAGE_BOUNDARY, (pu2Byte)&TxPageBndy);

	/*Set REG_CR bit 8. DMA beacon by SW.*/
	u1bTmp = PlatformEFIORead1Byte(Adapter, REG_CR_8814A + 1);
	PlatformEFIOWrite1Byte(Adapter,  REG_CR_8814A + 1, (u1bTmp | BIT0));


	/*Set FWHW_TXQ_CTRL 0x422[6]=0 to tell Hw the packet is not a real beacon frame.*/
	tmpReg422 = PlatformEFIORead1Byte(Adapter, REG_FWHW_TXQ_CTRL_8814A + 2);
	PlatformEFIOWrite1Byte(Adapter, REG_FWHW_TXQ_CTRL_8814A + 2,  tmpReg422 & (~BIT6));

	if (tmpReg422 & BIT6) {
		RT_TRACE(COMP_INIT, DBG_LOUD, ("SetBeamformDownloadNDPA_8814A(): There is an Adapter is sending beacon.\n"));
		bSendBeacon = TRUE;
	}

	/*0x204[11:0]	Beacon Head for TXDMA*/
	PlatformEFIOWrite2Byte(Adapter, REG_FIFOPAGE_CTRL_2_8814A, Head_Page);

	do {
		/*Clear beacon valid check bit.*/
		BcnValidReg = PlatformEFIORead1Byte(Adapter, REG_FIFOPAGE_CTRL_2_8814A + 1);
		PlatformEFIOWrite1Byte(Adapter, REG_FIFOPAGE_CTRL_2_8814A + 1, (BcnValidReg | BIT7));

		/*download NDPA rsvd page.*/
		if (pBeamEntry->BeamformEntryCap & BEAMFORMER_CAP_VHT_SU)
			Beamforming_SendVHTNDPAPacket(pDM_Odm, pBeamEntry->MacAddr, pBeamEntry->AID, pBeamEntry->SoundBW, BEACON_QUEUE);
		else
			Beamforming_SendHTNDPAPacket(pDM_Odm, pBeamEntry->MacAddr, pBeamEntry->SoundBW, BEACON_QUEUE);

		/*check rsvd page download OK.*/
		BcnValidReg = PlatformEFIORead1Byte(Adapter, REG_FIFOPAGE_CTRL_2_8814A + 1);
		count = 0;
		while (!(BcnValidReg & BIT7) && count < 20) {
			count++;
			delay_us(10);
			BcnValidReg = PlatformEFIORead1Byte(Adapter, REG_FIFOPAGE_CTRL_2_8814A + 2);
		}
		DLBcnCount++;
	} while (!(BcnValidReg & BIT7) && DLBcnCount < 5);

	if (!(BcnValidReg & BIT0))
		RT_DISP(FBEAM, FBEAM_ERROR, ("%s Download RSVD page failed!\n", __func__));

	/*0x204[11:0]	Beacon Head for TXDMA*/
	PlatformEFIOWrite2Byte(Adapter, REG_FIFOPAGE_CTRL_2_8814A, TxPageBndy);

	/*To make sure that if there exists an adapter which would like to send beacon.*/
	/*If exists, the origianl value of 0x422[6] will be 1, we should check this to*/
	/*prevent from setting 0x422[6] to 0 after download reserved page, or it will cause */
	/*the beacon cannot be sent by HW.*/
	/*2010.06.23. Added by tynli.*/
	if (bSendBeacon)
		PlatformEFIOWrite1Byte(Adapter, REG_FWHW_TXQ_CTRL_8814A + 2, tmpReg422);

	/*Do not enable HW DMA BCN or it will cause Pcie interface hang by timing issue. 2011.11.24. by tynli.*/
	/*Clear CR[8] or beacon packet will not be send to TxBuf anymore.*/
	u1bTmp = PlatformEFIORead1Byte(Adapter, REG_CR_8814A + 1);
	PlatformEFIOWrite1Byte(Adapter, REG_CR_8814A + 1, (u1bTmp & (~BIT0)));

	pBeamEntry->BeamformEntryState = BEAMFORMING_ENTRY_STATE_PROGRESSED;

	pHalData->bFwDwRsvdPageInProgress = FALSE;
}
//
// This function set bandwidth mode in protocol layer.
//
VOID
CHNL_SetBwChnl(
	IN	PADAPTER			pAdapter,
	IN	u1Byte				PrimaryChnl,
	IN	CHANNEL_WIDTH		Bandwidth,
	IN	EXTCHNL_OFFSET		BwOffset
	)
{
	PMGNT_INFO					pMgntInfo = &pAdapter->MgntInfo;
	PRT_CHANNEL_INFO			pChnlInfo = GET_CHNL_INFO(pMgntInfo);
	
	PADAPTER					DefAdapter = GetDefaultAdapter(pAdapter);
	PMGNT_INFO					pDefMgntInfo = &DefAdapter->MgntInfo;
	PRT_CHANNEL_INFO			pDefChnlInfo = GET_CHNL_INFO(pDefMgntInfo);
	PCHANNEL_COMMON_CONTEXT		pDefChnlCommInfo = DefAdapter->pPortCommonInfo->pChnlCommInfo;

	CHANNEL_WIDTH				ToSetBandWidth = CHANNEL_WIDTH_20;
	EXTCHNL_OFFSET				ToSTAExtChnlOffsetof40MHz= EXTCHNL_OFFSET_NO_EXT;
	EXTCHNL_OFFSET				ToSTAExtChnlOffsetof80MHz= EXTCHNL_OFFSET_NO_EXT;
	u1Byte						ToSTACenterFrequency;

	RT_TRACE_F(COMP_SCAN, DBG_LOUD, ("PrimaryChnl %d\n", PrimaryChnl));

	if(ACTING_AS_IBSS(DefAdapter))
	{
		{
			// 2013/10/15 MH Add for higher adhoc and VHT 2.4G mode.
			if (!pMgntInfo->bReg11nAdhoc && !pMgntInfo->bRegVht24g)
			{
				Bandwidth= CHANNEL_WIDTH_20;
				BwOffset = EXTCHNL_OFFSET_NO_EXT;
			}
		}
	}

	ToSetBandWidth = Bandwidth;
	ToSTAExtChnlOffsetof40MHz = BwOffset;
	ToSTACenterFrequency = CHNL_GetCenterFrequency(PrimaryChnl, Bandwidth, BwOffset);
	
	ToSetBandWidth = CHNL_CheckChnlPlanWithBW(pAdapter,PrimaryChnl,Bandwidth,BwOffset);

	if((ToSetBandWidth != Bandwidth) &&  ToSetBandWidth==CHANNEL_WIDTH_20)
		ToSTACenterFrequency =PrimaryChnl;
	
	if(Bandwidth == CHANNEL_WIDTH_80)
	{
		if(ToSTACenterFrequency > pMgntInfo->dot11CurrentChannelNumber)
			ToSTAExtChnlOffsetof80MHz = EXTCHNL_OFFSET_UPPER;
		else if(ToSTACenterFrequency < pMgntInfo->dot11CurrentChannelNumber)
			ToSTAExtChnlOffsetof80MHz = EXTCHNL_OFFSET_LOWER;
		else
			ToSTAExtChnlOffsetof80MHz = EXTCHNL_OFFSET_NO_EXT;		
	}

	RT_DISP(FCHNL, FCHNL_FUN,  ("Set ToSetBandWidth = %d, ToSTAExtChnlOffset = %d,ToSTAExtChnlOffsetof80MHz %d, ToSTACenterFrequency= %d \n", ToSetBandWidth, ToSTAExtChnlOffsetof40MHz,ToSTAExtChnlOffsetof80MHz,ToSTACenterFrequency));

	pMgntInfo->dot11CurrentChannelBandWidth = ToSetBandWidth;
	pChnlInfo->PrimaryChannelNumber = pDefChnlCommInfo->PrimaryChannelNumber = PrimaryChnl;
	pChnlInfo->CurrentChannelBandWidth = pDefChnlCommInfo->CurrentChannelBandWidth = ToSetBandWidth;
	pChnlInfo->CurrentChannelCenterFrequency = pDefChnlCommInfo->CurrentChannelCenterFrequency = ToSTACenterFrequency;
	pChnlInfo->Ext20MHzChnlOffsetOf40MHz = pDefChnlCommInfo->Ext20MHzChnlOffsetOf40MHz = ToSTAExtChnlOffsetof40MHz;
	pChnlInfo->Ext40MHzChnlOffsetOf80MHz = pDefChnlCommInfo->Ext40MHzChnlOffsetOf80MHz = ToSTAExtChnlOffsetof80MHz;

	// TODO: 2007.7.13 by Emily Wait 2000ms  in order to garantee that switching
	//   bandwidth is executed after scan is finished. It is a temporal solution
	//   because software should ganrantee the last operation of switching bandwidth
	//   is executed properlly. 
	if(!(RT_DRIVER_HALT(DefAdapter)))
		PlatformSetTimer(DefAdapter, &pDefChnlInfo->SwBwTimer, 0);

	FunctionOut(COMP_SCAN);
}
VOID
CHNL_SetBwChnlCallback(
	IN	PRT_TIMER		pTimer
	)
{
	PADAPTER			Adapter=(PADAPTER)pTimer->Adapter;
	PMGNT_INFO			pMgntInfo=&Adapter->MgntInfo;
	PRT_CHANNEL_INFO	pChnlInfo = pMgntInfo->pChannelInfo;
	PHAL_DATA_TYPE	   	pHalData = GET_HAL_DATA(Adapter);
	BOOLEAN				bSwBW = TRUE;

	RT_DISP(FCHNL, FCHNL_FUN, ("===>%s \n", __FUNCTION__));

	if(RT_DRIVER_HALT(Adapter))
	{
		RT_DISP(FCHNL, FCHNL_ERROR, ("<===%s bDriverStopped %d bSurpriseRemoved %d bDriverIsGoingToUnload %d\n", __FUNCTION__, Adapter->bDriverStopped, Adapter->bSurpriseRemoved, Adapter->bDriverIsGoingToUnload));	
		return;
	}

	if(Adapter->bInSetPower && RT_CANNOT_IO(Adapter))
	
	{
		RT_DISP(FCHNL, FCHNL_ERROR, ("<===%s can NOT IO\n", __FUNCTION__));
		bSwBW = FALSE;
	}

	if(MgntResetOrPnPInProgress(Adapter))
	{
		RT_DISP(FCHNL, FCHNL_ERROR, ("<===%s MgntResetOrPnPInProgress\n", __FUNCTION__));			
		bSwBW = FALSE;
	}
	
	if(bSwBW == FALSE)
	{
		PlatformAcquireSpinLock(Adapter, RT_BW_SPINLOCK);
		pChnlInfo->bSwBwInProgress = FALSE;
		PlatformReleaseSpinLock(Adapter, RT_BW_SPINLOCK);
		return;
	}
	
	if(MgntInitAdapterInProgress(pMgntInfo))
	{
		PlatformSetTimer(Adapter, &pChnlInfo->SwBwTimer, 100);
		return;
	}
	
   if(RT_IsSwChnlAndBwInProgress(Adapter))
   { 
  		RT_DISP(FCHNL, FCHNL_FUN, ("<===%s pHalData->SwChnlInProgress: %d, pHalData->SetBWModeInProgress: %d, pHalData->bSwChnlAndSetBWInProgress: %d\n", 
				__FUNCTION__, pHalData->SwChnlInProgress, pHalData->SetBWModeInProgress, pHalData->bSwChnlAndSetBWInProgress));
	
       	PlatformSetTimer(Adapter, &pChnlInfo->SwBwTimer, 10);
		return;
   }

	if(pMgntInfo->bScanInProgress)
	{
		RT_DISP(FCHNL, FCHNL_FUN, ("<===%s bScanInProgress\n", __FUNCTION__));
		PlatformSetTimer(Adapter, &pChnlInfo->SwBwTimer, 10);
		return;
	}
	   
	if(!CHNL_AcquireOpLock(Adapter, CHNLOP_SWBW))
	{
		PlatformSetTimer(Adapter, &pChnlInfo->SwBwTimer, 10);
		return;
	}

	if(IsDefaultAdapter(Adapter))
	{
		RT_DISP(FCHNL, FCHNL_FUN, ("%s  Def Adapter \n", __FUNCTION__));
	}
	else
	{
		RT_DISP(FCHNL, FCHNL_FUN, ("%s  Ext Adapter \n", __FUNCTION__));
	}

	PlatformAcquireSpinLock(Adapter, RT_BW_SPINLOCK);
	pChnlInfo->bSwBwInProgress = TRUE;	
	PlatformReleaseSpinLock(Adapter, RT_BW_SPINLOCK);

	chnl_HalSwBwChnl(Adapter);
		
	// bandtype different only occur in 92d ; for 92c/92s  last band type is the same as current band type		
	pHalData->LastBandType = pHalData->CurrentBandType;  

	PlatformAcquireSpinLock(Adapter, RT_BW_SPINLOCK);
	pChnlInfo->bSwBwInProgress = FALSE;
	PlatformReleaseSpinLock(Adapter, RT_BW_SPINLOCK);

	CHNL_ReleaseOpLock(Adapter);	
	
	RT_DISP(FCHNL, FCHNL_FUN, ("<===%s\n", __FUNCTION__));
}
VOID
CHNL_ChangeBwChnlFromPeerWorkitemCallBack(
	IN	PVOID			Context
)
{
	PADAPTER			Adapter = (PADAPTER)Context;	
	CHANNEL_WIDTH		ChnlBW;
	EXTCHNL_OFFSET		ExtChnlOffset;
	PMGNT_INFO			pMgntInfo = &Adapter->MgntInfo;
	PRT_CHANNEL_INFO	pChnlInfo = GET_CHNL_INFO(pMgntInfo);
	PADAPTER			pExtAdapter = GetFirstAPAdapter(Adapter);
	PADAPTER			pGoAdapter = GetFirstGOPort(Adapter);

	if(pExtAdapter != NULL)
	{
		if(pExtAdapter->bAPChannelInprogressForNewconnected)
		{
			RT_DISP(FCHNL, FCHNL_ERROR, ("%s: AP change channel in progress , return \n", __FUNCTION__));
			return;

		}
	}

	if(pGoAdapter != NULL)
	{
		if(pGoAdapter->bAPChannelInprogressForNewconnected)
		{
			RT_DISP(FCHNL, FCHNL_ERROR, ("%s: AP change channel in progress , return \n", __FUNCTION__));
			return;
		}
	}

	if(GetDefaultMgntInfo(Adapter)->RegMultiChannelFcsMode != 0)
	{
		if(TRUE == MultiChannel_IsFCSInProgress(Adapter))
		{
			RT_TRACE(COMP_MULTICHANNEL, DBG_TRACE, ("CHNL_ChangeBwChnlFromPeerWorkitemCallBack(): skip change ch & bw due to MCC\n"));
			return;
		}
	}
	
#if 0
	if(GetDefaultAdapter(Adapter)->bInHctTest)
	{
		RT_DISP(FCHNL, FCHNL_ERROR, ("%s: hct test , return \n", __FUNCTION__));
		return;
	
	}
#endif	

	
	chnl_GetBWFrom_IE(Adapter, &ChnlBW, &ExtChnlOffset);

	if(	pChnlInfo->CurrentChannelBandWidth != ChnlBW ||
		pChnlInfo->Ext20MHzChnlOffsetOf40MHz != ExtChnlOffset)
	{
		//
		// Leave LPS and wait until RF is already on before switching channel. 2014.09.25, by tynli.
		//
		LPSLeaveAndCheckReady(Adapter);

		RT_TRACE(COMP_MLME, DBG_LOUD, ("CHNL_ChangeBwChnlFromPeerWorkitemCallBack(): CurrentChannel=%d, ChnlBW=%d, ExtChnlOffset=%d\n",
			pMgntInfo->dot11CurrentChannelNumber, ChnlBW, ExtChnlOffset));

		CHNL_SetBwChnl(Adapter, pMgntInfo->dot11CurrentChannelNumber, ChnlBW, ExtChnlOffset);
		// We should set RA H2C cmd because the BW in TxDesc will be filled again by Fw, we 
		// need to inform Fw the BW changed information. 2012.11.26. by tynli. 
		// Suggested by SD1 Alex Chou.
		if(!ACTING_AS_AP(Adapter) && !ACTING_AS_IBSS(Adapter))
		{
			// we only need to set rate mask
			Adapter->HalFunc.UpdateHalRAMaskHandler(Adapter, pMgntInfo->mMacId, NULL, 0);

		}
	}

}
VOID
chnl_GetBWFrom_IE(
	IN	PADAPTER		Adapter,
	OUT PCHANNEL_WIDTH	pChnlBW,
	OUT PEXTCHNL_OFFSET	pExtChnlOffset
)
{
	PMGNT_INFO					pMgntInfo=&Adapter->MgntInfo;
	PRT_HIGH_THROUGHPUT		pHTInfo = GET_HT_INFO(pMgntInfo);
	PRT_VERY_HIGH_THROUGHPUT	pVHTInfo = GET_VHT_INFO(pMgntInfo);

	BOOLEAN 		bBW40MHz = FALSE, bBW80MHz = FALSE;
	CHANNEL_WIDTH	ChnlBW = CHANNEL_WIDTH_20;
	EXTCHNL_OFFSET	ExtChnlOffset = EXTCHNL_OFFSET_NO_EXT;

	if(pHTInfo->bCurrentHTSupport)
	{
		CHANNEL_WIDTH	PeerChnlBW = (CHANNEL_WIDTH)pHTInfo->bPeer40MHzCap;
		EXTCHNL_OFFSET	PeerExtChnlOffset = pHTInfo->PeerExtChnlOffset;

		ChnlBW = CHNL_GetRegBWSupport(Adapter);
		if(ChnlBW == CHANNEL_WIDTH_20)						// 20 STA -> 40 AP or 20 STA -> 20 AP
			ExtChnlOffset = EXTCHNL_OFFSET_NO_EXT;
		else if(PeerChnlBW == CHANNEL_WIDTH_20)				// 40 STA -> 20 AP
			ChnlBW = CHANNEL_WIDTH_20;
		else if(PeerExtChnlOffset == EXTCHNL_OFFSET_NO_EXT)
			ChnlBW = CHANNEL_WIDTH_20;
		else													// 40 STA -> 40 AP
		{
			if(	PeerExtChnlOffset == EXTCHNL_OFFSET_UPPER && 
				CHNL_IsLegalChannel(Adapter, pMgntInfo->dot11CurrentChannelNumber + 2))
				bBW40MHz = TRUE;
			else if(PeerExtChnlOffset== EXTCHNL_OFFSET_LOWER &&
				 CHNL_IsLegalChannel(Adapter, pMgntInfo->dot11CurrentChannelNumber - 2))
				bBW40MHz = TRUE;
			else
				bBW40MHz = FALSE;

			if(bBW40MHz == TRUE)
			{
				ChnlBW = PeerChnlBW;
				ExtChnlOffset = PeerExtChnlOffset;
			}	
			else
			{
				ChnlBW = CHANNEL_WIDTH_20;
				ExtChnlOffset = EXTCHNL_OFFSET_NO_EXT;
			}
		}
		RT_DISP(FCHNL, FCHNL_INFO, ("%s PeerChnlBW=%d, PeerExtChnlOffset=%d\n", __FUNCTION__, PeerChnlBW, PeerExtChnlOffset));
	}
	else
		ChnlBW = CHANNEL_WIDTH_20;

	
	if(bBW40MHz && pVHTInfo->bCurrentVHTSupport)
	{
		bBW80MHz = (CHNL_GetRegBWSupport(Adapter) >= CHANNEL_WIDTH_80)?(pVHTInfo->PeerChnlBW?1:0):0;

		if(bBW80MHz == 0)
			ChnlBW = CHANNEL_WIDTH_40;
		else
			ChnlBW = CHANNEL_WIDTH_80;
	}

	*pChnlBW = ChnlBW;
	*pExtChnlOffset = ExtChnlOffset;

	RT_DISP(FCHNL, FCHNL_INFO, ("%s ChnlBW=%d, ExtChnlOffset=%d, bEnableVHT = %d, bCurrentHTSupport = %d, bCurrentVHTSupport = %d,\n PeerChnlBW = %d, CHNL_GetRegBWSupport() = %d\n", __FUNCTION__, ChnlBW, ExtChnlOffset, pVHTInfo->bEnableVHT, pHTInfo->bCurrentHTSupport, pVHTInfo->bCurrentVHTSupport, pVHTInfo->PeerChnlBW, CHNL_GetRegBWSupport(Adapter)));
}