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 DOT11_N_SUPPORT
329 {"TGnWifiTest", Set_TGnWifiTest_Proc},
330 {"ForceGF", Set_ForceGF_Proc},
331 #endif // DOT11_N_SUPPORT //
332 #ifdef QOS_DLS_SUPPORT
333 {"DlsAddEntry", Set_DlsAddEntry_Proc},
334 {"DlsTearDownEntry", Set_DlsTearDownEntry_Proc},
335 #endif // QOS_DLS_SUPPORT //
336 {"LongRetry", Set_LongRetryLimit_Proc},
337 {"ShortRetry", Set_ShortRetryLimit_Proc},
338 #ifdef EXT_BUILD_CHANNEL_LIST
339 {"11dClientMode", Set_Ieee80211dClientMode_Proc},
340 #endif // EXT_BUILD_CHANNEL_LIST //
341 #ifdef CARRIER_DETECTION_SUPPORT
342 {"CarrierDetect", Set_CarrierDetect_Proc},
343 #endif // CARRIER_DETECTION_SUPPORT //
344 //2008/09/11:KH add to support efuse<--
346 {"efuseFreeNumber", set_eFuseGetFreeBlockCount_Proc},
347 {"efuseDump", set_eFusedump_Proc},
348 {"efuseLoadFromBin", set_eFuseLoadFromBin_Proc},
350 //2008/09/11:KH add to support efuse-->
356 IN PRTMP_ADAPTER pAd,
357 IN PNDIS_802_11_KEY pKey)
360 MAC_TABLE_ENTRY *pEntry;
362 DBGPRINT(RT_DEBUG_TRACE, ("RTMPAddKey ------>\n"));
364 if (pAd->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
366 if (pKey->KeyIndex & 0x80000000)
368 if (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPANone)
370 NdisZeroMemory(pAd->StaCfg.PMK, 32);
371 NdisMoveMemory(pAd->StaCfg.PMK, pKey->KeyMaterial, pKey->KeyLength);
375 NdisZeroMemory(&pAd->SharedKey[BSS0][0], sizeof(CIPHER_KEY));
376 pAd->SharedKey[BSS0][0].KeyLen = LEN_TKIP_EK;
377 NdisMoveMemory(pAd->SharedKey[BSS0][0].Key, pKey->KeyMaterial, LEN_TKIP_EK);
378 #ifdef WPA_SUPPLICANT_SUPPORT
379 if (pAd->StaCfg.PairCipher == Ndis802_11Encryption2Enabled)
381 NdisMoveMemory(pAd->SharedKey[BSS0][0].RxMic, pKey->KeyMaterial + LEN_TKIP_EK, LEN_TKIP_TXMICK);
382 NdisMoveMemory(pAd->SharedKey[BSS0][0].TxMic, pKey->KeyMaterial + LEN_TKIP_EK + LEN_TKIP_TXMICK, LEN_TKIP_RXMICK);
385 #endif // WPA_SUPPLICANT_SUPPORT //
387 NdisMoveMemory(pAd->SharedKey[BSS0][0].TxMic, pKey->KeyMaterial + LEN_TKIP_EK, LEN_TKIP_TXMICK);
388 NdisMoveMemory(pAd->SharedKey[BSS0][0].RxMic, pKey->KeyMaterial + LEN_TKIP_EK + LEN_TKIP_TXMICK, LEN_TKIP_RXMICK);
391 // Decide its ChiperAlg
392 if (pAd->StaCfg.PairCipher == Ndis802_11Encryption2Enabled)
393 pAd->SharedKey[BSS0][0].CipherAlg = CIPHER_TKIP;
394 else if (pAd->StaCfg.PairCipher == Ndis802_11Encryption3Enabled)
395 pAd->SharedKey[BSS0][0].CipherAlg = CIPHER_AES;
397 pAd->SharedKey[BSS0][0].CipherAlg = CIPHER_NONE;
399 // Update these related information to MAC_TABLE_ENTRY
400 pEntry = &pAd->MacTab.Content[BSSID_WCID];
401 NdisMoveMemory(pEntry->PairwiseKey.Key, pAd->SharedKey[BSS0][0].Key, LEN_TKIP_EK);
402 NdisMoveMemory(pEntry->PairwiseKey.RxMic, pAd->SharedKey[BSS0][0].RxMic, LEN_TKIP_RXMICK);
403 NdisMoveMemory(pEntry->PairwiseKey.TxMic, pAd->SharedKey[BSS0][0].TxMic, LEN_TKIP_TXMICK);
404 pEntry->PairwiseKey.CipherAlg = pAd->SharedKey[BSS0][0].CipherAlg;
406 // Update pairwise key information to ASIC Shared Key Table
407 AsicAddSharedKeyEntry(pAd,
410 pAd->SharedKey[BSS0][0].CipherAlg,
411 pAd->SharedKey[BSS0][0].Key,
412 pAd->SharedKey[BSS0][0].TxMic,
413 pAd->SharedKey[BSS0][0].RxMic);
415 // Update ASIC WCID attribute table and IVEIV table
416 RTMPAddWcidAttributeEntry(pAd,
419 pAd->SharedKey[BSS0][0].CipherAlg,
422 if (pAd->StaCfg.AuthMode >= Ndis802_11AuthModeWPA2)
424 // set 802.1x port control
425 //pAd->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
426 STA_PORT_SECURED(pAd);
428 // Indicate Connected for GUI
429 pAd->IndicateMediaState = NdisMediaStateConnected;
435 pAd->StaCfg.DefaultKeyId = (pKey->KeyIndex & 0xFF);
436 NdisZeroMemory(&pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId], sizeof(CIPHER_KEY));
437 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].KeyLen = LEN_TKIP_EK;
438 NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].Key, pKey->KeyMaterial, LEN_TKIP_EK);
439 #ifdef WPA_SUPPLICANT_SUPPORT
440 if (pAd->StaCfg.GroupCipher == Ndis802_11Encryption2Enabled)
442 NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].RxMic, pKey->KeyMaterial + LEN_TKIP_EK, LEN_TKIP_TXMICK);
443 NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].TxMic, pKey->KeyMaterial + LEN_TKIP_EK + LEN_TKIP_TXMICK, LEN_TKIP_RXMICK);
446 #endif // WPA_SUPPLICANT_SUPPORT //
448 NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].TxMic, pKey->KeyMaterial + LEN_TKIP_EK, LEN_TKIP_TXMICK);
449 NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].RxMic, pKey->KeyMaterial + LEN_TKIP_EK + LEN_TKIP_TXMICK, LEN_TKIP_RXMICK);
452 // Update Shared Key CipherAlg
453 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg = CIPHER_NONE;
454 if (pAd->StaCfg.GroupCipher == Ndis802_11Encryption2Enabled)
455 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg = CIPHER_TKIP;
456 else if (pAd->StaCfg.GroupCipher == Ndis802_11Encryption3Enabled)
457 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg = CIPHER_AES;
459 // Update group key information to ASIC Shared Key Table
460 AsicAddSharedKeyEntry(pAd,
462 pAd->StaCfg.DefaultKeyId,
463 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg,
464 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].Key,
465 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].TxMic,
466 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].RxMic);
468 // Update ASIC WCID attribute table and IVEIV table
469 RTMPAddWcidAttributeEntry(pAd,
471 pAd->StaCfg.DefaultKeyId,
472 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg,
475 // set 802.1x port control
476 //pAd->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
477 STA_PORT_SECURED(pAd);
479 // Indicate Connected for GUI
480 pAd->IndicateMediaState = NdisMediaStateConnected;
483 else // dynamic WEP from wpa_supplicant
488 if(pKey->KeyLength == 32)
491 KeyIdx = pKey->KeyIndex & 0x0fffffff;
495 // it is a default shared key, for Pairwise key setting
496 if (pKey->KeyIndex & 0x80000000)
498 pEntry = MacTableLookup(pAd, pKey->BSSID);
502 DBGPRINT(RT_DEBUG_TRACE, ("RTMPAddKey: Set Pair-wise Key\n"));
504 // set key material and key length
505 pEntry->PairwiseKey.KeyLen = (UCHAR)pKey->KeyLength;
506 NdisMoveMemory(pEntry->PairwiseKey.Key, &pKey->KeyMaterial, pKey->KeyLength);
509 if (pKey->KeyLength == 5)
510 pEntry->PairwiseKey.CipherAlg = CIPHER_WEP64;
512 pEntry->PairwiseKey.CipherAlg = CIPHER_WEP128;
514 // Add Pair-wise key to Asic
515 AsicAddPairwiseKeyEntry(
519 &pEntry->PairwiseKey);
521 // update WCID attribute table and IVEIV table for this entry
522 RTMPAddWcidAttributeEntry(
525 KeyIdx, // The value may be not zero
526 pEntry->PairwiseKey.CipherAlg,
533 // Default key for tx (shared key)
534 pAd->StaCfg.DefaultKeyId = (UCHAR) KeyIdx;
536 // set key material and key length
537 pAd->SharedKey[BSS0][KeyIdx].KeyLen = (UCHAR) pKey->KeyLength;
538 NdisMoveMemory(pAd->SharedKey[BSS0][KeyIdx].Key, &pKey->KeyMaterial, pKey->KeyLength);
541 if (pKey->KeyLength == 5)
542 pAd->SharedKey[BSS0][KeyIdx].CipherAlg = CIPHER_WEP64;
544 pAd->SharedKey[BSS0][KeyIdx].CipherAlg = CIPHER_WEP128;
546 CipherAlg = pAd->SharedKey[BSS0][KeyIdx].CipherAlg;
547 Key = pAd->SharedKey[BSS0][KeyIdx].Key;
549 // Set Group key material to Asic
550 AsicAddSharedKeyEntry(pAd, BSS0, KeyIdx, CipherAlg, Key, NULL, NULL);
552 // Update WCID attribute table and IVEIV table for this group key table
553 RTMPAddWcidAttributeEntry(pAd, BSS0, KeyIdx, CipherAlg, NULL);
562 char * rtstrchr(const char * s, int c)
564 for(; *s != (char) c; ++s)
571 This is required for LinEX2004/kernel2.6.7 to provide iwlist scanning function
575 rt_ioctl_giwname(struct net_device *dev,
576 struct iw_request_info *info,
577 char *name, char *extra)
579 // PRTMP_ADAPTER pAdapter = dev->ml_priv;
582 strncpy(name, "RT2870 Wireless", IFNAMSIZ);
587 int rt_ioctl_siwfreq(struct net_device *dev,
588 struct iw_request_info *info,
589 struct iw_freq *freq, char *extra)
591 PRTMP_ADAPTER pAdapter = dev->ml_priv;
594 //check if the interface is down
595 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
597 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
605 if((freq->e == 0) && (freq->m <= 1000))
606 chan = freq->m; // Setting by channel number
608 MAP_KHZ_TO_CHANNEL_ID( (freq->m /100) , chan); // Setting by frequency - search the table , like 2.412G, 2.422G,
610 if (ChannelSanity(pAdapter, chan) == TRUE)
612 pAdapter->CommonCfg.Channel = chan;
613 DBGPRINT(RT_DEBUG_ERROR, ("==>rt_ioctl_siwfreq::SIOCSIWFREQ[cmd=0x%x] (Channel=%d)\n", SIOCSIWFREQ, pAdapter->CommonCfg.Channel));
620 int rt_ioctl_giwfreq(struct net_device *dev,
621 struct iw_request_info *info,
622 struct iw_freq *freq, char *extra)
624 VIRTUAL_ADAPTER *pVirtualAd = NULL;
625 PRTMP_ADAPTER pAdapter;
629 if (dev->priv_flags == INT_MAIN)
631 pAdapter = dev->ml_priv;
635 pVirtualAd = dev->ml_priv;
636 pAdapter = pVirtualAd->RtmpDev->ml_priv;
639 if (pAdapter == NULL)
641 /* if 1st open fail, pAd will be free;
642 So the net_dev->ml_priv will be NULL in 2rd open */
646 ch = pAdapter->CommonCfg.Channel;
648 DBGPRINT(RT_DEBUG_TRACE,("==>rt_ioctl_giwfreq %d\n", ch));
650 MAP_CHANNEL_ID_TO_KHZ(ch, m);
656 int rt_ioctl_siwmode(struct net_device *dev,
657 struct iw_request_info *info,
658 __u32 *mode, char *extra)
660 PRTMP_ADAPTER pAdapter = dev->ml_priv;
662 //check if the interface is down
663 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
665 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
672 Set_NetworkType_Proc(pAdapter, "Adhoc");
675 Set_NetworkType_Proc(pAdapter, "Infra");
677 case IW_MODE_MONITOR:
678 Set_NetworkType_Proc(pAdapter, "Monitor");
681 DBGPRINT(RT_DEBUG_TRACE, ("===>rt_ioctl_siwmode::SIOCSIWMODE (unknown %d)\n", *mode));
685 // Reset Ralink supplicant to not use, it will be set to start when UI set PMK key
686 pAdapter->StaCfg.WpaState = SS_NOTUSE;
691 int rt_ioctl_giwmode(struct net_device *dev,
692 struct iw_request_info *info,
693 __u32 *mode, char *extra)
695 PRTMP_ADAPTER pAdapter = dev->ml_priv;
697 if (ADHOC_ON(pAdapter))
698 *mode = IW_MODE_ADHOC;
699 else if (INFRA_ON(pAdapter))
700 *mode = IW_MODE_INFRA;
701 else if (MONITOR_ON(pAdapter))
703 *mode = IW_MODE_MONITOR;
706 *mode = IW_MODE_AUTO;
708 DBGPRINT(RT_DEBUG_TRACE, ("==>rt_ioctl_giwmode(mode=%d)\n", *mode));
712 int rt_ioctl_siwsens(struct net_device *dev,
713 struct iw_request_info *info,
714 char *name, char *extra)
716 PRTMP_ADAPTER pAdapter = dev->ml_priv;
718 //check if the interface is down
719 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
721 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
728 int rt_ioctl_giwsens(struct net_device *dev,
729 struct iw_request_info *info,
730 char *name, char *extra)
735 int rt_ioctl_giwrange(struct net_device *dev,
736 struct iw_request_info *info,
737 struct iw_point *data, char *extra)
739 PRTMP_ADAPTER pAdapter = dev->ml_priv;
741 struct iw_range *range = (struct iw_range *) extra;
745 DBGPRINT(RT_DEBUG_TRACE ,("===>rt_ioctl_giwrange\n"));
746 data->length = sizeof(struct iw_range);
747 memset(range, 0, sizeof(struct iw_range));
749 range->txpower_capa = IW_TXPOW_DBM;
751 if (INFRA_ON(pAdapter)||ADHOC_ON(pAdapter))
753 range->min_pmp = 1 * 1024;
754 range->max_pmp = 65535 * 1024;
755 range->min_pmt = 1 * 1024;
756 range->max_pmt = 1000 * 1024;
757 range->pmp_flags = IW_POWER_PERIOD;
758 range->pmt_flags = IW_POWER_TIMEOUT;
759 range->pm_capa = IW_POWER_PERIOD | IW_POWER_TIMEOUT |
760 IW_POWER_UNICAST_R | IW_POWER_ALL_R;
763 range->we_version_compiled = WIRELESS_EXT;
764 range->we_version_source = 14;
766 range->retry_capa = IW_RETRY_LIMIT;
767 range->retry_flags = IW_RETRY_LIMIT;
768 range->min_retry = 0;
769 range->max_retry = 255;
771 range->num_channels = pAdapter->ChannelListNum;
774 for (i = 1; i <= range->num_channels; i++)
777 range->freq[val].i = pAdapter->ChannelList[i-1].Channel;
778 MAP_CHANNEL_ID_TO_KHZ(pAdapter->ChannelList[i-1].Channel, m);
779 range->freq[val].m = m * 100; /* HZ */
781 range->freq[val].e = 1;
783 if (val == IW_MAX_FREQUENCIES)
786 range->num_frequency = val;
788 range->max_qual.qual = 100; /* what is correct max? This was not
789 * documented exactly. At least
790 * 69 has been observed. */
791 range->max_qual.level = 0; /* dB */
792 range->max_qual.noise = 0; /* dB */
794 /* What would be suitable values for "average/typical" qual? */
795 range->avg_qual.qual = 20;
796 range->avg_qual.level = -60;
797 range->avg_qual.noise = -95;
798 range->sensitivity = 3;
800 range->max_encoding_tokens = NR_WEP_KEYS;
801 range->num_encoding_sizes = 2;
802 range->encoding_size[0] = 5;
803 range->encoding_size[1] = 13;
806 range->max_rts = 2347;
807 range->min_frag = 256;
808 range->max_frag = 2346;
810 #if WIRELESS_EXT > 17
811 /* IW_ENC_CAPA_* bit field */
812 range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 |
813 IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP;
819 int rt_ioctl_siwap(struct net_device *dev,
820 struct iw_request_info *info,
821 struct sockaddr *ap_addr, char *extra)
823 PRTMP_ADAPTER pAdapter = dev->ml_priv;
824 NDIS_802_11_MAC_ADDRESS Bssid;
826 //check if the interface is down
827 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
829 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
833 if (pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE)
835 RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
836 DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
839 // tell CNTL state machine to call NdisMSetInformationComplete() after completing
840 // this request, because this request is initiated by NDIS.
841 pAdapter->MlmeAux.CurrReqIsFromNdis = FALSE;
842 // Prevent to connect AP again in STAMlmePeriodicExec
843 pAdapter->MlmeAux.AutoReconnectSsidLen= 32;
845 memset(Bssid, 0, MAC_ADDR_LEN);
846 memcpy(Bssid, ap_addr->sa_data, MAC_ADDR_LEN);
847 MlmeEnqueue(pAdapter,
848 MLME_CNTL_STATE_MACHINE,
850 sizeof(NDIS_802_11_MAC_ADDRESS),
853 DBGPRINT(RT_DEBUG_TRACE, ("IOCTL::SIOCSIWAP %02x:%02x:%02x:%02x:%02x:%02x\n",
854 Bssid[0], Bssid[1], Bssid[2], Bssid[3], Bssid[4], Bssid[5]));
859 int rt_ioctl_giwap(struct net_device *dev,
860 struct iw_request_info *info,
861 struct sockaddr *ap_addr, char *extra)
863 PRTMP_ADAPTER pAdapter = dev->ml_priv;
865 if (INFRA_ON(pAdapter) || ADHOC_ON(pAdapter))
867 ap_addr->sa_family = ARPHRD_ETHER;
868 memcpy(ap_addr->sa_data, &pAdapter->CommonCfg.Bssid, ETH_ALEN);
870 #ifdef WPA_SUPPLICANT_SUPPORT
872 else if (pAdapter->StaCfg.WpaSupplicantUP != WPA_SUPPLICANT_DISABLE)
874 ap_addr->sa_family = ARPHRD_ETHER;
875 memcpy(ap_addr->sa_data, &pAdapter->MlmeAux.Bssid, ETH_ALEN);
877 #endif // WPA_SUPPLICANT_SUPPORT //
880 DBGPRINT(RT_DEBUG_TRACE, ("IOCTL::SIOCGIWAP(=EMPTY)\n"));
888 * Units are in db above the noise floor. That means the
889 * rssi values reported in the tx/rx descriptors in the
890 * driver are the SNR expressed in db.
892 * If you assume that the noise floor is -95, which is an
893 * excellent assumption 99.5 % of the time, then you can
894 * derive the absolute signal level (i.e. -95 + rssi).
895 * There are some other slight factors to take into account
896 * depending on whether the rssi measurement is from 11b,
897 * 11g, or 11a. These differences are at most 2db and
900 * NB: various calculations are based on the orinoco/wavelan
901 * drivers for compatibility
903 static void set_quality(PRTMP_ADAPTER pAdapter,
904 struct iw_quality *iq,
911 ChannelQuality = 100;
912 else if (rssi >= -80) // between -50 ~ -80dbm
913 ChannelQuality = (__u8)(24 + ((rssi + 80) * 26)/10);
914 else if (rssi >= -90) // between -80 ~ -90dbm
915 ChannelQuality = (__u8)((rssi + 90) * 26)/10;
919 iq->qual = (__u8)ChannelQuality;
921 iq->level = (__u8)(rssi);
922 iq->noise = (pAdapter->BbpWriteLatch[66] > pAdapter->BbpTuning.FalseCcaUpperThreshold) ? ((__u8)pAdapter->BbpTuning.FalseCcaUpperThreshold) : ((__u8) pAdapter->BbpWriteLatch[66]); // noise level (dBm)
923 iq->noise += 256 - 143;
924 iq->updated = pAdapter->iw_stats.qual.updated;
927 int rt_ioctl_iwaplist(struct net_device *dev,
928 struct iw_request_info *info,
929 struct iw_point *data, char *extra)
931 PRTMP_ADAPTER pAdapter = dev->ml_priv;
933 struct sockaddr addr[IW_MAX_AP];
934 struct iw_quality qual[IW_MAX_AP];
937 //check if the interface is down
938 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
940 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
946 for (i = 0; i <IW_MAX_AP ; i++)
948 if (i >= pAdapter->ScanTab.BssNr)
950 addr[i].sa_family = ARPHRD_ETHER;
951 memcpy(addr[i].sa_data, &pAdapter->ScanTab.BssEntry[i].Bssid, MAC_ADDR_LEN);
952 set_quality(pAdapter, &qual[i], pAdapter->ScanTab.BssEntry[i].Rssi);
955 memcpy(extra, &addr, i*sizeof(addr[0]));
956 data->flags = 1; /* signal quality present (sort of) */
957 memcpy(extra + i*sizeof(addr[0]), &qual, i*sizeof(qual[i]));
963 int rt_ioctl_siwscan(struct net_device *dev,
964 struct iw_request_info *info,
965 struct iw_point *data, char *extra)
967 PRTMP_ADAPTER pAdapter = dev->ml_priv;
970 int Status = NDIS_STATUS_SUCCESS;
972 //check if the interface is down
973 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
975 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
979 if (MONITOR_ON(pAdapter))
981 DBGPRINT(RT_DEBUG_TRACE, ("!!! Driver is in Monitor Mode now !!!\n"));
986 #ifdef WPA_SUPPLICANT_SUPPORT
987 if (pAdapter->StaCfg.WpaSupplicantUP == WPA_SUPPLICANT_ENABLE)
989 pAdapter->StaCfg.WpaSupplicantScanCount++;
991 #endif // WPA_SUPPLICANT_SUPPORT //
993 pAdapter->StaCfg.bScanReqIsFromWebUI = TRUE;
994 if (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
999 #ifdef WPA_SUPPLICANT_SUPPORT
1000 if ((pAdapter->StaCfg.WpaSupplicantUP == WPA_SUPPLICANT_ENABLE) &&
1001 (pAdapter->StaCfg.WpaSupplicantScanCount > 3))
1003 DBGPRINT(RT_DEBUG_TRACE, ("!!! WpaSupplicantScanCount > 3\n"));
1004 Status = NDIS_STATUS_SUCCESS;
1007 #endif // WPA_SUPPLICANT_SUPPORT //
1009 if ((OPSTATUS_TEST_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED)) &&
1010 ((pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA) ||
1011 (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK)) &&
1012 (pAdapter->StaCfg.PortSecured == WPA_802_1X_PORT_NOT_SECURED))
1014 DBGPRINT(RT_DEBUG_TRACE, ("!!! Link UP, Port Not Secured! ignore this set::OID_802_11_BSSID_LIST_SCAN\n"));
1015 Status = NDIS_STATUS_SUCCESS;
1019 if (pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE)
1021 RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
1022 DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
1025 // tell CNTL state machine to call NdisMSetInformationComplete() after completing
1026 // this request, because this request is initiated by NDIS.
1027 pAdapter->MlmeAux.CurrReqIsFromNdis = FALSE;
1028 // Reset allowed scan retries
1029 pAdapter->StaCfg.ScanCnt = 0;
1030 pAdapter->StaCfg.LastScanTime = Now;
1032 MlmeEnqueue(pAdapter,
1033 MLME_CNTL_STATE_MACHINE,
1034 OID_802_11_BSSID_LIST_SCAN,
1038 Status = NDIS_STATUS_SUCCESS;
1039 RT28XX_MLME_HANDLER(pAdapter);
1044 int rt_ioctl_giwscan(struct net_device *dev,
1045 struct iw_request_info *info,
1046 struct iw_point *data, char *extra)
1049 PRTMP_ADAPTER pAdapter = dev->ml_priv;
1051 char *current_ev = extra, *previous_ev = extra;
1053 char *current_val, custom[MAX_CUSTOM_LEN] = {0};
1056 #endif // IWEVGENIE //
1057 struct iw_event iwe;
1059 if (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
1062 * Still scanning, indicate the caller should try again.
1068 #ifdef WPA_SUPPLICANT_SUPPORT
1069 if (pAdapter->StaCfg.WpaSupplicantUP == WPA_SUPPLICANT_ENABLE)
1071 pAdapter->StaCfg.WpaSupplicantScanCount = 0;
1073 #endif // WPA_SUPPLICANT_SUPPORT //
1075 if (pAdapter->ScanTab.BssNr == 0)
1081 #if WIRELESS_EXT >= 17
1082 if (data->length > 0)
1083 end_buf = extra + data->length;
1085 end_buf = extra + IW_SCAN_MAX_DATA;
1087 end_buf = extra + IW_SCAN_MAX_DATA;
1090 for (i = 0; i < pAdapter->ScanTab.BssNr; i++)
1092 if (current_ev >= end_buf)
1094 #if WIRELESS_EXT >= 17
1102 //================================
1103 memset(&iwe, 0, sizeof(iwe));
1104 iwe.cmd = SIOCGIWAP;
1105 iwe.u.ap_addr.sa_family = ARPHRD_ETHER;
1106 memcpy(iwe.u.ap_addr.sa_data, &pAdapter->ScanTab.BssEntry[i].Bssid, ETH_ALEN);
1108 previous_ev = current_ev;
1109 current_ev = iwe_stream_add_event(info, current_ev, end_buf, &iwe, IW_EV_ADDR_LEN);
1110 if (current_ev == previous_ev)
1111 #if WIRELESS_EXT >= 17
1119 it will show scanned AP's WirelessMode .
1128 memset(&iwe, 0, sizeof(iwe));
1129 iwe.cmd = SIOCGIWNAME;
1133 PBSS_ENTRY pBssEntry=&pAdapter->ScanTab.BssEntry[i];
1134 BOOLEAN isGonly=FALSE;
1137 if (pBssEntry->Channel>14)
1139 if (pBssEntry->HtCapabilityLen!=0)
1140 strcpy(iwe.u.name,"802.11a/n");
1142 strcpy(iwe.u.name,"802.11a");
1147 if one of non B mode rate is set supported rate . it mean G only.
1149 for (rateCnt=0;rateCnt<pBssEntry->SupRateLen;rateCnt++)
1152 6Mbps(140) 9Mbps(146) and >=12Mbps(152) are supported rate , it mean G only.
1154 if (pBssEntry->SupRate[rateCnt]==140 || pBssEntry->SupRate[rateCnt]==146 || pBssEntry->SupRate[rateCnt]>=152)
1158 for (rateCnt=0;rateCnt<pBssEntry->ExtRateLen;rateCnt++)
1160 if (pBssEntry->ExtRate[rateCnt]==140 || pBssEntry->ExtRate[rateCnt]==146 || pBssEntry->ExtRate[rateCnt]>=152)
1165 if (pBssEntry->HtCapabilityLen!=0)
1168 strcpy(iwe.u.name,"802.11g/n");
1170 strcpy(iwe.u.name,"802.11b/g/n");
1175 strcpy(iwe.u.name,"802.11g");
1178 if (pBssEntry->SupRateLen==4 && pBssEntry->ExtRateLen==0)
1179 strcpy(iwe.u.name,"802.11b");
1181 strcpy(iwe.u.name,"802.11b/g");
1187 previous_ev = current_ev;
1188 current_ev = iwe_stream_add_event(info, current_ev, end_buf, &iwe, IW_EV_ADDR_LEN);
1189 if (current_ev == previous_ev)
1190 #if WIRELESS_EXT >= 17
1197 //================================
1198 memset(&iwe, 0, sizeof(iwe));
1199 iwe.cmd = SIOCGIWESSID;
1200 iwe.u.data.length = pAdapter->ScanTab.BssEntry[i].SsidLen;
1201 iwe.u.data.flags = 1;
1203 previous_ev = current_ev;
1204 current_ev = iwe_stream_add_point(info, current_ev, end_buf, &iwe, pAdapter->ScanTab.BssEntry[i].Ssid);
1205 if (current_ev == previous_ev)
1206 #if WIRELESS_EXT >= 17
1213 //================================
1214 memset(&iwe, 0, sizeof(iwe));
1215 iwe.cmd = SIOCGIWMODE;
1216 if (pAdapter->ScanTab.BssEntry[i].BssType == Ndis802_11IBSS)
1218 iwe.u.mode = IW_MODE_ADHOC;
1220 else if (pAdapter->ScanTab.BssEntry[i].BssType == Ndis802_11Infrastructure)
1222 iwe.u.mode = IW_MODE_INFRA;
1226 iwe.u.mode = IW_MODE_AUTO;
1228 iwe.len = IW_EV_UINT_LEN;
1230 previous_ev = current_ev;
1231 current_ev = iwe_stream_add_event(info, current_ev, end_buf, &iwe, IW_EV_UINT_LEN);
1232 if (current_ev == previous_ev)
1233 #if WIRELESS_EXT >= 17
1239 //Channel and Frequency
1240 //================================
1241 memset(&iwe, 0, sizeof(iwe));
1242 iwe.cmd = SIOCGIWFREQ;
1243 if (INFRA_ON(pAdapter) || ADHOC_ON(pAdapter))
1244 iwe.u.freq.m = pAdapter->ScanTab.BssEntry[i].Channel;
1246 iwe.u.freq.m = pAdapter->ScanTab.BssEntry[i].Channel;
1250 previous_ev = current_ev;
1251 current_ev = iwe_stream_add_event(info, current_ev, end_buf, &iwe, IW_EV_FREQ_LEN);
1252 if (current_ev == previous_ev)
1253 #if WIRELESS_EXT >= 17
1259 //Add quality statistics
1260 //================================
1261 memset(&iwe, 0, sizeof(iwe));
1263 iwe.u.qual.level = 0;
1264 iwe.u.qual.noise = 0;
1265 set_quality(pAdapter, &iwe.u.qual, pAdapter->ScanTab.BssEntry[i].Rssi);
1266 current_ev = iwe_stream_add_event(info, current_ev, end_buf, &iwe, IW_EV_QUAL_LEN);
1267 if (current_ev == previous_ev)
1268 #if WIRELESS_EXT >= 17
1275 //================================
1276 memset(&iwe, 0, sizeof(iwe));
1277 iwe.cmd = SIOCGIWENCODE;
1278 if (CAP_IS_PRIVACY_ON (pAdapter->ScanTab.BssEntry[i].CapabilityInfo ))
1279 iwe.u.data.flags =IW_ENCODE_ENABLED | IW_ENCODE_NOKEY;
1281 iwe.u.data.flags = IW_ENCODE_DISABLED;
1283 previous_ev = current_ev;
1284 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);
1285 if (current_ev == previous_ev)
1286 #if WIRELESS_EXT >= 17
1293 //================================
1294 if (pAdapter->ScanTab.BssEntry[i].SupRateLen)
1296 UCHAR tmpRate = pAdapter->ScanTab.BssEntry[i].SupRate[pAdapter->ScanTab.BssEntry[i].SupRateLen-1];
1297 memset(&iwe, 0, sizeof(iwe));
1298 iwe.cmd = SIOCGIWRATE;
1299 current_val = current_ev + IW_EV_LCP_LEN;
1300 if (tmpRate == 0x82)
1301 iwe.u.bitrate.value = 1 * 1000000;
1302 else if (tmpRate == 0x84)
1303 iwe.u.bitrate.value = 2 * 1000000;
1304 else if (tmpRate == 0x8B)
1305 iwe.u.bitrate.value = 5.5 * 1000000;
1306 else if (tmpRate == 0x96)
1307 iwe.u.bitrate.value = 11 * 1000000;
1309 iwe.u.bitrate.value = (tmpRate/2) * 1000000;
1311 iwe.u.bitrate.disabled = 0;
1312 current_val = iwe_stream_add_value(info, current_ev,
1313 current_val, end_buf, &iwe,
1316 if((current_val-current_ev)>IW_EV_LCP_LEN)
1317 current_ev = current_val;
1319 #if WIRELESS_EXT >= 17
1328 if (pAdapter->ScanTab.BssEntry[i].WpaIE.IELen > 0)
1330 memset(&iwe, 0, sizeof(iwe));
1331 memset(&custom[0], 0, MAX_CUSTOM_LEN);
1332 memcpy(custom, &(pAdapter->ScanTab.BssEntry[i].WpaIE.IE[0]),
1333 pAdapter->ScanTab.BssEntry[i].WpaIE.IELen);
1334 iwe.cmd = IWEVGENIE;
1335 iwe.u.data.length = pAdapter->ScanTab.BssEntry[i].WpaIE.IELen;
1336 current_ev = iwe_stream_add_point(info, current_ev, end_buf, &iwe, custom);
1337 if (current_ev == previous_ev)
1338 #if WIRELESS_EXT >= 17
1346 if (pAdapter->ScanTab.BssEntry[i].RsnIE.IELen > 0)
1348 memset(&iwe, 0, sizeof(iwe));
1349 memset(&custom[0], 0, MAX_CUSTOM_LEN);
1350 memcpy(custom, &(pAdapter->ScanTab.BssEntry[i].RsnIE.IE[0]),
1351 pAdapter->ScanTab.BssEntry[i].RsnIE.IELen);
1352 iwe.cmd = IWEVGENIE;
1353 iwe.u.data.length = pAdapter->ScanTab.BssEntry[i].RsnIE.IELen;
1354 current_ev = iwe_stream_add_point(info, current_ev, end_buf, &iwe, custom);
1355 if (current_ev == previous_ev)
1356 #if WIRELESS_EXT >= 17
1364 //================================
1365 if (pAdapter->ScanTab.BssEntry[i].WpaIE.IELen > 0)
1367 NdisZeroMemory(&iwe, sizeof(iwe));
1368 memset(&custom[0], 0, MAX_CUSTOM_LEN);
1369 iwe.cmd = IWEVCUSTOM;
1370 iwe.u.data.length = (pAdapter->ScanTab.BssEntry[i].WpaIE.IELen * 2) + 7;
1371 NdisMoveMemory(custom, "wpa_ie=", 7);
1372 for (idx = 0; idx < pAdapter->ScanTab.BssEntry[i].WpaIE.IELen; idx++)
1373 sprintf(custom, "%s%02x", custom, pAdapter->ScanTab.BssEntry[i].WpaIE.IE[idx]);
1374 previous_ev = current_ev;
1375 current_ev = iwe_stream_add_point(current_ev, end_buf, &iwe, custom);
1376 if (current_ev == previous_ev)
1377 #if WIRELESS_EXT >= 17
1385 if (pAdapter->ScanTab.BssEntry[i].RsnIE.IELen > 0)
1387 NdisZeroMemory(&iwe, sizeof(iwe));
1388 memset(&custom[0], 0, MAX_CUSTOM_LEN);
1389 iwe.cmd = IWEVCUSTOM;
1390 iwe.u.data.length = (pAdapter->ScanTab.BssEntry[i].RsnIE.IELen * 2) + 7;
1391 NdisMoveMemory(custom, "rsn_ie=", 7);
1392 for (idx = 0; idx < pAdapter->ScanTab.BssEntry[i].RsnIE.IELen; idx++)
1393 sprintf(custom, "%s%02x", custom, pAdapter->ScanTab.BssEntry[i].RsnIE.IE[idx]);
1394 previous_ev = current_ev;
1395 current_ev = iwe_stream_add_point(current_ev, end_buf, &iwe, custom);
1396 if (current_ev == previous_ev)
1397 #if WIRELESS_EXT >= 17
1403 #endif // IWEVGENIE //
1406 data->length = current_ev - extra;
1407 pAdapter->StaCfg.bScanReqIsFromWebUI = FALSE;
1408 DBGPRINT(RT_DEBUG_ERROR ,("===>rt_ioctl_giwscan. %d(%d) BSS returned, data->length = %d\n",i , pAdapter->ScanTab.BssNr, data->length));
1413 int rt_ioctl_siwessid(struct net_device *dev,
1414 struct iw_request_info *info,
1415 struct iw_point *data, char *essid)
1417 PRTMP_ADAPTER pAdapter = dev->ml_priv;
1419 //check if the interface is down
1420 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1422 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1428 PCHAR pSsidString = NULL;
1430 // Includes null character.
1431 if (data->length > (IW_ESSID_MAX_SIZE + 1))
1434 pSsidString = (CHAR *) kmalloc(MAX_LEN_OF_SSID+1, MEM_ALLOC_FLAG);
1437 NdisZeroMemory(pSsidString, MAX_LEN_OF_SSID+1);
1438 NdisMoveMemory(pSsidString, essid, data->length);
1439 if (Set_SSID_Proc(pAdapter, pSsidString) == FALSE)
1448 if (Set_SSID_Proc(pAdapter, "") == FALSE)
1454 int rt_ioctl_giwessid(struct net_device *dev,
1455 struct iw_request_info *info,
1456 struct iw_point *data, char *essid)
1458 PRTMP_ADAPTER pAdapter = dev->ml_priv;
1461 if (MONITOR_ON(pAdapter))
1467 if (OPSTATUS_TEST_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED))
1469 DBGPRINT(RT_DEBUG_TRACE ,("MediaState is connected\n"));
1470 data->length = pAdapter->CommonCfg.SsidLen;
1471 memcpy(essid, pAdapter->CommonCfg.Ssid, pAdapter->CommonCfg.SsidLen);
1474 #ifdef WPA_SUPPLICANT_SUPPORT
1476 else if (pAdapter->StaCfg.WpaSupplicantUP != WPA_SUPPLICANT_DISABLE)
1478 data->length = pAdapter->CommonCfg.SsidLen;
1479 memcpy(essid, pAdapter->CommonCfg.Ssid, pAdapter->CommonCfg.SsidLen);
1481 #endif // WPA_SUPPLICANT_SUPPORT //
1484 {//the ANY ssid was specified
1486 DBGPRINT(RT_DEBUG_TRACE ,("MediaState is not connected, ess\n"));
1493 int rt_ioctl_siwnickn(struct net_device *dev,
1494 struct iw_request_info *info,
1495 struct iw_point *data, char *nickname)
1497 PRTMP_ADAPTER pAdapter = dev->ml_priv;
1499 //check if the interface is down
1500 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1502 DBGPRINT(RT_DEBUG_TRACE ,("INFO::Network is down!\n"));
1506 if (data->length > IW_ESSID_MAX_SIZE)
1509 memset(pAdapter->nickname, 0, IW_ESSID_MAX_SIZE + 1);
1510 memcpy(pAdapter->nickname, nickname, data->length);
1516 int rt_ioctl_giwnickn(struct net_device *dev,
1517 struct iw_request_info *info,
1518 struct iw_point *data, char *nickname)
1520 PRTMP_ADAPTER pAdapter = dev->ml_priv;
1522 if (data->length > strlen(pAdapter->nickname) + 1)
1523 data->length = strlen(pAdapter->nickname) + 1;
1524 if (data->length > 0) {
1525 memcpy(nickname, pAdapter->nickname, data->length-1);
1526 nickname[data->length-1] = '\0';
1531 int rt_ioctl_siwrts(struct net_device *dev,
1532 struct iw_request_info *info,
1533 struct iw_param *rts, char *extra)
1535 PRTMP_ADAPTER pAdapter = dev->ml_priv;
1538 //check if the interface is down
1539 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1541 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1546 val = MAX_RTS_THRESHOLD;
1547 else if (rts->value < 0 || rts->value > MAX_RTS_THRESHOLD)
1549 else if (rts->value == 0)
1550 val = MAX_RTS_THRESHOLD;
1554 if (val != pAdapter->CommonCfg.RtsThreshold)
1555 pAdapter->CommonCfg.RtsThreshold = val;
1560 int rt_ioctl_giwrts(struct net_device *dev,
1561 struct iw_request_info *info,
1562 struct iw_param *rts, char *extra)
1564 PRTMP_ADAPTER pAdapter = dev->ml_priv;
1566 //check if the interface is down
1567 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1569 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1573 rts->value = pAdapter->CommonCfg.RtsThreshold;
1574 rts->disabled = (rts->value == MAX_RTS_THRESHOLD);
1580 int rt_ioctl_siwfrag(struct net_device *dev,
1581 struct iw_request_info *info,
1582 struct iw_param *frag, char *extra)
1584 PRTMP_ADAPTER pAdapter = dev->ml_priv;
1587 //check if the interface is down
1588 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1590 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1595 val = MAX_FRAG_THRESHOLD;
1596 else if (frag->value >= MIN_FRAG_THRESHOLD || frag->value <= MAX_FRAG_THRESHOLD)
1597 val = __cpu_to_le16(frag->value & ~0x1); /* even numbers only */
1598 else if (frag->value == 0)
1599 val = MAX_FRAG_THRESHOLD;
1603 pAdapter->CommonCfg.FragmentThreshold = val;
1607 int rt_ioctl_giwfrag(struct net_device *dev,
1608 struct iw_request_info *info,
1609 struct iw_param *frag, char *extra)
1611 PRTMP_ADAPTER pAdapter = dev->ml_priv;
1613 //check if the interface is down
1614 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1616 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1620 frag->value = pAdapter->CommonCfg.FragmentThreshold;
1621 frag->disabled = (frag->value == MAX_FRAG_THRESHOLD);
1627 #define MAX_WEP_KEY_SIZE 13
1628 #define MIN_WEP_KEY_SIZE 5
1629 int rt_ioctl_siwencode(struct net_device *dev,
1630 struct iw_request_info *info,
1631 struct iw_point *erq, char *extra)
1633 PRTMP_ADAPTER pAdapter = dev->ml_priv;
1635 //check if the interface is down
1636 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1638 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1642 if ((erq->length == 0) &&
1643 (erq->flags & IW_ENCODE_DISABLED))
1645 pAdapter->StaCfg.PairCipher = Ndis802_11WEPDisabled;
1646 pAdapter->StaCfg.GroupCipher = Ndis802_11WEPDisabled;
1647 pAdapter->StaCfg.WepStatus = Ndis802_11WEPDisabled;
1648 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
1649 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
1652 else if (erq->flags & IW_ENCODE_RESTRICTED || erq->flags & IW_ENCODE_OPEN)
1654 //pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
1655 STA_PORT_SECURED(pAdapter);
1656 pAdapter->StaCfg.PairCipher = Ndis802_11WEPEnabled;
1657 pAdapter->StaCfg.GroupCipher = Ndis802_11WEPEnabled;
1658 pAdapter->StaCfg.WepStatus = Ndis802_11WEPEnabled;
1659 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
1660 if (erq->flags & IW_ENCODE_RESTRICTED)
1661 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeShared;
1663 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
1666 if (erq->length > 0)
1668 int keyIdx = (erq->flags & IW_ENCODE_INDEX) - 1;
1669 /* Check the size of the key */
1670 if (erq->length > MAX_WEP_KEY_SIZE)
1674 /* Check key index */
1675 if ((keyIdx < 0) || (keyIdx >= NR_WEP_KEYS))
1677 DBGPRINT(RT_DEBUG_TRACE ,("==>rt_ioctl_siwencode::Wrong keyIdx=%d! Using default key instead (%d)\n",
1678 keyIdx, pAdapter->StaCfg.DefaultKeyId));
1681 keyIdx = pAdapter->StaCfg.DefaultKeyId;
1685 pAdapter->StaCfg.DefaultKeyId=keyIdx;
1688 NdisZeroMemory(pAdapter->SharedKey[BSS0][keyIdx].Key, 16);
1690 if (erq->length == MAX_WEP_KEY_SIZE)
1692 pAdapter->SharedKey[BSS0][keyIdx].KeyLen = MAX_WEP_KEY_SIZE;
1693 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CIPHER_WEP128;
1695 else if (erq->length == MIN_WEP_KEY_SIZE)
1697 pAdapter->SharedKey[BSS0][keyIdx].KeyLen = MIN_WEP_KEY_SIZE;
1698 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CIPHER_WEP64;
1701 /* Disable the key */
1702 pAdapter->SharedKey[BSS0][keyIdx].KeyLen = 0;
1704 /* Check if the key is not marked as invalid */
1705 if(!(erq->flags & IW_ENCODE_NOKEY))
1707 /* Copy the key in the driver */
1708 NdisMoveMemory(pAdapter->SharedKey[BSS0][keyIdx].Key, extra, erq->length);
1713 /* Do we want to just set the transmit key index ? */
1714 int index = (erq->flags & IW_ENCODE_INDEX) - 1;
1715 if ((index >= 0) && (index < 4))
1717 pAdapter->StaCfg.DefaultKeyId = index;
1720 /* Don't complain if only change the mode */
1721 if (!(erq->flags & IW_ENCODE_MODE))
1726 DBGPRINT(RT_DEBUG_TRACE ,("==>rt_ioctl_siwencode::erq->flags=%x\n",erq->flags));
1727 DBGPRINT(RT_DEBUG_TRACE ,("==>rt_ioctl_siwencode::AuthMode=%x\n",pAdapter->StaCfg.AuthMode));
1728 DBGPRINT(RT_DEBUG_TRACE ,("==>rt_ioctl_siwencode::DefaultKeyId=%x, KeyLen = %d\n",pAdapter->StaCfg.DefaultKeyId , pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].KeyLen));
1729 DBGPRINT(RT_DEBUG_TRACE ,("==>rt_ioctl_siwencode::WepStatus=%x\n",pAdapter->StaCfg.WepStatus));
1734 rt_ioctl_giwencode(struct net_device *dev,
1735 struct iw_request_info *info,
1736 struct iw_point *erq, char *key)
1738 PRTMP_ADAPTER pAdapter = dev->ml_priv;
1741 //check if the interface is down
1742 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1744 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1748 kid = erq->flags & IW_ENCODE_INDEX;
1749 DBGPRINT(RT_DEBUG_TRACE, ("===>rt_ioctl_giwencode %d\n", erq->flags & IW_ENCODE_INDEX));
1751 if (pAdapter->StaCfg.WepStatus == Ndis802_11WEPDisabled)
1754 erq->flags = IW_ENCODE_DISABLED;
1756 else if ((kid > 0) && (kid <=4))
1759 erq->flags = kid ; /* NB: base 1 */
1760 if (erq->length > pAdapter->SharedKey[BSS0][kid-1].KeyLen)
1761 erq->length = pAdapter->SharedKey[BSS0][kid-1].KeyLen;
1762 memcpy(key, pAdapter->SharedKey[BSS0][kid-1].Key, erq->length);
1763 //if ((kid == pAdapter->PortCfg.DefaultKeyId))
1764 //erq->flags |= IW_ENCODE_ENABLED; /* XXX */
1765 if (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeShared)
1766 erq->flags |= IW_ENCODE_RESTRICTED; /* XXX */
1768 erq->flags |= IW_ENCODE_OPEN; /* XXX */
1773 if (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeShared)
1774 erq->flags |= IW_ENCODE_RESTRICTED; /* XXX */
1776 erq->flags |= IW_ENCODE_OPEN; /* XXX */
1777 erq->length = pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].KeyLen;
1778 memcpy(key, pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].Key, erq->length);
1779 // copy default key ID
1780 if (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeShared)
1781 erq->flags |= IW_ENCODE_RESTRICTED; /* XXX */
1783 erq->flags |= IW_ENCODE_OPEN; /* XXX */
1784 erq->flags = pAdapter->StaCfg.DefaultKeyId + 1; /* NB: base 1 */
1785 erq->flags |= IW_ENCODE_ENABLED; /* XXX */
1793 rt_ioctl_setparam(struct net_device *dev, struct iw_request_info *info,
1794 void *w, char *extra)
1796 VIRTUAL_ADAPTER *pVirtualAd = NULL;
1797 PRTMP_ADAPTER pAdapter;
1799 char *this_char = extra;
1803 if (dev->priv_flags == INT_MAIN)
1805 pAdapter = dev->ml_priv;
1809 pVirtualAd = dev->ml_priv;
1810 pAdapter = pVirtualAd->RtmpDev->ml_priv;
1812 pObj = (POS_COOKIE) pAdapter->OS_Cookie;
1814 if (pAdapter == NULL)
1816 /* if 1st open fail, pAd will be free;
1817 So the net_dev->ml_priv will be NULL in 2rd open */
1822 pObj->ioctl_if_type = INT_MAIN;
1823 pObj->ioctl_if = MAIN_MBSSID;
1826 //check if the interface is down
1827 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1829 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1836 if ((value = rtstrchr(this_char, '=')) != NULL)
1842 // reject setting nothing besides ANY ssid(ssidLen=0)
1843 if (!*value && (strcmp(this_char, "SSID") != 0))
1846 for (PRTMP_PRIVATE_SET_PROC = RTMP_PRIVATE_SUPPORT_PROC; PRTMP_PRIVATE_SET_PROC->name; PRTMP_PRIVATE_SET_PROC++)
1848 if (strcmp(this_char, PRTMP_PRIVATE_SET_PROC->name) == 0)
1850 if(!PRTMP_PRIVATE_SET_PROC->set_proc(pAdapter, value))
1851 { //FALSE:Set private failed then return Invalid argument
1854 break; //Exit for loop.
1858 if(PRTMP_PRIVATE_SET_PROC->name == NULL)
1859 { //Not found argument
1861 DBGPRINT(RT_DEBUG_TRACE, ("===>rt_ioctl_setparam:: (iwpriv) Not Support Set Command [%s=%s]\n", this_char, value));
1869 rt_private_get_statistics(struct net_device *dev, struct iw_request_info *info,
1870 struct iw_point *wrq, char *extra)
1873 PRTMP_ADAPTER pAd = dev->ml_priv;
1881 memset(extra, 0x00, IW_PRIV_SIZE_MASK);
1882 sprintf(extra, "\n\n");
1887 sprintf(extra+strlen(extra), "Tx success = %ld\n", (ULONG)pAd->ate.TxDoneCount);
1888 //sprintf(extra+strlen(extra), "Tx success without retry = %ld\n", (ULONG)pAd->ate.TxDoneCount);
1891 #endif // RALINK_ATE //
1893 sprintf(extra+strlen(extra), "Tx success = %ld\n", (ULONG)pAd->WlanCounters.TransmittedFragmentCount.QuadPart);
1894 sprintf(extra+strlen(extra), "Tx success without retry = %ld\n", (ULONG)pAd->WlanCounters.TransmittedFragmentCount.QuadPart - (ULONG)pAd->WlanCounters.RetryCount.QuadPart);
1896 sprintf(extra+strlen(extra), "Tx success after retry = %ld\n", (ULONG)pAd->WlanCounters.RetryCount.QuadPart);
1897 sprintf(extra+strlen(extra), "Tx fail to Rcv ACK after retry = %ld\n", (ULONG)pAd->WlanCounters.FailedCount.QuadPart);
1898 sprintf(extra+strlen(extra), "RTS Success Rcv CTS = %ld\n", (ULONG)pAd->WlanCounters.RTSSuccessCount.QuadPart);
1899 sprintf(extra+strlen(extra), "RTS Fail Rcv CTS = %ld\n", (ULONG)pAd->WlanCounters.RTSFailureCount.QuadPart);
1901 sprintf(extra+strlen(extra), "Rx success = %ld\n", (ULONG)pAd->WlanCounters.ReceivedFragmentCount.QuadPart);
1902 sprintf(extra+strlen(extra), "Rx with CRC = %ld\n", (ULONG)pAd->WlanCounters.FCSErrorCount.QuadPart);
1903 sprintf(extra+strlen(extra), "Rx drop due to out of resource = %ld\n", (ULONG)pAd->Counters8023.RxNoBuffer);
1904 sprintf(extra+strlen(extra), "Rx duplicate frame = %ld\n", (ULONG)pAd->WlanCounters.FrameDuplicateCount.QuadPart);
1906 sprintf(extra+strlen(extra), "False CCA (one second) = %ld\n", (ULONG)pAd->RalinkCounters.OneSecFalseCCACnt);
1910 if (pAd->ate.RxAntennaSel == 0)
1912 sprintf(extra+strlen(extra), "RSSI-A = %ld\n", (LONG)(pAd->ate.LastRssi0 - pAd->BbpRssiToDbmDelta));
1913 sprintf(extra+strlen(extra), "RSSI-B (if available) = %ld\n", (LONG)(pAd->ate.LastRssi1 - pAd->BbpRssiToDbmDelta));
1914 sprintf(extra+strlen(extra), "RSSI-C (if available) = %ld\n\n", (LONG)(pAd->ate.LastRssi2 - pAd->BbpRssiToDbmDelta));
1918 sprintf(extra+strlen(extra), "RSSI = %ld\n", (LONG)(pAd->ate.LastRssi0 - pAd->BbpRssiToDbmDelta));
1922 #endif // RALINK_ATE //
1924 sprintf(extra+strlen(extra), "RSSI-A = %ld\n", (LONG)(pAd->StaCfg.RssiSample.LastRssi0 - pAd->BbpRssiToDbmDelta));
1925 sprintf(extra+strlen(extra), "RSSI-B (if available) = %ld\n", (LONG)(pAd->StaCfg.RssiSample.LastRssi1 - pAd->BbpRssiToDbmDelta));
1926 sprintf(extra+strlen(extra), "RSSI-C (if available) = %ld\n\n", (LONG)(pAd->StaCfg.RssiSample.LastRssi2 - pAd->BbpRssiToDbmDelta));
1928 #ifdef WPA_SUPPLICANT_SUPPORT
1929 sprintf(extra+strlen(extra), "WpaSupplicantUP = %d\n\n", pAd->StaCfg.WpaSupplicantUP);
1930 #endif // WPA_SUPPLICANT_SUPPORT //
1933 wrq->length = strlen(extra) + 1; // 1: size of '\0'
1934 DBGPRINT(RT_DEBUG_TRACE, ("<== rt_private_get_statistics, wrq->length = %d\n", wrq->length));
1939 #ifdef DOT11_N_SUPPORT
1941 IN PRTMP_ADAPTER pAd,
1945 BA_ORI_ENTRY *pOriBAEntry;
1946 BA_REC_ENTRY *pRecBAEntry;
1948 for (i=0; i<MAX_LEN_OF_MAC_TABLE; i++)
1950 PMAC_TABLE_ENTRY pEntry = &pAd->MacTab.Content[i];
1951 if (((pEntry->ValidAsCLI || pEntry->ValidAsApCli) && (pEntry->Sst == SST_ASSOC))
1952 || (pEntry->ValidAsWDS) || (pEntry->ValidAsMesh))
1954 sprintf(pOutBuf, "%s\n%02X:%02X:%02X:%02X:%02X:%02X (Aid = %d) (AP) -\n",
1956 pEntry->Addr[0], pEntry->Addr[1], pEntry->Addr[2],
1957 pEntry->Addr[3], pEntry->Addr[4], pEntry->Addr[5], pEntry->Aid);
1959 sprintf(pOutBuf, "%s[Recipient]\n", pOutBuf);
1960 for (j=0; j < NUM_OF_TID; j++)
1962 if (pEntry->BARecWcidArray[j] != 0)
1964 pRecBAEntry =&pAd->BATable.BARecEntry[pEntry->BARecWcidArray[j]];
1965 sprintf(pOutBuf, "%sTID=%d, BAWinSize=%d, LastIndSeq=%d, ReorderingPkts=%d\n", pOutBuf, j, pRecBAEntry->BAWinSize, pRecBAEntry->LastIndSeq, pRecBAEntry->list.qlen);
1968 sprintf(pOutBuf, "%s\n", pOutBuf);
1970 sprintf(pOutBuf, "%s[Originator]\n", pOutBuf);
1971 for (j=0; j < NUM_OF_TID; j++)
1973 if (pEntry->BAOriWcidArray[j] != 0)
1975 pOriBAEntry =&pAd->BATable.BAOriEntry[pEntry->BAOriWcidArray[j]];
1976 sprintf(pOutBuf, "%sTID=%d, BAWinSize=%d, StartSeq=%d, CurTxSeq=%d\n", pOutBuf, j, pOriBAEntry->BAWinSize, pOriBAEntry->Sequence, pEntry->TxSeq[j]);
1979 sprintf(pOutBuf, "%s\n\n", pOutBuf);
1981 if (strlen(pOutBuf) > (IW_PRIV_SIZE_MASK - 30))
1987 #endif // DOT11_N_SUPPORT //
1990 rt_private_show(struct net_device *dev, struct iw_request_info *info,
1991 struct iw_point *wrq, char *extra)
1994 VIRTUAL_ADAPTER *pVirtualAd = NULL;
1997 u32 subcmd = wrq->flags;
1999 if (dev->priv_flags == INT_MAIN)
2003 pVirtualAd = dev->ml_priv;
2004 pAd = pVirtualAd->RtmpDev->ml_priv;
2006 pObj = (POS_COOKIE) pAd->OS_Cookie;
2010 /* if 1st open fail, pAd will be free;
2011 So the net_dev->ml_priv will be NULL in 2rd open */
2020 memset(extra, 0x00, IW_PRIV_SIZE_MASK);
2023 pObj->ioctl_if_type = INT_MAIN;
2024 pObj->ioctl_if = MAIN_MBSSID;
2030 case SHOW_CONN_STATUS:
2031 if (MONITOR_ON(pAd))
2033 #ifdef DOT11_N_SUPPORT
2034 if (pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED &&
2035 pAd->CommonCfg.RegTransmitSetting.field.BW)
2036 sprintf(extra, "Monitor Mode(CentralChannel %d)\n", pAd->CommonCfg.CentralChannel);
2038 #endif // DOT11_N_SUPPORT //
2039 sprintf(extra, "Monitor Mode(Channel %d)\n", pAd->CommonCfg.Channel);
2043 if (pAd->IndicateMediaState == NdisMediaStateConnected)
2047 sprintf(extra, "Connected(AP: %s[%02X:%02X:%02X:%02X:%02X:%02X])\n",
2048 pAd->CommonCfg.Ssid,
2049 pAd->CommonCfg.Bssid[0],
2050 pAd->CommonCfg.Bssid[1],
2051 pAd->CommonCfg.Bssid[2],
2052 pAd->CommonCfg.Bssid[3],
2053 pAd->CommonCfg.Bssid[4],
2054 pAd->CommonCfg.Bssid[5]);
2055 DBGPRINT(RT_DEBUG_TRACE ,("Ssid=%s ,Ssidlen = %d\n",pAd->CommonCfg.Ssid, pAd->CommonCfg.SsidLen));
2057 else if (ADHOC_ON(pAd))
2058 sprintf(extra, "Connected\n");
2062 sprintf(extra, "Disconnected\n");
2063 DBGPRINT(RT_DEBUG_TRACE ,("ConnStatus is not connected\n"));
2066 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2068 case SHOW_DRVIER_VERION:
2069 sprintf(extra, "Driver version-%s, %s %s\n", STA_DRIVER_VERSION, __DATE__, __TIME__ );
2070 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2072 #ifdef DOT11_N_SUPPORT
2074 getBaInfo(pAd, extra);
2075 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2077 #endif // DOT11_N_SUPPORT //
2078 case SHOW_DESC_INFO:
2080 Show_DescInfo_Proc(pAd, NULL);
2081 wrq->length = 0; // 1: size of '\0'
2085 if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
2087 sprintf(extra, "Scanning\n");
2088 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2091 pAd->StaCfg.bSwRadio = FALSE;
2092 if (pAd->StaCfg.bRadio != (pAd->StaCfg.bHwRadio && pAd->StaCfg.bSwRadio))
2094 pAd->StaCfg.bRadio = (pAd->StaCfg.bHwRadio && pAd->StaCfg.bSwRadio);
2095 if (pAd->StaCfg.bRadio == FALSE)
2098 // Update extra information
2099 pAd->ExtraInfo = SW_RADIO_OFF;
2102 sprintf(extra, "Radio Off\n");
2103 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2106 if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
2108 sprintf(extra, "Scanning\n");
2109 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2112 pAd->StaCfg.bSwRadio = TRUE;
2113 //if (pAd->StaCfg.bRadio != (pAd->StaCfg.bHwRadio && pAd->StaCfg.bSwRadio))
2115 pAd->StaCfg.bRadio = (pAd->StaCfg.bHwRadio && pAd->StaCfg.bSwRadio);
2116 if (pAd->StaCfg.bRadio == TRUE)
2119 // Update extra information
2120 pAd->ExtraInfo = EXTRA_INFO_CLEAR;
2123 sprintf(extra, "Radio On\n");
2124 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2128 #ifdef QOS_DLS_SUPPORT
2129 case SHOW_DLS_ENTRY_INFO:
2131 Set_DlsEntryInfo_Display_Proc(pAd, NULL);
2132 wrq->length = 0; // 1: size of '\0'
2135 #endif // QOS_DLS_SUPPORT //
2137 case SHOW_CFG_VALUE:
2139 Status = RTMPShowCfgValue(pAd, wrq->pointer, extra);
2141 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2145 DBGPRINT(RT_DEBUG_TRACE, ("%s - unknow subcmd = %d\n", __func__, subcmd));
2153 int rt_ioctl_siwmlme(struct net_device *dev,
2154 struct iw_request_info *info,
2155 union iwreq_data *wrqu,
2158 PRTMP_ADAPTER pAd = dev->ml_priv;
2159 struct iw_mlme *pMlme = (struct iw_mlme *)wrqu->data.pointer;
2160 MLME_QUEUE_ELEM MsgElem;
2161 MLME_DISASSOC_REQ_STRUCT DisAssocReq;
2162 MLME_DEAUTH_REQ_STRUCT DeAuthReq;
2164 DBGPRINT(RT_DEBUG_TRACE, ("====> %s\n", __func__));
2171 #ifdef IW_MLME_DEAUTH
2172 case IW_MLME_DEAUTH:
2173 DBGPRINT(RT_DEBUG_TRACE, ("====> %s - IW_MLME_DEAUTH\n", __func__));
2174 COPY_MAC_ADDR(DeAuthReq.Addr, pAd->CommonCfg.Bssid);
2175 DeAuthReq.Reason = pMlme->reason_code;
2176 MsgElem.MsgLen = sizeof(MLME_DEAUTH_REQ_STRUCT);
2177 NdisMoveMemory(MsgElem.Msg, &DeAuthReq, sizeof(MLME_DEAUTH_REQ_STRUCT));
2178 MlmeDeauthReqAction(pAd, &MsgElem);
2181 LinkDown(pAd, FALSE);
2182 pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
2185 #endif // IW_MLME_DEAUTH //
2186 #ifdef IW_MLME_DISASSOC
2187 case IW_MLME_DISASSOC:
2188 DBGPRINT(RT_DEBUG_TRACE, ("====> %s - IW_MLME_DISASSOC\n", __func__));
2189 COPY_MAC_ADDR(DisAssocReq.Addr, pAd->CommonCfg.Bssid);
2190 DisAssocReq.Reason = pMlme->reason_code;
2192 MsgElem.Machine = ASSOC_STATE_MACHINE;
2193 MsgElem.MsgType = MT2_MLME_DISASSOC_REQ;
2194 MsgElem.MsgLen = sizeof(MLME_DISASSOC_REQ_STRUCT);
2195 NdisMoveMemory(MsgElem.Msg, &DisAssocReq, sizeof(MLME_DISASSOC_REQ_STRUCT));
2197 pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_OID_DISASSOC;
2198 MlmeDisassocReqAction(pAd, &MsgElem);
2200 #endif // IW_MLME_DISASSOC //
2202 DBGPRINT(RT_DEBUG_TRACE, ("====> %s - Unknow Command\n", __func__));
2208 #endif // SIOCSIWMLME //
2210 #if WIRELESS_EXT > 17
2211 int rt_ioctl_siwauth(struct net_device *dev,
2212 struct iw_request_info *info,
2213 union iwreq_data *wrqu, char *extra)
2215 PRTMP_ADAPTER pAdapter = dev->ml_priv;
2216 struct iw_param *param = &wrqu->param;
2218 //check if the interface is down
2219 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
2221 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
2224 switch (param->flags & IW_AUTH_INDEX) {
2225 case IW_AUTH_WPA_VERSION:
2226 if (param->value == IW_AUTH_WPA_VERSION_WPA)
2228 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPAPSK;
2229 if (pAdapter->StaCfg.BssType == BSS_ADHOC)
2230 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPANone;
2232 else if (param->value == IW_AUTH_WPA_VERSION_WPA2)
2233 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA2PSK;
2235 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_WPA_VERSION - param->value = %d!\n", __func__, param->value));
2237 case IW_AUTH_CIPHER_PAIRWISE:
2238 if (param->value == IW_AUTH_CIPHER_NONE)
2240 pAdapter->StaCfg.WepStatus = Ndis802_11WEPDisabled;
2241 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
2242 pAdapter->StaCfg.PairCipher = Ndis802_11WEPDisabled;
2244 else if (param->value == IW_AUTH_CIPHER_WEP40 ||
2245 param->value == IW_AUTH_CIPHER_WEP104)
2247 pAdapter->StaCfg.WepStatus = Ndis802_11WEPEnabled;
2248 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
2249 pAdapter->StaCfg.PairCipher = Ndis802_11WEPEnabled;
2250 #ifdef WPA_SUPPLICANT_SUPPORT
2251 pAdapter->StaCfg.IEEE8021X = FALSE;
2252 #endif // WPA_SUPPLICANT_SUPPORT //
2254 else if (param->value == IW_AUTH_CIPHER_TKIP)
2256 pAdapter->StaCfg.WepStatus = Ndis802_11Encryption2Enabled;
2257 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
2258 pAdapter->StaCfg.PairCipher = Ndis802_11Encryption2Enabled;
2260 else if (param->value == IW_AUTH_CIPHER_CCMP)
2262 pAdapter->StaCfg.WepStatus = Ndis802_11Encryption3Enabled;
2263 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
2264 pAdapter->StaCfg.PairCipher = Ndis802_11Encryption3Enabled;
2266 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_CIPHER_PAIRWISE - param->value = %d!\n", __func__, param->value));
2268 case IW_AUTH_CIPHER_GROUP:
2269 if (param->value == IW_AUTH_CIPHER_NONE)
2271 pAdapter->StaCfg.GroupCipher = Ndis802_11WEPDisabled;
2273 else if (param->value == IW_AUTH_CIPHER_WEP40 ||
2274 param->value == IW_AUTH_CIPHER_WEP104)
2276 pAdapter->StaCfg.GroupCipher = Ndis802_11WEPEnabled;
2278 else if (param->value == IW_AUTH_CIPHER_TKIP)
2280 pAdapter->StaCfg.GroupCipher = Ndis802_11Encryption2Enabled;
2282 else if (param->value == IW_AUTH_CIPHER_CCMP)
2284 pAdapter->StaCfg.GroupCipher = Ndis802_11Encryption3Enabled;
2286 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_CIPHER_GROUP - param->value = %d!\n", __func__, param->value));
2288 case IW_AUTH_KEY_MGMT:
2289 if (param->value == IW_AUTH_KEY_MGMT_802_1X)
2291 if (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK)
2293 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA;
2294 #ifdef WPA_SUPPLICANT_SUPPORT
2295 pAdapter->StaCfg.IEEE8021X = FALSE;
2296 #endif // WPA_SUPPLICANT_SUPPORT //
2298 else if (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK)
2300 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA2;
2301 #ifdef WPA_SUPPLICANT_SUPPORT
2302 pAdapter->StaCfg.IEEE8021X = FALSE;
2303 #endif // WPA_SUPPLICANT_SUPPORT //
2305 #ifdef WPA_SUPPLICANT_SUPPORT
2308 pAdapter->StaCfg.IEEE8021X = TRUE;
2309 #endif // WPA_SUPPLICANT_SUPPORT //
2311 else if (param->value == 0)
2313 //pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
2314 STA_PORT_SECURED(pAdapter);
2316 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_KEY_MGMT - param->value = %d!\n", __func__, param->value));
2318 case IW_AUTH_RX_UNENCRYPTED_EAPOL:
2320 case IW_AUTH_PRIVACY_INVOKED:
2321 /*if (param->value == 0)
2323 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
2324 pAdapter->StaCfg.WepStatus = Ndis802_11WEPDisabled;
2325 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
2326 pAdapter->StaCfg.PairCipher = Ndis802_11WEPDisabled;
2327 pAdapter->StaCfg.GroupCipher = Ndis802_11WEPDisabled;
2329 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_PRIVACY_INVOKED - param->value = %d!\n", __func__, param->value));
2331 case IW_AUTH_DROP_UNENCRYPTED:
2332 if (param->value != 0)
2333 pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED;
2336 //pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
2337 STA_PORT_SECURED(pAdapter);
2339 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_WPA_VERSION - param->value = %d!\n", __func__, param->value));
2341 case IW_AUTH_80211_AUTH_ALG:
2342 if (param->value & IW_AUTH_ALG_SHARED_KEY)
2344 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeShared;
2346 else if (param->value & IW_AUTH_ALG_OPEN_SYSTEM)
2348 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
2352 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_80211_AUTH_ALG - param->value = %d!\n", __func__, param->value));
2354 case IW_AUTH_WPA_ENABLED:
2355 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_WPA_ENABLED - Driver supports WPA!(param->value = %d)\n", __func__, param->value));
2364 int rt_ioctl_giwauth(struct net_device *dev,
2365 struct iw_request_info *info,
2366 union iwreq_data *wrqu, char *extra)
2368 PRTMP_ADAPTER pAdapter = dev->ml_priv;
2369 struct iw_param *param = &wrqu->param;
2371 //check if the interface is down
2372 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
2374 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
2378 switch (param->flags & IW_AUTH_INDEX) {
2379 case IW_AUTH_DROP_UNENCRYPTED:
2380 param->value = (pAdapter->StaCfg.WepStatus == Ndis802_11WEPDisabled) ? 0 : 1;
2383 case IW_AUTH_80211_AUTH_ALG:
2384 param->value = (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeShared) ? IW_AUTH_ALG_SHARED_KEY : IW_AUTH_ALG_OPEN_SYSTEM;
2387 case IW_AUTH_WPA_ENABLED:
2388 param->value = (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA) ? 1 : 0;
2394 DBGPRINT(RT_DEBUG_TRACE, ("rt_ioctl_giwauth::param->value = %d!\n", param->value));
2398 void fnSetCipherKey(
2399 IN PRTMP_ADAPTER pAdapter,
2403 IN struct iw_encode_ext *ext)
2405 NdisZeroMemory(&pAdapter->SharedKey[BSS0][keyIdx], sizeof(CIPHER_KEY));
2406 pAdapter->SharedKey[BSS0][keyIdx].KeyLen = LEN_TKIP_EK;
2407 NdisMoveMemory(pAdapter->SharedKey[BSS0][keyIdx].Key, ext->key, LEN_TKIP_EK);
2408 NdisMoveMemory(pAdapter->SharedKey[BSS0][keyIdx].TxMic, ext->key + LEN_TKIP_EK, LEN_TKIP_TXMICK);
2409 NdisMoveMemory(pAdapter->SharedKey[BSS0][keyIdx].RxMic, ext->key + LEN_TKIP_EK + LEN_TKIP_TXMICK, LEN_TKIP_RXMICK);
2410 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CipherAlg;
2412 // Update group key information to ASIC Shared Key Table
2413 AsicAddSharedKeyEntry(pAdapter,
2416 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg,
2417 pAdapter->SharedKey[BSS0][keyIdx].Key,
2418 pAdapter->SharedKey[BSS0][keyIdx].TxMic,
2419 pAdapter->SharedKey[BSS0][keyIdx].RxMic);
2422 // Update ASIC WCID attribute table and IVEIV table
2423 RTMPAddWcidAttributeEntry(pAdapter,
2426 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg,
2429 // Update ASIC WCID attribute table and IVEIV table
2430 RTMPAddWcidAttributeEntry(pAdapter,
2433 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg,
2434 &pAdapter->MacTab.Content[BSSID_WCID]);
2437 int rt_ioctl_siwencodeext(struct net_device *dev,
2438 struct iw_request_info *info,
2439 union iwreq_data *wrqu,
2442 PRTMP_ADAPTER pAdapter = dev->ml_priv;
2443 struct iw_point *encoding = &wrqu->encoding;
2444 struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
2445 int keyIdx, alg = ext->alg;
2447 //check if the interface is down
2448 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
2450 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
2454 if (encoding->flags & IW_ENCODE_DISABLED)
2456 keyIdx = (encoding->flags & IW_ENCODE_INDEX) - 1;
2457 // set BSSID wcid entry of the Pair-wise Key table as no-security mode
2458 AsicRemovePairwiseKeyEntry(pAdapter, BSS0, BSSID_WCID);
2459 pAdapter->SharedKey[BSS0][keyIdx].KeyLen = 0;
2460 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CIPHER_NONE;
2461 AsicRemoveSharedKeyEntry(pAdapter, 0, (UCHAR)keyIdx);
2462 NdisZeroMemory(&pAdapter->SharedKey[BSS0][keyIdx], sizeof(CIPHER_KEY));
2463 DBGPRINT(RT_DEBUG_TRACE, ("%s::Remove all keys!(encoding->flags = %x)\n", __func__, encoding->flags));
2467 // Get Key Index and convet to our own defined key index
2468 keyIdx = (encoding->flags & IW_ENCODE_INDEX) - 1;
2469 if((keyIdx < 0) || (keyIdx >= NR_WEP_KEYS))
2472 if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
2474 pAdapter->StaCfg.DefaultKeyId = keyIdx;
2475 DBGPRINT(RT_DEBUG_TRACE, ("%s::DefaultKeyId = %d\n", __func__, pAdapter->StaCfg.DefaultKeyId));
2479 case IW_ENCODE_ALG_NONE:
2480 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_ENCODE_ALG_NONE\n", __func__));
2482 case IW_ENCODE_ALG_WEP:
2483 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_ENCODE_ALG_WEP - ext->key_len = %d, keyIdx = %d\n", __func__, ext->key_len, keyIdx));
2484 if (ext->key_len == MAX_WEP_KEY_SIZE)
2486 pAdapter->SharedKey[BSS0][keyIdx].KeyLen = MAX_WEP_KEY_SIZE;
2487 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CIPHER_WEP128;
2489 else if (ext->key_len == MIN_WEP_KEY_SIZE)
2491 pAdapter->SharedKey[BSS0][keyIdx].KeyLen = MIN_WEP_KEY_SIZE;
2492 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CIPHER_WEP64;
2497 NdisZeroMemory(pAdapter->SharedKey[BSS0][keyIdx].Key, 16);
2498 NdisMoveMemory(pAdapter->SharedKey[BSS0][keyIdx].Key, ext->key, ext->key_len);
2500 case IW_ENCODE_ALG_TKIP:
2501 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_ENCODE_ALG_TKIP - keyIdx = %d, ext->key_len = %d\n", __func__, keyIdx, ext->key_len));
2502 if (ext->key_len == 32)
2504 if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
2506 fnSetCipherKey(pAdapter, keyIdx, CIPHER_TKIP, FALSE, ext);
2507 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA2)
2509 //pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
2510 STA_PORT_SECURED(pAdapter);
2513 else if (ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY)
2515 fnSetCipherKey(pAdapter, keyIdx, CIPHER_TKIP, TRUE, ext);
2517 // set 802.1x port control
2518 //pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
2519 STA_PORT_SECURED(pAdapter);
2525 case IW_ENCODE_ALG_CCMP:
2526 if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
2528 fnSetCipherKey(pAdapter, keyIdx, CIPHER_AES, FALSE, ext);
2529 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA2)
2530 //pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
2531 STA_PORT_SECURED(pAdapter);
2533 else if (ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY)
2535 fnSetCipherKey(pAdapter, keyIdx, CIPHER_AES, TRUE, ext);
2537 // set 802.1x port control
2538 //pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
2539 STA_PORT_SECURED(pAdapter);
2551 rt_ioctl_giwencodeext(struct net_device *dev,
2552 struct iw_request_info *info,
2553 union iwreq_data *wrqu, char *extra)
2555 PRTMP_ADAPTER pAd = dev->ml_priv;
2557 struct iw_point *encoding = &wrqu->encoding;
2558 struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
2559 int idx, max_key_len;
2561 DBGPRINT(RT_DEBUG_TRACE ,("===> rt_ioctl_giwencodeext\n"));
2563 max_key_len = encoding->length - sizeof(*ext);
2564 if (max_key_len < 0)
2567 idx = encoding->flags & IW_ENCODE_INDEX;
2570 if (idx < 1 || idx > 4)
2574 if ((pAd->StaCfg.WepStatus == Ndis802_11Encryption2Enabled) ||
2575 (pAd->StaCfg.WepStatus == Ndis802_11Encryption3Enabled))
2577 if (idx != pAd->StaCfg.DefaultKeyId)
2585 idx = pAd->StaCfg.DefaultKeyId;
2587 encoding->flags = idx + 1;
2588 memset(ext, 0, sizeof(*ext));
2591 switch(pAd->StaCfg.WepStatus) {
2592 case Ndis802_11WEPDisabled:
2593 ext->alg = IW_ENCODE_ALG_NONE;
2594 encoding->flags |= IW_ENCODE_DISABLED;
2596 case Ndis802_11WEPEnabled:
2597 ext->alg = IW_ENCODE_ALG_WEP;
2598 if (pAd->SharedKey[BSS0][idx].KeyLen > max_key_len)
2602 ext->key_len = pAd->SharedKey[BSS0][idx].KeyLen;
2603 pKey = &(pAd->SharedKey[BSS0][idx].Key[0]);
2606 case Ndis802_11Encryption2Enabled:
2607 case Ndis802_11Encryption3Enabled:
2608 if (pAd->StaCfg.WepStatus == Ndis802_11Encryption2Enabled)
2609 ext->alg = IW_ENCODE_ALG_TKIP;
2611 ext->alg = IW_ENCODE_ALG_CCMP;
2613 if (max_key_len < 32)
2618 pKey = &pAd->StaCfg.PMK[0];
2625 if (ext->key_len && pKey)
2627 encoding->flags |= IW_ENCODE_ENABLED;
2628 memcpy(ext->key, pKey, ext->key_len);
2635 int rt_ioctl_siwgenie(struct net_device *dev,
2636 struct iw_request_info *info,
2637 union iwreq_data *wrqu, char *extra)
2639 PRTMP_ADAPTER pAd = dev->ml_priv;
2641 if (wrqu->data.length > MAX_LEN_OF_RSNIE ||
2642 (wrqu->data.length && extra == NULL))
2645 if (wrqu->data.length)
2647 pAd->StaCfg.RSNIE_Len = wrqu->data.length;
2648 NdisMoveMemory(&pAd->StaCfg.RSN_IE[0], extra, pAd->StaCfg.RSNIE_Len);
2652 pAd->StaCfg.RSNIE_Len = 0;
2653 NdisZeroMemory(&pAd->StaCfg.RSN_IE[0], MAX_LEN_OF_RSNIE);
2658 #endif // SIOCSIWGENIE //
2660 int rt_ioctl_giwgenie(struct net_device *dev,
2661 struct iw_request_info *info,
2662 union iwreq_data *wrqu, char *extra)
2664 PRTMP_ADAPTER pAd = dev->ml_priv;
2666 if ((pAd->StaCfg.RSNIE_Len == 0) ||
2667 (pAd->StaCfg.AuthMode < Ndis802_11AuthModeWPA))
2669 wrqu->data.length = 0;
2673 #ifdef NATIVE_WPA_SUPPLICANT_SUPPORT
2675 if (pAd->StaCfg.WpaSupplicantUP == WPA_SUPPLICANT_ENABLE)
2677 if (wrqu->data.length < pAd->StaCfg.RSNIE_Len)
2680 wrqu->data.length = pAd->StaCfg.RSNIE_Len;
2681 memcpy(extra, &pAd->StaCfg.RSN_IE[0], pAd->StaCfg.RSNIE_Len);
2684 #endif // SIOCSIWGENIE //
2685 #endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
2687 UCHAR RSNIe = IE_WPA;
2689 if (wrqu->data.length < (pAd->StaCfg.RSNIE_Len + 2)) // ID, Len
2691 wrqu->data.length = pAd->StaCfg.RSNIE_Len + 2;
2693 if ((pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK) ||
2694 (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2))
2697 extra[0] = (char)RSNIe;
2698 extra[1] = pAd->StaCfg.RSNIE_Len;
2699 memcpy(extra+2, &pAd->StaCfg.RSN_IE[0], pAd->StaCfg.RSNIE_Len);
2705 int rt_ioctl_siwpmksa(struct net_device *dev,
2706 struct iw_request_info *info,
2707 union iwreq_data *wrqu,
2710 PRTMP_ADAPTER pAd = dev->ml_priv;
2711 struct iw_pmksa *pPmksa = (struct iw_pmksa *)wrqu->data.pointer;
2712 INT CachedIdx = 0, idx = 0;
2717 DBGPRINT(RT_DEBUG_TRACE ,("===> rt_ioctl_siwpmksa\n"));
2720 case IW_PMKSA_FLUSH:
2721 NdisZeroMemory(pAd->StaCfg.SavedPMK, sizeof(BSSID_INFO)*PMKID_NO);
2722 DBGPRINT(RT_DEBUG_TRACE ,("rt_ioctl_siwpmksa - IW_PMKSA_FLUSH\n"));
2724 case IW_PMKSA_REMOVE:
2725 for (CachedIdx = 0; CachedIdx < pAd->StaCfg.SavedPMKNum; CachedIdx++)
2727 // compare the BSSID
2728 if (NdisEqualMemory(pPmksa->bssid.sa_data, pAd->StaCfg.SavedPMK[CachedIdx].BSSID, MAC_ADDR_LEN))
2730 NdisZeroMemory(pAd->StaCfg.SavedPMK[CachedIdx].BSSID, MAC_ADDR_LEN);
2731 NdisZeroMemory(pAd->StaCfg.SavedPMK[CachedIdx].PMKID, 16);
2732 for (idx = CachedIdx; idx < (pAd->StaCfg.SavedPMKNum - 1); idx++)
2734 NdisMoveMemory(&pAd->StaCfg.SavedPMK[idx].BSSID[0], &pAd->StaCfg.SavedPMK[idx+1].BSSID[0], MAC_ADDR_LEN);
2735 NdisMoveMemory(&pAd->StaCfg.SavedPMK[idx].PMKID[0], &pAd->StaCfg.SavedPMK[idx+1].PMKID[0], 16);
2737 pAd->StaCfg.SavedPMKNum--;
2742 DBGPRINT(RT_DEBUG_TRACE ,("rt_ioctl_siwpmksa - IW_PMKSA_REMOVE\n"));
2745 for (CachedIdx = 0; CachedIdx < pAd->StaCfg.SavedPMKNum; CachedIdx++)
2747 // compare the BSSID
2748 if (NdisEqualMemory(pPmksa->bssid.sa_data, pAd->StaCfg.SavedPMK[CachedIdx].BSSID, MAC_ADDR_LEN))
2752 // Found, replace it
2753 if (CachedIdx < PMKID_NO)
2755 DBGPRINT(RT_DEBUG_OFF, ("Update PMKID, idx = %d\n", CachedIdx));
2756 NdisMoveMemory(&pAd->StaCfg.SavedPMK[CachedIdx].BSSID[0], pPmksa->bssid.sa_data, MAC_ADDR_LEN);
2757 NdisMoveMemory(&pAd->StaCfg.SavedPMK[CachedIdx].PMKID[0], pPmksa->pmkid, 16);
2758 pAd->StaCfg.SavedPMKNum++;
2760 // Not found, replace the last one
2763 // Randomly replace one
2764 CachedIdx = (pPmksa->bssid.sa_data[5] % PMKID_NO);
2765 DBGPRINT(RT_DEBUG_OFF, ("Update PMKID, idx = %d\n", CachedIdx));
2766 NdisMoveMemory(&pAd->StaCfg.SavedPMK[CachedIdx].BSSID[0], pPmksa->bssid.sa_data, MAC_ADDR_LEN);
2767 NdisMoveMemory(&pAd->StaCfg.SavedPMK[CachedIdx].PMKID[0], pPmksa->pmkid, 16);
2770 DBGPRINT(RT_DEBUG_TRACE ,("rt_ioctl_siwpmksa - IW_PMKSA_ADD\n"));
2773 DBGPRINT(RT_DEBUG_TRACE ,("rt_ioctl_siwpmksa - Unknow Command!!\n"));
2779 #endif // #if WIRELESS_EXT > 17
2783 rt_private_ioctl_bbp(struct net_device *dev, struct iw_request_info *info,
2784 struct iw_point *wrq, char *extra)
2789 // CHAR arg[255]={0};
2792 BOOLEAN bIsPrintAllBBP = FALSE;
2794 PRTMP_ADAPTER pAdapter = dev->ml_priv;
2797 memset(extra, 0x00, IW_PRIV_SIZE_MASK);
2799 if (wrq->length > 1) //No parameters.
2801 sprintf(extra, "\n");
2803 //Parsing Read or Write
2804 this_char = wrq->pointer;
2805 DBGPRINT(RT_DEBUG_TRACE, ("this_char=%s\n", this_char));
2809 if ((value = rtstrchr(this_char, '=')) != NULL)
2812 if (!value || !*value)
2814 DBGPRINT(RT_DEBUG_TRACE, ("this_char=%s, value=%s\n", this_char, value));
2815 if (sscanf(this_char, "%d", &(bbpId)) == 1)
2821 if (bbpId <= 138) // edit by johnli, RF power sequence setup, add BBP R138 for ADC dynamic on/off control
2825 if (ATE_ON(pAdapter))
2827 ATE_BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, ®BBP);
2830 #endif // RALINK_ATE //
2832 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, ®BBP);
2834 sprintf(extra+strlen(extra), "R%02d[0x%02X]:%02X\n", bbpId, bbpId*2, regBBP);
2835 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2836 DBGPRINT(RT_DEBUG_TRACE, ("msg=%s\n", extra));
2839 {//Invalid parametes, so default printk all bbp
2840 bIsPrintAllBBP = TRUE;
2845 { //Invalid parametes, so default printk all bbp
2846 bIsPrintAllBBP = TRUE;
2852 if ((sscanf(this_char, "%d", &(bbpId)) == 1) && (sscanf(value, "%x", &(bbpValue)) == 1))
2858 if (bbpId <= 138) // edit by johnli, RF power sequence setup, add BBP R138 for ADC dynamic on/off control
2862 if (ATE_ON(pAdapter))
2864 ATE_BBP_IO_WRITE8_BY_REG_ID(pAdapter, bbpId, bbpValue);
2865 //Read it back for showing
2866 ATE_BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, ®BBP);
2869 #endif // RALINK_ATE //
2871 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, bbpId, bbpValue);
2872 //Read it back for showing
2873 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, ®BBP);
2875 sprintf(extra+strlen(extra), "R%02d[0x%02X]:%02X\n", bbpId, bbpId*2, regBBP);
2876 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2877 DBGPRINT(RT_DEBUG_TRACE, ("msg=%s\n", extra));
2880 {//Invalid parametes, so default printk all bbp
2881 bIsPrintAllBBP = TRUE;
2886 { //Invalid parametes, so default printk all bbp
2887 bIsPrintAllBBP = TRUE;
2893 bIsPrintAllBBP = TRUE;
2898 memset(extra, 0x00, IW_PRIV_SIZE_MASK);
2899 sprintf(extra, "\n");
2901 for (bbpId = 0; bbpId <= 136; bbpId++)
2904 for (bbpId = 0; bbpId <= 138; bbpId++) // edit by johnli, RF power sequence setup, add BBP R138 for ADC dynamic on/off control
2907 if (strlen(extra) >= (IW_PRIV_SIZE_MASK - 10))
2910 if (ATE_ON(pAdapter))
2912 ATE_BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, ®BBP);
2915 #endif // RALINK_ATE //
2916 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, ®BBP);
2918 sprintf(extra+strlen(extra), "R%02d[0x%02X]:%02X ", bbpId, bbpId*2, regBBP);
2920 sprintf(extra+strlen(extra), "\n");
2922 sprintf(extra+strlen(extra), "%03d = %02X\n", bbpId, regBBP); // edit by johnli, change display format
2925 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2926 DBGPRINT(RT_DEBUG_TRACE, ("wrq->length = %d\n", wrq->length));
2929 DBGPRINT(RT_DEBUG_TRACE, ("<==rt_private_ioctl_bbp\n\n"));
2935 int rt_ioctl_siwrate(struct net_device *dev,
2936 struct iw_request_info *info,
2937 union iwreq_data *wrqu, char *extra)
2939 PRTMP_ADAPTER pAd = dev->ml_priv;
2940 UINT32 rate = wrqu->bitrate.value, fixed = wrqu->bitrate.fixed;
2942 //check if the interface is down
2943 if(!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_IN_USE))
2945 DBGPRINT(RT_DEBUG_TRACE, ("rt_ioctl_siwrate::Network is down!\n"));
2949 DBGPRINT(RT_DEBUG_TRACE, ("rt_ioctl_siwrate::(rate = %d, fixed = %d)\n", rate, fixed));
2950 /* rate = -1 => auto rate
2951 rate = X, fixed = 1 => (fixed rate X)
2956 pAd->StaCfg.DesiredTransmitSetting.field.MCS = MCS_AUTO;
2957 pAd->StaCfg.bAutoTxRateSwitch = TRUE;
2958 if ((pAd->CommonCfg.PhyMode <= PHY_11G) ||
2959 (pAd->MacTab.Content[BSSID_WCID].HTPhyMode.field.MODE <= MODE_OFDM))
2960 RTMPSetDesiredRates(pAd, -1);
2962 #ifdef DOT11_N_SUPPORT
2964 #endif // DOT11_N_SUPPORT //
2970 pAd->StaCfg.bAutoTxRateSwitch = FALSE;
2971 if ((pAd->CommonCfg.PhyMode <= PHY_11G) ||
2972 (pAd->MacTab.Content[BSSID_WCID].HTPhyMode.field.MODE <= MODE_OFDM))
2973 RTMPSetDesiredRates(pAd, rate);
2976 pAd->StaCfg.DesiredTransmitSetting.field.MCS = MCS_AUTO;
2977 #ifdef DOT11_N_SUPPORT
2979 #endif // DOT11_N_SUPPORT //
2981 DBGPRINT(RT_DEBUG_TRACE, ("rt_ioctl_siwrate::(HtMcs=%d)\n",pAd->StaCfg.DesiredTransmitSetting.field.MCS));
2985 // TODO: rate = X, fixed = 0 => (rates <= X)
2993 int rt_ioctl_giwrate(struct net_device *dev,
2994 struct iw_request_info *info,
2995 union iwreq_data *wrqu, char *extra)
2997 PRTMP_ADAPTER pAd = dev->ml_priv;
2998 int rate_index = 0, rate_count = 0;
2999 HTTRANSMIT_SETTING ht_setting;
3000 __s32 ralinkrate[] =
3001 {2, 4, 11, 22, // CCK
3002 12, 18, 24, 36, 48, 72, 96, 108, // OFDM
3003 13, 26, 39, 52, 78, 104, 117, 130, 26, 52, 78, 104, 156, 208, 234, 260, // 20MHz, 800ns GI, MCS: 0 ~ 15
3004 39, 78, 117, 156, 234, 312, 351, 390, // 20MHz, 800ns GI, MCS: 16 ~ 23
3005 27, 54, 81, 108, 162, 216, 243, 270, 54, 108, 162, 216, 324, 432, 486, 540, // 40MHz, 800ns GI, MCS: 0 ~ 15
3006 81, 162, 243, 324, 486, 648, 729, 810, // 40MHz, 800ns GI, MCS: 16 ~ 23
3007 14, 29, 43, 57, 87, 115, 130, 144, 29, 59, 87, 115, 173, 230, 260, 288, // 20MHz, 400ns GI, MCS: 0 ~ 15
3008 43, 87, 130, 173, 260, 317, 390, 433, // 20MHz, 400ns GI, MCS: 16 ~ 23
3009 30, 60, 90, 120, 180, 240, 270, 300, 60, 120, 180, 240, 360, 480, 540, 600, // 40MHz, 400ns GI, MCS: 0 ~ 15
3010 90, 180, 270, 360, 540, 720, 810, 900}; // 40MHz, 400ns GI, MCS: 16 ~ 23
3012 rate_count = sizeof(ralinkrate)/sizeof(__s32);
3013 //check if the interface is down
3014 if(!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_IN_USE))
3016 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
3020 if ((pAd->StaCfg.bAutoTxRateSwitch == FALSE) &&
3022 ((pAd->CommonCfg.PhyMode <= PHY_11G) || (pAd->MacTab.Content[BSSID_WCID].HTPhyMode.field.MODE <= MODE_OFDM)))
3023 ht_setting.word = pAd->StaCfg.HTPhyMode.word;
3025 ht_setting.word = pAd->MacTab.Content[BSSID_WCID].HTPhyMode.word;
3027 #ifdef DOT11_N_SUPPORT
3028 if (ht_setting.field.MODE >= MODE_HTMIX)
3030 // rate_index = 12 + ((UCHAR)ht_setting.field.BW *16) + ((UCHAR)ht_setting.field.ShortGI *32) + ((UCHAR)ht_setting.field.MCS);
3031 rate_index = 12 + ((UCHAR)ht_setting.field.BW *24) + ((UCHAR)ht_setting.field.ShortGI *48) + ((UCHAR)ht_setting.field.MCS);
3034 #endif // DOT11_N_SUPPORT //
3035 if (ht_setting.field.MODE == MODE_OFDM)
3036 rate_index = (UCHAR)(ht_setting.field.MCS) + 4;
3037 else if (ht_setting.field.MODE == MODE_CCK)
3038 rate_index = (UCHAR)(ht_setting.field.MCS);
3043 if (rate_index > rate_count)
3044 rate_index = rate_count;
3046 wrqu->bitrate.value = ralinkrate[rate_index] * 500000;
3047 wrqu->bitrate.disabled = 0;
3052 static const iw_handler rt_handler[] =
3054 (iw_handler) NULL, /* SIOCSIWCOMMIT */
3055 (iw_handler) rt_ioctl_giwname, /* SIOCGIWNAME */
3056 (iw_handler) NULL, /* SIOCSIWNWID */
3057 (iw_handler) NULL, /* SIOCGIWNWID */
3058 (iw_handler) rt_ioctl_siwfreq, /* SIOCSIWFREQ */
3059 (iw_handler) rt_ioctl_giwfreq, /* SIOCGIWFREQ */
3060 (iw_handler) rt_ioctl_siwmode, /* SIOCSIWMODE */
3061 (iw_handler) rt_ioctl_giwmode, /* SIOCGIWMODE */
3062 (iw_handler) NULL, /* SIOCSIWSENS */
3063 (iw_handler) NULL, /* SIOCGIWSENS */
3064 (iw_handler) NULL /* not used */, /* SIOCSIWRANGE */
3065 (iw_handler) rt_ioctl_giwrange, /* SIOCGIWRANGE */
3066 (iw_handler) NULL /* not used */, /* SIOCSIWPRIV */
3067 (iw_handler) NULL /* kernel code */, /* SIOCGIWPRIV */
3068 (iw_handler) NULL /* not used */, /* SIOCSIWSTATS */
3069 (iw_handler) rt28xx_get_wireless_stats /* kernel code */, /* SIOCGIWSTATS */
3070 (iw_handler) NULL, /* SIOCSIWSPY */
3071 (iw_handler) NULL, /* SIOCGIWSPY */
3072 (iw_handler) NULL, /* SIOCSIWTHRSPY */
3073 (iw_handler) NULL, /* SIOCGIWTHRSPY */
3074 (iw_handler) rt_ioctl_siwap, /* SIOCSIWAP */
3075 (iw_handler) rt_ioctl_giwap, /* SIOCGIWAP */
3077 (iw_handler) rt_ioctl_siwmlme, /* SIOCSIWMLME */
3079 (iw_handler) NULL, /* SIOCSIWMLME */
3080 #endif // SIOCSIWMLME //
3081 (iw_handler) rt_ioctl_iwaplist, /* SIOCGIWAPLIST */
3083 (iw_handler) rt_ioctl_siwscan, /* SIOCSIWSCAN */
3084 (iw_handler) rt_ioctl_giwscan, /* SIOCGIWSCAN */
3086 (iw_handler) NULL, /* SIOCSIWSCAN */
3087 (iw_handler) NULL, /* SIOCGIWSCAN */
3088 #endif /* SIOCGIWSCAN */
3089 (iw_handler) rt_ioctl_siwessid, /* SIOCSIWESSID */
3090 (iw_handler) rt_ioctl_giwessid, /* SIOCGIWESSID */
3091 (iw_handler) rt_ioctl_siwnickn, /* SIOCSIWNICKN */
3092 (iw_handler) rt_ioctl_giwnickn, /* SIOCGIWNICKN */
3093 (iw_handler) NULL, /* -- hole -- */
3094 (iw_handler) NULL, /* -- hole -- */
3095 (iw_handler) rt_ioctl_siwrate, /* SIOCSIWRATE */
3096 (iw_handler) rt_ioctl_giwrate, /* SIOCGIWRATE */
3097 (iw_handler) rt_ioctl_siwrts, /* SIOCSIWRTS */
3098 (iw_handler) rt_ioctl_giwrts, /* SIOCGIWRTS */
3099 (iw_handler) rt_ioctl_siwfrag, /* SIOCSIWFRAG */
3100 (iw_handler) rt_ioctl_giwfrag, /* SIOCGIWFRAG */
3101 (iw_handler) NULL, /* SIOCSIWTXPOW */
3102 (iw_handler) NULL, /* SIOCGIWTXPOW */
3103 (iw_handler) NULL, /* SIOCSIWRETRY */
3104 (iw_handler) NULL, /* SIOCGIWRETRY */
3105 (iw_handler) rt_ioctl_siwencode, /* SIOCSIWENCODE */
3106 (iw_handler) rt_ioctl_giwencode, /* SIOCGIWENCODE */
3107 (iw_handler) NULL, /* SIOCSIWPOWER */
3108 (iw_handler) NULL, /* SIOCGIWPOWER */
3109 (iw_handler) NULL, /* -- hole -- */
3110 (iw_handler) NULL, /* -- hole -- */
3111 #if WIRELESS_EXT > 17
3112 (iw_handler) rt_ioctl_siwgenie, /* SIOCSIWGENIE */
3113 (iw_handler) rt_ioctl_giwgenie, /* SIOCGIWGENIE */
3114 (iw_handler) rt_ioctl_siwauth, /* SIOCSIWAUTH */
3115 (iw_handler) rt_ioctl_giwauth, /* SIOCGIWAUTH */
3116 (iw_handler) rt_ioctl_siwencodeext, /* SIOCSIWENCODEEXT */
3117 (iw_handler) rt_ioctl_giwencodeext, /* SIOCGIWENCODEEXT */
3118 (iw_handler) rt_ioctl_siwpmksa, /* SIOCSIWPMKSA */
3122 static const iw_handler rt_priv_handlers[] = {
3123 (iw_handler) NULL, /* + 0x00 */
3124 (iw_handler) NULL, /* + 0x01 */
3125 #ifndef CONFIG_AP_SUPPORT
3126 (iw_handler) rt_ioctl_setparam, /* + 0x02 */
3128 (iw_handler) NULL, /* + 0x02 */
3129 #endif // CONFIG_AP_SUPPORT //
3131 (iw_handler) rt_private_ioctl_bbp, /* + 0x03 */
3133 (iw_handler) NULL, /* + 0x03 */
3135 (iw_handler) NULL, /* + 0x04 */
3136 (iw_handler) NULL, /* + 0x05 */
3137 (iw_handler) NULL, /* + 0x06 */
3138 (iw_handler) NULL, /* + 0x07 */
3139 (iw_handler) NULL, /* + 0x08 */
3140 (iw_handler) rt_private_get_statistics, /* + 0x09 */
3141 (iw_handler) NULL, /* + 0x0A */
3142 (iw_handler) NULL, /* + 0x0B */
3143 (iw_handler) NULL, /* + 0x0C */
3144 (iw_handler) NULL, /* + 0x0D */
3145 (iw_handler) NULL, /* + 0x0E */
3146 (iw_handler) NULL, /* + 0x0F */
3147 (iw_handler) NULL, /* + 0x10 */
3148 (iw_handler) rt_private_show, /* + 0x11 */
3149 (iw_handler) NULL, /* + 0x12 */
3150 (iw_handler) NULL, /* + 0x13 */
3151 (iw_handler) NULL, /* + 0x15 */
3152 (iw_handler) NULL, /* + 0x17 */
3153 (iw_handler) NULL, /* + 0x18 */
3156 const struct iw_handler_def rt28xx_iw_handler_def =
3158 #define N(a) (sizeof (a) / sizeof (a[0]))
3159 .standard = (iw_handler *) rt_handler,
3160 .num_standard = sizeof(rt_handler) / sizeof(iw_handler),
3161 .private = (iw_handler *) rt_priv_handlers,
3162 .num_private = N(rt_priv_handlers),
3163 .private_args = (struct iw_priv_args *) privtab,
3164 .num_private_args = N(privtab),
3165 #if IW_HANDLER_VERSION >= 7
3166 .get_wireless_stats = rt28xx_get_wireless_stats,
3170 INT RTMPSetInformation(
3171 IN PRTMP_ADAPTER pAdapter,
3172 IN OUT struct ifreq *rq,
3175 struct iwreq *wrq = (struct iwreq *) rq;
3176 NDIS_802_11_SSID Ssid;
3177 NDIS_802_11_MAC_ADDRESS Bssid;
3178 RT_802_11_PHY_MODE PhyMode;
3179 RT_802_11_STA_CONFIG StaConfig;
3180 NDIS_802_11_RATES aryRates;
3181 RT_802_11_PREAMBLE Preamble;
3182 NDIS_802_11_WEP_STATUS WepStatus;
3183 NDIS_802_11_AUTHENTICATION_MODE AuthMode = Ndis802_11AuthModeMax;
3184 NDIS_802_11_NETWORK_INFRASTRUCTURE BssType;
3185 NDIS_802_11_RTS_THRESHOLD RtsThresh;
3186 NDIS_802_11_FRAGMENTATION_THRESHOLD FragThresh;
3187 NDIS_802_11_POWER_MODE PowerMode;
3188 PNDIS_802_11_KEY pKey = NULL;
3189 PNDIS_802_11_WEP pWepKey =NULL;
3190 PNDIS_802_11_REMOVE_KEY pRemoveKey = NULL;
3191 NDIS_802_11_CONFIGURATION Config, *pConfig = NULL;
3192 NDIS_802_11_NETWORK_TYPE NetType;
3195 INT Status = NDIS_STATUS_SUCCESS, MaxPhyMode = PHY_11G;
3198 BOOLEAN StateMachineTouched = FALSE;
3199 #ifdef DOT11_N_SUPPORT
3200 OID_SET_HT_PHYMODE HT_PhyMode; //11n ,kathy
3201 #endif // DOT11_N_SUPPORT //
3202 #ifdef WPA_SUPPLICANT_SUPPORT
3203 PNDIS_802_11_PMKID pPmkId = NULL;
3204 BOOLEAN IEEE8021xState = FALSE;
3205 BOOLEAN IEEE8021x_required_keys = FALSE;
3206 UCHAR wpa_supplicant_enable = 0;
3207 #endif // WPA_SUPPLICANT_SUPPORT //
3210 TX_RTY_CFG_STRUC tx_rty_cfg;
3211 ULONG ShortRetryLimit, LongRetryLimit;
3213 #endif // SNMP_SUPPORT //
3216 #ifdef DOT11_N_SUPPORT
3217 MaxPhyMode = PHY_11N_5G;
3218 #endif // DOT11_N_SUPPORT //
3221 DBGPRINT(RT_DEBUG_TRACE, ("-->RTMPSetInformation(), 0x%08x\n", cmd&0x7FFF));
3222 switch(cmd & 0x7FFF) {
3223 case RT_OID_802_11_COUNTRY_REGION:
3224 if (wrq->u.data.length < sizeof(UCHAR))
3226 // Only avaliable when EEPROM not programming
3227 else if (!(pAdapter->CommonCfg.CountryRegion & 0x80) && !(pAdapter->CommonCfg.CountryRegionForABand & 0x80))
3232 Status = copy_from_user(&Country, wrq->u.data.pointer, wrq->u.data.length);
3233 pAdapter->CommonCfg.CountryRegion = (UCHAR)(Country & 0x000000FF);
3234 pAdapter->CommonCfg.CountryRegionForABand = (UCHAR)((Country >> 8) & 0x000000FF);
3235 TmpPhy = pAdapter->CommonCfg.PhyMode;
3236 pAdapter->CommonCfg.PhyMode = 0xff;
3237 // Build all corresponding channel information
3238 RTMPSetPhyMode(pAdapter, TmpPhy);
3239 #ifdef DOT11_N_SUPPORT
3240 SetCommonHT(pAdapter);
3241 #endif // DOT11_N_SUPPORT //
3242 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_COUNTRY_REGION (A:%d B/G:%d)\n", pAdapter->CommonCfg.CountryRegionForABand,
3243 pAdapter->CommonCfg.CountryRegion));
3246 case OID_802_11_BSSID_LIST_SCAN:
3248 if (ATE_ON(pAdapter))
3250 DBGPRINT(RT_DEBUG_TRACE, ("The driver is in ATE mode now\n"));
3253 #endif // RALINK_ATE //
3255 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_BSSID_LIST_SCAN, TxCnt = %d \n", pAdapter->RalinkCounters.LastOneSecTotalTxCount));
3257 if (MONITOR_ON(pAdapter))
3259 DBGPRINT(RT_DEBUG_TRACE, ("!!! Driver is in Monitor Mode now !!!\n"));
3263 //Benson add 20080527, when radio off, sta don't need to scan
3264 if (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_RADIO_OFF))
3267 if (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
3269 DBGPRINT(RT_DEBUG_TRACE, ("!!! Driver is scanning now !!!\n"));
3270 pAdapter->StaCfg.bScanReqIsFromWebUI = TRUE;
3271 Status = NDIS_STATUS_SUCCESS;
3275 if (pAdapter->RalinkCounters.LastOneSecTotalTxCount > 100)
3277 DBGPRINT(RT_DEBUG_TRACE, ("!!! Link UP, ignore this set::OID_802_11_BSSID_LIST_SCAN\n"));
3278 Status = NDIS_STATUS_SUCCESS;
3279 pAdapter->StaCfg.ScanCnt = 99; // Prevent auto scan triggered by this OID
3283 if ((OPSTATUS_TEST_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED)) &&
3284 ((pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA) ||
3285 (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK) ||
3286 (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA2) ||
3287 (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK)) &&
3288 (pAdapter->StaCfg.PortSecured == WPA_802_1X_PORT_NOT_SECURED))
3290 DBGPRINT(RT_DEBUG_TRACE, ("!!! Link UP, Port Not Secured! ignore this set::OID_802_11_BSSID_LIST_SCAN\n"));
3291 Status = NDIS_STATUS_SUCCESS;
3292 pAdapter->StaCfg.ScanCnt = 99; // Prevent auto scan triggered by this OID
3297 if (pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE)
3299 RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
3300 DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
3303 // tell CNTL state machine to call NdisMSetInformationComplete() after completing
3304 // this request, because this request is initiated by NDIS.
3305 pAdapter->MlmeAux.CurrReqIsFromNdis = FALSE;
3306 // Reset allowed scan retries
3307 pAdapter->StaCfg.ScanCnt = 0;
3308 pAdapter->StaCfg.LastScanTime = Now;
3310 pAdapter->StaCfg.bScanReqIsFromWebUI = TRUE;
3311 RTMP_SET_FLAG(pAdapter, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS);
3312 MlmeEnqueue(pAdapter,
3313 MLME_CNTL_STATE_MACHINE,
3314 OID_802_11_BSSID_LIST_SCAN,
3318 Status = NDIS_STATUS_SUCCESS;
3319 StateMachineTouched = TRUE;
3321 case OID_802_11_SSID:
3322 if (wrq->u.data.length != sizeof(NDIS_802_11_SSID))
3326 PCHAR pSsidString = NULL;
3327 Status = copy_from_user(&Ssid, wrq->u.data.pointer, wrq->u.data.length);
3329 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_SSID (Len=%d,Ssid=%s)\n", Ssid.SsidLength, Ssid.Ssid));
3330 if (Ssid.SsidLength > MAX_LEN_OF_SSID)
3334 if (Ssid.SsidLength == 0)
3336 Set_SSID_Proc(pAdapter, "");
3340 pSsidString = (CHAR *) kmalloc(MAX_LEN_OF_SSID+1, MEM_ALLOC_FLAG);
3343 NdisZeroMemory(pSsidString, MAX_LEN_OF_SSID+1);
3344 NdisMoveMemory(pSsidString, Ssid.Ssid, Ssid.SsidLength);
3345 Set_SSID_Proc(pAdapter, pSsidString);
3354 case OID_802_11_BSSID:
3356 if (ATE_ON(pAdapter))
3358 DBGPRINT(RT_DEBUG_TRACE, ("The driver is in ATE mode now\n"));
3361 #endif // RALINK_ATE //
3362 if (wrq->u.data.length != sizeof(NDIS_802_11_MAC_ADDRESS))
3366 Status = copy_from_user(&Bssid, wrq->u.data.pointer, wrq->u.data.length);
3368 // tell CNTL state machine to call NdisMSetInformationComplete() after completing
3369 // this request, because this request is initiated by NDIS.
3370 pAdapter->MlmeAux.CurrReqIsFromNdis = FALSE;
3372 // Prevent to connect AP again in STAMlmePeriodicExec
3373 pAdapter->MlmeAux.AutoReconnectSsidLen= 32;
3375 // Reset allowed scan retries
3376 pAdapter->StaCfg.ScanCnt = 0;
3378 if (pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE)
3380 RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
3381 DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
3383 MlmeEnqueue(pAdapter,
3384 MLME_CNTL_STATE_MACHINE,
3386 sizeof(NDIS_802_11_MAC_ADDRESS),
3388 Status = NDIS_STATUS_SUCCESS;
3389 StateMachineTouched = TRUE;
3391 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_BSSID %02x:%02x:%02x:%02x:%02x:%02x\n",
3392 Bssid[0], Bssid[1], Bssid[2], Bssid[3], Bssid[4], Bssid[5]));
3395 case RT_OID_802_11_RADIO:
3396 if (wrq->u.data.length != sizeof(BOOLEAN))
3400 Status = copy_from_user(&RadioState, wrq->u.data.pointer, wrq->u.data.length);
3401 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_RADIO (=%d)\n", RadioState));
3402 if (pAdapter->StaCfg.bSwRadio != RadioState)
3404 pAdapter->StaCfg.bSwRadio = RadioState;
3405 if (pAdapter->StaCfg.bRadio != (pAdapter->StaCfg.bHwRadio && pAdapter->StaCfg.bSwRadio))
3407 pAdapter->StaCfg.bRadio = (pAdapter->StaCfg.bHwRadio && pAdapter->StaCfg.bSwRadio);
3408 if (pAdapter->StaCfg.bRadio == TRUE)
3410 MlmeRadioOn(pAdapter);
3411 // Update extra information
3412 pAdapter->ExtraInfo = EXTRA_INFO_CLEAR;
3416 MlmeRadioOff(pAdapter);
3417 // Update extra information
3418 pAdapter->ExtraInfo = SW_RADIO_OFF;
3424 case RT_OID_802_11_PHY_MODE:
3425 if (wrq->u.data.length != sizeof(RT_802_11_PHY_MODE))
3429 Status = copy_from_user(&PhyMode, wrq->u.data.pointer, wrq->u.data.length);
3430 if (PhyMode <= MaxPhyMode)
3432 RTMPSetPhyMode(pAdapter, PhyMode);
3433 #ifdef DOT11_N_SUPPORT
3434 SetCommonHT(pAdapter);
3435 #endif // DOT11_N_SUPPORT //
3437 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_PHY_MODE (=%d)\n", PhyMode));
3440 case RT_OID_802_11_STA_CONFIG:
3441 if (wrq->u.data.length != sizeof(RT_802_11_STA_CONFIG))
3445 Status = copy_from_user(&StaConfig, wrq->u.data.pointer, wrq->u.data.length);
3446 pAdapter->CommonCfg.bEnableTxBurst = StaConfig.EnableTxBurst;
3447 pAdapter->CommonCfg.UseBGProtection = StaConfig.UseBGProtection;
3448 pAdapter->CommonCfg.bUseShortSlotTime = 1; // 2003-10-30 always SHORT SLOT capable
3449 if ((pAdapter->CommonCfg.PhyMode != StaConfig.AdhocMode) &&
3450 (StaConfig.AdhocMode <= MaxPhyMode))
3452 // allow dynamic change of "USE OFDM rate or not" in ADHOC mode
3453 // if setting changed, need to reset current TX rate as well as BEACON frame format
3454 pAdapter->CommonCfg.PhyMode = StaConfig.AdhocMode;
3455 if (pAdapter->StaCfg.BssType == BSS_ADHOC)
3457 RTMPSetPhyMode(pAdapter, PhyMode);
3458 MlmeUpdateTxRates(pAdapter, FALSE, 0);
3459 MakeIbssBeacon(pAdapter); // re-build BEACON frame
3460 AsicEnableIbssSync(pAdapter); // copy to on-chip memory
3463 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_SET_STA_CONFIG (Burst=%d, Protection=%ld,ShortSlot=%d\n",
3464 pAdapter->CommonCfg.bEnableTxBurst,
3465 pAdapter->CommonCfg.UseBGProtection,
3466 pAdapter->CommonCfg.bUseShortSlotTime));
3469 case OID_802_11_DESIRED_RATES:
3470 if (wrq->u.data.length != sizeof(NDIS_802_11_RATES))
3474 Status = copy_from_user(&aryRates, wrq->u.data.pointer, wrq->u.data.length);
3475 NdisZeroMemory(pAdapter->CommonCfg.DesireRate, MAX_LEN_OF_SUPPORTED_RATES);
3476 NdisMoveMemory(pAdapter->CommonCfg.DesireRate, &aryRates, sizeof(NDIS_802_11_RATES));
3477 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_DESIRED_RATES (%02x,%02x,%02x,%02x,%02x,%02x,%02x,%02x)\n",
3478 pAdapter->CommonCfg.DesireRate[0],pAdapter->CommonCfg.DesireRate[1],
3479 pAdapter->CommonCfg.DesireRate[2],pAdapter->CommonCfg.DesireRate[3],
3480 pAdapter->CommonCfg.DesireRate[4],pAdapter->CommonCfg.DesireRate[5],
3481 pAdapter->CommonCfg.DesireRate[6],pAdapter->CommonCfg.DesireRate[7] ));
3482 // Changing DesiredRate may affect the MAX TX rate we used to TX frames out
3483 MlmeUpdateTxRates(pAdapter, FALSE, 0);
3486 case RT_OID_802_11_PREAMBLE:
3487 if (wrq->u.data.length != sizeof(RT_802_11_PREAMBLE))
3491 Status = copy_from_user(&Preamble, wrq->u.data.pointer, wrq->u.data.length);
3492 if (Preamble == Rt802_11PreambleShort)
3494 pAdapter->CommonCfg.TxPreamble = Preamble;
3495 MlmeSetTxPreamble(pAdapter, Rt802_11PreambleShort);
3497 else if ((Preamble == Rt802_11PreambleLong) || (Preamble == Rt802_11PreambleAuto))
3499 // if user wants AUTO, initialize to LONG here, then change according to AP's
3500 // capability upon association.
3501 pAdapter->CommonCfg.TxPreamble = Preamble;
3502 MlmeSetTxPreamble(pAdapter, Rt802_11PreambleLong);
3509 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_PREAMBLE (=%d)\n", Preamble));
3512 case OID_802_11_WEP_STATUS:
3513 if (wrq->u.data.length != sizeof(NDIS_802_11_WEP_STATUS))
3517 Status = copy_from_user(&WepStatus, wrq->u.data.pointer, wrq->u.data.length);
3518 // Since TKIP, AES, WEP are all supported. It should not have any invalid setting
3519 if (WepStatus <= Ndis802_11Encryption3KeyAbsent)
3521 if (pAdapter->StaCfg.WepStatus != WepStatus)
3523 // Config has changed
3524 pAdapter->bConfigChanged = TRUE;
3526 pAdapter->StaCfg.WepStatus = WepStatus;
3527 pAdapter->StaCfg.OrigWepStatus = WepStatus;
3528 pAdapter->StaCfg.PairCipher = WepStatus;
3529 pAdapter->StaCfg.GroupCipher = WepStatus;
3536 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_WEP_STATUS (=%d)\n",WepStatus));
3539 case OID_802_11_AUTHENTICATION_MODE:
3540 if (wrq->u.data.length != sizeof(NDIS_802_11_AUTHENTICATION_MODE))
3544 Status = copy_from_user(&AuthMode, wrq->u.data.pointer, wrq->u.data.length);
3545 if (AuthMode > Ndis802_11AuthModeMax)
3552 if (pAdapter->StaCfg.AuthMode != AuthMode)
3554 // Config has changed
3555 pAdapter->bConfigChanged = TRUE;
3557 pAdapter->StaCfg.AuthMode = AuthMode;
3559 pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED;
3560 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_AUTHENTICATION_MODE (=%d) \n",pAdapter->StaCfg.AuthMode));
3563 case OID_802_11_INFRASTRUCTURE_MODE:
3564 if (wrq->u.data.length != sizeof(NDIS_802_11_NETWORK_INFRASTRUCTURE))
3568 Status = copy_from_user(&BssType, wrq->u.data.pointer, wrq->u.data.length);
3570 if (BssType == Ndis802_11IBSS)
3571 Set_NetworkType_Proc(pAdapter, "Adhoc");
3572 else if (BssType == Ndis802_11Infrastructure)
3573 Set_NetworkType_Proc(pAdapter, "Infra");
3574 else if (BssType == Ndis802_11Monitor)
3575 Set_NetworkType_Proc(pAdapter, "Monitor");
3579 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_INFRASTRUCTURE_MODE (unknown)\n"));
3583 case OID_802_11_REMOVE_WEP:
3584 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_WEP\n"));
3585 if (wrq->u.data.length != sizeof(NDIS_802_11_KEY_INDEX))
3591 KeyIdx = *(NDIS_802_11_KEY_INDEX *) wrq->u.data.pointer;
3593 if (KeyIdx & 0x80000000)
3595 // Should never set default bit when remove key
3600 KeyIdx = KeyIdx & 0x0fffffff;
3606 pAdapter->SharedKey[BSS0][KeyIdx].KeyLen = 0;
3607 pAdapter->SharedKey[BSS0][KeyIdx].CipherAlg = CIPHER_NONE;
3608 AsicRemoveSharedKeyEntry(pAdapter, 0, (UCHAR)KeyIdx);
3613 case RT_OID_802_11_RESET_COUNTERS:
3614 NdisZeroMemory(&pAdapter->WlanCounters, sizeof(COUNTER_802_11));
3615 NdisZeroMemory(&pAdapter->Counters8023, sizeof(COUNTER_802_3));
3616 NdisZeroMemory(&pAdapter->RalinkCounters, sizeof(COUNTER_RALINK));
3617 pAdapter->Counters8023.RxNoBuffer = 0;
3618 pAdapter->Counters8023.GoodReceives = 0;
3619 pAdapter->Counters8023.RxNoBuffer = 0;
3621 pAdapter->BulkOutComplete = 0;
3622 pAdapter->BulkOutCompleteOther= 0;
3623 pAdapter->BulkOutCompleteCancel = 0;
3624 pAdapter->BulkOutReq = 0;
3625 pAdapter->BulkInReq= 0;
3626 pAdapter->BulkInComplete = 0;
3627 pAdapter->BulkInCompleteFail = 0;
3629 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_RESET_COUNTERS \n"));
3631 case OID_802_11_RTS_THRESHOLD:
3632 if (wrq->u.data.length != sizeof(NDIS_802_11_RTS_THRESHOLD))
3636 Status = copy_from_user(&RtsThresh, wrq->u.data.pointer, wrq->u.data.length);
3637 if (RtsThresh > MAX_RTS_THRESHOLD)
3640 pAdapter->CommonCfg.RtsThreshold = (USHORT)RtsThresh;
3642 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_RTS_THRESHOLD (=%ld)\n",RtsThresh));
3644 case OID_802_11_FRAGMENTATION_THRESHOLD:
3645 if (wrq->u.data.length != sizeof(NDIS_802_11_FRAGMENTATION_THRESHOLD))
3649 Status = copy_from_user(&FragThresh, wrq->u.data.pointer, wrq->u.data.length);
3650 pAdapter->CommonCfg.bUseZeroToDisableFragment = FALSE;
3651 if (FragThresh > MAX_FRAG_THRESHOLD || FragThresh < MIN_FRAG_THRESHOLD)
3653 if (FragThresh == 0)
3655 pAdapter->CommonCfg.FragmentThreshold = MAX_FRAG_THRESHOLD;
3656 pAdapter->CommonCfg.bUseZeroToDisableFragment = TRUE;
3662 pAdapter->CommonCfg.FragmentThreshold = (USHORT)FragThresh;
3664 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_FRAGMENTATION_THRESHOLD (=%ld) \n",FragThresh));
3666 case OID_802_11_POWER_MODE:
3667 if (wrq->u.data.length != sizeof(NDIS_802_11_POWER_MODE))
3671 Status = copy_from_user(&PowerMode, wrq->u.data.pointer, wrq->u.data.length);
3672 if (PowerMode == Ndis802_11PowerModeCAM)
3673 Set_PSMode_Proc(pAdapter, "CAM");
3674 else if (PowerMode == Ndis802_11PowerModeMAX_PSP)
3675 Set_PSMode_Proc(pAdapter, "Max_PSP");
3676 else if (PowerMode == Ndis802_11PowerModeFast_PSP)
3677 Set_PSMode_Proc(pAdapter, "Fast_PSP");
3678 else if (PowerMode == Ndis802_11PowerModeLegacy_PSP)
3679 Set_PSMode_Proc(pAdapter, "Legacy_PSP");
3683 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_POWER_MODE (=%d)\n",PowerMode));
3685 case RT_OID_802_11_TX_POWER_LEVEL_1:
3686 if (wrq->u.data.length < sizeof(ULONG))
3690 Status = copy_from_user(&PowerTemp, wrq->u.data.pointer, wrq->u.data.length);
3691 if (PowerTemp > 100)
3692 PowerTemp = 0xffffffff; // AUTO
3693 pAdapter->CommonCfg.TxPowerDefault = PowerTemp; //keep current setting.
3694 pAdapter->CommonCfg.TxPowerPercentage = pAdapter->CommonCfg.TxPowerDefault;
3695 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_TX_POWER_LEVEL_1 (=%ld)\n", pAdapter->CommonCfg.TxPowerPercentage));
3698 case OID_802_11_NETWORK_TYPE_IN_USE:
3699 if (wrq->u.data.length != sizeof(NDIS_802_11_NETWORK_TYPE))
3703 Status = copy_from_user(&NetType, wrq->u.data.pointer, wrq->u.data.length);
3705 if (NetType == Ndis802_11DS)
3706 RTMPSetPhyMode(pAdapter, PHY_11B);
3707 else if (NetType == Ndis802_11OFDM24)
3708 RTMPSetPhyMode(pAdapter, PHY_11BG_MIXED);
3709 else if (NetType == Ndis802_11OFDM5)
3710 RTMPSetPhyMode(pAdapter, PHY_11A);
3713 #ifdef DOT11_N_SUPPORT
3714 if (Status == NDIS_STATUS_SUCCESS)
3715 SetCommonHT(pAdapter);
3716 #endif // DOT11_N_SUPPORT //
3717 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_NETWORK_TYPE_IN_USE (=%d)\n",NetType));
3720 // For WPA PSK PMK key
3721 case RT_OID_802_11_ADD_WPA:
3722 pKey = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
3729 Status = copy_from_user(pKey, wrq->u.data.pointer, wrq->u.data.length);
3730 if (pKey->Length != wrq->u.data.length)
3733 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_ADD_WPA, Failed!!\n"));
3737 if ((pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPAPSK) &&
3738 (pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPA2PSK) &&
3739 (pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPANone) )
3741 Status = -EOPNOTSUPP;
3742 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_ADD_WPA, Failed!! [AuthMode != WPAPSK/WPA2PSK/WPANONE]\n"));
3744 else if ((pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK) ||
3745 (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK) ||
3746 (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPANone) ) // Only for WPA PSK mode
3748 NdisMoveMemory(pAdapter->StaCfg.PMK, &pKey->KeyMaterial, pKey->KeyLength);
3749 // Use RaConfig as PSK agent.
3750 // Start STA supplicant state machine
3751 if (pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPANone)
3752 pAdapter->StaCfg.WpaState = SS_START;
3754 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_ADD_WPA (id=0x%x, Len=%d-byte)\n", pKey->KeyIndex, pKey->KeyLength));
3758 pAdapter->StaCfg.WpaState = SS_NOTUSE;
3759 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_ADD_WPA (id=0x%x, Len=%d-byte)\n", pKey->KeyIndex, pKey->KeyLength));
3764 case OID_802_11_REMOVE_KEY:
3765 pRemoveKey = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
3766 if(pRemoveKey == NULL)
3772 Status = copy_from_user(pRemoveKey, wrq->u.data.pointer, wrq->u.data.length);
3773 if (pRemoveKey->Length != wrq->u.data.length)
3776 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_KEY, Failed!!\n"));
3780 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
3782 RTMPWPARemoveKeyProc(pAdapter, pRemoveKey);
3783 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_KEY, Remove WPA Key!!\n"));
3787 KeyIdx = pRemoveKey->KeyIndex;
3789 if (KeyIdx & 0x80000000)
3791 // Should never set default bit when remove key
3793 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_KEY, Failed!!(Should never set default bit when remove key)\n"));
3797 KeyIdx = KeyIdx & 0x0fffffff;
3801 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_KEY, Failed!!(KeyId[%d] out of range)\n", KeyIdx));
3805 pAdapter->SharedKey[BSS0][KeyIdx].KeyLen = 0;
3806 pAdapter->SharedKey[BSS0][KeyIdx].CipherAlg = CIPHER_NONE;
3807 AsicRemoveSharedKeyEntry(pAdapter, 0, (UCHAR)KeyIdx);
3808 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_KEY (id=0x%x, Len=%d-byte)\n", pRemoveKey->KeyIndex, pRemoveKey->Length));
3816 case OID_802_11_ADD_KEY:
3817 pKey = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
3823 Status = copy_from_user(pKey, wrq->u.data.pointer, wrq->u.data.length);
3824 if (pKey->Length != wrq->u.data.length)
3827 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_KEY, Failed!!\n"));
3831 RTMPAddKey(pAdapter, pKey);
3832 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_KEY (id=0x%x, Len=%d-byte)\n", pKey->KeyIndex, pKey->KeyLength));
3836 case OID_802_11_CONFIGURATION:
3837 if (wrq->u.data.length != sizeof(NDIS_802_11_CONFIGURATION))
3841 Status = copy_from_user(&Config, wrq->u.data.pointer, wrq->u.data.length);
3844 if ((pConfig->BeaconPeriod >= 20) && (pConfig->BeaconPeriod <=400))
3845 pAdapter->CommonCfg.BeaconPeriod = (USHORT) pConfig->BeaconPeriod;
3847 pAdapter->StaActive.AtimWin = (USHORT) pConfig->ATIMWindow;
3848 MAP_KHZ_TO_CHANNEL_ID(pConfig->DSConfig, pAdapter->CommonCfg.Channel);
3850 // Save the channel on MlmeAux for CntlOidRTBssidProc used.
3852 pAdapter->MlmeAux.Channel = pAdapter->CommonCfg.Channel;
3854 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_CONFIGURATION (BeacnPeriod=%ld,AtimW=%ld,Ch=%d)\n",
3855 pConfig->BeaconPeriod, pConfig->ATIMWindow, pAdapter->CommonCfg.Channel));
3856 // Config has changed
3857 pAdapter->bConfigChanged = TRUE;
3860 #ifdef DOT11_N_SUPPORT
3861 case RT_OID_802_11_SET_HT_PHYMODE:
3862 if (wrq->u.data.length != sizeof(OID_SET_HT_PHYMODE))
3866 POID_SET_HT_PHYMODE pHTPhyMode = &HT_PhyMode;
3868 Status = copy_from_user(&HT_PhyMode, wrq->u.data.pointer, wrq->u.data.length);
3869 DBGPRINT(RT_DEBUG_TRACE, ("Set::pHTPhyMode (PhyMode = %d,TransmitNo = %d, HtMode = %d, ExtOffset = %d , MCS = %d, BW = %d, STBC = %d, SHORTGI = %d) \n",
3870 pHTPhyMode->PhyMode, pHTPhyMode->TransmitNo,pHTPhyMode->HtMode,pHTPhyMode->ExtOffset,
3871 pHTPhyMode->MCS, pHTPhyMode->BW, pHTPhyMode->STBC, pHTPhyMode->SHORTGI));
3872 if (pAdapter->CommonCfg.PhyMode >= PHY_11ABGN_MIXED)
3873 RTMPSetHT(pAdapter, pHTPhyMode);
3875 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_SET_HT_PHYMODE(MCS=%d,BW=%d,SGI=%d,STBC=%d)\n",
3876 pAdapter->StaCfg.HTPhyMode.field.MCS, pAdapter->StaCfg.HTPhyMode.field.BW, pAdapter->StaCfg.HTPhyMode.field.ShortGI,
3877 pAdapter->StaCfg.HTPhyMode.field.STBC));
3879 #endif // DOT11_N_SUPPORT //
3880 case RT_OID_802_11_SET_APSD_SETTING:
3881 if (wrq->u.data.length != sizeof(ULONG))
3886 Status = copy_from_user(&apsd, wrq->u.data.pointer, wrq->u.data.length);
3888 /*-------------------------------------------------------------------
3889 |B31~B7 | B6~B5 | B4 | B3 | B2 | B1 | B0 |
3890 ---------------------------------------------------------------------
3891 | Rsvd | Max SP Len | AC_VO | AC_VI | AC_BK | AC_BE | APSD Capable |
3892 ---------------------------------------------------------------------*/
3893 pAdapter->CommonCfg.bAPSDCapable = (apsd & 0x00000001) ? TRUE : FALSE;
3894 pAdapter->CommonCfg.bAPSDAC_BE = ((apsd & 0x00000002) >> 1) ? TRUE : FALSE;
3895 pAdapter->CommonCfg.bAPSDAC_BK = ((apsd & 0x00000004) >> 2) ? TRUE : FALSE;
3896 pAdapter->CommonCfg.bAPSDAC_VI = ((apsd & 0x00000008) >> 3) ? TRUE : FALSE;
3897 pAdapter->CommonCfg.bAPSDAC_VO = ((apsd & 0x00000010) >> 4) ? TRUE : FALSE;
3898 pAdapter->CommonCfg.MaxSPLength = (UCHAR)((apsd & 0x00000060) >> 5);
3900 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,
3901 pAdapter->CommonCfg.bAPSDAC_BE, pAdapter->CommonCfg.bAPSDAC_BK, pAdapter->CommonCfg.bAPSDAC_VI, pAdapter->CommonCfg.bAPSDAC_VO, pAdapter->CommonCfg.MaxSPLength));
3905 case RT_OID_802_11_SET_APSD_PSM:
3906 if (wrq->u.data.length != sizeof(ULONG))
3910 // Driver needs to notify AP when PSM changes
3911 Status = copy_from_user(&pAdapter->CommonCfg.bAPSDForcePowerSave, wrq->u.data.pointer, wrq->u.data.length);
3912 if (pAdapter->CommonCfg.bAPSDForcePowerSave != pAdapter->StaCfg.Psm)
3914 MlmeSetPsmBit(pAdapter, pAdapter->CommonCfg.bAPSDForcePowerSave);
3915 RTMPSendNullFrame(pAdapter, pAdapter->CommonCfg.TxRate, TRUE);
3917 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_SET_APSD_PSM (bAPSDForcePowerSave:%d)\n", pAdapter->CommonCfg.bAPSDForcePowerSave));
3920 #ifdef QOS_DLS_SUPPORT
3921 case RT_OID_802_11_SET_DLS:
3922 if (wrq->u.data.length != sizeof(ULONG))
3926 BOOLEAN oldvalue = pAdapter->CommonCfg.bDLSCapable;
3927 Status = copy_from_user(&pAdapter->CommonCfg.bDLSCapable, wrq->u.data.pointer, wrq->u.data.length);
3928 if (oldvalue && !pAdapter->CommonCfg.bDLSCapable)
3931 // tear down local dls table entry
3932 for (i=0; i<MAX_NUM_OF_INIT_DLS_ENTRY; i++)
3934 if (pAdapter->StaCfg.DLSEntry[i].Valid && (pAdapter->StaCfg.DLSEntry[i].Status == DLS_FINISH))
3936 pAdapter->StaCfg.DLSEntry[i].Status = DLS_NONE;
3937 pAdapter->StaCfg.DLSEntry[i].Valid = FALSE;
3938 RTMPSendDLSTearDownFrame(pAdapter, pAdapter->StaCfg.DLSEntry[i].MacAddr);
3942 // tear down peer dls table entry
3943 for (i=MAX_NUM_OF_INIT_DLS_ENTRY; i<MAX_NUM_OF_DLS_ENTRY; i++)
3945 if (pAdapter->StaCfg.DLSEntry[i].Valid && (pAdapter->StaCfg.DLSEntry[i].Status == DLS_FINISH))
3947 pAdapter->StaCfg.DLSEntry[i].Status = DLS_NONE;
3948 pAdapter->StaCfg.DLSEntry[i].Valid = FALSE;
3949 RTMPSendDLSTearDownFrame(pAdapter, pAdapter->StaCfg.DLSEntry[i].MacAddr);
3954 DBGPRINT(RT_DEBUG_TRACE,("Set::RT_OID_802_11_SET_DLS (=%d)\n", pAdapter->CommonCfg.bDLSCapable));
3958 case RT_OID_802_11_SET_DLS_PARAM:
3959 if (wrq->u.data.length != sizeof(RT_802_11_DLS_UI))
3965 NdisZeroMemory(&Dls, sizeof(RT_802_11_DLS));
3966 RTMPMoveMemory(&Dls, wrq->u.data.pointer, sizeof(RT_802_11_DLS_UI));
3967 MlmeEnqueue(pAdapter,
3968 MLME_CNTL_STATE_MACHINE,
3969 RT_OID_802_11_SET_DLS_PARAM,
3970 sizeof(RT_802_11_DLS),
3972 DBGPRINT(RT_DEBUG_TRACE,("Set::RT_OID_802_11_SET_DLS_PARAM \n"));
3975 #endif // QOS_DLS_SUPPORT //
3976 case RT_OID_802_11_SET_WMM:
3977 if (wrq->u.data.length != sizeof(BOOLEAN))
3981 Status = copy_from_user(&pAdapter->CommonCfg.bWmmCapable, wrq->u.data.pointer, wrq->u.data.length);
3982 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_SET_WMM (=%d) \n", pAdapter->CommonCfg.bWmmCapable));
3986 case OID_802_11_DISASSOCIATE:
3988 if (ATE_ON(pAdapter))
3990 DBGPRINT(RT_DEBUG_TRACE, ("The driver is in ATE mode now\n"));
3993 #endif // RALINK_ATE //
3995 // Set NdisRadioStateOff to TRUE, instead of called MlmeRadioOff.
3996 // Later on, NDIS_802_11_BSSID_LIST_EX->NumberOfItems should be 0
3997 // when query OID_802_11_BSSID_LIST.
3999 // TRUE: NumberOfItems will set to 0.
4000 // FALSE: NumberOfItems no change.
4002 pAdapter->CommonCfg.NdisRadioStateOff = TRUE;
4003 // Set to immediately send the media disconnect event
4004 pAdapter->MlmeAux.CurrReqIsFromNdis = TRUE;
4005 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_DISASSOCIATE \n"));
4007 if (INFRA_ON(pAdapter))
4009 if (pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE)
4011 RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
4012 DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
4015 MlmeEnqueue(pAdapter,
4016 MLME_CNTL_STATE_MACHINE,
4017 OID_802_11_DISASSOCIATE,
4021 StateMachineTouched = TRUE;
4025 #ifdef DOT11_N_SUPPORT
4026 case RT_OID_802_11_SET_IMME_BA_CAP:
4027 if (wrq->u.data.length != sizeof(OID_BACAP_STRUC))
4031 OID_BACAP_STRUC Orde ;
4032 Status = copy_from_user(&Orde, wrq->u.data.pointer, wrq->u.data.length);
4033 if (Orde.Policy > BA_NOTUSE)
4035 Status = NDIS_STATUS_INVALID_DATA;
4037 else if (Orde.Policy == BA_NOTUSE)
4039 pAdapter->CommonCfg.BACapability.field.Policy = BA_NOTUSE;
4040 pAdapter->CommonCfg.BACapability.field.MpduDensity = Orde.MpduDensity;
4041 pAdapter->CommonCfg.DesiredHtPhy.MpduDensity = Orde.MpduDensity;
4042 pAdapter->CommonCfg.DesiredHtPhy.AmsduEnable = Orde.AmsduEnable;
4043 pAdapter->CommonCfg.DesiredHtPhy.AmsduSize= Orde.AmsduSize;
4044 pAdapter->CommonCfg.DesiredHtPhy.MimoPs= Orde.MMPSmode;
4045 pAdapter->CommonCfg.BACapability.field.MMPSmode = Orde.MMPSmode;
4047 pAdapter->CommonCfg.HtCapability.HtCapInfo.MimoPs = Orde.MMPSmode;
4048 pAdapter->CommonCfg.HtCapability.HtCapInfo.AMsduSize = Orde.AmsduSize;
4049 pAdapter->CommonCfg.HtCapability.HtCapParm.MpduDensity = Orde.MpduDensity;
4053 pAdapter->CommonCfg.BACapability.field.AutoBA = Orde.AutoBA;
4054 pAdapter->CommonCfg.BACapability.field.Policy = IMMED_BA; // we only support immediate BA.
4055 pAdapter->CommonCfg.BACapability.field.MpduDensity = Orde.MpduDensity;
4056 pAdapter->CommonCfg.DesiredHtPhy.MpduDensity = Orde.MpduDensity;
4057 pAdapter->CommonCfg.DesiredHtPhy.AmsduEnable = Orde.AmsduEnable;
4058 pAdapter->CommonCfg.DesiredHtPhy.AmsduSize= Orde.AmsduSize;
4059 pAdapter->CommonCfg.DesiredHtPhy.MimoPs = Orde.MMPSmode;
4060 pAdapter->CommonCfg.BACapability.field.MMPSmode = Orde.MMPSmode;
4063 pAdapter->CommonCfg.HtCapability.HtCapInfo.MimoPs = Orde.MMPSmode;
4064 pAdapter->CommonCfg.HtCapability.HtCapInfo.AMsduSize = Orde.AmsduSize;
4065 pAdapter->CommonCfg.HtCapability.HtCapParm.MpduDensity = Orde.MpduDensity;
4067 if (pAdapter->CommonCfg.BACapability.field.RxBAWinLimit > MAX_RX_REORDERBUF)
4068 pAdapter->CommonCfg.BACapability.field.RxBAWinLimit = MAX_RX_REORDERBUF;
4072 pAdapter->CommonCfg.REGBACapability.word = pAdapter->CommonCfg.BACapability.word;
4073 DBGPRINT(RT_DEBUG_TRACE, ("Set::(Orde.AutoBA = %d) (Policy=%d)(ReBAWinLimit=%d)(TxBAWinLimit=%d)(AutoMode=%d)\n",Orde.AutoBA, pAdapter->CommonCfg.BACapability.field.Policy,
4074 pAdapter->CommonCfg.BACapability.field.RxBAWinLimit,pAdapter->CommonCfg.BACapability.field.TxBAWinLimit, pAdapter->CommonCfg.BACapability.field.AutoBA));
4075 DBGPRINT(RT_DEBUG_TRACE, ("Set::(MimoPs = %d)(AmsduEnable = %d) (AmsduSize=%d)(MpduDensity=%d)\n",pAdapter->CommonCfg.DesiredHtPhy.MimoPs, pAdapter->CommonCfg.DesiredHtPhy.AmsduEnable,
4076 pAdapter->CommonCfg.DesiredHtPhy.AmsduSize, pAdapter->CommonCfg.DesiredHtPhy.MpduDensity));
4080 case RT_OID_802_11_ADD_IMME_BA:
4081 DBGPRINT(RT_DEBUG_TRACE, (" Set :: RT_OID_802_11_ADD_IMME_BA \n"));
4082 if (wrq->u.data.length != sizeof(OID_ADD_BA_ENTRY))
4087 OID_ADD_BA_ENTRY BA;
4088 MAC_TABLE_ENTRY *pEntry;
4090 Status = copy_from_user(&BA, wrq->u.data.pointer, wrq->u.data.length);
4093 Status = NDIS_STATUS_INVALID_DATA;
4098 //BATableInsertEntry
4099 //As ad-hoc mode, BA pair is not limited to only BSSID. so add via OID.
4101 // in ad hoc mode, when adding BA pair, we should insert this entry into MACEntry too
4102 pEntry = MacTableLookup(pAdapter, BA.MACAddr);
4105 DBGPRINT(RT_DEBUG_TRACE, ("RT_OID_802_11_ADD_IMME_BA. break on no connection.----:%x:%x\n", BA.MACAddr[4], BA.MACAddr[5]));
4108 if (BA.IsRecipient == FALSE)
4110 if (pEntry->bIAmBadAtheros == TRUE)
4111 pAdapter->CommonCfg.BACapability.field.RxBAWinLimit = 0x10;
4113 BAOriSessionSetUp(pAdapter, pEntry, index, 0, 100, TRUE);
4117 //BATableInsertEntry(pAdapter, pEntry->Aid, BA.MACAddr, 0, 0xffff, BA.TID, BA.nMSDU, BA.IsRecipient);
4120 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_ADD_IMME_BA. Rec = %d. Mac = %x:%x:%x:%x:%x:%x . \n",
4121 BA.IsRecipient, BA.MACAddr[0], BA.MACAddr[1], BA.MACAddr[2], BA.MACAddr[2]
4122 , BA.MACAddr[4], BA.MACAddr[5]));
4127 case RT_OID_802_11_TEAR_IMME_BA:
4128 DBGPRINT(RT_DEBUG_TRACE, ("Set :: RT_OID_802_11_TEAR_IMME_BA \n"));
4129 if (wrq->u.data.length != sizeof(OID_ADD_BA_ENTRY))
4133 POID_ADD_BA_ENTRY pBA;
4134 MAC_TABLE_ENTRY *pEntry;
4136 pBA = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
4140 DBGPRINT(RT_DEBUG_TRACE, ("Set :: RT_OID_802_11_TEAR_IMME_BA kmalloc() can't allocate enough memory\n"));
4141 Status = NDIS_STATUS_FAILURE;
4145 Status = copy_from_user(pBA, wrq->u.data.pointer, wrq->u.data.length);
4146 DBGPRINT(RT_DEBUG_TRACE, ("Set :: RT_OID_802_11_TEAR_IMME_BA(TID=%d, bAllTid=%d)\n", pBA->TID, pBA->bAllTid));
4148 if (!pBA->bAllTid && (pBA->TID > NUM_OF_TID))
4150 Status = NDIS_STATUS_INVALID_DATA;
4154 if (pBA->IsRecipient == FALSE)
4156 pEntry = MacTableLookup(pAdapter, pBA->MACAddr);
4157 DBGPRINT(RT_DEBUG_TRACE, (" pBA->IsRecipient == FALSE\n"));
4160 DBGPRINT(RT_DEBUG_TRACE, (" pBA->pEntry\n"));
4161 BAOriSessionTearDown(pAdapter, pEntry->Aid, pBA->TID, FALSE, TRUE);
4164 DBGPRINT(RT_DEBUG_TRACE, ("Set :: Not found pEntry \n"));
4168 pEntry = MacTableLookup(pAdapter, pBA->MACAddr);
4171 BARecSessionTearDown( pAdapter, (UCHAR)pEntry->Aid, pBA->TID, TRUE);
4174 DBGPRINT(RT_DEBUG_TRACE, ("Set :: Not found pEntry \n"));
4180 #endif // DOT11_N_SUPPORT //
4182 // For WPA_SUPPLICANT to set static wep key
4183 case OID_802_11_ADD_WEP:
4184 pWepKey = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
4189 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_WEP, Failed!!\n"));
4192 Status = copy_from_user(pWepKey, wrq->u.data.pointer, wrq->u.data.length);
4196 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_WEP, Failed (length mismatch)!!\n"));
4200 KeyIdx = pWepKey->KeyIndex & 0x0fffffff;
4201 // KeyIdx must be 0 ~ 3
4205 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_WEP, Failed (KeyIdx must be smaller than 4)!!\n"));
4209 UCHAR CipherAlg = 0;
4212 // set key material and key length
4213 NdisZeroMemory(pAdapter->SharedKey[BSS0][KeyIdx].Key, 16);
4214 pAdapter->SharedKey[BSS0][KeyIdx].KeyLen = (UCHAR) pWepKey->KeyLength;
4215 NdisMoveMemory(pAdapter->SharedKey[BSS0][KeyIdx].Key, &pWepKey->KeyMaterial, pWepKey->KeyLength);
4217 switch(pWepKey->KeyLength)
4220 CipherAlg = CIPHER_WEP64;
4223 CipherAlg = CIPHER_WEP128;
4226 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_WEP, only support CIPHER_WEP64(len:5) & CIPHER_WEP128(len:13)!!\n"));
4230 pAdapter->SharedKey[BSS0][KeyIdx].CipherAlg = CipherAlg;
4232 // Default key for tx (shared key)
4233 if (pWepKey->KeyIndex & 0x80000000)
4235 #ifdef WPA_SUPPLICANT_SUPPORT
4236 // set key material and key length
4237 NdisZeroMemory(pAdapter->StaCfg.DesireSharedKey[KeyIdx].Key, 16);
4238 pAdapter->StaCfg.DesireSharedKey[KeyIdx].KeyLen = (UCHAR) pWepKey->KeyLength;
4239 NdisMoveMemory(pAdapter->StaCfg.DesireSharedKey[KeyIdx].Key, &pWepKey->KeyMaterial, pWepKey->KeyLength);
4240 pAdapter->StaCfg.DesireSharedKeyId = KeyIdx;
4241 pAdapter->StaCfg.DesireSharedKey[KeyIdx].CipherAlg = CipherAlg;
4242 #endif // WPA_SUPPLICANT_SUPPORT //
4243 pAdapter->StaCfg.DefaultKeyId = (UCHAR) KeyIdx;
4246 #ifdef WPA_SUPPLICANT_SUPPORT
4247 if (pAdapter->StaCfg.PortSecured == WPA_802_1X_PORT_SECURED)
4248 #endif // WPA_SUPPLICANT_SUPPORT
4250 Key = pAdapter->SharedKey[BSS0][KeyIdx].Key;
4252 // Set key material and cipherAlg to Asic
4253 AsicAddSharedKeyEntry(pAdapter, BSS0, KeyIdx, CipherAlg, Key, NULL, NULL);
4255 if (pWepKey->KeyIndex & 0x80000000)
4257 PMAC_TABLE_ENTRY pEntry = &pAdapter->MacTab.Content[BSSID_WCID];
4258 // Assign group key info
4259 RTMPAddWcidAttributeEntry(pAdapter, BSS0, KeyIdx, CipherAlg, NULL);
4260 // Assign pairwise key info
4261 RTMPAddWcidAttributeEntry(pAdapter, BSS0, KeyIdx, CipherAlg, pEntry);
4264 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"));
4269 #ifdef WPA_SUPPLICANT_SUPPORT
4270 case OID_SET_COUNTERMEASURES:
4271 if (wrq->u.data.length != sizeof(int))
4276 Status = copy_from_user(&enabled, wrq->u.data.pointer, wrq->u.data.length);
4278 pAdapter->StaCfg.bBlockAssoc = TRUE;
4280 // WPA MIC error should block association attempt for 60 seconds
4281 pAdapter->StaCfg.bBlockAssoc = FALSE;
4282 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_SET_COUNTERMEASURES bBlockAssoc=%s\n", pAdapter->StaCfg.bBlockAssoc ? "TRUE":"FALSE"));
4285 case RT_OID_WPA_SUPPLICANT_SUPPORT:
4286 if (wrq->u.data.length != sizeof(UCHAR))
4290 Status = copy_from_user(&wpa_supplicant_enable, wrq->u.data.pointer, wrq->u.data.length);
4291 pAdapter->StaCfg.WpaSupplicantUP = wpa_supplicant_enable;
4292 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_WPA_SUPPLICANT_SUPPORT (=%d)\n", pAdapter->StaCfg.WpaSupplicantUP));
4295 case OID_802_11_DEAUTHENTICATION:
4296 if (wrq->u.data.length != sizeof(MLME_DEAUTH_REQ_STRUCT))
4300 MLME_DEAUTH_REQ_STRUCT *pInfo;
4301 MLME_QUEUE_ELEM *MsgElem = (MLME_QUEUE_ELEM *) kmalloc(sizeof(MLME_QUEUE_ELEM), MEM_ALLOC_FLAG);
4303 pInfo = (MLME_DEAUTH_REQ_STRUCT *) MsgElem->Msg;
4304 Status = copy_from_user(pInfo, wrq->u.data.pointer, wrq->u.data.length);
4305 MlmeDeauthReqAction(pAdapter, MsgElem);
4308 if (INFRA_ON(pAdapter))
4310 LinkDown(pAdapter, FALSE);
4311 pAdapter->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
4313 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_DEAUTHENTICATION (Reason=%d)\n", pInfo->Reason));
4316 case OID_802_11_DROP_UNENCRYPTED:
4317 if (wrq->u.data.length != sizeof(int))
4322 Status = copy_from_user(&enabled, wrq->u.data.pointer, wrq->u.data.length);
4324 pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED;
4326 pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
4327 NdisAcquireSpinLock(&pAdapter->MacTabLock);
4328 pAdapter->MacTab.Content[BSSID_WCID].PortSecured = pAdapter->StaCfg.PortSecured;
4329 NdisReleaseSpinLock(&pAdapter->MacTabLock);
4330 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_DROP_UNENCRYPTED (=%d)\n", enabled));
4333 case OID_802_11_SET_IEEE8021X:
4334 if (wrq->u.data.length != sizeof(BOOLEAN))
4338 Status = copy_from_user(&IEEE8021xState, wrq->u.data.pointer, wrq->u.data.length);
4339 pAdapter->StaCfg.IEEE8021X = IEEE8021xState;
4340 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_SET_IEEE8021X (=%d)\n", IEEE8021xState));
4343 case OID_802_11_SET_IEEE8021X_REQUIRE_KEY:
4344 if (wrq->u.data.length != sizeof(BOOLEAN))
4348 Status = copy_from_user(&IEEE8021x_required_keys, wrq->u.data.pointer, wrq->u.data.length);
4349 pAdapter->StaCfg.IEEE8021x_required_keys = IEEE8021x_required_keys;
4350 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_SET_IEEE8021X_REQUIRE_KEY (%d)\n", IEEE8021x_required_keys));
4353 case OID_802_11_PMKID:
4354 pPmkId = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
4356 if(pPmkId == NULL) {
4360 Status = copy_from_user(pPmkId, wrq->u.data.pointer, wrq->u.data.length);
4362 // check the PMKID information
4363 if (pPmkId->BSSIDInfoCount == 0)
4364 NdisZeroMemory(pAdapter->StaCfg.SavedPMK, sizeof(BSSID_INFO)*PMKID_NO);
4367 PBSSID_INFO pBssIdInfo;
4371 for (BssIdx = 0; BssIdx < pPmkId->BSSIDInfoCount; BssIdx++)
4373 // point to the indexed BSSID_INFO structure
4374 pBssIdInfo = (PBSSID_INFO) ((PUCHAR) pPmkId + 2 * sizeof(UINT) + BssIdx * sizeof(BSSID_INFO));
4375 // Find the entry in the saved data base.
4376 for (CachedIdx = 0; CachedIdx < pAdapter->StaCfg.SavedPMKNum; CachedIdx++)
4378 // compare the BSSID
4379 if (NdisEqualMemory(pBssIdInfo->BSSID, pAdapter->StaCfg.SavedPMK[CachedIdx].BSSID, sizeof(NDIS_802_11_MAC_ADDRESS)))
4383 // Found, replace it
4384 if (CachedIdx < PMKID_NO)
4386 DBGPRINT(RT_DEBUG_OFF, ("Update OID_802_11_PMKID, idx = %d\n", CachedIdx));
4387 NdisMoveMemory(&pAdapter->StaCfg.SavedPMK[CachedIdx], pBssIdInfo, sizeof(BSSID_INFO));
4388 pAdapter->StaCfg.SavedPMKNum++;
4390 // Not found, replace the last one
4393 // Randomly replace one
4394 CachedIdx = (pBssIdInfo->BSSID[5] % 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));
4403 #endif // WPA_SUPPLICANT_SUPPORT //
4408 case OID_802_11_SHORTRETRYLIMIT:
4409 if (wrq->u.data.length != sizeof(ULONG))
4413 Status = copy_from_user(&ShortRetryLimit, wrq->u.data.pointer, wrq->u.data.length);
4414 RTMP_IO_READ32(pAdapter, TX_RTY_CFG, &tx_rty_cfg.word);
4415 tx_rty_cfg.field.ShortRtyLimit = ShortRetryLimit;
4416 RTMP_IO_WRITE32(pAdapter, TX_RTY_CFG, tx_rty_cfg.word);
4417 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_SHORTRETRYLIMIT (tx_rty_cfg.field.ShortRetryLimit=%d, ShortRetryLimit=%ld)\n", tx_rty_cfg.field.ShortRtyLimit, ShortRetryLimit));
4421 case OID_802_11_LONGRETRYLIMIT:
4422 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_LONGRETRYLIMIT \n"));
4423 if (wrq->u.data.length != sizeof(ULONG))
4427 Status = copy_from_user(&LongRetryLimit, wrq->u.data.pointer, wrq->u.data.length);
4428 RTMP_IO_READ32(pAdapter, TX_RTY_CFG, &tx_rty_cfg.word);
4429 tx_rty_cfg.field.LongRtyLimit = LongRetryLimit;
4430 RTMP_IO_WRITE32(pAdapter, TX_RTY_CFG, tx_rty_cfg.word);
4431 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_LONGRETRYLIMIT (tx_rty_cfg.field.LongRetryLimit= %d,LongRetryLimit=%ld)\n", tx_rty_cfg.field.LongRtyLimit, LongRetryLimit));
4435 case OID_802_11_WEPDEFAULTKEYVALUE:
4436 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_WEPDEFAULTKEYVALUE\n"));
4437 pKey = kmalloc(wrq->u.data.length, GFP_KERNEL);
4438 Status = copy_from_user(pKey, wrq->u.data.pointer, wrq->u.data.length);
4441 if ( pKey->Length != wrq->u.data.length)
4444 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_WEPDEFAULTKEYVALUE, Failed!!\n"));
4446 KeyIdx = pKey->KeyIndex & 0x0fffffff;
4447 DBGPRINT(RT_DEBUG_TRACE,("pKey->KeyIndex =%d, pKey->KeyLength=%d\n", pKey->KeyIndex, pKey->KeyLength));
4449 // it is a shared key
4454 pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].KeyLen = (UCHAR) pKey->KeyLength;
4455 NdisMoveMemory(&pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].Key, &pKey->KeyMaterial, pKey->KeyLength);
4456 if (pKey->KeyIndex & 0x80000000)
4458 // Default key for tx (shared key)
4459 pAdapter->StaCfg.DefaultKeyId = (UCHAR) KeyIdx;
4461 //RestartAPIsRequired = TRUE;
4466 case OID_802_11_WEPDEFAULTKEYID:
4467 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_WEPDEFAULTKEYID \n"));
4469 if (wrq->u.data.length != sizeof(UCHAR))
4472 Status = copy_from_user(&pAdapter->StaCfg.DefaultKeyId, wrq->u.data.pointer, wrq->u.data.length);
4477 case OID_802_11_CURRENTCHANNEL:
4478 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_CURRENTCHANNEL \n"));
4479 if (wrq->u.data.length != sizeof(UCHAR))
4483 Status = copy_from_user(&ctmp, wrq->u.data.pointer, wrq->u.data.length);
4484 sprintf(&ctmp,"%d", ctmp);
4485 Set_Channel_Proc(pAdapter, &ctmp);
4493 DBGPRINT(RT_DEBUG_TRACE, ("Set::unknown IOCTL's subcmd = 0x%08x\n", cmd));
4494 Status = -EOPNOTSUPP;
4502 INT RTMPQueryInformation(
4503 IN PRTMP_ADAPTER pAdapter,
4504 IN OUT struct ifreq *rq,
4507 struct iwreq *wrq = (struct iwreq *) rq;
4508 NDIS_802_11_BSSID_LIST_EX *pBssidList = NULL;
4509 PNDIS_WLAN_BSSID_EX pBss;
4510 NDIS_802_11_SSID Ssid;
4511 NDIS_802_11_CONFIGURATION *pConfiguration = NULL;
4512 RT_802_11_LINK_STATUS *pLinkStatus = NULL;
4513 RT_802_11_STA_CONFIG *pStaConfig = NULL;
4514 NDIS_802_11_STATISTICS *pStatistics = NULL;
4515 NDIS_802_11_RTS_THRESHOLD RtsThresh;
4516 NDIS_802_11_FRAGMENTATION_THRESHOLD FragThresh;
4517 NDIS_802_11_POWER_MODE PowerMode;
4518 NDIS_802_11_NETWORK_INFRASTRUCTURE BssType;
4519 RT_802_11_PREAMBLE PreamType;
4520 NDIS_802_11_AUTHENTICATION_MODE AuthMode;
4521 NDIS_802_11_WEP_STATUS WepStatus;
4522 NDIS_MEDIA_STATE MediaState;
4523 ULONG BssBufSize, ulInfo=0, NetworkTypeList[4], apsd = 0;
4525 PUCHAR pBuf = NULL, pPtr;
4526 INT Status = NDIS_STATUS_SUCCESS;
4527 UINT we_version_compiled;
4528 UCHAR i, Padding = 0;
4530 UCHAR driverVersion[8];
4531 OID_SET_HT_PHYMODE *pHTPhyMode = NULL;
4536 DefaultKeyIdxValue *pKeyIdxValue;
4538 TX_RTY_CFG_STRUC tx_rty_cfg;
4539 ULONG ShortRetryLimit, LongRetryLimit;
4545 case RT_OID_DEVICE_NAME:
4546 wrq->u.data.length = sizeof(STA_NIC_DEVICE_NAME);
4547 Status = copy_to_user(wrq->u.data.pointer, STA_NIC_DEVICE_NAME, wrq->u.data.length);
4549 case RT_OID_VERSION_INFO:
4550 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_VERSION_INFO \n"));
4551 wrq->u.data.length = 8*sizeof(UCHAR);
4552 sprintf(&driverVersion[0], "%s", STA_DRIVER_VERSION);
4553 driverVersion[7] = '\0';
4554 if (copy_to_user(wrq->u.data.pointer, &driverVersion, wrq->u.data.length))
4560 case RT_QUERY_ATE_TXDONE_COUNT:
4561 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_QUERY_ATE_TXDONE_COUNT \n"));
4562 wrq->u.data.length = sizeof(UINT32);
4563 if (copy_to_user(wrq->u.data.pointer, &pAdapter->ate.TxDoneCount, wrq->u.data.length))
4568 #endif // RALINK_ATE //
4569 case OID_802_11_BSSID_LIST:
4570 if (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
4573 * Still scanning, indicate the caller should try again.
4575 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_BSSID_LIST (Still scanning)\n"));
4578 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_BSSID_LIST (%d BSS returned)\n",pAdapter->ScanTab.BssNr));
4579 pAdapter->StaCfg.bScanReqIsFromWebUI = FALSE;
4580 // Claculate total buffer size required
4581 BssBufSize = sizeof(ULONG);
4583 for (i = 0; i < pAdapter->ScanTab.BssNr; i++)
4585 // Align pointer to 4 bytes boundary.
4586 //Padding = 4 - (pAdapter->ScanTab.BssEntry[i].VarIELen & 0x0003);
4589 BssBufSize += (sizeof(NDIS_WLAN_BSSID_EX) - 1 + sizeof(NDIS_802_11_FIXED_IEs) + pAdapter->ScanTab.BssEntry[i].VarIELen + Padding);
4592 // For safety issue, we add 256 bytes just in case
4594 // Allocate the same size as passed from higher layer
4595 pBuf = kmalloc(BssBufSize, MEM_ALLOC_FLAG);
4601 // Init 802_11_BSSID_LIST_EX structure
4602 NdisZeroMemory(pBuf, BssBufSize);
4603 pBssidList = (PNDIS_802_11_BSSID_LIST_EX) pBuf;
4604 pBssidList->NumberOfItems = pAdapter->ScanTab.BssNr;
4606 // Calculate total buffer length
4607 BssLen = 4; // Consist of NumberOfItems
4608 // Point to start of NDIS_WLAN_BSSID_EX
4609 // pPtr = pBuf + sizeof(ULONG);
4610 pPtr = (PUCHAR) &pBssidList->Bssid[0];
4611 for (i = 0; i < pAdapter->ScanTab.BssNr; i++)
4613 pBss = (PNDIS_WLAN_BSSID_EX) pPtr;
4614 NdisMoveMemory(&pBss->MacAddress, &pAdapter->ScanTab.BssEntry[i].Bssid, MAC_ADDR_LEN);
4615 if ((pAdapter->ScanTab.BssEntry[i].Hidden == 1) && (pAdapter->StaCfg.bShowHiddenSSID == FALSE))
4618 // We must return this SSID during 4way handshaking, otherwise Aegis will failed to parse WPA infomation
4619 // and then failed to send EAPOl farame.
4621 if ((pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA) && (pAdapter->StaCfg.PortSecured != WPA_802_1X_PORT_SECURED))
4623 pBss->Ssid.SsidLength = pAdapter->ScanTab.BssEntry[i].SsidLen;
4624 NdisMoveMemory(pBss->Ssid.Ssid, pAdapter->ScanTab.BssEntry[i].Ssid, pAdapter->ScanTab.BssEntry[i].SsidLen);
4627 pBss->Ssid.SsidLength = 0;
4631 pBss->Ssid.SsidLength = pAdapter->ScanTab.BssEntry[i].SsidLen;
4632 NdisMoveMemory(pBss->Ssid.Ssid, pAdapter->ScanTab.BssEntry[i].Ssid, pAdapter->ScanTab.BssEntry[i].SsidLen);
4634 pBss->Privacy = pAdapter->ScanTab.BssEntry[i].Privacy;
4635 pBss->Rssi = pAdapter->ScanTab.BssEntry[i].Rssi - pAdapter->BbpRssiToDbmDelta;
4636 pBss->NetworkTypeInUse = NetworkTypeInUseSanity(&pAdapter->ScanTab.BssEntry[i]);
4637 pBss->Configuration.Length = sizeof(NDIS_802_11_CONFIGURATION);
4638 pBss->Configuration.BeaconPeriod = pAdapter->ScanTab.BssEntry[i].BeaconPeriod;
4639 pBss->Configuration.ATIMWindow = pAdapter->ScanTab.BssEntry[i].AtimWin;
4641 MAP_CHANNEL_ID_TO_KHZ(pAdapter->ScanTab.BssEntry[i].Channel, pBss->Configuration.DSConfig);
4643 if (pAdapter->ScanTab.BssEntry[i].BssType == BSS_INFRA)
4644 pBss->InfrastructureMode = Ndis802_11Infrastructure;
4646 pBss->InfrastructureMode = Ndis802_11IBSS;
4648 NdisMoveMemory(pBss->SupportedRates, pAdapter->ScanTab.BssEntry[i].SupRate, pAdapter->ScanTab.BssEntry[i].SupRateLen);
4649 NdisMoveMemory(pBss->SupportedRates + pAdapter->ScanTab.BssEntry[i].SupRateLen,
4650 pAdapter->ScanTab.BssEntry[i].ExtRate,
4651 pAdapter->ScanTab.BssEntry[i].ExtRateLen);
4653 if (pAdapter->ScanTab.BssEntry[i].VarIELen == 0)
4655 pBss->IELength = sizeof(NDIS_802_11_FIXED_IEs);
4656 NdisMoveMemory(pBss->IEs, &pAdapter->ScanTab.BssEntry[i].FixIEs, sizeof(NDIS_802_11_FIXED_IEs));
4657 pPtr = pPtr + sizeof(NDIS_WLAN_BSSID_EX) - 1 + sizeof(NDIS_802_11_FIXED_IEs);
4661 pBss->IELength = (ULONG)(sizeof(NDIS_802_11_FIXED_IEs) + pAdapter->ScanTab.BssEntry[i].VarIELen);
4662 pPtr = pPtr + sizeof(NDIS_WLAN_BSSID_EX) - 1 + sizeof(NDIS_802_11_FIXED_IEs);
4663 NdisMoveMemory(pBss->IEs, &pAdapter->ScanTab.BssEntry[i].FixIEs, sizeof(NDIS_802_11_FIXED_IEs));
4664 NdisMoveMemory(pBss->IEs + sizeof(NDIS_802_11_FIXED_IEs), pAdapter->ScanTab.BssEntry[i].VarIEs, pAdapter->ScanTab.BssEntry[i].VarIELen);
4665 pPtr += pAdapter->ScanTab.BssEntry[i].VarIELen;
4667 pBss->Length = (ULONG)(sizeof(NDIS_WLAN_BSSID_EX) - 1 + sizeof(NDIS_802_11_FIXED_IEs) + pAdapter->ScanTab.BssEntry[i].VarIELen + Padding);
4669 #if WIRELESS_EXT < 17
4670 if ((BssLen + pBss->Length) < wrq->u.data.length)
4671 BssLen += pBss->Length;
4674 pBssidList->NumberOfItems = i;
4678 BssLen += pBss->Length;
4682 #if WIRELESS_EXT < 17
4683 wrq->u.data.length = BssLen;
4685 if (BssLen > wrq->u.data.length)
4691 wrq->u.data.length = BssLen;
4693 Status = copy_to_user(wrq->u.data.pointer, pBssidList, BssLen);
4696 case OID_802_3_CURRENT_ADDRESS:
4697 wrq->u.data.length = MAC_ADDR_LEN;
4698 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CurrentAddress, wrq->u.data.length);
4700 case OID_GEN_MEDIA_CONNECT_STATUS:
4701 if (pAdapter->IndicateMediaState == NdisMediaStateConnected)
4702 MediaState = NdisMediaStateConnected;
4704 MediaState = NdisMediaStateDisconnected;
4706 wrq->u.data.length = sizeof(NDIS_MEDIA_STATE);
4707 Status = copy_to_user(wrq->u.data.pointer, &MediaState, wrq->u.data.length);
4709 case OID_802_11_BSSID:
4711 if (ATE_ON(pAdapter))
4713 DBGPRINT(RT_DEBUG_TRACE, ("The driver is in ATE mode now\n"));
4714 Status = NDIS_STATUS_RESOURCES;
4717 #endif // RALINK_ATE //
4718 if (INFRA_ON(pAdapter) || ADHOC_ON(pAdapter))
4720 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.Bssid, sizeof(NDIS_802_11_MAC_ADDRESS));
4725 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_BSSID(=EMPTY)\n"));
4729 case OID_802_11_SSID:
4730 NdisZeroMemory(&Ssid, sizeof(NDIS_802_11_SSID));
4731 NdisZeroMemory(Ssid.Ssid, MAX_LEN_OF_SSID);
4732 Ssid.SsidLength = pAdapter->CommonCfg.SsidLen;
4733 memcpy(Ssid.Ssid, pAdapter->CommonCfg.Ssid, Ssid.SsidLength);
4734 wrq->u.data.length = sizeof(NDIS_802_11_SSID);
4735 Status = copy_to_user(wrq->u.data.pointer, &Ssid, wrq->u.data.length);
4736 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_SSID (Len=%d, ssid=%s)\n", Ssid.SsidLength,Ssid.Ssid));
4738 case RT_OID_802_11_QUERY_LINK_STATUS:
4739 pLinkStatus = (RT_802_11_LINK_STATUS *) kmalloc(sizeof(RT_802_11_LINK_STATUS), MEM_ALLOC_FLAG);
4742 pLinkStatus->CurrTxRate = RateIdTo500Kbps[pAdapter->CommonCfg.TxRate]; // unit : 500 kbps
4743 pLinkStatus->ChannelQuality = pAdapter->Mlme.ChannelQuality;
4744 pLinkStatus->RxByteCount = pAdapter->RalinkCounters.ReceivedByteCount;
4745 pLinkStatus->TxByteCount = pAdapter->RalinkCounters.TransmittedByteCount;
4746 pLinkStatus->CentralChannel = pAdapter->CommonCfg.CentralChannel;
4747 wrq->u.data.length = sizeof(RT_802_11_LINK_STATUS);
4748 Status = copy_to_user(wrq->u.data.pointer, pLinkStatus, wrq->u.data.length);
4750 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_LINK_STATUS\n"));
4754 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_LINK_STATUS(kmalloc failed)\n"));
4758 case OID_802_11_CONFIGURATION:
4759 pConfiguration = (NDIS_802_11_CONFIGURATION *) kmalloc(sizeof(NDIS_802_11_CONFIGURATION), MEM_ALLOC_FLAG);
4762 pConfiguration->Length = sizeof(NDIS_802_11_CONFIGURATION);
4763 pConfiguration->BeaconPeriod = pAdapter->CommonCfg.BeaconPeriod;
4764 pConfiguration->ATIMWindow = pAdapter->StaActive.AtimWin;
4765 MAP_CHANNEL_ID_TO_KHZ(pAdapter->CommonCfg.Channel, pConfiguration->DSConfig);
4766 wrq->u.data.length = sizeof(NDIS_802_11_CONFIGURATION);
4767 Status = copy_to_user(wrq->u.data.pointer, pConfiguration, wrq->u.data.length);
4768 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_CONFIGURATION(BeaconPeriod=%ld,AtimW=%ld,Channel=%d) \n",
4769 pConfiguration->BeaconPeriod, pConfiguration->ATIMWindow, pAdapter->CommonCfg.Channel));
4770 kfree(pConfiguration);
4774 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_CONFIGURATION(kmalloc failed)\n"));
4778 case RT_OID_802_11_SNR_0:
4779 if ((pAdapter->StaCfg.LastSNR0 > 0))
4781 ulInfo = ((0xeb - pAdapter->StaCfg.LastSNR0) * 3) / 16 ;
4782 wrq->u.data.length = sizeof(ulInfo);
4783 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4784 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_SNR_0(0x=%lx)\n", ulInfo));
4789 case RT_OID_802_11_SNR_1:
4790 if ((pAdapter->Antenna.field.RxPath > 1) &&
4791 (pAdapter->StaCfg.LastSNR1 > 0))
4793 ulInfo = ((0xeb - pAdapter->StaCfg.LastSNR1) * 3) / 16 ;
4794 wrq->u.data.length = sizeof(ulInfo);
4795 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4796 DBGPRINT(RT_DEBUG_TRACE,("Query::RT_OID_802_11_SNR_1(0x=%lx)\n",ulInfo));
4800 DBGPRINT(RT_DEBUG_TRACE,("Query::RT_OID_802_11_SNR_1(pAdapter->StaCfg.LastSNR1=%d)\n",pAdapter->StaCfg.LastSNR1));
4802 case OID_802_11_RSSI_TRIGGER:
4803 ulInfo = pAdapter->StaCfg.RssiSample.LastRssi0 - pAdapter->BbpRssiToDbmDelta;
4804 wrq->u.data.length = sizeof(ulInfo);
4805 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4806 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_RSSI_TRIGGER(=%ld)\n", ulInfo));
4808 case OID_802_11_RSSI:
4809 case RT_OID_802_11_RSSI:
4810 ulInfo = pAdapter->StaCfg.RssiSample.LastRssi0;
4811 wrq->u.data.length = sizeof(ulInfo);
4812 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4814 case RT_OID_802_11_RSSI_1:
4815 ulInfo = pAdapter->StaCfg.RssiSample.LastRssi1;
4816 wrq->u.data.length = sizeof(ulInfo);
4817 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4819 case RT_OID_802_11_RSSI_2:
4820 ulInfo = pAdapter->StaCfg.RssiSample.LastRssi2;
4821 wrq->u.data.length = sizeof(ulInfo);
4822 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4824 case OID_802_11_STATISTICS:
4825 pStatistics = (NDIS_802_11_STATISTICS *) kmalloc(sizeof(NDIS_802_11_STATISTICS), MEM_ALLOC_FLAG);
4828 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_STATISTICS \n"));
4829 // add the most up-to-date h/w raw counters into software counters
4830 NICUpdateRawCounters(pAdapter);
4832 // Sanity check for calculation of sucessful count
4833 if (pAdapter->WlanCounters.TransmittedFragmentCount.QuadPart < pAdapter->WlanCounters.RetryCount.QuadPart)
4834 pAdapter->WlanCounters.TransmittedFragmentCount.QuadPart = pAdapter->WlanCounters.RetryCount.QuadPart;
4836 pStatistics->TransmittedFragmentCount.QuadPart = pAdapter->WlanCounters.TransmittedFragmentCount.QuadPart;
4837 pStatistics->MulticastTransmittedFrameCount.QuadPart = pAdapter->WlanCounters.MulticastTransmittedFrameCount.QuadPart;
4838 pStatistics->FailedCount.QuadPart = pAdapter->WlanCounters.FailedCount.QuadPart;
4839 pStatistics->RetryCount.QuadPart = pAdapter->WlanCounters.RetryCount.QuadPart;
4840 pStatistics->MultipleRetryCount.QuadPart = pAdapter->WlanCounters.MultipleRetryCount.QuadPart;
4841 pStatistics->RTSSuccessCount.QuadPart = pAdapter->WlanCounters.RTSSuccessCount.QuadPart;
4842 pStatistics->RTSFailureCount.QuadPart = pAdapter->WlanCounters.RTSFailureCount.QuadPart;
4843 pStatistics->ACKFailureCount.QuadPart = pAdapter->WlanCounters.ACKFailureCount.QuadPart;
4844 pStatistics->FrameDuplicateCount.QuadPart = pAdapter->WlanCounters.FrameDuplicateCount.QuadPart;
4845 pStatistics->ReceivedFragmentCount.QuadPart = pAdapter->WlanCounters.ReceivedFragmentCount.QuadPart;
4846 pStatistics->MulticastReceivedFrameCount.QuadPart = pAdapter->WlanCounters.MulticastReceivedFrameCount.QuadPart;
4848 pStatistics->FCSErrorCount = pAdapter->RalinkCounters.RealFcsErrCount;
4850 pStatistics->FCSErrorCount.QuadPart = pAdapter->WlanCounters.FCSErrorCount.QuadPart;
4851 pStatistics->FrameDuplicateCount.u.LowPart = pAdapter->WlanCounters.FrameDuplicateCount.u.LowPart / 100;
4853 wrq->u.data.length = sizeof(NDIS_802_11_STATISTICS);
4854 Status = copy_to_user(wrq->u.data.pointer, pStatistics, wrq->u.data.length);
4859 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_STATISTICS(kmalloc failed)\n"));
4863 case OID_GEN_RCV_OK:
4864 ulInfo = pAdapter->Counters8023.GoodReceives;
4865 wrq->u.data.length = sizeof(ulInfo);
4866 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4868 case OID_GEN_RCV_NO_BUFFER:
4869 ulInfo = pAdapter->Counters8023.RxNoBuffer;
4870 wrq->u.data.length = sizeof(ulInfo);
4871 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4873 case RT_OID_802_11_PHY_MODE:
4874 ulInfo = (ULONG)pAdapter->CommonCfg.PhyMode;
4875 wrq->u.data.length = sizeof(ulInfo);
4876 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4877 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_PHY_MODE (=%ld)\n", ulInfo));
4879 case RT_OID_802_11_STA_CONFIG:
4880 pStaConfig = (RT_802_11_STA_CONFIG *) kmalloc(sizeof(RT_802_11_STA_CONFIG), MEM_ALLOC_FLAG);
4883 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_STA_CONFIG\n"));
4884 pStaConfig->EnableTxBurst = pAdapter->CommonCfg.bEnableTxBurst;
4885 pStaConfig->EnableTurboRate = 0;
4886 pStaConfig->UseBGProtection = pAdapter->CommonCfg.UseBGProtection;
4887 pStaConfig->UseShortSlotTime = pAdapter->CommonCfg.bUseShortSlotTime;
4888 //pStaConfig->AdhocMode = pAdapter->StaCfg.AdhocMode;
4889 pStaConfig->HwRadioStatus = (pAdapter->StaCfg.bHwRadio == TRUE) ? 1 : 0;
4890 pStaConfig->Rsv1 = 0;
4891 pStaConfig->SystemErrorBitmap = pAdapter->SystemErrorBitmap;
4892 wrq->u.data.length = sizeof(RT_802_11_STA_CONFIG);
4893 Status = copy_to_user(wrq->u.data.pointer, pStaConfig, wrq->u.data.length);
4898 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_STA_CONFIG(kmalloc failed)\n"));
4902 case OID_802_11_RTS_THRESHOLD:
4903 RtsThresh = pAdapter->CommonCfg.RtsThreshold;
4904 wrq->u.data.length = sizeof(RtsThresh);
4905 Status = copy_to_user(wrq->u.data.pointer, &RtsThresh, wrq->u.data.length);
4906 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_RTS_THRESHOLD(=%ld)\n", RtsThresh));
4908 case OID_802_11_FRAGMENTATION_THRESHOLD:
4909 FragThresh = pAdapter->CommonCfg.FragmentThreshold;
4910 if (pAdapter->CommonCfg.bUseZeroToDisableFragment == TRUE)
4912 wrq->u.data.length = sizeof(FragThresh);
4913 Status = copy_to_user(wrq->u.data.pointer, &FragThresh, wrq->u.data.length);
4914 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_FRAGMENTATION_THRESHOLD(=%ld)\n", FragThresh));
4916 case OID_802_11_POWER_MODE:
4917 PowerMode = pAdapter->StaCfg.WindowsPowerMode;
4918 wrq->u.data.length = sizeof(PowerMode);
4919 Status = copy_to_user(wrq->u.data.pointer, &PowerMode, wrq->u.data.length);
4920 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_POWER_MODE(=%d)\n", PowerMode));
4922 case RT_OID_802_11_RADIO:
4923 RadioState = (BOOLEAN) pAdapter->StaCfg.bSwRadio;
4924 wrq->u.data.length = sizeof(RadioState);
4925 Status = copy_to_user(wrq->u.data.pointer, &RadioState, wrq->u.data.length);
4926 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_RADIO (=%d)\n", RadioState));
4928 case OID_802_11_INFRASTRUCTURE_MODE:
4929 if (pAdapter->StaCfg.BssType == BSS_ADHOC)
4930 BssType = Ndis802_11IBSS;
4931 else if (pAdapter->StaCfg.BssType == BSS_INFRA)
4932 BssType = Ndis802_11Infrastructure;
4933 else if (pAdapter->StaCfg.BssType == BSS_MONITOR)
4934 BssType = Ndis802_11Monitor;
4936 BssType = Ndis802_11AutoUnknown;
4938 wrq->u.data.length = sizeof(BssType);
4939 Status = copy_to_user(wrq->u.data.pointer, &BssType, wrq->u.data.length);
4940 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_INFRASTRUCTURE_MODE(=%d)\n", BssType));
4942 case RT_OID_802_11_PREAMBLE:
4943 PreamType = pAdapter->CommonCfg.TxPreamble;
4944 wrq->u.data.length = sizeof(PreamType);
4945 Status = copy_to_user(wrq->u.data.pointer, &PreamType, wrq->u.data.length);
4946 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_PREAMBLE(=%d)\n", PreamType));
4948 case OID_802_11_AUTHENTICATION_MODE:
4949 AuthMode = pAdapter->StaCfg.AuthMode;
4950 wrq->u.data.length = sizeof(AuthMode);
4951 Status = copy_to_user(wrq->u.data.pointer, &AuthMode, wrq->u.data.length);
4952 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_AUTHENTICATION_MODE(=%d)\n", AuthMode));
4954 case OID_802_11_WEP_STATUS:
4955 WepStatus = pAdapter->StaCfg.WepStatus;
4956 wrq->u.data.length = sizeof(WepStatus);
4957 Status = copy_to_user(wrq->u.data.pointer, &WepStatus, wrq->u.data.length);
4958 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_WEP_STATUS(=%d)\n", WepStatus));
4960 case OID_802_11_TX_POWER_LEVEL:
4961 wrq->u.data.length = sizeof(ULONG);
4962 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.TxPower, wrq->u.data.length);
4963 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_TX_POWER_LEVEL %x\n",pAdapter->CommonCfg.TxPower));
4965 case RT_OID_802_11_TX_POWER_LEVEL_1:
4966 wrq->u.data.length = sizeof(ULONG);
4967 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.TxPowerPercentage, wrq->u.data.length);
4968 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_TX_POWER_LEVEL_1 (=%ld)\n", pAdapter->CommonCfg.TxPowerPercentage));
4970 case OID_802_11_NETWORK_TYPES_SUPPORTED:
4971 if ((pAdapter->RfIcType == RFIC_2850) || (pAdapter->RfIcType == RFIC_2750))
4973 NetworkTypeList[0] = 3; // NumberOfItems = 3
4974 NetworkTypeList[1] = Ndis802_11DS; // NetworkType[1] = 11b
4975 NetworkTypeList[2] = Ndis802_11OFDM24; // NetworkType[2] = 11g
4976 NetworkTypeList[3] = Ndis802_11OFDM5; // NetworkType[3] = 11a
4977 wrq->u.data.length = 16;
4978 Status = copy_to_user(wrq->u.data.pointer, &NetworkTypeList[0], wrq->u.data.length);
4982 NetworkTypeList[0] = 2; // NumberOfItems = 2
4983 NetworkTypeList[1] = Ndis802_11DS; // NetworkType[1] = 11b
4984 NetworkTypeList[2] = Ndis802_11OFDM24; // NetworkType[2] = 11g
4985 wrq->u.data.length = 12;
4986 Status = copy_to_user(wrq->u.data.pointer, &NetworkTypeList[0], wrq->u.data.length);
4988 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_NETWORK_TYPES_SUPPORTED\n"));
4990 case OID_802_11_NETWORK_TYPE_IN_USE:
4991 wrq->u.data.length = sizeof(ULONG);
4992 if (pAdapter->CommonCfg.PhyMode == PHY_11A)
4993 ulInfo = Ndis802_11OFDM5;
4994 else if ((pAdapter->CommonCfg.PhyMode == PHY_11BG_MIXED) || (pAdapter->CommonCfg.PhyMode == PHY_11G))
4995 ulInfo = Ndis802_11OFDM24;
4997 ulInfo = Ndis802_11DS;
4998 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
5000 case RT_OID_802_11_QUERY_LAST_RX_RATE:
5001 ulInfo = (ULONG)pAdapter->LastRxRate;
5002 wrq->u.data.length = sizeof(ulInfo);
5003 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
5004 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_LAST_RX_RATE (=%ld)\n", ulInfo));
5006 case RT_OID_802_11_QUERY_LAST_TX_RATE:
5007 //ulInfo = (ULONG)pAdapter->LastTxRate;
5008 ulInfo = (ULONG)pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.word;
5009 wrq->u.data.length = sizeof(ulInfo);
5010 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
5011 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_LAST_TX_RATE (=%lx)\n", ulInfo));
5013 case RT_OID_802_11_QUERY_EEPROM_VERSION:
5014 wrq->u.data.length = sizeof(ULONG);
5015 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->EepromVersion, wrq->u.data.length);
5017 case RT_OID_802_11_QUERY_FIRMWARE_VERSION:
5018 wrq->u.data.length = sizeof(ULONG);
5019 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->FirmwareVersion, wrq->u.data.length);
5021 case RT_OID_802_11_QUERY_NOISE_LEVEL:
5022 wrq->u.data.length = sizeof(UCHAR);
5023 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->BbpWriteLatch[66], wrq->u.data.length);
5024 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_NOISE_LEVEL (=%d)\n", pAdapter->BbpWriteLatch[66]));
5026 case RT_OID_802_11_EXTRA_INFO:
5027 wrq->u.data.length = sizeof(ULONG);
5028 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->ExtraInfo, wrq->u.data.length);
5029 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_EXTRA_INFO (=%ld)\n", pAdapter->ExtraInfo));
5031 case RT_OID_WE_VERSION_COMPILED:
5032 wrq->u.data.length = sizeof(UINT);
5033 we_version_compiled = WIRELESS_EXT;
5034 Status = copy_to_user(wrq->u.data.pointer, &we_version_compiled, wrq->u.data.length);
5036 case RT_OID_802_11_QUERY_APSD_SETTING:
5037 apsd = (pAdapter->CommonCfg.bAPSDCapable | (pAdapter->CommonCfg.bAPSDAC_BE << 1) | (pAdapter->CommonCfg.bAPSDAC_BK << 2)
5038 | (pAdapter->CommonCfg.bAPSDAC_VI << 3) | (pAdapter->CommonCfg.bAPSDAC_VO << 4) | (pAdapter->CommonCfg.MaxSPLength << 5));
5040 wrq->u.data.length = sizeof(ULONG);
5041 Status = copy_to_user(wrq->u.data.pointer, &apsd, wrq->u.data.length);
5042 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",
5043 apsd,pAdapter->CommonCfg.bAPSDCapable,pAdapter->CommonCfg.bAPSDAC_BE,pAdapter->CommonCfg.bAPSDAC_BK,pAdapter->CommonCfg.bAPSDAC_VI,pAdapter->CommonCfg.bAPSDAC_VO,pAdapter->CommonCfg.MaxSPLength));
5045 case RT_OID_802_11_QUERY_APSD_PSM:
5046 wrq->u.data.length = sizeof(ULONG);
5047 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.bAPSDForcePowerSave, wrq->u.data.length);
5048 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_APSD_PSM (=%d)\n", pAdapter->CommonCfg.bAPSDForcePowerSave));
5050 case RT_OID_802_11_QUERY_WMM:
5051 wrq->u.data.length = sizeof(BOOLEAN);
5052 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.bWmmCapable, wrq->u.data.length);
5053 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_WMM (=%d)\n", pAdapter->CommonCfg.bWmmCapable));
5055 #ifdef WPA_SUPPLICANT_SUPPORT
5056 case RT_OID_NEW_DRIVER:
5059 wrq->u.data.length = sizeof(UCHAR);
5060 Status = copy_to_user(wrq->u.data.pointer, &enabled, wrq->u.data.length);
5061 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_NEW_DRIVER (=%d)\n", enabled));
5064 case RT_OID_WPA_SUPPLICANT_SUPPORT:
5065 wrq->u.data.length = sizeof(UCHAR);
5066 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->StaCfg.WpaSupplicantUP, wrq->u.data.length);
5067 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_WPA_SUPPLICANT_SUPPORT (=%d)\n", pAdapter->StaCfg.WpaSupplicantUP));
5069 #endif // WPA_SUPPLICANT_SUPPORT //
5071 case RT_OID_DRIVER_DEVICE_NAME:
5072 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_DRIVER_DEVICE_NAME \n"));
5073 wrq->u.data.length = 16;
5074 if (copy_to_user(wrq->u.data.pointer, pAdapter->StaCfg.dev_name, wrq->u.data.length))
5079 case RT_OID_802_11_QUERY_HT_PHYMODE:
5080 pHTPhyMode = (OID_SET_HT_PHYMODE *) kmalloc(sizeof(OID_SET_HT_PHYMODE), MEM_ALLOC_FLAG);
5083 pHTPhyMode->PhyMode = pAdapter->CommonCfg.PhyMode;
5084 pHTPhyMode->HtMode = (UCHAR)pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.field.MODE;
5085 pHTPhyMode->BW = (UCHAR)pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.field.BW;
5086 pHTPhyMode->MCS= (UCHAR)pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.field.MCS;
5087 pHTPhyMode->SHORTGI= (UCHAR)pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.field.ShortGI;
5088 pHTPhyMode->STBC= (UCHAR)pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.field.STBC;
5090 pHTPhyMode->ExtOffset = ((pAdapter->CommonCfg.CentralChannel < pAdapter->CommonCfg.Channel) ? (EXTCHA_BELOW) : (EXTCHA_ABOVE));
5091 wrq->u.data.length = sizeof(OID_SET_HT_PHYMODE);
5092 if (copy_to_user(wrq->u.data.pointer, pHTPhyMode, wrq->u.data.length))
5096 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_HT_PHYMODE (PhyMode = %d, MCS =%d, BW = %d, STBC = %d, ExtOffset=%d)\n",
5097 pHTPhyMode->HtMode, pHTPhyMode->MCS, pHTPhyMode->BW, pHTPhyMode->STBC, pHTPhyMode->ExtOffset));
5098 DBGPRINT(RT_DEBUG_TRACE, (" MlmeUpdateTxRates (.word = %x )\n", pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.word));
5102 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_STA_CONFIG(kmalloc failed)\n"));
5106 case RT_OID_802_11_COUNTRY_REGION:
5107 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_COUNTRY_REGION \n"));
5108 wrq->u.data.length = sizeof(ulInfo);
5109 ulInfo = pAdapter->CommonCfg.CountryRegionForABand;
5110 ulInfo = (ulInfo << 8)|(pAdapter->CommonCfg.CountryRegion);
5111 if (copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length))
5116 case RT_OID_802_11_QUERY_DAT_HT_PHYMODE:
5117 pHTPhyMode = (OID_SET_HT_PHYMODE *) kmalloc(sizeof(OID_SET_HT_PHYMODE), MEM_ALLOC_FLAG);
5120 pHTPhyMode->PhyMode = pAdapter->CommonCfg.PhyMode;
5121 pHTPhyMode->HtMode = (UCHAR)pAdapter->CommonCfg.RegTransmitSetting.field.HTMODE;
5122 pHTPhyMode->BW = (UCHAR)pAdapter->CommonCfg.RegTransmitSetting.field.BW;
5123 pHTPhyMode->MCS= (UCHAR)pAdapter->StaCfg.DesiredTransmitSetting.field.MCS;
5124 pHTPhyMode->SHORTGI= (UCHAR)pAdapter->CommonCfg.RegTransmitSetting.field.ShortGI;
5125 pHTPhyMode->STBC= (UCHAR)pAdapter->CommonCfg.RegTransmitSetting.field.STBC;
5127 wrq->u.data.length = sizeof(OID_SET_HT_PHYMODE);
5128 if (copy_to_user(wrq->u.data.pointer, pHTPhyMode, wrq->u.data.length))
5132 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_HT_PHYMODE (PhyMode = %d, MCS =%d, BW = %d, STBC = %d, ExtOffset=%d)\n",
5133 pHTPhyMode->HtMode, pHTPhyMode->MCS, pHTPhyMode->BW, pHTPhyMode->STBC, pHTPhyMode->ExtOffset));
5134 DBGPRINT(RT_DEBUG_TRACE, (" MlmeUpdateTxRates (.word = %x )\n", pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.word));
5138 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_STA_CONFIG(kmalloc failed)\n"));
5142 case RT_OID_QUERY_MULTIPLE_CARD_SUPPORT:
5143 wrq->u.data.length = sizeof(UCHAR);
5145 #ifdef MULTIPLE_CARD_SUPPORT
5147 #endif // MULTIPLE_CARD_SUPPORT //
5148 if (copy_to_user(wrq->u.data.pointer, &i, wrq->u.data.length))
5152 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_QUERY_MULTIPLE_CARD_SUPPORT(=%d) \n", i));
5155 case RT_OID_802_11_MAC_ADDRESS:
5156 wrq->u.data.length = MAC_ADDR_LEN;
5157 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CurrentAddress, wrq->u.data.length);
5160 case RT_OID_802_11_MANUFACTUREROUI:
5161 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_MANUFACTUREROUI \n"));
5162 wrq->u.data.length = ManufacturerOUI_LEN;
5163 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CurrentAddress, wrq->u.data.length);
5166 case RT_OID_802_11_MANUFACTURERNAME:
5167 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_MANUFACTURERNAME \n"));
5168 wrq->u.data.length = strlen(ManufacturerNAME);
5169 Status = copy_to_user(wrq->u.data.pointer, ManufacturerNAME, wrq->u.data.length);
5172 case RT_OID_802_11_RESOURCETYPEIDNAME:
5173 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_RESOURCETYPEIDNAME \n"));
5174 wrq->u.data.length = strlen(ResourceTypeIdName);
5175 Status = copy_to_user(wrq->u.data.pointer, ResourceTypeIdName, wrq->u.data.length);
5178 case RT_OID_802_11_PRIVACYOPTIONIMPLEMENTED:
5179 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_PRIVACYOPTIONIMPLEMENTED \n"));
5180 ulInfo = 1; // 1 is support wep else 2 is not support.
5181 wrq->u.data.length = sizeof(ulInfo);
5182 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
5185 case RT_OID_802_11_POWERMANAGEMENTMODE:
5186 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_POWERMANAGEMENTMODE \n"));
5187 if (pAdapter->StaCfg.Psm == PSMP_ACTION)
5188 ulInfo = 1; // 1 is power active else 2 is power save.
5192 wrq->u.data.length = sizeof(ulInfo);
5193 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
5196 case OID_802_11_WEPDEFAULTKEYVALUE:
5197 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_WEPDEFAULTKEYVALUE \n"));
5198 //KeyIdxValue.KeyIdx = pAd->PortCfg.MBSSID[pAd->IoctlIF].DefaultKeyId;
5199 pKeyIdxValue = wrq->u.data.pointer;
5200 DBGPRINT(RT_DEBUG_TRACE,("KeyIdxValue.KeyIdx = %d, \n",pKeyIdxValue->KeyIdx));
5201 valueLen = pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].KeyLen;
5202 NdisMoveMemory(pKeyIdxValue->Value,
5203 &pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].Key,
5205 pKeyIdxValue->Value[valueLen]='\0';
5207 wrq->u.data.length = sizeof(DefaultKeyIdxValue);
5209 Status = copy_to_user(wrq->u.data.pointer, pKeyIdxValue, wrq->u.data.length);
5210 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,
5211 pAdapter->SharedKey[BSS0][0].Key[0],
5212 pAdapter->SharedKey[BSS0][1].Key[0],
5213 pAdapter->SharedKey[BSS0][2].Key[0],
5214 pAdapter->SharedKey[BSS0][3].Key[0]));
5217 case OID_802_11_WEPDEFAULTKEYID:
5218 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_WEPDEFAULTKEYID \n"));
5219 wrq->u.data.length = sizeof(UCHAR);
5220 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->StaCfg.DefaultKeyId, wrq->u.data.length);
5221 DBGPRINT(RT_DEBUG_TRACE, ("DefaultKeyId =%d \n", pAdapter->StaCfg.DefaultKeyId));
5224 case RT_OID_802_11_WEPKEYMAPPINGLENGTH:
5225 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_WEPKEYMAPPINGLENGTH \n"));
5226 wrq->u.data.length = sizeof(UCHAR);
5227 Status = copy_to_user(wrq->u.data.pointer,
5228 &pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].KeyLen,
5229 wrq->u.data.length);
5232 case OID_802_11_SHORTRETRYLIMIT:
5233 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_SHORTRETRYLIMIT \n"));
5234 wrq->u.data.length = sizeof(ULONG);
5235 RTMP_IO_READ32(pAdapter, TX_RTY_CFG, &tx_rty_cfg.word);
5236 ShortRetryLimit = tx_rty_cfg.field.ShortRtyLimit;
5237 DBGPRINT(RT_DEBUG_TRACE, ("ShortRetryLimit =%ld, tx_rty_cfg.field.ShortRetryLimit=%d\n", ShortRetryLimit, tx_rty_cfg.field.ShortRtyLimit));
5238 Status = copy_to_user(wrq->u.data.pointer, &ShortRetryLimit, wrq->u.data.length);
5241 case OID_802_11_LONGRETRYLIMIT:
5242 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_LONGRETRYLIMIT \n"));
5243 wrq->u.data.length = sizeof(ULONG);
5244 RTMP_IO_READ32(pAdapter, TX_RTY_CFG, &tx_rty_cfg.word);
5245 LongRetryLimit = tx_rty_cfg.field.LongRtyLimit;
5246 DBGPRINT(RT_DEBUG_TRACE, ("LongRetryLimit =%ld, tx_rty_cfg.field.LongRtyLimit=%d\n", LongRetryLimit, tx_rty_cfg.field.LongRtyLimit));
5247 Status = copy_to_user(wrq->u.data.pointer, &LongRetryLimit, wrq->u.data.length);
5250 case RT_OID_802_11_PRODUCTID:
5251 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_PRODUCTID \n"));
5254 sprintf(tmp, "%04x %04x\n", ((POS_COOKIE)pAdapter->OS_Cookie)->pUsb_Dev->descriptor.idVendor ,((POS_COOKIE)pAdapter->OS_Cookie)->pUsb_Dev->descriptor.idProduct);
5257 wrq->u.data.length = strlen(tmp);
5258 Status = copy_to_user(wrq->u.data.pointer, tmp, wrq->u.data.length);
5261 case RT_OID_802_11_MANUFACTUREID:
5262 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_MANUFACTUREID \n"));
5263 wrq->u.data.length = strlen(ManufacturerNAME);
5264 Status = copy_to_user(wrq->u.data.pointer, ManufacturerNAME, wrq->u.data.length);
5267 case OID_802_11_CURRENTCHANNEL:
5268 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_CURRENTCHANNEL \n"));
5269 wrq->u.data.length = sizeof(UCHAR);
5270 DBGPRINT(RT_DEBUG_TRACE, ("sizeof UCHAR=%d, channel=%d \n", sizeof(UCHAR), pAdapter->CommonCfg.Channel));
5271 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.Channel, wrq->u.data.length);
5272 DBGPRINT(RT_DEBUG_TRACE, ("Status=%d\n", Status));
5274 #endif //SNMP_SUPPORT
5276 case OID_802_11_BUILD_CHANNEL_EX:
5279 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_BUILD_CHANNEL_EX \n"));
5280 wrq->u.data.length = sizeof(UCHAR);
5281 #ifdef EXT_BUILD_CHANNEL_LIST
5282 DBGPRINT(RT_DEBUG_TRACE, ("Support EXT_BUILD_CHANNEL_LIST.\n"));
5285 DBGPRINT(RT_DEBUG_TRACE, ("Doesn't support EXT_BUILD_CHANNEL_LIST.\n"));
5287 #endif // EXT_BUILD_CHANNEL_LIST //
5288 Status = copy_to_user(wrq->u.data.pointer, &value, 1);
5289 DBGPRINT(RT_DEBUG_TRACE, ("Status=%d\n", Status));
5293 case OID_802_11_GET_CH_LIST:
5295 PRT_CHANNEL_LIST_INFO pChListBuf;
5297 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_GET_CH_LIST \n"));
5298 if (pAdapter->ChannelListNum == 0)
5300 wrq->u.data.length = 0;
5304 pChListBuf = (RT_CHANNEL_LIST_INFO *) kmalloc(sizeof(RT_CHANNEL_LIST_INFO), MEM_ALLOC_FLAG);
5305 if (pChListBuf == NULL)
5307 wrq->u.data.length = 0;
5311 pChListBuf->ChannelListNum = pAdapter->ChannelListNum;
5312 for (i = 0; i < pChListBuf->ChannelListNum; i++)
5313 pChListBuf->ChannelList[i] = pAdapter->ChannelList[i].Channel;
5315 wrq->u.data.length = sizeof(RT_CHANNEL_LIST_INFO);
5316 Status = copy_to_user(wrq->u.data.pointer, pChListBuf, sizeof(RT_CHANNEL_LIST_INFO));
5317 DBGPRINT(RT_DEBUG_TRACE, ("Status=%d\n", Status));
5324 case OID_802_11_GET_COUNTRY_CODE:
5325 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_GET_COUNTRY_CODE \n"));
5326 wrq->u.data.length = 2;
5327 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.CountryCode, 2);
5328 DBGPRINT(RT_DEBUG_TRACE, ("Status=%d\n", Status));
5331 case OID_802_11_GET_CHANNEL_GEOGRAPHY:
5332 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_GET_CHANNEL_GEOGRAPHY \n"));
5333 wrq->u.data.length = 1;
5334 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.Geography, 1);
5335 DBGPRINT(RT_DEBUG_TRACE, ("Status=%d\n", Status));
5339 #ifdef QOS_DLS_SUPPORT
5340 case RT_OID_802_11_QUERY_DLS:
5341 wrq->u.data.length = sizeof(BOOLEAN);
5342 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.bDLSCapable, wrq->u.data.length);
5343 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_DLS(=%d)\n", pAdapter->CommonCfg.bDLSCapable));
5346 case RT_OID_802_11_QUERY_DLS_PARAM:
5348 PRT_802_11_DLS_INFO pDlsInfo = kmalloc(sizeof(RT_802_11_DLS_INFO), GFP_ATOMIC);
5349 if (pDlsInfo == NULL)
5352 for (i=0; i<MAX_NUM_OF_DLS_ENTRY; i++)
5354 RTMPMoveMemory(&pDlsInfo->Entry[i], &pAdapter->StaCfg.DLSEntry[i], sizeof(RT_802_11_DLS_UI));
5357 pDlsInfo->num = MAX_NUM_OF_DLS_ENTRY;
5358 wrq->u.data.length = sizeof(RT_802_11_DLS_INFO);
5359 Status = copy_to_user(wrq->u.data.pointer, pDlsInfo, wrq->u.data.length);
5360 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_DLS_PARAM\n"));
5366 #endif // QOS_DLS_SUPPORT //
5368 DBGPRINT(RT_DEBUG_TRACE, ("Query::unknown IOCTL's subcmd = 0x%08x\n", cmd));
5369 Status = -EOPNOTSUPP;
5375 INT rt28xx_sta_ioctl(
5376 IN struct net_device *net_dev,
5377 IN OUT struct ifreq *rq,
5381 VIRTUAL_ADAPTER *pVirtualAd = NULL;
5382 RTMP_ADAPTER *pAd = NULL;
5383 struct iwreq *wrq = (struct iwreq *) rq;
5384 BOOLEAN StateMachineTouched = FALSE;
5385 INT Status = NDIS_STATUS_SUCCESS;
5388 if (net_dev->priv_flags == INT_MAIN)
5390 pAd = net_dev->ml_priv;
5394 pVirtualAd = net_dev->ml_priv;
5395 pAd = pVirtualAd->RtmpDev->ml_priv;
5397 pObj = (POS_COOKIE) pAd->OS_Cookie;
5401 /* if 1st open fail, pAd will be free;
5402 So the net_dev->ml_priv will be NULL in 2rd open */
5406 //check if the interface is down
5407 if(!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_IN_USE))
5410 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
5415 { // determine this ioctl command is comming from which interface.
5416 pObj->ioctl_if_type = INT_MAIN;
5417 pObj->ioctl_if = MAIN_MBSSID;
5423 #ifdef RALINK_28xx_QA
5424 case RTPRIV_IOCTL_ATE:
5426 RtmpDoAte(pAd, wrq);
5429 #endif // RALINK_28xx_QA //
5430 #endif // RALINK_ATE //
5432 DBGPRINT(RT_DEBUG_TRACE, ("IOCTL::SIOCGIFHWADDR\n"));
5433 memcpy(wrq->u.name, pAd->CurrentAddress, ETH_ALEN);
5437 char *name=&wrq->u.name[0];
5438 rt_ioctl_giwname(net_dev, NULL, name, NULL);
5441 case SIOCGIWESSID: //Get ESSID
5443 struct iw_point *essid=&wrq->u.essid;
5444 rt_ioctl_giwessid(net_dev, NULL, essid, essid->pointer);
5447 case SIOCSIWESSID: //Set ESSID
5449 struct iw_point *essid=&wrq->u.essid;
5450 rt_ioctl_siwessid(net_dev, NULL, essid, essid->pointer);
5453 case SIOCSIWNWID: // set network id (the cell)
5454 case SIOCGIWNWID: // get network id
5455 Status = -EOPNOTSUPP;
5457 case SIOCSIWFREQ: //set channel/frequency (Hz)
5459 struct iw_freq *freq=&wrq->u.freq;
5460 rt_ioctl_siwfreq(net_dev, NULL, freq, NULL);
5463 case SIOCGIWFREQ: // get channel/frequency (Hz)
5465 struct iw_freq *freq=&wrq->u.freq;
5466 rt_ioctl_giwfreq(net_dev, NULL, freq, NULL);
5469 case SIOCSIWNICKN: //set node name/nickname
5471 struct iw_point *data=&wrq->u.data;
5472 rt_ioctl_siwnickn(net_dev, NULL, data, NULL);
5475 case SIOCGIWNICKN: //get node name/nickname
5477 struct iw_point *data=&wrq->u.data;
5478 rt_ioctl_giwnickn(net_dev, NULL, data, NULL);
5481 case SIOCGIWRATE: //get default bit rate (bps)
5482 rt_ioctl_giwrate(net_dev, NULL, &wrq->u, NULL);
5484 case SIOCSIWRATE: //set default bit rate (bps)
5485 rt_ioctl_siwrate(net_dev, NULL, &wrq->u, NULL);
5487 case SIOCGIWRTS: // get RTS/CTS threshold (bytes)
5489 struct iw_param *rts=&wrq->u.rts;
5490 rt_ioctl_giwrts(net_dev, NULL, rts, NULL);
5493 case SIOCSIWRTS: //set RTS/CTS threshold (bytes)
5495 struct iw_param *rts=&wrq->u.rts;
5496 rt_ioctl_siwrts(net_dev, NULL, rts, NULL);
5499 case SIOCGIWFRAG: //get fragmentation thr (bytes)
5501 struct iw_param *frag=&wrq->u.frag;
5502 rt_ioctl_giwfrag(net_dev, NULL, frag, NULL);
5505 case SIOCSIWFRAG: //set fragmentation thr (bytes)
5507 struct iw_param *frag=&wrq->u.frag;
5508 rt_ioctl_siwfrag(net_dev, NULL, frag, NULL);
5511 case SIOCGIWENCODE: //get encoding token & mode
5513 struct iw_point *erq=&wrq->u.encoding;
5515 rt_ioctl_giwencode(net_dev, NULL, erq, erq->pointer);
5518 case SIOCSIWENCODE: //set encoding token & mode
5520 struct iw_point *erq=&wrq->u.encoding;
5522 rt_ioctl_siwencode(net_dev, NULL, erq, erq->pointer);
5525 case SIOCGIWAP: //get access point MAC addresses
5527 struct sockaddr *ap_addr=&wrq->u.ap_addr;
5528 rt_ioctl_giwap(net_dev, NULL, ap_addr, ap_addr->sa_data);
5531 case SIOCSIWAP: //set access point MAC addresses
5533 struct sockaddr *ap_addr=&wrq->u.ap_addr;
5534 rt_ioctl_siwap(net_dev, NULL, ap_addr, ap_addr->sa_data);
5537 case SIOCGIWMODE: //get operation mode
5539 __u32 *mode=&wrq->u.mode;
5540 rt_ioctl_giwmode(net_dev, NULL, mode, NULL);
5543 case SIOCSIWMODE: //set operation mode
5545 __u32 *mode=&wrq->u.mode;
5546 rt_ioctl_siwmode(net_dev, NULL, mode, NULL);
5549 case SIOCGIWSENS: //get sensitivity (dBm)
5550 case SIOCSIWSENS: //set sensitivity (dBm)
5551 case SIOCGIWPOWER: //get Power Management settings
5552 case SIOCSIWPOWER: //set Power Management settings
5553 case SIOCGIWTXPOW: //get transmit power (dBm)
5554 case SIOCSIWTXPOW: //set transmit power (dBm)
5555 case SIOCGIWRANGE: //Get range of parameters
5556 case SIOCGIWRETRY: //get retry limits and lifetime
5557 case SIOCSIWRETRY: //set retry limits and lifetime
5558 Status = -EOPNOTSUPP;
5561 case RT_PRIV_IOCTL_EXT:
5562 subcmd = wrq->u.data.flags;
5563 if( subcmd & OID_GET_SET_TOGGLE)
5564 Status = RTMPSetInformation(pAd, rq, subcmd);
5566 Status = RTMPQueryInformation(pAd, rq, subcmd);
5569 if (wrq->u.data.pointer)
5571 if ( access_ok(VERIFY_WRITE, wrq->u.data.pointer, sizeof(privtab)) != TRUE)
5573 wrq->u.data.length = sizeof(privtab) / sizeof(privtab[0]);
5574 if (copy_to_user(wrq->u.data.pointer, privtab, sizeof(privtab)))
5578 case RTPRIV_IOCTL_SET:
5579 if(access_ok(VERIFY_READ, wrq->u.data.pointer, wrq->u.data.length) != TRUE)
5581 rt_ioctl_setparam(net_dev, NULL, NULL, wrq->u.data.pointer);
5583 case RTPRIV_IOCTL_GSITESURVEY:
5584 RTMPIoctlGetSiteSurvey(pAd, wrq);
5587 case RTPRIV_IOCTL_MAC:
5588 RTMPIoctlMAC(pAd, wrq);
5590 case RTPRIV_IOCTL_E2P:
5591 RTMPIoctlE2PROM(pAd, wrq);
5594 case RTPRIV_IOCTL_RF:
5595 RTMPIoctlRF(pAd, wrq);
5602 DBGPRINT(RT_DEBUG_ERROR, ("IOCTL::unknown IOCTL's cmd = 0x%08x\n", cmd));
5603 Status = -EOPNOTSUPP;
5607 if(StateMachineTouched) // Upper layer sent a MLME-related operations
5608 RT28XX_MLME_HANDLER(pAd);
5614 ==========================================================================
5618 TRUE if all parameters are OK, FALSE otherwise
5619 ==========================================================================
5622 IN PRTMP_ADAPTER pAdapter,
5625 NDIS_802_11_SSID Ssid, *pSsid=NULL;
5626 BOOLEAN StateMachineTouched = FALSE;
5629 if( strlen(arg) <= MAX_LEN_OF_SSID)
5631 NdisZeroMemory(&Ssid, sizeof(NDIS_802_11_SSID));
5632 if (strlen(arg) != 0)
5634 NdisMoveMemory(Ssid.Ssid, arg, strlen(arg));
5635 Ssid.SsidLength = strlen(arg);
5639 Ssid.SsidLength = 0;
5640 memcpy(Ssid.Ssid, "", 0);
5641 pAdapter->StaCfg.BssType = BSS_INFRA;
5642 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
5643 pAdapter->StaCfg.WepStatus = Ndis802_11EncryptionDisabled;
5647 if (pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE)
5649 RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
5650 DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
5653 pAdapter->MlmeAux.CurrReqIsFromNdis = TRUE;
5654 pAdapter->StaCfg.bScanReqIsFromWebUI = FALSE;
5655 pAdapter->bConfigChanged = TRUE;
5657 MlmeEnqueue(pAdapter,
5658 MLME_CNTL_STATE_MACHINE,
5660 sizeof(NDIS_802_11_SSID),
5663 StateMachineTouched = TRUE;
5664 DBGPRINT(RT_DEBUG_TRACE, ("Set_SSID_Proc::(Len=%d,Ssid=%s)\n", Ssid.SsidLength, Ssid.Ssid));
5669 if (StateMachineTouched) // Upper layer sent a MLME-related operations
5670 RT28XX_MLME_HANDLER(pAdapter);
5677 ==========================================================================
5679 Set WmmCapable Enable or Disable
5681 TRUE if all parameters are OK, FALSE otherwise
5682 ==========================================================================
5684 INT Set_WmmCapable_Proc(
5685 IN PRTMP_ADAPTER pAd,
5688 BOOLEAN bWmmCapable;
5690 bWmmCapable = simple_strtol(arg, 0, 10);
5692 if ((bWmmCapable == 1)
5694 && (pAd->NumberOfPipes >= 5)
5697 pAd->CommonCfg.bWmmCapable = TRUE;
5698 else if (bWmmCapable == 0)
5699 pAd->CommonCfg.bWmmCapable = FALSE;
5701 return FALSE; //Invalid argument
5703 DBGPRINT(RT_DEBUG_TRACE, ("Set_WmmCapable_Proc::(bWmmCapable=%d)\n",
5704 pAd->CommonCfg.bWmmCapable));
5708 #endif // WMM_SUPPORT //
5711 ==========================================================================
5713 Set Network Type(Infrastructure/Adhoc mode)
5715 TRUE if all parameters are OK, FALSE otherwise
5716 ==========================================================================
5718 INT Set_NetworkType_Proc(
5719 IN PRTMP_ADAPTER pAdapter,
5724 if (strcmp(arg, "Adhoc") == 0)
5726 if (pAdapter->StaCfg.BssType != BSS_ADHOC)
5728 // Config has changed
5729 pAdapter->bConfigChanged = TRUE;
5730 if (MONITOR_ON(pAdapter))
5732 RTMP_IO_WRITE32(pAdapter, RX_FILTR_CFG, STANORMAL);
5733 RTMP_IO_READ32(pAdapter, MAC_SYS_CTRL, &Value);
5735 RTMP_IO_WRITE32(pAdapter, MAC_SYS_CTRL, Value);
5736 OPSTATUS_CLEAR_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED);
5737 pAdapter->StaCfg.bAutoReconnect = TRUE;
5738 LinkDown(pAdapter, FALSE);
5740 if (INFRA_ON(pAdapter))
5742 //BOOLEAN Cancelled;
5743 // Set the AutoReconnectSsid to prevent it reconnect to old SSID
5744 // Since calling this indicate user don't want to connect to that SSID anymore.
5745 pAdapter->MlmeAux.AutoReconnectSsidLen= 32;
5746 NdisZeroMemory(pAdapter->MlmeAux.AutoReconnectSsid, pAdapter->MlmeAux.AutoReconnectSsidLen);
5748 LinkDown(pAdapter, FALSE);
5750 DBGPRINT(RT_DEBUG_TRACE, ("NDIS_STATUS_MEDIA_DISCONNECT Event BB!\n"));
5753 pAdapter->StaCfg.BssType = BSS_ADHOC;
5754 pAdapter->net_dev->type = pAdapter->StaCfg.OriDevType;
5755 DBGPRINT(RT_DEBUG_TRACE, ("===>Set_NetworkType_Proc::(AD-HOC)\n"));
5757 else if (strcmp(arg, "Infra") == 0)
5759 if (pAdapter->StaCfg.BssType != BSS_INFRA)
5761 // Config has changed
5762 pAdapter->bConfigChanged = TRUE;
5763 if (MONITOR_ON(pAdapter))
5765 RTMP_IO_WRITE32(pAdapter, RX_FILTR_CFG, STANORMAL);
5766 RTMP_IO_READ32(pAdapter, MAC_SYS_CTRL, &Value);
5768 RTMP_IO_WRITE32(pAdapter, MAC_SYS_CTRL, Value);
5769 OPSTATUS_CLEAR_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED);
5770 pAdapter->StaCfg.bAutoReconnect = TRUE;
5771 LinkDown(pAdapter, FALSE);
5773 if (ADHOC_ON(pAdapter))
5775 // Set the AutoReconnectSsid to prevent it reconnect to old SSID
5776 // Since calling this indicate user don't want to connect to that SSID anymore.
5777 pAdapter->MlmeAux.AutoReconnectSsidLen= 32;
5778 NdisZeroMemory(pAdapter->MlmeAux.AutoReconnectSsid, pAdapter->MlmeAux.AutoReconnectSsidLen);
5780 LinkDown(pAdapter, FALSE);
5783 pAdapter->StaCfg.BssType = BSS_INFRA;
5784 pAdapter->net_dev->type = pAdapter->StaCfg.OriDevType;
5785 DBGPRINT(RT_DEBUG_TRACE, ("===>Set_NetworkType_Proc::(INFRA)\n"));
5787 pAdapter->StaCfg.BssType = BSS_INFRA;
5789 else if (strcmp(arg, "Monitor") == 0)
5792 BCN_TIME_CFG_STRUC csr;
5793 OPSTATUS_CLEAR_FLAG(pAdapter, fOP_STATUS_INFRA_ON);
5794 OPSTATUS_CLEAR_FLAG(pAdapter, fOP_STATUS_ADHOC_ON);
5795 OPSTATUS_SET_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED);
5796 // disable all periodic state machine
5797 pAdapter->StaCfg.bAutoReconnect = FALSE;
5798 // reset all mlme state machine
5799 RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
5800 DBGPRINT(RT_DEBUG_TRACE, ("fOP_STATUS_MEDIA_STATE_CONNECTED \n"));
5801 if (pAdapter->CommonCfg.CentralChannel == 0)
5803 #ifdef DOT11_N_SUPPORT
5804 if (pAdapter->CommonCfg.PhyMode == PHY_11AN_MIXED)
5805 pAdapter->CommonCfg.CentralChannel = 36;
5807 #endif // DOT11_N_SUPPORT //
5808 pAdapter->CommonCfg.CentralChannel = 6;
5810 #ifdef DOT11_N_SUPPORT
5812 N_ChannelCheck(pAdapter);
5813 #endif // DOT11_N_SUPPORT //
5815 #ifdef DOT11_N_SUPPORT
5816 if (pAdapter->CommonCfg.PhyMode >= PHY_11ABGN_MIXED &&
5817 pAdapter->CommonCfg.RegTransmitSetting.field.BW == BW_40 &&
5818 pAdapter->CommonCfg.RegTransmitSetting.field.EXTCHA == EXTCHA_ABOVE)
5820 // 40MHz ,control channel at lower
5821 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, BBP_R4, &bbpValue);
5822 bbpValue &= (~0x18);
5824 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R4, bbpValue);
5825 pAdapter->CommonCfg.BBPCurrentBW = BW_40;
5826 // RX : control channel at lower
5827 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, BBP_R3, &bbpValue);
5828 bbpValue &= (~0x20);
5829 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R3, bbpValue);
5831 RTMP_IO_READ32(pAdapter, TX_BAND_CFG, &Value);
5832 Value &= 0xfffffffe;
5833 RTMP_IO_WRITE32(pAdapter, TX_BAND_CFG, Value);
5834 pAdapter->CommonCfg.CentralChannel = pAdapter->CommonCfg.Channel + 2;
5835 AsicSwitchChannel(pAdapter, pAdapter->CommonCfg.CentralChannel, FALSE);
5836 AsicLockChannel(pAdapter, pAdapter->CommonCfg.CentralChannel);
5837 DBGPRINT(RT_DEBUG_TRACE, ("BW_40 ,control_channel(%d), CentralChannel(%d) \n",
5838 pAdapter->CommonCfg.Channel,
5839 pAdapter->CommonCfg.CentralChannel));
5841 else if (pAdapter->CommonCfg.PhyMode >= PHY_11ABGN_MIXED &&
5842 pAdapter->CommonCfg.RegTransmitSetting.field.BW == BW_40 &&
5843 pAdapter->CommonCfg.RegTransmitSetting.field.EXTCHA == EXTCHA_BELOW)
5845 // 40MHz ,control channel at upper
5846 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, BBP_R4, &bbpValue);
5847 bbpValue &= (~0x18);
5849 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R4, bbpValue);
5850 pAdapter->CommonCfg.BBPCurrentBW = BW_40;
5851 RTMP_IO_READ32(pAdapter, TX_BAND_CFG, &Value);
5853 RTMP_IO_WRITE32(pAdapter, TX_BAND_CFG, Value);
5855 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, BBP_R3, &bbpValue);
5857 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R3, bbpValue);
5858 pAdapter->CommonCfg.CentralChannel = pAdapter->CommonCfg.Channel - 2;
5859 AsicSwitchChannel(pAdapter, pAdapter->CommonCfg.CentralChannel, FALSE);
5860 AsicLockChannel(pAdapter, pAdapter->CommonCfg.CentralChannel);
5861 DBGPRINT(RT_DEBUG_TRACE, ("BW_40 ,control_channel(%d), CentralChannel(%d) \n",
5862 pAdapter->CommonCfg.Channel,
5863 pAdapter->CommonCfg.CentralChannel));
5866 #endif // DOT11_N_SUPPORT //
5869 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, BBP_R4, &bbpValue);
5870 bbpValue &= (~0x18);
5871 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R4, bbpValue);
5872 pAdapter->CommonCfg.BBPCurrentBW = BW_20;
5873 AsicSwitchChannel(pAdapter, pAdapter->CommonCfg.Channel, FALSE);
5874 AsicLockChannel(pAdapter, pAdapter->CommonCfg.Channel);
5875 DBGPRINT(RT_DEBUG_TRACE, ("BW_20, Channel(%d)\n", pAdapter->CommonCfg.Channel));
5877 // Enable Rx with promiscuous reception
5878 RTMP_IO_WRITE32(pAdapter, RX_FILTR_CFG, 0x3);
5879 // ASIC supporsts sniffer function with replacing RSSI with timestamp.
5880 //RTMP_IO_READ32(pAdapter, MAC_SYS_CTRL, &Value);
5882 //RTMP_IO_WRITE32(pAdapter, MAC_SYS_CTRL, Value);
5884 RTMP_IO_READ32(pAdapter, BCN_TIME_CFG, &csr.word);
5885 csr.field.bBeaconGen = 0;
5886 csr.field.bTBTTEnable = 0;
5887 csr.field.TsfSyncMode = 0;
5888 RTMP_IO_WRITE32(pAdapter, BCN_TIME_CFG, csr.word);
5890 pAdapter->StaCfg.BssType = BSS_MONITOR;
5891 pAdapter->net_dev->type = ARPHRD_IEEE80211_PRISM; //ARPHRD_IEEE80211; // IEEE80211
5892 DBGPRINT(RT_DEBUG_TRACE, ("===>Set_NetworkType_Proc::(MONITOR)\n"));
5895 // Reset Ralink supplicant to not use, it will be set to start when UI set PMK key
5896 pAdapter->StaCfg.WpaState = SS_NOTUSE;
5898 DBGPRINT(RT_DEBUG_TRACE, ("Set_NetworkType_Proc::(NetworkType=%d)\n", pAdapter->StaCfg.BssType));
5904 ==========================================================================
5906 Set Authentication mode
5908 TRUE if all parameters are OK, FALSE otherwise
5909 ==========================================================================
5911 INT Set_AuthMode_Proc(
5912 IN PRTMP_ADAPTER pAdapter,
5915 if ((strcmp(arg, "WEPAUTO") == 0) || (strcmp(arg, "wepauto") == 0))
5916 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeAutoSwitch;
5917 else if ((strcmp(arg, "OPEN") == 0) || (strcmp(arg, "open") == 0))
5918 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
5919 else if ((strcmp(arg, "SHARED") == 0) || (strcmp(arg, "shared") == 0))
5920 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeShared;
5921 else if ((strcmp(arg, "WPAPSK") == 0) || (strcmp(arg, "wpapsk") == 0))
5922 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPAPSK;
5923 else if ((strcmp(arg, "WPANONE") == 0) || (strcmp(arg, "wpanone") == 0))
5924 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPANone;
5925 else if ((strcmp(arg, "WPA2PSK") == 0) || (strcmp(arg, "wpa2psk") == 0))
5926 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA2PSK;
5927 #ifdef WPA_SUPPLICANT_SUPPORT
5928 else if ((strcmp(arg, "WPA") == 0) || (strcmp(arg, "wpa") == 0))
5929 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA;
5930 else if ((strcmp(arg, "WPA2") == 0) || (strcmp(arg, "wpa2") == 0))
5931 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA2;
5932 #endif // WPA_SUPPLICANT_SUPPORT //
5936 pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED;
5938 DBGPRINT(RT_DEBUG_TRACE, ("Set_AuthMode_Proc::(AuthMode=%d)\n", pAdapter->StaCfg.AuthMode));
5944 ==========================================================================
5948 TRUE if all parameters are OK, FALSE otherwise
5949 ==========================================================================
5951 INT Set_EncrypType_Proc(
5952 IN PRTMP_ADAPTER pAdapter,
5955 if ((strcmp(arg, "NONE") == 0) || (strcmp(arg, "none") == 0))
5957 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
5958 return TRUE; // do nothing
5960 pAdapter->StaCfg.WepStatus = Ndis802_11WEPDisabled;
5961 pAdapter->StaCfg.PairCipher = Ndis802_11WEPDisabled;
5962 pAdapter->StaCfg.GroupCipher = Ndis802_11WEPDisabled;
5964 else if ((strcmp(arg, "WEP") == 0) || (strcmp(arg, "wep") == 0))
5966 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
5967 return TRUE; // do nothing
5969 pAdapter->StaCfg.WepStatus = Ndis802_11WEPEnabled;
5970 pAdapter->StaCfg.PairCipher = Ndis802_11WEPEnabled;
5971 pAdapter->StaCfg.GroupCipher = Ndis802_11WEPEnabled;
5973 else if ((strcmp(arg, "TKIP") == 0) || (strcmp(arg, "tkip") == 0))
5975 if (pAdapter->StaCfg.AuthMode < Ndis802_11AuthModeWPA)
5976 return TRUE; // do nothing
5978 pAdapter->StaCfg.WepStatus = Ndis802_11Encryption2Enabled;
5979 pAdapter->StaCfg.PairCipher = Ndis802_11Encryption2Enabled;
5980 pAdapter->StaCfg.GroupCipher = Ndis802_11Encryption2Enabled;
5982 else if ((strcmp(arg, "AES") == 0) || (strcmp(arg, "aes") == 0))
5984 if (pAdapter->StaCfg.AuthMode < Ndis802_11AuthModeWPA)
5985 return TRUE; // do nothing
5987 pAdapter->StaCfg.WepStatus = Ndis802_11Encryption3Enabled;
5988 pAdapter->StaCfg.PairCipher = Ndis802_11Encryption3Enabled;
5989 pAdapter->StaCfg.GroupCipher = Ndis802_11Encryption3Enabled;
5994 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
5996 DBGPRINT(RT_DEBUG_TRACE, ("Set_EncrypType_Proc::(EncrypType=%d)\n", pAdapter->StaCfg.WepStatus));
6002 ==========================================================================
6006 TRUE if all parameters are OK, FALSE otherwise
6007 ==========================================================================
6009 INT Set_DefaultKeyID_Proc(
6010 IN PRTMP_ADAPTER pAdapter,
6015 KeyIdx = simple_strtol(arg, 0, 10);
6016 if((KeyIdx >= 1 ) && (KeyIdx <= 4))
6017 pAdapter->StaCfg.DefaultKeyId = (UCHAR) (KeyIdx - 1 );
6019 return FALSE; //Invalid argument
6021 DBGPRINT(RT_DEBUG_TRACE, ("Set_DefaultKeyID_Proc::(DefaultKeyID=%d)\n", pAdapter->StaCfg.DefaultKeyId));
6027 ==========================================================================
6031 TRUE if all parameters are OK, FALSE otherwise
6032 ==========================================================================
6035 IN PRTMP_ADAPTER pAdapter,
6040 UCHAR CipherAlg=CIPHER_WEP64;
6042 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
6043 return TRUE; // do nothing
6045 KeyLen = strlen(arg);
6049 case 5: //wep 40 Ascii type
6050 pAdapter->SharedKey[BSS0][0].KeyLen = KeyLen;
6051 memcpy(pAdapter->SharedKey[BSS0][0].Key, arg, KeyLen);
6052 CipherAlg = CIPHER_WEP64;
6053 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key1_Proc::(Key1=%s and type=%s)\n", arg, "Ascii"));
6055 case 10: //wep 40 Hex type
6056 for(i=0; i < KeyLen; i++)
6058 if( !isxdigit(*(arg+i)) )
6059 return FALSE; //Not Hex value;
6061 pAdapter->SharedKey[BSS0][0].KeyLen = KeyLen / 2 ;
6062 AtoH(arg, pAdapter->SharedKey[BSS0][0].Key, KeyLen / 2);
6063 CipherAlg = CIPHER_WEP64;
6064 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key1_Proc::(Key1=%s and type=%s)\n", arg, "Hex"));
6066 case 13: //wep 104 Ascii type
6067 pAdapter->SharedKey[BSS0][0].KeyLen = KeyLen;
6068 memcpy(pAdapter->SharedKey[BSS0][0].Key, arg, KeyLen);
6069 CipherAlg = CIPHER_WEP128;
6070 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key1_Proc::(Key1=%s and type=%s)\n", arg, "Ascii"));
6072 case 26: //wep 104 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_WEP128;
6081 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key1_Proc::(Key1=%s and type=%s)\n", arg, "Hex"));
6083 default: //Invalid argument
6084 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key1_Proc::Invalid argument (=%s)\n", arg));
6088 pAdapter->SharedKey[BSS0][0].CipherAlg = CipherAlg;
6090 // Set keys (into ASIC)
6091 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
6093 else // Old WEP stuff
6095 AsicAddSharedKeyEntry(pAdapter,
6098 pAdapter->SharedKey[BSS0][0].CipherAlg,
6099 pAdapter->SharedKey[BSS0][0].Key,
6107 ==========================================================================
6112 TRUE if all parameters are OK, FALSE otherwise
6113 ==========================================================================
6116 IN PRTMP_ADAPTER pAdapter,
6121 UCHAR CipherAlg=CIPHER_WEP64;
6123 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
6124 return TRUE; // do nothing
6126 KeyLen = strlen(arg);
6130 case 5: //wep 40 Ascii type
6131 pAdapter->SharedKey[BSS0][1].KeyLen = KeyLen;
6132 memcpy(pAdapter->SharedKey[BSS0][1].Key, arg, KeyLen);
6133 CipherAlg = CIPHER_WEP64;
6134 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key2_Proc::(Key2=%s and type=%s)\n", arg, "Ascii"));
6136 case 10: //wep 40 Hex type
6137 for(i=0; i < KeyLen; i++)
6139 if( !isxdigit(*(arg+i)) )
6140 return FALSE; //Not Hex value;
6142 pAdapter->SharedKey[BSS0][1].KeyLen = KeyLen / 2 ;
6143 AtoH(arg, pAdapter->SharedKey[BSS0][1].Key, KeyLen / 2);
6144 CipherAlg = CIPHER_WEP64;
6145 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key2_Proc::(Key2=%s and type=%s)\n", arg, "Hex"));
6147 case 13: //wep 104 Ascii type
6148 pAdapter->SharedKey[BSS0][1].KeyLen = KeyLen;
6149 memcpy(pAdapter->SharedKey[BSS0][1].Key, arg, KeyLen);
6150 CipherAlg = CIPHER_WEP128;
6151 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key2_Proc::(Key2=%s and type=%s)\n", arg, "Ascii"));
6153 case 26: //wep 104 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_WEP128;
6162 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key2_Proc::(Key2=%s and type=%s)\n", arg, "Hex"));
6164 default: //Invalid argument
6165 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key2_Proc::Invalid argument (=%s)\n", arg));
6168 pAdapter->SharedKey[BSS0][1].CipherAlg = CipherAlg;
6170 // Set keys (into ASIC)
6171 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
6173 else // Old WEP stuff
6175 AsicAddSharedKeyEntry(pAdapter,
6178 pAdapter->SharedKey[BSS0][1].CipherAlg,
6179 pAdapter->SharedKey[BSS0][1].Key,
6187 ==========================================================================
6191 TRUE if all parameters are OK, FALSE otherwise
6192 ==========================================================================
6195 IN PRTMP_ADAPTER pAdapter,
6200 UCHAR CipherAlg=CIPHER_WEP64;
6202 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
6203 return TRUE; // do nothing
6205 KeyLen = strlen(arg);
6209 case 5: //wep 40 Ascii type
6210 pAdapter->SharedKey[BSS0][2].KeyLen = KeyLen;
6211 memcpy(pAdapter->SharedKey[BSS0][2].Key, arg, KeyLen);
6212 CipherAlg = CIPHER_WEP64;
6213 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key3_Proc::(Key3=%s and type=Ascii)\n", arg));
6215 case 10: //wep 40 Hex type
6216 for(i=0; i < KeyLen; i++)
6218 if( !isxdigit(*(arg+i)) )
6219 return FALSE; //Not Hex value;
6221 pAdapter->SharedKey[BSS0][2].KeyLen = KeyLen / 2 ;
6222 AtoH(arg, pAdapter->SharedKey[BSS0][2].Key, KeyLen / 2);
6223 CipherAlg = CIPHER_WEP64;
6224 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key3_Proc::(Key3=%s and type=Hex)\n", arg));
6226 case 13: //wep 104 Ascii type
6227 pAdapter->SharedKey[BSS0][2].KeyLen = KeyLen;
6228 memcpy(pAdapter->SharedKey[BSS0][2].Key, arg, KeyLen);
6229 CipherAlg = CIPHER_WEP128;
6230 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key3_Proc::(Key3=%s and type=Ascii)\n", arg));
6232 case 26: //wep 104 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_WEP128;
6241 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key3_Proc::(Key3=%s and type=Hex)\n", arg));
6243 default: //Invalid argument
6244 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key3_Proc::Invalid argument (=%s)\n", arg));
6247 pAdapter->SharedKey[BSS0][2].CipherAlg = CipherAlg;
6249 // Set keys (into ASIC)
6250 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
6252 else // Old WEP stuff
6254 AsicAddSharedKeyEntry(pAdapter,
6257 pAdapter->SharedKey[BSS0][2].CipherAlg,
6258 pAdapter->SharedKey[BSS0][2].Key,
6266 ==========================================================================
6270 TRUE if all parameters are OK, FALSE otherwise
6271 ==========================================================================
6274 IN PRTMP_ADAPTER pAdapter,
6279 UCHAR CipherAlg=CIPHER_WEP64;
6281 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
6282 return TRUE; // do nothing
6284 KeyLen = strlen(arg);
6288 case 5: //wep 40 Ascii type
6289 pAdapter->SharedKey[BSS0][3].KeyLen = KeyLen;
6290 memcpy(pAdapter->SharedKey[BSS0][3].Key, arg, KeyLen);
6291 CipherAlg = CIPHER_WEP64;
6292 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key4_Proc::(Key4=%s and type=%s)\n", arg, "Ascii"));
6294 case 10: //wep 40 Hex type
6295 for(i=0; i < KeyLen; i++)
6297 if( !isxdigit(*(arg+i)) )
6298 return FALSE; //Not Hex value;
6300 pAdapter->SharedKey[BSS0][3].KeyLen = KeyLen / 2 ;
6301 AtoH(arg, pAdapter->SharedKey[BSS0][3].Key, KeyLen / 2);
6302 CipherAlg = CIPHER_WEP64;
6303 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key4_Proc::(Key4=%s and type=%s)\n", arg, "Hex"));
6305 case 13: //wep 104 Ascii type
6306 pAdapter->SharedKey[BSS0][3].KeyLen = KeyLen;
6307 memcpy(pAdapter->SharedKey[BSS0][3].Key, arg, KeyLen);
6308 CipherAlg = CIPHER_WEP128;
6309 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key4_Proc::(Key4=%s and type=%s)\n", arg, "Ascii"));
6311 case 26: //wep 104 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_WEP128;
6320 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key4_Proc::(Key4=%s and type=%s)\n", arg, "Hex"));
6322 default: //Invalid argument
6323 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key4_Proc::Invalid argument (=%s)\n", arg));
6326 pAdapter->SharedKey[BSS0][3].CipherAlg = CipherAlg;
6328 // Set keys (into ASIC)
6329 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
6331 else // Old WEP stuff
6333 AsicAddSharedKeyEntry(pAdapter,
6336 pAdapter->SharedKey[BSS0][3].CipherAlg,
6337 pAdapter->SharedKey[BSS0][3].Key,
6346 ==========================================================================
6350 TRUE if all parameters are OK, FALSE otherwise
6351 ==========================================================================
6353 INT Set_WPAPSK_Proc(
6354 IN PRTMP_ADAPTER pAdapter,
6357 UCHAR keyMaterial[40];
6359 if ((pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPAPSK) &&
6360 (pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPA2PSK) &&
6361 (pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPANone)
6363 return TRUE; // do nothing
6365 DBGPRINT(RT_DEBUG_TRACE, ("Set_WPAPSK_Proc::(WPAPSK=%s)\n", arg));
6367 NdisZeroMemory(keyMaterial, 40);
6369 if ((strlen(arg) < 8) || (strlen(arg) > 64))
6371 DBGPRINT(RT_DEBUG_TRACE, ("Set failed!!(WPAPSK=%s), WPAPSK key-string required 8 ~ 64 characters \n", arg));
6375 if (strlen(arg) == 64)
6377 AtoH(arg, keyMaterial, 32);
6378 NdisMoveMemory(pAdapter->StaCfg.PMK, keyMaterial, 32);
6383 PasswordHash((char *)arg, pAdapter->MlmeAux.Ssid, pAdapter->MlmeAux.SsidLen, keyMaterial);
6384 NdisMoveMemory(pAdapter->StaCfg.PMK, keyMaterial, 32);
6389 if(pAdapter->StaCfg.BssType == BSS_ADHOC &&
6390 pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPANone)
6392 pAdapter->StaCfg.WpaState = SS_NOTUSE;
6396 // Start STA supplicant state machine
6397 pAdapter->StaCfg.WpaState = SS_START;
6404 ==========================================================================
6406 Set Power Saving mode
6408 TRUE if all parameters are OK, FALSE otherwise
6409 ==========================================================================
6411 INT Set_PSMode_Proc(
6412 IN PRTMP_ADAPTER pAdapter,
6415 if (pAdapter->StaCfg.BssType == BSS_INFRA)
6417 if ((strcmp(arg, "Max_PSP") == 0) ||
6418 (strcmp(arg, "max_psp") == 0) ||
6419 (strcmp(arg, "MAX_PSP") == 0))
6421 // do NOT turn on PSM bit here, wait until MlmeCheckForPsmChange()
6422 // to exclude certain situations.
6423 if (pAdapter->StaCfg.bWindowsACCAMEnable == FALSE)
6424 pAdapter->StaCfg.WindowsPowerMode = Ndis802_11PowerModeMAX_PSP;
6425 pAdapter->StaCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeMAX_PSP;
6426 OPSTATUS_SET_FLAG(pAdapter, fOP_STATUS_RECEIVE_DTIM);
6427 pAdapter->StaCfg.DefaultListenCount = 5;
6430 else if ((strcmp(arg, "Fast_PSP") == 0) ||
6431 (strcmp(arg, "fast_psp") == 0) ||
6432 (strcmp(arg, "FAST_PSP") == 0))
6434 // do NOT turn on PSM bit here, wait until MlmeCheckForPsmChange()
6435 // to exclude certain situations.
6436 OPSTATUS_SET_FLAG(pAdapter, fOP_STATUS_RECEIVE_DTIM);
6437 if (pAdapter->StaCfg.bWindowsACCAMEnable == FALSE)
6438 pAdapter->StaCfg.WindowsPowerMode = Ndis802_11PowerModeFast_PSP;
6439 pAdapter->StaCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeFast_PSP;
6440 pAdapter->StaCfg.DefaultListenCount = 3;
6442 else if ((strcmp(arg, "Legacy_PSP") == 0) ||
6443 (strcmp(arg, "legacy_psp") == 0) ||
6444 (strcmp(arg, "LEGACY_PSP") == 0))
6446 // do NOT turn on PSM bit here, wait until MlmeCheckForPsmChange()
6447 // to exclude certain situations.
6448 OPSTATUS_SET_FLAG(pAdapter, fOP_STATUS_RECEIVE_DTIM);
6449 if (pAdapter->StaCfg.bWindowsACCAMEnable == FALSE)
6450 pAdapter->StaCfg.WindowsPowerMode = Ndis802_11PowerModeLegacy_PSP;
6451 pAdapter->StaCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeLegacy_PSP;
6452 pAdapter->StaCfg.DefaultListenCount = 3;
6456 //Default Ndis802_11PowerModeCAM
6457 // clear PSM bit immediately
6458 MlmeSetPsmBit(pAdapter, PWR_ACTIVE);
6459 OPSTATUS_SET_FLAG(pAdapter, fOP_STATUS_RECEIVE_DTIM);
6460 if (pAdapter->StaCfg.bWindowsACCAMEnable == FALSE)
6461 pAdapter->StaCfg.WindowsPowerMode = Ndis802_11PowerModeCAM;
6462 pAdapter->StaCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeCAM;
6465 DBGPRINT(RT_DEBUG_TRACE, ("Set_PSMode_Proc::(PSMode=%ld)\n", pAdapter->StaCfg.WindowsPowerMode));
6474 #ifdef WPA_SUPPLICANT_SUPPORT
6476 ==========================================================================
6478 Set WpaSupport flag.
6480 0: Driver ignore wpa_supplicant.
6481 1: wpa_supplicant initiates scanning and AP selection.
6482 2: driver takes care of scanning, AP selection, and IEEE 802.11 association parameters.
6484 TRUE if all parameters are OK, FALSE otherwise
6485 ==========================================================================
6487 INT Set_Wpa_Support(
6488 IN PRTMP_ADAPTER pAd,
6492 if ( simple_strtol(arg, 0, 10) == 0)
6493 pAd->StaCfg.WpaSupplicantUP = WPA_SUPPLICANT_DISABLE;
6494 else if ( simple_strtol(arg, 0, 10) == 1)
6495 pAd->StaCfg.WpaSupplicantUP = WPA_SUPPLICANT_ENABLE;
6496 else if ( simple_strtol(arg, 0, 10) == 2)
6497 pAd->StaCfg.WpaSupplicantUP = WPA_SUPPLICANT_ENABLE_WITH_WEB_UI;
6499 pAd->StaCfg.WpaSupplicantUP = WPA_SUPPLICANT_DISABLE;
6501 DBGPRINT(RT_DEBUG_TRACE, ("Set_Wpa_Support::(WpaSupplicantUP=%d)\n", pAd->StaCfg.WpaSupplicantUP));
6505 #endif // WPA_SUPPLICANT_SUPPORT //
6509 ==========================================================================
6513 pAdapter Pointer to our adapter
6514 wrq Pointer to the ioctl argument
6521 1.) iwpriv ra0 mac 0 ==> read MAC where Addr=0x0
6522 2.) iwpriv ra0 mac 0=12 ==> write MAC where Addr=0x0, value=12
6523 ==========================================================================
6526 IN PRTMP_ADAPTER pAdapter,
6527 IN struct iwreq *wrq)
6535 UCHAR temp[16], temp2[16];
6536 UINT32 macValue = 0;
6538 BOOLEAN bIsPrintAllMAC = FALSE;
6541 memset(msg, 0x00, 1024);
6542 if (wrq->u.data.length > 1) //No parameters.
6544 Status = copy_from_user(arg, wrq->u.data.pointer, (wrq->u.data.length > 255) ? 255 : wrq->u.data.length);
6547 //Parsing Read or Write
6552 if ((value = rtstrchr(this_char, '=')) != NULL)
6555 if (!value || !*value)
6558 if(strlen(this_char) > 4)
6561 j = strlen(this_char);
6564 if(this_char[j] > 'f' || this_char[j] < '0')
6569 k = j = strlen(this_char);
6572 this_char[4-k+j] = this_char[j];
6576 this_char[3-k++]='0';
6579 if(strlen(this_char) == 4)
6581 AtoH(this_char, temp, 2);
6582 macAddr = *temp*256 + temp[1];
6583 if (macAddr < 0xFFFF)
6585 RTMP_IO_READ32(pAdapter, macAddr, &macValue);
6586 DBGPRINT(RT_DEBUG_TRACE, ("MacAddr=%lx, MacValue=%x\n", macAddr, macValue));
6587 sprintf(msg+strlen(msg), "[0x%08lX]:%08X ", macAddr , macValue);
6590 {//Invalid parametes, so default printk all mac
6591 bIsPrintAllMAC = TRUE;
6598 memcpy(&temp2, value, strlen(value));
6599 temp2[strlen(value)] = '\0';
6602 if((strlen(this_char) > 4) || strlen(temp2) > 8)
6605 j = strlen(this_char);
6608 if(this_char[j] > 'f' || this_char[j] < '0')
6615 if(temp2[j] > 'f' || temp2[j] < '0')
6620 k = j = strlen(this_char);
6623 this_char[4-k+j] = this_char[j];
6627 this_char[3-k++]='0';
6631 k = j = strlen(temp2);
6634 temp2[8-k+j] = temp2[j];
6642 AtoH(this_char, temp, 2);
6643 macAddr = *temp*256 + temp[1];
6645 AtoH(temp2, temp, 4);
6646 macValue = *temp*256*256*256 + temp[1]*256*256 + temp[2]*256 + temp[3];
6649 if (macAddr == (HW_DEBUG_SETTING_BASE + 4))
6651 // 0x2bf4: byte0 non-zero: enable R17 tuning, 0: disable R17 tuning
6652 if (macValue & 0x000000ff)
6654 pAdapter->BbpTuning.bEnable = TRUE;
6655 DBGPRINT(RT_DEBUG_TRACE,("turn on R17 tuning\n"));
6660 pAdapter->BbpTuning.bEnable = FALSE;
6661 R66 = 0x26 + GET_LNA_GAIN(pAdapter);
6663 if (ATE_ON(pAdapter))
6665 ATE_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R66, (0x26 + GET_LNA_GAIN(pAdapter)));
6668 #endif // RALINK_ATE //
6669 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R66, (0x26 + GET_LNA_GAIN(pAdapter)));
6670 DBGPRINT(RT_DEBUG_TRACE,("turn off R17 tuning, restore to 0x%02x\n", R66));
6675 DBGPRINT(RT_DEBUG_TRACE, ("MacAddr=%02lx, MacValue=0x%x\n", macAddr, macValue));
6677 RTMP_IO_WRITE32(pAdapter, macAddr, macValue);
6678 sprintf(msg+strlen(msg), "[0x%08lX]:%08X ", macAddr, macValue);
6683 bIsPrintAllMAC = TRUE;
6687 struct file *file_w;
6688 PCHAR fileName = "MacDump.txt";
6689 mm_segment_t orig_fs;
6695 file_w = filp_open(fileName, O_WRONLY|O_CREAT, 0);
6698 DBGPRINT(RT_DEBUG_TRACE, ("-->2) %s: Error %ld opening %s\n", __func__, -PTR_ERR(file_w), fileName));
6702 if (file_w->f_op && file_w->f_op->write)
6707 while (macAddr <= 0x1800)
6709 RTMP_IO_READ32(pAdapter, macAddr, &macValue);
6710 sprintf(msg, "%08lx = %08X\n", macAddr, macValue);
6712 // write data to file
6713 file_w->f_op->write(file_w, msg, strlen(msg), &file_w->f_pos);
6718 sprintf(msg, "\nDump all MAC values to %s\n", fileName);
6720 filp_close(file_w, NULL);
6724 if(strlen(msg) == 1)
6725 sprintf(msg+strlen(msg), "===>Error command format!");
6727 // Copy the information into the user buffer
6728 wrq->u.data.length = strlen(msg);
6729 Status = copy_to_user(wrq->u.data.pointer, msg, wrq->u.data.length);
6731 DBGPRINT(RT_DEBUG_TRACE, ("<==RTMPIoctlMAC\n\n"));
6735 ==========================================================================
6739 pAdapter Pointer to our adapter
6740 wrq Pointer to the ioctl argument
6747 1.) iwpriv ra0 e2p 0 ==> read E2PROM where Addr=0x0
6748 2.) iwpriv ra0 e2p 0=1234 ==> write E2PROM where Addr=0x0, value=1234
6749 ==========================================================================
6751 VOID RTMPIoctlE2PROM(
6752 IN PRTMP_ADAPTER pAdapter,
6753 IN struct iwreq *wrq)
6761 UCHAR temp[16], temp2[16];
6764 BOOLEAN bIsPrintAllE2P = FALSE;
6767 memset(msg, 0x00, 1024);
6768 if (wrq->u.data.length > 1) //No parameters.
6770 Status = copy_from_user(arg, wrq->u.data.pointer, (wrq->u.data.length > 255) ? 255 : wrq->u.data.length);
6773 //Parsing Read or Write
6780 if ((value = rtstrchr(this_char, '=')) != NULL)
6783 if (!value || !*value)
6787 if(strlen(this_char) > 4)
6790 j = strlen(this_char);
6793 if(this_char[j] > 'f' || this_char[j] < '0')
6798 k = j = strlen(this_char);
6801 this_char[4-k+j] = this_char[j];
6805 this_char[3-k++]='0';
6808 if(strlen(this_char) == 4)
6810 AtoH(this_char, temp, 2);
6811 eepAddr = *temp*256 + temp[1];
6812 if (eepAddr < 0xFFFF)
6814 RT28xx_EEPROM_READ16(pAdapter, eepAddr, eepValue);
6815 sprintf(msg+strlen(msg), "[0x%04X]:0x%04X ", eepAddr , eepValue);
6818 {//Invalid parametes, so default printk all bbp
6819 bIsPrintAllE2P = TRUE;
6826 memcpy(&temp2, value, strlen(value));
6827 temp2[strlen(value)] = '\0';
6830 if((strlen(this_char) > 4) || strlen(temp2) > 8)
6833 j = strlen(this_char);
6836 if(this_char[j] > 'f' || this_char[j] < '0')
6842 if(temp2[j] > 'f' || temp2[j] < '0')
6847 k = j = strlen(this_char);
6850 this_char[4-k+j] = this_char[j];
6854 this_char[3-k++]='0';
6858 k = j = strlen(temp2);
6861 temp2[4-k+j] = temp2[j];
6868 AtoH(this_char, temp, 2);
6869 eepAddr = *temp*256 + temp[1];
6871 AtoH(temp2, temp, 2);
6872 eepValue = *temp*256 + temp[1];
6874 RT28xx_EEPROM_WRITE16(pAdapter, eepAddr, eepValue);
6875 sprintf(msg+strlen(msg), "[0x%02X]:%02X ", eepAddr, eepValue);
6879 bIsPrintAllE2P = TRUE;
6883 struct file *file_w;
6884 PCHAR fileName = "EEPROMDump.txt";
6885 mm_segment_t orig_fs;
6891 file_w = filp_open(fileName, O_WRONLY|O_CREAT, 0);
6894 DBGPRINT(RT_DEBUG_TRACE, ("-->2) %s: Error %ld opening %s\n", __func__, -PTR_ERR(file_w), fileName));
6898 if (file_w->f_op && file_w->f_op->write)
6903 while (eepAddr <= 0xFE)
6905 RT28xx_EEPROM_READ16(pAdapter, eepAddr, eepValue);
6906 sprintf(msg, "%08x = %04x\n", eepAddr , eepValue);
6908 // write data to file
6909 file_w->f_op->write(file_w, msg, strlen(msg), &file_w->f_pos);
6914 sprintf(msg, "\nDump all EEPROM values to %s\n", fileName);
6916 filp_close(file_w, NULL);
6920 if(strlen(msg) == 1)
6921 sprintf(msg+strlen(msg), "===>Error command format!");
6924 // Copy the information into the user buffer
6925 wrq->u.data.length = strlen(msg);
6926 Status = copy_to_user(wrq->u.data.pointer, msg, wrq->u.data.length);
6928 DBGPRINT(RT_DEBUG_TRACE, ("<==RTMPIoctlE2PROM\n"));
6932 ==========================================================================
6934 Read / Write RF register
6936 pAdapter Pointer to our adapter
6937 wrq Pointer to the ioctl argument
6944 1.) iwpriv ra0 rf ==> read all RF registers
6945 2.) iwpriv ra0 rf 1 ==> read RF where RegID=1
6946 3.) iwpriv ra0 rf 1=10 ==> write RF R1=0x10
6947 ==========================================================================
6950 IN PRTMP_ADAPTER pAdapter,
6951 IN struct iwreq *wrq)
6961 BOOLEAN bIsPrintAllRF = FALSE;
6964 memset(msg, 0x00, 2048);
6965 if (wrq->u.data.length > 1) //No parameters.
6967 Status = copy_from_user(arg, wrq->u.data.pointer, (wrq->u.data.length > 255) ? 255 : wrq->u.data.length);
6970 //Parsing Read or Write
6975 if ((value = strchr(this_char, '=')) != NULL)
6978 if (!value || !*value)
6980 if (sscanf(this_char, "%d", &(rfId)) == 1)
6984 // In RT2860 ATE mode, we do not load 8051 firmware.
6985 //We must access RF directly.
6986 // For RT2870 ATE mode, ATE_RF_IO_WRITE8(/READ8)_BY_REG_ID are redefined.
6988 if (ATE_ON(pAdapter))
6990 ATE_RF_IO_READ8_BY_REG_ID(pAdapter, rfId, ®RF);
6993 #endif // RALINK_ATE //
6994 // according to Andy, Gary, David require.
6995 // the command rf shall read rf register directly for dubug.
6996 // BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, ®BBP);
6997 RT30xxReadRFRegister(pAdapter, rfId, ®RF);
6999 sprintf(msg+strlen(msg), "R%02d[0x%02x]:%02X ", rfId, rfId*2, regRF);
7002 {//Invalid parametes, so default printk all RF
7003 bIsPrintAllRF = TRUE;
7008 { //Invalid parametes, so default printk all RF
7009 bIsPrintAllRF = TRUE;
7015 if ((sscanf(this_char, "%d", &(rfId)) == 1) && (sscanf(value, "%lx", &(rfValue)) == 1))
7019 // In RT2860 ATE mode, we do not load 8051 firmware.
7020 // We should access RF registers directly.
7021 // For RT2870 ATE mode, ATE_RF_IO_WRITE8/READ8_BY_REG_ID are redefined.
7023 if (ATE_ON(pAdapter))
7025 ATE_RF_IO_READ8_BY_REG_ID(pAdapter, rfId, ®RF);
7026 ATE_RF_IO_WRITE8_BY_REG_ID(pAdapter, (UCHAR)rfId,(UCHAR) rfValue);
7027 //Read it back for showing
7028 ATE_RF_IO_READ8_BY_REG_ID(pAdapter, rfId, ®RF);
7029 sprintf(msg+strlen(msg), "R%02d[0x%02X]:%02X\n", rfId, rfId*2, regRF);
7032 #endif // RALINK_ATE //
7034 // according to Andy, Gary, David require.
7035 // the command RF shall read/write RF register directly for dubug.
7036 //BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, ®BBP);
7037 //BBP_IO_WRITE8_BY_REG_ID(pAdapter, (UCHAR)bbpId,(UCHAR) bbpValue);
7038 RT30xxReadRFRegister(pAdapter, rfId, ®RF);
7039 RT30xxWriteRFRegister(pAdapter, (UCHAR)rfId,(UCHAR) rfValue);
7040 //Read it back for showing
7041 //BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, ®BBP);
7042 RT30xxReadRFRegister(pAdapter, rfId, ®RF);
7043 sprintf(msg+strlen(msg), "R%02d[0x%02X]:%02X\n", rfId, rfId*2, regRF);
7047 {//Invalid parametes, so default printk all RF
7048 bIsPrintAllRF = TRUE;
7052 { //Invalid parametes, so default printk all RF
7053 bIsPrintAllRF = TRUE;
7058 bIsPrintAllRF = TRUE;
7062 memset(msg, 0x00, 2048);
7064 for (rfId = 0; rfId <= 31; rfId++)
7066 // In RT2860 ATE mode, we do not load 8051 firmware.
7067 // We should access RF registers directly.
7068 // For RT2870 ATE mode, ATE_RF_IO_WRITE8/READ8_BY_REG_ID are redefined.
7070 if (ATE_ON(pAdapter))
7072 ATE_RF_IO_READ8_BY_REG_ID(pAdapter, rfId, ®RF);
7075 #endif // RALINK_ATE //
7077 // according to Andy, Gary, David require.
7078 // the command RF shall read/write RF register directly for dubug.
7079 RT30xxReadRFRegister(pAdapter, rfId, ®RF);
7080 sprintf(msg+strlen(msg), "%03d = %02X\n", rfId, regRF);
7082 // Copy the information into the user buffer
7083 DBGPRINT(RT_DEBUG_TRACE, ("strlen(msg)=%d\n", (UINT32)strlen(msg)));
7084 wrq->u.data.length = strlen(msg);
7085 if (copy_to_user(wrq->u.data.pointer, msg, wrq->u.data.length))
7087 DBGPRINT(RT_DEBUG_TRACE, ("%s: copy_to_user() fail\n", __func__));
7092 if(strlen(msg) == 1)
7093 sprintf(msg+strlen(msg), "===>Error command format!");
7095 DBGPRINT(RT_DEBUG_TRACE, ("copy to user [msg=%s]\n", msg));
7096 // Copy the information into the user buffer
7097 DBGPRINT(RT_DEBUG_TRACE, ("strlen(msg) =%d\n", (UINT32)strlen(msg)));
7099 // Copy the information into the user buffer
7100 wrq->u.data.length = strlen(msg);
7101 Status = copy_to_user(wrq->u.data.pointer, msg, wrq->u.data.length);
7104 DBGPRINT(RT_DEBUG_TRACE, ("<==RTMPIoctlRF\n\n"));
7112 INT Set_TGnWifiTest_Proc(
7113 IN PRTMP_ADAPTER pAd,
7116 if (simple_strtol(arg, 0, 10) == 0)
7117 pAd->StaCfg.bTGnWifiTest = FALSE;
7119 pAd->StaCfg.bTGnWifiTest = TRUE;
7121 DBGPRINT(RT_DEBUG_TRACE, ("IF Set_TGnWifiTest_Proc::(bTGnWifiTest=%d)\n", pAd->StaCfg.bTGnWifiTest));
7125 INT Set_LongRetryLimit_Proc(
7126 IN PRTMP_ADAPTER pAdapter,
7129 TX_RTY_CFG_STRUC tx_rty_cfg;
7130 UCHAR LongRetryLimit = (UCHAR)simple_strtol(arg, 0, 10);
7132 RTMP_IO_READ32(pAdapter, TX_RTY_CFG, &tx_rty_cfg.word);
7133 tx_rty_cfg.field.LongRtyLimit = LongRetryLimit;
7134 RTMP_IO_WRITE32(pAdapter, TX_RTY_CFG, tx_rty_cfg.word);
7135 DBGPRINT(RT_DEBUG_TRACE, ("IF Set_LongRetryLimit_Proc::(tx_rty_cfg=0x%x)\n", tx_rty_cfg.word));
7139 INT Set_ShortRetryLimit_Proc(
7140 IN PRTMP_ADAPTER pAdapter,
7143 TX_RTY_CFG_STRUC tx_rty_cfg;
7144 UCHAR ShortRetryLimit = (UCHAR)simple_strtol(arg, 0, 10);
7146 RTMP_IO_READ32(pAdapter, TX_RTY_CFG, &tx_rty_cfg.word);
7147 tx_rty_cfg.field.ShortRtyLimit = ShortRetryLimit;
7148 RTMP_IO_WRITE32(pAdapter, TX_RTY_CFG, tx_rty_cfg.word);
7149 DBGPRINT(RT_DEBUG_TRACE, ("IF Set_ShortRetryLimit_Proc::(tx_rty_cfg=0x%x)\n", tx_rty_cfg.word));
7153 #ifdef EXT_BUILD_CHANNEL_LIST
7154 INT Set_Ieee80211dClientMode_Proc(
7155 IN PRTMP_ADAPTER pAdapter,
7158 if (simple_strtol(arg, 0, 10) == 0)
7159 pAdapter->StaCfg.IEEE80211dClientMode = Rt802_11_D_None;
7160 else if (simple_strtol(arg, 0, 10) == 1)
7161 pAdapter->StaCfg.IEEE80211dClientMode = Rt802_11_D_Flexible;
7162 else if (simple_strtol(arg, 0, 10) == 2)
7163 pAdapter->StaCfg.IEEE80211dClientMode = Rt802_11_D_Strict;
7167 DBGPRINT(RT_DEBUG_TRACE, ("Set_Ieee802dMode_Proc::(IEEEE0211dMode=%d)\n", pAdapter->StaCfg.IEEE80211dClientMode));
7170 #endif // EXT_BUILD_CHANNEL_LIST //
7172 #ifdef CARRIER_DETECTION_SUPPORT
7173 INT Set_CarrierDetect_Proc(
7174 IN PRTMP_ADAPTER pAd,
7177 if (simple_strtol(arg, 0, 10) == 0)
7178 pAd->CommonCfg.CarrierDetect.Enable = FALSE;
7180 pAd->CommonCfg.CarrierDetect.Enable = TRUE;
7182 DBGPRINT(RT_DEBUG_TRACE, ("IF Set_CarrierDetect_Proc::(CarrierDetect.Enable=%d)\n", pAd->CommonCfg.CarrierDetect.Enable));
7185 #endif // CARRIER_DETECTION_SUPPORT //