aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2009-04-26 10:06:27 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2009-06-19 14:00:50 -0400
commit3fb468abc878cb8967d063c0d10094569c987d68 (patch)
treeaeabc288b2e45f2768dc61a3ad23a1c1a71a88aa /drivers
parent3a32ed12b69113094f0921dad50f112626cde44d (diff)
Staging: rt28[67]0: merge rt28[67]0/*.[ch]
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/staging/rt2870/aironet.h211
-rw-r--r--drivers/staging/rt2870/ap.h532
-rw-r--r--drivers/staging/rt2870/chlist.h1251
-rw-r--r--drivers/staging/rt2870/dfs.h101
-rw-r--r--drivers/staging/rt2870/link_list.h135
-rw-r--r--drivers/staging/rt2870/md5.h108
-rw-r--r--drivers/staging/rt2870/mlme.h1139
-rw-r--r--drivers/staging/rt2870/oid.h953
-rw-r--r--drivers/staging/rt2870/rt28xx.h1668
-rw-r--r--drivers/staging/rt2870/rt_config.h76
-rw-r--r--drivers/staging/rt2870/rt_linux.c1011
-rw-r--r--drivers/staging/rt2870/rt_linux.h847
-rw-r--r--drivers/staging/rt2870/rt_main_dev.c1041
-rw-r--r--drivers/staging/rt2870/rt_profile.c1894
-rw-r--r--drivers/staging/rt2870/rtmp.h6701
-rw-r--r--drivers/staging/rt2870/rtmp_ckipmic.h114
-rw-r--r--drivers/staging/rt2870/rtmp_def.h1444
-rw-r--r--drivers/staging/rt2870/rtmp_type.h95
-rw-r--r--drivers/staging/rt2870/spectrum.h293
-rw-r--r--drivers/staging/rt2870/spectrum_def.h96
-rw-r--r--drivers/staging/rt2870/sta_ioctl.c6862
-rw-r--r--drivers/staging/rt2870/wpa.h331
22 files changed, 22 insertions, 26881 deletions
diff --git a/drivers/staging/rt2870/aironet.h b/drivers/staging/rt2870/aironet.h
index 1e07b19b8cdc..ae6259710a4f 100644
--- a/drivers/staging/rt2870/aironet.h
+++ b/drivers/staging/rt2870/aironet.h
@@ -1,210 +1 @@
1/* #include "../rt2860/aironet.h"
2 *************************************************************************
3 * Ralink Tech Inc.
4 * 5F., No.36, Taiyuan St., Jhubei City,
5 * Hsinchu County 302,
6 * Taiwan, R.O.C.
7 *
8 * (c) Copyright 2002-2007, Ralink Technology, Inc.
9 *
10 * This program is free software; you can redistribute it and/or modify *
11 * it under the terms of the GNU General Public License as published by *
12 * the Free Software Foundation; either version 2 of the License, or *
13 * (at your option) any later version. *
14 * *
15 * This program is distributed in the hope that it will be useful, *
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
18 * GNU General Public License for more details. *
19 * *
20 * You should have received a copy of the GNU General Public License *
21 * along with this program; if not, write to the *
22 * Free Software Foundation, Inc., *
23 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
24 * *
25 *************************************************************************
26
27 Module Name:
28 aironet.h
29
30 Abstract:
31
32 Revision History:
33 Who When What
34 -------- ---------- ----------------------------------------------
35 Name Date Modification logs
36 Paul Lin 04-06-15 Initial
37*/
38
39#ifndef __AIRONET_H__
40#define __AIRONET_H__
41
42// Measurement Type definition
43#define MSRN_TYPE_UNUSED 0
44#define MSRN_TYPE_CHANNEL_LOAD_REQ 1
45#define MSRN_TYPE_NOISE_HIST_REQ 2
46#define MSRN_TYPE_BEACON_REQ 3
47#define MSRN_TYPE_FRAME_REQ 4
48
49// Scan Mode in Beacon Request
50#define MSRN_SCAN_MODE_PASSIVE 0
51#define MSRN_SCAN_MODE_ACTIVE 1
52#define MSRN_SCAN_MODE_BEACON_TABLE 2
53
54// PHY type definition for Aironet beacon report, CCX 2 table 36-9
55#define PHY_FH 1
56#define PHY_DSS 2
57#define PHY_UNUSED 3
58#define PHY_OFDM 4
59#define PHY_HR_DSS 5
60#define PHY_ERP 6
61
62// RPI table in dBm
63#define RPI_0 0 // Power <= -87
64#define RPI_1 1 // -87 < Power <= -82
65#define RPI_2 2 // -82 < Power <= -77
66#define RPI_3 3 // -77 < Power <= -72
67#define RPI_4 4 // -72 < Power <= -67
68#define RPI_5 5 // -67 < Power <= -62
69#define RPI_6 6 // -62 < Power <= -57
70#define RPI_7 7 // -57 < Power
71
72// Cisco Aironet IAPP definetions
73#define AIRONET_IAPP_TYPE 0x32
74#define AIRONET_IAPP_SUBTYPE_REQUEST 0x01
75#define AIRONET_IAPP_SUBTYPE_REPORT 0x81
76
77// Measurement Request detail format
78typedef struct _MEASUREMENT_REQUEST {
79 UCHAR Channel;
80 UCHAR ScanMode; // Use only in beacon request, other requests did not use this field
81 USHORT Duration;
82} MEASUREMENT_REQUEST, *PMEASUREMENT_REQUEST;
83
84// Beacon Measurement Report
85// All these field might change to UCHAR, because we didn't do anything to these report.
86// We copy all these beacons and report to CCX 2 AP.
87typedef struct _BEACON_REPORT {
88 UCHAR Channel;
89 UCHAR Spare;
90 USHORT Duration;
91 UCHAR PhyType; // Definiation is listed above table 36-9
92 UCHAR RxPower;
93 UCHAR BSSID[6];
94 UCHAR ParentTSF[4];
95 UCHAR TargetTSF[8];
96 USHORT BeaconInterval;
97 USHORT CapabilityInfo;
98} BEACON_REPORT, *PBEACON_REPORT;
99
100// Frame Measurement Report (Optional)
101typedef struct _FRAME_REPORT {
102 UCHAR Channel;
103 UCHAR Spare;
104 USHORT Duration;
105 UCHAR TA;
106 UCHAR BSSID[6];
107 UCHAR RSSI;
108 UCHAR Count;
109} FRAME_REPORT, *PFRAME_REPORT;
110
111#pragma pack(1)
112// Channel Load Report
113typedef struct _CHANNEL_LOAD_REPORT {
114 UCHAR Channel;
115 UCHAR Spare;
116 USHORT Duration;
117 UCHAR CCABusy;
118} CHANNEL_LOAD_REPORT, *PCHANNEL_LOAD_REPORT;
119#pragma pack()
120
121// Nosie Histogram Report
122typedef struct _NOISE_HIST_REPORT {
123 UCHAR Channel;
124 UCHAR Spare;
125 USHORT Duration;
126 UCHAR Density[8];
127} NOISE_HIST_REPORT, *PNOISE_HIST_REPORT;
128
129// Radio Management Capability element
130typedef struct _RADIO_MANAGEMENT_CAPABILITY {
131 UCHAR Eid; // TODO: Why the Eid is 1 byte, not normal 2 bytes???
132 UCHAR Length;
133 UCHAR AironetOui[3]; // AIronet OUI (00 40 96)
134 UCHAR Type; // Type / Version
135 USHORT Status; // swap16 required
136} RADIO_MANAGEMENT_CAPABILITY, *PRADIO_MANAGEMENT_CAPABILITY;
137
138// Measurement Mode Bit definition
139typedef struct _MEASUREMENT_MODE {
140 UCHAR Rsvd:4;
141 UCHAR Report:1;
142 UCHAR NotUsed:1;
143 UCHAR Enable:1;
144 UCHAR Parallel:1;
145} MEASUREMENT_MODE, *PMEASUREMENT_MODE;
146
147// Measurement Request element, This is little endian mode
148typedef struct _MEASUREMENT_REQUEST_ELEMENT {
149 USHORT Eid;
150 USHORT Length; // swap16 required
151 USHORT Token; // non-zero unique token
152 UCHAR Mode; // Measurement Mode
153 UCHAR Type; // Measurement type
154} MEASUREMENT_REQUEST_ELEMENT, *PMEASUREMENT_REQUEST_ELEMENT;
155
156// Measurement Report element, This is little endian mode
157typedef struct _MEASUREMENT_REPORT_ELEMENT {
158 USHORT Eid;
159 USHORT Length; // swap16 required
160 USHORT Token; // non-zero unique token
161 UCHAR Mode; // Measurement Mode
162 UCHAR Type; // Measurement type
163} MEASUREMENT_REPORT_ELEMENT, *PMEASUREMENT_REPORT_ELEMENT;
164
165// Cisco Aironet IAPP Frame Header, Network byte order used
166typedef struct _AIRONET_IAPP_HEADER {
167 UCHAR CiscoSnapHeader[8]; // 8 bytes Cisco snap header
168 USHORT Length; // IAPP ID & length, remember to swap16 in LE system
169 UCHAR Type; // IAPP type
170 UCHAR SubType; // IAPP subtype
171 UCHAR DA[6]; // Destination MAC address
172 UCHAR SA[6]; // Source MAC address
173 USHORT Token; // Dialog token, no need to swap16 since it is for yoken usage only
174} AIRONET_IAPP_HEADER, *PAIRONET_IAPP_HEADER;
175
176// Radio Measurement Request frame
177typedef struct _AIRONET_RM_REQUEST_FRAME {
178 AIRONET_IAPP_HEADER IAPP; // Common header
179 UCHAR Delay; // Activation Delay
180 UCHAR Offset; // Measurement offset
181} AIRONET_RM_REQUEST_FRAME, *PAIRONET_RM_REQUEST_FRAME;
182
183// Radio Measurement Report frame
184typedef struct _AIRONET_RM_REPORT_FRAME {
185 AIRONET_IAPP_HEADER IAPP; // Common header
186} AIRONET_RM_REPORT_FRAME, *PAIRONET_RM_REPORT_FRAME;
187
188// Saved element request actions which will saved in StaCfg.
189typedef struct _RM_REQUEST_ACTION {
190 MEASUREMENT_REQUEST_ELEMENT ReqElem; // Saved request element
191 MEASUREMENT_REQUEST Measurement; // Saved measurement within the request element
192} RM_REQUEST_ACTION, *PRM_REQUEST_ACTION;
193
194// CCX administration control
195typedef union _CCX_CONTROL {
196 struct {
197 UINT32 Enable:1; // Enable CCX2
198 UINT32 LeapEnable:1; // Enable LEAP at CCX2
199 UINT32 RMEnable:1; // Radio Measurement Enable
200 UINT32 DCRMEnable:1; // Non serving channel Radio Measurement enable
201 UINT32 QOSEnable:1; // Enable QOS for CCX 2.0 support
202 UINT32 FastRoamEnable:1; // Enable fast roaming
203 UINT32 Rsvd:2; // Not used
204 UINT32 dBmToRoam:8; // the condition to roam when receiving Rssi less than this value. It's negative value.
205 UINT32 TuLimit:16; // Limit for different channel scan
206 } field;
207 UINT32 word;
208} CCX_CONTROL, *PCCX_CONTROL;
209
210#endif // __AIRONET_H__
diff --git a/drivers/staging/rt2870/ap.h b/drivers/staging/rt2870/ap.h
index a814d55abeff..fe04b5f45f20 100644
--- a/drivers/staging/rt2870/ap.h
+++ b/drivers/staging/rt2870/ap.h
@@ -1,531 +1 @@
1/* #include "../rt2860/ap.h"
2 *************************************************************************
3 * Ralink Tech Inc.
4 * 5F., No.36, Taiyuan St., Jhubei City,
5 * Hsinchu County 302,
6 * Taiwan, R.O.C.
7 *
8 * (c) Copyright 2002-2007, Ralink Technology, Inc.
9 *
10 * This program is free software; you can redistribute it and/or modify *
11 * it under the terms of the GNU General Public License as published by *
12 * the Free Software Foundation; either version 2 of the License, or *
13 * (at your option) any later version. *
14 * *
15 * This program is distributed in the hope that it will be useful, *
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
18 * GNU General Public License for more details. *
19 * *
20 * You should have received a copy of the GNU General Public License *
21 * along with this program; if not, write to the *
22 * Free Software Foundation, Inc., *
23 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
24 * *
25 *************************************************************************
26
27 Module Name:
28 ap.h
29
30 Abstract:
31 Miniport generic portion header file
32
33 Revision History:
34 Who When What
35 -------- ---------- ----------------------------------------------
36 Paul Lin 08-01-2002 created
37 James Tan 09-06-2002 modified (Revise NTCRegTable)
38 John Chang 12-22-2004 modified for RT2561/2661. merge with STA driver
39*/
40#ifndef __AP_H__
41#define __AP_H__
42
43
44
45// ========================= AP RTMP.h ================================
46
47
48
49// =============================================================
50// Function Prototypes
51// =============================================================
52
53// ap_data.c
54
55BOOLEAN APBridgeToWirelessSta(
56 IN PRTMP_ADAPTER pAd,
57 IN PUCHAR pHeader,
58 IN UINT HdrLen,
59 IN PUCHAR pData,
60 IN UINT DataLen,
61 IN ULONG fromwdsidx);
62
63BOOLEAN APHandleRxDoneInterrupt(
64 IN PRTMP_ADAPTER pAd);
65
66VOID APSendPackets(
67 IN NDIS_HANDLE MiniportAdapterContext,
68 IN PPNDIS_PACKET ppPacketArray,
69 IN UINT NumberOfPackets);
70
71NDIS_STATUS APSendPacket(
72 IN PRTMP_ADAPTER pAd,
73 IN PNDIS_PACKET pPacket);
74
75
76NDIS_STATUS APHardTransmit(
77 IN PRTMP_ADAPTER pAd,
78 IN TX_BLK *pTxBlk,
79 IN UCHAR QueIdx);
80
81VOID APRxEAPOLFrameIndicate(
82 IN PRTMP_ADAPTER pAd,
83 IN MAC_TABLE_ENTRY *pEntry,
84 IN RX_BLK *pRxBlk,
85 IN UCHAR FromWhichBSSID);
86
87NDIS_STATUS APCheckRxError(
88 IN PRTMP_ADAPTER pAd,
89 IN PRT28XX_RXD_STRUC pRxD,
90 IN UCHAR Wcid);
91
92BOOLEAN APCheckClass2Class3Error(
93 IN PRTMP_ADAPTER pAd,
94 IN ULONG Wcid,
95 IN PHEADER_802_11 pHeader);
96
97VOID APHandleRxPsPoll(
98 IN PRTMP_ADAPTER pAd,
99 IN PUCHAR pAddr,
100 IN USHORT Aid,
101 IN BOOLEAN isActive);
102
103VOID RTMPDescriptorEndianChange(
104 IN PUCHAR pData,
105 IN ULONG DescriptorType);
106
107VOID RTMPFrameEndianChange(
108 IN PRTMP_ADAPTER pAd,
109 IN PUCHAR pData,
110 IN ULONG Dir,
111 IN BOOLEAN FromRxDoneInt);
112
113// ap_assoc.c
114
115VOID APAssocStateMachineInit(
116 IN PRTMP_ADAPTER pAd,
117 IN STATE_MACHINE *S,
118 OUT STATE_MACHINE_FUNC Trans[]);
119
120VOID APPeerAssocReqAction(
121 IN PRTMP_ADAPTER pAd,
122 IN MLME_QUEUE_ELEM *Elem);
123
124VOID APPeerReassocReqAction(
125 IN PRTMP_ADAPTER pAd,
126 IN MLME_QUEUE_ELEM *Elem);
127
128VOID APPeerDisassocReqAction(
129 IN PRTMP_ADAPTER pAd,
130 IN MLME_QUEUE_ELEM *Elem);
131
132VOID MbssKickOutStas(
133 IN PRTMP_ADAPTER pAd,
134 IN INT apidx,
135 IN USHORT Reason);
136
137VOID APMlmeKickOutSta(
138 IN PRTMP_ADAPTER pAd,
139 IN PUCHAR pStaAddr,
140 IN UCHAR Wcid,
141 IN USHORT Reason);
142
143VOID APMlmeDisassocReqAction(
144 IN PRTMP_ADAPTER pAd,
145 IN MLME_QUEUE_ELEM *Elem);
146
147VOID APCls3errAction(
148 IN PRTMP_ADAPTER pAd,
149 IN ULONG Wcid,
150 IN PHEADER_802_11 pHeader);
151
152
153USHORT APBuildAssociation(
154 IN PRTMP_ADAPTER pAd,
155 IN MAC_TABLE_ENTRY *pEntry,
156 IN USHORT CapabilityInfo,
157 IN UCHAR MaxSupportedRateIn500Kbps,
158 IN UCHAR *RSN,
159 IN UCHAR *pRSNLen,
160 IN BOOLEAN bWmmCapable,
161 IN ULONG RalinkIe,
162 IN HT_CAPABILITY_IE *pHtCapability,
163 IN UCHAR HtCapabilityLen,
164 OUT USHORT *pAid);
165
166// ap_auth.c
167
168void APAuthStateMachineInit(
169 IN PRTMP_ADAPTER pAd,
170 IN STATE_MACHINE *Sm,
171 OUT STATE_MACHINE_FUNC Trans[]);
172
173VOID APMlmeDeauthReqAction(
174 IN PRTMP_ADAPTER pAd,
175 IN MLME_QUEUE_ELEM *Elem);
176
177VOID APCls2errAction(
178 IN PRTMP_ADAPTER pAd,
179 IN ULONG Wcid,
180 IN PHEADER_802_11 pHeader);
181
182// ap_authrsp.c
183
184VOID APAuthRspStateMachineInit(
185 IN PRTMP_ADAPTER pAd,
186 IN PSTATE_MACHINE Sm,
187 IN STATE_MACHINE_FUNC Trans[]);
188
189VOID APPeerAuthAtAuthRspIdleAction(
190 IN PRTMP_ADAPTER pAd,
191 IN MLME_QUEUE_ELEM *Elem);
192
193VOID APPeerDeauthReqAction(
194 IN PRTMP_ADAPTER pAd,
195 IN MLME_QUEUE_ELEM *Elem);
196
197VOID APPeerAuthSimpleRspGenAndSend(
198 IN PRTMP_ADAPTER pAd,
199 IN PHEADER_802_11 pHdr80211,
200 IN USHORT Alg,
201 IN USHORT Seq,
202 IN USHORT StatusCode);
203
204// ap_connect.c
205
206BOOLEAN BeaconTransmitRequired(
207 IN PRTMP_ADAPTER pAd,
208 IN INT apidx);
209
210VOID APMakeBssBeacon(
211 IN PRTMP_ADAPTER pAd,
212 IN INT apidx);
213
214VOID APUpdateBeaconFrame(
215 IN PRTMP_ADAPTER pAd,
216 IN INT apidx);
217
218VOID APMakeAllBssBeacon(
219 IN PRTMP_ADAPTER pAd);
220
221VOID APUpdateAllBeaconFrame(
222 IN PRTMP_ADAPTER pAd);
223
224
225// ap_sync.c
226
227VOID APSyncStateMachineInit(
228 IN PRTMP_ADAPTER pAd,
229 IN STATE_MACHINE *Sm,
230 OUT STATE_MACHINE_FUNC Trans[]);
231
232VOID APScanTimeout(
233 IN PVOID SystemSpecific1,
234 IN PVOID FunctionContext,
235 IN PVOID SystemSpecific2,
236 IN PVOID SystemSpecific3);
237
238VOID APInvalidStateWhenScan(
239 IN PRTMP_ADAPTER pAd,
240 IN MLME_QUEUE_ELEM *Elem);
241
242VOID APScanTimeoutAction(
243 IN PRTMP_ADAPTER pAd,
244 IN MLME_QUEUE_ELEM *Elem);
245
246VOID APPeerProbeReqAction(
247 IN PRTMP_ADAPTER pAd,
248 IN MLME_QUEUE_ELEM *Elem);
249
250VOID APPeerBeaconAction(
251 IN PRTMP_ADAPTER pAd,
252 IN MLME_QUEUE_ELEM *Elem);
253
254VOID APMlmeScanReqAction(
255 IN PRTMP_ADAPTER pAd,
256 IN MLME_QUEUE_ELEM *Elem);
257
258VOID APPeerBeaconAtScanAction(
259 IN PRTMP_ADAPTER pAd,
260 IN MLME_QUEUE_ELEM *Elem);
261
262VOID APScanCnclAction(
263 IN PRTMP_ADAPTER pAd,
264 IN MLME_QUEUE_ELEM *Elem);
265
266VOID ApSiteSurvey(
267 IN PRTMP_ADAPTER pAd);
268
269VOID SupportRate(
270 IN PUCHAR SupRate,
271 IN UCHAR SupRateLen,
272 IN PUCHAR ExtRate,
273 IN UCHAR ExtRateLen,
274 OUT PUCHAR *Rates,
275 OUT PUCHAR RatesLen,
276 OUT PUCHAR pMaxSupportRate);
277
278
279BOOLEAN ApScanRunning(
280 IN PRTMP_ADAPTER pAd);
281
282// ap_wpa.c
283
284VOID APWpaStateMachineInit(
285 IN PRTMP_ADAPTER pAd,
286 IN STATE_MACHINE *Sm,
287 OUT STATE_MACHINE_FUNC Trans[]);
288
289// ap_mlme.c
290
291VOID APMlmePeriodicExec(
292 IN PRTMP_ADAPTER pAd);
293
294VOID APMlmeSelectTxRateTable(
295 IN PRTMP_ADAPTER pAd,
296 IN PMAC_TABLE_ENTRY pEntry,
297 IN PUCHAR *ppTable,
298 IN PUCHAR pTableSize,
299 IN PUCHAR pInitTxRateIdx);
300
301VOID APMlmeSetTxRate(
302 IN PRTMP_ADAPTER pAd,
303 IN PMAC_TABLE_ENTRY pEntry,
304 IN PRTMP_TX_RATE_SWITCH pTxRate);
305
306VOID APMlmeDynamicTxRateSwitching(
307 IN PRTMP_ADAPTER pAd);
308
309VOID APQuickResponeForRateUpExec(
310 IN PVOID SystemSpecific1,
311 IN PVOID FunctionContext,
312 IN PVOID SystemSpecific2,
313 IN PVOID SystemSpecific3);
314
315BOOLEAN APMsgTypeSubst(
316 IN PRTMP_ADAPTER pAd,
317 IN PFRAME_802_11 pFrame,
318 OUT INT *Machine,
319 OUT INT *MsgType);
320
321VOID APQuickResponeForRateUpExec(
322 IN PVOID SystemSpecific1,
323 IN PVOID FunctionContext,
324 IN PVOID SystemSpecific2,
325 IN PVOID SystemSpecific3);
326
327#ifdef RT2870
328VOID BeaconUpdateExec(
329 IN PVOID SystemSpecific1,
330 IN PVOID FunctionContext,
331 IN PVOID SystemSpecific2,
332 IN PVOID SystemSpecific3);
333#endif // RT2870 //
334
335VOID RTMPSetPiggyBack(
336 IN PRTMP_ADAPTER pAd,
337 IN BOOLEAN bPiggyBack);
338
339VOID APAsicEvaluateRxAnt(
340 IN PRTMP_ADAPTER pAd);
341
342VOID APAsicRxAntEvalTimeout(
343 IN PRTMP_ADAPTER pAd);
344
345// ap.c
346
347VOID APSwitchChannel(
348 IN PRTMP_ADAPTER pAd,
349 IN INT Channel);
350
351NDIS_STATUS APInitialize(
352 IN PRTMP_ADAPTER pAd);
353
354VOID APShutdown(
355 IN PRTMP_ADAPTER pAd);
356
357VOID APStartUp(
358 IN PRTMP_ADAPTER pAd);
359
360VOID APStop(
361 IN PRTMP_ADAPTER pAd);
362
363VOID APCleanupPsQueue(
364 IN PRTMP_ADAPTER pAd,
365 IN PQUEUE_HEADER pQueue);
366
367VOID MacTableReset(
368 IN PRTMP_ADAPTER pAd);
369
370MAC_TABLE_ENTRY *MacTableInsertEntry(
371 IN PRTMP_ADAPTER pAd,
372 IN PUCHAR pAddr,
373 IN UCHAR apidx,
374 IN BOOLEAN CleanAll);
375
376BOOLEAN MacTableDeleteEntry(
377 IN PRTMP_ADAPTER pAd,
378 IN USHORT wcid,
379 IN PUCHAR pAddr);
380
381MAC_TABLE_ENTRY *MacTableLookup(
382 IN PRTMP_ADAPTER pAd,
383 IN PUCHAR pAddr);
384
385VOID MacTableMaintenance(
386 IN PRTMP_ADAPTER pAd);
387
388UINT32 MacTableAssocStaNumGet(
389 IN PRTMP_ADAPTER pAd);
390
391MAC_TABLE_ENTRY *APSsPsInquiry(
392 IN PRTMP_ADAPTER pAd,
393 IN PUCHAR pAddr,
394 OUT SST *Sst,
395 OUT USHORT *Aid,
396 OUT UCHAR *PsMode,
397 OUT UCHAR *Rate);
398
399BOOLEAN APPsIndicate(
400 IN PRTMP_ADAPTER pAd,
401 IN PUCHAR pAddr,
402 IN ULONG Wcid,
403 IN UCHAR Psm);
404
405VOID ApLogEvent(
406 IN PRTMP_ADAPTER pAd,
407 IN PUCHAR pAddr,
408 IN USHORT Event);
409
410VOID APUpdateOperationMode(
411 IN PRTMP_ADAPTER pAd);
412
413VOID APUpdateCapabilityAndErpIe(
414 IN PRTMP_ADAPTER pAd);
415
416BOOLEAN ApCheckAccessControlList(
417 IN PRTMP_ADAPTER pAd,
418 IN PUCHAR pAddr,
419 IN UCHAR Apidx);
420
421VOID ApUpdateAccessControlList(
422 IN PRTMP_ADAPTER pAd,
423 IN UCHAR Apidx);
424
425VOID ApEnqueueNullFrame(
426 IN PRTMP_ADAPTER pAd,
427 IN PUCHAR pAddr,
428 IN UCHAR TxRate,
429 IN UCHAR PID,
430 IN UCHAR apidx,
431 IN BOOLEAN bQosNull,
432 IN BOOLEAN bEOSP,
433 IN UCHAR OldUP);
434
435VOID ApSendFrame(
436 IN PRTMP_ADAPTER pAd,
437 IN PVOID pBuffer,
438 IN ULONG Length,
439 IN UCHAR TxRate,
440 IN UCHAR PID);
441
442VOID ApEnqueueAckFrame(
443 IN PRTMP_ADAPTER pAd,
444 IN PUCHAR pAddr,
445 IN UCHAR TxRate,
446 IN UCHAR apidx);
447
448UCHAR APAutoSelectChannel(
449 IN PRTMP_ADAPTER pAd,
450 IN BOOLEAN Optimal);
451
452// ap_sanity.c
453
454
455BOOLEAN PeerAssocReqCmmSanity(
456 IN PRTMP_ADAPTER pAd,
457 IN BOOLEAN isRessoc,
458 IN VOID *Msg,
459 IN ULONG MsgLen,
460 OUT PUCHAR pAddr2,
461 OUT USHORT *pCapabilityInfo,
462 OUT USHORT *pListenInterval,
463 OUT PUCHAR pApAddr,
464 OUT UCHAR *pSsidLen,
465 OUT char *Ssid,
466 OUT UCHAR *pRatesLen,
467 OUT UCHAR Rates[],
468 OUT UCHAR *RSN,
469 OUT UCHAR *pRSNLen,
470 OUT BOOLEAN *pbWmmCapable,
471 OUT ULONG *pRalinkIe,
472 OUT UCHAR *pHtCapabilityLen,
473 OUT HT_CAPABILITY_IE *pHtCapability);
474
475BOOLEAN PeerDisassocReqSanity(
476 IN PRTMP_ADAPTER pAd,
477 IN VOID *Msg,
478 IN ULONG MsgLen,
479 OUT PUCHAR pAddr2,
480 OUT USHORT *Reason);
481
482BOOLEAN PeerDeauthReqSanity(
483 IN PRTMP_ADAPTER pAd,
484 IN VOID *Msg,
485 IN ULONG MsgLen,
486 OUT PUCHAR pAddr2,
487 OUT USHORT *Reason);
488
489BOOLEAN APPeerAuthSanity(
490 IN PRTMP_ADAPTER pAd,
491 IN VOID *Msg,
492 IN ULONG MsgLen,
493 OUT PUCHAR pAddr1,
494 OUT PUCHAR pAddr2,
495 OUT USHORT *Alg,
496 OUT USHORT *Seq,
497 OUT USHORT *Status,
498 CHAR *ChlgText);
499
500BOOLEAN APPeerProbeReqSanity(
501 IN PRTMP_ADAPTER pAd,
502 IN VOID *Msg,
503 IN ULONG MsgLen,
504 OUT PUCHAR pAddr2,
505 OUT CHAR Ssid[],
506 OUT UCHAR *SsidLen);
507
508BOOLEAN APPeerBeaconAndProbeRspSanity(
509 IN PRTMP_ADAPTER pAd,
510 IN VOID *Msg,
511 IN ULONG MsgLen,
512 OUT PUCHAR pAddr2,
513 OUT PUCHAR pBssid,
514 OUT CHAR Ssid[],
515 OUT UCHAR *SsidLen,
516 OUT UCHAR *BssType,
517 OUT USHORT *BeaconPeriod,
518 OUT UCHAR *Channel,
519 OUT LARGE_INTEGER *Timestamp,
520 OUT USHORT *CapabilityInfo,
521 OUT UCHAR Rate[],
522 OUT UCHAR *RateLen,
523 OUT BOOLEAN *ExtendedRateIeExist,
524 OUT UCHAR *Erp);
525
526
527// ================== end of AP RTMP.h ========================
528
529
530#endif // __AP_H__
531
diff --git a/drivers/staging/rt2870/chlist.h b/drivers/staging/rt2870/chlist.h
index 1ad26b574083..31999583b379 100644
--- a/drivers/staging/rt2870/chlist.h
+++ b/drivers/staging/rt2870/chlist.h
@@ -1,1250 +1 @@
1/* #include "../rt2860/chlist.h"
2 *************************************************************************
3 * Ralink Tech Inc.
4 * 5F., No.36, Taiyuan St., Jhubei City,
5 * Hsinchu County 302,
6 * Taiwan, R.O.C.
7 *
8 * (c) Copyright 2002-2007, Ralink Technology, Inc.
9 *
10 * This program is free software; you can redistribute it and/or modify *
11 * it under the terms of the GNU General Public License as published by *
12 * the Free Software Foundation; either version 2 of the License, or *
13 * (at your option) any later version. *
14 * *
15 * This program is distributed in the hope that it will be useful, *
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
18 * GNU General Public License for more details. *
19 * *
20 * You should have received a copy of the GNU General Public License *
21 * along with this program; if not, write to the *
22 * Free Software Foundation, Inc., *
23 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
24 * *
25 *************************************************************************
26
27 Module Name:
28 chlist.c
29
30 Abstract:
31
32 Revision History:
33 Who When What
34 -------- ---------- ----------------------------------------------
35 Fonchi Wu 2007-12-19 created
36*/
37
38#ifndef __CHLIST_H__
39#define __CHLIST_H__
40
41#include "rtmp_type.h"
42#include "rtmp_def.h"
43
44
45#define ODOR 0
46#define IDOR 1
47#define BOTH 2
48
49#define BAND_5G 0
50#define BAND_24G 1
51#define BAND_BOTH 2
52
53typedef struct _CH_DESP {
54 UCHAR FirstChannel;
55 UCHAR NumOfCh;
56 CHAR MaxTxPwr; // dBm
57 UCHAR Geography; // 0:out door, 1:in door, 2:both
58 BOOLEAN DfsReq; // Dfs require, 0: No, 1: yes.
59} CH_DESP, *PCH_DESP;
60
61typedef struct _CH_REGION {
62 UCHAR CountReg[3];
63 UCHAR DfsType; // 0: CE, 1: FCC, 2: JAP, 3:JAP_W53, JAP_W56
64 CH_DESP ChDesp[10];
65} CH_REGION, *PCH_REGION;
66
67static CH_REGION ChRegion[] =
68{
69 { // Antigua and Berbuda
70 "AG",
71 CE,
72 {
73 { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
74 { 36, 4, 23, BOTH, FALSE}, // 5G, ch 36~48
75 { 52, 4, 23, BOTH, FALSE}, // 5G, ch 52~64
76 { 100, 11, 30, BOTH, FALSE}, // 5G, ch 100~140
77 { 0}, // end
78 }
79 },
80
81 { // Argentina
82 "AR",
83 CE,
84 {
85 { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
86 { 52, 4, 24, BOTH, FALSE}, // 5G, ch 52~64
87 { 149, 4, 30, BOTH, FALSE}, // 5G, ch 149~161
88 { 0}, // end
89 }
90 },
91
92 { // Aruba
93 "AW",
94 CE,
95 {
96 { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
97 { 36, 4, 23, BOTH, FALSE}, // 5G, ch 36~48
98 { 52, 4, 23, BOTH, FALSE}, // 5G, ch 52~64
99 { 100, 11, 30, BOTH, FALSE}, // 5G, ch 100~140
100 { 0}, // end
101 }
102 },
103
104 { // Australia
105 "AU",
106 CE,
107 {
108 { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
109 { 36, 4, 23, BOTH, FALSE}, // 5G, ch 36~48
110 { 52, 4, 24, BOTH, FALSE}, // 5G, ch 52~64
111 { 149, 5, 30, BOTH, FALSE}, // 5G, ch 149~165
112 { 0}, // end
113 }
114 },
115
116 { // Austria
117 "AT",
118 CE,
119 {
120 { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
121 { 36, 4, 23, IDOR, TRUE}, // 5G, ch 36~48
122 { 52, 4, 23, IDOR, TRUE}, // 5G, ch 52~64
123 { 100, 11, 30, BOTH, TRUE}, // 5G, ch 100~140
124 { 0}, // end
125 }
126 },
127
128 { // Bahamas
129 "BS",
130 CE,
131 {
132 { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
133 { 36, 4, 23, BOTH, FALSE}, // 5G, ch 36~48
134 { 52, 4, 24, BOTH, FALSE}, // 5G, ch 52~64
135 { 149, 5, 30, BOTH, FALSE}, // 5G, ch 149~165
136 { 0}, // end
137 }
138 },
139
140 { // Barbados
141 "BB",
142 CE,
143 {
144 { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
145 { 36, 4, 23, BOTH, FALSE}, // 5G, ch 36~48
146 { 52, 4, 24, BOTH, FALSE}, // 5G, ch 52~64
147 { 100, 11, 30, BOTH, FALSE}, // 5G, ch 100~140
148 { 0}, // end
149 }
150 },
151
152 { // Bermuda
153 "BM",
154 CE,
155 {
156 { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
157 { 36, 4, 23, BOTH, FALSE}, // 5G, ch 36~48
158 { 52, 4, 24, BOTH, FALSE}, // 5G, ch 52~64
159 { 100, 11, 30, BOTH, FALSE}, // 5G, ch 100~140
160 { 0}, // end
161 }
162 },
163
164 { // Brazil
165 "BR",
166 CE,
167 {
168 { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
169 { 36, 4, 23, BOTH, FALSE}, // 5G, ch 36~48
170 { 52, 4, 24, BOTH, FALSE}, // 5G, ch 52~64
171 { 100, 11, 24, BOTH, FALSE}, // 5G, ch 100~140
172 { 149, 5, 30, BOTH, FALSE}, // 5G, ch 100~140
173 { 0}, // end
174 }
175 },
176
177 { // Belgium
178 "BE",
179 CE,
180 {
181 { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
182 { 36, 4, 18, IDOR, FALSE}, // 5G, ch 36~48
183 { 52, 4, 18, IDOR, FALSE}, // 5G, ch 52~64
184 { 0}, // end
185 }
186 },
187
188 { // Bulgaria
189 "BG",
190 CE,
191 {
192 { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
193 { 36, 4, 23, IDOR, FALSE}, // 5G, ch 36~48
194 { 52, 4, 23, IDOR, TRUE}, // 5G, ch 52~64
195 { 100, 11, 30, ODOR, TRUE}, // 5G, ch 100~140
196 { 0}, // end
197 }
198 },
199
200 { // Canada
201 "CA",
202 CE,
203 {
204 { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
205 { 36, 4, 23, BOTH, FALSE}, // 5G, ch 36~48
206 { 52, 4, 23, BOTH, FALSE}, // 5G, ch 52~64
207 { 149, 5, 30, BOTH, FALSE}, // 5G, ch 149~165
208 { 0}, // end
209 }
210 },
211
212 { // Cayman IsLands
213 "KY",
214 CE,
215 {
216 { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
217 { 36, 4, 23, BOTH, FALSE}, // 5G, ch 36~48
218 { 52, 4, 24, BOTH, FALSE}, // 5G, ch 52~64
219 { 100, 11, 30, BOTH, FALSE}, // 5G, ch 100~140
220 { 0}, // end
221 }
222 },
223
224 { // Chile
225 "CL",
226 CE,
227 {
228 { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
229 { 36, 4, 20, BOTH, FALSE}, // 5G, ch 36~48
230 { 52, 4, 20, BOTH, FALSE}, // 5G, ch 52~64
231 { 149, 5, 20, BOTH, FALSE}, // 5G, ch 149~165
232 { 0}, // end
233 }
234 },
235
236 { // China
237 "CN",
238 CE,
239 {
240 { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
241 { 149, 4, 27, BOTH, FALSE}, // 5G, ch 149~161
242 { 0}, // end
243 }
244 },
245
246 { // Colombia
247 "CO",
248 CE,
249 {
250 { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
251 { 36, 4, 17, BOTH, FALSE}, // 5G, ch 36~48
252 { 52, 4, 24, BOTH, FALSE}, // 5G, ch 52~64
253 { 100, 11, 30, BOTH, FALSE}, // 5G, ch 100~140
254 { 149, 5, 30, BOTH, FALSE}, // 5G, ch 149~165
255 { 0}, // end
256 }
257 },
258
259 { // Costa Rica
260 "CR",
261 CE,
262 {
263 { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
264 { 36, 4, 17, BOTH, FALSE}, // 5G, ch 36~48
265 { 52, 4, 24, BOTH, FALSE}, // 5G, ch 52~64
266 { 149, 4, 30, BOTH, FALSE}, // 5G, ch 149~161
267 { 0}, // end
268 }
269 },
270
271 { // Cyprus
272 "CY",
273 CE,
274 {
275 { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
276 { 36, 4, 23, IDOR, FALSE}, // 5G, ch 36~48
277 { 52, 4, 24, IDOR, TRUE}, // 5G, ch 52~64
278 { 100, 11, 30, BOTH, TRUE}, // 5G, ch 100~140
279 { 0}, // end
280 }
281 },
282
283 { // Czech_Republic
284 "CZ",
285 CE,
286 {
287 { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
288 { 36, 4, 23, IDOR, FALSE}, // 5G, ch 36~48
289 { 52, 4, 23, IDOR, TRUE}, // 5G, ch 52~64
290 { 0}, // end
291 }
292 },
293
294 { // Denmark
295 "DK",
296 CE,
297 {
298 { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
299 { 36, 4, 23, IDOR, FALSE}, // 5G, ch 36~48
300 { 52, 4, 23, IDOR, TRUE}, // 5G, ch 52~64
301 { 100, 11, 30, BOTH, TRUE}, // 5G, ch 100~140
302 { 0}, // end
303 }
304 },
305
306 { // Dominican Republic
307 "DO",
308 CE,
309 {
310 { 1, 0, 20, BOTH, FALSE}, // 2.4 G, ch 0
311 { 149, 4, 20, BOTH, FALSE}, // 5G, ch 149~161
312 { 0}, // end
313 }
314 },
315
316 { // Equador
317 "EC",
318 CE,
319 {
320 { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
321 { 100, 11, 27, BOTH, FALSE}, // 5G, ch 100~140
322 { 0}, // end
323 }
324 },
325
326 { // El Salvador
327 "SV",
328 CE,
329 {
330 { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
331 { 36, 4, 23, IDOR, FALSE}, // 5G, ch 36~48
332 { 52, 4, 30, BOTH, TRUE}, // 5G, ch 52~64
333 { 149, 4, 36, BOTH, TRUE}, // 5G, ch 149~165
334 { 0}, // end
335 }
336 },
337
338 { // Finland
339 "FI",
340 CE,
341 {
342 { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
343 { 36, 4, 23, IDOR, FALSE}, // 5G, ch 36~48
344 { 52, 4, 23, IDOR, TRUE}, // 5G, ch 52~64
345 { 100, 11, 30, BOTH, TRUE}, // 5G, ch 100~140
346 { 0}, // end
347 }
348 },
349
350 { // France
351 "FR",
352 CE,
353 {
354 { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
355 { 36, 4, 23, IDOR, FALSE}, // 5G, ch 36~48
356 { 52, 4, 23, IDOR, TRUE}, // 5G, ch 52~64
357 { 0}, // end
358 }
359 },
360
361 { // Germany
362 "DE",
363 CE,
364 {
365 { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
366 { 36, 4, 23, IDOR, FALSE}, // 5G, ch 36~48
367 { 52, 4, 23, IDOR, TRUE}, // 5G, ch 52~64
368 { 100, 11, 30, BOTH, TRUE}, // 5G, ch 100~140
369 { 0}, // end
370 }
371 },
372
373 { // Greece
374 "GR",
375 CE,
376 {
377 { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
378 { 36, 4, 23, IDOR, FALSE}, // 5G, ch 36~48
379 { 52, 4, 23, IDOR, TRUE}, // 5G, ch 52~64
380 { 100, 11, 30, ODOR, TRUE}, // 5G, ch 100~140
381 { 0}, // end
382 }
383 },
384
385 { // Guam
386 "GU",
387 CE,
388 {
389 { 1, 11, 20, BOTH, FALSE}, // 2.4 G, ch 1~11
390 { 36, 4, 17, BOTH, FALSE}, // 5G, ch 36~48
391 { 52, 4, 24, BOTH, FALSE}, // 5G, ch 52~64
392 { 100, 11, 30, BOTH, FALSE}, // 5G, ch 100~140
393 { 149, 5, 30, BOTH, FALSE}, // 5G, ch 149~165
394 { 0}, // end
395 }
396 },
397
398 { // Guatemala
399 "GT",
400 CE,
401 {
402 { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
403 { 36, 4, 17, BOTH, FALSE}, // 5G, ch 36~48
404 { 52, 4, 24, BOTH, FALSE}, // 5G, ch 52~64
405 { 149, 4, 30, BOTH, FALSE}, // 5G, ch 149~161
406 { 0}, // end
407 }
408 },
409
410 { // Haiti
411 "HT",
412 CE,
413 {
414 { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
415 { 36, 4, 17, BOTH, FALSE}, // 5G, ch 36~48
416 { 52, 4, 24, BOTH, FALSE}, // 5G, ch 52~64
417 { 149, 4, 30, BOTH, FALSE}, // 5G, ch 149~161
418 { 0}, // end
419 }
420 },
421
422 { // Honduras
423 "HN",
424 CE,
425 {
426 { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
427 { 149, 4, 27, BOTH, FALSE}, // 5G, ch 149~161
428 { 0}, // end
429 }
430 },
431
432 { // Hong Kong
433 "HK",
434 CE,
435 {
436 { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
437 { 36, 4, 23, IDOR, FALSE}, // 5G, ch 36~48
438 { 52, 4, 23, IDOR, FALSE}, // 5G, ch 52~64
439 { 149, 4, 30, BOTH, FALSE}, // 5G, ch 149~161
440 { 0}, // end
441 }
442 },
443
444 { // Hungary
445 "HU",
446 CE,
447 {
448 { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
449 { 36, 4, 23, IDOR, FALSE}, // 5G, ch 36~48
450 { 52, 4, 23, IDOR, TRUE}, // 5G, ch 52~64
451 { 0}, // end
452 }
453 },
454
455 { // Iceland
456 "IS",
457 CE,
458 {
459 { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
460 { 36, 4, 23, IDOR, FALSE}, // 5G, ch 36~48
461 { 52, 4, 23, IDOR, TRUE}, // 5G, ch 52~64
462 { 100, 11, 30, BOTH, TRUE}, // 5G, ch 100~140
463 { 0}, // end
464 }
465 },
466
467 { // India
468 "IN",
469 CE,
470 {
471 { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
472 { 149, 4, 24, IDOR, FALSE}, // 5G, ch 149~161
473 { 0}, // end
474 }
475 },
476
477 { // Indonesia
478 "ID",
479 CE,
480 {
481 { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
482 { 149, 4, 27, BOTH, FALSE}, // 5G, ch 149~161
483 { 0}, // end
484 }
485 },
486
487 { // Ireland
488 "IE",
489 CE,
490 {
491 { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
492 { 36, 4, 23, IDOR, FALSE}, // 5G, ch 36~48
493 { 52, 4, 23, IDOR, TRUE}, // 5G, ch 52~64
494 { 100, 11, 30, ODOR, TRUE}, // 5G, ch 100~140
495 { 0}, // end
496 }
497 },
498
499 { // Israel
500 "IL",
501 CE,
502 {
503 { 1, 3, 20, IDOR, FALSE}, // 2.4 G, ch 1~3
504 { 4, 6, 20, BOTH, FALSE}, // 2.4 G, ch 4~9
505 { 10, 4, 20, IDOR, FALSE}, // 2.4 G, ch 10~13
506 { 0}, // end
507 }
508 },
509
510 { // Italy
511 "IT",
512 CE,
513 {
514 { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
515 { 36, 4, 23, IDOR, FALSE}, // 5G, ch 36~48
516 { 52, 4, 23, IDOR, TRUE}, // 5G, ch 52~64
517 { 100, 11, 30, ODOR, TRUE}, // 5G, ch 100~140
518 { 0}, // end
519 }
520 },
521
522 { // Japan
523 "JP",
524 JAP,
525 {
526 { 1, 14, 20, BOTH, FALSE}, // 2.4 G, ch 1~14
527#ifndef RT30xx
528 { 36, 4, 23, IDOR, FALSE}, // 5G, ch 36~48
529#endif
530#ifdef RT30xx
531 { 34, 4, 23, IDOR, FALSE}, // 5G, ch 34~46
532#endif
533 { 0}, // end
534 }
535 },
536
537 { // Jordan
538 "JO",
539 CE,
540 {
541 { 1, 13, 20, IDOR, FALSE}, // 2.4 G, ch 1~13
542 { 36, 4, 23, IDOR, FALSE}, // 5G, ch 36~48
543 { 149, 4, 23, IDOR, FALSE}, // 5G, ch 149~161
544 { 0}, // end
545 }
546 },
547
548 { // Latvia
549 "LV",
550 CE,
551 {
552 { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
553 { 36, 4, 23, IDOR, FALSE}, // 5G, ch 36~48
554 { 52, 4, 23, IDOR, TRUE}, // 5G, ch 52~64
555 { 100, 11, 30, BOTH, TRUE}, // 5G, ch 100~140
556 { 0}, // end
557 }
558 },
559
560 { // Liechtenstein
561 "LI",
562 CE,
563 {
564 { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
565 { 52, 4, 23, IDOR, TRUE}, // 5G, ch 52~64
566 { 100, 11, 30, BOTH, TRUE}, // 5G, ch 100~140
567 { 0}, // end
568 }
569 },
570
571 { // Lithuania
572 "LT",
573 CE,
574 {
575 { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
576 { 36, 4, 23, IDOR, FALSE}, // 5G, ch 36~48
577 { 52, 4, 23, IDOR, TRUE}, // 5G, ch 52~64
578 { 100, 11, 30, BOTH, TRUE}, // 5G, ch 100~140
579 { 0}, // end
580 }
581 },
582
583 { // Luxemburg
584 "LU",
585 CE,
586 {
587 { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
588 { 36, 4, 23, IDOR, FALSE}, // 5G, ch 36~48
589 { 52, 4, 23, IDOR, TRUE}, // 5G, ch 52~64
590 { 100, 11, 30, BOTH, TRUE}, // 5G, ch 100~140
591 { 0}, // end
592 }
593 },
594
595 { // Malaysia
596 "MY",
597 CE,
598 {
599 { 36, 4, 23, BOTH, FALSE}, // 5G, ch 36~48
600 { 52, 4, 23, BOTH, FALSE}, // 5G, ch 52~64
601 { 149, 5, 20, BOTH, FALSE}, // 5G, ch 149~165
602 { 0}, // end
603 }
604 },
605
606 { // Malta
607 "MT",
608 CE,
609 {
610 { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
611 { 36, 4, 23, IDOR, FALSE}, // 5G, ch 36~48
612 { 52, 4, 23, IDOR, TRUE}, // 5G, ch 52~64
613 { 100, 11, 30, BOTH, TRUE}, // 5G, ch 100~140
614 { 0}, // end
615 }
616 },
617
618 { // Marocco
619 "MA",
620 CE,
621 {
622 { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
623 { 36, 4, 24, IDOR, FALSE}, // 5G, ch 36~48
624 { 0}, // end
625 }
626 },
627
628 { // Mexico
629 "MX",
630 CE,
631 {
632 { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
633 { 36, 4, 23, BOTH, FALSE}, // 5G, ch 36~48
634 { 52, 4, 24, BOTH, FALSE}, // 5G, ch 52~64
635 { 149, 5, 30, IDOR, FALSE}, // 5G, ch 149~165
636 { 0}, // end
637 }
638 },
639
640 { // Netherlands
641 "NL",
642 CE,
643 {
644 { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
645 { 36, 4, 23, IDOR, FALSE}, // 5G, ch 36~48
646 { 52, 4, 24, IDOR, TRUE}, // 5G, ch 52~64
647 { 100, 11, 30, BOTH, TRUE}, // 5G, ch 100~140
648 { 0}, // end
649 }
650 },
651
652 { // New Zealand
653 "NZ",
654 CE,
655 {
656 { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
657 { 36, 4, 24, BOTH, FALSE}, // 5G, ch 36~48
658 { 52, 4, 24, BOTH, FALSE}, // 5G, ch 52~64
659 { 149, 4, 30, BOTH, FALSE}, // 5G, ch 149~161
660 { 0}, // end
661 }
662 },
663
664 { // Norway
665 "NO",
666 CE,
667 {
668 { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
669 { 36, 4, 24, IDOR, FALSE}, // 5G, ch 36~48
670 { 52, 4, 24, IDOR, TRUE}, // 5G, ch 52~64
671 { 100, 11, 30, BOTH, TRUE}, // 5G, ch 149~161
672 { 0}, // end
673 }
674 },
675
676 { // Peru
677 "PE",
678 CE,
679 {
680 { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
681 { 149, 4, 27, BOTH, FALSE}, // 5G, ch 149~161
682 { 0}, // end
683 }
684 },
685
686 { // Portugal
687 "PT",
688 CE,
689 {
690 { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
691 { 36, 4, 23, IDOR, FALSE}, // 5G, ch 36~48
692 { 52, 4, 23, IDOR, TRUE}, // 5G, ch 52~64
693 { 100, 11, 30, BOTH, TRUE}, // 5G, ch 100~140
694 { 0}, // end
695 }
696 },
697
698 { // Poland
699 "PL",
700 CE,
701 {
702 { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
703 { 36, 4, 23, IDOR, FALSE}, // 5G, ch 36~48
704 { 52, 4, 23, IDOR, TRUE}, // 5G, ch 52~64
705 { 100, 11, 30, BOTH, TRUE}, // 5G, ch 100~140
706 { 0}, // end
707 }
708 },
709
710 { // Romania
711 "RO",
712 CE,
713 {
714 { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
715 { 36, 4, 23, IDOR, FALSE}, // 5G, ch 36~48
716 { 52, 4, 23, IDOR, TRUE}, // 5G, ch 52~64
717 { 100, 11, 30, BOTH, TRUE}, // 5G, ch 100~140
718 { 0}, // end
719 }
720 },
721
722 { // Russia
723 "RU",
724 CE,
725 {
726 { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
727 { 149, 4, 20, IDOR, FALSE}, // 5G, ch 149~161
728 { 0}, // end
729 }
730 },
731
732 { // Saudi Arabia
733 "SA",
734 CE,
735 {
736 { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
737 { 36, 4, 23, BOTH, FALSE}, // 5G, ch 36~48
738 { 52, 4, 23, BOTH, FALSE}, // 5G, ch 52~64
739 { 149, 4, 23, BOTH, FALSE}, // 5G, ch 149~161
740 { 0}, // end
741 }
742 },
743
744 { // Serbia_and_Montenegro
745 "CS",
746 CE,
747 {
748 { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
749 { 0}, // end
750 }
751 },
752
753 { // Singapore
754 "SG",
755 CE,
756 {
757 { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
758 { 36, 4, 23, BOTH, FALSE}, // 5G, ch 36~48
759 { 52, 4, 23, BOTH, FALSE}, // 5G, ch 52~64
760 { 149, 4, 20, BOTH, FALSE}, // 5G, ch 149~161
761 { 0}, // end
762 }
763 },
764
765 { // Slovakia
766 "SK",
767 CE,
768 {
769 { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
770 { 36, 4, 23, IDOR, FALSE}, // 5G, ch 36~48
771 { 52, 4, 23, IDOR, TRUE}, // 5G, ch 52~64
772 { 100, 11, 30, BOTH, TRUE}, // 5G, ch 100~140
773 { 0}, // end
774 }
775 },
776
777 { // Slovenia
778 "SI",
779 CE,
780 {
781 { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
782 { 36, 4, 23, IDOR, FALSE}, // 5G, ch 36~48
783 { 52, 4, 23, IDOR, TRUE}, // 5G, ch 52~64
784 { 0}, // end
785 }
786 },
787
788 { // South Africa
789 "ZA",
790 CE,
791 {
792 { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
793 { 36, 4, 23, BOTH, FALSE}, // 5G, ch 36~48
794 { 52, 4, 23, IDOR, FALSE}, // 5G, ch 52~64
795 { 100, 11, 30, BOTH, TRUE}, // 5G, ch 100~140
796 { 149, 4, 30, BOTH, FALSE}, // 5G, ch 149~161
797 { 0}, // end
798 }
799 },
800
801 { // South Korea
802 "KR",
803 CE,
804 {
805 { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
806 { 36, 4, 20, BOTH, FALSE}, // 5G, ch 36~48
807 { 52, 4, 20, BOTH, FALSE}, // 5G, ch 52~64
808 { 100, 8, 20, BOTH, FALSE}, // 5G, ch 100~128
809 { 149, 4, 20, BOTH, FALSE}, // 5G, ch 149~161
810 { 0}, // end
811 }
812 },
813
814 { // Spain
815 "ES",
816 CE,
817 {
818 { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
819 { 36, 4, 17, IDOR, FALSE}, // 5G, ch 36~48
820 { 52, 4, 23, IDOR, TRUE}, // 5G, ch 52~64
821 { 100, 11, 30, BOTH, TRUE}, // 5G, ch 100~140
822 { 0}, // end
823 }
824 },
825
826 { // Sweden
827 "SE",
828 CE,
829 {
830 { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
831 { 36, 4, 23, IDOR, FALSE}, // 5G, ch 36~48
832 { 52, 4, 23, IDOR, TRUE}, // 5G, ch 52~64
833 { 100, 11, 30, BOTH, TRUE}, // 5G, ch 100~140
834 { 0}, // end
835 }
836 },
837
838 { // Switzerland
839 "CH",
840 CE,
841 {
842 { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~13
843 { 36, 4, 23, IDOR, TRUE}, // 5G, ch 36~48
844 { 52, 4, 23, IDOR, TRUE}, // 5G, ch 52~64
845 { 0}, // end
846 }
847 },
848
849 { // Taiwan
850 "TW",
851 CE,
852 {
853 { 1, 11, 30, BOTH, FALSE}, // 2.4 G, ch 1~11
854 { 52, 4, 23, IDOR, FALSE}, // 5G, ch 52~64
855 { 0}, // end
856 }
857 },
858
859 { // Turkey
860 "TR",
861 CE,
862 {
863 { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~11
864 { 36, 4, 23, BOTH, FALSE}, // 5G, ch 36~48
865 { 52, 4, 23, BOTH, FALSE}, // 5G, ch 52~64
866 { 0}, // end
867 }
868 },
869
870 { // UK
871 "GB",
872 CE,
873 {
874 { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~11
875 { 36, 4, 23, IDOR, FALSE}, // 5G, ch 52~64
876 { 52, 4, 23, IDOR, TRUE}, // 5G, ch 52~64
877 { 100, 11, 30, BOTH, TRUE}, // 5G, ch 100~140
878 { 0}, // end
879 }
880 },
881
882 { // Ukraine
883 "UA",
884 CE,
885 {
886 { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~11
887 { 0}, // end
888 }
889 },
890
891 { // United_Arab_Emirates
892 "AE",
893 CE,
894 {
895 { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~11
896 { 0}, // end
897 }
898 },
899
900 { // United_States
901 "US",
902 CE,
903 {
904 { 1, 11, 30, BOTH, FALSE}, // 2.4 G, ch 1~11
905 { 36, 4, 17, IDOR, FALSE}, // 5G, ch 52~64
906 { 52, 4, 24, BOTH, TRUE}, // 5G, ch 52~64
907 { 100, 11, 30, BOTH, TRUE}, // 5G, ch 100~140
908 { 149, 5, 30, BOTH, FALSE}, // 5G, ch 149~165
909 { 0}, // end
910 }
911 },
912
913 { // Venezuela
914 "VE",
915 CE,
916 {
917 { 1, 13, 20, BOTH, FALSE}, // 2.4 G, ch 1~11
918 { 149, 4, 27, BOTH, FALSE}, // 5G, ch 149~161
919 { 0}, // end
920 }
921 },
922
923 { // Default
924 "",
925 CE,
926 {
927 { 1, 11, 20, BOTH, FALSE}, // 2.4 G, ch 1~11
928 { 36, 4, 20, BOTH, FALSE}, // 5G, ch 52~64
929 { 52, 4, 20, BOTH, FALSE}, // 5G, ch 52~64
930 { 100, 11, 20, BOTH, FALSE}, // 5G, ch 100~140
931 { 149, 5, 20, BOTH, FALSE}, // 5G, ch 149~165
932 { 0}, // end
933 }
934 },
935};
936
937static inline PCH_REGION GetChRegion(
938 IN PUCHAR CntryCode)
939{
940 INT loop = 0;
941 PCH_REGION pChRegion = NULL;
942
943 while (strcmp(ChRegion[loop].CountReg, "") != 0)
944 {
945 if (strncmp(ChRegion[loop].CountReg, CntryCode, 2) == 0)
946 {
947 pChRegion = &ChRegion[loop];
948 break;
949 }
950 loop++;
951 }
952
953 if (pChRegion == NULL)
954 pChRegion = &ChRegion[loop];
955 return pChRegion;
956}
957
958static inline VOID ChBandCheck(
959 IN UCHAR PhyMode,
960 OUT PUCHAR pChType)
961{
962 switch(PhyMode)
963 {
964 case PHY_11A:
965 case PHY_11AN_MIXED:
966 *pChType = BAND_5G;
967 break;
968 case PHY_11ABG_MIXED:
969 case PHY_11AGN_MIXED:
970 case PHY_11ABGN_MIXED:
971 *pChType = BAND_BOTH;
972 break;
973
974 default:
975 *pChType = BAND_24G;
976 break;
977 }
978}
979
980static inline UCHAR FillChList(
981 IN PRTMP_ADAPTER pAd,
982 IN PCH_DESP pChDesp,
983 IN UCHAR Offset,
984 IN UCHAR increment)
985{
986 INT i, j, l;
987 UCHAR channel;
988
989 j = Offset;
990 for (i = 0; i < pChDesp->NumOfCh; i++)
991 {
992 channel = pChDesp->FirstChannel + i * increment;
993 for (l=0; l<MAX_NUM_OF_CHANNELS; l++)
994 {
995 if (channel == pAd->TxPower[l].Channel)
996 {
997 pAd->ChannelList[j].Power = pAd->TxPower[l].Power;
998 pAd->ChannelList[j].Power2 = pAd->TxPower[l].Power2;
999 break;
1000 }
1001 }
1002 if (l == MAX_NUM_OF_CHANNELS)
1003 continue;
1004
1005 pAd->ChannelList[j].Channel = pChDesp->FirstChannel + i * increment;
1006 pAd->ChannelList[j].MaxTxPwr = pChDesp->MaxTxPwr;
1007 pAd->ChannelList[j].DfsReq = pChDesp->DfsReq;
1008 j++;
1009 }
1010 pAd->ChannelListNum = j;
1011
1012 return j;
1013}
1014
1015static inline VOID CreateChList(
1016 IN PRTMP_ADAPTER pAd,
1017 IN PCH_REGION pChRegion,
1018 IN UCHAR Geography)
1019{
1020 INT i;
1021 UCHAR offset = 0;
1022 PCH_DESP pChDesp;
1023 UCHAR ChType;
1024 UCHAR increment;
1025
1026 if (pChRegion == NULL)
1027 return;
1028
1029 ChBandCheck(pAd->CommonCfg.PhyMode, &ChType);
1030
1031 for (i=0; i<10; i++)
1032 {
1033 pChDesp = &pChRegion->ChDesp[i];
1034 if (pChDesp->FirstChannel == 0)
1035 break;
1036
1037 if (ChType == BAND_5G)
1038 {
1039 if (pChDesp->FirstChannel <= 14)
1040 continue;
1041 }
1042 else if (ChType == BAND_24G)
1043 {
1044 if (pChDesp->FirstChannel > 14)
1045 continue;
1046 }
1047
1048 if ((pChDesp->Geography == BOTH)
1049 || (pChDesp->Geography == Geography))
1050 {
1051 if (pChDesp->FirstChannel > 14)
1052 increment = 4;
1053 else
1054 increment = 1;
1055 offset = FillChList(pAd, pChDesp, offset, increment);
1056 }
1057 }
1058}
1059
1060static inline VOID BuildChannelListEx(
1061 IN PRTMP_ADAPTER pAd)
1062{
1063 PCH_REGION pChReg;
1064
1065 pChReg = GetChRegion(pAd->CommonCfg.CountryCode);
1066 CreateChList(pAd, pChReg, pAd->CommonCfg.Geography);
1067}
1068
1069static inline VOID BuildBeaconChList(
1070 IN PRTMP_ADAPTER pAd,
1071 OUT PUCHAR pBuf,
1072 OUT PULONG pBufLen)
1073{
1074 INT i;
1075 ULONG TmpLen;
1076 PCH_REGION pChRegion;
1077 PCH_DESP pChDesp;
1078 UCHAR ChType;
1079
1080 pChRegion = GetChRegion(pAd->CommonCfg.CountryCode);
1081
1082 if (pChRegion == NULL)
1083 return;
1084
1085 ChBandCheck(pAd->CommonCfg.PhyMode, &ChType);
1086 *pBufLen = 0;
1087
1088 for (i=0; i<10; i++)
1089 {
1090 pChDesp = &pChRegion->ChDesp[i];
1091 if (pChDesp->FirstChannel == 0)
1092 break;
1093
1094 if (ChType == BAND_5G)
1095 {
1096 if (pChDesp->FirstChannel <= 14)
1097 continue;
1098 }
1099 else if (ChType == BAND_24G)
1100 {
1101 if (pChDesp->FirstChannel > 14)
1102 continue;
1103 }
1104
1105 if ((pChDesp->Geography == BOTH)
1106 || (pChDesp->Geography == pAd->CommonCfg.Geography))
1107 {
1108 MakeOutgoingFrame(pBuf + *pBufLen, &TmpLen,
1109 1, &pChDesp->FirstChannel,
1110 1, &pChDesp->NumOfCh,
1111 1, &pChDesp->MaxTxPwr,
1112 END_OF_ARGS);
1113 *pBufLen += TmpLen;
1114 }
1115 }
1116}
1117
1118static inline BOOLEAN IsValidChannel(
1119 IN PRTMP_ADAPTER pAd,
1120 IN UCHAR channel)
1121
1122{
1123 INT i;
1124
1125 for (i = 0; i < pAd->ChannelListNum; i++)
1126 {
1127 if (pAd->ChannelList[i].Channel == channel)
1128 break;
1129 }
1130
1131 if (i == pAd->ChannelListNum)
1132 return FALSE;
1133 else
1134 return TRUE;
1135}
1136
1137
1138static inline UCHAR GetExtCh(
1139 IN UCHAR Channel,
1140 IN UCHAR Direction)
1141{
1142 CHAR ExtCh;
1143
1144 if (Direction == EXTCHA_ABOVE)
1145 ExtCh = Channel + 4;
1146 else
1147 ExtCh = (Channel - 4) > 0 ? (Channel - 4) : 0;
1148
1149 return ExtCh;
1150}
1151
1152
1153static inline VOID N_ChannelCheck(
1154 IN PRTMP_ADAPTER pAd)
1155{
1156 //UCHAR ChannelNum = pAd->ChannelListNum;
1157 UCHAR Channel = pAd->CommonCfg.Channel;
1158
1159 if ((pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED) && (pAd->CommonCfg.RegTransmitSetting.field.BW == BW_40))
1160 {
1161 if (Channel > 14)
1162 {
1163 if ((Channel == 36) || (Channel == 44) || (Channel == 52) || (Channel == 60) || (Channel == 100) || (Channel == 108) ||
1164 (Channel == 116) || (Channel == 124) || (Channel == 132) || (Channel == 149) || (Channel == 157))
1165 {
1166 pAd->CommonCfg.RegTransmitSetting.field.EXTCHA = EXTCHA_ABOVE;
1167 }
1168 else if ((Channel == 40) || (Channel == 48) || (Channel == 56) || (Channel == 64) || (Channel == 104) || (Channel == 112) ||
1169 (Channel == 120) || (Channel == 128) || (Channel == 136) || (Channel == 153) || (Channel == 161))
1170 {
1171 pAd->CommonCfg.RegTransmitSetting.field.EXTCHA = EXTCHA_BELOW;
1172 }
1173 else
1174 {
1175 pAd->CommonCfg.RegTransmitSetting.field.BW = BW_20;
1176 }
1177 }
1178 else
1179 {
1180 do
1181 {
1182 UCHAR ExtCh;
1183 UCHAR Dir = pAd->CommonCfg.RegTransmitSetting.field.EXTCHA;
1184 ExtCh = GetExtCh(Channel, Dir);
1185 if (IsValidChannel(pAd, ExtCh))
1186 break;
1187
1188 Dir = (Dir == EXTCHA_ABOVE) ? EXTCHA_BELOW : EXTCHA_ABOVE;
1189 ExtCh = GetExtCh(Channel, Dir);
1190 if (IsValidChannel(pAd, ExtCh))
1191 {
1192 pAd->CommonCfg.RegTransmitSetting.field.EXTCHA = Dir;
1193 break;
1194 }
1195 pAd->CommonCfg.RegTransmitSetting.field.BW = BW_20;
1196 } while(FALSE);
1197
1198 if (Channel == 14)
1199 {
1200 pAd->CommonCfg.RegTransmitSetting.field.BW = BW_20;
1201 //pAd->CommonCfg.RegTransmitSetting.field.EXTCHA = EXTCHA_NONE; // We didn't set the ExtCh as NONE due to it'll set in RTMPSetHT()
1202 }
1203 }
1204 }
1205
1206
1207}
1208
1209
1210static inline VOID N_SetCenCh(
1211 IN PRTMP_ADAPTER pAd)
1212{
1213 if (pAd->CommonCfg.RegTransmitSetting.field.BW == BW_40)
1214 {
1215 if (pAd->CommonCfg.RegTransmitSetting.field.EXTCHA == EXTCHA_ABOVE)
1216 {
1217 pAd->CommonCfg.CentralChannel = pAd->CommonCfg.Channel + 2;
1218 }
1219 else
1220 {
1221 if (pAd->CommonCfg.Channel == 14)
1222 pAd->CommonCfg.CentralChannel = pAd->CommonCfg.Channel - 1;
1223 else
1224 pAd->CommonCfg.CentralChannel = pAd->CommonCfg.Channel - 2;
1225 }
1226 }
1227 else
1228 {
1229 pAd->CommonCfg.CentralChannel = pAd->CommonCfg.Channel;
1230 }
1231}
1232
1233static inline UINT8 GetCuntryMaxTxPwr(
1234 IN PRTMP_ADAPTER pAd,
1235 IN UINT8 channel)
1236{
1237 int i;
1238 for (i = 0; i < pAd->ChannelListNum; i++)
1239 {
1240 if (pAd->ChannelList[i].Channel == channel)
1241 break;
1242 }
1243
1244 if (i == pAd->ChannelListNum)
1245 return 0xff;
1246 else
1247 return pAd->ChannelList[i].MaxTxPwr;
1248}
1249#endif // __CHLIST_H__
1250
diff --git a/drivers/staging/rt2870/dfs.h b/drivers/staging/rt2870/dfs.h
index 752a6352d9dd..1fdbd7bc5de5 100644
--- a/drivers/staging/rt2870/dfs.h
+++ b/drivers/staging/rt2870/dfs.h
@@ -1,100 +1 @@
1/* #include "../rt2860/dfs.h"
2 *************************************************************************
3 * Ralink Tech Inc.
4 * 5F., No.36, Taiyuan St., Jhubei City,
5 * Hsinchu County 302,
6 * Taiwan, R.O.C.
7 *
8 * (c) Copyright 2002-2007, Ralink Technology, Inc.
9 *
10 * This program is free software; you can redistribute it and/or modify *
11 * it under the terms of the GNU General Public License as published by *
12 * the Free Software Foundation; either version 2 of the License, or *
13 * (at your option) any later version. *
14 * *
15 * This program is distributed in the hope that it will be useful, *
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
18 * GNU General Public License for more details. *
19 * *
20 * You should have received a copy of the GNU General Public License *
21 * along with this program; if not, write to the *
22 * Free Software Foundation, Inc., *
23 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
24 * *
25 *************************************************************************
26
27 Module Name:
28 dfs.h
29
30 Abstract:
31 Support DFS function.
32
33 Revision History:
34 Who When What
35 -------- ---------- ----------------------------------------------
36 Fonchi 03-12-2007 created
37*/
38
39#define RADAR_PULSE 1
40#define RADAR_WIDTH 2
41
42#define WIDTH_RD_IDLE 0
43#define WIDTH_RD_CHECK 1
44
45
46VOID BbpRadarDetectionStart(
47 IN PRTMP_ADAPTER pAd);
48
49VOID BbpRadarDetectionStop(
50 IN PRTMP_ADAPTER pAd);
51
52VOID RadarDetectionStart(
53 IN PRTMP_ADAPTER pAd,
54 IN BOOLEAN CTS_Protect,
55 IN UINT8 CTSPeriod);
56
57VOID RadarDetectionStop(
58 IN PRTMP_ADAPTER pAd);
59
60VOID RadarDetectPeriodic(
61 IN PRTMP_ADAPTER pAd);
62
63
64BOOLEAN RadarChannelCheck(
65 IN PRTMP_ADAPTER pAd,
66 IN UCHAR Ch);
67
68ULONG JapRadarType(
69 IN PRTMP_ADAPTER pAd);
70
71ULONG RTMPBbpReadRadarDuration(
72 IN PRTMP_ADAPTER pAd);
73
74ULONG RTMPReadRadarDuration(
75 IN PRTMP_ADAPTER pAd);
76
77VOID RTMPCleanRadarDuration(
78 IN PRTMP_ADAPTER pAd);
79
80VOID RTMPPrepareRDCTSFrame(
81 IN PRTMP_ADAPTER pAd,
82 IN PUCHAR pDA,
83 IN ULONG Duration,
84 IN UCHAR RTSRate,
85 IN ULONG CTSBaseAddr,
86 IN UCHAR FrameGap);
87
88VOID RTMPPrepareRadarDetectParams(
89 IN PRTMP_ADAPTER pAd);
90
91
92INT Set_ChMovingTime_Proc(
93 IN PRTMP_ADAPTER pAd,
94 IN PUCHAR arg);
95
96INT Set_LongPulseRadarTh_Proc(
97 IN PRTMP_ADAPTER pAd,
98 IN PUCHAR arg);
99
100
diff --git a/drivers/staging/rt2870/link_list.h b/drivers/staging/rt2870/link_list.h
index f6521133fd5e..2589f3470390 100644
--- a/drivers/staging/rt2870/link_list.h
+++ b/drivers/staging/rt2870/link_list.h
@@ -1,134 +1 @@
1/* #include "../rt2860/link_list.h"
2 *************************************************************************
3 * Ralink Tech Inc.
4 * 5F., No.36, Taiyuan St., Jhubei City,
5 * Hsinchu County 302,
6 * Taiwan, R.O.C.
7 *
8 * (c) Copyright 2002-2007, Ralink Technology, Inc.
9 *
10 * This program is free software; you can redistribute it and/or modify *
11 * it under the terms of the GNU General Public License as published by *
12 * the Free Software Foundation; either version 2 of the License, or *
13 * (at your option) any later version. *
14 * *
15 * This program is distributed in the hope that it will be useful, *
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
18 * GNU General Public License for more details. *
19 * *
20 * You should have received a copy of the GNU General Public License *
21 * along with this program; if not, write to the *
22 * Free Software Foundation, Inc., *
23 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
24 * *
25 *************************************************************************
26 */
27
28#ifndef __LINK_LIST_H__
29#define __LINK_LIST_H__
30
31typedef struct _LIST_ENTRY
32{
33 struct _LIST_ENTRY *pNext;
34} LIST_ENTRY, *PLIST_ENTRY;
35
36typedef struct _LIST_HEADR
37{
38 PLIST_ENTRY pHead;
39 PLIST_ENTRY pTail;
40 UCHAR size;
41} LIST_HEADER, *PLIST_HEADER;
42
43static inline VOID initList(
44 IN PLIST_HEADER pList)
45{
46 pList->pHead = pList->pTail = NULL;
47 pList->size = 0;
48 return;
49}
50
51static inline VOID insertTailList(
52 IN PLIST_HEADER pList,
53 IN PLIST_ENTRY pEntry)
54{
55 pEntry->pNext = NULL;
56 if (pList->pTail)
57 pList->pTail->pNext = pEntry;
58 else
59 pList->pHead = pEntry;
60 pList->pTail = pEntry;
61 pList->size++;
62
63 return;
64}
65
66static inline PLIST_ENTRY removeHeadList(
67 IN PLIST_HEADER pList)
68{
69 PLIST_ENTRY pNext;
70 PLIST_ENTRY pEntry;
71
72 pEntry = pList->pHead;
73 if (pList->pHead != NULL)
74 {
75 pNext = pList->pHead->pNext;
76 pList->pHead = pNext;
77 if (pNext == NULL)
78 pList->pTail = NULL;
79 pList->size--;
80 }
81 return pEntry;
82}
83
84static inline int getListSize(
85 IN PLIST_HEADER pList)
86{
87 return pList->size;
88}
89
90static inline PLIST_ENTRY delEntryList(
91 IN PLIST_HEADER pList,
92 IN PLIST_ENTRY pEntry)
93{
94 PLIST_ENTRY pCurEntry;
95 PLIST_ENTRY pPrvEntry;
96
97 if(pList->pHead == NULL)
98 return NULL;
99
100 if(pEntry == pList->pHead)
101 {
102 pCurEntry = pList->pHead;
103 pList->pHead = pCurEntry->pNext;
104
105 if(pList->pHead == NULL)
106 pList->pTail = NULL;
107
108 pList->size--;
109 return pCurEntry;
110 }
111
112 pPrvEntry = pList->pHead;
113 pCurEntry = pPrvEntry->pNext;
114 while(pCurEntry != NULL)
115 {
116 if (pEntry == pCurEntry)
117 {
118 pPrvEntry->pNext = pCurEntry->pNext;
119
120 if(pEntry == pList->pTail)
121 pList->pTail = pPrvEntry;
122
123 pList->size--;
124 break;
125 }
126 pPrvEntry = pCurEntry;
127 pCurEntry = pPrvEntry->pNext;
128 }
129
130 return pCurEntry;
131}
132
133#endif // ___LINK_LIST_H__ //
134
diff --git a/drivers/staging/rt2870/md5.h b/drivers/staging/rt2870/md5.h
index d85db12170d5..d60cd05b54f7 100644
--- a/drivers/staging/rt2870/md5.h
+++ b/drivers/staging/rt2870/md5.h
@@ -1,107 +1 @@
1/* #include "../rt2860/md5.h"
2 *************************************************************************
3 * Ralink Tech Inc.
4 * 5F., No.36, Taiyuan St., Jhubei City,
5 * Hsinchu County 302,
6 * Taiwan, R.O.C.
7 *
8 * (c) Copyright 2002-2007, Ralink Technology, Inc.
9 *
10 * This program is free software; you can redistribute it and/or modify *
11 * it under the terms of the GNU General Public License as published by *
12 * the Free Software Foundation; either version 2 of the License, or *
13 * (at your option) any later version. *
14 * *
15 * This program is distributed in the hope that it will be useful, *
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
18 * GNU General Public License for more details. *
19 * *
20 * You should have received a copy of the GNU General Public License *
21 * along with this program; if not, write to the *
22 * Free Software Foundation, Inc., *
23 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
24 * *
25 *************************************************************************
26
27 Module Name:
28 md5.h
29
30 Abstract:
31
32 Revision History:
33 Who When What
34 -------- ---------- ----------------------------------------------
35 Name Date Modification logs
36 jan 10-28-03 Initial
37 Rita 11-23-04 Modify MD5 and SHA-1
38*/
39
40#ifndef uint8
41#define uint8 unsigned char
42#endif
43
44#ifndef uint32
45#define uint32 unsigned long int
46#endif
47
48
49#ifndef __MD5_H__
50#define __MD5_H__
51
52#define MD5_MAC_LEN 16
53
54typedef struct _MD5_CTX {
55 UINT32 Buf[4]; // buffers of four states
56 UCHAR Input[64]; // input message
57 UINT32 LenInBitCount[2]; // length counter for input message, 0 up to 64 bits
58} MD5_CTX;
59
60VOID MD5Init(MD5_CTX *pCtx);
61VOID MD5Update(MD5_CTX *pCtx, UCHAR *pData, UINT32 LenInBytes);
62VOID MD5Final(UCHAR Digest[16], MD5_CTX *pCtx);
63VOID MD5Transform(UINT32 Buf[4], UINT32 Mes[16]);
64
65void md5_mac(u8 *key, size_t key_len, u8 *data, size_t data_len, u8 *mac);
66void hmac_md5(u8 *key, size_t key_len, u8 *data, size_t data_len, u8 *mac);
67
68//
69// SHA context
70//
71typedef struct _SHA_CTX
72{
73 UINT32 Buf[5]; // buffers of five states
74 UCHAR Input[80]; // input message
75 UINT32 LenInBitCount[2]; // length counter for input message, 0 up to 64 bits
76
77} SHA_CTX;
78
79VOID SHAInit(SHA_CTX *pCtx);
80UCHAR SHAUpdate(SHA_CTX *pCtx, UCHAR *pData, UINT32 LenInBytes);
81VOID SHAFinal(SHA_CTX *pCtx, UCHAR Digest[20]);
82VOID SHATransform(UINT32 Buf[5], UINT32 Mes[20]);
83
84#define SHA_DIGEST_LEN 20
85#endif // __MD5_H__
86
87/******************************************************************************/
88#ifndef _AES_H
89#define _AES_H
90
91typedef struct
92{
93 uint32 erk[64]; /* encryption round keys */
94 uint32 drk[64]; /* decryption round keys */
95 int nr; /* number of rounds */
96}
97aes_context;
98
99int rtmp_aes_set_key( aes_context *ctx, uint8 *key, int nbits );
100void rtmp_aes_encrypt( aes_context *ctx, uint8 input[16], uint8 output[16] );
101void rtmp_aes_decrypt( aes_context *ctx, uint8 input[16], uint8 output[16] );
102
103void F(char *password, unsigned char *ssid, int ssidlength, int iterations, int count, unsigned char *output);
104int PasswordHash(char *password, unsigned char *ssid, int ssidlength, unsigned char *output);
105
106#endif /* aes.h */
107
diff --git a/drivers/staging/rt2870/mlme.h b/drivers/staging/rt2870/mlme.h
index 3d1a8284fbd4..58753ac441de 100644
--- a/drivers/staging/rt2870/mlme.h
+++ b/drivers/staging/rt2870/mlme.h
@@ -1,1138 +1 @@
1/* #include "../rt2860/mlme.h"
2 *************************************************************************
3 * Ralink Tech Inc.
4 * 5F., No.36, Taiyuan St., Jhubei City,
5 * Hsinchu County 302,
6 * Taiwan, R.O.C.
7 *
8 * (c) Copyright 2002-2007, Ralink Technology, Inc.
9 *
10 * This program is free software; you can redistribute it and/or modify *
11 * it under the terms of the GNU General Public License as published by *
12 * the Free Software Foundation; either version 2 of the License, or *
13 * (at your option) any later version. *
14 * *
15 * This program is distributed in the hope that it will be useful, *
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
18 * GNU General Public License for more details. *
19 * *
20 * You should have received a copy of the GNU General Public License *
21 * along with this program; if not, write to the *
22 * Free Software Foundation, Inc., *
23 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
24 * *
25 *************************************************************************
26
27 Module Name:
28 mlme.h
29
30 Abstract:
31
32 Revision History:
33 Who When What
34 -------- ---------- ----------------------------------------------
35 John Chang 2003-08-28 Created
36 John Chang 2004-09-06 modified for RT2600
37
38*/
39#ifndef __MLME_H__
40#define __MLME_H__
41
42// maximum supported capability information -
43// ESS, IBSS, Privacy, Short Preamble, Spectrum mgmt, Short Slot
44#define SUPPORTED_CAPABILITY_INFO 0x0533
45
46#define END_OF_ARGS -1
47#define LFSR_MASK 0x80000057
48#define MLME_TASK_EXEC_INTV 100/*200*/ //
49#define LEAD_TIME 5
50#define MLME_TASK_EXEC_MULTIPLE 10 /*5*/ // MLME_TASK_EXEC_MULTIPLE * MLME_TASK_EXEC_INTV = 1 sec
51#define REORDER_EXEC_INTV 100 // 0.1 sec
52
53// The definition of Radar detection duration region
54#define CE 0
55#define FCC 1
56#define JAP 2
57#define JAP_W53 3
58#define JAP_W56 4
59#define MAX_RD_REGION 5
60
61#ifdef NDIS51_MINIPORT
62#define BEACON_LOST_TIME 4000 // 2048 msec = 2 sec
63#else
64#define BEACON_LOST_TIME 4 * OS_HZ // 2048 msec = 2 sec
65#endif
66
67#define DLS_TIMEOUT 1200 // unit: msec
68#define AUTH_TIMEOUT 300 // unit: msec
69#define ASSOC_TIMEOUT 300 // unit: msec
70#define JOIN_TIMEOUT 2 * OS_HZ // unit: msec
71#define SHORT_CHANNEL_TIME 90 // unit: msec
72#define MIN_CHANNEL_TIME 110 // unit: msec, for dual band scan
73#define MAX_CHANNEL_TIME 140 // unit: msec, for single band scan
74#define FAST_ACTIVE_SCAN_TIME 30 // Active scan waiting for probe response time
75#define CW_MIN_IN_BITS 4 // actual CwMin = 2^CW_MIN_IN_BITS - 1
76#define CW_MAX_IN_BITS 10 // actual CwMax = 2^CW_MAX_IN_BITS - 1
77
78// Note: RSSI_TO_DBM_OFFSET has been changed to variable for new RF (2004-0720).
79// SHould not refer to this constant anymore
80//#define RSSI_TO_DBM_OFFSET 120 // for RT2530 RSSI-115 = dBm
81#define RSSI_FOR_MID_TX_POWER -55 // -55 db is considered mid-distance
82#define RSSI_FOR_LOW_TX_POWER -45 // -45 db is considered very short distance and
83 // eligible to use a lower TX power
84#define RSSI_FOR_LOWEST_TX_POWER -30
85//#define MID_TX_POWER_DELTA 0 // 0 db from full TX power upon mid-distance to AP
86#define LOW_TX_POWER_DELTA 6 // -3 db from full TX power upon very short distance. 1 grade is 0.5 db
87#define LOWEST_TX_POWER_DELTA 16 // -8 db from full TX power upon shortest distance. 1 grade is 0.5 db
88
89#define RSSI_TRIGGERED_UPON_BELOW_THRESHOLD 0
90#define RSSI_TRIGGERED_UPON_EXCCEED_THRESHOLD 1
91#define RSSI_THRESHOLD_FOR_ROAMING 25
92#define RSSI_DELTA 5
93
94// Channel Quality Indication
95#define CQI_IS_GOOD(cqi) ((cqi) >= 50)
96//#define CQI_IS_FAIR(cqi) (((cqi) >= 20) && ((cqi) < 50))
97#define CQI_IS_POOR(cqi) (cqi < 50) //(((cqi) >= 5) && ((cqi) < 20))
98#define CQI_IS_BAD(cqi) (cqi < 5)
99#define CQI_IS_DEAD(cqi) (cqi == 0)
100
101// weighting factor to calculate Channel quality, total should be 100%
102#define RSSI_WEIGHTING 50
103#define TX_WEIGHTING 30
104#define RX_WEIGHTING 20
105
106#define BSS_NOT_FOUND 0xFFFFFFFF
107
108#define MAX_LEN_OF_MLME_QUEUE 40 //10
109
110#define SCAN_PASSIVE 18 // scan with no probe request, only wait beacon and probe response
111#define SCAN_ACTIVE 19 // scan with probe request, and wait beacon and probe response
112#define SCAN_CISCO_PASSIVE 20 // Single channel passive scan
113#define SCAN_CISCO_ACTIVE 21 // Single channel active scan
114#define SCAN_CISCO_NOISE 22 // Single channel passive scan for noise histogram collection
115#define SCAN_CISCO_CHANNEL_LOAD 23 // Single channel passive scan for channel load collection
116#define FAST_SCAN_ACTIVE 24 // scan with probe request, and wait beacon and probe response
117
118#define MAC_ADDR_IS_GROUP(Addr) (((Addr[0]) & 0x01))
119#define MAC_ADDR_HASH(Addr) (Addr[0] ^ Addr[1] ^ Addr[2] ^ Addr[3] ^ Addr[4] ^ Addr[5])
120#define MAC_ADDR_HASH_INDEX(Addr) (MAC_ADDR_HASH(Addr) % HASH_TABLE_SIZE)
121#define TID_MAC_HASH(Addr,TID) (TID^Addr[0] ^ Addr[1] ^ Addr[2] ^ Addr[3] ^ Addr[4] ^ Addr[5])
122#define TID_MAC_HASH_INDEX(Addr,TID) (TID_MAC_HASH(Addr,TID) % HASH_TABLE_SIZE)
123
124// LED Control
125// assoiation ON. one LED ON. another blinking when TX, OFF when idle
126// no association, both LED off
127#define ASIC_LED_ACT_ON(pAd) RTMP_IO_WRITE32(pAd, MAC_CSR14, 0x00031e46)
128#define ASIC_LED_ACT_OFF(pAd) RTMP_IO_WRITE32(pAd, MAC_CSR14, 0x00001e46)
129
130// bit definition of the 2-byte pBEACON->Capability field
131#define CAP_IS_ESS_ON(x) (((x) & 0x0001) != 0)
132#define CAP_IS_IBSS_ON(x) (((x) & 0x0002) != 0)
133#define CAP_IS_CF_POLLABLE_ON(x) (((x) & 0x0004) != 0)
134#define CAP_IS_CF_POLL_REQ_ON(x) (((x) & 0x0008) != 0)
135#define CAP_IS_PRIVACY_ON(x) (((x) & 0x0010) != 0)
136#define CAP_IS_SHORT_PREAMBLE_ON(x) (((x) & 0x0020) != 0)
137#define CAP_IS_PBCC_ON(x) (((x) & 0x0040) != 0)
138#define CAP_IS_AGILITY_ON(x) (((x) & 0x0080) != 0)
139#define CAP_IS_SPECTRUM_MGMT(x) (((x) & 0x0100) != 0) // 802.11e d9
140#define CAP_IS_QOS(x) (((x) & 0x0200) != 0) // 802.11e d9
141#define CAP_IS_SHORT_SLOT(x) (((x) & 0x0400) != 0)
142#define CAP_IS_APSD(x) (((x) & 0x0800) != 0) // 802.11e d9
143#define CAP_IS_IMMED_BA(x) (((x) & 0x1000) != 0) // 802.11e d9
144#define CAP_IS_DSSS_OFDM(x) (((x) & 0x2000) != 0)
145#define CAP_IS_DELAY_BA(x) (((x) & 0x4000) != 0) // 802.11e d9
146
147#define CAP_GENERATE(ess,ibss,priv,s_pre,s_slot,spectrum) (((ess) ? 0x0001 : 0x0000) | ((ibss) ? 0x0002 : 0x0000) | ((priv) ? 0x0010 : 0x0000) | ((s_pre) ? 0x0020 : 0x0000) | ((s_slot) ? 0x0400 : 0x0000) | ((spectrum) ? 0x0100 : 0x0000))
148
149#define ERP_IS_NON_ERP_PRESENT(x) (((x) & 0x01) != 0) // 802.11g
150#define ERP_IS_USE_PROTECTION(x) (((x) & 0x02) != 0) // 802.11g
151#define ERP_IS_USE_BARKER_PREAMBLE(x) (((x) & 0x04) != 0) // 802.11g
152
153#define DRS_TX_QUALITY_WORST_BOUND 8// 3 // just test by gary
154#define DRS_PENALTY 8
155
156#define BA_NOTUSE 2
157//BA Policy subfiled value in ADDBA frame
158#define IMMED_BA 1
159#define DELAY_BA 0
160
161// BA Initiator subfield in DELBA frame
162#define ORIGINATOR 1
163#define RECIPIENT 0
164
165// ADDBA Status Code
166#define ADDBA_RESULTCODE_SUCCESS 0
167#define ADDBA_RESULTCODE_REFUSED 37
168#define ADDBA_RESULTCODE_INVALID_PARAMETERS 38
169
170// DELBA Reason Code
171#define DELBA_REASONCODE_QSTA_LEAVING 36
172#define DELBA_REASONCODE_END_BA 37
173#define DELBA_REASONCODE_UNKNOWN_BA 38
174#define DELBA_REASONCODE_TIMEOUT 39
175
176// reset all OneSecTx counters
177#define RESET_ONE_SEC_TX_CNT(__pEntry) \
178if (((__pEntry)) != NULL) \
179{ \
180 (__pEntry)->OneSecTxRetryOkCount = 0; \
181 (__pEntry)->OneSecTxFailCount = 0; \
182 (__pEntry)->OneSecTxNoRetryOkCount = 0; \
183}
184
185//
186// 802.11 frame formats
187//
188// HT Capability INFO field in HT Cap IE .
189typedef struct PACKED {
190 USHORT AdvCoding:1;
191 USHORT ChannelWidth:1;
192 USHORT MimoPs:2;//momi power safe
193 USHORT GF:1; //green field
194 USHORT ShortGIfor20:1;
195 USHORT ShortGIfor40:1; //for40MHz
196 USHORT TxSTBC:1;
197 USHORT RxSTBC:2;
198 USHORT DelayedBA:1; //rt2860c not support
199 USHORT AMsduSize:1; // only support as zero
200 USHORT CCKmodein40:1;
201 USHORT PSMP:1;
202 USHORT Forty_Mhz_Intolerant:1;
203 USHORT LSIGTxopProSup:1;
204} HT_CAP_INFO, *PHT_CAP_INFO;
205
206// HT Capability INFO field in HT Cap IE .
207typedef struct PACKED {
208 UCHAR MaxRAmpduFactor:2;
209 UCHAR MpduDensity:3;
210 UCHAR rsv:3;//momi power safe
211} HT_CAP_PARM, *PHT_CAP_PARM;
212
213// HT Capability INFO field in HT Cap IE .
214typedef struct PACKED {
215 UCHAR MCSSet[10];
216 UCHAR SupRate[2]; // unit : 1Mbps
217 UCHAR TxMCSSetDefined:1;
218 UCHAR TxRxNotEqual:1;
219 UCHAR TxStream:2;
220 UCHAR MpduDensity:1;
221 UCHAR rsv:3;
222 UCHAR rsv3[3];
223} HT_MCS_SET, *PHT_MCS_SET;
224
225// HT Capability INFO field in HT Cap IE .
226typedef struct PACKED {
227 USHORT Pco:1;
228 USHORT TranTime:2;
229 USHORT rsv:5;//momi power safe
230 USHORT MCSFeedback:2; //0:no MCS feedback, 2:unsolicited MCS feedback, 3:Full MCS feedback, 1:rsv.
231 USHORT PlusHTC:1; //+HTC control field support
232 USHORT RDGSupport:1; //reverse Direction Grant support
233 USHORT rsv2:4;
234} EXT_HT_CAP_INFO, *PEXT_HT_CAP_INFO;
235
236// HT Beamforming field in HT Cap IE .
237typedef struct PACKED _HT_BF_CAP{
238 ULONG TxBFRecCapable:1;
239 ULONG RxSoundCapable:1;
240 ULONG TxSoundCapable:1;
241 ULONG RxNDPCapable:1;
242 ULONG TxNDPCapable:1;
243 ULONG ImpTxBFCapable:1;
244 ULONG Calibration:2;
245 ULONG ExpCSICapable:1;
246 ULONG ExpNoComSteerCapable:1;
247 ULONG ExpComSteerCapable:1;
248 ULONG ExpCSIFbk:2;
249 ULONG ExpNoComBF:2;
250 ULONG ExpComBF:2;
251 ULONG MinGrouping:2;
252 ULONG CSIBFAntSup:2;
253 ULONG NoComSteerBFAntSup:2;
254 ULONG ComSteerBFAntSup:2;
255 ULONG CSIRowBFSup:2;
256 ULONG ChanEstimation:2;
257 ULONG rsv:3;
258} HT_BF_CAP, *PHT_BF_CAP;
259
260// HT antenna selection field in HT Cap IE .
261typedef struct PACKED _HT_AS_CAP{
262 UCHAR AntSelect:1;
263 UCHAR ExpCSIFbkTxASEL:1;
264 UCHAR AntIndFbkTxASEL:1;
265 UCHAR ExpCSIFbk:1;
266 UCHAR AntIndFbk:1;
267 UCHAR RxASel:1;
268 UCHAR TxSoundPPDU:1;
269 UCHAR rsv:1;
270} HT_AS_CAP, *PHT_AS_CAP;
271
272// Draft 1.0 set IE length 26, but is extensible..
273#define SIZE_HT_CAP_IE 26
274// The structure for HT Capability IE.
275typedef struct PACKED _HT_CAPABILITY_IE{
276 HT_CAP_INFO HtCapInfo;
277 HT_CAP_PARM HtCapParm;
278// HT_MCS_SET HtMCSSet;
279 UCHAR MCSSet[16];
280 EXT_HT_CAP_INFO ExtHtCapInfo;
281 HT_BF_CAP TxBFCap; // beamforming cap. rt2860c not support beamforming.
282 HT_AS_CAP ASCap; //antenna selection.
283} HT_CAPABILITY_IE, *PHT_CAPABILITY_IE;
284
285
286// 802.11n draft3 related structure definitions.
287// 7.3.2.60
288#define dot11OBSSScanPassiveDwell 20 // in TU. min amount of time that the STA continously scans each channel when performing an active OBSS scan.
289#define dot11OBSSScanActiveDwell 10 // in TU.min amount of time that the STA continously scans each channel when performing an passive OBSS scan.
290#define dot11BSSWidthTriggerScanInterval 300 // in sec. max interval between scan operations to be performed to detect BSS channel width trigger events.
291#define dot11OBSSScanPassiveTotalPerChannel 200 // in TU. min total amount of time that the STA scans each channel when performing a passive OBSS scan.
292#define dot11OBSSScanActiveTotalPerChannel 20 //in TU. min total amount of time that the STA scans each channel when performing a active OBSS scan
293#define dot11BSSWidthChannelTransactionDelayFactor 5 // min ratio between the delay time in performing a switch from 20MHz BSS to 20/40 BSS operation and the maxima
294 // interval between overlapping BSS scan operations.
295#define dot11BSSScanActivityThreshold 25 // in %%, max total time that a STA may be active on the medium during a period of
296 // (dot11BSSWidthChannelTransactionDelayFactor * dot11BSSWidthTriggerScanInterval) seconds without
297 // being obligated to perform OBSS Scan operations. default is 25(== 0.25%)
298
299typedef struct PACKED _OVERLAP_BSS_SCAN_IE{
300 USHORT ScanPassiveDwell;
301 USHORT ScanActiveDwell;
302 USHORT TriggerScanInt; // Trigger scan interval
303 USHORT PassiveTalPerChannel; // passive total per channel
304 USHORT ActiveTalPerChannel; // active total per channel
305 USHORT DelayFactor; // BSS width channel transition delay factor
306 USHORT ScanActThre; // Scan Activity threshold
307}OVERLAP_BSS_SCAN_IE, *POVERLAP_BSS_SCAN_IE;
308
309
310// 7.3.2.56. 20/40 Coexistence element used in Element ID = 72 = IE_2040_BSS_COEXIST
311typedef union PACKED _BSS_2040_COEXIST_IE{
312 struct PACKED {
313 UCHAR InfoReq:1;
314 UCHAR Intolerant40:1; // Inter-BSS. set 1 when prohibits a receiving BSS from operating as a 20/40 Mhz BSS.
315 UCHAR BSS20WidthReq:1; // Intra-BSS set 1 when prohibits a receiving AP from operating its BSS as a 20/40MHz BSS.
316 UCHAR rsv:5;
317 } field;
318 UCHAR word;
319} BSS_2040_COEXIST_IE, *PBSS_2040_COEXIST_IE;
320
321
322typedef struct _TRIGGER_EVENTA{
323 BOOLEAN bValid;
324 UCHAR BSSID[6];
325 UCHAR RegClass; // Regulatory Class
326 USHORT Channel;
327 ULONG CDCounter; // Maintain a seperate count down counter for each Event A.
328} TRIGGER_EVENTA, *PTRIGGER_EVENTA;
329
330// 20/40 trigger event table
331// If one Event A delete or created, or if Event B is detected or not detected, STA should send 2040BSSCoexistence to AP.
332#define MAX_TRIGGER_EVENT 64
333typedef struct _TRIGGER_EVENT_TAB{
334 UCHAR EventANo;
335 TRIGGER_EVENTA EventA[MAX_TRIGGER_EVENT];
336 ULONG EventBCountDown; // Count down counter for Event B.
337} TRIGGER_EVENT_TAB, *PTRIGGER_EVENT_TAB;
338
339// 7.3.27 20/40 Bss Coexistence Mgmt capability used in extended capabilities information IE( ID = 127 = IE_EXT_CAPABILITY).
340// This is the first octet and was defined in 802.11n D3.03 and 802.11yD9.0
341typedef struct PACKED _EXT_CAP_INFO_ELEMENT{
342 UCHAR BssCoexistMgmtSupport:1;
343 UCHAR rsv:1;
344 UCHAR ExtendChannelSwitch:1;
345 UCHAR rsv2:5;
346}EXT_CAP_INFO_ELEMENT, *PEXT_CAP_INFO_ELEMENT;
347
348
349// 802.11n 7.3.2.61
350typedef struct PACKED _BSS_2040_COEXIST_ELEMENT{
351 UCHAR ElementID; // ID = IE_2040_BSS_COEXIST = 72
352 UCHAR Len;
353 BSS_2040_COEXIST_IE BssCoexistIe;
354}BSS_2040_COEXIST_ELEMENT, *PBSS_2040_COEXIST_ELEMENT;
355
356
357//802.11n 7.3.2.59
358typedef struct PACKED _BSS_2040_INTOLERANT_CH_REPORT{
359 UCHAR ElementID; // ID = IE_2040_BSS_INTOLERANT_REPORT = 73
360 UCHAR Len;
361 UCHAR RegulatoryClass;
362 UCHAR ChList[0];
363}BSS_2040_INTOLERANT_CH_REPORT, *PBSS_2040_INTOLERANT_CH_REPORT;
364
365
366// The structure for channel switch annoucement IE. This is in 802.11n D3.03
367typedef struct PACKED _CHA_SWITCH_ANNOUNCE_IE{
368 UCHAR SwitchMode; //channel switch mode
369 UCHAR NewChannel; //
370 UCHAR SwitchCount; //
371} CHA_SWITCH_ANNOUNCE_IE, *PCHA_SWITCH_ANNOUNCE_IE;
372
373
374// The structure for channel switch annoucement IE. This is in 802.11n D3.03
375typedef struct PACKED _SEC_CHA_OFFSET_IE{
376 UCHAR SecondaryChannelOffset; // 1: Secondary above, 3: Secondary below, 0: no Secondary
377} SEC_CHA_OFFSET_IE, *PSEC_CHA_OFFSET_IE;
378
379
380// This structure is extracted from struct RT_HT_CAPABILITY
381typedef struct {
382 BOOLEAN bHtEnable; // If we should use ht rate.
383 BOOLEAN bPreNHt; // If we should use ht rate.
384 //Substract from HT Capability IE
385 UCHAR MCSSet[16]; //only supoort MCS=0-15,32 ,
386} RT_HT_PHY_INFO, *PRT_HT_PHY_INFO;
387
388//This structure substracts ralink supports from all 802.11n-related features.
389//Features not listed here but contained in 802.11n spec are not supported in rt2860.
390typedef struct {
391 USHORT ChannelWidth:1;
392 USHORT MimoPs:2;//mimo power safe MMPS_
393 USHORT GF:1; //green field
394 USHORT ShortGIfor20:1;
395 USHORT ShortGIfor40:1; //for40MHz
396 USHORT TxSTBC:1;
397 USHORT RxSTBC:2; // 2 bits
398 USHORT AmsduEnable:1; // Enable to transmit A-MSDU. Suggest disable. We should use A-MPDU to gain best benifit of 802.11n
399 USHORT AmsduSize:1; // Max receiving A-MSDU size
400 USHORT rsv:5;
401
402 //Substract from Addiont HT INFO IE
403 UCHAR MaxRAmpduFactor:2;
404 UCHAR MpduDensity:3;
405 UCHAR ExtChanOffset:2; // Please not the difference with following UCHAR NewExtChannelOffset; from 802.11n
406 UCHAR RecomWidth:1;
407
408 USHORT OperaionMode:2;
409 USHORT NonGfPresent:1;
410 USHORT rsv3:1;
411 USHORT OBSS_NonHTExist:1;
412 USHORT rsv2:11;
413
414 // New Extension Channel Offset IE
415 UCHAR NewExtChannelOffset;
416 // Extension Capability IE = 127
417 UCHAR BSSCoexist2040;
418} RT_HT_CAPABILITY, *PRT_HT_CAPABILITY;
419
420// field in Addtional HT Information IE .
421typedef struct PACKED {
422 UCHAR ExtChanOffset:2;
423 UCHAR RecomWidth:1;
424 UCHAR RifsMode:1;
425 UCHAR S_PSMPSup:1; //Indicate support for scheduled PSMP
426 UCHAR SerInterGranu:3; //service interval granularity
427} ADD_HTINFO, *PADD_HTINFO;
428
429typedef struct PACKED{
430 USHORT OperaionMode:2;
431 USHORT NonGfPresent:1;
432 USHORT rsv:1;
433 USHORT OBSS_NonHTExist:1;
434 USHORT rsv2:11;
435} ADD_HTINFO2, *PADD_HTINFO2;
436
437
438// TODO: Need sync with spec about the definition of StbcMcs. In Draft 3.03, it's reserved.
439typedef struct PACKED{
440 USHORT StbcMcs:6;
441 USHORT DualBeacon:1;
442 USHORT DualCTSProtect:1;
443 USHORT STBCBeacon:1;
444 USHORT LsigTxopProt:1; // L-SIG TXOP protection full support
445 USHORT PcoActive:1;
446 USHORT PcoPhase:1;
447 USHORT rsv:4;
448} ADD_HTINFO3, *PADD_HTINFO3;
449
450#define SIZE_ADD_HT_INFO_IE 22
451typedef struct PACKED{
452 UCHAR ControlChan;
453 ADD_HTINFO AddHtInfo;
454 ADD_HTINFO2 AddHtInfo2;
455 ADD_HTINFO3 AddHtInfo3;
456 UCHAR MCSSet[16]; // Basic MCS set
457} ADD_HT_INFO_IE, *PADD_HT_INFO_IE;
458
459typedef struct PACKED{
460 UCHAR NewExtChanOffset;
461} NEW_EXT_CHAN_IE, *PNEW_EXT_CHAN_IE;
462
463
464// 4-byte HTC field. maybe included in any frame except non-QOS data frame. The Order bit must set 1.
465typedef struct PACKED {
466 UINT32 MA:1; //management action payload exist in (QoS Null+HTC)
467 UINT32 TRQ:1; //sounding request
468 UINT32 MRQ:1; //MCS feedback. Request for a MCS feedback
469 UINT32 MRSorASI:3; // MRQ Sequence identifier. unchanged during entire procedure. 0x000-0x110.
470 UINT32 MFS:3; //SET to the received value of MRS. 0x111 for unsolicited MFB.
471 UINT32 MFBorASC:7; //Link adaptation feedback containing recommended MCS. 0x7f for no feedback or not available
472 UINT32 CalPos:2; // calibration position
473 UINT32 CalSeq:2; //calibration sequence
474 UINT32 FBKReq:2; //feedback request
475 UINT32 CSISTEERING:2; //CSI/ STEERING
476 UINT32 ZLFAnnouce:1; // ZLF announcement
477 UINT32 rsv:5; //calibration sequence
478 UINT32 ACConstraint:1; //feedback request
479 UINT32 RDG:1; //RDG / More PPDU
480} HT_CONTROL, *PHT_CONTROL;
481
482// 2-byte QOS CONTROL field
483typedef struct PACKED {
484 USHORT TID:4;
485 USHORT EOSP:1;
486 USHORT AckPolicy:2; //0: normal ACK 1:No ACK 2:scheduled under MTBA/PSMP 3: BA
487 USHORT AMsduPresent:1;
488 USHORT Txop_QueueSize:8;
489} QOS_CONTROL, *PQOS_CONTROL;
490
491// 2-byte Frame control field
492typedef struct PACKED {
493 USHORT Ver:2; // Protocol version
494 USHORT Type:2; // MSDU type
495 USHORT SubType:4; // MSDU subtype
496 USHORT ToDs:1; // To DS indication
497 USHORT FrDs:1; // From DS indication
498 USHORT MoreFrag:1; // More fragment bit
499 USHORT Retry:1; // Retry status bit
500 USHORT PwrMgmt:1; // Power management bit
501 USHORT MoreData:1; // More data bit
502 USHORT Wep:1; // Wep data
503 USHORT Order:1; // Strict order expected
504} FRAME_CONTROL, *PFRAME_CONTROL;
505
506typedef struct PACKED _HEADER_802_11 {
507 FRAME_CONTROL FC;
508 USHORT Duration;
509 UCHAR Addr1[MAC_ADDR_LEN];
510 UCHAR Addr2[MAC_ADDR_LEN];
511 UCHAR Addr3[MAC_ADDR_LEN];
512 USHORT Frag:4;
513 USHORT Sequence:12;
514 UCHAR Octet[0];
515} HEADER_802_11, *PHEADER_802_11;
516
517typedef struct PACKED _FRAME_802_11 {
518 HEADER_802_11 Hdr;
519 UCHAR Octet[1];
520} FRAME_802_11, *PFRAME_802_11;
521
522// QoSNull embedding of management action. When HT Control MA field set to 1.
523typedef struct PACKED _MA_BODY {
524 UCHAR Category;
525 UCHAR Action;
526 UCHAR Octet[1];
527} MA_BODY, *PMA_BODY;
528
529typedef struct PACKED _HEADER_802_3 {
530 UCHAR DAAddr1[MAC_ADDR_LEN];
531 UCHAR SAAddr2[MAC_ADDR_LEN];
532 UCHAR Octet[2];
533} HEADER_802_3, *PHEADER_802_3;
534////Block ACK related format
535// 2-byte BA Parameter field in DELBA frames to terminate an already set up bA
536typedef struct PACKED{
537 USHORT Rsv:11; // always set to 0
538 USHORT Initiator:1; // 1: originator 0:recipient
539 USHORT TID:4; // value of TC os TS
540} DELBA_PARM, *PDELBA_PARM;
541
542// 2-byte BA Parameter Set field in ADDBA frames to signal parm for setting up a BA
543typedef struct PACKED {
544 USHORT AMSDUSupported:1; // 0: not permitted 1: permitted
545 USHORT BAPolicy:1; // 1: immediately BA 0:delayed BA
546 USHORT TID:4; // value of TC os TS
547 USHORT BufSize:10; // number of buffe of size 2304 octetsr
548} BA_PARM, *PBA_PARM;
549
550// 2-byte BA Starting Seq CONTROL field
551typedef union PACKED {
552 struct PACKED {
553 USHORT FragNum:4; // always set to 0
554 USHORT StartSeq:12; // sequence number of the 1st MSDU for which this BAR is sent
555 } field;
556 USHORT word;
557} BASEQ_CONTROL, *PBASEQ_CONTROL;
558
559//BAControl and BARControl are the same
560// 2-byte BA CONTROL field in BA frame
561typedef struct PACKED {
562 USHORT ACKPolicy:1; // only related to N-Delayed BA. But not support in RT2860b. 0:NormalACK 1:No ACK
563 USHORT MTID:1; //EWC V1.24
564 USHORT Compressed:1;
565 USHORT Rsv:9;
566 USHORT TID:4;
567} BA_CONTROL, *PBA_CONTROL;
568
569// 2-byte BAR CONTROL field in BAR frame
570typedef struct PACKED {
571 USHORT ACKPolicy:1; // 0:normal ack, 1:no ack.
572 USHORT MTID:1; //if this bit1, use FRAME_MTBA_REQ, if 0, use FRAME_BA_REQ
573 USHORT Compressed:1;
574 USHORT Rsv1:9;
575 USHORT TID:4;
576} BAR_CONTROL, *PBAR_CONTROL;
577
578// BARControl in MTBAR frame
579typedef struct PACKED {
580 USHORT ACKPolicy:1;
581 USHORT MTID:1;
582 USHORT Compressed:1;
583 USHORT Rsv1:9;
584 USHORT NumTID:4;
585} MTBAR_CONTROL, *PMTBAR_CONTROL;
586
587typedef struct PACKED {
588 USHORT Rsv1:12;
589 USHORT TID:4;
590} PER_TID_INFO, *PPER_TID_INFO;
591
592typedef struct {
593 PER_TID_INFO PerTID;
594 BASEQ_CONTROL BAStartingSeq;
595} EACH_TID, *PEACH_TID;
596
597
598typedef struct PACKED _PSPOLL_FRAME {
599 FRAME_CONTROL FC;
600 USHORT Aid;
601 UCHAR Bssid[MAC_ADDR_LEN];
602 UCHAR Ta[MAC_ADDR_LEN];
603} PSPOLL_FRAME, *PPSPOLL_FRAME;
604
605typedef struct PACKED _RTS_FRAME {
606 FRAME_CONTROL FC;
607 USHORT Duration;
608 UCHAR Addr1[MAC_ADDR_LEN];
609 UCHAR Addr2[MAC_ADDR_LEN];
610}RTS_FRAME, *PRTS_FRAME;
611
612// BAREQ AND MTBAREQ have the same subtype BAR, 802.11n BAR use compressed bitmap.
613typedef struct PACKED _FRAME_BA_REQ {
614 FRAME_CONTROL FC;
615 USHORT Duration;
616 UCHAR Addr1[MAC_ADDR_LEN];
617 UCHAR Addr2[MAC_ADDR_LEN];
618 BAR_CONTROL BARControl;
619 BASEQ_CONTROL BAStartingSeq;
620} FRAME_BA_REQ, *PFRAME_BA_REQ;
621
622typedef struct PACKED _FRAME_MTBA_REQ {
623 FRAME_CONTROL FC;
624 USHORT Duration;
625 UCHAR Addr1[MAC_ADDR_LEN];
626 UCHAR Addr2[MAC_ADDR_LEN];
627 MTBAR_CONTROL MTBARControl;
628 PER_TID_INFO PerTIDInfo;
629 BASEQ_CONTROL BAStartingSeq;
630} FRAME_MTBA_REQ, *PFRAME_MTBA_REQ;
631
632// Compressed format is mandantory in HT STA
633typedef struct PACKED _FRAME_MTBA {
634 FRAME_CONTROL FC;
635 USHORT Duration;
636 UCHAR Addr1[MAC_ADDR_LEN];
637 UCHAR Addr2[MAC_ADDR_LEN];
638 BA_CONTROL BAControl;
639 BASEQ_CONTROL BAStartingSeq;
640 UCHAR BitMap[8];
641} FRAME_MTBA, *PFRAME_MTBA;
642
643typedef struct PACKED _FRAME_PSMP_ACTION {
644 HEADER_802_11 Hdr;
645 UCHAR Category;
646 UCHAR Action;
647 UCHAR Psmp; // 7.3.1.25
648} FRAME_PSMP_ACTION, *PFRAME_PSMP_ACTION;
649
650typedef struct PACKED _FRAME_ACTION_HDR {
651 HEADER_802_11 Hdr;
652 UCHAR Category;
653 UCHAR Action;
654} FRAME_ACTION_HDR, *PFRAME_ACTION_HDR;
655
656//Action Frame
657//Action Frame Category:Spectrum, Action:Channel Switch. 7.3.2.20
658typedef struct PACKED _CHAN_SWITCH_ANNOUNCE {
659 UCHAR ElementID; // ID = IE_CHANNEL_SWITCH_ANNOUNCEMENT = 37
660 UCHAR Len;
661 CHA_SWITCH_ANNOUNCE_IE CSAnnounceIe;
662} CHAN_SWITCH_ANNOUNCE, *PCHAN_SWITCH_ANNOUNCE;
663
664
665//802.11n : 7.3.2.20a
666typedef struct PACKED _SECOND_CHAN_OFFSET {
667 UCHAR ElementID; // ID = IE_SECONDARY_CH_OFFSET = 62
668 UCHAR Len;
669 SEC_CHA_OFFSET_IE SecChOffsetIe;
670} SECOND_CHAN_OFFSET, *PSECOND_CHAN_OFFSET;
671
672
673typedef struct PACKED _FRAME_SPETRUM_CS {
674 HEADER_802_11 Hdr;
675 UCHAR Category;
676 UCHAR Action;
677 CHAN_SWITCH_ANNOUNCE CSAnnounce;
678 SECOND_CHAN_OFFSET SecondChannel;
679} FRAME_SPETRUM_CS, *PFRAME_SPETRUM_CS;
680
681
682typedef struct PACKED _FRAME_ADDBA_REQ {
683 HEADER_802_11 Hdr;
684 UCHAR Category;
685 UCHAR Action;
686 UCHAR Token; // 1
687 BA_PARM BaParm; // 2 - 10
688 USHORT TimeOutValue; // 0 - 0
689 BASEQ_CONTROL BaStartSeq; // 0-0
690} FRAME_ADDBA_REQ, *PFRAME_ADDBA_REQ;
691
692typedef struct PACKED _FRAME_ADDBA_RSP {
693 HEADER_802_11 Hdr;
694 UCHAR Category;
695 UCHAR Action;
696 UCHAR Token;
697 USHORT StatusCode;
698 BA_PARM BaParm; //0 - 2
699 USHORT TimeOutValue;
700} FRAME_ADDBA_RSP, *PFRAME_ADDBA_RSP;
701
702typedef struct PACKED _FRAME_DELBA_REQ {
703 HEADER_802_11 Hdr;
704 UCHAR Category;
705 UCHAR Action;
706 DELBA_PARM DelbaParm;
707 USHORT ReasonCode;
708} FRAME_DELBA_REQ, *PFRAME_DELBA_REQ;
709
710
711//7.2.1.7
712typedef struct PACKED _FRAME_BAR {
713 FRAME_CONTROL FC;
714 USHORT Duration;
715 UCHAR Addr1[MAC_ADDR_LEN];
716 UCHAR Addr2[MAC_ADDR_LEN];
717 BAR_CONTROL BarControl;
718 BASEQ_CONTROL StartingSeq;
719} FRAME_BAR, *PFRAME_BAR;
720
721//7.2.1.7
722typedef struct PACKED _FRAME_BA {
723 FRAME_CONTROL FC;
724 USHORT Duration;
725 UCHAR Addr1[MAC_ADDR_LEN];
726 UCHAR Addr2[MAC_ADDR_LEN];
727 BAR_CONTROL BarControl;
728 BASEQ_CONTROL StartingSeq;
729 UCHAR bitmask[8];
730} FRAME_BA, *PFRAME_BA;
731
732
733// Radio Measuement Request Frame Format
734typedef struct PACKED _FRAME_RM_REQ_ACTION {
735 HEADER_802_11 Hdr;
736 UCHAR Category;
737 UCHAR Action;
738 UCHAR Token;
739 USHORT Repetition;
740 UCHAR data[0];
741} FRAME_RM_REQ_ACTION, *PFRAME_RM_REQ_ACTION;
742
743typedef struct PACKED {
744 UCHAR ID;
745 UCHAR Length;
746 UCHAR ChannelSwitchMode;
747 UCHAR NewRegClass;
748 UCHAR NewChannelNum;
749 UCHAR ChannelSwitchCount;
750} HT_EXT_CHANNEL_SWITCH_ANNOUNCEMENT_IE, *PHT_EXT_CHANNEL_SWITCH_ANNOUNCEMENT_IE;
751
752
753//
754// _Limit must be the 2**n - 1
755// _SEQ1 , _SEQ2 must be within 0 ~ _Limit
756//
757#define SEQ_STEPONE(_SEQ1, _SEQ2, _Limit) ((_SEQ1 == ((_SEQ2+1) & _Limit)))
758#define SEQ_SMALLER(_SEQ1, _SEQ2, _Limit) (((_SEQ1-_SEQ2) & ((_Limit+1)>>1)))
759#define SEQ_LARGER(_SEQ1, _SEQ2, _Limit) ((_SEQ1 != _SEQ2) && !(((_SEQ1-_SEQ2) & ((_Limit+1)>>1))))
760#define SEQ_WITHIN_WIN(_SEQ1, _SEQ2, _WIN, _Limit) (SEQ_LARGER(_SEQ1, _SEQ2, _Limit) && \
761 SEQ_SMALLER(_SEQ1, ((_SEQ2+_WIN+1)&_Limit), _Limit))
762
763//
764// Contention-free parameter (without ID and Length)
765//
766typedef struct PACKED {
767 BOOLEAN bValid; // 1: variable contains valid value
768 UCHAR CfpCount;
769 UCHAR CfpPeriod;
770 USHORT CfpMaxDuration;
771 USHORT CfpDurRemaining;
772} CF_PARM, *PCF_PARM;
773
774typedef struct _CIPHER_SUITE {
775 NDIS_802_11_ENCRYPTION_STATUS PairCipher; // Unicast cipher 1, this one has more secured cipher suite
776 NDIS_802_11_ENCRYPTION_STATUS PairCipherAux; // Unicast cipher 2 if AP announce two unicast cipher suite
777 NDIS_802_11_ENCRYPTION_STATUS GroupCipher; // Group cipher
778 USHORT RsnCapability; // RSN capability from beacon
779 BOOLEAN bMixMode; // Indicate Pair & Group cipher might be different
780} CIPHER_SUITE, *PCIPHER_SUITE;
781
782// EDCA configuration from AP's BEACON/ProbeRsp
783typedef struct {
784 BOOLEAN bValid; // 1: variable contains valid value
785 BOOLEAN bAdd; // 1: variable contains valid value
786 BOOLEAN bQAck;
787 BOOLEAN bQueueRequest;
788 BOOLEAN bTxopRequest;
789 BOOLEAN bAPSDCapable;
790// BOOLEAN bMoreDataAck;
791 UCHAR EdcaUpdateCount;
792 UCHAR Aifsn[4]; // 0:AC_BK, 1:AC_BE, 2:AC_VI, 3:AC_VO
793 UCHAR Cwmin[4];
794 UCHAR Cwmax[4];
795 USHORT Txop[4]; // in unit of 32-us
796 BOOLEAN bACM[4]; // 1: Admission Control of AC_BK is mandattory
797} EDCA_PARM, *PEDCA_PARM;
798
799// QBSS LOAD information from QAP's BEACON/ProbeRsp
800typedef struct {
801 BOOLEAN bValid; // 1: variable contains valid value
802 USHORT StaNum;
803 UCHAR ChannelUtilization;
804 USHORT RemainingAdmissionControl; // in unit of 32-us
805} QBSS_LOAD_PARM, *PQBSS_LOAD_PARM;
806
807// QBSS Info field in QSTA's assoc req
808typedef struct PACKED {
809 UCHAR UAPSD_AC_VO:1;
810 UCHAR UAPSD_AC_VI:1;
811 UCHAR UAPSD_AC_BK:1;
812 UCHAR UAPSD_AC_BE:1;
813 UCHAR Rsv1:1;
814 UCHAR MaxSPLength:2;
815 UCHAR Rsv2:1;
816} QBSS_STA_INFO_PARM, *PQBSS_STA_INFO_PARM;
817
818// QBSS Info field in QAP's Beacon/ProbeRsp
819typedef struct PACKED {
820 UCHAR ParamSetCount:4;
821 UCHAR Rsv:3;
822 UCHAR UAPSD:1;
823} QBSS_AP_INFO_PARM, *PQBSS_AP_INFO_PARM;
824
825// QOS Capability reported in QAP's BEACON/ProbeRsp
826// QOS Capability sent out in QSTA's AssociateReq/ReAssociateReq
827typedef struct {
828 BOOLEAN bValid; // 1: variable contains valid value
829 BOOLEAN bQAck;
830 BOOLEAN bQueueRequest;
831 BOOLEAN bTxopRequest;
832// BOOLEAN bMoreDataAck;
833 UCHAR EdcaUpdateCount;
834} QOS_CAPABILITY_PARM, *PQOS_CAPABILITY_PARM;
835
836typedef struct {
837 UCHAR IELen;
838 UCHAR IE[MAX_CUSTOM_LEN];
839} WPA_IE_;
840
841typedef struct {
842 UCHAR Bssid[MAC_ADDR_LEN];
843 UCHAR Channel;
844 UCHAR CentralChannel; //Store the wide-band central channel for 40MHz. .used in 40MHz AP. Or this is the same as Channel.
845 UCHAR BssType;
846 USHORT AtimWin;
847 USHORT BeaconPeriod;
848
849 UCHAR SupRate[MAX_LEN_OF_SUPPORTED_RATES];
850 UCHAR SupRateLen;
851 UCHAR ExtRate[MAX_LEN_OF_SUPPORTED_RATES];
852 UCHAR ExtRateLen;
853 HT_CAPABILITY_IE HtCapability;
854 UCHAR HtCapabilityLen;
855 ADD_HT_INFO_IE AddHtInfo; // AP might use this additional ht info IE
856 UCHAR AddHtInfoLen;
857 UCHAR NewExtChanOffset;
858 CHAR Rssi;
859 UCHAR Privacy; // Indicate security function ON/OFF. Don't mess up with auth mode.
860 UCHAR Hidden;
861
862 USHORT DtimPeriod;
863 USHORT CapabilityInfo;
864
865 USHORT CfpCount;
866 USHORT CfpPeriod;
867 USHORT CfpMaxDuration;
868 USHORT CfpDurRemaining;
869 UCHAR SsidLen;
870 CHAR Ssid[MAX_LEN_OF_SSID];
871
872 ULONG LastBeaconRxTime; // OS's timestamp
873
874 BOOLEAN bSES;
875
876 // New for WPA2
877 CIPHER_SUITE WPA; // AP announced WPA cipher suite
878 CIPHER_SUITE WPA2; // AP announced WPA2 cipher suite
879
880 // New for microsoft WPA support
881 NDIS_802_11_FIXED_IEs FixIEs;
882 NDIS_802_11_AUTHENTICATION_MODE AuthModeAux; // Addition mode for WPA2 / WPA capable AP
883 NDIS_802_11_AUTHENTICATION_MODE AuthMode;
884 NDIS_802_11_WEP_STATUS WepStatus; // Unicast Encryption Algorithm extract from VAR_IE
885 USHORT VarIELen; // Length of next VIE include EID & Length
886 UCHAR VarIEs[MAX_VIE_LEN];
887
888 // CCX Ckip information
889 UCHAR CkipFlag;
890
891 // CCX 2 TSF
892 UCHAR PTSF[4]; // Parent TSF
893 UCHAR TTSF[8]; // Target TSF
894
895 // 802.11e d9, and WMM
896 EDCA_PARM EdcaParm;
897 QOS_CAPABILITY_PARM QosCapability;
898 QBSS_LOAD_PARM QbssLoad;
899 WPA_IE_ WpaIE;
900 WPA_IE_ RsnIE;
901} BSS_ENTRY, *PBSS_ENTRY;
902
903typedef struct {
904 UCHAR BssNr;
905 UCHAR BssOverlapNr;
906 BSS_ENTRY BssEntry[MAX_LEN_OF_BSS_TABLE];
907} BSS_TABLE, *PBSS_TABLE;
908
909
910typedef struct _MLME_QUEUE_ELEM {
911 ULONG Machine;
912 ULONG MsgType;
913 ULONG MsgLen;
914 UCHAR Msg[MGMT_DMA_BUFFER_SIZE];
915 LARGE_INTEGER TimeStamp;
916 UCHAR Rssi0;
917 UCHAR Rssi1;
918 UCHAR Rssi2;
919 UCHAR Signal;
920 UCHAR Channel;
921 UCHAR Wcid;
922 BOOLEAN Occupied;
923} MLME_QUEUE_ELEM, *PMLME_QUEUE_ELEM;
924
925typedef struct _MLME_QUEUE {
926 ULONG Num;
927 ULONG Head;
928 ULONG Tail;
929 NDIS_SPIN_LOCK Lock;
930 MLME_QUEUE_ELEM Entry[MAX_LEN_OF_MLME_QUEUE];
931} MLME_QUEUE, *PMLME_QUEUE;
932
933typedef VOID (*STATE_MACHINE_FUNC)(VOID *Adaptor, MLME_QUEUE_ELEM *Elem);
934
935typedef struct _STATE_MACHINE {
936 ULONG Base;
937 ULONG NrState;
938 ULONG NrMsg;
939 ULONG CurrState;
940 STATE_MACHINE_FUNC *TransFunc;
941} STATE_MACHINE, *PSTATE_MACHINE;
942
943
944// MLME AUX data structure that hold temporarliy settings during a connection attempt.
945// Once this attemp succeeds, all settings will be copy to pAd->StaActive.
946// A connection attempt (user set OID, roaming, CCX fast roaming,..) consists of
947// several steps (JOIN, AUTH, ASSOC or REASSOC) and may fail at any step. We purposely
948// separate this under-trial settings away from pAd->StaActive so that once
949// this new attempt failed, driver can auto-recover back to the active settings.
950typedef struct _MLME_AUX {
951 UCHAR BssType;
952 UCHAR Ssid[MAX_LEN_OF_SSID];
953 UCHAR SsidLen;
954 UCHAR Bssid[MAC_ADDR_LEN];
955 UCHAR AutoReconnectSsid[MAX_LEN_OF_SSID];
956 UCHAR AutoReconnectSsidLen;
957 USHORT Alg;
958 UCHAR ScanType;
959 UCHAR Channel;
960 UCHAR CentralChannel;
961 USHORT Aid;
962 USHORT CapabilityInfo;
963 USHORT BeaconPeriod;
964 USHORT CfpMaxDuration;
965 USHORT CfpPeriod;
966 USHORT AtimWin;
967
968 // Copy supported rate from desired AP's beacon. We are trying to match
969 // AP's supported and extended rate settings.
970 UCHAR SupRate[MAX_LEN_OF_SUPPORTED_RATES];
971 UCHAR ExtRate[MAX_LEN_OF_SUPPORTED_RATES];
972 UCHAR SupRateLen;
973 UCHAR ExtRateLen;
974 HT_CAPABILITY_IE HtCapability;
975 UCHAR HtCapabilityLen;
976 ADD_HT_INFO_IE AddHtInfo; // AP might use this additional ht info IE
977 UCHAR NewExtChannelOffset;
978 //RT_HT_CAPABILITY SupportedHtPhy;
979
980 // new for QOS
981 QOS_CAPABILITY_PARM APQosCapability; // QOS capability of the current associated AP
982 EDCA_PARM APEdcaParm; // EDCA parameters of the current associated AP
983 QBSS_LOAD_PARM APQbssLoad; // QBSS load of the current associated AP
984
985 // new to keep Ralink specific feature
986 ULONG APRalinkIe;
987
988 BSS_TABLE SsidBssTab; // AP list for the same SSID
989 BSS_TABLE RoamTab; // AP list eligible for roaming
990 ULONG BssIdx;
991 ULONG RoamIdx;
992
993 BOOLEAN CurrReqIsFromNdis;
994
995 RALINK_TIMER_STRUCT BeaconTimer, ScanTimer;
996 RALINK_TIMER_STRUCT AuthTimer;
997 RALINK_TIMER_STRUCT AssocTimer, ReassocTimer, DisassocTimer;
998} MLME_AUX, *PMLME_AUX;
999
1000typedef struct _MLME_ADDBA_REQ_STRUCT{
1001 UCHAR Wcid; //
1002 UCHAR pAddr[MAC_ADDR_LEN];
1003 UCHAR BaBufSize;
1004 USHORT TimeOutValue;
1005 UCHAR TID;
1006 UCHAR Token;
1007 USHORT BaStartSeq;
1008} MLME_ADDBA_REQ_STRUCT, *PMLME_ADDBA_REQ_STRUCT;
1009
1010
1011typedef struct _MLME_DELBA_REQ_STRUCT{
1012 UCHAR Wcid; //
1013 UCHAR Addr[MAC_ADDR_LEN];
1014 UCHAR TID;
1015 UCHAR Initiator;
1016} MLME_DELBA_REQ_STRUCT, *PMLME_DELBA_REQ_STRUCT;
1017
1018// assoc struct is equal to reassoc
1019typedef struct _MLME_ASSOC_REQ_STRUCT{
1020 UCHAR Addr[MAC_ADDR_LEN];
1021 USHORT CapabilityInfo;
1022 USHORT ListenIntv;
1023 ULONG Timeout;
1024} MLME_ASSOC_REQ_STRUCT, *PMLME_ASSOC_REQ_STRUCT, MLME_REASSOC_REQ_STRUCT, *PMLME_REASSOC_REQ_STRUCT;
1025
1026typedef struct _MLME_DISASSOC_REQ_STRUCT{
1027 UCHAR Addr[MAC_ADDR_LEN];
1028 USHORT Reason;
1029} MLME_DISASSOC_REQ_STRUCT, *PMLME_DISASSOC_REQ_STRUCT;
1030
1031typedef struct _MLME_AUTH_REQ_STRUCT {
1032 UCHAR Addr[MAC_ADDR_LEN];
1033 USHORT Alg;
1034 ULONG Timeout;
1035} MLME_AUTH_REQ_STRUCT, *PMLME_AUTH_REQ_STRUCT;
1036
1037typedef struct _MLME_DEAUTH_REQ_STRUCT {
1038 UCHAR Addr[MAC_ADDR_LEN];
1039 USHORT Reason;
1040} MLME_DEAUTH_REQ_STRUCT, *PMLME_DEAUTH_REQ_STRUCT;
1041
1042typedef struct {
1043 ULONG BssIdx;
1044} MLME_JOIN_REQ_STRUCT;
1045
1046typedef struct _MLME_SCAN_REQ_STRUCT {
1047 UCHAR Bssid[MAC_ADDR_LEN];
1048 UCHAR BssType;
1049 UCHAR ScanType;
1050 UCHAR SsidLen;
1051 CHAR Ssid[MAX_LEN_OF_SSID];
1052} MLME_SCAN_REQ_STRUCT, *PMLME_SCAN_REQ_STRUCT;
1053
1054typedef struct _MLME_START_REQ_STRUCT {
1055 CHAR Ssid[MAX_LEN_OF_SSID];
1056 UCHAR SsidLen;
1057} MLME_START_REQ_STRUCT, *PMLME_START_REQ_STRUCT;
1058
1059typedef struct PACKED {
1060 UCHAR Eid;
1061 UCHAR Len;
1062 CHAR Octet[1];
1063} EID_STRUCT,*PEID_STRUCT, BEACON_EID_STRUCT, *PBEACON_EID_STRUCT;
1064
1065typedef struct PACKED _RTMP_TX_RATE_SWITCH
1066{
1067 UCHAR ItemNo;
1068 UCHAR STBC:1;
1069 UCHAR ShortGI:1;
1070 UCHAR BW:1;
1071 UCHAR Rsv1:1;
1072 UCHAR Mode:2;
1073 UCHAR Rsv2:2;
1074 UCHAR CurrMCS;
1075 UCHAR TrainUp;
1076 UCHAR TrainDown;
1077} RRTMP_TX_RATE_SWITCH, *PRTMP_TX_RATE_SWITCH;
1078
1079// ========================== AP mlme.h ===============================
1080#define TBTT_PRELOAD_TIME 384 // usec. LomgPreamble + 24-byte at 1Mbps
1081#define DEFAULT_DTIM_PERIOD 1
1082
1083#define MAC_TABLE_AGEOUT_TIME 300 // unit: sec
1084#define MAC_TABLE_ASSOC_TIMEOUT 5 // unit: sec
1085#define MAC_TABLE_FULL(Tab) ((Tab).size == MAX_LEN_OF_MAC_TABLE)
1086
1087// AP shall drop the sta if contine Tx fail count reach it.
1088#define MAC_ENTRY_LIFE_CHECK_CNT 20 // packet cnt.
1089
1090// Value domain of pMacEntry->Sst
1091typedef enum _Sst {
1092 SST_NOT_AUTH, // 0: equivalent to IEEE 802.11/1999 state 1
1093 SST_AUTH, // 1: equivalent to IEEE 802.11/1999 state 2
1094 SST_ASSOC // 2: equivalent to IEEE 802.11/1999 state 3
1095} SST;
1096
1097// value domain of pMacEntry->AuthState
1098typedef enum _AuthState {
1099 AS_NOT_AUTH,
1100 AS_AUTH_OPEN, // STA has been authenticated using OPEN SYSTEM
1101 AS_AUTH_KEY, // STA has been authenticated using SHARED KEY
1102 AS_AUTHENTICATING // STA is waiting for AUTH seq#3 using SHARED KEY
1103} AUTH_STATE;
1104
1105//for-wpa value domain of pMacEntry->WpaState 802.1i D3 p.114
1106typedef enum _ApWpaState {
1107 AS_NOTUSE, // 0
1108 AS_DISCONNECT, // 1
1109 AS_DISCONNECTED, // 2
1110 AS_INITIALIZE, // 3
1111 AS_AUTHENTICATION, // 4
1112 AS_AUTHENTICATION2, // 5
1113 AS_INITPMK, // 6
1114 AS_INITPSK, // 7
1115 AS_PTKSTART, // 8
1116 AS_PTKINIT_NEGOTIATING, // 9
1117 AS_PTKINITDONE, // 10
1118 AS_UPDATEKEYS, // 11
1119 AS_INTEGRITY_FAILURE, // 12
1120 AS_KEYUPDATE, // 13
1121} AP_WPA_STATE;
1122
1123// for-wpa value domain of pMacEntry->WpaState 802.1i D3 p.114
1124typedef enum _GTKState {
1125 REKEY_NEGOTIATING,
1126 REKEY_ESTABLISHED,
1127 KEYERROR,
1128} GTK_STATE;
1129
1130// for-wpa value domain of pMacEntry->WpaState 802.1i D3 p.114
1131typedef enum _WpaGTKState {
1132 SETKEYS,
1133 SETKEYS_DONE,
1134} WPA_GTK_STATE;
1135// ====================== end of AP mlme.h ============================
1136
1137
1138#endif // MLME_H__
diff --git a/drivers/staging/rt2870/oid.h b/drivers/staging/rt2870/oid.h
index b8fb31ba89b3..1223d81bfc62 100644
--- a/drivers/staging/rt2870/oid.h
+++ b/drivers/staging/rt2870/oid.h
@@ -1,952 +1 @@
1/* #include "../rt2860/oid.h"
2 *************************************************************************
3 * Ralink Tech Inc.
4 * 5F., No.36, Taiyuan St., Jhubei City,
5 * Hsinchu County 302,
6 * Taiwan, R.O.C.
7 *
8 * (c) Copyright 2002-2007, Ralink Technology, Inc.
9 *
10 * This program is free software; you can redistribute it and/or modify *
11 * it under the terms of the GNU General Public License as published by *
12 * the Free Software Foundation; either version 2 of the License, or *
13 * (at your option) any later version. *
14 * *
15 * This program is distributed in the hope that it will be useful, *
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
18 * GNU General Public License for more details. *
19 * *
20 * You should have received a copy of the GNU General Public License *
21 * along with this program; if not, write to the *
22 * Free Software Foundation, Inc., *
23 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
24 * *
25 *************************************************************************
26
27 Module Name:
28 oid.h
29
30 Abstract:
31
32 Revision History:
33 Who When What
34 -------- ---------- ----------------------------------------------
35 Name Date Modification logs
36*/
37#ifndef _OID_H_
38#define _OID_H_
39
40#define TRUE 1
41#define FALSE 0
42//
43// IEEE 802.11 Structures and definitions
44//
45#define MAX_TX_POWER_LEVEL 100 /* mW */
46#define MAX_RSSI_TRIGGER -10 /* dBm */
47#define MIN_RSSI_TRIGGER -200 /* dBm */
48#define MAX_FRAG_THRESHOLD 2346 /* byte count */
49#define MIN_FRAG_THRESHOLD 256 /* byte count */
50#define MAX_RTS_THRESHOLD 2347 /* byte count */
51
52// new types for Media Specific Indications
53// Extension channel offset
54#define EXTCHA_NONE 0
55#define EXTCHA_ABOVE 0x1
56#define EXTCHA_BELOW 0x3
57
58// BW
59#define BAND_WIDTH_20 0
60#define BAND_WIDTH_40 1
61#define BAND_WIDTH_BOTH 2
62#define BAND_WIDTH_10 3 // 802.11j has 10MHz. This definition is for internal usage. doesn't fill in the IE or other field.
63// SHORTGI
64#define GAP_INTERVAL_400 1 // only support in HT mode
65#define GAP_INTERVAL_800 0
66#define GAP_INTERVAL_BOTH 2
67
68#define NdisMediaStateConnected 1
69#define NdisMediaStateDisconnected 0
70
71#define NDIS_802_11_LENGTH_SSID 32
72#define NDIS_802_11_LENGTH_RATES 8
73#define NDIS_802_11_LENGTH_RATES_EX 16
74#define MAC_ADDR_LENGTH 6
75#define MAX_NUM_OF_CHS 49 // 14 channels @2.4G + 12@UNII + 4 @MMAC + 11 @HiperLAN2 + 7 @Japan + 1 as NULL terminationc
76#define MAX_NUMBER_OF_EVENT 10 // entry # in EVENT table
77#define MAX_NUMBER_OF_MAC 32 // if MAX_MBSSID_NUM is 8, this value can't be larger than 211
78#define MAX_NUMBER_OF_ACL 64
79#define MAX_LENGTH_OF_SUPPORT_RATES 12 // 1, 2, 5.5, 11, 6, 9, 12, 18, 24, 36, 48, 54
80#define MAX_NUMBER_OF_DLS_ENTRY 4
81
82#define OID_GEN_MACHINE_NAME 0x0001021A
83
84#define RT_QUERY_SIGNAL_CONTEXT 0x0402
85#define RT_SET_IAPP_PID 0x0404
86#define RT_SET_APD_PID 0x0405
87#define RT_SET_DEL_MAC_ENTRY 0x0406
88
89//
90// IEEE 802.11 OIDs
91//
92#define OID_GET_SET_TOGGLE 0x8000
93
94#define OID_802_11_NETWORK_TYPES_SUPPORTED 0x0103
95#define OID_802_11_NETWORK_TYPE_IN_USE 0x0104
96#define OID_802_11_RSSI_TRIGGER 0x0107
97#define RT_OID_802_11_RSSI 0x0108 //rt2860 only , kathy
98#define RT_OID_802_11_RSSI_1 0x0109 //rt2860 only , kathy
99#define RT_OID_802_11_RSSI_2 0x010A //rt2860 only , kathy
100#define OID_802_11_NUMBER_OF_ANTENNAS 0x010B
101#define OID_802_11_RX_ANTENNA_SELECTED 0x010C
102#define OID_802_11_TX_ANTENNA_SELECTED 0x010D
103#define OID_802_11_SUPPORTED_RATES 0x010E
104#define OID_802_11_ADD_WEP 0x0112
105#define OID_802_11_REMOVE_WEP 0x0113
106#define OID_802_11_DISASSOCIATE 0x0114
107#define OID_802_11_PRIVACY_FILTER 0x0118
108#define OID_802_11_ASSOCIATION_INFORMATION 0x011E
109#define OID_802_11_TEST 0x011F
110#define RT_OID_802_11_COUNTRY_REGION 0x0507
111#define OID_802_11_BSSID_LIST_SCAN 0x0508
112#define OID_802_11_SSID 0x0509
113#define OID_802_11_BSSID 0x050A
114#define RT_OID_802_11_RADIO 0x050B
115#define RT_OID_802_11_PHY_MODE 0x050C
116#define RT_OID_802_11_STA_CONFIG 0x050D
117#define OID_802_11_DESIRED_RATES 0x050E
118#define RT_OID_802_11_PREAMBLE 0x050F
119#define OID_802_11_WEP_STATUS 0x0510
120#define OID_802_11_AUTHENTICATION_MODE 0x0511
121#define OID_802_11_INFRASTRUCTURE_MODE 0x0512
122#define RT_OID_802_11_RESET_COUNTERS 0x0513
123#define OID_802_11_RTS_THRESHOLD 0x0514
124#define OID_802_11_FRAGMENTATION_THRESHOLD 0x0515
125#define OID_802_11_POWER_MODE 0x0516
126#define OID_802_11_TX_POWER_LEVEL 0x0517
127#define RT_OID_802_11_ADD_WPA 0x0518
128#define OID_802_11_REMOVE_KEY 0x0519
129#define OID_802_11_ADD_KEY 0x0520
130#define OID_802_11_CONFIGURATION 0x0521
131#define OID_802_11_TX_PACKET_BURST 0x0522
132#define RT_OID_802_11_QUERY_NOISE_LEVEL 0x0523
133#define RT_OID_802_11_EXTRA_INFO 0x0524
134#ifdef DBG
135#define RT_OID_802_11_HARDWARE_REGISTER 0x0525
136#endif
137#define OID_802_11_ENCRYPTION_STATUS OID_802_11_WEP_STATUS
138#define OID_802_11_DEAUTHENTICATION 0x0526
139#define OID_802_11_DROP_UNENCRYPTED 0x0527
140#define OID_802_11_MIC_FAILURE_REPORT_FRAME 0x0528
141
142// For 802.1x daemin using to require current driver configuration
143#define OID_802_11_RADIUS_QUERY_SETTING 0x0540
144
145#define RT_OID_DEVICE_NAME 0x0607
146#define RT_OID_VERSION_INFO 0x0608
147#define OID_802_11_BSSID_LIST 0x0609
148#define OID_802_3_CURRENT_ADDRESS 0x060A
149#define OID_GEN_MEDIA_CONNECT_STATUS 0x060B
150#define RT_OID_802_11_QUERY_LINK_STATUS 0x060C
151#define OID_802_11_RSSI 0x060D
152#define OID_802_11_STATISTICS 0x060E
153#define OID_GEN_RCV_OK 0x060F
154#define OID_GEN_RCV_NO_BUFFER 0x0610
155#define RT_OID_802_11_QUERY_EEPROM_VERSION 0x0611
156#define RT_OID_802_11_QUERY_FIRMWARE_VERSION 0x0612
157#define RT_OID_802_11_QUERY_LAST_RX_RATE 0x0613
158#define RT_OID_802_11_TX_POWER_LEVEL_1 0x0614
159#define RT_OID_802_11_QUERY_PIDVID 0x0615
160
161#define OID_SET_COUNTERMEASURES 0x0616
162#define OID_802_11_SET_IEEE8021X 0x0617
163#define OID_802_11_SET_IEEE8021X_REQUIRE_KEY 0x0618
164#define OID_802_11_PMKID 0x0620
165#define RT_OID_WPA_SUPPLICANT_SUPPORT 0x0621
166#define RT_OID_WE_VERSION_COMPILED 0x0622
167#define RT_OID_NEW_DRIVER 0x0623
168
169
170//rt2860 , kathy
171#define RT_OID_802_11_SNR_0 0x0630
172#define RT_OID_802_11_SNR_1 0x0631
173#define RT_OID_802_11_QUERY_LAST_TX_RATE 0x0632
174#define RT_OID_802_11_QUERY_HT_PHYMODE 0x0633
175#define RT_OID_802_11_SET_HT_PHYMODE 0x0634
176#define OID_802_11_RELOAD_DEFAULTS 0x0635
177#define RT_OID_802_11_QUERY_APSD_SETTING 0x0636
178#define RT_OID_802_11_SET_APSD_SETTING 0x0637
179#define RT_OID_802_11_QUERY_APSD_PSM 0x0638
180#define RT_OID_802_11_SET_APSD_PSM 0x0639
181#define RT_OID_802_11_QUERY_DLS 0x063A
182#define RT_OID_802_11_SET_DLS 0x063B
183#define RT_OID_802_11_QUERY_DLS_PARAM 0x063C
184#define RT_OID_802_11_SET_DLS_PARAM 0x063D
185#define RT_OID_802_11_QUERY_WMM 0x063E
186#define RT_OID_802_11_SET_WMM 0x063F
187#define RT_OID_802_11_QUERY_IMME_BA_CAP 0x0640
188#define RT_OID_802_11_SET_IMME_BA_CAP 0x0641
189#define RT_OID_802_11_QUERY_BATABLE 0x0642
190#define RT_OID_802_11_ADD_IMME_BA 0x0643
191#define RT_OID_802_11_TEAR_IMME_BA 0x0644
192#define RT_OID_DRIVER_DEVICE_NAME 0x0645
193#define RT_OID_802_11_QUERY_DAT_HT_PHYMODE 0x0646
194#define RT_OID_QUERY_MULTIPLE_CARD_SUPPORT 0x0647
195
196// Ralink defined OIDs
197// Dennis Lee move to platform specific
198
199#define RT_OID_802_11_BSSID (OID_GET_SET_TOGGLE | OID_802_11_BSSID)
200#define RT_OID_802_11_SSID (OID_GET_SET_TOGGLE | OID_802_11_SSID)
201#define RT_OID_802_11_INFRASTRUCTURE_MODE (OID_GET_SET_TOGGLE | OID_802_11_INFRASTRUCTURE_MODE)
202#define RT_OID_802_11_ADD_WEP (OID_GET_SET_TOGGLE | OID_802_11_ADD_WEP)
203#define RT_OID_802_11_ADD_KEY (OID_GET_SET_TOGGLE | OID_802_11_ADD_KEY)
204#define RT_OID_802_11_REMOVE_WEP (OID_GET_SET_TOGGLE | OID_802_11_REMOVE_WEP)
205#define RT_OID_802_11_REMOVE_KEY (OID_GET_SET_TOGGLE | OID_802_11_REMOVE_KEY)
206#define RT_OID_802_11_DISASSOCIATE (OID_GET_SET_TOGGLE | OID_802_11_DISASSOCIATE)
207#define RT_OID_802_11_AUTHENTICATION_MODE (OID_GET_SET_TOGGLE | OID_802_11_AUTHENTICATION_MODE)
208#define RT_OID_802_11_PRIVACY_FILTER (OID_GET_SET_TOGGLE | OID_802_11_PRIVACY_FILTER)
209#define RT_OID_802_11_BSSID_LIST_SCAN (OID_GET_SET_TOGGLE | OID_802_11_BSSID_LIST_SCAN)
210#define RT_OID_802_11_WEP_STATUS (OID_GET_SET_TOGGLE | OID_802_11_WEP_STATUS)
211#define RT_OID_802_11_RELOAD_DEFAULTS (OID_GET_SET_TOGGLE | OID_802_11_RELOAD_DEFAULTS)
212#define RT_OID_802_11_NETWORK_TYPE_IN_USE (OID_GET_SET_TOGGLE | OID_802_11_NETWORK_TYPE_IN_USE)
213#define RT_OID_802_11_TX_POWER_LEVEL (OID_GET_SET_TOGGLE | OID_802_11_TX_POWER_LEVEL)
214#define RT_OID_802_11_RSSI_TRIGGER (OID_GET_SET_TOGGLE | OID_802_11_RSSI_TRIGGER)
215#define RT_OID_802_11_FRAGMENTATION_THRESHOLD (OID_GET_SET_TOGGLE | OID_802_11_FRAGMENTATION_THRESHOLD)
216#define RT_OID_802_11_RTS_THRESHOLD (OID_GET_SET_TOGGLE | OID_802_11_RTS_THRESHOLD)
217#define RT_OID_802_11_RX_ANTENNA_SELECTED (OID_GET_SET_TOGGLE | OID_802_11_RX_ANTENNA_SELECTED)
218#define RT_OID_802_11_TX_ANTENNA_SELECTED (OID_GET_SET_TOGGLE | OID_802_11_TX_ANTENNA_SELECTED)
219#define RT_OID_802_11_SUPPORTED_RATES (OID_GET_SET_TOGGLE | OID_802_11_SUPPORTED_RATES)
220#define RT_OID_802_11_DESIRED_RATES (OID_GET_SET_TOGGLE | OID_802_11_DESIRED_RATES)
221#define RT_OID_802_11_CONFIGURATION (OID_GET_SET_TOGGLE | OID_802_11_CONFIGURATION)
222#define RT_OID_802_11_POWER_MODE (OID_GET_SET_TOGGLE | OID_802_11_POWER_MODE)
223
224typedef enum _NDIS_802_11_STATUS_TYPE
225{
226 Ndis802_11StatusType_Authentication,
227 Ndis802_11StatusType_MediaStreamMode,
228 Ndis802_11StatusType_PMKID_CandidateList,
229 Ndis802_11StatusTypeMax // not a real type, defined as an upper bound
230} NDIS_802_11_STATUS_TYPE, *PNDIS_802_11_STATUS_TYPE;
231
232typedef UCHAR NDIS_802_11_MAC_ADDRESS[6];
233
234typedef struct _NDIS_802_11_STATUS_INDICATION
235{
236 NDIS_802_11_STATUS_TYPE StatusType;
237} NDIS_802_11_STATUS_INDICATION, *PNDIS_802_11_STATUS_INDICATION;
238
239// mask for authentication/integrity fields
240#define NDIS_802_11_AUTH_REQUEST_AUTH_FIELDS 0x0f
241
242#define NDIS_802_11_AUTH_REQUEST_REAUTH 0x01
243#define NDIS_802_11_AUTH_REQUEST_KEYUPDATE 0x02
244#define NDIS_802_11_AUTH_REQUEST_PAIRWISE_ERROR 0x06
245#define NDIS_802_11_AUTH_REQUEST_GROUP_ERROR 0x0E
246
247typedef struct _NDIS_802_11_AUTHENTICATION_REQUEST
248{
249 ULONG Length; // Length of structure
250 NDIS_802_11_MAC_ADDRESS Bssid;
251 ULONG Flags;
252} NDIS_802_11_AUTHENTICATION_REQUEST, *PNDIS_802_11_AUTHENTICATION_REQUEST;
253
254//Added new types for PMKID Candidate lists.
255typedef struct _PMKID_CANDIDATE {
256 NDIS_802_11_MAC_ADDRESS BSSID;
257 ULONG Flags;
258} PMKID_CANDIDATE, *PPMKID_CANDIDATE;
259
260typedef struct _NDIS_802_11_PMKID_CANDIDATE_LIST
261{
262 ULONG Version; // Version of the structure
263 ULONG NumCandidates; // No. of pmkid candidates
264 PMKID_CANDIDATE CandidateList[1];
265} NDIS_802_11_PMKID_CANDIDATE_LIST, *PNDIS_802_11_PMKID_CANDIDATE_LIST;
266
267//Flags for PMKID Candidate list structure
268#define NDIS_802_11_PMKID_CANDIDATE_PREAUTH_ENABLED 0x01
269
270// Added new types for OFDM 5G and 2.4G
271typedef enum _NDIS_802_11_NETWORK_TYPE
272{
273 Ndis802_11FH,
274 Ndis802_11DS,
275 Ndis802_11OFDM5,
276 Ndis802_11OFDM5_N,
277 Ndis802_11OFDM24,
278 Ndis802_11OFDM24_N,
279 Ndis802_11Automode,
280 Ndis802_11NetworkTypeMax // not a real type, defined as an upper bound
281} NDIS_802_11_NETWORK_TYPE, *PNDIS_802_11_NETWORK_TYPE;
282
283typedef struct _NDIS_802_11_NETWORK_TYPE_LIST
284{
285 UINT NumberOfItems; // in list below, at least 1
286 NDIS_802_11_NETWORK_TYPE NetworkType [1];
287} NDIS_802_11_NETWORK_TYPE_LIST, *PNDIS_802_11_NETWORK_TYPE_LIST;
288
289typedef enum _NDIS_802_11_POWER_MODE
290{
291 Ndis802_11PowerModeCAM,
292 Ndis802_11PowerModeMAX_PSP,
293 Ndis802_11PowerModeFast_PSP,
294 Ndis802_11PowerModeLegacy_PSP,
295 Ndis802_11PowerModeMax // not a real mode, defined as an upper bound
296} NDIS_802_11_POWER_MODE, *PNDIS_802_11_POWER_MODE;
297
298typedef ULONG NDIS_802_11_TX_POWER_LEVEL; // in milliwatts
299
300//
301// Received Signal Strength Indication
302//
303typedef LONG NDIS_802_11_RSSI; // in dBm
304
305typedef struct _NDIS_802_11_CONFIGURATION_FH
306{
307 ULONG Length; // Length of structure
308 ULONG HopPattern; // As defined by 802.11, MSB set
309 ULONG HopSet; // to one if non-802.11
310 ULONG DwellTime; // units are Kusec
311} NDIS_802_11_CONFIGURATION_FH, *PNDIS_802_11_CONFIGURATION_FH;
312
313typedef struct _NDIS_802_11_CONFIGURATION
314{
315 ULONG Length; // Length of structure
316 ULONG BeaconPeriod; // units are Kusec
317 ULONG ATIMWindow; // units are Kusec
318 ULONG DSConfig; // Frequency, units are kHz
319 NDIS_802_11_CONFIGURATION_FH FHConfig;
320} NDIS_802_11_CONFIGURATION, *PNDIS_802_11_CONFIGURATION;
321
322typedef struct _NDIS_802_11_STATISTICS
323{
324 ULONG Length; // Length of structure
325 LARGE_INTEGER TransmittedFragmentCount;
326 LARGE_INTEGER MulticastTransmittedFrameCount;
327 LARGE_INTEGER FailedCount;
328 LARGE_INTEGER RetryCount;
329 LARGE_INTEGER MultipleRetryCount;
330 LARGE_INTEGER RTSSuccessCount;
331 LARGE_INTEGER RTSFailureCount;
332 LARGE_INTEGER ACKFailureCount;
333 LARGE_INTEGER FrameDuplicateCount;
334 LARGE_INTEGER ReceivedFragmentCount;
335 LARGE_INTEGER MulticastReceivedFrameCount;
336 LARGE_INTEGER FCSErrorCount;
337 LARGE_INTEGER TKIPLocalMICFailures;
338 LARGE_INTEGER TKIPRemoteMICErrors;
339 LARGE_INTEGER TKIPICVErrors;
340 LARGE_INTEGER TKIPCounterMeasuresInvoked;
341 LARGE_INTEGER TKIPReplays;
342 LARGE_INTEGER CCMPFormatErrors;
343 LARGE_INTEGER CCMPReplays;
344 LARGE_INTEGER CCMPDecryptErrors;
345 LARGE_INTEGER FourWayHandshakeFailures;
346} NDIS_802_11_STATISTICS, *PNDIS_802_11_STATISTICS;
347
348typedef ULONG NDIS_802_11_KEY_INDEX;
349typedef ULONGLONG NDIS_802_11_KEY_RSC;
350
351#define MAX_RADIUS_SRV_NUM 2 // 802.1x failover number
352
353typedef struct PACKED _RADIUS_SRV_INFO {
354 UINT32 radius_ip;
355 UINT32 radius_port;
356 UCHAR radius_key[64];
357 UCHAR radius_key_len;
358} RADIUS_SRV_INFO, *PRADIUS_SRV_INFO;
359
360typedef struct PACKED _RADIUS_KEY_INFO
361{
362 UCHAR radius_srv_num;
363 RADIUS_SRV_INFO radius_srv_info[MAX_RADIUS_SRV_NUM];
364 UCHAR ieee8021xWEP; // dynamic WEP
365 UCHAR key_index;
366 UCHAR key_length; // length of key in bytes
367 UCHAR key_material[13];
368} RADIUS_KEY_INFO, *PRADIUS_KEY_INFO;
369
370// It's used by 802.1x daemon to require relative configuration
371typedef struct PACKED _RADIUS_CONF
372{
373 UINT32 Length; // Length of this structure
374 UCHAR mbss_num; // indicate multiple BSS number
375 UINT32 own_ip_addr;
376 UINT32 retry_interval;
377 UINT32 session_timeout_interval;
378 UCHAR EAPifname[IFNAMSIZ];
379 UCHAR EAPifname_len;
380 UCHAR PreAuthifname[IFNAMSIZ];
381 UCHAR PreAuthifname_len;
382 RADIUS_KEY_INFO RadiusInfo[8/*MAX_MBSSID_NUM*/];
383} RADIUS_CONF, *PRADIUS_CONF;
384
385// Key mapping keys require a BSSID
386typedef struct _NDIS_802_11_KEY
387{
388 UINT Length; // Length of this structure
389 UINT KeyIndex;
390 UINT KeyLength; // length of key in bytes
391 NDIS_802_11_MAC_ADDRESS BSSID;
392 NDIS_802_11_KEY_RSC KeyRSC;
393 UCHAR KeyMaterial[1]; // variable length depending on above field
394} NDIS_802_11_KEY, *PNDIS_802_11_KEY;
395
396typedef struct _NDIS_802_11_REMOVE_KEY
397{
398 UINT Length; // Length of this structure
399 UINT KeyIndex;
400 NDIS_802_11_MAC_ADDRESS BSSID;
401} NDIS_802_11_REMOVE_KEY, *PNDIS_802_11_REMOVE_KEY;
402
403typedef struct _NDIS_802_11_WEP
404{
405 UINT Length; // Length of this structure
406 UINT KeyIndex; // 0 is the per-client key, 1-N are the
407 // global keys
408 UINT KeyLength; // length of key in bytes
409 UCHAR KeyMaterial[1];// variable length depending on above field
410} NDIS_802_11_WEP, *PNDIS_802_11_WEP;
411
412
413typedef enum _NDIS_802_11_NETWORK_INFRASTRUCTURE
414{
415 Ndis802_11IBSS,
416 Ndis802_11Infrastructure,
417 Ndis802_11AutoUnknown,
418 Ndis802_11Monitor,
419 Ndis802_11InfrastructureMax // Not a real value, defined as upper bound
420} NDIS_802_11_NETWORK_INFRASTRUCTURE, *PNDIS_802_11_NETWORK_INFRASTRUCTURE;
421
422// Add new authentication modes
423typedef enum _NDIS_802_11_AUTHENTICATION_MODE
424{
425 Ndis802_11AuthModeOpen,
426 Ndis802_11AuthModeShared,
427 Ndis802_11AuthModeAutoSwitch,
428 Ndis802_11AuthModeWPA,
429 Ndis802_11AuthModeWPAPSK,
430 Ndis802_11AuthModeWPANone,
431 Ndis802_11AuthModeWPA2,
432 Ndis802_11AuthModeWPA2PSK,
433 Ndis802_11AuthModeWPA1WPA2,
434 Ndis802_11AuthModeWPA1PSKWPA2PSK,
435 Ndis802_11AuthModeMax // Not a real mode, defined as upper bound
436} NDIS_802_11_AUTHENTICATION_MODE, *PNDIS_802_11_AUTHENTICATION_MODE;
437
438typedef UCHAR NDIS_802_11_RATES[NDIS_802_11_LENGTH_RATES]; // Set of 8 data rates
439typedef UCHAR NDIS_802_11_RATES_EX[NDIS_802_11_LENGTH_RATES_EX]; // Set of 16 data rates
440
441typedef struct PACKED _NDIS_802_11_SSID
442{
443 UINT SsidLength; // length of SSID field below, in bytes;
444 // this can be zero.
445 UCHAR Ssid[NDIS_802_11_LENGTH_SSID]; // SSID information field
446} NDIS_802_11_SSID, *PNDIS_802_11_SSID;
447
448
449typedef struct PACKED _NDIS_WLAN_BSSID
450{
451 ULONG Length; // Length of this structure
452 NDIS_802_11_MAC_ADDRESS MacAddress; // BSSID
453 UCHAR Reserved[2];
454 NDIS_802_11_SSID Ssid; // SSID
455 ULONG Privacy; // WEP encryption requirement
456 NDIS_802_11_RSSI Rssi; // receive signal strength in dBm
457 NDIS_802_11_NETWORK_TYPE NetworkTypeInUse;
458 NDIS_802_11_CONFIGURATION Configuration;
459 NDIS_802_11_NETWORK_INFRASTRUCTURE InfrastructureMode;
460 NDIS_802_11_RATES SupportedRates;
461} NDIS_WLAN_BSSID, *PNDIS_WLAN_BSSID;
462
463typedef struct PACKED _NDIS_802_11_BSSID_LIST
464{
465 UINT NumberOfItems; // in list below, at least 1
466 NDIS_WLAN_BSSID Bssid[1];
467} NDIS_802_11_BSSID_LIST, *PNDIS_802_11_BSSID_LIST;
468
469// Added Capabilities, IELength and IEs for each BSSID
470typedef struct PACKED _NDIS_WLAN_BSSID_EX
471{
472 ULONG Length; // Length of this structure
473 NDIS_802_11_MAC_ADDRESS MacAddress; // BSSID
474 UCHAR Reserved[2];
475 NDIS_802_11_SSID Ssid; // SSID
476 UINT Privacy; // WEP encryption requirement
477 NDIS_802_11_RSSI Rssi; // receive signal
478 // strength in dBm
479 NDIS_802_11_NETWORK_TYPE NetworkTypeInUse;
480 NDIS_802_11_CONFIGURATION Configuration;
481 NDIS_802_11_NETWORK_INFRASTRUCTURE InfrastructureMode;
482 NDIS_802_11_RATES_EX SupportedRates;
483 ULONG IELength;
484 UCHAR IEs[1];
485} NDIS_WLAN_BSSID_EX, *PNDIS_WLAN_BSSID_EX;
486
487typedef struct PACKED _NDIS_802_11_BSSID_LIST_EX
488{
489 UINT NumberOfItems; // in list below, at least 1
490 NDIS_WLAN_BSSID_EX Bssid[1];
491} NDIS_802_11_BSSID_LIST_EX, *PNDIS_802_11_BSSID_LIST_EX;
492
493typedef struct PACKED _NDIS_802_11_FIXED_IEs
494{
495 UCHAR Timestamp[8];
496 USHORT BeaconInterval;
497 USHORT Capabilities;
498} NDIS_802_11_FIXED_IEs, *PNDIS_802_11_FIXED_IEs;
499
500typedef struct _NDIS_802_11_VARIABLE_IEs
501{
502 UCHAR ElementID;
503 UCHAR Length; // Number of bytes in data field
504 UCHAR data[1];
505} NDIS_802_11_VARIABLE_IEs, *PNDIS_802_11_VARIABLE_IEs;
506
507typedef ULONG NDIS_802_11_FRAGMENTATION_THRESHOLD;
508
509typedef ULONG NDIS_802_11_RTS_THRESHOLD;
510
511typedef ULONG NDIS_802_11_ANTENNA;
512
513typedef enum _NDIS_802_11_PRIVACY_FILTER
514{
515 Ndis802_11PrivFilterAcceptAll,
516 Ndis802_11PrivFilter8021xWEP
517} NDIS_802_11_PRIVACY_FILTER, *PNDIS_802_11_PRIVACY_FILTER;
518
519// Added new encryption types
520// Also aliased typedef to new name
521typedef enum _NDIS_802_11_WEP_STATUS
522{
523 Ndis802_11WEPEnabled,
524 Ndis802_11Encryption1Enabled = Ndis802_11WEPEnabled,
525 Ndis802_11WEPDisabled,
526 Ndis802_11EncryptionDisabled = Ndis802_11WEPDisabled,
527 Ndis802_11WEPKeyAbsent,
528 Ndis802_11Encryption1KeyAbsent = Ndis802_11WEPKeyAbsent,
529 Ndis802_11WEPNotSupported,
530 Ndis802_11EncryptionNotSupported = Ndis802_11WEPNotSupported,
531 Ndis802_11Encryption2Enabled,
532 Ndis802_11Encryption2KeyAbsent,
533 Ndis802_11Encryption3Enabled,
534 Ndis802_11Encryption3KeyAbsent,
535 Ndis802_11Encryption4Enabled, // TKIP or AES mix
536 Ndis802_11Encryption4KeyAbsent,
537#ifndef RT30xx
538 Ndis802_11GroupWEP40Enabled,
539 Ndis802_11GroupWEP104Enabled,
540#endif
541} NDIS_802_11_WEP_STATUS, *PNDIS_802_11_WEP_STATUS,
542 NDIS_802_11_ENCRYPTION_STATUS, *PNDIS_802_11_ENCRYPTION_STATUS;
543
544typedef enum _NDIS_802_11_RELOAD_DEFAULTS
545{
546 Ndis802_11ReloadWEPKeys
547} NDIS_802_11_RELOAD_DEFAULTS, *PNDIS_802_11_RELOAD_DEFAULTS;
548
549#define NDIS_802_11_AI_REQFI_CAPABILITIES 1
550#define NDIS_802_11_AI_REQFI_LISTENINTERVAL 2
551#define NDIS_802_11_AI_REQFI_CURRENTAPADDRESS 4
552
553#define NDIS_802_11_AI_RESFI_CAPABILITIES 1
554#define NDIS_802_11_AI_RESFI_STATUSCODE 2
555#define NDIS_802_11_AI_RESFI_ASSOCIATIONID 4
556
557typedef struct _NDIS_802_11_AI_REQFI
558{
559 USHORT Capabilities;
560 USHORT ListenInterval;
561 NDIS_802_11_MAC_ADDRESS CurrentAPAddress;
562} NDIS_802_11_AI_REQFI, *PNDIS_802_11_AI_REQFI;
563
564typedef struct _NDIS_802_11_AI_RESFI
565{
566 USHORT Capabilities;
567 USHORT StatusCode;
568 USHORT AssociationId;
569} NDIS_802_11_AI_RESFI, *PNDIS_802_11_AI_RESFI;
570
571typedef struct _NDIS_802_11_ASSOCIATION_INFORMATION
572{
573 ULONG Length;
574 USHORT AvailableRequestFixedIEs;
575 NDIS_802_11_AI_REQFI RequestFixedIEs;
576 ULONG RequestIELength;
577 ULONG OffsetRequestIEs;
578 USHORT AvailableResponseFixedIEs;
579 NDIS_802_11_AI_RESFI ResponseFixedIEs;
580 ULONG ResponseIELength;
581 ULONG OffsetResponseIEs;
582} NDIS_802_11_ASSOCIATION_INFORMATION, *PNDIS_802_11_ASSOCIATION_INFORMATION;
583
584typedef struct _NDIS_802_11_AUTHENTICATION_EVENT
585{
586 NDIS_802_11_STATUS_INDICATION Status;
587 NDIS_802_11_AUTHENTICATION_REQUEST Request[1];
588} NDIS_802_11_AUTHENTICATION_EVENT, *PNDIS_802_11_AUTHENTICATION_EVENT;
589
590// 802.11 Media stream constraints, associated with OID_802_11_MEDIA_STREAM_MODE
591typedef enum _NDIS_802_11_MEDIA_STREAM_MODE
592{
593 Ndis802_11MediaStreamOff,
594 Ndis802_11MediaStreamOn,
595} NDIS_802_11_MEDIA_STREAM_MODE, *PNDIS_802_11_MEDIA_STREAM_MODE;
596
597// PMKID Structures
598typedef UCHAR NDIS_802_11_PMKID_VALUE[16];
599
600typedef struct _BSSID_INFO
601{
602 NDIS_802_11_MAC_ADDRESS BSSID;
603 NDIS_802_11_PMKID_VALUE PMKID;
604} BSSID_INFO, *PBSSID_INFO;
605
606typedef struct _NDIS_802_11_PMKID
607{
608 UINT Length;
609 UINT BSSIDInfoCount;
610 BSSID_INFO BSSIDInfo[1];
611} NDIS_802_11_PMKID, *PNDIS_802_11_PMKID;
612
613typedef struct _NDIS_802_11_AUTHENTICATION_ENCRYPTION
614{
615 NDIS_802_11_AUTHENTICATION_MODE AuthModeSupported;
616 NDIS_802_11_ENCRYPTION_STATUS EncryptStatusSupported;
617} NDIS_802_11_AUTHENTICATION_ENCRYPTION, *PNDIS_802_11_AUTHENTICATION_ENCRYPTION;
618
619typedef struct _NDIS_802_11_CAPABILITY
620{
621 ULONG Length;
622 ULONG Version;
623 ULONG NoOfPMKIDs;
624 ULONG NoOfAuthEncryptPairsSupported;
625 NDIS_802_11_AUTHENTICATION_ENCRYPTION AuthenticationEncryptionSupported[1];
626} NDIS_802_11_CAPABILITY, *PNDIS_802_11_CAPABILITY;
627
628#if WIRELESS_EXT <= 11
629#ifndef SIOCDEVPRIVATE
630#define SIOCDEVPRIVATE 0x8BE0
631#endif
632#define SIOCIWFIRSTPRIV SIOCDEVPRIVATE
633#endif
634
635#ifdef RT30xx
636#define RT_PRIV_IOCTL_EXT (SIOCIWFIRSTPRIV + 0x01) // Sync. with AP for wsc upnp daemon
637#endif
638#define RTPRIV_IOCTL_SET (SIOCIWFIRSTPRIV + 0x02)
639
640#ifdef DBG
641#define RTPRIV_IOCTL_BBP (SIOCIWFIRSTPRIV + 0x03)
642#define RTPRIV_IOCTL_MAC (SIOCIWFIRSTPRIV + 0x05)
643#ifdef RT30xx
644#define RTPRIV_IOCTL_RF (SIOCIWFIRSTPRIV + 0x13)
645#endif
646#define RTPRIV_IOCTL_E2P (SIOCIWFIRSTPRIV + 0x07)
647#endif
648
649#define RTPRIV_IOCTL_STATISTICS (SIOCIWFIRSTPRIV + 0x09)
650#define RTPRIV_IOCTL_ADD_PMKID_CACHE (SIOCIWFIRSTPRIV + 0x0A)
651#define RTPRIV_IOCTL_RADIUS_DATA (SIOCIWFIRSTPRIV + 0x0C)
652#define RTPRIV_IOCTL_GSITESURVEY (SIOCIWFIRSTPRIV + 0x0D)
653#define RT_PRIV_IOCTL (SIOCIWFIRSTPRIV + 0x0E) // Sync. with RT61 (for wpa_supplicant)
654#define RTPRIV_IOCTL_GET_MAC_TABLE (SIOCIWFIRSTPRIV + 0x0F)
655
656#define RTPRIV_IOCTL_SHOW (SIOCIWFIRSTPRIV + 0x11)
657enum {
658 SHOW_CONN_STATUS = 4,
659 SHOW_DRVIER_VERION = 5,
660 SHOW_BA_INFO = 6,
661 SHOW_DESC_INFO = 7,
662#ifdef RT2870
663 SHOW_RXBULK_INFO = 8,
664 SHOW_TXBULK_INFO = 9,
665#endif // RT2870 //
666 RAIO_OFF = 10,
667 RAIO_ON = 11,
668 SHOW_CFG_VALUE = 20,
669#ifndef RT30xx
670 SHOW_ADHOC_ENTRY_INFO = 21,
671#endif
672};
673
674#define OID_802_11_BUILD_CHANNEL_EX 0x0714
675#define OID_802_11_GET_CH_LIST 0x0715
676#define OID_802_11_GET_COUNTRY_CODE 0x0716
677#define OID_802_11_GET_CHANNEL_GEOGRAPHY 0x0717
678
679#ifdef RT30xx
680#define RT_OID_WSC_SET_PASSPHRASE 0x0740 // passphrase for wpa(2)-psk
681#define RT_OID_WSC_DRIVER_AUTO_CONNECT 0x0741
682#define RT_OID_WSC_QUERY_DEFAULT_PROFILE 0x0742
683#define RT_OID_WSC_SET_CONN_BY_PROFILE_INDEX 0x0743
684#define RT_OID_WSC_SET_ACTION 0x0744
685#define RT_OID_WSC_SET_SSID 0x0745
686#define RT_OID_WSC_SET_PIN_CODE 0x0746
687#define RT_OID_WSC_SET_MODE 0x0747 // PIN or PBC
688#define RT_OID_WSC_SET_CONF_MODE 0x0748 // Enrollee or Registrar
689#define RT_OID_WSC_SET_PROFILE 0x0749
690
691#define RT_OID_802_11_WSC_QUERY_PROFILE 0x0750
692// for consistency with RT61
693#define RT_OID_WSC_QUERY_STATUS 0x0751
694#define RT_OID_WSC_PIN_CODE 0x0752
695#define RT_OID_WSC_UUID 0x0753
696#define RT_OID_WSC_SET_SELECTED_REGISTRAR 0x0754
697#define RT_OID_WSC_EAPMSG 0x0755
698#define RT_OID_WSC_MANUFACTURER 0x0756
699#define RT_OID_WSC_MODEL_NAME 0x0757
700#define RT_OID_WSC_MODEL_NO 0x0758
701#define RT_OID_WSC_SERIAL_NO 0x0759
702#define RT_OID_WSC_MAC_ADDRESS 0x0760
703#endif
704
705#ifdef LLTD_SUPPORT
706// for consistency with RT61
707#define RT_OID_GET_PHY_MODE 0x761
708#endif // LLTD_SUPPORT //
709
710#ifdef RT30xx
711// New for MeetingHouse Api support
712#define OID_MH_802_1X_SUPPORTED 0xFFEDC100
713#endif
714
715// MIMO Tx parameter, ShortGI, MCS, STBC, etc. these are fields in TXWI. Don't change this definition!!!
716typedef union _HTTRANSMIT_SETTING {
717 struct {
718 USHORT MCS:7; // MCS
719 USHORT BW:1; //channel bandwidth 20MHz or 40 MHz
720 USHORT ShortGI:1;
721 USHORT STBC:2; //SPACE
722 USHORT rsv:2;
723 USHORT TxBF:1;
724 USHORT MODE:2; // Use definition MODE_xxx.
725 } field;
726 USHORT word;
727 } HTTRANSMIT_SETTING, *PHTTRANSMIT_SETTING;
728
729typedef enum _RT_802_11_PREAMBLE {
730 Rt802_11PreambleLong,
731 Rt802_11PreambleShort,
732 Rt802_11PreambleAuto
733} RT_802_11_PREAMBLE, *PRT_802_11_PREAMBLE;
734
735// Only for STA, need to sync with AP
736typedef enum _RT_802_11_PHY_MODE {
737 PHY_11BG_MIXED = 0,
738 PHY_11B,
739 PHY_11A,
740 PHY_11ABG_MIXED,
741 PHY_11G,
742 PHY_11ABGN_MIXED, // both band 5
743 PHY_11N_2_4G, // 11n-only with 2.4G band 6
744 PHY_11GN_MIXED, // 2.4G band 7
745 PHY_11AN_MIXED, // 5G band 8
746 PHY_11BGN_MIXED, // if check 802.11b. 9
747 PHY_11AGN_MIXED, // if check 802.11b. 10
748 PHY_11N_5G, // 11n-only with 5G band 11
749} RT_802_11_PHY_MODE;
750
751// put all proprietery for-query objects here to reduce # of Query_OID
752typedef struct _RT_802_11_LINK_STATUS {
753 ULONG CurrTxRate; // in units of 0.5Mbps
754 ULONG ChannelQuality; // 0..100 %
755 ULONG TxByteCount; // both ok and fail
756 ULONG RxByteCount; // both ok and fail
757 ULONG CentralChannel; // 40MHz central channel number
758} RT_802_11_LINK_STATUS, *PRT_802_11_LINK_STATUS;
759
760typedef struct _RT_802_11_EVENT_LOG {
761 LARGE_INTEGER SystemTime; // timestammp via NdisGetCurrentSystemTime()
762 UCHAR Addr[MAC_ADDR_LENGTH];
763 USHORT Event; // EVENT_xxx
764} RT_802_11_EVENT_LOG, *PRT_802_11_EVENT_LOG;
765
766typedef struct _RT_802_11_EVENT_TABLE {
767 ULONG Num;
768 ULONG Rsv; // to align Log[] at LARGE_INEGER boundary
769 RT_802_11_EVENT_LOG Log[MAX_NUMBER_OF_EVENT];
770} RT_802_11_EVENT_TABLE, PRT_802_11_EVENT_TABLE;
771
772// MIMO Tx parameter, ShortGI, MCS, STBC, etc. these are fields in TXWI. Don't change this definition!!!
773typedef union _MACHTTRANSMIT_SETTING {
774 struct {
775 USHORT MCS:7; // MCS
776 USHORT BW:1; //channel bandwidth 20MHz or 40 MHz
777 USHORT ShortGI:1;
778 USHORT STBC:2; //SPACE
779 USHORT rsv:3;
780 USHORT MODE:2; // Use definition MODE_xxx.
781 } field;
782 USHORT word;
783 } MACHTTRANSMIT_SETTING, *PMACHTTRANSMIT_SETTING;
784
785typedef struct _RT_802_11_MAC_ENTRY {
786 UCHAR Addr[MAC_ADDR_LENGTH];
787 UCHAR Aid;
788 UCHAR Psm; // 0:PWR_ACTIVE, 1:PWR_SAVE
789 UCHAR MimoPs; // 0:MMPS_STATIC, 1:MMPS_DYNAMIC, 3:MMPS_Enabled
790 CHAR AvgRssi0;
791 CHAR AvgRssi1;
792 CHAR AvgRssi2;
793 UINT32 ConnectedTime;
794 MACHTTRANSMIT_SETTING TxRate;
795} RT_802_11_MAC_ENTRY, *PRT_802_11_MAC_ENTRY;
796
797typedef struct _RT_802_11_MAC_TABLE {
798 ULONG Num;
799 RT_802_11_MAC_ENTRY Entry[MAX_NUMBER_OF_MAC];
800} RT_802_11_MAC_TABLE, *PRT_802_11_MAC_TABLE;
801
802// structure for query/set hardware register - MAC, BBP, RF register
803typedef struct _RT_802_11_HARDWARE_REGISTER {
804 ULONG HardwareType; // 0:MAC, 1:BBP, 2:RF register, 3:EEPROM
805 ULONG Offset; // Q/S register offset addr
806 ULONG Data; // R/W data buffer
807} RT_802_11_HARDWARE_REGISTER, *PRT_802_11_HARDWARE_REGISTER;
808
809typedef struct _RT_802_11_AP_CONFIG {
810 ULONG EnableTxBurst; // 0-disable, 1-enable
811 ULONG EnableTurboRate; // 0-disable, 1-enable 72/100mbps turbo rate
812 ULONG IsolateInterStaTraffic; // 0-disable, 1-enable isolation
813 ULONG HideSsid; // 0-disable, 1-enable hiding
814 ULONG UseBGProtection; // 0-AUTO, 1-always ON, 2-always OFF
815 ULONG UseShortSlotTime; // 0-no use, 1-use 9-us short slot time
816 ULONG Rsv1; // must be 0
817 ULONG SystemErrorBitmap; // ignore upon SET, return system error upon QUERY
818} RT_802_11_AP_CONFIG, *PRT_802_11_AP_CONFIG;
819
820// structure to query/set STA_CONFIG
821typedef struct _RT_802_11_STA_CONFIG {
822 ULONG EnableTxBurst; // 0-disable, 1-enable
823 ULONG EnableTurboRate; // 0-disable, 1-enable 72/100mbps turbo rate
824 ULONG UseBGProtection; // 0-AUTO, 1-always ON, 2-always OFF
825 ULONG UseShortSlotTime; // 0-no use, 1-use 9-us short slot time when applicable
826 ULONG AdhocMode; // 0-11b rates only (WIFI spec), 1 - b/g mixed, 2 - g only
827 ULONG HwRadioStatus; // 0-OFF, 1-ON, default is 1, Read-Only
828 ULONG Rsv1; // must be 0
829 ULONG SystemErrorBitmap; // ignore upon SET, return system error upon QUERY
830} RT_802_11_STA_CONFIG, *PRT_802_11_STA_CONFIG;
831
832//
833// For OID Query or Set about BA structure
834//
835typedef struct _OID_BACAP_STRUC {
836 UCHAR RxBAWinLimit;
837 UCHAR TxBAWinLimit;
838 UCHAR Policy; // 0: DELAY_BA 1:IMMED_BA (//BA Policy subfiled value in ADDBA frame) 2:BA-not use. other value invalid
839 UCHAR MpduDensity; // 0: DELAY_BA 1:IMMED_BA (//BA Policy subfiled value in ADDBA frame) 2:BA-not use. other value invalid
840 UCHAR AmsduEnable; //Enable AMSDU transmisstion
841 UCHAR AmsduSize; // 0:3839, 1:7935 bytes. UINT MSDUSizeToBytes[] = { 3839, 7935};
842 UCHAR MMPSmode; // MIMO power save more, 0:static, 1:dynamic, 2:rsv, 3:mimo enable
843 BOOLEAN AutoBA; // Auto BA will automatically
844} OID_BACAP_STRUC, *POID_BACAP_STRUC;
845
846typedef struct _RT_802_11_ACL_ENTRY {
847 UCHAR Addr[MAC_ADDR_LENGTH];
848 USHORT Rsv;
849} RT_802_11_ACL_ENTRY, *PRT_802_11_ACL_ENTRY;
850
851typedef struct PACKED _RT_802_11_ACL {
852 ULONG Policy; // 0-disable, 1-positive list, 2-negative list
853 ULONG Num;
854 RT_802_11_ACL_ENTRY Entry[MAX_NUMBER_OF_ACL];
855} RT_802_11_ACL, *PRT_802_11_ACL;
856
857typedef struct _RT_802_11_WDS {
858 ULONG Num;
859 NDIS_802_11_MAC_ADDRESS Entry[24/*MAX_NUM_OF_WDS_LINK*/];
860 ULONG KeyLength;
861 UCHAR KeyMaterial[32];
862} RT_802_11_WDS, *PRT_802_11_WDS;
863
864typedef struct _RT_802_11_TX_RATES_ {
865 UCHAR SupRateLen;
866 UCHAR SupRate[MAX_LENGTH_OF_SUPPORT_RATES];
867 UCHAR ExtRateLen;
868 UCHAR ExtRate[MAX_LENGTH_OF_SUPPORT_RATES];
869} RT_802_11_TX_RATES, *PRT_802_11_TX_RATES;
870
871
872// Definition of extra information code
873#define GENERAL_LINK_UP 0x0 // Link is Up
874#define GENERAL_LINK_DOWN 0x1 // Link is Down
875#define HW_RADIO_OFF 0x2 // Hardware radio off
876#define SW_RADIO_OFF 0x3 // Software radio off
877#define AUTH_FAIL 0x4 // Open authentication fail
878#define AUTH_FAIL_KEYS 0x5 // Shared authentication fail
879#define ASSOC_FAIL 0x6 // Association failed
880#define EAP_MIC_FAILURE 0x7 // Deauthencation because MIC failure
881#define EAP_4WAY_TIMEOUT 0x8 // Deauthencation on 4-way handshake timeout
882#define EAP_GROUP_KEY_TIMEOUT 0x9 // Deauthencation on group key handshake timeout
883#define EAP_SUCCESS 0xa // EAP succeed
884#define DETECT_RADAR_SIGNAL 0xb // Radar signal occur in current channel
885#define EXTRA_INFO_MAX 0xb // Indicate Last OID
886
887#define EXTRA_INFO_CLEAR 0xffffffff
888
889// This is OID setting structure. So only GF or MM as Mode. This is valid when our wirelss mode has 802.11n in use.
890typedef struct {
891 RT_802_11_PHY_MODE PhyMode; //
892 UCHAR TransmitNo;
893 UCHAR HtMode; //HTMODE_GF or HTMODE_MM
894 UCHAR ExtOffset; //extension channel above or below
895 UCHAR MCS;
896 UCHAR BW;
897 UCHAR STBC;
898 UCHAR SHORTGI;
899 UCHAR rsv;
900} OID_SET_HT_PHYMODE, *POID_SET_HT_PHYMODE;
901
902#ifdef LLTD_SUPPORT
903typedef struct _RT_LLTD_ASSOICATION_ENTRY {
904 UCHAR Addr[ETH_LENGTH_OF_ADDRESS];
905 unsigned short MOR; // maximum operational rate
906 UCHAR phyMode;
907} RT_LLTD_ASSOICATION_ENTRY, *PRT_LLTD_ASSOICATION_ENTRY;
908
909typedef struct _RT_LLTD_ASSOICATION_TABLE {
910 unsigned int Num;
911 RT_LLTD_ASSOICATION_ENTRY Entry[MAX_NUMBER_OF_MAC];
912} RT_LLTD_ASSOICATION_TABLE, *PRT_LLTD_ASSOICATION_TABLE;
913#endif // LLTD_SUPPORT //
914
915#define MAX_CUSTOM_LEN 128
916
917typedef enum _RT_802_11_D_CLIENT_MODE
918{
919 Rt802_11_D_None,
920 Rt802_11_D_Flexible,
921 Rt802_11_D_Strict,
922} RT_802_11_D_CLIENT_MODE, *PRT_802_11_D_CLIENT_MODE;
923
924typedef struct _RT_CHANNEL_LIST_INFO
925{
926 UCHAR ChannelList[MAX_NUM_OF_CHS]; // list all supported channels for site survey
927 UCHAR ChannelListNum; // number of channel in ChannelList[]
928} RT_CHANNEL_LIST_INFO, *PRT_CHANNEL_LIST_INFO;
929
930// WSC configured credential
931typedef struct _WSC_CREDENTIAL
932{
933 NDIS_802_11_SSID SSID; // mandatory
934 USHORT AuthType; // mandatory, 1: open, 2: wpa-psk, 4: shared, 8:wpa, 0x10: wpa2, 0x20: wpa2-psk
935 USHORT EncrType; // mandatory, 1: none, 2: wep, 4: tkip, 8: aes
936 UCHAR Key[64]; // mandatory, Maximum 64 byte
937 USHORT KeyLength;
938 UCHAR MacAddr[6]; // mandatory, AP MAC address
939 UCHAR KeyIndex; // optional, default is 1
940 UCHAR Rsvd[3]; // Make alignment
941} WSC_CREDENTIAL, *PWSC_CREDENTIAL;
942
943// WSC configured profiles
944typedef struct _WSC_PROFILE
945{
946 UINT ProfileCnt;
947 WSC_CREDENTIAL Profile[8]; // Support up to 8 profiles
948} WSC_PROFILE, *PWSC_PROFILE;
949
950
951#endif // _OID_H_
952
diff --git a/drivers/staging/rt2870/rt28xx.h b/drivers/staging/rt2870/rt28xx.h
index f03b0f5deefb..29bad957de48 100644
--- a/drivers/staging/rt2870/rt28xx.h
+++ b/drivers/staging/rt2870/rt28xx.h
@@ -1,1667 +1 @@
1/* #include "../rt2860/rt28xx.h"
2 *************************************************************************
3 * Ralink Tech Inc.
4 * 5F., No.36, Taiyuan St., Jhubei City,
5 * Hsinchu County 302,
6 * Taiwan, R.O.C.
7 *
8 * (c) Copyright 2002-2007, Ralink Technology, Inc.
9 *
10 * This program is free software; you can redistribute it and/or modify *
11 * it under the terms of the GNU General Public License as published by *
12 * the Free Software Foundation; either version 2 of the License, or *
13 * (at your option) any later version. *
14 * *
15 * This program is distributed in the hope that it will be useful, *
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
18 * GNU General Public License for more details. *
19 * *
20 * You should have received a copy of the GNU General Public License *
21 * along with this program; if not, write to the *
22 * Free Software Foundation, Inc., *
23 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
24 * *
25 *************************************************************************
26
27 Module Name:
28 rt28xx.h
29
30 Abstract:
31 RT28xx ASIC related definition & structures
32
33 Revision History:
34 Who When What
35 -------- ---------- ----------------------------------------------
36 Jan Lee Jan-3-2006 created for RT2860c
37*/
38
39#ifndef __RT28XX_H__
40#define __RT28XX_H__
41
42
43//
44// PCI registers - base address 0x0000
45//
46#define PCI_CFG 0x0000
47#define PCI_EECTRL 0x0004
48#define PCI_MCUCTRL 0x0008
49
50#ifdef RT30xx
51#define OPT_14 0x114
52
53typedef int NTSTATUS;
54#define RETRY_LIMIT 10
55#define STATUS_SUCCESS 0x00
56#define STATUS_UNSUCCESSFUL 0x01
57#endif
58
59//
60// SCH/DMA registers - base address 0x0200
61//
62// INT_SOURCE_CSR: Interrupt source register. Write one to clear corresponding bit
63//
64#define DMA_CSR0 0x200
65#define INT_SOURCE_CSR 0x200
66typedef union _INT_SOURCE_CSR_STRUC {
67 struct {
68 UINT32 RxDelayINT:1;
69 UINT32 TxDelayINT:1;
70 UINT32 RxDone:1;
71 UINT32 Ac0DmaDone:1;//4
72 UINT32 Ac1DmaDone:1;
73 UINT32 Ac2DmaDone:1;
74 UINT32 Ac3DmaDone:1;
75 UINT32 HccaDmaDone:1; // bit7
76 UINT32 MgmtDmaDone:1;
77 UINT32 MCUCommandINT:1;//bit 9
78 UINT32 RxTxCoherent:1;
79 UINT32 TBTTInt:1;
80 UINT32 PreTBTT:1;
81 UINT32 TXFifoStatusInt:1;//FIFO Statistics is full, sw should read 0x171c
82 UINT32 AutoWakeup:1;//bit14
83 UINT32 GPTimer:1;
84 UINT32 RxCoherent:1;//bit16
85 UINT32 TxCoherent:1;
86 UINT32 :14;
87 } field;
88 UINT32 word;
89} INT_SOURCE_CSR_STRUC, *PINT_SOURCE_CSR_STRUC;
90
91//
92// INT_MASK_CSR: Interrupt MASK register. 1: the interrupt is mask OFF
93//
94#define INT_MASK_CSR 0x204
95typedef union _INT_MASK_CSR_STRUC {
96 struct {
97 UINT32 RXDelay_INT_MSK:1;
98 UINT32 TxDelay:1;
99 UINT32 RxDone:1;
100 UINT32 Ac0DmaDone:1;
101 UINT32 Ac1DmaDone:1;
102 UINT32 Ac2DmaDone:1;
103 UINT32 Ac3DmaDone:1;
104 UINT32 HccaDmaDone:1;
105 UINT32 MgmtDmaDone:1;
106 UINT32 MCUCommandINT:1;
107 UINT32 :20;
108 UINT32 RxCoherent:1;
109 UINT32 TxCoherent:1;
110 } field;
111 UINT32 word;
112} INT_MASK_CSR_STRUC, *PINT_MASK_CSR_STRUC;
113
114#define WPDMA_GLO_CFG 0x208
115typedef union _WPDMA_GLO_CFG_STRUC {
116 struct {
117 UINT32 EnableTxDMA:1;
118 UINT32 TxDMABusy:1;
119 UINT32 EnableRxDMA:1;
120 UINT32 RxDMABusy:1;
121 UINT32 WPDMABurstSIZE:2;
122 UINT32 EnTXWriteBackDDONE:1;
123 UINT32 BigEndian:1;
124 UINT32 RXHdrScater:8;
125 UINT32 HDR_SEG_LEN:16;
126 } field;
127 UINT32 word;
128} WPDMA_GLO_CFG_STRUC, *PWPDMA_GLO_CFG_STRUC;
129
130#define WPDMA_RST_IDX 0x20c
131typedef union _WPDMA_RST_IDX_STRUC {
132 struct {
133 UINT32 RST_DTX_IDX0:1;
134 UINT32 RST_DTX_IDX1:1;
135 UINT32 RST_DTX_IDX2:1;
136 UINT32 RST_DTX_IDX3:1;
137 UINT32 RST_DTX_IDX4:1;
138 UINT32 RST_DTX_IDX5:1;
139 UINT32 rsv:10;
140 UINT32 RST_DRX_IDX0:1;
141 UINT32 :15;
142 } field;
143 UINT32 word;
144} WPDMA_RST_IDX_STRUC, *PWPDMA_RST_IDX_STRUC;
145
146#define DELAY_INT_CFG 0x0210
147typedef union _DELAY_INT_CFG_STRUC {
148 struct {
149 UINT32 RXMAX_PTIME:8;
150 UINT32 RXMAX_PINT:7;
151 UINT32 RXDLY_INT_EN:1;
152 UINT32 TXMAX_PTIME:8;
153 UINT32 TXMAX_PINT:7;
154 UINT32 TXDLY_INT_EN:1;
155 } field;
156 UINT32 word;
157} DELAY_INT_CFG_STRUC, *PDELAY_INT_CFG_STRUC;
158
159#define WMM_AIFSN_CFG 0x0214
160typedef union _AIFSN_CSR_STRUC {
161 struct {
162 UINT32 Aifsn0:4; // for AC_BE
163 UINT32 Aifsn1:4; // for AC_BK
164 UINT32 Aifsn2:4; // for AC_VI
165 UINT32 Aifsn3:4; // for AC_VO
166 UINT32 Rsv:16;
167 } field;
168 UINT32 word;
169} AIFSN_CSR_STRUC, *PAIFSN_CSR_STRUC;
170
171//
172// CWMIN_CSR: CWmin for each EDCA AC
173//
174#define WMM_CWMIN_CFG 0x0218
175typedef union _CWMIN_CSR_STRUC {
176 struct {
177 UINT32 Cwmin0:4; // for AC_BE
178 UINT32 Cwmin1:4; // for AC_BK
179 UINT32 Cwmin2:4; // for AC_VI
180 UINT32 Cwmin3:4; // for AC_VO
181 UINT32 Rsv:16;
182 } field;
183 UINT32 word;
184} CWMIN_CSR_STRUC, *PCWMIN_CSR_STRUC;
185
186//
187// CWMAX_CSR: CWmin for each EDCA AC
188//
189#define WMM_CWMAX_CFG 0x021c
190typedef union _CWMAX_CSR_STRUC {
191 struct {
192 UINT32 Cwmax0:4; // for AC_BE
193 UINT32 Cwmax1:4; // for AC_BK
194 UINT32 Cwmax2:4; // for AC_VI
195 UINT32 Cwmax3:4; // for AC_VO
196 UINT32 Rsv:16;
197 } field;
198 UINT32 word;
199} CWMAX_CSR_STRUC, *PCWMAX_CSR_STRUC;
200
201//
202// AC_TXOP_CSR0: AC_BK/AC_BE TXOP register
203//
204#define WMM_TXOP0_CFG 0x0220
205typedef union _AC_TXOP_CSR0_STRUC {
206 struct {
207 USHORT Ac0Txop; // for AC_BK, in unit of 32us
208 USHORT Ac1Txop; // for AC_BE, in unit of 32us
209 } field;
210 UINT32 word;
211} AC_TXOP_CSR0_STRUC, *PAC_TXOP_CSR0_STRUC;
212
213//
214// AC_TXOP_CSR1: AC_VO/AC_VI TXOP register
215//
216#define WMM_TXOP1_CFG 0x0224
217typedef union _AC_TXOP_CSR1_STRUC {
218 struct {
219 USHORT Ac2Txop; // for AC_VI, in unit of 32us
220 USHORT Ac3Txop; // for AC_VO, in unit of 32us
221 } field;
222 UINT32 word;
223} AC_TXOP_CSR1_STRUC, *PAC_TXOP_CSR1_STRUC;
224
225#define RINGREG_DIFF 0x10
226#define GPIO_CTRL_CFG 0x0228 //MAC_CSR13
227#define MCU_CMD_CFG 0x022c
228#define TX_BASE_PTR0 0x0230 //AC_BK base address
229#define TX_MAX_CNT0 0x0234
230#define TX_CTX_IDX0 0x0238
231#define TX_DTX_IDX0 0x023c
232#define TX_BASE_PTR1 0x0240 //AC_BE base address
233#define TX_MAX_CNT1 0x0244
234#define TX_CTX_IDX1 0x0248
235#define TX_DTX_IDX1 0x024c
236#define TX_BASE_PTR2 0x0250 //AC_VI base address
237#define TX_MAX_CNT2 0x0254
238#define TX_CTX_IDX2 0x0258
239#define TX_DTX_IDX2 0x025c
240#define TX_BASE_PTR3 0x0260 //AC_VO base address
241#define TX_MAX_CNT3 0x0264
242#define TX_CTX_IDX3 0x0268
243#define TX_DTX_IDX3 0x026c
244#define TX_BASE_PTR4 0x0270 //HCCA base address
245#define TX_MAX_CNT4 0x0274
246#define TX_CTX_IDX4 0x0278
247#define TX_DTX_IDX4 0x027c
248#define TX_BASE_PTR5 0x0280 //MGMT base address
249#define TX_MAX_CNT5 0x0284
250#define TX_CTX_IDX5 0x0288
251#define TX_DTX_IDX5 0x028c
252#define TX_MGMTMAX_CNT TX_MAX_CNT5
253#define TX_MGMTCTX_IDX TX_CTX_IDX5
254#define TX_MGMTDTX_IDX TX_DTX_IDX5
255#define RX_BASE_PTR 0x0290 //RX base address
256#define RX_MAX_CNT 0x0294
257#define RX_CRX_IDX 0x0298
258#define RX_DRX_IDX 0x029c
259#define USB_DMA_CFG 0x02a0
260
261typedef union _USB_DMA_CFG_STRUC {
262 struct {
263 UINT32 RxBulkAggTOut:8; //Rx Bulk Aggregation TimeOut in unit of 33ns
264 UINT32 RxBulkAggLmt:8; //Rx Bulk Aggregation Limit in unit of 256 bytes
265 UINT32 phyclear:1; //phy watch dog enable. write 1
266 UINT32 rsv:2;
267 UINT32 TxClear:1; //Clear USB DMA TX path
268 UINT32 TxopHalt:1; //Halt TXOP count down when TX buffer is full.
269 UINT32 RxBulkAggEn:1; //Enable Rx Bulk Aggregation
270 UINT32 RxBulkEn:1; //Enable USB DMA Rx
271 UINT32 TxBulkEn:1; //Enable USB DMA Tx
272 UINT32 EpoutValid:6; //OUT endpoint data valid
273 UINT32 RxBusy:1; //USB DMA RX FSM busy
274 UINT32 TxBusy:1; //USB DMA TX FSM busy
275 } field;
276 UINT32 word;
277} USB_DMA_CFG_STRUC, *PUSB_DMA_CFG_STRUC;
278
279//
280// 3 PBF registers
281//
282//
283// Most are for debug. Driver doesn't touch PBF register.
284#define PBF_SYS_CTRL 0x0400
285#define PBF_CFG 0x0408
286#define PBF_MAX_PCNT 0x040C
287#define PBF_CTRL 0x0410
288#define PBF_INT_STA 0x0414
289#define PBF_INT_ENA 0x0418
290#define TXRXQ_PCNT 0x0438
291#define PBF_DBG 0x043c
292#define PBF_CAP_CTRL 0x0440
293
294#ifdef RT30xx
295// eFuse registers
296#define EFUSE_CTRL 0x0580
297#define EFUSE_DATA0 0x0590
298#define EFUSE_DATA1 0x0594
299#define EFUSE_DATA2 0x0598
300#define EFUSE_DATA3 0x059c
301#define EFUSE_USAGE_MAP_START 0x2d0
302#define EFUSE_USAGE_MAP_END 0x2fc
303#define EFUSE_TAG 0x2fe
304#define EFUSE_USAGE_MAP_SIZE 45
305
306typedef union _EFUSE_CTRL_STRUC {
307 struct {
308 UINT32 EFSROM_AOUT:6;
309 UINT32 EFSROM_MODE:2;
310 UINT32 EFSROM_LDO_OFF_TIME:6;
311 UINT32 EFSROM_LDO_ON_TIME:2;
312 UINT32 EFSROM_AIN:10;
313 UINT32 RESERVED:4;
314 UINT32 EFSROM_KICK:1;
315 UINT32 SEL_EFUSE:1;
316 } field;
317 UINT32 word;
318} EFUSE_CTRL_STRUC, *PEFUSE_CTRL_STRUC;
319
320#define LDO_CFG0 0x05d4
321#define GPIO_SWITCH 0x05dc
322#endif /* RT30xx */
323
324//
325// 4 MAC registers
326//
327//
328// 4.1 MAC SYSTEM configuration registers (offset:0x1000)
329//
330#define MAC_CSR0 0x1000
331typedef union _ASIC_VER_ID_STRUC {
332 struct {
333 USHORT ASICRev; // reversion : 0
334 USHORT ASICVer; // version : 2860
335 } field;
336 UINT32 word;
337} ASIC_VER_ID_STRUC, *PASIC_VER_ID_STRUC;
338
339#define MAC_SYS_CTRL 0x1004 //MAC_CSR1
340#define MAC_ADDR_DW0 0x1008 // MAC ADDR DW0
341#define MAC_ADDR_DW1 0x100c // MAC ADDR DW1
342//
343// MAC_CSR2: STA MAC register 0
344//
345typedef union _MAC_DW0_STRUC {
346 struct {
347 UCHAR Byte0; // MAC address byte 0
348 UCHAR Byte1; // MAC address byte 1
349 UCHAR Byte2; // MAC address byte 2
350 UCHAR Byte3; // MAC address byte 3
351 } field;
352 UINT32 word;
353} MAC_DW0_STRUC, *PMAC_DW0_STRUC;
354
355//
356// MAC_CSR3: STA MAC register 1
357//
358typedef union _MAC_DW1_STRUC {
359 struct {
360 UCHAR Byte4; // MAC address byte 4
361 UCHAR Byte5; // MAC address byte 5
362 UCHAR U2MeMask;
363 UCHAR Rsvd1;
364 } field;
365 UINT32 word;
366} MAC_DW1_STRUC, *PMAC_DW1_STRUC;
367
368#define MAC_BSSID_DW0 0x1010 // MAC BSSID DW0
369#define MAC_BSSID_DW1 0x1014 // MAC BSSID DW1
370
371//
372// MAC_CSR5: BSSID register 1
373//
374typedef union _MAC_CSR5_STRUC {
375 struct {
376 UCHAR Byte4; // BSSID byte 4
377 UCHAR Byte5; // BSSID byte 5
378 USHORT BssIdMask:2; // 0: one BSSID, 10: 4 BSSID, 01: 2 BSSID , 11: 8BSSID
379 USHORT MBssBcnNum:3;
380 USHORT Rsvd:11;
381 } field;
382 UINT32 word;
383} MAC_CSR5_STRUC, *PMAC_CSR5_STRUC;
384
385#define MAX_LEN_CFG 0x1018 // rt2860b max 16k bytes. bit12:13 Maximum PSDU length (power factor) 0:2^13, 1:2^14, 2:2^15, 3:2^16
386#define BBP_CSR_CFG 0x101c //
387//
388// BBP_CSR_CFG: BBP serial control register
389//
390typedef union _BBP_CSR_CFG_STRUC {
391 struct {
392 UINT32 Value:8; // Register value to program into BBP
393 UINT32 RegNum:8; // Selected BBP register
394 UINT32 fRead:1; // 0: Write BBP, 1: Read BBP
395 UINT32 Busy:1; // 1: ASIC is busy execute BBP programming.
396 UINT32 BBP_PAR_DUR:1; // 0: 4 MAC clock cycles 1: 8 MAC clock cycles
397 UINT32 BBP_RW_MODE:1; // 0: use serial mode 1:parallel
398 UINT32 :12;
399 } field;
400 UINT32 word;
401} BBP_CSR_CFG_STRUC, *PBBP_CSR_CFG_STRUC;
402
403#define RF_CSR_CFG0 0x1020
404//
405// RF_CSR_CFG: RF control register
406//
407typedef union _RF_CSR_CFG0_STRUC {
408 struct {
409 UINT32 RegIdAndContent:24; // Register value to program into BBP
410 UINT32 bitwidth:5; // Selected BBP register
411 UINT32 StandbyMode:1; // 0: high when stand by 1: low when standby
412 UINT32 Sel:1; // 0:RF_LE0 activate 1:RF_LE1 activate
413 UINT32 Busy:1; // 0: idle 1: 8busy
414 } field;
415 UINT32 word;
416} RF_CSR_CFG0_STRUC, *PRF_CSR_CFG0_STRUC;
417
418#define RF_CSR_CFG1 0x1024
419typedef union _RF_CSR_CFG1_STRUC {
420 struct {
421 UINT32 RegIdAndContent:24; // Register value to program into BBP
422 UINT32 RFGap:5; // Gap between BB_CONTROL_RF and RF_LE. 0: 3 system clock cycle (37.5usec) 1: 5 system clock cycle (62.5usec)
423 UINT32 rsv:7; // 0: idle 1: 8busy
424 } field;
425 UINT32 word;
426} RF_CSR_CFG1_STRUC, *PRF_CSR_CFG1_STRUC;
427
428#define RF_CSR_CFG2 0x1028 //
429typedef union _RF_CSR_CFG2_STRUC {
430 struct {
431 UINT32 RegIdAndContent:24; // Register value to program into BBP
432 UINT32 rsv:8; // 0: idle 1: 8busy
433 } field;
434 UINT32 word;
435} RF_CSR_CFG2_STRUC, *PRF_CSR_CFG2_STRUC;
436
437#define LED_CFG 0x102c // MAC_CSR14
438typedef union _LED_CFG_STRUC {
439 struct {
440 UINT32 OnPeriod:8; // blinking on period unit 1ms
441 UINT32 OffPeriod:8; // blinking off period unit 1ms
442 UINT32 SlowBlinkPeriod:6; // slow blinking period. unit:1ms
443 UINT32 rsv:2;
444 UINT32 RLedMode:2; // red Led Mode 0: off1: blinking upon TX2: periodic slow blinking3: always on
445 UINT32 GLedMode:2; // green Led Mode
446 UINT32 YLedMode:2; // yellow Led Mode
447 UINT32 LedPolar:1; // Led Polarity. 0: active low1: active high
448 UINT32 :1;
449 } field;
450 UINT32 word;
451} LED_CFG_STRUC, *PLED_CFG_STRUC;
452
453//
454// 4.2 MAC TIMING configuration registers (offset:0x1100)
455//
456#define XIFS_TIME_CFG 0x1100 // MAC_CSR8 MAC_CSR9
457typedef union _IFS_SLOT_CFG_STRUC {
458 struct {
459 UINT32 CckmSifsTime:8; // unit 1us. Applied after CCK RX/TX
460 UINT32 OfdmSifsTime:8; // unit 1us. Applied after OFDM RX/TX
461 UINT32 OfdmXifsTime:4; //OFDM SIFS. unit 1us. Applied after OFDM RX when MAC doesn't reference BBP signal BBRXEND
462 UINT32 EIFS:9; // unit 1us
463 UINT32 BBRxendEnable:1; // reference RXEND signal to begin XIFS defer
464 UINT32 rsv:2;
465 } field;
466 UINT32 word;
467} IFS_SLOT_CFG_STRUC, *PIFS_SLOT_CFG_STRUC;
468
469#define BKOFF_SLOT_CFG 0x1104 // mac_csr9 last 8 bits
470#define NAV_TIME_CFG 0x1108 // NAV (MAC_CSR15)
471#define CH_TIME_CFG 0x110C // Count as channel busy
472#define PBF_LIFE_TIMER 0x1110 //TX/RX MPDU timestamp timer (free run)Unit: 1us
473#define BCN_TIME_CFG 0x1114 // TXRX_CSR9
474
475#define BCN_OFFSET0 0x042C
476#define BCN_OFFSET1 0x0430
477
478//
479// BCN_TIME_CFG : Synchronization control register
480//
481typedef union _BCN_TIME_CFG_STRUC {
482 struct {
483 UINT32 BeaconInterval:16; // in unit of 1/16 TU
484 UINT32 bTsfTicking:1; // Enable TSF auto counting
485 UINT32 TsfSyncMode:2; // Enable TSF sync, 00: disable, 01: infra mode, 10: ad-hoc mode
486 UINT32 bTBTTEnable:1;
487 UINT32 bBeaconGen:1; // Enable beacon generator
488 UINT32 :3;
489 UINT32 TxTimestampCompensate:8;
490 } field;
491 UINT32 word;
492} BCN_TIME_CFG_STRUC, *PBCN_TIME_CFG_STRUC;
493
494#define TBTT_SYNC_CFG 0x1118 // txrx_csr10
495#define TSF_TIMER_DW0 0x111C // Local TSF timer lsb 32 bits. Read-only
496#define TSF_TIMER_DW1 0x1120 // msb 32 bits. Read-only.
497#define TBTT_TIMER 0x1124 // TImer remains till next TBTT. Read-only. TXRX_CSR14
498#define INT_TIMER_CFG 0x1128 //
499#define INT_TIMER_EN 0x112c // GP-timer and pre-tbtt Int enable
500#define CH_IDLE_STA 0x1130 // channel idle time
501#define CH_BUSY_STA 0x1134 // channle busy time
502//
503// 4.2 MAC POWER configuration registers (offset:0x1200)
504//
505#define MAC_STATUS_CFG 0x1200 // old MAC_CSR12
506#define PWR_PIN_CFG 0x1204 // old MAC_CSR12
507#define AUTO_WAKEUP_CFG 0x1208 // old MAC_CSR10
508//
509// AUTO_WAKEUP_CFG: Manual power control / status register
510//
511typedef union _AUTO_WAKEUP_STRUC {
512 struct {
513 UINT32 AutoLeadTime:8;
514 UINT32 NumofSleepingTbtt:7; // ForceWake has high privilege than PutToSleep when both set
515 UINT32 EnableAutoWakeup:1; // 0:sleep, 1:awake
516 UINT32 :16;
517 } field;
518 UINT32 word;
519} AUTO_WAKEUP_STRUC, *PAUTO_WAKEUP_STRUC;
520
521//
522// 4.3 MAC TX configuration registers (offset:0x1300)
523//
524
525#define EDCA_AC0_CFG 0x1300 //AC_TXOP_CSR0 0x3474
526#define EDCA_AC1_CFG 0x1304
527#define EDCA_AC2_CFG 0x1308
528#define EDCA_AC3_CFG 0x130c
529typedef union _EDCA_AC_CFG_STRUC {
530 struct {
531 UINT32 AcTxop:8; // in unit of 32us
532 UINT32 Aifsn:4; // # of slot time
533 UINT32 Cwmin:4; //
534 UINT32 Cwmax:4; //unit power of 2
535 UINT32 :12; //
536 } field;
537 UINT32 word;
538} EDCA_AC_CFG_STRUC, *PEDCA_AC_CFG_STRUC;
539
540#define EDCA_TID_AC_MAP 0x1310
541#define TX_PWR_CFG_0 0x1314
542#define TX_PWR_CFG_1 0x1318
543#define TX_PWR_CFG_2 0x131C
544#define TX_PWR_CFG_3 0x1320
545#define TX_PWR_CFG_4 0x1324
546#define TX_PIN_CFG 0x1328
547#define TX_BAND_CFG 0x132c // 0x1 use upper 20MHz. 0 juse lower 20MHz
548#define TX_SW_CFG0 0x1330
549#define TX_SW_CFG1 0x1334
550#define TX_SW_CFG2 0x1338
551#define TXOP_THRES_CFG 0x133c
552#define TXOP_CTRL_CFG 0x1340
553#define TX_RTS_CFG 0x1344
554
555typedef union _TX_RTS_CFG_STRUC {
556 struct {
557 UINT32 AutoRtsRetryLimit:8;
558 UINT32 RtsThres:16; // unit:byte
559 UINT32 RtsFbkEn:1; // enable rts rate fallback
560 UINT32 rsv:7; // 1: HT non-STBC control frame enable
561 } field;
562 UINT32 word;
563} TX_RTS_CFG_STRUC, *PTX_RTS_CFG_STRUC;
564
565#define TX_TIMEOUT_CFG 0x1348
566typedef union _TX_TIMEOUT_CFG_STRUC {
567 struct {
568 UINT32 rsv:4;
569 UINT32 MpduLifeTime:4; // expiration time = 2^(9+MPDU LIFE TIME) us
570 UINT32 RxAckTimeout:8; // unit:slot. Used for TX precedure
571 UINT32 TxopTimeout:8; //TXOP timeout value for TXOP truncation. It is recommended that (SLOT_TIME) > (TX_OP_TIMEOUT) > (RX_ACK_TIMEOUT)
572 UINT32 rsv2:8; // 1: HT non-STBC control frame enable
573 } field;
574 UINT32 word;
575} TX_TIMEOUT_CFG_STRUC, *PTX_TIMEOUT_CFG_STRUC;
576
577#define TX_RTY_CFG 0x134c
578typedef union PACKED _TX_RTY_CFG_STRUC {
579 struct {
580 UINT32 ShortRtyLimit:8; // short retry limit
581 UINT32 LongRtyLimit:8; //long retry limit
582 UINT32 LongRtyThre:12; // Long retry threshoold
583 UINT32 NonAggRtyMode:1; // Non-Aggregate MPDU retry mode. 0:expired by retry limit, 1: expired by mpdu life timer
584 UINT32 AggRtyMode:1; // Aggregate MPDU retry mode. 0:expired by retry limit, 1: expired by mpdu life timer
585 UINT32 TxautoFBEnable:1; // Tx retry PHY rate auto fallback enable
586 UINT32 rsv:1; // 1: HT non-STBC control frame enable
587 } field;
588 UINT32 word;
589} TX_RTY_CFG_STRUC, *PTX_RTY_CFG_STRUC;
590
591#define TX_LINK_CFG 0x1350
592typedef union PACKED _TX_LINK_CFG_STRUC {
593 struct PACKED {
594 UINT32 RemoteMFBLifeTime:8; //remote MFB life time. unit : 32us
595 UINT32 MFBEnable:1; // TX apply remote MFB 1:enable
596 UINT32 RemoteUMFSEnable:1; // remote unsolicit MFB enable. 0: not apply remote remote unsolicit (MFS=7)
597 UINT32 TxMRQEn:1; // MCS request TX enable
598 UINT32 TxRDGEn:1; // RDG TX enable
599 UINT32 TxCFAckEn:1; // Piggyback CF-ACK enable
600 UINT32 rsv:3; //
601 UINT32 RemotMFB:8; // remote MCS feedback
602 UINT32 RemotMFS:8; //remote MCS feedback sequence number
603 } field;
604 UINT32 word;
605} TX_LINK_CFG_STRUC, *PTX_LINK_CFG_STRUC;
606
607#define HT_FBK_CFG0 0x1354
608typedef union PACKED _HT_FBK_CFG0_STRUC {
609 struct {
610 UINT32 HTMCS0FBK:4;
611 UINT32 HTMCS1FBK:4;
612 UINT32 HTMCS2FBK:4;
613 UINT32 HTMCS3FBK:4;
614 UINT32 HTMCS4FBK:4;
615 UINT32 HTMCS5FBK:4;
616 UINT32 HTMCS6FBK:4;
617 UINT32 HTMCS7FBK:4;
618 } field;
619 UINT32 word;
620} HT_FBK_CFG0_STRUC, *PHT_FBK_CFG0_STRUC;
621
622#define HT_FBK_CFG1 0x1358
623typedef union _HT_FBK_CFG1_STRUC {
624 struct {
625 UINT32 HTMCS8FBK:4;
626 UINT32 HTMCS9FBK:4;
627 UINT32 HTMCS10FBK:4;
628 UINT32 HTMCS11FBK:4;
629 UINT32 HTMCS12FBK:4;
630 UINT32 HTMCS13FBK:4;
631 UINT32 HTMCS14FBK:4;
632 UINT32 HTMCS15FBK:4;
633 } field;
634 UINT32 word;
635} HT_FBK_CFG1_STRUC, *PHT_FBK_CFG1_STRUC;
636
637#define LG_FBK_CFG0 0x135c
638typedef union _LG_FBK_CFG0_STRUC {
639 struct {
640 UINT32 OFDMMCS0FBK:4; //initial value is 0
641 UINT32 OFDMMCS1FBK:4; //initial value is 0
642 UINT32 OFDMMCS2FBK:4; //initial value is 1
643 UINT32 OFDMMCS3FBK:4; //initial value is 2
644 UINT32 OFDMMCS4FBK:4; //initial value is 3
645 UINT32 OFDMMCS5FBK:4; //initial value is 4
646 UINT32 OFDMMCS6FBK:4; //initial value is 5
647 UINT32 OFDMMCS7FBK:4; //initial value is 6
648 } field;
649 UINT32 word;
650} LG_FBK_CFG0_STRUC, *PLG_FBK_CFG0_STRUC;
651
652#define LG_FBK_CFG1 0x1360
653typedef union _LG_FBK_CFG1_STRUC {
654 struct {
655 UINT32 CCKMCS0FBK:4; //initial value is 0
656 UINT32 CCKMCS1FBK:4; //initial value is 0
657 UINT32 CCKMCS2FBK:4; //initial value is 1
658 UINT32 CCKMCS3FBK:4; //initial value is 2
659 UINT32 rsv:16;
660 } field;
661 UINT32 word;
662} LG_FBK_CFG1_STRUC, *PLG_FBK_CFG1_STRUC;
663
664//=======================================================
665//================ Protection Paramater================================
666//=======================================================
667#define CCK_PROT_CFG 0x1364 //CCK Protection
668#define ASIC_SHORTNAV 1
669#define ASIC_LONGNAV 2
670#define ASIC_RTS 1
671#define ASIC_CTS 2
672typedef union _PROT_CFG_STRUC {
673 struct {
674 UINT32 ProtectRate:16; //Protection control frame rate for CCK TX(RTS/CTS/CFEnd).
675 UINT32 ProtectCtrl:2; //Protection control frame type for CCK TX. 1:RTS/CTS, 2:CTS-to-self, 0:None, 3:rsv
676 UINT32 ProtectNav:2; //TXOP protection type for CCK TX. 0:None, 1:ShortNAVprotect, 2:LongNAVProtect, 3:rsv
677 UINT32 TxopAllowCck:1; //CCK TXOP allowance.0:disallow.
678 UINT32 TxopAllowOfdm:1; //CCK TXOP allowance.0:disallow.
679 UINT32 TxopAllowMM20:1; //CCK TXOP allowance. 0:disallow.
680 UINT32 TxopAllowMM40:1; //CCK TXOP allowance.0:disallow.
681 UINT32 TxopAllowGF20:1; //CCK TXOP allowance.0:disallow.
682 UINT32 TxopAllowGF40:1; //CCK TXOP allowance.0:disallow.
683 UINT32 RTSThEn:1; //RTS threshold enable on CCK TX
684 UINT32 rsv:5;
685 } field;
686 UINT32 word;
687} PROT_CFG_STRUC, *PPROT_CFG_STRUC;
688
689#define OFDM_PROT_CFG 0x1368 //OFDM Protection
690#define MM20_PROT_CFG 0x136C //MM20 Protection
691#define MM40_PROT_CFG 0x1370 //MM40 Protection
692#define GF20_PROT_CFG 0x1374 //GF20 Protection
693#define GF40_PROT_CFG 0x1378 //GR40 Protection
694#define EXP_CTS_TIME 0x137C //
695#define EXP_ACK_TIME 0x1380 //
696
697//
698// 4.4 MAC RX configuration registers (offset:0x1400)
699//
700#define RX_FILTR_CFG 0x1400 //TXRX_CSR0
701#define AUTO_RSP_CFG 0x1404 //TXRX_CSR4
702//
703// TXRX_CSR4: Auto-Responder/
704//
705typedef union _AUTO_RSP_CFG_STRUC {
706 struct {
707 UINT32 AutoResponderEnable:1;
708 UINT32 BACAckPolicyEnable:1; // 0:long, 1:short preamble
709 UINT32 CTS40MMode:1; // Response CTS 40MHz duplicate mode
710 UINT32 CTS40MRef:1; // Response CTS 40MHz duplicate mode
711 UINT32 AutoResponderPreamble:1; // 0:long, 1:short preamble
712 UINT32 rsv:1; // Power bit value in conrtrol frame
713 UINT32 DualCTSEn:1; // Power bit value in conrtrol frame
714 UINT32 AckCtsPsmBit:1; // Power bit value in conrtrol frame
715 UINT32 :24;
716 } field;
717 UINT32 word;
718} AUTO_RSP_CFG_STRUC, *PAUTO_RSP_CFG_STRUC;
719
720#define LEGACY_BASIC_RATE 0x1408 // TXRX_CSR5 0x3054
721#define HT_BASIC_RATE 0x140c
722#define HT_CTRL_CFG 0x1410
723#define SIFS_COST_CFG 0x1414
724#define RX_PARSER_CFG 0x1418 //Set NAV for all received frames
725
726//
727// 4.5 MAC Security configuration (offset:0x1500)
728//
729#define TX_SEC_CNT0 0x1500 //
730#define RX_SEC_CNT0 0x1504 //
731#define CCMP_FC_MUTE 0x1508 //
732//
733// 4.6 HCCA/PSMP (offset:0x1600)
734//
735#define TXOP_HLDR_ADDR0 0x1600
736#define TXOP_HLDR_ADDR1 0x1604
737#define TXOP_HLDR_ET 0x1608
738#define QOS_CFPOLL_RA_DW0 0x160c
739#define QOS_CFPOLL_A1_DW1 0x1610
740#define QOS_CFPOLL_QC 0x1614
741//
742// 4.7 MAC Statistis registers (offset:0x1700)
743//
744#define RX_STA_CNT0 0x1700 //
745#define RX_STA_CNT1 0x1704 //
746#define RX_STA_CNT2 0x1708 //
747
748//
749// RX_STA_CNT0_STRUC: RX PLCP error count & RX CRC error count
750//
751typedef union _RX_STA_CNT0_STRUC {
752 struct {
753 USHORT CrcErr;
754 USHORT PhyErr;
755 } field;
756 UINT32 word;
757} RX_STA_CNT0_STRUC, *PRX_STA_CNT0_STRUC;
758
759//
760// RX_STA_CNT1_STRUC: RX False CCA count & RX LONG frame count
761//
762typedef union _RX_STA_CNT1_STRUC {
763 struct {
764 USHORT FalseCca;
765 USHORT PlcpErr;
766 } field;
767 UINT32 word;
768} RX_STA_CNT1_STRUC, *PRX_STA_CNT1_STRUC;
769
770//
771// RX_STA_CNT2_STRUC:
772//
773typedef union _RX_STA_CNT2_STRUC {
774 struct {
775 USHORT RxDupliCount;
776 USHORT RxFifoOverflowCount;
777 } field;
778 UINT32 word;
779} RX_STA_CNT2_STRUC, *PRX_STA_CNT2_STRUC;
780
781#define TX_STA_CNT0 0x170C //
782//
783// STA_CSR3: TX Beacon count
784//
785typedef union _TX_STA_CNT0_STRUC {
786 struct {
787 USHORT TxFailCount;
788 USHORT TxBeaconCount;
789 } field;
790 UINT32 word;
791} TX_STA_CNT0_STRUC, *PTX_STA_CNT0_STRUC;
792
793#define TX_STA_CNT1 0x1710 //
794//
795// TX_STA_CNT1: TX tx count
796//
797typedef union _TX_STA_CNT1_STRUC {
798 struct {
799 USHORT TxSuccess;
800 USHORT TxRetransmit;
801 } field;
802 UINT32 word;
803} TX_STA_CNT1_STRUC, *PTX_STA_CNT1_STRUC;
804
805#define TX_STA_CNT2 0x1714 //
806//
807// TX_STA_CNT2: TX tx count
808//
809typedef union _TX_STA_CNT2_STRUC {
810 struct {
811 USHORT TxZeroLenCount;
812 USHORT TxUnderFlowCount;
813 } field;
814 UINT32 word;
815} TX_STA_CNT2_STRUC, *PTX_STA_CNT2_STRUC;
816
817#define TX_STA_FIFO 0x1718 //
818//
819// TX_STA_FIFO_STRUC: TX Result for specific PID status fifo register
820//
821typedef union PACKED _TX_STA_FIFO_STRUC {
822 struct {
823 UINT32 bValid:1; // 1:This register contains a valid TX result
824 UINT32 PidType:4;
825 UINT32 TxSuccess:1; // Tx No retry success
826 UINT32 TxAggre:1; // Tx Retry Success
827 UINT32 TxAckRequired:1; // Tx fail
828 UINT32 wcid:8; //wireless client index
829// UINT32 SuccessRate:16; //include MCS, mode ,shortGI, BW settingSame format as TXWI Word 0 Bit 31-16.
830 UINT32 SuccessRate:13; //include MCS, mode ,shortGI, BW settingSame format as TXWI Word 0 Bit 31-16.
831 UINT32 TxBF:1;
832 UINT32 Reserve:2;
833 } field;
834 UINT32 word;
835} TX_STA_FIFO_STRUC, *PTX_STA_FIFO_STRUC;
836
837// Debug counter
838#define TX_AGG_CNT 0x171c
839typedef union _TX_AGG_CNT_STRUC {
840 struct {
841 USHORT NonAggTxCount;
842 USHORT AggTxCount;
843 } field;
844 UINT32 word;
845} TX_AGG_CNT_STRUC, *PTX_AGG_CNT_STRUC;
846
847// Debug counter
848#define TX_AGG_CNT0 0x1720
849typedef union _TX_AGG_CNT0_STRUC {
850 struct {
851 USHORT AggSize1Count;
852 USHORT AggSize2Count;
853 } field;
854 UINT32 word;
855} TX_AGG_CNT0_STRUC, *PTX_AGG_CNT0_STRUC;
856
857// Debug counter
858#define TX_AGG_CNT1 0x1724
859typedef union _TX_AGG_CNT1_STRUC {
860 struct {
861 USHORT AggSize3Count;
862 USHORT AggSize4Count;
863 } field;
864 UINT32 word;
865} TX_AGG_CNT1_STRUC, *PTX_AGG_CNT1_STRUC;
866
867#define TX_AGG_CNT2 0x1728
868typedef union _TX_AGG_CNT2_STRUC {
869 struct {
870 USHORT AggSize5Count;
871 USHORT AggSize6Count;
872 } field;
873 UINT32 word;
874} TX_AGG_CNT2_STRUC, *PTX_AGG_CNT2_STRUC;
875
876// Debug counter
877#define TX_AGG_CNT3 0x172c
878typedef union _TX_AGG_CNT3_STRUC {
879 struct {
880 USHORT AggSize7Count;
881 USHORT AggSize8Count;
882 } field;
883 UINT32 word;
884} TX_AGG_CNT3_STRUC, *PTX_AGG_CNT3_STRUC;
885
886// Debug counter
887#define TX_AGG_CNT4 0x1730
888typedef union _TX_AGG_CNT4_STRUC {
889 struct {
890 USHORT AggSize9Count;
891 USHORT AggSize10Count;
892 } field;
893 UINT32 word;
894} TX_AGG_CNT4_STRUC, *PTX_AGG_CNT4_STRUC;
895
896#define TX_AGG_CNT5 0x1734
897typedef union _TX_AGG_CNT5_STRUC {
898 struct {
899 USHORT AggSize11Count;
900 USHORT AggSize12Count;
901 } field;
902 UINT32 word;
903} TX_AGG_CNT5_STRUC, *PTX_AGG_CNT5_STRUC;
904
905#define TX_AGG_CNT6 0x1738
906typedef union _TX_AGG_CNT6_STRUC {
907 struct {
908 USHORT AggSize13Count;
909 USHORT AggSize14Count;
910 } field;
911 UINT32 word;
912} TX_AGG_CNT6_STRUC, *PTX_AGG_CNT6_STRUC;
913
914#define TX_AGG_CNT7 0x173c
915typedef union _TX_AGG_CNT7_STRUC {
916 struct {
917 USHORT AggSize15Count;
918 USHORT AggSize16Count;
919 } field;
920 UINT32 word;
921} TX_AGG_CNT7_STRUC, *PTX_AGG_CNT7_STRUC;
922
923#define MPDU_DENSITY_CNT 0x1740
924typedef union _MPDU_DEN_CNT_STRUC {
925 struct {
926 USHORT TXZeroDelCount; //TX zero length delimiter count
927 USHORT RXZeroDelCount; //RX zero length delimiter count
928 } field;
929 UINT32 word;
930} MPDU_DEN_CNT_STRUC, *PMPDU_DEN_CNT_STRUC;
931
932//
933// TXRX control registers - base address 0x3000
934//
935// rt2860b UNKNOWN reg use R/O Reg Addr 0x77d0 first..
936#define TXRX_CSR1 0x77d0
937
938//
939// Security key table memory, base address = 0x1000
940//
941#define MAC_WCID_BASE 0x1800 //8-bytes(use only 6-bytes) * 256 entry =
942#define HW_WCID_ENTRY_SIZE 8
943#define PAIRWISE_KEY_TABLE_BASE 0x4000 // 32-byte * 256-entry = -byte
944#define HW_KEY_ENTRY_SIZE 0x20
945#define PAIRWISE_IVEIV_TABLE_BASE 0x6000 // 8-byte * 256-entry = -byte
946#define MAC_IVEIV_TABLE_BASE 0x6000 // 8-byte * 256-entry = -byte
947#define HW_IVEIV_ENTRY_SIZE 8
948#define MAC_WCID_ATTRIBUTE_BASE 0x6800 // 4-byte * 256-entry = -byte
949#define HW_WCID_ATTRI_SIZE 4
950#define WCID_RESERVED 0x6bfc
951#define SHARED_KEY_TABLE_BASE 0x6c00 // 32-byte * 16-entry = 512-byte
952#define SHARED_KEY_MODE_BASE 0x7000 // 32-byte * 16-entry = 512-byte
953#define HW_SHARED_KEY_MODE_SIZE 4
954#define SHAREDKEYTABLE 0
955#define PAIRWISEKEYTABLE 1
956
957typedef union _SHAREDKEY_MODE_STRUC {
958 struct {
959 UINT32 Bss0Key0CipherAlg:3;
960 UINT32 :1;
961 UINT32 Bss0Key1CipherAlg:3;
962 UINT32 :1;
963 UINT32 Bss0Key2CipherAlg:3;
964 UINT32 :1;
965 UINT32 Bss0Key3CipherAlg:3;
966 UINT32 :1;
967 UINT32 Bss1Key0CipherAlg:3;
968 UINT32 :1;
969 UINT32 Bss1Key1CipherAlg:3;
970 UINT32 :1;
971 UINT32 Bss1Key2CipherAlg:3;
972 UINT32 :1;
973 UINT32 Bss1Key3CipherAlg:3;
974 UINT32 :1;
975 } field;
976 UINT32 word;
977} SHAREDKEY_MODE_STRUC, *PSHAREDKEY_MODE_STRUC;
978
979// 64-entry for pairwise key table
980typedef struct _HW_WCID_ENTRY { // 8-byte per entry
981 UCHAR Address[6];
982 UCHAR Rsv[2];
983} HW_WCID_ENTRY, PHW_WCID_ENTRY;
984
985
986
987//
988// Other on-chip shared memory space, base = 0x2000
989//
990
991// CIS space - base address = 0x2000
992#define HW_CIS_BASE 0x2000
993
994// Carrier-sense CTS frame base address. It's where mac stores carrier-sense frame for carrier-sense function.
995#define HW_CS_CTS_BASE 0x7700
996// DFS CTS frame base address. It's where mac stores CTS frame for DFS.
997#define HW_DFS_CTS_BASE 0x7780
998#define HW_CTS_FRAME_SIZE 0x80
999
1000// 2004-11-08 john - since NULL frame won't be that long (256 byte). We steal 16 tail bytes
1001// to save debugging settings
1002#define HW_DEBUG_SETTING_BASE 0x77f0 // 0x77f0~0x77ff total 16 bytes
1003#define HW_DEBUG_SETTING_BASE2 0x7770 // 0x77f0~0x77ff total 16 bytes
1004
1005// In order to support maximum 8 MBSS and its maximum length is 512 for each beacon
1006// Three section discontinue memory segments will be used.
1007// 1. The original region for BCN 0~3
1008// 2. Extract memory from FCE table for BCN 4~5
1009// 3. Extract memory from Pair-wise key table for BCN 6~7
1010// It occupied those memory of wcid 238~253 for BCN 6
1011// and wcid 222~237 for BCN 7
1012#define HW_BEACON_MAX_SIZE 0x1000 /* unit: byte */
1013#define HW_BEACON_BASE0 0x7800
1014#define HW_BEACON_BASE1 0x7A00
1015#define HW_BEACON_BASE2 0x7C00
1016#define HW_BEACON_BASE3 0x7E00
1017#define HW_BEACON_BASE4 0x7200
1018#define HW_BEACON_BASE5 0x7400
1019#define HW_BEACON_BASE6 0x5DC0
1020#define HW_BEACON_BASE7 0x5BC0
1021
1022#define HW_BEACON_MAX_COUNT 8
1023#define HW_BEACON_OFFSET 0x0200
1024#define HW_BEACON_CONTENT_LEN (HW_BEACON_OFFSET - TXWI_SIZE)
1025
1026// HOST-MCU shared memory - base address = 0x2100
1027#define HOST_CMD_CSR 0x404
1028#define H2M_MAILBOX_CSR 0x7010
1029#define H2M_MAILBOX_CID 0x7014
1030#define H2M_MAILBOX_STATUS 0x701c
1031#define H2M_INT_SRC 0x7024
1032#define H2M_BBP_AGENT 0x7028
1033#define M2H_CMD_DONE_CSR 0x000c
1034#define MCU_TXOP_ARRAY_BASE 0x000c // TODO: to be provided by Albert
1035#define MCU_TXOP_ENTRY_SIZE 32 // TODO: to be provided by Albert
1036#define MAX_NUM_OF_TXOP_ENTRY 16 // TODO: must be same with 8051 firmware
1037#define MCU_MBOX_VERSION 0x01 // TODO: to be confirmed by Albert
1038#define MCU_MBOX_VERSION_OFFSET 5 // TODO: to be provided by Albert
1039
1040//
1041// Host DMA registers - base address 0x200 . TX0-3=EDCAQid0-3, TX4=HCCA, TX5=MGMT,
1042//
1043//
1044// DMA RING DESCRIPTOR
1045//
1046#define E2PROM_CSR 0x0004
1047#define IO_CNTL_CSR 0x77d0
1048
1049#ifdef RT2870
1050// 8051 firmware image for usb - use last-half base address = 0x3000
1051#define FIRMWARE_IMAGE_BASE 0x3000
1052#define MAX_FIRMWARE_IMAGE_SIZE 0x1000 // 4kbyte
1053#endif // RT2870 //
1054
1055// ================================================================
1056// Tx / Rx / Mgmt ring descriptor definition
1057// ================================================================
1058
1059// the following PID values are used to mark outgoing frame type in TXD->PID so that
1060// proper TX statistics can be collected based on these categories
1061// b3-2 of PID field -
1062#define PID_MGMT 0x05
1063#define PID_BEACON 0x0c
1064#define PID_DATA_NORMALUCAST 0x02
1065#define PID_DATA_AMPDU 0x04
1066#define PID_DATA_NO_ACK 0x08
1067#define PID_DATA_NOT_NORM_ACK 0x03
1068
1069// value domain of pTxD->HostQId (4-bit: 0~15)
1070#define QID_AC_BK 1 // meet ACI definition in 802.11e
1071#define QID_AC_BE 0 // meet ACI definition in 802.11e
1072#define QID_AC_VI 2
1073#define QID_AC_VO 3
1074#define QID_HCCA 4
1075#define NUM_OF_TX_RING 5
1076#define QID_MGMT 13
1077#define QID_RX 14
1078#define QID_OTHER 15
1079
1080
1081// ------------------------------------------------------
1082// BBP & RF definition
1083// ------------------------------------------------------
1084#define BUSY 1
1085#define IDLE 0
1086
1087#define RF_R00 0
1088#define RF_R01 1
1089#define RF_R02 2
1090#define RF_R03 3
1091#define RF_R04 4
1092#define RF_R05 5
1093#define RF_R06 6
1094#define RF_R07 7
1095#define RF_R08 8
1096#define RF_R09 9
1097#define RF_R10 10
1098#define RF_R11 11
1099#define RF_R12 12
1100#define RF_R13 13
1101#define RF_R14 14
1102#define RF_R15 15
1103#define RF_R16 16
1104#define RF_R17 17
1105#define RF_R18 18
1106#define RF_R19 19
1107#define RF_R20 20
1108#define RF_R21 21
1109#define RF_R22 22
1110#define RF_R23 23
1111#define RF_R24 24
1112#define RF_R25 25
1113#define RF_R26 26
1114#define RF_R27 27
1115#define RF_R28 28
1116#define RF_R29 29
1117#define RF_R30 30
1118#define RF_R31 31
1119
1120#define BBP_R0 0 // version
1121#define BBP_R1 1 // TSSI
1122#define BBP_R2 2 // TX configure
1123#define BBP_R3 3
1124#define BBP_R4 4
1125#define BBP_R5 5
1126#define BBP_R6 6
1127#define BBP_R14 14 // RX configure
1128#define BBP_R16 16
1129#define BBP_R17 17 // RX sensibility
1130#define BBP_R18 18
1131#define BBP_R21 21
1132#define BBP_R22 22
1133#define BBP_R24 24
1134#define BBP_R25 25
1135#ifdef RT30xx
1136#define BBP_R31 31
1137#endif
1138#define BBP_R49 49 //TSSI
1139#define BBP_R50 50
1140#define BBP_R51 51
1141#define BBP_R52 52
1142#define BBP_R55 55
1143#define BBP_R62 62 // Rx SQ0 Threshold HIGH
1144#define BBP_R63 63
1145#define BBP_R64 64
1146#define BBP_R65 65
1147#define BBP_R66 66
1148#define BBP_R67 67
1149#define BBP_R68 68
1150#define BBP_R69 69
1151#define BBP_R70 70 // Rx AGC SQ CCK Xcorr threshold
1152#define BBP_R73 73
1153#define BBP_R75 75
1154#define BBP_R77 77
1155#ifdef RT30xx
1156#define BBP_R79 79
1157#define BBP_R80 80
1158#endif
1159#define BBP_R81 81
1160#define BBP_R82 82
1161#define BBP_R83 83
1162#define BBP_R84 84
1163#define BBP_R86 86
1164#define BBP_R91 91
1165#define BBP_R92 92
1166#define BBP_R94 94 // Tx Gain Control
1167#define BBP_R103 103
1168#define BBP_R105 105
1169#define BBP_R113 113
1170#define BBP_R114 114
1171#define BBP_R115 115
1172#define BBP_R116 116
1173#define BBP_R117 117
1174#define BBP_R118 118
1175#define BBP_R119 119
1176#define BBP_R120 120
1177#define BBP_R121 121
1178#define BBP_R122 122
1179#define BBP_R123 123
1180#ifdef RT30xx
1181#define BBP_R138 138 // add by johnli, RF power sequence setup, ADC dynamic on/off control
1182#endif // RT30xx //
1183
1184
1185#define BBPR94_DEFAULT 0x06 // Add 1 value will gain 1db
1186
1187#define RSSI_FOR_VERY_LOW_SENSIBILITY -35
1188#define RSSI_FOR_LOW_SENSIBILITY -58
1189#define RSSI_FOR_MID_LOW_SENSIBILITY -80
1190#define RSSI_FOR_MID_SENSIBILITY -90
1191
1192//-------------------------------------------------------------------------
1193// EEPROM definition
1194//-------------------------------------------------------------------------
1195#define EEDO 0x08
1196#define EEDI 0x04
1197#define EECS 0x02
1198#define EESK 0x01
1199#define EERL 0x80
1200
1201#define EEPROM_WRITE_OPCODE 0x05
1202#define EEPROM_READ_OPCODE 0x06
1203#define EEPROM_EWDS_OPCODE 0x10
1204#define EEPROM_EWEN_OPCODE 0x13
1205
1206#define NUM_EEPROM_BBP_PARMS 19 // Include NIC Config 0, 1, CR, TX ALC step, BBPs
1207#define NUM_EEPROM_TX_G_PARMS 7
1208#define EEPROM_NIC1_OFFSET 0x34 // The address is from NIC config 0, not BBP register ID
1209#define EEPROM_NIC2_OFFSET 0x36 // The address is from NIC config 0, not BBP register ID
1210#define EEPROM_BBP_BASE_OFFSET 0xf0 // The address is from NIC config 0, not BBP register ID
1211#define EEPROM_G_TX_PWR_OFFSET 0x52
1212#define EEPROM_G_TX2_PWR_OFFSET 0x60
1213#define EEPROM_LED1_OFFSET 0x3c
1214#define EEPROM_LED2_OFFSET 0x3e
1215#define EEPROM_LED3_OFFSET 0x40
1216#define EEPROM_LNA_OFFSET 0x44
1217#define EEPROM_RSSI_BG_OFFSET 0x46
1218#define EEPROM_RSSI_A_OFFSET 0x4a
1219#define EEPROM_DEFINE_MAX_TXPWR 0x4e
1220#define EEPROM_TXPOWER_BYRATE_20MHZ_2_4G 0xde // 20MHZ 2.4G tx power.
1221#define EEPROM_TXPOWER_BYRATE_40MHZ_2_4G 0xee // 40MHZ 2.4G tx power.
1222#define EEPROM_TXPOWER_BYRATE_20MHZ_5G 0xfa // 20MHZ 5G tx power.
1223#define EEPROM_TXPOWER_BYRATE_40MHZ_5G 0x10a // 40MHZ 5G tx power.
1224#define EEPROM_A_TX_PWR_OFFSET 0x78
1225#define EEPROM_A_TX2_PWR_OFFSET 0xa6
1226#define EEPROM_VERSION_OFFSET 0x02
1227#define EEPROM_FREQ_OFFSET 0x3a
1228#define EEPROM_TXPOWER_BYRATE 0xde // 20MHZ power.
1229#define EEPROM_TXPOWER_DELTA 0x50 // 20MHZ AND 40 MHZ use different power. This is delta in 40MHZ.
1230#define VALID_EEPROM_VERSION 1
1231
1232// PairKeyMode definition
1233#define PKMODE_NONE 0
1234#define PKMODE_WEP64 1
1235#define PKMODE_WEP128 2
1236#define PKMODE_TKIP 3
1237#define PKMODE_AES 4
1238#define PKMODE_CKIP64 5
1239#define PKMODE_CKIP128 6
1240#define PKMODE_TKIP_NO_MIC 7 // MIC appended by driver: not a valid value in hardware key table
1241
1242// =================================================================================
1243// WCID format
1244// =================================================================================
1245//7.1 WCID ENTRY format : 8bytes
1246typedef struct _WCID_ENTRY_STRUC {
1247 UCHAR RXBABitmap7; // bit0 for TID8, bit7 for TID 15
1248 UCHAR RXBABitmap0; // bit0 for TID0, bit7 for TID 7
1249 UCHAR MAC[6]; // 0 for shared key table. 1 for pairwise key table
1250} WCID_ENTRY_STRUC, *PWCID_ENTRY_STRUC;
1251
1252//8.1.1 SECURITY KEY format : 8DW
1253// 32-byte per entry, total 16-entry for shared key table, 64-entry for pairwise key table
1254typedef struct _HW_KEY_ENTRY { // 32-byte per entry
1255 UCHAR Key[16];
1256 UCHAR TxMic[8];
1257 UCHAR RxMic[8];
1258} HW_KEY_ENTRY, *PHW_KEY_ENTRY;
1259
1260//8.1.2 IV/EIV format : 2DW
1261
1262//8.1.3 RX attribute entry format : 1DW
1263typedef struct _MAC_ATTRIBUTE_STRUC {
1264 UINT32 KeyTab:1; // 0 for shared key table. 1 for pairwise key table
1265 UINT32 PairKeyMode:3;
1266 UINT32 BSSIDIdx:3; //multipleBSS index for the WCID
1267 UINT32 RXWIUDF:3;
1268 UINT32 rsv:22;
1269} MAC_ATTRIBUTE_STRUC, *PMAC_ATTRIBUTE_STRUC;
1270
1271// =================================================================================
1272// TX / RX ring descriptor format
1273// =================================================================================
1274
1275// the first 24-byte in TXD is called TXINFO and will be DMAed to MAC block through TXFIFO.
1276// MAC block use this TXINFO to control the transmission behavior of this frame.
1277#define FIFO_MGMT 0
1278#define FIFO_HCCA 1
1279#define FIFO_EDCA 2
1280
1281//
1282// TX descriptor format, Tx ring, Mgmt Ring
1283//
1284typedef struct PACKED _TXD_STRUC {
1285 // Word 0
1286 UINT32 SDPtr0;
1287 // Word 1
1288 UINT32 SDLen1:14;
1289 UINT32 LastSec1:1;
1290 UINT32 Burst:1;
1291 UINT32 SDLen0:14;
1292 UINT32 LastSec0:1;
1293 UINT32 DMADONE:1;
1294 //Word2
1295 UINT32 SDPtr1;
1296 //Word3
1297 UINT32 rsv2:24;
1298 UINT32 WIV:1; // Wireless Info Valid. 1 if Driver already fill WI, o if DMA needs to copy WI to correctposition
1299 UINT32 QSEL:2; // select on-chip FIFO ID for 2nd-stage output scheduler.0:MGMT, 1:HCCA 2:EDCA
1300 UINT32 rsv:2;
1301 UINT32 TCO:1; //
1302 UINT32 UCO:1; //
1303 UINT32 ICO:1; //
1304} TXD_STRUC, *PTXD_STRUC;
1305
1306//
1307// TXD Wireless Information format for Tx ring and Mgmt Ring
1308//
1309//txop : for txop mode
1310// 0:txop for the MPDU frame will be handles by ASIC by register
1311// 1/2/3:the MPDU frame is send after PIFS/backoff/SIFS
1312typedef struct PACKED _TXWI_STRUC {
1313 // Word 0
1314 UINT32 FRAG:1; // 1 to inform TKIP engine this is a fragment.
1315 UINT32 MIMOps:1; // the remote peer is in dynamic MIMO-PS mode
1316 UINT32 CFACK:1;
1317 UINT32 TS:1;
1318
1319 UINT32 AMPDU:1;
1320 UINT32 MpduDensity:3;
1321 UINT32 txop:2; //FOR "THIS" frame. 0:HT TXOP rule , 1:PIFS TX ,2:Backoff, 3:sifs only when previous frame exchange is successful.
1322 UINT32 rsv:6;
1323
1324 UINT32 MCS:7;
1325 UINT32 BW:1; //channel bandwidth 20MHz or 40 MHz
1326 UINT32 ShortGI:1;
1327 UINT32 STBC:2; // 1: STBC support MCS =0-7, 2,3 : RESERVE
1328 UINT32 Ifs:1; //
1329 UINT32 rsv2:1;
1330 UINT32 TxBF:1; // 3*3
1331 UINT32 PHYMODE:2;
1332 // Word 1
1333 UINT32 ACK:1;
1334 UINT32 NSEQ:1;
1335 UINT32 BAWinSize:6;
1336 UINT32 WirelessCliID:8;
1337 UINT32 MPDUtotalByteCount:12;
1338 UINT32 PacketId:4;
1339 //Word2
1340 UINT32 IV;
1341 //Word3
1342 UINT32 EIV;
1343} TXWI_STRUC, *PTXWI_STRUC;
1344
1345//
1346// Rx descriptor format, Rx Ring
1347//
1348//
1349// RXWI wireless information format, in PBF. invisible in driver.
1350//
1351typedef struct PACKED _RXWI_STRUC {
1352 // Word 0
1353 UINT32 WirelessCliID:8;
1354 UINT32 KeyIndex:2;
1355 UINT32 BSSID:3;
1356 UINT32 UDF:3;
1357 UINT32 MPDUtotalByteCount:12;
1358 UINT32 TID:4;
1359 // Word 1
1360 UINT32 FRAG:4;
1361 UINT32 SEQUENCE:12;
1362 UINT32 MCS:7;
1363 UINT32 BW:1;
1364 UINT32 ShortGI:1;
1365 UINT32 STBC:2;
1366 UINT32 rsv:3;
1367 UINT32 PHYMODE:2; // 1: this RX frame is unicast to me
1368 //Word2
1369 UINT32 RSSI0:8;
1370 UINT32 RSSI1:8;
1371 UINT32 RSSI2:8;
1372 UINT32 rsv1:8;
1373 //Word3
1374 UINT32 SNR0:8;
1375 UINT32 SNR1:8;
1376 UINT32 rsv2:16;
1377} RXWI_STRUC, *PRXWI_STRUC;
1378
1379// =================================================================================
1380// HOST-MCU communication data structure
1381// =================================================================================
1382
1383//
1384// H2M_MAILBOX_CSR: Host-to-MCU Mailbox
1385//
1386typedef union _H2M_MAILBOX_STRUC {
1387 struct {
1388 UINT32 LowByte:8;
1389 UINT32 HighByte:8;
1390 UINT32 CmdToken:8;
1391 UINT32 Owner:8;
1392 } field;
1393 UINT32 word;
1394} H2M_MAILBOX_STRUC, *PH2M_MAILBOX_STRUC;
1395
1396//
1397// M2H_CMD_DONE_CSR: MCU-to-Host command complete indication
1398//
1399typedef union _M2H_CMD_DONE_STRUC {
1400 struct {
1401 UINT32 CmdToken0;
1402 UINT32 CmdToken1;
1403 UINT32 CmdToken2;
1404 UINT32 CmdToken3;
1405 } field;
1406 UINT32 word;
1407} M2H_CMD_DONE_STRUC, *PM2H_CMD_DONE_STRUC;
1408
1409//
1410// MCU_LEDCS: MCU LED Control Setting.
1411//
1412typedef union _MCU_LEDCS_STRUC {
1413 struct {
1414 UCHAR LedMode:7;
1415 UCHAR Polarity:1;
1416 } field;
1417 UCHAR word;
1418} MCU_LEDCS_STRUC, *PMCU_LEDCS_STRUC;
1419
1420// =================================================================================
1421// Register format
1422// =================================================================================
1423
1424
1425
1426//NAV_TIME_CFG :NAV
1427typedef union _NAV_TIME_CFG_STRUC {
1428 struct {
1429 UCHAR Sifs; // in unit of 1-us
1430 UCHAR SlotTime; // in unit of 1-us
1431 USHORT Eifs:9; // in unit of 1-us
1432 USHORT ZeroSifs:1; // Applied zero SIFS timer after OFDM RX 0: disable
1433 USHORT rsv:6;
1434 } field;
1435 UINT32 word;
1436} NAV_TIME_CFG_STRUC, *PNAV_TIME_CFG_STRUC;
1437
1438//
1439// RX_FILTR_CFG: /RX configuration register
1440//
1441typedef union _RX_FILTR_CFG_STRUC {
1442 struct {
1443 UINT32 DropCRCErr:1; // Drop CRC error
1444 UINT32 DropPhyErr:1; // Drop physical error
1445 UINT32 DropNotToMe:1; // Drop not to me unicast frame
1446 UINT32 DropNotMyBSSID:1; // Drop fram ToDs bit is true
1447
1448 UINT32 DropVerErr:1; // Drop version error frame
1449 UINT32 DropMcast:1; // Drop multicast frames
1450 UINT32 DropBcast:1; // Drop broadcast frames
1451 UINT32 DropDuplicate:1; // Drop duplicate frame
1452
1453 UINT32 DropCFEndAck:1; // Drop Ps-Poll
1454 UINT32 DropCFEnd:1; // Drop Ps-Poll
1455 UINT32 DropAck:1; // Drop Ps-Poll
1456 UINT32 DropCts:1; // Drop Ps-Poll
1457
1458 UINT32 DropRts:1; // Drop Ps-Poll
1459 UINT32 DropPsPoll:1; // Drop Ps-Poll
1460 UINT32 DropBA:1; //
1461 UINT32 DropBAR:1; //
1462
1463 UINT32 DropRsvCntlType:1;
1464 UINT32 :15;
1465 } field;
1466 UINT32 word;
1467} RX_FILTR_CFG_STRUC, *PRX_FILTR_CFG_STRUC;
1468
1469//
1470// PHY_CSR4: RF serial control register
1471//
1472typedef union _PHY_CSR4_STRUC {
1473 struct {
1474 UINT32 RFRegValue:24; // Register value (include register id) serial out to RF/IF chip.
1475 UINT32 NumberOfBits:5; // Number of bits used in RFRegValue (I:20, RFMD:22)
1476 UINT32 IFSelect:1; // 1: select IF to program, 0: select RF to program
1477 UINT32 PLL_LD:1; // RF PLL_LD status
1478 UINT32 Busy:1; // 1: ASIC is busy execute RF programming.
1479 } field;
1480 UINT32 word;
1481} PHY_CSR4_STRUC, *PPHY_CSR4_STRUC;
1482
1483//
1484// SEC_CSR5: shared key table security mode register
1485//
1486typedef union _SEC_CSR5_STRUC {
1487 struct {
1488 UINT32 Bss2Key0CipherAlg:3;
1489 UINT32 :1;
1490 UINT32 Bss2Key1CipherAlg:3;
1491 UINT32 :1;
1492 UINT32 Bss2Key2CipherAlg:3;
1493 UINT32 :1;
1494 UINT32 Bss2Key3CipherAlg:3;
1495 UINT32 :1;
1496 UINT32 Bss3Key0CipherAlg:3;
1497 UINT32 :1;
1498 UINT32 Bss3Key1CipherAlg:3;
1499 UINT32 :1;
1500 UINT32 Bss3Key2CipherAlg:3;
1501 UINT32 :1;
1502 UINT32 Bss3Key3CipherAlg:3;
1503 UINT32 :1;
1504 } field;
1505 UINT32 word;
1506} SEC_CSR5_STRUC, *PSEC_CSR5_STRUC;
1507
1508//
1509// HOST_CMD_CSR: For HOST to interrupt embedded processor
1510//
1511typedef union _HOST_CMD_CSR_STRUC {
1512 struct {
1513 UINT32 HostCommand:8;
1514 UINT32 Rsv:24;
1515 } field;
1516 UINT32 word;
1517} HOST_CMD_CSR_STRUC, *PHOST_CMD_CSR_STRUC;
1518
1519//
1520// AIFSN_CSR: AIFSN for each EDCA AC
1521//
1522
1523
1524
1525//
1526// E2PROM_CSR: EEPROM control register
1527//
1528typedef union _E2PROM_CSR_STRUC {
1529 struct {
1530 UINT32 Reload:1; // Reload EEPROM content, write one to reload, self-cleared.
1531 UINT32 EepromSK:1;
1532 UINT32 EepromCS:1;
1533 UINT32 EepromDI:1;
1534 UINT32 EepromDO:1;
1535 UINT32 Type:1; // 1: 93C46, 0:93C66
1536 UINT32 LoadStatus:1; // 1:loading, 0:done
1537 UINT32 Rsvd:25;
1538 } field;
1539 UINT32 word;
1540} E2PROM_CSR_STRUC, *PE2PROM_CSR_STRUC;
1541
1542// -------------------------------------------------------------------
1543// E2PROM data layout
1544// -------------------------------------------------------------------
1545
1546//
1547// EEPROM antenna select format
1548//
1549typedef union _EEPROM_ANTENNA_STRUC {
1550 struct {
1551 USHORT RxPath:4; // 1: 1R, 2: 2R, 3: 3R
1552 USHORT TxPath:4; // 1: 1T, 2: 2T
1553 USHORT RfIcType:4; // see E2PROM document
1554 USHORT Rsv:4;
1555 } field;
1556 USHORT word;
1557} EEPROM_ANTENNA_STRUC, *PEEPROM_ANTENNA_STRUC;
1558
1559typedef union _EEPROM_NIC_CINFIG2_STRUC {
1560 struct {
1561 USHORT HardwareRadioControl:1; // 1:enable, 0:disable
1562 USHORT DynamicTxAgcControl:1; //
1563 USHORT ExternalLNAForG:1; //
1564 USHORT ExternalLNAForA:1; // external LNA enable for 2.4G
1565 USHORT CardbusAcceleration:1; // !!! NOTE: 0 - enable, 1 - disable
1566 USHORT BW40MSidebandForG:1;
1567 USHORT BW40MSidebandForA:1;
1568 USHORT EnableWPSPBC:1; // WPS PBC Control bit
1569 USHORT BW40MAvailForG:1; // 0:enable, 1:disable
1570 USHORT BW40MAvailForA:1; // 0:enable, 1:disable
1571#ifndef RT30xx
1572 USHORT Rsv2:6; // must be 0
1573#endif
1574#ifdef RT30xx
1575 USHORT Rsv1:1; // must be 0
1576 USHORT AntDiversity:1; // Antenna diversity
1577 USHORT Rsv2:3; // must be 0
1578 USHORT DACTestBit:1; // control if driver should patch the DAC issue
1579#endif
1580 } field;
1581 USHORT word;
1582} EEPROM_NIC_CONFIG2_STRUC, *PEEPROM_NIC_CONFIG2_STRUC;
1583
1584//
1585// TX_PWR Value valid range 0xFA(-6) ~ 0x24(36)
1586//
1587typedef union _EEPROM_TX_PWR_STRUC {
1588 struct {
1589 CHAR Byte0; // Low Byte
1590 CHAR Byte1; // High Byte
1591 } field;
1592 USHORT word;
1593} EEPROM_TX_PWR_STRUC, *PEEPROM_TX_PWR_STRUC;
1594
1595typedef union _EEPROM_VERSION_STRUC {
1596 struct {
1597 UCHAR FaeReleaseNumber; // Low Byte
1598 UCHAR Version; // High Byte
1599 } field;
1600 USHORT word;
1601} EEPROM_VERSION_STRUC, *PEEPROM_VERSION_STRUC;
1602
1603typedef union _EEPROM_LED_STRUC {
1604 struct {
1605 USHORT PolarityRDY_G:1; // Polarity RDY_G setting.
1606 USHORT PolarityRDY_A:1; // Polarity RDY_A setting.
1607 USHORT PolarityACT:1; // Polarity ACT setting.
1608 USHORT PolarityGPIO_0:1; // Polarity GPIO#0 setting.
1609 USHORT PolarityGPIO_1:1; // Polarity GPIO#1 setting.
1610 USHORT PolarityGPIO_2:1; // Polarity GPIO#2 setting.
1611 USHORT PolarityGPIO_3:1; // Polarity GPIO#3 setting.
1612 USHORT PolarityGPIO_4:1; // Polarity GPIO#4 setting.
1613 USHORT LedMode:5; // Led mode.
1614 USHORT Rsvd:3; // Reserved
1615 } field;
1616 USHORT word;
1617} EEPROM_LED_STRUC, *PEEPROM_LED_STRUC;
1618
1619typedef union _EEPROM_TXPOWER_DELTA_STRUC {
1620 struct {
1621 UCHAR DeltaValue:6; // Tx Power dalta value (MAX=4)
1622 UCHAR Type:1; // 1: plus the delta value, 0: minus the delta value
1623 UCHAR TxPowerEnable:1;// Enable
1624 } field;
1625 UCHAR value;
1626} EEPROM_TXPOWER_DELTA_STRUC, *PEEPROM_TXPOWER_DELTA_STRUC;
1627
1628//
1629// QOS_CSR0: TXOP holder address0 register
1630//
1631typedef union _QOS_CSR0_STRUC {
1632 struct {
1633 UCHAR Byte0; // MAC address byte 0
1634 UCHAR Byte1; // MAC address byte 1
1635 UCHAR Byte2; // MAC address byte 2
1636 UCHAR Byte3; // MAC address byte 3
1637 } field;
1638 UINT32 word;
1639} QOS_CSR0_STRUC, *PQOS_CSR0_STRUC;
1640
1641//
1642// QOS_CSR1: TXOP holder address1 register
1643//
1644typedef union _QOS_CSR1_STRUC {
1645 struct {
1646 UCHAR Byte4; // MAC address byte 4
1647 UCHAR Byte5; // MAC address byte 5
1648 UCHAR Rsvd0;
1649 UCHAR Rsvd1;
1650 } field;
1651 UINT32 word;
1652} QOS_CSR1_STRUC, *PQOS_CSR1_STRUC;
1653
1654#define RF_CSR_CFG 0x500
1655typedef union _RF_CSR_CFG_STRUC {
1656 struct {
1657 UINT RF_CSR_DATA:8; // DATA
1658 UINT TESTCSR_RFACC_REGNUM:5; // RF register ID
1659 UINT Rsvd2:3; // Reserved
1660 UINT RF_CSR_WR:1; // 0: read 1: write
1661 UINT RF_CSR_KICK:1; // kick RF register read/write
1662 UINT Rsvd1:14; // Reserved
1663 } field;
1664 UINT word;
1665} RF_CSR_CFG_STRUC, *PRF_CSR_CFG_STRUC;
1666
1667#endif // __RT28XX_H__
diff --git a/drivers/staging/rt2870/rt_config.h b/drivers/staging/rt2870/rt_config.h
index 09e76759f889..1f6d6ed5630c 100644
--- a/drivers/staging/rt2870/rt_config.h
+++ b/drivers/staging/rt2870/rt_config.h
@@ -1,75 +1 @@
1/* #include "../rt2860/rt_config.h"
2 *************************************************************************
3 * Ralink Tech Inc.
4 * 5F., No.36, Taiyuan St., Jhubei City,
5 * Hsinchu County 302,
6 * Taiwan, R.O.C.
7 *
8 * (c) Copyright 2002-2007, Ralink Technology, Inc.
9 *
10 * This program is free software; you can redistribute it and/or modify *
11 * it under the terms of the GNU General Public License as published by *
12 * the Free Software Foundation; either version 2 of the License, or *
13 * (at your option) any later version. *
14 * *
15 * This program is distributed in the hope that it will be useful, *
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
18 * GNU General Public License for more details. *
19 * *
20 * You should have received a copy of the GNU General Public License *
21 * along with this program; if not, write to the *
22 * Free Software Foundation, Inc., *
23 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
24 * *
25 *************************************************************************
26
27 Module Name:
28 rt_config.h
29
30 Abstract:
31 Central header file to maintain all include files for all NDIS
32 miniport driver routines.
33
34 Revision History:
35 Who When What
36 -------- ---------- ----------------------------------------------
37 Paul Lin 08-01-2002 created
38
39*/
40#ifndef __RT_CONFIG_H__
41#define __RT_CONFIG_H__
42
43#include "rtmp_type.h"
44#ifdef LINUX
45#include "rt_linux.h"
46#endif
47#include "rtmp_def.h"
48#include "rt28xx.h"
49
50
51#ifdef RT2870
52#include "rt2870.h"
53#endif // RT2870 //
54
55#include "oid.h"
56#include "mlme.h"
57#include "wpa.h"
58#include "md5.h"
59#include "rtmp.h"
60#include "ap.h"
61#include "dfs.h"
62#include "chlist.h"
63#include "spectrum.h"
64
65
66#ifdef IGMP_SNOOP_SUPPORT
67#include "igmp_snoop.h"
68#endif // IGMP_SNOOP_SUPPORT //
69
70#ifdef IKANOS_VX_1X0
71#include "vr_ikans.h"
72#endif // IKANOS_VX_1X0 //
73
74#endif // __RT_CONFIG_H__
75
diff --git a/drivers/staging/rt2870/rt_linux.c b/drivers/staging/rt2870/rt_linux.c
index bd1d429f835e..88c697bf90eb 100644
--- a/drivers/staging/rt2870/rt_linux.c
+++ b/drivers/staging/rt2870/rt_linux.c
@@ -1,1010 +1 @@
1/* #include "../rt2860/rt_linux.c"
2 *************************************************************************
3 * Ralink Tech Inc.
4 * 5F., No.36, Taiyuan St., Jhubei City,
5 * Hsinchu County 302,
6 * Taiwan, R.O.C.
7 *
8 * (c) Copyright 2002-2007, Ralink Technology, Inc.
9 *
10 * This program is free software; you can redistribute it and/or modify *
11 * it under the terms of the GNU General Public License as published by *
12 * the Free Software Foundation; either version 2 of the License, or *
13 * (at your option) any later version. *
14 * *
15 * This program is distributed in the hope that it will be useful, *
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
18 * GNU General Public License for more details. *
19 * *
20 * You should have received a copy of the GNU General Public License *
21 * along with this program; if not, write to the *
22 * Free Software Foundation, Inc., *
23 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
24 * *
25 *************************************************************************
26 */
27
28#include "rt_config.h"
29
30ULONG RTDebugLevel = RT_DEBUG_ERROR;
31
32BUILD_TIMER_FUNCTION(MlmePeriodicExec);
33BUILD_TIMER_FUNCTION(AsicRxAntEvalTimeout);
34BUILD_TIMER_FUNCTION(APSDPeriodicExec);
35BUILD_TIMER_FUNCTION(AsicRfTuningExec);
36#ifdef RT2870
37BUILD_TIMER_FUNCTION(BeaconUpdateExec);
38#endif // RT2870 //
39
40BUILD_TIMER_FUNCTION(BeaconTimeout);
41BUILD_TIMER_FUNCTION(ScanTimeout);
42BUILD_TIMER_FUNCTION(AuthTimeout);
43BUILD_TIMER_FUNCTION(AssocTimeout);
44BUILD_TIMER_FUNCTION(ReassocTimeout);
45BUILD_TIMER_FUNCTION(DisassocTimeout);
46BUILD_TIMER_FUNCTION(LinkDownExec);
47BUILD_TIMER_FUNCTION(StaQuickResponeForRateUpExec);
48BUILD_TIMER_FUNCTION(WpaDisassocApAndBlockAssoc);
49
50// for wireless system event message
51char const *pWirelessSysEventText[IW_SYS_EVENT_TYPE_NUM] = {
52 // system status event
53 "had associated successfully", /* IW_ASSOC_EVENT_FLAG */
54 "had disassociated", /* IW_DISASSOC_EVENT_FLAG */
55 "had deauthenticated", /* IW_DEAUTH_EVENT_FLAG */
56 "had been aged-out and disassociated", /* IW_AGEOUT_EVENT_FLAG */
57 "occurred CounterMeasures attack", /* IW_COUNTER_MEASURES_EVENT_FLAG */
58 "occurred replay counter different in Key Handshaking", /* IW_REPLAY_COUNTER_DIFF_EVENT_FLAG */
59 "occurred RSNIE different in Key Handshaking", /* IW_RSNIE_DIFF_EVENT_FLAG */
60 "occurred MIC different in Key Handshaking", /* IW_MIC_DIFF_EVENT_FLAG */
61 "occurred ICV error in RX", /* IW_ICV_ERROR_EVENT_FLAG */
62 "occurred MIC error in RX", /* IW_MIC_ERROR_EVENT_FLAG */
63 "Group Key Handshaking timeout", /* IW_GROUP_HS_TIMEOUT_EVENT_FLAG */
64 "Pairwise Key Handshaking timeout", /* IW_PAIRWISE_HS_TIMEOUT_EVENT_FLAG */
65 "RSN IE sanity check failure", /* IW_RSNIE_SANITY_FAIL_EVENT_FLAG */
66 "set key done in WPA/WPAPSK", /* IW_SET_KEY_DONE_WPA1_EVENT_FLAG */
67 "set key done in WPA2/WPA2PSK", /* IW_SET_KEY_DONE_WPA2_EVENT_FLAG */
68 "connects with our wireless client", /* IW_STA_LINKUP_EVENT_FLAG */
69 "disconnects with our wireless client", /* IW_STA_LINKDOWN_EVENT_FLAG */
70 "scan completed" /* IW_SCAN_COMPLETED_EVENT_FLAG */
71 "scan terminate!! Busy!! Enqueue fail!!" /* IW_SCAN_ENQUEUE_FAIL_EVENT_FLAG */
72 };
73
74// for wireless IDS_spoof_attack event message
75char const *pWirelessSpoofEventText[IW_SPOOF_EVENT_TYPE_NUM] = {
76 "detected conflict SSID", /* IW_CONFLICT_SSID_EVENT_FLAG */
77 "detected spoofed association response", /* IW_SPOOF_ASSOC_RESP_EVENT_FLAG */
78 "detected spoofed reassociation responses", /* IW_SPOOF_REASSOC_RESP_EVENT_FLAG */
79 "detected spoofed probe response", /* IW_SPOOF_PROBE_RESP_EVENT_FLAG */
80 "detected spoofed beacon", /* IW_SPOOF_BEACON_EVENT_FLAG */
81 "detected spoofed disassociation", /* IW_SPOOF_DISASSOC_EVENT_FLAG */
82 "detected spoofed authentication", /* IW_SPOOF_AUTH_EVENT_FLAG */
83 "detected spoofed deauthentication", /* IW_SPOOF_DEAUTH_EVENT_FLAG */
84 "detected spoofed unknown management frame", /* IW_SPOOF_UNKNOWN_MGMT_EVENT_FLAG */
85 "detected replay attack" /* IW_REPLAY_ATTACK_EVENT_FLAG */
86 };
87
88// for wireless IDS_flooding_attack event message
89char const *pWirelessFloodEventText[IW_FLOOD_EVENT_TYPE_NUM] = {
90 "detected authentication flooding", /* IW_FLOOD_AUTH_EVENT_FLAG */
91 "detected association request flooding", /* IW_FLOOD_ASSOC_REQ_EVENT_FLAG */
92 "detected reassociation request flooding", /* IW_FLOOD_REASSOC_REQ_EVENT_FLAG */
93 "detected probe request flooding", /* IW_FLOOD_PROBE_REQ_EVENT_FLAG */
94 "detected disassociation flooding", /* IW_FLOOD_DISASSOC_EVENT_FLAG */
95 "detected deauthentication flooding", /* IW_FLOOD_DEAUTH_EVENT_FLAG */
96 "detected 802.1x eap-request flooding" /* IW_FLOOD_EAP_REQ_EVENT_FLAG */
97 };
98
99/* timeout -- ms */
100VOID RTMP_SetPeriodicTimer(
101 IN NDIS_MINIPORT_TIMER *pTimer,
102 IN unsigned long timeout)
103{
104 timeout = ((timeout*HZ) / 1000);
105 pTimer->expires = jiffies + timeout;
106 add_timer(pTimer);
107}
108
109/* convert NdisMInitializeTimer --> RTMP_OS_Init_Timer */
110VOID RTMP_OS_Init_Timer(
111 IN PRTMP_ADAPTER pAd,
112 IN NDIS_MINIPORT_TIMER *pTimer,
113 IN TIMER_FUNCTION function,
114 IN PVOID data)
115{
116 init_timer(pTimer);
117 pTimer->data = (unsigned long)data;
118 pTimer->function = function;
119}
120
121
122VOID RTMP_OS_Add_Timer(
123 IN NDIS_MINIPORT_TIMER *pTimer,
124 IN unsigned long timeout)
125{
126 if (timer_pending(pTimer))
127 return;
128
129 timeout = ((timeout*HZ) / 1000);
130 pTimer->expires = jiffies + timeout;
131 add_timer(pTimer);
132}
133
134VOID RTMP_OS_Mod_Timer(
135 IN NDIS_MINIPORT_TIMER *pTimer,
136 IN unsigned long timeout)
137{
138 timeout = ((timeout*HZ) / 1000);
139 mod_timer(pTimer, jiffies + timeout);
140}
141
142VOID RTMP_OS_Del_Timer(
143 IN NDIS_MINIPORT_TIMER *pTimer,
144 OUT BOOLEAN *pCancelled)
145{
146 if (timer_pending(pTimer))
147 {
148 *pCancelled = del_timer_sync(pTimer);
149 }
150 else
151 {
152 *pCancelled = TRUE;
153 }
154
155}
156
157VOID RTMP_OS_Release_Packet(
158 IN PRTMP_ADAPTER pAd,
159 IN PQUEUE_ENTRY pEntry)
160{
161 //RTMPFreeNdisPacket(pAd, (struct sk_buff *)pEntry);
162}
163
164// Unify all delay routine by using udelay
165VOID RTMPusecDelay(
166 IN ULONG usec)
167{
168 ULONG i;
169
170 for (i = 0; i < (usec / 50); i++)
171 udelay(50);
172
173 if (usec % 50)
174 udelay(usec % 50);
175}
176
177void RTMP_GetCurrentSystemTime(LARGE_INTEGER *time)
178{
179 time->u.LowPart = jiffies;
180}
181
182// pAd MUST allow to be NULL
183NDIS_STATUS os_alloc_mem(
184 IN PRTMP_ADAPTER pAd,
185 OUT PUCHAR *mem,
186 IN ULONG size)
187{
188 *mem = (PUCHAR) kmalloc(size, GFP_ATOMIC);
189 if (*mem)
190 return (NDIS_STATUS_SUCCESS);
191 else
192 return (NDIS_STATUS_FAILURE);
193}
194
195// pAd MUST allow to be NULL
196NDIS_STATUS os_free_mem(
197 IN PRTMP_ADAPTER pAd,
198 IN PUCHAR mem)
199{
200
201 ASSERT(mem);
202 kfree(mem);
203 return (NDIS_STATUS_SUCCESS);
204}
205
206
207PNDIS_PACKET RTMP_AllocateFragPacketBuffer(
208 IN PRTMP_ADAPTER pAd,
209 IN ULONG Length)
210{
211 struct sk_buff *pkt;
212
213 pkt = dev_alloc_skb(Length);
214
215 if (pkt == NULL)
216 {
217 DBGPRINT(RT_DEBUG_ERROR, ("can't allocate frag rx %ld size packet\n",Length));
218 }
219
220 if (pkt)
221 {
222 RTMP_SET_PACKET_SOURCE(OSPKT_TO_RTPKT(pkt), PKTSRC_NDIS);
223 }
224
225 return (PNDIS_PACKET) pkt;
226}
227
228
229PNDIS_PACKET RTMP_AllocateTxPacketBuffer(
230 IN PRTMP_ADAPTER pAd,
231 IN ULONG Length,
232 IN BOOLEAN Cached,
233 OUT PVOID *VirtualAddress)
234{
235 struct sk_buff *pkt;
236
237 pkt = dev_alloc_skb(Length);
238
239 if (pkt == NULL)
240 {
241 DBGPRINT(RT_DEBUG_ERROR, ("can't allocate tx %ld size packet\n",Length));
242 }
243
244 if (pkt)
245 {
246 RTMP_SET_PACKET_SOURCE(OSPKT_TO_RTPKT(pkt), PKTSRC_NDIS);
247 *VirtualAddress = (PVOID) pkt->data;
248 }
249 else
250 {
251 *VirtualAddress = (PVOID) NULL;
252 }
253
254 return (PNDIS_PACKET) pkt;
255}
256
257
258VOID build_tx_packet(
259 IN PRTMP_ADAPTER pAd,
260 IN PNDIS_PACKET pPacket,
261 IN PUCHAR pFrame,
262 IN ULONG FrameLen)
263{
264
265 struct sk_buff *pTxPkt;
266
267 ASSERT(pPacket);
268 pTxPkt = RTPKT_TO_OSPKT(pPacket);
269
270 NdisMoveMemory(skb_put(pTxPkt, FrameLen), pFrame, FrameLen);
271}
272
273VOID RTMPFreeAdapter(
274 IN PRTMP_ADAPTER pAd)
275{
276 POS_COOKIE os_cookie;
277 int index;
278
279 os_cookie=(POS_COOKIE)pAd->OS_Cookie;
280
281 kfree(pAd->BeaconBuf);
282
283
284 NdisFreeSpinLock(&pAd->MgmtRingLock);
285
286
287 for (index =0 ; index < NUM_OF_TX_RING; index++)
288 {
289 NdisFreeSpinLock(&pAd->TxSwQueueLock[index]);
290 NdisFreeSpinLock(&pAd->DeQueueLock[index]);
291 pAd->DeQueueRunning[index] = FALSE;
292 }
293
294 NdisFreeSpinLock(&pAd->irq_lock);
295
296
297 vfree(pAd); // pci_free_consistent(os_cookie->pci_dev,sizeof(RTMP_ADAPTER),pAd,os_cookie->pAd_pa);
298 kfree(os_cookie);
299}
300
301BOOLEAN OS_Need_Clone_Packet(void)
302{
303 return (FALSE);
304}
305
306
307
308/*
309 ========================================================================
310
311 Routine Description:
312 clone an input NDIS PACKET to another one. The new internally created NDIS PACKET
313 must have only one NDIS BUFFER
314 return - byte copied. 0 means can't create NDIS PACKET
315 NOTE: internally created NDIS_PACKET should be destroyed by RTMPFreeNdisPacket
316
317 Arguments:
318 pAd Pointer to our adapter
319 pInsAMSDUHdr EWC A-MSDU format has extra 14-bytes header. if TRUE, insert this 14-byte hdr in front of MSDU.
320 *pSrcTotalLen return total packet length. This lenght is calculated with 802.3 format packet.
321
322 Return Value:
323 NDIS_STATUS_SUCCESS
324 NDIS_STATUS_FAILURE
325
326 Note:
327
328 ========================================================================
329*/
330NDIS_STATUS RTMPCloneNdisPacket(
331 IN PRTMP_ADAPTER pAd,
332 IN BOOLEAN pInsAMSDUHdr,
333 IN PNDIS_PACKET pInPacket,
334 OUT PNDIS_PACKET *ppOutPacket)
335{
336
337 struct sk_buff *pkt;
338
339 ASSERT(pInPacket);
340 ASSERT(ppOutPacket);
341
342 // 1. Allocate a packet
343 pkt = dev_alloc_skb(2048);
344
345 if (pkt == NULL)
346 {
347 return NDIS_STATUS_FAILURE;
348 }
349
350 skb_put(pkt, GET_OS_PKT_LEN(pInPacket));
351 NdisMoveMemory(pkt->data, GET_OS_PKT_DATAPTR(pInPacket), GET_OS_PKT_LEN(pInPacket));
352 *ppOutPacket = OSPKT_TO_RTPKT(pkt);
353
354
355 RTMP_SET_PACKET_SOURCE(OSPKT_TO_RTPKT(pkt), PKTSRC_NDIS);
356
357 printk("###Clone###\n");
358
359 return NDIS_STATUS_SUCCESS;
360}
361
362
363// the allocated NDIS PACKET must be freed via RTMPFreeNdisPacket()
364NDIS_STATUS RTMPAllocateNdisPacket(
365 IN PRTMP_ADAPTER pAd,
366 OUT PNDIS_PACKET *ppPacket,
367 IN PUCHAR pHeader,
368 IN UINT HeaderLen,
369 IN PUCHAR pData,
370 IN UINT DataLen)
371{
372 PNDIS_PACKET pPacket;
373 ASSERT(pData);
374 ASSERT(DataLen);
375
376 // 1. Allocate a packet
377 pPacket = (PNDIS_PACKET *) dev_alloc_skb(HeaderLen + DataLen + TXPADDING_SIZE);
378 if (pPacket == NULL)
379 {
380 *ppPacket = NULL;
381#ifdef DEBUG
382 printk("RTMPAllocateNdisPacket Fail\n\n");
383#endif
384 return NDIS_STATUS_FAILURE;
385 }
386
387 // 2. clone the frame content
388 if (HeaderLen > 0)
389 NdisMoveMemory(GET_OS_PKT_DATAPTR(pPacket), pHeader, HeaderLen);
390 if (DataLen > 0)
391 NdisMoveMemory(GET_OS_PKT_DATAPTR(pPacket) + HeaderLen, pData, DataLen);
392
393 // 3. update length of packet
394 skb_put(GET_OS_PKT_TYPE(pPacket), HeaderLen+DataLen);
395
396 RTMP_SET_PACKET_SOURCE(pPacket, PKTSRC_NDIS);
397// printk("%s : pPacket = %p, len = %d\n", __func__, pPacket, GET_OS_PKT_LEN(pPacket));
398 *ppPacket = pPacket;
399 return NDIS_STATUS_SUCCESS;
400}
401
402/*
403 ========================================================================
404 Description:
405 This routine frees a miniport internally allocated NDIS_PACKET and its
406 corresponding NDIS_BUFFER and allocated memory.
407 ========================================================================
408*/
409VOID RTMPFreeNdisPacket(
410 IN PRTMP_ADAPTER pAd,
411 IN PNDIS_PACKET pPacket)
412{
413 dev_kfree_skb_any(RTPKT_TO_OSPKT(pPacket));
414}
415
416
417// IRQL = DISPATCH_LEVEL
418// NOTE: we do have an assumption here, that Byte0 and Byte1 always reasid at the same
419// scatter gather buffer
420NDIS_STATUS Sniff2BytesFromNdisBuffer(
421 IN PNDIS_BUFFER pFirstBuffer,
422 IN UCHAR DesiredOffset,
423 OUT PUCHAR pByte0,
424 OUT PUCHAR pByte1)
425{
426 *pByte0 = *(PUCHAR)(pFirstBuffer + DesiredOffset);
427 *pByte1 = *(PUCHAR)(pFirstBuffer + DesiredOffset + 1);
428
429 return NDIS_STATUS_SUCCESS;
430}
431
432
433void RTMP_QueryPacketInfo(
434 IN PNDIS_PACKET pPacket,
435 OUT PACKET_INFO *pPacketInfo,
436 OUT PUCHAR *pSrcBufVA,
437 OUT UINT *pSrcBufLen)
438{
439 pPacketInfo->BufferCount = 1;
440 pPacketInfo->pFirstBuffer = GET_OS_PKT_DATAPTR(pPacket);
441 pPacketInfo->PhysicalBufferCount = 1;
442 pPacketInfo->TotalPacketLength = GET_OS_PKT_LEN(pPacket);
443
444 *pSrcBufVA = GET_OS_PKT_DATAPTR(pPacket);
445 *pSrcBufLen = GET_OS_PKT_LEN(pPacket);
446}
447
448void RTMP_QueryNextPacketInfo(
449 IN PNDIS_PACKET *ppPacket,
450 OUT PACKET_INFO *pPacketInfo,
451 OUT PUCHAR *pSrcBufVA,
452 OUT UINT *pSrcBufLen)
453{
454 PNDIS_PACKET pPacket = NULL;
455
456 if (*ppPacket)
457 pPacket = GET_OS_PKT_NEXT(*ppPacket);
458
459 if (pPacket)
460 {
461 pPacketInfo->BufferCount = 1;
462 pPacketInfo->pFirstBuffer = GET_OS_PKT_DATAPTR(pPacket);
463 pPacketInfo->PhysicalBufferCount = 1;
464 pPacketInfo->TotalPacketLength = GET_OS_PKT_LEN(pPacket);
465
466 *pSrcBufVA = GET_OS_PKT_DATAPTR(pPacket);
467 *pSrcBufLen = GET_OS_PKT_LEN(pPacket);
468 *ppPacket = GET_OS_PKT_NEXT(pPacket);
469 }
470 else
471 {
472 pPacketInfo->BufferCount = 0;
473 pPacketInfo->pFirstBuffer = NULL;
474 pPacketInfo->PhysicalBufferCount = 0;
475 pPacketInfo->TotalPacketLength = 0;
476
477 *pSrcBufVA = NULL;
478 *pSrcBufLen = 0;
479 *ppPacket = NULL;
480 }
481}
482
483// not yet support MBSS
484PNET_DEV get_netdev_from_bssid(
485 IN PRTMP_ADAPTER pAd,
486 IN UCHAR FromWhichBSSID)
487{
488 PNET_DEV dev_p = NULL;
489
490 dev_p = pAd->net_dev;
491
492 ASSERT(dev_p);
493 return dev_p; /* return one of MBSS */
494}
495
496PNDIS_PACKET DuplicatePacket(
497 IN PRTMP_ADAPTER pAd,
498 IN PNDIS_PACKET pPacket,
499 IN UCHAR FromWhichBSSID)
500{
501 struct sk_buff *skb;
502 PNDIS_PACKET pRetPacket = NULL;
503 USHORT DataSize;
504 UCHAR *pData;
505
506 DataSize = (USHORT) GET_OS_PKT_LEN(pPacket);
507 pData = (PUCHAR) GET_OS_PKT_DATAPTR(pPacket);
508
509
510 skb = skb_clone(RTPKT_TO_OSPKT(pPacket), MEM_ALLOC_FLAG);
511 if (skb)
512 {
513 skb->dev = get_netdev_from_bssid(pAd, FromWhichBSSID);
514 pRetPacket = OSPKT_TO_RTPKT(skb);
515 }
516
517 return pRetPacket;
518
519}
520
521PNDIS_PACKET duplicate_pkt(
522 IN PRTMP_ADAPTER pAd,
523 IN PUCHAR pHeader802_3,
524 IN UINT HdrLen,
525 IN PUCHAR pData,
526 IN ULONG DataSize,
527 IN UCHAR FromWhichBSSID)
528{
529 struct sk_buff *skb;
530 PNDIS_PACKET pPacket = NULL;
531
532
533 if ((skb = __dev_alloc_skb(HdrLen + DataSize + 2, MEM_ALLOC_FLAG)) != NULL)
534 {
535 skb_reserve(skb, 2);
536 NdisMoveMemory(skb->tail, pHeader802_3, HdrLen);
537 skb_put(skb, HdrLen);
538 NdisMoveMemory(skb->tail, pData, DataSize);
539 skb_put(skb, DataSize);
540 skb->dev = get_netdev_from_bssid(pAd, FromWhichBSSID);
541 pPacket = OSPKT_TO_RTPKT(skb);
542 }
543
544 return pPacket;
545}
546
547
548#define TKIP_TX_MIC_SIZE 8
549PNDIS_PACKET duplicate_pkt_with_TKIP_MIC(
550 IN PRTMP_ADAPTER pAd,
551 IN PNDIS_PACKET pPacket)
552{
553 struct sk_buff *skb, *newskb;
554
555
556 skb = RTPKT_TO_OSPKT(pPacket);
557 if (skb_tailroom(skb) < TKIP_TX_MIC_SIZE)
558 {
559 // alloc a new skb and copy the packet
560 newskb = skb_copy_expand(skb, skb_headroom(skb), TKIP_TX_MIC_SIZE, GFP_ATOMIC);
561 dev_kfree_skb_any(skb);
562 if (newskb == NULL)
563 {
564 DBGPRINT(RT_DEBUG_ERROR, ("Extend Tx.MIC for packet failed!, dropping packet!\n"));
565 return NULL;
566 }
567 skb = newskb;
568 }
569
570 return OSPKT_TO_RTPKT(skb);
571}
572
573
574
575
576PNDIS_PACKET ClonePacket(
577 IN PRTMP_ADAPTER pAd,
578 IN PNDIS_PACKET pPacket,
579 IN PUCHAR pData,
580 IN ULONG DataSize)
581{
582 struct sk_buff *pRxPkt;
583 struct sk_buff *pClonedPkt;
584
585 ASSERT(pPacket);
586 pRxPkt = RTPKT_TO_OSPKT(pPacket);
587
588 // clone the packet
589 pClonedPkt = skb_clone(pRxPkt, MEM_ALLOC_FLAG);
590
591 if (pClonedPkt)
592 {
593 // set the correct dataptr and data len
594 pClonedPkt->dev = pRxPkt->dev;
595 pClonedPkt->data = pData;
596 pClonedPkt->len = DataSize;
597 pClonedPkt->tail = pClonedPkt->data + pClonedPkt->len;
598 ASSERT(DataSize < 1530);
599 }
600 return pClonedPkt;
601}
602
603//
604// change OS packet DataPtr and DataLen
605//
606void update_os_packet_info(
607 IN PRTMP_ADAPTER pAd,
608 IN RX_BLK *pRxBlk,
609 IN UCHAR FromWhichBSSID)
610{
611 struct sk_buff *pOSPkt;
612
613 ASSERT(pRxBlk->pRxPacket);
614 pOSPkt = RTPKT_TO_OSPKT(pRxBlk->pRxPacket);
615
616 pOSPkt->dev = get_netdev_from_bssid(pAd, FromWhichBSSID);
617 pOSPkt->data = pRxBlk->pData;
618 pOSPkt->len = pRxBlk->DataSize;
619 pOSPkt->tail = pOSPkt->data + pOSPkt->len;
620}
621
622
623void wlan_802_11_to_802_3_packet(
624 IN PRTMP_ADAPTER pAd,
625 IN RX_BLK *pRxBlk,
626 IN PUCHAR pHeader802_3,
627 IN UCHAR FromWhichBSSID)
628{
629 struct sk_buff *pOSPkt;
630
631 ASSERT(pRxBlk->pRxPacket);
632 ASSERT(pHeader802_3);
633
634 pOSPkt = RTPKT_TO_OSPKT(pRxBlk->pRxPacket);
635
636 pOSPkt->dev = get_netdev_from_bssid(pAd, FromWhichBSSID);
637 pOSPkt->data = pRxBlk->pData;
638 pOSPkt->len = pRxBlk->DataSize;
639 pOSPkt->tail = pOSPkt->data + pOSPkt->len;
640
641 //
642 // copy 802.3 header
643 //
644 //
645
646 NdisMoveMemory(skb_push(pOSPkt, LENGTH_802_3), pHeader802_3, LENGTH_802_3);
647}
648
649void announce_802_3_packet(
650 IN PRTMP_ADAPTER pAd,
651 IN PNDIS_PACKET pPacket)
652{
653
654 struct sk_buff *pRxPkt;
655
656 ASSERT(pPacket);
657
658 pRxPkt = RTPKT_TO_OSPKT(pPacket);
659
660 /* Push up the protocol stack */
661#ifdef IKANOS_VX_1X0
662 IKANOS_DataFrameRx(pAd, pRxPkt->dev, pRxPkt, pRxPkt->len);
663#else
664 pRxPkt->protocol = eth_type_trans(pRxPkt, pRxPkt->dev);
665
666 netif_rx(pRxPkt);
667#endif // IKANOS_VX_1X0 //
668}
669
670
671PRTMP_SCATTER_GATHER_LIST
672rt_get_sg_list_from_packet(PNDIS_PACKET pPacket, RTMP_SCATTER_GATHER_LIST *sg)
673{
674 sg->NumberOfElements = 1;
675 sg->Elements[0].Address = GET_OS_PKT_DATAPTR(pPacket);
676 sg->Elements[0].Length = GET_OS_PKT_LEN(pPacket);
677 return (sg);
678}
679
680void hex_dump(char *str, unsigned char *pSrcBufVA, unsigned int SrcBufLen)
681{
682 unsigned char *pt;
683 int x;
684
685 if (RTDebugLevel < RT_DEBUG_TRACE)
686 return;
687
688 pt = pSrcBufVA;
689 printk("%s: %p, len = %d\n",str, pSrcBufVA, SrcBufLen);
690 for (x=0; x<SrcBufLen; x++)
691 {
692 if (x % 16 == 0)
693 printk("0x%04x : ", x);
694 printk("%02x ", ((unsigned char)pt[x]));
695 if (x%16 == 15) printk("\n");
696 }
697 printk("\n");
698}
699
700/*
701 ========================================================================
702
703 Routine Description:
704 Send log message through wireless event
705
706 Support standard iw_event with IWEVCUSTOM. It is used below.
707
708 iwreq_data.data.flags is used to store event_flag that is defined by user.
709 iwreq_data.data.length is the length of the event log.
710
711 The format of the event log is composed of the entry's MAC address and
712 the desired log message (refer to pWirelessEventText).
713
714 ex: 11:22:33:44:55:66 has associated successfully
715
716 p.s. The requirement of Wireless Extension is v15 or newer.
717
718 ========================================================================
719*/
720VOID RTMPSendWirelessEvent(
721 IN PRTMP_ADAPTER pAd,
722 IN USHORT Event_flag,
723 IN PUCHAR pAddr,
724 IN UCHAR BssIdx,
725 IN CHAR Rssi)
726{
727#if WIRELESS_EXT >= 15
728
729 union iwreq_data wrqu;
730 PUCHAR pBuf = NULL, pBufPtr = NULL;
731 USHORT event, type, BufLen;
732 UCHAR event_table_len = 0;
733
734 type = Event_flag & 0xFF00;
735 event = Event_flag & 0x00FF;
736
737 switch (type)
738 {
739 case IW_SYS_EVENT_FLAG_START:
740 event_table_len = IW_SYS_EVENT_TYPE_NUM;
741 break;
742
743 case IW_SPOOF_EVENT_FLAG_START:
744 event_table_len = IW_SPOOF_EVENT_TYPE_NUM;
745 break;
746
747 case IW_FLOOD_EVENT_FLAG_START:
748 event_table_len = IW_FLOOD_EVENT_TYPE_NUM;
749 break;
750 }
751
752 if (event_table_len == 0)
753 {
754 DBGPRINT(RT_DEBUG_ERROR, ("%s : The type(%0x02x) is not valid.\n", __func__, type));
755 return;
756 }
757
758 if (event >= event_table_len)
759 {
760 DBGPRINT(RT_DEBUG_ERROR, ("%s : The event(%0x02x) is not valid.\n", __func__, event));
761 return;
762 }
763
764 //Allocate memory and copy the msg.
765 if((pBuf = kmalloc(IW_CUSTOM_MAX_LEN, GFP_ATOMIC)) != NULL)
766 {
767 //Prepare the payload
768 memset(pBuf, 0, IW_CUSTOM_MAX_LEN);
769
770 pBufPtr = pBuf;
771
772 if (pAddr)
773 pBufPtr += sprintf(pBufPtr, "(RT2860) STA(%02x:%02x:%02x:%02x:%02x:%02x) ", PRINT_MAC(pAddr));
774 else if (BssIdx < MAX_MBSSID_NUM)
775 pBufPtr += sprintf(pBufPtr, "(RT2860) BSS(ra%d) ", BssIdx);
776 else
777 pBufPtr += sprintf(pBufPtr, "(RT2860) ");
778
779 if (type == IW_SYS_EVENT_FLAG_START)
780 pBufPtr += sprintf(pBufPtr, "%s", pWirelessSysEventText[event]);
781 else if (type == IW_SPOOF_EVENT_FLAG_START)
782 pBufPtr += sprintf(pBufPtr, "%s (RSSI=%d)", pWirelessSpoofEventText[event], Rssi);
783 else if (type == IW_FLOOD_EVENT_FLAG_START)
784 pBufPtr += sprintf(pBufPtr, "%s", pWirelessFloodEventText[event]);
785 else
786 pBufPtr += sprintf(pBufPtr, "%s", "unknown event");
787
788 pBufPtr[pBufPtr - pBuf] = '\0';
789 BufLen = pBufPtr - pBuf;
790
791 memset(&wrqu, 0, sizeof(wrqu));
792 wrqu.data.flags = Event_flag;
793 wrqu.data.length = BufLen;
794
795 //send wireless event
796 wireless_send_event(pAd->net_dev, IWEVCUSTOM, &wrqu, pBuf);
797
798 //DBGPRINT(RT_DEBUG_TRACE, ("%s : %s\n", __func__, pBuf));
799
800 kfree(pBuf);
801 }
802 else
803 DBGPRINT(RT_DEBUG_ERROR, ("%s : Can't allocate memory for wireless event.\n", __func__));
804#else
805 DBGPRINT(RT_DEBUG_ERROR, ("%s : The Wireless Extension MUST be v15 or newer.\n", __func__));
806#endif /* WIRELESS_EXT >= 15 */
807}
808
809void send_monitor_packets(
810 IN PRTMP_ADAPTER pAd,
811 IN RX_BLK *pRxBlk)
812{
813 struct sk_buff *pOSPkt;
814 wlan_ng_prism2_header *ph;
815 int rate_index = 0;
816 USHORT header_len = 0;
817 UCHAR temp_header[40] = {0};
818
819 u_int32_t ralinkrate[256] = {2,4,11,22, 12,18,24,36,48,72,96, 108, 109, 110, 111, 112, 13, 26, 39, 52,78,104, 117, 130, 26, 52, 78,104, 156, 208, 234, 260, 27, 54,81,108,162, 216, 243, 270, // Last 38
820 54, 108, 162, 216, 324, 432, 486, 540, 14, 29, 43, 57, 87, 115, 130, 144, 29, 59,87,115, 173, 230,260, 288, 30, 60,90,120,180,240,270,300,60,120,180,240,360,480,540,600, 0,1,2,3,4,5,6,7,8,9,10,
821 11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80};
822
823
824 ASSERT(pRxBlk->pRxPacket);
825 if (pRxBlk->DataSize < 10)
826 {
827 DBGPRINT(RT_DEBUG_ERROR, ("%s : Size is too small! (%d)\n", __func__, pRxBlk->DataSize));
828 goto err_free_sk_buff;
829 }
830
831 if (pRxBlk->DataSize + sizeof(wlan_ng_prism2_header) > RX_BUFFER_AGGRESIZE)
832 {
833#ifndef RT30xx
834 DBGPRINT(RT_DEBUG_ERROR, ("%s : Size is too large! (%zu)\n", __func__, pRxBlk->DataSize + sizeof(wlan_ng_prism2_header)));
835#endif
836#ifdef RT30xx
837 DBGPRINT(RT_DEBUG_ERROR, ("%s : Size is too large! (%d)\n", __func__, pRxBlk->DataSize + sizeof(wlan_ng_prism2_header)));
838#endif
839 goto err_free_sk_buff;
840 }
841
842 pOSPkt = RTPKT_TO_OSPKT(pRxBlk->pRxPacket);
843 pOSPkt->dev = get_netdev_from_bssid(pAd, BSS0);
844 if (pRxBlk->pHeader->FC.Type == BTYPE_DATA)
845 {
846 pRxBlk->DataSize -= LENGTH_802_11;
847 if ((pRxBlk->pHeader->FC.ToDs == 1) &&
848 (pRxBlk->pHeader->FC.FrDs == 1))
849 header_len = LENGTH_802_11_WITH_ADDR4;
850 else
851 header_len = LENGTH_802_11;
852
853 // QOS
854 if (pRxBlk->pHeader->FC.SubType & 0x08)
855 {
856 header_len += 2;
857 // Data skip QOS contorl field
858 pRxBlk->DataSize -=2;
859 }
860
861 // Order bit: A-Ralink or HTC+
862 if (pRxBlk->pHeader->FC.Order)
863 {
864 header_len += 4;
865 // Data skip HTC contorl field
866 pRxBlk->DataSize -= 4;
867 }
868
869 // Copy Header
870 if (header_len <= 40)
871 NdisMoveMemory(temp_header, pRxBlk->pData, header_len);
872
873 // skip HW padding
874 if (pRxBlk->RxD.L2PAD)
875 pRxBlk->pData += (header_len + 2);
876 else
877 pRxBlk->pData += header_len;
878 } //end if
879
880
881 if (pRxBlk->DataSize < pOSPkt->len) {
882 skb_trim(pOSPkt,pRxBlk->DataSize);
883 } else {
884 skb_put(pOSPkt,(pRxBlk->DataSize - pOSPkt->len));
885 } //end if
886
887 if ((pRxBlk->pData - pOSPkt->data) > 0) {
888 skb_put(pOSPkt,(pRxBlk->pData - pOSPkt->data));
889 skb_pull(pOSPkt,(pRxBlk->pData - pOSPkt->data));
890 } //end if
891
892 if (skb_headroom(pOSPkt) < (sizeof(wlan_ng_prism2_header)+ header_len)) {
893 if (pskb_expand_head(pOSPkt, (sizeof(wlan_ng_prism2_header) + header_len), 0, GFP_ATOMIC)) {
894 DBGPRINT(RT_DEBUG_ERROR, ("%s : Reallocate header size of sk_buff fail!\n", __func__));
895 goto err_free_sk_buff;
896 } //end if
897 } //end if
898
899 if (header_len > 0)
900 NdisMoveMemory(skb_push(pOSPkt, header_len), temp_header, header_len);
901
902 ph = (wlan_ng_prism2_header *) skb_push(pOSPkt, sizeof(wlan_ng_prism2_header));
903 NdisZeroMemory(ph, sizeof(wlan_ng_prism2_header));
904
905 ph->msgcode = DIDmsg_lnxind_wlansniffrm;
906 ph->msglen = sizeof(wlan_ng_prism2_header);
907 strcpy(ph->devname, pAd->net_dev->name);
908
909 ph->hosttime.did = DIDmsg_lnxind_wlansniffrm_hosttime;
910 ph->hosttime.status = 0;
911 ph->hosttime.len = 4;
912 ph->hosttime.data = jiffies;
913
914 ph->mactime.did = DIDmsg_lnxind_wlansniffrm_mactime;
915 ph->mactime.status = 0;
916 ph->mactime.len = 0;
917 ph->mactime.data = 0;
918
919 ph->istx.did = DIDmsg_lnxind_wlansniffrm_istx;
920 ph->istx.status = 0;
921 ph->istx.len = 0;
922 ph->istx.data = 0;
923
924 ph->channel.did = DIDmsg_lnxind_wlansniffrm_channel;
925 ph->channel.status = 0;
926 ph->channel.len = 4;
927
928 ph->channel.data = (u_int32_t)pAd->CommonCfg.Channel;
929
930 ph->rssi.did = DIDmsg_lnxind_wlansniffrm_rssi;
931 ph->rssi.status = 0;
932 ph->rssi.len = 4;
933 ph->rssi.data = (u_int32_t)RTMPMaxRssi(pAd, ConvertToRssi(pAd, pRxBlk->pRxWI->RSSI0, RSSI_0), ConvertToRssi(pAd, pRxBlk->pRxWI->RSSI1, RSSI_1), ConvertToRssi(pAd, pRxBlk->pRxWI->RSSI2, RSSI_2));;
934
935 ph->signal.did = DIDmsg_lnxind_wlansniffrm_signal;
936 ph->signal.status = 0;
937 ph->signal.len = 4;
938 ph->signal.data = 0; //rssi + noise;
939
940 ph->noise.did = DIDmsg_lnxind_wlansniffrm_noise;
941 ph->noise.status = 0;
942 ph->noise.len = 4;
943 ph->noise.data = 0;
944
945 if (pRxBlk->pRxWI->PHYMODE >= MODE_HTMIX)
946 {
947 rate_index = 16 + ((UCHAR)pRxBlk->pRxWI->BW *16) + ((UCHAR)pRxBlk->pRxWI->ShortGI *32) + ((UCHAR)pRxBlk->pRxWI->MCS);
948 }
949 else
950 if (pRxBlk->pRxWI->PHYMODE == MODE_OFDM)
951 rate_index = (UCHAR)(pRxBlk->pRxWI->MCS) + 4;
952 else
953 rate_index = (UCHAR)(pRxBlk->pRxWI->MCS);
954 if (rate_index < 0)
955 rate_index = 0;
956 if (rate_index > 255)
957 rate_index = 255;
958
959 ph->rate.did = DIDmsg_lnxind_wlansniffrm_rate;
960 ph->rate.status = 0;
961 ph->rate.len = 4;
962 ph->rate.data = ralinkrate[rate_index];
963
964 ph->frmlen.did = DIDmsg_lnxind_wlansniffrm_frmlen;
965 ph->frmlen.status = 0;
966 ph->frmlen.len = 4;
967 ph->frmlen.data = (u_int32_t)pRxBlk->DataSize;
968
969
970 pOSPkt->pkt_type = PACKET_OTHERHOST;
971 pOSPkt->protocol = eth_type_trans(pOSPkt, pOSPkt->dev);
972 pOSPkt->ip_summed = CHECKSUM_NONE;
973 netif_rx(pOSPkt);
974
975 return;
976
977err_free_sk_buff:
978 RELEASE_NDIS_PACKET(pAd, pRxBlk->pRxPacket, NDIS_STATUS_FAILURE);
979 return;
980
981}
982
983void rtmp_os_thread_init(PUCHAR pThreadName, PVOID pNotify)
984{
985 daemonize(pThreadName /*"%s",pAd->net_dev->name*/);
986
987 allow_signal(SIGTERM);
988 allow_signal(SIGKILL);
989 current->flags |= PF_NOFREEZE;
990
991 /* signal that we've started the thread */
992 complete(pNotify);
993}
994
995void RTMP_IndicateMediaState(
996 IN PRTMP_ADAPTER pAd)
997{
998 if (pAd->CommonCfg.bWirelessEvent)
999 {
1000 if (pAd->IndicateMediaState == NdisMediaStateConnected)
1001 {
1002 RTMPSendWirelessEvent(pAd, IW_STA_LINKUP_EVENT_FLAG, pAd->MacTab.Content[BSSID_WCID].Addr, BSS0, 0);
1003 }
1004 else
1005 {
1006 RTMPSendWirelessEvent(pAd, IW_STA_LINKDOWN_EVENT_FLAG, pAd->MacTab.Content[BSSID_WCID].Addr, BSS0, 0);
1007 }
1008 }
1009}
1010
diff --git a/drivers/staging/rt2870/rt_linux.h b/drivers/staging/rt2870/rt_linux.h
index 56c534a3dc92..b2aeafbd5189 100644
--- a/drivers/staging/rt2870/rt_linux.h
+++ b/drivers/staging/rt2870/rt_linux.h
@@ -1,846 +1 @@
1/* #include "../rt2860/rt_linux.h"
2 *************************************************************************
3 * Ralink Tech Inc.
4 * 5F., No.36, Taiyuan St., Jhubei City,
5 * Hsinchu County 302,
6 * Taiwan, R.O.C.
7 *
8 * (c) Copyright 2002-2007, Ralink Technology, Inc.
9 *
10 * This program is free software; you can redistribute it and/or modify *
11 * it under the terms of the GNU General Public License as published by *
12 * the Free Software Foundation; either version 2 of the License, or *
13 * (at your option) any later version. *
14 * *
15 * This program is distributed in the hope that it will be useful, *
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
18 * GNU General Public License for more details. *
19 * *
20 * You should have received a copy of the GNU General Public License *
21 * along with this program; if not, write to the *
22 * Free Software Foundation, Inc., *
23 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
24 * *
25 *************************************************************************
26 */
27
28/***********************************************************************/
29/* */
30/* Program: rt_linux.c */
31/* Created: 4/21/2006 1:17:38 PM */
32/* Author: Wu Xi-Kun */
33/* Comments: `description` */
34/* */
35/*---------------------------------------------------------------------*/
36/* */
37/* History: */
38/* Revision 1.1 4/21/2006 1:17:38 PM xsikun */
39/* Initial revision */
40/* */
41/***********************************************************************/
42
43#include "rtmp_type.h"
44#include <linux/module.h>
45#include <linux/version.h>
46#include <linux/kernel.h>
47#ifndef RT30xx
48#include <linux/kthread.h>
49#endif
50
51#include <linux/spinlock.h>
52#include <linux/init.h>
53#include <linux/string.h>
54#include <linux/timer.h>
55#include <linux/errno.h>
56#include <linux/slab.h>
57#include <linux/interrupt.h>
58#include <linux/pci.h>
59#include <linux/netdevice.h>
60#include <linux/etherdevice.h>
61#include <linux/skbuff.h>
62#include <linux/ethtool.h>
63#include <linux/wireless.h>
64#include <linux/proc_fs.h>
65#include <linux/delay.h>
66#include <linux/if_arp.h>
67#include <linux/ctype.h>
68#include <linux/vmalloc.h>
69
70
71#ifdef RT30xx
72#include <linux/wireless.h>
73#endif
74#include <net/iw_handler.h>
75
76// load firmware
77#define __KERNEL_SYSCALLS__
78#include <linux/unistd.h>
79#include <asm/uaccess.h>
80
81
82#define MEM_ALLOC_FLAG (GFP_ATOMIC) //(GFP_DMA | GFP_ATOMIC)
83
84#ifndef IFNAMSIZ
85#define IFNAMSIZ 16
86#endif
87
88//#define CONFIG_CKIP_SUPPORT
89
90#undef __inline
91#define __inline static inline
92
93typedef int (*HARD_START_XMIT_FUNC)(struct sk_buff *skb, struct net_device *net_dev);
94
95// add by kathy
96
97#ifdef RT2870
98#define STA_PROFILE_PATH "/etc/Wireless/RT2870STA/RT2870STA.dat"
99#define STA_RT2870_IMAGE_FILE_NAME "/etc/Wireless/RT2870STA/rt2870.bin"
100#define STA_NIC_DEVICE_NAME "RT2870STA"
101#ifndef RT30xx
102#define STA_DRIVER_VERSION "1.4.0.0"
103#endif
104#ifdef RT30xx
105#define STA_DRIVER_VERSION "2.0.1.0"
106#endif
107#endif // RT2870 //
108
109#define RTMP_TIME_AFTER(a,b) \
110 (typecheck(unsigned long, (unsigned long)a) && \
111 typecheck(unsigned long, (unsigned long)b) && \
112 ((long)(b) - (long)(a) < 0))
113
114#define RTMP_TIME_AFTER_EQ(a,b) \
115 (typecheck(unsigned long, (unsigned long)a) && \
116 typecheck(unsigned long, (unsigned long)b) && \
117 ((long)(a) - (long)(b) >= 0))
118#define RTMP_TIME_BEFORE(a,b) RTMP_TIME_AFTER_EQ(b,a)
119
120#define RT_MOD_INC_USE_COUNT() \
121 if (!try_module_get(THIS_MODULE)) \
122 { \
123 DBGPRINT(RT_DEBUG_ERROR, ("%s: cannot reserve module\n", __func__)); \
124 return -1; \
125 }
126
127#define RT_MOD_DEC_USE_COUNT() module_put(THIS_MODULE);
128
129#define OS_HZ HZ
130
131#define ETH_LENGTH_OF_ADDRESS 6
132
133#define IN
134#define OUT
135
136#define NDIS_STATUS INT
137#define NDIS_STATUS_SUCCESS 0x00
138#define NDIS_STATUS_FAILURE 0x01
139#define NDIS_STATUS_INVALID_DATA 0x02
140#define NDIS_STATUS_RESOURCES 0x03
141
142#define MIN_NET_DEVICE_FOR_AID 0x00 //0x00~0x3f
143#define MIN_NET_DEVICE_FOR_MBSSID 0x00 //0x00,0x10,0x20,0x30
144#define MIN_NET_DEVICE_FOR_WDS 0x10 //0x40,0x50,0x60,0x70
145#define MIN_NET_DEVICE_FOR_APCLI 0x20
146#define MIN_NET_DEVICE_FOR_MESH 0x30
147#define MIN_NET_DEVICE_FOR_DLS 0x40
148
149#define NDIS_PACKET_TYPE_DIRECTED 0
150#define NDIS_PACKET_TYPE_MULTICAST 1
151#define NDIS_PACKET_TYPE_BROADCAST 2
152#define NDIS_PACKET_TYPE_ALL_MULTICAST 3
153
154#ifndef RT30xx
155typedef struct pid * THREAD_PID;
156#define GET_PID(_v) find_get_pid(_v)
157#define GET_PID_NUMBER(_v) pid_nr(_v)
158#define CHECK_PID_LEGALITY(_pid) if (pid_nr(_pid) >= 0)
159#define KILL_THREAD_PID(_A, _B, _C) kill_pid(_A, _B, _C)
160#endif
161
162struct os_lock {
163 spinlock_t lock;
164 unsigned long flags;
165};
166
167
168struct os_cookie {
169
170#ifdef RT2870
171 struct usb_device *pUsb_Dev;
172
173#ifndef RT30xx
174 struct task_struct *MLMEThr_task;
175 struct task_struct *RTUSBCmdThr_task;
176 struct task_struct *TimerQThr_task;
177#endif
178#ifdef RT30xx
179 struct pid * MLMEThr_pid;
180 struct pid * RTUSBCmdThr_pid;
181 struct pid * TimerQThr_pid;
182#endif
183#endif // RT2870 //
184
185 struct tasklet_struct rx_done_task;
186 struct tasklet_struct mgmt_dma_done_task;
187 struct tasklet_struct ac0_dma_done_task;
188 struct tasklet_struct ac1_dma_done_task;
189 struct tasklet_struct ac2_dma_done_task;
190 struct tasklet_struct ac3_dma_done_task;
191 struct tasklet_struct hcca_dma_done_task;
192 struct tasklet_struct tbtt_task;
193#ifdef RT2870
194 struct tasklet_struct null_frame_complete_task;
195 struct tasklet_struct rts_frame_complete_task;
196 struct tasklet_struct pspoll_frame_complete_task;
197#endif // RT2870 //
198
199
200 unsigned long apd_pid; //802.1x daemon pid
201 INT ioctl_if_type;
202 INT ioctl_if;
203};
204
205typedef struct _VIRTUAL_ADAPTER
206{
207 struct net_device *RtmpDev;
208 struct net_device *VirtualDev;
209} VIRTUAL_ADAPTER, PVIRTUAL_ADAPTER;
210
211#undef ASSERT
212#define ASSERT(x)
213
214typedef struct os_cookie * POS_COOKIE;
215typedef struct pci_dev * PPCI_DEV;
216typedef struct net_device * PNET_DEV;
217typedef void * PNDIS_PACKET;
218typedef char NDIS_PACKET;
219typedef PNDIS_PACKET * PPNDIS_PACKET;
220typedef dma_addr_t NDIS_PHYSICAL_ADDRESS;
221typedef dma_addr_t * PNDIS_PHYSICAL_ADDRESS;
222typedef spinlock_t NDIS_SPIN_LOCK;
223typedef struct timer_list NDIS_MINIPORT_TIMER;
224typedef void * NDIS_HANDLE;
225typedef char * PNDIS_BUFFER;
226
227
228
229void hex_dump(char *str, unsigned char *pSrcBufVA, unsigned int SrcBufLen);
230
231dma_addr_t linux_pci_map_single(void *handle, void *ptr, size_t size, int sd_idx, int direction);
232void linux_pci_unmap_single(void *handle, dma_addr_t dma_addr, size_t size, int direction);
233
234
235////////////////////////////////////////
236// MOVE TO rtmp.h ?
237/////////////////////////////////////////
238#define PKTSRC_NDIS 0x7f
239#define PKTSRC_DRIVER 0x0f
240#define PRINT_MAC(addr) \
241 addr[0], addr[1], addr[2], addr[3], addr[4], addr[5]
242
243
244#define RT2860_PCI_DEVICE_ID 0x0601
245
246
247#ifdef RT2870
248#define PCI_MAP_SINGLE(_handle, _ptr, _size, _dir) (ULONG)0
249
250#define PCI_UNMAP_SINGLE(_handle, _ptr, _size, _dir)
251#endif // RT2870 //
252
253
254#define BEACON_FRAME_DMA_CACHE_WBACK(_ptr, _size) \
255 dma_cache_wback(_ptr, _size)
256
257
258//////////////////////////////////////////
259//
260//////////////////////////////////////////
261
262
263#define NdisMIndicateStatus(_w, _x, _y, _z)
264
265typedef struct timer_list RTMP_OS_TIMER;
266
267#ifdef RT2870
268/* ----------------- Timer Related MARCO ---------------*/
269// In RT2870, we have a lot of timer functions and will read/write register, it's
270// not allowed in Linux USB sub-system to do it ( because of sleep issue when submit
271// to ctrl pipe). So we need a wrapper function to take care it.
272
273typedef VOID (*RT2870_TIMER_HANDLE)(
274 IN PVOID SystemSpecific1,
275 IN PVOID FunctionContext,
276 IN PVOID SystemSpecific2,
277 IN PVOID SystemSpecific3);
278#endif // RT2870 //
279
280
281typedef struct _RALINK_TIMER_STRUCT {
282 RTMP_OS_TIMER TimerObj; // Ndis Timer object
283 BOOLEAN Valid; // Set to True when call RTMPInitTimer
284 BOOLEAN State; // True if timer cancelled
285 BOOLEAN PeriodicType; // True if timer is periodic timer
286 BOOLEAN Repeat; // True if periodic timer
287 ULONG TimerValue; // Timer value in milliseconds
288 ULONG cookie; // os specific object
289#ifdef RT2870
290 RT2870_TIMER_HANDLE handle;
291 void *pAd;
292#endif // RT2870 //
293} RALINK_TIMER_STRUCT, *PRALINK_TIMER_STRUCT;
294
295
296#ifdef RT2870
297
298typedef enum _RT2870_KERNEL_THREAD_STATUS_
299{
300 RT2870_THREAD_UNKNOWN = 0,
301 RT2870_THREAD_INITED = 1,
302 RT2870_THREAD_RUNNING = 2,
303 RT2870_THREAD_STOPED = 4,
304}RT2870_KERNEL_THREAD_STATUS;
305
306#define RT2870_THREAD_CAN_DO_INSERT (RT2870_THREAD_INITED |RT2870_THREAD_RUNNING)
307
308typedef struct _RT2870_TIMER_ENTRY_
309{
310 RALINK_TIMER_STRUCT *pRaTimer;
311 struct _RT2870_TIMER_ENTRY_ *pNext;
312}RT2870_TIMER_ENTRY;
313
314
315#define TIMER_QUEUE_SIZE_MAX 128
316typedef struct _RT2870_TIMER_QUEUE_
317{
318 unsigned int status;
319 UCHAR *pTimerQPoll;
320 RT2870_TIMER_ENTRY *pQPollFreeList;
321 RT2870_TIMER_ENTRY *pQHead;
322 RT2870_TIMER_ENTRY *pQTail;
323}RT2870_TIMER_QUEUE;
324#endif // RT2870 //
325
326
327//#define DBG 1
328
329//
330// MACRO for debugging information
331//
332
333#ifdef DBG
334extern ULONG RTDebugLevel;
335
336#define DBGPRINT_RAW(Level, Fmt) \
337{ \
338 if (Level <= RTDebugLevel) \
339 { \
340 printk Fmt; \
341 } \
342}
343
344#define DBGPRINT(Level, Fmt) DBGPRINT_RAW(Level, Fmt)
345
346
347#define DBGPRINT_ERR(Fmt) \
348{ \
349 printk("ERROR!!! "); \
350 printk Fmt; \
351}
352
353#define DBGPRINT_S(Status, Fmt) \
354{ \
355 printk Fmt; \
356}
357
358
359#else
360#define DBGPRINT(Level, Fmt)
361#define DBGPRINT_RAW(Level, Fmt)
362#define DBGPRINT_S(Status, Fmt)
363#define DBGPRINT_ERR(Fmt)
364#endif
365
366
367//
368// spin_lock enhanced for Nested spin lock
369//
370#define NdisAllocateSpinLock(__lock) \
371{ \
372 spin_lock_init((spinlock_t *)(__lock)); \
373}
374
375#define NdisFreeSpinLock(lock) \
376{ \
377}
378
379
380#define RTMP_SEM_LOCK(__lock) \
381{ \
382 spin_lock_bh((spinlock_t *)(__lock)); \
383}
384
385#define RTMP_SEM_UNLOCK(__lock) \
386{ \
387 spin_unlock_bh((spinlock_t *)(__lock)); \
388}
389
390// sample, use semaphore lock to replace IRQ lock, 2007/11/15
391#define RTMP_IRQ_LOCK(__lock, __irqflags) \
392{ \
393 __irqflags = 0; \
394 spin_lock_bh((spinlock_t *)(__lock)); \
395 pAd->irq_disabled |= 1; \
396}
397
398#define RTMP_IRQ_UNLOCK(__lock, __irqflag) \
399{ \
400 pAd->irq_disabled &= 0; \
401 spin_unlock_bh((spinlock_t *)(__lock)); \
402}
403
404#define RTMP_INT_LOCK(__lock, __irqflags) \
405{ \
406 spin_lock_irqsave((spinlock_t *)__lock, __irqflags); \
407}
408
409#define RTMP_INT_UNLOCK(__lock, __irqflag) \
410{ \
411 spin_unlock_irqrestore((spinlock_t *)(__lock), ((unsigned long)__irqflag)); \
412}
413
414
415
416#ifdef RT2870
417//Patch for ASIC turst read/write bug, needs to remove after metel fix
418#define RTMP_IO_READ32(_A, _R, _pV) \
419 RTUSBReadMACRegister(_A, _R, _pV)
420
421#define RTMP_IO_READ8(_A, _R, _pV) \
422{ \
423}
424
425#define RTMP_IO_WRITE32(_A, _R, _V) \
426 RTUSBWriteMACRegister(_A, _R, _V)
427
428
429#define RTMP_IO_WRITE8(_A, _R, _V) \
430{ \
431 USHORT _Val = _V; \
432 RTUSBSingleWrite(_A, _R, _Val); \
433}
434
435
436#define RTMP_IO_WRITE16(_A, _R, _V) \
437{ \
438 RTUSBSingleWrite(_A, _R, _V); \
439}
440#endif // RT2870 //
441
442#ifndef wait_event_interruptible_timeout
443#define __wait_event_interruptible_timeout(wq, condition, ret) \
444do { \
445 wait_queue_t __wait; \
446 init_waitqueue_entry(&__wait, current); \
447 add_wait_queue(&wq, &__wait); \
448 for (;;) { \
449 set_current_state(TASK_INTERRUPTIBLE); \
450 if (condition) \
451 break; \
452 if (!signal_pending(current)) { \
453 ret = schedule_timeout(ret); \
454 if (!ret) \
455 break; \
456 continue; \
457 } \
458 ret = -ERESTARTSYS; \
459 break; \
460 } \
461 current->state = TASK_RUNNING; \
462 remove_wait_queue(&wq, &__wait); \
463} while (0)
464
465#define wait_event_interruptible_timeout(wq, condition, timeout) \
466({ \
467 long __ret = timeout; \
468 if (!(condition)) \
469 __wait_event_interruptible_timeout(wq, condition, __ret); \
470 __ret; \
471})
472#endif
473#define ONE_TICK 1
474#define OS_WAIT(_time) \
475{ int _i; \
476 long _loop = ((_time)/(1000/OS_HZ)) > 0 ? ((_time)/(1000/OS_HZ)) : 1;\
477 wait_queue_head_t _wait; \
478 init_waitqueue_head(&_wait); \
479 for (_i=0; _i<(_loop); _i++) \
480 wait_event_interruptible_timeout(_wait, 0, ONE_TICK); }
481
482
483typedef void (*TIMER_FUNCTION)(unsigned long);
484
485#define COPY_MAC_ADDR(Addr1, Addr2) memcpy((Addr1), (Addr2), MAC_ADDR_LEN)
486
487#define MlmeAllocateMemory(_pAd, _ppVA) os_alloc_mem(_pAd, _ppVA, MGMT_DMA_BUFFER_SIZE)
488#define MlmeFreeMemory(_pAd, _pVA) os_free_mem(_pAd, _pVA)
489
490
491#ifdef RT2870
492#define BUILD_TIMER_FUNCTION(_func) \
493void linux_##_func(unsigned long data) \
494{ \
495 PRALINK_TIMER_STRUCT _pTimer = (PRALINK_TIMER_STRUCT)data; \
496 RT2870_TIMER_ENTRY *_pQNode; \
497 RTMP_ADAPTER *_pAd; \
498 \
499 _pTimer->handle = _func; \
500 _pAd = (RTMP_ADAPTER *)_pTimer->pAd; \
501 _pQNode = RT2870_TimerQ_Insert(_pAd, _pTimer); \
502 if ((_pQNode == NULL) && (_pAd->TimerQ.status & RT2870_THREAD_CAN_DO_INSERT)) \
503 RTMP_OS_Add_Timer(&_pTimer->TimerObj, HZ); \
504}
505#endif // RT2870 //
506
507
508#define DECLARE_TIMER_FUNCTION(_func) \
509void linux_##_func(unsigned long data)
510
511#define GET_TIMER_FUNCTION(_func) \
512 linux_##_func
513
514DECLARE_TIMER_FUNCTION(MlmePeriodicExec);
515DECLARE_TIMER_FUNCTION(MlmeRssiReportExec);
516DECLARE_TIMER_FUNCTION(AsicRxAntEvalTimeout);
517DECLARE_TIMER_FUNCTION(APSDPeriodicExec);
518DECLARE_TIMER_FUNCTION(AsicRfTuningExec);
519#ifdef RT2870
520DECLARE_TIMER_FUNCTION(BeaconUpdateExec);
521#endif // RT2870 //
522
523DECLARE_TIMER_FUNCTION(BeaconTimeout);
524DECLARE_TIMER_FUNCTION(ScanTimeout);
525DECLARE_TIMER_FUNCTION(AuthTimeout);
526DECLARE_TIMER_FUNCTION(AssocTimeout);
527DECLARE_TIMER_FUNCTION(ReassocTimeout);
528DECLARE_TIMER_FUNCTION(DisassocTimeout);
529DECLARE_TIMER_FUNCTION(LinkDownExec);
530DECLARE_TIMER_FUNCTION(StaQuickResponeForRateUpExec);
531DECLARE_TIMER_FUNCTION(WpaDisassocApAndBlockAssoc);
532DECLARE_TIMER_FUNCTION(PsPollWakeExec);
533DECLARE_TIMER_FUNCTION(RadioOnExec);
534
535void RTMP_GetCurrentSystemTime(LARGE_INTEGER *time);
536
537
538/*
539 * packet helper
540 * - convert internal rt packet to os packet or
541 * os packet to rt packet
542 */
543#define RTPKT_TO_OSPKT(_p) ((struct sk_buff *)(_p))
544#define OSPKT_TO_RTPKT(_p) ((PNDIS_PACKET)(_p))
545
546#define GET_OS_PKT_DATAPTR(_pkt) \
547 (RTPKT_TO_OSPKT(_pkt)->data)
548
549#define GET_OS_PKT_LEN(_pkt) \
550 (RTPKT_TO_OSPKT(_pkt)->len)
551
552#define GET_OS_PKT_DATATAIL(_pkt) \
553 (RTPKT_TO_OSPKT(_pkt)->tail)
554
555#define GET_OS_PKT_HEAD(_pkt) \
556 (RTPKT_TO_OSPKT(_pkt)->head)
557
558#define GET_OS_PKT_END(_pkt) \
559 (RTPKT_TO_OSPKT(_pkt)->end)
560
561#define GET_OS_PKT_NETDEV(_pkt) \
562 (RTPKT_TO_OSPKT(_pkt)->dev)
563
564#define GET_OS_PKT_TYPE(_pkt) \
565 (RTPKT_TO_OSPKT(_pkt))
566
567#define GET_OS_PKT_NEXT(_pkt) \
568 (RTPKT_TO_OSPKT(_pkt)->next)
569
570
571#define OS_NTOHS(_Val) \
572 (ntohs(_Val))
573#define OS_HTONS(_Val) \
574 (htons(_Val))
575#define OS_NTOHL(_Val) \
576 (ntohl(_Val))
577#define OS_HTONL(_Val) \
578 (htonl(_Val))
579
580/* statistics counter */
581#define STATS_INC_RX_PACKETS(_pAd, _dev)
582#define STATS_INC_TX_PACKETS(_pAd, _dev)
583
584#define STATS_INC_RX_BYTESS(_pAd, _dev, len)
585#define STATS_INC_TX_BYTESS(_pAd, _dev, len)
586
587#define STATS_INC_RX_ERRORS(_pAd, _dev)
588#define STATS_INC_TX_ERRORS(_pAd, _dev)
589
590#define STATS_INC_RX_DROPPED(_pAd, _dev)
591#define STATS_INC_TX_DROPPED(_pAd, _dev)
592
593
594#define CB_OFF 10
595
596
597// check DDK NDIS_PACKET data structure and find out only MiniportReservedEx[0..7] can be used by our driver without
598// ambiguity. Fields after pPacket->MiniportReservedEx[8] may be used by other wrapper layer thus crashes the driver
599//
600
601// User Priority
602#define RTMP_SET_PACKET_UP(_p, _prio) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+0] = _prio)
603#define RTMP_GET_PACKET_UP(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+0])
604
605// Fragment #
606#define RTMP_SET_PACKET_FRAGMENTS(_p, _num) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+1] = _num)
607#define RTMP_GET_PACKET_FRAGMENTS(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+1])
608
609// 0x0 ~0x7f: TX to AP's own BSS which has the specified AID. if AID>127, set bit 7 in RTMP_SET_PACKET_EMACTAB too.
610//(this value also as MAC(on-chip WCID) table index)
611// 0x80~0xff: TX to a WDS link. b0~6: WDS index
612#define RTMP_SET_PACKET_WCID(_p, _wdsidx) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+2] = _wdsidx)
613#define RTMP_GET_PACKET_WCID(_p) ((UCHAR)(RTPKT_TO_OSPKT(_p)->cb[CB_OFF+2]))
614
615// 0xff: PKTSRC_NDIS, others: local TX buffer index. This value affects how to a packet
616#define RTMP_SET_PACKET_SOURCE(_p, _pktsrc) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+3] = _pktsrc)
617#define RTMP_GET_PACKET_SOURCE(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+3])
618
619// RTS/CTS-to-self protection method
620#define RTMP_SET_PACKET_RTS(_p, _num) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+4] = _num)
621#define RTMP_GET_PACKET_RTS(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+4])
622// see RTMP_S(G)ET_PACKET_EMACTAB
623
624// TX rate index
625#define RTMP_SET_PACKET_TXRATE(_p, _rate) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+5] = _rate)
626#define RTMP_GET_PACKET_TXRATE(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+5])
627
628// From which Interface
629#define RTMP_SET_PACKET_IF(_p, _ifdx) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+6] = _ifdx)
630#define RTMP_GET_PACKET_IF(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+6])
631#define RTMP_SET_PACKET_NET_DEVICE_MBSSID(_p, _bss) RTMP_SET_PACKET_IF((_p), (_bss))
632#define RTMP_SET_PACKET_NET_DEVICE_WDS(_p, _bss) RTMP_SET_PACKET_IF((_p), ((_bss) + MIN_NET_DEVICE_FOR_WDS))
633#define RTMP_SET_PACKET_NET_DEVICE_APCLI(_p, _idx) RTMP_SET_PACKET_IF((_p), ((_idx) + MIN_NET_DEVICE_FOR_APCLI))
634#define RTMP_SET_PACKET_NET_DEVICE_MESH(_p, _idx) RTMP_SET_PACKET_IF((_p), ((_idx) + MIN_NET_DEVICE_FOR_MESH))
635#define RTMP_GET_PACKET_NET_DEVICE_MBSSID(_p) RTMP_GET_PACKET_IF((_p))
636#define RTMP_GET_PACKET_NET_DEVICE(_p) RTMP_GET_PACKET_IF((_p))
637
638#define RTMP_SET_PACKET_MOREDATA(_p, _morebit) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+7] = _morebit)
639#define RTMP_GET_PACKET_MOREDATA(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+7])
640
641
642//
643// Sepcific Pakcet Type definition
644//
645#define RTMP_PACKET_SPECIFIC_CB_OFFSET 11
646
647#define RTMP_PACKET_SPECIFIC_DHCP 0x01
648#define RTMP_PACKET_SPECIFIC_EAPOL 0x02
649#define RTMP_PACKET_SPECIFIC_IPV4 0x04
650#define RTMP_PACKET_SPECIFIC_WAI 0x08
651#define RTMP_PACKET_SPECIFIC_VLAN 0x10
652#define RTMP_PACKET_SPECIFIC_LLCSNAP 0x20
653
654//Specific
655#define RTMP_SET_PACKET_SPECIFIC(_p, _flg) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11] = _flg)
656
657//DHCP
658#define RTMP_SET_PACKET_DHCP(_p, _flg) \
659 do{ \
660 if (_flg) \
661 (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11]) |= (RTMP_PACKET_SPECIFIC_DHCP); \
662 else \
663 (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11]) &= (!RTMP_PACKET_SPECIFIC_DHCP); \
664 }while(0)
665#define RTMP_GET_PACKET_DHCP(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11] & RTMP_PACKET_SPECIFIC_DHCP)
666
667//EAPOL
668#define RTMP_SET_PACKET_EAPOL(_p, _flg) \
669 do{ \
670 if (_flg) \
671 (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11]) |= (RTMP_PACKET_SPECIFIC_EAPOL); \
672 else \
673 (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11]) &= (!RTMP_PACKET_SPECIFIC_EAPOL); \
674 }while(0)
675#define RTMP_GET_PACKET_EAPOL(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11] & RTMP_PACKET_SPECIFIC_EAPOL)
676
677//WAI
678#define RTMP_SET_PACKET_WAI(_p, _flg) \
679 do{ \
680 if (_flg) \
681 (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11]) |= (RTMP_PACKET_SPECIFIC_WAI); \
682 else \
683 (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11]) &= (!RTMP_PACKET_SPECIFIC_WAI); \
684 }while(0)
685#define RTMP_GET_PACKET_WAI(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11] & RTMP_PACKET_SPECIFIC_WAI)
686
687#define RTMP_GET_PACKET_LOWRATE(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11] & (RTMP_PACKET_SPECIFIC_EAPOL | RTMP_PACKET_SPECIFIC_DHCP | RTMP_PACKET_SPECIFIC_WAI))
688
689//VLAN
690#define RTMP_SET_PACKET_VLAN(_p, _flg) \
691 do{ \
692 if (_flg) \
693 (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11]) |= (RTMP_PACKET_SPECIFIC_VLAN); \
694 else \
695 (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11]) &= (!RTMP_PACKET_SPECIFIC_VLAN); \
696 }while(0)
697#define RTMP_GET_PACKET_VLAN(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11] & RTMP_PACKET_SPECIFIC_VLAN)
698
699//LLC/SNAP
700#define RTMP_SET_PACKET_LLCSNAP(_p, _flg) \
701 do{ \
702 if (_flg) \
703 (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11]) |= (RTMP_PACKET_SPECIFIC_LLCSNAP); \
704 else \
705 (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11]) &= (!RTMP_PACKET_SPECIFIC_LLCSNAP); \
706 }while(0)
707
708#define RTMP_GET_PACKET_LLCSNAP(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11] & RTMP_PACKET_SPECIFIC_LLCSNAP)
709
710// IP
711#define RTMP_SET_PACKET_IPV4(_p, _flg) \
712 do{ \
713 if (_flg) \
714 (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11]) |= (RTMP_PACKET_SPECIFIC_IPV4); \
715 else \
716 (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11]) &= (!RTMP_PACKET_SPECIFIC_IPV4); \
717 }while(0)
718
719#define RTMP_GET_PACKET_IPV4(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11] & RTMP_PACKET_SPECIFIC_IPV4)
720
721
722// If this flag is set, it indicates that this EAPoL frame MUST be clear.
723#define RTMP_SET_PACKET_CLEAR_EAP_FRAME(_p, _flg) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+12] = _flg)
724#define RTMP_GET_PACKET_CLEAR_EAP_FRAME(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+12])
725
726#define RTMP_SET_PACKET_5VT(_p, _flg) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+22] = _flg)
727#define RTMP_GET_PACKET_5VT(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+22])
728
729
730#ifdef CONFIG_5VT_ENHANCE
731#define BRIDGE_TAG 0x35564252 // depends on 5VT define in br_input.c
732#endif
733
734
735#define NDIS_SET_PACKET_STATUS(_p, _status)
736
737
738#define GET_SG_LIST_FROM_PACKET(_p, _sc) \
739 rt_get_sg_list_from_packet(_p, _sc)
740
741
742#define NdisMoveMemory(Destination, Source, Length) memmove(Destination, Source, Length)
743#define NdisZeroMemory(Destination, Length) memset(Destination, 0, Length)
744#define NdisFillMemory(Destination, Length, Fill) memset(Destination, Fill, Length)
745#define NdisEqualMemory(Source1, Source2, Length) (!memcmp(Source1, Source2, Length))
746#define RTMPEqualMemory(Source1, Source2, Length) (!memcmp(Source1, Source2, Length))
747
748
749#define RTMP_INC_REF(_A) 0
750#define RTMP_DEC_REF(_A) 0
751#define RTMP_GET_REF(_A) 0
752
753
754
755/*
756 * ULONG
757 * RTMP_GetPhysicalAddressLow(
758 * IN NDIS_PHYSICAL_ADDRESS PhysicalAddress);
759 */
760#define RTMP_GetPhysicalAddressLow(PhysicalAddress) (PhysicalAddress)
761
762/*
763 * ULONG
764 * RTMP_GetPhysicalAddressHigh(
765 * IN NDIS_PHYSICAL_ADDRESS PhysicalAddress);
766 */
767#define RTMP_GetPhysicalAddressHigh(PhysicalAddress) (0)
768
769/*
770 * VOID
771 * RTMP_SetPhysicalAddressLow(
772 * IN NDIS_PHYSICAL_ADDRESS PhysicalAddress,
773 * IN ULONG Value);
774 */
775#define RTMP_SetPhysicalAddressLow(PhysicalAddress, Value) \
776 PhysicalAddress = Value;
777
778/*
779 * VOID
780 * RTMP_SetPhysicalAddressHigh(
781 * IN NDIS_PHYSICAL_ADDRESS PhysicalAddress,
782 * IN ULONG Value);
783 */
784#define RTMP_SetPhysicalAddressHigh(PhysicalAddress, Value)
785
786
787//CONTAINING_RECORD(pEntry, NDIS_PACKET, MiniportReservedEx);
788#define QUEUE_ENTRY_TO_PACKET(pEntry) \
789 (PNDIS_PACKET)(pEntry)
790
791#define PACKET_TO_QUEUE_ENTRY(pPacket) \
792 (PQUEUE_ENTRY)(pPacket)
793
794
795#ifndef CONTAINING_RECORD
796#define CONTAINING_RECORD(address, type, field) \
797((type *)((PCHAR)(address) - offsetof(type, field)))
798#endif
799
800
801#define RELEASE_NDIS_PACKET(_pAd, _pPacket, _Status) \
802{ \
803 RTMPFreeNdisPacket(_pAd, _pPacket); \
804}
805
806
807#define SWITCH_PhyAB(_pAA, _pBB) \
808{ \
809 ULONG AABasePaHigh; \
810 ULONG AABasePaLow; \
811 ULONG BBBasePaHigh; \
812 ULONG BBBasePaLow; \
813 BBBasePaHigh = RTMP_GetPhysicalAddressHigh(_pBB); \
814 BBBasePaLow = RTMP_GetPhysicalAddressLow(_pBB); \
815 AABasePaHigh = RTMP_GetPhysicalAddressHigh(_pAA); \
816 AABasePaLow = RTMP_GetPhysicalAddressLow(_pAA); \
817 RTMP_SetPhysicalAddressHigh(_pAA, BBBasePaHigh); \
818 RTMP_SetPhysicalAddressLow(_pAA, BBBasePaLow); \
819 RTMP_SetPhysicalAddressHigh(_pBB, AABasePaHigh); \
820 RTMP_SetPhysicalAddressLow(_pBB, AABasePaLow); \
821}
822
823
824#define NdisWriteErrorLogEntry(_a, _b, _c, _d)
825#define NdisMAllocateMapRegisters(_a, _b, _c, _d, _e) NDIS_STATUS_SUCCESS
826
827
828#define NdisAcquireSpinLock RTMP_SEM_LOCK
829#define NdisReleaseSpinLock RTMP_SEM_UNLOCK
830
831static inline void NdisGetSystemUpTime(ULONG *time)
832{
833 *time = jiffies;
834}
835
836//pPacket = CONTAINING_RECORD(pEntry, NDIS_PACKET, MiniportReservedEx);
837#define QUEUE_ENTRY_TO_PKT(pEntry) \
838 ((PNDIS_PACKET) (pEntry))
839
840int rt28xx_packet_xmit(struct sk_buff *skb);
841
842
843
844void rtmp_os_thread_init(PUCHAR pThreadName, PVOID pNotify);
845
846
diff --git a/drivers/staging/rt2870/rt_main_dev.c b/drivers/staging/rt2870/rt_main_dev.c
index 421aa28ebee3..121e1636017a 100644
--- a/drivers/staging/rt2870/rt_main_dev.c
+++ b/drivers/staging/rt2870/rt_main_dev.c
@@ -1,1040 +1 @@
1/* #include "../rt2860/rt_main_dev.c"
2 *************************************************************************
3 * Ralink Tech Inc.
4 * 5F., No.36, Taiyuan St., Jhubei City,
5 * Hsinchu County 302,
6 * Taiwan, R.O.C.
7 *
8 * (c) Copyright 2002-2007, Ralink Technology, Inc.
9 *
10 * This program is free software; you can redistribute it and/or modify *
11 * it under the terms of the GNU General Public License as published by *
12 * the Free Software Foundation; either version 2 of the License, or *
13 * (at your option) any later version. *
14 * *
15 * This program is distributed in the hope that it will be useful, *
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
18 * GNU General Public License for more details. *
19 * *
20 * You should have received a copy of the GNU General Public License *
21 * along with this program; if not, write to the *
22 * Free Software Foundation, Inc., *
23 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
24 * *
25 *************************************************************************
26
27 Module Name:
28 rt_main_dev.c
29
30 Abstract:
31 Create and register network interface.
32
33 Revision History:
34 Who When What
35 -------- ---------- ----------------------------------------------
36 Sample Mar/21/07 Merge RT2870 and RT2860 drivers.
37*/
38
39#include "rt_config.h"
40
41#define FORTY_MHZ_INTOLERANT_INTERVAL (60*1000) // 1 min
42
43/*---------------------------------------------------------------------*/
44/* Private Variables Used */
45/*---------------------------------------------------------------------*/
46//static RALINK_TIMER_STRUCT PeriodicTimer;
47
48char *mac = ""; // default 00:00:00:00:00:00
49char *hostname = "";
50module_param (mac, charp, 0);
51MODULE_PARM_DESC (mac, "rt28xx: wireless mac addr");
52
53
54/*---------------------------------------------------------------------*/
55/* Prototypes of Functions Used */
56/*---------------------------------------------------------------------*/
57extern BOOLEAN ba_reordering_resource_init(PRTMP_ADAPTER pAd, int num);
58extern void ba_reordering_resource_release(PRTMP_ADAPTER pAd);
59extern NDIS_STATUS NICLoadRateSwitchingParams(IN PRTMP_ADAPTER pAd);
60
61
62// public function prototype
63INT __devinit rt28xx_probe(IN void *_dev_p, IN void *_dev_id_p,
64 IN UINT argc, OUT PRTMP_ADAPTER *ppAd);
65
66// private function prototype
67static int rt28xx_init(IN struct net_device *net_dev);
68INT rt28xx_send_packets(IN struct sk_buff *skb_p, IN struct net_device *net_dev);
69
70static void CfgInitHook(PRTMP_ADAPTER pAd);
71
72extern const struct iw_handler_def rt28xx_iw_handler_def;
73
74#if WIRELESS_EXT >= 12
75// This function will be called when query /proc
76struct iw_statistics *rt28xx_get_wireless_stats(
77 IN struct net_device *net_dev);
78#endif
79
80struct net_device_stats *RT28xx_get_ether_stats(
81 IN struct net_device *net_dev);
82
83/*
84========================================================================
85Routine Description:
86 Close raxx interface.
87
88Arguments:
89 *net_dev the raxx interface pointer
90
91Return Value:
92 0 Open OK
93 otherwise Open Fail
94
95Note:
96 1. if open fail, kernel will not call the close function.
97 2. Free memory for
98 (1) Mlme Memory Handler: MlmeHalt()
99 (2) TX & RX: RTMPFreeTxRxRingMemory()
100 (3) BA Reordering: ba_reordering_resource_release()
101========================================================================
102*/
103int MainVirtualIF_close(IN struct net_device *net_dev)
104{
105 RTMP_ADAPTER *pAd = net_dev->ml_priv;
106
107 // Sanity check for pAd
108 if (pAd == NULL)
109 return 0; // close ok
110
111 netif_carrier_off(pAd->net_dev);
112 netif_stop_queue(pAd->net_dev);
113
114
115
116 VIRTUAL_IF_DOWN(pAd);
117
118 RT_MOD_DEC_USE_COUNT();
119
120 return 0; // close ok
121}
122
123/*
124========================================================================
125Routine Description:
126 Open raxx interface.
127
128Arguments:
129 *net_dev the raxx interface pointer
130
131Return Value:
132 0 Open OK
133 otherwise Open Fail
134
135Note:
136 1. if open fail, kernel will not call the close function.
137 2. Free memory for
138 (1) Mlme Memory Handler: MlmeHalt()
139 (2) TX & RX: RTMPFreeTxRxRingMemory()
140 (3) BA Reordering: ba_reordering_resource_release()
141========================================================================
142*/
143int MainVirtualIF_open(IN struct net_device *net_dev)
144{
145 RTMP_ADAPTER *pAd = net_dev->ml_priv;
146
147 // Sanity check for pAd
148 if (pAd == NULL)
149 return 0; // close ok
150
151 if (VIRTUAL_IF_UP(pAd) != 0)
152 return -1;
153
154 // increase MODULE use count
155 RT_MOD_INC_USE_COUNT();
156
157 netif_start_queue(net_dev);
158 netif_carrier_on(net_dev);
159 netif_wake_queue(net_dev);
160
161 return 0;
162}
163
164/*
165========================================================================
166Routine Description:
167 Close raxx interface.
168
169Arguments:
170 *net_dev the raxx interface pointer
171
172Return Value:
173 0 Open OK
174 otherwise Open Fail
175
176Note:
177 1. if open fail, kernel will not call the close function.
178 2. Free memory for
179 (1) Mlme Memory Handler: MlmeHalt()
180 (2) TX & RX: RTMPFreeTxRxRingMemory()
181 (3) BA Reordering: ba_reordering_resource_release()
182========================================================================
183*/
184int rt28xx_close(IN PNET_DEV dev)
185{
186 struct net_device * net_dev = (struct net_device *)dev;
187 RTMP_ADAPTER *pAd = net_dev->ml_priv;
188 BOOLEAN Cancelled = FALSE;
189 UINT32 i = 0;
190#ifdef RT2870
191 DECLARE_WAIT_QUEUE_HEAD(unlink_wakeup);
192 DECLARE_WAITQUEUE(wait, current);
193
194 //RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_REMOVE_IN_PROGRESS);
195#endif // RT2870 //
196
197
198 DBGPRINT(RT_DEBUG_TRACE, ("===> rt28xx_close\n"));
199
200 // Sanity check for pAd
201 if (pAd == NULL)
202 return 0; // close ok
203
204 {
205
206 // If dirver doesn't wake up firmware here,
207 // NICLoadFirmware will hang forever when interface is up again.
208 if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_DOZE))
209 {
210 AsicForceWakeup(pAd, TRUE);
211 }
212
213 if (INFRA_ON(pAd) &&
214 (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NIC_NOT_EXIST)))
215 {
216 MLME_DISASSOC_REQ_STRUCT DisReq;
217 MLME_QUEUE_ELEM *MsgElem = (MLME_QUEUE_ELEM *) kmalloc(sizeof(MLME_QUEUE_ELEM), MEM_ALLOC_FLAG);
218
219 COPY_MAC_ADDR(DisReq.Addr, pAd->CommonCfg.Bssid);
220 DisReq.Reason = REASON_DEAUTH_STA_LEAVING;
221
222 MsgElem->Machine = ASSOC_STATE_MACHINE;
223 MsgElem->MsgType = MT2_MLME_DISASSOC_REQ;
224 MsgElem->MsgLen = sizeof(MLME_DISASSOC_REQ_STRUCT);
225 NdisMoveMemory(MsgElem->Msg, &DisReq, sizeof(MLME_DISASSOC_REQ_STRUCT));
226
227 // Prevent to connect AP again in STAMlmePeriodicExec
228 pAd->MlmeAux.AutoReconnectSsidLen= 32;
229 NdisZeroMemory(pAd->MlmeAux.AutoReconnectSsid, pAd->MlmeAux.AutoReconnectSsidLen);
230
231 pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_OID_DISASSOC;
232 MlmeDisassocReqAction(pAd, MsgElem);
233 kfree(MsgElem);
234
235 RTMPusecDelay(1000);
236 }
237
238#ifdef RT2870
239 RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_REMOVE_IN_PROGRESS);
240#endif // RT2870 //
241
242#ifdef CCX_SUPPORT
243 RTMPCancelTimer(&pAd->StaCfg.LeapAuthTimer, &Cancelled);
244#endif
245
246 RTMPCancelTimer(&pAd->StaCfg.StaQuickResponeForRateUpTimer, &Cancelled);
247 RTMPCancelTimer(&pAd->StaCfg.WpaDisassocAndBlockAssocTimer, &Cancelled);
248
249 MlmeRadioOff(pAd);
250 }
251
252 RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS);
253
254 for (i = 0 ; i < NUM_OF_TX_RING; i++)
255 {
256 while (pAd->DeQueueRunning[i] == TRUE)
257 {
258 printk("Waiting for TxQueue[%d] done..........\n", i);
259 RTMPusecDelay(1000);
260 }
261 }
262
263#ifdef RT2870
264 // ensure there are no more active urbs.
265 add_wait_queue (&unlink_wakeup, &wait);
266 pAd->wait = &unlink_wakeup;
267
268 // maybe wait for deletions to finish.
269 i = 0;
270 //while((i < 25) && atomic_read(&pAd->PendingRx) > 0)
271 while(i < 25)
272 {
273 unsigned long IrqFlags;
274
275 RTMP_IRQ_LOCK(&pAd->BulkInLock, IrqFlags);
276 if (pAd->PendingRx == 0)
277 {
278 RTMP_IRQ_UNLOCK(&pAd->BulkInLock, IrqFlags);
279 break;
280 }
281 RTMP_IRQ_UNLOCK(&pAd->BulkInLock, IrqFlags);
282
283 msleep(UNLINK_TIMEOUT_MS); //Time in millisecond
284 i++;
285 }
286 pAd->wait = NULL;
287 remove_wait_queue (&unlink_wakeup, &wait);
288#endif // RT2870 //
289
290#ifdef RT2870
291 // We need clear timerQ related structure before exits of the timer thread.
292 RT2870_TimerQ_Exit(pAd);
293 // Close kernel threads or tasklets
294 RT28xxThreadTerminate(pAd);
295#endif // RT2870 //
296
297 // Stop Mlme state machine
298 MlmeHalt(pAd);
299
300 // Close kernel threads or tasklets
301 kill_thread_task(pAd);
302
303 MacTableReset(pAd);
304
305 MeasureReqTabExit(pAd);
306 TpcReqTabExit(pAd);
307
308
309
310
311 // Free Ring or USB buffers
312 RTMPFreeTxRxRingMemory(pAd);
313
314 RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS);
315
316 // Free BA reorder resource
317 ba_reordering_resource_release(pAd);
318
319 RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_START_UP);
320
321 return 0; // close ok
322} /* End of rt28xx_close */
323
324static int rt28xx_init(IN struct net_device *net_dev)
325{
326 PRTMP_ADAPTER pAd = net_dev->ml_priv;
327 UINT index;
328 UCHAR TmpPhy;
329 NDIS_STATUS Status;
330 UINT32 MacCsr0 = 0;
331
332 // Allocate BA Reordering memory
333 ba_reordering_resource_init(pAd, MAX_REORDERING_MPDU_NUM);
334
335 // Make sure MAC gets ready.
336 index = 0;
337 do
338 {
339 RTMP_IO_READ32(pAd, MAC_CSR0, &MacCsr0);
340 pAd->MACVersion = MacCsr0;
341
342 if ((pAd->MACVersion != 0x00) && (pAd->MACVersion != 0xFFFFFFFF))
343 break;
344
345 RTMPusecDelay(10);
346 } while (index++ < 100);
347
348 DBGPRINT(RT_DEBUG_TRACE, ("MAC_CSR0 [ Ver:Rev=0x%08x]\n", pAd->MACVersion));
349/*Iverson patch PCIE L1 issue */
350
351 // Disable DMA
352 RT28XXDMADisable(pAd);
353
354
355 // Load 8051 firmware
356 Status = NICLoadFirmware(pAd);
357 if (Status != NDIS_STATUS_SUCCESS)
358 {
359 DBGPRINT_ERR(("NICLoadFirmware failed, Status[=0x%08x]\n", Status));
360 goto err1;
361 }
362
363 NICLoadRateSwitchingParams(pAd);
364
365 // Disable interrupts here which is as soon as possible
366 // This statement should never be true. We might consider to remove it later
367
368 Status = RTMPAllocTxRxRingMemory(pAd);
369 if (Status != NDIS_STATUS_SUCCESS)
370 {
371 DBGPRINT_ERR(("RTMPAllocDMAMemory failed, Status[=0x%08x]\n", Status));
372 goto err1;
373 }
374
375 RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_IN_USE);
376
377 // initialize MLME
378 //
379
380 Status = MlmeInit(pAd);
381 if (Status != NDIS_STATUS_SUCCESS)
382 {
383 DBGPRINT_ERR(("MlmeInit failed, Status[=0x%08x]\n", Status));
384 goto err2;
385 }
386
387 // Initialize pAd->StaCfg, pAd->ApCfg, pAd->CommonCfg to manufacture default
388 //
389 UserCfgInit(pAd);
390
391#ifdef RT2870
392 // We need init timerQ related structure before create the timer thread.
393 RT2870_TimerQ_Init(pAd);
394#endif // RT2870 //
395
396 RT28XX_TASK_THREAD_INIT(pAd, Status);
397 if (Status != NDIS_STATUS_SUCCESS)
398 goto err1;
399
400 CfgInitHook(pAd);
401
402 NdisAllocateSpinLock(&pAd->MacTabLock);
403
404 MeasureReqTabInit(pAd);
405 TpcReqTabInit(pAd);
406
407 //
408 // Init the hardware, we need to init asic before read registry, otherwise mac register will be reset
409 //
410 Status = NICInitializeAdapter(pAd, TRUE);
411 if (Status != NDIS_STATUS_SUCCESS)
412 {
413 DBGPRINT_ERR(("NICInitializeAdapter failed, Status[=0x%08x]\n", Status));
414 if (Status != NDIS_STATUS_SUCCESS)
415 goto err3;
416 }
417
418 // Read parameters from Config File
419 Status = RTMPReadParametersHook(pAd);
420
421 printk("1. Phy Mode = %d\n", pAd->CommonCfg.PhyMode);
422 if (Status != NDIS_STATUS_SUCCESS)
423 {
424 DBGPRINT_ERR(("NICReadRegParameters failed, Status[=0x%08x]\n",Status));
425 goto err4;
426 }
427
428#ifdef RT2870
429 pAd->CommonCfg.bMultipleIRP = FALSE;
430
431 if (pAd->CommonCfg.bMultipleIRP)
432 pAd->CommonCfg.NumOfBulkInIRP = RX_RING_SIZE;
433 else
434 pAd->CommonCfg.NumOfBulkInIRP = 1;
435#endif // RT2870 //
436
437
438 //Init Ba Capability parameters.
439 pAd->CommonCfg.DesiredHtPhy.MpduDensity = (UCHAR)pAd->CommonCfg.BACapability.field.MpduDensity;
440 pAd->CommonCfg.DesiredHtPhy.AmsduEnable = (USHORT)pAd->CommonCfg.BACapability.field.AmsduEnable;
441 pAd->CommonCfg.DesiredHtPhy.AmsduSize = (USHORT)pAd->CommonCfg.BACapability.field.AmsduSize;
442 pAd->CommonCfg.DesiredHtPhy.MimoPs = (USHORT)pAd->CommonCfg.BACapability.field.MMPSmode;
443 // UPdata to HT IE
444 pAd->CommonCfg.HtCapability.HtCapInfo.MimoPs = (USHORT)pAd->CommonCfg.BACapability.field.MMPSmode;
445 pAd->CommonCfg.HtCapability.HtCapInfo.AMsduSize = (USHORT)pAd->CommonCfg.BACapability.field.AmsduSize;
446 pAd->CommonCfg.HtCapability.HtCapParm.MpduDensity = (UCHAR)pAd->CommonCfg.BACapability.field.MpduDensity;
447
448 printk("2. Phy Mode = %d\n", pAd->CommonCfg.PhyMode);
449
450 // We should read EEPROM for all cases. rt2860b
451 NICReadEEPROMParameters(pAd, mac);
452
453 printk("3. Phy Mode = %d\n", pAd->CommonCfg.PhyMode);
454
455 NICInitAsicFromEEPROM(pAd); //rt2860b
456
457 // Set PHY to appropriate mode
458 TmpPhy = pAd->CommonCfg.PhyMode;
459 pAd->CommonCfg.PhyMode = 0xff;
460 RTMPSetPhyMode(pAd, TmpPhy);
461 SetCommonHT(pAd);
462
463 // No valid channels.
464 if (pAd->ChannelListNum == 0)
465 {
466 printk("Wrong configuration. No valid channel found. Check \"ContryCode\" and \"ChannelGeography\" setting.\n");
467 goto err4;
468 }
469
470 printk("MCS Set = %02x %02x %02x %02x %02x\n", pAd->CommonCfg.HtCapability.MCSSet[0],
471 pAd->CommonCfg.HtCapability.MCSSet[1], pAd->CommonCfg.HtCapability.MCSSet[2],
472 pAd->CommonCfg.HtCapability.MCSSet[3], pAd->CommonCfg.HtCapability.MCSSet[4]);
473
474#ifdef RT2870
475 //Init RT30xx RFRegisters after read RFIC type from EEPROM
476 NICInitRT30xxRFRegisters(pAd);
477#endif // RT2870 //
478
479#ifdef IKANOS_VX_1X0
480 VR_IKANOS_FP_Init(pAd->ApCfg.BssidNum, pAd->PermanentAddress);
481#endif // IKANOS_VX_1X0 //
482
483 //
484 // Initialize RF register to default value
485 //
486 AsicSwitchChannel(pAd, pAd->CommonCfg.Channel, FALSE);
487 AsicLockChannel(pAd, pAd->CommonCfg.Channel);
488
489#ifndef RT30xx
490 // 8051 firmware require the signal during booting time.
491 AsicSendCommandToMcu(pAd, 0x72, 0xFF, 0x00, 0x00);
492#endif
493
494 if (pAd && (Status != NDIS_STATUS_SUCCESS))
495 {
496 //
497 // Undo everything if it failed
498 //
499 if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_IN_USE))
500 {
501 RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_IN_USE);
502 }
503 }
504 else if (pAd)
505 {
506 // Microsoft HCT require driver send a disconnect event after driver initialization.
507 OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED);
508 RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_MEDIA_STATE_CHANGE);
509
510 DBGPRINT(RT_DEBUG_TRACE, ("NDIS_STATUS_MEDIA_DISCONNECT Event B!\n"));
511
512
513#ifdef RT2870
514 RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_RESET_IN_PROGRESS);
515 RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_REMOVE_IN_PROGRESS);
516
517 //
518 // Support multiple BulkIn IRP,
519 // the value on pAd->CommonCfg.NumOfBulkInIRP may be large than 1.
520 //
521 for(index=0; index<pAd->CommonCfg.NumOfBulkInIRP; index++)
522 {
523 RTUSBBulkReceive(pAd);
524 DBGPRINT(RT_DEBUG_TRACE, ("RTUSBBulkReceive!\n" ));
525 }
526#endif // RT2870 //
527 }// end of else
528
529
530 DBGPRINT_S(Status, ("<==== RTMPInitialize, Status=%x\n", Status));
531
532 return TRUE;
533
534
535err4:
536err3:
537 MlmeHalt(pAd);
538err2:
539 RTMPFreeTxRxRingMemory(pAd);
540err1:
541 os_free_mem(pAd, pAd->mpdu_blk_pool.mem); // free BA pool
542 RT28XX_IRQ_RELEASE(net_dev);
543
544 // shall not set ml_priv to NULL here because the ml_priv didn't been free yet.
545 //net_dev->ml_priv = 0;
546
547 printk("!!! %s Initialized fail !!!\n", RT28xx_CHIP_NAME);
548 return FALSE;
549} /* End of rt28xx_init */
550
551
552/*
553========================================================================
554Routine Description:
555 Open raxx interface.
556
557Arguments:
558 *net_dev the raxx interface pointer
559
560Return Value:
561 0 Open OK
562 otherwise Open Fail
563
564Note:
565========================================================================
566*/
567int rt28xx_open(IN PNET_DEV dev)
568{
569 struct net_device * net_dev = (struct net_device *)dev;
570 PRTMP_ADAPTER pAd = net_dev->ml_priv;
571 int retval = 0;
572 POS_COOKIE pObj;
573
574
575 // Sanity check for pAd
576 if (pAd == NULL)
577 {
578 /* if 1st open fail, pAd will be free;
579 So the net_dev->ml_priv will be NULL in 2rd open */
580 return -1;
581 }
582
583 // Init
584 pObj = (POS_COOKIE)pAd->OS_Cookie;
585
586 // reset Adapter flags
587 RTMP_CLEAR_FLAGS(pAd);
588
589 // Request interrupt service routine for PCI device
590 // register the interrupt routine with the os
591 RT28XX_IRQ_REQUEST(net_dev);
592
593
594 // Init BssTab & ChannelInfo tabbles for auto channel select.
595
596
597 // Chip & other init
598 if (rt28xx_init(net_dev) == FALSE)
599 goto err;
600
601 NdisZeroMemory(pAd->StaCfg.dev_name, 16);
602 NdisMoveMemory(pAd->StaCfg.dev_name, net_dev->name, strlen(net_dev->name));
603
604 // Set up the Mac address
605 NdisMoveMemory(net_dev->dev_addr, (void *) pAd->CurrentAddress, 6);
606
607 // Init IRQ parameters
608 RT28XX_IRQ_INIT(pAd);
609
610 // Various AP function init
611
612 // Enable Interrupt
613 RT28XX_IRQ_ENABLE(pAd);
614
615 // Now Enable RxTx
616 RTMPEnableRxTx(pAd);
617 RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_START_UP);
618
619 {
620 UINT32 reg = 0;
621 RTMP_IO_READ32(pAd, 0x1300, &reg); // clear garbage interrupts
622 printk("0x1300 = %08x\n", reg);
623 }
624
625 return (retval);
626
627err:
628 return (-1);
629} /* End of rt28xx_open */
630
631static const struct net_device_ops rt2870_netdev_ops = {
632 .ndo_open = MainVirtualIF_open,
633 .ndo_stop = MainVirtualIF_close,
634 .ndo_do_ioctl = rt28xx_ioctl,
635 .ndo_get_stats = RT28xx_get_ether_stats,
636 .ndo_validate_addr = NULL,
637 .ndo_set_mac_address = eth_mac_addr,
638 .ndo_change_mtu = eth_change_mtu,
639#ifdef IKANOS_VX_1X0
640 .ndo_start_xmit = IKANOS_DataFramesTx,
641#else
642 .ndo_start_xmit = rt28xx_send_packets,
643#endif
644};
645
646/* Must not be called for mdev and apdev */
647static NDIS_STATUS rt_ieee80211_if_setup(struct net_device *dev, PRTMP_ADAPTER pAd)
648{
649 NDIS_STATUS Status;
650 INT i=0;
651 CHAR slot_name[IFNAMSIZ];
652 struct net_device *device;
653
654#if WIRELESS_EXT >= 12
655 if (pAd->OpMode == OPMODE_STA)
656 {
657 dev->wireless_handlers = &rt28xx_iw_handler_def;
658 }
659#endif //WIRELESS_EXT >= 12
660
661#if WIRELESS_EXT < 21
662 dev->get_wireless_stats = rt28xx_get_wireless_stats;
663#endif
664 dev->priv_flags = INT_MAIN;
665 dev->netdev_ops = &rt2870_netdev_ops;
666 // find available device name
667 for (i = 0; i < 8; i++)
668 {
669 sprintf(slot_name, "ra%d", i);
670
671 device = dev_get_by_name(dev_net(dev), slot_name);
672 if (device != NULL)
673 dev_put(device);
674
675 if (device == NULL)
676 break;
677 }
678
679 if(i == 8)
680 {
681 DBGPRINT(RT_DEBUG_ERROR, ("No available slot name\n"));
682 Status = NDIS_STATUS_FAILURE;
683 }
684 else
685 {
686 sprintf(dev->name, "ra%d", i);
687 Status = NDIS_STATUS_SUCCESS;
688 }
689
690 return Status;
691
692}
693
694/*
695========================================================================
696Routine Description:
697 Probe RT28XX chipset.
698
699Arguments:
700 _dev_p Point to the PCI or USB device
701 _dev_id_p Point to the PCI or USB device ID
702
703Return Value:
704 0 Probe OK
705 -ENODEV Probe Fail
706
707Note:
708========================================================================
709*/
710INT __devinit rt28xx_probe(
711 IN void *_dev_p,
712 IN void *_dev_id_p,
713 IN UINT argc,
714 OUT PRTMP_ADAPTER *ppAd)
715{
716 struct net_device *net_dev;
717 PRTMP_ADAPTER pAd = (PRTMP_ADAPTER) NULL;
718 INT status;
719 PVOID handle;
720#ifdef RT2870
721 struct usb_interface *intf = (struct usb_interface *)_dev_p;
722 struct usb_device *dev_p = interface_to_usbdev(intf);
723
724 dev_p = usb_get_dev(dev_p);
725#endif // RT2870 //
726
727
728 DBGPRINT(RT_DEBUG_TRACE, ("STA Driver version-%s\n", STA_DRIVER_VERSION));
729
730 net_dev = alloc_etherdev(sizeof(PRTMP_ADAPTER));
731 if (net_dev == NULL)
732 {
733 printk("alloc_netdev failed\n");
734
735 goto err_out;
736 }
737
738 netif_stop_queue(net_dev);
739
740/* for supporting Network Manager */
741/* Set the sysfs physical device reference for the network logical device
742 * if set prior to registration will cause a symlink during initialization.
743 */
744 SET_NETDEV_DEV(net_dev, &(dev_p->dev));
745
746 // Allocate RTMP_ADAPTER miniport adapter structure
747 handle = kmalloc(sizeof(struct os_cookie), GFP_KERNEL);
748 RT28XX_HANDLE_DEV_ASSIGN(handle, dev_p);
749
750 status = RTMPAllocAdapterBlock(handle, &pAd);
751 if (status != NDIS_STATUS_SUCCESS)
752 goto err_out_free_netdev;
753
754 net_dev->ml_priv = (PVOID)pAd;
755 pAd->net_dev = net_dev; // must be before RT28XXNetDevInit()
756
757 RT28XXNetDevInit(_dev_p, net_dev, pAd);
758
759 pAd->StaCfg.OriDevType = net_dev->type;
760
761 // Post config
762 if (RT28XXProbePostConfig(_dev_p, pAd, 0) == FALSE)
763 goto err_out_unmap;
764
765 pAd->OpMode = OPMODE_STA;
766
767 // sample move
768 if (rt_ieee80211_if_setup(net_dev, pAd) != NDIS_STATUS_SUCCESS)
769 goto err_out_unmap;
770
771 // Register this device
772 status = register_netdev(net_dev);
773 if (status)
774 goto err_out_unmap;
775
776 // Set driver data
777 RT28XX_DRVDATA_SET(_dev_p);
778
779
780
781 *ppAd = pAd;
782 return 0; // probe ok
783
784
785 /* --------------------------- ERROR HANDLE --------------------------- */
786err_out_unmap:
787 RTMPFreeAdapter(pAd);
788 RT28XX_UNMAP();
789
790err_out_free_netdev:
791 free_netdev(net_dev);
792
793err_out:
794 RT28XX_PUT_DEVICE(dev_p);
795
796 return -ENODEV; /* probe fail */
797} /* End of rt28xx_probe */
798
799
800/*
801========================================================================
802Routine Description:
803 The entry point for Linux kernel sent packet to our driver.
804
805Arguments:
806 sk_buff *skb the pointer refer to a sk_buffer.
807
808Return Value:
809 0
810
811Note:
812 This function is the entry point of Tx Path for Os delivery packet to
813 our driver. You only can put OS-depened & STA/AP common handle procedures
814 in here.
815========================================================================
816*/
817int rt28xx_packet_xmit(struct sk_buff *skb)
818{
819 struct net_device *net_dev = skb->dev;
820 PRTMP_ADAPTER pAd = net_dev->ml_priv;
821 int status = 0;
822 PNDIS_PACKET pPacket = (PNDIS_PACKET) skb;
823
824 {
825 // Drop send request since we are in monitor mode
826 if (MONITOR_ON(pAd))
827 {
828 RELEASE_NDIS_PACKET(pAd, pPacket, NDIS_STATUS_FAILURE);
829 goto done;
830 }
831 }
832
833 // EapolStart size is 18
834 if (skb->len < 14)
835 {
836 //printk("bad packet size: %d\n", pkt->len);
837 hex_dump("bad packet", skb->data, skb->len);
838 RELEASE_NDIS_PACKET(pAd, pPacket, NDIS_STATUS_FAILURE);
839 goto done;
840 }
841
842 RTMP_SET_PACKET_5VT(pPacket, 0);
843#ifdef CONFIG_5VT_ENHANCE
844 if (*(int*)(skb->cb) == BRIDGE_TAG) {
845 RTMP_SET_PACKET_5VT(pPacket, 1);
846 }
847#endif
848
849 STASendPackets((NDIS_HANDLE)pAd, (PPNDIS_PACKET) &pPacket, 1);
850
851 status = 0;
852done:
853
854 return status;
855}
856
857
858/*
859========================================================================
860Routine Description:
861 Send a packet to WLAN.
862
863Arguments:
864 skb_p points to our adapter
865 dev_p which WLAN network interface
866
867Return Value:
868 0: transmit successfully
869 otherwise: transmit fail
870
871Note:
872========================================================================
873*/
874INT rt28xx_send_packets(
875 IN struct sk_buff *skb_p,
876 IN struct net_device *net_dev)
877{
878 RTMP_ADAPTER *pAd = net_dev->ml_priv;
879
880 if (!(net_dev->flags & IFF_UP))
881 {
882 RELEASE_NDIS_PACKET(pAd, (PNDIS_PACKET)skb_p, NDIS_STATUS_FAILURE);
883 return 0;
884 }
885
886 NdisZeroMemory((PUCHAR)&skb_p->cb[CB_OFF], 15);
887 RTMP_SET_PACKET_NET_DEVICE_MBSSID(skb_p, MAIN_MBSSID);
888
889 return rt28xx_packet_xmit(skb_p);
890} /* End of MBSS_VirtualIF_PacketSend */
891
892
893
894
895void CfgInitHook(PRTMP_ADAPTER pAd)
896{
897 pAd->bBroadComHT = TRUE;
898} /* End of CfgInitHook */
899
900#if WIRELESS_EXT >= 12
901// This function will be called when query /proc
902struct iw_statistics *rt28xx_get_wireless_stats(
903 IN struct net_device *net_dev)
904{
905 PRTMP_ADAPTER pAd = net_dev->ml_priv;
906
907
908 DBGPRINT(RT_DEBUG_TRACE, ("rt28xx_get_wireless_stats --->\n"));
909
910 pAd->iw_stats.status = 0; // Status - device dependent for now
911
912 // link quality
913 pAd->iw_stats.qual.qual = ((pAd->Mlme.ChannelQuality * 12)/10 + 10);
914 if(pAd->iw_stats.qual.qual > 100)
915 pAd->iw_stats.qual.qual = 100;
916
917 if (pAd->OpMode == OPMODE_STA)
918 pAd->iw_stats.qual.level = RTMPMaxRssi(pAd, pAd->StaCfg.RssiSample.LastRssi0, pAd->StaCfg.RssiSample.LastRssi1, pAd->StaCfg.RssiSample.LastRssi2);
919
920 pAd->iw_stats.qual.noise = pAd->BbpWriteLatch[66]; // noise level (dBm)
921
922 pAd->iw_stats.qual.noise += 256 - 143;
923 pAd->iw_stats.qual.updated = 1; // Flags to know if updated
924#ifdef IW_QUAL_DBM
925 pAd->iw_stats.qual.updated |= IW_QUAL_DBM; // Level + Noise are dBm
926#endif // IW_QUAL_DBM //
927
928 pAd->iw_stats.discard.nwid = 0; // Rx : Wrong nwid/essid
929 pAd->iw_stats.miss.beacon = 0; // Missed beacons/superframe
930
931 DBGPRINT(RT_DEBUG_TRACE, ("<--- rt28xx_get_wireless_stats\n"));
932 return &pAd->iw_stats;
933} /* End of rt28xx_get_wireless_stats */
934#endif // WIRELESS_EXT //
935
936
937
938void tbtt_tasklet(unsigned long data)
939{
940#define MAX_TX_IN_TBTT (16)
941
942}
943
944INT rt28xx_ioctl(
945 IN struct net_device *net_dev,
946 IN OUT struct ifreq *rq,
947 IN INT cmd)
948{
949 VIRTUAL_ADAPTER *pVirtualAd = NULL;
950 RTMP_ADAPTER *pAd = NULL;
951 INT ret = 0;
952
953 if (net_dev->priv_flags == INT_MAIN)
954 {
955 pAd = net_dev->ml_priv;
956 }
957 else
958 {
959 pVirtualAd = net_dev->ml_priv;
960 pAd = pVirtualAd->RtmpDev->ml_priv;
961 }
962
963 if (pAd == NULL)
964 {
965 /* if 1st open fail, pAd will be free;
966 So the net_dev->ml_priv will be NULL in 2rd open */
967 return -ENETDOWN;
968 }
969
970 ret = rt28xx_sta_ioctl(net_dev, rq, cmd);
971
972 return ret;
973}
974
975/*
976 ========================================================================
977
978 Routine Description:
979 return ethernet statistics counter
980
981 Arguments:
982 net_dev Pointer to net_device
983
984 Return Value:
985 net_device_stats*
986
987 Note:
988
989 ========================================================================
990*/
991struct net_device_stats *RT28xx_get_ether_stats(
992 IN struct net_device *net_dev)
993{
994 RTMP_ADAPTER *pAd = NULL;
995
996 if (net_dev)
997 pAd = net_dev->ml_priv;
998
999 if (pAd)
1000 {
1001
1002 pAd->stats.rx_packets = pAd->WlanCounters.ReceivedFragmentCount.QuadPart;
1003 pAd->stats.tx_packets = pAd->WlanCounters.TransmittedFragmentCount.QuadPart;
1004
1005 pAd->stats.rx_bytes = pAd->RalinkCounters.ReceivedByteCount;
1006 pAd->stats.tx_bytes = pAd->RalinkCounters.TransmittedByteCount;
1007
1008 pAd->stats.rx_errors = pAd->Counters8023.RxErrors;
1009 pAd->stats.tx_errors = pAd->Counters8023.TxErrors;
1010
1011 pAd->stats.rx_dropped = 0;
1012 pAd->stats.tx_dropped = 0;
1013
1014 pAd->stats.multicast = pAd->WlanCounters.MulticastReceivedFrameCount.QuadPart; // multicast packets received
1015 pAd->stats.collisions = pAd->Counters8023.OneCollision + pAd->Counters8023.MoreCollisions; // Collision packets
1016
1017 pAd->stats.rx_length_errors = 0;
1018 pAd->stats.rx_over_errors = pAd->Counters8023.RxNoBuffer; // receiver ring buff overflow
1019 pAd->stats.rx_crc_errors = 0;//pAd->WlanCounters.FCSErrorCount; // recved pkt with crc error
1020 pAd->stats.rx_frame_errors = pAd->Counters8023.RcvAlignmentErrors; // recv'd frame alignment error
1021 pAd->stats.rx_fifo_errors = pAd->Counters8023.RxNoBuffer; // recv'r fifo overrun
1022 pAd->stats.rx_missed_errors = 0; // receiver missed packet
1023
1024 // detailed tx_errors
1025 pAd->stats.tx_aborted_errors = 0;
1026 pAd->stats.tx_carrier_errors = 0;
1027 pAd->stats.tx_fifo_errors = 0;
1028 pAd->stats.tx_heartbeat_errors = 0;
1029 pAd->stats.tx_window_errors = 0;
1030
1031 // for cslip etc
1032 pAd->stats.rx_compressed = 0;
1033 pAd->stats.tx_compressed = 0;
1034
1035 return &pAd->stats;
1036 }
1037 else
1038 return NULL;
1039}
1040
diff --git a/drivers/staging/rt2870/rt_profile.c b/drivers/staging/rt2870/rt_profile.c
index 22a0009f61cd..15988c5d9df7 100644
--- a/drivers/staging/rt2870/rt_profile.c
+++ b/drivers/staging/rt2870/rt_profile.c
@@ -1,1893 +1 @@
1/* #include "../rt2860/rt_profile.c"
2 *************************************************************************
3 * Ralink Tech Inc.
4 * 5F., No.36, Taiyuan St., Jhubei City,
5 * Hsinchu County 302,
6 * Taiwan, R.O.C.
7 *
8 * (c) Copyright 2002-2007, Ralink Technology, Inc.
9 *
10 * This program is free software; you can redistribute it and/or modify *
11 * it under the terms of the GNU General Public License as published by *
12 * the Free Software Foundation; either version 2 of the License, or *
13 * (at your option) any later version. *
14 * *
15 * This program is distributed in the hope that it will be useful, *
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
18 * GNU General Public License for more details. *
19 * *
20 * You should have received a copy of the GNU General Public License *
21 * along with this program; if not, write to the *
22 * Free Software Foundation, Inc., *
23 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
24 * *
25 *************************************************************************
26 */
27
28#include "rt_config.h"
29
30static void HTParametersHook(
31 IN PRTMP_ADAPTER pAd,
32 IN CHAR *pValueStr,
33 IN CHAR *pInput);
34
35#define ETH_MAC_ADDR_STR_LEN 17 // in format of xx:xx:xx:xx:xx:xx
36
37// We assume the s1 is a sting, s2 is a memory space with 6 bytes. and content of s1 will be changed.
38BOOLEAN rtstrmactohex(char *s1, char *s2)
39{
40 int i = 0;
41 char *ptokS = s1, *ptokE = s1;
42
43 if (strlen(s1) != ETH_MAC_ADDR_STR_LEN)
44 return FALSE;
45
46 while((*ptokS) != '\0')
47 {
48 if((ptokE = strchr(ptokS, ':')) != NULL)
49 *ptokE++ = '\0';
50 if ((strlen(ptokS) != 2) || (!isxdigit(*ptokS)) || (!isxdigit(*(ptokS+1))))
51 break; // fail
52 AtoH(ptokS, &s2[i++], 1);
53 ptokS = ptokE;
54 if (i == 6)
55 break; // parsing finished
56 }
57
58 return ( i == 6 ? TRUE : FALSE);
59
60}
61
62
63// we assume the s1 and s2 both are strings.
64BOOLEAN rtstrcasecmp(char *s1, char *s2)
65{
66 char *p1 = s1, *p2 = s2;
67
68 if (strlen(s1) != strlen(s2))
69 return FALSE;
70
71 while(*p1 != '\0')
72 {
73 if((*p1 != *p2) && ((*p1 ^ *p2) != 0x20))
74 return FALSE;
75 p1++;
76 p2++;
77 }
78
79 return TRUE;
80}
81
82// we assume the s1 (buffer) and s2 (key) both are strings.
83char * rtstrstruncasecmp(char * s1, char * s2)
84{
85 INT l1, l2, i;
86 char temp1, temp2;
87
88 l2 = strlen(s2);
89 if (!l2)
90 return (char *) s1;
91
92 l1 = strlen(s1);
93
94 while (l1 >= l2)
95 {
96 l1--;
97
98 for(i=0; i<l2; i++)
99 {
100 temp1 = *(s1+i);
101 temp2 = *(s2+i);
102
103 if (('a' <= temp1) && (temp1 <= 'z'))
104 temp1 = 'A'+(temp1-'a');
105 if (('a' <= temp2) && (temp2 <= 'z'))
106 temp2 = 'A'+(temp2-'a');
107
108 if (temp1 != temp2)
109 break;
110 }
111
112 if (i == l2)
113 return (char *) s1;
114
115 s1++;
116 }
117
118 return NULL; // not found
119}
120
121//add by kathy
122
123 /**
124 * strstr - Find the first substring in a %NUL terminated string
125 * @s1: The string to be searched
126 * @s2: The string to search for
127 */
128char * rtstrstr(const char * s1,const char * s2)
129{
130 INT l1, l2;
131
132 l2 = strlen(s2);
133 if (!l2)
134 return (char *) s1;
135
136 l1 = strlen(s1);
137
138 while (l1 >= l2)
139 {
140 l1--;
141 if (!memcmp(s1,s2,l2))
142 return (char *) s1;
143 s1++;
144 }
145
146 return NULL;
147}
148
149/**
150 * rstrtok - Split a string into tokens
151 * @s: The string to be searched
152 * @ct: The characters to search for
153 * * WARNING: strtok is deprecated, use strsep instead. However strsep is not compatible with old architecture.
154 */
155char * __rstrtok;
156char * rstrtok(char * s,const char * ct)
157{
158 char *sbegin, *send;
159
160 sbegin = s ? s : __rstrtok;
161 if (!sbegin)
162 {
163 return NULL;
164 }
165
166 sbegin += strspn(sbegin,ct);
167 if (*sbegin == '\0')
168 {
169 __rstrtok = NULL;
170 return( NULL );
171 }
172
173 send = strpbrk( sbegin, ct);
174 if (send && *send != '\0')
175 *send++ = '\0';
176
177 __rstrtok = send;
178
179 return (sbegin);
180}
181
182/**
183 * delimitcnt - return the count of a given delimiter in a given string.
184 * @s: The string to be searched.
185 * @ct: The delimiter to search for.
186 * Notice : We suppose the delimiter is a single-char string(for example : ";").
187 */
188INT delimitcnt(char * s,const char * ct)
189{
190 INT count = 0;
191 /* point to the beginning of the line */
192 const char *token = s;
193
194 for ( ;; )
195 {
196 token = strpbrk(token, ct); /* search for delimiters */
197
198 if ( token == NULL )
199 {
200 /* advanced to the terminating null character */
201 break;
202 }
203 /* skip the delimiter */
204 ++token;
205
206 /*
207 * Print the found text: use len with %.*s to specify field width.
208 */
209
210 /* accumulate delimiter count */
211 ++count;
212 }
213 return count;
214}
215
216/*
217 * converts the Internet host address from the standard numbers-and-dots notation
218 * into binary data.
219 * returns nonzero if the address is valid, zero if not.
220 */
221int rtinet_aton(const char *cp, unsigned int *addr)
222{
223 unsigned int val;
224 int base, n;
225 char c;
226 unsigned int parts[4];
227 unsigned int *pp = parts;
228
229 for (;;)
230 {
231 /*
232 * Collect number up to ``.''.
233 * Values are specified as for C:
234 * 0x=hex, 0=octal, other=decimal.
235 */
236 val = 0;
237 base = 10;
238 if (*cp == '0')
239 {
240 if (*++cp == 'x' || *cp == 'X')
241 base = 16, cp++;
242 else
243 base = 8;
244 }
245 while ((c = *cp) != '\0')
246 {
247 if (isdigit((unsigned char) c))
248 {
249 val = (val * base) + (c - '0');
250 cp++;
251 continue;
252 }
253 if (base == 16 && isxdigit((unsigned char) c))
254 {
255 val = (val << 4) +
256 (c + 10 - (islower((unsigned char) c) ? 'a' : 'A'));
257 cp++;
258 continue;
259 }
260 break;
261 }
262 if (*cp == '.')
263 {
264 /*
265 * Internet format: a.b.c.d a.b.c (with c treated as 16-bits)
266 * a.b (with b treated as 24 bits)
267 */
268 if (pp >= parts + 3 || val > 0xff)
269 return 0;
270 *pp++ = val, cp++;
271 }
272 else
273 break;
274 }
275
276 /*
277 * Check for trailing junk.
278 */
279 while (*cp)
280 if (!isspace((unsigned char) *cp++))
281 return 0;
282
283 /*
284 * Concoct the address according to the number of parts specified.
285 */
286 n = pp - parts + 1;
287 switch (n)
288 {
289
290 case 1: /* a -- 32 bits */
291 break;
292
293 case 2: /* a.b -- 8.24 bits */
294 if (val > 0xffffff)
295 return 0;
296 val |= parts[0] << 24;
297 break;
298
299 case 3: /* a.b.c -- 8.8.16 bits */
300 if (val > 0xffff)
301 return 0;
302 val |= (parts[0] << 24) | (parts[1] << 16);
303 break;
304
305 case 4: /* a.b.c.d -- 8.8.8.8 bits */
306 if (val > 0xff)
307 return 0;
308 val |= (parts[0] << 24) | (parts[1] << 16) | (parts[2] << 8);
309 break;
310 }
311
312 *addr = htonl(val);
313 return 1;
314
315}
316
317/*
318 ========================================================================
319
320 Routine Description:
321 Find key section for Get key parameter.
322
323 Arguments:
324 buffer Pointer to the buffer to start find the key section
325 section the key of the secion to be find
326
327 Return Value:
328 NULL Fail
329 Others Success
330 ========================================================================
331*/
332PUCHAR RTMPFindSection(
333 IN PCHAR buffer)
334{
335 CHAR temp_buf[32];
336 PUCHAR ptr;
337
338 strcpy(temp_buf, "Default");
339
340 if((ptr = rtstrstr(buffer, temp_buf)) != NULL)
341 return (ptr+strlen("\n"));
342 else
343 return NULL;
344}
345
346/*
347 ========================================================================
348
349 Routine Description:
350 Get key parameter.
351
352 Arguments:
353 key Pointer to key string
354 dest Pointer to destination
355 destsize The datasize of the destination
356 buffer Pointer to the buffer to start find the key
357
358 Return Value:
359 TRUE Success
360 FALSE Fail
361
362 Note:
363 This routine get the value with the matched key (case case-sensitive)
364 ========================================================================
365*/
366INT RTMPGetKeyParameter(
367 IN PCHAR key,
368 OUT PCHAR dest,
369 IN INT destsize,
370 IN PCHAR buffer)
371{
372 UCHAR *temp_buf1 = NULL;
373 UCHAR *temp_buf2 = NULL;
374 CHAR *start_ptr;
375 CHAR *end_ptr;
376 CHAR *ptr;
377 CHAR *offset = 0;
378 INT len;
379
380 //temp_buf1 = kmalloc(MAX_PARAM_BUFFER_SIZE, MEM_ALLOC_FLAG);
381 os_alloc_mem(NULL, &temp_buf1, MAX_PARAM_BUFFER_SIZE);
382
383 if(temp_buf1 == NULL)
384 return (FALSE);
385
386 //temp_buf2 = kmalloc(MAX_PARAM_BUFFER_SIZE, MEM_ALLOC_FLAG);
387 os_alloc_mem(NULL, &temp_buf2, MAX_PARAM_BUFFER_SIZE);
388 if(temp_buf2 == NULL)
389 {
390 os_free_mem(NULL, temp_buf1);
391 return (FALSE);
392 }
393
394 //find section
395 if((offset = RTMPFindSection(buffer)) == NULL)
396 {
397 os_free_mem(NULL, temp_buf1);
398 os_free_mem(NULL, temp_buf2);
399 return (FALSE);
400 }
401
402 strcpy(temp_buf1, "\n");
403 strcat(temp_buf1, key);
404 strcat(temp_buf1, "=");
405
406 //search key
407 if((start_ptr=rtstrstr(offset, temp_buf1))==NULL)
408 {
409 os_free_mem(NULL, temp_buf1);
410 os_free_mem(NULL, temp_buf2);
411 return (FALSE);
412 }
413
414 start_ptr+=strlen("\n");
415 if((end_ptr=rtstrstr(start_ptr, "\n"))==NULL)
416 end_ptr=start_ptr+strlen(start_ptr);
417
418 if (end_ptr<start_ptr)
419 {
420 os_free_mem(NULL, temp_buf1);
421 os_free_mem(NULL, temp_buf2);
422 return (FALSE);
423 }
424
425 NdisMoveMemory(temp_buf2, start_ptr, end_ptr-start_ptr);
426 temp_buf2[end_ptr-start_ptr]='\0';
427 len = strlen(temp_buf2);
428 strcpy(temp_buf1, temp_buf2);
429 if((start_ptr=rtstrstr(temp_buf1, "=")) == NULL)
430 {
431 os_free_mem(NULL, temp_buf1);
432 os_free_mem(NULL, temp_buf2);
433 return (FALSE);
434 }
435
436 strcpy(temp_buf2, start_ptr+1);
437 ptr = temp_buf2;
438 //trim space or tab
439 while(*ptr != 0x00)
440 {
441 if( (*ptr == ' ') || (*ptr == '\t') )
442 ptr++;
443 else
444 break;
445 }
446
447 len = strlen(ptr);
448 memset(dest, 0x00, destsize);
449 strncpy(dest, ptr, len >= destsize ? destsize: len);
450
451 os_free_mem(NULL, temp_buf1);
452 os_free_mem(NULL, temp_buf2);
453 return TRUE;
454}
455
456/*
457 ========================================================================
458
459 Routine Description:
460 Get key parameter.
461
462 Arguments:
463 key Pointer to key string
464 dest Pointer to destination
465 destsize The datasize of the destination
466 buffer Pointer to the buffer to start find the key
467
468 Return Value:
469 TRUE Success
470 FALSE Fail
471
472 Note:
473 This routine get the value with the matched key (case case-sensitive).
474 It is called for parsing SSID and any key string.
475 ========================================================================
476*/
477INT RTMPGetCriticalParameter(
478 IN PCHAR key,
479 OUT PCHAR dest,
480 IN INT destsize,
481 IN PCHAR buffer)
482{
483 UCHAR *temp_buf1 = NULL;
484 UCHAR *temp_buf2 = NULL;
485 CHAR *start_ptr;
486 CHAR *end_ptr;
487 CHAR *ptr;
488 CHAR *offset = 0;
489 INT len;
490
491 //temp_buf1 = kmalloc(MAX_PARAM_BUFFER_SIZE, MEM_ALLOC_FLAG);
492 os_alloc_mem(NULL, &temp_buf1, MAX_PARAM_BUFFER_SIZE);
493
494 if(temp_buf1 == NULL)
495 return (FALSE);
496
497 //temp_buf2 = kmalloc(MAX_PARAM_BUFFER_SIZE, MEM_ALLOC_FLAG);
498 os_alloc_mem(NULL, &temp_buf2, MAX_PARAM_BUFFER_SIZE);
499 if(temp_buf2 == NULL)
500 {
501 os_free_mem(NULL, temp_buf1);
502 return (FALSE);
503 }
504
505 //find section
506 if((offset = RTMPFindSection(buffer)) == NULL)
507 {
508 os_free_mem(NULL, temp_buf1);
509 os_free_mem(NULL, temp_buf2);
510 return (FALSE);
511 }
512
513 strcpy(temp_buf1, "\n");
514 strcat(temp_buf1, key);
515 strcat(temp_buf1, "=");
516
517 //search key
518 if((start_ptr=rtstrstr(offset, temp_buf1))==NULL)
519 {
520 os_free_mem(NULL, temp_buf1);
521 os_free_mem(NULL, temp_buf2);
522 return (FALSE);
523 }
524
525 start_ptr+=strlen("\n");
526 if((end_ptr=rtstrstr(start_ptr, "\n"))==NULL)
527 end_ptr=start_ptr+strlen(start_ptr);
528
529 if (end_ptr<start_ptr)
530 {
531 os_free_mem(NULL, temp_buf1);
532 os_free_mem(NULL, temp_buf2);
533 return (FALSE);
534 }
535
536 NdisMoveMemory(temp_buf2, start_ptr, end_ptr-start_ptr);
537 temp_buf2[end_ptr-start_ptr]='\0';
538 len = strlen(temp_buf2);
539 strcpy(temp_buf1, temp_buf2);
540 if((start_ptr=rtstrstr(temp_buf1, "=")) == NULL)
541 {
542 os_free_mem(NULL, temp_buf1);
543 os_free_mem(NULL, temp_buf2);
544 return (FALSE);
545 }
546
547 strcpy(temp_buf2, start_ptr+1);
548 ptr = temp_buf2;
549
550 //trim tab
551 /* We cannot trim space(' ') for SSID and key string. */
552 while(*ptr != 0x00)
553 {
554 //if( (*ptr == ' ') || (*ptr == '\t') )
555 if( (*ptr == '\t') )
556 ptr++;
557 else
558 break;
559 }
560
561 len = strlen(ptr);
562 memset(dest, 0x00, destsize);
563 strncpy(dest, ptr, len >= destsize ? destsize: len);
564
565 os_free_mem(NULL, temp_buf1);
566 os_free_mem(NULL, temp_buf2);
567 return TRUE;
568}
569
570/*
571 ========================================================================
572
573 Routine Description:
574 Get multiple key parameter.
575
576 Arguments:
577 key Pointer to key string
578 dest Pointer to destination
579 destsize The datasize of the destination
580 buffer Pointer to the buffer to start find the key
581
582 Return Value:
583 TRUE Success
584 FALSE Fail
585
586 Note:
587 This routine get the value with the matched key (case case-sensitive)
588 ========================================================================
589*/
590INT RTMPGetKeyParameterWithOffset(
591 IN PCHAR key,
592 OUT PCHAR dest,
593 OUT USHORT *end_offset,
594 IN INT destsize,
595 IN PCHAR buffer,
596 IN BOOLEAN bTrimSpace)
597{
598 UCHAR *temp_buf1 = NULL;
599 UCHAR *temp_buf2 = NULL;
600 CHAR *start_ptr;
601 CHAR *end_ptr;
602 CHAR *ptr;
603 CHAR *offset = 0;
604 INT len;
605
606 if (*end_offset >= MAX_INI_BUFFER_SIZE)
607 return (FALSE);
608
609 os_alloc_mem(NULL, &temp_buf1, MAX_PARAM_BUFFER_SIZE);
610
611 if(temp_buf1 == NULL)
612 return (FALSE);
613
614 os_alloc_mem(NULL, &temp_buf2, MAX_PARAM_BUFFER_SIZE);
615 if(temp_buf2 == NULL)
616 {
617 os_free_mem(NULL, temp_buf1);
618 return (FALSE);
619 }
620
621 //find section
622 if(*end_offset == 0)
623 {
624 if ((offset = RTMPFindSection(buffer)) == NULL)
625 {
626 os_free_mem(NULL, temp_buf1);
627 os_free_mem(NULL, temp_buf2);
628 return (FALSE);
629 }
630 }
631 else
632 offset = buffer + (*end_offset);
633
634 strcpy(temp_buf1, "\n");
635 strcat(temp_buf1, key);
636 strcat(temp_buf1, "=");
637
638 //search key
639 if((start_ptr=rtstrstr(offset, temp_buf1))==NULL)
640 {
641 os_free_mem(NULL, temp_buf1);
642 os_free_mem(NULL, temp_buf2);
643 return (FALSE);
644 }
645
646 start_ptr+=strlen("\n");
647 if((end_ptr=rtstrstr(start_ptr, "\n"))==NULL)
648 end_ptr=start_ptr+strlen(start_ptr);
649
650 if (end_ptr<start_ptr)
651 {
652 os_free_mem(NULL, temp_buf1);
653 os_free_mem(NULL, temp_buf2);
654 return (FALSE);
655 }
656
657 *end_offset = end_ptr - buffer;
658
659 NdisMoveMemory(temp_buf2, start_ptr, end_ptr-start_ptr);
660 temp_buf2[end_ptr-start_ptr]='\0';
661 len = strlen(temp_buf2);
662 strcpy(temp_buf1, temp_buf2);
663 if((start_ptr=rtstrstr(temp_buf1, "=")) == NULL)
664 {
665 os_free_mem(NULL, temp_buf1);
666 os_free_mem(NULL, temp_buf2);
667 return (FALSE);
668 }
669
670 strcpy(temp_buf2, start_ptr+1);
671 ptr = temp_buf2;
672 //trim space or tab
673 while(*ptr != 0x00)
674 {
675 if((bTrimSpace && (*ptr == ' ')) || (*ptr == '\t') )
676 ptr++;
677 else
678 break;
679 }
680
681 len = strlen(ptr);
682 memset(dest, 0x00, destsize);
683 strncpy(dest, ptr, len >= destsize ? destsize: len);
684
685 os_free_mem(NULL, temp_buf1);
686 os_free_mem(NULL, temp_buf2);
687 return TRUE;
688}
689
690
691static int rtmp_parse_key_buffer_from_file(IN PRTMP_ADAPTER pAd,IN char *buffer,IN ULONG KeyType,IN INT BSSIdx,IN INT KeyIdx)
692{
693 PUCHAR keybuff;
694 INT i = BSSIdx, idx = KeyIdx;
695 ULONG KeyLen;
696 UCHAR CipherAlg = CIPHER_WEP64;
697
698 keybuff = buffer;
699 KeyLen = strlen(keybuff);
700
701 if (KeyType == 1)
702 {//Ascii
703 if( (KeyLen == 5) || (KeyLen == 13))
704 {
705 pAd->SharedKey[i][idx].KeyLen = KeyLen;
706 NdisMoveMemory(pAd->SharedKey[i][idx].Key, keybuff, KeyLen);
707 if (KeyLen == 5)
708 CipherAlg = CIPHER_WEP64;
709 else
710 CipherAlg = CIPHER_WEP128;
711 pAd->SharedKey[i][idx].CipherAlg = CipherAlg;
712
713 DBGPRINT(RT_DEBUG_TRACE, ("I/F(ra%d) Key%dStr=%s and type=%s\n", i, idx+1, keybuff, (KeyType == 0) ? "Hex":"Ascii"));
714 return 1;
715 }
716 else
717 {//Invalid key length
718 DBGPRINT(RT_DEBUG_ERROR, ("Key%dStr is Invalid key length! KeyLen = %ld!\n", idx+1, KeyLen));
719 return 0;
720 }
721 }
722 else
723 {//Hex type
724 if( (KeyLen == 10) || (KeyLen == 26))
725 {
726 pAd->SharedKey[i][idx].KeyLen = KeyLen / 2;
727 AtoH(keybuff, pAd->SharedKey[i][idx].Key, KeyLen / 2);
728 if (KeyLen == 10)
729 CipherAlg = CIPHER_WEP64;
730 else
731 CipherAlg = CIPHER_WEP128;
732 pAd->SharedKey[i][idx].CipherAlg = CipherAlg;
733
734 DBGPRINT(RT_DEBUG_TRACE, ("I/F(ra%d) Key%dStr=%s and type=%s\n", i, idx+1, keybuff, (KeyType == 0) ? "Hex":"Ascii"));
735 return 1;
736 }
737 else
738 {//Invalid key length
739 DBGPRINT(RT_DEBUG_ERROR, ("I/F(ra%d) Key%dStr is Invalid key length! KeyLen = %ld!\n", i, idx+1, KeyLen));
740 return 0;
741 }
742 }
743}
744static void rtmp_read_key_parms_from_file(IN PRTMP_ADAPTER pAd, char *tmpbuf, char *buffer)
745{
746 char tok_str[16];
747 PUCHAR macptr;
748 INT i = 0, idx;
749 ULONG KeyType[MAX_MBSSID_NUM];
750 ULONG KeyIdx;
751
752 NdisZeroMemory(KeyType, MAX_MBSSID_NUM);
753
754 //DefaultKeyID
755 if(RTMPGetKeyParameter("DefaultKeyID", tmpbuf, 25, buffer))
756 {
757 {
758 KeyIdx = simple_strtol(tmpbuf, 0, 10);
759 if((KeyIdx >= 1 ) && (KeyIdx <= 4))
760 pAd->StaCfg.DefaultKeyId = (UCHAR) (KeyIdx - 1);
761 else
762 pAd->StaCfg.DefaultKeyId = 0;
763
764 DBGPRINT(RT_DEBUG_TRACE, ("DefaultKeyID(0~3)=%d\n", pAd->StaCfg.DefaultKeyId));
765 }
766 }
767
768
769 for (idx = 0; idx < 4; idx++)
770 {
771 sprintf(tok_str, "Key%dType", idx + 1);
772 //Key1Type
773 if (RTMPGetKeyParameter(tok_str, tmpbuf, 128, buffer))
774 {
775 for (i = 0, macptr = rstrtok(tmpbuf,";"); macptr; macptr = rstrtok(NULL,";"), i++)
776 {
777 KeyType[i] = simple_strtol(macptr, 0, 10);
778 }
779
780 {
781 sprintf(tok_str, "Key%dStr", idx + 1);
782 if (RTMPGetCriticalParameter(tok_str, tmpbuf, 128, buffer))
783 {
784 rtmp_parse_key_buffer_from_file(pAd, tmpbuf, KeyType[BSS0], BSS0, idx);
785 }
786 }
787 }
788 }
789}
790
791static void rtmp_read_sta_wmm_parms_from_file(IN PRTMP_ADAPTER pAd, char *tmpbuf, char *buffer)
792{
793 PUCHAR macptr;
794 INT i=0;
795 BOOLEAN bWmmEnable = FALSE;
796
797 //WmmCapable
798 if(RTMPGetKeyParameter("WmmCapable", tmpbuf, 32, buffer))
799 {
800 if(simple_strtol(tmpbuf, 0, 10) != 0) //Enable
801 {
802 pAd->CommonCfg.bWmmCapable = TRUE;
803 bWmmEnable = TRUE;
804 }
805 else //Disable
806 {
807 pAd->CommonCfg.bWmmCapable = FALSE;
808 }
809
810 DBGPRINT(RT_DEBUG_TRACE, ("WmmCapable=%d\n", pAd->CommonCfg.bWmmCapable));
811 }
812
813 //AckPolicy for AC_BK, AC_BE, AC_VI, AC_VO
814 if(RTMPGetKeyParameter("AckPolicy", tmpbuf, 32, buffer))
815 {
816 for (i = 0, macptr = rstrtok(tmpbuf,";"); macptr; macptr = rstrtok(NULL,";"), i++)
817 {
818 pAd->CommonCfg.AckPolicy[i] = (UCHAR)simple_strtol(macptr, 0, 10);
819
820 DBGPRINT(RT_DEBUG_TRACE, ("AckPolicy[%d]=%d\n", i, pAd->CommonCfg.AckPolicy[i]));
821 }
822 }
823
824 if (bWmmEnable)
825 {
826 //APSDCapable
827 if(RTMPGetKeyParameter("APSDCapable", tmpbuf, 10, buffer))
828 {
829 if(simple_strtol(tmpbuf, 0, 10) != 0) //Enable
830 pAd->CommonCfg.bAPSDCapable = TRUE;
831 else
832 pAd->CommonCfg.bAPSDCapable = FALSE;
833
834 DBGPRINT(RT_DEBUG_TRACE, ("APSDCapable=%d\n", pAd->CommonCfg.bAPSDCapable));
835 }
836
837 //APSDAC for AC_BE, AC_BK, AC_VI, AC_VO
838 if(RTMPGetKeyParameter("APSDAC", tmpbuf, 32, buffer))
839 {
840 BOOLEAN apsd_ac[4];
841
842 for (i = 0, macptr = rstrtok(tmpbuf,";"); macptr; macptr = rstrtok(NULL,";"), i++)
843 {
844 apsd_ac[i] = (BOOLEAN)simple_strtol(macptr, 0, 10);
845
846 DBGPRINT(RT_DEBUG_TRACE, ("APSDAC%d %d\n", i, apsd_ac[i]));
847 }
848
849 pAd->CommonCfg.bAPSDAC_BE = apsd_ac[0];
850 pAd->CommonCfg.bAPSDAC_BK = apsd_ac[1];
851 pAd->CommonCfg.bAPSDAC_VI = apsd_ac[2];
852 pAd->CommonCfg.bAPSDAC_VO = apsd_ac[3];
853 }
854 }
855
856}
857
858NDIS_STATUS RTMPReadParametersHook(
859 IN PRTMP_ADAPTER pAd)
860{
861 PUCHAR src = NULL;
862 struct file *srcf;
863 INT retval, orgfsuid, orgfsgid;
864 mm_segment_t orgfs;
865 CHAR *buffer;
866 CHAR *tmpbuf;
867 ULONG RtsThresh;
868 ULONG FragThresh;
869 UCHAR keyMaterial[40];
870
871 PUCHAR macptr;
872 INT i = 0;
873
874 buffer = kmalloc(MAX_INI_BUFFER_SIZE, MEM_ALLOC_FLAG);
875 if(buffer == NULL)
876 return NDIS_STATUS_FAILURE;
877
878 tmpbuf = kmalloc(MAX_PARAM_BUFFER_SIZE, MEM_ALLOC_FLAG);
879 if(tmpbuf == NULL)
880 {
881 kfree(buffer);
882 return NDIS_STATUS_FAILURE;
883 }
884
885 src = STA_PROFILE_PATH;
886
887 // Save uid and gid used for filesystem access.
888 // Set user and group to 0 (root)
889#ifndef RT30xx
890 orgfsuid = current_fsuid();
891 orgfsgid = current_fsgid();
892 /* Hm, can't really do this nicely anymore, so rely on these files
893 * being set to the proper permission to read them... */
894 /* current->cred->fsuid = current->cred->fsgid = 0; */
895#endif
896 orgfs = get_fs();
897 set_fs(KERNEL_DS);
898
899 if (src && *src)
900 {
901 srcf = filp_open(src, O_RDONLY, 0);
902 if (IS_ERR(srcf))
903 {
904 DBGPRINT(RT_DEBUG_ERROR, ("--> Error %ld opening %s\n", -PTR_ERR(srcf),src));
905 }
906 else
907 {
908 // The object must have a read method
909 if (srcf->f_op && srcf->f_op->read)
910 {
911 memset(buffer, 0x00, MAX_INI_BUFFER_SIZE);
912 retval=srcf->f_op->read(srcf, buffer, MAX_INI_BUFFER_SIZE, &srcf->f_pos);
913 if (retval < 0)
914 {
915 DBGPRINT(RT_DEBUG_TRACE, ("--> Read %s error %d\n", src, -retval));
916 }
917 else
918 {
919 // set file parameter to portcfg
920 //CountryRegion
921 if(RTMPGetKeyParameter("CountryRegion", tmpbuf, 25, buffer))
922 {
923 pAd->CommonCfg.CountryRegion = (UCHAR) simple_strtol(tmpbuf, 0, 10);
924 DBGPRINT(RT_DEBUG_TRACE, ("CountryRegion=%d\n", pAd->CommonCfg.CountryRegion));
925 }
926 //CountryRegionABand
927 if(RTMPGetKeyParameter("CountryRegionABand", tmpbuf, 25, buffer))
928 {
929 pAd->CommonCfg.CountryRegionForABand= (UCHAR) simple_strtol(tmpbuf, 0, 10);
930 DBGPRINT(RT_DEBUG_TRACE, ("CountryRegionABand=%d\n", pAd->CommonCfg.CountryRegionForABand));
931 }
932 //CountryCode
933 if(RTMPGetKeyParameter("CountryCode", tmpbuf, 25, buffer))
934 {
935 NdisMoveMemory(pAd->CommonCfg.CountryCode, tmpbuf , 2);
936
937 if (strlen(pAd->CommonCfg.CountryCode) != 0)
938 {
939 pAd->CommonCfg.bCountryFlag = TRUE;
940 }
941 DBGPRINT(RT_DEBUG_TRACE, ("CountryCode=%s\n", pAd->CommonCfg.CountryCode));
942 }
943 //ChannelGeography
944 if(RTMPGetKeyParameter("ChannelGeography", tmpbuf, 25, buffer))
945 {
946 UCHAR Geography = (UCHAR) simple_strtol(tmpbuf, 0, 10);
947 if (Geography <= BOTH)
948 {
949 pAd->CommonCfg.Geography = Geography;
950 pAd->CommonCfg.CountryCode[2] =
951 (pAd->CommonCfg.Geography == BOTH) ? ' ' : ((pAd->CommonCfg.Geography == IDOR) ? 'I' : 'O');
952 DBGPRINT(RT_DEBUG_TRACE, ("ChannelGeography=%d\n", pAd->CommonCfg.Geography));
953 }
954 }
955 else
956 {
957 pAd->CommonCfg.Geography = BOTH;
958 pAd->CommonCfg.CountryCode[2] = ' ';
959 }
960
961 {
962 //SSID
963 if (RTMPGetCriticalParameter("SSID", tmpbuf, 256, buffer))
964 {
965 if (strlen(tmpbuf) <= 32)
966 {
967 pAd->CommonCfg.SsidLen = (UCHAR) strlen(tmpbuf);
968 NdisZeroMemory(pAd->CommonCfg.Ssid, NDIS_802_11_LENGTH_SSID);
969 NdisMoveMemory(pAd->CommonCfg.Ssid, tmpbuf, pAd->CommonCfg.SsidLen);
970 pAd->MlmeAux.AutoReconnectSsidLen = pAd->CommonCfg.SsidLen;
971 NdisZeroMemory(pAd->MlmeAux.AutoReconnectSsid, NDIS_802_11_LENGTH_SSID);
972 NdisMoveMemory(pAd->MlmeAux.AutoReconnectSsid, tmpbuf, pAd->MlmeAux.AutoReconnectSsidLen);
973 pAd->MlmeAux.SsidLen = pAd->CommonCfg.SsidLen;
974 NdisZeroMemory(pAd->MlmeAux.Ssid, NDIS_802_11_LENGTH_SSID);
975 NdisMoveMemory(pAd->MlmeAux.Ssid, tmpbuf, pAd->MlmeAux.SsidLen);
976 DBGPRINT(RT_DEBUG_TRACE, ("%s::(SSID=%s)\n", __func__, tmpbuf));
977 }
978 }
979 }
980
981 {
982 //NetworkType
983 if (RTMPGetKeyParameter("NetworkType", tmpbuf, 25, buffer))
984 {
985 pAd->bConfigChanged = TRUE;
986 if (strcmp(tmpbuf, "Adhoc") == 0)
987 pAd->StaCfg.BssType = BSS_ADHOC;
988 else //Default Infrastructure mode
989 pAd->StaCfg.BssType = BSS_INFRA;
990 // Reset Ralink supplicant to not use, it will be set to start when UI set PMK key
991 pAd->StaCfg.WpaState = SS_NOTUSE;
992 DBGPRINT(RT_DEBUG_TRACE, ("%s::(NetworkType=%d)\n", __func__, pAd->StaCfg.BssType));
993 }
994 }
995
996 //Channel
997 if(RTMPGetKeyParameter("Channel", tmpbuf, 10, buffer))
998 {
999 pAd->CommonCfg.Channel = (UCHAR) simple_strtol(tmpbuf, 0, 10);
1000 DBGPRINT(RT_DEBUG_TRACE, ("Channel=%d\n", pAd->CommonCfg.Channel));
1001 }
1002 //WirelessMode
1003 if(RTMPGetKeyParameter("WirelessMode", tmpbuf, 10, buffer))
1004 {
1005 int value = 0, maxPhyMode = PHY_11G;
1006
1007 maxPhyMode = PHY_11N_5G;
1008
1009 value = simple_strtol(tmpbuf, 0, 10);
1010
1011 if (value <= maxPhyMode)
1012 {
1013 pAd->CommonCfg.PhyMode = value;
1014 }
1015 DBGPRINT(RT_DEBUG_TRACE, ("PhyMode=%d\n", pAd->CommonCfg.PhyMode));
1016 }
1017 //BasicRate
1018 if(RTMPGetKeyParameter("BasicRate", tmpbuf, 10, buffer))
1019 {
1020 pAd->CommonCfg.BasicRateBitmap = (ULONG) simple_strtol(tmpbuf, 0, 10);
1021 DBGPRINT(RT_DEBUG_TRACE, ("BasicRate=%ld\n", pAd->CommonCfg.BasicRateBitmap));
1022 }
1023 //BeaconPeriod
1024 if(RTMPGetKeyParameter("BeaconPeriod", tmpbuf, 10, buffer))
1025 {
1026 pAd->CommonCfg.BeaconPeriod = (USHORT) simple_strtol(tmpbuf, 0, 10);
1027 DBGPRINT(RT_DEBUG_TRACE, ("BeaconPeriod=%d\n", pAd->CommonCfg.BeaconPeriod));
1028 }
1029 //TxPower
1030 if(RTMPGetKeyParameter("TxPower", tmpbuf, 10, buffer))
1031 {
1032 pAd->CommonCfg.TxPowerPercentage = (ULONG) simple_strtol(tmpbuf, 0, 10);
1033
1034 pAd->CommonCfg.TxPowerDefault = pAd->CommonCfg.TxPowerPercentage;
1035
1036 DBGPRINT(RT_DEBUG_TRACE, ("TxPower=%ld\n", pAd->CommonCfg.TxPowerPercentage));
1037 }
1038 //BGProtection
1039 if(RTMPGetKeyParameter("BGProtection", tmpbuf, 10, buffer))
1040 {
1041 switch (simple_strtol(tmpbuf, 0, 10))
1042 {
1043 case 1: //Always On
1044 pAd->CommonCfg.UseBGProtection = 1;
1045 break;
1046 case 2: //Always OFF
1047 pAd->CommonCfg.UseBGProtection = 2;
1048 break;
1049 case 0: //AUTO
1050 default:
1051 pAd->CommonCfg.UseBGProtection = 0;
1052 break;
1053 }
1054 DBGPRINT(RT_DEBUG_TRACE, ("BGProtection=%ld\n", pAd->CommonCfg.UseBGProtection));
1055 }
1056 //OLBCDetection
1057 if(RTMPGetKeyParameter("DisableOLBC", tmpbuf, 10, buffer))
1058 {
1059 switch (simple_strtol(tmpbuf, 0, 10))
1060 {
1061 case 1: //disable OLBC Detection
1062 pAd->CommonCfg.DisableOLBCDetect = 1;
1063 break;
1064 case 0: //enable OLBC Detection
1065 pAd->CommonCfg.DisableOLBCDetect = 0;
1066 break;
1067 default:
1068 pAd->CommonCfg.DisableOLBCDetect= 0;
1069 break;
1070 }
1071 DBGPRINT(RT_DEBUG_TRACE, ("OLBCDetection=%ld\n", pAd->CommonCfg.DisableOLBCDetect));
1072 }
1073 //TxPreamble
1074 if(RTMPGetKeyParameter("TxPreamble", tmpbuf, 10, buffer))
1075 {
1076 switch (simple_strtol(tmpbuf, 0, 10))
1077 {
1078 case Rt802_11PreambleShort:
1079 pAd->CommonCfg.TxPreamble = Rt802_11PreambleShort;
1080 break;
1081 case Rt802_11PreambleLong:
1082 default:
1083 pAd->CommonCfg.TxPreamble = Rt802_11PreambleLong;
1084 break;
1085 }
1086 DBGPRINT(RT_DEBUG_TRACE, ("TxPreamble=%ld\n", pAd->CommonCfg.TxPreamble));
1087 }
1088 //RTSThreshold
1089 if(RTMPGetKeyParameter("RTSThreshold", tmpbuf, 10, buffer))
1090 {
1091 RtsThresh = simple_strtol(tmpbuf, 0, 10);
1092 if( (RtsThresh >= 1) && (RtsThresh <= MAX_RTS_THRESHOLD) )
1093 pAd->CommonCfg.RtsThreshold = (USHORT)RtsThresh;
1094 else
1095 pAd->CommonCfg.RtsThreshold = MAX_RTS_THRESHOLD;
1096
1097 DBGPRINT(RT_DEBUG_TRACE, ("RTSThreshold=%d\n", pAd->CommonCfg.RtsThreshold));
1098 }
1099 //FragThreshold
1100 if(RTMPGetKeyParameter("FragThreshold", tmpbuf, 10, buffer))
1101 {
1102 FragThresh = simple_strtol(tmpbuf, 0, 10);
1103 pAd->CommonCfg.bUseZeroToDisableFragment = FALSE;
1104
1105 if (FragThresh > MAX_FRAG_THRESHOLD || FragThresh < MIN_FRAG_THRESHOLD)
1106 { //illegal FragThresh so we set it to default
1107 pAd->CommonCfg.FragmentThreshold = MAX_FRAG_THRESHOLD;
1108 pAd->CommonCfg.bUseZeroToDisableFragment = TRUE;
1109 }
1110 else if (FragThresh % 2 == 1)
1111 {
1112 // The length of each fragment shall always be an even number of octets, except for the last fragment
1113 // of an MSDU or MMPDU, which may be either an even or an odd number of octets.
1114 pAd->CommonCfg.FragmentThreshold = (USHORT)(FragThresh - 1);
1115 }
1116 else
1117 {
1118 pAd->CommonCfg.FragmentThreshold = (USHORT)FragThresh;
1119 }
1120 //pAd->CommonCfg.AllowFragSize = (pAd->CommonCfg.FragmentThreshold) - LENGTH_802_11 - LENGTH_CRC;
1121 DBGPRINT(RT_DEBUG_TRACE, ("FragThreshold=%d\n", pAd->CommonCfg.FragmentThreshold));
1122 }
1123 //TxBurst
1124 if(RTMPGetKeyParameter("TxBurst", tmpbuf, 10, buffer))
1125 {
1126 if(simple_strtol(tmpbuf, 0, 10) != 0) //Enable
1127 pAd->CommonCfg.bEnableTxBurst = TRUE;
1128 else //Disable
1129 pAd->CommonCfg.bEnableTxBurst = FALSE;
1130 DBGPRINT(RT_DEBUG_TRACE, ("TxBurst=%d\n", pAd->CommonCfg.bEnableTxBurst));
1131 }
1132
1133#ifdef AGGREGATION_SUPPORT
1134 //PktAggregate
1135 if(RTMPGetKeyParameter("PktAggregate", tmpbuf, 10, buffer))
1136 {
1137 if(simple_strtol(tmpbuf, 0, 10) != 0) //Enable
1138 pAd->CommonCfg.bAggregationCapable = TRUE;
1139 else //Disable
1140 pAd->CommonCfg.bAggregationCapable = FALSE;
1141#ifdef PIGGYBACK_SUPPORT
1142 pAd->CommonCfg.bPiggyBackCapable = pAd->CommonCfg.bAggregationCapable;
1143#endif // PIGGYBACK_SUPPORT //
1144 DBGPRINT(RT_DEBUG_TRACE, ("PktAggregate=%d\n", pAd->CommonCfg.bAggregationCapable));
1145 }
1146#else
1147 pAd->CommonCfg.bAggregationCapable = FALSE;
1148 pAd->CommonCfg.bPiggyBackCapable = FALSE;
1149#endif // AGGREGATION_SUPPORT //
1150
1151 // WmmCapable
1152 rtmp_read_sta_wmm_parms_from_file(pAd, tmpbuf, buffer);
1153
1154 //ShortSlot
1155 if(RTMPGetKeyParameter("ShortSlot", tmpbuf, 10, buffer))
1156 {
1157 if(simple_strtol(tmpbuf, 0, 10) != 0) //Enable
1158 pAd->CommonCfg.bUseShortSlotTime = TRUE;
1159 else //Disable
1160 pAd->CommonCfg.bUseShortSlotTime = FALSE;
1161
1162 DBGPRINT(RT_DEBUG_TRACE, ("ShortSlot=%d\n", pAd->CommonCfg.bUseShortSlotTime));
1163 }
1164 //IEEE80211H
1165 if(RTMPGetKeyParameter("IEEE80211H", tmpbuf, 10, buffer))
1166 {
1167 for (i = 0, macptr = rstrtok(tmpbuf,";"); macptr; macptr = rstrtok(NULL,";"), i++)
1168 {
1169 if(simple_strtol(macptr, 0, 10) != 0) //Enable
1170 pAd->CommonCfg.bIEEE80211H = TRUE;
1171 else //Disable
1172 pAd->CommonCfg.bIEEE80211H = FALSE;
1173
1174 DBGPRINT(RT_DEBUG_TRACE, ("IEEE80211H=%d\n", pAd->CommonCfg.bIEEE80211H));
1175 }
1176 }
1177 //CSPeriod
1178 if(RTMPGetKeyParameter("CSPeriod", tmpbuf, 10, buffer))
1179 {
1180 if(simple_strtol(tmpbuf, 0, 10) != 0)
1181 pAd->CommonCfg.RadarDetect.CSPeriod = simple_strtol(tmpbuf, 0, 10);
1182 else
1183 pAd->CommonCfg.RadarDetect.CSPeriod = 0;
1184
1185 DBGPRINT(RT_DEBUG_TRACE, ("CSPeriod=%d\n", pAd->CommonCfg.RadarDetect.CSPeriod));
1186 }
1187
1188 //RDRegion
1189 if(RTMPGetKeyParameter("RDRegion", tmpbuf, 128, buffer))
1190 {
1191 if ((strncmp(tmpbuf, "JAP_W53", 7) == 0) || (strncmp(tmpbuf, "jap_w53", 7) == 0))
1192 {
1193 pAd->CommonCfg.RadarDetect.RDDurRegion = JAP_W53;
1194 pAd->CommonCfg.RadarDetect.DfsSessionTime = 15;
1195 }
1196 else if ((strncmp(tmpbuf, "JAP_W56", 7) == 0) || (strncmp(tmpbuf, "jap_w56", 7) == 0))
1197 {
1198 pAd->CommonCfg.RadarDetect.RDDurRegion = JAP_W56;
1199 pAd->CommonCfg.RadarDetect.DfsSessionTime = 13;
1200 }
1201 else if ((strncmp(tmpbuf, "JAP", 3) == 0) || (strncmp(tmpbuf, "jap", 3) == 0))
1202 {
1203 pAd->CommonCfg.RadarDetect.RDDurRegion = JAP;
1204 pAd->CommonCfg.RadarDetect.DfsSessionTime = 5;
1205 }
1206 else if ((strncmp(tmpbuf, "FCC", 3) == 0) || (strncmp(tmpbuf, "fcc", 3) == 0))
1207 {
1208 pAd->CommonCfg.RadarDetect.RDDurRegion = FCC;
1209 pAd->CommonCfg.RadarDetect.DfsSessionTime = 5;
1210 }
1211 else if ((strncmp(tmpbuf, "CE", 2) == 0) || (strncmp(tmpbuf, "ce", 2) == 0))
1212 {
1213 pAd->CommonCfg.RadarDetect.RDDurRegion = CE;
1214 pAd->CommonCfg.RadarDetect.DfsSessionTime = 13;
1215 }
1216 else
1217 {
1218 pAd->CommonCfg.RadarDetect.RDDurRegion = CE;
1219 pAd->CommonCfg.RadarDetect.DfsSessionTime = 13;
1220 }
1221
1222 DBGPRINT(RT_DEBUG_TRACE, ("RDRegion=%d\n", pAd->CommonCfg.RadarDetect.RDDurRegion));
1223 }
1224 else
1225 {
1226 pAd->CommonCfg.RadarDetect.RDDurRegion = CE;
1227 pAd->CommonCfg.RadarDetect.DfsSessionTime = 13;
1228 }
1229
1230 //WirelessEvent
1231 if(RTMPGetKeyParameter("WirelessEvent", tmpbuf, 10, buffer))
1232 {
1233#if WIRELESS_EXT >= 15
1234 if(simple_strtol(tmpbuf, 0, 10) != 0)
1235 pAd->CommonCfg.bWirelessEvent = simple_strtol(tmpbuf, 0, 10);
1236 else
1237 pAd->CommonCfg.bWirelessEvent = 0; // disable
1238#else
1239 pAd->CommonCfg.bWirelessEvent = 0; // disable
1240#endif
1241 DBGPRINT(RT_DEBUG_TRACE, ("WirelessEvent=%d\n", pAd->CommonCfg.bWirelessEvent));
1242 }
1243 if(RTMPGetKeyParameter("WiFiTest", tmpbuf, 10, buffer))
1244 {
1245 if(simple_strtol(tmpbuf, 0, 10) != 0)
1246 pAd->CommonCfg.bWiFiTest= simple_strtol(tmpbuf, 0, 10);
1247 else
1248 pAd->CommonCfg.bWiFiTest = 0; // disable
1249
1250 DBGPRINT(RT_DEBUG_TRACE, ("WiFiTest=%d\n", pAd->CommonCfg.bWiFiTest));
1251 }
1252 //AuthMode
1253 if(RTMPGetKeyParameter("AuthMode", tmpbuf, 128, buffer))
1254 {
1255 {
1256 if ((strcmp(tmpbuf, "WEPAUTO") == 0) || (strcmp(tmpbuf, "wepauto") == 0))
1257 pAd->StaCfg.AuthMode = Ndis802_11AuthModeAutoSwitch;
1258 else if ((strcmp(tmpbuf, "SHARED") == 0) || (strcmp(tmpbuf, "shared") == 0))
1259 pAd->StaCfg.AuthMode = Ndis802_11AuthModeShared;
1260 else if ((strcmp(tmpbuf, "WPAPSK") == 0) || (strcmp(tmpbuf, "wpapsk") == 0))
1261 pAd->StaCfg.AuthMode = Ndis802_11AuthModeWPAPSK;
1262 else if ((strcmp(tmpbuf, "WPANONE") == 0) || (strcmp(tmpbuf, "wpanone") == 0))
1263 pAd->StaCfg.AuthMode = Ndis802_11AuthModeWPANone;
1264 else if ((strcmp(tmpbuf, "WPA2PSK") == 0) || (strcmp(tmpbuf, "wpa2psk") == 0))
1265 pAd->StaCfg.AuthMode = Ndis802_11AuthModeWPA2PSK;
1266 else if ((strcmp(tmpbuf, "WPA") == 0) || (strcmp(tmpbuf, "wpa") == 0))
1267 pAd->StaCfg.AuthMode = Ndis802_11AuthModeWPA;
1268 else if ((strcmp(tmpbuf, "WPA2") == 0) || (strcmp(tmpbuf, "wpa2") == 0))
1269 pAd->StaCfg.AuthMode = Ndis802_11AuthModeWPA2;
1270 else
1271 pAd->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
1272
1273 pAd->StaCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED;
1274
1275 DBGPRINT(RT_DEBUG_TRACE, ("%s::(EncrypType=%d)\n", __func__, pAd->StaCfg.WepStatus));
1276 }
1277 }
1278 //EncrypType
1279 if(RTMPGetKeyParameter("EncrypType", tmpbuf, 128, buffer))
1280 {
1281 {
1282 if ((strcmp(tmpbuf, "WEP") == 0) || (strcmp(tmpbuf, "wep") == 0))
1283 pAd->StaCfg.WepStatus = Ndis802_11WEPEnabled;
1284 else if ((strcmp(tmpbuf, "TKIP") == 0) || (strcmp(tmpbuf, "tkip") == 0))
1285 pAd->StaCfg.WepStatus = Ndis802_11Encryption2Enabled;
1286 else if ((strcmp(tmpbuf, "AES") == 0) || (strcmp(tmpbuf, "aes") == 0))
1287 pAd->StaCfg.WepStatus = Ndis802_11Encryption3Enabled;
1288 else
1289 pAd->StaCfg.WepStatus = Ndis802_11WEPDisabled;
1290
1291 // Update all wepstatus related
1292 pAd->StaCfg.PairCipher = pAd->StaCfg.WepStatus;
1293 pAd->StaCfg.GroupCipher = pAd->StaCfg.WepStatus;
1294 pAd->StaCfg.OrigWepStatus = pAd->StaCfg.WepStatus;
1295 pAd->StaCfg.bMixCipher = FALSE;
1296
1297 DBGPRINT(RT_DEBUG_TRACE, ("%s::(EncrypType=%d)\n", __func__, pAd->StaCfg.WepStatus));
1298 }
1299 }
1300
1301 {
1302 if(RTMPGetCriticalParameter("WPAPSK", tmpbuf, 512, buffer))
1303 {
1304 int err=0;
1305
1306 tmpbuf[strlen(tmpbuf)] = '\0'; // make STA can process .$^& for WPAPSK input
1307
1308 if ((pAd->StaCfg.AuthMode != Ndis802_11AuthModeWPAPSK) &&
1309 (pAd->StaCfg.AuthMode != Ndis802_11AuthModeWPA2PSK) &&
1310 (pAd->StaCfg.AuthMode != Ndis802_11AuthModeWPANone)
1311 )
1312 {
1313 err = 1;
1314 }
1315 else if ((strlen(tmpbuf) >= 8) && (strlen(tmpbuf) < 64))
1316 {
1317 PasswordHash((char *)tmpbuf, pAd->CommonCfg.Ssid, pAd->CommonCfg.SsidLen, keyMaterial);
1318 NdisMoveMemory(pAd->StaCfg.PMK, keyMaterial, 32);
1319
1320 }
1321 else if (strlen(tmpbuf) == 64)
1322 {
1323 AtoH(tmpbuf, keyMaterial, 32);
1324 NdisMoveMemory(pAd->StaCfg.PMK, keyMaterial, 32);
1325 }
1326 else
1327 {
1328 err = 1;
1329 DBGPRINT(RT_DEBUG_ERROR, ("%s::(WPAPSK key-string required 8 ~ 64 characters!)\n", __func__));
1330 }
1331
1332 if (err == 0)
1333 {
1334 if ((pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK) ||
1335 (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK))
1336 {
1337 // Start STA supplicant state machine
1338 pAd->StaCfg.WpaState = SS_START;
1339 }
1340 else if (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPANone)
1341 {
1342 pAd->StaCfg.WpaState = SS_NOTUSE;
1343 }
1344
1345 DBGPRINT(RT_DEBUG_TRACE, ("%s::(WPAPSK=%s)\n", __func__, tmpbuf));
1346 }
1347 }
1348 }
1349
1350 //DefaultKeyID, KeyType, KeyStr
1351 rtmp_read_key_parms_from_file(pAd, tmpbuf, buffer);
1352
1353 HTParametersHook(pAd, tmpbuf, buffer);
1354
1355 {
1356 //PSMode
1357 if (RTMPGetKeyParameter("PSMode", tmpbuf, 10, buffer))
1358 {
1359 if (pAd->StaCfg.BssType == BSS_INFRA)
1360 {
1361 if ((strcmp(tmpbuf, "MAX_PSP") == 0) || (strcmp(tmpbuf, "max_psp") == 0))
1362 {
1363 // do NOT turn on PSM bit here, wait until MlmeCheckForPsmChange()
1364 // to exclude certain situations.
1365 // MlmeSetPsm(pAd, PWR_SAVE);
1366 OPSTATUS_SET_FLAG(pAd, fOP_STATUS_RECEIVE_DTIM);
1367 if (pAd->StaCfg.bWindowsACCAMEnable == FALSE)
1368 pAd->StaCfg.WindowsPowerMode = Ndis802_11PowerModeMAX_PSP;
1369 pAd->StaCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeMAX_PSP;
1370 pAd->StaCfg.DefaultListenCount = 5;
1371 }
1372 else if ((strcmp(tmpbuf, "Fast_PSP") == 0) || (strcmp(tmpbuf, "fast_psp") == 0)
1373 || (strcmp(tmpbuf, "FAST_PSP") == 0))
1374 {
1375 // do NOT turn on PSM bit here, wait until MlmeCheckForPsmChange()
1376 // to exclude certain situations.
1377 // MlmeSetPsmBit(pAd, PWR_SAVE);
1378 OPSTATUS_SET_FLAG(pAd, fOP_STATUS_RECEIVE_DTIM);
1379 if (pAd->StaCfg.bWindowsACCAMEnable == FALSE)
1380 pAd->StaCfg.WindowsPowerMode = Ndis802_11PowerModeFast_PSP;
1381 pAd->StaCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeFast_PSP;
1382 pAd->StaCfg.DefaultListenCount = 3;
1383 }
1384 else if ((strcmp(tmpbuf, "Legacy_PSP") == 0) || (strcmp(tmpbuf, "legacy_psp") == 0)
1385 || (strcmp(tmpbuf, "LEGACY_PSP") == 0))
1386 {
1387 // do NOT turn on PSM bit here, wait until MlmeCheckForPsmChange()
1388 // to exclude certain situations.
1389 // MlmeSetPsmBit(pAd, PWR_SAVE);
1390 OPSTATUS_SET_FLAG(pAd, fOP_STATUS_RECEIVE_DTIM);
1391 if (pAd->StaCfg.bWindowsACCAMEnable == FALSE)
1392 pAd->StaCfg.WindowsPowerMode = Ndis802_11PowerModeLegacy_PSP;
1393 pAd->StaCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeLegacy_PSP;
1394 pAd->StaCfg.DefaultListenCount = 3;
1395 }
1396 else
1397 { //Default Ndis802_11PowerModeCAM
1398 // clear PSM bit immediately
1399 MlmeSetPsmBit(pAd, PWR_ACTIVE);
1400 OPSTATUS_SET_FLAG(pAd, fOP_STATUS_RECEIVE_DTIM);
1401 if (pAd->StaCfg.bWindowsACCAMEnable == FALSE)
1402 pAd->StaCfg.WindowsPowerMode = Ndis802_11PowerModeCAM;
1403 pAd->StaCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeCAM;
1404 }
1405 DBGPRINT(RT_DEBUG_TRACE, ("PSMode=%ld\n", pAd->StaCfg.WindowsPowerMode));
1406 }
1407 }
1408 // FastRoaming
1409 if (RTMPGetKeyParameter("FastRoaming", tmpbuf, 32, buffer))
1410 {
1411 if (simple_strtol(tmpbuf, 0, 10) == 0)
1412 pAd->StaCfg.bFastRoaming = FALSE;
1413 else
1414 pAd->StaCfg.bFastRoaming = TRUE;
1415
1416 DBGPRINT(RT_DEBUG_TRACE, ("FastRoaming=%d\n", pAd->StaCfg.bFastRoaming));
1417 }
1418 // RoamThreshold
1419 if (RTMPGetKeyParameter("RoamThreshold", tmpbuf, 32, buffer))
1420 {
1421 long lInfo = simple_strtol(tmpbuf, 0, 10);
1422
1423 if (lInfo > 90 || lInfo < 60)
1424 pAd->StaCfg.dBmToRoam = -70;
1425 else
1426 pAd->StaCfg.dBmToRoam = (CHAR)(-1)*lInfo;
1427
1428 DBGPRINT(RT_DEBUG_TRACE, ("RoamThreshold=%d dBm\n", pAd->StaCfg.dBmToRoam));
1429 }
1430
1431 if(RTMPGetKeyParameter("TGnWifiTest", tmpbuf, 10, buffer))
1432 {
1433 if(simple_strtol(tmpbuf, 0, 10) == 0)
1434 pAd->StaCfg.bTGnWifiTest = FALSE;
1435 else
1436 pAd->StaCfg.bTGnWifiTest = TRUE;
1437 DBGPRINT(RT_DEBUG_TRACE, ("TGnWifiTest=%d\n", pAd->StaCfg.bTGnWifiTest));
1438 }
1439 }
1440
1441#ifdef RT30xx
1442 {
1443 if(RTMPGetKeyParameter("AntDiversity", tmpbuf, 10, buffer))
1444 {
1445 for (i = 0, macptr = rstrtok(tmpbuf,";"); macptr; macptr = rstrtok(NULL,";"), i++)
1446 {
1447 if(simple_strtol(macptr, 0, 10) != 0) //Enable
1448 pAd->CommonCfg.bRxAntDiversity = TRUE;
1449 else //Disable
1450 pAd->CommonCfg.bRxAntDiversity = FALSE;
1451
1452 DBGPRINT(RT_DEBUG_ERROR, ("AntDiversity=%d\n", pAd->CommonCfg.bRxAntDiversity));
1453 }
1454 }
1455 }
1456#endif // RT30xx //
1457 }
1458 }
1459 else
1460 {
1461 DBGPRINT(RT_DEBUG_TRACE, ("--> %s does not have a write method\n", src));
1462 }
1463
1464 retval=filp_close(srcf,NULL);
1465
1466 if (retval)
1467 {
1468 DBGPRINT(RT_DEBUG_TRACE, ("--> Error %d closing %s\n", -retval, src));
1469 }
1470 }
1471 }
1472
1473 set_fs(orgfs);
1474
1475 kfree(buffer);
1476 kfree(tmpbuf);
1477
1478 return (NDIS_STATUS_SUCCESS);
1479}
1480
1481static void HTParametersHook(
1482 IN PRTMP_ADAPTER pAd,
1483 IN CHAR *pValueStr,
1484 IN CHAR *pInput)
1485{
1486
1487 INT Value;
1488
1489 if (RTMPGetKeyParameter("HT_PROTECT", pValueStr, 25, pInput))
1490 {
1491 Value = simple_strtol(pValueStr, 0, 10);
1492 if (Value == 0)
1493 {
1494 pAd->CommonCfg.bHTProtect = FALSE;
1495 }
1496 else
1497 {
1498 pAd->CommonCfg.bHTProtect = TRUE;
1499 }
1500 DBGPRINT(RT_DEBUG_TRACE, ("HT: Protection = %s\n", (Value==0) ? "Disable" : "Enable"));
1501 }
1502
1503 if (RTMPGetKeyParameter("HT_MIMOPSEnable", pValueStr, 25, pInput))
1504 {
1505 Value = simple_strtol(pValueStr, 0, 10);
1506 if (Value == 0)
1507 {
1508 pAd->CommonCfg.bMIMOPSEnable = FALSE;
1509 }
1510 else
1511 {
1512 pAd->CommonCfg.bMIMOPSEnable = TRUE;
1513 }
1514 DBGPRINT(RT_DEBUG_TRACE, ("HT: MIMOPSEnable = %s\n", (Value==0) ? "Disable" : "Enable"));
1515 }
1516
1517
1518 if (RTMPGetKeyParameter("HT_MIMOPSMode", pValueStr, 25, pInput))
1519 {
1520 Value = simple_strtol(pValueStr, 0, 10);
1521 if (Value > MMPS_ENABLE)
1522 {
1523 pAd->CommonCfg.BACapability.field.MMPSmode = MMPS_ENABLE;
1524 }
1525 else
1526 {
1527 //TODO: add mimo power saving mechanism
1528 pAd->CommonCfg.BACapability.field.MMPSmode = MMPS_ENABLE;
1529 //pAd->CommonCfg.BACapability.field.MMPSmode = Value;
1530 }
1531 DBGPRINT(RT_DEBUG_TRACE, ("HT: MIMOPS Mode = %d\n", Value));
1532 }
1533
1534 if (RTMPGetKeyParameter("HT_BADecline", pValueStr, 25, pInput))
1535 {
1536 Value = simple_strtol(pValueStr, 0, 10);
1537 if (Value == 0)
1538 {
1539 pAd->CommonCfg.bBADecline = FALSE;
1540 }
1541 else
1542 {
1543 pAd->CommonCfg.bBADecline = TRUE;
1544 }
1545 DBGPRINT(RT_DEBUG_TRACE, ("HT: BA Decline = %s\n", (Value==0) ? "Disable" : "Enable"));
1546 }
1547
1548
1549 if (RTMPGetKeyParameter("HT_DisableReordering", pValueStr, 25, pInput))
1550 {
1551 Value = simple_strtol(pValueStr, 0, 10);
1552 if (Value == 0)
1553 {
1554 pAd->CommonCfg.bDisableReordering = FALSE;
1555 }
1556 else
1557 {
1558 pAd->CommonCfg.bDisableReordering = TRUE;
1559 }
1560 DBGPRINT(RT_DEBUG_TRACE, ("HT: DisableReordering = %s\n", (Value==0) ? "Disable" : "Enable"));
1561 }
1562
1563 if (RTMPGetKeyParameter("HT_AutoBA", pValueStr, 25, pInput))
1564 {
1565 Value = simple_strtol(pValueStr, 0, 10);
1566 if (Value == 0)
1567 {
1568 pAd->CommonCfg.BACapability.field.AutoBA = FALSE;
1569#ifdef RT30xx
1570 pAd->CommonCfg.BACapability.field.Policy = BA_NOTUSE;
1571#endif
1572 }
1573 else
1574 {
1575 pAd->CommonCfg.BACapability.field.AutoBA = TRUE;
1576#ifdef RT30xx
1577 pAd->CommonCfg.BACapability.field.Policy = IMMED_BA;
1578#endif
1579 }
1580 pAd->CommonCfg.REGBACapability.field.AutoBA = pAd->CommonCfg.BACapability.field.AutoBA;
1581#ifdef RT30xx
1582 pAd->CommonCfg.REGBACapability.field.Policy = pAd->CommonCfg.BACapability.field.Policy;
1583#endif
1584 DBGPRINT(RT_DEBUG_TRACE, ("HT: Auto BA = %s\n", (Value==0) ? "Disable" : "Enable"));
1585 }
1586
1587 // Tx_+HTC frame
1588 if (RTMPGetKeyParameter("HT_HTC", pValueStr, 25, pInput))
1589 {
1590 Value = simple_strtol(pValueStr, 0, 10);
1591 if (Value == 0)
1592 {
1593 pAd->HTCEnable = FALSE;
1594 }
1595 else
1596 {
1597 pAd->HTCEnable = TRUE;
1598 }
1599 DBGPRINT(RT_DEBUG_TRACE, ("HT: Tx +HTC frame = %s\n", (Value==0) ? "Disable" : "Enable"));
1600 }
1601
1602 // Enable HT Link Adaptation Control
1603 if (RTMPGetKeyParameter("HT_LinkAdapt", pValueStr, 25, pInput))
1604 {
1605 Value = simple_strtol(pValueStr, 0, 10);
1606 if (Value == 0)
1607 {
1608 pAd->bLinkAdapt = FALSE;
1609 }
1610 else
1611 {
1612 pAd->HTCEnable = TRUE;
1613 pAd->bLinkAdapt = TRUE;
1614 }
1615 DBGPRINT(RT_DEBUG_TRACE, ("HT: Link Adaptation Control = %s\n", (Value==0) ? "Disable" : "Enable(+HTC)"));
1616 }
1617
1618 // Reverse Direction Mechanism
1619 if (RTMPGetKeyParameter("HT_RDG", pValueStr, 25, pInput))
1620 {
1621 Value = simple_strtol(pValueStr, 0, 10);
1622 if (Value == 0)
1623 {
1624 pAd->CommonCfg.bRdg = FALSE;
1625 }
1626 else
1627 {
1628 pAd->HTCEnable = TRUE;
1629 pAd->CommonCfg.bRdg = TRUE;
1630 }
1631 DBGPRINT(RT_DEBUG_TRACE, ("HT: RDG = %s\n", (Value==0) ? "Disable" : "Enable(+HTC)"));
1632 }
1633
1634
1635
1636
1637 // Tx A-MSUD ?
1638 if (RTMPGetKeyParameter("HT_AMSDU", pValueStr, 25, pInput))
1639 {
1640 Value = simple_strtol(pValueStr, 0, 10);
1641 if (Value == 0)
1642 {
1643 pAd->CommonCfg.BACapability.field.AmsduEnable = FALSE;
1644 }
1645 else
1646 {
1647 pAd->CommonCfg.BACapability.field.AmsduEnable = TRUE;
1648 }
1649 DBGPRINT(RT_DEBUG_TRACE, ("HT: Tx A-MSDU = %s\n", (Value==0) ? "Disable" : "Enable"));
1650 }
1651
1652 // MPDU Density
1653 if (RTMPGetKeyParameter("HT_MpduDensity", pValueStr, 25, pInput))
1654 {
1655 Value = simple_strtol(pValueStr, 0, 10);
1656 if (Value <=7 && Value >= 0)
1657 {
1658 pAd->CommonCfg.BACapability.field.MpduDensity = Value;
1659 DBGPRINT(RT_DEBUG_TRACE, ("HT: MPDU Density = %d\n", Value));
1660 }
1661 else
1662 {
1663 pAd->CommonCfg.BACapability.field.MpduDensity = 4;
1664 DBGPRINT(RT_DEBUG_TRACE, ("HT: MPDU Density = %d (Default)\n", 4));
1665 }
1666 }
1667
1668 // Max Rx BA Window Size
1669 if (RTMPGetKeyParameter("HT_BAWinSize", pValueStr, 25, pInput))
1670 {
1671 Value = simple_strtol(pValueStr, 0, 10);
1672
1673 if (Value >=1 && Value <= 64)
1674 {
1675 pAd->CommonCfg.REGBACapability.field.RxBAWinLimit = Value;
1676 pAd->CommonCfg.BACapability.field.RxBAWinLimit = Value;
1677 DBGPRINT(RT_DEBUG_TRACE, ("HT: BA Windw Size = %d\n", Value));
1678 }
1679 else
1680 {
1681 pAd->CommonCfg.REGBACapability.field.RxBAWinLimit = 64;
1682 pAd->CommonCfg.BACapability.field.RxBAWinLimit = 64;
1683 DBGPRINT(RT_DEBUG_TRACE, ("HT: BA Windw Size = 64 (Defualt)\n"));
1684 }
1685
1686 }
1687
1688 // Guard Interval
1689 if (RTMPGetKeyParameter("HT_GI", pValueStr, 25, pInput))
1690 {
1691 Value = simple_strtol(pValueStr, 0, 10);
1692
1693 if (Value == GI_400)
1694 {
1695 pAd->CommonCfg.RegTransmitSetting.field.ShortGI = GI_400;
1696 }
1697 else
1698 {
1699 pAd->CommonCfg.RegTransmitSetting.field.ShortGI = GI_800;
1700 }
1701
1702 DBGPRINT(RT_DEBUG_TRACE, ("HT: Guard Interval = %s\n", (Value==GI_400) ? "400" : "800" ));
1703 }
1704
1705 // HT Operation Mode : Mixed Mode , Green Field
1706 if (RTMPGetKeyParameter("HT_OpMode", pValueStr, 25, pInput))
1707 {
1708 Value = simple_strtol(pValueStr, 0, 10);
1709
1710 if (Value == HTMODE_GF)
1711 {
1712
1713 pAd->CommonCfg.RegTransmitSetting.field.HTMODE = HTMODE_GF;
1714 }
1715 else
1716 {
1717 pAd->CommonCfg.RegTransmitSetting.field.HTMODE = HTMODE_MM;
1718 }
1719
1720 DBGPRINT(RT_DEBUG_TRACE, ("HT: Operate Mode = %s\n", (Value==HTMODE_GF) ? "Green Field" : "Mixed Mode" ));
1721 }
1722
1723 // Fixed Tx mode : CCK, OFDM
1724 if (RTMPGetKeyParameter("FixedTxMode", pValueStr, 25, pInput))
1725 {
1726 UCHAR fix_tx_mode;
1727
1728 {
1729 fix_tx_mode = FIXED_TXMODE_HT;
1730
1731 if (strcmp(pValueStr, "OFDM") == 0 || strcmp(pValueStr, "ofdm") == 0)
1732 {
1733 fix_tx_mode = FIXED_TXMODE_OFDM;
1734 }
1735 else if (strcmp(pValueStr, "CCK") == 0 || strcmp(pValueStr, "cck") == 0)
1736 {
1737 fix_tx_mode = FIXED_TXMODE_CCK;
1738 }
1739 else if (strcmp(pValueStr, "HT") == 0 || strcmp(pValueStr, "ht") == 0)
1740 {
1741 fix_tx_mode = FIXED_TXMODE_HT;
1742 }
1743 else
1744 {
1745 Value = simple_strtol(pValueStr, 0, 10);
1746 // 1 : CCK
1747 // 2 : OFDM
1748 // otherwise : HT
1749 if (Value == FIXED_TXMODE_CCK || Value == FIXED_TXMODE_OFDM)
1750 fix_tx_mode = Value;
1751 else
1752 fix_tx_mode = FIXED_TXMODE_HT;
1753 }
1754
1755 pAd->StaCfg.DesiredTransmitSetting.field.FixedTxMode = fix_tx_mode;
1756 DBGPRINT(RT_DEBUG_TRACE, ("Fixed Tx Mode = %d\n", fix_tx_mode));
1757
1758 }
1759 }
1760
1761
1762 // Channel Width
1763 if (RTMPGetKeyParameter("HT_BW", pValueStr, 25, pInput))
1764 {
1765 Value = simple_strtol(pValueStr, 0, 10);
1766
1767 if (Value == BW_40)
1768 {
1769 pAd->CommonCfg.RegTransmitSetting.field.BW = BW_40;
1770 }
1771 else
1772 {
1773 pAd->CommonCfg.RegTransmitSetting.field.BW = BW_20;
1774 }
1775
1776#ifdef MCAST_RATE_SPECIFIC
1777 pAd->CommonCfg.MCastPhyMode.field.BW = pAd->CommonCfg.RegTransmitSetting.field.BW;
1778#endif // MCAST_RATE_SPECIFIC //
1779
1780 DBGPRINT(RT_DEBUG_TRACE, ("HT: Channel Width = %s\n", (Value==BW_40) ? "40 MHz" : "20 MHz" ));
1781 }
1782
1783 if (RTMPGetKeyParameter("HT_EXTCHA", pValueStr, 25, pInput))
1784 {
1785 Value = simple_strtol(pValueStr, 0, 10);
1786
1787 if (Value == 0)
1788 {
1789
1790 pAd->CommonCfg.RegTransmitSetting.field.EXTCHA = EXTCHA_BELOW;
1791 }
1792 else
1793 {
1794 pAd->CommonCfg.RegTransmitSetting.field.EXTCHA = EXTCHA_ABOVE;
1795 }
1796
1797 DBGPRINT(RT_DEBUG_TRACE, ("HT: Ext Channel = %s\n", (Value==0) ? "BELOW" : "ABOVE" ));
1798 }
1799
1800 // MSC
1801 if (RTMPGetKeyParameter("HT_MCS", pValueStr, 50, pInput))
1802 {
1803 {
1804 Value = simple_strtol(pValueStr, 0, 10);
1805
1806 if ((Value >= 0 && Value <= 23) || (Value == 32)) // 3*3
1807 {
1808 pAd->StaCfg.DesiredTransmitSetting.field.MCS = Value;
1809 pAd->StaCfg.bAutoTxRateSwitch = FALSE;
1810 DBGPRINT(RT_DEBUG_TRACE, ("HT: MCS = %d\n", pAd->StaCfg.DesiredTransmitSetting.field.MCS));
1811 }
1812 else
1813 {
1814 pAd->StaCfg.DesiredTransmitSetting.field.MCS = MCS_AUTO;
1815 pAd->StaCfg.bAutoTxRateSwitch = TRUE;
1816 DBGPRINT(RT_DEBUG_TRACE, ("HT: MCS = AUTO\n"));
1817 }
1818 }
1819 }
1820
1821 // STBC
1822 if (RTMPGetKeyParameter("HT_STBC", pValueStr, 25, pInput))
1823 {
1824 Value = simple_strtol(pValueStr, 0, 10);
1825 if (Value == STBC_USE)
1826 {
1827 pAd->CommonCfg.RegTransmitSetting.field.STBC = STBC_USE;
1828 }
1829 else
1830 {
1831 pAd->CommonCfg.RegTransmitSetting.field.STBC = STBC_NONE;
1832 }
1833 DBGPRINT(RT_DEBUG_TRACE, ("HT: STBC = %d\n", pAd->CommonCfg.RegTransmitSetting.field.STBC));
1834 }
1835
1836 // 40_Mhz_Intolerant
1837 if (RTMPGetKeyParameter("HT_40MHZ_INTOLERANT", pValueStr, 25, pInput))
1838 {
1839 Value = simple_strtol(pValueStr, 0, 10);
1840 if (Value == 0)
1841 {
1842 pAd->CommonCfg.bForty_Mhz_Intolerant = FALSE;
1843 }
1844 else
1845 {
1846 pAd->CommonCfg.bForty_Mhz_Intolerant = TRUE;
1847 }
1848 DBGPRINT(RT_DEBUG_TRACE, ("HT: 40MHZ INTOLERANT = %d\n", pAd->CommonCfg.bForty_Mhz_Intolerant));
1849 }
1850 //HT_TxStream
1851 if(RTMPGetKeyParameter("HT_TxStream", pValueStr, 10, pInput))
1852 {
1853 switch (simple_strtol(pValueStr, 0, 10))
1854 {
1855 case 1:
1856 pAd->CommonCfg.TxStream = 1;
1857 break;
1858 case 2:
1859 pAd->CommonCfg.TxStream = 2;
1860 break;
1861 case 3: // 3*3
1862 default:
1863 pAd->CommonCfg.TxStream = 3;
1864
1865 if (pAd->MACVersion < RALINK_2883_VERSION)
1866 pAd->CommonCfg.TxStream = 2; // only 2 tx streams for RT2860 series
1867 break;
1868 }
1869 DBGPRINT(RT_DEBUG_TRACE, ("HT: Tx Stream = %d\n", pAd->CommonCfg.TxStream));
1870 }
1871 //HT_RxStream
1872 if(RTMPGetKeyParameter("HT_RxStream", pValueStr, 10, pInput))
1873 {
1874 switch (simple_strtol(pValueStr, 0, 10))
1875 {
1876 case 1:
1877 pAd->CommonCfg.RxStream = 1;
1878 break;
1879 case 2:
1880 pAd->CommonCfg.RxStream = 2;
1881 break;
1882 case 3:
1883 default:
1884 pAd->CommonCfg.RxStream = 3;
1885
1886 if (pAd->MACVersion < RALINK_2883_VERSION)
1887 pAd->CommonCfg.RxStream = 2; // only 2 rx streams for RT2860 series
1888 break;
1889 }
1890 DBGPRINT(RT_DEBUG_TRACE, ("HT: Rx Stream = %d\n", pAd->CommonCfg.RxStream));
1891 }
1892
1893}
diff --git a/drivers/staging/rt2870/rtmp.h b/drivers/staging/rt2870/rtmp.h
index 810797d9766c..e5ef89f8bef1 100644
--- a/drivers/staging/rt2870/rtmp.h
+++ b/drivers/staging/rt2870/rtmp.h
@@ -1,6700 +1 @@
1/* #include "../rt2860/rtmp.h"
2 *************************************************************************
3 * Ralink Tech Inc.
4 * 5F., No.36, Taiyuan St., Jhubei City,
5 * Hsinchu County 302,
6 * Taiwan, R.O.C.
7 *
8 * (c) Copyright 2002-2007, Ralink Technology, Inc.
9 *
10 * This program is free software; you can redistribute it and/or modify *
11 * it under the terms of the GNU General Public License as published by *
12 * the Free Software Foundation; either version 2 of the License, or *
13 * (at your option) any later version. *
14 * *
15 * This program is distributed in the hope that it will be useful, *
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
18 * GNU General Public License for more details. *
19 * *
20 * You should have received a copy of the GNU General Public License *
21 * along with this program; if not, write to the *
22 * Free Software Foundation, Inc., *
23 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
24 * *
25 *************************************************************************
26
27 Module Name:
28 rtmp.h
29
30 Abstract:
31 Miniport generic portion header file
32
33 Revision History:
34 Who When What
35 -------- ---------- ----------------------------------------------
36 Paul Lin 2002-08-01 created
37 James Tan 2002-09-06 modified (Revise NTCRegTable)
38 John Chang 2004-09-06 modified for RT2600
39*/
40#ifndef __RTMP_H__
41#define __RTMP_H__
42
43#include "link_list.h"
44#include "spectrum_def.h"
45
46#include "aironet.h"
47
48//#define DBG_DIAGNOSE 1
49
50#define VIRTUAL_IF_INC(__pAd) ((__pAd)->VirtualIfCnt++)
51#define VIRTUAL_IF_DEC(__pAd) ((__pAd)->VirtualIfCnt--)
52#define VIRTUAL_IF_NUM(__pAd) ((__pAd)->VirtualIfCnt)
53
54#ifdef RT2870
55////////////////////////////////////////////////////////////////////////////
56// The TX_BUFFER structure forms the transmitted USB packet to the device
57////////////////////////////////////////////////////////////////////////////
58typedef struct __TX_BUFFER{
59 union {
60 UCHAR WirelessPacket[TX_BUFFER_NORMSIZE];
61 HEADER_802_11 NullFrame;
62 PSPOLL_FRAME PsPollPacket;
63 RTS_FRAME RTSFrame;
64 }field;
65 UCHAR Aggregation[4]; //Buffer for save Aggregation size.
66} TX_BUFFER, *PTX_BUFFER;
67
68typedef struct __HTTX_BUFFER{
69 union {
70 UCHAR WirelessPacket[MAX_TXBULK_SIZE];
71 HEADER_802_11 NullFrame;
72 PSPOLL_FRAME PsPollPacket;
73 RTS_FRAME RTSFrame;
74 }field;
75 UCHAR Aggregation[4]; //Buffer for save Aggregation size.
76} HTTX_BUFFER, *PHTTX_BUFFER;
77
78
79// used to track driver-generated write irps
80typedef struct _TX_CONTEXT
81{
82 PVOID pAd; //Initialized in MiniportInitialize
83 PURB pUrb; //Initialized in MiniportInitialize
84 PIRP pIrp; //used to cancel pending bulk out.
85 //Initialized in MiniportInitialize
86 PTX_BUFFER TransferBuffer; //Initialized in MiniportInitialize
87 ULONG BulkOutSize;
88 UCHAR BulkOutPipeId;
89 UCHAR SelfIdx;
90 BOOLEAN InUse;
91 BOOLEAN bWaitingBulkOut; // at least one packet is in this TxContext, ready for making IRP anytime.
92 BOOLEAN bFullForBulkOut; // all tx buffer are full , so waiting for tx bulkout.
93 BOOLEAN IRPPending;
94 BOOLEAN LastOne;
95 BOOLEAN bAggregatible;
96 UCHAR Header_802_3[LENGTH_802_3];
97 UCHAR Rsv[2];
98 ULONG DataOffset;
99 UINT TxRate;
100 dma_addr_t data_dma; // urb dma on linux
101
102} TX_CONTEXT, *PTX_CONTEXT, **PPTX_CONTEXT;
103
104
105// used to track driver-generated write irps
106typedef struct _HT_TX_CONTEXT
107{
108 PVOID pAd; //Initialized in MiniportInitialize
109 PURB pUrb; //Initialized in MiniportInitialize
110 PIRP pIrp; //used to cancel pending bulk out.
111 //Initialized in MiniportInitialize
112 PHTTX_BUFFER TransferBuffer; //Initialized in MiniportInitialize
113 ULONG BulkOutSize; // Indicate the total bulk-out size in bytes in one bulk-transmission
114 UCHAR BulkOutPipeId;
115 BOOLEAN IRPPending;
116 BOOLEAN LastOne;
117 BOOLEAN bCurWriting;
118 BOOLEAN bRingEmpty;
119 BOOLEAN bCopySavePad;
120 UCHAR SavedPad[8];
121 UCHAR Header_802_3[LENGTH_802_3];
122 ULONG CurWritePosition; // Indicate the buffer offset which packet will be inserted start from.
123 ULONG CurWriteRealPos; // Indicate the buffer offset which packet now are writing to.
124 ULONG NextBulkOutPosition; // Indicate the buffer start offset of a bulk-transmission
125 ULONG ENextBulkOutPosition; // Indicate the buffer end offset of a bulk-transmission
126 UINT TxRate;
127 dma_addr_t data_dma; // urb dma on linux
128} HT_TX_CONTEXT, *PHT_TX_CONTEXT, **PPHT_TX_CONTEXT;
129
130
131//
132// Structure to keep track of receive packets and buffers to indicate
133// receive data to the protocol.
134//
135typedef struct _RX_CONTEXT
136{
137 PUCHAR TransferBuffer;
138 PVOID pAd;
139 PIRP pIrp;//used to cancel pending bulk in.
140 PURB pUrb;
141 //These 2 Boolean shouldn't both be 1 at the same time.
142 ULONG BulkInOffset; // number of packets waiting for reordering .
143 BOOLEAN bRxHandling; // Notify this packet is being process now.
144 BOOLEAN InUse; // USB Hardware Occupied. Wait for USB HW to put packet.
145 BOOLEAN Readable; // Receive Complete back. OK for driver to indicate receiving packet.
146 BOOLEAN IRPPending; // TODO: To be removed
147 atomic_t IrpLock;
148 NDIS_SPIN_LOCK RxContextLock;
149 dma_addr_t data_dma; // urb dma on linux
150} RX_CONTEXT, *PRX_CONTEXT;
151#endif // RT2870 //
152
153
154//
155// NDIS Version definitions
156//
157#ifdef NDIS50_MINIPORT
158#define RTMP_NDIS_MAJOR_VERSION 5
159#define RTMP_NDIS_MINOR_VERSION 0
160#endif
161
162#ifdef NDIS51_MINIPORT
163#define RTMP_NDIS_MAJOR_VERSION 5
164#define RTMP_NDIS_MINOR_VERSION 1
165#endif
166
167extern char NIC_VENDOR_DESC[];
168extern int NIC_VENDOR_DESC_LEN;
169
170extern unsigned char SNAP_AIRONET[];
171extern unsigned char CipherSuiteCiscoCCKM[];
172extern unsigned char CipherSuiteCiscoCCKMLen;
173extern unsigned char CipherSuiteCiscoCCKM24[];
174extern unsigned char CipherSuiteCiscoCCKM24Len;
175extern unsigned char CipherSuiteCCXTkip[];
176extern unsigned char CipherSuiteCCXTkipLen;
177extern unsigned char CISCO_OUI[];
178extern UCHAR BaSizeArray[4];
179
180extern UCHAR BROADCAST_ADDR[MAC_ADDR_LEN];
181extern UCHAR MULTICAST_ADDR[MAC_ADDR_LEN];
182extern UCHAR ZERO_MAC_ADDR[MAC_ADDR_LEN];
183extern ULONG BIT32[32];
184extern UCHAR BIT8[8];
185extern char* CipherName[];
186extern char* MCSToMbps[];
187extern UCHAR RxwiMCSToOfdmRate[12];
188extern UCHAR SNAP_802_1H[6];
189extern UCHAR SNAP_BRIDGE_TUNNEL[6];
190extern UCHAR SNAP_AIRONET[8];
191extern UCHAR CKIP_LLC_SNAP[8];
192extern UCHAR EAPOL_LLC_SNAP[8];
193extern UCHAR EAPOL[2];
194extern UCHAR IPX[2];
195extern UCHAR APPLE_TALK[2];
196extern UCHAR RateIdToPlcpSignal[12]; // see IEEE802.11a-1999 p.14
197extern UCHAR OfdmRateToRxwiMCS[];
198extern UCHAR OfdmSignalToRateId[16] ;
199extern UCHAR default_cwmin[4];
200extern UCHAR default_cwmax[4];
201extern UCHAR default_sta_aifsn[4];
202extern UCHAR MapUserPriorityToAccessCategory[8];
203
204extern USHORT RateUpPER[];
205extern USHORT RateDownPER[];
206extern UCHAR Phy11BNextRateDownward[];
207extern UCHAR Phy11BNextRateUpward[];
208extern UCHAR Phy11BGNextRateDownward[];
209extern UCHAR Phy11BGNextRateUpward[];
210extern UCHAR Phy11ANextRateDownward[];
211extern UCHAR Phy11ANextRateUpward[];
212extern CHAR RssiSafeLevelForTxRate[];
213extern UCHAR RateIdToMbps[];
214extern USHORT RateIdTo500Kbps[];
215
216extern UCHAR CipherSuiteWpaNoneTkip[];
217extern UCHAR CipherSuiteWpaNoneTkipLen;
218
219extern UCHAR CipherSuiteWpaNoneAes[];
220extern UCHAR CipherSuiteWpaNoneAesLen;
221
222extern UCHAR SsidIe;
223extern UCHAR SupRateIe;
224extern UCHAR ExtRateIe;
225
226extern UCHAR HtCapIe;
227extern UCHAR AddHtInfoIe;
228extern UCHAR NewExtChanIe;
229
230extern UCHAR ErpIe;
231extern UCHAR DsIe;
232extern UCHAR TimIe;
233extern UCHAR WpaIe;
234extern UCHAR Wpa2Ie;
235extern UCHAR IbssIe;
236extern UCHAR Ccx2Ie;
237#ifdef RT30xx
238extern UCHAR WapiIe;
239#endif
240
241extern UCHAR WPA_OUI[];
242extern UCHAR RSN_OUI[];
243#ifdef RT30xx
244extern UCHAR WAPI_OUI[];
245#endif
246extern UCHAR WME_INFO_ELEM[];
247extern UCHAR WME_PARM_ELEM[];
248extern UCHAR Ccx2QosInfo[];
249extern UCHAR Ccx2IeInfo[];
250extern UCHAR RALINK_OUI[];
251extern UCHAR PowerConstraintIE[];
252
253
254extern UCHAR RateSwitchTable[];
255extern UCHAR RateSwitchTable11B[];
256extern UCHAR RateSwitchTable11G[];
257extern UCHAR RateSwitchTable11BG[];
258
259extern UCHAR RateSwitchTable11BGN1S[];
260extern UCHAR RateSwitchTable11BGN2S[];
261extern UCHAR RateSwitchTable11BGN2SForABand[];
262extern UCHAR RateSwitchTable11N1S[];
263extern UCHAR RateSwitchTable11N2S[];
264extern UCHAR RateSwitchTable11N2SForABand[];
265
266extern UCHAR PRE_N_HT_OUI[];
267
268#define MAXSEQ (0xFFF)
269
270struct reordering_mpdu
271{
272 struct reordering_mpdu *next;
273 PNDIS_PACKET pPacket; /* coverted to 802.3 frame */
274 int Sequence; /* sequence number of MPDU */
275 BOOLEAN bAMSDU;
276};
277
278struct reordering_list
279{
280 struct reordering_mpdu *next;
281 int qlen;
282};
283
284struct reordering_mpdu_pool
285{
286 PVOID mem;
287 NDIS_SPIN_LOCK lock;
288 struct reordering_list freelist;
289};
290
291typedef struct _RSSI_SAMPLE {
292 CHAR LastRssi0; // last received RSSI
293 CHAR LastRssi1; // last received RSSI
294 CHAR LastRssi2; // last received RSSI
295 CHAR AvgRssi0;
296 CHAR AvgRssi1;
297 CHAR AvgRssi2;
298 SHORT AvgRssi0X8;
299 SHORT AvgRssi1X8;
300 SHORT AvgRssi2X8;
301} RSSI_SAMPLE;
302
303//
304// Queue structure and macros
305//
306typedef struct _QUEUE_ENTRY {
307 struct _QUEUE_ENTRY *Next;
308} QUEUE_ENTRY, *PQUEUE_ENTRY;
309
310// Queue structure
311typedef struct _QUEUE_HEADER {
312 PQUEUE_ENTRY Head;
313 PQUEUE_ENTRY Tail;
314 ULONG Number;
315} QUEUE_HEADER, *PQUEUE_HEADER;
316
317#define InitializeQueueHeader(QueueHeader) \
318{ \
319 (QueueHeader)->Head = (QueueHeader)->Tail = NULL; \
320 (QueueHeader)->Number = 0; \
321}
322
323#define RemoveHeadQueue(QueueHeader) \
324(QueueHeader)->Head; \
325{ \
326 PQUEUE_ENTRY pNext; \
327 if ((QueueHeader)->Head != NULL) \
328 { \
329 pNext = (QueueHeader)->Head->Next; \
330 (QueueHeader)->Head = pNext; \
331 if (pNext == NULL) \
332 (QueueHeader)->Tail = NULL; \
333 (QueueHeader)->Number--; \
334 } \
335}
336
337#define InsertHeadQueue(QueueHeader, QueueEntry) \
338{ \
339 ((PQUEUE_ENTRY)QueueEntry)->Next = (QueueHeader)->Head; \
340 (QueueHeader)->Head = (PQUEUE_ENTRY)(QueueEntry); \
341 if ((QueueHeader)->Tail == NULL) \
342 (QueueHeader)->Tail = (PQUEUE_ENTRY)(QueueEntry); \
343 (QueueHeader)->Number++; \
344}
345
346#define InsertTailQueue(QueueHeader, QueueEntry) \
347{ \
348 ((PQUEUE_ENTRY)QueueEntry)->Next = NULL; \
349 if ((QueueHeader)->Tail) \
350 (QueueHeader)->Tail->Next = (PQUEUE_ENTRY)(QueueEntry); \
351 else \
352 (QueueHeader)->Head = (PQUEUE_ENTRY)(QueueEntry); \
353 (QueueHeader)->Tail = (PQUEUE_ENTRY)(QueueEntry); \
354 (QueueHeader)->Number++; \
355}
356
357//
358// Macros for flag and ref count operations
359//
360#define RTMP_SET_FLAG(_M, _F) ((_M)->Flags |= (_F))
361#define RTMP_CLEAR_FLAG(_M, _F) ((_M)->Flags &= ~(_F))
362#define RTMP_CLEAR_FLAGS(_M) ((_M)->Flags = 0)
363#define RTMP_TEST_FLAG(_M, _F) (((_M)->Flags & (_F)) != 0)
364#define RTMP_TEST_FLAGS(_M, _F) (((_M)->Flags & (_F)) == (_F))
365
366#define OPSTATUS_SET_FLAG(_pAd, _F) ((_pAd)->CommonCfg.OpStatusFlags |= (_F))
367#define OPSTATUS_CLEAR_FLAG(_pAd, _F) ((_pAd)->CommonCfg.OpStatusFlags &= ~(_F))
368#define OPSTATUS_TEST_FLAG(_pAd, _F) (((_pAd)->CommonCfg.OpStatusFlags & (_F)) != 0)
369
370#define CLIENT_STATUS_SET_FLAG(_pEntry,_F) ((_pEntry)->ClientStatusFlags |= (_F))
371#define CLIENT_STATUS_CLEAR_FLAG(_pEntry,_F) ((_pEntry)->ClientStatusFlags &= ~(_F))
372#define CLIENT_STATUS_TEST_FLAG(_pEntry,_F) (((_pEntry)->ClientStatusFlags & (_F)) != 0)
373
374#define RX_FILTER_SET_FLAG(_pAd, _F) ((_pAd)->CommonCfg.PacketFilter |= (_F))
375#define RX_FILTER_CLEAR_FLAG(_pAd, _F) ((_pAd)->CommonCfg.PacketFilter &= ~(_F))
376#define RX_FILTER_TEST_FLAG(_pAd, _F) (((_pAd)->CommonCfg.PacketFilter & (_F)) != 0)
377
378#define STA_NO_SECURITY_ON(_p) (_p->StaCfg.WepStatus == Ndis802_11EncryptionDisabled)
379#define STA_WEP_ON(_p) (_p->StaCfg.WepStatus == Ndis802_11Encryption1Enabled)
380#define STA_TKIP_ON(_p) (_p->StaCfg.WepStatus == Ndis802_11Encryption2Enabled)
381#define STA_AES_ON(_p) (_p->StaCfg.WepStatus == Ndis802_11Encryption3Enabled)
382
383#define STA_TGN_WIFI_ON(_p) (_p->StaCfg.bTGnWifiTest == TRUE)
384
385#define CKIP_KP_ON(_p) ((((_p)->StaCfg.CkipFlag) & 0x10) && ((_p)->StaCfg.bCkipCmicOn == TRUE))
386#define CKIP_CMIC_ON(_p) ((((_p)->StaCfg.CkipFlag) & 0x08) && ((_p)->StaCfg.bCkipCmicOn == TRUE))
387
388
389#define INC_RING_INDEX(_idx, _RingSize) \
390{ \
391 (_idx) = (_idx+1) % (_RingSize); \
392}
393
394#ifdef RT30xx
395// We will have a cost down version which mac version is 0x3090xxxx
396#define IS_RT3090(_pAd) ((((_pAd)->MACVersion & 0xffff0000) == 0x30710000) || (((_pAd)->MACVersion & 0xffff0000) == 0x30900000))
397#endif
398#define IS_RT3070(_pAd) (((_pAd)->MACVersion & 0xffff0000) == 0x30700000)
399#ifdef RT30xx
400#define IS_RT3071(_pAd) (((_pAd)->MACVersion & 0xffff0000) == 0x30710000)
401#define IS_RT2070(_pAd) (((_pAd)->RfIcType == RFIC_2020) || ((_pAd)->EFuseTag == 0x27))
402
403#define IS_RT30xx(_pAd) (((_pAd)->MACVersion & 0xfff00000) == 0x30700000)
404#endif
405
406#define RING_PACKET_INIT(_TxRing, _idx) \
407{ \
408 _TxRing->Cell[_idx].pNdisPacket = NULL; \
409 _TxRing->Cell[_idx].pNextNdisPacket = NULL; \
410}
411
412#define TXDT_INIT(_TxD) \
413{ \
414 NdisZeroMemory(_TxD, TXD_SIZE); \
415 _TxD->DMADONE = 1; \
416}
417
418//Set last data segment
419#define RING_SET_LASTDS(_TxD, _IsSD0) \
420{ \
421 if (_IsSD0) {_TxD->LastSec0 = 1;} \
422 else {_TxD->LastSec1 = 1;} \
423}
424
425// Increase TxTsc value for next transmission
426// TODO:
427// When i==6, means TSC has done one full cycle, do re-keying stuff follow specs
428// Should send a special event microsoft defined to request re-key
429#define INC_TX_TSC(_tsc) \
430{ \
431 int i=0; \
432 while (++_tsc[i] == 0x0) \
433 { \
434 i++; \
435 if (i == 6) \
436 break; \
437 } \
438}
439
440// StaActive.SupportedHtPhy.MCSSet is copied from AP beacon. Don't need to update here.
441#define COPY_HTSETTINGS_FROM_MLME_AUX_TO_ACTIVE_CFG(_pAd) \
442{ \
443 _pAd->StaActive.SupportedHtPhy.ChannelWidth = _pAd->MlmeAux.HtCapability.HtCapInfo.ChannelWidth; \
444 _pAd->StaActive.SupportedHtPhy.MimoPs = _pAd->MlmeAux.HtCapability.HtCapInfo.MimoPs; \
445 _pAd->StaActive.SupportedHtPhy.GF = _pAd->MlmeAux.HtCapability.HtCapInfo.GF; \
446 _pAd->StaActive.SupportedHtPhy.ShortGIfor20 = _pAd->MlmeAux.HtCapability.HtCapInfo.ShortGIfor20; \
447 _pAd->StaActive.SupportedHtPhy.ShortGIfor40 = _pAd->MlmeAux.HtCapability.HtCapInfo.ShortGIfor40; \
448 _pAd->StaActive.SupportedHtPhy.TxSTBC = _pAd->MlmeAux.HtCapability.HtCapInfo.TxSTBC; \
449 _pAd->StaActive.SupportedHtPhy.RxSTBC = _pAd->MlmeAux.HtCapability.HtCapInfo.RxSTBC; \
450 _pAd->StaActive.SupportedHtPhy.ExtChanOffset = _pAd->MlmeAux.AddHtInfo.AddHtInfo.ExtChanOffset; \
451 _pAd->StaActive.SupportedHtPhy.RecomWidth = _pAd->MlmeAux.AddHtInfo.AddHtInfo.RecomWidth; \
452 _pAd->StaActive.SupportedHtPhy.OperaionMode = _pAd->MlmeAux.AddHtInfo.AddHtInfo2.OperaionMode; \
453 _pAd->StaActive.SupportedHtPhy.NonGfPresent = _pAd->MlmeAux.AddHtInfo.AddHtInfo2.NonGfPresent; \
454 NdisMoveMemory((_pAd)->MacTab.Content[BSSID_WCID].HTCapability.MCSSet, (_pAd)->StaActive.SupportedPhyInfo.MCSSet, sizeof(UCHAR) * 16);\
455}
456
457#define COPY_AP_HTSETTINGS_FROM_BEACON(_pAd, _pHtCapability) \
458{ \
459 _pAd->MacTab.Content[BSSID_WCID].AMsduSize = (UCHAR)(_pHtCapability->HtCapInfo.AMsduSize); \
460 _pAd->MacTab.Content[BSSID_WCID].MmpsMode= (UCHAR)(_pHtCapability->HtCapInfo.MimoPs); \
461 _pAd->MacTab.Content[BSSID_WCID].MaxRAmpduFactor = (UCHAR)(_pHtCapability->HtCapParm.MaxRAmpduFactor); \
462}
463
464//
465// BBP & RF are using indirect access. Before write any value into it.
466// We have to make sure there is no outstanding command pending via checking busy bit.
467//
468#define MAX_BUSY_COUNT 100 // Number of retry before failing access BBP & RF indirect register
469//
470
471#ifdef RT2870
472#define RTMP_RF_IO_WRITE32(_A, _V) RTUSBWriteRFRegister(_A, _V)
473#define RTMP_BBP_IO_READ8_BY_REG_ID(_A, _I, _pV) RTUSBReadBBPRegister(_A, _I, _pV)
474#define RTMP_BBP_IO_WRITE8_BY_REG_ID(_A, _I, _V) RTUSBWriteBBPRegister(_A, _I, _V)
475
476#define BBP_IO_WRITE8_BY_REG_ID(_A, _I, _V) RTUSBWriteBBPRegister(_A, _I, _V)
477#define BBP_IO_READ8_BY_REG_ID(_A, _I, _pV) RTUSBReadBBPRegister(_A, _I, _pV)
478#endif // RT2870 //
479
480#ifdef RT30xx
481#define RTMP_RF_IO_READ8_BY_REG_ID(_A, _I, _pV) RT30xxReadRFRegister(_A, _I, _pV)
482#define RTMP_RF_IO_WRITE8_BY_REG_ID(_A, _I, _V) RT30xxWriteRFRegister(_A, _I, _V)
483#endif // RT30xx //
484
485#define MAP_CHANNEL_ID_TO_KHZ(ch, khz) { \
486 switch (ch) \
487 { \
488 case 1: khz = 2412000; break; \
489 case 2: khz = 2417000; break; \
490 case 3: khz = 2422000; break; \
491 case 4: khz = 2427000; break; \
492 case 5: khz = 2432000; break; \
493 case 6: khz = 2437000; break; \
494 case 7: khz = 2442000; break; \
495 case 8: khz = 2447000; break; \
496 case 9: khz = 2452000; break; \
497 case 10: khz = 2457000; break; \
498 case 11: khz = 2462000; break; \
499 case 12: khz = 2467000; break; \
500 case 13: khz = 2472000; break; \
501 case 14: khz = 2484000; break; \
502 case 36: /* UNII */ khz = 5180000; break; \
503 case 40: /* UNII */ khz = 5200000; break; \
504 case 44: /* UNII */ khz = 5220000; break; \
505 case 48: /* UNII */ khz = 5240000; break; \
506 case 52: /* UNII */ khz = 5260000; break; \
507 case 56: /* UNII */ khz = 5280000; break; \
508 case 60: /* UNII */ khz = 5300000; break; \
509 case 64: /* UNII */ khz = 5320000; break; \
510 case 149: /* UNII */ khz = 5745000; break; \
511 case 153: /* UNII */ khz = 5765000; break; \
512 case 157: /* UNII */ khz = 5785000; break; \
513 case 161: /* UNII */ khz = 5805000; break; \
514 case 165: /* UNII */ khz = 5825000; break; \
515 case 100: /* HiperLAN2 */ khz = 5500000; break; \
516 case 104: /* HiperLAN2 */ khz = 5520000; break; \
517 case 108: /* HiperLAN2 */ khz = 5540000; break; \
518 case 112: /* HiperLAN2 */ khz = 5560000; break; \
519 case 116: /* HiperLAN2 */ khz = 5580000; break; \
520 case 120: /* HiperLAN2 */ khz = 5600000; break; \
521 case 124: /* HiperLAN2 */ khz = 5620000; break; \
522 case 128: /* HiperLAN2 */ khz = 5640000; break; \
523 case 132: /* HiperLAN2 */ khz = 5660000; break; \
524 case 136: /* HiperLAN2 */ khz = 5680000; break; \
525 case 140: /* HiperLAN2 */ khz = 5700000; break; \
526 case 34: /* Japan MMAC */ khz = 5170000; break; \
527 case 38: /* Japan MMAC */ khz = 5190000; break; \
528 case 42: /* Japan MMAC */ khz = 5210000; break; \
529 case 46: /* Japan MMAC */ khz = 5230000; break; \
530 case 184: /* Japan */ khz = 4920000; break; \
531 case 188: /* Japan */ khz = 4940000; break; \
532 case 192: /* Japan */ khz = 4960000; break; \
533 case 196: /* Japan */ khz = 4980000; break; \
534 case 208: /* Japan, means J08 */ khz = 5040000; break; \
535 case 212: /* Japan, means J12 */ khz = 5060000; break; \
536 case 216: /* Japan, means J16 */ khz = 5080000; break; \
537 default: khz = 2412000; break; \
538 } \
539 }
540
541#define MAP_KHZ_TO_CHANNEL_ID(khz, ch) { \
542 switch (khz) \
543 { \
544 case 2412000: ch = 1; break; \
545 case 2417000: ch = 2; break; \
546 case 2422000: ch = 3; break; \
547 case 2427000: ch = 4; break; \
548 case 2432000: ch = 5; break; \
549 case 2437000: ch = 6; break; \
550 case 2442000: ch = 7; break; \
551 case 2447000: ch = 8; break; \
552 case 2452000: ch = 9; break; \
553 case 2457000: ch = 10; break; \
554 case 2462000: ch = 11; break; \
555 case 2467000: ch = 12; break; \
556 case 2472000: ch = 13; break; \
557 case 2484000: ch = 14; break; \
558 case 5180000: ch = 36; /* UNII */ break; \
559 case 5200000: ch = 40; /* UNII */ break; \
560 case 5220000: ch = 44; /* UNII */ break; \
561 case 5240000: ch = 48; /* UNII */ break; \
562 case 5260000: ch = 52; /* UNII */ break; \
563 case 5280000: ch = 56; /* UNII */ break; \
564 case 5300000: ch = 60; /* UNII */ break; \
565 case 5320000: ch = 64; /* UNII */ break; \
566 case 5745000: ch = 149; /* UNII */ break; \
567 case 5765000: ch = 153; /* UNII */ break; \
568 case 5785000: ch = 157; /* UNII */ break; \
569 case 5805000: ch = 161; /* UNII */ break; \
570 case 5825000: ch = 165; /* UNII */ break; \
571 case 5500000: ch = 100; /* HiperLAN2 */ break; \
572 case 5520000: ch = 104; /* HiperLAN2 */ break; \
573 case 5540000: ch = 108; /* HiperLAN2 */ break; \
574 case 5560000: ch = 112; /* HiperLAN2 */ break; \
575 case 5580000: ch = 116; /* HiperLAN2 */ break; \
576 case 5600000: ch = 120; /* HiperLAN2 */ break; \
577 case 5620000: ch = 124; /* HiperLAN2 */ break; \
578 case 5640000: ch = 128; /* HiperLAN2 */ break; \
579 case 5660000: ch = 132; /* HiperLAN2 */ break; \
580 case 5680000: ch = 136; /* HiperLAN2 */ break; \
581 case 5700000: ch = 140; /* HiperLAN2 */ break; \
582 case 5170000: ch = 34; /* Japan MMAC */ break; \
583 case 5190000: ch = 38; /* Japan MMAC */ break; \
584 case 5210000: ch = 42; /* Japan MMAC */ break; \
585 case 5230000: ch = 46; /* Japan MMAC */ break; \
586 case 4920000: ch = 184; /* Japan */ break; \
587 case 4940000: ch = 188; /* Japan */ break; \
588 case 4960000: ch = 192; /* Japan */ break; \
589 case 4980000: ch = 196; /* Japan */ break; \
590 case 5040000: ch = 208; /* Japan, means J08 */ break; \
591 case 5060000: ch = 212; /* Japan, means J12 */ break; \
592 case 5080000: ch = 216; /* Japan, means J16 */ break; \
593 default: ch = 1; break; \
594 } \
595 }
596
597//
598// Common fragment list structure - Identical to the scatter gather frag list structure
599//
600#define NIC_MAX_PHYS_BUF_COUNT 8
601
602typedef struct _RTMP_SCATTER_GATHER_ELEMENT {
603 PVOID Address;
604 ULONG Length;
605 PULONG Reserved;
606} RTMP_SCATTER_GATHER_ELEMENT, *PRTMP_SCATTER_GATHER_ELEMENT;
607
608
609typedef struct _RTMP_SCATTER_GATHER_LIST {
610 ULONG NumberOfElements;
611 PULONG Reserved;
612 RTMP_SCATTER_GATHER_ELEMENT Elements[NIC_MAX_PHYS_BUF_COUNT];
613} RTMP_SCATTER_GATHER_LIST, *PRTMP_SCATTER_GATHER_LIST;
614
615//
616// Some utility macros
617//
618#ifndef min
619#define min(_a, _b) (((_a) < (_b)) ? (_a) : (_b))
620#endif
621
622#ifndef max
623#define max(_a, _b) (((_a) > (_b)) ? (_a) : (_b))
624#endif
625
626#define GET_LNA_GAIN(_pAd) ((_pAd->LatchRfRegs.Channel <= 14) ? (_pAd->BLNAGain) : ((_pAd->LatchRfRegs.Channel <= 64) ? (_pAd->ALNAGain0) : ((_pAd->LatchRfRegs.Channel <= 128) ? (_pAd->ALNAGain1) : (_pAd->ALNAGain2))))
627
628#define INC_COUNTER64(Val) (Val.QuadPart++)
629
630#define INFRA_ON(_p) (OPSTATUS_TEST_FLAG(_p, fOP_STATUS_INFRA_ON))
631#define ADHOC_ON(_p) (OPSTATUS_TEST_FLAG(_p, fOP_STATUS_ADHOC_ON))
632#define MONITOR_ON(_p) (((_p)->StaCfg.BssType) == BSS_MONITOR)
633#define IDLE_ON(_p) (!INFRA_ON(_p) && !ADHOC_ON(_p))
634
635// Check LEAP & CCKM flags
636#define LEAP_ON(_p) (((_p)->StaCfg.LeapAuthMode) == CISCO_AuthModeLEAP)
637#define LEAP_CCKM_ON(_p) ((((_p)->StaCfg.LeapAuthMode) == CISCO_AuthModeLEAP) && ((_p)->StaCfg.LeapAuthInfo.CCKM == TRUE))
638
639// if orginal Ethernet frame contains no LLC/SNAP, then an extra LLC/SNAP encap is required
640#define EXTRA_LLCSNAP_ENCAP_FROM_PKT_START(_pBufVA, _pExtraLlcSnapEncap) \
641{ \
642 if (((*(_pBufVA + 12) << 8) + *(_pBufVA + 13)) > 1500) \
643 { \
644 _pExtraLlcSnapEncap = SNAP_802_1H; \
645 if (NdisEqualMemory(IPX, _pBufVA + 12, 2) || \
646 NdisEqualMemory(APPLE_TALK, _pBufVA + 12, 2)) \
647 { \
648 _pExtraLlcSnapEncap = SNAP_BRIDGE_TUNNEL; \
649 } \
650 } \
651 else \
652 { \
653 _pExtraLlcSnapEncap = NULL; \
654 } \
655}
656
657// New Define for new Tx Path.
658#define EXTRA_LLCSNAP_ENCAP_FROM_PKT_OFFSET(_pBufVA, _pExtraLlcSnapEncap) \
659{ \
660 if (((*(_pBufVA) << 8) + *(_pBufVA + 1)) > 1500) \
661 { \
662 _pExtraLlcSnapEncap = SNAP_802_1H; \
663 if (NdisEqualMemory(IPX, _pBufVA, 2) || \
664 NdisEqualMemory(APPLE_TALK, _pBufVA, 2)) \
665 { \
666 _pExtraLlcSnapEncap = SNAP_BRIDGE_TUNNEL; \
667 } \
668 } \
669 else \
670 { \
671 _pExtraLlcSnapEncap = NULL; \
672 } \
673}
674
675
676#define MAKE_802_3_HEADER(_p, _pMac1, _pMac2, _pType) \
677{ \
678 NdisMoveMemory(_p, _pMac1, MAC_ADDR_LEN); \
679 NdisMoveMemory((_p + MAC_ADDR_LEN), _pMac2, MAC_ADDR_LEN); \
680 NdisMoveMemory((_p + MAC_ADDR_LEN * 2), _pType, LENGTH_802_3_TYPE); \
681}
682
683// if pData has no LLC/SNAP (neither RFC1042 nor Bridge tunnel), keep it that way.
684// else if the received frame is LLC/SNAP-encaped IPX or APPLETALK, preserve the LLC/SNAP field
685// else remove the LLC/SNAP field from the result Ethernet frame
686// Patch for WHQL only, which did not turn on Netbios but use IPX within its payload
687// Note:
688// _pData & _DataSize may be altered (remove 8-byte LLC/SNAP) by this MACRO
689// _pRemovedLLCSNAP: pointer to removed LLC/SNAP; NULL is not removed
690#define CONVERT_TO_802_3(_p8023hdr, _pDA, _pSA, _pData, _DataSize, _pRemovedLLCSNAP) \
691{ \
692 char LLC_Len[2]; \
693 \
694 _pRemovedLLCSNAP = NULL; \
695 if (NdisEqualMemory(SNAP_802_1H, _pData, 6) || \
696 NdisEqualMemory(SNAP_BRIDGE_TUNNEL, _pData, 6)) \
697 { \
698 PUCHAR pProto = _pData + 6; \
699 \
700 if ((NdisEqualMemory(IPX, pProto, 2) || NdisEqualMemory(APPLE_TALK, pProto, 2)) && \
701 NdisEqualMemory(SNAP_802_1H, _pData, 6)) \
702 { \
703 LLC_Len[0] = (UCHAR)(_DataSize / 256); \
704 LLC_Len[1] = (UCHAR)(_DataSize % 256); \
705 MAKE_802_3_HEADER(_p8023hdr, _pDA, _pSA, LLC_Len); \
706 } \
707 else \
708 { \
709 MAKE_802_3_HEADER(_p8023hdr, _pDA, _pSA, pProto); \
710 _pRemovedLLCSNAP = _pData; \
711 _DataSize -= LENGTH_802_1_H; \
712 _pData += LENGTH_802_1_H; \
713 } \
714 } \
715 else \
716 { \
717 LLC_Len[0] = (UCHAR)(_DataSize / 256); \
718 LLC_Len[1] = (UCHAR)(_DataSize % 256); \
719 MAKE_802_3_HEADER(_p8023hdr, _pDA, _pSA, LLC_Len); \
720 } \
721}
722
723#define SWITCH_AB( _pAA, _pBB) \
724{ \
725 PVOID pCC; \
726 pCC = _pBB; \
727 _pBB = _pAA; \
728 _pAA = pCC; \
729}
730
731// Enqueue this frame to MLME engine
732// We need to enqueue the whole frame because MLME need to pass data type
733// information from 802.11 header
734#ifdef RT2870
735#define REPORT_MGMT_FRAME_TO_MLME(_pAd, Wcid, _pFrame, _FrameSize, _Rssi0, _Rssi1, _Rssi2, _PlcpSignal) \
736{ \
737 UINT32 High32TSF=0, Low32TSF=0; \
738 MlmeEnqueueForRecv(_pAd, Wcid, High32TSF, Low32TSF, (UCHAR)_Rssi0, (UCHAR)_Rssi1,(UCHAR)_Rssi2,_FrameSize, _pFrame, (UCHAR)_PlcpSignal); \
739}
740#endif // RT2870 //
741
742#ifdef RT30xx
743//Need to collect each ant's rssi concurrently
744//rssi1 is report to pair2 Ant and rss2 is reprot to pair1 Ant when 4 Ant
745#define COLLECT_RX_ANTENNA_AVERAGE_RSSI(_pAd, _rssi1, _rssi2) \
746{ \
747 SHORT AvgRssi; \
748 UCHAR UsedAnt; \
749 if (_pAd->RxAnt.EvaluatePeriod == 0) \
750 { \
751 UsedAnt = _pAd->RxAnt.Pair1PrimaryRxAnt; \
752 AvgRssi = _pAd->RxAnt.Pair1AvgRssi[UsedAnt]; \
753 if (AvgRssi < 0) \
754 AvgRssi = AvgRssi - (AvgRssi >> 3) + _rssi1; \
755 else \
756 AvgRssi = _rssi1 << 3; \
757 _pAd->RxAnt.Pair1AvgRssi[UsedAnt] = AvgRssi; \
758 } \
759 else \
760 { \
761 UsedAnt = _pAd->RxAnt.Pair1SecondaryRxAnt; \
762 AvgRssi = _pAd->RxAnt.Pair1AvgRssi[UsedAnt]; \
763 if ((AvgRssi < 0) && (_pAd->RxAnt.FirstPktArrivedWhenEvaluate)) \
764 AvgRssi = AvgRssi - (AvgRssi >> 3) + _rssi1; \
765 else \
766 { \
767 _pAd->RxAnt.FirstPktArrivedWhenEvaluate = TRUE; \
768 AvgRssi = _rssi1 << 3; \
769 } \
770 _pAd->RxAnt.Pair1AvgRssi[UsedAnt] = AvgRssi; \
771 _pAd->RxAnt.RcvPktNumWhenEvaluate++; \
772 } \
773}
774#endif // RT30xx //
775
776
777#define NDIS_QUERY_BUFFER(_NdisBuf, _ppVA, _pBufLen) \
778 NdisQueryBuffer(_NdisBuf, _ppVA, _pBufLen)
779
780#define MAC_ADDR_EQUAL(pAddr1,pAddr2) RTMPEqualMemory((PVOID)(pAddr1), (PVOID)(pAddr2), MAC_ADDR_LEN)
781#define SSID_EQUAL(ssid1, len1, ssid2, len2) ((len1==len2) && (RTMPEqualMemory(ssid1, ssid2, len1)))
782
783//
784// Check if it is Japan W53(ch52,56,60,64) channel.
785//
786#define JapanChannelCheck(channel) ((channel == 52) || (channel == 56) || (channel == 60) || (channel == 64))
787
788#define STA_PORT_SECURED(_pAd) \
789{ \
790 _pAd->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED; \
791 NdisAcquireSpinLock(&_pAd->MacTabLock); \
792 _pAd->MacTab.Content[BSSID_WCID].PortSecured = _pAd->StaCfg.PortSecured; \
793 NdisReleaseSpinLock(&_pAd->MacTabLock); \
794}
795
796//
797// Register set pair for initialzation register set definition
798//
799typedef struct _RTMP_REG_PAIR
800{
801 ULONG Register;
802 ULONG Value;
803} RTMP_REG_PAIR, *PRTMP_REG_PAIR;
804
805typedef struct _REG_PAIR
806{
807 UCHAR Register;
808 UCHAR Value;
809} REG_PAIR, *PREG_PAIR;
810
811//
812// Register set pair for initialzation register set definition
813//
814typedef struct _RTMP_RF_REGS
815{
816 UCHAR Channel;
817 ULONG R1;
818 ULONG R2;
819 ULONG R3;
820 ULONG R4;
821} RTMP_RF_REGS, *PRTMP_RF_REGS;
822
823typedef struct _FREQUENCY_ITEM {
824 UCHAR Channel;
825 UCHAR N;
826 UCHAR R;
827 UCHAR K;
828} FREQUENCY_ITEM, *PFREQUENCY_ITEM;
829
830//
831// Data buffer for DMA operation, the buffer must be contiguous physical memory
832// Both DMA to / from CPU use the same structure.
833//
834typedef struct _RTMP_DMABUF
835{
836 ULONG AllocSize;
837 PVOID AllocVa; // TxBuf virtual address
838 NDIS_PHYSICAL_ADDRESS AllocPa; // TxBuf physical address
839} RTMP_DMABUF, *PRTMP_DMABUF;
840
841
842typedef union _HEADER_802_11_SEQ{
843 struct {
844 USHORT Frag:4;
845 USHORT Sequence:12;
846 } field;
847 USHORT value;
848} HEADER_802_11_SEQ, *PHEADER_802_11_SEQ;
849
850//
851// Data buffer for DMA operation, the buffer must be contiguous physical memory
852// Both DMA to / from CPU use the same structure.
853//
854typedef struct _RTMP_REORDERBUF
855{
856 BOOLEAN IsFull;
857 PVOID AllocVa; // TxBuf virtual address
858 UCHAR Header802_3[14];
859 HEADER_802_11_SEQ Sequence; //support compressed bitmap BA, so no consider fragment in BA
860 UCHAR DataOffset;
861 USHORT Datasize;
862 ULONG AllocSize;
863#ifdef RT2870
864 PUCHAR AllocPa;
865#endif // RT2870 //
866} RTMP_REORDERBUF, *PRTMP_REORDERBUF;
867
868//
869// Control block (Descriptor) for all ring descriptor DMA operation, buffer must be
870// contiguous physical memory. NDIS_PACKET stored the binding Rx packet descriptor
871// which won't be released, driver has to wait until upper layer return the packet
872// before giveing up this rx ring descriptor to ASIC. NDIS_BUFFER is assocaited pair
873// to describe the packet buffer. For Tx, NDIS_PACKET stored the tx packet descriptor
874// which driver should ACK upper layer when the tx is physically done or failed.
875//
876typedef struct _RTMP_DMACB
877{
878 ULONG AllocSize; // Control block size
879 PVOID AllocVa; // Control block virtual address
880 NDIS_PHYSICAL_ADDRESS AllocPa; // Control block physical address
881 PNDIS_PACKET pNdisPacket;
882 PNDIS_PACKET pNextNdisPacket;
883
884 RTMP_DMABUF DmaBuf; // Associated DMA buffer structure
885} RTMP_DMACB, *PRTMP_DMACB;
886
887typedef struct _RTMP_TX_BUF
888{
889 PQUEUE_ENTRY Next;
890 UCHAR Index;
891 ULONG AllocSize; // Control block size
892 PVOID AllocVa; // Control block virtual address
893 NDIS_PHYSICAL_ADDRESS AllocPa; // Control block physical address
894} RTMP_TXBUF, *PRTMP_TXBUF;
895
896typedef struct _RTMP_RX_BUF
897{
898 BOOLEAN InUse;
899 ULONG ByBaRecIndex;
900 RTMP_REORDERBUF MAP_RXBuf[MAX_RX_REORDERBUF];
901} RTMP_RXBUF, *PRTMP_RXBUF;
902typedef struct _RTMP_TX_RING
903{
904 RTMP_DMACB Cell[TX_RING_SIZE];
905 UINT32 TxCpuIdx;
906 UINT32 TxDmaIdx;
907 UINT32 TxSwFreeIdx; // software next free tx index
908} RTMP_TX_RING, *PRTMP_TX_RING;
909
910typedef struct _RTMP_RX_RING
911{
912 RTMP_DMACB Cell[RX_RING_SIZE];
913 UINT32 RxCpuIdx;
914 UINT32 RxDmaIdx;
915 INT32 RxSwReadIdx; // software next read index
916} RTMP_RX_RING, *PRTMP_RX_RING;
917
918typedef struct _RTMP_MGMT_RING
919{
920 RTMP_DMACB Cell[MGMT_RING_SIZE];
921 UINT32 TxCpuIdx;
922 UINT32 TxDmaIdx;
923 UINT32 TxSwFreeIdx; // software next free tx index
924} RTMP_MGMT_RING, *PRTMP_MGMT_RING;
925
926//
927// Statistic counter structure
928//
929typedef struct _COUNTER_802_3
930{
931 // General Stats
932 ULONG GoodTransmits;
933 ULONG GoodReceives;
934 ULONG TxErrors;
935 ULONG RxErrors;
936 ULONG RxNoBuffer;
937
938 // Ethernet Stats
939 ULONG RcvAlignmentErrors;
940 ULONG OneCollision;
941 ULONG MoreCollisions;
942
943} COUNTER_802_3, *PCOUNTER_802_3;
944
945typedef struct _COUNTER_802_11 {
946 ULONG Length;
947 LARGE_INTEGER LastTransmittedFragmentCount;
948 LARGE_INTEGER TransmittedFragmentCount;
949 LARGE_INTEGER MulticastTransmittedFrameCount;
950 LARGE_INTEGER FailedCount;
951 LARGE_INTEGER RetryCount;
952 LARGE_INTEGER MultipleRetryCount;
953 LARGE_INTEGER RTSSuccessCount;
954 LARGE_INTEGER RTSFailureCount;
955 LARGE_INTEGER ACKFailureCount;
956 LARGE_INTEGER FrameDuplicateCount;
957 LARGE_INTEGER ReceivedFragmentCount;
958 LARGE_INTEGER MulticastReceivedFrameCount;
959 LARGE_INTEGER FCSErrorCount;
960} COUNTER_802_11, *PCOUNTER_802_11;
961
962typedef struct _COUNTER_RALINK {
963 ULONG TransmittedByteCount; // both successful and failure, used to calculate TX throughput
964 ULONG ReceivedByteCount; // both CRC okay and CRC error, used to calculate RX throughput
965 ULONG BeenDisassociatedCount;
966 ULONG BadCQIAutoRecoveryCount;
967 ULONG PoorCQIRoamingCount;
968 ULONG MgmtRingFullCount;
969 ULONG RxCountSinceLastNULL;
970 ULONG RxCount;
971 ULONG RxRingErrCount;
972 ULONG KickTxCount;
973 ULONG TxRingErrCount;
974 LARGE_INTEGER RealFcsErrCount;
975 ULONG PendingNdisPacketCount;
976
977 ULONG OneSecOsTxCount[NUM_OF_TX_RING];
978 ULONG OneSecDmaDoneCount[NUM_OF_TX_RING];
979 UINT32 OneSecTxDoneCount;
980 ULONG OneSecRxCount;
981 UINT32 OneSecTxAggregationCount;
982 UINT32 OneSecRxAggregationCount;
983
984 UINT32 OneSecFrameDuplicateCount;
985
986#ifdef RT2870
987 ULONG OneSecTransmittedByteCount; // both successful and failure, used to calculate TX throughput
988#endif // RT2870 //
989
990 UINT32 OneSecTxNoRetryOkCount;
991 UINT32 OneSecTxRetryOkCount;
992 UINT32 OneSecTxFailCount;
993 UINT32 OneSecFalseCCACnt; // CCA error count, for debug purpose, might move to global counter
994 UINT32 OneSecRxOkCnt; // RX without error
995 UINT32 OneSecRxOkDataCnt; // unicast-to-me DATA frame count
996 UINT32 OneSecRxFcsErrCnt; // CRC error
997 UINT32 OneSecBeaconSentCnt;
998 UINT32 LastOneSecTotalTxCount; // OneSecTxNoRetryOkCount + OneSecTxRetryOkCount + OneSecTxFailCount
999 UINT32 LastOneSecRxOkDataCnt; // OneSecRxOkDataCnt
1000 ULONG DuplicateRcv;
1001 ULONG TxAggCount;
1002 ULONG TxNonAggCount;
1003 ULONG TxAgg1MPDUCount;
1004 ULONG TxAgg2MPDUCount;
1005 ULONG TxAgg3MPDUCount;
1006 ULONG TxAgg4MPDUCount;
1007 ULONG TxAgg5MPDUCount;
1008 ULONG TxAgg6MPDUCount;
1009 ULONG TxAgg7MPDUCount;
1010 ULONG TxAgg8MPDUCount;
1011 ULONG TxAgg9MPDUCount;
1012 ULONG TxAgg10MPDUCount;
1013 ULONG TxAgg11MPDUCount;
1014 ULONG TxAgg12MPDUCount;
1015 ULONG TxAgg13MPDUCount;
1016 ULONG TxAgg14MPDUCount;
1017 ULONG TxAgg15MPDUCount;
1018 ULONG TxAgg16MPDUCount;
1019
1020 LARGE_INTEGER TransmittedOctetsInAMSDU;
1021 LARGE_INTEGER TransmittedAMSDUCount;
1022 LARGE_INTEGER ReceivedOctesInAMSDUCount;
1023 LARGE_INTEGER ReceivedAMSDUCount;
1024 LARGE_INTEGER TransmittedAMPDUCount;
1025 LARGE_INTEGER TransmittedMPDUsInAMPDUCount;
1026 LARGE_INTEGER TransmittedOctetsInAMPDUCount;
1027 LARGE_INTEGER MPDUInReceivedAMPDUCount;
1028} COUNTER_RALINK, *PCOUNTER_RALINK;
1029
1030typedef struct _PID_COUNTER {
1031 ULONG TxAckRequiredCount; // CRC error
1032 ULONG TxAggreCount;
1033 ULONG TxSuccessCount; // OneSecTxNoRetryOkCount + OneSecTxRetryOkCount + OneSecTxFailCount
1034 ULONG LastSuccessRate;
1035} PID_COUNTER, *PPID_COUNTER;
1036
1037typedef struct _COUNTER_DRS {
1038 // to record the each TX rate's quality. 0 is best, the bigger the worse.
1039 USHORT TxQuality[MAX_STEP_OF_TX_RATE_SWITCH];
1040 UCHAR PER[MAX_STEP_OF_TX_RATE_SWITCH];
1041 UCHAR TxRateUpPenalty; // extra # of second penalty due to last unstable condition
1042 ULONG CurrTxRateStableTime; // # of second in current TX rate
1043 BOOLEAN fNoisyEnvironment;
1044 BOOLEAN fLastSecAccordingRSSI;
1045 UCHAR LastSecTxRateChangeAction; // 0: no change, 1:rate UP, 2:rate down
1046 UCHAR LastTimeTxRateChangeAction; //Keep last time value of LastSecTxRateChangeAction
1047 ULONG LastTxOkCount;
1048} COUNTER_DRS, *PCOUNTER_DRS;
1049
1050//
1051// Arcfour Structure Added by PaulWu
1052//
1053typedef struct _ARCFOUR
1054{
1055 UINT X;
1056 UINT Y;
1057 UCHAR STATE[256];
1058} ARCFOURCONTEXT, *PARCFOURCONTEXT;
1059
1060// MIMO Tx parameter, ShortGI, MCS, STBC, etc. these are fields in TXWI too. just copy to TXWI.
1061typedef struct _RECEIVE_SETTING {
1062 USHORT NumOfRX:2; // MIMO. WE HAVE 3R
1063 USHORT Mode:2; //channel bandwidth 20MHz or 40 MHz
1064 USHORT ShortGI:1;
1065 USHORT STBC:2; //SPACE
1066 USHORT rsv:3;
1067 USHORT OFDM:1;
1068 USHORT MIMO:1;
1069 } RECEIVE_SETTING, *PRECEIVE_SETTING;
1070
1071// Shared key data structure
1072typedef struct _WEP_KEY {
1073 UCHAR KeyLen; // Key length for each key, 0: entry is invalid
1074 UCHAR Key[MAX_LEN_OF_KEY]; // right now we implement 4 keys, 128 bits max
1075} WEP_KEY, *PWEP_KEY;
1076
1077typedef struct _CIPHER_KEY {
1078 UCHAR Key[16]; // right now we implement 4 keys, 128 bits max
1079 UCHAR RxMic[8]; // make alignment
1080 UCHAR TxMic[8];
1081 UCHAR TxTsc[6]; // 48bit TSC value
1082 UCHAR RxTsc[6]; // 48bit TSC value
1083 UCHAR CipherAlg; // 0-none, 1:WEP64, 2:WEP128, 3:TKIP, 4:AES, 5:CKIP64, 6:CKIP128
1084 UCHAR KeyLen;
1085 UCHAR BssId[6];
1086 // Key length for each key, 0: entry is invalid
1087 UCHAR Type; // Indicate Pairwise/Group when reporting MIC error
1088} CIPHER_KEY, *PCIPHER_KEY;
1089
1090typedef struct _BBP_TUNING_STRUCT {
1091 BOOLEAN Enable;
1092 UCHAR FalseCcaCountUpperBound; // 100 per sec
1093 UCHAR FalseCcaCountLowerBound; // 10 per sec
1094 UCHAR R17LowerBound; // specified in E2PROM
1095 UCHAR R17UpperBound; // 0x68 according to David Tung
1096 UCHAR CurrentR17Value;
1097} BBP_TUNING, *PBBP_TUNING;
1098
1099typedef struct _SOFT_RX_ANT_DIVERSITY_STRUCT {
1100 UCHAR EvaluatePeriod; // 0:not evalute status, 1: evaluate status, 2: switching status
1101#ifdef RT30xx
1102 UCHAR EvaluateStableCnt;
1103#endif
1104 UCHAR Pair1PrimaryRxAnt; // 0:Ant-E1, 1:Ant-E2
1105 UCHAR Pair1SecondaryRxAnt; // 0:Ant-E1, 1:Ant-E2
1106 UCHAR Pair2PrimaryRxAnt; // 0:Ant-E3, 1:Ant-E4
1107 UCHAR Pair2SecondaryRxAnt; // 0:Ant-E3, 1:Ant-E4
1108 SHORT Pair1AvgRssi[2]; // AvgRssi[0]:E1, AvgRssi[1]:E2
1109 SHORT Pair2AvgRssi[2]; // AvgRssi[0]:E3, AvgRssi[1]:E4
1110 SHORT Pair1LastAvgRssi; //
1111 SHORT Pair2LastAvgRssi; //
1112 ULONG RcvPktNumWhenEvaluate;
1113 BOOLEAN FirstPktArrivedWhenEvaluate;
1114 RALINK_TIMER_STRUCT RxAntDiversityTimer;
1115} SOFT_RX_ANT_DIVERSITY, *PSOFT_RX_ANT_DIVERSITY;
1116
1117typedef struct _LEAP_AUTH_INFO {
1118 BOOLEAN Enabled; //Ture: Enable LEAP Authentication
1119 BOOLEAN CCKM; //Ture: Use Fast Reauthentication with CCKM
1120 UCHAR Reserve[2];
1121 UCHAR UserName[256]; //LEAP, User name
1122 ULONG UserNameLen;
1123 UCHAR Password[256]; //LEAP, User Password
1124 ULONG PasswordLen;
1125} LEAP_AUTH_INFO, *PLEAP_AUTH_INFO;
1126
1127typedef struct {
1128 UCHAR Addr[MAC_ADDR_LEN];
1129 UCHAR ErrorCode[2]; //00 01-Invalid authentication type
1130 //00 02-Authentication timeout
1131 //00 03-Challenge from AP failed
1132 //00 04-Challenge to AP failed
1133 BOOLEAN Reported;
1134} ROGUEAP_ENTRY, *PROGUEAP_ENTRY;
1135
1136typedef struct {
1137 UCHAR RogueApNr;
1138 ROGUEAP_ENTRY RogueApEntry[MAX_LEN_OF_BSS_TABLE];
1139} ROGUEAP_TABLE, *PROGUEAP_TABLE;
1140
1141typedef struct {
1142 BOOLEAN Enable;
1143 UCHAR Delta;
1144 BOOLEAN PlusSign;
1145} CCK_TX_POWER_CALIBRATE, *PCCK_TX_POWER_CALIBRATE;
1146
1147//
1148// Receive Tuple Cache Format
1149//
1150typedef struct _TUPLE_CACHE {
1151 BOOLEAN Valid;
1152 UCHAR MacAddress[MAC_ADDR_LEN];
1153 USHORT Sequence;
1154 USHORT Frag;
1155} TUPLE_CACHE, *PTUPLE_CACHE;
1156
1157//
1158// Fragment Frame structure
1159//
1160typedef struct _FRAGMENT_FRAME {
1161 PNDIS_PACKET pFragPacket;
1162 ULONG RxSize;
1163 USHORT Sequence;
1164 USHORT LastFrag;
1165 ULONG Flags; // Some extra frame information. bit 0: LLC presented
1166} FRAGMENT_FRAME, *PFRAGMENT_FRAME;
1167
1168
1169//
1170// Packet information for NdisQueryPacket
1171//
1172typedef struct _PACKET_INFO {
1173 UINT PhysicalBufferCount; // Physical breaks of buffer descripor chained
1174 UINT BufferCount ; // Number of Buffer descriptor chained
1175 UINT TotalPacketLength ; // Self explained
1176 PNDIS_BUFFER pFirstBuffer; // Pointer to first buffer descriptor
1177} PACKET_INFO, *PPACKET_INFO;
1178
1179//
1180// Tkip Key structure which RC4 key & MIC calculation
1181//
1182typedef struct _TKIP_KEY_INFO {
1183 UINT nBytesInM; // # bytes in M for MICKEY
1184 ULONG IV16;
1185 ULONG IV32;
1186 ULONG K0; // for MICKEY Low
1187 ULONG K1; // for MICKEY Hig
1188 ULONG L; // Current state for MICKEY
1189 ULONG R; // Current state for MICKEY
1190 ULONG M; // Message accumulator for MICKEY
1191 UCHAR RC4KEY[16];
1192 UCHAR MIC[8];
1193} TKIP_KEY_INFO, *PTKIP_KEY_INFO;
1194
1195//
1196// Private / Misc data, counters for driver internal use
1197//
1198typedef struct __PRIVATE_STRUC {
1199 UINT SystemResetCnt; // System reset counter
1200 UINT TxRingFullCnt; // Tx ring full occurrance number
1201 UINT PhyRxErrCnt; // PHY Rx error count, for debug purpose, might move to global counter
1202 // Variables for WEP encryption / decryption in rtmp_wep.c
1203 UINT FCSCRC32;
1204 ARCFOURCONTEXT WEPCONTEXT;
1205 // Tkip stuff
1206 TKIP_KEY_INFO Tx;
1207 TKIP_KEY_INFO Rx;
1208} PRIVATE_STRUC, *PPRIVATE_STRUC;
1209
1210// structure to tune BBP R66 (BBP TUNING)
1211typedef struct _BBP_R66_TUNING {
1212 BOOLEAN bEnable;
1213 USHORT FalseCcaLowerThreshold; // default 100
1214 USHORT FalseCcaUpperThreshold; // default 512
1215 UCHAR R66Delta;
1216 UCHAR R66CurrentValue;
1217 BOOLEAN R66LowerUpperSelect; //Before LinkUp, Used LowerBound or UpperBound as R66 value.
1218} BBP_R66_TUNING, *PBBP_R66_TUNING;
1219
1220// structure to store channel TX power
1221typedef struct _CHANNEL_TX_POWER {
1222 USHORT RemainingTimeForUse; //unit: sec
1223 UCHAR Channel;
1224 CHAR Power;
1225 CHAR Power2;
1226 UCHAR MaxTxPwr;
1227 UCHAR DfsReq;
1228} CHANNEL_TX_POWER, *PCHANNEL_TX_POWER;
1229
1230// structure to store 802.11j channel TX power
1231typedef struct _CHANNEL_11J_TX_POWER {
1232 UCHAR Channel;
1233 UCHAR BW; // BW_10 or BW_20
1234 CHAR Power;
1235 CHAR Power2;
1236 USHORT RemainingTimeForUse; //unit: sec
1237} CHANNEL_11J_TX_POWER, *PCHANNEL_11J_TX_POWER;
1238
1239typedef enum _ABGBAND_STATE_ {
1240 UNKNOWN_BAND,
1241 BG_BAND,
1242 A_BAND,
1243} ABGBAND_STATE;
1244
1245typedef struct _MLME_STRUCT {
1246 // STA state machines
1247 STATE_MACHINE CntlMachine;
1248 STATE_MACHINE AssocMachine;
1249 STATE_MACHINE AuthMachine;
1250 STATE_MACHINE AuthRspMachine;
1251 STATE_MACHINE SyncMachine;
1252 STATE_MACHINE WpaPskMachine;
1253 STATE_MACHINE LeapMachine;
1254 STATE_MACHINE AironetMachine;
1255 STATE_MACHINE_FUNC AssocFunc[ASSOC_FUNC_SIZE];
1256 STATE_MACHINE_FUNC AuthFunc[AUTH_FUNC_SIZE];
1257 STATE_MACHINE_FUNC AuthRspFunc[AUTH_RSP_FUNC_SIZE];
1258 STATE_MACHINE_FUNC SyncFunc[SYNC_FUNC_SIZE];
1259 STATE_MACHINE_FUNC WpaPskFunc[WPA_PSK_FUNC_SIZE];
1260 STATE_MACHINE_FUNC AironetFunc[AIRONET_FUNC_SIZE];
1261 STATE_MACHINE_FUNC ActFunc[ACT_FUNC_SIZE];
1262 // Action
1263 STATE_MACHINE ActMachine;
1264
1265 ULONG ChannelQuality; // 0..100, Channel Quality Indication for Roaming
1266 ULONG Now32; // latch the value of NdisGetSystemUpTime()
1267 ULONG LastSendNULLpsmTime;
1268
1269 BOOLEAN bRunning;
1270 NDIS_SPIN_LOCK TaskLock;
1271 MLME_QUEUE Queue;
1272
1273 UINT ShiftReg;
1274
1275 RALINK_TIMER_STRUCT PeriodicTimer;
1276 RALINK_TIMER_STRUCT APSDPeriodicTimer;
1277 RALINK_TIMER_STRUCT LinkDownTimer;
1278 RALINK_TIMER_STRUCT LinkUpTimer;
1279 ULONG PeriodicRound;
1280 ULONG OneSecPeriodicRound;
1281
1282 UCHAR RealRxPath;
1283 BOOLEAN bLowThroughput;
1284 BOOLEAN bEnableAutoAntennaCheck;
1285 RALINK_TIMER_STRUCT RxAntEvalTimer;
1286
1287#ifdef RT2870
1288 UCHAR CaliBW40RfR24;
1289 UCHAR CaliBW20RfR24;
1290#endif // RT2870 //
1291
1292} MLME_STRUCT, *PMLME_STRUCT;
1293
1294// structure for radar detection and channel switch
1295typedef struct _RADAR_DETECT_STRUCT {
1296 UCHAR CSCount; //Channel switch counter
1297 UCHAR CSPeriod; //Channel switch period (beacon count)
1298 UCHAR RDCount; //Radar detection counter
1299 UCHAR RDMode; //Radar Detection mode
1300 UCHAR RDDurRegion; //Radar detection duration region
1301 UCHAR BBPR16;
1302 UCHAR BBPR17;
1303 UCHAR BBPR18;
1304 UCHAR BBPR21;
1305 UCHAR BBPR22;
1306 UCHAR BBPR64;
1307 ULONG InServiceMonitorCount; // unit: sec
1308 UINT8 DfsSessionTime;
1309 BOOLEAN bFastDfs;
1310 UINT8 ChMovingTime;
1311 UINT8 LongPulseRadarTh;
1312} RADAR_DETECT_STRUCT, *PRADAR_DETECT_STRUCT;
1313
1314typedef enum _REC_BLOCKACK_STATUS
1315{
1316 Recipient_NONE=0,
1317 Recipient_USED,
1318 Recipient_HandleRes,
1319 Recipient_Accept
1320} REC_BLOCKACK_STATUS, *PREC_BLOCKACK_STATUS;
1321
1322typedef enum _ORI_BLOCKACK_STATUS
1323{
1324 Originator_NONE=0,
1325 Originator_USED,
1326 Originator_WaitRes,
1327 Originator_Done
1328} ORI_BLOCKACK_STATUS, *PORI_BLOCKACK_STATUS;
1329
1330typedef struct _BA_ORI_ENTRY{
1331 UCHAR Wcid;
1332 UCHAR TID;
1333 UCHAR BAWinSize;
1334 UCHAR Token;
1335// Sequence is to fill every outgoing QoS DATA frame's sequence field in 802.11 header.
1336 USHORT Sequence;
1337 USHORT TimeOutValue;
1338 ORI_BLOCKACK_STATUS ORI_BA_Status;
1339 RALINK_TIMER_STRUCT ORIBATimer;
1340 PVOID pAdapter;
1341} BA_ORI_ENTRY, *PBA_ORI_ENTRY;
1342
1343typedef struct _BA_REC_ENTRY {
1344 UCHAR Wcid;
1345 UCHAR TID;
1346 UCHAR BAWinSize; // 7.3.1.14. each buffer is capable of holding a max AMSDU or MSDU.
1347 USHORT LastIndSeq;
1348 USHORT TimeOutValue;
1349 RALINK_TIMER_STRUCT RECBATimer;
1350 ULONG LastIndSeqAtTimer;
1351 ULONG nDropPacket;
1352 ULONG rcvSeq;
1353 REC_BLOCKACK_STATUS REC_BA_Status;
1354 NDIS_SPIN_LOCK RxReRingLock; // Rx Ring spinlock
1355 PVOID pAdapter;
1356 struct reordering_list list;
1357} BA_REC_ENTRY, *PBA_REC_ENTRY;
1358
1359
1360typedef struct {
1361 ULONG numAsRecipient; // I am recipient of numAsRecipient clients. These client are in the BARecEntry[]
1362 ULONG numAsOriginator; // I am originator of numAsOriginator clients. These clients are in the BAOriEntry[]
1363 BA_ORI_ENTRY BAOriEntry[MAX_LEN_OF_BA_ORI_TABLE];
1364 BA_REC_ENTRY BARecEntry[MAX_LEN_OF_BA_REC_TABLE];
1365} BA_TABLE, *PBA_TABLE;
1366
1367//For QureyBATableOID use;
1368typedef struct PACKED _OID_BA_REC_ENTRY{
1369 UCHAR MACAddr[MAC_ADDR_LEN];
1370 UCHAR BaBitmap; // if (BaBitmap&(1<<TID)), this session with{MACAddr, TID}exists, so read BufSize[TID] for BufferSize
1371 UCHAR rsv;
1372 UCHAR BufSize[8];
1373 REC_BLOCKACK_STATUS REC_BA_Status[8];
1374} OID_BA_REC_ENTRY, *POID_BA_REC_ENTRY;
1375
1376//For QureyBATableOID use;
1377typedef struct PACKED _OID_BA_ORI_ENTRY{
1378 UCHAR MACAddr[MAC_ADDR_LEN];
1379 UCHAR BaBitmap; // if (BaBitmap&(1<<TID)), this session with{MACAddr, TID}exists, so read BufSize[TID] for BufferSize, read ORI_BA_Status[TID] for status
1380 UCHAR rsv;
1381 UCHAR BufSize[8];
1382 ORI_BLOCKACK_STATUS ORI_BA_Status[8];
1383} OID_BA_ORI_ENTRY, *POID_BA_ORI_ENTRY;
1384
1385typedef struct _QUERYBA_TABLE{
1386 OID_BA_ORI_ENTRY BAOriEntry[32];
1387 OID_BA_REC_ENTRY BARecEntry[32];
1388 UCHAR OriNum;// Number of below BAOriEntry
1389 UCHAR RecNum;// Number of below BARecEntry
1390} QUERYBA_TABLE, *PQUERYBA_TABLE;
1391
1392typedef union _BACAP_STRUC {
1393 struct {
1394 UINT32 RxBAWinLimit:8;
1395 UINT32 TxBAWinLimit:8;
1396 UINT32 AutoBA:1; // automatically BA
1397 UINT32 Policy:2; // 0: DELAY_BA 1:IMMED_BA (//BA Policy subfiled value in ADDBA frame) 2:BA-not use
1398 UINT32 MpduDensity:3;
1399 UINT32 AmsduEnable:1; //Enable AMSDU transmisstion
1400 UINT32 AmsduSize:1; // 0:3839, 1:7935 bytes. UINT MSDUSizeToBytes[] = { 3839, 7935};
1401 UINT32 MMPSmode:2; // MIMO power save more, 0:static, 1:dynamic, 2:rsv, 3:mimo enable
1402 UINT32 bHtAdhoc:1; // adhoc can use ht rate.
1403 UINT32 b2040CoexistScanSup:1; //As Sta, support do 2040 coexistence scan for AP. As Ap, support monitor trigger event to check if can use BW 40MHz.
1404 UINT32 :4;
1405 } field;
1406 UINT32 word;
1407} BACAP_STRUC, *PBACAP_STRUC;
1408
1409//This structure is for all 802.11n card InterOptibilityTest action. Reset all Num every n second. (Details see MLMEPeriodic)
1410typedef struct _IOT_STRUC {
1411 UCHAR Threshold[2];
1412 UCHAR ReorderTimeOutNum[MAX_LEN_OF_BA_REC_TABLE]; // compare with threshold[0]
1413 UCHAR RefreshNum[MAX_LEN_OF_BA_REC_TABLE]; // compare with threshold[1]
1414 ULONG OneSecInWindowCount;
1415 ULONG OneSecFrameDuplicateCount;
1416 ULONG OneSecOutWindowCount;
1417 UCHAR DelOriAct;
1418 UCHAR DelRecAct;
1419 UCHAR RTSShortProt;
1420 UCHAR RTSLongProt;
1421 BOOLEAN bRTSLongProtOn;
1422 BOOLEAN bLastAtheros;
1423 BOOLEAN bCurrentAtheros;
1424 BOOLEAN bNowAtherosBurstOn;
1425 BOOLEAN bNextDisableRxBA;
1426 BOOLEAN bToggle;
1427} IOT_STRUC, *PIOT_STRUC;
1428
1429// This is the registry setting for 802.11n transmit setting. Used in advanced page.
1430typedef union _REG_TRANSMIT_SETTING {
1431 struct {
1432 UINT32 rsv0:10;
1433 UINT32 TxBF:1;
1434 UINT32 BW:1; //channel bandwidth 20MHz or 40 MHz
1435 UINT32 ShortGI:1;
1436 UINT32 STBC:1; //SPACE
1437 UINT32 TRANSNO:2;
1438 UINT32 HTMODE:1;
1439 UINT32 EXTCHA:2;
1440 UINT32 rsv:13;
1441 } field;
1442 UINT32 word;
1443} REG_TRANSMIT_SETTING, *PREG_TRANSMIT_SETTING;
1444
1445typedef union _DESIRED_TRANSMIT_SETTING {
1446 struct {
1447 USHORT MCS:7; // MCS
1448 USHORT PhyMode:4;
1449 USHORT FixedTxMode:2; // If MCS isn't AUTO, fix rate in CCK, OFDM or HT mode.
1450 USHORT rsv:3;
1451 } field;
1452 USHORT word;
1453 } DESIRED_TRANSMIT_SETTING, *PDESIRED_TRANSMIT_SETTING;
1454
1455typedef struct {
1456 BOOLEAN IsRecipient;
1457 UCHAR MACAddr[MAC_ADDR_LEN];
1458 UCHAR TID;
1459 UCHAR nMSDU;
1460 USHORT TimeOut;
1461 BOOLEAN bAllTid; // If True, delete all TID for BA sessions with this MACaddr.
1462} OID_ADD_BA_ENTRY, *POID_ADD_BA_ENTRY;
1463
1464//
1465// Multiple SSID structure
1466//
1467#define WLAN_MAX_NUM_OF_TIM ((MAX_LEN_OF_MAC_TABLE >> 3) + 1) /* /8 + 1 */
1468#define WLAN_CT_TIM_BCMC_OFFSET 0 /* unit: 32B */
1469
1470/* clear bcmc TIM bit */
1471#define WLAN_MR_TIM_BCMC_CLEAR(apidx) \
1472 pAd->ApCfg.MBSSID[apidx].TimBitmaps[WLAN_CT_TIM_BCMC_OFFSET] &= ~BIT8[0];
1473
1474/* set bcmc TIM bit */
1475#define WLAN_MR_TIM_BCMC_SET(apidx) \
1476 pAd->ApCfg.MBSSID[apidx].TimBitmaps[WLAN_CT_TIM_BCMC_OFFSET] |= BIT8[0];
1477
1478/* clear a station PS TIM bit */
1479#define WLAN_MR_TIM_BIT_CLEAR(ad_p, apidx, wcid) \
1480 { UCHAR tim_offset = wcid >> 3; \
1481 UCHAR bit_offset = wcid & 0x7; \
1482 ad_p->ApCfg.MBSSID[apidx].TimBitmaps[tim_offset] &= (~BIT8[bit_offset]); }
1483
1484/* set a station PS TIM bit */
1485#define WLAN_MR_TIM_BIT_SET(ad_p, apidx, wcid) \
1486 { UCHAR tim_offset = wcid >> 3; \
1487 UCHAR bit_offset = wcid & 0x7; \
1488 ad_p->ApCfg.MBSSID[apidx].TimBitmaps[tim_offset] |= BIT8[bit_offset]; }
1489
1490#ifdef RT2870
1491#define BEACON_BITMAP_MASK 0xff
1492typedef struct _BEACON_SYNC_STRUCT_
1493{
1494 UCHAR BeaconBuf[HW_BEACON_MAX_COUNT][HW_BEACON_OFFSET];
1495 UCHAR BeaconTxWI[HW_BEACON_MAX_COUNT][TXWI_SIZE];
1496 ULONG TimIELocationInBeacon[HW_BEACON_MAX_COUNT];
1497 ULONG CapabilityInfoLocationInBeacon[HW_BEACON_MAX_COUNT];
1498 BOOLEAN EnableBeacon; // trigger to enable beacon transmission.
1499 UCHAR BeaconBitMap; // NOTE: If the MAX_MBSSID_NUM is larger than 8, this parameter need to change.
1500 UCHAR DtimBitOn; // NOTE: If the MAX_MBSSID_NUM is larger than 8, this parameter need to change.
1501}BEACON_SYNC_STRUCT;
1502#endif // RT2870 //
1503
1504typedef struct _MULTISSID_STRUCT {
1505 UCHAR Bssid[MAC_ADDR_LEN];
1506 UCHAR SsidLen;
1507 CHAR Ssid[MAX_LEN_OF_SSID];
1508 USHORT CapabilityInfo;
1509
1510 PNET_DEV MSSIDDev;
1511
1512 NDIS_802_11_AUTHENTICATION_MODE AuthMode;
1513 NDIS_802_11_WEP_STATUS WepStatus;
1514 NDIS_802_11_WEP_STATUS GroupKeyWepStatus;
1515 WPA_MIX_PAIR_CIPHER WpaMixPairCipher;
1516
1517 ULONG TxCount;
1518 ULONG RxCount;
1519 ULONG ReceivedByteCount;
1520 ULONG TransmittedByteCount;
1521 ULONG RxErrorCount;
1522 ULONG RxDropCount;
1523
1524 HTTRANSMIT_SETTING HTPhyMode, MaxHTPhyMode, MinHTPhyMode;// For transmit phy setting in TXWI.
1525 RT_HT_PHY_INFO DesiredHtPhyInfo;
1526 DESIRED_TRANSMIT_SETTING DesiredTransmitSetting; // Desired transmit setting. this is for reading registry setting only. not useful.
1527 BOOLEAN bAutoTxRateSwitch;
1528
1529 UCHAR DefaultKeyId;
1530
1531 UCHAR TxRate; // RATE_1, RATE_2, RATE_5_5, RATE_11, ...
1532 UCHAR DesiredRates[MAX_LEN_OF_SUPPORTED_RATES];// OID_802_11_DESIRED_RATES
1533 UCHAR DesiredRatesIndex;
1534 UCHAR MaxTxRate; // RATE_1, RATE_2, RATE_5_5, RATE_11
1535
1536 UCHAR TimBitmaps[WLAN_MAX_NUM_OF_TIM];
1537
1538 // WPA
1539 UCHAR GMK[32];
1540 UCHAR PMK[32];
1541 UCHAR GTK[32];
1542 BOOLEAN IEEE8021X;
1543 BOOLEAN PreAuth;
1544 UCHAR GNonce[32];
1545 UCHAR PortSecured;
1546 NDIS_802_11_PRIVACY_FILTER PrivacyFilter;
1547 UCHAR BANClass3Data;
1548 ULONG IsolateInterStaTraffic;
1549
1550 UCHAR RSNIE_Len[2];
1551 UCHAR RSN_IE[2][MAX_LEN_OF_RSNIE];
1552
1553
1554 UCHAR TimIELocationInBeacon;
1555 UCHAR CapabilityInfoLocationInBeacon;
1556 // outgoing BEACON frame buffer and corresponding TXWI
1557 // PTXWI_STRUC BeaconTxWI; //
1558 CHAR BeaconBuf[MAX_BEACON_SIZE]; // NOTE: BeaconBuf should be 4-byte aligned
1559
1560 BOOLEAN bHideSsid;
1561 UINT16 StationKeepAliveTime; // unit: second
1562
1563 USHORT VLAN_VID;
1564 USHORT VLAN_Priority;
1565
1566 RT_802_11_ACL AccessControlList;
1567
1568 // EDCA Qos
1569 BOOLEAN bWmmCapable; // 0:disable WMM, 1:enable WMM
1570 BOOLEAN bDLSCapable; // 0:disable DLS, 1:enable DLS
1571
1572 UCHAR DlsPTK[64]; // Due to windows dirver count on meetinghouse to handle 4-way shake
1573
1574 // For 802.1x daemon setting per BSS
1575 UCHAR radius_srv_num;
1576 RADIUS_SRV_INFO radius_srv_info[MAX_RADIUS_SRV_NUM];
1577
1578#ifdef RTL865X_SOC
1579 unsigned int mylinkid;
1580#endif
1581
1582
1583 UINT32 RcvdConflictSsidCount;
1584 UINT32 RcvdSpoofedAssocRespCount;
1585 UINT32 RcvdSpoofedReassocRespCount;
1586 UINT32 RcvdSpoofedProbeRespCount;
1587 UINT32 RcvdSpoofedBeaconCount;
1588 UINT32 RcvdSpoofedDisassocCount;
1589 UINT32 RcvdSpoofedAuthCount;
1590 UINT32 RcvdSpoofedDeauthCount;
1591 UINT32 RcvdSpoofedUnknownMgmtCount;
1592 UINT32 RcvdReplayAttackCount;
1593
1594 CHAR RssiOfRcvdConflictSsid;
1595 CHAR RssiOfRcvdSpoofedAssocResp;
1596 CHAR RssiOfRcvdSpoofedReassocResp;
1597 CHAR RssiOfRcvdSpoofedProbeResp;
1598 CHAR RssiOfRcvdSpoofedBeacon;
1599 CHAR RssiOfRcvdSpoofedDisassoc;
1600 CHAR RssiOfRcvdSpoofedAuth;
1601 CHAR RssiOfRcvdSpoofedDeauth;
1602 CHAR RssiOfRcvdSpoofedUnknownMgmt;
1603 CHAR RssiOfRcvdReplayAttack;
1604
1605 BOOLEAN bBcnSntReq;
1606 UCHAR BcnBufIdx;
1607} MULTISSID_STRUCT, *PMULTISSID_STRUCT;
1608
1609// configuration common to OPMODE_AP as well as OPMODE_STA
1610typedef struct _COMMON_CONFIG {
1611
1612 BOOLEAN bCountryFlag;
1613 UCHAR CountryCode[3];
1614 UCHAR Geography;
1615 UCHAR CountryRegion; // Enum of country region, 0:FCC, 1:IC, 2:ETSI, 3:SPAIN, 4:France, 5:MKK, 6:MKK1, 7:Israel
1616 UCHAR CountryRegionForABand; // Enum of country region for A band
1617 UCHAR PhyMode; // PHY_11A, PHY_11B, PHY_11BG_MIXED, PHY_ABG_MIXED
1618 USHORT Dsifs; // in units of usec
1619 ULONG PacketFilter; // Packet filter for receiving
1620
1621 CHAR Ssid[MAX_LEN_OF_SSID]; // NOT NULL-terminated
1622 UCHAR SsidLen; // the actual ssid length in used
1623 UCHAR LastSsidLen; // the actual ssid length in used
1624 CHAR LastSsid[MAX_LEN_OF_SSID]; // NOT NULL-terminated
1625 UCHAR LastBssid[MAC_ADDR_LEN];
1626
1627 UCHAR Bssid[MAC_ADDR_LEN];
1628 USHORT BeaconPeriod;
1629 UCHAR Channel;
1630 UCHAR CentralChannel; // Central Channel when using 40MHz is indicating. not real channel.
1631
1632 UCHAR SupRate[MAX_LEN_OF_SUPPORTED_RATES];
1633 UCHAR SupRateLen;
1634 UCHAR ExtRate[MAX_LEN_OF_SUPPORTED_RATES];
1635 UCHAR ExtRateLen;
1636 UCHAR DesireRate[MAX_LEN_OF_SUPPORTED_RATES]; // OID_802_11_DESIRED_RATES
1637 UCHAR MaxDesiredRate;
1638 UCHAR ExpectedACKRate[MAX_LEN_OF_SUPPORTED_RATES];
1639
1640 ULONG BasicRateBitmap; // backup basic ratebitmap
1641
1642 BOOLEAN bAPSDCapable;
1643 BOOLEAN bInServicePeriod;
1644 BOOLEAN bAPSDAC_BE;
1645 BOOLEAN bAPSDAC_BK;
1646 BOOLEAN bAPSDAC_VI;
1647 BOOLEAN bAPSDAC_VO;
1648 BOOLEAN bNeedSendTriggerFrame;
1649 BOOLEAN bAPSDForcePowerSave; // Force power save mode, should only use in APSD-STAUT
1650 ULONG TriggerTimerCount;
1651 UCHAR MaxSPLength;
1652 UCHAR BBPCurrentBW; // BW_10, BW_20, BW_40
1653 REG_TRANSMIT_SETTING RegTransmitSetting; //registry transmit setting. this is for reading registry setting only. not useful.
1654 UCHAR TxRate; // Same value to fill in TXD. TxRate is 6-bit
1655 UCHAR MaxTxRate; // RATE_1, RATE_2, RATE_5_5, RATE_11
1656 UCHAR TxRateIndex; // Tx rate index in RateSwitchTable
1657 UCHAR TxRateTableSize; // Valid Tx rate table size in RateSwitchTable
1658 UCHAR MinTxRate; // RATE_1, RATE_2, RATE_5_5, RATE_11
1659 UCHAR RtsRate; // RATE_xxx
1660 HTTRANSMIT_SETTING MlmeTransmit; // MGMT frame PHY rate setting when operatin at Ht rate.
1661 UCHAR MlmeRate; // RATE_xxx, used to send MLME frames
1662 UCHAR BasicMlmeRate; // Default Rate for sending MLME frames
1663
1664 USHORT RtsThreshold; // in unit of BYTE
1665 USHORT FragmentThreshold; // in unit of BYTE
1666
1667 UCHAR TxPower; // in unit of mW
1668 ULONG TxPowerPercentage; // 0~100 %
1669 ULONG TxPowerDefault; // keep for TxPowerPercentage
1670
1671 BACAP_STRUC BACapability; // NO USE = 0XFF ; IMMED_BA =1 ; DELAY_BA=0
1672 BACAP_STRUC REGBACapability; // NO USE = 0XFF ; IMMED_BA =1 ; DELAY_BA=0
1673
1674 IOT_STRUC IOTestParm; // 802.11n InterOpbility Test Parameter;
1675 ULONG TxPreamble; // Rt802_11PreambleLong, Rt802_11PreambleShort, Rt802_11PreambleAuto
1676 BOOLEAN bUseZeroToDisableFragment; // Microsoft use 0 as disable
1677 ULONG UseBGProtection; // 0: auto, 1: always use, 2: always not use
1678 BOOLEAN bUseShortSlotTime; // 0: disable, 1 - use short slot (9us)
1679 BOOLEAN bEnableTxBurst; // 1: enble TX PACKET BURST, 0: disable TX PACKET BURST
1680 BOOLEAN bAggregationCapable; // 1: enable TX aggregation when the peer supports it
1681 BOOLEAN bPiggyBackCapable; // 1: enable TX piggy-back according MAC's version
1682 BOOLEAN bIEEE80211H; // 1: enable IEEE802.11h spec.
1683 ULONG DisableOLBCDetect; // 0: enable OLBC detect; 1 disable OLBC detect
1684
1685 BOOLEAN bRdg;
1686
1687 BOOLEAN bWmmCapable; // 0:disable WMM, 1:enable WMM
1688 QOS_CAPABILITY_PARM APQosCapability; // QOS capability of the current associated AP
1689 EDCA_PARM APEdcaParm; // EDCA parameters of the current associated AP
1690 QBSS_LOAD_PARM APQbssLoad; // QBSS load of the current associated AP
1691 UCHAR AckPolicy[4]; // ACK policy of the specified AC. see ACK_xxx
1692 BOOLEAN bDLSCapable; // 0:disable DLS, 1:enable DLS
1693 // a bitmap of BOOLEAN flags. each bit represent an operation status of a particular
1694 // BOOLEAN control, either ON or OFF. These flags should always be accessed via
1695 // OPSTATUS_TEST_FLAG(), OPSTATUS_SET_FLAG(), OP_STATUS_CLEAR_FLAG() macros.
1696 // see fOP_STATUS_xxx in RTMP_DEF.C for detail bit definition
1697 ULONG OpStatusFlags;
1698
1699 BOOLEAN NdisRadioStateOff; //For HCT 12.0, set this flag to TRUE instead of called MlmeRadioOff.
1700 ABGBAND_STATE BandState; // For setting BBP used on B/G or A mode.
1701#ifdef RT30xx
1702 BOOLEAN bRxAntDiversity; // 0:disable, 1:enable Software Rx Antenna Diversity.
1703#endif
1704
1705 // IEEE802.11H--DFS.
1706 RADAR_DETECT_STRUCT RadarDetect;
1707
1708 // HT
1709 UCHAR BASize; // USer desired BAWindowSize. Should not exceed our max capability
1710 //RT_HT_CAPABILITY SupportedHtPhy;
1711 RT_HT_CAPABILITY DesiredHtPhy;
1712 HT_CAPABILITY_IE HtCapability;
1713 ADD_HT_INFO_IE AddHTInfo; // Useful as AP.
1714 //This IE is used with channel switch announcement element when changing to a new 40MHz.
1715 //This IE is included in channel switch ammouncement frames 7.4.1.5, beacons, probe Rsp.
1716 NEW_EXT_CHAN_IE NewExtChanOffset; //7.3.2.20A, 1 if extension channel is above the control channel, 3 if below, 0 if not present
1717
1718 BOOLEAN bHTProtect;
1719 BOOLEAN bMIMOPSEnable;
1720 BOOLEAN bBADecline;
1721 BOOLEAN bDisableReordering;
1722 BOOLEAN bForty_Mhz_Intolerant;
1723 BOOLEAN bExtChannelSwitchAnnouncement;
1724 BOOLEAN bRcvBSSWidthTriggerEvents;
1725 ULONG LastRcvBSSWidthTriggerEventsTime;
1726
1727 UCHAR TxBASize;
1728
1729 // Enable wireless event
1730 BOOLEAN bWirelessEvent;
1731 BOOLEAN bWiFiTest; // Enable this parameter for WiFi test
1732
1733 // Tx & Rx Stream number selection
1734 UCHAR TxStream;
1735 UCHAR RxStream;
1736
1737 // transmit phy mode, trasmit rate for Multicast.
1738#ifdef MCAST_RATE_SPECIFIC
1739 UCHAR McastTransmitMcs;
1740 UCHAR McastTransmitPhyMode;
1741#endif // MCAST_RATE_SPECIFIC //
1742
1743 BOOLEAN bHardwareRadio; // Hardware controlled Radio enabled
1744
1745#ifdef RT2870
1746 BOOLEAN bMultipleIRP; // Multiple Bulk IN flag
1747 UCHAR NumOfBulkInIRP; // if bMultipleIRP == TRUE, NumOfBulkInIRP will be 4 otherwise be 1
1748 RT_HT_CAPABILITY SupportedHtPhy;
1749 ULONG MaxPktOneTxBulk;
1750 UCHAR TxBulkFactor;
1751 UCHAR RxBulkFactor;
1752
1753 BEACON_SYNC_STRUCT *pBeaconSync;
1754 RALINK_TIMER_STRUCT BeaconUpdateTimer;
1755 UINT32 BeaconAdjust;
1756 UINT32 BeaconFactor;
1757 UINT32 BeaconRemain;
1758#endif // RT2870 //
1759
1760
1761 NDIS_SPIN_LOCK MeasureReqTabLock;
1762 PMEASURE_REQ_TAB pMeasureReqTab;
1763
1764 NDIS_SPIN_LOCK TpcReqTabLock;
1765 PTPC_REQ_TAB pTpcReqTab;
1766
1767 // transmit phy mode, trasmit rate for Multicast.
1768#ifdef MCAST_RATE_SPECIFIC
1769 HTTRANSMIT_SETTING MCastPhyMode;
1770#endif // MCAST_RATE_SPECIFIC //
1771} COMMON_CONFIG, *PCOMMON_CONFIG;
1772
1773/* Modified by Wu Xi-Kun 4/21/2006 */
1774// STA configuration and status
1775typedef struct _STA_ADMIN_CONFIG {
1776 // GROUP 1 -
1777 // User configuration loaded from Registry, E2PROM or OID_xxx. These settings describe
1778 // the user intended configuration, but not necessary fully equal to the final
1779 // settings in ACTIVE BSS after negotiation/compromize with the BSS holder (either
1780 // AP or IBSS holder).
1781 // Once initialized, user configuration can only be changed via OID_xxx
1782 UCHAR BssType; // BSS_INFRA or BSS_ADHOC
1783 USHORT AtimWin; // used when starting a new IBSS
1784
1785 // GROUP 2 -
1786 // User configuration loaded from Registry, E2PROM or OID_xxx. These settings describe
1787 // the user intended configuration, and should be always applied to the final
1788 // settings in ACTIVE BSS without compromising with the BSS holder.
1789 // Once initialized, user configuration can only be changed via OID_xxx
1790 UCHAR RssiTrigger;
1791 UCHAR RssiTriggerMode; // RSSI_TRIGGERED_UPON_BELOW_THRESHOLD or RSSI_TRIGGERED_UPON_EXCCEED_THRESHOLD
1792 USHORT DefaultListenCount; // default listen count;
1793 ULONG WindowsPowerMode; // Power mode for AC power
1794 ULONG WindowsBatteryPowerMode; // Power mode for battery if exists
1795 BOOLEAN bWindowsACCAMEnable; // Enable CAM power mode when AC on
1796 BOOLEAN bAutoReconnect; // Set to TRUE when setting OID_802_11_SSID with no matching BSSID
1797 ULONG WindowsPowerProfile; // Windows power profile, for NDIS5.1 PnP
1798
1799 // MIB:ieee802dot11.dot11smt(1).dot11StationConfigTable(1)
1800 USHORT Psm; // power management mode (PWR_ACTIVE|PWR_SAVE)
1801 USHORT DisassocReason;
1802 UCHAR DisassocSta[MAC_ADDR_LEN];
1803 USHORT DeauthReason;
1804 UCHAR DeauthSta[MAC_ADDR_LEN];
1805 USHORT AuthFailReason;
1806 UCHAR AuthFailSta[MAC_ADDR_LEN];
1807
1808 NDIS_802_11_PRIVACY_FILTER PrivacyFilter; // PrivacyFilter enum for 802.1X
1809 NDIS_802_11_AUTHENTICATION_MODE AuthMode; // This should match to whatever microsoft defined
1810 NDIS_802_11_WEP_STATUS WepStatus;
1811 NDIS_802_11_WEP_STATUS OrigWepStatus; // Original wep status set from OID
1812
1813 // Add to support different cipher suite for WPA2/WPA mode
1814 NDIS_802_11_ENCRYPTION_STATUS GroupCipher; // Multicast cipher suite
1815 NDIS_802_11_ENCRYPTION_STATUS PairCipher; // Unicast cipher suite
1816 BOOLEAN bMixCipher; // Indicate current Pair & Group use different cipher suites
1817 USHORT RsnCapability;
1818
1819 NDIS_802_11_WEP_STATUS GroupKeyWepStatus;
1820
1821 UCHAR PMK[32]; // WPA PSK mode PMK
1822 UCHAR PTK[64]; // WPA PSK mode PTK
1823 UCHAR GTK[32]; // GTK from authenticator
1824 BSSID_INFO SavedPMK[PMKID_NO];
1825 UINT SavedPMKNum; // Saved PMKID number
1826
1827 UCHAR DefaultKeyId;
1828
1829
1830 // WPA 802.1x port control, WPA_802_1X_PORT_SECURED, WPA_802_1X_PORT_NOT_SECURED
1831 UCHAR PortSecured;
1832
1833 // For WPA countermeasures
1834 ULONG LastMicErrorTime; // record last MIC error time
1835 ULONG MicErrCnt; // Should be 0, 1, 2, then reset to zero (after disassoiciation).
1836 BOOLEAN bBlockAssoc; // Block associate attempt for 60 seconds after counter measure occurred.
1837 // For WPA-PSK supplicant state
1838 WPA_STATE WpaState; // Default is SS_NOTUSE and handled by microsoft 802.1x
1839 UCHAR ReplayCounter[8];
1840 UCHAR ANonce[32]; // ANonce for WPA-PSK from aurhenticator
1841 UCHAR SNonce[32]; // SNonce for WPA-PSK
1842
1843 UCHAR LastSNR0; // last received BEACON's SNR
1844 UCHAR LastSNR1; // last received BEACON's SNR for 2nd antenna
1845 RSSI_SAMPLE RssiSample;
1846 ULONG NumOfAvgRssiSample;
1847
1848 ULONG LastBeaconRxTime; // OS's timestamp of the last BEACON RX time
1849 ULONG Last11bBeaconRxTime; // OS's timestamp of the last 11B BEACON RX time
1850 ULONG Last11gBeaconRxTime; // OS's timestamp of the last 11G BEACON RX time
1851 ULONG Last20NBeaconRxTime; // OS's timestamp of the last 20MHz N BEACON RX time
1852
1853 ULONG LastScanTime; // Record last scan time for issue BSSID_SCAN_LIST
1854 ULONG ScanCnt; // Scan counts since most recent SSID, BSSID, SCAN OID request
1855 BOOLEAN bSwRadio; // Software controlled Radio On/Off, TRUE: On
1856 BOOLEAN bHwRadio; // Hardware controlled Radio On/Off, TRUE: On
1857 BOOLEAN bRadio; // Radio state, And of Sw & Hw radio state
1858 BOOLEAN bHardwareRadio; // Hardware controlled Radio enabled
1859 BOOLEAN bShowHiddenSSID; // Show all known SSID in SSID list get operation
1860
1861
1862 // New for WPA, windows want us to to keep association information and
1863 // Fixed IEs from last association response
1864 NDIS_802_11_ASSOCIATION_INFORMATION AssocInfo;
1865 USHORT ReqVarIELen; // Length of next VIE include EID & Length
1866 UCHAR ReqVarIEs[MAX_VIE_LEN]; // The content saved here should be little-endian format.
1867 USHORT ResVarIELen; // Length of next VIE include EID & Length
1868 UCHAR ResVarIEs[MAX_VIE_LEN];
1869
1870 UCHAR RSNIE_Len;
1871 UCHAR RSN_IE[MAX_LEN_OF_RSNIE]; // The content saved here should be little-endian format.
1872
1873 // New variables used for CCX 1.0
1874 BOOLEAN bCkipOn;
1875 BOOLEAN bCkipCmicOn;
1876 UCHAR CkipFlag;
1877 UCHAR GIV[3]; //for CCX iv
1878 UCHAR RxSEQ[4];
1879 UCHAR TxSEQ[4];
1880 UCHAR CKIPMIC[4];
1881 UCHAR LeapAuthMode;
1882 LEAP_AUTH_INFO LeapAuthInfo;
1883 UCHAR HashPwd[16];
1884 UCHAR NetworkChallenge[8];
1885 UCHAR NetworkChallengeResponse[24];
1886 UCHAR PeerChallenge[8];
1887
1888 UCHAR PeerChallengeResponse[24];
1889 UCHAR SessionKey[16]; //Network session keys (NSK)
1890 RALINK_TIMER_STRUCT LeapAuthTimer;
1891 ROGUEAP_TABLE RogueApTab; //Cisco CCX1 Rogue AP Detection
1892
1893 // New control flags for CCX
1894 CCX_CONTROL CCXControl; // Master administration state
1895 BOOLEAN CCXEnable; // Actual CCX state
1896 UCHAR CCXScanChannel; // Selected channel for CCX beacon request
1897 USHORT CCXScanTime; // Time out to wait for beacon and probe response
1898 UCHAR CCXReqType; // Current processing CCX request type
1899 BSS_TABLE CCXBssTab; // BSS Table
1900 UCHAR FrameReportBuf[2048]; // Buffer for creating frame report
1901 USHORT FrameReportLen; // Current Frame report length
1902 ULONG CLBusyBytes; // Save the total bytes received durning channel load scan time
1903 USHORT RPIDensity[8]; // Array for RPI density collection
1904 // Start address of each BSS table within FrameReportBuf
1905 // It's important to update the RxPower of the corresponding Bss
1906 USHORT BssReportOffset[MAX_LEN_OF_BSS_TABLE];
1907 USHORT BeaconToken; // Token for beacon report
1908 ULONG LastBssIndex; // Most current reported Bss index
1909 RM_REQUEST_ACTION MeasurementRequest[16]; // Saved measurement request
1910 UCHAR RMReqCnt; // Number of measurement request saved.
1911 UCHAR CurrentRMReqIdx; // Number of measurement request saved.
1912 BOOLEAN ParallelReq; // Parallel measurement, only one request performed,
1913 // It must be the same channel with maximum duration
1914 USHORT ParallelDuration; // Maximum duration for parallel measurement
1915 UCHAR ParallelChannel; // Only one channel with parallel measurement
1916 USHORT IAPPToken; // IAPP dialog token
1917 UCHAR CCXQosECWMin; // Cisco QOS ECWMin for AC 0
1918 UCHAR CCXQosECWMax; // Cisco QOS ECWMax for AC 0
1919 // Hack for channel load and noise histogram parameters
1920 UCHAR NHFactor; // Parameter for Noise histogram
1921 UCHAR CLFactor; // Parameter for channel load
1922
1923 UCHAR KRK[16]; //Key Refresh Key.
1924 UCHAR BTK[32]; //Base Transient Key
1925 BOOLEAN CCKMLinkUpFlag;
1926 ULONG CCKMRN; //(Re)Association request number.
1927 LARGE_INTEGER CCKMBeaconAtJoinTimeStamp; //TSF timer for Re-assocaite to the new AP
1928 UCHAR AironetCellPowerLimit; //in dBm
1929 UCHAR AironetIPAddress[4]; //eg. 192.168.1.1
1930 BOOLEAN CCXAdjacentAPReportFlag; //flag for determining report Assoc Lost time
1931 CHAR CCXAdjacentAPSsid[MAX_LEN_OF_SSID]; //Adjacent AP's SSID report
1932 UCHAR CCXAdjacentAPSsidLen; // the actual ssid length in used
1933 UCHAR CCXAdjacentAPBssid[MAC_ADDR_LEN]; //Adjacent AP's BSSID report
1934 USHORT CCXAdjacentAPChannel;
1935 ULONG CCXAdjacentAPLinkDownTime; //for Spec S32.
1936
1937 RALINK_TIMER_STRUCT StaQuickResponeForRateUpTimer;
1938 BOOLEAN StaQuickResponeForRateUpTimerRunning;
1939
1940 UCHAR DtimCount; // 0.. DtimPeriod-1
1941 UCHAR DtimPeriod; // default = 3
1942
1943 ////////////////////////////////////////////////////////////////////////////////////////
1944 // This is only for WHQL test.
1945 BOOLEAN WhqlTest;
1946 ////////////////////////////////////////////////////////////////////////////////////////
1947
1948 RALINK_TIMER_STRUCT WpaDisassocAndBlockAssocTimer;
1949 // Fast Roaming
1950 BOOLEAN bFastRoaming; // 0:disable fast roaming, 1:enable fast roaming
1951 CHAR dBmToRoam; // the condition to roam when receiving Rssi less than this value. It's negative value.
1952
1953 BOOLEAN IEEE8021X;
1954 BOOLEAN IEEE8021x_required_keys;
1955 CIPHER_KEY DesireSharedKey[4]; // Record user desired WEP keys
1956 UCHAR DesireSharedKeyId;
1957
1958 // 0: driver ignores wpa_supplicant
1959 // 1: wpa_supplicant initiates scanning and AP selection
1960 // 2: driver takes care of scanning, AP selection, and IEEE 802.11 association parameters
1961 UCHAR WpaSupplicantUP;
1962 UCHAR WpaSupplicantScanCount;
1963
1964 CHAR dev_name[16];
1965 USHORT OriDevType;
1966
1967 BOOLEAN bTGnWifiTest;
1968 BOOLEAN bScanReqIsFromWebUI;
1969
1970 HTTRANSMIT_SETTING HTPhyMode, MaxHTPhyMode, MinHTPhyMode;// For transmit phy setting in TXWI.
1971 DESIRED_TRANSMIT_SETTING DesiredTransmitSetting;
1972 RT_HT_PHY_INFO DesiredHtPhyInfo;
1973 BOOLEAN bAutoTxRateSwitch;
1974} STA_ADMIN_CONFIG, *PSTA_ADMIN_CONFIG;
1975
1976// This data structure keep the current active BSS/IBSS's configuration that this STA
1977// had agreed upon joining the network. Which means these parameters are usually decided
1978// by the BSS/IBSS creator instead of user configuration. Data in this data structurre
1979// is valid only when either ADHOC_ON(pAd) or INFRA_ON(pAd) is TRUE.
1980// Normally, after SCAN or failed roaming attempts, we need to recover back to
1981// the current active settings.
1982typedef struct _STA_ACTIVE_CONFIG {
1983 USHORT Aid;
1984 USHORT AtimWin; // in kusec; IBSS parameter set element
1985 USHORT CapabilityInfo;
1986 USHORT CfpMaxDuration;
1987 USHORT CfpPeriod;
1988
1989 // Copy supported rate from desired AP's beacon. We are trying to match
1990 // AP's supported and extended rate settings.
1991 UCHAR SupRate[MAX_LEN_OF_SUPPORTED_RATES];
1992 UCHAR ExtRate[MAX_LEN_OF_SUPPORTED_RATES];
1993 UCHAR SupRateLen;
1994 UCHAR ExtRateLen;
1995 // Copy supported ht from desired AP's beacon. We are trying to match
1996 RT_HT_PHY_INFO SupportedPhyInfo;
1997 RT_HT_CAPABILITY SupportedHtPhy;
1998} STA_ACTIVE_CONFIG, *PSTA_ACTIVE_CONFIG;
1999
2000#ifdef RT2870
2001// for USB interface, avoid in interrupt when write key
2002typedef struct RT_ADD_PAIRWISE_KEY_ENTRY {
2003 NDIS_802_11_MAC_ADDRESS MacAddr;
2004 USHORT MacTabMatchWCID; // ASIC
2005 CIPHER_KEY CipherKey;
2006} RT_ADD_PAIRWISE_KEY_ENTRY,*PRT_ADD_PAIRWISE_KEY_ENTRY;
2007#endif // RT2870 //
2008
2009// ----------- start of AP --------------------------
2010// AUTH-RSP State Machine Aux data structure
2011typedef struct _AP_MLME_AUX {
2012 UCHAR Addr[MAC_ADDR_LEN];
2013 USHORT Alg;
2014 CHAR Challenge[CIPHER_TEXT_LEN];
2015} AP_MLME_AUX, *PAP_MLME_AUX;
2016
2017// structure to define WPA Group Key Rekey Interval
2018typedef struct PACKED _RT_802_11_WPA_REKEY {
2019 ULONG ReKeyMethod; // mechanism for rekeying: 0:disable, 1: time-based, 2: packet-based
2020 ULONG ReKeyInterval; // time-based: seconds, packet-based: kilo-packets
2021} RT_WPA_REKEY,*PRT_WPA_REKEY, RT_802_11_WPA_REKEY, *PRT_802_11_WPA_REKEY;
2022
2023typedef struct _MAC_TABLE_ENTRY {
2024 //Choose 1 from ValidAsWDS and ValidAsCLI to validize.
2025 BOOLEAN ValidAsCLI; // Sta mode, set this TRUE after Linkup,too.
2026 BOOLEAN ValidAsWDS; // This is WDS Entry. only for AP mode.
2027 BOOLEAN ValidAsApCli; //This is a AP-Client entry, only for AP mode which enable AP-Client functions.
2028 BOOLEAN ValidAsMesh;
2029 BOOLEAN ValidAsDls; // This is DLS Entry. only for STA mode.
2030 BOOLEAN isCached;
2031 BOOLEAN bIAmBadAtheros; // Flag if this is Atheros chip that has IOT problem. We need to turn on RTS/CTS protection.
2032
2033 UCHAR EnqueueEapolStartTimerRunning; // Enqueue EAPoL-Start for triggering EAP SM
2034 //jan for wpa
2035 // record which entry revoke MIC Failure , if it leaves the BSS itself, AP won't update aMICFailTime MIB
2036 UCHAR CMTimerRunning;
2037 UCHAR apidx; // MBSS number
2038 UCHAR RSNIE_Len;
2039 UCHAR RSN_IE[MAX_LEN_OF_RSNIE];
2040 UCHAR ANonce[LEN_KEY_DESC_NONCE];
2041 UCHAR R_Counter[LEN_KEY_DESC_REPLAY];
2042 UCHAR PTK[64];
2043 UCHAR ReTryCounter;
2044 RALINK_TIMER_STRUCT RetryTimer;
2045 RALINK_TIMER_STRUCT EnqueueStartForPSKTimer; // A timer which enqueue EAPoL-Start for triggering PSK SM
2046 NDIS_802_11_AUTHENTICATION_MODE AuthMode; // This should match to whatever microsoft defined
2047 NDIS_802_11_WEP_STATUS WepStatus;
2048 AP_WPA_STATE WpaState;
2049 GTK_STATE GTKState;
2050 USHORT PortSecured;
2051 NDIS_802_11_PRIVACY_FILTER PrivacyFilter; // PrivacyFilter enum for 802.1X
2052 CIPHER_KEY PairwiseKey;
2053 PVOID pAd;
2054 INT PMKID_CacheIdx;
2055 UCHAR PMKID[LEN_PMKID];
2056
2057
2058 UCHAR Addr[MAC_ADDR_LEN];
2059 UCHAR PsMode;
2060 SST Sst;
2061 AUTH_STATE AuthState; // for SHARED KEY authentication state machine used only
2062 BOOLEAN IsReassocSta; // Indicate whether this is a reassociation procedure
2063 USHORT Aid;
2064 USHORT CapabilityInfo;
2065 UCHAR LastRssi;
2066 ULONG NoDataIdleCount;
2067 UINT16 StationKeepAliveCount; // unit: second
2068 ULONG PsQIdleCount;
2069 QUEUE_HEADER PsQueue;
2070
2071 UINT32 StaConnectTime; // the live time of this station since associated with AP
2072
2073 BOOLEAN bSendBAR;
2074 USHORT NoBADataCountDown;
2075
2076 UINT32 CachedBuf[16]; // UINT (4 bytes) for alignment
2077 UINT TxBFCount; // 3*3
2078 UINT FIFOCount;
2079 UINT DebugFIFOCount;
2080 UINT DebugTxCount;
2081 BOOLEAN bDlsInit;
2082
2083
2084//====================================================
2085//WDS entry needs these
2086// rt2860 add this. if ValidAsWDS==TRUE, MatchWDSTabIdx is the index in WdsTab.MacTab
2087 UINT MatchWDSTabIdx;
2088 UCHAR MaxSupportedRate;
2089 UCHAR CurrTxRate;
2090 UCHAR CurrTxRateIndex;
2091 // to record the each TX rate's quality. 0 is best, the bigger the worse.
2092 USHORT TxQuality[MAX_STEP_OF_TX_RATE_SWITCH];
2093 UINT32 OneSecTxNoRetryOkCount;
2094 UINT32 OneSecTxRetryOkCount;
2095 UINT32 OneSecTxFailCount;
2096 UINT32 ContinueTxFailCnt;
2097 UINT32 CurrTxRateStableTime; // # of second in current TX rate
2098 UCHAR TxRateUpPenalty; // extra # of second penalty due to last unstable condition
2099//====================================================
2100
2101 BOOLEAN fNoisyEnvironment;
2102 BOOLEAN fLastSecAccordingRSSI;
2103 UCHAR LastSecTxRateChangeAction; // 0: no change, 1:rate UP, 2:rate down
2104 CHAR LastTimeTxRateChangeAction; //Keep last time value of LastSecTxRateChangeAction
2105 ULONG LastTxOkCount;
2106 UCHAR PER[MAX_STEP_OF_TX_RATE_SWITCH];
2107
2108 // a bitmap of BOOLEAN flags. each bit represent an operation status of a particular
2109 // BOOLEAN control, either ON or OFF. These flags should always be accessed via
2110 // CLIENT_STATUS_TEST_FLAG(), CLIENT_STATUS_SET_FLAG(), CLIENT_STATUS_CLEAR_FLAG() macros.
2111 // see fOP_STATUS_xxx in RTMP_DEF.C for detail bit definition. fCLIENT_STATUS_AMSDU_INUSED
2112 ULONG ClientStatusFlags;
2113
2114 HTTRANSMIT_SETTING HTPhyMode, MaxHTPhyMode, MinHTPhyMode;// For transmit phy setting in TXWI.
2115
2116 // HT EWC MIMO-N used parameters
2117 USHORT RXBAbitmap; // fill to on-chip RXWI_BA_BITMASK in 8.1.3RX attribute entry format
2118 USHORT TXBAbitmap; // This bitmap as originator, only keep in software used to mark AMPDU bit in TXWI
2119 USHORT TXAutoBAbitmap;
2120 USHORT BADeclineBitmap;
2121 USHORT BARecWcidArray[NUM_OF_TID]; // The mapping wcid of recipient session. if RXBAbitmap bit is masked
2122 USHORT BAOriWcidArray[NUM_OF_TID]; // The mapping wcid of originator session. if TXBAbitmap bit is masked
2123 USHORT BAOriSequence[NUM_OF_TID]; // The mapping wcid of originator session. if TXBAbitmap bit is masked
2124
2125 // 802.11n features.
2126 UCHAR MpduDensity;
2127 UCHAR MaxRAmpduFactor;
2128 UCHAR AMsduSize;
2129 UCHAR MmpsMode; // MIMO power save more.
2130
2131 HT_CAPABILITY_IE HTCapability;
2132
2133 BOOLEAN bAutoTxRateSwitch;
2134
2135 UCHAR RateLen;
2136 struct _MAC_TABLE_ENTRY *pNext;
2137 USHORT TxSeq[NUM_OF_TID];
2138 USHORT NonQosDataSeq;
2139
2140 RSSI_SAMPLE RssiSample;
2141
2142 UINT32 TXMCSExpected[16];
2143 UINT32 TXMCSSuccessful[16];
2144 UINT32 TXMCSFailed[16];
2145 UINT32 TXMCSAutoFallBack[16][16];
2146
2147 ULONG LastBeaconRxTime;
2148} MAC_TABLE_ENTRY, *PMAC_TABLE_ENTRY;
2149
2150typedef struct _MAC_TABLE {
2151 USHORT Size;
2152 MAC_TABLE_ENTRY *Hash[HASH_TABLE_SIZE];
2153 MAC_TABLE_ENTRY Content[MAX_LEN_OF_MAC_TABLE];
2154 QUEUE_HEADER McastPsQueue;
2155 ULONG PsQIdleCount;
2156 BOOLEAN fAnyStationInPsm;
2157 BOOLEAN fAnyStationBadAtheros; // Check if any Station is atheros 802.11n Chip. We need to use RTS/CTS with Atheros 802,.11n chip.
2158 BOOLEAN fAnyTxOPForceDisable; // Check if it is necessary to disable BE TxOP
2159 BOOLEAN fAllStationAsRalink; // Check if all stations are ralink-chipset
2160 BOOLEAN fAnyStationIsLegacy; // Check if I use legacy rate to transmit to my BSS Station/
2161 BOOLEAN fAnyStationNonGF; // Check if any Station can't support GF.
2162 BOOLEAN fAnyStation20Only; // Check if any Station can't support GF.
2163 BOOLEAN fAnyStationMIMOPSDynamic; // Check if any Station is MIMO Dynamic
2164 BOOLEAN fAnyBASession; // Check if there is BA session. Force turn on RTS/CTS
2165} MAC_TABLE, *PMAC_TABLE;
2166
2167#define IS_HT_STA(_pMacEntry) \
2168 (_pMacEntry->MaxHTPhyMode.field.MODE >= MODE_HTMIX)
2169
2170#define IS_HT_RATE(_pMacEntry) \
2171 (_pMacEntry->HTPhyMode.field.MODE >= MODE_HTMIX)
2172
2173#define PEER_IS_HT_RATE(_pMacEntry) \
2174 (_pMacEntry->HTPhyMode.field.MODE >= MODE_HTMIX)
2175
2176typedef struct _WDS_ENTRY {
2177 BOOLEAN Valid;
2178 UCHAR Addr[MAC_ADDR_LEN];
2179 ULONG NoDataIdleCount;
2180 struct _WDS_ENTRY *pNext;
2181} WDS_ENTRY, *PWDS_ENTRY;
2182
2183typedef struct _WDS_TABLE_ENTRY {
2184 USHORT Size;
2185 UCHAR WdsAddr[MAC_ADDR_LEN];
2186 WDS_ENTRY *Hash[HASH_TABLE_SIZE];
2187 WDS_ENTRY Content[MAX_LEN_OF_MAC_TABLE];
2188 UCHAR MaxSupportedRate;
2189 UCHAR CurrTxRate;
2190 USHORT TxQuality[MAX_LEN_OF_SUPPORTED_RATES];
2191 USHORT OneSecTxOkCount;
2192 USHORT OneSecTxRetryOkCount;
2193 USHORT OneSecTxFailCount;
2194 ULONG CurrTxRateStableTime; // # of second in current TX rate
2195 UCHAR TxRateUpPenalty; // extra # of second penalty due to last unstable condition
2196} WDS_TABLE_ENTRY, *PWDS_TABLE_ENTRY;
2197
2198typedef struct _RT_802_11_WDS_ENTRY {
2199 PNET_DEV dev;
2200 UCHAR Valid;
2201 UCHAR PhyMode;
2202 UCHAR PeerWdsAddr[MAC_ADDR_LEN];
2203 UCHAR MacTabMatchWCID; // ASIC
2204 NDIS_802_11_WEP_STATUS WepStatus;
2205 UCHAR KeyIdx;
2206 CIPHER_KEY WdsKey;
2207 HTTRANSMIT_SETTING HTPhyMode, MaxHTPhyMode, MinHTPhyMode;
2208 RT_HT_PHY_INFO DesiredHtPhyInfo;
2209 BOOLEAN bAutoTxRateSwitch;
2210 DESIRED_TRANSMIT_SETTING DesiredTransmitSetting; // Desired transmit setting.
2211} RT_802_11_WDS_ENTRY, *PRT_802_11_WDS_ENTRY;
2212
2213typedef struct _WDS_TABLE {
2214 UCHAR Mode;
2215 ULONG Size;
2216 RT_802_11_WDS_ENTRY WdsEntry[MAX_WDS_ENTRY];
2217} WDS_TABLE, *PWDS_TABLE;
2218
2219typedef struct _APCLI_STRUCT {
2220 PNET_DEV dev;
2221#ifdef RTL865X_SOC
2222 unsigned int mylinkid;
2223#endif
2224 BOOLEAN Enable; // Set it as 1 if the apcli interface was configured to "1" or by iwpriv cmd "ApCliEnable"
2225 BOOLEAN Valid; // Set it as 1 if the apcli interface associated success to remote AP.
2226 UCHAR MacTabWCID; //WCID value, which point to the entry of ASIC Mac table.
2227 UCHAR SsidLen;
2228 CHAR Ssid[MAX_LEN_OF_SSID];
2229
2230 UCHAR CfgSsidLen;
2231 CHAR CfgSsid[MAX_LEN_OF_SSID];
2232 UCHAR CfgApCliBssid[ETH_LENGTH_OF_ADDRESS];
2233 UCHAR CurrentAddress[ETH_LENGTH_OF_ADDRESS];
2234
2235 ULONG ApCliRcvBeaconTime;
2236
2237 ULONG CtrlCurrState;
2238 ULONG SyncCurrState;
2239 ULONG AuthCurrState;
2240 ULONG AssocCurrState;
2241 ULONG WpaPskCurrState;
2242
2243 USHORT AuthReqCnt;
2244 USHORT AssocReqCnt;
2245
2246 ULONG ClientStatusFlags;
2247 UCHAR MpduDensity;
2248
2249 NDIS_802_11_AUTHENTICATION_MODE AuthMode; // This should match to whatever microsoft defined
2250 NDIS_802_11_WEP_STATUS WepStatus;
2251
2252 // Add to support different cipher suite for WPA2/WPA mode
2253 NDIS_802_11_ENCRYPTION_STATUS GroupCipher; // Multicast cipher suite
2254 NDIS_802_11_ENCRYPTION_STATUS PairCipher; // Unicast cipher suite
2255 BOOLEAN bMixCipher; // Indicate current Pair & Group use different cipher suites
2256 USHORT RsnCapability;
2257
2258 UCHAR PSK[100]; // reserve PSK key material
2259 UCHAR PSKLen;
2260 UCHAR PMK[32]; // WPA PSK mode PMK
2261 UCHAR GTK[32]; // GTK from authenticator
2262
2263 CIPHER_KEY SharedKey[SHARE_KEY_NUM];
2264 UCHAR DefaultKeyId;
2265
2266 // store RSN_IE built by driver
2267 UCHAR RSN_IE[MAX_LEN_OF_RSNIE]; // The content saved here should be convert to little-endian format.
2268 UCHAR RSNIE_Len;
2269
2270 // For WPA countermeasures
2271 ULONG LastMicErrorTime; // record last MIC error time
2272 BOOLEAN bBlockAssoc; // Block associate attempt for 60 seconds after counter measure occurred.
2273
2274 // For WPA-PSK supplicant state
2275 UCHAR SNonce[32]; // SNonce for WPA-PSK
2276 UCHAR GNonce[32]; // GNonce for WPA-PSK from authenticator
2277
2278 HTTRANSMIT_SETTING HTPhyMode, MaxHTPhyMode, MinHTPhyMode;
2279 RT_HT_PHY_INFO DesiredHtPhyInfo;
2280 BOOLEAN bAutoTxRateSwitch;
2281 DESIRED_TRANSMIT_SETTING DesiredTransmitSetting; // Desired transmit setting.
2282} APCLI_STRUCT, *PAPCLI_STRUCT;
2283
2284// ----------- end of AP ----------------------------
2285
2286struct wificonf
2287{
2288 BOOLEAN bShortGI;
2289 BOOLEAN bGreenField;
2290};
2291
2292
2293
2294typedef struct _INF_PCI_CONFIG
2295{
2296 PUCHAR CSRBaseAddress; // PCI MMIO Base Address, all access will use
2297}INF_PCI_CONFIG;
2298
2299typedef struct _INF_USB_CONFIG
2300{
2301 UINT BulkInEpAddr; // bulk-in endpoint address
2302 UINT BulkOutEpAddr[6]; // bulk-out endpoint address
2303
2304}INF_USB_CONFIG;
2305
2306#ifdef IKANOS_VX_1X0
2307 typedef void (*IkanosWlanTxCbFuncP)(void *, void *);
2308
2309 struct IKANOS_TX_INFO
2310 {
2311 struct net_device *netdev;
2312 IkanosWlanTxCbFuncP *fp;
2313 };
2314#endif // IKANOS_VX_1X0 //
2315
2316#ifdef DBG_DIAGNOSE
2317#define DIAGNOSE_TIME 10 // 10 sec
2318typedef struct _RtmpDiagStrcut_
2319{ // Diagnosis Related element
2320 unsigned char inited;
2321 unsigned char qIdx;
2322 unsigned char ArrayStartIdx;
2323 unsigned char ArrayCurIdx;
2324 // Tx Related Count
2325 USHORT TxDataCnt[DIAGNOSE_TIME];
2326 USHORT TxFailCnt[DIAGNOSE_TIME];
2327 USHORT TxDescCnt[DIAGNOSE_TIME][24]; // 3*3 // TxDesc queue length in scale of 0~14, >=15
2328 USHORT TxMcsCnt[DIAGNOSE_TIME][24]; // 3*3
2329 USHORT TxSWQueCnt[DIAGNOSE_TIME][9]; // TxSwQueue length in scale of 0, 1, 2, 3, 4, 5, 6, 7, >=8
2330
2331 USHORT TxAggCnt[DIAGNOSE_TIME];
2332 USHORT TxNonAggCnt[DIAGNOSE_TIME];
2333 USHORT TxAMPDUCnt[DIAGNOSE_TIME][24]; // 3*3 // 10 sec, TxDMA APMDU Aggregation count in range from 0 to 15, in setp of 1.
2334 USHORT TxRalinkCnt[DIAGNOSE_TIME]; // TxRalink Aggregation Count in 1 sec scale.
2335 USHORT TxAMSDUCnt[DIAGNOSE_TIME]; // TxAMSUD Aggregation Count in 1 sec scale.
2336
2337 // Rx Related Count
2338 USHORT RxDataCnt[DIAGNOSE_TIME]; // Rx Total Data count.
2339 USHORT RxCrcErrCnt[DIAGNOSE_TIME];
2340 USHORT RxMcsCnt[DIAGNOSE_TIME][24]; // 3*3
2341}RtmpDiagStruct;
2342#endif // DBG_DIAGNOSE //
2343
2344
2345//
2346// The miniport adapter structure
2347//
2348typedef struct _RTMP_ADAPTER
2349{
2350 PVOID OS_Cookie; // save specific structure relative to OS
2351 PNET_DEV net_dev;
2352 ULONG VirtualIfCnt;
2353
2354
2355
2356 NDIS_SPIN_LOCK irq_lock;
2357 UCHAR irq_disabled;
2358
2359#ifdef RT2870
2360/*****************************************************************************************/
2361/* USB related parameters */
2362/*****************************************************************************************/
2363 struct usb_config_descriptor *config;
2364 UINT BulkInEpAddr; // bulk-in endpoint address
2365 UINT BulkOutEpAddr[6]; // bulk-out endpoint address
2366
2367 UINT NumberOfPipes;
2368 USHORT BulkOutMaxPacketSize;
2369 USHORT BulkInMaxPacketSize;
2370
2371 //======Control Flags
2372 LONG PendingIoCount;
2373 ULONG BulkFlags;
2374 BOOLEAN bUsbTxBulkAggre; // Flags for bulk out data priority
2375
2376
2377 //======Timer Thread
2378 RT2870_TIMER_QUEUE TimerQ;
2379 NDIS_SPIN_LOCK TimerQLock;
2380
2381
2382 //======Cmd Thread
2383 CmdQ CmdQ;
2384 NDIS_SPIN_LOCK CmdQLock; // CmdQLock spinlock
2385
2386 BOOLEAN TimerFunc_kill;
2387 BOOLEAN mlme_kill;
2388
2389
2390 //======Semaphores (event)
2391 struct semaphore mlme_semaphore; /* to sleep thread on */
2392 struct semaphore RTUSBCmd_semaphore; /* to sleep thread on */
2393 struct semaphore RTUSBTimer_semaphore;
2394
2395 struct completion TimerQComplete;
2396 struct completion mlmeComplete;
2397 struct completion CmdQComplete;
2398 wait_queue_head_t *wait;
2399#endif // RT2870 //
2400
2401
2402/*****************************************************************************************/
2403 /* Both PCI/USB related parameters */
2404/*****************************************************************************************/
2405
2406
2407/*****************************************************************************************/
2408/* Tx related parameters */
2409/*****************************************************************************************/
2410 BOOLEAN DeQueueRunning[NUM_OF_TX_RING]; // for ensuring RTUSBDeQueuePacket get call once
2411 NDIS_SPIN_LOCK DeQueueLock[NUM_OF_TX_RING];
2412
2413#ifdef RT2870
2414 // Data related context and AC specified, 4 AC supported
2415 NDIS_SPIN_LOCK BulkOutLock[6]; // BulkOut spinlock for 4 ACs
2416 NDIS_SPIN_LOCK MLMEBulkOutLock; // MLME BulkOut lock
2417
2418 HT_TX_CONTEXT TxContext[NUM_OF_TX_RING];
2419 NDIS_SPIN_LOCK TxContextQueueLock[NUM_OF_TX_RING]; // TxContextQueue spinlock
2420
2421 // 4 sets of Bulk Out index and pending flag
2422 UCHAR NextBulkOutIndex[4]; // only used for 4 EDCA bulkout pipe
2423
2424 BOOLEAN BulkOutPending[6]; // used for total 6 bulkout pipe
2425 UCHAR bulkResetPipeid;
2426 BOOLEAN MgmtBulkPending;
2427 ULONG bulkResetReq[6];
2428#endif // RT2870 //
2429
2430 // resource for software backlog queues
2431 QUEUE_HEADER TxSwQueue[NUM_OF_TX_RING]; // 4 AC + 1 HCCA
2432 NDIS_SPIN_LOCK TxSwQueueLock[NUM_OF_TX_RING]; // TxSwQueue spinlock
2433
2434 RTMP_DMABUF MgmtDescRing; // Shared memory for MGMT descriptors
2435 RTMP_MGMT_RING MgmtRing;
2436 NDIS_SPIN_LOCK MgmtRingLock; // Prio Ring spinlock
2437
2438
2439/*****************************************************************************************/
2440/* Rx related parameters */
2441/*****************************************************************************************/
2442
2443
2444#ifdef RT2870
2445 RX_CONTEXT RxContext[RX_RING_SIZE]; // 1 for redundant multiple IRP bulk in.
2446 NDIS_SPIN_LOCK BulkInLock; // BulkIn spinlock for 4 ACs
2447 UCHAR PendingRx; // The Maxima pending Rx value should be RX_RING_SIZE.
2448 UCHAR NextRxBulkInIndex; // Indicate the current RxContext Index which hold by Host controller.
2449 UCHAR NextRxBulkInReadIndex; // Indicate the current RxContext Index which driver can read & process it.
2450 ULONG NextRxBulkInPosition; // Want to contatenate 2 URB buffer while 1st is bulkin failed URB. This Position is 1st URB TransferLength.
2451 ULONG TransferBufferLength; // current length of the packet buffer
2452 ULONG ReadPosition; // current read position in a packet buffer
2453#endif // RT2870 //
2454
2455
2456/*****************************************************************************************/
2457/* ASIC related parameters */
2458/*****************************************************************************************/
2459 UINT32 MACVersion; // MAC version. Record rt2860C(0x28600100) or rt2860D (0x28600101)..
2460
2461 // ---------------------------
2462 // E2PROM
2463 // ---------------------------
2464 ULONG EepromVersion; // byte 0: version, byte 1: revision, byte 2~3: unused
2465 UCHAR EEPROMAddressNum; // 93c46=6 93c66=8
2466 USHORT EEPROMDefaultValue[NUM_EEPROM_BBP_PARMS];
2467#ifdef RT30xx
2468 BOOLEAN EepromAccess;
2469 UCHAR EFuseTag;
2470#endif
2471 ULONG FirmwareVersion; // byte 0: Minor version, byte 1: Major version, otherwise unused.
2472
2473 // ---------------------------
2474 // BBP Control
2475 // ---------------------------
2476 UCHAR BbpWriteLatch[140]; // record last BBP register value written via BBP_IO_WRITE/BBP_IO_WRITE_VY_REG_ID
2477 UCHAR BbpRssiToDbmDelta;
2478 BBP_R66_TUNING BbpTuning;
2479
2480 // ----------------------------
2481 // RFIC control
2482 // ----------------------------
2483 UCHAR RfIcType; // RFIC_xxx
2484 ULONG RfFreqOffset; // Frequency offset for channel switching
2485 RTMP_RF_REGS LatchRfRegs; // latch th latest RF programming value since RF IC doesn't support READ
2486
2487 EEPROM_ANTENNA_STRUC Antenna; // Since ANtenna definition is different for a & g. We need to save it for future reference.
2488 EEPROM_NIC_CONFIG2_STRUC NicConfig2;
2489
2490 // This soft Rx Antenna Diversity mechanism is used only when user set
2491 // RX Antenna = DIVERSITY ON
2492 SOFT_RX_ANT_DIVERSITY RxAnt;
2493
2494 UCHAR RFProgSeq;
2495 CHANNEL_TX_POWER TxPower[MAX_NUM_OF_CHANNELS]; // Store Tx power value for all channels.
2496 CHANNEL_TX_POWER ChannelList[MAX_NUM_OF_CHANNELS]; // list all supported channels for site survey
2497 CHANNEL_11J_TX_POWER TxPower11J[MAX_NUM_OF_11JCHANNELS]; // 802.11j channel and bw
2498 CHANNEL_11J_TX_POWER ChannelList11J[MAX_NUM_OF_11JCHANNELS]; // list all supported channels for site survey
2499
2500 UCHAR ChannelListNum; // number of channel in ChannelList[]
2501 UCHAR Bbp94;
2502 BOOLEAN BbpForCCK;
2503 ULONG Tx20MPwrCfgABand[5];
2504 ULONG Tx20MPwrCfgGBand[5];
2505 ULONG Tx40MPwrCfgABand[5];
2506 ULONG Tx40MPwrCfgGBand[5];
2507
2508 BOOLEAN bAutoTxAgcA; // Enable driver auto Tx Agc control
2509 UCHAR TssiRefA; // Store Tssi reference value as 25 temperature.
2510 UCHAR TssiPlusBoundaryA[5]; // Tssi boundary for increase Tx power to compensate.
2511 UCHAR TssiMinusBoundaryA[5]; // Tssi boundary for decrease Tx power to compensate.
2512 UCHAR TxAgcStepA; // Store Tx TSSI delta increment / decrement value
2513 CHAR TxAgcCompensateA; // Store the compensation (TxAgcStep * (idx-1))
2514
2515 BOOLEAN bAutoTxAgcG; // Enable driver auto Tx Agc control
2516 UCHAR TssiRefG; // Store Tssi reference value as 25 temperature.
2517 UCHAR TssiPlusBoundaryG[5]; // Tssi boundary for increase Tx power to compensate.
2518 UCHAR TssiMinusBoundaryG[5]; // Tssi boundary for decrease Tx power to compensate.
2519 UCHAR TxAgcStepG; // Store Tx TSSI delta increment / decrement value
2520 CHAR TxAgcCompensateG; // Store the compensation (TxAgcStep * (idx-1))
2521
2522 //+++For RT2870, the parameteres is start from BGRssiOffset1 ~ BGRssiOffset3
2523 CHAR BGRssiOffset0; // Store B/G RSSI#0 Offset value on EEPROM 0x46h
2524 CHAR BGRssiOffset1; // Store B/G RSSI#1 Offset value
2525 CHAR BGRssiOffset2; // Store B/G RSSI#2 Offset value
2526 //---
2527
2528 //+++For RT2870, the parameteres is start from ARssiOffset1 ~ ARssiOffset3
2529 CHAR ARssiOffset0; // Store A RSSI#0 Offset value on EEPROM 0x4Ah
2530 CHAR ARssiOffset1; // Store A RSSI#1 Offset value
2531 CHAR ARssiOffset2; // Store A RSSI#2 Offset value
2532 //---
2533
2534 CHAR BLNAGain; // Store B/G external LNA#0 value on EEPROM 0x44h
2535 CHAR ALNAGain0; // Store A external LNA#0 value for ch36~64
2536 CHAR ALNAGain1; // Store A external LNA#1 value for ch100~128
2537 CHAR ALNAGain2; // Store A external LNA#2 value for ch132~165
2538
2539 // ----------------------------
2540 // LED control
2541 // ----------------------------
2542 MCU_LEDCS_STRUC LedCntl;
2543 USHORT Led1; // read from EEPROM 0x3c
2544 USHORT Led2; // EEPROM 0x3e
2545 USHORT Led3; // EEPROM 0x40
2546 UCHAR LedIndicatorStregth;
2547 UCHAR RssiSingalstrengthOffet;
2548 BOOLEAN bLedOnScanning;
2549 UCHAR LedStatus;
2550
2551/*****************************************************************************************/
2552/* 802.11 related parameters */
2553/*****************************************************************************************/
2554 // outgoing BEACON frame buffer and corresponding TXD
2555 TXWI_STRUC BeaconTxWI;
2556 PUCHAR BeaconBuf;
2557 USHORT BeaconOffset[HW_BEACON_MAX_COUNT];
2558
2559 // pre-build PS-POLL and NULL frame upon link up. for efficiency purpose.
2560 PSPOLL_FRAME PsPollFrame;
2561 HEADER_802_11 NullFrame;
2562
2563#ifdef RT2870
2564 TX_CONTEXT BeaconContext[BEACON_RING_SIZE];
2565 TX_CONTEXT NullContext;
2566 TX_CONTEXT PsPollContext;
2567 TX_CONTEXT RTSContext;
2568#endif // RT2870 //
2569
2570
2571
2572//=========AP===========
2573
2574
2575//=======STA===========
2576/* Modified by Wu Xi-Kun 4/21/2006 */
2577 // -----------------------------------------------
2578 // STA specific configuration & operation status
2579 // used only when pAd->OpMode == OPMODE_STA
2580 // -----------------------------------------------
2581 STA_ADMIN_CONFIG StaCfg; // user desired settings
2582 STA_ACTIVE_CONFIG StaActive; // valid only when ADHOC_ON(pAd) || INFRA_ON(pAd)
2583 CHAR nickname[IW_ESSID_MAX_SIZE+1]; // nickname, only used in the iwconfig i/f
2584 NDIS_MEDIA_STATE PreMediaState;
2585
2586//=======Common===========
2587 // OP mode: either AP or STA
2588 UCHAR OpMode; // OPMODE_STA, OPMODE_AP
2589
2590 NDIS_MEDIA_STATE IndicateMediaState; // Base on Indication state, default is NdisMediaStateDisConnected
2591
2592
2593 // configuration: read from Registry & E2PROM
2594 BOOLEAN bLocalAdminMAC; // Use user changed MAC
2595 UCHAR PermanentAddress[MAC_ADDR_LEN]; // Factory default MAC address
2596 UCHAR CurrentAddress[MAC_ADDR_LEN]; // User changed MAC address
2597
2598 // ------------------------------------------------------
2599 // common configuration to both OPMODE_STA and OPMODE_AP
2600 // ------------------------------------------------------
2601 COMMON_CONFIG CommonCfg;
2602 MLME_STRUCT Mlme;
2603
2604 // AP needs those vaiables for site survey feature.
2605 MLME_AUX MlmeAux; // temporary settings used during MLME state machine
2606 BSS_TABLE ScanTab; // store the latest SCAN result
2607
2608 //About MacTab, the sta driver will use #0 and #1 for multicast and AP.
2609 MAC_TABLE MacTab; // ASIC on-chip WCID entry table. At TX, ASIC always use key according to this on-chip table.
2610 NDIS_SPIN_LOCK MacTabLock;
2611
2612 BA_TABLE BATable;
2613
2614 NDIS_SPIN_LOCK BATabLock;
2615 RALINK_TIMER_STRUCT RECBATimer;
2616
2617 // encryption/decryption KEY tables
2618 CIPHER_KEY SharedKey[MAX_MBSSID_NUM][4]; // STA always use SharedKey[BSS0][0..3]
2619
2620 // RX re-assembly buffer for fragmentation
2621 FRAGMENT_FRAME FragFrame; // Frame storage for fragment frame
2622
2623 // various Counters
2624 COUNTER_802_3 Counters8023; // 802.3 counters
2625 COUNTER_802_11 WlanCounters; // 802.11 MIB counters
2626 COUNTER_RALINK RalinkCounters; // Ralink propriety counters
2627 COUNTER_DRS DrsCounters; // counters for Dynamic TX Rate Switching
2628 PRIVATE_STRUC PrivateInfo; // Private information & counters
2629
2630 // flags, see fRTMP_ADAPTER_xxx flags
2631 ULONG Flags; // Represent current device status
2632
2633 // current TX sequence #
2634 USHORT Sequence;
2635
2636 // Control disconnect / connect event generation
2637 //+++Didn't used anymore
2638 ULONG LinkDownTime;
2639 //---
2640 ULONG LastRxRate;
2641 ULONG LastTxRate;
2642 //+++Used only for Station
2643 BOOLEAN bConfigChanged; // Config Change flag for the same SSID setting
2644 //---
2645
2646 ULONG ExtraInfo; // Extra information for displaying status
2647 ULONG SystemErrorBitmap; // b0: E2PROM version error
2648
2649 //+++Didn't used anymore
2650 ULONG MacIcVersion; // MAC/BBP serial interface issue solved after ver.D
2651 //---
2652
2653 // ---------------------------
2654 // System event log
2655 // ---------------------------
2656 RT_802_11_EVENT_TABLE EventTab;
2657
2658
2659 BOOLEAN HTCEnable;
2660
2661 /*****************************************************************************************/
2662 /* Statistic related parameters */
2663 /*****************************************************************************************/
2664#ifdef RT2870
2665 ULONG BulkOutDataOneSecCount;
2666 ULONG BulkInDataOneSecCount;
2667 ULONG BulkLastOneSecCount; // BulkOutDataOneSecCount + BulkInDataOneSecCount
2668 ULONG watchDogRxCnt;
2669 ULONG watchDogRxOverFlowCnt;
2670 ULONG watchDogTxPendingCnt[NUM_OF_TX_RING];
2671#endif // RT2870 //
2672
2673 BOOLEAN bUpdateBcnCntDone;
2674 ULONG watchDogMacDeadlock; // prevent MAC/BBP into deadlock condition
2675 // ----------------------------
2676 // DEBUG paramerts
2677 // ----------------------------
2678 BOOLEAN bBanAllBaSetup;
2679 BOOLEAN bPromiscuous;
2680
2681 // ----------------------------
2682 // rt2860c emulation-use Parameters
2683 // ----------------------------
2684 ULONG rtsaccu[30];
2685 ULONG ctsaccu[30];
2686 ULONG cfendaccu[30];
2687 ULONG bacontent[16];
2688 ULONG rxint[RX_RING_SIZE+1];
2689 UCHAR rcvba[60];
2690 BOOLEAN bLinkAdapt;
2691 BOOLEAN bForcePrintTX;
2692 BOOLEAN bForcePrintRX;
2693 BOOLEAN bDisablescanning; //defined in RT2870 USB
2694 BOOLEAN bStaFifoTest;
2695 BOOLEAN bProtectionTest;
2696 BOOLEAN bHCCATest;
2697 BOOLEAN bGenOneHCCA;
2698 BOOLEAN bBroadComHT;
2699 //+++Following add from RT2870 USB.
2700 ULONG BulkOutReq;
2701 ULONG BulkOutComplete;
2702 ULONG BulkOutCompleteOther;
2703 ULONG BulkOutCompleteCancel; // seems not use now?
2704 ULONG BulkInReq;
2705 ULONG BulkInComplete;
2706 ULONG BulkInCompleteFail;
2707 //---
2708
2709 struct wificonf WIFItestbed;
2710
2711 struct reordering_mpdu_pool mpdu_blk_pool;
2712
2713 ULONG OneSecondnonBEpackets; // record non BE packets per second
2714
2715#if WIRELESS_EXT >= 12
2716 struct iw_statistics iw_stats;
2717#endif
2718
2719 struct net_device_stats stats;
2720
2721 ULONG TbttTickCount;
2722#ifdef PCI_MSI_SUPPORT
2723 BOOLEAN HaveMsi;
2724#endif // PCI_MSI_SUPPORT //
2725
2726
2727 UCHAR is_on;
2728
2729#define TIME_BASE (1000000/OS_HZ)
2730#define TIME_ONE_SECOND (1000000/TIME_BASE)
2731 UCHAR flg_be_adjust;
2732 ULONG be_adjust_last_time;
2733
2734
2735#ifdef IKANOS_VX_1X0
2736 struct IKANOS_TX_INFO IkanosTxInfo;
2737 struct IKANOS_TX_INFO IkanosRxInfo[MAX_MBSSID_NUM + MAX_WDS_ENTRY + MAX_APCLI_NUM + MAX_MESH_NUM];
2738#endif // IKANOS_VX_1X0 //
2739
2740
2741#ifdef DBG_DIAGNOSE
2742 RtmpDiagStruct DiagStruct;
2743#endif // DBG_DIAGNOSE //
2744
2745
2746 UINT8 PM_FlgSuspend;
2747
2748#ifdef RT30xx
2749//======efuse
2750 BOOLEAN bUseEfuse;
2751 BOOLEAN bEEPROMFile;
2752#endif // RT30xx //
2753
2754} RTMP_ADAPTER, *PRTMP_ADAPTER;
2755
2756//
2757// Cisco IAPP format
2758//
2759typedef struct _CISCO_IAPP_CONTENT_
2760{
2761 USHORT Length; //IAPP Length
2762 UCHAR MessageType; //IAPP type
2763 UCHAR FunctionCode; //IAPP function type
2764 UCHAR DestinaionMAC[MAC_ADDR_LEN];
2765 UCHAR SourceMAC[MAC_ADDR_LEN];
2766 USHORT Tag; //Tag(element IE) - Adjacent AP report
2767 USHORT TagLength; //Length of element not including 4 byte header
2768 UCHAR OUI[4]; //0x00, 0x40, 0x96, 0x00
2769 UCHAR PreviousAP[MAC_ADDR_LEN]; //MAC Address of access point
2770 USHORT Channel;
2771 USHORT SsidLen;
2772 UCHAR Ssid[MAX_LEN_OF_SSID];
2773 USHORT Seconds; //Seconds that the client has been disassociated.
2774} CISCO_IAPP_CONTENT, *PCISCO_IAPP_CONTENT;
2775
2776#define DELAYINTMASK 0x0003fffb
2777#define INTMASK 0x0003fffb
2778#define IndMask 0x0003fffc
2779#define RxINT 0x00000005 // Delayed Rx or indivi rx
2780#define TxDataInt 0x000000fa // Delayed Tx or indivi tx
2781#define TxMgmtInt 0x00000102 // Delayed Tx or indivi tx
2782#define TxCoherent 0x00020000 // tx coherent
2783#define RxCoherent 0x00010000 // rx coherent
2784#define McuCommand 0x00000200 // mcu
2785#define PreTBTTInt 0x00001000 // Pre-TBTT interrupt
2786#define TBTTInt 0x00000800 // TBTT interrupt
2787#define GPTimeOutInt 0x00008000 // GPtimeout interrupt
2788#define AutoWakeupInt 0x00004000 // AutoWakeupInt interrupt
2789#define FifoStaFullInt 0x00002000 // fifo statistics full interrupt
2790
2791
2792typedef struct _RX_BLK_
2793{
2794 RT28XX_RXD_STRUC RxD;
2795 PRXWI_STRUC pRxWI;
2796 PHEADER_802_11 pHeader;
2797 PNDIS_PACKET pRxPacket;
2798 UCHAR *pData;
2799 USHORT DataSize;
2800 USHORT Flags;
2801 UCHAR UserPriority; // for calculate TKIP MIC using
2802} RX_BLK;
2803
2804
2805#define RX_BLK_SET_FLAG(_pRxBlk, _flag) (_pRxBlk->Flags |= _flag)
2806#define RX_BLK_TEST_FLAG(_pRxBlk, _flag) (_pRxBlk->Flags & _flag)
2807#define RX_BLK_CLEAR_FLAG(_pRxBlk, _flag) (_pRxBlk->Flags &= ~(_flag))
2808
2809
2810#define fRX_WDS 0x0001
2811#define fRX_AMSDU 0x0002
2812#define fRX_ARALINK 0x0004
2813#define fRX_HTC 0x0008
2814#define fRX_PAD 0x0010
2815#define fRX_AMPDU 0x0020
2816#define fRX_QOS 0x0040
2817#define fRX_INFRA 0x0080
2818#define fRX_EAP 0x0100
2819#define fRX_MESH 0x0200
2820#define fRX_APCLI 0x0400
2821#define fRX_DLS 0x0800
2822#define fRX_WPI 0x1000
2823
2824#define LENGTH_AMSDU_SUBFRAMEHEAD 14
2825#define LENGTH_ARALINK_SUBFRAMEHEAD 14
2826#define LENGTH_ARALINK_HEADER_FIELD 2
2827
2828#define TX_UNKOWN_FRAME 0x00
2829#define TX_MCAST_FRAME 0x01
2830#define TX_LEGACY_FRAME 0x02
2831#define TX_AMPDU_FRAME 0x04
2832#define TX_AMSDU_FRAME 0x08
2833#define TX_RALINK_FRAME 0x10
2834#define TX_FRAG_FRAME 0x20
2835
2836
2837// Currently the sizeof(TX_BLK) is 148 bytes.
2838typedef struct _TX_BLK_
2839{
2840 UCHAR QueIdx;
2841 UCHAR TxFrameType; // Indicate the Transmission type of the all frames in one batch
2842 UCHAR TotalFrameNum; // Total frame number want to send-out in one batch
2843 USHORT TotalFragNum; // Total frame fragments required in one batch
2844 USHORT TotalFrameLen; // Total length of all frames want to send-out in one batch
2845
2846 QUEUE_HEADER TxPacketList;
2847 MAC_TABLE_ENTRY *pMacEntry; // NULL: packet with 802.11 RA field is multicast/broadcast address
2848 HTTRANSMIT_SETTING *pTransmit;
2849
2850 // Following structure used for the characteristics of a specific packet.
2851 PNDIS_PACKET pPacket;
2852 PUCHAR pSrcBufHeader; // Reference to the head of sk_buff->data
2853 PUCHAR pSrcBufData; // Reference to the sk_buff->data, will changed depends on hanlding progresss
2854 UINT SrcBufLen; // Length of packet payload which not including Layer 2 header
2855 PUCHAR pExtraLlcSnapEncap; // NULL means no extra LLC/SNAP is required
2856 UCHAR HeaderBuf[80]; // TempBuffer for TX_INFO + TX_WI + 802.11 Header + padding + AMSDU SubHeader + LLC/SNAP
2857 UCHAR MpduHeaderLen; // 802.11 header length NOT including the padding
2858 UCHAR HdrPadLen; // recording Header Padding Length;
2859 UCHAR apidx; // The interface associated to this packet
2860 UCHAR Wcid; // The MAC entry associated to this packet
2861 UCHAR UserPriority; // priority class of packet
2862 UCHAR FrameGap; // what kind of IFS this packet use
2863 UCHAR MpduReqNum; // number of fragments of this frame
2864 UCHAR TxRate; // TODO: Obsoleted? Should change to MCS?
2865 UCHAR CipherAlg; // cipher alogrithm
2866 PCIPHER_KEY pKey;
2867
2868
2869
2870 USHORT Flags; //See following definitions for detail.
2871
2872 //YOU SHOULD NOT TOUCH IT! Following parameters are used for hardware-depended layer.
2873 ULONG Priv; // Hardware specific value saved in here.
2874} TX_BLK, *PTX_BLK;
2875
2876
2877#define fTX_bRtsRequired 0x0001 // Indicate if need send RTS frame for protection. Not used in RT2860/RT2870.
2878#define fTX_bAckRequired 0x0002 // the packet need ack response
2879#define fTX_bPiggyBack 0x0004 // Legacy device use Piggback or not
2880#define fTX_bHTRate 0x0008 // allow to use HT rate
2881#define fTX_bForceNonQoS 0x0010 // force to transmit frame without WMM-QoS in HT mode
2882#define fTX_bAllowFrag 0x0020 // allow to fragment the packet, A-MPDU, A-MSDU, A-Ralink is not allowed to fragment
2883#define fTX_bMoreData 0x0040 // there are more data packets in PowerSave Queue
2884#define fTX_bWMM 0x0080 // QOS Data
2885
2886#define fTX_bClearEAPFrame 0x0100
2887
2888#define TX_BLK_ASSIGN_FLAG(_pTxBlk, _flag, value) \
2889 do { \
2890 if (value) \
2891 (_pTxBlk->Flags |= _flag) \
2892 else \
2893 (_pTxBlk->Flags &= ~(_flag)) \
2894 }while(0)
2895
2896#define TX_BLK_SET_FLAG(_pTxBlk, _flag) (_pTxBlk->Flags |= _flag)
2897#define TX_BLK_TEST_FLAG(_pTxBlk, _flag) (((_pTxBlk->Flags & _flag) == _flag) ? 1 : 0)
2898#define TX_BLK_CLEAR_FLAG(_pTxBlk, _flag) (_pTxBlk->Flags &= ~(_flag))
2899
2900
2901
2902
2903
2904//------------------------------------------------------------------------------------------
2905
2906static inline VOID ConvertMulticastIP2MAC(
2907 IN PUCHAR pIpAddr,
2908 IN PUCHAR *ppMacAddr,
2909 IN UINT16 ProtoType)
2910{
2911 if (pIpAddr == NULL)
2912 return;
2913
2914 if (ppMacAddr == NULL || *ppMacAddr == NULL)
2915 return;
2916
2917 switch (ProtoType)
2918 {
2919 case ETH_P_IPV6:
2920// memset(*ppMacAddr, 0, ETH_LENGTH_OF_ADDRESS);
2921 *(*ppMacAddr) = 0x33;
2922 *(*ppMacAddr + 1) = 0x33;
2923 *(*ppMacAddr + 2) = pIpAddr[12];
2924 *(*ppMacAddr + 3) = pIpAddr[13];
2925 *(*ppMacAddr + 4) = pIpAddr[14];
2926 *(*ppMacAddr + 5) = pIpAddr[15];
2927 break;
2928
2929 case ETH_P_IP:
2930 default:
2931// memset(*ppMacAddr, 0, ETH_LENGTH_OF_ADDRESS);
2932 *(*ppMacAddr) = 0x01;
2933 *(*ppMacAddr + 1) = 0x00;
2934 *(*ppMacAddr + 2) = 0x5e;
2935 *(*ppMacAddr + 3) = pIpAddr[1] & 0x7f;
2936 *(*ppMacAddr + 4) = pIpAddr[2];
2937 *(*ppMacAddr + 5) = pIpAddr[3];
2938 break;
2939 }
2940
2941 return;
2942}
2943
2944BOOLEAN RTMPCheckForHang(
2945 IN NDIS_HANDLE MiniportAdapterContext
2946 );
2947
2948VOID RTMPHalt(
2949 IN NDIS_HANDLE MiniportAdapterContext
2950 );
2951
2952//
2953// Private routines in rtmp_init.c
2954//
2955NDIS_STATUS RTMPAllocAdapterBlock(
2956 IN PVOID handle,
2957 OUT PRTMP_ADAPTER *ppAdapter
2958 );
2959
2960NDIS_STATUS RTMPAllocTxRxRingMemory(
2961 IN PRTMP_ADAPTER pAd
2962 );
2963
2964NDIS_STATUS RTMPFindAdapter(
2965 IN PRTMP_ADAPTER pAd,
2966 IN NDIS_HANDLE WrapperConfigurationContext
2967 );
2968
2969NDIS_STATUS RTMPReadParametersHook(
2970 IN PRTMP_ADAPTER pAd
2971 );
2972
2973VOID RTMPFreeAdapter(
2974 IN PRTMP_ADAPTER pAd
2975 );
2976
2977NDIS_STATUS NICReadRegParameters(
2978 IN PRTMP_ADAPTER pAd,
2979 IN NDIS_HANDLE WrapperConfigurationContext
2980 );
2981
2982#ifdef RT2870
2983VOID NICInitRT30xxRFRegisters(
2984 IN PRTMP_ADAPTER pAd);
2985#endif // RT2870 //
2986
2987VOID NICReadEEPROMParameters(
2988 IN PRTMP_ADAPTER pAd,
2989 IN PUCHAR mac_addr);
2990
2991VOID NICInitAsicFromEEPROM(
2992 IN PRTMP_ADAPTER pAd);
2993
2994VOID NICInitTxRxRingAndBacklogQueue(
2995 IN PRTMP_ADAPTER pAd);
2996
2997NDIS_STATUS NICInitializeAdapter(
2998 IN PRTMP_ADAPTER pAd,
2999 IN BOOLEAN bHardReset);
3000
3001NDIS_STATUS NICInitializeAsic(
3002 IN PRTMP_ADAPTER pAd,
3003 IN BOOLEAN bHardReset);
3004
3005VOID NICIssueReset(
3006 IN PRTMP_ADAPTER pAd);
3007
3008VOID RTMPRingCleanUp(
3009 IN PRTMP_ADAPTER pAd,
3010 IN UCHAR RingType);
3011
3012VOID RxTest(
3013 IN PRTMP_ADAPTER pAd);
3014
3015NDIS_STATUS DbgSendPacket(
3016 IN PRTMP_ADAPTER pAd,
3017 IN PNDIS_PACKET pPacket);
3018
3019VOID UserCfgInit(
3020 IN PRTMP_ADAPTER pAd);
3021
3022VOID NICResetFromError(
3023 IN PRTMP_ADAPTER pAd);
3024
3025VOID NICEraseFirmware(
3026 IN PRTMP_ADAPTER pAd);
3027
3028NDIS_STATUS NICLoadFirmware(
3029 IN PRTMP_ADAPTER pAd);
3030
3031NDIS_STATUS NICLoadRateSwitchingParams(
3032 IN PRTMP_ADAPTER pAd);
3033
3034BOOLEAN NICCheckForHang(
3035 IN PRTMP_ADAPTER pAd);
3036
3037VOID NICUpdateFifoStaCounters(
3038 IN PRTMP_ADAPTER pAd);
3039
3040VOID NICUpdateRawCounters(
3041 IN PRTMP_ADAPTER pAd);
3042
3043ULONG RTMPNotAllZero(
3044 IN PVOID pSrc1,
3045 IN ULONG Length);
3046
3047VOID RTMPZeroMemory(
3048 IN PVOID pSrc,
3049 IN ULONG Length);
3050
3051ULONG RTMPCompareMemory(
3052 IN PVOID pSrc1,
3053 IN PVOID pSrc2,
3054 IN ULONG Length);
3055
3056VOID RTMPMoveMemory(
3057 OUT PVOID pDest,
3058 IN PVOID pSrc,
3059 IN ULONG Length);
3060
3061VOID AtoH(
3062 char *src,
3063 UCHAR *dest,
3064 int destlen);
3065
3066UCHAR BtoH(
3067 char ch);
3068
3069VOID RTMPPatchMacBbpBug(
3070 IN PRTMP_ADAPTER pAd);
3071
3072VOID RTMPPatchCardBus(
3073 IN PRTMP_ADAPTER pAdapter);
3074
3075VOID RTMPPatchRalinkCardBus(
3076 IN PRTMP_ADAPTER pAdapter,
3077 IN ULONG Bus);
3078
3079ULONG RTMPReadCBConfig(
3080 IN ULONG Bus,
3081 IN ULONG Slot,
3082 IN ULONG Func,
3083 IN ULONG Offset);
3084
3085VOID RTMPWriteCBConfig(
3086 IN ULONG Bus,
3087 IN ULONG Slot,
3088 IN ULONG Func,
3089 IN ULONG Offset,
3090 IN ULONG Value);
3091
3092VOID RTMPInitTimer(
3093 IN PRTMP_ADAPTER pAd,
3094 IN PRALINK_TIMER_STRUCT pTimer,
3095 IN PVOID pTimerFunc,
3096 IN PVOID pData,
3097 IN BOOLEAN Repeat);
3098
3099VOID RTMPSetTimer(
3100 IN PRALINK_TIMER_STRUCT pTimer,
3101 IN ULONG Value);
3102
3103
3104VOID RTMPModTimer(
3105 IN PRALINK_TIMER_STRUCT pTimer,
3106 IN ULONG Value);
3107
3108VOID RTMPCancelTimer(
3109 IN PRALINK_TIMER_STRUCT pTimer,
3110 OUT BOOLEAN *pCancelled);
3111
3112VOID RTMPSetLED(
3113 IN PRTMP_ADAPTER pAd,
3114 IN UCHAR Status);
3115
3116VOID RTMPSetSignalLED(
3117 IN PRTMP_ADAPTER pAd,
3118 IN NDIS_802_11_RSSI Dbm);
3119
3120VOID RTMPEnableRxTx(
3121 IN PRTMP_ADAPTER pAd);
3122
3123//
3124// prototype in action.c
3125//
3126VOID ActionStateMachineInit(
3127 IN PRTMP_ADAPTER pAd,
3128 IN STATE_MACHINE *S,
3129 OUT STATE_MACHINE_FUNC Trans[]);
3130
3131VOID MlmeADDBAAction(
3132 IN PRTMP_ADAPTER pAd,
3133 IN MLME_QUEUE_ELEM *Elem);
3134
3135VOID MlmeDELBAAction(
3136 IN PRTMP_ADAPTER pAd,
3137 IN MLME_QUEUE_ELEM *Elem);
3138
3139VOID MlmeDLSAction(
3140 IN PRTMP_ADAPTER pAd,
3141 IN MLME_QUEUE_ELEM *Elem);
3142
3143VOID MlmeInvalidAction(
3144 IN PRTMP_ADAPTER pAd,
3145 IN MLME_QUEUE_ELEM *Elem);
3146
3147VOID MlmeQOSAction(
3148 IN PRTMP_ADAPTER pAd,
3149 IN MLME_QUEUE_ELEM *Elem);
3150
3151VOID PeerAddBAReqAction(
3152 IN PRTMP_ADAPTER pAd,
3153 IN MLME_QUEUE_ELEM *Elem);
3154
3155VOID PeerAddBARspAction(
3156 IN PRTMP_ADAPTER pAd,
3157 IN MLME_QUEUE_ELEM *Elem);
3158
3159VOID PeerDelBAAction(
3160 IN PRTMP_ADAPTER pAd,
3161 IN MLME_QUEUE_ELEM *Elem);
3162
3163VOID PeerBAAction(
3164 IN PRTMP_ADAPTER pAd,
3165 IN MLME_QUEUE_ELEM *Elem);
3166
3167VOID SendPSMPAction(
3168 IN PRTMP_ADAPTER pAd,
3169 IN UCHAR Wcid,
3170 IN UCHAR Psmp);
3171
3172VOID PeerRMAction(
3173 IN PRTMP_ADAPTER pAd,
3174 IN MLME_QUEUE_ELEM *Elem);
3175
3176VOID PeerPublicAction(
3177 IN PRTMP_ADAPTER pAd,
3178 IN MLME_QUEUE_ELEM *Elem);
3179
3180VOID StaPublicAction(
3181 IN PRTMP_ADAPTER pAd,
3182 IN UCHAR Bss2040Coexist);
3183
3184VOID PeerBSSTranAction(
3185 IN PRTMP_ADAPTER pAd,
3186 IN MLME_QUEUE_ELEM *Elem);
3187
3188VOID PeerHTAction(
3189 IN PRTMP_ADAPTER pAd,
3190 IN MLME_QUEUE_ELEM *Elem);
3191
3192VOID PeerQOSAction(
3193 IN PRTMP_ADAPTER pAd,
3194 IN MLME_QUEUE_ELEM *Elem);
3195
3196VOID RECBATimerTimeout(
3197 IN PVOID SystemSpecific1,
3198 IN PVOID FunctionContext,
3199 IN PVOID SystemSpecific2,
3200 IN PVOID SystemSpecific3);
3201
3202VOID ORIBATimerTimeout(
3203 IN PRTMP_ADAPTER pAd);
3204
3205VOID SendRefreshBAR(
3206 IN PRTMP_ADAPTER pAd,
3207 IN MAC_TABLE_ENTRY *pEntry);
3208
3209VOID ActHeaderInit(
3210 IN PRTMP_ADAPTER pAd,
3211 IN OUT PHEADER_802_11 pHdr80211,
3212 IN PUCHAR Addr1,
3213 IN PUCHAR Addr2,
3214 IN PUCHAR Addr3);
3215
3216VOID BarHeaderInit(
3217 IN PRTMP_ADAPTER pAd,
3218 IN OUT PFRAME_BAR pCntlBar,
3219 IN PUCHAR pDA,
3220 IN PUCHAR pSA);
3221
3222VOID InsertActField(
3223 IN PRTMP_ADAPTER pAd,
3224 OUT PUCHAR pFrameBuf,
3225 OUT PULONG pFrameLen,
3226 IN UINT8 Category,
3227 IN UINT8 ActCode);
3228
3229BOOLEAN QosBADataParse(
3230 IN PRTMP_ADAPTER pAd,
3231 IN BOOLEAN bAMSDU,
3232 IN PUCHAR p8023Header,
3233 IN UCHAR WCID,
3234 IN UCHAR TID,
3235 IN USHORT Sequence,
3236 IN UCHAR DataOffset,
3237 IN USHORT Datasize,
3238 IN UINT CurRxIndex);
3239
3240BOOLEAN CntlEnqueueForRecv(
3241 IN PRTMP_ADAPTER pAd,
3242 IN ULONG Wcid,
3243 IN ULONG MsgLen,
3244 IN PFRAME_BA_REQ pMsg);
3245
3246VOID BaAutoManSwitch(
3247 IN PRTMP_ADAPTER pAd);
3248
3249VOID HTIOTCheck(
3250 IN PRTMP_ADAPTER pAd,
3251 IN UCHAR BatRecIdx);
3252
3253//
3254// Private routines in rtmp_data.c
3255//
3256BOOLEAN RTMPHandleRxDoneInterrupt(
3257 IN PRTMP_ADAPTER pAd);
3258
3259VOID RTMPHandleTxDoneInterrupt(
3260 IN PRTMP_ADAPTER pAd);
3261
3262BOOLEAN RTMPHandleTxRingDmaDoneInterrupt(
3263 IN PRTMP_ADAPTER pAd,
3264 IN INT_SOURCE_CSR_STRUC TxRingBitmap);
3265
3266VOID RTMPHandleMgmtRingDmaDoneInterrupt(
3267 IN PRTMP_ADAPTER pAd);
3268
3269VOID RTMPHandleTBTTInterrupt(
3270 IN PRTMP_ADAPTER pAd);
3271
3272VOID RTMPHandlePreTBTTInterrupt(
3273 IN PRTMP_ADAPTER pAd);
3274
3275void RTMPHandleTwakeupInterrupt(
3276 IN PRTMP_ADAPTER pAd);
3277
3278VOID RTMPHandleRxCoherentInterrupt(
3279 IN PRTMP_ADAPTER pAd);
3280
3281BOOLEAN TxFrameIsAggregatible(
3282 IN PRTMP_ADAPTER pAd,
3283 IN PUCHAR pPrevAddr1,
3284 IN PUCHAR p8023hdr);
3285
3286BOOLEAN PeerIsAggreOn(
3287 IN PRTMP_ADAPTER pAd,
3288 IN ULONG TxRate,
3289 IN PMAC_TABLE_ENTRY pMacEntry);
3290
3291NDIS_STATUS Sniff2BytesFromNdisBuffer(
3292 IN PNDIS_BUFFER pFirstBuffer,
3293 IN UCHAR DesiredOffset,
3294 OUT PUCHAR pByte0,
3295 OUT PUCHAR pByte1);
3296
3297NDIS_STATUS STASendPacket(
3298 IN PRTMP_ADAPTER pAd,
3299 IN PNDIS_PACKET pPacket);
3300
3301VOID STASendPackets(
3302 IN NDIS_HANDLE MiniportAdapterContext,
3303 IN PPNDIS_PACKET ppPacketArray,
3304 IN UINT NumberOfPackets);
3305
3306VOID RTMPDeQueuePacket(
3307 IN PRTMP_ADAPTER pAd,
3308 IN BOOLEAN bIntContext,
3309 IN UCHAR QueIdx,
3310 IN UCHAR Max_Tx_Packets);
3311
3312NDIS_STATUS RTMPHardTransmit(
3313 IN PRTMP_ADAPTER pAd,
3314 IN PNDIS_PACKET pPacket,
3315 IN UCHAR QueIdx,
3316 OUT PULONG pFreeTXDLeft);
3317
3318NDIS_STATUS STAHardTransmit(
3319 IN PRTMP_ADAPTER pAd,
3320 IN TX_BLK *pTxBlk,
3321 IN UCHAR QueIdx);
3322
3323VOID STARxEAPOLFrameIndicate(
3324 IN PRTMP_ADAPTER pAd,
3325 IN MAC_TABLE_ENTRY *pEntry,
3326 IN RX_BLK *pRxBlk,
3327 IN UCHAR FromWhichBSSID);
3328
3329NDIS_STATUS RTMPFreeTXDRequest(
3330 IN PRTMP_ADAPTER pAd,
3331 IN UCHAR RingType,
3332 IN UCHAR NumberRequired,
3333 IN PUCHAR FreeNumberIs);
3334
3335NDIS_STATUS MlmeHardTransmit(
3336 IN PRTMP_ADAPTER pAd,
3337 IN UCHAR QueIdx,
3338 IN PNDIS_PACKET pPacket);
3339
3340NDIS_STATUS MlmeHardTransmitMgmtRing(
3341 IN PRTMP_ADAPTER pAd,
3342 IN UCHAR QueIdx,
3343 IN PNDIS_PACKET pPacket);
3344
3345NDIS_STATUS MlmeHardTransmitTxRing(
3346 IN PRTMP_ADAPTER pAd,
3347 IN UCHAR QueIdx,
3348 IN PNDIS_PACKET pPacket);
3349
3350USHORT RTMPCalcDuration(
3351 IN PRTMP_ADAPTER pAd,
3352 IN UCHAR Rate,
3353 IN ULONG Size);
3354
3355VOID RTMPWriteTxWI(
3356 IN PRTMP_ADAPTER pAd,
3357 IN PTXWI_STRUC pTxWI,
3358 IN BOOLEAN FRAG,
3359 IN BOOLEAN CFACK,
3360 IN BOOLEAN InsTimestamp,
3361 IN BOOLEAN AMPDU,
3362 IN BOOLEAN Ack,
3363 IN BOOLEAN NSeq, // HW new a sequence.
3364 IN UCHAR BASize,
3365 IN UCHAR WCID,
3366 IN ULONG Length,
3367 IN UCHAR PID,
3368 IN UCHAR TID,
3369 IN UCHAR TxRate,
3370 IN UCHAR Txopmode,
3371 IN BOOLEAN CfAck,
3372 IN HTTRANSMIT_SETTING *pTransmit);
3373
3374
3375VOID RTMPWriteTxWI_Data(
3376 IN PRTMP_ADAPTER pAd,
3377 IN OUT PTXWI_STRUC pTxWI,
3378 IN TX_BLK *pTxBlk);
3379
3380
3381VOID RTMPWriteTxWI_Cache(
3382 IN PRTMP_ADAPTER pAd,
3383 IN OUT PTXWI_STRUC pTxWI,
3384 IN TX_BLK *pTxBlk);
3385
3386VOID RTMPWriteTxDescriptor(
3387 IN PRTMP_ADAPTER pAd,
3388 IN PTXD_STRUC pTxD,
3389 IN BOOLEAN bWIV,
3390 IN UCHAR QSEL);
3391
3392VOID RTMPSuspendMsduTransmission(
3393 IN PRTMP_ADAPTER pAd);
3394
3395VOID RTMPResumeMsduTransmission(
3396 IN PRTMP_ADAPTER pAd);
3397
3398NDIS_STATUS MiniportMMRequest(
3399 IN PRTMP_ADAPTER pAd,
3400 IN UCHAR QueIdx,
3401 IN PUCHAR pData,
3402 IN UINT Length);
3403
3404NDIS_STATUS MiniportDataMMRequest(
3405 IN PRTMP_ADAPTER pAd,
3406 IN UCHAR QueIdx,
3407 IN PUCHAR pData,
3408 IN UINT Length);
3409
3410VOID RTMPSendNullFrame(
3411 IN PRTMP_ADAPTER pAd,
3412 IN UCHAR TxRate,
3413 IN BOOLEAN bQosNull);
3414
3415VOID RTMPSendDisassociationFrame(
3416 IN PRTMP_ADAPTER pAd);
3417
3418VOID RTMPSendRTSFrame(
3419 IN PRTMP_ADAPTER pAd,
3420 IN PUCHAR pDA,
3421 IN unsigned int NextMpduSize,
3422 IN UCHAR TxRate,
3423 IN UCHAR RTSRate,
3424 IN USHORT AckDuration,
3425 IN UCHAR QueIdx,
3426 IN UCHAR FrameGap);
3427
3428
3429NDIS_STATUS RTMPApplyPacketFilter(
3430 IN PRTMP_ADAPTER pAd,
3431 IN PRT28XX_RXD_STRUC pRxD,
3432 IN PHEADER_802_11 pHeader);
3433
3434PQUEUE_HEADER RTMPCheckTxSwQueue(
3435 IN PRTMP_ADAPTER pAd,
3436 OUT UCHAR *QueIdx);
3437
3438VOID RTMPReportMicError(
3439 IN PRTMP_ADAPTER pAd,
3440 IN PCIPHER_KEY pWpaKey);
3441
3442VOID WpaMicFailureReportFrame(
3443 IN PRTMP_ADAPTER pAd,
3444 IN MLME_QUEUE_ELEM *Elem);
3445
3446VOID WpaDisassocApAndBlockAssoc(
3447 IN PVOID SystemSpecific1,
3448 IN PVOID FunctionContext,
3449 IN PVOID SystemSpecific2,
3450 IN PVOID SystemSpecific3);
3451
3452NDIS_STATUS RTMPCloneNdisPacket(
3453 IN PRTMP_ADAPTER pAd,
3454 IN BOOLEAN pInsAMSDUHdr,
3455 IN PNDIS_PACKET pInPacket,
3456 OUT PNDIS_PACKET *ppOutPacket);
3457
3458NDIS_STATUS RTMPAllocateNdisPacket(
3459 IN PRTMP_ADAPTER pAd,
3460 IN PNDIS_PACKET *pPacket,
3461 IN PUCHAR pHeader,
3462 IN UINT HeaderLen,
3463 IN PUCHAR pData,
3464 IN UINT DataLen);
3465
3466VOID RTMPFreeNdisPacket(
3467 IN PRTMP_ADAPTER pAd,
3468 IN PNDIS_PACKET pPacket);
3469
3470BOOLEAN RTMPFreeTXDUponTxDmaDone(
3471 IN PRTMP_ADAPTER pAd,
3472 IN UCHAR QueIdx);
3473
3474BOOLEAN RTMPCheckDHCPFrame(
3475 IN PRTMP_ADAPTER pAd,
3476 IN PNDIS_PACKET pPacket);
3477
3478
3479BOOLEAN RTMPCheckEtherType(
3480 IN PRTMP_ADAPTER pAd,
3481 IN PNDIS_PACKET pPacket);
3482
3483
3484VOID RTMPCckBbpTuning(
3485 IN PRTMP_ADAPTER pAd,
3486 IN UINT TxRate);
3487
3488//
3489// Private routines in rtmp_wep.c
3490//
3491VOID RTMPInitWepEngine(
3492 IN PRTMP_ADAPTER pAd,
3493 IN PUCHAR pKey,
3494 IN UCHAR KeyId,
3495 IN UCHAR KeyLen,
3496 IN PUCHAR pDest);
3497
3498VOID RTMPEncryptData(
3499 IN PRTMP_ADAPTER pAd,
3500 IN PUCHAR pSrc,
3501 IN PUCHAR pDest,
3502 IN UINT Len);
3503
3504BOOLEAN RTMPDecryptData(
3505 IN PRTMP_ADAPTER pAdapter,
3506 IN PUCHAR pSrc,
3507 IN UINT Len,
3508 IN UINT idx);
3509
3510BOOLEAN RTMPSoftDecryptWEP(
3511 IN PRTMP_ADAPTER pAd,
3512 IN PUCHAR pData,
3513 IN ULONG DataByteCnt,
3514 IN PCIPHER_KEY pGroupKey);
3515
3516VOID RTMPSetICV(
3517 IN PRTMP_ADAPTER pAd,
3518 IN PUCHAR pDest);
3519
3520VOID ARCFOUR_INIT(
3521 IN PARCFOURCONTEXT Ctx,
3522 IN PUCHAR pKey,
3523 IN UINT KeyLen);
3524
3525UCHAR ARCFOUR_BYTE(
3526 IN PARCFOURCONTEXT Ctx);
3527
3528VOID ARCFOUR_DECRYPT(
3529 IN PARCFOURCONTEXT Ctx,
3530 IN PUCHAR pDest,
3531 IN PUCHAR pSrc,
3532 IN UINT Len);
3533
3534VOID ARCFOUR_ENCRYPT(
3535 IN PARCFOURCONTEXT Ctx,
3536 IN PUCHAR pDest,
3537 IN PUCHAR pSrc,
3538 IN UINT Len);
3539
3540VOID WPAARCFOUR_ENCRYPT(
3541 IN PARCFOURCONTEXT Ctx,
3542 IN PUCHAR pDest,
3543 IN PUCHAR pSrc,
3544 IN UINT Len);
3545
3546UINT RTMP_CALC_FCS32(
3547 IN UINT Fcs,
3548 IN PUCHAR Cp,
3549 IN INT Len);
3550
3551//
3552// MLME routines
3553//
3554
3555// Asic/RF/BBP related functions
3556
3557VOID AsicAdjustTxPower(
3558 IN PRTMP_ADAPTER pAd);
3559
3560VOID AsicUpdateProtect(
3561 IN PRTMP_ADAPTER pAd,
3562 IN USHORT OperaionMode,
3563 IN UCHAR SetMask,
3564 IN BOOLEAN bDisableBGProtect,
3565 IN BOOLEAN bNonGFExist);
3566
3567VOID AsicSwitchChannel(
3568 IN PRTMP_ADAPTER pAd,
3569 IN UCHAR Channel,
3570 IN BOOLEAN bScan);
3571
3572VOID AsicLockChannel(
3573 IN PRTMP_ADAPTER pAd,
3574 IN UCHAR Channel) ;
3575
3576VOID AsicAntennaSelect(
3577 IN PRTMP_ADAPTER pAd,
3578 IN UCHAR Channel);
3579
3580VOID AsicAntennaSetting(
3581 IN PRTMP_ADAPTER pAd,
3582 IN ABGBAND_STATE BandState);
3583
3584VOID AsicRfTuningExec(
3585 IN PVOID SystemSpecific1,
3586 IN PVOID FunctionContext,
3587 IN PVOID SystemSpecific2,
3588 IN PVOID SystemSpecific3);
3589
3590VOID AsicSleepThenAutoWakeup(
3591 IN PRTMP_ADAPTER pAd,
3592 IN USHORT TbttNumToNextWakeUp);
3593
3594VOID AsicForceSleep(
3595 IN PRTMP_ADAPTER pAd);
3596
3597VOID AsicForceWakeup(
3598 IN PRTMP_ADAPTER pAd,
3599 IN BOOLEAN bFromTx);
3600
3601VOID AsicSetBssid(
3602 IN PRTMP_ADAPTER pAd,
3603 IN PUCHAR pBssid);
3604
3605VOID AsicSetMcastWC(
3606 IN PRTMP_ADAPTER pAd);
3607
3608VOID AsicDelWcidTab(
3609 IN PRTMP_ADAPTER pAd,
3610 IN UCHAR Wcid);
3611
3612VOID AsicEnableRDG(
3613 IN PRTMP_ADAPTER pAd);
3614
3615VOID AsicDisableRDG(
3616 IN PRTMP_ADAPTER pAd);
3617
3618VOID AsicDisableSync(
3619 IN PRTMP_ADAPTER pAd);
3620
3621VOID AsicEnableBssSync(
3622 IN PRTMP_ADAPTER pAd);
3623
3624VOID AsicEnableIbssSync(
3625 IN PRTMP_ADAPTER pAd);
3626
3627VOID AsicSetEdcaParm(
3628 IN PRTMP_ADAPTER pAd,
3629 IN PEDCA_PARM pEdcaParm);
3630
3631VOID AsicSetSlotTime(
3632 IN PRTMP_ADAPTER pAd,
3633 IN BOOLEAN bUseShortSlotTime);
3634
3635VOID AsicAddSharedKeyEntry(
3636 IN PRTMP_ADAPTER pAd,
3637 IN UCHAR BssIndex,
3638 IN UCHAR KeyIdx,
3639 IN UCHAR CipherAlg,
3640 IN PUCHAR pKey,
3641 IN PUCHAR pTxMic,
3642 IN PUCHAR pRxMic);
3643
3644VOID AsicRemoveSharedKeyEntry(
3645 IN PRTMP_ADAPTER pAd,
3646 IN UCHAR BssIndex,
3647 IN UCHAR KeyIdx);
3648
3649VOID AsicUpdateWCIDAttribute(
3650 IN PRTMP_ADAPTER pAd,
3651 IN USHORT WCID,
3652 IN UCHAR BssIndex,
3653 IN UCHAR CipherAlg,
3654 IN BOOLEAN bUsePairewiseKeyTable);
3655
3656VOID AsicUpdateWCIDIVEIV(
3657 IN PRTMP_ADAPTER pAd,
3658 IN USHORT WCID,
3659 IN ULONG uIV,
3660 IN ULONG uEIV);
3661
3662VOID AsicUpdateRxWCIDTable(
3663 IN PRTMP_ADAPTER pAd,
3664 IN USHORT WCID,
3665 IN PUCHAR pAddr);
3666
3667VOID AsicAddKeyEntry(
3668 IN PRTMP_ADAPTER pAd,
3669 IN USHORT WCID,
3670 IN UCHAR BssIndex,
3671 IN UCHAR KeyIdx,
3672 IN PCIPHER_KEY pCipherKey,
3673 IN BOOLEAN bUsePairewiseKeyTable,
3674 IN BOOLEAN bTxKey);
3675
3676VOID AsicAddPairwiseKeyEntry(
3677 IN PRTMP_ADAPTER pAd,
3678 IN PUCHAR pAddr,
3679 IN UCHAR WCID,
3680 IN CIPHER_KEY *pCipherKey);
3681
3682VOID AsicRemovePairwiseKeyEntry(
3683 IN PRTMP_ADAPTER pAd,
3684 IN UCHAR BssIdx,
3685 IN UCHAR Wcid);
3686
3687BOOLEAN AsicSendCommandToMcu(
3688 IN PRTMP_ADAPTER pAd,
3689 IN UCHAR Command,
3690 IN UCHAR Token,
3691 IN UCHAR Arg0,
3692 IN UCHAR Arg1);
3693
3694
3695VOID MacAddrRandomBssid(
3696 IN PRTMP_ADAPTER pAd,
3697 OUT PUCHAR pAddr);
3698
3699VOID MgtMacHeaderInit(
3700 IN PRTMP_ADAPTER pAd,
3701 IN OUT PHEADER_802_11 pHdr80211,
3702 IN UCHAR SubType,
3703 IN UCHAR ToDs,
3704 IN PUCHAR pDA,
3705 IN PUCHAR pBssid);
3706
3707VOID MlmeRadioOff(
3708 IN PRTMP_ADAPTER pAd);
3709
3710VOID MlmeRadioOn(
3711 IN PRTMP_ADAPTER pAd);
3712
3713
3714VOID BssTableInit(
3715 IN BSS_TABLE *Tab);
3716
3717VOID BATableInit(
3718 IN PRTMP_ADAPTER pAd,
3719 IN BA_TABLE *Tab);
3720
3721ULONG BssTableSearch(
3722 IN BSS_TABLE *Tab,
3723 IN PUCHAR pBssid,
3724 IN UCHAR Channel);
3725
3726ULONG BssSsidTableSearch(
3727 IN BSS_TABLE *Tab,
3728 IN PUCHAR pBssid,
3729 IN PUCHAR pSsid,
3730 IN UCHAR SsidLen,
3731 IN UCHAR Channel);
3732
3733ULONG BssTableSearchWithSSID(
3734 IN BSS_TABLE *Tab,
3735 IN PUCHAR Bssid,
3736 IN PUCHAR pSsid,
3737 IN UCHAR SsidLen,
3738 IN UCHAR Channel);
3739
3740VOID BssTableDeleteEntry(
3741 IN OUT PBSS_TABLE pTab,
3742 IN PUCHAR pBssid,
3743 IN UCHAR Channel);
3744
3745VOID BATableDeleteORIEntry(
3746 IN OUT PRTMP_ADAPTER pAd,
3747 IN BA_ORI_ENTRY *pBAORIEntry);
3748
3749VOID BATableDeleteRECEntry(
3750 IN OUT PRTMP_ADAPTER pAd,
3751 IN BA_REC_ENTRY *pBARECEntry);
3752
3753VOID BATableTearORIEntry(
3754 IN OUT PRTMP_ADAPTER pAd,
3755 IN UCHAR TID,
3756 IN UCHAR Wcid,
3757 IN BOOLEAN bForceDelete,
3758 IN BOOLEAN ALL);
3759
3760VOID BATableTearRECEntry(
3761 IN OUT PRTMP_ADAPTER pAd,
3762 IN UCHAR TID,
3763 IN UCHAR WCID,
3764 IN BOOLEAN ALL);
3765
3766VOID BssEntrySet(
3767 IN PRTMP_ADAPTER pAd,
3768 OUT PBSS_ENTRY pBss,
3769 IN PUCHAR pBssid,
3770 IN CHAR Ssid[],
3771 IN UCHAR SsidLen,
3772 IN UCHAR BssType,
3773 IN USHORT BeaconPeriod,
3774 IN PCF_PARM CfParm,
3775 IN USHORT AtimWin,
3776 IN USHORT CapabilityInfo,
3777 IN UCHAR SupRate[],
3778 IN UCHAR SupRateLen,
3779 IN UCHAR ExtRate[],
3780 IN UCHAR ExtRateLen,
3781 IN HT_CAPABILITY_IE *pHtCapability,
3782 IN ADD_HT_INFO_IE *pAddHtInfo, // AP might use this additional ht info IE
3783 IN UCHAR HtCapabilityLen,
3784 IN UCHAR AddHtInfoLen,
3785 IN UCHAR NewExtChanOffset,
3786 IN UCHAR Channel,
3787 IN CHAR Rssi,
3788 IN LARGE_INTEGER TimeStamp,
3789 IN UCHAR CkipFlag,
3790 IN PEDCA_PARM pEdcaParm,
3791 IN PQOS_CAPABILITY_PARM pQosCapability,
3792 IN PQBSS_LOAD_PARM pQbssLoad,
3793 IN USHORT LengthVIE,
3794 IN PNDIS_802_11_VARIABLE_IEs pVIE);
3795
3796ULONG BssTableSetEntry(
3797 IN PRTMP_ADAPTER pAd,
3798 OUT PBSS_TABLE pTab,
3799 IN PUCHAR pBssid,
3800 IN CHAR Ssid[],
3801 IN UCHAR SsidLen,
3802 IN UCHAR BssType,
3803 IN USHORT BeaconPeriod,
3804 IN CF_PARM *CfParm,
3805 IN USHORT AtimWin,
3806 IN USHORT CapabilityInfo,
3807 IN UCHAR SupRate[],
3808 IN UCHAR SupRateLen,
3809 IN UCHAR ExtRate[],
3810 IN UCHAR ExtRateLen,
3811 IN HT_CAPABILITY_IE *pHtCapability,
3812 IN ADD_HT_INFO_IE *pAddHtInfo, // AP might use this additional ht info IE
3813 IN UCHAR HtCapabilityLen,
3814 IN UCHAR AddHtInfoLen,
3815 IN UCHAR NewExtChanOffset,
3816 IN UCHAR Channel,
3817 IN CHAR Rssi,
3818 IN LARGE_INTEGER TimeStamp,
3819 IN UCHAR CkipFlag,
3820 IN PEDCA_PARM pEdcaParm,
3821 IN PQOS_CAPABILITY_PARM pQosCapability,
3822 IN PQBSS_LOAD_PARM pQbssLoad,
3823 IN USHORT LengthVIE,
3824 IN PNDIS_802_11_VARIABLE_IEs pVIE);
3825
3826VOID BATableInsertEntry(
3827 IN PRTMP_ADAPTER pAd,
3828 IN USHORT Aid,
3829 IN USHORT TimeOutValue,
3830 IN USHORT StartingSeq,
3831 IN UCHAR TID,
3832 IN UCHAR BAWinSize,
3833 IN UCHAR OriginatorStatus,
3834 IN BOOLEAN IsRecipient);
3835
3836VOID BssTableSsidSort(
3837 IN PRTMP_ADAPTER pAd,
3838 OUT BSS_TABLE *OutTab,
3839 IN CHAR Ssid[],
3840 IN UCHAR SsidLen);
3841
3842VOID BssTableSortByRssi(
3843 IN OUT BSS_TABLE *OutTab);
3844
3845VOID BssCipherParse(
3846 IN OUT PBSS_ENTRY pBss);
3847
3848NDIS_STATUS MlmeQueueInit(
3849 IN MLME_QUEUE *Queue);
3850
3851VOID MlmeQueueDestroy(
3852 IN MLME_QUEUE *Queue);
3853
3854BOOLEAN MlmeEnqueue(
3855 IN PRTMP_ADAPTER pAd,
3856 IN ULONG Machine,
3857 IN ULONG MsgType,
3858 IN ULONG MsgLen,
3859 IN VOID *Msg);
3860
3861BOOLEAN MlmeEnqueueForRecv(
3862 IN PRTMP_ADAPTER pAd,
3863 IN ULONG Wcid,
3864 IN ULONG TimeStampHigh,
3865 IN ULONG TimeStampLow,
3866 IN UCHAR Rssi0,
3867 IN UCHAR Rssi1,
3868 IN UCHAR Rssi2,
3869 IN ULONG MsgLen,
3870 IN PVOID Msg,
3871 IN UCHAR Signal);
3872
3873
3874BOOLEAN MlmeDequeue(
3875 IN MLME_QUEUE *Queue,
3876 OUT MLME_QUEUE_ELEM **Elem);
3877
3878VOID MlmeRestartStateMachine(
3879 IN PRTMP_ADAPTER pAd);
3880
3881BOOLEAN MlmeQueueEmpty(
3882 IN MLME_QUEUE *Queue);
3883
3884BOOLEAN MlmeQueueFull(
3885 IN MLME_QUEUE *Queue);
3886
3887BOOLEAN MsgTypeSubst(
3888 IN PRTMP_ADAPTER pAd,
3889 IN PFRAME_802_11 pFrame,
3890 OUT INT *Machine,
3891 OUT INT *MsgType);
3892
3893VOID StateMachineInit(
3894 IN STATE_MACHINE *Sm,
3895 IN STATE_MACHINE_FUNC Trans[],
3896 IN ULONG StNr,
3897 IN ULONG MsgNr,
3898 IN STATE_MACHINE_FUNC DefFunc,
3899 IN ULONG InitState,
3900 IN ULONG Base);
3901
3902VOID StateMachineSetAction(
3903 IN STATE_MACHINE *S,
3904 IN ULONG St,
3905 ULONG Msg,
3906 IN STATE_MACHINE_FUNC F);
3907
3908VOID StateMachinePerformAction(
3909 IN PRTMP_ADAPTER pAd,
3910 IN STATE_MACHINE *S,
3911 IN MLME_QUEUE_ELEM *Elem);
3912
3913VOID Drop(
3914 IN PRTMP_ADAPTER pAd,
3915 IN MLME_QUEUE_ELEM *Elem);
3916
3917VOID AssocStateMachineInit(
3918 IN PRTMP_ADAPTER pAd,
3919 IN STATE_MACHINE *Sm,
3920 OUT STATE_MACHINE_FUNC Trans[]);
3921
3922VOID ReassocTimeout(
3923 IN PVOID SystemSpecific1,
3924 IN PVOID FunctionContext,
3925 IN PVOID SystemSpecific2,
3926 IN PVOID SystemSpecific3);
3927
3928VOID AssocTimeout(
3929 IN PVOID SystemSpecific1,
3930 IN PVOID FunctionContext,
3931 IN PVOID SystemSpecific2,
3932 IN PVOID SystemSpecific3);
3933
3934VOID DisassocTimeout(
3935 IN PVOID SystemSpecific1,
3936 IN PVOID FunctionContext,
3937 IN PVOID SystemSpecific2,
3938 IN PVOID SystemSpecific3);
3939
3940//----------------------------------------------
3941VOID MlmeDisassocReqAction(
3942 IN PRTMP_ADAPTER pAd,
3943 IN MLME_QUEUE_ELEM *Elem);
3944
3945VOID MlmeAssocReqAction(
3946 IN PRTMP_ADAPTER pAd,
3947 IN MLME_QUEUE_ELEM *Elem);
3948
3949VOID MlmeReassocReqAction(
3950 IN PRTMP_ADAPTER pAd,
3951 IN MLME_QUEUE_ELEM *Elem);
3952
3953VOID MlmeDisassocReqAction(
3954 IN PRTMP_ADAPTER pAd,
3955 IN MLME_QUEUE_ELEM *Elem);
3956
3957VOID PeerAssocRspAction(
3958 IN PRTMP_ADAPTER pAd,
3959 IN MLME_QUEUE_ELEM *Elem);
3960
3961VOID PeerReassocRspAction(
3962 IN PRTMP_ADAPTER pAd,
3963 IN MLME_QUEUE_ELEM *Elem);
3964
3965VOID PeerDisassocAction(
3966 IN PRTMP_ADAPTER pAd,
3967 IN MLME_QUEUE_ELEM *Elem);
3968
3969VOID DisassocTimeoutAction(
3970 IN PRTMP_ADAPTER pAd,
3971 IN MLME_QUEUE_ELEM *Elem);
3972
3973VOID AssocTimeoutAction(
3974 IN PRTMP_ADAPTER pAd,
3975 IN MLME_QUEUE_ELEM *Elem);
3976
3977VOID ReassocTimeoutAction(
3978 IN PRTMP_ADAPTER pAd,
3979 IN MLME_QUEUE_ELEM *Elem);
3980
3981VOID Cls3errAction(
3982 IN PRTMP_ADAPTER pAd,
3983 IN PUCHAR pAddr);
3984
3985VOID SwitchBetweenWepAndCkip(
3986 IN PRTMP_ADAPTER pAd);
3987
3988VOID InvalidStateWhenAssoc(
3989 IN PRTMP_ADAPTER pAd,
3990 IN MLME_QUEUE_ELEM *Elem);
3991
3992VOID InvalidStateWhenReassoc(
3993 IN PRTMP_ADAPTER pAd,
3994 IN MLME_QUEUE_ELEM *Elem);
3995
3996VOID InvalidStateWhenDisassociate(
3997 IN PRTMP_ADAPTER pAd,
3998 IN MLME_QUEUE_ELEM *Elem);
3999
4000#ifdef RT2870
4001VOID MlmeCntlConfirm(
4002 IN PRTMP_ADAPTER pAd,
4003 IN ULONG MsgType,
4004 IN USHORT Msg);
4005#endif // RT2870 //
4006
4007VOID ComposePsPoll(
4008 IN PRTMP_ADAPTER pAd);
4009
4010VOID ComposeNullFrame(
4011 IN PRTMP_ADAPTER pAd);
4012
4013VOID AssocPostProc(
4014 IN PRTMP_ADAPTER pAd,
4015 IN PUCHAR pAddr2,
4016 IN USHORT CapabilityInfo,
4017 IN USHORT Aid,
4018 IN UCHAR SupRate[],
4019 IN UCHAR SupRateLen,
4020 IN UCHAR ExtRate[],
4021 IN UCHAR ExtRateLen,
4022 IN PEDCA_PARM pEdcaParm,
4023 IN HT_CAPABILITY_IE *pHtCapability,
4024 IN UCHAR HtCapabilityLen,
4025 IN ADD_HT_INFO_IE *pAddHtInfo);
4026
4027VOID AuthStateMachineInit(
4028 IN PRTMP_ADAPTER pAd,
4029 IN PSTATE_MACHINE sm,
4030 OUT STATE_MACHINE_FUNC Trans[]);
4031
4032VOID AuthTimeout(
4033 IN PVOID SystemSpecific1,
4034 IN PVOID FunctionContext,
4035 IN PVOID SystemSpecific2,
4036 IN PVOID SystemSpecific3);
4037
4038VOID MlmeAuthReqAction(
4039 IN PRTMP_ADAPTER pAd,
4040 IN MLME_QUEUE_ELEM *Elem);
4041
4042VOID PeerAuthRspAtSeq2Action(
4043 IN PRTMP_ADAPTER pAd,
4044 IN MLME_QUEUE_ELEM *Elem);
4045
4046VOID PeerAuthRspAtSeq4Action(
4047 IN PRTMP_ADAPTER pAd,
4048 IN MLME_QUEUE_ELEM *Elem);
4049
4050VOID AuthTimeoutAction(
4051 IN PRTMP_ADAPTER pAd,
4052 IN MLME_QUEUE_ELEM *Elem);
4053
4054VOID Cls2errAction(
4055 IN PRTMP_ADAPTER pAd,
4056 IN PUCHAR pAddr);
4057
4058VOID MlmeDeauthReqAction(
4059 IN PRTMP_ADAPTER pAd,
4060 IN MLME_QUEUE_ELEM *Elem);
4061
4062VOID InvalidStateWhenAuth(
4063 IN PRTMP_ADAPTER pAd,
4064 IN MLME_QUEUE_ELEM *Elem);
4065
4066//=============================================
4067
4068VOID AuthRspStateMachineInit(
4069 IN PRTMP_ADAPTER pAd,
4070 IN PSTATE_MACHINE Sm,
4071 IN STATE_MACHINE_FUNC Trans[]);
4072
4073VOID PeerDeauthAction(
4074 IN PRTMP_ADAPTER pAd,
4075 IN MLME_QUEUE_ELEM *Elem);
4076
4077VOID PeerAuthSimpleRspGenAndSend(
4078 IN PRTMP_ADAPTER pAd,
4079 IN PHEADER_802_11 pHdr80211,
4080 IN USHORT Alg,
4081 IN USHORT Seq,
4082 IN USHORT Reason,
4083 IN USHORT Status);
4084
4085//
4086// Private routines in dls.c
4087//
4088
4089//========================================
4090
4091VOID SyncStateMachineInit(
4092 IN PRTMP_ADAPTER pAd,
4093 IN STATE_MACHINE *Sm,
4094 OUT STATE_MACHINE_FUNC Trans[]);
4095
4096VOID BeaconTimeout(
4097 IN PVOID SystemSpecific1,
4098 IN PVOID FunctionContext,
4099 IN PVOID SystemSpecific2,
4100 IN PVOID SystemSpecific3);
4101
4102VOID ScanTimeout(
4103 IN PVOID SystemSpecific1,
4104 IN PVOID FunctionContext,
4105 IN PVOID SystemSpecific2,
4106 IN PVOID SystemSpecific3);
4107
4108VOID MlmeScanReqAction(
4109 IN PRTMP_ADAPTER pAd,
4110 IN MLME_QUEUE_ELEM *Elem);
4111
4112VOID InvalidStateWhenScan(
4113 IN PRTMP_ADAPTER pAd,
4114 IN MLME_QUEUE_ELEM *Elem);
4115
4116VOID InvalidStateWhenJoin(
4117 IN PRTMP_ADAPTER pAd,
4118 IN MLME_QUEUE_ELEM *Elem);
4119
4120VOID InvalidStateWhenStart(
4121 IN PRTMP_ADAPTER pAd,
4122 IN MLME_QUEUE_ELEM *Elem);
4123
4124VOID PeerBeacon(
4125 IN PRTMP_ADAPTER pAd,
4126 IN MLME_QUEUE_ELEM *Elem);
4127
4128VOID EnqueueProbeRequest(
4129 IN PRTMP_ADAPTER pAd);
4130
4131BOOLEAN ScanRunning(
4132 IN PRTMP_ADAPTER pAd);
4133//=========================================
4134
4135VOID MlmeCntlInit(
4136 IN PRTMP_ADAPTER pAd,
4137 IN STATE_MACHINE *S,
4138 OUT STATE_MACHINE_FUNC Trans[]);
4139
4140VOID MlmeCntlMachinePerformAction(
4141 IN PRTMP_ADAPTER pAd,
4142 IN STATE_MACHINE *S,
4143 IN MLME_QUEUE_ELEM *Elem);
4144
4145VOID CntlIdleProc(
4146 IN PRTMP_ADAPTER pAd,
4147 IN MLME_QUEUE_ELEM *Elem);
4148
4149VOID CntlOidScanProc(
4150 IN PRTMP_ADAPTER pAd,
4151 IN MLME_QUEUE_ELEM *Elem);
4152
4153VOID CntlOidSsidProc(
4154 IN PRTMP_ADAPTER pAd,
4155 IN MLME_QUEUE_ELEM * Elem);
4156
4157VOID CntlOidRTBssidProc(
4158 IN PRTMP_ADAPTER pAd,
4159 IN MLME_QUEUE_ELEM * Elem);
4160
4161VOID CntlMlmeRoamingProc(
4162 IN PRTMP_ADAPTER pAd,
4163 IN MLME_QUEUE_ELEM * Elem);
4164
4165VOID CntlWaitDisassocProc(
4166 IN PRTMP_ADAPTER pAd,
4167 IN MLME_QUEUE_ELEM *Elem);
4168
4169VOID CntlWaitJoinProc(
4170 IN PRTMP_ADAPTER pAd,
4171 IN MLME_QUEUE_ELEM *Elem);
4172
4173VOID CntlWaitReassocProc(
4174 IN PRTMP_ADAPTER pAd,
4175 IN MLME_QUEUE_ELEM *Elem);
4176
4177VOID CntlWaitStartProc(
4178 IN PRTMP_ADAPTER pAd,
4179 IN MLME_QUEUE_ELEM *Elem);
4180
4181VOID CntlWaitAuthProc(
4182 IN PRTMP_ADAPTER pAd,
4183 IN MLME_QUEUE_ELEM *Elem);
4184
4185VOID CntlWaitAuthProc2(
4186 IN PRTMP_ADAPTER pAd,
4187 IN MLME_QUEUE_ELEM *Elem);
4188
4189VOID CntlWaitAssocProc(
4190 IN PRTMP_ADAPTER pAd,
4191 IN MLME_QUEUE_ELEM *Elem);
4192
4193VOID LinkUp(
4194 IN PRTMP_ADAPTER pAd,
4195 IN UCHAR BssType);
4196
4197VOID LinkDown(
4198 IN PRTMP_ADAPTER pAd,
4199 IN BOOLEAN IsReqFromAP);
4200
4201VOID IterateOnBssTab(
4202 IN PRTMP_ADAPTER pAd);
4203
4204VOID IterateOnBssTab2(
4205 IN PRTMP_ADAPTER pAd);;
4206
4207VOID JoinParmFill(
4208 IN PRTMP_ADAPTER pAd,
4209 IN OUT MLME_JOIN_REQ_STRUCT *JoinReq,
4210 IN ULONG BssIdx);
4211
4212VOID AssocParmFill(
4213 IN PRTMP_ADAPTER pAd,
4214 IN OUT MLME_ASSOC_REQ_STRUCT *AssocReq,
4215 IN PUCHAR pAddr,
4216 IN USHORT CapabilityInfo,
4217 IN ULONG Timeout,
4218 IN USHORT ListenIntv);
4219
4220VOID ScanParmFill(
4221 IN PRTMP_ADAPTER pAd,
4222 IN OUT MLME_SCAN_REQ_STRUCT *ScanReq,
4223 IN CHAR Ssid[],
4224 IN UCHAR SsidLen,
4225 IN UCHAR BssType,
4226 IN UCHAR ScanType);
4227
4228VOID DisassocParmFill(
4229 IN PRTMP_ADAPTER pAd,
4230 IN OUT MLME_DISASSOC_REQ_STRUCT *DisassocReq,
4231 IN PUCHAR pAddr,
4232 IN USHORT Reason);
4233
4234VOID StartParmFill(
4235 IN PRTMP_ADAPTER pAd,
4236 IN OUT MLME_START_REQ_STRUCT *StartReq,
4237 IN CHAR Ssid[],
4238 IN UCHAR SsidLen);
4239
4240VOID AuthParmFill(
4241 IN PRTMP_ADAPTER pAd,
4242 IN OUT MLME_AUTH_REQ_STRUCT *AuthReq,
4243 IN PUCHAR pAddr,
4244 IN USHORT Alg);
4245
4246VOID EnqueuePsPoll(
4247 IN PRTMP_ADAPTER pAd);
4248
4249VOID EnqueueBeaconFrame(
4250 IN PRTMP_ADAPTER pAd);
4251
4252VOID MlmeJoinReqAction(
4253 IN PRTMP_ADAPTER pAd,
4254 IN MLME_QUEUE_ELEM *Elem);
4255
4256VOID MlmeScanReqAction(
4257 IN PRTMP_ADAPTER pAd,
4258 IN MLME_QUEUE_ELEM *Elem);
4259
4260VOID MlmeStartReqAction(
4261 IN PRTMP_ADAPTER pAd,
4262 IN MLME_QUEUE_ELEM *Elem);
4263
4264VOID ScanTimeoutAction(
4265 IN PRTMP_ADAPTER pAd,
4266 IN MLME_QUEUE_ELEM *Elem);
4267
4268VOID BeaconTimeoutAtJoinAction(
4269 IN PRTMP_ADAPTER pAd,
4270 IN MLME_QUEUE_ELEM *Elem);
4271
4272VOID PeerBeaconAtScanAction(
4273 IN PRTMP_ADAPTER pAd,
4274 IN MLME_QUEUE_ELEM *Elem);
4275
4276VOID PeerBeaconAtJoinAction(
4277 IN PRTMP_ADAPTER pAd,
4278 IN MLME_QUEUE_ELEM *Elem);
4279
4280VOID PeerBeacon(
4281 IN PRTMP_ADAPTER pAd,
4282 IN MLME_QUEUE_ELEM *Elem);
4283
4284VOID PeerProbeReqAction(
4285 IN PRTMP_ADAPTER pAd,
4286 IN MLME_QUEUE_ELEM *Elem);
4287
4288VOID ScanNextChannel(
4289 IN PRTMP_ADAPTER pAd);
4290
4291ULONG MakeIbssBeacon(
4292 IN PRTMP_ADAPTER pAd);
4293
4294VOID CCXAdjacentAPReport(
4295 IN PRTMP_ADAPTER pAd);
4296
4297BOOLEAN MlmeScanReqSanity(
4298 IN PRTMP_ADAPTER pAd,
4299 IN VOID *Msg,
4300 IN ULONG MsgLen,
4301 OUT UCHAR *BssType,
4302 OUT CHAR ssid[],
4303 OUT UCHAR *SsidLen,
4304 OUT UCHAR *ScanType);
4305
4306BOOLEAN PeerBeaconAndProbeRspSanity(
4307 IN PRTMP_ADAPTER pAd,
4308 IN VOID *Msg,
4309 IN ULONG MsgLen,
4310 IN UCHAR MsgChannel,
4311 OUT PUCHAR pAddr2,
4312 OUT PUCHAR pBssid,
4313 OUT CHAR Ssid[],
4314 OUT UCHAR *pSsidLen,
4315 OUT UCHAR *pBssType,
4316 OUT USHORT *pBeaconPeriod,
4317 OUT UCHAR *pChannel,
4318 OUT UCHAR *pNewChannel,
4319 OUT LARGE_INTEGER *pTimestamp,
4320 OUT CF_PARM *pCfParm,
4321 OUT USHORT *pAtimWin,
4322 OUT USHORT *pCapabilityInfo,
4323 OUT UCHAR *pErp,
4324 OUT UCHAR *pDtimCount,
4325 OUT UCHAR *pDtimPeriod,
4326 OUT UCHAR *pBcastFlag,
4327 OUT UCHAR *pMessageToMe,
4328 OUT UCHAR SupRate[],
4329 OUT UCHAR *pSupRateLen,
4330 OUT UCHAR ExtRate[],
4331 OUT UCHAR *pExtRateLen,
4332 OUT UCHAR *pCkipFlag,
4333 OUT UCHAR *pAironetCellPowerLimit,
4334 OUT PEDCA_PARM pEdcaParm,
4335 OUT PQBSS_LOAD_PARM pQbssLoad,
4336 OUT PQOS_CAPABILITY_PARM pQosCapability,
4337 OUT ULONG *pRalinkIe,
4338 OUT UCHAR *pHtCapabilityLen,
4339 OUT UCHAR *pPreNHtCapabilityLen,
4340 OUT HT_CAPABILITY_IE *pHtCapability,
4341 OUT UCHAR *AddHtInfoLen,
4342 OUT ADD_HT_INFO_IE *AddHtInfo,
4343 OUT UCHAR *NewExtChannel,
4344 OUT USHORT *LengthVIE,
4345 OUT PNDIS_802_11_VARIABLE_IEs pVIE);
4346
4347BOOLEAN PeerAddBAReqActionSanity(
4348 IN PRTMP_ADAPTER pAd,
4349 IN VOID *pMsg,
4350 IN ULONG MsgLen,
4351 OUT PUCHAR pAddr2);
4352
4353BOOLEAN PeerAddBARspActionSanity(
4354 IN PRTMP_ADAPTER pAd,
4355 IN VOID *pMsg,
4356 IN ULONG MsgLen);
4357
4358BOOLEAN PeerDelBAActionSanity(
4359 IN PRTMP_ADAPTER pAd,
4360 IN UCHAR Wcid,
4361 IN VOID *pMsg,
4362 IN ULONG MsgLen);
4363
4364BOOLEAN MlmeAssocReqSanity(
4365 IN PRTMP_ADAPTER pAd,
4366 IN VOID *Msg,
4367 IN ULONG MsgLen,
4368 OUT PUCHAR pApAddr,
4369 OUT USHORT *CapabilityInfo,
4370 OUT ULONG *Timeout,
4371 OUT USHORT *ListenIntv);
4372
4373BOOLEAN MlmeAuthReqSanity(
4374 IN PRTMP_ADAPTER pAd,
4375 IN VOID *Msg,
4376 IN ULONG MsgLen,
4377 OUT PUCHAR pAddr,
4378 OUT ULONG *Timeout,
4379 OUT USHORT *Alg);
4380
4381BOOLEAN MlmeStartReqSanity(
4382 IN PRTMP_ADAPTER pAd,
4383 IN VOID *Msg,
4384 IN ULONG MsgLen,
4385 OUT CHAR Ssid[],
4386 OUT UCHAR *Ssidlen);
4387
4388BOOLEAN PeerAuthSanity(
4389 IN PRTMP_ADAPTER pAd,
4390 IN VOID *Msg,
4391 IN ULONG MsgLen,
4392 OUT PUCHAR pAddr,
4393 OUT USHORT *Alg,
4394 OUT USHORT *Seq,
4395 OUT USHORT *Status,
4396 OUT CHAR ChlgText[]);
4397
4398BOOLEAN PeerAssocRspSanity(
4399 IN PRTMP_ADAPTER pAd,
4400 IN VOID *pMsg,
4401 IN ULONG MsgLen,
4402 OUT PUCHAR pAddr2,
4403 OUT USHORT *pCapabilityInfo,
4404 OUT USHORT *pStatus,
4405 OUT USHORT *pAid,
4406 OUT UCHAR SupRate[],
4407 OUT UCHAR *pSupRateLen,
4408 OUT UCHAR ExtRate[],
4409 OUT UCHAR *pExtRateLen,
4410 OUT HT_CAPABILITY_IE *pHtCapability,
4411 OUT ADD_HT_INFO_IE *pAddHtInfo, // AP might use this additional ht info IE
4412 OUT UCHAR *pHtCapabilityLen,
4413 OUT UCHAR *pAddHtInfoLen,
4414 OUT UCHAR *pNewExtChannelOffset,
4415 OUT PEDCA_PARM pEdcaParm,
4416 OUT UCHAR *pCkipFlag);
4417
4418BOOLEAN PeerDisassocSanity(
4419 IN PRTMP_ADAPTER pAd,
4420 IN VOID *Msg,
4421 IN ULONG MsgLen,
4422 OUT PUCHAR pAddr2,
4423 OUT USHORT *Reason);
4424
4425BOOLEAN PeerWpaMessageSanity(
4426 IN PRTMP_ADAPTER pAd,
4427 IN PEAPOL_PACKET pMsg,
4428 IN ULONG MsgLen,
4429 IN UCHAR MsgType,
4430 IN MAC_TABLE_ENTRY *pEntry);
4431
4432BOOLEAN PeerDeauthSanity(
4433 IN PRTMP_ADAPTER pAd,
4434 IN VOID *Msg,
4435 IN ULONG MsgLen,
4436 OUT PUCHAR pAddr2,
4437 OUT USHORT *Reason);
4438
4439BOOLEAN PeerProbeReqSanity(
4440 IN PRTMP_ADAPTER pAd,
4441 IN VOID *Msg,
4442 IN ULONG MsgLen,
4443 OUT PUCHAR pAddr2,
4444 OUT CHAR Ssid[],
4445 OUT UCHAR *pSsidLen);
4446
4447BOOLEAN GetTimBit(
4448 IN CHAR *Ptr,
4449 IN USHORT Aid,
4450 OUT UCHAR *TimLen,
4451 OUT UCHAR *BcastFlag,
4452 OUT UCHAR *DtimCount,
4453 OUT UCHAR *DtimPeriod,
4454 OUT UCHAR *MessageToMe);
4455
4456UCHAR ChannelSanity(
4457 IN PRTMP_ADAPTER pAd,
4458 IN UCHAR channel);
4459
4460NDIS_802_11_NETWORK_TYPE NetworkTypeInUseSanity(
4461 IN PBSS_ENTRY pBss);
4462
4463BOOLEAN MlmeDelBAReqSanity(
4464 IN PRTMP_ADAPTER pAd,
4465 IN VOID *Msg,
4466 IN ULONG MsgLen);
4467
4468BOOLEAN MlmeAddBAReqSanity(
4469 IN PRTMP_ADAPTER pAd,
4470 IN VOID *Msg,
4471 IN ULONG MsgLen,
4472 OUT PUCHAR pAddr2);
4473
4474ULONG MakeOutgoingFrame(
4475 OUT CHAR *Buffer,
4476 OUT ULONG *Length, ...);
4477
4478VOID LfsrInit(
4479 IN PRTMP_ADAPTER pAd,
4480 IN ULONG Seed);
4481
4482UCHAR RandomByte(
4483 IN PRTMP_ADAPTER pAd);
4484
4485VOID AsicUpdateAutoFallBackTable(
4486 IN PRTMP_ADAPTER pAd,
4487 IN PUCHAR pTxRate);
4488
4489VOID MlmePeriodicExec(
4490 IN PVOID SystemSpecific1,
4491 IN PVOID FunctionContext,
4492 IN PVOID SystemSpecific2,
4493 IN PVOID SystemSpecific3);
4494
4495VOID LinkDownExec(
4496 IN PVOID SystemSpecific1,
4497 IN PVOID FunctionContext,
4498 IN PVOID SystemSpecific2,
4499 IN PVOID SystemSpecific3);
4500
4501VOID LinkUpExec(
4502 IN PVOID SystemSpecific1,
4503 IN PVOID FunctionContext,
4504 IN PVOID SystemSpecific2,
4505 IN PVOID SystemSpecific3);
4506
4507VOID STAMlmePeriodicExec(
4508 PRTMP_ADAPTER pAd);
4509
4510VOID MlmeAutoScan(
4511 IN PRTMP_ADAPTER pAd);
4512
4513VOID MlmeAutoReconnectLastSSID(
4514 IN PRTMP_ADAPTER pAd);
4515
4516BOOLEAN MlmeValidateSSID(
4517 IN PUCHAR pSsid,
4518 IN UCHAR SsidLen);
4519
4520VOID MlmeCheckForRoaming(
4521 IN PRTMP_ADAPTER pAd,
4522 IN ULONG Now32);
4523
4524VOID MlmeCheckForFastRoaming(
4525 IN PRTMP_ADAPTER pAd,
4526 IN ULONG Now);
4527
4528VOID MlmeDynamicTxRateSwitching(
4529 IN PRTMP_ADAPTER pAd);
4530
4531VOID MlmeSetTxRate(
4532 IN PRTMP_ADAPTER pAd,
4533 IN PMAC_TABLE_ENTRY pEntry,
4534 IN PRTMP_TX_RATE_SWITCH pTxRate);
4535
4536VOID MlmeSelectTxRateTable(
4537 IN PRTMP_ADAPTER pAd,
4538 IN PMAC_TABLE_ENTRY pEntry,
4539 IN PUCHAR *ppTable,
4540 IN PUCHAR pTableSize,
4541 IN PUCHAR pInitTxRateIdx);
4542
4543VOID MlmeCalculateChannelQuality(
4544 IN PRTMP_ADAPTER pAd,
4545 IN ULONG Now);
4546
4547VOID MlmeCheckPsmChange(
4548 IN PRTMP_ADAPTER pAd,
4549 IN ULONG Now32);
4550
4551VOID MlmeSetPsmBit(
4552 IN PRTMP_ADAPTER pAd,
4553 IN USHORT psm);
4554
4555VOID MlmeSetTxPreamble(
4556 IN PRTMP_ADAPTER pAd,
4557 IN USHORT TxPreamble);
4558
4559VOID UpdateBasicRateBitmap(
4560 IN PRTMP_ADAPTER pAd);
4561
4562VOID MlmeUpdateTxRates(
4563 IN PRTMP_ADAPTER pAd,
4564 IN BOOLEAN bLinkUp,
4565 IN UCHAR apidx);
4566
4567VOID MlmeUpdateHtTxRates(
4568 IN PRTMP_ADAPTER pAd,
4569 IN UCHAR apidx);
4570
4571VOID RTMPCheckRates(
4572 IN PRTMP_ADAPTER pAd,
4573 IN OUT UCHAR SupRate[],
4574 IN OUT UCHAR *SupRateLen);
4575
4576BOOLEAN RTMPCheckChannel(
4577 IN PRTMP_ADAPTER pAd,
4578 IN UCHAR CentralChannel,
4579 IN UCHAR Channel);
4580
4581BOOLEAN RTMPCheckHt(
4582 IN PRTMP_ADAPTER pAd,
4583 IN UCHAR Wcid,
4584 IN OUT HT_CAPABILITY_IE *pHtCapability,
4585 IN OUT ADD_HT_INFO_IE *pAddHtInfo);
4586
4587VOID StaQuickResponeForRateUpExec(
4588 IN PVOID SystemSpecific1,
4589 IN PVOID FunctionContext,
4590 IN PVOID SystemSpecific2,
4591 IN PVOID SystemSpecific3);
4592
4593VOID AsicBbpTuning1(
4594 IN PRTMP_ADAPTER pAd);
4595
4596VOID AsicBbpTuning2(
4597 IN PRTMP_ADAPTER pAd);
4598
4599VOID RTMPUpdateMlmeRate(
4600 IN PRTMP_ADAPTER pAd);
4601
4602CHAR RTMPMaxRssi(
4603 IN PRTMP_ADAPTER pAd,
4604 IN CHAR Rssi0,
4605 IN CHAR Rssi1,
4606 IN CHAR Rssi2);
4607
4608#ifdef RT30xx
4609VOID AsicSetRxAnt(
4610 IN PRTMP_ADAPTER pAd,
4611 IN UCHAR Ant);
4612#endif
4613
4614VOID AsicEvaluateRxAnt(
4615 IN PRTMP_ADAPTER pAd);
4616
4617VOID AsicRxAntEvalTimeout(
4618 IN PVOID SystemSpecific1,
4619 IN PVOID FunctionContext,
4620 IN PVOID SystemSpecific2,
4621 IN PVOID SystemSpecific3);
4622
4623VOID APSDPeriodicExec(
4624 IN PVOID SystemSpecific1,
4625 IN PVOID FunctionContext,
4626 IN PVOID SystemSpecific2,
4627 IN PVOID SystemSpecific3);
4628
4629BOOLEAN RTMPCheckEntryEnableAutoRateSwitch(
4630 IN PRTMP_ADAPTER pAd,
4631 IN PMAC_TABLE_ENTRY pEntry);
4632
4633UCHAR RTMPStaFixedTxMode(
4634 IN PRTMP_ADAPTER pAd,
4635 IN PMAC_TABLE_ENTRY pEntry);
4636
4637VOID RTMPUpdateLegacyTxSetting(
4638 UCHAR fixed_tx_mode,
4639 PMAC_TABLE_ENTRY pEntry);
4640
4641BOOLEAN RTMPAutoRateSwitchCheck(
4642 IN PRTMP_ADAPTER pAd);
4643
4644NDIS_STATUS MlmeInit(
4645 IN PRTMP_ADAPTER pAd);
4646
4647VOID MlmeHandler(
4648 IN PRTMP_ADAPTER pAd);
4649
4650VOID MlmeHalt(
4651 IN PRTMP_ADAPTER pAd);
4652
4653VOID MlmeResetRalinkCounters(
4654 IN PRTMP_ADAPTER pAd);
4655
4656VOID BuildChannelList(
4657 IN PRTMP_ADAPTER pAd);
4658
4659UCHAR FirstChannel(
4660 IN PRTMP_ADAPTER pAd);
4661
4662UCHAR NextChannel(
4663 IN PRTMP_ADAPTER pAd,
4664 IN UCHAR channel);
4665
4666VOID ChangeToCellPowerLimit(
4667 IN PRTMP_ADAPTER pAd,
4668 IN UCHAR AironetCellPowerLimit);
4669
4670VOID RaiseClock(
4671 IN PRTMP_ADAPTER pAd,
4672 IN UINT32 *x);
4673
4674VOID LowerClock(
4675 IN PRTMP_ADAPTER pAd,
4676 IN UINT32 *x);
4677
4678USHORT ShiftInBits(
4679 IN PRTMP_ADAPTER pAd);
4680
4681VOID ShiftOutBits(
4682 IN PRTMP_ADAPTER pAd,
4683 IN USHORT data,
4684 IN USHORT count);
4685
4686VOID EEpromCleanup(
4687 IN PRTMP_ADAPTER pAd);
4688
4689VOID EWDS(
4690 IN PRTMP_ADAPTER pAd);
4691
4692VOID EWEN(
4693 IN PRTMP_ADAPTER pAd);
4694
4695USHORT RTMP_EEPROM_READ16(
4696 IN PRTMP_ADAPTER pAd,
4697 IN USHORT Offset);
4698
4699VOID RTMP_EEPROM_WRITE16(
4700 IN PRTMP_ADAPTER pAd,
4701 IN USHORT Offset,
4702 IN USHORT Data);
4703
4704//
4705// Prototypes of function definition in rtmp_tkip.c
4706//
4707VOID RTMPInitTkipEngine(
4708 IN PRTMP_ADAPTER pAd,
4709 IN PUCHAR pTKey,
4710 IN UCHAR KeyId,
4711 IN PUCHAR pTA,
4712 IN PUCHAR pMICKey,
4713 IN PUCHAR pTSC,
4714 OUT PULONG pIV16,
4715 OUT PULONG pIV32);
4716
4717VOID RTMPInitMICEngine(
4718 IN PRTMP_ADAPTER pAd,
4719 IN PUCHAR pKey,
4720 IN PUCHAR pDA,
4721 IN PUCHAR pSA,
4722 IN UCHAR UserPriority,
4723 IN PUCHAR pMICKey);
4724
4725BOOLEAN RTMPTkipCompareMICValue(
4726 IN PRTMP_ADAPTER pAd,
4727 IN PUCHAR pSrc,
4728 IN PUCHAR pDA,
4729 IN PUCHAR pSA,
4730 IN PUCHAR pMICKey,
4731 IN UCHAR UserPriority,
4732 IN UINT Len);
4733
4734VOID RTMPCalculateMICValue(
4735 IN PRTMP_ADAPTER pAd,
4736 IN PNDIS_PACKET pPacket,
4737 IN PUCHAR pEncap,
4738 IN PCIPHER_KEY pKey,
4739 IN UCHAR apidx);
4740
4741BOOLEAN RTMPTkipCompareMICValueWithLLC(
4742 IN PRTMP_ADAPTER pAd,
4743 IN PUCHAR pLLC,
4744 IN PUCHAR pSrc,
4745 IN PUCHAR pDA,
4746 IN PUCHAR pSA,
4747 IN PUCHAR pMICKey,
4748 IN UINT Len);
4749
4750VOID RTMPTkipAppendByte(
4751 IN PTKIP_KEY_INFO pTkip,
4752 IN UCHAR uChar);
4753
4754VOID RTMPTkipAppend(
4755 IN PTKIP_KEY_INFO pTkip,
4756 IN PUCHAR pSrc,
4757 IN UINT nBytes);
4758
4759VOID RTMPTkipGetMIC(
4760 IN PTKIP_KEY_INFO pTkip);
4761
4762BOOLEAN RTMPSoftDecryptTKIP(
4763 IN PRTMP_ADAPTER pAd,
4764 IN PUCHAR pData,
4765 IN ULONG DataByteCnt,
4766 IN UCHAR UserPriority,
4767 IN PCIPHER_KEY pWpaKey);
4768
4769BOOLEAN RTMPSoftDecryptAES(
4770 IN PRTMP_ADAPTER pAd,
4771 IN PUCHAR pData,
4772 IN ULONG DataByteCnt,
4773 IN PCIPHER_KEY pWpaKey);
4774
4775//
4776// Prototypes of function definition in cmm_info.c
4777//
4778NDIS_STATUS RTMPWPARemoveKeyProc(
4779 IN PRTMP_ADAPTER pAd,
4780 IN PVOID pBuf);
4781
4782VOID RTMPWPARemoveAllKeys(
4783 IN PRTMP_ADAPTER pAd);
4784
4785BOOLEAN RTMPCheckStrPrintAble(
4786 IN CHAR *pInPutStr,
4787 IN UCHAR strLen);
4788
4789VOID RTMPSetPhyMode(
4790 IN PRTMP_ADAPTER pAd,
4791 IN ULONG phymode);
4792
4793VOID RTMPUpdateHTIE(
4794 IN RT_HT_CAPABILITY *pRtHt,
4795 IN UCHAR *pMcsSet,
4796 OUT HT_CAPABILITY_IE *pHtCapability,
4797 OUT ADD_HT_INFO_IE *pAddHtInfo);
4798
4799VOID RTMPAddWcidAttributeEntry(
4800 IN PRTMP_ADAPTER pAd,
4801 IN UCHAR BssIdx,
4802 IN UCHAR KeyIdx,
4803 IN UCHAR CipherAlg,
4804 IN MAC_TABLE_ENTRY *pEntry);
4805
4806CHAR *GetEncryptType(
4807 CHAR enc);
4808
4809CHAR *GetAuthMode(
4810 CHAR auth);
4811
4812VOID RTMPIoctlGetSiteSurvey(
4813 IN PRTMP_ADAPTER pAdapter,
4814 IN struct iwreq *wrq);
4815
4816VOID RTMPIoctlGetMacTable(
4817 IN PRTMP_ADAPTER pAd,
4818 IN struct iwreq *wrq);
4819
4820VOID RTMPIndicateWPA2Status(
4821 IN PRTMP_ADAPTER pAdapter);
4822
4823VOID RTMPOPModeSwitching(
4824 IN PRTMP_ADAPTER pAd);
4825
4826VOID RTMPAddBSSIDCipher(
4827 IN PRTMP_ADAPTER pAd,
4828 IN UCHAR Aid,
4829 IN PNDIS_802_11_KEY pKey,
4830 IN UCHAR CipherAlg);
4831
4832VOID RTMPSetHT(
4833 IN PRTMP_ADAPTER pAd,
4834 IN OID_SET_HT_PHYMODE *pHTPhyMode);
4835
4836VOID RTMPSetIndividualHT(
4837 IN PRTMP_ADAPTER pAd,
4838 IN UCHAR apidx);
4839
4840VOID RTMPSendWirelessEvent(
4841 IN PRTMP_ADAPTER pAd,
4842 IN USHORT Event_flag,
4843 IN PUCHAR pAddr,
4844 IN UCHAR BssIdx,
4845 IN CHAR Rssi);
4846
4847VOID NICUpdateCntlCounters(
4848 IN PRTMP_ADAPTER pAd,
4849 IN PHEADER_802_11 pHeader,
4850 IN UCHAR SubType,
4851 IN PRXWI_STRUC pRxWI);
4852//
4853// prototype in wpa.c
4854//
4855BOOLEAN WpaMsgTypeSubst(
4856 IN UCHAR EAPType,
4857 OUT INT *MsgType);
4858
4859VOID WpaPskStateMachineInit(
4860 IN PRTMP_ADAPTER pAd,
4861 IN STATE_MACHINE *S,
4862 OUT STATE_MACHINE_FUNC Trans[]);
4863
4864VOID WpaEAPOLKeyAction(
4865 IN PRTMP_ADAPTER pAd,
4866 IN MLME_QUEUE_ELEM *Elem);
4867
4868VOID WpaPairMsg1Action(
4869 IN PRTMP_ADAPTER pAd,
4870 IN MLME_QUEUE_ELEM *Elem);
4871
4872VOID WpaPairMsg3Action(
4873 IN PRTMP_ADAPTER pAd,
4874 IN MLME_QUEUE_ELEM *Elem);
4875
4876VOID WpaGroupMsg1Action(
4877 IN PRTMP_ADAPTER pAd,
4878 IN MLME_QUEUE_ELEM *Elem);
4879
4880VOID WpaMacHeaderInit(
4881 IN PRTMP_ADAPTER pAd,
4882 IN OUT PHEADER_802_11 pHdr80211,
4883 IN UCHAR wep,
4884 IN PUCHAR pAddr1);
4885
4886VOID Wpa2PairMsg1Action(
4887 IN PRTMP_ADAPTER pAd,
4888 IN MLME_QUEUE_ELEM *Elem);
4889
4890VOID Wpa2PairMsg3Action(
4891 IN PRTMP_ADAPTER pAd,
4892 IN MLME_QUEUE_ELEM *Elem);
4893
4894BOOLEAN ParseKeyData(
4895 IN PRTMP_ADAPTER pAd,
4896 IN PUCHAR pKeyData,
4897 IN UCHAR KeyDataLen,
4898 IN UCHAR bPairewise);
4899
4900VOID RTMPToWirelessSta(
4901 IN PRTMP_ADAPTER pAd,
4902 IN PUCHAR pHeader802_3,
4903 IN UINT HdrLen,
4904 IN PUCHAR pData,
4905 IN UINT DataLen,
4906 IN BOOLEAN is4wayFrame);
4907
4908VOID HMAC_SHA1(
4909 IN UCHAR *text,
4910 IN UINT text_len,
4911 IN UCHAR *key,
4912 IN UINT key_len,
4913 IN UCHAR *digest);
4914
4915VOID PRF(
4916 IN UCHAR *key,
4917 IN INT key_len,
4918 IN UCHAR *prefix,
4919 IN INT prefix_len,
4920 IN UCHAR *data,
4921 IN INT data_len,
4922 OUT UCHAR *output,
4923 IN INT len);
4924
4925VOID CCKMPRF(
4926 IN UCHAR *key,
4927 IN INT key_len,
4928 IN UCHAR *data,
4929 IN INT data_len,
4930 OUT UCHAR *output,
4931 IN INT len);
4932
4933VOID WpaCountPTK(
4934 IN PRTMP_ADAPTER pAd,
4935 IN UCHAR *PMK,
4936 IN UCHAR *ANonce,
4937 IN UCHAR *AA,
4938 IN UCHAR *SNonce,
4939 IN UCHAR *SA,
4940 OUT UCHAR *output,
4941 IN UINT len);
4942
4943VOID GenRandom(
4944 IN PRTMP_ADAPTER pAd,
4945 IN UCHAR *macAddr,
4946 OUT UCHAR *random);
4947
4948//
4949// prototype in aironet.c
4950//
4951VOID AironetStateMachineInit(
4952 IN PRTMP_ADAPTER pAd,
4953 IN STATE_MACHINE *S,
4954 OUT STATE_MACHINE_FUNC Trans[]);
4955
4956VOID AironetMsgAction(
4957 IN PRTMP_ADAPTER pAd,
4958 IN MLME_QUEUE_ELEM *Elem);
4959
4960VOID AironetRequestAction(
4961 IN PRTMP_ADAPTER pAd,
4962 IN MLME_QUEUE_ELEM *Elem);
4963
4964VOID ChannelLoadRequestAction(
4965 IN PRTMP_ADAPTER pAd,
4966 IN UCHAR Index);
4967
4968VOID NoiseHistRequestAction(
4969 IN PRTMP_ADAPTER pAd,
4970 IN UCHAR Index);
4971
4972VOID BeaconRequestAction(
4973 IN PRTMP_ADAPTER pAd,
4974 IN UCHAR Index);
4975
4976VOID AironetReportAction(
4977 IN PRTMP_ADAPTER pAd,
4978 IN MLME_QUEUE_ELEM *Elem);
4979
4980VOID ChannelLoadReportAction(
4981 IN PRTMP_ADAPTER pAd,
4982 IN UCHAR Index);
4983
4984VOID NoiseHistReportAction(
4985 IN PRTMP_ADAPTER pAd,
4986 IN UCHAR Index);
4987
4988VOID AironetFinalReportAction(
4989 IN PRTMP_ADAPTER pAd);
4990
4991VOID BeaconReportAction(
4992 IN PRTMP_ADAPTER pAd,
4993 IN UCHAR Index);
4994
4995VOID AironetAddBeaconReport(
4996 IN PRTMP_ADAPTER pAd,
4997 IN ULONG Index,
4998 IN PMLME_QUEUE_ELEM pElem);
4999
5000VOID AironetCreateBeaconReportFromBssTable(
5001 IN PRTMP_ADAPTER pAd);
5002
5003VOID DBGPRINT_TX_RING(
5004 IN PRTMP_ADAPTER pAd,
5005 IN UCHAR QueIdx);
5006
5007VOID DBGPRINT_RX_RING(
5008 IN PRTMP_ADAPTER pAd);
5009
5010CHAR ConvertToRssi(
5011 IN PRTMP_ADAPTER pAd,
5012 IN CHAR Rssi,
5013 IN UCHAR RssiNumber);
5014
5015VOID APAsicEvaluateRxAnt(
5016 IN PRTMP_ADAPTER pAd);
5017
5018
5019VOID APAsicRxAntEvalTimeout(
5020 IN PRTMP_ADAPTER pAd);
5021
5022//
5023// function prototype in cmm_wpa.c
5024//
5025BOOLEAN RTMPCheckWPAframe(
5026 IN PRTMP_ADAPTER pAd,
5027 IN PMAC_TABLE_ENTRY pEntry,
5028 IN PUCHAR pData,
5029 IN ULONG DataByteCount,
5030 IN UCHAR FromWhichBSSID);
5031
5032VOID AES_GTK_KEY_UNWRAP(
5033 IN UCHAR *key,
5034 OUT UCHAR *plaintext,
5035 IN UCHAR c_len,
5036 IN UCHAR *ciphertext);
5037
5038BOOLEAN RTMPCheckRSNIE(
5039 IN PRTMP_ADAPTER pAd,
5040 IN PUCHAR pData,
5041 IN UCHAR DataLen,
5042 IN MAC_TABLE_ENTRY *pEntry,
5043 OUT UCHAR *Offset);
5044
5045BOOLEAN RTMPParseEapolKeyData(
5046 IN PRTMP_ADAPTER pAd,
5047 IN PUCHAR pKeyData,
5048 IN UCHAR KeyDataLen,
5049 IN UCHAR GroupKeyIndex,
5050 IN UCHAR MsgType,
5051 IN BOOLEAN bWPA2,
5052 IN MAC_TABLE_ENTRY *pEntry);
5053
5054VOID ConstructEapolMsg(
5055 IN PRTMP_ADAPTER pAd,
5056 IN UCHAR PeerAuthMode,
5057 IN UCHAR PeerWepStatus,
5058 IN UCHAR MyGroupKeyWepStatus,
5059 IN UCHAR MsgType,
5060 IN UCHAR DefaultKeyIdx,
5061 IN UCHAR *ReplayCounter,
5062 IN UCHAR *KeyNonce,
5063 IN UCHAR *TxRSC,
5064 IN UCHAR *PTK,
5065 IN UCHAR *GTK,
5066 IN UCHAR *RSNIE,
5067 IN UCHAR RSNIE_Len,
5068 OUT PEAPOL_PACKET pMsg);
5069
5070VOID CalculateMIC(
5071 IN PRTMP_ADAPTER pAd,
5072 IN UCHAR PeerWepStatus,
5073 IN UCHAR *PTK,
5074 OUT PEAPOL_PACKET pMsg);
5075
5076NDIS_STATUS RTMPSoftDecryptBroadCastData(
5077 IN PRTMP_ADAPTER pAd,
5078 IN RX_BLK *pRxBlk,
5079 IN NDIS_802_11_ENCRYPTION_STATUS GroupCipher,
5080 IN PCIPHER_KEY pShard_key);
5081
5082VOID ConstructEapolKeyData(
5083 IN PRTMP_ADAPTER pAd,
5084 IN UCHAR PeerAuthMode,
5085 IN UCHAR PeerWepStatus,
5086 IN UCHAR GroupKeyWepStatus,
5087 IN UCHAR MsgType,
5088 IN UCHAR DefaultKeyIdx,
5089 IN BOOLEAN bWPA2Capable,
5090 IN UCHAR *PTK,
5091 IN UCHAR *GTK,
5092 IN UCHAR *RSNIE,
5093 IN UCHAR RSNIE_LEN,
5094 OUT PEAPOL_PACKET pMsg);
5095
5096VOID RTMPMakeRSNIE(
5097 IN PRTMP_ADAPTER pAd,
5098 IN UINT AuthMode,
5099 IN UINT WepStatus,
5100 IN UCHAR apidx);
5101
5102//
5103// function prototype in ap_wpa.c
5104//
5105
5106BOOLEAN APWpaMsgTypeSubst(
5107 IN UCHAR EAPType,
5108 OUT INT *MsgType) ;
5109
5110MAC_TABLE_ENTRY *PACInquiry(
5111 IN PRTMP_ADAPTER pAd,
5112 IN ULONG Wcid);
5113
5114BOOLEAN RTMPCheckMcast(
5115 IN PRTMP_ADAPTER pAd,
5116 IN PEID_STRUCT eid_ptr,
5117 IN MAC_TABLE_ENTRY *pEntry);
5118
5119BOOLEAN RTMPCheckUcast(
5120 IN PRTMP_ADAPTER pAd,
5121 IN PEID_STRUCT eid_ptr,
5122 IN MAC_TABLE_ENTRY *pEntry);
5123
5124BOOLEAN RTMPCheckAUTH(
5125 IN PRTMP_ADAPTER pAd,
5126 IN PEID_STRUCT eid_ptr,
5127 IN MAC_TABLE_ENTRY *pEntry);
5128
5129VOID WPAStart4WayHS(
5130 IN PRTMP_ADAPTER pAd,
5131 IN MAC_TABLE_ENTRY *pEntry,
5132 IN ULONG TimeInterval);
5133
5134VOID WPAStart2WayGroupHS(
5135 IN PRTMP_ADAPTER pAd,
5136 IN MAC_TABLE_ENTRY *pEntry);
5137
5138VOID APWpaEAPPacketAction(
5139 IN PRTMP_ADAPTER pAd,
5140 IN MLME_QUEUE_ELEM *Elem);
5141
5142VOID APWpaEAPOLStartAction(
5143 IN PRTMP_ADAPTER pAd,
5144 IN MLME_QUEUE_ELEM *Elem);
5145
5146VOID APWpaEAPOLLogoffAction(
5147 IN PRTMP_ADAPTER pAd,
5148 IN MLME_QUEUE_ELEM *Elem);
5149
5150VOID APWpaEAPOLKeyAction(
5151 IN PRTMP_ADAPTER pAd,
5152 IN MLME_QUEUE_ELEM *Elem);
5153
5154VOID APWpaEAPOLASFAlertAction(
5155 IN PRTMP_ADAPTER pAd,
5156 IN MLME_QUEUE_ELEM *Elem);
5157
5158VOID HandleCounterMeasure(
5159 IN PRTMP_ADAPTER pAd,
5160 IN MAC_TABLE_ENTRY *pEntry);
5161
5162VOID PeerPairMsg2Action(
5163 IN PRTMP_ADAPTER pAd,
5164 IN MAC_TABLE_ENTRY *pEntry,
5165 IN MLME_QUEUE_ELEM *Elem);
5166
5167VOID PeerPairMsg4Action(
5168 IN PRTMP_ADAPTER pAd,
5169 IN MAC_TABLE_ENTRY *pEntry,
5170 IN MLME_QUEUE_ELEM *Elem);
5171
5172VOID CMTimerExec(
5173 IN PVOID SystemSpecific1,
5174 IN PVOID FunctionContext,
5175 IN PVOID SystemSpecific2,
5176 IN PVOID SystemSpecific3);
5177
5178VOID WPARetryExec(
5179 IN PVOID SystemSpecific1,
5180 IN PVOID FunctionContext,
5181 IN PVOID SystemSpecific2,
5182 IN PVOID SystemSpecific3);
5183
5184VOID EnqueueStartForPSKExec(
5185 IN PVOID SystemSpecific1,
5186 IN PVOID FunctionContext,
5187 IN PVOID SystemSpecific2,
5188 IN PVOID SystemSpecific3);
5189
5190VOID RTMPHandleSTAKey(
5191 IN PRTMP_ADAPTER pAdapter,
5192 IN MAC_TABLE_ENTRY *pEntry,
5193 IN MLME_QUEUE_ELEM *Elem);
5194
5195VOID PeerGroupMsg2Action(
5196 IN PRTMP_ADAPTER pAd,
5197 IN PMAC_TABLE_ENTRY pEntry,
5198 IN VOID *Msg,
5199 IN UINT MsgLen);
5200
5201VOID PairDisAssocAction(
5202 IN PRTMP_ADAPTER pAd,
5203 IN PMAC_TABLE_ENTRY pEntry,
5204 IN USHORT Reason);
5205
5206VOID MlmeDeAuthAction(
5207 IN PRTMP_ADAPTER pAd,
5208 IN PMAC_TABLE_ENTRY pEntry,
5209 IN USHORT Reason);
5210
5211VOID GREKEYPeriodicExec(
5212 IN PVOID SystemSpecific1,
5213 IN PVOID FunctionContext,
5214 IN PVOID SystemSpecific2,
5215 IN PVOID SystemSpecific3);
5216
5217VOID CountGTK(
5218 IN UCHAR *PMK,
5219 IN UCHAR *GNonce,
5220 IN UCHAR *AA,
5221 OUT UCHAR *output,
5222 IN UINT len);
5223
5224VOID GetSmall(
5225 IN PVOID pSrc1,
5226 IN PVOID pSrc2,
5227 OUT PUCHAR out,
5228 IN ULONG Length);
5229
5230VOID GetLarge(
5231 IN PVOID pSrc1,
5232 IN PVOID pSrc2,
5233 OUT PUCHAR out,
5234 IN ULONG Length);
5235
5236VOID APGenRandom(
5237 IN PRTMP_ADAPTER pAd,
5238 OUT UCHAR *random);
5239
5240VOID AES_GTK_KEY_WRAP(
5241 IN UCHAR *key,
5242 IN UCHAR *plaintext,
5243 IN UCHAR p_len,
5244 OUT UCHAR *ciphertext);
5245
5246VOID WpaSend(
5247 IN PRTMP_ADAPTER pAdapter,
5248 IN PUCHAR pPacket,
5249 IN ULONG Len);
5250
5251VOID APToWirelessSta(
5252 IN PRTMP_ADAPTER pAd,
5253 IN MAC_TABLE_ENTRY *pEntry,
5254 IN PUCHAR pHeader802_3,
5255 IN UINT HdrLen,
5256 IN PUCHAR pData,
5257 IN UINT DataLen,
5258 IN BOOLEAN bClearFrame);
5259
5260VOID RTMPAddPMKIDCache(
5261 IN PRTMP_ADAPTER pAd,
5262 IN INT apidx,
5263 IN PUCHAR pAddr,
5264 IN UCHAR *PMKID,
5265 IN UCHAR *PMK);
5266
5267INT RTMPSearchPMKIDCache(
5268 IN PRTMP_ADAPTER pAd,
5269 IN INT apidx,
5270 IN PUCHAR pAddr);
5271
5272VOID RTMPDeletePMKIDCache(
5273 IN PRTMP_ADAPTER pAd,
5274 IN INT apidx,
5275 IN INT idx);
5276
5277VOID RTMPMaintainPMKIDCache(
5278 IN PRTMP_ADAPTER pAd);
5279
5280VOID RTMPSendTriggerFrame(
5281 IN PRTMP_ADAPTER pAd,
5282 IN PVOID pBuffer,
5283 IN ULONG Length,
5284 IN UCHAR TxRate,
5285 IN BOOLEAN bQosNull);
5286
5287#ifdef RT30xx
5288VOID RTMPFilterCalibration(
5289 IN PRTMP_ADAPTER pAd);
5290#endif // RT30xx //
5291
5292/* timeout -- ms */
5293VOID RTMP_SetPeriodicTimer(
5294 IN NDIS_MINIPORT_TIMER *pTimer,
5295 IN unsigned long timeout);
5296
5297VOID RTMP_OS_Init_Timer(
5298 IN PRTMP_ADAPTER pAd,
5299 IN NDIS_MINIPORT_TIMER *pTimer,
5300 IN TIMER_FUNCTION function,
5301 IN PVOID data);
5302
5303VOID RTMP_OS_Add_Timer(
5304 IN NDIS_MINIPORT_TIMER *pTimer,
5305 IN unsigned long timeout);
5306
5307VOID RTMP_OS_Mod_Timer(
5308 IN NDIS_MINIPORT_TIMER *pTimer,
5309 IN unsigned long timeout);
5310
5311
5312VOID RTMP_OS_Del_Timer(
5313 IN NDIS_MINIPORT_TIMER *pTimer,
5314 OUT BOOLEAN *pCancelled);
5315
5316
5317VOID RTMP_OS_Release_Packet(
5318 IN PRTMP_ADAPTER pAd,
5319 IN PQUEUE_ENTRY pEntry);
5320
5321VOID RTMPusecDelay(
5322 IN ULONG usec);
5323
5324NDIS_STATUS os_alloc_mem(
5325 IN PRTMP_ADAPTER pAd,
5326 OUT PUCHAR *mem,
5327 IN ULONG size);
5328
5329NDIS_STATUS os_free_mem(
5330 IN PRTMP_ADAPTER pAd,
5331 IN PUCHAR mem);
5332
5333
5334void RTMP_AllocateSharedMemory(
5335 IN PRTMP_ADAPTER pAd,
5336 IN ULONG Length,
5337 IN BOOLEAN Cached,
5338 OUT PVOID *VirtualAddress,
5339 OUT PNDIS_PHYSICAL_ADDRESS PhysicalAddress);
5340
5341VOID RTMPFreeTxRxRingMemory(
5342 IN PRTMP_ADAPTER pAd);
5343
5344NDIS_STATUS AdapterBlockAllocateMemory(
5345 IN PVOID handle,
5346 OUT PVOID *ppAd);
5347
5348void RTMP_AllocateTxDescMemory(
5349 IN PRTMP_ADAPTER pAd,
5350 IN UINT Index,
5351 IN ULONG Length,
5352 IN BOOLEAN Cached,
5353 OUT PVOID *VirtualAddress,
5354 OUT PNDIS_PHYSICAL_ADDRESS PhysicalAddress);
5355
5356void RTMP_AllocateFirstTxBuffer(
5357 IN PRTMP_ADAPTER pAd,
5358 IN UINT Index,
5359 IN ULONG Length,
5360 IN BOOLEAN Cached,
5361 OUT PVOID *VirtualAddress,
5362 OUT PNDIS_PHYSICAL_ADDRESS PhysicalAddress);
5363
5364void RTMP_AllocateMgmtDescMemory(
5365 IN PRTMP_ADAPTER pAd,
5366 IN ULONG Length,
5367 IN BOOLEAN Cached,
5368 OUT PVOID *VirtualAddress,
5369 OUT PNDIS_PHYSICAL_ADDRESS PhysicalAddress);
5370
5371void RTMP_AllocateRxDescMemory(
5372 IN PRTMP_ADAPTER pAd,
5373 IN ULONG Length,
5374 IN BOOLEAN Cached,
5375 OUT PVOID *VirtualAddress,
5376 OUT PNDIS_PHYSICAL_ADDRESS PhysicalAddress);
5377
5378PNDIS_PACKET RTMP_AllocateRxPacketBuffer(
5379 IN PRTMP_ADAPTER pAd,
5380 IN ULONG Length,
5381 IN BOOLEAN Cached,
5382 OUT PVOID *VirtualAddress,
5383 OUT PNDIS_PHYSICAL_ADDRESS PhysicalAddress);
5384
5385PNDIS_PACKET RTMP_AllocateTxPacketBuffer(
5386 IN PRTMP_ADAPTER pAd,
5387 IN ULONG Length,
5388 IN BOOLEAN Cached,
5389 OUT PVOID *VirtualAddress);
5390
5391PNDIS_PACKET RTMP_AllocateFragPacketBuffer(
5392 IN PRTMP_ADAPTER pAd,
5393 IN ULONG Length);
5394
5395void RTMP_QueryPacketInfo(
5396 IN PNDIS_PACKET pPacket,
5397 OUT PACKET_INFO *pPacketInfo,
5398 OUT PUCHAR *pSrcBufVA,
5399 OUT UINT *pSrcBufLen);
5400
5401void RTMP_QueryNextPacketInfo(
5402 IN PNDIS_PACKET *ppPacket,
5403 OUT PACKET_INFO *pPacketInfo,
5404 OUT PUCHAR *pSrcBufVA,
5405 OUT UINT *pSrcBufLen);
5406
5407
5408BOOLEAN RTMP_FillTxBlkInfo(
5409 IN RTMP_ADAPTER *pAd,
5410 IN TX_BLK *pTxBlk);
5411
5412
5413PRTMP_SCATTER_GATHER_LIST
5414rt_get_sg_list_from_packet(PNDIS_PACKET pPacket, RTMP_SCATTER_GATHER_LIST *sg);
5415
5416
5417 void announce_802_3_packet(
5418 IN PRTMP_ADAPTER pAd,
5419 IN PNDIS_PACKET pPacket);
5420
5421
5422UINT BA_Reorder_AMSDU_Annnounce(
5423 IN PRTMP_ADAPTER pAd,
5424 IN PNDIS_PACKET pPacket);
5425
5426
5427UINT Handle_AMSDU_Packet(
5428 IN PRTMP_ADAPTER pAd,
5429 IN PUCHAR pData,
5430 IN ULONG DataSize,
5431 IN UCHAR FromWhichBSSID);
5432
5433
5434void convert_802_11_to_802_3_packet(
5435 IN PRTMP_ADAPTER pAd,
5436 IN PNDIS_PACKET pPacket,
5437 IN PUCHAR p8023hdr,
5438 IN PUCHAR pData,
5439 IN ULONG DataSize,
5440 IN UCHAR FromWhichBSSID);
5441
5442
5443PNET_DEV get_netdev_from_bssid(
5444 IN PRTMP_ADAPTER pAd,
5445 IN UCHAR FromWhichBSSID);
5446
5447
5448PNDIS_PACKET duplicate_pkt(
5449 IN PRTMP_ADAPTER pAd,
5450 IN PUCHAR pHeader802_3,
5451 IN UINT HdrLen,
5452 IN PUCHAR pData,
5453 IN ULONG DataSize,
5454 IN UCHAR FromWhichBSSID);
5455
5456
5457PNDIS_PACKET duplicate_pkt_with_TKIP_MIC(
5458 IN PRTMP_ADAPTER pAd,
5459 IN PNDIS_PACKET pOldPkt);
5460
5461PNDIS_PACKET duplicate_pkt_with_VLAN(
5462 IN PRTMP_ADAPTER pAd,
5463 IN PUCHAR pHeader802_3,
5464 IN UINT HdrLen,
5465 IN PUCHAR pData,
5466 IN ULONG DataSize,
5467 IN UCHAR FromWhichBSSID);
5468
5469PNDIS_PACKET duplicate_pkt_with_WPI(
5470 IN PRTMP_ADAPTER pAd,
5471 IN PNDIS_PACKET pPacket,
5472 IN UINT32 ext_head_len,
5473 IN UINT32 ext_tail_len);
5474
5475UCHAR VLAN_8023_Header_Copy(
5476 IN PRTMP_ADAPTER pAd,
5477 IN PUCHAR pHeader802_3,
5478 IN UINT HdrLen,
5479 OUT PUCHAR pData,
5480 IN UCHAR FromWhichBSSID);
5481
5482void ba_flush_reordering_timeout_mpdus(
5483 IN PRTMP_ADAPTER pAd,
5484 IN PBA_REC_ENTRY pBAEntry,
5485 IN ULONG Now32);
5486
5487
5488VOID BAOriSessionSetUp(
5489 IN PRTMP_ADAPTER pAd,
5490 IN MAC_TABLE_ENTRY *pEntry,
5491 IN UCHAR TID,
5492 IN USHORT TimeOut,
5493 IN ULONG DelayTime,
5494 IN BOOLEAN isForced);
5495
5496VOID BASessionTearDownALL(
5497 IN OUT PRTMP_ADAPTER pAd,
5498 IN UCHAR Wcid);
5499
5500BOOLEAN OS_Need_Clone_Packet(void);
5501
5502
5503VOID build_tx_packet(
5504 IN PRTMP_ADAPTER pAd,
5505 IN PNDIS_PACKET pPacket,
5506 IN PUCHAR pFrame,
5507 IN ULONG FrameLen);
5508
5509
5510VOID BAOriSessionTearDown(
5511 IN OUT PRTMP_ADAPTER pAd,
5512 IN UCHAR Wcid,
5513 IN UCHAR TID,
5514 IN BOOLEAN bPassive,
5515 IN BOOLEAN bForceSend);
5516
5517VOID BARecSessionTearDown(
5518 IN OUT PRTMP_ADAPTER pAd,
5519 IN UCHAR Wcid,
5520 IN UCHAR TID,
5521 IN BOOLEAN bPassive);
5522
5523BOOLEAN ba_reordering_resource_init(PRTMP_ADAPTER pAd, int num);
5524void ba_reordering_resource_release(PRTMP_ADAPTER pAd);
5525
5526ULONG AutoChBssInsertEntry(
5527 IN PRTMP_ADAPTER pAd,
5528 IN PUCHAR pBssid,
5529 IN CHAR Ssid[],
5530 IN UCHAR SsidLen,
5531 IN UCHAR ChannelNo,
5532 IN CHAR Rssi);
5533
5534void AutoChBssTableInit(
5535 IN PRTMP_ADAPTER pAd);
5536
5537void ChannelInfoInit(
5538 IN PRTMP_ADAPTER pAd);
5539
5540void AutoChBssTableDestroy(
5541 IN PRTMP_ADAPTER pAd);
5542
5543void ChannelInfoDestroy(
5544 IN PRTMP_ADAPTER pAd);
5545
5546UCHAR New_ApAutoSelectChannel(
5547 IN PRTMP_ADAPTER pAd);
5548
5549BOOLEAN rtstrmactohex(
5550 IN char *s1,
5551 IN char *s2);
5552
5553BOOLEAN rtstrcasecmp(
5554 IN char *s1,
5555 IN char *s2);
5556
5557char *rtstrstruncasecmp(
5558 IN char *s1,
5559 IN char *s2);
5560
5561char *rtstrstr(
5562 IN const char * s1,
5563 IN const char * s2);
5564
5565char *rstrtok(
5566 IN char * s,
5567 IN const char * ct);
5568
5569int rtinet_aton(
5570 const char *cp,
5571 unsigned int *addr);
5572
5573////////// common ioctl functions //////////
5574INT Set_DriverVersion_Proc(
5575 IN PRTMP_ADAPTER pAd,
5576 IN PUCHAR arg);
5577
5578INT Set_CountryRegion_Proc(
5579 IN PRTMP_ADAPTER pAd,
5580 IN PUCHAR arg);
5581
5582INT Set_CountryRegionABand_Proc(
5583 IN PRTMP_ADAPTER pAd,
5584 IN PUCHAR arg);
5585
5586INT Set_WirelessMode_Proc(
5587 IN PRTMP_ADAPTER pAd,
5588 IN PUCHAR arg);
5589
5590INT Set_Channel_Proc(
5591 IN PRTMP_ADAPTER pAd,
5592 IN PUCHAR arg);
5593
5594INT Set_ShortSlot_Proc(
5595 IN PRTMP_ADAPTER pAd,
5596 IN PUCHAR arg);
5597
5598INT Set_TxPower_Proc(
5599 IN PRTMP_ADAPTER pAd,
5600 IN PUCHAR arg);
5601
5602INT Set_BGProtection_Proc(
5603 IN PRTMP_ADAPTER pAd,
5604 IN PUCHAR arg);
5605
5606INT Set_TxPreamble_Proc(
5607 IN PRTMP_ADAPTER pAd,
5608 IN PUCHAR arg);
5609
5610INT Set_RTSThreshold_Proc(
5611 IN PRTMP_ADAPTER pAd,
5612 IN PUCHAR arg);
5613
5614INT Set_FragThreshold_Proc(
5615 IN PRTMP_ADAPTER pAd,
5616 IN PUCHAR arg);
5617
5618INT Set_TxBurst_Proc(
5619 IN PRTMP_ADAPTER pAd,
5620 IN PUCHAR arg);
5621
5622#ifdef AGGREGATION_SUPPORT
5623INT Set_PktAggregate_Proc(
5624 IN PRTMP_ADAPTER pAd,
5625 IN PUCHAR arg);
5626#endif
5627
5628INT Set_IEEE80211H_Proc(
5629 IN PRTMP_ADAPTER pAd,
5630 IN PUCHAR arg);
5631
5632#ifdef DBG
5633INT Set_Debug_Proc(
5634 IN PRTMP_ADAPTER pAd,
5635 IN PUCHAR arg);
5636#endif
5637
5638INT Show_DescInfo_Proc(
5639 IN PRTMP_ADAPTER pAd,
5640 IN PUCHAR arg);
5641
5642INT Set_ResetStatCounter_Proc(
5643 IN PRTMP_ADAPTER pAd,
5644 IN PUCHAR arg);
5645
5646INT Set_BASetup_Proc(
5647 IN PRTMP_ADAPTER pAd,
5648 IN PUCHAR arg);
5649
5650INT Set_BADecline_Proc(
5651 IN PRTMP_ADAPTER pAd,
5652 IN PUCHAR arg);
5653
5654INT Set_BAOriTearDown_Proc(
5655 IN PRTMP_ADAPTER pAd,
5656 IN PUCHAR arg);
5657
5658INT Set_BARecTearDown_Proc(
5659 IN PRTMP_ADAPTER pAd,
5660 IN PUCHAR arg);
5661
5662INT Set_HtBw_Proc(
5663 IN PRTMP_ADAPTER pAd,
5664 IN PUCHAR arg);
5665
5666INT Set_HtMcs_Proc(
5667 IN PRTMP_ADAPTER pAd,
5668 IN PUCHAR arg);
5669
5670INT Set_HtGi_Proc(
5671 IN PRTMP_ADAPTER pAd,
5672 IN PUCHAR arg);
5673
5674INT Set_HtOpMode_Proc(
5675 IN PRTMP_ADAPTER pAd,
5676 IN PUCHAR arg);
5677
5678INT Set_HtStbc_Proc(
5679 IN PRTMP_ADAPTER pAd,
5680 IN PUCHAR arg);
5681
5682INT Set_HtHtc_Proc(
5683 IN PRTMP_ADAPTER pAd,
5684 IN PUCHAR arg);
5685
5686INT Set_HtExtcha_Proc(
5687 IN PRTMP_ADAPTER pAd,
5688 IN PUCHAR arg);
5689
5690INT Set_HtMpduDensity_Proc(
5691 IN PRTMP_ADAPTER pAd,
5692 IN PUCHAR arg);
5693
5694INT Set_HtBaWinSize_Proc(
5695 IN PRTMP_ADAPTER pAd,
5696 IN PUCHAR arg);
5697
5698INT Set_HtRdg_Proc(
5699 IN PRTMP_ADAPTER pAd,
5700 IN PUCHAR arg);
5701
5702INT Set_HtLinkAdapt_Proc(
5703 IN PRTMP_ADAPTER pAd,
5704 IN PUCHAR arg);
5705
5706INT Set_HtAmsdu_Proc(
5707 IN PRTMP_ADAPTER pAd,
5708 IN PUCHAR arg);
5709
5710INT Set_HtAutoBa_Proc(
5711 IN PRTMP_ADAPTER pAd,
5712 IN PUCHAR arg);
5713
5714INT Set_HtProtect_Proc(
5715 IN PRTMP_ADAPTER pAd,
5716 IN PUCHAR arg);
5717
5718INT Set_HtMimoPs_Proc(
5719 IN PRTMP_ADAPTER pAd,
5720 IN PUCHAR arg);
5721
5722
5723INT Set_ForceShortGI_Proc(
5724 IN PRTMP_ADAPTER pAd,
5725 IN PUCHAR arg);
5726
5727INT Set_ForceGF_Proc(
5728 IN PRTMP_ADAPTER pAd,
5729 IN PUCHAR arg);
5730
5731INT SetCommonHT(
5732 IN PRTMP_ADAPTER pAd);
5733
5734INT Set_SendPSMPAction_Proc(
5735 IN PRTMP_ADAPTER pAd,
5736 IN PUCHAR arg);
5737
5738INT Set_HtMIMOPSmode_Proc(
5739 IN PRTMP_ADAPTER pAd,
5740 IN PUCHAR arg);
5741
5742
5743INT Set_HtTxBASize_Proc(
5744 IN PRTMP_ADAPTER pAd,
5745 IN PUCHAR arg);
5746
5747//Dls , kathy
5748VOID RTMPSendDLSTearDownFrame(
5749 IN PRTMP_ADAPTER pAd,
5750 IN PUCHAR pDA);
5751
5752//Block ACK
5753VOID QueryBATABLE(
5754 IN PRTMP_ADAPTER pAd,
5755 OUT PQUERYBA_TABLE pBAT);
5756
5757INT WpaCheckEapCode(
5758 IN PRTMP_ADAPTER pAd,
5759 IN PUCHAR pFrame,
5760 IN USHORT FrameLen,
5761 IN USHORT OffSet);
5762
5763VOID WpaSendMicFailureToWpaSupplicant(
5764 IN PRTMP_ADAPTER pAd,
5765 IN BOOLEAN bUnicast);
5766
5767VOID SendAssocIEsToWpaSupplicant(
5768 IN PRTMP_ADAPTER pAd);
5769
5770int wext_notify_event_assoc(
5771 IN RTMP_ADAPTER *pAd);
5772
5773VOID Handle_BSS_Width_Trigger_Events(
5774 IN PRTMP_ADAPTER pAd);
5775
5776void build_ext_channel_switch_ie(
5777 IN PRTMP_ADAPTER pAd,
5778 IN HT_EXT_CHANNEL_SWITCH_ANNOUNCEMENT_IE *pIE);
5779
5780BOOLEAN APRxDoneInterruptHandle(
5781 IN PRTMP_ADAPTER pAd);
5782
5783BOOLEAN STARxDoneInterruptHandle(
5784 IN PRTMP_ADAPTER pAd,
5785 IN BOOLEAN argc);
5786
5787// AMPDU packet indication
5788VOID Indicate_AMPDU_Packet(
5789 IN PRTMP_ADAPTER pAd,
5790 IN RX_BLK *pRxBlk,
5791 IN UCHAR FromWhichBSSID);
5792
5793// AMSDU packet indication
5794VOID Indicate_AMSDU_Packet(
5795 IN PRTMP_ADAPTER pAd,
5796 IN RX_BLK *pRxBlk,
5797 IN UCHAR FromWhichBSSID);
5798
5799// Normal legacy Rx packet indication
5800VOID Indicate_Legacy_Packet(
5801 IN PRTMP_ADAPTER pAd,
5802 IN RX_BLK *pRxBlk,
5803 IN UCHAR FromWhichBSSID);
5804
5805VOID Indicate_EAPOL_Packet(
5806 IN PRTMP_ADAPTER pAd,
5807 IN RX_BLK *pRxBlk,
5808 IN UCHAR FromWhichBSSID);
5809
5810void update_os_packet_info(
5811 IN PRTMP_ADAPTER pAd,
5812 IN RX_BLK *pRxBlk,
5813 IN UCHAR FromWhichBSSID);
5814
5815void wlan_802_11_to_802_3_packet(
5816 IN PRTMP_ADAPTER pAd,
5817 IN RX_BLK *pRxBlk,
5818 IN PUCHAR pHeader802_3,
5819 IN UCHAR FromWhichBSSID);
5820
5821UINT deaggregate_AMSDU_announce(
5822 IN PRTMP_ADAPTER pAd,
5823 PNDIS_PACKET pPacket,
5824 IN PUCHAR pData,
5825 IN ULONG DataSize);
5826
5827// remove LLC and get 802_3 Header
5828#define RTMP_802_11_REMOVE_LLC_AND_CONVERT_TO_802_3(_pRxBlk, _pHeader802_3) \
5829{ \
5830 PUCHAR _pRemovedLLCSNAP = NULL, _pDA, _pSA; \
5831 \
5832 if (RX_BLK_TEST_FLAG(_pRxBlk, fRX_MESH)) \
5833 { \
5834 _pDA = _pRxBlk->pHeader->Addr3; \
5835 _pSA = (PUCHAR)_pRxBlk->pHeader + sizeof(HEADER_802_11); \
5836 } \
5837 else \
5838 { \
5839 if (RX_BLK_TEST_FLAG(_pRxBlk, fRX_INFRA)) \
5840 { \
5841 _pDA = _pRxBlk->pHeader->Addr1; \
5842 if (RX_BLK_TEST_FLAG(_pRxBlk, fRX_DLS)) \
5843 _pSA = _pRxBlk->pHeader->Addr2; \
5844 else \
5845 _pSA = _pRxBlk->pHeader->Addr3; \
5846 } \
5847 else \
5848 { \
5849 _pDA = _pRxBlk->pHeader->Addr1; \
5850 _pSA = _pRxBlk->pHeader->Addr2; \
5851 } \
5852 } \
5853 \
5854 CONVERT_TO_802_3(_pHeader802_3, _pDA, _pSA, _pRxBlk->pData, \
5855 _pRxBlk->DataSize, _pRemovedLLCSNAP); \
5856}
5857
5858BOOLEAN APFowardWirelessStaToWirelessSta(
5859 IN PRTMP_ADAPTER pAd,
5860 IN PNDIS_PACKET pPacket,
5861 IN ULONG FromWhichBSSID);
5862
5863VOID Announce_or_Forward_802_3_Packet(
5864 IN PRTMP_ADAPTER pAd,
5865 IN PNDIS_PACKET pPacket,
5866 IN UCHAR FromWhichBSSID);
5867
5868VOID Sta_Announce_or_Forward_802_3_Packet(
5869 IN PRTMP_ADAPTER pAd,
5870 IN PNDIS_PACKET pPacket,
5871 IN UCHAR FromWhichBSSID);
5872
5873#define ANNOUNCE_OR_FORWARD_802_3_PACKET(_pAd, _pPacket, _FromWhichBSS)\
5874 Sta_Announce_or_Forward_802_3_Packet(_pAd, _pPacket, _FromWhichBSS);
5875 //announce_802_3_packet(_pAd, _pPacket);
5876
5877PNDIS_PACKET DuplicatePacket(
5878 IN PRTMP_ADAPTER pAd,
5879 IN PNDIS_PACKET pPacket,
5880 IN UCHAR FromWhichBSSID);
5881
5882
5883PNDIS_PACKET ClonePacket(
5884 IN PRTMP_ADAPTER pAd,
5885 IN PNDIS_PACKET pPacket,
5886 IN PUCHAR pData,
5887 IN ULONG DataSize);
5888
5889
5890// Normal, AMPDU or AMSDU
5891VOID CmmRxnonRalinkFrameIndicate(
5892 IN PRTMP_ADAPTER pAd,
5893 IN RX_BLK *pRxBlk,
5894 IN UCHAR FromWhichBSSID);
5895
5896VOID CmmRxRalinkFrameIndicate(
5897 IN PRTMP_ADAPTER pAd,
5898 IN MAC_TABLE_ENTRY *pEntry,
5899 IN RX_BLK *pRxBlk,
5900 IN UCHAR FromWhichBSSID);
5901
5902VOID Update_Rssi_Sample(
5903 IN PRTMP_ADAPTER pAd,
5904 IN RSSI_SAMPLE *pRssi,
5905 IN PRXWI_STRUC pRxWI);
5906
5907PNDIS_PACKET GetPacketFromRxRing(
5908 IN PRTMP_ADAPTER pAd,
5909 OUT PRT28XX_RXD_STRUC pSaveRxD,
5910 OUT BOOLEAN *pbReschedule,
5911 IN OUT UINT32 *pRxPending);
5912
5913PNDIS_PACKET RTMPDeFragmentDataFrame(
5914 IN PRTMP_ADAPTER pAd,
5915 IN RX_BLK *pRxBlk);
5916
5917////////////////////////////////////////
5918enum {
5919 DIDmsg_lnxind_wlansniffrm = 0x00000044,
5920 DIDmsg_lnxind_wlansniffrm_hosttime = 0x00010044,
5921 DIDmsg_lnxind_wlansniffrm_mactime = 0x00020044,
5922 DIDmsg_lnxind_wlansniffrm_channel = 0x00030044,
5923 DIDmsg_lnxind_wlansniffrm_rssi = 0x00040044,
5924 DIDmsg_lnxind_wlansniffrm_sq = 0x00050044,
5925 DIDmsg_lnxind_wlansniffrm_signal = 0x00060044,
5926 DIDmsg_lnxind_wlansniffrm_noise = 0x00070044,
5927 DIDmsg_lnxind_wlansniffrm_rate = 0x00080044,
5928 DIDmsg_lnxind_wlansniffrm_istx = 0x00090044,
5929 DIDmsg_lnxind_wlansniffrm_frmlen = 0x000A0044
5930};
5931enum {
5932 P80211ENUM_msgitem_status_no_value = 0x00
5933};
5934enum {
5935 P80211ENUM_truth_false = 0x00,
5936 P80211ENUM_truth_true = 0x01
5937};
5938
5939/* Definition from madwifi */
5940typedef struct {
5941 UINT32 did;
5942 UINT16 status;
5943 UINT16 len;
5944 UINT32 data;
5945} p80211item_uint32_t;
5946
5947typedef struct {
5948 UINT32 msgcode;
5949 UINT32 msglen;
5950#define WLAN_DEVNAMELEN_MAX 16
5951 UINT8 devname[WLAN_DEVNAMELEN_MAX];
5952 p80211item_uint32_t hosttime;
5953 p80211item_uint32_t mactime;
5954 p80211item_uint32_t channel;
5955 p80211item_uint32_t rssi;
5956 p80211item_uint32_t sq;
5957 p80211item_uint32_t signal;
5958 p80211item_uint32_t noise;
5959 p80211item_uint32_t rate;
5960 p80211item_uint32_t istx;
5961 p80211item_uint32_t frmlen;
5962} wlan_ng_prism2_header;
5963
5964/* The radio capture header precedes the 802.11 header. */
5965typedef struct PACKED _ieee80211_radiotap_header {
5966 UINT8 it_version; /* Version 0. Only increases
5967 * for drastic changes,
5968 * introduction of compatible
5969 * new fields does not count.
5970 */
5971 UINT8 it_pad;
5972 UINT16 it_len; /* length of the whole
5973 * header in bytes, including
5974 * it_version, it_pad,
5975 * it_len, and data fields.
5976 */
5977 UINT32 it_present; /* A bitmap telling which
5978 * fields are present. Set bit 31
5979 * (0x80000000) to extend the
5980 * bitmap by another 32 bits.
5981 * Additional extensions are made
5982 * by setting bit 31.
5983 */
5984}ieee80211_radiotap_header ;
5985
5986enum ieee80211_radiotap_type {
5987 IEEE80211_RADIOTAP_TSFT = 0,
5988 IEEE80211_RADIOTAP_FLAGS = 1,
5989 IEEE80211_RADIOTAP_RATE = 2,
5990 IEEE80211_RADIOTAP_CHANNEL = 3,
5991 IEEE80211_RADIOTAP_FHSS = 4,
5992 IEEE80211_RADIOTAP_DBM_ANTSIGNAL = 5,
5993 IEEE80211_RADIOTAP_DBM_ANTNOISE = 6,
5994 IEEE80211_RADIOTAP_LOCK_QUALITY = 7,
5995 IEEE80211_RADIOTAP_TX_ATTENUATION = 8,
5996 IEEE80211_RADIOTAP_DB_TX_ATTENUATION = 9,
5997 IEEE80211_RADIOTAP_DBM_TX_POWER = 10,
5998 IEEE80211_RADIOTAP_ANTENNA = 11,
5999 IEEE80211_RADIOTAP_DB_ANTSIGNAL = 12,
6000 IEEE80211_RADIOTAP_DB_ANTNOISE = 13
6001};
6002
6003#define WLAN_RADIOTAP_PRESENT ( \
6004 (1 << IEEE80211_RADIOTAP_TSFT) | \
6005 (1 << IEEE80211_RADIOTAP_FLAGS) | \
6006 (1 << IEEE80211_RADIOTAP_RATE) | \
6007 0)
6008
6009typedef struct _wlan_radiotap_header {
6010 ieee80211_radiotap_header wt_ihdr;
6011 INT64 wt_tsft;
6012 UINT8 wt_flags;
6013 UINT8 wt_rate;
6014} wlan_radiotap_header;
6015/* Definition from madwifi */
6016
6017void send_monitor_packets(
6018 IN PRTMP_ADAPTER pAd,
6019 IN RX_BLK *pRxBlk);
6020
6021#if WIRELESS_EXT >= 12
6022// This function will be called when query /proc
6023struct iw_statistics *rt28xx_get_wireless_stats(
6024 IN struct net_device *net_dev);
6025#endif
6026
6027VOID RTMPSetDesiredRates(
6028 IN PRTMP_ADAPTER pAdapter,
6029 IN LONG Rates);
6030
6031INT Set_FixedTxMode_Proc(
6032 IN PRTMP_ADAPTER pAd,
6033 IN PUCHAR arg);
6034
6035static inline char* GetPhyMode(
6036 int Mode)
6037{
6038 switch(Mode)
6039 {
6040 case MODE_CCK:
6041 return "CCK";
6042
6043 case MODE_OFDM:
6044 return "OFDM";
6045 case MODE_HTMIX:
6046 return "HTMIX";
6047
6048 case MODE_HTGREENFIELD:
6049 return "GREEN";
6050 default:
6051 return "N/A";
6052 }
6053}
6054
6055
6056static inline char* GetBW(
6057 int BW)
6058{
6059 switch(BW)
6060 {
6061 case BW_10:
6062 return "10M";
6063
6064 case BW_20:
6065 return "20M";
6066 case BW_40:
6067 return "40M";
6068 default:
6069 return "N/A";
6070 }
6071}
6072
6073
6074VOID RT28xxThreadTerminate(
6075 IN RTMP_ADAPTER *pAd);
6076
6077BOOLEAN RT28XXChipsetCheck(
6078 IN void *_dev_p);
6079
6080BOOLEAN RT28XXNetDevInit(
6081 IN void *_dev_p,
6082 IN struct net_device *net_dev,
6083 IN RTMP_ADAPTER *pAd);
6084
6085BOOLEAN RT28XXProbePostConfig(
6086 IN void *_dev_p,
6087 IN RTMP_ADAPTER *pAd,
6088 IN INT32 argc);
6089
6090VOID RT28XXDMADisable(
6091 IN RTMP_ADAPTER *pAd);
6092
6093VOID RT28XXDMAEnable(
6094 IN RTMP_ADAPTER *pAd);
6095
6096VOID RT28xx_UpdateBeaconToAsic(
6097 IN RTMP_ADAPTER * pAd,
6098 IN INT apidx,
6099 IN ULONG BeaconLen,
6100 IN ULONG UpdatePos);
6101
6102INT rt28xx_ioctl(
6103 IN struct net_device *net_dev,
6104 IN OUT struct ifreq *rq,
6105 IN INT cmd);
6106
6107INT rt28xx_sta_ioctl(
6108 IN struct net_device *net_dev,
6109 IN OUT struct ifreq *rq,
6110 IN INT cmd);
6111
6112BOOLEAN RT28XXSecurityKeyAdd(
6113 IN PRTMP_ADAPTER pAd,
6114 IN ULONG apidx,
6115 IN ULONG KeyIdx,
6116 IN MAC_TABLE_ENTRY *pEntry);
6117
6118////////////////////////////////////////
6119PNDIS_PACKET GetPacketFromRxRing(
6120 IN PRTMP_ADAPTER pAd,
6121 OUT PRT28XX_RXD_STRUC pSaveRxD,
6122 OUT BOOLEAN *pbReschedule,
6123 IN OUT UINT32 *pRxPending);
6124
6125
6126void kill_thread_task(PRTMP_ADAPTER pAd);
6127
6128void tbtt_tasklet(unsigned long data);
6129
6130
6131VOID AsicTurnOffRFClk(
6132 IN PRTMP_ADAPTER pAd,
6133 IN UCHAR Channel);
6134
6135VOID AsicTurnOnRFClk(
6136 IN PRTMP_ADAPTER pAd,
6137 IN UCHAR Channel);
6138
6139#ifdef RT30xx
6140NTSTATUS RT30xxWriteRFRegister(
6141 IN PRTMP_ADAPTER pAd,
6142 IN UCHAR RegID,
6143 IN UCHAR Value);
6144
6145NTSTATUS RT30xxReadRFRegister(
6146 IN PRTMP_ADAPTER pAd,
6147 IN UCHAR RegID,
6148 IN PUCHAR pValue);
6149
6150//2008/09/11:KH add to support efuse<--
6151UCHAR eFuseReadRegisters(
6152 IN PRTMP_ADAPTER pAd,
6153 IN USHORT Offset,
6154 IN USHORT Length,
6155 OUT USHORT* pData);
6156
6157VOID eFuseReadPhysical(
6158 IN PRTMP_ADAPTER pAd,
6159 IN PUSHORT lpInBuffer,
6160 IN ULONG nInBufferSize,
6161 OUT PUSHORT lpOutBuffer,
6162 IN ULONG nOutBufferSize
6163);
6164
6165NTSTATUS eFuseRead(
6166 IN PRTMP_ADAPTER pAd,
6167 IN USHORT Offset,
6168 OUT PUCHAR pData,
6169 IN USHORT Length);
6170
6171VOID eFusePhysicalWriteRegisters(
6172 IN PRTMP_ADAPTER pAd,
6173 IN USHORT Offset,
6174 IN USHORT Length,
6175 OUT USHORT* pData);
6176
6177NTSTATUS eFuseWriteRegisters(
6178 IN PRTMP_ADAPTER pAd,
6179 IN USHORT Offset,
6180 IN USHORT Length,
6181 IN USHORT* pData);
6182
6183VOID eFuseWritePhysical(
6184 IN PRTMP_ADAPTER pAd,
6185 PUSHORT lpInBuffer,
6186 ULONG nInBufferSize,
6187 PUCHAR lpOutBuffer,
6188 ULONG nOutBufferSize
6189);
6190
6191NTSTATUS eFuseWrite(
6192 IN PRTMP_ADAPTER pAd,
6193 IN USHORT Offset,
6194 IN PUCHAR pData,
6195 IN USHORT length);
6196
6197INT set_eFuseGetFreeBlockCount_Proc(
6198 IN PRTMP_ADAPTER pAd,
6199 IN PUCHAR arg);
6200
6201INT set_eFusedump_Proc(
6202 IN PRTMP_ADAPTER pAd,
6203 IN PUCHAR arg);
6204
6205INT set_eFuseLoadFromBin_Proc(
6206 IN PRTMP_ADAPTER pAd,
6207 IN PUCHAR arg);
6208
6209NTSTATUS eFuseWriteRegistersFromBin(
6210 IN PRTMP_ADAPTER pAd,
6211 IN USHORT Offset,
6212 IN USHORT Length,
6213 IN USHORT* pData);
6214
6215VOID eFusePhysicalReadRegisters(
6216 IN PRTMP_ADAPTER pAd,
6217 IN USHORT Offset,
6218 IN USHORT Length,
6219 OUT USHORT* pData);
6220
6221NDIS_STATUS NICLoadEEPROM(
6222 IN PRTMP_ADAPTER pAd);
6223
6224BOOLEAN bNeedLoadEEPROM(
6225 IN PRTMP_ADAPTER pAd);
6226//2008/09/11:KH add to support efuse-->
6227#endif // RT30xx //
6228
6229#ifdef RT30xx
6230// add by johnli, RF power sequence setup
6231VOID RT30xxLoadRFNormalModeSetup(
6232 IN PRTMP_ADAPTER pAd);
6233
6234VOID RT30xxLoadRFSleepModeSetup(
6235 IN PRTMP_ADAPTER pAd);
6236
6237VOID RT30xxReverseRFSleepModeSetup(
6238 IN PRTMP_ADAPTER pAd);
6239// end johnli
6240#endif // RT30xx //
6241
6242#ifdef RT2870
6243//
6244// Function Prototype in rtusb_bulk.c
6245//
6246VOID RTUSBInitTxDesc(
6247 IN PRTMP_ADAPTER pAd,
6248 IN PTX_CONTEXT pTxContext,
6249 IN UCHAR BulkOutPipeId,
6250 IN usb_complete_t Func);
6251
6252VOID RTUSBInitHTTxDesc(
6253 IN PRTMP_ADAPTER pAd,
6254 IN PHT_TX_CONTEXT pTxContext,
6255 IN UCHAR BulkOutPipeId,
6256 IN ULONG BulkOutSize,
6257 IN usb_complete_t Func);
6258
6259VOID RTUSBInitRxDesc(
6260 IN PRTMP_ADAPTER pAd,
6261 IN PRX_CONTEXT pRxContext);
6262
6263VOID RTUSBCleanUpDataBulkOutQueue(
6264 IN PRTMP_ADAPTER pAd);
6265
6266VOID RTUSBCancelPendingBulkOutIRP(
6267 IN PRTMP_ADAPTER pAd);
6268
6269VOID RTUSBBulkOutDataPacket(
6270 IN PRTMP_ADAPTER pAd,
6271 IN UCHAR BulkOutPipeId,
6272 IN UCHAR Index);
6273
6274VOID RTUSBBulkOutNullFrame(
6275 IN PRTMP_ADAPTER pAd);
6276
6277VOID RTUSBBulkOutRTSFrame(
6278 IN PRTMP_ADAPTER pAd);
6279
6280VOID RTUSBCancelPendingBulkInIRP(
6281 IN PRTMP_ADAPTER pAd);
6282
6283VOID RTUSBCancelPendingIRPs(
6284 IN PRTMP_ADAPTER pAd);
6285
6286VOID RTUSBBulkOutMLMEPacket(
6287 IN PRTMP_ADAPTER pAd,
6288 IN UCHAR Index);
6289
6290VOID RTUSBBulkOutPsPoll(
6291 IN PRTMP_ADAPTER pAd);
6292
6293VOID RTUSBCleanUpMLMEBulkOutQueue(
6294 IN PRTMP_ADAPTER pAd);
6295
6296VOID RTUSBKickBulkOut(
6297 IN PRTMP_ADAPTER pAd);
6298
6299VOID RTUSBBulkReceive(
6300 IN PRTMP_ADAPTER pAd);
6301
6302VOID DoBulkIn(
6303 IN RTMP_ADAPTER *pAd);
6304
6305VOID RTUSBInitRxDesc(
6306 IN PRTMP_ADAPTER pAd,
6307 IN PRX_CONTEXT pRxContext);
6308
6309VOID RTUSBBulkRxHandle(
6310 IN unsigned long data);
6311
6312//
6313// Function Prototype in rtusb_io.c
6314//
6315NTSTATUS RTUSBMultiRead(
6316 IN PRTMP_ADAPTER pAd,
6317 IN USHORT Offset,
6318 OUT PUCHAR pData,
6319 IN USHORT length);
6320
6321NTSTATUS RTUSBMultiWrite(
6322 IN PRTMP_ADAPTER pAd,
6323 IN USHORT Offset,
6324 IN PUCHAR pData,
6325 IN USHORT length);
6326
6327NTSTATUS RTUSBMultiWrite_OneByte(
6328 IN PRTMP_ADAPTER pAd,
6329 IN USHORT Offset,
6330 IN PUCHAR pData);
6331
6332NTSTATUS RTUSBReadBBPRegister(
6333 IN PRTMP_ADAPTER pAd,
6334 IN UCHAR Id,
6335 IN PUCHAR pValue);
6336
6337NTSTATUS RTUSBWriteBBPRegister(
6338 IN PRTMP_ADAPTER pAd,
6339 IN UCHAR Id,
6340 IN UCHAR Value);
6341
6342NTSTATUS RTUSBWriteRFRegister(
6343 IN PRTMP_ADAPTER pAd,
6344 IN UINT32 Value);
6345
6346#ifndef RT30xx
6347NTSTATUS RT30xxWriteRFRegister(
6348 IN PRTMP_ADAPTER pAd,
6349 IN UCHAR RegID,
6350 IN UCHAR Value);
6351
6352NTSTATUS RT30xxReadRFRegister(
6353 IN PRTMP_ADAPTER pAd,
6354 IN UCHAR RegID,
6355 IN PUCHAR pValue);
6356#endif
6357
6358NTSTATUS RTUSB_VendorRequest(
6359 IN PRTMP_ADAPTER pAd,
6360 IN UINT32 TransferFlags,
6361 IN UCHAR ReservedBits,
6362 IN UCHAR Request,
6363 IN USHORT Value,
6364 IN USHORT Index,
6365 IN PVOID TransferBuffer,
6366 IN UINT32 TransferBufferLength);
6367
6368NTSTATUS RTUSBReadEEPROM(
6369 IN PRTMP_ADAPTER pAd,
6370 IN USHORT Offset,
6371 OUT PUCHAR pData,
6372 IN USHORT length);
6373
6374NTSTATUS RTUSBWriteEEPROM(
6375 IN PRTMP_ADAPTER pAd,
6376 IN USHORT Offset,
6377 IN PUCHAR pData,
6378 IN USHORT length);
6379
6380VOID RTUSBPutToSleep(
6381 IN PRTMP_ADAPTER pAd);
6382
6383NTSTATUS RTUSBWakeUp(
6384 IN PRTMP_ADAPTER pAd);
6385
6386VOID RTUSBInitializeCmdQ(
6387 IN PCmdQ cmdq);
6388
6389NDIS_STATUS RTUSBEnqueueCmdFromNdis(
6390 IN PRTMP_ADAPTER pAd,
6391 IN NDIS_OID Oid,
6392 IN BOOLEAN SetInformation,
6393 IN PVOID pInformationBuffer,
6394 IN UINT32 InformationBufferLength);
6395
6396NDIS_STATUS RTUSBEnqueueInternalCmd(
6397 IN PRTMP_ADAPTER pAd,
6398 IN NDIS_OID Oid,
6399 IN PVOID pInformationBuffer,
6400 IN UINT32 InformationBufferLength);
6401
6402VOID RTUSBDequeueCmd(
6403 IN PCmdQ cmdq,
6404 OUT PCmdQElmt *pcmdqelmt);
6405
6406INT RTUSBCmdThread(
6407 IN OUT PVOID Context);
6408
6409INT TimerQThread(
6410 IN OUT PVOID Context);
6411
6412RT2870_TIMER_ENTRY *RT2870_TimerQ_Insert(
6413 IN RTMP_ADAPTER *pAd,
6414 IN RALINK_TIMER_STRUCT *pTimer);
6415
6416BOOLEAN RT2870_TimerQ_Remove(
6417 IN RTMP_ADAPTER *pAd,
6418 IN RALINK_TIMER_STRUCT *pTimer);
6419
6420void RT2870_TimerQ_Exit(
6421 IN RTMP_ADAPTER *pAd);
6422
6423void RT2870_TimerQ_Init(
6424 IN RTMP_ADAPTER *pAd);
6425
6426VOID RT2870_BssBeaconExit(
6427 IN RTMP_ADAPTER *pAd);
6428
6429VOID RT2870_BssBeaconStop(
6430 IN RTMP_ADAPTER *pAd);
6431
6432VOID RT2870_BssBeaconStart(
6433 IN RTMP_ADAPTER * pAd);
6434
6435VOID RT2870_BssBeaconInit(
6436 IN RTMP_ADAPTER *pAd);
6437
6438VOID RT2870_WatchDog(
6439 IN RTMP_ADAPTER *pAd);
6440
6441NTSTATUS RTUSBWriteMACRegister(
6442 IN PRTMP_ADAPTER pAd,
6443 IN USHORT Offset,
6444 IN UINT32 Value);
6445
6446NTSTATUS RTUSBReadMACRegister(
6447 IN PRTMP_ADAPTER pAd,
6448 IN USHORT Offset,
6449 OUT PUINT32 pValue);
6450
6451NTSTATUS RTUSBSingleWrite(
6452 IN RTMP_ADAPTER *pAd,
6453 IN USHORT Offset,
6454 IN USHORT Value);
6455
6456NTSTATUS RTUSBFirmwareRun(
6457 IN PRTMP_ADAPTER pAd);
6458
6459NTSTATUS RTUSBFirmwareWrite(
6460 IN PRTMP_ADAPTER pAd,
6461 IN PUCHAR pFwImage,
6462 IN ULONG FwLen);
6463
6464NTSTATUS RTUSBFirmwareOpmode(
6465 IN PRTMP_ADAPTER pAd,
6466 OUT PUINT32 pValue);
6467
6468NTSTATUS RTUSBVenderReset(
6469 IN PRTMP_ADAPTER pAd);
6470
6471NDIS_STATUS RTUSBSetHardWareRegister(
6472 IN PRTMP_ADAPTER pAdapter,
6473 IN PVOID pBuf);
6474
6475NDIS_STATUS RTUSBQueryHardWareRegister(
6476 IN PRTMP_ADAPTER pAdapter,
6477 IN PVOID pBuf);
6478
6479VOID CMDHandler(
6480 IN PRTMP_ADAPTER pAd);
6481
6482
6483NDIS_STATUS CreateThreads(
6484 IN struct net_device *net_dev );
6485
6486
6487VOID MacTableInitialize(
6488 IN PRTMP_ADAPTER pAd);
6489
6490VOID MlmeSetPsm(
6491 IN PRTMP_ADAPTER pAd,
6492 IN USHORT psm);
6493
6494NDIS_STATUS RTMPWPAAddKeyProc(
6495 IN PRTMP_ADAPTER pAd,
6496 IN PVOID pBuf);
6497
6498VOID AsicRxAntEvalAction(
6499 IN PRTMP_ADAPTER pAd);
6500
6501void append_pkt(
6502 IN PRTMP_ADAPTER pAd,
6503 IN PUCHAR pHeader802_3,
6504 IN UINT HdrLen,
6505 IN PUCHAR pData,
6506 IN ULONG DataSize,
6507 OUT PNDIS_PACKET *ppPacket);
6508
6509UINT deaggregate_AMSDU_announce(
6510 IN PRTMP_ADAPTER pAd,
6511 PNDIS_PACKET pPacket,
6512 IN PUCHAR pData,
6513 IN ULONG DataSize);
6514
6515NDIS_STATUS RTMPCheckRxError(
6516 IN PRTMP_ADAPTER pAd,
6517 IN PHEADER_802_11 pHeader,
6518 IN PRXWI_STRUC pRxWI,
6519 IN PRT28XX_RXD_STRUC pRxINFO);
6520
6521
6522VOID RTUSBMlmeHardTransmit(
6523 IN PRTMP_ADAPTER pAd,
6524 IN PMGMT_STRUC pMgmt);
6525
6526INT MlmeThread(
6527 IN PVOID Context);
6528
6529//
6530// Function Prototype in rtusb_data.c
6531//
6532NDIS_STATUS RTUSBFreeDescriptorRequest(
6533 IN PRTMP_ADAPTER pAd,
6534 IN UCHAR BulkOutPipeId,
6535 IN UINT32 NumberRequired);
6536
6537
6538BOOLEAN RTUSBNeedQueueBackForAgg(
6539 IN RTMP_ADAPTER *pAd,
6540 IN UCHAR BulkOutPipeId);
6541
6542
6543VOID RTMPWriteTxInfo(
6544 IN PRTMP_ADAPTER pAd,
6545 IN PTXINFO_STRUC pTxInfo,
6546 IN USHORT USBDMApktLen,
6547 IN BOOLEAN bWiv,
6548 IN UCHAR QueueSel,
6549 IN UCHAR NextValid,
6550 IN UCHAR TxBurst);
6551
6552//
6553// Function Prototype in cmm_data_2870.c
6554//
6555USHORT RtmpUSB_WriteSubTxResource(
6556 IN PRTMP_ADAPTER pAd,
6557 IN TX_BLK *pTxBlk,
6558 IN BOOLEAN bIsLast,
6559 OUT USHORT *FreeNumber);
6560
6561USHORT RtmpUSB_WriteSingleTxResource(
6562 IN PRTMP_ADAPTER pAd,
6563 IN TX_BLK *pTxBlk,
6564 IN BOOLEAN bIsLast,
6565 OUT USHORT *FreeNumber);
6566
6567USHORT RtmpUSB_WriteFragTxResource(
6568 IN PRTMP_ADAPTER pAd,
6569 IN TX_BLK *pTxBlk,
6570 IN UCHAR fragNum,
6571 OUT USHORT *FreeNumber);
6572
6573USHORT RtmpUSB_WriteMultiTxResource(
6574 IN PRTMP_ADAPTER pAd,
6575 IN TX_BLK *pTxBlk,
6576 IN UCHAR frameNum,
6577 OUT USHORT *FreeNumber);
6578
6579VOID RtmpUSB_FinalWriteTxResource(
6580 IN PRTMP_ADAPTER pAd,
6581 IN TX_BLK *pTxBlk,
6582 IN USHORT totalMPDUSize,
6583 IN USHORT TxIdx);
6584
6585VOID RtmpUSBDataLastTxIdx(
6586 IN PRTMP_ADAPTER pAd,
6587 IN UCHAR QueIdx,
6588 IN USHORT TxIdx);
6589
6590VOID RtmpUSBDataKickOut(
6591 IN PRTMP_ADAPTER pAd,
6592 IN TX_BLK *pTxBlk,
6593 IN UCHAR QueIdx);
6594
6595
6596int RtmpUSBMgmtKickOut(
6597 IN RTMP_ADAPTER *pAd,
6598 IN UCHAR QueIdx,
6599 IN PNDIS_PACKET pPacket,
6600 IN PUCHAR pSrcBufVA,
6601 IN UINT SrcBufLen);
6602
6603VOID RtmpUSBNullFrameKickOut(
6604 IN RTMP_ADAPTER *pAd,
6605 IN UCHAR QueIdx,
6606 IN UCHAR *pNullFrame,
6607 IN UINT32 frameLen);
6608
6609VOID RT28xxUsbStaAsicForceWakeup(
6610 IN PRTMP_ADAPTER pAd,
6611 IN BOOLEAN bFromTx);
6612
6613VOID RT28xxUsbStaAsicSleepThenAutoWakeup(
6614 IN PRTMP_ADAPTER pAd,
6615 IN USHORT TbttNumToNextWakeUp);
6616
6617VOID RT28xxUsbMlmeRadioOn(
6618 IN PRTMP_ADAPTER pAd);
6619
6620VOID RT28xxUsbMlmeRadioOFF(
6621 IN PRTMP_ADAPTER pAd);
6622#endif // RT2870 //
6623
6624////////////////////////////////////////
6625
6626VOID QBSS_LoadInit(
6627 IN RTMP_ADAPTER *pAd);
6628
6629UINT32 QBSS_LoadElementAppend(
6630 IN RTMP_ADAPTER *pAd,
6631 OUT UINT8 *buf_p);
6632
6633VOID QBSS_LoadUpdate(
6634 IN RTMP_ADAPTER *pAd);
6635
6636///////////////////////////////////////
6637INT RTMPShowCfgValue(
6638 IN PRTMP_ADAPTER pAd,
6639 IN PUCHAR pName,
6640 IN PUCHAR pBuf);
6641
6642PCHAR RTMPGetRalinkAuthModeStr(
6643 IN NDIS_802_11_AUTHENTICATION_MODE authMode);
6644
6645PCHAR RTMPGetRalinkEncryModeStr(
6646 IN USHORT encryMode);
6647//////////////////////////////////////
6648
6649VOID AsicStaBbpTuning(
6650 IN PRTMP_ADAPTER pAd);
6651
6652BOOLEAN StaAddMacTableEntry(
6653 IN PRTMP_ADAPTER pAd,
6654 IN PMAC_TABLE_ENTRY pEntry,
6655 IN UCHAR MaxSupportedRateIn500Kbps,
6656 IN HT_CAPABILITY_IE *pHtCapability,
6657 IN UCHAR HtCapabilityLen,
6658 IN USHORT CapabilityInfo);
6659
6660void RTMP_IndicateMediaState(
6661 IN PRTMP_ADAPTER pAd);
6662
6663VOID ReSyncBeaconTime(
6664 IN PRTMP_ADAPTER pAd);
6665
6666VOID RTMPSetAGCInitValue(
6667 IN PRTMP_ADAPTER pAd,
6668 IN UCHAR BandWidth);
6669
6670int rt28xx_close(IN PNET_DEV dev);
6671int rt28xx_open(IN PNET_DEV dev);
6672
6673__inline INT VIRTUAL_IF_UP(PRTMP_ADAPTER pAd)
6674{
6675extern VOID MeshMakeBeacon(IN PRTMP_ADAPTER pAd, IN UCHAR idx);
6676extern VOID MeshUpdateBeaconFrame(IN PRTMP_ADAPTER pAd, IN UCHAR idx);
6677
6678 if (VIRTUAL_IF_NUM(pAd) == 0)
6679 {
6680 if (rt28xx_open(pAd->net_dev) != 0)
6681 return -1;
6682 }
6683 else
6684 {
6685 }
6686 VIRTUAL_IF_INC(pAd);
6687 return 0;
6688}
6689
6690__inline VOID VIRTUAL_IF_DOWN(PRTMP_ADAPTER pAd)
6691{
6692 VIRTUAL_IF_DEC(pAd);
6693 if (VIRTUAL_IF_NUM(pAd) == 0)
6694 rt28xx_close(pAd->net_dev);
6695 return;
6696}
6697
6698
6699#endif // __RTMP_H__
6700
diff --git a/drivers/staging/rt2870/rtmp_ckipmic.h b/drivers/staging/rt2870/rtmp_ckipmic.h
index a3d949a39d39..0e7f1dfd4547 100644
--- a/drivers/staging/rt2870/rtmp_ckipmic.h
+++ b/drivers/staging/rt2870/rtmp_ckipmic.h
@@ -1,113 +1 @@
1/* #include "../rt2860/rtmp_ckipmic.h"
2 *************************************************************************
3 * Ralink Tech Inc.
4 * 5F., No.36, Taiyuan St., Jhubei City,
5 * Hsinchu County 302,
6 * Taiwan, R.O.C.
7 *
8 * (c) Copyright 2002-2007, Ralink Technology, Inc.
9 *
10 * This program is free software; you can redistribute it and/or modify *
11 * it under the terms of the GNU General Public License as published by *
12 * the Free Software Foundation; either version 2 of the License, or *
13 * (at your option) any later version. *
14 * *
15 * This program is distributed in the hope that it will be useful, *
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
18 * GNU General Public License for more details. *
19 * *
20 * You should have received a copy of the GNU General Public License *
21 * along with this program; if not, write to the *
22 * Free Software Foundation, Inc., *
23 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
24 * *
25 *************************************************************************
26
27 Module Name:
28 rtmp_ckipmic.h
29
30 Abstract:
31
32 Revision History:
33 Who When What
34 -------- ---------- ----------------------------------------------
35 Name Date Modification logs
36*/
37#ifndef __RTMP_CKIPMIC_H__
38#define __RTMP_CKIPMIC_H__
39
40typedef struct _MIC_CONTEXT {
41 /* --- MMH context */
42 UCHAR CK[16]; /* the key */
43 UCHAR coefficient[16]; /* current aes counter mode coefficients */
44 ULONGLONG accum; /* accumulated mic, reduced to u32 in final() */
45 UINT position; /* current position (byte offset) in message */
46 UCHAR part[4]; /* for conversion of message to u32 for mmh */
47} MIC_CONTEXT, *PMIC_CONTEXT;
48
49VOID CKIP_key_permute(
50 OUT UCHAR *PK, /* output permuted key */
51 IN UCHAR *CK, /* input CKIP key */
52 IN UCHAR toDsFromDs, /* input toDs/FromDs bits */
53 IN UCHAR *piv); /* input pointer to IV */
54
55VOID RTMPCkipMicInit(
56 IN PMIC_CONTEXT pContext,
57 IN PUCHAR CK);
58
59VOID RTMPMicUpdate(
60 IN PMIC_CONTEXT pContext,
61 IN PUCHAR pOctets,
62 IN INT len);
63
64ULONG RTMPMicGetCoefficient(
65 IN PMIC_CONTEXT pContext);
66
67VOID xor_128(
68 IN PUCHAR a,
69 IN PUCHAR b,
70 OUT PUCHAR out);
71
72UCHAR RTMPCkipSbox(
73 IN UCHAR a);
74
75VOID xor_32(
76 IN PUCHAR a,
77 IN PUCHAR b,
78 OUT PUCHAR out);
79
80VOID next_key(
81 IN PUCHAR key,
82 IN INT round);
83
84VOID byte_sub(
85 IN PUCHAR in,
86 OUT PUCHAR out);
87
88VOID shift_row(
89 IN PUCHAR in,
90 OUT PUCHAR out);
91
92VOID mix_column(
93 IN PUCHAR in,
94 OUT PUCHAR out);
95
96VOID RTMPAesEncrypt(
97 IN PUCHAR key,
98 IN PUCHAR data,
99 IN PUCHAR ciphertext);
100
101VOID RTMPMicFinal(
102 IN PMIC_CONTEXT pContext,
103 OUT UCHAR digest[4]);
104
105VOID RTMPCkipInsertCMIC(
106 IN PRTMP_ADAPTER pAd,
107 OUT PUCHAR pMIC,
108 IN PUCHAR p80211hdr,
109 IN PNDIS_PACKET pPacket,
110 IN PCIPHER_KEY pKey,
111 IN PUCHAR mic_snap);
112
113#endif //__RTMP_CKIPMIC_H__
diff --git a/drivers/staging/rt2870/rtmp_def.h b/drivers/staging/rt2870/rtmp_def.h
index bb55de13eb2f..839d791b4f62 100644
--- a/drivers/staging/rt2870/rtmp_def.h
+++ b/drivers/staging/rt2870/rtmp_def.h
@@ -1,1443 +1 @@
1/* #include "../rt2860/rtmp_def.h"
2 *************************************************************************
3 * Ralink Tech Inc.
4 * 5F., No.36, Taiyuan St., Jhubei City,
5 * Hsinchu County 302,
6 * Taiwan, R.O.C.
7 *
8 * (c) Copyright 2002-2007, Ralink Technology, Inc.
9 *
10 * This program is free software; you can redistribute it and/or modify *
11 * it under the terms of the GNU General Public License as published by *
12 * the Free Software Foundation; either version 2 of the License, or *
13 * (at your option) any later version. *
14 * *
15 * This program is distributed in the hope that it will be useful, *
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
18 * GNU General Public License for more details. *
19 * *
20 * You should have received a copy of the GNU General Public License *
21 * along with this program; if not, write to the *
22 * Free Software Foundation, Inc., *
23 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
24 * *
25 *************************************************************************
26
27 Module Name:
28 rtmp_def.h
29
30 Abstract:
31 Miniport related definition header
32
33 Revision History:
34 Who When What
35 -------- ---------- ----------------------------------------------
36 Paul Lin 08-01-2002 created
37 John Chang 08-05-2003 add definition for 11g & other drafts
38*/
39#ifndef __RTMP_DEF_H__
40#define __RTMP_DEF_H__
41
42#include "oid.h"
43
44//
45// Debug information verbosity: lower values indicate higher urgency
46//
47#define RT_DEBUG_OFF 0
48#define RT_DEBUG_ERROR 1
49#define RT_DEBUG_WARN 2
50#define RT_DEBUG_TRACE 3
51#define RT_DEBUG_INFO 4
52#define RT_DEBUG_LOUD 5
53
54#define NIC_TAG ((ULONG)'0682')
55#define NIC_DBG_STRING ("**RT28xx**")
56
57#define RALINK_2883_VERSION ((UINT32)0x28830300)
58#define RALINK_2880E_VERSION ((UINT32)0x28720200)
59#define RALINK_3070_VERSION ((UINT32)0x30700200)
60
61//
62// NDIS version in use by the NIC driver.
63// The high byte is the major version. The low byte is the minor version.
64//
65#ifdef NDIS51_MINIPORT
66#define NIC_DRIVER_VERSION 0x0501
67#else
68#define NIC_DRIVER_VERSION 0x0500
69#endif
70
71//
72// NDIS media type, current is ethernet, change if native wireless supported
73//
74#define NIC_MEDIA_TYPE NdisMedium802_3
75#define NIC_PCI_HDR_LENGTH 0xe2
76#define NIC_MAX_PACKET_SIZE 2304
77#define NIC_HEADER_SIZE 14
78#define MAX_MAP_REGISTERS_NEEDED 32
79#define MIN_MAP_REGISTERS_NEEDED 2 //Todo: should consider fragment issue.
80
81//
82// interface type, we use PCI
83//
84#define NIC_INTERFACE_TYPE NdisInterfacePci
85#define NIC_INTERRUPT_MODE NdisInterruptLevelSensitive
86
87//
88// buffer size passed in NdisMQueryAdapterResources
89// We should only need three adapter resources (IO, interrupt and memory),
90// Some devices get extra resources, so have room for 10 resources
91// UF_SIZE (sizeof(NDIS_RESOURCE_LIST) + (10*sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR)))
92
93
94#define NIC_RESOURCE_B//
95// IO space length
96//
97#define NIC_MAP_IOSPACE_LENGTH sizeof(CSR_STRUC)
98
99#define MAX_RX_PKT_LEN 1520
100
101//
102// Entry number for each DMA descriptor ring
103//
104
105
106#ifdef RT2870
107#define TX_RING_SIZE 8 // 1
108#define PRIO_RING_SIZE 8
109#define MGMT_RING_SIZE 32 // PRIO_RING_SIZE
110#define RX_RING_SIZE 8
111#define MAX_TX_PROCESS 4
112#define LOCAL_TXBUF_SIZE 2048
113#endif // RT2870 //
114
115#define MAX_RX_PROCESS 128 //64 //32
116#define NUM_OF_LOCAL_TXBUF 2
117#define TXD_SIZE 16
118#define TXWI_SIZE 16
119#define RXD_SIZE 16
120#define RXWI_SIZE 16
121// TXINFO_SIZE + TXWI_SIZE + 802.11 Header Size + AMSDU sub frame header
122#define TX_DMA_1ST_BUFFER_SIZE 96 // only the 1st physical buffer is pre-allocated
123#define MGMT_DMA_BUFFER_SIZE 1536 //2048
124#define RX_BUFFER_AGGRESIZE 3840 //3904 //3968 //4096 //2048 //4096
125#define RX_BUFFER_NORMSIZE 3840 //3904 //3968 //4096 //2048 //4096
126#define TX_BUFFER_NORMSIZE RX_BUFFER_NORMSIZE
127#define MAX_FRAME_SIZE 2346 // Maximum 802.11 frame size
128#define MAX_AGGREGATION_SIZE 3840 //3904 //3968 //4096
129#define MAX_NUM_OF_TUPLE_CACHE 2
130#define MAX_MCAST_LIST_SIZE 32
131#define MAX_LEN_OF_VENDOR_DESC 64
132//#define MAX_SIZE_OF_MCAST_PSQ (NUM_OF_LOCAL_TXBUF >> 2) // AP won't spend more than 1/4 of total buffers on M/BCAST PSQ
133#define MAX_SIZE_OF_MCAST_PSQ 32
134
135#define MAX_RX_PROCESS_CNT (RX_RING_SIZE)
136
137
138#define MAX_PACKETS_IN_QUEUE (512) //(512) // to pass WMM A5-WPAPSK
139#define MAX_PACKETS_IN_MCAST_PS_QUEUE 32
140#define MAX_PACKETS_IN_PS_QUEUE 128 //32
141#define WMM_NUM_OF_AC 4 /* AC0, AC1, AC2, and AC3 */
142
143#ifdef RT30xx
144//2008/09/11:KH add to support efuse<--
145#define MAX_EEPROM_BIN_FILE_SIZE 1024
146//2008/09/11:KH add to support efuse-->
147#endif
148
149// RxFilter
150#define STANORMAL 0x17f97
151#define APNORMAL 0x15f97
152//
153// RTMP_ADAPTER flags
154//
155#define fRTMP_ADAPTER_MAP_REGISTER 0x00000001
156#define fRTMP_ADAPTER_INTERRUPT_IN_USE 0x00000002
157#define fRTMP_ADAPTER_HARDWARE_ERROR 0x00000004
158#define fRTMP_ADAPTER_SCATTER_GATHER 0x00000008
159#define fRTMP_ADAPTER_SEND_PACKET_ERROR 0x00000010
160#define fRTMP_ADAPTER_MLME_RESET_IN_PROGRESS 0x00000020
161#define fRTMP_ADAPTER_HALT_IN_PROGRESS 0x00000040
162#define fRTMP_ADAPTER_RESET_IN_PROGRESS 0x00000080
163#define fRTMP_ADAPTER_NIC_NOT_EXIST 0x00000100
164#define fRTMP_ADAPTER_TX_RING_ALLOCATED 0x00000200
165#define fRTMP_ADAPTER_REMOVE_IN_PROGRESS 0x00000400
166#define fRTMP_ADAPTER_MIMORATE_INUSED 0x00000800
167#define fRTMP_ADAPTER_RX_RING_ALLOCATED 0x00001000
168#define fRTMP_ADAPTER_INTERRUPT_ACTIVE 0x00002000
169#define fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS 0x00004000
170#define fRTMP_ADAPTER_REASSOC_IN_PROGRESS 0x00008000
171#define fRTMP_ADAPTER_MEDIA_STATE_PENDING 0x00010000
172#define fRTMP_ADAPTER_RADIO_OFF 0x00020000
173#define fRTMP_ADAPTER_BULKOUT_RESET 0x00040000
174#define fRTMP_ADAPTER_BULKIN_RESET 0x00080000
175#define fRTMP_ADAPTER_RDG_ACTIVE 0x00100000
176#define fRTMP_ADAPTER_DYNAMIC_BE_TXOP_ACTIVE 0x00200000
177#define fRTMP_ADAPTER_SCAN_2040 0x04000000
178#define fRTMP_ADAPTER_RADIO_MEASUREMENT 0x08000000
179
180#define fRTMP_ADAPTER_START_UP 0x10000000 //Devive already initialized and enabled Tx/Rx.
181#define fRTMP_ADAPTER_MEDIA_STATE_CHANGE 0x20000000
182#define fRTMP_ADAPTER_IDLE_RADIO_OFF 0x40000000
183
184//
185// STA operation status flags
186//
187#define fOP_STATUS_INFRA_ON 0x00000001
188#define fOP_STATUS_ADHOC_ON 0x00000002
189#define fOP_STATUS_BG_PROTECTION_INUSED 0x00000004
190#define fOP_STATUS_SHORT_SLOT_INUSED 0x00000008
191#define fOP_STATUS_SHORT_PREAMBLE_INUSED 0x00000010
192#define fOP_STATUS_RECEIVE_DTIM 0x00000020
193#define fOP_STATUS_MEDIA_STATE_CONNECTED 0x00000080
194#define fOP_STATUS_WMM_INUSED 0x00000100
195#define fOP_STATUS_AGGREGATION_INUSED 0x00000200
196#define fOP_STATUS_DOZE 0x00000400 // debug purpose
197#define fOP_STATUS_PIGGYBACK_INUSED 0x00000800 // piggy-back, and aggregation
198#define fOP_STATUS_APSD_INUSED 0x00001000
199#define fOP_STATUS_TX_AMSDU_INUSED 0x00002000
200#define fOP_STATUS_MAX_RETRY_ENABLED 0x00004000
201#define fOP_STATUS_WAKEUP_NOW 0x00008000
202#define fOP_STATUS_ADVANCE_POWER_SAVE_PCIE_DEVICE 0x00020000
203
204#define CCKSETPROTECT 0x1
205#define OFDMSETPROTECT 0x2
206#define MM20SETPROTECT 0x4
207#define MM40SETPROTECT 0x8
208#define GF20SETPROTECT 0x10
209#define GR40SETPROTECT 0x20
210#define ALLN_SETPROTECT (GR40SETPROTECT | GF20SETPROTECT | MM40SETPROTECT | MM20SETPROTECT)
211
212//
213// AP's client table operation status flags
214//
215#define fCLIENT_STATUS_WMM_CAPABLE 0x00000001 // CLIENT can parse QOS DATA frame
216#define fCLIENT_STATUS_AGGREGATION_CAPABLE 0x00000002 // CLIENT can receive Ralink's proprietary TX aggregation frame
217#define fCLIENT_STATUS_PIGGYBACK_CAPABLE 0x00000004 // CLIENT support piggy-back
218#define fCLIENT_STATUS_AMSDU_INUSED 0x00000008
219#define fCLIENT_STATUS_SGI20_CAPABLE 0x00000010
220#define fCLIENT_STATUS_SGI40_CAPABLE 0x00000020
221#define fCLIENT_STATUS_TxSTBC_CAPABLE 0x00000040
222#define fCLIENT_STATUS_RxSTBC_CAPABLE 0x00000080
223#define fCLIENT_STATUS_HTC_CAPABLE 0x00000100
224#define fCLIENT_STATUS_RDG_CAPABLE 0x00000200
225#define fCLIENT_STATUS_MCSFEEDBACK_CAPABLE 0x00000400
226#define fCLIENT_STATUS_APSD_CAPABLE 0x00000800 /* UAPSD STATION */
227
228#define fCLIENT_STATUS_RALINK_CHIPSET 0x00100000
229//
230// STA configuration flags
231//
232
233// 802.11n Operating Mode Definition. 0-3 also used in ASICUPdateProtect switch case
234#define HT_NO_PROTECT 0
235#define HT_LEGACY_PROTECT 1
236#define HT_40_PROTECT 2
237#define HT_2040_PROTECT 3
238#define HT_RTSCTS_6M 7
239//following is our own definition in order to turn on our ASIC protection register in INFRASTRUCTURE.
240#define HT_ATHEROS 8 // rt2860c has problem with atheros chip. we need to turn on RTS/CTS .
241#define HT_FORCERTSCTS 9 // Force turn on RTS/CTS first. then go to evaluate if this force RTS is necessary.
242
243//
244// RX Packet Filter control flags. Apply on pAd->PacketFilter
245//
246#define fRX_FILTER_ACCEPT_DIRECT NDIS_PACKET_TYPE_DIRECTED
247#define fRX_FILTER_ACCEPT_MULTICAST NDIS_PACKET_TYPE_MULTICAST
248#define fRX_FILTER_ACCEPT_BROADCAST NDIS_PACKET_TYPE_BROADCAST
249#define fRX_FILTER_ACCEPT_ALL_MULTICAST NDIS_PACKET_TYPE_ALL_MULTICAST
250
251//
252// Error code section
253//
254// NDIS_ERROR_CODE_ADAPTER_NOT_FOUND
255#define ERRLOG_READ_PCI_SLOT_FAILED 0x00000101L
256#define ERRLOG_WRITE_PCI_SLOT_FAILED 0x00000102L
257#define ERRLOG_VENDOR_DEVICE_NOMATCH 0x00000103L
258
259// NDIS_ERROR_CODE_ADAPTER_DISABLED
260#define ERRLOG_BUS_MASTER_DISABLED 0x00000201L
261
262// NDIS_ERROR_CODE_UNSUPPORTED_CONFIGURATION
263#define ERRLOG_INVALID_SPEED_DUPLEX 0x00000301L
264#define ERRLOG_SET_SECONDARY_FAILED 0x00000302L
265
266// NDIS_ERROR_CODE_OUT_OF_RESOURCES
267#define ERRLOG_OUT_OF_MEMORY 0x00000401L
268#define ERRLOG_OUT_OF_SHARED_MEMORY 0x00000402L
269#define ERRLOG_OUT_OF_MAP_REGISTERS 0x00000403L
270#define ERRLOG_OUT_OF_BUFFER_POOL 0x00000404L
271#define ERRLOG_OUT_OF_NDIS_BUFFER 0x00000405L
272#define ERRLOG_OUT_OF_PACKET_POOL 0x00000406L
273#define ERRLOG_OUT_OF_NDIS_PACKET 0x00000407L
274#define ERRLOG_OUT_OF_LOOKASIDE_MEMORY 0x00000408L
275
276// NDIS_ERROR_CODE_HARDWARE_FAILURE
277#define ERRLOG_SELFTEST_FAILED 0x00000501L
278#define ERRLOG_INITIALIZE_ADAPTER 0x00000502L
279#define ERRLOG_REMOVE_MINIPORT 0x00000503L
280
281// NDIS_ERROR_CODE_RESOURCE_CONFLICT
282#define ERRLOG_MAP_IO_SPACE 0x00000601L
283#define ERRLOG_QUERY_ADAPTER_RESOURCES 0x00000602L
284#define ERRLOG_NO_IO_RESOURCE 0x00000603L
285#define ERRLOG_NO_INTERRUPT_RESOURCE 0x00000604L
286#define ERRLOG_NO_MEMORY_RESOURCE 0x00000605L
287
288
289// WDS definition
290#define MAX_WDS_ENTRY 4
291#define WDS_PAIRWISE_KEY_OFFSET 60 // WDS links uses pairwise key#60 ~ 63 in ASIC pairwise key table
292
293#define WDS_DISABLE_MODE 0
294#define WDS_RESTRICT_MODE 1
295#define WDS_BRIDGE_MODE 2
296#define WDS_REPEATER_MODE 3
297#define WDS_LAZY_MODE 4
298
299
300#define MAX_MESH_NUM 0
301
302#define MAX_APCLI_NUM 0
303
304#define MAX_MBSSID_NUM 1
305#ifdef RT30xx
306#ifdef MBSS_SUPPORT
307#undef MAX_MBSSID_NUM
308#define MAX_MBSSID_NUM (8 - MAX_MESH_NUM - MAX_APCLI_NUM)
309#endif // MBSS_SUPPORT //
310#endif
311
312/* sanity check for apidx */
313#define MBSS_MR_APIDX_SANITY_CHECK(apidx) \
314 { if (apidx > MAX_MBSSID_NUM) { \
315 printk("%s> Error! apidx = %d > MAX_MBSSID_NUM!\n", __func__, apidx); \
316 apidx = MAIN_MBSSID; } }
317
318#define VALID_WCID(_wcid) ((_wcid) > 0 && (_wcid) < MAX_LEN_OF_MAC_TABLE )
319
320#define MAIN_MBSSID 0
321#define FIRST_MBSSID 1
322
323
324#define MAX_BEACON_SIZE 512
325// If the MAX_MBSSID_NUM is larger than 6,
326// it shall reserve some WCID space(wcid 222~253) for beacon frames.
327// - these wcid 238~253 are reserved for beacon#6(ra6).
328// - these wcid 222~237 are reserved for beacon#7(ra7).
329#if defined(MAX_MBSSID_NUM) && (MAX_MBSSID_NUM == 8)
330#define HW_RESERVED_WCID 222
331#elif defined(MAX_MBSSID_NUM) && (MAX_MBSSID_NUM == 7)
332#define HW_RESERVED_WCID 238
333#else
334#define HW_RESERVED_WCID 255
335#endif
336
337// Then dedicate wcid of DFS and Carrier-Sense.
338#define DFS_CTS_WCID (HW_RESERVED_WCID - 1)
339#define CS_CTS_WCID (HW_RESERVED_WCID - 2)
340#define LAST_SPECIFIC_WCID (HW_RESERVED_WCID - 2)
341
342// If MAX_MBSSID_NUM is 8, the maximum available wcid for the associated STA is 211.
343// If MAX_MBSSID_NUM is 7, the maximum available wcid for the associated STA is 228.
344#define MAX_AVAILABLE_CLIENT_WCID (LAST_SPECIFIC_WCID - MAX_MBSSID_NUM - 1)
345
346// TX need WCID to find Cipher Key
347// these wcid 212 ~ 219 are reserved for bc/mc packets if MAX_MBSSID_NUM is 8.
348#define GET_GroupKey_WCID(__wcid, __bssidx) \
349 { \
350 __wcid = LAST_SPECIFIC_WCID - (MAX_MBSSID_NUM) + __bssidx; \
351 }
352
353#define IsGroupKeyWCID(__wcid) (((__wcid) < LAST_SPECIFIC_WCID) && ((__wcid) >= (LAST_SPECIFIC_WCID - (MAX_MBSSID_NUM))))
354
355
356// definition to support multiple BSSID
357#define BSS0 0
358#define BSS1 1
359#define BSS2 2
360#define BSS3 3
361#define BSS4 4
362#define BSS5 5
363#define BSS6 6
364#define BSS7 7
365
366
367//============================================================
368// Length definitions
369#define PEER_KEY_NO 2
370#define MAC_ADDR_LEN 6
371#define TIMESTAMP_LEN 8
372#define MAX_LEN_OF_SUPPORTED_RATES MAX_LENGTH_OF_SUPPORT_RATES // 1, 2, 5.5, 11, 6, 9, 12, 18, 24, 36, 48, 54
373#define MAX_LEN_OF_KEY 32 // 32 octets == 256 bits, Redefine for WPA
374#define MAX_NUM_OF_CHANNELS MAX_NUM_OF_CHS // 14 channels @2.4G + 12@UNII + 4 @MMAC + 11 @HiperLAN2 + 7 @Japan + 1 as NULL termination
375#define MAX_NUM_OF_11JCHANNELS 20 // 14 channels @2.4G + 12@UNII + 4 @MMAC + 11 @HiperLAN2 + 7 @Japan + 1 as NULL termination
376#define MAX_LEN_OF_SSID 32
377#define CIPHER_TEXT_LEN 128
378#define HASH_TABLE_SIZE 256
379#define MAX_VIE_LEN 1024 // New for WPA cipher suite variable IE sizes.
380#define MAX_SUPPORT_MCS 32
381
382//============================================================
383// ASIC WCID Table definition.
384//============================================================
385#define BSSID_WCID 1 // in infra mode, always put bssid with this WCID
386#define MCAST_WCID 0x0
387#define BSS0Mcast_WCID 0x0
388#define BSS1Mcast_WCID 0xf8
389#define BSS2Mcast_WCID 0xf9
390#define BSS3Mcast_WCID 0xfa
391#define BSS4Mcast_WCID 0xfb
392#define BSS5Mcast_WCID 0xfc
393#define BSS6Mcast_WCID 0xfd
394#define BSS7Mcast_WCID 0xfe
395#define RESERVED_WCID 0xff
396
397#define MAX_NUM_OF_ACL_LIST MAX_NUMBER_OF_ACL
398
399#define MAX_LEN_OF_MAC_TABLE MAX_NUMBER_OF_MAC // if MAX_MBSSID_NUM is 8, this value can't be larger than 211
400
401#if MAX_LEN_OF_MAC_TABLE>MAX_AVAILABLE_CLIENT_WCID
402#error MAX_LEN_OF_MAC_TABLE can not be larger than MAX_AVAILABLE_CLIENT_WCID!!!!
403#endif
404
405#define MAX_NUM_OF_WDS_LINK_PERBSSID 3
406#define MAX_NUM_OF_WDS_LINK (MAX_NUM_OF_WDS_LINK_PERBSSID*MAX_MBSSID_NUM)
407#define MAX_NUM_OF_EVENT MAX_NUMBER_OF_EVENT
408#define WDS_LINK_START_WCID (MAX_LEN_OF_MAC_TABLE-1)
409
410#define NUM_OF_TID 8
411#define MAX_AID_BA 4
412#define MAX_LEN_OF_BA_REC_TABLE ((NUM_OF_TID * MAX_LEN_OF_MAC_TABLE)/2)// (NUM_OF_TID*MAX_AID_BA + 32) //Block ACK recipient
413#define MAX_LEN_OF_BA_ORI_TABLE ((NUM_OF_TID * MAX_LEN_OF_MAC_TABLE)/2)// (NUM_OF_TID*MAX_AID_BA + 32) // Block ACK originator
414#define MAX_LEN_OF_BSS_TABLE 64
415#define MAX_REORDERING_MPDU_NUM 512
416
417// key related definitions
418#define SHARE_KEY_NUM 4
419#define MAX_LEN_OF_SHARE_KEY 16 // byte count
420#define MAX_LEN_OF_PEER_KEY 16 // byte count
421#define PAIRWISE_KEY_NUM 64 // in MAC ASIC pairwise key table
422#define GROUP_KEY_NUM 4
423#define PMK_LEN 32
424#define WDS_PAIRWISE_KEY_OFFSET 60 // WDS links uses pairwise key#60 ~ 63 in ASIC pairwise key table
425#define PMKID_NO 4 // Number of PMKID saved supported
426#define MAX_LEN_OF_MLME_BUFFER 2048
427
428// power status related definitions
429#define PWR_ACTIVE 0
430#define PWR_SAVE 1
431#define PWR_MMPS 2 //MIMO power save
432
433// Auth and Assoc mode related definitions
434#define AUTH_MODE_OPEN 0x00
435#define AUTH_MODE_KEY 0x01
436
437// BSS Type definitions
438#define BSS_ADHOC 0 // = Ndis802_11IBSS
439#define BSS_INFRA 1 // = Ndis802_11Infrastructure
440#define BSS_ANY 2 // = Ndis802_11AutoUnknown
441#define BSS_MONITOR 3 // = Ndis802_11Monitor
442
443
444// Reason code definitions
445#define REASON_RESERVED 0
446#define REASON_UNSPECIFY 1
447#define REASON_NO_LONGER_VALID 2
448#define REASON_DEAUTH_STA_LEAVING 3
449#define REASON_DISASSOC_INACTIVE 4
450#define REASON_DISASSPC_AP_UNABLE 5
451#define REASON_CLS2ERR 6
452#define REASON_CLS3ERR 7
453#define REASON_DISASSOC_STA_LEAVING 8
454#define REASON_STA_REQ_ASSOC_NOT_AUTH 9
455#define REASON_INVALID_IE 13
456#define REASON_MIC_FAILURE 14
457#define REASON_4_WAY_TIMEOUT 15
458#define REASON_GROUP_KEY_HS_TIMEOUT 16
459#define REASON_IE_DIFFERENT 17
460#define REASON_MCIPHER_NOT_VALID 18
461#define REASON_UCIPHER_NOT_VALID 19
462#define REASON_AKMP_NOT_VALID 20
463#define REASON_UNSUPPORT_RSNE_VER 21
464#define REASON_INVALID_RSNE_CAP 22
465#define REASON_8021X_AUTH_FAIL 23
466#define REASON_CIPHER_SUITE_REJECTED 24
467#define REASON_DECLINED 37
468
469#define REASON_QOS_UNSPECIFY 32
470#define REASON_QOS_LACK_BANDWIDTH 33
471#define REASON_POOR_CHANNEL_CONDITION 34
472#define REASON_QOS_OUTSIDE_TXOP_LIMITION 35
473#define REASON_QOS_QSTA_LEAVING_QBSS 36
474#define REASON_QOS_UNWANTED_MECHANISM 37
475#define REASON_QOS_MECH_SETUP_REQUIRED 38
476#define REASON_QOS_REQUEST_TIMEOUT 39
477#define REASON_QOS_CIPHER_NOT_SUPPORT 45
478
479// Status code definitions
480#define MLME_SUCCESS 0
481#define MLME_UNSPECIFY_FAIL 1
482#define MLME_CANNOT_SUPPORT_CAP 10
483#define MLME_REASSOC_DENY_ASSOC_EXIST 11
484#define MLME_ASSOC_DENY_OUT_SCOPE 12
485#define MLME_ALG_NOT_SUPPORT 13
486#define MLME_SEQ_NR_OUT_OF_SEQUENCE 14
487#define MLME_REJ_CHALLENGE_FAILURE 15
488#define MLME_REJ_TIMEOUT 16
489#define MLME_ASSOC_REJ_UNABLE_HANDLE_STA 17
490#define MLME_ASSOC_REJ_DATA_RATE 18
491
492#define MLME_ASSOC_REJ_NO_EXT_RATE 22
493#define MLME_ASSOC_REJ_NO_EXT_RATE_PBCC 23
494#define MLME_ASSOC_REJ_NO_CCK_OFDM 24
495
496#define MLME_QOS_UNSPECIFY 32
497#define MLME_REQUEST_DECLINED 37
498#define MLME_REQUEST_WITH_INVALID_PARAM 38
499#define MLME_DLS_NOT_ALLOW_IN_QBSS 48
500#define MLME_DEST_STA_NOT_IN_QBSS 49
501#define MLME_DEST_STA_IS_NOT_A_QSTA 50
502
503#define MLME_INVALID_FORMAT 0x51
504#define MLME_FAIL_NO_RESOURCE 0x52
505#define MLME_STATE_MACHINE_REJECT 0x53
506#define MLME_MAC_TABLE_FAIL 0x54
507
508// IE code
509#define IE_SSID 0
510#define IE_SUPP_RATES 1
511#define IE_FH_PARM 2
512#define IE_DS_PARM 3
513#define IE_CF_PARM 4
514#define IE_TIM 5
515#define IE_IBSS_PARM 6
516#define IE_COUNTRY 7 // 802.11d
517#define IE_802_11D_REQUEST 10 // 802.11d
518#define IE_QBSS_LOAD 11 // 802.11e d9
519#define IE_EDCA_PARAMETER 12 // 802.11e d9
520#define IE_TSPEC 13 // 802.11e d9
521#define IE_TCLAS 14 // 802.11e d9
522#define IE_SCHEDULE 15 // 802.11e d9
523#define IE_CHALLENGE_TEXT 16
524#define IE_POWER_CONSTRAINT 32 // 802.11h d3.3
525#define IE_POWER_CAPABILITY 33 // 802.11h d3.3
526#define IE_TPC_REQUEST 34 // 802.11h d3.3
527#define IE_TPC_REPORT 35 // 802.11h d3.3
528#define IE_SUPP_CHANNELS 36 // 802.11h d3.3
529#define IE_CHANNEL_SWITCH_ANNOUNCEMENT 37 // 802.11h d3.3
530#define IE_MEASUREMENT_REQUEST 38 // 802.11h d3.3
531#define IE_MEASUREMENT_REPORT 39 // 802.11h d3.3
532#define IE_QUIET 40 // 802.11h d3.3
533#define IE_IBSS_DFS 41 // 802.11h d3.3
534#define IE_ERP 42 // 802.11g
535#define IE_TS_DELAY 43 // 802.11e d9
536#define IE_TCLAS_PROCESSING 44 // 802.11e d9
537#define IE_QOS_CAPABILITY 46 // 802.11e d6
538#define IE_HT_CAP 45 // 802.11n d1. HT CAPABILITY. ELEMENT ID TBD
539#define IE_AP_CHANNEL_REPORT 51 // 802.11k d6
540#define IE_HT_CAP2 52 // 802.11n d1. HT CAPABILITY. ELEMENT ID TBD
541#define IE_RSN 48 // 802.11i d3.0
542#define IE_WPA2 48 // WPA2
543#define IE_EXT_SUPP_RATES 50 // 802.11g
544#define IE_SUPP_REG_CLASS 59 // 802.11y. Supported regulatory classes.
545#define IE_EXT_CHANNEL_SWITCH_ANNOUNCEMENT 60 // 802.11n
546#define IE_ADD_HT 61 // 802.11n d1. ADDITIONAL HT CAPABILITY. ELEMENT ID TBD
547#define IE_ADD_HT2 53 // 802.11n d1. ADDITIONAL HT CAPABILITY. ELEMENT ID TBD
548
549
550// For 802.11n D3.03
551//#define IE_NEW_EXT_CHA_OFFSET 62 // 802.11n d1. New extension channel offset elemet
552#define IE_SECONDARY_CH_OFFSET 62 // 802.11n D3.03 Secondary Channel Offset element
553#define IE_WAPI 68 // WAPI information element
554#define IE_2040_BSS_COEXIST 72 // 802.11n D3.0.3
555#define IE_2040_BSS_INTOLERANT_REPORT 73 // 802.11n D3.03
556#define IE_OVERLAPBSS_SCAN_PARM 74 // 802.11n D3.03
557#define IE_EXT_CAPABILITY 127 // 802.11n D3.03
558
559
560#define IE_WPA 221 // WPA
561#define IE_VENDOR_SPECIFIC 221 // Wifi WMM (WME)
562
563#define OUI_BROADCOM_HT 51 //
564#define OUI_BROADCOM_HTADD 52 //
565#define OUI_PREN_HT_CAP 51 //
566#define OUI_PREN_ADD_HT 52 //
567
568// CCX information
569#define IE_AIRONET_CKIP 133 // CCX1.0 ID 85H for CKIP
570#define IE_AP_TX_POWER 150 // CCX 2.0 for AP transmit power
571#define IE_MEASUREMENT_CAPABILITY 221 // CCX 2.0
572#define IE_CCX_V2 221
573#define IE_AIRONET_IPADDRESS 149 // CCX ID 95H for IP Address
574#define IE_AIRONET_CCKMREASSOC 156 // CCX ID 9CH for CCKM Reassociation Request element
575#define CKIP_NEGOTIATION_LENGTH 30
576#define AIRONET_IPADDRESS_LENGTH 10
577#define AIRONET_CCKMREASSOC_LENGTH 24
578
579// ========================================================
580// MLME state machine definition
581// ========================================================
582
583// STA MLME state mahcines
584#define ASSOC_STATE_MACHINE 1
585#define AUTH_STATE_MACHINE 2
586#define AUTH_RSP_STATE_MACHINE 3
587#define SYNC_STATE_MACHINE 4
588#define MLME_CNTL_STATE_MACHINE 5
589#define WPA_PSK_STATE_MACHINE 6
590#define LEAP_STATE_MACHINE 7
591#define AIRONET_STATE_MACHINE 8
592#define ACTION_STATE_MACHINE 9
593
594// AP MLME state machines
595#define AP_ASSOC_STATE_MACHINE 11
596#define AP_AUTH_STATE_MACHINE 12
597#define AP_AUTH_RSP_STATE_MACHINE 13
598#define AP_SYNC_STATE_MACHINE 14
599#define AP_CNTL_STATE_MACHINE 15
600#define AP_WPA_STATE_MACHINE 16
601
602#ifdef RT30xx
603#define WSC_STATE_MACHINE 17
604#define WSC_UPNP_STATE_MACHINE 18
605#endif
606
607//
608// STA's CONTROL/CONNECT state machine: states, events, total function #
609//
610#define CNTL_IDLE 0
611#define CNTL_WAIT_DISASSOC 1
612#define CNTL_WAIT_JOIN 2
613#define CNTL_WAIT_REASSOC 3
614#define CNTL_WAIT_START 4
615#define CNTL_WAIT_AUTH 5
616#define CNTL_WAIT_ASSOC 6
617#define CNTL_WAIT_AUTH2 7
618#define CNTL_WAIT_OID_LIST_SCAN 8
619#define CNTL_WAIT_OID_DISASSOC 9
620#ifdef RT2870
621#define CNTL_WAIT_SCAN_FOR_CONNECT 10
622#endif // RT2870 //
623
624#define MT2_ASSOC_CONF 34
625#define MT2_AUTH_CONF 35
626#define MT2_DEAUTH_CONF 36
627#define MT2_DISASSOC_CONF 37
628#define MT2_REASSOC_CONF 38
629#define MT2_PWR_MGMT_CONF 39
630#define MT2_JOIN_CONF 40
631#define MT2_SCAN_CONF 41
632#define MT2_START_CONF 42
633#define MT2_GET_CONF 43
634#define MT2_SET_CONF 44
635#define MT2_RESET_CONF 45
636#define MT2_MLME_ROAMING_REQ 52
637
638#define CNTL_FUNC_SIZE 1
639
640//
641// STA's ASSOC state machine: states, events, total function #
642//
643#define ASSOC_IDLE 0
644#define ASSOC_WAIT_RSP 1
645#define REASSOC_WAIT_RSP 2
646#define DISASSOC_WAIT_RSP 3
647#define MAX_ASSOC_STATE 4
648
649#define ASSOC_MACHINE_BASE 0
650#define MT2_MLME_ASSOC_REQ 0
651#define MT2_MLME_REASSOC_REQ 1
652#define MT2_MLME_DISASSOC_REQ 2
653#define MT2_PEER_DISASSOC_REQ 3
654#define MT2_PEER_ASSOC_REQ 4
655#define MT2_PEER_ASSOC_RSP 5
656#define MT2_PEER_REASSOC_REQ 6
657#define MT2_PEER_REASSOC_RSP 7
658#define MT2_DISASSOC_TIMEOUT 8
659#define MT2_ASSOC_TIMEOUT 9
660#define MT2_REASSOC_TIMEOUT 10
661#define MAX_ASSOC_MSG 11
662
663#define ASSOC_FUNC_SIZE (MAX_ASSOC_STATE * MAX_ASSOC_MSG)
664
665//
666// ACT state machine: states, events, total function #
667//
668#define ACT_IDLE 0
669#define MAX_ACT_STATE 1
670
671#define ACT_MACHINE_BASE 0
672
673//Those PEER_xx_CATE number is based on real Categary value in IEEE spec. Please don'es modify it by your self.
674//Category
675#define MT2_PEER_SPECTRUM_CATE 0
676#define MT2_PEER_QOS_CATE 1
677#define MT2_PEER_DLS_CATE 2
678#define MT2_PEER_BA_CATE 3
679#define MT2_PEER_PUBLIC_CATE 4
680#define MT2_PEER_RM_CATE 5
681#define MT2_PEER_HT_CATE 7 // 7.4.7
682#define MAX_PEER_CATE_MSG 7
683#define MT2_MLME_ADD_BA_CATE 8
684#define MT2_MLME_ORI_DELBA_CATE 9
685#define MT2_MLME_REC_DELBA_CATE 10
686#define MT2_MLME_QOS_CATE 11
687#define MT2_MLME_DLS_CATE 12
688#define MT2_ACT_INVALID 13
689#define MAX_ACT_MSG 14
690
691//Category field
692#define CATEGORY_SPECTRUM 0
693#define CATEGORY_QOS 1
694#define CATEGORY_DLS 2
695#define CATEGORY_BA 3
696#define CATEGORY_PUBLIC 4
697#define CATEGORY_RM 5
698#define CATEGORY_HT 7
699
700
701// DLS Action frame definition
702#define ACTION_DLS_REQUEST 0
703#define ACTION_DLS_RESPONSE 1
704#define ACTION_DLS_TEARDOWN 2
705
706//Spectrum Action field value 802.11h 7.4.1
707#define SPEC_MRQ 0 // Request
708#define SPEC_MRP 1 //Report
709#define SPEC_TPCRQ 2
710#define SPEC_TPCRP 3
711#define SPEC_CHANNEL_SWITCH 4
712
713
714//BA Action field value
715#define ADDBA_REQ 0
716#define ADDBA_RESP 1
717#define DELBA 2
718
719//Public's Action field value in Public Category. Some in 802.11y and some in 11n
720#define ACTION_BSS_2040_COEXIST 0 // 11n
721#define ACTION_DSE_ENABLEMENT 1 // 11y D9.0
722#define ACTION_DSE_DEENABLEMENT 2 // 11y D9.0
723#define ACTION_DSE_REG_LOCATION_ANNOUNCE 3 // 11y D9.0
724#define ACTION_EXT_CH_SWITCH_ANNOUNCE 4 // 11y D9.0
725#define ACTION_DSE_MEASUREMENT_REQ 5 // 11y D9.0
726#define ACTION_DSE_MEASUREMENT_REPORT 6 // 11y D9.0
727#define ACTION_MEASUREMENT_PILOT_ACTION 7 // 11y D9.0
728#define ACTION_DSE_POWER_CONSTRAINT 8 // 11y D9.0
729
730
731//HT Action field value
732#define NOTIFY_BW_ACTION 0
733#define SMPS_ACTION 1
734#define PSMP_ACTION 2
735#define SETPCO_ACTION 3
736#define MIMO_CHA_MEASURE_ACTION 4
737#define MIMO_N_BEACONFORM 5
738#define MIMO_BEACONFORM 6
739#define ANTENNA_SELECT 7
740#define HT_INFO_EXCHANGE 8
741
742#define ACT_FUNC_SIZE (MAX_ACT_STATE * MAX_ACT_MSG)
743//
744// STA's AUTHENTICATION state machine: states, evvents, total function #
745//
746#define AUTH_REQ_IDLE 0
747#define AUTH_WAIT_SEQ2 1
748#define AUTH_WAIT_SEQ4 2
749#define MAX_AUTH_STATE 3
750
751#define AUTH_MACHINE_BASE 0
752#define MT2_MLME_AUTH_REQ 0
753#define MT2_PEER_AUTH_EVEN 1
754#define MT2_AUTH_TIMEOUT 2
755#define MAX_AUTH_MSG 3
756
757#define AUTH_FUNC_SIZE (MAX_AUTH_STATE * MAX_AUTH_MSG)
758
759//
760// STA's AUTH_RSP state machine: states, events, total function #
761//
762#define AUTH_RSP_IDLE 0
763#define AUTH_RSP_WAIT_CHAL 1
764#define MAX_AUTH_RSP_STATE 2
765
766#define AUTH_RSP_MACHINE_BASE 0
767#define MT2_AUTH_CHALLENGE_TIMEOUT 0
768#define MT2_PEER_AUTH_ODD 1
769#define MT2_PEER_DEAUTH 2
770#define MAX_AUTH_RSP_MSG 3
771
772#define AUTH_RSP_FUNC_SIZE (MAX_AUTH_RSP_STATE * MAX_AUTH_RSP_MSG)
773
774//
775// STA's SYNC state machine: states, events, total function #
776//
777#define SYNC_IDLE 0 // merge NO_BSS,IBSS_IDLE,IBSS_ACTIVE and BSS in to 1 state
778#define JOIN_WAIT_BEACON 1
779#define SCAN_LISTEN 2
780#define MAX_SYNC_STATE 3
781
782#define SYNC_MACHINE_BASE 0
783#define MT2_MLME_SCAN_REQ 0
784#define MT2_MLME_JOIN_REQ 1
785#define MT2_MLME_START_REQ 2
786#define MT2_PEER_BEACON 3
787#define MT2_PEER_PROBE_RSP 4
788#define MT2_PEER_ATIM 5
789#define MT2_SCAN_TIMEOUT 6
790#define MT2_BEACON_TIMEOUT 7
791#define MT2_ATIM_TIMEOUT 8
792#define MT2_PEER_PROBE_REQ 9
793#define MAX_SYNC_MSG 10
794
795#define SYNC_FUNC_SIZE (MAX_SYNC_STATE * MAX_SYNC_MSG)
796
797//Messages for the DLS state machine
798#define DLS_IDLE 0
799#define MAX_DLS_STATE 1
800
801#define DLS_MACHINE_BASE 0
802#define MT2_MLME_DLS_REQ 0
803#define MT2_PEER_DLS_REQ 1
804#define MT2_PEER_DLS_RSP 2
805#define MT2_MLME_DLS_TEAR_DOWN 3
806#define MT2_PEER_DLS_TEAR_DOWN 4
807#define MAX_DLS_MSG 5
808
809#define DLS_FUNC_SIZE (MAX_DLS_STATE * MAX_DLS_MSG)
810
811//
812// STA's WPA-PSK State machine: states, events, total function #
813//
814#define WPA_PSK_IDLE 0
815#define MAX_WPA_PSK_STATE 1
816
817#define WPA_MACHINE_BASE 0
818#define MT2_EAPPacket 0
819#define MT2_EAPOLStart 1
820#define MT2_EAPOLLogoff 2
821#define MT2_EAPOLKey 3
822#define MT2_EAPOLASFAlert 4
823#define MAX_WPA_PSK_MSG 5
824
825#define WPA_PSK_FUNC_SIZE (MAX_WPA_PSK_STATE * MAX_WPA_PSK_MSG)
826
827//
828// STA's CISCO-AIRONET State machine: states, events, total function #
829//
830#define AIRONET_IDLE 0
831#define AIRONET_SCANNING 1
832#define MAX_AIRONET_STATE 2
833
834#define AIRONET_MACHINE_BASE 0
835#define MT2_AIRONET_MSG 0
836#define MT2_AIRONET_SCAN_REQ 1
837#define MT2_AIRONET_SCAN_DONE 2
838#define MAX_AIRONET_MSG 3
839
840#define AIRONET_FUNC_SIZE (MAX_AIRONET_STATE * MAX_AIRONET_MSG)
841
842//
843// AP's CONTROL/CONNECT state machine: states, events, total function #
844//
845#define AP_CNTL_FUNC_SIZE 1
846
847//
848// AP's ASSOC state machine: states, events, total function #
849//
850#define AP_ASSOC_IDLE 0
851#define AP_MAX_ASSOC_STATE 1
852
853#define AP_ASSOC_MACHINE_BASE 0
854#define APMT2_MLME_DISASSOC_REQ 0
855#define APMT2_PEER_DISASSOC_REQ 1
856#define APMT2_PEER_ASSOC_REQ 2
857#define APMT2_PEER_REASSOC_REQ 3
858#define APMT2_CLS3ERR 4
859#define AP_MAX_ASSOC_MSG 5
860
861#define AP_ASSOC_FUNC_SIZE (AP_MAX_ASSOC_STATE * AP_MAX_ASSOC_MSG)
862
863//
864// AP's AUTHENTICATION state machine: states, events, total function #
865//
866#define AP_AUTH_REQ_IDLE 0
867#define AP_MAX_AUTH_STATE 1
868
869#define AP_AUTH_MACHINE_BASE 0
870#define APMT2_MLME_DEAUTH_REQ 0
871#define APMT2_CLS2ERR 1
872#define AP_MAX_AUTH_MSG 2
873
874#define AP_AUTH_FUNC_SIZE (AP_MAX_AUTH_STATE * AP_MAX_AUTH_MSG)
875
876//
877// AP's AUTH-RSP state machine: states, events, total function #
878//
879#define AP_AUTH_RSP_IDLE 0
880#define AP_MAX_AUTH_RSP_STATE 1
881
882#define AP_AUTH_RSP_MACHINE_BASE 0
883#define APMT2_AUTH_CHALLENGE_TIMEOUT 0
884#define APMT2_PEER_AUTH_ODD 1
885#define APMT2_PEER_DEAUTH 2
886#define AP_MAX_AUTH_RSP_MSG 3
887
888#define AP_AUTH_RSP_FUNC_SIZE (AP_MAX_AUTH_RSP_STATE * AP_MAX_AUTH_RSP_MSG)
889
890//
891// AP's SYNC state machine: states, events, total function #
892//
893#define AP_SYNC_IDLE 0
894#define AP_SCAN_LISTEN 1
895#define AP_MAX_SYNC_STATE 2
896
897#define AP_SYNC_MACHINE_BASE 0
898#define APMT2_PEER_PROBE_REQ 0
899#define APMT2_PEER_BEACON 1
900#define APMT2_MLME_SCAN_REQ 2
901#define APMT2_PEER_PROBE_RSP 3
902#define APMT2_SCAN_TIMEOUT 4
903#define APMT2_MLME_SCAN_CNCL 5
904#define AP_MAX_SYNC_MSG 6
905
906#define AP_SYNC_FUNC_SIZE (AP_MAX_SYNC_STATE * AP_MAX_SYNC_MSG)
907
908//
909// AP's WPA state machine: states, events, total function #
910//
911#define AP_WPA_PTK 0
912#define AP_MAX_WPA_PTK_STATE 1
913
914#define AP_WPA_MACHINE_BASE 0
915#define APMT2_EAPPacket 0
916#define APMT2_EAPOLStart 1
917#define APMT2_EAPOLLogoff 2
918#define APMT2_EAPOLKey 3
919#define APMT2_EAPOLASFAlert 4
920#define AP_MAX_WPA_MSG 5
921
922#define AP_WPA_FUNC_SIZE (AP_MAX_WPA_PTK_STATE * AP_MAX_WPA_MSG)
923
924// =============================================================================
925
926// value domain of 802.11 header FC.Tyte, which is b3..b2 of the 1st-byte of MAC header
927#define BTYPE_MGMT 0
928#define BTYPE_CNTL 1
929#define BTYPE_DATA 2
930
931// value domain of 802.11 MGMT frame's FC.subtype, which is b7..4 of the 1st-byte of MAC header
932#define SUBTYPE_ASSOC_REQ 0
933#define SUBTYPE_ASSOC_RSP 1
934#define SUBTYPE_REASSOC_REQ 2
935#define SUBTYPE_REASSOC_RSP 3
936#define SUBTYPE_PROBE_REQ 4
937#define SUBTYPE_PROBE_RSP 5
938#define SUBTYPE_BEACON 8
939#define SUBTYPE_ATIM 9
940#define SUBTYPE_DISASSOC 10
941#define SUBTYPE_AUTH 11
942#define SUBTYPE_DEAUTH 12
943#define SUBTYPE_ACTION 13
944#define SUBTYPE_ACTION_NO_ACK 14
945
946// value domain of 802.11 CNTL frame's FC.subtype, which is b7..4 of the 1st-byte of MAC header
947#define SUBTYPE_WRAPPER 7
948#define SUBTYPE_BLOCK_ACK_REQ 8
949#define SUBTYPE_BLOCK_ACK 9
950#define SUBTYPE_PS_POLL 10
951#define SUBTYPE_RTS 11
952#define SUBTYPE_CTS 12
953#define SUBTYPE_ACK 13
954#define SUBTYPE_CFEND 14
955#define SUBTYPE_CFEND_CFACK 15
956
957// value domain of 802.11 DATA frame's FC.subtype, which is b7..4 of the 1st-byte of MAC header
958#define SUBTYPE_DATA 0
959#define SUBTYPE_DATA_CFACK 1
960#define SUBTYPE_DATA_CFPOLL 2
961#define SUBTYPE_DATA_CFACK_CFPOLL 3
962#define SUBTYPE_NULL_FUNC 4
963#define SUBTYPE_CFACK 5
964#define SUBTYPE_CFPOLL 6
965#define SUBTYPE_CFACK_CFPOLL 7
966#define SUBTYPE_QDATA 8
967#define SUBTYPE_QDATA_CFACK 9
968#define SUBTYPE_QDATA_CFPOLL 10
969#define SUBTYPE_QDATA_CFACK_CFPOLL 11
970#define SUBTYPE_QOS_NULL 12
971#define SUBTYPE_QOS_CFACK 13
972#define SUBTYPE_QOS_CFPOLL 14
973#define SUBTYPE_QOS_CFACK_CFPOLL 15
974
975// ACK policy of QOS Control field bit 6:5
976#define NORMAL_ACK 0x00 // b6:5 = 00
977#define NO_ACK 0x20 // b6:5 = 01
978#define NO_EXPLICIT_ACK 0x40 // b6:5 = 10
979#define BLOCK_ACK 0x60 // b6:5 = 11
980
981//
982// rtmp_data.c use these definition
983//
984#define LENGTH_802_11 24
985#define LENGTH_802_11_AND_H 30
986#define LENGTH_802_11_CRC_H 34
987#define LENGTH_802_11_CRC 28
988#define LENGTH_802_11_WITH_ADDR4 30
989#define LENGTH_802_3 14
990#define LENGTH_802_3_TYPE 2
991#define LENGTH_802_1_H 8
992#define LENGTH_EAPOL_H 4
993#define LENGTH_WMMQOS_H 2
994#define LENGTH_CRC 4
995#define MAX_SEQ_NUMBER 0x0fff
996#define LENGTH_802_3_NO_TYPE 12
997#define LENGTH_802_1Q 4 /* VLAN related */
998
999// STA_CSR4.field.TxResult
1000#define TX_RESULT_SUCCESS 0
1001#define TX_RESULT_ZERO_LENGTH 1
1002#define TX_RESULT_UNDER_RUN 2
1003#define TX_RESULT_OHY_ERROR 4
1004#define TX_RESULT_RETRY_FAIL 6
1005
1006// All PHY rate summary in TXD
1007// Preamble MODE in TxD
1008#define MODE_CCK 0
1009#define MODE_OFDM 1
1010#define MODE_HTMIX 2
1011#define MODE_HTGREENFIELD 3
1012
1013// MCS for CCK. BW.SGI.STBC are reserved
1014#define MCS_LONGP_RATE_1 0 // long preamble CCK 1Mbps
1015#define MCS_LONGP_RATE_2 1 // long preamble CCK 1Mbps
1016#define MCS_LONGP_RATE_5_5 2
1017#define MCS_LONGP_RATE_11 3
1018#define MCS_SHORTP_RATE_1 4 // long preamble CCK 1Mbps. short is forbidden in 1Mbps
1019#define MCS_SHORTP_RATE_2 5 // short preamble CCK 2Mbps
1020#define MCS_SHORTP_RATE_5_5 6
1021#define MCS_SHORTP_RATE_11 7
1022// To send duplicate legacy OFDM. set BW=BW_40. SGI.STBC are reserved
1023#define MCS_RATE_6 0 // legacy OFDM
1024#define MCS_RATE_9 1 // OFDM
1025#define MCS_RATE_12 2 // OFDM
1026#define MCS_RATE_18 3 // OFDM
1027#define MCS_RATE_24 4 // OFDM
1028#define MCS_RATE_36 5 // OFDM
1029#define MCS_RATE_48 6 // OFDM
1030#define MCS_RATE_54 7 // OFDM
1031// HT
1032#define MCS_0 0 // 1S
1033#define MCS_1 1
1034#define MCS_2 2
1035#define MCS_3 3
1036#define MCS_4 4
1037#define MCS_5 5
1038#define MCS_6 6
1039#define MCS_7 7
1040#define MCS_8 8 // 2S
1041#define MCS_9 9
1042#define MCS_10 10
1043#define MCS_11 11
1044#define MCS_12 12
1045#define MCS_13 13
1046#define MCS_14 14
1047#define MCS_15 15
1048#define MCS_16 16 // 3*3
1049#define MCS_17 17
1050#define MCS_18 18
1051#define MCS_19 19
1052#define MCS_20 20
1053#define MCS_21 21
1054#define MCS_22 22
1055#define MCS_23 23
1056#define MCS_32 32
1057#define MCS_AUTO 33
1058
1059// OID_HTPHYMODE
1060// MODE
1061#define HTMODE_MM 0
1062#define HTMODE_GF 1
1063
1064// Fixed Tx MODE - HT, CCK or OFDM
1065#define FIXED_TXMODE_HT 0
1066#define FIXED_TXMODE_CCK 1
1067#define FIXED_TXMODE_OFDM 2
1068// BW
1069#define BW_20 BAND_WIDTH_20
1070#define BW_40 BAND_WIDTH_40
1071#define BW_BOTH BAND_WIDTH_BOTH
1072#define BW_10 BAND_WIDTH_10 // 802.11j has 10MHz. This definition is for internal usage. doesn't fill in the IE or other field.
1073
1074// SHORTGI
1075#define GI_400 GAP_INTERVAL_400 // only support in HT mode
1076#define GI_BOTH GAP_INTERVAL_BOTH
1077#define GI_800 GAP_INTERVAL_800
1078// STBC
1079#define STBC_NONE 0
1080#define STBC_USE 1 // limited use in rt2860b phy
1081#define RXSTBC_ONE 1 // rx support of one spatial stream
1082#define RXSTBC_TWO 2 // rx support of 1 and 2 spatial stream
1083#define RXSTBC_THR 3 // rx support of 1~3 spatial stream
1084// MCS FEEDBACK
1085#define MCSFBK_NONE 0 // not support mcs feedback /
1086#define MCSFBK_RSV 1 // reserved
1087#define MCSFBK_UNSOLICIT 2 // only support unsolict mcs feedback
1088#define MCSFBK_MRQ 3 // response to both MRQ and unsolict mcs feedback
1089
1090// MIMO power safe
1091#define MMPS_STATIC 0
1092#define MMPS_DYNAMIC 1
1093#define MMPS_RSV 2
1094#define MMPS_ENABLE 3
1095
1096
1097// A-MSDU size
1098#define AMSDU_0 0
1099#define AMSDU_1 1
1100
1101// MCS use 7 bits
1102#define TXRATEMIMO 0x80
1103#define TXRATEMCS 0x7F
1104#define TXRATEOFDM 0x7F
1105#define RATE_1 0
1106#define RATE_2 1
1107#define RATE_5_5 2
1108#define RATE_11 3
1109#define RATE_6 4 // OFDM
1110#define RATE_9 5 // OFDM
1111#define RATE_12 6 // OFDM
1112#define RATE_18 7 // OFDM
1113#define RATE_24 8 // OFDM
1114#define RATE_36 9 // OFDM
1115#define RATE_48 10 // OFDM
1116#define RATE_54 11 // OFDM
1117#define RATE_FIRST_OFDM_RATE RATE_6
1118#define RATE_LAST_OFDM_RATE RATE_54
1119#define RATE_6_5 12 // HT mix
1120#define RATE_13 13 // HT mix
1121#define RATE_19_5 14 // HT mix
1122#define RATE_26 15 // HT mix
1123#define RATE_39 16 // HT mix
1124#define RATE_52 17 // HT mix
1125#define RATE_58_5 18 // HT mix
1126#define RATE_65 19 // HT mix
1127#define RATE_78 20 // HT mix
1128#define RATE_104 21 // HT mix
1129#define RATE_117 22 // HT mix
1130#define RATE_130 23 // HT mix
1131//#define RATE_AUTO_SWITCH 255 // for StaCfg.FixedTxRate only
1132#define HTRATE_0 12
1133#define RATE_FIRST_MM_RATE HTRATE_0
1134#define RATE_FIRST_HT_RATE HTRATE_0
1135#define RATE_LAST_HT_RATE HTRATE_0
1136
1137// pTxWI->txop
1138#define IFS_HTTXOP 0 // The txop will be handles by ASIC.
1139#define IFS_PIFS 1
1140#define IFS_SIFS 2
1141#define IFS_BACKOFF 3
1142
1143// pTxD->RetryMode
1144#define LONG_RETRY 1
1145#define SHORT_RETRY 0
1146
1147// Country Region definition
1148#define REGION_MINIMUM_BG_BAND 0
1149#define REGION_0_BG_BAND 0 // 1-11
1150#define REGION_1_BG_BAND 1 // 1-13
1151#define REGION_2_BG_BAND 2 // 10-11
1152#define REGION_3_BG_BAND 3 // 10-13
1153#define REGION_4_BG_BAND 4 // 14
1154#define REGION_5_BG_BAND 5 // 1-14
1155#define REGION_6_BG_BAND 6 // 3-9
1156#define REGION_7_BG_BAND 7 // 5-13
1157#define REGION_31_BG_BAND 31 // 5-13
1158#define REGION_MAXIMUM_BG_BAND 7
1159
1160#define REGION_MINIMUM_A_BAND 0
1161#define REGION_0_A_BAND 0 // 36, 40, 44, 48, 52, 56, 60, 64, 149, 153, 157, 161, 165
1162#define REGION_1_A_BAND 1 // 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140
1163#define REGION_2_A_BAND 2 // 36, 40, 44, 48, 52, 56, 60, 64
1164#define REGION_3_A_BAND 3 // 52, 56, 60, 64, 149, 153, 157, 161
1165#define REGION_4_A_BAND 4 // 149, 153, 157, 161, 165
1166#define REGION_5_A_BAND 5 // 149, 153, 157, 161
1167#define REGION_6_A_BAND 6 // 36, 40, 44, 48
1168#define REGION_7_A_BAND 7 // 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140, 149, 153, 157, 161, 165
1169#define REGION_8_A_BAND 8 // 52, 56, 60, 64
1170#define REGION_9_A_BAND 9 // 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 132, 136, 140, 149, 153, 157, 161, 165
1171#define REGION_10_A_BAND 10 // 36, 40, 44, 48, 149, 153, 157, 161, 165
1172#define REGION_11_A_BAND 11 // 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 149, 153, 157, 161
1173#define REGION_MAXIMUM_A_BAND 11
1174
1175// pTxD->CipherAlg
1176#define CIPHER_NONE 0
1177#define CIPHER_WEP64 1
1178#define CIPHER_WEP128 2
1179#define CIPHER_TKIP 3
1180#define CIPHER_AES 4
1181#define CIPHER_CKIP64 5
1182#define CIPHER_CKIP128 6
1183#define CIPHER_TKIP_NO_MIC 7 // MIC appended by driver: not a valid value in hardware key table
1184#define CIPHER_SMS4 8
1185
1186// value domain of pAd->RfIcType
1187#define RFIC_2820 1 // 2.4G 2T3R
1188#define RFIC_2850 2 // 2.4G/5G 2T3R
1189#define RFIC_2720 3 // 2.4G 1T2R
1190#define RFIC_2750 4 // 2.4G/5G 1T2R
1191#define RFIC_3020 5 // 2.4G 1T1R
1192#define RFIC_2020 6 // 2.4G B/G
1193#ifdef RT30xx
1194#define RFIC_3021 7 // 2.4G 1T2R
1195#define RFIC_3022 8 // 2.4G 2T2R
1196#endif
1197
1198// LED Status.
1199#define LED_LINK_DOWN 0
1200#define LED_LINK_UP 1
1201#define LED_RADIO_OFF 2
1202#define LED_RADIO_ON 3
1203#define LED_HALT 4
1204#define LED_WPS 5
1205#define LED_ON_SITE_SURVEY 6
1206#define LED_POWER_UP 7
1207
1208// value domain of pAd->LedCntl.LedMode and E2PROM
1209#define LED_MODE_DEFAULT 0
1210#define LED_MODE_TWO_LED 1
1211#define LED_MODE_SIGNAL_STREGTH 8 // EEPROM define =8
1212
1213// RC4 init value, used fro WEP & TKIP
1214#define PPPINITFCS32 0xffffffff /* Initial FCS value */
1215
1216// value domain of pAd->StaCfg.PortSecured. 802.1X controlled port definition
1217#define WPA_802_1X_PORT_SECURED 1
1218#define WPA_802_1X_PORT_NOT_SECURED 2
1219
1220#define PAIRWISE_KEY 1
1221#define GROUP_KEY 2
1222
1223//definition of DRS
1224#define MAX_STEP_OF_TX_RATE_SWITCH 32
1225
1226
1227// pre-allocated free NDIS PACKET/BUFFER poll for internal usage
1228#define MAX_NUM_OF_FREE_NDIS_PACKET 128
1229
1230//Block ACK
1231#define MAX_TX_REORDERBUF 64
1232#define MAX_RX_REORDERBUF 64
1233#define DEFAULT_TX_TIMEOUT 30
1234#define DEFAULT_RX_TIMEOUT 30
1235
1236// definition of Recipient or Originator
1237#define I_RECIPIENT TRUE
1238#define I_ORIGINATOR FALSE
1239
1240#define DEFAULT_BBP_TX_POWER 0
1241#define DEFAULT_RF_TX_POWER 5
1242
1243#define MAX_INI_BUFFER_SIZE 4096
1244#define MAX_PARAM_BUFFER_SIZE (2048) // enough for ACL (18*64)
1245 //18 : the length of Mac address acceptable format "01:02:03:04:05:06;")
1246 //64 : MAX_NUM_OF_ACL_LIST
1247// definition of pAd->OpMode
1248#define OPMODE_STA 0
1249#define OPMODE_AP 1
1250//#define OPMODE_L3_BRG 2 // as AP and STA at the same time
1251
1252// ========================= AP rtmp_def.h ===========================
1253// value domain for pAd->EventTab.Log[].Event
1254#define EVENT_RESET_ACCESS_POINT 0 // Log = "hh:mm:ss Restart Access Point"
1255#define EVENT_ASSOCIATED 1 // Log = "hh:mm:ss STA 00:01:02:03:04:05 associated"
1256#define EVENT_DISASSOCIATED 2 // Log = "hh:mm:ss STA 00:01:02:03:04:05 left this BSS"
1257#define EVENT_AGED_OUT 3 // Log = "hh:mm:ss STA 00:01:02:03:04:05 was aged-out and removed from this BSS"
1258#define EVENT_COUNTER_M 4
1259#define EVENT_INVALID_PSK 5
1260#define EVENT_MAX_EVENT_TYPE 6
1261// ==== end of AP rtmp_def.h ============
1262
1263// definition RSSI Number
1264#define RSSI_0 0
1265#define RSSI_1 1
1266#define RSSI_2 2
1267
1268// definition of radar detection
1269#define RD_NORMAL_MODE 0 // Not found radar signal
1270#define RD_SWITCHING_MODE 1 // Found radar signal, and doing channel switch
1271#define RD_SILENCE_MODE 2 // After channel switch, need to be silence a while to ensure radar not found
1272
1273//Driver defined cid for mapping status and command.
1274#define SLEEPCID 0x11
1275#define WAKECID 0x22
1276#define QUERYPOWERCID 0x33
1277#define OWNERMCU 0x1
1278#define OWNERCPU 0x0
1279
1280// MBSSID definition
1281#define ENTRY_NOT_FOUND 0xFF
1282
1283
1284/* After Linux 2.6.9,
1285 * VLAN module use Private (from user) interface flags (netdevice->priv_flags).
1286 * #define IFF_802_1Q_VLAN 0x1 -- 802.1Q VLAN device. in if.h
1287 * ref to ip_sabotage_out() [ out->priv_flags & IFF_802_1Q_VLAN ] in br_netfilter.c
1288 *
1289 * For this reason, we MUST use EVEN value in priv_flags
1290 */
1291#define INT_MAIN 0x0100
1292#define INT_MBSSID 0x0200
1293#define INT_WDS 0x0300
1294#define INT_APCLI 0x0400
1295#define INT_MESH 0x0500
1296
1297// Use bitmap to allow coexist of ATE_TXFRAME and ATE_RXFRAME(i.e.,to support LoopBack mode)
1298
1299// WEP Key TYPE
1300#define WEP_HEXADECIMAL_TYPE 0
1301#define WEP_ASCII_TYPE 1
1302
1303
1304
1305// WIRELESS EVENTS definition
1306/* Max number of char in custom event, refer to wireless_tools.28/wireless.20.h */
1307#define IW_CUSTOM_MAX_LEN 255 /* In bytes */
1308
1309// For system event - start
1310#define IW_SYS_EVENT_FLAG_START 0x0200
1311#define IW_ASSOC_EVENT_FLAG 0x0200
1312#define IW_DISASSOC_EVENT_FLAG 0x0201
1313#define IW_DEAUTH_EVENT_FLAG 0x0202
1314#define IW_AGEOUT_EVENT_FLAG 0x0203
1315#define IW_COUNTER_MEASURES_EVENT_FLAG 0x0204
1316#define IW_REPLAY_COUNTER_DIFF_EVENT_FLAG 0x0205
1317#define IW_RSNIE_DIFF_EVENT_FLAG 0x0206
1318#define IW_MIC_DIFF_EVENT_FLAG 0x0207
1319#define IW_ICV_ERROR_EVENT_FLAG 0x0208
1320#define IW_MIC_ERROR_EVENT_FLAG 0x0209
1321#define IW_GROUP_HS_TIMEOUT_EVENT_FLAG 0x020A
1322#define IW_PAIRWISE_HS_TIMEOUT_EVENT_FLAG 0x020B
1323#define IW_RSNIE_SANITY_FAIL_EVENT_FLAG 0x020C
1324#define IW_SET_KEY_DONE_WPA1_EVENT_FLAG 0x020D
1325#define IW_SET_KEY_DONE_WPA2_EVENT_FLAG 0x020E
1326#define IW_STA_LINKUP_EVENT_FLAG 0x020F
1327#define IW_STA_LINKDOWN_EVENT_FLAG 0x0210
1328#define IW_SCAN_COMPLETED_EVENT_FLAG 0x0211
1329#define IW_SCAN_ENQUEUE_FAIL_EVENT_FLAG 0x0212
1330// if add new system event flag, please upadte the IW_SYS_EVENT_FLAG_END
1331#define IW_SYS_EVENT_FLAG_END 0x0212
1332#define IW_SYS_EVENT_TYPE_NUM (IW_SYS_EVENT_FLAG_END - IW_SYS_EVENT_FLAG_START + 1)
1333// For system event - end
1334
1335// For spoof attack event - start
1336#define IW_SPOOF_EVENT_FLAG_START 0x0300
1337#define IW_CONFLICT_SSID_EVENT_FLAG 0x0300
1338#define IW_SPOOF_ASSOC_RESP_EVENT_FLAG 0x0301
1339#define IW_SPOOF_REASSOC_RESP_EVENT_FLAG 0x0302
1340#define IW_SPOOF_PROBE_RESP_EVENT_FLAG 0x0303
1341#define IW_SPOOF_BEACON_EVENT_FLAG 0x0304
1342#define IW_SPOOF_DISASSOC_EVENT_FLAG 0x0305
1343#define IW_SPOOF_AUTH_EVENT_FLAG 0x0306
1344#define IW_SPOOF_DEAUTH_EVENT_FLAG 0x0307
1345#define IW_SPOOF_UNKNOWN_MGMT_EVENT_FLAG 0x0308
1346#define IW_REPLAY_ATTACK_EVENT_FLAG 0x0309
1347// if add new spoof attack event flag, please upadte the IW_SPOOF_EVENT_FLAG_END
1348#define IW_SPOOF_EVENT_FLAG_END 0x0309
1349#define IW_SPOOF_EVENT_TYPE_NUM (IW_SPOOF_EVENT_FLAG_END - IW_SPOOF_EVENT_FLAG_START + 1)
1350// For spoof attack event - end
1351
1352// For flooding attack event - start
1353#define IW_FLOOD_EVENT_FLAG_START 0x0400
1354#define IW_FLOOD_AUTH_EVENT_FLAG 0x0400
1355#define IW_FLOOD_ASSOC_REQ_EVENT_FLAG 0x0401
1356#define IW_FLOOD_REASSOC_REQ_EVENT_FLAG 0x0402
1357#define IW_FLOOD_PROBE_REQ_EVENT_FLAG 0x0403
1358#define IW_FLOOD_DISASSOC_EVENT_FLAG 0x0404
1359#define IW_FLOOD_DEAUTH_EVENT_FLAG 0x0405
1360#define IW_FLOOD_EAP_REQ_EVENT_FLAG 0x0406
1361// if add new flooding attack event flag, please upadte the IW_FLOOD_EVENT_FLAG_END
1362#define IW_FLOOD_EVENT_FLAG_END 0x0406
1363#define IW_FLOOD_EVENT_TYPE_NUM (IW_FLOOD_EVENT_FLAG_END - IW_FLOOD_EVENT_FLAG_START + 1)
1364// For flooding attack - end
1365
1366// End - WIRELESS EVENTS definition
1367
1368// definition for DLS, kathy
1369#define MAX_NUM_OF_INIT_DLS_ENTRY 1
1370#define MAX_NUM_OF_DLS_ENTRY MAX_NUMBER_OF_DLS_ENTRY
1371
1372//Block ACK , rt2860, kathy
1373#define MAX_TX_REORDERBUF 64
1374#define MAX_RX_REORDERBUF 64
1375#define DEFAULT_TX_TIMEOUT 30
1376#define DEFAULT_RX_TIMEOUT 30
1377#define MAX_BARECI_SESSION 8
1378
1379#ifndef IW_ESSID_MAX_SIZE
1380/* Maximum size of the ESSID and pAd->nickname strings */
1381#define IW_ESSID_MAX_SIZE 32
1382#endif
1383
1384#ifdef MCAST_RATE_SPECIFIC
1385#define MCAST_DISABLE 0
1386#define MCAST_CCK 1
1387#define MCAST_OFDM 2
1388#define MCAST_HTMIX 3
1389#endif // MCAST_RATE_SPECIFIC //
1390
1391// For AsicRadioOff/AsicRadioOn function
1392#define DOT11POWERSAVE 0
1393#define GUIRADIO_OFF 1
1394#define RTMP_HALT 2
1395#define GUI_IDLE_POWER_SAVE 3
1396// --
1397
1398
1399// definition for WpaSupport flag
1400#define WPA_SUPPLICANT_DISABLE 0
1401#define WPA_SUPPLICANT_ENABLE 1
1402#define WPA_SUPPLICANT_ENABLE_WITH_WEB_UI 2
1403
1404// Endian byte swapping codes
1405#define SWAP16(x) \
1406 ((UINT16)( \
1407 (((UINT16)(x) & (UINT16) 0x00ffU) << 8) | \
1408 (((UINT16)(x) & (UINT16) 0xff00U) >> 8) ))
1409
1410#define SWAP32(x) \
1411 ((UINT32)( \
1412 (((UINT32)(x) & (UINT32) 0x000000ffUL) << 24) | \
1413 (((UINT32)(x) & (UINT32) 0x0000ff00UL) << 8) | \
1414 (((UINT32)(x) & (UINT32) 0x00ff0000UL) >> 8) | \
1415 (((UINT32)(x) & (UINT32) 0xff000000UL) >> 24) ))
1416
1417#define SWAP64(x) \
1418 ((UINT64)( \
1419 (UINT64)(((UINT64)(x) & (UINT64) 0x00000000000000ffULL) << 56) | \
1420 (UINT64)(((UINT64)(x) & (UINT64) 0x000000000000ff00ULL) << 40) | \
1421 (UINT64)(((UINT64)(x) & (UINT64) 0x0000000000ff0000ULL) << 24) | \
1422 (UINT64)(((UINT64)(x) & (UINT64) 0x00000000ff000000ULL) << 8) | \
1423 (UINT64)(((UINT64)(x) & (UINT64) 0x000000ff00000000ULL) >> 8) | \
1424 (UINT64)(((UINT64)(x) & (UINT64) 0x0000ff0000000000ULL) >> 24) | \
1425 (UINT64)(((UINT64)(x) & (UINT64) 0x00ff000000000000ULL) >> 40) | \
1426 (UINT64)(((UINT64)(x) & (UINT64) 0xff00000000000000ULL) >> 56) ))
1427
1428#define cpu2le64(x) ((UINT64)(x))
1429#define le2cpu64(x) ((UINT64)(x))
1430#define cpu2le32(x) ((UINT32)(x))
1431#define le2cpu32(x) ((UINT32)(x))
1432#define cpu2le16(x) ((UINT16)(x))
1433#define le2cpu16(x) ((UINT16)(x))
1434#define cpu2be64(x) SWAP64((x))
1435#define be2cpu64(x) SWAP64((x))
1436#define cpu2be32(x) SWAP32((x))
1437#define be2cpu32(x) SWAP32((x))
1438#define cpu2be16(x) SWAP16((x))
1439#define be2cpu16(x) SWAP16((x))
1440
1441#endif // __RTMP_DEF_H__
1442
1443
diff --git a/drivers/staging/rt2870/rtmp_type.h b/drivers/staging/rt2870/rtmp_type.h
index 1fd7df1e1791..fbf97d0fa5d3 100644
--- a/drivers/staging/rt2870/rtmp_type.h
+++ b/drivers/staging/rt2870/rtmp_type.h
@@ -1,94 +1 @@
1/* #include "../rt2860/rtmp_type.h"
2 *************************************************************************
3 * Ralink Tech Inc.
4 * 5F., No.36, Taiyuan St., Jhubei City,
5 * Hsinchu County 302,
6 * Taiwan, R.O.C.
7 *
8 * (c) Copyright 2002-2007, Ralink Technology, Inc.
9 *
10 * This program is free software; you can redistribute it and/or modify *
11 * it under the terms of the GNU General Public License as published by *
12 * the Free Software Foundation; either version 2 of the License, or *
13 * (at your option) any later version. *
14 * *
15 * This program is distributed in the hope that it will be useful, *
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
18 * GNU General Public License for more details. *
19 * *
20 * You should have received a copy of the GNU General Public License *
21 * along with this program; if not, write to the *
22 * Free Software Foundation, Inc., *
23 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
24 * *
25 *************************************************************************
26
27 Module Name:
28 rtmp_type.h
29
30 Abstract:
31
32 Revision History:
33 Who When What
34 -------- ---------- ----------------------------------------------
35 Name Date Modification logs
36 Paul Lin 1-2-2004
37*/
38#ifndef __RTMP_TYPE_H__
39#define __RTMP_TYPE_H__
40
41#define PACKED __attribute__ ((packed))
42
43// Put platform dependent declaration here
44// For example, linux type definition
45typedef unsigned char UINT8;
46typedef unsigned short UINT16;
47typedef unsigned int UINT32;
48typedef unsigned long long UINT64;
49typedef int INT32;
50typedef long long INT64;
51
52typedef unsigned char * PUINT8;
53typedef unsigned short * PUINT16;
54typedef unsigned int * PUINT32;
55typedef unsigned long long * PUINT64;
56typedef int * PINT32;
57typedef long long * PINT64;
58
59typedef signed char CHAR;
60typedef signed short SHORT;
61typedef signed int INT;
62typedef signed long LONG;
63typedef signed long long LONGLONG;
64
65
66typedef unsigned char UCHAR;
67typedef unsigned short USHORT;
68typedef unsigned int UINT;
69typedef unsigned long ULONG;
70typedef unsigned long long ULONGLONG;
71
72typedef unsigned char BOOLEAN;
73typedef void VOID;
74
75typedef VOID * PVOID;
76typedef CHAR * PCHAR;
77typedef UCHAR * PUCHAR;
78typedef USHORT * PUSHORT;
79typedef LONG * PLONG;
80typedef ULONG * PULONG;
81typedef UINT * PUINT;
82
83typedef unsigned int NDIS_MEDIA_STATE;
84
85typedef union _LARGE_INTEGER {
86 struct {
87 UINT LowPart;
88 INT32 HighPart;
89 } u;
90 INT64 QuadPart;
91} LARGE_INTEGER;
92
93#endif // __RTMP_TYPE_H__
94
diff --git a/drivers/staging/rt2870/spectrum.h b/drivers/staging/rt2870/spectrum.h
index 95e0b0ebfe9b..8aa23a1833b1 100644
--- a/drivers/staging/rt2870/spectrum.h
+++ b/drivers/staging/rt2870/spectrum.h
@@ -1,292 +1 @@
1/* #include "../rt2860/spectrum.h"
2 *************************************************************************
3 * Ralink Tech Inc.
4 * 5F., No.36, Taiyuan St., Jhubei City,
5 * Hsinchu County 302,
6 * Taiwan, R.O.C.
7 *
8 * (c) Copyright 2002-2007, Ralink Technology, Inc.
9 *
10 * This program is free software; you can redistribute it and/or modify *
11 * it under the terms of the GNU General Public License as published by *
12 * the Free Software Foundation; either version 2 of the License, or *
13 * (at your option) any later version. *
14 * *
15 * This program is distributed in the hope that it will be useful, *
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
18 * GNU General Public License for more details. *
19 * *
20 * You should have received a copy of the GNU General Public License *
21 * along with this program; if not, write to the *
22 * Free Software Foundation, Inc., *
23 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
24 * *
25 *************************************************************************
26 */
27
28#ifndef __SPECTRUM_H__
29#define __SPECTRUM_H__
30
31#include "rtmp_type.h"
32#include "spectrum_def.h"
33
34typedef struct PACKED _TPC_REPORT_INFO
35{
36 UINT8 TxPwr;
37 UINT8 LinkMargin;
38} TPC_REPORT_INFO, *PTPC_REPORT_INFO;
39
40typedef struct PACKED _CH_SW_ANN_INFO
41{
42 UINT8 ChSwMode;
43 UINT8 Channel;
44 UINT8 ChSwCnt;
45} CH_SW_ANN_INFO, *PCH_SW_ANN_INFO;
46
47typedef union PACKED _MEASURE_REQ_MODE
48{
49 struct PACKED
50 {
51 UINT8 Rev0:1;
52 UINT8 Enable:1;
53 UINT8 Request:1;
54 UINT8 Report:1;
55 UINT8 Rev1:4;
56 } field;
57 UINT8 word;
58} MEASURE_REQ_MODE, *PMEASURE_REQ_MODE;
59
60typedef struct PACKED _MEASURE_REQ
61{
62 UINT8 ChNum;
63 UINT64 MeasureStartTime;
64 UINT16 MeasureDuration;
65} MEASURE_REQ, *PMEASURE_REQ;
66
67typedef struct PACKED _MEASURE_REQ_INFO
68{
69 UINT8 Token;
70 MEASURE_REQ_MODE ReqMode;
71 UINT8 ReqType;
72 MEASURE_REQ MeasureReq;
73} MEASURE_REQ_INFO, *PMEASURE_REQ_INFO;
74
75typedef union PACKED _MEASURE_BASIC_REPORT_MAP
76{
77 struct PACKED
78 {
79 UINT8 BSS:1;
80 UINT8 OfdmPreamble:1;
81 UINT8 UnidentifiedSignal:1;
82 UINT8 Radar:1;
83 UINT8 Unmeasure:1;
84 UINT8 Rev:3;
85 } field;
86 UINT8 word;
87} MEASURE_BASIC_REPORT_MAP, *PMEASURE_BASIC_REPORT_MAP;
88
89typedef struct PACKED _MEASURE_BASIC_REPORT
90{
91 UINT8 ChNum;
92 UINT64 MeasureStartTime;
93 UINT16 MeasureDuration;
94 MEASURE_BASIC_REPORT_MAP Map;
95} MEASURE_BASIC_REPORT, *PMEASURE_BASIC_REPORT;
96
97typedef struct PACKED _MEASURE_CCA_REPORT
98{
99 UINT8 ChNum;
100 UINT64 MeasureStartTime;
101 UINT16 MeasureDuration;
102 UINT8 CCA_Busy_Fraction;
103} MEASURE_CCA_REPORT, *PMEASURE_CCA_REPORT;
104
105typedef struct PACKED _MEASURE_RPI_REPORT
106{
107 UINT8 ChNum;
108 UINT64 MeasureStartTime;
109 UINT16 MeasureDuration;
110 UINT8 RPI_Density[8];
111} MEASURE_RPI_REPORT, *PMEASURE_RPI_REPORT;
112
113typedef union PACKED _MEASURE_REPORT_MODE
114{
115 struct PACKED
116 {
117 UINT8 Late:1;
118 UINT8 Incapable:1;
119 UINT8 Refused:1;
120 UINT8 Rev:5;
121 } field;
122 UINT8 word;
123} MEASURE_REPORT_MODE, *PMEASURE_REPORT_MODE;
124
125typedef struct PACKED _MEASURE_REPORT_INFO
126{
127 UINT8 Token;
128 MEASURE_REPORT_MODE ReportMode;
129 UINT8 ReportType;
130 UINT8 Octect[0];
131} MEASURE_REPORT_INFO, *PMEASURE_REPORT_INFO;
132
133typedef struct PACKED _QUIET_INFO
134{
135 UINT8 QuietCnt;
136 UINT8 QuietPeriod;
137 UINT8 QuietDuration;
138 UINT8 QuietOffset;
139} QUIET_INFO, *PQUIET_INFO;
140
141/*
142 ==========================================================================
143 Description:
144 Prepare Measurement request action frame and enqueue it into
145 management queue waiting for transmition.
146
147 Parametrs:
148 1. the destination mac address of the frame.
149
150 Return : None.
151 ==========================================================================
152 */
153VOID EnqueueMeasurementReq(
154 IN PRTMP_ADAPTER pAd,
155 IN PUCHAR pDA,
156 IN UINT8 MeasureToken,
157 IN UINT8 MeasureReqMode,
158 IN UINT8 MeasureReqType,
159 IN UINT8 MeasureCh,
160 IN UINT16 MeasureDuration);
161
162/*
163 ==========================================================================
164 Description:
165 Prepare Measurement report action frame and enqueue it into
166 management queue waiting for transmition.
167
168 Parametrs:
169 1. the destination mac address of the frame.
170
171 Return : None.
172 ==========================================================================
173 */
174VOID EnqueueMeasurementRep(
175 IN PRTMP_ADAPTER pAd,
176 IN PUCHAR pDA,
177 IN UINT8 DialogToken,
178 IN UINT8 MeasureToken,
179 IN UINT8 MeasureReqMode,
180 IN UINT8 MeasureReqType,
181 IN UINT8 ReportInfoLen,
182 IN PUINT8 pReportInfo);
183
184/*
185 ==========================================================================
186 Description:
187 Prepare TPC Request action frame and enqueue it into
188 management queue waiting for transmition.
189
190 Parametrs:
191 1. the destination mac address of the frame.
192
193 Return : None.
194 ==========================================================================
195 */
196VOID EnqueueTPCReq(
197 IN PRTMP_ADAPTER pAd,
198 IN PUCHAR pDA,
199 IN UCHAR DialogToken);
200
201/*
202 ==========================================================================
203 Description:
204 Prepare TPC Report action frame and enqueue it into
205 management queue waiting for transmition.
206
207 Parametrs:
208 1. the destination mac address of the frame.
209
210 Return : None.
211 ==========================================================================
212 */
213VOID EnqueueTPCRep(
214 IN PRTMP_ADAPTER pAd,
215 IN PUCHAR pDA,
216 IN UINT8 DialogToken,
217 IN UINT8 TxPwr,
218 IN UINT8 LinkMargin);
219
220/*
221 ==========================================================================
222 Description:
223 Prepare Channel Switch Announcement action frame and enqueue it into
224 management queue waiting for transmition.
225
226 Parametrs:
227 1. the destination mac address of the frame.
228 2. Channel switch announcement mode.
229 2. a New selected channel.
230
231 Return : None.
232 ==========================================================================
233 */
234VOID EnqueueChSwAnn(
235 IN PRTMP_ADAPTER pAd,
236 IN PUCHAR pDA,
237 IN UINT8 ChSwMode,
238 IN UINT8 NewCh);
239
240/*
241 ==========================================================================
242 Description:
243 Spectrun action frames Handler such as channel switch annoucement,
244 measurement report, measurement request actions frames.
245
246 Parametrs:
247 Elme - MLME message containing the received frame
248
249 Return : None.
250 ==========================================================================
251 */
252VOID PeerSpectrumAction(
253 IN PRTMP_ADAPTER pAd,
254 IN MLME_QUEUE_ELEM *Elem);
255
256/*
257 ==========================================================================
258 Description:
259
260 Parametrs:
261
262 Return : None.
263 ==========================================================================
264 */
265INT Set_MeasureReq_Proc(
266 IN PRTMP_ADAPTER pAd,
267 IN PUCHAR arg);
268
269INT Set_TpcReq_Proc(
270 IN PRTMP_ADAPTER pAd,
271 IN PUCHAR arg);
272
273VOID MeasureReqTabInit(
274 IN PRTMP_ADAPTER pAd);
275
276VOID MeasureReqTabExit(
277 IN PRTMP_ADAPTER pAd);
278
279VOID TpcReqTabInit(
280 IN PRTMP_ADAPTER pAd);
281
282VOID TpcReqTabExit(
283 IN PRTMP_ADAPTER pAd);
284
285VOID NotifyChSwAnnToPeerAPs(
286 IN PRTMP_ADAPTER pAd,
287 IN PUCHAR pRA,
288 IN PUCHAR pTA,
289 IN UINT8 ChSwMode,
290 IN UINT8 Channel);
291#endif // __SPECTRUM_H__ //
292
diff --git a/drivers/staging/rt2870/spectrum_def.h b/drivers/staging/rt2870/spectrum_def.h
index 4ca4817bba05..a65f551e3918 100644
--- a/drivers/staging/rt2870/spectrum_def.h
+++ b/drivers/staging/rt2870/spectrum_def.h
@@ -1,95 +1 @@
1/* #include "../rt2860/spectrum_def.h"
2 *************************************************************************
3 * Ralink Tech Inc.
4 * 5F., No.36, Taiyuan St., Jhubei City,
5 * Hsinchu County 302,
6 * Taiwan, R.O.C.
7 *
8 * (c) Copyright 2002-2007, Ralink Technology, Inc.
9 *
10 * This program is free software; you can redistribute it and/or modify *
11 * it under the terms of the GNU General Public License as published by *
12 * the Free Software Foundation; either version 2 of the License, or *
13 * (at your option) any later version. *
14 * *
15 * This program is distributed in the hope that it will be useful, *
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
18 * GNU General Public License for more details. *
19 * *
20 * You should have received a copy of the GNU General Public License *
21 * along with this program; if not, write to the *
22 * Free Software Foundation, Inc., *
23 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
24 * *
25 *************************************************************************
26
27 Module Name:
28 spectrum_def.h
29
30 Abstract:
31 Handle association related requests either from WSTA or from local MLME
32
33 Revision History:
34 Who When What
35 --------- ---------- ----------------------------------------------
36 Fonchi Wu 2008 created for 802.11h
37 */
38
39#ifndef __SPECTRUM_DEF_H__
40#define __SPECTRUM_DEF_H__
41
42#define MAX_MEASURE_REQ_TAB_SIZE 3
43#define MAX_HASH_MEASURE_REQ_TAB_SIZE MAX_MEASURE_REQ_TAB_SIZE
44
45#define MAX_TPC_REQ_TAB_SIZE 3
46#define MAX_HASH_TPC_REQ_TAB_SIZE MAX_TPC_REQ_TAB_SIZE
47
48#define MIN_RCV_PWR 100 /* Negative value ((dBm) */
49
50#define RM_TPC_REQ 0
51#define RM_MEASURE_REQ 1
52
53#define RM_BASIC 0
54#define RM_CCA 1
55#define RM_RPI_HISTOGRAM 2
56
57#define TPC_REQ_AGE_OUT 500 /* ms */
58#define MQ_REQ_AGE_OUT 500 /* ms */
59
60#define TPC_DIALOGTOKEN_HASH_INDEX(_DialogToken) ((_DialogToken) % MAX_HASH_TPC_REQ_TAB_SIZE)
61#define MQ_DIALOGTOKEN_HASH_INDEX(_DialogToken) ((_DialogToken) % MAX_MEASURE_REQ_TAB_SIZE)
62
63typedef struct _MEASURE_REQ_ENTRY
64{
65 struct _MEASURE_REQ_ENTRY *pNext;
66 ULONG lastTime;
67 BOOLEAN Valid;
68 UINT8 DialogToken;
69 UINT8 MeasureDialogToken[3]; // 0:basic measure, 1: CCA measure, 2: RPI_Histogram measure.
70} MEASURE_REQ_ENTRY, *PMEASURE_REQ_ENTRY;
71
72typedef struct _MEASURE_REQ_TAB
73{
74 UCHAR Size;
75 PMEASURE_REQ_ENTRY Hash[MAX_HASH_MEASURE_REQ_TAB_SIZE];
76 MEASURE_REQ_ENTRY Content[MAX_MEASURE_REQ_TAB_SIZE];
77} MEASURE_REQ_TAB, *PMEASURE_REQ_TAB;
78
79typedef struct _TPC_REQ_ENTRY
80{
81 struct _TPC_REQ_ENTRY *pNext;
82 ULONG lastTime;
83 BOOLEAN Valid;
84 UINT8 DialogToken;
85} TPC_REQ_ENTRY, *PTPC_REQ_ENTRY;
86
87typedef struct _TPC_REQ_TAB
88{
89 UCHAR Size;
90 PTPC_REQ_ENTRY Hash[MAX_HASH_TPC_REQ_TAB_SIZE];
91 TPC_REQ_ENTRY Content[MAX_TPC_REQ_TAB_SIZE];
92} TPC_REQ_TAB, *PTPC_REQ_TAB;
93
94#endif // __SPECTRUM_DEF_H__ //
95
diff --git a/drivers/staging/rt2870/sta_ioctl.c b/drivers/staging/rt2870/sta_ioctl.c
index 1945a39136c5..3553a6c898b9 100644
--- a/drivers/staging/rt2870/sta_ioctl.c
+++ b/drivers/staging/rt2870/sta_ioctl.c
@@ -1,6861 +1 @@
1/* #include "../rt2860/sta_ioctl.c"
2 *************************************************************************
3 * Ralink Tech Inc.
4 * 5F., No.36, Taiyuan St., Jhubei City,
5 * Hsinchu County 302,
6 * Taiwan, R.O.C.
7 *
8 * (c) Copyright 2002-2007, Ralink Technology, Inc.
9 *
10 * This program is free software; you can redistribute it and/or modify *
11 * it under the terms of the GNU General Public License as published by *
12 * the Free Software Foundation; either version 2 of the License, or *
13 * (at your option) any later version. *
14 * *
15 * This program is distributed in the hope that it will be useful, *
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
18 * GNU General Public License for more details. *
19 * *
20 * You should have received a copy of the GNU General Public License *
21 * along with this program; if not, write to the *
22 * Free Software Foundation, Inc., *
23 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
24 * *
25 *************************************************************************
26
27 Module Name:
28 sta_ioctl.c
29
30 Abstract:
31 IOCTL related subroutines
32
33 Revision History:
34 Who When What
35 -------- ---------- ----------------------------------------------
36 Rory Chen 01-03-2003 created
37 Rory Chen 02-14-2005 modify to support RT61
38*/
39
40#include "rt_config.h"
41
42#ifdef DBG
43extern ULONG RTDebugLevel;
44#endif
45
46#define NR_WEP_KEYS 4
47#define WEP_SMALL_KEY_LEN (40/8)
48#define WEP_LARGE_KEY_LEN (104/8)
49
50#define GROUP_KEY_NO 4
51
52extern UCHAR CipherWpa2Template[];
53extern UCHAR CipherWpaPskTkip[];
54extern UCHAR CipherWpaPskTkipLen;
55
56typedef struct PACKED _RT_VERSION_INFO{
57 UCHAR DriverVersionW;
58 UCHAR DriverVersionX;
59 UCHAR DriverVersionY;
60 UCHAR DriverVersionZ;
61 UINT DriverBuildYear;
62 UINT DriverBuildMonth;
63 UINT DriverBuildDay;
64} RT_VERSION_INFO, *PRT_VERSION_INFO;
65
66struct iw_priv_args privtab[] = {
67{ RTPRIV_IOCTL_SET,
68 IW_PRIV_TYPE_CHAR | 1024, 0,
69 "set"},
70
71{ RTPRIV_IOCTL_SHOW, 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK,
72 ""},
73{ RTPRIV_IOCTL_SHOW, IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK,
74 ""},
75/* --- sub-ioctls definitions --- */
76 { SHOW_CONN_STATUS,
77 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "connStatus" },
78 { SHOW_DRVIER_VERION,
79 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "driverVer" },
80 { SHOW_BA_INFO,
81 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "bainfo" },
82 { SHOW_DESC_INFO,
83 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "descinfo" },
84 { RAIO_OFF,
85 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "radio_off" },
86 { RAIO_ON,
87 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "radio_on" },
88 { SHOW_CFG_VALUE,
89 IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "show" },
90#ifndef RT30xx
91 { SHOW_ADHOC_ENTRY_INFO,
92 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "adhocEntry" },
93#endif
94/* --- sub-ioctls relations --- */
95
96#ifdef DBG
97{ RTPRIV_IOCTL_BBP,
98 IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK,
99 "bbp"},
100{ RTPRIV_IOCTL_MAC,
101 IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | 1024,
102 "mac"},
103#ifdef RT30xx
104{ RTPRIV_IOCTL_RF,
105 IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK,
106 "rf"},
107#endif // RT30xx //
108{ RTPRIV_IOCTL_E2P,
109 IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | 1024,
110 "e2p"},
111#endif /* DBG */
112
113{ RTPRIV_IOCTL_STATISTICS,
114 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK,
115 "stat"},
116{ RTPRIV_IOCTL_GSITESURVEY,
117 0, IW_PRIV_TYPE_CHAR | 1024,
118 "get_site_survey"},
119};
120
121INT Set_SSID_Proc(
122 IN PRTMP_ADAPTER pAdapter,
123 IN PUCHAR arg);
124
125#ifdef WMM_SUPPORT
126INT Set_WmmCapable_Proc(
127 IN PRTMP_ADAPTER pAd,
128 IN PUCHAR arg);
129#endif
130
131INT Set_NetworkType_Proc(
132 IN PRTMP_ADAPTER pAdapter,
133 IN PUCHAR arg);
134
135INT Set_AuthMode_Proc(
136 IN PRTMP_ADAPTER pAdapter,
137 IN PUCHAR arg);
138
139INT Set_EncrypType_Proc(
140 IN PRTMP_ADAPTER pAdapter,
141 IN PUCHAR arg);
142
143INT Set_DefaultKeyID_Proc(
144 IN PRTMP_ADAPTER pAdapter,
145 IN PUCHAR arg);
146
147INT Set_Key1_Proc(
148 IN PRTMP_ADAPTER pAdapter,
149 IN PUCHAR arg);
150
151INT Set_Key2_Proc(
152 IN PRTMP_ADAPTER pAdapter,
153 IN PUCHAR arg);
154
155INT Set_Key3_Proc(
156 IN PRTMP_ADAPTER pAdapter,
157 IN PUCHAR arg);
158
159INT Set_Key4_Proc(
160 IN PRTMP_ADAPTER pAdapter,
161 IN PUCHAR arg);
162
163INT Set_WPAPSK_Proc(
164 IN PRTMP_ADAPTER pAdapter,
165 IN PUCHAR arg);
166
167
168INT Set_PSMode_Proc(
169 IN PRTMP_ADAPTER pAdapter,
170 IN PUCHAR arg);
171
172INT Set_Wpa_Support(
173 IN PRTMP_ADAPTER pAd,
174 IN PUCHAR arg);
175
176#ifdef DBG
177#ifndef RT30xx
178VOID RTMPIoctlBBP(
179 IN PRTMP_ADAPTER pAdapter,
180 IN struct iwreq *wrq);
181#endif
182
183VOID RTMPIoctlMAC(
184 IN PRTMP_ADAPTER pAdapter,
185 IN struct iwreq *wrq);
186
187VOID RTMPIoctlE2PROM(
188 IN PRTMP_ADAPTER pAdapter,
189 IN struct iwreq *wrq);
190
191#ifdef RT30xx
192VOID RTMPIoctlRF(
193 IN PRTMP_ADAPTER pAdapter,
194 IN struct iwreq *wrq);
195#endif // RT30xx //
196#endif // DBG //
197
198
199NDIS_STATUS RTMPWPANoneAddKeyProc(
200 IN PRTMP_ADAPTER pAd,
201 IN PVOID pBuf);
202
203INT Set_FragTest_Proc(
204 IN PRTMP_ADAPTER pAdapter,
205 IN PUCHAR arg);
206
207INT Set_TGnWifiTest_Proc(
208 IN PRTMP_ADAPTER pAd,
209 IN PUCHAR arg);
210
211INT Set_LongRetryLimit_Proc(
212 IN PRTMP_ADAPTER pAdapter,
213 IN PUCHAR arg);
214
215INT Set_ShortRetryLimit_Proc(
216 IN PRTMP_ADAPTER pAdapter,
217 IN PUCHAR arg);
218
219#ifndef RT30xx
220INT Show_Adhoc_MacTable_Proc(
221 IN PRTMP_ADAPTER pAd,
222 IN PCHAR extra);
223#endif
224
225static struct {
226 CHAR *name;
227 INT (*set_proc)(PRTMP_ADAPTER pAdapter, PUCHAR arg);
228} *PRTMP_PRIVATE_SET_PROC, RTMP_PRIVATE_SUPPORT_PROC[] = {
229 {"DriverVersion", Set_DriverVersion_Proc},
230 {"CountryRegion", Set_CountryRegion_Proc},
231 {"CountryRegionABand", Set_CountryRegionABand_Proc},
232 {"SSID", Set_SSID_Proc},
233 {"WirelessMode", Set_WirelessMode_Proc},
234 {"TxBurst", Set_TxBurst_Proc},
235 {"TxPreamble", Set_TxPreamble_Proc},
236 {"TxPower", Set_TxPower_Proc},
237 {"Channel", Set_Channel_Proc},
238 {"BGProtection", Set_BGProtection_Proc},
239 {"RTSThreshold", Set_RTSThreshold_Proc},
240 {"FragThreshold", Set_FragThreshold_Proc},
241 {"HtBw", Set_HtBw_Proc},
242 {"HtMcs", Set_HtMcs_Proc},
243 {"HtGi", Set_HtGi_Proc},
244 {"HtOpMode", Set_HtOpMode_Proc},
245 {"HtExtcha", Set_HtExtcha_Proc},
246 {"HtMpduDensity", Set_HtMpduDensity_Proc},
247 {"HtBaWinSize", Set_HtBaWinSize_Proc},
248 {"HtRdg", Set_HtRdg_Proc},
249 {"HtAmsdu", Set_HtAmsdu_Proc},
250 {"HtAutoBa", Set_HtAutoBa_Proc},
251 {"HtBaDecline", Set_BADecline_Proc},
252 {"HtProtect", Set_HtProtect_Proc},
253 {"HtMimoPs", Set_HtMimoPs_Proc},
254#ifdef AGGREGATION_SUPPORT
255 {"PktAggregate", Set_PktAggregate_Proc},
256#endif
257
258#ifdef WMM_SUPPORT
259 {"WmmCapable", Set_WmmCapable_Proc},
260#endif
261 {"IEEE80211H", Set_IEEE80211H_Proc},
262 {"NetworkType", Set_NetworkType_Proc},
263 {"AuthMode", Set_AuthMode_Proc},
264 {"EncrypType", Set_EncrypType_Proc},
265 {"DefaultKeyID", Set_DefaultKeyID_Proc},
266 {"Key1", Set_Key1_Proc},
267 {"Key2", Set_Key2_Proc},
268 {"Key3", Set_Key3_Proc},
269 {"Key4", Set_Key4_Proc},
270 {"WPAPSK", Set_WPAPSK_Proc},
271 {"ResetCounter", Set_ResetStatCounter_Proc},
272 {"PSMode", Set_PSMode_Proc},
273#ifdef DBG
274 {"Debug", Set_Debug_Proc},
275#endif
276 {"WpaSupport", Set_Wpa_Support},
277 {"FixedTxMode", Set_FixedTxMode_Proc},
278 {"TGnWifiTest", Set_TGnWifiTest_Proc},
279 {"ForceGF", Set_ForceGF_Proc},
280 {"LongRetry", Set_LongRetryLimit_Proc},
281 {"ShortRetry", Set_ShortRetryLimit_Proc},
282//2008/09/11:KH add to support efuse<--
283#ifdef RT30xx
284 {"efuseFreeNumber", set_eFuseGetFreeBlockCount_Proc},
285 {"efuseDump", set_eFusedump_Proc},
286 {"efuseLoadFromBin", set_eFuseLoadFromBin_Proc},
287#endif // RT30xx //
288//2008/09/11:KH add to support efuse-->
289 {NULL,}
290};
291
292
293VOID RTMPAddKey(
294 IN PRTMP_ADAPTER pAd,
295 IN PNDIS_802_11_KEY pKey)
296{
297 ULONG KeyIdx;
298 MAC_TABLE_ENTRY *pEntry;
299
300 DBGPRINT(RT_DEBUG_TRACE, ("RTMPAddKey ------>\n"));
301
302 if (pAd->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
303 {
304 if (pKey->KeyIndex & 0x80000000)
305 {
306 if (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPANone)
307 {
308 NdisZeroMemory(pAd->StaCfg.PMK, 32);
309 NdisMoveMemory(pAd->StaCfg.PMK, pKey->KeyMaterial, pKey->KeyLength);
310 goto end;
311 }
312 // Update PTK
313 NdisZeroMemory(&pAd->SharedKey[BSS0][0], sizeof(CIPHER_KEY));
314 pAd->SharedKey[BSS0][0].KeyLen = LEN_TKIP_EK;
315 NdisMoveMemory(pAd->SharedKey[BSS0][0].Key, pKey->KeyMaterial, LEN_TKIP_EK);
316
317 if (pAd->StaCfg.PairCipher == Ndis802_11Encryption2Enabled)
318 {
319 NdisMoveMemory(pAd->SharedKey[BSS0][0].RxMic, pKey->KeyMaterial + LEN_TKIP_EK, LEN_TKIP_TXMICK);
320 NdisMoveMemory(pAd->SharedKey[BSS0][0].TxMic, pKey->KeyMaterial + LEN_TKIP_EK + LEN_TKIP_TXMICK, LEN_TKIP_RXMICK);
321 }
322 else
323 {
324 NdisMoveMemory(pAd->SharedKey[BSS0][0].TxMic, pKey->KeyMaterial + LEN_TKIP_EK, LEN_TKIP_TXMICK);
325 NdisMoveMemory(pAd->SharedKey[BSS0][0].RxMic, pKey->KeyMaterial + LEN_TKIP_EK + LEN_TKIP_TXMICK, LEN_TKIP_RXMICK);
326 }
327
328 // Decide its ChiperAlg
329 if (pAd->StaCfg.PairCipher == Ndis802_11Encryption2Enabled)
330 pAd->SharedKey[BSS0][0].CipherAlg = CIPHER_TKIP;
331 else if (pAd->StaCfg.PairCipher == Ndis802_11Encryption3Enabled)
332 pAd->SharedKey[BSS0][0].CipherAlg = CIPHER_AES;
333 else
334 pAd->SharedKey[BSS0][0].CipherAlg = CIPHER_NONE;
335
336 // Update these related information to MAC_TABLE_ENTRY
337 pEntry = &pAd->MacTab.Content[BSSID_WCID];
338 NdisMoveMemory(pEntry->PairwiseKey.Key, pAd->SharedKey[BSS0][0].Key, LEN_TKIP_EK);
339 NdisMoveMemory(pEntry->PairwiseKey.RxMic, pAd->SharedKey[BSS0][0].RxMic, LEN_TKIP_RXMICK);
340 NdisMoveMemory(pEntry->PairwiseKey.TxMic, pAd->SharedKey[BSS0][0].TxMic, LEN_TKIP_TXMICK);
341 pEntry->PairwiseKey.CipherAlg = pAd->SharedKey[BSS0][0].CipherAlg;
342
343 // Update pairwise key information to ASIC Shared Key Table
344 AsicAddSharedKeyEntry(pAd,
345 BSS0,
346 0,
347 pAd->SharedKey[BSS0][0].CipherAlg,
348 pAd->SharedKey[BSS0][0].Key,
349 pAd->SharedKey[BSS0][0].TxMic,
350 pAd->SharedKey[BSS0][0].RxMic);
351
352 // Update ASIC WCID attribute table and IVEIV table
353 RTMPAddWcidAttributeEntry(pAd,
354 BSS0,
355 0,
356 pAd->SharedKey[BSS0][0].CipherAlg,
357 pEntry);
358
359 if (pAd->StaCfg.AuthMode >= Ndis802_11AuthModeWPA2)
360 {
361 // set 802.1x port control
362 STA_PORT_SECURED(pAd);
363
364 // Indicate Connected for GUI
365 pAd->IndicateMediaState = NdisMediaStateConnected;
366 }
367 }
368 else
369 {
370 // Update GTK
371 pAd->StaCfg.DefaultKeyId = (pKey->KeyIndex & 0xFF);
372 NdisZeroMemory(&pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId], sizeof(CIPHER_KEY));
373 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].KeyLen = LEN_TKIP_EK;
374 NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].Key, pKey->KeyMaterial, LEN_TKIP_EK);
375
376 if (pAd->StaCfg.GroupCipher == Ndis802_11Encryption2Enabled)
377 {
378 NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].RxMic, pKey->KeyMaterial + LEN_TKIP_EK, LEN_TKIP_TXMICK);
379 NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].TxMic, pKey->KeyMaterial + LEN_TKIP_EK + LEN_TKIP_TXMICK, LEN_TKIP_RXMICK);
380 }
381 else
382 {
383 NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].TxMic, pKey->KeyMaterial + LEN_TKIP_EK, LEN_TKIP_TXMICK);
384 NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].RxMic, pKey->KeyMaterial + LEN_TKIP_EK + LEN_TKIP_TXMICK, LEN_TKIP_RXMICK);
385 }
386
387 // Update Shared Key CipherAlg
388 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg = CIPHER_NONE;
389 if (pAd->StaCfg.GroupCipher == Ndis802_11Encryption2Enabled)
390 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg = CIPHER_TKIP;
391 else if (pAd->StaCfg.GroupCipher == Ndis802_11Encryption3Enabled)
392 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg = CIPHER_AES;
393
394 // Update group key information to ASIC Shared Key Table
395 AsicAddSharedKeyEntry(pAd,
396 BSS0,
397 pAd->StaCfg.DefaultKeyId,
398 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg,
399 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].Key,
400 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].TxMic,
401 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].RxMic);
402
403 // Update ASIC WCID attribute table and IVEIV table
404 RTMPAddWcidAttributeEntry(pAd,
405 BSS0,
406 pAd->StaCfg.DefaultKeyId,
407 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg,
408 NULL);
409
410 // set 802.1x port control
411 STA_PORT_SECURED(pAd);
412
413 // Indicate Connected for GUI
414 pAd->IndicateMediaState = NdisMediaStateConnected;
415 }
416 }
417 else // dynamic WEP from wpa_supplicant
418 {
419 UCHAR CipherAlg;
420 PUCHAR Key;
421
422 if(pKey->KeyLength == 32)
423 goto end;
424
425 KeyIdx = pKey->KeyIndex & 0x0fffffff;
426
427 if (KeyIdx < 4)
428 {
429 // it is a default shared key, for Pairwise key setting
430 if (pKey->KeyIndex & 0x80000000)
431 {
432 pEntry = MacTableLookup(pAd, pKey->BSSID);
433
434 if (pEntry)
435 {
436 DBGPRINT(RT_DEBUG_TRACE, ("RTMPAddKey: Set Pair-wise Key\n"));
437
438 // set key material and key length
439 pEntry->PairwiseKey.KeyLen = (UCHAR)pKey->KeyLength;
440 NdisMoveMemory(pEntry->PairwiseKey.Key, &pKey->KeyMaterial, pKey->KeyLength);
441
442 // set Cipher type
443 if (pKey->KeyLength == 5)
444 pEntry->PairwiseKey.CipherAlg = CIPHER_WEP64;
445 else
446 pEntry->PairwiseKey.CipherAlg = CIPHER_WEP128;
447
448 // Add Pair-wise key to Asic
449 AsicAddPairwiseKeyEntry(
450 pAd,
451 pEntry->Addr,
452 (UCHAR)pEntry->Aid,
453 &pEntry->PairwiseKey);
454
455 // update WCID attribute table and IVEIV table for this entry
456 RTMPAddWcidAttributeEntry(
457 pAd,
458 BSS0,
459 KeyIdx, // The value may be not zero
460 pEntry->PairwiseKey.CipherAlg,
461 pEntry);
462
463 }
464 }
465 else
466 {
467 // Default key for tx (shared key)
468 pAd->StaCfg.DefaultKeyId = (UCHAR) KeyIdx;
469
470 // set key material and key length
471 pAd->SharedKey[BSS0][KeyIdx].KeyLen = (UCHAR) pKey->KeyLength;
472 NdisMoveMemory(pAd->SharedKey[BSS0][KeyIdx].Key, &pKey->KeyMaterial, pKey->KeyLength);
473
474 // Set Ciper type
475 if (pKey->KeyLength == 5)
476 pAd->SharedKey[BSS0][KeyIdx].CipherAlg = CIPHER_WEP64;
477 else
478 pAd->SharedKey[BSS0][KeyIdx].CipherAlg = CIPHER_WEP128;
479
480 CipherAlg = pAd->SharedKey[BSS0][KeyIdx].CipherAlg;
481 Key = pAd->SharedKey[BSS0][KeyIdx].Key;
482
483 // Set Group key material to Asic
484 AsicAddSharedKeyEntry(pAd, BSS0, KeyIdx, CipherAlg, Key, NULL, NULL);
485
486 // Update WCID attribute table and IVEIV table for this group key table
487 RTMPAddWcidAttributeEntry(pAd, BSS0, KeyIdx, CipherAlg, NULL);
488
489 }
490 }
491 }
492end:
493 return;
494}
495
496char * rtstrchr(const char * s, int c)
497{
498 for(; *s != (char) c; ++s)
499 if (*s == '\0')
500 return NULL;
501 return (char *) s;
502}
503
504/*
505This is required for LinEX2004/kernel2.6.7 to provide iwlist scanning function
506*/
507
508int
509rt_ioctl_giwname(struct net_device *dev,
510 struct iw_request_info *info,
511 char *name, char *extra)
512{
513// PRTMP_ADAPTER pAdapter = dev->ml_priv;
514
515#ifdef RT2870
516 strncpy(name, "RT2870 Wireless", IFNAMSIZ);
517#endif // RT2870 //
518 return 0;
519}
520
521int rt_ioctl_siwfreq(struct net_device *dev,
522 struct iw_request_info *info,
523 struct iw_freq *freq, char *extra)
524{
525 PRTMP_ADAPTER pAdapter = dev->ml_priv;
526 int chan = -1;
527
528 //check if the interface is down
529 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
530 {
531 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
532 return -ENETDOWN;
533 }
534
535
536 if (freq->e > 1)
537 return -EINVAL;
538
539 if((freq->e == 0) && (freq->m <= 1000))
540 chan = freq->m; // Setting by channel number
541 else
542 MAP_KHZ_TO_CHANNEL_ID( (freq->m /100) , chan); // Setting by frequency - search the table , like 2.412G, 2.422G,
543
544 if (ChannelSanity(pAdapter, chan) == TRUE)
545 {
546 pAdapter->CommonCfg.Channel = chan;
547 DBGPRINT(RT_DEBUG_ERROR, ("==>rt_ioctl_siwfreq::SIOCSIWFREQ[cmd=0x%x] (Channel=%d)\n", SIOCSIWFREQ, pAdapter->CommonCfg.Channel));
548 }
549 else
550 return -EINVAL;
551
552 return 0;
553}
554int rt_ioctl_giwfreq(struct net_device *dev,
555 struct iw_request_info *info,
556 struct iw_freq *freq, char *extra)
557{
558 VIRTUAL_ADAPTER *pVirtualAd = NULL;
559#ifndef RT30xx
560 PRTMP_ADAPTER pAdapter = NULL;
561#endif
562#ifdef RT30xx
563 PRTMP_ADAPTER pAdapter;
564#endif
565 UCHAR ch;
566 ULONG m;
567
568 if (dev->priv_flags == INT_MAIN)
569 {
570 pAdapter = dev->ml_priv;
571 }
572 else
573 {
574 pVirtualAd = dev->ml_priv;
575#ifndef RT30xx
576 if (pVirtualAd && pVirtualAd->RtmpDev)
577#endif
578 pAdapter = pVirtualAd->RtmpDev->ml_priv;
579 }
580
581 if (pAdapter == NULL)
582 {
583 /* if 1st open fail, pAd will be free;
584 So the net_dev->ml_priv will be NULL in 2rd open */
585 return -ENETDOWN;
586 }
587
588 ch = pAdapter->CommonCfg.Channel;
589
590 DBGPRINT(RT_DEBUG_TRACE,("==>rt_ioctl_giwfreq %d\n", ch));
591
592 MAP_CHANNEL_ID_TO_KHZ(ch, m);
593 freq->m = m * 100;
594 freq->e = 1;
595 return 0;
596}
597
598int rt_ioctl_siwmode(struct net_device *dev,
599 struct iw_request_info *info,
600 __u32 *mode, char *extra)
601{
602 PRTMP_ADAPTER pAdapter = dev->ml_priv;
603
604 //check if the interface is down
605 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
606 {
607 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
608 return -ENETDOWN;
609 }
610
611 switch (*mode)
612 {
613 case IW_MODE_ADHOC:
614 Set_NetworkType_Proc(pAdapter, "Adhoc");
615 break;
616 case IW_MODE_INFRA:
617 Set_NetworkType_Proc(pAdapter, "Infra");
618 break;
619 case IW_MODE_MONITOR:
620 Set_NetworkType_Proc(pAdapter, "Monitor");
621 break;
622 default:
623 DBGPRINT(RT_DEBUG_TRACE, ("===>rt_ioctl_siwmode::SIOCSIWMODE (unknown %d)\n", *mode));
624 return -EINVAL;
625 }
626
627 // Reset Ralink supplicant to not use, it will be set to start when UI set PMK key
628 pAdapter->StaCfg.WpaState = SS_NOTUSE;
629
630 return 0;
631}
632
633int rt_ioctl_giwmode(struct net_device *dev,
634 struct iw_request_info *info,
635 __u32 *mode, char *extra)
636{
637#ifndef RT30xx
638 PRTMP_ADAPTER pAdapter = NULL;
639 VIRTUAL_ADAPTER *pVirtualAd = NULL;
640
641 if (dev->priv_flags == INT_MAIN)
642 {
643 pAdapter = dev->ml_priv;
644 }
645 else
646 {
647 pVirtualAd = dev->ml_priv;
648 if (pVirtualAd && pVirtualAd->RtmpDev)
649 pAdapter = pVirtualAd->RtmpDev->ml_priv;
650 }
651
652 if (pAdapter == NULL)
653 {
654 /* if 1st open fail, pAd will be free;
655 So the net_dev->ml_priv will be NULL in 2rd open */
656 return -ENETDOWN;
657 }
658#endif
659#ifdef RT30xx
660 PRTMP_ADAPTER pAdapter = dev->ml_priv;
661#endif
662
663 if (ADHOC_ON(pAdapter))
664 *mode = IW_MODE_ADHOC;
665 else if (INFRA_ON(pAdapter))
666 *mode = IW_MODE_INFRA;
667 else if (MONITOR_ON(pAdapter))
668 {
669 *mode = IW_MODE_MONITOR;
670 }
671 else
672 *mode = IW_MODE_AUTO;
673
674 DBGPRINT(RT_DEBUG_TRACE, ("==>rt_ioctl_giwmode(mode=%d)\n", *mode));
675 return 0;
676}
677
678int rt_ioctl_siwsens(struct net_device *dev,
679 struct iw_request_info *info,
680 char *name, char *extra)
681{
682 PRTMP_ADAPTER pAdapter = dev->ml_priv;
683
684 //check if the interface is down
685 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
686 {
687 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
688 return -ENETDOWN;
689 }
690
691 return 0;
692}
693
694int rt_ioctl_giwsens(struct net_device *dev,
695 struct iw_request_info *info,
696 char *name, char *extra)
697{
698 return 0;
699}
700
701int rt_ioctl_giwrange(struct net_device *dev,
702 struct iw_request_info *info,
703 struct iw_point *data, char *extra)
704{
705#ifndef RT30xx
706 PRTMP_ADAPTER pAdapter = NULL;
707 VIRTUAL_ADAPTER *pVirtualAd = NULL;
708#endif
709#ifdef RT30xx
710 PRTMP_ADAPTER pAdapter = dev->ml_priv;
711#endif
712 struct iw_range *range = (struct iw_range *) extra;
713 u16 val;
714 int i;
715
716#ifndef RT30xx
717 if (dev->priv_flags == INT_MAIN)
718 {
719 pAdapter = dev->ml_priv;
720 }
721 else
722 {
723 pVirtualAd = dev->ml_priv;
724 if (pVirtualAd && pVirtualAd->RtmpDev)
725 pAdapter = pVirtualAd->RtmpDev->ml_priv;
726 }
727
728 if (pAdapter == NULL)
729 {
730 /* if 1st open fail, pAd will be free;
731 So the net_dev->ml_priv will be NULL in 2rd open */
732 return -ENETDOWN;
733 }
734#endif
735
736 DBGPRINT(RT_DEBUG_TRACE ,("===>rt_ioctl_giwrange\n"));
737 data->length = sizeof(struct iw_range);
738 memset(range, 0, sizeof(struct iw_range));
739
740 range->txpower_capa = IW_TXPOW_DBM;
741
742 if (INFRA_ON(pAdapter)||ADHOC_ON(pAdapter))
743 {
744 range->min_pmp = 1 * 1024;
745 range->max_pmp = 65535 * 1024;
746 range->min_pmt = 1 * 1024;
747 range->max_pmt = 1000 * 1024;
748 range->pmp_flags = IW_POWER_PERIOD;
749 range->pmt_flags = IW_POWER_TIMEOUT;
750 range->pm_capa = IW_POWER_PERIOD | IW_POWER_TIMEOUT |
751 IW_POWER_UNICAST_R | IW_POWER_ALL_R;
752 }
753
754 range->we_version_compiled = WIRELESS_EXT;
755 range->we_version_source = 14;
756
757 range->retry_capa = IW_RETRY_LIMIT;
758 range->retry_flags = IW_RETRY_LIMIT;
759 range->min_retry = 0;
760 range->max_retry = 255;
761
762 range->num_channels = pAdapter->ChannelListNum;
763
764 val = 0;
765 for (i = 1; i <= range->num_channels; i++)
766 {
767 u32 m;
768 range->freq[val].i = pAdapter->ChannelList[i-1].Channel;
769 MAP_CHANNEL_ID_TO_KHZ(pAdapter->ChannelList[i-1].Channel, m);
770 range->freq[val].m = m * 100; /* HZ */
771
772 range->freq[val].e = 1;
773 val++;
774 if (val == IW_MAX_FREQUENCIES)
775 break;
776 }
777 range->num_frequency = val;
778
779 range->max_qual.qual = 100; /* what is correct max? This was not
780 * documented exactly. At least
781 * 69 has been observed. */
782 range->max_qual.level = 0; /* dB */
783 range->max_qual.noise = 0; /* dB */
784
785 /* What would be suitable values for "average/typical" qual? */
786 range->avg_qual.qual = 20;
787 range->avg_qual.level = -60;
788 range->avg_qual.noise = -95;
789 range->sensitivity = 3;
790
791 range->max_encoding_tokens = NR_WEP_KEYS;
792 range->num_encoding_sizes = 2;
793 range->encoding_size[0] = 5;
794 range->encoding_size[1] = 13;
795
796 range->min_rts = 0;
797 range->max_rts = 2347;
798 range->min_frag = 256;
799 range->max_frag = 2346;
800
801#if WIRELESS_EXT > 17
802 /* IW_ENC_CAPA_* bit field */
803 range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 |
804 IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP;
805#endif
806
807 return 0;
808}
809
810int rt_ioctl_siwap(struct net_device *dev,
811 struct iw_request_info *info,
812 struct sockaddr *ap_addr, char *extra)
813{
814 PRTMP_ADAPTER pAdapter = dev->ml_priv;
815 NDIS_802_11_MAC_ADDRESS Bssid;
816
817 //check if the interface is down
818 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
819 {
820 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
821 return -ENETDOWN;
822 }
823
824 if (pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE)
825 {
826 RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
827 DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
828 }
829
830 // tell CNTL state machine to call NdisMSetInformationComplete() after completing
831 // this request, because this request is initiated by NDIS.
832 pAdapter->MlmeAux.CurrReqIsFromNdis = FALSE;
833 // Prevent to connect AP again in STAMlmePeriodicExec
834 pAdapter->MlmeAux.AutoReconnectSsidLen= 32;
835
836 memset(Bssid, 0, MAC_ADDR_LEN);
837 memcpy(Bssid, ap_addr->sa_data, MAC_ADDR_LEN);
838 MlmeEnqueue(pAdapter,
839 MLME_CNTL_STATE_MACHINE,
840 OID_802_11_BSSID,
841 sizeof(NDIS_802_11_MAC_ADDRESS),
842 (VOID *)&Bssid);
843
844 DBGPRINT(RT_DEBUG_TRACE, ("IOCTL::SIOCSIWAP %02x:%02x:%02x:%02x:%02x:%02x\n",
845 Bssid[0], Bssid[1], Bssid[2], Bssid[3], Bssid[4], Bssid[5]));
846
847 return 0;
848}
849
850int rt_ioctl_giwap(struct net_device *dev,
851 struct iw_request_info *info,
852 struct sockaddr *ap_addr, char *extra)
853{
854#ifndef RT30xx
855 PRTMP_ADAPTER pAdapter = NULL;
856 VIRTUAL_ADAPTER *pVirtualAd = NULL;
857
858 if (dev->priv_flags == INT_MAIN)
859 {
860 pAdapter = dev->ml_priv;
861 }
862 else
863 {
864 pVirtualAd = dev->ml_priv;
865 if (pVirtualAd && pVirtualAd->RtmpDev)
866 pAdapter = pVirtualAd->RtmpDev->ml_priv;
867 }
868
869 if (pAdapter == NULL)
870 {
871 /* if 1st open fail, pAd will be free;
872 So the net_dev->ml_priv will be NULL in 2rd open */
873 return -ENETDOWN;
874 }
875#endif
876#ifdef RT30xx
877 PRTMP_ADAPTER pAdapter = dev->ml_priv;
878#endif
879
880 if (INFRA_ON(pAdapter) || ADHOC_ON(pAdapter))
881 {
882 ap_addr->sa_family = ARPHRD_ETHER;
883 memcpy(ap_addr->sa_data, &pAdapter->CommonCfg.Bssid, ETH_ALEN);
884 }
885 // Add for RT2870
886 else if (pAdapter->StaCfg.WpaSupplicantUP != WPA_SUPPLICANT_DISABLE)
887 {
888 ap_addr->sa_family = ARPHRD_ETHER;
889 memcpy(ap_addr->sa_data, &pAdapter->MlmeAux.Bssid, ETH_ALEN);
890 }
891 else
892 {
893 DBGPRINT(RT_DEBUG_TRACE, ("IOCTL::SIOCGIWAP(=EMPTY)\n"));
894 return -ENOTCONN;
895 }
896
897 return 0;
898}
899
900/*
901 * Units are in db above the noise floor. That means the
902 * rssi values reported in the tx/rx descriptors in the
903 * driver are the SNR expressed in db.
904 *
905 * If you assume that the noise floor is -95, which is an
906 * excellent assumption 99.5 % of the time, then you can
907 * derive the absolute signal level (i.e. -95 + rssi).
908 * There are some other slight factors to take into account
909 * depending on whether the rssi measurement is from 11b,
910 * 11g, or 11a. These differences are at most 2db and
911 * can be documented.
912 *
913 * NB: various calculations are based on the orinoco/wavelan
914 * drivers for compatibility
915 */
916static void set_quality(PRTMP_ADAPTER pAdapter,
917 struct iw_quality *iq,
918 signed char rssi)
919{
920 __u8 ChannelQuality;
921
922 // Normalize Rssi
923 if (rssi >= -50)
924 ChannelQuality = 100;
925 else if (rssi >= -80) // between -50 ~ -80dbm
926 ChannelQuality = (__u8)(24 + ((rssi + 80) * 26)/10);
927 else if (rssi >= -90) // between -80 ~ -90dbm
928 ChannelQuality = (__u8)((rssi + 90) * 26)/10;
929 else
930 ChannelQuality = 0;
931
932 iq->qual = (__u8)ChannelQuality;
933
934 iq->level = (__u8)(rssi);
935 iq->noise = (pAdapter->BbpWriteLatch[66] > pAdapter->BbpTuning.FalseCcaUpperThreshold) ? ((__u8)pAdapter->BbpTuning.FalseCcaUpperThreshold) : ((__u8) pAdapter->BbpWriteLatch[66]); // noise level (dBm)
936 iq->noise += 256 - 143;
937 iq->updated = pAdapter->iw_stats.qual.updated;
938}
939
940int rt_ioctl_iwaplist(struct net_device *dev,
941 struct iw_request_info *info,
942 struct iw_point *data, char *extra)
943{
944 PRTMP_ADAPTER pAdapter = dev->ml_priv;
945
946 struct sockaddr addr[IW_MAX_AP];
947 struct iw_quality qual[IW_MAX_AP];
948 int i;
949
950 //check if the interface is down
951 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
952 {
953 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
954 data->length = 0;
955 return 0;
956 //return -ENETDOWN;
957 }
958
959 for (i = 0; i <IW_MAX_AP ; i++)
960 {
961 if (i >= pAdapter->ScanTab.BssNr)
962 break;
963 addr[i].sa_family = ARPHRD_ETHER;
964 memcpy(addr[i].sa_data, &pAdapter->ScanTab.BssEntry[i].Bssid, MAC_ADDR_LEN);
965 set_quality(pAdapter, &qual[i], pAdapter->ScanTab.BssEntry[i].Rssi);
966 }
967 data->length = i;
968 memcpy(extra, &addr, i*sizeof(addr[0]));
969 data->flags = 1; /* signal quality present (sort of) */
970 memcpy(extra + i*sizeof(addr[0]), &qual, i*sizeof(qual[i]));
971
972 return 0;
973}
974
975#ifdef SIOCGIWSCAN
976int rt_ioctl_siwscan(struct net_device *dev,
977 struct iw_request_info *info,
978 struct iw_point *data, char *extra)
979{
980 PRTMP_ADAPTER pAdapter = dev->ml_priv;
981
982 ULONG Now;
983 int Status = NDIS_STATUS_SUCCESS;
984
985 //check if the interface is down
986 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
987 {
988 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
989 return -ENETDOWN;
990 }
991
992 if (MONITOR_ON(pAdapter))
993 {
994 DBGPRINT(RT_DEBUG_TRACE, ("!!! Driver is in Monitor Mode now !!!\n"));
995 return -EINVAL;
996 }
997
998
999 if (pAdapter->StaCfg.WpaSupplicantUP == WPA_SUPPLICANT_ENABLE)
1000 {
1001 pAdapter->StaCfg.WpaSupplicantScanCount++;
1002 }
1003
1004 pAdapter->StaCfg.bScanReqIsFromWebUI = TRUE;
1005 if (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
1006 return 0;
1007 do{
1008 Now = jiffies;
1009
1010 if ((pAdapter->StaCfg.WpaSupplicantUP == WPA_SUPPLICANT_ENABLE) &&
1011 (pAdapter->StaCfg.WpaSupplicantScanCount > 3))
1012 {
1013 DBGPRINT(RT_DEBUG_TRACE, ("!!! WpaSupplicantScanCount > 3\n"));
1014 Status = NDIS_STATUS_SUCCESS;
1015 break;
1016 }
1017
1018 if ((OPSTATUS_TEST_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED)) &&
1019 ((pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA) ||
1020 (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK)) &&
1021 (pAdapter->StaCfg.PortSecured == WPA_802_1X_PORT_NOT_SECURED))
1022 {
1023 DBGPRINT(RT_DEBUG_TRACE, ("!!! Link UP, Port Not Secured! ignore this set::OID_802_11_BSSID_LIST_SCAN\n"));
1024 Status = NDIS_STATUS_SUCCESS;
1025 break;
1026 }
1027
1028 if (pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE)
1029 {
1030 RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
1031 DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
1032 }
1033
1034 // tell CNTL state machine to call NdisMSetInformationComplete() after completing
1035 // this request, because this request is initiated by NDIS.
1036 pAdapter->MlmeAux.CurrReqIsFromNdis = FALSE;
1037 // Reset allowed scan retries
1038 pAdapter->StaCfg.ScanCnt = 0;
1039 pAdapter->StaCfg.LastScanTime = Now;
1040
1041 MlmeEnqueue(pAdapter,
1042 MLME_CNTL_STATE_MACHINE,
1043 OID_802_11_BSSID_LIST_SCAN,
1044 0,
1045 NULL);
1046
1047 Status = NDIS_STATUS_SUCCESS;
1048 RT28XX_MLME_HANDLER(pAdapter);
1049 }while(0);
1050 return 0;
1051}
1052
1053int rt_ioctl_giwscan(struct net_device *dev,
1054 struct iw_request_info *info,
1055 struct iw_point *data, char *extra)
1056{
1057
1058 PRTMP_ADAPTER pAdapter = dev->ml_priv;
1059 int i=0;
1060 char *current_ev = extra, *previous_ev = extra;
1061 char *end_buf;
1062 char *current_val, custom[MAX_CUSTOM_LEN] = {0};
1063#ifndef IWEVGENIE
1064 char idx;
1065#endif // IWEVGENIE //
1066 struct iw_event iwe;
1067
1068 if (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
1069 {
1070 /*
1071 * Still scanning, indicate the caller should try again.
1072 */
1073 return -EAGAIN;
1074 }
1075
1076 if (pAdapter->StaCfg.WpaSupplicantUP == WPA_SUPPLICANT_ENABLE)
1077 {
1078 pAdapter->StaCfg.WpaSupplicantScanCount = 0;
1079 }
1080
1081 if (pAdapter->ScanTab.BssNr == 0)
1082 {
1083 data->length = 0;
1084 return 0;
1085 }
1086
1087#if WIRELESS_EXT >= 17
1088 if (data->length > 0)
1089 end_buf = extra + data->length;
1090 else
1091 end_buf = extra + IW_SCAN_MAX_DATA;
1092#else
1093 end_buf = extra + IW_SCAN_MAX_DATA;
1094#endif
1095
1096 for (i = 0; i < pAdapter->ScanTab.BssNr; i++)
1097 {
1098 if (current_ev >= end_buf)
1099 {
1100#if WIRELESS_EXT >= 17
1101 return -E2BIG;
1102#else
1103 break;
1104#endif
1105 }
1106
1107 //MAC address
1108 //================================
1109 memset(&iwe, 0, sizeof(iwe));
1110 iwe.cmd = SIOCGIWAP;
1111 iwe.u.ap_addr.sa_family = ARPHRD_ETHER;
1112 memcpy(iwe.u.ap_addr.sa_data, &pAdapter->ScanTab.BssEntry[i].Bssid, ETH_ALEN);
1113
1114 previous_ev = current_ev;
1115 current_ev = iwe_stream_add_event(info, current_ev,end_buf, &iwe, IW_EV_ADDR_LEN);
1116#ifdef RT30xx
1117 if (current_ev == previous_ev)
1118#if WIRELESS_EXT >= 17
1119 return -E2BIG;
1120#else
1121 break;
1122#endif
1123
1124 /*
1125 Protocol:
1126 it will show scanned AP's WirelessMode .
1127 it might be
1128 802.11a
1129 802.11a/n
1130 802.11g/n
1131 802.11b/g/n
1132 802.11g
1133 802.11b/g
1134 */
1135 memset(&iwe, 0, sizeof(iwe));
1136 iwe.cmd = SIOCGIWNAME;
1137
1138
1139 {
1140 PBSS_ENTRY pBssEntry=&pAdapter->ScanTab.BssEntry[i];
1141 BOOLEAN isGonly=FALSE;
1142 int rateCnt=0;
1143
1144 if (pBssEntry->Channel>14)
1145 {
1146 if (pBssEntry->HtCapabilityLen!=0)
1147 strcpy(iwe.u.name,"802.11a/n");
1148 else
1149 strcpy(iwe.u.name,"802.11a");
1150 }
1151 else
1152 {
1153 /*
1154 if one of non B mode rate is set supported rate . it mean G only.
1155 */
1156 for (rateCnt=0;rateCnt<pBssEntry->SupRateLen;rateCnt++)
1157 {
1158 /*
1159 6Mbps(140) 9Mbps(146) and >=12Mbps(152) are supported rate , it mean G only.
1160 */
1161 if (pBssEntry->SupRate[rateCnt]==140 || pBssEntry->SupRate[rateCnt]==146 || pBssEntry->SupRate[rateCnt]>=152)
1162 isGonly=TRUE;
1163 }
1164
1165 for (rateCnt=0;rateCnt<pBssEntry->ExtRateLen;rateCnt++)
1166 {
1167 if (pBssEntry->ExtRate[rateCnt]==140 || pBssEntry->ExtRate[rateCnt]==146 || pBssEntry->ExtRate[rateCnt]>=152)
1168 isGonly=TRUE;
1169 }
1170
1171
1172 if (pBssEntry->HtCapabilityLen!=0)
1173 {
1174 if (isGonly==TRUE)
1175 strcpy(iwe.u.name,"802.11g/n");
1176 else
1177 strcpy(iwe.u.name,"802.11b/g/n");
1178 }
1179 else
1180 {
1181 if (isGonly==TRUE)
1182 strcpy(iwe.u.name,"802.11g");
1183 else
1184 {
1185 if (pBssEntry->SupRateLen==4 && pBssEntry->ExtRateLen==0)
1186 strcpy(iwe.u.name,"802.11b");
1187 else
1188 strcpy(iwe.u.name,"802.11b/g");
1189 }
1190 }
1191 }
1192 }
1193
1194 previous_ev = current_ev;
1195 current_ev = iwe_stream_add_event(info, current_ev, end_buf, &iwe, IW_EV_ADDR_LEN);
1196#endif /* RT30xx */
1197 if (current_ev == previous_ev)
1198#if WIRELESS_EXT >= 17
1199 return -E2BIG;
1200#else
1201 break;
1202#endif
1203
1204 //ESSID
1205 //================================
1206 memset(&iwe, 0, sizeof(iwe));
1207 iwe.cmd = SIOCGIWESSID;
1208 iwe.u.data.length = pAdapter->ScanTab.BssEntry[i].SsidLen;
1209 iwe.u.data.flags = 1;
1210
1211 previous_ev = current_ev;
1212 current_ev = iwe_stream_add_point(info, current_ev,end_buf, &iwe, pAdapter->ScanTab.BssEntry[i].Ssid);
1213 if (current_ev == previous_ev)
1214#if WIRELESS_EXT >= 17
1215 return -E2BIG;
1216#else
1217 break;
1218#endif
1219
1220 //Network Type
1221 //================================
1222 memset(&iwe, 0, sizeof(iwe));
1223 iwe.cmd = SIOCGIWMODE;
1224 if (pAdapter->ScanTab.BssEntry[i].BssType == Ndis802_11IBSS)
1225 {
1226 iwe.u.mode = IW_MODE_ADHOC;
1227 }
1228 else if (pAdapter->ScanTab.BssEntry[i].BssType == Ndis802_11Infrastructure)
1229 {
1230 iwe.u.mode = IW_MODE_INFRA;
1231 }
1232 else
1233 {
1234 iwe.u.mode = IW_MODE_AUTO;
1235 }
1236 iwe.len = IW_EV_UINT_LEN;
1237
1238 previous_ev = current_ev;
1239 current_ev = iwe_stream_add_event(info, current_ev, end_buf, &iwe, IW_EV_UINT_LEN);
1240 if (current_ev == previous_ev)
1241#if WIRELESS_EXT >= 17
1242 return -E2BIG;
1243#else
1244 break;
1245#endif
1246
1247 //Channel and Frequency
1248 //================================
1249 memset(&iwe, 0, sizeof(iwe));
1250 iwe.cmd = SIOCGIWFREQ;
1251 if (INFRA_ON(pAdapter) || ADHOC_ON(pAdapter))
1252 iwe.u.freq.m = pAdapter->ScanTab.BssEntry[i].Channel;
1253 else
1254 iwe.u.freq.m = pAdapter->ScanTab.BssEntry[i].Channel;
1255 iwe.u.freq.e = 0;
1256 iwe.u.freq.i = 0;
1257
1258 previous_ev = current_ev;
1259 current_ev = iwe_stream_add_event(info, current_ev, end_buf, &iwe, IW_EV_FREQ_LEN);
1260 if (current_ev == previous_ev)
1261#if WIRELESS_EXT >= 17
1262 return -E2BIG;
1263#else
1264 break;
1265#endif
1266
1267 //Add quality statistics
1268 //================================
1269 memset(&iwe, 0, sizeof(iwe));
1270 iwe.cmd = IWEVQUAL;
1271 iwe.u.qual.level = 0;
1272 iwe.u.qual.noise = 0;
1273 set_quality(pAdapter, &iwe.u.qual, pAdapter->ScanTab.BssEntry[i].Rssi);
1274 current_ev = iwe_stream_add_event(info, current_ev, end_buf, &iwe, IW_EV_QUAL_LEN);
1275 if (current_ev == previous_ev)
1276#if WIRELESS_EXT >= 17
1277 return -E2BIG;
1278#else
1279 break;
1280#endif
1281
1282 //Encyption key
1283 //================================
1284 memset(&iwe, 0, sizeof(iwe));
1285 iwe.cmd = SIOCGIWENCODE;
1286 if (CAP_IS_PRIVACY_ON (pAdapter->ScanTab.BssEntry[i].CapabilityInfo ))
1287 iwe.u.data.flags =IW_ENCODE_ENABLED | IW_ENCODE_NOKEY;
1288 else
1289 iwe.u.data.flags = IW_ENCODE_DISABLED;
1290
1291 previous_ev = current_ev;
1292 current_ev = iwe_stream_add_point(info, current_ev, end_buf,&iwe, (char *)pAdapter->SharedKey[BSS0][(iwe.u.data.flags & IW_ENCODE_INDEX)-1].Key);
1293 if (current_ev == previous_ev)
1294#if WIRELESS_EXT >= 17
1295 return -E2BIG;
1296#else
1297 break;
1298#endif
1299
1300 //Bit Rate
1301 //================================
1302 if (pAdapter->ScanTab.BssEntry[i].SupRateLen)
1303 {
1304 UCHAR tmpRate = pAdapter->ScanTab.BssEntry[i].SupRate[pAdapter->ScanTab.BssEntry[i].SupRateLen-1];
1305 memset(&iwe, 0, sizeof(iwe));
1306 iwe.cmd = SIOCGIWRATE;
1307 current_val = current_ev + IW_EV_LCP_LEN;
1308 if (tmpRate == 0x82)
1309 iwe.u.bitrate.value = 1 * 1000000;
1310 else if (tmpRate == 0x84)
1311 iwe.u.bitrate.value = 2 * 1000000;
1312 else if (tmpRate == 0x8B)
1313 iwe.u.bitrate.value = 5.5 * 1000000;
1314 else if (tmpRate == 0x96)
1315 iwe.u.bitrate.value = 11 * 1000000;
1316 else
1317 iwe.u.bitrate.value = (tmpRate/2) * 1000000;
1318
1319 iwe.u.bitrate.disabled = 0;
1320 current_val = iwe_stream_add_value(info, current_ev,
1321 current_val, end_buf, &iwe,
1322 IW_EV_PARAM_LEN);
1323
1324 if((current_val-current_ev)>IW_EV_LCP_LEN)
1325 current_ev = current_val;
1326 else
1327#if WIRELESS_EXT >= 17
1328 return -E2BIG;
1329#else
1330 break;
1331#endif
1332 }
1333
1334#ifdef IWEVGENIE
1335 //WPA IE
1336 if (pAdapter->ScanTab.BssEntry[i].WpaIE.IELen > 0)
1337 {
1338 memset(&iwe, 0, sizeof(iwe));
1339 memset(&custom[0], 0, MAX_CUSTOM_LEN);
1340 memcpy(custom, &(pAdapter->ScanTab.BssEntry[i].WpaIE.IE[0]),
1341 pAdapter->ScanTab.BssEntry[i].WpaIE.IELen);
1342 iwe.cmd = IWEVGENIE;
1343 iwe.u.data.length = pAdapter->ScanTab.BssEntry[i].WpaIE.IELen;
1344 current_ev = iwe_stream_add_point(info, current_ev, end_buf, &iwe, custom);
1345 if (current_ev == previous_ev)
1346#if WIRELESS_EXT >= 17
1347 return -E2BIG;
1348#else
1349 break;
1350#endif
1351 }
1352
1353 //WPA2 IE
1354 if (pAdapter->ScanTab.BssEntry[i].RsnIE.IELen > 0)
1355 {
1356 memset(&iwe, 0, sizeof(iwe));
1357 memset(&custom[0], 0, MAX_CUSTOM_LEN);
1358 memcpy(custom, &(pAdapter->ScanTab.BssEntry[i].RsnIE.IE[0]),
1359 pAdapter->ScanTab.BssEntry[i].RsnIE.IELen);
1360 iwe.cmd = IWEVGENIE;
1361 iwe.u.data.length = pAdapter->ScanTab.BssEntry[i].RsnIE.IELen;
1362 current_ev = iwe_stream_add_point(info, current_ev, end_buf, &iwe, custom);
1363 if (current_ev == previous_ev)
1364#if WIRELESS_EXT >= 17
1365 return -E2BIG;
1366#else
1367 break;
1368#endif
1369 }
1370#else
1371 //WPA IE
1372 //================================
1373 if (pAdapter->ScanTab.BssEntry[i].WpaIE.IELen > 0)
1374 {
1375 NdisZeroMemory(&iwe, sizeof(iwe));
1376 memset(&custom[0], 0, MAX_CUSTOM_LEN);
1377 iwe.cmd = IWEVCUSTOM;
1378 iwe.u.data.length = (pAdapter->ScanTab.BssEntry[i].WpaIE.IELen * 2) + 7;
1379 NdisMoveMemory(custom, "wpa_ie=", 7);
1380 for (idx = 0; idx < pAdapter->ScanTab.BssEntry[i].WpaIE.IELen; idx++)
1381 sprintf(custom + strlen(custom), "%02x", pAdapter->ScanTab.BssEntry[i].WpaIE.IE[idx]);
1382 previous_ev = current_ev;
1383 current_ev = iwe_stream_add_point(current_ev, end_buf, &iwe, custom);
1384 if (current_ev == previous_ev)
1385#if WIRELESS_EXT >= 17
1386 return -E2BIG;
1387#else
1388 break;
1389#endif
1390 }
1391
1392 //WPA2 IE
1393 if (pAdapter->ScanTab.BssEntry[i].RsnIE.IELen > 0)
1394 {
1395 NdisZeroMemory(&iwe, sizeof(iwe));
1396 memset(&custom[0], 0, MAX_CUSTOM_LEN);
1397 iwe.cmd = IWEVCUSTOM;
1398 iwe.u.data.length = (pAdapter->ScanTab.BssEntry[i].RsnIE.IELen * 2) + 7;
1399 NdisMoveMemory(custom, "rsn_ie=", 7);
1400 for (idx = 0; idx < pAdapter->ScanTab.BssEntry[i].RsnIE.IELen; idx++)
1401 sprintf(custom + strlen(custom), "%02x", pAdapter->ScanTab.BssEntry[i].RsnIE.IE[idx]);
1402 previous_ev = current_ev;
1403 current_ev = iwe_stream_add_point(current_ev, end_buf, &iwe, custom);
1404 if (current_ev == previous_ev)
1405#if WIRELESS_EXT >= 17
1406 return -E2BIG;
1407#else
1408 break;
1409#endif
1410 }
1411#endif // IWEVGENIE //
1412 }
1413
1414 data->length = current_ev - extra;
1415 pAdapter->StaCfg.bScanReqIsFromWebUI = FALSE;
1416 DBGPRINT(RT_DEBUG_ERROR ,("===>rt_ioctl_giwscan. %d(%d) BSS returned, data->length = %d\n",i , pAdapter->ScanTab.BssNr, data->length));
1417 return 0;
1418}
1419#endif
1420
1421int rt_ioctl_siwessid(struct net_device *dev,
1422 struct iw_request_info *info,
1423 struct iw_point *data, char *essid)
1424{
1425 PRTMP_ADAPTER pAdapter = dev->ml_priv;
1426
1427 //check if the interface is down
1428 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1429 {
1430 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1431 return -ENETDOWN;
1432 }
1433
1434 if (data->flags)
1435 {
1436 PCHAR pSsidString = NULL;
1437
1438 // Includes null character.
1439 if (data->length > (IW_ESSID_MAX_SIZE + 1))
1440 return -E2BIG;
1441
1442 pSsidString = (CHAR *) kmalloc(MAX_LEN_OF_SSID+1, MEM_ALLOC_FLAG);
1443 if (pSsidString)
1444 {
1445 NdisZeroMemory(pSsidString, MAX_LEN_OF_SSID+1);
1446 NdisMoveMemory(pSsidString, essid, data->length);
1447 if (Set_SSID_Proc(pAdapter, pSsidString) == FALSE)
1448 return -EINVAL;
1449 }
1450 else
1451 return -ENOMEM;
1452 }
1453 else
1454 {
1455 // ANY ssid
1456 if (Set_SSID_Proc(pAdapter, "") == FALSE)
1457 return -EINVAL;
1458 }
1459 return 0;
1460}
1461
1462int rt_ioctl_giwessid(struct net_device *dev,
1463 struct iw_request_info *info,
1464 struct iw_point *data, char *essid)
1465{
1466#ifndef RT30xx
1467 PRTMP_ADAPTER pAdapter = NULL;
1468 VIRTUAL_ADAPTER *pVirtualAd = NULL;
1469
1470 if (dev->priv_flags == INT_MAIN)
1471 {
1472 pAdapter = dev->ml_priv;
1473 }
1474 else
1475 {
1476 pVirtualAd = dev->ml_priv;
1477 if (pVirtualAd && pVirtualAd->RtmpDev)
1478 pAdapter = pVirtualAd->RtmpDev->ml_priv;
1479 }
1480
1481 if (pAdapter == NULL)
1482 {
1483 /* if 1st open fail, pAd will be free;
1484 So the net_dev->ml_priv will be NULL in 2rd open */
1485 return -ENETDOWN;
1486 }
1487#endif
1488#ifdef RT30xx
1489 PRTMP_ADAPTER pAdapter = dev->ml_priv;
1490#endif
1491
1492 data->flags = 1;
1493 if (MONITOR_ON(pAdapter))
1494 {
1495 data->length = 0;
1496 return 0;
1497 }
1498
1499 if (OPSTATUS_TEST_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED))
1500 {
1501 DBGPRINT(RT_DEBUG_TRACE ,("MediaState is connected\n"));
1502 data->length = pAdapter->CommonCfg.SsidLen;
1503 memcpy(essid, pAdapter->CommonCfg.Ssid, pAdapter->CommonCfg.SsidLen);
1504 }
1505#ifdef RT2870
1506 // Add for RT2870
1507 else if (pAdapter->StaCfg.WpaSupplicantUP != WPA_SUPPLICANT_DISABLE)
1508 {
1509 data->length = pAdapter->CommonCfg.SsidLen;
1510 memcpy(essid, pAdapter->CommonCfg.Ssid, pAdapter->CommonCfg.SsidLen);
1511 }
1512#endif // RT2870 //
1513 else
1514 {//the ANY ssid was specified
1515 data->length = 0;
1516 DBGPRINT(RT_DEBUG_TRACE ,("MediaState is not connected, ess\n"));
1517 }
1518
1519 return 0;
1520
1521}
1522
1523int rt_ioctl_siwnickn(struct net_device *dev,
1524 struct iw_request_info *info,
1525 struct iw_point *data, char *nickname)
1526{
1527 PRTMP_ADAPTER pAdapter = dev->ml_priv;
1528
1529 //check if the interface is down
1530 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1531 {
1532 DBGPRINT(RT_DEBUG_TRACE ,("INFO::Network is down!\n"));
1533 return -ENETDOWN;
1534 }
1535
1536 if (data->length > IW_ESSID_MAX_SIZE)
1537 return -EINVAL;
1538
1539 memset(pAdapter->nickname, 0, IW_ESSID_MAX_SIZE + 1);
1540 memcpy(pAdapter->nickname, nickname, data->length);
1541
1542
1543 return 0;
1544}
1545
1546int rt_ioctl_giwnickn(struct net_device *dev,
1547 struct iw_request_info *info,
1548 struct iw_point *data, char *nickname)
1549{
1550#ifndef RT30xx
1551 PRTMP_ADAPTER pAdapter = NULL;
1552 VIRTUAL_ADAPTER *pVirtualAd = NULL;
1553
1554 if (dev->priv_flags == INT_MAIN)
1555 {
1556 pAdapter = dev->ml_priv;
1557 }
1558 else
1559 {
1560 pVirtualAd = dev->ml_priv;
1561 if (pVirtualAd && pVirtualAd->RtmpDev)
1562 pAdapter = pVirtualAd->RtmpDev->ml_priv;
1563 }
1564
1565 if (pAdapter == NULL)
1566 {
1567 /* if 1st open fail, pAd will be free;
1568 So the net_dev->ml_priv will be NULL in 2rd open */
1569 return -ENETDOWN;
1570 }
1571#endif
1572#ifdef RT30xx
1573 PRTMP_ADAPTER pAdapter = dev->ml_priv;
1574#endif
1575
1576 if (data->length > strlen(pAdapter->nickname) + 1)
1577 data->length = strlen(pAdapter->nickname) + 1;
1578 if (data->length > 0) {
1579 memcpy(nickname, pAdapter->nickname, data->length-1);
1580 nickname[data->length-1] = '\0';
1581 }
1582 return 0;
1583}
1584
1585int rt_ioctl_siwrts(struct net_device *dev,
1586 struct iw_request_info *info,
1587 struct iw_param *rts, char *extra)
1588{
1589 PRTMP_ADAPTER pAdapter = dev->ml_priv;
1590 u16 val;
1591
1592 //check if the interface is down
1593 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1594 {
1595 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1596 return -ENETDOWN;
1597 }
1598
1599 if (rts->disabled)
1600 val = MAX_RTS_THRESHOLD;
1601 else if (rts->value < 0 || rts->value > MAX_RTS_THRESHOLD)
1602 return -EINVAL;
1603 else if (rts->value == 0)
1604 val = MAX_RTS_THRESHOLD;
1605 else
1606 val = rts->value;
1607
1608 if (val != pAdapter->CommonCfg.RtsThreshold)
1609 pAdapter->CommonCfg.RtsThreshold = val;
1610
1611 return 0;
1612}
1613
1614int rt_ioctl_giwrts(struct net_device *dev,
1615 struct iw_request_info *info,
1616 struct iw_param *rts, char *extra)
1617{
1618#ifndef RT30xx
1619 PRTMP_ADAPTER pAdapter = NULL;
1620 VIRTUAL_ADAPTER *pVirtualAd = NULL;
1621
1622 if (dev->priv_flags == INT_MAIN)
1623 {
1624 pAdapter = dev->ml_priv;
1625 }
1626 else
1627 {
1628 pVirtualAd = dev->ml_priv;
1629 if (pVirtualAd && pVirtualAd->RtmpDev)
1630 pAdapter = pVirtualAd->RtmpDev->ml_priv;
1631 }
1632
1633 if (pAdapter == NULL)
1634 {
1635 /* if 1st open fail, pAd will be free;
1636 So the net_dev->ml_priv will be NULL in 2rd open */
1637 return -ENETDOWN;
1638 }
1639#endif
1640#ifdef RT30xx
1641 PRTMP_ADAPTER pAdapter = dev->ml_priv;
1642#endif
1643
1644 //check if the interface is down
1645 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1646 {
1647 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1648 return -ENETDOWN;
1649 }
1650
1651 rts->value = pAdapter->CommonCfg.RtsThreshold;
1652 rts->disabled = (rts->value == MAX_RTS_THRESHOLD);
1653 rts->fixed = 1;
1654
1655 return 0;
1656}
1657
1658int rt_ioctl_siwfrag(struct net_device *dev,
1659 struct iw_request_info *info,
1660 struct iw_param *frag, char *extra)
1661{
1662 PRTMP_ADAPTER pAdapter = dev->ml_priv;
1663 u16 val;
1664
1665 //check if the interface is down
1666 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1667 {
1668 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1669 return -ENETDOWN;
1670 }
1671
1672 if (frag->disabled)
1673 val = MAX_FRAG_THRESHOLD;
1674 else if (frag->value >= MIN_FRAG_THRESHOLD || frag->value <= MAX_FRAG_THRESHOLD)
1675 val = __cpu_to_le16(frag->value & ~0x1); /* even numbers only */
1676 else if (frag->value == 0)
1677 val = MAX_FRAG_THRESHOLD;
1678 else
1679 return -EINVAL;
1680
1681 pAdapter->CommonCfg.FragmentThreshold = val;
1682 return 0;
1683}
1684
1685int rt_ioctl_giwfrag(struct net_device *dev,
1686 struct iw_request_info *info,
1687 struct iw_param *frag, char *extra)
1688{
1689#ifndef RT30xx
1690 PRTMP_ADAPTER pAdapter = NULL;
1691 VIRTUAL_ADAPTER *pVirtualAd = NULL;
1692
1693 if (dev->priv_flags == INT_MAIN)
1694 {
1695 pAdapter = dev->ml_priv;
1696 }
1697 else
1698 {
1699 pVirtualAd = dev->ml_priv;
1700 if (pVirtualAd && pVirtualAd->RtmpDev)
1701 pAdapter = pVirtualAd->RtmpDev->ml_priv;
1702 }
1703
1704 if (pAdapter == NULL)
1705 {
1706 /* if 1st open fail, pAd will be free;
1707 So the net_dev->ml_priv will be NULL in 2rd open */
1708 return -ENETDOWN;
1709 }
1710#endif
1711#ifdef RT30xx
1712 PRTMP_ADAPTER pAdapter = dev->ml_priv;
1713#endif
1714
1715 //check if the interface is down
1716 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1717 {
1718 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1719 return -ENETDOWN;
1720 }
1721
1722 frag->value = pAdapter->CommonCfg.FragmentThreshold;
1723 frag->disabled = (frag->value == MAX_FRAG_THRESHOLD);
1724 frag->fixed = 1;
1725
1726 return 0;
1727}
1728
1729#define MAX_WEP_KEY_SIZE 13
1730#define MIN_WEP_KEY_SIZE 5
1731int rt_ioctl_siwencode(struct net_device *dev,
1732 struct iw_request_info *info,
1733 struct iw_point *erq, char *extra)
1734{
1735 PRTMP_ADAPTER pAdapter = dev->ml_priv;
1736
1737 //check if the interface is down
1738 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1739 {
1740 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1741 return -ENETDOWN;
1742 }
1743
1744 if ((erq->length == 0) &&
1745 (erq->flags & IW_ENCODE_DISABLED))
1746 {
1747 pAdapter->StaCfg.PairCipher = Ndis802_11WEPDisabled;
1748 pAdapter->StaCfg.GroupCipher = Ndis802_11WEPDisabled;
1749 pAdapter->StaCfg.WepStatus = Ndis802_11WEPDisabled;
1750 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
1751 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
1752 goto done;
1753 }
1754#ifndef RT30xx
1755 else if ((erq->length == 0) &&
1756 (erq->flags & IW_ENCODE_RESTRICTED || erq->flags & IW_ENCODE_OPEN))
1757#endif
1758#ifdef RT30xx
1759 else if (erq->flags & IW_ENCODE_RESTRICTED || erq->flags & IW_ENCODE_OPEN)
1760#endif
1761 {
1762 STA_PORT_SECURED(pAdapter);
1763 pAdapter->StaCfg.PairCipher = Ndis802_11WEPEnabled;
1764 pAdapter->StaCfg.GroupCipher = Ndis802_11WEPEnabled;
1765 pAdapter->StaCfg.WepStatus = Ndis802_11WEPEnabled;
1766 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
1767 if (erq->flags & IW_ENCODE_RESTRICTED)
1768 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeShared;
1769 else
1770 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
1771#ifndef RT30xx
1772 goto done;
1773#endif
1774 }
1775
1776 if (erq->length > 0)
1777 {
1778 int keyIdx = (erq->flags & IW_ENCODE_INDEX) - 1;
1779 /* Check the size of the key */
1780 if (erq->length > MAX_WEP_KEY_SIZE)
1781 {
1782 return -EINVAL;
1783 }
1784 /* Check key index */
1785 if ((keyIdx < 0) || (keyIdx >= NR_WEP_KEYS))
1786 {
1787 DBGPRINT(RT_DEBUG_TRACE ,("==>rt_ioctl_siwencode::Wrong keyIdx=%d! Using default key instead (%d)\n",
1788 keyIdx, pAdapter->StaCfg.DefaultKeyId));
1789
1790 //Using default key
1791 keyIdx = pAdapter->StaCfg.DefaultKeyId;
1792 }
1793#ifdef RT30xx
1794 else
1795 {
1796 pAdapter->StaCfg.DefaultKeyId=keyIdx;
1797 }
1798#endif
1799
1800 NdisZeroMemory(pAdapter->SharedKey[BSS0][keyIdx].Key, 16);
1801
1802 if (erq->length == MAX_WEP_KEY_SIZE)
1803 {
1804 pAdapter->SharedKey[BSS0][keyIdx].KeyLen = MAX_WEP_KEY_SIZE;
1805 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CIPHER_WEP128;
1806 }
1807 else if (erq->length == MIN_WEP_KEY_SIZE)
1808 {
1809 pAdapter->SharedKey[BSS0][keyIdx].KeyLen = MIN_WEP_KEY_SIZE;
1810 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CIPHER_WEP64;
1811 }
1812 else
1813 /* Disable the key */
1814 pAdapter->SharedKey[BSS0][keyIdx].KeyLen = 0;
1815
1816 /* Check if the key is not marked as invalid */
1817 if(!(erq->flags & IW_ENCODE_NOKEY))
1818 {
1819 /* Copy the key in the driver */
1820 NdisMoveMemory(pAdapter->SharedKey[BSS0][keyIdx].Key, extra, erq->length);
1821 }
1822 }
1823 else
1824 {
1825 /* Do we want to just set the transmit key index ? */
1826 int index = (erq->flags & IW_ENCODE_INDEX) - 1;
1827 if ((index >= 0) && (index < 4))
1828 {
1829 pAdapter->StaCfg.DefaultKeyId = index;
1830 }
1831 else
1832 /* Don't complain if only change the mode */
1833 if (!(erq->flags & IW_ENCODE_MODE))
1834 {
1835 return -EINVAL;
1836 }
1837 }
1838
1839done:
1840 DBGPRINT(RT_DEBUG_TRACE ,("==>rt_ioctl_siwencode::erq->flags=%x\n",erq->flags));
1841 DBGPRINT(RT_DEBUG_TRACE ,("==>rt_ioctl_siwencode::AuthMode=%x\n",pAdapter->StaCfg.AuthMode));
1842 DBGPRINT(RT_DEBUG_TRACE ,("==>rt_ioctl_siwencode::DefaultKeyId=%x, KeyLen = %d\n",pAdapter->StaCfg.DefaultKeyId , pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].KeyLen));
1843 DBGPRINT(RT_DEBUG_TRACE ,("==>rt_ioctl_siwencode::WepStatus=%x\n",pAdapter->StaCfg.WepStatus));
1844 return 0;
1845}
1846
1847int
1848rt_ioctl_giwencode(struct net_device *dev,
1849 struct iw_request_info *info,
1850 struct iw_point *erq, char *key)
1851{
1852#ifdef RT30xx
1853 PRTMP_ADAPTER pAdapter = dev->ml_priv;
1854#endif
1855 int kid;
1856#ifndef RT30xx
1857 PRTMP_ADAPTER pAdapter = NULL;
1858 VIRTUAL_ADAPTER *pVirtualAd = NULL;
1859
1860 if (dev->priv_flags == INT_MAIN)
1861 {
1862 pAdapter = dev->ml_priv;
1863 }
1864 else
1865 {
1866 pVirtualAd = dev->ml_priv;
1867 if (pVirtualAd && pVirtualAd->RtmpDev)
1868 pAdapter = pVirtualAd->RtmpDev->ml_priv;
1869 }
1870
1871 if (pAdapter == NULL)
1872 {
1873 /* if 1st open fail, pAd will be free;
1874 So the net_dev->ml_priv will be NULL in 2rd open */
1875 return -ENETDOWN;
1876 }
1877#endif
1878
1879 //check if the interface is down
1880 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1881 {
1882 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1883 return -ENETDOWN;
1884 }
1885
1886 kid = erq->flags & IW_ENCODE_INDEX;
1887 DBGPRINT(RT_DEBUG_TRACE, ("===>rt_ioctl_giwencode %d\n", erq->flags & IW_ENCODE_INDEX));
1888
1889 if (pAdapter->StaCfg.WepStatus == Ndis802_11WEPDisabled)
1890 {
1891 erq->length = 0;
1892 erq->flags = IW_ENCODE_DISABLED;
1893 }
1894 else if ((kid > 0) && (kid <=4))
1895 {
1896 // copy wep key
1897 erq->flags = kid ; /* NB: base 1 */
1898 if (erq->length > pAdapter->SharedKey[BSS0][kid-1].KeyLen)
1899 erq->length = pAdapter->SharedKey[BSS0][kid-1].KeyLen;
1900 memcpy(key, pAdapter->SharedKey[BSS0][kid-1].Key, erq->length);
1901 //if ((kid == pAdapter->PortCfg.DefaultKeyId))
1902 //erq->flags |= IW_ENCODE_ENABLED; /* XXX */
1903 if (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeShared)
1904 erq->flags |= IW_ENCODE_RESTRICTED; /* XXX */
1905 else
1906 erq->flags |= IW_ENCODE_OPEN; /* XXX */
1907
1908 }
1909 else if (kid == 0)
1910 {
1911 if (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeShared)
1912 erq->flags |= IW_ENCODE_RESTRICTED; /* XXX */
1913 else
1914 erq->flags |= IW_ENCODE_OPEN; /* XXX */
1915 erq->length = pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].KeyLen;
1916 memcpy(key, pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].Key, erq->length);
1917 // copy default key ID
1918 if (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeShared)
1919 erq->flags |= IW_ENCODE_RESTRICTED; /* XXX */
1920 else
1921 erq->flags |= IW_ENCODE_OPEN; /* XXX */
1922 erq->flags = pAdapter->StaCfg.DefaultKeyId + 1; /* NB: base 1 */
1923 erq->flags |= IW_ENCODE_ENABLED; /* XXX */
1924 }
1925
1926 return 0;
1927
1928}
1929
1930static int
1931rt_ioctl_setparam(struct net_device *dev, struct iw_request_info *info,
1932 void *w, char *extra)
1933{
1934 VIRTUAL_ADAPTER *pVirtualAd = NULL;
1935 PRTMP_ADAPTER pAdapter;
1936 POS_COOKIE pObj;
1937 char *this_char = extra;
1938 char *value;
1939 int Status=0;
1940
1941 if (dev->priv_flags == INT_MAIN)
1942 {
1943 pAdapter = dev->ml_priv;
1944 }
1945 else
1946 {
1947 pVirtualAd = dev->ml_priv;
1948 pAdapter = pVirtualAd->RtmpDev->ml_priv;
1949 }
1950 pObj = (POS_COOKIE) pAdapter->OS_Cookie;
1951
1952 if (pAdapter == NULL)
1953 {
1954 /* if 1st open fail, pAd will be free;
1955 So the net_dev->ml_priv will be NULL in 2rd open */
1956 return -ENETDOWN;
1957 }
1958
1959 {
1960 pObj->ioctl_if_type = INT_MAIN;
1961 pObj->ioctl_if = MAIN_MBSSID;
1962 }
1963
1964 //check if the interface is down
1965 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1966 {
1967 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1968 return -ENETDOWN;
1969 }
1970
1971 if (!*this_char)
1972 return -EINVAL;
1973
1974 if ((value = rtstrchr(this_char, '=')) != NULL)
1975 *value++ = 0;
1976
1977 if (!value)
1978 return -EINVAL;
1979
1980 // reject setting nothing besides ANY ssid(ssidLen=0)
1981 if (!*value && (strcmp(this_char, "SSID") != 0))
1982 return -EINVAL;
1983
1984 for (PRTMP_PRIVATE_SET_PROC = RTMP_PRIVATE_SUPPORT_PROC; PRTMP_PRIVATE_SET_PROC->name; PRTMP_PRIVATE_SET_PROC++)
1985 {
1986 if (strcmp(this_char, PRTMP_PRIVATE_SET_PROC->name) == 0)
1987 {
1988 if(!PRTMP_PRIVATE_SET_PROC->set_proc(pAdapter, value))
1989 { //FALSE:Set private failed then return Invalid argument
1990 Status = -EINVAL;
1991 }
1992 break; //Exit for loop.
1993 }
1994 }
1995
1996 if(PRTMP_PRIVATE_SET_PROC->name == NULL)
1997 { //Not found argument
1998 Status = -EINVAL;
1999 DBGPRINT(RT_DEBUG_TRACE, ("===>rt_ioctl_setparam:: (iwpriv) Not Support Set Command [%s=%s]\n", this_char, value));
2000 }
2001
2002 return Status;
2003}
2004
2005
2006static int
2007rt_private_get_statistics(struct net_device *dev, struct iw_request_info *info,
2008 struct iw_point *wrq, char *extra)
2009{
2010 INT Status = 0;
2011 PRTMP_ADAPTER pAd = dev->ml_priv;
2012
2013 if (extra == NULL)
2014 {
2015 wrq->length = 0;
2016 return -EIO;
2017 }
2018
2019 memset(extra, 0x00, IW_PRIV_SIZE_MASK);
2020 sprintf(extra, "\n\n");
2021
2022 {
2023 sprintf(extra+strlen(extra), "Tx success = %ld\n", (ULONG)pAd->WlanCounters.TransmittedFragmentCount.QuadPart);
2024 sprintf(extra+strlen(extra), "Tx success without retry = %ld\n", (ULONG)pAd->WlanCounters.TransmittedFragmentCount.QuadPart - (ULONG)pAd->WlanCounters.RetryCount.QuadPart);
2025 }
2026 sprintf(extra+strlen(extra), "Tx success after retry = %ld\n", (ULONG)pAd->WlanCounters.RetryCount.QuadPart);
2027 sprintf(extra+strlen(extra), "Tx fail to Rcv ACK after retry = %ld\n", (ULONG)pAd->WlanCounters.FailedCount.QuadPart);
2028 sprintf(extra+strlen(extra), "RTS Success Rcv CTS = %ld\n", (ULONG)pAd->WlanCounters.RTSSuccessCount.QuadPart);
2029 sprintf(extra+strlen(extra), "RTS Fail Rcv CTS = %ld\n", (ULONG)pAd->WlanCounters.RTSFailureCount.QuadPart);
2030
2031 sprintf(extra+strlen(extra), "Rx success = %ld\n", (ULONG)pAd->WlanCounters.ReceivedFragmentCount.QuadPart);
2032 sprintf(extra+strlen(extra), "Rx with CRC = %ld\n", (ULONG)pAd->WlanCounters.FCSErrorCount.QuadPart);
2033 sprintf(extra+strlen(extra), "Rx drop due to out of resource = %ld\n", (ULONG)pAd->Counters8023.RxNoBuffer);
2034 sprintf(extra+strlen(extra), "Rx duplicate frame = %ld\n", (ULONG)pAd->WlanCounters.FrameDuplicateCount.QuadPart);
2035
2036 sprintf(extra+strlen(extra), "False CCA (one second) = %ld\n", (ULONG)pAd->RalinkCounters.OneSecFalseCCACnt);
2037 {
2038 sprintf(extra+strlen(extra), "RSSI-A = %ld\n", (LONG)(pAd->StaCfg.RssiSample.LastRssi0 - pAd->BbpRssiToDbmDelta));
2039 sprintf(extra+strlen(extra), "RSSI-B (if available) = %ld\n", (LONG)(pAd->StaCfg.RssiSample.LastRssi1 - pAd->BbpRssiToDbmDelta));
2040 sprintf(extra+strlen(extra), "RSSI-C (if available) = %ld\n\n", (LONG)(pAd->StaCfg.RssiSample.LastRssi2 - pAd->BbpRssiToDbmDelta));
2041 }
2042 sprintf(extra+strlen(extra), "WpaSupplicantUP = %d\n\n", pAd->StaCfg.WpaSupplicantUP);
2043
2044 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2045 DBGPRINT(RT_DEBUG_TRACE, ("<== rt_private_get_statistics, wrq->length = %d\n", wrq->length));
2046
2047 return Status;
2048}
2049
2050void getBaInfo(
2051 IN PRTMP_ADAPTER pAd,
2052 IN PUCHAR pOutBuf)
2053{
2054 INT i, j;
2055 BA_ORI_ENTRY *pOriBAEntry;
2056 BA_REC_ENTRY *pRecBAEntry;
2057
2058 for (i=0; i<MAX_LEN_OF_MAC_TABLE; i++)
2059 {
2060 PMAC_TABLE_ENTRY pEntry = &pAd->MacTab.Content[i];
2061 if (((pEntry->ValidAsCLI || pEntry->ValidAsApCli) && (pEntry->Sst == SST_ASSOC))
2062 || (pEntry->ValidAsWDS) || (pEntry->ValidAsMesh))
2063 {
2064 sprintf(pOutBuf + strlen(pOutBuf), "\n%02X:%02X:%02X:%02X:%02X:%02X (Aid = %d) (AP) -\n",
2065 pEntry->Addr[0], pEntry->Addr[1], pEntry->Addr[2],
2066 pEntry->Addr[3], pEntry->Addr[4], pEntry->Addr[5], pEntry->Aid);
2067
2068 sprintf(pOutBuf, "%s[Recipient]\n", pOutBuf);
2069 for (j=0; j < NUM_OF_TID; j++)
2070 {
2071 if (pEntry->BARecWcidArray[j] != 0)
2072 {
2073 pRecBAEntry =&pAd->BATable.BARecEntry[pEntry->BARecWcidArray[j]];
2074 sprintf(pOutBuf + strlen(pOutBuf), "TID=%d, BAWinSize=%d, LastIndSeq=%d, ReorderingPkts=%d\n", j, pRecBAEntry->BAWinSize, pRecBAEntry->LastIndSeq, pRecBAEntry->list.qlen);
2075 }
2076 }
2077 sprintf(pOutBuf, "%s\n", pOutBuf);
2078
2079 sprintf(pOutBuf, "%s[Originator]\n", pOutBuf);
2080 for (j=0; j < NUM_OF_TID; j++)
2081 {
2082 if (pEntry->BAOriWcidArray[j] != 0)
2083 {
2084 pOriBAEntry =&pAd->BATable.BAOriEntry[pEntry->BAOriWcidArray[j]];
2085 sprintf(pOutBuf + strlen(pOutBuf), "TID=%d, BAWinSize=%d, StartSeq=%d, CurTxSeq=%d\n", j, pOriBAEntry->BAWinSize, pOriBAEntry->Sequence, pEntry->TxSeq[j]);
2086 }
2087 }
2088 sprintf(pOutBuf, "%s\n\n", pOutBuf);
2089 }
2090 if (strlen(pOutBuf) > (IW_PRIV_SIZE_MASK - 30))
2091 break;
2092 }
2093
2094 return;
2095}
2096
2097static int
2098rt_private_show(struct net_device *dev, struct iw_request_info *info,
2099 struct iw_point *wrq, char *extra)
2100{
2101 INT Status = 0;
2102 VIRTUAL_ADAPTER *pVirtualAd = NULL;
2103 PRTMP_ADAPTER pAd;
2104 POS_COOKIE pObj;
2105 u32 subcmd = wrq->flags;
2106
2107 if (dev->priv_flags == INT_MAIN)
2108 pAd = dev->ml_priv;
2109 else
2110 {
2111 pVirtualAd = dev->ml_priv;
2112 pAd = pVirtualAd->RtmpDev->ml_priv;
2113 }
2114 pObj = (POS_COOKIE) pAd->OS_Cookie;
2115
2116 if (pAd == NULL)
2117 {
2118 /* if 1st open fail, pAd will be free;
2119 So the net_dev->ml_priv will be NULL in 2rd open */
2120 return -ENETDOWN;
2121 }
2122
2123 if (extra == NULL)
2124 {
2125 wrq->length = 0;
2126 return -EIO;
2127 }
2128 memset(extra, 0x00, IW_PRIV_SIZE_MASK);
2129
2130 {
2131 pObj->ioctl_if_type = INT_MAIN;
2132 pObj->ioctl_if = MAIN_MBSSID;
2133 }
2134
2135 switch(subcmd)
2136 {
2137
2138 case SHOW_CONN_STATUS:
2139 if (MONITOR_ON(pAd))
2140 {
2141 if (pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED &&
2142 pAd->CommonCfg.RegTransmitSetting.field.BW)
2143 sprintf(extra, "Monitor Mode(CentralChannel %d)\n", pAd->CommonCfg.CentralChannel);
2144 else
2145 sprintf(extra, "Monitor Mode(Channel %d)\n", pAd->CommonCfg.Channel);
2146 }
2147 else
2148 {
2149 if (pAd->IndicateMediaState == NdisMediaStateConnected)
2150 {
2151 if (INFRA_ON(pAd))
2152 {
2153 sprintf(extra, "Connected(AP: %s[%02X:%02X:%02X:%02X:%02X:%02X])\n",
2154 pAd->CommonCfg.Ssid,
2155 pAd->CommonCfg.Bssid[0],
2156 pAd->CommonCfg.Bssid[1],
2157 pAd->CommonCfg.Bssid[2],
2158 pAd->CommonCfg.Bssid[3],
2159 pAd->CommonCfg.Bssid[4],
2160 pAd->CommonCfg.Bssid[5]);
2161 DBGPRINT(RT_DEBUG_TRACE ,("Ssid=%s ,Ssidlen = %d\n",pAd->CommonCfg.Ssid, pAd->CommonCfg.SsidLen));
2162 }
2163 else if (ADHOC_ON(pAd))
2164 sprintf(extra, "Connected\n");
2165 }
2166 else
2167 {
2168 sprintf(extra, "Disconnected\n");
2169 DBGPRINT(RT_DEBUG_TRACE ,("ConnStatus is not connected\n"));
2170 }
2171 }
2172 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2173 break;
2174 case SHOW_DRVIER_VERION:
2175 sprintf(extra, "Driver version-%s, %s %s\n", STA_DRIVER_VERSION, __DATE__, __TIME__ );
2176 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2177 break;
2178 case SHOW_BA_INFO:
2179 getBaInfo(pAd, extra);
2180 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2181 break;
2182 case SHOW_DESC_INFO:
2183 {
2184 Show_DescInfo_Proc(pAd, NULL);
2185 wrq->length = 0; // 1: size of '\0'
2186 }
2187 break;
2188 case RAIO_OFF:
2189 if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
2190 {
2191 sprintf(extra, "Scanning\n");
2192 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2193 break;
2194 }
2195 pAd->StaCfg.bSwRadio = FALSE;
2196 if (pAd->StaCfg.bRadio != (pAd->StaCfg.bHwRadio && pAd->StaCfg.bSwRadio))
2197 {
2198 pAd->StaCfg.bRadio = (pAd->StaCfg.bHwRadio && pAd->StaCfg.bSwRadio);
2199 if (pAd->StaCfg.bRadio == FALSE)
2200 {
2201 MlmeRadioOff(pAd);
2202 // Update extra information
2203 pAd->ExtraInfo = SW_RADIO_OFF;
2204 }
2205 }
2206 sprintf(extra, "Radio Off\n");
2207 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2208 break;
2209 case RAIO_ON:
2210 if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
2211 {
2212 sprintf(extra, "Scanning\n");
2213 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2214 break;
2215 }
2216 pAd->StaCfg.bSwRadio = TRUE;
2217 //if (pAd->StaCfg.bRadio != (pAd->StaCfg.bHwRadio && pAd->StaCfg.bSwRadio))
2218 {
2219 pAd->StaCfg.bRadio = (pAd->StaCfg.bHwRadio && pAd->StaCfg.bSwRadio);
2220 if (pAd->StaCfg.bRadio == TRUE)
2221 {
2222 MlmeRadioOn(pAd);
2223 // Update extra information
2224 pAd->ExtraInfo = EXTRA_INFO_CLEAR;
2225 }
2226 }
2227 sprintf(extra, "Radio On\n");
2228 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2229 break;
2230
2231 case SHOW_CFG_VALUE:
2232 {
2233 Status = RTMPShowCfgValue(pAd, wrq->pointer, extra);
2234 if (Status == 0)
2235 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2236 }
2237 break;
2238#ifndef RT30xx
2239 case SHOW_ADHOC_ENTRY_INFO:
2240 Show_Adhoc_MacTable_Proc(pAd, extra);
2241 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2242 break;
2243#endif
2244 default:
2245 DBGPRINT(RT_DEBUG_TRACE, ("%s - unknow subcmd = %d\n", __func__, subcmd));
2246 break;
2247 }
2248
2249 return Status;
2250}
2251
2252#ifdef SIOCSIWMLME
2253int rt_ioctl_siwmlme(struct net_device *dev,
2254 struct iw_request_info *info,
2255 union iwreq_data *wrqu,
2256 char *extra)
2257{
2258 PRTMP_ADAPTER pAd = dev->ml_priv;
2259 struct iw_mlme *pMlme = (struct iw_mlme *)wrqu->data.pointer;
2260 MLME_QUEUE_ELEM MsgElem;
2261 MLME_DISASSOC_REQ_STRUCT DisAssocReq;
2262 MLME_DEAUTH_REQ_STRUCT DeAuthReq;
2263
2264 DBGPRINT(RT_DEBUG_TRACE, ("====> %s\n", __func__));
2265
2266 if (pMlme == NULL)
2267 return -EINVAL;
2268
2269 switch(pMlme->cmd)
2270 {
2271#ifdef IW_MLME_DEAUTH
2272 case IW_MLME_DEAUTH:
2273 DBGPRINT(RT_DEBUG_TRACE, ("====> %s - IW_MLME_DEAUTH\n", __func__));
2274 COPY_MAC_ADDR(DeAuthReq.Addr, pAd->CommonCfg.Bssid);
2275 DeAuthReq.Reason = pMlme->reason_code;
2276 MsgElem.MsgLen = sizeof(MLME_DEAUTH_REQ_STRUCT);
2277 NdisMoveMemory(MsgElem.Msg, &DeAuthReq, sizeof(MLME_DEAUTH_REQ_STRUCT));
2278 MlmeDeauthReqAction(pAd, &MsgElem);
2279 if (INFRA_ON(pAd))
2280 {
2281 LinkDown(pAd, FALSE);
2282 pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
2283 }
2284 break;
2285#endif // IW_MLME_DEAUTH //
2286#ifdef IW_MLME_DISASSOC
2287 case IW_MLME_DISASSOC:
2288 DBGPRINT(RT_DEBUG_TRACE, ("====> %s - IW_MLME_DISASSOC\n", __func__));
2289 COPY_MAC_ADDR(DisAssocReq.Addr, pAd->CommonCfg.Bssid);
2290 DisAssocReq.Reason = pMlme->reason_code;
2291
2292 MsgElem.Machine = ASSOC_STATE_MACHINE;
2293 MsgElem.MsgType = MT2_MLME_DISASSOC_REQ;
2294 MsgElem.MsgLen = sizeof(MLME_DISASSOC_REQ_STRUCT);
2295 NdisMoveMemory(MsgElem.Msg, &DisAssocReq, sizeof(MLME_DISASSOC_REQ_STRUCT));
2296
2297 pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_OID_DISASSOC;
2298 MlmeDisassocReqAction(pAd, &MsgElem);
2299 break;
2300#endif // IW_MLME_DISASSOC //
2301 default:
2302 DBGPRINT(RT_DEBUG_TRACE, ("====> %s - Unknow Command\n", __func__));
2303 break;
2304 }
2305
2306 return 0;
2307}
2308#endif // SIOCSIWMLME //
2309
2310#if WIRELESS_EXT > 17
2311int rt_ioctl_siwauth(struct net_device *dev,
2312 struct iw_request_info *info,
2313 union iwreq_data *wrqu, char *extra)
2314{
2315 PRTMP_ADAPTER pAdapter = dev->ml_priv;
2316 struct iw_param *param = &wrqu->param;
2317
2318 //check if the interface is down
2319 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
2320 {
2321 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
2322 return -ENETDOWN;
2323 }
2324 switch (param->flags & IW_AUTH_INDEX) {
2325 case IW_AUTH_WPA_VERSION:
2326 if (param->value == IW_AUTH_WPA_VERSION_WPA)
2327 {
2328 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPAPSK;
2329 if (pAdapter->StaCfg.BssType == BSS_ADHOC)
2330 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPANone;
2331 }
2332 else if (param->value == IW_AUTH_WPA_VERSION_WPA2)
2333 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA2PSK;
2334
2335 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_WPA_VERSION - param->value = %d!\n", __func__, param->value));
2336 break;
2337 case IW_AUTH_CIPHER_PAIRWISE:
2338 if (param->value == IW_AUTH_CIPHER_NONE)
2339 {
2340 pAdapter->StaCfg.WepStatus = Ndis802_11WEPDisabled;
2341 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
2342 pAdapter->StaCfg.PairCipher = Ndis802_11WEPDisabled;
2343 }
2344 else if (param->value == IW_AUTH_CIPHER_WEP40 ||
2345 param->value == IW_AUTH_CIPHER_WEP104)
2346 {
2347 pAdapter->StaCfg.WepStatus = Ndis802_11WEPEnabled;
2348 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
2349 pAdapter->StaCfg.PairCipher = Ndis802_11WEPEnabled;
2350 pAdapter->StaCfg.IEEE8021X = FALSE;
2351 }
2352 else if (param->value == IW_AUTH_CIPHER_TKIP)
2353 {
2354 pAdapter->StaCfg.WepStatus = Ndis802_11Encryption2Enabled;
2355 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
2356 pAdapter->StaCfg.PairCipher = Ndis802_11Encryption2Enabled;
2357 }
2358 else if (param->value == IW_AUTH_CIPHER_CCMP)
2359 {
2360 pAdapter->StaCfg.WepStatus = Ndis802_11Encryption3Enabled;
2361 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
2362 pAdapter->StaCfg.PairCipher = Ndis802_11Encryption3Enabled;
2363 }
2364 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_CIPHER_PAIRWISE - param->value = %d!\n", __func__, param->value));
2365 break;
2366 case IW_AUTH_CIPHER_GROUP:
2367 if (param->value == IW_AUTH_CIPHER_NONE)
2368 {
2369 pAdapter->StaCfg.GroupCipher = Ndis802_11WEPDisabled;
2370 }
2371 else if (param->value == IW_AUTH_CIPHER_WEP40 ||
2372 param->value == IW_AUTH_CIPHER_WEP104)
2373 {
2374 pAdapter->StaCfg.GroupCipher = Ndis802_11WEPEnabled;
2375 }
2376 else if (param->value == IW_AUTH_CIPHER_TKIP)
2377 {
2378 pAdapter->StaCfg.GroupCipher = Ndis802_11Encryption2Enabled;
2379 }
2380 else if (param->value == IW_AUTH_CIPHER_CCMP)
2381 {
2382 pAdapter->StaCfg.GroupCipher = Ndis802_11Encryption3Enabled;
2383 }
2384 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_CIPHER_GROUP - param->value = %d!\n", __func__, param->value));
2385 break;
2386 case IW_AUTH_KEY_MGMT:
2387 if (param->value == IW_AUTH_KEY_MGMT_802_1X)
2388 {
2389 if (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK)
2390 {
2391 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA;
2392 pAdapter->StaCfg.IEEE8021X = FALSE;
2393 }
2394 else if (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK)
2395 {
2396 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA2;
2397 pAdapter->StaCfg.IEEE8021X = FALSE;
2398 }
2399 else
2400 // WEP 1x
2401 pAdapter->StaCfg.IEEE8021X = TRUE;
2402 }
2403 else if (param->value == 0)
2404 {
2405 STA_PORT_SECURED(pAdapter);
2406 }
2407 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_KEY_MGMT - param->value = %d!\n", __func__, param->value));
2408 break;
2409 case IW_AUTH_RX_UNENCRYPTED_EAPOL:
2410 break;
2411 case IW_AUTH_PRIVACY_INVOKED:
2412 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_PRIVACY_INVOKED - param->value = %d!\n", __func__, param->value));
2413 break;
2414 case IW_AUTH_DROP_UNENCRYPTED:
2415 if (param->value != 0)
2416 pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED;
2417 else
2418 {
2419 STA_PORT_SECURED(pAdapter);
2420 }
2421 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_WPA_VERSION - param->value = %d!\n", __func__, param->value));
2422 break;
2423 case IW_AUTH_80211_AUTH_ALG:
2424 if (param->value & IW_AUTH_ALG_SHARED_KEY)
2425 {
2426 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeShared;
2427 }
2428 else if (param->value & IW_AUTH_ALG_OPEN_SYSTEM)
2429 {
2430 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
2431 }
2432 else
2433 return -EINVAL;
2434 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_80211_AUTH_ALG - param->value = %d!\n", __func__, param->value));
2435 break;
2436 case IW_AUTH_WPA_ENABLED:
2437 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_WPA_ENABLED - Driver supports WPA!(param->value = %d)\n", __func__, param->value));
2438 break;
2439 default:
2440 return -EOPNOTSUPP;
2441}
2442
2443 return 0;
2444}
2445
2446int rt_ioctl_giwauth(struct net_device *dev,
2447 struct iw_request_info *info,
2448 union iwreq_data *wrqu, char *extra)
2449{
2450 PRTMP_ADAPTER pAdapter = dev->ml_priv;
2451 struct iw_param *param = &wrqu->param;
2452
2453 //check if the interface is down
2454 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
2455 {
2456 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
2457 return -ENETDOWN;
2458 }
2459
2460 switch (param->flags & IW_AUTH_INDEX) {
2461 case IW_AUTH_DROP_UNENCRYPTED:
2462 param->value = (pAdapter->StaCfg.WepStatus == Ndis802_11WEPDisabled) ? 0 : 1;
2463 break;
2464
2465 case IW_AUTH_80211_AUTH_ALG:
2466 param->value = (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeShared) ? IW_AUTH_ALG_SHARED_KEY : IW_AUTH_ALG_OPEN_SYSTEM;
2467 break;
2468
2469 case IW_AUTH_WPA_ENABLED:
2470 param->value = (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA) ? 1 : 0;
2471 break;
2472
2473 default:
2474 return -EOPNOTSUPP;
2475 }
2476 DBGPRINT(RT_DEBUG_TRACE, ("rt_ioctl_giwauth::param->value = %d!\n", param->value));
2477 return 0;
2478}
2479
2480void fnSetCipherKey(
2481 IN PRTMP_ADAPTER pAdapter,
2482 IN INT keyIdx,
2483 IN UCHAR CipherAlg,
2484 IN BOOLEAN bGTK,
2485 IN struct iw_encode_ext *ext)
2486{
2487 NdisZeroMemory(&pAdapter->SharedKey[BSS0][keyIdx], sizeof(CIPHER_KEY));
2488 pAdapter->SharedKey[BSS0][keyIdx].KeyLen = LEN_TKIP_EK;
2489 NdisMoveMemory(pAdapter->SharedKey[BSS0][keyIdx].Key, ext->key, LEN_TKIP_EK);
2490 NdisMoveMemory(pAdapter->SharedKey[BSS0][keyIdx].TxMic, ext->key + LEN_TKIP_EK, LEN_TKIP_TXMICK);
2491 NdisMoveMemory(pAdapter->SharedKey[BSS0][keyIdx].RxMic, ext->key + LEN_TKIP_EK + LEN_TKIP_TXMICK, LEN_TKIP_RXMICK);
2492 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CipherAlg;
2493
2494 // Update group key information to ASIC Shared Key Table
2495 AsicAddSharedKeyEntry(pAdapter,
2496 BSS0,
2497 keyIdx,
2498 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg,
2499 pAdapter->SharedKey[BSS0][keyIdx].Key,
2500 pAdapter->SharedKey[BSS0][keyIdx].TxMic,
2501 pAdapter->SharedKey[BSS0][keyIdx].RxMic);
2502
2503 if (bGTK)
2504 // Update ASIC WCID attribute table and IVEIV table
2505 RTMPAddWcidAttributeEntry(pAdapter,
2506 BSS0,
2507 keyIdx,
2508 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg,
2509 NULL);
2510 else
2511 // Update ASIC WCID attribute table and IVEIV table
2512 RTMPAddWcidAttributeEntry(pAdapter,
2513 BSS0,
2514 keyIdx,
2515 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg,
2516 &pAdapter->MacTab.Content[BSSID_WCID]);
2517}
2518
2519int rt_ioctl_siwencodeext(struct net_device *dev,
2520 struct iw_request_info *info,
2521 union iwreq_data *wrqu,
2522 char *extra)
2523 {
2524 PRTMP_ADAPTER pAdapter = dev->ml_priv;
2525 struct iw_point *encoding = &wrqu->encoding;
2526 struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
2527 int keyIdx, alg = ext->alg;
2528
2529 //check if the interface is down
2530 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
2531 {
2532 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
2533 return -ENETDOWN;
2534 }
2535
2536 if (encoding->flags & IW_ENCODE_DISABLED)
2537 {
2538 keyIdx = (encoding->flags & IW_ENCODE_INDEX) - 1;
2539 // set BSSID wcid entry of the Pair-wise Key table as no-security mode
2540 AsicRemovePairwiseKeyEntry(pAdapter, BSS0, BSSID_WCID);
2541 pAdapter->SharedKey[BSS0][keyIdx].KeyLen = 0;
2542 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CIPHER_NONE;
2543 AsicRemoveSharedKeyEntry(pAdapter, 0, (UCHAR)keyIdx);
2544 NdisZeroMemory(&pAdapter->SharedKey[BSS0][keyIdx], sizeof(CIPHER_KEY));
2545 DBGPRINT(RT_DEBUG_TRACE, ("%s::Remove all keys!(encoding->flags = %x)\n", __func__, encoding->flags));
2546 }
2547 else
2548 {
2549 // Get Key Index and convet to our own defined key index
2550 keyIdx = (encoding->flags & IW_ENCODE_INDEX) - 1;
2551 if((keyIdx < 0) || (keyIdx >= NR_WEP_KEYS))
2552 return -EINVAL;
2553
2554 if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
2555 {
2556 pAdapter->StaCfg.DefaultKeyId = keyIdx;
2557 DBGPRINT(RT_DEBUG_TRACE, ("%s::DefaultKeyId = %d\n", __func__, pAdapter->StaCfg.DefaultKeyId));
2558 }
2559
2560 switch (alg) {
2561 case IW_ENCODE_ALG_NONE:
2562 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_ENCODE_ALG_NONE\n", __func__));
2563 break;
2564 case IW_ENCODE_ALG_WEP:
2565 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_ENCODE_ALG_WEP - ext->key_len = %d, keyIdx = %d\n", __func__, ext->key_len, keyIdx));
2566 if (ext->key_len == MAX_WEP_KEY_SIZE)
2567 {
2568 pAdapter->SharedKey[BSS0][keyIdx].KeyLen = MAX_WEP_KEY_SIZE;
2569 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CIPHER_WEP128;
2570 }
2571 else if (ext->key_len == MIN_WEP_KEY_SIZE)
2572 {
2573 pAdapter->SharedKey[BSS0][keyIdx].KeyLen = MIN_WEP_KEY_SIZE;
2574 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CIPHER_WEP64;
2575 }
2576 else
2577 return -EINVAL;
2578
2579 NdisZeroMemory(pAdapter->SharedKey[BSS0][keyIdx].Key, 16);
2580 NdisMoveMemory(pAdapter->SharedKey[BSS0][keyIdx].Key, ext->key, ext->key_len);
2581#ifndef RT30xx
2582 if (pAdapter->StaCfg.GroupCipher == Ndis802_11GroupWEP40Enabled ||
2583 pAdapter->StaCfg.GroupCipher == Ndis802_11GroupWEP104Enabled)
2584 {
2585 // Set Group key material to Asic
2586 AsicAddSharedKeyEntry(pAdapter, BSS0, keyIdx, pAdapter->SharedKey[BSS0][keyIdx].CipherAlg, pAdapter->SharedKey[BSS0][keyIdx].Key, NULL, NULL);
2587
2588 // Update WCID attribute table and IVEIV table for this group key table
2589 RTMPAddWcidAttributeEntry(pAdapter, BSS0, keyIdx, pAdapter->SharedKey[BSS0][keyIdx].CipherAlg, NULL);
2590
2591 STA_PORT_SECURED(pAdapter);
2592
2593 // Indicate Connected for GUI
2594 pAdapter->IndicateMediaState = NdisMediaStateConnected;
2595 }
2596#endif
2597 break;
2598 case IW_ENCODE_ALG_TKIP:
2599 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_ENCODE_ALG_TKIP - keyIdx = %d, ext->key_len = %d\n", __func__, keyIdx, ext->key_len));
2600 if (ext->key_len == 32)
2601 {
2602 if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
2603 {
2604 fnSetCipherKey(pAdapter, keyIdx, CIPHER_TKIP, FALSE, ext);
2605 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA2)
2606 {
2607 STA_PORT_SECURED(pAdapter);
2608 }
2609 }
2610 else if (ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY)
2611 {
2612 fnSetCipherKey(pAdapter, keyIdx, CIPHER_TKIP, TRUE, ext);
2613
2614 // set 802.1x port control
2615 STA_PORT_SECURED(pAdapter);
2616 }
2617 }
2618 else
2619 return -EINVAL;
2620 break;
2621 case IW_ENCODE_ALG_CCMP:
2622 if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
2623 {
2624 fnSetCipherKey(pAdapter, keyIdx, CIPHER_AES, FALSE, ext);
2625 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA2)
2626 STA_PORT_SECURED(pAdapter);
2627 }
2628 else if (ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY)
2629 {
2630 fnSetCipherKey(pAdapter, keyIdx, CIPHER_AES, TRUE, ext);
2631
2632 // set 802.1x port control
2633 STA_PORT_SECURED(pAdapter);
2634 }
2635 break;
2636 default:
2637 return -EINVAL;
2638 }
2639 }
2640
2641 return 0;
2642}
2643
2644int
2645rt_ioctl_giwencodeext(struct net_device *dev,
2646 struct iw_request_info *info,
2647 union iwreq_data *wrqu, char *extra)
2648{
2649 PRTMP_ADAPTER pAd = dev->ml_priv;
2650 PCHAR pKey = NULL;
2651 struct iw_point *encoding = &wrqu->encoding;
2652 struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
2653 int idx, max_key_len;
2654
2655 DBGPRINT(RT_DEBUG_TRACE ,("===> rt_ioctl_giwencodeext\n"));
2656
2657 max_key_len = encoding->length - sizeof(*ext);
2658 if (max_key_len < 0)
2659 return -EINVAL;
2660
2661 idx = encoding->flags & IW_ENCODE_INDEX;
2662 if (idx)
2663 {
2664 if (idx < 1 || idx > 4)
2665 return -EINVAL;
2666 idx--;
2667
2668 if ((pAd->StaCfg.WepStatus == Ndis802_11Encryption2Enabled) ||
2669 (pAd->StaCfg.WepStatus == Ndis802_11Encryption3Enabled))
2670 {
2671 if (idx != pAd->StaCfg.DefaultKeyId)
2672 {
2673 ext->key_len = 0;
2674 return 0;
2675 }
2676 }
2677 }
2678 else
2679 idx = pAd->StaCfg.DefaultKeyId;
2680
2681 encoding->flags = idx + 1;
2682 memset(ext, 0, sizeof(*ext));
2683
2684 ext->key_len = 0;
2685 switch(pAd->StaCfg.WepStatus) {
2686 case Ndis802_11WEPDisabled:
2687 ext->alg = IW_ENCODE_ALG_NONE;
2688 encoding->flags |= IW_ENCODE_DISABLED;
2689 break;
2690 case Ndis802_11WEPEnabled:
2691 ext->alg = IW_ENCODE_ALG_WEP;
2692 if (pAd->SharedKey[BSS0][idx].KeyLen > max_key_len)
2693 return -E2BIG;
2694 else
2695 {
2696 ext->key_len = pAd->SharedKey[BSS0][idx].KeyLen;
2697 pKey = &(pAd->SharedKey[BSS0][idx].Key[0]);
2698 }
2699 break;
2700 case Ndis802_11Encryption2Enabled:
2701 case Ndis802_11Encryption3Enabled:
2702 if (pAd->StaCfg.WepStatus == Ndis802_11Encryption2Enabled)
2703 ext->alg = IW_ENCODE_ALG_TKIP;
2704 else
2705 ext->alg = IW_ENCODE_ALG_CCMP;
2706
2707 if (max_key_len < 32)
2708 return -E2BIG;
2709 else
2710 {
2711 ext->key_len = 32;
2712 pKey = &pAd->StaCfg.PMK[0];
2713 }
2714 break;
2715 default:
2716 return -EINVAL;
2717 }
2718
2719 if (ext->key_len && pKey)
2720 {
2721 encoding->flags |= IW_ENCODE_ENABLED;
2722 memcpy(ext->key, pKey, ext->key_len);
2723 }
2724
2725 return 0;
2726}
2727
2728#ifdef SIOCSIWGENIE
2729int rt_ioctl_siwgenie(struct net_device *dev,
2730 struct iw_request_info *info,
2731 union iwreq_data *wrqu, char *extra)
2732{
2733 PRTMP_ADAPTER pAd = dev->ml_priv;
2734
2735 if (wrqu->data.length > MAX_LEN_OF_RSNIE ||
2736 (wrqu->data.length && extra == NULL))
2737 return -EINVAL;
2738
2739 if (wrqu->data.length)
2740 {
2741 pAd->StaCfg.RSNIE_Len = wrqu->data.length;
2742 NdisMoveMemory(&pAd->StaCfg.RSN_IE[0], extra, pAd->StaCfg.RSNIE_Len);
2743 }
2744 else
2745 {
2746 pAd->StaCfg.RSNIE_Len = 0;
2747 NdisZeroMemory(&pAd->StaCfg.RSN_IE[0], MAX_LEN_OF_RSNIE);
2748 }
2749
2750 return 0;
2751}
2752#endif // SIOCSIWGENIE //
2753
2754int rt_ioctl_giwgenie(struct net_device *dev,
2755 struct iw_request_info *info,
2756 union iwreq_data *wrqu, char *extra)
2757{
2758 PRTMP_ADAPTER pAd = dev->ml_priv;
2759
2760 if ((pAd->StaCfg.RSNIE_Len == 0) ||
2761 (pAd->StaCfg.AuthMode < Ndis802_11AuthModeWPA))
2762 {
2763 wrqu->data.length = 0;
2764 return 0;
2765 }
2766
2767#ifdef SIOCSIWGENIE
2768 if (pAd->StaCfg.WpaSupplicantUP == WPA_SUPPLICANT_ENABLE)
2769 {
2770 if (wrqu->data.length < pAd->StaCfg.RSNIE_Len)
2771 return -E2BIG;
2772
2773 wrqu->data.length = pAd->StaCfg.RSNIE_Len;
2774 memcpy(extra, &pAd->StaCfg.RSN_IE[0], pAd->StaCfg.RSNIE_Len);
2775 }
2776 else
2777#endif // SIOCSIWGENIE //
2778 {
2779 UCHAR RSNIe = IE_WPA;
2780
2781 if (wrqu->data.length < (pAd->StaCfg.RSNIE_Len + 2)) // ID, Len
2782 return -E2BIG;
2783 wrqu->data.length = pAd->StaCfg.RSNIE_Len + 2;
2784
2785 if ((pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK) ||
2786 (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2))
2787 RSNIe = IE_RSN;
2788
2789 extra[0] = (char)RSNIe;
2790 extra[1] = pAd->StaCfg.RSNIE_Len;
2791 memcpy(extra+2, &pAd->StaCfg.RSN_IE[0], pAd->StaCfg.RSNIE_Len);
2792 }
2793
2794 return 0;
2795}
2796
2797int rt_ioctl_siwpmksa(struct net_device *dev,
2798 struct iw_request_info *info,
2799 union iwreq_data *wrqu,
2800 char *extra)
2801{
2802 PRTMP_ADAPTER pAd = dev->ml_priv;
2803 struct iw_pmksa *pPmksa = (struct iw_pmksa *)wrqu->data.pointer;
2804 INT CachedIdx = 0, idx = 0;
2805
2806 if (pPmksa == NULL)
2807 return -EINVAL;
2808
2809 DBGPRINT(RT_DEBUG_TRACE ,("===> rt_ioctl_siwpmksa\n"));
2810 switch(pPmksa->cmd)
2811 {
2812 case IW_PMKSA_FLUSH:
2813 NdisZeroMemory(pAd->StaCfg.SavedPMK, sizeof(BSSID_INFO)*PMKID_NO);
2814 DBGPRINT(RT_DEBUG_TRACE ,("rt_ioctl_siwpmksa - IW_PMKSA_FLUSH\n"));
2815 break;
2816 case IW_PMKSA_REMOVE:
2817 for (CachedIdx = 0; CachedIdx < pAd->StaCfg.SavedPMKNum; CachedIdx++)
2818 {
2819 // compare the BSSID
2820 if (NdisEqualMemory(pPmksa->bssid.sa_data, pAd->StaCfg.SavedPMK[CachedIdx].BSSID, MAC_ADDR_LEN))
2821 {
2822 NdisZeroMemory(pAd->StaCfg.SavedPMK[CachedIdx].BSSID, MAC_ADDR_LEN);
2823 NdisZeroMemory(pAd->StaCfg.SavedPMK[CachedIdx].PMKID, 16);
2824 for (idx = CachedIdx; idx < (pAd->StaCfg.SavedPMKNum - 1); idx++)
2825 {
2826 NdisMoveMemory(&pAd->StaCfg.SavedPMK[idx].BSSID[0], &pAd->StaCfg.SavedPMK[idx+1].BSSID[0], MAC_ADDR_LEN);
2827 NdisMoveMemory(&pAd->StaCfg.SavedPMK[idx].PMKID[0], &pAd->StaCfg.SavedPMK[idx+1].PMKID[0], 16);
2828 }
2829 pAd->StaCfg.SavedPMKNum--;
2830 break;
2831 }
2832 }
2833
2834 DBGPRINT(RT_DEBUG_TRACE ,("rt_ioctl_siwpmksa - IW_PMKSA_REMOVE\n"));
2835 break;
2836 case IW_PMKSA_ADD:
2837 for (CachedIdx = 0; CachedIdx < pAd->StaCfg.SavedPMKNum; CachedIdx++)
2838 {
2839 // compare the BSSID
2840 if (NdisEqualMemory(pPmksa->bssid.sa_data, pAd->StaCfg.SavedPMK[CachedIdx].BSSID, MAC_ADDR_LEN))
2841 break;
2842 }
2843
2844 // Found, replace it
2845 if (CachedIdx < PMKID_NO)
2846 {
2847 DBGPRINT(RT_DEBUG_OFF, ("Update PMKID, idx = %d\n", CachedIdx));
2848 NdisMoveMemory(&pAd->StaCfg.SavedPMK[CachedIdx].BSSID[0], pPmksa->bssid.sa_data, MAC_ADDR_LEN);
2849 NdisMoveMemory(&pAd->StaCfg.SavedPMK[CachedIdx].PMKID[0], pPmksa->pmkid, 16);
2850 pAd->StaCfg.SavedPMKNum++;
2851 }
2852 // Not found, replace the last one
2853 else
2854 {
2855 // Randomly replace one
2856 CachedIdx = (pPmksa->bssid.sa_data[5] % PMKID_NO);
2857 DBGPRINT(RT_DEBUG_OFF, ("Update PMKID, idx = %d\n", CachedIdx));
2858 NdisMoveMemory(&pAd->StaCfg.SavedPMK[CachedIdx].BSSID[0], pPmksa->bssid.sa_data, MAC_ADDR_LEN);
2859 NdisMoveMemory(&pAd->StaCfg.SavedPMK[CachedIdx].PMKID[0], pPmksa->pmkid, 16);
2860 }
2861
2862 DBGPRINT(RT_DEBUG_TRACE ,("rt_ioctl_siwpmksa - IW_PMKSA_ADD\n"));
2863 break;
2864 default:
2865 DBGPRINT(RT_DEBUG_TRACE ,("rt_ioctl_siwpmksa - Unknow Command!!\n"));
2866 break;
2867 }
2868
2869 return 0;
2870}
2871#endif // #if WIRELESS_EXT > 17
2872
2873#ifdef DBG
2874static int
2875rt_private_ioctl_bbp(struct net_device *dev, struct iw_request_info *info,
2876 struct iw_point *wrq, char *extra)
2877 {
2878 CHAR *this_char;
2879 CHAR *value = NULL;
2880 UCHAR regBBP = 0;
2881 UINT32 bbpId;
2882 UINT32 bbpValue;
2883 BOOLEAN bIsPrintAllBBP = FALSE;
2884 INT Status = 0;
2885 PRTMP_ADAPTER pAdapter = dev->ml_priv;
2886
2887
2888 memset(extra, 0x00, IW_PRIV_SIZE_MASK);
2889
2890 if (wrq->length > 1) //No parameters.
2891 {
2892 sprintf(extra, "\n");
2893
2894 //Parsing Read or Write
2895 this_char = wrq->pointer;
2896 DBGPRINT(RT_DEBUG_TRACE, ("this_char=%s\n", this_char));
2897 if (!*this_char)
2898 goto next;
2899
2900 if ((value = rtstrchr(this_char, '=')) != NULL)
2901 *value++ = 0;
2902
2903 if (!value || !*value)
2904 { //Read
2905 DBGPRINT(RT_DEBUG_TRACE, ("this_char=%s, value=%s\n", this_char, value));
2906 if (sscanf(this_char, "%d", &(bbpId)) == 1)
2907 {
2908#ifndef RT30xx
2909 if (bbpId <= 136)
2910#endif // RT30xx //
2911#ifdef RT30xx
2912 if (bbpId <= 138) // edit by johnli, RF power sequence setup, add BBP R138 for ADC dynamic on/off control
2913#endif // RT30xx //
2914 {
2915 {
2916 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, &regBBP);
2917 }
2918 sprintf(extra+strlen(extra), "R%02d[0x%02X]:%02X\n", bbpId, bbpId*2, regBBP);
2919 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2920 DBGPRINT(RT_DEBUG_TRACE, ("msg=%s\n", extra));
2921 }
2922 else
2923 {//Invalid parametes, so default printk all bbp
2924 bIsPrintAllBBP = TRUE;
2925 goto next;
2926 }
2927 }
2928 else
2929 { //Invalid parametes, so default printk all bbp
2930 bIsPrintAllBBP = TRUE;
2931 goto next;
2932 }
2933 }
2934 else
2935 { //Write
2936 if ((sscanf(this_char, "%d", &(bbpId)) == 1) && (sscanf(value, "%x", &(bbpValue)) == 1))
2937 {
2938#ifndef RT30xx
2939 if (bbpId <= 136)
2940#endif // RT30xx //
2941#ifdef RT30xx
2942 if (bbpId <= 138) // edit by johnli, RF power sequence setup, add BBP R138 for ADC dynamic on/off control
2943#endif // RT30xx //
2944 {
2945 {
2946 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, bbpId, bbpValue);
2947 //Read it back for showing
2948 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, &regBBP);
2949 }
2950 sprintf(extra+strlen(extra), "R%02d[0x%02X]:%02X\n", bbpId, bbpId*2, regBBP);
2951 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2952 DBGPRINT(RT_DEBUG_TRACE, ("msg=%s\n", extra));
2953 }
2954 else
2955 {//Invalid parametes, so default printk all bbp
2956 bIsPrintAllBBP = TRUE;
2957 goto next;
2958 }
2959 }
2960 else
2961 { //Invalid parametes, so default printk all bbp
2962 bIsPrintAllBBP = TRUE;
2963 goto next;
2964 }
2965 }
2966 }
2967 else
2968 bIsPrintAllBBP = TRUE;
2969
2970next:
2971 if (bIsPrintAllBBP)
2972 {
2973 memset(extra, 0x00, IW_PRIV_SIZE_MASK);
2974 sprintf(extra, "\n");
2975#ifndef RT30xx
2976 for (bbpId = 0; bbpId <= 136; bbpId++)
2977#endif // RT30xx //
2978#ifdef RT30xx
2979 for (bbpId = 0; bbpId <= 138; bbpId++) // edit by johnli, RF power sequence setup, add BBP R138 for ADC dynamic on/off control
2980#endif // RT30xx //
2981 {
2982 if (strlen(extra) >= (IW_PRIV_SIZE_MASK - 10))
2983 break;
2984 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, &regBBP);
2985#ifndef RT30xx
2986 sprintf(extra+strlen(extra), "R%02d[0x%02X]:%02X ", bbpId, bbpId*2, regBBP);
2987 if (bbpId%5 == 4)
2988 sprintf(extra+strlen(extra), "\n");
2989#endif
2990#ifdef RT30xx
2991 sprintf(extra+strlen(extra), "%03d = %02X\n", bbpId, regBBP); // edit by johnli, change display format
2992#endif
2993 }
2994
2995 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2996 DBGPRINT(RT_DEBUG_TRACE, ("wrq->length = %d\n", wrq->length));
2997 }
2998
2999 DBGPRINT(RT_DEBUG_TRACE, ("<==rt_private_ioctl_bbp\n\n"));
3000
3001 return Status;
3002}
3003#endif // DBG //
3004
3005int rt_ioctl_siwrate(struct net_device *dev,
3006 struct iw_request_info *info,
3007 union iwreq_data *wrqu, char *extra)
3008{
3009 PRTMP_ADAPTER pAd = dev->ml_priv;
3010 UINT32 rate = wrqu->bitrate.value, fixed = wrqu->bitrate.fixed;
3011
3012 //check if the interface is down
3013 if(!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_IN_USE))
3014 {
3015 DBGPRINT(RT_DEBUG_TRACE, ("rt_ioctl_siwrate::Network is down!\n"));
3016 return -ENETDOWN;
3017 }
3018
3019 DBGPRINT(RT_DEBUG_TRACE, ("rt_ioctl_siwrate::(rate = %d, fixed = %d)\n", rate, fixed));
3020 /* rate = -1 => auto rate
3021 rate = X, fixed = 1 => (fixed rate X)
3022 */
3023 if (rate == -1)
3024 {
3025 //Auto Rate
3026 pAd->StaCfg.DesiredTransmitSetting.field.MCS = MCS_AUTO;
3027 pAd->StaCfg.bAutoTxRateSwitch = TRUE;
3028 if ((pAd->CommonCfg.PhyMode <= PHY_11G) ||
3029 (pAd->MacTab.Content[BSSID_WCID].HTPhyMode.field.MODE <= MODE_OFDM))
3030 RTMPSetDesiredRates(pAd, -1);
3031
3032 SetCommonHT(pAd);
3033 }
3034 else
3035 {
3036 if (fixed)
3037 {
3038 pAd->StaCfg.bAutoTxRateSwitch = FALSE;
3039 if ((pAd->CommonCfg.PhyMode <= PHY_11G) ||
3040 (pAd->MacTab.Content[BSSID_WCID].HTPhyMode.field.MODE <= MODE_OFDM))
3041 RTMPSetDesiredRates(pAd, rate);
3042 else
3043 {
3044 pAd->StaCfg.DesiredTransmitSetting.field.MCS = MCS_AUTO;
3045 SetCommonHT(pAd);
3046 }
3047 DBGPRINT(RT_DEBUG_TRACE, ("rt_ioctl_siwrate::(HtMcs=%d)\n",pAd->StaCfg.DesiredTransmitSetting.field.MCS));
3048 }
3049 else
3050 {
3051 // TODO: rate = X, fixed = 0 => (rates <= X)
3052 return -EOPNOTSUPP;
3053 }
3054 }
3055
3056 return 0;
3057}
3058
3059int rt_ioctl_giwrate(struct net_device *dev,
3060 struct iw_request_info *info,
3061 union iwreq_data *wrqu, char *extra)
3062{
3063 PRTMP_ADAPTER pAd = dev->ml_priv;
3064 int rate_index = 0, rate_count = 0;
3065 HTTRANSMIT_SETTING ht_setting;
3066 __s32 ralinkrate[] =
3067 {2, 4, 11, 22, // CCK
3068 12, 18, 24, 36, 48, 72, 96, 108, // OFDM
3069 13, 26, 39, 52, 78, 104, 117, 130, 26, 52, 78, 104, 156, 208, 234, 260, // 20MHz, 800ns GI, MCS: 0 ~ 15
3070 39, 78, 117, 156, 234, 312, 351, 390, // 20MHz, 800ns GI, MCS: 16 ~ 23
3071 27, 54, 81, 108, 162, 216, 243, 270, 54, 108, 162, 216, 324, 432, 486, 540, // 40MHz, 800ns GI, MCS: 0 ~ 15
3072 81, 162, 243, 324, 486, 648, 729, 810, // 40MHz, 800ns GI, MCS: 16 ~ 23
3073 14, 29, 43, 57, 87, 115, 130, 144, 29, 59, 87, 115, 173, 230, 260, 288, // 20MHz, 400ns GI, MCS: 0 ~ 15
3074 43, 87, 130, 173, 260, 317, 390, 433, // 20MHz, 400ns GI, MCS: 16 ~ 23
3075 30, 60, 90, 120, 180, 240, 270, 300, 60, 120, 180, 240, 360, 480, 540, 600, // 40MHz, 400ns GI, MCS: 0 ~ 15
3076 90, 180, 270, 360, 540, 720, 810, 900}; // 40MHz, 400ns GI, MCS: 16 ~ 23
3077
3078 rate_count = sizeof(ralinkrate)/sizeof(__s32);
3079 //check if the interface is down
3080 if(!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_IN_USE))
3081 {
3082 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
3083 return -ENETDOWN;
3084 }
3085
3086 if ((pAd->StaCfg.bAutoTxRateSwitch == FALSE) &&
3087 (INFRA_ON(pAd)) &&
3088 ((pAd->CommonCfg.PhyMode <= PHY_11G) || (pAd->MacTab.Content[BSSID_WCID].HTPhyMode.field.MODE <= MODE_OFDM)))
3089 ht_setting.word = pAd->StaCfg.HTPhyMode.word;
3090 else
3091 ht_setting.word = pAd->MacTab.Content[BSSID_WCID].HTPhyMode.word;
3092
3093 if (ht_setting.field.MODE >= MODE_HTMIX)
3094 {
3095 rate_index = 12 + ((UCHAR)ht_setting.field.BW *24) + ((UCHAR)ht_setting.field.ShortGI *48) + ((UCHAR)ht_setting.field.MCS);
3096 }
3097 else
3098 if (ht_setting.field.MODE == MODE_OFDM)
3099 rate_index = (UCHAR)(ht_setting.field.MCS) + 4;
3100 else if (ht_setting.field.MODE == MODE_CCK)
3101 rate_index = (UCHAR)(ht_setting.field.MCS);
3102
3103 if (rate_index < 0)
3104 rate_index = 0;
3105
3106 if (rate_index > rate_count)
3107 rate_index = rate_count;
3108
3109 wrqu->bitrate.value = ralinkrate[rate_index] * 500000;
3110 wrqu->bitrate.disabled = 0;
3111
3112 return 0;
3113}
3114
3115static const iw_handler rt_handler[] =
3116{
3117 (iw_handler) NULL, /* SIOCSIWCOMMIT */
3118 (iw_handler) rt_ioctl_giwname, /* SIOCGIWNAME */
3119 (iw_handler) NULL, /* SIOCSIWNWID */
3120 (iw_handler) NULL, /* SIOCGIWNWID */
3121 (iw_handler) rt_ioctl_siwfreq, /* SIOCSIWFREQ */
3122 (iw_handler) rt_ioctl_giwfreq, /* SIOCGIWFREQ */
3123 (iw_handler) rt_ioctl_siwmode, /* SIOCSIWMODE */
3124 (iw_handler) rt_ioctl_giwmode, /* SIOCGIWMODE */
3125 (iw_handler) NULL, /* SIOCSIWSENS */
3126 (iw_handler) NULL, /* SIOCGIWSENS */
3127 (iw_handler) NULL /* not used */, /* SIOCSIWRANGE */
3128 (iw_handler) rt_ioctl_giwrange, /* SIOCGIWRANGE */
3129 (iw_handler) NULL /* not used */, /* SIOCSIWPRIV */
3130 (iw_handler) NULL /* kernel code */, /* SIOCGIWPRIV */
3131 (iw_handler) NULL /* not used */, /* SIOCSIWSTATS */
3132 (iw_handler) rt28xx_get_wireless_stats /* kernel code */, /* SIOCGIWSTATS */
3133 (iw_handler) NULL, /* SIOCSIWSPY */
3134 (iw_handler) NULL, /* SIOCGIWSPY */
3135 (iw_handler) NULL, /* SIOCSIWTHRSPY */
3136 (iw_handler) NULL, /* SIOCGIWTHRSPY */
3137 (iw_handler) rt_ioctl_siwap, /* SIOCSIWAP */
3138 (iw_handler) rt_ioctl_giwap, /* SIOCGIWAP */
3139#ifdef SIOCSIWMLME
3140 (iw_handler) rt_ioctl_siwmlme, /* SIOCSIWMLME */
3141#else
3142 (iw_handler) NULL, /* SIOCSIWMLME */
3143#endif // SIOCSIWMLME //
3144 (iw_handler) rt_ioctl_iwaplist, /* SIOCGIWAPLIST */
3145#ifdef SIOCGIWSCAN
3146 (iw_handler) rt_ioctl_siwscan, /* SIOCSIWSCAN */
3147 (iw_handler) rt_ioctl_giwscan, /* SIOCGIWSCAN */
3148#else
3149 (iw_handler) NULL, /* SIOCSIWSCAN */
3150 (iw_handler) NULL, /* SIOCGIWSCAN */
3151#endif /* SIOCGIWSCAN */
3152 (iw_handler) rt_ioctl_siwessid, /* SIOCSIWESSID */
3153 (iw_handler) rt_ioctl_giwessid, /* SIOCGIWESSID */
3154 (iw_handler) rt_ioctl_siwnickn, /* SIOCSIWNICKN */
3155 (iw_handler) rt_ioctl_giwnickn, /* SIOCGIWNICKN */
3156 (iw_handler) NULL, /* -- hole -- */
3157 (iw_handler) NULL, /* -- hole -- */
3158 (iw_handler) rt_ioctl_siwrate, /* SIOCSIWRATE */
3159 (iw_handler) rt_ioctl_giwrate, /* SIOCGIWRATE */
3160 (iw_handler) rt_ioctl_siwrts, /* SIOCSIWRTS */
3161 (iw_handler) rt_ioctl_giwrts, /* SIOCGIWRTS */
3162 (iw_handler) rt_ioctl_siwfrag, /* SIOCSIWFRAG */
3163 (iw_handler) rt_ioctl_giwfrag, /* SIOCGIWFRAG */
3164 (iw_handler) NULL, /* SIOCSIWTXPOW */
3165 (iw_handler) NULL, /* SIOCGIWTXPOW */
3166 (iw_handler) NULL, /* SIOCSIWRETRY */
3167 (iw_handler) NULL, /* SIOCGIWRETRY */
3168 (iw_handler) rt_ioctl_siwencode, /* SIOCSIWENCODE */
3169 (iw_handler) rt_ioctl_giwencode, /* SIOCGIWENCODE */
3170 (iw_handler) NULL, /* SIOCSIWPOWER */
3171 (iw_handler) NULL, /* SIOCGIWPOWER */
3172 (iw_handler) NULL, /* -- hole -- */
3173 (iw_handler) NULL, /* -- hole -- */
3174#if WIRELESS_EXT > 17
3175 (iw_handler) rt_ioctl_siwgenie, /* SIOCSIWGENIE */
3176 (iw_handler) rt_ioctl_giwgenie, /* SIOCGIWGENIE */
3177 (iw_handler) rt_ioctl_siwauth, /* SIOCSIWAUTH */
3178 (iw_handler) rt_ioctl_giwauth, /* SIOCGIWAUTH */
3179 (iw_handler) rt_ioctl_siwencodeext, /* SIOCSIWENCODEEXT */
3180 (iw_handler) rt_ioctl_giwencodeext, /* SIOCGIWENCODEEXT */
3181 (iw_handler) rt_ioctl_siwpmksa, /* SIOCSIWPMKSA */
3182#endif
3183};
3184
3185static const iw_handler rt_priv_handlers[] = {
3186 (iw_handler) NULL, /* + 0x00 */
3187 (iw_handler) NULL, /* + 0x01 */
3188 (iw_handler) rt_ioctl_setparam, /* + 0x02 */
3189#ifdef DBG
3190 (iw_handler) rt_private_ioctl_bbp, /* + 0x03 */
3191#else
3192 (iw_handler) NULL, /* + 0x03 */
3193#endif
3194 (iw_handler) NULL, /* + 0x04 */
3195 (iw_handler) NULL, /* + 0x05 */
3196 (iw_handler) NULL, /* + 0x06 */
3197 (iw_handler) NULL, /* + 0x07 */
3198 (iw_handler) NULL, /* + 0x08 */
3199 (iw_handler) rt_private_get_statistics, /* + 0x09 */
3200 (iw_handler) NULL, /* + 0x0A */
3201 (iw_handler) NULL, /* + 0x0B */
3202 (iw_handler) NULL, /* + 0x0C */
3203 (iw_handler) NULL, /* + 0x0D */
3204 (iw_handler) NULL, /* + 0x0E */
3205 (iw_handler) NULL, /* + 0x0F */
3206 (iw_handler) NULL, /* + 0x10 */
3207 (iw_handler) rt_private_show, /* + 0x11 */
3208 (iw_handler) NULL, /* + 0x12 */
3209 (iw_handler) NULL, /* + 0x13 */
3210 (iw_handler) NULL, /* + 0x15 */
3211 (iw_handler) NULL, /* + 0x17 */
3212 (iw_handler) NULL, /* + 0x18 */
3213};
3214
3215const struct iw_handler_def rt28xx_iw_handler_def =
3216{
3217#define N(a) (sizeof (a) / sizeof (a[0]))
3218 .standard = (iw_handler *) rt_handler,
3219 .num_standard = sizeof(rt_handler) / sizeof(iw_handler),
3220 .private = (iw_handler *) rt_priv_handlers,
3221 .num_private = N(rt_priv_handlers),
3222 .private_args = (struct iw_priv_args *) privtab,
3223 .num_private_args = N(privtab),
3224#if IW_HANDLER_VERSION >= 7
3225 .get_wireless_stats = rt28xx_get_wireless_stats,
3226#endif
3227};
3228
3229INT RTMPSetInformation(
3230 IN PRTMP_ADAPTER pAdapter,
3231 IN OUT struct ifreq *rq,
3232 IN INT cmd)
3233{
3234 struct iwreq *wrq = (struct iwreq *) rq;
3235 NDIS_802_11_SSID Ssid;
3236 NDIS_802_11_MAC_ADDRESS Bssid;
3237 RT_802_11_PHY_MODE PhyMode;
3238 RT_802_11_STA_CONFIG StaConfig;
3239 NDIS_802_11_RATES aryRates;
3240 RT_802_11_PREAMBLE Preamble;
3241 NDIS_802_11_WEP_STATUS WepStatus;
3242 NDIS_802_11_AUTHENTICATION_MODE AuthMode = Ndis802_11AuthModeMax;
3243 NDIS_802_11_NETWORK_INFRASTRUCTURE BssType;
3244 NDIS_802_11_RTS_THRESHOLD RtsThresh;
3245 NDIS_802_11_FRAGMENTATION_THRESHOLD FragThresh;
3246 NDIS_802_11_POWER_MODE PowerMode;
3247 PNDIS_802_11_KEY pKey = NULL;
3248 PNDIS_802_11_WEP pWepKey =NULL;
3249 PNDIS_802_11_REMOVE_KEY pRemoveKey = NULL;
3250 NDIS_802_11_CONFIGURATION Config, *pConfig = NULL;
3251 NDIS_802_11_NETWORK_TYPE NetType;
3252 ULONG Now;
3253 UINT KeyIdx = 0;
3254 INT Status = NDIS_STATUS_SUCCESS, MaxPhyMode = PHY_11G;
3255 ULONG PowerTemp;
3256 BOOLEAN RadioState;
3257 BOOLEAN StateMachineTouched = FALSE;
3258 OID_SET_HT_PHYMODE HT_PhyMode; //11n ,kathy
3259 PNDIS_802_11_PMKID pPmkId = NULL;
3260 BOOLEAN IEEE8021xState = FALSE;
3261 BOOLEAN IEEE8021x_required_keys = FALSE;
3262 UCHAR wpa_supplicant_enable = 0;
3263
3264 MaxPhyMode = PHY_11N_5G;
3265
3266 DBGPRINT(RT_DEBUG_TRACE, ("-->RTMPSetInformation(), 0x%08x\n", cmd&0x7FFF));
3267 switch(cmd & 0x7FFF) {
3268 case RT_OID_802_11_COUNTRY_REGION:
3269 if (wrq->u.data.length < sizeof(UCHAR))
3270 Status = -EINVAL;
3271 // Only avaliable when EEPROM not programming
3272 else if (!(pAdapter->CommonCfg.CountryRegion & 0x80) && !(pAdapter->CommonCfg.CountryRegionForABand & 0x80))
3273 {
3274 ULONG Country;
3275 UCHAR TmpPhy;
3276
3277 Status = copy_from_user(&Country, wrq->u.data.pointer, wrq->u.data.length);
3278 pAdapter->CommonCfg.CountryRegion = (UCHAR)(Country & 0x000000FF);
3279 pAdapter->CommonCfg.CountryRegionForABand = (UCHAR)((Country >> 8) & 0x000000FF);
3280 TmpPhy = pAdapter->CommonCfg.PhyMode;
3281 pAdapter->CommonCfg.PhyMode = 0xff;
3282 // Build all corresponding channel information
3283 RTMPSetPhyMode(pAdapter, TmpPhy);
3284 SetCommonHT(pAdapter);
3285 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_COUNTRY_REGION (A:%d B/G:%d)\n", pAdapter->CommonCfg.CountryRegionForABand,
3286 pAdapter->CommonCfg.CountryRegion));
3287 }
3288 break;
3289 case OID_802_11_BSSID_LIST_SCAN:
3290 Now = jiffies;
3291 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_BSSID_LIST_SCAN, TxCnt = %d \n", pAdapter->RalinkCounters.LastOneSecTotalTxCount));
3292
3293 if (MONITOR_ON(pAdapter))
3294 {
3295 DBGPRINT(RT_DEBUG_TRACE, ("!!! Driver is in Monitor Mode now !!!\n"));
3296 break;
3297 }
3298
3299 //Benson add 20080527, when radio off, sta don't need to scan
3300 if (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_RADIO_OFF))
3301 break;
3302
3303 if (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
3304 {
3305 DBGPRINT(RT_DEBUG_TRACE, ("!!! Driver is scanning now !!!\n"));
3306 pAdapter->StaCfg.bScanReqIsFromWebUI = TRUE;
3307 Status = NDIS_STATUS_SUCCESS;
3308 break;
3309 }
3310
3311 if (pAdapter->RalinkCounters.LastOneSecTotalTxCount > 100)
3312 {
3313 DBGPRINT(RT_DEBUG_TRACE, ("!!! Link UP, ignore this set::OID_802_11_BSSID_LIST_SCAN\n"));
3314 Status = NDIS_STATUS_SUCCESS;
3315 pAdapter->StaCfg.ScanCnt = 99; // Prevent auto scan triggered by this OID
3316 break;
3317 }
3318
3319 if ((OPSTATUS_TEST_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED)) &&
3320 ((pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA) ||
3321 (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK) ||
3322 (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA2) ||
3323 (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK)) &&
3324 (pAdapter->StaCfg.PortSecured == WPA_802_1X_PORT_NOT_SECURED))
3325 {
3326 DBGPRINT(RT_DEBUG_TRACE, ("!!! Link UP, Port Not Secured! ignore this set::OID_802_11_BSSID_LIST_SCAN\n"));
3327 Status = NDIS_STATUS_SUCCESS;
3328 pAdapter->StaCfg.ScanCnt = 99; // Prevent auto scan triggered by this OID
3329 break;
3330 }
3331
3332
3333 if (pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE)
3334 {
3335 RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
3336 DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
3337 }
3338
3339 // tell CNTL state machine to call NdisMSetInformationComplete() after completing
3340 // this request, because this request is initiated by NDIS.
3341 pAdapter->MlmeAux.CurrReqIsFromNdis = FALSE;
3342 // Reset allowed scan retries
3343 pAdapter->StaCfg.ScanCnt = 0;
3344 pAdapter->StaCfg.LastScanTime = Now;
3345
3346 pAdapter->StaCfg.bScanReqIsFromWebUI = TRUE;
3347 RTMP_SET_FLAG(pAdapter, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS);
3348 MlmeEnqueue(pAdapter,
3349 MLME_CNTL_STATE_MACHINE,
3350 OID_802_11_BSSID_LIST_SCAN,
3351 0,
3352 NULL);
3353
3354 Status = NDIS_STATUS_SUCCESS;
3355 StateMachineTouched = TRUE;
3356 break;
3357 case OID_802_11_SSID:
3358 if (wrq->u.data.length != sizeof(NDIS_802_11_SSID))
3359 Status = -EINVAL;
3360 else
3361 {
3362 PCHAR pSsidString = NULL;
3363 Status = copy_from_user(&Ssid, wrq->u.data.pointer, wrq->u.data.length);
3364
3365 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_SSID (Len=%d,Ssid=%s)\n", Ssid.SsidLength, Ssid.Ssid));
3366 if (Ssid.SsidLength > MAX_LEN_OF_SSID)
3367 Status = -EINVAL;
3368 else
3369 {
3370 if (Ssid.SsidLength == 0)
3371 {
3372 Set_SSID_Proc(pAdapter, "");
3373 }
3374 else
3375 {
3376 pSsidString = (CHAR *) kmalloc(MAX_LEN_OF_SSID+1, MEM_ALLOC_FLAG);
3377 if (pSsidString)
3378 {
3379 NdisZeroMemory(pSsidString, MAX_LEN_OF_SSID+1);
3380 NdisMoveMemory(pSsidString, Ssid.Ssid, Ssid.SsidLength);
3381 Set_SSID_Proc(pAdapter, pSsidString);
3382 kfree(pSsidString);
3383 }
3384 else
3385 Status = -ENOMEM;
3386 }
3387 }
3388 }
3389 break;
3390 case OID_802_11_BSSID:
3391 if (wrq->u.data.length != sizeof(NDIS_802_11_MAC_ADDRESS))
3392 Status = -EINVAL;
3393 else
3394 {
3395 Status = copy_from_user(&Bssid, wrq->u.data.pointer, wrq->u.data.length);
3396
3397 // tell CNTL state machine to call NdisMSetInformationComplete() after completing
3398 // this request, because this request is initiated by NDIS.
3399 pAdapter->MlmeAux.CurrReqIsFromNdis = FALSE;
3400
3401 // Prevent to connect AP again in STAMlmePeriodicExec
3402 pAdapter->MlmeAux.AutoReconnectSsidLen= 32;
3403
3404 // Reset allowed scan retries
3405 pAdapter->StaCfg.ScanCnt = 0;
3406
3407 if (pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE)
3408 {
3409 RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
3410 DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
3411 }
3412 MlmeEnqueue(pAdapter,
3413 MLME_CNTL_STATE_MACHINE,
3414 OID_802_11_BSSID,
3415 sizeof(NDIS_802_11_MAC_ADDRESS),
3416 (VOID *)&Bssid);
3417 Status = NDIS_STATUS_SUCCESS;
3418 StateMachineTouched = TRUE;
3419
3420 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_BSSID %02x:%02x:%02x:%02x:%02x:%02x\n",
3421 Bssid[0], Bssid[1], Bssid[2], Bssid[3], Bssid[4], Bssid[5]));
3422 }
3423 break;
3424 case RT_OID_802_11_RADIO:
3425 if (wrq->u.data.length != sizeof(BOOLEAN))
3426 Status = -EINVAL;
3427 else
3428 {
3429 Status = copy_from_user(&RadioState, wrq->u.data.pointer, wrq->u.data.length);
3430 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_RADIO (=%d)\n", RadioState));
3431 if (pAdapter->StaCfg.bSwRadio != RadioState)
3432 {
3433 pAdapter->StaCfg.bSwRadio = RadioState;
3434 if (pAdapter->StaCfg.bRadio != (pAdapter->StaCfg.bHwRadio && pAdapter->StaCfg.bSwRadio))
3435 {
3436 pAdapter->StaCfg.bRadio = (pAdapter->StaCfg.bHwRadio && pAdapter->StaCfg.bSwRadio);
3437 if (pAdapter->StaCfg.bRadio == TRUE)
3438 {
3439 MlmeRadioOn(pAdapter);
3440 // Update extra information
3441 pAdapter->ExtraInfo = EXTRA_INFO_CLEAR;
3442 }
3443 else
3444 {
3445 MlmeRadioOff(pAdapter);
3446 // Update extra information
3447 pAdapter->ExtraInfo = SW_RADIO_OFF;
3448 }
3449 }
3450 }
3451 }
3452 break;
3453 case RT_OID_802_11_PHY_MODE:
3454 if (wrq->u.data.length != sizeof(RT_802_11_PHY_MODE))
3455 Status = -EINVAL;
3456 else
3457 {
3458 Status = copy_from_user(&PhyMode, wrq->u.data.pointer, wrq->u.data.length);
3459 if (PhyMode <= MaxPhyMode)
3460 {
3461 RTMPSetPhyMode(pAdapter, PhyMode);
3462 SetCommonHT(pAdapter);
3463 }
3464 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_PHY_MODE (=%d)\n", PhyMode));
3465 }
3466 break;
3467 case RT_OID_802_11_STA_CONFIG:
3468 if (wrq->u.data.length != sizeof(RT_802_11_STA_CONFIG))
3469 Status = -EINVAL;
3470 else
3471 {
3472 Status = copy_from_user(&StaConfig, wrq->u.data.pointer, wrq->u.data.length);
3473 pAdapter->CommonCfg.bEnableTxBurst = StaConfig.EnableTxBurst;
3474 pAdapter->CommonCfg.UseBGProtection = StaConfig.UseBGProtection;
3475 pAdapter->CommonCfg.bUseShortSlotTime = 1; // 2003-10-30 always SHORT SLOT capable
3476 if ((pAdapter->CommonCfg.PhyMode != StaConfig.AdhocMode) &&
3477 (StaConfig.AdhocMode <= MaxPhyMode))
3478 {
3479 // allow dynamic change of "USE OFDM rate or not" in ADHOC mode
3480 // if setting changed, need to reset current TX rate as well as BEACON frame format
3481#ifdef RT30xx
3482 pAdapter->CommonCfg.PhyMode = StaConfig.AdhocMode;
3483#endif
3484 if (pAdapter->StaCfg.BssType == BSS_ADHOC)
3485 {
3486#ifndef RT30xx
3487 pAdapter->CommonCfg.PhyMode = StaConfig.AdhocMode;
3488#endif
3489 RTMPSetPhyMode(pAdapter, PhyMode);
3490 MlmeUpdateTxRates(pAdapter, FALSE, 0);
3491 MakeIbssBeacon(pAdapter); // re-build BEACON frame
3492 AsicEnableIbssSync(pAdapter); // copy to on-chip memory
3493 }
3494 }
3495 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_SET_STA_CONFIG (Burst=%d, Protection=%ld,ShortSlot=%d\n",
3496 pAdapter->CommonCfg.bEnableTxBurst,
3497 pAdapter->CommonCfg.UseBGProtection,
3498 pAdapter->CommonCfg.bUseShortSlotTime));
3499 }
3500 break;
3501 case OID_802_11_DESIRED_RATES:
3502 if (wrq->u.data.length != sizeof(NDIS_802_11_RATES))
3503 Status = -EINVAL;
3504 else
3505 {
3506 Status = copy_from_user(&aryRates, wrq->u.data.pointer, wrq->u.data.length);
3507 NdisZeroMemory(pAdapter->CommonCfg.DesireRate, MAX_LEN_OF_SUPPORTED_RATES);
3508 NdisMoveMemory(pAdapter->CommonCfg.DesireRate, &aryRates, sizeof(NDIS_802_11_RATES));
3509 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_DESIRED_RATES (%02x,%02x,%02x,%02x,%02x,%02x,%02x,%02x)\n",
3510 pAdapter->CommonCfg.DesireRate[0],pAdapter->CommonCfg.DesireRate[1],
3511 pAdapter->CommonCfg.DesireRate[2],pAdapter->CommonCfg.DesireRate[3],
3512 pAdapter->CommonCfg.DesireRate[4],pAdapter->CommonCfg.DesireRate[5],
3513 pAdapter->CommonCfg.DesireRate[6],pAdapter->CommonCfg.DesireRate[7] ));
3514 // Changing DesiredRate may affect the MAX TX rate we used to TX frames out
3515 MlmeUpdateTxRates(pAdapter, FALSE, 0);
3516 }
3517 break;
3518 case RT_OID_802_11_PREAMBLE:
3519 if (wrq->u.data.length != sizeof(RT_802_11_PREAMBLE))
3520 Status = -EINVAL;
3521 else
3522 {
3523 Status = copy_from_user(&Preamble, wrq->u.data.pointer, wrq->u.data.length);
3524 if (Preamble == Rt802_11PreambleShort)
3525 {
3526 pAdapter->CommonCfg.TxPreamble = Preamble;
3527 MlmeSetTxPreamble(pAdapter, Rt802_11PreambleShort);
3528 }
3529 else if ((Preamble == Rt802_11PreambleLong) || (Preamble == Rt802_11PreambleAuto))
3530 {
3531 // if user wants AUTO, initialize to LONG here, then change according to AP's
3532 // capability upon association.
3533 pAdapter->CommonCfg.TxPreamble = Preamble;
3534 MlmeSetTxPreamble(pAdapter, Rt802_11PreambleLong);
3535 }
3536 else
3537 {
3538 Status = -EINVAL;
3539 break;
3540 }
3541 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_PREAMBLE (=%d)\n", Preamble));
3542 }
3543 break;
3544 case OID_802_11_WEP_STATUS:
3545 if (wrq->u.data.length != sizeof(NDIS_802_11_WEP_STATUS))
3546 Status = -EINVAL;
3547 else
3548 {
3549 Status = copy_from_user(&WepStatus, wrq->u.data.pointer, wrq->u.data.length);
3550 // Since TKIP, AES, WEP are all supported. It should not have any invalid setting
3551 if (WepStatus <= Ndis802_11Encryption3KeyAbsent)
3552 {
3553 if (pAdapter->StaCfg.WepStatus != WepStatus)
3554 {
3555 // Config has changed
3556 pAdapter->bConfigChanged = TRUE;
3557 }
3558 pAdapter->StaCfg.WepStatus = WepStatus;
3559 pAdapter->StaCfg.OrigWepStatus = WepStatus;
3560 pAdapter->StaCfg.PairCipher = WepStatus;
3561 pAdapter->StaCfg.GroupCipher = WepStatus;
3562 }
3563 else
3564 {
3565 Status = -EINVAL;
3566 break;
3567 }
3568 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_WEP_STATUS (=%d)\n",WepStatus));
3569 }
3570 break;
3571 case OID_802_11_AUTHENTICATION_MODE:
3572 if (wrq->u.data.length != sizeof(NDIS_802_11_AUTHENTICATION_MODE))
3573 Status = -EINVAL;
3574 else
3575 {
3576 Status = copy_from_user(&AuthMode, wrq->u.data.pointer, wrq->u.data.length);
3577 if (AuthMode > Ndis802_11AuthModeMax)
3578 {
3579 Status = -EINVAL;
3580 break;
3581 }
3582 else
3583 {
3584 if (pAdapter->StaCfg.AuthMode != AuthMode)
3585 {
3586 // Config has changed
3587 pAdapter->bConfigChanged = TRUE;
3588 }
3589 pAdapter->StaCfg.AuthMode = AuthMode;
3590 }
3591 pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED;
3592 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_AUTHENTICATION_MODE (=%d) \n",pAdapter->StaCfg.AuthMode));
3593 }
3594 break;
3595 case OID_802_11_INFRASTRUCTURE_MODE:
3596 if (wrq->u.data.length != sizeof(NDIS_802_11_NETWORK_INFRASTRUCTURE))
3597 Status = -EINVAL;
3598 else
3599 {
3600 Status = copy_from_user(&BssType, wrq->u.data.pointer, wrq->u.data.length);
3601
3602 if (BssType == Ndis802_11IBSS)
3603 Set_NetworkType_Proc(pAdapter, "Adhoc");
3604 else if (BssType == Ndis802_11Infrastructure)
3605 Set_NetworkType_Proc(pAdapter, "Infra");
3606 else if (BssType == Ndis802_11Monitor)
3607 Set_NetworkType_Proc(pAdapter, "Monitor");
3608 else
3609 {
3610 Status = -EINVAL;
3611 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_INFRASTRUCTURE_MODE (unknown)\n"));
3612 }
3613 }
3614 break;
3615 case OID_802_11_REMOVE_WEP:
3616 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_WEP\n"));
3617 if (wrq->u.data.length != sizeof(NDIS_802_11_KEY_INDEX))
3618 {
3619 Status = -EINVAL;
3620 }
3621 else
3622 {
3623 KeyIdx = *(NDIS_802_11_KEY_INDEX *) wrq->u.data.pointer;
3624
3625 if (KeyIdx & 0x80000000)
3626 {
3627 // Should never set default bit when remove key
3628 Status = -EINVAL;
3629 }
3630 else
3631 {
3632 KeyIdx = KeyIdx & 0x0fffffff;
3633 if (KeyIdx >= 4){
3634 Status = -EINVAL;
3635 }
3636 else
3637 {
3638 pAdapter->SharedKey[BSS0][KeyIdx].KeyLen = 0;
3639 pAdapter->SharedKey[BSS0][KeyIdx].CipherAlg = CIPHER_NONE;
3640 AsicRemoveSharedKeyEntry(pAdapter, 0, (UCHAR)KeyIdx);
3641 }
3642 }
3643 }
3644 break;
3645 case RT_OID_802_11_RESET_COUNTERS:
3646 NdisZeroMemory(&pAdapter->WlanCounters, sizeof(COUNTER_802_11));
3647 NdisZeroMemory(&pAdapter->Counters8023, sizeof(COUNTER_802_3));
3648 NdisZeroMemory(&pAdapter->RalinkCounters, sizeof(COUNTER_RALINK));
3649 pAdapter->Counters8023.RxNoBuffer = 0;
3650 pAdapter->Counters8023.GoodReceives = 0;
3651 pAdapter->Counters8023.RxNoBuffer = 0;
3652#ifdef RT2870
3653 pAdapter->BulkOutComplete = 0;
3654 pAdapter->BulkOutCompleteOther= 0;
3655 pAdapter->BulkOutCompleteCancel = 0;
3656 pAdapter->BulkOutReq = 0;
3657 pAdapter->BulkInReq= 0;
3658 pAdapter->BulkInComplete = 0;
3659 pAdapter->BulkInCompleteFail = 0;
3660#endif // RT2870 //
3661 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_RESET_COUNTERS \n"));
3662 break;
3663 case OID_802_11_RTS_THRESHOLD:
3664 if (wrq->u.data.length != sizeof(NDIS_802_11_RTS_THRESHOLD))
3665 Status = -EINVAL;
3666 else
3667 {
3668 Status = copy_from_user(&RtsThresh, wrq->u.data.pointer, wrq->u.data.length);
3669 if (RtsThresh > MAX_RTS_THRESHOLD)
3670 Status = -EINVAL;
3671 else
3672 pAdapter->CommonCfg.RtsThreshold = (USHORT)RtsThresh;
3673 }
3674 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_RTS_THRESHOLD (=%ld)\n",RtsThresh));
3675 break;
3676 case OID_802_11_FRAGMENTATION_THRESHOLD:
3677 if (wrq->u.data.length != sizeof(NDIS_802_11_FRAGMENTATION_THRESHOLD))
3678 Status = -EINVAL;
3679 else
3680 {
3681 Status = copy_from_user(&FragThresh, wrq->u.data.pointer, wrq->u.data.length);
3682 pAdapter->CommonCfg.bUseZeroToDisableFragment = FALSE;
3683 if (FragThresh > MAX_FRAG_THRESHOLD || FragThresh < MIN_FRAG_THRESHOLD)
3684 {
3685 if (FragThresh == 0)
3686 {
3687 pAdapter->CommonCfg.FragmentThreshold = MAX_FRAG_THRESHOLD;
3688 pAdapter->CommonCfg.bUseZeroToDisableFragment = TRUE;
3689 }
3690 else
3691 Status = -EINVAL;
3692 }
3693 else
3694 pAdapter->CommonCfg.FragmentThreshold = (USHORT)FragThresh;
3695 }
3696 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_FRAGMENTATION_THRESHOLD (=%ld) \n",FragThresh));
3697 break;
3698 case OID_802_11_POWER_MODE:
3699 if (wrq->u.data.length != sizeof(NDIS_802_11_POWER_MODE))
3700 Status = -EINVAL;
3701 else
3702 {
3703 Status = copy_from_user(&PowerMode, wrq->u.data.pointer, wrq->u.data.length);
3704 if (PowerMode == Ndis802_11PowerModeCAM)
3705 Set_PSMode_Proc(pAdapter, "CAM");
3706 else if (PowerMode == Ndis802_11PowerModeMAX_PSP)
3707 Set_PSMode_Proc(pAdapter, "Max_PSP");
3708 else if (PowerMode == Ndis802_11PowerModeFast_PSP)
3709 Set_PSMode_Proc(pAdapter, "Fast_PSP");
3710 else if (PowerMode == Ndis802_11PowerModeLegacy_PSP)
3711 Set_PSMode_Proc(pAdapter, "Legacy_PSP");
3712 else
3713 Status = -EINVAL;
3714 }
3715 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_POWER_MODE (=%d)\n",PowerMode));
3716 break;
3717 case RT_OID_802_11_TX_POWER_LEVEL_1:
3718 if (wrq->u.data.length < sizeof(ULONG))
3719 Status = -EINVAL;
3720 else
3721 {
3722 Status = copy_from_user(&PowerTemp, wrq->u.data.pointer, wrq->u.data.length);
3723 if (PowerTemp > 100)
3724 PowerTemp = 0xffffffff; // AUTO
3725 pAdapter->CommonCfg.TxPowerDefault = PowerTemp; //keep current setting.
3726 pAdapter->CommonCfg.TxPowerPercentage = pAdapter->CommonCfg.TxPowerDefault;
3727 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_TX_POWER_LEVEL_1 (=%ld)\n", pAdapter->CommonCfg.TxPowerPercentage));
3728 }
3729 break;
3730 case OID_802_11_NETWORK_TYPE_IN_USE:
3731 if (wrq->u.data.length != sizeof(NDIS_802_11_NETWORK_TYPE))
3732 Status = -EINVAL;
3733 else
3734 {
3735 Status = copy_from_user(&NetType, wrq->u.data.pointer, wrq->u.data.length);
3736
3737 if (NetType == Ndis802_11DS)
3738 RTMPSetPhyMode(pAdapter, PHY_11B);
3739 else if (NetType == Ndis802_11OFDM24)
3740 RTMPSetPhyMode(pAdapter, PHY_11BG_MIXED);
3741 else if (NetType == Ndis802_11OFDM5)
3742 RTMPSetPhyMode(pAdapter, PHY_11A);
3743 else
3744 Status = -EINVAL;
3745
3746 if (Status == NDIS_STATUS_SUCCESS)
3747 SetCommonHT(pAdapter);
3748
3749 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_NETWORK_TYPE_IN_USE (=%d)\n",NetType));
3750 }
3751 break;
3752 // For WPA PSK PMK key
3753 case RT_OID_802_11_ADD_WPA:
3754 pKey = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
3755 if(pKey == NULL)
3756 {
3757 Status = -ENOMEM;
3758 break;
3759 }
3760
3761 Status = copy_from_user(pKey, wrq->u.data.pointer, wrq->u.data.length);
3762 if (pKey->Length != wrq->u.data.length)
3763 {
3764 Status = -EINVAL;
3765 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_ADD_WPA, Failed!!\n"));
3766 }
3767 else
3768 {
3769 if ((pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPAPSK) &&
3770 (pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPA2PSK) &&
3771 (pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPANone) )
3772 {
3773 Status = -EOPNOTSUPP;
3774 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_ADD_WPA, Failed!! [AuthMode != WPAPSK/WPA2PSK/WPANONE]\n"));
3775 }
3776 else if ((pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK) ||
3777 (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK) ||
3778 (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPANone) ) // Only for WPA PSK mode
3779 {
3780 NdisMoveMemory(pAdapter->StaCfg.PMK, &pKey->KeyMaterial, pKey->KeyLength);
3781 // Use RaConfig as PSK agent.
3782 // Start STA supplicant state machine
3783 if (pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPANone)
3784 pAdapter->StaCfg.WpaState = SS_START;
3785
3786 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_ADD_WPA (id=0x%x, Len=%d-byte)\n", pKey->KeyIndex, pKey->KeyLength));
3787 }
3788 else
3789 {
3790 pAdapter->StaCfg.WpaState = SS_NOTUSE;
3791 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_ADD_WPA (id=0x%x, Len=%d-byte)\n", pKey->KeyIndex, pKey->KeyLength));
3792 }
3793 }
3794 kfree(pKey);
3795 break;
3796 case OID_802_11_REMOVE_KEY:
3797 pRemoveKey = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
3798 if(pRemoveKey == NULL)
3799 {
3800 Status = -ENOMEM;
3801 break;
3802 }
3803
3804 Status = copy_from_user(pRemoveKey, wrq->u.data.pointer, wrq->u.data.length);
3805 if (pRemoveKey->Length != wrq->u.data.length)
3806 {
3807 Status = -EINVAL;
3808 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_KEY, Failed!!\n"));
3809 }
3810 else
3811 {
3812 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
3813 {
3814 RTMPWPARemoveKeyProc(pAdapter, pRemoveKey);
3815 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_KEY, Remove WPA Key!!\n"));
3816 }
3817 else
3818 {
3819 KeyIdx = pRemoveKey->KeyIndex;
3820
3821 if (KeyIdx & 0x80000000)
3822 {
3823 // Should never set default bit when remove key
3824 Status = -EINVAL;
3825 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_KEY, Failed!!(Should never set default bit when remove key)\n"));
3826 }
3827 else
3828 {
3829 KeyIdx = KeyIdx & 0x0fffffff;
3830 if (KeyIdx > 3)
3831 {
3832 Status = -EINVAL;
3833 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_KEY, Failed!!(KeyId[%d] out of range)\n", KeyIdx));
3834 }
3835 else
3836 {
3837 pAdapter->SharedKey[BSS0][KeyIdx].KeyLen = 0;
3838 pAdapter->SharedKey[BSS0][KeyIdx].CipherAlg = CIPHER_NONE;
3839 AsicRemoveSharedKeyEntry(pAdapter, 0, (UCHAR)KeyIdx);
3840 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_KEY (id=0x%x, Len=%d-byte)\n", pRemoveKey->KeyIndex, pRemoveKey->Length));
3841 }
3842 }
3843 }
3844 }
3845 kfree(pRemoveKey);
3846 break;
3847 // New for WPA
3848 case OID_802_11_ADD_KEY:
3849 pKey = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
3850 if(pKey == NULL)
3851 {
3852 Status = -ENOMEM;
3853 break;
3854 }
3855 Status = copy_from_user(pKey, wrq->u.data.pointer, wrq->u.data.length);
3856 if (pKey->Length != wrq->u.data.length)
3857 {
3858 Status = -EINVAL;
3859 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_KEY, Failed!!\n"));
3860 }
3861 else
3862 {
3863 RTMPAddKey(pAdapter, pKey);
3864 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_KEY (id=0x%x, Len=%d-byte)\n", pKey->KeyIndex, pKey->KeyLength));
3865 }
3866 kfree(pKey);
3867 break;
3868 case OID_802_11_CONFIGURATION:
3869 if (wrq->u.data.length != sizeof(NDIS_802_11_CONFIGURATION))
3870 Status = -EINVAL;
3871 else
3872 {
3873 Status = copy_from_user(&Config, wrq->u.data.pointer, wrq->u.data.length);
3874 pConfig = &Config;
3875
3876 if ((pConfig->BeaconPeriod >= 20) && (pConfig->BeaconPeriod <=400))
3877 pAdapter->CommonCfg.BeaconPeriod = (USHORT) pConfig->BeaconPeriod;
3878
3879 pAdapter->StaActive.AtimWin = (USHORT) pConfig->ATIMWindow;
3880 MAP_KHZ_TO_CHANNEL_ID(pConfig->DSConfig, pAdapter->CommonCfg.Channel);
3881 //
3882 // Save the channel on MlmeAux for CntlOidRTBssidProc used.
3883 //
3884 pAdapter->MlmeAux.Channel = pAdapter->CommonCfg.Channel;
3885
3886 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_CONFIGURATION (BeacnPeriod=%ld,AtimW=%ld,Ch=%d)\n",
3887 pConfig->BeaconPeriod, pConfig->ATIMWindow, pAdapter->CommonCfg.Channel));
3888 // Config has changed
3889 pAdapter->bConfigChanged = TRUE;
3890 }
3891 break;
3892 case RT_OID_802_11_SET_HT_PHYMODE:
3893 if (wrq->u.data.length != sizeof(OID_SET_HT_PHYMODE))
3894 Status = -EINVAL;
3895 else
3896 {
3897 POID_SET_HT_PHYMODE pHTPhyMode = &HT_PhyMode;
3898
3899 Status = copy_from_user(&HT_PhyMode, wrq->u.data.pointer, wrq->u.data.length);
3900 DBGPRINT(RT_DEBUG_TRACE, ("Set::pHTPhyMode (PhyMode = %d,TransmitNo = %d, HtMode = %d, ExtOffset = %d , MCS = %d, BW = %d, STBC = %d, SHORTGI = %d) \n",
3901 pHTPhyMode->PhyMode, pHTPhyMode->TransmitNo,pHTPhyMode->HtMode,pHTPhyMode->ExtOffset,
3902 pHTPhyMode->MCS, pHTPhyMode->BW, pHTPhyMode->STBC, pHTPhyMode->SHORTGI));
3903 if (pAdapter->CommonCfg.PhyMode >= PHY_11ABGN_MIXED)
3904 RTMPSetHT(pAdapter, pHTPhyMode);
3905 }
3906 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_SET_HT_PHYMODE(MCS=%d,BW=%d,SGI=%d,STBC=%d)\n",
3907 pAdapter->StaCfg.HTPhyMode.field.MCS, pAdapter->StaCfg.HTPhyMode.field.BW, pAdapter->StaCfg.HTPhyMode.field.ShortGI,
3908 pAdapter->StaCfg.HTPhyMode.field.STBC));
3909 break;
3910 case RT_OID_802_11_SET_APSD_SETTING:
3911 if (wrq->u.data.length != sizeof(ULONG))
3912 Status = -EINVAL;
3913 else
3914 {
3915 ULONG apsd ;
3916 Status = copy_from_user(&apsd, wrq->u.data.pointer, wrq->u.data.length);
3917
3918 /*-------------------------------------------------------------------
3919 |B31~B7 | B6~B5 | B4 | B3 | B2 | B1 | B0 |
3920 ---------------------------------------------------------------------
3921 | Rsvd | Max SP Len | AC_VO | AC_VI | AC_BK | AC_BE | APSD Capable |
3922 ---------------------------------------------------------------------*/
3923 pAdapter->CommonCfg.bAPSDCapable = (apsd & 0x00000001) ? TRUE : FALSE;
3924 pAdapter->CommonCfg.bAPSDAC_BE = ((apsd & 0x00000002) >> 1) ? TRUE : FALSE;
3925 pAdapter->CommonCfg.bAPSDAC_BK = ((apsd & 0x00000004) >> 2) ? TRUE : FALSE;
3926 pAdapter->CommonCfg.bAPSDAC_VI = ((apsd & 0x00000008) >> 3) ? TRUE : FALSE;
3927 pAdapter->CommonCfg.bAPSDAC_VO = ((apsd & 0x00000010) >> 4) ? TRUE : FALSE;
3928 pAdapter->CommonCfg.MaxSPLength = (UCHAR)((apsd & 0x00000060) >> 5);
3929
3930 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_SET_APSD_SETTING (apsd=0x%lx, APSDCap=%d, [BE,BK,VI,VO]=[%d/%d/%d/%d], MaxSPLen=%d)\n", apsd, pAdapter->CommonCfg.bAPSDCapable,
3931 pAdapter->CommonCfg.bAPSDAC_BE, pAdapter->CommonCfg.bAPSDAC_BK, pAdapter->CommonCfg.bAPSDAC_VI, pAdapter->CommonCfg.bAPSDAC_VO, pAdapter->CommonCfg.MaxSPLength));
3932 }
3933 break;
3934
3935 case RT_OID_802_11_SET_APSD_PSM:
3936 if (wrq->u.data.length != sizeof(ULONG))
3937 Status = -EINVAL;
3938 else
3939 {
3940 // Driver needs to notify AP when PSM changes
3941 Status = copy_from_user(&pAdapter->CommonCfg.bAPSDForcePowerSave, wrq->u.data.pointer, wrq->u.data.length);
3942 if (pAdapter->CommonCfg.bAPSDForcePowerSave != pAdapter->StaCfg.Psm)
3943 {
3944 MlmeSetPsmBit(pAdapter, pAdapter->CommonCfg.bAPSDForcePowerSave);
3945 RTMPSendNullFrame(pAdapter, pAdapter->CommonCfg.TxRate, TRUE);
3946 }
3947 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_SET_APSD_PSM (bAPSDForcePowerSave:%d)\n", pAdapter->CommonCfg.bAPSDForcePowerSave));
3948 }
3949 break;
3950
3951 case RT_OID_802_11_SET_WMM:
3952 if (wrq->u.data.length != sizeof(BOOLEAN))
3953 Status = -EINVAL;
3954 else
3955 {
3956 Status = copy_from_user(&pAdapter->CommonCfg.bWmmCapable, wrq->u.data.pointer, wrq->u.data.length);
3957 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_SET_WMM (=%d) \n", pAdapter->CommonCfg.bWmmCapable));
3958 }
3959 break;
3960
3961 case OID_802_11_DISASSOCIATE:
3962 //
3963 // Set NdisRadioStateOff to TRUE, instead of called MlmeRadioOff.
3964 // Later on, NDIS_802_11_BSSID_LIST_EX->NumberOfItems should be 0
3965 // when query OID_802_11_BSSID_LIST.
3966 //
3967 // TRUE: NumberOfItems will set to 0.
3968 // FALSE: NumberOfItems no change.
3969 //
3970 pAdapter->CommonCfg.NdisRadioStateOff = TRUE;
3971 // Set to immediately send the media disconnect event
3972 pAdapter->MlmeAux.CurrReqIsFromNdis = TRUE;
3973 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_DISASSOCIATE \n"));
3974
3975 if (INFRA_ON(pAdapter))
3976 {
3977 if (pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE)
3978 {
3979 RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
3980 DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
3981 }
3982
3983 MlmeEnqueue(pAdapter,
3984 MLME_CNTL_STATE_MACHINE,
3985 OID_802_11_DISASSOCIATE,
3986 0,
3987 NULL);
3988
3989 StateMachineTouched = TRUE;
3990 }
3991 break;
3992 case RT_OID_802_11_SET_IMME_BA_CAP:
3993 if (wrq->u.data.length != sizeof(OID_BACAP_STRUC))
3994 Status = -EINVAL;
3995 else
3996 {
3997 OID_BACAP_STRUC Orde ;
3998 Status = copy_from_user(&Orde, wrq->u.data.pointer, wrq->u.data.length);
3999 if (Orde.Policy > BA_NOTUSE)
4000 {
4001 Status = NDIS_STATUS_INVALID_DATA;
4002 }
4003 else if (Orde.Policy == BA_NOTUSE)
4004 {
4005 pAdapter->CommonCfg.BACapability.field.Policy = BA_NOTUSE;
4006 pAdapter->CommonCfg.BACapability.field.MpduDensity = Orde.MpduDensity;
4007 pAdapter->CommonCfg.DesiredHtPhy.MpduDensity = Orde.MpduDensity;
4008 pAdapter->CommonCfg.DesiredHtPhy.AmsduEnable = Orde.AmsduEnable;
4009 pAdapter->CommonCfg.DesiredHtPhy.AmsduSize= Orde.AmsduSize;
4010 pAdapter->CommonCfg.DesiredHtPhy.MimoPs= Orde.MMPSmode;
4011 pAdapter->CommonCfg.BACapability.field.MMPSmode = Orde.MMPSmode;
4012 // UPdata to HT IE
4013 pAdapter->CommonCfg.HtCapability.HtCapInfo.MimoPs = Orde.MMPSmode;
4014 pAdapter->CommonCfg.HtCapability.HtCapInfo.AMsduSize = Orde.AmsduSize;
4015 pAdapter->CommonCfg.HtCapability.HtCapParm.MpduDensity = Orde.MpduDensity;
4016 }
4017 else
4018 {
4019 pAdapter->CommonCfg.BACapability.field.AutoBA = Orde.AutoBA;
4020 pAdapter->CommonCfg.BACapability.field.Policy = IMMED_BA; // we only support immediate BA.
4021 pAdapter->CommonCfg.BACapability.field.MpduDensity = Orde.MpduDensity;
4022 pAdapter->CommonCfg.DesiredHtPhy.MpduDensity = Orde.MpduDensity;
4023 pAdapter->CommonCfg.DesiredHtPhy.AmsduEnable = Orde.AmsduEnable;
4024 pAdapter->CommonCfg.DesiredHtPhy.AmsduSize= Orde.AmsduSize;
4025 pAdapter->CommonCfg.DesiredHtPhy.MimoPs = Orde.MMPSmode;
4026 pAdapter->CommonCfg.BACapability.field.MMPSmode = Orde.MMPSmode;
4027
4028 // UPdata to HT IE
4029 pAdapter->CommonCfg.HtCapability.HtCapInfo.MimoPs = Orde.MMPSmode;
4030 pAdapter->CommonCfg.HtCapability.HtCapInfo.AMsduSize = Orde.AmsduSize;
4031 pAdapter->CommonCfg.HtCapability.HtCapParm.MpduDensity = Orde.MpduDensity;
4032
4033 if (pAdapter->CommonCfg.BACapability.field.RxBAWinLimit > MAX_RX_REORDERBUF)
4034 pAdapter->CommonCfg.BACapability.field.RxBAWinLimit = MAX_RX_REORDERBUF;
4035
4036 }
4037
4038 pAdapter->CommonCfg.REGBACapability.word = pAdapter->CommonCfg.BACapability.word;
4039 DBGPRINT(RT_DEBUG_TRACE, ("Set::(Orde.AutoBA = %d) (Policy=%d)(ReBAWinLimit=%d)(TxBAWinLimit=%d)(AutoMode=%d)\n",Orde.AutoBA, pAdapter->CommonCfg.BACapability.field.Policy,
4040 pAdapter->CommonCfg.BACapability.field.RxBAWinLimit,pAdapter->CommonCfg.BACapability.field.TxBAWinLimit, pAdapter->CommonCfg.BACapability.field.AutoBA));
4041 DBGPRINT(RT_DEBUG_TRACE, ("Set::(MimoPs = %d)(AmsduEnable = %d) (AmsduSize=%d)(MpduDensity=%d)\n",pAdapter->CommonCfg.DesiredHtPhy.MimoPs, pAdapter->CommonCfg.DesiredHtPhy.AmsduEnable,
4042 pAdapter->CommonCfg.DesiredHtPhy.AmsduSize, pAdapter->CommonCfg.DesiredHtPhy.MpduDensity));
4043 }
4044
4045 break;
4046 case RT_OID_802_11_ADD_IMME_BA:
4047 DBGPRINT(RT_DEBUG_TRACE, (" Set :: RT_OID_802_11_ADD_IMME_BA \n"));
4048 if (wrq->u.data.length != sizeof(OID_ADD_BA_ENTRY))
4049 Status = -EINVAL;
4050 else
4051 {
4052 UCHAR index;
4053 OID_ADD_BA_ENTRY BA;
4054 MAC_TABLE_ENTRY *pEntry;
4055
4056 Status = copy_from_user(&BA, wrq->u.data.pointer, wrq->u.data.length);
4057 if (BA.TID > 15)
4058 {
4059 Status = NDIS_STATUS_INVALID_DATA;
4060 break;
4061 }
4062 else
4063 {
4064 //BATableInsertEntry
4065 //As ad-hoc mode, BA pair is not limited to only BSSID. so add via OID.
4066 index = BA.TID;
4067 // in ad hoc mode, when adding BA pair, we should insert this entry into MACEntry too
4068 pEntry = MacTableLookup(pAdapter, BA.MACAddr);
4069 if (!pEntry)
4070 {
4071 DBGPRINT(RT_DEBUG_TRACE, ("RT_OID_802_11_ADD_IMME_BA. break on no connection.----:%x:%x\n", BA.MACAddr[4], BA.MACAddr[5]));
4072 break;
4073 }
4074 if (BA.IsRecipient == FALSE)
4075 {
4076 if (pEntry->bIAmBadAtheros == TRUE)
4077 pAdapter->CommonCfg.BACapability.field.RxBAWinLimit = 0x10;
4078
4079 BAOriSessionSetUp(pAdapter, pEntry, index, 0, 100, TRUE);
4080 }
4081 else
4082 {
4083 //BATableInsertEntry(pAdapter, pEntry->Aid, BA.MACAddr, 0, 0xffff, BA.TID, BA.nMSDU, BA.IsRecipient);
4084 }
4085
4086 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_ADD_IMME_BA. Rec = %d. Mac = %x:%x:%x:%x:%x:%x . \n",
4087 BA.IsRecipient, BA.MACAddr[0], BA.MACAddr[1], BA.MACAddr[2], BA.MACAddr[2]
4088 , BA.MACAddr[4], BA.MACAddr[5]));
4089 }
4090 }
4091 break;
4092
4093 case RT_OID_802_11_TEAR_IMME_BA:
4094 DBGPRINT(RT_DEBUG_TRACE, ("Set :: RT_OID_802_11_TEAR_IMME_BA \n"));
4095 if (wrq->u.data.length != sizeof(OID_ADD_BA_ENTRY))
4096 Status = -EINVAL;
4097 else
4098 {
4099 POID_ADD_BA_ENTRY pBA;
4100 MAC_TABLE_ENTRY *pEntry;
4101
4102 pBA = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
4103
4104 if (pBA == NULL)
4105 {
4106 DBGPRINT(RT_DEBUG_TRACE, ("Set :: RT_OID_802_11_TEAR_IMME_BA kmalloc() can't allocate enough memory\n"));
4107 Status = NDIS_STATUS_FAILURE;
4108 }
4109 else
4110 {
4111 Status = copy_from_user(pBA, wrq->u.data.pointer, wrq->u.data.length);
4112 DBGPRINT(RT_DEBUG_TRACE, ("Set :: RT_OID_802_11_TEAR_IMME_BA(TID=%d, bAllTid=%d)\n", pBA->TID, pBA->bAllTid));
4113
4114 if (!pBA->bAllTid && (pBA->TID > NUM_OF_TID))
4115 {
4116 Status = NDIS_STATUS_INVALID_DATA;
4117 break;
4118 }
4119
4120 if (pBA->IsRecipient == FALSE)
4121 {
4122 pEntry = MacTableLookup(pAdapter, pBA->MACAddr);
4123 DBGPRINT(RT_DEBUG_TRACE, (" pBA->IsRecipient == FALSE\n"));
4124 if (pEntry)
4125 {
4126 DBGPRINT(RT_DEBUG_TRACE, (" pBA->pEntry\n"));
4127 BAOriSessionTearDown(pAdapter, pEntry->Aid, pBA->TID, FALSE, TRUE);
4128 }
4129 else
4130 DBGPRINT(RT_DEBUG_TRACE, ("Set :: Not found pEntry \n"));
4131 }
4132 else
4133 {
4134 pEntry = MacTableLookup(pAdapter, pBA->MACAddr);
4135 if (pEntry)
4136 {
4137 BARecSessionTearDown( pAdapter, (UCHAR)pEntry->Aid, pBA->TID, TRUE);
4138 }
4139 else
4140 DBGPRINT(RT_DEBUG_TRACE, ("Set :: Not found pEntry \n"));
4141 }
4142 kfree(pBA);
4143 }
4144 }
4145 break;
4146 // For WPA_SUPPLICANT to set static wep key
4147 case OID_802_11_ADD_WEP:
4148 pWepKey = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
4149
4150 if(pWepKey == NULL)
4151 {
4152 Status = -ENOMEM;
4153 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_WEP, Failed!!\n"));
4154 break;
4155 }
4156 Status = copy_from_user(pWepKey, wrq->u.data.pointer, wrq->u.data.length);
4157 if (Status)
4158 {
4159 Status = -EINVAL;
4160 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_WEP, Failed (length mismatch)!!\n"));
4161 }
4162 else
4163 {
4164 KeyIdx = pWepKey->KeyIndex & 0x0fffffff;
4165 // KeyIdx must be 0 ~ 3
4166 if (KeyIdx > 4)
4167 {
4168 Status = -EINVAL;
4169 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_WEP, Failed (KeyIdx must be smaller than 4)!!\n"));
4170 }
4171 else
4172 {
4173 UCHAR CipherAlg = 0;
4174 PUCHAR Key;
4175
4176 // set key material and key length
4177 NdisZeroMemory(pAdapter->SharedKey[BSS0][KeyIdx].Key, 16);
4178 pAdapter->SharedKey[BSS0][KeyIdx].KeyLen = (UCHAR) pWepKey->KeyLength;
4179 NdisMoveMemory(pAdapter->SharedKey[BSS0][KeyIdx].Key, &pWepKey->KeyMaterial, pWepKey->KeyLength);
4180
4181 switch(pWepKey->KeyLength)
4182 {
4183 case 5:
4184 CipherAlg = CIPHER_WEP64;
4185 break;
4186 case 13:
4187 CipherAlg = CIPHER_WEP128;
4188 break;
4189 default:
4190 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_WEP, only support CIPHER_WEP64(len:5) & CIPHER_WEP128(len:13)!!\n"));
4191 Status = -EINVAL;
4192 break;
4193 }
4194 pAdapter->SharedKey[BSS0][KeyIdx].CipherAlg = CipherAlg;
4195
4196 // Default key for tx (shared key)
4197 if (pWepKey->KeyIndex & 0x80000000)
4198 {
4199 // set key material and key length
4200 NdisZeroMemory(pAdapter->StaCfg.DesireSharedKey[KeyIdx].Key, 16);
4201 pAdapter->StaCfg.DesireSharedKey[KeyIdx].KeyLen = (UCHAR) pWepKey->KeyLength;
4202 NdisMoveMemory(pAdapter->StaCfg.DesireSharedKey[KeyIdx].Key, &pWepKey->KeyMaterial, pWepKey->KeyLength);
4203 pAdapter->StaCfg.DesireSharedKeyId = KeyIdx;
4204 pAdapter->StaCfg.DesireSharedKey[KeyIdx].CipherAlg = CipherAlg;
4205 pAdapter->StaCfg.DefaultKeyId = (UCHAR) KeyIdx;
4206 }
4207#ifndef RT30xx
4208 if ((pAdapter->StaCfg.WpaSupplicantUP != WPA_SUPPLICANT_DISABLE) &&
4209 (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA))
4210 {
4211 Key = pWepKey->KeyMaterial;
4212
4213 // Set Group key material to Asic
4214 AsicAddSharedKeyEntry(pAdapter, BSS0, KeyIdx, CipherAlg, Key, NULL, NULL);
4215
4216 // Update WCID attribute table and IVEIV table for this group key table
4217 RTMPAddWcidAttributeEntry(pAdapter, BSS0, KeyIdx, CipherAlg, NULL);
4218
4219 STA_PORT_SECURED(pAdapter);
4220
4221 // Indicate Connected for GUI
4222 pAdapter->IndicateMediaState = NdisMediaStateConnected;
4223 }
4224 else if (pAdapter->StaCfg.PortSecured == WPA_802_1X_PORT_SECURED)
4225#endif
4226#ifdef RT30xx
4227 if (pAdapter->StaCfg.PortSecured == WPA_802_1X_PORT_SECURED)
4228#endif
4229 {
4230 Key = pAdapter->SharedKey[BSS0][KeyIdx].Key;
4231
4232 // Set key material and cipherAlg to Asic
4233 AsicAddSharedKeyEntry(pAdapter, BSS0, KeyIdx, CipherAlg, Key, NULL, NULL);
4234
4235 if (pWepKey->KeyIndex & 0x80000000)
4236 {
4237 PMAC_TABLE_ENTRY pEntry = &pAdapter->MacTab.Content[BSSID_WCID];
4238 // Assign group key info
4239 RTMPAddWcidAttributeEntry(pAdapter, BSS0, KeyIdx, CipherAlg, NULL);
4240 // Assign pairwise key info
4241 RTMPAddWcidAttributeEntry(pAdapter, BSS0, KeyIdx, CipherAlg, pEntry);
4242 }
4243 }
4244 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_WEP (id=0x%x, Len=%d-byte), %s\n", pWepKey->KeyIndex, pWepKey->KeyLength, (pAdapter->StaCfg.PortSecured == WPA_802_1X_PORT_SECURED) ? "Port Secured":"Port NOT Secured"));
4245 }
4246 }
4247 kfree(pWepKey);
4248 break;
4249 case OID_SET_COUNTERMEASURES:
4250 if (wrq->u.data.length != sizeof(int))
4251 Status = -EINVAL;
4252 else
4253 {
4254 int enabled = 0;
4255 Status = copy_from_user(&enabled, wrq->u.data.pointer, wrq->u.data.length);
4256 if (enabled == 1)
4257 pAdapter->StaCfg.bBlockAssoc = TRUE;
4258 else
4259 // WPA MIC error should block association attempt for 60 seconds
4260 pAdapter->StaCfg.bBlockAssoc = FALSE;
4261 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_SET_COUNTERMEASURES bBlockAssoc=%s\n", pAdapter->StaCfg.bBlockAssoc ? "TRUE":"FALSE"));
4262 }
4263 break;
4264 case RT_OID_WPA_SUPPLICANT_SUPPORT:
4265 if (wrq->u.data.length != sizeof(UCHAR))
4266 Status = -EINVAL;
4267 else
4268 {
4269 Status = copy_from_user(&wpa_supplicant_enable, wrq->u.data.pointer, wrq->u.data.length);
4270 pAdapter->StaCfg.WpaSupplicantUP = wpa_supplicant_enable;
4271 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_WPA_SUPPLICANT_SUPPORT (=%d)\n", pAdapter->StaCfg.WpaSupplicantUP));
4272 }
4273 break;
4274 case OID_802_11_DEAUTHENTICATION:
4275 if (wrq->u.data.length != sizeof(MLME_DEAUTH_REQ_STRUCT))
4276 Status = -EINVAL;
4277 else
4278 {
4279 MLME_DEAUTH_REQ_STRUCT *pInfo;
4280 MLME_QUEUE_ELEM *MsgElem = (MLME_QUEUE_ELEM *) kmalloc(sizeof(MLME_QUEUE_ELEM), MEM_ALLOC_FLAG);
4281
4282 pInfo = (MLME_DEAUTH_REQ_STRUCT *) MsgElem->Msg;
4283 Status = copy_from_user(pInfo, wrq->u.data.pointer, wrq->u.data.length);
4284 MlmeDeauthReqAction(pAdapter, MsgElem);
4285 kfree(MsgElem);
4286
4287 if (INFRA_ON(pAdapter))
4288 {
4289 LinkDown(pAdapter, FALSE);
4290 pAdapter->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
4291 }
4292 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_DEAUTHENTICATION (Reason=%d)\n", pInfo->Reason));
4293 }
4294 break;
4295 case OID_802_11_DROP_UNENCRYPTED:
4296 if (wrq->u.data.length != sizeof(int))
4297 Status = -EINVAL;
4298 else
4299 {
4300 int enabled = 0;
4301 Status = copy_from_user(&enabled, wrq->u.data.pointer, wrq->u.data.length);
4302 if (enabled == 1)
4303 pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED;
4304 else
4305 pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
4306 NdisAcquireSpinLock(&pAdapter->MacTabLock);
4307 pAdapter->MacTab.Content[BSSID_WCID].PortSecured = pAdapter->StaCfg.PortSecured;
4308 NdisReleaseSpinLock(&pAdapter->MacTabLock);
4309 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_DROP_UNENCRYPTED (=%d)\n", enabled));
4310 }
4311 break;
4312 case OID_802_11_SET_IEEE8021X:
4313 if (wrq->u.data.length != sizeof(BOOLEAN))
4314 Status = -EINVAL;
4315 else
4316 {
4317 Status = copy_from_user(&IEEE8021xState, wrq->u.data.pointer, wrq->u.data.length);
4318 pAdapter->StaCfg.IEEE8021X = IEEE8021xState;
4319 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_SET_IEEE8021X (=%d)\n", IEEE8021xState));
4320 }
4321 break;
4322 case OID_802_11_SET_IEEE8021X_REQUIRE_KEY:
4323 if (wrq->u.data.length != sizeof(BOOLEAN))
4324 Status = -EINVAL;
4325 else
4326 {
4327 Status = copy_from_user(&IEEE8021x_required_keys, wrq->u.data.pointer, wrq->u.data.length);
4328 pAdapter->StaCfg.IEEE8021x_required_keys = IEEE8021x_required_keys;
4329 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_SET_IEEE8021X_REQUIRE_KEY (%d)\n", IEEE8021x_required_keys));
4330 }
4331 break;
4332 case OID_802_11_PMKID:
4333 pPmkId = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
4334
4335 if(pPmkId == NULL) {
4336 Status = -ENOMEM;
4337 break;
4338 }
4339 Status = copy_from_user(pPmkId, wrq->u.data.pointer, wrq->u.data.length);
4340
4341 // check the PMKID information
4342 if (pPmkId->BSSIDInfoCount == 0)
4343 NdisZeroMemory(pAdapter->StaCfg.SavedPMK, sizeof(BSSID_INFO)*PMKID_NO);
4344 else
4345 {
4346 PBSSID_INFO pBssIdInfo;
4347 UINT BssIdx;
4348 UINT CachedIdx;
4349
4350 for (BssIdx = 0; BssIdx < pPmkId->BSSIDInfoCount; BssIdx++)
4351 {
4352 // point to the indexed BSSID_INFO structure
4353 pBssIdInfo = (PBSSID_INFO) ((PUCHAR) pPmkId + 2 * sizeof(UINT) + BssIdx * sizeof(BSSID_INFO));
4354 // Find the entry in the saved data base.
4355 for (CachedIdx = 0; CachedIdx < pAdapter->StaCfg.SavedPMKNum; CachedIdx++)
4356 {
4357 // compare the BSSID
4358 if (NdisEqualMemory(pBssIdInfo->BSSID, pAdapter->StaCfg.SavedPMK[CachedIdx].BSSID, sizeof(NDIS_802_11_MAC_ADDRESS)))
4359 break;
4360 }
4361
4362 // Found, replace it
4363 if (CachedIdx < PMKID_NO)
4364 {
4365 DBGPRINT(RT_DEBUG_OFF, ("Update OID_802_11_PMKID, idx = %d\n", CachedIdx));
4366 NdisMoveMemory(&pAdapter->StaCfg.SavedPMK[CachedIdx], pBssIdInfo, sizeof(BSSID_INFO));
4367 pAdapter->StaCfg.SavedPMKNum++;
4368 }
4369 // Not found, replace the last one
4370 else
4371 {
4372 // Randomly replace one
4373 CachedIdx = (pBssIdInfo->BSSID[5] % PMKID_NO);
4374 DBGPRINT(RT_DEBUG_OFF, ("Update OID_802_11_PMKID, idx = %d\n", CachedIdx));
4375 NdisMoveMemory(&pAdapter->StaCfg.SavedPMK[CachedIdx], pBssIdInfo, sizeof(BSSID_INFO));
4376 }
4377 }
4378 }
4379 if(pPmkId)
4380 kfree(pPmkId);
4381 break;
4382 default:
4383 DBGPRINT(RT_DEBUG_TRACE, ("Set::unknown IOCTL's subcmd = 0x%08x\n", cmd));
4384 Status = -EOPNOTSUPP;
4385 break;
4386 }
4387
4388
4389 return Status;
4390}
4391
4392INT RTMPQueryInformation(
4393 IN PRTMP_ADAPTER pAdapter,
4394 IN OUT struct ifreq *rq,
4395 IN INT cmd)
4396{
4397 struct iwreq *wrq = (struct iwreq *) rq;
4398 NDIS_802_11_BSSID_LIST_EX *pBssidList = NULL;
4399 PNDIS_WLAN_BSSID_EX pBss;
4400 NDIS_802_11_SSID Ssid;
4401 NDIS_802_11_CONFIGURATION *pConfiguration = NULL;
4402 RT_802_11_LINK_STATUS *pLinkStatus = NULL;
4403 RT_802_11_STA_CONFIG *pStaConfig = NULL;
4404 NDIS_802_11_STATISTICS *pStatistics = NULL;
4405 NDIS_802_11_RTS_THRESHOLD RtsThresh;
4406 NDIS_802_11_FRAGMENTATION_THRESHOLD FragThresh;
4407 NDIS_802_11_POWER_MODE PowerMode;
4408 NDIS_802_11_NETWORK_INFRASTRUCTURE BssType;
4409 RT_802_11_PREAMBLE PreamType;
4410 NDIS_802_11_AUTHENTICATION_MODE AuthMode;
4411 NDIS_802_11_WEP_STATUS WepStatus;
4412 NDIS_MEDIA_STATE MediaState;
4413 ULONG BssBufSize, ulInfo=0, NetworkTypeList[4], apsd = 0;
4414 USHORT BssLen = 0;
4415 PUCHAR pBuf = NULL, pPtr;
4416 INT Status = NDIS_STATUS_SUCCESS;
4417 UINT we_version_compiled;
4418 UCHAR i, Padding = 0;
4419 BOOLEAN RadioState;
4420 UCHAR driverVersion[8];
4421 OID_SET_HT_PHYMODE *pHTPhyMode = NULL;
4422
4423 switch(cmd)
4424 {
4425 case RT_OID_DEVICE_NAME:
4426 wrq->u.data.length = sizeof(STA_NIC_DEVICE_NAME);
4427 Status = copy_to_user(wrq->u.data.pointer, STA_NIC_DEVICE_NAME, wrq->u.data.length);
4428 break;
4429 case RT_OID_VERSION_INFO:
4430 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_VERSION_INFO \n"));
4431 wrq->u.data.length = 8*sizeof(UCHAR);
4432 sprintf(&driverVersion[0], "%s", STA_DRIVER_VERSION);
4433 driverVersion[7] = '\0';
4434 if (copy_to_user(wrq->u.data.pointer, &driverVersion, wrq->u.data.length))
4435 {
4436 Status = -EFAULT;
4437 }
4438 break;
4439 case OID_802_11_BSSID_LIST:
4440 if (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
4441 {
4442 /*
4443 * Still scanning, indicate the caller should try again.
4444 */
4445 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_BSSID_LIST (Still scanning)\n"));
4446 return -EAGAIN;
4447 }
4448 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_BSSID_LIST (%d BSS returned)\n",pAdapter->ScanTab.BssNr));
4449 pAdapter->StaCfg.bScanReqIsFromWebUI = FALSE;
4450 // Claculate total buffer size required
4451 BssBufSize = sizeof(ULONG);
4452
4453 for (i = 0; i < pAdapter->ScanTab.BssNr; i++)
4454 {
4455 // Align pointer to 4 bytes boundary.
4456 //Padding = 4 - (pAdapter->ScanTab.BssEntry[i].VarIELen & 0x0003);
4457 //if (Padding == 4)
4458 // Padding = 0;
4459 BssBufSize += (sizeof(NDIS_WLAN_BSSID_EX) - 1 + sizeof(NDIS_802_11_FIXED_IEs) + pAdapter->ScanTab.BssEntry[i].VarIELen + Padding);
4460 }
4461
4462 // For safety issue, we add 256 bytes just in case
4463 BssBufSize += 256;
4464 // Allocate the same size as passed from higher layer
4465 pBuf = kmalloc(BssBufSize, MEM_ALLOC_FLAG);
4466 if(pBuf == NULL)
4467 {
4468 Status = -ENOMEM;
4469 break;
4470 }
4471 // Init 802_11_BSSID_LIST_EX structure
4472 NdisZeroMemory(pBuf, BssBufSize);
4473 pBssidList = (PNDIS_802_11_BSSID_LIST_EX) pBuf;
4474 pBssidList->NumberOfItems = pAdapter->ScanTab.BssNr;
4475
4476 // Calculate total buffer length
4477 BssLen = 4; // Consist of NumberOfItems
4478 // Point to start of NDIS_WLAN_BSSID_EX
4479 // pPtr = pBuf + sizeof(ULONG);
4480 pPtr = (PUCHAR) &pBssidList->Bssid[0];
4481 for (i = 0; i < pAdapter->ScanTab.BssNr; i++)
4482 {
4483 pBss = (PNDIS_WLAN_BSSID_EX) pPtr;
4484 NdisMoveMemory(&pBss->MacAddress, &pAdapter->ScanTab.BssEntry[i].Bssid, MAC_ADDR_LEN);
4485 if ((pAdapter->ScanTab.BssEntry[i].Hidden == 1) && (pAdapter->StaCfg.bShowHiddenSSID == FALSE))
4486 {
4487 //
4488 // We must return this SSID during 4way handshaking, otherwise Aegis will failed to parse WPA infomation
4489 // and then failed to send EAPOl farame.
4490 //
4491 if ((pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA) && (pAdapter->StaCfg.PortSecured != WPA_802_1X_PORT_SECURED))
4492 {
4493 pBss->Ssid.SsidLength = pAdapter->ScanTab.BssEntry[i].SsidLen;
4494 NdisMoveMemory(pBss->Ssid.Ssid, pAdapter->ScanTab.BssEntry[i].Ssid, pAdapter->ScanTab.BssEntry[i].SsidLen);
4495 }
4496 else
4497 pBss->Ssid.SsidLength = 0;
4498 }
4499 else
4500 {
4501 pBss->Ssid.SsidLength = pAdapter->ScanTab.BssEntry[i].SsidLen;
4502 NdisMoveMemory(pBss->Ssid.Ssid, pAdapter->ScanTab.BssEntry[i].Ssid, pAdapter->ScanTab.BssEntry[i].SsidLen);
4503 }
4504 pBss->Privacy = pAdapter->ScanTab.BssEntry[i].Privacy;
4505 pBss->Rssi = pAdapter->ScanTab.BssEntry[i].Rssi - pAdapter->BbpRssiToDbmDelta;
4506 pBss->NetworkTypeInUse = NetworkTypeInUseSanity(&pAdapter->ScanTab.BssEntry[i]);
4507 pBss->Configuration.Length = sizeof(NDIS_802_11_CONFIGURATION);
4508 pBss->Configuration.BeaconPeriod = pAdapter->ScanTab.BssEntry[i].BeaconPeriod;
4509 pBss->Configuration.ATIMWindow = pAdapter->ScanTab.BssEntry[i].AtimWin;
4510
4511 MAP_CHANNEL_ID_TO_KHZ(pAdapter->ScanTab.BssEntry[i].Channel, pBss->Configuration.DSConfig);
4512
4513 if (pAdapter->ScanTab.BssEntry[i].BssType == BSS_INFRA)
4514 pBss->InfrastructureMode = Ndis802_11Infrastructure;
4515 else
4516 pBss->InfrastructureMode = Ndis802_11IBSS;
4517
4518 NdisMoveMemory(pBss->SupportedRates, pAdapter->ScanTab.BssEntry[i].SupRate, pAdapter->ScanTab.BssEntry[i].SupRateLen);
4519 NdisMoveMemory(pBss->SupportedRates + pAdapter->ScanTab.BssEntry[i].SupRateLen,
4520 pAdapter->ScanTab.BssEntry[i].ExtRate,
4521 pAdapter->ScanTab.BssEntry[i].ExtRateLen);
4522
4523 if (pAdapter->ScanTab.BssEntry[i].VarIELen == 0)
4524 {
4525 pBss->IELength = sizeof(NDIS_802_11_FIXED_IEs);
4526 NdisMoveMemory(pBss->IEs, &pAdapter->ScanTab.BssEntry[i].FixIEs, sizeof(NDIS_802_11_FIXED_IEs));
4527 pPtr = pPtr + sizeof(NDIS_WLAN_BSSID_EX) - 1 + sizeof(NDIS_802_11_FIXED_IEs);
4528 }
4529 else
4530 {
4531 pBss->IELength = (ULONG)(sizeof(NDIS_802_11_FIXED_IEs) + pAdapter->ScanTab.BssEntry[i].VarIELen);
4532 pPtr = pPtr + sizeof(NDIS_WLAN_BSSID_EX) - 1 + sizeof(NDIS_802_11_FIXED_IEs);
4533 NdisMoveMemory(pBss->IEs, &pAdapter->ScanTab.BssEntry[i].FixIEs, sizeof(NDIS_802_11_FIXED_IEs));
4534 NdisMoveMemory(pBss->IEs + sizeof(NDIS_802_11_FIXED_IEs), pAdapter->ScanTab.BssEntry[i].VarIEs, pAdapter->ScanTab.BssEntry[i].VarIELen);
4535 pPtr += pAdapter->ScanTab.BssEntry[i].VarIELen;
4536 }
4537 pBss->Length = (ULONG)(sizeof(NDIS_WLAN_BSSID_EX) - 1 + sizeof(NDIS_802_11_FIXED_IEs) + pAdapter->ScanTab.BssEntry[i].VarIELen + Padding);
4538
4539#if WIRELESS_EXT < 17
4540 if ((BssLen + pBss->Length) < wrq->u.data.length)
4541 BssLen += pBss->Length;
4542 else
4543 {
4544 pBssidList->NumberOfItems = i;
4545 break;
4546 }
4547#else
4548 BssLen += pBss->Length;
4549#endif
4550 }
4551
4552#if WIRELESS_EXT < 17
4553 wrq->u.data.length = BssLen;
4554#else
4555 if (BssLen > wrq->u.data.length)
4556 {
4557 kfree(pBssidList);
4558 return -E2BIG;
4559 }
4560 else
4561 wrq->u.data.length = BssLen;
4562#endif
4563 Status = copy_to_user(wrq->u.data.pointer, pBssidList, BssLen);
4564 kfree(pBssidList);
4565 break;
4566 case OID_802_3_CURRENT_ADDRESS:
4567 wrq->u.data.length = MAC_ADDR_LEN;
4568 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CurrentAddress, wrq->u.data.length);
4569 break;
4570 case OID_GEN_MEDIA_CONNECT_STATUS:
4571 if (pAdapter->IndicateMediaState == NdisMediaStateConnected)
4572 MediaState = NdisMediaStateConnected;
4573 else
4574 MediaState = NdisMediaStateDisconnected;
4575
4576 wrq->u.data.length = sizeof(NDIS_MEDIA_STATE);
4577 Status = copy_to_user(wrq->u.data.pointer, &MediaState, wrq->u.data.length);
4578 break;
4579 case OID_802_11_BSSID:
4580 if (INFRA_ON(pAdapter) || ADHOC_ON(pAdapter))
4581 {
4582 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.Bssid, sizeof(NDIS_802_11_MAC_ADDRESS));
4583
4584 }
4585 else
4586 {
4587 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_BSSID(=EMPTY)\n"));
4588 Status = -ENOTCONN;
4589 }
4590 break;
4591 case OID_802_11_SSID:
4592 NdisZeroMemory(&Ssid, sizeof(NDIS_802_11_SSID));
4593 NdisZeroMemory(Ssid.Ssid, MAX_LEN_OF_SSID);
4594 Ssid.SsidLength = pAdapter->CommonCfg.SsidLen;
4595 memcpy(Ssid.Ssid, pAdapter->CommonCfg.Ssid, Ssid.SsidLength);
4596 wrq->u.data.length = sizeof(NDIS_802_11_SSID);
4597 Status = copy_to_user(wrq->u.data.pointer, &Ssid, wrq->u.data.length);
4598 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_SSID (Len=%d, ssid=%s)\n", Ssid.SsidLength,Ssid.Ssid));
4599 break;
4600 case RT_OID_802_11_QUERY_LINK_STATUS:
4601 pLinkStatus = (RT_802_11_LINK_STATUS *) kmalloc(sizeof(RT_802_11_LINK_STATUS), MEM_ALLOC_FLAG);
4602 if (pLinkStatus)
4603 {
4604 pLinkStatus->CurrTxRate = RateIdTo500Kbps[pAdapter->CommonCfg.TxRate]; // unit : 500 kbps
4605 pLinkStatus->ChannelQuality = pAdapter->Mlme.ChannelQuality;
4606 pLinkStatus->RxByteCount = pAdapter->RalinkCounters.ReceivedByteCount;
4607 pLinkStatus->TxByteCount = pAdapter->RalinkCounters.TransmittedByteCount;
4608 pLinkStatus->CentralChannel = pAdapter->CommonCfg.CentralChannel;
4609 wrq->u.data.length = sizeof(RT_802_11_LINK_STATUS);
4610 Status = copy_to_user(wrq->u.data.pointer, pLinkStatus, wrq->u.data.length);
4611 kfree(pLinkStatus);
4612 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_LINK_STATUS\n"));
4613 }
4614 else
4615 {
4616 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_LINK_STATUS(kmalloc failed)\n"));
4617 Status = -EFAULT;
4618 }
4619 break;
4620 case OID_802_11_CONFIGURATION:
4621 pConfiguration = (NDIS_802_11_CONFIGURATION *) kmalloc(sizeof(NDIS_802_11_CONFIGURATION), MEM_ALLOC_FLAG);
4622 if (pConfiguration)
4623 {
4624 pConfiguration->Length = sizeof(NDIS_802_11_CONFIGURATION);
4625 pConfiguration->BeaconPeriod = pAdapter->CommonCfg.BeaconPeriod;
4626 pConfiguration->ATIMWindow = pAdapter->StaActive.AtimWin;
4627 MAP_CHANNEL_ID_TO_KHZ(pAdapter->CommonCfg.Channel, pConfiguration->DSConfig);
4628 wrq->u.data.length = sizeof(NDIS_802_11_CONFIGURATION);
4629 Status = copy_to_user(wrq->u.data.pointer, pConfiguration, wrq->u.data.length);
4630 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_CONFIGURATION(BeaconPeriod=%ld,AtimW=%ld,Channel=%d) \n",
4631 pConfiguration->BeaconPeriod, pConfiguration->ATIMWindow, pAdapter->CommonCfg.Channel));
4632 kfree(pConfiguration);
4633 }
4634 else
4635 {
4636 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_CONFIGURATION(kmalloc failed)\n"));
4637 Status = -EFAULT;
4638 }
4639 break;
4640 case RT_OID_802_11_SNR_0:
4641 if ((pAdapter->StaCfg.LastSNR0 > 0))
4642 {
4643 ulInfo = ((0xeb - pAdapter->StaCfg.LastSNR0) * 3) / 16 ;
4644 wrq->u.data.length = sizeof(ulInfo);
4645 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4646 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_SNR_0(0x=%lx)\n", ulInfo));
4647 }
4648 else
4649 Status = -EFAULT;
4650 break;
4651 case RT_OID_802_11_SNR_1:
4652 if ((pAdapter->Antenna.field.RxPath > 1) &&
4653 (pAdapter->StaCfg.LastSNR1 > 0))
4654 {
4655 ulInfo = ((0xeb - pAdapter->StaCfg.LastSNR1) * 3) / 16 ;
4656 wrq->u.data.length = sizeof(ulInfo);
4657 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4658 DBGPRINT(RT_DEBUG_TRACE,("Query::RT_OID_802_11_SNR_1(0x=%lx)\n",ulInfo));
4659 }
4660 else
4661 Status = -EFAULT;
4662 DBGPRINT(RT_DEBUG_TRACE,("Query::RT_OID_802_11_SNR_1(pAdapter->StaCfg.LastSNR1=%d)\n",pAdapter->StaCfg.LastSNR1));
4663 break;
4664 case OID_802_11_RSSI_TRIGGER:
4665 ulInfo = pAdapter->StaCfg.RssiSample.LastRssi0 - pAdapter->BbpRssiToDbmDelta;
4666 wrq->u.data.length = sizeof(ulInfo);
4667 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4668 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_RSSI_TRIGGER(=%ld)\n", ulInfo));
4669 break;
4670 case OID_802_11_RSSI:
4671 case RT_OID_802_11_RSSI:
4672 ulInfo = pAdapter->StaCfg.RssiSample.LastRssi0;
4673 wrq->u.data.length = sizeof(ulInfo);
4674 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4675 break;
4676 case RT_OID_802_11_RSSI_1:
4677 ulInfo = pAdapter->StaCfg.RssiSample.LastRssi1;
4678 wrq->u.data.length = sizeof(ulInfo);
4679 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4680 break;
4681 case RT_OID_802_11_RSSI_2:
4682 ulInfo = pAdapter->StaCfg.RssiSample.LastRssi2;
4683 wrq->u.data.length = sizeof(ulInfo);
4684 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4685 break;
4686 case OID_802_11_STATISTICS:
4687 pStatistics = (NDIS_802_11_STATISTICS *) kmalloc(sizeof(NDIS_802_11_STATISTICS), MEM_ALLOC_FLAG);
4688 if (pStatistics)
4689 {
4690 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_STATISTICS \n"));
4691 // add the most up-to-date h/w raw counters into software counters
4692 NICUpdateRawCounters(pAdapter);
4693
4694 // Sanity check for calculation of sucessful count
4695 if (pAdapter->WlanCounters.TransmittedFragmentCount.QuadPart < pAdapter->WlanCounters.RetryCount.QuadPart)
4696 pAdapter->WlanCounters.TransmittedFragmentCount.QuadPart = pAdapter->WlanCounters.RetryCount.QuadPart;
4697
4698 pStatistics->TransmittedFragmentCount.QuadPart = pAdapter->WlanCounters.TransmittedFragmentCount.QuadPart;
4699 pStatistics->MulticastTransmittedFrameCount.QuadPart = pAdapter->WlanCounters.MulticastTransmittedFrameCount.QuadPart;
4700 pStatistics->FailedCount.QuadPart = pAdapter->WlanCounters.FailedCount.QuadPart;
4701 pStatistics->RetryCount.QuadPart = pAdapter->WlanCounters.RetryCount.QuadPart;
4702 pStatistics->MultipleRetryCount.QuadPart = pAdapter->WlanCounters.MultipleRetryCount.QuadPart;
4703 pStatistics->RTSSuccessCount.QuadPart = pAdapter->WlanCounters.RTSSuccessCount.QuadPart;
4704 pStatistics->RTSFailureCount.QuadPart = pAdapter->WlanCounters.RTSFailureCount.QuadPart;
4705 pStatistics->ACKFailureCount.QuadPart = pAdapter->WlanCounters.ACKFailureCount.QuadPart;
4706 pStatistics->FrameDuplicateCount.QuadPart = pAdapter->WlanCounters.FrameDuplicateCount.QuadPart;
4707 pStatistics->ReceivedFragmentCount.QuadPart = pAdapter->WlanCounters.ReceivedFragmentCount.QuadPart;
4708 pStatistics->MulticastReceivedFrameCount.QuadPart = pAdapter->WlanCounters.MulticastReceivedFrameCount.QuadPart;
4709#ifdef DBG
4710 pStatistics->FCSErrorCount = pAdapter->RalinkCounters.RealFcsErrCount;
4711#else
4712 pStatistics->FCSErrorCount.QuadPart = pAdapter->WlanCounters.FCSErrorCount.QuadPart;
4713 pStatistics->FrameDuplicateCount.u.LowPart = pAdapter->WlanCounters.FrameDuplicateCount.u.LowPart / 100;
4714#endif
4715 wrq->u.data.length = sizeof(NDIS_802_11_STATISTICS);
4716 Status = copy_to_user(wrq->u.data.pointer, pStatistics, wrq->u.data.length);
4717 kfree(pStatistics);
4718 }
4719 else
4720 {
4721 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_STATISTICS(kmalloc failed)\n"));
4722 Status = -EFAULT;
4723 }
4724 break;
4725 case OID_GEN_RCV_OK:
4726 ulInfo = pAdapter->Counters8023.GoodReceives;
4727 wrq->u.data.length = sizeof(ulInfo);
4728 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4729 break;
4730 case OID_GEN_RCV_NO_BUFFER:
4731 ulInfo = pAdapter->Counters8023.RxNoBuffer;
4732 wrq->u.data.length = sizeof(ulInfo);
4733 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4734 break;
4735 case RT_OID_802_11_PHY_MODE:
4736 ulInfo = (ULONG)pAdapter->CommonCfg.PhyMode;
4737 wrq->u.data.length = sizeof(ulInfo);
4738 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4739 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_PHY_MODE (=%ld)\n", ulInfo));
4740 break;
4741 case RT_OID_802_11_STA_CONFIG:
4742 pStaConfig = (RT_802_11_STA_CONFIG *) kmalloc(sizeof(RT_802_11_STA_CONFIG), MEM_ALLOC_FLAG);
4743 if (pStaConfig)
4744 {
4745 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_STA_CONFIG\n"));
4746 pStaConfig->EnableTxBurst = pAdapter->CommonCfg.bEnableTxBurst;
4747 pStaConfig->EnableTurboRate = 0;
4748 pStaConfig->UseBGProtection = pAdapter->CommonCfg.UseBGProtection;
4749 pStaConfig->UseShortSlotTime = pAdapter->CommonCfg.bUseShortSlotTime;
4750 //pStaConfig->AdhocMode = pAdapter->StaCfg.AdhocMode;
4751 pStaConfig->HwRadioStatus = (pAdapter->StaCfg.bHwRadio == TRUE) ? 1 : 0;
4752 pStaConfig->Rsv1 = 0;
4753 pStaConfig->SystemErrorBitmap = pAdapter->SystemErrorBitmap;
4754 wrq->u.data.length = sizeof(RT_802_11_STA_CONFIG);
4755 Status = copy_to_user(wrq->u.data.pointer, pStaConfig, wrq->u.data.length);
4756 kfree(pStaConfig);
4757 }
4758 else
4759 {
4760 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_STA_CONFIG(kmalloc failed)\n"));
4761 Status = -EFAULT;
4762 }
4763 break;
4764 case OID_802_11_RTS_THRESHOLD:
4765 RtsThresh = pAdapter->CommonCfg.RtsThreshold;
4766 wrq->u.data.length = sizeof(RtsThresh);
4767 Status = copy_to_user(wrq->u.data.pointer, &RtsThresh, wrq->u.data.length);
4768 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_RTS_THRESHOLD(=%ld)\n", RtsThresh));
4769 break;
4770 case OID_802_11_FRAGMENTATION_THRESHOLD:
4771 FragThresh = pAdapter->CommonCfg.FragmentThreshold;
4772 if (pAdapter->CommonCfg.bUseZeroToDisableFragment == TRUE)
4773 FragThresh = 0;
4774 wrq->u.data.length = sizeof(FragThresh);
4775 Status = copy_to_user(wrq->u.data.pointer, &FragThresh, wrq->u.data.length);
4776 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_FRAGMENTATION_THRESHOLD(=%ld)\n", FragThresh));
4777 break;
4778 case OID_802_11_POWER_MODE:
4779 PowerMode = pAdapter->StaCfg.WindowsPowerMode;
4780 wrq->u.data.length = sizeof(PowerMode);
4781 Status = copy_to_user(wrq->u.data.pointer, &PowerMode, wrq->u.data.length);
4782 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_POWER_MODE(=%d)\n", PowerMode));
4783 break;
4784 case RT_OID_802_11_RADIO:
4785 RadioState = (BOOLEAN) pAdapter->StaCfg.bSwRadio;
4786 wrq->u.data.length = sizeof(RadioState);
4787 Status = copy_to_user(wrq->u.data.pointer, &RadioState, wrq->u.data.length);
4788 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_RADIO (=%d)\n", RadioState));
4789 break;
4790 case OID_802_11_INFRASTRUCTURE_MODE:
4791 if (pAdapter->StaCfg.BssType == BSS_ADHOC)
4792 BssType = Ndis802_11IBSS;
4793 else if (pAdapter->StaCfg.BssType == BSS_INFRA)
4794 BssType = Ndis802_11Infrastructure;
4795 else if (pAdapter->StaCfg.BssType == BSS_MONITOR)
4796 BssType = Ndis802_11Monitor;
4797 else
4798 BssType = Ndis802_11AutoUnknown;
4799
4800 wrq->u.data.length = sizeof(BssType);
4801 Status = copy_to_user(wrq->u.data.pointer, &BssType, wrq->u.data.length);
4802 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_INFRASTRUCTURE_MODE(=%d)\n", BssType));
4803 break;
4804 case RT_OID_802_11_PREAMBLE:
4805 PreamType = pAdapter->CommonCfg.TxPreamble;
4806 wrq->u.data.length = sizeof(PreamType);
4807 Status = copy_to_user(wrq->u.data.pointer, &PreamType, wrq->u.data.length);
4808 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_PREAMBLE(=%d)\n", PreamType));
4809 break;
4810 case OID_802_11_AUTHENTICATION_MODE:
4811 AuthMode = pAdapter->StaCfg.AuthMode;
4812 wrq->u.data.length = sizeof(AuthMode);
4813 Status = copy_to_user(wrq->u.data.pointer, &AuthMode, wrq->u.data.length);
4814 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_AUTHENTICATION_MODE(=%d)\n", AuthMode));
4815 break;
4816 case OID_802_11_WEP_STATUS:
4817 WepStatus = pAdapter->StaCfg.WepStatus;
4818 wrq->u.data.length = sizeof(WepStatus);
4819 Status = copy_to_user(wrq->u.data.pointer, &WepStatus, wrq->u.data.length);
4820 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_WEP_STATUS(=%d)\n", WepStatus));
4821 break;
4822 case OID_802_11_TX_POWER_LEVEL:
4823 wrq->u.data.length = sizeof(ULONG);
4824 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.TxPower, wrq->u.data.length);
4825 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_TX_POWER_LEVEL %x\n",pAdapter->CommonCfg.TxPower));
4826 break;
4827 case RT_OID_802_11_TX_POWER_LEVEL_1:
4828 wrq->u.data.length = sizeof(ULONG);
4829 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.TxPowerPercentage, wrq->u.data.length);
4830 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_TX_POWER_LEVEL_1 (=%ld)\n", pAdapter->CommonCfg.TxPowerPercentage));
4831 break;
4832 case OID_802_11_NETWORK_TYPES_SUPPORTED:
4833 if ((pAdapter->RfIcType == RFIC_2850) || (pAdapter->RfIcType == RFIC_2750))
4834 {
4835 NetworkTypeList[0] = 3; // NumberOfItems = 3
4836 NetworkTypeList[1] = Ndis802_11DS; // NetworkType[1] = 11b
4837 NetworkTypeList[2] = Ndis802_11OFDM24; // NetworkType[2] = 11g
4838 NetworkTypeList[3] = Ndis802_11OFDM5; // NetworkType[3] = 11a
4839 wrq->u.data.length = 16;
4840 Status = copy_to_user(wrq->u.data.pointer, &NetworkTypeList[0], wrq->u.data.length);
4841 }
4842 else
4843 {
4844 NetworkTypeList[0] = 2; // NumberOfItems = 2
4845 NetworkTypeList[1] = Ndis802_11DS; // NetworkType[1] = 11b
4846 NetworkTypeList[2] = Ndis802_11OFDM24; // NetworkType[2] = 11g
4847 wrq->u.data.length = 12;
4848 Status = copy_to_user(wrq->u.data.pointer, &NetworkTypeList[0], wrq->u.data.length);
4849 }
4850 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_NETWORK_TYPES_SUPPORTED\n"));
4851 break;
4852 case OID_802_11_NETWORK_TYPE_IN_USE:
4853 wrq->u.data.length = sizeof(ULONG);
4854 if (pAdapter->CommonCfg.PhyMode == PHY_11A)
4855 ulInfo = Ndis802_11OFDM5;
4856 else if ((pAdapter->CommonCfg.PhyMode == PHY_11BG_MIXED) || (pAdapter->CommonCfg.PhyMode == PHY_11G))
4857 ulInfo = Ndis802_11OFDM24;
4858 else
4859 ulInfo = Ndis802_11DS;
4860 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4861 break;
4862 case RT_OID_802_11_QUERY_LAST_RX_RATE:
4863 ulInfo = (ULONG)pAdapter->LastRxRate;
4864 wrq->u.data.length = sizeof(ulInfo);
4865 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4866 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_LAST_RX_RATE (=%ld)\n", ulInfo));
4867 break;
4868 case RT_OID_802_11_QUERY_LAST_TX_RATE:
4869 //ulInfo = (ULONG)pAdapter->LastTxRate;
4870 ulInfo = (ULONG)pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.word;
4871 wrq->u.data.length = sizeof(ulInfo);
4872 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4873 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_LAST_TX_RATE (=%lx)\n", ulInfo));
4874 break;
4875 case RT_OID_802_11_QUERY_EEPROM_VERSION:
4876 wrq->u.data.length = sizeof(ULONG);
4877 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->EepromVersion, wrq->u.data.length);
4878 break;
4879 case RT_OID_802_11_QUERY_FIRMWARE_VERSION:
4880 wrq->u.data.length = sizeof(ULONG);
4881 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->FirmwareVersion, wrq->u.data.length);
4882 break;
4883 case RT_OID_802_11_QUERY_NOISE_LEVEL:
4884 wrq->u.data.length = sizeof(UCHAR);
4885 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->BbpWriteLatch[66], wrq->u.data.length);
4886 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_NOISE_LEVEL (=%d)\n", pAdapter->BbpWriteLatch[66]));
4887 break;
4888 case RT_OID_802_11_EXTRA_INFO:
4889 wrq->u.data.length = sizeof(ULONG);
4890 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->ExtraInfo, wrq->u.data.length);
4891 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_EXTRA_INFO (=%ld)\n", pAdapter->ExtraInfo));
4892 break;
4893 case RT_OID_WE_VERSION_COMPILED:
4894 wrq->u.data.length = sizeof(UINT);
4895 we_version_compiled = WIRELESS_EXT;
4896 Status = copy_to_user(wrq->u.data.pointer, &we_version_compiled, wrq->u.data.length);
4897 break;
4898 case RT_OID_802_11_QUERY_APSD_SETTING:
4899 apsd = (pAdapter->CommonCfg.bAPSDCapable | (pAdapter->CommonCfg.bAPSDAC_BE << 1) | (pAdapter->CommonCfg.bAPSDAC_BK << 2)
4900 | (pAdapter->CommonCfg.bAPSDAC_VI << 3) | (pAdapter->CommonCfg.bAPSDAC_VO << 4) | (pAdapter->CommonCfg.MaxSPLength << 5));
4901
4902 wrq->u.data.length = sizeof(ULONG);
4903 Status = copy_to_user(wrq->u.data.pointer, &apsd, wrq->u.data.length);
4904 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_APSD_SETTING (=0x%lx,APSDCap=%d,AC_BE=%d,AC_BK=%d,AC_VI=%d,AC_VO=%d,MAXSPLen=%d)\n",
4905 apsd,pAdapter->CommonCfg.bAPSDCapable,pAdapter->CommonCfg.bAPSDAC_BE,pAdapter->CommonCfg.bAPSDAC_BK,pAdapter->CommonCfg.bAPSDAC_VI,pAdapter->CommonCfg.bAPSDAC_VO,pAdapter->CommonCfg.MaxSPLength));
4906 break;
4907 case RT_OID_802_11_QUERY_APSD_PSM:
4908 wrq->u.data.length = sizeof(ULONG);
4909 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.bAPSDForcePowerSave, wrq->u.data.length);
4910 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_APSD_PSM (=%d)\n", pAdapter->CommonCfg.bAPSDForcePowerSave));
4911 break;
4912 case RT_OID_802_11_QUERY_WMM:
4913 wrq->u.data.length = sizeof(BOOLEAN);
4914 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.bWmmCapable, wrq->u.data.length);
4915 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_WMM (=%d)\n", pAdapter->CommonCfg.bWmmCapable));
4916 break;
4917 case RT_OID_NEW_DRIVER:
4918 {
4919 UCHAR enabled = 1;
4920 wrq->u.data.length = sizeof(UCHAR);
4921 Status = copy_to_user(wrq->u.data.pointer, &enabled, wrq->u.data.length);
4922 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_NEW_DRIVER (=%d)\n", enabled));
4923 }
4924 break;
4925 case RT_OID_WPA_SUPPLICANT_SUPPORT:
4926 wrq->u.data.length = sizeof(UCHAR);
4927 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->StaCfg.WpaSupplicantUP, wrq->u.data.length);
4928 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_WPA_SUPPLICANT_SUPPORT (=%d)\n", pAdapter->StaCfg.WpaSupplicantUP));
4929 break;
4930 case RT_OID_DRIVER_DEVICE_NAME:
4931 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_DRIVER_DEVICE_NAME \n"));
4932 wrq->u.data.length = 16;
4933 if (copy_to_user(wrq->u.data.pointer, pAdapter->StaCfg.dev_name, wrq->u.data.length))
4934 {
4935 Status = -EFAULT;
4936 }
4937 break;
4938 case RT_OID_802_11_QUERY_HT_PHYMODE:
4939 pHTPhyMode = (OID_SET_HT_PHYMODE *) kmalloc(sizeof(OID_SET_HT_PHYMODE), MEM_ALLOC_FLAG);
4940 if (pHTPhyMode)
4941 {
4942 pHTPhyMode->PhyMode = pAdapter->CommonCfg.PhyMode;
4943 pHTPhyMode->HtMode = (UCHAR)pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.field.MODE;
4944 pHTPhyMode->BW = (UCHAR)pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.field.BW;
4945 pHTPhyMode->MCS= (UCHAR)pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.field.MCS;
4946 pHTPhyMode->SHORTGI= (UCHAR)pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.field.ShortGI;
4947 pHTPhyMode->STBC= (UCHAR)pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.field.STBC;
4948
4949 pHTPhyMode->ExtOffset = ((pAdapter->CommonCfg.CentralChannel < pAdapter->CommonCfg.Channel) ? (EXTCHA_BELOW) : (EXTCHA_ABOVE));
4950 wrq->u.data.length = sizeof(OID_SET_HT_PHYMODE);
4951 if (copy_to_user(wrq->u.data.pointer, pHTPhyMode, wrq->u.data.length))
4952 {
4953 Status = -EFAULT;
4954 }
4955 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_HT_PHYMODE (PhyMode = %d, MCS =%d, BW = %d, STBC = %d, ExtOffset=%d)\n",
4956 pHTPhyMode->HtMode, pHTPhyMode->MCS, pHTPhyMode->BW, pHTPhyMode->STBC, pHTPhyMode->ExtOffset));
4957 DBGPRINT(RT_DEBUG_TRACE, (" MlmeUpdateTxRates (.word = %x )\n", pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.word));
4958 }
4959 else
4960 {
4961 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_STA_CONFIG(kmalloc failed)\n"));
4962 Status = -EFAULT;
4963 }
4964 break;
4965 case RT_OID_802_11_COUNTRY_REGION:
4966 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_COUNTRY_REGION \n"));
4967 wrq->u.data.length = sizeof(ulInfo);
4968 ulInfo = pAdapter->CommonCfg.CountryRegionForABand;
4969 ulInfo = (ulInfo << 8)|(pAdapter->CommonCfg.CountryRegion);
4970 if (copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length))
4971 {
4972 Status = -EFAULT;
4973 }
4974 break;
4975 case RT_OID_802_11_QUERY_DAT_HT_PHYMODE:
4976 pHTPhyMode = (OID_SET_HT_PHYMODE *) kmalloc(sizeof(OID_SET_HT_PHYMODE), MEM_ALLOC_FLAG);
4977 if (pHTPhyMode)
4978 {
4979 pHTPhyMode->PhyMode = pAdapter->CommonCfg.PhyMode;
4980 pHTPhyMode->HtMode = (UCHAR)pAdapter->CommonCfg.RegTransmitSetting.field.HTMODE;
4981 pHTPhyMode->BW = (UCHAR)pAdapter->CommonCfg.RegTransmitSetting.field.BW;
4982 pHTPhyMode->MCS= (UCHAR)pAdapter->StaCfg.DesiredTransmitSetting.field.MCS;
4983 pHTPhyMode->SHORTGI= (UCHAR)pAdapter->CommonCfg.RegTransmitSetting.field.ShortGI;
4984 pHTPhyMode->STBC= (UCHAR)pAdapter->CommonCfg.RegTransmitSetting.field.STBC;
4985
4986 wrq->u.data.length = sizeof(OID_SET_HT_PHYMODE);
4987 if (copy_to_user(wrq->u.data.pointer, pHTPhyMode, wrq->u.data.length))
4988 {
4989 Status = -EFAULT;
4990 }
4991 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_HT_PHYMODE (PhyMode = %d, MCS =%d, BW = %d, STBC = %d, ExtOffset=%d)\n",
4992 pHTPhyMode->HtMode, pHTPhyMode->MCS, pHTPhyMode->BW, pHTPhyMode->STBC, pHTPhyMode->ExtOffset));
4993 DBGPRINT(RT_DEBUG_TRACE, (" MlmeUpdateTxRates (.word = %x )\n", pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.word));
4994 }
4995 else
4996 {
4997 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_STA_CONFIG(kmalloc failed)\n"));
4998 Status = -EFAULT;
4999 }
5000 break;
5001 case RT_OID_QUERY_MULTIPLE_CARD_SUPPORT:
5002 wrq->u.data.length = sizeof(UCHAR);
5003 i = 0;
5004 if (copy_to_user(wrq->u.data.pointer, &i, wrq->u.data.length))
5005 {
5006 Status = -EFAULT;
5007 }
5008 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_QUERY_MULTIPLE_CARD_SUPPORT(=%d) \n", i));
5009 break;
5010
5011 case OID_802_11_BUILD_CHANNEL_EX:
5012 {
5013 UCHAR value;
5014 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_BUILD_CHANNEL_EX \n"));
5015 wrq->u.data.length = sizeof(UCHAR);
5016 DBGPRINT(RT_DEBUG_TRACE, ("Doesn't support EXT_BUILD_CHANNEL_LIST.\n"));
5017 value = 0;
5018 Status = copy_to_user(wrq->u.data.pointer, &value, 1);
5019 DBGPRINT(RT_DEBUG_TRACE, ("Status=%d\n", Status));
5020 }
5021 break;
5022
5023 case OID_802_11_GET_CH_LIST:
5024 {
5025 PRT_CHANNEL_LIST_INFO pChListBuf;
5026
5027 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_GET_CH_LIST \n"));
5028 if (pAdapter->ChannelListNum == 0)
5029 {
5030 wrq->u.data.length = 0;
5031 break;
5032 }
5033
5034 pChListBuf = (RT_CHANNEL_LIST_INFO *) kmalloc(sizeof(RT_CHANNEL_LIST_INFO), MEM_ALLOC_FLAG);
5035 if (pChListBuf == NULL)
5036 {
5037 wrq->u.data.length = 0;
5038 break;
5039 }
5040
5041 pChListBuf->ChannelListNum = pAdapter->ChannelListNum;
5042 for (i = 0; i < pChListBuf->ChannelListNum; i++)
5043 pChListBuf->ChannelList[i] = pAdapter->ChannelList[i].Channel;
5044
5045 wrq->u.data.length = sizeof(RT_CHANNEL_LIST_INFO);
5046 Status = copy_to_user(wrq->u.data.pointer, pChListBuf, sizeof(RT_CHANNEL_LIST_INFO));
5047 DBGPRINT(RT_DEBUG_TRACE, ("Status=%d\n", Status));
5048
5049 if (pChListBuf)
5050 kfree(pChListBuf);
5051 }
5052 break;
5053
5054 case OID_802_11_GET_COUNTRY_CODE:
5055 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_GET_COUNTRY_CODE \n"));
5056 wrq->u.data.length = 2;
5057 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.CountryCode, 2);
5058 DBGPRINT(RT_DEBUG_TRACE, ("Status=%d\n", Status));
5059 break;
5060
5061 case OID_802_11_GET_CHANNEL_GEOGRAPHY:
5062 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_GET_CHANNEL_GEOGRAPHY \n"));
5063 wrq->u.data.length = 1;
5064 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.Geography, 1);
5065 DBGPRINT(RT_DEBUG_TRACE, ("Status=%d\n", Status));
5066 break;
5067
5068 default:
5069 DBGPRINT(RT_DEBUG_TRACE, ("Query::unknown IOCTL's subcmd = 0x%08x\n", cmd));
5070 Status = -EOPNOTSUPP;
5071 break;
5072 }
5073 return Status;
5074}
5075
5076INT rt28xx_sta_ioctl(
5077 IN struct net_device *net_dev,
5078 IN OUT struct ifreq *rq,
5079 IN INT cmd)
5080{
5081 POS_COOKIE pObj;
5082 VIRTUAL_ADAPTER *pVirtualAd = NULL;
5083 RTMP_ADAPTER *pAd = NULL;
5084 struct iwreq *wrq = (struct iwreq *) rq;
5085 BOOLEAN StateMachineTouched = FALSE;
5086 INT Status = NDIS_STATUS_SUCCESS;
5087 USHORT subcmd;
5088
5089 if (net_dev->priv_flags == INT_MAIN)
5090 {
5091 pAd = net_dev->ml_priv;
5092 }
5093 else
5094 {
5095 pVirtualAd = net_dev->ml_priv;
5096 pAd = pVirtualAd->RtmpDev->ml_priv;
5097 }
5098 pObj = (POS_COOKIE) pAd->OS_Cookie;
5099
5100 if (pAd == NULL)
5101 {
5102 /* if 1st open fail, pAd will be free;
5103 So the net_dev->ml_priv will be NULL in 2rd open */
5104 return -ENETDOWN;
5105 }
5106
5107 //check if the interface is down
5108 if(!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_IN_USE))
5109 {
5110 {
5111 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
5112 return -ENETDOWN;
5113 }
5114 }
5115
5116 { // determine this ioctl command is comming from which interface.
5117 pObj->ioctl_if_type = INT_MAIN;
5118 pObj->ioctl_if = MAIN_MBSSID;
5119 }
5120
5121 switch(cmd)
5122 {
5123 case SIOCGIFHWADDR:
5124 DBGPRINT(RT_DEBUG_TRACE, ("IOCTL::SIOCGIFHWADDR\n"));
5125 memcpy(wrq->u.name, pAd->CurrentAddress, ETH_ALEN);
5126 break;
5127 case SIOCGIWNAME:
5128 {
5129 char *name=&wrq->u.name[0];
5130 rt_ioctl_giwname(net_dev, NULL, name, NULL);
5131 break;
5132 }
5133 case SIOCGIWESSID: //Get ESSID
5134 {
5135 struct iw_point *essid=&wrq->u.essid;
5136 rt_ioctl_giwessid(net_dev, NULL, essid, essid->pointer);
5137 break;
5138 }
5139 case SIOCSIWESSID: //Set ESSID
5140 {
5141 struct iw_point *essid=&wrq->u.essid;
5142 rt_ioctl_siwessid(net_dev, NULL, essid, essid->pointer);
5143 break;
5144 }
5145 case SIOCSIWNWID: // set network id (the cell)
5146 case SIOCGIWNWID: // get network id
5147 Status = -EOPNOTSUPP;
5148 break;
5149 case SIOCSIWFREQ: //set channel/frequency (Hz)
5150 {
5151 struct iw_freq *freq=&wrq->u.freq;
5152 rt_ioctl_siwfreq(net_dev, NULL, freq, NULL);
5153 break;
5154 }
5155 case SIOCGIWFREQ: // get channel/frequency (Hz)
5156 {
5157 struct iw_freq *freq=&wrq->u.freq;
5158 rt_ioctl_giwfreq(net_dev, NULL, freq, NULL);
5159 break;
5160 }
5161 case SIOCSIWNICKN: //set node name/nickname
5162 {
5163 struct iw_point *data=&wrq->u.data;
5164 rt_ioctl_siwnickn(net_dev, NULL, data, NULL);
5165 break;
5166 }
5167 case SIOCGIWNICKN: //get node name/nickname
5168 {
5169 struct iw_point *data=&wrq->u.data;
5170 rt_ioctl_giwnickn(net_dev, NULL, data, NULL);
5171 break;
5172 }
5173 case SIOCGIWRATE: //get default bit rate (bps)
5174 rt_ioctl_giwrate(net_dev, NULL, &wrq->u, NULL);
5175 break;
5176 case SIOCSIWRATE: //set default bit rate (bps)
5177 rt_ioctl_siwrate(net_dev, NULL, &wrq->u, NULL);
5178 break;
5179 case SIOCGIWRTS: // get RTS/CTS threshold (bytes)
5180 {
5181 struct iw_param *rts=&wrq->u.rts;
5182 rt_ioctl_giwrts(net_dev, NULL, rts, NULL);
5183 break;
5184 }
5185 case SIOCSIWRTS: //set RTS/CTS threshold (bytes)
5186 {
5187 struct iw_param *rts=&wrq->u.rts;
5188 rt_ioctl_siwrts(net_dev, NULL, rts, NULL);
5189 break;
5190 }
5191 case SIOCGIWFRAG: //get fragmentation thr (bytes)
5192 {
5193 struct iw_param *frag=&wrq->u.frag;
5194 rt_ioctl_giwfrag(net_dev, NULL, frag, NULL);
5195 break;
5196 }
5197 case SIOCSIWFRAG: //set fragmentation thr (bytes)
5198 {
5199 struct iw_param *frag=&wrq->u.frag;
5200 rt_ioctl_siwfrag(net_dev, NULL, frag, NULL);
5201 break;
5202 }
5203 case SIOCGIWENCODE: //get encoding token & mode
5204 {
5205 struct iw_point *erq=&wrq->u.encoding;
5206 if(erq->pointer)
5207 rt_ioctl_giwencode(net_dev, NULL, erq, erq->pointer);
5208 break;
5209 }
5210 case SIOCSIWENCODE: //set encoding token & mode
5211 {
5212 struct iw_point *erq=&wrq->u.encoding;
5213 if(erq->pointer)
5214 rt_ioctl_siwencode(net_dev, NULL, erq, erq->pointer);
5215 break;
5216 }
5217 case SIOCGIWAP: //get access point MAC addresses
5218 {
5219 struct sockaddr *ap_addr=&wrq->u.ap_addr;
5220 rt_ioctl_giwap(net_dev, NULL, ap_addr, ap_addr->sa_data);
5221 break;
5222 }
5223 case SIOCSIWAP: //set access point MAC addresses
5224 {
5225 struct sockaddr *ap_addr=&wrq->u.ap_addr;
5226 rt_ioctl_siwap(net_dev, NULL, ap_addr, ap_addr->sa_data);
5227 break;
5228 }
5229 case SIOCGIWMODE: //get operation mode
5230 {
5231 __u32 *mode=&wrq->u.mode;
5232 rt_ioctl_giwmode(net_dev, NULL, mode, NULL);
5233 break;
5234 }
5235 case SIOCSIWMODE: //set operation mode
5236 {
5237 __u32 *mode=&wrq->u.mode;
5238 rt_ioctl_siwmode(net_dev, NULL, mode, NULL);
5239 break;
5240 }
5241 case SIOCGIWSENS: //get sensitivity (dBm)
5242 case SIOCSIWSENS: //set sensitivity (dBm)
5243 case SIOCGIWPOWER: //get Power Management settings
5244 case SIOCSIWPOWER: //set Power Management settings
5245 case SIOCGIWTXPOW: //get transmit power (dBm)
5246 case SIOCSIWTXPOW: //set transmit power (dBm)
5247 case SIOCGIWRANGE: //Get range of parameters
5248 case SIOCGIWRETRY: //get retry limits and lifetime
5249 case SIOCSIWRETRY: //set retry limits and lifetime
5250 Status = -EOPNOTSUPP;
5251 break;
5252 case RT_PRIV_IOCTL:
5253#ifdef RT30xx
5254 case RT_PRIV_IOCTL_EXT:
5255#endif
5256 subcmd = wrq->u.data.flags;
5257 if( subcmd & OID_GET_SET_TOGGLE)
5258 Status = RTMPSetInformation(pAd, rq, subcmd);
5259 else
5260 Status = RTMPQueryInformation(pAd, rq, subcmd);
5261 break;
5262 case SIOCGIWPRIV:
5263 if (wrq->u.data.pointer)
5264 {
5265 if ( access_ok(VERIFY_WRITE, wrq->u.data.pointer, sizeof(privtab)) != TRUE)
5266 break;
5267 wrq->u.data.length = sizeof(privtab) / sizeof(privtab[0]);
5268 if (copy_to_user(wrq->u.data.pointer, privtab, sizeof(privtab)))
5269 Status = -EFAULT;
5270 }
5271 break;
5272 case RTPRIV_IOCTL_SET:
5273 if(access_ok(VERIFY_READ, wrq->u.data.pointer, wrq->u.data.length) != TRUE)
5274 break;
5275 rt_ioctl_setparam(net_dev, NULL, NULL, wrq->u.data.pointer);
5276 break;
5277 case RTPRIV_IOCTL_GSITESURVEY:
5278 RTMPIoctlGetSiteSurvey(pAd, wrq);
5279 break;
5280#ifdef DBG
5281 case RTPRIV_IOCTL_MAC:
5282 RTMPIoctlMAC(pAd, wrq);
5283 break;
5284 case RTPRIV_IOCTL_E2P:
5285 RTMPIoctlE2PROM(pAd, wrq);
5286 break;
5287#ifdef RT30xx
5288 case RTPRIV_IOCTL_RF:
5289 RTMPIoctlRF(pAd, wrq);
5290 break;
5291#endif // RT30xx //
5292#endif // DBG //
5293 case SIOCETHTOOL:
5294 break;
5295 default:
5296 DBGPRINT(RT_DEBUG_ERROR, ("IOCTL::unknown IOCTL's cmd = 0x%08x\n", cmd));
5297 Status = -EOPNOTSUPP;
5298 break;
5299 }
5300
5301 if(StateMachineTouched) // Upper layer sent a MLME-related operations
5302 RT28XX_MLME_HANDLER(pAd);
5303
5304 return Status;
5305}
5306
5307/*
5308 ==========================================================================
5309 Description:
5310 Set SSID
5311 Return:
5312 TRUE if all parameters are OK, FALSE otherwise
5313 ==========================================================================
5314*/
5315INT Set_SSID_Proc(
5316 IN PRTMP_ADAPTER pAdapter,
5317 IN PUCHAR arg)
5318{
5319 NDIS_802_11_SSID Ssid, *pSsid=NULL;
5320 BOOLEAN StateMachineTouched = FALSE;
5321 int success = TRUE;
5322
5323 if( strlen(arg) <= MAX_LEN_OF_SSID)
5324 {
5325 NdisZeroMemory(&Ssid, sizeof(NDIS_802_11_SSID));
5326 if (strlen(arg) != 0)
5327 {
5328 NdisMoveMemory(Ssid.Ssid, arg, strlen(arg));
5329 Ssid.SsidLength = strlen(arg);
5330 }
5331 else //ANY ssid
5332 {
5333 Ssid.SsidLength = 0;
5334 memcpy(Ssid.Ssid, "", 0);
5335 pAdapter->StaCfg.BssType = BSS_INFRA;
5336 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
5337 pAdapter->StaCfg.WepStatus = Ndis802_11EncryptionDisabled;
5338 }
5339 pSsid = &Ssid;
5340
5341 if (pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE)
5342 {
5343 RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
5344 DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
5345 }
5346
5347 pAdapter->MlmeAux.CurrReqIsFromNdis = TRUE;
5348 pAdapter->StaCfg.bScanReqIsFromWebUI = FALSE;
5349 pAdapter->bConfigChanged = TRUE;
5350
5351 MlmeEnqueue(pAdapter,
5352 MLME_CNTL_STATE_MACHINE,
5353 OID_802_11_SSID,
5354 sizeof(NDIS_802_11_SSID),
5355 (VOID *)pSsid);
5356
5357 StateMachineTouched = TRUE;
5358 DBGPRINT(RT_DEBUG_TRACE, ("Set_SSID_Proc::(Len=%d,Ssid=%s)\n", Ssid.SsidLength, Ssid.Ssid));
5359 }
5360 else
5361 success = FALSE;
5362
5363 if (StateMachineTouched) // Upper layer sent a MLME-related operations
5364 RT28XX_MLME_HANDLER(pAdapter);
5365
5366 return success;
5367}
5368
5369#ifdef WMM_SUPPORT
5370/*
5371 ==========================================================================
5372 Description:
5373 Set WmmCapable Enable or Disable
5374 Return:
5375 TRUE if all parameters are OK, FALSE otherwise
5376 ==========================================================================
5377*/
5378INT Set_WmmCapable_Proc(
5379 IN PRTMP_ADAPTER pAd,
5380 IN PUCHAR arg)
5381{
5382 BOOLEAN bWmmCapable;
5383
5384 bWmmCapable = simple_strtol(arg, 0, 10);
5385
5386 if ((bWmmCapable == 1)
5387#ifdef RT2870
5388 && (pAd->NumberOfPipes >= 5)
5389#endif // RT2870 //
5390 )
5391 pAd->CommonCfg.bWmmCapable = TRUE;
5392 else if (bWmmCapable == 0)
5393 pAd->CommonCfg.bWmmCapable = FALSE;
5394 else
5395 return FALSE; //Invalid argument
5396
5397 DBGPRINT(RT_DEBUG_TRACE, ("Set_WmmCapable_Proc::(bWmmCapable=%d)\n",
5398 pAd->CommonCfg.bWmmCapable));
5399
5400 return TRUE;
5401}
5402#endif // WMM_SUPPORT //
5403
5404/*
5405 ==========================================================================
5406 Description:
5407 Set Network Type(Infrastructure/Adhoc mode)
5408 Return:
5409 TRUE if all parameters are OK, FALSE otherwise
5410 ==========================================================================
5411*/
5412INT Set_NetworkType_Proc(
5413 IN PRTMP_ADAPTER pAdapter,
5414 IN PUCHAR arg)
5415{
5416 UINT32 Value = 0;
5417
5418 if (strcmp(arg, "Adhoc") == 0)
5419 {
5420 if (pAdapter->StaCfg.BssType != BSS_ADHOC)
5421 {
5422 // Config has changed
5423 pAdapter->bConfigChanged = TRUE;
5424 if (MONITOR_ON(pAdapter))
5425 {
5426 RTMP_IO_WRITE32(pAdapter, RX_FILTR_CFG, STANORMAL);
5427 RTMP_IO_READ32(pAdapter, MAC_SYS_CTRL, &Value);
5428 Value &= (~0x80);
5429 RTMP_IO_WRITE32(pAdapter, MAC_SYS_CTRL, Value);
5430 OPSTATUS_CLEAR_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED);
5431 pAdapter->StaCfg.bAutoReconnect = TRUE;
5432 LinkDown(pAdapter, FALSE);
5433 }
5434 if (INFRA_ON(pAdapter))
5435 {
5436 //BOOLEAN Cancelled;
5437 // Set the AutoReconnectSsid to prevent it reconnect to old SSID
5438 // Since calling this indicate user don't want to connect to that SSID anymore.
5439 pAdapter->MlmeAux.AutoReconnectSsidLen= 32;
5440 NdisZeroMemory(pAdapter->MlmeAux.AutoReconnectSsid, pAdapter->MlmeAux.AutoReconnectSsidLen);
5441
5442 LinkDown(pAdapter, FALSE);
5443
5444 DBGPRINT(RT_DEBUG_TRACE, ("NDIS_STATUS_MEDIA_DISCONNECT Event BB!\n"));
5445 }
5446 }
5447 pAdapter->StaCfg.BssType = BSS_ADHOC;
5448 pAdapter->net_dev->type = pAdapter->StaCfg.OriDevType;
5449 DBGPRINT(RT_DEBUG_TRACE, ("===>Set_NetworkType_Proc::(AD-HOC)\n"));
5450 }
5451 else if (strcmp(arg, "Infra") == 0)
5452 {
5453 if (pAdapter->StaCfg.BssType != BSS_INFRA)
5454 {
5455 // Config has changed
5456 pAdapter->bConfigChanged = TRUE;
5457 if (MONITOR_ON(pAdapter))
5458 {
5459 RTMP_IO_WRITE32(pAdapter, RX_FILTR_CFG, STANORMAL);
5460 RTMP_IO_READ32(pAdapter, MAC_SYS_CTRL, &Value);
5461 Value &= (~0x80);
5462 RTMP_IO_WRITE32(pAdapter, MAC_SYS_CTRL, Value);
5463 OPSTATUS_CLEAR_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED);
5464 pAdapter->StaCfg.bAutoReconnect = TRUE;
5465 LinkDown(pAdapter, FALSE);
5466 }
5467 if (ADHOC_ON(pAdapter))
5468 {
5469 // Set the AutoReconnectSsid to prevent it reconnect to old SSID
5470 // Since calling this indicate user don't want to connect to that SSID anymore.
5471 pAdapter->MlmeAux.AutoReconnectSsidLen= 32;
5472 NdisZeroMemory(pAdapter->MlmeAux.AutoReconnectSsid, pAdapter->MlmeAux.AutoReconnectSsidLen);
5473
5474 LinkDown(pAdapter, FALSE);
5475 }
5476 }
5477 pAdapter->StaCfg.BssType = BSS_INFRA;
5478 pAdapter->net_dev->type = pAdapter->StaCfg.OriDevType;
5479 DBGPRINT(RT_DEBUG_TRACE, ("===>Set_NetworkType_Proc::(INFRA)\n"));
5480
5481 pAdapter->StaCfg.BssType = BSS_INFRA;
5482 }
5483 else if (strcmp(arg, "Monitor") == 0)
5484 {
5485 UCHAR bbpValue = 0;
5486 BCN_TIME_CFG_STRUC csr;
5487 OPSTATUS_CLEAR_FLAG(pAdapter, fOP_STATUS_INFRA_ON);
5488 OPSTATUS_CLEAR_FLAG(pAdapter, fOP_STATUS_ADHOC_ON);
5489 OPSTATUS_SET_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED);
5490 // disable all periodic state machine
5491 pAdapter->StaCfg.bAutoReconnect = FALSE;
5492 // reset all mlme state machine
5493 RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
5494 DBGPRINT(RT_DEBUG_TRACE, ("fOP_STATUS_MEDIA_STATE_CONNECTED \n"));
5495 if (pAdapter->CommonCfg.CentralChannel == 0)
5496 {
5497 if (pAdapter->CommonCfg.PhyMode == PHY_11AN_MIXED)
5498 pAdapter->CommonCfg.CentralChannel = 36;
5499 else
5500 pAdapter->CommonCfg.CentralChannel = 6;
5501 }
5502 else
5503 N_ChannelCheck(pAdapter);
5504
5505 if (pAdapter->CommonCfg.PhyMode >= PHY_11ABGN_MIXED &&
5506 pAdapter->CommonCfg.RegTransmitSetting.field.BW == BW_40 &&
5507 pAdapter->CommonCfg.RegTransmitSetting.field.EXTCHA == EXTCHA_ABOVE)
5508 {
5509 // 40MHz ,control channel at lower
5510 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, BBP_R4, &bbpValue);
5511 bbpValue &= (~0x18);
5512 bbpValue |= 0x10;
5513 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R4, bbpValue);
5514 pAdapter->CommonCfg.BBPCurrentBW = BW_40;
5515 // RX : control channel at lower
5516 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, BBP_R3, &bbpValue);
5517 bbpValue &= (~0x20);
5518 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R3, bbpValue);
5519
5520 RTMP_IO_READ32(pAdapter, TX_BAND_CFG, &Value);
5521 Value &= 0xfffffffe;
5522 RTMP_IO_WRITE32(pAdapter, TX_BAND_CFG, Value);
5523 pAdapter->CommonCfg.CentralChannel = pAdapter->CommonCfg.Channel + 2;
5524 AsicSwitchChannel(pAdapter, pAdapter->CommonCfg.CentralChannel, FALSE);
5525 AsicLockChannel(pAdapter, pAdapter->CommonCfg.CentralChannel);
5526 DBGPRINT(RT_DEBUG_TRACE, ("BW_40 ,control_channel(%d), CentralChannel(%d) \n",
5527 pAdapter->CommonCfg.Channel,
5528 pAdapter->CommonCfg.CentralChannel));
5529 }
5530 else if (pAdapter->CommonCfg.PhyMode >= PHY_11ABGN_MIXED &&
5531 pAdapter->CommonCfg.RegTransmitSetting.field.BW == BW_40 &&
5532 pAdapter->CommonCfg.RegTransmitSetting.field.EXTCHA == EXTCHA_BELOW)
5533 {
5534 // 40MHz ,control channel at upper
5535 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, BBP_R4, &bbpValue);
5536 bbpValue &= (~0x18);
5537 bbpValue |= 0x10;
5538 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R4, bbpValue);
5539 pAdapter->CommonCfg.BBPCurrentBW = BW_40;
5540 RTMP_IO_READ32(pAdapter, TX_BAND_CFG, &Value);
5541 Value |= 0x1;
5542 RTMP_IO_WRITE32(pAdapter, TX_BAND_CFG, Value);
5543
5544 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, BBP_R3, &bbpValue);
5545 bbpValue |= (0x20);
5546 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R3, bbpValue);
5547 pAdapter->CommonCfg.CentralChannel = pAdapter->CommonCfg.Channel - 2;
5548 AsicSwitchChannel(pAdapter, pAdapter->CommonCfg.CentralChannel, FALSE);
5549 AsicLockChannel(pAdapter, pAdapter->CommonCfg.CentralChannel);
5550 DBGPRINT(RT_DEBUG_TRACE, ("BW_40 ,control_channel(%d), CentralChannel(%d) \n",
5551 pAdapter->CommonCfg.Channel,
5552 pAdapter->CommonCfg.CentralChannel));
5553 }
5554 else
5555 {
5556 // 20MHz
5557 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, BBP_R4, &bbpValue);
5558 bbpValue &= (~0x18);
5559 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R4, bbpValue);
5560 pAdapter->CommonCfg.BBPCurrentBW = BW_20;
5561 AsicSwitchChannel(pAdapter, pAdapter->CommonCfg.Channel, FALSE);
5562 AsicLockChannel(pAdapter, pAdapter->CommonCfg.Channel);
5563 DBGPRINT(RT_DEBUG_TRACE, ("BW_20, Channel(%d)\n", pAdapter->CommonCfg.Channel));
5564 }
5565 // Enable Rx with promiscuous reception
5566 RTMP_IO_WRITE32(pAdapter, RX_FILTR_CFG, 0x3);
5567 // ASIC supporsts sniffer function with replacing RSSI with timestamp.
5568 //RTMP_IO_READ32(pAdapter, MAC_SYS_CTRL, &Value);
5569 //Value |= (0x80);
5570 //RTMP_IO_WRITE32(pAdapter, MAC_SYS_CTRL, Value);
5571 // disable sync
5572 RTMP_IO_READ32(pAdapter, BCN_TIME_CFG, &csr.word);
5573 csr.field.bBeaconGen = 0;
5574 csr.field.bTBTTEnable = 0;
5575 csr.field.TsfSyncMode = 0;
5576 RTMP_IO_WRITE32(pAdapter, BCN_TIME_CFG, csr.word);
5577
5578 pAdapter->StaCfg.BssType = BSS_MONITOR;
5579 pAdapter->net_dev->type = ARPHRD_IEEE80211_PRISM; //ARPHRD_IEEE80211; // IEEE80211
5580 DBGPRINT(RT_DEBUG_TRACE, ("===>Set_NetworkType_Proc::(MONITOR)\n"));
5581 }
5582
5583 // Reset Ralink supplicant to not use, it will be set to start when UI set PMK key
5584 pAdapter->StaCfg.WpaState = SS_NOTUSE;
5585
5586 DBGPRINT(RT_DEBUG_TRACE, ("Set_NetworkType_Proc::(NetworkType=%d)\n", pAdapter->StaCfg.BssType));
5587
5588 return TRUE;
5589}
5590
5591/*
5592 ==========================================================================
5593 Description:
5594 Set Authentication mode
5595 Return:
5596 TRUE if all parameters are OK, FALSE otherwise
5597 ==========================================================================
5598*/
5599INT Set_AuthMode_Proc(
5600 IN PRTMP_ADAPTER pAdapter,
5601 IN PUCHAR arg)
5602{
5603 if ((strcmp(arg, "WEPAUTO") == 0) || (strcmp(arg, "wepauto") == 0))
5604 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeAutoSwitch;
5605 else if ((strcmp(arg, "OPEN") == 0) || (strcmp(arg, "open") == 0))
5606 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
5607 else if ((strcmp(arg, "SHARED") == 0) || (strcmp(arg, "shared") == 0))
5608 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeShared;
5609 else if ((strcmp(arg, "WPAPSK") == 0) || (strcmp(arg, "wpapsk") == 0))
5610 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPAPSK;
5611 else if ((strcmp(arg, "WPANONE") == 0) || (strcmp(arg, "wpanone") == 0))
5612 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPANone;
5613 else if ((strcmp(arg, "WPA2PSK") == 0) || (strcmp(arg, "wpa2psk") == 0))
5614 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA2PSK;
5615 else if ((strcmp(arg, "WPA") == 0) || (strcmp(arg, "wpa") == 0))
5616 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA;
5617 else if ((strcmp(arg, "WPA2") == 0) || (strcmp(arg, "wpa2") == 0))
5618 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA2;
5619 else
5620 return FALSE;
5621
5622 pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED;
5623
5624 DBGPRINT(RT_DEBUG_TRACE, ("Set_AuthMode_Proc::(AuthMode=%d)\n", pAdapter->StaCfg.AuthMode));
5625
5626 return TRUE;
5627}
5628
5629/*
5630 ==========================================================================
5631 Description:
5632 Set Encryption Type
5633 Return:
5634 TRUE if all parameters are OK, FALSE otherwise
5635 ==========================================================================
5636*/
5637INT Set_EncrypType_Proc(
5638 IN PRTMP_ADAPTER pAdapter,
5639 IN PUCHAR arg)
5640{
5641 if ((strcmp(arg, "NONE") == 0) || (strcmp(arg, "none") == 0))
5642 {
5643 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
5644 return TRUE; // do nothing
5645
5646 pAdapter->StaCfg.WepStatus = Ndis802_11WEPDisabled;
5647 pAdapter->StaCfg.PairCipher = Ndis802_11WEPDisabled;
5648 pAdapter->StaCfg.GroupCipher = Ndis802_11WEPDisabled;
5649 }
5650 else if ((strcmp(arg, "WEP") == 0) || (strcmp(arg, "wep") == 0))
5651 {
5652 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
5653 return TRUE; // do nothing
5654
5655 pAdapter->StaCfg.WepStatus = Ndis802_11WEPEnabled;
5656 pAdapter->StaCfg.PairCipher = Ndis802_11WEPEnabled;
5657 pAdapter->StaCfg.GroupCipher = Ndis802_11WEPEnabled;
5658 }
5659 else if ((strcmp(arg, "TKIP") == 0) || (strcmp(arg, "tkip") == 0))
5660 {
5661 if (pAdapter->StaCfg.AuthMode < Ndis802_11AuthModeWPA)
5662 return TRUE; // do nothing
5663
5664 pAdapter->StaCfg.WepStatus = Ndis802_11Encryption2Enabled;
5665 pAdapter->StaCfg.PairCipher = Ndis802_11Encryption2Enabled;
5666 pAdapter->StaCfg.GroupCipher = Ndis802_11Encryption2Enabled;
5667 }
5668 else if ((strcmp(arg, "AES") == 0) || (strcmp(arg, "aes") == 0))
5669 {
5670 if (pAdapter->StaCfg.AuthMode < Ndis802_11AuthModeWPA)
5671 return TRUE; // do nothing
5672
5673 pAdapter->StaCfg.WepStatus = Ndis802_11Encryption3Enabled;
5674 pAdapter->StaCfg.PairCipher = Ndis802_11Encryption3Enabled;
5675 pAdapter->StaCfg.GroupCipher = Ndis802_11Encryption3Enabled;
5676 }
5677 else
5678 return FALSE;
5679
5680 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
5681
5682 DBGPRINT(RT_DEBUG_TRACE, ("Set_EncrypType_Proc::(EncrypType=%d)\n", pAdapter->StaCfg.WepStatus));
5683
5684 return TRUE;
5685}
5686
5687/*
5688 ==========================================================================
5689 Description:
5690 Set Default Key ID
5691 Return:
5692 TRUE if all parameters are OK, FALSE otherwise
5693 ==========================================================================
5694*/
5695INT Set_DefaultKeyID_Proc(
5696 IN PRTMP_ADAPTER pAdapter,
5697 IN PUCHAR arg)
5698{
5699 ULONG KeyIdx;
5700
5701 KeyIdx = simple_strtol(arg, 0, 10);
5702 if((KeyIdx >= 1 ) && (KeyIdx <= 4))
5703 pAdapter->StaCfg.DefaultKeyId = (UCHAR) (KeyIdx - 1 );
5704 else
5705 return FALSE; //Invalid argument
5706
5707 DBGPRINT(RT_DEBUG_TRACE, ("Set_DefaultKeyID_Proc::(DefaultKeyID=%d)\n", pAdapter->StaCfg.DefaultKeyId));
5708
5709 return TRUE;
5710}
5711
5712/*
5713 ==========================================================================
5714 Description:
5715 Set WEP KEY1
5716 Return:
5717 TRUE if all parameters are OK, FALSE otherwise
5718 ==========================================================================
5719*/
5720INT Set_Key1_Proc(
5721 IN PRTMP_ADAPTER pAdapter,
5722 IN PUCHAR arg)
5723{
5724 int KeyLen;
5725 int i;
5726 UCHAR CipherAlg=CIPHER_WEP64;
5727
5728 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
5729 return TRUE; // do nothing
5730
5731 KeyLen = strlen(arg);
5732
5733 switch (KeyLen)
5734 {
5735 case 5: //wep 40 Ascii type
5736 pAdapter->SharedKey[BSS0][0].KeyLen = KeyLen;
5737 memcpy(pAdapter->SharedKey[BSS0][0].Key, arg, KeyLen);
5738 CipherAlg = CIPHER_WEP64;
5739 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key1_Proc::(Key1=%s and type=%s)\n", arg, "Ascii"));
5740 break;
5741 case 10: //wep 40 Hex type
5742 for(i=0; i < KeyLen; i++)
5743 {
5744 if( !isxdigit(*(arg+i)) )
5745 return FALSE; //Not Hex value;
5746 }
5747 pAdapter->SharedKey[BSS0][0].KeyLen = KeyLen / 2 ;
5748 AtoH(arg, pAdapter->SharedKey[BSS0][0].Key, KeyLen / 2);
5749 CipherAlg = CIPHER_WEP64;
5750 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key1_Proc::(Key1=%s and type=%s)\n", arg, "Hex"));
5751 break;
5752 case 13: //wep 104 Ascii type
5753 pAdapter->SharedKey[BSS0][0].KeyLen = KeyLen;
5754 memcpy(pAdapter->SharedKey[BSS0][0].Key, arg, KeyLen);
5755 CipherAlg = CIPHER_WEP128;
5756 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key1_Proc::(Key1=%s and type=%s)\n", arg, "Ascii"));
5757 break;
5758 case 26: //wep 104 Hex type
5759 for(i=0; i < KeyLen; i++)
5760 {
5761 if( !isxdigit(*(arg+i)) )
5762 return FALSE; //Not Hex value;
5763 }
5764 pAdapter->SharedKey[BSS0][0].KeyLen = KeyLen / 2 ;
5765 AtoH(arg, pAdapter->SharedKey[BSS0][0].Key, KeyLen / 2);
5766 CipherAlg = CIPHER_WEP128;
5767 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key1_Proc::(Key1=%s and type=%s)\n", arg, "Hex"));
5768 break;
5769 default: //Invalid argument
5770 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key1_Proc::Invalid argument (=%s)\n", arg));
5771 return FALSE;
5772 }
5773
5774 pAdapter->SharedKey[BSS0][0].CipherAlg = CipherAlg;
5775
5776 // Set keys (into ASIC)
5777 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
5778 ; // not support
5779 else // Old WEP stuff
5780 {
5781 AsicAddSharedKeyEntry(pAdapter,
5782 0,
5783 0,
5784 pAdapter->SharedKey[BSS0][0].CipherAlg,
5785 pAdapter->SharedKey[BSS0][0].Key,
5786 NULL,
5787 NULL);
5788 }
5789
5790 return TRUE;
5791}
5792/*
5793 ==========================================================================
5794
5795 Description:
5796 Set WEP KEY2
5797 Return:
5798 TRUE if all parameters are OK, FALSE otherwise
5799 ==========================================================================
5800*/
5801INT Set_Key2_Proc(
5802 IN PRTMP_ADAPTER pAdapter,
5803 IN PUCHAR arg)
5804{
5805 int KeyLen;
5806 int i;
5807 UCHAR CipherAlg=CIPHER_WEP64;
5808
5809 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
5810 return TRUE; // do nothing
5811
5812 KeyLen = strlen(arg);
5813
5814 switch (KeyLen)
5815 {
5816 case 5: //wep 40 Ascii type
5817 pAdapter->SharedKey[BSS0][1].KeyLen = KeyLen;
5818 memcpy(pAdapter->SharedKey[BSS0][1].Key, arg, KeyLen);
5819 CipherAlg = CIPHER_WEP64;
5820 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key2_Proc::(Key2=%s and type=%s)\n", arg, "Ascii"));
5821 break;
5822 case 10: //wep 40 Hex type
5823 for(i=0; i < KeyLen; i++)
5824 {
5825 if( !isxdigit(*(arg+i)) )
5826 return FALSE; //Not Hex value;
5827 }
5828 pAdapter->SharedKey[BSS0][1].KeyLen = KeyLen / 2 ;
5829 AtoH(arg, pAdapter->SharedKey[BSS0][1].Key, KeyLen / 2);
5830 CipherAlg = CIPHER_WEP64;
5831 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key2_Proc::(Key2=%s and type=%s)\n", arg, "Hex"));
5832 break;
5833 case 13: //wep 104 Ascii type
5834 pAdapter->SharedKey[BSS0][1].KeyLen = KeyLen;
5835 memcpy(pAdapter->SharedKey[BSS0][1].Key, arg, KeyLen);
5836 CipherAlg = CIPHER_WEP128;
5837 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key2_Proc::(Key2=%s and type=%s)\n", arg, "Ascii"));
5838 break;
5839 case 26: //wep 104 Hex type
5840 for(i=0; i < KeyLen; i++)
5841 {
5842 if( !isxdigit(*(arg+i)) )
5843 return FALSE; //Not Hex value;
5844 }
5845 pAdapter->SharedKey[BSS0][1].KeyLen = KeyLen / 2 ;
5846 AtoH(arg, pAdapter->SharedKey[BSS0][1].Key, KeyLen / 2);
5847 CipherAlg = CIPHER_WEP128;
5848 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key2_Proc::(Key2=%s and type=%s)\n", arg, "Hex"));
5849 break;
5850 default: //Invalid argument
5851 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key2_Proc::Invalid argument (=%s)\n", arg));
5852 return FALSE;
5853 }
5854 pAdapter->SharedKey[BSS0][1].CipherAlg = CipherAlg;
5855
5856 // Set keys (into ASIC)
5857 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
5858 ; // not support
5859 else // Old WEP stuff
5860 {
5861 AsicAddSharedKeyEntry(pAdapter,
5862 0,
5863 1,
5864 pAdapter->SharedKey[BSS0][1].CipherAlg,
5865 pAdapter->SharedKey[BSS0][1].Key,
5866 NULL,
5867 NULL);
5868 }
5869
5870 return TRUE;
5871}
5872/*
5873 ==========================================================================
5874 Description:
5875 Set WEP KEY3
5876 Return:
5877 TRUE if all parameters are OK, FALSE otherwise
5878 ==========================================================================
5879*/
5880INT Set_Key3_Proc(
5881 IN PRTMP_ADAPTER pAdapter,
5882 IN PUCHAR arg)
5883{
5884 int KeyLen;
5885 int i;
5886 UCHAR CipherAlg=CIPHER_WEP64;
5887
5888 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
5889 return TRUE; // do nothing
5890
5891 KeyLen = strlen(arg);
5892
5893 switch (KeyLen)
5894 {
5895 case 5: //wep 40 Ascii type
5896 pAdapter->SharedKey[BSS0][2].KeyLen = KeyLen;
5897 memcpy(pAdapter->SharedKey[BSS0][2].Key, arg, KeyLen);
5898 CipherAlg = CIPHER_WEP64;
5899 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key3_Proc::(Key3=%s and type=Ascii)\n", arg));
5900 break;
5901 case 10: //wep 40 Hex type
5902 for(i=0; i < KeyLen; i++)
5903 {
5904 if( !isxdigit(*(arg+i)) )
5905 return FALSE; //Not Hex value;
5906 }
5907 pAdapter->SharedKey[BSS0][2].KeyLen = KeyLen / 2 ;
5908 AtoH(arg, pAdapter->SharedKey[BSS0][2].Key, KeyLen / 2);
5909 CipherAlg = CIPHER_WEP64;
5910 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key3_Proc::(Key3=%s and type=Hex)\n", arg));
5911 break;
5912 case 13: //wep 104 Ascii type
5913 pAdapter->SharedKey[BSS0][2].KeyLen = KeyLen;
5914 memcpy(pAdapter->SharedKey[BSS0][2].Key, arg, KeyLen);
5915 CipherAlg = CIPHER_WEP128;
5916 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key3_Proc::(Key3=%s and type=Ascii)\n", arg));
5917 break;
5918 case 26: //wep 104 Hex type
5919 for(i=0; i < KeyLen; i++)
5920 {
5921 if( !isxdigit(*(arg+i)) )
5922 return FALSE; //Not Hex value;
5923 }
5924 pAdapter->SharedKey[BSS0][2].KeyLen = KeyLen / 2 ;
5925 AtoH(arg, pAdapter->SharedKey[BSS0][2].Key, KeyLen / 2);
5926 CipherAlg = CIPHER_WEP128;
5927 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key3_Proc::(Key3=%s and type=Hex)\n", arg));
5928 break;
5929 default: //Invalid argument
5930 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key3_Proc::Invalid argument (=%s)\n", arg));
5931 return FALSE;
5932 }
5933 pAdapter->SharedKey[BSS0][2].CipherAlg = CipherAlg;
5934
5935 // Set keys (into ASIC)
5936 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
5937 ; // not support
5938 else // Old WEP stuff
5939 {
5940 AsicAddSharedKeyEntry(pAdapter,
5941 0,
5942 2,
5943 pAdapter->SharedKey[BSS0][2].CipherAlg,
5944 pAdapter->SharedKey[BSS0][2].Key,
5945 NULL,
5946 NULL);
5947 }
5948
5949 return TRUE;
5950}
5951/*
5952 ==========================================================================
5953 Description:
5954 Set WEP KEY4
5955 Return:
5956 TRUE if all parameters are OK, FALSE otherwise
5957 ==========================================================================
5958*/
5959INT Set_Key4_Proc(
5960 IN PRTMP_ADAPTER pAdapter,
5961 IN PUCHAR arg)
5962{
5963 int KeyLen;
5964 int i;
5965 UCHAR CipherAlg=CIPHER_WEP64;
5966
5967 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
5968 return TRUE; // do nothing
5969
5970 KeyLen = strlen(arg);
5971
5972 switch (KeyLen)
5973 {
5974 case 5: //wep 40 Ascii type
5975 pAdapter->SharedKey[BSS0][3].KeyLen = KeyLen;
5976 memcpy(pAdapter->SharedKey[BSS0][3].Key, arg, KeyLen);
5977 CipherAlg = CIPHER_WEP64;
5978 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key4_Proc::(Key4=%s and type=%s)\n", arg, "Ascii"));
5979 break;
5980 case 10: //wep 40 Hex type
5981 for(i=0; i < KeyLen; i++)
5982 {
5983 if( !isxdigit(*(arg+i)) )
5984 return FALSE; //Not Hex value;
5985 }
5986 pAdapter->SharedKey[BSS0][3].KeyLen = KeyLen / 2 ;
5987 AtoH(arg, pAdapter->SharedKey[BSS0][3].Key, KeyLen / 2);
5988 CipherAlg = CIPHER_WEP64;
5989 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key4_Proc::(Key4=%s and type=%s)\n", arg, "Hex"));
5990 break;
5991 case 13: //wep 104 Ascii type
5992 pAdapter->SharedKey[BSS0][3].KeyLen = KeyLen;
5993 memcpy(pAdapter->SharedKey[BSS0][3].Key, arg, KeyLen);
5994 CipherAlg = CIPHER_WEP128;
5995 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key4_Proc::(Key4=%s and type=%s)\n", arg, "Ascii"));
5996 break;
5997 case 26: //wep 104 Hex type
5998 for(i=0; i < KeyLen; i++)
5999 {
6000 if( !isxdigit(*(arg+i)) )
6001 return FALSE; //Not Hex value;
6002 }
6003 pAdapter->SharedKey[BSS0][3].KeyLen = KeyLen / 2 ;
6004 AtoH(arg, pAdapter->SharedKey[BSS0][3].Key, KeyLen / 2);
6005 CipherAlg = CIPHER_WEP128;
6006 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key4_Proc::(Key4=%s and type=%s)\n", arg, "Hex"));
6007 break;
6008 default: //Invalid argument
6009 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key4_Proc::Invalid argument (=%s)\n", arg));
6010 return FALSE;
6011 }
6012 pAdapter->SharedKey[BSS0][3].CipherAlg = CipherAlg;
6013
6014 // Set keys (into ASIC)
6015 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
6016 ; // not support
6017 else // Old WEP stuff
6018 {
6019 AsicAddSharedKeyEntry(pAdapter,
6020 0,
6021 3,
6022 pAdapter->SharedKey[BSS0][3].CipherAlg,
6023 pAdapter->SharedKey[BSS0][3].Key,
6024 NULL,
6025 NULL);
6026 }
6027
6028 return TRUE;
6029}
6030
6031/*
6032 ==========================================================================
6033 Description:
6034 Set WPA PSK key
6035 Return:
6036 TRUE if all parameters are OK, FALSE otherwise
6037 ==========================================================================
6038*/
6039INT Set_WPAPSK_Proc(
6040 IN PRTMP_ADAPTER pAdapter,
6041 IN PUCHAR arg)
6042{
6043 UCHAR keyMaterial[40];
6044
6045 if ((pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPAPSK) &&
6046 (pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPA2PSK) &&
6047 (pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPANone)
6048 )
6049 return TRUE; // do nothing
6050
6051 DBGPRINT(RT_DEBUG_TRACE, ("Set_WPAPSK_Proc::(WPAPSK=%s)\n", arg));
6052
6053 NdisZeroMemory(keyMaterial, 40);
6054
6055 if ((strlen(arg) < 8) || (strlen(arg) > 64))
6056 {
6057 DBGPRINT(RT_DEBUG_TRACE, ("Set failed!!(WPAPSK=%s), WPAPSK key-string required 8 ~ 64 characters \n", arg));
6058 return FALSE;
6059 }
6060
6061 if (strlen(arg) == 64)
6062 {
6063 AtoH(arg, keyMaterial, 32);
6064 NdisMoveMemory(pAdapter->StaCfg.PMK, keyMaterial, 32);
6065
6066 }
6067 else
6068 {
6069 PasswordHash((char *)arg, pAdapter->MlmeAux.Ssid, pAdapter->MlmeAux.SsidLen, keyMaterial);
6070 NdisMoveMemory(pAdapter->StaCfg.PMK, keyMaterial, 32);
6071 }
6072
6073
6074
6075 if(pAdapter->StaCfg.BssType == BSS_ADHOC &&
6076 pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPANone)
6077 {
6078 pAdapter->StaCfg.WpaState = SS_NOTUSE;
6079 }
6080 else
6081 {
6082 // Start STA supplicant state machine
6083 pAdapter->StaCfg.WpaState = SS_START;
6084 }
6085
6086 return TRUE;
6087}
6088
6089/*
6090 ==========================================================================
6091 Description:
6092 Set Power Saving mode
6093 Return:
6094 TRUE if all parameters are OK, FALSE otherwise
6095 ==========================================================================
6096*/
6097INT Set_PSMode_Proc(
6098 IN PRTMP_ADAPTER pAdapter,
6099 IN PUCHAR arg)
6100{
6101 if (pAdapter->StaCfg.BssType == BSS_INFRA)
6102 {
6103 if ((strcmp(arg, "Max_PSP") == 0) ||
6104 (strcmp(arg, "max_psp") == 0) ||
6105 (strcmp(arg, "MAX_PSP") == 0))
6106 {
6107 // do NOT turn on PSM bit here, wait until MlmeCheckForPsmChange()
6108 // to exclude certain situations.
6109 if (pAdapter->StaCfg.bWindowsACCAMEnable == FALSE)
6110 pAdapter->StaCfg.WindowsPowerMode = Ndis802_11PowerModeMAX_PSP;
6111 pAdapter->StaCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeMAX_PSP;
6112 OPSTATUS_SET_FLAG(pAdapter, fOP_STATUS_RECEIVE_DTIM);
6113 pAdapter->StaCfg.DefaultListenCount = 5;
6114
6115 }
6116 else if ((strcmp(arg, "Fast_PSP") == 0) ||
6117 (strcmp(arg, "fast_psp") == 0) ||
6118 (strcmp(arg, "FAST_PSP") == 0))
6119 {
6120 // do NOT turn on PSM bit here, wait until MlmeCheckForPsmChange()
6121 // to exclude certain situations.
6122 OPSTATUS_SET_FLAG(pAdapter, fOP_STATUS_RECEIVE_DTIM);
6123 if (pAdapter->StaCfg.bWindowsACCAMEnable == FALSE)
6124 pAdapter->StaCfg.WindowsPowerMode = Ndis802_11PowerModeFast_PSP;
6125 pAdapter->StaCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeFast_PSP;
6126 pAdapter->StaCfg.DefaultListenCount = 3;
6127 }
6128 else if ((strcmp(arg, "Legacy_PSP") == 0) ||
6129 (strcmp(arg, "legacy_psp") == 0) ||
6130 (strcmp(arg, "LEGACY_PSP") == 0))
6131 {
6132 // do NOT turn on PSM bit here, wait until MlmeCheckForPsmChange()
6133 // to exclude certain situations.
6134 OPSTATUS_SET_FLAG(pAdapter, fOP_STATUS_RECEIVE_DTIM);
6135 if (pAdapter->StaCfg.bWindowsACCAMEnable == FALSE)
6136 pAdapter->StaCfg.WindowsPowerMode = Ndis802_11PowerModeLegacy_PSP;
6137 pAdapter->StaCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeLegacy_PSP;
6138 pAdapter->StaCfg.DefaultListenCount = 3;
6139 }
6140 else
6141 {
6142 //Default Ndis802_11PowerModeCAM
6143 // clear PSM bit immediately
6144 MlmeSetPsmBit(pAdapter, PWR_ACTIVE);
6145 OPSTATUS_SET_FLAG(pAdapter, fOP_STATUS_RECEIVE_DTIM);
6146 if (pAdapter->StaCfg.bWindowsACCAMEnable == FALSE)
6147 pAdapter->StaCfg.WindowsPowerMode = Ndis802_11PowerModeCAM;
6148 pAdapter->StaCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeCAM;
6149 }
6150
6151 DBGPRINT(RT_DEBUG_TRACE, ("Set_PSMode_Proc::(PSMode=%ld)\n", pAdapter->StaCfg.WindowsPowerMode));
6152 }
6153 else
6154 return FALSE;
6155
6156
6157 return TRUE;
6158}
6159
6160/*
6161 ==========================================================================
6162 Description:
6163 Set WpaSupport flag.
6164 Value:
6165 0: Driver ignore wpa_supplicant.
6166 1: wpa_supplicant initiates scanning and AP selection.
6167 2: driver takes care of scanning, AP selection, and IEEE 802.11 association parameters.
6168 Return:
6169 TRUE if all parameters are OK, FALSE otherwise
6170 ==========================================================================
6171*/
6172INT Set_Wpa_Support(
6173 IN PRTMP_ADAPTER pAd,
6174 IN PUCHAR arg)
6175{
6176
6177 if ( simple_strtol(arg, 0, 10) == 0)
6178 pAd->StaCfg.WpaSupplicantUP = WPA_SUPPLICANT_DISABLE;
6179 else if ( simple_strtol(arg, 0, 10) == 1)
6180 pAd->StaCfg.WpaSupplicantUP = WPA_SUPPLICANT_ENABLE;
6181 else if ( simple_strtol(arg, 0, 10) == 2)
6182 pAd->StaCfg.WpaSupplicantUP = WPA_SUPPLICANT_ENABLE_WITH_WEB_UI;
6183 else
6184 pAd->StaCfg.WpaSupplicantUP = WPA_SUPPLICANT_DISABLE;
6185
6186 DBGPRINT(RT_DEBUG_TRACE, ("Set_Wpa_Support::(WpaSupplicantUP=%d)\n", pAd->StaCfg.WpaSupplicantUP));
6187
6188 return TRUE;
6189}
6190
6191#ifdef DBG
6192/*
6193 ==========================================================================
6194 Description:
6195 Read / Write MAC
6196 Arguments:
6197 pAdapter Pointer to our adapter
6198 wrq Pointer to the ioctl argument
6199
6200 Return Value:
6201 None
6202
6203 Note:
6204 Usage:
6205 1.) iwpriv ra0 mac 0 ==> read MAC where Addr=0x0
6206 2.) iwpriv ra0 mac 0=12 ==> write MAC where Addr=0x0, value=12
6207 ==========================================================================
6208*/
6209VOID RTMPIoctlMAC(
6210 IN PRTMP_ADAPTER pAdapter,
6211 IN struct iwreq *wrq)
6212{
6213 CHAR *this_char;
6214 CHAR *value;
6215 INT j = 0, k = 0;
6216 CHAR msg[1024];
6217 CHAR arg[255];
6218 ULONG macAddr = 0;
6219 UCHAR temp[16], temp2[16];
6220 UINT32 macValue = 0;
6221 INT Status;
6222#ifdef RT30xx
6223 BOOLEAN bIsPrintAllMAC = FALSE;
6224#endif
6225
6226 memset(msg, 0x00, 1024);
6227 if (wrq->u.data.length > 1) //No parameters.
6228 {
6229 Status = copy_from_user(arg, wrq->u.data.pointer, (wrq->u.data.length > 255) ? 255 : wrq->u.data.length);
6230 sprintf(msg, "\n");
6231
6232 //Parsing Read or Write
6233 this_char = arg;
6234 if (!*this_char)
6235 goto next;
6236
6237 if ((value = rtstrchr(this_char, '=')) != NULL)
6238 *value++ = 0;
6239
6240 if (!value || !*value)
6241 { //Read
6242 // Sanity check
6243 if(strlen(this_char) > 4)
6244 goto next;
6245
6246 j = strlen(this_char);
6247 while(j-- > 0)
6248 {
6249 if(this_char[j] > 'f' || this_char[j] < '0')
6250 return;
6251 }
6252
6253 // Mac Addr
6254 k = j = strlen(this_char);
6255 while(j-- > 0)
6256 {
6257 this_char[4-k+j] = this_char[j];
6258 }
6259
6260 while(k < 4)
6261 this_char[3-k++]='0';
6262 this_char[4]='\0';
6263
6264 if(strlen(this_char) == 4)
6265 {
6266 AtoH(this_char, temp, 2);
6267 macAddr = *temp*256 + temp[1];
6268 if (macAddr < 0xFFFF)
6269 {
6270 RTMP_IO_READ32(pAdapter, macAddr, &macValue);
6271 DBGPRINT(RT_DEBUG_TRACE, ("MacAddr=%lx, MacValue=%x\n", macAddr, macValue));
6272 sprintf(msg+strlen(msg), "[0x%08lX]:%08X ", macAddr , macValue);
6273 }
6274 else
6275#ifndef RT30xx
6276 {//Invalid parametes, so default printk all bbp
6277#endif
6278#ifdef RT30xx
6279 {//Invalid parametes, so default printk all mac
6280 bIsPrintAllMAC = TRUE;
6281#endif
6282 goto next;
6283 }
6284 }
6285 }
6286 else
6287 { //Write
6288 memcpy(&temp2, value, strlen(value));
6289 temp2[strlen(value)] = '\0';
6290
6291 // Sanity check
6292 if((strlen(this_char) > 4) || strlen(temp2) > 8)
6293 goto next;
6294
6295 j = strlen(this_char);
6296 while(j-- > 0)
6297 {
6298 if(this_char[j] > 'f' || this_char[j] < '0')
6299 return;
6300 }
6301
6302 j = strlen(temp2);
6303 while(j-- > 0)
6304 {
6305 if(temp2[j] > 'f' || temp2[j] < '0')
6306 return;
6307 }
6308
6309 //MAC Addr
6310 k = j = strlen(this_char);
6311 while(j-- > 0)
6312 {
6313 this_char[4-k+j] = this_char[j];
6314 }
6315
6316 while(k < 4)
6317 this_char[3-k++]='0';
6318 this_char[4]='\0';
6319
6320 //MAC value
6321 k = j = strlen(temp2);
6322 while(j-- > 0)
6323 {
6324 temp2[8-k+j] = temp2[j];
6325 }
6326
6327 while(k < 8)
6328 temp2[7-k++]='0';
6329 temp2[8]='\0';
6330
6331 {
6332 AtoH(this_char, temp, 2);
6333 macAddr = *temp*256 + temp[1];
6334
6335 AtoH(temp2, temp, 4);
6336 macValue = *temp*256*256*256 + temp[1]*256*256 + temp[2]*256 + temp[3];
6337
6338 // debug mode
6339 if (macAddr == (HW_DEBUG_SETTING_BASE + 4))
6340 {
6341 // 0x2bf4: byte0 non-zero: enable R17 tuning, 0: disable R17 tuning
6342 if (macValue & 0x000000ff)
6343 {
6344 pAdapter->BbpTuning.bEnable = TRUE;
6345 DBGPRINT(RT_DEBUG_TRACE,("turn on R17 tuning\n"));
6346 }
6347 else
6348 {
6349 UCHAR R66;
6350 pAdapter->BbpTuning.bEnable = FALSE;
6351 R66 = 0x26 + GET_LNA_GAIN(pAdapter);
6352 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R66, (0x26 + GET_LNA_GAIN(pAdapter)));
6353 DBGPRINT(RT_DEBUG_TRACE,("turn off R17 tuning, restore to 0x%02x\n", R66));
6354 }
6355 return;
6356 }
6357
6358 DBGPRINT(RT_DEBUG_TRACE, ("MacAddr=%02lx, MacValue=0x%x\n", macAddr, macValue));
6359
6360 RTMP_IO_WRITE32(pAdapter, macAddr, macValue);
6361 sprintf(msg+strlen(msg), "[0x%08lX]:%08X ", macAddr, macValue);
6362 }
6363 }
6364 }
6365#ifdef RT30xx
6366 else
6367 bIsPrintAllMAC = TRUE;
6368#endif
6369next:
6370#ifdef RT30xx
6371 if (bIsPrintAllMAC)
6372 {
6373 struct file *file_w;
6374 PCHAR fileName = "MacDump.txt";
6375 mm_segment_t orig_fs;
6376
6377 orig_fs = get_fs();
6378 set_fs(KERNEL_DS);
6379
6380 // open file
6381 file_w = filp_open(fileName, O_WRONLY|O_CREAT, 0);
6382 if (IS_ERR(file_w))
6383 {
6384 DBGPRINT(RT_DEBUG_TRACE, ("-->2) %s: Error %ld opening %s\n", __func__, -PTR_ERR(file_w), fileName));
6385 }
6386 else
6387 {
6388 if (file_w->f_op && file_w->f_op->write)
6389 {
6390 file_w->f_pos = 0;
6391 macAddr = 0x1000;
6392
6393 while (macAddr <= 0x1800)
6394 {
6395 RTMP_IO_READ32(pAdapter, macAddr, &macValue);
6396 sprintf(msg, "%08lx = %08X\n", macAddr, macValue);
6397
6398 // write data to file
6399 file_w->f_op->write(file_w, msg, strlen(msg), &file_w->f_pos);
6400
6401 printk("%s", msg);
6402 macAddr += 4;
6403 }
6404 sprintf(msg, "\nDump all MAC values to %s\n", fileName);
6405 }
6406 filp_close(file_w, NULL);
6407 }
6408 set_fs(orig_fs);
6409 }
6410#endif /* RT30xx */
6411 if(strlen(msg) == 1)
6412 sprintf(msg+strlen(msg), "===>Error command format!");
6413
6414 // Copy the information into the user buffer
6415 wrq->u.data.length = strlen(msg);
6416 Status = copy_to_user(wrq->u.data.pointer, msg, wrq->u.data.length);
6417
6418 DBGPRINT(RT_DEBUG_TRACE, ("<==RTMPIoctlMAC\n\n"));
6419}
6420
6421/*
6422 ==========================================================================
6423 Description:
6424 Read / Write E2PROM
6425 Arguments:
6426 pAdapter Pointer to our adapter
6427 wrq Pointer to the ioctl argument
6428
6429 Return Value:
6430 None
6431
6432 Note:
6433 Usage:
6434 1.) iwpriv ra0 e2p 0 ==> read E2PROM where Addr=0x0
6435 2.) iwpriv ra0 e2p 0=1234 ==> write E2PROM where Addr=0x0, value=1234
6436 ==========================================================================
6437*/
6438VOID RTMPIoctlE2PROM(
6439 IN PRTMP_ADAPTER pAdapter,
6440 IN struct iwreq *wrq)
6441{
6442 CHAR *this_char;
6443 CHAR *value;
6444 INT j = 0, k = 0;
6445 CHAR msg[1024];
6446 CHAR arg[255];
6447 USHORT eepAddr = 0;
6448 UCHAR temp[16], temp2[16];
6449 USHORT eepValue;
6450 int Status;
6451#ifdef RT30xx
6452 BOOLEAN bIsPrintAllE2P = FALSE;
6453#endif
6454
6455 memset(msg, 0x00, 1024);
6456 if (wrq->u.data.length > 1) //No parameters.
6457 {
6458 Status = copy_from_user(arg, wrq->u.data.pointer, (wrq->u.data.length > 255) ? 255 : wrq->u.data.length);
6459 sprintf(msg, "\n");
6460
6461 //Parsing Read or Write
6462 this_char = arg;
6463
6464
6465 if (!*this_char)
6466 goto next;
6467
6468 if ((value = rtstrchr(this_char, '=')) != NULL)
6469 *value++ = 0;
6470
6471 if (!value || !*value)
6472 { //Read
6473
6474 // Sanity check
6475 if(strlen(this_char) > 4)
6476 goto next;
6477
6478 j = strlen(this_char);
6479 while(j-- > 0)
6480 {
6481 if(this_char[j] > 'f' || this_char[j] < '0')
6482 return;
6483 }
6484
6485 // E2PROM addr
6486 k = j = strlen(this_char);
6487 while(j-- > 0)
6488 {
6489 this_char[4-k+j] = this_char[j];
6490 }
6491
6492 while(k < 4)
6493 this_char[3-k++]='0';
6494 this_char[4]='\0';
6495
6496 if(strlen(this_char) == 4)
6497 {
6498 AtoH(this_char, temp, 2);
6499 eepAddr = *temp*256 + temp[1];
6500 if (eepAddr < 0xFFFF)
6501 {
6502 RT28xx_EEPROM_READ16(pAdapter, eepAddr, eepValue);
6503 sprintf(msg+strlen(msg), "[0x%04X]:0x%04X ", eepAddr , eepValue);
6504 }
6505 else
6506 {//Invalid parametes, so default printk all bbp
6507#ifdef RT30xx
6508 bIsPrintAllE2P = TRUE;
6509#endif
6510 goto next;
6511 }
6512 }
6513 }
6514 else
6515 { //Write
6516 memcpy(&temp2, value, strlen(value));
6517 temp2[strlen(value)] = '\0';
6518
6519 // Sanity check
6520 if((strlen(this_char) > 4) || strlen(temp2) > 8)
6521 goto next;
6522
6523 j = strlen(this_char);
6524 while(j-- > 0)
6525 {
6526 if(this_char[j] > 'f' || this_char[j] < '0')
6527 return;
6528 }
6529 j = strlen(temp2);
6530 while(j-- > 0)
6531 {
6532 if(temp2[j] > 'f' || temp2[j] < '0')
6533 return;
6534 }
6535
6536 //MAC Addr
6537 k = j = strlen(this_char);
6538 while(j-- > 0)
6539 {
6540 this_char[4-k+j] = this_char[j];
6541 }
6542
6543 while(k < 4)
6544 this_char[3-k++]='0';
6545 this_char[4]='\0';
6546
6547 //MAC value
6548 k = j = strlen(temp2);
6549 while(j-- > 0)
6550 {
6551 temp2[4-k+j] = temp2[j];
6552 }
6553
6554 while(k < 4)
6555 temp2[3-k++]='0';
6556 temp2[4]='\0';
6557
6558 AtoH(this_char, temp, 2);
6559 eepAddr = *temp*256 + temp[1];
6560
6561 AtoH(temp2, temp, 2);
6562 eepValue = *temp*256 + temp[1];
6563
6564 RT28xx_EEPROM_WRITE16(pAdapter, eepAddr, eepValue);
6565 sprintf(msg+strlen(msg), "[0x%02X]:%02X ", eepAddr, eepValue);
6566 }
6567 }
6568#ifdef RT30xx
6569 else
6570 bIsPrintAllE2P = TRUE;
6571#endif
6572next:
6573#ifdef RT30xx
6574 if (bIsPrintAllE2P)
6575 {
6576 struct file *file_w;
6577 PCHAR fileName = "EEPROMDump.txt";
6578 mm_segment_t orig_fs;
6579
6580 orig_fs = get_fs();
6581 set_fs(KERNEL_DS);
6582
6583 // open file
6584 file_w = filp_open(fileName, O_WRONLY|O_CREAT, 0);
6585 if (IS_ERR(file_w))
6586 {
6587 DBGPRINT(RT_DEBUG_TRACE, ("-->2) %s: Error %ld opening %s\n", __func__, -PTR_ERR(file_w), fileName));
6588 }
6589 else
6590 {
6591 if (file_w->f_op && file_w->f_op->write)
6592 {
6593 file_w->f_pos = 0;
6594 eepAddr = 0x00;
6595
6596 while (eepAddr <= 0xFE)
6597 {
6598 RT28xx_EEPROM_READ16(pAdapter, eepAddr, eepValue);
6599 sprintf(msg, "%08x = %04x\n", eepAddr , eepValue);
6600
6601 // write data to file
6602 file_w->f_op->write(file_w, msg, strlen(msg), &file_w->f_pos);
6603
6604 printk("%s", msg);
6605 eepAddr += 2;
6606 }
6607 sprintf(msg, "\nDump all EEPROM values to %s\n", fileName);
6608 }
6609 filp_close(file_w, NULL);
6610 }
6611 set_fs(orig_fs);
6612 }
6613#endif /* RT30xx */
6614 if(strlen(msg) == 1)
6615 sprintf(msg+strlen(msg), "===>Error command format!");
6616
6617
6618 // Copy the information into the user buffer
6619 wrq->u.data.length = strlen(msg);
6620 Status = copy_to_user(wrq->u.data.pointer, msg, wrq->u.data.length);
6621
6622 DBGPRINT(RT_DEBUG_TRACE, ("<==RTMPIoctlE2PROM\n"));
6623}
6624#ifdef RT30xx
6625/*
6626 ==========================================================================
6627 Description:
6628 Read / Write RF register
6629Arguments:
6630 pAdapter Pointer to our adapter
6631 wrq Pointer to the ioctl argument
6632
6633 Return Value:
6634 None
6635
6636 Note:
6637 Usage:
6638 1.) iwpriv ra0 rf ==> read all RF registers
6639 2.) iwpriv ra0 rf 1 ==> read RF where RegID=1
6640 3.) iwpriv ra0 rf 1=10 ==> write RF R1=0x10
6641 ==========================================================================
6642*/
6643VOID RTMPIoctlRF(
6644 IN PRTMP_ADAPTER pAdapter,
6645 IN struct iwreq *wrq)
6646{
6647 CHAR *this_char;
6648 CHAR *value;
6649 UCHAR regRF = 0;
6650 CHAR msg[2048];
6651 CHAR arg[255];
6652 INT rfId;
6653 LONG rfValue;
6654 int Status;
6655 BOOLEAN bIsPrintAllRF = FALSE;
6656
6657
6658 memset(msg, 0x00, 2048);
6659 if (wrq->u.data.length > 1) //No parameters.
6660 {
6661 Status = copy_from_user(arg, wrq->u.data.pointer, (wrq->u.data.length > 255) ? 255 : wrq->u.data.length);
6662 sprintf(msg, "\n");
6663
6664 //Parsing Read or Write
6665 this_char = arg;
6666 if (!*this_char)
6667 goto next;
6668
6669 if ((value = strchr(this_char, '=')) != NULL)
6670 *value++ = 0;
6671
6672 if (!value || !*value)
6673 { //Read
6674 if (sscanf(this_char, "%d", &(rfId)) == 1)
6675 {
6676 if (rfId <= 31)
6677 {
6678 // In RT2860 ATE mode, we do not load 8051 firmware.
6679 //We must access RF directly.
6680 // For RT2870 ATE mode, ATE_RF_IO_WRITE8(/READ8)_BY_REG_ID are redefined.
6681 // according to Andy, Gary, David require.
6682 // the command rf shall read rf register directly for dubug.
6683 // BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, &regBBP);
6684 RT30xxReadRFRegister(pAdapter, rfId, &regRF);
6685
6686 sprintf(msg+strlen(msg), "R%02d[0x%02x]:%02X ", rfId, rfId*2, regRF);
6687 }
6688 else
6689 {//Invalid parametes, so default printk all RF
6690 bIsPrintAllRF = TRUE;
6691 goto next;
6692 }
6693 }
6694 else
6695 { //Invalid parametes, so default printk all RF
6696 bIsPrintAllRF = TRUE;
6697 goto next;
6698 }
6699 }
6700 else
6701 { //Write
6702 if ((sscanf(this_char, "%d", &(rfId)) == 1) && (sscanf(value, "%lx", &(rfValue)) == 1))
6703 {
6704 if (rfId <= 31)
6705 {
6706 // In RT2860 ATE mode, we do not load 8051 firmware.
6707 // We should access RF registers directly.
6708 // For RT2870 ATE mode, ATE_RF_IO_WRITE8/READ8_BY_REG_ID are redefined.
6709 {
6710 // according to Andy, Gary, David require.
6711 // the command RF shall read/write RF register directly for dubug.
6712 //BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, &regBBP);
6713 //BBP_IO_WRITE8_BY_REG_ID(pAdapter, (UCHAR)bbpId,(UCHAR) bbpValue);
6714 RT30xxReadRFRegister(pAdapter, rfId, &regRF);
6715 RT30xxWriteRFRegister(pAdapter, (UCHAR)rfId,(UCHAR) rfValue);
6716 //Read it back for showing
6717 //BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, &regBBP);
6718 RT30xxReadRFRegister(pAdapter, rfId, &regRF);
6719 sprintf(msg+strlen(msg), "R%02d[0x%02X]:%02X\n", rfId, rfId*2, regRF);
6720 }
6721 }
6722 else
6723 {//Invalid parametes, so default printk all RF
6724 bIsPrintAllRF = TRUE;
6725 }
6726 }
6727 else
6728 { //Invalid parametes, so default printk all RF
6729 bIsPrintAllRF = TRUE;
6730 }
6731 }
6732 }
6733 else
6734 bIsPrintAllRF = TRUE;
6735next:
6736 if (bIsPrintAllRF)
6737 {
6738 memset(msg, 0x00, 2048);
6739 sprintf(msg, "\n");
6740 for (rfId = 0; rfId <= 31; rfId++)
6741 {
6742 // according to Andy, Gary, David require.
6743 // the command RF shall read/write RF register directly for dubug.
6744 RT30xxReadRFRegister(pAdapter, rfId, &regRF);
6745 sprintf(msg+strlen(msg), "%03d = %02X\n", rfId, regRF);
6746 }
6747 // Copy the information into the user buffer
6748 DBGPRINT(RT_DEBUG_TRACE, ("strlen(msg)=%d\n", (UINT32)strlen(msg)));
6749 wrq->u.data.length = strlen(msg);
6750 if (copy_to_user(wrq->u.data.pointer, msg, wrq->u.data.length))
6751 {
6752 DBGPRINT(RT_DEBUG_TRACE, ("%s: copy_to_user() fail\n", __func__));
6753 }
6754 }
6755 else
6756 {
6757 if(strlen(msg) == 1)
6758 sprintf(msg+strlen(msg), "===>Error command format!");
6759
6760 DBGPRINT(RT_DEBUG_TRACE, ("copy to user [msg=%s]\n", msg));
6761 // Copy the information into the user buffer
6762 DBGPRINT(RT_DEBUG_TRACE, ("strlen(msg) =%d\n", (UINT32)strlen(msg)));
6763
6764 // Copy the information into the user buffer
6765 wrq->u.data.length = strlen(msg);
6766 Status = copy_to_user(wrq->u.data.pointer, msg, wrq->u.data.length);
6767 }
6768
6769 DBGPRINT(RT_DEBUG_TRACE, ("<==RTMPIoctlRF\n\n"));
6770}
6771#endif // RT30xx //
6772#endif // DBG //
6773
6774
6775
6776
6777INT Set_TGnWifiTest_Proc(
6778 IN PRTMP_ADAPTER pAd,
6779 IN PUCHAR arg)
6780{
6781 if (simple_strtol(arg, 0, 10) == 0)
6782 pAd->StaCfg.bTGnWifiTest = FALSE;
6783 else
6784 pAd->StaCfg.bTGnWifiTest = TRUE;
6785
6786 DBGPRINT(RT_DEBUG_TRACE, ("IF Set_TGnWifiTest_Proc::(bTGnWifiTest=%d)\n", pAd->StaCfg.bTGnWifiTest));
6787 return TRUE;
6788}
6789
6790INT Set_LongRetryLimit_Proc(
6791 IN PRTMP_ADAPTER pAdapter,
6792 IN PUCHAR arg)
6793{
6794 TX_RTY_CFG_STRUC tx_rty_cfg;
6795 UCHAR LongRetryLimit = (UCHAR)simple_strtol(arg, 0, 10);
6796
6797 RTMP_IO_READ32(pAdapter, TX_RTY_CFG, &tx_rty_cfg.word);
6798 tx_rty_cfg.field.LongRtyLimit = LongRetryLimit;
6799 RTMP_IO_WRITE32(pAdapter, TX_RTY_CFG, tx_rty_cfg.word);
6800 DBGPRINT(RT_DEBUG_TRACE, ("IF Set_LongRetryLimit_Proc::(tx_rty_cfg=0x%x)\n", tx_rty_cfg.word));
6801 return TRUE;
6802}
6803
6804INT Set_ShortRetryLimit_Proc(
6805 IN PRTMP_ADAPTER pAdapter,
6806 IN PUCHAR arg)
6807{
6808 TX_RTY_CFG_STRUC tx_rty_cfg;
6809 UCHAR ShortRetryLimit = (UCHAR)simple_strtol(arg, 0, 10);
6810
6811 RTMP_IO_READ32(pAdapter, TX_RTY_CFG, &tx_rty_cfg.word);
6812 tx_rty_cfg.field.ShortRtyLimit = ShortRetryLimit;
6813 RTMP_IO_WRITE32(pAdapter, TX_RTY_CFG, tx_rty_cfg.word);
6814 DBGPRINT(RT_DEBUG_TRACE, ("IF Set_ShortRetryLimit_Proc::(tx_rty_cfg=0x%x)\n", tx_rty_cfg.word));
6815 return TRUE;
6816}
6817
6818#ifndef RT30xx
6819INT Show_Adhoc_MacTable_Proc(
6820 IN PRTMP_ADAPTER pAd,
6821 IN PCHAR extra)
6822{
6823 INT i;
6824
6825 sprintf(extra, "\n");
6826
6827 sprintf(extra + strlen(extra), "HT Operating Mode : %d\n", pAd->CommonCfg.AddHTInfo.AddHtInfo2.OperaionMode);
6828
6829 sprintf(extra + strlen(extra), "\n%-19s%-4s%-4s%-7s%-7s%-7s%-10s%-6s%-6s%-6s%-6s\n",
6830 "MAC", "AID", "BSS", "RSSI0", "RSSI1", "RSSI2", "PhMd", "BW", "MCS", "SGI", "STBC");
6831
6832 for (i=1; i<MAX_LEN_OF_MAC_TABLE; i++)
6833 {
6834 PMAC_TABLE_ENTRY pEntry = &pAd->MacTab.Content[i];
6835
6836 if (strlen(extra) > (IW_PRIV_SIZE_MASK - 30))
6837 break;
6838 if ((pEntry->ValidAsCLI || pEntry->ValidAsApCli) && (pEntry->Sst == SST_ASSOC))
6839 {
6840 sprintf(extra + strlen(extra), "%02X:%02X:%02X:%02X:%02X:%02X ",
6841 pEntry->Addr[0], pEntry->Addr[1], pEntry->Addr[2],
6842 pEntry->Addr[3], pEntry->Addr[4], pEntry->Addr[5]);
6843 sprintf(extra + strlen(extra), "%-4d", (int)pEntry->Aid);
6844 sprintf(extra + strlen(extra), "%-4d", (int)pEntry->apidx);
6845 sprintf(extra + strlen(extra), "%-7d", pEntry->RssiSample.AvgRssi0);
6846 sprintf(extra + strlen(extra), "%-7d", pEntry->RssiSample.AvgRssi1);
6847 sprintf(extra + strlen(extra), "%-7d", pEntry->RssiSample.AvgRssi2);
6848 sprintf(extra + strlen(extra), "%-10s", GetPhyMode(pEntry->HTPhyMode.field.MODE));
6849 sprintf(extra + strlen(extra), "%-6s", GetBW(pEntry->HTPhyMode.field.BW));
6850 sprintf(extra + strlen(extra), "%-6d", pEntry->HTPhyMode.field.MCS);
6851 sprintf(extra + strlen(extra), "%-6d", pEntry->HTPhyMode.field.ShortGI);
6852 sprintf(extra + strlen(extra), "%-6d", pEntry->HTPhyMode.field.STBC);
6853 sprintf(extra + strlen(extra), "%-10d, %d, %d%%\n", pEntry->DebugFIFOCount, pEntry->DebugTxCount,
6854 (pEntry->DebugTxCount) ? ((pEntry->DebugTxCount-pEntry->DebugFIFOCount)*100/pEntry->DebugTxCount) : 0);
6855 sprintf(extra, "%s\n", extra);
6856 }
6857 }
6858
6859 return TRUE;
6860}
6861#endif /* RT30xx */
diff --git a/drivers/staging/rt2870/wpa.h b/drivers/staging/rt2870/wpa.h
index e6716748adfa..712507224146 100644
--- a/drivers/staging/rt2870/wpa.h
+++ b/drivers/staging/rt2870/wpa.h
@@ -1,330 +1 @@
1/* #include "../rt2860/wpa.h"
2 *************************************************************************
3 * Ralink Tech Inc.
4 * 5F., No.36, Taiyuan St., Jhubei City,
5 * Hsinchu County 302,
6 * Taiwan, R.O.C.
7 *
8 * (c) Copyright 2002-2007, Ralink Technology, Inc.
9 *
10 * This program is free software; you can redistribute it and/or modify *
11 * it under the terms of the GNU General Public License as published by *
12 * the Free Software Foundation; either version 2 of the License, or *
13 * (at your option) any later version. *
14 * *
15 * This program is distributed in the hope that it will be useful, *
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
18 * GNU General Public License for more details. *
19 * *
20 * You should have received a copy of the GNU General Public License *
21 * along with this program; if not, write to the *
22 * Free Software Foundation, Inc., *
23 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
24 * *
25 *************************************************************************
26
27 Module Name:
28 wpa.h
29
30 Abstract:
31
32 Revision History:
33 Who When What
34 -------- ---------- ----------------------------------------------
35 Name Date Modification logs
36*/
37
38#ifndef __WPA_H__
39#define __WPA_H__
40
41// EAPOL Key descripter frame format related length
42#define LEN_KEY_DESC_NONCE 32
43#define LEN_KEY_DESC_IV 16
44#define LEN_KEY_DESC_RSC 8
45#define LEN_KEY_DESC_ID 8
46#define LEN_KEY_DESC_REPLAY 8
47#define LEN_KEY_DESC_MIC 16
48
49// The length is the EAPoL-Key frame except key data field.
50// Please refer to 802.11i-2004 ,Figure 43u in p.78
51#define LEN_EAPOL_KEY_MSG (sizeof(KEY_DESCRIPTER) - MAX_LEN_OF_RSNIE)
52
53// EAP Code Type.
54#define EAP_CODE_REQUEST 1
55#define EAP_CODE_RESPONSE 2
56#define EAP_CODE_SUCCESS 3
57#define EAP_CODE_FAILURE 4
58
59// EAPOL frame Protocol Version
60#define EAPOL_VER 1
61#define EAPOL_VER2 2
62
63// EAPOL-KEY Descriptor Type
64#define WPA1_KEY_DESC 0xfe
65#define WPA2_KEY_DESC 0x02
66
67// Key Descriptor Version of Key Information
68#define DESC_TYPE_TKIP 1
69#define DESC_TYPE_AES 2
70#define DESC_TYPE_MESH 3
71
72#define LEN_MSG1_2WAY 0x7f
73#define MAX_LEN_OF_EAP_HS 256
74
75#define LEN_MASTER_KEY 32
76
77// EAPOL EK, MK
78#define LEN_EAP_EK 16
79#define LEN_EAP_MICK 16
80#define LEN_EAP_KEY ((LEN_EAP_EK)+(LEN_EAP_MICK))
81// TKIP key related
82#define LEN_PMKID 16
83#define LEN_TKIP_EK 16
84#define LEN_TKIP_RXMICK 8
85#define LEN_TKIP_TXMICK 8
86#define LEN_AES_EK 16
87#define LEN_AES_KEY LEN_AES_EK
88#define LEN_TKIP_KEY ((LEN_TKIP_EK)+(LEN_TKIP_RXMICK)+(LEN_TKIP_TXMICK))
89#define TKIP_AP_TXMICK_OFFSET ((LEN_EAP_KEY)+(LEN_TKIP_EK))
90#define TKIP_AP_RXMICK_OFFSET (TKIP_AP_TXMICK_OFFSET+LEN_TKIP_TXMICK)
91#define TKIP_GTK_LENGTH ((LEN_TKIP_EK)+(LEN_TKIP_RXMICK)+(LEN_TKIP_TXMICK))
92#define LEN_PTK ((LEN_EAP_KEY)+(LEN_TKIP_KEY))
93#ifndef RT30xx
94#define MIN_LEN_OF_GTK 5
95#endif
96
97// RSN IE Length definition
98#define MAX_LEN_OF_RSNIE 90
99#define MIN_LEN_OF_RSNIE 8
100
101//EAP Packet Type
102#define EAPPacket 0
103#define EAPOLStart 1
104#define EAPOLLogoff 2
105#define EAPOLKey 3
106#define EAPOLASFAlert 4
107#define EAPTtypeMax 5
108
109#define EAPOL_MSG_INVALID 0
110#define EAPOL_PAIR_MSG_1 1
111#define EAPOL_PAIR_MSG_2 2
112#define EAPOL_PAIR_MSG_3 3
113#define EAPOL_PAIR_MSG_4 4
114#define EAPOL_GROUP_MSG_1 5
115#define EAPOL_GROUP_MSG_2 6
116
117#define PAIRWISEKEY 1
118#define GROUPKEY 0
119
120// Retry timer counter initial value
121#define PEER_MSG1_RETRY_TIMER_CTR 0
122#define PEER_MSG3_RETRY_TIMER_CTR 10
123#define GROUP_MSG1_RETRY_TIMER_CTR 20
124
125
126#define EAPOL_START_DISABLE 0
127#define EAPOL_START_PSK 1
128#define EAPOL_START_1X 2
129
130#define MIX_CIPHER_WPA_TKIP_ON(x) (((x) & 0x08) != 0)
131#define MIX_CIPHER_WPA_AES_ON(x) (((x) & 0x04) != 0)
132#define MIX_CIPHER_WPA2_TKIP_ON(x) (((x) & 0x02) != 0)
133#define MIX_CIPHER_WPA2_AES_ON(x) (((x) & 0x01) != 0)
134
135#define ROUND_UP(__x, __y) \
136 (((ULONG)((__x)+((__y)-1))) & ((ULONG)~((__y)-1)))
137
138#define ADD_ONE_To_64BIT_VAR(_V) \
139{ \
140 UCHAR cnt = LEN_KEY_DESC_REPLAY; \
141 do \
142 { \
143 cnt--; \
144 _V[cnt]++; \
145 if (cnt == 0) \
146 break; \
147 }while (_V[cnt] == 0); \
148}
149
150#define IS_WPA_CAPABILITY(a) (((a) >= Ndis802_11AuthModeWPA) && ((a) <= Ndis802_11AuthModeWPA1PSKWPA2PSK))
151
152// EAPOL Key Information definition within Key descriptor format
153typedef struct PACKED _KEY_INFO
154{
155 UCHAR KeyMic:1;
156 UCHAR Secure:1;
157 UCHAR Error:1;
158 UCHAR Request:1;
159 UCHAR EKD_DL:1; // EKD for AP; DL for STA
160 UCHAR Rsvd:3;
161 UCHAR KeyDescVer:3;
162 UCHAR KeyType:1;
163 UCHAR KeyIndex:2;
164 UCHAR Install:1;
165 UCHAR KeyAck:1;
166} KEY_INFO, *PKEY_INFO;
167
168// EAPOL Key descriptor format
169typedef struct PACKED _KEY_DESCRIPTER
170{
171 UCHAR Type;
172 KEY_INFO KeyInfo;
173 UCHAR KeyLength[2];
174 UCHAR ReplayCounter[LEN_KEY_DESC_REPLAY];
175 UCHAR KeyNonce[LEN_KEY_DESC_NONCE];
176 UCHAR KeyIv[LEN_KEY_DESC_IV];
177 UCHAR KeyRsc[LEN_KEY_DESC_RSC];
178 UCHAR KeyId[LEN_KEY_DESC_ID];
179 UCHAR KeyMic[LEN_KEY_DESC_MIC];
180 UCHAR KeyDataLen[2];
181 UCHAR KeyData[MAX_LEN_OF_RSNIE];
182} KEY_DESCRIPTER, *PKEY_DESCRIPTER;
183
184typedef struct PACKED _EAPOL_PACKET
185{
186 UCHAR ProVer;
187 UCHAR ProType;
188 UCHAR Body_Len[2];
189 KEY_DESCRIPTER KeyDesc;
190} EAPOL_PACKET, *PEAPOL_PACKET;
191
192//802.11i D10 page 83
193typedef struct PACKED _GTK_ENCAP
194{
195 UCHAR Kid:2;
196 UCHAR tx:1;
197 UCHAR rsv:5;
198 UCHAR rsv1;
199 UCHAR GTK[TKIP_GTK_LENGTH];
200} GTK_ENCAP, *PGTK_ENCAP;
201
202typedef struct PACKED _KDE_ENCAP
203{
204 UCHAR Type;
205 UCHAR Len;
206 UCHAR OUI[3];
207 UCHAR DataType;
208 GTK_ENCAP GTKEncap;
209} KDE_ENCAP, *PKDE_ENCAP;
210
211// For WPA1
212typedef struct PACKED _RSNIE {
213 UCHAR oui[4];
214 USHORT version;
215 UCHAR mcast[4];
216 USHORT ucount;
217 struct PACKED {
218 UCHAR oui[4];
219 }ucast[1];
220} RSNIE, *PRSNIE;
221
222// For WPA2
223typedef struct PACKED _RSNIE2 {
224 USHORT version;
225 UCHAR mcast[4];
226 USHORT ucount;
227 struct PACKED {
228 UCHAR oui[4];
229 }ucast[1];
230} RSNIE2, *PRSNIE2;
231
232// AKM Suite
233typedef struct PACKED _RSNIE_AUTH {
234 USHORT acount;
235 struct PACKED {
236 UCHAR oui[4];
237 }auth[1];
238} RSNIE_AUTH,*PRSNIE_AUTH;
239
240typedef union PACKED _RSN_CAPABILITIES {
241 struct PACKED {
242 USHORT PreAuth:1;
243 USHORT No_Pairwise:1;
244 USHORT PTKSA_R_Counter:2;
245 USHORT GTKSA_R_Counter:2;
246 USHORT Rsvd:10;
247 } field;
248 USHORT word;
249} RSN_CAPABILITIES, *PRSN_CAPABILITIES;
250
251typedef struct PACKED _EAP_HDR {
252 UCHAR ProVer;
253 UCHAR ProType;
254 UCHAR Body_Len[2];
255 UCHAR code;
256 UCHAR identifier;
257 UCHAR length[2]; // including code and identifier, followed by length-2 octets of data
258} EAP_HDR, *PEAP_HDR;
259
260// For supplicant state machine states. 802.11i Draft 4.1, p. 97
261// We simplified it
262typedef enum _WpaState
263{
264 SS_NOTUSE, // 0
265 SS_START, // 1
266 SS_WAIT_MSG_3, // 2
267 SS_WAIT_GROUP, // 3
268 SS_FINISH, // 4
269 SS_KEYUPDATE, // 5
270} WPA_STATE;
271
272//
273// The definition of the cipher combination
274//
275// bit3 bit2 bit1 bit0
276// +------------+------------+
277// | WPA | WPA2 |
278// +------+-----+------+-----+
279// | TKIP | AES | TKIP | AES |
280// | 0 | 1 | 1 | 0 | -> 0x06
281// | 0 | 1 | 1 | 1 | -> 0x07
282// | 1 | 0 | 0 | 1 | -> 0x09
283// | 1 | 0 | 1 | 1 | -> 0x0B
284// | 1 | 1 | 0 | 1 | -> 0x0D
285// | 1 | 1 | 1 | 0 | -> 0x0E
286// | 1 | 1 | 1 | 1 | -> 0x0F
287// +------+-----+------+-----+
288//
289typedef enum _WpaMixPairCipher
290{
291 MIX_CIPHER_NOTUSE = 0x00,
292 WPA_NONE_WPA2_TKIPAES = 0x03, // WPA2-TKIPAES
293 WPA_AES_WPA2_TKIP = 0x06,
294 WPA_AES_WPA2_TKIPAES = 0x07,
295 WPA_TKIP_WPA2_AES = 0x09,
296 WPA_TKIP_WPA2_TKIPAES = 0x0B,
297 WPA_TKIPAES_WPA2_NONE = 0x0C, // WPA-TKIPAES
298 WPA_TKIPAES_WPA2_AES = 0x0D,
299 WPA_TKIPAES_WPA2_TKIP = 0x0E,
300 WPA_TKIPAES_WPA2_TKIPAES = 0x0F,
301} WPA_MIX_PAIR_CIPHER;
302
303typedef struct PACKED _RSN_IE_HEADER_STRUCT {
304 UCHAR Eid;
305 UCHAR Length;
306 USHORT Version; // Little endian format
307} RSN_IE_HEADER_STRUCT, *PRSN_IE_HEADER_STRUCT;
308
309// Cipher suite selector types
310typedef struct PACKED _CIPHER_SUITE_STRUCT {
311 UCHAR Oui[3];
312 UCHAR Type;
313} CIPHER_SUITE_STRUCT, *PCIPHER_SUITE_STRUCT;
314
315// Authentication and Key Management suite selector
316typedef struct PACKED _AKM_SUITE_STRUCT {
317 UCHAR Oui[3];
318 UCHAR Type;
319} AKM_SUITE_STRUCT, *PAKM_SUITE_STRUCT;
320
321// RSN capability
322typedef struct PACKED _RSN_CAPABILITY {
323 USHORT Rsv:10;
324 USHORT GTKSAReplayCnt:2;
325 USHORT PTKSAReplayCnt:2;
326 USHORT NoPairwise:1;
327 USHORT PreAuth:1;
328} RSN_CAPABILITY, *PRSN_CAPABILITY;
329
330#endif