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[];
64 typedef struct PACKED _RT_VERSION_INFO{
70 UINT DriverBuildMonth;
72 } RT_VERSION_INFO, *PRT_VERSION_INFO;
74 struct iw_priv_args privtab[] = {
76 IW_PRIV_TYPE_CHAR | 1024, 0,
79 { RTPRIV_IOCTL_SHOW, IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK,
81 /* --- sub-ioctls definitions --- */
83 IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "connStatus" },
85 IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "driverVer" },
87 IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "bainfo" },
89 IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "descinfo" },
91 IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "radio_off" },
93 IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "radio_on" },
94 #ifdef QOS_DLS_SUPPORT
95 { SHOW_DLS_ENTRY_INFO,
96 IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "dlsentryinfo" },
97 #endif // QOS_DLS_SUPPORT //
99 IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "show" },
100 { SHOW_ADHOC_ENTRY_INFO,
101 IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "adhocEntry" },
102 /* --- sub-ioctls relations --- */
106 IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK,
109 IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | 1024,
111 #ifdef RTMP_RF_RW_SUPPORT
113 IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK,
115 #endif // RTMP_RF_RW_SUPPORT //
117 IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | 1024,
121 { RTPRIV_IOCTL_STATISTICS,
122 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK,
124 { RTPRIV_IOCTL_GSITESURVEY,
125 0, IW_PRIV_TYPE_CHAR | 1024,
131 static __s32 ralinkrate[] =
132 {2, 4, 11, 22, // CCK
133 12, 18, 24, 36, 48, 72, 96, 108, // OFDM
134 13, 26, 39, 52, 78, 104, 117, 130, 26, 52, 78, 104, 156, 208, 234, 260, // 20MHz, 800ns GI, MCS: 0 ~ 15
135 39, 78, 117, 156, 234, 312, 351, 390, // 20MHz, 800ns GI, MCS: 16 ~ 23
136 27, 54, 81, 108, 162, 216, 243, 270, 54, 108, 162, 216, 324, 432, 486, 540, // 40MHz, 800ns GI, MCS: 0 ~ 15
137 81, 162, 243, 324, 486, 648, 729, 810, // 40MHz, 800ns GI, MCS: 16 ~ 23
138 14, 29, 43, 57, 87, 115, 130, 144, 29, 59, 87, 115, 173, 230, 260, 288, // 20MHz, 400ns GI, MCS: 0 ~ 15
139 43, 87, 130, 173, 260, 317, 390, 433, // 20MHz, 400ns GI, MCS: 16 ~ 23
140 30, 60, 90, 120, 180, 240, 270, 300, 60, 120, 180, 240, 360, 480, 540, 600, // 40MHz, 400ns GI, MCS: 0 ~ 15
141 90, 180, 270, 360, 540, 720, 810, 900};
146 IN PRTMP_ADAPTER pAdapter,
150 INT Set_WmmCapable_Proc(
151 IN PRTMP_ADAPTER pAd,
155 INT Set_NetworkType_Proc(
156 IN PRTMP_ADAPTER pAdapter,
159 INT Set_AuthMode_Proc(
160 IN PRTMP_ADAPTER pAdapter,
163 INT Set_EncrypType_Proc(
164 IN PRTMP_ADAPTER pAdapter,
167 INT Set_DefaultKeyID_Proc(
168 IN PRTMP_ADAPTER pAdapter,
172 IN PRTMP_ADAPTER pAdapter,
176 IN PRTMP_ADAPTER pAdapter,
180 IN PRTMP_ADAPTER pAdapter,
184 IN PRTMP_ADAPTER pAdapter,
188 IN PRTMP_ADAPTER pAdapter,
193 IN PRTMP_ADAPTER pAdapter,
197 INT Set_PCIePSLevel_Proc(
198 IN PRTMP_ADAPTER pAdapter,
201 #ifdef WPA_SUPPLICANT_SUPPORT
203 IN PRTMP_ADAPTER pAd,
205 #endif // WPA_SUPPLICANT_SUPPORT //
210 IN PRTMP_ADAPTER pAdapter,
211 IN struct iwreq *wrq);
213 VOID RTMPIoctlE2PROM(
214 IN PRTMP_ADAPTER pAdapter,
215 IN struct iwreq *wrq);
219 NDIS_STATUS RTMPWPANoneAddKeyProc(
220 IN PRTMP_ADAPTER pAd,
223 INT Set_FragTest_Proc(
224 IN PRTMP_ADAPTER pAdapter,
227 #ifdef DOT11_N_SUPPORT
228 INT Set_TGnWifiTest_Proc(
229 IN PRTMP_ADAPTER pAd,
231 #endif // DOT11_N_SUPPORT //
233 INT Set_LongRetryLimit_Proc(
234 IN PRTMP_ADAPTER pAdapter,
237 INT Set_ShortRetryLimit_Proc(
238 IN PRTMP_ADAPTER pAdapter,
241 #ifdef EXT_BUILD_CHANNEL_LIST
242 INT Set_Ieee80211dClientMode_Proc(
243 IN PRTMP_ADAPTER pAdapter,
245 #endif // EXT_BUILD_CHANNEL_LIST //
247 #ifdef CARRIER_DETECTION_SUPPORT
248 INT Set_CarrierDetect_Proc(
249 IN PRTMP_ADAPTER pAd,
251 #endif // CARRIER_DETECTION_SUPPORT //
253 INT Show_Adhoc_MacTable_Proc(
254 IN PRTMP_ADAPTER pAd,
257 #ifdef RTMP_RF_RW_SUPPORT
259 IN PRTMP_ADAPTER pAdapter,
260 IN struct iwreq *wrq);
261 #endif // RTMP_RF_RW_SUPPORT //
264 INT Set_BeaconLostTime_Proc(
265 IN PRTMP_ADAPTER pAd,
268 INT Set_AutoRoaming_Proc(
269 IN PRTMP_ADAPTER pAd,
272 INT Set_SiteSurvey_Proc(
273 IN PRTMP_ADAPTER pAd,
276 INT Set_ForceTxBurst_Proc(
277 IN PRTMP_ADAPTER pAd,
280 #ifdef ANT_DIVERSITY_SUPPORT
281 INT Set_Antenna_Proc(
282 IN PRTMP_ADAPTER pAd,
284 #endif // ANT_DIVERSITY_SUPPORT //
288 INT (*set_proc)(PRTMP_ADAPTER pAdapter, PSTRING arg);
289 } *PRTMP_PRIVATE_SET_PROC, RTMP_PRIVATE_SUPPORT_PROC[] = {
290 {"DriverVersion", Set_DriverVersion_Proc},
291 {"CountryRegion", Set_CountryRegion_Proc},
292 {"CountryRegionABand", Set_CountryRegionABand_Proc},
293 {"SSID", Set_SSID_Proc},
294 {"WirelessMode", Set_WirelessMode_Proc},
295 {"TxBurst", Set_TxBurst_Proc},
296 {"TxPreamble", Set_TxPreamble_Proc},
297 {"TxPower", Set_TxPower_Proc},
298 {"Channel", Set_Channel_Proc},
299 {"BGProtection", Set_BGProtection_Proc},
300 {"RTSThreshold", Set_RTSThreshold_Proc},
301 {"FragThreshold", Set_FragThreshold_Proc},
302 #ifdef DOT11_N_SUPPORT
303 {"HtBw", Set_HtBw_Proc},
304 {"HtMcs", Set_HtMcs_Proc},
305 {"HtGi", Set_HtGi_Proc},
306 {"HtOpMode", Set_HtOpMode_Proc},
307 {"HtExtcha", Set_HtExtcha_Proc},
308 {"HtMpduDensity", Set_HtMpduDensity_Proc},
309 {"HtBaWinSize", Set_HtBaWinSize_Proc},
310 {"HtRdg", Set_HtRdg_Proc},
311 {"HtAmsdu", Set_HtAmsdu_Proc},
312 {"HtAutoBa", Set_HtAutoBa_Proc},
313 {"HtBaDecline", Set_BADecline_Proc},
314 {"HtProtect", Set_HtProtect_Proc},
315 {"HtMimoPs", Set_HtMimoPs_Proc},
316 {"HtDisallowTKIP", Set_HtDisallowTKIP_Proc},
317 #endif // DOT11_N_SUPPORT //
319 #ifdef AGGREGATION_SUPPORT
320 {"PktAggregate", Set_PktAggregate_Proc},
321 #endif // AGGREGATION_SUPPORT //
324 {"WmmCapable", Set_WmmCapable_Proc},
326 {"IEEE80211H", Set_IEEE80211H_Proc},
327 {"NetworkType", Set_NetworkType_Proc},
328 {"AuthMode", Set_AuthMode_Proc},
329 {"EncrypType", Set_EncrypType_Proc},
330 {"DefaultKeyID", Set_DefaultKeyID_Proc},
331 {"Key1", Set_Key1_Proc},
332 {"Key2", Set_Key2_Proc},
333 {"Key3", Set_Key3_Proc},
334 {"Key4", Set_Key4_Proc},
335 {"WPAPSK", Set_WPAPSK_Proc},
336 {"ResetCounter", Set_ResetStatCounter_Proc},
337 {"PSMode", Set_PSMode_Proc},
339 {"Debug", Set_Debug_Proc},
343 {"ATE", Set_ATE_Proc},
344 {"ATEDA", Set_ATE_DA_Proc},
345 {"ATESA", Set_ATE_SA_Proc},
346 {"ATEBSSID", Set_ATE_BSSID_Proc},
347 {"ATECHANNEL", Set_ATE_CHANNEL_Proc},
348 {"ATETXPOW0", Set_ATE_TX_POWER0_Proc},
349 {"ATETXPOW1", Set_ATE_TX_POWER1_Proc},
350 {"ATETXANT", Set_ATE_TX_Antenna_Proc},
351 {"ATERXANT", Set_ATE_RX_Antenna_Proc},
352 {"ATETXFREQOFFSET", Set_ATE_TX_FREQOFFSET_Proc},
353 {"ATETXBW", Set_ATE_TX_BW_Proc},
354 {"ATETXLEN", Set_ATE_TX_LENGTH_Proc},
355 {"ATETXCNT", Set_ATE_TX_COUNT_Proc},
356 {"ATETXMCS", Set_ATE_TX_MCS_Proc},
357 {"ATETXMODE", Set_ATE_TX_MODE_Proc},
358 {"ATETXGI", Set_ATE_TX_GI_Proc},
359 {"ATERXFER", Set_ATE_RX_FER_Proc},
360 {"ATERRF", Set_ATE_Read_RF_Proc},
361 {"ATEWRF1", Set_ATE_Write_RF1_Proc},
362 {"ATEWRF2", Set_ATE_Write_RF2_Proc},
363 {"ATEWRF3", Set_ATE_Write_RF3_Proc},
364 {"ATEWRF4", Set_ATE_Write_RF4_Proc},
365 {"ATELDE2P", Set_ATE_Load_E2P_Proc},
366 {"ATERE2P", Set_ATE_Read_E2P_Proc},
367 {"ATESHOW", Set_ATE_Show_Proc},
368 {"ATEHELP", Set_ATE_Help_Proc},
370 #ifdef RALINK_28xx_QA
371 {"TxStop", Set_TxStop_Proc},
372 {"RxStop", Set_RxStop_Proc},
373 #endif // RALINK_28xx_QA //
374 #endif // RALINK_ATE //
376 #ifdef WPA_SUPPLICANT_SUPPORT
377 {"WpaSupport", Set_Wpa_Support},
378 #endif // WPA_SUPPLICANT_SUPPORT //
384 {"FixedTxMode", Set_FixedTxMode_Proc},
385 #ifdef CONFIG_APSTA_MIXED_SUPPORT
386 {"OpMode", Set_OpMode_Proc},
387 #endif // CONFIG_APSTA_MIXED_SUPPORT //
388 #ifdef DOT11_N_SUPPORT
389 {"TGnWifiTest", Set_TGnWifiTest_Proc},
390 {"ForceGF", Set_ForceGF_Proc},
391 #endif // DOT11_N_SUPPORT //
392 #ifdef QOS_DLS_SUPPORT
393 {"DlsAddEntry", Set_DlsAddEntry_Proc},
394 {"DlsTearDownEntry", Set_DlsTearDownEntry_Proc},
395 #endif // QOS_DLS_SUPPORT //
396 {"LongRetry", Set_LongRetryLimit_Proc},
397 {"ShortRetry", Set_ShortRetryLimit_Proc},
398 #ifdef EXT_BUILD_CHANNEL_LIST
399 {"11dClientMode", Set_Ieee80211dClientMode_Proc},
400 #endif // EXT_BUILD_CHANNEL_LIST //
401 #ifdef CARRIER_DETECTION_SUPPORT
402 {"CarrierDetect", Set_CarrierDetect_Proc},
403 #endif // CARRIER_DETECTION_SUPPORT //
406 //2008/09/11:KH add to support efuse<--
408 #ifdef RTMP_EFUSE_SUPPORT
409 {"efuseFreeNumber", set_eFuseGetFreeBlockCount_Proc},
410 {"efuseDump", set_eFusedump_Proc},
411 {"efuseLoadFromBin", set_eFuseLoadFromBin_Proc},
412 {"efuseBufferModeWriteBack", set_eFuseBufferModeWriteBack_Proc},
413 #endif // RTMP_EFUSE_SUPPORT //
414 #ifdef ANT_DIVERSITY_SUPPORT
415 {"ant", Set_Antenna_Proc},
416 #endif // ANT_DIVERSITY_SUPPORT //
418 //2008/09/11:KH add to support efuse-->
420 {"BeaconLostTime", Set_BeaconLostTime_Proc},
421 {"AutoRoaming", Set_AutoRoaming_Proc},
422 {"SiteSurvey", Set_SiteSurvey_Proc},
423 {"ForceTxBurst", Set_ForceTxBurst_Proc},
430 IN PRTMP_ADAPTER pAd,
431 IN PNDIS_802_11_KEY pKey)
434 MAC_TABLE_ENTRY *pEntry;
436 DBGPRINT(RT_DEBUG_TRACE, ("RTMPAddKey ------>\n"));
438 if (pAd->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
440 if (pKey->KeyIndex & 0x80000000)
442 if (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPANone)
444 NdisZeroMemory(pAd->StaCfg.PMK, 32);
445 NdisMoveMemory(pAd->StaCfg.PMK, pKey->KeyMaterial, pKey->KeyLength);
449 NdisZeroMemory(&pAd->SharedKey[BSS0][0], sizeof(CIPHER_KEY));
450 pAd->SharedKey[BSS0][0].KeyLen = LEN_TKIP_EK;
451 NdisMoveMemory(pAd->SharedKey[BSS0][0].Key, pKey->KeyMaterial, LEN_TKIP_EK);
452 #ifdef WPA_SUPPLICANT_SUPPORT
453 if (pAd->StaCfg.PairCipher == Ndis802_11Encryption2Enabled)
455 NdisMoveMemory(pAd->SharedKey[BSS0][0].RxMic, pKey->KeyMaterial + LEN_TKIP_EK, LEN_TKIP_TXMICK);
456 NdisMoveMemory(pAd->SharedKey[BSS0][0].TxMic, pKey->KeyMaterial + LEN_TKIP_EK + LEN_TKIP_TXMICK, LEN_TKIP_RXMICK);
459 #endif // WPA_SUPPLICANT_SUPPORT //
461 NdisMoveMemory(pAd->SharedKey[BSS0][0].TxMic, pKey->KeyMaterial + LEN_TKIP_EK, LEN_TKIP_TXMICK);
462 NdisMoveMemory(pAd->SharedKey[BSS0][0].RxMic, pKey->KeyMaterial + LEN_TKIP_EK + LEN_TKIP_TXMICK, LEN_TKIP_RXMICK);
465 // Decide its ChiperAlg
466 if (pAd->StaCfg.PairCipher == Ndis802_11Encryption2Enabled)
467 pAd->SharedKey[BSS0][0].CipherAlg = CIPHER_TKIP;
468 else if (pAd->StaCfg.PairCipher == Ndis802_11Encryption3Enabled)
469 pAd->SharedKey[BSS0][0].CipherAlg = CIPHER_AES;
471 pAd->SharedKey[BSS0][0].CipherAlg = CIPHER_NONE;
473 // Update these related information to MAC_TABLE_ENTRY
474 pEntry = &pAd->MacTab.Content[BSSID_WCID];
475 NdisMoveMemory(pEntry->PairwiseKey.Key, pAd->SharedKey[BSS0][0].Key, LEN_TKIP_EK);
476 NdisMoveMemory(pEntry->PairwiseKey.RxMic, pAd->SharedKey[BSS0][0].RxMic, LEN_TKIP_RXMICK);
477 NdisMoveMemory(pEntry->PairwiseKey.TxMic, pAd->SharedKey[BSS0][0].TxMic, LEN_TKIP_TXMICK);
478 pEntry->PairwiseKey.CipherAlg = pAd->SharedKey[BSS0][0].CipherAlg;
480 // Update pairwise key information to ASIC Shared Key Table
481 AsicAddSharedKeyEntry(pAd,
484 pAd->SharedKey[BSS0][0].CipherAlg,
485 pAd->SharedKey[BSS0][0].Key,
486 pAd->SharedKey[BSS0][0].TxMic,
487 pAd->SharedKey[BSS0][0].RxMic);
489 // Update ASIC WCID attribute table and IVEIV table
490 RTMPAddWcidAttributeEntry(pAd,
493 pAd->SharedKey[BSS0][0].CipherAlg,
496 if (pAd->StaCfg.AuthMode >= Ndis802_11AuthModeWPA2)
498 // set 802.1x port control
499 //pAd->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
500 STA_PORT_SECURED(pAd);
502 // Indicate Connected for GUI
503 pAd->IndicateMediaState = NdisMediaStateConnected;
509 pAd->StaCfg.DefaultKeyId = (pKey->KeyIndex & 0xFF);
510 NdisZeroMemory(&pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId], sizeof(CIPHER_KEY));
511 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].KeyLen = LEN_TKIP_EK;
512 NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].Key, pKey->KeyMaterial, LEN_TKIP_EK);
513 #ifdef WPA_SUPPLICANT_SUPPORT
514 if (pAd->StaCfg.GroupCipher == Ndis802_11Encryption2Enabled)
516 NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].RxMic, pKey->KeyMaterial + LEN_TKIP_EK, LEN_TKIP_TXMICK);
517 NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].TxMic, pKey->KeyMaterial + LEN_TKIP_EK + LEN_TKIP_TXMICK, LEN_TKIP_RXMICK);
520 #endif // WPA_SUPPLICANT_SUPPORT //
522 NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].TxMic, pKey->KeyMaterial + LEN_TKIP_EK, LEN_TKIP_TXMICK);
523 NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].RxMic, pKey->KeyMaterial + LEN_TKIP_EK + LEN_TKIP_TXMICK, LEN_TKIP_RXMICK);
526 // Update Shared Key CipherAlg
527 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg = CIPHER_NONE;
528 if (pAd->StaCfg.GroupCipher == Ndis802_11Encryption2Enabled)
529 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg = CIPHER_TKIP;
530 else if (pAd->StaCfg.GroupCipher == Ndis802_11Encryption3Enabled)
531 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg = CIPHER_AES;
533 // Update group key information to ASIC Shared Key Table
534 AsicAddSharedKeyEntry(pAd,
536 pAd->StaCfg.DefaultKeyId,
537 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg,
538 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].Key,
539 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].TxMic,
540 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].RxMic);
542 // Update ASIC WCID attribute table and IVEIV table
543 RTMPAddWcidAttributeEntry(pAd,
545 pAd->StaCfg.DefaultKeyId,
546 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg,
549 // set 802.1x port control
550 //pAd->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
551 STA_PORT_SECURED(pAd);
553 // Indicate Connected for GUI
554 pAd->IndicateMediaState = NdisMediaStateConnected;
557 else // dynamic WEP from wpa_supplicant
562 if(pKey->KeyLength == 32)
565 KeyIdx = pKey->KeyIndex & 0x0fffffff;
569 // it is a default shared key, for Pairwise key setting
570 if (pKey->KeyIndex & 0x80000000)
572 pEntry = MacTableLookup(pAd, pKey->BSSID);
576 DBGPRINT(RT_DEBUG_TRACE, ("RTMPAddKey: Set Pair-wise Key\n"));
578 // set key material and key length
579 pEntry->PairwiseKey.KeyLen = (UCHAR)pKey->KeyLength;
580 NdisMoveMemory(pEntry->PairwiseKey.Key, &pKey->KeyMaterial, pKey->KeyLength);
583 if (pKey->KeyLength == 5)
584 pEntry->PairwiseKey.CipherAlg = CIPHER_WEP64;
586 pEntry->PairwiseKey.CipherAlg = CIPHER_WEP128;
588 // Add Pair-wise key to Asic
589 AsicAddPairwiseKeyEntry(
593 &pEntry->PairwiseKey);
595 // update WCID attribute table and IVEIV table for this entry
596 RTMPAddWcidAttributeEntry(
599 KeyIdx, // The value may be not zero
600 pEntry->PairwiseKey.CipherAlg,
607 // Default key for tx (shared key)
608 pAd->StaCfg.DefaultKeyId = (UCHAR) KeyIdx;
610 // set key material and key length
611 pAd->SharedKey[BSS0][KeyIdx].KeyLen = (UCHAR) pKey->KeyLength;
612 NdisMoveMemory(pAd->SharedKey[BSS0][KeyIdx].Key, &pKey->KeyMaterial, pKey->KeyLength);
615 if (pKey->KeyLength == 5)
616 pAd->SharedKey[BSS0][KeyIdx].CipherAlg = CIPHER_WEP64;
618 pAd->SharedKey[BSS0][KeyIdx].CipherAlg = CIPHER_WEP128;
620 CipherAlg = pAd->SharedKey[BSS0][KeyIdx].CipherAlg;
621 Key = pAd->SharedKey[BSS0][KeyIdx].Key;
623 // Set Group key material to Asic
624 AsicAddSharedKeyEntry(pAd, BSS0, KeyIdx, CipherAlg, Key, NULL, NULL);
626 // Update WCID attribute table and IVEIV table for this group key table
627 RTMPAddWcidAttributeEntry(pAd, BSS0, KeyIdx, CipherAlg, NULL);
636 char * rtstrchr(const char * s, int c)
638 for(; *s != (char) c; ++s)
645 This is required for LinEX2004/kernel2.6.7 to provide iwlist scanning function
649 rt_ioctl_giwname(struct net_device *dev,
650 struct iw_request_info *info,
651 char *name, char *extra)
655 strncpy(name, "RT2860 Wireless", IFNAMSIZ);
656 #endif // RTMP_MAC_PCI //
660 int rt_ioctl_siwfreq(struct net_device *dev,
661 struct iw_request_info *info,
662 struct iw_freq *freq, char *extra)
664 PRTMP_ADAPTER pAdapter = RTMP_OS_NETDEV_GET_PRIV(dev);
667 //check if the interface is down
668 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
670 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
678 if((freq->e == 0) && (freq->m <= 1000))
679 chan = freq->m; // Setting by channel number
681 MAP_KHZ_TO_CHANNEL_ID( (freq->m /100) , chan); // Setting by frequency - search the table , like 2.412G, 2.422G,
683 if (ChannelSanity(pAdapter, chan) == TRUE)
685 pAdapter->CommonCfg.Channel = chan;
686 DBGPRINT(RT_DEBUG_ERROR, ("==>rt_ioctl_siwfreq::SIOCSIWFREQ[cmd=0x%x] (Channel=%d)\n", SIOCSIWFREQ, pAdapter->CommonCfg.Channel));
695 int rt_ioctl_giwfreq(struct net_device *dev,
696 struct iw_request_info *info,
697 struct iw_freq *freq, char *extra)
699 PRTMP_ADAPTER pAdapter = NULL;
703 pAdapter = RTMP_OS_NETDEV_GET_PRIV(dev);
704 if (pAdapter == NULL)
706 /* if 1st open fail, pAd will be free;
707 So the net_dev->priv will be NULL in 2rd open */
711 ch = pAdapter->CommonCfg.Channel;
713 DBGPRINT(RT_DEBUG_TRACE,("==>rt_ioctl_giwfreq %d\n", ch));
715 MAP_CHANNEL_ID_TO_KHZ(ch, m);
722 int rt_ioctl_siwmode(struct net_device *dev,
723 struct iw_request_info *info,
724 __u32 *mode, char *extra)
726 PRTMP_ADAPTER pAdapter = RTMP_OS_NETDEV_GET_PRIV(dev);
728 //check if the interface is down
729 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
731 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
738 Set_NetworkType_Proc(pAdapter, "Adhoc");
741 Set_NetworkType_Proc(pAdapter, "Infra");
743 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,4,20))
744 case IW_MODE_MONITOR:
745 Set_NetworkType_Proc(pAdapter, "Monitor");
749 DBGPRINT(RT_DEBUG_TRACE, ("===>rt_ioctl_siwmode::SIOCSIWMODE (unknown %d)\n", *mode));
753 // Reset Ralink supplicant to not use, it will be set to start when UI set PMK key
754 pAdapter->StaCfg.WpaState = SS_NOTUSE;
760 int rt_ioctl_giwmode(struct net_device *dev,
761 struct iw_request_info *info,
762 __u32 *mode, char *extra)
764 PRTMP_ADAPTER pAdapter = RTMP_OS_NETDEV_GET_PRIV(dev);
766 if (pAdapter == NULL)
768 /* if 1st open fail, pAd will be free;
769 So the net_dev->priv will be NULL in 2rd open */
773 if (ADHOC_ON(pAdapter))
774 *mode = IW_MODE_ADHOC;
775 else if (INFRA_ON(pAdapter))
776 *mode = IW_MODE_INFRA;
777 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,4,20))
778 else if (MONITOR_ON(pAdapter))
780 *mode = IW_MODE_MONITOR;
784 *mode = IW_MODE_AUTO;
786 DBGPRINT(RT_DEBUG_TRACE, ("==>rt_ioctl_giwmode(mode=%d)\n", *mode));
790 int rt_ioctl_siwsens(struct net_device *dev,
791 struct iw_request_info *info,
792 char *name, char *extra)
794 PRTMP_ADAPTER pAdapter = RTMP_OS_NETDEV_GET_PRIV(dev);
796 //check if the interface is down
797 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
799 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
806 int rt_ioctl_giwsens(struct net_device *dev,
807 struct iw_request_info *info,
808 char *name, char *extra)
813 int rt_ioctl_giwrange(struct net_device *dev,
814 struct iw_request_info *info,
815 struct iw_point *data, char *extra)
817 PRTMP_ADAPTER pAdapter = RTMP_OS_NETDEV_GET_PRIV(dev);
818 struct iw_range *range = (struct iw_range *) extra;
822 if (pAdapter == NULL)
824 /* if 1st open fail, pAd will be free;
825 So the net_dev->priv will be NULL in 2rd open */
829 DBGPRINT(RT_DEBUG_TRACE ,("===>rt_ioctl_giwrange\n"));
830 data->length = sizeof(struct iw_range);
831 memset(range, 0, sizeof(struct iw_range));
833 range->txpower_capa = IW_TXPOW_DBM;
835 if (INFRA_ON(pAdapter)||ADHOC_ON(pAdapter))
837 range->min_pmp = 1 * 1024;
838 range->max_pmp = 65535 * 1024;
839 range->min_pmt = 1 * 1024;
840 range->max_pmt = 1000 * 1024;
841 range->pmp_flags = IW_POWER_PERIOD;
842 range->pmt_flags = IW_POWER_TIMEOUT;
843 range->pm_capa = IW_POWER_PERIOD | IW_POWER_TIMEOUT |
844 IW_POWER_UNICAST_R | IW_POWER_ALL_R;
847 range->we_version_compiled = WIRELESS_EXT;
848 range->we_version_source = 14;
850 range->retry_capa = IW_RETRY_LIMIT;
851 range->retry_flags = IW_RETRY_LIMIT;
852 range->min_retry = 0;
853 range->max_retry = 255;
855 range->num_channels = pAdapter->ChannelListNum;
858 for (i = 1; i <= range->num_channels; i++)
861 range->freq[val].i = pAdapter->ChannelList[i-1].Channel;
862 MAP_CHANNEL_ID_TO_KHZ(pAdapter->ChannelList[i-1].Channel, m);
863 range->freq[val].m = m * 100; /* OS_HZ */
865 range->freq[val].e = 1;
867 if (val == IW_MAX_FREQUENCIES)
870 range->num_frequency = val;
872 range->max_qual.qual = 100; /* what is correct max? This was not
873 * documented exactly. At least
874 * 69 has been observed. */
875 range->max_qual.level = 0; /* dB */
876 range->max_qual.noise = 0; /* dB */
878 /* What would be suitable values for "average/typical" qual? */
879 range->avg_qual.qual = 20;
880 range->avg_qual.level = -60;
881 range->avg_qual.noise = -95;
882 range->sensitivity = 3;
884 range->max_encoding_tokens = NR_WEP_KEYS;
885 range->num_encoding_sizes = 2;
886 range->encoding_size[0] = 5;
887 range->encoding_size[1] = 13;
890 range->max_rts = 2347;
891 range->min_frag = 256;
892 range->max_frag = 2346;
894 #if WIRELESS_EXT > 17
895 /* IW_ENC_CAPA_* bit field */
896 range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 |
897 IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP;
903 int rt_ioctl_siwap(struct net_device *dev,
904 struct iw_request_info *info,
905 struct sockaddr *ap_addr, char *extra)
907 PRTMP_ADAPTER pAdapter = RTMP_OS_NETDEV_GET_PRIV(dev);
908 NDIS_802_11_MAC_ADDRESS Bssid;
910 //check if the interface is down
911 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
913 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
917 if (pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE)
919 RTMP_MLME_RESET_STATE_MACHINE(pAdapter);
920 DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
923 // tell CNTL state machine to call NdisMSetInformationComplete() after completing
924 // this request, because this request is initiated by NDIS.
925 pAdapter->MlmeAux.CurrReqIsFromNdis = FALSE;
926 // Prevent to connect AP again in STAMlmePeriodicExec
927 pAdapter->MlmeAux.AutoReconnectSsidLen= 32;
929 memset(Bssid, 0, MAC_ADDR_LEN);
930 memcpy(Bssid, ap_addr->sa_data, MAC_ADDR_LEN);
931 MlmeEnqueue(pAdapter,
932 MLME_CNTL_STATE_MACHINE,
934 sizeof(NDIS_802_11_MAC_ADDRESS),
937 DBGPRINT(RT_DEBUG_TRACE, ("IOCTL::SIOCSIWAP %02x:%02x:%02x:%02x:%02x:%02x\n",
938 Bssid[0], Bssid[1], Bssid[2], Bssid[3], Bssid[4], Bssid[5]));
943 int rt_ioctl_giwap(struct net_device *dev,
944 struct iw_request_info *info,
945 struct sockaddr *ap_addr, char *extra)
947 PRTMP_ADAPTER pAdapter = RTMP_OS_NETDEV_GET_PRIV(dev);
949 if (pAdapter == NULL)
951 /* if 1st open fail, pAd will be free;
952 So the net_dev->priv will be NULL in 2rd open */
956 if (INFRA_ON(pAdapter) || ADHOC_ON(pAdapter))
958 ap_addr->sa_family = ARPHRD_ETHER;
959 memcpy(ap_addr->sa_data, &pAdapter->CommonCfg.Bssid, ETH_ALEN);
961 #ifdef WPA_SUPPLICANT_SUPPORT
963 else if (pAdapter->StaCfg.WpaSupplicantUP != WPA_SUPPLICANT_DISABLE)
965 ap_addr->sa_family = ARPHRD_ETHER;
966 memcpy(ap_addr->sa_data, &pAdapter->MlmeAux.Bssid, ETH_ALEN);
968 #endif // WPA_SUPPLICANT_SUPPORT //
971 DBGPRINT(RT_DEBUG_TRACE, ("IOCTL::SIOCGIWAP(=EMPTY)\n"));
979 * Units are in db above the noise floor. That means the
980 * rssi values reported in the tx/rx descriptors in the
981 * driver are the SNR expressed in db.
983 * If you assume that the noise floor is -95, which is an
984 * excellent assumption 99.5 % of the time, then you can
985 * derive the absolute signal level (i.e. -95 + rssi).
986 * There are some other slight factors to take into account
987 * depending on whether the rssi measurement is from 11b,
988 * 11g, or 11a. These differences are at most 2db and
991 * NB: various calculations are based on the orinoco/wavelan
992 * drivers for compatibility
994 static void set_quality(PRTMP_ADAPTER pAdapter,
995 struct iw_quality *iq,
1002 ChannelQuality = 100;
1003 else if (rssi >= -80) // between -50 ~ -80dbm
1004 ChannelQuality = (__u8)(24 + ((rssi + 80) * 26)/10);
1005 else if (rssi >= -90) // between -80 ~ -90dbm
1006 ChannelQuality = (__u8)((rssi + 90) * 26)/10;
1010 iq->qual = (__u8)ChannelQuality;
1012 iq->level = (__u8)(rssi);
1013 iq->noise = (pAdapter->BbpWriteLatch[66] > pAdapter->BbpTuning.FalseCcaUpperThreshold) ? ((__u8)pAdapter->BbpTuning.FalseCcaUpperThreshold) : ((__u8) pAdapter->BbpWriteLatch[66]); // noise level (dBm)
1014 iq->noise += 256 - 143;
1015 iq->updated = pAdapter->iw_stats.qual.updated;
1018 int rt_ioctl_iwaplist(struct net_device *dev,
1019 struct iw_request_info *info,
1020 struct iw_point *data, char *extra)
1022 PRTMP_ADAPTER pAdapter = RTMP_OS_NETDEV_GET_PRIV(dev);
1024 struct sockaddr addr[IW_MAX_AP];
1025 struct iw_quality qual[IW_MAX_AP];
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"));
1037 for (i = 0; i <IW_MAX_AP ; i++)
1039 if (i >= pAdapter->ScanTab.BssNr)
1041 addr[i].sa_family = ARPHRD_ETHER;
1042 memcpy(addr[i].sa_data, &pAdapter->ScanTab.BssEntry[i].Bssid, MAC_ADDR_LEN);
1043 set_quality(pAdapter, &qual[i], pAdapter->ScanTab.BssEntry[i].Rssi);
1046 memcpy(extra, &addr, i*sizeof(addr[0]));
1047 data->flags = 1; /* signal quality present (sort of) */
1048 memcpy(extra + i*sizeof(addr[0]), &qual, i*sizeof(qual[i]));
1054 int rt_ioctl_siwscan(struct net_device *dev,
1055 struct iw_request_info *info,
1056 struct iw_point *data, char *extra)
1058 PRTMP_ADAPTER pAdapter = RTMP_OS_NETDEV_GET_PRIV(dev);
1061 int Status = NDIS_STATUS_SUCCESS;
1063 //check if the interface is down
1064 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1066 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1070 if (MONITOR_ON(pAdapter))
1072 DBGPRINT(RT_DEBUG_TRACE, ("!!! Driver is in Monitor Mode now !!!\n"));
1077 #ifdef WPA_SUPPLICANT_SUPPORT
1078 if (pAdapter->StaCfg.WpaSupplicantUP == WPA_SUPPLICANT_ENABLE)
1080 pAdapter->StaCfg.WpaSupplicantScanCount++;
1082 #endif // WPA_SUPPLICANT_SUPPORT //
1084 pAdapter->StaCfg.bScanReqIsFromWebUI = TRUE;
1085 if (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
1086 return NDIS_STATUS_SUCCESS;
1090 #ifdef WPA_SUPPLICANT_SUPPORT
1091 if ((pAdapter->StaCfg.WpaSupplicantUP == WPA_SUPPLICANT_ENABLE) &&
1092 (pAdapter->StaCfg.WpaSupplicantScanCount > 3))
1094 DBGPRINT(RT_DEBUG_TRACE, ("!!! WpaSupplicantScanCount > 3\n"));
1095 Status = NDIS_STATUS_SUCCESS;
1098 #endif // WPA_SUPPLICANT_SUPPORT //
1100 if ((OPSTATUS_TEST_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED)) &&
1101 ((pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA) ||
1102 (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK)) &&
1103 (pAdapter->StaCfg.PortSecured == WPA_802_1X_PORT_NOT_SECURED))
1105 DBGPRINT(RT_DEBUG_TRACE, ("!!! Link UP, Port Not Secured! ignore this set::OID_802_11_BSSID_LIST_SCAN\n"));
1106 Status = NDIS_STATUS_SUCCESS;
1110 if (pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE)
1112 RTMP_MLME_RESET_STATE_MACHINE(pAdapter);
1113 DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
1116 // tell CNTL state machine to call NdisMSetInformationComplete() after completing
1117 // this request, because this request is initiated by NDIS.
1118 pAdapter->MlmeAux.CurrReqIsFromNdis = FALSE;
1119 // Reset allowed scan retries
1120 pAdapter->StaCfg.ScanCnt = 0;
1121 pAdapter->StaCfg.LastScanTime = Now;
1123 MlmeEnqueue(pAdapter,
1124 MLME_CNTL_STATE_MACHINE,
1125 OID_802_11_BSSID_LIST_SCAN,
1129 Status = NDIS_STATUS_SUCCESS;
1130 RTMP_MLME_HANDLER(pAdapter);
1132 return NDIS_STATUS_SUCCESS;
1135 int rt_ioctl_giwscan(struct net_device *dev,
1136 struct iw_request_info *info,
1137 struct iw_point *data, char *extra)
1140 PRTMP_ADAPTER pAdapter = RTMP_OS_NETDEV_GET_PRIV(dev);
1142 PSTRING current_ev = extra, previous_ev = extra;
1144 PSTRING current_val;
1145 STRING custom[MAX_CUSTOM_LEN] = {0};
1148 #endif // IWEVGENIE //
1149 struct iw_event iwe;
1151 if (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
1154 * Still scanning, indicate the caller should try again.
1160 #ifdef WPA_SUPPLICANT_SUPPORT
1161 if (pAdapter->StaCfg.WpaSupplicantUP == WPA_SUPPLICANT_ENABLE)
1163 pAdapter->StaCfg.WpaSupplicantScanCount = 0;
1165 #endif // WPA_SUPPLICANT_SUPPORT //
1167 if (pAdapter->ScanTab.BssNr == 0)
1173 #if WIRELESS_EXT >= 17
1174 if (data->length > 0)
1175 end_buf = extra + data->length;
1177 end_buf = extra + IW_SCAN_MAX_DATA;
1179 end_buf = extra + IW_SCAN_MAX_DATA;
1182 for (i = 0; i < pAdapter->ScanTab.BssNr; i++)
1184 if (current_ev >= end_buf)
1186 #if WIRELESS_EXT >= 17
1194 //================================
1195 memset(&iwe, 0, sizeof(iwe));
1196 iwe.cmd = SIOCGIWAP;
1197 iwe.u.ap_addr.sa_family = ARPHRD_ETHER;
1198 memcpy(iwe.u.ap_addr.sa_data, &pAdapter->ScanTab.BssEntry[i].Bssid, ETH_ALEN);
1200 previous_ev = current_ev;
1201 current_ev = IWE_STREAM_ADD_EVENT(info, current_ev,end_buf, &iwe, IW_EV_ADDR_LEN);
1202 if (current_ev == previous_ev)
1203 #if WIRELESS_EXT >= 17
1211 it will show scanned AP's WirelessMode .
1220 memset(&iwe, 0, sizeof(iwe));
1221 iwe.cmd = SIOCGIWNAME;
1225 PBSS_ENTRY pBssEntry=&pAdapter->ScanTab.BssEntry[i];
1226 BOOLEAN isGonly=FALSE;
1229 if (pBssEntry->Channel>14)
1231 if (pBssEntry->HtCapabilityLen!=0)
1232 strcpy(iwe.u.name,"802.11a/n");
1234 strcpy(iwe.u.name,"802.11a");
1239 if one of non B mode rate is set supported rate . it mean G only.
1241 for (rateCnt=0;rateCnt<pBssEntry->SupRateLen;rateCnt++)
1244 6Mbps(140) 9Mbps(146) and >=12Mbps(152) are supported rate , it mean G only.
1246 if (pBssEntry->SupRate[rateCnt]==140 || pBssEntry->SupRate[rateCnt]==146 || pBssEntry->SupRate[rateCnt]>=152)
1250 for (rateCnt=0;rateCnt<pBssEntry->ExtRateLen;rateCnt++)
1252 if (pBssEntry->ExtRate[rateCnt]==140 || pBssEntry->ExtRate[rateCnt]==146 || pBssEntry->ExtRate[rateCnt]>=152)
1257 if (pBssEntry->HtCapabilityLen!=0)
1260 strcpy(iwe.u.name,"802.11g/n");
1262 strcpy(iwe.u.name,"802.11b/g/n");
1267 strcpy(iwe.u.name,"802.11g");
1270 if (pBssEntry->SupRateLen==4 && pBssEntry->ExtRateLen==0)
1271 strcpy(iwe.u.name,"802.11b");
1273 strcpy(iwe.u.name,"802.11b/g");
1279 previous_ev = current_ev;
1280 current_ev = IWE_STREAM_ADD_EVENT(info, current_ev,end_buf, &iwe, IW_EV_ADDR_LEN);
1281 if (current_ev == previous_ev)
1282 #if WIRELESS_EXT >= 17
1289 //================================
1290 memset(&iwe, 0, sizeof(iwe));
1291 iwe.cmd = SIOCGIWESSID;
1292 iwe.u.data.length = pAdapter->ScanTab.BssEntry[i].SsidLen;
1293 iwe.u.data.flags = 1;
1295 previous_ev = current_ev;
1296 current_ev = IWE_STREAM_ADD_POINT(info, current_ev,end_buf, &iwe, (PSTRING) pAdapter->ScanTab.BssEntry[i].Ssid);
1297 if (current_ev == previous_ev)
1298 #if WIRELESS_EXT >= 17
1305 //================================
1306 memset(&iwe, 0, sizeof(iwe));
1307 iwe.cmd = SIOCGIWMODE;
1308 if (pAdapter->ScanTab.BssEntry[i].BssType == Ndis802_11IBSS)
1310 iwe.u.mode = IW_MODE_ADHOC;
1312 else if (pAdapter->ScanTab.BssEntry[i].BssType == Ndis802_11Infrastructure)
1314 iwe.u.mode = IW_MODE_INFRA;
1318 iwe.u.mode = IW_MODE_AUTO;
1320 iwe.len = IW_EV_UINT_LEN;
1322 previous_ev = current_ev;
1323 current_ev = IWE_STREAM_ADD_EVENT(info, current_ev, end_buf, &iwe, IW_EV_UINT_LEN);
1324 if (current_ev == previous_ev)
1325 #if WIRELESS_EXT >= 17
1331 //Channel and Frequency
1332 //================================
1333 memset(&iwe, 0, sizeof(iwe));
1334 iwe.cmd = SIOCGIWFREQ;
1335 if (INFRA_ON(pAdapter) || ADHOC_ON(pAdapter))
1336 iwe.u.freq.m = pAdapter->ScanTab.BssEntry[i].Channel;
1338 iwe.u.freq.m = pAdapter->ScanTab.BssEntry[i].Channel;
1342 previous_ev = current_ev;
1343 current_ev = IWE_STREAM_ADD_EVENT(info, current_ev,end_buf, &iwe, IW_EV_FREQ_LEN);
1344 if (current_ev == previous_ev)
1345 #if WIRELESS_EXT >= 17
1351 //Add quality statistics
1352 //================================
1353 memset(&iwe, 0, sizeof(iwe));
1355 iwe.u.qual.level = 0;
1356 iwe.u.qual.noise = 0;
1357 set_quality(pAdapter, &iwe.u.qual, pAdapter->ScanTab.BssEntry[i].Rssi);
1358 current_ev = IWE_STREAM_ADD_EVENT(info, current_ev, end_buf, &iwe, IW_EV_QUAL_LEN);
1359 if (current_ev == previous_ev)
1360 #if WIRELESS_EXT >= 17
1367 //================================
1368 memset(&iwe, 0, sizeof(iwe));
1369 iwe.cmd = SIOCGIWENCODE;
1370 if (CAP_IS_PRIVACY_ON (pAdapter->ScanTab.BssEntry[i].CapabilityInfo ))
1371 iwe.u.data.flags =IW_ENCODE_ENABLED | IW_ENCODE_NOKEY;
1373 iwe.u.data.flags = IW_ENCODE_DISABLED;
1375 previous_ev = current_ev;
1376 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);
1377 if (current_ev == previous_ev)
1378 #if WIRELESS_EXT >= 17
1385 //================================
1386 if (pAdapter->ScanTab.BssEntry[i].SupRateLen)
1388 UCHAR tmpRate = pAdapter->ScanTab.BssEntry[i].SupRate[pAdapter->ScanTab.BssEntry[i].SupRateLen-1];
1389 memset(&iwe, 0, sizeof(iwe));
1390 iwe.cmd = SIOCGIWRATE;
1391 current_val = current_ev + IW_EV_LCP_LEN;
1392 if (tmpRate == 0x82)
1393 iwe.u.bitrate.value = 1 * 1000000;
1394 else if (tmpRate == 0x84)
1395 iwe.u.bitrate.value = 2 * 1000000;
1396 else if (tmpRate == 0x8B)
1397 iwe.u.bitrate.value = 5.5 * 1000000;
1398 else if (tmpRate == 0x96)
1399 iwe.u.bitrate.value = 11 * 1000000;
1401 iwe.u.bitrate.value = (tmpRate/2) * 1000000;
1403 if (tmpRate == 0x6c && pAdapter->ScanTab.BssEntry[i].HtCapabilityLen > 0)
1405 int rate_count = sizeof(ralinkrate)/sizeof(__s32);
1406 HT_CAP_INFO capInfo = pAdapter->ScanTab.BssEntry[i].HtCapability.HtCapInfo;
1407 int shortGI = capInfo.ChannelWidth ? capInfo.ShortGIfor40 : capInfo.ShortGIfor20;
1408 int maxMCS = pAdapter->ScanTab.BssEntry[i].HtCapability.MCSSet[1] ? 15 : 7;
1409 int rate_index = 12 + ((UCHAR)capInfo.ChannelWidth * 24) + ((UCHAR)shortGI *48) + ((UCHAR)maxMCS);
1412 if (rate_index > rate_count)
1413 rate_index = rate_count;
1414 iwe.u.bitrate.value = ralinkrate[rate_index] * 500000;
1417 iwe.u.bitrate.disabled = 0;
1418 current_val = IWE_STREAM_ADD_VALUE(info, current_ev,
1419 current_val, end_buf, &iwe,
1422 if((current_val-current_ev)>IW_EV_LCP_LEN)
1423 current_ev = current_val;
1425 #if WIRELESS_EXT >= 17
1434 if (pAdapter->ScanTab.BssEntry[i].WpaIE.IELen > 0)
1436 memset(&iwe, 0, sizeof(iwe));
1437 memset(&custom[0], 0, MAX_CUSTOM_LEN);
1438 memcpy(custom, &(pAdapter->ScanTab.BssEntry[i].WpaIE.IE[0]),
1439 pAdapter->ScanTab.BssEntry[i].WpaIE.IELen);
1440 iwe.cmd = IWEVGENIE;
1441 iwe.u.data.length = pAdapter->ScanTab.BssEntry[i].WpaIE.IELen;
1442 current_ev = IWE_STREAM_ADD_POINT(info, current_ev, end_buf, &iwe, custom);
1443 if (current_ev == previous_ev)
1444 #if WIRELESS_EXT >= 17
1452 if (pAdapter->ScanTab.BssEntry[i].RsnIE.IELen > 0)
1454 memset(&iwe, 0, sizeof(iwe));
1455 memset(&custom[0], 0, MAX_CUSTOM_LEN);
1456 memcpy(custom, &(pAdapter->ScanTab.BssEntry[i].RsnIE.IE[0]),
1457 pAdapter->ScanTab.BssEntry[i].RsnIE.IELen);
1458 iwe.cmd = IWEVGENIE;
1459 iwe.u.data.length = pAdapter->ScanTab.BssEntry[i].RsnIE.IELen;
1460 current_ev = IWE_STREAM_ADD_POINT(info, current_ev, end_buf, &iwe, custom);
1461 if (current_ev == previous_ev)
1462 #if WIRELESS_EXT >= 17
1470 //================================
1471 if (pAdapter->ScanTab.BssEntry[i].WpaIE.IELen > 0)
1473 NdisZeroMemory(&iwe, sizeof(iwe));
1474 memset(&custom[0], 0, MAX_CUSTOM_LEN);
1475 iwe.cmd = IWEVCUSTOM;
1476 iwe.u.data.length = (pAdapter->ScanTab.BssEntry[i].WpaIE.IELen * 2) + 7;
1477 NdisMoveMemory(custom, "wpa_ie=", 7);
1478 for (idx = 0; idx < pAdapter->ScanTab.BssEntry[i].WpaIE.IELen; idx++)
1479 sprintf(custom, "%s%02x", custom, pAdapter->ScanTab.BssEntry[i].WpaIE.IE[idx]);
1480 previous_ev = current_ev;
1481 current_ev = IWE_STREAM_ADD_POINT(info, current_ev, end_buf, &iwe, custom);
1482 if (current_ev == previous_ev)
1483 #if WIRELESS_EXT >= 17
1491 if (pAdapter->ScanTab.BssEntry[i].RsnIE.IELen > 0)
1493 NdisZeroMemory(&iwe, sizeof(iwe));
1494 memset(&custom[0], 0, MAX_CUSTOM_LEN);
1495 iwe.cmd = IWEVCUSTOM;
1496 iwe.u.data.length = (pAdapter->ScanTab.BssEntry[i].RsnIE.IELen * 2) + 7;
1497 NdisMoveMemory(custom, "rsn_ie=", 7);
1498 for (idx = 0; idx < pAdapter->ScanTab.BssEntry[i].RsnIE.IELen; idx++)
1499 sprintf(custom, "%s%02x", custom, pAdapter->ScanTab.BssEntry[i].RsnIE.IE[idx]);
1500 previous_ev = current_ev;
1501 current_ev = IWE_STREAM_ADD_POINT(info, current_ev, end_buf, &iwe, custom);
1502 if (current_ev == previous_ev)
1503 #if WIRELESS_EXT >= 17
1509 #endif // IWEVGENIE //
1512 data->length = current_ev - extra;
1513 pAdapter->StaCfg.bScanReqIsFromWebUI = FALSE;
1514 DBGPRINT(RT_DEBUG_ERROR ,("===>rt_ioctl_giwscan. %d(%d) BSS returned, data->length = %d\n",i , pAdapter->ScanTab.BssNr, data->length));
1519 int rt_ioctl_siwessid(struct net_device *dev,
1520 struct iw_request_info *info,
1521 struct iw_point *data, char *essid)
1523 PRTMP_ADAPTER pAdapter = RTMP_OS_NETDEV_GET_PRIV(dev);
1525 //check if the interface is down
1526 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1528 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1534 PSTRING pSsidString = NULL;
1536 // Includes null character.
1537 if (data->length > (IW_ESSID_MAX_SIZE + 1))
1540 pSsidString = kmalloc(MAX_LEN_OF_SSID+1, MEM_ALLOC_FLAG);
1543 NdisZeroMemory(pSsidString, MAX_LEN_OF_SSID+1);
1544 NdisMoveMemory(pSsidString, essid, data->length);
1545 if (Set_SSID_Proc(pAdapter, pSsidString) == FALSE)
1554 if (Set_SSID_Proc(pAdapter, "") == FALSE)
1560 int rt_ioctl_giwessid(struct net_device *dev,
1561 struct iw_request_info *info,
1562 struct iw_point *data, char *essid)
1564 PRTMP_ADAPTER pAdapter = RTMP_OS_NETDEV_GET_PRIV(dev);
1566 if (pAdapter == NULL)
1568 /* if 1st open fail, pAd will be free;
1569 So the net_dev->priv will be NULL in 2rd open */
1574 if (MONITOR_ON(pAdapter))
1580 if (OPSTATUS_TEST_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED))
1582 DBGPRINT(RT_DEBUG_TRACE ,("MediaState is connected\n"));
1583 data->length = pAdapter->CommonCfg.SsidLen;
1584 memcpy(essid, pAdapter->CommonCfg.Ssid, pAdapter->CommonCfg.SsidLen);
1587 {//the ANY ssid was specified
1589 DBGPRINT(RT_DEBUG_TRACE ,("MediaState is not connected, ess\n"));
1596 int rt_ioctl_siwnickn(struct net_device *dev,
1597 struct iw_request_info *info,
1598 struct iw_point *data, char *nickname)
1600 PRTMP_ADAPTER pAdapter = RTMP_OS_NETDEV_GET_PRIV(dev);
1602 //check if the interface is down
1603 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1605 DBGPRINT(RT_DEBUG_TRACE ,("INFO::Network is down!\n"));
1609 if (data->length > IW_ESSID_MAX_SIZE)
1612 memset(pAdapter->nickname, 0, IW_ESSID_MAX_SIZE + 1);
1613 memcpy(pAdapter->nickname, nickname, data->length);
1619 int rt_ioctl_giwnickn(struct net_device *dev,
1620 struct iw_request_info *info,
1621 struct iw_point *data, char *nickname)
1623 PRTMP_ADAPTER pAdapter = RTMP_OS_NETDEV_GET_PRIV(dev);
1625 if (pAdapter == NULL)
1627 /* if 1st open fail, pAd will be free;
1628 So the net_dev->priv will be NULL in 2rd open */
1632 if (data->length > strlen((PSTRING) pAdapter->nickname) + 1)
1633 data->length = strlen((PSTRING) pAdapter->nickname) + 1;
1634 if (data->length > 0) {
1635 memcpy(nickname, pAdapter->nickname, data->length-1);
1636 nickname[data->length-1] = '\0';
1641 int rt_ioctl_siwrts(struct net_device *dev,
1642 struct iw_request_info *info,
1643 struct iw_param *rts, char *extra)
1645 PRTMP_ADAPTER pAdapter = RTMP_OS_NETDEV_GET_PRIV(dev);
1648 //check if the interface is down
1649 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1651 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1656 val = MAX_RTS_THRESHOLD;
1657 else if (rts->value < 0 || rts->value > MAX_RTS_THRESHOLD)
1659 else if (rts->value == 0)
1660 val = MAX_RTS_THRESHOLD;
1664 if (val != pAdapter->CommonCfg.RtsThreshold)
1665 pAdapter->CommonCfg.RtsThreshold = val;
1670 int rt_ioctl_giwrts(struct net_device *dev,
1671 struct iw_request_info *info,
1672 struct iw_param *rts, char *extra)
1674 PRTMP_ADAPTER pAdapter = RTMP_OS_NETDEV_GET_PRIV(dev);
1676 if (pAdapter == NULL)
1678 /* if 1st open fail, pAd will be free;
1679 So the net_dev->priv will be NULL in 2rd open */
1683 //check if the interface is down
1684 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1686 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1690 rts->value = pAdapter->CommonCfg.RtsThreshold;
1691 rts->disabled = (rts->value == MAX_RTS_THRESHOLD);
1697 int rt_ioctl_siwfrag(struct net_device *dev,
1698 struct iw_request_info *info,
1699 struct iw_param *frag, char *extra)
1701 PRTMP_ADAPTER pAdapter = RTMP_OS_NETDEV_GET_PRIV(dev);
1704 //check if the interface is down
1705 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1707 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1712 val = MAX_FRAG_THRESHOLD;
1713 else if (frag->value >= MIN_FRAG_THRESHOLD || frag->value <= MAX_FRAG_THRESHOLD)
1714 val = __cpu_to_le16(frag->value & ~0x1); /* even numbers only */
1715 else if (frag->value == 0)
1716 val = MAX_FRAG_THRESHOLD;
1720 pAdapter->CommonCfg.FragmentThreshold = val;
1724 int rt_ioctl_giwfrag(struct net_device *dev,
1725 struct iw_request_info *info,
1726 struct iw_param *frag, char *extra)
1728 PRTMP_ADAPTER pAdapter = RTMP_OS_NETDEV_GET_PRIV(dev);
1730 if (pAdapter == NULL)
1732 /* if 1st open fail, pAd will be free;
1733 So the net_dev->priv will be NULL in 2rd open */
1737 //check if the interface is down
1738 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1740 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1744 frag->value = pAdapter->CommonCfg.FragmentThreshold;
1745 frag->disabled = (frag->value == MAX_FRAG_THRESHOLD);
1751 #define MAX_WEP_KEY_SIZE 13
1752 #define MIN_WEP_KEY_SIZE 5
1753 int rt_ioctl_siwencode(struct net_device *dev,
1754 struct iw_request_info *info,
1755 struct iw_point *erq, char *extra)
1757 PRTMP_ADAPTER pAdapter = RTMP_OS_NETDEV_GET_PRIV(dev);
1759 //check if the interface is down
1760 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1762 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1766 if ((erq->length == 0) &&
1767 (erq->flags & IW_ENCODE_DISABLED))
1769 pAdapter->StaCfg.PairCipher = Ndis802_11WEPDisabled;
1770 pAdapter->StaCfg.GroupCipher = Ndis802_11WEPDisabled;
1771 pAdapter->StaCfg.WepStatus = Ndis802_11WEPDisabled;
1772 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
1773 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
1776 else if (erq->flags & IW_ENCODE_RESTRICTED || erq->flags & IW_ENCODE_OPEN)
1778 //pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
1779 STA_PORT_SECURED(pAdapter);
1780 pAdapter->StaCfg.PairCipher = Ndis802_11WEPEnabled;
1781 pAdapter->StaCfg.GroupCipher = Ndis802_11WEPEnabled;
1782 pAdapter->StaCfg.WepStatus = Ndis802_11WEPEnabled;
1783 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
1784 if (erq->flags & IW_ENCODE_RESTRICTED)
1785 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeShared;
1787 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
1790 if (erq->length > 0)
1792 int keyIdx = (erq->flags & IW_ENCODE_INDEX) - 1;
1793 /* Check the size of the key */
1794 if (erq->length > MAX_WEP_KEY_SIZE)
1798 /* Check key index */
1799 if ((keyIdx < 0) || (keyIdx >= NR_WEP_KEYS))
1801 DBGPRINT(RT_DEBUG_TRACE ,("==>rt_ioctl_siwencode::Wrong keyIdx=%d! Using default key instead (%d)\n",
1802 keyIdx, pAdapter->StaCfg.DefaultKeyId));
1805 keyIdx = pAdapter->StaCfg.DefaultKeyId;
1808 pAdapter->StaCfg.DefaultKeyId = keyIdx;
1810 NdisZeroMemory(pAdapter->SharedKey[BSS0][keyIdx].Key, 16);
1812 if (erq->length == MAX_WEP_KEY_SIZE)
1814 pAdapter->SharedKey[BSS0][keyIdx].KeyLen = MAX_WEP_KEY_SIZE;
1815 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CIPHER_WEP128;
1817 else if (erq->length == MIN_WEP_KEY_SIZE)
1819 pAdapter->SharedKey[BSS0][keyIdx].KeyLen = MIN_WEP_KEY_SIZE;
1820 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CIPHER_WEP64;
1823 /* Disable the key */
1824 pAdapter->SharedKey[BSS0][keyIdx].KeyLen = 0;
1826 /* Check if the key is not marked as invalid */
1827 if(!(erq->flags & IW_ENCODE_NOKEY))
1829 /* Copy the key in the driver */
1830 NdisMoveMemory(pAdapter->SharedKey[BSS0][keyIdx].Key, extra, erq->length);
1835 /* Do we want to just set the transmit key index ? */
1836 int index = (erq->flags & IW_ENCODE_INDEX) - 1;
1837 if ((index >= 0) && (index < 4))
1839 pAdapter->StaCfg.DefaultKeyId = index;
1842 /* Don't complain if only change the mode */
1843 if(!erq->flags & IW_ENCODE_MODE)
1850 DBGPRINT(RT_DEBUG_TRACE ,("==>rt_ioctl_siwencode::erq->flags=%x\n",erq->flags));
1851 DBGPRINT(RT_DEBUG_TRACE ,("==>rt_ioctl_siwencode::AuthMode=%x\n",pAdapter->StaCfg.AuthMode));
1852 DBGPRINT(RT_DEBUG_TRACE ,("==>rt_ioctl_siwencode::DefaultKeyId=%x, KeyLen = %d\n",pAdapter->StaCfg.DefaultKeyId , pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].KeyLen));
1853 DBGPRINT(RT_DEBUG_TRACE ,("==>rt_ioctl_siwencode::WepStatus=%x\n",pAdapter->StaCfg.WepStatus));
1858 rt_ioctl_giwencode(struct net_device *dev,
1859 struct iw_request_info *info,
1860 struct iw_point *erq, char *key)
1863 PRTMP_ADAPTER pAdapter = RTMP_OS_NETDEV_GET_PRIV(dev);
1865 if (pAdapter == NULL)
1867 /* if 1st open fail, pAd will be free;
1868 So the net_dev->priv will be NULL in 2rd open */
1872 //check if the interface is down
1873 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1875 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1879 kid = erq->flags & IW_ENCODE_INDEX;
1880 DBGPRINT(RT_DEBUG_TRACE, ("===>rt_ioctl_giwencode %d\n", erq->flags & IW_ENCODE_INDEX));
1882 if (pAdapter->StaCfg.WepStatus == Ndis802_11WEPDisabled)
1885 erq->flags = IW_ENCODE_DISABLED;
1887 else if ((kid > 0) && (kid <=4))
1890 erq->flags = kid ; /* NB: base 1 */
1891 if (erq->length > pAdapter->SharedKey[BSS0][kid-1].KeyLen)
1892 erq->length = pAdapter->SharedKey[BSS0][kid-1].KeyLen;
1893 memcpy(key, pAdapter->SharedKey[BSS0][kid-1].Key, erq->length);
1894 //if ((kid == pAdapter->PortCfg.DefaultKeyId))
1895 //erq->flags |= IW_ENCODE_ENABLED; /* XXX */
1896 if (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeShared)
1897 erq->flags |= IW_ENCODE_RESTRICTED; /* XXX */
1899 erq->flags |= IW_ENCODE_OPEN; /* XXX */
1904 if (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeShared)
1905 erq->flags |= IW_ENCODE_RESTRICTED; /* XXX */
1907 erq->flags |= IW_ENCODE_OPEN; /* XXX */
1908 erq->length = pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].KeyLen;
1909 memcpy(key, pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].Key, erq->length);
1910 // copy default key ID
1911 if (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeShared)
1912 erq->flags |= IW_ENCODE_RESTRICTED; /* XXX */
1914 erq->flags |= IW_ENCODE_OPEN; /* XXX */
1915 erq->flags = pAdapter->StaCfg.DefaultKeyId + 1; /* NB: base 1 */
1916 erq->flags |= IW_ENCODE_ENABLED; /* XXX */
1924 rt_ioctl_setparam(struct net_device *dev, struct iw_request_info *info,
1925 void *w, char *extra)
1927 PRTMP_ADAPTER pAdapter;
1929 PSTRING this_char = extra;
1933 pAdapter = RTMP_OS_NETDEV_GET_PRIV(dev);
1934 if (pAdapter == NULL)
1936 /* if 1st open fail, pAd will be free;
1937 So the net_dev->priv will be NULL in 2rd open */
1941 pObj = (POS_COOKIE) pAdapter->OS_Cookie;
1943 pObj->ioctl_if_type = INT_MAIN;
1944 pObj->ioctl_if = MAIN_MBSSID;
1947 //check if the interface is down
1948 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1950 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1957 if ((value = rtstrchr(this_char, '=')) != NULL)
1960 if (!value && (strcmp(this_char, "SiteSurvey") != 0))
1965 // reject setting nothing besides ANY ssid(ssidLen=0)
1966 if (!*value && (strcmp(this_char, "SSID") != 0))
1970 for (PRTMP_PRIVATE_SET_PROC = RTMP_PRIVATE_SUPPORT_PROC; PRTMP_PRIVATE_SET_PROC->name; PRTMP_PRIVATE_SET_PROC++)
1972 if (strcmp(this_char, PRTMP_PRIVATE_SET_PROC->name) == 0)
1974 if(!PRTMP_PRIVATE_SET_PROC->set_proc(pAdapter, value))
1975 { //FALSE:Set private failed then return Invalid argument
1978 break; //Exit for loop.
1982 if(PRTMP_PRIVATE_SET_PROC->name == NULL)
1983 { //Not found argument
1985 DBGPRINT(RT_DEBUG_TRACE, ("===>rt_ioctl_setparam:: (iwpriv) Not Support Set Command [%s=%s]\n", this_char, value));
1993 rt_private_get_statistics(struct net_device *dev, struct iw_request_info *info,
1994 struct iw_point *wrq, char *extra)
1997 PRTMP_ADAPTER pAd = RTMP_OS_NETDEV_GET_PRIV(dev);
2005 memset(extra, 0x00, IW_PRIV_SIZE_MASK);
2006 sprintf(extra, "\n\n");
2011 sprintf(extra+strlen(extra), "Tx success = %ld\n", (ULONG)pAd->ate.TxDoneCount);
2012 //sprintf(extra+strlen(extra), "Tx success without retry = %ld\n", (ULONG)pAd->ate.TxDoneCount);
2015 #endif // RALINK_ATE //
2017 sprintf(extra+strlen(extra), "Tx success = %ld\n", (ULONG)pAd->WlanCounters.TransmittedFragmentCount.QuadPart);
2018 sprintf(extra+strlen(extra), "Tx success without retry = %ld\n", (ULONG)pAd->WlanCounters.TransmittedFragmentCount.QuadPart - (ULONG)pAd->WlanCounters.RetryCount.QuadPart);
2020 sprintf(extra+strlen(extra), "Tx success after retry = %ld\n", (ULONG)pAd->WlanCounters.RetryCount.QuadPart);
2021 sprintf(extra+strlen(extra), "Tx fail to Rcv ACK after retry = %ld\n", (ULONG)pAd->WlanCounters.FailedCount.QuadPart);
2022 sprintf(extra+strlen(extra), "RTS Success Rcv CTS = %ld\n", (ULONG)pAd->WlanCounters.RTSSuccessCount.QuadPart);
2023 sprintf(extra+strlen(extra), "RTS Fail Rcv CTS = %ld\n", (ULONG)pAd->WlanCounters.RTSFailureCount.QuadPart);
2025 sprintf(extra+strlen(extra), "Rx success = %ld\n", (ULONG)pAd->WlanCounters.ReceivedFragmentCount.QuadPart);
2026 sprintf(extra+strlen(extra), "Rx with CRC = %ld\n", (ULONG)pAd->WlanCounters.FCSErrorCount.QuadPart);
2027 sprintf(extra+strlen(extra), "Rx drop due to out of resource = %ld\n", (ULONG)pAd->Counters8023.RxNoBuffer);
2028 sprintf(extra+strlen(extra), "Rx duplicate frame = %ld\n", (ULONG)pAd->WlanCounters.FrameDuplicateCount.QuadPart);
2030 sprintf(extra+strlen(extra), "False CCA (one second) = %ld\n", (ULONG)pAd->RalinkCounters.OneSecFalseCCACnt);
2035 if (pAd->ate.RxAntennaSel == 0)
2037 sprintf(extra+strlen(extra), "RSSI-A = %ld\n", (LONG)(pAd->ate.LastRssi0 - pAd->BbpRssiToDbmDelta));
2038 sprintf(extra+strlen(extra), "RSSI-B (if available) = %ld\n", (LONG)(pAd->ate.LastRssi1 - pAd->BbpRssiToDbmDelta));
2039 sprintf(extra+strlen(extra), "RSSI-C (if available) = %ld\n\n", (LONG)(pAd->ate.LastRssi2 - pAd->BbpRssiToDbmDelta));
2043 sprintf(extra+strlen(extra), "RSSI = %ld\n", (LONG)(pAd->ate.LastRssi0 - pAd->BbpRssiToDbmDelta));
2047 #endif // RALINK_ATE //
2049 sprintf(extra+strlen(extra), "RSSI-A = %ld\n", (LONG)(pAd->StaCfg.RssiSample.LastRssi0 - pAd->BbpRssiToDbmDelta));
2050 sprintf(extra+strlen(extra), "RSSI-B (if available) = %ld\n", (LONG)(pAd->StaCfg.RssiSample.LastRssi1 - pAd->BbpRssiToDbmDelta));
2051 sprintf(extra+strlen(extra), "RSSI-C (if available) = %ld\n\n", (LONG)(pAd->StaCfg.RssiSample.LastRssi2 - pAd->BbpRssiToDbmDelta));
2053 #ifdef WPA_SUPPLICANT_SUPPORT
2054 sprintf(extra+strlen(extra), "WpaSupplicantUP = %d\n\n", pAd->StaCfg.WpaSupplicantUP);
2055 #endif // WPA_SUPPLICANT_SUPPORT //
2059 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2060 DBGPRINT(RT_DEBUG_TRACE, ("<== rt_private_get_statistics, wrq->length = %d\n", wrq->length));
2065 #ifdef DOT11_N_SUPPORT
2067 IN PRTMP_ADAPTER pAd,
2071 BA_ORI_ENTRY *pOriBAEntry;
2072 BA_REC_ENTRY *pRecBAEntry;
2074 for (i=0; i<MAX_LEN_OF_MAC_TABLE; i++)
2076 PMAC_TABLE_ENTRY pEntry = &pAd->MacTab.Content[i];
2077 if (((pEntry->ValidAsCLI || pEntry->ValidAsApCli) && (pEntry->Sst == SST_ASSOC))
2078 || (pEntry->ValidAsWDS) || (pEntry->ValidAsMesh))
2080 sprintf(pOutBuf, "%s\n%02X:%02X:%02X:%02X:%02X:%02X (Aid = %d) (AP) -\n",
2082 pEntry->Addr[0], pEntry->Addr[1], pEntry->Addr[2],
2083 pEntry->Addr[3], pEntry->Addr[4], pEntry->Addr[5], pEntry->Aid);
2085 sprintf(pOutBuf, "%s[Recipient]\n", pOutBuf);
2086 for (j=0; j < NUM_OF_TID; j++)
2088 if (pEntry->BARecWcidArray[j] != 0)
2090 pRecBAEntry =&pAd->BATable.BARecEntry[pEntry->BARecWcidArray[j]];
2091 sprintf(pOutBuf, "%sTID=%d, BAWinSize=%d, LastIndSeq=%d, ReorderingPkts=%d\n", pOutBuf, j, pRecBAEntry->BAWinSize, pRecBAEntry->LastIndSeq, pRecBAEntry->list.qlen);
2094 sprintf(pOutBuf, "%s\n", pOutBuf);
2096 sprintf(pOutBuf, "%s[Originator]\n", pOutBuf);
2097 for (j=0; j < NUM_OF_TID; j++)
2099 if (pEntry->BAOriWcidArray[j] != 0)
2101 pOriBAEntry =&pAd->BATable.BAOriEntry[pEntry->BAOriWcidArray[j]];
2102 sprintf(pOutBuf, "%sTID=%d, BAWinSize=%d, StartSeq=%d, CurTxSeq=%d\n", pOutBuf, j, pOriBAEntry->BAWinSize, pOriBAEntry->Sequence, pEntry->TxSeq[j]);
2105 sprintf(pOutBuf, "%s\n\n", pOutBuf);
2107 if (strlen(pOutBuf) > (IW_PRIV_SIZE_MASK - 30))
2113 #endif // DOT11_N_SUPPORT //
2116 rt_private_show(struct net_device *dev, struct iw_request_info *info,
2117 struct iw_point *wrq, PSTRING extra)
2122 u32 subcmd = wrq->flags;
2124 pAd = RTMP_OS_NETDEV_GET_PRIV(dev);
2127 /* if 1st open fail, pAd will be free;
2128 So the net_dev->priv will be NULL in 2rd open */
2132 pObj = (POS_COOKIE) pAd->OS_Cookie;
2138 memset(extra, 0x00, IW_PRIV_SIZE_MASK);
2141 pObj->ioctl_if_type = INT_MAIN;
2142 pObj->ioctl_if = MAIN_MBSSID;
2148 case SHOW_CONN_STATUS:
2149 if (MONITOR_ON(pAd))
2151 #ifdef DOT11_N_SUPPORT
2152 if (pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED &&
2153 pAd->CommonCfg.RegTransmitSetting.field.BW)
2154 sprintf(extra, "Monitor Mode(CentralChannel %d)\n", pAd->CommonCfg.CentralChannel);
2156 #endif // DOT11_N_SUPPORT //
2157 sprintf(extra, "Monitor Mode(Channel %d)\n", pAd->CommonCfg.Channel);
2161 if (pAd->IndicateMediaState == NdisMediaStateConnected)
2165 sprintf(extra, "Connected(AP: %s[%02X:%02X:%02X:%02X:%02X:%02X])\n",
2166 pAd->CommonCfg.Ssid,
2167 pAd->CommonCfg.Bssid[0],
2168 pAd->CommonCfg.Bssid[1],
2169 pAd->CommonCfg.Bssid[2],
2170 pAd->CommonCfg.Bssid[3],
2171 pAd->CommonCfg.Bssid[4],
2172 pAd->CommonCfg.Bssid[5]);
2173 DBGPRINT(RT_DEBUG_TRACE ,("Ssid=%s ,Ssidlen = %d\n",pAd->CommonCfg.Ssid, pAd->CommonCfg.SsidLen));
2175 else if (ADHOC_ON(pAd))
2176 sprintf(extra, "Connected\n");
2180 sprintf(extra, "Disconnected\n");
2181 DBGPRINT(RT_DEBUG_TRACE ,("ConnStatus is not connected\n"));
2184 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2186 case SHOW_DRVIER_VERION:
2187 sprintf(extra, "Driver version-%s, %s %s\n", STA_DRIVER_VERSION, __DATE__, __TIME__ );
2188 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2190 #ifdef DOT11_N_SUPPORT
2192 getBaInfo(pAd, extra);
2193 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2195 #endif // DOT11_N_SUPPORT //
2196 case SHOW_DESC_INFO:
2198 Show_DescInfo_Proc(pAd, NULL);
2199 wrq->length = 0; // 1: size of '\0'
2203 if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
2205 if (pAd->Mlme.CntlMachine.CurrState != CNTL_IDLE)
2207 RTMP_MLME_RESET_STATE_MACHINE(pAd);
2208 DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
2211 pAd->StaCfg.bSwRadio = FALSE;
2212 if (pAd->StaCfg.bRadio != (pAd->StaCfg.bHwRadio && pAd->StaCfg.bSwRadio))
2214 pAd->StaCfg.bRadio = (pAd->StaCfg.bHwRadio && pAd->StaCfg.bSwRadio);
2215 if (pAd->StaCfg.bRadio == FALSE)
2218 // Update extra information
2219 pAd->ExtraInfo = SW_RADIO_OFF;
2222 sprintf(extra, "Radio Off\n");
2223 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2226 pAd->StaCfg.bSwRadio = TRUE;
2227 //if (pAd->StaCfg.bRadio != (pAd->StaCfg.bHwRadio && pAd->StaCfg.bSwRadio))
2229 pAd->StaCfg.bRadio = (pAd->StaCfg.bHwRadio && pAd->StaCfg.bSwRadio);
2230 if (pAd->StaCfg.bRadio == TRUE)
2233 // Update extra information
2234 pAd->ExtraInfo = EXTRA_INFO_CLEAR;
2237 sprintf(extra, "Radio On\n");
2238 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2242 #ifdef QOS_DLS_SUPPORT
2243 case SHOW_DLS_ENTRY_INFO:
2245 Set_DlsEntryInfo_Display_Proc(pAd, NULL);
2246 wrq->length = 0; // 1: size of '\0'
2249 #endif // QOS_DLS_SUPPORT //
2251 case SHOW_CFG_VALUE:
2253 Status = RTMPShowCfgValue(pAd, (PSTRING) wrq->pointer, extra);
2255 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2258 case SHOW_ADHOC_ENTRY_INFO:
2259 Show_Adhoc_MacTable_Proc(pAd, extra);
2260 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2263 DBGPRINT(RT_DEBUG_TRACE, ("%s - unknow subcmd = %d\n", __FUNCTION__, subcmd));
2271 int rt_ioctl_siwmlme(struct net_device *dev,
2272 struct iw_request_info *info,
2273 union iwreq_data *wrqu,
2276 PRTMP_ADAPTER pAd = RTMP_OS_NETDEV_GET_PRIV(dev);
2277 struct iw_mlme *pMlme = (struct iw_mlme *)wrqu->data.pointer;
2278 MLME_QUEUE_ELEM MsgElem;
2279 MLME_DISASSOC_REQ_STRUCT DisAssocReq;
2280 MLME_DEAUTH_REQ_STRUCT DeAuthReq;
2282 DBGPRINT(RT_DEBUG_TRACE, ("====> %s\n", __FUNCTION__));
2289 #ifdef IW_MLME_DEAUTH
2290 case IW_MLME_DEAUTH:
2291 DBGPRINT(RT_DEBUG_TRACE, ("====> %s - IW_MLME_DEAUTH\n", __FUNCTION__));
2292 COPY_MAC_ADDR(DeAuthReq.Addr, pAd->CommonCfg.Bssid);
2293 DeAuthReq.Reason = pMlme->reason_code;
2294 MsgElem.MsgLen = sizeof(MLME_DEAUTH_REQ_STRUCT);
2295 NdisMoveMemory(MsgElem.Msg, &DeAuthReq, sizeof(MLME_DEAUTH_REQ_STRUCT));
2296 MlmeDeauthReqAction(pAd, &MsgElem);
2299 LinkDown(pAd, FALSE);
2300 pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
2303 #endif // IW_MLME_DEAUTH //
2304 #ifdef IW_MLME_DISASSOC
2305 case IW_MLME_DISASSOC:
2306 DBGPRINT(RT_DEBUG_TRACE, ("====> %s - IW_MLME_DISASSOC\n", __FUNCTION__));
2307 COPY_MAC_ADDR(DisAssocReq.Addr, pAd->CommonCfg.Bssid);
2308 DisAssocReq.Reason = pMlme->reason_code;
2310 MsgElem.Machine = ASSOC_STATE_MACHINE;
2311 MsgElem.MsgType = MT2_MLME_DISASSOC_REQ;
2312 MsgElem.MsgLen = sizeof(MLME_DISASSOC_REQ_STRUCT);
2313 NdisMoveMemory(MsgElem.Msg, &DisAssocReq, sizeof(MLME_DISASSOC_REQ_STRUCT));
2315 pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_OID_DISASSOC;
2316 MlmeDisassocReqAction(pAd, &MsgElem);
2318 #endif // IW_MLME_DISASSOC //
2320 DBGPRINT(RT_DEBUG_TRACE, ("====> %s - Unknow Command\n", __FUNCTION__));
2326 #endif // SIOCSIWMLME //
2328 #if WIRELESS_EXT > 17
2329 int rt_ioctl_siwauth(struct net_device *dev,
2330 struct iw_request_info *info,
2331 union iwreq_data *wrqu, char *extra)
2333 PRTMP_ADAPTER pAdapter = RTMP_OS_NETDEV_GET_PRIV(dev);
2334 struct iw_param *param = &wrqu->param;
2336 //check if the interface is down
2337 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
2339 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
2342 switch (param->flags & IW_AUTH_INDEX) {
2343 case IW_AUTH_WPA_VERSION:
2344 if (param->value == IW_AUTH_WPA_VERSION_WPA)
2346 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPAPSK;
2347 if (pAdapter->StaCfg.BssType == BSS_ADHOC)
2348 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPANone;
2350 else if (param->value == IW_AUTH_WPA_VERSION_WPA2)
2351 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA2PSK;
2353 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_WPA_VERSION - param->value = %d!\n", __FUNCTION__, param->value));
2355 case IW_AUTH_CIPHER_PAIRWISE:
2356 if (param->value == IW_AUTH_CIPHER_NONE)
2358 pAdapter->StaCfg.WepStatus = Ndis802_11WEPDisabled;
2359 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
2360 pAdapter->StaCfg.PairCipher = Ndis802_11WEPDisabled;
2362 else if (param->value == IW_AUTH_CIPHER_WEP40 ||
2363 param->value == IW_AUTH_CIPHER_WEP104)
2365 pAdapter->StaCfg.WepStatus = Ndis802_11WEPEnabled;
2366 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
2367 pAdapter->StaCfg.PairCipher = Ndis802_11WEPEnabled;
2368 #ifdef WPA_SUPPLICANT_SUPPORT
2369 pAdapter->StaCfg.IEEE8021X = FALSE;
2370 #endif // WPA_SUPPLICANT_SUPPORT //
2372 else if (param->value == IW_AUTH_CIPHER_TKIP)
2374 pAdapter->StaCfg.WepStatus = Ndis802_11Encryption2Enabled;
2375 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
2376 pAdapter->StaCfg.PairCipher = Ndis802_11Encryption2Enabled;
2378 else if (param->value == IW_AUTH_CIPHER_CCMP)
2380 pAdapter->StaCfg.WepStatus = Ndis802_11Encryption3Enabled;
2381 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
2382 pAdapter->StaCfg.PairCipher = Ndis802_11Encryption3Enabled;
2384 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_CIPHER_PAIRWISE - param->value = %d!\n", __FUNCTION__, param->value));
2386 case IW_AUTH_CIPHER_GROUP:
2387 if (param->value == IW_AUTH_CIPHER_NONE)
2389 pAdapter->StaCfg.GroupCipher = Ndis802_11WEPDisabled;
2391 else if (param->value == IW_AUTH_CIPHER_WEP40 ||
2392 param->value == IW_AUTH_CIPHER_WEP104)
2394 pAdapter->StaCfg.GroupCipher = Ndis802_11WEPEnabled;
2396 else if (param->value == IW_AUTH_CIPHER_TKIP)
2398 pAdapter->StaCfg.GroupCipher = Ndis802_11Encryption2Enabled;
2400 else if (param->value == IW_AUTH_CIPHER_CCMP)
2402 pAdapter->StaCfg.GroupCipher = Ndis802_11Encryption3Enabled;
2404 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_CIPHER_GROUP - param->value = %d!\n", __FUNCTION__, param->value));
2406 case IW_AUTH_KEY_MGMT:
2407 if (param->value == IW_AUTH_KEY_MGMT_802_1X)
2409 if (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK)
2411 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA;
2412 #ifdef WPA_SUPPLICANT_SUPPORT
2413 pAdapter->StaCfg.IEEE8021X = FALSE;
2414 #endif // WPA_SUPPLICANT_SUPPORT //
2416 else if (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK)
2418 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA2;
2419 #ifdef WPA_SUPPLICANT_SUPPORT
2420 pAdapter->StaCfg.IEEE8021X = FALSE;
2421 #endif // WPA_SUPPLICANT_SUPPORT //
2423 #ifdef WPA_SUPPLICANT_SUPPORT
2426 pAdapter->StaCfg.IEEE8021X = TRUE;
2427 #endif // WPA_SUPPLICANT_SUPPORT //
2429 else if (param->value == 0)
2431 //pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
2432 STA_PORT_SECURED(pAdapter);
2434 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_KEY_MGMT - param->value = %d!\n", __FUNCTION__, param->value));
2436 case IW_AUTH_RX_UNENCRYPTED_EAPOL:
2438 case IW_AUTH_PRIVACY_INVOKED:
2439 /*if (param->value == 0)
2441 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
2442 pAdapter->StaCfg.WepStatus = Ndis802_11WEPDisabled;
2443 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
2444 pAdapter->StaCfg.PairCipher = Ndis802_11WEPDisabled;
2445 pAdapter->StaCfg.GroupCipher = Ndis802_11WEPDisabled;
2447 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_PRIVACY_INVOKED - param->value = %d!\n", __FUNCTION__, param->value));
2449 case IW_AUTH_DROP_UNENCRYPTED:
2450 if (param->value != 0)
2451 pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED;
2454 //pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
2455 STA_PORT_SECURED(pAdapter);
2457 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_WPA_VERSION - param->value = %d!\n", __FUNCTION__, param->value));
2459 case IW_AUTH_80211_AUTH_ALG:
2460 if (param->value & IW_AUTH_ALG_SHARED_KEY)
2462 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeShared;
2464 else if (param->value & IW_AUTH_ALG_OPEN_SYSTEM)
2466 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
2470 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_80211_AUTH_ALG - param->value = %d!\n", __FUNCTION__, param->value));
2472 case IW_AUTH_WPA_ENABLED:
2473 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_WPA_ENABLED - Driver supports WPA!(param->value = %d)\n", __FUNCTION__, param->value));
2482 int rt_ioctl_giwauth(struct net_device *dev,
2483 struct iw_request_info *info,
2484 union iwreq_data *wrqu, char *extra)
2486 PRTMP_ADAPTER pAdapter = RTMP_OS_NETDEV_GET_PRIV(dev);
2487 struct iw_param *param = &wrqu->param;
2489 //check if the interface is down
2490 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
2492 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
2496 switch (param->flags & IW_AUTH_INDEX) {
2497 case IW_AUTH_DROP_UNENCRYPTED:
2498 param->value = (pAdapter->StaCfg.WepStatus == Ndis802_11WEPDisabled) ? 0 : 1;
2501 case IW_AUTH_80211_AUTH_ALG:
2502 param->value = (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeShared) ? IW_AUTH_ALG_SHARED_KEY : IW_AUTH_ALG_OPEN_SYSTEM;
2505 case IW_AUTH_WPA_ENABLED:
2506 param->value = (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA) ? 1 : 0;
2512 DBGPRINT(RT_DEBUG_TRACE, ("rt_ioctl_giwauth::param->value = %d!\n", param->value));
2516 void fnSetCipherKey(
2517 IN PRTMP_ADAPTER pAdapter,
2521 IN struct iw_encode_ext *ext)
2523 NdisZeroMemory(&pAdapter->SharedKey[BSS0][keyIdx], sizeof(CIPHER_KEY));
2524 pAdapter->SharedKey[BSS0][keyIdx].KeyLen = LEN_TKIP_EK;
2525 NdisMoveMemory(pAdapter->SharedKey[BSS0][keyIdx].Key, ext->key, LEN_TKIP_EK);
2526 NdisMoveMemory(pAdapter->SharedKey[BSS0][keyIdx].TxMic, ext->key + LEN_TKIP_EK, LEN_TKIP_TXMICK);
2527 NdisMoveMemory(pAdapter->SharedKey[BSS0][keyIdx].RxMic, ext->key + LEN_TKIP_EK + LEN_TKIP_TXMICK, LEN_TKIP_RXMICK);
2528 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CipherAlg;
2530 // Update group key information to ASIC Shared Key Table
2531 AsicAddSharedKeyEntry(pAdapter,
2534 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg,
2535 pAdapter->SharedKey[BSS0][keyIdx].Key,
2536 pAdapter->SharedKey[BSS0][keyIdx].TxMic,
2537 pAdapter->SharedKey[BSS0][keyIdx].RxMic);
2540 // Update ASIC WCID attribute table and IVEIV table
2541 RTMPAddWcidAttributeEntry(pAdapter,
2544 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg,
2547 // Update ASIC WCID attribute table and IVEIV table
2548 RTMPAddWcidAttributeEntry(pAdapter,
2551 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg,
2552 &pAdapter->MacTab.Content[BSSID_WCID]);
2555 int rt_ioctl_siwencodeext(struct net_device *dev,
2556 struct iw_request_info *info,
2557 union iwreq_data *wrqu,
2560 PRTMP_ADAPTER pAdapter = RTMP_OS_NETDEV_GET_PRIV(dev);
2561 struct iw_point *encoding = &wrqu->encoding;
2562 struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
2563 int keyIdx, alg = ext->alg;
2565 //check if the interface is down
2566 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
2568 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
2572 if (encoding->flags & IW_ENCODE_DISABLED)
2574 keyIdx = (encoding->flags & IW_ENCODE_INDEX) - 1;
2575 // set BSSID wcid entry of the Pair-wise Key table as no-security mode
2576 AsicRemovePairwiseKeyEntry(pAdapter, BSS0, BSSID_WCID);
2577 pAdapter->SharedKey[BSS0][keyIdx].KeyLen = 0;
2578 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CIPHER_NONE;
2579 AsicRemoveSharedKeyEntry(pAdapter, 0, (UCHAR)keyIdx);
2580 NdisZeroMemory(&pAdapter->SharedKey[BSS0][keyIdx], sizeof(CIPHER_KEY));
2581 DBGPRINT(RT_DEBUG_TRACE, ("%s::Remove all keys!(encoding->flags = %x)\n", __FUNCTION__, encoding->flags));
2585 // Get Key Index and convet to our own defined key index
2586 keyIdx = (encoding->flags & IW_ENCODE_INDEX) - 1;
2587 if((keyIdx < 0) || (keyIdx >= NR_WEP_KEYS))
2590 if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
2592 pAdapter->StaCfg.DefaultKeyId = keyIdx;
2593 DBGPRINT(RT_DEBUG_TRACE, ("%s::DefaultKeyId = %d\n", __FUNCTION__, pAdapter->StaCfg.DefaultKeyId));
2597 case IW_ENCODE_ALG_NONE:
2598 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_ENCODE_ALG_NONE\n", __FUNCTION__));
2600 case IW_ENCODE_ALG_WEP:
2601 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_ENCODE_ALG_WEP - ext->key_len = %d, keyIdx = %d\n", __FUNCTION__, ext->key_len, keyIdx));
2602 if (ext->key_len == MAX_WEP_KEY_SIZE)
2604 pAdapter->SharedKey[BSS0][keyIdx].KeyLen = MAX_WEP_KEY_SIZE;
2605 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CIPHER_WEP128;
2607 else if (ext->key_len == MIN_WEP_KEY_SIZE)
2609 pAdapter->SharedKey[BSS0][keyIdx].KeyLen = MIN_WEP_KEY_SIZE;
2610 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CIPHER_WEP64;
2615 NdisZeroMemory(pAdapter->SharedKey[BSS0][keyIdx].Key, 16);
2616 NdisMoveMemory(pAdapter->SharedKey[BSS0][keyIdx].Key, ext->key, ext->key_len);
2618 if (pAdapter->StaCfg.GroupCipher == Ndis802_11GroupWEP40Enabled ||
2619 pAdapter->StaCfg.GroupCipher == Ndis802_11GroupWEP104Enabled)
2621 // Set Group key material to Asic
2622 AsicAddSharedKeyEntry(pAdapter, BSS0, keyIdx, pAdapter->SharedKey[BSS0][keyIdx].CipherAlg, pAdapter->SharedKey[BSS0][keyIdx].Key, NULL, NULL);
2623 // Update WCID attribute table and IVEIV table for this group key table
2624 RTMPAddWcidAttributeEntry(pAdapter, BSS0, keyIdx, pAdapter->SharedKey[BSS0][keyIdx].CipherAlg, NULL);
2625 STA_PORT_SECURED(pAdapter);
2626 // Indicate Connected for GUI
2627 pAdapter->IndicateMediaState = NdisMediaStateConnected;
2630 case IW_ENCODE_ALG_TKIP:
2631 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_ENCODE_ALG_TKIP - keyIdx = %d, ext->key_len = %d\n", __FUNCTION__, keyIdx, ext->key_len));
2632 if (ext->key_len == 32)
2634 if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
2636 fnSetCipherKey(pAdapter, keyIdx, CIPHER_TKIP, FALSE, ext);
2637 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA2)
2639 //pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
2640 STA_PORT_SECURED(pAdapter);
2641 pAdapter->IndicateMediaState = NdisMediaStateConnected;
2644 else if (ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY)
2646 fnSetCipherKey(pAdapter, keyIdx, CIPHER_TKIP, TRUE, ext);
2648 // set 802.1x port control
2649 //pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
2650 STA_PORT_SECURED(pAdapter);
2651 pAdapter->IndicateMediaState = NdisMediaStateConnected;
2657 case IW_ENCODE_ALG_CCMP:
2658 if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
2660 fnSetCipherKey(pAdapter, keyIdx, CIPHER_AES, FALSE, ext);
2661 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA2)
2662 //pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
2663 STA_PORT_SECURED(pAdapter);
2664 pAdapter->IndicateMediaState = NdisMediaStateConnected;
2666 else if (ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY)
2668 fnSetCipherKey(pAdapter, keyIdx, CIPHER_AES, TRUE, ext);
2670 // set 802.1x port control
2671 //pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
2672 STA_PORT_SECURED(pAdapter);
2673 pAdapter->IndicateMediaState = NdisMediaStateConnected;
2685 rt_ioctl_giwencodeext(struct net_device *dev,
2686 struct iw_request_info *info,
2687 union iwreq_data *wrqu, char *extra)
2689 PRTMP_ADAPTER pAd = RTMP_OS_NETDEV_GET_PRIV(dev);
2691 struct iw_point *encoding = &wrqu->encoding;
2692 struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
2693 int idx, max_key_len;
2695 DBGPRINT(RT_DEBUG_TRACE ,("===> rt_ioctl_giwencodeext\n"));
2697 max_key_len = encoding->length - sizeof(*ext);
2698 if (max_key_len < 0)
2701 idx = encoding->flags & IW_ENCODE_INDEX;
2704 if (idx < 1 || idx > 4)
2708 if ((pAd->StaCfg.WepStatus == Ndis802_11Encryption2Enabled) ||
2709 (pAd->StaCfg.WepStatus == Ndis802_11Encryption3Enabled))
2711 if (idx != pAd->StaCfg.DefaultKeyId)
2719 idx = pAd->StaCfg.DefaultKeyId;
2721 encoding->flags = idx + 1;
2722 memset(ext, 0, sizeof(*ext));
2725 switch(pAd->StaCfg.WepStatus) {
2726 case Ndis802_11WEPDisabled:
2727 ext->alg = IW_ENCODE_ALG_NONE;
2728 encoding->flags |= IW_ENCODE_DISABLED;
2730 case Ndis802_11WEPEnabled:
2731 ext->alg = IW_ENCODE_ALG_WEP;
2732 if (pAd->SharedKey[BSS0][idx].KeyLen > max_key_len)
2736 ext->key_len = pAd->SharedKey[BSS0][idx].KeyLen;
2737 pKey = (PCHAR)&(pAd->SharedKey[BSS0][idx].Key[0]);
2740 case Ndis802_11Encryption2Enabled:
2741 case Ndis802_11Encryption3Enabled:
2742 if (pAd->StaCfg.WepStatus == Ndis802_11Encryption2Enabled)
2743 ext->alg = IW_ENCODE_ALG_TKIP;
2745 ext->alg = IW_ENCODE_ALG_CCMP;
2747 if (max_key_len < 32)
2752 pKey = (PCHAR)&pAd->StaCfg.PMK[0];
2759 if (ext->key_len && pKey)
2761 encoding->flags |= IW_ENCODE_ENABLED;
2762 memcpy(ext->key, pKey, ext->key_len);
2769 int rt_ioctl_siwgenie(struct net_device *dev,
2770 struct iw_request_info *info,
2771 union iwreq_data *wrqu, char *extra)
2773 PRTMP_ADAPTER pAd = RTMP_OS_NETDEV_GET_PRIV(dev);
2775 DBGPRINT(RT_DEBUG_TRACE ,("===> rt_ioctl_siwgenie\n"));
2776 #ifdef NATIVE_WPA_SUPPLICANT_SUPPORT
2777 pAd->StaCfg.bRSN_IE_FromWpaSupplicant = FALSE;
2778 #endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
2779 if (wrqu->data.length > MAX_LEN_OF_RSNIE ||
2780 (wrqu->data.length && extra == NULL))
2783 if (wrqu->data.length)
2785 pAd->StaCfg.RSNIE_Len = wrqu->data.length;
2786 NdisMoveMemory(&pAd->StaCfg.RSN_IE[0], extra, pAd->StaCfg.RSNIE_Len);
2787 #ifdef NATIVE_WPA_SUPPLICANT_SUPPORT
2788 pAd->StaCfg.bRSN_IE_FromWpaSupplicant = TRUE;
2789 #endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
2793 pAd->StaCfg.RSNIE_Len = 0;
2794 NdisZeroMemory(&pAd->StaCfg.RSN_IE[0], MAX_LEN_OF_RSNIE);
2799 #endif // SIOCSIWGENIE //
2801 int rt_ioctl_giwgenie(struct net_device *dev,
2802 struct iw_request_info *info,
2803 union iwreq_data *wrqu, char *extra)
2805 PRTMP_ADAPTER pAd = RTMP_OS_NETDEV_GET_PRIV(dev);
2807 if ((pAd->StaCfg.RSNIE_Len == 0) ||
2808 (pAd->StaCfg.AuthMode < Ndis802_11AuthModeWPA))
2810 wrqu->data.length = 0;
2814 #ifdef NATIVE_WPA_SUPPLICANT_SUPPORT
2816 if (pAd->StaCfg.WpaSupplicantUP == WPA_SUPPLICANT_ENABLE)
2818 if (wrqu->data.length < pAd->StaCfg.RSNIE_Len)
2821 wrqu->data.length = pAd->StaCfg.RSNIE_Len;
2822 memcpy(extra, &pAd->StaCfg.RSN_IE[0], pAd->StaCfg.RSNIE_Len);
2825 #endif // SIOCSIWGENIE //
2826 #endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
2828 UCHAR RSNIe = IE_WPA;
2830 if (wrqu->data.length < (pAd->StaCfg.RSNIE_Len + 2)) // ID, Len
2832 wrqu->data.length = pAd->StaCfg.RSNIE_Len + 2;
2834 if ((pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK) ||
2835 (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2))
2838 extra[0] = (char)RSNIe;
2839 extra[1] = pAd->StaCfg.RSNIE_Len;
2840 memcpy(extra+2, &pAd->StaCfg.RSN_IE[0], pAd->StaCfg.RSNIE_Len);
2846 int rt_ioctl_siwpmksa(struct net_device *dev,
2847 struct iw_request_info *info,
2848 union iwreq_data *wrqu,
2851 PRTMP_ADAPTER pAd = RTMP_OS_NETDEV_GET_PRIV(dev);
2852 struct iw_pmksa *pPmksa = (struct iw_pmksa *)wrqu->data.pointer;
2853 INT CachedIdx = 0, idx = 0;
2858 DBGPRINT(RT_DEBUG_TRACE ,("===> rt_ioctl_siwpmksa\n"));
2861 case IW_PMKSA_FLUSH:
2862 NdisZeroMemory(pAd->StaCfg.SavedPMK, sizeof(BSSID_INFO)*PMKID_NO);
2863 DBGPRINT(RT_DEBUG_TRACE ,("rt_ioctl_siwpmksa - IW_PMKSA_FLUSH\n"));
2865 case IW_PMKSA_REMOVE:
2866 for (CachedIdx = 0; CachedIdx < pAd->StaCfg.SavedPMKNum; CachedIdx++)
2868 // compare the BSSID
2869 if (NdisEqualMemory(pPmksa->bssid.sa_data, pAd->StaCfg.SavedPMK[CachedIdx].BSSID, MAC_ADDR_LEN))
2871 NdisZeroMemory(pAd->StaCfg.SavedPMK[CachedIdx].BSSID, MAC_ADDR_LEN);
2872 NdisZeroMemory(pAd->StaCfg.SavedPMK[CachedIdx].PMKID, 16);
2873 for (idx = CachedIdx; idx < (pAd->StaCfg.SavedPMKNum - 1); idx++)
2875 NdisMoveMemory(&pAd->StaCfg.SavedPMK[idx].BSSID[0], &pAd->StaCfg.SavedPMK[idx+1].BSSID[0], MAC_ADDR_LEN);
2876 NdisMoveMemory(&pAd->StaCfg.SavedPMK[idx].PMKID[0], &pAd->StaCfg.SavedPMK[idx+1].PMKID[0], 16);
2878 pAd->StaCfg.SavedPMKNum--;
2883 DBGPRINT(RT_DEBUG_TRACE ,("rt_ioctl_siwpmksa - IW_PMKSA_REMOVE\n"));
2886 for (CachedIdx = 0; CachedIdx < pAd->StaCfg.SavedPMKNum; CachedIdx++)
2888 // compare the BSSID
2889 if (NdisEqualMemory(pPmksa->bssid.sa_data, pAd->StaCfg.SavedPMK[CachedIdx].BSSID, MAC_ADDR_LEN))
2893 // Found, replace it
2894 if (CachedIdx < PMKID_NO)
2896 DBGPRINT(RT_DEBUG_OFF, ("Update PMKID, idx = %d\n", CachedIdx));
2897 NdisMoveMemory(&pAd->StaCfg.SavedPMK[CachedIdx].BSSID[0], pPmksa->bssid.sa_data, MAC_ADDR_LEN);
2898 NdisMoveMemory(&pAd->StaCfg.SavedPMK[CachedIdx].PMKID[0], pPmksa->pmkid, 16);
2899 pAd->StaCfg.SavedPMKNum++;
2901 // Not found, replace the last one
2904 // Randomly replace one
2905 CachedIdx = (pPmksa->bssid.sa_data[5] % PMKID_NO);
2906 DBGPRINT(RT_DEBUG_OFF, ("Update PMKID, idx = %d\n", CachedIdx));
2907 NdisMoveMemory(&pAd->StaCfg.SavedPMK[CachedIdx].BSSID[0], pPmksa->bssid.sa_data, MAC_ADDR_LEN);
2908 NdisMoveMemory(&pAd->StaCfg.SavedPMK[CachedIdx].PMKID[0], pPmksa->pmkid, 16);
2911 DBGPRINT(RT_DEBUG_TRACE ,("rt_ioctl_siwpmksa - IW_PMKSA_ADD\n"));
2914 DBGPRINT(RT_DEBUG_TRACE ,("rt_ioctl_siwpmksa - Unknow Command!!\n"));
2920 #endif // #if WIRELESS_EXT > 17
2924 rt_private_ioctl_bbp(struct net_device *dev, struct iw_request_info *info,
2925 struct iw_point *wrq, char *extra)
2928 PSTRING value = NULL;
2930 // CHAR arg[255]={0};
2933 BOOLEAN bIsPrintAllBBP = FALSE;
2935 PRTMP_ADAPTER pAdapter = RTMP_OS_NETDEV_GET_PRIV(dev);
2938 memset(extra, 0x00, IW_PRIV_SIZE_MASK);
2940 if (wrq->length > 1) //No parameters.
2942 sprintf(extra, "\n");
2944 //Parsing Read or Write
2945 this_char = wrq->pointer;
2946 DBGPRINT(RT_DEBUG_TRACE, ("this_char=%s\n", this_char));
2950 if ((value = rtstrchr(this_char, '=')) != NULL)
2953 if (!value || !*value)
2955 DBGPRINT(RT_DEBUG_TRACE, ("this_char=%s, value=%s\n", this_char, value));
2956 if (sscanf(this_char, "%d", &(bbpId)) == 1)
2958 if (bbpId <= MAX_BBP_ID)
2961 if (ATE_ON(pAdapter))
2963 ATE_BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, ®BBP);
2966 #endif // RALINK_ATE //
2968 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, ®BBP);
2970 sprintf(extra+strlen(extra), "R%02d[0x%02X]:%02X\n", bbpId, bbpId, regBBP);
2971 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2972 DBGPRINT(RT_DEBUG_TRACE, ("msg=%s\n", extra));
2975 {//Invalid parametes, so default printk all bbp
2976 bIsPrintAllBBP = TRUE;
2981 { //Invalid parametes, so default printk all bbp
2982 bIsPrintAllBBP = TRUE;
2988 if ((sscanf(this_char, "%d", &(bbpId)) == 1) && (sscanf(value, "%x", &(bbpValue)) == 1))
2990 if (bbpId <= MAX_BBP_ID)
2993 if (ATE_ON(pAdapter))
2995 ATE_BBP_IO_WRITE8_BY_REG_ID(pAdapter, bbpId, bbpValue);
2996 /* read it back for showing */
2997 ATE_BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, ®BBP);
3000 #endif // RALINK_ATE //
3002 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, bbpId, bbpValue);
3003 /* read it back for showing */
3004 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, ®BBP);
3006 sprintf(extra+strlen(extra), "R%02d[0x%02X]:%02X\n", bbpId, bbpId, regBBP);
3007 wrq->length = strlen(extra) + 1; // 1: size of '\0'
3008 DBGPRINT(RT_DEBUG_TRACE, ("msg=%s\n", extra));
3011 {//Invalid parametes, so default printk all bbp
3012 bIsPrintAllBBP = TRUE;
3017 { //Invalid parametes, so default printk all bbp
3018 bIsPrintAllBBP = TRUE;
3024 bIsPrintAllBBP = TRUE;
3029 memset(extra, 0x00, IW_PRIV_SIZE_MASK);
3030 sprintf(extra, "\n");
3031 for (bbpId = 0; bbpId <= MAX_BBP_ID; bbpId++)
3033 if (strlen(extra) >= (IW_PRIV_SIZE_MASK - 20))
3036 if (ATE_ON(pAdapter))
3038 ATE_BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, ®BBP);
3041 #endif // RALINK_ATE //
3042 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, ®BBP);
3043 sprintf(extra+strlen(extra), "R%02d[0x%02X]:%02X ", bbpId, bbpId, regBBP);
3045 sprintf(extra+strlen(extra), "%03d = %02X\n", bbpId, regBBP); // edit by johnli, change display format
3048 wrq->length = strlen(extra) + 1; // 1: size of '\0'
3049 DBGPRINT(RT_DEBUG_TRACE, ("wrq->length = %d\n", wrq->length));
3052 DBGPRINT(RT_DEBUG_TRACE, ("<==rt_private_ioctl_bbp\n\n"));
3058 int rt_ioctl_siwrate(struct net_device *dev,
3059 struct iw_request_info *info,
3060 union iwreq_data *wrqu, char *extra)
3062 PRTMP_ADAPTER pAd = RTMP_OS_NETDEV_GET_PRIV(dev);
3063 UINT32 rate = wrqu->bitrate.value, fixed = wrqu->bitrate.fixed;
3065 //check if the interface is down
3066 if(!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_IN_USE))
3068 DBGPRINT(RT_DEBUG_TRACE, ("rt_ioctl_siwrate::Network is down!\n"));
3072 DBGPRINT(RT_DEBUG_TRACE, ("rt_ioctl_siwrate::(rate = %d, fixed = %d)\n", rate, fixed));
3073 /* rate = -1 => auto rate
3074 rate = X, fixed = 1 => (fixed rate X)
3079 pAd->StaCfg.DesiredTransmitSetting.field.MCS = MCS_AUTO;
3080 pAd->StaCfg.bAutoTxRateSwitch = TRUE;
3081 if ((pAd->CommonCfg.PhyMode <= PHY_11G) ||
3082 (pAd->MacTab.Content[BSSID_WCID].HTPhyMode.field.MODE <= MODE_OFDM))
3083 RTMPSetDesiredRates(pAd, -1);
3085 #ifdef DOT11_N_SUPPORT
3087 #endif // DOT11_N_SUPPORT //
3093 pAd->StaCfg.bAutoTxRateSwitch = FALSE;
3094 if ((pAd->CommonCfg.PhyMode <= PHY_11G) ||
3095 (pAd->MacTab.Content[BSSID_WCID].HTPhyMode.field.MODE <= MODE_OFDM))
3096 RTMPSetDesiredRates(pAd, rate);
3099 pAd->StaCfg.DesiredTransmitSetting.field.MCS = MCS_AUTO;
3100 #ifdef DOT11_N_SUPPORT
3102 #endif // DOT11_N_SUPPORT //
3104 DBGPRINT(RT_DEBUG_TRACE, ("rt_ioctl_siwrate::(HtMcs=%d)\n",pAd->StaCfg.DesiredTransmitSetting.field.MCS));
3108 // TODO: rate = X, fixed = 0 => (rates <= X)
3116 int rt_ioctl_giwrate(struct net_device *dev,
3117 struct iw_request_info *info,
3118 union iwreq_data *wrqu, char *extra)
3120 PRTMP_ADAPTER pAd = RTMP_OS_NETDEV_GET_PRIV(dev);
3121 int rate_index = 0, rate_count = 0;
3122 HTTRANSMIT_SETTING ht_setting;
3123 /* Remove to global variable
3124 __s32 ralinkrate[] =
3125 {2, 4, 11, 22, // CCK
3126 12, 18, 24, 36, 48, 72, 96, 108, // OFDM
3127 13, 26, 39, 52, 78, 104, 117, 130, 26, 52, 78, 104, 156, 208, 234, 260, // 20MHz, 800ns GI, MCS: 0 ~ 15
3128 39, 78, 117, 156, 234, 312, 351, 390, // 20MHz, 800ns GI, MCS: 16 ~ 23
3129 27, 54, 81, 108, 162, 216, 243, 270, 54, 108, 162, 216, 324, 432, 486, 540, // 40MHz, 800ns GI, MCS: 0 ~ 15
3130 81, 162, 243, 324, 486, 648, 729, 810, // 40MHz, 800ns GI, MCS: 16 ~ 23
3131 14, 29, 43, 57, 87, 115, 130, 144, 29, 59, 87, 115, 173, 230, 260, 288, // 20MHz, 400ns GI, MCS: 0 ~ 15
3132 43, 87, 130, 173, 260, 317, 390, 433, // 20MHz, 400ns GI, MCS: 16 ~ 23
3133 30, 60, 90, 120, 180, 240, 270, 300, 60, 120, 180, 240, 360, 480, 540, 600, // 40MHz, 400ns GI, MCS: 0 ~ 15
3134 90, 180, 270, 360, 540, 720, 810, 900}; // 40MHz, 400ns GI, MCS: 16 ~ 23
3137 rate_count = sizeof(ralinkrate)/sizeof(__s32);
3138 //check if the interface is down
3139 if(!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_IN_USE))
3141 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
3145 if ((pAd->StaCfg.bAutoTxRateSwitch == FALSE) &&
3147 ((pAd->CommonCfg.PhyMode <= PHY_11G) || (pAd->MacTab.Content[BSSID_WCID].HTPhyMode.field.MODE <= MODE_OFDM)))
3148 ht_setting.word = pAd->StaCfg.HTPhyMode.word;
3150 ht_setting.word = pAd->MacTab.Content[BSSID_WCID].HTPhyMode.word;
3152 #ifdef DOT11_N_SUPPORT
3153 if (ht_setting.field.MODE >= MODE_HTMIX)
3155 // rate_index = 12 + ((UCHAR)ht_setting.field.BW *16) + ((UCHAR)ht_setting.field.ShortGI *32) + ((UCHAR)ht_setting.field.MCS);
3156 rate_index = 12 + ((UCHAR)ht_setting.field.BW *24) + ((UCHAR)ht_setting.field.ShortGI *48) + ((UCHAR)ht_setting.field.MCS);
3159 #endif // DOT11_N_SUPPORT //
3160 if (ht_setting.field.MODE == MODE_OFDM)
3161 rate_index = (UCHAR)(ht_setting.field.MCS) + 4;
3162 else if (ht_setting.field.MODE == MODE_CCK)
3163 rate_index = (UCHAR)(ht_setting.field.MCS);
3168 if (rate_index > rate_count)
3169 rate_index = rate_count;
3171 wrqu->bitrate.value = ralinkrate[rate_index] * 500000;
3172 wrqu->bitrate.disabled = 0;
3177 static const iw_handler rt_handler[] =
3179 (iw_handler) NULL, /* SIOCSIWCOMMIT */
3180 (iw_handler) rt_ioctl_giwname, /* SIOCGIWNAME */
3181 (iw_handler) NULL, /* SIOCSIWNWID */
3182 (iw_handler) NULL, /* SIOCGIWNWID */
3183 (iw_handler) rt_ioctl_siwfreq, /* SIOCSIWFREQ */
3184 (iw_handler) rt_ioctl_giwfreq, /* SIOCGIWFREQ */
3185 (iw_handler) rt_ioctl_siwmode, /* SIOCSIWMODE */
3186 (iw_handler) rt_ioctl_giwmode, /* SIOCGIWMODE */
3187 (iw_handler) NULL, /* SIOCSIWSENS */
3188 (iw_handler) NULL, /* SIOCGIWSENS */
3189 (iw_handler) NULL /* not used */, /* SIOCSIWRANGE */
3190 (iw_handler) rt_ioctl_giwrange, /* SIOCGIWRANGE */
3191 (iw_handler) NULL /* not used */, /* SIOCSIWPRIV */
3192 (iw_handler) NULL /* kernel code */, /* SIOCGIWPRIV */
3193 (iw_handler) NULL /* not used */, /* SIOCSIWSTATS */
3194 (iw_handler) rt28xx_get_wireless_stats /* kernel code */, /* SIOCGIWSTATS */
3195 (iw_handler) NULL, /* SIOCSIWSPY */
3196 (iw_handler) NULL, /* SIOCGIWSPY */
3197 (iw_handler) NULL, /* SIOCSIWTHRSPY */
3198 (iw_handler) NULL, /* SIOCGIWTHRSPY */
3199 (iw_handler) rt_ioctl_siwap, /* SIOCSIWAP */
3200 (iw_handler) rt_ioctl_giwap, /* SIOCGIWAP */
3202 (iw_handler) rt_ioctl_siwmlme, /* SIOCSIWMLME */
3204 (iw_handler) NULL, /* SIOCSIWMLME */
3205 #endif // SIOCSIWMLME //
3206 (iw_handler) rt_ioctl_iwaplist, /* SIOCGIWAPLIST */
3208 (iw_handler) rt_ioctl_siwscan, /* SIOCSIWSCAN */
3209 (iw_handler) rt_ioctl_giwscan, /* SIOCGIWSCAN */
3211 (iw_handler) NULL, /* SIOCSIWSCAN */
3212 (iw_handler) NULL, /* SIOCGIWSCAN */
3213 #endif /* SIOCGIWSCAN */
3214 (iw_handler) rt_ioctl_siwessid, /* SIOCSIWESSID */
3215 (iw_handler) rt_ioctl_giwessid, /* SIOCGIWESSID */
3216 (iw_handler) rt_ioctl_siwnickn, /* SIOCSIWNICKN */
3217 (iw_handler) rt_ioctl_giwnickn, /* SIOCGIWNICKN */
3218 (iw_handler) NULL, /* -- hole -- */
3219 (iw_handler) NULL, /* -- hole -- */
3220 (iw_handler) rt_ioctl_siwrate, /* SIOCSIWRATE */
3221 (iw_handler) rt_ioctl_giwrate, /* SIOCGIWRATE */
3222 (iw_handler) rt_ioctl_siwrts, /* SIOCSIWRTS */
3223 (iw_handler) rt_ioctl_giwrts, /* SIOCGIWRTS */
3224 (iw_handler) rt_ioctl_siwfrag, /* SIOCSIWFRAG */
3225 (iw_handler) rt_ioctl_giwfrag, /* SIOCGIWFRAG */
3226 (iw_handler) NULL, /* SIOCSIWTXPOW */
3227 (iw_handler) NULL, /* SIOCGIWTXPOW */
3228 (iw_handler) NULL, /* SIOCSIWRETRY */
3229 (iw_handler) NULL, /* SIOCGIWRETRY */
3230 (iw_handler) rt_ioctl_siwencode, /* SIOCSIWENCODE */
3231 (iw_handler) rt_ioctl_giwencode, /* SIOCGIWENCODE */
3232 (iw_handler) NULL, /* SIOCSIWPOWER */
3233 (iw_handler) NULL, /* SIOCGIWPOWER */
3234 (iw_handler) NULL, /* -- hole -- */
3235 (iw_handler) NULL, /* -- hole -- */
3236 #if WIRELESS_EXT > 17
3237 (iw_handler) rt_ioctl_siwgenie, /* SIOCSIWGENIE */
3238 (iw_handler) rt_ioctl_giwgenie, /* SIOCGIWGENIE */
3239 (iw_handler) rt_ioctl_siwauth, /* SIOCSIWAUTH */
3240 (iw_handler) rt_ioctl_giwauth, /* SIOCGIWAUTH */
3241 (iw_handler) rt_ioctl_siwencodeext, /* SIOCSIWENCODEEXT */
3242 (iw_handler) rt_ioctl_giwencodeext, /* SIOCGIWENCODEEXT */
3243 (iw_handler) rt_ioctl_siwpmksa, /* SIOCSIWPMKSA */
3247 static const iw_handler rt_priv_handlers[] = {
3248 (iw_handler) NULL, /* + 0x00 */
3249 (iw_handler) NULL, /* + 0x01 */
3250 (iw_handler) rt_ioctl_setparam, /* + 0x02 */
3252 (iw_handler) rt_private_ioctl_bbp, /* + 0x03 */
3254 (iw_handler) NULL, /* + 0x03 */
3256 (iw_handler) NULL, /* + 0x04 */
3257 (iw_handler) NULL, /* + 0x05 */
3258 (iw_handler) NULL, /* + 0x06 */
3259 (iw_handler) NULL, /* + 0x07 */
3260 (iw_handler) NULL, /* + 0x08 */
3261 (iw_handler) rt_private_get_statistics, /* + 0x09 */
3262 (iw_handler) NULL, /* + 0x0A */
3263 (iw_handler) NULL, /* + 0x0B */
3264 (iw_handler) NULL, /* + 0x0C */
3265 (iw_handler) NULL, /* + 0x0D */
3266 (iw_handler) NULL, /* + 0x0E */
3267 (iw_handler) NULL, /* + 0x0F */
3268 (iw_handler) NULL, /* + 0x10 */
3269 (iw_handler) rt_private_show, /* + 0x11 */
3270 (iw_handler) NULL, /* + 0x12 */
3271 (iw_handler) NULL, /* + 0x13 */
3272 (iw_handler) NULL, /* + 0x14 */
3273 (iw_handler) NULL, /* + 0x15 */
3274 (iw_handler) NULL, /* + 0x16 */
3275 (iw_handler) NULL, /* + 0x17 */
3276 (iw_handler) NULL, /* + 0x18 */
3279 const struct iw_handler_def rt28xx_iw_handler_def =
3281 #define N(a) (sizeof (a) / sizeof (a[0]))
3282 .standard = (iw_handler *) rt_handler,
3283 .num_standard = sizeof(rt_handler) / sizeof(iw_handler),
3284 .private = (iw_handler *) rt_priv_handlers,
3285 .num_private = N(rt_priv_handlers),
3286 .private_args = (struct iw_priv_args *) privtab,
3287 .num_private_args = N(privtab),
3288 #if IW_HANDLER_VERSION >= 7
3289 .get_wireless_stats = rt28xx_get_wireless_stats,
3293 INT RTMPSetInformation(
3294 IN PRTMP_ADAPTER pAd,
3295 IN OUT struct ifreq *rq,
3298 struct iwreq *wrq = (struct iwreq *) rq;
3299 NDIS_802_11_SSID Ssid;
3300 NDIS_802_11_MAC_ADDRESS Bssid;
3301 RT_802_11_PHY_MODE PhyMode;
3302 RT_802_11_STA_CONFIG StaConfig;
3303 NDIS_802_11_RATES aryRates;
3304 RT_802_11_PREAMBLE Preamble;
3305 NDIS_802_11_WEP_STATUS WepStatus;
3306 NDIS_802_11_AUTHENTICATION_MODE AuthMode = Ndis802_11AuthModeMax;
3307 NDIS_802_11_NETWORK_INFRASTRUCTURE BssType;
3308 NDIS_802_11_RTS_THRESHOLD RtsThresh;
3309 NDIS_802_11_FRAGMENTATION_THRESHOLD FragThresh;
3310 NDIS_802_11_POWER_MODE PowerMode;
3311 PNDIS_802_11_KEY pKey = NULL;
3312 PNDIS_802_11_WEP pWepKey =NULL;
3313 PNDIS_802_11_REMOVE_KEY pRemoveKey = NULL;
3314 NDIS_802_11_CONFIGURATION Config, *pConfig = NULL;
3315 NDIS_802_11_NETWORK_TYPE NetType;
3318 INT Status = NDIS_STATUS_SUCCESS, MaxPhyMode = PHY_11G;
3321 BOOLEAN StateMachineTouched = FALSE;
3322 PNDIS_802_11_PASSPHRASE ppassphrase = NULL;
3323 #ifdef DOT11_N_SUPPORT
3324 OID_SET_HT_PHYMODE HT_PhyMode; //11n ,kathy
3325 #endif // DOT11_N_SUPPORT //
3326 #ifdef WPA_SUPPLICANT_SUPPORT
3327 PNDIS_802_11_PMKID pPmkId = NULL;
3328 BOOLEAN IEEE8021xState = FALSE;
3329 BOOLEAN IEEE8021x_required_keys = FALSE;
3330 UCHAR wpa_supplicant_enable = 0;
3331 #endif // WPA_SUPPLICANT_SUPPORT //
3334 TX_RTY_CFG_STRUC tx_rty_cfg;
3335 ULONG ShortRetryLimit, LongRetryLimit;
3337 #endif // SNMP_SUPPORT //
3342 #ifdef DOT11_N_SUPPORT
3343 MaxPhyMode = PHY_11N_5G;
3344 #endif // DOT11_N_SUPPORT //
3346 DBGPRINT(RT_DEBUG_TRACE, ("-->RTMPSetInformation(), 0x%08x\n", cmd&0x7FFF));
3347 switch(cmd & 0x7FFF) {
3348 case RT_OID_802_11_COUNTRY_REGION:
3349 if (wrq->u.data.length < sizeof(UCHAR))
3351 // Only avaliable when EEPROM not programming
3352 else if (!(pAd->CommonCfg.CountryRegion & 0x80) && !(pAd->CommonCfg.CountryRegionForABand & 0x80))
3357 Status = copy_from_user(&Country, wrq->u.data.pointer, wrq->u.data.length);
3358 pAd->CommonCfg.CountryRegion = (UCHAR)(Country & 0x000000FF);
3359 pAd->CommonCfg.CountryRegionForABand = (UCHAR)((Country >> 8) & 0x000000FF);
3360 TmpPhy = pAd->CommonCfg.PhyMode;
3361 pAd->CommonCfg.PhyMode = 0xff;
3362 // Build all corresponding channel information
3363 RTMPSetPhyMode(pAd, TmpPhy);
3364 #ifdef DOT11_N_SUPPORT
3366 #endif // DOT11_N_SUPPORT //
3367 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_COUNTRY_REGION (A:%d B/G:%d)\n", pAd->CommonCfg.CountryRegionForABand,
3368 pAd->CommonCfg.CountryRegion));
3371 case OID_802_11_BSSID_LIST_SCAN:
3373 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_BSSID_LIST_SCAN, TxCnt = %d \n", pAd->RalinkCounters.LastOneSecTotalTxCount));
3375 if (MONITOR_ON(pAd))
3377 DBGPRINT(RT_DEBUG_TRACE, ("!!! Driver is in Monitor Mode now !!!\n"));
3381 //Benson add 20080527, when radio off, sta don't need to scan
3382 if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_RADIO_OFF))
3385 if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
3387 DBGPRINT(RT_DEBUG_TRACE, ("!!! Driver is scanning now !!!\n"));
3388 pAd->StaCfg.bScanReqIsFromWebUI = TRUE;
3389 Status = NDIS_STATUS_SUCCESS;
3393 if (pAd->RalinkCounters.LastOneSecTotalTxCount > 100)
3395 DBGPRINT(RT_DEBUG_TRACE, ("!!! Link UP, ignore this set::OID_802_11_BSSID_LIST_SCAN\n"));
3396 Status = NDIS_STATUS_SUCCESS;
3397 pAd->StaCfg.ScanCnt = 99; // Prevent auto scan triggered by this OID
3401 if ((OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED)) &&
3402 ((pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA) ||
3403 (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK) ||
3404 (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2) ||
3405 (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK)) &&
3406 (pAd->StaCfg.PortSecured == WPA_802_1X_PORT_NOT_SECURED))
3408 DBGPRINT(RT_DEBUG_TRACE, ("!!! Link UP, Port Not Secured! ignore this set::OID_802_11_BSSID_LIST_SCAN\n"));
3409 Status = NDIS_STATUS_SUCCESS;
3410 pAd->StaCfg.ScanCnt = 99; // Prevent auto scan triggered by this OID
3415 if (pAd->Mlme.CntlMachine.CurrState != CNTL_IDLE)
3417 RTMP_MLME_RESET_STATE_MACHINE(pAd);
3418 DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
3421 // tell CNTL state machine to call NdisMSetInformationComplete() after completing
3422 // this request, because this request is initiated by NDIS.
3423 pAd->MlmeAux.CurrReqIsFromNdis = FALSE;
3424 // Reset allowed scan retries
3425 pAd->StaCfg.ScanCnt = 0;
3426 pAd->StaCfg.LastScanTime = Now;
3428 pAd->StaCfg.bScanReqIsFromWebUI = TRUE;
3429 RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS);
3431 MLME_CNTL_STATE_MACHINE,
3432 OID_802_11_BSSID_LIST_SCAN,
3436 Status = NDIS_STATUS_SUCCESS;
3437 StateMachineTouched = TRUE;
3439 case OID_802_11_SSID:
3440 if (wrq->u.data.length != sizeof(NDIS_802_11_SSID))
3444 PSTRING pSsidString = NULL;
3445 Status = copy_from_user(&Ssid, wrq->u.data.pointer, wrq->u.data.length);
3447 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_SSID (Len=%d,Ssid=%s)\n", Ssid.SsidLength, Ssid.Ssid));
3448 if (Ssid.SsidLength > MAX_LEN_OF_SSID)
3452 if (Ssid.SsidLength == 0)
3454 Set_SSID_Proc(pAd, "");
3458 pSsidString = (PSTRING)kmalloc(MAX_LEN_OF_SSID+1, MEM_ALLOC_FLAG);
3461 NdisZeroMemory(pSsidString, MAX_LEN_OF_SSID+1);
3462 NdisMoveMemory(pSsidString, Ssid.Ssid, Ssid.SsidLength);
3463 Set_SSID_Proc(pAd, pSsidString);
3472 case OID_802_11_SET_PASSPHRASE:
3473 ppassphrase= kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
3475 if(ppassphrase== NULL)
3478 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_SET_PASSPHRASE, Failed!!\n"));
3483 Status = copy_from_user(ppassphrase, wrq->u.data.pointer, wrq->u.data.length);
3488 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_SET_PASSPHRASE, Failed (length mismatch)!!\n"));
3492 if(ppassphrase->KeyLength < 8 || ppassphrase->KeyLength > 64)
3495 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_SET_PASSPHRASE, Failed (len less than 8 or greater than 64)!!\n"));
3499 // set key passphrase and length
3500 NdisZeroMemory(pAd->StaCfg.WpaPassPhrase, 64);
3501 NdisMoveMemory(pAd->StaCfg.WpaPassPhrase, &ppassphrase->KeyMaterial, ppassphrase->KeyLength);
3502 pAd->StaCfg.WpaPassPhraseLen = ppassphrase->KeyLength;
3503 hex_dump("pAd->StaCfg.WpaPassPhrase", pAd->StaCfg.WpaPassPhrase, 64);
3504 printk("WpaPassPhrase=%s\n",pAd->StaCfg.WpaPassPhrase);
3511 case OID_802_11_BSSID:
3512 if (wrq->u.data.length != sizeof(NDIS_802_11_MAC_ADDRESS))
3516 Status = copy_from_user(&Bssid, wrq->u.data.pointer, wrq->u.data.length);
3518 // tell CNTL state machine to call NdisMSetInformationComplete() after completing
3519 // this request, because this request is initiated by NDIS.
3520 pAd->MlmeAux.CurrReqIsFromNdis = FALSE;
3522 // Prevent to connect AP again in STAMlmePeriodicExec
3523 pAd->MlmeAux.AutoReconnectSsidLen= 32;
3525 // Reset allowed scan retries
3526 pAd->StaCfg.ScanCnt = 0;
3528 if (pAd->Mlme.CntlMachine.CurrState != CNTL_IDLE)
3530 RTMP_MLME_RESET_STATE_MACHINE(pAd);
3531 DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
3534 MLME_CNTL_STATE_MACHINE,
3536 sizeof(NDIS_802_11_MAC_ADDRESS),
3538 Status = NDIS_STATUS_SUCCESS;
3539 StateMachineTouched = TRUE;
3541 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_BSSID %02x:%02x:%02x:%02x:%02x:%02x\n",
3542 Bssid[0], Bssid[1], Bssid[2], Bssid[3], Bssid[4], Bssid[5]));
3545 case RT_OID_802_11_RADIO:
3546 if (wrq->u.data.length != sizeof(BOOLEAN))
3550 Status = copy_from_user(&RadioState, wrq->u.data.pointer, wrq->u.data.length);
3551 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_RADIO (=%d)\n", RadioState));
3552 if (pAd->StaCfg.bSwRadio != RadioState)
3554 pAd->StaCfg.bSwRadio = RadioState;
3555 if (pAd->StaCfg.bRadio != (pAd->StaCfg.bHwRadio && pAd->StaCfg.bSwRadio))
3557 pAd->StaCfg.bRadio = (pAd->StaCfg.bHwRadio && pAd->StaCfg.bSwRadio);
3558 if (pAd->StaCfg.bRadio == TRUE)
3561 // Update extra information
3562 pAd->ExtraInfo = EXTRA_INFO_CLEAR;
3566 if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
3568 if (pAd->Mlme.CntlMachine.CurrState != CNTL_IDLE)
3570 RTMP_MLME_RESET_STATE_MACHINE(pAd);
3571 DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
3576 // Update extra information
3577 pAd->ExtraInfo = SW_RADIO_OFF;
3583 case RT_OID_802_11_PHY_MODE:
3584 if (wrq->u.data.length != sizeof(RT_802_11_PHY_MODE))
3588 Status = copy_from_user(&PhyMode, wrq->u.data.pointer, wrq->u.data.length);
3589 if (PhyMode <= MaxPhyMode)
3591 RTMPSetPhyMode(pAd, PhyMode);
3592 #ifdef DOT11_N_SUPPORT
3594 #endif // DOT11_N_SUPPORT //
3596 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_PHY_MODE (=%d)\n", PhyMode));
3599 case RT_OID_802_11_STA_CONFIG:
3600 if (wrq->u.data.length != sizeof(RT_802_11_STA_CONFIG))
3606 Status = copy_from_user(&StaConfig, wrq->u.data.pointer, wrq->u.data.length);
3607 pAd->CommonCfg.bEnableTxBurst = StaConfig.EnableTxBurst;
3608 pAd->CommonCfg.UseBGProtection = StaConfig.UseBGProtection;
3609 pAd->CommonCfg.bUseShortSlotTime = 1; // 2003-10-30 always SHORT SLOT capable
3610 if ((pAd->CommonCfg.PhyMode != StaConfig.AdhocMode) &&
3611 (StaConfig.AdhocMode <= MaxPhyMode))
3613 // allow dynamic change of "USE OFDM rate or not" in ADHOC mode
3614 // if setting changed, need to reset current TX rate as well as BEACON frame format
3615 if (pAd->StaCfg.BssType == BSS_ADHOC)
3617 pAd->CommonCfg.PhyMode = StaConfig.AdhocMode;
3618 RTMPSetPhyMode(pAd, PhyMode);
3619 MlmeUpdateTxRates(pAd, FALSE, 0);
3620 MakeIbssBeacon(pAd); // re-build BEACON frame
3621 AsicEnableIbssSync(pAd); // copy to on-chip memory
3624 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_SET_STA_CONFIG (Burst=%d, Protection=%ld,ShortSlot=%d\n",
3625 pAd->CommonCfg.bEnableTxBurst,
3626 pAd->CommonCfg.UseBGProtection,
3627 pAd->CommonCfg.bUseShortSlotTime));
3629 if (pAd->CommonCfg.PSPXlink)
3633 RTMP_IO_WRITE32(pAd, RX_FILTR_CFG, Value);
3635 RTMP_IO_READ32(pAd, MAC_SYS_CTRL, &Value);
3637 RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, Value);
3640 case OID_802_11_DESIRED_RATES:
3641 if (wrq->u.data.length != sizeof(NDIS_802_11_RATES))
3645 Status = copy_from_user(&aryRates, wrq->u.data.pointer, wrq->u.data.length);
3646 NdisZeroMemory(pAd->CommonCfg.DesireRate, MAX_LEN_OF_SUPPORTED_RATES);
3647 NdisMoveMemory(pAd->CommonCfg.DesireRate, &aryRates, sizeof(NDIS_802_11_RATES));
3648 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_DESIRED_RATES (%02x,%02x,%02x,%02x,%02x,%02x,%02x,%02x)\n",
3649 pAd->CommonCfg.DesireRate[0],pAd->CommonCfg.DesireRate[1],
3650 pAd->CommonCfg.DesireRate[2],pAd->CommonCfg.DesireRate[3],
3651 pAd->CommonCfg.DesireRate[4],pAd->CommonCfg.DesireRate[5],
3652 pAd->CommonCfg.DesireRate[6],pAd->CommonCfg.DesireRate[7] ));
3653 // Changing DesiredRate may affect the MAX TX rate we used to TX frames out
3654 MlmeUpdateTxRates(pAd, FALSE, 0);
3657 case RT_OID_802_11_PREAMBLE:
3658 if (wrq->u.data.length != sizeof(RT_802_11_PREAMBLE))
3662 Status = copy_from_user(&Preamble, wrq->u.data.pointer, wrq->u.data.length);
3663 if (Preamble == Rt802_11PreambleShort)
3665 pAd->CommonCfg.TxPreamble = Preamble;
3666 MlmeSetTxPreamble(pAd, Rt802_11PreambleShort);
3668 else if ((Preamble == Rt802_11PreambleLong) || (Preamble == Rt802_11PreambleAuto))
3670 // if user wants AUTO, initialize to LONG here, then change according to AP's
3671 // capability upon association.
3672 pAd->CommonCfg.TxPreamble = Preamble;
3673 MlmeSetTxPreamble(pAd, Rt802_11PreambleLong);
3680 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_PREAMBLE (=%d)\n", Preamble));
3683 case OID_802_11_WEP_STATUS:
3684 if (wrq->u.data.length != sizeof(NDIS_802_11_WEP_STATUS))
3688 Status = copy_from_user(&WepStatus, wrq->u.data.pointer, wrq->u.data.length);
3689 // Since TKIP, AES, WEP are all supported. It should not have any invalid setting
3690 if (WepStatus <= Ndis802_11Encryption3KeyAbsent)
3692 if (pAd->StaCfg.WepStatus != WepStatus)
3694 // Config has changed
3695 pAd->bConfigChanged = TRUE;
3697 pAd->StaCfg.WepStatus = WepStatus;
3698 pAd->StaCfg.OrigWepStatus = WepStatus;
3699 pAd->StaCfg.PairCipher = WepStatus;
3700 pAd->StaCfg.GroupCipher = WepStatus;
3707 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_WEP_STATUS (=%d)\n",WepStatus));
3710 case OID_802_11_AUTHENTICATION_MODE:
3711 if (wrq->u.data.length != sizeof(NDIS_802_11_AUTHENTICATION_MODE))
3715 Status = copy_from_user(&AuthMode, wrq->u.data.pointer, wrq->u.data.length);
3716 if (AuthMode > Ndis802_11AuthModeMax)
3723 if (pAd->StaCfg.AuthMode != AuthMode)
3725 // Config has changed
3726 pAd->bConfigChanged = TRUE;
3728 pAd->StaCfg.AuthMode = AuthMode;
3730 pAd->StaCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED;
3731 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_AUTHENTICATION_MODE (=%d) \n",pAd->StaCfg.AuthMode));
3734 case OID_802_11_INFRASTRUCTURE_MODE:
3735 if (wrq->u.data.length != sizeof(NDIS_802_11_NETWORK_INFRASTRUCTURE))
3739 Status = copy_from_user(&BssType, wrq->u.data.pointer, wrq->u.data.length);
3741 if (BssType == Ndis802_11IBSS)
3742 Set_NetworkType_Proc(pAd, "Adhoc");
3743 else if (BssType == Ndis802_11Infrastructure)
3744 Set_NetworkType_Proc(pAd, "Infra");
3745 else if (BssType == Ndis802_11Monitor)
3746 Set_NetworkType_Proc(pAd, "Monitor");
3750 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_INFRASTRUCTURE_MODE (unknown)\n"));
3754 case OID_802_11_REMOVE_WEP:
3755 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_WEP\n"));
3756 if (wrq->u.data.length != sizeof(NDIS_802_11_KEY_INDEX))
3762 KeyIdx = *(NDIS_802_11_KEY_INDEX *) wrq->u.data.pointer;
3764 if (KeyIdx & 0x80000000)
3766 // Should never set default bit when remove key
3771 KeyIdx = KeyIdx & 0x0fffffff;
3777 pAd->SharedKey[BSS0][KeyIdx].KeyLen = 0;
3778 pAd->SharedKey[BSS0][KeyIdx].CipherAlg = CIPHER_NONE;
3779 AsicRemoveSharedKeyEntry(pAd, 0, (UCHAR)KeyIdx);
3784 case RT_OID_802_11_RESET_COUNTERS:
3785 NdisZeroMemory(&pAd->WlanCounters, sizeof(COUNTER_802_11));
3786 NdisZeroMemory(&pAd->Counters8023, sizeof(COUNTER_802_3));
3787 NdisZeroMemory(&pAd->RalinkCounters, sizeof(COUNTER_RALINK));
3788 pAd->Counters8023.RxNoBuffer = 0;
3789 pAd->Counters8023.GoodReceives = 0;
3790 pAd->Counters8023.RxNoBuffer = 0;
3791 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_RESET_COUNTERS \n"));
3793 case OID_802_11_RTS_THRESHOLD:
3794 if (wrq->u.data.length != sizeof(NDIS_802_11_RTS_THRESHOLD))
3798 Status = copy_from_user(&RtsThresh, wrq->u.data.pointer, wrq->u.data.length);
3799 if (RtsThresh > MAX_RTS_THRESHOLD)
3802 pAd->CommonCfg.RtsThreshold = (USHORT)RtsThresh;
3804 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_RTS_THRESHOLD (=%ld)\n",RtsThresh));
3806 case OID_802_11_FRAGMENTATION_THRESHOLD:
3807 if (wrq->u.data.length != sizeof(NDIS_802_11_FRAGMENTATION_THRESHOLD))
3811 Status = copy_from_user(&FragThresh, wrq->u.data.pointer, wrq->u.data.length);
3812 pAd->CommonCfg.bUseZeroToDisableFragment = FALSE;
3813 if (FragThresh > MAX_FRAG_THRESHOLD || FragThresh < MIN_FRAG_THRESHOLD)
3815 if (FragThresh == 0)
3817 pAd->CommonCfg.FragmentThreshold = MAX_FRAG_THRESHOLD;
3818 pAd->CommonCfg.bUseZeroToDisableFragment = TRUE;
3824 pAd->CommonCfg.FragmentThreshold = (USHORT)FragThresh;
3826 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_FRAGMENTATION_THRESHOLD (=%ld) \n",FragThresh));
3828 case OID_802_11_POWER_MODE:
3829 if (wrq->u.data.length != sizeof(NDIS_802_11_POWER_MODE))
3833 Status = copy_from_user(&PowerMode, wrq->u.data.pointer, wrq->u.data.length);
3834 if (PowerMode == Ndis802_11PowerModeCAM)
3835 Set_PSMode_Proc(pAd, "CAM");
3836 else if (PowerMode == Ndis802_11PowerModeMAX_PSP)
3837 Set_PSMode_Proc(pAd, "Max_PSP");
3838 else if (PowerMode == Ndis802_11PowerModeFast_PSP)
3839 Set_PSMode_Proc(pAd, "Fast_PSP");
3840 else if (PowerMode == Ndis802_11PowerModeLegacy_PSP)
3841 Set_PSMode_Proc(pAd, "Legacy_PSP");
3845 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_POWER_MODE (=%d)\n",PowerMode));
3847 case RT_OID_802_11_TX_POWER_LEVEL_1:
3848 if (wrq->u.data.length < sizeof(ULONG))
3852 Status = copy_from_user(&PowerTemp, wrq->u.data.pointer, wrq->u.data.length);
3853 if (PowerTemp > 100)
3854 PowerTemp = 0xffffffff; // AUTO
3855 pAd->CommonCfg.TxPowerDefault = PowerTemp; //keep current setting.
3856 pAd->CommonCfg.TxPowerPercentage = pAd->CommonCfg.TxPowerDefault;
3857 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_TX_POWER_LEVEL_1 (=%ld)\n", pAd->CommonCfg.TxPowerPercentage));
3860 case OID_802_11_NETWORK_TYPE_IN_USE:
3861 if (wrq->u.data.length != sizeof(NDIS_802_11_NETWORK_TYPE))
3865 Status = copy_from_user(&NetType, wrq->u.data.pointer, wrq->u.data.length);
3867 if (NetType == Ndis802_11DS)
3868 RTMPSetPhyMode(pAd, PHY_11B);
3869 else if (NetType == Ndis802_11OFDM24)
3870 RTMPSetPhyMode(pAd, PHY_11BG_MIXED);
3871 else if (NetType == Ndis802_11OFDM5)
3872 RTMPSetPhyMode(pAd, PHY_11A);
3875 #ifdef DOT11_N_SUPPORT
3876 if (Status == NDIS_STATUS_SUCCESS)
3878 #endif // DOT11_N_SUPPORT //
3879 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_NETWORK_TYPE_IN_USE (=%d)\n",NetType));
3882 // For WPA PSK PMK key
3883 case RT_OID_802_11_ADD_WPA:
3884 pKey = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
3891 Status = copy_from_user(pKey, wrq->u.data.pointer, wrq->u.data.length);
3892 if (pKey->Length != wrq->u.data.length)
3895 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_ADD_WPA, Failed!!\n"));
3899 if ((pAd->StaCfg.AuthMode != Ndis802_11AuthModeWPAPSK) &&
3900 (pAd->StaCfg.AuthMode != Ndis802_11AuthModeWPA2PSK) &&
3901 (pAd->StaCfg.AuthMode != Ndis802_11AuthModeWPANone) )
3903 Status = -EOPNOTSUPP;
3904 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_ADD_WPA, Failed!! [AuthMode != WPAPSK/WPA2PSK/WPANONE]\n"));
3906 else if ((pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK) ||
3907 (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK) ||
3908 (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPANone) ) // Only for WPA PSK mode
3910 NdisMoveMemory(pAd->StaCfg.PMK, &pKey->KeyMaterial, pKey->KeyLength);
3911 // Use RaConfig as PSK agent.
3912 // Start STA supplicant state machine
3913 if (pAd->StaCfg.AuthMode != Ndis802_11AuthModeWPANone)
3914 pAd->StaCfg.WpaState = SS_START;
3916 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_ADD_WPA (id=0x%x, Len=%d-byte)\n", pKey->KeyIndex, pKey->KeyLength));
3920 pAd->StaCfg.WpaState = SS_NOTUSE;
3921 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_ADD_WPA (id=0x%x, Len=%d-byte)\n", pKey->KeyIndex, pKey->KeyLength));
3926 case OID_802_11_REMOVE_KEY:
3927 pRemoveKey = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
3928 if(pRemoveKey == NULL)
3934 Status = copy_from_user(pRemoveKey, wrq->u.data.pointer, wrq->u.data.length);
3935 if (pRemoveKey->Length != wrq->u.data.length)
3938 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_KEY, Failed!!\n"));
3942 if (pAd->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
3944 RTMPWPARemoveKeyProc(pAd, pRemoveKey);
3945 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_KEY, Remove WPA Key!!\n"));
3949 KeyIdx = pRemoveKey->KeyIndex;
3951 if (KeyIdx & 0x80000000)
3953 // Should never set default bit when remove key
3955 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_KEY, Failed!!(Should never set default bit when remove key)\n"));
3959 KeyIdx = KeyIdx & 0x0fffffff;
3963 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_KEY, Failed!!(KeyId[%d] out of range)\n", KeyIdx));
3967 pAd->SharedKey[BSS0][KeyIdx].KeyLen = 0;
3968 pAd->SharedKey[BSS0][KeyIdx].CipherAlg = CIPHER_NONE;
3969 AsicRemoveSharedKeyEntry(pAd, 0, (UCHAR)KeyIdx);
3970 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_KEY (id=0x%x, Len=%d-byte)\n", pRemoveKey->KeyIndex, pRemoveKey->Length));
3978 case OID_802_11_ADD_KEY:
3979 pKey = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
3985 Status = copy_from_user(pKey, wrq->u.data.pointer, wrq->u.data.length);
3986 if (pKey->Length != wrq->u.data.length)
3989 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_KEY, Failed!!\n"));
3993 RTMPAddKey(pAd, pKey);
3994 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_KEY (id=0x%x, Len=%d-byte)\n", pKey->KeyIndex, pKey->KeyLength));
3998 case OID_802_11_CONFIGURATION:
3999 if (wrq->u.data.length != sizeof(NDIS_802_11_CONFIGURATION))
4003 Status = copy_from_user(&Config, wrq->u.data.pointer, wrq->u.data.length);
4006 if ((pConfig->BeaconPeriod >= 20) && (pConfig->BeaconPeriod <=400))
4007 pAd->CommonCfg.BeaconPeriod = (USHORT) pConfig->BeaconPeriod;
4009 pAd->StaActive.AtimWin = (USHORT) pConfig->ATIMWindow;
4010 MAP_KHZ_TO_CHANNEL_ID(pConfig->DSConfig, pAd->CommonCfg.Channel);
4012 // Save the channel on MlmeAux for CntlOidRTBssidProc used.
4014 pAd->MlmeAux.Channel = pAd->CommonCfg.Channel;
4016 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_CONFIGURATION (BeacnPeriod=%ld,AtimW=%ld,Ch=%d)\n",
4017 pConfig->BeaconPeriod, pConfig->ATIMWindow, pAd->CommonCfg.Channel));
4018 // Config has changed
4019 pAd->bConfigChanged = TRUE;
4022 #ifdef DOT11_N_SUPPORT
4023 case RT_OID_802_11_SET_HT_PHYMODE:
4024 if (wrq->u.data.length != sizeof(OID_SET_HT_PHYMODE))
4028 POID_SET_HT_PHYMODE pHTPhyMode = &HT_PhyMode;
4030 Status = copy_from_user(&HT_PhyMode, wrq->u.data.pointer, wrq->u.data.length);
4031 DBGPRINT(RT_DEBUG_TRACE, ("Set::pHTPhyMode (PhyMode = %d,TransmitNo = %d, HtMode = %d, ExtOffset = %d , MCS = %d, BW = %d, STBC = %d, SHORTGI = %d) \n",
4032 pHTPhyMode->PhyMode, pHTPhyMode->TransmitNo,pHTPhyMode->HtMode,pHTPhyMode->ExtOffset,
4033 pHTPhyMode->MCS, pHTPhyMode->BW, pHTPhyMode->STBC, pHTPhyMode->SHORTGI));
4034 if (pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED)
4035 RTMPSetHT(pAd, pHTPhyMode);
4037 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_SET_HT_PHYMODE(MCS=%d,BW=%d,SGI=%d,STBC=%d)\n",
4038 pAd->StaCfg.HTPhyMode.field.MCS, pAd->StaCfg.HTPhyMode.field.BW, pAd->StaCfg.HTPhyMode.field.ShortGI,
4039 pAd->StaCfg.HTPhyMode.field.STBC));
4041 #endif // DOT11_N_SUPPORT //
4042 case RT_OID_802_11_SET_APSD_SETTING:
4043 if (wrq->u.data.length != sizeof(ULONG))
4048 Status = copy_from_user(&apsd, wrq->u.data.pointer, wrq->u.data.length);
4050 /*-------------------------------------------------------------------
4051 |B31~B7 | B6~B5 | B4 | B3 | B2 | B1 | B0 |
4052 ---------------------------------------------------------------------
4053 | Rsvd | Max SP Len | AC_VO | AC_VI | AC_BK | AC_BE | APSD Capable |
4054 ---------------------------------------------------------------------*/
4055 pAd->CommonCfg.bAPSDCapable = (apsd & 0x00000001) ? TRUE : FALSE;
4056 pAd->CommonCfg.bAPSDAC_BE = ((apsd & 0x00000002) >> 1) ? TRUE : FALSE;
4057 pAd->CommonCfg.bAPSDAC_BK = ((apsd & 0x00000004) >> 2) ? TRUE : FALSE;
4058 pAd->CommonCfg.bAPSDAC_VI = ((apsd & 0x00000008) >> 3) ? TRUE : FALSE;
4059 pAd->CommonCfg.bAPSDAC_VO = ((apsd & 0x00000010) >> 4) ? TRUE : FALSE;
4060 pAd->CommonCfg.MaxSPLength = (UCHAR)((apsd & 0x00000060) >> 5);
4062 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, pAd->CommonCfg.bAPSDCapable,
4063 pAd->CommonCfg.bAPSDAC_BE, pAd->CommonCfg.bAPSDAC_BK, pAd->CommonCfg.bAPSDAC_VI, pAd->CommonCfg.bAPSDAC_VO, pAd->CommonCfg.MaxSPLength));
4067 case RT_OID_802_11_SET_APSD_PSM:
4068 if (wrq->u.data.length != sizeof(ULONG))
4072 // Driver needs to notify AP when PSM changes
4073 Status = copy_from_user(&pAd->CommonCfg.bAPSDForcePowerSave, wrq->u.data.pointer, wrq->u.data.length);
4074 if (pAd->CommonCfg.bAPSDForcePowerSave != pAd->StaCfg.Psm)
4076 RTMP_SET_PSM_BIT(pAd, pAd->CommonCfg.bAPSDForcePowerSave);
4077 RTMPSendNullFrame(pAd, pAd->CommonCfg.TxRate, TRUE);
4079 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_SET_APSD_PSM (bAPSDForcePowerSave:%d)\n", pAd->CommonCfg.bAPSDForcePowerSave));
4082 #ifdef QOS_DLS_SUPPORT
4083 case RT_OID_802_11_SET_DLS:
4084 if (wrq->u.data.length != sizeof(ULONG))
4088 BOOLEAN oldvalue = pAd->CommonCfg.bDLSCapable;
4089 Status = copy_from_user(&pAd->CommonCfg.bDLSCapable, wrq->u.data.pointer, wrq->u.data.length);
4090 if (oldvalue && !pAd->CommonCfg.bDLSCapable)
4093 // tear down local dls table entry
4094 for (i=0; i<MAX_NUM_OF_INIT_DLS_ENTRY; i++)
4096 if (pAd->StaCfg.DLSEntry[i].Valid && (pAd->StaCfg.DLSEntry[i].Status == DLS_FINISH))
4098 pAd->StaCfg.DLSEntry[i].Status = DLS_NONE;
4099 pAd->StaCfg.DLSEntry[i].Valid = FALSE;
4100 RTMPSendDLSTearDownFrame(pAd, pAd->StaCfg.DLSEntry[i].MacAddr);
4104 // tear down peer dls table entry
4105 for (i=MAX_NUM_OF_INIT_DLS_ENTRY; i<MAX_NUM_OF_DLS_ENTRY; i++)
4107 if (pAd->StaCfg.DLSEntry[i].Valid && (pAd->StaCfg.DLSEntry[i].Status == DLS_FINISH))
4109 pAd->StaCfg.DLSEntry[i].Status = DLS_NONE;
4110 pAd->StaCfg.DLSEntry[i].Valid = FALSE;
4111 RTMPSendDLSTearDownFrame(pAd, pAd->StaCfg.DLSEntry[i].MacAddr);
4116 DBGPRINT(RT_DEBUG_TRACE,("Set::RT_OID_802_11_SET_DLS (=%d)\n", pAd->CommonCfg.bDLSCapable));
4120 case RT_OID_802_11_SET_DLS_PARAM:
4121 if (wrq->u.data.length != sizeof(RT_802_11_DLS_UI))
4127 NdisZeroMemory(&Dls, sizeof(RT_802_11_DLS));
4128 RTMPMoveMemory(&Dls, wrq->u.data.pointer, sizeof(RT_802_11_DLS_UI));
4130 MLME_CNTL_STATE_MACHINE,
4131 RT_OID_802_11_SET_DLS_PARAM,
4132 sizeof(RT_802_11_DLS),
4134 DBGPRINT(RT_DEBUG_TRACE,("Set::RT_OID_802_11_SET_DLS_PARAM \n"));
4137 #endif // QOS_DLS_SUPPORT //
4138 case RT_OID_802_11_SET_WMM:
4139 if (wrq->u.data.length != sizeof(BOOLEAN))
4143 Status = copy_from_user(&pAd->CommonCfg.bWmmCapable, wrq->u.data.pointer, wrq->u.data.length);
4144 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_SET_WMM (=%d) \n", pAd->CommonCfg.bWmmCapable));
4148 case OID_802_11_DISASSOCIATE:
4150 // Set NdisRadioStateOff to TRUE, instead of called MlmeRadioOff.
4151 // Later on, NDIS_802_11_BSSID_LIST_EX->NumberOfItems should be 0
4152 // when query OID_802_11_BSSID_LIST.
4154 // TRUE: NumberOfItems will set to 0.
4155 // FALSE: NumberOfItems no change.
4157 pAd->CommonCfg.NdisRadioStateOff = TRUE;
4158 // Set to immediately send the media disconnect event
4159 pAd->MlmeAux.CurrReqIsFromNdis = TRUE;
4160 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_DISASSOCIATE \n"));
4165 if (pAd->Mlme.CntlMachine.CurrState != CNTL_IDLE)
4167 RTMP_MLME_RESET_STATE_MACHINE(pAd);
4168 DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
4172 MLME_CNTL_STATE_MACHINE,
4173 OID_802_11_DISASSOCIATE,
4177 StateMachineTouched = TRUE;
4181 #ifdef DOT11_N_SUPPORT
4182 case RT_OID_802_11_SET_IMME_BA_CAP:
4183 if (wrq->u.data.length != sizeof(OID_BACAP_STRUC))
4187 OID_BACAP_STRUC Orde ;
4188 Status = copy_from_user(&Orde, wrq->u.data.pointer, wrq->u.data.length);
4189 if (Orde.Policy > BA_NOTUSE)
4191 Status = NDIS_STATUS_INVALID_DATA;
4193 else if (Orde.Policy == BA_NOTUSE)
4195 pAd->CommonCfg.BACapability.field.Policy = BA_NOTUSE;
4196 pAd->CommonCfg.BACapability.field.MpduDensity = Orde.MpduDensity;
4197 pAd->CommonCfg.DesiredHtPhy.MpduDensity = Orde.MpduDensity;
4198 pAd->CommonCfg.DesiredHtPhy.AmsduEnable = Orde.AmsduEnable;
4199 pAd->CommonCfg.DesiredHtPhy.AmsduSize= Orde.AmsduSize;
4200 pAd->CommonCfg.DesiredHtPhy.MimoPs= Orde.MMPSmode;
4201 pAd->CommonCfg.BACapability.field.MMPSmode = Orde.MMPSmode;
4203 pAd->CommonCfg.HtCapability.HtCapInfo.MimoPs = Orde.MMPSmode;
4204 pAd->CommonCfg.HtCapability.HtCapInfo.AMsduSize = Orde.AmsduSize;
4205 pAd->CommonCfg.HtCapability.HtCapParm.MpduDensity = Orde.MpduDensity;
4209 pAd->CommonCfg.BACapability.field.AutoBA = Orde.AutoBA;
4210 pAd->CommonCfg.BACapability.field.Policy = IMMED_BA; // we only support immediate BA.
4211 pAd->CommonCfg.BACapability.field.MpduDensity = Orde.MpduDensity;
4212 pAd->CommonCfg.DesiredHtPhy.MpduDensity = Orde.MpduDensity;
4213 pAd->CommonCfg.DesiredHtPhy.AmsduEnable = Orde.AmsduEnable;
4214 pAd->CommonCfg.DesiredHtPhy.AmsduSize= Orde.AmsduSize;
4215 pAd->CommonCfg.DesiredHtPhy.MimoPs = Orde.MMPSmode;
4216 pAd->CommonCfg.BACapability.field.MMPSmode = Orde.MMPSmode;
4219 pAd->CommonCfg.HtCapability.HtCapInfo.MimoPs = Orde.MMPSmode;
4220 pAd->CommonCfg.HtCapability.HtCapInfo.AMsduSize = Orde.AmsduSize;
4221 pAd->CommonCfg.HtCapability.HtCapParm.MpduDensity = Orde.MpduDensity;
4223 if (pAd->CommonCfg.BACapability.field.RxBAWinLimit > MAX_RX_REORDERBUF)
4224 pAd->CommonCfg.BACapability.field.RxBAWinLimit = MAX_RX_REORDERBUF;
4228 pAd->CommonCfg.REGBACapability.word = pAd->CommonCfg.BACapability.word;
4229 DBGPRINT(RT_DEBUG_TRACE, ("Set::(Orde.AutoBA = %d) (Policy=%d)(ReBAWinLimit=%d)(TxBAWinLimit=%d)(AutoMode=%d)\n",Orde.AutoBA, pAd->CommonCfg.BACapability.field.Policy,
4230 pAd->CommonCfg.BACapability.field.RxBAWinLimit,pAd->CommonCfg.BACapability.field.TxBAWinLimit, pAd->CommonCfg.BACapability.field.AutoBA));
4231 DBGPRINT(RT_DEBUG_TRACE, ("Set::(MimoPs = %d)(AmsduEnable = %d) (AmsduSize=%d)(MpduDensity=%d)\n",pAd->CommonCfg.DesiredHtPhy.MimoPs, pAd->CommonCfg.DesiredHtPhy.AmsduEnable,
4232 pAd->CommonCfg.DesiredHtPhy.AmsduSize, pAd->CommonCfg.DesiredHtPhy.MpduDensity));
4236 case RT_OID_802_11_ADD_IMME_BA:
4237 DBGPRINT(RT_DEBUG_TRACE, (" Set :: RT_OID_802_11_ADD_IMME_BA \n"));
4238 if (wrq->u.data.length != sizeof(OID_ADD_BA_ENTRY))
4243 OID_ADD_BA_ENTRY BA;
4244 MAC_TABLE_ENTRY *pEntry;
4246 Status = copy_from_user(&BA, wrq->u.data.pointer, wrq->u.data.length);
4249 Status = NDIS_STATUS_INVALID_DATA;
4254 //BATableInsertEntry
4255 //As ad-hoc mode, BA pair is not limited to only BSSID. so add via OID.
4257 // in ad hoc mode, when adding BA pair, we should insert this entry into MACEntry too
4258 pEntry = MacTableLookup(pAd, BA.MACAddr);
4261 DBGPRINT(RT_DEBUG_TRACE, ("RT_OID_802_11_ADD_IMME_BA. break on no connection.----:%x:%x\n", BA.MACAddr[4], BA.MACAddr[5]));
4264 if (BA.IsRecipient == FALSE)
4266 if (pEntry->bIAmBadAtheros == TRUE)
4267 pAd->CommonCfg.BACapability.field.RxBAWinLimit = 0x10;
4269 BAOriSessionSetUp(pAd, pEntry, index, 0, 100, TRUE);
4273 //BATableInsertEntry(pAd, pEntry->Aid, BA.MACAddr, 0, 0xffff, BA.TID, BA.nMSDU, BA.IsRecipient);
4276 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_ADD_IMME_BA. Rec = %d. Mac = %x:%x:%x:%x:%x:%x . \n",
4277 BA.IsRecipient, BA.MACAddr[0], BA.MACAddr[1], BA.MACAddr[2], BA.MACAddr[2]
4278 , BA.MACAddr[4], BA.MACAddr[5]));
4283 case RT_OID_802_11_TEAR_IMME_BA:
4284 DBGPRINT(RT_DEBUG_TRACE, ("Set :: RT_OID_802_11_TEAR_IMME_BA \n"));
4285 if (wrq->u.data.length != sizeof(OID_ADD_BA_ENTRY))
4289 POID_ADD_BA_ENTRY pBA;
4290 MAC_TABLE_ENTRY *pEntry;
4292 pBA = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
4296 DBGPRINT(RT_DEBUG_TRACE, ("Set :: RT_OID_802_11_TEAR_IMME_BA kmalloc() can't allocate enough memory\n"));
4297 Status = NDIS_STATUS_FAILURE;
4301 Status = copy_from_user(pBA, wrq->u.data.pointer, wrq->u.data.length);
4302 DBGPRINT(RT_DEBUG_TRACE, ("Set :: RT_OID_802_11_TEAR_IMME_BA(TID=%d, bAllTid=%d)\n", pBA->TID, pBA->bAllTid));
4304 if (!pBA->bAllTid && (pBA->TID > NUM_OF_TID))
4306 Status = NDIS_STATUS_INVALID_DATA;
4310 if (pBA->IsRecipient == FALSE)
4312 pEntry = MacTableLookup(pAd, pBA->MACAddr);
4313 DBGPRINT(RT_DEBUG_TRACE, (" pBA->IsRecipient == FALSE\n"));
4316 DBGPRINT(RT_DEBUG_TRACE, (" pBA->pEntry\n"));
4317 BAOriSessionTearDown(pAd, pEntry->Aid, pBA->TID, FALSE, TRUE);
4320 DBGPRINT(RT_DEBUG_TRACE, ("Set :: Not found pEntry \n"));
4324 pEntry = MacTableLookup(pAd, pBA->MACAddr);
4327 BARecSessionTearDown( pAd, (UCHAR)pEntry->Aid, pBA->TID, TRUE);
4330 DBGPRINT(RT_DEBUG_TRACE, ("Set :: Not found pEntry \n"));
4336 #endif // DOT11_N_SUPPORT //
4338 // For WPA_SUPPLICANT to set static wep key
4339 case OID_802_11_ADD_WEP:
4340 pWepKey = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
4345 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_WEP, Failed!!\n"));
4348 Status = copy_from_user(pWepKey, wrq->u.data.pointer, wrq->u.data.length);
4352 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_WEP, Failed (length mismatch)!!\n"));
4356 KeyIdx = pWepKey->KeyIndex & 0x0fffffff;
4357 // KeyIdx must be 0 ~ 3
4361 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_WEP, Failed (KeyIdx must be smaller than 4)!!\n"));
4365 UCHAR CipherAlg = 0;
4368 // set key material and key length
4369 NdisZeroMemory(pAd->SharedKey[BSS0][KeyIdx].Key, 16);
4370 pAd->SharedKey[BSS0][KeyIdx].KeyLen = (UCHAR) pWepKey->KeyLength;
4371 NdisMoveMemory(pAd->SharedKey[BSS0][KeyIdx].Key, &pWepKey->KeyMaterial, pWepKey->KeyLength);
4373 switch(pWepKey->KeyLength)
4376 CipherAlg = CIPHER_WEP64;
4379 CipherAlg = CIPHER_WEP128;
4382 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_WEP, only support CIPHER_WEP64(len:5) & CIPHER_WEP128(len:13)!!\n"));
4386 pAd->SharedKey[BSS0][KeyIdx].CipherAlg = CipherAlg;
4388 // Default key for tx (shared key)
4389 if (pWepKey->KeyIndex & 0x80000000)
4391 #ifdef WPA_SUPPLICANT_SUPPORT
4392 // set key material and key length
4393 NdisZeroMemory(pAd->StaCfg.DesireSharedKey[KeyIdx].Key, 16);
4394 pAd->StaCfg.DesireSharedKey[KeyIdx].KeyLen = (UCHAR) pWepKey->KeyLength;
4395 NdisMoveMemory(pAd->StaCfg.DesireSharedKey[KeyIdx].Key, &pWepKey->KeyMaterial, pWepKey->KeyLength);
4396 pAd->StaCfg.DesireSharedKeyId = KeyIdx;
4397 pAd->StaCfg.DesireSharedKey[KeyIdx].CipherAlg = CipherAlg;
4398 #endif // WPA_SUPPLICANT_SUPPORT //
4399 pAd->StaCfg.DefaultKeyId = (UCHAR) KeyIdx;
4402 #ifdef WPA_SUPPLICANT_SUPPORT
4403 if ((pAd->StaCfg.WpaSupplicantUP != WPA_SUPPLICANT_DISABLE) &&
4404 (pAd->StaCfg.AuthMode >= Ndis802_11AuthModeWPA))
4406 Key = pWepKey->KeyMaterial;
4408 // Set Group key material to Asic
4409 AsicAddSharedKeyEntry(pAd, BSS0, KeyIdx, CipherAlg, Key, NULL, NULL);
4411 // Update WCID attribute table and IVEIV table for this group key table
4412 RTMPAddWcidAttributeEntry(pAd, BSS0, KeyIdx, CipherAlg, NULL);
4414 STA_PORT_SECURED(pAd);
4416 // Indicate Connected for GUI
4417 pAd->IndicateMediaState = NdisMediaStateConnected;
4419 else if (pAd->StaCfg.PortSecured == WPA_802_1X_PORT_SECURED)
4420 #endif // WPA_SUPPLICANT_SUPPORT
4422 Key = pAd->SharedKey[BSS0][KeyIdx].Key;
4424 // Set key material and cipherAlg to Asic
4425 AsicAddSharedKeyEntry(pAd, BSS0, KeyIdx, CipherAlg, Key, NULL, NULL);
4427 if (pWepKey->KeyIndex & 0x80000000)
4429 PMAC_TABLE_ENTRY pEntry = &pAd->MacTab.Content[BSSID_WCID];
4430 // Assign group key info
4431 RTMPAddWcidAttributeEntry(pAd, BSS0, KeyIdx, CipherAlg, NULL);
4432 // Assign pairwise key info
4433 RTMPAddWcidAttributeEntry(pAd, BSS0, KeyIdx, CipherAlg, pEntry);
4436 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_WEP (id=0x%x, Len=%d-byte), %s\n", pWepKey->KeyIndex, pWepKey->KeyLength, (pAd->StaCfg.PortSecured == WPA_802_1X_PORT_SECURED) ? "Port Secured":"Port NOT Secured"));
4441 #ifdef WPA_SUPPLICANT_SUPPORT
4442 case OID_SET_COUNTERMEASURES:
4443 if (wrq->u.data.length != sizeof(int))
4448 Status = copy_from_user(&enabled, wrq->u.data.pointer, wrq->u.data.length);
4450 pAd->StaCfg.bBlockAssoc = TRUE;
4452 // WPA MIC error should block association attempt for 60 seconds
4453 pAd->StaCfg.bBlockAssoc = FALSE;
4454 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_SET_COUNTERMEASURES bBlockAssoc=%s\n", pAd->StaCfg.bBlockAssoc ? "TRUE":"FALSE"));
4457 case RT_OID_WPA_SUPPLICANT_SUPPORT:
4458 if (wrq->u.data.length != sizeof(UCHAR))
4462 Status = copy_from_user(&wpa_supplicant_enable, wrq->u.data.pointer, wrq->u.data.length);
4463 pAd->StaCfg.WpaSupplicantUP = wpa_supplicant_enable;
4464 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_WPA_SUPPLICANT_SUPPORT (=%d)\n", pAd->StaCfg.WpaSupplicantUP));
4467 case OID_802_11_DEAUTHENTICATION:
4468 if (wrq->u.data.length != sizeof(MLME_DEAUTH_REQ_STRUCT))
4472 MLME_DEAUTH_REQ_STRUCT *pInfo;
4473 MLME_QUEUE_ELEM *MsgElem = (MLME_QUEUE_ELEM *) kmalloc(sizeof(MLME_QUEUE_ELEM), MEM_ALLOC_FLAG);
4474 if (MsgElem == NULL)
4476 DBGPRINT(RT_DEBUG_ERROR, ("%s():alloc memory failed!\n", __FUNCTION__));
4480 pInfo = (MLME_DEAUTH_REQ_STRUCT *) MsgElem->Msg;
4481 Status = copy_from_user(pInfo, wrq->u.data.pointer, wrq->u.data.length);
4482 MlmeDeauthReqAction(pAd, MsgElem);
4487 LinkDown(pAd, FALSE);
4488 pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
4490 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_DEAUTHENTICATION (Reason=%d)\n", pInfo->Reason));
4493 case OID_802_11_DROP_UNENCRYPTED:
4494 if (wrq->u.data.length != sizeof(int))
4499 Status = copy_from_user(&enabled, wrq->u.data.pointer, wrq->u.data.length);
4501 pAd->StaCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED;
4503 pAd->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
4504 NdisAcquireSpinLock(&pAd->MacTabLock);
4505 pAd->MacTab.Content[BSSID_WCID].PortSecured = pAd->StaCfg.PortSecured;
4506 NdisReleaseSpinLock(&pAd->MacTabLock);
4507 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_DROP_UNENCRYPTED (=%d)\n", enabled));
4510 case OID_802_11_SET_IEEE8021X:
4511 if (wrq->u.data.length != sizeof(BOOLEAN))
4515 Status = copy_from_user(&IEEE8021xState, wrq->u.data.pointer, wrq->u.data.length);
4516 pAd->StaCfg.IEEE8021X = IEEE8021xState;
4517 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_SET_IEEE8021X (=%d)\n", IEEE8021xState));
4520 case OID_802_11_SET_IEEE8021X_REQUIRE_KEY:
4521 if (wrq->u.data.length != sizeof(BOOLEAN))
4525 Status = copy_from_user(&IEEE8021x_required_keys, wrq->u.data.pointer, wrq->u.data.length);
4526 pAd->StaCfg.IEEE8021x_required_keys = IEEE8021x_required_keys;
4527 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_SET_IEEE8021X_REQUIRE_KEY (%d)\n", IEEE8021x_required_keys));
4530 case OID_802_11_PMKID:
4531 pPmkId = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
4533 if(pPmkId == NULL) {
4537 Status = copy_from_user(pPmkId, wrq->u.data.pointer, wrq->u.data.length);
4539 // check the PMKID information
4540 if (pPmkId->BSSIDInfoCount == 0)
4541 NdisZeroMemory(pAd->StaCfg.SavedPMK, sizeof(BSSID_INFO)*PMKID_NO);
4544 PBSSID_INFO pBssIdInfo;
4548 for (BssIdx = 0; BssIdx < pPmkId->BSSIDInfoCount; BssIdx++)
4550 // point to the indexed BSSID_INFO structure
4551 pBssIdInfo = (PBSSID_INFO) ((PUCHAR) pPmkId + 2 * sizeof(UINT) + BssIdx * sizeof(BSSID_INFO));
4552 // Find the entry in the saved data base.
4553 for (CachedIdx = 0; CachedIdx < pAd->StaCfg.SavedPMKNum; CachedIdx++)
4555 // compare the BSSID
4556 if (NdisEqualMemory(pBssIdInfo->BSSID, pAd->StaCfg.SavedPMK[CachedIdx].BSSID, sizeof(NDIS_802_11_MAC_ADDRESS)))
4560 // Found, replace it
4561 if (CachedIdx < PMKID_NO)
4563 DBGPRINT(RT_DEBUG_OFF, ("Update OID_802_11_PMKID, idx = %d\n", CachedIdx));
4564 NdisMoveMemory(&pAd->StaCfg.SavedPMK[CachedIdx], pBssIdInfo, sizeof(BSSID_INFO));
4565 pAd->StaCfg.SavedPMKNum++;
4567 // Not found, replace the last one
4570 // Randomly replace one
4571 CachedIdx = (pBssIdInfo->BSSID[5] % PMKID_NO);
4572 DBGPRINT(RT_DEBUG_OFF, ("Update OID_802_11_PMKID, idx = %d\n", CachedIdx));
4573 NdisMoveMemory(&pAd->StaCfg.SavedPMK[CachedIdx], pBssIdInfo, sizeof(BSSID_INFO));
4580 #endif // WPA_SUPPLICANT_SUPPORT //
4585 case OID_802_11_SHORTRETRYLIMIT:
4586 if (wrq->u.data.length != sizeof(ULONG))
4590 Status = copy_from_user(&ShortRetryLimit, wrq->u.data.pointer, wrq->u.data.length);
4591 RTMP_IO_READ32(pAd, TX_RTY_CFG, &tx_rty_cfg.word);
4592 tx_rty_cfg.field.ShortRtyLimit = ShortRetryLimit;
4593 RTMP_IO_WRITE32(pAd, TX_RTY_CFG, tx_rty_cfg.word);
4594 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_SHORTRETRYLIMIT (tx_rty_cfg.field.ShortRetryLimit=%d, ShortRetryLimit=%ld)\n", tx_rty_cfg.field.ShortRtyLimit, ShortRetryLimit));
4598 case OID_802_11_LONGRETRYLIMIT:
4599 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_LONGRETRYLIMIT \n"));
4600 if (wrq->u.data.length != sizeof(ULONG))
4604 Status = copy_from_user(&LongRetryLimit, wrq->u.data.pointer, wrq->u.data.length);
4605 RTMP_IO_READ32(pAd, TX_RTY_CFG, &tx_rty_cfg.word);
4606 tx_rty_cfg.field.LongRtyLimit = LongRetryLimit;
4607 RTMP_IO_WRITE32(pAd, TX_RTY_CFG, tx_rty_cfg.word);
4608 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_LONGRETRYLIMIT (tx_rty_cfg.field.LongRetryLimit= %d,LongRetryLimit=%ld)\n", tx_rty_cfg.field.LongRtyLimit, LongRetryLimit));
4612 case OID_802_11_WEPDEFAULTKEYVALUE:
4613 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_WEPDEFAULTKEYVALUE\n"));
4614 pKey = kmalloc(wrq->u.data.length, GFP_KERNEL);
4615 Status = copy_from_user(pKey, wrq->u.data.pointer, wrq->u.data.length);
4618 if ( pKey->Length != wrq->u.data.length)
4621 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_WEPDEFAULTKEYVALUE, Failed!!\n"));
4623 KeyIdx = pKey->KeyIndex & 0x0fffffff;
4624 DBGPRINT(RT_DEBUG_TRACE,("pKey->KeyIndex =%d, pKey->KeyLength=%d\n", pKey->KeyIndex, pKey->KeyLength));
4626 // it is a shared key
4631 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].KeyLen = (UCHAR) pKey->KeyLength;
4632 NdisMoveMemory(&pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].Key, &pKey->KeyMaterial, pKey->KeyLength);
4633 if (pKey->KeyIndex & 0x80000000)
4635 // Default key for tx (shared key)
4636 pAd->StaCfg.DefaultKeyId = (UCHAR) KeyIdx;
4638 //RestartAPIsRequired = TRUE;
4643 case OID_802_11_WEPDEFAULTKEYID:
4644 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_WEPDEFAULTKEYID \n"));
4646 if (wrq->u.data.length != sizeof(UCHAR))
4649 Status = copy_from_user(&pAd->StaCfg.DefaultKeyId, wrq->u.data.pointer, wrq->u.data.length);
4654 case OID_802_11_CURRENTCHANNEL:
4655 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_CURRENTCHANNEL \n"));
4656 if (wrq->u.data.length != sizeof(UCHAR))
4660 Status = copy_from_user(&ctmp, wrq->u.data.pointer, wrq->u.data.length);
4661 sprintf((PSTRING)&ctmp,"%d", ctmp);
4662 Set_Channel_Proc(pAd, (PSTRING)&ctmp);
4669 case RT_OID_802_11_SET_PSPXLINK_MODE:
4670 if (wrq->u.data.length != sizeof(BOOLEAN))
4674 Status = copy_from_user(&pAd->CommonCfg.PSPXlink, wrq->u.data.pointer, wrq->u.data.length);
4675 /*if (pAd->CommonCfg.PSPXlink)
4676 RX_FILTER_SET_FLAG(pAd, fRX_FILTER_ACCEPT_PROMISCUOUS)*/
4677 DBGPRINT(RT_DEBUG_TRACE,("Set::RT_OID_802_11_SET_PSPXLINK_MODE(=%d) \n", pAd->CommonCfg.PSPXlink));
4683 DBGPRINT(RT_DEBUG_TRACE, ("Set::unknown IOCTL's subcmd = 0x%08x\n", cmd));
4684 Status = -EOPNOTSUPP;
4692 INT RTMPQueryInformation(
4693 IN PRTMP_ADAPTER pAd,
4694 IN OUT struct ifreq *rq,
4697 struct iwreq *wrq = (struct iwreq *) rq;
4698 NDIS_802_11_BSSID_LIST_EX *pBssidList = NULL;
4699 PNDIS_WLAN_BSSID_EX pBss;
4700 NDIS_802_11_SSID Ssid;
4701 NDIS_802_11_CONFIGURATION *pConfiguration = NULL;
4702 RT_802_11_LINK_STATUS *pLinkStatus = NULL;
4703 RT_802_11_STA_CONFIG *pStaConfig = NULL;
4704 NDIS_802_11_STATISTICS *pStatistics = NULL;
4705 NDIS_802_11_RTS_THRESHOLD RtsThresh;
4706 NDIS_802_11_FRAGMENTATION_THRESHOLD FragThresh;
4707 NDIS_802_11_POWER_MODE PowerMode;
4708 NDIS_802_11_NETWORK_INFRASTRUCTURE BssType;
4709 RT_802_11_PREAMBLE PreamType;
4710 NDIS_802_11_AUTHENTICATION_MODE AuthMode;
4711 NDIS_802_11_WEP_STATUS WepStatus;
4712 NDIS_MEDIA_STATE MediaState;
4713 ULONG BssBufSize, ulInfo=0, NetworkTypeList[4], apsd = 0;
4715 PUCHAR pBuf = NULL, pPtr;
4716 INT Status = NDIS_STATUS_SUCCESS;
4717 UINT we_version_compiled;
4718 UCHAR i, Padding = 0;
4720 STRING driverVersion[8];
4721 OID_SET_HT_PHYMODE *pHTPhyMode = NULL;
4726 DefaultKeyIdxValue *pKeyIdxValue;
4728 TX_RTY_CFG_STRUC tx_rty_cfg;
4729 ULONG ShortRetryLimit, LongRetryLimit;
4735 case RT_OID_DEVICE_NAME:
4736 wrq->u.data.length = sizeof(pAd->nickname);
4737 Status = copy_to_user(wrq->u.data.pointer, pAd->nickname, wrq->u.data.length);
4739 case RT_OID_VERSION_INFO:
4740 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_VERSION_INFO \n"));
4741 wrq->u.data.length = 8*sizeof(CHAR);
4742 sprintf(&driverVersion[0], "%s", STA_DRIVER_VERSION);
4743 driverVersion[7] = '\0';
4744 if (copy_to_user(wrq->u.data.pointer, &driverVersion[0], wrq->u.data.length))
4750 case OID_802_11_BSSID_LIST:
4751 if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
4754 * Still scanning, indicate the caller should try again.
4756 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_BSSID_LIST (Still scanning)\n"));
4759 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_BSSID_LIST (%d BSS returned)\n",pAd->ScanTab.BssNr));
4760 pAd->StaCfg.bScanReqIsFromWebUI = FALSE;
4761 // Claculate total buffer size required
4762 BssBufSize = sizeof(ULONG);
4764 for (i = 0; i < pAd->ScanTab.BssNr; i++)
4766 // Align pointer to 4 bytes boundary.
4767 //Padding = 4 - (pAdapter->ScanTab.BssEntry[i].VarIELen & 0x0003);
4770 BssBufSize += (sizeof(NDIS_WLAN_BSSID_EX) - 1 + sizeof(NDIS_802_11_FIXED_IEs) + pAd->ScanTab.BssEntry[i].VarIELen + Padding);
4773 // For safety issue, we add 256 bytes just in case
4775 // Allocate the same size as passed from higher layer
4776 pBuf = kmalloc(BssBufSize, MEM_ALLOC_FLAG);
4782 // Init 802_11_BSSID_LIST_EX structure
4783 NdisZeroMemory(pBuf, BssBufSize);
4784 pBssidList = (PNDIS_802_11_BSSID_LIST_EX) pBuf;
4785 pBssidList->NumberOfItems = pAd->ScanTab.BssNr;
4787 // Calculate total buffer length
4788 BssLen = 4; // Consist of NumberOfItems
4789 // Point to start of NDIS_WLAN_BSSID_EX
4790 // pPtr = pBuf + sizeof(ULONG);
4791 pPtr = (PUCHAR) &pBssidList->Bssid[0];
4792 for (i = 0; i < pAd->ScanTab.BssNr; i++)
4794 pBss = (PNDIS_WLAN_BSSID_EX) pPtr;
4795 NdisMoveMemory(&pBss->MacAddress, &pAd->ScanTab.BssEntry[i].Bssid, MAC_ADDR_LEN);
4796 if ((pAd->ScanTab.BssEntry[i].Hidden == 1) && (pAd->StaCfg.bShowHiddenSSID == FALSE))
4799 // We must return this SSID during 4way handshaking, otherwise Aegis will failed to parse WPA infomation
4800 // and then failed to send EAPOl farame.
4802 if ((pAd->StaCfg.AuthMode >= Ndis802_11AuthModeWPA) && (pAd->StaCfg.PortSecured != WPA_802_1X_PORT_SECURED))
4804 pBss->Ssid.SsidLength = pAd->ScanTab.BssEntry[i].SsidLen;
4805 NdisMoveMemory(pBss->Ssid.Ssid, pAd->ScanTab.BssEntry[i].Ssid, pAd->ScanTab.BssEntry[i].SsidLen);
4808 pBss->Ssid.SsidLength = 0;
4812 pBss->Ssid.SsidLength = pAd->ScanTab.BssEntry[i].SsidLen;
4813 NdisMoveMemory(pBss->Ssid.Ssid, pAd->ScanTab.BssEntry[i].Ssid, pAd->ScanTab.BssEntry[i].SsidLen);
4815 pBss->Privacy = pAd->ScanTab.BssEntry[i].Privacy;
4816 pBss->Rssi = pAd->ScanTab.BssEntry[i].Rssi - pAd->BbpRssiToDbmDelta;
4817 pBss->NetworkTypeInUse = NetworkTypeInUseSanity(&pAd->ScanTab.BssEntry[i]);
4818 pBss->Configuration.Length = sizeof(NDIS_802_11_CONFIGURATION);
4819 pBss->Configuration.BeaconPeriod = pAd->ScanTab.BssEntry[i].BeaconPeriod;
4820 pBss->Configuration.ATIMWindow = pAd->ScanTab.BssEntry[i].AtimWin;
4822 MAP_CHANNEL_ID_TO_KHZ(pAd->ScanTab.BssEntry[i].Channel, pBss->Configuration.DSConfig);
4824 if (pAd->ScanTab.BssEntry[i].BssType == BSS_INFRA)
4825 pBss->InfrastructureMode = Ndis802_11Infrastructure;
4827 pBss->InfrastructureMode = Ndis802_11IBSS;
4829 NdisMoveMemory(pBss->SupportedRates, pAd->ScanTab.BssEntry[i].SupRate, pAd->ScanTab.BssEntry[i].SupRateLen);
4830 NdisMoveMemory(pBss->SupportedRates + pAd->ScanTab.BssEntry[i].SupRateLen,
4831 pAd->ScanTab.BssEntry[i].ExtRate,
4832 pAd->ScanTab.BssEntry[i].ExtRateLen);
4834 if (pAd->ScanTab.BssEntry[i].VarIELen == 0)
4836 pBss->IELength = sizeof(NDIS_802_11_FIXED_IEs);
4837 NdisMoveMemory(pBss->IEs, &pAd->ScanTab.BssEntry[i].FixIEs, sizeof(NDIS_802_11_FIXED_IEs));
4838 pPtr = pPtr + sizeof(NDIS_WLAN_BSSID_EX) - 1 + sizeof(NDIS_802_11_FIXED_IEs);
4842 pBss->IELength = (ULONG)(sizeof(NDIS_802_11_FIXED_IEs) + pAd->ScanTab.BssEntry[i].VarIELen);
4843 pPtr = pPtr + sizeof(NDIS_WLAN_BSSID_EX) - 1 + sizeof(NDIS_802_11_FIXED_IEs);
4844 NdisMoveMemory(pBss->IEs, &pAd->ScanTab.BssEntry[i].FixIEs, sizeof(NDIS_802_11_FIXED_IEs));
4845 NdisMoveMemory(pBss->IEs + sizeof(NDIS_802_11_FIXED_IEs), pAd->ScanTab.BssEntry[i].VarIEs, pAd->ScanTab.BssEntry[i].VarIELen);
4846 pPtr += pAd->ScanTab.BssEntry[i].VarIELen;
4848 pBss->Length = (ULONG)(sizeof(NDIS_WLAN_BSSID_EX) - 1 + sizeof(NDIS_802_11_FIXED_IEs) + pAd->ScanTab.BssEntry[i].VarIELen + Padding);
4850 #if WIRELESS_EXT < 17
4851 if ((BssLen + pBss->Length) < wrq->u.data.length)
4852 BssLen += pBss->Length;
4855 pBssidList->NumberOfItems = i;
4859 BssLen += pBss->Length;
4863 #if WIRELESS_EXT < 17
4864 wrq->u.data.length = BssLen;
4866 if (BssLen > wrq->u.data.length)
4872 wrq->u.data.length = BssLen;
4874 Status = copy_to_user(wrq->u.data.pointer, pBssidList, BssLen);
4877 case OID_802_3_CURRENT_ADDRESS:
4878 wrq->u.data.length = MAC_ADDR_LEN;
4879 Status = copy_to_user(wrq->u.data.pointer, &pAd->CurrentAddress, wrq->u.data.length);
4881 case OID_GEN_MEDIA_CONNECT_STATUS:
4882 if (pAd->IndicateMediaState == NdisMediaStateConnected)
4883 MediaState = NdisMediaStateConnected;
4885 MediaState = NdisMediaStateDisconnected;
4887 wrq->u.data.length = sizeof(NDIS_MEDIA_STATE);
4888 Status = copy_to_user(wrq->u.data.pointer, &MediaState, wrq->u.data.length);
4890 case OID_802_11_BSSID:
4891 if (INFRA_ON(pAd) || ADHOC_ON(pAd))
4893 Status = copy_to_user(wrq->u.data.pointer, &pAd->CommonCfg.Bssid, sizeof(NDIS_802_11_MAC_ADDRESS));
4898 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_BSSID(=EMPTY)\n"));
4902 case OID_802_11_SSID:
4903 NdisZeroMemory(&Ssid, sizeof(NDIS_802_11_SSID));
4904 NdisZeroMemory(Ssid.Ssid, MAX_LEN_OF_SSID);
4905 Ssid.SsidLength = pAd->CommonCfg.SsidLen;
4906 memcpy(Ssid.Ssid, pAd->CommonCfg.Ssid, Ssid.SsidLength);
4907 wrq->u.data.length = sizeof(NDIS_802_11_SSID);
4908 Status = copy_to_user(wrq->u.data.pointer, &Ssid, wrq->u.data.length);
4909 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_SSID (Len=%d, ssid=%s)\n", Ssid.SsidLength,Ssid.Ssid));
4911 case RT_OID_802_11_QUERY_LINK_STATUS:
4912 pLinkStatus = (RT_802_11_LINK_STATUS *) kmalloc(sizeof(RT_802_11_LINK_STATUS), MEM_ALLOC_FLAG);
4915 pLinkStatus->CurrTxRate = RateIdTo500Kbps[pAd->CommonCfg.TxRate]; // unit : 500 kbps
4916 pLinkStatus->ChannelQuality = pAd->Mlme.ChannelQuality;
4917 pLinkStatus->RxByteCount = pAd->RalinkCounters.ReceivedByteCount;
4918 pLinkStatus->TxByteCount = pAd->RalinkCounters.TransmittedByteCount;
4919 pLinkStatus->CentralChannel = pAd->CommonCfg.CentralChannel;
4920 wrq->u.data.length = sizeof(RT_802_11_LINK_STATUS);
4921 Status = copy_to_user(wrq->u.data.pointer, pLinkStatus, wrq->u.data.length);
4923 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_LINK_STATUS\n"));
4927 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_LINK_STATUS(kmalloc failed)\n"));
4931 case OID_802_11_CONFIGURATION:
4932 pConfiguration = (NDIS_802_11_CONFIGURATION *) kmalloc(sizeof(NDIS_802_11_CONFIGURATION), MEM_ALLOC_FLAG);
4935 pConfiguration->Length = sizeof(NDIS_802_11_CONFIGURATION);
4936 pConfiguration->BeaconPeriod = pAd->CommonCfg.BeaconPeriod;
4937 pConfiguration->ATIMWindow = pAd->StaActive.AtimWin;
4938 MAP_CHANNEL_ID_TO_KHZ(pAd->CommonCfg.Channel, pConfiguration->DSConfig);
4939 wrq->u.data.length = sizeof(NDIS_802_11_CONFIGURATION);
4940 Status = copy_to_user(wrq->u.data.pointer, pConfiguration, wrq->u.data.length);
4941 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_CONFIGURATION(BeaconPeriod=%ld,AtimW=%ld,Channel=%d) \n",
4942 pConfiguration->BeaconPeriod, pConfiguration->ATIMWindow, pAd->CommonCfg.Channel));
4943 kfree(pConfiguration);
4947 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_CONFIGURATION(kmalloc failed)\n"));
4951 case RT_OID_802_11_SNR_0:
4952 if ((pAd->StaCfg.LastSNR0 > 0))
4954 ulInfo = ((0xeb - pAd->StaCfg.LastSNR0) * 3) / 16 ;
4955 wrq->u.data.length = sizeof(ulInfo);
4956 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4957 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_SNR_0(0x=%lx)\n", ulInfo));
4962 case RT_OID_802_11_SNR_1:
4963 if ((pAd->Antenna.field.RxPath > 1) &&
4964 (pAd->StaCfg.LastSNR1 > 0))
4966 ulInfo = ((0xeb - pAd->StaCfg.LastSNR1) * 3) / 16 ;
4967 wrq->u.data.length = sizeof(ulInfo);
4968 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4969 DBGPRINT(RT_DEBUG_TRACE,("Query::RT_OID_802_11_SNR_1(0x=%lx)\n",ulInfo));
4973 DBGPRINT(RT_DEBUG_TRACE,("Query::RT_OID_802_11_SNR_1(pAd->StaCfg.LastSNR1=%d)\n",pAd->StaCfg.LastSNR1));
4975 case OID_802_11_RSSI_TRIGGER:
4976 ulInfo = pAd->StaCfg.RssiSample.LastRssi0 - pAd->BbpRssiToDbmDelta;
4977 wrq->u.data.length = sizeof(ulInfo);
4978 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4979 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_RSSI_TRIGGER(=%ld)\n", ulInfo));
4981 case OID_802_11_RSSI:
4982 case RT_OID_802_11_RSSI:
4983 ulInfo = pAd->StaCfg.RssiSample.LastRssi0;
4984 wrq->u.data.length = sizeof(ulInfo);
4985 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4987 case RT_OID_802_11_RSSI_1:
4988 ulInfo = pAd->StaCfg.RssiSample.LastRssi1;
4989 wrq->u.data.length = sizeof(ulInfo);
4990 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4992 case RT_OID_802_11_RSSI_2:
4993 ulInfo = pAd->StaCfg.RssiSample.LastRssi2;
4994 wrq->u.data.length = sizeof(ulInfo);
4995 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4997 case OID_802_11_STATISTICS:
4998 pStatistics = (NDIS_802_11_STATISTICS *) kmalloc(sizeof(NDIS_802_11_STATISTICS), MEM_ALLOC_FLAG);
5001 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_STATISTICS \n"));
5002 // add the most up-to-date h/w raw counters into software counters
5003 NICUpdateRawCounters(pAd);
5005 // Sanity check for calculation of sucessful count
5006 if (pAd->WlanCounters.TransmittedFragmentCount.QuadPart < pAd->WlanCounters.RetryCount.QuadPart)
5007 pAd->WlanCounters.TransmittedFragmentCount.QuadPart = pAd->WlanCounters.RetryCount.QuadPart;
5009 pStatistics->TransmittedFragmentCount.QuadPart = pAd->WlanCounters.TransmittedFragmentCount.QuadPart;
5010 pStatistics->MulticastTransmittedFrameCount.QuadPart = pAd->WlanCounters.MulticastTransmittedFrameCount.QuadPart;
5011 pStatistics->FailedCount.QuadPart = pAd->WlanCounters.FailedCount.QuadPart;
5012 pStatistics->RetryCount.QuadPart = pAd->WlanCounters.RetryCount.QuadPart;
5013 pStatistics->MultipleRetryCount.QuadPart = pAd->WlanCounters.MultipleRetryCount.QuadPart;
5014 pStatistics->RTSSuccessCount.QuadPart = pAd->WlanCounters.RTSSuccessCount.QuadPart;
5015 pStatistics->RTSFailureCount.QuadPart = pAd->WlanCounters.RTSFailureCount.QuadPart;
5016 pStatistics->ACKFailureCount.QuadPart = pAd->WlanCounters.ACKFailureCount.QuadPart;
5017 pStatistics->FrameDuplicateCount.QuadPart = pAd->WlanCounters.FrameDuplicateCount.QuadPart;
5018 pStatistics->ReceivedFragmentCount.QuadPart = pAd->WlanCounters.ReceivedFragmentCount.QuadPart;
5019 pStatistics->MulticastReceivedFrameCount.QuadPart = pAd->WlanCounters.MulticastReceivedFrameCount.QuadPart;
5021 pStatistics->FCSErrorCount = pAd->RalinkCounters.RealFcsErrCount;
5023 pStatistics->FCSErrorCount.QuadPart = pAd->WlanCounters.FCSErrorCount.QuadPart;
5024 pStatistics->FrameDuplicateCount.u.LowPart = pAd->WlanCounters.FrameDuplicateCount.u.LowPart / 100;
5026 wrq->u.data.length = sizeof(NDIS_802_11_STATISTICS);
5027 Status = copy_to_user(wrq->u.data.pointer, pStatistics, wrq->u.data.length);
5032 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_STATISTICS(kmalloc failed)\n"));
5036 case OID_GEN_RCV_OK:
5037 ulInfo = pAd->Counters8023.GoodReceives;
5038 wrq->u.data.length = sizeof(ulInfo);
5039 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
5041 case OID_GEN_RCV_NO_BUFFER:
5042 ulInfo = pAd->Counters8023.RxNoBuffer;
5043 wrq->u.data.length = sizeof(ulInfo);
5044 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
5046 case RT_OID_802_11_PHY_MODE:
5047 ulInfo = (ULONG)pAd->CommonCfg.PhyMode;
5048 wrq->u.data.length = sizeof(ulInfo);
5049 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
5050 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_PHY_MODE (=%ld)\n", ulInfo));
5052 case RT_OID_802_11_STA_CONFIG:
5053 pStaConfig = (RT_802_11_STA_CONFIG *) kmalloc(sizeof(RT_802_11_STA_CONFIG), MEM_ALLOC_FLAG);
5056 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_STA_CONFIG\n"));
5057 pStaConfig->EnableTxBurst = pAd->CommonCfg.bEnableTxBurst;
5058 pStaConfig->EnableTurboRate = 0;
5059 pStaConfig->UseBGProtection = pAd->CommonCfg.UseBGProtection;
5060 pStaConfig->UseShortSlotTime = pAd->CommonCfg.bUseShortSlotTime;
5061 //pStaConfig->AdhocMode = pAd->StaCfg.AdhocMode;
5062 pStaConfig->HwRadioStatus = (pAd->StaCfg.bHwRadio == TRUE) ? 1 : 0;
5063 pStaConfig->Rsv1 = 0;
5064 pStaConfig->SystemErrorBitmap = pAd->SystemErrorBitmap;
5065 wrq->u.data.length = sizeof(RT_802_11_STA_CONFIG);
5066 Status = copy_to_user(wrq->u.data.pointer, pStaConfig, wrq->u.data.length);
5071 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_STA_CONFIG(kmalloc failed)\n"));
5075 case OID_802_11_RTS_THRESHOLD:
5076 RtsThresh = pAd->CommonCfg.RtsThreshold;
5077 wrq->u.data.length = sizeof(RtsThresh);
5078 Status = copy_to_user(wrq->u.data.pointer, &RtsThresh, wrq->u.data.length);
5079 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_RTS_THRESHOLD(=%ld)\n", RtsThresh));
5081 case OID_802_11_FRAGMENTATION_THRESHOLD:
5082 FragThresh = pAd->CommonCfg.FragmentThreshold;
5083 if (pAd->CommonCfg.bUseZeroToDisableFragment == TRUE)
5085 wrq->u.data.length = sizeof(FragThresh);
5086 Status = copy_to_user(wrq->u.data.pointer, &FragThresh, wrq->u.data.length);
5087 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_FRAGMENTATION_THRESHOLD(=%ld)\n", FragThresh));
5089 case OID_802_11_POWER_MODE:
5090 PowerMode = pAd->StaCfg.WindowsPowerMode;
5091 wrq->u.data.length = sizeof(PowerMode);
5092 Status = copy_to_user(wrq->u.data.pointer, &PowerMode, wrq->u.data.length);
5093 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_POWER_MODE(=%d)\n", PowerMode));
5095 case RT_OID_802_11_RADIO:
5096 RadioState = (BOOLEAN) pAd->StaCfg.bSwRadio;
5097 wrq->u.data.length = sizeof(RadioState);
5098 Status = copy_to_user(wrq->u.data.pointer, &RadioState, wrq->u.data.length);
5099 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_RADIO (=%d)\n", RadioState));
5101 case OID_802_11_INFRASTRUCTURE_MODE:
5102 if (pAd->StaCfg.BssType == BSS_ADHOC)
5103 BssType = Ndis802_11IBSS;
5104 else if (pAd->StaCfg.BssType == BSS_INFRA)
5105 BssType = Ndis802_11Infrastructure;
5106 else if (pAd->StaCfg.BssType == BSS_MONITOR)
5107 BssType = Ndis802_11Monitor;
5109 BssType = Ndis802_11AutoUnknown;
5111 wrq->u.data.length = sizeof(BssType);
5112 Status = copy_to_user(wrq->u.data.pointer, &BssType, wrq->u.data.length);
5113 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_INFRASTRUCTURE_MODE(=%d)\n", BssType));
5115 case RT_OID_802_11_PREAMBLE:
5116 PreamType = pAd->CommonCfg.TxPreamble;
5117 wrq->u.data.length = sizeof(PreamType);
5118 Status = copy_to_user(wrq->u.data.pointer, &PreamType, wrq->u.data.length);
5119 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_PREAMBLE(=%d)\n", PreamType));
5121 case OID_802_11_AUTHENTICATION_MODE:
5122 AuthMode = pAd->StaCfg.AuthMode;
5123 wrq->u.data.length = sizeof(AuthMode);
5124 Status = copy_to_user(wrq->u.data.pointer, &AuthMode, wrq->u.data.length);
5125 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_AUTHENTICATION_MODE(=%d)\n", AuthMode));
5127 case OID_802_11_WEP_STATUS:
5128 WepStatus = pAd->StaCfg.WepStatus;
5129 wrq->u.data.length = sizeof(WepStatus);
5130 Status = copy_to_user(wrq->u.data.pointer, &WepStatus, wrq->u.data.length);
5131 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_WEP_STATUS(=%d)\n", WepStatus));
5133 case OID_802_11_TX_POWER_LEVEL:
5134 wrq->u.data.length = sizeof(ULONG);
5135 Status = copy_to_user(wrq->u.data.pointer, &pAd->CommonCfg.TxPower, wrq->u.data.length);
5136 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_TX_POWER_LEVEL %x\n",pAd->CommonCfg.TxPower));
5138 case RT_OID_802_11_TX_POWER_LEVEL_1:
5139 wrq->u.data.length = sizeof(ULONG);
5140 Status = copy_to_user(wrq->u.data.pointer, &pAd->CommonCfg.TxPowerPercentage, wrq->u.data.length);
5141 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_TX_POWER_LEVEL_1 (=%ld)\n", pAd->CommonCfg.TxPowerPercentage));
5143 case OID_802_11_NETWORK_TYPES_SUPPORTED:
5144 if ((pAd->RfIcType == RFIC_2850) || (pAd->RfIcType == RFIC_2750) || (pAd->RfIcType == RFIC_3052))
5146 NetworkTypeList[0] = 3; // NumberOfItems = 3
5147 NetworkTypeList[1] = Ndis802_11DS; // NetworkType[1] = 11b
5148 NetworkTypeList[2] = Ndis802_11OFDM24; // NetworkType[2] = 11g
5149 NetworkTypeList[3] = Ndis802_11OFDM5; // NetworkType[3] = 11a
5150 wrq->u.data.length = 16;
5151 Status = copy_to_user(wrq->u.data.pointer, &NetworkTypeList[0], wrq->u.data.length);
5155 NetworkTypeList[0] = 2; // NumberOfItems = 2
5156 NetworkTypeList[1] = Ndis802_11DS; // NetworkType[1] = 11b
5157 NetworkTypeList[2] = Ndis802_11OFDM24; // NetworkType[2] = 11g
5158 wrq->u.data.length = 12;
5159 Status = copy_to_user(wrq->u.data.pointer, &NetworkTypeList[0], wrq->u.data.length);
5161 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_NETWORK_TYPES_SUPPORTED\n"));
5163 case OID_802_11_NETWORK_TYPE_IN_USE:
5164 wrq->u.data.length = sizeof(ULONG);
5165 if (pAd->CommonCfg.PhyMode == PHY_11A)
5166 ulInfo = Ndis802_11OFDM5;
5167 else if ((pAd->CommonCfg.PhyMode == PHY_11BG_MIXED) || (pAd->CommonCfg.PhyMode == PHY_11G))
5168 ulInfo = Ndis802_11OFDM24;
5170 ulInfo = Ndis802_11DS;
5171 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
5173 case RT_OID_802_11_QUERY_LAST_RX_RATE:
5174 ulInfo = (ULONG)pAd->LastRxRate;
5175 wrq->u.data.length = sizeof(ulInfo);
5176 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
5177 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_LAST_RX_RATE (=%ld)\n", ulInfo));
5179 case RT_OID_802_11_QUERY_LAST_TX_RATE:
5180 //ulInfo = (ULONG)pAd->LastTxRate;
5181 ulInfo = (ULONG)pAd->MacTab.Content[BSSID_WCID].HTPhyMode.word;
5182 wrq->u.data.length = sizeof(ulInfo);
5183 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
5184 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_LAST_TX_RATE (=%lx)\n", ulInfo));
5186 case RT_OID_802_11_QUERY_EEPROM_VERSION:
5187 wrq->u.data.length = sizeof(ULONG);
5188 Status = copy_to_user(wrq->u.data.pointer, &pAd->EepromVersion, wrq->u.data.length);
5190 case RT_OID_802_11_QUERY_FIRMWARE_VERSION:
5191 wrq->u.data.length = sizeof(ULONG);
5192 Status = copy_to_user(wrq->u.data.pointer, &pAd->FirmwareVersion, wrq->u.data.length);
5194 case RT_OID_802_11_QUERY_NOISE_LEVEL:
5195 wrq->u.data.length = sizeof(UCHAR);
5196 Status = copy_to_user(wrq->u.data.pointer, &pAd->BbpWriteLatch[66], wrq->u.data.length);
5197 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_NOISE_LEVEL (=%d)\n", pAd->BbpWriteLatch[66]));
5199 case RT_OID_802_11_EXTRA_INFO:
5200 wrq->u.data.length = sizeof(ULONG);
5201 Status = copy_to_user(wrq->u.data.pointer, &pAd->ExtraInfo, wrq->u.data.length);
5202 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_EXTRA_INFO (=%ld)\n", pAd->ExtraInfo));
5204 case RT_OID_WE_VERSION_COMPILED:
5205 wrq->u.data.length = sizeof(UINT);
5206 we_version_compiled = WIRELESS_EXT;
5207 Status = copy_to_user(wrq->u.data.pointer, &we_version_compiled, wrq->u.data.length);
5209 case RT_OID_802_11_QUERY_APSD_SETTING:
5210 apsd = (pAd->CommonCfg.bAPSDCapable | (pAd->CommonCfg.bAPSDAC_BE << 1) | (pAd->CommonCfg.bAPSDAC_BK << 2)
5211 | (pAd->CommonCfg.bAPSDAC_VI << 3) | (pAd->CommonCfg.bAPSDAC_VO << 4) | (pAd->CommonCfg.MaxSPLength << 5));
5213 wrq->u.data.length = sizeof(ULONG);
5214 Status = copy_to_user(wrq->u.data.pointer, &apsd, wrq->u.data.length);
5215 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",
5216 apsd,pAd->CommonCfg.bAPSDCapable,pAd->CommonCfg.bAPSDAC_BE,pAd->CommonCfg.bAPSDAC_BK,pAd->CommonCfg.bAPSDAC_VI,pAd->CommonCfg.bAPSDAC_VO,pAd->CommonCfg.MaxSPLength));
5218 case RT_OID_802_11_QUERY_APSD_PSM:
5219 wrq->u.data.length = sizeof(ULONG);
5220 Status = copy_to_user(wrq->u.data.pointer, &pAd->CommonCfg.bAPSDForcePowerSave, wrq->u.data.length);
5221 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_APSD_PSM (=%d)\n", pAd->CommonCfg.bAPSDForcePowerSave));
5223 case RT_OID_802_11_QUERY_WMM:
5224 wrq->u.data.length = sizeof(BOOLEAN);
5225 Status = copy_to_user(wrq->u.data.pointer, &pAd->CommonCfg.bWmmCapable, wrq->u.data.length);
5226 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_WMM (=%d)\n", pAd->CommonCfg.bWmmCapable));
5228 #ifdef WPA_SUPPLICANT_SUPPORT
5229 case RT_OID_NEW_DRIVER:
5232 wrq->u.data.length = sizeof(UCHAR);
5233 Status = copy_to_user(wrq->u.data.pointer, &enabled, wrq->u.data.length);
5234 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_NEW_DRIVER (=%d)\n", enabled));
5237 case RT_OID_WPA_SUPPLICANT_SUPPORT:
5238 wrq->u.data.length = sizeof(UCHAR);
5239 Status = copy_to_user(wrq->u.data.pointer, &pAd->StaCfg.WpaSupplicantUP, wrq->u.data.length);
5240 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_WPA_SUPPLICANT_SUPPORT (=%d)\n", pAd->StaCfg.WpaSupplicantUP));
5242 #endif // WPA_SUPPLICANT_SUPPORT //
5244 case RT_OID_DRIVER_DEVICE_NAME:
5245 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_DRIVER_DEVICE_NAME \n"));
5246 wrq->u.data.length = 16;
5247 if (copy_to_user(wrq->u.data.pointer, pAd->StaCfg.dev_name, wrq->u.data.length))
5252 case RT_OID_802_11_QUERY_HT_PHYMODE:
5253 pHTPhyMode = (OID_SET_HT_PHYMODE *) kmalloc(sizeof(OID_SET_HT_PHYMODE), MEM_ALLOC_FLAG);
5256 pHTPhyMode->PhyMode = pAd->CommonCfg.PhyMode;
5257 pHTPhyMode->HtMode = (UCHAR)pAd->MacTab.Content[BSSID_WCID].HTPhyMode.field.MODE;
5258 pHTPhyMode->BW = (UCHAR)pAd->MacTab.Content[BSSID_WCID].HTPhyMode.field.BW;
5259 pHTPhyMode->MCS= (UCHAR)pAd->MacTab.Content[BSSID_WCID].HTPhyMode.field.MCS;
5260 pHTPhyMode->SHORTGI= (UCHAR)pAd->MacTab.Content[BSSID_WCID].HTPhyMode.field.ShortGI;
5261 pHTPhyMode->STBC= (UCHAR)pAd->MacTab.Content[BSSID_WCID].HTPhyMode.field.STBC;
5263 pHTPhyMode->ExtOffset = ((pAd->CommonCfg.CentralChannel < pAd->CommonCfg.Channel) ? (EXTCHA_BELOW) : (EXTCHA_ABOVE));
5264 wrq->u.data.length = sizeof(OID_SET_HT_PHYMODE);
5265 if (copy_to_user(wrq->u.data.pointer, pHTPhyMode, wrq->u.data.length))
5269 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_HT_PHYMODE (PhyMode = %d, MCS =%d, BW = %d, STBC = %d, ExtOffset=%d)\n",
5270 pHTPhyMode->HtMode, pHTPhyMode->MCS, pHTPhyMode->BW, pHTPhyMode->STBC, pHTPhyMode->ExtOffset));
5271 DBGPRINT(RT_DEBUG_TRACE, (" MlmeUpdateTxRates (.word = %x )\n", pAd->MacTab.Content[BSSID_WCID].HTPhyMode.word));
5275 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_STA_CONFIG(kmalloc failed)\n"));
5279 case RT_OID_802_11_COUNTRY_REGION:
5280 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_COUNTRY_REGION \n"));
5281 wrq->u.data.length = sizeof(ulInfo);
5282 ulInfo = pAd->CommonCfg.CountryRegionForABand;
5283 ulInfo = (ulInfo << 8)|(pAd->CommonCfg.CountryRegion);
5284 if (copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length))
5289 case RT_OID_802_11_QUERY_DAT_HT_PHYMODE:
5290 pHTPhyMode = (OID_SET_HT_PHYMODE *) kmalloc(sizeof(OID_SET_HT_PHYMODE), MEM_ALLOC_FLAG);
5293 pHTPhyMode->PhyMode = pAd->CommonCfg.PhyMode;
5294 pHTPhyMode->HtMode = (UCHAR)pAd->CommonCfg.RegTransmitSetting.field.HTMODE;
5295 pHTPhyMode->BW = (UCHAR)pAd->CommonCfg.RegTransmitSetting.field.BW;
5296 pHTPhyMode->MCS= (UCHAR)pAd->StaCfg.DesiredTransmitSetting.field.MCS;
5297 pHTPhyMode->SHORTGI= (UCHAR)pAd->CommonCfg.RegTransmitSetting.field.ShortGI;
5298 pHTPhyMode->STBC= (UCHAR)pAd->CommonCfg.RegTransmitSetting.field.STBC;
5300 wrq->u.data.length = sizeof(OID_SET_HT_PHYMODE);
5301 if (copy_to_user(wrq->u.data.pointer, pHTPhyMode, wrq->u.data.length))
5305 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_HT_PHYMODE (PhyMode = %d, MCS =%d, BW = %d, STBC = %d, ExtOffset=%d)\n",
5306 pHTPhyMode->HtMode, pHTPhyMode->MCS, pHTPhyMode->BW, pHTPhyMode->STBC, pHTPhyMode->ExtOffset));
5307 DBGPRINT(RT_DEBUG_TRACE, (" MlmeUpdateTxRates (.word = %x )\n", pAd->MacTab.Content[BSSID_WCID].HTPhyMode.word));
5311 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_STA_CONFIG(kmalloc failed)\n"));
5315 case RT_OID_QUERY_MULTIPLE_CARD_SUPPORT:
5316 wrq->u.data.length = sizeof(UCHAR);
5318 #ifdef MULTIPLE_CARD_SUPPORT
5320 #endif // MULTIPLE_CARD_SUPPORT //
5321 if (copy_to_user(wrq->u.data.pointer, &i, wrq->u.data.length))
5325 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_QUERY_MULTIPLE_CARD_SUPPORT(=%d) \n", i));
5328 case RT_OID_802_11_MAC_ADDRESS:
5329 wrq->u.data.length = MAC_ADDR_LEN;
5330 Status = copy_to_user(wrq->u.data.pointer, &pAd->CurrentAddress, wrq->u.data.length);
5333 case RT_OID_802_11_MANUFACTUREROUI:
5334 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_MANUFACTUREROUI \n"));
5335 wrq->u.data.length = ManufacturerOUI_LEN;
5336 Status = copy_to_user(wrq->u.data.pointer, &pAd->CurrentAddress, wrq->u.data.length);
5339 case RT_OID_802_11_MANUFACTURERNAME:
5340 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_MANUFACTURERNAME \n"));
5341 wrq->u.data.length = strlen(ManufacturerNAME);
5342 Status = copy_to_user(wrq->u.data.pointer, ManufacturerNAME, wrq->u.data.length);
5345 case RT_OID_802_11_RESOURCETYPEIDNAME:
5346 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_RESOURCETYPEIDNAME \n"));
5347 wrq->u.data.length = strlen(ResourceTypeIdName);
5348 Status = copy_to_user(wrq->u.data.pointer, ResourceTypeIdName, wrq->u.data.length);
5351 case RT_OID_802_11_PRIVACYOPTIONIMPLEMENTED:
5352 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_PRIVACYOPTIONIMPLEMENTED \n"));
5353 ulInfo = 1; // 1 is support wep else 2 is not support.
5354 wrq->u.data.length = sizeof(ulInfo);
5355 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
5358 case RT_OID_802_11_POWERMANAGEMENTMODE:
5359 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_POWERMANAGEMENTMODE \n"));
5360 if (pAd->StaCfg.Psm == PSMP_ACTION)
5361 ulInfo = 1; // 1 is power active else 2 is power save.
5365 wrq->u.data.length = sizeof(ulInfo);
5366 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
5369 case OID_802_11_WEPDEFAULTKEYVALUE:
5370 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_WEPDEFAULTKEYVALUE \n"));
5371 //KeyIdxValue.KeyIdx = pAd->PortCfg.MBSSID[pAd->IoctlIF].DefaultKeyId;
5372 pKeyIdxValue = wrq->u.data.pointer;
5373 DBGPRINT(RT_DEBUG_TRACE,("KeyIdxValue.KeyIdx = %d, \n",pKeyIdxValue->KeyIdx));
5374 valueLen = pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].KeyLen;
5375 NdisMoveMemory(pKeyIdxValue->Value,
5376 &pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].Key,
5378 pKeyIdxValue->Value[valueLen]='\0';
5380 wrq->u.data.length = sizeof(DefaultKeyIdxValue);
5382 Status = copy_to_user(wrq->u.data.pointer, pKeyIdxValue, wrq->u.data.length);
5383 DBGPRINT(RT_DEBUG_TRACE,("DefaultKeyId = %d, total len = %d, str len=%d, KeyValue= %02x %02x %02x %02x \n",
5384 pAd->StaCfg.DefaultKeyId,
5386 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].KeyLen,
5387 pAd->SharedKey[BSS0][0].Key[0],
5388 pAd->SharedKey[BSS0][1].Key[0],
5389 pAd->SharedKey[BSS0][2].Key[0],
5390 pAd->SharedKey[BSS0][3].Key[0]));
5393 case OID_802_11_WEPDEFAULTKEYID:
5394 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_WEPDEFAULTKEYID \n"));
5395 wrq->u.data.length = sizeof(UCHAR);
5396 Status = copy_to_user(wrq->u.data.pointer, &pAd->StaCfg.DefaultKeyId, wrq->u.data.length);
5397 DBGPRINT(RT_DEBUG_TRACE, ("DefaultKeyId =%d \n", pAd->StaCfg.DefaultKeyId));
5400 case RT_OID_802_11_WEPKEYMAPPINGLENGTH:
5401 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_WEPKEYMAPPINGLENGTH \n"));
5402 wrq->u.data.length = sizeof(UCHAR);
5403 Status = copy_to_user(wrq->u.data.pointer,
5404 &pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].KeyLen,
5405 wrq->u.data.length);
5408 case OID_802_11_SHORTRETRYLIMIT:
5409 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_SHORTRETRYLIMIT \n"));
5410 wrq->u.data.length = sizeof(ULONG);
5411 RTMP_IO_READ32(pAd, TX_RTY_CFG, &tx_rty_cfg.word);
5412 ShortRetryLimit = tx_rty_cfg.field.ShortRtyLimit;
5413 DBGPRINT(RT_DEBUG_TRACE, ("ShortRetryLimit =%ld, tx_rty_cfg.field.ShortRetryLimit=%d\n", ShortRetryLimit, tx_rty_cfg.field.ShortRtyLimit));
5414 Status = copy_to_user(wrq->u.data.pointer, &ShortRetryLimit, wrq->u.data.length);
5417 case OID_802_11_LONGRETRYLIMIT:
5418 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_LONGRETRYLIMIT \n"));
5419 wrq->u.data.length = sizeof(ULONG);
5420 RTMP_IO_READ32(pAd, TX_RTY_CFG, &tx_rty_cfg.word);
5421 LongRetryLimit = tx_rty_cfg.field.LongRtyLimit;
5422 DBGPRINT(RT_DEBUG_TRACE, ("LongRetryLimit =%ld, tx_rty_cfg.field.LongRtyLimit=%d\n", LongRetryLimit, tx_rty_cfg.field.LongRtyLimit));
5423 Status = copy_to_user(wrq->u.data.pointer, &LongRetryLimit, wrq->u.data.length);
5426 case RT_OID_802_11_PRODUCTID:
5427 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_PRODUCTID \n"));
5433 if (((POS_COOKIE)pAd->OS_Cookie)->pci_dev != NULL)
5434 pci_read_config_word(((POS_COOKIE)pAd->OS_Cookie)->pci_dev, PCI_DEVICE_ID, &device_id);
5436 DBGPRINT(RT_DEBUG_TRACE, (" pci_dev = NULL\n"));
5437 sprintf((PSTRING)tmp, "%04x %04x\n", NIC_PCI_VENDOR_ID, device_id);
5439 #endif // RTMP_MAC_PCI //
5440 wrq->u.data.length = strlen((PSTRING)tmp);
5441 Status = copy_to_user(wrq->u.data.pointer, tmp, wrq->u.data.length);
5444 case RT_OID_802_11_MANUFACTUREID:
5445 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_MANUFACTUREID \n"));
5446 wrq->u.data.length = strlen(ManufacturerNAME);
5447 Status = copy_to_user(wrq->u.data.pointer, ManufacturerNAME, wrq->u.data.length);
5450 case OID_802_11_CURRENTCHANNEL:
5451 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_CURRENTCHANNEL \n"));
5452 wrq->u.data.length = sizeof(UCHAR);
5453 DBGPRINT(RT_DEBUG_TRACE, ("sizeof UCHAR=%d, channel=%d \n", sizeof(UCHAR), pAd->CommonCfg.Channel));
5454 Status = copy_to_user(wrq->u.data.pointer, &pAd->CommonCfg.Channel, wrq->u.data.length);
5455 DBGPRINT(RT_DEBUG_TRACE, ("Status=%d\n", Status));
5457 #endif //SNMP_SUPPORT
5459 case OID_802_11_BUILD_CHANNEL_EX:
5462 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_BUILD_CHANNEL_EX \n"));
5463 wrq->u.data.length = sizeof(UCHAR);
5464 #ifdef EXT_BUILD_CHANNEL_LIST
5465 DBGPRINT(RT_DEBUG_TRACE, ("Support EXT_BUILD_CHANNEL_LIST.\n"));
5468 DBGPRINT(RT_DEBUG_TRACE, ("Doesn't support EXT_BUILD_CHANNEL_LIST.\n"));
5470 #endif // EXT_BUILD_CHANNEL_LIST //
5471 Status = copy_to_user(wrq->u.data.pointer, &value, 1);
5472 DBGPRINT(RT_DEBUG_TRACE, ("Status=%d\n", Status));
5476 case OID_802_11_GET_CH_LIST:
5478 PRT_CHANNEL_LIST_INFO pChListBuf;
5480 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_GET_CH_LIST \n"));
5481 if (pAd->ChannelListNum == 0)
5483 wrq->u.data.length = 0;
5487 pChListBuf = (RT_CHANNEL_LIST_INFO *) kmalloc(sizeof(RT_CHANNEL_LIST_INFO), MEM_ALLOC_FLAG);
5488 if (pChListBuf == NULL)
5490 wrq->u.data.length = 0;
5494 pChListBuf->ChannelListNum = pAd->ChannelListNum;
5495 for (i = 0; i < pChListBuf->ChannelListNum; i++)
5496 pChListBuf->ChannelList[i] = pAd->ChannelList[i].Channel;
5498 wrq->u.data.length = sizeof(RT_CHANNEL_LIST_INFO);
5499 Status = copy_to_user(wrq->u.data.pointer, pChListBuf, sizeof(RT_CHANNEL_LIST_INFO));
5500 DBGPRINT(RT_DEBUG_TRACE, ("Status=%d\n", Status));
5507 case OID_802_11_GET_COUNTRY_CODE:
5508 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_GET_COUNTRY_CODE \n"));
5509 wrq->u.data.length = 2;
5510 Status = copy_to_user(wrq->u.data.pointer, &pAd->CommonCfg.CountryCode, 2);
5511 DBGPRINT(RT_DEBUG_TRACE, ("Status=%d\n", Status));
5514 case OID_802_11_GET_CHANNEL_GEOGRAPHY:
5515 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_GET_CHANNEL_GEOGRAPHY \n"));
5516 wrq->u.data.length = 1;
5517 Status = copy_to_user(wrq->u.data.pointer, &pAd->CommonCfg.Geography, 1);
5518 DBGPRINT(RT_DEBUG_TRACE, ("Status=%d\n", Status));
5522 #ifdef QOS_DLS_SUPPORT
5523 case RT_OID_802_11_QUERY_DLS:
5524 wrq->u.data.length = sizeof(BOOLEAN);
5525 Status = copy_to_user(wrq->u.data.pointer, &pAd->CommonCfg.bDLSCapable, wrq->u.data.length);
5526 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_DLS(=%d)\n", pAd->CommonCfg.bDLSCapable));
5529 case RT_OID_802_11_QUERY_DLS_PARAM:
5531 PRT_802_11_DLS_INFO pDlsInfo = kmalloc(sizeof(RT_802_11_DLS_INFO), GFP_ATOMIC);
5532 if (pDlsInfo == NULL)
5535 for (i=0; i<MAX_NUM_OF_DLS_ENTRY; i++)
5537 RTMPMoveMemory(&pDlsInfo->Entry[i], &pAd->StaCfg.DLSEntry[i], sizeof(RT_802_11_DLS_UI));
5540 pDlsInfo->num = MAX_NUM_OF_DLS_ENTRY;
5541 wrq->u.data.length = sizeof(RT_802_11_DLS_INFO);
5542 Status = copy_to_user(wrq->u.data.pointer, pDlsInfo, wrq->u.data.length);
5543 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_DLS_PARAM\n"));
5549 #endif // QOS_DLS_SUPPORT //
5551 case OID_802_11_SET_PSPXLINK_MODE:
5552 wrq->u.data.length = sizeof(BOOLEAN);
5553 Status = copy_to_user(wrq->u.data.pointer, &pAd->CommonCfg.PSPXlink, wrq->u.data.length);
5554 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_SET_PSPXLINK_MODE(=%d)\n", pAd->CommonCfg.PSPXlink));
5559 DBGPRINT(RT_DEBUG_TRACE, ("Query::unknown IOCTL's subcmd = 0x%08x\n", cmd));
5560 Status = -EOPNOTSUPP;
5566 INT rt28xx_sta_ioctl(
5567 IN struct net_device *net_dev,
5568 IN OUT struct ifreq *rq,
5572 RTMP_ADAPTER *pAd = NULL;
5573 struct iwreq *wrq = (struct iwreq *) rq;
5574 BOOLEAN StateMachineTouched = FALSE;
5575 INT Status = NDIS_STATUS_SUCCESS;
5579 pAd = RTMP_OS_NETDEV_GET_PRIV(net_dev);
5582 /* if 1st open fail, pAd will be free;
5583 So the net_dev->priv will be NULL in 2rd open */
5586 pObj = (POS_COOKIE) pAd->OS_Cookie;
5588 //check if the interface is down
5589 if(!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_IN_USE))
5591 #ifdef CONFIG_APSTA_MIXED_SUPPORT
5592 if (wrq->u.data.pointer == NULL)
5597 if (strstr(wrq->u.data.pointer, "OpMode") == NULL)
5598 #endif // CONFIG_APSTA_MIXED_SUPPORT //
5600 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
5605 { // determine this ioctl command is comming from which interface.
5606 pObj->ioctl_if_type = INT_MAIN;
5607 pObj->ioctl_if = MAIN_MBSSID;
5613 #ifdef RALINK_28xx_QA
5614 case RTPRIV_IOCTL_ATE:
5616 RtmpDoAte(pAd, wrq);
5619 #endif // RALINK_28xx_QA //
5620 #endif // RALINK_ATE //
5622 DBGPRINT(RT_DEBUG_TRACE, ("IOCTL::SIOCGIFHWADDR\n"));
5623 memcpy(wrq->u.name, pAd->CurrentAddress, ETH_ALEN);
5627 char *name=&wrq->u.name[0];
5628 rt_ioctl_giwname(net_dev, NULL, name, NULL);
5631 case SIOCGIWESSID: //Get ESSID
5633 struct iw_point *essid=&wrq->u.essid;
5634 rt_ioctl_giwessid(net_dev, NULL, essid, essid->pointer);
5637 case SIOCSIWESSID: //Set ESSID
5639 struct iw_point *essid=&wrq->u.essid;
5640 rt_ioctl_siwessid(net_dev, NULL, essid, essid->pointer);
5643 case SIOCSIWNWID: // set network id (the cell)
5644 case SIOCGIWNWID: // get network id
5645 Status = -EOPNOTSUPP;
5647 case SIOCSIWFREQ: //set channel/frequency (Hz)
5649 struct iw_freq *freq=&wrq->u.freq;
5650 rt_ioctl_siwfreq(net_dev, NULL, freq, NULL);
5653 case SIOCGIWFREQ: // get channel/frequency (Hz)
5655 struct iw_freq *freq=&wrq->u.freq;
5656 rt_ioctl_giwfreq(net_dev, NULL, freq, NULL);
5659 case SIOCSIWNICKN: //set node name/nickname
5661 //struct iw_point *data=&wrq->u.data;
5662 //rt_ioctl_siwnickn(net_dev, NULL, data, NULL);
5665 case SIOCGIWNICKN: //get node name/nickname
5667 struct iw_point *erq = NULL;
5669 erq->length = strlen((PSTRING) pAd->nickname);
5670 Status = copy_to_user(erq->pointer, pAd->nickname, erq->length);
5673 case SIOCGIWRATE: //get default bit rate (bps)
5674 rt_ioctl_giwrate(net_dev, NULL, &wrq->u, NULL);
5676 case SIOCSIWRATE: //set default bit rate (bps)
5677 rt_ioctl_siwrate(net_dev, NULL, &wrq->u, NULL);
5679 case SIOCGIWRTS: // get RTS/CTS threshold (bytes)
5681 struct iw_param *rts=&wrq->u.rts;
5682 rt_ioctl_giwrts(net_dev, NULL, rts, NULL);
5685 case SIOCSIWRTS: //set RTS/CTS threshold (bytes)
5687 struct iw_param *rts=&wrq->u.rts;
5688 rt_ioctl_siwrts(net_dev, NULL, rts, NULL);
5691 case SIOCGIWFRAG: //get fragmentation thr (bytes)
5693 struct iw_param *frag=&wrq->u.frag;
5694 rt_ioctl_giwfrag(net_dev, NULL, frag, NULL);
5697 case SIOCSIWFRAG: //set fragmentation thr (bytes)
5699 struct iw_param *frag=&wrq->u.frag;
5700 rt_ioctl_siwfrag(net_dev, NULL, frag, NULL);
5703 case SIOCGIWENCODE: //get encoding token & mode
5705 struct iw_point *erq=&wrq->u.encoding;
5707 rt_ioctl_giwencode(net_dev, NULL, erq, erq->pointer);
5710 case SIOCSIWENCODE: //set encoding token & mode
5712 struct iw_point *erq=&wrq->u.encoding;
5714 rt_ioctl_siwencode(net_dev, NULL, erq, erq->pointer);
5717 case SIOCGIWAP: //get access point MAC addresses
5719 struct sockaddr *ap_addr=&wrq->u.ap_addr;
5720 rt_ioctl_giwap(net_dev, NULL, ap_addr, ap_addr->sa_data);
5723 case SIOCSIWAP: //set access point MAC addresses
5725 struct sockaddr *ap_addr=&wrq->u.ap_addr;
5726 rt_ioctl_siwap(net_dev, NULL, ap_addr, ap_addr->sa_data);
5729 case SIOCGIWMODE: //get operation mode
5731 __u32 *mode=&wrq->u.mode;
5732 rt_ioctl_giwmode(net_dev, NULL, mode, NULL);
5735 case SIOCSIWMODE: //set operation mode
5737 __u32 *mode=&wrq->u.mode;
5738 rt_ioctl_siwmode(net_dev, NULL, mode, NULL);
5741 case SIOCGIWSENS: //get sensitivity (dBm)
5742 case SIOCSIWSENS: //set sensitivity (dBm)
5743 case SIOCGIWPOWER: //get Power Management settings
5744 case SIOCSIWPOWER: //set Power Management settings
5745 case SIOCGIWTXPOW: //get transmit power (dBm)
5746 case SIOCSIWTXPOW: //set transmit power (dBm)
5747 case SIOCGIWRANGE: //Get range of parameters
5748 case SIOCGIWRETRY: //get retry limits and lifetime
5749 case SIOCSIWRETRY: //set retry limits and lifetime
5750 Status = -EOPNOTSUPP;
5753 case RT_PRIV_IOCTL_EXT:
5754 subcmd = wrq->u.data.flags;
5755 if( subcmd & OID_GET_SET_TOGGLE)
5756 Status = RTMPSetInformation(pAd, rq, subcmd);
5758 Status = RTMPQueryInformation(pAd, rq, subcmd);
5761 if (wrq->u.data.pointer)
5763 if ( access_ok(VERIFY_WRITE, wrq->u.data.pointer, sizeof(privtab)) != TRUE)
5765 wrq->u.data.length = sizeof(privtab) / sizeof(privtab[0]);
5766 if (copy_to_user(wrq->u.data.pointer, privtab, sizeof(privtab)))
5770 case RTPRIV_IOCTL_SET:
5771 if(access_ok(VERIFY_READ, wrq->u.data.pointer, wrq->u.data.length) != TRUE)
5773 rt_ioctl_setparam(net_dev, NULL, NULL, wrq->u.data.pointer);
5775 case RTPRIV_IOCTL_GSITESURVEY:
5776 RTMPIoctlGetSiteSurvey(pAd, wrq);
5779 case RTPRIV_IOCTL_MAC:
5780 RTMPIoctlMAC(pAd, wrq);
5782 case RTPRIV_IOCTL_E2P:
5783 RTMPIoctlE2PROM(pAd, wrq);
5785 #ifdef RTMP_RF_RW_SUPPORT
5786 case RTPRIV_IOCTL_RF:
5787 RTMPIoctlRF(pAd, wrq);
5789 #endif // RTMP_RF_RW_SUPPORT //
5795 DBGPRINT(RT_DEBUG_ERROR, ("IOCTL::unknown IOCTL's cmd = 0x%08x\n", cmd));
5796 Status = -EOPNOTSUPP;
5800 if(StateMachineTouched) // Upper layer sent a MLME-related operations
5801 RTMP_MLME_HANDLER(pAd);
5807 ==========================================================================
5811 TRUE if all parameters are OK, FALSE otherwise
5812 ==========================================================================
5815 IN PRTMP_ADAPTER pAdapter,
5818 NDIS_802_11_SSID Ssid, *pSsid=NULL;
5819 BOOLEAN StateMachineTouched = FALSE;
5822 if( strlen(arg) <= MAX_LEN_OF_SSID)
5824 NdisZeroMemory(&Ssid, sizeof(NDIS_802_11_SSID));
5825 if (strlen(arg) != 0)
5827 NdisMoveMemory(Ssid.Ssid, arg, strlen(arg));
5828 Ssid.SsidLength = strlen(arg);
5832 Ssid.SsidLength = 0;
5833 memcpy(Ssid.Ssid, "", 0);
5834 pAdapter->StaCfg.BssType = BSS_INFRA;
5835 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
5836 pAdapter->StaCfg.WepStatus = Ndis802_11EncryptionDisabled;
5840 if (pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE)
5842 RTMP_MLME_RESET_STATE_MACHINE(pAdapter);
5843 DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
5846 if ((pAdapter->StaCfg.WpaPassPhraseLen >= 8) &&
5847 (pAdapter->StaCfg.WpaPassPhraseLen <= 64))
5849 STRING passphrase_str[65] = {0};
5850 UCHAR keyMaterial[40];
5852 RTMPMoveMemory(passphrase_str, pAdapter->StaCfg.WpaPassPhrase, pAdapter->StaCfg.WpaPassPhraseLen);
5853 RTMPZeroMemory(pAdapter->StaCfg.PMK, 32);
5854 if (pAdapter->StaCfg.WpaPassPhraseLen == 64)
5856 AtoH((PSTRING) pAdapter->StaCfg.WpaPassPhrase, pAdapter->StaCfg.PMK, 32);
5860 PasswordHash((PSTRING) pAdapter->StaCfg.WpaPassPhrase, Ssid.Ssid, Ssid.SsidLength, keyMaterial);
5861 NdisMoveMemory(pAdapter->StaCfg.PMK, keyMaterial, 32);
5865 pAdapter->MlmeAux.CurrReqIsFromNdis = TRUE;
5866 pAdapter->StaCfg.bScanReqIsFromWebUI = FALSE;
5867 pAdapter->bConfigChanged = TRUE;
5869 MlmeEnqueue(pAdapter,
5870 MLME_CNTL_STATE_MACHINE,
5872 sizeof(NDIS_802_11_SSID),
5875 StateMachineTouched = TRUE;
5876 DBGPRINT(RT_DEBUG_TRACE, ("Set_SSID_Proc::(Len=%d,Ssid=%s)\n", Ssid.SsidLength, Ssid.Ssid));
5881 if (StateMachineTouched) // Upper layer sent a MLME-related operations
5882 RTMP_MLME_HANDLER(pAdapter);
5889 ==========================================================================
5891 Set WmmCapable Enable or Disable
5893 TRUE if all parameters are OK, FALSE otherwise
5894 ==========================================================================
5896 INT Set_WmmCapable_Proc(
5897 IN PRTMP_ADAPTER pAd,
5900 BOOLEAN bWmmCapable;
5902 bWmmCapable = simple_strtol(arg, 0, 10);
5904 if ((bWmmCapable == 1)
5906 pAd->CommonCfg.bWmmCapable = TRUE;
5907 else if (bWmmCapable == 0)
5908 pAd->CommonCfg.bWmmCapable = FALSE;
5910 return FALSE; //Invalid argument
5912 DBGPRINT(RT_DEBUG_TRACE, ("Set_WmmCapable_Proc::(bWmmCapable=%d)\n",
5913 pAd->CommonCfg.bWmmCapable));
5917 #endif // WMM_SUPPORT //
5920 ==========================================================================
5922 Set Network Type(Infrastructure/Adhoc mode)
5924 TRUE if all parameters are OK, FALSE otherwise
5925 ==========================================================================
5927 INT Set_NetworkType_Proc(
5928 IN PRTMP_ADAPTER pAdapter,
5933 if (strcmp(arg, "Adhoc") == 0)
5935 if (pAdapter->StaCfg.BssType != BSS_ADHOC)
5937 // Config has changed
5938 pAdapter->bConfigChanged = TRUE;
5939 if (MONITOR_ON(pAdapter))
5941 RTMP_IO_WRITE32(pAdapter, RX_FILTR_CFG, STANORMAL);
5942 RTMP_IO_READ32(pAdapter, MAC_SYS_CTRL, &Value);
5944 RTMP_IO_WRITE32(pAdapter, MAC_SYS_CTRL, Value);
5945 OPSTATUS_CLEAR_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED);
5946 pAdapter->StaCfg.bAutoReconnect = TRUE;
5947 LinkDown(pAdapter, FALSE);
5949 if (INFRA_ON(pAdapter))
5951 //BOOLEAN Cancelled;
5952 // Set the AutoReconnectSsid to prevent it reconnect to old SSID
5953 // Since calling this indicate user don't want to connect to that SSID anymore.
5954 pAdapter->MlmeAux.AutoReconnectSsidLen= 32;
5955 NdisZeroMemory(pAdapter->MlmeAux.AutoReconnectSsid, pAdapter->MlmeAux.AutoReconnectSsidLen);
5957 LinkDown(pAdapter, FALSE);
5959 DBGPRINT(RT_DEBUG_TRACE, ("NDIS_STATUS_MEDIA_DISCONNECT Event BB!\n"));
5962 pAdapter->StaCfg.BssType = BSS_ADHOC;
5963 pAdapter->net_dev->type = pAdapter->StaCfg.OriDevType;
5964 DBGPRINT(RT_DEBUG_TRACE, ("===>Set_NetworkType_Proc::(AD-HOC)\n"));
5966 else if (strcmp(arg, "Infra") == 0)
5968 if (pAdapter->StaCfg.BssType != BSS_INFRA)
5970 // Config has changed
5971 pAdapter->bConfigChanged = TRUE;
5972 if (MONITOR_ON(pAdapter))
5974 RTMP_IO_WRITE32(pAdapter, RX_FILTR_CFG, STANORMAL);
5975 RTMP_IO_READ32(pAdapter, MAC_SYS_CTRL, &Value);
5977 RTMP_IO_WRITE32(pAdapter, MAC_SYS_CTRL, Value);
5978 OPSTATUS_CLEAR_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED);
5979 pAdapter->StaCfg.bAutoReconnect = TRUE;
5980 LinkDown(pAdapter, FALSE);
5982 if (ADHOC_ON(pAdapter))
5984 // Set the AutoReconnectSsid to prevent it reconnect to old SSID
5985 // Since calling this indicate user don't want to connect to that SSID anymore.
5986 pAdapter->MlmeAux.AutoReconnectSsidLen= 32;
5987 NdisZeroMemory(pAdapter->MlmeAux.AutoReconnectSsid, pAdapter->MlmeAux.AutoReconnectSsidLen);
5989 LinkDown(pAdapter, FALSE);
5992 pAdapter->StaCfg.BssType = BSS_INFRA;
5993 pAdapter->net_dev->type = pAdapter->StaCfg.OriDevType;
5994 DBGPRINT(RT_DEBUG_TRACE, ("===>Set_NetworkType_Proc::(INFRA)\n"));
5996 else if (strcmp(arg, "Monitor") == 0)
5999 BCN_TIME_CFG_STRUC csr;
6000 OPSTATUS_CLEAR_FLAG(pAdapter, fOP_STATUS_INFRA_ON);
6001 OPSTATUS_CLEAR_FLAG(pAdapter, fOP_STATUS_ADHOC_ON);
6002 OPSTATUS_SET_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED);
6003 // disable all periodic state machine
6004 pAdapter->StaCfg.bAutoReconnect = FALSE;
6005 // reset all mlme state machine
6006 RTMP_MLME_RESET_STATE_MACHINE(pAdapter);
6007 DBGPRINT(RT_DEBUG_TRACE, ("fOP_STATUS_MEDIA_STATE_CONNECTED \n"));
6008 if (pAdapter->CommonCfg.CentralChannel == 0)
6010 #ifdef DOT11_N_SUPPORT
6011 if (pAdapter->CommonCfg.PhyMode == PHY_11AN_MIXED)
6012 pAdapter->CommonCfg.CentralChannel = 36;
6014 #endif // DOT11_N_SUPPORT //
6015 pAdapter->CommonCfg.CentralChannel = 6;
6017 #ifdef DOT11_N_SUPPORT
6019 N_ChannelCheck(pAdapter);
6020 #endif // DOT11_N_SUPPORT //
6022 #ifdef DOT11_N_SUPPORT
6023 if (pAdapter->CommonCfg.PhyMode >= PHY_11ABGN_MIXED &&
6024 pAdapter->CommonCfg.RegTransmitSetting.field.BW == BW_40 &&
6025 pAdapter->CommonCfg.RegTransmitSetting.field.EXTCHA == EXTCHA_ABOVE)
6027 // 40MHz ,control channel at lower
6028 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, BBP_R4, &bbpValue);
6029 bbpValue &= (~0x18);
6031 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R4, bbpValue);
6032 pAdapter->CommonCfg.BBPCurrentBW = BW_40;
6033 // RX : control channel at lower
6034 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, BBP_R3, &bbpValue);
6035 bbpValue &= (~0x20);
6036 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R3, bbpValue);
6038 RTMP_IO_READ32(pAdapter, TX_BAND_CFG, &Value);
6039 Value &= 0xfffffffe;
6040 RTMP_IO_WRITE32(pAdapter, TX_BAND_CFG, Value);
6041 pAdapter->CommonCfg.CentralChannel = pAdapter->CommonCfg.Channel + 2;
6042 AsicSwitchChannel(pAdapter, pAdapter->CommonCfg.CentralChannel, FALSE);
6043 AsicLockChannel(pAdapter, pAdapter->CommonCfg.CentralChannel);
6044 DBGPRINT(RT_DEBUG_TRACE, ("BW_40 ,control_channel(%d), CentralChannel(%d) \n",
6045 pAdapter->CommonCfg.Channel,
6046 pAdapter->CommonCfg.CentralChannel));
6048 else if (pAdapter->CommonCfg.PhyMode >= PHY_11ABGN_MIXED &&
6049 pAdapter->CommonCfg.RegTransmitSetting.field.BW == BW_40 &&
6050 pAdapter->CommonCfg.RegTransmitSetting.field.EXTCHA == EXTCHA_BELOW)
6052 // 40MHz ,control channel at upper
6053 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, BBP_R4, &bbpValue);
6054 bbpValue &= (~0x18);
6056 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R4, bbpValue);
6057 pAdapter->CommonCfg.BBPCurrentBW = BW_40;
6058 RTMP_IO_READ32(pAdapter, TX_BAND_CFG, &Value);
6060 RTMP_IO_WRITE32(pAdapter, TX_BAND_CFG, Value);
6062 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, BBP_R3, &bbpValue);
6064 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R3, bbpValue);
6065 pAdapter->CommonCfg.CentralChannel = pAdapter->CommonCfg.Channel - 2;
6066 AsicSwitchChannel(pAdapter, pAdapter->CommonCfg.CentralChannel, FALSE);
6067 AsicLockChannel(pAdapter, pAdapter->CommonCfg.CentralChannel);
6068 DBGPRINT(RT_DEBUG_TRACE, ("BW_40 ,control_channel(%d), CentralChannel(%d) \n",
6069 pAdapter->CommonCfg.Channel,
6070 pAdapter->CommonCfg.CentralChannel));
6073 #endif // DOT11_N_SUPPORT //
6076 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, BBP_R4, &bbpValue);
6077 bbpValue &= (~0x18);
6078 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R4, bbpValue);
6079 pAdapter->CommonCfg.BBPCurrentBW = BW_20;
6080 AsicSwitchChannel(pAdapter, pAdapter->CommonCfg.Channel, FALSE);
6081 AsicLockChannel(pAdapter, pAdapter->CommonCfg.Channel);
6082 DBGPRINT(RT_DEBUG_TRACE, ("BW_20, Channel(%d)\n", pAdapter->CommonCfg.Channel));
6084 // Enable Rx with promiscuous reception
6085 RTMP_IO_WRITE32(pAdapter, RX_FILTR_CFG, 0x3);
6086 // ASIC supporsts sniffer function with replacing RSSI with timestamp.
6087 //RTMP_IO_READ32(pAdapter, MAC_SYS_CTRL, &Value);
6089 //RTMP_IO_WRITE32(pAdapter, MAC_SYS_CTRL, Value);
6091 RTMP_IO_READ32(pAdapter, BCN_TIME_CFG, &csr.word);
6092 csr.field.bBeaconGen = 0;
6093 csr.field.bTBTTEnable = 0;
6094 csr.field.TsfSyncMode = 0;
6095 RTMP_IO_WRITE32(pAdapter, BCN_TIME_CFG, csr.word);
6097 pAdapter->StaCfg.BssType = BSS_MONITOR;
6098 pAdapter->net_dev->type = ARPHRD_IEEE80211_PRISM; //ARPHRD_IEEE80211; // IEEE80211
6099 DBGPRINT(RT_DEBUG_TRACE, ("===>Set_NetworkType_Proc::(MONITOR)\n"));
6102 // Reset Ralink supplicant to not use, it will be set to start when UI set PMK key
6103 pAdapter->StaCfg.WpaState = SS_NOTUSE;
6105 DBGPRINT(RT_DEBUG_TRACE, ("Set_NetworkType_Proc::(NetworkType=%d)\n", pAdapter->StaCfg.BssType));
6111 ==========================================================================
6113 Set Authentication mode
6115 TRUE if all parameters are OK, FALSE otherwise
6116 ==========================================================================
6118 INT Set_AuthMode_Proc(
6119 IN PRTMP_ADAPTER pAdapter,
6122 if ((strcmp(arg, "WEPAUTO") == 0) || (strcmp(arg, "wepauto") == 0))
6123 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeAutoSwitch;
6124 else if ((strcmp(arg, "OPEN") == 0) || (strcmp(arg, "open") == 0))
6125 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
6126 else if ((strcmp(arg, "SHARED") == 0) || (strcmp(arg, "shared") == 0))
6127 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeShared;
6128 else if ((strcmp(arg, "WPAPSK") == 0) || (strcmp(arg, "wpapsk") == 0))
6129 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPAPSK;
6130 else if ((strcmp(arg, "WPANONE") == 0) || (strcmp(arg, "wpanone") == 0))
6131 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPANone;
6132 else if ((strcmp(arg, "WPA2PSK") == 0) || (strcmp(arg, "wpa2psk") == 0))
6133 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA2PSK;
6134 #ifdef WPA_SUPPLICANT_SUPPORT
6135 else if ((strcmp(arg, "WPA") == 0) || (strcmp(arg, "wpa") == 0))
6136 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA;
6137 else if ((strcmp(arg, "WPA2") == 0) || (strcmp(arg, "wpa2") == 0))
6138 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA2;
6139 #endif // WPA_SUPPLICANT_SUPPORT //
6143 pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED;
6145 DBGPRINT(RT_DEBUG_TRACE, ("Set_AuthMode_Proc::(AuthMode=%d)\n", pAdapter->StaCfg.AuthMode));
6151 ==========================================================================
6155 TRUE if all parameters are OK, FALSE otherwise
6156 ==========================================================================
6158 INT Set_EncrypType_Proc(
6159 IN PRTMP_ADAPTER pAdapter,
6162 if ((strcmp(arg, "NONE") == 0) || (strcmp(arg, "none") == 0))
6164 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
6165 return TRUE; // do nothing
6167 pAdapter->StaCfg.WepStatus = Ndis802_11WEPDisabled;
6168 pAdapter->StaCfg.PairCipher = Ndis802_11WEPDisabled;
6169 pAdapter->StaCfg.GroupCipher = Ndis802_11WEPDisabled;
6171 else if ((strcmp(arg, "WEP") == 0) || (strcmp(arg, "wep") == 0))
6173 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
6174 return TRUE; // do nothing
6176 pAdapter->StaCfg.WepStatus = Ndis802_11WEPEnabled;
6177 pAdapter->StaCfg.PairCipher = Ndis802_11WEPEnabled;
6178 pAdapter->StaCfg.GroupCipher = Ndis802_11WEPEnabled;
6180 else if ((strcmp(arg, "TKIP") == 0) || (strcmp(arg, "tkip") == 0))
6182 if (pAdapter->StaCfg.AuthMode < Ndis802_11AuthModeWPA)
6183 return TRUE; // do nothing
6185 pAdapter->StaCfg.WepStatus = Ndis802_11Encryption2Enabled;
6186 pAdapter->StaCfg.PairCipher = Ndis802_11Encryption2Enabled;
6187 pAdapter->StaCfg.GroupCipher = Ndis802_11Encryption2Enabled;
6189 else if ((strcmp(arg, "AES") == 0) || (strcmp(arg, "aes") == 0))
6191 if (pAdapter->StaCfg.AuthMode < Ndis802_11AuthModeWPA)
6192 return TRUE; // do nothing
6194 pAdapter->StaCfg.WepStatus = Ndis802_11Encryption3Enabled;
6195 pAdapter->StaCfg.PairCipher = Ndis802_11Encryption3Enabled;
6196 pAdapter->StaCfg.GroupCipher = Ndis802_11Encryption3Enabled;
6201 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
6203 DBGPRINT(RT_DEBUG_TRACE, ("Set_EncrypType_Proc::(EncrypType=%d)\n", pAdapter->StaCfg.WepStatus));
6209 ==========================================================================
6213 TRUE if all parameters are OK, FALSE otherwise
6214 ==========================================================================
6216 INT Set_DefaultKeyID_Proc(
6217 IN PRTMP_ADAPTER pAdapter,
6222 KeyIdx = simple_strtol(arg, 0, 10);
6223 if((KeyIdx >= 1 ) && (KeyIdx <= 4))
6224 pAdapter->StaCfg.DefaultKeyId = (UCHAR) (KeyIdx - 1 );
6226 return FALSE; //Invalid argument
6228 DBGPRINT(RT_DEBUG_TRACE, ("Set_DefaultKeyID_Proc::(DefaultKeyID=%d)\n", pAdapter->StaCfg.DefaultKeyId));
6234 ==========================================================================
6238 TRUE if all parameters are OK, FALSE otherwise
6239 ==========================================================================
6242 IN PRTMP_ADAPTER pAdapter,
6247 UCHAR CipherAlg=CIPHER_WEP64;
6249 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
6250 return TRUE; // do nothing
6252 KeyLen = strlen(arg);
6256 case 5: //wep 40 Ascii type
6257 pAdapter->SharedKey[BSS0][0].KeyLen = KeyLen;
6258 memcpy(pAdapter->SharedKey[BSS0][0].Key, arg, KeyLen);
6259 CipherAlg = CIPHER_WEP64;
6260 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key1_Proc::(Key1=%s and type=%s)\n", arg, "Ascii"));
6262 case 10: //wep 40 Hex type
6263 for(i=0; i < KeyLen; i++)
6265 if( !isxdigit(*(arg+i)) )
6266 return FALSE; //Not Hex value;
6268 pAdapter->SharedKey[BSS0][0].KeyLen = KeyLen / 2 ;
6269 AtoH(arg, pAdapter->SharedKey[BSS0][0].Key, KeyLen / 2);
6270 CipherAlg = CIPHER_WEP64;
6271 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key1_Proc::(Key1=%s and type=%s)\n", arg, "Hex"));
6273 case 13: //wep 104 Ascii type
6274 pAdapter->SharedKey[BSS0][0].KeyLen = KeyLen;
6275 memcpy(pAdapter->SharedKey[BSS0][0].Key, arg, KeyLen);
6276 CipherAlg = CIPHER_WEP128;
6277 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key1_Proc::(Key1=%s and type=%s)\n", arg, "Ascii"));
6279 case 26: //wep 104 Hex type
6280 for(i=0; i < KeyLen; i++)
6282 if( !isxdigit(*(arg+i)) )
6283 return FALSE; //Not Hex value;
6285 pAdapter->SharedKey[BSS0][0].KeyLen = KeyLen / 2 ;
6286 AtoH(arg, pAdapter->SharedKey[BSS0][0].Key, KeyLen / 2);
6287 CipherAlg = CIPHER_WEP128;
6288 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key1_Proc::(Key1=%s and type=%s)\n", arg, "Hex"));
6290 default: //Invalid argument
6291 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key1_Proc::Invalid argument (=%s)\n", arg));
6295 pAdapter->SharedKey[BSS0][0].CipherAlg = CipherAlg;
6297 // Set keys (into ASIC)
6298 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
6300 else // Old WEP stuff
6302 AsicAddSharedKeyEntry(pAdapter,
6305 pAdapter->SharedKey[BSS0][0].CipherAlg,
6306 pAdapter->SharedKey[BSS0][0].Key,
6314 ==========================================================================
6319 TRUE if all parameters are OK, FALSE otherwise
6320 ==========================================================================
6323 IN PRTMP_ADAPTER pAdapter,
6328 UCHAR CipherAlg=CIPHER_WEP64;
6330 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
6331 return TRUE; // do nothing
6333 KeyLen = strlen(arg);
6337 case 5: //wep 40 Ascii type
6338 pAdapter->SharedKey[BSS0][1].KeyLen = KeyLen;
6339 memcpy(pAdapter->SharedKey[BSS0][1].Key, arg, KeyLen);
6340 CipherAlg = CIPHER_WEP64;
6341 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key2_Proc::(Key2=%s and type=%s)\n", arg, "Ascii"));
6343 case 10: //wep 40 Hex type
6344 for(i=0; i < KeyLen; i++)
6346 if( !isxdigit(*(arg+i)) )
6347 return FALSE; //Not Hex value;
6349 pAdapter->SharedKey[BSS0][1].KeyLen = KeyLen / 2 ;
6350 AtoH(arg, pAdapter->SharedKey[BSS0][1].Key, KeyLen / 2);
6351 CipherAlg = CIPHER_WEP64;
6352 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key2_Proc::(Key2=%s and type=%s)\n", arg, "Hex"));
6354 case 13: //wep 104 Ascii type
6355 pAdapter->SharedKey[BSS0][1].KeyLen = KeyLen;
6356 memcpy(pAdapter->SharedKey[BSS0][1].Key, arg, KeyLen);
6357 CipherAlg = CIPHER_WEP128;
6358 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key2_Proc::(Key2=%s and type=%s)\n", arg, "Ascii"));
6360 case 26: //wep 104 Hex type
6361 for(i=0; i < KeyLen; i++)
6363 if( !isxdigit(*(arg+i)) )
6364 return FALSE; //Not Hex value;
6366 pAdapter->SharedKey[BSS0][1].KeyLen = KeyLen / 2 ;
6367 AtoH(arg, pAdapter->SharedKey[BSS0][1].Key, KeyLen / 2);
6368 CipherAlg = CIPHER_WEP128;
6369 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key2_Proc::(Key2=%s and type=%s)\n", arg, "Hex"));
6371 default: //Invalid argument
6372 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key2_Proc::Invalid argument (=%s)\n", arg));
6375 pAdapter->SharedKey[BSS0][1].CipherAlg = CipherAlg;
6377 // Set keys (into ASIC)
6378 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
6380 else // Old WEP stuff
6382 AsicAddSharedKeyEntry(pAdapter,
6385 pAdapter->SharedKey[BSS0][1].CipherAlg,
6386 pAdapter->SharedKey[BSS0][1].Key,
6394 ==========================================================================
6398 TRUE if all parameters are OK, FALSE otherwise
6399 ==========================================================================
6402 IN PRTMP_ADAPTER pAdapter,
6407 UCHAR CipherAlg=CIPHER_WEP64;
6409 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
6410 return TRUE; // do nothing
6412 KeyLen = strlen(arg);
6416 case 5: //wep 40 Ascii type
6417 pAdapter->SharedKey[BSS0][2].KeyLen = KeyLen;
6418 memcpy(pAdapter->SharedKey[BSS0][2].Key, arg, KeyLen);
6419 CipherAlg = CIPHER_WEP64;
6420 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key3_Proc::(Key3=%s and type=Ascii)\n", arg));
6422 case 10: //wep 40 Hex type
6423 for(i=0; i < KeyLen; i++)
6425 if( !isxdigit(*(arg+i)) )
6426 return FALSE; //Not Hex value;
6428 pAdapter->SharedKey[BSS0][2].KeyLen = KeyLen / 2 ;
6429 AtoH(arg, pAdapter->SharedKey[BSS0][2].Key, KeyLen / 2);
6430 CipherAlg = CIPHER_WEP64;
6431 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key3_Proc::(Key3=%s and type=Hex)\n", arg));
6433 case 13: //wep 104 Ascii type
6434 pAdapter->SharedKey[BSS0][2].KeyLen = KeyLen;
6435 memcpy(pAdapter->SharedKey[BSS0][2].Key, arg, KeyLen);
6436 CipherAlg = CIPHER_WEP128;
6437 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key3_Proc::(Key3=%s and type=Ascii)\n", arg));
6439 case 26: //wep 104 Hex type
6440 for(i=0; i < KeyLen; i++)
6442 if( !isxdigit(*(arg+i)) )
6443 return FALSE; //Not Hex value;
6445 pAdapter->SharedKey[BSS0][2].KeyLen = KeyLen / 2 ;
6446 AtoH(arg, pAdapter->SharedKey[BSS0][2].Key, KeyLen / 2);
6447 CipherAlg = CIPHER_WEP128;
6448 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key3_Proc::(Key3=%s and type=Hex)\n", arg));
6450 default: //Invalid argument
6451 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key3_Proc::Invalid argument (=%s)\n", arg));
6454 pAdapter->SharedKey[BSS0][2].CipherAlg = CipherAlg;
6456 // Set keys (into ASIC)
6457 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
6459 else // Old WEP stuff
6461 AsicAddSharedKeyEntry(pAdapter,
6464 pAdapter->SharedKey[BSS0][2].CipherAlg,
6465 pAdapter->SharedKey[BSS0][2].Key,
6473 ==========================================================================
6477 TRUE if all parameters are OK, FALSE otherwise
6478 ==========================================================================
6481 IN PRTMP_ADAPTER pAdapter,
6486 UCHAR CipherAlg=CIPHER_WEP64;
6488 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
6489 return TRUE; // do nothing
6491 KeyLen = strlen(arg);
6495 case 5: //wep 40 Ascii type
6496 pAdapter->SharedKey[BSS0][3].KeyLen = KeyLen;
6497 memcpy(pAdapter->SharedKey[BSS0][3].Key, arg, KeyLen);
6498 CipherAlg = CIPHER_WEP64;
6499 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key4_Proc::(Key4=%s and type=%s)\n", arg, "Ascii"));
6501 case 10: //wep 40 Hex type
6502 for(i=0; i < KeyLen; i++)
6504 if( !isxdigit(*(arg+i)) )
6505 return FALSE; //Not Hex value;
6507 pAdapter->SharedKey[BSS0][3].KeyLen = KeyLen / 2 ;
6508 AtoH(arg, pAdapter->SharedKey[BSS0][3].Key, KeyLen / 2);
6509 CipherAlg = CIPHER_WEP64;
6510 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key4_Proc::(Key4=%s and type=%s)\n", arg, "Hex"));
6512 case 13: //wep 104 Ascii type
6513 pAdapter->SharedKey[BSS0][3].KeyLen = KeyLen;
6514 memcpy(pAdapter->SharedKey[BSS0][3].Key, arg, KeyLen);
6515 CipherAlg = CIPHER_WEP128;
6516 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key4_Proc::(Key4=%s and type=%s)\n", arg, "Ascii"));
6518 case 26: //wep 104 Hex type
6519 for(i=0; i < KeyLen; i++)
6521 if( !isxdigit(*(arg+i)) )
6522 return FALSE; //Not Hex value;
6524 pAdapter->SharedKey[BSS0][3].KeyLen = KeyLen / 2 ;
6525 AtoH(arg, pAdapter->SharedKey[BSS0][3].Key, KeyLen / 2);
6526 CipherAlg = CIPHER_WEP128;
6527 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key4_Proc::(Key4=%s and type=%s)\n", arg, "Hex"));
6529 default: //Invalid argument
6530 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key4_Proc::Invalid argument (=%s)\n", arg));
6533 pAdapter->SharedKey[BSS0][3].CipherAlg = CipherAlg;
6535 // Set keys (into ASIC)
6536 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
6538 else // Old WEP stuff
6540 AsicAddSharedKeyEntry(pAdapter,
6543 pAdapter->SharedKey[BSS0][3].CipherAlg,
6544 pAdapter->SharedKey[BSS0][3].Key,
6553 ==========================================================================
6557 TRUE if all parameters are OK, FALSE otherwise
6558 ==========================================================================
6560 INT Set_WPAPSK_Proc(
6561 IN PRTMP_ADAPTER pAd,
6566 if ((pAd->StaCfg.AuthMode != Ndis802_11AuthModeWPAPSK) &&
6567 (pAd->StaCfg.AuthMode != Ndis802_11AuthModeWPA2PSK) &&
6568 (pAd->StaCfg.AuthMode != Ndis802_11AuthModeWPANone)
6570 return TRUE; // do nothing
6572 DBGPRINT(RT_DEBUG_TRACE, ("Set_WPAPSK_Proc::(WPAPSK=%s)\n", arg));
6574 status = RT_CfgSetWPAPSKKey(pAd, arg, pAd->MlmeAux.Ssid, pAd->MlmeAux.SsidLen, pAd->StaCfg.PMK);
6575 if (status == FALSE)
6577 DBGPRINT(RT_DEBUG_TRACE, ("Set_WPAPSK_Proc(): Set key failed!\n"));
6580 NdisZeroMemory(pAd->StaCfg.WpaPassPhrase, 64);
6581 NdisMoveMemory(pAd->StaCfg.WpaPassPhrase, arg, strlen(arg));
6582 pAd->StaCfg.WpaPassPhraseLen = (UINT)strlen(arg);
6586 if(pAd->StaCfg.BssType == BSS_ADHOC &&
6587 pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPANone)
6589 pAd->StaCfg.WpaState = SS_NOTUSE;
6593 // Start STA supplicant state machine
6594 pAd->StaCfg.WpaState = SS_START;
6601 ==========================================================================
6603 Set Power Saving mode
6605 TRUE if all parameters are OK, FALSE otherwise
6606 ==========================================================================
6608 INT Set_PSMode_Proc(
6609 IN PRTMP_ADAPTER pAdapter,
6612 if (pAdapter->StaCfg.BssType == BSS_INFRA)
6614 if ((strcmp(arg, "Max_PSP") == 0) ||
6615 (strcmp(arg, "max_psp") == 0) ||
6616 (strcmp(arg, "MAX_PSP") == 0))
6618 // do NOT turn on PSM bit here, wait until MlmeCheckPsmChange()
6619 // to exclude certain situations.
6620 if (pAdapter->StaCfg.bWindowsACCAMEnable == FALSE)
6621 pAdapter->StaCfg.WindowsPowerMode = Ndis802_11PowerModeMAX_PSP;
6622 pAdapter->StaCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeMAX_PSP;
6623 OPSTATUS_SET_FLAG(pAdapter, fOP_STATUS_RECEIVE_DTIM);
6624 pAdapter->StaCfg.DefaultListenCount = 5;
6627 else if ((strcmp(arg, "Fast_PSP") == 0) ||
6628 (strcmp(arg, "fast_psp") == 0) ||
6629 (strcmp(arg, "FAST_PSP") == 0))
6631 // do NOT turn on PSM bit here, wait until MlmeCheckPsmChange()
6632 // to exclude certain situations.
6633 OPSTATUS_SET_FLAG(pAdapter, fOP_STATUS_RECEIVE_DTIM);
6634 if (pAdapter->StaCfg.bWindowsACCAMEnable == FALSE)
6635 pAdapter->StaCfg.WindowsPowerMode = Ndis802_11PowerModeFast_PSP;
6636 pAdapter->StaCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeFast_PSP;
6637 pAdapter->StaCfg.DefaultListenCount = 3;
6639 else if ((strcmp(arg, "Legacy_PSP") == 0) ||
6640 (strcmp(arg, "legacy_psp") == 0) ||
6641 (strcmp(arg, "LEGACY_PSP") == 0))
6643 // do NOT turn on PSM bit here, wait until MlmeCheckPsmChange()
6644 // to exclude certain situations.
6645 OPSTATUS_SET_FLAG(pAdapter, fOP_STATUS_RECEIVE_DTIM);
6646 if (pAdapter->StaCfg.bWindowsACCAMEnable == FALSE)
6647 pAdapter->StaCfg.WindowsPowerMode = Ndis802_11PowerModeLegacy_PSP;
6648 pAdapter->StaCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeLegacy_PSP;
6649 pAdapter->StaCfg.DefaultListenCount = 3;
6653 //Default Ndis802_11PowerModeCAM
6654 // clear PSM bit immediately
6655 RTMP_SET_PSM_BIT(pAdapter, PWR_ACTIVE);
6656 OPSTATUS_SET_FLAG(pAdapter, fOP_STATUS_RECEIVE_DTIM);
6657 if (pAdapter->StaCfg.bWindowsACCAMEnable == FALSE)
6658 pAdapter->StaCfg.WindowsPowerMode = Ndis802_11PowerModeCAM;
6659 pAdapter->StaCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeCAM;
6662 DBGPRINT(RT_DEBUG_TRACE, ("Set_PSMode_Proc::(PSMode=%ld)\n", pAdapter->StaCfg.WindowsPowerMode));
6670 //Add to suport the function which clould dynamicallly enable/disable PCIe Power Saving
6672 #ifdef WPA_SUPPLICANT_SUPPORT
6674 ==========================================================================
6676 Set WpaSupport flag.
6678 0: Driver ignore wpa_supplicant.
6679 1: wpa_supplicant initiates scanning and AP selection.
6680 2: driver takes care of scanning, AP selection, and IEEE 802.11 association parameters.
6682 TRUE if all parameters are OK, FALSE otherwise
6683 ==========================================================================
6685 INT Set_Wpa_Support(
6686 IN PRTMP_ADAPTER pAd,
6690 if ( simple_strtol(arg, 0, 10) == 0)
6691 pAd->StaCfg.WpaSupplicantUP = WPA_SUPPLICANT_DISABLE;
6692 else if ( simple_strtol(arg, 0, 10) == 1)
6693 pAd->StaCfg.WpaSupplicantUP = WPA_SUPPLICANT_ENABLE;
6694 else if ( simple_strtol(arg, 0, 10) == 2)
6695 pAd->StaCfg.WpaSupplicantUP = WPA_SUPPLICANT_ENABLE_WITH_WEB_UI;
6697 pAd->StaCfg.WpaSupplicantUP = WPA_SUPPLICANT_DISABLE;
6699 DBGPRINT(RT_DEBUG_TRACE, ("Set_Wpa_Support::(WpaSupplicantUP=%d)\n", pAd->StaCfg.WpaSupplicantUP));
6703 #endif // WPA_SUPPLICANT_SUPPORT //
6707 ==========================================================================
6711 pAdapter Pointer to our adapter
6712 wrq Pointer to the ioctl argument
6719 1.) iwpriv ra0 mac 0 ==> read MAC where Addr=0x0
6720 2.) iwpriv ra0 mac 0=12 ==> write MAC where Addr=0x0, value=12
6721 ==========================================================================
6724 IN PRTMP_ADAPTER pAdapter,
6725 IN struct iwreq *wrq)
6735 UINT32 macValue = 0;
6737 BOOLEAN bIsPrintAllMAC = FALSE;
6740 memset(msg, 0x00, 1024);
6741 if (wrq->u.data.length > 1) //No parameters.
6743 Status = copy_from_user(arg, wrq->u.data.pointer, (wrq->u.data.length > 255) ? 255 : wrq->u.data.length);
6746 //Parsing Read or Write
6751 if ((value = rtstrchr(this_char, '=')) != NULL)
6754 if (!value || !*value)
6757 if(strlen(this_char) > 4)
6760 j = strlen(this_char);
6763 if(this_char[j] > 'f' || this_char[j] < '0')
6768 k = j = strlen(this_char);
6771 this_char[4-k+j] = this_char[j];
6775 this_char[3-k++]='0';
6778 if(strlen(this_char) == 4)
6780 AtoH(this_char, temp, 2);
6781 macAddr = *temp*256 + temp[1];
6782 if (macAddr < 0xFFFF)
6784 RTMP_IO_READ32(pAdapter, macAddr, &macValue);
6785 DBGPRINT(RT_DEBUG_TRACE, ("MacAddr=%lx, MacValue=%x\n", macAddr, macValue));
6786 sprintf(msg+strlen(msg), "[0x%08lX]:%08X ", macAddr , macValue);
6789 {//Invalid parametes, so default printk all mac
6790 bIsPrintAllMAC = TRUE;
6797 memcpy(&temp2, value, strlen(value));
6798 temp2[strlen(value)] = '\0';
6801 if((strlen(this_char) > 4) || strlen(temp2) > 8)
6804 j = strlen(this_char);
6807 if(this_char[j] > 'f' || this_char[j] < '0')
6814 if(temp2[j] > 'f' || temp2[j] < '0')
6819 k = j = strlen(this_char);
6822 this_char[4-k+j] = this_char[j];
6826 this_char[3-k++]='0';
6830 k = j = strlen(temp2);
6833 temp2[8-k+j] = temp2[j];
6841 AtoH(this_char, temp, 2);
6842 macAddr = *temp*256 + temp[1];
6844 AtoH(temp2, temp, 4);
6845 macValue = *temp*256*256*256 + temp[1]*256*256 + temp[2]*256 + temp[3];
6848 if (macAddr == (HW_DEBUG_SETTING_BASE + 4))
6850 // 0x2bf4: byte0 non-zero: enable R17 tuning, 0: disable R17 tuning
6851 if (macValue & 0x000000ff)
6853 pAdapter->BbpTuning.bEnable = TRUE;
6854 DBGPRINT(RT_DEBUG_TRACE,("turn on R17 tuning\n"));
6859 pAdapter->BbpTuning.bEnable = FALSE;
6860 R66 = 0x26 + GET_LNA_GAIN(pAdapter);
6862 if (ATE_ON(pAdapter))
6864 ATE_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R66, (0x26 + GET_LNA_GAIN(pAdapter)));
6867 #endif // RALINK_ATE //
6869 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R66, (0x26 + GET_LNA_GAIN(pAdapter)));
6870 DBGPRINT(RT_DEBUG_TRACE,("turn off R17 tuning, restore to 0x%02x\n", R66));
6875 DBGPRINT(RT_DEBUG_TRACE, ("MacAddr=%02lx, MacValue=0x%x\n", macAddr, macValue));
6877 RTMP_IO_WRITE32(pAdapter, macAddr, macValue);
6878 sprintf(msg+strlen(msg), "[0x%08lX]:%08X ", macAddr, macValue);
6883 bIsPrintAllMAC = TRUE;
6887 struct file *file_w;
6888 PSTRING fileName = "MacDump.txt";
6889 mm_segment_t orig_fs;
6895 file_w = filp_open(fileName, O_WRONLY|O_CREAT, 0);
6898 DBGPRINT(RT_DEBUG_TRACE, ("-->2) %s: Error %ld opening %s\n", __FUNCTION__, -PTR_ERR(file_w), fileName));
6902 if (file_w->f_op && file_w->f_op->write)
6907 while (macAddr <= 0x1800)
6909 RTMP_IO_READ32(pAdapter, macAddr, &macValue);
6910 sprintf(msg, "%08lx = %08X\n", macAddr, macValue);
6912 // write data to file
6913 file_w->f_op->write(file_w, msg, strlen(msg), &file_w->f_pos);
6918 sprintf(msg, "\nDump all MAC values to %s\n", fileName);
6920 filp_close(file_w, NULL);
6924 if(strlen(msg) == 1)
6925 sprintf(msg+strlen(msg), "===>Error command format!");
6927 // Copy the information into the user buffer
6928 wrq->u.data.length = strlen(msg);
6929 Status = copy_to_user(wrq->u.data.pointer, msg, wrq->u.data.length);
6931 DBGPRINT(RT_DEBUG_TRACE, ("<==RTMPIoctlMAC\n\n"));
6935 ==========================================================================
6939 pAdapter Pointer to our adapter
6940 wrq Pointer to the ioctl argument
6947 1.) iwpriv ra0 e2p 0 ==> read E2PROM where Addr=0x0
6948 2.) iwpriv ra0 e2p 0=1234 ==> write E2PROM where Addr=0x0, value=1234
6949 ==========================================================================
6951 VOID RTMPIoctlE2PROM(
6952 IN PRTMP_ADAPTER pAdapter,
6953 IN struct iwreq *wrq)
6965 BOOLEAN bIsPrintAllE2P = FALSE;
6968 memset(msg, 0x00, 1024);
6969 if (wrq->u.data.length > 1) //No parameters.
6971 Status = copy_from_user(arg, wrq->u.data.pointer, (wrq->u.data.length > 255) ? 255 : wrq->u.data.length);
6974 //Parsing Read or Write
6981 if ((value = rtstrchr(this_char, '=')) != NULL)
6984 if (!value || !*value)
6988 if(strlen(this_char) > 4)
6991 j = strlen(this_char);
6994 if(this_char[j] > 'f' || this_char[j] < '0')
6999 k = j = strlen(this_char);
7002 this_char[4-k+j] = this_char[j];
7006 this_char[3-k++]='0';
7009 if(strlen(this_char) == 4)
7011 AtoH(this_char, temp, 2);
7012 eepAddr = *temp*256 + temp[1];
7013 if (eepAddr < 0xFFFF)
7015 RT28xx_EEPROM_READ16(pAdapter, eepAddr, eepValue);
7016 sprintf(msg+strlen(msg), "[0x%04X]:0x%04X ", eepAddr , eepValue);
7019 {//Invalid parametes, so default printk all bbp
7020 bIsPrintAllE2P = TRUE;
7027 memcpy(&temp2, value, strlen(value));
7028 temp2[strlen(value)] = '\0';
7031 if((strlen(this_char) > 4) || strlen(temp2) > 8)
7034 j = strlen(this_char);
7037 if(this_char[j] > 'f' || this_char[j] < '0')
7043 if(temp2[j] > 'f' || temp2[j] < '0')
7048 k = j = strlen(this_char);
7051 this_char[4-k+j] = this_char[j];
7055 this_char[3-k++]='0';
7059 k = j = strlen(temp2);
7062 temp2[4-k+j] = temp2[j];
7069 AtoH(this_char, temp, 2);
7070 eepAddr = *temp*256 + temp[1];
7072 AtoH(temp2, temp, 2);
7073 eepValue = *temp*256 + temp[1];
7075 RT28xx_EEPROM_WRITE16(pAdapter, eepAddr, eepValue);
7076 sprintf(msg+strlen(msg), "[0x%02X]:%02X ", eepAddr, eepValue);
7080 bIsPrintAllE2P = TRUE;
7084 struct file *file_w;
7085 PSTRING fileName = "EEPROMDump.txt";
7086 mm_segment_t orig_fs;
7092 file_w = filp_open(fileName, O_WRONLY|O_CREAT, 0);
7095 DBGPRINT(RT_DEBUG_TRACE, ("-->2) %s: Error %ld opening %s\n", __FUNCTION__, -PTR_ERR(file_w), fileName));
7099 if (file_w->f_op && file_w->f_op->write)
7104 while (eepAddr <= 0xFE)
7106 RT28xx_EEPROM_READ16(pAdapter, eepAddr, eepValue);
7107 sprintf(msg, "%08x = %04x\n", eepAddr , eepValue);
7109 // write data to file
7110 file_w->f_op->write(file_w, msg, strlen(msg), &file_w->f_pos);
7115 sprintf(msg, "\nDump all EEPROM values to %s\n", fileName);
7117 filp_close(file_w, NULL);
7121 if(strlen(msg) == 1)
7122 sprintf(msg+strlen(msg), "===>Error command format!");
7125 // Copy the information into the user buffer
7126 wrq->u.data.length = strlen(msg);
7127 Status = copy_to_user(wrq->u.data.pointer, msg, wrq->u.data.length);
7129 DBGPRINT(RT_DEBUG_TRACE, ("<==RTMPIoctlE2PROM\n"));
7135 ==========================================================================
7137 Read / Write RF register
7139 pAdapter Pointer to our adapter
7140 wrq Pointer to the ioctl argument
7147 1.) iwpriv ra0 rf ==> read all RF registers
7148 2.) iwpriv ra0 rf 1 ==> read RF where RegID=1
7149 3.) iwpriv ra0 rf 1=10 ==> write RF R1=0x10
7150 ==========================================================================
7153 IN PRTMP_ADAPTER pAdapter,
7154 IN struct iwreq *wrq)
7164 BOOLEAN bIsPrintAllRF = FALSE;
7167 memset(msg, 0x00, 2048);
7168 if (wrq->u.data.length > 1) //No parameters.
7170 Status = copy_from_user(arg, wrq->u.data.pointer, (wrq->u.data.length > 255) ? 255 : wrq->u.data.length);
7173 //Parsing Read or Write
7178 if ((value = strchr(this_char, '=')) != NULL)
7181 if (!value || !*value)
7183 if (sscanf((PSTRING) this_char, "%d", &(rfId)) == 1)
7189 In RT2860 ATE mode, we do not load 8051 firmware.
7190 We must access RF directly.
7191 For RT2870 ATE mode, ATE_RF_IO_WRITE8(/READ8)_BY_REG_ID are redefined.
7193 if (ATE_ON(pAdapter))
7195 ATE_RF_IO_READ8_BY_REG_ID(pAdapter, rfId, ®RF);
7198 #endif // RALINK_ATE //
7199 // according to Andy, Gary, David require.
7200 // the command rf shall read rf register directly for dubug.
7201 // BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, ®BBP);
7202 RT30xxReadRFRegister(pAdapter, rfId, ®RF);
7204 sprintf(msg+strlen(msg), "R%02d[0x%02x]:%02X ", rfId, rfId, regRF);
7207 {//Invalid parametes, so default printk all RF
7208 bIsPrintAllRF = TRUE;
7213 { //Invalid parametes, so default printk all RF
7214 bIsPrintAllRF = TRUE;
7220 if ((sscanf((PSTRING) this_char, "%d", &(rfId)) == 1) && (sscanf((PSTRING) value, "%lx", &(rfValue)) == 1))
7226 In RT2860 ATE mode, we do not load 8051 firmware.
7227 We must access RF directly.
7228 For RT2870 ATE mode, ATE_RF_IO_WRITE8(/READ8)_BY_REG_ID are redefined.
7230 if (ATE_ON(pAdapter))
7232 ATE_RF_IO_READ8_BY_REG_ID(pAdapter, rfId, ®RF);
7233 ATE_RF_IO_WRITE8_BY_REG_ID(pAdapter, (UCHAR)rfId,(UCHAR) rfValue);
7234 //Read it back for showing
7235 ATE_RF_IO_READ8_BY_REG_ID(pAdapter, rfId, ®RF);
7236 sprintf(msg+strlen(msg), "R%02d[0x%02X]:%02X\n", rfId, rfId, regRF);
7239 #endif // RALINK_ATE //
7241 // according to Andy, Gary, David require.
7242 // the command RF shall read/write RF register directly for dubug.
7243 //BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, ®BBP);
7244 //BBP_IO_WRITE8_BY_REG_ID(pAdapter, (UCHAR)bbpId,(UCHAR) bbpValue);
7245 RT30xxReadRFRegister(pAdapter, rfId, ®RF);
7246 RT30xxWriteRFRegister(pAdapter, (UCHAR)rfId,(UCHAR) rfValue);
7247 //Read it back for showing
7248 //BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, ®BBP);
7249 RT30xxReadRFRegister(pAdapter, rfId, ®RF);
7250 sprintf(msg+strlen(msg), "R%02d[0x%02X]:%02X\n", rfId, rfId, regRF);
7254 {//Invalid parametes, so default printk all RF
7255 bIsPrintAllRF = TRUE;
7259 { //Invalid parametes, so default printk all RF
7260 bIsPrintAllRF = TRUE;
7265 bIsPrintAllRF = TRUE;
7269 memset(msg, 0x00, 2048);
7271 for (rfId = 0; rfId <= 31; rfId++)
7275 In RT2860 ATE mode, we do not load 8051 firmware.
7276 We must access RF directly.
7277 For RT2870 ATE mode, ATE_RF_IO_WRITE8(/READ8)_BY_REG_ID are redefined.
7279 if (ATE_ON(pAdapter))
7281 ATE_RF_IO_READ8_BY_REG_ID(pAdapter, rfId, ®RF);
7284 #endif // RALINK_ATE //
7286 // according to Andy, Gary, David require.
7287 // the command RF shall read/write RF register directly for dubug.
7288 RT30xxReadRFRegister(pAdapter, rfId, ®RF);
7289 sprintf(msg+strlen(msg), "%03d = %02X\n", rfId, regRF);
7291 // Copy the information into the user buffer
7292 DBGPRINT(RT_DEBUG_TRACE, ("strlen(msg)=%d\n", (UINT32)strlen(msg)));
7293 wrq->u.data.length = strlen(msg);
7294 if (copy_to_user(wrq->u.data.pointer, msg, wrq->u.data.length))
7296 DBGPRINT(RT_DEBUG_TRACE, ("%s: copy_to_user() fail\n", __FUNCTION__));
7301 if(strlen(msg) == 1)
7302 sprintf(msg+strlen(msg), "===>Error command format!");
7304 DBGPRINT(RT_DEBUG_TRACE, ("copy to user [msg=%s]\n", msg));
7305 // Copy the information into the user buffer
7306 DBGPRINT(RT_DEBUG_TRACE, ("strlen(msg) =%d\n", (UINT32)strlen(msg)));
7308 // Copy the information into the user buffer
7309 wrq->u.data.length = strlen(msg);
7310 Status = copy_to_user(wrq->u.data.pointer, msg, wrq->u.data.length);
7313 DBGPRINT(RT_DEBUG_TRACE, ("<==RTMPIoctlRF\n\n"));
7321 INT Set_TGnWifiTest_Proc(
7322 IN PRTMP_ADAPTER pAd,
7325 if (simple_strtol(arg, 0, 10) == 0)
7326 pAd->StaCfg.bTGnWifiTest = FALSE;
7328 pAd->StaCfg.bTGnWifiTest = TRUE;
7330 DBGPRINT(RT_DEBUG_TRACE, ("IF Set_TGnWifiTest_Proc::(bTGnWifiTest=%d)\n", pAd->StaCfg.bTGnWifiTest));
7334 #ifdef EXT_BUILD_CHANNEL_LIST
7335 INT Set_Ieee80211dClientMode_Proc(
7336 IN PRTMP_ADAPTER pAdapter,
7339 if (simple_strtol(arg, 0, 10) == 0)
7340 pAdapter->StaCfg.IEEE80211dClientMode = Rt802_11_D_None;
7341 else if (simple_strtol(arg, 0, 10) == 1)
7342 pAdapter->StaCfg.IEEE80211dClientMode = Rt802_11_D_Flexible;
7343 else if (simple_strtol(arg, 0, 10) == 2)
7344 pAdapter->StaCfg.IEEE80211dClientMode = Rt802_11_D_Strict;
7348 DBGPRINT(RT_DEBUG_TRACE, ("Set_Ieee802dMode_Proc::(IEEEE0211dMode=%d)\n", pAdapter->StaCfg.IEEE80211dClientMode));
7351 #endif // EXT_BUILD_CHANNEL_LIST //
7353 #ifdef CARRIER_DETECTION_SUPPORT
7354 INT Set_CarrierDetect_Proc(
7355 IN PRTMP_ADAPTER pAd,
7358 if (simple_strtol(arg, 0, 10) == 0)
7359 pAd->CommonCfg.CarrierDetect.Enable = FALSE;
7361 pAd->CommonCfg.CarrierDetect.Enable = TRUE;
7363 DBGPRINT(RT_DEBUG_TRACE, ("IF Set_CarrierDetect_Proc::(CarrierDetect.Enable=%d)\n", pAd->CommonCfg.CarrierDetect.Enable));
7366 #endif // CARRIER_DETECTION_SUPPORT //
7369 INT Show_Adhoc_MacTable_Proc(
7370 IN PRTMP_ADAPTER pAd,
7375 sprintf(extra, "\n");
7377 #ifdef DOT11_N_SUPPORT
7378 sprintf(extra, "%sHT Operating Mode : %d\n", extra, pAd->CommonCfg.AddHTInfo.AddHtInfo2.OperaionMode);
7379 #endif // DOT11_N_SUPPORT //
7381 sprintf(extra, "%s\n%-19s%-4s%-4s%-7s%-7s%-7s%-10s%-6s%-6s%-6s%-6s\n", extra,
7382 "MAC", "AID", "BSS", "RSSI0", "RSSI1", "RSSI2", "PhMd", "BW", "MCS", "SGI", "STBC");
7384 for (i=1; i<MAX_LEN_OF_MAC_TABLE; i++)
7386 PMAC_TABLE_ENTRY pEntry = &pAd->MacTab.Content[i];
7388 if (strlen(extra) > (IW_PRIV_SIZE_MASK - 30))
7390 if ((pEntry->ValidAsCLI || pEntry->ValidAsApCli) && (pEntry->Sst == SST_ASSOC))
7392 sprintf(extra, "%s%02X:%02X:%02X:%02X:%02X:%02X ", extra,
7393 pEntry->Addr[0], pEntry->Addr[1], pEntry->Addr[2],
7394 pEntry->Addr[3], pEntry->Addr[4], pEntry->Addr[5]);
7395 sprintf(extra, "%s%-4d", extra, (int)pEntry->Aid);
7396 sprintf(extra, "%s%-4d", extra, (int)pEntry->apidx);
7397 sprintf(extra, "%s%-7d", extra, pEntry->RssiSample.AvgRssi0);
7398 sprintf(extra, "%s%-7d", extra, pEntry->RssiSample.AvgRssi1);
7399 sprintf(extra, "%s%-7d", extra, pEntry->RssiSample.AvgRssi2);
7400 sprintf(extra, "%s%-10s", extra, GetPhyMode(pEntry->HTPhyMode.field.MODE));
7401 sprintf(extra, "%s%-6s", extra, GetBW(pEntry->HTPhyMode.field.BW));
7402 sprintf(extra, "%s%-6d", extra, pEntry->HTPhyMode.field.MCS);
7403 sprintf(extra, "%s%-6d", extra, pEntry->HTPhyMode.field.ShortGI);
7404 sprintf(extra, "%s%-6d", extra, pEntry->HTPhyMode.field.STBC);
7405 sprintf(extra, "%s%-10d, %d, %d%%\n", extra, pEntry->DebugFIFOCount, pEntry->DebugTxCount,
7406 (pEntry->DebugTxCount) ? ((pEntry->DebugTxCount-pEntry->DebugFIFOCount)*100/pEntry->DebugTxCount) : 0);
7407 sprintf(extra, "%s\n", extra);
7415 INT Set_BeaconLostTime_Proc(
7416 IN PRTMP_ADAPTER pAd,
7419 ULONG ltmp = (ULONG)simple_strtol(arg, 0, 10);
7421 if ((ltmp != 0) && (ltmp <= 60))
7422 pAd->StaCfg.BeaconLostTime = (ltmp * OS_HZ);
7424 DBGPRINT(RT_DEBUG_TRACE, ("IF Set_BeaconLostTime_Proc::(BeaconLostTime=%ld)\n", pAd->StaCfg.BeaconLostTime));
7428 INT Set_AutoRoaming_Proc(
7429 IN PRTMP_ADAPTER pAd,
7432 if (simple_strtol(arg, 0, 10) == 0)
7433 pAd->StaCfg.bAutoRoaming = FALSE;
7435 pAd->StaCfg.bAutoRoaming = TRUE;
7437 DBGPRINT(RT_DEBUG_TRACE, ("IF Set_AutoRoaming_Proc::(bAutoRoaming=%d)\n", pAd->StaCfg.bAutoRoaming));
7443 ==========================================================================
7445 Issue a site survey command to driver
7447 pAdapter Pointer to our adapter
7448 wrq Pointer to the ioctl argument
7455 1.) iwpriv ra0 set site_survey
7456 ==========================================================================
7458 INT Set_SiteSurvey_Proc(
7459 IN PRTMP_ADAPTER pAd,
7462 NDIS_802_11_SSID Ssid;
7464 //check if the interface is down
7465 if (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_IN_USE))
7467 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
7471 if (MONITOR_ON(pAd))
7473 DBGPRINT(RT_DEBUG_TRACE, ("!!! Driver is in Monitor Mode now !!!\n"));
7477 RTMPZeroMemory(&Ssid, sizeof(NDIS_802_11_SSID));
7478 Ssid.SsidLength = 0;
7479 if ((arg != NULL) &&
7480 (strlen(arg) <= MAX_LEN_OF_SSID))
7482 RTMPMoveMemory(Ssid.Ssid, arg, strlen(arg));
7483 Ssid.SsidLength = strlen(arg);
7486 pAd->StaCfg.bScanReqIsFromWebUI = TRUE;
7488 if (pAd->Mlme.CntlMachine.CurrState != CNTL_IDLE)
7490 RTMP_MLME_RESET_STATE_MACHINE(pAd);
7491 DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
7494 // tell CNTL state machine to call NdisMSetInformationComplete() after completing
7495 // this request, because this request is initiated by NDIS.
7496 pAd->MlmeAux.CurrReqIsFromNdis = FALSE;
7497 // Reset allowed scan retries
7498 pAd->StaCfg.ScanCnt = 0;
7499 NdisGetSystemUpTime(&pAd->StaCfg.LastScanTime);
7502 MLME_CNTL_STATE_MACHINE,
7503 OID_802_11_BSSID_LIST_SCAN,
7507 RTMP_MLME_HANDLER(pAd);
7509 DBGPRINT(RT_DEBUG_TRACE, ("Set_SiteSurvey_Proc\n"));
7514 INT Set_ForceTxBurst_Proc(
7515 IN PRTMP_ADAPTER pAd,
7518 if (simple_strtol(arg, 0, 10) == 0)
7519 pAd->StaCfg.bForceTxBurst = FALSE;
7521 pAd->StaCfg.bForceTxBurst = TRUE;
7523 DBGPRINT(RT_DEBUG_TRACE, ("IF Set_ForceTxBurst_Proc::(bForceTxBurst=%d)\n", pAd->StaCfg.bForceTxBurst));
7527 #ifdef ANT_DIVERSITY_SUPPORT
7528 INT Set_Antenna_Proc(
7529 IN PRTMP_ADAPTER pAd,
7533 DBGPRINT(RT_DEBUG_TRACE, ("==> Set_Antenna_Proc *******************\n"));
7535 if(simple_strtol(arg, 0, 10) <= 3)
7536 UsedAnt = simple_strtol(arg, 0, 10);
7538 pAd->CommonCfg.bRxAntDiversity = UsedAnt; // Auto switch
7539 if (UsedAnt == ANT_DIVERSITY_ENABLE)
7541 pAd->RxAnt.EvaluateStableCnt = 0;
7542 DBGPRINT(RT_DEBUG_TRACE, ("<== Set_Antenna_Proc(Auto Switch Mode), (%d,%d)\n", pAd->RxAnt.Pair1PrimaryRxAnt, pAd->RxAnt.Pair1SecondaryRxAnt));
7544 /* 2: Fix in the PHY Antenna CON1*/
7545 if (UsedAnt == ANT_FIX_ANT1)
7547 AsicSetRxAnt(pAd, 0);
7548 DBGPRINT(RT_DEBUG_TRACE, ("<== Set_Antenna_Proc(Fix in Ant CON1), (%d,%d)\n", pAd->RxAnt.Pair1PrimaryRxAnt, pAd->RxAnt.Pair1SecondaryRxAnt));
7550 /* 3: Fix in the PHY Antenna CON2*/
7551 if (UsedAnt == ANT_FIX_ANT2)
7553 AsicSetRxAnt(pAd, 1);
7554 DBGPRINT(RT_DEBUG_TRACE, ("<== Set_Antenna_Proc(Fix in Ant CON2), (%d,%d)\n", pAd->RxAnt.Pair1PrimaryRxAnt, pAd->RxAnt.Pair1SecondaryRxAnt));
7559 #endif // ANT_DIVERSITY_SUPPORT //