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)
1735 DBGPRINT(RT_DEBUG_TRACE ,("==>rt_ioctl_siwencode::erq->flags=%x\n",erq->flags));
1736 DBGPRINT(RT_DEBUG_TRACE ,("==>rt_ioctl_siwencode::AuthMode=%x\n",pAdapter->StaCfg.AuthMode));
1737 DBGPRINT(RT_DEBUG_TRACE ,("==>rt_ioctl_siwencode::DefaultKeyId=%x, KeyLen = %d\n",pAdapter->StaCfg.DefaultKeyId , pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].KeyLen));
1738 DBGPRINT(RT_DEBUG_TRACE ,("==>rt_ioctl_siwencode::WepStatus=%x\n",pAdapter->StaCfg.WepStatus));
1743 rt_ioctl_giwencode(struct net_device *dev,
1744 struct iw_request_info *info,
1745 struct iw_point *erq, char *key)
1747 PRTMP_ADAPTER pAdapter = dev->ml_priv;
1750 //check if the interface is down
1751 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1753 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1757 kid = erq->flags & IW_ENCODE_INDEX;
1758 DBGPRINT(RT_DEBUG_TRACE, ("===>rt_ioctl_giwencode %d\n", erq->flags & IW_ENCODE_INDEX));
1760 if (pAdapter->StaCfg.WepStatus == Ndis802_11WEPDisabled)
1763 erq->flags = IW_ENCODE_DISABLED;
1765 else if ((kid > 0) && (kid <=4))
1768 erq->flags = kid ; /* NB: base 1 */
1769 if (erq->length > pAdapter->SharedKey[BSS0][kid-1].KeyLen)
1770 erq->length = pAdapter->SharedKey[BSS0][kid-1].KeyLen;
1771 memcpy(key, pAdapter->SharedKey[BSS0][kid-1].Key, erq->length);
1772 //if ((kid == pAdapter->PortCfg.DefaultKeyId))
1773 //erq->flags |= IW_ENCODE_ENABLED; /* XXX */
1774 if (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeShared)
1775 erq->flags |= IW_ENCODE_RESTRICTED; /* XXX */
1777 erq->flags |= IW_ENCODE_OPEN; /* XXX */
1782 if (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeShared)
1783 erq->flags |= IW_ENCODE_RESTRICTED; /* XXX */
1785 erq->flags |= IW_ENCODE_OPEN; /* XXX */
1786 erq->length = pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].KeyLen;
1787 memcpy(key, pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].Key, erq->length);
1788 // copy default key ID
1789 if (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeShared)
1790 erq->flags |= IW_ENCODE_RESTRICTED; /* XXX */
1792 erq->flags |= IW_ENCODE_OPEN; /* XXX */
1793 erq->flags = pAdapter->StaCfg.DefaultKeyId + 1; /* NB: base 1 */
1794 erq->flags |= IW_ENCODE_ENABLED; /* XXX */
1802 rt_ioctl_setparam(struct net_device *dev, struct iw_request_info *info,
1803 void *w, char *extra)
1805 VIRTUAL_ADAPTER *pVirtualAd = NULL;
1806 PRTMP_ADAPTER pAdapter;
1808 char *this_char = extra;
1812 if (dev->priv_flags == INT_MAIN)
1814 pAdapter = dev->ml_priv;
1818 pVirtualAd = dev->ml_priv;
1819 pAdapter = pVirtualAd->RtmpDev->ml_priv;
1821 pObj = (POS_COOKIE) pAdapter->OS_Cookie;
1823 if (pAdapter == NULL)
1825 /* if 1st open fail, pAd will be free;
1826 So the net_dev->ml_priv will be NULL in 2rd open */
1831 pObj->ioctl_if_type = INT_MAIN;
1832 pObj->ioctl_if = MAIN_MBSSID;
1835 //check if the interface is down
1836 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1838 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1845 if ((value = rtstrchr(this_char, '=')) != NULL)
1851 // reject setting nothing besides ANY ssid(ssidLen=0)
1852 if (!*value && (strcmp(this_char, "SSID") != 0))
1855 for (PRTMP_PRIVATE_SET_PROC = RTMP_PRIVATE_SUPPORT_PROC; PRTMP_PRIVATE_SET_PROC->name; PRTMP_PRIVATE_SET_PROC++)
1857 if (strcmp(this_char, PRTMP_PRIVATE_SET_PROC->name) == 0)
1859 if(!PRTMP_PRIVATE_SET_PROC->set_proc(pAdapter, value))
1860 { //FALSE:Set private failed then return Invalid argument
1863 break; //Exit for loop.
1867 if(PRTMP_PRIVATE_SET_PROC->name == NULL)
1868 { //Not found argument
1870 DBGPRINT(RT_DEBUG_TRACE, ("===>rt_ioctl_setparam:: (iwpriv) Not Support Set Command [%s=%s]\n", this_char, value));
1878 rt_private_get_statistics(struct net_device *dev, struct iw_request_info *info,
1879 struct iw_point *wrq, char *extra)
1882 PRTMP_ADAPTER pAd = dev->ml_priv;
1890 memset(extra, 0x00, IW_PRIV_SIZE_MASK);
1891 sprintf(extra, "\n\n");
1896 sprintf(extra+strlen(extra), "Tx success = %ld\n", (ULONG)pAd->ate.TxDoneCount);
1897 //sprintf(extra+strlen(extra), "Tx success without retry = %ld\n", (ULONG)pAd->ate.TxDoneCount);
1900 #endif // RALINK_ATE //
1902 sprintf(extra+strlen(extra), "Tx success = %ld\n", (ULONG)pAd->WlanCounters.TransmittedFragmentCount.QuadPart);
1903 sprintf(extra+strlen(extra), "Tx success without retry = %ld\n", (ULONG)pAd->WlanCounters.TransmittedFragmentCount.QuadPart - (ULONG)pAd->WlanCounters.RetryCount.QuadPart);
1905 sprintf(extra+strlen(extra), "Tx success after retry = %ld\n", (ULONG)pAd->WlanCounters.RetryCount.QuadPart);
1906 sprintf(extra+strlen(extra), "Tx fail to Rcv ACK after retry = %ld\n", (ULONG)pAd->WlanCounters.FailedCount.QuadPart);
1907 sprintf(extra+strlen(extra), "RTS Success Rcv CTS = %ld\n", (ULONG)pAd->WlanCounters.RTSSuccessCount.QuadPart);
1908 sprintf(extra+strlen(extra), "RTS Fail Rcv CTS = %ld\n", (ULONG)pAd->WlanCounters.RTSFailureCount.QuadPart);
1910 sprintf(extra+strlen(extra), "Rx success = %ld\n", (ULONG)pAd->WlanCounters.ReceivedFragmentCount.QuadPart);
1911 sprintf(extra+strlen(extra), "Rx with CRC = %ld\n", (ULONG)pAd->WlanCounters.FCSErrorCount.QuadPart);
1912 sprintf(extra+strlen(extra), "Rx drop due to out of resource = %ld\n", (ULONG)pAd->Counters8023.RxNoBuffer);
1913 sprintf(extra+strlen(extra), "Rx duplicate frame = %ld\n", (ULONG)pAd->WlanCounters.FrameDuplicateCount.QuadPart);
1915 sprintf(extra+strlen(extra), "False CCA (one second) = %ld\n", (ULONG)pAd->RalinkCounters.OneSecFalseCCACnt);
1919 if (pAd->ate.RxAntennaSel == 0)
1921 sprintf(extra+strlen(extra), "RSSI-A = %ld\n", (LONG)(pAd->ate.LastRssi0 - pAd->BbpRssiToDbmDelta));
1922 sprintf(extra+strlen(extra), "RSSI-B (if available) = %ld\n", (LONG)(pAd->ate.LastRssi1 - pAd->BbpRssiToDbmDelta));
1923 sprintf(extra+strlen(extra), "RSSI-C (if available) = %ld\n\n", (LONG)(pAd->ate.LastRssi2 - pAd->BbpRssiToDbmDelta));
1927 sprintf(extra+strlen(extra), "RSSI = %ld\n", (LONG)(pAd->ate.LastRssi0 - pAd->BbpRssiToDbmDelta));
1931 #endif // RALINK_ATE //
1933 sprintf(extra+strlen(extra), "RSSI-A = %ld\n", (LONG)(pAd->StaCfg.RssiSample.LastRssi0 - pAd->BbpRssiToDbmDelta));
1934 sprintf(extra+strlen(extra), "RSSI-B (if available) = %ld\n", (LONG)(pAd->StaCfg.RssiSample.LastRssi1 - pAd->BbpRssiToDbmDelta));
1935 sprintf(extra+strlen(extra), "RSSI-C (if available) = %ld\n\n", (LONG)(pAd->StaCfg.RssiSample.LastRssi2 - pAd->BbpRssiToDbmDelta));
1937 #ifdef WPA_SUPPLICANT_SUPPORT
1938 sprintf(extra+strlen(extra), "WpaSupplicantUP = %d\n\n", pAd->StaCfg.WpaSupplicantUP);
1939 #endif // WPA_SUPPLICANT_SUPPORT //
1942 wrq->length = strlen(extra) + 1; // 1: size of '\0'
1943 DBGPRINT(RT_DEBUG_TRACE, ("<== rt_private_get_statistics, wrq->length = %d\n", wrq->length));
1948 #ifdef DOT11_N_SUPPORT
1950 IN PRTMP_ADAPTER pAd,
1954 BA_ORI_ENTRY *pOriBAEntry;
1955 BA_REC_ENTRY *pRecBAEntry;
1957 for (i=0; i<MAX_LEN_OF_MAC_TABLE; i++)
1959 PMAC_TABLE_ENTRY pEntry = &pAd->MacTab.Content[i];
1960 if (((pEntry->ValidAsCLI || pEntry->ValidAsApCli) && (pEntry->Sst == SST_ASSOC))
1961 || (pEntry->ValidAsWDS) || (pEntry->ValidAsMesh))
1963 sprintf(pOutBuf, "%s\n%02X:%02X:%02X:%02X:%02X:%02X (Aid = %d) (AP) -\n",
1965 pEntry->Addr[0], pEntry->Addr[1], pEntry->Addr[2],
1966 pEntry->Addr[3], pEntry->Addr[4], pEntry->Addr[5], pEntry->Aid);
1968 sprintf(pOutBuf, "%s[Recipient]\n", pOutBuf);
1969 for (j=0; j < NUM_OF_TID; j++)
1971 if (pEntry->BARecWcidArray[j] != 0)
1973 pRecBAEntry =&pAd->BATable.BARecEntry[pEntry->BARecWcidArray[j]];
1974 sprintf(pOutBuf, "%sTID=%d, BAWinSize=%d, LastIndSeq=%d, ReorderingPkts=%d\n", pOutBuf, j, pRecBAEntry->BAWinSize, pRecBAEntry->LastIndSeq, pRecBAEntry->list.qlen);
1977 sprintf(pOutBuf, "%s\n", pOutBuf);
1979 sprintf(pOutBuf, "%s[Originator]\n", pOutBuf);
1980 for (j=0; j < NUM_OF_TID; j++)
1982 if (pEntry->BAOriWcidArray[j] != 0)
1984 pOriBAEntry =&pAd->BATable.BAOriEntry[pEntry->BAOriWcidArray[j]];
1985 sprintf(pOutBuf, "%sTID=%d, BAWinSize=%d, StartSeq=%d, CurTxSeq=%d\n", pOutBuf, j, pOriBAEntry->BAWinSize, pOriBAEntry->Sequence, pEntry->TxSeq[j]);
1988 sprintf(pOutBuf, "%s\n\n", pOutBuf);
1990 if (strlen(pOutBuf) > (IW_PRIV_SIZE_MASK - 30))
1996 #endif // DOT11_N_SUPPORT //
1999 rt_private_show(struct net_device *dev, struct iw_request_info *info,
2000 struct iw_point *wrq, char *extra)
2003 VIRTUAL_ADAPTER *pVirtualAd = NULL;
2006 u32 subcmd = wrq->flags;
2008 if (dev->priv_flags == INT_MAIN)
2012 pVirtualAd = dev->ml_priv;
2013 pAd = pVirtualAd->RtmpDev->ml_priv;
2015 pObj = (POS_COOKIE) pAd->OS_Cookie;
2019 /* if 1st open fail, pAd will be free;
2020 So the net_dev->ml_priv will be NULL in 2rd open */
2029 memset(extra, 0x00, IW_PRIV_SIZE_MASK);
2032 pObj->ioctl_if_type = INT_MAIN;
2033 pObj->ioctl_if = MAIN_MBSSID;
2039 case SHOW_CONN_STATUS:
2040 if (MONITOR_ON(pAd))
2042 #ifdef DOT11_N_SUPPORT
2043 if (pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED &&
2044 pAd->CommonCfg.RegTransmitSetting.field.BW)
2045 sprintf(extra, "Monitor Mode(CentralChannel %d)\n", pAd->CommonCfg.CentralChannel);
2047 #endif // DOT11_N_SUPPORT //
2048 sprintf(extra, "Monitor Mode(Channel %d)\n", pAd->CommonCfg.Channel);
2052 if (pAd->IndicateMediaState == NdisMediaStateConnected)
2056 sprintf(extra, "Connected(AP: %s[%02X:%02X:%02X:%02X:%02X:%02X])\n",
2057 pAd->CommonCfg.Ssid,
2058 pAd->CommonCfg.Bssid[0],
2059 pAd->CommonCfg.Bssid[1],
2060 pAd->CommonCfg.Bssid[2],
2061 pAd->CommonCfg.Bssid[3],
2062 pAd->CommonCfg.Bssid[4],
2063 pAd->CommonCfg.Bssid[5]);
2064 DBGPRINT(RT_DEBUG_TRACE ,("Ssid=%s ,Ssidlen = %d\n",pAd->CommonCfg.Ssid, pAd->CommonCfg.SsidLen));
2066 else if (ADHOC_ON(pAd))
2067 sprintf(extra, "Connected\n");
2071 sprintf(extra, "Disconnected\n");
2072 DBGPRINT(RT_DEBUG_TRACE ,("ConnStatus is not connected\n"));
2075 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2077 case SHOW_DRVIER_VERION:
2078 sprintf(extra, "Driver version-%s, %s %s\n", STA_DRIVER_VERSION, __DATE__, __TIME__ );
2079 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2081 #ifdef DOT11_N_SUPPORT
2083 getBaInfo(pAd, extra);
2084 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2086 #endif // DOT11_N_SUPPORT //
2087 case SHOW_DESC_INFO:
2089 Show_DescInfo_Proc(pAd, NULL);
2090 wrq->length = 0; // 1: size of '\0'
2094 if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
2096 sprintf(extra, "Scanning\n");
2097 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2100 pAd->StaCfg.bSwRadio = FALSE;
2101 if (pAd->StaCfg.bRadio != (pAd->StaCfg.bHwRadio && pAd->StaCfg.bSwRadio))
2103 pAd->StaCfg.bRadio = (pAd->StaCfg.bHwRadio && pAd->StaCfg.bSwRadio);
2104 if (pAd->StaCfg.bRadio == FALSE)
2107 // Update extra information
2108 pAd->ExtraInfo = SW_RADIO_OFF;
2111 sprintf(extra, "Radio Off\n");
2112 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2115 if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
2117 sprintf(extra, "Scanning\n");
2118 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2121 pAd->StaCfg.bSwRadio = TRUE;
2122 //if (pAd->StaCfg.bRadio != (pAd->StaCfg.bHwRadio && pAd->StaCfg.bSwRadio))
2124 pAd->StaCfg.bRadio = (pAd->StaCfg.bHwRadio && pAd->StaCfg.bSwRadio);
2125 if (pAd->StaCfg.bRadio == TRUE)
2128 // Update extra information
2129 pAd->ExtraInfo = EXTRA_INFO_CLEAR;
2132 sprintf(extra, "Radio On\n");
2133 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2137 #ifdef QOS_DLS_SUPPORT
2138 case SHOW_DLS_ENTRY_INFO:
2140 Set_DlsEntryInfo_Display_Proc(pAd, NULL);
2141 wrq->length = 0; // 1: size of '\0'
2144 #endif // QOS_DLS_SUPPORT //
2146 case SHOW_CFG_VALUE:
2148 Status = RTMPShowCfgValue(pAd, wrq->pointer, extra);
2150 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2154 DBGPRINT(RT_DEBUG_TRACE, ("%s - unknow subcmd = %d\n", __FUNCTION__, subcmd));
2162 int rt_ioctl_siwmlme(struct net_device *dev,
2163 struct iw_request_info *info,
2164 union iwreq_data *wrqu,
2167 PRTMP_ADAPTER pAd = dev->ml_priv;
2168 struct iw_mlme *pMlme = (struct iw_mlme *)wrqu->data.pointer;
2169 MLME_QUEUE_ELEM MsgElem;
2170 MLME_DISASSOC_REQ_STRUCT DisAssocReq;
2171 MLME_DEAUTH_REQ_STRUCT DeAuthReq;
2173 DBGPRINT(RT_DEBUG_TRACE, ("====> %s\n", __FUNCTION__));
2180 #ifdef IW_MLME_DEAUTH
2181 case IW_MLME_DEAUTH:
2182 DBGPRINT(RT_DEBUG_TRACE, ("====> %s - IW_MLME_DEAUTH\n", __FUNCTION__));
2183 COPY_MAC_ADDR(DeAuthReq.Addr, pAd->CommonCfg.Bssid);
2184 DeAuthReq.Reason = pMlme->reason_code;
2185 MsgElem.MsgLen = sizeof(MLME_DEAUTH_REQ_STRUCT);
2186 NdisMoveMemory(MsgElem.Msg, &DeAuthReq, sizeof(MLME_DEAUTH_REQ_STRUCT));
2187 MlmeDeauthReqAction(pAd, &MsgElem);
2190 LinkDown(pAd, FALSE);
2191 pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
2194 #endif // IW_MLME_DEAUTH //
2195 #ifdef IW_MLME_DISASSOC
2196 case IW_MLME_DISASSOC:
2197 DBGPRINT(RT_DEBUG_TRACE, ("====> %s - IW_MLME_DISASSOC\n", __FUNCTION__));
2198 COPY_MAC_ADDR(DisAssocReq.Addr, pAd->CommonCfg.Bssid);
2199 DisAssocReq.Reason = pMlme->reason_code;
2201 MsgElem.Machine = ASSOC_STATE_MACHINE;
2202 MsgElem.MsgType = MT2_MLME_DISASSOC_REQ;
2203 MsgElem.MsgLen = sizeof(MLME_DISASSOC_REQ_STRUCT);
2204 NdisMoveMemory(MsgElem.Msg, &DisAssocReq, sizeof(MLME_DISASSOC_REQ_STRUCT));
2206 pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_OID_DISASSOC;
2207 MlmeDisassocReqAction(pAd, &MsgElem);
2209 #endif // IW_MLME_DISASSOC //
2211 DBGPRINT(RT_DEBUG_TRACE, ("====> %s - Unknow Command\n", __FUNCTION__));
2217 #endif // SIOCSIWMLME //
2219 #if WIRELESS_EXT > 17
2220 int rt_ioctl_siwauth(struct net_device *dev,
2221 struct iw_request_info *info,
2222 union iwreq_data *wrqu, char *extra)
2224 PRTMP_ADAPTER pAdapter = dev->ml_priv;
2225 struct iw_param *param = &wrqu->param;
2227 //check if the interface is down
2228 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
2230 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
2233 switch (param->flags & IW_AUTH_INDEX) {
2234 case IW_AUTH_WPA_VERSION:
2235 if (param->value == IW_AUTH_WPA_VERSION_WPA)
2237 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPAPSK;
2238 if (pAdapter->StaCfg.BssType == BSS_ADHOC)
2239 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPANone;
2241 else if (param->value == IW_AUTH_WPA_VERSION_WPA2)
2242 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA2PSK;
2244 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_WPA_VERSION - param->value = %d!\n", __FUNCTION__, param->value));
2246 case IW_AUTH_CIPHER_PAIRWISE:
2247 if (param->value == IW_AUTH_CIPHER_NONE)
2249 pAdapter->StaCfg.WepStatus = Ndis802_11WEPDisabled;
2250 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
2251 pAdapter->StaCfg.PairCipher = Ndis802_11WEPDisabled;
2253 else if (param->value == IW_AUTH_CIPHER_WEP40 ||
2254 param->value == IW_AUTH_CIPHER_WEP104)
2256 pAdapter->StaCfg.WepStatus = Ndis802_11WEPEnabled;
2257 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
2258 pAdapter->StaCfg.PairCipher = Ndis802_11WEPEnabled;
2259 #ifdef WPA_SUPPLICANT_SUPPORT
2260 pAdapter->StaCfg.IEEE8021X = FALSE;
2261 #endif // WPA_SUPPLICANT_SUPPORT //
2263 else if (param->value == IW_AUTH_CIPHER_TKIP)
2265 pAdapter->StaCfg.WepStatus = Ndis802_11Encryption2Enabled;
2266 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
2267 pAdapter->StaCfg.PairCipher = Ndis802_11Encryption2Enabled;
2269 else if (param->value == IW_AUTH_CIPHER_CCMP)
2271 pAdapter->StaCfg.WepStatus = Ndis802_11Encryption3Enabled;
2272 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
2273 pAdapter->StaCfg.PairCipher = Ndis802_11Encryption3Enabled;
2275 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_CIPHER_PAIRWISE - param->value = %d!\n", __FUNCTION__, param->value));
2277 case IW_AUTH_CIPHER_GROUP:
2278 if (param->value == IW_AUTH_CIPHER_NONE)
2280 pAdapter->StaCfg.GroupCipher = Ndis802_11WEPDisabled;
2282 else if (param->value == IW_AUTH_CIPHER_WEP40 ||
2283 param->value == IW_AUTH_CIPHER_WEP104)
2285 pAdapter->StaCfg.GroupCipher = Ndis802_11WEPEnabled;
2287 else if (param->value == IW_AUTH_CIPHER_TKIP)
2289 pAdapter->StaCfg.GroupCipher = Ndis802_11Encryption2Enabled;
2291 else if (param->value == IW_AUTH_CIPHER_CCMP)
2293 pAdapter->StaCfg.GroupCipher = Ndis802_11Encryption3Enabled;
2295 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_CIPHER_GROUP - param->value = %d!\n", __FUNCTION__, param->value));
2297 case IW_AUTH_KEY_MGMT:
2298 if (param->value == IW_AUTH_KEY_MGMT_802_1X)
2300 if (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK)
2302 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA;
2303 #ifdef WPA_SUPPLICANT_SUPPORT
2304 pAdapter->StaCfg.IEEE8021X = FALSE;
2305 #endif // WPA_SUPPLICANT_SUPPORT //
2307 else if (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK)
2309 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA2;
2310 #ifdef WPA_SUPPLICANT_SUPPORT
2311 pAdapter->StaCfg.IEEE8021X = FALSE;
2312 #endif // WPA_SUPPLICANT_SUPPORT //
2314 #ifdef WPA_SUPPLICANT_SUPPORT
2317 pAdapter->StaCfg.IEEE8021X = TRUE;
2318 #endif // WPA_SUPPLICANT_SUPPORT //
2320 else if (param->value == 0)
2322 //pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
2323 STA_PORT_SECURED(pAdapter);
2325 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_KEY_MGMT - param->value = %d!\n", __FUNCTION__, param->value));
2327 case IW_AUTH_RX_UNENCRYPTED_EAPOL:
2329 case IW_AUTH_PRIVACY_INVOKED:
2330 /*if (param->value == 0)
2332 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
2333 pAdapter->StaCfg.WepStatus = Ndis802_11WEPDisabled;
2334 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
2335 pAdapter->StaCfg.PairCipher = Ndis802_11WEPDisabled;
2336 pAdapter->StaCfg.GroupCipher = Ndis802_11WEPDisabled;
2338 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_PRIVACY_INVOKED - param->value = %d!\n", __FUNCTION__, param->value));
2340 case IW_AUTH_DROP_UNENCRYPTED:
2341 if (param->value != 0)
2342 pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED;
2345 //pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
2346 STA_PORT_SECURED(pAdapter);
2348 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_WPA_VERSION - param->value = %d!\n", __FUNCTION__, param->value));
2350 case IW_AUTH_80211_AUTH_ALG:
2351 if (param->value & IW_AUTH_ALG_SHARED_KEY)
2353 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeShared;
2355 else if (param->value & IW_AUTH_ALG_OPEN_SYSTEM)
2357 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
2361 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_80211_AUTH_ALG - param->value = %d!\n", __FUNCTION__, param->value));
2363 case IW_AUTH_WPA_ENABLED:
2364 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_WPA_ENABLED - Driver supports WPA!(param->value = %d)\n", __FUNCTION__, param->value));
2373 int rt_ioctl_giwauth(struct net_device *dev,
2374 struct iw_request_info *info,
2375 union iwreq_data *wrqu, char *extra)
2377 PRTMP_ADAPTER pAdapter = dev->ml_priv;
2378 struct iw_param *param = &wrqu->param;
2380 //check if the interface is down
2381 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
2383 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
2387 switch (param->flags & IW_AUTH_INDEX) {
2388 case IW_AUTH_DROP_UNENCRYPTED:
2389 param->value = (pAdapter->StaCfg.WepStatus == Ndis802_11WEPDisabled) ? 0 : 1;
2392 case IW_AUTH_80211_AUTH_ALG:
2393 param->value = (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeShared) ? IW_AUTH_ALG_SHARED_KEY : IW_AUTH_ALG_OPEN_SYSTEM;
2396 case IW_AUTH_WPA_ENABLED:
2397 param->value = (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA) ? 1 : 0;
2403 DBGPRINT(RT_DEBUG_TRACE, ("rt_ioctl_giwauth::param->value = %d!\n", param->value));
2407 void fnSetCipherKey(
2408 IN PRTMP_ADAPTER pAdapter,
2412 IN struct iw_encode_ext *ext)
2414 NdisZeroMemory(&pAdapter->SharedKey[BSS0][keyIdx], sizeof(CIPHER_KEY));
2415 pAdapter->SharedKey[BSS0][keyIdx].KeyLen = LEN_TKIP_EK;
2416 NdisMoveMemory(pAdapter->SharedKey[BSS0][keyIdx].Key, ext->key, LEN_TKIP_EK);
2417 NdisMoveMemory(pAdapter->SharedKey[BSS0][keyIdx].TxMic, ext->key + LEN_TKIP_EK, LEN_TKIP_TXMICK);
2418 NdisMoveMemory(pAdapter->SharedKey[BSS0][keyIdx].RxMic, ext->key + LEN_TKIP_EK + LEN_TKIP_TXMICK, LEN_TKIP_RXMICK);
2419 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CipherAlg;
2421 // Update group key information to ASIC Shared Key Table
2422 AsicAddSharedKeyEntry(pAdapter,
2425 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg,
2426 pAdapter->SharedKey[BSS0][keyIdx].Key,
2427 pAdapter->SharedKey[BSS0][keyIdx].TxMic,
2428 pAdapter->SharedKey[BSS0][keyIdx].RxMic);
2431 // Update ASIC WCID attribute table and IVEIV table
2432 RTMPAddWcidAttributeEntry(pAdapter,
2435 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg,
2438 // Update ASIC WCID attribute table and IVEIV table
2439 RTMPAddWcidAttributeEntry(pAdapter,
2442 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg,
2443 &pAdapter->MacTab.Content[BSSID_WCID]);
2446 int rt_ioctl_siwencodeext(struct net_device *dev,
2447 struct iw_request_info *info,
2448 union iwreq_data *wrqu,
2451 PRTMP_ADAPTER pAdapter = dev->ml_priv;
2452 struct iw_point *encoding = &wrqu->encoding;
2453 struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
2454 int keyIdx, alg = ext->alg;
2456 //check if the interface is down
2457 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
2459 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
2463 if (encoding->flags & IW_ENCODE_DISABLED)
2465 keyIdx = (encoding->flags & IW_ENCODE_INDEX) - 1;
2466 // set BSSID wcid entry of the Pair-wise Key table as no-security mode
2467 AsicRemovePairwiseKeyEntry(pAdapter, BSS0, BSSID_WCID);
2468 pAdapter->SharedKey[BSS0][keyIdx].KeyLen = 0;
2469 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CIPHER_NONE;
2470 AsicRemoveSharedKeyEntry(pAdapter, 0, (UCHAR)keyIdx);
2471 NdisZeroMemory(&pAdapter->SharedKey[BSS0][keyIdx], sizeof(CIPHER_KEY));
2472 DBGPRINT(RT_DEBUG_TRACE, ("%s::Remove all keys!(encoding->flags = %x)\n", __FUNCTION__, encoding->flags));
2476 // Get Key Index and convet to our own defined key index
2477 keyIdx = (encoding->flags & IW_ENCODE_INDEX) - 1;
2478 if((keyIdx < 0) || (keyIdx >= NR_WEP_KEYS))
2481 if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
2483 pAdapter->StaCfg.DefaultKeyId = keyIdx;
2484 DBGPRINT(RT_DEBUG_TRACE, ("%s::DefaultKeyId = %d\n", __FUNCTION__, pAdapter->StaCfg.DefaultKeyId));
2488 case IW_ENCODE_ALG_NONE:
2489 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_ENCODE_ALG_NONE\n", __FUNCTION__));
2491 case IW_ENCODE_ALG_WEP:
2492 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_ENCODE_ALG_WEP - ext->key_len = %d, keyIdx = %d\n", __FUNCTION__, ext->key_len, keyIdx));
2493 if (ext->key_len == MAX_WEP_KEY_SIZE)
2495 pAdapter->SharedKey[BSS0][keyIdx].KeyLen = MAX_WEP_KEY_SIZE;
2496 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CIPHER_WEP128;
2498 else if (ext->key_len == MIN_WEP_KEY_SIZE)
2500 pAdapter->SharedKey[BSS0][keyIdx].KeyLen = MIN_WEP_KEY_SIZE;
2501 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CIPHER_WEP64;
2506 NdisZeroMemory(pAdapter->SharedKey[BSS0][keyIdx].Key, 16);
2507 NdisMoveMemory(pAdapter->SharedKey[BSS0][keyIdx].Key, ext->key, ext->key_len);
2509 case IW_ENCODE_ALG_TKIP:
2510 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_ENCODE_ALG_TKIP - keyIdx = %d, ext->key_len = %d\n", __FUNCTION__, keyIdx, ext->key_len));
2511 if (ext->key_len == 32)
2513 if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
2515 fnSetCipherKey(pAdapter, keyIdx, CIPHER_TKIP, FALSE, ext);
2516 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA2)
2518 //pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
2519 STA_PORT_SECURED(pAdapter);
2522 else if (ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY)
2524 fnSetCipherKey(pAdapter, keyIdx, CIPHER_TKIP, TRUE, ext);
2526 // set 802.1x port control
2527 //pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
2528 STA_PORT_SECURED(pAdapter);
2534 case IW_ENCODE_ALG_CCMP:
2535 if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
2537 fnSetCipherKey(pAdapter, keyIdx, CIPHER_AES, FALSE, ext);
2538 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA2)
2539 //pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
2540 STA_PORT_SECURED(pAdapter);
2542 else if (ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY)
2544 fnSetCipherKey(pAdapter, keyIdx, CIPHER_AES, TRUE, ext);
2546 // set 802.1x port control
2547 //pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
2548 STA_PORT_SECURED(pAdapter);
2560 rt_ioctl_giwencodeext(struct net_device *dev,
2561 struct iw_request_info *info,
2562 union iwreq_data *wrqu, char *extra)
2564 PRTMP_ADAPTER pAd = dev->ml_priv;
2566 struct iw_point *encoding = &wrqu->encoding;
2567 struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
2568 int idx, max_key_len;
2570 DBGPRINT(RT_DEBUG_TRACE ,("===> rt_ioctl_giwencodeext\n"));
2572 max_key_len = encoding->length - sizeof(*ext);
2573 if (max_key_len < 0)
2576 idx = encoding->flags & IW_ENCODE_INDEX;
2579 if (idx < 1 || idx > 4)
2583 if ((pAd->StaCfg.WepStatus == Ndis802_11Encryption2Enabled) ||
2584 (pAd->StaCfg.WepStatus == Ndis802_11Encryption3Enabled))
2586 if (idx != pAd->StaCfg.DefaultKeyId)
2594 idx = pAd->StaCfg.DefaultKeyId;
2596 encoding->flags = idx + 1;
2597 memset(ext, 0, sizeof(*ext));
2600 switch(pAd->StaCfg.WepStatus) {
2601 case Ndis802_11WEPDisabled:
2602 ext->alg = IW_ENCODE_ALG_NONE;
2603 encoding->flags |= IW_ENCODE_DISABLED;
2605 case Ndis802_11WEPEnabled:
2606 ext->alg = IW_ENCODE_ALG_WEP;
2607 if (pAd->SharedKey[BSS0][idx].KeyLen > max_key_len)
2611 ext->key_len = pAd->SharedKey[BSS0][idx].KeyLen;
2612 pKey = &(pAd->SharedKey[BSS0][idx].Key[0]);
2615 case Ndis802_11Encryption2Enabled:
2616 case Ndis802_11Encryption3Enabled:
2617 if (pAd->StaCfg.WepStatus == Ndis802_11Encryption2Enabled)
2618 ext->alg = IW_ENCODE_ALG_TKIP;
2620 ext->alg = IW_ENCODE_ALG_CCMP;
2622 if (max_key_len < 32)
2627 pKey = &pAd->StaCfg.PMK[0];
2634 if (ext->key_len && pKey)
2636 encoding->flags |= IW_ENCODE_ENABLED;
2637 memcpy(ext->key, pKey, ext->key_len);
2644 int rt_ioctl_siwgenie(struct net_device *dev,
2645 struct iw_request_info *info,
2646 union iwreq_data *wrqu, char *extra)
2648 PRTMP_ADAPTER pAd = dev->ml_priv;
2650 if (wrqu->data.length > MAX_LEN_OF_RSNIE ||
2651 (wrqu->data.length && extra == NULL))
2654 if (wrqu->data.length)
2656 pAd->StaCfg.RSNIE_Len = wrqu->data.length;
2657 NdisMoveMemory(&pAd->StaCfg.RSN_IE[0], extra, pAd->StaCfg.RSNIE_Len);
2661 pAd->StaCfg.RSNIE_Len = 0;
2662 NdisZeroMemory(&pAd->StaCfg.RSN_IE[0], MAX_LEN_OF_RSNIE);
2667 #endif // SIOCSIWGENIE //
2669 int rt_ioctl_giwgenie(struct net_device *dev,
2670 struct iw_request_info *info,
2671 union iwreq_data *wrqu, char *extra)
2673 PRTMP_ADAPTER pAd = dev->ml_priv;
2675 if ((pAd->StaCfg.RSNIE_Len == 0) ||
2676 (pAd->StaCfg.AuthMode < Ndis802_11AuthModeWPA))
2678 wrqu->data.length = 0;
2682 #ifdef NATIVE_WPA_SUPPLICANT_SUPPORT
2684 if (pAd->StaCfg.WpaSupplicantUP == WPA_SUPPLICANT_ENABLE)
2686 if (wrqu->data.length < pAd->StaCfg.RSNIE_Len)
2689 wrqu->data.length = pAd->StaCfg.RSNIE_Len;
2690 memcpy(extra, &pAd->StaCfg.RSN_IE[0], pAd->StaCfg.RSNIE_Len);
2693 #endif // SIOCSIWGENIE //
2694 #endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
2696 UCHAR RSNIe = IE_WPA;
2698 if (wrqu->data.length < (pAd->StaCfg.RSNIE_Len + 2)) // ID, Len
2700 wrqu->data.length = pAd->StaCfg.RSNIE_Len + 2;
2702 if ((pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK) ||
2703 (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2))
2706 extra[0] = (char)RSNIe;
2707 extra[1] = pAd->StaCfg.RSNIE_Len;
2708 memcpy(extra+2, &pAd->StaCfg.RSN_IE[0], pAd->StaCfg.RSNIE_Len);
2714 int rt_ioctl_siwpmksa(struct net_device *dev,
2715 struct iw_request_info *info,
2716 union iwreq_data *wrqu,
2719 PRTMP_ADAPTER pAd = dev->ml_priv;
2720 struct iw_pmksa *pPmksa = (struct iw_pmksa *)wrqu->data.pointer;
2721 INT CachedIdx = 0, idx = 0;
2726 DBGPRINT(RT_DEBUG_TRACE ,("===> rt_ioctl_siwpmksa\n"));
2729 case IW_PMKSA_FLUSH:
2730 NdisZeroMemory(pAd->StaCfg.SavedPMK, sizeof(BSSID_INFO)*PMKID_NO);
2731 DBGPRINT(RT_DEBUG_TRACE ,("rt_ioctl_siwpmksa - IW_PMKSA_FLUSH\n"));
2733 case IW_PMKSA_REMOVE:
2734 for (CachedIdx = 0; CachedIdx < pAd->StaCfg.SavedPMKNum; CachedIdx++)
2736 // compare the BSSID
2737 if (NdisEqualMemory(pPmksa->bssid.sa_data, pAd->StaCfg.SavedPMK[CachedIdx].BSSID, MAC_ADDR_LEN))
2739 NdisZeroMemory(pAd->StaCfg.SavedPMK[CachedIdx].BSSID, MAC_ADDR_LEN);
2740 NdisZeroMemory(pAd->StaCfg.SavedPMK[CachedIdx].PMKID, 16);
2741 for (idx = CachedIdx; idx < (pAd->StaCfg.SavedPMKNum - 1); idx++)
2743 NdisMoveMemory(&pAd->StaCfg.SavedPMK[idx].BSSID[0], &pAd->StaCfg.SavedPMK[idx+1].BSSID[0], MAC_ADDR_LEN);
2744 NdisMoveMemory(&pAd->StaCfg.SavedPMK[idx].PMKID[0], &pAd->StaCfg.SavedPMK[idx+1].PMKID[0], 16);
2746 pAd->StaCfg.SavedPMKNum--;
2751 DBGPRINT(RT_DEBUG_TRACE ,("rt_ioctl_siwpmksa - IW_PMKSA_REMOVE\n"));
2754 for (CachedIdx = 0; CachedIdx < pAd->StaCfg.SavedPMKNum; CachedIdx++)
2756 // compare the BSSID
2757 if (NdisEqualMemory(pPmksa->bssid.sa_data, pAd->StaCfg.SavedPMK[CachedIdx].BSSID, MAC_ADDR_LEN))
2761 // Found, replace it
2762 if (CachedIdx < PMKID_NO)
2764 DBGPRINT(RT_DEBUG_OFF, ("Update PMKID, idx = %d\n", CachedIdx));
2765 NdisMoveMemory(&pAd->StaCfg.SavedPMK[CachedIdx].BSSID[0], pPmksa->bssid.sa_data, MAC_ADDR_LEN);
2766 NdisMoveMemory(&pAd->StaCfg.SavedPMK[CachedIdx].PMKID[0], pPmksa->pmkid, 16);
2767 pAd->StaCfg.SavedPMKNum++;
2769 // Not found, replace the last one
2772 // Randomly replace one
2773 CachedIdx = (pPmksa->bssid.sa_data[5] % PMKID_NO);
2774 DBGPRINT(RT_DEBUG_OFF, ("Update PMKID, idx = %d\n", CachedIdx));
2775 NdisMoveMemory(&pAd->StaCfg.SavedPMK[CachedIdx].BSSID[0], pPmksa->bssid.sa_data, MAC_ADDR_LEN);
2776 NdisMoveMemory(&pAd->StaCfg.SavedPMK[CachedIdx].PMKID[0], pPmksa->pmkid, 16);
2779 DBGPRINT(RT_DEBUG_TRACE ,("rt_ioctl_siwpmksa - IW_PMKSA_ADD\n"));
2782 DBGPRINT(RT_DEBUG_TRACE ,("rt_ioctl_siwpmksa - Unknow Command!!\n"));
2788 #endif // #if WIRELESS_EXT > 17
2792 rt_private_ioctl_bbp(struct net_device *dev, struct iw_request_info *info,
2793 struct iw_point *wrq, char *extra)
2798 // CHAR arg[255]={0};
2801 BOOLEAN bIsPrintAllBBP = FALSE;
2803 PRTMP_ADAPTER pAdapter = dev->ml_priv;
2806 memset(extra, 0x00, IW_PRIV_SIZE_MASK);
2808 if (wrq->length > 1) //No parameters.
2810 sprintf(extra, "\n");
2812 //Parsing Read or Write
2813 this_char = wrq->pointer;
2814 DBGPRINT(RT_DEBUG_TRACE, ("this_char=%s\n", this_char));
2818 if ((value = rtstrchr(this_char, '=')) != NULL)
2821 if (!value || !*value)
2823 DBGPRINT(RT_DEBUG_TRACE, ("this_char=%s, value=%s\n", this_char, value));
2824 if (sscanf(this_char, "%d", &(bbpId)) == 1)
2830 if (bbpId <= 138) // edit by johnli, RF power sequence setup, add BBP R138 for ADC dynamic on/off control
2834 if (ATE_ON(pAdapter))
2836 ATE_BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, ®BBP);
2839 #endif // RALINK_ATE //
2841 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, ®BBP);
2843 sprintf(extra+strlen(extra), "R%02d[0x%02X]:%02X\n", bbpId, bbpId*2, regBBP);
2844 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2845 DBGPRINT(RT_DEBUG_TRACE, ("msg=%s\n", extra));
2848 {//Invalid parametes, so default printk all bbp
2849 bIsPrintAllBBP = TRUE;
2854 { //Invalid parametes, so default printk all bbp
2855 bIsPrintAllBBP = TRUE;
2861 if ((sscanf(this_char, "%d", &(bbpId)) == 1) && (sscanf(value, "%x", &(bbpValue)) == 1))
2867 if (bbpId <= 138) // edit by johnli, RF power sequence setup, add BBP R138 for ADC dynamic on/off control
2871 if (ATE_ON(pAdapter))
2873 ATE_BBP_IO_WRITE8_BY_REG_ID(pAdapter, bbpId, bbpValue);
2874 //Read it back for showing
2875 ATE_BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, ®BBP);
2878 #endif // RALINK_ATE //
2880 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, bbpId, bbpValue);
2881 //Read it back for showing
2882 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, ®BBP);
2884 sprintf(extra+strlen(extra), "R%02d[0x%02X]:%02X\n", bbpId, bbpId*2, regBBP);
2885 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2886 DBGPRINT(RT_DEBUG_TRACE, ("msg=%s\n", extra));
2889 {//Invalid parametes, so default printk all bbp
2890 bIsPrintAllBBP = TRUE;
2895 { //Invalid parametes, so default printk all bbp
2896 bIsPrintAllBBP = TRUE;
2902 bIsPrintAllBBP = TRUE;
2907 memset(extra, 0x00, IW_PRIV_SIZE_MASK);
2908 sprintf(extra, "\n");
2910 for (bbpId = 0; bbpId <= 136; bbpId++)
2913 for (bbpId = 0; bbpId <= 138; bbpId++) // edit by johnli, RF power sequence setup, add BBP R138 for ADC dynamic on/off control
2916 if (strlen(extra) >= (IW_PRIV_SIZE_MASK - 10))
2919 if (ATE_ON(pAdapter))
2921 ATE_BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, ®BBP);
2924 #endif // RALINK_ATE //
2925 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, ®BBP);
2927 sprintf(extra+strlen(extra), "R%02d[0x%02X]:%02X ", bbpId, bbpId*2, regBBP);
2929 sprintf(extra+strlen(extra), "\n");
2931 sprintf(extra+strlen(extra), "%03d = %02X\n", bbpId, regBBP); // edit by johnli, change display format
2934 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2935 DBGPRINT(RT_DEBUG_TRACE, ("wrq->length = %d\n", wrq->length));
2938 DBGPRINT(RT_DEBUG_TRACE, ("<==rt_private_ioctl_bbp\n\n"));
2944 int rt_ioctl_siwrate(struct net_device *dev,
2945 struct iw_request_info *info,
2946 union iwreq_data *wrqu, char *extra)
2948 PRTMP_ADAPTER pAd = dev->ml_priv;
2949 UINT32 rate = wrqu->bitrate.value, fixed = wrqu->bitrate.fixed;
2951 //check if the interface is down
2952 if(!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_IN_USE))
2954 DBGPRINT(RT_DEBUG_TRACE, ("rt_ioctl_siwrate::Network is down!\n"));
2958 DBGPRINT(RT_DEBUG_TRACE, ("rt_ioctl_siwrate::(rate = %d, fixed = %d)\n", rate, fixed));
2959 /* rate = -1 => auto rate
2960 rate = X, fixed = 1 => (fixed rate X)
2965 pAd->StaCfg.DesiredTransmitSetting.field.MCS = MCS_AUTO;
2966 pAd->StaCfg.bAutoTxRateSwitch = TRUE;
2967 if ((pAd->CommonCfg.PhyMode <= PHY_11G) ||
2968 (pAd->MacTab.Content[BSSID_WCID].HTPhyMode.field.MODE <= MODE_OFDM))
2969 RTMPSetDesiredRates(pAd, -1);
2971 #ifdef DOT11_N_SUPPORT
2973 #endif // DOT11_N_SUPPORT //
2979 pAd->StaCfg.bAutoTxRateSwitch = FALSE;
2980 if ((pAd->CommonCfg.PhyMode <= PHY_11G) ||
2981 (pAd->MacTab.Content[BSSID_WCID].HTPhyMode.field.MODE <= MODE_OFDM))
2982 RTMPSetDesiredRates(pAd, rate);
2985 pAd->StaCfg.DesiredTransmitSetting.field.MCS = MCS_AUTO;
2986 #ifdef DOT11_N_SUPPORT
2988 #endif // DOT11_N_SUPPORT //
2990 DBGPRINT(RT_DEBUG_TRACE, ("rt_ioctl_siwrate::(HtMcs=%d)\n",pAd->StaCfg.DesiredTransmitSetting.field.MCS));
2994 // TODO: rate = X, fixed = 0 => (rates <= X)
3002 int rt_ioctl_giwrate(struct net_device *dev,
3003 struct iw_request_info *info,
3004 union iwreq_data *wrqu, char *extra)
3006 PRTMP_ADAPTER pAd = dev->ml_priv;
3007 int rate_index = 0, rate_count = 0;
3008 HTTRANSMIT_SETTING ht_setting;
3009 __s32 ralinkrate[] =
3010 {2, 4, 11, 22, // CCK
3011 12, 18, 24, 36, 48, 72, 96, 108, // OFDM
3012 13, 26, 39, 52, 78, 104, 117, 130, 26, 52, 78, 104, 156, 208, 234, 260, // 20MHz, 800ns GI, MCS: 0 ~ 15
3013 39, 78, 117, 156, 234, 312, 351, 390, // 20MHz, 800ns GI, MCS: 16 ~ 23
3014 27, 54, 81, 108, 162, 216, 243, 270, 54, 108, 162, 216, 324, 432, 486, 540, // 40MHz, 800ns GI, MCS: 0 ~ 15
3015 81, 162, 243, 324, 486, 648, 729, 810, // 40MHz, 800ns GI, MCS: 16 ~ 23
3016 14, 29, 43, 57, 87, 115, 130, 144, 29, 59, 87, 115, 173, 230, 260, 288, // 20MHz, 400ns GI, MCS: 0 ~ 15
3017 43, 87, 130, 173, 260, 317, 390, 433, // 20MHz, 400ns GI, MCS: 16 ~ 23
3018 30, 60, 90, 120, 180, 240, 270, 300, 60, 120, 180, 240, 360, 480, 540, 600, // 40MHz, 400ns GI, MCS: 0 ~ 15
3019 90, 180, 270, 360, 540, 720, 810, 900}; // 40MHz, 400ns GI, MCS: 16 ~ 23
3021 rate_count = sizeof(ralinkrate)/sizeof(__s32);
3022 //check if the interface is down
3023 if(!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_IN_USE))
3025 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
3029 if ((pAd->StaCfg.bAutoTxRateSwitch == FALSE) &&
3031 ((pAd->CommonCfg.PhyMode <= PHY_11G) || (pAd->MacTab.Content[BSSID_WCID].HTPhyMode.field.MODE <= MODE_OFDM)))
3032 ht_setting.word = pAd->StaCfg.HTPhyMode.word;
3034 ht_setting.word = pAd->MacTab.Content[BSSID_WCID].HTPhyMode.word;
3036 #ifdef DOT11_N_SUPPORT
3037 if (ht_setting.field.MODE >= MODE_HTMIX)
3039 // rate_index = 12 + ((UCHAR)ht_setting.field.BW *16) + ((UCHAR)ht_setting.field.ShortGI *32) + ((UCHAR)ht_setting.field.MCS);
3040 rate_index = 12 + ((UCHAR)ht_setting.field.BW *24) + ((UCHAR)ht_setting.field.ShortGI *48) + ((UCHAR)ht_setting.field.MCS);
3043 #endif // DOT11_N_SUPPORT //
3044 if (ht_setting.field.MODE == MODE_OFDM)
3045 rate_index = (UCHAR)(ht_setting.field.MCS) + 4;
3046 else if (ht_setting.field.MODE == MODE_CCK)
3047 rate_index = (UCHAR)(ht_setting.field.MCS);
3052 if (rate_index > rate_count)
3053 rate_index = rate_count;
3055 wrqu->bitrate.value = ralinkrate[rate_index] * 500000;
3056 wrqu->bitrate.disabled = 0;
3061 static const iw_handler rt_handler[] =
3063 (iw_handler) NULL, /* SIOCSIWCOMMIT */
3064 (iw_handler) rt_ioctl_giwname, /* SIOCGIWNAME */
3065 (iw_handler) NULL, /* SIOCSIWNWID */
3066 (iw_handler) NULL, /* SIOCGIWNWID */
3067 (iw_handler) rt_ioctl_siwfreq, /* SIOCSIWFREQ */
3068 (iw_handler) rt_ioctl_giwfreq, /* SIOCGIWFREQ */
3069 (iw_handler) rt_ioctl_siwmode, /* SIOCSIWMODE */
3070 (iw_handler) rt_ioctl_giwmode, /* SIOCGIWMODE */
3071 (iw_handler) NULL, /* SIOCSIWSENS */
3072 (iw_handler) NULL, /* SIOCGIWSENS */
3073 (iw_handler) NULL /* not used */, /* SIOCSIWRANGE */
3074 (iw_handler) rt_ioctl_giwrange, /* SIOCGIWRANGE */
3075 (iw_handler) NULL /* not used */, /* SIOCSIWPRIV */
3076 (iw_handler) NULL /* kernel code */, /* SIOCGIWPRIV */
3077 (iw_handler) NULL /* not used */, /* SIOCSIWSTATS */
3078 (iw_handler) rt28xx_get_wireless_stats /* kernel code */, /* SIOCGIWSTATS */
3079 (iw_handler) NULL, /* SIOCSIWSPY */
3080 (iw_handler) NULL, /* SIOCGIWSPY */
3081 (iw_handler) NULL, /* SIOCSIWTHRSPY */
3082 (iw_handler) NULL, /* SIOCGIWTHRSPY */
3083 (iw_handler) rt_ioctl_siwap, /* SIOCSIWAP */
3084 (iw_handler) rt_ioctl_giwap, /* SIOCGIWAP */
3086 (iw_handler) rt_ioctl_siwmlme, /* SIOCSIWMLME */
3088 (iw_handler) NULL, /* SIOCSIWMLME */
3089 #endif // SIOCSIWMLME //
3090 (iw_handler) rt_ioctl_iwaplist, /* SIOCGIWAPLIST */
3092 (iw_handler) rt_ioctl_siwscan, /* SIOCSIWSCAN */
3093 (iw_handler) rt_ioctl_giwscan, /* SIOCGIWSCAN */
3095 (iw_handler) NULL, /* SIOCSIWSCAN */
3096 (iw_handler) NULL, /* SIOCGIWSCAN */
3097 #endif /* SIOCGIWSCAN */
3098 (iw_handler) rt_ioctl_siwessid, /* SIOCSIWESSID */
3099 (iw_handler) rt_ioctl_giwessid, /* SIOCGIWESSID */
3100 (iw_handler) rt_ioctl_siwnickn, /* SIOCSIWNICKN */
3101 (iw_handler) rt_ioctl_giwnickn, /* SIOCGIWNICKN */
3102 (iw_handler) NULL, /* -- hole -- */
3103 (iw_handler) NULL, /* -- hole -- */
3104 (iw_handler) rt_ioctl_siwrate, /* SIOCSIWRATE */
3105 (iw_handler) rt_ioctl_giwrate, /* SIOCGIWRATE */
3106 (iw_handler) rt_ioctl_siwrts, /* SIOCSIWRTS */
3107 (iw_handler) rt_ioctl_giwrts, /* SIOCGIWRTS */
3108 (iw_handler) rt_ioctl_siwfrag, /* SIOCSIWFRAG */
3109 (iw_handler) rt_ioctl_giwfrag, /* SIOCGIWFRAG */
3110 (iw_handler) NULL, /* SIOCSIWTXPOW */
3111 (iw_handler) NULL, /* SIOCGIWTXPOW */
3112 (iw_handler) NULL, /* SIOCSIWRETRY */
3113 (iw_handler) NULL, /* SIOCGIWRETRY */
3114 (iw_handler) rt_ioctl_siwencode, /* SIOCSIWENCODE */
3115 (iw_handler) rt_ioctl_giwencode, /* SIOCGIWENCODE */
3116 (iw_handler) NULL, /* SIOCSIWPOWER */
3117 (iw_handler) NULL, /* SIOCGIWPOWER */
3118 (iw_handler) NULL, /* -- hole -- */
3119 (iw_handler) NULL, /* -- hole -- */
3120 #if WIRELESS_EXT > 17
3121 (iw_handler) rt_ioctl_siwgenie, /* SIOCSIWGENIE */
3122 (iw_handler) rt_ioctl_giwgenie, /* SIOCGIWGENIE */
3123 (iw_handler) rt_ioctl_siwauth, /* SIOCSIWAUTH */
3124 (iw_handler) rt_ioctl_giwauth, /* SIOCGIWAUTH */
3125 (iw_handler) rt_ioctl_siwencodeext, /* SIOCSIWENCODEEXT */
3126 (iw_handler) rt_ioctl_giwencodeext, /* SIOCGIWENCODEEXT */
3127 (iw_handler) rt_ioctl_siwpmksa, /* SIOCSIWPMKSA */
3131 static const iw_handler rt_priv_handlers[] = {
3132 (iw_handler) NULL, /* + 0x00 */
3133 (iw_handler) NULL, /* + 0x01 */
3134 #ifndef CONFIG_AP_SUPPORT
3135 (iw_handler) rt_ioctl_setparam, /* + 0x02 */
3137 (iw_handler) NULL, /* + 0x02 */
3138 #endif // CONFIG_AP_SUPPORT //
3140 (iw_handler) rt_private_ioctl_bbp, /* + 0x03 */
3142 (iw_handler) NULL, /* + 0x03 */
3144 (iw_handler) NULL, /* + 0x04 */
3145 (iw_handler) NULL, /* + 0x05 */
3146 (iw_handler) NULL, /* + 0x06 */
3147 (iw_handler) NULL, /* + 0x07 */
3148 (iw_handler) NULL, /* + 0x08 */
3149 (iw_handler) rt_private_get_statistics, /* + 0x09 */
3150 (iw_handler) NULL, /* + 0x0A */
3151 (iw_handler) NULL, /* + 0x0B */
3152 (iw_handler) NULL, /* + 0x0C */
3153 (iw_handler) NULL, /* + 0x0D */
3154 (iw_handler) NULL, /* + 0x0E */
3155 (iw_handler) NULL, /* + 0x0F */
3156 (iw_handler) NULL, /* + 0x10 */
3157 (iw_handler) rt_private_show, /* + 0x11 */
3158 (iw_handler) NULL, /* + 0x12 */
3159 (iw_handler) NULL, /* + 0x13 */
3160 (iw_handler) NULL, /* + 0x15 */
3161 (iw_handler) NULL, /* + 0x17 */
3162 (iw_handler) NULL, /* + 0x18 */
3165 const struct iw_handler_def rt28xx_iw_handler_def =
3167 #define N(a) (sizeof (a) / sizeof (a[0]))
3168 .standard = (iw_handler *) rt_handler,
3169 .num_standard = sizeof(rt_handler) / sizeof(iw_handler),
3170 .private = (iw_handler *) rt_priv_handlers,
3171 .num_private = N(rt_priv_handlers),
3172 .private_args = (struct iw_priv_args *) privtab,
3173 .num_private_args = N(privtab),
3174 #if IW_HANDLER_VERSION >= 7
3175 .get_wireless_stats = rt28xx_get_wireless_stats,
3179 INT RTMPSetInformation(
3180 IN PRTMP_ADAPTER pAdapter,
3181 IN OUT struct ifreq *rq,
3184 struct iwreq *wrq = (struct iwreq *) rq;
3185 NDIS_802_11_SSID Ssid;
3186 NDIS_802_11_MAC_ADDRESS Bssid;
3187 RT_802_11_PHY_MODE PhyMode;
3188 RT_802_11_STA_CONFIG StaConfig;
3189 NDIS_802_11_RATES aryRates;
3190 RT_802_11_PREAMBLE Preamble;
3191 NDIS_802_11_WEP_STATUS WepStatus;
3192 NDIS_802_11_AUTHENTICATION_MODE AuthMode = Ndis802_11AuthModeMax;
3193 NDIS_802_11_NETWORK_INFRASTRUCTURE BssType;
3194 NDIS_802_11_RTS_THRESHOLD RtsThresh;
3195 NDIS_802_11_FRAGMENTATION_THRESHOLD FragThresh;
3196 NDIS_802_11_POWER_MODE PowerMode;
3197 PNDIS_802_11_KEY pKey = NULL;
3198 PNDIS_802_11_WEP pWepKey =NULL;
3199 PNDIS_802_11_REMOVE_KEY pRemoveKey = NULL;
3200 NDIS_802_11_CONFIGURATION Config, *pConfig = NULL;
3201 NDIS_802_11_NETWORK_TYPE NetType;
3204 INT Status = NDIS_STATUS_SUCCESS, MaxPhyMode = PHY_11G;
3207 BOOLEAN StateMachineTouched = FALSE;
3208 #ifdef DOT11_N_SUPPORT
3209 OID_SET_HT_PHYMODE HT_PhyMode; //11n ,kathy
3210 #endif // DOT11_N_SUPPORT //
3211 #ifdef WPA_SUPPLICANT_SUPPORT
3212 PNDIS_802_11_PMKID pPmkId = NULL;
3213 BOOLEAN IEEE8021xState = FALSE;
3214 BOOLEAN IEEE8021x_required_keys = FALSE;
3215 UCHAR wpa_supplicant_enable = 0;
3216 #endif // WPA_SUPPLICANT_SUPPORT //
3219 TX_RTY_CFG_STRUC tx_rty_cfg;
3220 ULONG ShortRetryLimit, LongRetryLimit;
3222 #endif // SNMP_SUPPORT //
3225 #ifdef DOT11_N_SUPPORT
3226 MaxPhyMode = PHY_11N_5G;
3227 #endif // DOT11_N_SUPPORT //
3230 DBGPRINT(RT_DEBUG_TRACE, ("-->RTMPSetInformation(), 0x%08x\n", cmd&0x7FFF));
3231 switch(cmd & 0x7FFF) {
3232 case RT_OID_802_11_COUNTRY_REGION:
3233 if (wrq->u.data.length < sizeof(UCHAR))
3235 // Only avaliable when EEPROM not programming
3236 else if (!(pAdapter->CommonCfg.CountryRegion & 0x80) && !(pAdapter->CommonCfg.CountryRegionForABand & 0x80))
3241 Status = copy_from_user(&Country, wrq->u.data.pointer, wrq->u.data.length);
3242 pAdapter->CommonCfg.CountryRegion = (UCHAR)(Country & 0x000000FF);
3243 pAdapter->CommonCfg.CountryRegionForABand = (UCHAR)((Country >> 8) & 0x000000FF);
3244 TmpPhy = pAdapter->CommonCfg.PhyMode;
3245 pAdapter->CommonCfg.PhyMode = 0xff;
3246 // Build all corresponding channel information
3247 RTMPSetPhyMode(pAdapter, TmpPhy);
3248 #ifdef DOT11_N_SUPPORT
3249 SetCommonHT(pAdapter);
3250 #endif // DOT11_N_SUPPORT //
3251 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_COUNTRY_REGION (A:%d B/G:%d)\n", pAdapter->CommonCfg.CountryRegionForABand,
3252 pAdapter->CommonCfg.CountryRegion));
3255 case OID_802_11_BSSID_LIST_SCAN:
3257 if (ATE_ON(pAdapter))
3259 DBGPRINT(RT_DEBUG_TRACE, ("The driver is in ATE mode now\n"));
3262 #endif // RALINK_ATE //
3264 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_BSSID_LIST_SCAN, TxCnt = %d \n", pAdapter->RalinkCounters.LastOneSecTotalTxCount));
3266 if (MONITOR_ON(pAdapter))
3268 DBGPRINT(RT_DEBUG_TRACE, ("!!! Driver is in Monitor Mode now !!!\n"));
3272 //Benson add 20080527, when radio off, sta don't need to scan
3273 if (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_RADIO_OFF))
3276 if (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
3278 DBGPRINT(RT_DEBUG_TRACE, ("!!! Driver is scanning now !!!\n"));
3279 pAdapter->StaCfg.bScanReqIsFromWebUI = TRUE;
3280 Status = NDIS_STATUS_SUCCESS;
3284 if (pAdapter->RalinkCounters.LastOneSecTotalTxCount > 100)
3286 DBGPRINT(RT_DEBUG_TRACE, ("!!! Link UP, ignore this set::OID_802_11_BSSID_LIST_SCAN\n"));
3287 Status = NDIS_STATUS_SUCCESS;
3288 pAdapter->StaCfg.ScanCnt = 99; // Prevent auto scan triggered by this OID
3292 if ((OPSTATUS_TEST_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED)) &&
3293 ((pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA) ||
3294 (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK) ||
3295 (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA2) ||
3296 (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK)) &&
3297 (pAdapter->StaCfg.PortSecured == WPA_802_1X_PORT_NOT_SECURED))
3299 DBGPRINT(RT_DEBUG_TRACE, ("!!! Link UP, Port Not Secured! ignore this set::OID_802_11_BSSID_LIST_SCAN\n"));
3300 Status = NDIS_STATUS_SUCCESS;
3301 pAdapter->StaCfg.ScanCnt = 99; // Prevent auto scan triggered by this OID
3306 if (pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE)
3308 RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
3309 DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
3312 // tell CNTL state machine to call NdisMSetInformationComplete() after completing
3313 // this request, because this request is initiated by NDIS.
3314 pAdapter->MlmeAux.CurrReqIsFromNdis = FALSE;
3315 // Reset allowed scan retries
3316 pAdapter->StaCfg.ScanCnt = 0;
3317 pAdapter->StaCfg.LastScanTime = Now;
3319 pAdapter->StaCfg.bScanReqIsFromWebUI = TRUE;
3320 RTMP_SET_FLAG(pAdapter, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS);
3321 MlmeEnqueue(pAdapter,
3322 MLME_CNTL_STATE_MACHINE,
3323 OID_802_11_BSSID_LIST_SCAN,
3327 Status = NDIS_STATUS_SUCCESS;
3328 StateMachineTouched = TRUE;
3330 case OID_802_11_SSID:
3331 if (wrq->u.data.length != sizeof(NDIS_802_11_SSID))
3335 PCHAR pSsidString = NULL;
3336 Status = copy_from_user(&Ssid, wrq->u.data.pointer, wrq->u.data.length);
3338 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_SSID (Len=%d,Ssid=%s)\n", Ssid.SsidLength, Ssid.Ssid));
3339 if (Ssid.SsidLength > MAX_LEN_OF_SSID)
3343 if (Ssid.SsidLength == 0)
3345 Set_SSID_Proc(pAdapter, "");
3349 pSsidString = (CHAR *) kmalloc(MAX_LEN_OF_SSID+1, MEM_ALLOC_FLAG);
3352 NdisZeroMemory(pSsidString, MAX_LEN_OF_SSID+1);
3353 NdisMoveMemory(pSsidString, Ssid.Ssid, Ssid.SsidLength);
3354 Set_SSID_Proc(pAdapter, pSsidString);
3363 case OID_802_11_BSSID:
3365 if (ATE_ON(pAdapter))
3367 DBGPRINT(RT_DEBUG_TRACE, ("The driver is in ATE mode now\n"));
3370 #endif // RALINK_ATE //
3371 if (wrq->u.data.length != sizeof(NDIS_802_11_MAC_ADDRESS))
3375 Status = copy_from_user(&Bssid, wrq->u.data.pointer, wrq->u.data.length);
3377 // tell CNTL state machine to call NdisMSetInformationComplete() after completing
3378 // this request, because this request is initiated by NDIS.
3379 pAdapter->MlmeAux.CurrReqIsFromNdis = FALSE;
3381 // Prevent to connect AP again in STAMlmePeriodicExec
3382 pAdapter->MlmeAux.AutoReconnectSsidLen= 32;
3384 // Reset allowed scan retries
3385 pAdapter->StaCfg.ScanCnt = 0;
3387 if (pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE)
3389 RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
3390 DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
3392 MlmeEnqueue(pAdapter,
3393 MLME_CNTL_STATE_MACHINE,
3395 sizeof(NDIS_802_11_MAC_ADDRESS),
3397 Status = NDIS_STATUS_SUCCESS;
3398 StateMachineTouched = TRUE;
3400 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_BSSID %02x:%02x:%02x:%02x:%02x:%02x\n",
3401 Bssid[0], Bssid[1], Bssid[2], Bssid[3], Bssid[4], Bssid[5]));
3404 case RT_OID_802_11_RADIO:
3405 if (wrq->u.data.length != sizeof(BOOLEAN))
3409 Status = copy_from_user(&RadioState, wrq->u.data.pointer, wrq->u.data.length);
3410 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_RADIO (=%d)\n", RadioState));
3411 if (pAdapter->StaCfg.bSwRadio != RadioState)
3413 pAdapter->StaCfg.bSwRadio = RadioState;
3414 if (pAdapter->StaCfg.bRadio != (pAdapter->StaCfg.bHwRadio && pAdapter->StaCfg.bSwRadio))
3416 pAdapter->StaCfg.bRadio = (pAdapter->StaCfg.bHwRadio && pAdapter->StaCfg.bSwRadio);
3417 if (pAdapter->StaCfg.bRadio == TRUE)
3419 MlmeRadioOn(pAdapter);
3420 // Update extra information
3421 pAdapter->ExtraInfo = EXTRA_INFO_CLEAR;
3425 MlmeRadioOff(pAdapter);
3426 // Update extra information
3427 pAdapter->ExtraInfo = SW_RADIO_OFF;
3433 case RT_OID_802_11_PHY_MODE:
3434 if (wrq->u.data.length != sizeof(RT_802_11_PHY_MODE))
3438 Status = copy_from_user(&PhyMode, wrq->u.data.pointer, wrq->u.data.length);
3439 if (PhyMode <= MaxPhyMode)
3441 RTMPSetPhyMode(pAdapter, PhyMode);
3442 #ifdef DOT11_N_SUPPORT
3443 SetCommonHT(pAdapter);
3444 #endif // DOT11_N_SUPPORT //
3446 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_PHY_MODE (=%d)\n", PhyMode));
3449 case RT_OID_802_11_STA_CONFIG:
3450 if (wrq->u.data.length != sizeof(RT_802_11_STA_CONFIG))
3454 Status = copy_from_user(&StaConfig, wrq->u.data.pointer, wrq->u.data.length);
3455 pAdapter->CommonCfg.bEnableTxBurst = StaConfig.EnableTxBurst;
3456 pAdapter->CommonCfg.UseBGProtection = StaConfig.UseBGProtection;
3457 pAdapter->CommonCfg.bUseShortSlotTime = 1; // 2003-10-30 always SHORT SLOT capable
3458 if ((pAdapter->CommonCfg.PhyMode != StaConfig.AdhocMode) &&
3459 (StaConfig.AdhocMode <= MaxPhyMode))
3461 // allow dynamic change of "USE OFDM rate or not" in ADHOC mode
3462 // if setting changed, need to reset current TX rate as well as BEACON frame format
3463 pAdapter->CommonCfg.PhyMode = StaConfig.AdhocMode;
3464 if (pAdapter->StaCfg.BssType == BSS_ADHOC)
3466 RTMPSetPhyMode(pAdapter, PhyMode);
3467 MlmeUpdateTxRates(pAdapter, FALSE, 0);
3468 MakeIbssBeacon(pAdapter); // re-build BEACON frame
3469 AsicEnableIbssSync(pAdapter); // copy to on-chip memory
3472 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_SET_STA_CONFIG (Burst=%d, Protection=%ld,ShortSlot=%d\n",
3473 pAdapter->CommonCfg.bEnableTxBurst,
3474 pAdapter->CommonCfg.UseBGProtection,
3475 pAdapter->CommonCfg.bUseShortSlotTime));
3478 case OID_802_11_DESIRED_RATES:
3479 if (wrq->u.data.length != sizeof(NDIS_802_11_RATES))
3483 Status = copy_from_user(&aryRates, wrq->u.data.pointer, wrq->u.data.length);
3484 NdisZeroMemory(pAdapter->CommonCfg.DesireRate, MAX_LEN_OF_SUPPORTED_RATES);
3485 NdisMoveMemory(pAdapter->CommonCfg.DesireRate, &aryRates, sizeof(NDIS_802_11_RATES));
3486 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_DESIRED_RATES (%02x,%02x,%02x,%02x,%02x,%02x,%02x,%02x)\n",
3487 pAdapter->CommonCfg.DesireRate[0],pAdapter->CommonCfg.DesireRate[1],
3488 pAdapter->CommonCfg.DesireRate[2],pAdapter->CommonCfg.DesireRate[3],
3489 pAdapter->CommonCfg.DesireRate[4],pAdapter->CommonCfg.DesireRate[5],
3490 pAdapter->CommonCfg.DesireRate[6],pAdapter->CommonCfg.DesireRate[7] ));
3491 // Changing DesiredRate may affect the MAX TX rate we used to TX frames out
3492 MlmeUpdateTxRates(pAdapter, FALSE, 0);
3495 case RT_OID_802_11_PREAMBLE:
3496 if (wrq->u.data.length != sizeof(RT_802_11_PREAMBLE))
3500 Status = copy_from_user(&Preamble, wrq->u.data.pointer, wrq->u.data.length);
3501 if (Preamble == Rt802_11PreambleShort)
3503 pAdapter->CommonCfg.TxPreamble = Preamble;
3504 MlmeSetTxPreamble(pAdapter, Rt802_11PreambleShort);
3506 else if ((Preamble == Rt802_11PreambleLong) || (Preamble == Rt802_11PreambleAuto))
3508 // if user wants AUTO, initialize to LONG here, then change according to AP's
3509 // capability upon association.
3510 pAdapter->CommonCfg.TxPreamble = Preamble;
3511 MlmeSetTxPreamble(pAdapter, Rt802_11PreambleLong);
3518 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_PREAMBLE (=%d)\n", Preamble));
3521 case OID_802_11_WEP_STATUS:
3522 if (wrq->u.data.length != sizeof(NDIS_802_11_WEP_STATUS))
3526 Status = copy_from_user(&WepStatus, wrq->u.data.pointer, wrq->u.data.length);
3527 // Since TKIP, AES, WEP are all supported. It should not have any invalid setting
3528 if (WepStatus <= Ndis802_11Encryption3KeyAbsent)
3530 if (pAdapter->StaCfg.WepStatus != WepStatus)
3532 // Config has changed
3533 pAdapter->bConfigChanged = TRUE;
3535 pAdapter->StaCfg.WepStatus = WepStatus;
3536 pAdapter->StaCfg.OrigWepStatus = WepStatus;
3537 pAdapter->StaCfg.PairCipher = WepStatus;
3538 pAdapter->StaCfg.GroupCipher = WepStatus;
3545 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_WEP_STATUS (=%d)\n",WepStatus));
3548 case OID_802_11_AUTHENTICATION_MODE:
3549 if (wrq->u.data.length != sizeof(NDIS_802_11_AUTHENTICATION_MODE))
3553 Status = copy_from_user(&AuthMode, wrq->u.data.pointer, wrq->u.data.length);
3554 if (AuthMode > Ndis802_11AuthModeMax)
3561 if (pAdapter->StaCfg.AuthMode != AuthMode)
3563 // Config has changed
3564 pAdapter->bConfigChanged = TRUE;
3566 pAdapter->StaCfg.AuthMode = AuthMode;
3568 pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED;
3569 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_AUTHENTICATION_MODE (=%d) \n",pAdapter->StaCfg.AuthMode));
3572 case OID_802_11_INFRASTRUCTURE_MODE:
3573 if (wrq->u.data.length != sizeof(NDIS_802_11_NETWORK_INFRASTRUCTURE))
3577 Status = copy_from_user(&BssType, wrq->u.data.pointer, wrq->u.data.length);
3579 if (BssType == Ndis802_11IBSS)
3580 Set_NetworkType_Proc(pAdapter, "Adhoc");
3581 else if (BssType == Ndis802_11Infrastructure)
3582 Set_NetworkType_Proc(pAdapter, "Infra");
3583 else if (BssType == Ndis802_11Monitor)
3584 Set_NetworkType_Proc(pAdapter, "Monitor");
3588 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_INFRASTRUCTURE_MODE (unknown)\n"));
3592 case OID_802_11_REMOVE_WEP:
3593 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_WEP\n"));
3594 if (wrq->u.data.length != sizeof(NDIS_802_11_KEY_INDEX))
3600 KeyIdx = *(NDIS_802_11_KEY_INDEX *) wrq->u.data.pointer;
3602 if (KeyIdx & 0x80000000)
3604 // Should never set default bit when remove key
3609 KeyIdx = KeyIdx & 0x0fffffff;
3615 pAdapter->SharedKey[BSS0][KeyIdx].KeyLen = 0;
3616 pAdapter->SharedKey[BSS0][KeyIdx].CipherAlg = CIPHER_NONE;
3617 AsicRemoveSharedKeyEntry(pAdapter, 0, (UCHAR)KeyIdx);
3622 case RT_OID_802_11_RESET_COUNTERS:
3623 NdisZeroMemory(&pAdapter->WlanCounters, sizeof(COUNTER_802_11));
3624 NdisZeroMemory(&pAdapter->Counters8023, sizeof(COUNTER_802_3));
3625 NdisZeroMemory(&pAdapter->RalinkCounters, sizeof(COUNTER_RALINK));
3626 pAdapter->Counters8023.RxNoBuffer = 0;
3627 pAdapter->Counters8023.GoodReceives = 0;
3628 pAdapter->Counters8023.RxNoBuffer = 0;
3630 pAdapter->BulkOutComplete = 0;
3631 pAdapter->BulkOutCompleteOther= 0;
3632 pAdapter->BulkOutCompleteCancel = 0;
3633 pAdapter->BulkOutReq = 0;
3634 pAdapter->BulkInReq= 0;
3635 pAdapter->BulkInComplete = 0;
3636 pAdapter->BulkInCompleteFail = 0;
3638 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_RESET_COUNTERS \n"));
3640 case OID_802_11_RTS_THRESHOLD:
3641 if (wrq->u.data.length != sizeof(NDIS_802_11_RTS_THRESHOLD))
3645 Status = copy_from_user(&RtsThresh, wrq->u.data.pointer, wrq->u.data.length);
3646 if (RtsThresh > MAX_RTS_THRESHOLD)
3649 pAdapter->CommonCfg.RtsThreshold = (USHORT)RtsThresh;
3651 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_RTS_THRESHOLD (=%ld)\n",RtsThresh));
3653 case OID_802_11_FRAGMENTATION_THRESHOLD:
3654 if (wrq->u.data.length != sizeof(NDIS_802_11_FRAGMENTATION_THRESHOLD))
3658 Status = copy_from_user(&FragThresh, wrq->u.data.pointer, wrq->u.data.length);
3659 pAdapter->CommonCfg.bUseZeroToDisableFragment = FALSE;
3660 if (FragThresh > MAX_FRAG_THRESHOLD || FragThresh < MIN_FRAG_THRESHOLD)
3662 if (FragThresh == 0)
3664 pAdapter->CommonCfg.FragmentThreshold = MAX_FRAG_THRESHOLD;
3665 pAdapter->CommonCfg.bUseZeroToDisableFragment = TRUE;
3671 pAdapter->CommonCfg.FragmentThreshold = (USHORT)FragThresh;
3673 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_FRAGMENTATION_THRESHOLD (=%ld) \n",FragThresh));
3675 case OID_802_11_POWER_MODE:
3676 if (wrq->u.data.length != sizeof(NDIS_802_11_POWER_MODE))
3680 Status = copy_from_user(&PowerMode, wrq->u.data.pointer, wrq->u.data.length);
3681 if (PowerMode == Ndis802_11PowerModeCAM)
3682 Set_PSMode_Proc(pAdapter, "CAM");
3683 else if (PowerMode == Ndis802_11PowerModeMAX_PSP)
3684 Set_PSMode_Proc(pAdapter, "Max_PSP");
3685 else if (PowerMode == Ndis802_11PowerModeFast_PSP)
3686 Set_PSMode_Proc(pAdapter, "Fast_PSP");
3687 else if (PowerMode == Ndis802_11PowerModeLegacy_PSP)
3688 Set_PSMode_Proc(pAdapter, "Legacy_PSP");
3692 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_POWER_MODE (=%d)\n",PowerMode));
3694 case RT_OID_802_11_TX_POWER_LEVEL_1:
3695 if (wrq->u.data.length < sizeof(ULONG))
3699 Status = copy_from_user(&PowerTemp, wrq->u.data.pointer, wrq->u.data.length);
3700 if (PowerTemp > 100)
3701 PowerTemp = 0xffffffff; // AUTO
3702 pAdapter->CommonCfg.TxPowerDefault = PowerTemp; //keep current setting.
3703 pAdapter->CommonCfg.TxPowerPercentage = pAdapter->CommonCfg.TxPowerDefault;
3704 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_TX_POWER_LEVEL_1 (=%ld)\n", pAdapter->CommonCfg.TxPowerPercentage));
3707 case OID_802_11_NETWORK_TYPE_IN_USE:
3708 if (wrq->u.data.length != sizeof(NDIS_802_11_NETWORK_TYPE))
3712 Status = copy_from_user(&NetType, wrq->u.data.pointer, wrq->u.data.length);
3714 if (NetType == Ndis802_11DS)
3715 RTMPSetPhyMode(pAdapter, PHY_11B);
3716 else if (NetType == Ndis802_11OFDM24)
3717 RTMPSetPhyMode(pAdapter, PHY_11BG_MIXED);
3718 else if (NetType == Ndis802_11OFDM5)
3719 RTMPSetPhyMode(pAdapter, PHY_11A);
3722 #ifdef DOT11_N_SUPPORT
3723 if (Status == NDIS_STATUS_SUCCESS)
3724 SetCommonHT(pAdapter);
3725 #endif // DOT11_N_SUPPORT //
3726 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_NETWORK_TYPE_IN_USE (=%d)\n",NetType));
3729 // For WPA PSK PMK key
3730 case RT_OID_802_11_ADD_WPA:
3731 pKey = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
3738 Status = copy_from_user(pKey, wrq->u.data.pointer, wrq->u.data.length);
3739 if (pKey->Length != wrq->u.data.length)
3742 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_ADD_WPA, Failed!!\n"));
3746 if ((pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPAPSK) &&
3747 (pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPA2PSK) &&
3748 (pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPANone) )
3750 Status = -EOPNOTSUPP;
3751 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_ADD_WPA, Failed!! [AuthMode != WPAPSK/WPA2PSK/WPANONE]\n"));
3753 else if ((pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK) ||
3754 (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK) ||
3755 (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPANone) ) // Only for WPA PSK mode
3757 NdisMoveMemory(pAdapter->StaCfg.PMK, &pKey->KeyMaterial, pKey->KeyLength);
3758 // Use RaConfig as PSK agent.
3759 // Start STA supplicant state machine
3760 if (pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPANone)
3761 pAdapter->StaCfg.WpaState = SS_START;
3763 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_ADD_WPA (id=0x%x, Len=%d-byte)\n", pKey->KeyIndex, pKey->KeyLength));
3767 pAdapter->StaCfg.WpaState = SS_NOTUSE;
3768 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_ADD_WPA (id=0x%x, Len=%d-byte)\n", pKey->KeyIndex, pKey->KeyLength));
3773 case OID_802_11_REMOVE_KEY:
3774 pRemoveKey = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
3775 if(pRemoveKey == NULL)
3781 Status = copy_from_user(pRemoveKey, wrq->u.data.pointer, wrq->u.data.length);
3782 if (pRemoveKey->Length != wrq->u.data.length)
3785 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_KEY, Failed!!\n"));
3789 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
3791 RTMPWPARemoveKeyProc(pAdapter, pRemoveKey);
3792 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_KEY, Remove WPA Key!!\n"));
3796 KeyIdx = pRemoveKey->KeyIndex;
3798 if (KeyIdx & 0x80000000)
3800 // Should never set default bit when remove key
3802 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_KEY, Failed!!(Should never set default bit when remove key)\n"));
3806 KeyIdx = KeyIdx & 0x0fffffff;
3810 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_KEY, Failed!!(KeyId[%d] out of range)\n", KeyIdx));
3814 pAdapter->SharedKey[BSS0][KeyIdx].KeyLen = 0;
3815 pAdapter->SharedKey[BSS0][KeyIdx].CipherAlg = CIPHER_NONE;
3816 AsicRemoveSharedKeyEntry(pAdapter, 0, (UCHAR)KeyIdx);
3817 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_KEY (id=0x%x, Len=%d-byte)\n", pRemoveKey->KeyIndex, pRemoveKey->Length));
3825 case OID_802_11_ADD_KEY:
3826 pKey = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
3832 Status = copy_from_user(pKey, wrq->u.data.pointer, wrq->u.data.length);
3833 if (pKey->Length != wrq->u.data.length)
3836 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_KEY, Failed!!\n"));
3840 RTMPAddKey(pAdapter, pKey);
3841 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_KEY (id=0x%x, Len=%d-byte)\n", pKey->KeyIndex, pKey->KeyLength));
3845 case OID_802_11_CONFIGURATION:
3846 if (wrq->u.data.length != sizeof(NDIS_802_11_CONFIGURATION))
3850 Status = copy_from_user(&Config, wrq->u.data.pointer, wrq->u.data.length);
3853 if ((pConfig->BeaconPeriod >= 20) && (pConfig->BeaconPeriod <=400))
3854 pAdapter->CommonCfg.BeaconPeriod = (USHORT) pConfig->BeaconPeriod;
3856 pAdapter->StaActive.AtimWin = (USHORT) pConfig->ATIMWindow;
3857 MAP_KHZ_TO_CHANNEL_ID(pConfig->DSConfig, pAdapter->CommonCfg.Channel);
3859 // Save the channel on MlmeAux for CntlOidRTBssidProc used.
3861 pAdapter->MlmeAux.Channel = pAdapter->CommonCfg.Channel;
3863 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_CONFIGURATION (BeacnPeriod=%ld,AtimW=%ld,Ch=%d)\n",
3864 pConfig->BeaconPeriod, pConfig->ATIMWindow, pAdapter->CommonCfg.Channel));
3865 // Config has changed
3866 pAdapter->bConfigChanged = TRUE;
3869 #ifdef DOT11_N_SUPPORT
3870 case RT_OID_802_11_SET_HT_PHYMODE:
3871 if (wrq->u.data.length != sizeof(OID_SET_HT_PHYMODE))
3875 POID_SET_HT_PHYMODE pHTPhyMode = &HT_PhyMode;
3877 Status = copy_from_user(&HT_PhyMode, wrq->u.data.pointer, wrq->u.data.length);
3878 DBGPRINT(RT_DEBUG_TRACE, ("Set::pHTPhyMode (PhyMode = %d,TransmitNo = %d, HtMode = %d, ExtOffset = %d , MCS = %d, BW = %d, STBC = %d, SHORTGI = %d) \n",
3879 pHTPhyMode->PhyMode, pHTPhyMode->TransmitNo,pHTPhyMode->HtMode,pHTPhyMode->ExtOffset,
3880 pHTPhyMode->MCS, pHTPhyMode->BW, pHTPhyMode->STBC, pHTPhyMode->SHORTGI));
3881 if (pAdapter->CommonCfg.PhyMode >= PHY_11ABGN_MIXED)
3882 RTMPSetHT(pAdapter, pHTPhyMode);
3884 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_SET_HT_PHYMODE(MCS=%d,BW=%d,SGI=%d,STBC=%d)\n",
3885 pAdapter->StaCfg.HTPhyMode.field.MCS, pAdapter->StaCfg.HTPhyMode.field.BW, pAdapter->StaCfg.HTPhyMode.field.ShortGI,
3886 pAdapter->StaCfg.HTPhyMode.field.STBC));
3888 #endif // DOT11_N_SUPPORT //
3889 case RT_OID_802_11_SET_APSD_SETTING:
3890 if (wrq->u.data.length != sizeof(ULONG))
3895 Status = copy_from_user(&apsd, wrq->u.data.pointer, wrq->u.data.length);
3897 /*-------------------------------------------------------------------
3898 |B31~B7 | B6~B5 | B4 | B3 | B2 | B1 | B0 |
3899 ---------------------------------------------------------------------
3900 | Rsvd | Max SP Len | AC_VO | AC_VI | AC_BK | AC_BE | APSD Capable |
3901 ---------------------------------------------------------------------*/
3902 pAdapter->CommonCfg.bAPSDCapable = (apsd & 0x00000001) ? TRUE : FALSE;
3903 pAdapter->CommonCfg.bAPSDAC_BE = ((apsd & 0x00000002) >> 1) ? TRUE : FALSE;
3904 pAdapter->CommonCfg.bAPSDAC_BK = ((apsd & 0x00000004) >> 2) ? TRUE : FALSE;
3905 pAdapter->CommonCfg.bAPSDAC_VI = ((apsd & 0x00000008) >> 3) ? TRUE : FALSE;
3906 pAdapter->CommonCfg.bAPSDAC_VO = ((apsd & 0x00000010) >> 4) ? TRUE : FALSE;
3907 pAdapter->CommonCfg.MaxSPLength = (UCHAR)((apsd & 0x00000060) >> 5);
3909 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,
3910 pAdapter->CommonCfg.bAPSDAC_BE, pAdapter->CommonCfg.bAPSDAC_BK, pAdapter->CommonCfg.bAPSDAC_VI, pAdapter->CommonCfg.bAPSDAC_VO, pAdapter->CommonCfg.MaxSPLength));
3914 case RT_OID_802_11_SET_APSD_PSM:
3915 if (wrq->u.data.length != sizeof(ULONG))
3919 // Driver needs to notify AP when PSM changes
3920 Status = copy_from_user(&pAdapter->CommonCfg.bAPSDForcePowerSave, wrq->u.data.pointer, wrq->u.data.length);
3921 if (pAdapter->CommonCfg.bAPSDForcePowerSave != pAdapter->StaCfg.Psm)
3923 MlmeSetPsmBit(pAdapter, pAdapter->CommonCfg.bAPSDForcePowerSave);
3924 RTMPSendNullFrame(pAdapter, pAdapter->CommonCfg.TxRate, TRUE);
3926 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_SET_APSD_PSM (bAPSDForcePowerSave:%d)\n", pAdapter->CommonCfg.bAPSDForcePowerSave));
3929 #ifdef QOS_DLS_SUPPORT
3930 case RT_OID_802_11_SET_DLS:
3931 if (wrq->u.data.length != sizeof(ULONG))
3935 BOOLEAN oldvalue = pAdapter->CommonCfg.bDLSCapable;
3936 Status = copy_from_user(&pAdapter->CommonCfg.bDLSCapable, wrq->u.data.pointer, wrq->u.data.length);
3937 if (oldvalue && !pAdapter->CommonCfg.bDLSCapable)
3940 // tear down local dls table entry
3941 for (i=0; i<MAX_NUM_OF_INIT_DLS_ENTRY; i++)
3943 if (pAdapter->StaCfg.DLSEntry[i].Valid && (pAdapter->StaCfg.DLSEntry[i].Status == DLS_FINISH))
3945 pAdapter->StaCfg.DLSEntry[i].Status = DLS_NONE;
3946 pAdapter->StaCfg.DLSEntry[i].Valid = FALSE;
3947 RTMPSendDLSTearDownFrame(pAdapter, pAdapter->StaCfg.DLSEntry[i].MacAddr);
3951 // tear down peer dls table entry
3952 for (i=MAX_NUM_OF_INIT_DLS_ENTRY; i<MAX_NUM_OF_DLS_ENTRY; i++)
3954 if (pAdapter->StaCfg.DLSEntry[i].Valid && (pAdapter->StaCfg.DLSEntry[i].Status == DLS_FINISH))
3956 pAdapter->StaCfg.DLSEntry[i].Status = DLS_NONE;
3957 pAdapter->StaCfg.DLSEntry[i].Valid = FALSE;
3958 RTMPSendDLSTearDownFrame(pAdapter, pAdapter->StaCfg.DLSEntry[i].MacAddr);
3963 DBGPRINT(RT_DEBUG_TRACE,("Set::RT_OID_802_11_SET_DLS (=%d)\n", pAdapter->CommonCfg.bDLSCapable));
3967 case RT_OID_802_11_SET_DLS_PARAM:
3968 if (wrq->u.data.length != sizeof(RT_802_11_DLS_UI))
3974 NdisZeroMemory(&Dls, sizeof(RT_802_11_DLS));
3975 RTMPMoveMemory(&Dls, wrq->u.data.pointer, sizeof(RT_802_11_DLS_UI));
3976 MlmeEnqueue(pAdapter,
3977 MLME_CNTL_STATE_MACHINE,
3978 RT_OID_802_11_SET_DLS_PARAM,
3979 sizeof(RT_802_11_DLS),
3981 DBGPRINT(RT_DEBUG_TRACE,("Set::RT_OID_802_11_SET_DLS_PARAM \n"));
3984 #endif // QOS_DLS_SUPPORT //
3985 case RT_OID_802_11_SET_WMM:
3986 if (wrq->u.data.length != sizeof(BOOLEAN))
3990 Status = copy_from_user(&pAdapter->CommonCfg.bWmmCapable, wrq->u.data.pointer, wrq->u.data.length);
3991 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_SET_WMM (=%d) \n", pAdapter->CommonCfg.bWmmCapable));
3995 case OID_802_11_DISASSOCIATE:
3997 if (ATE_ON(pAdapter))
3999 DBGPRINT(RT_DEBUG_TRACE, ("The driver is in ATE mode now\n"));
4002 #endif // RALINK_ATE //
4004 // Set NdisRadioStateOff to TRUE, instead of called MlmeRadioOff.
4005 // Later on, NDIS_802_11_BSSID_LIST_EX->NumberOfItems should be 0
4006 // when query OID_802_11_BSSID_LIST.
4008 // TRUE: NumberOfItems will set to 0.
4009 // FALSE: NumberOfItems no change.
4011 pAdapter->CommonCfg.NdisRadioStateOff = TRUE;
4012 // Set to immediately send the media disconnect event
4013 pAdapter->MlmeAux.CurrReqIsFromNdis = TRUE;
4014 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_DISASSOCIATE \n"));
4016 if (INFRA_ON(pAdapter))
4018 if (pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE)
4020 RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
4021 DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
4024 MlmeEnqueue(pAdapter,
4025 MLME_CNTL_STATE_MACHINE,
4026 OID_802_11_DISASSOCIATE,
4030 StateMachineTouched = TRUE;
4034 #ifdef DOT11_N_SUPPORT
4035 case RT_OID_802_11_SET_IMME_BA_CAP:
4036 if (wrq->u.data.length != sizeof(OID_BACAP_STRUC))
4040 OID_BACAP_STRUC Orde ;
4041 Status = copy_from_user(&Orde, wrq->u.data.pointer, wrq->u.data.length);
4042 if (Orde.Policy > BA_NOTUSE)
4044 Status = NDIS_STATUS_INVALID_DATA;
4046 else if (Orde.Policy == BA_NOTUSE)
4048 pAdapter->CommonCfg.BACapability.field.Policy = BA_NOTUSE;
4049 pAdapter->CommonCfg.BACapability.field.MpduDensity = Orde.MpduDensity;
4050 pAdapter->CommonCfg.DesiredHtPhy.MpduDensity = Orde.MpduDensity;
4051 pAdapter->CommonCfg.DesiredHtPhy.AmsduEnable = Orde.AmsduEnable;
4052 pAdapter->CommonCfg.DesiredHtPhy.AmsduSize= Orde.AmsduSize;
4053 pAdapter->CommonCfg.DesiredHtPhy.MimoPs= Orde.MMPSmode;
4054 pAdapter->CommonCfg.BACapability.field.MMPSmode = Orde.MMPSmode;
4056 pAdapter->CommonCfg.HtCapability.HtCapInfo.MimoPs = Orde.MMPSmode;
4057 pAdapter->CommonCfg.HtCapability.HtCapInfo.AMsduSize = Orde.AmsduSize;
4058 pAdapter->CommonCfg.HtCapability.HtCapParm.MpduDensity = Orde.MpduDensity;
4062 pAdapter->CommonCfg.BACapability.field.AutoBA = Orde.AutoBA;
4063 pAdapter->CommonCfg.BACapability.field.Policy = IMMED_BA; // we only support immediate BA.
4064 pAdapter->CommonCfg.BACapability.field.MpduDensity = Orde.MpduDensity;
4065 pAdapter->CommonCfg.DesiredHtPhy.MpduDensity = Orde.MpduDensity;
4066 pAdapter->CommonCfg.DesiredHtPhy.AmsduEnable = Orde.AmsduEnable;
4067 pAdapter->CommonCfg.DesiredHtPhy.AmsduSize= Orde.AmsduSize;
4068 pAdapter->CommonCfg.DesiredHtPhy.MimoPs = Orde.MMPSmode;
4069 pAdapter->CommonCfg.BACapability.field.MMPSmode = Orde.MMPSmode;
4072 pAdapter->CommonCfg.HtCapability.HtCapInfo.MimoPs = Orde.MMPSmode;
4073 pAdapter->CommonCfg.HtCapability.HtCapInfo.AMsduSize = Orde.AmsduSize;
4074 pAdapter->CommonCfg.HtCapability.HtCapParm.MpduDensity = Orde.MpduDensity;
4076 if (pAdapter->CommonCfg.BACapability.field.RxBAWinLimit > MAX_RX_REORDERBUF)
4077 pAdapter->CommonCfg.BACapability.field.RxBAWinLimit = MAX_RX_REORDERBUF;
4081 pAdapter->CommonCfg.REGBACapability.word = pAdapter->CommonCfg.BACapability.word;
4082 DBGPRINT(RT_DEBUG_TRACE, ("Set::(Orde.AutoBA = %d) (Policy=%d)(ReBAWinLimit=%d)(TxBAWinLimit=%d)(AutoMode=%d)\n",Orde.AutoBA, pAdapter->CommonCfg.BACapability.field.Policy,
4083 pAdapter->CommonCfg.BACapability.field.RxBAWinLimit,pAdapter->CommonCfg.BACapability.field.TxBAWinLimit, pAdapter->CommonCfg.BACapability.field.AutoBA));
4084 DBGPRINT(RT_DEBUG_TRACE, ("Set::(MimoPs = %d)(AmsduEnable = %d) (AmsduSize=%d)(MpduDensity=%d)\n",pAdapter->CommonCfg.DesiredHtPhy.MimoPs, pAdapter->CommonCfg.DesiredHtPhy.AmsduEnable,
4085 pAdapter->CommonCfg.DesiredHtPhy.AmsduSize, pAdapter->CommonCfg.DesiredHtPhy.MpduDensity));
4089 case RT_OID_802_11_ADD_IMME_BA:
4090 DBGPRINT(RT_DEBUG_TRACE, (" Set :: RT_OID_802_11_ADD_IMME_BA \n"));
4091 if (wrq->u.data.length != sizeof(OID_ADD_BA_ENTRY))
4096 OID_ADD_BA_ENTRY BA;
4097 MAC_TABLE_ENTRY *pEntry;
4099 Status = copy_from_user(&BA, wrq->u.data.pointer, wrq->u.data.length);
4102 Status = NDIS_STATUS_INVALID_DATA;
4107 //BATableInsertEntry
4108 //As ad-hoc mode, BA pair is not limited to only BSSID. so add via OID.
4110 // in ad hoc mode, when adding BA pair, we should insert this entry into MACEntry too
4111 pEntry = MacTableLookup(pAdapter, BA.MACAddr);
4114 DBGPRINT(RT_DEBUG_TRACE, ("RT_OID_802_11_ADD_IMME_BA. break on no connection.----:%x:%x\n", BA.MACAddr[4], BA.MACAddr[5]));
4117 if (BA.IsRecipient == FALSE)
4119 if (pEntry->bIAmBadAtheros == TRUE)
4120 pAdapter->CommonCfg.BACapability.field.RxBAWinLimit = 0x10;
4122 BAOriSessionSetUp(pAdapter, pEntry, index, 0, 100, TRUE);
4126 //BATableInsertEntry(pAdapter, pEntry->Aid, BA.MACAddr, 0, 0xffff, BA.TID, BA.nMSDU, BA.IsRecipient);
4129 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_ADD_IMME_BA. Rec = %d. Mac = %x:%x:%x:%x:%x:%x . \n",
4130 BA.IsRecipient, BA.MACAddr[0], BA.MACAddr[1], BA.MACAddr[2], BA.MACAddr[2]
4131 , BA.MACAddr[4], BA.MACAddr[5]));
4136 case RT_OID_802_11_TEAR_IMME_BA:
4137 DBGPRINT(RT_DEBUG_TRACE, ("Set :: RT_OID_802_11_TEAR_IMME_BA \n"));
4138 if (wrq->u.data.length != sizeof(OID_ADD_BA_ENTRY))
4142 POID_ADD_BA_ENTRY pBA;
4143 MAC_TABLE_ENTRY *pEntry;
4145 pBA = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
4149 DBGPRINT(RT_DEBUG_TRACE, ("Set :: RT_OID_802_11_TEAR_IMME_BA kmalloc() can't allocate enough memory\n"));
4150 Status = NDIS_STATUS_FAILURE;
4154 Status = copy_from_user(pBA, wrq->u.data.pointer, wrq->u.data.length);
4155 DBGPRINT(RT_DEBUG_TRACE, ("Set :: RT_OID_802_11_TEAR_IMME_BA(TID=%d, bAllTid=%d)\n", pBA->TID, pBA->bAllTid));
4157 if (!pBA->bAllTid && (pBA->TID > NUM_OF_TID))
4159 Status = NDIS_STATUS_INVALID_DATA;
4163 if (pBA->IsRecipient == FALSE)
4165 pEntry = MacTableLookup(pAdapter, pBA->MACAddr);
4166 DBGPRINT(RT_DEBUG_TRACE, (" pBA->IsRecipient == FALSE\n"));
4169 DBGPRINT(RT_DEBUG_TRACE, (" pBA->pEntry\n"));
4170 BAOriSessionTearDown(pAdapter, pEntry->Aid, pBA->TID, FALSE, TRUE);
4173 DBGPRINT(RT_DEBUG_TRACE, ("Set :: Not found pEntry \n"));
4177 pEntry = MacTableLookup(pAdapter, pBA->MACAddr);
4180 BARecSessionTearDown( pAdapter, (UCHAR)pEntry->Aid, pBA->TID, TRUE);
4183 DBGPRINT(RT_DEBUG_TRACE, ("Set :: Not found pEntry \n"));
4189 #endif // DOT11_N_SUPPORT //
4191 // For WPA_SUPPLICANT to set static wep key
4192 case OID_802_11_ADD_WEP:
4193 pWepKey = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
4198 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_WEP, Failed!!\n"));
4201 Status = copy_from_user(pWepKey, wrq->u.data.pointer, wrq->u.data.length);
4205 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_WEP, Failed (length mismatch)!!\n"));
4209 KeyIdx = pWepKey->KeyIndex & 0x0fffffff;
4210 // KeyIdx must be 0 ~ 3
4214 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_WEP, Failed (KeyIdx must be smaller than 4)!!\n"));
4218 UCHAR CipherAlg = 0;
4221 // set key material and key length
4222 NdisZeroMemory(pAdapter->SharedKey[BSS0][KeyIdx].Key, 16);
4223 pAdapter->SharedKey[BSS0][KeyIdx].KeyLen = (UCHAR) pWepKey->KeyLength;
4224 NdisMoveMemory(pAdapter->SharedKey[BSS0][KeyIdx].Key, &pWepKey->KeyMaterial, pWepKey->KeyLength);
4226 switch(pWepKey->KeyLength)
4229 CipherAlg = CIPHER_WEP64;
4232 CipherAlg = CIPHER_WEP128;
4235 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_WEP, only support CIPHER_WEP64(len:5) & CIPHER_WEP128(len:13)!!\n"));
4239 pAdapter->SharedKey[BSS0][KeyIdx].CipherAlg = CipherAlg;
4241 // Default key for tx (shared key)
4242 if (pWepKey->KeyIndex & 0x80000000)
4244 #ifdef WPA_SUPPLICANT_SUPPORT
4245 // set key material and key length
4246 NdisZeroMemory(pAdapter->StaCfg.DesireSharedKey[KeyIdx].Key, 16);
4247 pAdapter->StaCfg.DesireSharedKey[KeyIdx].KeyLen = (UCHAR) pWepKey->KeyLength;
4248 NdisMoveMemory(pAdapter->StaCfg.DesireSharedKey[KeyIdx].Key, &pWepKey->KeyMaterial, pWepKey->KeyLength);
4249 pAdapter->StaCfg.DesireSharedKeyId = KeyIdx;
4250 pAdapter->StaCfg.DesireSharedKey[KeyIdx].CipherAlg = CipherAlg;
4251 #endif // WPA_SUPPLICANT_SUPPORT //
4252 pAdapter->StaCfg.DefaultKeyId = (UCHAR) KeyIdx;
4255 #ifdef WPA_SUPPLICANT_SUPPORT
4256 if (pAdapter->StaCfg.PortSecured == WPA_802_1X_PORT_SECURED)
4257 #endif // WPA_SUPPLICANT_SUPPORT
4259 Key = pAdapter->SharedKey[BSS0][KeyIdx].Key;
4261 // Set key material and cipherAlg to Asic
4262 AsicAddSharedKeyEntry(pAdapter, BSS0, KeyIdx, CipherAlg, Key, NULL, NULL);
4264 if (pWepKey->KeyIndex & 0x80000000)
4266 PMAC_TABLE_ENTRY pEntry = &pAdapter->MacTab.Content[BSSID_WCID];
4267 // Assign group key info
4268 RTMPAddWcidAttributeEntry(pAdapter, BSS0, KeyIdx, CipherAlg, NULL);
4269 // Assign pairwise key info
4270 RTMPAddWcidAttributeEntry(pAdapter, BSS0, KeyIdx, CipherAlg, pEntry);
4273 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"));
4278 #ifdef WPA_SUPPLICANT_SUPPORT
4279 case OID_SET_COUNTERMEASURES:
4280 if (wrq->u.data.length != sizeof(int))
4285 Status = copy_from_user(&enabled, wrq->u.data.pointer, wrq->u.data.length);
4287 pAdapter->StaCfg.bBlockAssoc = TRUE;
4289 // WPA MIC error should block association attempt for 60 seconds
4290 pAdapter->StaCfg.bBlockAssoc = FALSE;
4291 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_SET_COUNTERMEASURES bBlockAssoc=%s\n", pAdapter->StaCfg.bBlockAssoc ? "TRUE":"FALSE"));
4294 case RT_OID_WPA_SUPPLICANT_SUPPORT:
4295 if (wrq->u.data.length != sizeof(UCHAR))
4299 Status = copy_from_user(&wpa_supplicant_enable, wrq->u.data.pointer, wrq->u.data.length);
4300 pAdapter->StaCfg.WpaSupplicantUP = wpa_supplicant_enable;
4301 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_WPA_SUPPLICANT_SUPPORT (=%d)\n", pAdapter->StaCfg.WpaSupplicantUP));
4304 case OID_802_11_DEAUTHENTICATION:
4305 if (wrq->u.data.length != sizeof(MLME_DEAUTH_REQ_STRUCT))
4309 MLME_DEAUTH_REQ_STRUCT *pInfo;
4310 MLME_QUEUE_ELEM *MsgElem = (MLME_QUEUE_ELEM *) kmalloc(sizeof(MLME_QUEUE_ELEM), MEM_ALLOC_FLAG);
4312 pInfo = (MLME_DEAUTH_REQ_STRUCT *) MsgElem->Msg;
4313 Status = copy_from_user(pInfo, wrq->u.data.pointer, wrq->u.data.length);
4314 MlmeDeauthReqAction(pAdapter, MsgElem);
4317 if (INFRA_ON(pAdapter))
4319 LinkDown(pAdapter, FALSE);
4320 pAdapter->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
4322 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_DEAUTHENTICATION (Reason=%d)\n", pInfo->Reason));
4325 case OID_802_11_DROP_UNENCRYPTED:
4326 if (wrq->u.data.length != sizeof(int))
4331 Status = copy_from_user(&enabled, wrq->u.data.pointer, wrq->u.data.length);
4333 pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED;
4335 pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
4336 NdisAcquireSpinLock(&pAdapter->MacTabLock);
4337 pAdapter->MacTab.Content[BSSID_WCID].PortSecured = pAdapter->StaCfg.PortSecured;
4338 NdisReleaseSpinLock(&pAdapter->MacTabLock);
4339 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_DROP_UNENCRYPTED (=%d)\n", enabled));
4342 case OID_802_11_SET_IEEE8021X:
4343 if (wrq->u.data.length != sizeof(BOOLEAN))
4347 Status = copy_from_user(&IEEE8021xState, wrq->u.data.pointer, wrq->u.data.length);
4348 pAdapter->StaCfg.IEEE8021X = IEEE8021xState;
4349 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_SET_IEEE8021X (=%d)\n", IEEE8021xState));
4352 case OID_802_11_SET_IEEE8021X_REQUIRE_KEY:
4353 if (wrq->u.data.length != sizeof(BOOLEAN))
4357 Status = copy_from_user(&IEEE8021x_required_keys, wrq->u.data.pointer, wrq->u.data.length);
4358 pAdapter->StaCfg.IEEE8021x_required_keys = IEEE8021x_required_keys;
4359 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_SET_IEEE8021X_REQUIRE_KEY (%d)\n", IEEE8021x_required_keys));
4362 case OID_802_11_PMKID:
4363 pPmkId = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
4365 if(pPmkId == NULL) {
4369 Status = copy_from_user(pPmkId, wrq->u.data.pointer, wrq->u.data.length);
4371 // check the PMKID information
4372 if (pPmkId->BSSIDInfoCount == 0)
4373 NdisZeroMemory(pAdapter->StaCfg.SavedPMK, sizeof(BSSID_INFO)*PMKID_NO);
4376 PBSSID_INFO pBssIdInfo;
4380 for (BssIdx = 0; BssIdx < pPmkId->BSSIDInfoCount; BssIdx++)
4382 // point to the indexed BSSID_INFO structure
4383 pBssIdInfo = (PBSSID_INFO) ((PUCHAR) pPmkId + 2 * sizeof(UINT) + BssIdx * sizeof(BSSID_INFO));
4384 // Find the entry in the saved data base.
4385 for (CachedIdx = 0; CachedIdx < pAdapter->StaCfg.SavedPMKNum; CachedIdx++)
4387 // compare the BSSID
4388 if (NdisEqualMemory(pBssIdInfo->BSSID, pAdapter->StaCfg.SavedPMK[CachedIdx].BSSID, sizeof(NDIS_802_11_MAC_ADDRESS)))
4392 // Found, replace it
4393 if (CachedIdx < PMKID_NO)
4395 DBGPRINT(RT_DEBUG_OFF, ("Update OID_802_11_PMKID, idx = %d\n", CachedIdx));
4396 NdisMoveMemory(&pAdapter->StaCfg.SavedPMK[CachedIdx], pBssIdInfo, sizeof(BSSID_INFO));
4397 pAdapter->StaCfg.SavedPMKNum++;
4399 // Not found, replace the last one
4402 // Randomly replace one
4403 CachedIdx = (pBssIdInfo->BSSID[5] % PMKID_NO);
4404 DBGPRINT(RT_DEBUG_OFF, ("Update OID_802_11_PMKID, idx = %d\n", CachedIdx));
4405 NdisMoveMemory(&pAdapter->StaCfg.SavedPMK[CachedIdx], pBssIdInfo, sizeof(BSSID_INFO));
4412 #endif // WPA_SUPPLICANT_SUPPORT //
4417 case OID_802_11_SHORTRETRYLIMIT:
4418 if (wrq->u.data.length != sizeof(ULONG))
4422 Status = copy_from_user(&ShortRetryLimit, wrq->u.data.pointer, wrq->u.data.length);
4423 RTMP_IO_READ32(pAdapter, TX_RTY_CFG, &tx_rty_cfg.word);
4424 tx_rty_cfg.field.ShortRtyLimit = ShortRetryLimit;
4425 RTMP_IO_WRITE32(pAdapter, TX_RTY_CFG, tx_rty_cfg.word);
4426 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_SHORTRETRYLIMIT (tx_rty_cfg.field.ShortRetryLimit=%d, ShortRetryLimit=%ld)\n", tx_rty_cfg.field.ShortRtyLimit, ShortRetryLimit));
4430 case OID_802_11_LONGRETRYLIMIT:
4431 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_LONGRETRYLIMIT \n"));
4432 if (wrq->u.data.length != sizeof(ULONG))
4436 Status = copy_from_user(&LongRetryLimit, wrq->u.data.pointer, wrq->u.data.length);
4437 RTMP_IO_READ32(pAdapter, TX_RTY_CFG, &tx_rty_cfg.word);
4438 tx_rty_cfg.field.LongRtyLimit = LongRetryLimit;
4439 RTMP_IO_WRITE32(pAdapter, TX_RTY_CFG, tx_rty_cfg.word);
4440 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_LONGRETRYLIMIT (tx_rty_cfg.field.LongRetryLimit= %d,LongRetryLimit=%ld)\n", tx_rty_cfg.field.LongRtyLimit, LongRetryLimit));
4444 case OID_802_11_WEPDEFAULTKEYVALUE:
4445 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_WEPDEFAULTKEYVALUE\n"));
4446 pKey = kmalloc(wrq->u.data.length, GFP_KERNEL);
4447 Status = copy_from_user(pKey, wrq->u.data.pointer, wrq->u.data.length);
4450 if ( pKey->Length != wrq->u.data.length)
4453 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_WEPDEFAULTKEYVALUE, Failed!!\n"));
4455 KeyIdx = pKey->KeyIndex & 0x0fffffff;
4456 DBGPRINT(RT_DEBUG_TRACE,("pKey->KeyIndex =%d, pKey->KeyLength=%d\n", pKey->KeyIndex, pKey->KeyLength));
4458 // it is a shared key
4463 pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].KeyLen = (UCHAR) pKey->KeyLength;
4464 NdisMoveMemory(&pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].Key, &pKey->KeyMaterial, pKey->KeyLength);
4465 if (pKey->KeyIndex & 0x80000000)
4467 // Default key for tx (shared key)
4468 pAdapter->StaCfg.DefaultKeyId = (UCHAR) KeyIdx;
4470 //RestartAPIsRequired = TRUE;
4475 case OID_802_11_WEPDEFAULTKEYID:
4476 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_WEPDEFAULTKEYID \n"));
4478 if (wrq->u.data.length != sizeof(UCHAR))
4481 Status = copy_from_user(&pAdapter->StaCfg.DefaultKeyId, wrq->u.data.pointer, wrq->u.data.length);
4486 case OID_802_11_CURRENTCHANNEL:
4487 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_CURRENTCHANNEL \n"));
4488 if (wrq->u.data.length != sizeof(UCHAR))
4492 Status = copy_from_user(&ctmp, wrq->u.data.pointer, wrq->u.data.length);
4493 sprintf(&ctmp,"%d", ctmp);
4494 Set_Channel_Proc(pAdapter, &ctmp);
4502 DBGPRINT(RT_DEBUG_TRACE, ("Set::unknown IOCTL's subcmd = 0x%08x\n", cmd));
4503 Status = -EOPNOTSUPP;
4511 INT RTMPQueryInformation(
4512 IN PRTMP_ADAPTER pAdapter,
4513 IN OUT struct ifreq *rq,
4516 struct iwreq *wrq = (struct iwreq *) rq;
4517 NDIS_802_11_BSSID_LIST_EX *pBssidList = NULL;
4518 PNDIS_WLAN_BSSID_EX pBss;
4519 NDIS_802_11_SSID Ssid;
4520 NDIS_802_11_CONFIGURATION *pConfiguration = NULL;
4521 RT_802_11_LINK_STATUS *pLinkStatus = NULL;
4522 RT_802_11_STA_CONFIG *pStaConfig = NULL;
4523 NDIS_802_11_STATISTICS *pStatistics = NULL;
4524 NDIS_802_11_RTS_THRESHOLD RtsThresh;
4525 NDIS_802_11_FRAGMENTATION_THRESHOLD FragThresh;
4526 NDIS_802_11_POWER_MODE PowerMode;
4527 NDIS_802_11_NETWORK_INFRASTRUCTURE BssType;
4528 RT_802_11_PREAMBLE PreamType;
4529 NDIS_802_11_AUTHENTICATION_MODE AuthMode;
4530 NDIS_802_11_WEP_STATUS WepStatus;
4531 NDIS_MEDIA_STATE MediaState;
4532 ULONG BssBufSize, ulInfo=0, NetworkTypeList[4], apsd = 0;
4534 PUCHAR pBuf = NULL, pPtr;
4535 INT Status = NDIS_STATUS_SUCCESS;
4536 UINT we_version_compiled;
4537 UCHAR i, Padding = 0;
4539 UCHAR driverVersion[8];
4540 OID_SET_HT_PHYMODE *pHTPhyMode = NULL;
4545 DefaultKeyIdxValue *pKeyIdxValue;
4547 TX_RTY_CFG_STRUC tx_rty_cfg;
4548 ULONG ShortRetryLimit, LongRetryLimit;
4554 case RT_OID_DEVICE_NAME:
4555 wrq->u.data.length = sizeof(STA_NIC_DEVICE_NAME);
4556 Status = copy_to_user(wrq->u.data.pointer, STA_NIC_DEVICE_NAME, wrq->u.data.length);
4558 case RT_OID_VERSION_INFO:
4559 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_VERSION_INFO \n"));
4560 wrq->u.data.length = 8*sizeof(UCHAR);
4561 sprintf(&driverVersion[0], "%s", STA_DRIVER_VERSION);
4562 driverVersion[7] = '\0';
4563 if (copy_to_user(wrq->u.data.pointer, &driverVersion, wrq->u.data.length))
4569 case RT_QUERY_ATE_TXDONE_COUNT:
4570 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_QUERY_ATE_TXDONE_COUNT \n"));
4571 wrq->u.data.length = sizeof(UINT32);
4572 if (copy_to_user(wrq->u.data.pointer, &pAdapter->ate.TxDoneCount, wrq->u.data.length))
4577 #endif // RALINK_ATE //
4578 case OID_802_11_BSSID_LIST:
4579 if (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
4582 * Still scanning, indicate the caller should try again.
4584 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_BSSID_LIST (Still scanning)\n"));
4587 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_BSSID_LIST (%d BSS returned)\n",pAdapter->ScanTab.BssNr));
4588 pAdapter->StaCfg.bScanReqIsFromWebUI = FALSE;
4589 // Claculate total buffer size required
4590 BssBufSize = sizeof(ULONG);
4592 for (i = 0; i < pAdapter->ScanTab.BssNr; i++)
4594 // Align pointer to 4 bytes boundary.
4595 //Padding = 4 - (pAdapter->ScanTab.BssEntry[i].VarIELen & 0x0003);
4598 BssBufSize += (sizeof(NDIS_WLAN_BSSID_EX) - 1 + sizeof(NDIS_802_11_FIXED_IEs) + pAdapter->ScanTab.BssEntry[i].VarIELen + Padding);
4601 // For safety issue, we add 256 bytes just in case
4603 // Allocate the same size as passed from higher layer
4604 pBuf = kmalloc(BssBufSize, MEM_ALLOC_FLAG);
4610 // Init 802_11_BSSID_LIST_EX structure
4611 NdisZeroMemory(pBuf, BssBufSize);
4612 pBssidList = (PNDIS_802_11_BSSID_LIST_EX) pBuf;
4613 pBssidList->NumberOfItems = pAdapter->ScanTab.BssNr;
4615 // Calculate total buffer length
4616 BssLen = 4; // Consist of NumberOfItems
4617 // Point to start of NDIS_WLAN_BSSID_EX
4618 // pPtr = pBuf + sizeof(ULONG);
4619 pPtr = (PUCHAR) &pBssidList->Bssid[0];
4620 for (i = 0; i < pAdapter->ScanTab.BssNr; i++)
4622 pBss = (PNDIS_WLAN_BSSID_EX) pPtr;
4623 NdisMoveMemory(&pBss->MacAddress, &pAdapter->ScanTab.BssEntry[i].Bssid, MAC_ADDR_LEN);
4624 if ((pAdapter->ScanTab.BssEntry[i].Hidden == 1) && (pAdapter->StaCfg.bShowHiddenSSID == FALSE))
4627 // We must return this SSID during 4way handshaking, otherwise Aegis will failed to parse WPA infomation
4628 // and then failed to send EAPOl farame.
4630 if ((pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA) && (pAdapter->StaCfg.PortSecured != WPA_802_1X_PORT_SECURED))
4632 pBss->Ssid.SsidLength = pAdapter->ScanTab.BssEntry[i].SsidLen;
4633 NdisMoveMemory(pBss->Ssid.Ssid, pAdapter->ScanTab.BssEntry[i].Ssid, pAdapter->ScanTab.BssEntry[i].SsidLen);
4636 pBss->Ssid.SsidLength = 0;
4640 pBss->Ssid.SsidLength = pAdapter->ScanTab.BssEntry[i].SsidLen;
4641 NdisMoveMemory(pBss->Ssid.Ssid, pAdapter->ScanTab.BssEntry[i].Ssid, pAdapter->ScanTab.BssEntry[i].SsidLen);
4643 pBss->Privacy = pAdapter->ScanTab.BssEntry[i].Privacy;
4644 pBss->Rssi = pAdapter->ScanTab.BssEntry[i].Rssi - pAdapter->BbpRssiToDbmDelta;
4645 pBss->NetworkTypeInUse = NetworkTypeInUseSanity(&pAdapter->ScanTab.BssEntry[i]);
4646 pBss->Configuration.Length = sizeof(NDIS_802_11_CONFIGURATION);
4647 pBss->Configuration.BeaconPeriod = pAdapter->ScanTab.BssEntry[i].BeaconPeriod;
4648 pBss->Configuration.ATIMWindow = pAdapter->ScanTab.BssEntry[i].AtimWin;
4650 MAP_CHANNEL_ID_TO_KHZ(pAdapter->ScanTab.BssEntry[i].Channel, pBss->Configuration.DSConfig);
4652 if (pAdapter->ScanTab.BssEntry[i].BssType == BSS_INFRA)
4653 pBss->InfrastructureMode = Ndis802_11Infrastructure;
4655 pBss->InfrastructureMode = Ndis802_11IBSS;
4657 NdisMoveMemory(pBss->SupportedRates, pAdapter->ScanTab.BssEntry[i].SupRate, pAdapter->ScanTab.BssEntry[i].SupRateLen);
4658 NdisMoveMemory(pBss->SupportedRates + pAdapter->ScanTab.BssEntry[i].SupRateLen,
4659 pAdapter->ScanTab.BssEntry[i].ExtRate,
4660 pAdapter->ScanTab.BssEntry[i].ExtRateLen);
4662 if (pAdapter->ScanTab.BssEntry[i].VarIELen == 0)
4664 pBss->IELength = sizeof(NDIS_802_11_FIXED_IEs);
4665 NdisMoveMemory(pBss->IEs, &pAdapter->ScanTab.BssEntry[i].FixIEs, sizeof(NDIS_802_11_FIXED_IEs));
4666 pPtr = pPtr + sizeof(NDIS_WLAN_BSSID_EX) - 1 + sizeof(NDIS_802_11_FIXED_IEs);
4670 pBss->IELength = (ULONG)(sizeof(NDIS_802_11_FIXED_IEs) + pAdapter->ScanTab.BssEntry[i].VarIELen);
4671 pPtr = pPtr + sizeof(NDIS_WLAN_BSSID_EX) - 1 + sizeof(NDIS_802_11_FIXED_IEs);
4672 NdisMoveMemory(pBss->IEs, &pAdapter->ScanTab.BssEntry[i].FixIEs, sizeof(NDIS_802_11_FIXED_IEs));
4673 NdisMoveMemory(pBss->IEs + sizeof(NDIS_802_11_FIXED_IEs), pAdapter->ScanTab.BssEntry[i].VarIEs, pAdapter->ScanTab.BssEntry[i].VarIELen);
4674 pPtr += pAdapter->ScanTab.BssEntry[i].VarIELen;
4676 pBss->Length = (ULONG)(sizeof(NDIS_WLAN_BSSID_EX) - 1 + sizeof(NDIS_802_11_FIXED_IEs) + pAdapter->ScanTab.BssEntry[i].VarIELen + Padding);
4678 #if WIRELESS_EXT < 17
4679 if ((BssLen + pBss->Length) < wrq->u.data.length)
4680 BssLen += pBss->Length;
4683 pBssidList->NumberOfItems = i;
4687 BssLen += pBss->Length;
4691 #if WIRELESS_EXT < 17
4692 wrq->u.data.length = BssLen;
4694 if (BssLen > wrq->u.data.length)
4700 wrq->u.data.length = BssLen;
4702 Status = copy_to_user(wrq->u.data.pointer, pBssidList, BssLen);
4705 case OID_802_3_CURRENT_ADDRESS:
4706 wrq->u.data.length = MAC_ADDR_LEN;
4707 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CurrentAddress, wrq->u.data.length);
4709 case OID_GEN_MEDIA_CONNECT_STATUS:
4710 if (pAdapter->IndicateMediaState == NdisMediaStateConnected)
4711 MediaState = NdisMediaStateConnected;
4713 MediaState = NdisMediaStateDisconnected;
4715 wrq->u.data.length = sizeof(NDIS_MEDIA_STATE);
4716 Status = copy_to_user(wrq->u.data.pointer, &MediaState, wrq->u.data.length);
4718 case OID_802_11_BSSID:
4720 if (ATE_ON(pAdapter))
4722 DBGPRINT(RT_DEBUG_TRACE, ("The driver is in ATE mode now\n"));
4723 Status = NDIS_STATUS_RESOURCES;
4726 #endif // RALINK_ATE //
4727 if (INFRA_ON(pAdapter) || ADHOC_ON(pAdapter))
4729 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.Bssid, sizeof(NDIS_802_11_MAC_ADDRESS));
4734 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_BSSID(=EMPTY)\n"));
4738 case OID_802_11_SSID:
4739 NdisZeroMemory(&Ssid, sizeof(NDIS_802_11_SSID));
4740 NdisZeroMemory(Ssid.Ssid, MAX_LEN_OF_SSID);
4741 Ssid.SsidLength = pAdapter->CommonCfg.SsidLen;
4742 memcpy(Ssid.Ssid, pAdapter->CommonCfg.Ssid, Ssid.SsidLength);
4743 wrq->u.data.length = sizeof(NDIS_802_11_SSID);
4744 Status = copy_to_user(wrq->u.data.pointer, &Ssid, wrq->u.data.length);
4745 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_SSID (Len=%d, ssid=%s)\n", Ssid.SsidLength,Ssid.Ssid));
4747 case RT_OID_802_11_QUERY_LINK_STATUS:
4748 pLinkStatus = (RT_802_11_LINK_STATUS *) kmalloc(sizeof(RT_802_11_LINK_STATUS), MEM_ALLOC_FLAG);
4751 pLinkStatus->CurrTxRate = RateIdTo500Kbps[pAdapter->CommonCfg.TxRate]; // unit : 500 kbps
4752 pLinkStatus->ChannelQuality = pAdapter->Mlme.ChannelQuality;
4753 pLinkStatus->RxByteCount = pAdapter->RalinkCounters.ReceivedByteCount;
4754 pLinkStatus->TxByteCount = pAdapter->RalinkCounters.TransmittedByteCount;
4755 pLinkStatus->CentralChannel = pAdapter->CommonCfg.CentralChannel;
4756 wrq->u.data.length = sizeof(RT_802_11_LINK_STATUS);
4757 Status = copy_to_user(wrq->u.data.pointer, pLinkStatus, wrq->u.data.length);
4759 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_LINK_STATUS\n"));
4763 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_LINK_STATUS(kmalloc failed)\n"));
4767 case OID_802_11_CONFIGURATION:
4768 pConfiguration = (NDIS_802_11_CONFIGURATION *) kmalloc(sizeof(NDIS_802_11_CONFIGURATION), MEM_ALLOC_FLAG);
4771 pConfiguration->Length = sizeof(NDIS_802_11_CONFIGURATION);
4772 pConfiguration->BeaconPeriod = pAdapter->CommonCfg.BeaconPeriod;
4773 pConfiguration->ATIMWindow = pAdapter->StaActive.AtimWin;
4774 MAP_CHANNEL_ID_TO_KHZ(pAdapter->CommonCfg.Channel, pConfiguration->DSConfig);
4775 wrq->u.data.length = sizeof(NDIS_802_11_CONFIGURATION);
4776 Status = copy_to_user(wrq->u.data.pointer, pConfiguration, wrq->u.data.length);
4777 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_CONFIGURATION(BeaconPeriod=%ld,AtimW=%ld,Channel=%d) \n",
4778 pConfiguration->BeaconPeriod, pConfiguration->ATIMWindow, pAdapter->CommonCfg.Channel));
4779 kfree(pConfiguration);
4783 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_CONFIGURATION(kmalloc failed)\n"));
4787 case RT_OID_802_11_SNR_0:
4788 if ((pAdapter->StaCfg.LastSNR0 > 0))
4790 ulInfo = ((0xeb - pAdapter->StaCfg.LastSNR0) * 3) / 16 ;
4791 wrq->u.data.length = sizeof(ulInfo);
4792 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4793 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_SNR_0(0x=%lx)\n", ulInfo));
4798 case RT_OID_802_11_SNR_1:
4799 if ((pAdapter->Antenna.field.RxPath > 1) &&
4800 (pAdapter->StaCfg.LastSNR1 > 0))
4802 ulInfo = ((0xeb - pAdapter->StaCfg.LastSNR1) * 3) / 16 ;
4803 wrq->u.data.length = sizeof(ulInfo);
4804 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4805 DBGPRINT(RT_DEBUG_TRACE,("Query::RT_OID_802_11_SNR_1(0x=%lx)\n",ulInfo));
4809 DBGPRINT(RT_DEBUG_TRACE,("Query::RT_OID_802_11_SNR_1(pAdapter->StaCfg.LastSNR1=%d)\n",pAdapter->StaCfg.LastSNR1));
4811 case OID_802_11_RSSI_TRIGGER:
4812 ulInfo = pAdapter->StaCfg.RssiSample.LastRssi0 - pAdapter->BbpRssiToDbmDelta;
4813 wrq->u.data.length = sizeof(ulInfo);
4814 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4815 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_RSSI_TRIGGER(=%ld)\n", ulInfo));
4817 case OID_802_11_RSSI:
4818 case RT_OID_802_11_RSSI:
4819 ulInfo = pAdapter->StaCfg.RssiSample.LastRssi0;
4820 wrq->u.data.length = sizeof(ulInfo);
4821 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4823 case RT_OID_802_11_RSSI_1:
4824 ulInfo = pAdapter->StaCfg.RssiSample.LastRssi1;
4825 wrq->u.data.length = sizeof(ulInfo);
4826 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4828 case RT_OID_802_11_RSSI_2:
4829 ulInfo = pAdapter->StaCfg.RssiSample.LastRssi2;
4830 wrq->u.data.length = sizeof(ulInfo);
4831 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4833 case OID_802_11_STATISTICS:
4834 pStatistics = (NDIS_802_11_STATISTICS *) kmalloc(sizeof(NDIS_802_11_STATISTICS), MEM_ALLOC_FLAG);
4837 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_STATISTICS \n"));
4838 // add the most up-to-date h/w raw counters into software counters
4839 NICUpdateRawCounters(pAdapter);
4841 // Sanity check for calculation of sucessful count
4842 if (pAdapter->WlanCounters.TransmittedFragmentCount.QuadPart < pAdapter->WlanCounters.RetryCount.QuadPart)
4843 pAdapter->WlanCounters.TransmittedFragmentCount.QuadPart = pAdapter->WlanCounters.RetryCount.QuadPart;
4845 pStatistics->TransmittedFragmentCount.QuadPart = pAdapter->WlanCounters.TransmittedFragmentCount.QuadPart;
4846 pStatistics->MulticastTransmittedFrameCount.QuadPart = pAdapter->WlanCounters.MulticastTransmittedFrameCount.QuadPart;
4847 pStatistics->FailedCount.QuadPart = pAdapter->WlanCounters.FailedCount.QuadPart;
4848 pStatistics->RetryCount.QuadPart = pAdapter->WlanCounters.RetryCount.QuadPart;
4849 pStatistics->MultipleRetryCount.QuadPart = pAdapter->WlanCounters.MultipleRetryCount.QuadPart;
4850 pStatistics->RTSSuccessCount.QuadPart = pAdapter->WlanCounters.RTSSuccessCount.QuadPart;
4851 pStatistics->RTSFailureCount.QuadPart = pAdapter->WlanCounters.RTSFailureCount.QuadPart;
4852 pStatistics->ACKFailureCount.QuadPart = pAdapter->WlanCounters.ACKFailureCount.QuadPart;
4853 pStatistics->FrameDuplicateCount.QuadPart = pAdapter->WlanCounters.FrameDuplicateCount.QuadPart;
4854 pStatistics->ReceivedFragmentCount.QuadPart = pAdapter->WlanCounters.ReceivedFragmentCount.QuadPart;
4855 pStatistics->MulticastReceivedFrameCount.QuadPart = pAdapter->WlanCounters.MulticastReceivedFrameCount.QuadPart;
4857 pStatistics->FCSErrorCount = pAdapter->RalinkCounters.RealFcsErrCount;
4859 pStatistics->FCSErrorCount.QuadPart = pAdapter->WlanCounters.FCSErrorCount.QuadPart;
4860 pStatistics->FrameDuplicateCount.u.LowPart = pAdapter->WlanCounters.FrameDuplicateCount.u.LowPart / 100;
4862 wrq->u.data.length = sizeof(NDIS_802_11_STATISTICS);
4863 Status = copy_to_user(wrq->u.data.pointer, pStatistics, wrq->u.data.length);
4868 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_STATISTICS(kmalloc failed)\n"));
4872 case OID_GEN_RCV_OK:
4873 ulInfo = pAdapter->Counters8023.GoodReceives;
4874 wrq->u.data.length = sizeof(ulInfo);
4875 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4877 case OID_GEN_RCV_NO_BUFFER:
4878 ulInfo = pAdapter->Counters8023.RxNoBuffer;
4879 wrq->u.data.length = sizeof(ulInfo);
4880 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4882 case RT_OID_802_11_PHY_MODE:
4883 ulInfo = (ULONG)pAdapter->CommonCfg.PhyMode;
4884 wrq->u.data.length = sizeof(ulInfo);
4885 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4886 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_PHY_MODE (=%ld)\n", ulInfo));
4888 case RT_OID_802_11_STA_CONFIG:
4889 pStaConfig = (RT_802_11_STA_CONFIG *) kmalloc(sizeof(RT_802_11_STA_CONFIG), MEM_ALLOC_FLAG);
4892 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_STA_CONFIG\n"));
4893 pStaConfig->EnableTxBurst = pAdapter->CommonCfg.bEnableTxBurst;
4894 pStaConfig->EnableTurboRate = 0;
4895 pStaConfig->UseBGProtection = pAdapter->CommonCfg.UseBGProtection;
4896 pStaConfig->UseShortSlotTime = pAdapter->CommonCfg.bUseShortSlotTime;
4897 //pStaConfig->AdhocMode = pAdapter->StaCfg.AdhocMode;
4898 pStaConfig->HwRadioStatus = (pAdapter->StaCfg.bHwRadio == TRUE) ? 1 : 0;
4899 pStaConfig->Rsv1 = 0;
4900 pStaConfig->SystemErrorBitmap = pAdapter->SystemErrorBitmap;
4901 wrq->u.data.length = sizeof(RT_802_11_STA_CONFIG);
4902 Status = copy_to_user(wrq->u.data.pointer, pStaConfig, wrq->u.data.length);
4907 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_STA_CONFIG(kmalloc failed)\n"));
4911 case OID_802_11_RTS_THRESHOLD:
4912 RtsThresh = pAdapter->CommonCfg.RtsThreshold;
4913 wrq->u.data.length = sizeof(RtsThresh);
4914 Status = copy_to_user(wrq->u.data.pointer, &RtsThresh, wrq->u.data.length);
4915 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_RTS_THRESHOLD(=%ld)\n", RtsThresh));
4917 case OID_802_11_FRAGMENTATION_THRESHOLD:
4918 FragThresh = pAdapter->CommonCfg.FragmentThreshold;
4919 if (pAdapter->CommonCfg.bUseZeroToDisableFragment == TRUE)
4921 wrq->u.data.length = sizeof(FragThresh);
4922 Status = copy_to_user(wrq->u.data.pointer, &FragThresh, wrq->u.data.length);
4923 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_FRAGMENTATION_THRESHOLD(=%ld)\n", FragThresh));
4925 case OID_802_11_POWER_MODE:
4926 PowerMode = pAdapter->StaCfg.WindowsPowerMode;
4927 wrq->u.data.length = sizeof(PowerMode);
4928 Status = copy_to_user(wrq->u.data.pointer, &PowerMode, wrq->u.data.length);
4929 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_POWER_MODE(=%d)\n", PowerMode));
4931 case RT_OID_802_11_RADIO:
4932 RadioState = (BOOLEAN) pAdapter->StaCfg.bSwRadio;
4933 wrq->u.data.length = sizeof(RadioState);
4934 Status = copy_to_user(wrq->u.data.pointer, &RadioState, wrq->u.data.length);
4935 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_RADIO (=%d)\n", RadioState));
4937 case OID_802_11_INFRASTRUCTURE_MODE:
4938 if (pAdapter->StaCfg.BssType == BSS_ADHOC)
4939 BssType = Ndis802_11IBSS;
4940 else if (pAdapter->StaCfg.BssType == BSS_INFRA)
4941 BssType = Ndis802_11Infrastructure;
4942 else if (pAdapter->StaCfg.BssType == BSS_MONITOR)
4943 BssType = Ndis802_11Monitor;
4945 BssType = Ndis802_11AutoUnknown;
4947 wrq->u.data.length = sizeof(BssType);
4948 Status = copy_to_user(wrq->u.data.pointer, &BssType, wrq->u.data.length);
4949 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_INFRASTRUCTURE_MODE(=%d)\n", BssType));
4951 case RT_OID_802_11_PREAMBLE:
4952 PreamType = pAdapter->CommonCfg.TxPreamble;
4953 wrq->u.data.length = sizeof(PreamType);
4954 Status = copy_to_user(wrq->u.data.pointer, &PreamType, wrq->u.data.length);
4955 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_PREAMBLE(=%d)\n", PreamType));
4957 case OID_802_11_AUTHENTICATION_MODE:
4958 AuthMode = pAdapter->StaCfg.AuthMode;
4959 wrq->u.data.length = sizeof(AuthMode);
4960 Status = copy_to_user(wrq->u.data.pointer, &AuthMode, wrq->u.data.length);
4961 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_AUTHENTICATION_MODE(=%d)\n", AuthMode));
4963 case OID_802_11_WEP_STATUS:
4964 WepStatus = pAdapter->StaCfg.WepStatus;
4965 wrq->u.data.length = sizeof(WepStatus);
4966 Status = copy_to_user(wrq->u.data.pointer, &WepStatus, wrq->u.data.length);
4967 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_WEP_STATUS(=%d)\n", WepStatus));
4969 case OID_802_11_TX_POWER_LEVEL:
4970 wrq->u.data.length = sizeof(ULONG);
4971 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.TxPower, wrq->u.data.length);
4972 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_TX_POWER_LEVEL %x\n",pAdapter->CommonCfg.TxPower));
4974 case RT_OID_802_11_TX_POWER_LEVEL_1:
4975 wrq->u.data.length = sizeof(ULONG);
4976 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.TxPowerPercentage, wrq->u.data.length);
4977 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_TX_POWER_LEVEL_1 (=%ld)\n", pAdapter->CommonCfg.TxPowerPercentage));
4979 case OID_802_11_NETWORK_TYPES_SUPPORTED:
4980 if ((pAdapter->RfIcType == RFIC_2850) || (pAdapter->RfIcType == RFIC_2750))
4982 NetworkTypeList[0] = 3; // NumberOfItems = 3
4983 NetworkTypeList[1] = Ndis802_11DS; // NetworkType[1] = 11b
4984 NetworkTypeList[2] = Ndis802_11OFDM24; // NetworkType[2] = 11g
4985 NetworkTypeList[3] = Ndis802_11OFDM5; // NetworkType[3] = 11a
4986 wrq->u.data.length = 16;
4987 Status = copy_to_user(wrq->u.data.pointer, &NetworkTypeList[0], wrq->u.data.length);
4991 NetworkTypeList[0] = 2; // NumberOfItems = 2
4992 NetworkTypeList[1] = Ndis802_11DS; // NetworkType[1] = 11b
4993 NetworkTypeList[2] = Ndis802_11OFDM24; // NetworkType[2] = 11g
4994 wrq->u.data.length = 12;
4995 Status = copy_to_user(wrq->u.data.pointer, &NetworkTypeList[0], wrq->u.data.length);
4997 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_NETWORK_TYPES_SUPPORTED\n"));
4999 case OID_802_11_NETWORK_TYPE_IN_USE:
5000 wrq->u.data.length = sizeof(ULONG);
5001 if (pAdapter->CommonCfg.PhyMode == PHY_11A)
5002 ulInfo = Ndis802_11OFDM5;
5003 else if ((pAdapter->CommonCfg.PhyMode == PHY_11BG_MIXED) || (pAdapter->CommonCfg.PhyMode == PHY_11G))
5004 ulInfo = Ndis802_11OFDM24;
5006 ulInfo = Ndis802_11DS;
5007 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
5009 case RT_OID_802_11_QUERY_LAST_RX_RATE:
5010 ulInfo = (ULONG)pAdapter->LastRxRate;
5011 wrq->u.data.length = sizeof(ulInfo);
5012 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
5013 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_LAST_RX_RATE (=%ld)\n", ulInfo));
5015 case RT_OID_802_11_QUERY_LAST_TX_RATE:
5016 //ulInfo = (ULONG)pAdapter->LastTxRate;
5017 ulInfo = (ULONG)pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.word;
5018 wrq->u.data.length = sizeof(ulInfo);
5019 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
5020 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_LAST_TX_RATE (=%lx)\n", ulInfo));
5022 case RT_OID_802_11_QUERY_EEPROM_VERSION:
5023 wrq->u.data.length = sizeof(ULONG);
5024 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->EepromVersion, wrq->u.data.length);
5026 case RT_OID_802_11_QUERY_FIRMWARE_VERSION:
5027 wrq->u.data.length = sizeof(ULONG);
5028 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->FirmwareVersion, wrq->u.data.length);
5030 case RT_OID_802_11_QUERY_NOISE_LEVEL:
5031 wrq->u.data.length = sizeof(UCHAR);
5032 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->BbpWriteLatch[66], wrq->u.data.length);
5033 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_NOISE_LEVEL (=%d)\n", pAdapter->BbpWriteLatch[66]));
5035 case RT_OID_802_11_EXTRA_INFO:
5036 wrq->u.data.length = sizeof(ULONG);
5037 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->ExtraInfo, wrq->u.data.length);
5038 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_EXTRA_INFO (=%ld)\n", pAdapter->ExtraInfo));
5040 case RT_OID_WE_VERSION_COMPILED:
5041 wrq->u.data.length = sizeof(UINT);
5042 we_version_compiled = WIRELESS_EXT;
5043 Status = copy_to_user(wrq->u.data.pointer, &we_version_compiled, wrq->u.data.length);
5045 case RT_OID_802_11_QUERY_APSD_SETTING:
5046 apsd = (pAdapter->CommonCfg.bAPSDCapable | (pAdapter->CommonCfg.bAPSDAC_BE << 1) | (pAdapter->CommonCfg.bAPSDAC_BK << 2)
5047 | (pAdapter->CommonCfg.bAPSDAC_VI << 3) | (pAdapter->CommonCfg.bAPSDAC_VO << 4) | (pAdapter->CommonCfg.MaxSPLength << 5));
5049 wrq->u.data.length = sizeof(ULONG);
5050 Status = copy_to_user(wrq->u.data.pointer, &apsd, wrq->u.data.length);
5051 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",
5052 apsd,pAdapter->CommonCfg.bAPSDCapable,pAdapter->CommonCfg.bAPSDAC_BE,pAdapter->CommonCfg.bAPSDAC_BK,pAdapter->CommonCfg.bAPSDAC_VI,pAdapter->CommonCfg.bAPSDAC_VO,pAdapter->CommonCfg.MaxSPLength));
5054 case RT_OID_802_11_QUERY_APSD_PSM:
5055 wrq->u.data.length = sizeof(ULONG);
5056 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.bAPSDForcePowerSave, wrq->u.data.length);
5057 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_APSD_PSM (=%d)\n", pAdapter->CommonCfg.bAPSDForcePowerSave));
5059 case RT_OID_802_11_QUERY_WMM:
5060 wrq->u.data.length = sizeof(BOOLEAN);
5061 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.bWmmCapable, wrq->u.data.length);
5062 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_WMM (=%d)\n", pAdapter->CommonCfg.bWmmCapable));
5064 #ifdef WPA_SUPPLICANT_SUPPORT
5065 case RT_OID_NEW_DRIVER:
5068 wrq->u.data.length = sizeof(UCHAR);
5069 Status = copy_to_user(wrq->u.data.pointer, &enabled, wrq->u.data.length);
5070 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_NEW_DRIVER (=%d)\n", enabled));
5073 case RT_OID_WPA_SUPPLICANT_SUPPORT:
5074 wrq->u.data.length = sizeof(UCHAR);
5075 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->StaCfg.WpaSupplicantUP, wrq->u.data.length);
5076 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_WPA_SUPPLICANT_SUPPORT (=%d)\n", pAdapter->StaCfg.WpaSupplicantUP));
5078 #endif // WPA_SUPPLICANT_SUPPORT //
5080 case RT_OID_DRIVER_DEVICE_NAME:
5081 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_DRIVER_DEVICE_NAME \n"));
5082 wrq->u.data.length = 16;
5083 if (copy_to_user(wrq->u.data.pointer, pAdapter->StaCfg.dev_name, wrq->u.data.length))
5088 case RT_OID_802_11_QUERY_HT_PHYMODE:
5089 pHTPhyMode = (OID_SET_HT_PHYMODE *) kmalloc(sizeof(OID_SET_HT_PHYMODE), MEM_ALLOC_FLAG);
5092 pHTPhyMode->PhyMode = pAdapter->CommonCfg.PhyMode;
5093 pHTPhyMode->HtMode = (UCHAR)pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.field.MODE;
5094 pHTPhyMode->BW = (UCHAR)pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.field.BW;
5095 pHTPhyMode->MCS= (UCHAR)pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.field.MCS;
5096 pHTPhyMode->SHORTGI= (UCHAR)pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.field.ShortGI;
5097 pHTPhyMode->STBC= (UCHAR)pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.field.STBC;
5099 pHTPhyMode->ExtOffset = ((pAdapter->CommonCfg.CentralChannel < pAdapter->CommonCfg.Channel) ? (EXTCHA_BELOW) : (EXTCHA_ABOVE));
5100 wrq->u.data.length = sizeof(OID_SET_HT_PHYMODE);
5101 if (copy_to_user(wrq->u.data.pointer, pHTPhyMode, wrq->u.data.length))
5105 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_HT_PHYMODE (PhyMode = %d, MCS =%d, BW = %d, STBC = %d, ExtOffset=%d)\n",
5106 pHTPhyMode->HtMode, pHTPhyMode->MCS, pHTPhyMode->BW, pHTPhyMode->STBC, pHTPhyMode->ExtOffset));
5107 DBGPRINT(RT_DEBUG_TRACE, (" MlmeUpdateTxRates (.word = %x )\n", pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.word));
5111 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_STA_CONFIG(kmalloc failed)\n"));
5115 case RT_OID_802_11_COUNTRY_REGION:
5116 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_COUNTRY_REGION \n"));
5117 wrq->u.data.length = sizeof(ulInfo);
5118 ulInfo = pAdapter->CommonCfg.CountryRegionForABand;
5119 ulInfo = (ulInfo << 8)|(pAdapter->CommonCfg.CountryRegion);
5120 if (copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length))
5125 case RT_OID_802_11_QUERY_DAT_HT_PHYMODE:
5126 pHTPhyMode = (OID_SET_HT_PHYMODE *) kmalloc(sizeof(OID_SET_HT_PHYMODE), MEM_ALLOC_FLAG);
5129 pHTPhyMode->PhyMode = pAdapter->CommonCfg.PhyMode;
5130 pHTPhyMode->HtMode = (UCHAR)pAdapter->CommonCfg.RegTransmitSetting.field.HTMODE;
5131 pHTPhyMode->BW = (UCHAR)pAdapter->CommonCfg.RegTransmitSetting.field.BW;
5132 pHTPhyMode->MCS= (UCHAR)pAdapter->StaCfg.DesiredTransmitSetting.field.MCS;
5133 pHTPhyMode->SHORTGI= (UCHAR)pAdapter->CommonCfg.RegTransmitSetting.field.ShortGI;
5134 pHTPhyMode->STBC= (UCHAR)pAdapter->CommonCfg.RegTransmitSetting.field.STBC;
5136 wrq->u.data.length = sizeof(OID_SET_HT_PHYMODE);
5137 if (copy_to_user(wrq->u.data.pointer, pHTPhyMode, wrq->u.data.length))
5141 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_HT_PHYMODE (PhyMode = %d, MCS =%d, BW = %d, STBC = %d, ExtOffset=%d)\n",
5142 pHTPhyMode->HtMode, pHTPhyMode->MCS, pHTPhyMode->BW, pHTPhyMode->STBC, pHTPhyMode->ExtOffset));
5143 DBGPRINT(RT_DEBUG_TRACE, (" MlmeUpdateTxRates (.word = %x )\n", pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.word));
5147 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_STA_CONFIG(kmalloc failed)\n"));
5151 case RT_OID_QUERY_MULTIPLE_CARD_SUPPORT:
5152 wrq->u.data.length = sizeof(UCHAR);
5154 #ifdef MULTIPLE_CARD_SUPPORT
5156 #endif // MULTIPLE_CARD_SUPPORT //
5157 if (copy_to_user(wrq->u.data.pointer, &i, wrq->u.data.length))
5161 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_QUERY_MULTIPLE_CARD_SUPPORT(=%d) \n", i));
5164 case RT_OID_802_11_MAC_ADDRESS:
5165 wrq->u.data.length = MAC_ADDR_LEN;
5166 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CurrentAddress, wrq->u.data.length);
5169 case RT_OID_802_11_MANUFACTUREROUI:
5170 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_MANUFACTUREROUI \n"));
5171 wrq->u.data.length = ManufacturerOUI_LEN;
5172 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CurrentAddress, wrq->u.data.length);
5175 case RT_OID_802_11_MANUFACTURERNAME:
5176 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_MANUFACTURERNAME \n"));
5177 wrq->u.data.length = strlen(ManufacturerNAME);
5178 Status = copy_to_user(wrq->u.data.pointer, ManufacturerNAME, wrq->u.data.length);
5181 case RT_OID_802_11_RESOURCETYPEIDNAME:
5182 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_RESOURCETYPEIDNAME \n"));
5183 wrq->u.data.length = strlen(ResourceTypeIdName);
5184 Status = copy_to_user(wrq->u.data.pointer, ResourceTypeIdName, wrq->u.data.length);
5187 case RT_OID_802_11_PRIVACYOPTIONIMPLEMENTED:
5188 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_PRIVACYOPTIONIMPLEMENTED \n"));
5189 ulInfo = 1; // 1 is support wep else 2 is not support.
5190 wrq->u.data.length = sizeof(ulInfo);
5191 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
5194 case RT_OID_802_11_POWERMANAGEMENTMODE:
5195 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_POWERMANAGEMENTMODE \n"));
5196 if (pAdapter->StaCfg.Psm == PSMP_ACTION)
5197 ulInfo = 1; // 1 is power active else 2 is power save.
5201 wrq->u.data.length = sizeof(ulInfo);
5202 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
5205 case OID_802_11_WEPDEFAULTKEYVALUE:
5206 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_WEPDEFAULTKEYVALUE \n"));
5207 //KeyIdxValue.KeyIdx = pAd->PortCfg.MBSSID[pAd->IoctlIF].DefaultKeyId;
5208 pKeyIdxValue = wrq->u.data.pointer;
5209 DBGPRINT(RT_DEBUG_TRACE,("KeyIdxValue.KeyIdx = %d, \n",pKeyIdxValue->KeyIdx));
5210 valueLen = pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].KeyLen;
5211 NdisMoveMemory(pKeyIdxValue->Value,
5212 &pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].Key,
5214 pKeyIdxValue->Value[valueLen]='\0';
5216 wrq->u.data.length = sizeof(DefaultKeyIdxValue);
5218 Status = copy_to_user(wrq->u.data.pointer, pKeyIdxValue, wrq->u.data.length);
5219 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,
5220 pAdapter->SharedKey[BSS0][0].Key[0],
5221 pAdapter->SharedKey[BSS0][1].Key[0],
5222 pAdapter->SharedKey[BSS0][2].Key[0],
5223 pAdapter->SharedKey[BSS0][3].Key[0]));
5226 case OID_802_11_WEPDEFAULTKEYID:
5227 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_WEPDEFAULTKEYID \n"));
5228 wrq->u.data.length = sizeof(UCHAR);
5229 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->StaCfg.DefaultKeyId, wrq->u.data.length);
5230 DBGPRINT(RT_DEBUG_TRACE, ("DefaultKeyId =%d \n", pAdapter->StaCfg.DefaultKeyId));
5233 case RT_OID_802_11_WEPKEYMAPPINGLENGTH:
5234 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_WEPKEYMAPPINGLENGTH \n"));
5235 wrq->u.data.length = sizeof(UCHAR);
5236 Status = copy_to_user(wrq->u.data.pointer,
5237 &pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].KeyLen,
5238 wrq->u.data.length);
5241 case OID_802_11_SHORTRETRYLIMIT:
5242 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_SHORTRETRYLIMIT \n"));
5243 wrq->u.data.length = sizeof(ULONG);
5244 RTMP_IO_READ32(pAdapter, TX_RTY_CFG, &tx_rty_cfg.word);
5245 ShortRetryLimit = tx_rty_cfg.field.ShortRtyLimit;
5246 DBGPRINT(RT_DEBUG_TRACE, ("ShortRetryLimit =%ld, tx_rty_cfg.field.ShortRetryLimit=%d\n", ShortRetryLimit, tx_rty_cfg.field.ShortRtyLimit));
5247 Status = copy_to_user(wrq->u.data.pointer, &ShortRetryLimit, wrq->u.data.length);
5250 case OID_802_11_LONGRETRYLIMIT:
5251 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_LONGRETRYLIMIT \n"));
5252 wrq->u.data.length = sizeof(ULONG);
5253 RTMP_IO_READ32(pAdapter, TX_RTY_CFG, &tx_rty_cfg.word);
5254 LongRetryLimit = tx_rty_cfg.field.LongRtyLimit;
5255 DBGPRINT(RT_DEBUG_TRACE, ("LongRetryLimit =%ld, tx_rty_cfg.field.LongRtyLimit=%d\n", LongRetryLimit, tx_rty_cfg.field.LongRtyLimit));
5256 Status = copy_to_user(wrq->u.data.pointer, &LongRetryLimit, wrq->u.data.length);
5259 case RT_OID_802_11_PRODUCTID:
5260 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_PRODUCTID \n"));
5263 sprintf(tmp, "%04x %04x\n", ((POS_COOKIE)pAdapter->OS_Cookie)->pUsb_Dev->descriptor.idVendor ,((POS_COOKIE)pAdapter->OS_Cookie)->pUsb_Dev->descriptor.idProduct);
5266 wrq->u.data.length = strlen(tmp);
5267 Status = copy_to_user(wrq->u.data.pointer, tmp, wrq->u.data.length);
5270 case RT_OID_802_11_MANUFACTUREID:
5271 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_MANUFACTUREID \n"));
5272 wrq->u.data.length = strlen(ManufacturerNAME);
5273 Status = copy_to_user(wrq->u.data.pointer, ManufacturerNAME, wrq->u.data.length);
5276 case OID_802_11_CURRENTCHANNEL:
5277 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_CURRENTCHANNEL \n"));
5278 wrq->u.data.length = sizeof(UCHAR);
5279 DBGPRINT(RT_DEBUG_TRACE, ("sizeof UCHAR=%d, channel=%d \n", sizeof(UCHAR), pAdapter->CommonCfg.Channel));
5280 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.Channel, wrq->u.data.length);
5281 DBGPRINT(RT_DEBUG_TRACE, ("Status=%d\n", Status));
5283 #endif //SNMP_SUPPORT
5285 case OID_802_11_BUILD_CHANNEL_EX:
5288 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_BUILD_CHANNEL_EX \n"));
5289 wrq->u.data.length = sizeof(UCHAR);
5290 #ifdef EXT_BUILD_CHANNEL_LIST
5291 DBGPRINT(RT_DEBUG_TRACE, ("Support EXT_BUILD_CHANNEL_LIST.\n"));
5294 DBGPRINT(RT_DEBUG_TRACE, ("Doesn't support EXT_BUILD_CHANNEL_LIST.\n"));
5296 #endif // EXT_BUILD_CHANNEL_LIST //
5297 Status = copy_to_user(wrq->u.data.pointer, &value, 1);
5298 DBGPRINT(RT_DEBUG_TRACE, ("Status=%d\n", Status));
5302 case OID_802_11_GET_CH_LIST:
5304 PRT_CHANNEL_LIST_INFO pChListBuf;
5306 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_GET_CH_LIST \n"));
5307 if (pAdapter->ChannelListNum == 0)
5309 wrq->u.data.length = 0;
5313 pChListBuf = (RT_CHANNEL_LIST_INFO *) kmalloc(sizeof(RT_CHANNEL_LIST_INFO), MEM_ALLOC_FLAG);
5314 if (pChListBuf == NULL)
5316 wrq->u.data.length = 0;
5320 pChListBuf->ChannelListNum = pAdapter->ChannelListNum;
5321 for (i = 0; i < pChListBuf->ChannelListNum; i++)
5322 pChListBuf->ChannelList[i] = pAdapter->ChannelList[i].Channel;
5324 wrq->u.data.length = sizeof(RT_CHANNEL_LIST_INFO);
5325 Status = copy_to_user(wrq->u.data.pointer, pChListBuf, sizeof(RT_CHANNEL_LIST_INFO));
5326 DBGPRINT(RT_DEBUG_TRACE, ("Status=%d\n", Status));
5333 case OID_802_11_GET_COUNTRY_CODE:
5334 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_GET_COUNTRY_CODE \n"));
5335 wrq->u.data.length = 2;
5336 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.CountryCode, 2);
5337 DBGPRINT(RT_DEBUG_TRACE, ("Status=%d\n", Status));
5340 case OID_802_11_GET_CHANNEL_GEOGRAPHY:
5341 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_GET_CHANNEL_GEOGRAPHY \n"));
5342 wrq->u.data.length = 1;
5343 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.Geography, 1);
5344 DBGPRINT(RT_DEBUG_TRACE, ("Status=%d\n", Status));
5348 #ifdef QOS_DLS_SUPPORT
5349 case RT_OID_802_11_QUERY_DLS:
5350 wrq->u.data.length = sizeof(BOOLEAN);
5351 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.bDLSCapable, wrq->u.data.length);
5352 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_DLS(=%d)\n", pAdapter->CommonCfg.bDLSCapable));
5355 case RT_OID_802_11_QUERY_DLS_PARAM:
5357 PRT_802_11_DLS_INFO pDlsInfo = kmalloc(sizeof(RT_802_11_DLS_INFO), GFP_ATOMIC);
5358 if (pDlsInfo == NULL)
5361 for (i=0; i<MAX_NUM_OF_DLS_ENTRY; i++)
5363 RTMPMoveMemory(&pDlsInfo->Entry[i], &pAdapter->StaCfg.DLSEntry[i], sizeof(RT_802_11_DLS_UI));
5366 pDlsInfo->num = MAX_NUM_OF_DLS_ENTRY;
5367 wrq->u.data.length = sizeof(RT_802_11_DLS_INFO);
5368 Status = copy_to_user(wrq->u.data.pointer, pDlsInfo, wrq->u.data.length);
5369 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_DLS_PARAM\n"));
5375 #endif // QOS_DLS_SUPPORT //
5377 DBGPRINT(RT_DEBUG_TRACE, ("Query::unknown IOCTL's subcmd = 0x%08x\n", cmd));
5378 Status = -EOPNOTSUPP;
5384 INT rt28xx_sta_ioctl(
5385 IN struct net_device *net_dev,
5386 IN OUT struct ifreq *rq,
5390 VIRTUAL_ADAPTER *pVirtualAd = NULL;
5391 RTMP_ADAPTER *pAd = NULL;
5392 struct iwreq *wrq = (struct iwreq *) rq;
5393 BOOLEAN StateMachineTouched = FALSE;
5394 INT Status = NDIS_STATUS_SUCCESS;
5397 if (net_dev->priv_flags == INT_MAIN)
5399 pAd = net_dev->ml_priv;
5403 pVirtualAd = net_dev->ml_priv;
5404 pAd = pVirtualAd->RtmpDev->ml_priv;
5406 pObj = (POS_COOKIE) pAd->OS_Cookie;
5410 /* if 1st open fail, pAd will be free;
5411 So the net_dev->ml_priv will be NULL in 2rd open */
5415 //check if the interface is down
5416 if(!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_IN_USE))
5418 #ifdef CONFIG_APSTA_MIXED_SUPPORT
5419 if (wrq->u.data.pointer == NULL)
5424 if (strstr(wrq->u.data.pointer, "OpMode") == NULL)
5425 #endif // CONFIG_APSTA_MIXED_SUPPORT //
5427 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
5432 { // determine this ioctl command is comming from which interface.
5433 pObj->ioctl_if_type = INT_MAIN;
5434 pObj->ioctl_if = MAIN_MBSSID;
5440 #ifdef RALINK_28xx_QA
5441 case RTPRIV_IOCTL_ATE:
5443 RtmpDoAte(pAd, wrq);
5446 #endif // RALINK_28xx_QA //
5447 #endif // RALINK_ATE //
5449 DBGPRINT(RT_DEBUG_TRACE, ("IOCTL::SIOCGIFHWADDR\n"));
5450 memcpy(wrq->u.name, pAd->CurrentAddress, ETH_ALEN);
5454 char *name=&wrq->u.name[0];
5455 rt_ioctl_giwname(net_dev, NULL, name, NULL);
5458 case SIOCGIWESSID: //Get ESSID
5460 struct iw_point *essid=&wrq->u.essid;
5461 rt_ioctl_giwessid(net_dev, NULL, essid, essid->pointer);
5464 case SIOCSIWESSID: //Set ESSID
5466 struct iw_point *essid=&wrq->u.essid;
5467 rt_ioctl_siwessid(net_dev, NULL, essid, essid->pointer);
5470 case SIOCSIWNWID: // set network id (the cell)
5471 case SIOCGIWNWID: // get network id
5472 Status = -EOPNOTSUPP;
5474 case SIOCSIWFREQ: //set channel/frequency (Hz)
5476 struct iw_freq *freq=&wrq->u.freq;
5477 rt_ioctl_siwfreq(net_dev, NULL, freq, NULL);
5480 case SIOCGIWFREQ: // get channel/frequency (Hz)
5482 struct iw_freq *freq=&wrq->u.freq;
5483 rt_ioctl_giwfreq(net_dev, NULL, freq, NULL);
5486 case SIOCSIWNICKN: //set node name/nickname
5488 struct iw_point *data=&wrq->u.data;
5489 rt_ioctl_siwnickn(net_dev, NULL, data, NULL);
5492 case SIOCGIWNICKN: //get node name/nickname
5494 struct iw_point *data=&wrq->u.data;
5495 rt_ioctl_giwnickn(net_dev, NULL, data, NULL);
5498 case SIOCGIWRATE: //get default bit rate (bps)
5499 rt_ioctl_giwrate(net_dev, NULL, &wrq->u, NULL);
5501 case SIOCSIWRATE: //set default bit rate (bps)
5502 rt_ioctl_siwrate(net_dev, NULL, &wrq->u, NULL);
5504 case SIOCGIWRTS: // get RTS/CTS threshold (bytes)
5506 struct iw_param *rts=&wrq->u.rts;
5507 rt_ioctl_giwrts(net_dev, NULL, rts, NULL);
5510 case SIOCSIWRTS: //set RTS/CTS threshold (bytes)
5512 struct iw_param *rts=&wrq->u.rts;
5513 rt_ioctl_siwrts(net_dev, NULL, rts, NULL);
5516 case SIOCGIWFRAG: //get fragmentation thr (bytes)
5518 struct iw_param *frag=&wrq->u.frag;
5519 rt_ioctl_giwfrag(net_dev, NULL, frag, NULL);
5522 case SIOCSIWFRAG: //set fragmentation thr (bytes)
5524 struct iw_param *frag=&wrq->u.frag;
5525 rt_ioctl_siwfrag(net_dev, NULL, frag, NULL);
5528 case SIOCGIWENCODE: //get encoding token & mode
5530 struct iw_point *erq=&wrq->u.encoding;
5532 rt_ioctl_giwencode(net_dev, NULL, erq, erq->pointer);
5535 case SIOCSIWENCODE: //set encoding token & mode
5537 struct iw_point *erq=&wrq->u.encoding;
5539 rt_ioctl_siwencode(net_dev, NULL, erq, erq->pointer);
5542 case SIOCGIWAP: //get access point MAC addresses
5544 struct sockaddr *ap_addr=&wrq->u.ap_addr;
5545 rt_ioctl_giwap(net_dev, NULL, ap_addr, ap_addr->sa_data);
5548 case SIOCSIWAP: //set access point MAC addresses
5550 struct sockaddr *ap_addr=&wrq->u.ap_addr;
5551 rt_ioctl_siwap(net_dev, NULL, ap_addr, ap_addr->sa_data);
5554 case SIOCGIWMODE: //get operation mode
5556 __u32 *mode=&wrq->u.mode;
5557 rt_ioctl_giwmode(net_dev, NULL, mode, NULL);
5560 case SIOCSIWMODE: //set operation mode
5562 __u32 *mode=&wrq->u.mode;
5563 rt_ioctl_siwmode(net_dev, NULL, mode, NULL);
5566 case SIOCGIWSENS: //get sensitivity (dBm)
5567 case SIOCSIWSENS: //set sensitivity (dBm)
5568 case SIOCGIWPOWER: //get Power Management settings
5569 case SIOCSIWPOWER: //set Power Management settings
5570 case SIOCGIWTXPOW: //get transmit power (dBm)
5571 case SIOCSIWTXPOW: //set transmit power (dBm)
5572 case SIOCGIWRANGE: //Get range of parameters
5573 case SIOCGIWRETRY: //get retry limits and lifetime
5574 case SIOCSIWRETRY: //set retry limits and lifetime
5575 Status = -EOPNOTSUPP;
5578 case RT_PRIV_IOCTL_EXT:
5579 subcmd = wrq->u.data.flags;
5580 if( subcmd & OID_GET_SET_TOGGLE)
5581 Status = RTMPSetInformation(pAd, rq, subcmd);
5583 Status = RTMPQueryInformation(pAd, rq, subcmd);
5586 if (wrq->u.data.pointer)
5588 if ( access_ok(VERIFY_WRITE, wrq->u.data.pointer, sizeof(privtab)) != TRUE)
5590 wrq->u.data.length = sizeof(privtab) / sizeof(privtab[0]);
5591 if (copy_to_user(wrq->u.data.pointer, privtab, sizeof(privtab)))
5595 case RTPRIV_IOCTL_SET:
5596 if(access_ok(VERIFY_READ, wrq->u.data.pointer, wrq->u.data.length) != TRUE)
5598 rt_ioctl_setparam(net_dev, NULL, NULL, wrq->u.data.pointer);
5600 case RTPRIV_IOCTL_GSITESURVEY:
5601 RTMPIoctlGetSiteSurvey(pAd, wrq);
5604 case RTPRIV_IOCTL_MAC:
5605 RTMPIoctlMAC(pAd, wrq);
5607 case RTPRIV_IOCTL_E2P:
5608 RTMPIoctlE2PROM(pAd, wrq);
5611 case RTPRIV_IOCTL_RF:
5612 RTMPIoctlRF(pAd, wrq);
5619 DBGPRINT(RT_DEBUG_ERROR, ("IOCTL::unknown IOCTL's cmd = 0x%08x\n", cmd));
5620 Status = -EOPNOTSUPP;
5624 if(StateMachineTouched) // Upper layer sent a MLME-related operations
5625 RT28XX_MLME_HANDLER(pAd);
5631 ==========================================================================
5635 TRUE if all parameters are OK, FALSE otherwise
5636 ==========================================================================
5639 IN PRTMP_ADAPTER pAdapter,
5642 NDIS_802_11_SSID Ssid, *pSsid=NULL;
5643 BOOLEAN StateMachineTouched = FALSE;
5646 if( strlen(arg) <= MAX_LEN_OF_SSID)
5648 NdisZeroMemory(&Ssid, sizeof(NDIS_802_11_SSID));
5649 if (strlen(arg) != 0)
5651 NdisMoveMemory(Ssid.Ssid, arg, strlen(arg));
5652 Ssid.SsidLength = strlen(arg);
5656 Ssid.SsidLength = 0;
5657 memcpy(Ssid.Ssid, "", 0);
5658 pAdapter->StaCfg.BssType = BSS_INFRA;
5659 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
5660 pAdapter->StaCfg.WepStatus = Ndis802_11EncryptionDisabled;
5664 if (pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE)
5666 RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
5667 DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
5670 pAdapter->MlmeAux.CurrReqIsFromNdis = TRUE;
5671 pAdapter->StaCfg.bScanReqIsFromWebUI = FALSE;
5672 pAdapter->bConfigChanged = TRUE;
5674 MlmeEnqueue(pAdapter,
5675 MLME_CNTL_STATE_MACHINE,
5677 sizeof(NDIS_802_11_SSID),
5680 StateMachineTouched = TRUE;
5681 DBGPRINT(RT_DEBUG_TRACE, ("Set_SSID_Proc::(Len=%d,Ssid=%s)\n", Ssid.SsidLength, Ssid.Ssid));
5686 if (StateMachineTouched) // Upper layer sent a MLME-related operations
5687 RT28XX_MLME_HANDLER(pAdapter);
5694 ==========================================================================
5696 Set WmmCapable Enable or Disable
5698 TRUE if all parameters are OK, FALSE otherwise
5699 ==========================================================================
5701 INT Set_WmmCapable_Proc(
5702 IN PRTMP_ADAPTER pAd,
5705 BOOLEAN bWmmCapable;
5707 bWmmCapable = simple_strtol(arg, 0, 10);
5709 if ((bWmmCapable == 1)
5711 && (pAd->NumberOfPipes >= 5)
5714 pAd->CommonCfg.bWmmCapable = TRUE;
5715 else if (bWmmCapable == 0)
5716 pAd->CommonCfg.bWmmCapable = FALSE;
5718 return FALSE; //Invalid argument
5720 DBGPRINT(RT_DEBUG_TRACE, ("Set_WmmCapable_Proc::(bWmmCapable=%d)\n",
5721 pAd->CommonCfg.bWmmCapable));
5725 #endif // WMM_SUPPORT //
5728 ==========================================================================
5730 Set Network Type(Infrastructure/Adhoc mode)
5732 TRUE if all parameters are OK, FALSE otherwise
5733 ==========================================================================
5735 INT Set_NetworkType_Proc(
5736 IN PRTMP_ADAPTER pAdapter,
5741 if (strcmp(arg, "Adhoc") == 0)
5743 if (pAdapter->StaCfg.BssType != BSS_ADHOC)
5745 // Config has changed
5746 pAdapter->bConfigChanged = TRUE;
5747 if (MONITOR_ON(pAdapter))
5749 RTMP_IO_WRITE32(pAdapter, RX_FILTR_CFG, STANORMAL);
5750 RTMP_IO_READ32(pAdapter, MAC_SYS_CTRL, &Value);
5752 RTMP_IO_WRITE32(pAdapter, MAC_SYS_CTRL, Value);
5753 OPSTATUS_CLEAR_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED);
5754 pAdapter->StaCfg.bAutoReconnect = TRUE;
5755 LinkDown(pAdapter, FALSE);
5757 if (INFRA_ON(pAdapter))
5759 //BOOLEAN Cancelled;
5760 // Set the AutoReconnectSsid to prevent it reconnect to old SSID
5761 // Since calling this indicate user don't want to connect to that SSID anymore.
5762 pAdapter->MlmeAux.AutoReconnectSsidLen= 32;
5763 NdisZeroMemory(pAdapter->MlmeAux.AutoReconnectSsid, pAdapter->MlmeAux.AutoReconnectSsidLen);
5765 LinkDown(pAdapter, FALSE);
5767 DBGPRINT(RT_DEBUG_TRACE, ("NDIS_STATUS_MEDIA_DISCONNECT Event BB!\n"));
5770 pAdapter->StaCfg.BssType = BSS_ADHOC;
5771 pAdapter->net_dev->type = pAdapter->StaCfg.OriDevType;
5772 DBGPRINT(RT_DEBUG_TRACE, ("===>Set_NetworkType_Proc::(AD-HOC)\n"));
5774 else if (strcmp(arg, "Infra") == 0)
5776 if (pAdapter->StaCfg.BssType != BSS_INFRA)
5778 // Config has changed
5779 pAdapter->bConfigChanged = TRUE;
5780 if (MONITOR_ON(pAdapter))
5782 RTMP_IO_WRITE32(pAdapter, RX_FILTR_CFG, STANORMAL);
5783 RTMP_IO_READ32(pAdapter, MAC_SYS_CTRL, &Value);
5785 RTMP_IO_WRITE32(pAdapter, MAC_SYS_CTRL, Value);
5786 OPSTATUS_CLEAR_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED);
5787 pAdapter->StaCfg.bAutoReconnect = TRUE;
5788 LinkDown(pAdapter, FALSE);
5790 if (ADHOC_ON(pAdapter))
5792 // Set the AutoReconnectSsid to prevent it reconnect to old SSID
5793 // Since calling this indicate user don't want to connect to that SSID anymore.
5794 pAdapter->MlmeAux.AutoReconnectSsidLen= 32;
5795 NdisZeroMemory(pAdapter->MlmeAux.AutoReconnectSsid, pAdapter->MlmeAux.AutoReconnectSsidLen);
5797 LinkDown(pAdapter, FALSE);
5800 pAdapter->StaCfg.BssType = BSS_INFRA;
5801 pAdapter->net_dev->type = pAdapter->StaCfg.OriDevType;
5802 DBGPRINT(RT_DEBUG_TRACE, ("===>Set_NetworkType_Proc::(INFRA)\n"));
5804 pAdapter->StaCfg.BssType = BSS_INFRA;
5806 else if (strcmp(arg, "Monitor") == 0)
5809 BCN_TIME_CFG_STRUC csr;
5810 OPSTATUS_CLEAR_FLAG(pAdapter, fOP_STATUS_INFRA_ON);
5811 OPSTATUS_CLEAR_FLAG(pAdapter, fOP_STATUS_ADHOC_ON);
5812 OPSTATUS_SET_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED);
5813 // disable all periodic state machine
5814 pAdapter->StaCfg.bAutoReconnect = FALSE;
5815 // reset all mlme state machine
5816 RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
5817 DBGPRINT(RT_DEBUG_TRACE, ("fOP_STATUS_MEDIA_STATE_CONNECTED \n"));
5818 if (pAdapter->CommonCfg.CentralChannel == 0)
5820 #ifdef DOT11_N_SUPPORT
5821 if (pAdapter->CommonCfg.PhyMode == PHY_11AN_MIXED)
5822 pAdapter->CommonCfg.CentralChannel = 36;
5824 #endif // DOT11_N_SUPPORT //
5825 pAdapter->CommonCfg.CentralChannel = 6;
5827 #ifdef DOT11_N_SUPPORT
5829 N_ChannelCheck(pAdapter);
5830 #endif // DOT11_N_SUPPORT //
5832 #ifdef DOT11_N_SUPPORT
5833 if (pAdapter->CommonCfg.PhyMode >= PHY_11ABGN_MIXED &&
5834 pAdapter->CommonCfg.RegTransmitSetting.field.BW == BW_40 &&
5835 pAdapter->CommonCfg.RegTransmitSetting.field.EXTCHA == EXTCHA_ABOVE)
5837 // 40MHz ,control channel at lower
5838 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, BBP_R4, &bbpValue);
5839 bbpValue &= (~0x18);
5841 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R4, bbpValue);
5842 pAdapter->CommonCfg.BBPCurrentBW = BW_40;
5843 // RX : control channel at lower
5844 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, BBP_R3, &bbpValue);
5845 bbpValue &= (~0x20);
5846 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R3, bbpValue);
5848 RTMP_IO_READ32(pAdapter, TX_BAND_CFG, &Value);
5849 Value &= 0xfffffffe;
5850 RTMP_IO_WRITE32(pAdapter, TX_BAND_CFG, Value);
5851 pAdapter->CommonCfg.CentralChannel = pAdapter->CommonCfg.Channel + 2;
5852 AsicSwitchChannel(pAdapter, pAdapter->CommonCfg.CentralChannel, FALSE);
5853 AsicLockChannel(pAdapter, pAdapter->CommonCfg.CentralChannel);
5854 DBGPRINT(RT_DEBUG_TRACE, ("BW_40 ,control_channel(%d), CentralChannel(%d) \n",
5855 pAdapter->CommonCfg.Channel,
5856 pAdapter->CommonCfg.CentralChannel));
5858 else if (pAdapter->CommonCfg.PhyMode >= PHY_11ABGN_MIXED &&
5859 pAdapter->CommonCfg.RegTransmitSetting.field.BW == BW_40 &&
5860 pAdapter->CommonCfg.RegTransmitSetting.field.EXTCHA == EXTCHA_BELOW)
5862 // 40MHz ,control channel at upper
5863 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, BBP_R4, &bbpValue);
5864 bbpValue &= (~0x18);
5866 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R4, bbpValue);
5867 pAdapter->CommonCfg.BBPCurrentBW = BW_40;
5868 RTMP_IO_READ32(pAdapter, TX_BAND_CFG, &Value);
5870 RTMP_IO_WRITE32(pAdapter, TX_BAND_CFG, Value);
5872 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, BBP_R3, &bbpValue);
5874 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R3, bbpValue);
5875 pAdapter->CommonCfg.CentralChannel = pAdapter->CommonCfg.Channel - 2;
5876 AsicSwitchChannel(pAdapter, pAdapter->CommonCfg.CentralChannel, FALSE);
5877 AsicLockChannel(pAdapter, pAdapter->CommonCfg.CentralChannel);
5878 DBGPRINT(RT_DEBUG_TRACE, ("BW_40 ,control_channel(%d), CentralChannel(%d) \n",
5879 pAdapter->CommonCfg.Channel,
5880 pAdapter->CommonCfg.CentralChannel));
5883 #endif // DOT11_N_SUPPORT //
5886 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, BBP_R4, &bbpValue);
5887 bbpValue &= (~0x18);
5888 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R4, bbpValue);
5889 pAdapter->CommonCfg.BBPCurrentBW = BW_20;
5890 AsicSwitchChannel(pAdapter, pAdapter->CommonCfg.Channel, FALSE);
5891 AsicLockChannel(pAdapter, pAdapter->CommonCfg.Channel);
5892 DBGPRINT(RT_DEBUG_TRACE, ("BW_20, Channel(%d)\n", pAdapter->CommonCfg.Channel));
5894 // Enable Rx with promiscuous reception
5895 RTMP_IO_WRITE32(pAdapter, RX_FILTR_CFG, 0x3);
5896 // ASIC supporsts sniffer function with replacing RSSI with timestamp.
5897 //RTMP_IO_READ32(pAdapter, MAC_SYS_CTRL, &Value);
5899 //RTMP_IO_WRITE32(pAdapter, MAC_SYS_CTRL, Value);
5901 RTMP_IO_READ32(pAdapter, BCN_TIME_CFG, &csr.word);
5902 csr.field.bBeaconGen = 0;
5903 csr.field.bTBTTEnable = 0;
5904 csr.field.TsfSyncMode = 0;
5905 RTMP_IO_WRITE32(pAdapter, BCN_TIME_CFG, csr.word);
5907 pAdapter->StaCfg.BssType = BSS_MONITOR;
5908 pAdapter->net_dev->type = ARPHRD_IEEE80211_PRISM; //ARPHRD_IEEE80211; // IEEE80211
5909 DBGPRINT(RT_DEBUG_TRACE, ("===>Set_NetworkType_Proc::(MONITOR)\n"));
5912 // Reset Ralink supplicant to not use, it will be set to start when UI set PMK key
5913 pAdapter->StaCfg.WpaState = SS_NOTUSE;
5915 DBGPRINT(RT_DEBUG_TRACE, ("Set_NetworkType_Proc::(NetworkType=%d)\n", pAdapter->StaCfg.BssType));
5921 ==========================================================================
5923 Set Authentication mode
5925 TRUE if all parameters are OK, FALSE otherwise
5926 ==========================================================================
5928 INT Set_AuthMode_Proc(
5929 IN PRTMP_ADAPTER pAdapter,
5932 if ((strcmp(arg, "WEPAUTO") == 0) || (strcmp(arg, "wepauto") == 0))
5933 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeAutoSwitch;
5934 else if ((strcmp(arg, "OPEN") == 0) || (strcmp(arg, "open") == 0))
5935 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
5936 else if ((strcmp(arg, "SHARED") == 0) || (strcmp(arg, "shared") == 0))
5937 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeShared;
5938 else if ((strcmp(arg, "WPAPSK") == 0) || (strcmp(arg, "wpapsk") == 0))
5939 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPAPSK;
5940 else if ((strcmp(arg, "WPANONE") == 0) || (strcmp(arg, "wpanone") == 0))
5941 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPANone;
5942 else if ((strcmp(arg, "WPA2PSK") == 0) || (strcmp(arg, "wpa2psk") == 0))
5943 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA2PSK;
5944 #ifdef WPA_SUPPLICANT_SUPPORT
5945 else if ((strcmp(arg, "WPA") == 0) || (strcmp(arg, "wpa") == 0))
5946 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA;
5947 else if ((strcmp(arg, "WPA2") == 0) || (strcmp(arg, "wpa2") == 0))
5948 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA2;
5949 #endif // WPA_SUPPLICANT_SUPPORT //
5953 pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED;
5955 DBGPRINT(RT_DEBUG_TRACE, ("Set_AuthMode_Proc::(AuthMode=%d)\n", pAdapter->StaCfg.AuthMode));
5961 ==========================================================================
5965 TRUE if all parameters are OK, FALSE otherwise
5966 ==========================================================================
5968 INT Set_EncrypType_Proc(
5969 IN PRTMP_ADAPTER pAdapter,
5972 if ((strcmp(arg, "NONE") == 0) || (strcmp(arg, "none") == 0))
5974 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
5975 return TRUE; // do nothing
5977 pAdapter->StaCfg.WepStatus = Ndis802_11WEPDisabled;
5978 pAdapter->StaCfg.PairCipher = Ndis802_11WEPDisabled;
5979 pAdapter->StaCfg.GroupCipher = Ndis802_11WEPDisabled;
5981 else if ((strcmp(arg, "WEP") == 0) || (strcmp(arg, "wep") == 0))
5983 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
5984 return TRUE; // do nothing
5986 pAdapter->StaCfg.WepStatus = Ndis802_11WEPEnabled;
5987 pAdapter->StaCfg.PairCipher = Ndis802_11WEPEnabled;
5988 pAdapter->StaCfg.GroupCipher = Ndis802_11WEPEnabled;
5990 else if ((strcmp(arg, "TKIP") == 0) || (strcmp(arg, "tkip") == 0))
5992 if (pAdapter->StaCfg.AuthMode < Ndis802_11AuthModeWPA)
5993 return TRUE; // do nothing
5995 pAdapter->StaCfg.WepStatus = Ndis802_11Encryption2Enabled;
5996 pAdapter->StaCfg.PairCipher = Ndis802_11Encryption2Enabled;
5997 pAdapter->StaCfg.GroupCipher = Ndis802_11Encryption2Enabled;
5999 else if ((strcmp(arg, "AES") == 0) || (strcmp(arg, "aes") == 0))
6001 if (pAdapter->StaCfg.AuthMode < Ndis802_11AuthModeWPA)
6002 return TRUE; // do nothing
6004 pAdapter->StaCfg.WepStatus = Ndis802_11Encryption3Enabled;
6005 pAdapter->StaCfg.PairCipher = Ndis802_11Encryption3Enabled;
6006 pAdapter->StaCfg.GroupCipher = Ndis802_11Encryption3Enabled;
6011 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
6013 DBGPRINT(RT_DEBUG_TRACE, ("Set_EncrypType_Proc::(EncrypType=%d)\n", pAdapter->StaCfg.WepStatus));
6019 ==========================================================================
6023 TRUE if all parameters are OK, FALSE otherwise
6024 ==========================================================================
6026 INT Set_DefaultKeyID_Proc(
6027 IN PRTMP_ADAPTER pAdapter,
6032 KeyIdx = simple_strtol(arg, 0, 10);
6033 if((KeyIdx >= 1 ) && (KeyIdx <= 4))
6034 pAdapter->StaCfg.DefaultKeyId = (UCHAR) (KeyIdx - 1 );
6036 return FALSE; //Invalid argument
6038 DBGPRINT(RT_DEBUG_TRACE, ("Set_DefaultKeyID_Proc::(DefaultKeyID=%d)\n", pAdapter->StaCfg.DefaultKeyId));
6044 ==========================================================================
6048 TRUE if all parameters are OK, FALSE otherwise
6049 ==========================================================================
6052 IN PRTMP_ADAPTER pAdapter,
6057 UCHAR CipherAlg=CIPHER_WEP64;
6059 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
6060 return TRUE; // do nothing
6062 KeyLen = strlen(arg);
6066 case 5: //wep 40 Ascii type
6067 pAdapter->SharedKey[BSS0][0].KeyLen = KeyLen;
6068 memcpy(pAdapter->SharedKey[BSS0][0].Key, arg, KeyLen);
6069 CipherAlg = CIPHER_WEP64;
6070 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key1_Proc::(Key1=%s and type=%s)\n", arg, "Ascii"));
6072 case 10: //wep 40 Hex type
6073 for(i=0; i < KeyLen; i++)
6075 if( !isxdigit(*(arg+i)) )
6076 return FALSE; //Not Hex value;
6078 pAdapter->SharedKey[BSS0][0].KeyLen = KeyLen / 2 ;
6079 AtoH(arg, pAdapter->SharedKey[BSS0][0].Key, KeyLen / 2);
6080 CipherAlg = CIPHER_WEP64;
6081 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key1_Proc::(Key1=%s and type=%s)\n", arg, "Hex"));
6083 case 13: //wep 104 Ascii type
6084 pAdapter->SharedKey[BSS0][0].KeyLen = KeyLen;
6085 memcpy(pAdapter->SharedKey[BSS0][0].Key, arg, KeyLen);
6086 CipherAlg = CIPHER_WEP128;
6087 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key1_Proc::(Key1=%s and type=%s)\n", arg, "Ascii"));
6089 case 26: //wep 104 Hex type
6090 for(i=0; i < KeyLen; i++)
6092 if( !isxdigit(*(arg+i)) )
6093 return FALSE; //Not Hex value;
6095 pAdapter->SharedKey[BSS0][0].KeyLen = KeyLen / 2 ;
6096 AtoH(arg, pAdapter->SharedKey[BSS0][0].Key, KeyLen / 2);
6097 CipherAlg = CIPHER_WEP128;
6098 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key1_Proc::(Key1=%s and type=%s)\n", arg, "Hex"));
6100 default: //Invalid argument
6101 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key1_Proc::Invalid argument (=%s)\n", arg));
6105 pAdapter->SharedKey[BSS0][0].CipherAlg = CipherAlg;
6107 // Set keys (into ASIC)
6108 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
6110 else // Old WEP stuff
6112 AsicAddSharedKeyEntry(pAdapter,
6115 pAdapter->SharedKey[BSS0][0].CipherAlg,
6116 pAdapter->SharedKey[BSS0][0].Key,
6124 ==========================================================================
6129 TRUE if all parameters are OK, FALSE otherwise
6130 ==========================================================================
6133 IN PRTMP_ADAPTER pAdapter,
6138 UCHAR CipherAlg=CIPHER_WEP64;
6140 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
6141 return TRUE; // do nothing
6143 KeyLen = strlen(arg);
6147 case 5: //wep 40 Ascii type
6148 pAdapter->SharedKey[BSS0][1].KeyLen = KeyLen;
6149 memcpy(pAdapter->SharedKey[BSS0][1].Key, arg, KeyLen);
6150 CipherAlg = CIPHER_WEP64;
6151 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key2_Proc::(Key2=%s and type=%s)\n", arg, "Ascii"));
6153 case 10: //wep 40 Hex type
6154 for(i=0; i < KeyLen; i++)
6156 if( !isxdigit(*(arg+i)) )
6157 return FALSE; //Not Hex value;
6159 pAdapter->SharedKey[BSS0][1].KeyLen = KeyLen / 2 ;
6160 AtoH(arg, pAdapter->SharedKey[BSS0][1].Key, KeyLen / 2);
6161 CipherAlg = CIPHER_WEP64;
6162 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key2_Proc::(Key2=%s and type=%s)\n", arg, "Hex"));
6164 case 13: //wep 104 Ascii type
6165 pAdapter->SharedKey[BSS0][1].KeyLen = KeyLen;
6166 memcpy(pAdapter->SharedKey[BSS0][1].Key, arg, KeyLen);
6167 CipherAlg = CIPHER_WEP128;
6168 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key2_Proc::(Key2=%s and type=%s)\n", arg, "Ascii"));
6170 case 26: //wep 104 Hex type
6171 for(i=0; i < KeyLen; i++)
6173 if( !isxdigit(*(arg+i)) )
6174 return FALSE; //Not Hex value;
6176 pAdapter->SharedKey[BSS0][1].KeyLen = KeyLen / 2 ;
6177 AtoH(arg, pAdapter->SharedKey[BSS0][1].Key, KeyLen / 2);
6178 CipherAlg = CIPHER_WEP128;
6179 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key2_Proc::(Key2=%s and type=%s)\n", arg, "Hex"));
6181 default: //Invalid argument
6182 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key2_Proc::Invalid argument (=%s)\n", arg));
6185 pAdapter->SharedKey[BSS0][1].CipherAlg = CipherAlg;
6187 // Set keys (into ASIC)
6188 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
6190 else // Old WEP stuff
6192 AsicAddSharedKeyEntry(pAdapter,
6195 pAdapter->SharedKey[BSS0][1].CipherAlg,
6196 pAdapter->SharedKey[BSS0][1].Key,
6204 ==========================================================================
6208 TRUE if all parameters are OK, FALSE otherwise
6209 ==========================================================================
6212 IN PRTMP_ADAPTER pAdapter,
6217 UCHAR CipherAlg=CIPHER_WEP64;
6219 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
6220 return TRUE; // do nothing
6222 KeyLen = strlen(arg);
6226 case 5: //wep 40 Ascii type
6227 pAdapter->SharedKey[BSS0][2].KeyLen = KeyLen;
6228 memcpy(pAdapter->SharedKey[BSS0][2].Key, arg, KeyLen);
6229 CipherAlg = CIPHER_WEP64;
6230 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key3_Proc::(Key3=%s and type=Ascii)\n", arg));
6232 case 10: //wep 40 Hex type
6233 for(i=0; i < KeyLen; i++)
6235 if( !isxdigit(*(arg+i)) )
6236 return FALSE; //Not Hex value;
6238 pAdapter->SharedKey[BSS0][2].KeyLen = KeyLen / 2 ;
6239 AtoH(arg, pAdapter->SharedKey[BSS0][2].Key, KeyLen / 2);
6240 CipherAlg = CIPHER_WEP64;
6241 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key3_Proc::(Key3=%s and type=Hex)\n", arg));
6243 case 13: //wep 104 Ascii type
6244 pAdapter->SharedKey[BSS0][2].KeyLen = KeyLen;
6245 memcpy(pAdapter->SharedKey[BSS0][2].Key, arg, KeyLen);
6246 CipherAlg = CIPHER_WEP128;
6247 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key3_Proc::(Key3=%s and type=Ascii)\n", arg));
6249 case 26: //wep 104 Hex type
6250 for(i=0; i < KeyLen; i++)
6252 if( !isxdigit(*(arg+i)) )
6253 return FALSE; //Not Hex value;
6255 pAdapter->SharedKey[BSS0][2].KeyLen = KeyLen / 2 ;
6256 AtoH(arg, pAdapter->SharedKey[BSS0][2].Key, KeyLen / 2);
6257 CipherAlg = CIPHER_WEP128;
6258 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key3_Proc::(Key3=%s and type=Hex)\n", arg));
6260 default: //Invalid argument
6261 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key3_Proc::Invalid argument (=%s)\n", arg));
6264 pAdapter->SharedKey[BSS0][2].CipherAlg = CipherAlg;
6266 // Set keys (into ASIC)
6267 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
6269 else // Old WEP stuff
6271 AsicAddSharedKeyEntry(pAdapter,
6274 pAdapter->SharedKey[BSS0][2].CipherAlg,
6275 pAdapter->SharedKey[BSS0][2].Key,
6283 ==========================================================================
6287 TRUE if all parameters are OK, FALSE otherwise
6288 ==========================================================================
6291 IN PRTMP_ADAPTER pAdapter,
6296 UCHAR CipherAlg=CIPHER_WEP64;
6298 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
6299 return TRUE; // do nothing
6301 KeyLen = strlen(arg);
6305 case 5: //wep 40 Ascii type
6306 pAdapter->SharedKey[BSS0][3].KeyLen = KeyLen;
6307 memcpy(pAdapter->SharedKey[BSS0][3].Key, arg, KeyLen);
6308 CipherAlg = CIPHER_WEP64;
6309 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key4_Proc::(Key4=%s and type=%s)\n", arg, "Ascii"));
6311 case 10: //wep 40 Hex type
6312 for(i=0; i < KeyLen; i++)
6314 if( !isxdigit(*(arg+i)) )
6315 return FALSE; //Not Hex value;
6317 pAdapter->SharedKey[BSS0][3].KeyLen = KeyLen / 2 ;
6318 AtoH(arg, pAdapter->SharedKey[BSS0][3].Key, KeyLen / 2);
6319 CipherAlg = CIPHER_WEP64;
6320 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key4_Proc::(Key4=%s and type=%s)\n", arg, "Hex"));
6322 case 13: //wep 104 Ascii type
6323 pAdapter->SharedKey[BSS0][3].KeyLen = KeyLen;
6324 memcpy(pAdapter->SharedKey[BSS0][3].Key, arg, KeyLen);
6325 CipherAlg = CIPHER_WEP128;
6326 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key4_Proc::(Key4=%s and type=%s)\n", arg, "Ascii"));
6328 case 26: //wep 104 Hex type
6329 for(i=0; i < KeyLen; i++)
6331 if( !isxdigit(*(arg+i)) )
6332 return FALSE; //Not Hex value;
6334 pAdapter->SharedKey[BSS0][3].KeyLen = KeyLen / 2 ;
6335 AtoH(arg, pAdapter->SharedKey[BSS0][3].Key, KeyLen / 2);
6336 CipherAlg = CIPHER_WEP128;
6337 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key4_Proc::(Key4=%s and type=%s)\n", arg, "Hex"));
6339 default: //Invalid argument
6340 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key4_Proc::Invalid argument (=%s)\n", arg));
6343 pAdapter->SharedKey[BSS0][3].CipherAlg = CipherAlg;
6345 // Set keys (into ASIC)
6346 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
6348 else // Old WEP stuff
6350 AsicAddSharedKeyEntry(pAdapter,
6353 pAdapter->SharedKey[BSS0][3].CipherAlg,
6354 pAdapter->SharedKey[BSS0][3].Key,
6363 ==========================================================================
6367 TRUE if all parameters are OK, FALSE otherwise
6368 ==========================================================================
6370 INT Set_WPAPSK_Proc(
6371 IN PRTMP_ADAPTER pAdapter,
6374 UCHAR keyMaterial[40];
6376 if ((pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPAPSK) &&
6377 (pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPA2PSK) &&
6378 (pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPANone)
6380 return TRUE; // do nothing
6382 DBGPRINT(RT_DEBUG_TRACE, ("Set_WPAPSK_Proc::(WPAPSK=%s)\n", arg));
6384 NdisZeroMemory(keyMaterial, 40);
6386 if ((strlen(arg) < 8) || (strlen(arg) > 64))
6388 DBGPRINT(RT_DEBUG_TRACE, ("Set failed!!(WPAPSK=%s), WPAPSK key-string required 8 ~ 64 characters \n", arg));
6392 if (strlen(arg) == 64)
6394 AtoH(arg, keyMaterial, 32);
6395 NdisMoveMemory(pAdapter->StaCfg.PMK, keyMaterial, 32);
6400 PasswordHash((char *)arg, pAdapter->MlmeAux.Ssid, pAdapter->MlmeAux.SsidLen, keyMaterial);
6401 NdisMoveMemory(pAdapter->StaCfg.PMK, keyMaterial, 32);
6406 if(pAdapter->StaCfg.BssType == BSS_ADHOC &&
6407 pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPANone)
6409 pAdapter->StaCfg.WpaState = SS_NOTUSE;
6413 // Start STA supplicant state machine
6414 pAdapter->StaCfg.WpaState = SS_START;
6421 ==========================================================================
6423 Set Power Saving mode
6425 TRUE if all parameters are OK, FALSE otherwise
6426 ==========================================================================
6428 INT Set_PSMode_Proc(
6429 IN PRTMP_ADAPTER pAdapter,
6432 if (pAdapter->StaCfg.BssType == BSS_INFRA)
6434 if ((strcmp(arg, "Max_PSP") == 0) ||
6435 (strcmp(arg, "max_psp") == 0) ||
6436 (strcmp(arg, "MAX_PSP") == 0))
6438 // do NOT turn on PSM bit here, wait until MlmeCheckForPsmChange()
6439 // to exclude certain situations.
6440 if (pAdapter->StaCfg.bWindowsACCAMEnable == FALSE)
6441 pAdapter->StaCfg.WindowsPowerMode = Ndis802_11PowerModeMAX_PSP;
6442 pAdapter->StaCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeMAX_PSP;
6443 OPSTATUS_SET_FLAG(pAdapter, fOP_STATUS_RECEIVE_DTIM);
6444 pAdapter->StaCfg.DefaultListenCount = 5;
6447 else if ((strcmp(arg, "Fast_PSP") == 0) ||
6448 (strcmp(arg, "fast_psp") == 0) ||
6449 (strcmp(arg, "FAST_PSP") == 0))
6451 // do NOT turn on PSM bit here, wait until MlmeCheckForPsmChange()
6452 // to exclude certain situations.
6453 OPSTATUS_SET_FLAG(pAdapter, fOP_STATUS_RECEIVE_DTIM);
6454 if (pAdapter->StaCfg.bWindowsACCAMEnable == FALSE)
6455 pAdapter->StaCfg.WindowsPowerMode = Ndis802_11PowerModeFast_PSP;
6456 pAdapter->StaCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeFast_PSP;
6457 pAdapter->StaCfg.DefaultListenCount = 3;
6459 else if ((strcmp(arg, "Legacy_PSP") == 0) ||
6460 (strcmp(arg, "legacy_psp") == 0) ||
6461 (strcmp(arg, "LEGACY_PSP") == 0))
6463 // do NOT turn on PSM bit here, wait until MlmeCheckForPsmChange()
6464 // to exclude certain situations.
6465 OPSTATUS_SET_FLAG(pAdapter, fOP_STATUS_RECEIVE_DTIM);
6466 if (pAdapter->StaCfg.bWindowsACCAMEnable == FALSE)
6467 pAdapter->StaCfg.WindowsPowerMode = Ndis802_11PowerModeLegacy_PSP;
6468 pAdapter->StaCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeLegacy_PSP;
6469 pAdapter->StaCfg.DefaultListenCount = 3;
6473 //Default Ndis802_11PowerModeCAM
6474 // clear PSM bit immediately
6475 MlmeSetPsmBit(pAdapter, PWR_ACTIVE);
6476 OPSTATUS_SET_FLAG(pAdapter, fOP_STATUS_RECEIVE_DTIM);
6477 if (pAdapter->StaCfg.bWindowsACCAMEnable == FALSE)
6478 pAdapter->StaCfg.WindowsPowerMode = Ndis802_11PowerModeCAM;
6479 pAdapter->StaCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeCAM;
6482 DBGPRINT(RT_DEBUG_TRACE, ("Set_PSMode_Proc::(PSMode=%ld)\n", pAdapter->StaCfg.WindowsPowerMode));
6491 #ifdef WPA_SUPPLICANT_SUPPORT
6493 ==========================================================================
6495 Set WpaSupport flag.
6497 0: Driver ignore wpa_supplicant.
6498 1: wpa_supplicant initiates scanning and AP selection.
6499 2: driver takes care of scanning, AP selection, and IEEE 802.11 association parameters.
6501 TRUE if all parameters are OK, FALSE otherwise
6502 ==========================================================================
6504 INT Set_Wpa_Support(
6505 IN PRTMP_ADAPTER pAd,
6509 if ( simple_strtol(arg, 0, 10) == 0)
6510 pAd->StaCfg.WpaSupplicantUP = WPA_SUPPLICANT_DISABLE;
6511 else if ( simple_strtol(arg, 0, 10) == 1)
6512 pAd->StaCfg.WpaSupplicantUP = WPA_SUPPLICANT_ENABLE;
6513 else if ( simple_strtol(arg, 0, 10) == 2)
6514 pAd->StaCfg.WpaSupplicantUP = WPA_SUPPLICANT_ENABLE_WITH_WEB_UI;
6516 pAd->StaCfg.WpaSupplicantUP = WPA_SUPPLICANT_DISABLE;
6518 DBGPRINT(RT_DEBUG_TRACE, ("Set_Wpa_Support::(WpaSupplicantUP=%d)\n", pAd->StaCfg.WpaSupplicantUP));
6522 #endif // WPA_SUPPLICANT_SUPPORT //
6526 ==========================================================================
6530 pAdapter Pointer to our adapter
6531 wrq Pointer to the ioctl argument
6538 1.) iwpriv ra0 mac 0 ==> read MAC where Addr=0x0
6539 2.) iwpriv ra0 mac 0=12 ==> write MAC where Addr=0x0, value=12
6540 ==========================================================================
6543 IN PRTMP_ADAPTER pAdapter,
6544 IN struct iwreq *wrq)
6552 UCHAR temp[16], temp2[16];
6553 UINT32 macValue = 0;
6555 BOOLEAN bIsPrintAllMAC = FALSE;
6558 memset(msg, 0x00, 1024);
6559 if (wrq->u.data.length > 1) //No parameters.
6561 Status = copy_from_user(arg, wrq->u.data.pointer, (wrq->u.data.length > 255) ? 255 : wrq->u.data.length);
6564 //Parsing Read or Write
6569 if ((value = rtstrchr(this_char, '=')) != NULL)
6572 if (!value || !*value)
6575 if(strlen(this_char) > 4)
6578 j = strlen(this_char);
6581 if(this_char[j] > 'f' || this_char[j] < '0')
6586 k = j = strlen(this_char);
6589 this_char[4-k+j] = this_char[j];
6593 this_char[3-k++]='0';
6596 if(strlen(this_char) == 4)
6598 AtoH(this_char, temp, 2);
6599 macAddr = *temp*256 + temp[1];
6600 if (macAddr < 0xFFFF)
6602 RTMP_IO_READ32(pAdapter, macAddr, &macValue);
6603 DBGPRINT(RT_DEBUG_TRACE, ("MacAddr=%lx, MacValue=%x\n", macAddr, macValue));
6604 sprintf(msg+strlen(msg), "[0x%08lX]:%08X ", macAddr , macValue);
6607 {//Invalid parametes, so default printk all mac
6608 bIsPrintAllMAC = TRUE;
6615 memcpy(&temp2, value, strlen(value));
6616 temp2[strlen(value)] = '\0';
6619 if((strlen(this_char) > 4) || strlen(temp2) > 8)
6622 j = strlen(this_char);
6625 if(this_char[j] > 'f' || this_char[j] < '0')
6632 if(temp2[j] > 'f' || temp2[j] < '0')
6637 k = j = strlen(this_char);
6640 this_char[4-k+j] = this_char[j];
6644 this_char[3-k++]='0';
6648 k = j = strlen(temp2);
6651 temp2[8-k+j] = temp2[j];
6659 AtoH(this_char, temp, 2);
6660 macAddr = *temp*256 + temp[1];
6662 AtoH(temp2, temp, 4);
6663 macValue = *temp*256*256*256 + temp[1]*256*256 + temp[2]*256 + temp[3];
6666 if (macAddr == (HW_DEBUG_SETTING_BASE + 4))
6668 // 0x2bf4: byte0 non-zero: enable R17 tuning, 0: disable R17 tuning
6669 if (macValue & 0x000000ff)
6671 pAdapter->BbpTuning.bEnable = TRUE;
6672 DBGPRINT(RT_DEBUG_TRACE,("turn on R17 tuning\n"));
6677 pAdapter->BbpTuning.bEnable = FALSE;
6678 R66 = 0x26 + GET_LNA_GAIN(pAdapter);
6680 if (ATE_ON(pAdapter))
6682 ATE_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R66, (0x26 + GET_LNA_GAIN(pAdapter)));
6685 #endif // RALINK_ATE //
6686 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R66, (0x26 + GET_LNA_GAIN(pAdapter)));
6687 DBGPRINT(RT_DEBUG_TRACE,("turn off R17 tuning, restore to 0x%02x\n", R66));
6692 DBGPRINT(RT_DEBUG_TRACE, ("MacAddr=%02lx, MacValue=0x%x\n", macAddr, macValue));
6694 RTMP_IO_WRITE32(pAdapter, macAddr, macValue);
6695 sprintf(msg+strlen(msg), "[0x%08lX]:%08X ", macAddr, macValue);
6700 bIsPrintAllMAC = TRUE;
6704 struct file *file_w;
6705 PCHAR fileName = "MacDump.txt";
6706 mm_segment_t orig_fs;
6712 file_w = filp_open(fileName, O_WRONLY|O_CREAT, 0);
6715 DBGPRINT(RT_DEBUG_TRACE, ("-->2) %s: Error %ld opening %s\n", __FUNCTION__, -PTR_ERR(file_w), fileName));
6719 if (file_w->f_op && file_w->f_op->write)
6724 while (macAddr <= 0x1800)
6726 RTMP_IO_READ32(pAdapter, macAddr, &macValue);
6727 sprintf(msg, "%08lx = %08X\n", macAddr, macValue);
6729 // write data to file
6730 file_w->f_op->write(file_w, msg, strlen(msg), &file_w->f_pos);
6735 sprintf(msg, "\nDump all MAC values to %s\n", fileName);
6737 filp_close(file_w, NULL);
6741 if(strlen(msg) == 1)
6742 sprintf(msg+strlen(msg), "===>Error command format!");
6744 // Copy the information into the user buffer
6745 wrq->u.data.length = strlen(msg);
6746 Status = copy_to_user(wrq->u.data.pointer, msg, wrq->u.data.length);
6748 DBGPRINT(RT_DEBUG_TRACE, ("<==RTMPIoctlMAC\n\n"));
6752 ==========================================================================
6756 pAdapter Pointer to our adapter
6757 wrq Pointer to the ioctl argument
6764 1.) iwpriv ra0 e2p 0 ==> read E2PROM where Addr=0x0
6765 2.) iwpriv ra0 e2p 0=1234 ==> write E2PROM where Addr=0x0, value=1234
6766 ==========================================================================
6768 VOID RTMPIoctlE2PROM(
6769 IN PRTMP_ADAPTER pAdapter,
6770 IN struct iwreq *wrq)
6778 UCHAR temp[16], temp2[16];
6781 BOOLEAN bIsPrintAllE2P = FALSE;
6784 memset(msg, 0x00, 1024);
6785 if (wrq->u.data.length > 1) //No parameters.
6787 Status = copy_from_user(arg, wrq->u.data.pointer, (wrq->u.data.length > 255) ? 255 : wrq->u.data.length);
6790 //Parsing Read or Write
6797 if ((value = rtstrchr(this_char, '=')) != NULL)
6800 if (!value || !*value)
6804 if(strlen(this_char) > 4)
6807 j = strlen(this_char);
6810 if(this_char[j] > 'f' || this_char[j] < '0')
6815 k = j = strlen(this_char);
6818 this_char[4-k+j] = this_char[j];
6822 this_char[3-k++]='0';
6825 if(strlen(this_char) == 4)
6827 AtoH(this_char, temp, 2);
6828 eepAddr = *temp*256 + temp[1];
6829 if (eepAddr < 0xFFFF)
6831 RT28xx_EEPROM_READ16(pAdapter, eepAddr, eepValue);
6832 sprintf(msg+strlen(msg), "[0x%04X]:0x%04X ", eepAddr , eepValue);
6835 {//Invalid parametes, so default printk all bbp
6836 bIsPrintAllE2P = TRUE;
6843 memcpy(&temp2, value, strlen(value));
6844 temp2[strlen(value)] = '\0';
6847 if((strlen(this_char) > 4) || strlen(temp2) > 8)
6850 j = strlen(this_char);
6853 if(this_char[j] > 'f' || this_char[j] < '0')
6859 if(temp2[j] > 'f' || temp2[j] < '0')
6864 k = j = strlen(this_char);
6867 this_char[4-k+j] = this_char[j];
6871 this_char[3-k++]='0';
6875 k = j = strlen(temp2);
6878 temp2[4-k+j] = temp2[j];
6885 AtoH(this_char, temp, 2);
6886 eepAddr = *temp*256 + temp[1];
6888 AtoH(temp2, temp, 2);
6889 eepValue = *temp*256 + temp[1];
6891 RT28xx_EEPROM_WRITE16(pAdapter, eepAddr, eepValue);
6892 sprintf(msg+strlen(msg), "[0x%02X]:%02X ", eepAddr, eepValue);
6896 bIsPrintAllE2P = TRUE;
6900 struct file *file_w;
6901 PCHAR fileName = "EEPROMDump.txt";
6902 mm_segment_t orig_fs;
6908 file_w = filp_open(fileName, O_WRONLY|O_CREAT, 0);
6911 DBGPRINT(RT_DEBUG_TRACE, ("-->2) %s: Error %ld opening %s\n", __FUNCTION__, -PTR_ERR(file_w), fileName));
6915 if (file_w->f_op && file_w->f_op->write)
6920 while (eepAddr <= 0xFE)
6922 RT28xx_EEPROM_READ16(pAdapter, eepAddr, eepValue);
6923 sprintf(msg, "%08x = %04x\n", eepAddr , eepValue);
6925 // write data to file
6926 file_w->f_op->write(file_w, msg, strlen(msg), &file_w->f_pos);
6931 sprintf(msg, "\nDump all EEPROM values to %s\n", fileName);
6933 filp_close(file_w, NULL);
6937 if(strlen(msg) == 1)
6938 sprintf(msg+strlen(msg), "===>Error command format!");
6941 // Copy the information into the user buffer
6942 wrq->u.data.length = strlen(msg);
6943 Status = copy_to_user(wrq->u.data.pointer, msg, wrq->u.data.length);
6945 DBGPRINT(RT_DEBUG_TRACE, ("<==RTMPIoctlE2PROM\n"));
6949 ==========================================================================
6951 Read / Write RF register
6953 pAdapter Pointer to our adapter
6954 wrq Pointer to the ioctl argument
6961 1.) iwpriv ra0 rf ==> read all RF registers
6962 2.) iwpriv ra0 rf 1 ==> read RF where RegID=1
6963 3.) iwpriv ra0 rf 1=10 ==> write RF R1=0x10
6964 ==========================================================================
6967 IN PRTMP_ADAPTER pAdapter,
6968 IN struct iwreq *wrq)
6978 BOOLEAN bIsPrintAllRF = FALSE;
6981 memset(msg, 0x00, 2048);
6982 if (wrq->u.data.length > 1) //No parameters.
6984 Status = copy_from_user(arg, wrq->u.data.pointer, (wrq->u.data.length > 255) ? 255 : wrq->u.data.length);
6987 //Parsing Read or Write
6992 if ((value = strchr(this_char, '=')) != NULL)
6995 if (!value || !*value)
6997 if (sscanf(this_char, "%d", &(rfId)) == 1)
7001 // In RT2860 ATE mode, we do not load 8051 firmware.
7002 //We must access RF directly.
7003 // For RT2870 ATE mode, ATE_RF_IO_WRITE8(/READ8)_BY_REG_ID are redefined.
7005 if (ATE_ON(pAdapter))
7007 ATE_RF_IO_READ8_BY_REG_ID(pAdapter, rfId, ®RF);
7010 #endif // RALINK_ATE //
7011 // according to Andy, Gary, David require.
7012 // the command rf shall read rf register directly for dubug.
7013 // BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, ®BBP);
7014 RT30xxReadRFRegister(pAdapter, rfId, ®RF);
7016 sprintf(msg+strlen(msg), "R%02d[0x%02x]:%02X ", rfId, rfId*2, regRF);
7019 {//Invalid parametes, so default printk all RF
7020 bIsPrintAllRF = TRUE;
7025 { //Invalid parametes, so default printk all RF
7026 bIsPrintAllRF = TRUE;
7032 if ((sscanf(this_char, "%d", &(rfId)) == 1) && (sscanf(value, "%lx", &(rfValue)) == 1))
7036 // In RT2860 ATE mode, we do not load 8051 firmware.
7037 // We should access RF registers directly.
7038 // For RT2870 ATE mode, ATE_RF_IO_WRITE8/READ8_BY_REG_ID are redefined.
7040 if (ATE_ON(pAdapter))
7042 ATE_RF_IO_READ8_BY_REG_ID(pAdapter, rfId, ®RF);
7043 ATE_RF_IO_WRITE8_BY_REG_ID(pAdapter, (UCHAR)rfId,(UCHAR) rfValue);
7044 //Read it back for showing
7045 ATE_RF_IO_READ8_BY_REG_ID(pAdapter, rfId, ®RF);
7046 sprintf(msg+strlen(msg), "R%02d[0x%02X]:%02X\n", rfId, rfId*2, regRF);
7049 #endif // RALINK_ATE //
7051 // according to Andy, Gary, David require.
7052 // the command RF shall read/write RF register directly for dubug.
7053 //BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, ®BBP);
7054 //BBP_IO_WRITE8_BY_REG_ID(pAdapter, (UCHAR)bbpId,(UCHAR) bbpValue);
7055 RT30xxReadRFRegister(pAdapter, rfId, ®RF);
7056 RT30xxWriteRFRegister(pAdapter, (UCHAR)rfId,(UCHAR) rfValue);
7057 //Read it back for showing
7058 //BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, ®BBP);
7059 RT30xxReadRFRegister(pAdapter, rfId, ®RF);
7060 sprintf(msg+strlen(msg), "R%02d[0x%02X]:%02X\n", rfId, rfId*2, regRF);
7064 {//Invalid parametes, so default printk all RF
7065 bIsPrintAllRF = TRUE;
7069 { //Invalid parametes, so default printk all RF
7070 bIsPrintAllRF = TRUE;
7075 bIsPrintAllRF = TRUE;
7079 memset(msg, 0x00, 2048);
7081 for (rfId = 0; rfId <= 31; rfId++)
7083 // In RT2860 ATE mode, we do not load 8051 firmware.
7084 // We should access RF registers directly.
7085 // For RT2870 ATE mode, ATE_RF_IO_WRITE8/READ8_BY_REG_ID are redefined.
7087 if (ATE_ON(pAdapter))
7089 ATE_RF_IO_READ8_BY_REG_ID(pAdapter, rfId, ®RF);
7092 #endif // RALINK_ATE //
7094 // according to Andy, Gary, David require.
7095 // the command RF shall read/write RF register directly for dubug.
7096 RT30xxReadRFRegister(pAdapter, rfId, ®RF);
7097 sprintf(msg+strlen(msg), "%03d = %02X\n", rfId, regRF);
7099 // Copy the information into the user buffer
7100 DBGPRINT(RT_DEBUG_TRACE, ("strlen(msg)=%d\n", (UINT32)strlen(msg)));
7101 wrq->u.data.length = strlen(msg);
7102 if (copy_to_user(wrq->u.data.pointer, msg, wrq->u.data.length))
7104 DBGPRINT(RT_DEBUG_TRACE, ("%s: copy_to_user() fail\n", __FUNCTION__));
7109 if(strlen(msg) == 1)
7110 sprintf(msg+strlen(msg), "===>Error command format!");
7112 DBGPRINT(RT_DEBUG_TRACE, ("copy to user [msg=%s]\n", msg));
7113 // Copy the information into the user buffer
7114 DBGPRINT(RT_DEBUG_TRACE, ("strlen(msg) =%d\n", (UINT32)strlen(msg)));
7116 // Copy the information into the user buffer
7117 wrq->u.data.length = strlen(msg);
7118 Status = copy_to_user(wrq->u.data.pointer, msg, wrq->u.data.length);
7121 DBGPRINT(RT_DEBUG_TRACE, ("<==RTMPIoctlRF\n\n"));
7129 INT Set_TGnWifiTest_Proc(
7130 IN PRTMP_ADAPTER pAd,
7133 if (simple_strtol(arg, 0, 10) == 0)
7134 pAd->StaCfg.bTGnWifiTest = FALSE;
7136 pAd->StaCfg.bTGnWifiTest = TRUE;
7138 DBGPRINT(RT_DEBUG_TRACE, ("IF Set_TGnWifiTest_Proc::(bTGnWifiTest=%d)\n", pAd->StaCfg.bTGnWifiTest));
7142 INT Set_LongRetryLimit_Proc(
7143 IN PRTMP_ADAPTER pAdapter,
7146 TX_RTY_CFG_STRUC tx_rty_cfg;
7147 UCHAR LongRetryLimit = (UCHAR)simple_strtol(arg, 0, 10);
7149 RTMP_IO_READ32(pAdapter, TX_RTY_CFG, &tx_rty_cfg.word);
7150 tx_rty_cfg.field.LongRtyLimit = LongRetryLimit;
7151 RTMP_IO_WRITE32(pAdapter, TX_RTY_CFG, tx_rty_cfg.word);
7152 DBGPRINT(RT_DEBUG_TRACE, ("IF Set_LongRetryLimit_Proc::(tx_rty_cfg=0x%x)\n", tx_rty_cfg.word));
7156 INT Set_ShortRetryLimit_Proc(
7157 IN PRTMP_ADAPTER pAdapter,
7160 TX_RTY_CFG_STRUC tx_rty_cfg;
7161 UCHAR ShortRetryLimit = (UCHAR)simple_strtol(arg, 0, 10);
7163 RTMP_IO_READ32(pAdapter, TX_RTY_CFG, &tx_rty_cfg.word);
7164 tx_rty_cfg.field.ShortRtyLimit = ShortRetryLimit;
7165 RTMP_IO_WRITE32(pAdapter, TX_RTY_CFG, tx_rty_cfg.word);
7166 DBGPRINT(RT_DEBUG_TRACE, ("IF Set_ShortRetryLimit_Proc::(tx_rty_cfg=0x%x)\n", tx_rty_cfg.word));
7170 #ifdef EXT_BUILD_CHANNEL_LIST
7171 INT Set_Ieee80211dClientMode_Proc(
7172 IN PRTMP_ADAPTER pAdapter,
7175 if (simple_strtol(arg, 0, 10) == 0)
7176 pAdapter->StaCfg.IEEE80211dClientMode = Rt802_11_D_None;
7177 else if (simple_strtol(arg, 0, 10) == 1)
7178 pAdapter->StaCfg.IEEE80211dClientMode = Rt802_11_D_Flexible;
7179 else if (simple_strtol(arg, 0, 10) == 2)
7180 pAdapter->StaCfg.IEEE80211dClientMode = Rt802_11_D_Strict;
7184 DBGPRINT(RT_DEBUG_TRACE, ("Set_Ieee802dMode_Proc::(IEEEE0211dMode=%d)\n", pAdapter->StaCfg.IEEE80211dClientMode));
7187 #endif // EXT_BUILD_CHANNEL_LIST //
7189 #ifdef CARRIER_DETECTION_SUPPORT
7190 INT Set_CarrierDetect_Proc(
7191 IN PRTMP_ADAPTER pAd,
7194 if (simple_strtol(arg, 0, 10) == 0)
7195 pAd->CommonCfg.CarrierDetect.Enable = FALSE;
7197 pAd->CommonCfg.CarrierDetect.Enable = TRUE;
7199 DBGPRINT(RT_DEBUG_TRACE, ("IF Set_CarrierDetect_Proc::(CarrierDetect.Enable=%d)\n", pAd->CommonCfg.CarrierDetect.Enable));
7202 #endif // CARRIER_DETECTION_SUPPORT //