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 { SHOW_ADHOC_ENTRY_INFO,
95 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "adhocEntry" },
97 /* --- sub-ioctls relations --- */
101 IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK,
104 IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | 1024,
107 IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | 1024,
111 { RTPRIV_IOCTL_STATISTICS,
112 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK,
114 { RTPRIV_IOCTL_GSITESURVEY,
115 0, IW_PRIV_TYPE_CHAR | 1024,
120 IN PRTMP_ADAPTER pAdapter,
124 INT Set_WmmCapable_Proc(
125 IN PRTMP_ADAPTER pAd,
129 INT Set_NetworkType_Proc(
130 IN PRTMP_ADAPTER pAdapter,
133 INT Set_AuthMode_Proc(
134 IN PRTMP_ADAPTER pAdapter,
137 INT Set_EncrypType_Proc(
138 IN PRTMP_ADAPTER pAdapter,
141 INT Set_DefaultKeyID_Proc(
142 IN PRTMP_ADAPTER pAdapter,
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,
167 IN PRTMP_ADAPTER pAdapter,
170 #ifdef WPA_SUPPLICANT_SUPPORT
172 IN PRTMP_ADAPTER pAd,
174 #endif // WPA_SUPPLICANT_SUPPORT //
178 IN PRTMP_ADAPTER pAdapter,
179 IN struct iwreq *wrq);
182 IN PRTMP_ADAPTER pAdapter,
183 IN struct iwreq *wrq);
185 VOID RTMPIoctlE2PROM(
186 IN PRTMP_ADAPTER pAdapter,
187 IN struct iwreq *wrq);
191 NDIS_STATUS RTMPWPANoneAddKeyProc(
192 IN PRTMP_ADAPTER pAd,
195 INT Set_FragTest_Proc(
196 IN PRTMP_ADAPTER pAdapter,
199 #ifdef DOT11_N_SUPPORT
200 INT Set_TGnWifiTest_Proc(
201 IN PRTMP_ADAPTER pAd,
203 #endif // DOT11_N_SUPPORT //
205 INT Set_LongRetryLimit_Proc(
206 IN PRTMP_ADAPTER pAdapter,
209 INT Set_ShortRetryLimit_Proc(
210 IN PRTMP_ADAPTER pAdapter,
213 #ifdef EXT_BUILD_CHANNEL_LIST
214 INT Set_Ieee80211dClientMode_Proc(
215 IN PRTMP_ADAPTER pAdapter,
217 #endif // EXT_BUILD_CHANNEL_LIST //
219 #ifdef CARRIER_DETECTION_SUPPORT
220 INT Set_CarrierDetect_Proc(
221 IN PRTMP_ADAPTER pAd,
223 #endif // CARRIER_DETECTION_SUPPORT //
225 INT Show_Adhoc_MacTable_Proc(
226 IN PRTMP_ADAPTER pAd,
231 INT (*set_proc)(PRTMP_ADAPTER pAdapter, PUCHAR arg);
232 } *PRTMP_PRIVATE_SET_PROC, RTMP_PRIVATE_SUPPORT_PROC[] = {
233 {"DriverVersion", Set_DriverVersion_Proc},
234 {"CountryRegion", Set_CountryRegion_Proc},
235 {"CountryRegionABand", Set_CountryRegionABand_Proc},
236 {"SSID", Set_SSID_Proc},
237 {"WirelessMode", Set_WirelessMode_Proc},
238 {"TxBurst", Set_TxBurst_Proc},
239 {"TxPreamble", Set_TxPreamble_Proc},
240 {"TxPower", Set_TxPower_Proc},
241 {"Channel", Set_Channel_Proc},
242 {"BGProtection", Set_BGProtection_Proc},
243 {"RTSThreshold", Set_RTSThreshold_Proc},
244 {"FragThreshold", Set_FragThreshold_Proc},
245 #ifdef DOT11_N_SUPPORT
246 {"HtBw", Set_HtBw_Proc},
247 {"HtMcs", Set_HtMcs_Proc},
248 {"HtGi", Set_HtGi_Proc},
249 {"HtOpMode", Set_HtOpMode_Proc},
250 {"HtExtcha", Set_HtExtcha_Proc},
251 {"HtMpduDensity", Set_HtMpduDensity_Proc},
252 {"HtBaWinSize", Set_HtBaWinSize_Proc},
253 {"HtRdg", Set_HtRdg_Proc},
254 {"HtAmsdu", Set_HtAmsdu_Proc},
255 {"HtAutoBa", Set_HtAutoBa_Proc},
256 {"HtBaDecline", Set_BADecline_Proc},
257 {"HtProtect", Set_HtProtect_Proc},
258 {"HtMimoPs", Set_HtMimoPs_Proc},
259 #endif // DOT11_N_SUPPORT //
261 #ifdef AGGREGATION_SUPPORT
262 {"PktAggregate", Set_PktAggregate_Proc},
266 {"WmmCapable", Set_WmmCapable_Proc},
268 {"IEEE80211H", Set_IEEE80211H_Proc},
269 {"NetworkType", Set_NetworkType_Proc},
270 {"AuthMode", Set_AuthMode_Proc},
271 {"EncrypType", Set_EncrypType_Proc},
272 {"DefaultKeyID", Set_DefaultKeyID_Proc},
273 {"Key1", Set_Key1_Proc},
274 {"Key2", Set_Key2_Proc},
275 {"Key3", Set_Key3_Proc},
276 {"Key4", Set_Key4_Proc},
277 {"WPAPSK", Set_WPAPSK_Proc},
278 {"ResetCounter", Set_ResetStatCounter_Proc},
279 {"PSMode", Set_PSMode_Proc},
281 {"Debug", Set_Debug_Proc},
285 {"ATE", Set_ATE_Proc},
286 {"ATEDA", Set_ATE_DA_Proc},
287 {"ATESA", Set_ATE_SA_Proc},
288 {"ATEBSSID", Set_ATE_BSSID_Proc},
289 {"ATECHANNEL", Set_ATE_CHANNEL_Proc},
290 {"ATETXPOW0", Set_ATE_TX_POWER0_Proc},
291 {"ATETXPOW1", Set_ATE_TX_POWER1_Proc},
292 {"ATETXANT", Set_ATE_TX_Antenna_Proc},
293 {"ATERXANT", Set_ATE_RX_Antenna_Proc},
294 {"ATETXFREQOFFSET", Set_ATE_TX_FREQOFFSET_Proc},
295 {"ATETXBW", Set_ATE_TX_BW_Proc},
296 {"ATETXLEN", Set_ATE_TX_LENGTH_Proc},
297 {"ATETXCNT", Set_ATE_TX_COUNT_Proc},
298 {"ATETXMCS", Set_ATE_TX_MCS_Proc},
299 {"ATETXMODE", Set_ATE_TX_MODE_Proc},
300 {"ATETXGI", Set_ATE_TX_GI_Proc},
301 {"ATERXFER", Set_ATE_RX_FER_Proc},
302 {"ATERRF", Set_ATE_Read_RF_Proc},
303 {"ATEWRF1", Set_ATE_Write_RF1_Proc},
304 {"ATEWRF2", Set_ATE_Write_RF2_Proc},
305 {"ATEWRF3", Set_ATE_Write_RF3_Proc},
306 {"ATEWRF4", Set_ATE_Write_RF4_Proc},
307 {"ATELDE2P", Set_ATE_Load_E2P_Proc},
308 {"ATERE2P", Set_ATE_Read_E2P_Proc},
309 {"ATESHOW", Set_ATE_Show_Proc},
310 {"ATEHELP", Set_ATE_Help_Proc},
312 #ifdef RALINK_28xx_QA
313 {"TxStop", Set_TxStop_Proc},
314 {"RxStop", Set_RxStop_Proc},
315 #endif // RALINK_28xx_QA //
316 #endif // RALINK_ATE //
318 #ifdef WPA_SUPPLICANT_SUPPORT
319 {"WpaSupport", Set_Wpa_Support},
320 #endif // WPA_SUPPLICANT_SUPPORT //
324 {"FixedTxMode", Set_FixedTxMode_Proc},
325 #ifdef CONFIG_APSTA_MIXED_SUPPORT
326 {"OpMode", Set_OpMode_Proc},
327 #endif // CONFIG_APSTA_MIXED_SUPPORT //
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 //
350 IN PRTMP_ADAPTER pAd,
351 IN PNDIS_802_11_KEY pKey)
354 MAC_TABLE_ENTRY *pEntry;
356 DBGPRINT(RT_DEBUG_TRACE, ("RTMPAddKey ------>\n"));
358 if (pAd->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
360 if (pKey->KeyIndex & 0x80000000)
362 if (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPANone)
364 NdisZeroMemory(pAd->StaCfg.PMK, 32);
365 NdisMoveMemory(pAd->StaCfg.PMK, pKey->KeyMaterial, pKey->KeyLength);
369 NdisZeroMemory(&pAd->SharedKey[BSS0][0], sizeof(CIPHER_KEY));
370 pAd->SharedKey[BSS0][0].KeyLen = LEN_TKIP_EK;
371 NdisMoveMemory(pAd->SharedKey[BSS0][0].Key, pKey->KeyMaterial, LEN_TKIP_EK);
372 #ifdef WPA_SUPPLICANT_SUPPORT
373 if (pAd->StaCfg.PairCipher == Ndis802_11Encryption2Enabled)
375 NdisMoveMemory(pAd->SharedKey[BSS0][0].RxMic, pKey->KeyMaterial + LEN_TKIP_EK, LEN_TKIP_TXMICK);
376 NdisMoveMemory(pAd->SharedKey[BSS0][0].TxMic, pKey->KeyMaterial + LEN_TKIP_EK + LEN_TKIP_TXMICK, LEN_TKIP_RXMICK);
379 #endif // WPA_SUPPLICANT_SUPPORT //
381 NdisMoveMemory(pAd->SharedKey[BSS0][0].TxMic, pKey->KeyMaterial + LEN_TKIP_EK, LEN_TKIP_TXMICK);
382 NdisMoveMemory(pAd->SharedKey[BSS0][0].RxMic, pKey->KeyMaterial + LEN_TKIP_EK + LEN_TKIP_TXMICK, LEN_TKIP_RXMICK);
385 // Decide its ChiperAlg
386 if (pAd->StaCfg.PairCipher == Ndis802_11Encryption2Enabled)
387 pAd->SharedKey[BSS0][0].CipherAlg = CIPHER_TKIP;
388 else if (pAd->StaCfg.PairCipher == Ndis802_11Encryption3Enabled)
389 pAd->SharedKey[BSS0][0].CipherAlg = CIPHER_AES;
391 pAd->SharedKey[BSS0][0].CipherAlg = CIPHER_NONE;
393 // Update these related information to MAC_TABLE_ENTRY
394 pEntry = &pAd->MacTab.Content[BSSID_WCID];
395 NdisMoveMemory(pEntry->PairwiseKey.Key, pAd->SharedKey[BSS0][0].Key, LEN_TKIP_EK);
396 NdisMoveMemory(pEntry->PairwiseKey.RxMic, pAd->SharedKey[BSS0][0].RxMic, LEN_TKIP_RXMICK);
397 NdisMoveMemory(pEntry->PairwiseKey.TxMic, pAd->SharedKey[BSS0][0].TxMic, LEN_TKIP_TXMICK);
398 pEntry->PairwiseKey.CipherAlg = pAd->SharedKey[BSS0][0].CipherAlg;
400 // Update pairwise key information to ASIC Shared Key Table
401 AsicAddSharedKeyEntry(pAd,
404 pAd->SharedKey[BSS0][0].CipherAlg,
405 pAd->SharedKey[BSS0][0].Key,
406 pAd->SharedKey[BSS0][0].TxMic,
407 pAd->SharedKey[BSS0][0].RxMic);
409 // Update ASIC WCID attribute table and IVEIV table
410 RTMPAddWcidAttributeEntry(pAd,
413 pAd->SharedKey[BSS0][0].CipherAlg,
416 if (pAd->StaCfg.AuthMode >= Ndis802_11AuthModeWPA2)
418 // set 802.1x port control
419 //pAd->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
420 STA_PORT_SECURED(pAd);
422 // Indicate Connected for GUI
423 pAd->IndicateMediaState = NdisMediaStateConnected;
429 pAd->StaCfg.DefaultKeyId = (pKey->KeyIndex & 0xFF);
430 NdisZeroMemory(&pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId], sizeof(CIPHER_KEY));
431 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].KeyLen = LEN_TKIP_EK;
432 NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].Key, pKey->KeyMaterial, LEN_TKIP_EK);
433 #ifdef WPA_SUPPLICANT_SUPPORT
434 if (pAd->StaCfg.GroupCipher == Ndis802_11Encryption2Enabled)
436 NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].RxMic, pKey->KeyMaterial + LEN_TKIP_EK, LEN_TKIP_TXMICK);
437 NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].TxMic, pKey->KeyMaterial + LEN_TKIP_EK + LEN_TKIP_TXMICK, LEN_TKIP_RXMICK);
440 #endif // WPA_SUPPLICANT_SUPPORT //
442 NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].TxMic, pKey->KeyMaterial + LEN_TKIP_EK, LEN_TKIP_TXMICK);
443 NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].RxMic, pKey->KeyMaterial + LEN_TKIP_EK + LEN_TKIP_TXMICK, LEN_TKIP_RXMICK);
446 // Update Shared Key CipherAlg
447 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg = CIPHER_NONE;
448 if (pAd->StaCfg.GroupCipher == Ndis802_11Encryption2Enabled)
449 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg = CIPHER_TKIP;
450 else if (pAd->StaCfg.GroupCipher == Ndis802_11Encryption3Enabled)
451 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg = CIPHER_AES;
453 // Update group key information to ASIC Shared Key Table
454 AsicAddSharedKeyEntry(pAd,
456 pAd->StaCfg.DefaultKeyId,
457 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg,
458 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].Key,
459 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].TxMic,
460 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].RxMic);
462 // Update ASIC WCID attribute table and IVEIV table
463 RTMPAddWcidAttributeEntry(pAd,
465 pAd->StaCfg.DefaultKeyId,
466 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg,
469 // set 802.1x port control
470 //pAd->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
471 STA_PORT_SECURED(pAd);
473 // Indicate Connected for GUI
474 pAd->IndicateMediaState = NdisMediaStateConnected;
477 else // dynamic WEP from wpa_supplicant
482 if(pKey->KeyLength == 32)
485 KeyIdx = pKey->KeyIndex & 0x0fffffff;
489 // it is a default shared key, for Pairwise key setting
490 if (pKey->KeyIndex & 0x80000000)
492 pEntry = MacTableLookup(pAd, pKey->BSSID);
496 DBGPRINT(RT_DEBUG_TRACE, ("RTMPAddKey: Set Pair-wise Key\n"));
498 // set key material and key length
499 pEntry->PairwiseKey.KeyLen = (UCHAR)pKey->KeyLength;
500 NdisMoveMemory(pEntry->PairwiseKey.Key, &pKey->KeyMaterial, pKey->KeyLength);
503 if (pKey->KeyLength == 5)
504 pEntry->PairwiseKey.CipherAlg = CIPHER_WEP64;
506 pEntry->PairwiseKey.CipherAlg = CIPHER_WEP128;
508 // Add Pair-wise key to Asic
509 AsicAddPairwiseKeyEntry(
513 &pEntry->PairwiseKey);
515 // update WCID attribute table and IVEIV table for this entry
516 RTMPAddWcidAttributeEntry(
519 KeyIdx, // The value may be not zero
520 pEntry->PairwiseKey.CipherAlg,
527 // Default key for tx (shared key)
528 pAd->StaCfg.DefaultKeyId = (UCHAR) KeyIdx;
530 // set key material and key length
531 pAd->SharedKey[BSS0][KeyIdx].KeyLen = (UCHAR) pKey->KeyLength;
532 NdisMoveMemory(pAd->SharedKey[BSS0][KeyIdx].Key, &pKey->KeyMaterial, pKey->KeyLength);
535 if (pKey->KeyLength == 5)
536 pAd->SharedKey[BSS0][KeyIdx].CipherAlg = CIPHER_WEP64;
538 pAd->SharedKey[BSS0][KeyIdx].CipherAlg = CIPHER_WEP128;
540 CipherAlg = pAd->SharedKey[BSS0][KeyIdx].CipherAlg;
541 Key = pAd->SharedKey[BSS0][KeyIdx].Key;
543 // Set Group key material to Asic
544 AsicAddSharedKeyEntry(pAd, BSS0, KeyIdx, CipherAlg, Key, NULL, NULL);
546 // Update WCID attribute table and IVEIV table for this group key table
547 RTMPAddWcidAttributeEntry(pAd, BSS0, KeyIdx, CipherAlg, NULL);
556 char * rtstrchr(const char * s, int c)
558 for(; *s != (char) c; ++s)
565 This is required for LinEX2004/kernel2.6.7 to provide iwlist scanning function
569 rt_ioctl_giwname(struct net_device *dev,
570 struct iw_request_info *info,
571 char *name, char *extra)
573 // PRTMP_ADAPTER pAdapter = dev->ml_priv;
576 strncpy(name, "RT2870 Wireless", IFNAMSIZ);
581 int rt_ioctl_siwfreq(struct net_device *dev,
582 struct iw_request_info *info,
583 struct iw_freq *freq, char *extra)
585 PRTMP_ADAPTER pAdapter = dev->ml_priv;
588 //check if the interface is down
589 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
591 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
599 if((freq->e == 0) && (freq->m <= 1000))
600 chan = freq->m; // Setting by channel number
602 MAP_KHZ_TO_CHANNEL_ID( (freq->m /100) , chan); // Setting by frequency - search the table , like 2.412G, 2.422G,
604 if (ChannelSanity(pAdapter, chan) == TRUE)
606 pAdapter->CommonCfg.Channel = chan;
607 DBGPRINT(RT_DEBUG_ERROR, ("==>rt_ioctl_siwfreq::SIOCSIWFREQ[cmd=0x%x] (Channel=%d)\n", SIOCSIWFREQ, pAdapter->CommonCfg.Channel));
614 int rt_ioctl_giwfreq(struct net_device *dev,
615 struct iw_request_info *info,
616 struct iw_freq *freq, char *extra)
618 VIRTUAL_ADAPTER *pVirtualAd = NULL;
619 PRTMP_ADAPTER pAdapter = NULL;
623 if (dev->priv_flags == INT_MAIN)
625 pAdapter = dev->ml_priv;
629 pVirtualAd = dev->ml_priv;
630 if (pVirtualAd && pVirtualAd->RtmpDev)
631 pAdapter = pVirtualAd->RtmpDev->ml_priv;
634 if (pAdapter == NULL)
636 /* if 1st open fail, pAd will be free;
637 So the net_dev->ml_priv will be NULL in 2rd open */
641 ch = pAdapter->CommonCfg.Channel;
643 DBGPRINT(RT_DEBUG_TRACE,("==>rt_ioctl_giwfreq %d\n", ch));
645 MAP_CHANNEL_ID_TO_KHZ(ch, m);
651 int rt_ioctl_siwmode(struct net_device *dev,
652 struct iw_request_info *info,
653 __u32 *mode, char *extra)
655 PRTMP_ADAPTER pAdapter = dev->ml_priv;
657 //check if the interface is down
658 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
660 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
667 Set_NetworkType_Proc(pAdapter, "Adhoc");
670 Set_NetworkType_Proc(pAdapter, "Infra");
672 case IW_MODE_MONITOR:
673 Set_NetworkType_Proc(pAdapter, "Monitor");
676 DBGPRINT(RT_DEBUG_TRACE, ("===>rt_ioctl_siwmode::SIOCSIWMODE (unknown %d)\n", *mode));
680 // Reset Ralink supplicant to not use, it will be set to start when UI set PMK key
681 pAdapter->StaCfg.WpaState = SS_NOTUSE;
686 int rt_ioctl_giwmode(struct net_device *dev,
687 struct iw_request_info *info,
688 __u32 *mode, char *extra)
690 PRTMP_ADAPTER pAdapter = NULL;
691 VIRTUAL_ADAPTER *pVirtualAd = NULL;
693 if (dev->priv_flags == INT_MAIN)
695 pAdapter = dev->ml_priv;
699 pVirtualAd = dev->ml_priv;
700 if (pVirtualAd && pVirtualAd->RtmpDev)
701 pAdapter = pVirtualAd->RtmpDev->ml_priv;
704 if (pAdapter == NULL)
706 /* if 1st open fail, pAd will be free;
707 So the net_dev->ml_priv will be NULL in 2rd open */
711 if (ADHOC_ON(pAdapter))
712 *mode = IW_MODE_ADHOC;
713 else if (INFRA_ON(pAdapter))
714 *mode = IW_MODE_INFRA;
715 else if (MONITOR_ON(pAdapter))
717 *mode = IW_MODE_MONITOR;
720 *mode = IW_MODE_AUTO;
722 DBGPRINT(RT_DEBUG_TRACE, ("==>rt_ioctl_giwmode(mode=%d)\n", *mode));
726 int rt_ioctl_siwsens(struct net_device *dev,
727 struct iw_request_info *info,
728 char *name, char *extra)
730 PRTMP_ADAPTER pAdapter = dev->ml_priv;
732 //check if the interface is down
733 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
735 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
742 int rt_ioctl_giwsens(struct net_device *dev,
743 struct iw_request_info *info,
744 char *name, char *extra)
749 int rt_ioctl_giwrange(struct net_device *dev,
750 struct iw_request_info *info,
751 struct iw_point *data, char *extra)
753 PRTMP_ADAPTER pAdapter = NULL;
754 VIRTUAL_ADAPTER *pVirtualAd = NULL;
755 struct iw_range *range = (struct iw_range *) extra;
759 if (dev->priv_flags == INT_MAIN)
761 pAdapter = dev->ml_priv;
765 pVirtualAd = dev->ml_priv;
766 if (pVirtualAd && pVirtualAd->RtmpDev)
767 pAdapter = pVirtualAd->RtmpDev->ml_priv;
770 if (pAdapter == NULL)
772 /* if 1st open fail, pAd will be free;
773 So the net_dev->ml_priv will be NULL in 2rd open */
777 DBGPRINT(RT_DEBUG_TRACE ,("===>rt_ioctl_giwrange\n"));
778 data->length = sizeof(struct iw_range);
779 memset(range, 0, sizeof(struct iw_range));
781 range->txpower_capa = IW_TXPOW_DBM;
783 if (INFRA_ON(pAdapter)||ADHOC_ON(pAdapter))
785 range->min_pmp = 1 * 1024;
786 range->max_pmp = 65535 * 1024;
787 range->min_pmt = 1 * 1024;
788 range->max_pmt = 1000 * 1024;
789 range->pmp_flags = IW_POWER_PERIOD;
790 range->pmt_flags = IW_POWER_TIMEOUT;
791 range->pm_capa = IW_POWER_PERIOD | IW_POWER_TIMEOUT |
792 IW_POWER_UNICAST_R | IW_POWER_ALL_R;
795 range->we_version_compiled = WIRELESS_EXT;
796 range->we_version_source = 14;
798 range->retry_capa = IW_RETRY_LIMIT;
799 range->retry_flags = IW_RETRY_LIMIT;
800 range->min_retry = 0;
801 range->max_retry = 255;
803 range->num_channels = pAdapter->ChannelListNum;
806 for (i = 1; i <= range->num_channels; i++)
809 range->freq[val].i = pAdapter->ChannelList[i-1].Channel;
810 MAP_CHANNEL_ID_TO_KHZ(pAdapter->ChannelList[i-1].Channel, m);
811 range->freq[val].m = m * 100; /* HZ */
813 range->freq[val].e = 1;
815 if (val == IW_MAX_FREQUENCIES)
818 range->num_frequency = val;
820 range->max_qual.qual = 100; /* what is correct max? This was not
821 * documented exactly. At least
822 * 69 has been observed. */
823 range->max_qual.level = 0; /* dB */
824 range->max_qual.noise = 0; /* dB */
826 /* What would be suitable values for "average/typical" qual? */
827 range->avg_qual.qual = 20;
828 range->avg_qual.level = -60;
829 range->avg_qual.noise = -95;
830 range->sensitivity = 3;
832 range->max_encoding_tokens = NR_WEP_KEYS;
833 range->num_encoding_sizes = 2;
834 range->encoding_size[0] = 5;
835 range->encoding_size[1] = 13;
838 range->max_rts = 2347;
839 range->min_frag = 256;
840 range->max_frag = 2346;
842 #if WIRELESS_EXT > 17
843 /* IW_ENC_CAPA_* bit field */
844 range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 |
845 IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP;
851 int rt_ioctl_siwap(struct net_device *dev,
852 struct iw_request_info *info,
853 struct sockaddr *ap_addr, char *extra)
855 PRTMP_ADAPTER pAdapter = dev->ml_priv;
856 NDIS_802_11_MAC_ADDRESS Bssid;
858 //check if the interface is down
859 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
861 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
865 if (pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE)
867 RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
868 DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
871 // tell CNTL state machine to call NdisMSetInformationComplete() after completing
872 // this request, because this request is initiated by NDIS.
873 pAdapter->MlmeAux.CurrReqIsFromNdis = FALSE;
874 // Prevent to connect AP again in STAMlmePeriodicExec
875 pAdapter->MlmeAux.AutoReconnectSsidLen= 32;
877 memset(Bssid, 0, MAC_ADDR_LEN);
878 memcpy(Bssid, ap_addr->sa_data, MAC_ADDR_LEN);
879 MlmeEnqueue(pAdapter,
880 MLME_CNTL_STATE_MACHINE,
882 sizeof(NDIS_802_11_MAC_ADDRESS),
885 DBGPRINT(RT_DEBUG_TRACE, ("IOCTL::SIOCSIWAP %02x:%02x:%02x:%02x:%02x:%02x\n",
886 Bssid[0], Bssid[1], Bssid[2], Bssid[3], Bssid[4], Bssid[5]));
891 int rt_ioctl_giwap(struct net_device *dev,
892 struct iw_request_info *info,
893 struct sockaddr *ap_addr, char *extra)
895 PRTMP_ADAPTER pAdapter = NULL;
896 VIRTUAL_ADAPTER *pVirtualAd = NULL;
898 if (dev->priv_flags == INT_MAIN)
900 pAdapter = dev->ml_priv;
904 pVirtualAd = dev->ml_priv;
905 if (pVirtualAd && pVirtualAd->RtmpDev)
906 pAdapter = pVirtualAd->RtmpDev->ml_priv;
909 if (pAdapter == NULL)
911 /* if 1st open fail, pAd will be free;
912 So the net_dev->ml_priv will be NULL in 2rd open */
916 if (INFRA_ON(pAdapter) || ADHOC_ON(pAdapter))
918 ap_addr->sa_family = ARPHRD_ETHER;
919 memcpy(ap_addr->sa_data, &pAdapter->CommonCfg.Bssid, ETH_ALEN);
921 #ifdef WPA_SUPPLICANT_SUPPORT
923 else if (pAdapter->StaCfg.WpaSupplicantUP != WPA_SUPPLICANT_DISABLE)
925 ap_addr->sa_family = ARPHRD_ETHER;
926 memcpy(ap_addr->sa_data, &pAdapter->MlmeAux.Bssid, ETH_ALEN);
928 #endif // WPA_SUPPLICANT_SUPPORT //
931 DBGPRINT(RT_DEBUG_TRACE, ("IOCTL::SIOCGIWAP(=EMPTY)\n"));
939 * Units are in db above the noise floor. That means the
940 * rssi values reported in the tx/rx descriptors in the
941 * driver are the SNR expressed in db.
943 * If you assume that the noise floor is -95, which is an
944 * excellent assumption 99.5 % of the time, then you can
945 * derive the absolute signal level (i.e. -95 + rssi).
946 * There are some other slight factors to take into account
947 * depending on whether the rssi measurement is from 11b,
948 * 11g, or 11a. These differences are at most 2db and
951 * NB: various calculations are based on the orinoco/wavelan
952 * drivers for compatibility
954 static void set_quality(PRTMP_ADAPTER pAdapter,
955 struct iw_quality *iq,
962 ChannelQuality = 100;
963 else if (rssi >= -80) // between -50 ~ -80dbm
964 ChannelQuality = (__u8)(24 + ((rssi + 80) * 26)/10);
965 else if (rssi >= -90) // between -80 ~ -90dbm
966 ChannelQuality = (__u8)((rssi + 90) * 26)/10;
970 iq->qual = (__u8)ChannelQuality;
972 iq->level = (__u8)(rssi);
973 iq->noise = (pAdapter->BbpWriteLatch[66] > pAdapter->BbpTuning.FalseCcaUpperThreshold) ? ((__u8)pAdapter->BbpTuning.FalseCcaUpperThreshold) : ((__u8) pAdapter->BbpWriteLatch[66]); // noise level (dBm)
974 iq->noise += 256 - 143;
975 iq->updated = pAdapter->iw_stats.qual.updated;
978 int rt_ioctl_iwaplist(struct net_device *dev,
979 struct iw_request_info *info,
980 struct iw_point *data, char *extra)
982 PRTMP_ADAPTER pAdapter = dev->ml_priv;
984 struct sockaddr addr[IW_MAX_AP];
985 struct iw_quality qual[IW_MAX_AP];
988 //check if the interface is down
989 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
991 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
997 for (i = 0; i <IW_MAX_AP ; i++)
999 if (i >= pAdapter->ScanTab.BssNr)
1001 addr[i].sa_family = ARPHRD_ETHER;
1002 memcpy(addr[i].sa_data, &pAdapter->ScanTab.BssEntry[i].Bssid, MAC_ADDR_LEN);
1003 set_quality(pAdapter, &qual[i], pAdapter->ScanTab.BssEntry[i].Rssi);
1006 memcpy(extra, &addr, i*sizeof(addr[0]));
1007 data->flags = 1; /* signal quality present (sort of) */
1008 memcpy(extra + i*sizeof(addr[0]), &qual, i*sizeof(qual[i]));
1014 int rt_ioctl_siwscan(struct net_device *dev,
1015 struct iw_request_info *info,
1016 struct iw_point *data, char *extra)
1018 PRTMP_ADAPTER pAdapter = dev->ml_priv;
1021 int Status = NDIS_STATUS_SUCCESS;
1023 //check if the interface is down
1024 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1026 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1030 if (MONITOR_ON(pAdapter))
1032 DBGPRINT(RT_DEBUG_TRACE, ("!!! Driver is in Monitor Mode now !!!\n"));
1037 #ifdef WPA_SUPPLICANT_SUPPORT
1038 if (pAdapter->StaCfg.WpaSupplicantUP == WPA_SUPPLICANT_ENABLE)
1040 pAdapter->StaCfg.WpaSupplicantScanCount++;
1042 #endif // WPA_SUPPLICANT_SUPPORT //
1044 pAdapter->StaCfg.bScanReqIsFromWebUI = TRUE;
1045 if (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
1050 #ifdef WPA_SUPPLICANT_SUPPORT
1051 if ((pAdapter->StaCfg.WpaSupplicantUP == WPA_SUPPLICANT_ENABLE) &&
1052 (pAdapter->StaCfg.WpaSupplicantScanCount > 3))
1054 DBGPRINT(RT_DEBUG_TRACE, ("!!! WpaSupplicantScanCount > 3\n"));
1055 Status = NDIS_STATUS_SUCCESS;
1058 #endif // WPA_SUPPLICANT_SUPPORT //
1060 if ((OPSTATUS_TEST_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED)) &&
1061 ((pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA) ||
1062 (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK)) &&
1063 (pAdapter->StaCfg.PortSecured == WPA_802_1X_PORT_NOT_SECURED))
1065 DBGPRINT(RT_DEBUG_TRACE, ("!!! Link UP, Port Not Secured! ignore this set::OID_802_11_BSSID_LIST_SCAN\n"));
1066 Status = NDIS_STATUS_SUCCESS;
1070 if (pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE)
1072 RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
1073 DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
1076 // tell CNTL state machine to call NdisMSetInformationComplete() after completing
1077 // this request, because this request is initiated by NDIS.
1078 pAdapter->MlmeAux.CurrReqIsFromNdis = FALSE;
1079 // Reset allowed scan retries
1080 pAdapter->StaCfg.ScanCnt = 0;
1081 pAdapter->StaCfg.LastScanTime = Now;
1083 MlmeEnqueue(pAdapter,
1084 MLME_CNTL_STATE_MACHINE,
1085 OID_802_11_BSSID_LIST_SCAN,
1089 Status = NDIS_STATUS_SUCCESS;
1090 RT28XX_MLME_HANDLER(pAdapter);
1095 int rt_ioctl_giwscan(struct net_device *dev,
1096 struct iw_request_info *info,
1097 struct iw_point *data, char *extra)
1100 PRTMP_ADAPTER pAdapter = dev->ml_priv;
1102 char *current_ev = extra, *previous_ev = extra;
1104 char *current_val, custom[MAX_CUSTOM_LEN] = {0};
1107 #endif // IWEVGENIE //
1108 struct iw_event iwe;
1110 if (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
1113 * Still scanning, indicate the caller should try again.
1119 #ifdef WPA_SUPPLICANT_SUPPORT
1120 if (pAdapter->StaCfg.WpaSupplicantUP == WPA_SUPPLICANT_ENABLE)
1122 pAdapter->StaCfg.WpaSupplicantScanCount = 0;
1124 #endif // WPA_SUPPLICANT_SUPPORT //
1126 if (pAdapter->ScanTab.BssNr == 0)
1132 #if WIRELESS_EXT >= 17
1133 if (data->length > 0)
1134 end_buf = extra + data->length;
1136 end_buf = extra + IW_SCAN_MAX_DATA;
1138 end_buf = extra + IW_SCAN_MAX_DATA;
1141 for (i = 0; i < pAdapter->ScanTab.BssNr; i++)
1143 if (current_ev >= end_buf)
1145 #if WIRELESS_EXT >= 17
1153 //================================
1154 memset(&iwe, 0, sizeof(iwe));
1155 iwe.cmd = SIOCGIWAP;
1156 iwe.u.ap_addr.sa_family = ARPHRD_ETHER;
1157 memcpy(iwe.u.ap_addr.sa_data, &pAdapter->ScanTab.BssEntry[i].Bssid, ETH_ALEN);
1159 previous_ev = current_ev;
1160 current_ev = iwe_stream_add_event(info, current_ev,end_buf, &iwe, IW_EV_ADDR_LEN);
1161 if (current_ev == previous_ev)
1162 #if WIRELESS_EXT >= 17
1169 //================================
1170 memset(&iwe, 0, sizeof(iwe));
1171 iwe.cmd = SIOCGIWESSID;
1172 iwe.u.data.length = pAdapter->ScanTab.BssEntry[i].SsidLen;
1173 iwe.u.data.flags = 1;
1175 previous_ev = current_ev;
1176 current_ev = iwe_stream_add_point(info, current_ev,end_buf, &iwe, pAdapter->ScanTab.BssEntry[i].Ssid);
1177 if (current_ev == previous_ev)
1178 #if WIRELESS_EXT >= 17
1185 //================================
1186 memset(&iwe, 0, sizeof(iwe));
1187 iwe.cmd = SIOCGIWMODE;
1188 if (pAdapter->ScanTab.BssEntry[i].BssType == Ndis802_11IBSS)
1190 iwe.u.mode = IW_MODE_ADHOC;
1192 else if (pAdapter->ScanTab.BssEntry[i].BssType == Ndis802_11Infrastructure)
1194 iwe.u.mode = IW_MODE_INFRA;
1198 iwe.u.mode = IW_MODE_AUTO;
1200 iwe.len = IW_EV_UINT_LEN;
1202 previous_ev = current_ev;
1203 current_ev = iwe_stream_add_event(info, current_ev, end_buf, &iwe, IW_EV_UINT_LEN);
1204 if (current_ev == previous_ev)
1205 #if WIRELESS_EXT >= 17
1211 //Channel and Frequency
1212 //================================
1213 memset(&iwe, 0, sizeof(iwe));
1214 iwe.cmd = SIOCGIWFREQ;
1215 if (INFRA_ON(pAdapter) || ADHOC_ON(pAdapter))
1216 iwe.u.freq.m = pAdapter->ScanTab.BssEntry[i].Channel;
1218 iwe.u.freq.m = pAdapter->ScanTab.BssEntry[i].Channel;
1222 previous_ev = current_ev;
1223 current_ev = iwe_stream_add_event(info, current_ev, end_buf, &iwe, IW_EV_FREQ_LEN);
1224 if (current_ev == previous_ev)
1225 #if WIRELESS_EXT >= 17
1231 //Add quality statistics
1232 //================================
1233 memset(&iwe, 0, sizeof(iwe));
1235 iwe.u.qual.level = 0;
1236 iwe.u.qual.noise = 0;
1237 set_quality(pAdapter, &iwe.u.qual, pAdapter->ScanTab.BssEntry[i].Rssi);
1238 current_ev = iwe_stream_add_event(info, current_ev, end_buf, &iwe, IW_EV_QUAL_LEN);
1239 if (current_ev == previous_ev)
1240 #if WIRELESS_EXT >= 17
1247 //================================
1248 memset(&iwe, 0, sizeof(iwe));
1249 iwe.cmd = SIOCGIWENCODE;
1250 if (CAP_IS_PRIVACY_ON (pAdapter->ScanTab.BssEntry[i].CapabilityInfo ))
1251 iwe.u.data.flags =IW_ENCODE_ENABLED | IW_ENCODE_NOKEY;
1253 iwe.u.data.flags = IW_ENCODE_DISABLED;
1255 previous_ev = current_ev;
1256 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);
1257 if (current_ev == previous_ev)
1258 #if WIRELESS_EXT >= 17
1265 //================================
1266 if (pAdapter->ScanTab.BssEntry[i].SupRateLen)
1268 UCHAR tmpRate = pAdapter->ScanTab.BssEntry[i].SupRate[pAdapter->ScanTab.BssEntry[i].SupRateLen-1];
1269 memset(&iwe, 0, sizeof(iwe));
1270 iwe.cmd = SIOCGIWRATE;
1271 current_val = current_ev + IW_EV_LCP_LEN;
1272 if (tmpRate == 0x82)
1273 iwe.u.bitrate.value = 1 * 1000000;
1274 else if (tmpRate == 0x84)
1275 iwe.u.bitrate.value = 2 * 1000000;
1276 else if (tmpRate == 0x8B)
1277 iwe.u.bitrate.value = 5.5 * 1000000;
1278 else if (tmpRate == 0x96)
1279 iwe.u.bitrate.value = 11 * 1000000;
1281 iwe.u.bitrate.value = (tmpRate/2) * 1000000;
1283 iwe.u.bitrate.disabled = 0;
1284 current_val = iwe_stream_add_value(info, current_ev,
1285 current_val, end_buf, &iwe,
1288 if((current_val-current_ev)>IW_EV_LCP_LEN)
1289 current_ev = current_val;
1291 #if WIRELESS_EXT >= 17
1300 if (pAdapter->ScanTab.BssEntry[i].WpaIE.IELen > 0)
1302 memset(&iwe, 0, sizeof(iwe));
1303 memset(&custom[0], 0, MAX_CUSTOM_LEN);
1304 memcpy(custom, &(pAdapter->ScanTab.BssEntry[i].WpaIE.IE[0]),
1305 pAdapter->ScanTab.BssEntry[i].WpaIE.IELen);
1306 iwe.cmd = IWEVGENIE;
1307 iwe.u.data.length = pAdapter->ScanTab.BssEntry[i].WpaIE.IELen;
1308 current_ev = iwe_stream_add_point(info, current_ev, end_buf, &iwe, custom);
1309 if (current_ev == previous_ev)
1310 #if WIRELESS_EXT >= 17
1318 if (pAdapter->ScanTab.BssEntry[i].RsnIE.IELen > 0)
1320 memset(&iwe, 0, sizeof(iwe));
1321 memset(&custom[0], 0, MAX_CUSTOM_LEN);
1322 memcpy(custom, &(pAdapter->ScanTab.BssEntry[i].RsnIE.IE[0]),
1323 pAdapter->ScanTab.BssEntry[i].RsnIE.IELen);
1324 iwe.cmd = IWEVGENIE;
1325 iwe.u.data.length = pAdapter->ScanTab.BssEntry[i].RsnIE.IELen;
1326 current_ev = iwe_stream_add_point(info, current_ev, end_buf, &iwe, custom);
1327 if (current_ev == previous_ev)
1328 #if WIRELESS_EXT >= 17
1336 //================================
1337 if (pAdapter->ScanTab.BssEntry[i].WpaIE.IELen > 0)
1339 NdisZeroMemory(&iwe, sizeof(iwe));
1340 memset(&custom[0], 0, MAX_CUSTOM_LEN);
1341 iwe.cmd = IWEVCUSTOM;
1342 iwe.u.data.length = (pAdapter->ScanTab.BssEntry[i].WpaIE.IELen * 2) + 7;
1343 NdisMoveMemory(custom, "wpa_ie=", 7);
1344 for (idx = 0; idx < pAdapter->ScanTab.BssEntry[i].WpaIE.IELen; idx++)
1345 sprintf(custom + strlen(custom), "%02x", pAdapter->ScanTab.BssEntry[i].WpaIE.IE[idx]);
1346 previous_ev = current_ev;
1347 current_ev = iwe_stream_add_point(current_ev, end_buf, &iwe, custom);
1348 if (current_ev == previous_ev)
1349 #if WIRELESS_EXT >= 17
1357 if (pAdapter->ScanTab.BssEntry[i].RsnIE.IELen > 0)
1359 NdisZeroMemory(&iwe, sizeof(iwe));
1360 memset(&custom[0], 0, MAX_CUSTOM_LEN);
1361 iwe.cmd = IWEVCUSTOM;
1362 iwe.u.data.length = (pAdapter->ScanTab.BssEntry[i].RsnIE.IELen * 2) + 7;
1363 NdisMoveMemory(custom, "rsn_ie=", 7);
1364 for (idx = 0; idx < pAdapter->ScanTab.BssEntry[i].RsnIE.IELen; idx++)
1365 sprintf(custom + strlen(custom), "%02x", pAdapter->ScanTab.BssEntry[i].RsnIE.IE[idx]);
1366 previous_ev = current_ev;
1367 current_ev = iwe_stream_add_point(current_ev, end_buf, &iwe, custom);
1368 if (current_ev == previous_ev)
1369 #if WIRELESS_EXT >= 17
1375 #endif // IWEVGENIE //
1378 data->length = current_ev - extra;
1379 pAdapter->StaCfg.bScanReqIsFromWebUI = FALSE;
1380 DBGPRINT(RT_DEBUG_ERROR ,("===>rt_ioctl_giwscan. %d(%d) BSS returned, data->length = %d\n",i , pAdapter->ScanTab.BssNr, data->length));
1385 int rt_ioctl_siwessid(struct net_device *dev,
1386 struct iw_request_info *info,
1387 struct iw_point *data, char *essid)
1389 PRTMP_ADAPTER pAdapter = dev->ml_priv;
1391 //check if the interface is down
1392 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1394 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1400 PCHAR pSsidString = NULL;
1402 // Includes null character.
1403 if (data->length > (IW_ESSID_MAX_SIZE + 1))
1406 pSsidString = (CHAR *) kmalloc(MAX_LEN_OF_SSID+1, MEM_ALLOC_FLAG);
1409 NdisZeroMemory(pSsidString, MAX_LEN_OF_SSID+1);
1410 NdisMoveMemory(pSsidString, essid, data->length);
1411 if (Set_SSID_Proc(pAdapter, pSsidString) == FALSE)
1420 if (Set_SSID_Proc(pAdapter, "") == FALSE)
1426 int rt_ioctl_giwessid(struct net_device *dev,
1427 struct iw_request_info *info,
1428 struct iw_point *data, char *essid)
1430 PRTMP_ADAPTER pAdapter = NULL;
1431 VIRTUAL_ADAPTER *pVirtualAd = NULL;
1433 if (dev->priv_flags == INT_MAIN)
1435 pAdapter = dev->ml_priv;
1439 pVirtualAd = dev->ml_priv;
1440 if (pVirtualAd && pVirtualAd->RtmpDev)
1441 pAdapter = pVirtualAd->RtmpDev->ml_priv;
1444 if (pAdapter == NULL)
1446 /* if 1st open fail, pAd will be free;
1447 So the net_dev->ml_priv will be NULL in 2rd open */
1452 if (MONITOR_ON(pAdapter))
1458 if (OPSTATUS_TEST_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED))
1460 DBGPRINT(RT_DEBUG_TRACE ,("MediaState is connected\n"));
1461 data->length = pAdapter->CommonCfg.SsidLen;
1462 memcpy(essid, pAdapter->CommonCfg.Ssid, pAdapter->CommonCfg.SsidLen);
1465 #ifdef WPA_SUPPLICANT_SUPPORT
1467 else if (pAdapter->StaCfg.WpaSupplicantUP != WPA_SUPPLICANT_DISABLE)
1469 data->length = pAdapter->CommonCfg.SsidLen;
1470 memcpy(essid, pAdapter->CommonCfg.Ssid, pAdapter->CommonCfg.SsidLen);
1472 #endif // WPA_SUPPLICANT_SUPPORT //
1475 {//the ANY ssid was specified
1477 DBGPRINT(RT_DEBUG_TRACE ,("MediaState is not connected, ess\n"));
1484 int rt_ioctl_siwnickn(struct net_device *dev,
1485 struct iw_request_info *info,
1486 struct iw_point *data, char *nickname)
1488 PRTMP_ADAPTER pAdapter = dev->ml_priv;
1490 //check if the interface is down
1491 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1493 DBGPRINT(RT_DEBUG_TRACE ,("INFO::Network is down!\n"));
1497 if (data->length > IW_ESSID_MAX_SIZE)
1500 memset(pAdapter->nickname, 0, IW_ESSID_MAX_SIZE + 1);
1501 memcpy(pAdapter->nickname, nickname, data->length);
1507 int rt_ioctl_giwnickn(struct net_device *dev,
1508 struct iw_request_info *info,
1509 struct iw_point *data, char *nickname)
1511 PRTMP_ADAPTER pAdapter = NULL;
1512 VIRTUAL_ADAPTER *pVirtualAd = NULL;
1514 if (dev->priv_flags == INT_MAIN)
1516 pAdapter = dev->ml_priv;
1520 pVirtualAd = dev->ml_priv;
1521 if (pVirtualAd && pVirtualAd->RtmpDev)
1522 pAdapter = pVirtualAd->RtmpDev->ml_priv;
1525 if (pAdapter == NULL)
1527 /* if 1st open fail, pAd will be free;
1528 So the net_dev->ml_priv will be NULL in 2rd open */
1532 if (data->length > strlen(pAdapter->nickname) + 1)
1533 data->length = strlen(pAdapter->nickname) + 1;
1534 if (data->length > 0) {
1535 memcpy(nickname, pAdapter->nickname, data->length-1);
1536 nickname[data->length-1] = '\0';
1541 int rt_ioctl_siwrts(struct net_device *dev,
1542 struct iw_request_info *info,
1543 struct iw_param *rts, char *extra)
1545 PRTMP_ADAPTER pAdapter = dev->ml_priv;
1548 //check if the interface is down
1549 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1551 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1556 val = MAX_RTS_THRESHOLD;
1557 else if (rts->value < 0 || rts->value > MAX_RTS_THRESHOLD)
1559 else if (rts->value == 0)
1560 val = MAX_RTS_THRESHOLD;
1564 if (val != pAdapter->CommonCfg.RtsThreshold)
1565 pAdapter->CommonCfg.RtsThreshold = val;
1570 int rt_ioctl_giwrts(struct net_device *dev,
1571 struct iw_request_info *info,
1572 struct iw_param *rts, char *extra)
1574 PRTMP_ADAPTER pAdapter = NULL;
1575 VIRTUAL_ADAPTER *pVirtualAd = NULL;
1577 if (dev->priv_flags == INT_MAIN)
1579 pAdapter = dev->ml_priv;
1583 pVirtualAd = dev->ml_priv;
1584 if (pVirtualAd && pVirtualAd->RtmpDev)
1585 pAdapter = pVirtualAd->RtmpDev->ml_priv;
1588 if (pAdapter == NULL)
1590 /* if 1st open fail, pAd will be free;
1591 So the net_dev->ml_priv will be NULL in 2rd open */
1595 //check if the interface is down
1596 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1598 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1602 rts->value = pAdapter->CommonCfg.RtsThreshold;
1603 rts->disabled = (rts->value == MAX_RTS_THRESHOLD);
1609 int rt_ioctl_siwfrag(struct net_device *dev,
1610 struct iw_request_info *info,
1611 struct iw_param *frag, char *extra)
1613 PRTMP_ADAPTER pAdapter = dev->ml_priv;
1616 //check if the interface is down
1617 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1619 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1624 val = MAX_FRAG_THRESHOLD;
1625 else if (frag->value >= MIN_FRAG_THRESHOLD || frag->value <= MAX_FRAG_THRESHOLD)
1626 val = __cpu_to_le16(frag->value & ~0x1); /* even numbers only */
1627 else if (frag->value == 0)
1628 val = MAX_FRAG_THRESHOLD;
1632 pAdapter->CommonCfg.FragmentThreshold = val;
1636 int rt_ioctl_giwfrag(struct net_device *dev,
1637 struct iw_request_info *info,
1638 struct iw_param *frag, char *extra)
1640 PRTMP_ADAPTER pAdapter = NULL;
1641 VIRTUAL_ADAPTER *pVirtualAd = NULL;
1643 if (dev->priv_flags == INT_MAIN)
1645 pAdapter = dev->ml_priv;
1649 pVirtualAd = dev->ml_priv;
1650 if (pVirtualAd && pVirtualAd->RtmpDev)
1651 pAdapter = pVirtualAd->RtmpDev->ml_priv;
1654 if (pAdapter == NULL)
1656 /* if 1st open fail, pAd will be free;
1657 So the net_dev->ml_priv will be NULL in 2rd open */
1661 //check if the interface is down
1662 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1664 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1668 frag->value = pAdapter->CommonCfg.FragmentThreshold;
1669 frag->disabled = (frag->value == MAX_FRAG_THRESHOLD);
1675 #define MAX_WEP_KEY_SIZE 13
1676 #define MIN_WEP_KEY_SIZE 5
1677 int rt_ioctl_siwencode(struct net_device *dev,
1678 struct iw_request_info *info,
1679 struct iw_point *erq, char *extra)
1681 PRTMP_ADAPTER pAdapter = dev->ml_priv;
1683 //check if the interface is down
1684 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1686 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1690 if ((erq->length == 0) &&
1691 (erq->flags & IW_ENCODE_DISABLED))
1693 pAdapter->StaCfg.PairCipher = Ndis802_11WEPDisabled;
1694 pAdapter->StaCfg.GroupCipher = Ndis802_11WEPDisabled;
1695 pAdapter->StaCfg.WepStatus = Ndis802_11WEPDisabled;
1696 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
1697 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
1700 else if ((erq->length == 0) &&
1701 (erq->flags & IW_ENCODE_RESTRICTED || erq->flags & IW_ENCODE_OPEN))
1703 //pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
1704 STA_PORT_SECURED(pAdapter);
1705 pAdapter->StaCfg.PairCipher = Ndis802_11WEPEnabled;
1706 pAdapter->StaCfg.GroupCipher = Ndis802_11WEPEnabled;
1707 pAdapter->StaCfg.WepStatus = Ndis802_11WEPEnabled;
1708 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
1709 if (erq->flags & IW_ENCODE_RESTRICTED)
1710 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeShared;
1712 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
1716 if (erq->length > 0)
1718 int keyIdx = (erq->flags & IW_ENCODE_INDEX) - 1;
1719 /* Check the size of the key */
1720 if (erq->length > MAX_WEP_KEY_SIZE) {
1723 /* Check key index */
1724 if ((keyIdx < 0) || (keyIdx >= NR_WEP_KEYS))
1726 DBGPRINT(RT_DEBUG_TRACE ,("==>rt_ioctl_siwencode::Wrong keyIdx=%d! Using default key instead (%d)\n",
1727 keyIdx, pAdapter->StaCfg.DefaultKeyId));
1730 keyIdx = pAdapter->StaCfg.DefaultKeyId;
1733 NdisZeroMemory(pAdapter->SharedKey[BSS0][keyIdx].Key, 16);
1735 if (erq->length == MAX_WEP_KEY_SIZE)
1737 pAdapter->SharedKey[BSS0][keyIdx].KeyLen = MAX_WEP_KEY_SIZE;
1738 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CIPHER_WEP128;
1740 else if (erq->length == MIN_WEP_KEY_SIZE)
1742 pAdapter->SharedKey[BSS0][keyIdx].KeyLen = MIN_WEP_KEY_SIZE;
1743 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CIPHER_WEP64;
1746 /* Disable the key */
1747 pAdapter->SharedKey[BSS0][keyIdx].KeyLen = 0;
1749 /* Check if the key is not marked as invalid */
1750 if(!(erq->flags & IW_ENCODE_NOKEY)) {
1751 /* Copy the key in the driver */
1752 NdisMoveMemory(pAdapter->SharedKey[BSS0][keyIdx].Key, extra, erq->length);
1757 /* Do we want to just set the transmit key index ? */
1758 int index = (erq->flags & IW_ENCODE_INDEX) - 1;
1759 if ((index >= 0) && (index < 4))
1761 pAdapter->StaCfg.DefaultKeyId = index;
1764 /* Don't complain if only change the mode */
1765 if (!(erq->flags & IW_ENCODE_MODE)) {
1771 DBGPRINT(RT_DEBUG_TRACE ,("==>rt_ioctl_siwencode::erq->flags=%x\n",erq->flags));
1772 DBGPRINT(RT_DEBUG_TRACE ,("==>rt_ioctl_siwencode::AuthMode=%x\n",pAdapter->StaCfg.AuthMode));
1773 DBGPRINT(RT_DEBUG_TRACE ,("==>rt_ioctl_siwencode::DefaultKeyId=%x, KeyLen = %d\n",pAdapter->StaCfg.DefaultKeyId , pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].KeyLen));
1774 DBGPRINT(RT_DEBUG_TRACE ,("==>rt_ioctl_siwencode::WepStatus=%x\n",pAdapter->StaCfg.WepStatus));
1779 rt_ioctl_giwencode(struct net_device *dev,
1780 struct iw_request_info *info,
1781 struct iw_point *erq, char *key)
1784 PRTMP_ADAPTER pAdapter = NULL;
1785 VIRTUAL_ADAPTER *pVirtualAd = NULL;
1787 if (dev->priv_flags == INT_MAIN)
1789 pAdapter = dev->ml_priv;
1793 pVirtualAd = dev->ml_priv;
1794 if (pVirtualAd && pVirtualAd->RtmpDev)
1795 pAdapter = pVirtualAd->RtmpDev->ml_priv;
1798 if (pAdapter == NULL)
1800 /* if 1st open fail, pAd will be free;
1801 So the net_dev->ml_priv will be NULL in 2rd open */
1805 //check if the interface is down
1806 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1808 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1812 kid = erq->flags & IW_ENCODE_INDEX;
1813 DBGPRINT(RT_DEBUG_TRACE, ("===>rt_ioctl_giwencode %d\n", erq->flags & IW_ENCODE_INDEX));
1815 if (pAdapter->StaCfg.WepStatus == Ndis802_11WEPDisabled)
1818 erq->flags = IW_ENCODE_DISABLED;
1820 else if ((kid > 0) && (kid <=4))
1823 erq->flags = kid ; /* NB: base 1 */
1824 if (erq->length > pAdapter->SharedKey[BSS0][kid-1].KeyLen)
1825 erq->length = pAdapter->SharedKey[BSS0][kid-1].KeyLen;
1826 memcpy(key, pAdapter->SharedKey[BSS0][kid-1].Key, erq->length);
1827 //if ((kid == pAdapter->PortCfg.DefaultKeyId))
1828 //erq->flags |= IW_ENCODE_ENABLED; /* XXX */
1829 if (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeShared)
1830 erq->flags |= IW_ENCODE_RESTRICTED; /* XXX */
1832 erq->flags |= IW_ENCODE_OPEN; /* XXX */
1837 if (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeShared)
1838 erq->flags |= IW_ENCODE_RESTRICTED; /* XXX */
1840 erq->flags |= IW_ENCODE_OPEN; /* XXX */
1841 erq->length = pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].KeyLen;
1842 memcpy(key, pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].Key, erq->length);
1843 // copy default key ID
1844 if (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeShared)
1845 erq->flags |= IW_ENCODE_RESTRICTED; /* XXX */
1847 erq->flags |= IW_ENCODE_OPEN; /* XXX */
1848 erq->flags = pAdapter->StaCfg.DefaultKeyId + 1; /* NB: base 1 */
1849 erq->flags |= IW_ENCODE_ENABLED; /* XXX */
1857 rt_ioctl_setparam(struct net_device *dev, struct iw_request_info *info,
1858 void *w, char *extra)
1860 VIRTUAL_ADAPTER *pVirtualAd = NULL;
1861 PRTMP_ADAPTER pAdapter;
1863 char *this_char = extra;
1867 if (dev->priv_flags == INT_MAIN)
1869 pAdapter = dev->ml_priv;
1873 pVirtualAd = dev->ml_priv;
1874 pAdapter = pVirtualAd->RtmpDev->ml_priv;
1876 pObj = (POS_COOKIE) pAdapter->OS_Cookie;
1878 if (pAdapter == NULL)
1880 /* if 1st open fail, pAd will be free;
1881 So the net_dev->ml_priv will be NULL in 2rd open */
1886 pObj->ioctl_if_type = INT_MAIN;
1887 pObj->ioctl_if = MAIN_MBSSID;
1890 //check if the interface is down
1891 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1893 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1900 if ((value = rtstrchr(this_char, '=')) != NULL)
1906 // reject setting nothing besides ANY ssid(ssidLen=0)
1907 if (!*value && (strcmp(this_char, "SSID") != 0))
1910 for (PRTMP_PRIVATE_SET_PROC = RTMP_PRIVATE_SUPPORT_PROC; PRTMP_PRIVATE_SET_PROC->name; PRTMP_PRIVATE_SET_PROC++)
1912 if (strcmp(this_char, PRTMP_PRIVATE_SET_PROC->name) == 0)
1914 if(!PRTMP_PRIVATE_SET_PROC->set_proc(pAdapter, value))
1915 { //FALSE:Set private failed then return Invalid argument
1918 break; //Exit for loop.
1922 if(PRTMP_PRIVATE_SET_PROC->name == NULL)
1923 { //Not found argument
1925 DBGPRINT(RT_DEBUG_TRACE, ("===>rt_ioctl_setparam:: (iwpriv) Not Support Set Command [%s=%s]\n", this_char, value));
1933 rt_private_get_statistics(struct net_device *dev, struct iw_request_info *info,
1934 struct iw_point *wrq, char *extra)
1937 PRTMP_ADAPTER pAd = dev->ml_priv;
1945 memset(extra, 0x00, IW_PRIV_SIZE_MASK);
1946 sprintf(extra, "\n\n");
1951 sprintf(extra+strlen(extra), "Tx success = %ld\n", (ULONG)pAd->ate.TxDoneCount);
1952 //sprintf(extra+strlen(extra), "Tx success without retry = %ld\n", (ULONG)pAd->ate.TxDoneCount);
1955 #endif // RALINK_ATE //
1957 sprintf(extra+strlen(extra), "Tx success = %ld\n", (ULONG)pAd->WlanCounters.TransmittedFragmentCount.QuadPart);
1958 sprintf(extra+strlen(extra), "Tx success without retry = %ld\n", (ULONG)pAd->WlanCounters.TransmittedFragmentCount.QuadPart - (ULONG)pAd->WlanCounters.RetryCount.QuadPart);
1960 sprintf(extra+strlen(extra), "Tx success after retry = %ld\n", (ULONG)pAd->WlanCounters.RetryCount.QuadPart);
1961 sprintf(extra+strlen(extra), "Tx fail to Rcv ACK after retry = %ld\n", (ULONG)pAd->WlanCounters.FailedCount.QuadPart);
1962 sprintf(extra+strlen(extra), "RTS Success Rcv CTS = %ld\n", (ULONG)pAd->WlanCounters.RTSSuccessCount.QuadPart);
1963 sprintf(extra+strlen(extra), "RTS Fail Rcv CTS = %ld\n", (ULONG)pAd->WlanCounters.RTSFailureCount.QuadPart);
1965 sprintf(extra+strlen(extra), "Rx success = %ld\n", (ULONG)pAd->WlanCounters.ReceivedFragmentCount.QuadPart);
1966 sprintf(extra+strlen(extra), "Rx with CRC = %ld\n", (ULONG)pAd->WlanCounters.FCSErrorCount.QuadPart);
1967 sprintf(extra+strlen(extra), "Rx drop due to out of resource = %ld\n", (ULONG)pAd->Counters8023.RxNoBuffer);
1968 sprintf(extra+strlen(extra), "Rx duplicate frame = %ld\n", (ULONG)pAd->WlanCounters.FrameDuplicateCount.QuadPart);
1970 sprintf(extra+strlen(extra), "False CCA (one second) = %ld\n", (ULONG)pAd->RalinkCounters.OneSecFalseCCACnt);
1974 if (pAd->ate.RxAntennaSel == 0)
1976 sprintf(extra+strlen(extra), "RSSI-A = %ld\n", (LONG)(pAd->ate.LastRssi0 - pAd->BbpRssiToDbmDelta));
1977 sprintf(extra+strlen(extra), "RSSI-B (if available) = %ld\n", (LONG)(pAd->ate.LastRssi1 - pAd->BbpRssiToDbmDelta));
1978 sprintf(extra+strlen(extra), "RSSI-C (if available) = %ld\n\n", (LONG)(pAd->ate.LastRssi2 - pAd->BbpRssiToDbmDelta));
1982 sprintf(extra+strlen(extra), "RSSI = %ld\n", (LONG)(pAd->ate.LastRssi0 - pAd->BbpRssiToDbmDelta));
1986 #endif // RALINK_ATE //
1988 sprintf(extra+strlen(extra), "RSSI-A = %ld\n", (LONG)(pAd->StaCfg.RssiSample.LastRssi0 - pAd->BbpRssiToDbmDelta));
1989 sprintf(extra+strlen(extra), "RSSI-B (if available) = %ld\n", (LONG)(pAd->StaCfg.RssiSample.LastRssi1 - pAd->BbpRssiToDbmDelta));
1990 sprintf(extra+strlen(extra), "RSSI-C (if available) = %ld\n\n", (LONG)(pAd->StaCfg.RssiSample.LastRssi2 - pAd->BbpRssiToDbmDelta));
1992 #ifdef WPA_SUPPLICANT_SUPPORT
1993 sprintf(extra+strlen(extra), "WpaSupplicantUP = %d\n\n", pAd->StaCfg.WpaSupplicantUP);
1994 #endif // WPA_SUPPLICANT_SUPPORT //
1997 wrq->length = strlen(extra) + 1; // 1: size of '\0'
1998 DBGPRINT(RT_DEBUG_TRACE, ("<== rt_private_get_statistics, wrq->length = %d\n", wrq->length));
2003 #ifdef DOT11_N_SUPPORT
2005 IN PRTMP_ADAPTER pAd,
2009 BA_ORI_ENTRY *pOriBAEntry;
2010 BA_REC_ENTRY *pRecBAEntry;
2012 for (i=0; i<MAX_LEN_OF_MAC_TABLE; i++)
2014 PMAC_TABLE_ENTRY pEntry = &pAd->MacTab.Content[i];
2015 if (((pEntry->ValidAsCLI || pEntry->ValidAsApCli) && (pEntry->Sst == SST_ASSOC))
2016 || (pEntry->ValidAsWDS) || (pEntry->ValidAsMesh))
2018 sprintf(pOutBuf + strlen(pOutBuf), "\n%02X:%02X:%02X:%02X:%02X:%02X (Aid = %d) (AP) -\n",
2019 pEntry->Addr[0], pEntry->Addr[1], pEntry->Addr[2],
2020 pEntry->Addr[3], pEntry->Addr[4], pEntry->Addr[5], pEntry->Aid);
2022 sprintf(pOutBuf, "%s[Recipient]\n", pOutBuf);
2023 for (j=0; j < NUM_OF_TID; j++)
2025 if (pEntry->BARecWcidArray[j] != 0)
2027 pRecBAEntry =&pAd->BATable.BARecEntry[pEntry->BARecWcidArray[j]];
2028 sprintf(pOutBuf + strlen(pOutBuf), "TID=%d, BAWinSize=%d, LastIndSeq=%d, ReorderingPkts=%d\n", j, pRecBAEntry->BAWinSize, pRecBAEntry->LastIndSeq, pRecBAEntry->list.qlen);
2031 sprintf(pOutBuf, "%s\n", pOutBuf);
2033 sprintf(pOutBuf, "%s[Originator]\n", pOutBuf);
2034 for (j=0; j < NUM_OF_TID; j++)
2036 if (pEntry->BAOriWcidArray[j] != 0)
2038 pOriBAEntry =&pAd->BATable.BAOriEntry[pEntry->BAOriWcidArray[j]];
2039 sprintf(pOutBuf + strlen(pOutBuf), "TID=%d, BAWinSize=%d, StartSeq=%d, CurTxSeq=%d\n", j, pOriBAEntry->BAWinSize, pOriBAEntry->Sequence, pEntry->TxSeq[j]);
2042 sprintf(pOutBuf, "%s\n\n", pOutBuf);
2044 if (strlen(pOutBuf) > (IW_PRIV_SIZE_MASK - 30))
2050 #endif // DOT11_N_SUPPORT //
2053 rt_private_show(struct net_device *dev, struct iw_request_info *info,
2054 struct iw_point *wrq, char *extra)
2057 VIRTUAL_ADAPTER *pVirtualAd = NULL;
2060 u32 subcmd = wrq->flags;
2062 if (dev->priv_flags == INT_MAIN)
2066 pVirtualAd = dev->ml_priv;
2067 pAd = pVirtualAd->RtmpDev->ml_priv;
2069 pObj = (POS_COOKIE) pAd->OS_Cookie;
2073 /* if 1st open fail, pAd will be free;
2074 So the net_dev->ml_priv will be NULL in 2rd open */
2083 memset(extra, 0x00, IW_PRIV_SIZE_MASK);
2086 pObj->ioctl_if_type = INT_MAIN;
2087 pObj->ioctl_if = MAIN_MBSSID;
2093 case SHOW_CONN_STATUS:
2094 if (MONITOR_ON(pAd))
2096 #ifdef DOT11_N_SUPPORT
2097 if (pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED &&
2098 pAd->CommonCfg.RegTransmitSetting.field.BW)
2099 sprintf(extra, "Monitor Mode(CentralChannel %d)\n", pAd->CommonCfg.CentralChannel);
2101 #endif // DOT11_N_SUPPORT //
2102 sprintf(extra, "Monitor Mode(Channel %d)\n", pAd->CommonCfg.Channel);
2106 if (pAd->IndicateMediaState == NdisMediaStateConnected)
2110 sprintf(extra, "Connected(AP: %s[%02X:%02X:%02X:%02X:%02X:%02X])\n",
2111 pAd->CommonCfg.Ssid,
2112 pAd->CommonCfg.Bssid[0],
2113 pAd->CommonCfg.Bssid[1],
2114 pAd->CommonCfg.Bssid[2],
2115 pAd->CommonCfg.Bssid[3],
2116 pAd->CommonCfg.Bssid[4],
2117 pAd->CommonCfg.Bssid[5]);
2118 DBGPRINT(RT_DEBUG_TRACE ,("Ssid=%s ,Ssidlen = %d\n",pAd->CommonCfg.Ssid, pAd->CommonCfg.SsidLen));
2120 else if (ADHOC_ON(pAd))
2121 sprintf(extra, "Connected\n");
2125 sprintf(extra, "Disconnected\n");
2126 DBGPRINT(RT_DEBUG_TRACE ,("ConnStatus is not connected\n"));
2129 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2131 case SHOW_DRVIER_VERION:
2132 sprintf(extra, "Driver version-%s, %s %s\n", STA_DRIVER_VERSION, __DATE__, __TIME__ );
2133 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2135 #ifdef DOT11_N_SUPPORT
2137 getBaInfo(pAd, extra);
2138 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2140 #endif // DOT11_N_SUPPORT //
2141 case SHOW_DESC_INFO:
2143 Show_DescInfo_Proc(pAd, NULL);
2144 wrq->length = 0; // 1: size of '\0'
2148 if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
2150 sprintf(extra, "Scanning\n");
2151 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2154 pAd->StaCfg.bSwRadio = FALSE;
2155 if (pAd->StaCfg.bRadio != (pAd->StaCfg.bHwRadio && pAd->StaCfg.bSwRadio))
2157 pAd->StaCfg.bRadio = (pAd->StaCfg.bHwRadio && pAd->StaCfg.bSwRadio);
2158 if (pAd->StaCfg.bRadio == FALSE)
2161 // Update extra information
2162 pAd->ExtraInfo = SW_RADIO_OFF;
2165 sprintf(extra, "Radio Off\n");
2166 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2169 if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
2171 sprintf(extra, "Scanning\n");
2172 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2175 pAd->StaCfg.bSwRadio = TRUE;
2176 //if (pAd->StaCfg.bRadio != (pAd->StaCfg.bHwRadio && pAd->StaCfg.bSwRadio))
2178 pAd->StaCfg.bRadio = (pAd->StaCfg.bHwRadio && pAd->StaCfg.bSwRadio);
2179 if (pAd->StaCfg.bRadio == TRUE)
2182 // Update extra information
2183 pAd->ExtraInfo = EXTRA_INFO_CLEAR;
2186 sprintf(extra, "Radio On\n");
2187 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2191 #ifdef QOS_DLS_SUPPORT
2192 case SHOW_DLS_ENTRY_INFO:
2194 Set_DlsEntryInfo_Display_Proc(pAd, NULL);
2195 wrq->length = 0; // 1: size of '\0'
2198 #endif // QOS_DLS_SUPPORT //
2200 case SHOW_CFG_VALUE:
2202 Status = RTMPShowCfgValue(pAd, wrq->pointer, extra);
2204 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2207 case SHOW_ADHOC_ENTRY_INFO:
2208 Show_Adhoc_MacTable_Proc(pAd, extra);
2209 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2212 DBGPRINT(RT_DEBUG_TRACE, ("%s - unknow subcmd = %d\n", __func__, subcmd));
2220 int rt_ioctl_siwmlme(struct net_device *dev,
2221 struct iw_request_info *info,
2222 union iwreq_data *wrqu,
2225 PRTMP_ADAPTER pAd = dev->ml_priv;
2226 struct iw_mlme *pMlme = (struct iw_mlme *)wrqu->data.pointer;
2227 MLME_QUEUE_ELEM MsgElem;
2228 MLME_DISASSOC_REQ_STRUCT DisAssocReq;
2229 MLME_DEAUTH_REQ_STRUCT DeAuthReq;
2231 DBGPRINT(RT_DEBUG_TRACE, ("====> %s\n", __func__));
2238 #ifdef IW_MLME_DEAUTH
2239 case IW_MLME_DEAUTH:
2240 DBGPRINT(RT_DEBUG_TRACE, ("====> %s - IW_MLME_DEAUTH\n", __func__));
2241 COPY_MAC_ADDR(DeAuthReq.Addr, pAd->CommonCfg.Bssid);
2242 DeAuthReq.Reason = pMlme->reason_code;
2243 MsgElem.MsgLen = sizeof(MLME_DEAUTH_REQ_STRUCT);
2244 NdisMoveMemory(MsgElem.Msg, &DeAuthReq, sizeof(MLME_DEAUTH_REQ_STRUCT));
2245 MlmeDeauthReqAction(pAd, &MsgElem);
2248 LinkDown(pAd, FALSE);
2249 pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
2252 #endif // IW_MLME_DEAUTH //
2253 #ifdef IW_MLME_DISASSOC
2254 case IW_MLME_DISASSOC:
2255 DBGPRINT(RT_DEBUG_TRACE, ("====> %s - IW_MLME_DISASSOC\n", __func__));
2256 COPY_MAC_ADDR(DisAssocReq.Addr, pAd->CommonCfg.Bssid);
2257 DisAssocReq.Reason = pMlme->reason_code;
2259 MsgElem.Machine = ASSOC_STATE_MACHINE;
2260 MsgElem.MsgType = MT2_MLME_DISASSOC_REQ;
2261 MsgElem.MsgLen = sizeof(MLME_DISASSOC_REQ_STRUCT);
2262 NdisMoveMemory(MsgElem.Msg, &DisAssocReq, sizeof(MLME_DISASSOC_REQ_STRUCT));
2264 pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_OID_DISASSOC;
2265 MlmeDisassocReqAction(pAd, &MsgElem);
2267 #endif // IW_MLME_DISASSOC //
2269 DBGPRINT(RT_DEBUG_TRACE, ("====> %s - Unknow Command\n", __func__));
2275 #endif // SIOCSIWMLME //
2277 #if WIRELESS_EXT > 17
2278 int rt_ioctl_siwauth(struct net_device *dev,
2279 struct iw_request_info *info,
2280 union iwreq_data *wrqu, char *extra)
2282 PRTMP_ADAPTER pAdapter = dev->ml_priv;
2283 struct iw_param *param = &wrqu->param;
2285 //check if the interface is down
2286 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
2288 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
2291 switch (param->flags & IW_AUTH_INDEX) {
2292 case IW_AUTH_WPA_VERSION:
2293 if (param->value == IW_AUTH_WPA_VERSION_WPA)
2295 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPAPSK;
2296 if (pAdapter->StaCfg.BssType == BSS_ADHOC)
2297 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPANone;
2299 else if (param->value == IW_AUTH_WPA_VERSION_WPA2)
2300 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA2PSK;
2302 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_WPA_VERSION - param->value = %d!\n", __func__, param->value));
2304 case IW_AUTH_CIPHER_PAIRWISE:
2305 if (param->value == IW_AUTH_CIPHER_NONE)
2307 pAdapter->StaCfg.WepStatus = Ndis802_11WEPDisabled;
2308 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
2309 pAdapter->StaCfg.PairCipher = Ndis802_11WEPDisabled;
2311 else if (param->value == IW_AUTH_CIPHER_WEP40 ||
2312 param->value == IW_AUTH_CIPHER_WEP104)
2314 pAdapter->StaCfg.WepStatus = Ndis802_11WEPEnabled;
2315 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
2316 pAdapter->StaCfg.PairCipher = Ndis802_11WEPEnabled;
2317 #ifdef WPA_SUPPLICANT_SUPPORT
2318 pAdapter->StaCfg.IEEE8021X = FALSE;
2319 #endif // WPA_SUPPLICANT_SUPPORT //
2321 else if (param->value == IW_AUTH_CIPHER_TKIP)
2323 pAdapter->StaCfg.WepStatus = Ndis802_11Encryption2Enabled;
2324 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
2325 pAdapter->StaCfg.PairCipher = Ndis802_11Encryption2Enabled;
2327 else if (param->value == IW_AUTH_CIPHER_CCMP)
2329 pAdapter->StaCfg.WepStatus = Ndis802_11Encryption3Enabled;
2330 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
2331 pAdapter->StaCfg.PairCipher = Ndis802_11Encryption3Enabled;
2333 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_CIPHER_PAIRWISE - param->value = %d!\n", __func__, param->value));
2335 case IW_AUTH_CIPHER_GROUP:
2336 if (param->value == IW_AUTH_CIPHER_NONE)
2338 pAdapter->StaCfg.GroupCipher = Ndis802_11WEPDisabled;
2340 else if (param->value == IW_AUTH_CIPHER_WEP40 ||
2341 param->value == IW_AUTH_CIPHER_WEP104)
2343 pAdapter->StaCfg.GroupCipher = Ndis802_11WEPEnabled;
2345 else if (param->value == IW_AUTH_CIPHER_TKIP)
2347 pAdapter->StaCfg.GroupCipher = Ndis802_11Encryption2Enabled;
2349 else if (param->value == IW_AUTH_CIPHER_CCMP)
2351 pAdapter->StaCfg.GroupCipher = Ndis802_11Encryption3Enabled;
2353 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_CIPHER_GROUP - param->value = %d!\n", __func__, param->value));
2355 case IW_AUTH_KEY_MGMT:
2356 if (param->value == IW_AUTH_KEY_MGMT_802_1X)
2358 if (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK)
2360 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA;
2361 #ifdef WPA_SUPPLICANT_SUPPORT
2362 pAdapter->StaCfg.IEEE8021X = FALSE;
2363 #endif // WPA_SUPPLICANT_SUPPORT //
2365 else if (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK)
2367 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA2;
2368 #ifdef WPA_SUPPLICANT_SUPPORT
2369 pAdapter->StaCfg.IEEE8021X = FALSE;
2370 #endif // WPA_SUPPLICANT_SUPPORT //
2372 #ifdef WPA_SUPPLICANT_SUPPORT
2375 pAdapter->StaCfg.IEEE8021X = TRUE;
2376 #endif // WPA_SUPPLICANT_SUPPORT //
2378 else if (param->value == 0)
2380 //pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
2381 STA_PORT_SECURED(pAdapter);
2383 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_KEY_MGMT - param->value = %d!\n", __func__, param->value));
2385 case IW_AUTH_RX_UNENCRYPTED_EAPOL:
2387 case IW_AUTH_PRIVACY_INVOKED:
2388 /*if (param->value == 0)
2390 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
2391 pAdapter->StaCfg.WepStatus = Ndis802_11WEPDisabled;
2392 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
2393 pAdapter->StaCfg.PairCipher = Ndis802_11WEPDisabled;
2394 pAdapter->StaCfg.GroupCipher = Ndis802_11WEPDisabled;
2396 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_PRIVACY_INVOKED - param->value = %d!\n", __func__, param->value));
2398 case IW_AUTH_DROP_UNENCRYPTED:
2399 if (param->value != 0)
2400 pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED;
2403 //pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
2404 STA_PORT_SECURED(pAdapter);
2406 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_WPA_VERSION - param->value = %d!\n", __func__, param->value));
2408 case IW_AUTH_80211_AUTH_ALG:
2409 if (param->value & IW_AUTH_ALG_SHARED_KEY)
2411 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeShared;
2413 else if (param->value & IW_AUTH_ALG_OPEN_SYSTEM)
2415 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
2419 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_80211_AUTH_ALG - param->value = %d!\n", __func__, param->value));
2421 case IW_AUTH_WPA_ENABLED:
2422 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_WPA_ENABLED - Driver supports WPA!(param->value = %d)\n", __func__, param->value));
2431 int rt_ioctl_giwauth(struct net_device *dev,
2432 struct iw_request_info *info,
2433 union iwreq_data *wrqu, char *extra)
2435 PRTMP_ADAPTER pAdapter = dev->ml_priv;
2436 struct iw_param *param = &wrqu->param;
2438 //check if the interface is down
2439 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
2441 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
2445 switch (param->flags & IW_AUTH_INDEX) {
2446 case IW_AUTH_DROP_UNENCRYPTED:
2447 param->value = (pAdapter->StaCfg.WepStatus == Ndis802_11WEPDisabled) ? 0 : 1;
2450 case IW_AUTH_80211_AUTH_ALG:
2451 param->value = (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeShared) ? IW_AUTH_ALG_SHARED_KEY : IW_AUTH_ALG_OPEN_SYSTEM;
2454 case IW_AUTH_WPA_ENABLED:
2455 param->value = (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA) ? 1 : 0;
2461 DBGPRINT(RT_DEBUG_TRACE, ("rt_ioctl_giwauth::param->value = %d!\n", param->value));
2465 void fnSetCipherKey(
2466 IN PRTMP_ADAPTER pAdapter,
2470 IN struct iw_encode_ext *ext)
2472 NdisZeroMemory(&pAdapter->SharedKey[BSS0][keyIdx], sizeof(CIPHER_KEY));
2473 pAdapter->SharedKey[BSS0][keyIdx].KeyLen = LEN_TKIP_EK;
2474 NdisMoveMemory(pAdapter->SharedKey[BSS0][keyIdx].Key, ext->key, LEN_TKIP_EK);
2475 NdisMoveMemory(pAdapter->SharedKey[BSS0][keyIdx].TxMic, ext->key + LEN_TKIP_EK, LEN_TKIP_TXMICK);
2476 NdisMoveMemory(pAdapter->SharedKey[BSS0][keyIdx].RxMic, ext->key + LEN_TKIP_EK + LEN_TKIP_TXMICK, LEN_TKIP_RXMICK);
2477 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CipherAlg;
2479 // Update group key information to ASIC Shared Key Table
2480 AsicAddSharedKeyEntry(pAdapter,
2483 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg,
2484 pAdapter->SharedKey[BSS0][keyIdx].Key,
2485 pAdapter->SharedKey[BSS0][keyIdx].TxMic,
2486 pAdapter->SharedKey[BSS0][keyIdx].RxMic);
2489 // Update ASIC WCID attribute table and IVEIV table
2490 RTMPAddWcidAttributeEntry(pAdapter,
2493 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg,
2496 // Update ASIC WCID attribute table and IVEIV table
2497 RTMPAddWcidAttributeEntry(pAdapter,
2500 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg,
2501 &pAdapter->MacTab.Content[BSSID_WCID]);
2504 int rt_ioctl_siwencodeext(struct net_device *dev,
2505 struct iw_request_info *info,
2506 union iwreq_data *wrqu,
2509 PRTMP_ADAPTER pAdapter = dev->ml_priv;
2510 struct iw_point *encoding = &wrqu->encoding;
2511 struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
2512 int keyIdx, alg = ext->alg;
2514 //check if the interface is down
2515 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
2517 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
2521 if (encoding->flags & IW_ENCODE_DISABLED)
2523 keyIdx = (encoding->flags & IW_ENCODE_INDEX) - 1;
2524 // set BSSID wcid entry of the Pair-wise Key table as no-security mode
2525 AsicRemovePairwiseKeyEntry(pAdapter, BSS0, BSSID_WCID);
2526 pAdapter->SharedKey[BSS0][keyIdx].KeyLen = 0;
2527 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CIPHER_NONE;
2528 AsicRemoveSharedKeyEntry(pAdapter, 0, (UCHAR)keyIdx);
2529 NdisZeroMemory(&pAdapter->SharedKey[BSS0][keyIdx], sizeof(CIPHER_KEY));
2530 DBGPRINT(RT_DEBUG_TRACE, ("%s::Remove all keys!(encoding->flags = %x)\n", __func__, encoding->flags));
2534 // Get Key Index and convet to our own defined key index
2535 keyIdx = (encoding->flags & IW_ENCODE_INDEX) - 1;
2536 if((keyIdx < 0) || (keyIdx >= NR_WEP_KEYS))
2539 if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
2541 pAdapter->StaCfg.DefaultKeyId = keyIdx;
2542 DBGPRINT(RT_DEBUG_TRACE, ("%s::DefaultKeyId = %d\n", __func__, pAdapter->StaCfg.DefaultKeyId));
2546 case IW_ENCODE_ALG_NONE:
2547 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_ENCODE_ALG_NONE\n", __func__));
2549 case IW_ENCODE_ALG_WEP:
2550 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_ENCODE_ALG_WEP - ext->key_len = %d, keyIdx = %d\n", __func__, ext->key_len, keyIdx));
2551 if (ext->key_len == MAX_WEP_KEY_SIZE)
2553 pAdapter->SharedKey[BSS0][keyIdx].KeyLen = MAX_WEP_KEY_SIZE;
2554 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CIPHER_WEP128;
2556 else if (ext->key_len == MIN_WEP_KEY_SIZE)
2558 pAdapter->SharedKey[BSS0][keyIdx].KeyLen = MIN_WEP_KEY_SIZE;
2559 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CIPHER_WEP64;
2564 NdisZeroMemory(pAdapter->SharedKey[BSS0][keyIdx].Key, 16);
2565 NdisMoveMemory(pAdapter->SharedKey[BSS0][keyIdx].Key, ext->key, ext->key_len);
2567 if (pAdapter->StaCfg.GroupCipher == Ndis802_11GroupWEP40Enabled ||
2568 pAdapter->StaCfg.GroupCipher == Ndis802_11GroupWEP104Enabled)
2570 // Set Group key material to Asic
2571 AsicAddSharedKeyEntry(pAdapter, BSS0, keyIdx, pAdapter->SharedKey[BSS0][keyIdx].CipherAlg, pAdapter->SharedKey[BSS0][keyIdx].Key, NULL, NULL);
2573 // Update WCID attribute table and IVEIV table for this group key table
2574 RTMPAddWcidAttributeEntry(pAdapter, BSS0, keyIdx, pAdapter->SharedKey[BSS0][keyIdx].CipherAlg, NULL);
2576 STA_PORT_SECURED(pAdapter);
2578 // Indicate Connected for GUI
2579 pAdapter->IndicateMediaState = NdisMediaStateConnected;
2582 case IW_ENCODE_ALG_TKIP:
2583 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_ENCODE_ALG_TKIP - keyIdx = %d, ext->key_len = %d\n", __func__, keyIdx, ext->key_len));
2584 if (ext->key_len == 32)
2586 if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
2588 fnSetCipherKey(pAdapter, keyIdx, CIPHER_TKIP, FALSE, ext);
2589 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA2)
2591 //pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
2592 STA_PORT_SECURED(pAdapter);
2595 else if (ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY)
2597 fnSetCipherKey(pAdapter, keyIdx, CIPHER_TKIP, TRUE, ext);
2599 // set 802.1x port control
2600 //pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
2601 STA_PORT_SECURED(pAdapter);
2607 case IW_ENCODE_ALG_CCMP:
2608 if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
2610 fnSetCipherKey(pAdapter, keyIdx, CIPHER_AES, FALSE, ext);
2611 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA2)
2612 //pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
2613 STA_PORT_SECURED(pAdapter);
2615 else if (ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY)
2617 fnSetCipherKey(pAdapter, keyIdx, CIPHER_AES, TRUE, ext);
2619 // set 802.1x port control
2620 //pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
2621 STA_PORT_SECURED(pAdapter);
2633 rt_ioctl_giwencodeext(struct net_device *dev,
2634 struct iw_request_info *info,
2635 union iwreq_data *wrqu, char *extra)
2637 PRTMP_ADAPTER pAd = dev->ml_priv;
2639 struct iw_point *encoding = &wrqu->encoding;
2640 struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
2641 int idx, max_key_len;
2643 DBGPRINT(RT_DEBUG_TRACE ,("===> rt_ioctl_giwencodeext\n"));
2645 max_key_len = encoding->length - sizeof(*ext);
2646 if (max_key_len < 0)
2649 idx = encoding->flags & IW_ENCODE_INDEX;
2652 if (idx < 1 || idx > 4)
2656 if ((pAd->StaCfg.WepStatus == Ndis802_11Encryption2Enabled) ||
2657 (pAd->StaCfg.WepStatus == Ndis802_11Encryption3Enabled))
2659 if (idx != pAd->StaCfg.DefaultKeyId)
2667 idx = pAd->StaCfg.DefaultKeyId;
2669 encoding->flags = idx + 1;
2670 memset(ext, 0, sizeof(*ext));
2673 switch(pAd->StaCfg.WepStatus) {
2674 case Ndis802_11WEPDisabled:
2675 ext->alg = IW_ENCODE_ALG_NONE;
2676 encoding->flags |= IW_ENCODE_DISABLED;
2678 case Ndis802_11WEPEnabled:
2679 ext->alg = IW_ENCODE_ALG_WEP;
2680 if (pAd->SharedKey[BSS0][idx].KeyLen > max_key_len)
2684 ext->key_len = pAd->SharedKey[BSS0][idx].KeyLen;
2685 pKey = &(pAd->SharedKey[BSS0][idx].Key[0]);
2688 case Ndis802_11Encryption2Enabled:
2689 case Ndis802_11Encryption3Enabled:
2690 if (pAd->StaCfg.WepStatus == Ndis802_11Encryption2Enabled)
2691 ext->alg = IW_ENCODE_ALG_TKIP;
2693 ext->alg = IW_ENCODE_ALG_CCMP;
2695 if (max_key_len < 32)
2700 pKey = &pAd->StaCfg.PMK[0];
2707 if (ext->key_len && pKey)
2709 encoding->flags |= IW_ENCODE_ENABLED;
2710 memcpy(ext->key, pKey, ext->key_len);
2717 int rt_ioctl_siwgenie(struct net_device *dev,
2718 struct iw_request_info *info,
2719 union iwreq_data *wrqu, char *extra)
2721 PRTMP_ADAPTER pAd = dev->ml_priv;
2723 if (wrqu->data.length > MAX_LEN_OF_RSNIE ||
2724 (wrqu->data.length && extra == NULL))
2727 if (wrqu->data.length)
2729 pAd->StaCfg.RSNIE_Len = wrqu->data.length;
2730 NdisMoveMemory(&pAd->StaCfg.RSN_IE[0], extra, pAd->StaCfg.RSNIE_Len);
2734 pAd->StaCfg.RSNIE_Len = 0;
2735 NdisZeroMemory(&pAd->StaCfg.RSN_IE[0], MAX_LEN_OF_RSNIE);
2740 #endif // SIOCSIWGENIE //
2742 int rt_ioctl_giwgenie(struct net_device *dev,
2743 struct iw_request_info *info,
2744 union iwreq_data *wrqu, char *extra)
2746 PRTMP_ADAPTER pAd = dev->ml_priv;
2748 if ((pAd->StaCfg.RSNIE_Len == 0) ||
2749 (pAd->StaCfg.AuthMode < Ndis802_11AuthModeWPA))
2751 wrqu->data.length = 0;
2755 #ifdef NATIVE_WPA_SUPPLICANT_SUPPORT
2757 if (pAd->StaCfg.WpaSupplicantUP == WPA_SUPPLICANT_ENABLE)
2759 if (wrqu->data.length < pAd->StaCfg.RSNIE_Len)
2762 wrqu->data.length = pAd->StaCfg.RSNIE_Len;
2763 memcpy(extra, &pAd->StaCfg.RSN_IE[0], pAd->StaCfg.RSNIE_Len);
2766 #endif // SIOCSIWGENIE //
2767 #endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
2769 UCHAR RSNIe = IE_WPA;
2771 if (wrqu->data.length < (pAd->StaCfg.RSNIE_Len + 2)) // ID, Len
2773 wrqu->data.length = pAd->StaCfg.RSNIE_Len + 2;
2775 if ((pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK) ||
2776 (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2))
2779 extra[0] = (char)RSNIe;
2780 extra[1] = pAd->StaCfg.RSNIE_Len;
2781 memcpy(extra+2, &pAd->StaCfg.RSN_IE[0], pAd->StaCfg.RSNIE_Len);
2787 int rt_ioctl_siwpmksa(struct net_device *dev,
2788 struct iw_request_info *info,
2789 union iwreq_data *wrqu,
2792 PRTMP_ADAPTER pAd = dev->ml_priv;
2793 struct iw_pmksa *pPmksa = (struct iw_pmksa *)wrqu->data.pointer;
2794 INT CachedIdx = 0, idx = 0;
2799 DBGPRINT(RT_DEBUG_TRACE ,("===> rt_ioctl_siwpmksa\n"));
2802 case IW_PMKSA_FLUSH:
2803 NdisZeroMemory(pAd->StaCfg.SavedPMK, sizeof(BSSID_INFO)*PMKID_NO);
2804 DBGPRINT(RT_DEBUG_TRACE ,("rt_ioctl_siwpmksa - IW_PMKSA_FLUSH\n"));
2806 case IW_PMKSA_REMOVE:
2807 for (CachedIdx = 0; CachedIdx < pAd->StaCfg.SavedPMKNum; CachedIdx++)
2809 // compare the BSSID
2810 if (NdisEqualMemory(pPmksa->bssid.sa_data, pAd->StaCfg.SavedPMK[CachedIdx].BSSID, MAC_ADDR_LEN))
2812 NdisZeroMemory(pAd->StaCfg.SavedPMK[CachedIdx].BSSID, MAC_ADDR_LEN);
2813 NdisZeroMemory(pAd->StaCfg.SavedPMK[CachedIdx].PMKID, 16);
2814 for (idx = CachedIdx; idx < (pAd->StaCfg.SavedPMKNum - 1); idx++)
2816 NdisMoveMemory(&pAd->StaCfg.SavedPMK[idx].BSSID[0], &pAd->StaCfg.SavedPMK[idx+1].BSSID[0], MAC_ADDR_LEN);
2817 NdisMoveMemory(&pAd->StaCfg.SavedPMK[idx].PMKID[0], &pAd->StaCfg.SavedPMK[idx+1].PMKID[0], 16);
2819 pAd->StaCfg.SavedPMKNum--;
2824 DBGPRINT(RT_DEBUG_TRACE ,("rt_ioctl_siwpmksa - IW_PMKSA_REMOVE\n"));
2827 for (CachedIdx = 0; CachedIdx < pAd->StaCfg.SavedPMKNum; CachedIdx++)
2829 // compare the BSSID
2830 if (NdisEqualMemory(pPmksa->bssid.sa_data, pAd->StaCfg.SavedPMK[CachedIdx].BSSID, MAC_ADDR_LEN))
2834 // Found, replace it
2835 if (CachedIdx < PMKID_NO)
2837 DBGPRINT(RT_DEBUG_OFF, ("Update PMKID, idx = %d\n", CachedIdx));
2838 NdisMoveMemory(&pAd->StaCfg.SavedPMK[CachedIdx].BSSID[0], pPmksa->bssid.sa_data, MAC_ADDR_LEN);
2839 NdisMoveMemory(&pAd->StaCfg.SavedPMK[CachedIdx].PMKID[0], pPmksa->pmkid, 16);
2840 pAd->StaCfg.SavedPMKNum++;
2842 // Not found, replace the last one
2845 // Randomly replace one
2846 CachedIdx = (pPmksa->bssid.sa_data[5] % PMKID_NO);
2847 DBGPRINT(RT_DEBUG_OFF, ("Update PMKID, idx = %d\n", CachedIdx));
2848 NdisMoveMemory(&pAd->StaCfg.SavedPMK[CachedIdx].BSSID[0], pPmksa->bssid.sa_data, MAC_ADDR_LEN);
2849 NdisMoveMemory(&pAd->StaCfg.SavedPMK[CachedIdx].PMKID[0], pPmksa->pmkid, 16);
2852 DBGPRINT(RT_DEBUG_TRACE ,("rt_ioctl_siwpmksa - IW_PMKSA_ADD\n"));
2855 DBGPRINT(RT_DEBUG_TRACE ,("rt_ioctl_siwpmksa - Unknow Command!!\n"));
2861 #endif // #if WIRELESS_EXT > 17
2865 rt_private_ioctl_bbp(struct net_device *dev, struct iw_request_info *info,
2866 struct iw_point *wrq, char *extra)
2871 // CHAR arg[255]={0};
2874 BOOLEAN bIsPrintAllBBP = FALSE;
2876 PRTMP_ADAPTER pAdapter = dev->ml_priv;
2879 memset(extra, 0x00, IW_PRIV_SIZE_MASK);
2881 if (wrq->length > 1) //No parameters.
2883 sprintf(extra, "\n");
2885 //Parsing Read or Write
2886 this_char = wrq->pointer;
2887 DBGPRINT(RT_DEBUG_TRACE, ("this_char=%s\n", this_char));
2891 if ((value = rtstrchr(this_char, '=')) != NULL)
2894 if (!value || !*value)
2896 DBGPRINT(RT_DEBUG_TRACE, ("this_char=%s, value=%s\n", this_char, value));
2897 if (sscanf(this_char, "%d", &(bbpId)) == 1)
2902 if (ATE_ON(pAdapter))
2904 ATE_BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, ®BBP);
2907 #endif // RALINK_ATE //
2909 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, ®BBP);
2911 sprintf(extra+strlen(extra), "R%02d[0x%02X]:%02X\n", bbpId, bbpId*2, regBBP);
2912 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2913 DBGPRINT(RT_DEBUG_TRACE, ("msg=%s\n", extra));
2916 {//Invalid parametes, so default printk all bbp
2917 bIsPrintAllBBP = TRUE;
2922 { //Invalid parametes, so default printk all bbp
2923 bIsPrintAllBBP = TRUE;
2929 if ((sscanf(this_char, "%d", &(bbpId)) == 1) && (sscanf(value, "%x", &(bbpValue)) == 1))
2934 if (ATE_ON(pAdapter))
2936 ATE_BBP_IO_WRITE8_BY_REG_ID(pAdapter, bbpId, bbpValue);
2937 //Read it back for showing
2938 ATE_BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, ®BBP);
2941 #endif // RALINK_ATE //
2943 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, bbpId, bbpValue);
2944 //Read it back for showing
2945 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, ®BBP);
2947 sprintf(extra+strlen(extra), "R%02d[0x%02X]:%02X\n", bbpId, bbpId*2, regBBP);
2948 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2949 DBGPRINT(RT_DEBUG_TRACE, ("msg=%s\n", extra));
2952 {//Invalid parametes, so default printk all bbp
2953 bIsPrintAllBBP = TRUE;
2958 { //Invalid parametes, so default printk all bbp
2959 bIsPrintAllBBP = TRUE;
2965 bIsPrintAllBBP = TRUE;
2970 memset(extra, 0x00, IW_PRIV_SIZE_MASK);
2971 sprintf(extra, "\n");
2972 for (bbpId = 0; bbpId <= 136; bbpId++)
2974 if (strlen(extra) >= (IW_PRIV_SIZE_MASK - 10))
2977 if (ATE_ON(pAdapter))
2979 ATE_BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, ®BBP);
2982 #endif // RALINK_ATE //
2983 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, ®BBP);
2984 sprintf(extra+strlen(extra), "R%02d[0x%02X]:%02X ", bbpId, bbpId*2, regBBP);
2986 sprintf(extra+strlen(extra), "\n");
2989 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2990 DBGPRINT(RT_DEBUG_TRACE, ("wrq->length = %d\n", wrq->length));
2993 DBGPRINT(RT_DEBUG_TRACE, ("<==rt_private_ioctl_bbp\n\n"));
2999 int rt_ioctl_siwrate(struct net_device *dev,
3000 struct iw_request_info *info,
3001 union iwreq_data *wrqu, char *extra)
3003 PRTMP_ADAPTER pAd = dev->ml_priv;
3004 UINT32 rate = wrqu->bitrate.value, fixed = wrqu->bitrate.fixed;
3006 //check if the interface is down
3007 if(!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_IN_USE))
3009 DBGPRINT(RT_DEBUG_TRACE, ("rt_ioctl_siwrate::Network is down!\n"));
3013 DBGPRINT(RT_DEBUG_TRACE, ("rt_ioctl_siwrate::(rate = %d, fixed = %d)\n", rate, fixed));
3014 /* rate = -1 => auto rate
3015 rate = X, fixed = 1 => (fixed rate X)
3020 pAd->StaCfg.DesiredTransmitSetting.field.MCS = MCS_AUTO;
3021 pAd->StaCfg.bAutoTxRateSwitch = TRUE;
3022 if ((pAd->CommonCfg.PhyMode <= PHY_11G) ||
3023 (pAd->MacTab.Content[BSSID_WCID].HTPhyMode.field.MODE <= MODE_OFDM))
3024 RTMPSetDesiredRates(pAd, -1);
3026 #ifdef DOT11_N_SUPPORT
3028 #endif // DOT11_N_SUPPORT //
3034 pAd->StaCfg.bAutoTxRateSwitch = FALSE;
3035 if ((pAd->CommonCfg.PhyMode <= PHY_11G) ||
3036 (pAd->MacTab.Content[BSSID_WCID].HTPhyMode.field.MODE <= MODE_OFDM))
3037 RTMPSetDesiredRates(pAd, rate);
3040 pAd->StaCfg.DesiredTransmitSetting.field.MCS = MCS_AUTO;
3041 #ifdef DOT11_N_SUPPORT
3043 #endif // DOT11_N_SUPPORT //
3045 DBGPRINT(RT_DEBUG_TRACE, ("rt_ioctl_siwrate::(HtMcs=%d)\n",pAd->StaCfg.DesiredTransmitSetting.field.MCS));
3049 // TODO: rate = X, fixed = 0 => (rates <= X)
3057 int rt_ioctl_giwrate(struct net_device *dev,
3058 struct iw_request_info *info,
3059 union iwreq_data *wrqu, char *extra)
3061 PRTMP_ADAPTER pAd = dev->ml_priv;
3062 int rate_index = 0, rate_count = 0;
3063 HTTRANSMIT_SETTING ht_setting;
3064 __s32 ralinkrate[] =
3065 {2, 4, 11, 22, // CCK
3066 12, 18, 24, 36, 48, 72, 96, 108, // OFDM
3067 13, 26, 39, 52, 78, 104, 117, 130, 26, 52, 78, 104, 156, 208, 234, 260, // 20MHz, 800ns GI, MCS: 0 ~ 15
3068 39, 78, 117, 156, 234, 312, 351, 390, // 20MHz, 800ns GI, MCS: 16 ~ 23
3069 27, 54, 81, 108, 162, 216, 243, 270, 54, 108, 162, 216, 324, 432, 486, 540, // 40MHz, 800ns GI, MCS: 0 ~ 15
3070 81, 162, 243, 324, 486, 648, 729, 810, // 40MHz, 800ns GI, MCS: 16 ~ 23
3071 14, 29, 43, 57, 87, 115, 130, 144, 29, 59, 87, 115, 173, 230, 260, 288, // 20MHz, 400ns GI, MCS: 0 ~ 15
3072 43, 87, 130, 173, 260, 317, 390, 433, // 20MHz, 400ns GI, MCS: 16 ~ 23
3073 30, 60, 90, 120, 180, 240, 270, 300, 60, 120, 180, 240, 360, 480, 540, 600, // 40MHz, 400ns GI, MCS: 0 ~ 15
3074 90, 180, 270, 360, 540, 720, 810, 900}; // 40MHz, 400ns GI, MCS: 16 ~ 23
3076 rate_count = sizeof(ralinkrate)/sizeof(__s32);
3077 //check if the interface is down
3078 if(!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_IN_USE))
3080 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
3084 if ((pAd->StaCfg.bAutoTxRateSwitch == FALSE) &&
3086 ((pAd->CommonCfg.PhyMode <= PHY_11G) || (pAd->MacTab.Content[BSSID_WCID].HTPhyMode.field.MODE <= MODE_OFDM)))
3087 ht_setting.word = pAd->StaCfg.HTPhyMode.word;
3089 ht_setting.word = pAd->MacTab.Content[BSSID_WCID].HTPhyMode.word;
3091 #ifdef DOT11_N_SUPPORT
3092 if (ht_setting.field.MODE >= MODE_HTMIX)
3094 // rate_index = 12 + ((UCHAR)ht_setting.field.BW *16) + ((UCHAR)ht_setting.field.ShortGI *32) + ((UCHAR)ht_setting.field.MCS);
3095 rate_index = 12 + ((UCHAR)ht_setting.field.BW *24) + ((UCHAR)ht_setting.field.ShortGI *48) + ((UCHAR)ht_setting.field.MCS);
3098 #endif // DOT11_N_SUPPORT //
3099 if (ht_setting.field.MODE == MODE_OFDM)
3100 rate_index = (UCHAR)(ht_setting.field.MCS) + 4;
3101 else if (ht_setting.field.MODE == MODE_CCK)
3102 rate_index = (UCHAR)(ht_setting.field.MCS);
3107 if (rate_index > rate_count)
3108 rate_index = rate_count;
3110 wrqu->bitrate.value = ralinkrate[rate_index] * 500000;
3111 wrqu->bitrate.disabled = 0;
3116 static const iw_handler rt_handler[] =
3118 (iw_handler) NULL, /* SIOCSIWCOMMIT */
3119 (iw_handler) rt_ioctl_giwname, /* SIOCGIWNAME */
3120 (iw_handler) NULL, /* SIOCSIWNWID */
3121 (iw_handler) NULL, /* SIOCGIWNWID */
3122 (iw_handler) rt_ioctl_siwfreq, /* SIOCSIWFREQ */
3123 (iw_handler) rt_ioctl_giwfreq, /* SIOCGIWFREQ */
3124 (iw_handler) rt_ioctl_siwmode, /* SIOCSIWMODE */
3125 (iw_handler) rt_ioctl_giwmode, /* SIOCGIWMODE */
3126 (iw_handler) NULL, /* SIOCSIWSENS */
3127 (iw_handler) NULL, /* SIOCGIWSENS */
3128 (iw_handler) NULL /* not used */, /* SIOCSIWRANGE */
3129 (iw_handler) rt_ioctl_giwrange, /* SIOCGIWRANGE */
3130 (iw_handler) NULL /* not used */, /* SIOCSIWPRIV */
3131 (iw_handler) NULL /* kernel code */, /* SIOCGIWPRIV */
3132 (iw_handler) NULL /* not used */, /* SIOCSIWSTATS */
3133 (iw_handler) rt28xx_get_wireless_stats /* kernel code */, /* SIOCGIWSTATS */
3134 (iw_handler) NULL, /* SIOCSIWSPY */
3135 (iw_handler) NULL, /* SIOCGIWSPY */
3136 (iw_handler) NULL, /* SIOCSIWTHRSPY */
3137 (iw_handler) NULL, /* SIOCGIWTHRSPY */
3138 (iw_handler) rt_ioctl_siwap, /* SIOCSIWAP */
3139 (iw_handler) rt_ioctl_giwap, /* SIOCGIWAP */
3141 (iw_handler) rt_ioctl_siwmlme, /* SIOCSIWMLME */
3143 (iw_handler) NULL, /* SIOCSIWMLME */
3144 #endif // SIOCSIWMLME //
3145 (iw_handler) rt_ioctl_iwaplist, /* SIOCGIWAPLIST */
3147 (iw_handler) rt_ioctl_siwscan, /* SIOCSIWSCAN */
3148 (iw_handler) rt_ioctl_giwscan, /* SIOCGIWSCAN */
3150 (iw_handler) NULL, /* SIOCSIWSCAN */
3151 (iw_handler) NULL, /* SIOCGIWSCAN */
3152 #endif /* SIOCGIWSCAN */
3153 (iw_handler) rt_ioctl_siwessid, /* SIOCSIWESSID */
3154 (iw_handler) rt_ioctl_giwessid, /* SIOCGIWESSID */
3155 (iw_handler) rt_ioctl_siwnickn, /* SIOCSIWNICKN */
3156 (iw_handler) rt_ioctl_giwnickn, /* SIOCGIWNICKN */
3157 (iw_handler) NULL, /* -- hole -- */
3158 (iw_handler) NULL, /* -- hole -- */
3159 (iw_handler) rt_ioctl_siwrate, /* SIOCSIWRATE */
3160 (iw_handler) rt_ioctl_giwrate, /* SIOCGIWRATE */
3161 (iw_handler) rt_ioctl_siwrts, /* SIOCSIWRTS */
3162 (iw_handler) rt_ioctl_giwrts, /* SIOCGIWRTS */
3163 (iw_handler) rt_ioctl_siwfrag, /* SIOCSIWFRAG */
3164 (iw_handler) rt_ioctl_giwfrag, /* SIOCGIWFRAG */
3165 (iw_handler) NULL, /* SIOCSIWTXPOW */
3166 (iw_handler) NULL, /* SIOCGIWTXPOW */
3167 (iw_handler) NULL, /* SIOCSIWRETRY */
3168 (iw_handler) NULL, /* SIOCGIWRETRY */
3169 (iw_handler) rt_ioctl_siwencode, /* SIOCSIWENCODE */
3170 (iw_handler) rt_ioctl_giwencode, /* SIOCGIWENCODE */
3171 (iw_handler) NULL, /* SIOCSIWPOWER */
3172 (iw_handler) NULL, /* SIOCGIWPOWER */
3173 (iw_handler) NULL, /* -- hole -- */
3174 (iw_handler) NULL, /* -- hole -- */
3175 #if WIRELESS_EXT > 17
3176 (iw_handler) rt_ioctl_siwgenie, /* SIOCSIWGENIE */
3177 (iw_handler) rt_ioctl_giwgenie, /* SIOCGIWGENIE */
3178 (iw_handler) rt_ioctl_siwauth, /* SIOCSIWAUTH */
3179 (iw_handler) rt_ioctl_giwauth, /* SIOCGIWAUTH */
3180 (iw_handler) rt_ioctl_siwencodeext, /* SIOCSIWENCODEEXT */
3181 (iw_handler) rt_ioctl_giwencodeext, /* SIOCGIWENCODEEXT */
3182 (iw_handler) rt_ioctl_siwpmksa, /* SIOCSIWPMKSA */
3186 static const iw_handler rt_priv_handlers[] = {
3187 (iw_handler) NULL, /* + 0x00 */
3188 (iw_handler) NULL, /* + 0x01 */
3189 #ifndef CONFIG_AP_SUPPORT
3190 (iw_handler) rt_ioctl_setparam, /* + 0x02 */
3192 (iw_handler) NULL, /* + 0x02 */
3193 #endif // CONFIG_AP_SUPPORT //
3195 (iw_handler) rt_private_ioctl_bbp, /* + 0x03 */
3197 (iw_handler) NULL, /* + 0x03 */
3199 (iw_handler) NULL, /* + 0x04 */
3200 (iw_handler) NULL, /* + 0x05 */
3201 (iw_handler) NULL, /* + 0x06 */
3202 (iw_handler) NULL, /* + 0x07 */
3203 (iw_handler) NULL, /* + 0x08 */
3204 (iw_handler) rt_private_get_statistics, /* + 0x09 */
3205 (iw_handler) NULL, /* + 0x0A */
3206 (iw_handler) NULL, /* + 0x0B */
3207 (iw_handler) NULL, /* + 0x0C */
3208 (iw_handler) NULL, /* + 0x0D */
3209 (iw_handler) NULL, /* + 0x0E */
3210 (iw_handler) NULL, /* + 0x0F */
3211 (iw_handler) NULL, /* + 0x10 */
3212 (iw_handler) rt_private_show, /* + 0x11 */
3213 (iw_handler) NULL, /* + 0x12 */
3214 (iw_handler) NULL, /* + 0x13 */
3215 (iw_handler) NULL, /* + 0x15 */
3216 (iw_handler) NULL, /* + 0x17 */
3217 (iw_handler) NULL, /* + 0x18 */
3220 const struct iw_handler_def rt28xx_iw_handler_def =
3222 #define N(a) (sizeof (a) / sizeof (a[0]))
3223 .standard = (iw_handler *) rt_handler,
3224 .num_standard = sizeof(rt_handler) / sizeof(iw_handler),
3225 .private = (iw_handler *) rt_priv_handlers,
3226 .num_private = N(rt_priv_handlers),
3227 .private_args = (struct iw_priv_args *) privtab,
3228 .num_private_args = N(privtab),
3229 #if IW_HANDLER_VERSION >= 7
3230 .get_wireless_stats = rt28xx_get_wireless_stats,
3234 INT RTMPSetInformation(
3235 IN PRTMP_ADAPTER pAdapter,
3236 IN OUT struct ifreq *rq,
3239 struct iwreq *wrq = (struct iwreq *) rq;
3240 NDIS_802_11_SSID Ssid;
3241 NDIS_802_11_MAC_ADDRESS Bssid;
3242 RT_802_11_PHY_MODE PhyMode;
3243 RT_802_11_STA_CONFIG StaConfig;
3244 NDIS_802_11_RATES aryRates;
3245 RT_802_11_PREAMBLE Preamble;
3246 NDIS_802_11_WEP_STATUS WepStatus;
3247 NDIS_802_11_AUTHENTICATION_MODE AuthMode = Ndis802_11AuthModeMax;
3248 NDIS_802_11_NETWORK_INFRASTRUCTURE BssType;
3249 NDIS_802_11_RTS_THRESHOLD RtsThresh;
3250 NDIS_802_11_FRAGMENTATION_THRESHOLD FragThresh;
3251 NDIS_802_11_POWER_MODE PowerMode;
3252 PNDIS_802_11_KEY pKey = NULL;
3253 PNDIS_802_11_WEP pWepKey =NULL;
3254 PNDIS_802_11_REMOVE_KEY pRemoveKey = NULL;
3255 NDIS_802_11_CONFIGURATION Config, *pConfig = NULL;
3256 NDIS_802_11_NETWORK_TYPE NetType;
3259 INT Status = NDIS_STATUS_SUCCESS, MaxPhyMode = PHY_11G;
3262 BOOLEAN StateMachineTouched = FALSE;
3263 #ifdef DOT11_N_SUPPORT
3264 OID_SET_HT_PHYMODE HT_PhyMode; //11n ,kathy
3265 #endif // DOT11_N_SUPPORT //
3266 #ifdef WPA_SUPPLICANT_SUPPORT
3267 PNDIS_802_11_PMKID pPmkId = NULL;
3268 BOOLEAN IEEE8021xState = FALSE;
3269 BOOLEAN IEEE8021x_required_keys = FALSE;
3270 UCHAR wpa_supplicant_enable = 0;
3271 #endif // WPA_SUPPLICANT_SUPPORT //
3274 TX_RTY_CFG_STRUC tx_rty_cfg;
3275 ULONG ShortRetryLimit, LongRetryLimit;
3277 #endif // SNMP_SUPPORT //
3281 #ifdef DOT11_N_SUPPORT
3282 MaxPhyMode = PHY_11N_5G;
3283 #endif // DOT11_N_SUPPORT //
3286 DBGPRINT(RT_DEBUG_TRACE, ("-->RTMPSetInformation(), 0x%08x\n", cmd&0x7FFF));
3287 switch(cmd & 0x7FFF) {
3288 case RT_OID_802_11_COUNTRY_REGION:
3289 if (wrq->u.data.length < sizeof(UCHAR))
3291 // Only avaliable when EEPROM not programming
3292 else if (!(pAdapter->CommonCfg.CountryRegion & 0x80) && !(pAdapter->CommonCfg.CountryRegionForABand & 0x80))
3297 Status = copy_from_user(&Country, wrq->u.data.pointer, wrq->u.data.length);
3298 pAdapter->CommonCfg.CountryRegion = (UCHAR)(Country & 0x000000FF);
3299 pAdapter->CommonCfg.CountryRegionForABand = (UCHAR)((Country >> 8) & 0x000000FF);
3300 TmpPhy = pAdapter->CommonCfg.PhyMode;
3301 pAdapter->CommonCfg.PhyMode = 0xff;
3302 // Build all corresponding channel information
3303 RTMPSetPhyMode(pAdapter, TmpPhy);
3304 #ifdef DOT11_N_SUPPORT
3305 SetCommonHT(pAdapter);
3306 #endif // DOT11_N_SUPPORT //
3307 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_COUNTRY_REGION (A:%d B/G:%d)\n", pAdapter->CommonCfg.CountryRegionForABand,
3308 pAdapter->CommonCfg.CountryRegion));
3311 case OID_802_11_BSSID_LIST_SCAN:
3313 if (ATE_ON(pAdapter))
3315 DBGPRINT(RT_DEBUG_TRACE, ("The driver is in ATE mode now\n"));
3318 #endif // RALINK_ATE //
3320 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_BSSID_LIST_SCAN, TxCnt = %d \n", pAdapter->RalinkCounters.LastOneSecTotalTxCount));
3322 if (MONITOR_ON(pAdapter))
3324 DBGPRINT(RT_DEBUG_TRACE, ("!!! Driver is in Monitor Mode now !!!\n"));
3328 //Benson add 20080527, when radio off, sta don't need to scan
3329 if (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_RADIO_OFF))
3332 if (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
3334 DBGPRINT(RT_DEBUG_TRACE, ("!!! Driver is scanning now !!!\n"));
3335 pAdapter->StaCfg.bScanReqIsFromWebUI = TRUE;
3336 Status = NDIS_STATUS_SUCCESS;
3340 if (pAdapter->RalinkCounters.LastOneSecTotalTxCount > 100)
3342 DBGPRINT(RT_DEBUG_TRACE, ("!!! Link UP, ignore this set::OID_802_11_BSSID_LIST_SCAN\n"));
3343 Status = NDIS_STATUS_SUCCESS;
3344 pAdapter->StaCfg.ScanCnt = 99; // Prevent auto scan triggered by this OID
3348 if ((OPSTATUS_TEST_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED)) &&
3349 ((pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA) ||
3350 (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK) ||
3351 (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA2) ||
3352 (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK)) &&
3353 (pAdapter->StaCfg.PortSecured == WPA_802_1X_PORT_NOT_SECURED))
3355 DBGPRINT(RT_DEBUG_TRACE, ("!!! Link UP, Port Not Secured! ignore this set::OID_802_11_BSSID_LIST_SCAN\n"));
3356 Status = NDIS_STATUS_SUCCESS;
3357 pAdapter->StaCfg.ScanCnt = 99; // Prevent auto scan triggered by this OID
3362 if (pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE)
3364 RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
3365 DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
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;
3371 // Reset allowed scan retries
3372 pAdapter->StaCfg.ScanCnt = 0;
3373 pAdapter->StaCfg.LastScanTime = Now;
3375 pAdapter->StaCfg.bScanReqIsFromWebUI = TRUE;
3376 RTMP_SET_FLAG(pAdapter, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS);
3377 MlmeEnqueue(pAdapter,
3378 MLME_CNTL_STATE_MACHINE,
3379 OID_802_11_BSSID_LIST_SCAN,
3383 Status = NDIS_STATUS_SUCCESS;
3384 StateMachineTouched = TRUE;
3386 case OID_802_11_SSID:
3387 if (wrq->u.data.length != sizeof(NDIS_802_11_SSID))
3391 PCHAR pSsidString = NULL;
3392 Status = copy_from_user(&Ssid, wrq->u.data.pointer, wrq->u.data.length);
3394 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_SSID (Len=%d,Ssid=%s)\n", Ssid.SsidLength, Ssid.Ssid));
3395 if (Ssid.SsidLength > MAX_LEN_OF_SSID)
3399 if (Ssid.SsidLength == 0)
3401 Set_SSID_Proc(pAdapter, "");
3405 pSsidString = (CHAR *) kmalloc(MAX_LEN_OF_SSID+1, MEM_ALLOC_FLAG);
3408 NdisZeroMemory(pSsidString, MAX_LEN_OF_SSID+1);
3409 NdisMoveMemory(pSsidString, Ssid.Ssid, Ssid.SsidLength);
3410 Set_SSID_Proc(pAdapter, pSsidString);
3419 case OID_802_11_BSSID:
3421 if (ATE_ON(pAdapter))
3423 DBGPRINT(RT_DEBUG_TRACE, ("The driver is in ATE mode now\n"));
3426 #endif // RALINK_ATE //
3427 if (wrq->u.data.length != sizeof(NDIS_802_11_MAC_ADDRESS))
3431 Status = copy_from_user(&Bssid, wrq->u.data.pointer, wrq->u.data.length);
3433 // tell CNTL state machine to call NdisMSetInformationComplete() after completing
3434 // this request, because this request is initiated by NDIS.
3435 pAdapter->MlmeAux.CurrReqIsFromNdis = FALSE;
3437 // Prevent to connect AP again in STAMlmePeriodicExec
3438 pAdapter->MlmeAux.AutoReconnectSsidLen= 32;
3440 // Reset allowed scan retries
3441 pAdapter->StaCfg.ScanCnt = 0;
3443 if (pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE)
3445 RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
3446 DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
3448 MlmeEnqueue(pAdapter,
3449 MLME_CNTL_STATE_MACHINE,
3451 sizeof(NDIS_802_11_MAC_ADDRESS),
3453 Status = NDIS_STATUS_SUCCESS;
3454 StateMachineTouched = TRUE;
3456 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_BSSID %02x:%02x:%02x:%02x:%02x:%02x\n",
3457 Bssid[0], Bssid[1], Bssid[2], Bssid[3], Bssid[4], Bssid[5]));
3460 case RT_OID_802_11_RADIO:
3461 if (wrq->u.data.length != sizeof(BOOLEAN))
3465 Status = copy_from_user(&RadioState, wrq->u.data.pointer, wrq->u.data.length);
3466 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_RADIO (=%d)\n", RadioState));
3467 if (pAdapter->StaCfg.bSwRadio != RadioState)
3469 pAdapter->StaCfg.bSwRadio = RadioState;
3470 if (pAdapter->StaCfg.bRadio != (pAdapter->StaCfg.bHwRadio && pAdapter->StaCfg.bSwRadio))
3472 pAdapter->StaCfg.bRadio = (pAdapter->StaCfg.bHwRadio && pAdapter->StaCfg.bSwRadio);
3473 if (pAdapter->StaCfg.bRadio == TRUE)
3475 MlmeRadioOn(pAdapter);
3476 // Update extra information
3477 pAdapter->ExtraInfo = EXTRA_INFO_CLEAR;
3481 MlmeRadioOff(pAdapter);
3482 // Update extra information
3483 pAdapter->ExtraInfo = SW_RADIO_OFF;
3489 case RT_OID_802_11_PHY_MODE:
3490 if (wrq->u.data.length != sizeof(RT_802_11_PHY_MODE))
3494 Status = copy_from_user(&PhyMode, wrq->u.data.pointer, wrq->u.data.length);
3495 if (PhyMode <= MaxPhyMode)
3497 RTMPSetPhyMode(pAdapter, PhyMode);
3498 #ifdef DOT11_N_SUPPORT
3499 SetCommonHT(pAdapter);
3500 #endif // DOT11_N_SUPPORT //
3502 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_PHY_MODE (=%d)\n", PhyMode));
3505 case RT_OID_802_11_STA_CONFIG:
3506 if (wrq->u.data.length != sizeof(RT_802_11_STA_CONFIG))
3510 Status = copy_from_user(&StaConfig, wrq->u.data.pointer, wrq->u.data.length);
3511 pAdapter->CommonCfg.bEnableTxBurst = StaConfig.EnableTxBurst;
3512 pAdapter->CommonCfg.UseBGProtection = StaConfig.UseBGProtection;
3513 pAdapter->CommonCfg.bUseShortSlotTime = 1; // 2003-10-30 always SHORT SLOT capable
3514 if ((pAdapter->CommonCfg.PhyMode != StaConfig.AdhocMode) &&
3515 (StaConfig.AdhocMode <= MaxPhyMode))
3517 // allow dynamic change of "USE OFDM rate or not" in ADHOC mode
3518 // if setting changed, need to reset current TX rate as well as BEACON frame format
3519 if (pAdapter->StaCfg.BssType == BSS_ADHOC)
3521 pAdapter->CommonCfg.PhyMode = StaConfig.AdhocMode;
3522 RTMPSetPhyMode(pAdapter, PhyMode);
3523 MlmeUpdateTxRates(pAdapter, FALSE, 0);
3524 MakeIbssBeacon(pAdapter); // re-build BEACON frame
3525 AsicEnableIbssSync(pAdapter); // copy to on-chip memory
3528 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_SET_STA_CONFIG (Burst=%d, Protection=%ld,ShortSlot=%d\n",
3529 pAdapter->CommonCfg.bEnableTxBurst,
3530 pAdapter->CommonCfg.UseBGProtection,
3531 pAdapter->CommonCfg.bUseShortSlotTime));
3534 case OID_802_11_DESIRED_RATES:
3535 if (wrq->u.data.length != sizeof(NDIS_802_11_RATES))
3539 Status = copy_from_user(&aryRates, wrq->u.data.pointer, wrq->u.data.length);
3540 NdisZeroMemory(pAdapter->CommonCfg.DesireRate, MAX_LEN_OF_SUPPORTED_RATES);
3541 NdisMoveMemory(pAdapter->CommonCfg.DesireRate, &aryRates, sizeof(NDIS_802_11_RATES));
3542 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_DESIRED_RATES (%02x,%02x,%02x,%02x,%02x,%02x,%02x,%02x)\n",
3543 pAdapter->CommonCfg.DesireRate[0],pAdapter->CommonCfg.DesireRate[1],
3544 pAdapter->CommonCfg.DesireRate[2],pAdapter->CommonCfg.DesireRate[3],
3545 pAdapter->CommonCfg.DesireRate[4],pAdapter->CommonCfg.DesireRate[5],
3546 pAdapter->CommonCfg.DesireRate[6],pAdapter->CommonCfg.DesireRate[7] ));
3547 // Changing DesiredRate may affect the MAX TX rate we used to TX frames out
3548 MlmeUpdateTxRates(pAdapter, FALSE, 0);
3551 case RT_OID_802_11_PREAMBLE:
3552 if (wrq->u.data.length != sizeof(RT_802_11_PREAMBLE))
3556 Status = copy_from_user(&Preamble, wrq->u.data.pointer, wrq->u.data.length);
3557 if (Preamble == Rt802_11PreambleShort)
3559 pAdapter->CommonCfg.TxPreamble = Preamble;
3560 MlmeSetTxPreamble(pAdapter, Rt802_11PreambleShort);
3562 else if ((Preamble == Rt802_11PreambleLong) || (Preamble == Rt802_11PreambleAuto))
3564 // if user wants AUTO, initialize to LONG here, then change according to AP's
3565 // capability upon association.
3566 pAdapter->CommonCfg.TxPreamble = Preamble;
3567 MlmeSetTxPreamble(pAdapter, Rt802_11PreambleLong);
3574 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_PREAMBLE (=%d)\n", Preamble));
3577 case OID_802_11_WEP_STATUS:
3578 if (wrq->u.data.length != sizeof(NDIS_802_11_WEP_STATUS))
3582 Status = copy_from_user(&WepStatus, wrq->u.data.pointer, wrq->u.data.length);
3583 // Since TKIP, AES, WEP are all supported. It should not have any invalid setting
3584 if (WepStatus <= Ndis802_11Encryption3KeyAbsent)
3586 if (pAdapter->StaCfg.WepStatus != WepStatus)
3588 // Config has changed
3589 pAdapter->bConfigChanged = TRUE;
3591 pAdapter->StaCfg.WepStatus = WepStatus;
3592 pAdapter->StaCfg.OrigWepStatus = WepStatus;
3593 pAdapter->StaCfg.PairCipher = WepStatus;
3594 pAdapter->StaCfg.GroupCipher = WepStatus;
3601 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_WEP_STATUS (=%d)\n",WepStatus));
3604 case OID_802_11_AUTHENTICATION_MODE:
3605 if (wrq->u.data.length != sizeof(NDIS_802_11_AUTHENTICATION_MODE))
3609 Status = copy_from_user(&AuthMode, wrq->u.data.pointer, wrq->u.data.length);
3610 if (AuthMode > Ndis802_11AuthModeMax)
3617 if (pAdapter->StaCfg.AuthMode != AuthMode)
3619 // Config has changed
3620 pAdapter->bConfigChanged = TRUE;
3622 pAdapter->StaCfg.AuthMode = AuthMode;
3624 pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED;
3625 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_AUTHENTICATION_MODE (=%d) \n",pAdapter->StaCfg.AuthMode));
3628 case OID_802_11_INFRASTRUCTURE_MODE:
3629 if (wrq->u.data.length != sizeof(NDIS_802_11_NETWORK_INFRASTRUCTURE))
3633 Status = copy_from_user(&BssType, wrq->u.data.pointer, wrq->u.data.length);
3635 if (BssType == Ndis802_11IBSS)
3636 Set_NetworkType_Proc(pAdapter, "Adhoc");
3637 else if (BssType == Ndis802_11Infrastructure)
3638 Set_NetworkType_Proc(pAdapter, "Infra");
3639 else if (BssType == Ndis802_11Monitor)
3640 Set_NetworkType_Proc(pAdapter, "Monitor");
3644 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_INFRASTRUCTURE_MODE (unknown)\n"));
3648 case OID_802_11_REMOVE_WEP:
3649 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_WEP\n"));
3650 if (wrq->u.data.length != sizeof(NDIS_802_11_KEY_INDEX))
3656 KeyIdx = *(NDIS_802_11_KEY_INDEX *) wrq->u.data.pointer;
3658 if (KeyIdx & 0x80000000)
3660 // Should never set default bit when remove key
3665 KeyIdx = KeyIdx & 0x0fffffff;
3671 pAdapter->SharedKey[BSS0][KeyIdx].KeyLen = 0;
3672 pAdapter->SharedKey[BSS0][KeyIdx].CipherAlg = CIPHER_NONE;
3673 AsicRemoveSharedKeyEntry(pAdapter, 0, (UCHAR)KeyIdx);
3678 case RT_OID_802_11_RESET_COUNTERS:
3679 NdisZeroMemory(&pAdapter->WlanCounters, sizeof(COUNTER_802_11));
3680 NdisZeroMemory(&pAdapter->Counters8023, sizeof(COUNTER_802_3));
3681 NdisZeroMemory(&pAdapter->RalinkCounters, sizeof(COUNTER_RALINK));
3682 pAdapter->Counters8023.RxNoBuffer = 0;
3683 pAdapter->Counters8023.GoodReceives = 0;
3684 pAdapter->Counters8023.RxNoBuffer = 0;
3686 pAdapter->BulkOutComplete = 0;
3687 pAdapter->BulkOutCompleteOther= 0;
3688 pAdapter->BulkOutCompleteCancel = 0;
3689 pAdapter->BulkOutReq = 0;
3690 pAdapter->BulkInReq= 0;
3691 pAdapter->BulkInComplete = 0;
3692 pAdapter->BulkInCompleteFail = 0;
3694 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_RESET_COUNTERS \n"));
3696 case OID_802_11_RTS_THRESHOLD:
3697 if (wrq->u.data.length != sizeof(NDIS_802_11_RTS_THRESHOLD))
3701 Status = copy_from_user(&RtsThresh, wrq->u.data.pointer, wrq->u.data.length);
3702 if (RtsThresh > MAX_RTS_THRESHOLD)
3705 pAdapter->CommonCfg.RtsThreshold = (USHORT)RtsThresh;
3707 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_RTS_THRESHOLD (=%ld)\n",RtsThresh));
3709 case OID_802_11_FRAGMENTATION_THRESHOLD:
3710 if (wrq->u.data.length != sizeof(NDIS_802_11_FRAGMENTATION_THRESHOLD))
3714 Status = copy_from_user(&FragThresh, wrq->u.data.pointer, wrq->u.data.length);
3715 pAdapter->CommonCfg.bUseZeroToDisableFragment = FALSE;
3716 if (FragThresh > MAX_FRAG_THRESHOLD || FragThresh < MIN_FRAG_THRESHOLD)
3718 if (FragThresh == 0)
3720 pAdapter->CommonCfg.FragmentThreshold = MAX_FRAG_THRESHOLD;
3721 pAdapter->CommonCfg.bUseZeroToDisableFragment = TRUE;
3727 pAdapter->CommonCfg.FragmentThreshold = (USHORT)FragThresh;
3729 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_FRAGMENTATION_THRESHOLD (=%ld) \n",FragThresh));
3731 case OID_802_11_POWER_MODE:
3732 if (wrq->u.data.length != sizeof(NDIS_802_11_POWER_MODE))
3736 Status = copy_from_user(&PowerMode, wrq->u.data.pointer, wrq->u.data.length);
3737 if (PowerMode == Ndis802_11PowerModeCAM)
3738 Set_PSMode_Proc(pAdapter, "CAM");
3739 else if (PowerMode == Ndis802_11PowerModeMAX_PSP)
3740 Set_PSMode_Proc(pAdapter, "Max_PSP");
3741 else if (PowerMode == Ndis802_11PowerModeFast_PSP)
3742 Set_PSMode_Proc(pAdapter, "Fast_PSP");
3743 else if (PowerMode == Ndis802_11PowerModeLegacy_PSP)
3744 Set_PSMode_Proc(pAdapter, "Legacy_PSP");
3748 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_POWER_MODE (=%d)\n",PowerMode));
3750 case RT_OID_802_11_TX_POWER_LEVEL_1:
3751 if (wrq->u.data.length < sizeof(ULONG))
3755 Status = copy_from_user(&PowerTemp, wrq->u.data.pointer, wrq->u.data.length);
3756 if (PowerTemp > 100)
3757 PowerTemp = 0xffffffff; // AUTO
3758 pAdapter->CommonCfg.TxPowerDefault = PowerTemp; //keep current setting.
3759 pAdapter->CommonCfg.TxPowerPercentage = pAdapter->CommonCfg.TxPowerDefault;
3760 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_TX_POWER_LEVEL_1 (=%ld)\n", pAdapter->CommonCfg.TxPowerPercentage));
3763 case OID_802_11_NETWORK_TYPE_IN_USE:
3764 if (wrq->u.data.length != sizeof(NDIS_802_11_NETWORK_TYPE))
3768 Status = copy_from_user(&NetType, wrq->u.data.pointer, wrq->u.data.length);
3770 if (NetType == Ndis802_11DS)
3771 RTMPSetPhyMode(pAdapter, PHY_11B);
3772 else if (NetType == Ndis802_11OFDM24)
3773 RTMPSetPhyMode(pAdapter, PHY_11BG_MIXED);
3774 else if (NetType == Ndis802_11OFDM5)
3775 RTMPSetPhyMode(pAdapter, PHY_11A);
3778 #ifdef DOT11_N_SUPPORT
3779 if (Status == NDIS_STATUS_SUCCESS)
3780 SetCommonHT(pAdapter);
3781 #endif // DOT11_N_SUPPORT //
3782 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_NETWORK_TYPE_IN_USE (=%d)\n",NetType));
3785 // For WPA PSK PMK key
3786 case RT_OID_802_11_ADD_WPA:
3787 pKey = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
3794 Status = copy_from_user(pKey, wrq->u.data.pointer, wrq->u.data.length);
3795 if (pKey->Length != wrq->u.data.length)
3798 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_ADD_WPA, Failed!!\n"));
3802 if ((pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPAPSK) &&
3803 (pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPA2PSK) &&
3804 (pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPANone) )
3806 Status = -EOPNOTSUPP;
3807 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_ADD_WPA, Failed!! [AuthMode != WPAPSK/WPA2PSK/WPANONE]\n"));
3809 else if ((pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK) ||
3810 (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK) ||
3811 (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPANone) ) // Only for WPA PSK mode
3813 NdisMoveMemory(pAdapter->StaCfg.PMK, &pKey->KeyMaterial, pKey->KeyLength);
3814 // Use RaConfig as PSK agent.
3815 // Start STA supplicant state machine
3816 if (pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPANone)
3817 pAdapter->StaCfg.WpaState = SS_START;
3819 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_ADD_WPA (id=0x%x, Len=%d-byte)\n", pKey->KeyIndex, pKey->KeyLength));
3823 pAdapter->StaCfg.WpaState = SS_NOTUSE;
3824 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_ADD_WPA (id=0x%x, Len=%d-byte)\n", pKey->KeyIndex, pKey->KeyLength));
3829 case OID_802_11_REMOVE_KEY:
3830 pRemoveKey = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
3831 if(pRemoveKey == NULL)
3837 Status = copy_from_user(pRemoveKey, wrq->u.data.pointer, wrq->u.data.length);
3838 if (pRemoveKey->Length != wrq->u.data.length)
3841 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_KEY, Failed!!\n"));
3845 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
3847 RTMPWPARemoveKeyProc(pAdapter, pRemoveKey);
3848 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_KEY, Remove WPA Key!!\n"));
3852 KeyIdx = pRemoveKey->KeyIndex;
3854 if (KeyIdx & 0x80000000)
3856 // Should never set default bit when remove key
3858 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_KEY, Failed!!(Should never set default bit when remove key)\n"));
3862 KeyIdx = KeyIdx & 0x0fffffff;
3866 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_KEY, Failed!!(KeyId[%d] out of range)\n", KeyIdx));
3870 pAdapter->SharedKey[BSS0][KeyIdx].KeyLen = 0;
3871 pAdapter->SharedKey[BSS0][KeyIdx].CipherAlg = CIPHER_NONE;
3872 AsicRemoveSharedKeyEntry(pAdapter, 0, (UCHAR)KeyIdx);
3873 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_KEY (id=0x%x, Len=%d-byte)\n", pRemoveKey->KeyIndex, pRemoveKey->Length));
3881 case OID_802_11_ADD_KEY:
3882 pKey = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
3888 Status = copy_from_user(pKey, wrq->u.data.pointer, wrq->u.data.length);
3889 if (pKey->Length != wrq->u.data.length)
3892 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_KEY, Failed!!\n"));
3896 RTMPAddKey(pAdapter, pKey);
3897 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_KEY (id=0x%x, Len=%d-byte)\n", pKey->KeyIndex, pKey->KeyLength));
3901 case OID_802_11_CONFIGURATION:
3902 if (wrq->u.data.length != sizeof(NDIS_802_11_CONFIGURATION))
3906 Status = copy_from_user(&Config, wrq->u.data.pointer, wrq->u.data.length);
3909 if ((pConfig->BeaconPeriod >= 20) && (pConfig->BeaconPeriod <=400))
3910 pAdapter->CommonCfg.BeaconPeriod = (USHORT) pConfig->BeaconPeriod;
3912 pAdapter->StaActive.AtimWin = (USHORT) pConfig->ATIMWindow;
3913 MAP_KHZ_TO_CHANNEL_ID(pConfig->DSConfig, pAdapter->CommonCfg.Channel);
3915 // Save the channel on MlmeAux for CntlOidRTBssidProc used.
3917 pAdapter->MlmeAux.Channel = pAdapter->CommonCfg.Channel;
3919 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_CONFIGURATION (BeacnPeriod=%ld,AtimW=%ld,Ch=%d)\n",
3920 pConfig->BeaconPeriod, pConfig->ATIMWindow, pAdapter->CommonCfg.Channel));
3921 // Config has changed
3922 pAdapter->bConfigChanged = TRUE;
3925 #ifdef DOT11_N_SUPPORT
3926 case RT_OID_802_11_SET_HT_PHYMODE:
3927 if (wrq->u.data.length != sizeof(OID_SET_HT_PHYMODE))
3931 POID_SET_HT_PHYMODE pHTPhyMode = &HT_PhyMode;
3933 Status = copy_from_user(&HT_PhyMode, wrq->u.data.pointer, wrq->u.data.length);
3934 DBGPRINT(RT_DEBUG_TRACE, ("Set::pHTPhyMode (PhyMode = %d,TransmitNo = %d, HtMode = %d, ExtOffset = %d , MCS = %d, BW = %d, STBC = %d, SHORTGI = %d) \n",
3935 pHTPhyMode->PhyMode, pHTPhyMode->TransmitNo,pHTPhyMode->HtMode,pHTPhyMode->ExtOffset,
3936 pHTPhyMode->MCS, pHTPhyMode->BW, pHTPhyMode->STBC, pHTPhyMode->SHORTGI));
3937 if (pAdapter->CommonCfg.PhyMode >= PHY_11ABGN_MIXED)
3938 RTMPSetHT(pAdapter, pHTPhyMode);
3940 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_SET_HT_PHYMODE(MCS=%d,BW=%d,SGI=%d,STBC=%d)\n",
3941 pAdapter->StaCfg.HTPhyMode.field.MCS, pAdapter->StaCfg.HTPhyMode.field.BW, pAdapter->StaCfg.HTPhyMode.field.ShortGI,
3942 pAdapter->StaCfg.HTPhyMode.field.STBC));
3944 #endif // DOT11_N_SUPPORT //
3945 case RT_OID_802_11_SET_APSD_SETTING:
3946 if (wrq->u.data.length != sizeof(ULONG))
3951 Status = copy_from_user(&apsd, wrq->u.data.pointer, wrq->u.data.length);
3953 /*-------------------------------------------------------------------
3954 |B31~B7 | B6~B5 | B4 | B3 | B2 | B1 | B0 |
3955 ---------------------------------------------------------------------
3956 | Rsvd | Max SP Len | AC_VO | AC_VI | AC_BK | AC_BE | APSD Capable |
3957 ---------------------------------------------------------------------*/
3958 pAdapter->CommonCfg.bAPSDCapable = (apsd & 0x00000001) ? TRUE : FALSE;
3959 pAdapter->CommonCfg.bAPSDAC_BE = ((apsd & 0x00000002) >> 1) ? TRUE : FALSE;
3960 pAdapter->CommonCfg.bAPSDAC_BK = ((apsd & 0x00000004) >> 2) ? TRUE : FALSE;
3961 pAdapter->CommonCfg.bAPSDAC_VI = ((apsd & 0x00000008) >> 3) ? TRUE : FALSE;
3962 pAdapter->CommonCfg.bAPSDAC_VO = ((apsd & 0x00000010) >> 4) ? TRUE : FALSE;
3963 pAdapter->CommonCfg.MaxSPLength = (UCHAR)((apsd & 0x00000060) >> 5);
3965 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,
3966 pAdapter->CommonCfg.bAPSDAC_BE, pAdapter->CommonCfg.bAPSDAC_BK, pAdapter->CommonCfg.bAPSDAC_VI, pAdapter->CommonCfg.bAPSDAC_VO, pAdapter->CommonCfg.MaxSPLength));
3970 case RT_OID_802_11_SET_APSD_PSM:
3971 if (wrq->u.data.length != sizeof(ULONG))
3975 // Driver needs to notify AP when PSM changes
3976 Status = copy_from_user(&pAdapter->CommonCfg.bAPSDForcePowerSave, wrq->u.data.pointer, wrq->u.data.length);
3977 if (pAdapter->CommonCfg.bAPSDForcePowerSave != pAdapter->StaCfg.Psm)
3979 MlmeSetPsmBit(pAdapter, pAdapter->CommonCfg.bAPSDForcePowerSave);
3980 RTMPSendNullFrame(pAdapter, pAdapter->CommonCfg.TxRate, TRUE);
3982 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_SET_APSD_PSM (bAPSDForcePowerSave:%d)\n", pAdapter->CommonCfg.bAPSDForcePowerSave));
3985 #ifdef QOS_DLS_SUPPORT
3986 case RT_OID_802_11_SET_DLS:
3987 if (wrq->u.data.length != sizeof(ULONG))
3991 BOOLEAN oldvalue = pAdapter->CommonCfg.bDLSCapable;
3992 Status = copy_from_user(&pAdapter->CommonCfg.bDLSCapable, wrq->u.data.pointer, wrq->u.data.length);
3993 if (oldvalue && !pAdapter->CommonCfg.bDLSCapable)
3996 // tear down local dls table entry
3997 for (i=0; i<MAX_NUM_OF_INIT_DLS_ENTRY; i++)
3999 if (pAdapter->StaCfg.DLSEntry[i].Valid && (pAdapter->StaCfg.DLSEntry[i].Status == DLS_FINISH))
4001 pAdapter->StaCfg.DLSEntry[i].Status = DLS_NONE;
4002 pAdapter->StaCfg.DLSEntry[i].Valid = FALSE;
4003 RTMPSendDLSTearDownFrame(pAdapter, pAdapter->StaCfg.DLSEntry[i].MacAddr);
4007 // tear down peer dls table entry
4008 for (i=MAX_NUM_OF_INIT_DLS_ENTRY; i<MAX_NUM_OF_DLS_ENTRY; i++)
4010 if (pAdapter->StaCfg.DLSEntry[i].Valid && (pAdapter->StaCfg.DLSEntry[i].Status == DLS_FINISH))
4012 pAdapter->StaCfg.DLSEntry[i].Status = DLS_NONE;
4013 pAdapter->StaCfg.DLSEntry[i].Valid = FALSE;
4014 RTMPSendDLSTearDownFrame(pAdapter, pAdapter->StaCfg.DLSEntry[i].MacAddr);
4019 DBGPRINT(RT_DEBUG_TRACE,("Set::RT_OID_802_11_SET_DLS (=%d)\n", pAdapter->CommonCfg.bDLSCapable));
4023 case RT_OID_802_11_SET_DLS_PARAM:
4024 if (wrq->u.data.length != sizeof(RT_802_11_DLS_UI))
4030 NdisZeroMemory(&Dls, sizeof(RT_802_11_DLS));
4031 RTMPMoveMemory(&Dls, wrq->u.data.pointer, sizeof(RT_802_11_DLS_UI));
4032 MlmeEnqueue(pAdapter,
4033 MLME_CNTL_STATE_MACHINE,
4034 RT_OID_802_11_SET_DLS_PARAM,
4035 sizeof(RT_802_11_DLS),
4037 DBGPRINT(RT_DEBUG_TRACE,("Set::RT_OID_802_11_SET_DLS_PARAM \n"));
4040 #endif // QOS_DLS_SUPPORT //
4041 case RT_OID_802_11_SET_WMM:
4042 if (wrq->u.data.length != sizeof(BOOLEAN))
4046 Status = copy_from_user(&pAdapter->CommonCfg.bWmmCapable, wrq->u.data.pointer, wrq->u.data.length);
4047 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_SET_WMM (=%d) \n", pAdapter->CommonCfg.bWmmCapable));
4051 case OID_802_11_DISASSOCIATE:
4053 if (ATE_ON(pAdapter))
4055 DBGPRINT(RT_DEBUG_TRACE, ("The driver is in ATE mode now\n"));
4058 #endif // RALINK_ATE //
4060 // Set NdisRadioStateOff to TRUE, instead of called MlmeRadioOff.
4061 // Later on, NDIS_802_11_BSSID_LIST_EX->NumberOfItems should be 0
4062 // when query OID_802_11_BSSID_LIST.
4064 // TRUE: NumberOfItems will set to 0.
4065 // FALSE: NumberOfItems no change.
4067 pAdapter->CommonCfg.NdisRadioStateOff = TRUE;
4068 // Set to immediately send the media disconnect event
4069 pAdapter->MlmeAux.CurrReqIsFromNdis = TRUE;
4070 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_DISASSOCIATE \n"));
4072 if (INFRA_ON(pAdapter))
4074 if (pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE)
4076 RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
4077 DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
4080 MlmeEnqueue(pAdapter,
4081 MLME_CNTL_STATE_MACHINE,
4082 OID_802_11_DISASSOCIATE,
4086 StateMachineTouched = TRUE;
4090 #ifdef DOT11_N_SUPPORT
4091 case RT_OID_802_11_SET_IMME_BA_CAP:
4092 if (wrq->u.data.length != sizeof(OID_BACAP_STRUC))
4096 OID_BACAP_STRUC Orde ;
4097 Status = copy_from_user(&Orde, wrq->u.data.pointer, wrq->u.data.length);
4098 if (Orde.Policy > BA_NOTUSE)
4100 Status = NDIS_STATUS_INVALID_DATA;
4102 else if (Orde.Policy == BA_NOTUSE)
4104 pAdapter->CommonCfg.BACapability.field.Policy = BA_NOTUSE;
4105 pAdapter->CommonCfg.BACapability.field.MpduDensity = Orde.MpduDensity;
4106 pAdapter->CommonCfg.DesiredHtPhy.MpduDensity = Orde.MpduDensity;
4107 pAdapter->CommonCfg.DesiredHtPhy.AmsduEnable = Orde.AmsduEnable;
4108 pAdapter->CommonCfg.DesiredHtPhy.AmsduSize= Orde.AmsduSize;
4109 pAdapter->CommonCfg.DesiredHtPhy.MimoPs= Orde.MMPSmode;
4110 pAdapter->CommonCfg.BACapability.field.MMPSmode = Orde.MMPSmode;
4112 pAdapter->CommonCfg.HtCapability.HtCapInfo.MimoPs = Orde.MMPSmode;
4113 pAdapter->CommonCfg.HtCapability.HtCapInfo.AMsduSize = Orde.AmsduSize;
4114 pAdapter->CommonCfg.HtCapability.HtCapParm.MpduDensity = Orde.MpduDensity;
4118 pAdapter->CommonCfg.BACapability.field.AutoBA = Orde.AutoBA;
4119 pAdapter->CommonCfg.BACapability.field.Policy = IMMED_BA; // we only support immediate BA.
4120 pAdapter->CommonCfg.BACapability.field.MpduDensity = Orde.MpduDensity;
4121 pAdapter->CommonCfg.DesiredHtPhy.MpduDensity = Orde.MpduDensity;
4122 pAdapter->CommonCfg.DesiredHtPhy.AmsduEnable = Orde.AmsduEnable;
4123 pAdapter->CommonCfg.DesiredHtPhy.AmsduSize= Orde.AmsduSize;
4124 pAdapter->CommonCfg.DesiredHtPhy.MimoPs = Orde.MMPSmode;
4125 pAdapter->CommonCfg.BACapability.field.MMPSmode = Orde.MMPSmode;
4128 pAdapter->CommonCfg.HtCapability.HtCapInfo.MimoPs = Orde.MMPSmode;
4129 pAdapter->CommonCfg.HtCapability.HtCapInfo.AMsduSize = Orde.AmsduSize;
4130 pAdapter->CommonCfg.HtCapability.HtCapParm.MpduDensity = Orde.MpduDensity;
4132 if (pAdapter->CommonCfg.BACapability.field.RxBAWinLimit > MAX_RX_REORDERBUF)
4133 pAdapter->CommonCfg.BACapability.field.RxBAWinLimit = MAX_RX_REORDERBUF;
4137 pAdapter->CommonCfg.REGBACapability.word = pAdapter->CommonCfg.BACapability.word;
4138 DBGPRINT(RT_DEBUG_TRACE, ("Set::(Orde.AutoBA = %d) (Policy=%d)(ReBAWinLimit=%d)(TxBAWinLimit=%d)(AutoMode=%d)\n",Orde.AutoBA, pAdapter->CommonCfg.BACapability.field.Policy,
4139 pAdapter->CommonCfg.BACapability.field.RxBAWinLimit,pAdapter->CommonCfg.BACapability.field.TxBAWinLimit, pAdapter->CommonCfg.BACapability.field.AutoBA));
4140 DBGPRINT(RT_DEBUG_TRACE, ("Set::(MimoPs = %d)(AmsduEnable = %d) (AmsduSize=%d)(MpduDensity=%d)\n",pAdapter->CommonCfg.DesiredHtPhy.MimoPs, pAdapter->CommonCfg.DesiredHtPhy.AmsduEnable,
4141 pAdapter->CommonCfg.DesiredHtPhy.AmsduSize, pAdapter->CommonCfg.DesiredHtPhy.MpduDensity));
4145 case RT_OID_802_11_ADD_IMME_BA:
4146 DBGPRINT(RT_DEBUG_TRACE, (" Set :: RT_OID_802_11_ADD_IMME_BA \n"));
4147 if (wrq->u.data.length != sizeof(OID_ADD_BA_ENTRY))
4152 OID_ADD_BA_ENTRY BA;
4153 MAC_TABLE_ENTRY *pEntry;
4155 Status = copy_from_user(&BA, wrq->u.data.pointer, wrq->u.data.length);
4158 Status = NDIS_STATUS_INVALID_DATA;
4163 //BATableInsertEntry
4164 //As ad-hoc mode, BA pair is not limited to only BSSID. so add via OID.
4166 // in ad hoc mode, when adding BA pair, we should insert this entry into MACEntry too
4167 pEntry = MacTableLookup(pAdapter, BA.MACAddr);
4170 DBGPRINT(RT_DEBUG_TRACE, ("RT_OID_802_11_ADD_IMME_BA. break on no connection.----:%x:%x\n", BA.MACAddr[4], BA.MACAddr[5]));
4173 if (BA.IsRecipient == FALSE)
4175 if (pEntry->bIAmBadAtheros == TRUE)
4176 pAdapter->CommonCfg.BACapability.field.RxBAWinLimit = 0x10;
4178 BAOriSessionSetUp(pAdapter, pEntry, index, 0, 100, TRUE);
4182 //BATableInsertEntry(pAdapter, pEntry->Aid, BA.MACAddr, 0, 0xffff, BA.TID, BA.nMSDU, BA.IsRecipient);
4185 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_ADD_IMME_BA. Rec = %d. Mac = %x:%x:%x:%x:%x:%x . \n",
4186 BA.IsRecipient, BA.MACAddr[0], BA.MACAddr[1], BA.MACAddr[2], BA.MACAddr[2]
4187 , BA.MACAddr[4], BA.MACAddr[5]));
4192 case RT_OID_802_11_TEAR_IMME_BA:
4193 DBGPRINT(RT_DEBUG_TRACE, ("Set :: RT_OID_802_11_TEAR_IMME_BA \n"));
4194 if (wrq->u.data.length != sizeof(OID_ADD_BA_ENTRY))
4198 POID_ADD_BA_ENTRY pBA;
4199 MAC_TABLE_ENTRY *pEntry;
4201 pBA = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
4205 DBGPRINT(RT_DEBUG_TRACE, ("Set :: RT_OID_802_11_TEAR_IMME_BA kmalloc() can't allocate enough memory\n"));
4206 Status = NDIS_STATUS_FAILURE;
4210 Status = copy_from_user(pBA, wrq->u.data.pointer, wrq->u.data.length);
4211 DBGPRINT(RT_DEBUG_TRACE, ("Set :: RT_OID_802_11_TEAR_IMME_BA(TID=%d, bAllTid=%d)\n", pBA->TID, pBA->bAllTid));
4213 if (!pBA->bAllTid && (pBA->TID > NUM_OF_TID))
4215 Status = NDIS_STATUS_INVALID_DATA;
4219 if (pBA->IsRecipient == FALSE)
4221 pEntry = MacTableLookup(pAdapter, pBA->MACAddr);
4222 DBGPRINT(RT_DEBUG_TRACE, (" pBA->IsRecipient == FALSE\n"));
4225 DBGPRINT(RT_DEBUG_TRACE, (" pBA->pEntry\n"));
4226 BAOriSessionTearDown(pAdapter, pEntry->Aid, pBA->TID, FALSE, TRUE);
4229 DBGPRINT(RT_DEBUG_TRACE, ("Set :: Not found pEntry \n"));
4233 pEntry = MacTableLookup(pAdapter, pBA->MACAddr);
4236 BARecSessionTearDown( pAdapter, (UCHAR)pEntry->Aid, pBA->TID, TRUE);
4239 DBGPRINT(RT_DEBUG_TRACE, ("Set :: Not found pEntry \n"));
4245 #endif // DOT11_N_SUPPORT //
4247 // For WPA_SUPPLICANT to set static wep key
4248 case OID_802_11_ADD_WEP:
4249 pWepKey = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
4254 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_WEP, Failed!!\n"));
4257 Status = copy_from_user(pWepKey, wrq->u.data.pointer, wrq->u.data.length);
4261 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_WEP, Failed (length mismatch)!!\n"));
4265 KeyIdx = pWepKey->KeyIndex & 0x0fffffff;
4266 // KeyIdx must be 0 ~ 3
4270 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_WEP, Failed (KeyIdx must be smaller than 4)!!\n"));
4274 UCHAR CipherAlg = 0;
4277 // set key material and key length
4278 NdisZeroMemory(pAdapter->SharedKey[BSS0][KeyIdx].Key, 16);
4279 pAdapter->SharedKey[BSS0][KeyIdx].KeyLen = (UCHAR) pWepKey->KeyLength;
4280 NdisMoveMemory(pAdapter->SharedKey[BSS0][KeyIdx].Key, &pWepKey->KeyMaterial, pWepKey->KeyLength);
4282 switch(pWepKey->KeyLength)
4285 CipherAlg = CIPHER_WEP64;
4288 CipherAlg = CIPHER_WEP128;
4291 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_WEP, only support CIPHER_WEP64(len:5) & CIPHER_WEP128(len:13)!!\n"));
4295 pAdapter->SharedKey[BSS0][KeyIdx].CipherAlg = CipherAlg;
4297 // Default key for tx (shared key)
4298 if (pWepKey->KeyIndex & 0x80000000)
4300 #ifdef WPA_SUPPLICANT_SUPPORT
4301 // set key material and key length
4302 NdisZeroMemory(pAdapter->StaCfg.DesireSharedKey[KeyIdx].Key, 16);
4303 pAdapter->StaCfg.DesireSharedKey[KeyIdx].KeyLen = (UCHAR) pWepKey->KeyLength;
4304 NdisMoveMemory(pAdapter->StaCfg.DesireSharedKey[KeyIdx].Key, &pWepKey->KeyMaterial, pWepKey->KeyLength);
4305 pAdapter->StaCfg.DesireSharedKeyId = KeyIdx;
4306 pAdapter->StaCfg.DesireSharedKey[KeyIdx].CipherAlg = CipherAlg;
4307 #endif // WPA_SUPPLICANT_SUPPORT //
4308 pAdapter->StaCfg.DefaultKeyId = (UCHAR) KeyIdx;
4311 #ifdef WPA_SUPPLICANT_SUPPORT
4312 if ((pAdapter->StaCfg.WpaSupplicantUP != WPA_SUPPLICANT_DISABLE) &&
4313 (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA))
4315 Key = pWepKey->KeyMaterial;
4317 // Set Group key material to Asic
4318 AsicAddSharedKeyEntry(pAdapter, BSS0, KeyIdx, CipherAlg, Key, NULL, NULL);
4320 // Update WCID attribute table and IVEIV table for this group key table
4321 RTMPAddWcidAttributeEntry(pAdapter, BSS0, KeyIdx, CipherAlg, NULL);
4323 STA_PORT_SECURED(pAdapter);
4325 // Indicate Connected for GUI
4326 pAdapter->IndicateMediaState = NdisMediaStateConnected;
4328 else if (pAdapter->StaCfg.PortSecured == WPA_802_1X_PORT_SECURED)
4329 #endif // WPA_SUPPLICANT_SUPPORT
4331 Key = pAdapter->SharedKey[BSS0][KeyIdx].Key;
4333 // Set key material and cipherAlg to Asic
4334 AsicAddSharedKeyEntry(pAdapter, BSS0, KeyIdx, CipherAlg, Key, NULL, NULL);
4336 if (pWepKey->KeyIndex & 0x80000000)
4338 PMAC_TABLE_ENTRY pEntry = &pAdapter->MacTab.Content[BSSID_WCID];
4339 // Assign group key info
4340 RTMPAddWcidAttributeEntry(pAdapter, BSS0, KeyIdx, CipherAlg, NULL);
4341 // Assign pairwise key info
4342 RTMPAddWcidAttributeEntry(pAdapter, BSS0, KeyIdx, CipherAlg, pEntry);
4345 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"));
4350 #ifdef WPA_SUPPLICANT_SUPPORT
4351 case OID_SET_COUNTERMEASURES:
4352 if (wrq->u.data.length != sizeof(int))
4357 Status = copy_from_user(&enabled, wrq->u.data.pointer, wrq->u.data.length);
4359 pAdapter->StaCfg.bBlockAssoc = TRUE;
4361 // WPA MIC error should block association attempt for 60 seconds
4362 pAdapter->StaCfg.bBlockAssoc = FALSE;
4363 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_SET_COUNTERMEASURES bBlockAssoc=%s\n", pAdapter->StaCfg.bBlockAssoc ? "TRUE":"FALSE"));
4366 case RT_OID_WPA_SUPPLICANT_SUPPORT:
4367 if (wrq->u.data.length != sizeof(UCHAR))
4371 Status = copy_from_user(&wpa_supplicant_enable, wrq->u.data.pointer, wrq->u.data.length);
4372 pAdapter->StaCfg.WpaSupplicantUP = wpa_supplicant_enable;
4373 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_WPA_SUPPLICANT_SUPPORT (=%d)\n", pAdapter->StaCfg.WpaSupplicantUP));
4376 case OID_802_11_DEAUTHENTICATION:
4377 if (wrq->u.data.length != sizeof(MLME_DEAUTH_REQ_STRUCT))
4381 MLME_DEAUTH_REQ_STRUCT *pInfo;
4382 MLME_QUEUE_ELEM *MsgElem = (MLME_QUEUE_ELEM *) kmalloc(sizeof(MLME_QUEUE_ELEM), MEM_ALLOC_FLAG);
4384 pInfo = (MLME_DEAUTH_REQ_STRUCT *) MsgElem->Msg;
4385 Status = copy_from_user(pInfo, wrq->u.data.pointer, wrq->u.data.length);
4386 MlmeDeauthReqAction(pAdapter, MsgElem);
4389 if (INFRA_ON(pAdapter))
4391 LinkDown(pAdapter, FALSE);
4392 pAdapter->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
4394 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_DEAUTHENTICATION (Reason=%d)\n", pInfo->Reason));
4397 case OID_802_11_DROP_UNENCRYPTED:
4398 if (wrq->u.data.length != sizeof(int))
4403 Status = copy_from_user(&enabled, wrq->u.data.pointer, wrq->u.data.length);
4405 pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED;
4407 pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
4408 NdisAcquireSpinLock(&pAdapter->MacTabLock);
4409 pAdapter->MacTab.Content[BSSID_WCID].PortSecured = pAdapter->StaCfg.PortSecured;
4410 NdisReleaseSpinLock(&pAdapter->MacTabLock);
4411 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_DROP_UNENCRYPTED (=%d)\n", enabled));
4414 case OID_802_11_SET_IEEE8021X:
4415 if (wrq->u.data.length != sizeof(BOOLEAN))
4419 Status = copy_from_user(&IEEE8021xState, wrq->u.data.pointer, wrq->u.data.length);
4420 pAdapter->StaCfg.IEEE8021X = IEEE8021xState;
4421 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_SET_IEEE8021X (=%d)\n", IEEE8021xState));
4424 case OID_802_11_SET_IEEE8021X_REQUIRE_KEY:
4425 if (wrq->u.data.length != sizeof(BOOLEAN))
4429 Status = copy_from_user(&IEEE8021x_required_keys, wrq->u.data.pointer, wrq->u.data.length);
4430 pAdapter->StaCfg.IEEE8021x_required_keys = IEEE8021x_required_keys;
4431 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_SET_IEEE8021X_REQUIRE_KEY (%d)\n", IEEE8021x_required_keys));
4434 case OID_802_11_PMKID:
4435 pPmkId = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
4437 if(pPmkId == NULL) {
4441 Status = copy_from_user(pPmkId, wrq->u.data.pointer, wrq->u.data.length);
4443 // check the PMKID information
4444 if (pPmkId->BSSIDInfoCount == 0)
4445 NdisZeroMemory(pAdapter->StaCfg.SavedPMK, sizeof(BSSID_INFO)*PMKID_NO);
4448 PBSSID_INFO pBssIdInfo;
4452 for (BssIdx = 0; BssIdx < pPmkId->BSSIDInfoCount; BssIdx++)
4454 // point to the indexed BSSID_INFO structure
4455 pBssIdInfo = (PBSSID_INFO) ((PUCHAR) pPmkId + 2 * sizeof(UINT) + BssIdx * sizeof(BSSID_INFO));
4456 // Find the entry in the saved data base.
4457 for (CachedIdx = 0; CachedIdx < pAdapter->StaCfg.SavedPMKNum; CachedIdx++)
4459 // compare the BSSID
4460 if (NdisEqualMemory(pBssIdInfo->BSSID, pAdapter->StaCfg.SavedPMK[CachedIdx].BSSID, sizeof(NDIS_802_11_MAC_ADDRESS)))
4464 // Found, replace it
4465 if (CachedIdx < PMKID_NO)
4467 DBGPRINT(RT_DEBUG_OFF, ("Update OID_802_11_PMKID, idx = %d\n", CachedIdx));
4468 NdisMoveMemory(&pAdapter->StaCfg.SavedPMK[CachedIdx], pBssIdInfo, sizeof(BSSID_INFO));
4469 pAdapter->StaCfg.SavedPMKNum++;
4471 // Not found, replace the last one
4474 // Randomly replace one
4475 CachedIdx = (pBssIdInfo->BSSID[5] % PMKID_NO);
4476 DBGPRINT(RT_DEBUG_OFF, ("Update OID_802_11_PMKID, idx = %d\n", CachedIdx));
4477 NdisMoveMemory(&pAdapter->StaCfg.SavedPMK[CachedIdx], pBssIdInfo, sizeof(BSSID_INFO));
4484 #endif // WPA_SUPPLICANT_SUPPORT //
4489 case OID_802_11_SHORTRETRYLIMIT:
4490 if (wrq->u.data.length != sizeof(ULONG))
4494 Status = copy_from_user(&ShortRetryLimit, wrq->u.data.pointer, wrq->u.data.length);
4495 RTMP_IO_READ32(pAdapter, TX_RTY_CFG, &tx_rty_cfg.word);
4496 tx_rty_cfg.field.ShortRtyLimit = ShortRetryLimit;
4497 RTMP_IO_WRITE32(pAdapter, TX_RTY_CFG, tx_rty_cfg.word);
4498 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_SHORTRETRYLIMIT (tx_rty_cfg.field.ShortRetryLimit=%d, ShortRetryLimit=%ld)\n", tx_rty_cfg.field.ShortRtyLimit, ShortRetryLimit));
4502 case OID_802_11_LONGRETRYLIMIT:
4503 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_LONGRETRYLIMIT \n"));
4504 if (wrq->u.data.length != sizeof(ULONG))
4508 Status = copy_from_user(&LongRetryLimit, wrq->u.data.pointer, wrq->u.data.length);
4509 RTMP_IO_READ32(pAdapter, TX_RTY_CFG, &tx_rty_cfg.word);
4510 tx_rty_cfg.field.LongRtyLimit = LongRetryLimit;
4511 RTMP_IO_WRITE32(pAdapter, TX_RTY_CFG, tx_rty_cfg.word);
4512 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_LONGRETRYLIMIT (tx_rty_cfg.field.LongRetryLimit= %d,LongRetryLimit=%ld)\n", tx_rty_cfg.field.LongRtyLimit, LongRetryLimit));
4516 case OID_802_11_WEPDEFAULTKEYVALUE:
4517 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_WEPDEFAULTKEYVALUE\n"));
4518 pKey = kmalloc(wrq->u.data.length, GFP_KERNEL);
4519 Status = copy_from_user(pKey, wrq->u.data.pointer, wrq->u.data.length);
4522 if ( pKey->Length != wrq->u.data.length)
4525 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_WEPDEFAULTKEYVALUE, Failed!!\n"));
4527 KeyIdx = pKey->KeyIndex & 0x0fffffff;
4528 DBGPRINT(RT_DEBUG_TRACE,("pKey->KeyIndex =%d, pKey->KeyLength=%d\n", pKey->KeyIndex, pKey->KeyLength));
4530 // it is a shared key
4535 pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].KeyLen = (UCHAR) pKey->KeyLength;
4536 NdisMoveMemory(&pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].Key, &pKey->KeyMaterial, pKey->KeyLength);
4537 if (pKey->KeyIndex & 0x80000000)
4539 // Default key for tx (shared key)
4540 pAdapter->StaCfg.DefaultKeyId = (UCHAR) KeyIdx;
4542 //RestartAPIsRequired = TRUE;
4547 case OID_802_11_WEPDEFAULTKEYID:
4548 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_WEPDEFAULTKEYID \n"));
4550 if (wrq->u.data.length != sizeof(UCHAR))
4553 Status = copy_from_user(&pAdapter->StaCfg.DefaultKeyId, wrq->u.data.pointer, wrq->u.data.length);
4558 case OID_802_11_CURRENTCHANNEL:
4559 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_CURRENTCHANNEL \n"));
4560 if (wrq->u.data.length != sizeof(UCHAR))
4564 Status = copy_from_user(&ctmp, wrq->u.data.pointer, wrq->u.data.length);
4565 sprintf(&ctmp,"%d", ctmp);
4566 Set_Channel_Proc(pAdapter, &ctmp);
4574 DBGPRINT(RT_DEBUG_TRACE, ("Set::unknown IOCTL's subcmd = 0x%08x\n", cmd));
4575 Status = -EOPNOTSUPP;
4583 INT RTMPQueryInformation(
4584 IN PRTMP_ADAPTER pAdapter,
4585 IN OUT struct ifreq *rq,
4588 struct iwreq *wrq = (struct iwreq *) rq;
4589 NDIS_802_11_BSSID_LIST_EX *pBssidList = NULL;
4590 PNDIS_WLAN_BSSID_EX pBss;
4591 NDIS_802_11_SSID Ssid;
4592 NDIS_802_11_CONFIGURATION *pConfiguration = NULL;
4593 RT_802_11_LINK_STATUS *pLinkStatus = NULL;
4594 RT_802_11_STA_CONFIG *pStaConfig = NULL;
4595 NDIS_802_11_STATISTICS *pStatistics = NULL;
4596 NDIS_802_11_RTS_THRESHOLD RtsThresh;
4597 NDIS_802_11_FRAGMENTATION_THRESHOLD FragThresh;
4598 NDIS_802_11_POWER_MODE PowerMode;
4599 NDIS_802_11_NETWORK_INFRASTRUCTURE BssType;
4600 RT_802_11_PREAMBLE PreamType;
4601 NDIS_802_11_AUTHENTICATION_MODE AuthMode;
4602 NDIS_802_11_WEP_STATUS WepStatus;
4603 NDIS_MEDIA_STATE MediaState;
4604 ULONG BssBufSize, ulInfo=0, NetworkTypeList[4], apsd = 0;
4606 PUCHAR pBuf = NULL, pPtr;
4607 INT Status = NDIS_STATUS_SUCCESS;
4608 UINT we_version_compiled;
4609 UCHAR i, Padding = 0;
4611 UCHAR driverVersion[8];
4612 OID_SET_HT_PHYMODE *pHTPhyMode = NULL;
4617 DefaultKeyIdxValue *pKeyIdxValue;
4619 TX_RTY_CFG_STRUC tx_rty_cfg;
4620 ULONG ShortRetryLimit, LongRetryLimit;
4626 case RT_OID_DEVICE_NAME:
4627 wrq->u.data.length = sizeof(STA_NIC_DEVICE_NAME);
4628 Status = copy_to_user(wrq->u.data.pointer, STA_NIC_DEVICE_NAME, wrq->u.data.length);
4630 case RT_OID_VERSION_INFO:
4631 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_VERSION_INFO \n"));
4632 wrq->u.data.length = 8*sizeof(UCHAR);
4633 sprintf(&driverVersion[0], "%s", STA_DRIVER_VERSION);
4634 driverVersion[7] = '\0';
4635 if (copy_to_user(wrq->u.data.pointer, &driverVersion, wrq->u.data.length))
4641 case RT_QUERY_ATE_TXDONE_COUNT:
4642 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_QUERY_ATE_TXDONE_COUNT \n"));
4643 wrq->u.data.length = sizeof(UINT32);
4644 if (copy_to_user(wrq->u.data.pointer, &pAdapter->ate.TxDoneCount, wrq->u.data.length))
4649 #endif // RALINK_ATE //
4650 case OID_802_11_BSSID_LIST:
4651 if (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
4654 * Still scanning, indicate the caller should try again.
4656 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_BSSID_LIST (Still scanning)\n"));
4659 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_BSSID_LIST (%d BSS returned)\n",pAdapter->ScanTab.BssNr));
4660 pAdapter->StaCfg.bScanReqIsFromWebUI = FALSE;
4661 // Claculate total buffer size required
4662 BssBufSize = sizeof(ULONG);
4664 for (i = 0; i < pAdapter->ScanTab.BssNr; i++)
4666 // Align pointer to 4 bytes boundary.
4667 //Padding = 4 - (pAdapter->ScanTab.BssEntry[i].VarIELen & 0x0003);
4670 BssBufSize += (sizeof(NDIS_WLAN_BSSID_EX) - 1 + sizeof(NDIS_802_11_FIXED_IEs) + pAdapter->ScanTab.BssEntry[i].VarIELen + Padding);
4673 // For safety issue, we add 256 bytes just in case
4675 // Allocate the same size as passed from higher layer
4676 pBuf = kmalloc(BssBufSize, MEM_ALLOC_FLAG);
4682 // Init 802_11_BSSID_LIST_EX structure
4683 NdisZeroMemory(pBuf, BssBufSize);
4684 pBssidList = (PNDIS_802_11_BSSID_LIST_EX) pBuf;
4685 pBssidList->NumberOfItems = pAdapter->ScanTab.BssNr;
4687 // Calculate total buffer length
4688 BssLen = 4; // Consist of NumberOfItems
4689 // Point to start of NDIS_WLAN_BSSID_EX
4690 // pPtr = pBuf + sizeof(ULONG);
4691 pPtr = (PUCHAR) &pBssidList->Bssid[0];
4692 for (i = 0; i < pAdapter->ScanTab.BssNr; i++)
4694 pBss = (PNDIS_WLAN_BSSID_EX) pPtr;
4695 NdisMoveMemory(&pBss->MacAddress, &pAdapter->ScanTab.BssEntry[i].Bssid, MAC_ADDR_LEN);
4696 if ((pAdapter->ScanTab.BssEntry[i].Hidden == 1) && (pAdapter->StaCfg.bShowHiddenSSID == FALSE))
4699 // We must return this SSID during 4way handshaking, otherwise Aegis will failed to parse WPA infomation
4700 // and then failed to send EAPOl farame.
4702 if ((pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA) && (pAdapter->StaCfg.PortSecured != WPA_802_1X_PORT_SECURED))
4704 pBss->Ssid.SsidLength = pAdapter->ScanTab.BssEntry[i].SsidLen;
4705 NdisMoveMemory(pBss->Ssid.Ssid, pAdapter->ScanTab.BssEntry[i].Ssid, pAdapter->ScanTab.BssEntry[i].SsidLen);
4708 pBss->Ssid.SsidLength = 0;
4712 pBss->Ssid.SsidLength = pAdapter->ScanTab.BssEntry[i].SsidLen;
4713 NdisMoveMemory(pBss->Ssid.Ssid, pAdapter->ScanTab.BssEntry[i].Ssid, pAdapter->ScanTab.BssEntry[i].SsidLen);
4715 pBss->Privacy = pAdapter->ScanTab.BssEntry[i].Privacy;
4716 pBss->Rssi = pAdapter->ScanTab.BssEntry[i].Rssi - pAdapter->BbpRssiToDbmDelta;
4717 pBss->NetworkTypeInUse = NetworkTypeInUseSanity(&pAdapter->ScanTab.BssEntry[i]);
4718 pBss->Configuration.Length = sizeof(NDIS_802_11_CONFIGURATION);
4719 pBss->Configuration.BeaconPeriod = pAdapter->ScanTab.BssEntry[i].BeaconPeriod;
4720 pBss->Configuration.ATIMWindow = pAdapter->ScanTab.BssEntry[i].AtimWin;
4722 MAP_CHANNEL_ID_TO_KHZ(pAdapter->ScanTab.BssEntry[i].Channel, pBss->Configuration.DSConfig);
4724 if (pAdapter->ScanTab.BssEntry[i].BssType == BSS_INFRA)
4725 pBss->InfrastructureMode = Ndis802_11Infrastructure;
4727 pBss->InfrastructureMode = Ndis802_11IBSS;
4729 NdisMoveMemory(pBss->SupportedRates, pAdapter->ScanTab.BssEntry[i].SupRate, pAdapter->ScanTab.BssEntry[i].SupRateLen);
4730 NdisMoveMemory(pBss->SupportedRates + pAdapter->ScanTab.BssEntry[i].SupRateLen,
4731 pAdapter->ScanTab.BssEntry[i].ExtRate,
4732 pAdapter->ScanTab.BssEntry[i].ExtRateLen);
4734 if (pAdapter->ScanTab.BssEntry[i].VarIELen == 0)
4736 pBss->IELength = sizeof(NDIS_802_11_FIXED_IEs);
4737 NdisMoveMemory(pBss->IEs, &pAdapter->ScanTab.BssEntry[i].FixIEs, sizeof(NDIS_802_11_FIXED_IEs));
4738 pPtr = pPtr + sizeof(NDIS_WLAN_BSSID_EX) - 1 + sizeof(NDIS_802_11_FIXED_IEs);
4742 pBss->IELength = (ULONG)(sizeof(NDIS_802_11_FIXED_IEs) + pAdapter->ScanTab.BssEntry[i].VarIELen);
4743 pPtr = pPtr + sizeof(NDIS_WLAN_BSSID_EX) - 1 + sizeof(NDIS_802_11_FIXED_IEs);
4744 NdisMoveMemory(pBss->IEs, &pAdapter->ScanTab.BssEntry[i].FixIEs, sizeof(NDIS_802_11_FIXED_IEs));
4745 NdisMoveMemory(pBss->IEs + sizeof(NDIS_802_11_FIXED_IEs), pAdapter->ScanTab.BssEntry[i].VarIEs, pAdapter->ScanTab.BssEntry[i].VarIELen);
4746 pPtr += pAdapter->ScanTab.BssEntry[i].VarIELen;
4748 pBss->Length = (ULONG)(sizeof(NDIS_WLAN_BSSID_EX) - 1 + sizeof(NDIS_802_11_FIXED_IEs) + pAdapter->ScanTab.BssEntry[i].VarIELen + Padding);
4750 #if WIRELESS_EXT < 17
4751 if ((BssLen + pBss->Length) < wrq->u.data.length)
4752 BssLen += pBss->Length;
4755 pBssidList->NumberOfItems = i;
4759 BssLen += pBss->Length;
4763 #if WIRELESS_EXT < 17
4764 wrq->u.data.length = BssLen;
4766 if (BssLen > wrq->u.data.length)
4772 wrq->u.data.length = BssLen;
4774 Status = copy_to_user(wrq->u.data.pointer, pBssidList, BssLen);
4777 case OID_802_3_CURRENT_ADDRESS:
4778 wrq->u.data.length = MAC_ADDR_LEN;
4779 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CurrentAddress, wrq->u.data.length);
4781 case OID_GEN_MEDIA_CONNECT_STATUS:
4782 if (pAdapter->IndicateMediaState == NdisMediaStateConnected)
4783 MediaState = NdisMediaStateConnected;
4785 MediaState = NdisMediaStateDisconnected;
4787 wrq->u.data.length = sizeof(NDIS_MEDIA_STATE);
4788 Status = copy_to_user(wrq->u.data.pointer, &MediaState, wrq->u.data.length);
4790 case OID_802_11_BSSID:
4792 if (ATE_ON(pAdapter))
4794 DBGPRINT(RT_DEBUG_TRACE, ("The driver is in ATE mode now\n"));
4795 Status = NDIS_STATUS_RESOURCES;
4798 #endif // RALINK_ATE //
4799 if (INFRA_ON(pAdapter) || ADHOC_ON(pAdapter))
4801 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.Bssid, sizeof(NDIS_802_11_MAC_ADDRESS));
4806 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_BSSID(=EMPTY)\n"));
4810 case OID_802_11_SSID:
4811 NdisZeroMemory(&Ssid, sizeof(NDIS_802_11_SSID));
4812 NdisZeroMemory(Ssid.Ssid, MAX_LEN_OF_SSID);
4813 Ssid.SsidLength = pAdapter->CommonCfg.SsidLen;
4814 memcpy(Ssid.Ssid, pAdapter->CommonCfg.Ssid, Ssid.SsidLength);
4815 wrq->u.data.length = sizeof(NDIS_802_11_SSID);
4816 Status = copy_to_user(wrq->u.data.pointer, &Ssid, wrq->u.data.length);
4817 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_SSID (Len=%d, ssid=%s)\n", Ssid.SsidLength,Ssid.Ssid));
4819 case RT_OID_802_11_QUERY_LINK_STATUS:
4820 pLinkStatus = (RT_802_11_LINK_STATUS *) kmalloc(sizeof(RT_802_11_LINK_STATUS), MEM_ALLOC_FLAG);
4823 pLinkStatus->CurrTxRate = RateIdTo500Kbps[pAdapter->CommonCfg.TxRate]; // unit : 500 kbps
4824 pLinkStatus->ChannelQuality = pAdapter->Mlme.ChannelQuality;
4825 pLinkStatus->RxByteCount = pAdapter->RalinkCounters.ReceivedByteCount;
4826 pLinkStatus->TxByteCount = pAdapter->RalinkCounters.TransmittedByteCount;
4827 pLinkStatus->CentralChannel = pAdapter->CommonCfg.CentralChannel;
4828 wrq->u.data.length = sizeof(RT_802_11_LINK_STATUS);
4829 Status = copy_to_user(wrq->u.data.pointer, pLinkStatus, wrq->u.data.length);
4831 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_LINK_STATUS\n"));
4835 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_LINK_STATUS(kmalloc failed)\n"));
4839 case OID_802_11_CONFIGURATION:
4840 pConfiguration = (NDIS_802_11_CONFIGURATION *) kmalloc(sizeof(NDIS_802_11_CONFIGURATION), MEM_ALLOC_FLAG);
4843 pConfiguration->Length = sizeof(NDIS_802_11_CONFIGURATION);
4844 pConfiguration->BeaconPeriod = pAdapter->CommonCfg.BeaconPeriod;
4845 pConfiguration->ATIMWindow = pAdapter->StaActive.AtimWin;
4846 MAP_CHANNEL_ID_TO_KHZ(pAdapter->CommonCfg.Channel, pConfiguration->DSConfig);
4847 wrq->u.data.length = sizeof(NDIS_802_11_CONFIGURATION);
4848 Status = copy_to_user(wrq->u.data.pointer, pConfiguration, wrq->u.data.length);
4849 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_CONFIGURATION(BeaconPeriod=%ld,AtimW=%ld,Channel=%d) \n",
4850 pConfiguration->BeaconPeriod, pConfiguration->ATIMWindow, pAdapter->CommonCfg.Channel));
4851 kfree(pConfiguration);
4855 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_CONFIGURATION(kmalloc failed)\n"));
4859 case RT_OID_802_11_SNR_0:
4860 if ((pAdapter->StaCfg.LastSNR0 > 0))
4862 ulInfo = ((0xeb - pAdapter->StaCfg.LastSNR0) * 3) / 16 ;
4863 wrq->u.data.length = sizeof(ulInfo);
4864 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4865 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_SNR_0(0x=%lx)\n", ulInfo));
4870 case RT_OID_802_11_SNR_1:
4871 if ((pAdapter->Antenna.field.RxPath > 1) &&
4872 (pAdapter->StaCfg.LastSNR1 > 0))
4874 ulInfo = ((0xeb - pAdapter->StaCfg.LastSNR1) * 3) / 16 ;
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_SNR_1(0x=%lx)\n",ulInfo));
4881 DBGPRINT(RT_DEBUG_TRACE,("Query::RT_OID_802_11_SNR_1(pAdapter->StaCfg.LastSNR1=%d)\n",pAdapter->StaCfg.LastSNR1));
4883 case OID_802_11_RSSI_TRIGGER:
4884 ulInfo = pAdapter->StaCfg.RssiSample.LastRssi0 - pAdapter->BbpRssiToDbmDelta;
4885 wrq->u.data.length = sizeof(ulInfo);
4886 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4887 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_RSSI_TRIGGER(=%ld)\n", ulInfo));
4889 case OID_802_11_RSSI:
4890 case RT_OID_802_11_RSSI:
4891 ulInfo = pAdapter->StaCfg.RssiSample.LastRssi0;
4892 wrq->u.data.length = sizeof(ulInfo);
4893 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4895 case RT_OID_802_11_RSSI_1:
4896 ulInfo = pAdapter->StaCfg.RssiSample.LastRssi1;
4897 wrq->u.data.length = sizeof(ulInfo);
4898 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4900 case RT_OID_802_11_RSSI_2:
4901 ulInfo = pAdapter->StaCfg.RssiSample.LastRssi2;
4902 wrq->u.data.length = sizeof(ulInfo);
4903 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4905 case OID_802_11_STATISTICS:
4906 pStatistics = (NDIS_802_11_STATISTICS *) kmalloc(sizeof(NDIS_802_11_STATISTICS), MEM_ALLOC_FLAG);
4909 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_STATISTICS \n"));
4910 // add the most up-to-date h/w raw counters into software counters
4911 NICUpdateRawCounters(pAdapter);
4913 // Sanity check for calculation of sucessful count
4914 if (pAdapter->WlanCounters.TransmittedFragmentCount.QuadPart < pAdapter->WlanCounters.RetryCount.QuadPart)
4915 pAdapter->WlanCounters.TransmittedFragmentCount.QuadPart = pAdapter->WlanCounters.RetryCount.QuadPart;
4917 pStatistics->TransmittedFragmentCount.QuadPart = pAdapter->WlanCounters.TransmittedFragmentCount.QuadPart;
4918 pStatistics->MulticastTransmittedFrameCount.QuadPart = pAdapter->WlanCounters.MulticastTransmittedFrameCount.QuadPart;
4919 pStatistics->FailedCount.QuadPart = pAdapter->WlanCounters.FailedCount.QuadPart;
4920 pStatistics->RetryCount.QuadPart = pAdapter->WlanCounters.RetryCount.QuadPart;
4921 pStatistics->MultipleRetryCount.QuadPart = pAdapter->WlanCounters.MultipleRetryCount.QuadPart;
4922 pStatistics->RTSSuccessCount.QuadPart = pAdapter->WlanCounters.RTSSuccessCount.QuadPart;
4923 pStatistics->RTSFailureCount.QuadPart = pAdapter->WlanCounters.RTSFailureCount.QuadPart;
4924 pStatistics->ACKFailureCount.QuadPart = pAdapter->WlanCounters.ACKFailureCount.QuadPart;
4925 pStatistics->FrameDuplicateCount.QuadPart = pAdapter->WlanCounters.FrameDuplicateCount.QuadPart;
4926 pStatistics->ReceivedFragmentCount.QuadPart = pAdapter->WlanCounters.ReceivedFragmentCount.QuadPart;
4927 pStatistics->MulticastReceivedFrameCount.QuadPart = pAdapter->WlanCounters.MulticastReceivedFrameCount.QuadPart;
4929 pStatistics->FCSErrorCount = pAdapter->RalinkCounters.RealFcsErrCount;
4931 pStatistics->FCSErrorCount.QuadPart = pAdapter->WlanCounters.FCSErrorCount.QuadPart;
4932 pStatistics->FrameDuplicateCount.u.LowPart = pAdapter->WlanCounters.FrameDuplicateCount.u.LowPart / 100;
4934 wrq->u.data.length = sizeof(NDIS_802_11_STATISTICS);
4935 Status = copy_to_user(wrq->u.data.pointer, pStatistics, wrq->u.data.length);
4940 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_STATISTICS(kmalloc failed)\n"));
4944 case OID_GEN_RCV_OK:
4945 ulInfo = pAdapter->Counters8023.GoodReceives;
4946 wrq->u.data.length = sizeof(ulInfo);
4947 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4949 case OID_GEN_RCV_NO_BUFFER:
4950 ulInfo = pAdapter->Counters8023.RxNoBuffer;
4951 wrq->u.data.length = sizeof(ulInfo);
4952 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4954 case RT_OID_802_11_PHY_MODE:
4955 ulInfo = (ULONG)pAdapter->CommonCfg.PhyMode;
4956 wrq->u.data.length = sizeof(ulInfo);
4957 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4958 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_PHY_MODE (=%ld)\n", ulInfo));
4960 case RT_OID_802_11_STA_CONFIG:
4961 pStaConfig = (RT_802_11_STA_CONFIG *) kmalloc(sizeof(RT_802_11_STA_CONFIG), MEM_ALLOC_FLAG);
4964 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_STA_CONFIG\n"));
4965 pStaConfig->EnableTxBurst = pAdapter->CommonCfg.bEnableTxBurst;
4966 pStaConfig->EnableTurboRate = 0;
4967 pStaConfig->UseBGProtection = pAdapter->CommonCfg.UseBGProtection;
4968 pStaConfig->UseShortSlotTime = pAdapter->CommonCfg.bUseShortSlotTime;
4969 //pStaConfig->AdhocMode = pAdapter->StaCfg.AdhocMode;
4970 pStaConfig->HwRadioStatus = (pAdapter->StaCfg.bHwRadio == TRUE) ? 1 : 0;
4971 pStaConfig->Rsv1 = 0;
4972 pStaConfig->SystemErrorBitmap = pAdapter->SystemErrorBitmap;
4973 wrq->u.data.length = sizeof(RT_802_11_STA_CONFIG);
4974 Status = copy_to_user(wrq->u.data.pointer, pStaConfig, wrq->u.data.length);
4979 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_STA_CONFIG(kmalloc failed)\n"));
4983 case OID_802_11_RTS_THRESHOLD:
4984 RtsThresh = pAdapter->CommonCfg.RtsThreshold;
4985 wrq->u.data.length = sizeof(RtsThresh);
4986 Status = copy_to_user(wrq->u.data.pointer, &RtsThresh, wrq->u.data.length);
4987 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_RTS_THRESHOLD(=%ld)\n", RtsThresh));
4989 case OID_802_11_FRAGMENTATION_THRESHOLD:
4990 FragThresh = pAdapter->CommonCfg.FragmentThreshold;
4991 if (pAdapter->CommonCfg.bUseZeroToDisableFragment == TRUE)
4993 wrq->u.data.length = sizeof(FragThresh);
4994 Status = copy_to_user(wrq->u.data.pointer, &FragThresh, wrq->u.data.length);
4995 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_FRAGMENTATION_THRESHOLD(=%ld)\n", FragThresh));
4997 case OID_802_11_POWER_MODE:
4998 PowerMode = pAdapter->StaCfg.WindowsPowerMode;
4999 wrq->u.data.length = sizeof(PowerMode);
5000 Status = copy_to_user(wrq->u.data.pointer, &PowerMode, wrq->u.data.length);
5001 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_POWER_MODE(=%d)\n", PowerMode));
5003 case RT_OID_802_11_RADIO:
5004 RadioState = (BOOLEAN) pAdapter->StaCfg.bSwRadio;
5005 wrq->u.data.length = sizeof(RadioState);
5006 Status = copy_to_user(wrq->u.data.pointer, &RadioState, wrq->u.data.length);
5007 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_RADIO (=%d)\n", RadioState));
5009 case OID_802_11_INFRASTRUCTURE_MODE:
5010 if (pAdapter->StaCfg.BssType == BSS_ADHOC)
5011 BssType = Ndis802_11IBSS;
5012 else if (pAdapter->StaCfg.BssType == BSS_INFRA)
5013 BssType = Ndis802_11Infrastructure;
5014 else if (pAdapter->StaCfg.BssType == BSS_MONITOR)
5015 BssType = Ndis802_11Monitor;
5017 BssType = Ndis802_11AutoUnknown;
5019 wrq->u.data.length = sizeof(BssType);
5020 Status = copy_to_user(wrq->u.data.pointer, &BssType, wrq->u.data.length);
5021 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_INFRASTRUCTURE_MODE(=%d)\n", BssType));
5023 case RT_OID_802_11_PREAMBLE:
5024 PreamType = pAdapter->CommonCfg.TxPreamble;
5025 wrq->u.data.length = sizeof(PreamType);
5026 Status = copy_to_user(wrq->u.data.pointer, &PreamType, wrq->u.data.length);
5027 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_PREAMBLE(=%d)\n", PreamType));
5029 case OID_802_11_AUTHENTICATION_MODE:
5030 AuthMode = pAdapter->StaCfg.AuthMode;
5031 wrq->u.data.length = sizeof(AuthMode);
5032 Status = copy_to_user(wrq->u.data.pointer, &AuthMode, wrq->u.data.length);
5033 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_AUTHENTICATION_MODE(=%d)\n", AuthMode));
5035 case OID_802_11_WEP_STATUS:
5036 WepStatus = pAdapter->StaCfg.WepStatus;
5037 wrq->u.data.length = sizeof(WepStatus);
5038 Status = copy_to_user(wrq->u.data.pointer, &WepStatus, wrq->u.data.length);
5039 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_WEP_STATUS(=%d)\n", WepStatus));
5041 case OID_802_11_TX_POWER_LEVEL:
5042 wrq->u.data.length = sizeof(ULONG);
5043 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.TxPower, wrq->u.data.length);
5044 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_TX_POWER_LEVEL %x\n",pAdapter->CommonCfg.TxPower));
5046 case RT_OID_802_11_TX_POWER_LEVEL_1:
5047 wrq->u.data.length = sizeof(ULONG);
5048 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.TxPowerPercentage, wrq->u.data.length);
5049 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_TX_POWER_LEVEL_1 (=%ld)\n", pAdapter->CommonCfg.TxPowerPercentage));
5051 case OID_802_11_NETWORK_TYPES_SUPPORTED:
5052 if ((pAdapter->RfIcType == RFIC_2850) || (pAdapter->RfIcType == RFIC_2750))
5054 NetworkTypeList[0] = 3; // NumberOfItems = 3
5055 NetworkTypeList[1] = Ndis802_11DS; // NetworkType[1] = 11b
5056 NetworkTypeList[2] = Ndis802_11OFDM24; // NetworkType[2] = 11g
5057 NetworkTypeList[3] = Ndis802_11OFDM5; // NetworkType[3] = 11a
5058 wrq->u.data.length = 16;
5059 Status = copy_to_user(wrq->u.data.pointer, &NetworkTypeList[0], wrq->u.data.length);
5063 NetworkTypeList[0] = 2; // NumberOfItems = 2
5064 NetworkTypeList[1] = Ndis802_11DS; // NetworkType[1] = 11b
5065 NetworkTypeList[2] = Ndis802_11OFDM24; // NetworkType[2] = 11g
5066 wrq->u.data.length = 12;
5067 Status = copy_to_user(wrq->u.data.pointer, &NetworkTypeList[0], wrq->u.data.length);
5069 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_NETWORK_TYPES_SUPPORTED\n"));
5071 case OID_802_11_NETWORK_TYPE_IN_USE:
5072 wrq->u.data.length = sizeof(ULONG);
5073 if (pAdapter->CommonCfg.PhyMode == PHY_11A)
5074 ulInfo = Ndis802_11OFDM5;
5075 else if ((pAdapter->CommonCfg.PhyMode == PHY_11BG_MIXED) || (pAdapter->CommonCfg.PhyMode == PHY_11G))
5076 ulInfo = Ndis802_11OFDM24;
5078 ulInfo = Ndis802_11DS;
5079 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
5081 case RT_OID_802_11_QUERY_LAST_RX_RATE:
5082 ulInfo = (ULONG)pAdapter->LastRxRate;
5083 wrq->u.data.length = sizeof(ulInfo);
5084 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
5085 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_LAST_RX_RATE (=%ld)\n", ulInfo));
5087 case RT_OID_802_11_QUERY_LAST_TX_RATE:
5088 //ulInfo = (ULONG)pAdapter->LastTxRate;
5089 ulInfo = (ULONG)pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.word;
5090 wrq->u.data.length = sizeof(ulInfo);
5091 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
5092 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_LAST_TX_RATE (=%lx)\n", ulInfo));
5094 case RT_OID_802_11_QUERY_EEPROM_VERSION:
5095 wrq->u.data.length = sizeof(ULONG);
5096 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->EepromVersion, wrq->u.data.length);
5098 case RT_OID_802_11_QUERY_FIRMWARE_VERSION:
5099 wrq->u.data.length = sizeof(ULONG);
5100 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->FirmwareVersion, wrq->u.data.length);
5102 case RT_OID_802_11_QUERY_NOISE_LEVEL:
5103 wrq->u.data.length = sizeof(UCHAR);
5104 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->BbpWriteLatch[66], wrq->u.data.length);
5105 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_NOISE_LEVEL (=%d)\n", pAdapter->BbpWriteLatch[66]));
5107 case RT_OID_802_11_EXTRA_INFO:
5108 wrq->u.data.length = sizeof(ULONG);
5109 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->ExtraInfo, wrq->u.data.length);
5110 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_EXTRA_INFO (=%ld)\n", pAdapter->ExtraInfo));
5112 case RT_OID_WE_VERSION_COMPILED:
5113 wrq->u.data.length = sizeof(UINT);
5114 we_version_compiled = WIRELESS_EXT;
5115 Status = copy_to_user(wrq->u.data.pointer, &we_version_compiled, wrq->u.data.length);
5117 case RT_OID_802_11_QUERY_APSD_SETTING:
5118 apsd = (pAdapter->CommonCfg.bAPSDCapable | (pAdapter->CommonCfg.bAPSDAC_BE << 1) | (pAdapter->CommonCfg.bAPSDAC_BK << 2)
5119 | (pAdapter->CommonCfg.bAPSDAC_VI << 3) | (pAdapter->CommonCfg.bAPSDAC_VO << 4) | (pAdapter->CommonCfg.MaxSPLength << 5));
5121 wrq->u.data.length = sizeof(ULONG);
5122 Status = copy_to_user(wrq->u.data.pointer, &apsd, wrq->u.data.length);
5123 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",
5124 apsd,pAdapter->CommonCfg.bAPSDCapable,pAdapter->CommonCfg.bAPSDAC_BE,pAdapter->CommonCfg.bAPSDAC_BK,pAdapter->CommonCfg.bAPSDAC_VI,pAdapter->CommonCfg.bAPSDAC_VO,pAdapter->CommonCfg.MaxSPLength));
5126 case RT_OID_802_11_QUERY_APSD_PSM:
5127 wrq->u.data.length = sizeof(ULONG);
5128 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.bAPSDForcePowerSave, wrq->u.data.length);
5129 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_APSD_PSM (=%d)\n", pAdapter->CommonCfg.bAPSDForcePowerSave));
5131 case RT_OID_802_11_QUERY_WMM:
5132 wrq->u.data.length = sizeof(BOOLEAN);
5133 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.bWmmCapable, wrq->u.data.length);
5134 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_WMM (=%d)\n", pAdapter->CommonCfg.bWmmCapable));
5136 #ifdef WPA_SUPPLICANT_SUPPORT
5137 case RT_OID_NEW_DRIVER:
5140 wrq->u.data.length = sizeof(UCHAR);
5141 Status = copy_to_user(wrq->u.data.pointer, &enabled, wrq->u.data.length);
5142 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_NEW_DRIVER (=%d)\n", enabled));
5145 case RT_OID_WPA_SUPPLICANT_SUPPORT:
5146 wrq->u.data.length = sizeof(UCHAR);
5147 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->StaCfg.WpaSupplicantUP, wrq->u.data.length);
5148 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_WPA_SUPPLICANT_SUPPORT (=%d)\n", pAdapter->StaCfg.WpaSupplicantUP));
5150 #endif // WPA_SUPPLICANT_SUPPORT //
5152 case RT_OID_DRIVER_DEVICE_NAME:
5153 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_DRIVER_DEVICE_NAME \n"));
5154 wrq->u.data.length = 16;
5155 if (copy_to_user(wrq->u.data.pointer, pAdapter->StaCfg.dev_name, wrq->u.data.length))
5160 case RT_OID_802_11_QUERY_HT_PHYMODE:
5161 pHTPhyMode = (OID_SET_HT_PHYMODE *) kmalloc(sizeof(OID_SET_HT_PHYMODE), MEM_ALLOC_FLAG);
5164 pHTPhyMode->PhyMode = pAdapter->CommonCfg.PhyMode;
5165 pHTPhyMode->HtMode = (UCHAR)pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.field.MODE;
5166 pHTPhyMode->BW = (UCHAR)pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.field.BW;
5167 pHTPhyMode->MCS= (UCHAR)pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.field.MCS;
5168 pHTPhyMode->SHORTGI= (UCHAR)pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.field.ShortGI;
5169 pHTPhyMode->STBC= (UCHAR)pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.field.STBC;
5171 pHTPhyMode->ExtOffset = ((pAdapter->CommonCfg.CentralChannel < pAdapter->CommonCfg.Channel) ? (EXTCHA_BELOW) : (EXTCHA_ABOVE));
5172 wrq->u.data.length = sizeof(OID_SET_HT_PHYMODE);
5173 if (copy_to_user(wrq->u.data.pointer, pHTPhyMode, wrq->u.data.length))
5177 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_HT_PHYMODE (PhyMode = %d, MCS =%d, BW = %d, STBC = %d, ExtOffset=%d)\n",
5178 pHTPhyMode->HtMode, pHTPhyMode->MCS, pHTPhyMode->BW, pHTPhyMode->STBC, pHTPhyMode->ExtOffset));
5179 DBGPRINT(RT_DEBUG_TRACE, (" MlmeUpdateTxRates (.word = %x )\n", pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.word));
5183 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_STA_CONFIG(kmalloc failed)\n"));
5187 case RT_OID_802_11_COUNTRY_REGION:
5188 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_COUNTRY_REGION \n"));
5189 wrq->u.data.length = sizeof(ulInfo);
5190 ulInfo = pAdapter->CommonCfg.CountryRegionForABand;
5191 ulInfo = (ulInfo << 8)|(pAdapter->CommonCfg.CountryRegion);
5192 if (copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length))
5197 case RT_OID_802_11_QUERY_DAT_HT_PHYMODE:
5198 pHTPhyMode = (OID_SET_HT_PHYMODE *) kmalloc(sizeof(OID_SET_HT_PHYMODE), MEM_ALLOC_FLAG);
5201 pHTPhyMode->PhyMode = pAdapter->CommonCfg.PhyMode;
5202 pHTPhyMode->HtMode = (UCHAR)pAdapter->CommonCfg.RegTransmitSetting.field.HTMODE;
5203 pHTPhyMode->BW = (UCHAR)pAdapter->CommonCfg.RegTransmitSetting.field.BW;
5204 pHTPhyMode->MCS= (UCHAR)pAdapter->StaCfg.DesiredTransmitSetting.field.MCS;
5205 pHTPhyMode->SHORTGI= (UCHAR)pAdapter->CommonCfg.RegTransmitSetting.field.ShortGI;
5206 pHTPhyMode->STBC= (UCHAR)pAdapter->CommonCfg.RegTransmitSetting.field.STBC;
5208 wrq->u.data.length = sizeof(OID_SET_HT_PHYMODE);
5209 if (copy_to_user(wrq->u.data.pointer, pHTPhyMode, wrq->u.data.length))
5213 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_HT_PHYMODE (PhyMode = %d, MCS =%d, BW = %d, STBC = %d, ExtOffset=%d)\n",
5214 pHTPhyMode->HtMode, pHTPhyMode->MCS, pHTPhyMode->BW, pHTPhyMode->STBC, pHTPhyMode->ExtOffset));
5215 DBGPRINT(RT_DEBUG_TRACE, (" MlmeUpdateTxRates (.word = %x )\n", pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.word));
5219 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_STA_CONFIG(kmalloc failed)\n"));
5223 case RT_OID_QUERY_MULTIPLE_CARD_SUPPORT:
5224 wrq->u.data.length = sizeof(UCHAR);
5226 #ifdef MULTIPLE_CARD_SUPPORT
5228 #endif // MULTIPLE_CARD_SUPPORT //
5229 if (copy_to_user(wrq->u.data.pointer, &i, wrq->u.data.length))
5233 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_QUERY_MULTIPLE_CARD_SUPPORT(=%d) \n", i));
5236 case RT_OID_802_11_MAC_ADDRESS:
5237 wrq->u.data.length = MAC_ADDR_LEN;
5238 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CurrentAddress, wrq->u.data.length);
5241 case RT_OID_802_11_MANUFACTUREROUI:
5242 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_MANUFACTUREROUI \n"));
5243 wrq->u.data.length = ManufacturerOUI_LEN;
5244 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CurrentAddress, wrq->u.data.length);
5247 case RT_OID_802_11_MANUFACTURERNAME:
5248 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_MANUFACTURERNAME \n"));
5249 wrq->u.data.length = strlen(ManufacturerNAME);
5250 Status = copy_to_user(wrq->u.data.pointer, ManufacturerNAME, wrq->u.data.length);
5253 case RT_OID_802_11_RESOURCETYPEIDNAME:
5254 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_RESOURCETYPEIDNAME \n"));
5255 wrq->u.data.length = strlen(ResourceTypeIdName);
5256 Status = copy_to_user(wrq->u.data.pointer, ResourceTypeIdName, wrq->u.data.length);
5259 case RT_OID_802_11_PRIVACYOPTIONIMPLEMENTED:
5260 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_PRIVACYOPTIONIMPLEMENTED \n"));
5261 ulInfo = 1; // 1 is support wep else 2 is not support.
5262 wrq->u.data.length = sizeof(ulInfo);
5263 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
5266 case RT_OID_802_11_POWERMANAGEMENTMODE:
5267 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_POWERMANAGEMENTMODE \n"));
5268 if (pAdapter->StaCfg.Psm == PSMP_ACTION)
5269 ulInfo = 1; // 1 is power active else 2 is power save.
5273 wrq->u.data.length = sizeof(ulInfo);
5274 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
5277 case OID_802_11_WEPDEFAULTKEYVALUE:
5278 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_WEPDEFAULTKEYVALUE \n"));
5279 //KeyIdxValue.KeyIdx = pAd->PortCfg.MBSSID[pAd->IoctlIF].DefaultKeyId;
5280 pKeyIdxValue = wrq->u.data.pointer;
5281 DBGPRINT(RT_DEBUG_TRACE,("KeyIdxValue.KeyIdx = %d, \n",pKeyIdxValue->KeyIdx));
5282 valueLen = pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].KeyLen;
5283 NdisMoveMemory(pKeyIdxValue->Value,
5284 &pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].Key,
5286 pKeyIdxValue->Value[valueLen]='\0';
5288 wrq->u.data.length = sizeof(DefaultKeyIdxValue);
5290 Status = copy_to_user(wrq->u.data.pointer, pKeyIdxValue, wrq->u.data.length);
5291 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,
5292 pAdapter->SharedKey[BSS0][0].Key[0],
5293 pAdapter->SharedKey[BSS0][1].Key[0],
5294 pAdapter->SharedKey[BSS0][2].Key[0],
5295 pAdapter->SharedKey[BSS0][3].Key[0]));
5298 case OID_802_11_WEPDEFAULTKEYID:
5299 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_WEPDEFAULTKEYID \n"));
5300 wrq->u.data.length = sizeof(UCHAR);
5301 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->StaCfg.DefaultKeyId, wrq->u.data.length);
5302 DBGPRINT(RT_DEBUG_TRACE, ("DefaultKeyId =%d \n", pAdapter->StaCfg.DefaultKeyId));
5305 case RT_OID_802_11_WEPKEYMAPPINGLENGTH:
5306 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_WEPKEYMAPPINGLENGTH \n"));
5307 wrq->u.data.length = sizeof(UCHAR);
5308 Status = copy_to_user(wrq->u.data.pointer,
5309 &pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].KeyLen,
5310 wrq->u.data.length);
5313 case OID_802_11_SHORTRETRYLIMIT:
5314 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_SHORTRETRYLIMIT \n"));
5315 wrq->u.data.length = sizeof(ULONG);
5316 RTMP_IO_READ32(pAdapter, TX_RTY_CFG, &tx_rty_cfg.word);
5317 ShortRetryLimit = tx_rty_cfg.field.ShortRtyLimit;
5318 DBGPRINT(RT_DEBUG_TRACE, ("ShortRetryLimit =%ld, tx_rty_cfg.field.ShortRetryLimit=%d\n", ShortRetryLimit, tx_rty_cfg.field.ShortRtyLimit));
5319 Status = copy_to_user(wrq->u.data.pointer, &ShortRetryLimit, wrq->u.data.length);
5322 case OID_802_11_LONGRETRYLIMIT:
5323 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_LONGRETRYLIMIT \n"));
5324 wrq->u.data.length = sizeof(ULONG);
5325 RTMP_IO_READ32(pAdapter, TX_RTY_CFG, &tx_rty_cfg.word);
5326 LongRetryLimit = tx_rty_cfg.field.LongRtyLimit;
5327 DBGPRINT(RT_DEBUG_TRACE, ("LongRetryLimit =%ld, tx_rty_cfg.field.LongRtyLimit=%d\n", LongRetryLimit, tx_rty_cfg.field.LongRtyLimit));
5328 Status = copy_to_user(wrq->u.data.pointer, &LongRetryLimit, wrq->u.data.length);
5331 case RT_OID_802_11_PRODUCTID:
5332 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_PRODUCTID \n"));
5335 sprintf(tmp, "%04x %04x\n", ((POS_COOKIE)pAdapter->OS_Cookie)->pUsb_Dev->descriptor.idVendor ,((POS_COOKIE)pAdapter->OS_Cookie)->pUsb_Dev->descriptor.idProduct);
5338 wrq->u.data.length = strlen(tmp);
5339 Status = copy_to_user(wrq->u.data.pointer, tmp, wrq->u.data.length);
5342 case RT_OID_802_11_MANUFACTUREID:
5343 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_MANUFACTUREID \n"));
5344 wrq->u.data.length = strlen(ManufacturerNAME);
5345 Status = copy_to_user(wrq->u.data.pointer, ManufacturerNAME, wrq->u.data.length);
5348 case OID_802_11_CURRENTCHANNEL:
5349 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_CURRENTCHANNEL \n"));
5350 wrq->u.data.length = sizeof(UCHAR);
5351 DBGPRINT(RT_DEBUG_TRACE, ("sizeof UCHAR=%d, channel=%d \n", sizeof(UCHAR), pAdapter->CommonCfg.Channel));
5352 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.Channel, wrq->u.data.length);
5353 DBGPRINT(RT_DEBUG_TRACE, ("Status=%d\n", Status));
5355 #endif //SNMP_SUPPORT
5357 case OID_802_11_BUILD_CHANNEL_EX:
5360 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_BUILD_CHANNEL_EX \n"));
5361 wrq->u.data.length = sizeof(UCHAR);
5362 #ifdef EXT_BUILD_CHANNEL_LIST
5363 DBGPRINT(RT_DEBUG_TRACE, ("Support EXT_BUILD_CHANNEL_LIST.\n"));
5366 DBGPRINT(RT_DEBUG_TRACE, ("Doesn't support EXT_BUILD_CHANNEL_LIST.\n"));
5368 #endif // EXT_BUILD_CHANNEL_LIST //
5369 Status = copy_to_user(wrq->u.data.pointer, &value, 1);
5370 DBGPRINT(RT_DEBUG_TRACE, ("Status=%d\n", Status));
5374 case OID_802_11_GET_CH_LIST:
5376 PRT_CHANNEL_LIST_INFO pChListBuf;
5378 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_GET_CH_LIST \n"));
5379 if (pAdapter->ChannelListNum == 0)
5381 wrq->u.data.length = 0;
5385 pChListBuf = (RT_CHANNEL_LIST_INFO *) kmalloc(sizeof(RT_CHANNEL_LIST_INFO), MEM_ALLOC_FLAG);
5386 if (pChListBuf == NULL)
5388 wrq->u.data.length = 0;
5392 pChListBuf->ChannelListNum = pAdapter->ChannelListNum;
5393 for (i = 0; i < pChListBuf->ChannelListNum; i++)
5394 pChListBuf->ChannelList[i] = pAdapter->ChannelList[i].Channel;
5396 wrq->u.data.length = sizeof(RT_CHANNEL_LIST_INFO);
5397 Status = copy_to_user(wrq->u.data.pointer, pChListBuf, sizeof(RT_CHANNEL_LIST_INFO));
5398 DBGPRINT(RT_DEBUG_TRACE, ("Status=%d\n", Status));
5405 case OID_802_11_GET_COUNTRY_CODE:
5406 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_GET_COUNTRY_CODE \n"));
5407 wrq->u.data.length = 2;
5408 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.CountryCode, 2);
5409 DBGPRINT(RT_DEBUG_TRACE, ("Status=%d\n", Status));
5412 case OID_802_11_GET_CHANNEL_GEOGRAPHY:
5413 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_GET_CHANNEL_GEOGRAPHY \n"));
5414 wrq->u.data.length = 1;
5415 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.Geography, 1);
5416 DBGPRINT(RT_DEBUG_TRACE, ("Status=%d\n", Status));
5420 #ifdef QOS_DLS_SUPPORT
5421 case RT_OID_802_11_QUERY_DLS:
5422 wrq->u.data.length = sizeof(BOOLEAN);
5423 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.bDLSCapable, wrq->u.data.length);
5424 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_DLS(=%d)\n", pAdapter->CommonCfg.bDLSCapable));
5427 case RT_OID_802_11_QUERY_DLS_PARAM:
5429 PRT_802_11_DLS_INFO pDlsInfo = kmalloc(sizeof(RT_802_11_DLS_INFO), GFP_ATOMIC);
5430 if (pDlsInfo == NULL)
5433 for (i=0; i<MAX_NUM_OF_DLS_ENTRY; i++)
5435 RTMPMoveMemory(&pDlsInfo->Entry[i], &pAdapter->StaCfg.DLSEntry[i], sizeof(RT_802_11_DLS_UI));
5438 pDlsInfo->num = MAX_NUM_OF_DLS_ENTRY;
5439 wrq->u.data.length = sizeof(RT_802_11_DLS_INFO);
5440 Status = copy_to_user(wrq->u.data.pointer, pDlsInfo, wrq->u.data.length);
5441 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_DLS_PARAM\n"));
5447 #endif // QOS_DLS_SUPPORT //
5449 DBGPRINT(RT_DEBUG_TRACE, ("Query::unknown IOCTL's subcmd = 0x%08x\n", cmd));
5450 Status = -EOPNOTSUPP;
5456 INT rt28xx_sta_ioctl(
5457 IN struct net_device *net_dev,
5458 IN OUT struct ifreq *rq,
5462 VIRTUAL_ADAPTER *pVirtualAd = NULL;
5463 RTMP_ADAPTER *pAd = NULL;
5464 struct iwreq *wrq = (struct iwreq *) rq;
5465 BOOLEAN StateMachineTouched = FALSE;
5466 INT Status = NDIS_STATUS_SUCCESS;
5469 if (net_dev->priv_flags == INT_MAIN)
5471 pAd = net_dev->ml_priv;
5475 pVirtualAd = net_dev->ml_priv;
5476 pAd = pVirtualAd->RtmpDev->ml_priv;
5478 pObj = (POS_COOKIE) pAd->OS_Cookie;
5482 /* if 1st open fail, pAd will be free;
5483 So the net_dev->ml_priv will be NULL in 2rd open */
5487 //check if the interface is down
5488 if(!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_IN_USE))
5490 #ifdef CONFIG_APSTA_MIXED_SUPPORT
5491 if (wrq->u.data.pointer == NULL)
5496 if (strstr(wrq->u.data.pointer, "OpMode") == NULL)
5497 #endif // CONFIG_APSTA_MIXED_SUPPORT //
5499 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
5504 { // determine this ioctl command is comming from which interface.
5505 pObj->ioctl_if_type = INT_MAIN;
5506 pObj->ioctl_if = MAIN_MBSSID;
5512 #ifdef RALINK_28xx_QA
5513 case RTPRIV_IOCTL_ATE:
5515 RtmpDoAte(pAd, wrq);
5518 #endif // RALINK_28xx_QA //
5519 #endif // RALINK_ATE //
5521 DBGPRINT(RT_DEBUG_TRACE, ("IOCTL::SIOCGIFHWADDR\n"));
5522 memcpy(wrq->u.name, pAd->CurrentAddress, ETH_ALEN);
5526 char *name=&wrq->u.name[0];
5527 rt_ioctl_giwname(net_dev, NULL, name, NULL);
5530 case SIOCGIWESSID: //Get ESSID
5532 struct iw_point *essid=&wrq->u.essid;
5533 rt_ioctl_giwessid(net_dev, NULL, essid, essid->pointer);
5536 case SIOCSIWESSID: //Set ESSID
5538 struct iw_point *essid=&wrq->u.essid;
5539 rt_ioctl_siwessid(net_dev, NULL, essid, essid->pointer);
5542 case SIOCSIWNWID: // set network id (the cell)
5543 case SIOCGIWNWID: // get network id
5544 Status = -EOPNOTSUPP;
5546 case SIOCSIWFREQ: //set channel/frequency (Hz)
5548 struct iw_freq *freq=&wrq->u.freq;
5549 rt_ioctl_siwfreq(net_dev, NULL, freq, NULL);
5552 case SIOCGIWFREQ: // get channel/frequency (Hz)
5554 struct iw_freq *freq=&wrq->u.freq;
5555 rt_ioctl_giwfreq(net_dev, NULL, freq, NULL);
5558 case SIOCSIWNICKN: //set node name/nickname
5560 struct iw_point *data=&wrq->u.data;
5561 rt_ioctl_siwnickn(net_dev, NULL, data, NULL);
5564 case SIOCGIWNICKN: //get node name/nickname
5566 struct iw_point *data=&wrq->u.data;
5567 rt_ioctl_giwnickn(net_dev, NULL, data, NULL);
5570 case SIOCGIWRATE: //get default bit rate (bps)
5571 rt_ioctl_giwrate(net_dev, NULL, &wrq->u, NULL);
5573 case SIOCSIWRATE: //set default bit rate (bps)
5574 rt_ioctl_siwrate(net_dev, NULL, &wrq->u, NULL);
5576 case SIOCGIWRTS: // get RTS/CTS threshold (bytes)
5578 struct iw_param *rts=&wrq->u.rts;
5579 rt_ioctl_giwrts(net_dev, NULL, rts, NULL);
5582 case SIOCSIWRTS: //set RTS/CTS threshold (bytes)
5584 struct iw_param *rts=&wrq->u.rts;
5585 rt_ioctl_siwrts(net_dev, NULL, rts, NULL);
5588 case SIOCGIWFRAG: //get fragmentation thr (bytes)
5590 struct iw_param *frag=&wrq->u.frag;
5591 rt_ioctl_giwfrag(net_dev, NULL, frag, NULL);
5594 case SIOCSIWFRAG: //set fragmentation thr (bytes)
5596 struct iw_param *frag=&wrq->u.frag;
5597 rt_ioctl_siwfrag(net_dev, NULL, frag, NULL);
5600 case SIOCGIWENCODE: //get encoding token & mode
5602 struct iw_point *erq=&wrq->u.encoding;
5604 rt_ioctl_giwencode(net_dev, NULL, erq, erq->pointer);
5607 case SIOCSIWENCODE: //set encoding token & mode
5609 struct iw_point *erq=&wrq->u.encoding;
5611 rt_ioctl_siwencode(net_dev, NULL, erq, erq->pointer);
5614 case SIOCGIWAP: //get access point MAC addresses
5616 struct sockaddr *ap_addr=&wrq->u.ap_addr;
5617 rt_ioctl_giwap(net_dev, NULL, ap_addr, ap_addr->sa_data);
5620 case SIOCSIWAP: //set access point MAC addresses
5622 struct sockaddr *ap_addr=&wrq->u.ap_addr;
5623 rt_ioctl_siwap(net_dev, NULL, ap_addr, ap_addr->sa_data);
5626 case SIOCGIWMODE: //get operation mode
5628 __u32 *mode=&wrq->u.mode;
5629 rt_ioctl_giwmode(net_dev, NULL, mode, NULL);
5632 case SIOCSIWMODE: //set operation mode
5634 __u32 *mode=&wrq->u.mode;
5635 rt_ioctl_siwmode(net_dev, NULL, mode, NULL);
5638 case SIOCGIWSENS: //get sensitivity (dBm)
5639 case SIOCSIWSENS: //set sensitivity (dBm)
5640 case SIOCGIWPOWER: //get Power Management settings
5641 case SIOCSIWPOWER: //set Power Management settings
5642 case SIOCGIWTXPOW: //get transmit power (dBm)
5643 case SIOCSIWTXPOW: //set transmit power (dBm)
5644 case SIOCGIWRANGE: //Get range of parameters
5645 case SIOCGIWRETRY: //get retry limits and lifetime
5646 case SIOCSIWRETRY: //set retry limits and lifetime
5647 Status = -EOPNOTSUPP;
5650 subcmd = wrq->u.data.flags;
5651 if( subcmd & OID_GET_SET_TOGGLE)
5652 Status = RTMPSetInformation(pAd, rq, subcmd);
5654 Status = RTMPQueryInformation(pAd, rq, subcmd);
5657 if (wrq->u.data.pointer)
5659 if ( access_ok(VERIFY_WRITE, wrq->u.data.pointer, sizeof(privtab)) != TRUE)
5661 wrq->u.data.length = sizeof(privtab) / sizeof(privtab[0]);
5662 if (copy_to_user(wrq->u.data.pointer, privtab, sizeof(privtab)))
5666 case RTPRIV_IOCTL_SET:
5667 if(access_ok(VERIFY_READ, wrq->u.data.pointer, wrq->u.data.length) != TRUE)
5669 rt_ioctl_setparam(net_dev, NULL, NULL, wrq->u.data.pointer);
5671 case RTPRIV_IOCTL_GSITESURVEY:
5672 RTMPIoctlGetSiteSurvey(pAd, wrq);
5675 case RTPRIV_IOCTL_MAC:
5676 RTMPIoctlMAC(pAd, wrq);
5678 case RTPRIV_IOCTL_E2P:
5679 RTMPIoctlE2PROM(pAd, wrq);
5685 DBGPRINT(RT_DEBUG_ERROR, ("IOCTL::unknown IOCTL's cmd = 0x%08x\n", cmd));
5686 Status = -EOPNOTSUPP;
5690 if(StateMachineTouched) // Upper layer sent a MLME-related operations
5691 RT28XX_MLME_HANDLER(pAd);
5697 ==========================================================================
5701 TRUE if all parameters are OK, FALSE otherwise
5702 ==========================================================================
5705 IN PRTMP_ADAPTER pAdapter,
5708 NDIS_802_11_SSID Ssid, *pSsid=NULL;
5709 BOOLEAN StateMachineTouched = FALSE;
5712 if( strlen(arg) <= MAX_LEN_OF_SSID)
5714 NdisZeroMemory(&Ssid, sizeof(NDIS_802_11_SSID));
5715 if (strlen(arg) != 0)
5717 NdisMoveMemory(Ssid.Ssid, arg, strlen(arg));
5718 Ssid.SsidLength = strlen(arg);
5722 Ssid.SsidLength = 0;
5723 memcpy(Ssid.Ssid, "", 0);
5724 pAdapter->StaCfg.BssType = BSS_INFRA;
5725 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
5726 pAdapter->StaCfg.WepStatus = Ndis802_11EncryptionDisabled;
5730 if (pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE)
5732 RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
5733 DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
5736 pAdapter->MlmeAux.CurrReqIsFromNdis = TRUE;
5737 pAdapter->StaCfg.bScanReqIsFromWebUI = FALSE;
5738 pAdapter->bConfigChanged = TRUE;
5740 MlmeEnqueue(pAdapter,
5741 MLME_CNTL_STATE_MACHINE,
5743 sizeof(NDIS_802_11_SSID),
5746 StateMachineTouched = TRUE;
5747 DBGPRINT(RT_DEBUG_TRACE, ("Set_SSID_Proc::(Len=%d,Ssid=%s)\n", Ssid.SsidLength, Ssid.Ssid));
5752 if (StateMachineTouched) // Upper layer sent a MLME-related operations
5753 RT28XX_MLME_HANDLER(pAdapter);
5760 ==========================================================================
5762 Set WmmCapable Enable or Disable
5764 TRUE if all parameters are OK, FALSE otherwise
5765 ==========================================================================
5767 INT Set_WmmCapable_Proc(
5768 IN PRTMP_ADAPTER pAd,
5771 BOOLEAN bWmmCapable;
5773 bWmmCapable = simple_strtol(arg, 0, 10);
5775 if ((bWmmCapable == 1)
5777 && (pAd->NumberOfPipes >= 5)
5780 pAd->CommonCfg.bWmmCapable = TRUE;
5781 else if (bWmmCapable == 0)
5782 pAd->CommonCfg.bWmmCapable = FALSE;
5784 return FALSE; //Invalid argument
5786 DBGPRINT(RT_DEBUG_TRACE, ("Set_WmmCapable_Proc::(bWmmCapable=%d)\n",
5787 pAd->CommonCfg.bWmmCapable));
5791 #endif // WMM_SUPPORT //
5794 ==========================================================================
5796 Set Network Type(Infrastructure/Adhoc mode)
5798 TRUE if all parameters are OK, FALSE otherwise
5799 ==========================================================================
5801 INT Set_NetworkType_Proc(
5802 IN PRTMP_ADAPTER pAdapter,
5807 if (strcmp(arg, "Adhoc") == 0)
5809 if (pAdapter->StaCfg.BssType != BSS_ADHOC)
5811 // Config has changed
5812 pAdapter->bConfigChanged = TRUE;
5813 if (MONITOR_ON(pAdapter))
5815 RTMP_IO_WRITE32(pAdapter, RX_FILTR_CFG, STANORMAL);
5816 RTMP_IO_READ32(pAdapter, MAC_SYS_CTRL, &Value);
5818 RTMP_IO_WRITE32(pAdapter, MAC_SYS_CTRL, Value);
5819 OPSTATUS_CLEAR_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED);
5820 pAdapter->StaCfg.bAutoReconnect = TRUE;
5821 LinkDown(pAdapter, FALSE);
5823 if (INFRA_ON(pAdapter))
5825 //BOOLEAN Cancelled;
5826 // Set the AutoReconnectSsid to prevent it reconnect to old SSID
5827 // Since calling this indicate user don't want to connect to that SSID anymore.
5828 pAdapter->MlmeAux.AutoReconnectSsidLen= 32;
5829 NdisZeroMemory(pAdapter->MlmeAux.AutoReconnectSsid, pAdapter->MlmeAux.AutoReconnectSsidLen);
5831 LinkDown(pAdapter, FALSE);
5833 DBGPRINT(RT_DEBUG_TRACE, ("NDIS_STATUS_MEDIA_DISCONNECT Event BB!\n"));
5836 pAdapter->StaCfg.BssType = BSS_ADHOC;
5837 pAdapter->net_dev->type = pAdapter->StaCfg.OriDevType;
5838 DBGPRINT(RT_DEBUG_TRACE, ("===>Set_NetworkType_Proc::(AD-HOC)\n"));
5840 else if (strcmp(arg, "Infra") == 0)
5842 if (pAdapter->StaCfg.BssType != BSS_INFRA)
5844 // Config has changed
5845 pAdapter->bConfigChanged = TRUE;
5846 if (MONITOR_ON(pAdapter))
5848 RTMP_IO_WRITE32(pAdapter, RX_FILTR_CFG, STANORMAL);
5849 RTMP_IO_READ32(pAdapter, MAC_SYS_CTRL, &Value);
5851 RTMP_IO_WRITE32(pAdapter, MAC_SYS_CTRL, Value);
5852 OPSTATUS_CLEAR_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED);
5853 pAdapter->StaCfg.bAutoReconnect = TRUE;
5854 LinkDown(pAdapter, FALSE);
5856 if (ADHOC_ON(pAdapter))
5858 // Set the AutoReconnectSsid to prevent it reconnect to old SSID
5859 // Since calling this indicate user don't want to connect to that SSID anymore.
5860 pAdapter->MlmeAux.AutoReconnectSsidLen= 32;
5861 NdisZeroMemory(pAdapter->MlmeAux.AutoReconnectSsid, pAdapter->MlmeAux.AutoReconnectSsidLen);
5863 LinkDown(pAdapter, FALSE);
5866 pAdapter->StaCfg.BssType = BSS_INFRA;
5867 pAdapter->net_dev->type = pAdapter->StaCfg.OriDevType;
5868 DBGPRINT(RT_DEBUG_TRACE, ("===>Set_NetworkType_Proc::(INFRA)\n"));
5870 pAdapter->StaCfg.BssType = BSS_INFRA;
5872 else if (strcmp(arg, "Monitor") == 0)
5875 BCN_TIME_CFG_STRUC csr;
5876 OPSTATUS_CLEAR_FLAG(pAdapter, fOP_STATUS_INFRA_ON);
5877 OPSTATUS_CLEAR_FLAG(pAdapter, fOP_STATUS_ADHOC_ON);
5878 OPSTATUS_SET_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED);
5879 // disable all periodic state machine
5880 pAdapter->StaCfg.bAutoReconnect = FALSE;
5881 // reset all mlme state machine
5882 RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
5883 DBGPRINT(RT_DEBUG_TRACE, ("fOP_STATUS_MEDIA_STATE_CONNECTED \n"));
5884 if (pAdapter->CommonCfg.CentralChannel == 0)
5886 #ifdef DOT11_N_SUPPORT
5887 if (pAdapter->CommonCfg.PhyMode == PHY_11AN_MIXED)
5888 pAdapter->CommonCfg.CentralChannel = 36;
5890 #endif // DOT11_N_SUPPORT //
5891 pAdapter->CommonCfg.CentralChannel = 6;
5893 #ifdef DOT11_N_SUPPORT
5895 N_ChannelCheck(pAdapter);
5896 #endif // DOT11_N_SUPPORT //
5898 #ifdef DOT11_N_SUPPORT
5899 if (pAdapter->CommonCfg.PhyMode >= PHY_11ABGN_MIXED &&
5900 pAdapter->CommonCfg.RegTransmitSetting.field.BW == BW_40 &&
5901 pAdapter->CommonCfg.RegTransmitSetting.field.EXTCHA == EXTCHA_ABOVE)
5903 // 40MHz ,control channel at lower
5904 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, BBP_R4, &bbpValue);
5905 bbpValue &= (~0x18);
5907 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R4, bbpValue);
5908 pAdapter->CommonCfg.BBPCurrentBW = BW_40;
5909 // RX : control channel at lower
5910 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, BBP_R3, &bbpValue);
5911 bbpValue &= (~0x20);
5912 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R3, bbpValue);
5914 RTMP_IO_READ32(pAdapter, TX_BAND_CFG, &Value);
5915 Value &= 0xfffffffe;
5916 RTMP_IO_WRITE32(pAdapter, TX_BAND_CFG, Value);
5917 pAdapter->CommonCfg.CentralChannel = pAdapter->CommonCfg.Channel + 2;
5918 AsicSwitchChannel(pAdapter, pAdapter->CommonCfg.CentralChannel, FALSE);
5919 AsicLockChannel(pAdapter, pAdapter->CommonCfg.CentralChannel);
5920 DBGPRINT(RT_DEBUG_TRACE, ("BW_40 ,control_channel(%d), CentralChannel(%d) \n",
5921 pAdapter->CommonCfg.Channel,
5922 pAdapter->CommonCfg.CentralChannel));
5924 else if (pAdapter->CommonCfg.PhyMode >= PHY_11ABGN_MIXED &&
5925 pAdapter->CommonCfg.RegTransmitSetting.field.BW == BW_40 &&
5926 pAdapter->CommonCfg.RegTransmitSetting.field.EXTCHA == EXTCHA_BELOW)
5928 // 40MHz ,control channel at upper
5929 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, BBP_R4, &bbpValue);
5930 bbpValue &= (~0x18);
5932 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R4, bbpValue);
5933 pAdapter->CommonCfg.BBPCurrentBW = BW_40;
5934 RTMP_IO_READ32(pAdapter, TX_BAND_CFG, &Value);
5936 RTMP_IO_WRITE32(pAdapter, TX_BAND_CFG, Value);
5938 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, BBP_R3, &bbpValue);
5940 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R3, bbpValue);
5941 pAdapter->CommonCfg.CentralChannel = pAdapter->CommonCfg.Channel - 2;
5942 AsicSwitchChannel(pAdapter, pAdapter->CommonCfg.CentralChannel, FALSE);
5943 AsicLockChannel(pAdapter, pAdapter->CommonCfg.CentralChannel);
5944 DBGPRINT(RT_DEBUG_TRACE, ("BW_40 ,control_channel(%d), CentralChannel(%d) \n",
5945 pAdapter->CommonCfg.Channel,
5946 pAdapter->CommonCfg.CentralChannel));
5949 #endif // DOT11_N_SUPPORT //
5952 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, BBP_R4, &bbpValue);
5953 bbpValue &= (~0x18);
5954 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R4, bbpValue);
5955 pAdapter->CommonCfg.BBPCurrentBW = BW_20;
5956 AsicSwitchChannel(pAdapter, pAdapter->CommonCfg.Channel, FALSE);
5957 AsicLockChannel(pAdapter, pAdapter->CommonCfg.Channel);
5958 DBGPRINT(RT_DEBUG_TRACE, ("BW_20, Channel(%d)\n", pAdapter->CommonCfg.Channel));
5960 // Enable Rx with promiscuous reception
5961 RTMP_IO_WRITE32(pAdapter, RX_FILTR_CFG, 0x3);
5962 // ASIC supporsts sniffer function with replacing RSSI with timestamp.
5963 //RTMP_IO_READ32(pAdapter, MAC_SYS_CTRL, &Value);
5965 //RTMP_IO_WRITE32(pAdapter, MAC_SYS_CTRL, Value);
5967 RTMP_IO_READ32(pAdapter, BCN_TIME_CFG, &csr.word);
5968 csr.field.bBeaconGen = 0;
5969 csr.field.bTBTTEnable = 0;
5970 csr.field.TsfSyncMode = 0;
5971 RTMP_IO_WRITE32(pAdapter, BCN_TIME_CFG, csr.word);
5973 pAdapter->StaCfg.BssType = BSS_MONITOR;
5974 pAdapter->net_dev->type = ARPHRD_IEEE80211_PRISM; //ARPHRD_IEEE80211; // IEEE80211
5975 DBGPRINT(RT_DEBUG_TRACE, ("===>Set_NetworkType_Proc::(MONITOR)\n"));
5978 // Reset Ralink supplicant to not use, it will be set to start when UI set PMK key
5979 pAdapter->StaCfg.WpaState = SS_NOTUSE;
5981 DBGPRINT(RT_DEBUG_TRACE, ("Set_NetworkType_Proc::(NetworkType=%d)\n", pAdapter->StaCfg.BssType));
5987 ==========================================================================
5989 Set Authentication mode
5991 TRUE if all parameters are OK, FALSE otherwise
5992 ==========================================================================
5994 INT Set_AuthMode_Proc(
5995 IN PRTMP_ADAPTER pAdapter,
5998 if ((strcmp(arg, "WEPAUTO") == 0) || (strcmp(arg, "wepauto") == 0))
5999 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeAutoSwitch;
6000 else if ((strcmp(arg, "OPEN") == 0) || (strcmp(arg, "open") == 0))
6001 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
6002 else if ((strcmp(arg, "SHARED") == 0) || (strcmp(arg, "shared") == 0))
6003 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeShared;
6004 else if ((strcmp(arg, "WPAPSK") == 0) || (strcmp(arg, "wpapsk") == 0))
6005 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPAPSK;
6006 else if ((strcmp(arg, "WPANONE") == 0) || (strcmp(arg, "wpanone") == 0))
6007 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPANone;
6008 else if ((strcmp(arg, "WPA2PSK") == 0) || (strcmp(arg, "wpa2psk") == 0))
6009 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA2PSK;
6010 #ifdef WPA_SUPPLICANT_SUPPORT
6011 else if ((strcmp(arg, "WPA") == 0) || (strcmp(arg, "wpa") == 0))
6012 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA;
6013 else if ((strcmp(arg, "WPA2") == 0) || (strcmp(arg, "wpa2") == 0))
6014 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA2;
6015 #endif // WPA_SUPPLICANT_SUPPORT //
6019 pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED;
6021 DBGPRINT(RT_DEBUG_TRACE, ("Set_AuthMode_Proc::(AuthMode=%d)\n", pAdapter->StaCfg.AuthMode));
6027 ==========================================================================
6031 TRUE if all parameters are OK, FALSE otherwise
6032 ==========================================================================
6034 INT Set_EncrypType_Proc(
6035 IN PRTMP_ADAPTER pAdapter,
6038 if ((strcmp(arg, "NONE") == 0) || (strcmp(arg, "none") == 0))
6040 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
6041 return TRUE; // do nothing
6043 pAdapter->StaCfg.WepStatus = Ndis802_11WEPDisabled;
6044 pAdapter->StaCfg.PairCipher = Ndis802_11WEPDisabled;
6045 pAdapter->StaCfg.GroupCipher = Ndis802_11WEPDisabled;
6047 else if ((strcmp(arg, "WEP") == 0) || (strcmp(arg, "wep") == 0))
6049 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
6050 return TRUE; // do nothing
6052 pAdapter->StaCfg.WepStatus = Ndis802_11WEPEnabled;
6053 pAdapter->StaCfg.PairCipher = Ndis802_11WEPEnabled;
6054 pAdapter->StaCfg.GroupCipher = Ndis802_11WEPEnabled;
6056 else if ((strcmp(arg, "TKIP") == 0) || (strcmp(arg, "tkip") == 0))
6058 if (pAdapter->StaCfg.AuthMode < Ndis802_11AuthModeWPA)
6059 return TRUE; // do nothing
6061 pAdapter->StaCfg.WepStatus = Ndis802_11Encryption2Enabled;
6062 pAdapter->StaCfg.PairCipher = Ndis802_11Encryption2Enabled;
6063 pAdapter->StaCfg.GroupCipher = Ndis802_11Encryption2Enabled;
6065 else if ((strcmp(arg, "AES") == 0) || (strcmp(arg, "aes") == 0))
6067 if (pAdapter->StaCfg.AuthMode < Ndis802_11AuthModeWPA)
6068 return TRUE; // do nothing
6070 pAdapter->StaCfg.WepStatus = Ndis802_11Encryption3Enabled;
6071 pAdapter->StaCfg.PairCipher = Ndis802_11Encryption3Enabled;
6072 pAdapter->StaCfg.GroupCipher = Ndis802_11Encryption3Enabled;
6077 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
6079 DBGPRINT(RT_DEBUG_TRACE, ("Set_EncrypType_Proc::(EncrypType=%d)\n", pAdapter->StaCfg.WepStatus));
6085 ==========================================================================
6089 TRUE if all parameters are OK, FALSE otherwise
6090 ==========================================================================
6092 INT Set_DefaultKeyID_Proc(
6093 IN PRTMP_ADAPTER pAdapter,
6098 KeyIdx = simple_strtol(arg, 0, 10);
6099 if((KeyIdx >= 1 ) && (KeyIdx <= 4))
6100 pAdapter->StaCfg.DefaultKeyId = (UCHAR) (KeyIdx - 1 );
6102 return FALSE; //Invalid argument
6104 DBGPRINT(RT_DEBUG_TRACE, ("Set_DefaultKeyID_Proc::(DefaultKeyID=%d)\n", pAdapter->StaCfg.DefaultKeyId));
6110 ==========================================================================
6114 TRUE if all parameters are OK, FALSE otherwise
6115 ==========================================================================
6118 IN PRTMP_ADAPTER pAdapter,
6123 UCHAR CipherAlg=CIPHER_WEP64;
6125 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
6126 return TRUE; // do nothing
6128 KeyLen = strlen(arg);
6132 case 5: //wep 40 Ascii type
6133 pAdapter->SharedKey[BSS0][0].KeyLen = KeyLen;
6134 memcpy(pAdapter->SharedKey[BSS0][0].Key, arg, KeyLen);
6135 CipherAlg = CIPHER_WEP64;
6136 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key1_Proc::(Key1=%s and type=%s)\n", arg, "Ascii"));
6138 case 10: //wep 40 Hex type
6139 for(i=0; i < KeyLen; i++)
6141 if( !isxdigit(*(arg+i)) )
6142 return FALSE; //Not Hex value;
6144 pAdapter->SharedKey[BSS0][0].KeyLen = KeyLen / 2 ;
6145 AtoH(arg, pAdapter->SharedKey[BSS0][0].Key, KeyLen / 2);
6146 CipherAlg = CIPHER_WEP64;
6147 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key1_Proc::(Key1=%s and type=%s)\n", arg, "Hex"));
6149 case 13: //wep 104 Ascii type
6150 pAdapter->SharedKey[BSS0][0].KeyLen = KeyLen;
6151 memcpy(pAdapter->SharedKey[BSS0][0].Key, arg, KeyLen);
6152 CipherAlg = CIPHER_WEP128;
6153 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key1_Proc::(Key1=%s and type=%s)\n", arg, "Ascii"));
6155 case 26: //wep 104 Hex type
6156 for(i=0; i < KeyLen; i++)
6158 if( !isxdigit(*(arg+i)) )
6159 return FALSE; //Not Hex value;
6161 pAdapter->SharedKey[BSS0][0].KeyLen = KeyLen / 2 ;
6162 AtoH(arg, pAdapter->SharedKey[BSS0][0].Key, KeyLen / 2);
6163 CipherAlg = CIPHER_WEP128;
6164 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key1_Proc::(Key1=%s and type=%s)\n", arg, "Hex"));
6166 default: //Invalid argument
6167 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key1_Proc::Invalid argument (=%s)\n", arg));
6171 pAdapter->SharedKey[BSS0][0].CipherAlg = CipherAlg;
6173 // Set keys (into ASIC)
6174 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
6176 else // Old WEP stuff
6178 AsicAddSharedKeyEntry(pAdapter,
6181 pAdapter->SharedKey[BSS0][0].CipherAlg,
6182 pAdapter->SharedKey[BSS0][0].Key,
6190 ==========================================================================
6195 TRUE if all parameters are OK, FALSE otherwise
6196 ==========================================================================
6199 IN PRTMP_ADAPTER pAdapter,
6204 UCHAR CipherAlg=CIPHER_WEP64;
6206 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
6207 return TRUE; // do nothing
6209 KeyLen = strlen(arg);
6213 case 5: //wep 40 Ascii type
6214 pAdapter->SharedKey[BSS0][1].KeyLen = KeyLen;
6215 memcpy(pAdapter->SharedKey[BSS0][1].Key, arg, KeyLen);
6216 CipherAlg = CIPHER_WEP64;
6217 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key2_Proc::(Key2=%s and type=%s)\n", arg, "Ascii"));
6219 case 10: //wep 40 Hex type
6220 for(i=0; i < KeyLen; i++)
6222 if( !isxdigit(*(arg+i)) )
6223 return FALSE; //Not Hex value;
6225 pAdapter->SharedKey[BSS0][1].KeyLen = KeyLen / 2 ;
6226 AtoH(arg, pAdapter->SharedKey[BSS0][1].Key, KeyLen / 2);
6227 CipherAlg = CIPHER_WEP64;
6228 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key2_Proc::(Key2=%s and type=%s)\n", arg, "Hex"));
6230 case 13: //wep 104 Ascii type
6231 pAdapter->SharedKey[BSS0][1].KeyLen = KeyLen;
6232 memcpy(pAdapter->SharedKey[BSS0][1].Key, arg, KeyLen);
6233 CipherAlg = CIPHER_WEP128;
6234 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key2_Proc::(Key2=%s and type=%s)\n", arg, "Ascii"));
6236 case 26: //wep 104 Hex type
6237 for(i=0; i < KeyLen; i++)
6239 if( !isxdigit(*(arg+i)) )
6240 return FALSE; //Not Hex value;
6242 pAdapter->SharedKey[BSS0][1].KeyLen = KeyLen / 2 ;
6243 AtoH(arg, pAdapter->SharedKey[BSS0][1].Key, KeyLen / 2);
6244 CipherAlg = CIPHER_WEP128;
6245 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key2_Proc::(Key2=%s and type=%s)\n", arg, "Hex"));
6247 default: //Invalid argument
6248 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key2_Proc::Invalid argument (=%s)\n", arg));
6251 pAdapter->SharedKey[BSS0][1].CipherAlg = CipherAlg;
6253 // Set keys (into ASIC)
6254 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
6256 else // Old WEP stuff
6258 AsicAddSharedKeyEntry(pAdapter,
6261 pAdapter->SharedKey[BSS0][1].CipherAlg,
6262 pAdapter->SharedKey[BSS0][1].Key,
6270 ==========================================================================
6274 TRUE if all parameters are OK, FALSE otherwise
6275 ==========================================================================
6278 IN PRTMP_ADAPTER pAdapter,
6283 UCHAR CipherAlg=CIPHER_WEP64;
6285 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
6286 return TRUE; // do nothing
6288 KeyLen = strlen(arg);
6292 case 5: //wep 40 Ascii type
6293 pAdapter->SharedKey[BSS0][2].KeyLen = KeyLen;
6294 memcpy(pAdapter->SharedKey[BSS0][2].Key, arg, KeyLen);
6295 CipherAlg = CIPHER_WEP64;
6296 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key3_Proc::(Key3=%s and type=Ascii)\n", arg));
6298 case 10: //wep 40 Hex type
6299 for(i=0; i < KeyLen; i++)
6301 if( !isxdigit(*(arg+i)) )
6302 return FALSE; //Not Hex value;
6304 pAdapter->SharedKey[BSS0][2].KeyLen = KeyLen / 2 ;
6305 AtoH(arg, pAdapter->SharedKey[BSS0][2].Key, KeyLen / 2);
6306 CipherAlg = CIPHER_WEP64;
6307 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key3_Proc::(Key3=%s and type=Hex)\n", arg));
6309 case 13: //wep 104 Ascii type
6310 pAdapter->SharedKey[BSS0][2].KeyLen = KeyLen;
6311 memcpy(pAdapter->SharedKey[BSS0][2].Key, arg, KeyLen);
6312 CipherAlg = CIPHER_WEP128;
6313 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key3_Proc::(Key3=%s and type=Ascii)\n", arg));
6315 case 26: //wep 104 Hex type
6316 for(i=0; i < KeyLen; i++)
6318 if( !isxdigit(*(arg+i)) )
6319 return FALSE; //Not Hex value;
6321 pAdapter->SharedKey[BSS0][2].KeyLen = KeyLen / 2 ;
6322 AtoH(arg, pAdapter->SharedKey[BSS0][2].Key, KeyLen / 2);
6323 CipherAlg = CIPHER_WEP128;
6324 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key3_Proc::(Key3=%s and type=Hex)\n", arg));
6326 default: //Invalid argument
6327 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key3_Proc::Invalid argument (=%s)\n", arg));
6330 pAdapter->SharedKey[BSS0][2].CipherAlg = CipherAlg;
6332 // Set keys (into ASIC)
6333 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
6335 else // Old WEP stuff
6337 AsicAddSharedKeyEntry(pAdapter,
6340 pAdapter->SharedKey[BSS0][2].CipherAlg,
6341 pAdapter->SharedKey[BSS0][2].Key,
6349 ==========================================================================
6353 TRUE if all parameters are OK, FALSE otherwise
6354 ==========================================================================
6357 IN PRTMP_ADAPTER pAdapter,
6362 UCHAR CipherAlg=CIPHER_WEP64;
6364 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
6365 return TRUE; // do nothing
6367 KeyLen = strlen(arg);
6371 case 5: //wep 40 Ascii type
6372 pAdapter->SharedKey[BSS0][3].KeyLen = KeyLen;
6373 memcpy(pAdapter->SharedKey[BSS0][3].Key, arg, KeyLen);
6374 CipherAlg = CIPHER_WEP64;
6375 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key4_Proc::(Key4=%s and type=%s)\n", arg, "Ascii"));
6377 case 10: //wep 40 Hex type
6378 for(i=0; i < KeyLen; i++)
6380 if( !isxdigit(*(arg+i)) )
6381 return FALSE; //Not Hex value;
6383 pAdapter->SharedKey[BSS0][3].KeyLen = KeyLen / 2 ;
6384 AtoH(arg, pAdapter->SharedKey[BSS0][3].Key, KeyLen / 2);
6385 CipherAlg = CIPHER_WEP64;
6386 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key4_Proc::(Key4=%s and type=%s)\n", arg, "Hex"));
6388 case 13: //wep 104 Ascii type
6389 pAdapter->SharedKey[BSS0][3].KeyLen = KeyLen;
6390 memcpy(pAdapter->SharedKey[BSS0][3].Key, arg, KeyLen);
6391 CipherAlg = CIPHER_WEP128;
6392 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key4_Proc::(Key4=%s and type=%s)\n", arg, "Ascii"));
6394 case 26: //wep 104 Hex type
6395 for(i=0; i < KeyLen; i++)
6397 if( !isxdigit(*(arg+i)) )
6398 return FALSE; //Not Hex value;
6400 pAdapter->SharedKey[BSS0][3].KeyLen = KeyLen / 2 ;
6401 AtoH(arg, pAdapter->SharedKey[BSS0][3].Key, KeyLen / 2);
6402 CipherAlg = CIPHER_WEP128;
6403 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key4_Proc::(Key4=%s and type=%s)\n", arg, "Hex"));
6405 default: //Invalid argument
6406 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key4_Proc::Invalid argument (=%s)\n", arg));
6409 pAdapter->SharedKey[BSS0][3].CipherAlg = CipherAlg;
6411 // Set keys (into ASIC)
6412 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
6414 else // Old WEP stuff
6416 AsicAddSharedKeyEntry(pAdapter,
6419 pAdapter->SharedKey[BSS0][3].CipherAlg,
6420 pAdapter->SharedKey[BSS0][3].Key,
6429 ==========================================================================
6433 TRUE if all parameters are OK, FALSE otherwise
6434 ==========================================================================
6436 INT Set_WPAPSK_Proc(
6437 IN PRTMP_ADAPTER pAdapter,
6440 UCHAR keyMaterial[40];
6442 if ((pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPAPSK) &&
6443 (pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPA2PSK) &&
6444 (pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPANone)
6446 return TRUE; // do nothing
6448 DBGPRINT(RT_DEBUG_TRACE, ("Set_WPAPSK_Proc::(WPAPSK=%s)\n", arg));
6450 NdisZeroMemory(keyMaterial, 40);
6452 if ((strlen(arg) < 8) || (strlen(arg) > 64))
6454 DBGPRINT(RT_DEBUG_TRACE, ("Set failed!!(WPAPSK=%s), WPAPSK key-string required 8 ~ 64 characters \n", arg));
6458 if (strlen(arg) == 64)
6460 AtoH(arg, keyMaterial, 32);
6461 NdisMoveMemory(pAdapter->StaCfg.PMK, keyMaterial, 32);
6466 PasswordHash((char *)arg, pAdapter->MlmeAux.Ssid, pAdapter->MlmeAux.SsidLen, keyMaterial);
6467 NdisMoveMemory(pAdapter->StaCfg.PMK, keyMaterial, 32);
6472 if(pAdapter->StaCfg.BssType == BSS_ADHOC &&
6473 pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPANone)
6475 pAdapter->StaCfg.WpaState = SS_NOTUSE;
6479 // Start STA supplicant state machine
6480 pAdapter->StaCfg.WpaState = SS_START;
6487 ==========================================================================
6489 Set Power Saving mode
6491 TRUE if all parameters are OK, FALSE otherwise
6492 ==========================================================================
6494 INT Set_PSMode_Proc(
6495 IN PRTMP_ADAPTER pAdapter,
6498 if (pAdapter->StaCfg.BssType == BSS_INFRA)
6500 if ((strcmp(arg, "Max_PSP") == 0) ||
6501 (strcmp(arg, "max_psp") == 0) ||
6502 (strcmp(arg, "MAX_PSP") == 0))
6504 // do NOT turn on PSM bit here, wait until MlmeCheckForPsmChange()
6505 // to exclude certain situations.
6506 if (pAdapter->StaCfg.bWindowsACCAMEnable == FALSE)
6507 pAdapter->StaCfg.WindowsPowerMode = Ndis802_11PowerModeMAX_PSP;
6508 pAdapter->StaCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeMAX_PSP;
6509 OPSTATUS_SET_FLAG(pAdapter, fOP_STATUS_RECEIVE_DTIM);
6510 pAdapter->StaCfg.DefaultListenCount = 5;
6513 else if ((strcmp(arg, "Fast_PSP") == 0) ||
6514 (strcmp(arg, "fast_psp") == 0) ||
6515 (strcmp(arg, "FAST_PSP") == 0))
6517 // do NOT turn on PSM bit here, wait until MlmeCheckForPsmChange()
6518 // to exclude certain situations.
6519 OPSTATUS_SET_FLAG(pAdapter, fOP_STATUS_RECEIVE_DTIM);
6520 if (pAdapter->StaCfg.bWindowsACCAMEnable == FALSE)
6521 pAdapter->StaCfg.WindowsPowerMode = Ndis802_11PowerModeFast_PSP;
6522 pAdapter->StaCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeFast_PSP;
6523 pAdapter->StaCfg.DefaultListenCount = 3;
6525 else if ((strcmp(arg, "Legacy_PSP") == 0) ||
6526 (strcmp(arg, "legacy_psp") == 0) ||
6527 (strcmp(arg, "LEGACY_PSP") == 0))
6529 // do NOT turn on PSM bit here, wait until MlmeCheckForPsmChange()
6530 // to exclude certain situations.
6531 OPSTATUS_SET_FLAG(pAdapter, fOP_STATUS_RECEIVE_DTIM);
6532 if (pAdapter->StaCfg.bWindowsACCAMEnable == FALSE)
6533 pAdapter->StaCfg.WindowsPowerMode = Ndis802_11PowerModeLegacy_PSP;
6534 pAdapter->StaCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeLegacy_PSP;
6535 pAdapter->StaCfg.DefaultListenCount = 3;
6539 //Default Ndis802_11PowerModeCAM
6540 // clear PSM bit immediately
6541 MlmeSetPsmBit(pAdapter, PWR_ACTIVE);
6542 OPSTATUS_SET_FLAG(pAdapter, fOP_STATUS_RECEIVE_DTIM);
6543 if (pAdapter->StaCfg.bWindowsACCAMEnable == FALSE)
6544 pAdapter->StaCfg.WindowsPowerMode = Ndis802_11PowerModeCAM;
6545 pAdapter->StaCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeCAM;
6548 DBGPRINT(RT_DEBUG_TRACE, ("Set_PSMode_Proc::(PSMode=%ld)\n", pAdapter->StaCfg.WindowsPowerMode));
6557 #ifdef WPA_SUPPLICANT_SUPPORT
6559 ==========================================================================
6561 Set WpaSupport flag.
6563 0: Driver ignore wpa_supplicant.
6564 1: wpa_supplicant initiates scanning and AP selection.
6565 2: driver takes care of scanning, AP selection, and IEEE 802.11 association parameters.
6567 TRUE if all parameters are OK, FALSE otherwise
6568 ==========================================================================
6570 INT Set_Wpa_Support(
6571 IN PRTMP_ADAPTER pAd,
6575 if ( simple_strtol(arg, 0, 10) == 0)
6576 pAd->StaCfg.WpaSupplicantUP = WPA_SUPPLICANT_DISABLE;
6577 else if ( simple_strtol(arg, 0, 10) == 1)
6578 pAd->StaCfg.WpaSupplicantUP = WPA_SUPPLICANT_ENABLE;
6579 else if ( simple_strtol(arg, 0, 10) == 2)
6580 pAd->StaCfg.WpaSupplicantUP = WPA_SUPPLICANT_ENABLE_WITH_WEB_UI;
6582 pAd->StaCfg.WpaSupplicantUP = WPA_SUPPLICANT_DISABLE;
6584 DBGPRINT(RT_DEBUG_TRACE, ("Set_Wpa_Support::(WpaSupplicantUP=%d)\n", pAd->StaCfg.WpaSupplicantUP));
6588 #endif // WPA_SUPPLICANT_SUPPORT //
6592 ==========================================================================
6596 pAdapter Pointer to our adapter
6597 wrq Pointer to the ioctl argument
6604 1.) iwpriv ra0 mac 0 ==> read MAC where Addr=0x0
6605 2.) iwpriv ra0 mac 0=12 ==> write MAC where Addr=0x0, value=12
6606 ==========================================================================
6609 IN PRTMP_ADAPTER pAdapter,
6610 IN struct iwreq *wrq)
6618 UCHAR temp[16], temp2[16];
6619 UINT32 macValue = 0;
6623 memset(msg, 0x00, 1024);
6624 if (wrq->u.data.length > 1) //No parameters.
6626 Status = copy_from_user(arg, wrq->u.data.pointer, (wrq->u.data.length > 255) ? 255 : wrq->u.data.length);
6629 //Parsing Read or Write
6634 if ((value = rtstrchr(this_char, '=')) != NULL)
6637 if (!value || !*value)
6640 if(strlen(this_char) > 4)
6643 j = strlen(this_char);
6646 if(this_char[j] > 'f' || this_char[j] < '0')
6651 k = j = strlen(this_char);
6654 this_char[4-k+j] = this_char[j];
6658 this_char[3-k++]='0';
6661 if(strlen(this_char) == 4)
6663 AtoH(this_char, temp, 2);
6664 macAddr = *temp*256 + temp[1];
6665 if (macAddr < 0xFFFF)
6667 RTMP_IO_READ32(pAdapter, macAddr, &macValue);
6668 DBGPRINT(RT_DEBUG_TRACE, ("MacAddr=%lx, MacValue=%x\n", macAddr, macValue));
6669 sprintf(msg+strlen(msg), "[0x%08lX]:%08X ", macAddr , macValue);
6672 {//Invalid parametes, so default printk all bbp
6679 memcpy(&temp2, value, strlen(value));
6680 temp2[strlen(value)] = '\0';
6683 if((strlen(this_char) > 4) || strlen(temp2) > 8)
6686 j = strlen(this_char);
6689 if(this_char[j] > 'f' || this_char[j] < '0')
6696 if(temp2[j] > 'f' || temp2[j] < '0')
6701 k = j = strlen(this_char);
6704 this_char[4-k+j] = this_char[j];
6708 this_char[3-k++]='0';
6712 k = j = strlen(temp2);
6715 temp2[8-k+j] = temp2[j];
6723 AtoH(this_char, temp, 2);
6724 macAddr = *temp*256 + temp[1];
6726 AtoH(temp2, temp, 4);
6727 macValue = *temp*256*256*256 + temp[1]*256*256 + temp[2]*256 + temp[3];
6730 if (macAddr == (HW_DEBUG_SETTING_BASE + 4))
6732 // 0x2bf4: byte0 non-zero: enable R17 tuning, 0: disable R17 tuning
6733 if (macValue & 0x000000ff)
6735 pAdapter->BbpTuning.bEnable = TRUE;
6736 DBGPRINT(RT_DEBUG_TRACE,("turn on R17 tuning\n"));
6741 pAdapter->BbpTuning.bEnable = FALSE;
6742 R66 = 0x26 + GET_LNA_GAIN(pAdapter);
6744 if (ATE_ON(pAdapter))
6746 ATE_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R66, (0x26 + GET_LNA_GAIN(pAdapter)));
6749 #endif // RALINK_ATE //
6750 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R66, (0x26 + GET_LNA_GAIN(pAdapter)));
6751 DBGPRINT(RT_DEBUG_TRACE,("turn off R17 tuning, restore to 0x%02x\n", R66));
6756 DBGPRINT(RT_DEBUG_TRACE, ("MacAddr=%02lx, MacValue=0x%x\n", macAddr, macValue));
6758 RTMP_IO_WRITE32(pAdapter, macAddr, macValue);
6759 sprintf(msg+strlen(msg), "[0x%08lX]:%08X ", macAddr, macValue);
6764 if(strlen(msg) == 1)
6765 sprintf(msg+strlen(msg), "===>Error command format!");
6767 // Copy the information into the user buffer
6768 wrq->u.data.length = strlen(msg);
6769 Status = copy_to_user(wrq->u.data.pointer, msg, wrq->u.data.length);
6771 DBGPRINT(RT_DEBUG_TRACE, ("<==RTMPIoctlMAC\n\n"));
6775 ==========================================================================
6779 pAdapter Pointer to our adapter
6780 wrq Pointer to the ioctl argument
6787 1.) iwpriv ra0 e2p 0 ==> read E2PROM where Addr=0x0
6788 2.) iwpriv ra0 e2p 0=1234 ==> write E2PROM where Addr=0x0, value=1234
6789 ==========================================================================
6791 VOID RTMPIoctlE2PROM(
6792 IN PRTMP_ADAPTER pAdapter,
6793 IN struct iwreq *wrq)
6801 UCHAR temp[16], temp2[16];
6806 memset(msg, 0x00, 1024);
6807 if (wrq->u.data.length > 1) //No parameters.
6809 Status = copy_from_user(arg, wrq->u.data.pointer, (wrq->u.data.length > 255) ? 255 : wrq->u.data.length);
6812 //Parsing Read or Write
6819 if ((value = rtstrchr(this_char, '=')) != NULL)
6822 if (!value || !*value)
6826 if(strlen(this_char) > 4)
6829 j = strlen(this_char);
6832 if(this_char[j] > 'f' || this_char[j] < '0')
6837 k = j = strlen(this_char);
6840 this_char[4-k+j] = this_char[j];
6844 this_char[3-k++]='0';
6847 if(strlen(this_char) == 4)
6849 AtoH(this_char, temp, 2);
6850 eepAddr = *temp*256 + temp[1];
6851 if (eepAddr < 0xFFFF)
6853 RT28xx_EEPROM_READ16(pAdapter, eepAddr, eepValue);
6854 sprintf(msg+strlen(msg), "[0x%04X]:0x%04X ", eepAddr , eepValue);
6857 {//Invalid parametes, so default printk all bbp
6864 memcpy(&temp2, value, strlen(value));
6865 temp2[strlen(value)] = '\0';
6868 if((strlen(this_char) > 4) || strlen(temp2) > 8)
6871 j = strlen(this_char);
6874 if(this_char[j] > 'f' || this_char[j] < '0')
6880 if(temp2[j] > 'f' || temp2[j] < '0')
6885 k = j = strlen(this_char);
6888 this_char[4-k+j] = this_char[j];
6892 this_char[3-k++]='0';
6896 k = j = strlen(temp2);
6899 temp2[4-k+j] = temp2[j];
6906 AtoH(this_char, temp, 2);
6907 eepAddr = *temp*256 + temp[1];
6909 AtoH(temp2, temp, 2);
6910 eepValue = *temp*256 + temp[1];
6912 RT28xx_EEPROM_WRITE16(pAdapter, eepAddr, eepValue);
6913 sprintf(msg+strlen(msg), "[0x%02X]:%02X ", eepAddr, eepValue);
6917 if(strlen(msg) == 1)
6918 sprintf(msg+strlen(msg), "===>Error command format!");
6921 // Copy the information into the user buffer
6922 wrq->u.data.length = strlen(msg);
6923 Status = copy_to_user(wrq->u.data.pointer, msg, wrq->u.data.length);
6925 DBGPRINT(RT_DEBUG_TRACE, ("<==RTMPIoctlE2PROM\n"));
6932 INT Set_TGnWifiTest_Proc(
6933 IN PRTMP_ADAPTER pAd,
6936 if (simple_strtol(arg, 0, 10) == 0)
6937 pAd->StaCfg.bTGnWifiTest = FALSE;
6939 pAd->StaCfg.bTGnWifiTest = TRUE;
6941 DBGPRINT(RT_DEBUG_TRACE, ("IF Set_TGnWifiTest_Proc::(bTGnWifiTest=%d)\n", pAd->StaCfg.bTGnWifiTest));
6945 INT Set_LongRetryLimit_Proc(
6946 IN PRTMP_ADAPTER pAdapter,
6949 TX_RTY_CFG_STRUC tx_rty_cfg;
6950 UCHAR LongRetryLimit = (UCHAR)simple_strtol(arg, 0, 10);
6952 RTMP_IO_READ32(pAdapter, TX_RTY_CFG, &tx_rty_cfg.word);
6953 tx_rty_cfg.field.LongRtyLimit = LongRetryLimit;
6954 RTMP_IO_WRITE32(pAdapter, TX_RTY_CFG, tx_rty_cfg.word);
6955 DBGPRINT(RT_DEBUG_TRACE, ("IF Set_LongRetryLimit_Proc::(tx_rty_cfg=0x%x)\n", tx_rty_cfg.word));
6959 INT Set_ShortRetryLimit_Proc(
6960 IN PRTMP_ADAPTER pAdapter,
6963 TX_RTY_CFG_STRUC tx_rty_cfg;
6964 UCHAR ShortRetryLimit = (UCHAR)simple_strtol(arg, 0, 10);
6966 RTMP_IO_READ32(pAdapter, TX_RTY_CFG, &tx_rty_cfg.word);
6967 tx_rty_cfg.field.ShortRtyLimit = ShortRetryLimit;
6968 RTMP_IO_WRITE32(pAdapter, TX_RTY_CFG, tx_rty_cfg.word);
6969 DBGPRINT(RT_DEBUG_TRACE, ("IF Set_ShortRetryLimit_Proc::(tx_rty_cfg=0x%x)\n", tx_rty_cfg.word));
6973 #ifdef EXT_BUILD_CHANNEL_LIST
6974 INT Set_Ieee80211dClientMode_Proc(
6975 IN PRTMP_ADAPTER pAdapter,
6978 if (simple_strtol(arg, 0, 10) == 0)
6979 pAdapter->StaCfg.IEEE80211dClientMode = Rt802_11_D_None;
6980 else if (simple_strtol(arg, 0, 10) == 1)
6981 pAdapter->StaCfg.IEEE80211dClientMode = Rt802_11_D_Flexible;
6982 else if (simple_strtol(arg, 0, 10) == 2)
6983 pAdapter->StaCfg.IEEE80211dClientMode = Rt802_11_D_Strict;
6987 DBGPRINT(RT_DEBUG_TRACE, ("Set_Ieee802dMode_Proc::(IEEEE0211dMode=%d)\n", pAdapter->StaCfg.IEEE80211dClientMode));
6990 #endif // EXT_BUILD_CHANNEL_LIST //
6992 #ifdef CARRIER_DETECTION_SUPPORT
6993 INT Set_CarrierDetect_Proc(
6994 IN PRTMP_ADAPTER pAd,
6997 if (simple_strtol(arg, 0, 10) == 0)
6998 pAd->CommonCfg.CarrierDetect.Enable = FALSE;
7000 pAd->CommonCfg.CarrierDetect.Enable = TRUE;
7002 DBGPRINT(RT_DEBUG_TRACE, ("IF Set_CarrierDetect_Proc::(CarrierDetect.Enable=%d)\n", pAd->CommonCfg.CarrierDetect.Enable));
7005 #endif // CARRIER_DETECTION_SUPPORT //
7008 INT Show_Adhoc_MacTable_Proc(
7009 IN PRTMP_ADAPTER pAd,
7014 sprintf(extra, "\n");
7016 #ifdef DOT11_N_SUPPORT
7017 sprintf(extra + strlen(extra), "HT Operating Mode : %d\n", pAd->CommonCfg.AddHTInfo.AddHtInfo2.OperaionMode);
7018 #endif // DOT11_N_SUPPORT //
7020 sprintf(extra + strlen(extra), "\n%-19s%-4s%-4s%-7s%-7s%-7s%-10s%-6s%-6s%-6s%-6s\n",
7021 "MAC", "AID", "BSS", "RSSI0", "RSSI1", "RSSI2", "PhMd", "BW", "MCS", "SGI", "STBC");
7023 for (i=1; i<MAX_LEN_OF_MAC_TABLE; i++)
7025 PMAC_TABLE_ENTRY pEntry = &pAd->MacTab.Content[i];
7027 if (strlen(extra) > (IW_PRIV_SIZE_MASK - 30))
7029 if ((pEntry->ValidAsCLI || pEntry->ValidAsApCli) && (pEntry->Sst == SST_ASSOC))
7031 sprintf(extra + strlen(extra), "%02X:%02X:%02X:%02X:%02X:%02X ",
7032 pEntry->Addr[0], pEntry->Addr[1], pEntry->Addr[2],
7033 pEntry->Addr[3], pEntry->Addr[4], pEntry->Addr[5]);
7034 sprintf(extra + strlen(extra), "%-4d", (int)pEntry->Aid);
7035 sprintf(extra + strlen(extra), "%-4d", (int)pEntry->apidx);
7036 sprintf(extra + strlen(extra), "%-7d", pEntry->RssiSample.AvgRssi0);
7037 sprintf(extra + strlen(extra), "%-7d", pEntry->RssiSample.AvgRssi1);
7038 sprintf(extra + strlen(extra), "%-7d", pEntry->RssiSample.AvgRssi2);
7039 sprintf(extra + strlen(extra), "%-10s", GetPhyMode(pEntry->HTPhyMode.field.MODE));
7040 sprintf(extra + strlen(extra), "%-6s", GetBW(pEntry->HTPhyMode.field.BW));
7041 sprintf(extra + strlen(extra), "%-6d", pEntry->HTPhyMode.field.MCS);
7042 sprintf(extra + strlen(extra), "%-6d", pEntry->HTPhyMode.field.ShortGI);
7043 sprintf(extra + strlen(extra), "%-6d", pEntry->HTPhyMode.field.STBC);
7044 sprintf(extra + strlen(extra), "%-10d, %d, %d%%\n", pEntry->DebugFIFOCount, pEntry->DebugTxCount,
7045 (pEntry->DebugTxCount) ? ((pEntry->DebugTxCount-pEntry->DebugFIFOCount)*100/pEntry->DebugTxCount) : 0);
7046 sprintf(extra, "%s\n", extra);