2 *************************************************************************
4 * 5F., No.36, Taiyuan St., Jhubei City,
8 * (c) Copyright 2002-2007, Ralink Technology, Inc.
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. *
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. *
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. *
25 *************************************************************************
31 IOCTL related subroutines
35 -------- ---------- ----------------------------------------------
36 Rory Chen 01-03-2003 created
37 Rory Chen 02-14-2005 modify to support RT61
40 #include "rt_config.h"
43 extern ULONG RTDebugLevel
;
47 #define WEP_SMALL_KEY_LEN (40/8)
48 #define WEP_LARGE_KEY_LEN (104/8)
50 #define GROUP_KEY_NO 4
52 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27)
53 #define IWE_STREAM_ADD_EVENT(_A, _B, _C, _D, _E) iwe_stream_add_event(_A, _B, _C, _D, _E)
54 #define IWE_STREAM_ADD_POINT(_A, _B, _C, _D, _E) iwe_stream_add_point(_A, _B, _C, _D, _E)
55 #define IWE_STREAM_ADD_VALUE(_A, _B, _C, _D, _E, _F) iwe_stream_add_value(_A, _B, _C, _D, _E, _F)
57 #define IWE_STREAM_ADD_EVENT(_A, _B, _C, _D, _E) iwe_stream_add_event(_B, _C, _D, _E)
58 #define IWE_STREAM_ADD_POINT(_A, _B, _C, _D, _E) iwe_stream_add_point(_B, _C, _D, _E)
59 #define IWE_STREAM_ADD_VALUE(_A, _B, _C, _D, _E, _F) iwe_stream_add_value(_B, _C, _D, _E, _F)
62 extern UCHAR CipherWpa2Template
[];
63 extern UCHAR CipherWpaPskTkip
[];
64 extern UCHAR CipherWpaPskTkipLen
;
66 typedef struct PACKED _RT_VERSION_INFO
{
72 UINT DriverBuildMonth
;
74 } RT_VERSION_INFO
, *PRT_VERSION_INFO
;
76 struct iw_priv_args privtab
[] = {
78 IW_PRIV_TYPE_CHAR
| 1024, 0,
81 { RTPRIV_IOCTL_SHOW
, 0, IW_PRIV_TYPE_CHAR
| IW_PRIV_SIZE_MASK
,
83 { RTPRIV_IOCTL_SHOW
, IW_PRIV_TYPE_CHAR
| 1024, IW_PRIV_TYPE_CHAR
| IW_PRIV_SIZE_MASK
,
85 /* --- sub-ioctls definitions --- */
87 0, IW_PRIV_TYPE_CHAR
| IW_PRIV_SIZE_MASK
, "connStatus" },
89 0, IW_PRIV_TYPE_CHAR
| IW_PRIV_SIZE_MASK
, "driverVer" },
91 0, IW_PRIV_TYPE_CHAR
| IW_PRIV_SIZE_MASK
, "bainfo" },
93 0, IW_PRIV_TYPE_CHAR
| IW_PRIV_SIZE_MASK
, "descinfo" },
95 0, IW_PRIV_TYPE_CHAR
| IW_PRIV_SIZE_MASK
, "radio_off" },
97 0, IW_PRIV_TYPE_CHAR
| IW_PRIV_SIZE_MASK
, "radio_on" },
98 #ifdef QOS_DLS_SUPPORT
99 { SHOW_DLS_ENTRY_INFO
,
100 0, IW_PRIV_TYPE_CHAR
| IW_PRIV_SIZE_MASK
, "dlsentryinfo" },
101 #endif // QOS_DLS_SUPPORT //
103 IW_PRIV_TYPE_CHAR
| 1024, IW_PRIV_TYPE_CHAR
| IW_PRIV_SIZE_MASK
, "show" },
104 /* --- sub-ioctls relations --- */
108 IW_PRIV_TYPE_CHAR
| IW_PRIV_SIZE_MASK
, IW_PRIV_TYPE_CHAR
| IW_PRIV_SIZE_MASK
,
111 IW_PRIV_TYPE_CHAR
| 1024, IW_PRIV_TYPE_CHAR
| 1024,
114 IW_PRIV_TYPE_CHAR
| 1024, IW_PRIV_TYPE_CHAR
| 1024,
118 { RTPRIV_IOCTL_STATISTICS
,
119 0, IW_PRIV_TYPE_CHAR
| IW_PRIV_SIZE_MASK
,
121 { RTPRIV_IOCTL_GSITESURVEY
,
122 0, IW_PRIV_TYPE_CHAR
| 1024,
127 IN PRTMP_ADAPTER pAdapter
,
131 INT
Set_WmmCapable_Proc(
132 IN PRTMP_ADAPTER pAd
,
136 INT
Set_NetworkType_Proc(
137 IN PRTMP_ADAPTER pAdapter
,
140 INT
Set_AuthMode_Proc(
141 IN PRTMP_ADAPTER pAdapter
,
144 INT
Set_EncrypType_Proc(
145 IN PRTMP_ADAPTER pAdapter
,
148 INT
Set_DefaultKeyID_Proc(
149 IN PRTMP_ADAPTER pAdapter
,
153 IN PRTMP_ADAPTER pAdapter
,
157 IN PRTMP_ADAPTER pAdapter
,
161 IN PRTMP_ADAPTER pAdapter
,
165 IN PRTMP_ADAPTER pAdapter
,
169 IN PRTMP_ADAPTER pAdapter
,
174 IN PRTMP_ADAPTER pAdapter
,
177 #ifdef WPA_SUPPLICANT_SUPPORT
179 IN PRTMP_ADAPTER pAd
,
181 #endif // WPA_SUPPLICANT_SUPPORT //
185 IN PRTMP_ADAPTER pAdapter
,
186 IN
struct iwreq
*wrq
);
189 IN PRTMP_ADAPTER pAdapter
,
190 IN
struct iwreq
*wrq
);
192 VOID
RTMPIoctlE2PROM(
193 IN PRTMP_ADAPTER pAdapter
,
194 IN
struct iwreq
*wrq
);
198 NDIS_STATUS
RTMPWPANoneAddKeyProc(
199 IN PRTMP_ADAPTER pAd
,
202 INT
Set_FragTest_Proc(
203 IN PRTMP_ADAPTER pAdapter
,
206 #ifdef DOT11_N_SUPPORT
207 INT
Set_TGnWifiTest_Proc(
208 IN PRTMP_ADAPTER pAd
,
210 #endif // DOT11_N_SUPPORT //
212 INT
Set_LongRetryLimit_Proc(
213 IN PRTMP_ADAPTER pAdapter
,
216 INT
Set_ShortRetryLimit_Proc(
217 IN PRTMP_ADAPTER pAdapter
,
220 #ifdef EXT_BUILD_CHANNEL_LIST
221 INT
Set_Ieee80211dClientMode_Proc(
222 IN PRTMP_ADAPTER pAdapter
,
224 #endif // EXT_BUILD_CHANNEL_LIST //
226 #ifdef CARRIER_DETECTION_SUPPORT
227 INT
Set_CarrierDetect_Proc(
228 IN PRTMP_ADAPTER pAd
,
230 #endif // CARRIER_DETECTION_SUPPORT //
234 INT (*set_proc
)(PRTMP_ADAPTER pAdapter
, PUCHAR arg
);
235 } *PRTMP_PRIVATE_SET_PROC
, RTMP_PRIVATE_SUPPORT_PROC
[] = {
236 {"DriverVersion", Set_DriverVersion_Proc
},
237 {"CountryRegion", Set_CountryRegion_Proc
},
238 {"CountryRegionABand", Set_CountryRegionABand_Proc
},
239 {"SSID", Set_SSID_Proc
},
240 {"WirelessMode", Set_WirelessMode_Proc
},
241 {"TxBurst", Set_TxBurst_Proc
},
242 {"TxPreamble", Set_TxPreamble_Proc
},
243 {"TxPower", Set_TxPower_Proc
},
244 {"Channel", Set_Channel_Proc
},
245 {"BGProtection", Set_BGProtection_Proc
},
246 {"RTSThreshold", Set_RTSThreshold_Proc
},
247 {"FragThreshold", Set_FragThreshold_Proc
},
248 #ifdef DOT11_N_SUPPORT
249 {"HtBw", Set_HtBw_Proc
},
250 {"HtMcs", Set_HtMcs_Proc
},
251 {"HtGi", Set_HtGi_Proc
},
252 {"HtOpMode", Set_HtOpMode_Proc
},
253 {"HtExtcha", Set_HtExtcha_Proc
},
254 {"HtMpduDensity", Set_HtMpduDensity_Proc
},
255 {"HtBaWinSize", Set_HtBaWinSize_Proc
},
256 {"HtRdg", Set_HtRdg_Proc
},
257 {"HtAmsdu", Set_HtAmsdu_Proc
},
258 {"HtAutoBa", Set_HtAutoBa_Proc
},
259 {"HtBaDecline", Set_BADecline_Proc
},
260 {"HtProtect", Set_HtProtect_Proc
},
261 {"HtMimoPs", Set_HtMimoPs_Proc
},
262 #endif // DOT11_N_SUPPORT //
264 #ifdef AGGREGATION_SUPPORT
265 {"PktAggregate", Set_PktAggregate_Proc
},
269 {"WmmCapable", Set_WmmCapable_Proc
},
271 {"IEEE80211H", Set_IEEE80211H_Proc
},
272 {"NetworkType", Set_NetworkType_Proc
},
273 {"AuthMode", Set_AuthMode_Proc
},
274 {"EncrypType", Set_EncrypType_Proc
},
275 {"DefaultKeyID", Set_DefaultKeyID_Proc
},
276 {"Key1", Set_Key1_Proc
},
277 {"Key2", Set_Key2_Proc
},
278 {"Key3", Set_Key3_Proc
},
279 {"Key4", Set_Key4_Proc
},
280 {"WPAPSK", Set_WPAPSK_Proc
},
281 {"ResetCounter", Set_ResetStatCounter_Proc
},
282 {"PSMode", Set_PSMode_Proc
},
284 {"Debug", Set_Debug_Proc
},
288 {"ATE", Set_ATE_Proc
},
289 {"ATEDA", Set_ATE_DA_Proc
},
290 {"ATESA", Set_ATE_SA_Proc
},
291 {"ATEBSSID", Set_ATE_BSSID_Proc
},
292 {"ATECHANNEL", Set_ATE_CHANNEL_Proc
},
293 {"ATETXPOW0", Set_ATE_TX_POWER0_Proc
},
294 {"ATETXPOW1", Set_ATE_TX_POWER1_Proc
},
295 {"ATETXANT", Set_ATE_TX_Antenna_Proc
},
296 {"ATERXANT", Set_ATE_RX_Antenna_Proc
},
297 {"ATETXFREQOFFSET", Set_ATE_TX_FREQOFFSET_Proc
},
298 {"ATETXBW", Set_ATE_TX_BW_Proc
},
299 {"ATETXLEN", Set_ATE_TX_LENGTH_Proc
},
300 {"ATETXCNT", Set_ATE_TX_COUNT_Proc
},
301 {"ATETXMCS", Set_ATE_TX_MCS_Proc
},
302 {"ATETXMODE", Set_ATE_TX_MODE_Proc
},
303 {"ATETXGI", Set_ATE_TX_GI_Proc
},
304 {"ATERXFER", Set_ATE_RX_FER_Proc
},
305 {"ATERRF", Set_ATE_Read_RF_Proc
},
306 {"ATEWRF1", Set_ATE_Write_RF1_Proc
},
307 {"ATEWRF2", Set_ATE_Write_RF2_Proc
},
308 {"ATEWRF3", Set_ATE_Write_RF3_Proc
},
309 {"ATEWRF4", Set_ATE_Write_RF4_Proc
},
310 {"ATELDE2P", Set_ATE_Load_E2P_Proc
},
311 {"ATERE2P", Set_ATE_Read_E2P_Proc
},
312 {"ATESHOW", Set_ATE_Show_Proc
},
313 {"ATEHELP", Set_ATE_Help_Proc
},
315 #ifdef RALINK_28xx_QA
316 {"TxStop", Set_TxStop_Proc
},
317 {"RxStop", Set_RxStop_Proc
},
318 #endif // RALINK_28xx_QA //
319 #endif // RALINK_ATE //
321 #ifdef WPA_SUPPLICANT_SUPPORT
322 {"WpaSupport", Set_Wpa_Support
},
323 #endif // WPA_SUPPLICANT_SUPPORT //
327 {"FixedTxMode", Set_FixedTxMode_Proc
},
328 #ifdef CONFIG_APSTA_MIXED_SUPPORT
329 {"OpMode", Set_OpMode_Proc
},
330 #endif // CONFIG_APSTA_MIXED_SUPPORT //
331 #ifdef DOT11_N_SUPPORT
332 {"TGnWifiTest", Set_TGnWifiTest_Proc
},
333 {"ForceGF", Set_ForceGF_Proc
},
334 #endif // DOT11_N_SUPPORT //
335 #ifdef QOS_DLS_SUPPORT
336 {"DlsAddEntry", Set_DlsAddEntry_Proc
},
337 {"DlsTearDownEntry", Set_DlsTearDownEntry_Proc
},
338 #endif // QOS_DLS_SUPPORT //
339 {"LongRetry", Set_LongRetryLimit_Proc
},
340 {"ShortRetry", Set_ShortRetryLimit_Proc
},
341 #ifdef EXT_BUILD_CHANNEL_LIST
342 {"11dClientMode", Set_Ieee80211dClientMode_Proc
},
343 #endif // EXT_BUILD_CHANNEL_LIST //
344 #ifdef CARRIER_DETECTION_SUPPORT
345 {"CarrierDetect", Set_CarrierDetect_Proc
},
346 #endif // CARRIER_DETECTION_SUPPORT //
353 IN PRTMP_ADAPTER pAd
,
354 IN PNDIS_802_11_KEY pKey
)
357 MAC_TABLE_ENTRY
*pEntry
;
359 DBGPRINT(RT_DEBUG_TRACE
, ("RTMPAddKey ------>\n"));
361 if (pAd
->StaCfg
.AuthMode
>= Ndis802_11AuthModeWPA
)
363 if (pKey
->KeyIndex
& 0x80000000)
365 if (pAd
->StaCfg
.AuthMode
== Ndis802_11AuthModeWPANone
)
367 NdisZeroMemory(pAd
->StaCfg
.PMK
, 32);
368 NdisMoveMemory(pAd
->StaCfg
.PMK
, pKey
->KeyMaterial
, pKey
->KeyLength
);
372 NdisZeroMemory(&pAd
->SharedKey
[BSS0
][0], sizeof(CIPHER_KEY
));
373 pAd
->SharedKey
[BSS0
][0].KeyLen
= LEN_TKIP_EK
;
374 NdisMoveMemory(pAd
->SharedKey
[BSS0
][0].Key
, pKey
->KeyMaterial
, LEN_TKIP_EK
);
375 #ifdef WPA_SUPPLICANT_SUPPORT
376 if (pAd
->StaCfg
.PairCipher
== Ndis802_11Encryption2Enabled
)
378 NdisMoveMemory(pAd
->SharedKey
[BSS0
][0].RxMic
, pKey
->KeyMaterial
+ LEN_TKIP_EK
, LEN_TKIP_TXMICK
);
379 NdisMoveMemory(pAd
->SharedKey
[BSS0
][0].TxMic
, pKey
->KeyMaterial
+ LEN_TKIP_EK
+ LEN_TKIP_TXMICK
, LEN_TKIP_RXMICK
);
382 #endif // WPA_SUPPLICANT_SUPPORT //
384 NdisMoveMemory(pAd
->SharedKey
[BSS0
][0].TxMic
, pKey
->KeyMaterial
+ LEN_TKIP_EK
, LEN_TKIP_TXMICK
);
385 NdisMoveMemory(pAd
->SharedKey
[BSS0
][0].RxMic
, pKey
->KeyMaterial
+ LEN_TKIP_EK
+ LEN_TKIP_TXMICK
, LEN_TKIP_RXMICK
);
388 // Decide its ChiperAlg
389 if (pAd
->StaCfg
.PairCipher
== Ndis802_11Encryption2Enabled
)
390 pAd
->SharedKey
[BSS0
][0].CipherAlg
= CIPHER_TKIP
;
391 else if (pAd
->StaCfg
.PairCipher
== Ndis802_11Encryption3Enabled
)
392 pAd
->SharedKey
[BSS0
][0].CipherAlg
= CIPHER_AES
;
394 pAd
->SharedKey
[BSS0
][0].CipherAlg
= CIPHER_NONE
;
396 // Update these related information to MAC_TABLE_ENTRY
397 pEntry
= &pAd
->MacTab
.Content
[BSSID_WCID
];
398 NdisMoveMemory(pEntry
->PairwiseKey
.Key
, pAd
->SharedKey
[BSS0
][0].Key
, LEN_TKIP_EK
);
399 NdisMoveMemory(pEntry
->PairwiseKey
.RxMic
, pAd
->SharedKey
[BSS0
][0].RxMic
, LEN_TKIP_RXMICK
);
400 NdisMoveMemory(pEntry
->PairwiseKey
.TxMic
, pAd
->SharedKey
[BSS0
][0].TxMic
, LEN_TKIP_TXMICK
);
401 pEntry
->PairwiseKey
.CipherAlg
= pAd
->SharedKey
[BSS0
][0].CipherAlg
;
403 // Update pairwise key information to ASIC Shared Key Table
404 AsicAddSharedKeyEntry(pAd
,
407 pAd
->SharedKey
[BSS0
][0].CipherAlg
,
408 pAd
->SharedKey
[BSS0
][0].Key
,
409 pAd
->SharedKey
[BSS0
][0].TxMic
,
410 pAd
->SharedKey
[BSS0
][0].RxMic
);
412 // Update ASIC WCID attribute table and IVEIV table
413 RTMPAddWcidAttributeEntry(pAd
,
416 pAd
->SharedKey
[BSS0
][0].CipherAlg
,
419 if (pAd
->StaCfg
.AuthMode
>= Ndis802_11AuthModeWPA2
)
421 // set 802.1x port control
422 STA_PORT_SECURED(pAd
);
424 // Indicate Connected for GUI
425 pAd
->IndicateMediaState
= NdisMediaStateConnected
;
431 pAd
->StaCfg
.DefaultKeyId
= (pKey
->KeyIndex
& 0xFF);
432 NdisZeroMemory(&pAd
->SharedKey
[BSS0
][pAd
->StaCfg
.DefaultKeyId
], sizeof(CIPHER_KEY
));
433 pAd
->SharedKey
[BSS0
][pAd
->StaCfg
.DefaultKeyId
].KeyLen
= LEN_TKIP_EK
;
434 NdisMoveMemory(pAd
->SharedKey
[BSS0
][pAd
->StaCfg
.DefaultKeyId
].Key
, pKey
->KeyMaterial
, LEN_TKIP_EK
);
435 #ifdef WPA_SUPPLICANT_SUPPORT
436 if (pAd
->StaCfg
.GroupCipher
== Ndis802_11Encryption2Enabled
)
438 NdisMoveMemory(pAd
->SharedKey
[BSS0
][pAd
->StaCfg
.DefaultKeyId
].RxMic
, pKey
->KeyMaterial
+ LEN_TKIP_EK
, LEN_TKIP_TXMICK
);
439 NdisMoveMemory(pAd
->SharedKey
[BSS0
][pAd
->StaCfg
.DefaultKeyId
].TxMic
, pKey
->KeyMaterial
+ LEN_TKIP_EK
+ LEN_TKIP_TXMICK
, LEN_TKIP_RXMICK
);
442 #endif // WPA_SUPPLICANT_SUPPORT //
444 NdisMoveMemory(pAd
->SharedKey
[BSS0
][pAd
->StaCfg
.DefaultKeyId
].TxMic
, pKey
->KeyMaterial
+ LEN_TKIP_EK
, LEN_TKIP_TXMICK
);
445 NdisMoveMemory(pAd
->SharedKey
[BSS0
][pAd
->StaCfg
.DefaultKeyId
].RxMic
, pKey
->KeyMaterial
+ LEN_TKIP_EK
+ LEN_TKIP_TXMICK
, LEN_TKIP_RXMICK
);
448 // Update Shared Key CipherAlg
449 pAd
->SharedKey
[BSS0
][pAd
->StaCfg
.DefaultKeyId
].CipherAlg
= CIPHER_NONE
;
450 if (pAd
->StaCfg
.GroupCipher
== Ndis802_11Encryption2Enabled
)
451 pAd
->SharedKey
[BSS0
][pAd
->StaCfg
.DefaultKeyId
].CipherAlg
= CIPHER_TKIP
;
452 else if (pAd
->StaCfg
.GroupCipher
== Ndis802_11Encryption3Enabled
)
453 pAd
->SharedKey
[BSS0
][pAd
->StaCfg
.DefaultKeyId
].CipherAlg
= CIPHER_AES
;
455 // Update group key information to ASIC Shared Key Table
456 AsicAddSharedKeyEntry(pAd
,
458 pAd
->StaCfg
.DefaultKeyId
,
459 pAd
->SharedKey
[BSS0
][pAd
->StaCfg
.DefaultKeyId
].CipherAlg
,
460 pAd
->SharedKey
[BSS0
][pAd
->StaCfg
.DefaultKeyId
].Key
,
461 pAd
->SharedKey
[BSS0
][pAd
->StaCfg
.DefaultKeyId
].TxMic
,
462 pAd
->SharedKey
[BSS0
][pAd
->StaCfg
.DefaultKeyId
].RxMic
);
464 // Update ASIC WCID attribute table and IVEIV table
465 RTMPAddWcidAttributeEntry(pAd
,
467 pAd
->StaCfg
.DefaultKeyId
,
468 pAd
->SharedKey
[BSS0
][pAd
->StaCfg
.DefaultKeyId
].CipherAlg
,
471 // set 802.1x port control
472 STA_PORT_SECURED(pAd
);
474 // Indicate Connected for GUI
475 pAd
->IndicateMediaState
= NdisMediaStateConnected
;
478 else // dynamic WEP from wpa_supplicant
483 if(pKey
->KeyLength
== 32)
486 KeyIdx
= pKey
->KeyIndex
& 0x0fffffff;
490 // it is a default shared key, for Pairwise key setting
491 if (pKey
->KeyIndex
& 0x80000000)
493 pEntry
= MacTableLookup(pAd
, pKey
->BSSID
);
497 DBGPRINT(RT_DEBUG_TRACE
, ("RTMPAddKey: Set Pair-wise Key\n"));
499 // set key material and key length
500 pEntry
->PairwiseKey
.KeyLen
= (UCHAR
)pKey
->KeyLength
;
501 NdisMoveMemory(pEntry
->PairwiseKey
.Key
, &pKey
->KeyMaterial
, pKey
->KeyLength
);
504 if (pKey
->KeyLength
== 5)
505 pEntry
->PairwiseKey
.CipherAlg
= CIPHER_WEP64
;
507 pEntry
->PairwiseKey
.CipherAlg
= CIPHER_WEP128
;
509 // Add Pair-wise key to Asic
510 AsicAddPairwiseKeyEntry(
514 &pEntry
->PairwiseKey
);
516 // update WCID attribute table and IVEIV table for this entry
517 RTMPAddWcidAttributeEntry(
520 KeyIdx
, // The value may be not zero
521 pEntry
->PairwiseKey
.CipherAlg
,
528 // Default key for tx (shared key)
529 pAd
->StaCfg
.DefaultKeyId
= (UCHAR
) KeyIdx
;
531 // set key material and key length
532 pAd
->SharedKey
[BSS0
][KeyIdx
].KeyLen
= (UCHAR
) pKey
->KeyLength
;
533 NdisMoveMemory(pAd
->SharedKey
[BSS0
][KeyIdx
].Key
, &pKey
->KeyMaterial
, pKey
->KeyLength
);
536 if (pKey
->KeyLength
== 5)
537 pAd
->SharedKey
[BSS0
][KeyIdx
].CipherAlg
= CIPHER_WEP64
;
539 pAd
->SharedKey
[BSS0
][KeyIdx
].CipherAlg
= CIPHER_WEP128
;
541 CipherAlg
= pAd
->SharedKey
[BSS0
][KeyIdx
].CipherAlg
;
542 Key
= pAd
->SharedKey
[BSS0
][KeyIdx
].Key
;
544 // Set Group key material to Asic
545 AsicAddSharedKeyEntry(pAd
, BSS0
, KeyIdx
, CipherAlg
, Key
, NULL
, NULL
);
547 // Update WCID attribute table and IVEIV table for this group key table
548 RTMPAddWcidAttributeEntry(pAd
, BSS0
, KeyIdx
, CipherAlg
, NULL
);
557 char * rtstrchr(const char * s
, int c
)
559 for(; *s
!= (char) c
; ++s
)
566 This is required for LinEX2004/kernel2.6.7 to provide iwlist scanning function
570 rt_ioctl_giwname(struct net_device
*dev
,
571 struct iw_request_info
*info
,
572 char *name
, char *extra
)
574 // PRTMP_ADAPTER pAdapter = dev->ml_priv;
577 strncpy(name
, "RT2860 Wireless", IFNAMSIZ
);
582 int rt_ioctl_siwfreq(struct net_device
*dev
,
583 struct iw_request_info
*info
,
584 struct iw_freq
*freq
, char *extra
)
586 PRTMP_ADAPTER pAdapter
= dev
->ml_priv
;
589 //check if the interface is down
590 if(!RTMP_TEST_FLAG(pAdapter
, fRTMP_ADAPTER_INTERRUPT_IN_USE
))
592 DBGPRINT(RT_DEBUG_TRACE
, ("INFO::Network is down!\n"));
600 if((freq
->e
== 0) && (freq
->m
<= 1000))
601 chan
= freq
->m
; // Setting by channel number
603 MAP_KHZ_TO_CHANNEL_ID( (freq
->m
/100) , chan
); // Setting by frequency - search the table , like 2.412G, 2.422G,
605 if (ChannelSanity(pAdapter
, chan
) == TRUE
)
607 pAdapter
->CommonCfg
.Channel
= chan
;
608 DBGPRINT(RT_DEBUG_ERROR
, ("==>rt_ioctl_siwfreq::SIOCSIWFREQ[cmd=0x%x] (Channel=%d)\n", SIOCSIWFREQ
, pAdapter
->CommonCfg
.Channel
));
615 int rt_ioctl_giwfreq(struct net_device
*dev
,
616 struct iw_request_info
*info
,
617 struct iw_freq
*freq
, char *extra
)
619 VIRTUAL_ADAPTER
*pVirtualAd
= NULL
;
620 PRTMP_ADAPTER pAdapter
= NULL
;
624 if (dev
->priv_flags
== INT_MAIN
)
626 pAdapter
= dev
->ml_priv
;
630 pVirtualAd
= dev
->ml_priv
;
631 if (pVirtualAd
&& pVirtualAd
->RtmpDev
)
632 pAdapter
= pVirtualAd
->RtmpDev
->ml_priv
;
635 if (pAdapter
== NULL
)
637 /* if 1st open fail, pAd will be free;
638 So the net_dev->ml_priv will be NULL in 2rd open */
642 ch
= pAdapter
->CommonCfg
.Channel
;
644 DBGPRINT(RT_DEBUG_TRACE
,("==>rt_ioctl_giwfreq %d\n", ch
));
646 MAP_CHANNEL_ID_TO_KHZ(ch
, m
);
652 int rt_ioctl_siwmode(struct net_device
*dev
,
653 struct iw_request_info
*info
,
654 __u32
*mode
, char *extra
)
656 PRTMP_ADAPTER pAdapter
= dev
->ml_priv
;
658 //check if the interface is down
659 if(!RTMP_TEST_FLAG(pAdapter
, fRTMP_ADAPTER_INTERRUPT_IN_USE
))
661 DBGPRINT(RT_DEBUG_TRACE
, ("INFO::Network is down!\n"));
668 Set_NetworkType_Proc(pAdapter
, "Adhoc");
671 Set_NetworkType_Proc(pAdapter
, "Infra");
673 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,4,20))
674 case IW_MODE_MONITOR
:
675 Set_NetworkType_Proc(pAdapter
, "Monitor");
679 DBGPRINT(RT_DEBUG_TRACE
, ("===>rt_ioctl_siwmode::SIOCSIWMODE (unknown %d)\n", *mode
));
683 // Reset Ralink supplicant to not use, it will be set to start when UI set PMK key
684 pAdapter
->StaCfg
.WpaState
= SS_NOTUSE
;
689 int rt_ioctl_giwmode(struct net_device
*dev
,
690 struct iw_request_info
*info
,
691 __u32
*mode
, char *extra
)
693 PRTMP_ADAPTER pAdapter
= NULL
;
694 VIRTUAL_ADAPTER
*pVirtualAd
= NULL
;
696 if (dev
->priv_flags
== INT_MAIN
)
698 pAdapter
= dev
->ml_priv
;
702 pVirtualAd
= dev
->ml_priv
;
703 if (pVirtualAd
&& pVirtualAd
->RtmpDev
)
704 pAdapter
= pVirtualAd
->RtmpDev
->ml_priv
;
707 if (pAdapter
== NULL
)
709 /* if 1st open fail, pAd will be free;
710 So the net_dev->ml_priv will be NULL in 2rd open */
714 if (ADHOC_ON(pAdapter
))
715 *mode
= IW_MODE_ADHOC
;
716 else if (INFRA_ON(pAdapter
))
717 *mode
= IW_MODE_INFRA
;
718 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,4,20))
719 else if (MONITOR_ON(pAdapter
))
721 *mode
= IW_MODE_MONITOR
;
725 *mode
= IW_MODE_AUTO
;
727 DBGPRINT(RT_DEBUG_TRACE
, ("==>rt_ioctl_giwmode(mode=%d)\n", *mode
));
731 int rt_ioctl_siwsens(struct net_device
*dev
,
732 struct iw_request_info
*info
,
733 char *name
, char *extra
)
735 PRTMP_ADAPTER pAdapter
= dev
->ml_priv
;
737 //check if the interface is down
738 if(!RTMP_TEST_FLAG(pAdapter
, fRTMP_ADAPTER_INTERRUPT_IN_USE
))
740 DBGPRINT(RT_DEBUG_TRACE
, ("INFO::Network is down!\n"));
747 int rt_ioctl_giwsens(struct net_device
*dev
,
748 struct iw_request_info
*info
,
749 char *name
, char *extra
)
754 int rt_ioctl_giwrange(struct net_device
*dev
,
755 struct iw_request_info
*info
,
756 struct iw_point
*data
, char *extra
)
758 PRTMP_ADAPTER pAdapter
= NULL
;
759 VIRTUAL_ADAPTER
*pVirtualAd
= NULL
;
760 struct iw_range
*range
= (struct iw_range
*) extra
;
764 if (dev
->priv_flags
== INT_MAIN
)
766 pAdapter
= dev
->ml_priv
;
770 pVirtualAd
= dev
->ml_priv
;
771 if (pVirtualAd
&& pVirtualAd
->RtmpDev
)
772 pAdapter
= pVirtualAd
->RtmpDev
->ml_priv
;
775 if (pAdapter
== NULL
)
777 /* if 1st open fail, pAd will be free;
778 So the net_dev->ml_priv will be NULL in 2rd open */
782 DBGPRINT(RT_DEBUG_TRACE
,("===>rt_ioctl_giwrange\n"));
783 data
->length
= sizeof(struct iw_range
);
784 memset(range
, 0, sizeof(struct iw_range
));
786 range
->txpower_capa
= IW_TXPOW_DBM
;
788 if (INFRA_ON(pAdapter
)||ADHOC_ON(pAdapter
))
790 range
->min_pmp
= 1 * 1024;
791 range
->max_pmp
= 65535 * 1024;
792 range
->min_pmt
= 1 * 1024;
793 range
->max_pmt
= 1000 * 1024;
794 range
->pmp_flags
= IW_POWER_PERIOD
;
795 range
->pmt_flags
= IW_POWER_TIMEOUT
;
796 range
->pm_capa
= IW_POWER_PERIOD
| IW_POWER_TIMEOUT
|
797 IW_POWER_UNICAST_R
| IW_POWER_ALL_R
;
800 range
->we_version_compiled
= WIRELESS_EXT
;
801 range
->we_version_source
= 14;
803 range
->retry_capa
= IW_RETRY_LIMIT
;
804 range
->retry_flags
= IW_RETRY_LIMIT
;
805 range
->min_retry
= 0;
806 range
->max_retry
= 255;
808 range
->num_channels
= pAdapter
->ChannelListNum
;
811 for (i
= 1; i
<= range
->num_channels
; i
++)
814 range
->freq
[val
].i
= pAdapter
->ChannelList
[i
-1].Channel
;
815 MAP_CHANNEL_ID_TO_KHZ(pAdapter
->ChannelList
[i
-1].Channel
, m
);
816 range
->freq
[val
].m
= m
* 100; /* HZ */
818 range
->freq
[val
].e
= 1;
820 if (val
== IW_MAX_FREQUENCIES
)
823 range
->num_frequency
= val
;
825 range
->max_qual
.qual
= 100; /* what is correct max? This was not
826 * documented exactly. At least
827 * 69 has been observed. */
828 range
->max_qual
.level
= 0; /* dB */
829 range
->max_qual
.noise
= 0; /* dB */
831 /* What would be suitable values for "average/typical" qual? */
832 range
->avg_qual
.qual
= 20;
833 range
->avg_qual
.level
= -60;
834 range
->avg_qual
.noise
= -95;
835 range
->sensitivity
= 3;
837 range
->max_encoding_tokens
= NR_WEP_KEYS
;
838 range
->num_encoding_sizes
= 2;
839 range
->encoding_size
[0] = 5;
840 range
->encoding_size
[1] = 13;
843 range
->max_rts
= 2347;
844 range
->min_frag
= 256;
845 range
->max_frag
= 2346;
847 #if WIRELESS_EXT > 17
848 /* IW_ENC_CAPA_* bit field */
849 range
->enc_capa
= IW_ENC_CAPA_WPA
| IW_ENC_CAPA_WPA2
|
850 IW_ENC_CAPA_CIPHER_TKIP
| IW_ENC_CAPA_CIPHER_CCMP
;
856 int rt_ioctl_siwap(struct net_device
*dev
,
857 struct iw_request_info
*info
,
858 struct sockaddr
*ap_addr
, char *extra
)
860 PRTMP_ADAPTER pAdapter
= dev
->ml_priv
;
861 NDIS_802_11_MAC_ADDRESS Bssid
;
863 //check if the interface is down
864 if(!RTMP_TEST_FLAG(pAdapter
, fRTMP_ADAPTER_INTERRUPT_IN_USE
))
866 DBGPRINT(RT_DEBUG_TRACE
, ("INFO::Network is down!\n"));
870 if (pAdapter
->Mlme
.CntlMachine
.CurrState
!= CNTL_IDLE
)
872 RT28XX_MLME_RESET_STATE_MACHINE(pAdapter
);
873 DBGPRINT(RT_DEBUG_TRACE
, ("!!! MLME busy, reset MLME state machine !!!\n"));
876 // tell CNTL state machine to call NdisMSetInformationComplete() after completing
877 // this request, because this request is initiated by NDIS.
878 pAdapter
->MlmeAux
.CurrReqIsFromNdis
= FALSE
;
879 // Prevent to connect AP again in STAMlmePeriodicExec
880 pAdapter
->MlmeAux
.AutoReconnectSsidLen
= 32;
882 memset(Bssid
, 0, MAC_ADDR_LEN
);
883 memcpy(Bssid
, ap_addr
->sa_data
, MAC_ADDR_LEN
);
884 MlmeEnqueue(pAdapter
,
885 MLME_CNTL_STATE_MACHINE
,
887 sizeof(NDIS_802_11_MAC_ADDRESS
),
890 DBGPRINT(RT_DEBUG_TRACE
, ("IOCTL::SIOCSIWAP %02x:%02x:%02x:%02x:%02x:%02x\n",
891 Bssid
[0], Bssid
[1], Bssid
[2], Bssid
[3], Bssid
[4], Bssid
[5]));
896 int rt_ioctl_giwap(struct net_device
*dev
,
897 struct iw_request_info
*info
,
898 struct sockaddr
*ap_addr
, char *extra
)
900 PRTMP_ADAPTER pAdapter
= NULL
;
901 VIRTUAL_ADAPTER
*pVirtualAd
= NULL
;
903 if (dev
->priv_flags
== INT_MAIN
)
905 pAdapter
= dev
->ml_priv
;
909 pVirtualAd
= dev
->ml_priv
;
910 if (pVirtualAd
&& pVirtualAd
->RtmpDev
)
911 pAdapter
= pVirtualAd
->RtmpDev
->ml_priv
;
914 if (pAdapter
== NULL
)
916 /* if 1st open fail, pAd will be free;
917 So the net_dev->ml_priv will be NULL in 2rd open */
921 if (INFRA_ON(pAdapter
) || ADHOC_ON(pAdapter
))
923 ap_addr
->sa_family
= ARPHRD_ETHER
;
924 memcpy(ap_addr
->sa_data
, &pAdapter
->CommonCfg
.Bssid
, ETH_ALEN
);
926 #ifdef WPA_SUPPLICANT_SUPPORT
928 else if (pAdapter
->StaCfg
.WpaSupplicantUP
!= WPA_SUPPLICANT_DISABLE
)
930 ap_addr
->sa_family
= ARPHRD_ETHER
;
931 memcpy(ap_addr
->sa_data
, &pAdapter
->MlmeAux
.Bssid
, ETH_ALEN
);
933 #endif // WPA_SUPPLICANT_SUPPORT //
936 DBGPRINT(RT_DEBUG_TRACE
, ("IOCTL::SIOCGIWAP(=EMPTY)\n"));
944 * Units are in db above the noise floor. That means the
945 * rssi values reported in the tx/rx descriptors in the
946 * driver are the SNR expressed in db.
948 * If you assume that the noise floor is -95, which is an
949 * excellent assumption 99.5 % of the time, then you can
950 * derive the absolute signal level (i.e. -95 + rssi).
951 * There are some other slight factors to take into account
952 * depending on whether the rssi measurement is from 11b,
953 * 11g, or 11a. These differences are at most 2db and
956 * NB: various calculations are based on the orinoco/wavelan
957 * drivers for compatibility
959 static void set_quality(PRTMP_ADAPTER pAdapter
,
960 struct iw_quality
*iq
,
967 ChannelQuality
= 100;
968 else if (rssi
>= -80) // between -50 ~ -80dbm
969 ChannelQuality
= (__u8
)(24 + ((rssi
+ 80) * 26)/10);
970 else if (rssi
>= -90) // between -80 ~ -90dbm
971 ChannelQuality
= (__u8
)((rssi
+ 90) * 26)/10;
975 iq
->qual
= (__u8
)ChannelQuality
;
977 iq
->level
= (__u8
)(rssi
);
978 iq
->noise
= (pAdapter
->BbpWriteLatch
[66] > pAdapter
->BbpTuning
.FalseCcaUpperThreshold
) ? ((__u8
)pAdapter
->BbpTuning
.FalseCcaUpperThreshold
) : ((__u8
) pAdapter
->BbpWriteLatch
[66]); // noise level (dBm)
979 iq
->noise
+= 256 - 143;
980 iq
->updated
= pAdapter
->iw_stats
.qual
.updated
;
983 int rt_ioctl_iwaplist(struct net_device
*dev
,
984 struct iw_request_info
*info
,
985 struct iw_point
*data
, char *extra
)
987 PRTMP_ADAPTER pAdapter
= dev
->ml_priv
;
989 struct sockaddr addr
[IW_MAX_AP
];
990 struct iw_quality qual
[IW_MAX_AP
];
993 //check if the interface is down
994 if(!RTMP_TEST_FLAG(pAdapter
, fRTMP_ADAPTER_INTERRUPT_IN_USE
))
996 DBGPRINT(RT_DEBUG_TRACE
, ("INFO::Network is down!\n"));
1002 for (i
= 0; i
<IW_MAX_AP
; i
++)
1004 if (i
>= pAdapter
->ScanTab
.BssNr
)
1006 addr
[i
].sa_family
= ARPHRD_ETHER
;
1007 memcpy(addr
[i
].sa_data
, &pAdapter
->ScanTab
.BssEntry
[i
].Bssid
, MAC_ADDR_LEN
);
1008 set_quality(pAdapter
, &qual
[i
], pAdapter
->ScanTab
.BssEntry
[i
].Rssi
);
1011 memcpy(extra
, &addr
, i
*sizeof(addr
[0]));
1012 data
->flags
= 1; /* signal quality present (sort of) */
1013 memcpy(extra
+ i
*sizeof(addr
[0]), &qual
, i
*sizeof(qual
[i
]));
1019 int rt_ioctl_siwscan(struct net_device
*dev
,
1020 struct iw_request_info
*info
,
1021 struct iw_point
*data
, char *extra
)
1023 PRTMP_ADAPTER pAdapter
= dev
->ml_priv
;
1026 int Status
= NDIS_STATUS_SUCCESS
;
1028 //check if the interface is down
1029 if(!RTMP_TEST_FLAG(pAdapter
, fRTMP_ADAPTER_INTERRUPT_IN_USE
))
1031 DBGPRINT(RT_DEBUG_TRACE
, ("INFO::Network is down!\n"));
1035 if (MONITOR_ON(pAdapter
))
1037 DBGPRINT(RT_DEBUG_TRACE
, ("!!! Driver is in Monitor Mode now !!!\n"));
1042 #ifdef WPA_SUPPLICANT_SUPPORT
1043 if (pAdapter
->StaCfg
.WpaSupplicantUP
== WPA_SUPPLICANT_ENABLE
)
1045 pAdapter
->StaCfg
.WpaSupplicantScanCount
++;
1047 #endif // WPA_SUPPLICANT_SUPPORT //
1049 pAdapter
->StaCfg
.bScanReqIsFromWebUI
= TRUE
;
1050 if (RTMP_TEST_FLAG(pAdapter
, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS
))
1055 #ifdef WPA_SUPPLICANT_SUPPORT
1056 if ((pAdapter
->StaCfg
.WpaSupplicantUP
== WPA_SUPPLICANT_ENABLE
) &&
1057 (pAdapter
->StaCfg
.WpaSupplicantScanCount
> 3))
1059 DBGPRINT(RT_DEBUG_TRACE
, ("!!! WpaSupplicantScanCount > 3\n"));
1060 Status
= NDIS_STATUS_SUCCESS
;
1063 #endif // WPA_SUPPLICANT_SUPPORT //
1065 if ((OPSTATUS_TEST_FLAG(pAdapter
, fOP_STATUS_MEDIA_STATE_CONNECTED
)) &&
1066 ((pAdapter
->StaCfg
.AuthMode
== Ndis802_11AuthModeWPA
) ||
1067 (pAdapter
->StaCfg
.AuthMode
== Ndis802_11AuthModeWPAPSK
)) &&
1068 (pAdapter
->StaCfg
.PortSecured
== WPA_802_1X_PORT_NOT_SECURED
))
1070 DBGPRINT(RT_DEBUG_TRACE
, ("!!! Link UP, Port Not Secured! ignore this set::OID_802_11_BSSID_LIST_SCAN\n"));
1071 Status
= NDIS_STATUS_SUCCESS
;
1075 if (pAdapter
->Mlme
.CntlMachine
.CurrState
!= CNTL_IDLE
)
1077 RT28XX_MLME_RESET_STATE_MACHINE(pAdapter
);
1078 DBGPRINT(RT_DEBUG_TRACE
, ("!!! MLME busy, reset MLME state machine !!!\n"));
1081 // tell CNTL state machine to call NdisMSetInformationComplete() after completing
1082 // this request, because this request is initiated by NDIS.
1083 pAdapter
->MlmeAux
.CurrReqIsFromNdis
= FALSE
;
1084 // Reset allowed scan retries
1085 pAdapter
->StaCfg
.ScanCnt
= 0;
1086 pAdapter
->StaCfg
.LastScanTime
= Now
;
1088 MlmeEnqueue(pAdapter
,
1089 MLME_CNTL_STATE_MACHINE
,
1090 OID_802_11_BSSID_LIST_SCAN
,
1094 Status
= NDIS_STATUS_SUCCESS
;
1095 RT28XX_MLME_HANDLER(pAdapter
);
1100 int rt_ioctl_giwscan(struct net_device
*dev
,
1101 struct iw_request_info
*info
,
1102 struct iw_point
*data
, char *extra
)
1105 PRTMP_ADAPTER pAdapter
= dev
->ml_priv
;
1107 char *current_ev
= extra
, *previous_ev
= extra
;
1109 char *current_val
, custom
[MAX_CUSTOM_LEN
] = {0};
1112 #endif // IWEVGENIE //
1113 struct iw_event iwe
;
1115 if (RTMP_TEST_FLAG(pAdapter
, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS
))
1118 * Still scanning, indicate the caller should try again.
1124 #ifdef WPA_SUPPLICANT_SUPPORT
1125 if (pAdapter
->StaCfg
.WpaSupplicantUP
== WPA_SUPPLICANT_ENABLE
)
1127 pAdapter
->StaCfg
.WpaSupplicantScanCount
= 0;
1129 #endif // WPA_SUPPLICANT_SUPPORT //
1131 if (pAdapter
->ScanTab
.BssNr
== 0)
1137 #if WIRELESS_EXT >= 17
1138 if (data
->length
> 0)
1139 end_buf
= extra
+ data
->length
;
1141 end_buf
= extra
+ IW_SCAN_MAX_DATA
;
1143 end_buf
= extra
+ IW_SCAN_MAX_DATA
;
1146 for (i
= 0; i
< pAdapter
->ScanTab
.BssNr
; i
++)
1148 if (current_ev
>= end_buf
)
1150 #if WIRELESS_EXT >= 17
1158 //================================
1159 memset(&iwe
, 0, sizeof(iwe
));
1160 iwe
.cmd
= SIOCGIWAP
;
1161 iwe
.u
.ap_addr
.sa_family
= ARPHRD_ETHER
;
1162 memcpy(iwe
.u
.ap_addr
.sa_data
, &pAdapter
->ScanTab
.BssEntry
[i
].Bssid
, ETH_ALEN
);
1164 previous_ev
= current_ev
;
1165 current_ev
= IWE_STREAM_ADD_EVENT(info
, current_ev
,end_buf
, &iwe
, IW_EV_ADDR_LEN
);
1166 if (current_ev
== previous_ev
)
1167 #if WIRELESS_EXT >= 17
1174 //================================
1175 memset(&iwe
, 0, sizeof(iwe
));
1176 iwe
.cmd
= SIOCGIWESSID
;
1177 iwe
.u
.data
.length
= pAdapter
->ScanTab
.BssEntry
[i
].SsidLen
;
1178 iwe
.u
.data
.flags
= 1;
1180 previous_ev
= current_ev
;
1181 current_ev
= IWE_STREAM_ADD_POINT(info
, current_ev
,end_buf
, &iwe
, pAdapter
->ScanTab
.BssEntry
[i
].Ssid
);
1182 if (current_ev
== previous_ev
)
1183 #if WIRELESS_EXT >= 17
1190 //================================
1191 memset(&iwe
, 0, sizeof(iwe
));
1192 iwe
.cmd
= SIOCGIWMODE
;
1193 if (pAdapter
->ScanTab
.BssEntry
[i
].BssType
== Ndis802_11IBSS
)
1195 iwe
.u
.mode
= IW_MODE_ADHOC
;
1197 else if (pAdapter
->ScanTab
.BssEntry
[i
].BssType
== Ndis802_11Infrastructure
)
1199 iwe
.u
.mode
= IW_MODE_INFRA
;
1203 iwe
.u
.mode
= IW_MODE_AUTO
;
1205 iwe
.len
= IW_EV_UINT_LEN
;
1207 previous_ev
= current_ev
;
1208 current_ev
= IWE_STREAM_ADD_EVENT(info
, current_ev
, end_buf
, &iwe
, IW_EV_UINT_LEN
);
1209 if (current_ev
== previous_ev
)
1210 #if WIRELESS_EXT >= 17
1216 //Channel and Frequency
1217 //================================
1218 memset(&iwe
, 0, sizeof(iwe
));
1219 iwe
.cmd
= SIOCGIWFREQ
;
1220 if (INFRA_ON(pAdapter
) || ADHOC_ON(pAdapter
))
1221 iwe
.u
.freq
.m
= pAdapter
->ScanTab
.BssEntry
[i
].Channel
;
1223 iwe
.u
.freq
.m
= pAdapter
->ScanTab
.BssEntry
[i
].Channel
;
1227 previous_ev
= current_ev
;
1228 current_ev
= IWE_STREAM_ADD_EVENT(info
, current_ev
,end_buf
, &iwe
, IW_EV_FREQ_LEN
);
1229 if (current_ev
== previous_ev
)
1230 #if WIRELESS_EXT >= 17
1236 //Add quality statistics
1237 //================================
1238 memset(&iwe
, 0, sizeof(iwe
));
1240 iwe
.u
.qual
.level
= 0;
1241 iwe
.u
.qual
.noise
= 0;
1242 set_quality(pAdapter
, &iwe
.u
.qual
, pAdapter
->ScanTab
.BssEntry
[i
].Rssi
);
1243 current_ev
= IWE_STREAM_ADD_EVENT(info
, current_ev
, end_buf
, &iwe
, IW_EV_QUAL_LEN
);
1244 if (current_ev
== previous_ev
)
1245 #if WIRELESS_EXT >= 17
1252 //================================
1253 memset(&iwe
, 0, sizeof(iwe
));
1254 iwe
.cmd
= SIOCGIWENCODE
;
1255 if (CAP_IS_PRIVACY_ON (pAdapter
->ScanTab
.BssEntry
[i
].CapabilityInfo
))
1256 iwe
.u
.data
.flags
=IW_ENCODE_ENABLED
| IW_ENCODE_NOKEY
;
1258 iwe
.u
.data
.flags
= IW_ENCODE_DISABLED
;
1260 previous_ev
= current_ev
;
1261 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
);
1262 if (current_ev
== previous_ev
)
1263 #if WIRELESS_EXT >= 17
1270 //================================
1271 if (pAdapter
->ScanTab
.BssEntry
[i
].SupRateLen
)
1273 UCHAR tmpRate
= pAdapter
->ScanTab
.BssEntry
[i
].SupRate
[pAdapter
->ScanTab
.BssEntry
[i
].SupRateLen
-1];
1274 memset(&iwe
, 0, sizeof(iwe
));
1275 iwe
.cmd
= SIOCGIWRATE
;
1276 current_val
= current_ev
+ IW_EV_LCP_LEN
;
1277 if (tmpRate
== 0x82)
1278 iwe
.u
.bitrate
.value
= 1 * 1000000;
1279 else if (tmpRate
== 0x84)
1280 iwe
.u
.bitrate
.value
= 2 * 1000000;
1281 else if (tmpRate
== 0x8B)
1282 iwe
.u
.bitrate
.value
= 5.5 * 1000000;
1283 else if (tmpRate
== 0x96)
1284 iwe
.u
.bitrate
.value
= 11 * 1000000;
1286 iwe
.u
.bitrate
.value
= (tmpRate
/2) * 1000000;
1288 iwe
.u
.bitrate
.disabled
= 0;
1289 current_val
= IWE_STREAM_ADD_VALUE(info
, current_ev
,
1290 current_val
, end_buf
, &iwe
,
1293 if((current_val
-current_ev
)>IW_EV_LCP_LEN
)
1294 current_ev
= current_val
;
1296 #if WIRELESS_EXT >= 17
1305 if (pAdapter
->ScanTab
.BssEntry
[i
].WpaIE
.IELen
> 0)
1307 memset(&iwe
, 0, sizeof(iwe
));
1308 memset(&custom
[0], 0, MAX_CUSTOM_LEN
);
1309 memcpy(custom
, &(pAdapter
->ScanTab
.BssEntry
[i
].WpaIE
.IE
[0]),
1310 pAdapter
->ScanTab
.BssEntry
[i
].WpaIE
.IELen
);
1311 iwe
.cmd
= IWEVGENIE
;
1312 iwe
.u
.data
.length
= pAdapter
->ScanTab
.BssEntry
[i
].WpaIE
.IELen
;
1313 current_ev
= IWE_STREAM_ADD_POINT(info
, current_ev
, end_buf
, &iwe
, custom
);
1314 if (current_ev
== previous_ev
)
1315 #if WIRELESS_EXT >= 17
1323 if (pAdapter
->ScanTab
.BssEntry
[i
].RsnIE
.IELen
> 0)
1325 memset(&iwe
, 0, sizeof(iwe
));
1326 memset(&custom
[0], 0, MAX_CUSTOM_LEN
);
1327 memcpy(custom
, &(pAdapter
->ScanTab
.BssEntry
[i
].RsnIE
.IE
[0]),
1328 pAdapter
->ScanTab
.BssEntry
[i
].RsnIE
.IELen
);
1329 iwe
.cmd
= IWEVGENIE
;
1330 iwe
.u
.data
.length
= pAdapter
->ScanTab
.BssEntry
[i
].RsnIE
.IELen
;
1331 current_ev
= IWE_STREAM_ADD_POINT(info
, current_ev
, end_buf
, &iwe
, custom
);
1332 if (current_ev
== previous_ev
)
1333 #if WIRELESS_EXT >= 17
1341 //================================
1342 if (pAdapter
->ScanTab
.BssEntry
[i
].WpaIE
.IELen
> 0)
1344 NdisZeroMemory(&iwe
, sizeof(iwe
));
1345 memset(&custom
[0], 0, MAX_CUSTOM_LEN
);
1346 iwe
.cmd
= IWEVCUSTOM
;
1347 iwe
.u
.data
.length
= (pAdapter
->ScanTab
.BssEntry
[i
].WpaIE
.IELen
* 2) + 7;
1348 NdisMoveMemory(custom
, "wpa_ie=", 7);
1349 for (idx
= 0; idx
< pAdapter
->ScanTab
.BssEntry
[i
].WpaIE
.IELen
; idx
++)
1350 sprintf(custom
, "%s%02x", custom
, pAdapter
->ScanTab
.BssEntry
[i
].WpaIE
.IE
[idx
]);
1351 previous_ev
= current_ev
;
1352 current_ev
= IWE_STREAM_ADD_POINT(info
, current_ev
, end_buf
, &iwe
, custom
);
1353 if (current_ev
== previous_ev
)
1354 #if WIRELESS_EXT >= 17
1362 if (pAdapter
->ScanTab
.BssEntry
[i
].RsnIE
.IELen
> 0)
1364 NdisZeroMemory(&iwe
, sizeof(iwe
));
1365 memset(&custom
[0], 0, MAX_CUSTOM_LEN
);
1366 iwe
.cmd
= IWEVCUSTOM
;
1367 iwe
.u
.data
.length
= (pAdapter
->ScanTab
.BssEntry
[i
].RsnIE
.IELen
* 2) + 7;
1368 NdisMoveMemory(custom
, "rsn_ie=", 7);
1369 for (idx
= 0; idx
< pAdapter
->ScanTab
.BssEntry
[i
].RsnIE
.IELen
; idx
++)
1370 sprintf(custom
, "%s%02x", custom
, pAdapter
->ScanTab
.BssEntry
[i
].RsnIE
.IE
[idx
]);
1371 previous_ev
= current_ev
;
1372 current_ev
= IWE_STREAM_ADD_POINT(info
, current_ev
, end_buf
, &iwe
, custom
);
1373 if (current_ev
== previous_ev
)
1374 #if WIRELESS_EXT >= 17
1380 #endif // IWEVGENIE //
1383 data
->length
= current_ev
- extra
;
1384 pAdapter
->StaCfg
.bScanReqIsFromWebUI
= FALSE
;
1385 DBGPRINT(RT_DEBUG_ERROR
,("===>rt_ioctl_giwscan. %d(%d) BSS returned, data->length = %d\n",i
, pAdapter
->ScanTab
.BssNr
, data
->length
));
1390 int rt_ioctl_siwessid(struct net_device
*dev
,
1391 struct iw_request_info
*info
,
1392 struct iw_point
*data
, char *essid
)
1394 PRTMP_ADAPTER pAdapter
= dev
->ml_priv
;
1396 //check if the interface is down
1397 if(!RTMP_TEST_FLAG(pAdapter
, fRTMP_ADAPTER_INTERRUPT_IN_USE
))
1399 DBGPRINT(RT_DEBUG_TRACE
, ("INFO::Network is down!\n"));
1405 PCHAR pSsidString
= NULL
;
1407 // Includes null character.
1408 if (data
->length
> (IW_ESSID_MAX_SIZE
+ 1))
1411 pSsidString
= (CHAR
*) kmalloc(MAX_LEN_OF_SSID
+1, MEM_ALLOC_FLAG
);
1414 NdisZeroMemory(pSsidString
, MAX_LEN_OF_SSID
+1);
1415 NdisMoveMemory(pSsidString
, essid
, data
->length
);
1416 if (Set_SSID_Proc(pAdapter
, pSsidString
) == FALSE
)
1425 if (Set_SSID_Proc(pAdapter
, "") == FALSE
)
1431 int rt_ioctl_giwessid(struct net_device
*dev
,
1432 struct iw_request_info
*info
,
1433 struct iw_point
*data
, char *essid
)
1435 PRTMP_ADAPTER pAdapter
= NULL
;
1436 VIRTUAL_ADAPTER
*pVirtualAd
= NULL
;
1438 if (dev
->priv_flags
== INT_MAIN
)
1440 pAdapter
= dev
->ml_priv
;
1444 pVirtualAd
= dev
->ml_priv
;
1445 if (pVirtualAd
&& pVirtualAd
->RtmpDev
)
1446 pAdapter
= pVirtualAd
->RtmpDev
->ml_priv
;
1449 if (pAdapter
== NULL
)
1451 /* if 1st open fail, pAd will be free;
1452 So the net_dev->ml_priv will be NULL in 2rd open */
1457 if (MONITOR_ON(pAdapter
))
1463 if (OPSTATUS_TEST_FLAG(pAdapter
, fOP_STATUS_MEDIA_STATE_CONNECTED
))
1465 DBGPRINT(RT_DEBUG_TRACE
,("MediaState is connected\n"));
1466 data
->length
= pAdapter
->CommonCfg
.SsidLen
;
1467 memcpy(essid
, pAdapter
->CommonCfg
.Ssid
, pAdapter
->CommonCfg
.SsidLen
);
1470 {//the ANY ssid was specified
1472 DBGPRINT(RT_DEBUG_TRACE
,("MediaState is not connected, ess\n"));
1479 int rt_ioctl_siwnickn(struct net_device
*dev
,
1480 struct iw_request_info
*info
,
1481 struct iw_point
*data
, char *nickname
)
1483 PRTMP_ADAPTER pAdapter
= dev
->ml_priv
;
1485 //check if the interface is down
1486 if(!RTMP_TEST_FLAG(pAdapter
, fRTMP_ADAPTER_INTERRUPT_IN_USE
))
1488 DBGPRINT(RT_DEBUG_TRACE
,("INFO::Network is down!\n"));
1492 if (data
->length
> IW_ESSID_MAX_SIZE
)
1495 memset(pAdapter
->nickname
, 0, IW_ESSID_MAX_SIZE
+ 1);
1496 memcpy(pAdapter
->nickname
, nickname
, data
->length
);
1502 int rt_ioctl_giwnickn(struct net_device
*dev
,
1503 struct iw_request_info
*info
,
1504 struct iw_point
*data
, char *nickname
)
1506 PRTMP_ADAPTER pAdapter
= NULL
;
1507 VIRTUAL_ADAPTER
*pVirtualAd
= NULL
;
1509 if (dev
->priv_flags
== INT_MAIN
)
1511 pAdapter
= dev
->ml_priv
;
1515 pVirtualAd
= dev
->ml_priv
;
1516 if (pVirtualAd
&& pVirtualAd
->RtmpDev
)
1517 pAdapter
= pVirtualAd
->RtmpDev
->ml_priv
;
1520 if (pAdapter
== NULL
)
1522 /* if 1st open fail, pAd will be free;
1523 So the net_dev->ml_priv will be NULL in 2rd open */
1527 if (data
->length
> strlen(pAdapter
->nickname
) + 1)
1528 data
->length
= strlen(pAdapter
->nickname
) + 1;
1529 if (data
->length
> 0) {
1530 memcpy(nickname
, pAdapter
->nickname
, data
->length
-1);
1531 nickname
[data
->length
-1] = '\0';
1536 int rt_ioctl_siwrts(struct net_device
*dev
,
1537 struct iw_request_info
*info
,
1538 struct iw_param
*rts
, char *extra
)
1540 PRTMP_ADAPTER pAdapter
= dev
->ml_priv
;
1543 //check if the interface is down
1544 if(!RTMP_TEST_FLAG(pAdapter
, fRTMP_ADAPTER_INTERRUPT_IN_USE
))
1546 DBGPRINT(RT_DEBUG_TRACE
, ("INFO::Network is down!\n"));
1551 val
= MAX_RTS_THRESHOLD
;
1552 else if (rts
->value
< 0 || rts
->value
> MAX_RTS_THRESHOLD
)
1554 else if (rts
->value
== 0)
1555 val
= MAX_RTS_THRESHOLD
;
1559 if (val
!= pAdapter
->CommonCfg
.RtsThreshold
)
1560 pAdapter
->CommonCfg
.RtsThreshold
= val
;
1565 int rt_ioctl_giwrts(struct net_device
*dev
,
1566 struct iw_request_info
*info
,
1567 struct iw_param
*rts
, char *extra
)
1569 PRTMP_ADAPTER pAdapter
= NULL
;
1570 VIRTUAL_ADAPTER
*pVirtualAd
= NULL
;
1572 if (dev
->priv_flags
== INT_MAIN
)
1574 pAdapter
= dev
->ml_priv
;
1578 pVirtualAd
= dev
->ml_priv
;
1579 if (pVirtualAd
&& pVirtualAd
->RtmpDev
)
1580 pAdapter
= pVirtualAd
->RtmpDev
->ml_priv
;
1583 if (pAdapter
== NULL
)
1585 /* if 1st open fail, pAd will be free;
1586 So the net_dev->ml_priv will be NULL in 2rd open */
1590 //check if the interface is down
1591 if(!RTMP_TEST_FLAG(pAdapter
, fRTMP_ADAPTER_INTERRUPT_IN_USE
))
1593 DBGPRINT(RT_DEBUG_TRACE
, ("INFO::Network is down!\n"));
1597 rts
->value
= pAdapter
->CommonCfg
.RtsThreshold
;
1598 rts
->disabled
= (rts
->value
== MAX_RTS_THRESHOLD
);
1604 int rt_ioctl_siwfrag(struct net_device
*dev
,
1605 struct iw_request_info
*info
,
1606 struct iw_param
*frag
, char *extra
)
1608 PRTMP_ADAPTER pAdapter
= dev
->ml_priv
;
1611 //check if the interface is down
1612 if(!RTMP_TEST_FLAG(pAdapter
, fRTMP_ADAPTER_INTERRUPT_IN_USE
))
1614 DBGPRINT(RT_DEBUG_TRACE
, ("INFO::Network is down!\n"));
1619 val
= MAX_FRAG_THRESHOLD
;
1620 else if (frag
->value
>= MIN_FRAG_THRESHOLD
|| frag
->value
<= MAX_FRAG_THRESHOLD
)
1621 val
= __cpu_to_le16(frag
->value
& ~0x1); /* even numbers only */
1622 else if (frag
->value
== 0)
1623 val
= MAX_FRAG_THRESHOLD
;
1627 pAdapter
->CommonCfg
.FragmentThreshold
= val
;
1631 int rt_ioctl_giwfrag(struct net_device
*dev
,
1632 struct iw_request_info
*info
,
1633 struct iw_param
*frag
, char *extra
)
1635 PRTMP_ADAPTER pAdapter
= NULL
;
1636 VIRTUAL_ADAPTER
*pVirtualAd
= NULL
;
1638 if (dev
->priv_flags
== INT_MAIN
)
1640 pAdapter
= dev
->ml_priv
;
1644 pVirtualAd
= dev
->ml_priv
;
1645 if (pVirtualAd
&& pVirtualAd
->RtmpDev
)
1646 pAdapter
= pVirtualAd
->RtmpDev
->ml_priv
;
1649 if (pAdapter
== NULL
)
1651 /* if 1st open fail, pAd will be free;
1652 So the net_dev->ml_priv will be NULL in 2rd open */
1656 //check if the interface is down
1657 if(!RTMP_TEST_FLAG(pAdapter
, fRTMP_ADAPTER_INTERRUPT_IN_USE
))
1659 DBGPRINT(RT_DEBUG_TRACE
, ("INFO::Network is down!\n"));
1663 frag
->value
= pAdapter
->CommonCfg
.FragmentThreshold
;
1664 frag
->disabled
= (frag
->value
== MAX_FRAG_THRESHOLD
);
1670 #define MAX_WEP_KEY_SIZE 13
1671 #define MIN_WEP_KEY_SIZE 5
1672 int rt_ioctl_siwencode(struct net_device
*dev
,
1673 struct iw_request_info
*info
,
1674 struct iw_point
*erq
, char *extra
)
1676 PRTMP_ADAPTER pAdapter
= dev
->ml_priv
;
1678 //check if the interface is down
1679 if(!RTMP_TEST_FLAG(pAdapter
, fRTMP_ADAPTER_INTERRUPT_IN_USE
))
1681 DBGPRINT(RT_DEBUG_TRACE
, ("INFO::Network is down!\n"));
1685 if ((erq
->length
== 0) &&
1686 (erq
->flags
& IW_ENCODE_DISABLED
))
1688 pAdapter
->StaCfg
.PairCipher
= Ndis802_11WEPDisabled
;
1689 pAdapter
->StaCfg
.GroupCipher
= Ndis802_11WEPDisabled
;
1690 pAdapter
->StaCfg
.WepStatus
= Ndis802_11WEPDisabled
;
1691 pAdapter
->StaCfg
.OrigWepStatus
= pAdapter
->StaCfg
.WepStatus
;
1692 pAdapter
->StaCfg
.AuthMode
= Ndis802_11AuthModeOpen
;
1695 else if ((erq
->length
== 0) &&
1696 (erq
->flags
& IW_ENCODE_RESTRICTED
|| erq
->flags
& IW_ENCODE_OPEN
))
1698 STA_PORT_SECURED(pAdapter
);
1699 pAdapter
->StaCfg
.PairCipher
= Ndis802_11WEPEnabled
;
1700 pAdapter
->StaCfg
.GroupCipher
= Ndis802_11WEPEnabled
;
1701 pAdapter
->StaCfg
.WepStatus
= Ndis802_11WEPEnabled
;
1702 pAdapter
->StaCfg
.OrigWepStatus
= pAdapter
->StaCfg
.WepStatus
;
1703 if (erq
->flags
& IW_ENCODE_RESTRICTED
)
1704 pAdapter
->StaCfg
.AuthMode
= Ndis802_11AuthModeShared
;
1706 pAdapter
->StaCfg
.AuthMode
= Ndis802_11AuthModeOpen
;
1710 if (erq
->length
> 0)
1712 int keyIdx
= (erq
->flags
& IW_ENCODE_INDEX
) - 1;
1713 /* Check the size of the key */
1714 if (erq
->length
> MAX_WEP_KEY_SIZE
) {
1717 /* Check key index */
1718 if ((keyIdx
< 0) || (keyIdx
>= NR_WEP_KEYS
))
1720 DBGPRINT(RT_DEBUG_TRACE
,("==>rt_ioctl_siwencode::Wrong keyIdx=%d! Using default key instead (%d)\n",
1721 keyIdx
, pAdapter
->StaCfg
.DefaultKeyId
));
1724 keyIdx
= pAdapter
->StaCfg
.DefaultKeyId
;
1727 NdisZeroMemory(pAdapter
->SharedKey
[BSS0
][keyIdx
].Key
, 16);
1729 if (erq
->length
== MAX_WEP_KEY_SIZE
)
1731 pAdapter
->SharedKey
[BSS0
][keyIdx
].KeyLen
= MAX_WEP_KEY_SIZE
;
1732 pAdapter
->SharedKey
[BSS0
][keyIdx
].CipherAlg
= CIPHER_WEP128
;
1734 else if (erq
->length
== MIN_WEP_KEY_SIZE
)
1736 pAdapter
->SharedKey
[BSS0
][keyIdx
].KeyLen
= MIN_WEP_KEY_SIZE
;
1737 pAdapter
->SharedKey
[BSS0
][keyIdx
].CipherAlg
= CIPHER_WEP64
;
1740 /* Disable the key */
1741 pAdapter
->SharedKey
[BSS0
][keyIdx
].KeyLen
= 0;
1743 /* Check if the key is not marked as invalid */
1744 if(!(erq
->flags
& IW_ENCODE_NOKEY
)) {
1745 /* Copy the key in the driver */
1746 NdisMoveMemory(pAdapter
->SharedKey
[BSS0
][keyIdx
].Key
, extra
, erq
->length
);
1751 /* Do we want to just set the transmit key index ? */
1752 int index
= (erq
->flags
& IW_ENCODE_INDEX
) - 1;
1753 if ((index
>= 0) && (index
< 4))
1755 pAdapter
->StaCfg
.DefaultKeyId
= index
;
1758 /* Don't complain if only change the mode */
1759 if(!erq
->flags
& IW_ENCODE_MODE
) {
1765 DBGPRINT(RT_DEBUG_TRACE
,("==>rt_ioctl_siwencode::erq->flags=%x\n",erq
->flags
));
1766 DBGPRINT(RT_DEBUG_TRACE
,("==>rt_ioctl_siwencode::AuthMode=%x\n",pAdapter
->StaCfg
.AuthMode
));
1767 DBGPRINT(RT_DEBUG_TRACE
,("==>rt_ioctl_siwencode::DefaultKeyId=%x, KeyLen = %d\n",pAdapter
->StaCfg
.DefaultKeyId
, pAdapter
->SharedKey
[BSS0
][pAdapter
->StaCfg
.DefaultKeyId
].KeyLen
));
1768 DBGPRINT(RT_DEBUG_TRACE
,("==>rt_ioctl_siwencode::WepStatus=%x\n",pAdapter
->StaCfg
.WepStatus
));
1773 rt_ioctl_giwencode(struct net_device
*dev
,
1774 struct iw_request_info
*info
,
1775 struct iw_point
*erq
, char *key
)
1778 PRTMP_ADAPTER pAdapter
= NULL
;
1779 VIRTUAL_ADAPTER
*pVirtualAd
= NULL
;
1781 if (dev
->priv_flags
== INT_MAIN
)
1783 pAdapter
= dev
->ml_priv
;
1787 pVirtualAd
= dev
->ml_priv
;
1788 if (pVirtualAd
&& pVirtualAd
->RtmpDev
)
1789 pAdapter
= pVirtualAd
->RtmpDev
->ml_priv
;
1792 if (pAdapter
== NULL
)
1794 /* if 1st open fail, pAd will be free;
1795 So the net_dev->ml_priv will be NULL in 2rd open */
1799 //check if the interface is down
1800 if(!RTMP_TEST_FLAG(pAdapter
, fRTMP_ADAPTER_INTERRUPT_IN_USE
))
1802 DBGPRINT(RT_DEBUG_TRACE
, ("INFO::Network is down!\n"));
1806 kid
= erq
->flags
& IW_ENCODE_INDEX
;
1807 DBGPRINT(RT_DEBUG_TRACE
, ("===>rt_ioctl_giwencode %d\n", erq
->flags
& IW_ENCODE_INDEX
));
1809 if (pAdapter
->StaCfg
.WepStatus
== Ndis802_11WEPDisabled
)
1812 erq
->flags
= IW_ENCODE_DISABLED
;
1814 else if ((kid
> 0) && (kid
<=4))
1817 erq
->flags
= kid
; /* NB: base 1 */
1818 if (erq
->length
> pAdapter
->SharedKey
[BSS0
][kid
-1].KeyLen
)
1819 erq
->length
= pAdapter
->SharedKey
[BSS0
][kid
-1].KeyLen
;
1820 memcpy(key
, pAdapter
->SharedKey
[BSS0
][kid
-1].Key
, erq
->length
);
1821 //if ((kid == pAdapter->PortCfg.DefaultKeyId))
1822 //erq->flags |= IW_ENCODE_ENABLED; /* XXX */
1823 if (pAdapter
->StaCfg
.AuthMode
== Ndis802_11AuthModeShared
)
1824 erq
->flags
|= IW_ENCODE_RESTRICTED
; /* XXX */
1826 erq
->flags
|= IW_ENCODE_OPEN
; /* XXX */
1831 if (pAdapter
->StaCfg
.AuthMode
== Ndis802_11AuthModeShared
)
1832 erq
->flags
|= IW_ENCODE_RESTRICTED
; /* XXX */
1834 erq
->flags
|= IW_ENCODE_OPEN
; /* XXX */
1835 erq
->length
= pAdapter
->SharedKey
[BSS0
][pAdapter
->StaCfg
.DefaultKeyId
].KeyLen
;
1836 memcpy(key
, pAdapter
->SharedKey
[BSS0
][pAdapter
->StaCfg
.DefaultKeyId
].Key
, erq
->length
);
1837 // copy default key ID
1838 if (pAdapter
->StaCfg
.AuthMode
== Ndis802_11AuthModeShared
)
1839 erq
->flags
|= IW_ENCODE_RESTRICTED
; /* XXX */
1841 erq
->flags
|= IW_ENCODE_OPEN
; /* XXX */
1842 erq
->flags
= pAdapter
->StaCfg
.DefaultKeyId
+ 1; /* NB: base 1 */
1843 erq
->flags
|= IW_ENCODE_ENABLED
; /* XXX */
1851 rt_ioctl_setparam(struct net_device
*dev
, struct iw_request_info
*info
,
1852 void *w
, char *extra
)
1854 VIRTUAL_ADAPTER
*pVirtualAd
= NULL
;
1855 PRTMP_ADAPTER pAdapter
;
1857 char *this_char
= extra
;
1861 if (dev
->priv_flags
== INT_MAIN
)
1863 pAdapter
= dev
->ml_priv
;
1867 pVirtualAd
= dev
->ml_priv
;
1868 pAdapter
= pVirtualAd
->RtmpDev
->ml_priv
;
1870 pObj
= (POS_COOKIE
) pAdapter
->OS_Cookie
;
1872 if (pAdapter
== NULL
)
1874 /* if 1st open fail, pAd will be free;
1875 So the net_dev->ml_priv will be NULL in 2rd open */
1880 pObj
->ioctl_if_type
= INT_MAIN
;
1881 pObj
->ioctl_if
= MAIN_MBSSID
;
1884 //check if the interface is down
1885 if(!RTMP_TEST_FLAG(pAdapter
, fRTMP_ADAPTER_INTERRUPT_IN_USE
))
1887 DBGPRINT(RT_DEBUG_TRACE
, ("INFO::Network is down!\n"));
1894 if ((value
= rtstrchr(this_char
, '=')) != NULL
)
1900 // reject setting nothing besides ANY ssid(ssidLen=0)
1901 if (!*value
&& (strcmp(this_char
, "SSID") != 0))
1904 for (PRTMP_PRIVATE_SET_PROC
= RTMP_PRIVATE_SUPPORT_PROC
; PRTMP_PRIVATE_SET_PROC
->name
; PRTMP_PRIVATE_SET_PROC
++)
1906 if (strcmp(this_char
, PRTMP_PRIVATE_SET_PROC
->name
) == 0)
1908 if(!PRTMP_PRIVATE_SET_PROC
->set_proc(pAdapter
, value
))
1909 { //FALSE:Set private failed then return Invalid argument
1912 break; //Exit for loop.
1916 if(PRTMP_PRIVATE_SET_PROC
->name
== NULL
)
1917 { //Not found argument
1919 DBGPRINT(RT_DEBUG_TRACE
, ("===>rt_ioctl_setparam:: (iwpriv) Not Support Set Command [%s=%s]\n", this_char
, value
));
1927 rt_private_get_statistics(struct net_device
*dev
, struct iw_request_info
*info
,
1928 struct iw_point
*wrq
, char *extra
)
1931 PRTMP_ADAPTER pAd
= dev
->ml_priv
;
1939 memset(extra
, 0x00, IW_PRIV_SIZE_MASK
);
1940 sprintf(extra
, "\n\n");
1945 sprintf(extra
+strlen(extra
), "Tx success = %ld\n", (ULONG
)pAd
->ate
.TxDoneCount
);
1946 //sprintf(extra+strlen(extra), "Tx success without retry = %ld\n", (ULONG)pAd->ate.TxDoneCount);
1949 #endif // RALINK_ATE //
1951 sprintf(extra
+strlen(extra
), "Tx success = %ld\n", (ULONG
)pAd
->WlanCounters
.TransmittedFragmentCount
.QuadPart
);
1952 sprintf(extra
+strlen(extra
), "Tx success without retry = %ld\n", (ULONG
)pAd
->WlanCounters
.TransmittedFragmentCount
.QuadPart
- (ULONG
)pAd
->WlanCounters
.RetryCount
.QuadPart
);
1954 sprintf(extra
+strlen(extra
), "Tx success after retry = %ld\n", (ULONG
)pAd
->WlanCounters
.RetryCount
.QuadPart
);
1955 sprintf(extra
+strlen(extra
), "Tx fail to Rcv ACK after retry = %ld\n", (ULONG
)pAd
->WlanCounters
.FailedCount
.QuadPart
);
1956 sprintf(extra
+strlen(extra
), "RTS Success Rcv CTS = %ld\n", (ULONG
)pAd
->WlanCounters
.RTSSuccessCount
.QuadPart
);
1957 sprintf(extra
+strlen(extra
), "RTS Fail Rcv CTS = %ld\n", (ULONG
)pAd
->WlanCounters
.RTSFailureCount
.QuadPart
);
1959 sprintf(extra
+strlen(extra
), "Rx success = %ld\n", (ULONG
)pAd
->WlanCounters
.ReceivedFragmentCount
.QuadPart
);
1960 sprintf(extra
+strlen(extra
), "Rx with CRC = %ld\n", (ULONG
)pAd
->WlanCounters
.FCSErrorCount
.QuadPart
);
1961 sprintf(extra
+strlen(extra
), "Rx drop due to out of resource = %ld\n", (ULONG
)pAd
->Counters8023
.RxNoBuffer
);
1962 sprintf(extra
+strlen(extra
), "Rx duplicate frame = %ld\n", (ULONG
)pAd
->WlanCounters
.FrameDuplicateCount
.QuadPart
);
1964 sprintf(extra
+strlen(extra
), "False CCA (one second) = %ld\n", (ULONG
)pAd
->RalinkCounters
.OneSecFalseCCACnt
);
1968 if (pAd
->ate
.RxAntennaSel
== 0)
1970 sprintf(extra
+strlen(extra
), "RSSI-A = %ld\n", (LONG
)(pAd
->ate
.LastRssi0
- pAd
->BbpRssiToDbmDelta
));
1971 sprintf(extra
+strlen(extra
), "RSSI-B (if available) = %ld\n", (LONG
)(pAd
->ate
.LastRssi1
- pAd
->BbpRssiToDbmDelta
));
1972 sprintf(extra
+strlen(extra
), "RSSI-C (if available) = %ld\n\n", (LONG
)(pAd
->ate
.LastRssi2
- pAd
->BbpRssiToDbmDelta
));
1976 sprintf(extra
+strlen(extra
), "RSSI = %ld\n", (LONG
)(pAd
->ate
.LastRssi0
- pAd
->BbpRssiToDbmDelta
));
1980 #endif // RALINK_ATE //
1982 sprintf(extra
+strlen(extra
), "RSSI-A = %ld\n", (LONG
)(pAd
->StaCfg
.RssiSample
.LastRssi0
- pAd
->BbpRssiToDbmDelta
));
1983 sprintf(extra
+strlen(extra
), "RSSI-B (if available) = %ld\n", (LONG
)(pAd
->StaCfg
.RssiSample
.LastRssi1
- pAd
->BbpRssiToDbmDelta
));
1984 sprintf(extra
+strlen(extra
), "RSSI-C (if available) = %ld\n\n", (LONG
)(pAd
->StaCfg
.RssiSample
.LastRssi2
- pAd
->BbpRssiToDbmDelta
));
1986 #ifdef WPA_SUPPLICANT_SUPPORT
1987 sprintf(extra
+strlen(extra
), "WpaSupplicantUP = %d\n\n", pAd
->StaCfg
.WpaSupplicantUP
);
1988 #endif // WPA_SUPPLICANT_SUPPORT //
1991 wrq
->length
= strlen(extra
) + 1; // 1: size of '\0'
1992 DBGPRINT(RT_DEBUG_TRACE
, ("<== rt_private_get_statistics, wrq->length = %d\n", wrq
->length
));
1997 #ifdef DOT11_N_SUPPORT
1999 IN PRTMP_ADAPTER pAd
,
2003 BA_ORI_ENTRY
*pOriBAEntry
;
2004 BA_REC_ENTRY
*pRecBAEntry
;
2006 for (i
=0; i
<MAX_LEN_OF_MAC_TABLE
; i
++)
2008 PMAC_TABLE_ENTRY pEntry
= &pAd
->MacTab
.Content
[i
];
2009 if (((pEntry
->ValidAsCLI
|| pEntry
->ValidAsApCli
) && (pEntry
->Sst
== SST_ASSOC
))
2010 || (pEntry
->ValidAsWDS
) || (pEntry
->ValidAsMesh
))
2012 sprintf(pOutBuf
, "%s\n%02X:%02X:%02X:%02X:%02X:%02X (Aid = %d) (AP) -\n",
2014 pEntry
->Addr
[0], pEntry
->Addr
[1], pEntry
->Addr
[2],
2015 pEntry
->Addr
[3], pEntry
->Addr
[4], pEntry
->Addr
[5], pEntry
->Aid
);
2017 sprintf(pOutBuf
, "%s[Recipient]\n", pOutBuf
);
2018 for (j
=0; j
< NUM_OF_TID
; j
++)
2020 if (pEntry
->BARecWcidArray
[j
] != 0)
2022 pRecBAEntry
=&pAd
->BATable
.BARecEntry
[pEntry
->BARecWcidArray
[j
]];
2023 sprintf(pOutBuf
, "%sTID=%d, BAWinSize=%d, LastIndSeq=%d, ReorderingPkts=%d\n", pOutBuf
, j
, pRecBAEntry
->BAWinSize
, pRecBAEntry
->LastIndSeq
, pRecBAEntry
->list
.qlen
);
2026 sprintf(pOutBuf
, "%s\n", pOutBuf
);
2028 sprintf(pOutBuf
, "%s[Originator]\n", pOutBuf
);
2029 for (j
=0; j
< NUM_OF_TID
; j
++)
2031 if (pEntry
->BAOriWcidArray
[j
] != 0)
2033 pOriBAEntry
=&pAd
->BATable
.BAOriEntry
[pEntry
->BAOriWcidArray
[j
]];
2034 sprintf(pOutBuf
, "%sTID=%d, BAWinSize=%d, StartSeq=%d, CurTxSeq=%d\n", pOutBuf
, j
, pOriBAEntry
->BAWinSize
, pOriBAEntry
->Sequence
, pEntry
->TxSeq
[j
]);
2037 sprintf(pOutBuf
, "%s\n\n", pOutBuf
);
2039 if (strlen(pOutBuf
) > (IW_PRIV_SIZE_MASK
- 30))
2045 #endif // DOT11_N_SUPPORT //
2048 rt_private_show(struct net_device
*dev
, struct iw_request_info
*info
,
2049 struct iw_point
*wrq
, char *extra
)
2052 VIRTUAL_ADAPTER
*pVirtualAd
= NULL
;
2055 u32 subcmd
= wrq
->flags
;
2057 if (dev
->priv_flags
== INT_MAIN
)
2061 pVirtualAd
= dev
->ml_priv
;
2062 pAd
= pVirtualAd
->RtmpDev
->ml_priv
;
2064 pObj
= (POS_COOKIE
) pAd
->OS_Cookie
;
2068 /* if 1st open fail, pAd will be free;
2069 So the net_dev->ml_priv will be NULL in 2rd open */
2078 memset(extra
, 0x00, IW_PRIV_SIZE_MASK
);
2081 pObj
->ioctl_if_type
= INT_MAIN
;
2082 pObj
->ioctl_if
= MAIN_MBSSID
;
2088 case SHOW_CONN_STATUS
:
2089 if (MONITOR_ON(pAd
))
2091 #ifdef DOT11_N_SUPPORT
2092 if (pAd
->CommonCfg
.PhyMode
>= PHY_11ABGN_MIXED
&&
2093 pAd
->CommonCfg
.RegTransmitSetting
.field
.BW
)
2094 sprintf(extra
, "Monitor Mode(CentralChannel %d)\n", pAd
->CommonCfg
.CentralChannel
);
2096 #endif // DOT11_N_SUPPORT //
2097 sprintf(extra
, "Monitor Mode(Channel %d)\n", pAd
->CommonCfg
.Channel
);
2101 if (pAd
->IndicateMediaState
== NdisMediaStateConnected
)
2105 sprintf(extra
, "Connected(AP: %s[%02X:%02X:%02X:%02X:%02X:%02X])\n",
2106 pAd
->CommonCfg
.Ssid
,
2107 pAd
->CommonCfg
.Bssid
[0],
2108 pAd
->CommonCfg
.Bssid
[1],
2109 pAd
->CommonCfg
.Bssid
[2],
2110 pAd
->CommonCfg
.Bssid
[3],
2111 pAd
->CommonCfg
.Bssid
[4],
2112 pAd
->CommonCfg
.Bssid
[5]);
2113 DBGPRINT(RT_DEBUG_TRACE
,("Ssid=%s ,Ssidlen = %d\n",pAd
->CommonCfg
.Ssid
, pAd
->CommonCfg
.SsidLen
));
2115 else if (ADHOC_ON(pAd
))
2116 sprintf(extra
, "Connected\n");
2120 sprintf(extra
, "Disconnected\n");
2121 DBGPRINT(RT_DEBUG_TRACE
,("ConnStatus is not connected\n"));
2124 wrq
->length
= strlen(extra
) + 1; // 1: size of '\0'
2126 case SHOW_DRVIER_VERION
:
2127 sprintf(extra
, "Driver version-%s, %s %s\n", STA_DRIVER_VERSION
, __DATE__
, __TIME__
);
2128 wrq
->length
= strlen(extra
) + 1; // 1: size of '\0'
2130 #ifdef DOT11_N_SUPPORT
2132 getBaInfo(pAd
, extra
);
2133 wrq
->length
= strlen(extra
) + 1; // 1: size of '\0'
2135 #endif // DOT11_N_SUPPORT //
2136 case SHOW_DESC_INFO
:
2138 Show_DescInfo_Proc(pAd
, NULL
);
2139 wrq
->length
= 0; // 1: size of '\0'
2143 if (RTMP_TEST_FLAG(pAd
, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS
))
2145 sprintf(extra
, "Scanning\n");
2146 wrq
->length
= strlen(extra
) + 1; // 1: size of '\0'
2149 pAd
->StaCfg
.bSwRadio
= FALSE
;
2150 if (pAd
->StaCfg
.bRadio
!= (pAd
->StaCfg
.bHwRadio
&& pAd
->StaCfg
.bSwRadio
))
2152 pAd
->StaCfg
.bRadio
= (pAd
->StaCfg
.bHwRadio
&& pAd
->StaCfg
.bSwRadio
);
2153 if (pAd
->StaCfg
.bRadio
== FALSE
)
2156 // Update extra information
2157 pAd
->ExtraInfo
= SW_RADIO_OFF
;
2160 sprintf(extra
, "Radio Off\n");
2161 wrq
->length
= strlen(extra
) + 1; // 1: size of '\0'
2164 if (RTMP_TEST_FLAG(pAd
, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS
))
2166 sprintf(extra
, "Scanning\n");
2167 wrq
->length
= strlen(extra
) + 1; // 1: size of '\0'
2170 pAd
->StaCfg
.bSwRadio
= TRUE
;
2171 //if (pAd->StaCfg.bRadio != (pAd->StaCfg.bHwRadio && pAd->StaCfg.bSwRadio))
2173 pAd
->StaCfg
.bRadio
= (pAd
->StaCfg
.bHwRadio
&& pAd
->StaCfg
.bSwRadio
);
2174 if (pAd
->StaCfg
.bRadio
== TRUE
)
2177 // Update extra information
2178 pAd
->ExtraInfo
= EXTRA_INFO_CLEAR
;
2181 sprintf(extra
, "Radio On\n");
2182 wrq
->length
= strlen(extra
) + 1; // 1: size of '\0'
2186 #ifdef QOS_DLS_SUPPORT
2187 case SHOW_DLS_ENTRY_INFO
:
2189 Set_DlsEntryInfo_Display_Proc(pAd
, NULL
);
2190 wrq
->length
= 0; // 1: size of '\0'
2193 #endif // QOS_DLS_SUPPORT //
2195 case SHOW_CFG_VALUE
:
2197 Status
= RTMPShowCfgValue(pAd
, wrq
->pointer
, extra
);
2199 wrq
->length
= strlen(extra
) + 1; // 1: size of '\0'
2203 DBGPRINT(RT_DEBUG_TRACE
, ("%s - unknow subcmd = %d\n", __func__
, subcmd
));
2211 int rt_ioctl_siwmlme(struct net_device
*dev
,
2212 struct iw_request_info
*info
,
2213 union iwreq_data
*wrqu
,
2216 PRTMP_ADAPTER pAd
= dev
->ml_priv
;
2217 struct iw_mlme
*pMlme
= (struct iw_mlme
*)wrqu
->data
.pointer
;
2218 MLME_QUEUE_ELEM MsgElem
;
2219 MLME_DISASSOC_REQ_STRUCT DisAssocReq
;
2220 MLME_DEAUTH_REQ_STRUCT DeAuthReq
;
2222 DBGPRINT(RT_DEBUG_TRACE
, ("====> %s\n", __func__
));
2229 #ifdef IW_MLME_DEAUTH
2230 case IW_MLME_DEAUTH
:
2231 DBGPRINT(RT_DEBUG_TRACE
, ("====> %s - IW_MLME_DEAUTH\n", __func__
));
2232 COPY_MAC_ADDR(DeAuthReq
.Addr
, pAd
->CommonCfg
.Bssid
);
2233 DeAuthReq
.Reason
= pMlme
->reason_code
;
2234 MsgElem
.MsgLen
= sizeof(MLME_DEAUTH_REQ_STRUCT
);
2235 NdisMoveMemory(MsgElem
.Msg
, &DeAuthReq
, sizeof(MLME_DEAUTH_REQ_STRUCT
));
2236 MlmeDeauthReqAction(pAd
, &MsgElem
);
2239 LinkDown(pAd
, FALSE
);
2240 pAd
->Mlme
.AssocMachine
.CurrState
= ASSOC_IDLE
;
2243 #endif // IW_MLME_DEAUTH //
2244 #ifdef IW_MLME_DISASSOC
2245 case IW_MLME_DISASSOC
:
2246 DBGPRINT(RT_DEBUG_TRACE
, ("====> %s - IW_MLME_DISASSOC\n", __func__
));
2247 COPY_MAC_ADDR(DisAssocReq
.Addr
, pAd
->CommonCfg
.Bssid
);
2248 DisAssocReq
.Reason
= pMlme
->reason_code
;
2250 MsgElem
.Machine
= ASSOC_STATE_MACHINE
;
2251 MsgElem
.MsgType
= MT2_MLME_DISASSOC_REQ
;
2252 MsgElem
.MsgLen
= sizeof(MLME_DISASSOC_REQ_STRUCT
);
2253 NdisMoveMemory(MsgElem
.Msg
, &DisAssocReq
, sizeof(MLME_DISASSOC_REQ_STRUCT
));
2255 pAd
->Mlme
.CntlMachine
.CurrState
= CNTL_WAIT_OID_DISASSOC
;
2256 MlmeDisassocReqAction(pAd
, &MsgElem
);
2258 #endif // IW_MLME_DISASSOC //
2260 DBGPRINT(RT_DEBUG_TRACE
, ("====> %s - Unknow Command\n", __func__
));
2266 #endif // SIOCSIWMLME //
2268 #if WIRELESS_EXT > 17
2269 int rt_ioctl_siwauth(struct net_device
*dev
,
2270 struct iw_request_info
*info
,
2271 union iwreq_data
*wrqu
, char *extra
)
2273 PRTMP_ADAPTER pAdapter
= dev
->ml_priv
;
2274 struct iw_param
*param
= &wrqu
->param
;
2276 //check if the interface is down
2277 if(!RTMP_TEST_FLAG(pAdapter
, fRTMP_ADAPTER_INTERRUPT_IN_USE
))
2279 DBGPRINT(RT_DEBUG_TRACE
, ("INFO::Network is down!\n"));
2282 switch (param
->flags
& IW_AUTH_INDEX
) {
2283 case IW_AUTH_WPA_VERSION
:
2284 if (param
->value
== IW_AUTH_WPA_VERSION_WPA
)
2286 pAdapter
->StaCfg
.AuthMode
= Ndis802_11AuthModeWPAPSK
;
2287 if (pAdapter
->StaCfg
.BssType
== BSS_ADHOC
)
2288 pAdapter
->StaCfg
.AuthMode
= Ndis802_11AuthModeWPANone
;
2290 else if (param
->value
== IW_AUTH_WPA_VERSION_WPA2
)
2291 pAdapter
->StaCfg
.AuthMode
= Ndis802_11AuthModeWPA2PSK
;
2293 DBGPRINT(RT_DEBUG_TRACE
, ("%s::IW_AUTH_WPA_VERSION - param->value = %d!\n", __func__
, param
->value
));
2295 case IW_AUTH_CIPHER_PAIRWISE
:
2296 if (param
->value
== IW_AUTH_CIPHER_NONE
)
2298 pAdapter
->StaCfg
.WepStatus
= Ndis802_11WEPDisabled
;
2299 pAdapter
->StaCfg
.OrigWepStatus
= pAdapter
->StaCfg
.WepStatus
;
2300 pAdapter
->StaCfg
.PairCipher
= Ndis802_11WEPDisabled
;
2302 else if (param
->value
== IW_AUTH_CIPHER_WEP40
||
2303 param
->value
== IW_AUTH_CIPHER_WEP104
)
2305 pAdapter
->StaCfg
.WepStatus
= Ndis802_11WEPEnabled
;
2306 pAdapter
->StaCfg
.OrigWepStatus
= pAdapter
->StaCfg
.WepStatus
;
2307 pAdapter
->StaCfg
.PairCipher
= Ndis802_11WEPEnabled
;
2308 #ifdef WPA_SUPPLICANT_SUPPORT
2309 pAdapter
->StaCfg
.IEEE8021X
= FALSE
;
2310 #endif // WPA_SUPPLICANT_SUPPORT //
2312 else if (param
->value
== IW_AUTH_CIPHER_TKIP
)
2314 pAdapter
->StaCfg
.WepStatus
= Ndis802_11Encryption2Enabled
;
2315 pAdapter
->StaCfg
.OrigWepStatus
= pAdapter
->StaCfg
.WepStatus
;
2316 pAdapter
->StaCfg
.PairCipher
= Ndis802_11Encryption2Enabled
;
2318 else if (param
->value
== IW_AUTH_CIPHER_CCMP
)
2320 pAdapter
->StaCfg
.WepStatus
= Ndis802_11Encryption3Enabled
;
2321 pAdapter
->StaCfg
.OrigWepStatus
= pAdapter
->StaCfg
.WepStatus
;
2322 pAdapter
->StaCfg
.PairCipher
= Ndis802_11Encryption3Enabled
;
2324 DBGPRINT(RT_DEBUG_TRACE
, ("%s::IW_AUTH_CIPHER_PAIRWISE - param->value = %d!\n", __func__
, param
->value
));
2326 case IW_AUTH_CIPHER_GROUP
:
2327 if (param
->value
== IW_AUTH_CIPHER_NONE
)
2329 pAdapter
->StaCfg
.GroupCipher
= Ndis802_11WEPDisabled
;
2331 else if (param
->value
== IW_AUTH_CIPHER_WEP40
||
2332 param
->value
== IW_AUTH_CIPHER_WEP104
)
2334 pAdapter
->StaCfg
.GroupCipher
= Ndis802_11WEPEnabled
;
2336 else if (param
->value
== IW_AUTH_CIPHER_TKIP
)
2338 pAdapter
->StaCfg
.GroupCipher
= Ndis802_11Encryption2Enabled
;
2340 else if (param
->value
== IW_AUTH_CIPHER_CCMP
)
2342 pAdapter
->StaCfg
.GroupCipher
= Ndis802_11Encryption3Enabled
;
2344 DBGPRINT(RT_DEBUG_TRACE
, ("%s::IW_AUTH_CIPHER_GROUP - param->value = %d!\n", __func__
, param
->value
));
2346 case IW_AUTH_KEY_MGMT
:
2347 if (param
->value
== IW_AUTH_KEY_MGMT_802_1X
)
2349 if (pAdapter
->StaCfg
.AuthMode
== Ndis802_11AuthModeWPAPSK
)
2351 pAdapter
->StaCfg
.AuthMode
= Ndis802_11AuthModeWPA
;
2352 #ifdef WPA_SUPPLICANT_SUPPORT
2353 pAdapter
->StaCfg
.IEEE8021X
= FALSE
;
2354 #endif // WPA_SUPPLICANT_SUPPORT //
2356 else if (pAdapter
->StaCfg
.AuthMode
== Ndis802_11AuthModeWPA2PSK
)
2358 pAdapter
->StaCfg
.AuthMode
= Ndis802_11AuthModeWPA2
;
2359 #ifdef WPA_SUPPLICANT_SUPPORT
2360 pAdapter
->StaCfg
.IEEE8021X
= FALSE
;
2361 #endif // WPA_SUPPLICANT_SUPPORT //
2363 #ifdef WPA_SUPPLICANT_SUPPORT
2366 pAdapter
->StaCfg
.IEEE8021X
= TRUE
;
2367 #endif // WPA_SUPPLICANT_SUPPORT //
2369 else if (param
->value
== 0)
2371 STA_PORT_SECURED(pAdapter
);
2373 DBGPRINT(RT_DEBUG_TRACE
, ("%s::IW_AUTH_KEY_MGMT - param->value = %d!\n", __func__
, param
->value
));
2375 case IW_AUTH_RX_UNENCRYPTED_EAPOL
:
2377 case IW_AUTH_PRIVACY_INVOKED
:
2378 DBGPRINT(RT_DEBUG_TRACE
, ("%s::IW_AUTH_PRIVACY_INVOKED - param->value = %d!\n", __func__
, param
->value
));
2380 case IW_AUTH_DROP_UNENCRYPTED
:
2381 if (param
->value
!= 0)
2382 pAdapter
->StaCfg
.PortSecured
= WPA_802_1X_PORT_NOT_SECURED
;
2385 STA_PORT_SECURED(pAdapter
);
2387 DBGPRINT(RT_DEBUG_TRACE
, ("%s::IW_AUTH_WPA_VERSION - param->value = %d!\n", __func__
, param
->value
));
2389 case IW_AUTH_80211_AUTH_ALG
:
2390 if (param
->value
& IW_AUTH_ALG_SHARED_KEY
)
2392 pAdapter
->StaCfg
.AuthMode
= Ndis802_11AuthModeShared
;
2394 else if (param
->value
& IW_AUTH_ALG_OPEN_SYSTEM
)
2396 pAdapter
->StaCfg
.AuthMode
= Ndis802_11AuthModeOpen
;
2400 DBGPRINT(RT_DEBUG_TRACE
, ("%s::IW_AUTH_80211_AUTH_ALG - param->value = %d!\n", __func__
, param
->value
));
2402 case IW_AUTH_WPA_ENABLED
:
2403 DBGPRINT(RT_DEBUG_TRACE
, ("%s::IW_AUTH_WPA_ENABLED - Driver supports WPA!(param->value = %d)\n", __func__
, param
->value
));
2412 int rt_ioctl_giwauth(struct net_device
*dev
,
2413 struct iw_request_info
*info
,
2414 union iwreq_data
*wrqu
, char *extra
)
2416 PRTMP_ADAPTER pAdapter
= dev
->ml_priv
;
2417 struct iw_param
*param
= &wrqu
->param
;
2419 //check if the interface is down
2420 if(!RTMP_TEST_FLAG(pAdapter
, fRTMP_ADAPTER_INTERRUPT_IN_USE
))
2422 DBGPRINT(RT_DEBUG_TRACE
, ("INFO::Network is down!\n"));
2426 switch (param
->flags
& IW_AUTH_INDEX
) {
2427 case IW_AUTH_DROP_UNENCRYPTED
:
2428 param
->value
= (pAdapter
->StaCfg
.WepStatus
== Ndis802_11WEPDisabled
) ? 0 : 1;
2431 case IW_AUTH_80211_AUTH_ALG
:
2432 param
->value
= (pAdapter
->StaCfg
.AuthMode
== Ndis802_11AuthModeShared
) ? IW_AUTH_ALG_SHARED_KEY
: IW_AUTH_ALG_OPEN_SYSTEM
;
2435 case IW_AUTH_WPA_ENABLED
:
2436 param
->value
= (pAdapter
->StaCfg
.AuthMode
>= Ndis802_11AuthModeWPA
) ? 1 : 0;
2442 DBGPRINT(RT_DEBUG_TRACE
, ("rt_ioctl_giwauth::param->value = %d!\n", param
->value
));
2446 void fnSetCipherKey(
2447 IN PRTMP_ADAPTER pAdapter
,
2451 IN
struct iw_encode_ext
*ext
)
2453 NdisZeroMemory(&pAdapter
->SharedKey
[BSS0
][keyIdx
], sizeof(CIPHER_KEY
));
2454 pAdapter
->SharedKey
[BSS0
][keyIdx
].KeyLen
= LEN_TKIP_EK
;
2455 NdisMoveMemory(pAdapter
->SharedKey
[BSS0
][keyIdx
].Key
, ext
->key
, LEN_TKIP_EK
);
2456 NdisMoveMemory(pAdapter
->SharedKey
[BSS0
][keyIdx
].TxMic
, ext
->key
+ LEN_TKIP_EK
, LEN_TKIP_TXMICK
);
2457 NdisMoveMemory(pAdapter
->SharedKey
[BSS0
][keyIdx
].RxMic
, ext
->key
+ LEN_TKIP_EK
+ LEN_TKIP_TXMICK
, LEN_TKIP_RXMICK
);
2458 pAdapter
->SharedKey
[BSS0
][keyIdx
].CipherAlg
= CipherAlg
;
2460 // Update group key information to ASIC Shared Key Table
2461 AsicAddSharedKeyEntry(pAdapter
,
2464 pAdapter
->SharedKey
[BSS0
][keyIdx
].CipherAlg
,
2465 pAdapter
->SharedKey
[BSS0
][keyIdx
].Key
,
2466 pAdapter
->SharedKey
[BSS0
][keyIdx
].TxMic
,
2467 pAdapter
->SharedKey
[BSS0
][keyIdx
].RxMic
);
2470 // Update ASIC WCID attribute table and IVEIV table
2471 RTMPAddWcidAttributeEntry(pAdapter
,
2474 pAdapter
->SharedKey
[BSS0
][keyIdx
].CipherAlg
,
2477 // Update ASIC WCID attribute table and IVEIV table
2478 RTMPAddWcidAttributeEntry(pAdapter
,
2481 pAdapter
->SharedKey
[BSS0
][keyIdx
].CipherAlg
,
2482 &pAdapter
->MacTab
.Content
[BSSID_WCID
]);
2485 int rt_ioctl_siwencodeext(struct net_device
*dev
,
2486 struct iw_request_info
*info
,
2487 union iwreq_data
*wrqu
,
2490 PRTMP_ADAPTER pAdapter
= dev
->ml_priv
;
2491 struct iw_point
*encoding
= &wrqu
->encoding
;
2492 struct iw_encode_ext
*ext
= (struct iw_encode_ext
*)extra
;
2493 int keyIdx
, alg
= ext
->alg
;
2495 //check if the interface is down
2496 if(!RTMP_TEST_FLAG(pAdapter
, fRTMP_ADAPTER_INTERRUPT_IN_USE
))
2498 DBGPRINT(RT_DEBUG_TRACE
, ("INFO::Network is down!\n"));
2502 if (encoding
->flags
& IW_ENCODE_DISABLED
)
2504 keyIdx
= (encoding
->flags
& IW_ENCODE_INDEX
) - 1;
2505 // set BSSID wcid entry of the Pair-wise Key table as no-security mode
2506 AsicRemovePairwiseKeyEntry(pAdapter
, BSS0
, BSSID_WCID
);
2507 pAdapter
->SharedKey
[BSS0
][keyIdx
].KeyLen
= 0;
2508 pAdapter
->SharedKey
[BSS0
][keyIdx
].CipherAlg
= CIPHER_NONE
;
2509 AsicRemoveSharedKeyEntry(pAdapter
, 0, (UCHAR
)keyIdx
);
2510 NdisZeroMemory(&pAdapter
->SharedKey
[BSS0
][keyIdx
], sizeof(CIPHER_KEY
));
2511 DBGPRINT(RT_DEBUG_TRACE
, ("%s::Remove all keys!(encoding->flags = %x)\n", __func__
, encoding
->flags
));
2515 // Get Key Index and convet to our own defined key index
2516 keyIdx
= (encoding
->flags
& IW_ENCODE_INDEX
) - 1;
2517 if((keyIdx
< 0) || (keyIdx
>= NR_WEP_KEYS
))
2520 if (ext
->ext_flags
& IW_ENCODE_EXT_SET_TX_KEY
)
2522 pAdapter
->StaCfg
.DefaultKeyId
= keyIdx
;
2523 DBGPRINT(RT_DEBUG_TRACE
, ("%s::DefaultKeyId = %d\n", __func__
, pAdapter
->StaCfg
.DefaultKeyId
));
2527 case IW_ENCODE_ALG_NONE
:
2528 DBGPRINT(RT_DEBUG_TRACE
, ("%s::IW_ENCODE_ALG_NONE\n", __func__
));
2530 case IW_ENCODE_ALG_WEP
:
2531 DBGPRINT(RT_DEBUG_TRACE
, ("%s::IW_ENCODE_ALG_WEP - ext->key_len = %d, keyIdx = %d\n", __func__
, ext
->key_len
, keyIdx
));
2532 if (ext
->key_len
== MAX_WEP_KEY_SIZE
)
2534 pAdapter
->SharedKey
[BSS0
][keyIdx
].KeyLen
= MAX_WEP_KEY_SIZE
;
2535 pAdapter
->SharedKey
[BSS0
][keyIdx
].CipherAlg
= CIPHER_WEP128
;
2537 else if (ext
->key_len
== MIN_WEP_KEY_SIZE
)
2539 pAdapter
->SharedKey
[BSS0
][keyIdx
].KeyLen
= MIN_WEP_KEY_SIZE
;
2540 pAdapter
->SharedKey
[BSS0
][keyIdx
].CipherAlg
= CIPHER_WEP64
;
2545 NdisZeroMemory(pAdapter
->SharedKey
[BSS0
][keyIdx
].Key
, 16);
2546 NdisMoveMemory(pAdapter
->SharedKey
[BSS0
][keyIdx
].Key
, ext
->key
, ext
->key_len
);
2548 case IW_ENCODE_ALG_TKIP
:
2549 DBGPRINT(RT_DEBUG_TRACE
, ("%s::IW_ENCODE_ALG_TKIP - keyIdx = %d, ext->key_len = %d\n", __func__
, keyIdx
, ext
->key_len
));
2550 if (ext
->key_len
== 32)
2552 if (ext
->ext_flags
& IW_ENCODE_EXT_SET_TX_KEY
)
2554 fnSetCipherKey(pAdapter
, keyIdx
, CIPHER_TKIP
, FALSE
, ext
);
2555 if (pAdapter
->StaCfg
.AuthMode
>= Ndis802_11AuthModeWPA2
)
2557 STA_PORT_SECURED(pAdapter
);
2560 else if (ext
->ext_flags
& IW_ENCODE_EXT_GROUP_KEY
)
2562 fnSetCipherKey(pAdapter
, keyIdx
, CIPHER_TKIP
, TRUE
, ext
);
2564 // set 802.1x port control
2565 STA_PORT_SECURED(pAdapter
);
2571 case IW_ENCODE_ALG_CCMP
:
2572 if (ext
->ext_flags
& IW_ENCODE_EXT_SET_TX_KEY
)
2574 fnSetCipherKey(pAdapter
, keyIdx
, CIPHER_AES
, FALSE
, ext
);
2575 if (pAdapter
->StaCfg
.AuthMode
>= Ndis802_11AuthModeWPA2
)
2576 STA_PORT_SECURED(pAdapter
);
2578 else if (ext
->ext_flags
& IW_ENCODE_EXT_GROUP_KEY
)
2580 fnSetCipherKey(pAdapter
, keyIdx
, CIPHER_AES
, TRUE
, ext
);
2582 // set 802.1x port control
2583 STA_PORT_SECURED(pAdapter
);
2595 rt_ioctl_giwencodeext(struct net_device
*dev
,
2596 struct iw_request_info
*info
,
2597 union iwreq_data
*wrqu
, char *extra
)
2599 PRTMP_ADAPTER pAd
= dev
->ml_priv
;
2601 struct iw_point
*encoding
= &wrqu
->encoding
;
2602 struct iw_encode_ext
*ext
= (struct iw_encode_ext
*)extra
;
2603 int idx
, max_key_len
;
2605 DBGPRINT(RT_DEBUG_TRACE
,("===> rt_ioctl_giwencodeext\n"));
2607 max_key_len
= encoding
->length
- sizeof(*ext
);
2608 if (max_key_len
< 0)
2611 idx
= encoding
->flags
& IW_ENCODE_INDEX
;
2614 if (idx
< 1 || idx
> 4)
2618 if ((pAd
->StaCfg
.WepStatus
== Ndis802_11Encryption2Enabled
) ||
2619 (pAd
->StaCfg
.WepStatus
== Ndis802_11Encryption3Enabled
))
2621 if (idx
!= pAd
->StaCfg
.DefaultKeyId
)
2629 idx
= pAd
->StaCfg
.DefaultKeyId
;
2631 encoding
->flags
= idx
+ 1;
2632 memset(ext
, 0, sizeof(*ext
));
2635 switch(pAd
->StaCfg
.WepStatus
) {
2636 case Ndis802_11WEPDisabled
:
2637 ext
->alg
= IW_ENCODE_ALG_NONE
;
2638 encoding
->flags
|= IW_ENCODE_DISABLED
;
2640 case Ndis802_11WEPEnabled
:
2641 ext
->alg
= IW_ENCODE_ALG_WEP
;
2642 if (pAd
->SharedKey
[BSS0
][idx
].KeyLen
> max_key_len
)
2646 ext
->key_len
= pAd
->SharedKey
[BSS0
][idx
].KeyLen
;
2647 pKey
= &(pAd
->SharedKey
[BSS0
][idx
].Key
[0]);
2650 case Ndis802_11Encryption2Enabled
:
2651 case Ndis802_11Encryption3Enabled
:
2652 if (pAd
->StaCfg
.WepStatus
== Ndis802_11Encryption2Enabled
)
2653 ext
->alg
= IW_ENCODE_ALG_TKIP
;
2655 ext
->alg
= IW_ENCODE_ALG_CCMP
;
2657 if (max_key_len
< 32)
2662 pKey
= &pAd
->StaCfg
.PMK
[0];
2669 if (ext
->key_len
&& pKey
)
2671 encoding
->flags
|= IW_ENCODE_ENABLED
;
2672 memcpy(ext
->key
, pKey
, ext
->key_len
);
2679 int rt_ioctl_siwgenie(struct net_device
*dev
,
2680 struct iw_request_info
*info
,
2681 union iwreq_data
*wrqu
, char *extra
)
2683 PRTMP_ADAPTER pAd
= dev
->ml_priv
;
2685 if (wrqu
->data
.length
> MAX_LEN_OF_RSNIE
||
2686 (wrqu
->data
.length
&& extra
== NULL
))
2689 if (wrqu
->data
.length
)
2691 pAd
->StaCfg
.RSNIE_Len
= wrqu
->data
.length
;
2692 NdisMoveMemory(&pAd
->StaCfg
.RSN_IE
[0], extra
, pAd
->StaCfg
.RSNIE_Len
);
2696 pAd
->StaCfg
.RSNIE_Len
= 0;
2697 NdisZeroMemory(&pAd
->StaCfg
.RSN_IE
[0], MAX_LEN_OF_RSNIE
);
2702 #endif // SIOCSIWGENIE //
2704 int rt_ioctl_giwgenie(struct net_device
*dev
,
2705 struct iw_request_info
*info
,
2706 union iwreq_data
*wrqu
, char *extra
)
2708 PRTMP_ADAPTER pAd
= dev
->ml_priv
;
2710 if ((pAd
->StaCfg
.RSNIE_Len
== 0) ||
2711 (pAd
->StaCfg
.AuthMode
< Ndis802_11AuthModeWPA
))
2713 wrqu
->data
.length
= 0;
2717 #ifdef NATIVE_WPA_SUPPLICANT_SUPPORT
2719 if (pAd
->StaCfg
.WpaSupplicantUP
== WPA_SUPPLICANT_ENABLE
)
2721 if (wrqu
->data
.length
< pAd
->StaCfg
.RSNIE_Len
)
2724 wrqu
->data
.length
= pAd
->StaCfg
.RSNIE_Len
;
2725 memcpy(extra
, &pAd
->StaCfg
.RSN_IE
[0], pAd
->StaCfg
.RSNIE_Len
);
2728 #endif // SIOCSIWGENIE //
2729 #endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
2731 UCHAR RSNIe
= IE_WPA
;
2733 if (wrqu
->data
.length
< (pAd
->StaCfg
.RSNIE_Len
+ 2)) // ID, Len
2735 wrqu
->data
.length
= pAd
->StaCfg
.RSNIE_Len
+ 2;
2737 if ((pAd
->StaCfg
.AuthMode
== Ndis802_11AuthModeWPA2PSK
) ||
2738 (pAd
->StaCfg
.AuthMode
== Ndis802_11AuthModeWPA2
))
2741 extra
[0] = (char)RSNIe
;
2742 extra
[1] = pAd
->StaCfg
.RSNIE_Len
;
2743 memcpy(extra
+2, &pAd
->StaCfg
.RSN_IE
[0], pAd
->StaCfg
.RSNIE_Len
);
2749 int rt_ioctl_siwpmksa(struct net_device
*dev
,
2750 struct iw_request_info
*info
,
2751 union iwreq_data
*wrqu
,
2754 PRTMP_ADAPTER pAd
= dev
->ml_priv
;
2755 struct iw_pmksa
*pPmksa
= (struct iw_pmksa
*)wrqu
->data
.pointer
;
2756 INT CachedIdx
= 0, idx
= 0;
2761 DBGPRINT(RT_DEBUG_TRACE
,("===> rt_ioctl_siwpmksa\n"));
2764 case IW_PMKSA_FLUSH
:
2765 NdisZeroMemory(pAd
->StaCfg
.SavedPMK
, sizeof(BSSID_INFO
)*PMKID_NO
);
2766 DBGPRINT(RT_DEBUG_TRACE
,("rt_ioctl_siwpmksa - IW_PMKSA_FLUSH\n"));
2768 case IW_PMKSA_REMOVE
:
2769 for (CachedIdx
= 0; CachedIdx
< pAd
->StaCfg
.SavedPMKNum
; CachedIdx
++)
2771 // compare the BSSID
2772 if (NdisEqualMemory(pPmksa
->bssid
.sa_data
, pAd
->StaCfg
.SavedPMK
[CachedIdx
].BSSID
, MAC_ADDR_LEN
))
2774 NdisZeroMemory(pAd
->StaCfg
.SavedPMK
[CachedIdx
].BSSID
, MAC_ADDR_LEN
);
2775 NdisZeroMemory(pAd
->StaCfg
.SavedPMK
[CachedIdx
].PMKID
, 16);
2776 for (idx
= CachedIdx
; idx
< (pAd
->StaCfg
.SavedPMKNum
- 1); idx
++)
2778 NdisMoveMemory(&pAd
->StaCfg
.SavedPMK
[idx
].BSSID
[0], &pAd
->StaCfg
.SavedPMK
[idx
+1].BSSID
[0], MAC_ADDR_LEN
);
2779 NdisMoveMemory(&pAd
->StaCfg
.SavedPMK
[idx
].PMKID
[0], &pAd
->StaCfg
.SavedPMK
[idx
+1].PMKID
[0], 16);
2781 pAd
->StaCfg
.SavedPMKNum
--;
2786 DBGPRINT(RT_DEBUG_TRACE
,("rt_ioctl_siwpmksa - IW_PMKSA_REMOVE\n"));
2789 for (CachedIdx
= 0; CachedIdx
< pAd
->StaCfg
.SavedPMKNum
; CachedIdx
++)
2791 // compare the BSSID
2792 if (NdisEqualMemory(pPmksa
->bssid
.sa_data
, pAd
->StaCfg
.SavedPMK
[CachedIdx
].BSSID
, MAC_ADDR_LEN
))
2796 // Found, replace it
2797 if (CachedIdx
< PMKID_NO
)
2799 DBGPRINT(RT_DEBUG_OFF
, ("Update PMKID, idx = %d\n", CachedIdx
));
2800 NdisMoveMemory(&pAd
->StaCfg
.SavedPMK
[CachedIdx
].BSSID
[0], pPmksa
->bssid
.sa_data
, MAC_ADDR_LEN
);
2801 NdisMoveMemory(&pAd
->StaCfg
.SavedPMK
[CachedIdx
].PMKID
[0], pPmksa
->pmkid
, 16);
2802 pAd
->StaCfg
.SavedPMKNum
++;
2804 // Not found, replace the last one
2807 // Randomly replace one
2808 CachedIdx
= (pPmksa
->bssid
.sa_data
[5] % PMKID_NO
);
2809 DBGPRINT(RT_DEBUG_OFF
, ("Update PMKID, idx = %d\n", CachedIdx
));
2810 NdisMoveMemory(&pAd
->StaCfg
.SavedPMK
[CachedIdx
].BSSID
[0], pPmksa
->bssid
.sa_data
, MAC_ADDR_LEN
);
2811 NdisMoveMemory(&pAd
->StaCfg
.SavedPMK
[CachedIdx
].PMKID
[0], pPmksa
->pmkid
, 16);
2814 DBGPRINT(RT_DEBUG_TRACE
,("rt_ioctl_siwpmksa - IW_PMKSA_ADD\n"));
2817 DBGPRINT(RT_DEBUG_TRACE
,("rt_ioctl_siwpmksa - Unknow Command!!\n"));
2823 #endif // #if WIRELESS_EXT > 17
2827 rt_private_ioctl_bbp(struct net_device
*dev
, struct iw_request_info
*info
,
2828 struct iw_point
*wrq
, char *extra
)
2835 BOOLEAN bIsPrintAllBBP
= FALSE
;
2837 PRTMP_ADAPTER pAdapter
= dev
->ml_priv
;
2840 memset(extra
, 0x00, IW_PRIV_SIZE_MASK
);
2842 if (wrq
->length
> 1) //No parameters.
2844 sprintf(extra
, "\n");
2846 //Parsing Read or Write
2847 this_char
= wrq
->pointer
;
2848 DBGPRINT(RT_DEBUG_TRACE
, ("this_char=%s\n", this_char
));
2852 if ((value
= rtstrchr(this_char
, '=')) != NULL
)
2855 if (!value
|| !*value
)
2857 DBGPRINT(RT_DEBUG_TRACE
, ("this_char=%s, value=%s\n", this_char
, value
));
2858 if (sscanf(this_char
, "%d", &(bbpId
)) == 1)
2863 if (ATE_ON(pAdapter
))
2865 ATE_BBP_IO_READ8_BY_REG_ID(pAdapter
, bbpId
, ®BBP
);
2868 #endif // RALINK_ATE //
2870 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter
, bbpId
, ®BBP
);
2872 sprintf(extra
+strlen(extra
), "R%02d[0x%02X]:%02X\n", bbpId
, bbpId
*2, regBBP
);
2873 wrq
->length
= strlen(extra
) + 1; // 1: size of '\0'
2874 DBGPRINT(RT_DEBUG_TRACE
, ("msg=%s\n", extra
));
2877 {//Invalid parametes, so default printk all bbp
2878 bIsPrintAllBBP
= TRUE
;
2883 { //Invalid parametes, so default printk all bbp
2884 bIsPrintAllBBP
= TRUE
;
2890 if ((sscanf(this_char
, "%d", &(bbpId
)) == 1) && (sscanf(value
, "%x", &(bbpValue
)) == 1))
2895 if (ATE_ON(pAdapter
))
2897 ATE_BBP_IO_WRITE8_BY_REG_ID(pAdapter
, bbpId
, bbpValue
);
2898 //Read it back for showing
2899 ATE_BBP_IO_READ8_BY_REG_ID(pAdapter
, bbpId
, ®BBP
);
2902 #endif // RALINK_ATE //
2904 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter
, bbpId
, bbpValue
);
2905 //Read it back for showing
2906 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter
, bbpId
, ®BBP
);
2908 sprintf(extra
+strlen(extra
), "R%02d[0x%02X]:%02X\n", bbpId
, bbpId
*2, regBBP
);
2909 wrq
->length
= strlen(extra
) + 1; // 1: size of '\0'
2910 DBGPRINT(RT_DEBUG_TRACE
, ("msg=%s\n", extra
));
2913 {//Invalid parametes, so default printk all bbp
2914 bIsPrintAllBBP
= TRUE
;
2919 { //Invalid parametes, so default printk all bbp
2920 bIsPrintAllBBP
= TRUE
;
2926 bIsPrintAllBBP
= TRUE
;
2931 memset(extra
, 0x00, IW_PRIV_SIZE_MASK
);
2932 sprintf(extra
, "\n");
2933 for (bbpId
= 0; bbpId
<= 136; bbpId
++)
2935 if (strlen(extra
) >= (IW_PRIV_SIZE_MASK
- 10))
2938 if (ATE_ON(pAdapter
))
2940 ATE_BBP_IO_READ8_BY_REG_ID(pAdapter
, bbpId
, ®BBP
);
2943 #endif // RALINK_ATE //
2944 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter
, bbpId
, ®BBP
);
2945 sprintf(extra
+strlen(extra
), "R%02d[0x%02X]:%02X ", bbpId
, bbpId
*2, regBBP
);
2947 sprintf(extra
+strlen(extra
), "\n");
2950 wrq
->length
= strlen(extra
) + 1; // 1: size of '\0'
2951 DBGPRINT(RT_DEBUG_TRACE
, ("wrq->length = %d\n", wrq
->length
));
2954 DBGPRINT(RT_DEBUG_TRACE
, ("<==rt_private_ioctl_bbp\n\n"));
2960 int rt_ioctl_siwrate(struct net_device
*dev
,
2961 struct iw_request_info
*info
,
2962 union iwreq_data
*wrqu
, char *extra
)
2964 PRTMP_ADAPTER pAd
= dev
->ml_priv
;
2965 UINT32 rate
= wrqu
->bitrate
.value
, fixed
= wrqu
->bitrate
.fixed
;
2967 //check if the interface is down
2968 if(!RTMP_TEST_FLAG(pAd
, fRTMP_ADAPTER_INTERRUPT_IN_USE
))
2970 DBGPRINT(RT_DEBUG_TRACE
, ("rt_ioctl_siwrate::Network is down!\n"));
2974 DBGPRINT(RT_DEBUG_TRACE
, ("rt_ioctl_siwrate::(rate = %d, fixed = %d)\n", rate
, fixed
));
2975 /* rate = -1 => auto rate
2976 rate = X, fixed = 1 => (fixed rate X)
2981 pAd
->StaCfg
.DesiredTransmitSetting
.field
.MCS
= MCS_AUTO
;
2982 pAd
->StaCfg
.bAutoTxRateSwitch
= TRUE
;
2983 if ((pAd
->CommonCfg
.PhyMode
<= PHY_11G
) ||
2984 (pAd
->MacTab
.Content
[BSSID_WCID
].HTPhyMode
.field
.MODE
<= MODE_OFDM
))
2985 RTMPSetDesiredRates(pAd
, -1);
2987 #ifdef DOT11_N_SUPPORT
2989 #endif // DOT11_N_SUPPORT //
2995 pAd
->StaCfg
.bAutoTxRateSwitch
= FALSE
;
2996 if ((pAd
->CommonCfg
.PhyMode
<= PHY_11G
) ||
2997 (pAd
->MacTab
.Content
[BSSID_WCID
].HTPhyMode
.field
.MODE
<= MODE_OFDM
))
2998 RTMPSetDesiredRates(pAd
, rate
);
3001 pAd
->StaCfg
.DesiredTransmitSetting
.field
.MCS
= MCS_AUTO
;
3002 #ifdef DOT11_N_SUPPORT
3004 #endif // DOT11_N_SUPPORT //
3006 DBGPRINT(RT_DEBUG_TRACE
, ("rt_ioctl_siwrate::(HtMcs=%d)\n",pAd
->StaCfg
.DesiredTransmitSetting
.field
.MCS
));
3010 // TODO: rate = X, fixed = 0 => (rates <= X)
3018 int rt_ioctl_giwrate(struct net_device
*dev
,
3019 struct iw_request_info
*info
,
3020 union iwreq_data
*wrqu
, char *extra
)
3022 PRTMP_ADAPTER pAd
= dev
->ml_priv
;
3023 int rate_index
= 0, rate_count
= 0;
3024 HTTRANSMIT_SETTING ht_setting
;
3025 __s32 ralinkrate
[] =
3026 {2, 4, 11, 22, // CCK
3027 12, 18, 24, 36, 48, 72, 96, 108, // OFDM
3028 13, 26, 39, 52, 78, 104, 117, 130, 26, 52, 78, 104, 156, 208, 234, 260, // 20MHz, 800ns GI, MCS: 0 ~ 15
3029 39, 78, 117, 156, 234, 312, 351, 390, // 20MHz, 800ns GI, MCS: 16 ~ 23
3030 27, 54, 81, 108, 162, 216, 243, 270, 54, 108, 162, 216, 324, 432, 486, 540, // 40MHz, 800ns GI, MCS: 0 ~ 15
3031 81, 162, 243, 324, 486, 648, 729, 810, // 40MHz, 800ns GI, MCS: 16 ~ 23
3032 14, 29, 43, 57, 87, 115, 130, 144, 29, 59, 87, 115, 173, 230, 260, 288, // 20MHz, 400ns GI, MCS: 0 ~ 15
3033 43, 87, 130, 173, 260, 317, 390, 433, // 20MHz, 400ns GI, MCS: 16 ~ 23
3034 30, 60, 90, 120, 180, 240, 270, 300, 60, 120, 180, 240, 360, 480, 540, 600, // 40MHz, 400ns GI, MCS: 0 ~ 15
3035 90, 180, 270, 360, 540, 720, 810, 900}; // 40MHz, 400ns GI, MCS: 16 ~ 23
3037 rate_count
= sizeof(ralinkrate
)/sizeof(__s32
);
3038 //check if the interface is down
3039 if(!RTMP_TEST_FLAG(pAd
, fRTMP_ADAPTER_INTERRUPT_IN_USE
))
3041 DBGPRINT(RT_DEBUG_TRACE
, ("INFO::Network is down!\n"));
3045 if ((pAd
->StaCfg
.bAutoTxRateSwitch
== FALSE
) &&
3047 ((pAd
->CommonCfg
.PhyMode
<= PHY_11G
) || (pAd
->MacTab
.Content
[BSSID_WCID
].HTPhyMode
.field
.MODE
<= MODE_OFDM
)))
3048 ht_setting
.word
= pAd
->StaCfg
.HTPhyMode
.word
;
3050 ht_setting
.word
= pAd
->MacTab
.Content
[BSSID_WCID
].HTPhyMode
.word
;
3052 #ifdef DOT11_N_SUPPORT
3053 if (ht_setting
.field
.MODE
>= MODE_HTMIX
)
3055 rate_index
= 12 + ((UCHAR
)ht_setting
.field
.BW
*24) + ((UCHAR
)ht_setting
.field
.ShortGI
*48) + ((UCHAR
)ht_setting
.field
.MCS
);
3058 #endif // DOT11_N_SUPPORT //
3059 if (ht_setting
.field
.MODE
== MODE_OFDM
)
3060 rate_index
= (UCHAR
)(ht_setting
.field
.MCS
) + 4;
3061 else if (ht_setting
.field
.MODE
== MODE_CCK
)
3062 rate_index
= (UCHAR
)(ht_setting
.field
.MCS
);
3067 if (rate_index
> rate_count
)
3068 rate_index
= rate_count
;
3070 wrqu
->bitrate
.value
= ralinkrate
[rate_index
] * 500000;
3071 wrqu
->bitrate
.disabled
= 0;
3076 static const iw_handler rt_handler
[] =
3078 (iw_handler
) NULL
, /* SIOCSIWCOMMIT */
3079 (iw_handler
) rt_ioctl_giwname
, /* SIOCGIWNAME */
3080 (iw_handler
) NULL
, /* SIOCSIWNWID */
3081 (iw_handler
) NULL
, /* SIOCGIWNWID */
3082 (iw_handler
) rt_ioctl_siwfreq
, /* SIOCSIWFREQ */
3083 (iw_handler
) rt_ioctl_giwfreq
, /* SIOCGIWFREQ */
3084 (iw_handler
) rt_ioctl_siwmode
, /* SIOCSIWMODE */
3085 (iw_handler
) rt_ioctl_giwmode
, /* SIOCGIWMODE */
3086 (iw_handler
) NULL
, /* SIOCSIWSENS */
3087 (iw_handler
) NULL
, /* SIOCGIWSENS */
3088 (iw_handler
) NULL
/* not used */, /* SIOCSIWRANGE */
3089 (iw_handler
) rt_ioctl_giwrange
, /* SIOCGIWRANGE */
3090 (iw_handler
) NULL
/* not used */, /* SIOCSIWPRIV */
3091 (iw_handler
) NULL
/* kernel code */, /* SIOCGIWPRIV */
3092 (iw_handler
) NULL
/* not used */, /* SIOCSIWSTATS */
3093 (iw_handler
) rt28xx_get_wireless_stats
/* kernel code */, /* SIOCGIWSTATS */
3094 (iw_handler
) NULL
, /* SIOCSIWSPY */
3095 (iw_handler
) NULL
, /* SIOCGIWSPY */
3096 (iw_handler
) NULL
, /* SIOCSIWTHRSPY */
3097 (iw_handler
) NULL
, /* SIOCGIWTHRSPY */
3098 (iw_handler
) rt_ioctl_siwap
, /* SIOCSIWAP */
3099 (iw_handler
) rt_ioctl_giwap
, /* SIOCGIWAP */
3101 (iw_handler
) rt_ioctl_siwmlme
, /* SIOCSIWMLME */
3103 (iw_handler
) NULL
, /* SIOCSIWMLME */
3104 #endif // SIOCSIWMLME //
3105 (iw_handler
) rt_ioctl_iwaplist
, /* SIOCGIWAPLIST */
3107 (iw_handler
) rt_ioctl_siwscan
, /* SIOCSIWSCAN */
3108 (iw_handler
) rt_ioctl_giwscan
, /* SIOCGIWSCAN */
3110 (iw_handler
) NULL
, /* SIOCSIWSCAN */
3111 (iw_handler
) NULL
, /* SIOCGIWSCAN */
3112 #endif /* SIOCGIWSCAN */
3113 (iw_handler
) rt_ioctl_siwessid
, /* SIOCSIWESSID */
3114 (iw_handler
) rt_ioctl_giwessid
, /* SIOCGIWESSID */
3115 (iw_handler
) rt_ioctl_siwnickn
, /* SIOCSIWNICKN */
3116 (iw_handler
) rt_ioctl_giwnickn
, /* SIOCGIWNICKN */
3117 (iw_handler
) NULL
, /* -- hole -- */
3118 (iw_handler
) NULL
, /* -- hole -- */
3119 (iw_handler
) rt_ioctl_siwrate
, /* SIOCSIWRATE */
3120 (iw_handler
) rt_ioctl_giwrate
, /* SIOCGIWRATE */
3121 (iw_handler
) rt_ioctl_siwrts
, /* SIOCSIWRTS */
3122 (iw_handler
) rt_ioctl_giwrts
, /* SIOCGIWRTS */
3123 (iw_handler
) rt_ioctl_siwfrag
, /* SIOCSIWFRAG */
3124 (iw_handler
) rt_ioctl_giwfrag
, /* SIOCGIWFRAG */
3125 (iw_handler
) NULL
, /* SIOCSIWTXPOW */
3126 (iw_handler
) NULL
, /* SIOCGIWTXPOW */
3127 (iw_handler
) NULL
, /* SIOCSIWRETRY */
3128 (iw_handler
) NULL
, /* SIOCGIWRETRY */
3129 (iw_handler
) rt_ioctl_siwencode
, /* SIOCSIWENCODE */
3130 (iw_handler
) rt_ioctl_giwencode
, /* SIOCGIWENCODE */
3131 (iw_handler
) NULL
, /* SIOCSIWPOWER */
3132 (iw_handler
) NULL
, /* SIOCGIWPOWER */
3133 (iw_handler
) NULL
, /* -- hole -- */
3134 (iw_handler
) NULL
, /* -- hole -- */
3135 #if WIRELESS_EXT > 17
3136 (iw_handler
) rt_ioctl_siwgenie
, /* SIOCSIWGENIE */
3137 (iw_handler
) rt_ioctl_giwgenie
, /* SIOCGIWGENIE */
3138 (iw_handler
) rt_ioctl_siwauth
, /* SIOCSIWAUTH */
3139 (iw_handler
) rt_ioctl_giwauth
, /* SIOCGIWAUTH */
3140 (iw_handler
) rt_ioctl_siwencodeext
, /* SIOCSIWENCODEEXT */
3141 (iw_handler
) rt_ioctl_giwencodeext
, /* SIOCGIWENCODEEXT */
3142 (iw_handler
) rt_ioctl_siwpmksa
, /* SIOCSIWPMKSA */
3146 static const iw_handler rt_priv_handlers
[] = {
3147 (iw_handler
) NULL
, /* + 0x00 */
3148 (iw_handler
) NULL
, /* + 0x01 */
3149 #ifndef CONFIG_AP_SUPPORT
3150 (iw_handler
) rt_ioctl_setparam
, /* + 0x02 */
3152 (iw_handler
) NULL
, /* + 0x02 */
3153 #endif // CONFIG_AP_SUPPORT //
3155 (iw_handler
) rt_private_ioctl_bbp
, /* + 0x03 */
3157 (iw_handler
) NULL
, /* + 0x03 */
3159 (iw_handler
) NULL
, /* + 0x04 */
3160 (iw_handler
) NULL
, /* + 0x05 */
3161 (iw_handler
) NULL
, /* + 0x06 */
3162 (iw_handler
) NULL
, /* + 0x07 */
3163 (iw_handler
) NULL
, /* + 0x08 */
3164 (iw_handler
) rt_private_get_statistics
, /* + 0x09 */
3165 (iw_handler
) NULL
, /* + 0x0A */
3166 (iw_handler
) NULL
, /* + 0x0B */
3167 (iw_handler
) NULL
, /* + 0x0C */
3168 (iw_handler
) NULL
, /* + 0x0D */
3169 (iw_handler
) NULL
, /* + 0x0E */
3170 (iw_handler
) NULL
, /* + 0x0F */
3171 (iw_handler
) NULL
, /* + 0x10 */
3172 (iw_handler
) rt_private_show
, /* + 0x11 */
3173 (iw_handler
) NULL
, /* + 0x12 */
3174 (iw_handler
) NULL
, /* + 0x13 */
3175 (iw_handler
) NULL
, /* + 0x15 */
3176 (iw_handler
) NULL
, /* + 0x17 */
3177 (iw_handler
) NULL
, /* + 0x18 */
3180 const struct iw_handler_def rt28xx_iw_handler_def
=
3182 #define N(a) (sizeof (a) / sizeof (a[0]))
3183 .standard
= (iw_handler
*) rt_handler
,
3184 .num_standard
= sizeof(rt_handler
) / sizeof(iw_handler
),
3185 .private = (iw_handler
*) rt_priv_handlers
,
3186 .num_private
= N(rt_priv_handlers
),
3187 .private_args
= (struct iw_priv_args
*) privtab
,
3188 .num_private_args
= N(privtab
),
3189 #if IW_HANDLER_VERSION >= 7
3190 .get_wireless_stats
= rt28xx_get_wireless_stats
,
3194 INT
RTMPSetInformation(
3195 IN PRTMP_ADAPTER pAdapter
,
3196 IN OUT
struct ifreq
*rq
,
3199 struct iwreq
*wrq
= (struct iwreq
*) rq
;
3200 NDIS_802_11_SSID Ssid
;
3201 NDIS_802_11_MAC_ADDRESS Bssid
;
3202 RT_802_11_PHY_MODE PhyMode
;
3203 RT_802_11_STA_CONFIG StaConfig
;
3204 NDIS_802_11_RATES aryRates
;
3205 RT_802_11_PREAMBLE Preamble
;
3206 NDIS_802_11_WEP_STATUS WepStatus
;
3207 NDIS_802_11_AUTHENTICATION_MODE AuthMode
= Ndis802_11AuthModeMax
;
3208 NDIS_802_11_NETWORK_INFRASTRUCTURE BssType
;
3209 NDIS_802_11_RTS_THRESHOLD RtsThresh
;
3210 NDIS_802_11_FRAGMENTATION_THRESHOLD FragThresh
;
3211 NDIS_802_11_POWER_MODE PowerMode
;
3212 PNDIS_802_11_KEY pKey
= NULL
;
3213 PNDIS_802_11_WEP pWepKey
=NULL
;
3214 PNDIS_802_11_REMOVE_KEY pRemoveKey
= NULL
;
3215 NDIS_802_11_CONFIGURATION Config
, *pConfig
= NULL
;
3216 NDIS_802_11_NETWORK_TYPE NetType
;
3219 INT Status
= NDIS_STATUS_SUCCESS
, MaxPhyMode
= PHY_11G
;
3222 BOOLEAN StateMachineTouched
= FALSE
;
3223 #ifdef DOT11_N_SUPPORT
3224 OID_SET_HT_PHYMODE HT_PhyMode
; //11n ,kathy
3225 #endif // DOT11_N_SUPPORT //
3226 #ifdef WPA_SUPPLICANT_SUPPORT
3227 PNDIS_802_11_PMKID pPmkId
= NULL
;
3228 BOOLEAN IEEE8021xState
= FALSE
;
3229 BOOLEAN IEEE8021x_required_keys
= FALSE
;
3230 UCHAR wpa_supplicant_enable
= 0;
3231 #endif // WPA_SUPPLICANT_SUPPORT //
3234 TX_RTY_CFG_STRUC tx_rty_cfg
;
3235 ULONG ShortRetryLimit
, LongRetryLimit
;
3237 #endif // SNMP_SUPPORT //
3240 #ifdef DOT11_N_SUPPORT
3241 MaxPhyMode
= PHY_11N_5G
;
3242 #endif // DOT11_N_SUPPORT //
3245 DBGPRINT(RT_DEBUG_TRACE
, ("-->RTMPSetInformation(), 0x%08x\n", cmd
&0x7FFF));
3246 switch(cmd
& 0x7FFF) {
3247 case RT_OID_802_11_COUNTRY_REGION
:
3248 if (wrq
->u
.data
.length
< sizeof(UCHAR
))
3250 // Only avaliable when EEPROM not programming
3251 else if (!(pAdapter
->CommonCfg
.CountryRegion
& 0x80) && !(pAdapter
->CommonCfg
.CountryRegionForABand
& 0x80))
3256 Status
= copy_from_user(&Country
, wrq
->u
.data
.pointer
, wrq
->u
.data
.length
);
3257 pAdapter
->CommonCfg
.CountryRegion
= (UCHAR
)(Country
& 0x000000FF);
3258 pAdapter
->CommonCfg
.CountryRegionForABand
= (UCHAR
)((Country
>> 8) & 0x000000FF);
3259 TmpPhy
= pAdapter
->CommonCfg
.PhyMode
;
3260 pAdapter
->CommonCfg
.PhyMode
= 0xff;
3261 // Build all corresponding channel information
3262 RTMPSetPhyMode(pAdapter
, TmpPhy
);
3263 #ifdef DOT11_N_SUPPORT
3264 SetCommonHT(pAdapter
);
3265 #endif // DOT11_N_SUPPORT //
3266 DBGPRINT(RT_DEBUG_TRACE
, ("Set::RT_OID_802_11_COUNTRY_REGION (A:%d B/G:%d)\n", pAdapter
->CommonCfg
.CountryRegionForABand
,
3267 pAdapter
->CommonCfg
.CountryRegion
));
3270 case OID_802_11_BSSID_LIST_SCAN
:
3272 if (ATE_ON(pAdapter
))
3274 DBGPRINT(RT_DEBUG_TRACE
, ("The driver is in ATE mode now\n"));
3277 #endif // RALINK_ATE //
3279 DBGPRINT(RT_DEBUG_TRACE
, ("Set::OID_802_11_BSSID_LIST_SCAN, TxCnt = %d \n", pAdapter
->RalinkCounters
.LastOneSecTotalTxCount
));
3281 if (MONITOR_ON(pAdapter
))
3283 DBGPRINT(RT_DEBUG_TRACE
, ("!!! Driver is in Monitor Mode now !!!\n"));
3287 //Benson add 20080527, when radio off, sta don't need to scan
3288 if (RTMP_TEST_FLAG(pAdapter
, fRTMP_ADAPTER_RADIO_OFF
))
3291 if (RTMP_TEST_FLAG(pAdapter
, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS
))
3293 DBGPRINT(RT_DEBUG_TRACE
, ("!!! Driver is scanning now !!!\n"));
3294 pAdapter
->StaCfg
.bScanReqIsFromWebUI
= TRUE
;
3295 Status
= NDIS_STATUS_SUCCESS
;
3299 if (pAdapter
->RalinkCounters
.LastOneSecTotalTxCount
> 100)
3301 DBGPRINT(RT_DEBUG_TRACE
, ("!!! Link UP, ignore this set::OID_802_11_BSSID_LIST_SCAN\n"));
3302 Status
= NDIS_STATUS_SUCCESS
;
3303 pAdapter
->StaCfg
.ScanCnt
= 99; // Prevent auto scan triggered by this OID
3307 if ((OPSTATUS_TEST_FLAG(pAdapter
, fOP_STATUS_MEDIA_STATE_CONNECTED
)) &&
3308 ((pAdapter
->StaCfg
.AuthMode
== Ndis802_11AuthModeWPA
) ||
3309 (pAdapter
->StaCfg
.AuthMode
== Ndis802_11AuthModeWPAPSK
) ||
3310 (pAdapter
->StaCfg
.AuthMode
== Ndis802_11AuthModeWPA2
) ||
3311 (pAdapter
->StaCfg
.AuthMode
== Ndis802_11AuthModeWPA2PSK
)) &&
3312 (pAdapter
->StaCfg
.PortSecured
== WPA_802_1X_PORT_NOT_SECURED
))
3314 DBGPRINT(RT_DEBUG_TRACE
, ("!!! Link UP, Port Not Secured! ignore this set::OID_802_11_BSSID_LIST_SCAN\n"));
3315 Status
= NDIS_STATUS_SUCCESS
;
3316 pAdapter
->StaCfg
.ScanCnt
= 99; // Prevent auto scan triggered by this OID
3321 if (pAdapter
->Mlme
.CntlMachine
.CurrState
!= CNTL_IDLE
)
3323 RT28XX_MLME_RESET_STATE_MACHINE(pAdapter
);
3324 DBGPRINT(RT_DEBUG_TRACE
, ("!!! MLME busy, reset MLME state machine !!!\n"));
3327 // tell CNTL state machine to call NdisMSetInformationComplete() after completing
3328 // this request, because this request is initiated by NDIS.
3329 pAdapter
->MlmeAux
.CurrReqIsFromNdis
= FALSE
;
3330 // Reset allowed scan retries
3331 pAdapter
->StaCfg
.ScanCnt
= 0;
3332 pAdapter
->StaCfg
.LastScanTime
= Now
;
3334 pAdapter
->StaCfg
.bScanReqIsFromWebUI
= TRUE
;
3335 RTMP_SET_FLAG(pAdapter
, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS
);
3336 MlmeEnqueue(pAdapter
,
3337 MLME_CNTL_STATE_MACHINE
,
3338 OID_802_11_BSSID_LIST_SCAN
,
3342 Status
= NDIS_STATUS_SUCCESS
;
3343 StateMachineTouched
= TRUE
;
3345 case OID_802_11_SSID
:
3346 if (wrq
->u
.data
.length
!= sizeof(NDIS_802_11_SSID
))
3350 PCHAR pSsidString
= NULL
;
3351 Status
= copy_from_user(&Ssid
, wrq
->u
.data
.pointer
, wrq
->u
.data
.length
);
3353 DBGPRINT(RT_DEBUG_TRACE
, ("Set::OID_802_11_SSID (Len=%d,Ssid=%s)\n", Ssid
.SsidLength
, Ssid
.Ssid
));
3354 if (Ssid
.SsidLength
> MAX_LEN_OF_SSID
)
3358 if (Ssid
.SsidLength
== 0)
3360 Set_SSID_Proc(pAdapter
, "");
3364 pSsidString
= (CHAR
*) kmalloc(MAX_LEN_OF_SSID
+1, MEM_ALLOC_FLAG
);
3367 NdisZeroMemory(pSsidString
, MAX_LEN_OF_SSID
+1);
3368 NdisMoveMemory(pSsidString
, Ssid
.Ssid
, Ssid
.SsidLength
);
3369 Set_SSID_Proc(pAdapter
, pSsidString
);
3378 case OID_802_11_BSSID
:
3380 if (ATE_ON(pAdapter
))
3382 DBGPRINT(RT_DEBUG_TRACE
, ("The driver is in ATE mode now\n"));
3385 #endif // RALINK_ATE //
3386 if (wrq
->u
.data
.length
!= sizeof(NDIS_802_11_MAC_ADDRESS
))
3390 Status
= copy_from_user(&Bssid
, wrq
->u
.data
.pointer
, wrq
->u
.data
.length
);
3392 // tell CNTL state machine to call NdisMSetInformationComplete() after completing
3393 // this request, because this request is initiated by NDIS.
3394 pAdapter
->MlmeAux
.CurrReqIsFromNdis
= FALSE
;
3396 // Prevent to connect AP again in STAMlmePeriodicExec
3397 pAdapter
->MlmeAux
.AutoReconnectSsidLen
= 32;
3399 // Reset allowed scan retries
3400 pAdapter
->StaCfg
.ScanCnt
= 0;
3402 if (pAdapter
->Mlme
.CntlMachine
.CurrState
!= CNTL_IDLE
)
3404 RT28XX_MLME_RESET_STATE_MACHINE(pAdapter
);
3405 DBGPRINT(RT_DEBUG_TRACE
, ("!!! MLME busy, reset MLME state machine !!!\n"));
3407 MlmeEnqueue(pAdapter
,
3408 MLME_CNTL_STATE_MACHINE
,
3410 sizeof(NDIS_802_11_MAC_ADDRESS
),
3412 Status
= NDIS_STATUS_SUCCESS
;
3413 StateMachineTouched
= TRUE
;
3415 DBGPRINT(RT_DEBUG_TRACE
, ("Set::OID_802_11_BSSID %02x:%02x:%02x:%02x:%02x:%02x\n",
3416 Bssid
[0], Bssid
[1], Bssid
[2], Bssid
[3], Bssid
[4], Bssid
[5]));
3419 case RT_OID_802_11_RADIO
:
3420 if (wrq
->u
.data
.length
!= sizeof(BOOLEAN
))
3424 Status
= copy_from_user(&RadioState
, wrq
->u
.data
.pointer
, wrq
->u
.data
.length
);
3425 DBGPRINT(RT_DEBUG_TRACE
, ("Set::RT_OID_802_11_RADIO (=%d)\n", RadioState
));
3426 if (pAdapter
->StaCfg
.bSwRadio
!= RadioState
)
3428 pAdapter
->StaCfg
.bSwRadio
= RadioState
;
3429 if (pAdapter
->StaCfg
.bRadio
!= (pAdapter
->StaCfg
.bHwRadio
&& pAdapter
->StaCfg
.bSwRadio
))
3431 pAdapter
->StaCfg
.bRadio
= (pAdapter
->StaCfg
.bHwRadio
&& pAdapter
->StaCfg
.bSwRadio
);
3432 if (pAdapter
->StaCfg
.bRadio
== TRUE
)
3434 MlmeRadioOn(pAdapter
);
3435 // Update extra information
3436 pAdapter
->ExtraInfo
= EXTRA_INFO_CLEAR
;
3440 MlmeRadioOff(pAdapter
);
3441 // Update extra information
3442 pAdapter
->ExtraInfo
= SW_RADIO_OFF
;
3448 case RT_OID_802_11_PHY_MODE
:
3449 if (wrq
->u
.data
.length
!= sizeof(RT_802_11_PHY_MODE
))
3453 Status
= copy_from_user(&PhyMode
, wrq
->u
.data
.pointer
, wrq
->u
.data
.length
);
3454 if (PhyMode
<= MaxPhyMode
)
3456 RTMPSetPhyMode(pAdapter
, PhyMode
);
3457 #ifdef DOT11_N_SUPPORT
3458 SetCommonHT(pAdapter
);
3459 #endif // DOT11_N_SUPPORT //
3461 DBGPRINT(RT_DEBUG_TRACE
, ("Set::RT_OID_802_11_PHY_MODE (=%d)\n", PhyMode
));
3464 case RT_OID_802_11_STA_CONFIG
:
3465 if (wrq
->u
.data
.length
!= sizeof(RT_802_11_STA_CONFIG
))
3469 Status
= copy_from_user(&StaConfig
, wrq
->u
.data
.pointer
, wrq
->u
.data
.length
);
3470 pAdapter
->CommonCfg
.bEnableTxBurst
= StaConfig
.EnableTxBurst
;
3471 pAdapter
->CommonCfg
.UseBGProtection
= StaConfig
.UseBGProtection
;
3472 pAdapter
->CommonCfg
.bUseShortSlotTime
= 1; // 2003-10-30 always SHORT SLOT capable
3473 if ((pAdapter
->CommonCfg
.PhyMode
!= StaConfig
.AdhocMode
) &&
3474 (StaConfig
.AdhocMode
<= MaxPhyMode
))
3476 // allow dynamic change of "USE OFDM rate or not" in ADHOC mode
3477 // if setting changed, need to reset current TX rate as well as BEACON frame format
3478 if (pAdapter
->StaCfg
.BssType
== BSS_ADHOC
)
3480 pAdapter
->CommonCfg
.PhyMode
= StaConfig
.AdhocMode
;
3481 RTMPSetPhyMode(pAdapter
, PhyMode
);
3482 MlmeUpdateTxRates(pAdapter
, FALSE
, 0);
3483 MakeIbssBeacon(pAdapter
); // re-build BEACON frame
3484 AsicEnableIbssSync(pAdapter
); // copy to on-chip memory
3487 DBGPRINT(RT_DEBUG_TRACE
, ("Set::RT_OID_802_11_SET_STA_CONFIG (Burst=%d, Protection=%ld,ShortSlot=%d\n",
3488 pAdapter
->CommonCfg
.bEnableTxBurst
,
3489 pAdapter
->CommonCfg
.UseBGProtection
,
3490 pAdapter
->CommonCfg
.bUseShortSlotTime
));
3493 case OID_802_11_DESIRED_RATES
:
3494 if (wrq
->u
.data
.length
!= sizeof(NDIS_802_11_RATES
))
3498 Status
= copy_from_user(&aryRates
, wrq
->u
.data
.pointer
, wrq
->u
.data
.length
);
3499 NdisZeroMemory(pAdapter
->CommonCfg
.DesireRate
, MAX_LEN_OF_SUPPORTED_RATES
);
3500 NdisMoveMemory(pAdapter
->CommonCfg
.DesireRate
, &aryRates
, sizeof(NDIS_802_11_RATES
));
3501 DBGPRINT(RT_DEBUG_TRACE
, ("Set::OID_802_11_DESIRED_RATES (%02x,%02x,%02x,%02x,%02x,%02x,%02x,%02x)\n",
3502 pAdapter
->CommonCfg
.DesireRate
[0],pAdapter
->CommonCfg
.DesireRate
[1],
3503 pAdapter
->CommonCfg
.DesireRate
[2],pAdapter
->CommonCfg
.DesireRate
[3],
3504 pAdapter
->CommonCfg
.DesireRate
[4],pAdapter
->CommonCfg
.DesireRate
[5],
3505 pAdapter
->CommonCfg
.DesireRate
[6],pAdapter
->CommonCfg
.DesireRate
[7] ));
3506 // Changing DesiredRate may affect the MAX TX rate we used to TX frames out
3507 MlmeUpdateTxRates(pAdapter
, FALSE
, 0);
3510 case RT_OID_802_11_PREAMBLE
:
3511 if (wrq
->u
.data
.length
!= sizeof(RT_802_11_PREAMBLE
))
3515 Status
= copy_from_user(&Preamble
, wrq
->u
.data
.pointer
, wrq
->u
.data
.length
);
3516 if (Preamble
== Rt802_11PreambleShort
)
3518 pAdapter
->CommonCfg
.TxPreamble
= Preamble
;
3519 MlmeSetTxPreamble(pAdapter
, Rt802_11PreambleShort
);
3521 else if ((Preamble
== Rt802_11PreambleLong
) || (Preamble
== Rt802_11PreambleAuto
))
3523 // if user wants AUTO, initialize to LONG here, then change according to AP's
3524 // capability upon association.
3525 pAdapter
->CommonCfg
.TxPreamble
= Preamble
;
3526 MlmeSetTxPreamble(pAdapter
, Rt802_11PreambleLong
);
3533 DBGPRINT(RT_DEBUG_TRACE
, ("Set::RT_OID_802_11_PREAMBLE (=%d)\n", Preamble
));
3536 case OID_802_11_WEP_STATUS
:
3537 if (wrq
->u
.data
.length
!= sizeof(NDIS_802_11_WEP_STATUS
))
3541 Status
= copy_from_user(&WepStatus
, wrq
->u
.data
.pointer
, wrq
->u
.data
.length
);
3542 // Since TKIP, AES, WEP are all supported. It should not have any invalid setting
3543 if (WepStatus
<= Ndis802_11Encryption3KeyAbsent
)
3545 if (pAdapter
->StaCfg
.WepStatus
!= WepStatus
)
3547 // Config has changed
3548 pAdapter
->bConfigChanged
= TRUE
;
3550 pAdapter
->StaCfg
.WepStatus
= WepStatus
;
3551 pAdapter
->StaCfg
.OrigWepStatus
= WepStatus
;
3552 pAdapter
->StaCfg
.PairCipher
= WepStatus
;
3553 pAdapter
->StaCfg
.GroupCipher
= WepStatus
;
3560 DBGPRINT(RT_DEBUG_TRACE
, ("Set::OID_802_11_WEP_STATUS (=%d)\n",WepStatus
));
3563 case OID_802_11_AUTHENTICATION_MODE
:
3564 if (wrq
->u
.data
.length
!= sizeof(NDIS_802_11_AUTHENTICATION_MODE
))
3568 Status
= copy_from_user(&AuthMode
, wrq
->u
.data
.pointer
, wrq
->u
.data
.length
);
3569 if (AuthMode
> Ndis802_11AuthModeMax
)
3576 if (pAdapter
->StaCfg
.AuthMode
!= AuthMode
)
3578 // Config has changed
3579 pAdapter
->bConfigChanged
= TRUE
;
3581 pAdapter
->StaCfg
.AuthMode
= AuthMode
;
3583 pAdapter
->StaCfg
.PortSecured
= WPA_802_1X_PORT_NOT_SECURED
;
3584 DBGPRINT(RT_DEBUG_TRACE
, ("Set::OID_802_11_AUTHENTICATION_MODE (=%d) \n",pAdapter
->StaCfg
.AuthMode
));
3587 case OID_802_11_INFRASTRUCTURE_MODE
:
3588 if (wrq
->u
.data
.length
!= sizeof(NDIS_802_11_NETWORK_INFRASTRUCTURE
))
3592 Status
= copy_from_user(&BssType
, wrq
->u
.data
.pointer
, wrq
->u
.data
.length
);
3594 if (BssType
== Ndis802_11IBSS
)
3595 Set_NetworkType_Proc(pAdapter
, "Adhoc");
3596 else if (BssType
== Ndis802_11Infrastructure
)
3597 Set_NetworkType_Proc(pAdapter
, "Infra");
3598 else if (BssType
== Ndis802_11Monitor
)
3599 Set_NetworkType_Proc(pAdapter
, "Monitor");
3603 DBGPRINT(RT_DEBUG_TRACE
, ("Set::OID_802_11_INFRASTRUCTURE_MODE (unknown)\n"));
3607 case OID_802_11_REMOVE_WEP
:
3608 DBGPRINT(RT_DEBUG_TRACE
, ("Set::OID_802_11_REMOVE_WEP\n"));
3609 if (wrq
->u
.data
.length
!= sizeof(NDIS_802_11_KEY_INDEX
))
3615 KeyIdx
= *(NDIS_802_11_KEY_INDEX
*) wrq
->u
.data
.pointer
;
3617 if (KeyIdx
& 0x80000000)
3619 // Should never set default bit when remove key
3624 KeyIdx
= KeyIdx
& 0x0fffffff;
3630 pAdapter
->SharedKey
[BSS0
][KeyIdx
].KeyLen
= 0;
3631 pAdapter
->SharedKey
[BSS0
][KeyIdx
].CipherAlg
= CIPHER_NONE
;
3632 AsicRemoveSharedKeyEntry(pAdapter
, 0, (UCHAR
)KeyIdx
);
3637 case RT_OID_802_11_RESET_COUNTERS
:
3638 NdisZeroMemory(&pAdapter
->WlanCounters
, sizeof(COUNTER_802_11
));
3639 NdisZeroMemory(&pAdapter
->Counters8023
, sizeof(COUNTER_802_3
));
3640 NdisZeroMemory(&pAdapter
->RalinkCounters
, sizeof(COUNTER_RALINK
));
3641 pAdapter
->Counters8023
.RxNoBuffer
= 0;
3642 pAdapter
->Counters8023
.GoodReceives
= 0;
3643 pAdapter
->Counters8023
.RxNoBuffer
= 0;
3644 DBGPRINT(RT_DEBUG_TRACE
, ("Set::RT_OID_802_11_RESET_COUNTERS \n"));
3646 case OID_802_11_RTS_THRESHOLD
:
3647 if (wrq
->u
.data
.length
!= sizeof(NDIS_802_11_RTS_THRESHOLD
))
3651 Status
= copy_from_user(&RtsThresh
, wrq
->u
.data
.pointer
, wrq
->u
.data
.length
);
3652 if (RtsThresh
> MAX_RTS_THRESHOLD
)
3655 pAdapter
->CommonCfg
.RtsThreshold
= (USHORT
)RtsThresh
;
3657 DBGPRINT(RT_DEBUG_TRACE
, ("Set::OID_802_11_RTS_THRESHOLD (=%ld)\n",RtsThresh
));
3659 case OID_802_11_FRAGMENTATION_THRESHOLD
:
3660 if (wrq
->u
.data
.length
!= sizeof(NDIS_802_11_FRAGMENTATION_THRESHOLD
))
3664 Status
= copy_from_user(&FragThresh
, wrq
->u
.data
.pointer
, wrq
->u
.data
.length
);
3665 pAdapter
->CommonCfg
.bUseZeroToDisableFragment
= FALSE
;
3666 if (FragThresh
> MAX_FRAG_THRESHOLD
|| FragThresh
< MIN_FRAG_THRESHOLD
)
3668 if (FragThresh
== 0)
3670 pAdapter
->CommonCfg
.FragmentThreshold
= MAX_FRAG_THRESHOLD
;
3671 pAdapter
->CommonCfg
.bUseZeroToDisableFragment
= TRUE
;
3677 pAdapter
->CommonCfg
.FragmentThreshold
= (USHORT
)FragThresh
;
3679 DBGPRINT(RT_DEBUG_TRACE
, ("Set::OID_802_11_FRAGMENTATION_THRESHOLD (=%ld) \n",FragThresh
));
3681 case OID_802_11_POWER_MODE
:
3682 if (wrq
->u
.data
.length
!= sizeof(NDIS_802_11_POWER_MODE
))
3686 Status
= copy_from_user(&PowerMode
, wrq
->u
.data
.pointer
, wrq
->u
.data
.length
);
3687 if (PowerMode
== Ndis802_11PowerModeCAM
)
3688 Set_PSMode_Proc(pAdapter
, "CAM");
3689 else if (PowerMode
== Ndis802_11PowerModeMAX_PSP
)
3690 Set_PSMode_Proc(pAdapter
, "Max_PSP");
3691 else if (PowerMode
== Ndis802_11PowerModeFast_PSP
)
3692 Set_PSMode_Proc(pAdapter
, "Fast_PSP");
3693 else if (PowerMode
== Ndis802_11PowerModeLegacy_PSP
)
3694 Set_PSMode_Proc(pAdapter
, "Legacy_PSP");
3698 DBGPRINT(RT_DEBUG_TRACE
, ("Set::OID_802_11_POWER_MODE (=%d)\n",PowerMode
));
3700 case RT_OID_802_11_TX_POWER_LEVEL_1
:
3701 if (wrq
->u
.data
.length
< sizeof(ULONG
))
3705 Status
= copy_from_user(&PowerTemp
, wrq
->u
.data
.pointer
, wrq
->u
.data
.length
);
3706 if (PowerTemp
> 100)
3707 PowerTemp
= 0xffffffff; // AUTO
3708 pAdapter
->CommonCfg
.TxPowerDefault
= PowerTemp
; //keep current setting.
3709 pAdapter
->CommonCfg
.TxPowerPercentage
= pAdapter
->CommonCfg
.TxPowerDefault
;
3710 DBGPRINT(RT_DEBUG_TRACE
, ("Set::RT_OID_802_11_TX_POWER_LEVEL_1 (=%ld)\n", pAdapter
->CommonCfg
.TxPowerPercentage
));
3713 case OID_802_11_NETWORK_TYPE_IN_USE
:
3714 if (wrq
->u
.data
.length
!= sizeof(NDIS_802_11_NETWORK_TYPE
))
3718 Status
= copy_from_user(&NetType
, wrq
->u
.data
.pointer
, wrq
->u
.data
.length
);
3720 if (NetType
== Ndis802_11DS
)
3721 RTMPSetPhyMode(pAdapter
, PHY_11B
);
3722 else if (NetType
== Ndis802_11OFDM24
)
3723 RTMPSetPhyMode(pAdapter
, PHY_11BG_MIXED
);
3724 else if (NetType
== Ndis802_11OFDM5
)
3725 RTMPSetPhyMode(pAdapter
, PHY_11A
);
3728 #ifdef DOT11_N_SUPPORT
3729 if (Status
== NDIS_STATUS_SUCCESS
)
3730 SetCommonHT(pAdapter
);
3731 #endif // DOT11_N_SUPPORT //
3732 DBGPRINT(RT_DEBUG_TRACE
, ("Set::OID_802_11_NETWORK_TYPE_IN_USE (=%d)\n",NetType
));
3735 // For WPA PSK PMK key
3736 case RT_OID_802_11_ADD_WPA
:
3737 pKey
= kmalloc(wrq
->u
.data
.length
, MEM_ALLOC_FLAG
);
3744 Status
= copy_from_user(pKey
, wrq
->u
.data
.pointer
, wrq
->u
.data
.length
);
3745 if (pKey
->Length
!= wrq
->u
.data
.length
)
3748 DBGPRINT(RT_DEBUG_TRACE
, ("Set::RT_OID_802_11_ADD_WPA, Failed!!\n"));
3752 if ((pAdapter
->StaCfg
.AuthMode
!= Ndis802_11AuthModeWPAPSK
) &&
3753 (pAdapter
->StaCfg
.AuthMode
!= Ndis802_11AuthModeWPA2PSK
) &&
3754 (pAdapter
->StaCfg
.AuthMode
!= Ndis802_11AuthModeWPANone
) )
3756 Status
= -EOPNOTSUPP
;
3757 DBGPRINT(RT_DEBUG_TRACE
, ("Set::RT_OID_802_11_ADD_WPA, Failed!! [AuthMode != WPAPSK/WPA2PSK/WPANONE]\n"));
3759 else if ((pAdapter
->StaCfg
.AuthMode
== Ndis802_11AuthModeWPAPSK
) ||
3760 (pAdapter
->StaCfg
.AuthMode
== Ndis802_11AuthModeWPA2PSK
) ||
3761 (pAdapter
->StaCfg
.AuthMode
== Ndis802_11AuthModeWPANone
) ) // Only for WPA PSK mode
3763 NdisMoveMemory(pAdapter
->StaCfg
.PMK
, &pKey
->KeyMaterial
, pKey
->KeyLength
);
3764 // Use RaConfig as PSK agent.
3765 // Start STA supplicant state machine
3766 if (pAdapter
->StaCfg
.AuthMode
!= Ndis802_11AuthModeWPANone
)
3767 pAdapter
->StaCfg
.WpaState
= SS_START
;
3769 DBGPRINT(RT_DEBUG_TRACE
, ("Set::RT_OID_802_11_ADD_WPA (id=0x%x, Len=%d-byte)\n", pKey
->KeyIndex
, pKey
->KeyLength
));
3773 pAdapter
->StaCfg
.WpaState
= SS_NOTUSE
;
3774 DBGPRINT(RT_DEBUG_TRACE
, ("Set::RT_OID_802_11_ADD_WPA (id=0x%x, Len=%d-byte)\n", pKey
->KeyIndex
, pKey
->KeyLength
));
3779 case OID_802_11_REMOVE_KEY
:
3780 pRemoveKey
= kmalloc(wrq
->u
.data
.length
, MEM_ALLOC_FLAG
);
3781 if(pRemoveKey
== NULL
)
3787 Status
= copy_from_user(pRemoveKey
, wrq
->u
.data
.pointer
, wrq
->u
.data
.length
);
3788 if (pRemoveKey
->Length
!= wrq
->u
.data
.length
)
3791 DBGPRINT(RT_DEBUG_TRACE
, ("Set::OID_802_11_REMOVE_KEY, Failed!!\n"));
3795 if (pAdapter
->StaCfg
.AuthMode
>= Ndis802_11AuthModeWPA
)
3797 RTMPWPARemoveKeyProc(pAdapter
, pRemoveKey
);
3798 DBGPRINT(RT_DEBUG_TRACE
, ("Set::OID_802_11_REMOVE_KEY, Remove WPA Key!!\n"));
3802 KeyIdx
= pRemoveKey
->KeyIndex
;
3804 if (KeyIdx
& 0x80000000)
3806 // Should never set default bit when remove key
3808 DBGPRINT(RT_DEBUG_TRACE
, ("Set::OID_802_11_REMOVE_KEY, Failed!!(Should never set default bit when remove key)\n"));
3812 KeyIdx
= KeyIdx
& 0x0fffffff;
3816 DBGPRINT(RT_DEBUG_TRACE
, ("Set::OID_802_11_REMOVE_KEY, Failed!!(KeyId[%d] out of range)\n", KeyIdx
));
3820 pAdapter
->SharedKey
[BSS0
][KeyIdx
].KeyLen
= 0;
3821 pAdapter
->SharedKey
[BSS0
][KeyIdx
].CipherAlg
= CIPHER_NONE
;
3822 AsicRemoveSharedKeyEntry(pAdapter
, 0, (UCHAR
)KeyIdx
);
3823 DBGPRINT(RT_DEBUG_TRACE
, ("Set::OID_802_11_REMOVE_KEY (id=0x%x, Len=%d-byte)\n", pRemoveKey
->KeyIndex
, pRemoveKey
->Length
));
3831 case OID_802_11_ADD_KEY
:
3832 pKey
= kmalloc(wrq
->u
.data
.length
, MEM_ALLOC_FLAG
);
3838 Status
= copy_from_user(pKey
, wrq
->u
.data
.pointer
, wrq
->u
.data
.length
);
3839 if (pKey
->Length
!= wrq
->u
.data
.length
)
3842 DBGPRINT(RT_DEBUG_TRACE
, ("Set::OID_802_11_ADD_KEY, Failed!!\n"));
3846 RTMPAddKey(pAdapter
, pKey
);
3847 DBGPRINT(RT_DEBUG_TRACE
, ("Set::OID_802_11_ADD_KEY (id=0x%x, Len=%d-byte)\n", pKey
->KeyIndex
, pKey
->KeyLength
));
3851 case OID_802_11_CONFIGURATION
:
3852 if (wrq
->u
.data
.length
!= sizeof(NDIS_802_11_CONFIGURATION
))
3856 Status
= copy_from_user(&Config
, wrq
->u
.data
.pointer
, wrq
->u
.data
.length
);
3859 if ((pConfig
->BeaconPeriod
>= 20) && (pConfig
->BeaconPeriod
<=400))
3860 pAdapter
->CommonCfg
.BeaconPeriod
= (USHORT
) pConfig
->BeaconPeriod
;
3862 pAdapter
->StaActive
.AtimWin
= (USHORT
) pConfig
->ATIMWindow
;
3863 MAP_KHZ_TO_CHANNEL_ID(pConfig
->DSConfig
, pAdapter
->CommonCfg
.Channel
);
3865 // Save the channel on MlmeAux for CntlOidRTBssidProc used.
3867 pAdapter
->MlmeAux
.Channel
= pAdapter
->CommonCfg
.Channel
;
3869 DBGPRINT(RT_DEBUG_TRACE
, ("Set::OID_802_11_CONFIGURATION (BeacnPeriod=%ld,AtimW=%ld,Ch=%d)\n",
3870 pConfig
->BeaconPeriod
, pConfig
->ATIMWindow
, pAdapter
->CommonCfg
.Channel
));
3871 // Config has changed
3872 pAdapter
->bConfigChanged
= TRUE
;
3875 #ifdef DOT11_N_SUPPORT
3876 case RT_OID_802_11_SET_HT_PHYMODE
:
3877 if (wrq
->u
.data
.length
!= sizeof(OID_SET_HT_PHYMODE
))
3881 POID_SET_HT_PHYMODE pHTPhyMode
= &HT_PhyMode
;
3883 Status
= copy_from_user(&HT_PhyMode
, wrq
->u
.data
.pointer
, wrq
->u
.data
.length
);
3884 DBGPRINT(RT_DEBUG_TRACE
, ("Set::pHTPhyMode (PhyMode = %d,TransmitNo = %d, HtMode = %d, ExtOffset = %d , MCS = %d, BW = %d, STBC = %d, SHORTGI = %d) \n",
3885 pHTPhyMode
->PhyMode
, pHTPhyMode
->TransmitNo
,pHTPhyMode
->HtMode
,pHTPhyMode
->ExtOffset
,
3886 pHTPhyMode
->MCS
, pHTPhyMode
->BW
, pHTPhyMode
->STBC
, pHTPhyMode
->SHORTGI
));
3887 if (pAdapter
->CommonCfg
.PhyMode
>= PHY_11ABGN_MIXED
)
3888 RTMPSetHT(pAdapter
, pHTPhyMode
);
3890 DBGPRINT(RT_DEBUG_TRACE
, ("Set::RT_OID_802_11_SET_HT_PHYMODE(MCS=%d,BW=%d,SGI=%d,STBC=%d)\n",
3891 pAdapter
->StaCfg
.HTPhyMode
.field
.MCS
, pAdapter
->StaCfg
.HTPhyMode
.field
.BW
, pAdapter
->StaCfg
.HTPhyMode
.field
.ShortGI
,
3892 pAdapter
->StaCfg
.HTPhyMode
.field
.STBC
));
3894 #endif // DOT11_N_SUPPORT //
3895 case RT_OID_802_11_SET_APSD_SETTING
:
3896 if (wrq
->u
.data
.length
!= sizeof(ULONG
))
3901 Status
= copy_from_user(&apsd
, wrq
->u
.data
.pointer
, wrq
->u
.data
.length
);
3903 /*-------------------------------------------------------------------
3904 |B31~B7 | B6~B5 | B4 | B3 | B2 | B1 | B0 |
3905 ---------------------------------------------------------------------
3906 | Rsvd | Max SP Len | AC_VO | AC_VI | AC_BK | AC_BE | APSD Capable |
3907 ---------------------------------------------------------------------*/
3908 pAdapter
->CommonCfg
.bAPSDCapable
= (apsd
& 0x00000001) ? TRUE
: FALSE
;
3909 pAdapter
->CommonCfg
.bAPSDAC_BE
= ((apsd
& 0x00000002) >> 1) ? TRUE
: FALSE
;
3910 pAdapter
->CommonCfg
.bAPSDAC_BK
= ((apsd
& 0x00000004) >> 2) ? TRUE
: FALSE
;
3911 pAdapter
->CommonCfg
.bAPSDAC_VI
= ((apsd
& 0x00000008) >> 3) ? TRUE
: FALSE
;
3912 pAdapter
->CommonCfg
.bAPSDAC_VO
= ((apsd
& 0x00000010) >> 4) ? TRUE
: FALSE
;
3913 pAdapter
->CommonCfg
.MaxSPLength
= (UCHAR
)((apsd
& 0x00000060) >> 5);
3915 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
,
3916 pAdapter
->CommonCfg
.bAPSDAC_BE
, pAdapter
->CommonCfg
.bAPSDAC_BK
, pAdapter
->CommonCfg
.bAPSDAC_VI
, pAdapter
->CommonCfg
.bAPSDAC_VO
, pAdapter
->CommonCfg
.MaxSPLength
));
3920 case RT_OID_802_11_SET_APSD_PSM
:
3921 if (wrq
->u
.data
.length
!= sizeof(ULONG
))
3925 // Driver needs to notify AP when PSM changes
3926 Status
= copy_from_user(&pAdapter
->CommonCfg
.bAPSDForcePowerSave
, wrq
->u
.data
.pointer
, wrq
->u
.data
.length
);
3927 if (pAdapter
->CommonCfg
.bAPSDForcePowerSave
!= pAdapter
->StaCfg
.Psm
)
3929 MlmeSetPsmBit(pAdapter
, pAdapter
->CommonCfg
.bAPSDForcePowerSave
);
3930 RTMPSendNullFrame(pAdapter
, pAdapter
->CommonCfg
.TxRate
, TRUE
);
3932 DBGPRINT(RT_DEBUG_TRACE
, ("Set::RT_OID_802_11_SET_APSD_PSM (bAPSDForcePowerSave:%d)\n", pAdapter
->CommonCfg
.bAPSDForcePowerSave
));
3935 #ifdef QOS_DLS_SUPPORT
3936 case RT_OID_802_11_SET_DLS
:
3937 if (wrq
->u
.data
.length
!= sizeof(ULONG
))
3941 BOOLEAN oldvalue
= pAdapter
->CommonCfg
.bDLSCapable
;
3942 Status
= copy_from_user(&pAdapter
->CommonCfg
.bDLSCapable
, wrq
->u
.data
.pointer
, wrq
->u
.data
.length
);
3943 if (oldvalue
&& !pAdapter
->CommonCfg
.bDLSCapable
)
3946 // tear down local dls table entry
3947 for (i
=0; i
<MAX_NUM_OF_INIT_DLS_ENTRY
; i
++)
3949 if (pAdapter
->StaCfg
.DLSEntry
[i
].Valid
&& (pAdapter
->StaCfg
.DLSEntry
[i
].Status
== DLS_FINISH
))
3951 pAdapter
->StaCfg
.DLSEntry
[i
].Status
= DLS_NONE
;
3952 pAdapter
->StaCfg
.DLSEntry
[i
].Valid
= FALSE
;
3953 RTMPSendDLSTearDownFrame(pAdapter
, pAdapter
->StaCfg
.DLSEntry
[i
].MacAddr
);
3957 // tear down peer dls table entry
3958 for (i
=MAX_NUM_OF_INIT_DLS_ENTRY
; i
<MAX_NUM_OF_DLS_ENTRY
; i
++)
3960 if (pAdapter
->StaCfg
.DLSEntry
[i
].Valid
&& (pAdapter
->StaCfg
.DLSEntry
[i
].Status
== DLS_FINISH
))
3962 pAdapter
->StaCfg
.DLSEntry
[i
].Status
= DLS_NONE
;
3963 pAdapter
->StaCfg
.DLSEntry
[i
].Valid
= FALSE
;
3964 RTMPSendDLSTearDownFrame(pAdapter
, pAdapter
->StaCfg
.DLSEntry
[i
].MacAddr
);
3969 DBGPRINT(RT_DEBUG_TRACE
,("Set::RT_OID_802_11_SET_DLS (=%d)\n", pAdapter
->CommonCfg
.bDLSCapable
));
3973 case RT_OID_802_11_SET_DLS_PARAM
:
3974 if (wrq
->u
.data
.length
!= sizeof(RT_802_11_DLS_UI
))
3980 NdisZeroMemory(&Dls
, sizeof(RT_802_11_DLS
));
3981 RTMPMoveMemory(&Dls
, wrq
->u
.data
.pointer
, sizeof(RT_802_11_DLS_UI
));
3982 MlmeEnqueue(pAdapter
,
3983 MLME_CNTL_STATE_MACHINE
,
3984 RT_OID_802_11_SET_DLS_PARAM
,
3985 sizeof(RT_802_11_DLS
),
3987 DBGPRINT(RT_DEBUG_TRACE
,("Set::RT_OID_802_11_SET_DLS_PARAM \n"));
3990 #endif // QOS_DLS_SUPPORT //
3991 case RT_OID_802_11_SET_WMM
:
3992 if (wrq
->u
.data
.length
!= sizeof(BOOLEAN
))
3996 Status
= copy_from_user(&pAdapter
->CommonCfg
.bWmmCapable
, wrq
->u
.data
.pointer
, wrq
->u
.data
.length
);
3997 DBGPRINT(RT_DEBUG_TRACE
, ("Set::RT_OID_802_11_SET_WMM (=%d) \n", pAdapter
->CommonCfg
.bWmmCapable
));
4001 case OID_802_11_DISASSOCIATE
:
4003 if (ATE_ON(pAdapter
))
4005 DBGPRINT(RT_DEBUG_TRACE
, ("The driver is in ATE mode now\n"));
4008 #endif // RALINK_ATE //
4010 // Set NdisRadioStateOff to TRUE, instead of called MlmeRadioOff.
4011 // Later on, NDIS_802_11_BSSID_LIST_EX->NumberOfItems should be 0
4012 // when query OID_802_11_BSSID_LIST.
4014 // TRUE: NumberOfItems will set to 0.
4015 // FALSE: NumberOfItems no change.
4017 pAdapter
->CommonCfg
.NdisRadioStateOff
= TRUE
;
4018 // Set to immediately send the media disconnect event
4019 pAdapter
->MlmeAux
.CurrReqIsFromNdis
= TRUE
;
4020 DBGPRINT(RT_DEBUG_TRACE
, ("Set::OID_802_11_DISASSOCIATE \n"));
4022 if (INFRA_ON(pAdapter
))
4024 if (pAdapter
->Mlme
.CntlMachine
.CurrState
!= CNTL_IDLE
)
4026 RT28XX_MLME_RESET_STATE_MACHINE(pAdapter
);
4027 DBGPRINT(RT_DEBUG_TRACE
, ("!!! MLME busy, reset MLME state machine !!!\n"));
4030 MlmeEnqueue(pAdapter
,
4031 MLME_CNTL_STATE_MACHINE
,
4032 OID_802_11_DISASSOCIATE
,
4036 StateMachineTouched
= TRUE
;
4040 #ifdef DOT11_N_SUPPORT
4041 case RT_OID_802_11_SET_IMME_BA_CAP
:
4042 if (wrq
->u
.data
.length
!= sizeof(OID_BACAP_STRUC
))
4046 OID_BACAP_STRUC Orde
;
4047 Status
= copy_from_user(&Orde
, wrq
->u
.data
.pointer
, wrq
->u
.data
.length
);
4048 if (Orde
.Policy
> BA_NOTUSE
)
4050 Status
= NDIS_STATUS_INVALID_DATA
;
4052 else if (Orde
.Policy
== BA_NOTUSE
)
4054 pAdapter
->CommonCfg
.BACapability
.field
.Policy
= BA_NOTUSE
;
4055 pAdapter
->CommonCfg
.BACapability
.field
.MpduDensity
= Orde
.MpduDensity
;
4056 pAdapter
->CommonCfg
.DesiredHtPhy
.MpduDensity
= Orde
.MpduDensity
;
4057 pAdapter
->CommonCfg
.DesiredHtPhy
.AmsduEnable
= Orde
.AmsduEnable
;
4058 pAdapter
->CommonCfg
.DesiredHtPhy
.AmsduSize
= Orde
.AmsduSize
;
4059 pAdapter
->CommonCfg
.DesiredHtPhy
.MimoPs
= Orde
.MMPSmode
;
4060 pAdapter
->CommonCfg
.BACapability
.field
.MMPSmode
= Orde
.MMPSmode
;
4062 pAdapter
->CommonCfg
.HtCapability
.HtCapInfo
.MimoPs
= Orde
.MMPSmode
;
4063 pAdapter
->CommonCfg
.HtCapability
.HtCapInfo
.AMsduSize
= Orde
.AmsduSize
;
4064 pAdapter
->CommonCfg
.HtCapability
.HtCapParm
.MpduDensity
= Orde
.MpduDensity
;
4068 pAdapter
->CommonCfg
.BACapability
.field
.AutoBA
= Orde
.AutoBA
;
4069 pAdapter
->CommonCfg
.BACapability
.field
.Policy
= IMMED_BA
; // we only support immediate BA.
4070 pAdapter
->CommonCfg
.BACapability
.field
.MpduDensity
= Orde
.MpduDensity
;
4071 pAdapter
->CommonCfg
.DesiredHtPhy
.MpduDensity
= Orde
.MpduDensity
;
4072 pAdapter
->CommonCfg
.DesiredHtPhy
.AmsduEnable
= Orde
.AmsduEnable
;
4073 pAdapter
->CommonCfg
.DesiredHtPhy
.AmsduSize
= Orde
.AmsduSize
;
4074 pAdapter
->CommonCfg
.DesiredHtPhy
.MimoPs
= Orde
.MMPSmode
;
4075 pAdapter
->CommonCfg
.BACapability
.field
.MMPSmode
= Orde
.MMPSmode
;
4078 pAdapter
->CommonCfg
.HtCapability
.HtCapInfo
.MimoPs
= Orde
.MMPSmode
;
4079 pAdapter
->CommonCfg
.HtCapability
.HtCapInfo
.AMsduSize
= Orde
.AmsduSize
;
4080 pAdapter
->CommonCfg
.HtCapability
.HtCapParm
.MpduDensity
= Orde
.MpduDensity
;
4082 if (pAdapter
->CommonCfg
.BACapability
.field
.RxBAWinLimit
> MAX_RX_REORDERBUF
)
4083 pAdapter
->CommonCfg
.BACapability
.field
.RxBAWinLimit
= MAX_RX_REORDERBUF
;
4087 pAdapter
->CommonCfg
.REGBACapability
.word
= pAdapter
->CommonCfg
.BACapability
.word
;
4088 DBGPRINT(RT_DEBUG_TRACE
, ("Set::(Orde.AutoBA = %d) (Policy=%d)(ReBAWinLimit=%d)(TxBAWinLimit=%d)(AutoMode=%d)\n",Orde
.AutoBA
, pAdapter
->CommonCfg
.BACapability
.field
.Policy
,
4089 pAdapter
->CommonCfg
.BACapability
.field
.RxBAWinLimit
,pAdapter
->CommonCfg
.BACapability
.field
.TxBAWinLimit
, pAdapter
->CommonCfg
.BACapability
.field
.AutoBA
));
4090 DBGPRINT(RT_DEBUG_TRACE
, ("Set::(MimoPs = %d)(AmsduEnable = %d) (AmsduSize=%d)(MpduDensity=%d)\n",pAdapter
->CommonCfg
.DesiredHtPhy
.MimoPs
, pAdapter
->CommonCfg
.DesiredHtPhy
.AmsduEnable
,
4091 pAdapter
->CommonCfg
.DesiredHtPhy
.AmsduSize
, pAdapter
->CommonCfg
.DesiredHtPhy
.MpduDensity
));
4095 case RT_OID_802_11_ADD_IMME_BA
:
4096 DBGPRINT(RT_DEBUG_TRACE
, (" Set :: RT_OID_802_11_ADD_IMME_BA \n"));
4097 if (wrq
->u
.data
.length
!= sizeof(OID_ADD_BA_ENTRY
))
4102 OID_ADD_BA_ENTRY BA
;
4103 MAC_TABLE_ENTRY
*pEntry
;
4105 Status
= copy_from_user(&BA
, wrq
->u
.data
.pointer
, wrq
->u
.data
.length
);
4108 Status
= NDIS_STATUS_INVALID_DATA
;
4113 //BATableInsertEntry
4114 //As ad-hoc mode, BA pair is not limited to only BSSID. so add via OID.
4116 // in ad hoc mode, when adding BA pair, we should insert this entry into MACEntry too
4117 pEntry
= MacTableLookup(pAdapter
, BA
.MACAddr
);
4120 DBGPRINT(RT_DEBUG_TRACE
, ("RT_OID_802_11_ADD_IMME_BA. break on no connection.----:%x:%x\n", BA
.MACAddr
[4], BA
.MACAddr
[5]));
4123 if (BA
.IsRecipient
== FALSE
)
4125 if (pEntry
->bIAmBadAtheros
== TRUE
)
4126 pAdapter
->CommonCfg
.BACapability
.field
.RxBAWinLimit
= 0x10;
4128 BAOriSessionSetUp(pAdapter
, pEntry
, index
, 0, 100, TRUE
);
4132 //BATableInsertEntry(pAdapter, pEntry->Aid, BA.MACAddr, 0, 0xffff, BA.TID, BA.nMSDU, BA.IsRecipient);
4135 DBGPRINT(RT_DEBUG_TRACE
, ("Set::RT_OID_802_11_ADD_IMME_BA. Rec = %d. Mac = %x:%x:%x:%x:%x:%x . \n",
4136 BA
.IsRecipient
, BA
.MACAddr
[0], BA
.MACAddr
[1], BA
.MACAddr
[2], BA
.MACAddr
[2]
4137 , BA
.MACAddr
[4], BA
.MACAddr
[5]));
4142 case RT_OID_802_11_TEAR_IMME_BA
:
4143 DBGPRINT(RT_DEBUG_TRACE
, ("Set :: RT_OID_802_11_TEAR_IMME_BA \n"));
4144 if (wrq
->u
.data
.length
!= sizeof(OID_ADD_BA_ENTRY
))
4148 POID_ADD_BA_ENTRY pBA
;
4149 MAC_TABLE_ENTRY
*pEntry
;
4151 pBA
= kmalloc(wrq
->u
.data
.length
, MEM_ALLOC_FLAG
);
4155 DBGPRINT(RT_DEBUG_TRACE
, ("Set :: RT_OID_802_11_TEAR_IMME_BA kmalloc() can't allocate enough memory\n"));
4156 Status
= NDIS_STATUS_FAILURE
;
4160 Status
= copy_from_user(pBA
, wrq
->u
.data
.pointer
, wrq
->u
.data
.length
);
4161 DBGPRINT(RT_DEBUG_TRACE
, ("Set :: RT_OID_802_11_TEAR_IMME_BA(TID=%d, bAllTid=%d)\n", pBA
->TID
, pBA
->bAllTid
));
4163 if (!pBA
->bAllTid
&& (pBA
->TID
> NUM_OF_TID
))
4165 Status
= NDIS_STATUS_INVALID_DATA
;
4169 if (pBA
->IsRecipient
== FALSE
)
4171 pEntry
= MacTableLookup(pAdapter
, pBA
->MACAddr
);
4172 DBGPRINT(RT_DEBUG_TRACE
, (" pBA->IsRecipient == FALSE\n"));
4175 DBGPRINT(RT_DEBUG_TRACE
, (" pBA->pEntry\n"));
4176 BAOriSessionTearDown(pAdapter
, pEntry
->Aid
, pBA
->TID
, FALSE
, TRUE
);
4179 DBGPRINT(RT_DEBUG_TRACE
, ("Set :: Not found pEntry \n"));
4183 pEntry
= MacTableLookup(pAdapter
, pBA
->MACAddr
);
4186 BARecSessionTearDown( pAdapter
, (UCHAR
)pEntry
->Aid
, pBA
->TID
, TRUE
);
4189 DBGPRINT(RT_DEBUG_TRACE
, ("Set :: Not found pEntry \n"));
4195 #endif // DOT11_N_SUPPORT //
4197 // For WPA_SUPPLICANT to set static wep key
4198 case OID_802_11_ADD_WEP
:
4199 pWepKey
= kmalloc(wrq
->u
.data
.length
, MEM_ALLOC_FLAG
);
4204 DBGPRINT(RT_DEBUG_TRACE
, ("Set::OID_802_11_ADD_WEP, Failed!!\n"));
4207 Status
= copy_from_user(pWepKey
, wrq
->u
.data
.pointer
, wrq
->u
.data
.length
);
4211 DBGPRINT(RT_DEBUG_TRACE
, ("Set::OID_802_11_ADD_WEP, Failed (length mismatch)!!\n"));
4215 KeyIdx
= pWepKey
->KeyIndex
& 0x0fffffff;
4216 // KeyIdx must be 0 ~ 3
4220 DBGPRINT(RT_DEBUG_TRACE
, ("Set::OID_802_11_ADD_WEP, Failed (KeyIdx must be smaller than 4)!!\n"));
4224 UCHAR CipherAlg
= 0;
4227 // set key material and key length
4228 NdisZeroMemory(pAdapter
->SharedKey
[BSS0
][KeyIdx
].Key
, 16);
4229 pAdapter
->SharedKey
[BSS0
][KeyIdx
].KeyLen
= (UCHAR
) pWepKey
->KeyLength
;
4230 NdisMoveMemory(pAdapter
->SharedKey
[BSS0
][KeyIdx
].Key
, &pWepKey
->KeyMaterial
, pWepKey
->KeyLength
);
4232 switch(pWepKey
->KeyLength
)
4235 CipherAlg
= CIPHER_WEP64
;
4238 CipherAlg
= CIPHER_WEP128
;
4241 DBGPRINT(RT_DEBUG_TRACE
, ("Set::OID_802_11_ADD_WEP, only support CIPHER_WEP64(len:5) & CIPHER_WEP128(len:13)!!\n"));
4245 pAdapter
->SharedKey
[BSS0
][KeyIdx
].CipherAlg
= CipherAlg
;
4247 // Default key for tx (shared key)
4248 if (pWepKey
->KeyIndex
& 0x80000000)
4250 #ifdef WPA_SUPPLICANT_SUPPORT
4251 // set key material and key length
4252 NdisZeroMemory(pAdapter
->StaCfg
.DesireSharedKey
[KeyIdx
].Key
, 16);
4253 pAdapter
->StaCfg
.DesireSharedKey
[KeyIdx
].KeyLen
= (UCHAR
) pWepKey
->KeyLength
;
4254 NdisMoveMemory(pAdapter
->StaCfg
.DesireSharedKey
[KeyIdx
].Key
, &pWepKey
->KeyMaterial
, pWepKey
->KeyLength
);
4255 pAdapter
->StaCfg
.DesireSharedKeyId
= KeyIdx
;
4256 pAdapter
->StaCfg
.DesireSharedKey
[KeyIdx
].CipherAlg
= CipherAlg
;
4257 #endif // WPA_SUPPLICANT_SUPPORT //
4258 pAdapter
->StaCfg
.DefaultKeyId
= (UCHAR
) KeyIdx
;
4261 #ifdef WPA_SUPPLICANT_SUPPORT
4262 if (pAdapter
->StaCfg
.PortSecured
== WPA_802_1X_PORT_SECURED
)
4263 #endif // WPA_SUPPLICANT_SUPPORT
4265 Key
= pAdapter
->SharedKey
[BSS0
][KeyIdx
].Key
;
4267 // Set key material and cipherAlg to Asic
4268 AsicAddSharedKeyEntry(pAdapter
, BSS0
, KeyIdx
, CipherAlg
, Key
, NULL
, NULL
);
4270 if (pWepKey
->KeyIndex
& 0x80000000)
4272 PMAC_TABLE_ENTRY pEntry
= &pAdapter
->MacTab
.Content
[BSSID_WCID
];
4273 // Assign group key info
4274 RTMPAddWcidAttributeEntry(pAdapter
, BSS0
, KeyIdx
, CipherAlg
, NULL
);
4275 // Assign pairwise key info
4276 RTMPAddWcidAttributeEntry(pAdapter
, BSS0
, KeyIdx
, CipherAlg
, pEntry
);
4279 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"));
4284 #ifdef WPA_SUPPLICANT_SUPPORT
4285 case OID_SET_COUNTERMEASURES
:
4286 if (wrq
->u
.data
.length
!= sizeof(int))
4291 Status
= copy_from_user(&enabled
, wrq
->u
.data
.pointer
, wrq
->u
.data
.length
);
4293 pAdapter
->StaCfg
.bBlockAssoc
= TRUE
;
4295 // WPA MIC error should block association attempt for 60 seconds
4296 pAdapter
->StaCfg
.bBlockAssoc
= FALSE
;
4297 DBGPRINT(RT_DEBUG_TRACE
, ("Set::OID_SET_COUNTERMEASURES bBlockAssoc=%s\n", pAdapter
->StaCfg
.bBlockAssoc
? "TRUE":"FALSE"));
4300 case RT_OID_WPA_SUPPLICANT_SUPPORT
:
4301 if (wrq
->u
.data
.length
!= sizeof(UCHAR
))
4305 Status
= copy_from_user(&wpa_supplicant_enable
, wrq
->u
.data
.pointer
, wrq
->u
.data
.length
);
4306 pAdapter
->StaCfg
.WpaSupplicantUP
= wpa_supplicant_enable
;
4307 DBGPRINT(RT_DEBUG_TRACE
, ("Set::RT_OID_WPA_SUPPLICANT_SUPPORT (=%d)\n", pAdapter
->StaCfg
.WpaSupplicantUP
));
4310 case OID_802_11_DEAUTHENTICATION
:
4311 if (wrq
->u
.data
.length
!= sizeof(MLME_DEAUTH_REQ_STRUCT
))
4315 MLME_DEAUTH_REQ_STRUCT
*pInfo
;
4316 MLME_QUEUE_ELEM
*MsgElem
= (MLME_QUEUE_ELEM
*) kmalloc(sizeof(MLME_QUEUE_ELEM
), MEM_ALLOC_FLAG
);
4318 pInfo
= (MLME_DEAUTH_REQ_STRUCT
*) MsgElem
->Msg
;
4319 Status
= copy_from_user(pInfo
, wrq
->u
.data
.pointer
, wrq
->u
.data
.length
);
4320 MlmeDeauthReqAction(pAdapter
, MsgElem
);
4323 if (INFRA_ON(pAdapter
))
4325 LinkDown(pAdapter
, FALSE
);
4326 pAdapter
->Mlme
.AssocMachine
.CurrState
= ASSOC_IDLE
;
4328 DBGPRINT(RT_DEBUG_TRACE
, ("Set::OID_802_11_DEAUTHENTICATION (Reason=%d)\n", pInfo
->Reason
));
4331 case OID_802_11_DROP_UNENCRYPTED
:
4332 if (wrq
->u
.data
.length
!= sizeof(int))
4337 Status
= copy_from_user(&enabled
, wrq
->u
.data
.pointer
, wrq
->u
.data
.length
);
4339 pAdapter
->StaCfg
.PortSecured
= WPA_802_1X_PORT_NOT_SECURED
;
4341 pAdapter
->StaCfg
.PortSecured
= WPA_802_1X_PORT_SECURED
;
4342 NdisAcquireSpinLock(&pAdapter
->MacTabLock
);
4343 pAdapter
->MacTab
.Content
[BSSID_WCID
].PortSecured
= pAdapter
->StaCfg
.PortSecured
;
4344 NdisReleaseSpinLock(&pAdapter
->MacTabLock
);
4345 DBGPRINT(RT_DEBUG_TRACE
, ("Set::OID_802_11_DROP_UNENCRYPTED (=%d)\n", enabled
));
4348 case OID_802_11_SET_IEEE8021X
:
4349 if (wrq
->u
.data
.length
!= sizeof(BOOLEAN
))
4353 Status
= copy_from_user(&IEEE8021xState
, wrq
->u
.data
.pointer
, wrq
->u
.data
.length
);
4354 pAdapter
->StaCfg
.IEEE8021X
= IEEE8021xState
;
4355 DBGPRINT(RT_DEBUG_TRACE
, ("Set::OID_802_11_SET_IEEE8021X (=%d)\n", IEEE8021xState
));
4358 case OID_802_11_SET_IEEE8021X_REQUIRE_KEY
:
4359 if (wrq
->u
.data
.length
!= sizeof(BOOLEAN
))
4363 Status
= copy_from_user(&IEEE8021x_required_keys
, wrq
->u
.data
.pointer
, wrq
->u
.data
.length
);
4364 pAdapter
->StaCfg
.IEEE8021x_required_keys
= IEEE8021x_required_keys
;
4365 DBGPRINT(RT_DEBUG_TRACE
, ("Set::OID_802_11_SET_IEEE8021X_REQUIRE_KEY (%d)\n", IEEE8021x_required_keys
));
4368 case OID_802_11_PMKID
:
4369 pPmkId
= kmalloc(wrq
->u
.data
.length
, MEM_ALLOC_FLAG
);
4371 if(pPmkId
== NULL
) {
4375 Status
= copy_from_user(pPmkId
, wrq
->u
.data
.pointer
, wrq
->u
.data
.length
);
4377 // check the PMKID information
4378 if (pPmkId
->BSSIDInfoCount
== 0)
4379 NdisZeroMemory(pAdapter
->StaCfg
.SavedPMK
, sizeof(BSSID_INFO
)*PMKID_NO
);
4382 PBSSID_INFO pBssIdInfo
;
4386 for (BssIdx
= 0; BssIdx
< pPmkId
->BSSIDInfoCount
; BssIdx
++)
4388 // point to the indexed BSSID_INFO structure
4389 pBssIdInfo
= (PBSSID_INFO
) ((PUCHAR
) pPmkId
+ 2 * sizeof(UINT
) + BssIdx
* sizeof(BSSID_INFO
));
4390 // Find the entry in the saved data base.
4391 for (CachedIdx
= 0; CachedIdx
< pAdapter
->StaCfg
.SavedPMKNum
; CachedIdx
++)
4393 // compare the BSSID
4394 if (NdisEqualMemory(pBssIdInfo
->BSSID
, pAdapter
->StaCfg
.SavedPMK
[CachedIdx
].BSSID
, sizeof(NDIS_802_11_MAC_ADDRESS
)))
4398 // Found, replace it
4399 if (CachedIdx
< PMKID_NO
)
4401 DBGPRINT(RT_DEBUG_OFF
, ("Update OID_802_11_PMKID, idx = %d\n", CachedIdx
));
4402 NdisMoveMemory(&pAdapter
->StaCfg
.SavedPMK
[CachedIdx
], pBssIdInfo
, sizeof(BSSID_INFO
));
4403 pAdapter
->StaCfg
.SavedPMKNum
++;
4405 // Not found, replace the last one
4408 // Randomly replace one
4409 CachedIdx
= (pBssIdInfo
->BSSID
[5] % PMKID_NO
);
4410 DBGPRINT(RT_DEBUG_OFF
, ("Update OID_802_11_PMKID, idx = %d\n", CachedIdx
));
4411 NdisMoveMemory(&pAdapter
->StaCfg
.SavedPMK
[CachedIdx
], pBssIdInfo
, sizeof(BSSID_INFO
));
4418 #endif // WPA_SUPPLICANT_SUPPORT //
4423 case OID_802_11_SHORTRETRYLIMIT
:
4424 if (wrq
->u
.data
.length
!= sizeof(ULONG
))
4428 Status
= copy_from_user(&ShortRetryLimit
, wrq
->u
.data
.pointer
, wrq
->u
.data
.length
);
4429 RTMP_IO_READ32(pAdapter
, TX_RTY_CFG
, &tx_rty_cfg
.word
);
4430 tx_rty_cfg
.field
.ShortRtyLimit
= ShortRetryLimit
;
4431 RTMP_IO_WRITE32(pAdapter
, TX_RTY_CFG
, tx_rty_cfg
.word
);
4432 DBGPRINT(RT_DEBUG_TRACE
, ("Set::OID_802_11_SHORTRETRYLIMIT (tx_rty_cfg.field.ShortRetryLimit=%d, ShortRetryLimit=%ld)\n", tx_rty_cfg
.field
.ShortRtyLimit
, ShortRetryLimit
));
4436 case OID_802_11_LONGRETRYLIMIT
:
4437 DBGPRINT(RT_DEBUG_TRACE
, ("Set::OID_802_11_LONGRETRYLIMIT \n"));
4438 if (wrq
->u
.data
.length
!= sizeof(ULONG
))
4442 Status
= copy_from_user(&LongRetryLimit
, wrq
->u
.data
.pointer
, wrq
->u
.data
.length
);
4443 RTMP_IO_READ32(pAdapter
, TX_RTY_CFG
, &tx_rty_cfg
.word
);
4444 tx_rty_cfg
.field
.LongRtyLimit
= LongRetryLimit
;
4445 RTMP_IO_WRITE32(pAdapter
, TX_RTY_CFG
, tx_rty_cfg
.word
);
4446 DBGPRINT(RT_DEBUG_TRACE
, ("Set::OID_802_11_LONGRETRYLIMIT (tx_rty_cfg.field.LongRetryLimit= %d,LongRetryLimit=%ld)\n", tx_rty_cfg
.field
.LongRtyLimit
, LongRetryLimit
));
4450 case OID_802_11_WEPDEFAULTKEYVALUE
:
4451 DBGPRINT(RT_DEBUG_TRACE
, ("Set::OID_802_11_WEPDEFAULTKEYVALUE\n"));
4452 pKey
= kmalloc(wrq
->u
.data
.length
, GFP_KERNEL
);
4453 Status
= copy_from_user(pKey
, wrq
->u
.data
.pointer
, wrq
->u
.data
.length
);
4456 if ( pKey
->Length
!= wrq
->u
.data
.length
)
4459 DBGPRINT(RT_DEBUG_TRACE
, ("Set::OID_802_11_WEPDEFAULTKEYVALUE, Failed!!\n"));
4461 KeyIdx
= pKey
->KeyIndex
& 0x0fffffff;
4462 DBGPRINT(RT_DEBUG_TRACE
,("pKey->KeyIndex =%d, pKey->KeyLength=%d\n", pKey
->KeyIndex
, pKey
->KeyLength
));
4464 // it is a shared key
4469 pAdapter
->SharedKey
[BSS0
][pAdapter
->StaCfg
.DefaultKeyId
].KeyLen
= (UCHAR
) pKey
->KeyLength
;
4470 NdisMoveMemory(&pAdapter
->SharedKey
[BSS0
][pAdapter
->StaCfg
.DefaultKeyId
].Key
, &pKey
->KeyMaterial
, pKey
->KeyLength
);
4471 if (pKey
->KeyIndex
& 0x80000000)
4473 // Default key for tx (shared key)
4474 pAdapter
->StaCfg
.DefaultKeyId
= (UCHAR
) KeyIdx
;
4476 //RestartAPIsRequired = TRUE;
4481 case OID_802_11_WEPDEFAULTKEYID
:
4482 DBGPRINT(RT_DEBUG_TRACE
, ("Set::OID_802_11_WEPDEFAULTKEYID \n"));
4484 if (wrq
->u
.data
.length
!= sizeof(UCHAR
))
4487 Status
= copy_from_user(&pAdapter
->StaCfg
.DefaultKeyId
, wrq
->u
.data
.pointer
, wrq
->u
.data
.length
);
4492 case OID_802_11_CURRENTCHANNEL
:
4493 DBGPRINT(RT_DEBUG_TRACE
, ("Set::OID_802_11_CURRENTCHANNEL \n"));
4494 if (wrq
->u
.data
.length
!= sizeof(UCHAR
))
4498 Status
= copy_from_user(&ctmp
, wrq
->u
.data
.pointer
, wrq
->u
.data
.length
);
4499 sprintf(&ctmp
,"%d", ctmp
);
4500 Set_Channel_Proc(pAdapter
, &ctmp
);
4508 DBGPRINT(RT_DEBUG_TRACE
, ("Set::unknown IOCTL's subcmd = 0x%08x\n", cmd
));
4509 Status
= -EOPNOTSUPP
;
4517 INT
RTMPQueryInformation(
4518 IN PRTMP_ADAPTER pAdapter
,
4519 IN OUT
struct ifreq
*rq
,
4522 struct iwreq
*wrq
= (struct iwreq
*) rq
;
4523 NDIS_802_11_BSSID_LIST_EX
*pBssidList
= NULL
;
4524 PNDIS_WLAN_BSSID_EX pBss
;
4525 NDIS_802_11_SSID Ssid
;
4526 NDIS_802_11_CONFIGURATION
*pConfiguration
= NULL
;
4527 RT_802_11_LINK_STATUS
*pLinkStatus
= NULL
;
4528 RT_802_11_STA_CONFIG
*pStaConfig
= NULL
;
4529 NDIS_802_11_STATISTICS
*pStatistics
= NULL
;
4530 NDIS_802_11_RTS_THRESHOLD RtsThresh
;
4531 NDIS_802_11_FRAGMENTATION_THRESHOLD FragThresh
;
4532 NDIS_802_11_POWER_MODE PowerMode
;
4533 NDIS_802_11_NETWORK_INFRASTRUCTURE BssType
;
4534 RT_802_11_PREAMBLE PreamType
;
4535 NDIS_802_11_AUTHENTICATION_MODE AuthMode
;
4536 NDIS_802_11_WEP_STATUS WepStatus
;
4537 NDIS_MEDIA_STATE MediaState
;
4538 ULONG BssBufSize
, ulInfo
=0, NetworkTypeList
[4], apsd
= 0;
4540 PUCHAR pBuf
= NULL
, pPtr
;
4541 INT Status
= NDIS_STATUS_SUCCESS
;
4542 UINT we_version_compiled
;
4543 UCHAR i
, Padding
= 0;
4545 UCHAR driverVersion
[8];
4546 OID_SET_HT_PHYMODE
*pHTPhyMode
= NULL
;
4551 DefaultKeyIdxValue
*pKeyIdxValue
;
4553 TX_RTY_CFG_STRUC tx_rty_cfg
;
4554 ULONG ShortRetryLimit
, LongRetryLimit
;
4560 case RT_OID_DEVICE_NAME
:
4561 wrq
->u
.data
.length
= sizeof(STA_NIC_DEVICE_NAME
);
4562 Status
= copy_to_user(wrq
->u
.data
.pointer
, STA_NIC_DEVICE_NAME
, wrq
->u
.data
.length
);
4564 case RT_OID_VERSION_INFO
:
4565 DBGPRINT(RT_DEBUG_TRACE
, ("Query::RT_OID_VERSION_INFO \n"));
4566 wrq
->u
.data
.length
= 8*sizeof(UCHAR
);
4567 sprintf(&driverVersion
[0], "%s", STA_DRIVER_VERSION
);
4568 driverVersion
[7] = '\0';
4569 if (copy_to_user(wrq
->u
.data
.pointer
, &driverVersion
, wrq
->u
.data
.length
))
4575 case RT_QUERY_ATE_TXDONE_COUNT
:
4576 DBGPRINT(RT_DEBUG_TRACE
, ("Query::RT_QUERY_ATE_TXDONE_COUNT \n"));
4577 wrq
->u
.data
.length
= sizeof(UINT32
);
4578 if (copy_to_user(wrq
->u
.data
.pointer
, &pAdapter
->ate
.TxDoneCount
, wrq
->u
.data
.length
))
4583 #endif // RALINK_ATE //
4584 case OID_802_11_BSSID_LIST
:
4585 if (RTMP_TEST_FLAG(pAdapter
, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS
))
4588 * Still scanning, indicate the caller should try again.
4590 DBGPRINT(RT_DEBUG_TRACE
, ("Query::OID_802_11_BSSID_LIST (Still scanning)\n"));
4593 DBGPRINT(RT_DEBUG_TRACE
, ("Query::OID_802_11_BSSID_LIST (%d BSS returned)\n",pAdapter
->ScanTab
.BssNr
));
4594 pAdapter
->StaCfg
.bScanReqIsFromWebUI
= FALSE
;
4595 // Claculate total buffer size required
4596 BssBufSize
= sizeof(ULONG
);
4598 for (i
= 0; i
< pAdapter
->ScanTab
.BssNr
; i
++)
4600 // Align pointer to 4 bytes boundary.
4601 //Padding = 4 - (pAdapter->ScanTab.BssEntry[i].VarIELen & 0x0003);
4604 BssBufSize
+= (sizeof(NDIS_WLAN_BSSID_EX
) - 1 + sizeof(NDIS_802_11_FIXED_IEs
) + pAdapter
->ScanTab
.BssEntry
[i
].VarIELen
+ Padding
);
4607 // For safety issue, we add 256 bytes just in case
4609 // Allocate the same size as passed from higher layer
4610 pBuf
= kmalloc(BssBufSize
, MEM_ALLOC_FLAG
);
4616 // Init 802_11_BSSID_LIST_EX structure
4617 NdisZeroMemory(pBuf
, BssBufSize
);
4618 pBssidList
= (PNDIS_802_11_BSSID_LIST_EX
) pBuf
;
4619 pBssidList
->NumberOfItems
= pAdapter
->ScanTab
.BssNr
;
4621 // Calculate total buffer length
4622 BssLen
= 4; // Consist of NumberOfItems
4623 // Point to start of NDIS_WLAN_BSSID_EX
4624 // pPtr = pBuf + sizeof(ULONG);
4625 pPtr
= (PUCHAR
) &pBssidList
->Bssid
[0];
4626 for (i
= 0; i
< pAdapter
->ScanTab
.BssNr
; i
++)
4628 pBss
= (PNDIS_WLAN_BSSID_EX
) pPtr
;
4629 NdisMoveMemory(&pBss
->MacAddress
, &pAdapter
->ScanTab
.BssEntry
[i
].Bssid
, MAC_ADDR_LEN
);
4630 if ((pAdapter
->ScanTab
.BssEntry
[i
].Hidden
== 1) && (pAdapter
->StaCfg
.bShowHiddenSSID
== FALSE
))
4633 // We must return this SSID during 4way handshaking, otherwise Aegis will failed to parse WPA infomation
4634 // and then failed to send EAPOl farame.
4636 if ((pAdapter
->StaCfg
.AuthMode
>= Ndis802_11AuthModeWPA
) && (pAdapter
->StaCfg
.PortSecured
!= WPA_802_1X_PORT_SECURED
))
4638 pBss
->Ssid
.SsidLength
= pAdapter
->ScanTab
.BssEntry
[i
].SsidLen
;
4639 NdisMoveMemory(pBss
->Ssid
.Ssid
, pAdapter
->ScanTab
.BssEntry
[i
].Ssid
, pAdapter
->ScanTab
.BssEntry
[i
].SsidLen
);
4642 pBss
->Ssid
.SsidLength
= 0;
4646 pBss
->Ssid
.SsidLength
= pAdapter
->ScanTab
.BssEntry
[i
].SsidLen
;
4647 NdisMoveMemory(pBss
->Ssid
.Ssid
, pAdapter
->ScanTab
.BssEntry
[i
].Ssid
, pAdapter
->ScanTab
.BssEntry
[i
].SsidLen
);
4649 pBss
->Privacy
= pAdapter
->ScanTab
.BssEntry
[i
].Privacy
;
4650 pBss
->Rssi
= pAdapter
->ScanTab
.BssEntry
[i
].Rssi
- pAdapter
->BbpRssiToDbmDelta
;
4651 pBss
->NetworkTypeInUse
= NetworkTypeInUseSanity(&pAdapter
->ScanTab
.BssEntry
[i
]);
4652 pBss
->Configuration
.Length
= sizeof(NDIS_802_11_CONFIGURATION
);
4653 pBss
->Configuration
.BeaconPeriod
= pAdapter
->ScanTab
.BssEntry
[i
].BeaconPeriod
;
4654 pBss
->Configuration
.ATIMWindow
= pAdapter
->ScanTab
.BssEntry
[i
].AtimWin
;
4656 MAP_CHANNEL_ID_TO_KHZ(pAdapter
->ScanTab
.BssEntry
[i
].Channel
, pBss
->Configuration
.DSConfig
);
4658 if (pAdapter
->ScanTab
.BssEntry
[i
].BssType
== BSS_INFRA
)
4659 pBss
->InfrastructureMode
= Ndis802_11Infrastructure
;
4661 pBss
->InfrastructureMode
= Ndis802_11IBSS
;
4663 NdisMoveMemory(pBss
->SupportedRates
, pAdapter
->ScanTab
.BssEntry
[i
].SupRate
, pAdapter
->ScanTab
.BssEntry
[i
].SupRateLen
);
4664 NdisMoveMemory(pBss
->SupportedRates
+ pAdapter
->ScanTab
.BssEntry
[i
].SupRateLen
,
4665 pAdapter
->ScanTab
.BssEntry
[i
].ExtRate
,
4666 pAdapter
->ScanTab
.BssEntry
[i
].ExtRateLen
);
4668 if (pAdapter
->ScanTab
.BssEntry
[i
].VarIELen
== 0)
4670 pBss
->IELength
= sizeof(NDIS_802_11_FIXED_IEs
);
4671 NdisMoveMemory(pBss
->IEs
, &pAdapter
->ScanTab
.BssEntry
[i
].FixIEs
, sizeof(NDIS_802_11_FIXED_IEs
));
4672 pPtr
= pPtr
+ sizeof(NDIS_WLAN_BSSID_EX
) - 1 + sizeof(NDIS_802_11_FIXED_IEs
);
4676 pBss
->IELength
= (ULONG
)(sizeof(NDIS_802_11_FIXED_IEs
) + pAdapter
->ScanTab
.BssEntry
[i
].VarIELen
);
4677 pPtr
= pPtr
+ sizeof(NDIS_WLAN_BSSID_EX
) - 1 + sizeof(NDIS_802_11_FIXED_IEs
);
4678 NdisMoveMemory(pBss
->IEs
, &pAdapter
->ScanTab
.BssEntry
[i
].FixIEs
, sizeof(NDIS_802_11_FIXED_IEs
));
4679 NdisMoveMemory(pBss
->IEs
+ sizeof(NDIS_802_11_FIXED_IEs
), pAdapter
->ScanTab
.BssEntry
[i
].VarIEs
, pAdapter
->ScanTab
.BssEntry
[i
].VarIELen
);
4680 pPtr
+= pAdapter
->ScanTab
.BssEntry
[i
].VarIELen
;
4682 pBss
->Length
= (ULONG
)(sizeof(NDIS_WLAN_BSSID_EX
) - 1 + sizeof(NDIS_802_11_FIXED_IEs
) + pAdapter
->ScanTab
.BssEntry
[i
].VarIELen
+ Padding
);
4684 #if WIRELESS_EXT < 17
4685 if ((BssLen
+ pBss
->Length
) < wrq
->u
.data
.length
)
4686 BssLen
+= pBss
->Length
;
4689 pBssidList
->NumberOfItems
= i
;
4693 BssLen
+= pBss
->Length
;
4697 #if WIRELESS_EXT < 17
4698 wrq
->u
.data
.length
= BssLen
;
4700 if (BssLen
> wrq
->u
.data
.length
)
4706 wrq
->u
.data
.length
= BssLen
;
4708 Status
= copy_to_user(wrq
->u
.data
.pointer
, pBssidList
, BssLen
);
4711 case OID_802_3_CURRENT_ADDRESS
:
4712 wrq
->u
.data
.length
= MAC_ADDR_LEN
;
4713 Status
= copy_to_user(wrq
->u
.data
.pointer
, &pAdapter
->CurrentAddress
, wrq
->u
.data
.length
);
4715 case OID_GEN_MEDIA_CONNECT_STATUS
:
4716 if (pAdapter
->IndicateMediaState
== NdisMediaStateConnected
)
4717 MediaState
= NdisMediaStateConnected
;
4719 MediaState
= NdisMediaStateDisconnected
;
4721 wrq
->u
.data
.length
= sizeof(NDIS_MEDIA_STATE
);
4722 Status
= copy_to_user(wrq
->u
.data
.pointer
, &MediaState
, wrq
->u
.data
.length
);
4724 case OID_802_11_BSSID
:
4726 if (ATE_ON(pAdapter
))
4728 DBGPRINT(RT_DEBUG_TRACE
, ("The driver is in ATE mode now\n"));
4729 Status
= NDIS_STATUS_RESOURCES
;
4732 #endif // RALINK_ATE //
4733 if (INFRA_ON(pAdapter
) || ADHOC_ON(pAdapter
))
4735 Status
= copy_to_user(wrq
->u
.data
.pointer
, &pAdapter
->CommonCfg
.Bssid
, sizeof(NDIS_802_11_MAC_ADDRESS
));
4740 DBGPRINT(RT_DEBUG_TRACE
, ("Query::OID_802_11_BSSID(=EMPTY)\n"));
4744 case OID_802_11_SSID
:
4745 NdisZeroMemory(&Ssid
, sizeof(NDIS_802_11_SSID
));
4746 NdisZeroMemory(Ssid
.Ssid
, MAX_LEN_OF_SSID
);
4747 Ssid
.SsidLength
= pAdapter
->CommonCfg
.SsidLen
;
4748 memcpy(Ssid
.Ssid
, pAdapter
->CommonCfg
.Ssid
, Ssid
.SsidLength
);
4749 wrq
->u
.data
.length
= sizeof(NDIS_802_11_SSID
);
4750 Status
= copy_to_user(wrq
->u
.data
.pointer
, &Ssid
, wrq
->u
.data
.length
);
4751 DBGPRINT(RT_DEBUG_TRACE
, ("Query::OID_802_11_SSID (Len=%d, ssid=%s)\n", Ssid
.SsidLength
,Ssid
.Ssid
));
4753 case RT_OID_802_11_QUERY_LINK_STATUS
:
4754 pLinkStatus
= (RT_802_11_LINK_STATUS
*) kmalloc(sizeof(RT_802_11_LINK_STATUS
), MEM_ALLOC_FLAG
);
4757 pLinkStatus
->CurrTxRate
= RateIdTo500Kbps
[pAdapter
->CommonCfg
.TxRate
]; // unit : 500 kbps
4758 pLinkStatus
->ChannelQuality
= pAdapter
->Mlme
.ChannelQuality
;
4759 pLinkStatus
->RxByteCount
= pAdapter
->RalinkCounters
.ReceivedByteCount
;
4760 pLinkStatus
->TxByteCount
= pAdapter
->RalinkCounters
.TransmittedByteCount
;
4761 pLinkStatus
->CentralChannel
= pAdapter
->CommonCfg
.CentralChannel
;
4762 wrq
->u
.data
.length
= sizeof(RT_802_11_LINK_STATUS
);
4763 Status
= copy_to_user(wrq
->u
.data
.pointer
, pLinkStatus
, wrq
->u
.data
.length
);
4765 DBGPRINT(RT_DEBUG_TRACE
, ("Query::RT_OID_802_11_QUERY_LINK_STATUS\n"));
4769 DBGPRINT(RT_DEBUG_TRACE
, ("Query::RT_OID_802_11_QUERY_LINK_STATUS(kmalloc failed)\n"));
4773 case OID_802_11_CONFIGURATION
:
4774 pConfiguration
= (NDIS_802_11_CONFIGURATION
*) kmalloc(sizeof(NDIS_802_11_CONFIGURATION
), MEM_ALLOC_FLAG
);
4777 pConfiguration
->Length
= sizeof(NDIS_802_11_CONFIGURATION
);
4778 pConfiguration
->BeaconPeriod
= pAdapter
->CommonCfg
.BeaconPeriod
;
4779 pConfiguration
->ATIMWindow
= pAdapter
->StaActive
.AtimWin
;
4780 MAP_CHANNEL_ID_TO_KHZ(pAdapter
->CommonCfg
.Channel
, pConfiguration
->DSConfig
);
4781 wrq
->u
.data
.length
= sizeof(NDIS_802_11_CONFIGURATION
);
4782 Status
= copy_to_user(wrq
->u
.data
.pointer
, pConfiguration
, wrq
->u
.data
.length
);
4783 DBGPRINT(RT_DEBUG_TRACE
, ("Query::OID_802_11_CONFIGURATION(BeaconPeriod=%ld,AtimW=%ld,Channel=%d) \n",
4784 pConfiguration
->BeaconPeriod
, pConfiguration
->ATIMWindow
, pAdapter
->CommonCfg
.Channel
));
4785 kfree(pConfiguration
);
4789 DBGPRINT(RT_DEBUG_TRACE
, ("Query::OID_802_11_CONFIGURATION(kmalloc failed)\n"));
4793 case RT_OID_802_11_SNR_0
:
4794 if ((pAdapter
->StaCfg
.LastSNR0
> 0))
4796 ulInfo
= ((0xeb - pAdapter
->StaCfg
.LastSNR0
) * 3) / 16 ;
4797 wrq
->u
.data
.length
= sizeof(ulInfo
);
4798 Status
= copy_to_user(wrq
->u
.data
.pointer
, &ulInfo
, wrq
->u
.data
.length
);
4799 DBGPRINT(RT_DEBUG_TRACE
, ("Query::RT_OID_802_11_SNR_0(0x=%lx)\n", ulInfo
));
4804 case RT_OID_802_11_SNR_1
:
4805 if ((pAdapter
->Antenna
.field
.RxPath
> 1) &&
4806 (pAdapter
->StaCfg
.LastSNR1
> 0))
4808 ulInfo
= ((0xeb - pAdapter
->StaCfg
.LastSNR1
) * 3) / 16 ;
4809 wrq
->u
.data
.length
= sizeof(ulInfo
);
4810 Status
= copy_to_user(wrq
->u
.data
.pointer
, &ulInfo
, wrq
->u
.data
.length
);
4811 DBGPRINT(RT_DEBUG_TRACE
,("Query::RT_OID_802_11_SNR_1(0x=%lx)\n",ulInfo
));
4815 DBGPRINT(RT_DEBUG_TRACE
,("Query::RT_OID_802_11_SNR_1(pAdapter->StaCfg.LastSNR1=%d)\n",pAdapter
->StaCfg
.LastSNR1
));
4817 case OID_802_11_RSSI_TRIGGER
:
4818 ulInfo
= pAdapter
->StaCfg
.RssiSample
.LastRssi0
- pAdapter
->BbpRssiToDbmDelta
;
4819 wrq
->u
.data
.length
= sizeof(ulInfo
);
4820 Status
= copy_to_user(wrq
->u
.data
.pointer
, &ulInfo
, wrq
->u
.data
.length
);
4821 DBGPRINT(RT_DEBUG_TRACE
, ("Query::OID_802_11_RSSI_TRIGGER(=%ld)\n", ulInfo
));
4823 case OID_802_11_RSSI
:
4824 case RT_OID_802_11_RSSI
:
4825 ulInfo
= pAdapter
->StaCfg
.RssiSample
.LastRssi0
;
4826 wrq
->u
.data
.length
= sizeof(ulInfo
);
4827 Status
= copy_to_user(wrq
->u
.data
.pointer
, &ulInfo
, wrq
->u
.data
.length
);
4829 case RT_OID_802_11_RSSI_1
:
4830 ulInfo
= pAdapter
->StaCfg
.RssiSample
.LastRssi1
;
4831 wrq
->u
.data
.length
= sizeof(ulInfo
);
4832 Status
= copy_to_user(wrq
->u
.data
.pointer
, &ulInfo
, wrq
->u
.data
.length
);
4834 case RT_OID_802_11_RSSI_2
:
4835 ulInfo
= pAdapter
->StaCfg
.RssiSample
.LastRssi2
;
4836 wrq
->u
.data
.length
= sizeof(ulInfo
);
4837 Status
= copy_to_user(wrq
->u
.data
.pointer
, &ulInfo
, wrq
->u
.data
.length
);
4839 case OID_802_11_STATISTICS
:
4840 pStatistics
= (NDIS_802_11_STATISTICS
*) kmalloc(sizeof(NDIS_802_11_STATISTICS
), MEM_ALLOC_FLAG
);
4843 DBGPRINT(RT_DEBUG_TRACE
, ("Query::OID_802_11_STATISTICS \n"));
4844 // add the most up-to-date h/w raw counters into software counters
4845 NICUpdateRawCounters(pAdapter
);
4847 // Sanity check for calculation of sucessful count
4848 if (pAdapter
->WlanCounters
.TransmittedFragmentCount
.QuadPart
< pAdapter
->WlanCounters
.RetryCount
.QuadPart
)
4849 pAdapter
->WlanCounters
.TransmittedFragmentCount
.QuadPart
= pAdapter
->WlanCounters
.RetryCount
.QuadPart
;
4851 pStatistics
->TransmittedFragmentCount
.QuadPart
= pAdapter
->WlanCounters
.TransmittedFragmentCount
.QuadPart
;
4852 pStatistics
->MulticastTransmittedFrameCount
.QuadPart
= pAdapter
->WlanCounters
.MulticastTransmittedFrameCount
.QuadPart
;
4853 pStatistics
->FailedCount
.QuadPart
= pAdapter
->WlanCounters
.FailedCount
.QuadPart
;
4854 pStatistics
->RetryCount
.QuadPart
= pAdapter
->WlanCounters
.RetryCount
.QuadPart
;
4855 pStatistics
->MultipleRetryCount
.QuadPart
= pAdapter
->WlanCounters
.MultipleRetryCount
.QuadPart
;
4856 pStatistics
->RTSSuccessCount
.QuadPart
= pAdapter
->WlanCounters
.RTSSuccessCount
.QuadPart
;
4857 pStatistics
->RTSFailureCount
.QuadPart
= pAdapter
->WlanCounters
.RTSFailureCount
.QuadPart
;
4858 pStatistics
->ACKFailureCount
.QuadPart
= pAdapter
->WlanCounters
.ACKFailureCount
.QuadPart
;
4859 pStatistics
->FrameDuplicateCount
.QuadPart
= pAdapter
->WlanCounters
.FrameDuplicateCount
.QuadPart
;
4860 pStatistics
->ReceivedFragmentCount
.QuadPart
= pAdapter
->WlanCounters
.ReceivedFragmentCount
.QuadPart
;
4861 pStatistics
->MulticastReceivedFrameCount
.QuadPart
= pAdapter
->WlanCounters
.MulticastReceivedFrameCount
.QuadPart
;
4863 pStatistics
->FCSErrorCount
= pAdapter
->RalinkCounters
.RealFcsErrCount
;
4865 pStatistics
->FCSErrorCount
.QuadPart
= pAdapter
->WlanCounters
.FCSErrorCount
.QuadPart
;
4866 pStatistics
->FrameDuplicateCount
.u
.LowPart
= pAdapter
->WlanCounters
.FrameDuplicateCount
.u
.LowPart
/ 100;
4868 wrq
->u
.data
.length
= sizeof(NDIS_802_11_STATISTICS
);
4869 Status
= copy_to_user(wrq
->u
.data
.pointer
, pStatistics
, wrq
->u
.data
.length
);
4874 DBGPRINT(RT_DEBUG_TRACE
, ("Query::OID_802_11_STATISTICS(kmalloc failed)\n"));
4878 case OID_GEN_RCV_OK
:
4879 ulInfo
= pAdapter
->Counters8023
.GoodReceives
;
4880 wrq
->u
.data
.length
= sizeof(ulInfo
);
4881 Status
= copy_to_user(wrq
->u
.data
.pointer
, &ulInfo
, wrq
->u
.data
.length
);
4883 case OID_GEN_RCV_NO_BUFFER
:
4884 ulInfo
= pAdapter
->Counters8023
.RxNoBuffer
;
4885 wrq
->u
.data
.length
= sizeof(ulInfo
);
4886 Status
= copy_to_user(wrq
->u
.data
.pointer
, &ulInfo
, wrq
->u
.data
.length
);
4888 case RT_OID_802_11_PHY_MODE
:
4889 ulInfo
= (ULONG
)pAdapter
->CommonCfg
.PhyMode
;
4890 wrq
->u
.data
.length
= sizeof(ulInfo
);
4891 Status
= copy_to_user(wrq
->u
.data
.pointer
, &ulInfo
, wrq
->u
.data
.length
);
4892 DBGPRINT(RT_DEBUG_TRACE
, ("Query::RT_OID_802_11_PHY_MODE (=%ld)\n", ulInfo
));
4894 case RT_OID_802_11_STA_CONFIG
:
4895 pStaConfig
= (RT_802_11_STA_CONFIG
*) kmalloc(sizeof(RT_802_11_STA_CONFIG
), MEM_ALLOC_FLAG
);
4898 DBGPRINT(RT_DEBUG_TRACE
, ("Query::RT_OID_802_11_STA_CONFIG\n"));
4899 pStaConfig
->EnableTxBurst
= pAdapter
->CommonCfg
.bEnableTxBurst
;
4900 pStaConfig
->EnableTurboRate
= 0;
4901 pStaConfig
->UseBGProtection
= pAdapter
->CommonCfg
.UseBGProtection
;
4902 pStaConfig
->UseShortSlotTime
= pAdapter
->CommonCfg
.bUseShortSlotTime
;
4903 //pStaConfig->AdhocMode = pAdapter->StaCfg.AdhocMode;
4904 pStaConfig
->HwRadioStatus
= (pAdapter
->StaCfg
.bHwRadio
== TRUE
) ? 1 : 0;
4905 pStaConfig
->Rsv1
= 0;
4906 pStaConfig
->SystemErrorBitmap
= pAdapter
->SystemErrorBitmap
;
4907 wrq
->u
.data
.length
= sizeof(RT_802_11_STA_CONFIG
);
4908 Status
= copy_to_user(wrq
->u
.data
.pointer
, pStaConfig
, wrq
->u
.data
.length
);
4913 DBGPRINT(RT_DEBUG_TRACE
, ("Query::RT_OID_802_11_STA_CONFIG(kmalloc failed)\n"));
4917 case OID_802_11_RTS_THRESHOLD
:
4918 RtsThresh
= pAdapter
->CommonCfg
.RtsThreshold
;
4919 wrq
->u
.data
.length
= sizeof(RtsThresh
);
4920 Status
= copy_to_user(wrq
->u
.data
.pointer
, &RtsThresh
, wrq
->u
.data
.length
);
4921 DBGPRINT(RT_DEBUG_TRACE
, ("Query::OID_802_11_RTS_THRESHOLD(=%ld)\n", RtsThresh
));
4923 case OID_802_11_FRAGMENTATION_THRESHOLD
:
4924 FragThresh
= pAdapter
->CommonCfg
.FragmentThreshold
;
4925 if (pAdapter
->CommonCfg
.bUseZeroToDisableFragment
== TRUE
)
4927 wrq
->u
.data
.length
= sizeof(FragThresh
);
4928 Status
= copy_to_user(wrq
->u
.data
.pointer
, &FragThresh
, wrq
->u
.data
.length
);
4929 DBGPRINT(RT_DEBUG_TRACE
, ("Query::OID_802_11_FRAGMENTATION_THRESHOLD(=%ld)\n", FragThresh
));
4931 case OID_802_11_POWER_MODE
:
4932 PowerMode
= pAdapter
->StaCfg
.WindowsPowerMode
;
4933 wrq
->u
.data
.length
= sizeof(PowerMode
);
4934 Status
= copy_to_user(wrq
->u
.data
.pointer
, &PowerMode
, wrq
->u
.data
.length
);
4935 DBGPRINT(RT_DEBUG_TRACE
, ("Query::OID_802_11_POWER_MODE(=%d)\n", PowerMode
));
4937 case RT_OID_802_11_RADIO
:
4938 RadioState
= (BOOLEAN
) pAdapter
->StaCfg
.bSwRadio
;
4939 wrq
->u
.data
.length
= sizeof(RadioState
);
4940 Status
= copy_to_user(wrq
->u
.data
.pointer
, &RadioState
, wrq
->u
.data
.length
);
4941 DBGPRINT(RT_DEBUG_TRACE
, ("Query::RT_OID_802_11_QUERY_RADIO (=%d)\n", RadioState
));
4943 case OID_802_11_INFRASTRUCTURE_MODE
:
4944 if (pAdapter
->StaCfg
.BssType
== BSS_ADHOC
)
4945 BssType
= Ndis802_11IBSS
;
4946 else if (pAdapter
->StaCfg
.BssType
== BSS_INFRA
)
4947 BssType
= Ndis802_11Infrastructure
;
4948 else if (pAdapter
->StaCfg
.BssType
== BSS_MONITOR
)
4949 BssType
= Ndis802_11Monitor
;
4951 BssType
= Ndis802_11AutoUnknown
;
4953 wrq
->u
.data
.length
= sizeof(BssType
);
4954 Status
= copy_to_user(wrq
->u
.data
.pointer
, &BssType
, wrq
->u
.data
.length
);
4955 DBGPRINT(RT_DEBUG_TRACE
, ("Query::OID_802_11_INFRASTRUCTURE_MODE(=%d)\n", BssType
));
4957 case RT_OID_802_11_PREAMBLE
:
4958 PreamType
= pAdapter
->CommonCfg
.TxPreamble
;
4959 wrq
->u
.data
.length
= sizeof(PreamType
);
4960 Status
= copy_to_user(wrq
->u
.data
.pointer
, &PreamType
, wrq
->u
.data
.length
);
4961 DBGPRINT(RT_DEBUG_TRACE
, ("Query::RT_OID_802_11_PREAMBLE(=%d)\n", PreamType
));
4963 case OID_802_11_AUTHENTICATION_MODE
:
4964 AuthMode
= pAdapter
->StaCfg
.AuthMode
;
4965 wrq
->u
.data
.length
= sizeof(AuthMode
);
4966 Status
= copy_to_user(wrq
->u
.data
.pointer
, &AuthMode
, wrq
->u
.data
.length
);
4967 DBGPRINT(RT_DEBUG_TRACE
, ("Query::OID_802_11_AUTHENTICATION_MODE(=%d)\n", AuthMode
));
4969 case OID_802_11_WEP_STATUS
:
4970 WepStatus
= pAdapter
->StaCfg
.WepStatus
;
4971 wrq
->u
.data
.length
= sizeof(WepStatus
);
4972 Status
= copy_to_user(wrq
->u
.data
.pointer
, &WepStatus
, wrq
->u
.data
.length
);
4973 DBGPRINT(RT_DEBUG_TRACE
, ("Query::OID_802_11_WEP_STATUS(=%d)\n", WepStatus
));
4975 case OID_802_11_TX_POWER_LEVEL
:
4976 wrq
->u
.data
.length
= sizeof(ULONG
);
4977 Status
= copy_to_user(wrq
->u
.data
.pointer
, &pAdapter
->CommonCfg
.TxPower
, wrq
->u
.data
.length
);
4978 DBGPRINT(RT_DEBUG_TRACE
, ("Query::OID_802_11_TX_POWER_LEVEL %x\n",pAdapter
->CommonCfg
.TxPower
));
4980 case RT_OID_802_11_TX_POWER_LEVEL_1
:
4981 wrq
->u
.data
.length
= sizeof(ULONG
);
4982 Status
= copy_to_user(wrq
->u
.data
.pointer
, &pAdapter
->CommonCfg
.TxPowerPercentage
, wrq
->u
.data
.length
);
4983 DBGPRINT(RT_DEBUG_TRACE
, ("Query::RT_OID_802_11_TX_POWER_LEVEL_1 (=%ld)\n", pAdapter
->CommonCfg
.TxPowerPercentage
));
4985 case OID_802_11_NETWORK_TYPES_SUPPORTED
:
4986 if ((pAdapter
->RfIcType
== RFIC_2850
) || (pAdapter
->RfIcType
== RFIC_2750
))
4988 NetworkTypeList
[0] = 3; // NumberOfItems = 3
4989 NetworkTypeList
[1] = Ndis802_11DS
; // NetworkType[1] = 11b
4990 NetworkTypeList
[2] = Ndis802_11OFDM24
; // NetworkType[2] = 11g
4991 NetworkTypeList
[3] = Ndis802_11OFDM5
; // NetworkType[3] = 11a
4992 wrq
->u
.data
.length
= 16;
4993 Status
= copy_to_user(wrq
->u
.data
.pointer
, &NetworkTypeList
[0], wrq
->u
.data
.length
);
4997 NetworkTypeList
[0] = 2; // NumberOfItems = 2
4998 NetworkTypeList
[1] = Ndis802_11DS
; // NetworkType[1] = 11b
4999 NetworkTypeList
[2] = Ndis802_11OFDM24
; // NetworkType[2] = 11g
5000 wrq
->u
.data
.length
= 12;
5001 Status
= copy_to_user(wrq
->u
.data
.pointer
, &NetworkTypeList
[0], wrq
->u
.data
.length
);
5003 DBGPRINT(RT_DEBUG_TRACE
, ("Query::OID_802_11_NETWORK_TYPES_SUPPORTED\n"));
5005 case OID_802_11_NETWORK_TYPE_IN_USE
:
5006 wrq
->u
.data
.length
= sizeof(ULONG
);
5007 if (pAdapter
->CommonCfg
.PhyMode
== PHY_11A
)
5008 ulInfo
= Ndis802_11OFDM5
;
5009 else if ((pAdapter
->CommonCfg
.PhyMode
== PHY_11BG_MIXED
) || (pAdapter
->CommonCfg
.PhyMode
== PHY_11G
))
5010 ulInfo
= Ndis802_11OFDM24
;
5012 ulInfo
= Ndis802_11DS
;
5013 Status
= copy_to_user(wrq
->u
.data
.pointer
, &ulInfo
, wrq
->u
.data
.length
);
5015 case RT_OID_802_11_QUERY_LAST_RX_RATE
:
5016 ulInfo
= (ULONG
)pAdapter
->LastRxRate
;
5017 wrq
->u
.data
.length
= sizeof(ulInfo
);
5018 Status
= copy_to_user(wrq
->u
.data
.pointer
, &ulInfo
, wrq
->u
.data
.length
);
5019 DBGPRINT(RT_DEBUG_TRACE
, ("Query::RT_OID_802_11_QUERY_LAST_RX_RATE (=%ld)\n", ulInfo
));
5021 case RT_OID_802_11_QUERY_LAST_TX_RATE
:
5022 //ulInfo = (ULONG)pAdapter->LastTxRate;
5023 ulInfo
= (ULONG
)pAdapter
->MacTab
.Content
[BSSID_WCID
].HTPhyMode
.word
;
5024 wrq
->u
.data
.length
= sizeof(ulInfo
);
5025 Status
= copy_to_user(wrq
->u
.data
.pointer
, &ulInfo
, wrq
->u
.data
.length
);
5026 DBGPRINT(RT_DEBUG_TRACE
, ("Query::RT_OID_802_11_QUERY_LAST_TX_RATE (=%lx)\n", ulInfo
));
5028 case RT_OID_802_11_QUERY_EEPROM_VERSION
:
5029 wrq
->u
.data
.length
= sizeof(ULONG
);
5030 Status
= copy_to_user(wrq
->u
.data
.pointer
, &pAdapter
->EepromVersion
, wrq
->u
.data
.length
);
5032 case RT_OID_802_11_QUERY_FIRMWARE_VERSION
:
5033 wrq
->u
.data
.length
= sizeof(ULONG
);
5034 Status
= copy_to_user(wrq
->u
.data
.pointer
, &pAdapter
->FirmwareVersion
, wrq
->u
.data
.length
);
5036 case RT_OID_802_11_QUERY_NOISE_LEVEL
:
5037 wrq
->u
.data
.length
= sizeof(UCHAR
);
5038 Status
= copy_to_user(wrq
->u
.data
.pointer
, &pAdapter
->BbpWriteLatch
[66], wrq
->u
.data
.length
);
5039 DBGPRINT(RT_DEBUG_TRACE
, ("Query::RT_OID_802_11_QUERY_NOISE_LEVEL (=%d)\n", pAdapter
->BbpWriteLatch
[66]));
5041 case RT_OID_802_11_EXTRA_INFO
:
5042 wrq
->u
.data
.length
= sizeof(ULONG
);
5043 Status
= copy_to_user(wrq
->u
.data
.pointer
, &pAdapter
->ExtraInfo
, wrq
->u
.data
.length
);
5044 DBGPRINT(RT_DEBUG_TRACE
, ("Query::RT_OID_802_11_EXTRA_INFO (=%ld)\n", pAdapter
->ExtraInfo
));
5046 case RT_OID_WE_VERSION_COMPILED
:
5047 wrq
->u
.data
.length
= sizeof(UINT
);
5048 we_version_compiled
= WIRELESS_EXT
;
5049 Status
= copy_to_user(wrq
->u
.data
.pointer
, &we_version_compiled
, wrq
->u
.data
.length
);
5051 case RT_OID_802_11_QUERY_APSD_SETTING
:
5052 apsd
= (pAdapter
->CommonCfg
.bAPSDCapable
| (pAdapter
->CommonCfg
.bAPSDAC_BE
<< 1) | (pAdapter
->CommonCfg
.bAPSDAC_BK
<< 2)
5053 | (pAdapter
->CommonCfg
.bAPSDAC_VI
<< 3) | (pAdapter
->CommonCfg
.bAPSDAC_VO
<< 4) | (pAdapter
->CommonCfg
.MaxSPLength
<< 5));
5055 wrq
->u
.data
.length
= sizeof(ULONG
);
5056 Status
= copy_to_user(wrq
->u
.data
.pointer
, &apsd
, wrq
->u
.data
.length
);
5057 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",
5058 apsd
,pAdapter
->CommonCfg
.bAPSDCapable
,pAdapter
->CommonCfg
.bAPSDAC_BE
,pAdapter
->CommonCfg
.bAPSDAC_BK
,pAdapter
->CommonCfg
.bAPSDAC_VI
,pAdapter
->CommonCfg
.bAPSDAC_VO
,pAdapter
->CommonCfg
.MaxSPLength
));
5060 case RT_OID_802_11_QUERY_APSD_PSM
:
5061 wrq
->u
.data
.length
= sizeof(ULONG
);
5062 Status
= copy_to_user(wrq
->u
.data
.pointer
, &pAdapter
->CommonCfg
.bAPSDForcePowerSave
, wrq
->u
.data
.length
);
5063 DBGPRINT(RT_DEBUG_TRACE
, ("Query::RT_OID_802_11_QUERY_APSD_PSM (=%d)\n", pAdapter
->CommonCfg
.bAPSDForcePowerSave
));
5065 case RT_OID_802_11_QUERY_WMM
:
5066 wrq
->u
.data
.length
= sizeof(BOOLEAN
);
5067 Status
= copy_to_user(wrq
->u
.data
.pointer
, &pAdapter
->CommonCfg
.bWmmCapable
, wrq
->u
.data
.length
);
5068 DBGPRINT(RT_DEBUG_TRACE
, ("Query::RT_OID_802_11_QUERY_WMM (=%d)\n", pAdapter
->CommonCfg
.bWmmCapable
));
5070 #ifdef WPA_SUPPLICANT_SUPPORT
5071 case RT_OID_NEW_DRIVER
:
5074 wrq
->u
.data
.length
= sizeof(UCHAR
);
5075 Status
= copy_to_user(wrq
->u
.data
.pointer
, &enabled
, wrq
->u
.data
.length
);
5076 DBGPRINT(RT_DEBUG_TRACE
, ("Query::RT_OID_NEW_DRIVER (=%d)\n", enabled
));
5079 case RT_OID_WPA_SUPPLICANT_SUPPORT
:
5080 wrq
->u
.data
.length
= sizeof(UCHAR
);
5081 Status
= copy_to_user(wrq
->u
.data
.pointer
, &pAdapter
->StaCfg
.WpaSupplicantUP
, wrq
->u
.data
.length
);
5082 DBGPRINT(RT_DEBUG_TRACE
, ("Query::RT_OID_WPA_SUPPLICANT_SUPPORT (=%d)\n", pAdapter
->StaCfg
.WpaSupplicantUP
));
5084 #endif // WPA_SUPPLICANT_SUPPORT //
5086 case RT_OID_DRIVER_DEVICE_NAME
:
5087 DBGPRINT(RT_DEBUG_TRACE
, ("Query::RT_OID_DRIVER_DEVICE_NAME \n"));
5088 wrq
->u
.data
.length
= 16;
5089 if (copy_to_user(wrq
->u
.data
.pointer
, pAdapter
->StaCfg
.dev_name
, wrq
->u
.data
.length
))
5094 case RT_OID_802_11_QUERY_HT_PHYMODE
:
5095 pHTPhyMode
= (OID_SET_HT_PHYMODE
*) kmalloc(sizeof(OID_SET_HT_PHYMODE
), MEM_ALLOC_FLAG
);
5098 pHTPhyMode
->PhyMode
= pAdapter
->CommonCfg
.PhyMode
;
5099 pHTPhyMode
->HtMode
= (UCHAR
)pAdapter
->MacTab
.Content
[BSSID_WCID
].HTPhyMode
.field
.MODE
;
5100 pHTPhyMode
->BW
= (UCHAR
)pAdapter
->MacTab
.Content
[BSSID_WCID
].HTPhyMode
.field
.BW
;
5101 pHTPhyMode
->MCS
= (UCHAR
)pAdapter
->MacTab
.Content
[BSSID_WCID
].HTPhyMode
.field
.MCS
;
5102 pHTPhyMode
->SHORTGI
= (UCHAR
)pAdapter
->MacTab
.Content
[BSSID_WCID
].HTPhyMode
.field
.ShortGI
;
5103 pHTPhyMode
->STBC
= (UCHAR
)pAdapter
->MacTab
.Content
[BSSID_WCID
].HTPhyMode
.field
.STBC
;
5105 pHTPhyMode
->ExtOffset
= ((pAdapter
->CommonCfg
.CentralChannel
< pAdapter
->CommonCfg
.Channel
) ? (EXTCHA_BELOW
) : (EXTCHA_ABOVE
));
5106 wrq
->u
.data
.length
= sizeof(OID_SET_HT_PHYMODE
);
5107 if (copy_to_user(wrq
->u
.data
.pointer
, pHTPhyMode
, wrq
->u
.data
.length
))
5111 DBGPRINT(RT_DEBUG_TRACE
, ("Query::RT_OID_802_11_QUERY_HT_PHYMODE (PhyMode = %d, MCS =%d, BW = %d, STBC = %d, ExtOffset=%d)\n",
5112 pHTPhyMode
->HtMode
, pHTPhyMode
->MCS
, pHTPhyMode
->BW
, pHTPhyMode
->STBC
, pHTPhyMode
->ExtOffset
));
5113 DBGPRINT(RT_DEBUG_TRACE
, (" MlmeUpdateTxRates (.word = %x )\n", pAdapter
->MacTab
.Content
[BSSID_WCID
].HTPhyMode
.word
));
5117 DBGPRINT(RT_DEBUG_TRACE
, ("Query::RT_OID_802_11_STA_CONFIG(kmalloc failed)\n"));
5121 case RT_OID_802_11_COUNTRY_REGION
:
5122 DBGPRINT(RT_DEBUG_TRACE
, ("Query::RT_OID_802_11_COUNTRY_REGION \n"));
5123 wrq
->u
.data
.length
= sizeof(ulInfo
);
5124 ulInfo
= pAdapter
->CommonCfg
.CountryRegionForABand
;
5125 ulInfo
= (ulInfo
<< 8)|(pAdapter
->CommonCfg
.CountryRegion
);
5126 if (copy_to_user(wrq
->u
.data
.pointer
, &ulInfo
, wrq
->u
.data
.length
))
5131 case RT_OID_802_11_QUERY_DAT_HT_PHYMODE
:
5132 pHTPhyMode
= (OID_SET_HT_PHYMODE
*) kmalloc(sizeof(OID_SET_HT_PHYMODE
), MEM_ALLOC_FLAG
);
5135 pHTPhyMode
->PhyMode
= pAdapter
->CommonCfg
.PhyMode
;
5136 pHTPhyMode
->HtMode
= (UCHAR
)pAdapter
->CommonCfg
.RegTransmitSetting
.field
.HTMODE
;
5137 pHTPhyMode
->BW
= (UCHAR
)pAdapter
->CommonCfg
.RegTransmitSetting
.field
.BW
;
5138 pHTPhyMode
->MCS
= (UCHAR
)pAdapter
->StaCfg
.DesiredTransmitSetting
.field
.MCS
;
5139 pHTPhyMode
->SHORTGI
= (UCHAR
)pAdapter
->CommonCfg
.RegTransmitSetting
.field
.ShortGI
;
5140 pHTPhyMode
->STBC
= (UCHAR
)pAdapter
->CommonCfg
.RegTransmitSetting
.field
.STBC
;
5142 wrq
->u
.data
.length
= sizeof(OID_SET_HT_PHYMODE
);
5143 if (copy_to_user(wrq
->u
.data
.pointer
, pHTPhyMode
, wrq
->u
.data
.length
))
5147 DBGPRINT(RT_DEBUG_TRACE
, ("Query::RT_OID_802_11_QUERY_HT_PHYMODE (PhyMode = %d, MCS =%d, BW = %d, STBC = %d, ExtOffset=%d)\n",
5148 pHTPhyMode
->HtMode
, pHTPhyMode
->MCS
, pHTPhyMode
->BW
, pHTPhyMode
->STBC
, pHTPhyMode
->ExtOffset
));
5149 DBGPRINT(RT_DEBUG_TRACE
, (" MlmeUpdateTxRates (.word = %x )\n", pAdapter
->MacTab
.Content
[BSSID_WCID
].HTPhyMode
.word
));
5153 DBGPRINT(RT_DEBUG_TRACE
, ("Query::RT_OID_802_11_STA_CONFIG(kmalloc failed)\n"));
5157 case RT_OID_QUERY_MULTIPLE_CARD_SUPPORT
:
5158 wrq
->u
.data
.length
= sizeof(UCHAR
);
5160 #ifdef MULTIPLE_CARD_SUPPORT
5162 #endif // MULTIPLE_CARD_SUPPORT //
5163 if (copy_to_user(wrq
->u
.data
.pointer
, &i
, wrq
->u
.data
.length
))
5167 DBGPRINT(RT_DEBUG_TRACE
, ("Query::RT_OID_QUERY_MULTIPLE_CARD_SUPPORT(=%d) \n", i
));
5170 case RT_OID_802_11_MAC_ADDRESS
:
5171 wrq
->u
.data
.length
= MAC_ADDR_LEN
;
5172 Status
= copy_to_user(wrq
->u
.data
.pointer
, &pAdapter
->CurrentAddress
, wrq
->u
.data
.length
);
5175 case RT_OID_802_11_MANUFACTUREROUI
:
5176 DBGPRINT(RT_DEBUG_TRACE
, ("Query::RT_OID_802_11_MANUFACTUREROUI \n"));
5177 wrq
->u
.data
.length
= ManufacturerOUI_LEN
;
5178 Status
= copy_to_user(wrq
->u
.data
.pointer
, &pAdapter
->CurrentAddress
, wrq
->u
.data
.length
);
5181 case RT_OID_802_11_MANUFACTURERNAME
:
5182 DBGPRINT(RT_DEBUG_TRACE
, ("Query::RT_OID_802_11_MANUFACTURERNAME \n"));
5183 wrq
->u
.data
.length
= strlen(ManufacturerNAME
);
5184 Status
= copy_to_user(wrq
->u
.data
.pointer
, ManufacturerNAME
, wrq
->u
.data
.length
);
5187 case RT_OID_802_11_RESOURCETYPEIDNAME
:
5188 DBGPRINT(RT_DEBUG_TRACE
, ("Query::RT_OID_802_11_RESOURCETYPEIDNAME \n"));
5189 wrq
->u
.data
.length
= strlen(ResourceTypeIdName
);
5190 Status
= copy_to_user(wrq
->u
.data
.pointer
, ResourceTypeIdName
, wrq
->u
.data
.length
);
5193 case RT_OID_802_11_PRIVACYOPTIONIMPLEMENTED
:
5194 DBGPRINT(RT_DEBUG_TRACE
, ("Query::RT_OID_802_11_PRIVACYOPTIONIMPLEMENTED \n"));
5195 ulInfo
= 1; // 1 is support wep else 2 is not support.
5196 wrq
->u
.data
.length
= sizeof(ulInfo
);
5197 Status
= copy_to_user(wrq
->u
.data
.pointer
, &ulInfo
, wrq
->u
.data
.length
);
5200 case RT_OID_802_11_POWERMANAGEMENTMODE
:
5201 DBGPRINT(RT_DEBUG_TRACE
, ("Query::RT_OID_802_11_POWERMANAGEMENTMODE \n"));
5202 if (pAdapter
->StaCfg
.Psm
== PSMP_ACTION
)
5203 ulInfo
= 1; // 1 is power active else 2 is power save.
5207 wrq
->u
.data
.length
= sizeof(ulInfo
);
5208 Status
= copy_to_user(wrq
->u
.data
.pointer
, &ulInfo
, wrq
->u
.data
.length
);
5211 case OID_802_11_WEPDEFAULTKEYVALUE
:
5212 DBGPRINT(RT_DEBUG_TRACE
, ("Query::OID_802_11_WEPDEFAULTKEYVALUE \n"));
5213 //KeyIdxValue.KeyIdx = pAd->PortCfg.MBSSID[pAd->IoctlIF].DefaultKeyId;
5214 pKeyIdxValue
= wrq
->u
.data
.pointer
;
5215 DBGPRINT(RT_DEBUG_TRACE
,("KeyIdxValue.KeyIdx = %d, \n",pKeyIdxValue
->KeyIdx
));
5216 valueLen
= pAdapter
->SharedKey
[BSS0
][pAdapter
->StaCfg
.DefaultKeyId
].KeyLen
;
5217 NdisMoveMemory(pKeyIdxValue
->Value
,
5218 &pAdapter
->SharedKey
[BSS0
][pAdapter
->StaCfg
.DefaultKeyId
].Key
,
5220 pKeyIdxValue
->Value
[valueLen
]='\0';
5222 wrq
->u
.data
.length
= sizeof(DefaultKeyIdxValue
);
5224 Status
= copy_to_user(wrq
->u
.data
.pointer
, pKeyIdxValue
, wrq
->u
.data
.length
);
5225 DBGPRINT(RT_DEBUG_TRACE
,("DefaultKeyId = %d, total len = %d, str len=%d, KeyValue= %02x %02x %02x %02x \n", pAdapter
->StaCfg
.DefaultKeyId
, wrq
->u
.data
.length
, pAdapter
->SharedKey
[BSS0
][pAdapter
->StaCfg
.DefaultKeyId
].KeyLen
,
5226 pAdapter
->SharedKey
[BSS0
][0].Key
[0],
5227 pAdapter
->SharedKey
[BSS0
][1].Key
[0],
5228 pAdapter
->SharedKey
[BSS0
][2].Key
[0],
5229 pAdapter
->SharedKey
[BSS0
][3].Key
[0]));
5232 case OID_802_11_WEPDEFAULTKEYID
:
5233 DBGPRINT(RT_DEBUG_TRACE
, ("Query::RT_OID_802_11_WEPDEFAULTKEYID \n"));
5234 wrq
->u
.data
.length
= sizeof(UCHAR
);
5235 Status
= copy_to_user(wrq
->u
.data
.pointer
, &pAdapter
->StaCfg
.DefaultKeyId
, wrq
->u
.data
.length
);
5236 DBGPRINT(RT_DEBUG_TRACE
, ("DefaultKeyId =%d \n", pAdapter
->StaCfg
.DefaultKeyId
));
5239 case RT_OID_802_11_WEPKEYMAPPINGLENGTH
:
5240 DBGPRINT(RT_DEBUG_TRACE
, ("Query::RT_OID_802_11_WEPKEYMAPPINGLENGTH \n"));
5241 wrq
->u
.data
.length
= sizeof(UCHAR
);
5242 Status
= copy_to_user(wrq
->u
.data
.pointer
,
5243 &pAdapter
->SharedKey
[BSS0
][pAdapter
->StaCfg
.DefaultKeyId
].KeyLen
,
5244 wrq
->u
.data
.length
);
5247 case OID_802_11_SHORTRETRYLIMIT
:
5248 DBGPRINT(RT_DEBUG_TRACE
, ("Query::OID_802_11_SHORTRETRYLIMIT \n"));
5249 wrq
->u
.data
.length
= sizeof(ULONG
);
5250 RTMP_IO_READ32(pAdapter
, TX_RTY_CFG
, &tx_rty_cfg
.word
);
5251 ShortRetryLimit
= tx_rty_cfg
.field
.ShortRtyLimit
;
5252 DBGPRINT(RT_DEBUG_TRACE
, ("ShortRetryLimit =%ld, tx_rty_cfg.field.ShortRetryLimit=%d\n", ShortRetryLimit
, tx_rty_cfg
.field
.ShortRtyLimit
));
5253 Status
= copy_to_user(wrq
->u
.data
.pointer
, &ShortRetryLimit
, wrq
->u
.data
.length
);
5256 case OID_802_11_LONGRETRYLIMIT
:
5257 DBGPRINT(RT_DEBUG_TRACE
, ("Query::OID_802_11_LONGRETRYLIMIT \n"));
5258 wrq
->u
.data
.length
= sizeof(ULONG
);
5259 RTMP_IO_READ32(pAdapter
, TX_RTY_CFG
, &tx_rty_cfg
.word
);
5260 LongRetryLimit
= tx_rty_cfg
.field
.LongRtyLimit
;
5261 DBGPRINT(RT_DEBUG_TRACE
, ("LongRetryLimit =%ld, tx_rty_cfg.field.LongRtyLimit=%d\n", LongRetryLimit
, tx_rty_cfg
.field
.LongRtyLimit
));
5262 Status
= copy_to_user(wrq
->u
.data
.pointer
, &LongRetryLimit
, wrq
->u
.data
.length
);
5265 case RT_OID_802_11_PRODUCTID
:
5266 DBGPRINT(RT_DEBUG_TRACE
, ("Query::RT_OID_802_11_PRODUCTID \n"));
5272 if (((POS_COOKIE
)pAdapter
->OS_Cookie
)->pci_dev
!= NULL
)
5273 pci_read_config_word(((POS_COOKIE
)pAdapter
->OS_Cookie
)->pci_dev
, PCI_DEVICE_ID
, &device_id
);
5275 DBGPRINT(RT_DEBUG_TRACE
, (" pci_dev = NULL\n"));
5276 sprintf(tmp
, "%04x %04x\n", NIC_PCI_VENDOR_ID
, device_id
);
5279 wrq
->u
.data
.length
= strlen(tmp
);
5280 Status
= copy_to_user(wrq
->u
.data
.pointer
, tmp
, wrq
->u
.data
.length
);
5283 case RT_OID_802_11_MANUFACTUREID
:
5284 DBGPRINT(RT_DEBUG_TRACE
, ("Query::RT_OID_802_11_MANUFACTUREID \n"));
5285 wrq
->u
.data
.length
= strlen(ManufacturerNAME
);
5286 Status
= copy_to_user(wrq
->u
.data
.pointer
, ManufacturerNAME
, wrq
->u
.data
.length
);
5289 case OID_802_11_CURRENTCHANNEL
:
5290 DBGPRINT(RT_DEBUG_TRACE
, ("Query::OID_802_11_CURRENTCHANNEL \n"));
5291 wrq
->u
.data
.length
= sizeof(UCHAR
);
5292 DBGPRINT(RT_DEBUG_TRACE
, ("sizeof UCHAR=%d, channel=%d \n", sizeof(UCHAR
), pAdapter
->CommonCfg
.Channel
));
5293 Status
= copy_to_user(wrq
->u
.data
.pointer
, &pAdapter
->CommonCfg
.Channel
, wrq
->u
.data
.length
);
5294 DBGPRINT(RT_DEBUG_TRACE
, ("Status=%d\n", Status
));
5296 #endif //SNMP_SUPPORT
5298 case OID_802_11_BUILD_CHANNEL_EX
:
5301 DBGPRINT(RT_DEBUG_TRACE
, ("Query::OID_802_11_BUILD_CHANNEL_EX \n"));
5302 wrq
->u
.data
.length
= sizeof(UCHAR
);
5303 #ifdef EXT_BUILD_CHANNEL_LIST
5304 DBGPRINT(RT_DEBUG_TRACE
, ("Support EXT_BUILD_CHANNEL_LIST.\n"));
5307 DBGPRINT(RT_DEBUG_TRACE
, ("Doesn't support EXT_BUILD_CHANNEL_LIST.\n"));
5309 #endif // EXT_BUILD_CHANNEL_LIST //
5310 Status
= copy_to_user(wrq
->u
.data
.pointer
, &value
, 1);
5311 DBGPRINT(RT_DEBUG_TRACE
, ("Status=%d\n", Status
));
5315 case OID_802_11_GET_CH_LIST
:
5317 PRT_CHANNEL_LIST_INFO pChListBuf
;
5319 DBGPRINT(RT_DEBUG_TRACE
, ("Query::OID_802_11_GET_CH_LIST \n"));
5320 if (pAdapter
->ChannelListNum
== 0)
5322 wrq
->u
.data
.length
= 0;
5326 pChListBuf
= (RT_CHANNEL_LIST_INFO
*) kmalloc(sizeof(RT_CHANNEL_LIST_INFO
), MEM_ALLOC_FLAG
);
5327 if (pChListBuf
== NULL
)
5329 wrq
->u
.data
.length
= 0;
5333 pChListBuf
->ChannelListNum
= pAdapter
->ChannelListNum
;
5334 for (i
= 0; i
< pChListBuf
->ChannelListNum
; i
++)
5335 pChListBuf
->ChannelList
[i
] = pAdapter
->ChannelList
[i
].Channel
;
5337 wrq
->u
.data
.length
= sizeof(RT_CHANNEL_LIST_INFO
);
5338 Status
= copy_to_user(wrq
->u
.data
.pointer
, pChListBuf
, sizeof(RT_CHANNEL_LIST_INFO
));
5339 DBGPRINT(RT_DEBUG_TRACE
, ("Status=%d\n", Status
));
5346 case OID_802_11_GET_COUNTRY_CODE
:
5347 DBGPRINT(RT_DEBUG_TRACE
, ("Query::OID_802_11_GET_COUNTRY_CODE \n"));
5348 wrq
->u
.data
.length
= 2;
5349 Status
= copy_to_user(wrq
->u
.data
.pointer
, &pAdapter
->CommonCfg
.CountryCode
, 2);
5350 DBGPRINT(RT_DEBUG_TRACE
, ("Status=%d\n", Status
));
5353 case OID_802_11_GET_CHANNEL_GEOGRAPHY
:
5354 DBGPRINT(RT_DEBUG_TRACE
, ("Query::OID_802_11_GET_CHANNEL_GEOGRAPHY \n"));
5355 wrq
->u
.data
.length
= 1;
5356 Status
= copy_to_user(wrq
->u
.data
.pointer
, &pAdapter
->CommonCfg
.Geography
, 1);
5357 DBGPRINT(RT_DEBUG_TRACE
, ("Status=%d\n", Status
));
5361 #ifdef QOS_DLS_SUPPORT
5362 case RT_OID_802_11_QUERY_DLS
:
5363 wrq
->u
.data
.length
= sizeof(BOOLEAN
);
5364 Status
= copy_to_user(wrq
->u
.data
.pointer
, &pAdapter
->CommonCfg
.bDLSCapable
, wrq
->u
.data
.length
);
5365 DBGPRINT(RT_DEBUG_TRACE
, ("Query::RT_OID_802_11_QUERY_DLS(=%d)\n", pAdapter
->CommonCfg
.bDLSCapable
));
5368 case RT_OID_802_11_QUERY_DLS_PARAM
:
5370 PRT_802_11_DLS_INFO pDlsInfo
= kmalloc(sizeof(RT_802_11_DLS_INFO
), GFP_ATOMIC
);
5371 if (pDlsInfo
== NULL
)
5374 for (i
=0; i
<MAX_NUM_OF_DLS_ENTRY
; i
++)
5376 RTMPMoveMemory(&pDlsInfo
->Entry
[i
], &pAdapter
->StaCfg
.DLSEntry
[i
], sizeof(RT_802_11_DLS_UI
));
5379 pDlsInfo
->num
= MAX_NUM_OF_DLS_ENTRY
;
5380 wrq
->u
.data
.length
= sizeof(RT_802_11_DLS_INFO
);
5381 Status
= copy_to_user(wrq
->u
.data
.pointer
, pDlsInfo
, wrq
->u
.data
.length
);
5382 DBGPRINT(RT_DEBUG_TRACE
, ("Query::RT_OID_802_11_QUERY_DLS_PARAM\n"));
5388 #endif // QOS_DLS_SUPPORT //
5390 DBGPRINT(RT_DEBUG_TRACE
, ("Query::unknown IOCTL's subcmd = 0x%08x\n", cmd
));
5391 Status
= -EOPNOTSUPP
;
5397 INT
rt28xx_sta_ioctl(
5398 IN
struct net_device
*net_dev
,
5399 IN OUT
struct ifreq
*rq
,
5403 VIRTUAL_ADAPTER
*pVirtualAd
= NULL
;
5404 RTMP_ADAPTER
*pAd
= NULL
;
5405 struct iwreq
*wrq
= (struct iwreq
*) rq
;
5406 BOOLEAN StateMachineTouched
= FALSE
;
5407 INT Status
= NDIS_STATUS_SUCCESS
;
5410 if (net_dev
->priv_flags
== INT_MAIN
)
5412 pAd
= net_dev
->ml_priv
;
5416 pVirtualAd
= net_dev
->ml_priv
;
5417 pAd
= pVirtualAd
->RtmpDev
->ml_priv
;
5419 pObj
= (POS_COOKIE
) pAd
->OS_Cookie
;
5423 /* if 1st open fail, pAd will be free;
5424 So the net_dev->ml_priv will be NULL in 2rd open */
5428 //check if the interface is down
5429 if(!RTMP_TEST_FLAG(pAd
, fRTMP_ADAPTER_INTERRUPT_IN_USE
))
5431 #ifdef CONFIG_APSTA_MIXED_SUPPORT
5432 if (wrq
->u
.data
.pointer
== NULL
)
5437 if (strstr(wrq
->u
.data
.pointer
, "OpMode") == NULL
)
5438 #endif // CONFIG_APSTA_MIXED_SUPPORT //
5440 DBGPRINT(RT_DEBUG_TRACE
, ("INFO::Network is down!\n"));
5445 { // determine this ioctl command is comming from which interface.
5446 pObj
->ioctl_if_type
= INT_MAIN
;
5447 pObj
->ioctl_if
= MAIN_MBSSID
;
5453 #ifdef RALINK_28xx_QA
5454 case RTPRIV_IOCTL_ATE
:
5456 RtmpDoAte(pAd
, wrq
);
5459 #endif // RALINK_28xx_QA //
5460 #endif // RALINK_ATE //
5462 DBGPRINT(RT_DEBUG_TRACE
, ("IOCTL::SIOCGIFHWADDR\n"));
5463 memcpy(wrq
->u
.name
, pAd
->CurrentAddress
, ETH_ALEN
);
5467 char *name
=&wrq
->u
.name
[0];
5468 rt_ioctl_giwname(net_dev
, NULL
, name
, NULL
);
5471 case SIOCGIWESSID
: //Get ESSID
5473 struct iw_point
*essid
=&wrq
->u
.essid
;
5474 rt_ioctl_giwessid(net_dev
, NULL
, essid
, essid
->pointer
);
5477 case SIOCSIWESSID
: //Set ESSID
5479 struct iw_point
*essid
=&wrq
->u
.essid
;
5480 rt_ioctl_siwessid(net_dev
, NULL
, essid
, essid
->pointer
);
5483 case SIOCSIWNWID
: // set network id (the cell)
5484 case SIOCGIWNWID
: // get network id
5485 Status
= -EOPNOTSUPP
;
5487 case SIOCSIWFREQ
: //set channel/frequency (Hz)
5489 struct iw_freq
*freq
=&wrq
->u
.freq
;
5490 rt_ioctl_siwfreq(net_dev
, NULL
, freq
, NULL
);
5493 case SIOCGIWFREQ
: // get channel/frequency (Hz)
5495 struct iw_freq
*freq
=&wrq
->u
.freq
;
5496 rt_ioctl_giwfreq(net_dev
, NULL
, freq
, NULL
);
5499 case SIOCSIWNICKN
: //set node name/nickname
5501 struct iw_point
*data
=&wrq
->u
.data
;
5502 rt_ioctl_siwnickn(net_dev
, NULL
, data
, NULL
);
5505 case SIOCGIWNICKN
: //get node name/nickname
5507 struct iw_point
*data
=&wrq
->u
.data
;
5508 rt_ioctl_giwnickn(net_dev
, NULL
, data
, NULL
);
5511 case SIOCGIWRATE
: //get default bit rate (bps)
5512 rt_ioctl_giwrate(net_dev
, NULL
, &wrq
->u
, NULL
);
5514 case SIOCSIWRATE
: //set default bit rate (bps)
5515 rt_ioctl_siwrate(net_dev
, NULL
, &wrq
->u
, NULL
);
5517 case SIOCGIWRTS
: // get RTS/CTS threshold (bytes)
5519 struct iw_param
*rts
=&wrq
->u
.rts
;
5520 rt_ioctl_giwrts(net_dev
, NULL
, rts
, NULL
);
5523 case SIOCSIWRTS
: //set RTS/CTS threshold (bytes)
5525 struct iw_param
*rts
=&wrq
->u
.rts
;
5526 rt_ioctl_siwrts(net_dev
, NULL
, rts
, NULL
);
5529 case SIOCGIWFRAG
: //get fragmentation thr (bytes)
5531 struct iw_param
*frag
=&wrq
->u
.frag
;
5532 rt_ioctl_giwfrag(net_dev
, NULL
, frag
, NULL
);
5535 case SIOCSIWFRAG
: //set fragmentation thr (bytes)
5537 struct iw_param
*frag
=&wrq
->u
.frag
;
5538 rt_ioctl_siwfrag(net_dev
, NULL
, frag
, NULL
);
5541 case SIOCGIWENCODE
: //get encoding token & mode
5543 struct iw_point
*erq
=&wrq
->u
.encoding
;
5545 rt_ioctl_giwencode(net_dev
, NULL
, erq
, erq
->pointer
);
5548 case SIOCSIWENCODE
: //set encoding token & mode
5550 struct iw_point
*erq
=&wrq
->u
.encoding
;
5552 rt_ioctl_siwencode(net_dev
, NULL
, erq
, erq
->pointer
);
5555 case SIOCGIWAP
: //get access point MAC addresses
5557 struct sockaddr
*ap_addr
=&wrq
->u
.ap_addr
;
5558 rt_ioctl_giwap(net_dev
, NULL
, ap_addr
, ap_addr
->sa_data
);
5561 case SIOCSIWAP
: //set access point MAC addresses
5563 struct sockaddr
*ap_addr
=&wrq
->u
.ap_addr
;
5564 rt_ioctl_siwap(net_dev
, NULL
, ap_addr
, ap_addr
->sa_data
);
5567 case SIOCGIWMODE
: //get operation mode
5569 __u32
*mode
=&wrq
->u
.mode
;
5570 rt_ioctl_giwmode(net_dev
, NULL
, mode
, NULL
);
5573 case SIOCSIWMODE
: //set operation mode
5575 __u32
*mode
=&wrq
->u
.mode
;
5576 rt_ioctl_siwmode(net_dev
, NULL
, mode
, NULL
);
5579 case SIOCGIWSENS
: //get sensitivity (dBm)
5580 case SIOCSIWSENS
: //set sensitivity (dBm)
5581 case SIOCGIWPOWER
: //get Power Management settings
5582 case SIOCSIWPOWER
: //set Power Management settings
5583 case SIOCGIWTXPOW
: //get transmit power (dBm)
5584 case SIOCSIWTXPOW
: //set transmit power (dBm)
5585 case SIOCGIWRANGE
: //Get range of parameters
5586 case SIOCGIWRETRY
: //get retry limits and lifetime
5587 case SIOCSIWRETRY
: //set retry limits and lifetime
5588 Status
= -EOPNOTSUPP
;
5591 subcmd
= wrq
->u
.data
.flags
;
5592 if( subcmd
& OID_GET_SET_TOGGLE
)
5593 Status
= RTMPSetInformation(pAd
, rq
, subcmd
);
5595 Status
= RTMPQueryInformation(pAd
, rq
, subcmd
);
5598 if (wrq
->u
.data
.pointer
)
5600 if ( access_ok(VERIFY_WRITE
, wrq
->u
.data
.pointer
, sizeof(privtab
)) != TRUE
)
5602 wrq
->u
.data
.length
= sizeof(privtab
) / sizeof(privtab
[0]);
5603 if (copy_to_user(wrq
->u
.data
.pointer
, privtab
, sizeof(privtab
)))
5607 case RTPRIV_IOCTL_SET
:
5608 if(access_ok(VERIFY_READ
, wrq
->u
.data
.pointer
, wrq
->u
.data
.length
) != TRUE
)
5610 rt_ioctl_setparam(net_dev
, NULL
, NULL
, wrq
->u
.data
.pointer
);
5612 case RTPRIV_IOCTL_GSITESURVEY
:
5613 RTMPIoctlGetSiteSurvey(pAd
, wrq
);
5616 case RTPRIV_IOCTL_MAC
:
5617 RTMPIoctlMAC(pAd
, wrq
);
5619 case RTPRIV_IOCTL_E2P
:
5620 RTMPIoctlE2PROM(pAd
, wrq
);
5626 DBGPRINT(RT_DEBUG_ERROR
, ("IOCTL::unknown IOCTL's cmd = 0x%08x\n", cmd
));
5627 Status
= -EOPNOTSUPP
;
5631 if(StateMachineTouched
) // Upper layer sent a MLME-related operations
5632 RT28XX_MLME_HANDLER(pAd
);
5638 ==========================================================================
5642 TRUE if all parameters are OK, FALSE otherwise
5643 ==========================================================================
5646 IN PRTMP_ADAPTER pAdapter
,
5649 NDIS_802_11_SSID Ssid
, *pSsid
=NULL
;
5650 BOOLEAN StateMachineTouched
= FALSE
;
5653 if( strlen(arg
) <= MAX_LEN_OF_SSID
)
5655 NdisZeroMemory(&Ssid
, sizeof(NDIS_802_11_SSID
));
5656 if (strlen(arg
) != 0)
5658 NdisMoveMemory(Ssid
.Ssid
, arg
, strlen(arg
));
5659 Ssid
.SsidLength
= strlen(arg
);
5663 Ssid
.SsidLength
= 0;
5664 memcpy(Ssid
.Ssid
, "", 0);
5665 pAdapter
->StaCfg
.BssType
= BSS_INFRA
;
5666 pAdapter
->StaCfg
.AuthMode
= Ndis802_11AuthModeOpen
;
5667 pAdapter
->StaCfg
.WepStatus
= Ndis802_11EncryptionDisabled
;
5671 if (pAdapter
->Mlme
.CntlMachine
.CurrState
!= CNTL_IDLE
)
5673 RT28XX_MLME_RESET_STATE_MACHINE(pAdapter
);
5674 DBGPRINT(RT_DEBUG_TRACE
, ("!!! MLME busy, reset MLME state machine !!!\n"));
5677 pAdapter
->MlmeAux
.CurrReqIsFromNdis
= TRUE
;
5678 pAdapter
->StaCfg
.bScanReqIsFromWebUI
= FALSE
;
5679 pAdapter
->bConfigChanged
= TRUE
;
5681 MlmeEnqueue(pAdapter
,
5682 MLME_CNTL_STATE_MACHINE
,
5684 sizeof(NDIS_802_11_SSID
),
5687 StateMachineTouched
= TRUE
;
5688 DBGPRINT(RT_DEBUG_TRACE
, ("Set_SSID_Proc::(Len=%d,Ssid=%s)\n", Ssid
.SsidLength
, Ssid
.Ssid
));
5693 if (StateMachineTouched
) // Upper layer sent a MLME-related operations
5694 RT28XX_MLME_HANDLER(pAdapter
);
5701 ==========================================================================
5703 Set WmmCapable Enable or Disable
5705 TRUE if all parameters are OK, FALSE otherwise
5706 ==========================================================================
5708 INT
Set_WmmCapable_Proc(
5709 IN PRTMP_ADAPTER pAd
,
5712 BOOLEAN bWmmCapable
;
5714 bWmmCapable
= simple_strtol(arg
, 0, 10);
5716 if ((bWmmCapable
== 1)
5718 pAd
->CommonCfg
.bWmmCapable
= TRUE
;
5719 else if (bWmmCapable
== 0)
5720 pAd
->CommonCfg
.bWmmCapable
= FALSE
;
5722 return FALSE
; //Invalid argument
5724 DBGPRINT(RT_DEBUG_TRACE
, ("Set_WmmCapable_Proc::(bWmmCapable=%d)\n",
5725 pAd
->CommonCfg
.bWmmCapable
));
5729 #endif // WMM_SUPPORT //
5732 ==========================================================================
5734 Set Network Type(Infrastructure/Adhoc mode)
5736 TRUE if all parameters are OK, FALSE otherwise
5737 ==========================================================================
5739 INT
Set_NetworkType_Proc(
5740 IN PRTMP_ADAPTER pAdapter
,
5745 if (strcmp(arg
, "Adhoc") == 0)
5747 if (pAdapter
->StaCfg
.BssType
!= BSS_ADHOC
)
5749 // Config has changed
5750 pAdapter
->bConfigChanged
= TRUE
;
5751 if (MONITOR_ON(pAdapter
))
5753 RTMP_IO_WRITE32(pAdapter
, RX_FILTR_CFG
, STANORMAL
);
5754 RTMP_IO_READ32(pAdapter
, MAC_SYS_CTRL
, &Value
);
5756 RTMP_IO_WRITE32(pAdapter
, MAC_SYS_CTRL
, Value
);
5757 OPSTATUS_CLEAR_FLAG(pAdapter
, fOP_STATUS_MEDIA_STATE_CONNECTED
);
5758 pAdapter
->StaCfg
.bAutoReconnect
= TRUE
;
5759 LinkDown(pAdapter
, FALSE
);
5761 if (INFRA_ON(pAdapter
))
5763 //BOOLEAN Cancelled;
5764 // Set the AutoReconnectSsid to prevent it reconnect to old SSID
5765 // Since calling this indicate user don't want to connect to that SSID anymore.
5766 pAdapter
->MlmeAux
.AutoReconnectSsidLen
= 32;
5767 NdisZeroMemory(pAdapter
->MlmeAux
.AutoReconnectSsid
, pAdapter
->MlmeAux
.AutoReconnectSsidLen
);
5769 LinkDown(pAdapter
, FALSE
);
5771 DBGPRINT(RT_DEBUG_TRACE
, ("NDIS_STATUS_MEDIA_DISCONNECT Event BB!\n"));
5774 pAdapter
->StaCfg
.BssType
= BSS_ADHOC
;
5775 pAdapter
->net_dev
->type
= pAdapter
->StaCfg
.OriDevType
;
5776 DBGPRINT(RT_DEBUG_TRACE
, ("===>Set_NetworkType_Proc::(AD-HOC)\n"));
5778 else if (strcmp(arg
, "Infra") == 0)
5780 if (pAdapter
->StaCfg
.BssType
!= BSS_INFRA
)
5782 // Config has changed
5783 pAdapter
->bConfigChanged
= TRUE
;
5784 if (MONITOR_ON(pAdapter
))
5786 RTMP_IO_WRITE32(pAdapter
, RX_FILTR_CFG
, STANORMAL
);
5787 RTMP_IO_READ32(pAdapter
, MAC_SYS_CTRL
, &Value
);
5789 RTMP_IO_WRITE32(pAdapter
, MAC_SYS_CTRL
, Value
);
5790 OPSTATUS_CLEAR_FLAG(pAdapter
, fOP_STATUS_MEDIA_STATE_CONNECTED
);
5791 pAdapter
->StaCfg
.bAutoReconnect
= TRUE
;
5792 LinkDown(pAdapter
, FALSE
);
5794 if (ADHOC_ON(pAdapter
))
5796 // Set the AutoReconnectSsid to prevent it reconnect to old SSID
5797 // Since calling this indicate user don't want to connect to that SSID anymore.
5798 pAdapter
->MlmeAux
.AutoReconnectSsidLen
= 32;
5799 NdisZeroMemory(pAdapter
->MlmeAux
.AutoReconnectSsid
, pAdapter
->MlmeAux
.AutoReconnectSsidLen
);
5801 LinkDown(pAdapter
, FALSE
);
5804 pAdapter
->StaCfg
.BssType
= BSS_INFRA
;
5805 pAdapter
->net_dev
->type
= pAdapter
->StaCfg
.OriDevType
;
5806 DBGPRINT(RT_DEBUG_TRACE
, ("===>Set_NetworkType_Proc::(INFRA)\n"));
5808 pAdapter
->StaCfg
.BssType
= BSS_INFRA
;
5810 else if (strcmp(arg
, "Monitor") == 0)
5813 BCN_TIME_CFG_STRUC csr
;
5814 OPSTATUS_CLEAR_FLAG(pAdapter
, fOP_STATUS_INFRA_ON
);
5815 OPSTATUS_CLEAR_FLAG(pAdapter
, fOP_STATUS_ADHOC_ON
);
5816 OPSTATUS_SET_FLAG(pAdapter
, fOP_STATUS_MEDIA_STATE_CONNECTED
);
5817 // disable all periodic state machine
5818 pAdapter
->StaCfg
.bAutoReconnect
= FALSE
;
5819 // reset all mlme state machine
5820 RT28XX_MLME_RESET_STATE_MACHINE(pAdapter
);
5821 DBGPRINT(RT_DEBUG_TRACE
, ("fOP_STATUS_MEDIA_STATE_CONNECTED \n"));
5822 if (pAdapter
->CommonCfg
.CentralChannel
== 0)
5824 #ifdef DOT11_N_SUPPORT
5825 if (pAdapter
->CommonCfg
.PhyMode
== PHY_11AN_MIXED
)
5826 pAdapter
->CommonCfg
.CentralChannel
= 36;
5828 #endif // DOT11_N_SUPPORT //
5829 pAdapter
->CommonCfg
.CentralChannel
= 6;
5831 #ifdef DOT11_N_SUPPORT
5833 N_ChannelCheck(pAdapter
);
5834 #endif // DOT11_N_SUPPORT //
5836 #ifdef DOT11_N_SUPPORT
5837 if (pAdapter
->CommonCfg
.PhyMode
>= PHY_11ABGN_MIXED
&&
5838 pAdapter
->CommonCfg
.RegTransmitSetting
.field
.BW
== BW_40
&&
5839 pAdapter
->CommonCfg
.RegTransmitSetting
.field
.EXTCHA
== EXTCHA_ABOVE
)
5841 // 40MHz ,control channel at lower
5842 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter
, BBP_R4
, &bbpValue
);
5843 bbpValue
&= (~0x18);
5845 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter
, BBP_R4
, bbpValue
);
5846 pAdapter
->CommonCfg
.BBPCurrentBW
= BW_40
;
5847 // RX : control channel at lower
5848 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter
, BBP_R3
, &bbpValue
);
5849 bbpValue
&= (~0x20);
5850 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter
, BBP_R3
, bbpValue
);
5852 RTMP_IO_READ32(pAdapter
, TX_BAND_CFG
, &Value
);
5853 Value
&= 0xfffffffe;
5854 RTMP_IO_WRITE32(pAdapter
, TX_BAND_CFG
, Value
);
5855 pAdapter
->CommonCfg
.CentralChannel
= pAdapter
->CommonCfg
.Channel
+ 2;
5856 AsicSwitchChannel(pAdapter
, pAdapter
->CommonCfg
.CentralChannel
, FALSE
);
5857 AsicLockChannel(pAdapter
, pAdapter
->CommonCfg
.CentralChannel
);
5858 DBGPRINT(RT_DEBUG_TRACE
, ("BW_40 ,control_channel(%d), CentralChannel(%d) \n",
5859 pAdapter
->CommonCfg
.Channel
,
5860 pAdapter
->CommonCfg
.CentralChannel
));
5862 else if (pAdapter
->CommonCfg
.PhyMode
>= PHY_11ABGN_MIXED
&&
5863 pAdapter
->CommonCfg
.RegTransmitSetting
.field
.BW
== BW_40
&&
5864 pAdapter
->CommonCfg
.RegTransmitSetting
.field
.EXTCHA
== EXTCHA_BELOW
)
5866 // 40MHz ,control channel at upper
5867 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter
, BBP_R4
, &bbpValue
);
5868 bbpValue
&= (~0x18);
5870 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter
, BBP_R4
, bbpValue
);
5871 pAdapter
->CommonCfg
.BBPCurrentBW
= BW_40
;
5872 RTMP_IO_READ32(pAdapter
, TX_BAND_CFG
, &Value
);
5874 RTMP_IO_WRITE32(pAdapter
, TX_BAND_CFG
, Value
);
5876 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter
, BBP_R3
, &bbpValue
);
5878 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter
, BBP_R3
, bbpValue
);
5879 pAdapter
->CommonCfg
.CentralChannel
= pAdapter
->CommonCfg
.Channel
- 2;
5880 AsicSwitchChannel(pAdapter
, pAdapter
->CommonCfg
.CentralChannel
, FALSE
);
5881 AsicLockChannel(pAdapter
, pAdapter
->CommonCfg
.CentralChannel
);
5882 DBGPRINT(RT_DEBUG_TRACE
, ("BW_40 ,control_channel(%d), CentralChannel(%d) \n",
5883 pAdapter
->CommonCfg
.Channel
,
5884 pAdapter
->CommonCfg
.CentralChannel
));
5887 #endif // DOT11_N_SUPPORT //
5890 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter
, BBP_R4
, &bbpValue
);
5891 bbpValue
&= (~0x18);
5892 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter
, BBP_R4
, bbpValue
);
5893 pAdapter
->CommonCfg
.BBPCurrentBW
= BW_20
;
5894 AsicSwitchChannel(pAdapter
, pAdapter
->CommonCfg
.Channel
, FALSE
);
5895 AsicLockChannel(pAdapter
, pAdapter
->CommonCfg
.Channel
);
5896 DBGPRINT(RT_DEBUG_TRACE
, ("BW_20, Channel(%d)\n", pAdapter
->CommonCfg
.Channel
));
5898 // Enable Rx with promiscuous reception
5899 RTMP_IO_WRITE32(pAdapter
, RX_FILTR_CFG
, 0x3);
5900 // ASIC supporsts sniffer function with replacing RSSI with timestamp.
5901 //RTMP_IO_READ32(pAdapter, MAC_SYS_CTRL, &Value);
5903 //RTMP_IO_WRITE32(pAdapter, MAC_SYS_CTRL, Value);
5905 RTMP_IO_READ32(pAdapter
, BCN_TIME_CFG
, &csr
.word
);
5906 csr
.field
.bBeaconGen
= 0;
5907 csr
.field
.bTBTTEnable
= 0;
5908 csr
.field
.TsfSyncMode
= 0;
5909 RTMP_IO_WRITE32(pAdapter
, BCN_TIME_CFG
, csr
.word
);
5911 pAdapter
->StaCfg
.BssType
= BSS_MONITOR
;
5912 pAdapter
->net_dev
->type
= ARPHRD_IEEE80211_PRISM
; //ARPHRD_IEEE80211; // IEEE80211
5913 DBGPRINT(RT_DEBUG_TRACE
, ("===>Set_NetworkType_Proc::(MONITOR)\n"));
5916 // Reset Ralink supplicant to not use, it will be set to start when UI set PMK key
5917 pAdapter
->StaCfg
.WpaState
= SS_NOTUSE
;
5919 DBGPRINT(RT_DEBUG_TRACE
, ("Set_NetworkType_Proc::(NetworkType=%d)\n", pAdapter
->StaCfg
.BssType
));
5925 ==========================================================================
5927 Set Authentication mode
5929 TRUE if all parameters are OK, FALSE otherwise
5930 ==========================================================================
5932 INT
Set_AuthMode_Proc(
5933 IN PRTMP_ADAPTER pAdapter
,
5936 if ((strcmp(arg
, "WEPAUTO") == 0) || (strcmp(arg
, "wepauto") == 0))
5937 pAdapter
->StaCfg
.AuthMode
= Ndis802_11AuthModeAutoSwitch
;
5938 else if ((strcmp(arg
, "OPEN") == 0) || (strcmp(arg
, "open") == 0))
5939 pAdapter
->StaCfg
.AuthMode
= Ndis802_11AuthModeOpen
;
5940 else if ((strcmp(arg
, "SHARED") == 0) || (strcmp(arg
, "shared") == 0))
5941 pAdapter
->StaCfg
.AuthMode
= Ndis802_11AuthModeShared
;
5942 else if ((strcmp(arg
, "WPAPSK") == 0) || (strcmp(arg
, "wpapsk") == 0))
5943 pAdapter
->StaCfg
.AuthMode
= Ndis802_11AuthModeWPAPSK
;
5944 else if ((strcmp(arg
, "WPANONE") == 0) || (strcmp(arg
, "wpanone") == 0))
5945 pAdapter
->StaCfg
.AuthMode
= Ndis802_11AuthModeWPANone
;
5946 else if ((strcmp(arg
, "WPA2PSK") == 0) || (strcmp(arg
, "wpa2psk") == 0))
5947 pAdapter
->StaCfg
.AuthMode
= Ndis802_11AuthModeWPA2PSK
;
5948 #ifdef WPA_SUPPLICANT_SUPPORT
5949 else if ((strcmp(arg
, "WPA") == 0) || (strcmp(arg
, "wpa") == 0))
5950 pAdapter
->StaCfg
.AuthMode
= Ndis802_11AuthModeWPA
;
5951 else if ((strcmp(arg
, "WPA2") == 0) || (strcmp(arg
, "wpa2") == 0))
5952 pAdapter
->StaCfg
.AuthMode
= Ndis802_11AuthModeWPA2
;
5953 #endif // WPA_SUPPLICANT_SUPPORT //
5957 pAdapter
->StaCfg
.PortSecured
= WPA_802_1X_PORT_NOT_SECURED
;
5959 DBGPRINT(RT_DEBUG_TRACE
, ("Set_AuthMode_Proc::(AuthMode=%d)\n", pAdapter
->StaCfg
.AuthMode
));
5965 ==========================================================================
5969 TRUE if all parameters are OK, FALSE otherwise
5970 ==========================================================================
5972 INT
Set_EncrypType_Proc(
5973 IN PRTMP_ADAPTER pAdapter
,
5976 if ((strcmp(arg
, "NONE") == 0) || (strcmp(arg
, "none") == 0))
5978 if (pAdapter
->StaCfg
.AuthMode
>= Ndis802_11AuthModeWPA
)
5979 return TRUE
; // do nothing
5981 pAdapter
->StaCfg
.WepStatus
= Ndis802_11WEPDisabled
;
5982 pAdapter
->StaCfg
.PairCipher
= Ndis802_11WEPDisabled
;
5983 pAdapter
->StaCfg
.GroupCipher
= Ndis802_11WEPDisabled
;
5985 else if ((strcmp(arg
, "WEP") == 0) || (strcmp(arg
, "wep") == 0))
5987 if (pAdapter
->StaCfg
.AuthMode
>= Ndis802_11AuthModeWPA
)
5988 return TRUE
; // do nothing
5990 pAdapter
->StaCfg
.WepStatus
= Ndis802_11WEPEnabled
;
5991 pAdapter
->StaCfg
.PairCipher
= Ndis802_11WEPEnabled
;
5992 pAdapter
->StaCfg
.GroupCipher
= Ndis802_11WEPEnabled
;
5994 else if ((strcmp(arg
, "TKIP") == 0) || (strcmp(arg
, "tkip") == 0))
5996 if (pAdapter
->StaCfg
.AuthMode
< Ndis802_11AuthModeWPA
)
5997 return TRUE
; // do nothing
5999 pAdapter
->StaCfg
.WepStatus
= Ndis802_11Encryption2Enabled
;
6000 pAdapter
->StaCfg
.PairCipher
= Ndis802_11Encryption2Enabled
;
6001 pAdapter
->StaCfg
.GroupCipher
= Ndis802_11Encryption2Enabled
;
6003 else if ((strcmp(arg
, "AES") == 0) || (strcmp(arg
, "aes") == 0))
6005 if (pAdapter
->StaCfg
.AuthMode
< Ndis802_11AuthModeWPA
)
6006 return TRUE
; // do nothing
6008 pAdapter
->StaCfg
.WepStatus
= Ndis802_11Encryption3Enabled
;
6009 pAdapter
->StaCfg
.PairCipher
= Ndis802_11Encryption3Enabled
;
6010 pAdapter
->StaCfg
.GroupCipher
= Ndis802_11Encryption3Enabled
;
6015 pAdapter
->StaCfg
.OrigWepStatus
= pAdapter
->StaCfg
.WepStatus
;
6017 DBGPRINT(RT_DEBUG_TRACE
, ("Set_EncrypType_Proc::(EncrypType=%d)\n", pAdapter
->StaCfg
.WepStatus
));
6023 ==========================================================================
6027 TRUE if all parameters are OK, FALSE otherwise
6028 ==========================================================================
6030 INT
Set_DefaultKeyID_Proc(
6031 IN PRTMP_ADAPTER pAdapter
,
6036 KeyIdx
= simple_strtol(arg
, 0, 10);
6037 if((KeyIdx
>= 1 ) && (KeyIdx
<= 4))
6038 pAdapter
->StaCfg
.DefaultKeyId
= (UCHAR
) (KeyIdx
- 1 );
6040 return FALSE
; //Invalid argument
6042 DBGPRINT(RT_DEBUG_TRACE
, ("Set_DefaultKeyID_Proc::(DefaultKeyID=%d)\n", pAdapter
->StaCfg
.DefaultKeyId
));
6048 ==========================================================================
6052 TRUE if all parameters are OK, FALSE otherwise
6053 ==========================================================================
6056 IN PRTMP_ADAPTER pAdapter
,
6061 UCHAR CipherAlg
=CIPHER_WEP64
;
6063 if (pAdapter
->StaCfg
.AuthMode
>= Ndis802_11AuthModeWPA
)
6064 return TRUE
; // do nothing
6066 KeyLen
= strlen(arg
);
6070 case 5: //wep 40 Ascii type
6071 pAdapter
->SharedKey
[BSS0
][0].KeyLen
= KeyLen
;
6072 memcpy(pAdapter
->SharedKey
[BSS0
][0].Key
, arg
, KeyLen
);
6073 CipherAlg
= CIPHER_WEP64
;
6074 DBGPRINT(RT_DEBUG_TRACE
, ("Set_Key1_Proc::(Key1=%s and type=%s)\n", arg
, "Ascii"));
6076 case 10: //wep 40 Hex type
6077 for(i
=0; i
< KeyLen
; i
++)
6079 if( !isxdigit(*(arg
+i
)) )
6080 return FALSE
; //Not Hex value;
6082 pAdapter
->SharedKey
[BSS0
][0].KeyLen
= KeyLen
/ 2 ;
6083 AtoH(arg
, pAdapter
->SharedKey
[BSS0
][0].Key
, KeyLen
/ 2);
6084 CipherAlg
= CIPHER_WEP64
;
6085 DBGPRINT(RT_DEBUG_TRACE
, ("Set_Key1_Proc::(Key1=%s and type=%s)\n", arg
, "Hex"));
6087 case 13: //wep 104 Ascii type
6088 pAdapter
->SharedKey
[BSS0
][0].KeyLen
= KeyLen
;
6089 memcpy(pAdapter
->SharedKey
[BSS0
][0].Key
, arg
, KeyLen
);
6090 CipherAlg
= CIPHER_WEP128
;
6091 DBGPRINT(RT_DEBUG_TRACE
, ("Set_Key1_Proc::(Key1=%s and type=%s)\n", arg
, "Ascii"));
6093 case 26: //wep 104 Hex type
6094 for(i
=0; i
< KeyLen
; i
++)
6096 if( !isxdigit(*(arg
+i
)) )
6097 return FALSE
; //Not Hex value;
6099 pAdapter
->SharedKey
[BSS0
][0].KeyLen
= KeyLen
/ 2 ;
6100 AtoH(arg
, pAdapter
->SharedKey
[BSS0
][0].Key
, KeyLen
/ 2);
6101 CipherAlg
= CIPHER_WEP128
;
6102 DBGPRINT(RT_DEBUG_TRACE
, ("Set_Key1_Proc::(Key1=%s and type=%s)\n", arg
, "Hex"));
6104 default: //Invalid argument
6105 DBGPRINT(RT_DEBUG_TRACE
, ("Set_Key1_Proc::Invalid argument (=%s)\n", arg
));
6109 pAdapter
->SharedKey
[BSS0
][0].CipherAlg
= CipherAlg
;
6111 // Set keys (into ASIC)
6112 if (pAdapter
->StaCfg
.AuthMode
>= Ndis802_11AuthModeWPA
)
6114 else // Old WEP stuff
6116 AsicAddSharedKeyEntry(pAdapter
,
6119 pAdapter
->SharedKey
[BSS0
][0].CipherAlg
,
6120 pAdapter
->SharedKey
[BSS0
][0].Key
,
6128 ==========================================================================
6133 TRUE if all parameters are OK, FALSE otherwise
6134 ==========================================================================
6137 IN PRTMP_ADAPTER pAdapter
,
6142 UCHAR CipherAlg
=CIPHER_WEP64
;
6144 if (pAdapter
->StaCfg
.AuthMode
>= Ndis802_11AuthModeWPA
)
6145 return TRUE
; // do nothing
6147 KeyLen
= strlen(arg
);
6151 case 5: //wep 40 Ascii type
6152 pAdapter
->SharedKey
[BSS0
][1].KeyLen
= KeyLen
;
6153 memcpy(pAdapter
->SharedKey
[BSS0
][1].Key
, arg
, KeyLen
);
6154 CipherAlg
= CIPHER_WEP64
;
6155 DBGPRINT(RT_DEBUG_TRACE
, ("Set_Key2_Proc::(Key2=%s and type=%s)\n", arg
, "Ascii"));
6157 case 10: //wep 40 Hex type
6158 for(i
=0; i
< KeyLen
; i
++)
6160 if( !isxdigit(*(arg
+i
)) )
6161 return FALSE
; //Not Hex value;
6163 pAdapter
->SharedKey
[BSS0
][1].KeyLen
= KeyLen
/ 2 ;
6164 AtoH(arg
, pAdapter
->SharedKey
[BSS0
][1].Key
, KeyLen
/ 2);
6165 CipherAlg
= CIPHER_WEP64
;
6166 DBGPRINT(RT_DEBUG_TRACE
, ("Set_Key2_Proc::(Key2=%s and type=%s)\n", arg
, "Hex"));
6168 case 13: //wep 104 Ascii type
6169 pAdapter
->SharedKey
[BSS0
][1].KeyLen
= KeyLen
;
6170 memcpy(pAdapter
->SharedKey
[BSS0
][1].Key
, arg
, KeyLen
);
6171 CipherAlg
= CIPHER_WEP128
;
6172 DBGPRINT(RT_DEBUG_TRACE
, ("Set_Key2_Proc::(Key2=%s and type=%s)\n", arg
, "Ascii"));
6174 case 26: //wep 104 Hex type
6175 for(i
=0; i
< KeyLen
; i
++)
6177 if( !isxdigit(*(arg
+i
)) )
6178 return FALSE
; //Not Hex value;
6180 pAdapter
->SharedKey
[BSS0
][1].KeyLen
= KeyLen
/ 2 ;
6181 AtoH(arg
, pAdapter
->SharedKey
[BSS0
][1].Key
, KeyLen
/ 2);
6182 CipherAlg
= CIPHER_WEP128
;
6183 DBGPRINT(RT_DEBUG_TRACE
, ("Set_Key2_Proc::(Key2=%s and type=%s)\n", arg
, "Hex"));
6185 default: //Invalid argument
6186 DBGPRINT(RT_DEBUG_TRACE
, ("Set_Key2_Proc::Invalid argument (=%s)\n", arg
));
6189 pAdapter
->SharedKey
[BSS0
][1].CipherAlg
= CipherAlg
;
6191 // Set keys (into ASIC)
6192 if (pAdapter
->StaCfg
.AuthMode
>= Ndis802_11AuthModeWPA
)
6194 else // Old WEP stuff
6196 AsicAddSharedKeyEntry(pAdapter
,
6199 pAdapter
->SharedKey
[BSS0
][1].CipherAlg
,
6200 pAdapter
->SharedKey
[BSS0
][1].Key
,
6208 ==========================================================================
6212 TRUE if all parameters are OK, FALSE otherwise
6213 ==========================================================================
6216 IN PRTMP_ADAPTER pAdapter
,
6221 UCHAR CipherAlg
=CIPHER_WEP64
;
6223 if (pAdapter
->StaCfg
.AuthMode
>= Ndis802_11AuthModeWPA
)
6224 return TRUE
; // do nothing
6226 KeyLen
= strlen(arg
);
6230 case 5: //wep 40 Ascii type
6231 pAdapter
->SharedKey
[BSS0
][2].KeyLen
= KeyLen
;
6232 memcpy(pAdapter
->SharedKey
[BSS0
][2].Key
, arg
, KeyLen
);
6233 CipherAlg
= CIPHER_WEP64
;
6234 DBGPRINT(RT_DEBUG_TRACE
, ("Set_Key3_Proc::(Key3=%s and type=Ascii)\n", arg
));
6236 case 10: //wep 40 Hex type
6237 for(i
=0; i
< KeyLen
; i
++)
6239 if( !isxdigit(*(arg
+i
)) )
6240 return FALSE
; //Not Hex value;
6242 pAdapter
->SharedKey
[BSS0
][2].KeyLen
= KeyLen
/ 2 ;
6243 AtoH(arg
, pAdapter
->SharedKey
[BSS0
][2].Key
, KeyLen
/ 2);
6244 CipherAlg
= CIPHER_WEP64
;
6245 DBGPRINT(RT_DEBUG_TRACE
, ("Set_Key3_Proc::(Key3=%s and type=Hex)\n", arg
));
6247 case 13: //wep 104 Ascii type
6248 pAdapter
->SharedKey
[BSS0
][2].KeyLen
= KeyLen
;
6249 memcpy(pAdapter
->SharedKey
[BSS0
][2].Key
, arg
, KeyLen
);
6250 CipherAlg
= CIPHER_WEP128
;
6251 DBGPRINT(RT_DEBUG_TRACE
, ("Set_Key3_Proc::(Key3=%s and type=Ascii)\n", arg
));
6253 case 26: //wep 104 Hex type
6254 for(i
=0; i
< KeyLen
; i
++)
6256 if( !isxdigit(*(arg
+i
)) )
6257 return FALSE
; //Not Hex value;
6259 pAdapter
->SharedKey
[BSS0
][2].KeyLen
= KeyLen
/ 2 ;
6260 AtoH(arg
, pAdapter
->SharedKey
[BSS0
][2].Key
, KeyLen
/ 2);
6261 CipherAlg
= CIPHER_WEP128
;
6262 DBGPRINT(RT_DEBUG_TRACE
, ("Set_Key3_Proc::(Key3=%s and type=Hex)\n", arg
));
6264 default: //Invalid argument
6265 DBGPRINT(RT_DEBUG_TRACE
, ("Set_Key3_Proc::Invalid argument (=%s)\n", arg
));
6268 pAdapter
->SharedKey
[BSS0
][2].CipherAlg
= CipherAlg
;
6270 // Set keys (into ASIC)
6271 if (pAdapter
->StaCfg
.AuthMode
>= Ndis802_11AuthModeWPA
)
6273 else // Old WEP stuff
6275 AsicAddSharedKeyEntry(pAdapter
,
6278 pAdapter
->SharedKey
[BSS0
][2].CipherAlg
,
6279 pAdapter
->SharedKey
[BSS0
][2].Key
,
6287 ==========================================================================
6291 TRUE if all parameters are OK, FALSE otherwise
6292 ==========================================================================
6295 IN PRTMP_ADAPTER pAdapter
,
6300 UCHAR CipherAlg
=CIPHER_WEP64
;
6302 if (pAdapter
->StaCfg
.AuthMode
>= Ndis802_11AuthModeWPA
)
6303 return TRUE
; // do nothing
6305 KeyLen
= strlen(arg
);
6309 case 5: //wep 40 Ascii type
6310 pAdapter
->SharedKey
[BSS0
][3].KeyLen
= KeyLen
;
6311 memcpy(pAdapter
->SharedKey
[BSS0
][3].Key
, arg
, KeyLen
);
6312 CipherAlg
= CIPHER_WEP64
;
6313 DBGPRINT(RT_DEBUG_TRACE
, ("Set_Key4_Proc::(Key4=%s and type=%s)\n", arg
, "Ascii"));
6315 case 10: //wep 40 Hex type
6316 for(i
=0; i
< KeyLen
; i
++)
6318 if( !isxdigit(*(arg
+i
)) )
6319 return FALSE
; //Not Hex value;
6321 pAdapter
->SharedKey
[BSS0
][3].KeyLen
= KeyLen
/ 2 ;
6322 AtoH(arg
, pAdapter
->SharedKey
[BSS0
][3].Key
, KeyLen
/ 2);
6323 CipherAlg
= CIPHER_WEP64
;
6324 DBGPRINT(RT_DEBUG_TRACE
, ("Set_Key4_Proc::(Key4=%s and type=%s)\n", arg
, "Hex"));
6326 case 13: //wep 104 Ascii type
6327 pAdapter
->SharedKey
[BSS0
][3].KeyLen
= KeyLen
;
6328 memcpy(pAdapter
->SharedKey
[BSS0
][3].Key
, arg
, KeyLen
);
6329 CipherAlg
= CIPHER_WEP128
;
6330 DBGPRINT(RT_DEBUG_TRACE
, ("Set_Key4_Proc::(Key4=%s and type=%s)\n", arg
, "Ascii"));
6332 case 26: //wep 104 Hex type
6333 for(i
=0; i
< KeyLen
; i
++)
6335 if( !isxdigit(*(arg
+i
)) )
6336 return FALSE
; //Not Hex value;
6338 pAdapter
->SharedKey
[BSS0
][3].KeyLen
= KeyLen
/ 2 ;
6339 AtoH(arg
, pAdapter
->SharedKey
[BSS0
][3].Key
, KeyLen
/ 2);
6340 CipherAlg
= CIPHER_WEP128
;
6341 DBGPRINT(RT_DEBUG_TRACE
, ("Set_Key4_Proc::(Key4=%s and type=%s)\n", arg
, "Hex"));
6343 default: //Invalid argument
6344 DBGPRINT(RT_DEBUG_TRACE
, ("Set_Key4_Proc::Invalid argument (=%s)\n", arg
));
6347 pAdapter
->SharedKey
[BSS0
][3].CipherAlg
= CipherAlg
;
6349 // Set keys (into ASIC)
6350 if (pAdapter
->StaCfg
.AuthMode
>= Ndis802_11AuthModeWPA
)
6352 else // Old WEP stuff
6354 AsicAddSharedKeyEntry(pAdapter
,
6357 pAdapter
->SharedKey
[BSS0
][3].CipherAlg
,
6358 pAdapter
->SharedKey
[BSS0
][3].Key
,
6367 ==========================================================================
6371 TRUE if all parameters are OK, FALSE otherwise
6372 ==========================================================================
6374 INT
Set_WPAPSK_Proc(
6375 IN PRTMP_ADAPTER pAdapter
,
6378 UCHAR keyMaterial
[40];
6380 if ((pAdapter
->StaCfg
.AuthMode
!= Ndis802_11AuthModeWPAPSK
) &&
6381 (pAdapter
->StaCfg
.AuthMode
!= Ndis802_11AuthModeWPA2PSK
) &&
6382 (pAdapter
->StaCfg
.AuthMode
!= Ndis802_11AuthModeWPANone
)
6384 return TRUE
; // do nothing
6386 DBGPRINT(RT_DEBUG_TRACE
, ("Set_WPAPSK_Proc::(WPAPSK=%s)\n", arg
));
6388 NdisZeroMemory(keyMaterial
, 40);
6390 if ((strlen(arg
) < 8) || (strlen(arg
) > 64))
6392 DBGPRINT(RT_DEBUG_TRACE
, ("Set failed!!(WPAPSK=%s), WPAPSK key-string required 8 ~ 64 characters \n", arg
));
6396 if (strlen(arg
) == 64)
6398 AtoH(arg
, keyMaterial
, 32);
6399 NdisMoveMemory(pAdapter
->StaCfg
.PMK
, keyMaterial
, 32);
6404 PasswordHash((char *)arg
, pAdapter
->MlmeAux
.Ssid
, pAdapter
->MlmeAux
.SsidLen
, keyMaterial
);
6405 NdisMoveMemory(pAdapter
->StaCfg
.PMK
, keyMaterial
, 32);
6410 if(pAdapter
->StaCfg
.BssType
== BSS_ADHOC
&&
6411 pAdapter
->StaCfg
.AuthMode
== Ndis802_11AuthModeWPANone
)
6413 pAdapter
->StaCfg
.WpaState
= SS_NOTUSE
;
6417 // Start STA supplicant state machine
6418 pAdapter
->StaCfg
.WpaState
= SS_START
;
6425 ==========================================================================
6427 Set Power Saving mode
6429 TRUE if all parameters are OK, FALSE otherwise
6430 ==========================================================================
6432 INT
Set_PSMode_Proc(
6433 IN PRTMP_ADAPTER pAdapter
,
6436 if (pAdapter
->StaCfg
.BssType
== BSS_INFRA
)
6438 if ((strcmp(arg
, "Max_PSP") == 0) ||
6439 (strcmp(arg
, "max_psp") == 0) ||
6440 (strcmp(arg
, "MAX_PSP") == 0))
6442 // do NOT turn on PSM bit here, wait until MlmeCheckForPsmChange()
6443 // to exclude certain situations.
6444 if (pAdapter
->StaCfg
.bWindowsACCAMEnable
== FALSE
)
6445 pAdapter
->StaCfg
.WindowsPowerMode
= Ndis802_11PowerModeMAX_PSP
;
6446 pAdapter
->StaCfg
.WindowsBatteryPowerMode
= Ndis802_11PowerModeMAX_PSP
;
6447 OPSTATUS_SET_FLAG(pAdapter
, fOP_STATUS_RECEIVE_DTIM
);
6448 pAdapter
->StaCfg
.DefaultListenCount
= 5;
6451 else if ((strcmp(arg
, "Fast_PSP") == 0) ||
6452 (strcmp(arg
, "fast_psp") == 0) ||
6453 (strcmp(arg
, "FAST_PSP") == 0))
6455 // do NOT turn on PSM bit here, wait until MlmeCheckForPsmChange()
6456 // to exclude certain situations.
6457 OPSTATUS_SET_FLAG(pAdapter
, fOP_STATUS_RECEIVE_DTIM
);
6458 if (pAdapter
->StaCfg
.bWindowsACCAMEnable
== FALSE
)
6459 pAdapter
->StaCfg
.WindowsPowerMode
= Ndis802_11PowerModeFast_PSP
;
6460 pAdapter
->StaCfg
.WindowsBatteryPowerMode
= Ndis802_11PowerModeFast_PSP
;
6461 pAdapter
->StaCfg
.DefaultListenCount
= 3;
6463 else if ((strcmp(arg
, "Legacy_PSP") == 0) ||
6464 (strcmp(arg
, "legacy_psp") == 0) ||
6465 (strcmp(arg
, "LEGACY_PSP") == 0))
6467 // do NOT turn on PSM bit here, wait until MlmeCheckForPsmChange()
6468 // to exclude certain situations.
6469 OPSTATUS_SET_FLAG(pAdapter
, fOP_STATUS_RECEIVE_DTIM
);
6470 if (pAdapter
->StaCfg
.bWindowsACCAMEnable
== FALSE
)
6471 pAdapter
->StaCfg
.WindowsPowerMode
= Ndis802_11PowerModeLegacy_PSP
;
6472 pAdapter
->StaCfg
.WindowsBatteryPowerMode
= Ndis802_11PowerModeLegacy_PSP
;
6473 pAdapter
->StaCfg
.DefaultListenCount
= 3;
6477 //Default Ndis802_11PowerModeCAM
6478 // clear PSM bit immediately
6479 MlmeSetPsmBit(pAdapter
, PWR_ACTIVE
);
6480 OPSTATUS_SET_FLAG(pAdapter
, fOP_STATUS_RECEIVE_DTIM
);
6481 if (pAdapter
->StaCfg
.bWindowsACCAMEnable
== FALSE
)
6482 pAdapter
->StaCfg
.WindowsPowerMode
= Ndis802_11PowerModeCAM
;
6483 pAdapter
->StaCfg
.WindowsBatteryPowerMode
= Ndis802_11PowerModeCAM
;
6486 DBGPRINT(RT_DEBUG_TRACE
, ("Set_PSMode_Proc::(PSMode=%ld)\n", pAdapter
->StaCfg
.WindowsPowerMode
));
6495 #ifdef WPA_SUPPLICANT_SUPPORT
6497 ==========================================================================
6499 Set WpaSupport flag.
6501 0: Driver ignore wpa_supplicant.
6502 1: wpa_supplicant initiates scanning and AP selection.
6503 2: driver takes care of scanning, AP selection, and IEEE 802.11 association parameters.
6505 TRUE if all parameters are OK, FALSE otherwise
6506 ==========================================================================
6508 INT
Set_Wpa_Support(
6509 IN PRTMP_ADAPTER pAd
,
6513 if ( simple_strtol(arg
, 0, 10) == 0)
6514 pAd
->StaCfg
.WpaSupplicantUP
= WPA_SUPPLICANT_DISABLE
;
6515 else if ( simple_strtol(arg
, 0, 10) == 1)
6516 pAd
->StaCfg
.WpaSupplicantUP
= WPA_SUPPLICANT_ENABLE
;
6517 else if ( simple_strtol(arg
, 0, 10) == 2)
6518 pAd
->StaCfg
.WpaSupplicantUP
= WPA_SUPPLICANT_ENABLE_WITH_WEB_UI
;
6520 pAd
->StaCfg
.WpaSupplicantUP
= WPA_SUPPLICANT_DISABLE
;
6522 DBGPRINT(RT_DEBUG_TRACE
, ("Set_Wpa_Support::(WpaSupplicantUP=%d)\n", pAd
->StaCfg
.WpaSupplicantUP
));
6526 #endif // WPA_SUPPLICANT_SUPPORT //
6530 ==========================================================================
6534 pAdapter Pointer to our adapter
6535 wrq Pointer to the ioctl argument
6542 1.) iwpriv ra0 mac 0 ==> read MAC where Addr=0x0
6543 2.) iwpriv ra0 mac 0=12 ==> write MAC where Addr=0x0, value=12
6544 ==========================================================================
6547 IN PRTMP_ADAPTER pAdapter
,
6548 IN
struct iwreq
*wrq
)
6556 UCHAR temp
[16], temp2
[16];
6557 UINT32 macValue
= 0;
6561 memset(msg
, 0x00, 1024);
6562 if (wrq
->u
.data
.length
> 1) //No parameters.
6564 Status
= copy_from_user(arg
, wrq
->u
.data
.pointer
, (wrq
->u
.data
.length
> 255) ? 255 : wrq
->u
.data
.length
);
6567 //Parsing Read or Write
6572 if ((value
= rtstrchr(this_char
, '=')) != NULL
)
6575 if (!value
|| !*value
)
6578 if(strlen(this_char
) > 4)
6581 j
= strlen(this_char
);
6584 if(this_char
[j
] > 'f' || this_char
[j
] < '0')
6589 k
= j
= strlen(this_char
);
6592 this_char
[4-k
+j
] = this_char
[j
];
6596 this_char
[3-k
++]='0';
6599 if(strlen(this_char
) == 4)
6601 AtoH(this_char
, temp
, 2);
6602 macAddr
= *temp
*256 + temp
[1];
6603 if (macAddr
< 0xFFFF)
6605 RTMP_IO_READ32(pAdapter
, macAddr
, &macValue
);
6606 DBGPRINT(RT_DEBUG_TRACE
, ("MacAddr=%lx, MacValue=%x\n", macAddr
, macValue
));
6607 sprintf(msg
+strlen(msg
), "[0x%08lX]:%08X ", macAddr
, macValue
);
6610 {//Invalid parametes, so default printk all bbp
6617 memcpy(&temp2
, value
, strlen(value
));
6618 temp2
[strlen(value
)] = '\0';
6621 if((strlen(this_char
) > 4) || strlen(temp2
) > 8)
6624 j
= strlen(this_char
);
6627 if(this_char
[j
] > 'f' || this_char
[j
] < '0')
6634 if(temp2
[j
] > 'f' || temp2
[j
] < '0')
6639 k
= j
= strlen(this_char
);
6642 this_char
[4-k
+j
] = this_char
[j
];
6646 this_char
[3-k
++]='0';
6650 k
= j
= strlen(temp2
);
6653 temp2
[8-k
+j
] = temp2
[j
];
6661 AtoH(this_char
, temp
, 2);
6662 macAddr
= *temp
*256 + temp
[1];
6664 AtoH(temp2
, temp
, 4);
6665 macValue
= *temp
*256*256*256 + temp
[1]*256*256 + temp
[2]*256 + temp
[3];
6668 if (macAddr
== (HW_DEBUG_SETTING_BASE
+ 4))
6670 // 0x2bf4: byte0 non-zero: enable R17 tuning, 0: disable R17 tuning
6671 if (macValue
& 0x000000ff)
6673 pAdapter
->BbpTuning
.bEnable
= TRUE
;
6674 DBGPRINT(RT_DEBUG_TRACE
,("turn on R17 tuning\n"));
6679 pAdapter
->BbpTuning
.bEnable
= FALSE
;
6680 R66
= 0x26 + GET_LNA_GAIN(pAdapter
);
6682 if (ATE_ON(pAdapter
))
6684 ATE_BBP_IO_WRITE8_BY_REG_ID(pAdapter
, BBP_R66
, (0x26 + GET_LNA_GAIN(pAdapter
)));
6687 #endif // RALINK_ATE //
6688 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter
, BBP_R66
, (0x26 + GET_LNA_GAIN(pAdapter
)));
6689 DBGPRINT(RT_DEBUG_TRACE
,("turn off R17 tuning, restore to 0x%02x\n", R66
));
6694 DBGPRINT(RT_DEBUG_TRACE
, ("MacAddr=%02lx, MacValue=0x%x\n", macAddr
, macValue
));
6696 RTMP_IO_WRITE32(pAdapter
, macAddr
, macValue
);
6697 sprintf(msg
+strlen(msg
), "[0x%08lX]:%08X ", macAddr
, macValue
);
6702 if(strlen(msg
) == 1)
6703 sprintf(msg
+strlen(msg
), "===>Error command format!");
6705 // Copy the information into the user buffer
6706 wrq
->u
.data
.length
= strlen(msg
);
6707 Status
= copy_to_user(wrq
->u
.data
.pointer
, msg
, wrq
->u
.data
.length
);
6709 DBGPRINT(RT_DEBUG_TRACE
, ("<==RTMPIoctlMAC\n\n"));
6713 ==========================================================================
6717 pAdapter Pointer to our adapter
6718 wrq Pointer to the ioctl argument
6725 1.) iwpriv ra0 e2p 0 ==> read E2PROM where Addr=0x0
6726 2.) iwpriv ra0 e2p 0=1234 ==> write E2PROM where Addr=0x0, value=1234
6727 ==========================================================================
6729 VOID
RTMPIoctlE2PROM(
6730 IN PRTMP_ADAPTER pAdapter
,
6731 IN
struct iwreq
*wrq
)
6739 UCHAR temp
[16], temp2
[16];
6744 memset(msg
, 0x00, 1024);
6745 if (wrq
->u
.data
.length
> 1) //No parameters.
6747 Status
= copy_from_user(arg
, wrq
->u
.data
.pointer
, (wrq
->u
.data
.length
> 255) ? 255 : wrq
->u
.data
.length
);
6750 //Parsing Read or Write
6757 if ((value
= rtstrchr(this_char
, '=')) != NULL
)
6760 if (!value
|| !*value
)
6764 if(strlen(this_char
) > 4)
6767 j
= strlen(this_char
);
6770 if(this_char
[j
] > 'f' || this_char
[j
] < '0')
6775 k
= j
= strlen(this_char
);
6778 this_char
[4-k
+j
] = this_char
[j
];
6782 this_char
[3-k
++]='0';
6785 if(strlen(this_char
) == 4)
6787 AtoH(this_char
, temp
, 2);
6788 eepAddr
= *temp
*256 + temp
[1];
6789 if (eepAddr
< 0xFFFF)
6791 RT28xx_EEPROM_READ16(pAdapter
, eepAddr
, eepValue
);
6792 sprintf(msg
+strlen(msg
), "[0x%04X]:0x%04X ", eepAddr
, eepValue
);
6795 {//Invalid parametes, so default printk all bbp
6802 memcpy(&temp2
, value
, strlen(value
));
6803 temp2
[strlen(value
)] = '\0';
6806 if((strlen(this_char
) > 4) || strlen(temp2
) > 8)
6809 j
= strlen(this_char
);
6812 if(this_char
[j
] > 'f' || this_char
[j
] < '0')
6818 if(temp2
[j
] > 'f' || temp2
[j
] < '0')
6823 k
= j
= strlen(this_char
);
6826 this_char
[4-k
+j
] = this_char
[j
];
6830 this_char
[3-k
++]='0';
6834 k
= j
= strlen(temp2
);
6837 temp2
[4-k
+j
] = temp2
[j
];
6844 AtoH(this_char
, temp
, 2);
6845 eepAddr
= *temp
*256 + temp
[1];
6847 AtoH(temp2
, temp
, 2);
6848 eepValue
= *temp
*256 + temp
[1];
6850 RT28xx_EEPROM_WRITE16(pAdapter
, eepAddr
, eepValue
);
6851 sprintf(msg
+strlen(msg
), "[0x%02X]:%02X ", eepAddr
, eepValue
);
6855 if(strlen(msg
) == 1)
6856 sprintf(msg
+strlen(msg
), "===>Error command format!");
6859 // Copy the information into the user buffer
6860 wrq
->u
.data
.length
= strlen(msg
);
6861 Status
= copy_to_user(wrq
->u
.data
.pointer
, msg
, wrq
->u
.data
.length
);
6863 DBGPRINT(RT_DEBUG_TRACE
, ("<==RTMPIoctlE2PROM\n"));
6870 INT
Set_TGnWifiTest_Proc(
6871 IN PRTMP_ADAPTER pAd
,
6874 if (simple_strtol(arg
, 0, 10) == 0)
6875 pAd
->StaCfg
.bTGnWifiTest
= FALSE
;
6877 pAd
->StaCfg
.bTGnWifiTest
= TRUE
;
6879 DBGPRINT(RT_DEBUG_TRACE
, ("IF Set_TGnWifiTest_Proc::(bTGnWifiTest=%d)\n", pAd
->StaCfg
.bTGnWifiTest
));
6883 INT
Set_LongRetryLimit_Proc(
6884 IN PRTMP_ADAPTER pAdapter
,
6887 TX_RTY_CFG_STRUC tx_rty_cfg
;
6888 UCHAR LongRetryLimit
= (UCHAR
)simple_strtol(arg
, 0, 10);
6890 RTMP_IO_READ32(pAdapter
, TX_RTY_CFG
, &tx_rty_cfg
.word
);
6891 tx_rty_cfg
.field
.LongRtyLimit
= LongRetryLimit
;
6892 RTMP_IO_WRITE32(pAdapter
, TX_RTY_CFG
, tx_rty_cfg
.word
);
6893 DBGPRINT(RT_DEBUG_TRACE
, ("IF Set_LongRetryLimit_Proc::(tx_rty_cfg=0x%x)\n", tx_rty_cfg
.word
));
6897 INT
Set_ShortRetryLimit_Proc(
6898 IN PRTMP_ADAPTER pAdapter
,
6901 TX_RTY_CFG_STRUC tx_rty_cfg
;
6902 UCHAR ShortRetryLimit
= (UCHAR
)simple_strtol(arg
, 0, 10);
6904 RTMP_IO_READ32(pAdapter
, TX_RTY_CFG
, &tx_rty_cfg
.word
);
6905 tx_rty_cfg
.field
.ShortRtyLimit
= ShortRetryLimit
;
6906 RTMP_IO_WRITE32(pAdapter
, TX_RTY_CFG
, tx_rty_cfg
.word
);
6907 DBGPRINT(RT_DEBUG_TRACE
, ("IF Set_ShortRetryLimit_Proc::(tx_rty_cfg=0x%x)\n", tx_rty_cfg
.word
));
6911 #ifdef EXT_BUILD_CHANNEL_LIST
6912 INT
Set_Ieee80211dClientMode_Proc(
6913 IN PRTMP_ADAPTER pAdapter
,
6916 if (simple_strtol(arg
, 0, 10) == 0)
6917 pAdapter
->StaCfg
.IEEE80211dClientMode
= Rt802_11_D_None
;
6918 else if (simple_strtol(arg
, 0, 10) == 1)
6919 pAdapter
->StaCfg
.IEEE80211dClientMode
= Rt802_11_D_Flexible
;
6920 else if (simple_strtol(arg
, 0, 10) == 2)
6921 pAdapter
->StaCfg
.IEEE80211dClientMode
= Rt802_11_D_Strict
;
6925 DBGPRINT(RT_DEBUG_TRACE
, ("Set_Ieee802dMode_Proc::(IEEEE0211dMode=%d)\n", pAdapter
->StaCfg
.IEEE80211dClientMode
));
6928 #endif // EXT_BUILD_CHANNEL_LIST //
6930 #ifdef CARRIER_DETECTION_SUPPORT
6931 INT
Set_CarrierDetect_Proc(
6932 IN PRTMP_ADAPTER pAd
,
6935 if (simple_strtol(arg
, 0, 10) == 0)
6936 pAd
->CommonCfg
.CarrierDetect
.Enable
= FALSE
;
6938 pAd
->CommonCfg
.CarrierDetect
.Enable
= TRUE
;
6940 DBGPRINT(RT_DEBUG_TRACE
, ("IF Set_CarrierDetect_Proc::(CarrierDetect.Enable=%d)\n", pAd
->CommonCfg
.CarrierDetect
.Enable
));
6943 #endif // CARRIER_DETECTION_SUPPORT //