Commit 5f5d2df8 authored by Bartlomiej Zolnierkiewicz's avatar Bartlomiej Zolnierkiewicz Committed by Greg Kroah-Hartman

Staging: rt2860: prepare for rt28[67]0/sta/*.[ch] merge

Signed-off-by: default avatarBartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 371abf6d
This diff is collapsed.
This diff is collapsed.
......@@ -74,6 +74,7 @@ VOID STARxEAPOLFrameIndicate(
if (pAd->StaCfg.DesireSharedKey[idx].KeyLen > 0)
{
#ifdef RT2860
MAC_TABLE_ENTRY *pEntry = &pAd->MacTab.Content[BSSID_WCID];
// Set key material and cipherAlg to Asic
......@@ -87,6 +88,32 @@ VOID STARxEAPOLFrameIndicate(
pAd->IndicateMediaState = NdisMediaStateConnected;
pAd->ExtraInfo = GENERAL_LINK_UP;
#endif
#ifdef RT2870
union
{
char buf[sizeof(NDIS_802_11_WEP)+MAX_LEN_OF_KEY- 1];
NDIS_802_11_WEP keyinfo;
} WepKey;
int len;
NdisZeroMemory(&WepKey, sizeof(WepKey));
len =pAd->StaCfg.DesireSharedKey[idx].KeyLen;
NdisMoveMemory(WepKey.keyinfo.KeyMaterial,
pAd->StaCfg.DesireSharedKey[idx].Key,
pAd->StaCfg.DesireSharedKey[idx].KeyLen);
WepKey.keyinfo.KeyIndex = 0x80000000 + idx;
WepKey.keyinfo.KeyLength = len;
pAd->SharedKey[BSS0][idx].KeyLen =(UCHAR) (len <= 5 ? 5 : 13);
pAd->IndicateMediaState = NdisMediaStateConnected;
pAd->ExtraInfo = GENERAL_LINK_UP;
// need to enqueue cmd to thread
RTUSBEnqueueCmdFromNdis(pAd, OID_802_11_ADD_WEP, TRUE, &WepKey, sizeof(WepKey.keyinfo) + len - 1);
#endif // RT2870 //
// For Preventing ShardKey Table is cleared by remove key procedure.
pAd->SharedKey[BSS0][idx].CipherAlg = CipherAlg;
pAd->SharedKey[BSS0][idx].KeyLen = pAd->StaCfg.DesireSharedKey[idx].KeyLen;
......@@ -548,7 +575,13 @@ VOID STAHandleRxMgmtFrame(
{
// We should collect RSSI not only U2M data but also my beacon
#ifdef RT30xx
if ((pHeader->FC.SubType == SUBTYPE_BEACON) && (MAC_ADDR_EQUAL(&pAd->CommonCfg.Bssid, &pHeader->Addr2))
&& (pAd->RxAnt.EvaluatePeriod == 0))
#endif
#ifndef RT30xx
if ((pHeader->FC.SubType == SUBTYPE_BEACON) && (MAC_ADDR_EQUAL(&pAd->CommonCfg.Bssid, &pHeader->Addr2)))
#endif
{
Update_Rssi_Sample(pAd, &pAd->StaCfg.RssiSample, pRxWI);
......@@ -556,6 +589,18 @@ VOID STAHandleRxMgmtFrame(
pAd->StaCfg.LastSNR1 = (UCHAR)(pRxWI->SNR1);
}
#ifdef RT30xx
// collect rssi information for antenna diversity
if (pAd->NicConfig2.field.AntDiversity)
{
if ((pRxD->U2M) || ((pHeader->FC.SubType == SUBTYPE_BEACON) && (MAC_ADDR_EQUAL(&pAd->CommonCfg.Bssid, &pHeader->Addr2))))
{
COLLECT_RX_ANTENNA_AVERAGE_RSSI(pAd, ConvertToRssi(pAd, (UCHAR)pRxWI->RSSI0, RSSI_0), 0); //Note: RSSI2 not used on RT73
pAd->StaCfg.NumOfAvgRssiSample ++;
}
}
#endif // RT30xx //
// First check the size, it MUST not exceed the mlme queue size
if (pRxWI->MPDUtotalByteCount > MGMT_DMA_BUFFER_SIZE)
{
......@@ -643,12 +688,14 @@ BOOLEAN STARxDoneInterruptHandle(
break;
}
#ifdef RT2860
if (RxProcessed++ > MAX_RX_PROCESS_CNT)
{
// need to reschedule rx handle
bReschedule = TRUE;
break;
}
#endif
RxProcessed ++; // test
......@@ -738,6 +785,7 @@ BOOLEAN STARxDoneInterruptHandle(
}
}
#ifdef RT2860
// fRTMP_PS_GO_TO_SLEEP_NOW is set if receiving beacon.
if (RTMP_TEST_PSFLAG(pAd, fRTMP_PS_GO_TO_SLEEP_NOW) && (INFRA_ON(pAd)))
{
......@@ -745,6 +793,7 @@ BOOLEAN STARxDoneInterruptHandle(
AsicSleepThenAutoWakeup(pAd, pAd->ThisTbttNumToNextWakeUp);
bReschedule = FALSE;
}
#endif
return bReschedule;
}
......@@ -762,7 +811,12 @@ BOOLEAN STARxDoneInterruptHandle(
VOID RTMPHandleTwakeupInterrupt(
IN PRTMP_ADAPTER pAd)
{
#ifdef RT2860
AsicForceWakeup(pAd, DOT11POWERSAVE);
#endif
#ifdef RT2870
AsicForceWakeup(pAd, FALSE);
#endif
}
/*
......@@ -1011,7 +1065,13 @@ NDIS_STATUS STASendPacket(
//
UserPriority = 0;
QueIdx = QID_AC_BE;
#ifdef RT2860
if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_WMM_INUSED))
#endif
#ifdef RT2870
if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_WMM_INUSED) &&
CLIENT_STATUS_TEST_FLAG(pEntry, fCLIENT_STATUS_WMM_CAPABLE))
#endif
{
USHORT Protocol;
UCHAR LlcSnapLen = 0, Byte0, Byte1;
......@@ -1075,7 +1135,12 @@ NDIS_STATUS STASendPacket(
RTMP_IRQ_UNLOCK(&pAd->irq_lock, IrqFlags);
if ((pAd->CommonCfg.BACapability.field.AutoBA == TRUE)&&
#ifdef RT2860
(pAd->StaActive.SupportedPhyInfo.bHtEnable == TRUE))
#endif
#ifdef RT2870
IS_HT_STA(pEntry))
#endif
{
if (((pEntry->TXBAbitmap & (1<<UserPriority)) == 0) &&
((pEntry->BADeclineBitmap & (1<<UserPriority)) == 0) &&
......@@ -1119,14 +1184,27 @@ NDIS_STATUS STASendPacket(
========================================================================
*/
#ifdef RT2870
/*
Actually, this function used to check if the TxHardware Queue still has frame need to send.
If no frame need to send, go to sleep, else, still wake up.
*/
#endif
NDIS_STATUS RTMPFreeTXDRequest(
IN PRTMP_ADAPTER pAd,
IN UCHAR QueIdx,
IN UCHAR NumberRequired,
IN PUCHAR FreeNumberIs)
{
#ifdef RT2860
ULONG FreeNumber = 0;
#endif
NDIS_STATUS Status = NDIS_STATUS_FAILURE;
#ifdef RT2870
unsigned long IrqFlags;
HT_TX_CONTEXT *pHTTXContext;
#endif
switch (QueIdx)
{
......@@ -1135,6 +1213,7 @@ NDIS_STATUS RTMPFreeTXDRequest(
case QID_AC_VI:
case QID_AC_VO:
case QID_HCCA:
#ifdef RT2860
if (pAd->TxRing[QueIdx].TxSwFreeIdx > pAd->TxRing[QueIdx].TxCpuIdx)
FreeNumber = pAd->TxRing[QueIdx].TxSwFreeIdx - pAd->TxRing[QueIdx].TxCpuIdx - 1;
else
......@@ -1142,9 +1221,27 @@ NDIS_STATUS RTMPFreeTXDRequest(
if (FreeNumber >= NumberRequired)
Status = NDIS_STATUS_SUCCESS;
#endif
#ifdef RT2870
{
pHTTXContext = &pAd->TxContext[QueIdx];
RTMP_IRQ_LOCK(&pAd->TxContextQueueLock[QueIdx], IrqFlags);
if ((pHTTXContext->CurWritePosition != pHTTXContext->ENextBulkOutPosition) ||
(pHTTXContext->IRPPending == TRUE))
{
Status = NDIS_STATUS_FAILURE;
}
else
{
Status = NDIS_STATUS_SUCCESS;
}
RTMP_IRQ_UNLOCK(&pAd->TxContextQueueLock[QueIdx], IrqFlags);
}
#endif
break;
case QID_MGMT:
#ifdef RT2860
if (pAd->MgmtRing.TxSwFreeIdx > pAd->MgmtRing.TxCpuIdx)
FreeNumber = pAd->MgmtRing.TxSwFreeIdx - pAd->MgmtRing.TxCpuIdx - 1;
else
......@@ -1152,13 +1249,22 @@ NDIS_STATUS RTMPFreeTXDRequest(
if (FreeNumber >= NumberRequired)
Status = NDIS_STATUS_SUCCESS;
#endif
#ifdef RT2870
if (pAd->MgmtRing.TxSwFreeIdx != MGMT_RING_SIZE)
Status = NDIS_STATUS_FAILURE;
else
Status = NDIS_STATUS_SUCCESS;
#endif
break;
default:
DBGPRINT(RT_DEBUG_ERROR,("RTMPFreeTXDRequest::Invalid QueIdx(=%d)\n", QueIdx));
break;
}
#ifdef RT2860
*FreeNumberIs = (UCHAR)FreeNumber;
#endif
return (Status);
}
......@@ -1689,7 +1795,9 @@ VOID STA_AMPDU_Frame_Tx(
//
// Kick out Tx
//
#ifdef RT2860
if (!RTMP_TEST_PSFLAG(pAd, fRTMP_PS_DISABLE_TX))
#endif
HAL_KickOutTx(pAd, pTxBlk, pTxBlk->QueIdx);
pAd->RalinkCounters.KickTxCount++;
......@@ -1820,7 +1928,9 @@ VOID STA_AMSDU_Frame_Tx(
//
// Kick out Tx
//
#ifdef RT2860
if (!RTMP_TEST_PSFLAG(pAd, fRTMP_PS_DISABLE_TX))
#endif
HAL_KickOutTx(pAd, pTxBlk, pTxBlk->QueIdx);
}
......@@ -1940,7 +2050,9 @@ VOID STA_Legacy_Frame_Tx(
//
// Kick out Tx
//
#ifdef RT2860
if (!RTMP_TEST_PSFLAG(pAd, fRTMP_PS_DISABLE_TX))
#endif
HAL_KickOutTx(pAd, pTxBlk, pTxBlk->QueIdx);
}
......@@ -2051,7 +2163,9 @@ VOID STA_ARalink_Frame_Tx(
//
// Kick out Tx
//
#ifdef RT2860
if (!RTMP_TEST_PSFLAG(pAd, fRTMP_PS_DISABLE_TX))
#endif
HAL_KickOutTx(pAd, pTxBlk, pTxBlk->QueIdx);
}
......@@ -2320,7 +2434,12 @@ NDIS_STATUS STAHardTransmit(
if ((pAd->StaCfg.Psm == PWR_SAVE) && OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_DOZE))
{
DBGPRINT_RAW(RT_DEBUG_TRACE, ("AsicForceWakeup At HardTx\n"));
#ifdef RT2860
AsicForceWakeup(pAd, FROM_TX);
#endif
#ifdef RT2870
AsicForceWakeup(pAd, TRUE);
#endif
}
// It should not change PSM bit, when APSD turn on.
......
......@@ -37,6 +37,7 @@
*/
#include "../rt_config.h"
#ifdef RT2860
#define AC0_DEF_TXOP 0
#define AC1_DEF_TXOP 0
#define AC2_DEF_TXOP 94
......@@ -71,6 +72,10 @@ VOID AdhocTurnOnQos(
}
AsicSetEdcaParm(pAd, &pAd->CommonCfg.APEdcaParm);
}
#endif /* RT2860 */
#ifdef RT2870
#define ADHOC_ENTRY_BEACON_LOST_TIME (2*OS_HZ) // 2 sec
#endif
/*
==========================================================================
......@@ -226,6 +231,7 @@ VOID MlmeScanReqAction(
// Increase the scan retry counters.
pAd->StaCfg.ScanCnt++;
#ifdef RT2860
if ((OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_ADVANCE_POWER_SAVE_PCIE_DEVICE)) &&
(IDLE_ON(pAd)) &&
(pAd->StaCfg.bRadio == TRUE) &&
......@@ -233,6 +239,7 @@ VOID MlmeScanReqAction(
{
RT28xxPciAsicRadioOn(pAd, GUI_IDLE_POWER_SAVE);
}
#endif
// first check the parameter sanity
if (MlmeScanReqSanity(pAd,
......@@ -345,6 +352,7 @@ VOID MlmeJoinReqAction(
DBGPRINT(RT_DEBUG_TRACE, ("SYNC - MlmeJoinReqAction(BSS #%ld)\n", pInfo->BssIdx));
#ifdef RT2860
if ((OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_ADVANCE_POWER_SAVE_PCIE_DEVICE)) &&
(IDLE_ON(pAd)) &&
(pAd->StaCfg.bRadio == TRUE) &&
......@@ -352,6 +360,7 @@ VOID MlmeJoinReqAction(
{
RT28xxPciAsicRadioOn(pAd, GUI_IDLE_POWER_SAVE);
}
#endif
// reset all the timers
RTMPCancelTimer(&pAd->MlmeAux.ScanTimer, &TimerCancelled);
......@@ -1107,6 +1116,10 @@ VOID PeerBeacon(
// Add the safeguard against the mismatch of adhoc wep status
if (pAd->StaCfg.WepStatus != pAd->ScanTab.BssEntry[Bssidx].WepStatus)
{
#ifdef RT30xx
DBGPRINT(RT_DEBUG_TRACE, ("SYNC - Not matched wep status %d %d\n", pAd->StaCfg.WepStatus, pAd->ScanTab.BssEntry[Bssidx].WepStatus));
DBGPRINT(RT_DEBUG_TRACE, ("bssid=%s\n", pAd->ScanTab.BssEntry[Bssidx].Bssid));
#endif
return;
}
......@@ -1170,11 +1183,14 @@ VOID PeerBeacon(
pAd->CommonCfg.TxPowerPercentage = pAd->CommonCfg.TxPowerDefault;
}
#ifdef RT2860
// at least one 11b peer joined. downgrade the MaxTxRate to 11Mbps
// after last 11b peer left for several seconds, we'll auto switch back to 11G rate
// in MlmePeriodicExec()
#endif
if (ADHOC_ON(pAd) && (CAP_IS_IBSS_ON(CapabilityInfo)))
{
#ifdef RT2860
BOOLEAN bRestart;
BOOLEAN bnRestart;
......@@ -1359,6 +1375,79 @@ VOID PeerBeacon(
}
}
}
#endif /* RT2860 */
#ifdef RT2870
UCHAR MaxSupportedRateIn500Kbps = 0;
UCHAR idx;
MAC_TABLE_ENTRY *pEntry;
// supported rates array may not be sorted. sort it and find the maximum rate
for (idx=0; idx<SupRateLen; idx++)
{
if (MaxSupportedRateIn500Kbps < (SupRate[idx] & 0x7f))
MaxSupportedRateIn500Kbps = SupRate[idx] & 0x7f;
}
for (idx=0; idx<ExtRateLen; idx++)
{
if (MaxSupportedRateIn500Kbps < (ExtRate[idx] & 0x7f))
MaxSupportedRateIn500Kbps = ExtRate[idx] & 0x7f;
}
// look up the existing table
pEntry = MacTableLookup(pAd, Addr2);
// Ad-hoc mode is using MAC address as BA session. So we need to continuously find newly joined adhoc station by receiving beacon.
// To prevent always check this, we use wcid == RESERVED_WCID to recognize it as newly joined adhoc station.
if ((ADHOC_ON(pAd) && (Elem->Wcid == RESERVED_WCID)) ||
(pEntry && ((pEntry->LastBeaconRxTime + ADHOC_ENTRY_BEACON_LOST_TIME) < Now)))
{
if (pEntry == NULL)
// Another adhoc joining, add to our MAC table.
pEntry = MacTableInsertEntry(pAd, Addr2, BSS0, FALSE);
if (StaAddMacTableEntry(pAd, pEntry, MaxSupportedRateIn500Kbps, &HtCapability, HtCapabilityLen, CapabilityInfo) == FALSE)
{
DBGPRINT(RT_DEBUG_TRACE, ("ADHOC - Add Entry failed.\n"));
return;
}
if (pEntry &&
(Elem->Wcid == RESERVED_WCID))
{
idx = pAd->StaCfg.DefaultKeyId;
RT28XX_STA_SECURITY_INFO_ADD(pAd, BSS0, idx, pEntry);
}
}
if (pEntry && pEntry->ValidAsCLI)
pEntry->LastBeaconRxTime = Now;
// At least another peer in this IBSS, declare MediaState as CONNECTED
if (!OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED))
{
OPSTATUS_SET_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED);
pAd->IndicateMediaState = NdisMediaStateConnected;
RTMP_IndicateMediaState(pAd);
pAd->ExtraInfo = GENERAL_LINK_UP;
AsicSetBssid(pAd, pAd->CommonCfg.Bssid);
// 2003/03/12 - john
// Make sure this entry in "ScanTab" table, thus complies to Microsoft's policy that
// "site survey" result should always include the current connected network.
//
Bssidx = BssTableSearch(&pAd->ScanTab, Bssid, Channel);
if (Bssidx == BSS_NOT_FOUND)
{
Bssidx = BssTableSetEntry(pAd, &pAd->ScanTab, Bssid, Ssid, SsidLen, BssType, BeaconPeriod,
&CfParm, AtimWin, CapabilityInfo, SupRate, SupRateLen, ExtRate, ExtRateLen, &HtCapability,
&AddHtInfo, HtCapabilityLen, AddHtInfoLen, NewExtChannelOffset, Channel, RealRssi, TimeStamp, 0,
&EdcaParm, &QosCapability, &QbssLoad, LenVIE, pVIE);
}
DBGPRINT(RT_DEBUG_TRACE, ("ADHOC fOP_STATUS_MEDIA_STATE_CONNECTED.\n"));
}
#endif /* RT2870 */
}
if (INFRA_ON(pAd))
......@@ -1447,10 +1536,12 @@ VOID PeerBeacon(
// 5. otherwise, put PHY back to sleep to save battery.
if (MessageToMe)
{
#ifdef RT2860
if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_ADVANCE_POWER_SAVE_PCIE_DEVICE))
{
RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R3, pAd->StaCfg.BBPR3);
}
#endif
if (pAd->CommonCfg.bAPSDCapable && pAd->CommonCfg.APEdcaParm.bAPSDCapable &&
pAd->CommonCfg.bAPSDAC_BE && pAd->CommonCfg.bAPSDAC_BK && pAd->CommonCfg.bAPSDAC_VI && pAd->CommonCfg.bAPSDAC_VO)
{
......@@ -1461,10 +1552,12 @@ VOID PeerBeacon(
}
else if (BcastFlag && (DtimCount == 0) && OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_RECEIVE_DTIM))
{
#ifdef RT2860
if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_ADVANCE_POWER_SAVE_PCIE_DEVICE))
{
RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R3, pAd->StaCfg.BBPR3);
}
#endif
}
else if ((pAd->TxSwQueue[QID_AC_BK].Number != 0) ||
(pAd->TxSwQueue[QID_AC_BE].Number != 0) ||
......@@ -1478,10 +1571,12 @@ VOID PeerBeacon(
{
// TODO: consider scheduled HCCA. might not be proper to use traditional DTIM-based power-saving scheme
// can we cheat here (i.e. just check MGMT & AC_BE) for better performance?
#ifdef RT2860
if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_ADVANCE_POWER_SAVE_PCIE_DEVICE))
{
RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R3, pAd->StaCfg.BBPR3);
}
#endif
}
else
{
......@@ -1496,9 +1591,14 @@ VOID PeerBeacon(
if (!OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_DOZE))
{
#ifdef RT2860
// Set a flag to go to sleep . Then after parse this RxDoneInterrupt, will go to sleep mode.
RTMP_SET_PSFLAG(pAd, fRTMP_PS_GO_TO_SLEEP_NOW);
pAd->ThisTbttNumToNextWakeUp = TbttNumToNextWakeUp;
#endif
#ifdef RT2870
AsicSleepThenAutoWakeup(pAd, TbttNumToNextWakeUp);
#endif
}
}
}
......
......@@ -1384,10 +1384,12 @@ VOID WpaGroupMsg1Action(
pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg = CIPHER_TKIP;
else if (pAd->StaCfg.GroupCipher == Ndis802_11Encryption3Enabled)
pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg = CIPHER_AES;
#ifndef RT30xx
else if (pAd->StaCfg.GroupCipher == Ndis802_11GroupWEP40Enabled)
pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg = CIPHER_WEP64;
else if (pAd->StaCfg.GroupCipher == Ndis802_11GroupWEP104Enabled)
pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg = CIPHER_WEP128;
#endif
//hex_dump("Group Key :", pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].Key, LEN_TKIP_EK);
}
......@@ -1764,7 +1766,12 @@ BOOLEAN ParseKeyData(
// Get GTK length - refer to IEEE 802.11i-2004 p.82
GTKLEN = pKDE->Len -6;
#ifdef RT30xx
if (GTKLEN < LEN_AES_KEY)
#endif
#ifndef RT30xx
if (GTKLEN < MIN_LEN_OF_GTK)
#endif
{
DBGPRINT(RT_DEBUG_ERROR, ("ERROR: GTK Key length is too short (%d) \n", GTKLEN));
return FALSE;
......@@ -1790,10 +1797,12 @@ BOOLEAN ParseKeyData(
pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg = CIPHER_TKIP;
else if (pAd->StaCfg.GroupCipher == Ndis802_11Encryption3Enabled)
pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg = CIPHER_AES;
#ifndef RT30xx
else if (pAd->StaCfg.GroupCipher == Ndis802_11GroupWEP40Enabled)
pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg = CIPHER_WEP64;
else if (pAd->StaCfg.GroupCipher == Ndis802_11GroupWEP104Enabled)
pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg = CIPHER_WEP128;
#endif
return TRUE;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment