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 extern UCHAR CipherWpa2Template[];
53 extern UCHAR CipherWpaPskTkip[];
54 extern UCHAR CipherWpaPskTkipLen;
56 typedef struct PACKED _RT_VERSION_INFO{
62 UINT DriverBuildMonth;
64 } RT_VERSION_INFO, *PRT_VERSION_INFO;
66 struct iw_priv_args privtab[] = {
68 IW_PRIV_TYPE_CHAR | 1024, 0,
71 { RTPRIV_IOCTL_SHOW, 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK,
73 { RTPRIV_IOCTL_SHOW, IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK,
75 /* --- sub-ioctls definitions --- */
77 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "connStatus" },
79 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "driverVer" },
81 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "bainfo" },
83 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "descinfo" },
85 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "radio_off" },
87 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "radio_on" },
88 #ifdef QOS_DLS_SUPPORT
89 { SHOW_DLS_ENTRY_INFO,
90 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "dlsentryinfo" },
91 #endif // QOS_DLS_SUPPORT //
93 IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "show" },
94 /* --- sub-ioctls relations --- */
98 IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK,
101 IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | 1024,
105 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,
113 { RTPRIV_IOCTL_STATISTICS,
114 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK,
116 { RTPRIV_IOCTL_GSITESURVEY,
117 0, IW_PRIV_TYPE_CHAR | 1024,
124 IN PRTMP_ADAPTER pAdapter,
128 INT Set_WmmCapable_Proc(
129 IN PRTMP_ADAPTER pAd,
133 INT Set_NetworkType_Proc(
134 IN PRTMP_ADAPTER pAdapter,
137 INT Set_AuthMode_Proc(
138 IN PRTMP_ADAPTER pAdapter,
141 INT Set_EncrypType_Proc(
142 IN PRTMP_ADAPTER pAdapter,
145 INT Set_DefaultKeyID_Proc(
146 IN PRTMP_ADAPTER pAdapter,
150 IN PRTMP_ADAPTER pAdapter,
154 IN PRTMP_ADAPTER pAdapter,
158 IN PRTMP_ADAPTER pAdapter,
162 IN PRTMP_ADAPTER pAdapter,
166 IN PRTMP_ADAPTER pAdapter,
171 IN PRTMP_ADAPTER pAdapter,
174 #ifdef WPA_SUPPLICANT_SUPPORT
176 IN PRTMP_ADAPTER pAd,
178 #endif // WPA_SUPPLICANT_SUPPORT //
183 IN PRTMP_ADAPTER pAdapter,
184 IN struct iwreq *wrq);
186 VOID RTMPIoctlE2PROM(
187 IN PRTMP_ADAPTER pAdapter,
188 IN struct iwreq *wrq);
192 IN PRTMP_ADAPTER pAdapter,
193 IN struct iwreq *wrq);
198 NDIS_STATUS RTMPWPANoneAddKeyProc(
199 IN PRTMP_ADAPTER pAd,
202 INT Set_FragTest_Proc(
203 IN PRTMP_ADAPTER pAdapter,
206 #ifdef DOT11_N_SUPPORT
207 INT Set_TGnWifiTest_Proc(
208 IN PRTMP_ADAPTER pAd,
210 #endif // DOT11_N_SUPPORT //
212 INT Set_LongRetryLimit_Proc(
213 IN PRTMP_ADAPTER pAdapter,
216 INT Set_ShortRetryLimit_Proc(
217 IN PRTMP_ADAPTER pAdapter,
220 #ifdef EXT_BUILD_CHANNEL_LIST
221 INT Set_Ieee80211dClientMode_Proc(
222 IN PRTMP_ADAPTER pAdapter,
224 #endif // EXT_BUILD_CHANNEL_LIST //
226 #ifdef CARRIER_DETECTION_SUPPORT
227 INT Set_CarrierDetect_Proc(
228 IN PRTMP_ADAPTER pAd,
230 #endif // CARRIER_DETECTION_SUPPORT //
234 INT (*set_proc)(PRTMP_ADAPTER pAdapter, PUCHAR arg);
235 } *PRTMP_PRIVATE_SET_PROC, RTMP_PRIVATE_SUPPORT_PROC[] = {
236 {"DriverVersion", Set_DriverVersion_Proc},
237 {"CountryRegion", Set_CountryRegion_Proc},
238 {"CountryRegionABand", Set_CountryRegionABand_Proc},
239 {"SSID", Set_SSID_Proc},
240 {"WirelessMode", Set_WirelessMode_Proc},
241 {"TxBurst", Set_TxBurst_Proc},
242 {"TxPreamble", Set_TxPreamble_Proc},
243 {"TxPower", Set_TxPower_Proc},
244 {"Channel", Set_Channel_Proc},
245 {"BGProtection", Set_BGProtection_Proc},
246 {"RTSThreshold", Set_RTSThreshold_Proc},
247 {"FragThreshold", Set_FragThreshold_Proc},
248 #ifdef DOT11_N_SUPPORT
249 {"HtBw", Set_HtBw_Proc},
250 {"HtMcs", Set_HtMcs_Proc},
251 {"HtGi", Set_HtGi_Proc},
252 {"HtOpMode", Set_HtOpMode_Proc},
253 {"HtExtcha", Set_HtExtcha_Proc},
254 {"HtMpduDensity", Set_HtMpduDensity_Proc},
255 {"HtBaWinSize", Set_HtBaWinSize_Proc},
256 {"HtRdg", Set_HtRdg_Proc},
257 {"HtAmsdu", Set_HtAmsdu_Proc},
258 {"HtAutoBa", Set_HtAutoBa_Proc},
259 {"HtBaDecline", Set_BADecline_Proc},
260 {"HtProtect", Set_HtProtect_Proc},
261 {"HtMimoPs", Set_HtMimoPs_Proc},
262 #endif // DOT11_N_SUPPORT //
264 #ifdef AGGREGATION_SUPPORT
265 {"PktAggregate", Set_PktAggregate_Proc},
269 {"WmmCapable", Set_WmmCapable_Proc},
271 {"IEEE80211H", Set_IEEE80211H_Proc},
272 {"NetworkType", Set_NetworkType_Proc},
273 {"AuthMode", Set_AuthMode_Proc},
274 {"EncrypType", Set_EncrypType_Proc},
275 {"DefaultKeyID", Set_DefaultKeyID_Proc},
276 {"Key1", Set_Key1_Proc},
277 {"Key2", Set_Key2_Proc},
278 {"Key3", Set_Key3_Proc},
279 {"Key4", Set_Key4_Proc},
280 {"WPAPSK", Set_WPAPSK_Proc},
281 {"ResetCounter", Set_ResetStatCounter_Proc},
282 {"PSMode", Set_PSMode_Proc},
284 {"Debug", Set_Debug_Proc},
288 {"ATE", Set_ATE_Proc},
289 {"ATEDA", Set_ATE_DA_Proc},
290 {"ATESA", Set_ATE_SA_Proc},
291 {"ATEBSSID", Set_ATE_BSSID_Proc},
292 {"ATECHANNEL", Set_ATE_CHANNEL_Proc},
293 {"ATETXPOW0", Set_ATE_TX_POWER0_Proc},
294 {"ATETXPOW1", Set_ATE_TX_POWER1_Proc},
295 {"ATETXANT", Set_ATE_TX_Antenna_Proc},
296 {"ATERXANT", Set_ATE_RX_Antenna_Proc},
297 {"ATETXFREQOFFSET", Set_ATE_TX_FREQOFFSET_Proc},
298 {"ATETXBW", Set_ATE_TX_BW_Proc},
299 {"ATETXLEN", Set_ATE_TX_LENGTH_Proc},
300 {"ATETXCNT", Set_ATE_TX_COUNT_Proc},
301 {"ATETXMCS", Set_ATE_TX_MCS_Proc},
302 {"ATETXMODE", Set_ATE_TX_MODE_Proc},
303 {"ATETXGI", Set_ATE_TX_GI_Proc},
304 {"ATERXFER", Set_ATE_RX_FER_Proc},
305 {"ATERRF", Set_ATE_Read_RF_Proc},
306 {"ATEWRF1", Set_ATE_Write_RF1_Proc},
307 {"ATEWRF2", Set_ATE_Write_RF2_Proc},
308 {"ATEWRF3", Set_ATE_Write_RF3_Proc},
309 {"ATEWRF4", Set_ATE_Write_RF4_Proc},
310 {"ATELDE2P", Set_ATE_Load_E2P_Proc},
311 {"ATERE2P", Set_ATE_Read_E2P_Proc},
312 {"ATESHOW", Set_ATE_Show_Proc},
313 {"ATEHELP", Set_ATE_Help_Proc},
315 #ifdef RALINK_28xx_QA
316 {"TxStop", Set_TxStop_Proc},
317 {"RxStop", Set_RxStop_Proc},
318 #endif // RALINK_28xx_QA //
319 #endif // RALINK_ATE //
321 #ifdef WPA_SUPPLICANT_SUPPORT
322 {"WpaSupport", Set_Wpa_Support},
323 #endif // WPA_SUPPLICANT_SUPPORT //
327 {"FixedTxMode", Set_FixedTxMode_Proc},
328 #ifdef CONFIG_APSTA_MIXED_SUPPORT
329 {"OpMode", Set_OpMode_Proc},
330 #endif // CONFIG_APSTA_MIXED_SUPPORT //
331 #ifdef DOT11_N_SUPPORT
332 {"TGnWifiTest", Set_TGnWifiTest_Proc},
333 {"ForceGF", Set_ForceGF_Proc},
334 #endif // DOT11_N_SUPPORT //
335 #ifdef QOS_DLS_SUPPORT
336 {"DlsAddEntry", Set_DlsAddEntry_Proc},
337 {"DlsTearDownEntry", Set_DlsTearDownEntry_Proc},
338 #endif // QOS_DLS_SUPPORT //
339 {"LongRetry", Set_LongRetryLimit_Proc},
340 {"ShortRetry", Set_ShortRetryLimit_Proc},
341 #ifdef EXT_BUILD_CHANNEL_LIST
342 {"11dClientMode", Set_Ieee80211dClientMode_Proc},
343 #endif // EXT_BUILD_CHANNEL_LIST //
344 #ifdef CARRIER_DETECTION_SUPPORT
345 {"CarrierDetect", Set_CarrierDetect_Proc},
346 #endif // CARRIER_DETECTION_SUPPORT //
347 //2008/09/11:KH add to support efuse<--
349 {"efuseFreeNumber", set_eFuseGetFreeBlockCount_Proc},
350 {"efuseDump", set_eFusedump_Proc},
351 {"efuseLoadFromBin", set_eFuseLoadFromBin_Proc},
353 //2008/09/11:KH add to support efuse-->
359 IN PRTMP_ADAPTER pAd,
360 IN PNDIS_802_11_KEY pKey)
363 MAC_TABLE_ENTRY *pEntry;
365 DBGPRINT(RT_DEBUG_TRACE, ("RTMPAddKey ------>\n"));
367 if (pAd->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
369 if (pKey->KeyIndex & 0x80000000)
371 if (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPANone)
373 NdisZeroMemory(pAd->StaCfg.PMK, 32);
374 NdisMoveMemory(pAd->StaCfg.PMK, pKey->KeyMaterial, pKey->KeyLength);
378 NdisZeroMemory(&pAd->SharedKey[BSS0][0], sizeof(CIPHER_KEY));
379 pAd->SharedKey[BSS0][0].KeyLen = LEN_TKIP_EK;
380 NdisMoveMemory(pAd->SharedKey[BSS0][0].Key, pKey->KeyMaterial, LEN_TKIP_EK);
381 #ifdef WPA_SUPPLICANT_SUPPORT
382 if (pAd->StaCfg.PairCipher == Ndis802_11Encryption2Enabled)
384 NdisMoveMemory(pAd->SharedKey[BSS0][0].RxMic, pKey->KeyMaterial + LEN_TKIP_EK, LEN_TKIP_TXMICK);
385 NdisMoveMemory(pAd->SharedKey[BSS0][0].TxMic, pKey->KeyMaterial + LEN_TKIP_EK + LEN_TKIP_TXMICK, LEN_TKIP_RXMICK);
388 #endif // WPA_SUPPLICANT_SUPPORT //
390 NdisMoveMemory(pAd->SharedKey[BSS0][0].TxMic, pKey->KeyMaterial + LEN_TKIP_EK, LEN_TKIP_TXMICK);
391 NdisMoveMemory(pAd->SharedKey[BSS0][0].RxMic, pKey->KeyMaterial + LEN_TKIP_EK + LEN_TKIP_TXMICK, LEN_TKIP_RXMICK);
394 // Decide its ChiperAlg
395 if (pAd->StaCfg.PairCipher == Ndis802_11Encryption2Enabled)
396 pAd->SharedKey[BSS0][0].CipherAlg = CIPHER_TKIP;
397 else if (pAd->StaCfg.PairCipher == Ndis802_11Encryption3Enabled)
398 pAd->SharedKey[BSS0][0].CipherAlg = CIPHER_AES;
400 pAd->SharedKey[BSS0][0].CipherAlg = CIPHER_NONE;
402 // Update these related information to MAC_TABLE_ENTRY
403 pEntry = &pAd->MacTab.Content[BSSID_WCID];
404 NdisMoveMemory(pEntry->PairwiseKey.Key, pAd->SharedKey[BSS0][0].Key, LEN_TKIP_EK);
405 NdisMoveMemory(pEntry->PairwiseKey.RxMic, pAd->SharedKey[BSS0][0].RxMic, LEN_TKIP_RXMICK);
406 NdisMoveMemory(pEntry->PairwiseKey.TxMic, pAd->SharedKey[BSS0][0].TxMic, LEN_TKIP_TXMICK);
407 pEntry->PairwiseKey.CipherAlg = pAd->SharedKey[BSS0][0].CipherAlg;
409 // Update pairwise key information to ASIC Shared Key Table
410 AsicAddSharedKeyEntry(pAd,
413 pAd->SharedKey[BSS0][0].CipherAlg,
414 pAd->SharedKey[BSS0][0].Key,
415 pAd->SharedKey[BSS0][0].TxMic,
416 pAd->SharedKey[BSS0][0].RxMic);
418 // Update ASIC WCID attribute table and IVEIV table
419 RTMPAddWcidAttributeEntry(pAd,
422 pAd->SharedKey[BSS0][0].CipherAlg,
425 if (pAd->StaCfg.AuthMode >= Ndis802_11AuthModeWPA2)
427 // set 802.1x port control
428 //pAd->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
429 STA_PORT_SECURED(pAd);
431 // Indicate Connected for GUI
432 pAd->IndicateMediaState = NdisMediaStateConnected;
438 pAd->StaCfg.DefaultKeyId = (pKey->KeyIndex & 0xFF);
439 NdisZeroMemory(&pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId], sizeof(CIPHER_KEY));
440 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].KeyLen = LEN_TKIP_EK;
441 NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].Key, pKey->KeyMaterial, LEN_TKIP_EK);
442 #ifdef WPA_SUPPLICANT_SUPPORT
443 if (pAd->StaCfg.GroupCipher == Ndis802_11Encryption2Enabled)
445 NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].RxMic, pKey->KeyMaterial + LEN_TKIP_EK, LEN_TKIP_TXMICK);
446 NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].TxMic, pKey->KeyMaterial + LEN_TKIP_EK + LEN_TKIP_TXMICK, LEN_TKIP_RXMICK);
449 #endif // WPA_SUPPLICANT_SUPPORT //
451 NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].TxMic, pKey->KeyMaterial + LEN_TKIP_EK, LEN_TKIP_TXMICK);
452 NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].RxMic, pKey->KeyMaterial + LEN_TKIP_EK + LEN_TKIP_TXMICK, LEN_TKIP_RXMICK);
455 // Update Shared Key CipherAlg
456 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg = CIPHER_NONE;
457 if (pAd->StaCfg.GroupCipher == Ndis802_11Encryption2Enabled)
458 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg = CIPHER_TKIP;
459 else if (pAd->StaCfg.GroupCipher == Ndis802_11Encryption3Enabled)
460 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg = CIPHER_AES;
462 // Update group key information to ASIC Shared Key Table
463 AsicAddSharedKeyEntry(pAd,
465 pAd->StaCfg.DefaultKeyId,
466 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg,
467 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].Key,
468 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].TxMic,
469 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].RxMic);
471 // Update ASIC WCID attribute table and IVEIV table
472 RTMPAddWcidAttributeEntry(pAd,
474 pAd->StaCfg.DefaultKeyId,
475 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg,
478 // set 802.1x port control
479 //pAd->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
480 STA_PORT_SECURED(pAd);
482 // Indicate Connected for GUI
483 pAd->IndicateMediaState = NdisMediaStateConnected;
486 else // dynamic WEP from wpa_supplicant
491 if(pKey->KeyLength == 32)
494 KeyIdx = pKey->KeyIndex & 0x0fffffff;
498 // it is a default shared key, for Pairwise key setting
499 if (pKey->KeyIndex & 0x80000000)
501 pEntry = MacTableLookup(pAd, pKey->BSSID);
505 DBGPRINT(RT_DEBUG_TRACE, ("RTMPAddKey: Set Pair-wise Key\n"));
507 // set key material and key length
508 pEntry->PairwiseKey.KeyLen = (UCHAR)pKey->KeyLength;
509 NdisMoveMemory(pEntry->PairwiseKey.Key, &pKey->KeyMaterial, pKey->KeyLength);
512 if (pKey->KeyLength == 5)
513 pEntry->PairwiseKey.CipherAlg = CIPHER_WEP64;
515 pEntry->PairwiseKey.CipherAlg = CIPHER_WEP128;
517 // Add Pair-wise key to Asic
518 AsicAddPairwiseKeyEntry(
522 &pEntry->PairwiseKey);
524 // update WCID attribute table and IVEIV table for this entry
525 RTMPAddWcidAttributeEntry(
528 KeyIdx, // The value may be not zero
529 pEntry->PairwiseKey.CipherAlg,
536 // Default key for tx (shared key)
537 pAd->StaCfg.DefaultKeyId = (UCHAR) KeyIdx;
539 // set key material and key length
540 pAd->SharedKey[BSS0][KeyIdx].KeyLen = (UCHAR) pKey->KeyLength;
541 NdisMoveMemory(pAd->SharedKey[BSS0][KeyIdx].Key, &pKey->KeyMaterial, pKey->KeyLength);
544 if (pKey->KeyLength == 5)
545 pAd->SharedKey[BSS0][KeyIdx].CipherAlg = CIPHER_WEP64;
547 pAd->SharedKey[BSS0][KeyIdx].CipherAlg = CIPHER_WEP128;
549 CipherAlg = pAd->SharedKey[BSS0][KeyIdx].CipherAlg;
550 Key = pAd->SharedKey[BSS0][KeyIdx].Key;
552 // Set Group key material to Asic
553 AsicAddSharedKeyEntry(pAd, BSS0, KeyIdx, CipherAlg, Key, NULL, NULL);
555 // Update WCID attribute table and IVEIV table for this group key table
556 RTMPAddWcidAttributeEntry(pAd, BSS0, KeyIdx, CipherAlg, NULL);
565 char * rtstrchr(const char * s, int c)
567 for(; *s != (char) c; ++s)
574 This is required for LinEX2004/kernel2.6.7 to provide iwlist scanning function
578 rt_ioctl_giwname(struct net_device *dev,
579 struct iw_request_info *info,
580 char *name, char *extra)
582 // PRTMP_ADAPTER pAdapter = dev->ml_priv;
585 strncpy(name, "RT2870 Wireless", IFNAMSIZ);
590 int rt_ioctl_siwfreq(struct net_device *dev,
591 struct iw_request_info *info,
592 struct iw_freq *freq, char *extra)
594 PRTMP_ADAPTER pAdapter = dev->ml_priv;
597 //check if the interface is down
598 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
600 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
608 if((freq->e == 0) && (freq->m <= 1000))
609 chan = freq->m; // Setting by channel number
611 MAP_KHZ_TO_CHANNEL_ID( (freq->m /100) , chan); // Setting by frequency - search the table , like 2.412G, 2.422G,
613 if (ChannelSanity(pAdapter, chan) == TRUE)
615 pAdapter->CommonCfg.Channel = chan;
616 DBGPRINT(RT_DEBUG_ERROR, ("==>rt_ioctl_siwfreq::SIOCSIWFREQ[cmd=0x%x] (Channel=%d)\n", SIOCSIWFREQ, pAdapter->CommonCfg.Channel));
623 int rt_ioctl_giwfreq(struct net_device *dev,
624 struct iw_request_info *info,
625 struct iw_freq *freq, char *extra)
627 VIRTUAL_ADAPTER *pVirtualAd = NULL;
628 PRTMP_ADAPTER pAdapter;
632 if (dev->priv_flags == INT_MAIN)
634 pAdapter = dev->ml_priv;
638 pVirtualAd = dev->ml_priv;
639 pAdapter = pVirtualAd->RtmpDev->ml_priv;
642 if (pAdapter == NULL)
644 /* if 1st open fail, pAd will be free;
645 So the net_dev->ml_priv will be NULL in 2rd open */
649 ch = pAdapter->CommonCfg.Channel;
651 DBGPRINT(RT_DEBUG_TRACE,("==>rt_ioctl_giwfreq %d\n", ch));
653 MAP_CHANNEL_ID_TO_KHZ(ch, m);
659 int rt_ioctl_siwmode(struct net_device *dev,
660 struct iw_request_info *info,
661 __u32 *mode, char *extra)
663 PRTMP_ADAPTER pAdapter = dev->ml_priv;
665 //check if the interface is down
666 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
668 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
675 Set_NetworkType_Proc(pAdapter, "Adhoc");
678 Set_NetworkType_Proc(pAdapter, "Infra");
680 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,4,20))
681 case IW_MODE_MONITOR:
682 Set_NetworkType_Proc(pAdapter, "Monitor");
686 DBGPRINT(RT_DEBUG_TRACE, ("===>rt_ioctl_siwmode::SIOCSIWMODE (unknown %d)\n", *mode));
690 // Reset Ralink supplicant to not use, it will be set to start when UI set PMK key
691 pAdapter->StaCfg.WpaState = SS_NOTUSE;
696 int rt_ioctl_giwmode(struct net_device *dev,
697 struct iw_request_info *info,
698 __u32 *mode, char *extra)
700 PRTMP_ADAPTER pAdapter = dev->ml_priv;
702 if (ADHOC_ON(pAdapter))
703 *mode = IW_MODE_ADHOC;
704 else if (INFRA_ON(pAdapter))
705 *mode = IW_MODE_INFRA;
706 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,4,20))
707 else if (MONITOR_ON(pAdapter))
709 *mode = IW_MODE_MONITOR;
713 *mode = IW_MODE_AUTO;
715 DBGPRINT(RT_DEBUG_TRACE, ("==>rt_ioctl_giwmode(mode=%d)\n", *mode));
719 int rt_ioctl_siwsens(struct net_device *dev,
720 struct iw_request_info *info,
721 char *name, char *extra)
723 PRTMP_ADAPTER pAdapter = dev->ml_priv;
725 //check if the interface is down
726 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
728 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
735 int rt_ioctl_giwsens(struct net_device *dev,
736 struct iw_request_info *info,
737 char *name, char *extra)
742 int rt_ioctl_giwrange(struct net_device *dev,
743 struct iw_request_info *info,
744 struct iw_point *data, char *extra)
746 PRTMP_ADAPTER pAdapter = dev->ml_priv;
748 struct iw_range *range = (struct iw_range *) extra;
752 DBGPRINT(RT_DEBUG_TRACE ,("===>rt_ioctl_giwrange\n"));
753 data->length = sizeof(struct iw_range);
754 memset(range, 0, sizeof(struct iw_range));
756 range->txpower_capa = IW_TXPOW_DBM;
758 if (INFRA_ON(pAdapter)||ADHOC_ON(pAdapter))
760 range->min_pmp = 1 * 1024;
761 range->max_pmp = 65535 * 1024;
762 range->min_pmt = 1 * 1024;
763 range->max_pmt = 1000 * 1024;
764 range->pmp_flags = IW_POWER_PERIOD;
765 range->pmt_flags = IW_POWER_TIMEOUT;
766 range->pm_capa = IW_POWER_PERIOD | IW_POWER_TIMEOUT |
767 IW_POWER_UNICAST_R | IW_POWER_ALL_R;
770 range->we_version_compiled = WIRELESS_EXT;
771 range->we_version_source = 14;
773 range->retry_capa = IW_RETRY_LIMIT;
774 range->retry_flags = IW_RETRY_LIMIT;
775 range->min_retry = 0;
776 range->max_retry = 255;
778 range->num_channels = pAdapter->ChannelListNum;
781 for (i = 1; i <= range->num_channels; i++)
784 range->freq[val].i = pAdapter->ChannelList[i-1].Channel;
785 MAP_CHANNEL_ID_TO_KHZ(pAdapter->ChannelList[i-1].Channel, m);
786 range->freq[val].m = m * 100; /* HZ */
788 range->freq[val].e = 1;
790 if (val == IW_MAX_FREQUENCIES)
793 range->num_frequency = val;
795 range->max_qual.qual = 100; /* what is correct max? This was not
796 * documented exactly. At least
797 * 69 has been observed. */
798 range->max_qual.level = 0; /* dB */
799 range->max_qual.noise = 0; /* dB */
801 /* What would be suitable values for "average/typical" qual? */
802 range->avg_qual.qual = 20;
803 range->avg_qual.level = -60;
804 range->avg_qual.noise = -95;
805 range->sensitivity = 3;
807 range->max_encoding_tokens = NR_WEP_KEYS;
808 range->num_encoding_sizes = 2;
809 range->encoding_size[0] = 5;
810 range->encoding_size[1] = 13;
813 range->max_rts = 2347;
814 range->min_frag = 256;
815 range->max_frag = 2346;
817 #if WIRELESS_EXT > 17
818 /* IW_ENC_CAPA_* bit field */
819 range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 |
820 IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP;
826 int rt_ioctl_siwap(struct net_device *dev,
827 struct iw_request_info *info,
828 struct sockaddr *ap_addr, char *extra)
830 PRTMP_ADAPTER pAdapter = dev->ml_priv;
831 NDIS_802_11_MAC_ADDRESS Bssid;
833 //check if the interface is down
834 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
836 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
840 if (pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE)
842 RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
843 DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
846 // tell CNTL state machine to call NdisMSetInformationComplete() after completing
847 // this request, because this request is initiated by NDIS.
848 pAdapter->MlmeAux.CurrReqIsFromNdis = FALSE;
849 // Prevent to connect AP again in STAMlmePeriodicExec
850 pAdapter->MlmeAux.AutoReconnectSsidLen= 32;
852 memset(Bssid, 0, MAC_ADDR_LEN);
853 memcpy(Bssid, ap_addr->sa_data, MAC_ADDR_LEN);
854 MlmeEnqueue(pAdapter,
855 MLME_CNTL_STATE_MACHINE,
857 sizeof(NDIS_802_11_MAC_ADDRESS),
860 DBGPRINT(RT_DEBUG_TRACE, ("IOCTL::SIOCSIWAP %02x:%02x:%02x:%02x:%02x:%02x\n",
861 Bssid[0], Bssid[1], Bssid[2], Bssid[3], Bssid[4], Bssid[5]));
866 int rt_ioctl_giwap(struct net_device *dev,
867 struct iw_request_info *info,
868 struct sockaddr *ap_addr, char *extra)
870 PRTMP_ADAPTER pAdapter = dev->ml_priv;
872 if (INFRA_ON(pAdapter) || ADHOC_ON(pAdapter))
874 ap_addr->sa_family = ARPHRD_ETHER;
875 memcpy(ap_addr->sa_data, &pAdapter->CommonCfg.Bssid, ETH_ALEN);
877 #ifdef WPA_SUPPLICANT_SUPPORT
879 else if (pAdapter->StaCfg.WpaSupplicantUP != WPA_SUPPLICANT_DISABLE)
881 ap_addr->sa_family = ARPHRD_ETHER;
882 memcpy(ap_addr->sa_data, &pAdapter->MlmeAux.Bssid, ETH_ALEN);
884 #endif // WPA_SUPPLICANT_SUPPORT //
887 DBGPRINT(RT_DEBUG_TRACE, ("IOCTL::SIOCGIWAP(=EMPTY)\n"));
895 * Units are in db above the noise floor. That means the
896 * rssi values reported in the tx/rx descriptors in the
897 * driver are the SNR expressed in db.
899 * If you assume that the noise floor is -95, which is an
900 * excellent assumption 99.5 % of the time, then you can
901 * derive the absolute signal level (i.e. -95 + rssi).
902 * There are some other slight factors to take into account
903 * depending on whether the rssi measurement is from 11b,
904 * 11g, or 11a. These differences are at most 2db and
907 * NB: various calculations are based on the orinoco/wavelan
908 * drivers for compatibility
910 static void set_quality(PRTMP_ADAPTER pAdapter,
911 struct iw_quality *iq,
918 ChannelQuality = 100;
919 else if (rssi >= -80) // between -50 ~ -80dbm
920 ChannelQuality = (__u8)(24 + ((rssi + 80) * 26)/10);
921 else if (rssi >= -90) // between -80 ~ -90dbm
922 ChannelQuality = (__u8)((rssi + 90) * 26)/10;
926 iq->qual = (__u8)ChannelQuality;
928 iq->level = (__u8)(rssi);
929 iq->noise = (pAdapter->BbpWriteLatch[66] > pAdapter->BbpTuning.FalseCcaUpperThreshold) ? ((__u8)pAdapter->BbpTuning.FalseCcaUpperThreshold) : ((__u8) pAdapter->BbpWriteLatch[66]); // noise level (dBm)
930 iq->noise += 256 - 143;
931 iq->updated = pAdapter->iw_stats.qual.updated;
934 int rt_ioctl_iwaplist(struct net_device *dev,
935 struct iw_request_info *info,
936 struct iw_point *data, char *extra)
938 PRTMP_ADAPTER pAdapter = dev->ml_priv;
940 struct sockaddr addr[IW_MAX_AP];
941 struct iw_quality qual[IW_MAX_AP];
944 //check if the interface is down
945 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
947 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
953 for (i = 0; i <IW_MAX_AP ; i++)
955 if (i >= pAdapter->ScanTab.BssNr)
957 addr[i].sa_family = ARPHRD_ETHER;
958 memcpy(addr[i].sa_data, &pAdapter->ScanTab.BssEntry[i].Bssid, MAC_ADDR_LEN);
959 set_quality(pAdapter, &qual[i], pAdapter->ScanTab.BssEntry[i].Rssi);
962 memcpy(extra, &addr, i*sizeof(addr[0]));
963 data->flags = 1; /* signal quality present (sort of) */
964 memcpy(extra + i*sizeof(addr[0]), &qual, i*sizeof(qual[i]));
970 int rt_ioctl_siwscan(struct net_device *dev,
971 struct iw_request_info *info,
972 struct iw_point *data, char *extra)
974 PRTMP_ADAPTER pAdapter = dev->ml_priv;
977 int Status = NDIS_STATUS_SUCCESS;
979 //check if the interface is down
980 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
982 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
986 if (MONITOR_ON(pAdapter))
988 DBGPRINT(RT_DEBUG_TRACE, ("!!! Driver is in Monitor Mode now !!!\n"));
993 #ifdef WPA_SUPPLICANT_SUPPORT
994 if (pAdapter->StaCfg.WpaSupplicantUP == WPA_SUPPLICANT_ENABLE)
996 pAdapter->StaCfg.WpaSupplicantScanCount++;
998 #endif // WPA_SUPPLICANT_SUPPORT //
1000 pAdapter->StaCfg.bScanReqIsFromWebUI = TRUE;
1001 if (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
1006 #ifdef WPA_SUPPLICANT_SUPPORT
1007 if ((pAdapter->StaCfg.WpaSupplicantUP == WPA_SUPPLICANT_ENABLE) &&
1008 (pAdapter->StaCfg.WpaSupplicantScanCount > 3))
1010 DBGPRINT(RT_DEBUG_TRACE, ("!!! WpaSupplicantScanCount > 3\n"));
1011 Status = NDIS_STATUS_SUCCESS;
1014 #endif // WPA_SUPPLICANT_SUPPORT //
1016 if ((OPSTATUS_TEST_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED)) &&
1017 ((pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA) ||
1018 (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK)) &&
1019 (pAdapter->StaCfg.PortSecured == WPA_802_1X_PORT_NOT_SECURED))
1021 DBGPRINT(RT_DEBUG_TRACE, ("!!! Link UP, Port Not Secured! ignore this set::OID_802_11_BSSID_LIST_SCAN\n"));
1022 Status = NDIS_STATUS_SUCCESS;
1026 if (pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE)
1028 RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
1029 DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
1032 // tell CNTL state machine to call NdisMSetInformationComplete() after completing
1033 // this request, because this request is initiated by NDIS.
1034 pAdapter->MlmeAux.CurrReqIsFromNdis = FALSE;
1035 // Reset allowed scan retries
1036 pAdapter->StaCfg.ScanCnt = 0;
1037 pAdapter->StaCfg.LastScanTime = Now;
1039 MlmeEnqueue(pAdapter,
1040 MLME_CNTL_STATE_MACHINE,
1041 OID_802_11_BSSID_LIST_SCAN,
1045 Status = NDIS_STATUS_SUCCESS;
1046 RT28XX_MLME_HANDLER(pAdapter);
1051 int rt_ioctl_giwscan(struct net_device *dev,
1052 struct iw_request_info *info,
1053 struct iw_point *data, char *extra)
1056 PRTMP_ADAPTER pAdapter = dev->ml_priv;
1058 char *current_ev = extra, *previous_ev = extra;
1060 char *current_val, custom[MAX_CUSTOM_LEN] = {0};
1063 #endif // IWEVGENIE //
1064 struct iw_event iwe;
1066 if (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
1069 * Still scanning, indicate the caller should try again.
1075 #ifdef WPA_SUPPLICANT_SUPPORT
1076 if (pAdapter->StaCfg.WpaSupplicantUP == WPA_SUPPLICANT_ENABLE)
1078 pAdapter->StaCfg.WpaSupplicantScanCount = 0;
1080 #endif // WPA_SUPPLICANT_SUPPORT //
1082 if (pAdapter->ScanTab.BssNr == 0)
1088 #if WIRELESS_EXT >= 17
1089 if (data->length > 0)
1090 end_buf = extra + data->length;
1092 end_buf = extra + IW_SCAN_MAX_DATA;
1094 end_buf = extra + IW_SCAN_MAX_DATA;
1097 for (i = 0; i < pAdapter->ScanTab.BssNr; i++)
1099 if (current_ev >= end_buf)
1101 #if WIRELESS_EXT >= 17
1109 //================================
1110 memset(&iwe, 0, sizeof(iwe));
1111 iwe.cmd = SIOCGIWAP;
1112 iwe.u.ap_addr.sa_family = ARPHRD_ETHER;
1113 memcpy(iwe.u.ap_addr.sa_data, &pAdapter->ScanTab.BssEntry[i].Bssid, ETH_ALEN);
1115 previous_ev = current_ev;
1116 current_ev = iwe_stream_add_event(info, current_ev, end_buf, &iwe, IW_EV_ADDR_LEN);
1117 if (current_ev == previous_ev)
1118 #if WIRELESS_EXT >= 17
1126 it will show scanned AP's WirelessMode .
1135 memset(&iwe, 0, sizeof(iwe));
1136 iwe.cmd = SIOCGIWNAME;
1140 PBSS_ENTRY pBssEntry=&pAdapter->ScanTab.BssEntry[i];
1141 BOOLEAN isGonly=FALSE;
1144 if (pBssEntry->Channel>14)
1146 if (pBssEntry->HtCapabilityLen!=0)
1147 strcpy(iwe.u.name,"802.11a/n");
1149 strcpy(iwe.u.name,"802.11a");
1154 if one of non B mode rate is set supported rate . it mean G only.
1156 for (rateCnt=0;rateCnt<pBssEntry->SupRateLen;rateCnt++)
1159 6Mbps(140) 9Mbps(146) and >=12Mbps(152) are supported rate , it mean G only.
1161 if (pBssEntry->SupRate[rateCnt]==140 || pBssEntry->SupRate[rateCnt]==146 || pBssEntry->SupRate[rateCnt]>=152)
1165 for (rateCnt=0;rateCnt<pBssEntry->ExtRateLen;rateCnt++)
1167 if (pBssEntry->ExtRate[rateCnt]==140 || pBssEntry->ExtRate[rateCnt]==146 || pBssEntry->ExtRate[rateCnt]>=152)
1172 if (pBssEntry->HtCapabilityLen!=0)
1175 strcpy(iwe.u.name,"802.11g/n");
1177 strcpy(iwe.u.name,"802.11b/g/n");
1182 strcpy(iwe.u.name,"802.11g");
1185 if (pBssEntry->SupRateLen==4 && pBssEntry->ExtRateLen==0)
1186 strcpy(iwe.u.name,"802.11b");
1188 strcpy(iwe.u.name,"802.11b/g");
1194 previous_ev = current_ev;
1195 current_ev = iwe_stream_add_event(info, current_ev, end_buf, &iwe, IW_EV_ADDR_LEN);
1196 if (current_ev == previous_ev)
1197 #if WIRELESS_EXT >= 17
1204 //================================
1205 memset(&iwe, 0, sizeof(iwe));
1206 iwe.cmd = SIOCGIWESSID;
1207 iwe.u.data.length = pAdapter->ScanTab.BssEntry[i].SsidLen;
1208 iwe.u.data.flags = 1;
1210 previous_ev = current_ev;
1211 current_ev = iwe_stream_add_point(info, current_ev, end_buf, &iwe, pAdapter->ScanTab.BssEntry[i].Ssid);
1212 if (current_ev == previous_ev)
1213 #if WIRELESS_EXT >= 17
1220 //================================
1221 memset(&iwe, 0, sizeof(iwe));
1222 iwe.cmd = SIOCGIWMODE;
1223 if (pAdapter->ScanTab.BssEntry[i].BssType == Ndis802_11IBSS)
1225 iwe.u.mode = IW_MODE_ADHOC;
1227 else if (pAdapter->ScanTab.BssEntry[i].BssType == Ndis802_11Infrastructure)
1229 iwe.u.mode = IW_MODE_INFRA;
1233 iwe.u.mode = IW_MODE_AUTO;
1235 iwe.len = IW_EV_UINT_LEN;
1237 previous_ev = current_ev;
1238 current_ev = iwe_stream_add_event(info, current_ev, end_buf, &iwe, IW_EV_UINT_LEN);
1239 if (current_ev == previous_ev)
1240 #if WIRELESS_EXT >= 17
1246 //Channel and Frequency
1247 //================================
1248 memset(&iwe, 0, sizeof(iwe));
1249 iwe.cmd = SIOCGIWFREQ;
1250 if (INFRA_ON(pAdapter) || ADHOC_ON(pAdapter))
1251 iwe.u.freq.m = pAdapter->ScanTab.BssEntry[i].Channel;
1253 iwe.u.freq.m = pAdapter->ScanTab.BssEntry[i].Channel;
1257 previous_ev = current_ev;
1258 current_ev = iwe_stream_add_event(info, current_ev, end_buf, &iwe, IW_EV_FREQ_LEN);
1259 if (current_ev == previous_ev)
1260 #if WIRELESS_EXT >= 17
1266 //Add quality statistics
1267 //================================
1268 memset(&iwe, 0, sizeof(iwe));
1270 iwe.u.qual.level = 0;
1271 iwe.u.qual.noise = 0;
1272 set_quality(pAdapter, &iwe.u.qual, pAdapter->ScanTab.BssEntry[i].Rssi);
1273 current_ev = iwe_stream_add_event(info, current_ev, end_buf, &iwe, IW_EV_QUAL_LEN);
1274 if (current_ev == previous_ev)
1275 #if WIRELESS_EXT >= 17
1282 //================================
1283 memset(&iwe, 0, sizeof(iwe));
1284 iwe.cmd = SIOCGIWENCODE;
1285 if (CAP_IS_PRIVACY_ON (pAdapter->ScanTab.BssEntry[i].CapabilityInfo ))
1286 iwe.u.data.flags =IW_ENCODE_ENABLED | IW_ENCODE_NOKEY;
1288 iwe.u.data.flags = IW_ENCODE_DISABLED;
1290 previous_ev = current_ev;
1291 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);
1292 if (current_ev == previous_ev)
1293 #if WIRELESS_EXT >= 17
1300 //================================
1301 if (pAdapter->ScanTab.BssEntry[i].SupRateLen)
1303 UCHAR tmpRate = pAdapter->ScanTab.BssEntry[i].SupRate[pAdapter->ScanTab.BssEntry[i].SupRateLen-1];
1304 memset(&iwe, 0, sizeof(iwe));
1305 iwe.cmd = SIOCGIWRATE;
1306 current_val = current_ev + IW_EV_LCP_LEN;
1307 if (tmpRate == 0x82)
1308 iwe.u.bitrate.value = 1 * 1000000;
1309 else if (tmpRate == 0x84)
1310 iwe.u.bitrate.value = 2 * 1000000;
1311 else if (tmpRate == 0x8B)
1312 iwe.u.bitrate.value = 5.5 * 1000000;
1313 else if (tmpRate == 0x96)
1314 iwe.u.bitrate.value = 11 * 1000000;
1316 iwe.u.bitrate.value = (tmpRate/2) * 1000000;
1318 iwe.u.bitrate.disabled = 0;
1319 current_val = iwe_stream_add_value(info, current_ev,
1320 current_val, end_buf, &iwe,
1323 if((current_val-current_ev)>IW_EV_LCP_LEN)
1324 current_ev = current_val;
1326 #if WIRELESS_EXT >= 17
1335 if (pAdapter->ScanTab.BssEntry[i].WpaIE.IELen > 0)
1337 memset(&iwe, 0, sizeof(iwe));
1338 memset(&custom[0], 0, MAX_CUSTOM_LEN);
1339 memcpy(custom, &(pAdapter->ScanTab.BssEntry[i].WpaIE.IE[0]),
1340 pAdapter->ScanTab.BssEntry[i].WpaIE.IELen);
1341 iwe.cmd = IWEVGENIE;
1342 iwe.u.data.length = pAdapter->ScanTab.BssEntry[i].WpaIE.IELen;
1343 current_ev = iwe_stream_add_point(info, current_ev, end_buf, &iwe, custom);
1344 if (current_ev == previous_ev)
1345 #if WIRELESS_EXT >= 17
1353 if (pAdapter->ScanTab.BssEntry[i].RsnIE.IELen > 0)
1355 memset(&iwe, 0, sizeof(iwe));
1356 memset(&custom[0], 0, MAX_CUSTOM_LEN);
1357 memcpy(custom, &(pAdapter->ScanTab.BssEntry[i].RsnIE.IE[0]),
1358 pAdapter->ScanTab.BssEntry[i].RsnIE.IELen);
1359 iwe.cmd = IWEVGENIE;
1360 iwe.u.data.length = pAdapter->ScanTab.BssEntry[i].RsnIE.IELen;
1361 current_ev = iwe_stream_add_point(info, current_ev, end_buf, &iwe, custom);
1362 if (current_ev == previous_ev)
1363 #if WIRELESS_EXT >= 17
1371 //================================
1372 if (pAdapter->ScanTab.BssEntry[i].WpaIE.IELen > 0)
1374 NdisZeroMemory(&iwe, sizeof(iwe));
1375 memset(&custom[0], 0, MAX_CUSTOM_LEN);
1376 iwe.cmd = IWEVCUSTOM;
1377 iwe.u.data.length = (pAdapter->ScanTab.BssEntry[i].WpaIE.IELen * 2) + 7;
1378 NdisMoveMemory(custom, "wpa_ie=", 7);
1379 for (idx = 0; idx < pAdapter->ScanTab.BssEntry[i].WpaIE.IELen; idx++)
1380 sprintf(custom, "%s%02x", custom, pAdapter->ScanTab.BssEntry[i].WpaIE.IE[idx]);
1381 previous_ev = current_ev;
1382 current_ev = iwe_stream_add_point(current_ev, end_buf, &iwe, custom);
1383 if (current_ev == previous_ev)
1384 #if WIRELESS_EXT >= 17
1392 if (pAdapter->ScanTab.BssEntry[i].RsnIE.IELen > 0)
1394 NdisZeroMemory(&iwe, sizeof(iwe));
1395 memset(&custom[0], 0, MAX_CUSTOM_LEN);
1396 iwe.cmd = IWEVCUSTOM;
1397 iwe.u.data.length = (pAdapter->ScanTab.BssEntry[i].RsnIE.IELen * 2) + 7;
1398 NdisMoveMemory(custom, "rsn_ie=", 7);
1399 for (idx = 0; idx < pAdapter->ScanTab.BssEntry[i].RsnIE.IELen; idx++)
1400 sprintf(custom, "%s%02x", custom, pAdapter->ScanTab.BssEntry[i].RsnIE.IE[idx]);
1401 previous_ev = current_ev;
1402 current_ev = iwe_stream_add_point(current_ev, end_buf, &iwe, custom);
1403 if (current_ev == previous_ev)
1404 #if WIRELESS_EXT >= 17
1410 #endif // IWEVGENIE //
1413 data->length = current_ev - extra;
1414 pAdapter->StaCfg.bScanReqIsFromWebUI = FALSE;
1415 DBGPRINT(RT_DEBUG_ERROR ,("===>rt_ioctl_giwscan. %d(%d) BSS returned, data->length = %d\n",i , pAdapter->ScanTab.BssNr, data->length));
1420 int rt_ioctl_siwessid(struct net_device *dev,
1421 struct iw_request_info *info,
1422 struct iw_point *data, char *essid)
1424 PRTMP_ADAPTER pAdapter = dev->ml_priv;
1426 //check if the interface is down
1427 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1429 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1435 PCHAR pSsidString = NULL;
1437 // Includes null character.
1438 if (data->length > (IW_ESSID_MAX_SIZE + 1))
1441 pSsidString = (CHAR *) kmalloc(MAX_LEN_OF_SSID+1, MEM_ALLOC_FLAG);
1444 NdisZeroMemory(pSsidString, MAX_LEN_OF_SSID+1);
1445 NdisMoveMemory(pSsidString, essid, data->length);
1446 if (Set_SSID_Proc(pAdapter, pSsidString) == FALSE)
1455 if (Set_SSID_Proc(pAdapter, "") == FALSE)
1461 int rt_ioctl_giwessid(struct net_device *dev,
1462 struct iw_request_info *info,
1463 struct iw_point *data, char *essid)
1465 PRTMP_ADAPTER pAdapter = dev->ml_priv;
1468 if (MONITOR_ON(pAdapter))
1474 if (OPSTATUS_TEST_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED))
1476 DBGPRINT(RT_DEBUG_TRACE ,("MediaState is connected\n"));
1477 data->length = pAdapter->CommonCfg.SsidLen;
1478 memcpy(essid, pAdapter->CommonCfg.Ssid, pAdapter->CommonCfg.SsidLen);
1481 #ifdef WPA_SUPPLICANT_SUPPORT
1483 else if (pAdapter->StaCfg.WpaSupplicantUP != WPA_SUPPLICANT_DISABLE)
1485 data->length = pAdapter->CommonCfg.SsidLen;
1486 memcpy(essid, pAdapter->CommonCfg.Ssid, pAdapter->CommonCfg.SsidLen);
1488 #endif // WPA_SUPPLICANT_SUPPORT //
1491 {//the ANY ssid was specified
1493 DBGPRINT(RT_DEBUG_TRACE ,("MediaState is not connected, ess\n"));
1500 int rt_ioctl_siwnickn(struct net_device *dev,
1501 struct iw_request_info *info,
1502 struct iw_point *data, char *nickname)
1504 PRTMP_ADAPTER pAdapter = dev->ml_priv;
1506 //check if the interface is down
1507 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1509 DBGPRINT(RT_DEBUG_TRACE ,("INFO::Network is down!\n"));
1513 if (data->length > IW_ESSID_MAX_SIZE)
1516 memset(pAdapter->nickname, 0, IW_ESSID_MAX_SIZE + 1);
1517 memcpy(pAdapter->nickname, nickname, data->length);
1523 int rt_ioctl_giwnickn(struct net_device *dev,
1524 struct iw_request_info *info,
1525 struct iw_point *data, char *nickname)
1527 PRTMP_ADAPTER pAdapter = dev->ml_priv;
1529 if (data->length > strlen(pAdapter->nickname) + 1)
1530 data->length = strlen(pAdapter->nickname) + 1;
1531 if (data->length > 0) {
1532 memcpy(nickname, pAdapter->nickname, data->length-1);
1533 nickname[data->length-1] = '\0';
1538 int rt_ioctl_siwrts(struct net_device *dev,
1539 struct iw_request_info *info,
1540 struct iw_param *rts, char *extra)
1542 PRTMP_ADAPTER pAdapter = dev->ml_priv;
1545 //check if the interface is down
1546 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1548 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1553 val = MAX_RTS_THRESHOLD;
1554 else if (rts->value < 0 || rts->value > MAX_RTS_THRESHOLD)
1556 else if (rts->value == 0)
1557 val = MAX_RTS_THRESHOLD;
1561 if (val != pAdapter->CommonCfg.RtsThreshold)
1562 pAdapter->CommonCfg.RtsThreshold = val;
1567 int rt_ioctl_giwrts(struct net_device *dev,
1568 struct iw_request_info *info,
1569 struct iw_param *rts, char *extra)
1571 PRTMP_ADAPTER pAdapter = dev->ml_priv;
1573 //check if the interface is down
1574 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1576 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1580 rts->value = pAdapter->CommonCfg.RtsThreshold;
1581 rts->disabled = (rts->value == MAX_RTS_THRESHOLD);
1587 int rt_ioctl_siwfrag(struct net_device *dev,
1588 struct iw_request_info *info,
1589 struct iw_param *frag, char *extra)
1591 PRTMP_ADAPTER pAdapter = dev->ml_priv;
1594 //check if the interface is down
1595 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1597 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1602 val = MAX_FRAG_THRESHOLD;
1603 else if (frag->value >= MIN_FRAG_THRESHOLD || frag->value <= MAX_FRAG_THRESHOLD)
1604 val = __cpu_to_le16(frag->value & ~0x1); /* even numbers only */
1605 else if (frag->value == 0)
1606 val = MAX_FRAG_THRESHOLD;
1610 pAdapter->CommonCfg.FragmentThreshold = val;
1614 int rt_ioctl_giwfrag(struct net_device *dev,
1615 struct iw_request_info *info,
1616 struct iw_param *frag, char *extra)
1618 PRTMP_ADAPTER pAdapter = dev->ml_priv;
1620 //check if the interface is down
1621 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1623 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1627 frag->value = pAdapter->CommonCfg.FragmentThreshold;
1628 frag->disabled = (frag->value == MAX_FRAG_THRESHOLD);
1634 #define MAX_WEP_KEY_SIZE 13
1635 #define MIN_WEP_KEY_SIZE 5
1636 int rt_ioctl_siwencode(struct net_device *dev,
1637 struct iw_request_info *info,
1638 struct iw_point *erq, char *extra)
1640 PRTMP_ADAPTER pAdapter = dev->ml_priv;
1642 //check if the interface is down
1643 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1645 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1649 if ((erq->length == 0) &&
1650 (erq->flags & IW_ENCODE_DISABLED))
1652 pAdapter->StaCfg.PairCipher = Ndis802_11WEPDisabled;
1653 pAdapter->StaCfg.GroupCipher = Ndis802_11WEPDisabled;
1654 pAdapter->StaCfg.WepStatus = Ndis802_11WEPDisabled;
1655 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
1656 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
1659 else if (erq->flags & IW_ENCODE_RESTRICTED || erq->flags & IW_ENCODE_OPEN)
1661 //pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
1662 STA_PORT_SECURED(pAdapter);
1663 pAdapter->StaCfg.PairCipher = Ndis802_11WEPEnabled;
1664 pAdapter->StaCfg.GroupCipher = Ndis802_11WEPEnabled;
1665 pAdapter->StaCfg.WepStatus = Ndis802_11WEPEnabled;
1666 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
1667 if (erq->flags & IW_ENCODE_RESTRICTED)
1668 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeShared;
1670 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
1673 if (erq->length > 0)
1675 int keyIdx = (erq->flags & IW_ENCODE_INDEX) - 1;
1676 /* Check the size of the key */
1677 if (erq->length > MAX_WEP_KEY_SIZE)
1681 /* Check key index */
1682 if ((keyIdx < 0) || (keyIdx >= NR_WEP_KEYS))
1684 DBGPRINT(RT_DEBUG_TRACE ,("==>rt_ioctl_siwencode::Wrong keyIdx=%d! Using default key instead (%d)\n",
1685 keyIdx, pAdapter->StaCfg.DefaultKeyId));
1688 keyIdx = pAdapter->StaCfg.DefaultKeyId;
1692 pAdapter->StaCfg.DefaultKeyId=keyIdx;
1695 NdisZeroMemory(pAdapter->SharedKey[BSS0][keyIdx].Key, 16);
1697 if (erq->length == MAX_WEP_KEY_SIZE)
1699 pAdapter->SharedKey[BSS0][keyIdx].KeyLen = MAX_WEP_KEY_SIZE;
1700 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CIPHER_WEP128;
1702 else if (erq->length == MIN_WEP_KEY_SIZE)
1704 pAdapter->SharedKey[BSS0][keyIdx].KeyLen = MIN_WEP_KEY_SIZE;
1705 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CIPHER_WEP64;
1708 /* Disable the key */
1709 pAdapter->SharedKey[BSS0][keyIdx].KeyLen = 0;
1711 /* Check if the key is not marked as invalid */
1712 if(!(erq->flags & IW_ENCODE_NOKEY))
1714 /* Copy the key in the driver */
1715 NdisMoveMemory(pAdapter->SharedKey[BSS0][keyIdx].Key, extra, erq->length);
1720 /* Do we want to just set the transmit key index ? */
1721 int index = (erq->flags & IW_ENCODE_INDEX) - 1;
1722 if ((index >= 0) && (index < 4))
1724 pAdapter->StaCfg.DefaultKeyId = index;
1727 /* Don't complain if only change the mode */
1728 if (!(erq->flags & IW_ENCODE_MODE))
1733 DBGPRINT(RT_DEBUG_TRACE ,("==>rt_ioctl_siwencode::erq->flags=%x\n",erq->flags));
1734 DBGPRINT(RT_DEBUG_TRACE ,("==>rt_ioctl_siwencode::AuthMode=%x\n",pAdapter->StaCfg.AuthMode));
1735 DBGPRINT(RT_DEBUG_TRACE ,("==>rt_ioctl_siwencode::DefaultKeyId=%x, KeyLen = %d\n",pAdapter->StaCfg.DefaultKeyId , pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].KeyLen));
1736 DBGPRINT(RT_DEBUG_TRACE ,("==>rt_ioctl_siwencode::WepStatus=%x\n",pAdapter->StaCfg.WepStatus));
1741 rt_ioctl_giwencode(struct net_device *dev,
1742 struct iw_request_info *info,
1743 struct iw_point *erq, char *key)
1745 PRTMP_ADAPTER pAdapter = dev->ml_priv;
1748 //check if the interface is down
1749 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1751 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1755 kid = erq->flags & IW_ENCODE_INDEX;
1756 DBGPRINT(RT_DEBUG_TRACE, ("===>rt_ioctl_giwencode %d\n", erq->flags & IW_ENCODE_INDEX));
1758 if (pAdapter->StaCfg.WepStatus == Ndis802_11WEPDisabled)
1761 erq->flags = IW_ENCODE_DISABLED;
1763 else if ((kid > 0) && (kid <=4))
1766 erq->flags = kid ; /* NB: base 1 */
1767 if (erq->length > pAdapter->SharedKey[BSS0][kid-1].KeyLen)
1768 erq->length = pAdapter->SharedKey[BSS0][kid-1].KeyLen;
1769 memcpy(key, pAdapter->SharedKey[BSS0][kid-1].Key, erq->length);
1770 //if ((kid == pAdapter->PortCfg.DefaultKeyId))
1771 //erq->flags |= IW_ENCODE_ENABLED; /* XXX */
1772 if (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeShared)
1773 erq->flags |= IW_ENCODE_RESTRICTED; /* XXX */
1775 erq->flags |= IW_ENCODE_OPEN; /* XXX */
1780 if (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeShared)
1781 erq->flags |= IW_ENCODE_RESTRICTED; /* XXX */
1783 erq->flags |= IW_ENCODE_OPEN; /* XXX */
1784 erq->length = pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].KeyLen;
1785 memcpy(key, pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].Key, erq->length);
1786 // copy default key ID
1787 if (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeShared)
1788 erq->flags |= IW_ENCODE_RESTRICTED; /* XXX */
1790 erq->flags |= IW_ENCODE_OPEN; /* XXX */
1791 erq->flags = pAdapter->StaCfg.DefaultKeyId + 1; /* NB: base 1 */
1792 erq->flags |= IW_ENCODE_ENABLED; /* XXX */
1800 rt_ioctl_setparam(struct net_device *dev, struct iw_request_info *info,
1801 void *w, char *extra)
1803 VIRTUAL_ADAPTER *pVirtualAd = NULL;
1804 PRTMP_ADAPTER pAdapter;
1806 char *this_char = extra;
1810 if (dev->priv_flags == INT_MAIN)
1812 pAdapter = dev->ml_priv;
1816 pVirtualAd = dev->ml_priv;
1817 pAdapter = pVirtualAd->RtmpDev->ml_priv;
1819 pObj = (POS_COOKIE) pAdapter->OS_Cookie;
1821 if (pAdapter == NULL)
1823 /* if 1st open fail, pAd will be free;
1824 So the net_dev->ml_priv will be NULL in 2rd open */
1829 pObj->ioctl_if_type = INT_MAIN;
1830 pObj->ioctl_if = MAIN_MBSSID;
1833 //check if the interface is down
1834 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1836 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1843 if ((value = rtstrchr(this_char, '=')) != NULL)
1849 // reject setting nothing besides ANY ssid(ssidLen=0)
1850 if (!*value && (strcmp(this_char, "SSID") != 0))
1853 for (PRTMP_PRIVATE_SET_PROC = RTMP_PRIVATE_SUPPORT_PROC; PRTMP_PRIVATE_SET_PROC->name; PRTMP_PRIVATE_SET_PROC++)
1855 if (strcmp(this_char, PRTMP_PRIVATE_SET_PROC->name) == 0)
1857 if(!PRTMP_PRIVATE_SET_PROC->set_proc(pAdapter, value))
1858 { //FALSE:Set private failed then return Invalid argument
1861 break; //Exit for loop.
1865 if(PRTMP_PRIVATE_SET_PROC->name == NULL)
1866 { //Not found argument
1868 DBGPRINT(RT_DEBUG_TRACE, ("===>rt_ioctl_setparam:: (iwpriv) Not Support Set Command [%s=%s]\n", this_char, value));
1876 rt_private_get_statistics(struct net_device *dev, struct iw_request_info *info,
1877 struct iw_point *wrq, char *extra)
1880 PRTMP_ADAPTER pAd = dev->ml_priv;
1888 memset(extra, 0x00, IW_PRIV_SIZE_MASK);
1889 sprintf(extra, "\n\n");
1894 sprintf(extra+strlen(extra), "Tx success = %ld\n", (ULONG)pAd->ate.TxDoneCount);
1895 //sprintf(extra+strlen(extra), "Tx success without retry = %ld\n", (ULONG)pAd->ate.TxDoneCount);
1898 #endif // RALINK_ATE //
1900 sprintf(extra+strlen(extra), "Tx success = %ld\n", (ULONG)pAd->WlanCounters.TransmittedFragmentCount.QuadPart);
1901 sprintf(extra+strlen(extra), "Tx success without retry = %ld\n", (ULONG)pAd->WlanCounters.TransmittedFragmentCount.QuadPart - (ULONG)pAd->WlanCounters.RetryCount.QuadPart);
1903 sprintf(extra+strlen(extra), "Tx success after retry = %ld\n", (ULONG)pAd->WlanCounters.RetryCount.QuadPart);
1904 sprintf(extra+strlen(extra), "Tx fail to Rcv ACK after retry = %ld\n", (ULONG)pAd->WlanCounters.FailedCount.QuadPart);
1905 sprintf(extra+strlen(extra), "RTS Success Rcv CTS = %ld\n", (ULONG)pAd->WlanCounters.RTSSuccessCount.QuadPart);
1906 sprintf(extra+strlen(extra), "RTS Fail Rcv CTS = %ld\n", (ULONG)pAd->WlanCounters.RTSFailureCount.QuadPart);
1908 sprintf(extra+strlen(extra), "Rx success = %ld\n", (ULONG)pAd->WlanCounters.ReceivedFragmentCount.QuadPart);
1909 sprintf(extra+strlen(extra), "Rx with CRC = %ld\n", (ULONG)pAd->WlanCounters.FCSErrorCount.QuadPart);
1910 sprintf(extra+strlen(extra), "Rx drop due to out of resource = %ld\n", (ULONG)pAd->Counters8023.RxNoBuffer);
1911 sprintf(extra+strlen(extra), "Rx duplicate frame = %ld\n", (ULONG)pAd->WlanCounters.FrameDuplicateCount.QuadPart);
1913 sprintf(extra+strlen(extra), "False CCA (one second) = %ld\n", (ULONG)pAd->RalinkCounters.OneSecFalseCCACnt);
1917 if (pAd->ate.RxAntennaSel == 0)
1919 sprintf(extra+strlen(extra), "RSSI-A = %ld\n", (LONG)(pAd->ate.LastRssi0 - pAd->BbpRssiToDbmDelta));
1920 sprintf(extra+strlen(extra), "RSSI-B (if available) = %ld\n", (LONG)(pAd->ate.LastRssi1 - pAd->BbpRssiToDbmDelta));
1921 sprintf(extra+strlen(extra), "RSSI-C (if available) = %ld\n\n", (LONG)(pAd->ate.LastRssi2 - pAd->BbpRssiToDbmDelta));
1925 sprintf(extra+strlen(extra), "RSSI = %ld\n", (LONG)(pAd->ate.LastRssi0 - pAd->BbpRssiToDbmDelta));
1929 #endif // RALINK_ATE //
1931 sprintf(extra+strlen(extra), "RSSI-A = %ld\n", (LONG)(pAd->StaCfg.RssiSample.LastRssi0 - pAd->BbpRssiToDbmDelta));
1932 sprintf(extra+strlen(extra), "RSSI-B (if available) = %ld\n", (LONG)(pAd->StaCfg.RssiSample.LastRssi1 - pAd->BbpRssiToDbmDelta));
1933 sprintf(extra+strlen(extra), "RSSI-C (if available) = %ld\n\n", (LONG)(pAd->StaCfg.RssiSample.LastRssi2 - pAd->BbpRssiToDbmDelta));
1935 #ifdef WPA_SUPPLICANT_SUPPORT
1936 sprintf(extra+strlen(extra), "WpaSupplicantUP = %d\n\n", pAd->StaCfg.WpaSupplicantUP);
1937 #endif // WPA_SUPPLICANT_SUPPORT //
1940 wrq->length = strlen(extra) + 1; // 1: size of '\0'
1941 DBGPRINT(RT_DEBUG_TRACE, ("<== rt_private_get_statistics, wrq->length = %d\n", wrq->length));
1946 #ifdef DOT11_N_SUPPORT
1948 IN PRTMP_ADAPTER pAd,
1952 BA_ORI_ENTRY *pOriBAEntry;
1953 BA_REC_ENTRY *pRecBAEntry;
1955 for (i=0; i<MAX_LEN_OF_MAC_TABLE; i++)
1957 PMAC_TABLE_ENTRY pEntry = &pAd->MacTab.Content[i];
1958 if (((pEntry->ValidAsCLI || pEntry->ValidAsApCli) && (pEntry->Sst == SST_ASSOC))
1959 || (pEntry->ValidAsWDS) || (pEntry->ValidAsMesh))
1961 sprintf(pOutBuf, "%s\n%02X:%02X:%02X:%02X:%02X:%02X (Aid = %d) (AP) -\n",
1963 pEntry->Addr[0], pEntry->Addr[1], pEntry->Addr[2],
1964 pEntry->Addr[3], pEntry->Addr[4], pEntry->Addr[5], pEntry->Aid);
1966 sprintf(pOutBuf, "%s[Recipient]\n", pOutBuf);
1967 for (j=0; j < NUM_OF_TID; j++)
1969 if (pEntry->BARecWcidArray[j] != 0)
1971 pRecBAEntry =&pAd->BATable.BARecEntry[pEntry->BARecWcidArray[j]];
1972 sprintf(pOutBuf, "%sTID=%d, BAWinSize=%d, LastIndSeq=%d, ReorderingPkts=%d\n", pOutBuf, j, pRecBAEntry->BAWinSize, pRecBAEntry->LastIndSeq, pRecBAEntry->list.qlen);
1975 sprintf(pOutBuf, "%s\n", pOutBuf);
1977 sprintf(pOutBuf, "%s[Originator]\n", pOutBuf);
1978 for (j=0; j < NUM_OF_TID; j++)
1980 if (pEntry->BAOriWcidArray[j] != 0)
1982 pOriBAEntry =&pAd->BATable.BAOriEntry[pEntry->BAOriWcidArray[j]];
1983 sprintf(pOutBuf, "%sTID=%d, BAWinSize=%d, StartSeq=%d, CurTxSeq=%d\n", pOutBuf, j, pOriBAEntry->BAWinSize, pOriBAEntry->Sequence, pEntry->TxSeq[j]);
1986 sprintf(pOutBuf, "%s\n\n", pOutBuf);
1988 if (strlen(pOutBuf) > (IW_PRIV_SIZE_MASK - 30))
1994 #endif // DOT11_N_SUPPORT //
1997 rt_private_show(struct net_device *dev, struct iw_request_info *info,
1998 struct iw_point *wrq, char *extra)
2001 VIRTUAL_ADAPTER *pVirtualAd = NULL;
2004 u32 subcmd = wrq->flags;
2006 if (dev->priv_flags == INT_MAIN)
2010 pVirtualAd = dev->ml_priv;
2011 pAd = pVirtualAd->RtmpDev->ml_priv;
2013 pObj = (POS_COOKIE) pAd->OS_Cookie;
2017 /* if 1st open fail, pAd will be free;
2018 So the net_dev->ml_priv will be NULL in 2rd open */
2027 memset(extra, 0x00, IW_PRIV_SIZE_MASK);
2030 pObj->ioctl_if_type = INT_MAIN;
2031 pObj->ioctl_if = MAIN_MBSSID;
2037 case SHOW_CONN_STATUS:
2038 if (MONITOR_ON(pAd))
2040 #ifdef DOT11_N_SUPPORT
2041 if (pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED &&
2042 pAd->CommonCfg.RegTransmitSetting.field.BW)
2043 sprintf(extra, "Monitor Mode(CentralChannel %d)\n", pAd->CommonCfg.CentralChannel);
2045 #endif // DOT11_N_SUPPORT //
2046 sprintf(extra, "Monitor Mode(Channel %d)\n", pAd->CommonCfg.Channel);
2050 if (pAd->IndicateMediaState == NdisMediaStateConnected)
2054 sprintf(extra, "Connected(AP: %s[%02X:%02X:%02X:%02X:%02X:%02X])\n",
2055 pAd->CommonCfg.Ssid,
2056 pAd->CommonCfg.Bssid[0],
2057 pAd->CommonCfg.Bssid[1],
2058 pAd->CommonCfg.Bssid[2],
2059 pAd->CommonCfg.Bssid[3],
2060 pAd->CommonCfg.Bssid[4],
2061 pAd->CommonCfg.Bssid[5]);
2062 DBGPRINT(RT_DEBUG_TRACE ,("Ssid=%s ,Ssidlen = %d\n",pAd->CommonCfg.Ssid, pAd->CommonCfg.SsidLen));
2064 else if (ADHOC_ON(pAd))
2065 sprintf(extra, "Connected\n");
2069 sprintf(extra, "Disconnected\n");
2070 DBGPRINT(RT_DEBUG_TRACE ,("ConnStatus is not connected\n"));
2073 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2075 case SHOW_DRVIER_VERION:
2076 sprintf(extra, "Driver version-%s, %s %s\n", STA_DRIVER_VERSION, __DATE__, __TIME__ );
2077 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2079 #ifdef DOT11_N_SUPPORT
2081 getBaInfo(pAd, extra);
2082 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2084 #endif // DOT11_N_SUPPORT //
2085 case SHOW_DESC_INFO:
2087 Show_DescInfo_Proc(pAd, NULL);
2088 wrq->length = 0; // 1: size of '\0'
2092 if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
2094 sprintf(extra, "Scanning\n");
2095 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2098 pAd->StaCfg.bSwRadio = FALSE;
2099 if (pAd->StaCfg.bRadio != (pAd->StaCfg.bHwRadio && pAd->StaCfg.bSwRadio))
2101 pAd->StaCfg.bRadio = (pAd->StaCfg.bHwRadio && pAd->StaCfg.bSwRadio);
2102 if (pAd->StaCfg.bRadio == FALSE)
2105 // Update extra information
2106 pAd->ExtraInfo = SW_RADIO_OFF;
2109 sprintf(extra, "Radio Off\n");
2110 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2113 if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
2115 sprintf(extra, "Scanning\n");
2116 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2119 pAd->StaCfg.bSwRadio = TRUE;
2120 //if (pAd->StaCfg.bRadio != (pAd->StaCfg.bHwRadio && pAd->StaCfg.bSwRadio))
2122 pAd->StaCfg.bRadio = (pAd->StaCfg.bHwRadio && pAd->StaCfg.bSwRadio);
2123 if (pAd->StaCfg.bRadio == TRUE)
2126 // Update extra information
2127 pAd->ExtraInfo = EXTRA_INFO_CLEAR;
2130 sprintf(extra, "Radio On\n");
2131 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2135 #ifdef QOS_DLS_SUPPORT
2136 case SHOW_DLS_ENTRY_INFO:
2138 Set_DlsEntryInfo_Display_Proc(pAd, NULL);
2139 wrq->length = 0; // 1: size of '\0'
2142 #endif // QOS_DLS_SUPPORT //
2144 case SHOW_CFG_VALUE:
2146 Status = RTMPShowCfgValue(pAd, wrq->pointer, extra);
2148 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2152 DBGPRINT(RT_DEBUG_TRACE, ("%s - unknow subcmd = %d\n", __func__, subcmd));
2160 int rt_ioctl_siwmlme(struct net_device *dev,
2161 struct iw_request_info *info,
2162 union iwreq_data *wrqu,
2165 PRTMP_ADAPTER pAd = dev->ml_priv;
2166 struct iw_mlme *pMlme = (struct iw_mlme *)wrqu->data.pointer;
2167 MLME_QUEUE_ELEM MsgElem;
2168 MLME_DISASSOC_REQ_STRUCT DisAssocReq;
2169 MLME_DEAUTH_REQ_STRUCT DeAuthReq;
2171 DBGPRINT(RT_DEBUG_TRACE, ("====> %s\n", __func__));
2178 #ifdef IW_MLME_DEAUTH
2179 case IW_MLME_DEAUTH:
2180 DBGPRINT(RT_DEBUG_TRACE, ("====> %s - IW_MLME_DEAUTH\n", __func__));
2181 COPY_MAC_ADDR(DeAuthReq.Addr, pAd->CommonCfg.Bssid);
2182 DeAuthReq.Reason = pMlme->reason_code;
2183 MsgElem.MsgLen = sizeof(MLME_DEAUTH_REQ_STRUCT);
2184 NdisMoveMemory(MsgElem.Msg, &DeAuthReq, sizeof(MLME_DEAUTH_REQ_STRUCT));
2185 MlmeDeauthReqAction(pAd, &MsgElem);
2188 LinkDown(pAd, FALSE);
2189 pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
2192 #endif // IW_MLME_DEAUTH //
2193 #ifdef IW_MLME_DISASSOC
2194 case IW_MLME_DISASSOC:
2195 DBGPRINT(RT_DEBUG_TRACE, ("====> %s - IW_MLME_DISASSOC\n", __func__));
2196 COPY_MAC_ADDR(DisAssocReq.Addr, pAd->CommonCfg.Bssid);
2197 DisAssocReq.Reason = pMlme->reason_code;
2199 MsgElem.Machine = ASSOC_STATE_MACHINE;
2200 MsgElem.MsgType = MT2_MLME_DISASSOC_REQ;
2201 MsgElem.MsgLen = sizeof(MLME_DISASSOC_REQ_STRUCT);
2202 NdisMoveMemory(MsgElem.Msg, &DisAssocReq, sizeof(MLME_DISASSOC_REQ_STRUCT));
2204 pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_OID_DISASSOC;
2205 MlmeDisassocReqAction(pAd, &MsgElem);
2207 #endif // IW_MLME_DISASSOC //
2209 DBGPRINT(RT_DEBUG_TRACE, ("====> %s - Unknow Command\n", __func__));
2215 #endif // SIOCSIWMLME //
2217 #if WIRELESS_EXT > 17
2218 int rt_ioctl_siwauth(struct net_device *dev,
2219 struct iw_request_info *info,
2220 union iwreq_data *wrqu, char *extra)
2222 PRTMP_ADAPTER pAdapter = dev->ml_priv;
2223 struct iw_param *param = &wrqu->param;
2225 //check if the interface is down
2226 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
2228 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
2231 switch (param->flags & IW_AUTH_INDEX) {
2232 case IW_AUTH_WPA_VERSION:
2233 if (param->value == IW_AUTH_WPA_VERSION_WPA)
2235 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPAPSK;
2236 if (pAdapter->StaCfg.BssType == BSS_ADHOC)
2237 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPANone;
2239 else if (param->value == IW_AUTH_WPA_VERSION_WPA2)
2240 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA2PSK;
2242 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_WPA_VERSION - param->value = %d!\n", __func__, param->value));
2244 case IW_AUTH_CIPHER_PAIRWISE:
2245 if (param->value == IW_AUTH_CIPHER_NONE)
2247 pAdapter->StaCfg.WepStatus = Ndis802_11WEPDisabled;
2248 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
2249 pAdapter->StaCfg.PairCipher = Ndis802_11WEPDisabled;
2251 else if (param->value == IW_AUTH_CIPHER_WEP40 ||
2252 param->value == IW_AUTH_CIPHER_WEP104)
2254 pAdapter->StaCfg.WepStatus = Ndis802_11WEPEnabled;
2255 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
2256 pAdapter->StaCfg.PairCipher = Ndis802_11WEPEnabled;
2257 #ifdef WPA_SUPPLICANT_SUPPORT
2258 pAdapter->StaCfg.IEEE8021X = FALSE;
2259 #endif // WPA_SUPPLICANT_SUPPORT //
2261 else if (param->value == IW_AUTH_CIPHER_TKIP)
2263 pAdapter->StaCfg.WepStatus = Ndis802_11Encryption2Enabled;
2264 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
2265 pAdapter->StaCfg.PairCipher = Ndis802_11Encryption2Enabled;
2267 else if (param->value == IW_AUTH_CIPHER_CCMP)
2269 pAdapter->StaCfg.WepStatus = Ndis802_11Encryption3Enabled;
2270 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
2271 pAdapter->StaCfg.PairCipher = Ndis802_11Encryption3Enabled;
2273 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_CIPHER_PAIRWISE - param->value = %d!\n", __func__, param->value));
2275 case IW_AUTH_CIPHER_GROUP:
2276 if (param->value == IW_AUTH_CIPHER_NONE)
2278 pAdapter->StaCfg.GroupCipher = Ndis802_11WEPDisabled;
2280 else if (param->value == IW_AUTH_CIPHER_WEP40 ||
2281 param->value == IW_AUTH_CIPHER_WEP104)
2283 pAdapter->StaCfg.GroupCipher = Ndis802_11WEPEnabled;
2285 else if (param->value == IW_AUTH_CIPHER_TKIP)
2287 pAdapter->StaCfg.GroupCipher = Ndis802_11Encryption2Enabled;
2289 else if (param->value == IW_AUTH_CIPHER_CCMP)
2291 pAdapter->StaCfg.GroupCipher = Ndis802_11Encryption3Enabled;
2293 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_CIPHER_GROUP - param->value = %d!\n", __func__, param->value));
2295 case IW_AUTH_KEY_MGMT:
2296 if (param->value == IW_AUTH_KEY_MGMT_802_1X)
2298 if (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK)
2300 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA;
2301 #ifdef WPA_SUPPLICANT_SUPPORT
2302 pAdapter->StaCfg.IEEE8021X = FALSE;
2303 #endif // WPA_SUPPLICANT_SUPPORT //
2305 else if (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK)
2307 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA2;
2308 #ifdef WPA_SUPPLICANT_SUPPORT
2309 pAdapter->StaCfg.IEEE8021X = FALSE;
2310 #endif // WPA_SUPPLICANT_SUPPORT //
2312 #ifdef WPA_SUPPLICANT_SUPPORT
2315 pAdapter->StaCfg.IEEE8021X = TRUE;
2316 #endif // WPA_SUPPLICANT_SUPPORT //
2318 else if (param->value == 0)
2320 //pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
2321 STA_PORT_SECURED(pAdapter);
2323 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_KEY_MGMT - param->value = %d!\n", __func__, param->value));
2325 case IW_AUTH_RX_UNENCRYPTED_EAPOL:
2327 case IW_AUTH_PRIVACY_INVOKED:
2328 /*if (param->value == 0)
2330 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
2331 pAdapter->StaCfg.WepStatus = Ndis802_11WEPDisabled;
2332 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
2333 pAdapter->StaCfg.PairCipher = Ndis802_11WEPDisabled;
2334 pAdapter->StaCfg.GroupCipher = Ndis802_11WEPDisabled;
2336 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_PRIVACY_INVOKED - param->value = %d!\n", __func__, param->value));
2338 case IW_AUTH_DROP_UNENCRYPTED:
2339 if (param->value != 0)
2340 pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED;
2343 //pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
2344 STA_PORT_SECURED(pAdapter);
2346 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_WPA_VERSION - param->value = %d!\n", __func__, param->value));
2348 case IW_AUTH_80211_AUTH_ALG:
2349 if (param->value & IW_AUTH_ALG_SHARED_KEY)
2351 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeShared;
2353 else if (param->value & IW_AUTH_ALG_OPEN_SYSTEM)
2355 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
2359 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_80211_AUTH_ALG - param->value = %d!\n", __func__, param->value));
2361 case IW_AUTH_WPA_ENABLED:
2362 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_WPA_ENABLED - Driver supports WPA!(param->value = %d)\n", __func__, param->value));
2371 int rt_ioctl_giwauth(struct net_device *dev,
2372 struct iw_request_info *info,
2373 union iwreq_data *wrqu, char *extra)
2375 PRTMP_ADAPTER pAdapter = dev->ml_priv;
2376 struct iw_param *param = &wrqu->param;
2378 //check if the interface is down
2379 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
2381 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
2385 switch (param->flags & IW_AUTH_INDEX) {
2386 case IW_AUTH_DROP_UNENCRYPTED:
2387 param->value = (pAdapter->StaCfg.WepStatus == Ndis802_11WEPDisabled) ? 0 : 1;
2390 case IW_AUTH_80211_AUTH_ALG:
2391 param->value = (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeShared) ? IW_AUTH_ALG_SHARED_KEY : IW_AUTH_ALG_OPEN_SYSTEM;
2394 case IW_AUTH_WPA_ENABLED:
2395 param->value = (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA) ? 1 : 0;
2401 DBGPRINT(RT_DEBUG_TRACE, ("rt_ioctl_giwauth::param->value = %d!\n", param->value));
2405 void fnSetCipherKey(
2406 IN PRTMP_ADAPTER pAdapter,
2410 IN struct iw_encode_ext *ext)
2412 NdisZeroMemory(&pAdapter->SharedKey[BSS0][keyIdx], sizeof(CIPHER_KEY));
2413 pAdapter->SharedKey[BSS0][keyIdx].KeyLen = LEN_TKIP_EK;
2414 NdisMoveMemory(pAdapter->SharedKey[BSS0][keyIdx].Key, ext->key, LEN_TKIP_EK);
2415 NdisMoveMemory(pAdapter->SharedKey[BSS0][keyIdx].TxMic, ext->key + LEN_TKIP_EK, LEN_TKIP_TXMICK);
2416 NdisMoveMemory(pAdapter->SharedKey[BSS0][keyIdx].RxMic, ext->key + LEN_TKIP_EK + LEN_TKIP_TXMICK, LEN_TKIP_RXMICK);
2417 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CipherAlg;
2419 // Update group key information to ASIC Shared Key Table
2420 AsicAddSharedKeyEntry(pAdapter,
2423 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg,
2424 pAdapter->SharedKey[BSS0][keyIdx].Key,
2425 pAdapter->SharedKey[BSS0][keyIdx].TxMic,
2426 pAdapter->SharedKey[BSS0][keyIdx].RxMic);
2429 // Update ASIC WCID attribute table and IVEIV table
2430 RTMPAddWcidAttributeEntry(pAdapter,
2433 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg,
2436 // Update ASIC WCID attribute table and IVEIV table
2437 RTMPAddWcidAttributeEntry(pAdapter,
2440 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg,
2441 &pAdapter->MacTab.Content[BSSID_WCID]);
2444 int rt_ioctl_siwencodeext(struct net_device *dev,
2445 struct iw_request_info *info,
2446 union iwreq_data *wrqu,
2449 PRTMP_ADAPTER pAdapter = dev->ml_priv;
2450 struct iw_point *encoding = &wrqu->encoding;
2451 struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
2452 int keyIdx, alg = ext->alg;
2454 //check if the interface is down
2455 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
2457 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
2461 if (encoding->flags & IW_ENCODE_DISABLED)
2463 keyIdx = (encoding->flags & IW_ENCODE_INDEX) - 1;
2464 // set BSSID wcid entry of the Pair-wise Key table as no-security mode
2465 AsicRemovePairwiseKeyEntry(pAdapter, BSS0, BSSID_WCID);
2466 pAdapter->SharedKey[BSS0][keyIdx].KeyLen = 0;
2467 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CIPHER_NONE;
2468 AsicRemoveSharedKeyEntry(pAdapter, 0, (UCHAR)keyIdx);
2469 NdisZeroMemory(&pAdapter->SharedKey[BSS0][keyIdx], sizeof(CIPHER_KEY));
2470 DBGPRINT(RT_DEBUG_TRACE, ("%s::Remove all keys!(encoding->flags = %x)\n", __func__, encoding->flags));
2474 // Get Key Index and convet to our own defined key index
2475 keyIdx = (encoding->flags & IW_ENCODE_INDEX) - 1;
2476 if((keyIdx < 0) || (keyIdx >= NR_WEP_KEYS))
2479 if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
2481 pAdapter->StaCfg.DefaultKeyId = keyIdx;
2482 DBGPRINT(RT_DEBUG_TRACE, ("%s::DefaultKeyId = %d\n", __func__, pAdapter->StaCfg.DefaultKeyId));
2486 case IW_ENCODE_ALG_NONE:
2487 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_ENCODE_ALG_NONE\n", __func__));
2489 case IW_ENCODE_ALG_WEP:
2490 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_ENCODE_ALG_WEP - ext->key_len = %d, keyIdx = %d\n", __func__, ext->key_len, keyIdx));
2491 if (ext->key_len == MAX_WEP_KEY_SIZE)
2493 pAdapter->SharedKey[BSS0][keyIdx].KeyLen = MAX_WEP_KEY_SIZE;
2494 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CIPHER_WEP128;
2496 else if (ext->key_len == MIN_WEP_KEY_SIZE)
2498 pAdapter->SharedKey[BSS0][keyIdx].KeyLen = MIN_WEP_KEY_SIZE;
2499 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CIPHER_WEP64;
2504 NdisZeroMemory(pAdapter->SharedKey[BSS0][keyIdx].Key, 16);
2505 NdisMoveMemory(pAdapter->SharedKey[BSS0][keyIdx].Key, ext->key, ext->key_len);
2507 case IW_ENCODE_ALG_TKIP:
2508 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_ENCODE_ALG_TKIP - keyIdx = %d, ext->key_len = %d\n", __func__, keyIdx, ext->key_len));
2509 if (ext->key_len == 32)
2511 if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
2513 fnSetCipherKey(pAdapter, keyIdx, CIPHER_TKIP, FALSE, ext);
2514 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA2)
2516 //pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
2517 STA_PORT_SECURED(pAdapter);
2520 else if (ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY)
2522 fnSetCipherKey(pAdapter, keyIdx, CIPHER_TKIP, TRUE, ext);
2524 // set 802.1x port control
2525 //pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
2526 STA_PORT_SECURED(pAdapter);
2532 case IW_ENCODE_ALG_CCMP:
2533 if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
2535 fnSetCipherKey(pAdapter, keyIdx, CIPHER_AES, FALSE, ext);
2536 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA2)
2537 //pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
2538 STA_PORT_SECURED(pAdapter);
2540 else if (ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY)
2542 fnSetCipherKey(pAdapter, keyIdx, CIPHER_AES, TRUE, ext);
2544 // set 802.1x port control
2545 //pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
2546 STA_PORT_SECURED(pAdapter);
2558 rt_ioctl_giwencodeext(struct net_device *dev,
2559 struct iw_request_info *info,
2560 union iwreq_data *wrqu, char *extra)
2562 PRTMP_ADAPTER pAd = dev->ml_priv;
2564 struct iw_point *encoding = &wrqu->encoding;
2565 struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
2566 int idx, max_key_len;
2568 DBGPRINT(RT_DEBUG_TRACE ,("===> rt_ioctl_giwencodeext\n"));
2570 max_key_len = encoding->length - sizeof(*ext);
2571 if (max_key_len < 0)
2574 idx = encoding->flags & IW_ENCODE_INDEX;
2577 if (idx < 1 || idx > 4)
2581 if ((pAd->StaCfg.WepStatus == Ndis802_11Encryption2Enabled) ||
2582 (pAd->StaCfg.WepStatus == Ndis802_11Encryption3Enabled))
2584 if (idx != pAd->StaCfg.DefaultKeyId)
2592 idx = pAd->StaCfg.DefaultKeyId;
2594 encoding->flags = idx + 1;
2595 memset(ext, 0, sizeof(*ext));
2598 switch(pAd->StaCfg.WepStatus) {
2599 case Ndis802_11WEPDisabled:
2600 ext->alg = IW_ENCODE_ALG_NONE;
2601 encoding->flags |= IW_ENCODE_DISABLED;
2603 case Ndis802_11WEPEnabled:
2604 ext->alg = IW_ENCODE_ALG_WEP;
2605 if (pAd->SharedKey[BSS0][idx].KeyLen > max_key_len)
2609 ext->key_len = pAd->SharedKey[BSS0][idx].KeyLen;
2610 pKey = &(pAd->SharedKey[BSS0][idx].Key[0]);
2613 case Ndis802_11Encryption2Enabled:
2614 case Ndis802_11Encryption3Enabled:
2615 if (pAd->StaCfg.WepStatus == Ndis802_11Encryption2Enabled)
2616 ext->alg = IW_ENCODE_ALG_TKIP;
2618 ext->alg = IW_ENCODE_ALG_CCMP;
2620 if (max_key_len < 32)
2625 pKey = &pAd->StaCfg.PMK[0];
2632 if (ext->key_len && pKey)
2634 encoding->flags |= IW_ENCODE_ENABLED;
2635 memcpy(ext->key, pKey, ext->key_len);
2642 int rt_ioctl_siwgenie(struct net_device *dev,
2643 struct iw_request_info *info,
2644 union iwreq_data *wrqu, char *extra)
2646 PRTMP_ADAPTER pAd = dev->ml_priv;
2648 if (wrqu->data.length > MAX_LEN_OF_RSNIE ||
2649 (wrqu->data.length && extra == NULL))
2652 if (wrqu->data.length)
2654 pAd->StaCfg.RSNIE_Len = wrqu->data.length;
2655 NdisMoveMemory(&pAd->StaCfg.RSN_IE[0], extra, pAd->StaCfg.RSNIE_Len);
2659 pAd->StaCfg.RSNIE_Len = 0;
2660 NdisZeroMemory(&pAd->StaCfg.RSN_IE[0], MAX_LEN_OF_RSNIE);
2665 #endif // SIOCSIWGENIE //
2667 int rt_ioctl_giwgenie(struct net_device *dev,
2668 struct iw_request_info *info,
2669 union iwreq_data *wrqu, char *extra)
2671 PRTMP_ADAPTER pAd = dev->ml_priv;
2673 if ((pAd->StaCfg.RSNIE_Len == 0) ||
2674 (pAd->StaCfg.AuthMode < Ndis802_11AuthModeWPA))
2676 wrqu->data.length = 0;
2680 #ifdef NATIVE_WPA_SUPPLICANT_SUPPORT
2682 if (pAd->StaCfg.WpaSupplicantUP == WPA_SUPPLICANT_ENABLE)
2684 if (wrqu->data.length < pAd->StaCfg.RSNIE_Len)
2687 wrqu->data.length = pAd->StaCfg.RSNIE_Len;
2688 memcpy(extra, &pAd->StaCfg.RSN_IE[0], pAd->StaCfg.RSNIE_Len);
2691 #endif // SIOCSIWGENIE //
2692 #endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
2694 UCHAR RSNIe = IE_WPA;
2696 if (wrqu->data.length < (pAd->StaCfg.RSNIE_Len + 2)) // ID, Len
2698 wrqu->data.length = pAd->StaCfg.RSNIE_Len + 2;
2700 if ((pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK) ||
2701 (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2))
2704 extra[0] = (char)RSNIe;
2705 extra[1] = pAd->StaCfg.RSNIE_Len;
2706 memcpy(extra+2, &pAd->StaCfg.RSN_IE[0], pAd->StaCfg.RSNIE_Len);
2712 int rt_ioctl_siwpmksa(struct net_device *dev,
2713 struct iw_request_info *info,
2714 union iwreq_data *wrqu,
2717 PRTMP_ADAPTER pAd = dev->ml_priv;
2718 struct iw_pmksa *pPmksa = (struct iw_pmksa *)wrqu->data.pointer;
2719 INT CachedIdx = 0, idx = 0;
2724 DBGPRINT(RT_DEBUG_TRACE ,("===> rt_ioctl_siwpmksa\n"));
2727 case IW_PMKSA_FLUSH:
2728 NdisZeroMemory(pAd->StaCfg.SavedPMK, sizeof(BSSID_INFO)*PMKID_NO);
2729 DBGPRINT(RT_DEBUG_TRACE ,("rt_ioctl_siwpmksa - IW_PMKSA_FLUSH\n"));
2731 case IW_PMKSA_REMOVE:
2732 for (CachedIdx = 0; CachedIdx < pAd->StaCfg.SavedPMKNum; CachedIdx++)
2734 // compare the BSSID
2735 if (NdisEqualMemory(pPmksa->bssid.sa_data, pAd->StaCfg.SavedPMK[CachedIdx].BSSID, MAC_ADDR_LEN))
2737 NdisZeroMemory(pAd->StaCfg.SavedPMK[CachedIdx].BSSID, MAC_ADDR_LEN);
2738 NdisZeroMemory(pAd->StaCfg.SavedPMK[CachedIdx].PMKID, 16);
2739 for (idx = CachedIdx; idx < (pAd->StaCfg.SavedPMKNum - 1); idx++)
2741 NdisMoveMemory(&pAd->StaCfg.SavedPMK[idx].BSSID[0], &pAd->StaCfg.SavedPMK[idx+1].BSSID[0], MAC_ADDR_LEN);
2742 NdisMoveMemory(&pAd->StaCfg.SavedPMK[idx].PMKID[0], &pAd->StaCfg.SavedPMK[idx+1].PMKID[0], 16);
2744 pAd->StaCfg.SavedPMKNum--;
2749 DBGPRINT(RT_DEBUG_TRACE ,("rt_ioctl_siwpmksa - IW_PMKSA_REMOVE\n"));
2752 for (CachedIdx = 0; CachedIdx < pAd->StaCfg.SavedPMKNum; CachedIdx++)
2754 // compare the BSSID
2755 if (NdisEqualMemory(pPmksa->bssid.sa_data, pAd->StaCfg.SavedPMK[CachedIdx].BSSID, MAC_ADDR_LEN))
2759 // Found, replace it
2760 if (CachedIdx < PMKID_NO)
2762 DBGPRINT(RT_DEBUG_OFF, ("Update PMKID, idx = %d\n", CachedIdx));
2763 NdisMoveMemory(&pAd->StaCfg.SavedPMK[CachedIdx].BSSID[0], pPmksa->bssid.sa_data, MAC_ADDR_LEN);
2764 NdisMoveMemory(&pAd->StaCfg.SavedPMK[CachedIdx].PMKID[0], pPmksa->pmkid, 16);
2765 pAd->StaCfg.SavedPMKNum++;
2767 // Not found, replace the last one
2770 // Randomly replace one
2771 CachedIdx = (pPmksa->bssid.sa_data[5] % PMKID_NO);
2772 DBGPRINT(RT_DEBUG_OFF, ("Update PMKID, idx = %d\n", CachedIdx));
2773 NdisMoveMemory(&pAd->StaCfg.SavedPMK[CachedIdx].BSSID[0], pPmksa->bssid.sa_data, MAC_ADDR_LEN);
2774 NdisMoveMemory(&pAd->StaCfg.SavedPMK[CachedIdx].PMKID[0], pPmksa->pmkid, 16);
2777 DBGPRINT(RT_DEBUG_TRACE ,("rt_ioctl_siwpmksa - IW_PMKSA_ADD\n"));
2780 DBGPRINT(RT_DEBUG_TRACE ,("rt_ioctl_siwpmksa - Unknow Command!!\n"));
2786 #endif // #if WIRELESS_EXT > 17
2790 rt_private_ioctl_bbp(struct net_device *dev, struct iw_request_info *info,
2791 struct iw_point *wrq, char *extra)
2796 // CHAR arg[255]={0};
2799 BOOLEAN bIsPrintAllBBP = FALSE;
2801 PRTMP_ADAPTER pAdapter = dev->ml_priv;
2804 memset(extra, 0x00, IW_PRIV_SIZE_MASK);
2806 if (wrq->length > 1) //No parameters.
2808 sprintf(extra, "\n");
2810 //Parsing Read or Write
2811 this_char = wrq->pointer;
2812 DBGPRINT(RT_DEBUG_TRACE, ("this_char=%s\n", this_char));
2816 if ((value = rtstrchr(this_char, '=')) != NULL)
2819 if (!value || !*value)
2821 DBGPRINT(RT_DEBUG_TRACE, ("this_char=%s, value=%s\n", this_char, value));
2822 if (sscanf(this_char, "%d", &(bbpId)) == 1)
2828 if (bbpId <= 138) // edit by johnli, RF power sequence setup, add BBP R138 for ADC dynamic on/off control
2832 if (ATE_ON(pAdapter))
2834 ATE_BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, ®BBP);
2837 #endif // RALINK_ATE //
2839 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, ®BBP);
2841 sprintf(extra+strlen(extra), "R%02d[0x%02X]:%02X\n", bbpId, bbpId*2, regBBP);
2842 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2843 DBGPRINT(RT_DEBUG_TRACE, ("msg=%s\n", extra));
2846 {//Invalid parametes, so default printk all bbp
2847 bIsPrintAllBBP = TRUE;
2852 { //Invalid parametes, so default printk all bbp
2853 bIsPrintAllBBP = TRUE;
2859 if ((sscanf(this_char, "%d", &(bbpId)) == 1) && (sscanf(value, "%x", &(bbpValue)) == 1))
2865 if (bbpId <= 138) // edit by johnli, RF power sequence setup, add BBP R138 for ADC dynamic on/off control
2869 if (ATE_ON(pAdapter))
2871 ATE_BBP_IO_WRITE8_BY_REG_ID(pAdapter, bbpId, bbpValue);
2872 //Read it back for showing
2873 ATE_BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, ®BBP);
2876 #endif // RALINK_ATE //
2878 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, bbpId, bbpValue);
2879 //Read it back for showing
2880 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, ®BBP);
2882 sprintf(extra+strlen(extra), "R%02d[0x%02X]:%02X\n", bbpId, bbpId*2, regBBP);
2883 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2884 DBGPRINT(RT_DEBUG_TRACE, ("msg=%s\n", extra));
2887 {//Invalid parametes, so default printk all bbp
2888 bIsPrintAllBBP = TRUE;
2893 { //Invalid parametes, so default printk all bbp
2894 bIsPrintAllBBP = TRUE;
2900 bIsPrintAllBBP = TRUE;
2905 memset(extra, 0x00, IW_PRIV_SIZE_MASK);
2906 sprintf(extra, "\n");
2908 for (bbpId = 0; bbpId <= 136; bbpId++)
2911 for (bbpId = 0; bbpId <= 138; bbpId++) // edit by johnli, RF power sequence setup, add BBP R138 for ADC dynamic on/off control
2914 if (strlen(extra) >= (IW_PRIV_SIZE_MASK - 10))
2917 if (ATE_ON(pAdapter))
2919 ATE_BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, ®BBP);
2922 #endif // RALINK_ATE //
2923 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, ®BBP);
2925 sprintf(extra+strlen(extra), "R%02d[0x%02X]:%02X ", bbpId, bbpId*2, regBBP);
2927 sprintf(extra+strlen(extra), "\n");
2929 sprintf(extra+strlen(extra), "%03d = %02X\n", bbpId, regBBP); // edit by johnli, change display format
2932 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2933 DBGPRINT(RT_DEBUG_TRACE, ("wrq->length = %d\n", wrq->length));
2936 DBGPRINT(RT_DEBUG_TRACE, ("<==rt_private_ioctl_bbp\n\n"));
2942 int rt_ioctl_siwrate(struct net_device *dev,
2943 struct iw_request_info *info,
2944 union iwreq_data *wrqu, char *extra)
2946 PRTMP_ADAPTER pAd = dev->ml_priv;
2947 UINT32 rate = wrqu->bitrate.value, fixed = wrqu->bitrate.fixed;
2949 //check if the interface is down
2950 if(!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_IN_USE))
2952 DBGPRINT(RT_DEBUG_TRACE, ("rt_ioctl_siwrate::Network is down!\n"));
2956 DBGPRINT(RT_DEBUG_TRACE, ("rt_ioctl_siwrate::(rate = %d, fixed = %d)\n", rate, fixed));
2957 /* rate = -1 => auto rate
2958 rate = X, fixed = 1 => (fixed rate X)
2963 pAd->StaCfg.DesiredTransmitSetting.field.MCS = MCS_AUTO;
2964 pAd->StaCfg.bAutoTxRateSwitch = TRUE;
2965 if ((pAd->CommonCfg.PhyMode <= PHY_11G) ||
2966 (pAd->MacTab.Content[BSSID_WCID].HTPhyMode.field.MODE <= MODE_OFDM))
2967 RTMPSetDesiredRates(pAd, -1);
2969 #ifdef DOT11_N_SUPPORT
2971 #endif // DOT11_N_SUPPORT //
2977 pAd->StaCfg.bAutoTxRateSwitch = FALSE;
2978 if ((pAd->CommonCfg.PhyMode <= PHY_11G) ||
2979 (pAd->MacTab.Content[BSSID_WCID].HTPhyMode.field.MODE <= MODE_OFDM))
2980 RTMPSetDesiredRates(pAd, rate);
2983 pAd->StaCfg.DesiredTransmitSetting.field.MCS = MCS_AUTO;
2984 #ifdef DOT11_N_SUPPORT
2986 #endif // DOT11_N_SUPPORT //
2988 DBGPRINT(RT_DEBUG_TRACE, ("rt_ioctl_siwrate::(HtMcs=%d)\n",pAd->StaCfg.DesiredTransmitSetting.field.MCS));
2992 // TODO: rate = X, fixed = 0 => (rates <= X)
3000 int rt_ioctl_giwrate(struct net_device *dev,
3001 struct iw_request_info *info,
3002 union iwreq_data *wrqu, char *extra)
3004 PRTMP_ADAPTER pAd = dev->ml_priv;
3005 int rate_index = 0, rate_count = 0;
3006 HTTRANSMIT_SETTING ht_setting;
3007 __s32 ralinkrate[] =
3008 {2, 4, 11, 22, // CCK
3009 12, 18, 24, 36, 48, 72, 96, 108, // OFDM
3010 13, 26, 39, 52, 78, 104, 117, 130, 26, 52, 78, 104, 156, 208, 234, 260, // 20MHz, 800ns GI, MCS: 0 ~ 15
3011 39, 78, 117, 156, 234, 312, 351, 390, // 20MHz, 800ns GI, MCS: 16 ~ 23
3012 27, 54, 81, 108, 162, 216, 243, 270, 54, 108, 162, 216, 324, 432, 486, 540, // 40MHz, 800ns GI, MCS: 0 ~ 15
3013 81, 162, 243, 324, 486, 648, 729, 810, // 40MHz, 800ns GI, MCS: 16 ~ 23
3014 14, 29, 43, 57, 87, 115, 130, 144, 29, 59, 87, 115, 173, 230, 260, 288, // 20MHz, 400ns GI, MCS: 0 ~ 15
3015 43, 87, 130, 173, 260, 317, 390, 433, // 20MHz, 400ns GI, MCS: 16 ~ 23
3016 30, 60, 90, 120, 180, 240, 270, 300, 60, 120, 180, 240, 360, 480, 540, 600, // 40MHz, 400ns GI, MCS: 0 ~ 15
3017 90, 180, 270, 360, 540, 720, 810, 900}; // 40MHz, 400ns GI, MCS: 16 ~ 23
3019 rate_count = sizeof(ralinkrate)/sizeof(__s32);
3020 //check if the interface is down
3021 if(!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_IN_USE))
3023 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
3027 if ((pAd->StaCfg.bAutoTxRateSwitch == FALSE) &&
3029 ((pAd->CommonCfg.PhyMode <= PHY_11G) || (pAd->MacTab.Content[BSSID_WCID].HTPhyMode.field.MODE <= MODE_OFDM)))
3030 ht_setting.word = pAd->StaCfg.HTPhyMode.word;
3032 ht_setting.word = pAd->MacTab.Content[BSSID_WCID].HTPhyMode.word;
3034 #ifdef DOT11_N_SUPPORT
3035 if (ht_setting.field.MODE >= MODE_HTMIX)
3037 // rate_index = 12 + ((UCHAR)ht_setting.field.BW *16) + ((UCHAR)ht_setting.field.ShortGI *32) + ((UCHAR)ht_setting.field.MCS);
3038 rate_index = 12 + ((UCHAR)ht_setting.field.BW *24) + ((UCHAR)ht_setting.field.ShortGI *48) + ((UCHAR)ht_setting.field.MCS);
3041 #endif // DOT11_N_SUPPORT //
3042 if (ht_setting.field.MODE == MODE_OFDM)
3043 rate_index = (UCHAR)(ht_setting.field.MCS) + 4;
3044 else if (ht_setting.field.MODE == MODE_CCK)
3045 rate_index = (UCHAR)(ht_setting.field.MCS);
3050 if (rate_index > rate_count)
3051 rate_index = rate_count;
3053 wrqu->bitrate.value = ralinkrate[rate_index] * 500000;
3054 wrqu->bitrate.disabled = 0;
3059 static const iw_handler rt_handler[] =
3061 (iw_handler) NULL, /* SIOCSIWCOMMIT */
3062 (iw_handler) rt_ioctl_giwname, /* SIOCGIWNAME */
3063 (iw_handler) NULL, /* SIOCSIWNWID */
3064 (iw_handler) NULL, /* SIOCGIWNWID */
3065 (iw_handler) rt_ioctl_siwfreq, /* SIOCSIWFREQ */
3066 (iw_handler) rt_ioctl_giwfreq, /* SIOCGIWFREQ */
3067 (iw_handler) rt_ioctl_siwmode, /* SIOCSIWMODE */
3068 (iw_handler) rt_ioctl_giwmode, /* SIOCGIWMODE */
3069 (iw_handler) NULL, /* SIOCSIWSENS */
3070 (iw_handler) NULL, /* SIOCGIWSENS */
3071 (iw_handler) NULL /* not used */, /* SIOCSIWRANGE */
3072 (iw_handler) rt_ioctl_giwrange, /* SIOCGIWRANGE */
3073 (iw_handler) NULL /* not used */, /* SIOCSIWPRIV */
3074 (iw_handler) NULL /* kernel code */, /* SIOCGIWPRIV */
3075 (iw_handler) NULL /* not used */, /* SIOCSIWSTATS */
3076 (iw_handler) rt28xx_get_wireless_stats /* kernel code */, /* SIOCGIWSTATS */
3077 (iw_handler) NULL, /* SIOCSIWSPY */
3078 (iw_handler) NULL, /* SIOCGIWSPY */
3079 (iw_handler) NULL, /* SIOCSIWTHRSPY */
3080 (iw_handler) NULL, /* SIOCGIWTHRSPY */
3081 (iw_handler) rt_ioctl_siwap, /* SIOCSIWAP */
3082 (iw_handler) rt_ioctl_giwap, /* SIOCGIWAP */
3084 (iw_handler) rt_ioctl_siwmlme, /* SIOCSIWMLME */
3086 (iw_handler) NULL, /* SIOCSIWMLME */
3087 #endif // SIOCSIWMLME //
3088 (iw_handler) rt_ioctl_iwaplist, /* SIOCGIWAPLIST */
3090 (iw_handler) rt_ioctl_siwscan, /* SIOCSIWSCAN */
3091 (iw_handler) rt_ioctl_giwscan, /* SIOCGIWSCAN */
3093 (iw_handler) NULL, /* SIOCSIWSCAN */
3094 (iw_handler) NULL, /* SIOCGIWSCAN */
3095 #endif /* SIOCGIWSCAN */
3096 (iw_handler) rt_ioctl_siwessid, /* SIOCSIWESSID */
3097 (iw_handler) rt_ioctl_giwessid, /* SIOCGIWESSID */
3098 (iw_handler) rt_ioctl_siwnickn, /* SIOCSIWNICKN */
3099 (iw_handler) rt_ioctl_giwnickn, /* SIOCGIWNICKN */
3100 (iw_handler) NULL, /* -- hole -- */
3101 (iw_handler) NULL, /* -- hole -- */
3102 (iw_handler) rt_ioctl_siwrate, /* SIOCSIWRATE */
3103 (iw_handler) rt_ioctl_giwrate, /* SIOCGIWRATE */
3104 (iw_handler) rt_ioctl_siwrts, /* SIOCSIWRTS */
3105 (iw_handler) rt_ioctl_giwrts, /* SIOCGIWRTS */
3106 (iw_handler) rt_ioctl_siwfrag, /* SIOCSIWFRAG */
3107 (iw_handler) rt_ioctl_giwfrag, /* SIOCGIWFRAG */
3108 (iw_handler) NULL, /* SIOCSIWTXPOW */
3109 (iw_handler) NULL, /* SIOCGIWTXPOW */
3110 (iw_handler) NULL, /* SIOCSIWRETRY */
3111 (iw_handler) NULL, /* SIOCGIWRETRY */
3112 (iw_handler) rt_ioctl_siwencode, /* SIOCSIWENCODE */
3113 (iw_handler) rt_ioctl_giwencode, /* SIOCGIWENCODE */
3114 (iw_handler) NULL, /* SIOCSIWPOWER */
3115 (iw_handler) NULL, /* SIOCGIWPOWER */
3116 (iw_handler) NULL, /* -- hole -- */
3117 (iw_handler) NULL, /* -- hole -- */
3118 #if WIRELESS_EXT > 17
3119 (iw_handler) rt_ioctl_siwgenie, /* SIOCSIWGENIE */
3120 (iw_handler) rt_ioctl_giwgenie, /* SIOCGIWGENIE */
3121 (iw_handler) rt_ioctl_siwauth, /* SIOCSIWAUTH */
3122 (iw_handler) rt_ioctl_giwauth, /* SIOCGIWAUTH */
3123 (iw_handler) rt_ioctl_siwencodeext, /* SIOCSIWENCODEEXT */
3124 (iw_handler) rt_ioctl_giwencodeext, /* SIOCGIWENCODEEXT */
3125 (iw_handler) rt_ioctl_siwpmksa, /* SIOCSIWPMKSA */
3129 static const iw_handler rt_priv_handlers[] = {
3130 (iw_handler) NULL, /* + 0x00 */
3131 (iw_handler) NULL, /* + 0x01 */
3132 #ifndef CONFIG_AP_SUPPORT
3133 (iw_handler) rt_ioctl_setparam, /* + 0x02 */
3135 (iw_handler) NULL, /* + 0x02 */
3136 #endif // CONFIG_AP_SUPPORT //
3138 (iw_handler) rt_private_ioctl_bbp, /* + 0x03 */
3140 (iw_handler) NULL, /* + 0x03 */
3142 (iw_handler) NULL, /* + 0x04 */
3143 (iw_handler) NULL, /* + 0x05 */
3144 (iw_handler) NULL, /* + 0x06 */
3145 (iw_handler) NULL, /* + 0x07 */
3146 (iw_handler) NULL, /* + 0x08 */
3147 (iw_handler) rt_private_get_statistics, /* + 0x09 */
3148 (iw_handler) NULL, /* + 0x0A */
3149 (iw_handler) NULL, /* + 0x0B */
3150 (iw_handler) NULL, /* + 0x0C */
3151 (iw_handler) NULL, /* + 0x0D */
3152 (iw_handler) NULL, /* + 0x0E */
3153 (iw_handler) NULL, /* + 0x0F */
3154 (iw_handler) NULL, /* + 0x10 */
3155 (iw_handler) rt_private_show, /* + 0x11 */
3156 (iw_handler) NULL, /* + 0x12 */
3157 (iw_handler) NULL, /* + 0x13 */
3158 (iw_handler) NULL, /* + 0x15 */
3159 (iw_handler) NULL, /* + 0x17 */
3160 (iw_handler) NULL, /* + 0x18 */
3163 const struct iw_handler_def rt28xx_iw_handler_def =
3165 #define N(a) (sizeof (a) / sizeof (a[0]))
3166 .standard = (iw_handler *) rt_handler,
3167 .num_standard = sizeof(rt_handler) / sizeof(iw_handler),
3168 .private = (iw_handler *) rt_priv_handlers,
3169 .num_private = N(rt_priv_handlers),
3170 .private_args = (struct iw_priv_args *) privtab,
3171 .num_private_args = N(privtab),
3172 #if IW_HANDLER_VERSION >= 7
3173 .get_wireless_stats = rt28xx_get_wireless_stats,
3177 INT RTMPSetInformation(
3178 IN PRTMP_ADAPTER pAdapter,
3179 IN OUT struct ifreq *rq,
3182 struct iwreq *wrq = (struct iwreq *) rq;
3183 NDIS_802_11_SSID Ssid;
3184 NDIS_802_11_MAC_ADDRESS Bssid;
3185 RT_802_11_PHY_MODE PhyMode;
3186 RT_802_11_STA_CONFIG StaConfig;
3187 NDIS_802_11_RATES aryRates;
3188 RT_802_11_PREAMBLE Preamble;
3189 NDIS_802_11_WEP_STATUS WepStatus;
3190 NDIS_802_11_AUTHENTICATION_MODE AuthMode = Ndis802_11AuthModeMax;
3191 NDIS_802_11_NETWORK_INFRASTRUCTURE BssType;
3192 NDIS_802_11_RTS_THRESHOLD RtsThresh;
3193 NDIS_802_11_FRAGMENTATION_THRESHOLD FragThresh;
3194 NDIS_802_11_POWER_MODE PowerMode;
3195 PNDIS_802_11_KEY pKey = NULL;
3196 PNDIS_802_11_WEP pWepKey =NULL;
3197 PNDIS_802_11_REMOVE_KEY pRemoveKey = NULL;
3198 NDIS_802_11_CONFIGURATION Config, *pConfig = NULL;
3199 NDIS_802_11_NETWORK_TYPE NetType;
3202 INT Status = NDIS_STATUS_SUCCESS, MaxPhyMode = PHY_11G;
3205 BOOLEAN StateMachineTouched = FALSE;
3206 #ifdef DOT11_N_SUPPORT
3207 OID_SET_HT_PHYMODE HT_PhyMode; //11n ,kathy
3208 #endif // DOT11_N_SUPPORT //
3209 #ifdef WPA_SUPPLICANT_SUPPORT
3210 PNDIS_802_11_PMKID pPmkId = NULL;
3211 BOOLEAN IEEE8021xState = FALSE;
3212 BOOLEAN IEEE8021x_required_keys = FALSE;
3213 UCHAR wpa_supplicant_enable = 0;
3214 #endif // WPA_SUPPLICANT_SUPPORT //
3217 TX_RTY_CFG_STRUC tx_rty_cfg;
3218 ULONG ShortRetryLimit, LongRetryLimit;
3220 #endif // SNMP_SUPPORT //
3223 #ifdef DOT11_N_SUPPORT
3224 MaxPhyMode = PHY_11N_5G;
3225 #endif // DOT11_N_SUPPORT //
3228 DBGPRINT(RT_DEBUG_TRACE, ("-->RTMPSetInformation(), 0x%08x\n", cmd&0x7FFF));
3229 switch(cmd & 0x7FFF) {
3230 case RT_OID_802_11_COUNTRY_REGION:
3231 if (wrq->u.data.length < sizeof(UCHAR))
3233 // Only avaliable when EEPROM not programming
3234 else if (!(pAdapter->CommonCfg.CountryRegion & 0x80) && !(pAdapter->CommonCfg.CountryRegionForABand & 0x80))
3239 Status = copy_from_user(&Country, wrq->u.data.pointer, wrq->u.data.length);
3240 pAdapter->CommonCfg.CountryRegion = (UCHAR)(Country & 0x000000FF);
3241 pAdapter->CommonCfg.CountryRegionForABand = (UCHAR)((Country >> 8) & 0x000000FF);
3242 TmpPhy = pAdapter->CommonCfg.PhyMode;
3243 pAdapter->CommonCfg.PhyMode = 0xff;
3244 // Build all corresponding channel information
3245 RTMPSetPhyMode(pAdapter, TmpPhy);
3246 #ifdef DOT11_N_SUPPORT
3247 SetCommonHT(pAdapter);
3248 #endif // DOT11_N_SUPPORT //
3249 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_COUNTRY_REGION (A:%d B/G:%d)\n", pAdapter->CommonCfg.CountryRegionForABand,
3250 pAdapter->CommonCfg.CountryRegion));
3253 case OID_802_11_BSSID_LIST_SCAN:
3255 if (ATE_ON(pAdapter))
3257 DBGPRINT(RT_DEBUG_TRACE, ("The driver is in ATE mode now\n"));
3260 #endif // RALINK_ATE //
3262 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_BSSID_LIST_SCAN, TxCnt = %d \n", pAdapter->RalinkCounters.LastOneSecTotalTxCount));
3264 if (MONITOR_ON(pAdapter))
3266 DBGPRINT(RT_DEBUG_TRACE, ("!!! Driver is in Monitor Mode now !!!\n"));
3270 //Benson add 20080527, when radio off, sta don't need to scan
3271 if (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_RADIO_OFF))
3274 if (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
3276 DBGPRINT(RT_DEBUG_TRACE, ("!!! Driver is scanning now !!!\n"));
3277 pAdapter->StaCfg.bScanReqIsFromWebUI = TRUE;
3278 Status = NDIS_STATUS_SUCCESS;
3282 if (pAdapter->RalinkCounters.LastOneSecTotalTxCount > 100)
3284 DBGPRINT(RT_DEBUG_TRACE, ("!!! Link UP, ignore this set::OID_802_11_BSSID_LIST_SCAN\n"));
3285 Status = NDIS_STATUS_SUCCESS;
3286 pAdapter->StaCfg.ScanCnt = 99; // Prevent auto scan triggered by this OID
3290 if ((OPSTATUS_TEST_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED)) &&
3291 ((pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA) ||
3292 (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK) ||
3293 (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA2) ||
3294 (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK)) &&
3295 (pAdapter->StaCfg.PortSecured == WPA_802_1X_PORT_NOT_SECURED))
3297 DBGPRINT(RT_DEBUG_TRACE, ("!!! Link UP, Port Not Secured! ignore this set::OID_802_11_BSSID_LIST_SCAN\n"));
3298 Status = NDIS_STATUS_SUCCESS;
3299 pAdapter->StaCfg.ScanCnt = 99; // Prevent auto scan triggered by this OID
3304 if (pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE)
3306 RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
3307 DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
3310 // tell CNTL state machine to call NdisMSetInformationComplete() after completing
3311 // this request, because this request is initiated by NDIS.
3312 pAdapter->MlmeAux.CurrReqIsFromNdis = FALSE;
3313 // Reset allowed scan retries
3314 pAdapter->StaCfg.ScanCnt = 0;
3315 pAdapter->StaCfg.LastScanTime = Now;
3317 pAdapter->StaCfg.bScanReqIsFromWebUI = TRUE;
3318 RTMP_SET_FLAG(pAdapter, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS);
3319 MlmeEnqueue(pAdapter,
3320 MLME_CNTL_STATE_MACHINE,
3321 OID_802_11_BSSID_LIST_SCAN,
3325 Status = NDIS_STATUS_SUCCESS;
3326 StateMachineTouched = TRUE;
3328 case OID_802_11_SSID:
3329 if (wrq->u.data.length != sizeof(NDIS_802_11_SSID))
3333 PCHAR pSsidString = NULL;
3334 Status = copy_from_user(&Ssid, wrq->u.data.pointer, wrq->u.data.length);
3336 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_SSID (Len=%d,Ssid=%s)\n", Ssid.SsidLength, Ssid.Ssid));
3337 if (Ssid.SsidLength > MAX_LEN_OF_SSID)
3341 if (Ssid.SsidLength == 0)
3343 Set_SSID_Proc(pAdapter, "");
3347 pSsidString = (CHAR *) kmalloc(MAX_LEN_OF_SSID+1, MEM_ALLOC_FLAG);
3350 NdisZeroMemory(pSsidString, MAX_LEN_OF_SSID+1);
3351 NdisMoveMemory(pSsidString, Ssid.Ssid, Ssid.SsidLength);
3352 Set_SSID_Proc(pAdapter, pSsidString);
3361 case OID_802_11_BSSID:
3363 if (ATE_ON(pAdapter))
3365 DBGPRINT(RT_DEBUG_TRACE, ("The driver is in ATE mode now\n"));
3368 #endif // RALINK_ATE //
3369 if (wrq->u.data.length != sizeof(NDIS_802_11_MAC_ADDRESS))
3373 Status = copy_from_user(&Bssid, wrq->u.data.pointer, wrq->u.data.length);
3375 // tell CNTL state machine to call NdisMSetInformationComplete() after completing
3376 // this request, because this request is initiated by NDIS.
3377 pAdapter->MlmeAux.CurrReqIsFromNdis = FALSE;
3379 // Prevent to connect AP again in STAMlmePeriodicExec
3380 pAdapter->MlmeAux.AutoReconnectSsidLen= 32;
3382 // Reset allowed scan retries
3383 pAdapter->StaCfg.ScanCnt = 0;
3385 if (pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE)
3387 RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
3388 DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
3390 MlmeEnqueue(pAdapter,
3391 MLME_CNTL_STATE_MACHINE,
3393 sizeof(NDIS_802_11_MAC_ADDRESS),
3395 Status = NDIS_STATUS_SUCCESS;
3396 StateMachineTouched = TRUE;
3398 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_BSSID %02x:%02x:%02x:%02x:%02x:%02x\n",
3399 Bssid[0], Bssid[1], Bssid[2], Bssid[3], Bssid[4], Bssid[5]));
3402 case RT_OID_802_11_RADIO:
3403 if (wrq->u.data.length != sizeof(BOOLEAN))
3407 Status = copy_from_user(&RadioState, wrq->u.data.pointer, wrq->u.data.length);
3408 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_RADIO (=%d)\n", RadioState));
3409 if (pAdapter->StaCfg.bSwRadio != RadioState)
3411 pAdapter->StaCfg.bSwRadio = RadioState;
3412 if (pAdapter->StaCfg.bRadio != (pAdapter->StaCfg.bHwRadio && pAdapter->StaCfg.bSwRadio))
3414 pAdapter->StaCfg.bRadio = (pAdapter->StaCfg.bHwRadio && pAdapter->StaCfg.bSwRadio);
3415 if (pAdapter->StaCfg.bRadio == TRUE)
3417 MlmeRadioOn(pAdapter);
3418 // Update extra information
3419 pAdapter->ExtraInfo = EXTRA_INFO_CLEAR;
3423 MlmeRadioOff(pAdapter);
3424 // Update extra information
3425 pAdapter->ExtraInfo = SW_RADIO_OFF;
3431 case RT_OID_802_11_PHY_MODE:
3432 if (wrq->u.data.length != sizeof(RT_802_11_PHY_MODE))
3436 Status = copy_from_user(&PhyMode, wrq->u.data.pointer, wrq->u.data.length);
3437 if (PhyMode <= MaxPhyMode)
3439 RTMPSetPhyMode(pAdapter, PhyMode);
3440 #ifdef DOT11_N_SUPPORT
3441 SetCommonHT(pAdapter);
3442 #endif // DOT11_N_SUPPORT //
3444 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_PHY_MODE (=%d)\n", PhyMode));
3447 case RT_OID_802_11_STA_CONFIG:
3448 if (wrq->u.data.length != sizeof(RT_802_11_STA_CONFIG))
3452 Status = copy_from_user(&StaConfig, wrq->u.data.pointer, wrq->u.data.length);
3453 pAdapter->CommonCfg.bEnableTxBurst = StaConfig.EnableTxBurst;
3454 pAdapter->CommonCfg.UseBGProtection = StaConfig.UseBGProtection;
3455 pAdapter->CommonCfg.bUseShortSlotTime = 1; // 2003-10-30 always SHORT SLOT capable
3456 if ((pAdapter->CommonCfg.PhyMode != StaConfig.AdhocMode) &&
3457 (StaConfig.AdhocMode <= MaxPhyMode))
3459 // allow dynamic change of "USE OFDM rate or not" in ADHOC mode
3460 // if setting changed, need to reset current TX rate as well as BEACON frame format
3461 pAdapter->CommonCfg.PhyMode = StaConfig.AdhocMode;
3462 if (pAdapter->StaCfg.BssType == BSS_ADHOC)
3464 RTMPSetPhyMode(pAdapter, PhyMode);
3465 MlmeUpdateTxRates(pAdapter, FALSE, 0);
3466 MakeIbssBeacon(pAdapter); // re-build BEACON frame
3467 AsicEnableIbssSync(pAdapter); // copy to on-chip memory
3470 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_SET_STA_CONFIG (Burst=%d, Protection=%ld,ShortSlot=%d\n",
3471 pAdapter->CommonCfg.bEnableTxBurst,
3472 pAdapter->CommonCfg.UseBGProtection,
3473 pAdapter->CommonCfg.bUseShortSlotTime));
3476 case OID_802_11_DESIRED_RATES:
3477 if (wrq->u.data.length != sizeof(NDIS_802_11_RATES))
3481 Status = copy_from_user(&aryRates, wrq->u.data.pointer, wrq->u.data.length);
3482 NdisZeroMemory(pAdapter->CommonCfg.DesireRate, MAX_LEN_OF_SUPPORTED_RATES);
3483 NdisMoveMemory(pAdapter->CommonCfg.DesireRate, &aryRates, sizeof(NDIS_802_11_RATES));
3484 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_DESIRED_RATES (%02x,%02x,%02x,%02x,%02x,%02x,%02x,%02x)\n",
3485 pAdapter->CommonCfg.DesireRate[0],pAdapter->CommonCfg.DesireRate[1],
3486 pAdapter->CommonCfg.DesireRate[2],pAdapter->CommonCfg.DesireRate[3],
3487 pAdapter->CommonCfg.DesireRate[4],pAdapter->CommonCfg.DesireRate[5],
3488 pAdapter->CommonCfg.DesireRate[6],pAdapter->CommonCfg.DesireRate[7] ));
3489 // Changing DesiredRate may affect the MAX TX rate we used to TX frames out
3490 MlmeUpdateTxRates(pAdapter, FALSE, 0);
3493 case RT_OID_802_11_PREAMBLE:
3494 if (wrq->u.data.length != sizeof(RT_802_11_PREAMBLE))
3498 Status = copy_from_user(&Preamble, wrq->u.data.pointer, wrq->u.data.length);
3499 if (Preamble == Rt802_11PreambleShort)
3501 pAdapter->CommonCfg.TxPreamble = Preamble;
3502 MlmeSetTxPreamble(pAdapter, Rt802_11PreambleShort);
3504 else if ((Preamble == Rt802_11PreambleLong) || (Preamble == Rt802_11PreambleAuto))
3506 // if user wants AUTO, initialize to LONG here, then change according to AP's
3507 // capability upon association.
3508 pAdapter->CommonCfg.TxPreamble = Preamble;
3509 MlmeSetTxPreamble(pAdapter, Rt802_11PreambleLong);
3516 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_PREAMBLE (=%d)\n", Preamble));
3519 case OID_802_11_WEP_STATUS:
3520 if (wrq->u.data.length != sizeof(NDIS_802_11_WEP_STATUS))
3524 Status = copy_from_user(&WepStatus, wrq->u.data.pointer, wrq->u.data.length);
3525 // Since TKIP, AES, WEP are all supported. It should not have any invalid setting
3526 if (WepStatus <= Ndis802_11Encryption3KeyAbsent)
3528 if (pAdapter->StaCfg.WepStatus != WepStatus)
3530 // Config has changed
3531 pAdapter->bConfigChanged = TRUE;
3533 pAdapter->StaCfg.WepStatus = WepStatus;
3534 pAdapter->StaCfg.OrigWepStatus = WepStatus;
3535 pAdapter->StaCfg.PairCipher = WepStatus;
3536 pAdapter->StaCfg.GroupCipher = WepStatus;
3543 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_WEP_STATUS (=%d)\n",WepStatus));
3546 case OID_802_11_AUTHENTICATION_MODE:
3547 if (wrq->u.data.length != sizeof(NDIS_802_11_AUTHENTICATION_MODE))
3551 Status = copy_from_user(&AuthMode, wrq->u.data.pointer, wrq->u.data.length);
3552 if (AuthMode > Ndis802_11AuthModeMax)
3559 if (pAdapter->StaCfg.AuthMode != AuthMode)
3561 // Config has changed
3562 pAdapter->bConfigChanged = TRUE;
3564 pAdapter->StaCfg.AuthMode = AuthMode;
3566 pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED;
3567 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_AUTHENTICATION_MODE (=%d) \n",pAdapter->StaCfg.AuthMode));
3570 case OID_802_11_INFRASTRUCTURE_MODE:
3571 if (wrq->u.data.length != sizeof(NDIS_802_11_NETWORK_INFRASTRUCTURE))
3575 Status = copy_from_user(&BssType, wrq->u.data.pointer, wrq->u.data.length);
3577 if (BssType == Ndis802_11IBSS)
3578 Set_NetworkType_Proc(pAdapter, "Adhoc");
3579 else if (BssType == Ndis802_11Infrastructure)
3580 Set_NetworkType_Proc(pAdapter, "Infra");
3581 else if (BssType == Ndis802_11Monitor)
3582 Set_NetworkType_Proc(pAdapter, "Monitor");
3586 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_INFRASTRUCTURE_MODE (unknown)\n"));
3590 case OID_802_11_REMOVE_WEP:
3591 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_WEP\n"));
3592 if (wrq->u.data.length != sizeof(NDIS_802_11_KEY_INDEX))
3598 KeyIdx = *(NDIS_802_11_KEY_INDEX *) wrq->u.data.pointer;
3600 if (KeyIdx & 0x80000000)
3602 // Should never set default bit when remove key
3607 KeyIdx = KeyIdx & 0x0fffffff;
3613 pAdapter->SharedKey[BSS0][KeyIdx].KeyLen = 0;
3614 pAdapter->SharedKey[BSS0][KeyIdx].CipherAlg = CIPHER_NONE;
3615 AsicRemoveSharedKeyEntry(pAdapter, 0, (UCHAR)KeyIdx);
3620 case RT_OID_802_11_RESET_COUNTERS:
3621 NdisZeroMemory(&pAdapter->WlanCounters, sizeof(COUNTER_802_11));
3622 NdisZeroMemory(&pAdapter->Counters8023, sizeof(COUNTER_802_3));
3623 NdisZeroMemory(&pAdapter->RalinkCounters, sizeof(COUNTER_RALINK));
3624 pAdapter->Counters8023.RxNoBuffer = 0;
3625 pAdapter->Counters8023.GoodReceives = 0;
3626 pAdapter->Counters8023.RxNoBuffer = 0;
3628 pAdapter->BulkOutComplete = 0;
3629 pAdapter->BulkOutCompleteOther= 0;
3630 pAdapter->BulkOutCompleteCancel = 0;
3631 pAdapter->BulkOutReq = 0;
3632 pAdapter->BulkInReq= 0;
3633 pAdapter->BulkInComplete = 0;
3634 pAdapter->BulkInCompleteFail = 0;
3636 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_RESET_COUNTERS \n"));
3638 case OID_802_11_RTS_THRESHOLD:
3639 if (wrq->u.data.length != sizeof(NDIS_802_11_RTS_THRESHOLD))
3643 Status = copy_from_user(&RtsThresh, wrq->u.data.pointer, wrq->u.data.length);
3644 if (RtsThresh > MAX_RTS_THRESHOLD)
3647 pAdapter->CommonCfg.RtsThreshold = (USHORT)RtsThresh;
3649 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_RTS_THRESHOLD (=%ld)\n",RtsThresh));
3651 case OID_802_11_FRAGMENTATION_THRESHOLD:
3652 if (wrq->u.data.length != sizeof(NDIS_802_11_FRAGMENTATION_THRESHOLD))
3656 Status = copy_from_user(&FragThresh, wrq->u.data.pointer, wrq->u.data.length);
3657 pAdapter->CommonCfg.bUseZeroToDisableFragment = FALSE;
3658 if (FragThresh > MAX_FRAG_THRESHOLD || FragThresh < MIN_FRAG_THRESHOLD)
3660 if (FragThresh == 0)
3662 pAdapter->CommonCfg.FragmentThreshold = MAX_FRAG_THRESHOLD;
3663 pAdapter->CommonCfg.bUseZeroToDisableFragment = TRUE;
3669 pAdapter->CommonCfg.FragmentThreshold = (USHORT)FragThresh;
3671 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_FRAGMENTATION_THRESHOLD (=%ld) \n",FragThresh));
3673 case OID_802_11_POWER_MODE:
3674 if (wrq->u.data.length != sizeof(NDIS_802_11_POWER_MODE))
3678 Status = copy_from_user(&PowerMode, wrq->u.data.pointer, wrq->u.data.length);
3679 if (PowerMode == Ndis802_11PowerModeCAM)
3680 Set_PSMode_Proc(pAdapter, "CAM");
3681 else if (PowerMode == Ndis802_11PowerModeMAX_PSP)
3682 Set_PSMode_Proc(pAdapter, "Max_PSP");
3683 else if (PowerMode == Ndis802_11PowerModeFast_PSP)
3684 Set_PSMode_Proc(pAdapter, "Fast_PSP");
3685 else if (PowerMode == Ndis802_11PowerModeLegacy_PSP)
3686 Set_PSMode_Proc(pAdapter, "Legacy_PSP");
3690 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_POWER_MODE (=%d)\n",PowerMode));
3692 case RT_OID_802_11_TX_POWER_LEVEL_1:
3693 if (wrq->u.data.length < sizeof(ULONG))
3697 Status = copy_from_user(&PowerTemp, wrq->u.data.pointer, wrq->u.data.length);
3698 if (PowerTemp > 100)
3699 PowerTemp = 0xffffffff; // AUTO
3700 pAdapter->CommonCfg.TxPowerDefault = PowerTemp; //keep current setting.
3701 pAdapter->CommonCfg.TxPowerPercentage = pAdapter->CommonCfg.TxPowerDefault;
3702 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_TX_POWER_LEVEL_1 (=%ld)\n", pAdapter->CommonCfg.TxPowerPercentage));
3705 case OID_802_11_NETWORK_TYPE_IN_USE:
3706 if (wrq->u.data.length != sizeof(NDIS_802_11_NETWORK_TYPE))
3710 Status = copy_from_user(&NetType, wrq->u.data.pointer, wrq->u.data.length);
3712 if (NetType == Ndis802_11DS)
3713 RTMPSetPhyMode(pAdapter, PHY_11B);
3714 else if (NetType == Ndis802_11OFDM24)
3715 RTMPSetPhyMode(pAdapter, PHY_11BG_MIXED);
3716 else if (NetType == Ndis802_11OFDM5)
3717 RTMPSetPhyMode(pAdapter, PHY_11A);
3720 #ifdef DOT11_N_SUPPORT
3721 if (Status == NDIS_STATUS_SUCCESS)
3722 SetCommonHT(pAdapter);
3723 #endif // DOT11_N_SUPPORT //
3724 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_NETWORK_TYPE_IN_USE (=%d)\n",NetType));
3727 // For WPA PSK PMK key
3728 case RT_OID_802_11_ADD_WPA:
3729 pKey = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
3736 Status = copy_from_user(pKey, wrq->u.data.pointer, wrq->u.data.length);
3737 if (pKey->Length != wrq->u.data.length)
3740 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_ADD_WPA, Failed!!\n"));
3744 if ((pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPAPSK) &&
3745 (pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPA2PSK) &&
3746 (pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPANone) )
3748 Status = -EOPNOTSUPP;
3749 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_ADD_WPA, Failed!! [AuthMode != WPAPSK/WPA2PSK/WPANONE]\n"));
3751 else if ((pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK) ||
3752 (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK) ||
3753 (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPANone) ) // Only for WPA PSK mode
3755 NdisMoveMemory(pAdapter->StaCfg.PMK, &pKey->KeyMaterial, pKey->KeyLength);
3756 // Use RaConfig as PSK agent.
3757 // Start STA supplicant state machine
3758 if (pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPANone)
3759 pAdapter->StaCfg.WpaState = SS_START;
3761 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_ADD_WPA (id=0x%x, Len=%d-byte)\n", pKey->KeyIndex, pKey->KeyLength));
3765 pAdapter->StaCfg.WpaState = SS_NOTUSE;
3766 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_ADD_WPA (id=0x%x, Len=%d-byte)\n", pKey->KeyIndex, pKey->KeyLength));
3771 case OID_802_11_REMOVE_KEY:
3772 pRemoveKey = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
3773 if(pRemoveKey == NULL)
3779 Status = copy_from_user(pRemoveKey, wrq->u.data.pointer, wrq->u.data.length);
3780 if (pRemoveKey->Length != wrq->u.data.length)
3783 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_KEY, Failed!!\n"));
3787 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
3789 RTMPWPARemoveKeyProc(pAdapter, pRemoveKey);
3790 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_KEY, Remove WPA Key!!\n"));
3794 KeyIdx = pRemoveKey->KeyIndex;
3796 if (KeyIdx & 0x80000000)
3798 // Should never set default bit when remove key
3800 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_KEY, Failed!!(Should never set default bit when remove key)\n"));
3804 KeyIdx = KeyIdx & 0x0fffffff;
3808 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_KEY, Failed!!(KeyId[%d] out of range)\n", KeyIdx));
3812 pAdapter->SharedKey[BSS0][KeyIdx].KeyLen = 0;
3813 pAdapter->SharedKey[BSS0][KeyIdx].CipherAlg = CIPHER_NONE;
3814 AsicRemoveSharedKeyEntry(pAdapter, 0, (UCHAR)KeyIdx);
3815 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_KEY (id=0x%x, Len=%d-byte)\n", pRemoveKey->KeyIndex, pRemoveKey->Length));
3823 case OID_802_11_ADD_KEY:
3824 pKey = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
3830 Status = copy_from_user(pKey, wrq->u.data.pointer, wrq->u.data.length);
3831 if (pKey->Length != wrq->u.data.length)
3834 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_KEY, Failed!!\n"));
3838 RTMPAddKey(pAdapter, pKey);
3839 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_KEY (id=0x%x, Len=%d-byte)\n", pKey->KeyIndex, pKey->KeyLength));
3843 case OID_802_11_CONFIGURATION:
3844 if (wrq->u.data.length != sizeof(NDIS_802_11_CONFIGURATION))
3848 Status = copy_from_user(&Config, wrq->u.data.pointer, wrq->u.data.length);
3851 if ((pConfig->BeaconPeriod >= 20) && (pConfig->BeaconPeriod <=400))
3852 pAdapter->CommonCfg.BeaconPeriod = (USHORT) pConfig->BeaconPeriod;
3854 pAdapter->StaActive.AtimWin = (USHORT) pConfig->ATIMWindow;
3855 MAP_KHZ_TO_CHANNEL_ID(pConfig->DSConfig, pAdapter->CommonCfg.Channel);
3857 // Save the channel on MlmeAux for CntlOidRTBssidProc used.
3859 pAdapter->MlmeAux.Channel = pAdapter->CommonCfg.Channel;
3861 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_CONFIGURATION (BeacnPeriod=%ld,AtimW=%ld,Ch=%d)\n",
3862 pConfig->BeaconPeriod, pConfig->ATIMWindow, pAdapter->CommonCfg.Channel));
3863 // Config has changed
3864 pAdapter->bConfigChanged = TRUE;
3867 #ifdef DOT11_N_SUPPORT
3868 case RT_OID_802_11_SET_HT_PHYMODE:
3869 if (wrq->u.data.length != sizeof(OID_SET_HT_PHYMODE))
3873 POID_SET_HT_PHYMODE pHTPhyMode = &HT_PhyMode;
3875 Status = copy_from_user(&HT_PhyMode, wrq->u.data.pointer, wrq->u.data.length);
3876 DBGPRINT(RT_DEBUG_TRACE, ("Set::pHTPhyMode (PhyMode = %d,TransmitNo = %d, HtMode = %d, ExtOffset = %d , MCS = %d, BW = %d, STBC = %d, SHORTGI = %d) \n",
3877 pHTPhyMode->PhyMode, pHTPhyMode->TransmitNo,pHTPhyMode->HtMode,pHTPhyMode->ExtOffset,
3878 pHTPhyMode->MCS, pHTPhyMode->BW, pHTPhyMode->STBC, pHTPhyMode->SHORTGI));
3879 if (pAdapter->CommonCfg.PhyMode >= PHY_11ABGN_MIXED)
3880 RTMPSetHT(pAdapter, pHTPhyMode);
3882 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_SET_HT_PHYMODE(MCS=%d,BW=%d,SGI=%d,STBC=%d)\n",
3883 pAdapter->StaCfg.HTPhyMode.field.MCS, pAdapter->StaCfg.HTPhyMode.field.BW, pAdapter->StaCfg.HTPhyMode.field.ShortGI,
3884 pAdapter->StaCfg.HTPhyMode.field.STBC));
3886 #endif // DOT11_N_SUPPORT //
3887 case RT_OID_802_11_SET_APSD_SETTING:
3888 if (wrq->u.data.length != sizeof(ULONG))
3893 Status = copy_from_user(&apsd, wrq->u.data.pointer, wrq->u.data.length);
3895 /*-------------------------------------------------------------------
3896 |B31~B7 | B6~B5 | B4 | B3 | B2 | B1 | B0 |
3897 ---------------------------------------------------------------------
3898 | Rsvd | Max SP Len | AC_VO | AC_VI | AC_BK | AC_BE | APSD Capable |
3899 ---------------------------------------------------------------------*/
3900 pAdapter->CommonCfg.bAPSDCapable = (apsd & 0x00000001) ? TRUE : FALSE;
3901 pAdapter->CommonCfg.bAPSDAC_BE = ((apsd & 0x00000002) >> 1) ? TRUE : FALSE;
3902 pAdapter->CommonCfg.bAPSDAC_BK = ((apsd & 0x00000004) >> 2) ? TRUE : FALSE;
3903 pAdapter->CommonCfg.bAPSDAC_VI = ((apsd & 0x00000008) >> 3) ? TRUE : FALSE;
3904 pAdapter->CommonCfg.bAPSDAC_VO = ((apsd & 0x00000010) >> 4) ? TRUE : FALSE;
3905 pAdapter->CommonCfg.MaxSPLength = (UCHAR)((apsd & 0x00000060) >> 5);
3907 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_SET_APSD_SETTING (apsd=0x%lx, APSDCap=%d, [BE,BK,VI,VO]=[%d/%d/%d/%d], MaxSPLen=%d)\n", apsd, pAdapter->CommonCfg.bAPSDCapable,
3908 pAdapter->CommonCfg.bAPSDAC_BE, pAdapter->CommonCfg.bAPSDAC_BK, pAdapter->CommonCfg.bAPSDAC_VI, pAdapter->CommonCfg.bAPSDAC_VO, pAdapter->CommonCfg.MaxSPLength));
3912 case RT_OID_802_11_SET_APSD_PSM:
3913 if (wrq->u.data.length != sizeof(ULONG))
3917 // Driver needs to notify AP when PSM changes
3918 Status = copy_from_user(&pAdapter->CommonCfg.bAPSDForcePowerSave, wrq->u.data.pointer, wrq->u.data.length);
3919 if (pAdapter->CommonCfg.bAPSDForcePowerSave != pAdapter->StaCfg.Psm)
3921 MlmeSetPsmBit(pAdapter, pAdapter->CommonCfg.bAPSDForcePowerSave);
3922 RTMPSendNullFrame(pAdapter, pAdapter->CommonCfg.TxRate, TRUE);
3924 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_SET_APSD_PSM (bAPSDForcePowerSave:%d)\n", pAdapter->CommonCfg.bAPSDForcePowerSave));
3927 #ifdef QOS_DLS_SUPPORT
3928 case RT_OID_802_11_SET_DLS:
3929 if (wrq->u.data.length != sizeof(ULONG))
3933 BOOLEAN oldvalue = pAdapter->CommonCfg.bDLSCapable;
3934 Status = copy_from_user(&pAdapter->CommonCfg.bDLSCapable, wrq->u.data.pointer, wrq->u.data.length);
3935 if (oldvalue && !pAdapter->CommonCfg.bDLSCapable)
3938 // tear down local dls table entry
3939 for (i=0; i<MAX_NUM_OF_INIT_DLS_ENTRY; i++)
3941 if (pAdapter->StaCfg.DLSEntry[i].Valid && (pAdapter->StaCfg.DLSEntry[i].Status == DLS_FINISH))
3943 pAdapter->StaCfg.DLSEntry[i].Status = DLS_NONE;
3944 pAdapter->StaCfg.DLSEntry[i].Valid = FALSE;
3945 RTMPSendDLSTearDownFrame(pAdapter, pAdapter->StaCfg.DLSEntry[i].MacAddr);
3949 // tear down peer dls table entry
3950 for (i=MAX_NUM_OF_INIT_DLS_ENTRY; i<MAX_NUM_OF_DLS_ENTRY; i++)
3952 if (pAdapter->StaCfg.DLSEntry[i].Valid && (pAdapter->StaCfg.DLSEntry[i].Status == DLS_FINISH))
3954 pAdapter->StaCfg.DLSEntry[i].Status = DLS_NONE;
3955 pAdapter->StaCfg.DLSEntry[i].Valid = FALSE;
3956 RTMPSendDLSTearDownFrame(pAdapter, pAdapter->StaCfg.DLSEntry[i].MacAddr);
3961 DBGPRINT(RT_DEBUG_TRACE,("Set::RT_OID_802_11_SET_DLS (=%d)\n", pAdapter->CommonCfg.bDLSCapable));
3965 case RT_OID_802_11_SET_DLS_PARAM:
3966 if (wrq->u.data.length != sizeof(RT_802_11_DLS_UI))
3972 NdisZeroMemory(&Dls, sizeof(RT_802_11_DLS));
3973 RTMPMoveMemory(&Dls, wrq->u.data.pointer, sizeof(RT_802_11_DLS_UI));
3974 MlmeEnqueue(pAdapter,
3975 MLME_CNTL_STATE_MACHINE,
3976 RT_OID_802_11_SET_DLS_PARAM,
3977 sizeof(RT_802_11_DLS),
3979 DBGPRINT(RT_DEBUG_TRACE,("Set::RT_OID_802_11_SET_DLS_PARAM \n"));
3982 #endif // QOS_DLS_SUPPORT //
3983 case RT_OID_802_11_SET_WMM:
3984 if (wrq->u.data.length != sizeof(BOOLEAN))
3988 Status = copy_from_user(&pAdapter->CommonCfg.bWmmCapable, wrq->u.data.pointer, wrq->u.data.length);
3989 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_SET_WMM (=%d) \n", pAdapter->CommonCfg.bWmmCapable));
3993 case OID_802_11_DISASSOCIATE:
3995 if (ATE_ON(pAdapter))
3997 DBGPRINT(RT_DEBUG_TRACE, ("The driver is in ATE mode now\n"));
4000 #endif // RALINK_ATE //
4002 // Set NdisRadioStateOff to TRUE, instead of called MlmeRadioOff.
4003 // Later on, NDIS_802_11_BSSID_LIST_EX->NumberOfItems should be 0
4004 // when query OID_802_11_BSSID_LIST.
4006 // TRUE: NumberOfItems will set to 0.
4007 // FALSE: NumberOfItems no change.
4009 pAdapter->CommonCfg.NdisRadioStateOff = TRUE;
4010 // Set to immediately send the media disconnect event
4011 pAdapter->MlmeAux.CurrReqIsFromNdis = TRUE;
4012 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_DISASSOCIATE \n"));
4014 if (INFRA_ON(pAdapter))
4016 if (pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE)
4018 RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
4019 DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
4022 MlmeEnqueue(pAdapter,
4023 MLME_CNTL_STATE_MACHINE,
4024 OID_802_11_DISASSOCIATE,
4028 StateMachineTouched = TRUE;
4032 #ifdef DOT11_N_SUPPORT
4033 case RT_OID_802_11_SET_IMME_BA_CAP:
4034 if (wrq->u.data.length != sizeof(OID_BACAP_STRUC))
4038 OID_BACAP_STRUC Orde ;
4039 Status = copy_from_user(&Orde, wrq->u.data.pointer, wrq->u.data.length);
4040 if (Orde.Policy > BA_NOTUSE)
4042 Status = NDIS_STATUS_INVALID_DATA;
4044 else if (Orde.Policy == BA_NOTUSE)
4046 pAdapter->CommonCfg.BACapability.field.Policy = BA_NOTUSE;
4047 pAdapter->CommonCfg.BACapability.field.MpduDensity = Orde.MpduDensity;
4048 pAdapter->CommonCfg.DesiredHtPhy.MpduDensity = Orde.MpduDensity;
4049 pAdapter->CommonCfg.DesiredHtPhy.AmsduEnable = Orde.AmsduEnable;
4050 pAdapter->CommonCfg.DesiredHtPhy.AmsduSize= Orde.AmsduSize;
4051 pAdapter->CommonCfg.DesiredHtPhy.MimoPs= Orde.MMPSmode;
4052 pAdapter->CommonCfg.BACapability.field.MMPSmode = Orde.MMPSmode;
4054 pAdapter->CommonCfg.HtCapability.HtCapInfo.MimoPs = Orde.MMPSmode;
4055 pAdapter->CommonCfg.HtCapability.HtCapInfo.AMsduSize = Orde.AmsduSize;
4056 pAdapter->CommonCfg.HtCapability.HtCapParm.MpduDensity = Orde.MpduDensity;
4060 pAdapter->CommonCfg.BACapability.field.AutoBA = Orde.AutoBA;
4061 pAdapter->CommonCfg.BACapability.field.Policy = IMMED_BA; // we only support immediate BA.
4062 pAdapter->CommonCfg.BACapability.field.MpduDensity = Orde.MpduDensity;
4063 pAdapter->CommonCfg.DesiredHtPhy.MpduDensity = Orde.MpduDensity;
4064 pAdapter->CommonCfg.DesiredHtPhy.AmsduEnable = Orde.AmsduEnable;
4065 pAdapter->CommonCfg.DesiredHtPhy.AmsduSize= Orde.AmsduSize;
4066 pAdapter->CommonCfg.DesiredHtPhy.MimoPs = Orde.MMPSmode;
4067 pAdapter->CommonCfg.BACapability.field.MMPSmode = Orde.MMPSmode;
4070 pAdapter->CommonCfg.HtCapability.HtCapInfo.MimoPs = Orde.MMPSmode;
4071 pAdapter->CommonCfg.HtCapability.HtCapInfo.AMsduSize = Orde.AmsduSize;
4072 pAdapter->CommonCfg.HtCapability.HtCapParm.MpduDensity = Orde.MpduDensity;
4074 if (pAdapter->CommonCfg.BACapability.field.RxBAWinLimit > MAX_RX_REORDERBUF)
4075 pAdapter->CommonCfg.BACapability.field.RxBAWinLimit = MAX_RX_REORDERBUF;
4079 pAdapter->CommonCfg.REGBACapability.word = pAdapter->CommonCfg.BACapability.word;
4080 DBGPRINT(RT_DEBUG_TRACE, ("Set::(Orde.AutoBA = %d) (Policy=%d)(ReBAWinLimit=%d)(TxBAWinLimit=%d)(AutoMode=%d)\n",Orde.AutoBA, pAdapter->CommonCfg.BACapability.field.Policy,
4081 pAdapter->CommonCfg.BACapability.field.RxBAWinLimit,pAdapter->CommonCfg.BACapability.field.TxBAWinLimit, pAdapter->CommonCfg.BACapability.field.AutoBA));
4082 DBGPRINT(RT_DEBUG_TRACE, ("Set::(MimoPs = %d)(AmsduEnable = %d) (AmsduSize=%d)(MpduDensity=%d)\n",pAdapter->CommonCfg.DesiredHtPhy.MimoPs, pAdapter->CommonCfg.DesiredHtPhy.AmsduEnable,
4083 pAdapter->CommonCfg.DesiredHtPhy.AmsduSize, pAdapter->CommonCfg.DesiredHtPhy.MpduDensity));
4087 case RT_OID_802_11_ADD_IMME_BA:
4088 DBGPRINT(RT_DEBUG_TRACE, (" Set :: RT_OID_802_11_ADD_IMME_BA \n"));
4089 if (wrq->u.data.length != sizeof(OID_ADD_BA_ENTRY))
4094 OID_ADD_BA_ENTRY BA;
4095 MAC_TABLE_ENTRY *pEntry;
4097 Status = copy_from_user(&BA, wrq->u.data.pointer, wrq->u.data.length);
4100 Status = NDIS_STATUS_INVALID_DATA;
4105 //BATableInsertEntry
4106 //As ad-hoc mode, BA pair is not limited to only BSSID. so add via OID.
4108 // in ad hoc mode, when adding BA pair, we should insert this entry into MACEntry too
4109 pEntry = MacTableLookup(pAdapter, BA.MACAddr);
4112 DBGPRINT(RT_DEBUG_TRACE, ("RT_OID_802_11_ADD_IMME_BA. break on no connection.----:%x:%x\n", BA.MACAddr[4], BA.MACAddr[5]));
4115 if (BA.IsRecipient == FALSE)
4117 if (pEntry->bIAmBadAtheros == TRUE)
4118 pAdapter->CommonCfg.BACapability.field.RxBAWinLimit = 0x10;
4120 BAOriSessionSetUp(pAdapter, pEntry, index, 0, 100, TRUE);
4124 //BATableInsertEntry(pAdapter, pEntry->Aid, BA.MACAddr, 0, 0xffff, BA.TID, BA.nMSDU, BA.IsRecipient);
4127 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_ADD_IMME_BA. Rec = %d. Mac = %x:%x:%x:%x:%x:%x . \n",
4128 BA.IsRecipient, BA.MACAddr[0], BA.MACAddr[1], BA.MACAddr[2], BA.MACAddr[2]
4129 , BA.MACAddr[4], BA.MACAddr[5]));
4134 case RT_OID_802_11_TEAR_IMME_BA:
4135 DBGPRINT(RT_DEBUG_TRACE, ("Set :: RT_OID_802_11_TEAR_IMME_BA \n"));
4136 if (wrq->u.data.length != sizeof(OID_ADD_BA_ENTRY))
4140 POID_ADD_BA_ENTRY pBA;
4141 MAC_TABLE_ENTRY *pEntry;
4143 pBA = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
4147 DBGPRINT(RT_DEBUG_TRACE, ("Set :: RT_OID_802_11_TEAR_IMME_BA kmalloc() can't allocate enough memory\n"));
4148 Status = NDIS_STATUS_FAILURE;
4152 Status = copy_from_user(pBA, wrq->u.data.pointer, wrq->u.data.length);
4153 DBGPRINT(RT_DEBUG_TRACE, ("Set :: RT_OID_802_11_TEAR_IMME_BA(TID=%d, bAllTid=%d)\n", pBA->TID, pBA->bAllTid));
4155 if (!pBA->bAllTid && (pBA->TID > NUM_OF_TID))
4157 Status = NDIS_STATUS_INVALID_DATA;
4161 if (pBA->IsRecipient == FALSE)
4163 pEntry = MacTableLookup(pAdapter, pBA->MACAddr);
4164 DBGPRINT(RT_DEBUG_TRACE, (" pBA->IsRecipient == FALSE\n"));
4167 DBGPRINT(RT_DEBUG_TRACE, (" pBA->pEntry\n"));
4168 BAOriSessionTearDown(pAdapter, pEntry->Aid, pBA->TID, FALSE, TRUE);
4171 DBGPRINT(RT_DEBUG_TRACE, ("Set :: Not found pEntry \n"));
4175 pEntry = MacTableLookup(pAdapter, pBA->MACAddr);
4178 BARecSessionTearDown( pAdapter, (UCHAR)pEntry->Aid, pBA->TID, TRUE);
4181 DBGPRINT(RT_DEBUG_TRACE, ("Set :: Not found pEntry \n"));
4187 #endif // DOT11_N_SUPPORT //
4189 // For WPA_SUPPLICANT to set static wep key
4190 case OID_802_11_ADD_WEP:
4191 pWepKey = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
4196 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_WEP, Failed!!\n"));
4199 Status = copy_from_user(pWepKey, wrq->u.data.pointer, wrq->u.data.length);
4203 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_WEP, Failed (length mismatch)!!\n"));
4207 KeyIdx = pWepKey->KeyIndex & 0x0fffffff;
4208 // KeyIdx must be 0 ~ 3
4212 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_WEP, Failed (KeyIdx must be smaller than 4)!!\n"));
4216 UCHAR CipherAlg = 0;
4219 // set key material and key length
4220 NdisZeroMemory(pAdapter->SharedKey[BSS0][KeyIdx].Key, 16);
4221 pAdapter->SharedKey[BSS0][KeyIdx].KeyLen = (UCHAR) pWepKey->KeyLength;
4222 NdisMoveMemory(pAdapter->SharedKey[BSS0][KeyIdx].Key, &pWepKey->KeyMaterial, pWepKey->KeyLength);
4224 switch(pWepKey->KeyLength)
4227 CipherAlg = CIPHER_WEP64;
4230 CipherAlg = CIPHER_WEP128;
4233 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_WEP, only support CIPHER_WEP64(len:5) & CIPHER_WEP128(len:13)!!\n"));
4237 pAdapter->SharedKey[BSS0][KeyIdx].CipherAlg = CipherAlg;
4239 // Default key for tx (shared key)
4240 if (pWepKey->KeyIndex & 0x80000000)
4242 #ifdef WPA_SUPPLICANT_SUPPORT
4243 // set key material and key length
4244 NdisZeroMemory(pAdapter->StaCfg.DesireSharedKey[KeyIdx].Key, 16);
4245 pAdapter->StaCfg.DesireSharedKey[KeyIdx].KeyLen = (UCHAR) pWepKey->KeyLength;
4246 NdisMoveMemory(pAdapter->StaCfg.DesireSharedKey[KeyIdx].Key, &pWepKey->KeyMaterial, pWepKey->KeyLength);
4247 pAdapter->StaCfg.DesireSharedKeyId = KeyIdx;
4248 pAdapter->StaCfg.DesireSharedKey[KeyIdx].CipherAlg = CipherAlg;
4249 #endif // WPA_SUPPLICANT_SUPPORT //
4250 pAdapter->StaCfg.DefaultKeyId = (UCHAR) KeyIdx;
4253 #ifdef WPA_SUPPLICANT_SUPPORT
4254 if (pAdapter->StaCfg.PortSecured == WPA_802_1X_PORT_SECURED)
4255 #endif // WPA_SUPPLICANT_SUPPORT
4257 Key = pAdapter->SharedKey[BSS0][KeyIdx].Key;
4259 // Set key material and cipherAlg to Asic
4260 AsicAddSharedKeyEntry(pAdapter, BSS0, KeyIdx, CipherAlg, Key, NULL, NULL);
4262 if (pWepKey->KeyIndex & 0x80000000)
4264 PMAC_TABLE_ENTRY pEntry = &pAdapter->MacTab.Content[BSSID_WCID];
4265 // Assign group key info
4266 RTMPAddWcidAttributeEntry(pAdapter, BSS0, KeyIdx, CipherAlg, NULL);
4267 // Assign pairwise key info
4268 RTMPAddWcidAttributeEntry(pAdapter, BSS0, KeyIdx, CipherAlg, pEntry);
4271 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_WEP (id=0x%x, Len=%d-byte), %s\n", pWepKey->KeyIndex, pWepKey->KeyLength, (pAdapter->StaCfg.PortSecured == WPA_802_1X_PORT_SECURED) ? "Port Secured":"Port NOT Secured"));
4276 #ifdef WPA_SUPPLICANT_SUPPORT
4277 case OID_SET_COUNTERMEASURES:
4278 if (wrq->u.data.length != sizeof(int))
4283 Status = copy_from_user(&enabled, wrq->u.data.pointer, wrq->u.data.length);
4285 pAdapter->StaCfg.bBlockAssoc = TRUE;
4287 // WPA MIC error should block association attempt for 60 seconds
4288 pAdapter->StaCfg.bBlockAssoc = FALSE;
4289 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_SET_COUNTERMEASURES bBlockAssoc=%s\n", pAdapter->StaCfg.bBlockAssoc ? "TRUE":"FALSE"));
4292 case RT_OID_WPA_SUPPLICANT_SUPPORT:
4293 if (wrq->u.data.length != sizeof(UCHAR))
4297 Status = copy_from_user(&wpa_supplicant_enable, wrq->u.data.pointer, wrq->u.data.length);
4298 pAdapter->StaCfg.WpaSupplicantUP = wpa_supplicant_enable;
4299 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_WPA_SUPPLICANT_SUPPORT (=%d)\n", pAdapter->StaCfg.WpaSupplicantUP));
4302 case OID_802_11_DEAUTHENTICATION:
4303 if (wrq->u.data.length != sizeof(MLME_DEAUTH_REQ_STRUCT))
4307 MLME_DEAUTH_REQ_STRUCT *pInfo;
4308 MLME_QUEUE_ELEM *MsgElem = (MLME_QUEUE_ELEM *) kmalloc(sizeof(MLME_QUEUE_ELEM), MEM_ALLOC_FLAG);
4310 pInfo = (MLME_DEAUTH_REQ_STRUCT *) MsgElem->Msg;
4311 Status = copy_from_user(pInfo, wrq->u.data.pointer, wrq->u.data.length);
4312 MlmeDeauthReqAction(pAdapter, MsgElem);
4315 if (INFRA_ON(pAdapter))
4317 LinkDown(pAdapter, FALSE);
4318 pAdapter->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
4320 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_DEAUTHENTICATION (Reason=%d)\n", pInfo->Reason));
4323 case OID_802_11_DROP_UNENCRYPTED:
4324 if (wrq->u.data.length != sizeof(int))
4329 Status = copy_from_user(&enabled, wrq->u.data.pointer, wrq->u.data.length);
4331 pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED;
4333 pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
4334 NdisAcquireSpinLock(&pAdapter->MacTabLock);
4335 pAdapter->MacTab.Content[BSSID_WCID].PortSecured = pAdapter->StaCfg.PortSecured;
4336 NdisReleaseSpinLock(&pAdapter->MacTabLock);
4337 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_DROP_UNENCRYPTED (=%d)\n", enabled));
4340 case OID_802_11_SET_IEEE8021X:
4341 if (wrq->u.data.length != sizeof(BOOLEAN))
4345 Status = copy_from_user(&IEEE8021xState, wrq->u.data.pointer, wrq->u.data.length);
4346 pAdapter->StaCfg.IEEE8021X = IEEE8021xState;
4347 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_SET_IEEE8021X (=%d)\n", IEEE8021xState));
4350 case OID_802_11_SET_IEEE8021X_REQUIRE_KEY:
4351 if (wrq->u.data.length != sizeof(BOOLEAN))
4355 Status = copy_from_user(&IEEE8021x_required_keys, wrq->u.data.pointer, wrq->u.data.length);
4356 pAdapter->StaCfg.IEEE8021x_required_keys = IEEE8021x_required_keys;
4357 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_SET_IEEE8021X_REQUIRE_KEY (%d)\n", IEEE8021x_required_keys));
4360 case OID_802_11_PMKID:
4361 pPmkId = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
4363 if(pPmkId == NULL) {
4367 Status = copy_from_user(pPmkId, wrq->u.data.pointer, wrq->u.data.length);
4369 // check the PMKID information
4370 if (pPmkId->BSSIDInfoCount == 0)
4371 NdisZeroMemory(pAdapter->StaCfg.SavedPMK, sizeof(BSSID_INFO)*PMKID_NO);
4374 PBSSID_INFO pBssIdInfo;
4378 for (BssIdx = 0; BssIdx < pPmkId->BSSIDInfoCount; BssIdx++)
4380 // point to the indexed BSSID_INFO structure
4381 pBssIdInfo = (PBSSID_INFO) ((PUCHAR) pPmkId + 2 * sizeof(UINT) + BssIdx * sizeof(BSSID_INFO));
4382 // Find the entry in the saved data base.
4383 for (CachedIdx = 0; CachedIdx < pAdapter->StaCfg.SavedPMKNum; CachedIdx++)
4385 // compare the BSSID
4386 if (NdisEqualMemory(pBssIdInfo->BSSID, pAdapter->StaCfg.SavedPMK[CachedIdx].BSSID, sizeof(NDIS_802_11_MAC_ADDRESS)))
4390 // Found, replace it
4391 if (CachedIdx < PMKID_NO)
4393 DBGPRINT(RT_DEBUG_OFF, ("Update OID_802_11_PMKID, idx = %d\n", CachedIdx));
4394 NdisMoveMemory(&pAdapter->StaCfg.SavedPMK[CachedIdx], pBssIdInfo, sizeof(BSSID_INFO));
4395 pAdapter->StaCfg.SavedPMKNum++;
4397 // Not found, replace the last one
4400 // Randomly replace one
4401 CachedIdx = (pBssIdInfo->BSSID[5] % PMKID_NO);
4402 DBGPRINT(RT_DEBUG_OFF, ("Update OID_802_11_PMKID, idx = %d\n", CachedIdx));
4403 NdisMoveMemory(&pAdapter->StaCfg.SavedPMK[CachedIdx], pBssIdInfo, sizeof(BSSID_INFO));
4410 #endif // WPA_SUPPLICANT_SUPPORT //
4415 case OID_802_11_SHORTRETRYLIMIT:
4416 if (wrq->u.data.length != sizeof(ULONG))
4420 Status = copy_from_user(&ShortRetryLimit, wrq->u.data.pointer, wrq->u.data.length);
4421 RTMP_IO_READ32(pAdapter, TX_RTY_CFG, &tx_rty_cfg.word);
4422 tx_rty_cfg.field.ShortRtyLimit = ShortRetryLimit;
4423 RTMP_IO_WRITE32(pAdapter, TX_RTY_CFG, tx_rty_cfg.word);
4424 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_SHORTRETRYLIMIT (tx_rty_cfg.field.ShortRetryLimit=%d, ShortRetryLimit=%ld)\n", tx_rty_cfg.field.ShortRtyLimit, ShortRetryLimit));
4428 case OID_802_11_LONGRETRYLIMIT:
4429 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_LONGRETRYLIMIT \n"));
4430 if (wrq->u.data.length != sizeof(ULONG))
4434 Status = copy_from_user(&LongRetryLimit, wrq->u.data.pointer, wrq->u.data.length);
4435 RTMP_IO_READ32(pAdapter, TX_RTY_CFG, &tx_rty_cfg.word);
4436 tx_rty_cfg.field.LongRtyLimit = LongRetryLimit;
4437 RTMP_IO_WRITE32(pAdapter, TX_RTY_CFG, tx_rty_cfg.word);
4438 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_LONGRETRYLIMIT (tx_rty_cfg.field.LongRetryLimit= %d,LongRetryLimit=%ld)\n", tx_rty_cfg.field.LongRtyLimit, LongRetryLimit));
4442 case OID_802_11_WEPDEFAULTKEYVALUE:
4443 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_WEPDEFAULTKEYVALUE\n"));
4444 pKey = kmalloc(wrq->u.data.length, GFP_KERNEL);
4445 Status = copy_from_user(pKey, wrq->u.data.pointer, wrq->u.data.length);
4448 if ( pKey->Length != wrq->u.data.length)
4451 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_WEPDEFAULTKEYVALUE, Failed!!\n"));
4453 KeyIdx = pKey->KeyIndex & 0x0fffffff;
4454 DBGPRINT(RT_DEBUG_TRACE,("pKey->KeyIndex =%d, pKey->KeyLength=%d\n", pKey->KeyIndex, pKey->KeyLength));
4456 // it is a shared key
4461 pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].KeyLen = (UCHAR) pKey->KeyLength;
4462 NdisMoveMemory(&pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].Key, &pKey->KeyMaterial, pKey->KeyLength);
4463 if (pKey->KeyIndex & 0x80000000)
4465 // Default key for tx (shared key)
4466 pAdapter->StaCfg.DefaultKeyId = (UCHAR) KeyIdx;
4468 //RestartAPIsRequired = TRUE;
4473 case OID_802_11_WEPDEFAULTKEYID:
4474 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_WEPDEFAULTKEYID \n"));
4476 if (wrq->u.data.length != sizeof(UCHAR))
4479 Status = copy_from_user(&pAdapter->StaCfg.DefaultKeyId, wrq->u.data.pointer, wrq->u.data.length);
4484 case OID_802_11_CURRENTCHANNEL:
4485 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_CURRENTCHANNEL \n"));
4486 if (wrq->u.data.length != sizeof(UCHAR))
4490 Status = copy_from_user(&ctmp, wrq->u.data.pointer, wrq->u.data.length);
4491 sprintf(&ctmp,"%d", ctmp);
4492 Set_Channel_Proc(pAdapter, &ctmp);
4500 DBGPRINT(RT_DEBUG_TRACE, ("Set::unknown IOCTL's subcmd = 0x%08x\n", cmd));
4501 Status = -EOPNOTSUPP;
4509 INT RTMPQueryInformation(
4510 IN PRTMP_ADAPTER pAdapter,
4511 IN OUT struct ifreq *rq,
4514 struct iwreq *wrq = (struct iwreq *) rq;
4515 NDIS_802_11_BSSID_LIST_EX *pBssidList = NULL;
4516 PNDIS_WLAN_BSSID_EX pBss;
4517 NDIS_802_11_SSID Ssid;
4518 NDIS_802_11_CONFIGURATION *pConfiguration = NULL;
4519 RT_802_11_LINK_STATUS *pLinkStatus = NULL;
4520 RT_802_11_STA_CONFIG *pStaConfig = NULL;
4521 NDIS_802_11_STATISTICS *pStatistics = NULL;
4522 NDIS_802_11_RTS_THRESHOLD RtsThresh;
4523 NDIS_802_11_FRAGMENTATION_THRESHOLD FragThresh;
4524 NDIS_802_11_POWER_MODE PowerMode;
4525 NDIS_802_11_NETWORK_INFRASTRUCTURE BssType;
4526 RT_802_11_PREAMBLE PreamType;
4527 NDIS_802_11_AUTHENTICATION_MODE AuthMode;
4528 NDIS_802_11_WEP_STATUS WepStatus;
4529 NDIS_MEDIA_STATE MediaState;
4530 ULONG BssBufSize, ulInfo=0, NetworkTypeList[4], apsd = 0;
4532 PUCHAR pBuf = NULL, pPtr;
4533 INT Status = NDIS_STATUS_SUCCESS;
4534 UINT we_version_compiled;
4535 UCHAR i, Padding = 0;
4537 UCHAR driverVersion[8];
4538 OID_SET_HT_PHYMODE *pHTPhyMode = NULL;
4543 DefaultKeyIdxValue *pKeyIdxValue;
4545 TX_RTY_CFG_STRUC tx_rty_cfg;
4546 ULONG ShortRetryLimit, LongRetryLimit;
4552 case RT_OID_DEVICE_NAME:
4553 wrq->u.data.length = sizeof(STA_NIC_DEVICE_NAME);
4554 Status = copy_to_user(wrq->u.data.pointer, STA_NIC_DEVICE_NAME, wrq->u.data.length);
4556 case RT_OID_VERSION_INFO:
4557 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_VERSION_INFO \n"));
4558 wrq->u.data.length = 8*sizeof(UCHAR);
4559 sprintf(&driverVersion[0], "%s", STA_DRIVER_VERSION);
4560 driverVersion[7] = '\0';
4561 if (copy_to_user(wrq->u.data.pointer, &driverVersion, wrq->u.data.length))
4567 case RT_QUERY_ATE_TXDONE_COUNT:
4568 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_QUERY_ATE_TXDONE_COUNT \n"));
4569 wrq->u.data.length = sizeof(UINT32);
4570 if (copy_to_user(wrq->u.data.pointer, &pAdapter->ate.TxDoneCount, wrq->u.data.length))
4575 #endif // RALINK_ATE //
4576 case OID_802_11_BSSID_LIST:
4577 if (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
4580 * Still scanning, indicate the caller should try again.
4582 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_BSSID_LIST (Still scanning)\n"));
4585 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_BSSID_LIST (%d BSS returned)\n",pAdapter->ScanTab.BssNr));
4586 pAdapter->StaCfg.bScanReqIsFromWebUI = FALSE;
4587 // Claculate total buffer size required
4588 BssBufSize = sizeof(ULONG);
4590 for (i = 0; i < pAdapter->ScanTab.BssNr; i++)
4592 // Align pointer to 4 bytes boundary.
4593 //Padding = 4 - (pAdapter->ScanTab.BssEntry[i].VarIELen & 0x0003);
4596 BssBufSize += (sizeof(NDIS_WLAN_BSSID_EX) - 1 + sizeof(NDIS_802_11_FIXED_IEs) + pAdapter->ScanTab.BssEntry[i].VarIELen + Padding);
4599 // For safety issue, we add 256 bytes just in case
4601 // Allocate the same size as passed from higher layer
4602 pBuf = kmalloc(BssBufSize, MEM_ALLOC_FLAG);
4608 // Init 802_11_BSSID_LIST_EX structure
4609 NdisZeroMemory(pBuf, BssBufSize);
4610 pBssidList = (PNDIS_802_11_BSSID_LIST_EX) pBuf;
4611 pBssidList->NumberOfItems = pAdapter->ScanTab.BssNr;
4613 // Calculate total buffer length
4614 BssLen = 4; // Consist of NumberOfItems
4615 // Point to start of NDIS_WLAN_BSSID_EX
4616 // pPtr = pBuf + sizeof(ULONG);
4617 pPtr = (PUCHAR) &pBssidList->Bssid[0];
4618 for (i = 0; i < pAdapter->ScanTab.BssNr; i++)
4620 pBss = (PNDIS_WLAN_BSSID_EX) pPtr;
4621 NdisMoveMemory(&pBss->MacAddress, &pAdapter->ScanTab.BssEntry[i].Bssid, MAC_ADDR_LEN);
4622 if ((pAdapter->ScanTab.BssEntry[i].Hidden == 1) && (pAdapter->StaCfg.bShowHiddenSSID == FALSE))
4625 // We must return this SSID during 4way handshaking, otherwise Aegis will failed to parse WPA infomation
4626 // and then failed to send EAPOl farame.
4628 if ((pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA) && (pAdapter->StaCfg.PortSecured != WPA_802_1X_PORT_SECURED))
4630 pBss->Ssid.SsidLength = pAdapter->ScanTab.BssEntry[i].SsidLen;
4631 NdisMoveMemory(pBss->Ssid.Ssid, pAdapter->ScanTab.BssEntry[i].Ssid, pAdapter->ScanTab.BssEntry[i].SsidLen);
4634 pBss->Ssid.SsidLength = 0;
4638 pBss->Ssid.SsidLength = pAdapter->ScanTab.BssEntry[i].SsidLen;
4639 NdisMoveMemory(pBss->Ssid.Ssid, pAdapter->ScanTab.BssEntry[i].Ssid, pAdapter->ScanTab.BssEntry[i].SsidLen);
4641 pBss->Privacy = pAdapter->ScanTab.BssEntry[i].Privacy;
4642 pBss->Rssi = pAdapter->ScanTab.BssEntry[i].Rssi - pAdapter->BbpRssiToDbmDelta;
4643 pBss->NetworkTypeInUse = NetworkTypeInUseSanity(&pAdapter->ScanTab.BssEntry[i]);
4644 pBss->Configuration.Length = sizeof(NDIS_802_11_CONFIGURATION);
4645 pBss->Configuration.BeaconPeriod = pAdapter->ScanTab.BssEntry[i].BeaconPeriod;
4646 pBss->Configuration.ATIMWindow = pAdapter->ScanTab.BssEntry[i].AtimWin;
4648 MAP_CHANNEL_ID_TO_KHZ(pAdapter->ScanTab.BssEntry[i].Channel, pBss->Configuration.DSConfig);
4650 if (pAdapter->ScanTab.BssEntry[i].BssType == BSS_INFRA)
4651 pBss->InfrastructureMode = Ndis802_11Infrastructure;
4653 pBss->InfrastructureMode = Ndis802_11IBSS;
4655 NdisMoveMemory(pBss->SupportedRates, pAdapter->ScanTab.BssEntry[i].SupRate, pAdapter->ScanTab.BssEntry[i].SupRateLen);
4656 NdisMoveMemory(pBss->SupportedRates + pAdapter->ScanTab.BssEntry[i].SupRateLen,
4657 pAdapter->ScanTab.BssEntry[i].ExtRate,
4658 pAdapter->ScanTab.BssEntry[i].ExtRateLen);
4660 if (pAdapter->ScanTab.BssEntry[i].VarIELen == 0)
4662 pBss->IELength = sizeof(NDIS_802_11_FIXED_IEs);
4663 NdisMoveMemory(pBss->IEs, &pAdapter->ScanTab.BssEntry[i].FixIEs, sizeof(NDIS_802_11_FIXED_IEs));
4664 pPtr = pPtr + sizeof(NDIS_WLAN_BSSID_EX) - 1 + sizeof(NDIS_802_11_FIXED_IEs);
4668 pBss->IELength = (ULONG)(sizeof(NDIS_802_11_FIXED_IEs) + pAdapter->ScanTab.BssEntry[i].VarIELen);
4669 pPtr = pPtr + sizeof(NDIS_WLAN_BSSID_EX) - 1 + sizeof(NDIS_802_11_FIXED_IEs);
4670 NdisMoveMemory(pBss->IEs, &pAdapter->ScanTab.BssEntry[i].FixIEs, sizeof(NDIS_802_11_FIXED_IEs));
4671 NdisMoveMemory(pBss->IEs + sizeof(NDIS_802_11_FIXED_IEs), pAdapter->ScanTab.BssEntry[i].VarIEs, pAdapter->ScanTab.BssEntry[i].VarIELen);
4672 pPtr += pAdapter->ScanTab.BssEntry[i].VarIELen;
4674 pBss->Length = (ULONG)(sizeof(NDIS_WLAN_BSSID_EX) - 1 + sizeof(NDIS_802_11_FIXED_IEs) + pAdapter->ScanTab.BssEntry[i].VarIELen + Padding);
4676 #if WIRELESS_EXT < 17
4677 if ((BssLen + pBss->Length) < wrq->u.data.length)
4678 BssLen += pBss->Length;
4681 pBssidList->NumberOfItems = i;
4685 BssLen += pBss->Length;
4689 #if WIRELESS_EXT < 17
4690 wrq->u.data.length = BssLen;
4692 if (BssLen > wrq->u.data.length)
4698 wrq->u.data.length = BssLen;
4700 Status = copy_to_user(wrq->u.data.pointer, pBssidList, BssLen);
4703 case OID_802_3_CURRENT_ADDRESS:
4704 wrq->u.data.length = MAC_ADDR_LEN;
4705 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CurrentAddress, wrq->u.data.length);
4707 case OID_GEN_MEDIA_CONNECT_STATUS:
4708 if (pAdapter->IndicateMediaState == NdisMediaStateConnected)
4709 MediaState = NdisMediaStateConnected;
4711 MediaState = NdisMediaStateDisconnected;
4713 wrq->u.data.length = sizeof(NDIS_MEDIA_STATE);
4714 Status = copy_to_user(wrq->u.data.pointer, &MediaState, wrq->u.data.length);
4716 case OID_802_11_BSSID:
4718 if (ATE_ON(pAdapter))
4720 DBGPRINT(RT_DEBUG_TRACE, ("The driver is in ATE mode now\n"));
4721 Status = NDIS_STATUS_RESOURCES;
4724 #endif // RALINK_ATE //
4725 if (INFRA_ON(pAdapter) || ADHOC_ON(pAdapter))
4727 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.Bssid, sizeof(NDIS_802_11_MAC_ADDRESS));
4732 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_BSSID(=EMPTY)\n"));
4736 case OID_802_11_SSID:
4737 NdisZeroMemory(&Ssid, sizeof(NDIS_802_11_SSID));
4738 NdisZeroMemory(Ssid.Ssid, MAX_LEN_OF_SSID);
4739 Ssid.SsidLength = pAdapter->CommonCfg.SsidLen;
4740 memcpy(Ssid.Ssid, pAdapter->CommonCfg.Ssid, Ssid.SsidLength);
4741 wrq->u.data.length = sizeof(NDIS_802_11_SSID);
4742 Status = copy_to_user(wrq->u.data.pointer, &Ssid, wrq->u.data.length);
4743 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_SSID (Len=%d, ssid=%s)\n", Ssid.SsidLength,Ssid.Ssid));
4745 case RT_OID_802_11_QUERY_LINK_STATUS:
4746 pLinkStatus = (RT_802_11_LINK_STATUS *) kmalloc(sizeof(RT_802_11_LINK_STATUS), MEM_ALLOC_FLAG);
4749 pLinkStatus->CurrTxRate = RateIdTo500Kbps[pAdapter->CommonCfg.TxRate]; // unit : 500 kbps
4750 pLinkStatus->ChannelQuality = pAdapter->Mlme.ChannelQuality;
4751 pLinkStatus->RxByteCount = pAdapter->RalinkCounters.ReceivedByteCount;
4752 pLinkStatus->TxByteCount = pAdapter->RalinkCounters.TransmittedByteCount;
4753 pLinkStatus->CentralChannel = pAdapter->CommonCfg.CentralChannel;
4754 wrq->u.data.length = sizeof(RT_802_11_LINK_STATUS);
4755 Status = copy_to_user(wrq->u.data.pointer, pLinkStatus, wrq->u.data.length);
4757 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_LINK_STATUS\n"));
4761 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_LINK_STATUS(kmalloc failed)\n"));
4765 case OID_802_11_CONFIGURATION:
4766 pConfiguration = (NDIS_802_11_CONFIGURATION *) kmalloc(sizeof(NDIS_802_11_CONFIGURATION), MEM_ALLOC_FLAG);
4769 pConfiguration->Length = sizeof(NDIS_802_11_CONFIGURATION);
4770 pConfiguration->BeaconPeriod = pAdapter->CommonCfg.BeaconPeriod;
4771 pConfiguration->ATIMWindow = pAdapter->StaActive.AtimWin;
4772 MAP_CHANNEL_ID_TO_KHZ(pAdapter->CommonCfg.Channel, pConfiguration->DSConfig);
4773 wrq->u.data.length = sizeof(NDIS_802_11_CONFIGURATION);
4774 Status = copy_to_user(wrq->u.data.pointer, pConfiguration, wrq->u.data.length);
4775 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_CONFIGURATION(BeaconPeriod=%ld,AtimW=%ld,Channel=%d) \n",
4776 pConfiguration->BeaconPeriod, pConfiguration->ATIMWindow, pAdapter->CommonCfg.Channel));
4777 kfree(pConfiguration);
4781 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_CONFIGURATION(kmalloc failed)\n"));
4785 case RT_OID_802_11_SNR_0:
4786 if ((pAdapter->StaCfg.LastSNR0 > 0))
4788 ulInfo = ((0xeb - pAdapter->StaCfg.LastSNR0) * 3) / 16 ;
4789 wrq->u.data.length = sizeof(ulInfo);
4790 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4791 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_SNR_0(0x=%lx)\n", ulInfo));
4796 case RT_OID_802_11_SNR_1:
4797 if ((pAdapter->Antenna.field.RxPath > 1) &&
4798 (pAdapter->StaCfg.LastSNR1 > 0))
4800 ulInfo = ((0xeb - pAdapter->StaCfg.LastSNR1) * 3) / 16 ;
4801 wrq->u.data.length = sizeof(ulInfo);
4802 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4803 DBGPRINT(RT_DEBUG_TRACE,("Query::RT_OID_802_11_SNR_1(0x=%lx)\n",ulInfo));
4807 DBGPRINT(RT_DEBUG_TRACE,("Query::RT_OID_802_11_SNR_1(pAdapter->StaCfg.LastSNR1=%d)\n",pAdapter->StaCfg.LastSNR1));
4809 case OID_802_11_RSSI_TRIGGER:
4810 ulInfo = pAdapter->StaCfg.RssiSample.LastRssi0 - pAdapter->BbpRssiToDbmDelta;
4811 wrq->u.data.length = sizeof(ulInfo);
4812 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4813 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_RSSI_TRIGGER(=%ld)\n", ulInfo));
4815 case OID_802_11_RSSI:
4816 case RT_OID_802_11_RSSI:
4817 ulInfo = pAdapter->StaCfg.RssiSample.LastRssi0;
4818 wrq->u.data.length = sizeof(ulInfo);
4819 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4821 case RT_OID_802_11_RSSI_1:
4822 ulInfo = pAdapter->StaCfg.RssiSample.LastRssi1;
4823 wrq->u.data.length = sizeof(ulInfo);
4824 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4826 case RT_OID_802_11_RSSI_2:
4827 ulInfo = pAdapter->StaCfg.RssiSample.LastRssi2;
4828 wrq->u.data.length = sizeof(ulInfo);
4829 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4831 case OID_802_11_STATISTICS:
4832 pStatistics = (NDIS_802_11_STATISTICS *) kmalloc(sizeof(NDIS_802_11_STATISTICS), MEM_ALLOC_FLAG);
4835 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_STATISTICS \n"));
4836 // add the most up-to-date h/w raw counters into software counters
4837 NICUpdateRawCounters(pAdapter);
4839 // Sanity check for calculation of sucessful count
4840 if (pAdapter->WlanCounters.TransmittedFragmentCount.QuadPart < pAdapter->WlanCounters.RetryCount.QuadPart)
4841 pAdapter->WlanCounters.TransmittedFragmentCount.QuadPart = pAdapter->WlanCounters.RetryCount.QuadPart;
4843 pStatistics->TransmittedFragmentCount.QuadPart = pAdapter->WlanCounters.TransmittedFragmentCount.QuadPart;
4844 pStatistics->MulticastTransmittedFrameCount.QuadPart = pAdapter->WlanCounters.MulticastTransmittedFrameCount.QuadPart;
4845 pStatistics->FailedCount.QuadPart = pAdapter->WlanCounters.FailedCount.QuadPart;
4846 pStatistics->RetryCount.QuadPart = pAdapter->WlanCounters.RetryCount.QuadPart;
4847 pStatistics->MultipleRetryCount.QuadPart = pAdapter->WlanCounters.MultipleRetryCount.QuadPart;
4848 pStatistics->RTSSuccessCount.QuadPart = pAdapter->WlanCounters.RTSSuccessCount.QuadPart;
4849 pStatistics->RTSFailureCount.QuadPart = pAdapter->WlanCounters.RTSFailureCount.QuadPart;
4850 pStatistics->ACKFailureCount.QuadPart = pAdapter->WlanCounters.ACKFailureCount.QuadPart;
4851 pStatistics->FrameDuplicateCount.QuadPart = pAdapter->WlanCounters.FrameDuplicateCount.QuadPart;
4852 pStatistics->ReceivedFragmentCount.QuadPart = pAdapter->WlanCounters.ReceivedFragmentCount.QuadPart;
4853 pStatistics->MulticastReceivedFrameCount.QuadPart = pAdapter->WlanCounters.MulticastReceivedFrameCount.QuadPart;
4855 pStatistics->FCSErrorCount = pAdapter->RalinkCounters.RealFcsErrCount;
4857 pStatistics->FCSErrorCount.QuadPart = pAdapter->WlanCounters.FCSErrorCount.QuadPart;
4858 pStatistics->FrameDuplicateCount.u.LowPart = pAdapter->WlanCounters.FrameDuplicateCount.u.LowPart / 100;
4860 wrq->u.data.length = sizeof(NDIS_802_11_STATISTICS);
4861 Status = copy_to_user(wrq->u.data.pointer, pStatistics, wrq->u.data.length);
4866 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_STATISTICS(kmalloc failed)\n"));
4870 case OID_GEN_RCV_OK:
4871 ulInfo = pAdapter->Counters8023.GoodReceives;
4872 wrq->u.data.length = sizeof(ulInfo);
4873 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4875 case OID_GEN_RCV_NO_BUFFER:
4876 ulInfo = pAdapter->Counters8023.RxNoBuffer;
4877 wrq->u.data.length = sizeof(ulInfo);
4878 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4880 case RT_OID_802_11_PHY_MODE:
4881 ulInfo = (ULONG)pAdapter->CommonCfg.PhyMode;
4882 wrq->u.data.length = sizeof(ulInfo);
4883 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4884 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_PHY_MODE (=%ld)\n", ulInfo));
4886 case RT_OID_802_11_STA_CONFIG:
4887 pStaConfig = (RT_802_11_STA_CONFIG *) kmalloc(sizeof(RT_802_11_STA_CONFIG), MEM_ALLOC_FLAG);
4890 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_STA_CONFIG\n"));
4891 pStaConfig->EnableTxBurst = pAdapter->CommonCfg.bEnableTxBurst;
4892 pStaConfig->EnableTurboRate = 0;
4893 pStaConfig->UseBGProtection = pAdapter->CommonCfg.UseBGProtection;
4894 pStaConfig->UseShortSlotTime = pAdapter->CommonCfg.bUseShortSlotTime;
4895 //pStaConfig->AdhocMode = pAdapter->StaCfg.AdhocMode;
4896 pStaConfig->HwRadioStatus = (pAdapter->StaCfg.bHwRadio == TRUE) ? 1 : 0;
4897 pStaConfig->Rsv1 = 0;
4898 pStaConfig->SystemErrorBitmap = pAdapter->SystemErrorBitmap;
4899 wrq->u.data.length = sizeof(RT_802_11_STA_CONFIG);
4900 Status = copy_to_user(wrq->u.data.pointer, pStaConfig, wrq->u.data.length);
4905 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_STA_CONFIG(kmalloc failed)\n"));
4909 case OID_802_11_RTS_THRESHOLD:
4910 RtsThresh = pAdapter->CommonCfg.RtsThreshold;
4911 wrq->u.data.length = sizeof(RtsThresh);
4912 Status = copy_to_user(wrq->u.data.pointer, &RtsThresh, wrq->u.data.length);
4913 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_RTS_THRESHOLD(=%ld)\n", RtsThresh));
4915 case OID_802_11_FRAGMENTATION_THRESHOLD:
4916 FragThresh = pAdapter->CommonCfg.FragmentThreshold;
4917 if (pAdapter->CommonCfg.bUseZeroToDisableFragment == TRUE)
4919 wrq->u.data.length = sizeof(FragThresh);
4920 Status = copy_to_user(wrq->u.data.pointer, &FragThresh, wrq->u.data.length);
4921 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_FRAGMENTATION_THRESHOLD(=%ld)\n", FragThresh));
4923 case OID_802_11_POWER_MODE:
4924 PowerMode = pAdapter->StaCfg.WindowsPowerMode;
4925 wrq->u.data.length = sizeof(PowerMode);
4926 Status = copy_to_user(wrq->u.data.pointer, &PowerMode, wrq->u.data.length);
4927 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_POWER_MODE(=%d)\n", PowerMode));
4929 case RT_OID_802_11_RADIO:
4930 RadioState = (BOOLEAN) pAdapter->StaCfg.bSwRadio;
4931 wrq->u.data.length = sizeof(RadioState);
4932 Status = copy_to_user(wrq->u.data.pointer, &RadioState, wrq->u.data.length);
4933 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_RADIO (=%d)\n", RadioState));
4935 case OID_802_11_INFRASTRUCTURE_MODE:
4936 if (pAdapter->StaCfg.BssType == BSS_ADHOC)
4937 BssType = Ndis802_11IBSS;
4938 else if (pAdapter->StaCfg.BssType == BSS_INFRA)
4939 BssType = Ndis802_11Infrastructure;
4940 else if (pAdapter->StaCfg.BssType == BSS_MONITOR)
4941 BssType = Ndis802_11Monitor;
4943 BssType = Ndis802_11AutoUnknown;
4945 wrq->u.data.length = sizeof(BssType);
4946 Status = copy_to_user(wrq->u.data.pointer, &BssType, wrq->u.data.length);
4947 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_INFRASTRUCTURE_MODE(=%d)\n", BssType));
4949 case RT_OID_802_11_PREAMBLE:
4950 PreamType = pAdapter->CommonCfg.TxPreamble;
4951 wrq->u.data.length = sizeof(PreamType);
4952 Status = copy_to_user(wrq->u.data.pointer, &PreamType, wrq->u.data.length);
4953 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_PREAMBLE(=%d)\n", PreamType));
4955 case OID_802_11_AUTHENTICATION_MODE:
4956 AuthMode = pAdapter->StaCfg.AuthMode;
4957 wrq->u.data.length = sizeof(AuthMode);
4958 Status = copy_to_user(wrq->u.data.pointer, &AuthMode, wrq->u.data.length);
4959 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_AUTHENTICATION_MODE(=%d)\n", AuthMode));
4961 case OID_802_11_WEP_STATUS:
4962 WepStatus = pAdapter->StaCfg.WepStatus;
4963 wrq->u.data.length = sizeof(WepStatus);
4964 Status = copy_to_user(wrq->u.data.pointer, &WepStatus, wrq->u.data.length);
4965 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_WEP_STATUS(=%d)\n", WepStatus));
4967 case OID_802_11_TX_POWER_LEVEL:
4968 wrq->u.data.length = sizeof(ULONG);
4969 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.TxPower, wrq->u.data.length);
4970 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_TX_POWER_LEVEL %x\n",pAdapter->CommonCfg.TxPower));
4972 case RT_OID_802_11_TX_POWER_LEVEL_1:
4973 wrq->u.data.length = sizeof(ULONG);
4974 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.TxPowerPercentage, wrq->u.data.length);
4975 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_TX_POWER_LEVEL_1 (=%ld)\n", pAdapter->CommonCfg.TxPowerPercentage));
4977 case OID_802_11_NETWORK_TYPES_SUPPORTED:
4978 if ((pAdapter->RfIcType == RFIC_2850) || (pAdapter->RfIcType == RFIC_2750))
4980 NetworkTypeList[0] = 3; // NumberOfItems = 3
4981 NetworkTypeList[1] = Ndis802_11DS; // NetworkType[1] = 11b
4982 NetworkTypeList[2] = Ndis802_11OFDM24; // NetworkType[2] = 11g
4983 NetworkTypeList[3] = Ndis802_11OFDM5; // NetworkType[3] = 11a
4984 wrq->u.data.length = 16;
4985 Status = copy_to_user(wrq->u.data.pointer, &NetworkTypeList[0], wrq->u.data.length);
4989 NetworkTypeList[0] = 2; // NumberOfItems = 2
4990 NetworkTypeList[1] = Ndis802_11DS; // NetworkType[1] = 11b
4991 NetworkTypeList[2] = Ndis802_11OFDM24; // NetworkType[2] = 11g
4992 wrq->u.data.length = 12;
4993 Status = copy_to_user(wrq->u.data.pointer, &NetworkTypeList[0], wrq->u.data.length);
4995 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_NETWORK_TYPES_SUPPORTED\n"));
4997 case OID_802_11_NETWORK_TYPE_IN_USE:
4998 wrq->u.data.length = sizeof(ULONG);
4999 if (pAdapter->CommonCfg.PhyMode == PHY_11A)
5000 ulInfo = Ndis802_11OFDM5;
5001 else if ((pAdapter->CommonCfg.PhyMode == PHY_11BG_MIXED) || (pAdapter->CommonCfg.PhyMode == PHY_11G))
5002 ulInfo = Ndis802_11OFDM24;
5004 ulInfo = Ndis802_11DS;
5005 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
5007 case RT_OID_802_11_QUERY_LAST_RX_RATE:
5008 ulInfo = (ULONG)pAdapter->LastRxRate;
5009 wrq->u.data.length = sizeof(ulInfo);
5010 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
5011 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_LAST_RX_RATE (=%ld)\n", ulInfo));
5013 case RT_OID_802_11_QUERY_LAST_TX_RATE:
5014 //ulInfo = (ULONG)pAdapter->LastTxRate;
5015 ulInfo = (ULONG)pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.word;
5016 wrq->u.data.length = sizeof(ulInfo);
5017 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
5018 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_LAST_TX_RATE (=%lx)\n", ulInfo));
5020 case RT_OID_802_11_QUERY_EEPROM_VERSION:
5021 wrq->u.data.length = sizeof(ULONG);
5022 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->EepromVersion, wrq->u.data.length);
5024 case RT_OID_802_11_QUERY_FIRMWARE_VERSION:
5025 wrq->u.data.length = sizeof(ULONG);
5026 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->FirmwareVersion, wrq->u.data.length);
5028 case RT_OID_802_11_QUERY_NOISE_LEVEL:
5029 wrq->u.data.length = sizeof(UCHAR);
5030 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->BbpWriteLatch[66], wrq->u.data.length);
5031 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_NOISE_LEVEL (=%d)\n", pAdapter->BbpWriteLatch[66]));
5033 case RT_OID_802_11_EXTRA_INFO:
5034 wrq->u.data.length = sizeof(ULONG);
5035 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->ExtraInfo, wrq->u.data.length);
5036 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_EXTRA_INFO (=%ld)\n", pAdapter->ExtraInfo));
5038 case RT_OID_WE_VERSION_COMPILED:
5039 wrq->u.data.length = sizeof(UINT);
5040 we_version_compiled = WIRELESS_EXT;
5041 Status = copy_to_user(wrq->u.data.pointer, &we_version_compiled, wrq->u.data.length);
5043 case RT_OID_802_11_QUERY_APSD_SETTING:
5044 apsd = (pAdapter->CommonCfg.bAPSDCapable | (pAdapter->CommonCfg.bAPSDAC_BE << 1) | (pAdapter->CommonCfg.bAPSDAC_BK << 2)
5045 | (pAdapter->CommonCfg.bAPSDAC_VI << 3) | (pAdapter->CommonCfg.bAPSDAC_VO << 4) | (pAdapter->CommonCfg.MaxSPLength << 5));
5047 wrq->u.data.length = sizeof(ULONG);
5048 Status = copy_to_user(wrq->u.data.pointer, &apsd, wrq->u.data.length);
5049 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",
5050 apsd,pAdapter->CommonCfg.bAPSDCapable,pAdapter->CommonCfg.bAPSDAC_BE,pAdapter->CommonCfg.bAPSDAC_BK,pAdapter->CommonCfg.bAPSDAC_VI,pAdapter->CommonCfg.bAPSDAC_VO,pAdapter->CommonCfg.MaxSPLength));
5052 case RT_OID_802_11_QUERY_APSD_PSM:
5053 wrq->u.data.length = sizeof(ULONG);
5054 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.bAPSDForcePowerSave, wrq->u.data.length);
5055 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_APSD_PSM (=%d)\n", pAdapter->CommonCfg.bAPSDForcePowerSave));
5057 case RT_OID_802_11_QUERY_WMM:
5058 wrq->u.data.length = sizeof(BOOLEAN);
5059 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.bWmmCapable, wrq->u.data.length);
5060 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_WMM (=%d)\n", pAdapter->CommonCfg.bWmmCapable));
5062 #ifdef WPA_SUPPLICANT_SUPPORT
5063 case RT_OID_NEW_DRIVER:
5066 wrq->u.data.length = sizeof(UCHAR);
5067 Status = copy_to_user(wrq->u.data.pointer, &enabled, wrq->u.data.length);
5068 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_NEW_DRIVER (=%d)\n", enabled));
5071 case RT_OID_WPA_SUPPLICANT_SUPPORT:
5072 wrq->u.data.length = sizeof(UCHAR);
5073 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->StaCfg.WpaSupplicantUP, wrq->u.data.length);
5074 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_WPA_SUPPLICANT_SUPPORT (=%d)\n", pAdapter->StaCfg.WpaSupplicantUP));
5076 #endif // WPA_SUPPLICANT_SUPPORT //
5078 case RT_OID_DRIVER_DEVICE_NAME:
5079 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_DRIVER_DEVICE_NAME \n"));
5080 wrq->u.data.length = 16;
5081 if (copy_to_user(wrq->u.data.pointer, pAdapter->StaCfg.dev_name, wrq->u.data.length))
5086 case RT_OID_802_11_QUERY_HT_PHYMODE:
5087 pHTPhyMode = (OID_SET_HT_PHYMODE *) kmalloc(sizeof(OID_SET_HT_PHYMODE), MEM_ALLOC_FLAG);
5090 pHTPhyMode->PhyMode = pAdapter->CommonCfg.PhyMode;
5091 pHTPhyMode->HtMode = (UCHAR)pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.field.MODE;
5092 pHTPhyMode->BW = (UCHAR)pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.field.BW;
5093 pHTPhyMode->MCS= (UCHAR)pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.field.MCS;
5094 pHTPhyMode->SHORTGI= (UCHAR)pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.field.ShortGI;
5095 pHTPhyMode->STBC= (UCHAR)pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.field.STBC;
5097 pHTPhyMode->ExtOffset = ((pAdapter->CommonCfg.CentralChannel < pAdapter->CommonCfg.Channel) ? (EXTCHA_BELOW) : (EXTCHA_ABOVE));
5098 wrq->u.data.length = sizeof(OID_SET_HT_PHYMODE);
5099 if (copy_to_user(wrq->u.data.pointer, pHTPhyMode, wrq->u.data.length))
5103 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_HT_PHYMODE (PhyMode = %d, MCS =%d, BW = %d, STBC = %d, ExtOffset=%d)\n",
5104 pHTPhyMode->HtMode, pHTPhyMode->MCS, pHTPhyMode->BW, pHTPhyMode->STBC, pHTPhyMode->ExtOffset));
5105 DBGPRINT(RT_DEBUG_TRACE, (" MlmeUpdateTxRates (.word = %x )\n", pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.word));
5109 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_STA_CONFIG(kmalloc failed)\n"));
5113 case RT_OID_802_11_COUNTRY_REGION:
5114 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_COUNTRY_REGION \n"));
5115 wrq->u.data.length = sizeof(ulInfo);
5116 ulInfo = pAdapter->CommonCfg.CountryRegionForABand;
5117 ulInfo = (ulInfo << 8)|(pAdapter->CommonCfg.CountryRegion);
5118 if (copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length))
5123 case RT_OID_802_11_QUERY_DAT_HT_PHYMODE:
5124 pHTPhyMode = (OID_SET_HT_PHYMODE *) kmalloc(sizeof(OID_SET_HT_PHYMODE), MEM_ALLOC_FLAG);
5127 pHTPhyMode->PhyMode = pAdapter->CommonCfg.PhyMode;
5128 pHTPhyMode->HtMode = (UCHAR)pAdapter->CommonCfg.RegTransmitSetting.field.HTMODE;
5129 pHTPhyMode->BW = (UCHAR)pAdapter->CommonCfg.RegTransmitSetting.field.BW;
5130 pHTPhyMode->MCS= (UCHAR)pAdapter->StaCfg.DesiredTransmitSetting.field.MCS;
5131 pHTPhyMode->SHORTGI= (UCHAR)pAdapter->CommonCfg.RegTransmitSetting.field.ShortGI;
5132 pHTPhyMode->STBC= (UCHAR)pAdapter->CommonCfg.RegTransmitSetting.field.STBC;
5134 wrq->u.data.length = sizeof(OID_SET_HT_PHYMODE);
5135 if (copy_to_user(wrq->u.data.pointer, pHTPhyMode, wrq->u.data.length))
5139 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_HT_PHYMODE (PhyMode = %d, MCS =%d, BW = %d, STBC = %d, ExtOffset=%d)\n",
5140 pHTPhyMode->HtMode, pHTPhyMode->MCS, pHTPhyMode->BW, pHTPhyMode->STBC, pHTPhyMode->ExtOffset));
5141 DBGPRINT(RT_DEBUG_TRACE, (" MlmeUpdateTxRates (.word = %x )\n", pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.word));
5145 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_STA_CONFIG(kmalloc failed)\n"));
5149 case RT_OID_QUERY_MULTIPLE_CARD_SUPPORT:
5150 wrq->u.data.length = sizeof(UCHAR);
5152 #ifdef MULTIPLE_CARD_SUPPORT
5154 #endif // MULTIPLE_CARD_SUPPORT //
5155 if (copy_to_user(wrq->u.data.pointer, &i, wrq->u.data.length))
5159 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_QUERY_MULTIPLE_CARD_SUPPORT(=%d) \n", i));
5162 case RT_OID_802_11_MAC_ADDRESS:
5163 wrq->u.data.length = MAC_ADDR_LEN;
5164 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CurrentAddress, wrq->u.data.length);
5167 case RT_OID_802_11_MANUFACTUREROUI:
5168 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_MANUFACTUREROUI \n"));
5169 wrq->u.data.length = ManufacturerOUI_LEN;
5170 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CurrentAddress, wrq->u.data.length);
5173 case RT_OID_802_11_MANUFACTURERNAME:
5174 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_MANUFACTURERNAME \n"));
5175 wrq->u.data.length = strlen(ManufacturerNAME);
5176 Status = copy_to_user(wrq->u.data.pointer, ManufacturerNAME, wrq->u.data.length);
5179 case RT_OID_802_11_RESOURCETYPEIDNAME:
5180 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_RESOURCETYPEIDNAME \n"));
5181 wrq->u.data.length = strlen(ResourceTypeIdName);
5182 Status = copy_to_user(wrq->u.data.pointer, ResourceTypeIdName, wrq->u.data.length);
5185 case RT_OID_802_11_PRIVACYOPTIONIMPLEMENTED:
5186 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_PRIVACYOPTIONIMPLEMENTED \n"));
5187 ulInfo = 1; // 1 is support wep else 2 is not support.
5188 wrq->u.data.length = sizeof(ulInfo);
5189 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
5192 case RT_OID_802_11_POWERMANAGEMENTMODE:
5193 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_POWERMANAGEMENTMODE \n"));
5194 if (pAdapter->StaCfg.Psm == PSMP_ACTION)
5195 ulInfo = 1; // 1 is power active else 2 is power save.
5199 wrq->u.data.length = sizeof(ulInfo);
5200 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
5203 case OID_802_11_WEPDEFAULTKEYVALUE:
5204 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_WEPDEFAULTKEYVALUE \n"));
5205 //KeyIdxValue.KeyIdx = pAd->PortCfg.MBSSID[pAd->IoctlIF].DefaultKeyId;
5206 pKeyIdxValue = wrq->u.data.pointer;
5207 DBGPRINT(RT_DEBUG_TRACE,("KeyIdxValue.KeyIdx = %d, \n",pKeyIdxValue->KeyIdx));
5208 valueLen = pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].KeyLen;
5209 NdisMoveMemory(pKeyIdxValue->Value,
5210 &pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].Key,
5212 pKeyIdxValue->Value[valueLen]='\0';
5214 wrq->u.data.length = sizeof(DefaultKeyIdxValue);
5216 Status = copy_to_user(wrq->u.data.pointer, pKeyIdxValue, wrq->u.data.length);
5217 DBGPRINT(RT_DEBUG_TRACE,("DefaultKeyId = %d, total len = %d, str len=%d, KeyValue= %02x %02x %02x %02x \n", pAdapter->StaCfg.DefaultKeyId, wrq->u.data.length, pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].KeyLen,
5218 pAdapter->SharedKey[BSS0][0].Key[0],
5219 pAdapter->SharedKey[BSS0][1].Key[0],
5220 pAdapter->SharedKey[BSS0][2].Key[0],
5221 pAdapter->SharedKey[BSS0][3].Key[0]));
5224 case OID_802_11_WEPDEFAULTKEYID:
5225 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_WEPDEFAULTKEYID \n"));
5226 wrq->u.data.length = sizeof(UCHAR);
5227 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->StaCfg.DefaultKeyId, wrq->u.data.length);
5228 DBGPRINT(RT_DEBUG_TRACE, ("DefaultKeyId =%d \n", pAdapter->StaCfg.DefaultKeyId));
5231 case RT_OID_802_11_WEPKEYMAPPINGLENGTH:
5232 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_WEPKEYMAPPINGLENGTH \n"));
5233 wrq->u.data.length = sizeof(UCHAR);
5234 Status = copy_to_user(wrq->u.data.pointer,
5235 &pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].KeyLen,
5236 wrq->u.data.length);
5239 case OID_802_11_SHORTRETRYLIMIT:
5240 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_SHORTRETRYLIMIT \n"));
5241 wrq->u.data.length = sizeof(ULONG);
5242 RTMP_IO_READ32(pAdapter, TX_RTY_CFG, &tx_rty_cfg.word);
5243 ShortRetryLimit = tx_rty_cfg.field.ShortRtyLimit;
5244 DBGPRINT(RT_DEBUG_TRACE, ("ShortRetryLimit =%ld, tx_rty_cfg.field.ShortRetryLimit=%d\n", ShortRetryLimit, tx_rty_cfg.field.ShortRtyLimit));
5245 Status = copy_to_user(wrq->u.data.pointer, &ShortRetryLimit, wrq->u.data.length);
5248 case OID_802_11_LONGRETRYLIMIT:
5249 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_LONGRETRYLIMIT \n"));
5250 wrq->u.data.length = sizeof(ULONG);
5251 RTMP_IO_READ32(pAdapter, TX_RTY_CFG, &tx_rty_cfg.word);
5252 LongRetryLimit = tx_rty_cfg.field.LongRtyLimit;
5253 DBGPRINT(RT_DEBUG_TRACE, ("LongRetryLimit =%ld, tx_rty_cfg.field.LongRtyLimit=%d\n", LongRetryLimit, tx_rty_cfg.field.LongRtyLimit));
5254 Status = copy_to_user(wrq->u.data.pointer, &LongRetryLimit, wrq->u.data.length);
5257 case RT_OID_802_11_PRODUCTID:
5258 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_PRODUCTID \n"));
5261 sprintf(tmp, "%04x %04x\n", ((POS_COOKIE)pAdapter->OS_Cookie)->pUsb_Dev->descriptor.idVendor ,((POS_COOKIE)pAdapter->OS_Cookie)->pUsb_Dev->descriptor.idProduct);
5264 wrq->u.data.length = strlen(tmp);
5265 Status = copy_to_user(wrq->u.data.pointer, tmp, wrq->u.data.length);
5268 case RT_OID_802_11_MANUFACTUREID:
5269 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_MANUFACTUREID \n"));
5270 wrq->u.data.length = strlen(ManufacturerNAME);
5271 Status = copy_to_user(wrq->u.data.pointer, ManufacturerNAME, wrq->u.data.length);
5274 case OID_802_11_CURRENTCHANNEL:
5275 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_CURRENTCHANNEL \n"));
5276 wrq->u.data.length = sizeof(UCHAR);
5277 DBGPRINT(RT_DEBUG_TRACE, ("sizeof UCHAR=%d, channel=%d \n", sizeof(UCHAR), pAdapter->CommonCfg.Channel));
5278 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.Channel, wrq->u.data.length);
5279 DBGPRINT(RT_DEBUG_TRACE, ("Status=%d\n", Status));
5281 #endif //SNMP_SUPPORT
5283 case OID_802_11_BUILD_CHANNEL_EX:
5286 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_BUILD_CHANNEL_EX \n"));
5287 wrq->u.data.length = sizeof(UCHAR);
5288 #ifdef EXT_BUILD_CHANNEL_LIST
5289 DBGPRINT(RT_DEBUG_TRACE, ("Support EXT_BUILD_CHANNEL_LIST.\n"));
5292 DBGPRINT(RT_DEBUG_TRACE, ("Doesn't support EXT_BUILD_CHANNEL_LIST.\n"));
5294 #endif // EXT_BUILD_CHANNEL_LIST //
5295 Status = copy_to_user(wrq->u.data.pointer, &value, 1);
5296 DBGPRINT(RT_DEBUG_TRACE, ("Status=%d\n", Status));
5300 case OID_802_11_GET_CH_LIST:
5302 PRT_CHANNEL_LIST_INFO pChListBuf;
5304 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_GET_CH_LIST \n"));
5305 if (pAdapter->ChannelListNum == 0)
5307 wrq->u.data.length = 0;
5311 pChListBuf = (RT_CHANNEL_LIST_INFO *) kmalloc(sizeof(RT_CHANNEL_LIST_INFO), MEM_ALLOC_FLAG);
5312 if (pChListBuf == NULL)
5314 wrq->u.data.length = 0;
5318 pChListBuf->ChannelListNum = pAdapter->ChannelListNum;
5319 for (i = 0; i < pChListBuf->ChannelListNum; i++)
5320 pChListBuf->ChannelList[i] = pAdapter->ChannelList[i].Channel;
5322 wrq->u.data.length = sizeof(RT_CHANNEL_LIST_INFO);
5323 Status = copy_to_user(wrq->u.data.pointer, pChListBuf, sizeof(RT_CHANNEL_LIST_INFO));
5324 DBGPRINT(RT_DEBUG_TRACE, ("Status=%d\n", Status));
5331 case OID_802_11_GET_COUNTRY_CODE:
5332 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_GET_COUNTRY_CODE \n"));
5333 wrq->u.data.length = 2;
5334 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.CountryCode, 2);
5335 DBGPRINT(RT_DEBUG_TRACE, ("Status=%d\n", Status));
5338 case OID_802_11_GET_CHANNEL_GEOGRAPHY:
5339 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_GET_CHANNEL_GEOGRAPHY \n"));
5340 wrq->u.data.length = 1;
5341 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.Geography, 1);
5342 DBGPRINT(RT_DEBUG_TRACE, ("Status=%d\n", Status));
5346 #ifdef QOS_DLS_SUPPORT
5347 case RT_OID_802_11_QUERY_DLS:
5348 wrq->u.data.length = sizeof(BOOLEAN);
5349 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.bDLSCapable, wrq->u.data.length);
5350 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_DLS(=%d)\n", pAdapter->CommonCfg.bDLSCapable));
5353 case RT_OID_802_11_QUERY_DLS_PARAM:
5355 PRT_802_11_DLS_INFO pDlsInfo = kmalloc(sizeof(RT_802_11_DLS_INFO), GFP_ATOMIC);
5356 if (pDlsInfo == NULL)
5359 for (i=0; i<MAX_NUM_OF_DLS_ENTRY; i++)
5361 RTMPMoveMemory(&pDlsInfo->Entry[i], &pAdapter->StaCfg.DLSEntry[i], sizeof(RT_802_11_DLS_UI));
5364 pDlsInfo->num = MAX_NUM_OF_DLS_ENTRY;
5365 wrq->u.data.length = sizeof(RT_802_11_DLS_INFO);
5366 Status = copy_to_user(wrq->u.data.pointer, pDlsInfo, wrq->u.data.length);
5367 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_DLS_PARAM\n"));
5373 #endif // QOS_DLS_SUPPORT //
5375 DBGPRINT(RT_DEBUG_TRACE, ("Query::unknown IOCTL's subcmd = 0x%08x\n", cmd));
5376 Status = -EOPNOTSUPP;
5382 INT rt28xx_sta_ioctl(
5383 IN struct net_device *net_dev,
5384 IN OUT struct ifreq *rq,
5388 VIRTUAL_ADAPTER *pVirtualAd = NULL;
5389 RTMP_ADAPTER *pAd = NULL;
5390 struct iwreq *wrq = (struct iwreq *) rq;
5391 BOOLEAN StateMachineTouched = FALSE;
5392 INT Status = NDIS_STATUS_SUCCESS;
5395 if (net_dev->priv_flags == INT_MAIN)
5397 pAd = net_dev->ml_priv;
5401 pVirtualAd = net_dev->ml_priv;
5402 pAd = pVirtualAd->RtmpDev->ml_priv;
5404 pObj = (POS_COOKIE) pAd->OS_Cookie;
5408 /* if 1st open fail, pAd will be free;
5409 So the net_dev->ml_priv will be NULL in 2rd open */
5413 //check if the interface is down
5414 if(!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_IN_USE))
5416 #ifdef CONFIG_APSTA_MIXED_SUPPORT
5417 if (wrq->u.data.pointer == NULL)
5422 if (strstr(wrq->u.data.pointer, "OpMode") == NULL)
5423 #endif // CONFIG_APSTA_MIXED_SUPPORT //
5425 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
5430 { // determine this ioctl command is comming from which interface.
5431 pObj->ioctl_if_type = INT_MAIN;
5432 pObj->ioctl_if = MAIN_MBSSID;
5438 #ifdef RALINK_28xx_QA
5439 case RTPRIV_IOCTL_ATE:
5441 RtmpDoAte(pAd, wrq);
5444 #endif // RALINK_28xx_QA //
5445 #endif // RALINK_ATE //
5447 DBGPRINT(RT_DEBUG_TRACE, ("IOCTL::SIOCGIFHWADDR\n"));
5448 memcpy(wrq->u.name, pAd->CurrentAddress, ETH_ALEN);
5452 char *name=&wrq->u.name[0];
5453 rt_ioctl_giwname(net_dev, NULL, name, NULL);
5456 case SIOCGIWESSID: //Get ESSID
5458 struct iw_point *essid=&wrq->u.essid;
5459 rt_ioctl_giwessid(net_dev, NULL, essid, essid->pointer);
5462 case SIOCSIWESSID: //Set ESSID
5464 struct iw_point *essid=&wrq->u.essid;
5465 rt_ioctl_siwessid(net_dev, NULL, essid, essid->pointer);
5468 case SIOCSIWNWID: // set network id (the cell)
5469 case SIOCGIWNWID: // get network id
5470 Status = -EOPNOTSUPP;
5472 case SIOCSIWFREQ: //set channel/frequency (Hz)
5474 struct iw_freq *freq=&wrq->u.freq;
5475 rt_ioctl_siwfreq(net_dev, NULL, freq, NULL);
5478 case SIOCGIWFREQ: // get channel/frequency (Hz)
5480 struct iw_freq *freq=&wrq->u.freq;
5481 rt_ioctl_giwfreq(net_dev, NULL, freq, NULL);
5484 case SIOCSIWNICKN: //set node name/nickname
5486 struct iw_point *data=&wrq->u.data;
5487 rt_ioctl_siwnickn(net_dev, NULL, data, NULL);
5490 case SIOCGIWNICKN: //get node name/nickname
5492 struct iw_point *data=&wrq->u.data;
5493 rt_ioctl_giwnickn(net_dev, NULL, data, NULL);
5496 case SIOCGIWRATE: //get default bit rate (bps)
5497 rt_ioctl_giwrate(net_dev, NULL, &wrq->u, NULL);
5499 case SIOCSIWRATE: //set default bit rate (bps)
5500 rt_ioctl_siwrate(net_dev, NULL, &wrq->u, NULL);
5502 case SIOCGIWRTS: // get RTS/CTS threshold (bytes)
5504 struct iw_param *rts=&wrq->u.rts;
5505 rt_ioctl_giwrts(net_dev, NULL, rts, NULL);
5508 case SIOCSIWRTS: //set RTS/CTS threshold (bytes)
5510 struct iw_param *rts=&wrq->u.rts;
5511 rt_ioctl_siwrts(net_dev, NULL, rts, NULL);
5514 case SIOCGIWFRAG: //get fragmentation thr (bytes)
5516 struct iw_param *frag=&wrq->u.frag;
5517 rt_ioctl_giwfrag(net_dev, NULL, frag, NULL);
5520 case SIOCSIWFRAG: //set fragmentation thr (bytes)
5522 struct iw_param *frag=&wrq->u.frag;
5523 rt_ioctl_siwfrag(net_dev, NULL, frag, NULL);
5526 case SIOCGIWENCODE: //get encoding token & mode
5528 struct iw_point *erq=&wrq->u.encoding;
5530 rt_ioctl_giwencode(net_dev, NULL, erq, erq->pointer);
5533 case SIOCSIWENCODE: //set encoding token & mode
5535 struct iw_point *erq=&wrq->u.encoding;
5537 rt_ioctl_siwencode(net_dev, NULL, erq, erq->pointer);
5540 case SIOCGIWAP: //get access point MAC addresses
5542 struct sockaddr *ap_addr=&wrq->u.ap_addr;
5543 rt_ioctl_giwap(net_dev, NULL, ap_addr, ap_addr->sa_data);
5546 case SIOCSIWAP: //set access point MAC addresses
5548 struct sockaddr *ap_addr=&wrq->u.ap_addr;
5549 rt_ioctl_siwap(net_dev, NULL, ap_addr, ap_addr->sa_data);
5552 case SIOCGIWMODE: //get operation mode
5554 __u32 *mode=&wrq->u.mode;
5555 rt_ioctl_giwmode(net_dev, NULL, mode, NULL);
5558 case SIOCSIWMODE: //set operation mode
5560 __u32 *mode=&wrq->u.mode;
5561 rt_ioctl_siwmode(net_dev, NULL, mode, NULL);
5564 case SIOCGIWSENS: //get sensitivity (dBm)
5565 case SIOCSIWSENS: //set sensitivity (dBm)
5566 case SIOCGIWPOWER: //get Power Management settings
5567 case SIOCSIWPOWER: //set Power Management settings
5568 case SIOCGIWTXPOW: //get transmit power (dBm)
5569 case SIOCSIWTXPOW: //set transmit power (dBm)
5570 case SIOCGIWRANGE: //Get range of parameters
5571 case SIOCGIWRETRY: //get retry limits and lifetime
5572 case SIOCSIWRETRY: //set retry limits and lifetime
5573 Status = -EOPNOTSUPP;
5576 case RT_PRIV_IOCTL_EXT:
5577 subcmd = wrq->u.data.flags;
5578 if( subcmd & OID_GET_SET_TOGGLE)
5579 Status = RTMPSetInformation(pAd, rq, subcmd);
5581 Status = RTMPQueryInformation(pAd, rq, subcmd);
5584 if (wrq->u.data.pointer)
5586 if ( access_ok(VERIFY_WRITE, wrq->u.data.pointer, sizeof(privtab)) != TRUE)
5588 wrq->u.data.length = sizeof(privtab) / sizeof(privtab[0]);
5589 if (copy_to_user(wrq->u.data.pointer, privtab, sizeof(privtab)))
5593 case RTPRIV_IOCTL_SET:
5594 if(access_ok(VERIFY_READ, wrq->u.data.pointer, wrq->u.data.length) != TRUE)
5596 rt_ioctl_setparam(net_dev, NULL, NULL, wrq->u.data.pointer);
5598 case RTPRIV_IOCTL_GSITESURVEY:
5599 RTMPIoctlGetSiteSurvey(pAd, wrq);
5602 case RTPRIV_IOCTL_MAC:
5603 RTMPIoctlMAC(pAd, wrq);
5605 case RTPRIV_IOCTL_E2P:
5606 RTMPIoctlE2PROM(pAd, wrq);
5609 case RTPRIV_IOCTL_RF:
5610 RTMPIoctlRF(pAd, wrq);
5617 DBGPRINT(RT_DEBUG_ERROR, ("IOCTL::unknown IOCTL's cmd = 0x%08x\n", cmd));
5618 Status = -EOPNOTSUPP;
5622 if(StateMachineTouched) // Upper layer sent a MLME-related operations
5623 RT28XX_MLME_HANDLER(pAd);
5629 ==========================================================================
5633 TRUE if all parameters are OK, FALSE otherwise
5634 ==========================================================================
5637 IN PRTMP_ADAPTER pAdapter,
5640 NDIS_802_11_SSID Ssid, *pSsid=NULL;
5641 BOOLEAN StateMachineTouched = FALSE;
5644 if( strlen(arg) <= MAX_LEN_OF_SSID)
5646 NdisZeroMemory(&Ssid, sizeof(NDIS_802_11_SSID));
5647 if (strlen(arg) != 0)
5649 NdisMoveMemory(Ssid.Ssid, arg, strlen(arg));
5650 Ssid.SsidLength = strlen(arg);
5654 Ssid.SsidLength = 0;
5655 memcpy(Ssid.Ssid, "", 0);
5656 pAdapter->StaCfg.BssType = BSS_INFRA;
5657 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
5658 pAdapter->StaCfg.WepStatus = Ndis802_11EncryptionDisabled;
5662 if (pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE)
5664 RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
5665 DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
5668 pAdapter->MlmeAux.CurrReqIsFromNdis = TRUE;
5669 pAdapter->StaCfg.bScanReqIsFromWebUI = FALSE;
5670 pAdapter->bConfigChanged = TRUE;
5672 MlmeEnqueue(pAdapter,
5673 MLME_CNTL_STATE_MACHINE,
5675 sizeof(NDIS_802_11_SSID),
5678 StateMachineTouched = TRUE;
5679 DBGPRINT(RT_DEBUG_TRACE, ("Set_SSID_Proc::(Len=%d,Ssid=%s)\n", Ssid.SsidLength, Ssid.Ssid));
5684 if (StateMachineTouched) // Upper layer sent a MLME-related operations
5685 RT28XX_MLME_HANDLER(pAdapter);
5692 ==========================================================================
5694 Set WmmCapable Enable or Disable
5696 TRUE if all parameters are OK, FALSE otherwise
5697 ==========================================================================
5699 INT Set_WmmCapable_Proc(
5700 IN PRTMP_ADAPTER pAd,
5703 BOOLEAN bWmmCapable;
5705 bWmmCapable = simple_strtol(arg, 0, 10);
5707 if ((bWmmCapable == 1)
5709 && (pAd->NumberOfPipes >= 5)
5712 pAd->CommonCfg.bWmmCapable = TRUE;
5713 else if (bWmmCapable == 0)
5714 pAd->CommonCfg.bWmmCapable = FALSE;
5716 return FALSE; //Invalid argument
5718 DBGPRINT(RT_DEBUG_TRACE, ("Set_WmmCapable_Proc::(bWmmCapable=%d)\n",
5719 pAd->CommonCfg.bWmmCapable));
5723 #endif // WMM_SUPPORT //
5726 ==========================================================================
5728 Set Network Type(Infrastructure/Adhoc mode)
5730 TRUE if all parameters are OK, FALSE otherwise
5731 ==========================================================================
5733 INT Set_NetworkType_Proc(
5734 IN PRTMP_ADAPTER pAdapter,
5739 if (strcmp(arg, "Adhoc") == 0)
5741 if (pAdapter->StaCfg.BssType != BSS_ADHOC)
5743 // Config has changed
5744 pAdapter->bConfigChanged = TRUE;
5745 if (MONITOR_ON(pAdapter))
5747 RTMP_IO_WRITE32(pAdapter, RX_FILTR_CFG, STANORMAL);
5748 RTMP_IO_READ32(pAdapter, MAC_SYS_CTRL, &Value);
5750 RTMP_IO_WRITE32(pAdapter, MAC_SYS_CTRL, Value);
5751 OPSTATUS_CLEAR_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED);
5752 pAdapter->StaCfg.bAutoReconnect = TRUE;
5753 LinkDown(pAdapter, FALSE);
5755 if (INFRA_ON(pAdapter))
5757 //BOOLEAN Cancelled;
5758 // Set the AutoReconnectSsid to prevent it reconnect to old SSID
5759 // Since calling this indicate user don't want to connect to that SSID anymore.
5760 pAdapter->MlmeAux.AutoReconnectSsidLen= 32;
5761 NdisZeroMemory(pAdapter->MlmeAux.AutoReconnectSsid, pAdapter->MlmeAux.AutoReconnectSsidLen);
5763 LinkDown(pAdapter, FALSE);
5765 DBGPRINT(RT_DEBUG_TRACE, ("NDIS_STATUS_MEDIA_DISCONNECT Event BB!\n"));
5768 pAdapter->StaCfg.BssType = BSS_ADHOC;
5769 pAdapter->net_dev->type = pAdapter->StaCfg.OriDevType;
5770 DBGPRINT(RT_DEBUG_TRACE, ("===>Set_NetworkType_Proc::(AD-HOC)\n"));
5772 else if (strcmp(arg, "Infra") == 0)
5774 if (pAdapter->StaCfg.BssType != BSS_INFRA)
5776 // Config has changed
5777 pAdapter->bConfigChanged = TRUE;
5778 if (MONITOR_ON(pAdapter))
5780 RTMP_IO_WRITE32(pAdapter, RX_FILTR_CFG, STANORMAL);
5781 RTMP_IO_READ32(pAdapter, MAC_SYS_CTRL, &Value);
5783 RTMP_IO_WRITE32(pAdapter, MAC_SYS_CTRL, Value);
5784 OPSTATUS_CLEAR_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED);
5785 pAdapter->StaCfg.bAutoReconnect = TRUE;
5786 LinkDown(pAdapter, FALSE);
5788 if (ADHOC_ON(pAdapter))
5790 // Set the AutoReconnectSsid to prevent it reconnect to old SSID
5791 // Since calling this indicate user don't want to connect to that SSID anymore.
5792 pAdapter->MlmeAux.AutoReconnectSsidLen= 32;
5793 NdisZeroMemory(pAdapter->MlmeAux.AutoReconnectSsid, pAdapter->MlmeAux.AutoReconnectSsidLen);
5795 LinkDown(pAdapter, FALSE);
5798 pAdapter->StaCfg.BssType = BSS_INFRA;
5799 pAdapter->net_dev->type = pAdapter->StaCfg.OriDevType;
5800 DBGPRINT(RT_DEBUG_TRACE, ("===>Set_NetworkType_Proc::(INFRA)\n"));
5802 pAdapter->StaCfg.BssType = BSS_INFRA;
5804 else if (strcmp(arg, "Monitor") == 0)
5807 BCN_TIME_CFG_STRUC csr;
5808 OPSTATUS_CLEAR_FLAG(pAdapter, fOP_STATUS_INFRA_ON);
5809 OPSTATUS_CLEAR_FLAG(pAdapter, fOP_STATUS_ADHOC_ON);
5810 OPSTATUS_SET_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED);
5811 // disable all periodic state machine
5812 pAdapter->StaCfg.bAutoReconnect = FALSE;
5813 // reset all mlme state machine
5814 RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
5815 DBGPRINT(RT_DEBUG_TRACE, ("fOP_STATUS_MEDIA_STATE_CONNECTED \n"));
5816 if (pAdapter->CommonCfg.CentralChannel == 0)
5818 #ifdef DOT11_N_SUPPORT
5819 if (pAdapter->CommonCfg.PhyMode == PHY_11AN_MIXED)
5820 pAdapter->CommonCfg.CentralChannel = 36;
5822 #endif // DOT11_N_SUPPORT //
5823 pAdapter->CommonCfg.CentralChannel = 6;
5825 #ifdef DOT11_N_SUPPORT
5827 N_ChannelCheck(pAdapter);
5828 #endif // DOT11_N_SUPPORT //
5830 #ifdef DOT11_N_SUPPORT
5831 if (pAdapter->CommonCfg.PhyMode >= PHY_11ABGN_MIXED &&
5832 pAdapter->CommonCfg.RegTransmitSetting.field.BW == BW_40 &&
5833 pAdapter->CommonCfg.RegTransmitSetting.field.EXTCHA == EXTCHA_ABOVE)
5835 // 40MHz ,control channel at lower
5836 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, BBP_R4, &bbpValue);
5837 bbpValue &= (~0x18);
5839 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R4, bbpValue);
5840 pAdapter->CommonCfg.BBPCurrentBW = BW_40;
5841 // RX : control channel at lower
5842 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, BBP_R3, &bbpValue);
5843 bbpValue &= (~0x20);
5844 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R3, bbpValue);
5846 RTMP_IO_READ32(pAdapter, TX_BAND_CFG, &Value);
5847 Value &= 0xfffffffe;
5848 RTMP_IO_WRITE32(pAdapter, TX_BAND_CFG, Value);
5849 pAdapter->CommonCfg.CentralChannel = pAdapter->CommonCfg.Channel + 2;
5850 AsicSwitchChannel(pAdapter, pAdapter->CommonCfg.CentralChannel, FALSE);
5851 AsicLockChannel(pAdapter, pAdapter->CommonCfg.CentralChannel);
5852 DBGPRINT(RT_DEBUG_TRACE, ("BW_40 ,control_channel(%d), CentralChannel(%d) \n",
5853 pAdapter->CommonCfg.Channel,
5854 pAdapter->CommonCfg.CentralChannel));
5856 else if (pAdapter->CommonCfg.PhyMode >= PHY_11ABGN_MIXED &&
5857 pAdapter->CommonCfg.RegTransmitSetting.field.BW == BW_40 &&
5858 pAdapter->CommonCfg.RegTransmitSetting.field.EXTCHA == EXTCHA_BELOW)
5860 // 40MHz ,control channel at upper
5861 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, BBP_R4, &bbpValue);
5862 bbpValue &= (~0x18);
5864 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R4, bbpValue);
5865 pAdapter->CommonCfg.BBPCurrentBW = BW_40;
5866 RTMP_IO_READ32(pAdapter, TX_BAND_CFG, &Value);
5868 RTMP_IO_WRITE32(pAdapter, TX_BAND_CFG, Value);
5870 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, BBP_R3, &bbpValue);
5872 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R3, bbpValue);
5873 pAdapter->CommonCfg.CentralChannel = pAdapter->CommonCfg.Channel - 2;
5874 AsicSwitchChannel(pAdapter, pAdapter->CommonCfg.CentralChannel, FALSE);
5875 AsicLockChannel(pAdapter, pAdapter->CommonCfg.CentralChannel);
5876 DBGPRINT(RT_DEBUG_TRACE, ("BW_40 ,control_channel(%d), CentralChannel(%d) \n",
5877 pAdapter->CommonCfg.Channel,
5878 pAdapter->CommonCfg.CentralChannel));
5881 #endif // DOT11_N_SUPPORT //
5884 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, BBP_R4, &bbpValue);
5885 bbpValue &= (~0x18);
5886 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R4, bbpValue);
5887 pAdapter->CommonCfg.BBPCurrentBW = BW_20;
5888 AsicSwitchChannel(pAdapter, pAdapter->CommonCfg.Channel, FALSE);
5889 AsicLockChannel(pAdapter, pAdapter->CommonCfg.Channel);
5890 DBGPRINT(RT_DEBUG_TRACE, ("BW_20, Channel(%d)\n", pAdapter->CommonCfg.Channel));
5892 // Enable Rx with promiscuous reception
5893 RTMP_IO_WRITE32(pAdapter, RX_FILTR_CFG, 0x3);
5894 // ASIC supporsts sniffer function with replacing RSSI with timestamp.
5895 //RTMP_IO_READ32(pAdapter, MAC_SYS_CTRL, &Value);
5897 //RTMP_IO_WRITE32(pAdapter, MAC_SYS_CTRL, Value);
5899 RTMP_IO_READ32(pAdapter, BCN_TIME_CFG, &csr.word);
5900 csr.field.bBeaconGen = 0;
5901 csr.field.bTBTTEnable = 0;
5902 csr.field.TsfSyncMode = 0;
5903 RTMP_IO_WRITE32(pAdapter, BCN_TIME_CFG, csr.word);
5905 pAdapter->StaCfg.BssType = BSS_MONITOR;
5906 pAdapter->net_dev->type = ARPHRD_IEEE80211_PRISM; //ARPHRD_IEEE80211; // IEEE80211
5907 DBGPRINT(RT_DEBUG_TRACE, ("===>Set_NetworkType_Proc::(MONITOR)\n"));
5910 // Reset Ralink supplicant to not use, it will be set to start when UI set PMK key
5911 pAdapter->StaCfg.WpaState = SS_NOTUSE;
5913 DBGPRINT(RT_DEBUG_TRACE, ("Set_NetworkType_Proc::(NetworkType=%d)\n", pAdapter->StaCfg.BssType));
5919 ==========================================================================
5921 Set Authentication mode
5923 TRUE if all parameters are OK, FALSE otherwise
5924 ==========================================================================
5926 INT Set_AuthMode_Proc(
5927 IN PRTMP_ADAPTER pAdapter,
5930 if ((strcmp(arg, "WEPAUTO") == 0) || (strcmp(arg, "wepauto") == 0))
5931 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeAutoSwitch;
5932 else if ((strcmp(arg, "OPEN") == 0) || (strcmp(arg, "open") == 0))
5933 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
5934 else if ((strcmp(arg, "SHARED") == 0) || (strcmp(arg, "shared") == 0))
5935 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeShared;
5936 else if ((strcmp(arg, "WPAPSK") == 0) || (strcmp(arg, "wpapsk") == 0))
5937 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPAPSK;
5938 else if ((strcmp(arg, "WPANONE") == 0) || (strcmp(arg, "wpanone") == 0))
5939 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPANone;
5940 else if ((strcmp(arg, "WPA2PSK") == 0) || (strcmp(arg, "wpa2psk") == 0))
5941 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA2PSK;
5942 #ifdef WPA_SUPPLICANT_SUPPORT
5943 else if ((strcmp(arg, "WPA") == 0) || (strcmp(arg, "wpa") == 0))
5944 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA;
5945 else if ((strcmp(arg, "WPA2") == 0) || (strcmp(arg, "wpa2") == 0))
5946 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA2;
5947 #endif // WPA_SUPPLICANT_SUPPORT //
5951 pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED;
5953 DBGPRINT(RT_DEBUG_TRACE, ("Set_AuthMode_Proc::(AuthMode=%d)\n", pAdapter->StaCfg.AuthMode));
5959 ==========================================================================
5963 TRUE if all parameters are OK, FALSE otherwise
5964 ==========================================================================
5966 INT Set_EncrypType_Proc(
5967 IN PRTMP_ADAPTER pAdapter,
5970 if ((strcmp(arg, "NONE") == 0) || (strcmp(arg, "none") == 0))
5972 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
5973 return TRUE; // do nothing
5975 pAdapter->StaCfg.WepStatus = Ndis802_11WEPDisabled;
5976 pAdapter->StaCfg.PairCipher = Ndis802_11WEPDisabled;
5977 pAdapter->StaCfg.GroupCipher = Ndis802_11WEPDisabled;
5979 else if ((strcmp(arg, "WEP") == 0) || (strcmp(arg, "wep") == 0))
5981 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
5982 return TRUE; // do nothing
5984 pAdapter->StaCfg.WepStatus = Ndis802_11WEPEnabled;
5985 pAdapter->StaCfg.PairCipher = Ndis802_11WEPEnabled;
5986 pAdapter->StaCfg.GroupCipher = Ndis802_11WEPEnabled;
5988 else if ((strcmp(arg, "TKIP") == 0) || (strcmp(arg, "tkip") == 0))
5990 if (pAdapter->StaCfg.AuthMode < Ndis802_11AuthModeWPA)
5991 return TRUE; // do nothing
5993 pAdapter->StaCfg.WepStatus = Ndis802_11Encryption2Enabled;
5994 pAdapter->StaCfg.PairCipher = Ndis802_11Encryption2Enabled;
5995 pAdapter->StaCfg.GroupCipher = Ndis802_11Encryption2Enabled;
5997 else if ((strcmp(arg, "AES") == 0) || (strcmp(arg, "aes") == 0))
5999 if (pAdapter->StaCfg.AuthMode < Ndis802_11AuthModeWPA)
6000 return TRUE; // do nothing
6002 pAdapter->StaCfg.WepStatus = Ndis802_11Encryption3Enabled;
6003 pAdapter->StaCfg.PairCipher = Ndis802_11Encryption3Enabled;
6004 pAdapter->StaCfg.GroupCipher = Ndis802_11Encryption3Enabled;
6009 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
6011 DBGPRINT(RT_DEBUG_TRACE, ("Set_EncrypType_Proc::(EncrypType=%d)\n", pAdapter->StaCfg.WepStatus));
6017 ==========================================================================
6021 TRUE if all parameters are OK, FALSE otherwise
6022 ==========================================================================
6024 INT Set_DefaultKeyID_Proc(
6025 IN PRTMP_ADAPTER pAdapter,
6030 KeyIdx = simple_strtol(arg, 0, 10);
6031 if((KeyIdx >= 1 ) && (KeyIdx <= 4))
6032 pAdapter->StaCfg.DefaultKeyId = (UCHAR) (KeyIdx - 1 );
6034 return FALSE; //Invalid argument
6036 DBGPRINT(RT_DEBUG_TRACE, ("Set_DefaultKeyID_Proc::(DefaultKeyID=%d)\n", pAdapter->StaCfg.DefaultKeyId));
6042 ==========================================================================
6046 TRUE if all parameters are OK, FALSE otherwise
6047 ==========================================================================
6050 IN PRTMP_ADAPTER pAdapter,
6055 UCHAR CipherAlg=CIPHER_WEP64;
6057 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
6058 return TRUE; // do nothing
6060 KeyLen = strlen(arg);
6064 case 5: //wep 40 Ascii type
6065 pAdapter->SharedKey[BSS0][0].KeyLen = KeyLen;
6066 memcpy(pAdapter->SharedKey[BSS0][0].Key, arg, KeyLen);
6067 CipherAlg = CIPHER_WEP64;
6068 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key1_Proc::(Key1=%s and type=%s)\n", arg, "Ascii"));
6070 case 10: //wep 40 Hex type
6071 for(i=0; i < KeyLen; i++)
6073 if( !isxdigit(*(arg+i)) )
6074 return FALSE; //Not Hex value;
6076 pAdapter->SharedKey[BSS0][0].KeyLen = KeyLen / 2 ;
6077 AtoH(arg, pAdapter->SharedKey[BSS0][0].Key, KeyLen / 2);
6078 CipherAlg = CIPHER_WEP64;
6079 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key1_Proc::(Key1=%s and type=%s)\n", arg, "Hex"));
6081 case 13: //wep 104 Ascii type
6082 pAdapter->SharedKey[BSS0][0].KeyLen = KeyLen;
6083 memcpy(pAdapter->SharedKey[BSS0][0].Key, arg, KeyLen);
6084 CipherAlg = CIPHER_WEP128;
6085 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key1_Proc::(Key1=%s and type=%s)\n", arg, "Ascii"));
6087 case 26: //wep 104 Hex type
6088 for(i=0; i < KeyLen; i++)
6090 if( !isxdigit(*(arg+i)) )
6091 return FALSE; //Not Hex value;
6093 pAdapter->SharedKey[BSS0][0].KeyLen = KeyLen / 2 ;
6094 AtoH(arg, pAdapter->SharedKey[BSS0][0].Key, KeyLen / 2);
6095 CipherAlg = CIPHER_WEP128;
6096 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key1_Proc::(Key1=%s and type=%s)\n", arg, "Hex"));
6098 default: //Invalid argument
6099 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key1_Proc::Invalid argument (=%s)\n", arg));
6103 pAdapter->SharedKey[BSS0][0].CipherAlg = CipherAlg;
6105 // Set keys (into ASIC)
6106 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
6108 else // Old WEP stuff
6110 AsicAddSharedKeyEntry(pAdapter,
6113 pAdapter->SharedKey[BSS0][0].CipherAlg,
6114 pAdapter->SharedKey[BSS0][0].Key,
6122 ==========================================================================
6127 TRUE if all parameters are OK, FALSE otherwise
6128 ==========================================================================
6131 IN PRTMP_ADAPTER pAdapter,
6136 UCHAR CipherAlg=CIPHER_WEP64;
6138 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
6139 return TRUE; // do nothing
6141 KeyLen = strlen(arg);
6145 case 5: //wep 40 Ascii type
6146 pAdapter->SharedKey[BSS0][1].KeyLen = KeyLen;
6147 memcpy(pAdapter->SharedKey[BSS0][1].Key, arg, KeyLen);
6148 CipherAlg = CIPHER_WEP64;
6149 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key2_Proc::(Key2=%s and type=%s)\n", arg, "Ascii"));
6151 case 10: //wep 40 Hex type
6152 for(i=0; i < KeyLen; i++)
6154 if( !isxdigit(*(arg+i)) )
6155 return FALSE; //Not Hex value;
6157 pAdapter->SharedKey[BSS0][1].KeyLen = KeyLen / 2 ;
6158 AtoH(arg, pAdapter->SharedKey[BSS0][1].Key, KeyLen / 2);
6159 CipherAlg = CIPHER_WEP64;
6160 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key2_Proc::(Key2=%s and type=%s)\n", arg, "Hex"));
6162 case 13: //wep 104 Ascii type
6163 pAdapter->SharedKey[BSS0][1].KeyLen = KeyLen;
6164 memcpy(pAdapter->SharedKey[BSS0][1].Key, arg, KeyLen);
6165 CipherAlg = CIPHER_WEP128;
6166 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key2_Proc::(Key2=%s and type=%s)\n", arg, "Ascii"));
6168 case 26: //wep 104 Hex type
6169 for(i=0; i < KeyLen; i++)
6171 if( !isxdigit(*(arg+i)) )
6172 return FALSE; //Not Hex value;
6174 pAdapter->SharedKey[BSS0][1].KeyLen = KeyLen / 2 ;
6175 AtoH(arg, pAdapter->SharedKey[BSS0][1].Key, KeyLen / 2);
6176 CipherAlg = CIPHER_WEP128;
6177 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key2_Proc::(Key2=%s and type=%s)\n", arg, "Hex"));
6179 default: //Invalid argument
6180 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key2_Proc::Invalid argument (=%s)\n", arg));
6183 pAdapter->SharedKey[BSS0][1].CipherAlg = CipherAlg;
6185 // Set keys (into ASIC)
6186 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
6188 else // Old WEP stuff
6190 AsicAddSharedKeyEntry(pAdapter,
6193 pAdapter->SharedKey[BSS0][1].CipherAlg,
6194 pAdapter->SharedKey[BSS0][1].Key,
6202 ==========================================================================
6206 TRUE if all parameters are OK, FALSE otherwise
6207 ==========================================================================
6210 IN PRTMP_ADAPTER pAdapter,
6215 UCHAR CipherAlg=CIPHER_WEP64;
6217 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
6218 return TRUE; // do nothing
6220 KeyLen = strlen(arg);
6224 case 5: //wep 40 Ascii type
6225 pAdapter->SharedKey[BSS0][2].KeyLen = KeyLen;
6226 memcpy(pAdapter->SharedKey[BSS0][2].Key, arg, KeyLen);
6227 CipherAlg = CIPHER_WEP64;
6228 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key3_Proc::(Key3=%s and type=Ascii)\n", arg));
6230 case 10: //wep 40 Hex type
6231 for(i=0; i < KeyLen; i++)
6233 if( !isxdigit(*(arg+i)) )
6234 return FALSE; //Not Hex value;
6236 pAdapter->SharedKey[BSS0][2].KeyLen = KeyLen / 2 ;
6237 AtoH(arg, pAdapter->SharedKey[BSS0][2].Key, KeyLen / 2);
6238 CipherAlg = CIPHER_WEP64;
6239 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key3_Proc::(Key3=%s and type=Hex)\n", arg));
6241 case 13: //wep 104 Ascii type
6242 pAdapter->SharedKey[BSS0][2].KeyLen = KeyLen;
6243 memcpy(pAdapter->SharedKey[BSS0][2].Key, arg, KeyLen);
6244 CipherAlg = CIPHER_WEP128;
6245 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key3_Proc::(Key3=%s and type=Ascii)\n", arg));
6247 case 26: //wep 104 Hex type
6248 for(i=0; i < KeyLen; i++)
6250 if( !isxdigit(*(arg+i)) )
6251 return FALSE; //Not Hex value;
6253 pAdapter->SharedKey[BSS0][2].KeyLen = KeyLen / 2 ;
6254 AtoH(arg, pAdapter->SharedKey[BSS0][2].Key, KeyLen / 2);
6255 CipherAlg = CIPHER_WEP128;
6256 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key3_Proc::(Key3=%s and type=Hex)\n", arg));
6258 default: //Invalid argument
6259 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key3_Proc::Invalid argument (=%s)\n", arg));
6262 pAdapter->SharedKey[BSS0][2].CipherAlg = CipherAlg;
6264 // Set keys (into ASIC)
6265 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
6267 else // Old WEP stuff
6269 AsicAddSharedKeyEntry(pAdapter,
6272 pAdapter->SharedKey[BSS0][2].CipherAlg,
6273 pAdapter->SharedKey[BSS0][2].Key,
6281 ==========================================================================
6285 TRUE if all parameters are OK, FALSE otherwise
6286 ==========================================================================
6289 IN PRTMP_ADAPTER pAdapter,
6294 UCHAR CipherAlg=CIPHER_WEP64;
6296 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
6297 return TRUE; // do nothing
6299 KeyLen = strlen(arg);
6303 case 5: //wep 40 Ascii type
6304 pAdapter->SharedKey[BSS0][3].KeyLen = KeyLen;
6305 memcpy(pAdapter->SharedKey[BSS0][3].Key, arg, KeyLen);
6306 CipherAlg = CIPHER_WEP64;
6307 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key4_Proc::(Key4=%s and type=%s)\n", arg, "Ascii"));
6309 case 10: //wep 40 Hex type
6310 for(i=0; i < KeyLen; i++)
6312 if( !isxdigit(*(arg+i)) )
6313 return FALSE; //Not Hex value;
6315 pAdapter->SharedKey[BSS0][3].KeyLen = KeyLen / 2 ;
6316 AtoH(arg, pAdapter->SharedKey[BSS0][3].Key, KeyLen / 2);
6317 CipherAlg = CIPHER_WEP64;
6318 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key4_Proc::(Key4=%s and type=%s)\n", arg, "Hex"));
6320 case 13: //wep 104 Ascii type
6321 pAdapter->SharedKey[BSS0][3].KeyLen = KeyLen;
6322 memcpy(pAdapter->SharedKey[BSS0][3].Key, arg, KeyLen);
6323 CipherAlg = CIPHER_WEP128;
6324 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key4_Proc::(Key4=%s and type=%s)\n", arg, "Ascii"));
6326 case 26: //wep 104 Hex type
6327 for(i=0; i < KeyLen; i++)
6329 if( !isxdigit(*(arg+i)) )
6330 return FALSE; //Not Hex value;
6332 pAdapter->SharedKey[BSS0][3].KeyLen = KeyLen / 2 ;
6333 AtoH(arg, pAdapter->SharedKey[BSS0][3].Key, KeyLen / 2);
6334 CipherAlg = CIPHER_WEP128;
6335 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key4_Proc::(Key4=%s and type=%s)\n", arg, "Hex"));
6337 default: //Invalid argument
6338 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key4_Proc::Invalid argument (=%s)\n", arg));
6341 pAdapter->SharedKey[BSS0][3].CipherAlg = CipherAlg;
6343 // Set keys (into ASIC)
6344 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
6346 else // Old WEP stuff
6348 AsicAddSharedKeyEntry(pAdapter,
6351 pAdapter->SharedKey[BSS0][3].CipherAlg,
6352 pAdapter->SharedKey[BSS0][3].Key,
6361 ==========================================================================
6365 TRUE if all parameters are OK, FALSE otherwise
6366 ==========================================================================
6368 INT Set_WPAPSK_Proc(
6369 IN PRTMP_ADAPTER pAdapter,
6372 UCHAR keyMaterial[40];
6374 if ((pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPAPSK) &&
6375 (pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPA2PSK) &&
6376 (pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPANone)
6378 return TRUE; // do nothing
6380 DBGPRINT(RT_DEBUG_TRACE, ("Set_WPAPSK_Proc::(WPAPSK=%s)\n", arg));
6382 NdisZeroMemory(keyMaterial, 40);
6384 if ((strlen(arg) < 8) || (strlen(arg) > 64))
6386 DBGPRINT(RT_DEBUG_TRACE, ("Set failed!!(WPAPSK=%s), WPAPSK key-string required 8 ~ 64 characters \n", arg));
6390 if (strlen(arg) == 64)
6392 AtoH(arg, keyMaterial, 32);
6393 NdisMoveMemory(pAdapter->StaCfg.PMK, keyMaterial, 32);
6398 PasswordHash((char *)arg, pAdapter->MlmeAux.Ssid, pAdapter->MlmeAux.SsidLen, keyMaterial);
6399 NdisMoveMemory(pAdapter->StaCfg.PMK, keyMaterial, 32);
6404 if(pAdapter->StaCfg.BssType == BSS_ADHOC &&
6405 pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPANone)
6407 pAdapter->StaCfg.WpaState = SS_NOTUSE;
6411 // Start STA supplicant state machine
6412 pAdapter->StaCfg.WpaState = SS_START;
6419 ==========================================================================
6421 Set Power Saving mode
6423 TRUE if all parameters are OK, FALSE otherwise
6424 ==========================================================================
6426 INT Set_PSMode_Proc(
6427 IN PRTMP_ADAPTER pAdapter,
6430 if (pAdapter->StaCfg.BssType == BSS_INFRA)
6432 if ((strcmp(arg, "Max_PSP") == 0) ||
6433 (strcmp(arg, "max_psp") == 0) ||
6434 (strcmp(arg, "MAX_PSP") == 0))
6436 // do NOT turn on PSM bit here, wait until MlmeCheckForPsmChange()
6437 // to exclude certain situations.
6438 if (pAdapter->StaCfg.bWindowsACCAMEnable == FALSE)
6439 pAdapter->StaCfg.WindowsPowerMode = Ndis802_11PowerModeMAX_PSP;
6440 pAdapter->StaCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeMAX_PSP;
6441 OPSTATUS_SET_FLAG(pAdapter, fOP_STATUS_RECEIVE_DTIM);
6442 pAdapter->StaCfg.DefaultListenCount = 5;
6445 else if ((strcmp(arg, "Fast_PSP") == 0) ||
6446 (strcmp(arg, "fast_psp") == 0) ||
6447 (strcmp(arg, "FAST_PSP") == 0))
6449 // do NOT turn on PSM bit here, wait until MlmeCheckForPsmChange()
6450 // to exclude certain situations.
6451 OPSTATUS_SET_FLAG(pAdapter, fOP_STATUS_RECEIVE_DTIM);
6452 if (pAdapter->StaCfg.bWindowsACCAMEnable == FALSE)
6453 pAdapter->StaCfg.WindowsPowerMode = Ndis802_11PowerModeFast_PSP;
6454 pAdapter->StaCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeFast_PSP;
6455 pAdapter->StaCfg.DefaultListenCount = 3;
6457 else if ((strcmp(arg, "Legacy_PSP") == 0) ||
6458 (strcmp(arg, "legacy_psp") == 0) ||
6459 (strcmp(arg, "LEGACY_PSP") == 0))
6461 // do NOT turn on PSM bit here, wait until MlmeCheckForPsmChange()
6462 // to exclude certain situations.
6463 OPSTATUS_SET_FLAG(pAdapter, fOP_STATUS_RECEIVE_DTIM);
6464 if (pAdapter->StaCfg.bWindowsACCAMEnable == FALSE)
6465 pAdapter->StaCfg.WindowsPowerMode = Ndis802_11PowerModeLegacy_PSP;
6466 pAdapter->StaCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeLegacy_PSP;
6467 pAdapter->StaCfg.DefaultListenCount = 3;
6471 //Default Ndis802_11PowerModeCAM
6472 // clear PSM bit immediately
6473 MlmeSetPsmBit(pAdapter, PWR_ACTIVE);
6474 OPSTATUS_SET_FLAG(pAdapter, fOP_STATUS_RECEIVE_DTIM);
6475 if (pAdapter->StaCfg.bWindowsACCAMEnable == FALSE)
6476 pAdapter->StaCfg.WindowsPowerMode = Ndis802_11PowerModeCAM;
6477 pAdapter->StaCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeCAM;
6480 DBGPRINT(RT_DEBUG_TRACE, ("Set_PSMode_Proc::(PSMode=%ld)\n", pAdapter->StaCfg.WindowsPowerMode));
6489 #ifdef WPA_SUPPLICANT_SUPPORT
6491 ==========================================================================
6493 Set WpaSupport flag.
6495 0: Driver ignore wpa_supplicant.
6496 1: wpa_supplicant initiates scanning and AP selection.
6497 2: driver takes care of scanning, AP selection, and IEEE 802.11 association parameters.
6499 TRUE if all parameters are OK, FALSE otherwise
6500 ==========================================================================
6502 INT Set_Wpa_Support(
6503 IN PRTMP_ADAPTER pAd,
6507 if ( simple_strtol(arg, 0, 10) == 0)
6508 pAd->StaCfg.WpaSupplicantUP = WPA_SUPPLICANT_DISABLE;
6509 else if ( simple_strtol(arg, 0, 10) == 1)
6510 pAd->StaCfg.WpaSupplicantUP = WPA_SUPPLICANT_ENABLE;
6511 else if ( simple_strtol(arg, 0, 10) == 2)
6512 pAd->StaCfg.WpaSupplicantUP = WPA_SUPPLICANT_ENABLE_WITH_WEB_UI;
6514 pAd->StaCfg.WpaSupplicantUP = WPA_SUPPLICANT_DISABLE;
6516 DBGPRINT(RT_DEBUG_TRACE, ("Set_Wpa_Support::(WpaSupplicantUP=%d)\n", pAd->StaCfg.WpaSupplicantUP));
6520 #endif // WPA_SUPPLICANT_SUPPORT //
6524 ==========================================================================
6528 pAdapter Pointer to our adapter
6529 wrq Pointer to the ioctl argument
6536 1.) iwpriv ra0 mac 0 ==> read MAC where Addr=0x0
6537 2.) iwpriv ra0 mac 0=12 ==> write MAC where Addr=0x0, value=12
6538 ==========================================================================
6541 IN PRTMP_ADAPTER pAdapter,
6542 IN struct iwreq *wrq)
6550 UCHAR temp[16], temp2[16];
6551 UINT32 macValue = 0;
6553 BOOLEAN bIsPrintAllMAC = FALSE;
6556 memset(msg, 0x00, 1024);
6557 if (wrq->u.data.length > 1) //No parameters.
6559 Status = copy_from_user(arg, wrq->u.data.pointer, (wrq->u.data.length > 255) ? 255 : wrq->u.data.length);
6562 //Parsing Read or Write
6567 if ((value = rtstrchr(this_char, '=')) != NULL)
6570 if (!value || !*value)
6573 if(strlen(this_char) > 4)
6576 j = strlen(this_char);
6579 if(this_char[j] > 'f' || this_char[j] < '0')
6584 k = j = strlen(this_char);
6587 this_char[4-k+j] = this_char[j];
6591 this_char[3-k++]='0';
6594 if(strlen(this_char) == 4)
6596 AtoH(this_char, temp, 2);
6597 macAddr = *temp*256 + temp[1];
6598 if (macAddr < 0xFFFF)
6600 RTMP_IO_READ32(pAdapter, macAddr, &macValue);
6601 DBGPRINT(RT_DEBUG_TRACE, ("MacAddr=%lx, MacValue=%x\n", macAddr, macValue));
6602 sprintf(msg+strlen(msg), "[0x%08lX]:%08X ", macAddr , macValue);
6605 {//Invalid parametes, so default printk all mac
6606 bIsPrintAllMAC = TRUE;
6613 memcpy(&temp2, value, strlen(value));
6614 temp2[strlen(value)] = '\0';
6617 if((strlen(this_char) > 4) || strlen(temp2) > 8)
6620 j = strlen(this_char);
6623 if(this_char[j] > 'f' || this_char[j] < '0')
6630 if(temp2[j] > 'f' || temp2[j] < '0')
6635 k = j = strlen(this_char);
6638 this_char[4-k+j] = this_char[j];
6642 this_char[3-k++]='0';
6646 k = j = strlen(temp2);
6649 temp2[8-k+j] = temp2[j];
6657 AtoH(this_char, temp, 2);
6658 macAddr = *temp*256 + temp[1];
6660 AtoH(temp2, temp, 4);
6661 macValue = *temp*256*256*256 + temp[1]*256*256 + temp[2]*256 + temp[3];
6664 if (macAddr == (HW_DEBUG_SETTING_BASE + 4))
6666 // 0x2bf4: byte0 non-zero: enable R17 tuning, 0: disable R17 tuning
6667 if (macValue & 0x000000ff)
6669 pAdapter->BbpTuning.bEnable = TRUE;
6670 DBGPRINT(RT_DEBUG_TRACE,("turn on R17 tuning\n"));
6675 pAdapter->BbpTuning.bEnable = FALSE;
6676 R66 = 0x26 + GET_LNA_GAIN(pAdapter);
6678 if (ATE_ON(pAdapter))
6680 ATE_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R66, (0x26 + GET_LNA_GAIN(pAdapter)));
6683 #endif // RALINK_ATE //
6684 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R66, (0x26 + GET_LNA_GAIN(pAdapter)));
6685 DBGPRINT(RT_DEBUG_TRACE,("turn off R17 tuning, restore to 0x%02x\n", R66));
6690 DBGPRINT(RT_DEBUG_TRACE, ("MacAddr=%02lx, MacValue=0x%x\n", macAddr, macValue));
6692 RTMP_IO_WRITE32(pAdapter, macAddr, macValue);
6693 sprintf(msg+strlen(msg), "[0x%08lX]:%08X ", macAddr, macValue);
6698 bIsPrintAllMAC = TRUE;
6702 struct file *file_w;
6703 PCHAR fileName = "MacDump.txt";
6704 mm_segment_t orig_fs;
6710 file_w = filp_open(fileName, O_WRONLY|O_CREAT, 0);
6713 DBGPRINT(RT_DEBUG_TRACE, ("-->2) %s: Error %ld opening %s\n", __func__, -PTR_ERR(file_w), fileName));
6717 if (file_w->f_op && file_w->f_op->write)
6722 while (macAddr <= 0x1800)
6724 RTMP_IO_READ32(pAdapter, macAddr, &macValue);
6725 sprintf(msg, "%08lx = %08X\n", macAddr, macValue);
6727 // write data to file
6728 file_w->f_op->write(file_w, msg, strlen(msg), &file_w->f_pos);
6733 sprintf(msg, "\nDump all MAC values to %s\n", fileName);
6735 filp_close(file_w, NULL);
6739 if(strlen(msg) == 1)
6740 sprintf(msg+strlen(msg), "===>Error command format!");
6742 // Copy the information into the user buffer
6743 wrq->u.data.length = strlen(msg);
6744 Status = copy_to_user(wrq->u.data.pointer, msg, wrq->u.data.length);
6746 DBGPRINT(RT_DEBUG_TRACE, ("<==RTMPIoctlMAC\n\n"));
6750 ==========================================================================
6754 pAdapter Pointer to our adapter
6755 wrq Pointer to the ioctl argument
6762 1.) iwpriv ra0 e2p 0 ==> read E2PROM where Addr=0x0
6763 2.) iwpriv ra0 e2p 0=1234 ==> write E2PROM where Addr=0x0, value=1234
6764 ==========================================================================
6766 VOID RTMPIoctlE2PROM(
6767 IN PRTMP_ADAPTER pAdapter,
6768 IN struct iwreq *wrq)
6776 UCHAR temp[16], temp2[16];
6779 BOOLEAN bIsPrintAllE2P = FALSE;
6782 memset(msg, 0x00, 1024);
6783 if (wrq->u.data.length > 1) //No parameters.
6785 Status = copy_from_user(arg, wrq->u.data.pointer, (wrq->u.data.length > 255) ? 255 : wrq->u.data.length);
6788 //Parsing Read or Write
6795 if ((value = rtstrchr(this_char, '=')) != NULL)
6798 if (!value || !*value)
6802 if(strlen(this_char) > 4)
6805 j = strlen(this_char);
6808 if(this_char[j] > 'f' || this_char[j] < '0')
6813 k = j = strlen(this_char);
6816 this_char[4-k+j] = this_char[j];
6820 this_char[3-k++]='0';
6823 if(strlen(this_char) == 4)
6825 AtoH(this_char, temp, 2);
6826 eepAddr = *temp*256 + temp[1];
6827 if (eepAddr < 0xFFFF)
6829 RT28xx_EEPROM_READ16(pAdapter, eepAddr, eepValue);
6830 sprintf(msg+strlen(msg), "[0x%04X]:0x%04X ", eepAddr , eepValue);
6833 {//Invalid parametes, so default printk all bbp
6834 bIsPrintAllE2P = TRUE;
6841 memcpy(&temp2, value, strlen(value));
6842 temp2[strlen(value)] = '\0';
6845 if((strlen(this_char) > 4) || strlen(temp2) > 8)
6848 j = strlen(this_char);
6851 if(this_char[j] > 'f' || this_char[j] < '0')
6857 if(temp2[j] > 'f' || temp2[j] < '0')
6862 k = j = strlen(this_char);
6865 this_char[4-k+j] = this_char[j];
6869 this_char[3-k++]='0';
6873 k = j = strlen(temp2);
6876 temp2[4-k+j] = temp2[j];
6883 AtoH(this_char, temp, 2);
6884 eepAddr = *temp*256 + temp[1];
6886 AtoH(temp2, temp, 2);
6887 eepValue = *temp*256 + temp[1];
6889 RT28xx_EEPROM_WRITE16(pAdapter, eepAddr, eepValue);
6890 sprintf(msg+strlen(msg), "[0x%02X]:%02X ", eepAddr, eepValue);
6894 bIsPrintAllE2P = TRUE;
6898 struct file *file_w;
6899 PCHAR fileName = "EEPROMDump.txt";
6900 mm_segment_t orig_fs;
6906 file_w = filp_open(fileName, O_WRONLY|O_CREAT, 0);
6909 DBGPRINT(RT_DEBUG_TRACE, ("-->2) %s: Error %ld opening %s\n", __func__, -PTR_ERR(file_w), fileName));
6913 if (file_w->f_op && file_w->f_op->write)
6918 while (eepAddr <= 0xFE)
6920 RT28xx_EEPROM_READ16(pAdapter, eepAddr, eepValue);
6921 sprintf(msg, "%08x = %04x\n", eepAddr , eepValue);
6923 // write data to file
6924 file_w->f_op->write(file_w, msg, strlen(msg), &file_w->f_pos);
6929 sprintf(msg, "\nDump all EEPROM values to %s\n", fileName);
6931 filp_close(file_w, NULL);
6935 if(strlen(msg) == 1)
6936 sprintf(msg+strlen(msg), "===>Error command format!");
6939 // Copy the information into the user buffer
6940 wrq->u.data.length = strlen(msg);
6941 Status = copy_to_user(wrq->u.data.pointer, msg, wrq->u.data.length);
6943 DBGPRINT(RT_DEBUG_TRACE, ("<==RTMPIoctlE2PROM\n"));
6947 ==========================================================================
6949 Read / Write RF register
6951 pAdapter Pointer to our adapter
6952 wrq Pointer to the ioctl argument
6959 1.) iwpriv ra0 rf ==> read all RF registers
6960 2.) iwpriv ra0 rf 1 ==> read RF where RegID=1
6961 3.) iwpriv ra0 rf 1=10 ==> write RF R1=0x10
6962 ==========================================================================
6965 IN PRTMP_ADAPTER pAdapter,
6966 IN struct iwreq *wrq)
6976 BOOLEAN bIsPrintAllRF = FALSE;
6979 memset(msg, 0x00, 2048);
6980 if (wrq->u.data.length > 1) //No parameters.
6982 Status = copy_from_user(arg, wrq->u.data.pointer, (wrq->u.data.length > 255) ? 255 : wrq->u.data.length);
6985 //Parsing Read or Write
6990 if ((value = strchr(this_char, '=')) != NULL)
6993 if (!value || !*value)
6995 if (sscanf(this_char, "%d", &(rfId)) == 1)
6999 // In RT2860 ATE mode, we do not load 8051 firmware.
7000 //We must access RF directly.
7001 // For RT2870 ATE mode, ATE_RF_IO_WRITE8(/READ8)_BY_REG_ID are redefined.
7003 if (ATE_ON(pAdapter))
7005 ATE_RF_IO_READ8_BY_REG_ID(pAdapter, rfId, ®RF);
7008 #endif // RALINK_ATE //
7009 // according to Andy, Gary, David require.
7010 // the command rf shall read rf register directly for dubug.
7011 // BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, ®BBP);
7012 RT30xxReadRFRegister(pAdapter, rfId, ®RF);
7014 sprintf(msg+strlen(msg), "R%02d[0x%02x]:%02X ", rfId, rfId*2, regRF);
7017 {//Invalid parametes, so default printk all RF
7018 bIsPrintAllRF = TRUE;
7023 { //Invalid parametes, so default printk all RF
7024 bIsPrintAllRF = TRUE;
7030 if ((sscanf(this_char, "%d", &(rfId)) == 1) && (sscanf(value, "%lx", &(rfValue)) == 1))
7034 // In RT2860 ATE mode, we do not load 8051 firmware.
7035 // We should access RF registers directly.
7036 // For RT2870 ATE mode, ATE_RF_IO_WRITE8/READ8_BY_REG_ID are redefined.
7038 if (ATE_ON(pAdapter))
7040 ATE_RF_IO_READ8_BY_REG_ID(pAdapter, rfId, ®RF);
7041 ATE_RF_IO_WRITE8_BY_REG_ID(pAdapter, (UCHAR)rfId,(UCHAR) rfValue);
7042 //Read it back for showing
7043 ATE_RF_IO_READ8_BY_REG_ID(pAdapter, rfId, ®RF);
7044 sprintf(msg+strlen(msg), "R%02d[0x%02X]:%02X\n", rfId, rfId*2, regRF);
7047 #endif // RALINK_ATE //
7049 // according to Andy, Gary, David require.
7050 // the command RF shall read/write RF register directly for dubug.
7051 //BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, ®BBP);
7052 //BBP_IO_WRITE8_BY_REG_ID(pAdapter, (UCHAR)bbpId,(UCHAR) bbpValue);
7053 RT30xxReadRFRegister(pAdapter, rfId, ®RF);
7054 RT30xxWriteRFRegister(pAdapter, (UCHAR)rfId,(UCHAR) rfValue);
7055 //Read it back for showing
7056 //BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, ®BBP);
7057 RT30xxReadRFRegister(pAdapter, rfId, ®RF);
7058 sprintf(msg+strlen(msg), "R%02d[0x%02X]:%02X\n", rfId, rfId*2, regRF);
7062 {//Invalid parametes, so default printk all RF
7063 bIsPrintAllRF = TRUE;
7067 { //Invalid parametes, so default printk all RF
7068 bIsPrintAllRF = TRUE;
7073 bIsPrintAllRF = TRUE;
7077 memset(msg, 0x00, 2048);
7079 for (rfId = 0; rfId <= 31; rfId++)
7081 // In RT2860 ATE mode, we do not load 8051 firmware.
7082 // We should access RF registers directly.
7083 // For RT2870 ATE mode, ATE_RF_IO_WRITE8/READ8_BY_REG_ID are redefined.
7085 if (ATE_ON(pAdapter))
7087 ATE_RF_IO_READ8_BY_REG_ID(pAdapter, rfId, ®RF);
7090 #endif // RALINK_ATE //
7092 // according to Andy, Gary, David require.
7093 // the command RF shall read/write RF register directly for dubug.
7094 RT30xxReadRFRegister(pAdapter, rfId, ®RF);
7095 sprintf(msg+strlen(msg), "%03d = %02X\n", rfId, regRF);
7097 // Copy the information into the user buffer
7098 DBGPRINT(RT_DEBUG_TRACE, ("strlen(msg)=%d\n", (UINT32)strlen(msg)));
7099 wrq->u.data.length = strlen(msg);
7100 if (copy_to_user(wrq->u.data.pointer, msg, wrq->u.data.length))
7102 DBGPRINT(RT_DEBUG_TRACE, ("%s: copy_to_user() fail\n", __func__));
7107 if(strlen(msg) == 1)
7108 sprintf(msg+strlen(msg), "===>Error command format!");
7110 DBGPRINT(RT_DEBUG_TRACE, ("copy to user [msg=%s]\n", msg));
7111 // Copy the information into the user buffer
7112 DBGPRINT(RT_DEBUG_TRACE, ("strlen(msg) =%d\n", (UINT32)strlen(msg)));
7114 // Copy the information into the user buffer
7115 wrq->u.data.length = strlen(msg);
7116 Status = copy_to_user(wrq->u.data.pointer, msg, wrq->u.data.length);
7119 DBGPRINT(RT_DEBUG_TRACE, ("<==RTMPIoctlRF\n\n"));
7127 INT Set_TGnWifiTest_Proc(
7128 IN PRTMP_ADAPTER pAd,
7131 if (simple_strtol(arg, 0, 10) == 0)
7132 pAd->StaCfg.bTGnWifiTest = FALSE;
7134 pAd->StaCfg.bTGnWifiTest = TRUE;
7136 DBGPRINT(RT_DEBUG_TRACE, ("IF Set_TGnWifiTest_Proc::(bTGnWifiTest=%d)\n", pAd->StaCfg.bTGnWifiTest));
7140 INT Set_LongRetryLimit_Proc(
7141 IN PRTMP_ADAPTER pAdapter,
7144 TX_RTY_CFG_STRUC tx_rty_cfg;
7145 UCHAR LongRetryLimit = (UCHAR)simple_strtol(arg, 0, 10);
7147 RTMP_IO_READ32(pAdapter, TX_RTY_CFG, &tx_rty_cfg.word);
7148 tx_rty_cfg.field.LongRtyLimit = LongRetryLimit;
7149 RTMP_IO_WRITE32(pAdapter, TX_RTY_CFG, tx_rty_cfg.word);
7150 DBGPRINT(RT_DEBUG_TRACE, ("IF Set_LongRetryLimit_Proc::(tx_rty_cfg=0x%x)\n", tx_rty_cfg.word));
7154 INT Set_ShortRetryLimit_Proc(
7155 IN PRTMP_ADAPTER pAdapter,
7158 TX_RTY_CFG_STRUC tx_rty_cfg;
7159 UCHAR ShortRetryLimit = (UCHAR)simple_strtol(arg, 0, 10);
7161 RTMP_IO_READ32(pAdapter, TX_RTY_CFG, &tx_rty_cfg.word);
7162 tx_rty_cfg.field.ShortRtyLimit = ShortRetryLimit;
7163 RTMP_IO_WRITE32(pAdapter, TX_RTY_CFG, tx_rty_cfg.word);
7164 DBGPRINT(RT_DEBUG_TRACE, ("IF Set_ShortRetryLimit_Proc::(tx_rty_cfg=0x%x)\n", tx_rty_cfg.word));
7168 #ifdef EXT_BUILD_CHANNEL_LIST
7169 INT Set_Ieee80211dClientMode_Proc(
7170 IN PRTMP_ADAPTER pAdapter,
7173 if (simple_strtol(arg, 0, 10) == 0)
7174 pAdapter->StaCfg.IEEE80211dClientMode = Rt802_11_D_None;
7175 else if (simple_strtol(arg, 0, 10) == 1)
7176 pAdapter->StaCfg.IEEE80211dClientMode = Rt802_11_D_Flexible;
7177 else if (simple_strtol(arg, 0, 10) == 2)
7178 pAdapter->StaCfg.IEEE80211dClientMode = Rt802_11_D_Strict;
7182 DBGPRINT(RT_DEBUG_TRACE, ("Set_Ieee802dMode_Proc::(IEEEE0211dMode=%d)\n", pAdapter->StaCfg.IEEE80211dClientMode));
7185 #endif // EXT_BUILD_CHANNEL_LIST //
7187 #ifdef CARRIER_DETECTION_SUPPORT
7188 INT Set_CarrierDetect_Proc(
7189 IN PRTMP_ADAPTER pAd,
7192 if (simple_strtol(arg, 0, 10) == 0)
7193 pAd->CommonCfg.CarrierDetect.Enable = FALSE;
7195 pAd->CommonCfg.CarrierDetect.Enable = TRUE;
7197 DBGPRINT(RT_DEBUG_TRACE, ("IF Set_CarrierDetect_Proc::(CarrierDetect.Enable=%d)\n", pAd->CommonCfg.CarrierDetect.Enable));
7200 #endif // CARRIER_DETECTION_SUPPORT //