2 *************************************************************************
4 * 5F., No.36, Taiyuan St., Jhubei City,
8 * (c) Copyright 2002-2007, Ralink Technology, Inc.
10 * This program is free software; you can redistribute it and/or modify *
11 * it under the terms of the GNU General Public License as published by *
12 * the Free Software Foundation; either version 2 of the License, or *
13 * (at your option) any later version. *
15 * This program is distributed in the hope that it will be useful, *
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
18 * GNU General Public License for more details. *
20 * You should have received a copy of the GNU General Public License *
21 * along with this program; if not, write to the *
22 * Free Software Foundation, Inc., *
23 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
25 *************************************************************************
31 IOCTL related subroutines
35 -------- ---------- ----------------------------------------------
36 Rory Chen 01-03-2003 created
37 Rory Chen 02-14-2005 modify to support RT61
40 #include "rt_config.h"
43 extern ULONG RTDebugLevel;
47 #define WEP_SMALL_KEY_LEN (40/8)
48 #define WEP_LARGE_KEY_LEN (104/8)
50 #define GROUP_KEY_NO 4
52 extern UCHAR CipherWpa2Template[];
53 extern UCHAR CipherWpaPskTkip[];
54 extern UCHAR CipherWpaPskTkipLen;
56 typedef struct PACKED _RT_VERSION_INFO{
62 UINT DriverBuildMonth;
64 } RT_VERSION_INFO, *PRT_VERSION_INFO;
66 struct iw_priv_args privtab[] = {
68 IW_PRIV_TYPE_CHAR | 1024, 0,
71 { RTPRIV_IOCTL_SHOW, 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK,
73 { RTPRIV_IOCTL_SHOW, IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK,
75 /* --- sub-ioctls definitions --- */
77 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "connStatus" },
79 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "driverVer" },
81 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "bainfo" },
83 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "descinfo" },
85 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "radio_off" },
87 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "radio_on" },
88 #ifdef QOS_DLS_SUPPORT
89 { SHOW_DLS_ENTRY_INFO,
90 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "dlsentryinfo" },
91 #endif // QOS_DLS_SUPPORT //
93 IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "show" },
94 /* --- sub-ioctls relations --- */
98 IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK,
101 IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | 1024,
104 IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | 1024,
108 { RTPRIV_IOCTL_STATISTICS,
109 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK,
111 { RTPRIV_IOCTL_GSITESURVEY,
112 0, IW_PRIV_TYPE_CHAR | 1024,
117 IN PRTMP_ADAPTER pAdapter,
121 INT Set_WmmCapable_Proc(
122 IN PRTMP_ADAPTER pAd,
126 INT Set_NetworkType_Proc(
127 IN PRTMP_ADAPTER pAdapter,
130 INT Set_AuthMode_Proc(
131 IN PRTMP_ADAPTER pAdapter,
134 INT Set_EncrypType_Proc(
135 IN PRTMP_ADAPTER pAdapter,
138 INT Set_DefaultKeyID_Proc(
139 IN PRTMP_ADAPTER pAdapter,
143 IN PRTMP_ADAPTER pAdapter,
147 IN PRTMP_ADAPTER pAdapter,
151 IN PRTMP_ADAPTER pAdapter,
155 IN PRTMP_ADAPTER pAdapter,
159 IN PRTMP_ADAPTER pAdapter,
164 IN PRTMP_ADAPTER pAdapter,
167 #ifdef WPA_SUPPLICANT_SUPPORT
169 IN PRTMP_ADAPTER pAd,
171 #endif // WPA_SUPPLICANT_SUPPORT //
175 IN PRTMP_ADAPTER pAdapter,
176 IN struct iwreq *wrq);
179 IN PRTMP_ADAPTER pAdapter,
180 IN struct iwreq *wrq);
182 VOID RTMPIoctlE2PROM(
183 IN PRTMP_ADAPTER pAdapter,
184 IN struct iwreq *wrq);
188 NDIS_STATUS RTMPWPANoneAddKeyProc(
189 IN PRTMP_ADAPTER pAd,
192 INT Set_FragTest_Proc(
193 IN PRTMP_ADAPTER pAdapter,
196 #ifdef DOT11_N_SUPPORT
197 INT Set_TGnWifiTest_Proc(
198 IN PRTMP_ADAPTER pAd,
200 #endif // DOT11_N_SUPPORT //
202 INT Set_LongRetryLimit_Proc(
203 IN PRTMP_ADAPTER pAdapter,
206 INT Set_ShortRetryLimit_Proc(
207 IN PRTMP_ADAPTER pAdapter,
210 #ifdef EXT_BUILD_CHANNEL_LIST
211 INT Set_Ieee80211dClientMode_Proc(
212 IN PRTMP_ADAPTER pAdapter,
214 #endif // EXT_BUILD_CHANNEL_LIST //
216 #ifdef CARRIER_DETECTION_SUPPORT
217 INT Set_CarrierDetect_Proc(
218 IN PRTMP_ADAPTER pAd,
220 #endif // CARRIER_DETECTION_SUPPORT //
224 INT (*set_proc)(PRTMP_ADAPTER pAdapter, PUCHAR arg);
225 } *PRTMP_PRIVATE_SET_PROC, RTMP_PRIVATE_SUPPORT_PROC[] = {
226 {"DriverVersion", Set_DriverVersion_Proc},
227 {"CountryRegion", Set_CountryRegion_Proc},
228 {"CountryRegionABand", Set_CountryRegionABand_Proc},
229 {"SSID", Set_SSID_Proc},
230 {"WirelessMode", Set_WirelessMode_Proc},
231 {"TxBurst", Set_TxBurst_Proc},
232 {"TxPreamble", Set_TxPreamble_Proc},
233 {"TxPower", Set_TxPower_Proc},
234 {"Channel", Set_Channel_Proc},
235 {"BGProtection", Set_BGProtection_Proc},
236 {"RTSThreshold", Set_RTSThreshold_Proc},
237 {"FragThreshold", Set_FragThreshold_Proc},
238 #ifdef DOT11_N_SUPPORT
239 {"HtBw", Set_HtBw_Proc},
240 {"HtMcs", Set_HtMcs_Proc},
241 {"HtGi", Set_HtGi_Proc},
242 {"HtOpMode", Set_HtOpMode_Proc},
243 {"HtExtcha", Set_HtExtcha_Proc},
244 {"HtMpduDensity", Set_HtMpduDensity_Proc},
245 {"HtBaWinSize", Set_HtBaWinSize_Proc},
246 {"HtRdg", Set_HtRdg_Proc},
247 {"HtAmsdu", Set_HtAmsdu_Proc},
248 {"HtAutoBa", Set_HtAutoBa_Proc},
249 {"HtBaDecline", Set_BADecline_Proc},
250 {"HtProtect", Set_HtProtect_Proc},
251 {"HtMimoPs", Set_HtMimoPs_Proc},
252 #endif // DOT11_N_SUPPORT //
254 #ifdef AGGREGATION_SUPPORT
255 {"PktAggregate", Set_PktAggregate_Proc},
259 {"WmmCapable", Set_WmmCapable_Proc},
261 {"IEEE80211H", Set_IEEE80211H_Proc},
262 {"NetworkType", Set_NetworkType_Proc},
263 {"AuthMode", Set_AuthMode_Proc},
264 {"EncrypType", Set_EncrypType_Proc},
265 {"DefaultKeyID", Set_DefaultKeyID_Proc},
266 {"Key1", Set_Key1_Proc},
267 {"Key2", Set_Key2_Proc},
268 {"Key3", Set_Key3_Proc},
269 {"Key4", Set_Key4_Proc},
270 {"WPAPSK", Set_WPAPSK_Proc},
271 {"ResetCounter", Set_ResetStatCounter_Proc},
272 {"PSMode", Set_PSMode_Proc},
274 {"Debug", Set_Debug_Proc},
278 {"ATE", Set_ATE_Proc},
279 {"ATEDA", Set_ATE_DA_Proc},
280 {"ATESA", Set_ATE_SA_Proc},
281 {"ATEBSSID", Set_ATE_BSSID_Proc},
282 {"ATECHANNEL", Set_ATE_CHANNEL_Proc},
283 {"ATETXPOW0", Set_ATE_TX_POWER0_Proc},
284 {"ATETXPOW1", Set_ATE_TX_POWER1_Proc},
285 {"ATETXANT", Set_ATE_TX_Antenna_Proc},
286 {"ATERXANT", Set_ATE_RX_Antenna_Proc},
287 {"ATETXFREQOFFSET", Set_ATE_TX_FREQOFFSET_Proc},
288 {"ATETXBW", Set_ATE_TX_BW_Proc},
289 {"ATETXLEN", Set_ATE_TX_LENGTH_Proc},
290 {"ATETXCNT", Set_ATE_TX_COUNT_Proc},
291 {"ATETXMCS", Set_ATE_TX_MCS_Proc},
292 {"ATETXMODE", Set_ATE_TX_MODE_Proc},
293 {"ATETXGI", Set_ATE_TX_GI_Proc},
294 {"ATERXFER", Set_ATE_RX_FER_Proc},
295 {"ATERRF", Set_ATE_Read_RF_Proc},
296 {"ATEWRF1", Set_ATE_Write_RF1_Proc},
297 {"ATEWRF2", Set_ATE_Write_RF2_Proc},
298 {"ATEWRF3", Set_ATE_Write_RF3_Proc},
299 {"ATEWRF4", Set_ATE_Write_RF4_Proc},
300 {"ATELDE2P", Set_ATE_Load_E2P_Proc},
301 {"ATERE2P", Set_ATE_Read_E2P_Proc},
302 {"ATESHOW", Set_ATE_Show_Proc},
303 {"ATEHELP", Set_ATE_Help_Proc},
305 #ifdef RALINK_28xx_QA
306 {"TxStop", Set_TxStop_Proc},
307 {"RxStop", Set_RxStop_Proc},
308 #endif // RALINK_28xx_QA //
309 #endif // RALINK_ATE //
311 #ifdef WPA_SUPPLICANT_SUPPORT
312 {"WpaSupport", Set_Wpa_Support},
313 #endif // WPA_SUPPLICANT_SUPPORT //
317 {"FixedTxMode", Set_FixedTxMode_Proc},
318 #ifdef CONFIG_APSTA_MIXED_SUPPORT
319 {"OpMode", Set_OpMode_Proc},
320 #endif // CONFIG_APSTA_MIXED_SUPPORT //
321 #ifdef DOT11_N_SUPPORT
322 {"TGnWifiTest", Set_TGnWifiTest_Proc},
323 {"ForceGF", Set_ForceGF_Proc},
324 #endif // DOT11_N_SUPPORT //
325 #ifdef QOS_DLS_SUPPORT
326 {"DlsAddEntry", Set_DlsAddEntry_Proc},
327 {"DlsTearDownEntry", Set_DlsTearDownEntry_Proc},
328 #endif // QOS_DLS_SUPPORT //
329 {"LongRetry", Set_LongRetryLimit_Proc},
330 {"ShortRetry", Set_ShortRetryLimit_Proc},
331 #ifdef EXT_BUILD_CHANNEL_LIST
332 {"11dClientMode", Set_Ieee80211dClientMode_Proc},
333 #endif // EXT_BUILD_CHANNEL_LIST //
334 #ifdef CARRIER_DETECTION_SUPPORT
335 {"CarrierDetect", Set_CarrierDetect_Proc},
336 #endif // CARRIER_DETECTION_SUPPORT //
343 IN PRTMP_ADAPTER pAd,
344 IN PNDIS_802_11_KEY pKey)
347 MAC_TABLE_ENTRY *pEntry;
349 DBGPRINT(RT_DEBUG_TRACE, ("RTMPAddKey ------>\n"));
351 RTMP_CLEAR_PSFLAG(pAd, fRTMP_PS_CAN_GO_SLEEP);
352 if (RTMP_TEST_PSFLAG(pAd, fRTMP_PS_SET_PCI_CLK_OFF_COMMAND))
354 if (pAd->StaCfg.bRadio == FALSE)
356 RTMP_SET_PSFLAG(pAd, fRTMP_PS_CAN_GO_SLEEP);
359 DBGPRINT(RT_DEBUG_TRACE,("RTMPWPAAddKeyProc1==>\n"));
360 RTMPPCIeLinkCtrlValueRestore(pAd, RESTORE_HALT);
362 pAd->bPCIclkOff = FALSE;
365 if (pAd->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
367 if (pKey->KeyIndex & 0x80000000)
369 if (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPANone)
371 NdisZeroMemory(pAd->StaCfg.PMK, 32);
372 NdisMoveMemory(pAd->StaCfg.PMK, pKey->KeyMaterial, pKey->KeyLength);
376 NdisZeroMemory(&pAd->SharedKey[BSS0][0], sizeof(CIPHER_KEY));
377 pAd->SharedKey[BSS0][0].KeyLen = LEN_TKIP_EK;
378 NdisMoveMemory(pAd->SharedKey[BSS0][0].Key, pKey->KeyMaterial, LEN_TKIP_EK);
379 #ifdef WPA_SUPPLICANT_SUPPORT
380 if (pAd->StaCfg.PairCipher == Ndis802_11Encryption2Enabled)
382 NdisMoveMemory(pAd->SharedKey[BSS0][0].RxMic, pKey->KeyMaterial + LEN_TKIP_EK, LEN_TKIP_TXMICK);
383 NdisMoveMemory(pAd->SharedKey[BSS0][0].TxMic, pKey->KeyMaterial + LEN_TKIP_EK + LEN_TKIP_TXMICK, LEN_TKIP_RXMICK);
386 #endif // WPA_SUPPLICANT_SUPPORT //
388 NdisMoveMemory(pAd->SharedKey[BSS0][0].TxMic, pKey->KeyMaterial + LEN_TKIP_EK, LEN_TKIP_TXMICK);
389 NdisMoveMemory(pAd->SharedKey[BSS0][0].RxMic, pKey->KeyMaterial + LEN_TKIP_EK + LEN_TKIP_TXMICK, LEN_TKIP_RXMICK);
392 // Decide its ChiperAlg
393 if (pAd->StaCfg.PairCipher == Ndis802_11Encryption2Enabled)
394 pAd->SharedKey[BSS0][0].CipherAlg = CIPHER_TKIP;
395 else if (pAd->StaCfg.PairCipher == Ndis802_11Encryption3Enabled)
396 pAd->SharedKey[BSS0][0].CipherAlg = CIPHER_AES;
398 pAd->SharedKey[BSS0][0].CipherAlg = CIPHER_NONE;
400 // Update these related information to MAC_TABLE_ENTRY
401 pEntry = &pAd->MacTab.Content[BSSID_WCID];
402 NdisMoveMemory(pEntry->PairwiseKey.Key, pAd->SharedKey[BSS0][0].Key, LEN_TKIP_EK);
403 NdisMoveMemory(pEntry->PairwiseKey.RxMic, pAd->SharedKey[BSS0][0].RxMic, LEN_TKIP_RXMICK);
404 NdisMoveMemory(pEntry->PairwiseKey.TxMic, pAd->SharedKey[BSS0][0].TxMic, LEN_TKIP_TXMICK);
405 pEntry->PairwiseKey.CipherAlg = pAd->SharedKey[BSS0][0].CipherAlg;
407 // Update pairwise key information to ASIC Shared Key Table
408 AsicAddSharedKeyEntry(pAd,
411 pAd->SharedKey[BSS0][0].CipherAlg,
412 pAd->SharedKey[BSS0][0].Key,
413 pAd->SharedKey[BSS0][0].TxMic,
414 pAd->SharedKey[BSS0][0].RxMic);
416 // Update ASIC WCID attribute table and IVEIV table
417 RTMPAddWcidAttributeEntry(pAd,
420 pAd->SharedKey[BSS0][0].CipherAlg,
423 if (pAd->StaCfg.AuthMode >= Ndis802_11AuthModeWPA2)
425 // set 802.1x port control
426 STA_PORT_SECURED(pAd);
428 // Indicate Connected for GUI
429 pAd->IndicateMediaState = NdisMediaStateConnected;
435 pAd->StaCfg.DefaultKeyId = (pKey->KeyIndex & 0xFF);
436 NdisZeroMemory(&pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId], sizeof(CIPHER_KEY));
437 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].KeyLen = LEN_TKIP_EK;
438 NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].Key, pKey->KeyMaterial, LEN_TKIP_EK);
439 #ifdef WPA_SUPPLICANT_SUPPORT
440 if (pAd->StaCfg.GroupCipher == Ndis802_11Encryption2Enabled)
442 NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].RxMic, pKey->KeyMaterial + LEN_TKIP_EK, LEN_TKIP_TXMICK);
443 NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].TxMic, pKey->KeyMaterial + LEN_TKIP_EK + LEN_TKIP_TXMICK, LEN_TKIP_RXMICK);
446 #endif // WPA_SUPPLICANT_SUPPORT //
448 NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].TxMic, pKey->KeyMaterial + LEN_TKIP_EK, LEN_TKIP_TXMICK);
449 NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].RxMic, pKey->KeyMaterial + LEN_TKIP_EK + LEN_TKIP_TXMICK, LEN_TKIP_RXMICK);
452 // Update Shared Key CipherAlg
453 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg = CIPHER_NONE;
454 if (pAd->StaCfg.GroupCipher == Ndis802_11Encryption2Enabled)
455 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg = CIPHER_TKIP;
456 else if (pAd->StaCfg.GroupCipher == Ndis802_11Encryption3Enabled)
457 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg = CIPHER_AES;
459 // Update group key information to ASIC Shared Key Table
460 AsicAddSharedKeyEntry(pAd,
462 pAd->StaCfg.DefaultKeyId,
463 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg,
464 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].Key,
465 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].TxMic,
466 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].RxMic);
468 // Update ASIC WCID attribute table and IVEIV table
469 RTMPAddWcidAttributeEntry(pAd,
471 pAd->StaCfg.DefaultKeyId,
472 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg,
475 // set 802.1x port control
476 STA_PORT_SECURED(pAd);
478 // Indicate Connected for GUI
479 pAd->IndicateMediaState = NdisMediaStateConnected;
482 else // dynamic WEP from wpa_supplicant
487 if(pKey->KeyLength == 32)
490 KeyIdx = pKey->KeyIndex & 0x0fffffff;
494 // it is a default shared key, for Pairwise key setting
495 if (pKey->KeyIndex & 0x80000000)
497 pEntry = MacTableLookup(pAd, pKey->BSSID);
501 DBGPRINT(RT_DEBUG_TRACE, ("RTMPAddKey: Set Pair-wise Key\n"));
503 // set key material and key length
504 pEntry->PairwiseKey.KeyLen = (UCHAR)pKey->KeyLength;
505 NdisMoveMemory(pEntry->PairwiseKey.Key, &pKey->KeyMaterial, pKey->KeyLength);
508 if (pKey->KeyLength == 5)
509 pEntry->PairwiseKey.CipherAlg = CIPHER_WEP64;
511 pEntry->PairwiseKey.CipherAlg = CIPHER_WEP128;
513 // Add Pair-wise key to Asic
514 AsicAddPairwiseKeyEntry(
518 &pEntry->PairwiseKey);
520 // update WCID attribute table and IVEIV table for this entry
521 RTMPAddWcidAttributeEntry(
524 KeyIdx, // The value may be not zero
525 pEntry->PairwiseKey.CipherAlg,
532 // Default key for tx (shared key)
533 pAd->StaCfg.DefaultKeyId = (UCHAR) KeyIdx;
535 // set key material and key length
536 pAd->SharedKey[BSS0][KeyIdx].KeyLen = (UCHAR) pKey->KeyLength;
537 NdisMoveMemory(pAd->SharedKey[BSS0][KeyIdx].Key, &pKey->KeyMaterial, pKey->KeyLength);
540 if (pKey->KeyLength == 5)
541 pAd->SharedKey[BSS0][KeyIdx].CipherAlg = CIPHER_WEP64;
543 pAd->SharedKey[BSS0][KeyIdx].CipherAlg = CIPHER_WEP128;
545 CipherAlg = pAd->SharedKey[BSS0][KeyIdx].CipherAlg;
546 Key = pAd->SharedKey[BSS0][KeyIdx].Key;
548 // Set Group key material to Asic
549 AsicAddSharedKeyEntry(pAd, BSS0, KeyIdx, CipherAlg, Key, NULL, NULL);
551 // Update WCID attribute table and IVEIV table for this group key table
552 RTMPAddWcidAttributeEntry(pAd, BSS0, KeyIdx, CipherAlg, NULL);
558 RTMP_SET_PSFLAG(pAd, fRTMP_PS_CAN_GO_SLEEP);
559 DBGPRINT(RT_DEBUG_INFO, ("<------ RTMPAddKey\n"));
563 char * rtstrchr(const char * s, int c)
565 for(; *s != (char) c; ++s)
572 This is required for LinEX2004/kernel2.6.7 to provide iwlist scanning function
576 rt_ioctl_giwname(struct net_device *dev,
577 struct iw_request_info *info,
578 char *name, char *extra)
580 // PRTMP_ADAPTER pAdapter = dev->ml_priv;
582 strncpy(name, "RT2860 Wireless", IFNAMSIZ);
586 int rt_ioctl_siwfreq(struct net_device *dev,
587 struct iw_request_info *info,
588 struct iw_freq *freq, char *extra)
590 PRTMP_ADAPTER pAdapter = dev->ml_priv;
593 //check if the interface is down
594 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
596 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
604 if((freq->e == 0) && (freq->m <= 1000))
605 chan = freq->m; // Setting by channel number
607 MAP_KHZ_TO_CHANNEL_ID( (freq->m /100) , chan); // Setting by frequency - search the table , like 2.412G, 2.422G,
609 if (ChannelSanity(pAdapter, chan) == TRUE)
611 pAdapter->CommonCfg.Channel = chan;
612 DBGPRINT(RT_DEBUG_ERROR, ("==>rt_ioctl_siwfreq::SIOCSIWFREQ[cmd=0x%x] (Channel=%d)\n", SIOCSIWFREQ, pAdapter->CommonCfg.Channel));
619 int rt_ioctl_giwfreq(struct net_device *dev,
620 struct iw_request_info *info,
621 struct iw_freq *freq, char *extra)
623 VIRTUAL_ADAPTER *pVirtualAd = NULL;
624 PRTMP_ADAPTER pAdapter = NULL;
628 if (dev->priv_flags == INT_MAIN)
630 pAdapter = dev->ml_priv;
634 pVirtualAd = dev->ml_priv;
635 if (pVirtualAd && pVirtualAd->RtmpDev)
636 pAdapter = pVirtualAd->RtmpDev->ml_priv;
639 if (pAdapter == NULL)
641 /* if 1st open fail, pAd will be free;
642 So the net_dev->ml_priv will be NULL in 2rd open */
646 ch = pAdapter->CommonCfg.Channel;
648 DBGPRINT(RT_DEBUG_TRACE,("==>rt_ioctl_giwfreq %d\n", ch));
650 MAP_CHANNEL_ID_TO_KHZ(ch, m);
656 int rt_ioctl_siwmode(struct net_device *dev,
657 struct iw_request_info *info,
658 __u32 *mode, char *extra)
660 PRTMP_ADAPTER pAdapter = dev->ml_priv;
662 //check if the interface is down
663 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
665 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
672 Set_NetworkType_Proc(pAdapter, "Adhoc");
675 Set_NetworkType_Proc(pAdapter, "Infra");
677 case IW_MODE_MONITOR:
678 Set_NetworkType_Proc(pAdapter, "Monitor");
681 DBGPRINT(RT_DEBUG_TRACE, ("===>rt_ioctl_siwmode::SIOCSIWMODE (unknown %d)\n", *mode));
685 // Reset Ralink supplicant to not use, it will be set to start when UI set PMK key
686 pAdapter->StaCfg.WpaState = SS_NOTUSE;
691 int rt_ioctl_giwmode(struct net_device *dev,
692 struct iw_request_info *info,
693 __u32 *mode, char *extra)
695 PRTMP_ADAPTER pAdapter = NULL;
696 VIRTUAL_ADAPTER *pVirtualAd = NULL;
698 if (dev->priv_flags == INT_MAIN)
700 pAdapter = dev->ml_priv;
704 pVirtualAd = dev->ml_priv;
705 if (pVirtualAd && pVirtualAd->RtmpDev)
706 pAdapter = pVirtualAd->RtmpDev->ml_priv;
709 if (pAdapter == NULL)
711 /* if 1st open fail, pAd will be free;
712 So the net_dev->ml_priv will be NULL in 2rd open */
716 if (ADHOC_ON(pAdapter))
717 *mode = IW_MODE_ADHOC;
718 else if (INFRA_ON(pAdapter))
719 *mode = IW_MODE_INFRA;
720 else if (MONITOR_ON(pAdapter))
722 *mode = IW_MODE_MONITOR;
725 *mode = IW_MODE_AUTO;
727 DBGPRINT(RT_DEBUG_TRACE, ("==>rt_ioctl_giwmode(mode=%d)\n", *mode));
731 int rt_ioctl_siwsens(struct net_device *dev,
732 struct iw_request_info *info,
733 char *name, char *extra)
735 PRTMP_ADAPTER pAdapter = dev->ml_priv;
737 //check if the interface is down
738 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
740 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
747 int rt_ioctl_giwsens(struct net_device *dev,
748 struct iw_request_info *info,
749 char *name, char *extra)
754 int rt_ioctl_giwrange(struct net_device *dev,
755 struct iw_request_info *info,
756 struct iw_point *data, char *extra)
758 PRTMP_ADAPTER pAdapter = NULL;
759 VIRTUAL_ADAPTER *pVirtualAd = NULL;
760 struct iw_range *range = (struct iw_range *) extra;
764 if (dev->priv_flags == INT_MAIN)
766 pAdapter = dev->ml_priv;
770 pVirtualAd = dev->ml_priv;
771 if (pVirtualAd && pVirtualAd->RtmpDev)
772 pAdapter = pVirtualAd->RtmpDev->ml_priv;
775 if (pAdapter == NULL)
777 /* if 1st open fail, pAd will be free;
778 So the net_dev->ml_priv will be NULL in 2rd open */
782 DBGPRINT(RT_DEBUG_TRACE ,("===>rt_ioctl_giwrange\n"));
783 data->length = sizeof(struct iw_range);
784 memset(range, 0, sizeof(struct iw_range));
786 range->txpower_capa = IW_TXPOW_DBM;
788 if (INFRA_ON(pAdapter)||ADHOC_ON(pAdapter))
790 range->min_pmp = 1 * 1024;
791 range->max_pmp = 65535 * 1024;
792 range->min_pmt = 1 * 1024;
793 range->max_pmt = 1000 * 1024;
794 range->pmp_flags = IW_POWER_PERIOD;
795 range->pmt_flags = IW_POWER_TIMEOUT;
796 range->pm_capa = IW_POWER_PERIOD | IW_POWER_TIMEOUT |
797 IW_POWER_UNICAST_R | IW_POWER_ALL_R;
800 range->we_version_compiled = WIRELESS_EXT;
801 range->we_version_source = 14;
803 range->retry_capa = IW_RETRY_LIMIT;
804 range->retry_flags = IW_RETRY_LIMIT;
805 range->min_retry = 0;
806 range->max_retry = 255;
808 range->num_channels = pAdapter->ChannelListNum;
811 for (i = 1; i <= range->num_channels; i++)
814 range->freq[val].i = pAdapter->ChannelList[i-1].Channel;
815 MAP_CHANNEL_ID_TO_KHZ(pAdapter->ChannelList[i-1].Channel, m);
816 range->freq[val].m = m * 100; /* HZ */
818 range->freq[val].e = 1;
820 if (val == IW_MAX_FREQUENCIES)
823 range->num_frequency = val;
825 range->max_qual.qual = 100; /* what is correct max? This was not
826 * documented exactly. At least
827 * 69 has been observed. */
828 range->max_qual.level = 0; /* dB */
829 range->max_qual.noise = 0; /* dB */
831 /* What would be suitable values for "average/typical" qual? */
832 range->avg_qual.qual = 20;
833 range->avg_qual.level = -60;
834 range->avg_qual.noise = -95;
835 range->sensitivity = 3;
837 range->max_encoding_tokens = NR_WEP_KEYS;
838 range->num_encoding_sizes = 2;
839 range->encoding_size[0] = 5;
840 range->encoding_size[1] = 13;
843 range->max_rts = 2347;
844 range->min_frag = 256;
845 range->max_frag = 2346;
847 #if WIRELESS_EXT > 17
848 /* IW_ENC_CAPA_* bit field */
849 range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 |
850 IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP;
856 int rt_ioctl_siwap(struct net_device *dev,
857 struct iw_request_info *info,
858 struct sockaddr *ap_addr, char *extra)
860 PRTMP_ADAPTER pAdapter = dev->ml_priv;
861 NDIS_802_11_MAC_ADDRESS Bssid;
863 //check if the interface is down
864 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
866 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
870 if (pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE)
872 RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
873 DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
876 // tell CNTL state machine to call NdisMSetInformationComplete() after completing
877 // this request, because this request is initiated by NDIS.
878 pAdapter->MlmeAux.CurrReqIsFromNdis = FALSE;
879 // Prevent to connect AP again in STAMlmePeriodicExec
880 pAdapter->MlmeAux.AutoReconnectSsidLen= 32;
882 memset(Bssid, 0, MAC_ADDR_LEN);
883 memcpy(Bssid, ap_addr->sa_data, MAC_ADDR_LEN);
884 MlmeEnqueue(pAdapter,
885 MLME_CNTL_STATE_MACHINE,
887 sizeof(NDIS_802_11_MAC_ADDRESS),
890 DBGPRINT(RT_DEBUG_TRACE, ("IOCTL::SIOCSIWAP %02x:%02x:%02x:%02x:%02x:%02x\n",
891 Bssid[0], Bssid[1], Bssid[2], Bssid[3], Bssid[4], Bssid[5]));
896 int rt_ioctl_giwap(struct net_device *dev,
897 struct iw_request_info *info,
898 struct sockaddr *ap_addr, char *extra)
900 PRTMP_ADAPTER pAdapter = NULL;
901 VIRTUAL_ADAPTER *pVirtualAd = NULL;
903 if (dev->priv_flags == INT_MAIN)
905 pAdapter = dev->ml_priv;
909 pVirtualAd = dev->ml_priv;
910 if (pVirtualAd && pVirtualAd->RtmpDev)
911 pAdapter = pVirtualAd->RtmpDev->ml_priv;
914 if (pAdapter == NULL)
916 /* if 1st open fail, pAd will be free;
917 So the net_dev->ml_priv will be NULL in 2rd open */
921 if (INFRA_ON(pAdapter) || ADHOC_ON(pAdapter))
923 ap_addr->sa_family = ARPHRD_ETHER;
924 memcpy(ap_addr->sa_data, &pAdapter->CommonCfg.Bssid, ETH_ALEN);
926 #ifdef WPA_SUPPLICANT_SUPPORT
928 else if (pAdapter->StaCfg.WpaSupplicantUP != WPA_SUPPLICANT_DISABLE)
930 ap_addr->sa_family = ARPHRD_ETHER;
931 memcpy(ap_addr->sa_data, &pAdapter->MlmeAux.Bssid, ETH_ALEN);
933 #endif // WPA_SUPPLICANT_SUPPORT //
936 DBGPRINT(RT_DEBUG_TRACE, ("IOCTL::SIOCGIWAP(=EMPTY)\n"));
944 * Units are in db above the noise floor. That means the
945 * rssi values reported in the tx/rx descriptors in the
946 * driver are the SNR expressed in db.
948 * If you assume that the noise floor is -95, which is an
949 * excellent assumption 99.5 % of the time, then you can
950 * derive the absolute signal level (i.e. -95 + rssi).
951 * There are some other slight factors to take into account
952 * depending on whether the rssi measurement is from 11b,
953 * 11g, or 11a. These differences are at most 2db and
956 * NB: various calculations are based on the orinoco/wavelan
957 * drivers for compatibility
959 static void set_quality(PRTMP_ADAPTER pAdapter,
960 struct iw_quality *iq,
967 ChannelQuality = 100;
968 else if (rssi >= -80) // between -50 ~ -80dbm
969 ChannelQuality = (__u8)(24 + ((rssi + 80) * 26)/10);
970 else if (rssi >= -90) // between -80 ~ -90dbm
971 ChannelQuality = (__u8)((rssi + 90) * 26)/10;
975 iq->qual = (__u8)ChannelQuality;
977 iq->level = (__u8)(rssi);
978 iq->noise = (pAdapter->BbpWriteLatch[66] > pAdapter->BbpTuning.FalseCcaUpperThreshold) ? ((__u8)pAdapter->BbpTuning.FalseCcaUpperThreshold) : ((__u8) pAdapter->BbpWriteLatch[66]); // noise level (dBm)
979 iq->noise += 256 - 143;
980 iq->updated = pAdapter->iw_stats.qual.updated;
983 int rt_ioctl_iwaplist(struct net_device *dev,
984 struct iw_request_info *info,
985 struct iw_point *data, char *extra)
987 PRTMP_ADAPTER pAdapter = dev->ml_priv;
989 struct sockaddr addr[IW_MAX_AP];
990 struct iw_quality qual[IW_MAX_AP];
993 //check if the interface is down
994 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
996 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1002 for (i = 0; i <IW_MAX_AP ; i++)
1004 if (i >= pAdapter->ScanTab.BssNr)
1006 addr[i].sa_family = ARPHRD_ETHER;
1007 memcpy(addr[i].sa_data, &pAdapter->ScanTab.BssEntry[i].Bssid, MAC_ADDR_LEN);
1008 set_quality(pAdapter, &qual[i], pAdapter->ScanTab.BssEntry[i].Rssi);
1011 memcpy(extra, &addr, i*sizeof(addr[0]));
1012 data->flags = 1; /* signal quality present (sort of) */
1013 memcpy(extra + i*sizeof(addr[0]), &qual, i*sizeof(qual[i]));
1019 int rt_ioctl_siwscan(struct net_device *dev,
1020 struct iw_request_info *info,
1021 struct iw_point *data, char *extra)
1023 PRTMP_ADAPTER pAdapter = dev->ml_priv;
1026 int Status = NDIS_STATUS_SUCCESS;
1028 //check if the interface is down
1029 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1031 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1035 if (MONITOR_ON(pAdapter))
1037 DBGPRINT(RT_DEBUG_TRACE, ("!!! Driver is in Monitor Mode now !!!\n"));
1041 if ((pAdapter->OpMode == OPMODE_STA) && (IDLE_ON(pAdapter))
1042 && (pAdapter->StaCfg.bRadio == TRUE)
1043 && (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_IDLE_RADIO_OFF)))
1045 RT28xxPciAsicRadioOn(pAdapter, GUI_IDLE_POWER_SAVE);
1047 // Check if still radio off.
1048 else if (pAdapter->bPCIclkOff == TRUE)
1051 #ifdef WPA_SUPPLICANT_SUPPORT
1052 if (pAdapter->StaCfg.WpaSupplicantUP == WPA_SUPPLICANT_ENABLE)
1054 pAdapter->StaCfg.WpaSupplicantScanCount++;
1056 #endif // WPA_SUPPLICANT_SUPPORT //
1058 pAdapter->StaCfg.bScanReqIsFromWebUI = TRUE;
1059 if (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
1064 #ifdef WPA_SUPPLICANT_SUPPORT
1065 if ((pAdapter->StaCfg.WpaSupplicantUP == WPA_SUPPLICANT_ENABLE) &&
1066 (pAdapter->StaCfg.WpaSupplicantScanCount > 3))
1068 DBGPRINT(RT_DEBUG_TRACE, ("!!! WpaSupplicantScanCount > 3\n"));
1069 Status = NDIS_STATUS_SUCCESS;
1072 #endif // WPA_SUPPLICANT_SUPPORT //
1074 if ((OPSTATUS_TEST_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED)) &&
1075 ((pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA) ||
1076 (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK)) &&
1077 (pAdapter->StaCfg.PortSecured == WPA_802_1X_PORT_NOT_SECURED))
1079 DBGPRINT(RT_DEBUG_TRACE, ("!!! Link UP, Port Not Secured! ignore this set::OID_802_11_BSSID_LIST_SCAN\n"));
1080 Status = NDIS_STATUS_SUCCESS;
1084 if (pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE)
1086 RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
1087 DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
1090 // tell CNTL state machine to call NdisMSetInformationComplete() after completing
1091 // this request, because this request is initiated by NDIS.
1092 pAdapter->MlmeAux.CurrReqIsFromNdis = FALSE;
1093 // Reset allowed scan retries
1094 pAdapter->StaCfg.ScanCnt = 0;
1095 pAdapter->StaCfg.LastScanTime = Now;
1097 MlmeEnqueue(pAdapter,
1098 MLME_CNTL_STATE_MACHINE,
1099 OID_802_11_BSSID_LIST_SCAN,
1103 Status = NDIS_STATUS_SUCCESS;
1104 RT28XX_MLME_HANDLER(pAdapter);
1109 int rt_ioctl_giwscan(struct net_device *dev,
1110 struct iw_request_info *info,
1111 struct iw_point *data, char *extra)
1114 PRTMP_ADAPTER pAdapter = dev->ml_priv;
1116 char *current_ev = extra, *previous_ev = extra;
1118 char *current_val, custom[MAX_CUSTOM_LEN] = {0};
1121 #endif // IWEVGENIE //
1122 struct iw_event iwe;
1124 if (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
1127 * Still scanning, indicate the caller should try again.
1133 #ifdef WPA_SUPPLICANT_SUPPORT
1134 if (pAdapter->StaCfg.WpaSupplicantUP == WPA_SUPPLICANT_ENABLE)
1136 pAdapter->StaCfg.WpaSupplicantScanCount = 0;
1138 #endif // WPA_SUPPLICANT_SUPPORT //
1140 if (pAdapter->ScanTab.BssNr == 0)
1146 #if WIRELESS_EXT >= 17
1147 if (data->length > 0)
1148 end_buf = extra + data->length;
1150 end_buf = extra + IW_SCAN_MAX_DATA;
1152 end_buf = extra + IW_SCAN_MAX_DATA;
1155 for (i = 0; i < pAdapter->ScanTab.BssNr; i++)
1157 if (current_ev >= end_buf)
1159 #if WIRELESS_EXT >= 17
1167 //================================
1168 memset(&iwe, 0, sizeof(iwe));
1169 iwe.cmd = SIOCGIWAP;
1170 iwe.u.ap_addr.sa_family = ARPHRD_ETHER;
1171 memcpy(iwe.u.ap_addr.sa_data, &pAdapter->ScanTab.BssEntry[i].Bssid, ETH_ALEN);
1173 previous_ev = current_ev;
1174 current_ev = iwe_stream_add_event(info, current_ev,end_buf, &iwe, IW_EV_ADDR_LEN);
1175 if (current_ev == previous_ev)
1176 #if WIRELESS_EXT >= 17
1183 //================================
1184 memset(&iwe, 0, sizeof(iwe));
1185 iwe.cmd = SIOCGIWESSID;
1186 iwe.u.data.length = pAdapter->ScanTab.BssEntry[i].SsidLen;
1187 iwe.u.data.flags = 1;
1189 previous_ev = current_ev;
1190 current_ev = iwe_stream_add_point(info, current_ev,end_buf, &iwe, pAdapter->ScanTab.BssEntry[i].Ssid);
1191 if (current_ev == previous_ev)
1192 #if WIRELESS_EXT >= 17
1199 //================================
1200 memset(&iwe, 0, sizeof(iwe));
1201 iwe.cmd = SIOCGIWMODE;
1202 if (pAdapter->ScanTab.BssEntry[i].BssType == Ndis802_11IBSS)
1204 iwe.u.mode = IW_MODE_ADHOC;
1206 else if (pAdapter->ScanTab.BssEntry[i].BssType == Ndis802_11Infrastructure)
1208 iwe.u.mode = IW_MODE_INFRA;
1212 iwe.u.mode = IW_MODE_AUTO;
1214 iwe.len = IW_EV_UINT_LEN;
1216 previous_ev = current_ev;
1217 current_ev = iwe_stream_add_event(info, current_ev, end_buf, &iwe, IW_EV_UINT_LEN);
1218 if (current_ev == previous_ev)
1219 #if WIRELESS_EXT >= 17
1225 //Channel and Frequency
1226 //================================
1227 memset(&iwe, 0, sizeof(iwe));
1228 iwe.cmd = SIOCGIWFREQ;
1229 if (INFRA_ON(pAdapter) || ADHOC_ON(pAdapter))
1230 iwe.u.freq.m = pAdapter->ScanTab.BssEntry[i].Channel;
1232 iwe.u.freq.m = pAdapter->ScanTab.BssEntry[i].Channel;
1236 previous_ev = current_ev;
1237 current_ev = iwe_stream_add_event(info, current_ev, end_buf, &iwe, IW_EV_FREQ_LEN);
1238 if (current_ev == previous_ev)
1239 #if WIRELESS_EXT >= 17
1245 //Add quality statistics
1246 //================================
1247 memset(&iwe, 0, sizeof(iwe));
1249 iwe.u.qual.level = 0;
1250 iwe.u.qual.noise = 0;
1251 set_quality(pAdapter, &iwe.u.qual, pAdapter->ScanTab.BssEntry[i].Rssi);
1252 current_ev = iwe_stream_add_event(info, current_ev, end_buf, &iwe, IW_EV_QUAL_LEN);
1253 if (current_ev == previous_ev)
1254 #if WIRELESS_EXT >= 17
1261 //================================
1262 memset(&iwe, 0, sizeof(iwe));
1263 iwe.cmd = SIOCGIWENCODE;
1264 if (CAP_IS_PRIVACY_ON (pAdapter->ScanTab.BssEntry[i].CapabilityInfo ))
1265 iwe.u.data.flags =IW_ENCODE_ENABLED | IW_ENCODE_NOKEY;
1267 iwe.u.data.flags = IW_ENCODE_DISABLED;
1269 previous_ev = current_ev;
1270 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);
1271 if (current_ev == previous_ev)
1272 #if WIRELESS_EXT >= 17
1279 //================================
1280 if (pAdapter->ScanTab.BssEntry[i].SupRateLen)
1282 UCHAR tmpRate = pAdapter->ScanTab.BssEntry[i].SupRate[pAdapter->ScanTab.BssEntry[i].SupRateLen-1];
1283 memset(&iwe, 0, sizeof(iwe));
1284 iwe.cmd = SIOCGIWRATE;
1285 current_val = current_ev + IW_EV_LCP_LEN;
1286 if (tmpRate == 0x82)
1287 iwe.u.bitrate.value = 1 * 1000000;
1288 else if (tmpRate == 0x84)
1289 iwe.u.bitrate.value = 2 * 1000000;
1290 else if (tmpRate == 0x8B)
1291 iwe.u.bitrate.value = 5.5 * 1000000;
1292 else if (tmpRate == 0x96)
1293 iwe.u.bitrate.value = 11 * 1000000;
1295 iwe.u.bitrate.value = (tmpRate/2) * 1000000;
1297 iwe.u.bitrate.disabled = 0;
1298 current_val = iwe_stream_add_value(info, current_ev,
1299 current_val, end_buf, &iwe,
1302 if((current_val-current_ev)>IW_EV_LCP_LEN)
1303 current_ev = current_val;
1305 #if WIRELESS_EXT >= 17
1314 if (pAdapter->ScanTab.BssEntry[i].WpaIE.IELen > 0)
1316 memset(&iwe, 0, sizeof(iwe));
1317 memset(&custom[0], 0, MAX_CUSTOM_LEN);
1318 memcpy(custom, &(pAdapter->ScanTab.BssEntry[i].WpaIE.IE[0]),
1319 pAdapter->ScanTab.BssEntry[i].WpaIE.IELen);
1320 iwe.cmd = IWEVGENIE;
1321 iwe.u.data.length = pAdapter->ScanTab.BssEntry[i].WpaIE.IELen;
1322 current_ev = iwe_stream_add_point(info, current_ev, end_buf, &iwe, custom);
1323 if (current_ev == previous_ev)
1324 #if WIRELESS_EXT >= 17
1332 if (pAdapter->ScanTab.BssEntry[i].RsnIE.IELen > 0)
1334 memset(&iwe, 0, sizeof(iwe));
1335 memset(&custom[0], 0, MAX_CUSTOM_LEN);
1336 memcpy(custom, &(pAdapter->ScanTab.BssEntry[i].RsnIE.IE[0]),
1337 pAdapter->ScanTab.BssEntry[i].RsnIE.IELen);
1338 iwe.cmd = IWEVGENIE;
1339 iwe.u.data.length = pAdapter->ScanTab.BssEntry[i].RsnIE.IELen;
1340 current_ev = iwe_stream_add_point(info, current_ev, end_buf, &iwe, custom);
1341 if (current_ev == previous_ev)
1342 #if WIRELESS_EXT >= 17
1350 //================================
1351 if (pAdapter->ScanTab.BssEntry[i].WpaIE.IELen > 0)
1353 NdisZeroMemory(&iwe, sizeof(iwe));
1354 memset(&custom[0], 0, MAX_CUSTOM_LEN);
1355 iwe.cmd = IWEVCUSTOM;
1356 iwe.u.data.length = (pAdapter->ScanTab.BssEntry[i].WpaIE.IELen * 2) + 7;
1357 NdisMoveMemory(custom, "wpa_ie=", 7);
1358 for (idx = 0; idx < pAdapter->ScanTab.BssEntry[i].WpaIE.IELen; idx++)
1359 sprintf(custom + strlen(custom), "%02x", pAdapter->ScanTab.BssEntry[i].WpaIE.IE[idx]);
1360 previous_ev = current_ev;
1361 current_ev = iwe_stream_add_point(current_ev, end_buf, &iwe, custom);
1362 if (current_ev == previous_ev)
1363 #if WIRELESS_EXT >= 17
1371 if (pAdapter->ScanTab.BssEntry[i].RsnIE.IELen > 0)
1373 NdisZeroMemory(&iwe, sizeof(iwe));
1374 memset(&custom[0], 0, MAX_CUSTOM_LEN);
1375 iwe.cmd = IWEVCUSTOM;
1376 iwe.u.data.length = (pAdapter->ScanTab.BssEntry[i].RsnIE.IELen * 2) + 7;
1377 NdisMoveMemory(custom, "rsn_ie=", 7);
1378 for (idx = 0; idx < pAdapter->ScanTab.BssEntry[i].RsnIE.IELen; idx++)
1379 sprintf(custom + strlen(custom), "%02x", pAdapter->ScanTab.BssEntry[i].RsnIE.IE[idx]);
1380 previous_ev = current_ev;
1381 current_ev = iwe_stream_add_point(current_ev, end_buf, &iwe, custom);
1382 if (current_ev == previous_ev)
1383 #if WIRELESS_EXT >= 17
1389 #endif // IWEVGENIE //
1392 data->length = current_ev - extra;
1393 pAdapter->StaCfg.bScanReqIsFromWebUI = FALSE;
1394 DBGPRINT(RT_DEBUG_ERROR ,("===>rt_ioctl_giwscan. %d(%d) BSS returned, data->length = %d\n",i , pAdapter->ScanTab.BssNr, data->length));
1399 int rt_ioctl_siwessid(struct net_device *dev,
1400 struct iw_request_info *info,
1401 struct iw_point *data, char *essid)
1403 PRTMP_ADAPTER pAdapter = dev->ml_priv;
1405 //check if the interface is down
1406 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1408 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1414 PCHAR pSsidString = NULL;
1416 // Includes null character.
1417 if (data->length > (IW_ESSID_MAX_SIZE + 1))
1420 pSsidString = (CHAR *) kmalloc(MAX_LEN_OF_SSID+1, MEM_ALLOC_FLAG);
1423 NdisZeroMemory(pSsidString, MAX_LEN_OF_SSID+1);
1424 NdisMoveMemory(pSsidString, essid, data->length);
1425 if (Set_SSID_Proc(pAdapter, pSsidString) == FALSE)
1434 if (Set_SSID_Proc(pAdapter, "") == FALSE)
1440 int rt_ioctl_giwessid(struct net_device *dev,
1441 struct iw_request_info *info,
1442 struct iw_point *data, char *essid)
1444 PRTMP_ADAPTER pAdapter = NULL;
1445 VIRTUAL_ADAPTER *pVirtualAd = NULL;
1447 if (dev->priv_flags == INT_MAIN)
1449 pAdapter = dev->ml_priv;
1453 pVirtualAd = dev->ml_priv;
1454 if (pVirtualAd && pVirtualAd->RtmpDev)
1455 pAdapter = pVirtualAd->RtmpDev->ml_priv;
1458 if (pAdapter == NULL)
1460 /* if 1st open fail, pAd will be free;
1461 So the net_dev->ml_priv will be NULL in 2rd open */
1466 if (MONITOR_ON(pAdapter))
1472 if (OPSTATUS_TEST_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED))
1474 DBGPRINT(RT_DEBUG_TRACE ,("MediaState is connected\n"));
1475 data->length = pAdapter->CommonCfg.SsidLen;
1476 memcpy(essid, pAdapter->CommonCfg.Ssid, pAdapter->CommonCfg.SsidLen);
1479 {//the ANY ssid was specified
1481 DBGPRINT(RT_DEBUG_TRACE ,("MediaState is not connected, ess\n"));
1488 int rt_ioctl_siwnickn(struct net_device *dev,
1489 struct iw_request_info *info,
1490 struct iw_point *data, char *nickname)
1492 PRTMP_ADAPTER pAdapter = dev->ml_priv;
1494 //check if the interface is down
1495 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1497 DBGPRINT(RT_DEBUG_TRACE ,("INFO::Network is down!\n"));
1501 if (data->length > IW_ESSID_MAX_SIZE)
1504 memset(pAdapter->nickname, 0, IW_ESSID_MAX_SIZE + 1);
1505 memcpy(pAdapter->nickname, nickname, data->length);
1511 int rt_ioctl_giwnickn(struct net_device *dev,
1512 struct iw_request_info *info,
1513 struct iw_point *data, char *nickname)
1515 PRTMP_ADAPTER pAdapter = NULL;
1516 VIRTUAL_ADAPTER *pVirtualAd = NULL;
1518 if (dev->priv_flags == INT_MAIN)
1520 pAdapter = dev->ml_priv;
1524 pVirtualAd = dev->ml_priv;
1525 if (pVirtualAd && pVirtualAd->RtmpDev)
1526 pAdapter = pVirtualAd->RtmpDev->ml_priv;
1529 if (pAdapter == NULL)
1531 /* if 1st open fail, pAd will be free;
1532 So the net_dev->ml_priv will be NULL in 2rd open */
1536 if (data->length > strlen(pAdapter->nickname) + 1)
1537 data->length = strlen(pAdapter->nickname) + 1;
1538 if (data->length > 0) {
1539 memcpy(nickname, pAdapter->nickname, data->length-1);
1540 nickname[data->length-1] = '\0';
1545 int rt_ioctl_siwrts(struct net_device *dev,
1546 struct iw_request_info *info,
1547 struct iw_param *rts, char *extra)
1549 PRTMP_ADAPTER pAdapter = dev->ml_priv;
1552 //check if the interface is down
1553 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1555 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1560 val = MAX_RTS_THRESHOLD;
1561 else if (rts->value < 0 || rts->value > MAX_RTS_THRESHOLD)
1563 else if (rts->value == 0)
1564 val = MAX_RTS_THRESHOLD;
1568 if (val != pAdapter->CommonCfg.RtsThreshold)
1569 pAdapter->CommonCfg.RtsThreshold = val;
1574 int rt_ioctl_giwrts(struct net_device *dev,
1575 struct iw_request_info *info,
1576 struct iw_param *rts, char *extra)
1578 PRTMP_ADAPTER pAdapter = NULL;
1579 VIRTUAL_ADAPTER *pVirtualAd = NULL;
1581 if (dev->priv_flags == INT_MAIN)
1583 pAdapter = dev->ml_priv;
1587 pVirtualAd = dev->ml_priv;
1588 if (pVirtualAd && pVirtualAd->RtmpDev)
1589 pAdapter = pVirtualAd->RtmpDev->ml_priv;
1592 if (pAdapter == NULL)
1594 /* if 1st open fail, pAd will be free;
1595 So the net_dev->ml_priv will be NULL in 2rd open */
1599 //check if the interface is down
1600 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1602 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1606 rts->value = pAdapter->CommonCfg.RtsThreshold;
1607 rts->disabled = (rts->value == MAX_RTS_THRESHOLD);
1613 int rt_ioctl_siwfrag(struct net_device *dev,
1614 struct iw_request_info *info,
1615 struct iw_param *frag, char *extra)
1617 PRTMP_ADAPTER pAdapter = dev->ml_priv;
1620 //check if the interface is down
1621 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1623 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1628 val = MAX_FRAG_THRESHOLD;
1629 else if (frag->value >= MIN_FRAG_THRESHOLD || frag->value <= MAX_FRAG_THRESHOLD)
1630 val = __cpu_to_le16(frag->value & ~0x1); /* even numbers only */
1631 else if (frag->value == 0)
1632 val = MAX_FRAG_THRESHOLD;
1636 pAdapter->CommonCfg.FragmentThreshold = val;
1640 int rt_ioctl_giwfrag(struct net_device *dev,
1641 struct iw_request_info *info,
1642 struct iw_param *frag, char *extra)
1644 PRTMP_ADAPTER pAdapter = NULL;
1645 VIRTUAL_ADAPTER *pVirtualAd = NULL;
1647 if (dev->priv_flags == INT_MAIN)
1649 pAdapter = dev->ml_priv;
1653 pVirtualAd = dev->ml_priv;
1654 if (pVirtualAd && pVirtualAd->RtmpDev)
1655 pAdapter = pVirtualAd->RtmpDev->ml_priv;
1658 if (pAdapter == NULL)
1660 /* if 1st open fail, pAd will be free;
1661 So the net_dev->ml_priv will be NULL in 2rd open */
1665 //check if the interface is down
1666 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1668 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1672 frag->value = pAdapter->CommonCfg.FragmentThreshold;
1673 frag->disabled = (frag->value == MAX_FRAG_THRESHOLD);
1679 #define MAX_WEP_KEY_SIZE 13
1680 #define MIN_WEP_KEY_SIZE 5
1681 int rt_ioctl_siwencode(struct net_device *dev,
1682 struct iw_request_info *info,
1683 struct iw_point *erq, char *extra)
1685 PRTMP_ADAPTER pAdapter = dev->ml_priv;
1687 //check if the interface is down
1688 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1690 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1694 if ((erq->length == 0) &&
1695 (erq->flags & IW_ENCODE_DISABLED))
1697 pAdapter->StaCfg.PairCipher = Ndis802_11WEPDisabled;
1698 pAdapter->StaCfg.GroupCipher = Ndis802_11WEPDisabled;
1699 pAdapter->StaCfg.WepStatus = Ndis802_11WEPDisabled;
1700 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
1701 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
1704 else if ((erq->length == 0) &&
1705 (erq->flags & IW_ENCODE_RESTRICTED || erq->flags & IW_ENCODE_OPEN))
1707 STA_PORT_SECURED(pAdapter);
1708 pAdapter->StaCfg.PairCipher = Ndis802_11WEPEnabled;
1709 pAdapter->StaCfg.GroupCipher = Ndis802_11WEPEnabled;
1710 pAdapter->StaCfg.WepStatus = Ndis802_11WEPEnabled;
1711 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
1712 if (erq->flags & IW_ENCODE_RESTRICTED)
1713 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeShared;
1715 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
1719 if (erq->length > 0)
1721 int keyIdx = (erq->flags & IW_ENCODE_INDEX) - 1;
1722 /* Check the size of the key */
1723 if (erq->length > MAX_WEP_KEY_SIZE) {
1726 /* Check key index */
1727 if ((keyIdx < 0) || (keyIdx >= NR_WEP_KEYS))
1729 DBGPRINT(RT_DEBUG_TRACE ,("==>rt_ioctl_siwencode::Wrong keyIdx=%d! Using default key instead (%d)\n",
1730 keyIdx, pAdapter->StaCfg.DefaultKeyId));
1733 keyIdx = pAdapter->StaCfg.DefaultKeyId;
1736 NdisZeroMemory(pAdapter->SharedKey[BSS0][keyIdx].Key, 16);
1738 if (erq->length == MAX_WEP_KEY_SIZE)
1740 pAdapter->SharedKey[BSS0][keyIdx].KeyLen = MAX_WEP_KEY_SIZE;
1741 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CIPHER_WEP128;
1743 else if (erq->length == MIN_WEP_KEY_SIZE)
1745 pAdapter->SharedKey[BSS0][keyIdx].KeyLen = MIN_WEP_KEY_SIZE;
1746 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CIPHER_WEP64;
1749 /* Disable the key */
1750 pAdapter->SharedKey[BSS0][keyIdx].KeyLen = 0;
1752 /* Check if the key is not marked as invalid */
1753 if(!(erq->flags & IW_ENCODE_NOKEY)) {
1754 /* Copy the key in the driver */
1755 NdisMoveMemory(pAdapter->SharedKey[BSS0][keyIdx].Key, extra, erq->length);
1760 /* Do we want to just set the transmit key index ? */
1761 int index = (erq->flags & IW_ENCODE_INDEX) - 1;
1762 if ((index >= 0) && (index < 4))
1764 pAdapter->StaCfg.DefaultKeyId = index;
1767 /* Don't complain if only change the mode */
1768 if (!(erq->flags & IW_ENCODE_MODE)) {
1774 DBGPRINT(RT_DEBUG_TRACE ,("==>rt_ioctl_siwencode::erq->flags=%x\n",erq->flags));
1775 DBGPRINT(RT_DEBUG_TRACE ,("==>rt_ioctl_siwencode::AuthMode=%x\n",pAdapter->StaCfg.AuthMode));
1776 DBGPRINT(RT_DEBUG_TRACE ,("==>rt_ioctl_siwencode::DefaultKeyId=%x, KeyLen = %d\n",pAdapter->StaCfg.DefaultKeyId , pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].KeyLen));
1777 DBGPRINT(RT_DEBUG_TRACE ,("==>rt_ioctl_siwencode::WepStatus=%x\n",pAdapter->StaCfg.WepStatus));
1782 rt_ioctl_giwencode(struct net_device *dev,
1783 struct iw_request_info *info,
1784 struct iw_point *erq, char *key)
1787 PRTMP_ADAPTER pAdapter = NULL;
1788 VIRTUAL_ADAPTER *pVirtualAd = NULL;
1790 if (dev->priv_flags == INT_MAIN)
1792 pAdapter = dev->ml_priv;
1796 pVirtualAd = dev->ml_priv;
1797 if (pVirtualAd && pVirtualAd->RtmpDev)
1798 pAdapter = pVirtualAd->RtmpDev->ml_priv;
1801 if (pAdapter == NULL)
1803 /* if 1st open fail, pAd will be free;
1804 So the net_dev->ml_priv will be NULL in 2rd open */
1808 //check if the interface is down
1809 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1811 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1815 kid = erq->flags & IW_ENCODE_INDEX;
1816 DBGPRINT(RT_DEBUG_TRACE, ("===>rt_ioctl_giwencode %d\n", erq->flags & IW_ENCODE_INDEX));
1818 if (pAdapter->StaCfg.WepStatus == Ndis802_11WEPDisabled)
1821 erq->flags = IW_ENCODE_DISABLED;
1823 else if ((kid > 0) && (kid <=4))
1826 erq->flags = kid ; /* NB: base 1 */
1827 if (erq->length > pAdapter->SharedKey[BSS0][kid-1].KeyLen)
1828 erq->length = pAdapter->SharedKey[BSS0][kid-1].KeyLen;
1829 memcpy(key, pAdapter->SharedKey[BSS0][kid-1].Key, erq->length);
1830 //if ((kid == pAdapter->PortCfg.DefaultKeyId))
1831 //erq->flags |= IW_ENCODE_ENABLED; /* XXX */
1832 if (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeShared)
1833 erq->flags |= IW_ENCODE_RESTRICTED; /* XXX */
1835 erq->flags |= IW_ENCODE_OPEN; /* XXX */
1840 if (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeShared)
1841 erq->flags |= IW_ENCODE_RESTRICTED; /* XXX */
1843 erq->flags |= IW_ENCODE_OPEN; /* XXX */
1844 erq->length = pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].KeyLen;
1845 memcpy(key, pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].Key, erq->length);
1846 // copy default key ID
1847 if (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeShared)
1848 erq->flags |= IW_ENCODE_RESTRICTED; /* XXX */
1850 erq->flags |= IW_ENCODE_OPEN; /* XXX */
1851 erq->flags = pAdapter->StaCfg.DefaultKeyId + 1; /* NB: base 1 */
1852 erq->flags |= IW_ENCODE_ENABLED; /* XXX */
1860 rt_ioctl_setparam(struct net_device *dev, struct iw_request_info *info,
1861 void *w, char *extra)
1863 VIRTUAL_ADAPTER *pVirtualAd = NULL;
1864 PRTMP_ADAPTER pAdapter;
1866 char *this_char = extra;
1870 if (dev->priv_flags == INT_MAIN)
1872 pAdapter = dev->ml_priv;
1876 pVirtualAd = dev->ml_priv;
1877 pAdapter = pVirtualAd->RtmpDev->ml_priv;
1879 pObj = (POS_COOKIE) pAdapter->OS_Cookie;
1881 if (pAdapter == NULL)
1883 /* if 1st open fail, pAd will be free;
1884 So the net_dev->ml_priv will be NULL in 2rd open */
1889 pObj->ioctl_if_type = INT_MAIN;
1890 pObj->ioctl_if = MAIN_MBSSID;
1893 //check if the interface is down
1894 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1896 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1903 if ((value = rtstrchr(this_char, '=')) != NULL)
1909 // reject setting nothing besides ANY ssid(ssidLen=0)
1910 if (!*value && (strcmp(this_char, "SSID") != 0))
1913 for (PRTMP_PRIVATE_SET_PROC = RTMP_PRIVATE_SUPPORT_PROC; PRTMP_PRIVATE_SET_PROC->name; PRTMP_PRIVATE_SET_PROC++)
1915 if (strcmp(this_char, PRTMP_PRIVATE_SET_PROC->name) == 0)
1917 if(!PRTMP_PRIVATE_SET_PROC->set_proc(pAdapter, value))
1918 { //FALSE:Set private failed then return Invalid argument
1921 break; //Exit for loop.
1925 if(PRTMP_PRIVATE_SET_PROC->name == NULL)
1926 { //Not found argument
1928 DBGPRINT(RT_DEBUG_TRACE, ("===>rt_ioctl_setparam:: (iwpriv) Not Support Set Command [%s=%s]\n", this_char, value));
1936 rt_private_get_statistics(struct net_device *dev, struct iw_request_info *info,
1937 struct iw_point *wrq, char *extra)
1940 PRTMP_ADAPTER pAd = dev->ml_priv;
1948 memset(extra, 0x00, IW_PRIV_SIZE_MASK);
1949 sprintf(extra, "\n\n");
1954 sprintf(extra+strlen(extra), "Tx success = %ld\n", (ULONG)pAd->ate.TxDoneCount);
1955 //sprintf(extra+strlen(extra), "Tx success without retry = %ld\n", (ULONG)pAd->ate.TxDoneCount);
1958 #endif // RALINK_ATE //
1960 sprintf(extra+strlen(extra), "Tx success = %ld\n", (ULONG)pAd->WlanCounters.TransmittedFragmentCount.QuadPart);
1961 sprintf(extra+strlen(extra), "Tx success without retry = %ld\n", (ULONG)pAd->WlanCounters.TransmittedFragmentCount.QuadPart - (ULONG)pAd->WlanCounters.RetryCount.QuadPart);
1963 sprintf(extra+strlen(extra), "Tx success after retry = %ld\n", (ULONG)pAd->WlanCounters.RetryCount.QuadPart);
1964 sprintf(extra+strlen(extra), "Tx fail to Rcv ACK after retry = %ld\n", (ULONG)pAd->WlanCounters.FailedCount.QuadPart);
1965 sprintf(extra+strlen(extra), "RTS Success Rcv CTS = %ld\n", (ULONG)pAd->WlanCounters.RTSSuccessCount.QuadPart);
1966 sprintf(extra+strlen(extra), "RTS Fail Rcv CTS = %ld\n", (ULONG)pAd->WlanCounters.RTSFailureCount.QuadPart);
1968 sprintf(extra+strlen(extra), "Rx success = %ld\n", (ULONG)pAd->WlanCounters.ReceivedFragmentCount.QuadPart);
1969 sprintf(extra+strlen(extra), "Rx with CRC = %ld\n", (ULONG)pAd->WlanCounters.FCSErrorCount.QuadPart);
1970 sprintf(extra+strlen(extra), "Rx drop due to out of resource = %ld\n", (ULONG)pAd->Counters8023.RxNoBuffer);
1971 sprintf(extra+strlen(extra), "Rx duplicate frame = %ld\n", (ULONG)pAd->WlanCounters.FrameDuplicateCount.QuadPart);
1973 sprintf(extra+strlen(extra), "False CCA (one second) = %ld\n", (ULONG)pAd->RalinkCounters.OneSecFalseCCACnt);
1977 if (pAd->ate.RxAntennaSel == 0)
1979 sprintf(extra+strlen(extra), "RSSI-A = %ld\n", (LONG)(pAd->ate.LastRssi0 - pAd->BbpRssiToDbmDelta));
1980 sprintf(extra+strlen(extra), "RSSI-B (if available) = %ld\n", (LONG)(pAd->ate.LastRssi1 - pAd->BbpRssiToDbmDelta));
1981 sprintf(extra+strlen(extra), "RSSI-C (if available) = %ld\n\n", (LONG)(pAd->ate.LastRssi2 - pAd->BbpRssiToDbmDelta));
1985 sprintf(extra+strlen(extra), "RSSI = %ld\n", (LONG)(pAd->ate.LastRssi0 - pAd->BbpRssiToDbmDelta));
1989 #endif // RALINK_ATE //
1991 sprintf(extra+strlen(extra), "RSSI-A = %ld\n", (LONG)(pAd->StaCfg.RssiSample.LastRssi0 - pAd->BbpRssiToDbmDelta));
1992 sprintf(extra+strlen(extra), "RSSI-B (if available) = %ld\n", (LONG)(pAd->StaCfg.RssiSample.LastRssi1 - pAd->BbpRssiToDbmDelta));
1993 sprintf(extra+strlen(extra), "RSSI-C (if available) = %ld\n\n", (LONG)(pAd->StaCfg.RssiSample.LastRssi2 - pAd->BbpRssiToDbmDelta));
1995 #ifdef WPA_SUPPLICANT_SUPPORT
1996 sprintf(extra+strlen(extra), "WpaSupplicantUP = %d\n\n", pAd->StaCfg.WpaSupplicantUP);
1997 #endif // WPA_SUPPLICANT_SUPPORT //
2000 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2001 DBGPRINT(RT_DEBUG_TRACE, ("<== rt_private_get_statistics, wrq->length = %d\n", wrq->length));
2006 #ifdef DOT11_N_SUPPORT
2008 IN PRTMP_ADAPTER pAd,
2012 BA_ORI_ENTRY *pOriBAEntry;
2013 BA_REC_ENTRY *pRecBAEntry;
2015 for (i=0; i<MAX_LEN_OF_MAC_TABLE; i++)
2017 PMAC_TABLE_ENTRY pEntry = &pAd->MacTab.Content[i];
2018 if (((pEntry->ValidAsCLI || pEntry->ValidAsApCli) && (pEntry->Sst == SST_ASSOC))
2019 || (pEntry->ValidAsWDS) || (pEntry->ValidAsMesh))
2021 sprintf(pOutBuf + strlen(pOutBuf), "\n%02X:%02X:%02X:%02X:%02X:%02X (Aid = %d) (AP) -\n",
2022 pEntry->Addr[0], pEntry->Addr[1], pEntry->Addr[2],
2023 pEntry->Addr[3], pEntry->Addr[4], pEntry->Addr[5], pEntry->Aid);
2025 sprintf(pOutBuf, "%s[Recipient]\n", pOutBuf);
2026 for (j=0; j < NUM_OF_TID; j++)
2028 if (pEntry->BARecWcidArray[j] != 0)
2030 pRecBAEntry =&pAd->BATable.BARecEntry[pEntry->BARecWcidArray[j]];
2031 sprintf(pOutBuf + strlen(pOutBuf), "TID=%d, BAWinSize=%d, LastIndSeq=%d, ReorderingPkts=%d\n", j, pRecBAEntry->BAWinSize, pRecBAEntry->LastIndSeq, pRecBAEntry->list.qlen);
2034 sprintf(pOutBuf, "%s\n", pOutBuf);
2036 sprintf(pOutBuf, "%s[Originator]\n", pOutBuf);
2037 for (j=0; j < NUM_OF_TID; j++)
2039 if (pEntry->BAOriWcidArray[j] != 0)
2041 pOriBAEntry =&pAd->BATable.BAOriEntry[pEntry->BAOriWcidArray[j]];
2042 sprintf(pOutBuf + strlen(pOutBuf), "TID=%d, BAWinSize=%d, StartSeq=%d, CurTxSeq=%d\n", j, pOriBAEntry->BAWinSize, pOriBAEntry->Sequence, pEntry->TxSeq[j]);
2045 sprintf(pOutBuf, "%s\n\n", pOutBuf);
2047 if (strlen(pOutBuf) > (IW_PRIV_SIZE_MASK - 30))
2053 #endif // DOT11_N_SUPPORT //
2056 rt_private_show(struct net_device *dev, struct iw_request_info *info,
2057 struct iw_point *wrq, char *extra)
2060 VIRTUAL_ADAPTER *pVirtualAd = NULL;
2063 u32 subcmd = wrq->flags;
2065 if (dev->priv_flags == INT_MAIN)
2069 pVirtualAd = dev->ml_priv;
2070 pAd = pVirtualAd->RtmpDev->ml_priv;
2072 pObj = (POS_COOKIE) pAd->OS_Cookie;
2076 /* if 1st open fail, pAd will be free;
2077 So the net_dev->ml_priv will be NULL in 2rd open */
2086 memset(extra, 0x00, IW_PRIV_SIZE_MASK);
2089 pObj->ioctl_if_type = INT_MAIN;
2090 pObj->ioctl_if = MAIN_MBSSID;
2096 case SHOW_CONN_STATUS:
2097 if (MONITOR_ON(pAd))
2099 #ifdef DOT11_N_SUPPORT
2100 if (pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED &&
2101 pAd->CommonCfg.RegTransmitSetting.field.BW)
2102 sprintf(extra, "Monitor Mode(CentralChannel %d)\n", pAd->CommonCfg.CentralChannel);
2104 #endif // DOT11_N_SUPPORT //
2105 sprintf(extra, "Monitor Mode(Channel %d)\n", pAd->CommonCfg.Channel);
2109 if (pAd->IndicateMediaState == NdisMediaStateConnected)
2113 sprintf(extra, "Connected(AP: %s[%02X:%02X:%02X:%02X:%02X:%02X])\n",
2114 pAd->CommonCfg.Ssid,
2115 pAd->CommonCfg.Bssid[0],
2116 pAd->CommonCfg.Bssid[1],
2117 pAd->CommonCfg.Bssid[2],
2118 pAd->CommonCfg.Bssid[3],
2119 pAd->CommonCfg.Bssid[4],
2120 pAd->CommonCfg.Bssid[5]);
2121 DBGPRINT(RT_DEBUG_TRACE ,("Ssid=%s ,Ssidlen = %d\n",pAd->CommonCfg.Ssid, pAd->CommonCfg.SsidLen));
2123 else if (ADHOC_ON(pAd))
2124 sprintf(extra, "Connected\n");
2128 sprintf(extra, "Disconnected\n");
2129 DBGPRINT(RT_DEBUG_TRACE ,("ConnStatus is not connected\n"));
2132 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2134 case SHOW_DRVIER_VERION:
2135 sprintf(extra, "Driver version-%s, %s %s\n", STA_DRIVER_VERSION, __DATE__, __TIME__ );
2136 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2138 #ifdef DOT11_N_SUPPORT
2140 getBaInfo(pAd, extra);
2141 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2143 #endif // DOT11_N_SUPPORT //
2144 case SHOW_DESC_INFO:
2146 Show_DescInfo_Proc(pAd, NULL);
2147 wrq->length = 0; // 1: size of '\0'
2151 if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
2153 sprintf(extra, "Scanning\n");
2154 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2157 pAd->StaCfg.bSwRadio = FALSE;
2158 if (pAd->StaCfg.bRadio != (pAd->StaCfg.bHwRadio && pAd->StaCfg.bSwRadio))
2160 pAd->StaCfg.bRadio = (pAd->StaCfg.bHwRadio && pAd->StaCfg.bSwRadio);
2161 if (pAd->StaCfg.bRadio == FALSE)
2164 // Update extra information
2165 pAd->ExtraInfo = SW_RADIO_OFF;
2168 sprintf(extra, "Radio Off\n");
2169 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2172 pAd->StaCfg.bSwRadio = TRUE;
2173 //if (pAd->StaCfg.bRadio != (pAd->StaCfg.bHwRadio && pAd->StaCfg.bSwRadio))
2175 pAd->StaCfg.bRadio = (pAd->StaCfg.bHwRadio && pAd->StaCfg.bSwRadio);
2176 if (pAd->StaCfg.bRadio == TRUE)
2179 // Update extra information
2180 pAd->ExtraInfo = EXTRA_INFO_CLEAR;
2183 sprintf(extra, "Radio On\n");
2184 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2188 #ifdef QOS_DLS_SUPPORT
2189 case SHOW_DLS_ENTRY_INFO:
2191 Set_DlsEntryInfo_Display_Proc(pAd, NULL);
2192 wrq->length = 0; // 1: size of '\0'
2195 #endif // QOS_DLS_SUPPORT //
2197 case SHOW_CFG_VALUE:
2199 Status = RTMPShowCfgValue(pAd, wrq->pointer, extra);
2201 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2205 DBGPRINT(RT_DEBUG_TRACE, ("%s - unknow subcmd = %d\n", __func__, subcmd));
2213 int rt_ioctl_siwmlme(struct net_device *dev,
2214 struct iw_request_info *info,
2215 union iwreq_data *wrqu,
2218 PRTMP_ADAPTER pAd = dev->ml_priv;
2219 struct iw_mlme *pMlme = (struct iw_mlme *)wrqu->data.pointer;
2220 MLME_QUEUE_ELEM MsgElem;
2221 MLME_DISASSOC_REQ_STRUCT DisAssocReq;
2222 MLME_DEAUTH_REQ_STRUCT DeAuthReq;
2224 DBGPRINT(RT_DEBUG_TRACE, ("====> %s\n", __func__));
2231 #ifdef IW_MLME_DEAUTH
2232 case IW_MLME_DEAUTH:
2233 DBGPRINT(RT_DEBUG_TRACE, ("====> %s - IW_MLME_DEAUTH\n", __func__));
2234 COPY_MAC_ADDR(DeAuthReq.Addr, pAd->CommonCfg.Bssid);
2235 DeAuthReq.Reason = pMlme->reason_code;
2236 MsgElem.MsgLen = sizeof(MLME_DEAUTH_REQ_STRUCT);
2237 NdisMoveMemory(MsgElem.Msg, &DeAuthReq, sizeof(MLME_DEAUTH_REQ_STRUCT));
2238 MlmeDeauthReqAction(pAd, &MsgElem);
2241 LinkDown(pAd, FALSE);
2242 pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
2245 #endif // IW_MLME_DEAUTH //
2246 #ifdef IW_MLME_DISASSOC
2247 case IW_MLME_DISASSOC:
2248 DBGPRINT(RT_DEBUG_TRACE, ("====> %s - IW_MLME_DISASSOC\n", __func__));
2249 COPY_MAC_ADDR(DisAssocReq.Addr, pAd->CommonCfg.Bssid);
2250 DisAssocReq.Reason = pMlme->reason_code;
2252 MsgElem.Machine = ASSOC_STATE_MACHINE;
2253 MsgElem.MsgType = MT2_MLME_DISASSOC_REQ;
2254 MsgElem.MsgLen = sizeof(MLME_DISASSOC_REQ_STRUCT);
2255 NdisMoveMemory(MsgElem.Msg, &DisAssocReq, sizeof(MLME_DISASSOC_REQ_STRUCT));
2257 pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_OID_DISASSOC;
2258 MlmeDisassocReqAction(pAd, &MsgElem);
2260 #endif // IW_MLME_DISASSOC //
2262 DBGPRINT(RT_DEBUG_TRACE, ("====> %s - Unknow Command\n", __func__));
2268 #endif // SIOCSIWMLME //
2270 #if WIRELESS_EXT > 17
2271 int rt_ioctl_siwauth(struct net_device *dev,
2272 struct iw_request_info *info,
2273 union iwreq_data *wrqu, char *extra)
2275 PRTMP_ADAPTER pAdapter = dev->ml_priv;
2276 struct iw_param *param = &wrqu->param;
2278 //check if the interface is down
2279 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
2281 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
2284 switch (param->flags & IW_AUTH_INDEX) {
2285 case IW_AUTH_WPA_VERSION:
2286 if (param->value == IW_AUTH_WPA_VERSION_WPA)
2288 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPAPSK;
2289 if (pAdapter->StaCfg.BssType == BSS_ADHOC)
2290 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPANone;
2292 else if (param->value == IW_AUTH_WPA_VERSION_WPA2)
2293 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA2PSK;
2295 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_WPA_VERSION - param->value = %d!\n", __func__, param->value));
2297 case IW_AUTH_CIPHER_PAIRWISE:
2298 if (param->value == IW_AUTH_CIPHER_NONE)
2300 pAdapter->StaCfg.WepStatus = Ndis802_11WEPDisabled;
2301 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
2302 pAdapter->StaCfg.PairCipher = Ndis802_11WEPDisabled;
2304 else if (param->value == IW_AUTH_CIPHER_WEP40 ||
2305 param->value == IW_AUTH_CIPHER_WEP104)
2307 pAdapter->StaCfg.WepStatus = Ndis802_11WEPEnabled;
2308 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
2309 pAdapter->StaCfg.PairCipher = Ndis802_11WEPEnabled;
2310 #ifdef WPA_SUPPLICANT_SUPPORT
2311 pAdapter->StaCfg.IEEE8021X = FALSE;
2312 #endif // WPA_SUPPLICANT_SUPPORT //
2314 else if (param->value == IW_AUTH_CIPHER_TKIP)
2316 pAdapter->StaCfg.WepStatus = Ndis802_11Encryption2Enabled;
2317 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
2318 pAdapter->StaCfg.PairCipher = Ndis802_11Encryption2Enabled;
2320 else if (param->value == IW_AUTH_CIPHER_CCMP)
2322 pAdapter->StaCfg.WepStatus = Ndis802_11Encryption3Enabled;
2323 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
2324 pAdapter->StaCfg.PairCipher = Ndis802_11Encryption3Enabled;
2326 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_CIPHER_PAIRWISE - param->value = %d!\n", __func__, param->value));
2328 case IW_AUTH_CIPHER_GROUP:
2329 if (param->value == IW_AUTH_CIPHER_NONE)
2331 pAdapter->StaCfg.GroupCipher = Ndis802_11WEPDisabled;
2333 else if (param->value == IW_AUTH_CIPHER_WEP40 ||
2334 param->value == IW_AUTH_CIPHER_WEP104)
2336 pAdapter->StaCfg.GroupCipher = Ndis802_11WEPEnabled;
2338 else if (param->value == IW_AUTH_CIPHER_TKIP)
2340 pAdapter->StaCfg.GroupCipher = Ndis802_11Encryption2Enabled;
2342 else if (param->value == IW_AUTH_CIPHER_CCMP)
2344 pAdapter->StaCfg.GroupCipher = Ndis802_11Encryption3Enabled;
2346 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_CIPHER_GROUP - param->value = %d!\n", __func__, param->value));
2348 case IW_AUTH_KEY_MGMT:
2349 if (param->value == IW_AUTH_KEY_MGMT_802_1X)
2351 if (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK)
2353 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA;
2354 #ifdef WPA_SUPPLICANT_SUPPORT
2355 pAdapter->StaCfg.IEEE8021X = FALSE;
2356 #endif // WPA_SUPPLICANT_SUPPORT //
2358 else if (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK)
2360 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA2;
2361 #ifdef WPA_SUPPLICANT_SUPPORT
2362 pAdapter->StaCfg.IEEE8021X = FALSE;
2363 #endif // WPA_SUPPLICANT_SUPPORT //
2365 #ifdef WPA_SUPPLICANT_SUPPORT
2368 pAdapter->StaCfg.IEEE8021X = TRUE;
2369 #endif // WPA_SUPPLICANT_SUPPORT //
2371 else if (param->value == 0)
2373 STA_PORT_SECURED(pAdapter);
2375 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_KEY_MGMT - param->value = %d!\n", __func__, param->value));
2377 case IW_AUTH_RX_UNENCRYPTED_EAPOL:
2379 case IW_AUTH_PRIVACY_INVOKED:
2380 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_PRIVACY_INVOKED - param->value = %d!\n", __func__, param->value));
2382 case IW_AUTH_DROP_UNENCRYPTED:
2383 if (param->value != 0)
2384 pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED;
2387 STA_PORT_SECURED(pAdapter);
2389 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_WPA_VERSION - param->value = %d!\n", __func__, param->value));
2391 case IW_AUTH_80211_AUTH_ALG:
2392 if (param->value & IW_AUTH_ALG_SHARED_KEY)
2394 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeShared;
2396 else if (param->value & IW_AUTH_ALG_OPEN_SYSTEM)
2398 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
2402 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_80211_AUTH_ALG - param->value = %d!\n", __func__, param->value));
2404 case IW_AUTH_WPA_ENABLED:
2405 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_WPA_ENABLED - Driver supports WPA!(param->value = %d)\n", __func__, param->value));
2414 int rt_ioctl_giwauth(struct net_device *dev,
2415 struct iw_request_info *info,
2416 union iwreq_data *wrqu, char *extra)
2418 PRTMP_ADAPTER pAdapter = dev->ml_priv;
2419 struct iw_param *param = &wrqu->param;
2421 //check if the interface is down
2422 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
2424 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
2428 switch (param->flags & IW_AUTH_INDEX) {
2429 case IW_AUTH_DROP_UNENCRYPTED:
2430 param->value = (pAdapter->StaCfg.WepStatus == Ndis802_11WEPDisabled) ? 0 : 1;
2433 case IW_AUTH_80211_AUTH_ALG:
2434 param->value = (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeShared) ? IW_AUTH_ALG_SHARED_KEY : IW_AUTH_ALG_OPEN_SYSTEM;
2437 case IW_AUTH_WPA_ENABLED:
2438 param->value = (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA) ? 1 : 0;
2444 DBGPRINT(RT_DEBUG_TRACE, ("rt_ioctl_giwauth::param->value = %d!\n", param->value));
2448 void fnSetCipherKey(
2449 IN PRTMP_ADAPTER pAdapter,
2453 IN struct iw_encode_ext *ext)
2455 RTMP_CLEAR_PSFLAG(pAdapter, fRTMP_PS_CAN_GO_SLEEP);
2456 if (RTMP_TEST_PSFLAG(pAdapter, fRTMP_PS_SET_PCI_CLK_OFF_COMMAND))
2458 if (pAdapter->StaCfg.bRadio == FALSE)
2460 RTMP_SET_PSFLAG(pAdapter, fRTMP_PS_CAN_GO_SLEEP);
2463 DBGPRINT(RT_DEBUG_TRACE,("RTMPWPAAddKeyProc1==>\n"));
2464 RTMPPCIeLinkCtrlValueRestore(pAdapter, RESTORE_HALT);
2465 RTMPusecDelay(6000);
2466 pAdapter->bPCIclkOff = FALSE;
2469 NdisZeroMemory(&pAdapter->SharedKey[BSS0][keyIdx], sizeof(CIPHER_KEY));
2470 pAdapter->SharedKey[BSS0][keyIdx].KeyLen = LEN_TKIP_EK;
2471 NdisMoveMemory(pAdapter->SharedKey[BSS0][keyIdx].Key, ext->key, LEN_TKIP_EK);
2472 NdisMoveMemory(pAdapter->SharedKey[BSS0][keyIdx].TxMic, ext->key + LEN_TKIP_EK, LEN_TKIP_TXMICK);
2473 NdisMoveMemory(pAdapter->SharedKey[BSS0][keyIdx].RxMic, ext->key + LEN_TKIP_EK + LEN_TKIP_TXMICK, LEN_TKIP_RXMICK);
2474 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CipherAlg;
2476 // Update group key information to ASIC Shared Key Table
2477 AsicAddSharedKeyEntry(pAdapter,
2480 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg,
2481 pAdapter->SharedKey[BSS0][keyIdx].Key,
2482 pAdapter->SharedKey[BSS0][keyIdx].TxMic,
2483 pAdapter->SharedKey[BSS0][keyIdx].RxMic);
2486 // Update ASIC WCID attribute table and IVEIV table
2487 RTMPAddWcidAttributeEntry(pAdapter,
2490 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg,
2493 // Update ASIC WCID attribute table and IVEIV table
2494 RTMPAddWcidAttributeEntry(pAdapter,
2497 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg,
2498 &pAdapter->MacTab.Content[BSSID_WCID]);
2500 RTMP_SET_PSFLAG(pAdapter, fRTMP_PS_CAN_GO_SLEEP);
2503 int rt_ioctl_siwencodeext(struct net_device *dev,
2504 struct iw_request_info *info,
2505 union iwreq_data *wrqu,
2508 PRTMP_ADAPTER pAdapter = dev->ml_priv;
2509 struct iw_point *encoding = &wrqu->encoding;
2510 struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
2511 int keyIdx, alg = ext->alg;
2513 //check if the interface is down
2514 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
2516 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
2520 if (encoding->flags & IW_ENCODE_DISABLED)
2522 keyIdx = (encoding->flags & IW_ENCODE_INDEX) - 1;
2523 // set BSSID wcid entry of the Pair-wise Key table as no-security mode
2524 AsicRemovePairwiseKeyEntry(pAdapter, BSS0, BSSID_WCID);
2525 pAdapter->SharedKey[BSS0][keyIdx].KeyLen = 0;
2526 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CIPHER_NONE;
2527 AsicRemoveSharedKeyEntry(pAdapter, 0, (UCHAR)keyIdx);
2528 NdisZeroMemory(&pAdapter->SharedKey[BSS0][keyIdx], sizeof(CIPHER_KEY));
2529 DBGPRINT(RT_DEBUG_TRACE, ("%s::Remove all keys!(encoding->flags = %x)\n", __func__, encoding->flags));
2533 // Get Key Index and convet to our own defined key index
2534 keyIdx = (encoding->flags & IW_ENCODE_INDEX) - 1;
2535 if((keyIdx < 0) || (keyIdx >= NR_WEP_KEYS))
2538 if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
2540 pAdapter->StaCfg.DefaultKeyId = keyIdx;
2541 DBGPRINT(RT_DEBUG_TRACE, ("%s::DefaultKeyId = %d\n", __func__, pAdapter->StaCfg.DefaultKeyId));
2545 case IW_ENCODE_ALG_NONE:
2546 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_ENCODE_ALG_NONE\n", __func__));
2548 case IW_ENCODE_ALG_WEP:
2549 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_ENCODE_ALG_WEP - ext->key_len = %d, keyIdx = %d\n", __func__, ext->key_len, keyIdx));
2550 if (ext->key_len == MAX_WEP_KEY_SIZE)
2552 pAdapter->SharedKey[BSS0][keyIdx].KeyLen = MAX_WEP_KEY_SIZE;
2553 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CIPHER_WEP128;
2555 else if (ext->key_len == MIN_WEP_KEY_SIZE)
2557 pAdapter->SharedKey[BSS0][keyIdx].KeyLen = MIN_WEP_KEY_SIZE;
2558 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CIPHER_WEP64;
2563 NdisZeroMemory(pAdapter->SharedKey[BSS0][keyIdx].Key, 16);
2564 NdisMoveMemory(pAdapter->SharedKey[BSS0][keyIdx].Key, ext->key, ext->key_len);
2566 if (pAdapter->StaCfg.GroupCipher == Ndis802_11GroupWEP40Enabled ||
2567 pAdapter->StaCfg.GroupCipher == Ndis802_11GroupWEP104Enabled)
2569 // Set Group key material to Asic
2570 AsicAddSharedKeyEntry(pAdapter, BSS0, keyIdx, pAdapter->SharedKey[BSS0][keyIdx].CipherAlg, pAdapter->SharedKey[BSS0][keyIdx].Key, NULL, NULL);
2572 // Update WCID attribute table and IVEIV table for this group key table
2573 RTMPAddWcidAttributeEntry(pAdapter, BSS0, keyIdx, pAdapter->SharedKey[BSS0][keyIdx].CipherAlg, NULL);
2575 STA_PORT_SECURED(pAdapter);
2577 // Indicate Connected for GUI
2578 pAdapter->IndicateMediaState = NdisMediaStateConnected;
2581 case IW_ENCODE_ALG_TKIP:
2582 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_ENCODE_ALG_TKIP - keyIdx = %d, ext->key_len = %d\n", __func__, keyIdx, ext->key_len));
2583 if (ext->key_len == 32)
2585 if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
2587 fnSetCipherKey(pAdapter, keyIdx, CIPHER_TKIP, FALSE, ext);
2588 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA2)
2590 STA_PORT_SECURED(pAdapter);
2593 else if (ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY)
2595 fnSetCipherKey(pAdapter, keyIdx, CIPHER_TKIP, TRUE, ext);
2597 // set 802.1x port control
2598 STA_PORT_SECURED(pAdapter);
2604 case IW_ENCODE_ALG_CCMP:
2605 if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
2607 fnSetCipherKey(pAdapter, keyIdx, CIPHER_AES, FALSE, ext);
2608 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA2)
2609 STA_PORT_SECURED(pAdapter);
2611 else if (ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY)
2613 fnSetCipherKey(pAdapter, keyIdx, CIPHER_AES, TRUE, ext);
2615 // set 802.1x port control
2616 STA_PORT_SECURED(pAdapter);
2628 rt_ioctl_giwencodeext(struct net_device *dev,
2629 struct iw_request_info *info,
2630 union iwreq_data *wrqu, char *extra)
2632 PRTMP_ADAPTER pAd = dev->ml_priv;
2634 struct iw_point *encoding = &wrqu->encoding;
2635 struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
2636 int idx, max_key_len;
2638 DBGPRINT(RT_DEBUG_TRACE ,("===> rt_ioctl_giwencodeext\n"));
2640 max_key_len = encoding->length - sizeof(*ext);
2641 if (max_key_len < 0)
2644 idx = encoding->flags & IW_ENCODE_INDEX;
2647 if (idx < 1 || idx > 4)
2651 if ((pAd->StaCfg.WepStatus == Ndis802_11Encryption2Enabled) ||
2652 (pAd->StaCfg.WepStatus == Ndis802_11Encryption3Enabled))
2654 if (idx != pAd->StaCfg.DefaultKeyId)
2662 idx = pAd->StaCfg.DefaultKeyId;
2664 encoding->flags = idx + 1;
2665 memset(ext, 0, sizeof(*ext));
2668 switch(pAd->StaCfg.WepStatus) {
2669 case Ndis802_11WEPDisabled:
2670 ext->alg = IW_ENCODE_ALG_NONE;
2671 encoding->flags |= IW_ENCODE_DISABLED;
2673 case Ndis802_11WEPEnabled:
2674 ext->alg = IW_ENCODE_ALG_WEP;
2675 if (pAd->SharedKey[BSS0][idx].KeyLen > max_key_len)
2679 ext->key_len = pAd->SharedKey[BSS0][idx].KeyLen;
2680 pKey = &(pAd->SharedKey[BSS0][idx].Key[0]);
2683 case Ndis802_11Encryption2Enabled:
2684 case Ndis802_11Encryption3Enabled:
2685 if (pAd->StaCfg.WepStatus == Ndis802_11Encryption2Enabled)
2686 ext->alg = IW_ENCODE_ALG_TKIP;
2688 ext->alg = IW_ENCODE_ALG_CCMP;
2690 if (max_key_len < 32)
2695 pKey = &pAd->StaCfg.PMK[0];
2702 if (ext->key_len && pKey)
2704 encoding->flags |= IW_ENCODE_ENABLED;
2705 memcpy(ext->key, pKey, ext->key_len);
2712 int rt_ioctl_siwgenie(struct net_device *dev,
2713 struct iw_request_info *info,
2714 union iwreq_data *wrqu, char *extra)
2716 PRTMP_ADAPTER pAd = dev->ml_priv;
2718 if (wrqu->data.length > MAX_LEN_OF_RSNIE ||
2719 (wrqu->data.length && extra == NULL))
2722 if (wrqu->data.length)
2724 pAd->StaCfg.RSNIE_Len = wrqu->data.length;
2725 NdisMoveMemory(&pAd->StaCfg.RSN_IE[0], extra, pAd->StaCfg.RSNIE_Len);
2729 pAd->StaCfg.RSNIE_Len = 0;
2730 NdisZeroMemory(&pAd->StaCfg.RSN_IE[0], MAX_LEN_OF_RSNIE);
2735 #endif // SIOCSIWGENIE //
2737 int rt_ioctl_giwgenie(struct net_device *dev,
2738 struct iw_request_info *info,
2739 union iwreq_data *wrqu, char *extra)
2741 PRTMP_ADAPTER pAd = dev->ml_priv;
2743 if ((pAd->StaCfg.RSNIE_Len == 0) ||
2744 (pAd->StaCfg.AuthMode < Ndis802_11AuthModeWPA))
2746 wrqu->data.length = 0;
2750 #ifdef NATIVE_WPA_SUPPLICANT_SUPPORT
2752 if (pAd->StaCfg.WpaSupplicantUP == WPA_SUPPLICANT_ENABLE)
2754 if (wrqu->data.length < pAd->StaCfg.RSNIE_Len)
2757 wrqu->data.length = pAd->StaCfg.RSNIE_Len;
2758 memcpy(extra, &pAd->StaCfg.RSN_IE[0], pAd->StaCfg.RSNIE_Len);
2761 #endif // SIOCSIWGENIE //
2762 #endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
2764 UCHAR RSNIe = IE_WPA;
2766 if (wrqu->data.length < (pAd->StaCfg.RSNIE_Len + 2)) // ID, Len
2768 wrqu->data.length = pAd->StaCfg.RSNIE_Len + 2;
2770 if ((pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK) ||
2771 (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2))
2774 extra[0] = (char)RSNIe;
2775 extra[1] = pAd->StaCfg.RSNIE_Len;
2776 memcpy(extra+2, &pAd->StaCfg.RSN_IE[0], pAd->StaCfg.RSNIE_Len);
2782 int rt_ioctl_siwpmksa(struct net_device *dev,
2783 struct iw_request_info *info,
2784 union iwreq_data *wrqu,
2787 PRTMP_ADAPTER pAd = dev->ml_priv;
2788 struct iw_pmksa *pPmksa = (struct iw_pmksa *)wrqu->data.pointer;
2789 INT CachedIdx = 0, idx = 0;
2794 DBGPRINT(RT_DEBUG_TRACE ,("===> rt_ioctl_siwpmksa\n"));
2797 case IW_PMKSA_FLUSH:
2798 NdisZeroMemory(pAd->StaCfg.SavedPMK, sizeof(BSSID_INFO)*PMKID_NO);
2799 DBGPRINT(RT_DEBUG_TRACE ,("rt_ioctl_siwpmksa - IW_PMKSA_FLUSH\n"));
2801 case IW_PMKSA_REMOVE:
2802 for (CachedIdx = 0; CachedIdx < pAd->StaCfg.SavedPMKNum; CachedIdx++)
2804 // compare the BSSID
2805 if (NdisEqualMemory(pPmksa->bssid.sa_data, pAd->StaCfg.SavedPMK[CachedIdx].BSSID, MAC_ADDR_LEN))
2807 NdisZeroMemory(pAd->StaCfg.SavedPMK[CachedIdx].BSSID, MAC_ADDR_LEN);
2808 NdisZeroMemory(pAd->StaCfg.SavedPMK[CachedIdx].PMKID, 16);
2809 for (idx = CachedIdx; idx < (pAd->StaCfg.SavedPMKNum - 1); idx++)
2811 NdisMoveMemory(&pAd->StaCfg.SavedPMK[idx].BSSID[0], &pAd->StaCfg.SavedPMK[idx+1].BSSID[0], MAC_ADDR_LEN);
2812 NdisMoveMemory(&pAd->StaCfg.SavedPMK[idx].PMKID[0], &pAd->StaCfg.SavedPMK[idx+1].PMKID[0], 16);
2814 pAd->StaCfg.SavedPMKNum--;
2819 DBGPRINT(RT_DEBUG_TRACE ,("rt_ioctl_siwpmksa - IW_PMKSA_REMOVE\n"));
2822 for (CachedIdx = 0; CachedIdx < pAd->StaCfg.SavedPMKNum; CachedIdx++)
2824 // compare the BSSID
2825 if (NdisEqualMemory(pPmksa->bssid.sa_data, pAd->StaCfg.SavedPMK[CachedIdx].BSSID, MAC_ADDR_LEN))
2829 // Found, replace it
2830 if (CachedIdx < PMKID_NO)
2832 DBGPRINT(RT_DEBUG_OFF, ("Update PMKID, idx = %d\n", CachedIdx));
2833 NdisMoveMemory(&pAd->StaCfg.SavedPMK[CachedIdx].BSSID[0], pPmksa->bssid.sa_data, MAC_ADDR_LEN);
2834 NdisMoveMemory(&pAd->StaCfg.SavedPMK[CachedIdx].PMKID[0], pPmksa->pmkid, 16);
2835 pAd->StaCfg.SavedPMKNum++;
2837 // Not found, replace the last one
2840 // Randomly replace one
2841 CachedIdx = (pPmksa->bssid.sa_data[5] % PMKID_NO);
2842 DBGPRINT(RT_DEBUG_OFF, ("Update PMKID, idx = %d\n", CachedIdx));
2843 NdisMoveMemory(&pAd->StaCfg.SavedPMK[CachedIdx].BSSID[0], pPmksa->bssid.sa_data, MAC_ADDR_LEN);
2844 NdisMoveMemory(&pAd->StaCfg.SavedPMK[CachedIdx].PMKID[0], pPmksa->pmkid, 16);
2847 DBGPRINT(RT_DEBUG_TRACE ,("rt_ioctl_siwpmksa - IW_PMKSA_ADD\n"));
2850 DBGPRINT(RT_DEBUG_TRACE ,("rt_ioctl_siwpmksa - Unknow Command!!\n"));
2856 #endif // #if WIRELESS_EXT > 17
2860 rt_private_ioctl_bbp(struct net_device *dev, struct iw_request_info *info,
2861 struct iw_point *wrq, char *extra)
2868 BOOLEAN bIsPrintAllBBP = FALSE;
2870 PRTMP_ADAPTER pAdapter = dev->ml_priv;
2873 memset(extra, 0x00, IW_PRIV_SIZE_MASK);
2875 if (wrq->length > 1) //No parameters.
2877 sprintf(extra, "\n");
2879 //Parsing Read or Write
2880 this_char = wrq->pointer;
2881 DBGPRINT(RT_DEBUG_TRACE, ("this_char=%s\n", this_char));
2885 if ((value = rtstrchr(this_char, '=')) != NULL)
2888 if (!value || !*value)
2890 DBGPRINT(RT_DEBUG_TRACE, ("this_char=%s, value=%s\n", this_char, value));
2891 if (sscanf(this_char, "%d", &(bbpId)) == 1)
2896 if (ATE_ON(pAdapter))
2898 ATE_BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, ®BBP);
2901 #endif // RALINK_ATE //
2903 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, ®BBP);
2905 sprintf(extra+strlen(extra), "R%02d[0x%02X]:%02X\n", bbpId, bbpId*2, regBBP);
2906 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2907 DBGPRINT(RT_DEBUG_TRACE, ("msg=%s\n", extra));
2910 {//Invalid parametes, so default printk all bbp
2911 bIsPrintAllBBP = TRUE;
2916 { //Invalid parametes, so default printk all bbp
2917 bIsPrintAllBBP = TRUE;
2923 if ((sscanf(this_char, "%d", &(bbpId)) == 1) && (sscanf(value, "%x", &(bbpValue)) == 1))
2928 if (ATE_ON(pAdapter))
2930 ATE_BBP_IO_WRITE8_BY_REG_ID(pAdapter, bbpId, bbpValue);
2931 //Read it back for showing
2932 ATE_BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, ®BBP);
2935 #endif // RALINK_ATE //
2937 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, bbpId, bbpValue);
2938 //Read it back for showing
2939 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, ®BBP);
2941 sprintf(extra+strlen(extra), "R%02d[0x%02X]:%02X\n", bbpId, bbpId*2, regBBP);
2942 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2943 DBGPRINT(RT_DEBUG_TRACE, ("msg=%s\n", extra));
2946 {//Invalid parametes, so default printk all bbp
2947 bIsPrintAllBBP = TRUE;
2952 { //Invalid parametes, so default printk all bbp
2953 bIsPrintAllBBP = TRUE;
2959 bIsPrintAllBBP = TRUE;
2964 memset(extra, 0x00, IW_PRIV_SIZE_MASK);
2965 sprintf(extra, "\n");
2966 for (bbpId = 0; bbpId <= 136; bbpId++)
2968 if (strlen(extra) >= (IW_PRIV_SIZE_MASK - 10))
2971 if (ATE_ON(pAdapter))
2973 ATE_BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, ®BBP);
2976 #endif // RALINK_ATE //
2977 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, ®BBP);
2978 sprintf(extra+strlen(extra), "R%02d[0x%02X]:%02X ", bbpId, bbpId*2, regBBP);
2980 sprintf(extra+strlen(extra), "\n");
2983 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2984 DBGPRINT(RT_DEBUG_TRACE, ("wrq->length = %d\n", wrq->length));
2987 DBGPRINT(RT_DEBUG_TRACE, ("<==rt_private_ioctl_bbp\n\n"));
2993 int rt_ioctl_siwrate(struct net_device *dev,
2994 struct iw_request_info *info,
2995 union iwreq_data *wrqu, char *extra)
2997 PRTMP_ADAPTER pAd = dev->ml_priv;
2998 UINT32 rate = wrqu->bitrate.value, fixed = wrqu->bitrate.fixed;
3000 //check if the interface is down
3001 if(!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_IN_USE))
3003 DBGPRINT(RT_DEBUG_TRACE, ("rt_ioctl_siwrate::Network is down!\n"));
3007 DBGPRINT(RT_DEBUG_TRACE, ("rt_ioctl_siwrate::(rate = %d, fixed = %d)\n", rate, fixed));
3008 /* rate = -1 => auto rate
3009 rate = X, fixed = 1 => (fixed rate X)
3014 pAd->StaCfg.DesiredTransmitSetting.field.MCS = MCS_AUTO;
3015 pAd->StaCfg.bAutoTxRateSwitch = TRUE;
3016 if ((pAd->CommonCfg.PhyMode <= PHY_11G) ||
3017 (pAd->MacTab.Content[BSSID_WCID].HTPhyMode.field.MODE <= MODE_OFDM))
3018 RTMPSetDesiredRates(pAd, -1);
3020 #ifdef DOT11_N_SUPPORT
3022 #endif // DOT11_N_SUPPORT //
3028 pAd->StaCfg.bAutoTxRateSwitch = FALSE;
3029 if ((pAd->CommonCfg.PhyMode <= PHY_11G) ||
3030 (pAd->MacTab.Content[BSSID_WCID].HTPhyMode.field.MODE <= MODE_OFDM))
3031 RTMPSetDesiredRates(pAd, rate);
3034 pAd->StaCfg.DesiredTransmitSetting.field.MCS = MCS_AUTO;
3035 #ifdef DOT11_N_SUPPORT
3037 #endif // DOT11_N_SUPPORT //
3039 DBGPRINT(RT_DEBUG_TRACE, ("rt_ioctl_siwrate::(HtMcs=%d)\n",pAd->StaCfg.DesiredTransmitSetting.field.MCS));
3043 // TODO: rate = X, fixed = 0 => (rates <= X)
3051 int rt_ioctl_giwrate(struct net_device *dev,
3052 struct iw_request_info *info,
3053 union iwreq_data *wrqu, char *extra)
3055 PRTMP_ADAPTER pAd = dev->ml_priv;
3056 int rate_index = 0, rate_count = 0;
3057 HTTRANSMIT_SETTING ht_setting;
3058 __s32 ralinkrate[] =
3059 {2, 4, 11, 22, // CCK
3060 12, 18, 24, 36, 48, 72, 96, 108, // OFDM
3061 13, 26, 39, 52, 78, 104, 117, 130, 26, 52, 78, 104, 156, 208, 234, 260, // 20MHz, 800ns GI, MCS: 0 ~ 15
3062 39, 78, 117, 156, 234, 312, 351, 390, // 20MHz, 800ns GI, MCS: 16 ~ 23
3063 27, 54, 81, 108, 162, 216, 243, 270, 54, 108, 162, 216, 324, 432, 486, 540, // 40MHz, 800ns GI, MCS: 0 ~ 15
3064 81, 162, 243, 324, 486, 648, 729, 810, // 40MHz, 800ns GI, MCS: 16 ~ 23
3065 14, 29, 43, 57, 87, 115, 130, 144, 29, 59, 87, 115, 173, 230, 260, 288, // 20MHz, 400ns GI, MCS: 0 ~ 15
3066 43, 87, 130, 173, 260, 317, 390, 433, // 20MHz, 400ns GI, MCS: 16 ~ 23
3067 30, 60, 90, 120, 180, 240, 270, 300, 60, 120, 180, 240, 360, 480, 540, 600, // 40MHz, 400ns GI, MCS: 0 ~ 15
3068 90, 180, 270, 360, 540, 720, 810, 900}; // 40MHz, 400ns GI, MCS: 16 ~ 23
3070 rate_count = sizeof(ralinkrate)/sizeof(__s32);
3071 //check if the interface is down
3072 if(!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_IN_USE))
3074 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
3078 if ((pAd->StaCfg.bAutoTxRateSwitch == FALSE) &&
3080 ((pAd->CommonCfg.PhyMode <= PHY_11G) || (pAd->MacTab.Content[BSSID_WCID].HTPhyMode.field.MODE <= MODE_OFDM)))
3081 ht_setting.word = pAd->StaCfg.HTPhyMode.word;
3083 ht_setting.word = pAd->MacTab.Content[BSSID_WCID].HTPhyMode.word;
3085 #ifdef DOT11_N_SUPPORT
3086 if (ht_setting.field.MODE >= MODE_HTMIX)
3088 rate_index = 12 + ((UCHAR)ht_setting.field.BW *24) + ((UCHAR)ht_setting.field.ShortGI *48) + ((UCHAR)ht_setting.field.MCS);
3091 #endif // DOT11_N_SUPPORT //
3092 if (ht_setting.field.MODE == MODE_OFDM)
3093 rate_index = (UCHAR)(ht_setting.field.MCS) + 4;
3094 else if (ht_setting.field.MODE == MODE_CCK)
3095 rate_index = (UCHAR)(ht_setting.field.MCS);
3100 if (rate_index > rate_count)
3101 rate_index = rate_count;
3103 wrqu->bitrate.value = ralinkrate[rate_index] * 500000;
3104 wrqu->bitrate.disabled = 0;
3109 static const iw_handler rt_handler[] =
3111 (iw_handler) NULL, /* SIOCSIWCOMMIT */
3112 (iw_handler) rt_ioctl_giwname, /* SIOCGIWNAME */
3113 (iw_handler) NULL, /* SIOCSIWNWID */
3114 (iw_handler) NULL, /* SIOCGIWNWID */
3115 (iw_handler) rt_ioctl_siwfreq, /* SIOCSIWFREQ */
3116 (iw_handler) rt_ioctl_giwfreq, /* SIOCGIWFREQ */
3117 (iw_handler) rt_ioctl_siwmode, /* SIOCSIWMODE */
3118 (iw_handler) rt_ioctl_giwmode, /* SIOCGIWMODE */
3119 (iw_handler) NULL, /* SIOCSIWSENS */
3120 (iw_handler) NULL, /* SIOCGIWSENS */
3121 (iw_handler) NULL /* not used */, /* SIOCSIWRANGE */
3122 (iw_handler) rt_ioctl_giwrange, /* SIOCGIWRANGE */
3123 (iw_handler) NULL /* not used */, /* SIOCSIWPRIV */
3124 (iw_handler) NULL /* kernel code */, /* SIOCGIWPRIV */
3125 (iw_handler) NULL /* not used */, /* SIOCSIWSTATS */
3126 (iw_handler) rt28xx_get_wireless_stats /* kernel code */, /* SIOCGIWSTATS */
3127 (iw_handler) NULL, /* SIOCSIWSPY */
3128 (iw_handler) NULL, /* SIOCGIWSPY */
3129 (iw_handler) NULL, /* SIOCSIWTHRSPY */
3130 (iw_handler) NULL, /* SIOCGIWTHRSPY */
3131 (iw_handler) rt_ioctl_siwap, /* SIOCSIWAP */
3132 (iw_handler) rt_ioctl_giwap, /* SIOCGIWAP */
3134 (iw_handler) rt_ioctl_siwmlme, /* SIOCSIWMLME */
3136 (iw_handler) NULL, /* SIOCSIWMLME */
3137 #endif // SIOCSIWMLME //
3138 (iw_handler) rt_ioctl_iwaplist, /* SIOCGIWAPLIST */
3140 (iw_handler) rt_ioctl_siwscan, /* SIOCSIWSCAN */
3141 (iw_handler) rt_ioctl_giwscan, /* SIOCGIWSCAN */
3143 (iw_handler) NULL, /* SIOCSIWSCAN */
3144 (iw_handler) NULL, /* SIOCGIWSCAN */
3145 #endif /* SIOCGIWSCAN */
3146 (iw_handler) rt_ioctl_siwessid, /* SIOCSIWESSID */
3147 (iw_handler) rt_ioctl_giwessid, /* SIOCGIWESSID */
3148 (iw_handler) rt_ioctl_siwnickn, /* SIOCSIWNICKN */
3149 (iw_handler) rt_ioctl_giwnickn, /* SIOCGIWNICKN */
3150 (iw_handler) NULL, /* -- hole -- */
3151 (iw_handler) NULL, /* -- hole -- */
3152 (iw_handler) rt_ioctl_siwrate, /* SIOCSIWRATE */
3153 (iw_handler) rt_ioctl_giwrate, /* SIOCGIWRATE */
3154 (iw_handler) rt_ioctl_siwrts, /* SIOCSIWRTS */
3155 (iw_handler) rt_ioctl_giwrts, /* SIOCGIWRTS */
3156 (iw_handler) rt_ioctl_siwfrag, /* SIOCSIWFRAG */
3157 (iw_handler) rt_ioctl_giwfrag, /* SIOCGIWFRAG */
3158 (iw_handler) NULL, /* SIOCSIWTXPOW */
3159 (iw_handler) NULL, /* SIOCGIWTXPOW */
3160 (iw_handler) NULL, /* SIOCSIWRETRY */
3161 (iw_handler) NULL, /* SIOCGIWRETRY */
3162 (iw_handler) rt_ioctl_siwencode, /* SIOCSIWENCODE */
3163 (iw_handler) rt_ioctl_giwencode, /* SIOCGIWENCODE */
3164 (iw_handler) NULL, /* SIOCSIWPOWER */
3165 (iw_handler) NULL, /* SIOCGIWPOWER */
3166 (iw_handler) NULL, /* -- hole -- */
3167 (iw_handler) NULL, /* -- hole -- */
3168 #if WIRELESS_EXT > 17
3169 (iw_handler) rt_ioctl_siwgenie, /* SIOCSIWGENIE */
3170 (iw_handler) rt_ioctl_giwgenie, /* SIOCGIWGENIE */
3171 (iw_handler) rt_ioctl_siwauth, /* SIOCSIWAUTH */
3172 (iw_handler) rt_ioctl_giwauth, /* SIOCGIWAUTH */
3173 (iw_handler) rt_ioctl_siwencodeext, /* SIOCSIWENCODEEXT */
3174 (iw_handler) rt_ioctl_giwencodeext, /* SIOCGIWENCODEEXT */
3175 (iw_handler) rt_ioctl_siwpmksa, /* SIOCSIWPMKSA */
3179 static const iw_handler rt_priv_handlers[] = {
3180 (iw_handler) NULL, /* + 0x00 */
3181 (iw_handler) NULL, /* + 0x01 */
3182 #ifndef CONFIG_AP_SUPPORT
3183 (iw_handler) rt_ioctl_setparam, /* + 0x02 */
3185 (iw_handler) NULL, /* + 0x02 */
3186 #endif // CONFIG_AP_SUPPORT //
3188 (iw_handler) rt_private_ioctl_bbp, /* + 0x03 */
3190 (iw_handler) NULL, /* + 0x03 */
3192 (iw_handler) NULL, /* + 0x04 */
3193 (iw_handler) NULL, /* + 0x05 */
3194 (iw_handler) NULL, /* + 0x06 */
3195 (iw_handler) NULL, /* + 0x07 */
3196 (iw_handler) NULL, /* + 0x08 */
3197 (iw_handler) rt_private_get_statistics, /* + 0x09 */
3198 (iw_handler) NULL, /* + 0x0A */
3199 (iw_handler) NULL, /* + 0x0B */
3200 (iw_handler) NULL, /* + 0x0C */
3201 (iw_handler) NULL, /* + 0x0D */
3202 (iw_handler) NULL, /* + 0x0E */
3203 (iw_handler) NULL, /* + 0x0F */
3204 (iw_handler) NULL, /* + 0x10 */
3205 (iw_handler) rt_private_show, /* + 0x11 */
3206 (iw_handler) NULL, /* + 0x12 */
3207 (iw_handler) NULL, /* + 0x13 */
3208 (iw_handler) NULL, /* + 0x15 */
3209 (iw_handler) NULL, /* + 0x17 */
3210 (iw_handler) NULL, /* + 0x18 */
3213 const struct iw_handler_def rt28xx_iw_handler_def =
3215 #define N(a) (sizeof (a) / sizeof (a[0]))
3216 .standard = (iw_handler *) rt_handler,
3217 .num_standard = sizeof(rt_handler) / sizeof(iw_handler),
3218 .private = (iw_handler *) rt_priv_handlers,
3219 .num_private = N(rt_priv_handlers),
3220 .private_args = (struct iw_priv_args *) privtab,
3221 .num_private_args = N(privtab),
3222 #if IW_HANDLER_VERSION >= 7
3223 .get_wireless_stats = rt28xx_get_wireless_stats,
3227 INT RTMPSetInformation(
3228 IN PRTMP_ADAPTER pAdapter,
3229 IN OUT struct ifreq *rq,
3232 struct iwreq *wrq = (struct iwreq *) rq;
3233 NDIS_802_11_SSID Ssid;
3234 NDIS_802_11_MAC_ADDRESS Bssid;
3235 RT_802_11_PHY_MODE PhyMode;
3236 RT_802_11_STA_CONFIG StaConfig;
3237 NDIS_802_11_RATES aryRates;
3238 RT_802_11_PREAMBLE Preamble;
3239 NDIS_802_11_WEP_STATUS WepStatus;
3240 NDIS_802_11_AUTHENTICATION_MODE AuthMode = Ndis802_11AuthModeMax;
3241 NDIS_802_11_NETWORK_INFRASTRUCTURE BssType;
3242 NDIS_802_11_RTS_THRESHOLD RtsThresh;
3243 NDIS_802_11_FRAGMENTATION_THRESHOLD FragThresh;
3244 NDIS_802_11_POWER_MODE PowerMode;
3245 PNDIS_802_11_KEY pKey = NULL;
3246 PNDIS_802_11_WEP pWepKey =NULL;
3247 PNDIS_802_11_REMOVE_KEY pRemoveKey = NULL;
3248 NDIS_802_11_CONFIGURATION Config, *pConfig = NULL;
3249 NDIS_802_11_NETWORK_TYPE NetType;
3252 INT Status = NDIS_STATUS_SUCCESS, MaxPhyMode = PHY_11G;
3255 BOOLEAN StateMachineTouched = FALSE;
3256 #ifdef DOT11_N_SUPPORT
3257 OID_SET_HT_PHYMODE HT_PhyMode; //11n ,kathy
3258 #endif // DOT11_N_SUPPORT //
3259 #ifdef WPA_SUPPLICANT_SUPPORT
3260 PNDIS_802_11_PMKID pPmkId = NULL;
3261 BOOLEAN IEEE8021xState = FALSE;
3262 BOOLEAN IEEE8021x_required_keys = FALSE;
3263 UCHAR wpa_supplicant_enable = 0;
3264 #endif // WPA_SUPPLICANT_SUPPORT //
3267 TX_RTY_CFG_STRUC tx_rty_cfg;
3268 ULONG ShortRetryLimit, LongRetryLimit;
3270 #endif // SNMP_SUPPORT //
3273 #ifdef DOT11_N_SUPPORT
3274 MaxPhyMode = PHY_11N_5G;
3275 #endif // DOT11_N_SUPPORT //
3278 DBGPRINT(RT_DEBUG_TRACE, ("-->RTMPSetInformation(), 0x%08x\n", cmd&0x7FFF));
3279 switch(cmd & 0x7FFF) {
3280 case RT_OID_802_11_COUNTRY_REGION:
3281 if (wrq->u.data.length < sizeof(UCHAR))
3283 // Only avaliable when EEPROM not programming
3284 else if (!(pAdapter->CommonCfg.CountryRegion & 0x80) && !(pAdapter->CommonCfg.CountryRegionForABand & 0x80))
3289 Status = copy_from_user(&Country, wrq->u.data.pointer, wrq->u.data.length);
3290 pAdapter->CommonCfg.CountryRegion = (UCHAR)(Country & 0x000000FF);
3291 pAdapter->CommonCfg.CountryRegionForABand = (UCHAR)((Country >> 8) & 0x000000FF);
3292 TmpPhy = pAdapter->CommonCfg.PhyMode;
3293 pAdapter->CommonCfg.PhyMode = 0xff;
3294 // Build all corresponding channel information
3295 RTMPSetPhyMode(pAdapter, TmpPhy);
3296 #ifdef DOT11_N_SUPPORT
3297 SetCommonHT(pAdapter);
3298 #endif // DOT11_N_SUPPORT //
3299 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_COUNTRY_REGION (A:%d B/G:%d)\n", pAdapter->CommonCfg.CountryRegionForABand,
3300 pAdapter->CommonCfg.CountryRegion));
3303 case OID_802_11_BSSID_LIST_SCAN:
3305 if (ATE_ON(pAdapter))
3307 DBGPRINT(RT_DEBUG_TRACE, ("The driver is in ATE mode now\n"));
3310 #endif // RALINK_ATE //
3312 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_BSSID_LIST_SCAN, TxCnt = %d \n", pAdapter->RalinkCounters.LastOneSecTotalTxCount));
3314 if (MONITOR_ON(pAdapter))
3316 DBGPRINT(RT_DEBUG_TRACE, ("!!! Driver is in Monitor Mode now !!!\n"));
3320 //Benson add 20080527, when radio off, sta don't need to scan
3321 if (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_RADIO_OFF))
3324 if (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
3326 DBGPRINT(RT_DEBUG_TRACE, ("!!! Driver is scanning now !!!\n"));
3327 pAdapter->StaCfg.bScanReqIsFromWebUI = TRUE;
3328 Status = NDIS_STATUS_SUCCESS;
3332 if (pAdapter->RalinkCounters.LastOneSecTotalTxCount > 100)
3334 DBGPRINT(RT_DEBUG_TRACE, ("!!! Link UP, ignore this set::OID_802_11_BSSID_LIST_SCAN\n"));
3335 Status = NDIS_STATUS_SUCCESS;
3336 pAdapter->StaCfg.ScanCnt = 99; // Prevent auto scan triggered by this OID
3340 if ((OPSTATUS_TEST_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED)) &&
3341 ((pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA) ||
3342 (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK) ||
3343 (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA2) ||
3344 (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK)) &&
3345 (pAdapter->StaCfg.PortSecured == WPA_802_1X_PORT_NOT_SECURED))
3347 DBGPRINT(RT_DEBUG_TRACE, ("!!! Link UP, Port Not Secured! ignore this set::OID_802_11_BSSID_LIST_SCAN\n"));
3348 Status = NDIS_STATUS_SUCCESS;
3349 pAdapter->StaCfg.ScanCnt = 99; // Prevent auto scan triggered by this OID
3354 if (pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE)
3356 RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
3357 DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
3360 // tell CNTL state machine to call NdisMSetInformationComplete() after completing
3361 // this request, because this request is initiated by NDIS.
3362 pAdapter->MlmeAux.CurrReqIsFromNdis = FALSE;
3363 // Reset allowed scan retries
3364 pAdapter->StaCfg.ScanCnt = 0;
3365 pAdapter->StaCfg.LastScanTime = Now;
3367 pAdapter->StaCfg.bScanReqIsFromWebUI = TRUE;
3368 RTMP_SET_FLAG(pAdapter, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS);
3369 MlmeEnqueue(pAdapter,
3370 MLME_CNTL_STATE_MACHINE,
3371 OID_802_11_BSSID_LIST_SCAN,
3375 Status = NDIS_STATUS_SUCCESS;
3376 StateMachineTouched = TRUE;
3378 case OID_802_11_SSID:
3379 if (wrq->u.data.length != sizeof(NDIS_802_11_SSID))
3383 PCHAR pSsidString = NULL;
3384 Status = copy_from_user(&Ssid, wrq->u.data.pointer, wrq->u.data.length);
3386 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_SSID (Len=%d,Ssid=%s)\n", Ssid.SsidLength, Ssid.Ssid));
3387 if (Ssid.SsidLength > MAX_LEN_OF_SSID)
3391 if (Ssid.SsidLength == 0)
3393 Set_SSID_Proc(pAdapter, "");
3397 pSsidString = (CHAR *) kmalloc(MAX_LEN_OF_SSID+1, MEM_ALLOC_FLAG);
3400 NdisZeroMemory(pSsidString, MAX_LEN_OF_SSID+1);
3401 NdisMoveMemory(pSsidString, Ssid.Ssid, Ssid.SsidLength);
3402 Set_SSID_Proc(pAdapter, pSsidString);
3411 case OID_802_11_BSSID:
3413 if (ATE_ON(pAdapter))
3415 DBGPRINT(RT_DEBUG_TRACE, ("The driver is in ATE mode now\n"));
3418 #endif // RALINK_ATE //
3419 if (wrq->u.data.length != sizeof(NDIS_802_11_MAC_ADDRESS))
3423 Status = copy_from_user(&Bssid, wrq->u.data.pointer, wrq->u.data.length);
3425 // tell CNTL state machine to call NdisMSetInformationComplete() after completing
3426 // this request, because this request is initiated by NDIS.
3427 pAdapter->MlmeAux.CurrReqIsFromNdis = FALSE;
3429 // Prevent to connect AP again in STAMlmePeriodicExec
3430 pAdapter->MlmeAux.AutoReconnectSsidLen= 32;
3432 // Reset allowed scan retries
3433 pAdapter->StaCfg.ScanCnt = 0;
3435 if (pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE)
3437 RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
3438 DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
3440 MlmeEnqueue(pAdapter,
3441 MLME_CNTL_STATE_MACHINE,
3443 sizeof(NDIS_802_11_MAC_ADDRESS),
3445 Status = NDIS_STATUS_SUCCESS;
3446 StateMachineTouched = TRUE;
3448 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_BSSID %02x:%02x:%02x:%02x:%02x:%02x\n",
3449 Bssid[0], Bssid[1], Bssid[2], Bssid[3], Bssid[4], Bssid[5]));
3452 case RT_OID_802_11_RADIO:
3453 if (wrq->u.data.length != sizeof(BOOLEAN))
3457 Status = copy_from_user(&RadioState, wrq->u.data.pointer, wrq->u.data.length);
3458 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_RADIO (=%d)\n", RadioState));
3459 if (pAdapter->StaCfg.bSwRadio != RadioState)
3461 pAdapter->StaCfg.bSwRadio = RadioState;
3462 if (pAdapter->StaCfg.bRadio != (pAdapter->StaCfg.bHwRadio && pAdapter->StaCfg.bSwRadio))
3464 pAdapter->StaCfg.bRadio = (pAdapter->StaCfg.bHwRadio && pAdapter->StaCfg.bSwRadio);
3465 if (pAdapter->StaCfg.bRadio == TRUE)
3467 MlmeRadioOn(pAdapter);
3468 // Update extra information
3469 pAdapter->ExtraInfo = EXTRA_INFO_CLEAR;
3473 MlmeRadioOff(pAdapter);
3474 // Update extra information
3475 pAdapter->ExtraInfo = SW_RADIO_OFF;
3481 case RT_OID_802_11_PHY_MODE:
3482 if (wrq->u.data.length != sizeof(RT_802_11_PHY_MODE))
3486 Status = copy_from_user(&PhyMode, wrq->u.data.pointer, wrq->u.data.length);
3487 if (PhyMode <= MaxPhyMode)
3489 RTMPSetPhyMode(pAdapter, PhyMode);
3490 #ifdef DOT11_N_SUPPORT
3491 SetCommonHT(pAdapter);
3492 #endif // DOT11_N_SUPPORT //
3494 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_PHY_MODE (=%d)\n", PhyMode));
3497 case RT_OID_802_11_STA_CONFIG:
3498 if (wrq->u.data.length != sizeof(RT_802_11_STA_CONFIG))
3502 Status = copy_from_user(&StaConfig, wrq->u.data.pointer, wrq->u.data.length);
3503 pAdapter->CommonCfg.bEnableTxBurst = StaConfig.EnableTxBurst;
3504 pAdapter->CommonCfg.UseBGProtection = StaConfig.UseBGProtection;
3505 pAdapter->CommonCfg.bUseShortSlotTime = 1; // 2003-10-30 always SHORT SLOT capable
3506 if ((pAdapter->CommonCfg.PhyMode != StaConfig.AdhocMode) &&
3507 (StaConfig.AdhocMode <= MaxPhyMode))
3509 // allow dynamic change of "USE OFDM rate or not" in ADHOC mode
3510 // if setting changed, need to reset current TX rate as well as BEACON frame format
3511 if (pAdapter->StaCfg.BssType == BSS_ADHOC)
3513 pAdapter->CommonCfg.PhyMode = StaConfig.AdhocMode;
3514 RTMPSetPhyMode(pAdapter, PhyMode);
3515 MlmeUpdateTxRates(pAdapter, FALSE, 0);
3516 MakeIbssBeacon(pAdapter); // re-build BEACON frame
3517 AsicEnableIbssSync(pAdapter); // copy to on-chip memory
3520 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_SET_STA_CONFIG (Burst=%d, Protection=%ld,ShortSlot=%d\n",
3521 pAdapter->CommonCfg.bEnableTxBurst,
3522 pAdapter->CommonCfg.UseBGProtection,
3523 pAdapter->CommonCfg.bUseShortSlotTime));
3526 case OID_802_11_DESIRED_RATES:
3527 if (wrq->u.data.length != sizeof(NDIS_802_11_RATES))
3531 Status = copy_from_user(&aryRates, wrq->u.data.pointer, wrq->u.data.length);
3532 NdisZeroMemory(pAdapter->CommonCfg.DesireRate, MAX_LEN_OF_SUPPORTED_RATES);
3533 NdisMoveMemory(pAdapter->CommonCfg.DesireRate, &aryRates, sizeof(NDIS_802_11_RATES));
3534 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_DESIRED_RATES (%02x,%02x,%02x,%02x,%02x,%02x,%02x,%02x)\n",
3535 pAdapter->CommonCfg.DesireRate[0],pAdapter->CommonCfg.DesireRate[1],
3536 pAdapter->CommonCfg.DesireRate[2],pAdapter->CommonCfg.DesireRate[3],
3537 pAdapter->CommonCfg.DesireRate[4],pAdapter->CommonCfg.DesireRate[5],
3538 pAdapter->CommonCfg.DesireRate[6],pAdapter->CommonCfg.DesireRate[7] ));
3539 // Changing DesiredRate may affect the MAX TX rate we used to TX frames out
3540 MlmeUpdateTxRates(pAdapter, FALSE, 0);
3543 case RT_OID_802_11_PREAMBLE:
3544 if (wrq->u.data.length != sizeof(RT_802_11_PREAMBLE))
3548 Status = copy_from_user(&Preamble, wrq->u.data.pointer, wrq->u.data.length);
3549 if (Preamble == Rt802_11PreambleShort)
3551 pAdapter->CommonCfg.TxPreamble = Preamble;
3552 MlmeSetTxPreamble(pAdapter, Rt802_11PreambleShort);
3554 else if ((Preamble == Rt802_11PreambleLong) || (Preamble == Rt802_11PreambleAuto))
3556 // if user wants AUTO, initialize to LONG here, then change according to AP's
3557 // capability upon association.
3558 pAdapter->CommonCfg.TxPreamble = Preamble;
3559 MlmeSetTxPreamble(pAdapter, Rt802_11PreambleLong);
3566 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_PREAMBLE (=%d)\n", Preamble));
3569 case OID_802_11_WEP_STATUS:
3570 if (wrq->u.data.length != sizeof(NDIS_802_11_WEP_STATUS))
3574 Status = copy_from_user(&WepStatus, wrq->u.data.pointer, wrq->u.data.length);
3575 // Since TKIP, AES, WEP are all supported. It should not have any invalid setting
3576 if (WepStatus <= Ndis802_11Encryption3KeyAbsent)
3578 if (pAdapter->StaCfg.WepStatus != WepStatus)
3580 // Config has changed
3581 pAdapter->bConfigChanged = TRUE;
3583 pAdapter->StaCfg.WepStatus = WepStatus;
3584 pAdapter->StaCfg.OrigWepStatus = WepStatus;
3585 pAdapter->StaCfg.PairCipher = WepStatus;
3586 pAdapter->StaCfg.GroupCipher = WepStatus;
3593 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_WEP_STATUS (=%d)\n",WepStatus));
3596 case OID_802_11_AUTHENTICATION_MODE:
3597 if (wrq->u.data.length != sizeof(NDIS_802_11_AUTHENTICATION_MODE))
3601 Status = copy_from_user(&AuthMode, wrq->u.data.pointer, wrq->u.data.length);
3602 if (AuthMode > Ndis802_11AuthModeMax)
3609 if (pAdapter->StaCfg.AuthMode != AuthMode)
3611 // Config has changed
3612 pAdapter->bConfigChanged = TRUE;
3614 pAdapter->StaCfg.AuthMode = AuthMode;
3616 pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED;
3617 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_AUTHENTICATION_MODE (=%d) \n",pAdapter->StaCfg.AuthMode));
3620 case OID_802_11_INFRASTRUCTURE_MODE:
3621 if (wrq->u.data.length != sizeof(NDIS_802_11_NETWORK_INFRASTRUCTURE))
3625 Status = copy_from_user(&BssType, wrq->u.data.pointer, wrq->u.data.length);
3627 if (BssType == Ndis802_11IBSS)
3628 Set_NetworkType_Proc(pAdapter, "Adhoc");
3629 else if (BssType == Ndis802_11Infrastructure)
3630 Set_NetworkType_Proc(pAdapter, "Infra");
3631 else if (BssType == Ndis802_11Monitor)
3632 Set_NetworkType_Proc(pAdapter, "Monitor");
3636 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_INFRASTRUCTURE_MODE (unknown)\n"));
3640 case OID_802_11_REMOVE_WEP:
3641 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_WEP\n"));
3642 if (wrq->u.data.length != sizeof(NDIS_802_11_KEY_INDEX))
3648 KeyIdx = *(NDIS_802_11_KEY_INDEX *) wrq->u.data.pointer;
3650 if (KeyIdx & 0x80000000)
3652 // Should never set default bit when remove key
3657 KeyIdx = KeyIdx & 0x0fffffff;
3663 pAdapter->SharedKey[BSS0][KeyIdx].KeyLen = 0;
3664 pAdapter->SharedKey[BSS0][KeyIdx].CipherAlg = CIPHER_NONE;
3665 AsicRemoveSharedKeyEntry(pAdapter, 0, (UCHAR)KeyIdx);
3670 case RT_OID_802_11_RESET_COUNTERS:
3671 NdisZeroMemory(&pAdapter->WlanCounters, sizeof(COUNTER_802_11));
3672 NdisZeroMemory(&pAdapter->Counters8023, sizeof(COUNTER_802_3));
3673 NdisZeroMemory(&pAdapter->RalinkCounters, sizeof(COUNTER_RALINK));
3674 pAdapter->Counters8023.RxNoBuffer = 0;
3675 pAdapter->Counters8023.GoodReceives = 0;
3676 pAdapter->Counters8023.RxNoBuffer = 0;
3677 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_RESET_COUNTERS \n"));
3679 case OID_802_11_RTS_THRESHOLD:
3680 if (wrq->u.data.length != sizeof(NDIS_802_11_RTS_THRESHOLD))
3684 Status = copy_from_user(&RtsThresh, wrq->u.data.pointer, wrq->u.data.length);
3685 if (RtsThresh > MAX_RTS_THRESHOLD)
3688 pAdapter->CommonCfg.RtsThreshold = (USHORT)RtsThresh;
3690 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_RTS_THRESHOLD (=%ld)\n",RtsThresh));
3692 case OID_802_11_FRAGMENTATION_THRESHOLD:
3693 if (wrq->u.data.length != sizeof(NDIS_802_11_FRAGMENTATION_THRESHOLD))
3697 Status = copy_from_user(&FragThresh, wrq->u.data.pointer, wrq->u.data.length);
3698 pAdapter->CommonCfg.bUseZeroToDisableFragment = FALSE;
3699 if (FragThresh > MAX_FRAG_THRESHOLD || FragThresh < MIN_FRAG_THRESHOLD)
3701 if (FragThresh == 0)
3703 pAdapter->CommonCfg.FragmentThreshold = MAX_FRAG_THRESHOLD;
3704 pAdapter->CommonCfg.bUseZeroToDisableFragment = TRUE;
3710 pAdapter->CommonCfg.FragmentThreshold = (USHORT)FragThresh;
3712 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_FRAGMENTATION_THRESHOLD (=%ld) \n",FragThresh));
3714 case OID_802_11_POWER_MODE:
3715 if (wrq->u.data.length != sizeof(NDIS_802_11_POWER_MODE))
3719 Status = copy_from_user(&PowerMode, wrq->u.data.pointer, wrq->u.data.length);
3720 if (PowerMode == Ndis802_11PowerModeCAM)
3721 Set_PSMode_Proc(pAdapter, "CAM");
3722 else if (PowerMode == Ndis802_11PowerModeMAX_PSP)
3723 Set_PSMode_Proc(pAdapter, "Max_PSP");
3724 else if (PowerMode == Ndis802_11PowerModeFast_PSP)
3725 Set_PSMode_Proc(pAdapter, "Fast_PSP");
3726 else if (PowerMode == Ndis802_11PowerModeLegacy_PSP)
3727 Set_PSMode_Proc(pAdapter, "Legacy_PSP");
3731 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_POWER_MODE (=%d)\n",PowerMode));
3733 case RT_OID_802_11_TX_POWER_LEVEL_1:
3734 if (wrq->u.data.length < sizeof(ULONG))
3738 Status = copy_from_user(&PowerTemp, wrq->u.data.pointer, wrq->u.data.length);
3739 if (PowerTemp > 100)
3740 PowerTemp = 0xffffffff; // AUTO
3741 pAdapter->CommonCfg.TxPowerDefault = PowerTemp; //keep current setting.
3742 pAdapter->CommonCfg.TxPowerPercentage = pAdapter->CommonCfg.TxPowerDefault;
3743 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_TX_POWER_LEVEL_1 (=%ld)\n", pAdapter->CommonCfg.TxPowerPercentage));
3746 case OID_802_11_NETWORK_TYPE_IN_USE:
3747 if (wrq->u.data.length != sizeof(NDIS_802_11_NETWORK_TYPE))
3751 Status = copy_from_user(&NetType, wrq->u.data.pointer, wrq->u.data.length);
3753 if (NetType == Ndis802_11DS)
3754 RTMPSetPhyMode(pAdapter, PHY_11B);
3755 else if (NetType == Ndis802_11OFDM24)
3756 RTMPSetPhyMode(pAdapter, PHY_11BG_MIXED);
3757 else if (NetType == Ndis802_11OFDM5)
3758 RTMPSetPhyMode(pAdapter, PHY_11A);
3761 #ifdef DOT11_N_SUPPORT
3762 if (Status == NDIS_STATUS_SUCCESS)
3763 SetCommonHT(pAdapter);
3764 #endif // DOT11_N_SUPPORT //
3765 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_NETWORK_TYPE_IN_USE (=%d)\n",NetType));
3768 // For WPA PSK PMK key
3769 case RT_OID_802_11_ADD_WPA:
3770 pKey = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
3777 Status = copy_from_user(pKey, wrq->u.data.pointer, wrq->u.data.length);
3778 if (pKey->Length != wrq->u.data.length)
3781 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_ADD_WPA, Failed!!\n"));
3785 if ((pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPAPSK) &&
3786 (pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPA2PSK) &&
3787 (pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPANone) )
3789 Status = -EOPNOTSUPP;
3790 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_ADD_WPA, Failed!! [AuthMode != WPAPSK/WPA2PSK/WPANONE]\n"));
3792 else if ((pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK) ||
3793 (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK) ||
3794 (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPANone) ) // Only for WPA PSK mode
3796 NdisMoveMemory(pAdapter->StaCfg.PMK, &pKey->KeyMaterial, pKey->KeyLength);
3797 // Use RaConfig as PSK agent.
3798 // Start STA supplicant state machine
3799 if (pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPANone)
3800 pAdapter->StaCfg.WpaState = SS_START;
3802 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_ADD_WPA (id=0x%x, Len=%d-byte)\n", pKey->KeyIndex, pKey->KeyLength));
3806 pAdapter->StaCfg.WpaState = SS_NOTUSE;
3807 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_ADD_WPA (id=0x%x, Len=%d-byte)\n", pKey->KeyIndex, pKey->KeyLength));
3812 case OID_802_11_REMOVE_KEY:
3813 pRemoveKey = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
3814 if(pRemoveKey == NULL)
3820 Status = copy_from_user(pRemoveKey, wrq->u.data.pointer, wrq->u.data.length);
3821 if (pRemoveKey->Length != wrq->u.data.length)
3824 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_KEY, Failed!!\n"));
3828 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
3830 RTMPWPARemoveKeyProc(pAdapter, pRemoveKey);
3831 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_KEY, Remove WPA Key!!\n"));
3835 KeyIdx = pRemoveKey->KeyIndex;
3837 if (KeyIdx & 0x80000000)
3839 // Should never set default bit when remove key
3841 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_KEY, Failed!!(Should never set default bit when remove key)\n"));
3845 KeyIdx = KeyIdx & 0x0fffffff;
3849 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_KEY, Failed!!(KeyId[%d] out of range)\n", KeyIdx));
3853 pAdapter->SharedKey[BSS0][KeyIdx].KeyLen = 0;
3854 pAdapter->SharedKey[BSS0][KeyIdx].CipherAlg = CIPHER_NONE;
3855 AsicRemoveSharedKeyEntry(pAdapter, 0, (UCHAR)KeyIdx);
3856 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_KEY (id=0x%x, Len=%d-byte)\n", pRemoveKey->KeyIndex, pRemoveKey->Length));
3864 case OID_802_11_ADD_KEY:
3865 pKey = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
3871 Status = copy_from_user(pKey, wrq->u.data.pointer, wrq->u.data.length);
3872 if (pKey->Length != wrq->u.data.length)
3875 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_KEY, Failed!!\n"));
3879 RTMPAddKey(pAdapter, pKey);
3880 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_KEY (id=0x%x, Len=%d-byte)\n", pKey->KeyIndex, pKey->KeyLength));
3884 case OID_802_11_CONFIGURATION:
3885 if (wrq->u.data.length != sizeof(NDIS_802_11_CONFIGURATION))
3889 Status = copy_from_user(&Config, wrq->u.data.pointer, wrq->u.data.length);
3892 if ((pConfig->BeaconPeriod >= 20) && (pConfig->BeaconPeriod <=400))
3893 pAdapter->CommonCfg.BeaconPeriod = (USHORT) pConfig->BeaconPeriod;
3895 pAdapter->StaActive.AtimWin = (USHORT) pConfig->ATIMWindow;
3896 MAP_KHZ_TO_CHANNEL_ID(pConfig->DSConfig, pAdapter->CommonCfg.Channel);
3898 // Save the channel on MlmeAux for CntlOidRTBssidProc used.
3900 pAdapter->MlmeAux.Channel = pAdapter->CommonCfg.Channel;
3902 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_CONFIGURATION (BeacnPeriod=%ld,AtimW=%ld,Ch=%d)\n",
3903 pConfig->BeaconPeriod, pConfig->ATIMWindow, pAdapter->CommonCfg.Channel));
3904 // Config has changed
3905 pAdapter->bConfigChanged = TRUE;
3908 #ifdef DOT11_N_SUPPORT
3909 case RT_OID_802_11_SET_HT_PHYMODE:
3910 if (wrq->u.data.length != sizeof(OID_SET_HT_PHYMODE))
3914 POID_SET_HT_PHYMODE pHTPhyMode = &HT_PhyMode;
3916 Status = copy_from_user(&HT_PhyMode, wrq->u.data.pointer, wrq->u.data.length);
3917 DBGPRINT(RT_DEBUG_TRACE, ("Set::pHTPhyMode (PhyMode = %d,TransmitNo = %d, HtMode = %d, ExtOffset = %d , MCS = %d, BW = %d, STBC = %d, SHORTGI = %d) \n",
3918 pHTPhyMode->PhyMode, pHTPhyMode->TransmitNo,pHTPhyMode->HtMode,pHTPhyMode->ExtOffset,
3919 pHTPhyMode->MCS, pHTPhyMode->BW, pHTPhyMode->STBC, pHTPhyMode->SHORTGI));
3920 if (pAdapter->CommonCfg.PhyMode >= PHY_11ABGN_MIXED)
3921 RTMPSetHT(pAdapter, pHTPhyMode);
3923 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_SET_HT_PHYMODE(MCS=%d,BW=%d,SGI=%d,STBC=%d)\n",
3924 pAdapter->StaCfg.HTPhyMode.field.MCS, pAdapter->StaCfg.HTPhyMode.field.BW, pAdapter->StaCfg.HTPhyMode.field.ShortGI,
3925 pAdapter->StaCfg.HTPhyMode.field.STBC));
3927 #endif // DOT11_N_SUPPORT //
3928 case RT_OID_802_11_SET_APSD_SETTING:
3929 if (wrq->u.data.length != sizeof(ULONG))
3934 Status = copy_from_user(&apsd, wrq->u.data.pointer, wrq->u.data.length);
3936 /*-------------------------------------------------------------------
3937 |B31~B7 | B6~B5 | B4 | B3 | B2 | B1 | B0 |
3938 ---------------------------------------------------------------------
3939 | Rsvd | Max SP Len | AC_VO | AC_VI | AC_BK | AC_BE | APSD Capable |
3940 ---------------------------------------------------------------------*/
3941 pAdapter->CommonCfg.bAPSDCapable = (apsd & 0x00000001) ? TRUE : FALSE;
3942 pAdapter->CommonCfg.bAPSDAC_BE = ((apsd & 0x00000002) >> 1) ? TRUE : FALSE;
3943 pAdapter->CommonCfg.bAPSDAC_BK = ((apsd & 0x00000004) >> 2) ? TRUE : FALSE;
3944 pAdapter->CommonCfg.bAPSDAC_VI = ((apsd & 0x00000008) >> 3) ? TRUE : FALSE;
3945 pAdapter->CommonCfg.bAPSDAC_VO = ((apsd & 0x00000010) >> 4) ? TRUE : FALSE;
3946 pAdapter->CommonCfg.MaxSPLength = (UCHAR)((apsd & 0x00000060) >> 5);
3948 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,
3949 pAdapter->CommonCfg.bAPSDAC_BE, pAdapter->CommonCfg.bAPSDAC_BK, pAdapter->CommonCfg.bAPSDAC_VI, pAdapter->CommonCfg.bAPSDAC_VO, pAdapter->CommonCfg.MaxSPLength));
3953 case RT_OID_802_11_SET_APSD_PSM:
3954 if (wrq->u.data.length != sizeof(ULONG))
3958 // Driver needs to notify AP when PSM changes
3959 Status = copy_from_user(&pAdapter->CommonCfg.bAPSDForcePowerSave, wrq->u.data.pointer, wrq->u.data.length);
3960 if (pAdapter->CommonCfg.bAPSDForcePowerSave != pAdapter->StaCfg.Psm)
3962 MlmeSetPsmBit(pAdapter, pAdapter->CommonCfg.bAPSDForcePowerSave);
3963 RTMPSendNullFrame(pAdapter, pAdapter->CommonCfg.TxRate, TRUE);
3965 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_SET_APSD_PSM (bAPSDForcePowerSave:%d)\n", pAdapter->CommonCfg.bAPSDForcePowerSave));
3968 #ifdef QOS_DLS_SUPPORT
3969 case RT_OID_802_11_SET_DLS:
3970 if (wrq->u.data.length != sizeof(ULONG))
3974 BOOLEAN oldvalue = pAdapter->CommonCfg.bDLSCapable;
3975 Status = copy_from_user(&pAdapter->CommonCfg.bDLSCapable, wrq->u.data.pointer, wrq->u.data.length);
3976 if (oldvalue && !pAdapter->CommonCfg.bDLSCapable)
3979 // tear down local dls table entry
3980 for (i=0; i<MAX_NUM_OF_INIT_DLS_ENTRY; i++)
3982 if (pAdapter->StaCfg.DLSEntry[i].Valid && (pAdapter->StaCfg.DLSEntry[i].Status == DLS_FINISH))
3984 pAdapter->StaCfg.DLSEntry[i].Status = DLS_NONE;
3985 pAdapter->StaCfg.DLSEntry[i].Valid = FALSE;
3986 RTMPSendDLSTearDownFrame(pAdapter, pAdapter->StaCfg.DLSEntry[i].MacAddr);
3990 // tear down peer dls table entry
3991 for (i=MAX_NUM_OF_INIT_DLS_ENTRY; i<MAX_NUM_OF_DLS_ENTRY; i++)
3993 if (pAdapter->StaCfg.DLSEntry[i].Valid && (pAdapter->StaCfg.DLSEntry[i].Status == DLS_FINISH))
3995 pAdapter->StaCfg.DLSEntry[i].Status = DLS_NONE;
3996 pAdapter->StaCfg.DLSEntry[i].Valid = FALSE;
3997 RTMPSendDLSTearDownFrame(pAdapter, pAdapter->StaCfg.DLSEntry[i].MacAddr);
4002 DBGPRINT(RT_DEBUG_TRACE,("Set::RT_OID_802_11_SET_DLS (=%d)\n", pAdapter->CommonCfg.bDLSCapable));
4006 case RT_OID_802_11_SET_DLS_PARAM:
4007 if (wrq->u.data.length != sizeof(RT_802_11_DLS_UI))
4013 NdisZeroMemory(&Dls, sizeof(RT_802_11_DLS));
4014 RTMPMoveMemory(&Dls, wrq->u.data.pointer, sizeof(RT_802_11_DLS_UI));
4015 MlmeEnqueue(pAdapter,
4016 MLME_CNTL_STATE_MACHINE,
4017 RT_OID_802_11_SET_DLS_PARAM,
4018 sizeof(RT_802_11_DLS),
4020 DBGPRINT(RT_DEBUG_TRACE,("Set::RT_OID_802_11_SET_DLS_PARAM \n"));
4023 #endif // QOS_DLS_SUPPORT //
4024 case RT_OID_802_11_SET_WMM:
4025 if (wrq->u.data.length != sizeof(BOOLEAN))
4029 Status = copy_from_user(&pAdapter->CommonCfg.bWmmCapable, wrq->u.data.pointer, wrq->u.data.length);
4030 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_SET_WMM (=%d) \n", pAdapter->CommonCfg.bWmmCapable));
4034 case OID_802_11_DISASSOCIATE:
4036 if (ATE_ON(pAdapter))
4038 DBGPRINT(RT_DEBUG_TRACE, ("The driver is in ATE mode now\n"));
4041 #endif // RALINK_ATE //
4043 // Set NdisRadioStateOff to TRUE, instead of called MlmeRadioOff.
4044 // Later on, NDIS_802_11_BSSID_LIST_EX->NumberOfItems should be 0
4045 // when query OID_802_11_BSSID_LIST.
4047 // TRUE: NumberOfItems will set to 0.
4048 // FALSE: NumberOfItems no change.
4050 pAdapter->CommonCfg.NdisRadioStateOff = TRUE;
4051 // Set to immediately send the media disconnect event
4052 pAdapter->MlmeAux.CurrReqIsFromNdis = TRUE;
4053 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_DISASSOCIATE \n"));
4055 if (INFRA_ON(pAdapter))
4057 if (pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE)
4059 RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
4060 DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
4063 MlmeEnqueue(pAdapter,
4064 MLME_CNTL_STATE_MACHINE,
4065 OID_802_11_DISASSOCIATE,
4069 StateMachineTouched = TRUE;
4073 #ifdef DOT11_N_SUPPORT
4074 case RT_OID_802_11_SET_IMME_BA_CAP:
4075 if (wrq->u.data.length != sizeof(OID_BACAP_STRUC))
4079 OID_BACAP_STRUC Orde ;
4080 Status = copy_from_user(&Orde, wrq->u.data.pointer, wrq->u.data.length);
4081 if (Orde.Policy > BA_NOTUSE)
4083 Status = NDIS_STATUS_INVALID_DATA;
4085 else if (Orde.Policy == BA_NOTUSE)
4087 pAdapter->CommonCfg.BACapability.field.Policy = BA_NOTUSE;
4088 pAdapter->CommonCfg.BACapability.field.MpduDensity = Orde.MpduDensity;
4089 pAdapter->CommonCfg.DesiredHtPhy.MpduDensity = Orde.MpduDensity;
4090 pAdapter->CommonCfg.DesiredHtPhy.AmsduEnable = Orde.AmsduEnable;
4091 pAdapter->CommonCfg.DesiredHtPhy.AmsduSize= Orde.AmsduSize;
4092 pAdapter->CommonCfg.DesiredHtPhy.MimoPs= Orde.MMPSmode;
4093 pAdapter->CommonCfg.BACapability.field.MMPSmode = Orde.MMPSmode;
4095 pAdapter->CommonCfg.HtCapability.HtCapInfo.MimoPs = Orde.MMPSmode;
4096 pAdapter->CommonCfg.HtCapability.HtCapInfo.AMsduSize = Orde.AmsduSize;
4097 pAdapter->CommonCfg.HtCapability.HtCapParm.MpduDensity = Orde.MpduDensity;
4101 pAdapter->CommonCfg.BACapability.field.AutoBA = Orde.AutoBA;
4102 pAdapter->CommonCfg.BACapability.field.Policy = IMMED_BA; // we only support immediate BA.
4103 pAdapter->CommonCfg.BACapability.field.MpduDensity = Orde.MpduDensity;
4104 pAdapter->CommonCfg.DesiredHtPhy.MpduDensity = Orde.MpduDensity;
4105 pAdapter->CommonCfg.DesiredHtPhy.AmsduEnable = Orde.AmsduEnable;
4106 pAdapter->CommonCfg.DesiredHtPhy.AmsduSize= Orde.AmsduSize;
4107 pAdapter->CommonCfg.DesiredHtPhy.MimoPs = Orde.MMPSmode;
4108 pAdapter->CommonCfg.BACapability.field.MMPSmode = Orde.MMPSmode;
4111 pAdapter->CommonCfg.HtCapability.HtCapInfo.MimoPs = Orde.MMPSmode;
4112 pAdapter->CommonCfg.HtCapability.HtCapInfo.AMsduSize = Orde.AmsduSize;
4113 pAdapter->CommonCfg.HtCapability.HtCapParm.MpduDensity = Orde.MpduDensity;
4115 if (pAdapter->CommonCfg.BACapability.field.RxBAWinLimit > MAX_RX_REORDERBUF)
4116 pAdapter->CommonCfg.BACapability.field.RxBAWinLimit = MAX_RX_REORDERBUF;
4120 pAdapter->CommonCfg.REGBACapability.word = pAdapter->CommonCfg.BACapability.word;
4121 DBGPRINT(RT_DEBUG_TRACE, ("Set::(Orde.AutoBA = %d) (Policy=%d)(ReBAWinLimit=%d)(TxBAWinLimit=%d)(AutoMode=%d)\n",Orde.AutoBA, pAdapter->CommonCfg.BACapability.field.Policy,
4122 pAdapter->CommonCfg.BACapability.field.RxBAWinLimit,pAdapter->CommonCfg.BACapability.field.TxBAWinLimit, pAdapter->CommonCfg.BACapability.field.AutoBA));
4123 DBGPRINT(RT_DEBUG_TRACE, ("Set::(MimoPs = %d)(AmsduEnable = %d) (AmsduSize=%d)(MpduDensity=%d)\n",pAdapter->CommonCfg.DesiredHtPhy.MimoPs, pAdapter->CommonCfg.DesiredHtPhy.AmsduEnable,
4124 pAdapter->CommonCfg.DesiredHtPhy.AmsduSize, pAdapter->CommonCfg.DesiredHtPhy.MpduDensity));
4128 case RT_OID_802_11_ADD_IMME_BA:
4129 DBGPRINT(RT_DEBUG_TRACE, (" Set :: RT_OID_802_11_ADD_IMME_BA \n"));
4130 if (wrq->u.data.length != sizeof(OID_ADD_BA_ENTRY))
4135 OID_ADD_BA_ENTRY BA;
4136 MAC_TABLE_ENTRY *pEntry;
4138 Status = copy_from_user(&BA, wrq->u.data.pointer, wrq->u.data.length);
4141 Status = NDIS_STATUS_INVALID_DATA;
4146 //BATableInsertEntry
4147 //As ad-hoc mode, BA pair is not limited to only BSSID. so add via OID.
4149 // in ad hoc mode, when adding BA pair, we should insert this entry into MACEntry too
4150 pEntry = MacTableLookup(pAdapter, BA.MACAddr);
4153 DBGPRINT(RT_DEBUG_TRACE, ("RT_OID_802_11_ADD_IMME_BA. break on no connection.----:%x:%x\n", BA.MACAddr[4], BA.MACAddr[5]));
4156 if (BA.IsRecipient == FALSE)
4158 if (pEntry->bIAmBadAtheros == TRUE)
4159 pAdapter->CommonCfg.BACapability.field.RxBAWinLimit = 0x10;
4161 BAOriSessionSetUp(pAdapter, pEntry, index, 0, 100, TRUE);
4165 //BATableInsertEntry(pAdapter, pEntry->Aid, BA.MACAddr, 0, 0xffff, BA.TID, BA.nMSDU, BA.IsRecipient);
4168 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_ADD_IMME_BA. Rec = %d. Mac = %x:%x:%x:%x:%x:%x . \n",
4169 BA.IsRecipient, BA.MACAddr[0], BA.MACAddr[1], BA.MACAddr[2], BA.MACAddr[2]
4170 , BA.MACAddr[4], BA.MACAddr[5]));
4175 case RT_OID_802_11_TEAR_IMME_BA:
4176 DBGPRINT(RT_DEBUG_TRACE, ("Set :: RT_OID_802_11_TEAR_IMME_BA \n"));
4177 if (wrq->u.data.length != sizeof(OID_ADD_BA_ENTRY))
4181 POID_ADD_BA_ENTRY pBA;
4182 MAC_TABLE_ENTRY *pEntry;
4184 pBA = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
4188 DBGPRINT(RT_DEBUG_TRACE, ("Set :: RT_OID_802_11_TEAR_IMME_BA kmalloc() can't allocate enough memory\n"));
4189 Status = NDIS_STATUS_FAILURE;
4193 Status = copy_from_user(pBA, wrq->u.data.pointer, wrq->u.data.length);
4194 DBGPRINT(RT_DEBUG_TRACE, ("Set :: RT_OID_802_11_TEAR_IMME_BA(TID=%d, bAllTid=%d)\n", pBA->TID, pBA->bAllTid));
4196 if (!pBA->bAllTid && (pBA->TID > NUM_OF_TID))
4198 Status = NDIS_STATUS_INVALID_DATA;
4202 if (pBA->IsRecipient == FALSE)
4204 pEntry = MacTableLookup(pAdapter, pBA->MACAddr);
4205 DBGPRINT(RT_DEBUG_TRACE, (" pBA->IsRecipient == FALSE\n"));
4208 DBGPRINT(RT_DEBUG_TRACE, (" pBA->pEntry\n"));
4209 BAOriSessionTearDown(pAdapter, pEntry->Aid, pBA->TID, FALSE, TRUE);
4212 DBGPRINT(RT_DEBUG_TRACE, ("Set :: Not found pEntry \n"));
4216 pEntry = MacTableLookup(pAdapter, pBA->MACAddr);
4219 BARecSessionTearDown( pAdapter, (UCHAR)pEntry->Aid, pBA->TID, TRUE);
4222 DBGPRINT(RT_DEBUG_TRACE, ("Set :: Not found pEntry \n"));
4228 #endif // DOT11_N_SUPPORT //
4230 // For WPA_SUPPLICANT to set static wep key
4231 case OID_802_11_ADD_WEP:
4232 pWepKey = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
4237 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_WEP, Failed!!\n"));
4240 Status = copy_from_user(pWepKey, wrq->u.data.pointer, wrq->u.data.length);
4244 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_WEP, Failed (length mismatch)!!\n"));
4248 KeyIdx = pWepKey->KeyIndex & 0x0fffffff;
4249 // KeyIdx must be 0 ~ 3
4253 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_WEP, Failed (KeyIdx must be smaller than 4)!!\n"));
4257 UCHAR CipherAlg = 0;
4260 // set key material and key length
4261 NdisZeroMemory(pAdapter->SharedKey[BSS0][KeyIdx].Key, 16);
4262 pAdapter->SharedKey[BSS0][KeyIdx].KeyLen = (UCHAR) pWepKey->KeyLength;
4263 NdisMoveMemory(pAdapter->SharedKey[BSS0][KeyIdx].Key, &pWepKey->KeyMaterial, pWepKey->KeyLength);
4265 switch(pWepKey->KeyLength)
4268 CipherAlg = CIPHER_WEP64;
4271 CipherAlg = CIPHER_WEP128;
4274 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_WEP, only support CIPHER_WEP64(len:5) & CIPHER_WEP128(len:13)!!\n"));
4278 pAdapter->SharedKey[BSS0][KeyIdx].CipherAlg = CipherAlg;
4280 // Default key for tx (shared key)
4281 if (pWepKey->KeyIndex & 0x80000000)
4283 #ifdef WPA_SUPPLICANT_SUPPORT
4284 // set key material and key length
4285 NdisZeroMemory(pAdapter->StaCfg.DesireSharedKey[KeyIdx].Key, 16);
4286 pAdapter->StaCfg.DesireSharedKey[KeyIdx].KeyLen = (UCHAR) pWepKey->KeyLength;
4287 NdisMoveMemory(pAdapter->StaCfg.DesireSharedKey[KeyIdx].Key, &pWepKey->KeyMaterial, pWepKey->KeyLength);
4288 pAdapter->StaCfg.DesireSharedKeyId = KeyIdx;
4289 pAdapter->StaCfg.DesireSharedKey[KeyIdx].CipherAlg = CipherAlg;
4290 #endif // WPA_SUPPLICANT_SUPPORT //
4291 pAdapter->StaCfg.DefaultKeyId = (UCHAR) KeyIdx;
4294 #ifdef WPA_SUPPLICANT_SUPPORT
4295 if ((pAdapter->StaCfg.WpaSupplicantUP != 0) &&
4296 (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA))
4298 Key = pWepKey->KeyMaterial;
4300 // Set Group key material to Asic
4301 AsicAddSharedKeyEntry(pAdapter, BSS0, KeyIdx, CipherAlg, Key, NULL, NULL);
4303 // Update WCID attribute table and IVEIV table for this group key table
4304 RTMPAddWcidAttributeEntry(pAdapter, BSS0, KeyIdx, CipherAlg, NULL);
4306 STA_PORT_SECURED(pAdapter);
4308 // Indicate Connected for GUI
4309 pAdapter->IndicateMediaState = NdisMediaStateConnected;
4311 else if (pAdapter->StaCfg.PortSecured == WPA_802_1X_PORT_SECURED)
4312 #endif // WPA_SUPPLICANT_SUPPORT
4314 Key = pAdapter->SharedKey[BSS0][KeyIdx].Key;
4316 // Set key material and cipherAlg to Asic
4317 AsicAddSharedKeyEntry(pAdapter, BSS0, KeyIdx, CipherAlg, Key, NULL, NULL);
4319 if (pWepKey->KeyIndex & 0x80000000)
4321 PMAC_TABLE_ENTRY pEntry = &pAdapter->MacTab.Content[BSSID_WCID];
4322 // Assign group key info
4323 RTMPAddWcidAttributeEntry(pAdapter, BSS0, KeyIdx, CipherAlg, NULL);
4324 // Assign pairwise key info
4325 RTMPAddWcidAttributeEntry(pAdapter, BSS0, KeyIdx, CipherAlg, pEntry);
4328 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"));
4333 #ifdef WPA_SUPPLICANT_SUPPORT
4334 case OID_SET_COUNTERMEASURES:
4335 if (wrq->u.data.length != sizeof(int))
4340 Status = copy_from_user(&enabled, wrq->u.data.pointer, wrq->u.data.length);
4342 pAdapter->StaCfg.bBlockAssoc = TRUE;
4344 // WPA MIC error should block association attempt for 60 seconds
4345 pAdapter->StaCfg.bBlockAssoc = FALSE;
4346 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_SET_COUNTERMEASURES bBlockAssoc=%s\n", pAdapter->StaCfg.bBlockAssoc ? "TRUE":"FALSE"));
4349 case RT_OID_WPA_SUPPLICANT_SUPPORT:
4350 if (wrq->u.data.length != sizeof(UCHAR))
4354 Status = copy_from_user(&wpa_supplicant_enable, wrq->u.data.pointer, wrq->u.data.length);
4355 pAdapter->StaCfg.WpaSupplicantUP = wpa_supplicant_enable;
4356 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_WPA_SUPPLICANT_SUPPORT (=%d)\n", pAdapter->StaCfg.WpaSupplicantUP));
4359 case OID_802_11_DEAUTHENTICATION:
4360 if (wrq->u.data.length != sizeof(MLME_DEAUTH_REQ_STRUCT))
4364 MLME_DEAUTH_REQ_STRUCT *pInfo;
4365 MLME_QUEUE_ELEM *MsgElem = (MLME_QUEUE_ELEM *) kmalloc(sizeof(MLME_QUEUE_ELEM), MEM_ALLOC_FLAG);
4367 pInfo = (MLME_DEAUTH_REQ_STRUCT *) MsgElem->Msg;
4368 Status = copy_from_user(pInfo, wrq->u.data.pointer, wrq->u.data.length);
4369 MlmeDeauthReqAction(pAdapter, MsgElem);
4372 if (INFRA_ON(pAdapter))
4374 LinkDown(pAdapter, FALSE);
4375 pAdapter->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
4377 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_DEAUTHENTICATION (Reason=%d)\n", pInfo->Reason));
4380 case OID_802_11_DROP_UNENCRYPTED:
4381 if (wrq->u.data.length != sizeof(int))
4386 Status = copy_from_user(&enabled, wrq->u.data.pointer, wrq->u.data.length);
4388 pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED;
4390 pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
4391 NdisAcquireSpinLock(&pAdapter->MacTabLock);
4392 pAdapter->MacTab.Content[BSSID_WCID].PortSecured = pAdapter->StaCfg.PortSecured;
4393 NdisReleaseSpinLock(&pAdapter->MacTabLock);
4394 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_DROP_UNENCRYPTED (=%d)\n", enabled));
4397 case OID_802_11_SET_IEEE8021X:
4398 if (wrq->u.data.length != sizeof(BOOLEAN))
4402 Status = copy_from_user(&IEEE8021xState, wrq->u.data.pointer, wrq->u.data.length);
4403 pAdapter->StaCfg.IEEE8021X = IEEE8021xState;
4404 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_SET_IEEE8021X (=%d)\n", IEEE8021xState));
4407 case OID_802_11_SET_IEEE8021X_REQUIRE_KEY:
4408 if (wrq->u.data.length != sizeof(BOOLEAN))
4412 Status = copy_from_user(&IEEE8021x_required_keys, wrq->u.data.pointer, wrq->u.data.length);
4413 pAdapter->StaCfg.IEEE8021x_required_keys = IEEE8021x_required_keys;
4414 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_SET_IEEE8021X_REQUIRE_KEY (%d)\n", IEEE8021x_required_keys));
4417 case OID_802_11_PMKID:
4418 pPmkId = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
4420 if(pPmkId == NULL) {
4424 Status = copy_from_user(pPmkId, wrq->u.data.pointer, wrq->u.data.length);
4426 // check the PMKID information
4427 if (pPmkId->BSSIDInfoCount == 0)
4428 NdisZeroMemory(pAdapter->StaCfg.SavedPMK, sizeof(BSSID_INFO)*PMKID_NO);
4431 PBSSID_INFO pBssIdInfo;
4435 for (BssIdx = 0; BssIdx < pPmkId->BSSIDInfoCount; BssIdx++)
4437 // point to the indexed BSSID_INFO structure
4438 pBssIdInfo = (PBSSID_INFO) ((PUCHAR) pPmkId + 2 * sizeof(UINT) + BssIdx * sizeof(BSSID_INFO));
4439 // Find the entry in the saved data base.
4440 for (CachedIdx = 0; CachedIdx < pAdapter->StaCfg.SavedPMKNum; CachedIdx++)
4442 // compare the BSSID
4443 if (NdisEqualMemory(pBssIdInfo->BSSID, pAdapter->StaCfg.SavedPMK[CachedIdx].BSSID, sizeof(NDIS_802_11_MAC_ADDRESS)))
4447 // Found, replace it
4448 if (CachedIdx < PMKID_NO)
4450 DBGPRINT(RT_DEBUG_OFF, ("Update OID_802_11_PMKID, idx = %d\n", CachedIdx));
4451 NdisMoveMemory(&pAdapter->StaCfg.SavedPMK[CachedIdx], pBssIdInfo, sizeof(BSSID_INFO));
4452 pAdapter->StaCfg.SavedPMKNum++;
4454 // Not found, replace the last one
4457 // Randomly replace one
4458 CachedIdx = (pBssIdInfo->BSSID[5] % PMKID_NO);
4459 DBGPRINT(RT_DEBUG_OFF, ("Update OID_802_11_PMKID, idx = %d\n", CachedIdx));
4460 NdisMoveMemory(&pAdapter->StaCfg.SavedPMK[CachedIdx], pBssIdInfo, sizeof(BSSID_INFO));
4467 #endif // WPA_SUPPLICANT_SUPPORT //
4472 case OID_802_11_SHORTRETRYLIMIT:
4473 if (wrq->u.data.length != sizeof(ULONG))
4477 Status = copy_from_user(&ShortRetryLimit, wrq->u.data.pointer, wrq->u.data.length);
4478 RTMP_IO_READ32(pAdapter, TX_RTY_CFG, &tx_rty_cfg.word);
4479 tx_rty_cfg.field.ShortRtyLimit = ShortRetryLimit;
4480 RTMP_IO_WRITE32(pAdapter, TX_RTY_CFG, tx_rty_cfg.word);
4481 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_SHORTRETRYLIMIT (tx_rty_cfg.field.ShortRetryLimit=%d, ShortRetryLimit=%ld)\n", tx_rty_cfg.field.ShortRtyLimit, ShortRetryLimit));
4485 case OID_802_11_LONGRETRYLIMIT:
4486 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_LONGRETRYLIMIT \n"));
4487 if (wrq->u.data.length != sizeof(ULONG))
4491 Status = copy_from_user(&LongRetryLimit, wrq->u.data.pointer, wrq->u.data.length);
4492 RTMP_IO_READ32(pAdapter, TX_RTY_CFG, &tx_rty_cfg.word);
4493 tx_rty_cfg.field.LongRtyLimit = LongRetryLimit;
4494 RTMP_IO_WRITE32(pAdapter, TX_RTY_CFG, tx_rty_cfg.word);
4495 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_LONGRETRYLIMIT (tx_rty_cfg.field.LongRetryLimit= %d,LongRetryLimit=%ld)\n", tx_rty_cfg.field.LongRtyLimit, LongRetryLimit));
4499 case OID_802_11_WEPDEFAULTKEYVALUE:
4500 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_WEPDEFAULTKEYVALUE\n"));
4501 pKey = kmalloc(wrq->u.data.length, GFP_KERNEL);
4502 Status = copy_from_user(pKey, wrq->u.data.pointer, wrq->u.data.length);
4505 if ( pKey->Length != wrq->u.data.length)
4508 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_WEPDEFAULTKEYVALUE, Failed!!\n"));
4510 KeyIdx = pKey->KeyIndex & 0x0fffffff;
4511 DBGPRINT(RT_DEBUG_TRACE,("pKey->KeyIndex =%d, pKey->KeyLength=%d\n", pKey->KeyIndex, pKey->KeyLength));
4513 // it is a shared key
4518 pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].KeyLen = (UCHAR) pKey->KeyLength;
4519 NdisMoveMemory(&pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].Key, &pKey->KeyMaterial, pKey->KeyLength);
4520 if (pKey->KeyIndex & 0x80000000)
4522 // Default key for tx (shared key)
4523 pAdapter->StaCfg.DefaultKeyId = (UCHAR) KeyIdx;
4525 //RestartAPIsRequired = TRUE;
4530 case OID_802_11_WEPDEFAULTKEYID:
4531 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_WEPDEFAULTKEYID \n"));
4533 if (wrq->u.data.length != sizeof(UCHAR))
4536 Status = copy_from_user(&pAdapter->StaCfg.DefaultKeyId, wrq->u.data.pointer, wrq->u.data.length);
4541 case OID_802_11_CURRENTCHANNEL:
4542 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_CURRENTCHANNEL \n"));
4543 if (wrq->u.data.length != sizeof(UCHAR))
4547 Status = copy_from_user(&ctmp, wrq->u.data.pointer, wrq->u.data.length);
4548 sprintf(&ctmp,"%d", ctmp);
4549 Set_Channel_Proc(pAdapter, &ctmp);
4557 DBGPRINT(RT_DEBUG_TRACE, ("Set::unknown IOCTL's subcmd = 0x%08x\n", cmd));
4558 Status = -EOPNOTSUPP;
4566 INT RTMPQueryInformation(
4567 IN PRTMP_ADAPTER pAdapter,
4568 IN OUT struct ifreq *rq,
4571 struct iwreq *wrq = (struct iwreq *) rq;
4572 NDIS_802_11_BSSID_LIST_EX *pBssidList = NULL;
4573 PNDIS_WLAN_BSSID_EX pBss;
4574 NDIS_802_11_SSID Ssid;
4575 NDIS_802_11_CONFIGURATION *pConfiguration = NULL;
4576 RT_802_11_LINK_STATUS *pLinkStatus = NULL;
4577 RT_802_11_STA_CONFIG *pStaConfig = NULL;
4578 NDIS_802_11_STATISTICS *pStatistics = NULL;
4579 NDIS_802_11_RTS_THRESHOLD RtsThresh;
4580 NDIS_802_11_FRAGMENTATION_THRESHOLD FragThresh;
4581 NDIS_802_11_POWER_MODE PowerMode;
4582 NDIS_802_11_NETWORK_INFRASTRUCTURE BssType;
4583 RT_802_11_PREAMBLE PreamType;
4584 NDIS_802_11_AUTHENTICATION_MODE AuthMode;
4585 NDIS_802_11_WEP_STATUS WepStatus;
4586 NDIS_MEDIA_STATE MediaState;
4587 ULONG BssBufSize, ulInfo=0, NetworkTypeList[4], apsd = 0;
4589 PUCHAR pBuf = NULL, pPtr;
4590 INT Status = NDIS_STATUS_SUCCESS;
4591 UINT we_version_compiled;
4592 UCHAR i, Padding = 0;
4594 UCHAR driverVersion[8];
4595 OID_SET_HT_PHYMODE *pHTPhyMode = NULL;
4600 DefaultKeyIdxValue *pKeyIdxValue;
4602 TX_RTY_CFG_STRUC tx_rty_cfg;
4603 ULONG ShortRetryLimit, LongRetryLimit;
4609 case RT_OID_DEVICE_NAME:
4610 wrq->u.data.length = sizeof(STA_NIC_DEVICE_NAME);
4611 Status = copy_to_user(wrq->u.data.pointer, STA_NIC_DEVICE_NAME, wrq->u.data.length);
4613 case RT_OID_VERSION_INFO:
4614 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_VERSION_INFO \n"));
4615 wrq->u.data.length = 8*sizeof(UCHAR);
4616 sprintf(&driverVersion[0], "%s", STA_DRIVER_VERSION);
4617 driverVersion[7] = '\0';
4618 if (copy_to_user(wrq->u.data.pointer, &driverVersion, wrq->u.data.length))
4624 case RT_QUERY_ATE_TXDONE_COUNT:
4625 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_QUERY_ATE_TXDONE_COUNT \n"));
4626 wrq->u.data.length = sizeof(UINT32);
4627 if (copy_to_user(wrq->u.data.pointer, &pAdapter->ate.TxDoneCount, wrq->u.data.length))
4632 #endif // RALINK_ATE //
4633 case OID_802_11_BSSID_LIST:
4634 if (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
4637 * Still scanning, indicate the caller should try again.
4639 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_BSSID_LIST (Still scanning)\n"));
4642 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_BSSID_LIST (%d BSS returned)\n",pAdapter->ScanTab.BssNr));
4643 pAdapter->StaCfg.bScanReqIsFromWebUI = FALSE;
4644 // Claculate total buffer size required
4645 BssBufSize = sizeof(ULONG);
4647 for (i = 0; i < pAdapter->ScanTab.BssNr; i++)
4649 // Align pointer to 4 bytes boundary.
4650 //Padding = 4 - (pAdapter->ScanTab.BssEntry[i].VarIELen & 0x0003);
4653 BssBufSize += (sizeof(NDIS_WLAN_BSSID_EX) - 1 + sizeof(NDIS_802_11_FIXED_IEs) + pAdapter->ScanTab.BssEntry[i].VarIELen + Padding);
4656 // For safety issue, we add 256 bytes just in case
4658 // Allocate the same size as passed from higher layer
4659 pBuf = kmalloc(BssBufSize, MEM_ALLOC_FLAG);
4665 // Init 802_11_BSSID_LIST_EX structure
4666 NdisZeroMemory(pBuf, BssBufSize);
4667 pBssidList = (PNDIS_802_11_BSSID_LIST_EX) pBuf;
4668 pBssidList->NumberOfItems = pAdapter->ScanTab.BssNr;
4670 // Calculate total buffer length
4671 BssLen = 4; // Consist of NumberOfItems
4672 // Point to start of NDIS_WLAN_BSSID_EX
4673 // pPtr = pBuf + sizeof(ULONG);
4674 pPtr = (PUCHAR) &pBssidList->Bssid[0];
4675 for (i = 0; i < pAdapter->ScanTab.BssNr; i++)
4677 pBss = (PNDIS_WLAN_BSSID_EX) pPtr;
4678 NdisMoveMemory(&pBss->MacAddress, &pAdapter->ScanTab.BssEntry[i].Bssid, MAC_ADDR_LEN);
4679 if ((pAdapter->ScanTab.BssEntry[i].Hidden == 1) && (pAdapter->StaCfg.bShowHiddenSSID == FALSE))
4682 // We must return this SSID during 4way handshaking, otherwise Aegis will failed to parse WPA infomation
4683 // and then failed to send EAPOl farame.
4685 if ((pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA) && (pAdapter->StaCfg.PortSecured != WPA_802_1X_PORT_SECURED))
4687 pBss->Ssid.SsidLength = pAdapter->ScanTab.BssEntry[i].SsidLen;
4688 NdisMoveMemory(pBss->Ssid.Ssid, pAdapter->ScanTab.BssEntry[i].Ssid, pAdapter->ScanTab.BssEntry[i].SsidLen);
4691 pBss->Ssid.SsidLength = 0;
4695 pBss->Ssid.SsidLength = pAdapter->ScanTab.BssEntry[i].SsidLen;
4696 NdisMoveMemory(pBss->Ssid.Ssid, pAdapter->ScanTab.BssEntry[i].Ssid, pAdapter->ScanTab.BssEntry[i].SsidLen);
4698 pBss->Privacy = pAdapter->ScanTab.BssEntry[i].Privacy;
4699 pBss->Rssi = pAdapter->ScanTab.BssEntry[i].Rssi - pAdapter->BbpRssiToDbmDelta;
4700 pBss->NetworkTypeInUse = NetworkTypeInUseSanity(&pAdapter->ScanTab.BssEntry[i]);
4701 pBss->Configuration.Length = sizeof(NDIS_802_11_CONFIGURATION);
4702 pBss->Configuration.BeaconPeriod = pAdapter->ScanTab.BssEntry[i].BeaconPeriod;
4703 pBss->Configuration.ATIMWindow = pAdapter->ScanTab.BssEntry[i].AtimWin;
4705 MAP_CHANNEL_ID_TO_KHZ(pAdapter->ScanTab.BssEntry[i].Channel, pBss->Configuration.DSConfig);
4707 if (pAdapter->ScanTab.BssEntry[i].BssType == BSS_INFRA)
4708 pBss->InfrastructureMode = Ndis802_11Infrastructure;
4710 pBss->InfrastructureMode = Ndis802_11IBSS;
4712 NdisMoveMemory(pBss->SupportedRates, pAdapter->ScanTab.BssEntry[i].SupRate, pAdapter->ScanTab.BssEntry[i].SupRateLen);
4713 NdisMoveMemory(pBss->SupportedRates + pAdapter->ScanTab.BssEntry[i].SupRateLen,
4714 pAdapter->ScanTab.BssEntry[i].ExtRate,
4715 pAdapter->ScanTab.BssEntry[i].ExtRateLen);
4717 if (pAdapter->ScanTab.BssEntry[i].VarIELen == 0)
4719 pBss->IELength = sizeof(NDIS_802_11_FIXED_IEs);
4720 NdisMoveMemory(pBss->IEs, &pAdapter->ScanTab.BssEntry[i].FixIEs, sizeof(NDIS_802_11_FIXED_IEs));
4721 pPtr = pPtr + sizeof(NDIS_WLAN_BSSID_EX) - 1 + sizeof(NDIS_802_11_FIXED_IEs);
4725 pBss->IELength = (ULONG)(sizeof(NDIS_802_11_FIXED_IEs) + pAdapter->ScanTab.BssEntry[i].VarIELen);
4726 pPtr = pPtr + sizeof(NDIS_WLAN_BSSID_EX) - 1 + sizeof(NDIS_802_11_FIXED_IEs);
4727 NdisMoveMemory(pBss->IEs, &pAdapter->ScanTab.BssEntry[i].FixIEs, sizeof(NDIS_802_11_FIXED_IEs));
4728 NdisMoveMemory(pBss->IEs + sizeof(NDIS_802_11_FIXED_IEs), pAdapter->ScanTab.BssEntry[i].VarIEs, pAdapter->ScanTab.BssEntry[i].VarIELen);
4729 pPtr += pAdapter->ScanTab.BssEntry[i].VarIELen;
4731 pBss->Length = (ULONG)(sizeof(NDIS_WLAN_BSSID_EX) - 1 + sizeof(NDIS_802_11_FIXED_IEs) + pAdapter->ScanTab.BssEntry[i].VarIELen + Padding);
4733 #if WIRELESS_EXT < 17
4734 if ((BssLen + pBss->Length) < wrq->u.data.length)
4735 BssLen += pBss->Length;
4738 pBssidList->NumberOfItems = i;
4742 BssLen += pBss->Length;
4746 #if WIRELESS_EXT < 17
4747 wrq->u.data.length = BssLen;
4749 if (BssLen > wrq->u.data.length)
4755 wrq->u.data.length = BssLen;
4757 Status = copy_to_user(wrq->u.data.pointer, pBssidList, BssLen);
4760 case OID_802_3_CURRENT_ADDRESS:
4761 wrq->u.data.length = MAC_ADDR_LEN;
4762 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CurrentAddress, wrq->u.data.length);
4764 case OID_GEN_MEDIA_CONNECT_STATUS:
4765 if (pAdapter->IndicateMediaState == NdisMediaStateConnected)
4766 MediaState = NdisMediaStateConnected;
4768 MediaState = NdisMediaStateDisconnected;
4770 wrq->u.data.length = sizeof(NDIS_MEDIA_STATE);
4771 Status = copy_to_user(wrq->u.data.pointer, &MediaState, wrq->u.data.length);
4773 case OID_802_11_BSSID:
4775 if (ATE_ON(pAdapter))
4777 DBGPRINT(RT_DEBUG_TRACE, ("The driver is in ATE mode now\n"));
4778 Status = NDIS_STATUS_RESOURCES;
4781 #endif // RALINK_ATE //
4782 if (INFRA_ON(pAdapter) || ADHOC_ON(pAdapter))
4784 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.Bssid, sizeof(NDIS_802_11_MAC_ADDRESS));
4789 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_BSSID(=EMPTY)\n"));
4793 case OID_802_11_SSID:
4794 NdisZeroMemory(&Ssid, sizeof(NDIS_802_11_SSID));
4795 NdisZeroMemory(Ssid.Ssid, MAX_LEN_OF_SSID);
4796 Ssid.SsidLength = pAdapter->CommonCfg.SsidLen;
4797 memcpy(Ssid.Ssid, pAdapter->CommonCfg.Ssid, Ssid.SsidLength);
4798 wrq->u.data.length = sizeof(NDIS_802_11_SSID);
4799 Status = copy_to_user(wrq->u.data.pointer, &Ssid, wrq->u.data.length);
4800 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_SSID (Len=%d, ssid=%s)\n", Ssid.SsidLength,Ssid.Ssid));
4802 case RT_OID_802_11_QUERY_LINK_STATUS:
4803 pLinkStatus = (RT_802_11_LINK_STATUS *) kmalloc(sizeof(RT_802_11_LINK_STATUS), MEM_ALLOC_FLAG);
4806 pLinkStatus->CurrTxRate = RateIdTo500Kbps[pAdapter->CommonCfg.TxRate]; // unit : 500 kbps
4807 pLinkStatus->ChannelQuality = pAdapter->Mlme.ChannelQuality;
4808 pLinkStatus->RxByteCount = pAdapter->RalinkCounters.ReceivedByteCount;
4809 pLinkStatus->TxByteCount = pAdapter->RalinkCounters.TransmittedByteCount;
4810 pLinkStatus->CentralChannel = pAdapter->CommonCfg.CentralChannel;
4811 wrq->u.data.length = sizeof(RT_802_11_LINK_STATUS);
4812 Status = copy_to_user(wrq->u.data.pointer, pLinkStatus, wrq->u.data.length);
4814 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_LINK_STATUS\n"));
4818 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_LINK_STATUS(kmalloc failed)\n"));
4822 case OID_802_11_CONFIGURATION:
4823 pConfiguration = (NDIS_802_11_CONFIGURATION *) kmalloc(sizeof(NDIS_802_11_CONFIGURATION), MEM_ALLOC_FLAG);
4826 pConfiguration->Length = sizeof(NDIS_802_11_CONFIGURATION);
4827 pConfiguration->BeaconPeriod = pAdapter->CommonCfg.BeaconPeriod;
4828 pConfiguration->ATIMWindow = pAdapter->StaActive.AtimWin;
4829 MAP_CHANNEL_ID_TO_KHZ(pAdapter->CommonCfg.Channel, pConfiguration->DSConfig);
4830 wrq->u.data.length = sizeof(NDIS_802_11_CONFIGURATION);
4831 Status = copy_to_user(wrq->u.data.pointer, pConfiguration, wrq->u.data.length);
4832 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_CONFIGURATION(BeaconPeriod=%ld,AtimW=%ld,Channel=%d) \n",
4833 pConfiguration->BeaconPeriod, pConfiguration->ATIMWindow, pAdapter->CommonCfg.Channel));
4834 kfree(pConfiguration);
4838 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_CONFIGURATION(kmalloc failed)\n"));
4842 case RT_OID_802_11_SNR_0:
4843 if ((pAdapter->StaCfg.LastSNR0 > 0))
4845 ulInfo = ((0xeb - pAdapter->StaCfg.LastSNR0) * 3) / 16 ;
4846 wrq->u.data.length = sizeof(ulInfo);
4847 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4848 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_SNR_0(0x=%lx)\n", ulInfo));
4853 case RT_OID_802_11_SNR_1:
4854 if ((pAdapter->Antenna.field.RxPath > 1) &&
4855 (pAdapter->StaCfg.LastSNR1 > 0))
4857 ulInfo = ((0xeb - pAdapter->StaCfg.LastSNR1) * 3) / 16 ;
4858 wrq->u.data.length = sizeof(ulInfo);
4859 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4860 DBGPRINT(RT_DEBUG_TRACE,("Query::RT_OID_802_11_SNR_1(0x=%lx)\n",ulInfo));
4864 DBGPRINT(RT_DEBUG_TRACE,("Query::RT_OID_802_11_SNR_1(pAdapter->StaCfg.LastSNR1=%d)\n",pAdapter->StaCfg.LastSNR1));
4866 case OID_802_11_RSSI_TRIGGER:
4867 ulInfo = pAdapter->StaCfg.RssiSample.LastRssi0 - pAdapter->BbpRssiToDbmDelta;
4868 wrq->u.data.length = sizeof(ulInfo);
4869 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4870 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_RSSI_TRIGGER(=%ld)\n", ulInfo));
4872 case OID_802_11_RSSI:
4873 case RT_OID_802_11_RSSI:
4874 ulInfo = pAdapter->StaCfg.RssiSample.LastRssi0;
4875 wrq->u.data.length = sizeof(ulInfo);
4876 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4878 case RT_OID_802_11_RSSI_1:
4879 ulInfo = pAdapter->StaCfg.RssiSample.LastRssi1;
4880 wrq->u.data.length = sizeof(ulInfo);
4881 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4883 case RT_OID_802_11_RSSI_2:
4884 ulInfo = pAdapter->StaCfg.RssiSample.LastRssi2;
4885 wrq->u.data.length = sizeof(ulInfo);
4886 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4888 case OID_802_11_STATISTICS:
4889 pStatistics = (NDIS_802_11_STATISTICS *) kmalloc(sizeof(NDIS_802_11_STATISTICS), MEM_ALLOC_FLAG);
4892 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_STATISTICS \n"));
4893 // add the most up-to-date h/w raw counters into software counters
4894 NICUpdateRawCounters(pAdapter);
4896 // Sanity check for calculation of sucessful count
4897 if (pAdapter->WlanCounters.TransmittedFragmentCount.QuadPart < pAdapter->WlanCounters.RetryCount.QuadPart)
4898 pAdapter->WlanCounters.TransmittedFragmentCount.QuadPart = pAdapter->WlanCounters.RetryCount.QuadPart;
4900 pStatistics->TransmittedFragmentCount.QuadPart = pAdapter->WlanCounters.TransmittedFragmentCount.QuadPart;
4901 pStatistics->MulticastTransmittedFrameCount.QuadPart = pAdapter->WlanCounters.MulticastTransmittedFrameCount.QuadPart;
4902 pStatistics->FailedCount.QuadPart = pAdapter->WlanCounters.FailedCount.QuadPart;
4903 pStatistics->RetryCount.QuadPart = pAdapter->WlanCounters.RetryCount.QuadPart;
4904 pStatistics->MultipleRetryCount.QuadPart = pAdapter->WlanCounters.MultipleRetryCount.QuadPart;
4905 pStatistics->RTSSuccessCount.QuadPart = pAdapter->WlanCounters.RTSSuccessCount.QuadPart;
4906 pStatistics->RTSFailureCount.QuadPart = pAdapter->WlanCounters.RTSFailureCount.QuadPart;
4907 pStatistics->ACKFailureCount.QuadPart = pAdapter->WlanCounters.ACKFailureCount.QuadPart;
4908 pStatistics->FrameDuplicateCount.QuadPart = pAdapter->WlanCounters.FrameDuplicateCount.QuadPart;
4909 pStatistics->ReceivedFragmentCount.QuadPart = pAdapter->WlanCounters.ReceivedFragmentCount.QuadPart;
4910 pStatistics->MulticastReceivedFrameCount.QuadPart = pAdapter->WlanCounters.MulticastReceivedFrameCount.QuadPart;
4912 pStatistics->FCSErrorCount = pAdapter->RalinkCounters.RealFcsErrCount;
4914 pStatistics->FCSErrorCount.QuadPart = pAdapter->WlanCounters.FCSErrorCount.QuadPart;
4915 pStatistics->FrameDuplicateCount.u.LowPart = pAdapter->WlanCounters.FrameDuplicateCount.u.LowPart / 100;
4917 wrq->u.data.length = sizeof(NDIS_802_11_STATISTICS);
4918 Status = copy_to_user(wrq->u.data.pointer, pStatistics, wrq->u.data.length);
4923 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_STATISTICS(kmalloc failed)\n"));
4927 case OID_GEN_RCV_OK:
4928 ulInfo = pAdapter->Counters8023.GoodReceives;
4929 wrq->u.data.length = sizeof(ulInfo);
4930 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4932 case OID_GEN_RCV_NO_BUFFER:
4933 ulInfo = pAdapter->Counters8023.RxNoBuffer;
4934 wrq->u.data.length = sizeof(ulInfo);
4935 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4937 case RT_OID_802_11_PHY_MODE:
4938 ulInfo = (ULONG)pAdapter->CommonCfg.PhyMode;
4939 wrq->u.data.length = sizeof(ulInfo);
4940 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4941 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_PHY_MODE (=%ld)\n", ulInfo));
4943 case RT_OID_802_11_STA_CONFIG:
4944 pStaConfig = (RT_802_11_STA_CONFIG *) kmalloc(sizeof(RT_802_11_STA_CONFIG), MEM_ALLOC_FLAG);
4947 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_STA_CONFIG\n"));
4948 pStaConfig->EnableTxBurst = pAdapter->CommonCfg.bEnableTxBurst;
4949 pStaConfig->EnableTurboRate = 0;
4950 pStaConfig->UseBGProtection = pAdapter->CommonCfg.UseBGProtection;
4951 pStaConfig->UseShortSlotTime = pAdapter->CommonCfg.bUseShortSlotTime;
4952 //pStaConfig->AdhocMode = pAdapter->StaCfg.AdhocMode;
4953 pStaConfig->HwRadioStatus = (pAdapter->StaCfg.bHwRadio == TRUE) ? 1 : 0;
4954 pStaConfig->Rsv1 = 0;
4955 pStaConfig->SystemErrorBitmap = pAdapter->SystemErrorBitmap;
4956 wrq->u.data.length = sizeof(RT_802_11_STA_CONFIG);
4957 Status = copy_to_user(wrq->u.data.pointer, pStaConfig, wrq->u.data.length);
4962 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_STA_CONFIG(kmalloc failed)\n"));
4966 case OID_802_11_RTS_THRESHOLD:
4967 RtsThresh = pAdapter->CommonCfg.RtsThreshold;
4968 wrq->u.data.length = sizeof(RtsThresh);
4969 Status = copy_to_user(wrq->u.data.pointer, &RtsThresh, wrq->u.data.length);
4970 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_RTS_THRESHOLD(=%ld)\n", RtsThresh));
4972 case OID_802_11_FRAGMENTATION_THRESHOLD:
4973 FragThresh = pAdapter->CommonCfg.FragmentThreshold;
4974 if (pAdapter->CommonCfg.bUseZeroToDisableFragment == TRUE)
4976 wrq->u.data.length = sizeof(FragThresh);
4977 Status = copy_to_user(wrq->u.data.pointer, &FragThresh, wrq->u.data.length);
4978 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_FRAGMENTATION_THRESHOLD(=%ld)\n", FragThresh));
4980 case OID_802_11_POWER_MODE:
4981 PowerMode = pAdapter->StaCfg.WindowsPowerMode;
4982 wrq->u.data.length = sizeof(PowerMode);
4983 Status = copy_to_user(wrq->u.data.pointer, &PowerMode, wrq->u.data.length);
4984 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_POWER_MODE(=%d)\n", PowerMode));
4986 case RT_OID_802_11_RADIO:
4987 RadioState = (BOOLEAN) pAdapter->StaCfg.bSwRadio;
4988 wrq->u.data.length = sizeof(RadioState);
4989 Status = copy_to_user(wrq->u.data.pointer, &RadioState, wrq->u.data.length);
4990 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_RADIO (=%d)\n", RadioState));
4992 case OID_802_11_INFRASTRUCTURE_MODE:
4993 if (pAdapter->StaCfg.BssType == BSS_ADHOC)
4994 BssType = Ndis802_11IBSS;
4995 else if (pAdapter->StaCfg.BssType == BSS_INFRA)
4996 BssType = Ndis802_11Infrastructure;
4997 else if (pAdapter->StaCfg.BssType == BSS_MONITOR)
4998 BssType = Ndis802_11Monitor;
5000 BssType = Ndis802_11AutoUnknown;
5002 wrq->u.data.length = sizeof(BssType);
5003 Status = copy_to_user(wrq->u.data.pointer, &BssType, wrq->u.data.length);
5004 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_INFRASTRUCTURE_MODE(=%d)\n", BssType));
5006 case RT_OID_802_11_PREAMBLE:
5007 PreamType = pAdapter->CommonCfg.TxPreamble;
5008 wrq->u.data.length = sizeof(PreamType);
5009 Status = copy_to_user(wrq->u.data.pointer, &PreamType, wrq->u.data.length);
5010 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_PREAMBLE(=%d)\n", PreamType));
5012 case OID_802_11_AUTHENTICATION_MODE:
5013 AuthMode = pAdapter->StaCfg.AuthMode;
5014 wrq->u.data.length = sizeof(AuthMode);
5015 Status = copy_to_user(wrq->u.data.pointer, &AuthMode, wrq->u.data.length);
5016 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_AUTHENTICATION_MODE(=%d)\n", AuthMode));
5018 case OID_802_11_WEP_STATUS:
5019 WepStatus = pAdapter->StaCfg.WepStatus;
5020 wrq->u.data.length = sizeof(WepStatus);
5021 Status = copy_to_user(wrq->u.data.pointer, &WepStatus, wrq->u.data.length);
5022 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_WEP_STATUS(=%d)\n", WepStatus));
5024 case OID_802_11_TX_POWER_LEVEL:
5025 wrq->u.data.length = sizeof(ULONG);
5026 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.TxPower, wrq->u.data.length);
5027 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_TX_POWER_LEVEL %x\n",pAdapter->CommonCfg.TxPower));
5029 case RT_OID_802_11_TX_POWER_LEVEL_1:
5030 wrq->u.data.length = sizeof(ULONG);
5031 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.TxPowerPercentage, wrq->u.data.length);
5032 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_TX_POWER_LEVEL_1 (=%ld)\n", pAdapter->CommonCfg.TxPowerPercentage));
5034 case OID_802_11_NETWORK_TYPES_SUPPORTED:
5035 if ((pAdapter->RfIcType == RFIC_2850) || (pAdapter->RfIcType == RFIC_2750))
5037 NetworkTypeList[0] = 3; // NumberOfItems = 3
5038 NetworkTypeList[1] = Ndis802_11DS; // NetworkType[1] = 11b
5039 NetworkTypeList[2] = Ndis802_11OFDM24; // NetworkType[2] = 11g
5040 NetworkTypeList[3] = Ndis802_11OFDM5; // NetworkType[3] = 11a
5041 wrq->u.data.length = 16;
5042 Status = copy_to_user(wrq->u.data.pointer, &NetworkTypeList[0], wrq->u.data.length);
5046 NetworkTypeList[0] = 2; // NumberOfItems = 2
5047 NetworkTypeList[1] = Ndis802_11DS; // NetworkType[1] = 11b
5048 NetworkTypeList[2] = Ndis802_11OFDM24; // NetworkType[2] = 11g
5049 wrq->u.data.length = 12;
5050 Status = copy_to_user(wrq->u.data.pointer, &NetworkTypeList[0], wrq->u.data.length);
5052 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_NETWORK_TYPES_SUPPORTED\n"));
5054 case OID_802_11_NETWORK_TYPE_IN_USE:
5055 wrq->u.data.length = sizeof(ULONG);
5056 if (pAdapter->CommonCfg.PhyMode == PHY_11A)
5057 ulInfo = Ndis802_11OFDM5;
5058 else if ((pAdapter->CommonCfg.PhyMode == PHY_11BG_MIXED) || (pAdapter->CommonCfg.PhyMode == PHY_11G))
5059 ulInfo = Ndis802_11OFDM24;
5061 ulInfo = Ndis802_11DS;
5062 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
5064 case RT_OID_802_11_QUERY_LAST_RX_RATE:
5065 ulInfo = (ULONG)pAdapter->LastRxRate;
5066 wrq->u.data.length = sizeof(ulInfo);
5067 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
5068 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_LAST_RX_RATE (=%ld)\n", ulInfo));
5070 case RT_OID_802_11_QUERY_LAST_TX_RATE:
5071 //ulInfo = (ULONG)pAdapter->LastTxRate;
5072 ulInfo = (ULONG)pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.word;
5073 wrq->u.data.length = sizeof(ulInfo);
5074 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
5075 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_LAST_TX_RATE (=%lx)\n", ulInfo));
5077 case RT_OID_802_11_QUERY_EEPROM_VERSION:
5078 wrq->u.data.length = sizeof(ULONG);
5079 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->EepromVersion, wrq->u.data.length);
5081 case RT_OID_802_11_QUERY_FIRMWARE_VERSION:
5082 wrq->u.data.length = sizeof(ULONG);
5083 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->FirmwareVersion, wrq->u.data.length);
5085 case RT_OID_802_11_QUERY_NOISE_LEVEL:
5086 wrq->u.data.length = sizeof(UCHAR);
5087 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->BbpWriteLatch[66], wrq->u.data.length);
5088 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_NOISE_LEVEL (=%d)\n", pAdapter->BbpWriteLatch[66]));
5090 case RT_OID_802_11_EXTRA_INFO:
5091 wrq->u.data.length = sizeof(ULONG);
5092 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->ExtraInfo, wrq->u.data.length);
5093 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_EXTRA_INFO (=%ld)\n", pAdapter->ExtraInfo));
5095 case RT_OID_WE_VERSION_COMPILED:
5096 wrq->u.data.length = sizeof(UINT);
5097 we_version_compiled = WIRELESS_EXT;
5098 Status = copy_to_user(wrq->u.data.pointer, &we_version_compiled, wrq->u.data.length);
5100 case RT_OID_802_11_QUERY_APSD_SETTING:
5101 apsd = (pAdapter->CommonCfg.bAPSDCapable | (pAdapter->CommonCfg.bAPSDAC_BE << 1) | (pAdapter->CommonCfg.bAPSDAC_BK << 2)
5102 | (pAdapter->CommonCfg.bAPSDAC_VI << 3) | (pAdapter->CommonCfg.bAPSDAC_VO << 4) | (pAdapter->CommonCfg.MaxSPLength << 5));
5104 wrq->u.data.length = sizeof(ULONG);
5105 Status = copy_to_user(wrq->u.data.pointer, &apsd, wrq->u.data.length);
5106 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",
5107 apsd,pAdapter->CommonCfg.bAPSDCapable,pAdapter->CommonCfg.bAPSDAC_BE,pAdapter->CommonCfg.bAPSDAC_BK,pAdapter->CommonCfg.bAPSDAC_VI,pAdapter->CommonCfg.bAPSDAC_VO,pAdapter->CommonCfg.MaxSPLength));
5109 case RT_OID_802_11_QUERY_APSD_PSM:
5110 wrq->u.data.length = sizeof(ULONG);
5111 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.bAPSDForcePowerSave, wrq->u.data.length);
5112 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_APSD_PSM (=%d)\n", pAdapter->CommonCfg.bAPSDForcePowerSave));
5114 case RT_OID_802_11_QUERY_WMM:
5115 wrq->u.data.length = sizeof(BOOLEAN);
5116 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.bWmmCapable, wrq->u.data.length);
5117 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_WMM (=%d)\n", pAdapter->CommonCfg.bWmmCapable));
5119 #ifdef WPA_SUPPLICANT_SUPPORT
5120 case RT_OID_NEW_DRIVER:
5123 wrq->u.data.length = sizeof(UCHAR);
5124 Status = copy_to_user(wrq->u.data.pointer, &enabled, wrq->u.data.length);
5125 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_NEW_DRIVER (=%d)\n", enabled));
5128 case RT_OID_WPA_SUPPLICANT_SUPPORT:
5129 wrq->u.data.length = sizeof(UCHAR);
5130 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->StaCfg.WpaSupplicantUP, wrq->u.data.length);
5131 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_WPA_SUPPLICANT_SUPPORT (=%d)\n", pAdapter->StaCfg.WpaSupplicantUP));
5133 #endif // WPA_SUPPLICANT_SUPPORT //
5135 case RT_OID_DRIVER_DEVICE_NAME:
5136 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_DRIVER_DEVICE_NAME \n"));
5137 wrq->u.data.length = 16;
5138 if (copy_to_user(wrq->u.data.pointer, pAdapter->StaCfg.dev_name, wrq->u.data.length))
5143 case RT_OID_802_11_QUERY_HT_PHYMODE:
5144 pHTPhyMode = (OID_SET_HT_PHYMODE *) kmalloc(sizeof(OID_SET_HT_PHYMODE), MEM_ALLOC_FLAG);
5147 pHTPhyMode->PhyMode = pAdapter->CommonCfg.PhyMode;
5148 pHTPhyMode->HtMode = (UCHAR)pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.field.MODE;
5149 pHTPhyMode->BW = (UCHAR)pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.field.BW;
5150 pHTPhyMode->MCS= (UCHAR)pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.field.MCS;
5151 pHTPhyMode->SHORTGI= (UCHAR)pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.field.ShortGI;
5152 pHTPhyMode->STBC= (UCHAR)pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.field.STBC;
5154 pHTPhyMode->ExtOffset = ((pAdapter->CommonCfg.CentralChannel < pAdapter->CommonCfg.Channel) ? (EXTCHA_BELOW) : (EXTCHA_ABOVE));
5155 wrq->u.data.length = sizeof(OID_SET_HT_PHYMODE);
5156 if (copy_to_user(wrq->u.data.pointer, pHTPhyMode, wrq->u.data.length))
5160 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_HT_PHYMODE (PhyMode = %d, MCS =%d, BW = %d, STBC = %d, ExtOffset=%d)\n",
5161 pHTPhyMode->HtMode, pHTPhyMode->MCS, pHTPhyMode->BW, pHTPhyMode->STBC, pHTPhyMode->ExtOffset));
5162 DBGPRINT(RT_DEBUG_TRACE, (" MlmeUpdateTxRates (.word = %x )\n", pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.word));
5166 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_STA_CONFIG(kmalloc failed)\n"));
5170 case RT_OID_802_11_COUNTRY_REGION:
5171 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_COUNTRY_REGION \n"));
5172 wrq->u.data.length = sizeof(ulInfo);
5173 ulInfo = pAdapter->CommonCfg.CountryRegionForABand;
5174 ulInfo = (ulInfo << 8)|(pAdapter->CommonCfg.CountryRegion);
5175 if (copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length))
5180 case RT_OID_802_11_QUERY_DAT_HT_PHYMODE:
5181 pHTPhyMode = (OID_SET_HT_PHYMODE *) kmalloc(sizeof(OID_SET_HT_PHYMODE), MEM_ALLOC_FLAG);
5184 pHTPhyMode->PhyMode = pAdapter->CommonCfg.PhyMode;
5185 pHTPhyMode->HtMode = (UCHAR)pAdapter->CommonCfg.RegTransmitSetting.field.HTMODE;
5186 pHTPhyMode->BW = (UCHAR)pAdapter->CommonCfg.RegTransmitSetting.field.BW;
5187 pHTPhyMode->MCS= (UCHAR)pAdapter->StaCfg.DesiredTransmitSetting.field.MCS;
5188 pHTPhyMode->SHORTGI= (UCHAR)pAdapter->CommonCfg.RegTransmitSetting.field.ShortGI;
5189 pHTPhyMode->STBC= (UCHAR)pAdapter->CommonCfg.RegTransmitSetting.field.STBC;
5191 wrq->u.data.length = sizeof(OID_SET_HT_PHYMODE);
5192 if (copy_to_user(wrq->u.data.pointer, pHTPhyMode, wrq->u.data.length))
5196 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_HT_PHYMODE (PhyMode = %d, MCS =%d, BW = %d, STBC = %d, ExtOffset=%d)\n",
5197 pHTPhyMode->HtMode, pHTPhyMode->MCS, pHTPhyMode->BW, pHTPhyMode->STBC, pHTPhyMode->ExtOffset));
5198 DBGPRINT(RT_DEBUG_TRACE, (" MlmeUpdateTxRates (.word = %x )\n", pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.word));
5202 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_STA_CONFIG(kmalloc failed)\n"));
5206 case RT_OID_QUERY_MULTIPLE_CARD_SUPPORT:
5207 wrq->u.data.length = sizeof(UCHAR);
5209 #ifdef MULTIPLE_CARD_SUPPORT
5211 #endif // MULTIPLE_CARD_SUPPORT //
5212 if (copy_to_user(wrq->u.data.pointer, &i, wrq->u.data.length))
5216 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_QUERY_MULTIPLE_CARD_SUPPORT(=%d) \n", i));
5219 case RT_OID_802_11_MAC_ADDRESS:
5220 wrq->u.data.length = MAC_ADDR_LEN;
5221 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CurrentAddress, wrq->u.data.length);
5224 case RT_OID_802_11_MANUFACTUREROUI:
5225 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_MANUFACTUREROUI \n"));
5226 wrq->u.data.length = ManufacturerOUI_LEN;
5227 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CurrentAddress, wrq->u.data.length);
5230 case RT_OID_802_11_MANUFACTURERNAME:
5231 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_MANUFACTURERNAME \n"));
5232 wrq->u.data.length = strlen(ManufacturerNAME);
5233 Status = copy_to_user(wrq->u.data.pointer, ManufacturerNAME, wrq->u.data.length);
5236 case RT_OID_802_11_RESOURCETYPEIDNAME:
5237 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_RESOURCETYPEIDNAME \n"));
5238 wrq->u.data.length = strlen(ResourceTypeIdName);
5239 Status = copy_to_user(wrq->u.data.pointer, ResourceTypeIdName, wrq->u.data.length);
5242 case RT_OID_802_11_PRIVACYOPTIONIMPLEMENTED:
5243 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_PRIVACYOPTIONIMPLEMENTED \n"));
5244 ulInfo = 1; // 1 is support wep else 2 is not support.
5245 wrq->u.data.length = sizeof(ulInfo);
5246 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
5249 case RT_OID_802_11_POWERMANAGEMENTMODE:
5250 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_POWERMANAGEMENTMODE \n"));
5251 if (pAdapter->StaCfg.Psm == PSMP_ACTION)
5252 ulInfo = 1; // 1 is power active else 2 is power save.
5256 wrq->u.data.length = sizeof(ulInfo);
5257 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
5260 case OID_802_11_WEPDEFAULTKEYVALUE:
5261 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_WEPDEFAULTKEYVALUE \n"));
5262 //KeyIdxValue.KeyIdx = pAd->PortCfg.MBSSID[pAd->IoctlIF].DefaultKeyId;
5263 pKeyIdxValue = wrq->u.data.pointer;
5264 DBGPRINT(RT_DEBUG_TRACE,("KeyIdxValue.KeyIdx = %d, \n",pKeyIdxValue->KeyIdx));
5265 valueLen = pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].KeyLen;
5266 NdisMoveMemory(pKeyIdxValue->Value,
5267 &pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].Key,
5269 pKeyIdxValue->Value[valueLen]='\0';
5271 wrq->u.data.length = sizeof(DefaultKeyIdxValue);
5273 Status = copy_to_user(wrq->u.data.pointer, pKeyIdxValue, wrq->u.data.length);
5274 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,
5275 pAdapter->SharedKey[BSS0][0].Key[0],
5276 pAdapter->SharedKey[BSS0][1].Key[0],
5277 pAdapter->SharedKey[BSS0][2].Key[0],
5278 pAdapter->SharedKey[BSS0][3].Key[0]));
5281 case OID_802_11_WEPDEFAULTKEYID:
5282 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_WEPDEFAULTKEYID \n"));
5283 wrq->u.data.length = sizeof(UCHAR);
5284 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->StaCfg.DefaultKeyId, wrq->u.data.length);
5285 DBGPRINT(RT_DEBUG_TRACE, ("DefaultKeyId =%d \n", pAdapter->StaCfg.DefaultKeyId));
5288 case RT_OID_802_11_WEPKEYMAPPINGLENGTH:
5289 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_WEPKEYMAPPINGLENGTH \n"));
5290 wrq->u.data.length = sizeof(UCHAR);
5291 Status = copy_to_user(wrq->u.data.pointer,
5292 &pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].KeyLen,
5293 wrq->u.data.length);
5296 case OID_802_11_SHORTRETRYLIMIT:
5297 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_SHORTRETRYLIMIT \n"));
5298 wrq->u.data.length = sizeof(ULONG);
5299 RTMP_IO_READ32(pAdapter, TX_RTY_CFG, &tx_rty_cfg.word);
5300 ShortRetryLimit = tx_rty_cfg.field.ShortRtyLimit;
5301 DBGPRINT(RT_DEBUG_TRACE, ("ShortRetryLimit =%ld, tx_rty_cfg.field.ShortRetryLimit=%d\n", ShortRetryLimit, tx_rty_cfg.field.ShortRtyLimit));
5302 Status = copy_to_user(wrq->u.data.pointer, &ShortRetryLimit, wrq->u.data.length);
5305 case OID_802_11_LONGRETRYLIMIT:
5306 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_LONGRETRYLIMIT \n"));
5307 wrq->u.data.length = sizeof(ULONG);
5308 RTMP_IO_READ32(pAdapter, TX_RTY_CFG, &tx_rty_cfg.word);
5309 LongRetryLimit = tx_rty_cfg.field.LongRtyLimit;
5310 DBGPRINT(RT_DEBUG_TRACE, ("LongRetryLimit =%ld, tx_rty_cfg.field.LongRtyLimit=%d\n", LongRetryLimit, tx_rty_cfg.field.LongRtyLimit));
5311 Status = copy_to_user(wrq->u.data.pointer, &LongRetryLimit, wrq->u.data.length);
5314 case RT_OID_802_11_PRODUCTID:
5315 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_PRODUCTID \n"));
5320 if (((POS_COOKIE)pAdapter->OS_Cookie)->pci_dev != NULL)
5321 pci_read_config_word(((POS_COOKIE)pAdapter->OS_Cookie)->pci_dev, PCI_DEVICE_ID, &device_id);
5323 DBGPRINT(RT_DEBUG_TRACE, (" pci_dev = NULL\n"));
5324 sprintf(tmp, "%04x %04x\n", NIC_PCI_VENDOR_ID, device_id);
5326 wrq->u.data.length = strlen(tmp);
5327 Status = copy_to_user(wrq->u.data.pointer, tmp, wrq->u.data.length);
5330 case RT_OID_802_11_MANUFACTUREID:
5331 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_MANUFACTUREID \n"));
5332 wrq->u.data.length = strlen(ManufacturerNAME);
5333 Status = copy_to_user(wrq->u.data.pointer, ManufacturerNAME, wrq->u.data.length);
5336 case OID_802_11_CURRENTCHANNEL:
5337 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_CURRENTCHANNEL \n"));
5338 wrq->u.data.length = sizeof(UCHAR);
5339 DBGPRINT(RT_DEBUG_TRACE, ("sizeof UCHAR=%d, channel=%d \n", sizeof(UCHAR), pAdapter->CommonCfg.Channel));
5340 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.Channel, wrq->u.data.length);
5341 DBGPRINT(RT_DEBUG_TRACE, ("Status=%d\n", Status));
5343 #endif //SNMP_SUPPORT
5345 case OID_802_11_BUILD_CHANNEL_EX:
5348 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_BUILD_CHANNEL_EX \n"));
5349 wrq->u.data.length = sizeof(UCHAR);
5350 #ifdef EXT_BUILD_CHANNEL_LIST
5351 DBGPRINT(RT_DEBUG_TRACE, ("Support EXT_BUILD_CHANNEL_LIST.\n"));
5354 DBGPRINT(RT_DEBUG_TRACE, ("Doesn't support EXT_BUILD_CHANNEL_LIST.\n"));
5356 #endif // EXT_BUILD_CHANNEL_LIST //
5357 Status = copy_to_user(wrq->u.data.pointer, &value, 1);
5358 DBGPRINT(RT_DEBUG_TRACE, ("Status=%d\n", Status));
5362 case OID_802_11_GET_CH_LIST:
5364 PRT_CHANNEL_LIST_INFO pChListBuf;
5366 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_GET_CH_LIST \n"));
5367 if (pAdapter->ChannelListNum == 0)
5369 wrq->u.data.length = 0;
5373 pChListBuf = (RT_CHANNEL_LIST_INFO *) kmalloc(sizeof(RT_CHANNEL_LIST_INFO), MEM_ALLOC_FLAG);
5374 if (pChListBuf == NULL)
5376 wrq->u.data.length = 0;
5380 pChListBuf->ChannelListNum = pAdapter->ChannelListNum;
5381 for (i = 0; i < pChListBuf->ChannelListNum; i++)
5382 pChListBuf->ChannelList[i] = pAdapter->ChannelList[i].Channel;
5384 wrq->u.data.length = sizeof(RT_CHANNEL_LIST_INFO);
5385 Status = copy_to_user(wrq->u.data.pointer, pChListBuf, sizeof(RT_CHANNEL_LIST_INFO));
5386 DBGPRINT(RT_DEBUG_TRACE, ("Status=%d\n", Status));
5393 case OID_802_11_GET_COUNTRY_CODE:
5394 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_GET_COUNTRY_CODE \n"));
5395 wrq->u.data.length = 2;
5396 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.CountryCode, 2);
5397 DBGPRINT(RT_DEBUG_TRACE, ("Status=%d\n", Status));
5400 case OID_802_11_GET_CHANNEL_GEOGRAPHY:
5401 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_GET_CHANNEL_GEOGRAPHY \n"));
5402 wrq->u.data.length = 1;
5403 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.Geography, 1);
5404 DBGPRINT(RT_DEBUG_TRACE, ("Status=%d\n", Status));
5408 #ifdef QOS_DLS_SUPPORT
5409 case RT_OID_802_11_QUERY_DLS:
5410 wrq->u.data.length = sizeof(BOOLEAN);
5411 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.bDLSCapable, wrq->u.data.length);
5412 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_DLS(=%d)\n", pAdapter->CommonCfg.bDLSCapable));
5415 case RT_OID_802_11_QUERY_DLS_PARAM:
5417 PRT_802_11_DLS_INFO pDlsInfo = kmalloc(sizeof(RT_802_11_DLS_INFO), GFP_ATOMIC);
5418 if (pDlsInfo == NULL)
5421 for (i=0; i<MAX_NUM_OF_DLS_ENTRY; i++)
5423 RTMPMoveMemory(&pDlsInfo->Entry[i], &pAdapter->StaCfg.DLSEntry[i], sizeof(RT_802_11_DLS_UI));
5426 pDlsInfo->num = MAX_NUM_OF_DLS_ENTRY;
5427 wrq->u.data.length = sizeof(RT_802_11_DLS_INFO);
5428 Status = copy_to_user(wrq->u.data.pointer, pDlsInfo, wrq->u.data.length);
5429 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_DLS_PARAM\n"));
5435 #endif // QOS_DLS_SUPPORT //
5437 DBGPRINT(RT_DEBUG_TRACE, ("Query::unknown IOCTL's subcmd = 0x%08x\n", cmd));
5438 Status = -EOPNOTSUPP;
5444 INT rt28xx_sta_ioctl(
5445 IN struct net_device *net_dev,
5446 IN OUT struct ifreq *rq,
5450 VIRTUAL_ADAPTER *pVirtualAd = NULL;
5451 RTMP_ADAPTER *pAd = NULL;
5452 struct iwreq *wrq = (struct iwreq *) rq;
5453 BOOLEAN StateMachineTouched = FALSE;
5454 INT Status = NDIS_STATUS_SUCCESS;
5457 if (net_dev->priv_flags == INT_MAIN)
5459 pAd = net_dev->ml_priv;
5463 pVirtualAd = net_dev->ml_priv;
5464 pAd = pVirtualAd->RtmpDev->ml_priv;
5466 pObj = (POS_COOKIE) pAd->OS_Cookie;
5470 /* if 1st open fail, pAd will be free;
5471 So the net_dev->ml_priv will be NULL in 2rd open */
5475 //check if the interface is down
5476 if(!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_IN_USE))
5478 #ifdef CONFIG_APSTA_MIXED_SUPPORT
5479 if (wrq->u.data.pointer == NULL)
5484 if (strstr(wrq->u.data.pointer, "OpMode") == NULL)
5485 #endif // CONFIG_APSTA_MIXED_SUPPORT //
5487 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
5492 { // determine this ioctl command is comming from which interface.
5493 pObj->ioctl_if_type = INT_MAIN;
5494 pObj->ioctl_if = MAIN_MBSSID;
5500 #ifdef RALINK_28xx_QA
5501 case RTPRIV_IOCTL_ATE:
5503 RtmpDoAte(pAd, wrq);
5506 #endif // RALINK_28xx_QA //
5507 #endif // RALINK_ATE //
5509 DBGPRINT(RT_DEBUG_TRACE, ("IOCTL::SIOCGIFHWADDR\n"));
5510 memcpy(wrq->u.name, pAd->CurrentAddress, ETH_ALEN);
5514 char *name=&wrq->u.name[0];
5515 rt_ioctl_giwname(net_dev, NULL, name, NULL);
5518 case SIOCGIWESSID: //Get ESSID
5520 struct iw_point *essid=&wrq->u.essid;
5521 rt_ioctl_giwessid(net_dev, NULL, essid, essid->pointer);
5524 case SIOCSIWESSID: //Set ESSID
5526 struct iw_point *essid=&wrq->u.essid;
5527 rt_ioctl_siwessid(net_dev, NULL, essid, essid->pointer);
5530 case SIOCSIWNWID: // set network id (the cell)
5531 case SIOCGIWNWID: // get network id
5532 Status = -EOPNOTSUPP;
5534 case SIOCSIWFREQ: //set channel/frequency (Hz)
5536 struct iw_freq *freq=&wrq->u.freq;
5537 rt_ioctl_siwfreq(net_dev, NULL, freq, NULL);
5540 case SIOCGIWFREQ: // get channel/frequency (Hz)
5542 struct iw_freq *freq=&wrq->u.freq;
5543 rt_ioctl_giwfreq(net_dev, NULL, freq, NULL);
5546 case SIOCSIWNICKN: //set node name/nickname
5548 struct iw_point *data=&wrq->u.data;
5549 rt_ioctl_siwnickn(net_dev, NULL, data, NULL);
5552 case SIOCGIWNICKN: //get node name/nickname
5554 struct iw_point *data=&wrq->u.data;
5555 rt_ioctl_giwnickn(net_dev, NULL, data, NULL);
5558 case SIOCGIWRATE: //get default bit rate (bps)
5559 rt_ioctl_giwrate(net_dev, NULL, &wrq->u, NULL);
5561 case SIOCSIWRATE: //set default bit rate (bps)
5562 rt_ioctl_siwrate(net_dev, NULL, &wrq->u, NULL);
5564 case SIOCGIWRTS: // get RTS/CTS threshold (bytes)
5566 struct iw_param *rts=&wrq->u.rts;
5567 rt_ioctl_giwrts(net_dev, NULL, rts, NULL);
5570 case SIOCSIWRTS: //set RTS/CTS threshold (bytes)
5572 struct iw_param *rts=&wrq->u.rts;
5573 rt_ioctl_siwrts(net_dev, NULL, rts, NULL);
5576 case SIOCGIWFRAG: //get fragmentation thr (bytes)
5578 struct iw_param *frag=&wrq->u.frag;
5579 rt_ioctl_giwfrag(net_dev, NULL, frag, NULL);
5582 case SIOCSIWFRAG: //set fragmentation thr (bytes)
5584 struct iw_param *frag=&wrq->u.frag;
5585 rt_ioctl_siwfrag(net_dev, NULL, frag, NULL);
5588 case SIOCGIWENCODE: //get encoding token & mode
5590 struct iw_point *erq=&wrq->u.encoding;
5592 rt_ioctl_giwencode(net_dev, NULL, erq, erq->pointer);
5595 case SIOCSIWENCODE: //set encoding token & mode
5597 struct iw_point *erq=&wrq->u.encoding;
5599 rt_ioctl_siwencode(net_dev, NULL, erq, erq->pointer);
5602 case SIOCGIWAP: //get access point MAC addresses
5604 struct sockaddr *ap_addr=&wrq->u.ap_addr;
5605 rt_ioctl_giwap(net_dev, NULL, ap_addr, ap_addr->sa_data);
5608 case SIOCSIWAP: //set access point MAC addresses
5610 struct sockaddr *ap_addr=&wrq->u.ap_addr;
5611 rt_ioctl_siwap(net_dev, NULL, ap_addr, ap_addr->sa_data);
5614 case SIOCGIWMODE: //get operation mode
5616 __u32 *mode=&wrq->u.mode;
5617 rt_ioctl_giwmode(net_dev, NULL, mode, NULL);
5620 case SIOCSIWMODE: //set operation mode
5622 __u32 *mode=&wrq->u.mode;
5623 rt_ioctl_siwmode(net_dev, NULL, mode, NULL);
5626 case SIOCGIWSENS: //get sensitivity (dBm)
5627 case SIOCSIWSENS: //set sensitivity (dBm)
5628 case SIOCGIWPOWER: //get Power Management settings
5629 case SIOCSIWPOWER: //set Power Management settings
5630 case SIOCGIWTXPOW: //get transmit power (dBm)
5631 case SIOCSIWTXPOW: //set transmit power (dBm)
5632 case SIOCGIWRANGE: //Get range of parameters
5633 case SIOCGIWRETRY: //get retry limits and lifetime
5634 case SIOCSIWRETRY: //set retry limits and lifetime
5635 Status = -EOPNOTSUPP;
5638 subcmd = wrq->u.data.flags;
5639 if( subcmd & OID_GET_SET_TOGGLE)
5640 Status = RTMPSetInformation(pAd, rq, subcmd);
5642 Status = RTMPQueryInformation(pAd, rq, subcmd);
5645 if (wrq->u.data.pointer)
5647 if ( access_ok(VERIFY_WRITE, wrq->u.data.pointer, sizeof(privtab)) != TRUE)
5649 wrq->u.data.length = sizeof(privtab) / sizeof(privtab[0]);
5650 if (copy_to_user(wrq->u.data.pointer, privtab, sizeof(privtab)))
5654 case RTPRIV_IOCTL_SET:
5655 if(access_ok(VERIFY_READ, wrq->u.data.pointer, wrq->u.data.length) != TRUE)
5657 rt_ioctl_setparam(net_dev, NULL, NULL, wrq->u.data.pointer);
5659 case RTPRIV_IOCTL_GSITESURVEY:
5660 RTMPIoctlGetSiteSurvey(pAd, wrq);
5663 case RTPRIV_IOCTL_MAC:
5664 RTMPIoctlMAC(pAd, wrq);
5666 case RTPRIV_IOCTL_E2P:
5667 RTMPIoctlE2PROM(pAd, wrq);
5673 DBGPRINT(RT_DEBUG_ERROR, ("IOCTL::unknown IOCTL's cmd = 0x%08x\n", cmd));
5674 Status = -EOPNOTSUPP;
5678 if(StateMachineTouched) // Upper layer sent a MLME-related operations
5679 RT28XX_MLME_HANDLER(pAd);
5685 ==========================================================================
5689 TRUE if all parameters are OK, FALSE otherwise
5690 ==========================================================================
5693 IN PRTMP_ADAPTER pAdapter,
5696 NDIS_802_11_SSID Ssid, *pSsid=NULL;
5697 BOOLEAN StateMachineTouched = FALSE;
5700 if( strlen(arg) <= MAX_LEN_OF_SSID)
5702 NdisZeroMemory(&Ssid, sizeof(NDIS_802_11_SSID));
5703 if (strlen(arg) != 0)
5705 NdisMoveMemory(Ssid.Ssid, arg, strlen(arg));
5706 Ssid.SsidLength = strlen(arg);
5710 Ssid.SsidLength = 0;
5711 memcpy(Ssid.Ssid, "", 0);
5712 pAdapter->StaCfg.BssType = BSS_INFRA;
5713 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
5714 pAdapter->StaCfg.WepStatus = Ndis802_11EncryptionDisabled;
5718 if (pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE)
5720 RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
5721 DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
5724 pAdapter->MlmeAux.CurrReqIsFromNdis = TRUE;
5725 pAdapter->StaCfg.bScanReqIsFromWebUI = FALSE;
5726 pAdapter->bConfigChanged = TRUE;
5728 MlmeEnqueue(pAdapter,
5729 MLME_CNTL_STATE_MACHINE,
5731 sizeof(NDIS_802_11_SSID),
5734 StateMachineTouched = TRUE;
5735 DBGPRINT(RT_DEBUG_TRACE, ("Set_SSID_Proc::(Len=%d,Ssid=%s)\n", Ssid.SsidLength, Ssid.Ssid));
5740 if (StateMachineTouched) // Upper layer sent a MLME-related operations
5741 RT28XX_MLME_HANDLER(pAdapter);
5748 ==========================================================================
5750 Set WmmCapable Enable or Disable
5752 TRUE if all parameters are OK, FALSE otherwise
5753 ==========================================================================
5755 INT Set_WmmCapable_Proc(
5756 IN PRTMP_ADAPTER pAd,
5759 BOOLEAN bWmmCapable;
5761 bWmmCapable = simple_strtol(arg, 0, 10);
5763 if ((bWmmCapable == 1)
5765 pAd->CommonCfg.bWmmCapable = TRUE;
5766 else if (bWmmCapable == 0)
5767 pAd->CommonCfg.bWmmCapable = FALSE;
5769 return FALSE; //Invalid argument
5771 DBGPRINT(RT_DEBUG_TRACE, ("Set_WmmCapable_Proc::(bWmmCapable=%d)\n",
5772 pAd->CommonCfg.bWmmCapable));
5776 #endif // WMM_SUPPORT //
5779 ==========================================================================
5781 Set Network Type(Infrastructure/Adhoc mode)
5783 TRUE if all parameters are OK, FALSE otherwise
5784 ==========================================================================
5786 INT Set_NetworkType_Proc(
5787 IN PRTMP_ADAPTER pAdapter,
5792 if (strcmp(arg, "Adhoc") == 0)
5794 if (pAdapter->StaCfg.BssType != BSS_ADHOC)
5796 // Config has changed
5797 pAdapter->bConfigChanged = TRUE;
5798 if (MONITOR_ON(pAdapter))
5800 RTMP_IO_WRITE32(pAdapter, RX_FILTR_CFG, STANORMAL);
5801 RTMP_IO_READ32(pAdapter, MAC_SYS_CTRL, &Value);
5803 RTMP_IO_WRITE32(pAdapter, MAC_SYS_CTRL, Value);
5804 OPSTATUS_CLEAR_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED);
5805 pAdapter->StaCfg.bAutoReconnect = TRUE;
5806 LinkDown(pAdapter, FALSE);
5808 if (INFRA_ON(pAdapter))
5810 //BOOLEAN Cancelled;
5811 // Set the AutoReconnectSsid to prevent it reconnect to old SSID
5812 // Since calling this indicate user don't want to connect to that SSID anymore.
5813 pAdapter->MlmeAux.AutoReconnectSsidLen= 32;
5814 NdisZeroMemory(pAdapter->MlmeAux.AutoReconnectSsid, pAdapter->MlmeAux.AutoReconnectSsidLen);
5816 LinkDown(pAdapter, FALSE);
5818 DBGPRINT(RT_DEBUG_TRACE, ("NDIS_STATUS_MEDIA_DISCONNECT Event BB!\n"));
5821 pAdapter->StaCfg.BssType = BSS_ADHOC;
5822 pAdapter->net_dev->type = pAdapter->StaCfg.OriDevType;
5823 DBGPRINT(RT_DEBUG_TRACE, ("===>Set_NetworkType_Proc::(AD-HOC)\n"));
5825 else if (strcmp(arg, "Infra") == 0)
5827 if (pAdapter->StaCfg.BssType != BSS_INFRA)
5829 // Config has changed
5830 pAdapter->bConfigChanged = TRUE;
5831 if (MONITOR_ON(pAdapter))
5833 RTMP_IO_WRITE32(pAdapter, RX_FILTR_CFG, STANORMAL);
5834 RTMP_IO_READ32(pAdapter, MAC_SYS_CTRL, &Value);
5836 RTMP_IO_WRITE32(pAdapter, MAC_SYS_CTRL, Value);
5837 OPSTATUS_CLEAR_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED);
5838 pAdapter->StaCfg.bAutoReconnect = TRUE;
5839 LinkDown(pAdapter, FALSE);
5841 if (ADHOC_ON(pAdapter))
5843 // Set the AutoReconnectSsid to prevent it reconnect to old SSID
5844 // Since calling this indicate user don't want to connect to that SSID anymore.
5845 pAdapter->MlmeAux.AutoReconnectSsidLen= 32;
5846 NdisZeroMemory(pAdapter->MlmeAux.AutoReconnectSsid, pAdapter->MlmeAux.AutoReconnectSsidLen);
5848 LinkDown(pAdapter, FALSE);
5851 pAdapter->StaCfg.BssType = BSS_INFRA;
5852 pAdapter->net_dev->type = pAdapter->StaCfg.OriDevType;
5853 DBGPRINT(RT_DEBUG_TRACE, ("===>Set_NetworkType_Proc::(INFRA)\n"));
5855 pAdapter->StaCfg.BssType = BSS_INFRA;
5857 else if (strcmp(arg, "Monitor") == 0)
5860 BCN_TIME_CFG_STRUC csr;
5861 OPSTATUS_CLEAR_FLAG(pAdapter, fOP_STATUS_INFRA_ON);
5862 OPSTATUS_CLEAR_FLAG(pAdapter, fOP_STATUS_ADHOC_ON);
5863 OPSTATUS_SET_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED);
5864 // disable all periodic state machine
5865 pAdapter->StaCfg.bAutoReconnect = FALSE;
5866 // reset all mlme state machine
5867 RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
5868 DBGPRINT(RT_DEBUG_TRACE, ("fOP_STATUS_MEDIA_STATE_CONNECTED \n"));
5869 if (pAdapter->CommonCfg.CentralChannel == 0)
5871 #ifdef DOT11_N_SUPPORT
5872 if (pAdapter->CommonCfg.PhyMode == PHY_11AN_MIXED)
5873 pAdapter->CommonCfg.CentralChannel = 36;
5875 #endif // DOT11_N_SUPPORT //
5876 pAdapter->CommonCfg.CentralChannel = 6;
5878 #ifdef DOT11_N_SUPPORT
5880 N_ChannelCheck(pAdapter);
5881 #endif // DOT11_N_SUPPORT //
5883 #ifdef DOT11_N_SUPPORT
5884 if (pAdapter->CommonCfg.PhyMode >= PHY_11ABGN_MIXED &&
5885 pAdapter->CommonCfg.RegTransmitSetting.field.BW == BW_40 &&
5886 pAdapter->CommonCfg.RegTransmitSetting.field.EXTCHA == EXTCHA_ABOVE)
5888 // 40MHz ,control channel at lower
5889 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, BBP_R4, &bbpValue);
5890 bbpValue &= (~0x18);
5892 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R4, bbpValue);
5893 pAdapter->CommonCfg.BBPCurrentBW = BW_40;
5894 // RX : control channel at lower
5895 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, BBP_R3, &bbpValue);
5896 bbpValue &= (~0x20);
5897 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R3, bbpValue);
5899 RTMP_IO_READ32(pAdapter, TX_BAND_CFG, &Value);
5900 Value &= 0xfffffffe;
5901 RTMP_IO_WRITE32(pAdapter, TX_BAND_CFG, Value);
5902 pAdapter->CommonCfg.CentralChannel = pAdapter->CommonCfg.Channel + 2;
5903 AsicSwitchChannel(pAdapter, pAdapter->CommonCfg.CentralChannel, FALSE);
5904 AsicLockChannel(pAdapter, pAdapter->CommonCfg.CentralChannel);
5905 DBGPRINT(RT_DEBUG_TRACE, ("BW_40 ,control_channel(%d), CentralChannel(%d) \n",
5906 pAdapter->CommonCfg.Channel,
5907 pAdapter->CommonCfg.CentralChannel));
5909 else if (pAdapter->CommonCfg.PhyMode >= PHY_11ABGN_MIXED &&
5910 pAdapter->CommonCfg.RegTransmitSetting.field.BW == BW_40 &&
5911 pAdapter->CommonCfg.RegTransmitSetting.field.EXTCHA == EXTCHA_BELOW)
5913 // 40MHz ,control channel at upper
5914 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, BBP_R4, &bbpValue);
5915 bbpValue &= (~0x18);
5917 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R4, bbpValue);
5918 pAdapter->CommonCfg.BBPCurrentBW = BW_40;
5919 RTMP_IO_READ32(pAdapter, TX_BAND_CFG, &Value);
5921 RTMP_IO_WRITE32(pAdapter, TX_BAND_CFG, Value);
5923 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, BBP_R3, &bbpValue);
5925 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R3, bbpValue);
5926 pAdapter->CommonCfg.CentralChannel = pAdapter->CommonCfg.Channel - 2;
5927 AsicSwitchChannel(pAdapter, pAdapter->CommonCfg.CentralChannel, FALSE);
5928 AsicLockChannel(pAdapter, pAdapter->CommonCfg.CentralChannel);
5929 DBGPRINT(RT_DEBUG_TRACE, ("BW_40 ,control_channel(%d), CentralChannel(%d) \n",
5930 pAdapter->CommonCfg.Channel,
5931 pAdapter->CommonCfg.CentralChannel));
5934 #endif // DOT11_N_SUPPORT //
5937 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, BBP_R4, &bbpValue);
5938 bbpValue &= (~0x18);
5939 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R4, bbpValue);
5940 pAdapter->CommonCfg.BBPCurrentBW = BW_20;
5941 AsicSwitchChannel(pAdapter, pAdapter->CommonCfg.Channel, FALSE);
5942 AsicLockChannel(pAdapter, pAdapter->CommonCfg.Channel);
5943 DBGPRINT(RT_DEBUG_TRACE, ("BW_20, Channel(%d)\n", pAdapter->CommonCfg.Channel));
5945 // Enable Rx with promiscuous reception
5946 RTMP_IO_WRITE32(pAdapter, RX_FILTR_CFG, 0x3);
5947 // ASIC supporsts sniffer function with replacing RSSI with timestamp.
5948 //RTMP_IO_READ32(pAdapter, MAC_SYS_CTRL, &Value);
5950 //RTMP_IO_WRITE32(pAdapter, MAC_SYS_CTRL, Value);
5952 RTMP_IO_READ32(pAdapter, BCN_TIME_CFG, &csr.word);
5953 csr.field.bBeaconGen = 0;
5954 csr.field.bTBTTEnable = 0;
5955 csr.field.TsfSyncMode = 0;
5956 RTMP_IO_WRITE32(pAdapter, BCN_TIME_CFG, csr.word);
5958 pAdapter->StaCfg.BssType = BSS_MONITOR;
5959 pAdapter->net_dev->type = ARPHRD_IEEE80211_PRISM; //ARPHRD_IEEE80211; // IEEE80211
5960 DBGPRINT(RT_DEBUG_TRACE, ("===>Set_NetworkType_Proc::(MONITOR)\n"));
5963 // Reset Ralink supplicant to not use, it will be set to start when UI set PMK key
5964 pAdapter->StaCfg.WpaState = SS_NOTUSE;
5966 DBGPRINT(RT_DEBUG_TRACE, ("Set_NetworkType_Proc::(NetworkType=%d)\n", pAdapter->StaCfg.BssType));
5972 ==========================================================================
5974 Set Authentication mode
5976 TRUE if all parameters are OK, FALSE otherwise
5977 ==========================================================================
5979 INT Set_AuthMode_Proc(
5980 IN PRTMP_ADAPTER pAdapter,
5983 if ((strcmp(arg, "WEPAUTO") == 0) || (strcmp(arg, "wepauto") == 0))
5984 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeAutoSwitch;
5985 else if ((strcmp(arg, "OPEN") == 0) || (strcmp(arg, "open") == 0))
5986 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
5987 else if ((strcmp(arg, "SHARED") == 0) || (strcmp(arg, "shared") == 0))
5988 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeShared;
5989 else if ((strcmp(arg, "WPAPSK") == 0) || (strcmp(arg, "wpapsk") == 0))
5990 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPAPSK;
5991 else if ((strcmp(arg, "WPANONE") == 0) || (strcmp(arg, "wpanone") == 0))
5992 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPANone;
5993 else if ((strcmp(arg, "WPA2PSK") == 0) || (strcmp(arg, "wpa2psk") == 0))
5994 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA2PSK;
5995 #ifdef WPA_SUPPLICANT_SUPPORT
5996 else if ((strcmp(arg, "WPA") == 0) || (strcmp(arg, "wpa") == 0))
5997 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA;
5998 else if ((strcmp(arg, "WPA2") == 0) || (strcmp(arg, "wpa2") == 0))
5999 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA2;
6000 #endif // WPA_SUPPLICANT_SUPPORT //
6004 pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED;
6006 DBGPRINT(RT_DEBUG_TRACE, ("Set_AuthMode_Proc::(AuthMode=%d)\n", pAdapter->StaCfg.AuthMode));
6012 ==========================================================================
6016 TRUE if all parameters are OK, FALSE otherwise
6017 ==========================================================================
6019 INT Set_EncrypType_Proc(
6020 IN PRTMP_ADAPTER pAdapter,
6023 if ((strcmp(arg, "NONE") == 0) || (strcmp(arg, "none") == 0))
6025 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
6026 return TRUE; // do nothing
6028 pAdapter->StaCfg.WepStatus = Ndis802_11WEPDisabled;
6029 pAdapter->StaCfg.PairCipher = Ndis802_11WEPDisabled;
6030 pAdapter->StaCfg.GroupCipher = Ndis802_11WEPDisabled;
6032 else if ((strcmp(arg, "WEP") == 0) || (strcmp(arg, "wep") == 0))
6034 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
6035 return TRUE; // do nothing
6037 pAdapter->StaCfg.WepStatus = Ndis802_11WEPEnabled;
6038 pAdapter->StaCfg.PairCipher = Ndis802_11WEPEnabled;
6039 pAdapter->StaCfg.GroupCipher = Ndis802_11WEPEnabled;
6041 else if ((strcmp(arg, "TKIP") == 0) || (strcmp(arg, "tkip") == 0))
6043 if (pAdapter->StaCfg.AuthMode < Ndis802_11AuthModeWPA)
6044 return TRUE; // do nothing
6046 pAdapter->StaCfg.WepStatus = Ndis802_11Encryption2Enabled;
6047 pAdapter->StaCfg.PairCipher = Ndis802_11Encryption2Enabled;
6048 pAdapter->StaCfg.GroupCipher = Ndis802_11Encryption2Enabled;
6050 else if ((strcmp(arg, "AES") == 0) || (strcmp(arg, "aes") == 0))
6052 if (pAdapter->StaCfg.AuthMode < Ndis802_11AuthModeWPA)
6053 return TRUE; // do nothing
6055 pAdapter->StaCfg.WepStatus = Ndis802_11Encryption3Enabled;
6056 pAdapter->StaCfg.PairCipher = Ndis802_11Encryption3Enabled;
6057 pAdapter->StaCfg.GroupCipher = Ndis802_11Encryption3Enabled;
6062 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
6064 DBGPRINT(RT_DEBUG_TRACE, ("Set_EncrypType_Proc::(EncrypType=%d)\n", pAdapter->StaCfg.WepStatus));
6070 ==========================================================================
6074 TRUE if all parameters are OK, FALSE otherwise
6075 ==========================================================================
6077 INT Set_DefaultKeyID_Proc(
6078 IN PRTMP_ADAPTER pAdapter,
6083 KeyIdx = simple_strtol(arg, 0, 10);
6084 if((KeyIdx >= 1 ) && (KeyIdx <= 4))
6085 pAdapter->StaCfg.DefaultKeyId = (UCHAR) (KeyIdx - 1 );
6087 return FALSE; //Invalid argument
6089 DBGPRINT(RT_DEBUG_TRACE, ("Set_DefaultKeyID_Proc::(DefaultKeyID=%d)\n", pAdapter->StaCfg.DefaultKeyId));
6095 ==========================================================================
6099 TRUE if all parameters are OK, FALSE otherwise
6100 ==========================================================================
6103 IN PRTMP_ADAPTER pAdapter,
6108 UCHAR CipherAlg=CIPHER_WEP64;
6110 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
6111 return TRUE; // do nothing
6113 KeyLen = strlen(arg);
6117 case 5: //wep 40 Ascii type
6118 pAdapter->SharedKey[BSS0][0].KeyLen = KeyLen;
6119 memcpy(pAdapter->SharedKey[BSS0][0].Key, arg, KeyLen);
6120 CipherAlg = CIPHER_WEP64;
6121 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key1_Proc::(Key1=%s and type=%s)\n", arg, "Ascii"));
6123 case 10: //wep 40 Hex type
6124 for(i=0; i < KeyLen; i++)
6126 if( !isxdigit(*(arg+i)) )
6127 return FALSE; //Not Hex value;
6129 pAdapter->SharedKey[BSS0][0].KeyLen = KeyLen / 2 ;
6130 AtoH(arg, pAdapter->SharedKey[BSS0][0].Key, KeyLen / 2);
6131 CipherAlg = CIPHER_WEP64;
6132 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key1_Proc::(Key1=%s and type=%s)\n", arg, "Hex"));
6134 case 13: //wep 104 Ascii type
6135 pAdapter->SharedKey[BSS0][0].KeyLen = KeyLen;
6136 memcpy(pAdapter->SharedKey[BSS0][0].Key, arg, KeyLen);
6137 CipherAlg = CIPHER_WEP128;
6138 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key1_Proc::(Key1=%s and type=%s)\n", arg, "Ascii"));
6140 case 26: //wep 104 Hex type
6141 for(i=0; i < KeyLen; i++)
6143 if( !isxdigit(*(arg+i)) )
6144 return FALSE; //Not Hex value;
6146 pAdapter->SharedKey[BSS0][0].KeyLen = KeyLen / 2 ;
6147 AtoH(arg, pAdapter->SharedKey[BSS0][0].Key, KeyLen / 2);
6148 CipherAlg = CIPHER_WEP128;
6149 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key1_Proc::(Key1=%s and type=%s)\n", arg, "Hex"));
6151 default: //Invalid argument
6152 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key1_Proc::Invalid argument (=%s)\n", arg));
6156 pAdapter->SharedKey[BSS0][0].CipherAlg = CipherAlg;
6158 // Set keys (into ASIC)
6159 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
6161 else // Old WEP stuff
6163 AsicAddSharedKeyEntry(pAdapter,
6166 pAdapter->SharedKey[BSS0][0].CipherAlg,
6167 pAdapter->SharedKey[BSS0][0].Key,
6175 ==========================================================================
6180 TRUE if all parameters are OK, FALSE otherwise
6181 ==========================================================================
6184 IN PRTMP_ADAPTER pAdapter,
6189 UCHAR CipherAlg=CIPHER_WEP64;
6191 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
6192 return TRUE; // do nothing
6194 KeyLen = strlen(arg);
6198 case 5: //wep 40 Ascii type
6199 pAdapter->SharedKey[BSS0][1].KeyLen = KeyLen;
6200 memcpy(pAdapter->SharedKey[BSS0][1].Key, arg, KeyLen);
6201 CipherAlg = CIPHER_WEP64;
6202 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key2_Proc::(Key2=%s and type=%s)\n", arg, "Ascii"));
6204 case 10: //wep 40 Hex type
6205 for(i=0; i < KeyLen; i++)
6207 if( !isxdigit(*(arg+i)) )
6208 return FALSE; //Not Hex value;
6210 pAdapter->SharedKey[BSS0][1].KeyLen = KeyLen / 2 ;
6211 AtoH(arg, pAdapter->SharedKey[BSS0][1].Key, KeyLen / 2);
6212 CipherAlg = CIPHER_WEP64;
6213 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key2_Proc::(Key2=%s and type=%s)\n", arg, "Hex"));
6215 case 13: //wep 104 Ascii type
6216 pAdapter->SharedKey[BSS0][1].KeyLen = KeyLen;
6217 memcpy(pAdapter->SharedKey[BSS0][1].Key, arg, KeyLen);
6218 CipherAlg = CIPHER_WEP128;
6219 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key2_Proc::(Key2=%s and type=%s)\n", arg, "Ascii"));
6221 case 26: //wep 104 Hex type
6222 for(i=0; i < KeyLen; i++)
6224 if( !isxdigit(*(arg+i)) )
6225 return FALSE; //Not Hex value;
6227 pAdapter->SharedKey[BSS0][1].KeyLen = KeyLen / 2 ;
6228 AtoH(arg, pAdapter->SharedKey[BSS0][1].Key, KeyLen / 2);
6229 CipherAlg = CIPHER_WEP128;
6230 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key2_Proc::(Key2=%s and type=%s)\n", arg, "Hex"));
6232 default: //Invalid argument
6233 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key2_Proc::Invalid argument (=%s)\n", arg));
6236 pAdapter->SharedKey[BSS0][1].CipherAlg = CipherAlg;
6238 // Set keys (into ASIC)
6239 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
6241 else // Old WEP stuff
6243 AsicAddSharedKeyEntry(pAdapter,
6246 pAdapter->SharedKey[BSS0][1].CipherAlg,
6247 pAdapter->SharedKey[BSS0][1].Key,
6255 ==========================================================================
6259 TRUE if all parameters are OK, FALSE otherwise
6260 ==========================================================================
6263 IN PRTMP_ADAPTER pAdapter,
6268 UCHAR CipherAlg=CIPHER_WEP64;
6270 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
6271 return TRUE; // do nothing
6273 KeyLen = strlen(arg);
6277 case 5: //wep 40 Ascii type
6278 pAdapter->SharedKey[BSS0][2].KeyLen = KeyLen;
6279 memcpy(pAdapter->SharedKey[BSS0][2].Key, arg, KeyLen);
6280 CipherAlg = CIPHER_WEP64;
6281 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key3_Proc::(Key3=%s and type=Ascii)\n", arg));
6283 case 10: //wep 40 Hex type
6284 for(i=0; i < KeyLen; i++)
6286 if( !isxdigit(*(arg+i)) )
6287 return FALSE; //Not Hex value;
6289 pAdapter->SharedKey[BSS0][2].KeyLen = KeyLen / 2 ;
6290 AtoH(arg, pAdapter->SharedKey[BSS0][2].Key, KeyLen / 2);
6291 CipherAlg = CIPHER_WEP64;
6292 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key3_Proc::(Key3=%s and type=Hex)\n", arg));
6294 case 13: //wep 104 Ascii type
6295 pAdapter->SharedKey[BSS0][2].KeyLen = KeyLen;
6296 memcpy(pAdapter->SharedKey[BSS0][2].Key, arg, KeyLen);
6297 CipherAlg = CIPHER_WEP128;
6298 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key3_Proc::(Key3=%s and type=Ascii)\n", arg));
6300 case 26: //wep 104 Hex type
6301 for(i=0; i < KeyLen; i++)
6303 if( !isxdigit(*(arg+i)) )
6304 return FALSE; //Not Hex value;
6306 pAdapter->SharedKey[BSS0][2].KeyLen = KeyLen / 2 ;
6307 AtoH(arg, pAdapter->SharedKey[BSS0][2].Key, KeyLen / 2);
6308 CipherAlg = CIPHER_WEP128;
6309 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key3_Proc::(Key3=%s and type=Hex)\n", arg));
6311 default: //Invalid argument
6312 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key3_Proc::Invalid argument (=%s)\n", arg));
6315 pAdapter->SharedKey[BSS0][2].CipherAlg = CipherAlg;
6317 // Set keys (into ASIC)
6318 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
6320 else // Old WEP stuff
6322 AsicAddSharedKeyEntry(pAdapter,
6325 pAdapter->SharedKey[BSS0][2].CipherAlg,
6326 pAdapter->SharedKey[BSS0][2].Key,
6334 ==========================================================================
6338 TRUE if all parameters are OK, FALSE otherwise
6339 ==========================================================================
6342 IN PRTMP_ADAPTER pAdapter,
6347 UCHAR CipherAlg=CIPHER_WEP64;
6349 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
6350 return TRUE; // do nothing
6352 KeyLen = strlen(arg);
6356 case 5: //wep 40 Ascii type
6357 pAdapter->SharedKey[BSS0][3].KeyLen = KeyLen;
6358 memcpy(pAdapter->SharedKey[BSS0][3].Key, arg, KeyLen);
6359 CipherAlg = CIPHER_WEP64;
6360 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key4_Proc::(Key4=%s and type=%s)\n", arg, "Ascii"));
6362 case 10: //wep 40 Hex type
6363 for(i=0; i < KeyLen; i++)
6365 if( !isxdigit(*(arg+i)) )
6366 return FALSE; //Not Hex value;
6368 pAdapter->SharedKey[BSS0][3].KeyLen = KeyLen / 2 ;
6369 AtoH(arg, pAdapter->SharedKey[BSS0][3].Key, KeyLen / 2);
6370 CipherAlg = CIPHER_WEP64;
6371 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key4_Proc::(Key4=%s and type=%s)\n", arg, "Hex"));
6373 case 13: //wep 104 Ascii type
6374 pAdapter->SharedKey[BSS0][3].KeyLen = KeyLen;
6375 memcpy(pAdapter->SharedKey[BSS0][3].Key, arg, KeyLen);
6376 CipherAlg = CIPHER_WEP128;
6377 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key4_Proc::(Key4=%s and type=%s)\n", arg, "Ascii"));
6379 case 26: //wep 104 Hex type
6380 for(i=0; i < KeyLen; i++)
6382 if( !isxdigit(*(arg+i)) )
6383 return FALSE; //Not Hex value;
6385 pAdapter->SharedKey[BSS0][3].KeyLen = KeyLen / 2 ;
6386 AtoH(arg, pAdapter->SharedKey[BSS0][3].Key, KeyLen / 2);
6387 CipherAlg = CIPHER_WEP128;
6388 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key4_Proc::(Key4=%s and type=%s)\n", arg, "Hex"));
6390 default: //Invalid argument
6391 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key4_Proc::Invalid argument (=%s)\n", arg));
6394 pAdapter->SharedKey[BSS0][3].CipherAlg = CipherAlg;
6396 // Set keys (into ASIC)
6397 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
6399 else // Old WEP stuff
6401 AsicAddSharedKeyEntry(pAdapter,
6404 pAdapter->SharedKey[BSS0][3].CipherAlg,
6405 pAdapter->SharedKey[BSS0][3].Key,
6414 ==========================================================================
6418 TRUE if all parameters are OK, FALSE otherwise
6419 ==========================================================================
6421 INT Set_WPAPSK_Proc(
6422 IN PRTMP_ADAPTER pAdapter,
6425 UCHAR keyMaterial[40];
6427 if ((pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPAPSK) &&
6428 (pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPA2PSK) &&
6429 (pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPANone)
6431 return TRUE; // do nothing
6433 DBGPRINT(RT_DEBUG_TRACE, ("Set_WPAPSK_Proc::(WPAPSK=%s)\n", arg));
6435 NdisZeroMemory(keyMaterial, 40);
6437 if ((strlen(arg) < 8) || (strlen(arg) > 64))
6439 DBGPRINT(RT_DEBUG_TRACE, ("Set failed!!(WPAPSK=%s), WPAPSK key-string required 8 ~ 64 characters \n", arg));
6443 if (strlen(arg) == 64)
6445 AtoH(arg, keyMaterial, 32);
6446 NdisMoveMemory(pAdapter->StaCfg.PMK, keyMaterial, 32);
6451 PasswordHash((char *)arg, pAdapter->MlmeAux.Ssid, pAdapter->MlmeAux.SsidLen, keyMaterial);
6452 NdisMoveMemory(pAdapter->StaCfg.PMK, keyMaterial, 32);
6457 if(pAdapter->StaCfg.BssType == BSS_ADHOC &&
6458 pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPANone)
6460 pAdapter->StaCfg.WpaState = SS_NOTUSE;
6464 // Start STA supplicant state machine
6465 pAdapter->StaCfg.WpaState = SS_START;
6472 ==========================================================================
6474 Set Power Saving mode
6476 TRUE if all parameters are OK, FALSE otherwise
6477 ==========================================================================
6479 INT Set_PSMode_Proc(
6480 IN PRTMP_ADAPTER pAdapter,
6483 if (pAdapter->StaCfg.BssType == BSS_INFRA)
6485 if ((strcmp(arg, "Max_PSP") == 0) ||
6486 (strcmp(arg, "max_psp") == 0) ||
6487 (strcmp(arg, "MAX_PSP") == 0))
6489 // do NOT turn on PSM bit here, wait until MlmeCheckForPsmChange()
6490 // to exclude certain situations.
6491 if (pAdapter->StaCfg.bWindowsACCAMEnable == FALSE)
6492 pAdapter->StaCfg.WindowsPowerMode = Ndis802_11PowerModeMAX_PSP;
6493 pAdapter->StaCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeMAX_PSP;
6494 OPSTATUS_SET_FLAG(pAdapter, fOP_STATUS_RECEIVE_DTIM);
6495 pAdapter->StaCfg.DefaultListenCount = 5;
6498 else if ((strcmp(arg, "Fast_PSP") == 0) ||
6499 (strcmp(arg, "fast_psp") == 0) ||
6500 (strcmp(arg, "FAST_PSP") == 0))
6502 // do NOT turn on PSM bit here, wait until MlmeCheckForPsmChange()
6503 // to exclude certain situations.
6504 OPSTATUS_SET_FLAG(pAdapter, fOP_STATUS_RECEIVE_DTIM);
6505 if (pAdapter->StaCfg.bWindowsACCAMEnable == FALSE)
6506 pAdapter->StaCfg.WindowsPowerMode = Ndis802_11PowerModeFast_PSP;
6507 pAdapter->StaCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeFast_PSP;
6508 pAdapter->StaCfg.DefaultListenCount = 3;
6510 else if ((strcmp(arg, "Legacy_PSP") == 0) ||
6511 (strcmp(arg, "legacy_psp") == 0) ||
6512 (strcmp(arg, "LEGACY_PSP") == 0))
6514 // do NOT turn on PSM bit here, wait until MlmeCheckForPsmChange()
6515 // to exclude certain situations.
6516 OPSTATUS_SET_FLAG(pAdapter, fOP_STATUS_RECEIVE_DTIM);
6517 if (pAdapter->StaCfg.bWindowsACCAMEnable == FALSE)
6518 pAdapter->StaCfg.WindowsPowerMode = Ndis802_11PowerModeLegacy_PSP;
6519 pAdapter->StaCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeLegacy_PSP;
6520 pAdapter->StaCfg.DefaultListenCount = 3;
6524 //Default Ndis802_11PowerModeCAM
6525 // clear PSM bit immediately
6526 MlmeSetPsmBit(pAdapter, PWR_ACTIVE);
6527 OPSTATUS_SET_FLAG(pAdapter, fOP_STATUS_RECEIVE_DTIM);
6528 if (pAdapter->StaCfg.bWindowsACCAMEnable == FALSE)
6529 pAdapter->StaCfg.WindowsPowerMode = Ndis802_11PowerModeCAM;
6530 pAdapter->StaCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeCAM;
6533 DBGPRINT(RT_DEBUG_TRACE, ("Set_PSMode_Proc::(PSMode=%ld)\n", pAdapter->StaCfg.WindowsPowerMode));
6542 #ifdef WPA_SUPPLICANT_SUPPORT
6544 ==========================================================================
6546 Set WpaSupport flag.
6548 0: Driver ignore wpa_supplicant.
6549 1: wpa_supplicant initiates scanning and AP selection.
6550 2: driver takes care of scanning, AP selection, and IEEE 802.11 association parameters.
6552 TRUE if all parameters are OK, FALSE otherwise
6553 ==========================================================================
6555 INT Set_Wpa_Support(
6556 IN PRTMP_ADAPTER pAd,
6560 if ( simple_strtol(arg, 0, 10) == 0)
6561 pAd->StaCfg.WpaSupplicantUP = WPA_SUPPLICANT_DISABLE;
6562 else if ( simple_strtol(arg, 0, 10) == 1)
6563 pAd->StaCfg.WpaSupplicantUP = WPA_SUPPLICANT_ENABLE;
6564 else if ( simple_strtol(arg, 0, 10) == 2)
6565 pAd->StaCfg.WpaSupplicantUP = WPA_SUPPLICANT_ENABLE_WITH_WEB_UI;
6567 pAd->StaCfg.WpaSupplicantUP = WPA_SUPPLICANT_DISABLE;
6569 DBGPRINT(RT_DEBUG_TRACE, ("Set_Wpa_Support::(WpaSupplicantUP=%d)\n", pAd->StaCfg.WpaSupplicantUP));
6573 #endif // WPA_SUPPLICANT_SUPPORT //
6577 ==========================================================================
6581 pAdapter Pointer to our adapter
6582 wrq Pointer to the ioctl argument
6589 1.) iwpriv ra0 mac 0 ==> read MAC where Addr=0x0
6590 2.) iwpriv ra0 mac 0=12 ==> write MAC where Addr=0x0, value=12
6591 ==========================================================================
6594 IN PRTMP_ADAPTER pAdapter,
6595 IN struct iwreq *wrq)
6603 UCHAR temp[16], temp2[16];
6604 UINT32 macValue = 0;
6608 memset(msg, 0x00, 1024);
6609 if (wrq->u.data.length > 1) //No parameters.
6611 Status = copy_from_user(arg, wrq->u.data.pointer, (wrq->u.data.length > 255) ? 255 : wrq->u.data.length);
6614 //Parsing Read or Write
6619 if ((value = rtstrchr(this_char, '=')) != NULL)
6622 if (!value || !*value)
6625 if(strlen(this_char) > 4)
6628 j = strlen(this_char);
6631 if(this_char[j] > 'f' || this_char[j] < '0')
6636 k = j = strlen(this_char);
6639 this_char[4-k+j] = this_char[j];
6643 this_char[3-k++]='0';
6646 if(strlen(this_char) == 4)
6648 AtoH(this_char, temp, 2);
6649 macAddr = *temp*256 + temp[1];
6650 if (macAddr < 0xFFFF)
6652 RTMP_IO_READ32(pAdapter, macAddr, &macValue);
6653 DBGPRINT(RT_DEBUG_TRACE, ("MacAddr=%lx, MacValue=%x\n", macAddr, macValue));
6654 sprintf(msg+strlen(msg), "[0x%08lX]:%08X ", macAddr , macValue);
6657 {//Invalid parametes, so default printk all bbp
6664 memcpy(&temp2, value, strlen(value));
6665 temp2[strlen(value)] = '\0';
6668 if((strlen(this_char) > 4) || strlen(temp2) > 8)
6671 j = strlen(this_char);
6674 if(this_char[j] > 'f' || this_char[j] < '0')
6681 if(temp2[j] > 'f' || temp2[j] < '0')
6686 k = j = strlen(this_char);
6689 this_char[4-k+j] = this_char[j];
6693 this_char[3-k++]='0';
6697 k = j = strlen(temp2);
6700 temp2[8-k+j] = temp2[j];
6708 AtoH(this_char, temp, 2);
6709 macAddr = *temp*256 + temp[1];
6711 AtoH(temp2, temp, 4);
6712 macValue = *temp*256*256*256 + temp[1]*256*256 + temp[2]*256 + temp[3];
6715 if (macAddr == (HW_DEBUG_SETTING_BASE + 4))
6717 // 0x2bf4: byte0 non-zero: enable R17 tuning, 0: disable R17 tuning
6718 if (macValue & 0x000000ff)
6720 pAdapter->BbpTuning.bEnable = TRUE;
6721 DBGPRINT(RT_DEBUG_TRACE,("turn on R17 tuning\n"));
6726 pAdapter->BbpTuning.bEnable = FALSE;
6727 R66 = 0x26 + GET_LNA_GAIN(pAdapter);
6729 if (ATE_ON(pAdapter))
6731 ATE_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R66, (0x26 + GET_LNA_GAIN(pAdapter)));
6734 #endif // RALINK_ATE //
6735 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R66, (0x26 + GET_LNA_GAIN(pAdapter)));
6736 DBGPRINT(RT_DEBUG_TRACE,("turn off R17 tuning, restore to 0x%02x\n", R66));
6741 DBGPRINT(RT_DEBUG_TRACE, ("MacAddr=%02lx, MacValue=0x%x\n", macAddr, macValue));
6743 RTMP_IO_WRITE32(pAdapter, macAddr, macValue);
6744 sprintf(msg+strlen(msg), "[0x%08lX]:%08X ", macAddr, macValue);
6749 if(strlen(msg) == 1)
6750 sprintf(msg+strlen(msg), "===>Error command format!");
6752 // Copy the information into the user buffer
6753 wrq->u.data.length = strlen(msg);
6754 Status = copy_to_user(wrq->u.data.pointer, msg, wrq->u.data.length);
6756 DBGPRINT(RT_DEBUG_TRACE, ("<==RTMPIoctlMAC\n\n"));
6760 ==========================================================================
6764 pAdapter Pointer to our adapter
6765 wrq Pointer to the ioctl argument
6772 1.) iwpriv ra0 e2p 0 ==> read E2PROM where Addr=0x0
6773 2.) iwpriv ra0 e2p 0=1234 ==> write E2PROM where Addr=0x0, value=1234
6774 ==========================================================================
6776 VOID RTMPIoctlE2PROM(
6777 IN PRTMP_ADAPTER pAdapter,
6778 IN struct iwreq *wrq)
6786 UCHAR temp[16], temp2[16];
6791 memset(msg, 0x00, 1024);
6792 if (wrq->u.data.length > 1) //No parameters.
6794 Status = copy_from_user(arg, wrq->u.data.pointer, (wrq->u.data.length > 255) ? 255 : wrq->u.data.length);
6797 //Parsing Read or Write
6804 if ((value = rtstrchr(this_char, '=')) != NULL)
6807 if (!value || !*value)
6811 if(strlen(this_char) > 4)
6814 j = strlen(this_char);
6817 if(this_char[j] > 'f' || this_char[j] < '0')
6822 k = j = strlen(this_char);
6825 this_char[4-k+j] = this_char[j];
6829 this_char[3-k++]='0';
6832 if(strlen(this_char) == 4)
6834 AtoH(this_char, temp, 2);
6835 eepAddr = *temp*256 + temp[1];
6836 if (eepAddr < 0xFFFF)
6838 RT28xx_EEPROM_READ16(pAdapter, eepAddr, eepValue);
6839 sprintf(msg+strlen(msg), "[0x%04X]:0x%04X ", eepAddr , eepValue);
6842 {//Invalid parametes, so default printk all bbp
6849 memcpy(&temp2, value, strlen(value));
6850 temp2[strlen(value)] = '\0';
6853 if((strlen(this_char) > 4) || strlen(temp2) > 8)
6856 j = strlen(this_char);
6859 if(this_char[j] > 'f' || this_char[j] < '0')
6865 if(temp2[j] > 'f' || temp2[j] < '0')
6870 k = j = strlen(this_char);
6873 this_char[4-k+j] = this_char[j];
6877 this_char[3-k++]='0';
6881 k = j = strlen(temp2);
6884 temp2[4-k+j] = temp2[j];
6891 AtoH(this_char, temp, 2);
6892 eepAddr = *temp*256 + temp[1];
6894 AtoH(temp2, temp, 2);
6895 eepValue = *temp*256 + temp[1];
6897 RT28xx_EEPROM_WRITE16(pAdapter, eepAddr, eepValue);
6898 sprintf(msg+strlen(msg), "[0x%02X]:%02X ", eepAddr, eepValue);
6902 if(strlen(msg) == 1)
6903 sprintf(msg+strlen(msg), "===>Error command format!");
6906 // Copy the information into the user buffer
6907 wrq->u.data.length = strlen(msg);
6908 Status = copy_to_user(wrq->u.data.pointer, msg, wrq->u.data.length);
6910 DBGPRINT(RT_DEBUG_TRACE, ("<==RTMPIoctlE2PROM\n"));
6917 INT Set_TGnWifiTest_Proc(
6918 IN PRTMP_ADAPTER pAd,
6921 if (simple_strtol(arg, 0, 10) == 0)
6922 pAd->StaCfg.bTGnWifiTest = FALSE;
6924 pAd->StaCfg.bTGnWifiTest = TRUE;
6926 DBGPRINT(RT_DEBUG_TRACE, ("IF Set_TGnWifiTest_Proc::(bTGnWifiTest=%d)\n", pAd->StaCfg.bTGnWifiTest));
6930 INT Set_LongRetryLimit_Proc(
6931 IN PRTMP_ADAPTER pAdapter,
6934 TX_RTY_CFG_STRUC tx_rty_cfg;
6935 UCHAR LongRetryLimit = (UCHAR)simple_strtol(arg, 0, 10);
6937 RTMP_IO_READ32(pAdapter, TX_RTY_CFG, &tx_rty_cfg.word);
6938 tx_rty_cfg.field.LongRtyLimit = LongRetryLimit;
6939 RTMP_IO_WRITE32(pAdapter, TX_RTY_CFG, tx_rty_cfg.word);
6940 DBGPRINT(RT_DEBUG_TRACE, ("IF Set_LongRetryLimit_Proc::(tx_rty_cfg=0x%x)\n", tx_rty_cfg.word));
6944 INT Set_ShortRetryLimit_Proc(
6945 IN PRTMP_ADAPTER pAdapter,
6948 TX_RTY_CFG_STRUC tx_rty_cfg;
6949 UCHAR ShortRetryLimit = (UCHAR)simple_strtol(arg, 0, 10);
6951 RTMP_IO_READ32(pAdapter, TX_RTY_CFG, &tx_rty_cfg.word);
6952 tx_rty_cfg.field.ShortRtyLimit = ShortRetryLimit;
6953 RTMP_IO_WRITE32(pAdapter, TX_RTY_CFG, tx_rty_cfg.word);
6954 DBGPRINT(RT_DEBUG_TRACE, ("IF Set_ShortRetryLimit_Proc::(tx_rty_cfg=0x%x)\n", tx_rty_cfg.word));
6958 #ifdef EXT_BUILD_CHANNEL_LIST
6959 INT Set_Ieee80211dClientMode_Proc(
6960 IN PRTMP_ADAPTER pAdapter,
6963 if (simple_strtol(arg, 0, 10) == 0)
6964 pAdapter->StaCfg.IEEE80211dClientMode = Rt802_11_D_None;
6965 else if (simple_strtol(arg, 0, 10) == 1)
6966 pAdapter->StaCfg.IEEE80211dClientMode = Rt802_11_D_Flexible;
6967 else if (simple_strtol(arg, 0, 10) == 2)
6968 pAdapter->StaCfg.IEEE80211dClientMode = Rt802_11_D_Strict;
6972 DBGPRINT(RT_DEBUG_TRACE, ("Set_Ieee802dMode_Proc::(IEEEE0211dMode=%d)\n", pAdapter->StaCfg.IEEE80211dClientMode));
6975 #endif // EXT_BUILD_CHANNEL_LIST //
6977 #ifdef CARRIER_DETECTION_SUPPORT
6978 INT Set_CarrierDetect_Proc(
6979 IN PRTMP_ADAPTER pAd,
6982 if (simple_strtol(arg, 0, 10) == 0)
6983 pAd->CommonCfg.CarrierDetect.Enable = FALSE;
6985 pAd->CommonCfg.CarrierDetect.Enable = TRUE;
6987 DBGPRINT(RT_DEBUG_TRACE, ("IF Set_CarrierDetect_Proc::(CarrierDetect.Enable=%d)\n", pAd->CommonCfg.CarrierDetect.Enable));
6990 #endif // CARRIER_DETECTION_SUPPORT //