summaryrefslogtreecommitdiff
path: root/drivers/staging/rt2860/common/spectrum.c
diff options
context:
space:
mode:
authorBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2009-09-22 20:44:07 +0200
committerGreg Kroah-Hartman <gregkh@suse.de>2009-12-11 12:21:44 -0800
commitca97b8388838ee9ea4b4bad04948f8f7f8a607a3 (patch)
tree2f45db84158e603cbde3871fb9f5137448ef6773 /drivers/staging/rt2860/common/spectrum.c
parent3441d25f03a078d493777f165194f8623ec2750f (diff)
Staging: rt28x0: updates from vendor's V2.1.0.0 drivers
Port changes from: * 2009_0420_RT2860_Linux_STA_V2.1.0.0 * 2009_0302_RT2870_Linux_STA_v2.1.0.0 * 2009_0525_RT3070_Linux_STA_v2.1.1.0 to in-kernel drivers. From the RT2860 driver release note: [2.1.0.0] 1. New generation schema for multiple OS porting 2. Fixed Ad-hoc ping failed in noisy environment. (Probe Response has too many retry packet then cause "not enough space in MgmtRing") 3. Fixed WPA(2)PSK issue when group cipher of AP is WEP40 or WEP104. 4. Modified iwpriv ra0 get_site_survey: In scan list result: Security shows "NONE" when AP is OPEN/NONE, shows "WEP" when AP is OPEN/WEP or SHARED/WEP, shows "WPAPSK(WPA2PSK)/TKIP(AES)" when AP is WPAPSK(WPA2PSK)/TKIP(AES) shows "WPA(WPA2)/TKIP(AES)" when AP is WPA(WPA2)/TKIP(AES) 5. Support kthread. 6. Add New A band channel list region 15 contains the whole channels in the A band region 4 and the new CE channel 167,169,171,173 7. Add New IEEE802.11r functionality. 8. Fixed WPA2-Enterprise failed when AP reboot or turn off then turn on. 9. Fixed STA cannot connect to 11B only AP when the setting of is PHY_11GN. From the RT2870 driver release note: [V2.1.0.0] 1. New generation schema for multiple OS porting. 2. Fixed Ad-hoc ping failed in noisy environment. (Probe Response has too many retry packet then cause "not enough space in MgmtRing"). 3. Fixed WPS failed with D-Link DIR-628 in 5GHz. 4. Change FastRoaming in DAT file to AutoRoaming. 5. Support kthread. 6. Add New A band channel list region 15 contains the whole channels in the A band region and the new CE channel 167,169,171,173. 7. New IEEE802.11r functionality. From the RT3070 driver release note: Version V2.1.1.0 1. Linux kernel 2.6.29 support. 2. Fix eFuse write from BIN file bug. Version 2.1.0.0 1. New generation schema for multiple OS porting 2. Fixed Ad-hoc ping failed in noisy environment. 3. Modified iwpriv ra0 get_site_survey: 4. Change FastRoaming in DAT file to AutoRoaming. 5. Support kthread. 6. New IEEE802.11r functionality. Tested with RT2860 and RT3070 chipsets. Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/staging/rt2860/common/spectrum.c')
-rw-r--r--drivers/staging/rt2860/common/spectrum.c460
1 files changed, 397 insertions, 63 deletions
diff --git a/drivers/staging/rt2860/common/spectrum.c b/drivers/staging/rt2860/common/spectrum.c
index c658bf3082c3..7fd715ad39b1 100644
--- a/drivers/staging/rt2860/common/spectrum.c
+++ b/drivers/staging/rt2860/common/spectrum.c
@@ -40,6 +40,239 @@
#include "../rt_config.h"
#include "action.h"
+
+/* The regulatory information in the USA (US) */
+DOT11_REGULATORY_INFORMATION USARegulatoryInfo[] =
+{
+/* "regulatory class" "number of channels" "Max Tx Pwr" "channel list" */
+ {0, {0, 0, {0}}}, // Invlid entry
+ {1, {4, 16, {36, 40, 44, 48}}},
+ {2, {4, 23, {52, 56, 60, 64}}},
+ {3, {4, 29, {149, 153, 157, 161}}},
+ {4, {11, 23, {100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140}}},
+ {5, {5, 30, {149, 153, 157, 161, 165}}},
+ {6, {10, 14, {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}}},
+ {7, {10, 27, {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}}},
+ {8, {5, 17, {11, 13, 15, 17, 19}}},
+ {9, {5, 30, {11, 13, 15, 17, 19}}},
+ {10, {2, 20, {21, 25}}},
+ {11, {2, 33, {21, 25}}},
+ {12, {11, 30, {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}}}
+};
+#define USA_REGULATORY_INFO_SIZE (sizeof(USARegulatoryInfo) / sizeof(DOT11_REGULATORY_INFORMATION))
+
+
+/* The regulatory information in Europe */
+DOT11_REGULATORY_INFORMATION EuropeRegulatoryInfo[] =
+{
+/* "regulatory class" "number of channels" "Max Tx Pwr" "channel list" */
+ {0, {0, 0, {0}}}, // Invalid entry
+ {1, {4, 20, {36, 40, 44, 48}}},
+ {2, {4, 20, {52, 56, 60, 64}}},
+ {3, {11, 30, {100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140}}},
+ {4, {13, 20, {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13}}}
+};
+#define EU_REGULATORY_INFO_SIZE (sizeof(EuropeRegulatoryInfo) / sizeof(DOT11_REGULATORY_INFORMATION))
+
+
+/* The regulatory information in Japan */
+DOT11_REGULATORY_INFORMATION JapanRegulatoryInfo[] =
+{
+/* "regulatory class" "number of channels" "Max Tx Pwr" "channel list" */
+ {0, {0, 0, {0}}}, // Invalid entry
+ {1, {4, 22, {34, 38, 42, 46}}},
+ {2, {3, 24, {8, 12, 16}}},
+ {3, {3, 24, {8, 12, 16}}},
+ {4, {3, 24, {8, 12, 16}}},
+ {5, {3, 24, {8, 12, 16}}},
+ {6, {3, 22, {8, 12, 16}}},
+ {7, {4, 24, {184, 188, 192, 196}}},
+ {8, {4, 24, {184, 188, 192, 196}}},
+ {9, {4, 24, {184, 188, 192, 196}}},
+ {10, {4, 24, {184, 188, 192, 196}}},
+ {11, {4, 22, {184, 188, 192, 196}}},
+ {12, {4, 24, {7, 8, 9, 11}}},
+ {13, {4, 24, {7, 8, 9, 11}}},
+ {14, {4, 24, {7, 8, 9, 11}}},
+ {15, {4, 24, {7, 8, 9, 11}}},
+ {16, {6, 24, {183, 184, 185, 187, 188, 189}}},
+ {17, {6, 24, {183, 184, 185, 187, 188, 189}}},
+ {18, {6, 24, {183, 184, 185, 187, 188, 189}}},
+ {19, {6, 24, {183, 184, 185, 187, 188, 189}}},
+ {20, {6, 17, {183, 184, 185, 187, 188, 189}}},
+ {21, {6, 24, {6, 7, 8, 9, 10, 11}}},
+ {22, {6, 24, {6, 7, 8, 9, 10, 11}}},
+ {23, {6, 24, {6, 7, 8, 9, 10, 11}}},
+ {24, {6, 24, {6, 7, 8, 9, 10, 11}}},
+ {25, {8, 24, {182, 183, 184, 185, 186, 187, 188, 189}}},
+ {26, {8, 24, {182, 183, 184, 185, 186, 187, 188, 189}}},
+ {27, {8, 24, {182, 183, 184, 185, 186, 187, 188, 189}}},
+ {28, {8, 24, {182, 183, 184, 185, 186, 187, 188, 189}}},
+ {29, {8, 17, {182, 183, 184, 185, 186, 187, 188, 189}}},
+ {30, {13, 23, {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13}}},
+ {31, {1, 23, {14}}},
+ {32, {4, 22, {52, 56, 60, 64}}}
+};
+#define JP_REGULATORY_INFO_SIZE (sizeof(JapanRegulatoryInfo) / sizeof(DOT11_REGULATORY_INFORMATION))
+
+
+CHAR RTMP_GetTxPwr(
+ IN PRTMP_ADAPTER pAd,
+ IN HTTRANSMIT_SETTING HTTxMode)
+{
+typedef struct __TX_PWR_CFG
+{
+ UINT8 Mode;
+ UINT8 MCS;
+ UINT16 req;
+ UINT8 shift;
+ UINT32 BitMask;
+} TX_PWR_CFG;
+
+ UINT32 Value;
+ INT Idx;
+ UINT8 PhyMode;
+ CHAR CurTxPwr;
+ UINT8 TxPwrRef = 0;
+ CHAR DaltaPwr;
+ ULONG TxPwr[5];
+
+
+ TX_PWR_CFG TxPwrCfg[] = {
+ {MODE_CCK, 0, 0, 4, 0x000000f0},
+ {MODE_CCK, 1, 0, 0, 0x0000000f},
+ {MODE_CCK, 2, 0, 12, 0x0000f000},
+ {MODE_CCK, 3, 0, 8, 0x00000f00},
+
+ {MODE_OFDM, 0, 0, 20, 0x00f00000},
+ {MODE_OFDM, 1, 0, 16, 0x000f0000},
+ {MODE_OFDM, 2, 0, 28, 0xf0000000},
+ {MODE_OFDM, 3, 0, 24, 0x0f000000},
+ {MODE_OFDM, 4, 1, 4, 0x000000f0},
+ {MODE_OFDM, 5, 1, 0, 0x0000000f},
+ {MODE_OFDM, 6, 1, 12, 0x0000f000},
+ {MODE_OFDM, 7, 1, 8, 0x00000f00}
+ ,{MODE_HTMIX, 0, 1, 20, 0x00f00000},
+ {MODE_HTMIX, 1, 1, 16, 0x000f0000},
+ {MODE_HTMIX, 2, 1, 28, 0xf0000000},
+ {MODE_HTMIX, 3, 1, 24, 0x0f000000},
+ {MODE_HTMIX, 4, 2, 4, 0x000000f0},
+ {MODE_HTMIX, 5, 2, 0, 0x0000000f},
+ {MODE_HTMIX, 6, 2, 12, 0x0000f000},
+ {MODE_HTMIX, 7, 2, 8, 0x00000f00},
+ {MODE_HTMIX, 8, 2, 20, 0x00f00000},
+ {MODE_HTMIX, 9, 2, 16, 0x000f0000},
+ {MODE_HTMIX, 10, 2, 28, 0xf0000000},
+ {MODE_HTMIX, 11, 2, 24, 0x0f000000},
+ {MODE_HTMIX, 12, 3, 4, 0x000000f0},
+ {MODE_HTMIX, 13, 3, 0, 0x0000000f},
+ {MODE_HTMIX, 14, 3, 12, 0x0000f000},
+ {MODE_HTMIX, 15, 3, 8, 0x00000f00}
+ };
+#define MAX_TXPWR_TAB_SIZE (sizeof(TxPwrCfg) / sizeof(TX_PWR_CFG))
+
+ CurTxPwr = 19;
+
+ /* check Tx Power setting from UI. */
+ if (pAd->CommonCfg.TxPowerPercentage > 90)
+ ;
+ else if (pAd->CommonCfg.TxPowerPercentage > 60) /* reduce Pwr for 1 dB. */
+ CurTxPwr -= 1;
+ else if (pAd->CommonCfg.TxPowerPercentage > 30) /* reduce Pwr for 3 dB. */
+ CurTxPwr -= 3;
+ else if (pAd->CommonCfg.TxPowerPercentage > 15) /* reduce Pwr for 6 dB. */
+ CurTxPwr -= 6;
+ else if (pAd->CommonCfg.TxPowerPercentage > 9) /* reduce Pwr for 9 dB. */
+ CurTxPwr -= 9;
+ else /* reduce Pwr for 12 dB. */
+ CurTxPwr -= 12;
+
+ if (pAd->CommonCfg.BBPCurrentBW == BW_40)
+ {
+ if (pAd->CommonCfg.CentralChannel > 14)
+ {
+ 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
+ {
+ if (pAd->CommonCfg.Channel > 14)
+ {
+ TxPwr[0] = pAd->Tx20MPwrCfgABand[0];
+ TxPwr[1] = pAd->Tx20MPwrCfgABand[1];
+ TxPwr[2] = pAd->Tx20MPwrCfgABand[2];
+ TxPwr[3] = pAd->Tx20MPwrCfgABand[3];
+ TxPwr[4] = pAd->Tx20MPwrCfgABand[4];
+ }
+ else
+ {
+ TxPwr[0] = pAd->Tx20MPwrCfgGBand[0];
+ TxPwr[1] = pAd->Tx20MPwrCfgGBand[1];
+ TxPwr[2] = pAd->Tx20MPwrCfgGBand[2];
+ TxPwr[3] = pAd->Tx20MPwrCfgGBand[3];
+ TxPwr[4] = pAd->Tx20MPwrCfgGBand[4];
+ }
+ }
+
+
+ switch(HTTxMode.field.MODE)
+ {
+ case MODE_CCK:
+ case MODE_OFDM:
+ Value = TxPwr[1];
+ TxPwrRef = (Value & 0x00000f00) >> 8;
+
+ break;
+
+ case MODE_HTMIX:
+ case MODE_HTGREENFIELD:
+ if (pAd->CommonCfg.TxStream == 1)
+ {
+ Value = TxPwr[2];
+ TxPwrRef = (Value & 0x00000f00) >> 8;
+ }
+ else if (pAd->CommonCfg.TxStream == 2)
+ {
+ Value = TxPwr[3];
+ TxPwrRef = (Value & 0x00000f00) >> 8;
+ }
+ break;
+ }
+
+ PhyMode =
+ (HTTxMode.field.MODE == MODE_HTGREENFIELD)
+ ? MODE_HTMIX :
+ HTTxMode.field.MODE;
+
+ for (Idx = 0; Idx < MAX_TXPWR_TAB_SIZE; Idx++)
+ {
+ if ((TxPwrCfg[Idx].Mode == PhyMode)
+ && (TxPwrCfg[Idx].MCS == HTTxMode.field.MCS))
+ {
+ Value = TxPwr[TxPwrCfg[Idx].req];
+ DaltaPwr = TxPwrRef - (CHAR)((Value & TxPwrCfg[Idx].BitMask)
+ >> TxPwrCfg[Idx].shift);
+ CurTxPwr -= DaltaPwr;
+ break;
+ }
+ }
+
+ return CurTxPwr;
+}
+
+
VOID MeasureReqTabInit(
IN PRTMP_ADAPTER pAd)
{
@@ -57,7 +290,7 @@ VOID MeasureReqTabInit(
VOID MeasureReqTabExit(
IN PRTMP_ADAPTER pAd)
{
- NdisFreeSpinLock(pAd->CommonCfg.MeasureReqTabLock);
+ NdisFreeSpinLock(&pAd->CommonCfg.MeasureReqTabLock);
if (pAd->CommonCfg.pMeasureReqTab)
kfree(pAd->CommonCfg.pMeasureReqTab);
@@ -66,7 +299,7 @@ VOID MeasureReqTabExit(
return;
}
-static PMEASURE_REQ_ENTRY MeasureReqLookUp(
+PMEASURE_REQ_ENTRY MeasureReqLookUp(
IN PRTMP_ADAPTER pAd,
IN UINT8 DialogToken)
{
@@ -102,7 +335,7 @@ static PMEASURE_REQ_ENTRY MeasureReqLookUp(
return pEntry;
}
-static PMEASURE_REQ_ENTRY MeasureReqInsert(
+PMEASURE_REQ_ENTRY MeasureReqInsert(
IN PRTMP_ADAPTER pAd,
IN UINT8 DialogToken)
{
@@ -201,7 +434,7 @@ static PMEASURE_REQ_ENTRY MeasureReqInsert(
return pEntry;
}
-static VOID MeasureReqDelete(
+VOID MeasureReqDelete(
IN PRTMP_ADAPTER pAd,
IN UINT8 DialogToken)
{
@@ -275,7 +508,7 @@ VOID TpcReqTabInit(
VOID TpcReqTabExit(
IN PRTMP_ADAPTER pAd)
{
- NdisFreeSpinLock(pAd->CommonCfg.TpcReqTabLock);
+ NdisFreeSpinLock(&pAd->CommonCfg.TpcReqTabLock);
if (pAd->CommonCfg.pTpcReqTab)
kfree(pAd->CommonCfg.pTpcReqTab);
@@ -514,6 +747,72 @@ static UINT8 GetCurTxPwr(
/*
==========================================================================
Description:
+ Get Current Transmit Power.
+
+ Parametrs:
+
+ Return : Current Time Stamp.
+ ==========================================================================
+ */
+VOID InsertChannelRepIE(
+ IN PRTMP_ADAPTER pAd,
+ OUT PUCHAR pFrameBuf,
+ OUT PULONG pFrameLen,
+ IN PSTRING pCountry,
+ IN UINT8 RegulatoryClass)
+{
+ ULONG TempLen;
+ UINT8 Len;
+ UINT8 IEId = IE_AP_CHANNEL_REPORT;
+ PUCHAR pChListPtr = NULL;
+
+ Len = 1;
+ if (strncmp(pCountry, "US", 2) == 0)
+ {
+ if (RegulatoryClass >= USA_REGULATORY_INFO_SIZE)
+ {
+ DBGPRINT(RT_DEBUG_ERROR, ("%s: USA Unknow Requlatory class (%d)\n",
+ __func__, RegulatoryClass));
+ return;
+ }
+
+ Len += USARegulatoryInfo[RegulatoryClass].ChannelSet.NumberOfChannels;
+ pChListPtr = USARegulatoryInfo[RegulatoryClass].ChannelSet.ChannelList;
+ }
+ else if (strncmp(pCountry, "JP", 2) == 0)
+ {
+ if (RegulatoryClass >= JP_REGULATORY_INFO_SIZE)
+ {
+ DBGPRINT(RT_DEBUG_ERROR, ("%s: JP Unknow Requlatory class (%d)\n",
+ __func__, RegulatoryClass));
+ return;
+ }
+
+ Len += JapanRegulatoryInfo[RegulatoryClass].ChannelSet.NumberOfChannels;
+ pChListPtr = JapanRegulatoryInfo[RegulatoryClass].ChannelSet.ChannelList;
+ }
+ else
+ {
+ DBGPRINT(RT_DEBUG_ERROR, ("%s: Unknow Country (%s)\n",
+ __func__, pCountry));
+ return;
+ }
+
+ MakeOutgoingFrame(pFrameBuf, &TempLen,
+ 1, &IEId,
+ 1, &Len,
+ 1, &RegulatoryClass,
+ Len -1, pChListPtr,
+ END_OF_ARGS);
+
+ *pFrameLen = *pFrameLen + TempLen;
+
+ return;
+}
+
+/*
+ ==========================================================================
+ Description:
Insert Dialog Token into frame.
Parametrs:
@@ -524,7 +823,7 @@ static UINT8 GetCurTxPwr(
Return : None.
==========================================================================
*/
-static VOID InsertDialogToken(
+VOID InsertDialogToken(
IN PRTMP_ADAPTER pAd,
OUT PUCHAR pFrameBuf,
OUT PULONG pFrameLen,
@@ -585,7 +884,7 @@ static VOID InsertDialogToken(
Return : None.
==========================================================================
*/
- static VOID InsertTpcReportIE(
+VOID InsertTpcReportIE(
IN PRTMP_ADAPTER pAd,
OUT PUCHAR pFrameBuf,
OUT PULONG pFrameLen,
@@ -679,16 +978,16 @@ static VOID InsertMeasureReqIE(
IN PRTMP_ADAPTER pAd,
OUT PUCHAR pFrameBuf,
OUT PULONG pFrameLen,
+ IN UINT8 Len,
IN PMEASURE_REQ_INFO pMeasureReqIE)
{
ULONG TempLen;
- UINT8 Len = sizeof(MEASURE_REQ_INFO);
UINT8 ElementID = IE_MEASUREMENT_REQUEST;
MakeOutgoingFrame(pFrameBuf, &TempLen,
1, &ElementID,
1, &Len,
- Len, pMeasureReqIE,
+ sizeof(MEASURE_REQ_INFO), pMeasureReqIE,
END_OF_ARGS);
*pFrameLen = *pFrameLen + TempLen;
@@ -758,53 +1057,43 @@ static VOID InsertMeasureReportIE(
Return : None.
==========================================================================
*/
-VOID EnqueueMeasurementReq(
+VOID MakeMeasurementReqFrame(
IN PRTMP_ADAPTER pAd,
- IN PUCHAR pDA,
+ OUT PUCHAR pOutBuffer,
+ OUT PULONG pFrameLen,
+ IN UINT8 TotalLen,
+ IN UINT8 Category,
+ IN UINT8 Action,
IN UINT8 MeasureToken,
IN UINT8 MeasureReqMode,
IN UINT8 MeasureReqType,
- IN UINT8 MeasureCh,
- IN UINT16 MeasureDuration)
+ IN UINT8 NumOfRepetitions)
{
- PUCHAR pOutBuffer = NULL;
- NDIS_STATUS NStatus;
- ULONG FrameLen;
- HEADER_802_11 ActHdr;
+ ULONG TempLen;
MEASURE_REQ_INFO MeasureReqIE;
- UINT8 RmReqDailogToken = RandomByte(pAd);
- UINT64 MeasureStartTime = GetCurrentTimeStamp(pAd);
- // build action frame header.
- MgtMacHeaderInit(pAd, &ActHdr, SUBTYPE_ACTION, 0, pDA,
- pAd->CurrentAddress);
+ InsertActField(pAd, (pOutBuffer + *pFrameLen), pFrameLen, Category, Action);
- NStatus = MlmeAllocateMemory(pAd, (PVOID)&pOutBuffer); //Get an unused nonpaged memory
- if(NStatus != NDIS_STATUS_SUCCESS)
- {
- DBGPRINT(RT_DEBUG_TRACE, ("%s() allocate memory failed \n", __func__));
- return;
- }
- NdisMoveMemory(pOutBuffer, (PCHAR)&ActHdr, sizeof(HEADER_802_11));
- FrameLen = sizeof(HEADER_802_11);
+ // fill Dialog Token
+ InsertDialogToken(pAd, (pOutBuffer + *pFrameLen), pFrameLen, MeasureToken);
- InsertActField(pAd, (pOutBuffer + FrameLen), &FrameLen, CATEGORY_SPECTRUM, SPEC_MRQ);
+ /* fill Number of repetitions. */
+ if (Category == CATEGORY_RM)
+ {
+ MakeOutgoingFrame((pOutBuffer+*pFrameLen), &TempLen,
+ 2, &NumOfRepetitions,
+ END_OF_ARGS);
- // fill Dialog Token
- InsertDialogToken(pAd, (pOutBuffer + FrameLen), &FrameLen, MeasureToken);
+ *pFrameLen += TempLen;
+ }
// prepare Measurement IE.
NdisZeroMemory(&MeasureReqIE, sizeof(MEASURE_REQ_INFO));
- MeasureReqIE.Token = RmReqDailogToken;
+ MeasureReqIE.Token = MeasureToken;
MeasureReqIE.ReqMode.word = MeasureReqMode;
MeasureReqIE.ReqType = MeasureReqType;
- MeasureReqIE.MeasureReq.ChNum = MeasureCh;
- MeasureReqIE.MeasureReq.MeasureStartTime = cpu2le64(MeasureStartTime);
- MeasureReqIE.MeasureReq.MeasureDuration = cpu2le16(MeasureDuration);
- InsertMeasureReqIE(pAd, (pOutBuffer + FrameLen), &FrameLen, &MeasureReqIE);
-
- MiniportMMRequest(pAd, QID_AC_BE, pOutBuffer, FrameLen);
- MlmeFreeMemory(pAd, pOutBuffer);
+ InsertMeasureReqIE(pAd, (pOutBuffer+*pFrameLen), pFrameLen,
+ TotalLen, &MeasureReqIE);
return;
}
@@ -858,7 +1147,7 @@ VOID EnqueueMeasurementRep(
// prepare Measurement IE.
NdisZeroMemory(&MeasureRepIE, sizeof(MEASURE_REPORT_INFO));
MeasureRepIE.Token = MeasureToken;
- MeasureRepIE.ReportMode.word = MeasureReqMode;
+ MeasureRepIE.ReportMode = MeasureReqMode;
MeasureRepIE.ReportType = MeasureReqType;
InsertMeasureReportIE(pAd, (pOutBuffer + FrameLen), &FrameLen, &MeasureRepIE, ReportInfoLen, pReportInfo);
@@ -1159,7 +1448,8 @@ static BOOLEAN PeerMeasureReqSanity(
IN VOID *pMsg,
IN ULONG MsgLen,
OUT PUINT8 pDialogToken,
- OUT PMEASURE_REQ_INFO pMeasureReqInfo)
+ OUT PMEASURE_REQ_INFO pMeasureReqInfo,
+ OUT PMEASURE_REQ pMeasureReq)
{
PFRAME_802_11 Fr = (PFRAME_802_11)pMsg;
PUCHAR pFramePtr = Fr->Octet;
@@ -1192,12 +1482,12 @@ static BOOLEAN PeerMeasureReqSanity(
NdisMoveMemory(&pMeasureReqInfo->Token, eid_ptr->Octet, 1);
NdisMoveMemory(&pMeasureReqInfo->ReqMode.word, eid_ptr->Octet + 1, 1);
NdisMoveMemory(&pMeasureReqInfo->ReqType, eid_ptr->Octet + 2, 1);
- ptr = eid_ptr->Octet + 3;
- NdisMoveMemory(&pMeasureReqInfo->MeasureReq.ChNum, ptr, 1);
+ ptr = (PUCHAR)(eid_ptr->Octet + 3);
+ NdisMoveMemory(&pMeasureReq->ChNum, ptr, 1);
NdisMoveMemory(&MeasureStartTime, ptr + 1, 8);
- pMeasureReqInfo->MeasureReq.MeasureStartTime = SWAP64(MeasureStartTime);
+ pMeasureReq->MeasureStartTime = SWAP64(MeasureStartTime);
NdisMoveMemory(&MeasureDuration, ptr + 9, 2);
- pMeasureReqInfo->MeasureReq.MeasureDuration = SWAP16(MeasureDuration);
+ pMeasureReq->MeasureDuration = SWAP16(MeasureDuration);
result = TRUE;
break;
@@ -1285,7 +1575,7 @@ static BOOLEAN PeerMeasureReportSanity(
if (pMeasureReportInfo->ReportType == RM_BASIC)
{
PMEASURE_BASIC_REPORT pReport = (PMEASURE_BASIC_REPORT)pReportBuf;
- ptr = eid_ptr->Octet + 3;
+ ptr = (PUCHAR)(eid_ptr->Octet + 3);
NdisMoveMemory(&pReport->ChNum, ptr, 1);
NdisMoveMemory(&pReport->MeasureStartTime, ptr + 1, 8);
NdisMoveMemory(&pReport->MeasureDuration, ptr + 9, 2);
@@ -1295,7 +1585,7 @@ static BOOLEAN PeerMeasureReportSanity(
else if (pMeasureReportInfo->ReportType == RM_CCA)
{
PMEASURE_CCA_REPORT pReport = (PMEASURE_CCA_REPORT)pReportBuf;
- ptr = eid_ptr->Octet + 3;
+ ptr = (PUCHAR)(eid_ptr->Octet + 3);
NdisMoveMemory(&pReport->ChNum, ptr, 1);
NdisMoveMemory(&pReport->MeasureStartTime, ptr + 1, 8);
NdisMoveMemory(&pReport->MeasureDuration, ptr + 9, 2);
@@ -1305,7 +1595,7 @@ static BOOLEAN PeerMeasureReportSanity(
else if (pMeasureReportInfo->ReportType == RM_RPI_HISTOGRAM)
{
PMEASURE_RPI_REPORT pReport = (PMEASURE_RPI_REPORT)pReportBuf;
- ptr = eid_ptr->Octet + 3;
+ ptr = (PUCHAR)(eid_ptr->Octet + 3);
NdisMoveMemory(&pReport->ChNum, ptr, 1);
NdisMoveMemory(&pReport->MeasureStartTime, ptr + 1, 8);
NdisMoveMemory(&pReport->MeasureDuration, ptr + 9, 2);
@@ -1533,9 +1823,10 @@ static VOID PeerMeasureReqAction(
PFRAME_802_11 pFr = (PFRAME_802_11)Elem->Msg;
UINT8 DialogToken;
MEASURE_REQ_INFO MeasureReqInfo;
+ MEASURE_REQ MeasureReq;
MEASURE_REPORT_MODE ReportMode;
- if(PeerMeasureReqSanity(pAd, Elem->Msg, Elem->MsgLen, &DialogToken, &MeasureReqInfo))
+ if(PeerMeasureReqSanity(pAd, Elem->Msg, Elem->MsgLen, &DialogToken, &MeasureReqInfo, &MeasureReq))
{
ReportMode.word = 0;
ReportMode.field.Incapable = 1;
@@ -1729,8 +2020,8 @@ VOID PeerSpectrumAction(
break;
case SPEC_CHANNEL_SWITCH:
-{
-}
+
+
PeerChSwAnnAction(pAd, Elem);
break;
}
@@ -1749,16 +2040,31 @@ VOID PeerSpectrumAction(
*/
INT Set_MeasureReq_Proc(
IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
+ IN PSTRING arg)
{
UINT Aid = 1;
UINT ArgIdx;
- PUCHAR thisChar;
+ PSTRING thisChar;
MEASURE_REQ_MODE MeasureReqMode;
UINT8 MeasureReqToken = RandomByte(pAd);
UINT8 MeasureReqType = RM_BASIC;
UINT8 MeasureCh = 1;
+ UINT64 MeasureStartTime = GetCurrentTimeStamp(pAd);
+ MEASURE_REQ MeasureReq;
+ UINT8 TotalLen;
+
+ HEADER_802_11 ActHdr;
+ PUCHAR pOutBuffer = NULL;
+ NDIS_STATUS NStatus;
+ ULONG FrameLen;
+
+ NStatus = MlmeAllocateMemory(pAd, (PVOID)&pOutBuffer); //Get an unused nonpaged memory
+ if(NStatus != NDIS_STATUS_SUCCESS)
+ {
+ DBGPRINT(RT_DEBUG_TRACE, ("%s() allocate memory failed \n", __func__));
+ goto END_OF_MEASURE_REQ;
+ }
ArgIdx = 1;
while ((thisChar = strsep((char **)&arg, "-")) != NULL)
@@ -1766,7 +2072,7 @@ INT Set_MeasureReq_Proc(
switch(ArgIdx)
{
case 1: // Aid.
- Aid = simple_strtol(thisChar, 0, 16);
+ Aid = (UINT8) simple_strtol(thisChar, 0, 16);
break;
case 2: // Measurement Request Type.
@@ -1774,12 +2080,12 @@ INT Set_MeasureReq_Proc(
if (MeasureReqType > 3)
{
DBGPRINT(RT_DEBUG_ERROR, ("%s: unknow MeasureReqType(%d)\n", __func__, MeasureReqType));
- return TRUE;
+ goto END_OF_MEASURE_REQ;
}
break;
case 3: // Measurement channel.
- MeasureCh = simple_strtol(thisChar, 0, 16);
+ MeasureCh = (UINT8) simple_strtol(thisChar, 0, 16);
break;
}
ArgIdx++;
@@ -1789,7 +2095,7 @@ INT Set_MeasureReq_Proc(
if (!VALID_WCID(Aid))
{
DBGPRINT(RT_DEBUG_ERROR, ("%s: unknow sta of Aid(%d)\n", __func__, Aid));
- return TRUE;
+ goto END_OF_MEASURE_REQ;
}
MeasureReqMode.word = 0;
@@ -1797,21 +2103,49 @@ INT Set_MeasureReq_Proc(
MeasureReqInsert(pAd, MeasureReqToken);
- EnqueueMeasurementReq(pAd, pAd->MacTab.Content[Aid].Addr,
- MeasureReqToken, MeasureReqMode.word, MeasureReqType, MeasureCh, 2000);
+ // build action frame header.
+ MgtMacHeaderInit(pAd, &ActHdr, SUBTYPE_ACTION, 0, pAd->MacTab.Content[Aid].Addr,
+ pAd->CurrentAddress);
+
+ NdisMoveMemory(pOutBuffer, (PCHAR)&ActHdr, sizeof(HEADER_802_11));
+ FrameLen = sizeof(HEADER_802_11);
+
+ TotalLen = sizeof(MEASURE_REQ_INFO) + sizeof(MEASURE_REQ);
+
+ MakeMeasurementReqFrame(pAd, pOutBuffer, &FrameLen,
+ sizeof(MEASURE_REQ_INFO), CATEGORY_RM, RM_BASIC,
+ MeasureReqToken, MeasureReqMode.word,
+ MeasureReqType, 0);
+
+ MeasureReq.ChNum = MeasureCh;
+ MeasureReq.MeasureStartTime = cpu2le64(MeasureStartTime);
+ MeasureReq.MeasureDuration = cpu2le16(2000);
+
+ {
+ ULONG TempLen;
+ MakeOutgoingFrame( pOutBuffer+FrameLen, &TempLen,
+ sizeof(MEASURE_REQ), &MeasureReq,
+ END_OF_ARGS);
+ FrameLen += TempLen;
+ }
+
+ MiniportMMRequest(pAd, QID_AC_BE, pOutBuffer, (UINT)FrameLen);
+
+END_OF_MEASURE_REQ:
+ MlmeFreeMemory(pAd, pOutBuffer);
return TRUE;
}
INT Set_TpcReq_Proc(
IN PRTMP_ADAPTER pAd,
- IN PUCHAR arg)
+ IN PSTRING arg)
{
UINT Aid;
UINT8 TpcReqToken = RandomByte(pAd);
- Aid = simple_strtol(arg, 0, 16);
+ Aid = (UINT) simple_strtol(arg, 0, 16);
DBGPRINT(RT_DEBUG_TRACE, ("%s::Aid = %d\n", __func__, Aid));
if (!VALID_WCID(Aid))