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 #define IWE_STREAM_ADD_EVENT(_A, _B, _C, _D, _E) iwe_stream_add_event(_A, _B, _C, _D, _E)
53 #define IWE_STREAM_ADD_POINT(_A, _B, _C, _D, _E) iwe_stream_add_point(_A, _B, _C, _D, _E)
54 #define IWE_STREAM_ADD_VALUE(_A, _B, _C, _D, _E, _F) iwe_stream_add_value(_A, _B, _C, _D, _E, _F)
56 extern UCHAR CipherWpa2Template[];
57 extern UCHAR CipherWpaPskTkip[];
58 extern UCHAR CipherWpaPskTkipLen;
60 typedef struct PACKED _RT_VERSION_INFO{
66 UINT DriverBuildMonth;
68 } RT_VERSION_INFO, *PRT_VERSION_INFO;
70 struct iw_priv_args privtab[] = {
72 IW_PRIV_TYPE_CHAR | 1024, 0,
75 { RTPRIV_IOCTL_SHOW, 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK,
77 { RTPRIV_IOCTL_SHOW, IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK,
79 /* --- sub-ioctls definitions --- */
81 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "connStatus" },
83 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "driverVer" },
85 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "bainfo" },
87 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "descinfo" },
89 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "radio_off" },
91 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "radio_on" },
92 #ifdef QOS_DLS_SUPPORT
93 { SHOW_DLS_ENTRY_INFO,
94 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "dlsentryinfo" },
95 #endif // QOS_DLS_SUPPORT //
97 IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "show" },
98 { SHOW_ADHOC_ENTRY_INFO,
99 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "adhocEntry" },
101 /* --- sub-ioctls relations --- */
105 IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK,
108 IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | 1024,
111 IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | 1024,
115 { RTPRIV_IOCTL_STATISTICS,
116 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK,
118 { RTPRIV_IOCTL_GSITESURVEY,
119 0, IW_PRIV_TYPE_CHAR | 1024,
124 IN PRTMP_ADAPTER pAdapter,
128 INT Set_WmmCapable_Proc(
129 IN PRTMP_ADAPTER pAd,
133 INT Set_NetworkType_Proc(
134 IN PRTMP_ADAPTER pAdapter,
137 INT Set_AuthMode_Proc(
138 IN PRTMP_ADAPTER pAdapter,
141 INT Set_EncrypType_Proc(
142 IN PRTMP_ADAPTER pAdapter,
145 INT Set_DefaultKeyID_Proc(
146 IN PRTMP_ADAPTER pAdapter,
150 IN PRTMP_ADAPTER pAdapter,
154 IN PRTMP_ADAPTER pAdapter,
158 IN PRTMP_ADAPTER pAdapter,
162 IN PRTMP_ADAPTER pAdapter,
166 IN PRTMP_ADAPTER pAdapter,
171 IN PRTMP_ADAPTER pAdapter,
174 #ifdef WPA_SUPPLICANT_SUPPORT
176 IN PRTMP_ADAPTER pAd,
178 #endif // WPA_SUPPLICANT_SUPPORT //
182 IN PRTMP_ADAPTER pAdapter,
183 IN struct iwreq *wrq);
186 IN PRTMP_ADAPTER pAdapter,
187 IN struct iwreq *wrq);
189 VOID RTMPIoctlE2PROM(
190 IN PRTMP_ADAPTER pAdapter,
191 IN struct iwreq *wrq);
195 NDIS_STATUS RTMPWPANoneAddKeyProc(
196 IN PRTMP_ADAPTER pAd,
199 INT Set_FragTest_Proc(
200 IN PRTMP_ADAPTER pAdapter,
203 #ifdef DOT11_N_SUPPORT
204 INT Set_TGnWifiTest_Proc(
205 IN PRTMP_ADAPTER pAd,
207 #endif // DOT11_N_SUPPORT //
209 INT Set_LongRetryLimit_Proc(
210 IN PRTMP_ADAPTER pAdapter,
213 INT Set_ShortRetryLimit_Proc(
214 IN PRTMP_ADAPTER pAdapter,
217 #ifdef EXT_BUILD_CHANNEL_LIST
218 INT Set_Ieee80211dClientMode_Proc(
219 IN PRTMP_ADAPTER pAdapter,
221 #endif // EXT_BUILD_CHANNEL_LIST //
223 #ifdef CARRIER_DETECTION_SUPPORT
224 INT Set_CarrierDetect_Proc(
225 IN PRTMP_ADAPTER pAd,
227 #endif // CARRIER_DETECTION_SUPPORT //
229 INT Show_Adhoc_MacTable_Proc(
230 IN PRTMP_ADAPTER pAd,
235 INT (*set_proc)(PRTMP_ADAPTER pAdapter, PUCHAR arg);
236 } *PRTMP_PRIVATE_SET_PROC, RTMP_PRIVATE_SUPPORT_PROC[] = {
237 {"DriverVersion", Set_DriverVersion_Proc},
238 {"CountryRegion", Set_CountryRegion_Proc},
239 {"CountryRegionABand", Set_CountryRegionABand_Proc},
240 {"SSID", Set_SSID_Proc},
241 {"WirelessMode", Set_WirelessMode_Proc},
242 {"TxBurst", Set_TxBurst_Proc},
243 {"TxPreamble", Set_TxPreamble_Proc},
244 {"TxPower", Set_TxPower_Proc},
245 {"Channel", Set_Channel_Proc},
246 {"BGProtection", Set_BGProtection_Proc},
247 {"RTSThreshold", Set_RTSThreshold_Proc},
248 {"FragThreshold", Set_FragThreshold_Proc},
249 #ifdef DOT11_N_SUPPORT
250 {"HtBw", Set_HtBw_Proc},
251 {"HtMcs", Set_HtMcs_Proc},
252 {"HtGi", Set_HtGi_Proc},
253 {"HtOpMode", Set_HtOpMode_Proc},
254 {"HtExtcha", Set_HtExtcha_Proc},
255 {"HtMpduDensity", Set_HtMpduDensity_Proc},
256 {"HtBaWinSize", Set_HtBaWinSize_Proc},
257 {"HtRdg", Set_HtRdg_Proc},
258 {"HtAmsdu", Set_HtAmsdu_Proc},
259 {"HtAutoBa", Set_HtAutoBa_Proc},
260 {"HtBaDecline", Set_BADecline_Proc},
261 {"HtProtect", Set_HtProtect_Proc},
262 {"HtMimoPs", Set_HtMimoPs_Proc},
263 #endif // DOT11_N_SUPPORT //
265 #ifdef AGGREGATION_SUPPORT
266 {"PktAggregate", Set_PktAggregate_Proc},
270 {"WmmCapable", Set_WmmCapable_Proc},
272 {"IEEE80211H", Set_IEEE80211H_Proc},
273 {"NetworkType", Set_NetworkType_Proc},
274 {"AuthMode", Set_AuthMode_Proc},
275 {"EncrypType", Set_EncrypType_Proc},
276 {"DefaultKeyID", Set_DefaultKeyID_Proc},
277 {"Key1", Set_Key1_Proc},
278 {"Key2", Set_Key2_Proc},
279 {"Key3", Set_Key3_Proc},
280 {"Key4", Set_Key4_Proc},
281 {"WPAPSK", Set_WPAPSK_Proc},
282 {"ResetCounter", Set_ResetStatCounter_Proc},
283 {"PSMode", Set_PSMode_Proc},
285 {"Debug", Set_Debug_Proc},
289 {"ATE", Set_ATE_Proc},
290 {"ATEDA", Set_ATE_DA_Proc},
291 {"ATESA", Set_ATE_SA_Proc},
292 {"ATEBSSID", Set_ATE_BSSID_Proc},
293 {"ATECHANNEL", Set_ATE_CHANNEL_Proc},
294 {"ATETXPOW0", Set_ATE_TX_POWER0_Proc},
295 {"ATETXPOW1", Set_ATE_TX_POWER1_Proc},
296 {"ATETXANT", Set_ATE_TX_Antenna_Proc},
297 {"ATERXANT", Set_ATE_RX_Antenna_Proc},
298 {"ATETXFREQOFFSET", Set_ATE_TX_FREQOFFSET_Proc},
299 {"ATETXBW", Set_ATE_TX_BW_Proc},
300 {"ATETXLEN", Set_ATE_TX_LENGTH_Proc},
301 {"ATETXCNT", Set_ATE_TX_COUNT_Proc},
302 {"ATETXMCS", Set_ATE_TX_MCS_Proc},
303 {"ATETXMODE", Set_ATE_TX_MODE_Proc},
304 {"ATETXGI", Set_ATE_TX_GI_Proc},
305 {"ATERXFER", Set_ATE_RX_FER_Proc},
306 {"ATERRF", Set_ATE_Read_RF_Proc},
307 {"ATEWRF1", Set_ATE_Write_RF1_Proc},
308 {"ATEWRF2", Set_ATE_Write_RF2_Proc},
309 {"ATEWRF3", Set_ATE_Write_RF3_Proc},
310 {"ATEWRF4", Set_ATE_Write_RF4_Proc},
311 {"ATELDE2P", Set_ATE_Load_E2P_Proc},
312 {"ATERE2P", Set_ATE_Read_E2P_Proc},
313 {"ATESHOW", Set_ATE_Show_Proc},
314 {"ATEHELP", Set_ATE_Help_Proc},
316 #ifdef RALINK_28xx_QA
317 {"TxStop", Set_TxStop_Proc},
318 {"RxStop", Set_RxStop_Proc},
319 #endif // RALINK_28xx_QA //
320 #endif // RALINK_ATE //
322 #ifdef WPA_SUPPLICANT_SUPPORT
323 {"WpaSupport", Set_Wpa_Support},
324 #endif // WPA_SUPPLICANT_SUPPORT //
328 {"FixedTxMode", Set_FixedTxMode_Proc},
329 #ifdef CONFIG_APSTA_MIXED_SUPPORT
330 {"OpMode", Set_OpMode_Proc},
331 #endif // CONFIG_APSTA_MIXED_SUPPORT //
332 #ifdef DOT11_N_SUPPORT
333 {"TGnWifiTest", Set_TGnWifiTest_Proc},
334 {"ForceGF", Set_ForceGF_Proc},
335 #endif // DOT11_N_SUPPORT //
336 #ifdef QOS_DLS_SUPPORT
337 {"DlsAddEntry", Set_DlsAddEntry_Proc},
338 {"DlsTearDownEntry", Set_DlsTearDownEntry_Proc},
339 #endif // QOS_DLS_SUPPORT //
340 {"LongRetry", Set_LongRetryLimit_Proc},
341 {"ShortRetry", Set_ShortRetryLimit_Proc},
342 #ifdef EXT_BUILD_CHANNEL_LIST
343 {"11dClientMode", Set_Ieee80211dClientMode_Proc},
344 #endif // EXT_BUILD_CHANNEL_LIST //
345 #ifdef CARRIER_DETECTION_SUPPORT
346 {"CarrierDetect", Set_CarrierDetect_Proc},
347 #endif // CARRIER_DETECTION_SUPPORT //
354 IN PRTMP_ADAPTER pAd,
355 IN PNDIS_802_11_KEY pKey)
358 MAC_TABLE_ENTRY *pEntry;
360 DBGPRINT(RT_DEBUG_TRACE, ("RTMPAddKey ------>\n"));
362 if (pAd->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
364 if (pKey->KeyIndex & 0x80000000)
366 if (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPANone)
368 NdisZeroMemory(pAd->StaCfg.PMK, 32);
369 NdisMoveMemory(pAd->StaCfg.PMK, pKey->KeyMaterial, pKey->KeyLength);
373 NdisZeroMemory(&pAd->SharedKey[BSS0][0], sizeof(CIPHER_KEY));
374 pAd->SharedKey[BSS0][0].KeyLen = LEN_TKIP_EK;
375 NdisMoveMemory(pAd->SharedKey[BSS0][0].Key, pKey->KeyMaterial, LEN_TKIP_EK);
376 #ifdef WPA_SUPPLICANT_SUPPORT
377 if (pAd->StaCfg.PairCipher == Ndis802_11Encryption2Enabled)
379 NdisMoveMemory(pAd->SharedKey[BSS0][0].RxMic, pKey->KeyMaterial + LEN_TKIP_EK, LEN_TKIP_TXMICK);
380 NdisMoveMemory(pAd->SharedKey[BSS0][0].TxMic, pKey->KeyMaterial + LEN_TKIP_EK + LEN_TKIP_TXMICK, LEN_TKIP_RXMICK);
383 #endif // WPA_SUPPLICANT_SUPPORT //
385 NdisMoveMemory(pAd->SharedKey[BSS0][0].TxMic, pKey->KeyMaterial + LEN_TKIP_EK, LEN_TKIP_TXMICK);
386 NdisMoveMemory(pAd->SharedKey[BSS0][0].RxMic, pKey->KeyMaterial + LEN_TKIP_EK + LEN_TKIP_TXMICK, LEN_TKIP_RXMICK);
389 // Decide its ChiperAlg
390 if (pAd->StaCfg.PairCipher == Ndis802_11Encryption2Enabled)
391 pAd->SharedKey[BSS0][0].CipherAlg = CIPHER_TKIP;
392 else if (pAd->StaCfg.PairCipher == Ndis802_11Encryption3Enabled)
393 pAd->SharedKey[BSS0][0].CipherAlg = CIPHER_AES;
395 pAd->SharedKey[BSS0][0].CipherAlg = CIPHER_NONE;
397 // Update these related information to MAC_TABLE_ENTRY
398 pEntry = &pAd->MacTab.Content[BSSID_WCID];
399 NdisMoveMemory(pEntry->PairwiseKey.Key, pAd->SharedKey[BSS0][0].Key, LEN_TKIP_EK);
400 NdisMoveMemory(pEntry->PairwiseKey.RxMic, pAd->SharedKey[BSS0][0].RxMic, LEN_TKIP_RXMICK);
401 NdisMoveMemory(pEntry->PairwiseKey.TxMic, pAd->SharedKey[BSS0][0].TxMic, LEN_TKIP_TXMICK);
402 pEntry->PairwiseKey.CipherAlg = pAd->SharedKey[BSS0][0].CipherAlg;
404 // Update pairwise key information to ASIC Shared Key Table
405 AsicAddSharedKeyEntry(pAd,
408 pAd->SharedKey[BSS0][0].CipherAlg,
409 pAd->SharedKey[BSS0][0].Key,
410 pAd->SharedKey[BSS0][0].TxMic,
411 pAd->SharedKey[BSS0][0].RxMic);
413 // Update ASIC WCID attribute table and IVEIV table
414 RTMPAddWcidAttributeEntry(pAd,
417 pAd->SharedKey[BSS0][0].CipherAlg,
420 if (pAd->StaCfg.AuthMode >= Ndis802_11AuthModeWPA2)
422 // set 802.1x port control
423 //pAd->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
424 STA_PORT_SECURED(pAd);
426 // Indicate Connected for GUI
427 pAd->IndicateMediaState = NdisMediaStateConnected;
433 pAd->StaCfg.DefaultKeyId = (pKey->KeyIndex & 0xFF);
434 NdisZeroMemory(&pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId], sizeof(CIPHER_KEY));
435 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].KeyLen = LEN_TKIP_EK;
436 NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].Key, pKey->KeyMaterial, LEN_TKIP_EK);
437 #ifdef WPA_SUPPLICANT_SUPPORT
438 if (pAd->StaCfg.GroupCipher == Ndis802_11Encryption2Enabled)
440 NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].RxMic, pKey->KeyMaterial + LEN_TKIP_EK, LEN_TKIP_TXMICK);
441 NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].TxMic, pKey->KeyMaterial + LEN_TKIP_EK + LEN_TKIP_TXMICK, LEN_TKIP_RXMICK);
444 #endif // WPA_SUPPLICANT_SUPPORT //
446 NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].TxMic, pKey->KeyMaterial + LEN_TKIP_EK, LEN_TKIP_TXMICK);
447 NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].RxMic, pKey->KeyMaterial + LEN_TKIP_EK + LEN_TKIP_TXMICK, LEN_TKIP_RXMICK);
450 // Update Shared Key CipherAlg
451 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg = CIPHER_NONE;
452 if (pAd->StaCfg.GroupCipher == Ndis802_11Encryption2Enabled)
453 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg = CIPHER_TKIP;
454 else if (pAd->StaCfg.GroupCipher == Ndis802_11Encryption3Enabled)
455 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg = CIPHER_AES;
457 // Update group key information to ASIC Shared Key Table
458 AsicAddSharedKeyEntry(pAd,
460 pAd->StaCfg.DefaultKeyId,
461 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg,
462 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].Key,
463 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].TxMic,
464 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].RxMic);
466 // Update ASIC WCID attribute table and IVEIV table
467 RTMPAddWcidAttributeEntry(pAd,
469 pAd->StaCfg.DefaultKeyId,
470 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg,
473 // set 802.1x port control
474 //pAd->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
475 STA_PORT_SECURED(pAd);
477 // Indicate Connected for GUI
478 pAd->IndicateMediaState = NdisMediaStateConnected;
481 else // dynamic WEP from wpa_supplicant
486 if(pKey->KeyLength == 32)
489 KeyIdx = pKey->KeyIndex & 0x0fffffff;
493 // it is a default shared key, for Pairwise key setting
494 if (pKey->KeyIndex & 0x80000000)
496 pEntry = MacTableLookup(pAd, pKey->BSSID);
500 DBGPRINT(RT_DEBUG_TRACE, ("RTMPAddKey: Set Pair-wise Key\n"));
502 // set key material and key length
503 pEntry->PairwiseKey.KeyLen = (UCHAR)pKey->KeyLength;
504 NdisMoveMemory(pEntry->PairwiseKey.Key, &pKey->KeyMaterial, pKey->KeyLength);
507 if (pKey->KeyLength == 5)
508 pEntry->PairwiseKey.CipherAlg = CIPHER_WEP64;
510 pEntry->PairwiseKey.CipherAlg = CIPHER_WEP128;
512 // Add Pair-wise key to Asic
513 AsicAddPairwiseKeyEntry(
517 &pEntry->PairwiseKey);
519 // update WCID attribute table and IVEIV table for this entry
520 RTMPAddWcidAttributeEntry(
523 KeyIdx, // The value may be not zero
524 pEntry->PairwiseKey.CipherAlg,
531 // Default key for tx (shared key)
532 pAd->StaCfg.DefaultKeyId = (UCHAR) KeyIdx;
534 // set key material and key length
535 pAd->SharedKey[BSS0][KeyIdx].KeyLen = (UCHAR) pKey->KeyLength;
536 NdisMoveMemory(pAd->SharedKey[BSS0][KeyIdx].Key, &pKey->KeyMaterial, pKey->KeyLength);
539 if (pKey->KeyLength == 5)
540 pAd->SharedKey[BSS0][KeyIdx].CipherAlg = CIPHER_WEP64;
542 pAd->SharedKey[BSS0][KeyIdx].CipherAlg = CIPHER_WEP128;
544 CipherAlg = pAd->SharedKey[BSS0][KeyIdx].CipherAlg;
545 Key = pAd->SharedKey[BSS0][KeyIdx].Key;
547 // Set Group key material to Asic
548 AsicAddSharedKeyEntry(pAd, BSS0, KeyIdx, CipherAlg, Key, NULL, NULL);
550 // Update WCID attribute table and IVEIV table for this group key table
551 RTMPAddWcidAttributeEntry(pAd, BSS0, KeyIdx, CipherAlg, NULL);
560 char * rtstrchr(const char * s, int c)
562 for(; *s != (char) c; ++s)
569 This is required for LinEX2004/kernel2.6.7 to provide iwlist scanning function
573 rt_ioctl_giwname(struct net_device *dev,
574 struct iw_request_info *info,
575 char *name, char *extra)
577 // PRTMP_ADAPTER pAdapter = dev->ml_priv;
580 strncpy(name, "RT2870 Wireless", IFNAMSIZ);
585 int rt_ioctl_siwfreq(struct net_device *dev,
586 struct iw_request_info *info,
587 struct iw_freq *freq, char *extra)
589 PRTMP_ADAPTER pAdapter = dev->ml_priv;
592 //check if the interface is down
593 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
595 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
603 if((freq->e == 0) && (freq->m <= 1000))
604 chan = freq->m; // Setting by channel number
606 MAP_KHZ_TO_CHANNEL_ID( (freq->m /100) , chan); // Setting by frequency - search the table , like 2.412G, 2.422G,
608 if (ChannelSanity(pAdapter, chan) == TRUE)
610 pAdapter->CommonCfg.Channel = chan;
611 DBGPRINT(RT_DEBUG_ERROR, ("==>rt_ioctl_siwfreq::SIOCSIWFREQ[cmd=0x%x] (Channel=%d)\n", SIOCSIWFREQ, pAdapter->CommonCfg.Channel));
618 int rt_ioctl_giwfreq(struct net_device *dev,
619 struct iw_request_info *info,
620 struct iw_freq *freq, char *extra)
622 VIRTUAL_ADAPTER *pVirtualAd = NULL;
623 PRTMP_ADAPTER pAdapter = NULL;
627 if (dev->priv_flags == INT_MAIN)
629 pAdapter = dev->ml_priv;
633 pVirtualAd = dev->ml_priv;
634 if (pVirtualAd && pVirtualAd->RtmpDev)
635 pAdapter = pVirtualAd->RtmpDev->ml_priv;
638 if (pAdapter == NULL)
640 /* if 1st open fail, pAd will be free;
641 So the net_dev->ml_priv will be NULL in 2rd open */
645 ch = pAdapter->CommonCfg.Channel;
647 DBGPRINT(RT_DEBUG_TRACE,("==>rt_ioctl_giwfreq %d\n", ch));
649 MAP_CHANNEL_ID_TO_KHZ(ch, m);
655 int rt_ioctl_siwmode(struct net_device *dev,
656 struct iw_request_info *info,
657 __u32 *mode, char *extra)
659 PRTMP_ADAPTER pAdapter = dev->ml_priv;
661 //check if the interface is down
662 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
664 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
671 Set_NetworkType_Proc(pAdapter, "Adhoc");
674 Set_NetworkType_Proc(pAdapter, "Infra");
676 case IW_MODE_MONITOR:
677 Set_NetworkType_Proc(pAdapter, "Monitor");
680 DBGPRINT(RT_DEBUG_TRACE, ("===>rt_ioctl_siwmode::SIOCSIWMODE (unknown %d)\n", *mode));
684 // Reset Ralink supplicant to not use, it will be set to start when UI set PMK key
685 pAdapter->StaCfg.WpaState = SS_NOTUSE;
690 int rt_ioctl_giwmode(struct net_device *dev,
691 struct iw_request_info *info,
692 __u32 *mode, char *extra)
694 PRTMP_ADAPTER pAdapter = NULL;
695 VIRTUAL_ADAPTER *pVirtualAd = NULL;
697 if (dev->priv_flags == INT_MAIN)
699 pAdapter = dev->ml_priv;
703 pVirtualAd = dev->ml_priv;
704 if (pVirtualAd && pVirtualAd->RtmpDev)
705 pAdapter = pVirtualAd->RtmpDev->ml_priv;
708 if (pAdapter == NULL)
710 /* if 1st open fail, pAd will be free;
711 So the net_dev->ml_priv will be NULL in 2rd open */
715 if (ADHOC_ON(pAdapter))
716 *mode = IW_MODE_ADHOC;
717 else if (INFRA_ON(pAdapter))
718 *mode = IW_MODE_INFRA;
719 else if (MONITOR_ON(pAdapter))
721 *mode = IW_MODE_MONITOR;
724 *mode = IW_MODE_AUTO;
726 DBGPRINT(RT_DEBUG_TRACE, ("==>rt_ioctl_giwmode(mode=%d)\n", *mode));
730 int rt_ioctl_siwsens(struct net_device *dev,
731 struct iw_request_info *info,
732 char *name, char *extra)
734 PRTMP_ADAPTER pAdapter = dev->ml_priv;
736 //check if the interface is down
737 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
739 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
746 int rt_ioctl_giwsens(struct net_device *dev,
747 struct iw_request_info *info,
748 char *name, char *extra)
753 int rt_ioctl_giwrange(struct net_device *dev,
754 struct iw_request_info *info,
755 struct iw_point *data, char *extra)
757 PRTMP_ADAPTER pAdapter = NULL;
758 VIRTUAL_ADAPTER *pVirtualAd = NULL;
759 struct iw_range *range = (struct iw_range *) extra;
763 if (dev->priv_flags == INT_MAIN)
765 pAdapter = dev->ml_priv;
769 pVirtualAd = dev->ml_priv;
770 if (pVirtualAd && pVirtualAd->RtmpDev)
771 pAdapter = pVirtualAd->RtmpDev->ml_priv;
774 if (pAdapter == NULL)
776 /* if 1st open fail, pAd will be free;
777 So the net_dev->ml_priv will be NULL in 2rd open */
781 DBGPRINT(RT_DEBUG_TRACE ,("===>rt_ioctl_giwrange\n"));
782 data->length = sizeof(struct iw_range);
783 memset(range, 0, sizeof(struct iw_range));
785 range->txpower_capa = IW_TXPOW_DBM;
787 if (INFRA_ON(pAdapter)||ADHOC_ON(pAdapter))
789 range->min_pmp = 1 * 1024;
790 range->max_pmp = 65535 * 1024;
791 range->min_pmt = 1 * 1024;
792 range->max_pmt = 1000 * 1024;
793 range->pmp_flags = IW_POWER_PERIOD;
794 range->pmt_flags = IW_POWER_TIMEOUT;
795 range->pm_capa = IW_POWER_PERIOD | IW_POWER_TIMEOUT |
796 IW_POWER_UNICAST_R | IW_POWER_ALL_R;
799 range->we_version_compiled = WIRELESS_EXT;
800 range->we_version_source = 14;
802 range->retry_capa = IW_RETRY_LIMIT;
803 range->retry_flags = IW_RETRY_LIMIT;
804 range->min_retry = 0;
805 range->max_retry = 255;
807 range->num_channels = pAdapter->ChannelListNum;
810 for (i = 1; i <= range->num_channels; i++)
813 range->freq[val].i = pAdapter->ChannelList[i-1].Channel;
814 MAP_CHANNEL_ID_TO_KHZ(pAdapter->ChannelList[i-1].Channel, m);
815 range->freq[val].m = m * 100; /* HZ */
817 range->freq[val].e = 1;
819 if (val == IW_MAX_FREQUENCIES)
822 range->num_frequency = val;
824 range->max_qual.qual = 100; /* what is correct max? This was not
825 * documented exactly. At least
826 * 69 has been observed. */
827 range->max_qual.level = 0; /* dB */
828 range->max_qual.noise = 0; /* dB */
830 /* What would be suitable values for "average/typical" qual? */
831 range->avg_qual.qual = 20;
832 range->avg_qual.level = -60;
833 range->avg_qual.noise = -95;
834 range->sensitivity = 3;
836 range->max_encoding_tokens = NR_WEP_KEYS;
837 range->num_encoding_sizes = 2;
838 range->encoding_size[0] = 5;
839 range->encoding_size[1] = 13;
842 range->max_rts = 2347;
843 range->min_frag = 256;
844 range->max_frag = 2346;
846 #if WIRELESS_EXT > 17
847 /* IW_ENC_CAPA_* bit field */
848 range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 |
849 IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP;
855 int rt_ioctl_siwap(struct net_device *dev,
856 struct iw_request_info *info,
857 struct sockaddr *ap_addr, char *extra)
859 PRTMP_ADAPTER pAdapter = dev->ml_priv;
860 NDIS_802_11_MAC_ADDRESS Bssid;
862 //check if the interface is down
863 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
865 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
869 if (pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE)
871 RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
872 DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
875 // tell CNTL state machine to call NdisMSetInformationComplete() after completing
876 // this request, because this request is initiated by NDIS.
877 pAdapter->MlmeAux.CurrReqIsFromNdis = FALSE;
878 // Prevent to connect AP again in STAMlmePeriodicExec
879 pAdapter->MlmeAux.AutoReconnectSsidLen= 32;
881 memset(Bssid, 0, MAC_ADDR_LEN);
882 memcpy(Bssid, ap_addr->sa_data, MAC_ADDR_LEN);
883 MlmeEnqueue(pAdapter,
884 MLME_CNTL_STATE_MACHINE,
886 sizeof(NDIS_802_11_MAC_ADDRESS),
889 DBGPRINT(RT_DEBUG_TRACE, ("IOCTL::SIOCSIWAP %02x:%02x:%02x:%02x:%02x:%02x\n",
890 Bssid[0], Bssid[1], Bssid[2], Bssid[3], Bssid[4], Bssid[5]));
895 int rt_ioctl_giwap(struct net_device *dev,
896 struct iw_request_info *info,
897 struct sockaddr *ap_addr, char *extra)
899 PRTMP_ADAPTER pAdapter = NULL;
900 VIRTUAL_ADAPTER *pVirtualAd = NULL;
902 if (dev->priv_flags == INT_MAIN)
904 pAdapter = dev->ml_priv;
908 pVirtualAd = dev->ml_priv;
909 if (pVirtualAd && pVirtualAd->RtmpDev)
910 pAdapter = pVirtualAd->RtmpDev->ml_priv;
913 if (pAdapter == NULL)
915 /* if 1st open fail, pAd will be free;
916 So the net_dev->ml_priv will be NULL in 2rd open */
920 if (INFRA_ON(pAdapter) || ADHOC_ON(pAdapter))
922 ap_addr->sa_family = ARPHRD_ETHER;
923 memcpy(ap_addr->sa_data, &pAdapter->CommonCfg.Bssid, ETH_ALEN);
925 #ifdef WPA_SUPPLICANT_SUPPORT
927 else if (pAdapter->StaCfg.WpaSupplicantUP != WPA_SUPPLICANT_DISABLE)
929 ap_addr->sa_family = ARPHRD_ETHER;
930 memcpy(ap_addr->sa_data, &pAdapter->MlmeAux.Bssid, ETH_ALEN);
932 #endif // WPA_SUPPLICANT_SUPPORT //
935 DBGPRINT(RT_DEBUG_TRACE, ("IOCTL::SIOCGIWAP(=EMPTY)\n"));
943 * Units are in db above the noise floor. That means the
944 * rssi values reported in the tx/rx descriptors in the
945 * driver are the SNR expressed in db.
947 * If you assume that the noise floor is -95, which is an
948 * excellent assumption 99.5 % of the time, then you can
949 * derive the absolute signal level (i.e. -95 + rssi).
950 * There are some other slight factors to take into account
951 * depending on whether the rssi measurement is from 11b,
952 * 11g, or 11a. These differences are at most 2db and
955 * NB: various calculations are based on the orinoco/wavelan
956 * drivers for compatibility
958 static void set_quality(PRTMP_ADAPTER pAdapter,
959 struct iw_quality *iq,
966 ChannelQuality = 100;
967 else if (rssi >= -80) // between -50 ~ -80dbm
968 ChannelQuality = (__u8)(24 + ((rssi + 80) * 26)/10);
969 else if (rssi >= -90) // between -80 ~ -90dbm
970 ChannelQuality = (__u8)((rssi + 90) * 26)/10;
974 iq->qual = (__u8)ChannelQuality;
976 iq->level = (__u8)(rssi);
977 iq->noise = (pAdapter->BbpWriteLatch[66] > pAdapter->BbpTuning.FalseCcaUpperThreshold) ? ((__u8)pAdapter->BbpTuning.FalseCcaUpperThreshold) : ((__u8) pAdapter->BbpWriteLatch[66]); // noise level (dBm)
978 iq->noise += 256 - 143;
979 iq->updated = pAdapter->iw_stats.qual.updated;
982 int rt_ioctl_iwaplist(struct net_device *dev,
983 struct iw_request_info *info,
984 struct iw_point *data, char *extra)
986 PRTMP_ADAPTER pAdapter = dev->ml_priv;
988 struct sockaddr addr[IW_MAX_AP];
989 struct iw_quality qual[IW_MAX_AP];
992 //check if the interface is down
993 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
995 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1001 for (i = 0; i <IW_MAX_AP ; i++)
1003 if (i >= pAdapter->ScanTab.BssNr)
1005 addr[i].sa_family = ARPHRD_ETHER;
1006 memcpy(addr[i].sa_data, &pAdapter->ScanTab.BssEntry[i].Bssid, MAC_ADDR_LEN);
1007 set_quality(pAdapter, &qual[i], pAdapter->ScanTab.BssEntry[i].Rssi);
1010 memcpy(extra, &addr, i*sizeof(addr[0]));
1011 data->flags = 1; /* signal quality present (sort of) */
1012 memcpy(extra + i*sizeof(addr[0]), &qual, i*sizeof(qual[i]));
1018 int rt_ioctl_siwscan(struct net_device *dev,
1019 struct iw_request_info *info,
1020 struct iw_point *data, char *extra)
1022 PRTMP_ADAPTER pAdapter = dev->ml_priv;
1025 int Status = NDIS_STATUS_SUCCESS;
1027 //check if the interface is down
1028 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1030 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1034 if (MONITOR_ON(pAdapter))
1036 DBGPRINT(RT_DEBUG_TRACE, ("!!! Driver is in Monitor Mode now !!!\n"));
1041 #ifdef WPA_SUPPLICANT_SUPPORT
1042 if (pAdapter->StaCfg.WpaSupplicantUP == WPA_SUPPLICANT_ENABLE)
1044 pAdapter->StaCfg.WpaSupplicantScanCount++;
1046 #endif // WPA_SUPPLICANT_SUPPORT //
1048 pAdapter->StaCfg.bScanReqIsFromWebUI = TRUE;
1049 if (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
1054 #ifdef WPA_SUPPLICANT_SUPPORT
1055 if ((pAdapter->StaCfg.WpaSupplicantUP == WPA_SUPPLICANT_ENABLE) &&
1056 (pAdapter->StaCfg.WpaSupplicantScanCount > 3))
1058 DBGPRINT(RT_DEBUG_TRACE, ("!!! WpaSupplicantScanCount > 3\n"));
1059 Status = NDIS_STATUS_SUCCESS;
1062 #endif // WPA_SUPPLICANT_SUPPORT //
1064 if ((OPSTATUS_TEST_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED)) &&
1065 ((pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA) ||
1066 (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK)) &&
1067 (pAdapter->StaCfg.PortSecured == WPA_802_1X_PORT_NOT_SECURED))
1069 DBGPRINT(RT_DEBUG_TRACE, ("!!! Link UP, Port Not Secured! ignore this set::OID_802_11_BSSID_LIST_SCAN\n"));
1070 Status = NDIS_STATUS_SUCCESS;
1074 if (pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE)
1076 RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
1077 DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
1080 // tell CNTL state machine to call NdisMSetInformationComplete() after completing
1081 // this request, because this request is initiated by NDIS.
1082 pAdapter->MlmeAux.CurrReqIsFromNdis = FALSE;
1083 // Reset allowed scan retries
1084 pAdapter->StaCfg.ScanCnt = 0;
1085 pAdapter->StaCfg.LastScanTime = Now;
1087 MlmeEnqueue(pAdapter,
1088 MLME_CNTL_STATE_MACHINE,
1089 OID_802_11_BSSID_LIST_SCAN,
1093 Status = NDIS_STATUS_SUCCESS;
1094 RT28XX_MLME_HANDLER(pAdapter);
1099 int rt_ioctl_giwscan(struct net_device *dev,
1100 struct iw_request_info *info,
1101 struct iw_point *data, char *extra)
1104 PRTMP_ADAPTER pAdapter = dev->ml_priv;
1106 char *current_ev = extra, *previous_ev = extra;
1108 char *current_val, custom[MAX_CUSTOM_LEN] = {0};
1111 #endif // IWEVGENIE //
1112 struct iw_event iwe;
1114 if (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
1117 * Still scanning, indicate the caller should try again.
1123 #ifdef WPA_SUPPLICANT_SUPPORT
1124 if (pAdapter->StaCfg.WpaSupplicantUP == WPA_SUPPLICANT_ENABLE)
1126 pAdapter->StaCfg.WpaSupplicantScanCount = 0;
1128 #endif // WPA_SUPPLICANT_SUPPORT //
1130 if (pAdapter->ScanTab.BssNr == 0)
1136 #if WIRELESS_EXT >= 17
1137 if (data->length > 0)
1138 end_buf = extra + data->length;
1140 end_buf = extra + IW_SCAN_MAX_DATA;
1142 end_buf = extra + IW_SCAN_MAX_DATA;
1145 for (i = 0; i < pAdapter->ScanTab.BssNr; i++)
1147 if (current_ev >= end_buf)
1149 #if WIRELESS_EXT >= 17
1157 //================================
1158 memset(&iwe, 0, sizeof(iwe));
1159 iwe.cmd = SIOCGIWAP;
1160 iwe.u.ap_addr.sa_family = ARPHRD_ETHER;
1161 memcpy(iwe.u.ap_addr.sa_data, &pAdapter->ScanTab.BssEntry[i].Bssid, ETH_ALEN);
1163 previous_ev = current_ev;
1164 current_ev = IWE_STREAM_ADD_EVENT(info, current_ev,end_buf, &iwe, IW_EV_ADDR_LEN);
1165 if (current_ev == previous_ev)
1166 #if WIRELESS_EXT >= 17
1173 //================================
1174 memset(&iwe, 0, sizeof(iwe));
1175 iwe.cmd = SIOCGIWESSID;
1176 iwe.u.data.length = pAdapter->ScanTab.BssEntry[i].SsidLen;
1177 iwe.u.data.flags = 1;
1179 previous_ev = current_ev;
1180 current_ev = IWE_STREAM_ADD_POINT(info, current_ev,end_buf, &iwe, pAdapter->ScanTab.BssEntry[i].Ssid);
1181 if (current_ev == previous_ev)
1182 #if WIRELESS_EXT >= 17
1189 //================================
1190 memset(&iwe, 0, sizeof(iwe));
1191 iwe.cmd = SIOCGIWMODE;
1192 if (pAdapter->ScanTab.BssEntry[i].BssType == Ndis802_11IBSS)
1194 iwe.u.mode = IW_MODE_ADHOC;
1196 else if (pAdapter->ScanTab.BssEntry[i].BssType == Ndis802_11Infrastructure)
1198 iwe.u.mode = IW_MODE_INFRA;
1202 iwe.u.mode = IW_MODE_AUTO;
1204 iwe.len = IW_EV_UINT_LEN;
1206 previous_ev = current_ev;
1207 current_ev = IWE_STREAM_ADD_EVENT(info, current_ev, end_buf, &iwe, IW_EV_UINT_LEN);
1208 if (current_ev == previous_ev)
1209 #if WIRELESS_EXT >= 17
1215 //Channel and Frequency
1216 //================================
1217 memset(&iwe, 0, sizeof(iwe));
1218 iwe.cmd = SIOCGIWFREQ;
1219 if (INFRA_ON(pAdapter) || ADHOC_ON(pAdapter))
1220 iwe.u.freq.m = pAdapter->ScanTab.BssEntry[i].Channel;
1222 iwe.u.freq.m = pAdapter->ScanTab.BssEntry[i].Channel;
1226 previous_ev = current_ev;
1227 current_ev = IWE_STREAM_ADD_EVENT(info, current_ev,end_buf, &iwe, IW_EV_FREQ_LEN);
1228 if (current_ev == previous_ev)
1229 #if WIRELESS_EXT >= 17
1235 //Add quality statistics
1236 //================================
1237 memset(&iwe, 0, sizeof(iwe));
1239 iwe.u.qual.level = 0;
1240 iwe.u.qual.noise = 0;
1241 set_quality(pAdapter, &iwe.u.qual, pAdapter->ScanTab.BssEntry[i].Rssi);
1242 current_ev = IWE_STREAM_ADD_EVENT(info, current_ev, end_buf, &iwe, IW_EV_QUAL_LEN);
1243 if (current_ev == previous_ev)
1244 #if WIRELESS_EXT >= 17
1251 //================================
1252 memset(&iwe, 0, sizeof(iwe));
1253 iwe.cmd = SIOCGIWENCODE;
1254 if (CAP_IS_PRIVACY_ON (pAdapter->ScanTab.BssEntry[i].CapabilityInfo ))
1255 iwe.u.data.flags =IW_ENCODE_ENABLED | IW_ENCODE_NOKEY;
1257 iwe.u.data.flags = IW_ENCODE_DISABLED;
1259 previous_ev = current_ev;
1260 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);
1261 if (current_ev == previous_ev)
1262 #if WIRELESS_EXT >= 17
1269 //================================
1270 if (pAdapter->ScanTab.BssEntry[i].SupRateLen)
1272 UCHAR tmpRate = pAdapter->ScanTab.BssEntry[i].SupRate[pAdapter->ScanTab.BssEntry[i].SupRateLen-1];
1273 memset(&iwe, 0, sizeof(iwe));
1274 iwe.cmd = SIOCGIWRATE;
1275 current_val = current_ev + IW_EV_LCP_LEN;
1276 if (tmpRate == 0x82)
1277 iwe.u.bitrate.value = 1 * 1000000;
1278 else if (tmpRate == 0x84)
1279 iwe.u.bitrate.value = 2 * 1000000;
1280 else if (tmpRate == 0x8B)
1281 iwe.u.bitrate.value = 5.5 * 1000000;
1282 else if (tmpRate == 0x96)
1283 iwe.u.bitrate.value = 11 * 1000000;
1285 iwe.u.bitrate.value = (tmpRate/2) * 1000000;
1287 iwe.u.bitrate.disabled = 0;
1288 current_val = IWE_STREAM_ADD_VALUE(info, current_ev,
1289 current_val, end_buf, &iwe,
1292 if((current_val-current_ev)>IW_EV_LCP_LEN)
1293 current_ev = current_val;
1295 #if WIRELESS_EXT >= 17
1304 if (pAdapter->ScanTab.BssEntry[i].WpaIE.IELen > 0)
1306 memset(&iwe, 0, sizeof(iwe));
1307 memset(&custom[0], 0, MAX_CUSTOM_LEN);
1308 memcpy(custom, &(pAdapter->ScanTab.BssEntry[i].WpaIE.IE[0]),
1309 pAdapter->ScanTab.BssEntry[i].WpaIE.IELen);
1310 iwe.cmd = IWEVGENIE;
1311 iwe.u.data.length = pAdapter->ScanTab.BssEntry[i].WpaIE.IELen;
1312 current_ev = IWE_STREAM_ADD_POINT(info, current_ev, end_buf, &iwe, custom);
1313 if (current_ev == previous_ev)
1314 #if WIRELESS_EXT >= 17
1322 if (pAdapter->ScanTab.BssEntry[i].RsnIE.IELen > 0)
1324 memset(&iwe, 0, sizeof(iwe));
1325 memset(&custom[0], 0, MAX_CUSTOM_LEN);
1326 memcpy(custom, &(pAdapter->ScanTab.BssEntry[i].RsnIE.IE[0]),
1327 pAdapter->ScanTab.BssEntry[i].RsnIE.IELen);
1328 iwe.cmd = IWEVGENIE;
1329 iwe.u.data.length = pAdapter->ScanTab.BssEntry[i].RsnIE.IELen;
1330 current_ev = IWE_STREAM_ADD_POINT(info, current_ev, end_buf, &iwe, custom);
1331 if (current_ev == previous_ev)
1332 #if WIRELESS_EXT >= 17
1340 //================================
1341 if (pAdapter->ScanTab.BssEntry[i].WpaIE.IELen > 0)
1343 NdisZeroMemory(&iwe, sizeof(iwe));
1344 memset(&custom[0], 0, MAX_CUSTOM_LEN);
1345 iwe.cmd = IWEVCUSTOM;
1346 iwe.u.data.length = (pAdapter->ScanTab.BssEntry[i].WpaIE.IELen * 2) + 7;
1347 NdisMoveMemory(custom, "wpa_ie=", 7);
1348 for (idx = 0; idx < pAdapter->ScanTab.BssEntry[i].WpaIE.IELen; idx++)
1349 sprintf(custom + strlen(custom), "%02x", pAdapter->ScanTab.BssEntry[i].WpaIE.IE[idx]);
1350 previous_ev = current_ev;
1351 current_ev = IWE_STREAM_ADD_POINT(info, current_ev, end_buf, &iwe, custom);
1352 if (current_ev == previous_ev)
1353 #if WIRELESS_EXT >= 17
1361 if (pAdapter->ScanTab.BssEntry[i].RsnIE.IELen > 0)
1363 NdisZeroMemory(&iwe, sizeof(iwe));
1364 memset(&custom[0], 0, MAX_CUSTOM_LEN);
1365 iwe.cmd = IWEVCUSTOM;
1366 iwe.u.data.length = (pAdapter->ScanTab.BssEntry[i].RsnIE.IELen * 2) + 7;
1367 NdisMoveMemory(custom, "rsn_ie=", 7);
1368 for (idx = 0; idx < pAdapter->ScanTab.BssEntry[i].RsnIE.IELen; idx++)
1369 sprintf(custom + strlen(custom), "%02x", pAdapter->ScanTab.BssEntry[i].RsnIE.IE[idx]);
1370 previous_ev = current_ev;
1371 current_ev = IWE_STREAM_ADD_POINT(info, current_ev, end_buf, &iwe, custom);
1372 if (current_ev == previous_ev)
1373 #if WIRELESS_EXT >= 17
1379 #endif // IWEVGENIE //
1382 data->length = current_ev - extra;
1383 pAdapter->StaCfg.bScanReqIsFromWebUI = FALSE;
1384 DBGPRINT(RT_DEBUG_ERROR ,("===>rt_ioctl_giwscan. %d(%d) BSS returned, data->length = %d\n",i , pAdapter->ScanTab.BssNr, data->length));
1389 int rt_ioctl_siwessid(struct net_device *dev,
1390 struct iw_request_info *info,
1391 struct iw_point *data, char *essid)
1393 PRTMP_ADAPTER pAdapter = dev->ml_priv;
1395 //check if the interface is down
1396 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1398 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1404 PCHAR pSsidString = NULL;
1406 // Includes null character.
1407 if (data->length > (IW_ESSID_MAX_SIZE + 1))
1410 pSsidString = (CHAR *) kmalloc(MAX_LEN_OF_SSID+1, MEM_ALLOC_FLAG);
1413 NdisZeroMemory(pSsidString, MAX_LEN_OF_SSID+1);
1414 NdisMoveMemory(pSsidString, essid, data->length);
1415 if (Set_SSID_Proc(pAdapter, pSsidString) == FALSE)
1424 if (Set_SSID_Proc(pAdapter, "") == FALSE)
1430 int rt_ioctl_giwessid(struct net_device *dev,
1431 struct iw_request_info *info,
1432 struct iw_point *data, char *essid)
1434 PRTMP_ADAPTER pAdapter = NULL;
1435 VIRTUAL_ADAPTER *pVirtualAd = NULL;
1437 if (dev->priv_flags == INT_MAIN)
1439 pAdapter = dev->ml_priv;
1443 pVirtualAd = dev->ml_priv;
1444 if (pVirtualAd && pVirtualAd->RtmpDev)
1445 pAdapter = pVirtualAd->RtmpDev->ml_priv;
1448 if (pAdapter == NULL)
1450 /* if 1st open fail, pAd will be free;
1451 So the net_dev->ml_priv will be NULL in 2rd open */
1456 if (MONITOR_ON(pAdapter))
1462 if (OPSTATUS_TEST_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED))
1464 DBGPRINT(RT_DEBUG_TRACE ,("MediaState is connected\n"));
1465 data->length = pAdapter->CommonCfg.SsidLen;
1466 memcpy(essid, pAdapter->CommonCfg.Ssid, pAdapter->CommonCfg.SsidLen);
1469 #ifdef WPA_SUPPLICANT_SUPPORT
1471 else if (pAdapter->StaCfg.WpaSupplicantUP != WPA_SUPPLICANT_DISABLE)
1473 data->length = pAdapter->CommonCfg.SsidLen;
1474 memcpy(essid, pAdapter->CommonCfg.Ssid, pAdapter->CommonCfg.SsidLen);
1476 #endif // WPA_SUPPLICANT_SUPPORT //
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 //pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
1708 STA_PORT_SECURED(pAdapter);
1709 pAdapter->StaCfg.PairCipher = Ndis802_11WEPEnabled;
1710 pAdapter->StaCfg.GroupCipher = Ndis802_11WEPEnabled;
1711 pAdapter->StaCfg.WepStatus = Ndis802_11WEPEnabled;
1712 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
1713 if (erq->flags & IW_ENCODE_RESTRICTED)
1714 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeShared;
1716 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
1720 if (erq->length > 0)
1722 int keyIdx = (erq->flags & IW_ENCODE_INDEX) - 1;
1723 /* Check the size of the key */
1724 if (erq->length > MAX_WEP_KEY_SIZE) {
1727 /* Check key index */
1728 if ((keyIdx < 0) || (keyIdx >= NR_WEP_KEYS))
1730 DBGPRINT(RT_DEBUG_TRACE ,("==>rt_ioctl_siwencode::Wrong keyIdx=%d! Using default key instead (%d)\n",
1731 keyIdx, pAdapter->StaCfg.DefaultKeyId));
1734 keyIdx = pAdapter->StaCfg.DefaultKeyId;
1737 NdisZeroMemory(pAdapter->SharedKey[BSS0][keyIdx].Key, 16);
1739 if (erq->length == MAX_WEP_KEY_SIZE)
1741 pAdapter->SharedKey[BSS0][keyIdx].KeyLen = MAX_WEP_KEY_SIZE;
1742 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CIPHER_WEP128;
1744 else if (erq->length == MIN_WEP_KEY_SIZE)
1746 pAdapter->SharedKey[BSS0][keyIdx].KeyLen = MIN_WEP_KEY_SIZE;
1747 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CIPHER_WEP64;
1750 /* Disable the key */
1751 pAdapter->SharedKey[BSS0][keyIdx].KeyLen = 0;
1753 /* Check if the key is not marked as invalid */
1754 if(!(erq->flags & IW_ENCODE_NOKEY)) {
1755 /* Copy the key in the driver */
1756 NdisMoveMemory(pAdapter->SharedKey[BSS0][keyIdx].Key, extra, erq->length);
1761 /* Do we want to just set the transmit key index ? */
1762 int index = (erq->flags & IW_ENCODE_INDEX) - 1;
1763 if ((index >= 0) && (index < 4))
1765 pAdapter->StaCfg.DefaultKeyId = index;
1768 /* Don't complain if only change the mode */
1769 if (!(erq->flags & IW_ENCODE_MODE)) {
1775 DBGPRINT(RT_DEBUG_TRACE ,("==>rt_ioctl_siwencode::erq->flags=%x\n",erq->flags));
1776 DBGPRINT(RT_DEBUG_TRACE ,("==>rt_ioctl_siwencode::AuthMode=%x\n",pAdapter->StaCfg.AuthMode));
1777 DBGPRINT(RT_DEBUG_TRACE ,("==>rt_ioctl_siwencode::DefaultKeyId=%x, KeyLen = %d\n",pAdapter->StaCfg.DefaultKeyId , pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].KeyLen));
1778 DBGPRINT(RT_DEBUG_TRACE ,("==>rt_ioctl_siwencode::WepStatus=%x\n",pAdapter->StaCfg.WepStatus));
1783 rt_ioctl_giwencode(struct net_device *dev,
1784 struct iw_request_info *info,
1785 struct iw_point *erq, char *key)
1788 PRTMP_ADAPTER pAdapter = NULL;
1789 VIRTUAL_ADAPTER *pVirtualAd = NULL;
1791 if (dev->priv_flags == INT_MAIN)
1793 pAdapter = dev->ml_priv;
1797 pVirtualAd = dev->ml_priv;
1798 if (pVirtualAd && pVirtualAd->RtmpDev)
1799 pAdapter = pVirtualAd->RtmpDev->ml_priv;
1802 if (pAdapter == NULL)
1804 /* if 1st open fail, pAd will be free;
1805 So the net_dev->ml_priv will be NULL in 2rd open */
1809 //check if the interface is down
1810 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1812 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1816 kid = erq->flags & IW_ENCODE_INDEX;
1817 DBGPRINT(RT_DEBUG_TRACE, ("===>rt_ioctl_giwencode %d\n", erq->flags & IW_ENCODE_INDEX));
1819 if (pAdapter->StaCfg.WepStatus == Ndis802_11WEPDisabled)
1822 erq->flags = IW_ENCODE_DISABLED;
1824 else if ((kid > 0) && (kid <=4))
1827 erq->flags = kid ; /* NB: base 1 */
1828 if (erq->length > pAdapter->SharedKey[BSS0][kid-1].KeyLen)
1829 erq->length = pAdapter->SharedKey[BSS0][kid-1].KeyLen;
1830 memcpy(key, pAdapter->SharedKey[BSS0][kid-1].Key, erq->length);
1831 //if ((kid == pAdapter->PortCfg.DefaultKeyId))
1832 //erq->flags |= IW_ENCODE_ENABLED; /* XXX */
1833 if (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeShared)
1834 erq->flags |= IW_ENCODE_RESTRICTED; /* XXX */
1836 erq->flags |= IW_ENCODE_OPEN; /* XXX */
1841 if (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeShared)
1842 erq->flags |= IW_ENCODE_RESTRICTED; /* XXX */
1844 erq->flags |= IW_ENCODE_OPEN; /* XXX */
1845 erq->length = pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].KeyLen;
1846 memcpy(key, pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].Key, erq->length);
1847 // copy default key ID
1848 if (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeShared)
1849 erq->flags |= IW_ENCODE_RESTRICTED; /* XXX */
1851 erq->flags |= IW_ENCODE_OPEN; /* XXX */
1852 erq->flags = pAdapter->StaCfg.DefaultKeyId + 1; /* NB: base 1 */
1853 erq->flags |= IW_ENCODE_ENABLED; /* XXX */
1861 rt_ioctl_setparam(struct net_device *dev, struct iw_request_info *info,
1862 void *w, char *extra)
1864 VIRTUAL_ADAPTER *pVirtualAd = NULL;
1865 PRTMP_ADAPTER pAdapter;
1867 char *this_char = extra;
1871 if (dev->priv_flags == INT_MAIN)
1873 pAdapter = dev->ml_priv;
1877 pVirtualAd = dev->ml_priv;
1878 pAdapter = pVirtualAd->RtmpDev->ml_priv;
1880 pObj = (POS_COOKIE) pAdapter->OS_Cookie;
1882 if (pAdapter == NULL)
1884 /* if 1st open fail, pAd will be free;
1885 So the net_dev->ml_priv will be NULL in 2rd open */
1890 pObj->ioctl_if_type = INT_MAIN;
1891 pObj->ioctl_if = MAIN_MBSSID;
1894 //check if the interface is down
1895 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1897 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1904 if ((value = rtstrchr(this_char, '=')) != NULL)
1910 // reject setting nothing besides ANY ssid(ssidLen=0)
1911 if (!*value && (strcmp(this_char, "SSID") != 0))
1914 for (PRTMP_PRIVATE_SET_PROC = RTMP_PRIVATE_SUPPORT_PROC; PRTMP_PRIVATE_SET_PROC->name; PRTMP_PRIVATE_SET_PROC++)
1916 if (strcmp(this_char, PRTMP_PRIVATE_SET_PROC->name) == 0)
1918 if(!PRTMP_PRIVATE_SET_PROC->set_proc(pAdapter, value))
1919 { //FALSE:Set private failed then return Invalid argument
1922 break; //Exit for loop.
1926 if(PRTMP_PRIVATE_SET_PROC->name == NULL)
1927 { //Not found argument
1929 DBGPRINT(RT_DEBUG_TRACE, ("===>rt_ioctl_setparam:: (iwpriv) Not Support Set Command [%s=%s]\n", this_char, value));
1937 rt_private_get_statistics(struct net_device *dev, struct iw_request_info *info,
1938 struct iw_point *wrq, char *extra)
1941 PRTMP_ADAPTER pAd = dev->ml_priv;
1949 memset(extra, 0x00, IW_PRIV_SIZE_MASK);
1950 sprintf(extra, "\n\n");
1955 sprintf(extra+strlen(extra), "Tx success = %ld\n", (ULONG)pAd->ate.TxDoneCount);
1956 //sprintf(extra+strlen(extra), "Tx success without retry = %ld\n", (ULONG)pAd->ate.TxDoneCount);
1959 #endif // RALINK_ATE //
1961 sprintf(extra+strlen(extra), "Tx success = %ld\n", (ULONG)pAd->WlanCounters.TransmittedFragmentCount.QuadPart);
1962 sprintf(extra+strlen(extra), "Tx success without retry = %ld\n", (ULONG)pAd->WlanCounters.TransmittedFragmentCount.QuadPart - (ULONG)pAd->WlanCounters.RetryCount.QuadPart);
1964 sprintf(extra+strlen(extra), "Tx success after retry = %ld\n", (ULONG)pAd->WlanCounters.RetryCount.QuadPart);
1965 sprintf(extra+strlen(extra), "Tx fail to Rcv ACK after retry = %ld\n", (ULONG)pAd->WlanCounters.FailedCount.QuadPart);
1966 sprintf(extra+strlen(extra), "RTS Success Rcv CTS = %ld\n", (ULONG)pAd->WlanCounters.RTSSuccessCount.QuadPart);
1967 sprintf(extra+strlen(extra), "RTS Fail Rcv CTS = %ld\n", (ULONG)pAd->WlanCounters.RTSFailureCount.QuadPart);
1969 sprintf(extra+strlen(extra), "Rx success = %ld\n", (ULONG)pAd->WlanCounters.ReceivedFragmentCount.QuadPart);
1970 sprintf(extra+strlen(extra), "Rx with CRC = %ld\n", (ULONG)pAd->WlanCounters.FCSErrorCount.QuadPart);
1971 sprintf(extra+strlen(extra), "Rx drop due to out of resource = %ld\n", (ULONG)pAd->Counters8023.RxNoBuffer);
1972 sprintf(extra+strlen(extra), "Rx duplicate frame = %ld\n", (ULONG)pAd->WlanCounters.FrameDuplicateCount.QuadPart);
1974 sprintf(extra+strlen(extra), "False CCA (one second) = %ld\n", (ULONG)pAd->RalinkCounters.OneSecFalseCCACnt);
1978 if (pAd->ate.RxAntennaSel == 0)
1980 sprintf(extra+strlen(extra), "RSSI-A = %ld\n", (LONG)(pAd->ate.LastRssi0 - pAd->BbpRssiToDbmDelta));
1981 sprintf(extra+strlen(extra), "RSSI-B (if available) = %ld\n", (LONG)(pAd->ate.LastRssi1 - pAd->BbpRssiToDbmDelta));
1982 sprintf(extra+strlen(extra), "RSSI-C (if available) = %ld\n\n", (LONG)(pAd->ate.LastRssi2 - pAd->BbpRssiToDbmDelta));
1986 sprintf(extra+strlen(extra), "RSSI = %ld\n", (LONG)(pAd->ate.LastRssi0 - pAd->BbpRssiToDbmDelta));
1990 #endif // RALINK_ATE //
1992 sprintf(extra+strlen(extra), "RSSI-A = %ld\n", (LONG)(pAd->StaCfg.RssiSample.LastRssi0 - pAd->BbpRssiToDbmDelta));
1993 sprintf(extra+strlen(extra), "RSSI-B (if available) = %ld\n", (LONG)(pAd->StaCfg.RssiSample.LastRssi1 - pAd->BbpRssiToDbmDelta));
1994 sprintf(extra+strlen(extra), "RSSI-C (if available) = %ld\n\n", (LONG)(pAd->StaCfg.RssiSample.LastRssi2 - pAd->BbpRssiToDbmDelta));
1996 #ifdef WPA_SUPPLICANT_SUPPORT
1997 sprintf(extra+strlen(extra), "WpaSupplicantUP = %d\n\n", pAd->StaCfg.WpaSupplicantUP);
1998 #endif // WPA_SUPPLICANT_SUPPORT //
2001 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2002 DBGPRINT(RT_DEBUG_TRACE, ("<== rt_private_get_statistics, wrq->length = %d\n", wrq->length));
2007 #ifdef DOT11_N_SUPPORT
2009 IN PRTMP_ADAPTER pAd,
2013 BA_ORI_ENTRY *pOriBAEntry;
2014 BA_REC_ENTRY *pRecBAEntry;
2016 for (i=0; i<MAX_LEN_OF_MAC_TABLE; i++)
2018 PMAC_TABLE_ENTRY pEntry = &pAd->MacTab.Content[i];
2019 if (((pEntry->ValidAsCLI || pEntry->ValidAsApCli) && (pEntry->Sst == SST_ASSOC))
2020 || (pEntry->ValidAsWDS) || (pEntry->ValidAsMesh))
2022 sprintf(pOutBuf + strlen(pOutBuf), "\n%02X:%02X:%02X:%02X:%02X:%02X (Aid = %d) (AP) -\n",
2023 pEntry->Addr[0], pEntry->Addr[1], pEntry->Addr[2],
2024 pEntry->Addr[3], pEntry->Addr[4], pEntry->Addr[5], pEntry->Aid);
2026 sprintf(pOutBuf, "%s[Recipient]\n", pOutBuf);
2027 for (j=0; j < NUM_OF_TID; j++)
2029 if (pEntry->BARecWcidArray[j] != 0)
2031 pRecBAEntry =&pAd->BATable.BARecEntry[pEntry->BARecWcidArray[j]];
2032 sprintf(pOutBuf + strlen(pOutBuf), "TID=%d, BAWinSize=%d, LastIndSeq=%d, ReorderingPkts=%d\n", j, pRecBAEntry->BAWinSize, pRecBAEntry->LastIndSeq, pRecBAEntry->list.qlen);
2035 sprintf(pOutBuf, "%s\n", pOutBuf);
2037 sprintf(pOutBuf, "%s[Originator]\n", pOutBuf);
2038 for (j=0; j < NUM_OF_TID; j++)
2040 if (pEntry->BAOriWcidArray[j] != 0)
2042 pOriBAEntry =&pAd->BATable.BAOriEntry[pEntry->BAOriWcidArray[j]];
2043 sprintf(pOutBuf + strlen(pOutBuf), "TID=%d, BAWinSize=%d, StartSeq=%d, CurTxSeq=%d\n", j, pOriBAEntry->BAWinSize, pOriBAEntry->Sequence, pEntry->TxSeq[j]);
2046 sprintf(pOutBuf, "%s\n\n", pOutBuf);
2048 if (strlen(pOutBuf) > (IW_PRIV_SIZE_MASK - 30))
2054 #endif // DOT11_N_SUPPORT //
2057 rt_private_show(struct net_device *dev, struct iw_request_info *info,
2058 struct iw_point *wrq, char *extra)
2061 VIRTUAL_ADAPTER *pVirtualAd = NULL;
2064 u32 subcmd = wrq->flags;
2066 if (dev->priv_flags == INT_MAIN)
2070 pVirtualAd = dev->ml_priv;
2071 pAd = pVirtualAd->RtmpDev->ml_priv;
2073 pObj = (POS_COOKIE) pAd->OS_Cookie;
2077 /* if 1st open fail, pAd will be free;
2078 So the net_dev->ml_priv will be NULL in 2rd open */
2087 memset(extra, 0x00, IW_PRIV_SIZE_MASK);
2090 pObj->ioctl_if_type = INT_MAIN;
2091 pObj->ioctl_if = MAIN_MBSSID;
2097 case SHOW_CONN_STATUS:
2098 if (MONITOR_ON(pAd))
2100 #ifdef DOT11_N_SUPPORT
2101 if (pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED &&
2102 pAd->CommonCfg.RegTransmitSetting.field.BW)
2103 sprintf(extra, "Monitor Mode(CentralChannel %d)\n", pAd->CommonCfg.CentralChannel);
2105 #endif // DOT11_N_SUPPORT //
2106 sprintf(extra, "Monitor Mode(Channel %d)\n", pAd->CommonCfg.Channel);
2110 if (pAd->IndicateMediaState == NdisMediaStateConnected)
2114 sprintf(extra, "Connected(AP: %s[%02X:%02X:%02X:%02X:%02X:%02X])\n",
2115 pAd->CommonCfg.Ssid,
2116 pAd->CommonCfg.Bssid[0],
2117 pAd->CommonCfg.Bssid[1],
2118 pAd->CommonCfg.Bssid[2],
2119 pAd->CommonCfg.Bssid[3],
2120 pAd->CommonCfg.Bssid[4],
2121 pAd->CommonCfg.Bssid[5]);
2122 DBGPRINT(RT_DEBUG_TRACE ,("Ssid=%s ,Ssidlen = %d\n",pAd->CommonCfg.Ssid, pAd->CommonCfg.SsidLen));
2124 else if (ADHOC_ON(pAd))
2125 sprintf(extra, "Connected\n");
2129 sprintf(extra, "Disconnected\n");
2130 DBGPRINT(RT_DEBUG_TRACE ,("ConnStatus is not connected\n"));
2133 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2135 case SHOW_DRVIER_VERION:
2136 sprintf(extra, "Driver version-%s, %s %s\n", STA_DRIVER_VERSION, __DATE__, __TIME__ );
2137 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2139 #ifdef DOT11_N_SUPPORT
2141 getBaInfo(pAd, extra);
2142 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2144 #endif // DOT11_N_SUPPORT //
2145 case SHOW_DESC_INFO:
2147 Show_DescInfo_Proc(pAd, NULL);
2148 wrq->length = 0; // 1: size of '\0'
2152 if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
2154 sprintf(extra, "Scanning\n");
2155 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2158 pAd->StaCfg.bSwRadio = FALSE;
2159 if (pAd->StaCfg.bRadio != (pAd->StaCfg.bHwRadio && pAd->StaCfg.bSwRadio))
2161 pAd->StaCfg.bRadio = (pAd->StaCfg.bHwRadio && pAd->StaCfg.bSwRadio);
2162 if (pAd->StaCfg.bRadio == FALSE)
2165 // Update extra information
2166 pAd->ExtraInfo = SW_RADIO_OFF;
2169 sprintf(extra, "Radio Off\n");
2170 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2173 if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
2175 sprintf(extra, "Scanning\n");
2176 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2179 pAd->StaCfg.bSwRadio = TRUE;
2180 //if (pAd->StaCfg.bRadio != (pAd->StaCfg.bHwRadio && pAd->StaCfg.bSwRadio))
2182 pAd->StaCfg.bRadio = (pAd->StaCfg.bHwRadio && pAd->StaCfg.bSwRadio);
2183 if (pAd->StaCfg.bRadio == TRUE)
2186 // Update extra information
2187 pAd->ExtraInfo = EXTRA_INFO_CLEAR;
2190 sprintf(extra, "Radio On\n");
2191 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2195 #ifdef QOS_DLS_SUPPORT
2196 case SHOW_DLS_ENTRY_INFO:
2198 Set_DlsEntryInfo_Display_Proc(pAd, NULL);
2199 wrq->length = 0; // 1: size of '\0'
2202 #endif // QOS_DLS_SUPPORT //
2204 case SHOW_CFG_VALUE:
2206 Status = RTMPShowCfgValue(pAd, wrq->pointer, extra);
2208 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2211 case SHOW_ADHOC_ENTRY_INFO:
2212 Show_Adhoc_MacTable_Proc(pAd, extra);
2213 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2216 DBGPRINT(RT_DEBUG_TRACE, ("%s - unknow subcmd = %d\n", __func__, subcmd));
2224 int rt_ioctl_siwmlme(struct net_device *dev,
2225 struct iw_request_info *info,
2226 union iwreq_data *wrqu,
2229 PRTMP_ADAPTER pAd = dev->ml_priv;
2230 struct iw_mlme *pMlme = (struct iw_mlme *)wrqu->data.pointer;
2231 MLME_QUEUE_ELEM MsgElem;
2232 MLME_DISASSOC_REQ_STRUCT DisAssocReq;
2233 MLME_DEAUTH_REQ_STRUCT DeAuthReq;
2235 DBGPRINT(RT_DEBUG_TRACE, ("====> %s\n", __func__));
2242 #ifdef IW_MLME_DEAUTH
2243 case IW_MLME_DEAUTH:
2244 DBGPRINT(RT_DEBUG_TRACE, ("====> %s - IW_MLME_DEAUTH\n", __func__));
2245 COPY_MAC_ADDR(DeAuthReq.Addr, pAd->CommonCfg.Bssid);
2246 DeAuthReq.Reason = pMlme->reason_code;
2247 MsgElem.MsgLen = sizeof(MLME_DEAUTH_REQ_STRUCT);
2248 NdisMoveMemory(MsgElem.Msg, &DeAuthReq, sizeof(MLME_DEAUTH_REQ_STRUCT));
2249 MlmeDeauthReqAction(pAd, &MsgElem);
2252 LinkDown(pAd, FALSE);
2253 pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
2256 #endif // IW_MLME_DEAUTH //
2257 #ifdef IW_MLME_DISASSOC
2258 case IW_MLME_DISASSOC:
2259 DBGPRINT(RT_DEBUG_TRACE, ("====> %s - IW_MLME_DISASSOC\n", __func__));
2260 COPY_MAC_ADDR(DisAssocReq.Addr, pAd->CommonCfg.Bssid);
2261 DisAssocReq.Reason = pMlme->reason_code;
2263 MsgElem.Machine = ASSOC_STATE_MACHINE;
2264 MsgElem.MsgType = MT2_MLME_DISASSOC_REQ;
2265 MsgElem.MsgLen = sizeof(MLME_DISASSOC_REQ_STRUCT);
2266 NdisMoveMemory(MsgElem.Msg, &DisAssocReq, sizeof(MLME_DISASSOC_REQ_STRUCT));
2268 pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_OID_DISASSOC;
2269 MlmeDisassocReqAction(pAd, &MsgElem);
2271 #endif // IW_MLME_DISASSOC //
2273 DBGPRINT(RT_DEBUG_TRACE, ("====> %s - Unknow Command\n", __func__));
2279 #endif // SIOCSIWMLME //
2281 #if WIRELESS_EXT > 17
2282 int rt_ioctl_siwauth(struct net_device *dev,
2283 struct iw_request_info *info,
2284 union iwreq_data *wrqu, char *extra)
2286 PRTMP_ADAPTER pAdapter = dev->ml_priv;
2287 struct iw_param *param = &wrqu->param;
2289 //check if the interface is down
2290 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
2292 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
2295 switch (param->flags & IW_AUTH_INDEX) {
2296 case IW_AUTH_WPA_VERSION:
2297 if (param->value == IW_AUTH_WPA_VERSION_WPA)
2299 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPAPSK;
2300 if (pAdapter->StaCfg.BssType == BSS_ADHOC)
2301 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPANone;
2303 else if (param->value == IW_AUTH_WPA_VERSION_WPA2)
2304 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA2PSK;
2306 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_WPA_VERSION - param->value = %d!\n", __func__, param->value));
2308 case IW_AUTH_CIPHER_PAIRWISE:
2309 if (param->value == IW_AUTH_CIPHER_NONE)
2311 pAdapter->StaCfg.WepStatus = Ndis802_11WEPDisabled;
2312 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
2313 pAdapter->StaCfg.PairCipher = Ndis802_11WEPDisabled;
2315 else if (param->value == IW_AUTH_CIPHER_WEP40 ||
2316 param->value == IW_AUTH_CIPHER_WEP104)
2318 pAdapter->StaCfg.WepStatus = Ndis802_11WEPEnabled;
2319 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
2320 pAdapter->StaCfg.PairCipher = Ndis802_11WEPEnabled;
2321 #ifdef WPA_SUPPLICANT_SUPPORT
2322 pAdapter->StaCfg.IEEE8021X = FALSE;
2323 #endif // WPA_SUPPLICANT_SUPPORT //
2325 else if (param->value == IW_AUTH_CIPHER_TKIP)
2327 pAdapter->StaCfg.WepStatus = Ndis802_11Encryption2Enabled;
2328 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
2329 pAdapter->StaCfg.PairCipher = Ndis802_11Encryption2Enabled;
2331 else if (param->value == IW_AUTH_CIPHER_CCMP)
2333 pAdapter->StaCfg.WepStatus = Ndis802_11Encryption3Enabled;
2334 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
2335 pAdapter->StaCfg.PairCipher = Ndis802_11Encryption3Enabled;
2337 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_CIPHER_PAIRWISE - param->value = %d!\n", __func__, param->value));
2339 case IW_AUTH_CIPHER_GROUP:
2340 if (param->value == IW_AUTH_CIPHER_NONE)
2342 pAdapter->StaCfg.GroupCipher = Ndis802_11WEPDisabled;
2344 else if (param->value == IW_AUTH_CIPHER_WEP40 ||
2345 param->value == IW_AUTH_CIPHER_WEP104)
2347 pAdapter->StaCfg.GroupCipher = Ndis802_11WEPEnabled;
2349 else if (param->value == IW_AUTH_CIPHER_TKIP)
2351 pAdapter->StaCfg.GroupCipher = Ndis802_11Encryption2Enabled;
2353 else if (param->value == IW_AUTH_CIPHER_CCMP)
2355 pAdapter->StaCfg.GroupCipher = Ndis802_11Encryption3Enabled;
2357 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_CIPHER_GROUP - param->value = %d!\n", __func__, param->value));
2359 case IW_AUTH_KEY_MGMT:
2360 if (param->value == IW_AUTH_KEY_MGMT_802_1X)
2362 if (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK)
2364 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA;
2365 #ifdef WPA_SUPPLICANT_SUPPORT
2366 pAdapter->StaCfg.IEEE8021X = FALSE;
2367 #endif // WPA_SUPPLICANT_SUPPORT //
2369 else if (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK)
2371 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA2;
2372 #ifdef WPA_SUPPLICANT_SUPPORT
2373 pAdapter->StaCfg.IEEE8021X = FALSE;
2374 #endif // WPA_SUPPLICANT_SUPPORT //
2376 #ifdef WPA_SUPPLICANT_SUPPORT
2379 pAdapter->StaCfg.IEEE8021X = TRUE;
2380 #endif // WPA_SUPPLICANT_SUPPORT //
2382 else if (param->value == 0)
2384 //pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
2385 STA_PORT_SECURED(pAdapter);
2387 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_KEY_MGMT - param->value = %d!\n", __func__, param->value));
2389 case IW_AUTH_RX_UNENCRYPTED_EAPOL:
2391 case IW_AUTH_PRIVACY_INVOKED:
2392 /*if (param->value == 0)
2394 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
2395 pAdapter->StaCfg.WepStatus = Ndis802_11WEPDisabled;
2396 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
2397 pAdapter->StaCfg.PairCipher = Ndis802_11WEPDisabled;
2398 pAdapter->StaCfg.GroupCipher = Ndis802_11WEPDisabled;
2400 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_PRIVACY_INVOKED - param->value = %d!\n", __func__, param->value));
2402 case IW_AUTH_DROP_UNENCRYPTED:
2403 if (param->value != 0)
2404 pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED;
2407 //pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
2408 STA_PORT_SECURED(pAdapter);
2410 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_WPA_VERSION - param->value = %d!\n", __func__, param->value));
2412 case IW_AUTH_80211_AUTH_ALG:
2413 if (param->value & IW_AUTH_ALG_SHARED_KEY)
2415 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeShared;
2417 else if (param->value & IW_AUTH_ALG_OPEN_SYSTEM)
2419 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
2423 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_80211_AUTH_ALG - param->value = %d!\n", __func__, param->value));
2425 case IW_AUTH_WPA_ENABLED:
2426 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_WPA_ENABLED - Driver supports WPA!(param->value = %d)\n", __func__, param->value));
2435 int rt_ioctl_giwauth(struct net_device *dev,
2436 struct iw_request_info *info,
2437 union iwreq_data *wrqu, char *extra)
2439 PRTMP_ADAPTER pAdapter = dev->ml_priv;
2440 struct iw_param *param = &wrqu->param;
2442 //check if the interface is down
2443 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
2445 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
2449 switch (param->flags & IW_AUTH_INDEX) {
2450 case IW_AUTH_DROP_UNENCRYPTED:
2451 param->value = (pAdapter->StaCfg.WepStatus == Ndis802_11WEPDisabled) ? 0 : 1;
2454 case IW_AUTH_80211_AUTH_ALG:
2455 param->value = (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeShared) ? IW_AUTH_ALG_SHARED_KEY : IW_AUTH_ALG_OPEN_SYSTEM;
2458 case IW_AUTH_WPA_ENABLED:
2459 param->value = (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA) ? 1 : 0;
2465 DBGPRINT(RT_DEBUG_TRACE, ("rt_ioctl_giwauth::param->value = %d!\n", param->value));
2469 void fnSetCipherKey(
2470 IN PRTMP_ADAPTER pAdapter,
2474 IN struct iw_encode_ext *ext)
2476 NdisZeroMemory(&pAdapter->SharedKey[BSS0][keyIdx], sizeof(CIPHER_KEY));
2477 pAdapter->SharedKey[BSS0][keyIdx].KeyLen = LEN_TKIP_EK;
2478 NdisMoveMemory(pAdapter->SharedKey[BSS0][keyIdx].Key, ext->key, LEN_TKIP_EK);
2479 NdisMoveMemory(pAdapter->SharedKey[BSS0][keyIdx].TxMic, ext->key + LEN_TKIP_EK, LEN_TKIP_TXMICK);
2480 NdisMoveMemory(pAdapter->SharedKey[BSS0][keyIdx].RxMic, ext->key + LEN_TKIP_EK + LEN_TKIP_TXMICK, LEN_TKIP_RXMICK);
2481 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CipherAlg;
2483 // Update group key information to ASIC Shared Key Table
2484 AsicAddSharedKeyEntry(pAdapter,
2487 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg,
2488 pAdapter->SharedKey[BSS0][keyIdx].Key,
2489 pAdapter->SharedKey[BSS0][keyIdx].TxMic,
2490 pAdapter->SharedKey[BSS0][keyIdx].RxMic);
2493 // Update ASIC WCID attribute table and IVEIV table
2494 RTMPAddWcidAttributeEntry(pAdapter,
2497 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg,
2500 // Update ASIC WCID attribute table and IVEIV table
2501 RTMPAddWcidAttributeEntry(pAdapter,
2504 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg,
2505 &pAdapter->MacTab.Content[BSSID_WCID]);
2508 int rt_ioctl_siwencodeext(struct net_device *dev,
2509 struct iw_request_info *info,
2510 union iwreq_data *wrqu,
2513 PRTMP_ADAPTER pAdapter = dev->ml_priv;
2514 struct iw_point *encoding = &wrqu->encoding;
2515 struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
2516 int keyIdx, alg = ext->alg;
2518 //check if the interface is down
2519 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
2521 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
2525 if (encoding->flags & IW_ENCODE_DISABLED)
2527 keyIdx = (encoding->flags & IW_ENCODE_INDEX) - 1;
2528 // set BSSID wcid entry of the Pair-wise Key table as no-security mode
2529 AsicRemovePairwiseKeyEntry(pAdapter, BSS0, BSSID_WCID);
2530 pAdapter->SharedKey[BSS0][keyIdx].KeyLen = 0;
2531 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CIPHER_NONE;
2532 AsicRemoveSharedKeyEntry(pAdapter, 0, (UCHAR)keyIdx);
2533 NdisZeroMemory(&pAdapter->SharedKey[BSS0][keyIdx], sizeof(CIPHER_KEY));
2534 DBGPRINT(RT_DEBUG_TRACE, ("%s::Remove all keys!(encoding->flags = %x)\n", __func__, encoding->flags));
2538 // Get Key Index and convet to our own defined key index
2539 keyIdx = (encoding->flags & IW_ENCODE_INDEX) - 1;
2540 if((keyIdx < 0) || (keyIdx >= NR_WEP_KEYS))
2543 if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
2545 pAdapter->StaCfg.DefaultKeyId = keyIdx;
2546 DBGPRINT(RT_DEBUG_TRACE, ("%s::DefaultKeyId = %d\n", __func__, pAdapter->StaCfg.DefaultKeyId));
2550 case IW_ENCODE_ALG_NONE:
2551 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_ENCODE_ALG_NONE\n", __func__));
2553 case IW_ENCODE_ALG_WEP:
2554 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_ENCODE_ALG_WEP - ext->key_len = %d, keyIdx = %d\n", __func__, ext->key_len, keyIdx));
2555 if (ext->key_len == MAX_WEP_KEY_SIZE)
2557 pAdapter->SharedKey[BSS0][keyIdx].KeyLen = MAX_WEP_KEY_SIZE;
2558 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CIPHER_WEP128;
2560 else if (ext->key_len == MIN_WEP_KEY_SIZE)
2562 pAdapter->SharedKey[BSS0][keyIdx].KeyLen = MIN_WEP_KEY_SIZE;
2563 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CIPHER_WEP64;
2568 NdisZeroMemory(pAdapter->SharedKey[BSS0][keyIdx].Key, 16);
2569 NdisMoveMemory(pAdapter->SharedKey[BSS0][keyIdx].Key, ext->key, ext->key_len);
2571 if (pAdapter->StaCfg.GroupCipher == Ndis802_11GroupWEP40Enabled ||
2572 pAdapter->StaCfg.GroupCipher == Ndis802_11GroupWEP104Enabled)
2574 // Set Group key material to Asic
2575 AsicAddSharedKeyEntry(pAdapter, BSS0, keyIdx, pAdapter->SharedKey[BSS0][keyIdx].CipherAlg, pAdapter->SharedKey[BSS0][keyIdx].Key, NULL, NULL);
2577 // Update WCID attribute table and IVEIV table for this group key table
2578 RTMPAddWcidAttributeEntry(pAdapter, BSS0, keyIdx, pAdapter->SharedKey[BSS0][keyIdx].CipherAlg, NULL);
2580 STA_PORT_SECURED(pAdapter);
2582 // Indicate Connected for GUI
2583 pAdapter->IndicateMediaState = NdisMediaStateConnected;
2586 case IW_ENCODE_ALG_TKIP:
2587 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_ENCODE_ALG_TKIP - keyIdx = %d, ext->key_len = %d\n", __func__, keyIdx, ext->key_len));
2588 if (ext->key_len == 32)
2590 if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
2592 fnSetCipherKey(pAdapter, keyIdx, CIPHER_TKIP, FALSE, ext);
2593 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA2)
2595 //pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
2596 STA_PORT_SECURED(pAdapter);
2599 else if (ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY)
2601 fnSetCipherKey(pAdapter, keyIdx, CIPHER_TKIP, TRUE, ext);
2603 // set 802.1x port control
2604 //pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
2605 STA_PORT_SECURED(pAdapter);
2611 case IW_ENCODE_ALG_CCMP:
2612 if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
2614 fnSetCipherKey(pAdapter, keyIdx, CIPHER_AES, FALSE, ext);
2615 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA2)
2616 //pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
2617 STA_PORT_SECURED(pAdapter);
2619 else if (ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY)
2621 fnSetCipherKey(pAdapter, keyIdx, CIPHER_AES, TRUE, ext);
2623 // set 802.1x port control
2624 //pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
2625 STA_PORT_SECURED(pAdapter);
2637 rt_ioctl_giwencodeext(struct net_device *dev,
2638 struct iw_request_info *info,
2639 union iwreq_data *wrqu, char *extra)
2641 PRTMP_ADAPTER pAd = dev->ml_priv;
2643 struct iw_point *encoding = &wrqu->encoding;
2644 struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
2645 int idx, max_key_len;
2647 DBGPRINT(RT_DEBUG_TRACE ,("===> rt_ioctl_giwencodeext\n"));
2649 max_key_len = encoding->length - sizeof(*ext);
2650 if (max_key_len < 0)
2653 idx = encoding->flags & IW_ENCODE_INDEX;
2656 if (idx < 1 || idx > 4)
2660 if ((pAd->StaCfg.WepStatus == Ndis802_11Encryption2Enabled) ||
2661 (pAd->StaCfg.WepStatus == Ndis802_11Encryption3Enabled))
2663 if (idx != pAd->StaCfg.DefaultKeyId)
2671 idx = pAd->StaCfg.DefaultKeyId;
2673 encoding->flags = idx + 1;
2674 memset(ext, 0, sizeof(*ext));
2677 switch(pAd->StaCfg.WepStatus) {
2678 case Ndis802_11WEPDisabled:
2679 ext->alg = IW_ENCODE_ALG_NONE;
2680 encoding->flags |= IW_ENCODE_DISABLED;
2682 case Ndis802_11WEPEnabled:
2683 ext->alg = IW_ENCODE_ALG_WEP;
2684 if (pAd->SharedKey[BSS0][idx].KeyLen > max_key_len)
2688 ext->key_len = pAd->SharedKey[BSS0][idx].KeyLen;
2689 pKey = &(pAd->SharedKey[BSS0][idx].Key[0]);
2692 case Ndis802_11Encryption2Enabled:
2693 case Ndis802_11Encryption3Enabled:
2694 if (pAd->StaCfg.WepStatus == Ndis802_11Encryption2Enabled)
2695 ext->alg = IW_ENCODE_ALG_TKIP;
2697 ext->alg = IW_ENCODE_ALG_CCMP;
2699 if (max_key_len < 32)
2704 pKey = &pAd->StaCfg.PMK[0];
2711 if (ext->key_len && pKey)
2713 encoding->flags |= IW_ENCODE_ENABLED;
2714 memcpy(ext->key, pKey, ext->key_len);
2721 int rt_ioctl_siwgenie(struct net_device *dev,
2722 struct iw_request_info *info,
2723 union iwreq_data *wrqu, char *extra)
2725 PRTMP_ADAPTER pAd = dev->ml_priv;
2727 if (wrqu->data.length > MAX_LEN_OF_RSNIE ||
2728 (wrqu->data.length && extra == NULL))
2731 if (wrqu->data.length)
2733 pAd->StaCfg.RSNIE_Len = wrqu->data.length;
2734 NdisMoveMemory(&pAd->StaCfg.RSN_IE[0], extra, pAd->StaCfg.RSNIE_Len);
2738 pAd->StaCfg.RSNIE_Len = 0;
2739 NdisZeroMemory(&pAd->StaCfg.RSN_IE[0], MAX_LEN_OF_RSNIE);
2744 #endif // SIOCSIWGENIE //
2746 int rt_ioctl_giwgenie(struct net_device *dev,
2747 struct iw_request_info *info,
2748 union iwreq_data *wrqu, char *extra)
2750 PRTMP_ADAPTER pAd = dev->ml_priv;
2752 if ((pAd->StaCfg.RSNIE_Len == 0) ||
2753 (pAd->StaCfg.AuthMode < Ndis802_11AuthModeWPA))
2755 wrqu->data.length = 0;
2759 #ifdef NATIVE_WPA_SUPPLICANT_SUPPORT
2761 if (pAd->StaCfg.WpaSupplicantUP == WPA_SUPPLICANT_ENABLE)
2763 if (wrqu->data.length < pAd->StaCfg.RSNIE_Len)
2766 wrqu->data.length = pAd->StaCfg.RSNIE_Len;
2767 memcpy(extra, &pAd->StaCfg.RSN_IE[0], pAd->StaCfg.RSNIE_Len);
2770 #endif // SIOCSIWGENIE //
2771 #endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
2773 UCHAR RSNIe = IE_WPA;
2775 if (wrqu->data.length < (pAd->StaCfg.RSNIE_Len + 2)) // ID, Len
2777 wrqu->data.length = pAd->StaCfg.RSNIE_Len + 2;
2779 if ((pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK) ||
2780 (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2))
2783 extra[0] = (char)RSNIe;
2784 extra[1] = pAd->StaCfg.RSNIE_Len;
2785 memcpy(extra+2, &pAd->StaCfg.RSN_IE[0], pAd->StaCfg.RSNIE_Len);
2791 int rt_ioctl_siwpmksa(struct net_device *dev,
2792 struct iw_request_info *info,
2793 union iwreq_data *wrqu,
2796 PRTMP_ADAPTER pAd = dev->ml_priv;
2797 struct iw_pmksa *pPmksa = (struct iw_pmksa *)wrqu->data.pointer;
2798 INT CachedIdx = 0, idx = 0;
2803 DBGPRINT(RT_DEBUG_TRACE ,("===> rt_ioctl_siwpmksa\n"));
2806 case IW_PMKSA_FLUSH:
2807 NdisZeroMemory(pAd->StaCfg.SavedPMK, sizeof(BSSID_INFO)*PMKID_NO);
2808 DBGPRINT(RT_DEBUG_TRACE ,("rt_ioctl_siwpmksa - IW_PMKSA_FLUSH\n"));
2810 case IW_PMKSA_REMOVE:
2811 for (CachedIdx = 0; CachedIdx < pAd->StaCfg.SavedPMKNum; CachedIdx++)
2813 // compare the BSSID
2814 if (NdisEqualMemory(pPmksa->bssid.sa_data, pAd->StaCfg.SavedPMK[CachedIdx].BSSID, MAC_ADDR_LEN))
2816 NdisZeroMemory(pAd->StaCfg.SavedPMK[CachedIdx].BSSID, MAC_ADDR_LEN);
2817 NdisZeroMemory(pAd->StaCfg.SavedPMK[CachedIdx].PMKID, 16);
2818 for (idx = CachedIdx; idx < (pAd->StaCfg.SavedPMKNum - 1); idx++)
2820 NdisMoveMemory(&pAd->StaCfg.SavedPMK[idx].BSSID[0], &pAd->StaCfg.SavedPMK[idx+1].BSSID[0], MAC_ADDR_LEN);
2821 NdisMoveMemory(&pAd->StaCfg.SavedPMK[idx].PMKID[0], &pAd->StaCfg.SavedPMK[idx+1].PMKID[0], 16);
2823 pAd->StaCfg.SavedPMKNum--;
2828 DBGPRINT(RT_DEBUG_TRACE ,("rt_ioctl_siwpmksa - IW_PMKSA_REMOVE\n"));
2831 for (CachedIdx = 0; CachedIdx < pAd->StaCfg.SavedPMKNum; CachedIdx++)
2833 // compare the BSSID
2834 if (NdisEqualMemory(pPmksa->bssid.sa_data, pAd->StaCfg.SavedPMK[CachedIdx].BSSID, MAC_ADDR_LEN))
2838 // Found, replace it
2839 if (CachedIdx < PMKID_NO)
2841 DBGPRINT(RT_DEBUG_OFF, ("Update PMKID, idx = %d\n", CachedIdx));
2842 NdisMoveMemory(&pAd->StaCfg.SavedPMK[CachedIdx].BSSID[0], pPmksa->bssid.sa_data, MAC_ADDR_LEN);
2843 NdisMoveMemory(&pAd->StaCfg.SavedPMK[CachedIdx].PMKID[0], pPmksa->pmkid, 16);
2844 pAd->StaCfg.SavedPMKNum++;
2846 // Not found, replace the last one
2849 // Randomly replace one
2850 CachedIdx = (pPmksa->bssid.sa_data[5] % PMKID_NO);
2851 DBGPRINT(RT_DEBUG_OFF, ("Update PMKID, idx = %d\n", CachedIdx));
2852 NdisMoveMemory(&pAd->StaCfg.SavedPMK[CachedIdx].BSSID[0], pPmksa->bssid.sa_data, MAC_ADDR_LEN);
2853 NdisMoveMemory(&pAd->StaCfg.SavedPMK[CachedIdx].PMKID[0], pPmksa->pmkid, 16);
2856 DBGPRINT(RT_DEBUG_TRACE ,("rt_ioctl_siwpmksa - IW_PMKSA_ADD\n"));
2859 DBGPRINT(RT_DEBUG_TRACE ,("rt_ioctl_siwpmksa - Unknow Command!!\n"));
2865 #endif // #if WIRELESS_EXT > 17
2869 rt_private_ioctl_bbp(struct net_device *dev, struct iw_request_info *info,
2870 struct iw_point *wrq, char *extra)
2875 // CHAR arg[255]={0};
2878 BOOLEAN bIsPrintAllBBP = FALSE;
2880 PRTMP_ADAPTER pAdapter = dev->ml_priv;
2883 memset(extra, 0x00, IW_PRIV_SIZE_MASK);
2885 if (wrq->length > 1) //No parameters.
2887 sprintf(extra, "\n");
2889 //Parsing Read or Write
2890 this_char = wrq->pointer;
2891 DBGPRINT(RT_DEBUG_TRACE, ("this_char=%s\n", this_char));
2895 if ((value = rtstrchr(this_char, '=')) != NULL)
2898 if (!value || !*value)
2900 DBGPRINT(RT_DEBUG_TRACE, ("this_char=%s, value=%s\n", this_char, value));
2901 if (sscanf(this_char, "%d", &(bbpId)) == 1)
2906 if (ATE_ON(pAdapter))
2908 ATE_BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, ®BBP);
2911 #endif // RALINK_ATE //
2913 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, ®BBP);
2915 sprintf(extra+strlen(extra), "R%02d[0x%02X]:%02X\n", bbpId, bbpId*2, regBBP);
2916 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2917 DBGPRINT(RT_DEBUG_TRACE, ("msg=%s\n", extra));
2920 {//Invalid parametes, so default printk all bbp
2921 bIsPrintAllBBP = TRUE;
2926 { //Invalid parametes, so default printk all bbp
2927 bIsPrintAllBBP = TRUE;
2933 if ((sscanf(this_char, "%d", &(bbpId)) == 1) && (sscanf(value, "%x", &(bbpValue)) == 1))
2938 if (ATE_ON(pAdapter))
2940 ATE_BBP_IO_WRITE8_BY_REG_ID(pAdapter, bbpId, bbpValue);
2941 //Read it back for showing
2942 ATE_BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, ®BBP);
2945 #endif // RALINK_ATE //
2947 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, bbpId, bbpValue);
2948 //Read it back for showing
2949 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, ®BBP);
2951 sprintf(extra+strlen(extra), "R%02d[0x%02X]:%02X\n", bbpId, bbpId*2, regBBP);
2952 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2953 DBGPRINT(RT_DEBUG_TRACE, ("msg=%s\n", extra));
2956 {//Invalid parametes, so default printk all bbp
2957 bIsPrintAllBBP = TRUE;
2962 { //Invalid parametes, so default printk all bbp
2963 bIsPrintAllBBP = TRUE;
2969 bIsPrintAllBBP = TRUE;
2974 memset(extra, 0x00, IW_PRIV_SIZE_MASK);
2975 sprintf(extra, "\n");
2976 for (bbpId = 0; bbpId <= 136; bbpId++)
2978 if (strlen(extra) >= (IW_PRIV_SIZE_MASK - 10))
2981 if (ATE_ON(pAdapter))
2983 ATE_BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, ®BBP);
2986 #endif // RALINK_ATE //
2987 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, ®BBP);
2988 sprintf(extra+strlen(extra), "R%02d[0x%02X]:%02X ", bbpId, bbpId*2, regBBP);
2990 sprintf(extra+strlen(extra), "\n");
2993 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2994 DBGPRINT(RT_DEBUG_TRACE, ("wrq->length = %d\n", wrq->length));
2997 DBGPRINT(RT_DEBUG_TRACE, ("<==rt_private_ioctl_bbp\n\n"));
3003 int rt_ioctl_siwrate(struct net_device *dev,
3004 struct iw_request_info *info,
3005 union iwreq_data *wrqu, char *extra)
3007 PRTMP_ADAPTER pAd = dev->ml_priv;
3008 UINT32 rate = wrqu->bitrate.value, fixed = wrqu->bitrate.fixed;
3010 //check if the interface is down
3011 if(!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_IN_USE))
3013 DBGPRINT(RT_DEBUG_TRACE, ("rt_ioctl_siwrate::Network is down!\n"));
3017 DBGPRINT(RT_DEBUG_TRACE, ("rt_ioctl_siwrate::(rate = %d, fixed = %d)\n", rate, fixed));
3018 /* rate = -1 => auto rate
3019 rate = X, fixed = 1 => (fixed rate X)
3024 pAd->StaCfg.DesiredTransmitSetting.field.MCS = MCS_AUTO;
3025 pAd->StaCfg.bAutoTxRateSwitch = TRUE;
3026 if ((pAd->CommonCfg.PhyMode <= PHY_11G) ||
3027 (pAd->MacTab.Content[BSSID_WCID].HTPhyMode.field.MODE <= MODE_OFDM))
3028 RTMPSetDesiredRates(pAd, -1);
3030 #ifdef DOT11_N_SUPPORT
3032 #endif // DOT11_N_SUPPORT //
3038 pAd->StaCfg.bAutoTxRateSwitch = FALSE;
3039 if ((pAd->CommonCfg.PhyMode <= PHY_11G) ||
3040 (pAd->MacTab.Content[BSSID_WCID].HTPhyMode.field.MODE <= MODE_OFDM))
3041 RTMPSetDesiredRates(pAd, rate);
3044 pAd->StaCfg.DesiredTransmitSetting.field.MCS = MCS_AUTO;
3045 #ifdef DOT11_N_SUPPORT
3047 #endif // DOT11_N_SUPPORT //
3049 DBGPRINT(RT_DEBUG_TRACE, ("rt_ioctl_siwrate::(HtMcs=%d)\n",pAd->StaCfg.DesiredTransmitSetting.field.MCS));
3053 // TODO: rate = X, fixed = 0 => (rates <= X)
3061 int rt_ioctl_giwrate(struct net_device *dev,
3062 struct iw_request_info *info,
3063 union iwreq_data *wrqu, char *extra)
3065 PRTMP_ADAPTER pAd = dev->ml_priv;
3066 int rate_index = 0, rate_count = 0;
3067 HTTRANSMIT_SETTING ht_setting;
3068 __s32 ralinkrate[] =
3069 {2, 4, 11, 22, // CCK
3070 12, 18, 24, 36, 48, 72, 96, 108, // OFDM
3071 13, 26, 39, 52, 78, 104, 117, 130, 26, 52, 78, 104, 156, 208, 234, 260, // 20MHz, 800ns GI, MCS: 0 ~ 15
3072 39, 78, 117, 156, 234, 312, 351, 390, // 20MHz, 800ns GI, MCS: 16 ~ 23
3073 27, 54, 81, 108, 162, 216, 243, 270, 54, 108, 162, 216, 324, 432, 486, 540, // 40MHz, 800ns GI, MCS: 0 ~ 15
3074 81, 162, 243, 324, 486, 648, 729, 810, // 40MHz, 800ns GI, MCS: 16 ~ 23
3075 14, 29, 43, 57, 87, 115, 130, 144, 29, 59, 87, 115, 173, 230, 260, 288, // 20MHz, 400ns GI, MCS: 0 ~ 15
3076 43, 87, 130, 173, 260, 317, 390, 433, // 20MHz, 400ns GI, MCS: 16 ~ 23
3077 30, 60, 90, 120, 180, 240, 270, 300, 60, 120, 180, 240, 360, 480, 540, 600, // 40MHz, 400ns GI, MCS: 0 ~ 15
3078 90, 180, 270, 360, 540, 720, 810, 900}; // 40MHz, 400ns GI, MCS: 16 ~ 23
3080 rate_count = sizeof(ralinkrate)/sizeof(__s32);
3081 //check if the interface is down
3082 if(!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_IN_USE))
3084 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
3088 if ((pAd->StaCfg.bAutoTxRateSwitch == FALSE) &&
3090 ((pAd->CommonCfg.PhyMode <= PHY_11G) || (pAd->MacTab.Content[BSSID_WCID].HTPhyMode.field.MODE <= MODE_OFDM)))
3091 ht_setting.word = pAd->StaCfg.HTPhyMode.word;
3093 ht_setting.word = pAd->MacTab.Content[BSSID_WCID].HTPhyMode.word;
3095 #ifdef DOT11_N_SUPPORT
3096 if (ht_setting.field.MODE >= MODE_HTMIX)
3098 // rate_index = 12 + ((UCHAR)ht_setting.field.BW *16) + ((UCHAR)ht_setting.field.ShortGI *32) + ((UCHAR)ht_setting.field.MCS);
3099 rate_index = 12 + ((UCHAR)ht_setting.field.BW *24) + ((UCHAR)ht_setting.field.ShortGI *48) + ((UCHAR)ht_setting.field.MCS);
3102 #endif // DOT11_N_SUPPORT //
3103 if (ht_setting.field.MODE == MODE_OFDM)
3104 rate_index = (UCHAR)(ht_setting.field.MCS) + 4;
3105 else if (ht_setting.field.MODE == MODE_CCK)
3106 rate_index = (UCHAR)(ht_setting.field.MCS);
3111 if (rate_index > rate_count)
3112 rate_index = rate_count;
3114 wrqu->bitrate.value = ralinkrate[rate_index] * 500000;
3115 wrqu->bitrate.disabled = 0;
3120 static const iw_handler rt_handler[] =
3122 (iw_handler) NULL, /* SIOCSIWCOMMIT */
3123 (iw_handler) rt_ioctl_giwname, /* SIOCGIWNAME */
3124 (iw_handler) NULL, /* SIOCSIWNWID */
3125 (iw_handler) NULL, /* SIOCGIWNWID */
3126 (iw_handler) rt_ioctl_siwfreq, /* SIOCSIWFREQ */
3127 (iw_handler) rt_ioctl_giwfreq, /* SIOCGIWFREQ */
3128 (iw_handler) rt_ioctl_siwmode, /* SIOCSIWMODE */
3129 (iw_handler) rt_ioctl_giwmode, /* SIOCGIWMODE */
3130 (iw_handler) NULL, /* SIOCSIWSENS */
3131 (iw_handler) NULL, /* SIOCGIWSENS */
3132 (iw_handler) NULL /* not used */, /* SIOCSIWRANGE */
3133 (iw_handler) rt_ioctl_giwrange, /* SIOCGIWRANGE */
3134 (iw_handler) NULL /* not used */, /* SIOCSIWPRIV */
3135 (iw_handler) NULL /* kernel code */, /* SIOCGIWPRIV */
3136 (iw_handler) NULL /* not used */, /* SIOCSIWSTATS */
3137 (iw_handler) rt28xx_get_wireless_stats /* kernel code */, /* SIOCGIWSTATS */
3138 (iw_handler) NULL, /* SIOCSIWSPY */
3139 (iw_handler) NULL, /* SIOCGIWSPY */
3140 (iw_handler) NULL, /* SIOCSIWTHRSPY */
3141 (iw_handler) NULL, /* SIOCGIWTHRSPY */
3142 (iw_handler) rt_ioctl_siwap, /* SIOCSIWAP */
3143 (iw_handler) rt_ioctl_giwap, /* SIOCGIWAP */
3145 (iw_handler) rt_ioctl_siwmlme, /* SIOCSIWMLME */
3147 (iw_handler) NULL, /* SIOCSIWMLME */
3148 #endif // SIOCSIWMLME //
3149 (iw_handler) rt_ioctl_iwaplist, /* SIOCGIWAPLIST */
3151 (iw_handler) rt_ioctl_siwscan, /* SIOCSIWSCAN */
3152 (iw_handler) rt_ioctl_giwscan, /* SIOCGIWSCAN */
3154 (iw_handler) NULL, /* SIOCSIWSCAN */
3155 (iw_handler) NULL, /* SIOCGIWSCAN */
3156 #endif /* SIOCGIWSCAN */
3157 (iw_handler) rt_ioctl_siwessid, /* SIOCSIWESSID */
3158 (iw_handler) rt_ioctl_giwessid, /* SIOCGIWESSID */
3159 (iw_handler) rt_ioctl_siwnickn, /* SIOCSIWNICKN */
3160 (iw_handler) rt_ioctl_giwnickn, /* SIOCGIWNICKN */
3161 (iw_handler) NULL, /* -- hole -- */
3162 (iw_handler) NULL, /* -- hole -- */
3163 (iw_handler) rt_ioctl_siwrate, /* SIOCSIWRATE */
3164 (iw_handler) rt_ioctl_giwrate, /* SIOCGIWRATE */
3165 (iw_handler) rt_ioctl_siwrts, /* SIOCSIWRTS */
3166 (iw_handler) rt_ioctl_giwrts, /* SIOCGIWRTS */
3167 (iw_handler) rt_ioctl_siwfrag, /* SIOCSIWFRAG */
3168 (iw_handler) rt_ioctl_giwfrag, /* SIOCGIWFRAG */
3169 (iw_handler) NULL, /* SIOCSIWTXPOW */
3170 (iw_handler) NULL, /* SIOCGIWTXPOW */
3171 (iw_handler) NULL, /* SIOCSIWRETRY */
3172 (iw_handler) NULL, /* SIOCGIWRETRY */
3173 (iw_handler) rt_ioctl_siwencode, /* SIOCSIWENCODE */
3174 (iw_handler) rt_ioctl_giwencode, /* SIOCGIWENCODE */
3175 (iw_handler) NULL, /* SIOCSIWPOWER */
3176 (iw_handler) NULL, /* SIOCGIWPOWER */
3177 (iw_handler) NULL, /* -- hole -- */
3178 (iw_handler) NULL, /* -- hole -- */
3179 #if WIRELESS_EXT > 17
3180 (iw_handler) rt_ioctl_siwgenie, /* SIOCSIWGENIE */
3181 (iw_handler) rt_ioctl_giwgenie, /* SIOCGIWGENIE */
3182 (iw_handler) rt_ioctl_siwauth, /* SIOCSIWAUTH */
3183 (iw_handler) rt_ioctl_giwauth, /* SIOCGIWAUTH */
3184 (iw_handler) rt_ioctl_siwencodeext, /* SIOCSIWENCODEEXT */
3185 (iw_handler) rt_ioctl_giwencodeext, /* SIOCGIWENCODEEXT */
3186 (iw_handler) rt_ioctl_siwpmksa, /* SIOCSIWPMKSA */
3190 static const iw_handler rt_priv_handlers[] = {
3191 (iw_handler) NULL, /* + 0x00 */
3192 (iw_handler) NULL, /* + 0x01 */
3193 #ifndef CONFIG_AP_SUPPORT
3194 (iw_handler) rt_ioctl_setparam, /* + 0x02 */
3196 (iw_handler) NULL, /* + 0x02 */
3197 #endif // CONFIG_AP_SUPPORT //
3199 (iw_handler) rt_private_ioctl_bbp, /* + 0x03 */
3201 (iw_handler) NULL, /* + 0x03 */
3203 (iw_handler) NULL, /* + 0x04 */
3204 (iw_handler) NULL, /* + 0x05 */
3205 (iw_handler) NULL, /* + 0x06 */
3206 (iw_handler) NULL, /* + 0x07 */
3207 (iw_handler) NULL, /* + 0x08 */
3208 (iw_handler) rt_private_get_statistics, /* + 0x09 */
3209 (iw_handler) NULL, /* + 0x0A */
3210 (iw_handler) NULL, /* + 0x0B */
3211 (iw_handler) NULL, /* + 0x0C */
3212 (iw_handler) NULL, /* + 0x0D */
3213 (iw_handler) NULL, /* + 0x0E */
3214 (iw_handler) NULL, /* + 0x0F */
3215 (iw_handler) NULL, /* + 0x10 */
3216 (iw_handler) rt_private_show, /* + 0x11 */
3217 (iw_handler) NULL, /* + 0x12 */
3218 (iw_handler) NULL, /* + 0x13 */
3219 (iw_handler) NULL, /* + 0x15 */
3220 (iw_handler) NULL, /* + 0x17 */
3221 (iw_handler) NULL, /* + 0x18 */
3224 const struct iw_handler_def rt28xx_iw_handler_def =
3226 #define N(a) (sizeof (a) / sizeof (a[0]))
3227 .standard = (iw_handler *) rt_handler,
3228 .num_standard = sizeof(rt_handler) / sizeof(iw_handler),
3229 .private = (iw_handler *) rt_priv_handlers,
3230 .num_private = N(rt_priv_handlers),
3231 .private_args = (struct iw_priv_args *) privtab,
3232 .num_private_args = N(privtab),
3233 #if IW_HANDLER_VERSION >= 7
3234 .get_wireless_stats = rt28xx_get_wireless_stats,
3238 INT RTMPSetInformation(
3239 IN PRTMP_ADAPTER pAdapter,
3240 IN OUT struct ifreq *rq,
3243 struct iwreq *wrq = (struct iwreq *) rq;
3244 NDIS_802_11_SSID Ssid;
3245 NDIS_802_11_MAC_ADDRESS Bssid;
3246 RT_802_11_PHY_MODE PhyMode;
3247 RT_802_11_STA_CONFIG StaConfig;
3248 NDIS_802_11_RATES aryRates;
3249 RT_802_11_PREAMBLE Preamble;
3250 NDIS_802_11_WEP_STATUS WepStatus;
3251 NDIS_802_11_AUTHENTICATION_MODE AuthMode = Ndis802_11AuthModeMax;
3252 NDIS_802_11_NETWORK_INFRASTRUCTURE BssType;
3253 NDIS_802_11_RTS_THRESHOLD RtsThresh;
3254 NDIS_802_11_FRAGMENTATION_THRESHOLD FragThresh;
3255 NDIS_802_11_POWER_MODE PowerMode;
3256 PNDIS_802_11_KEY pKey = NULL;
3257 PNDIS_802_11_WEP pWepKey =NULL;
3258 PNDIS_802_11_REMOVE_KEY pRemoveKey = NULL;
3259 NDIS_802_11_CONFIGURATION Config, *pConfig = NULL;
3260 NDIS_802_11_NETWORK_TYPE NetType;
3263 INT Status = NDIS_STATUS_SUCCESS, MaxPhyMode = PHY_11G;
3266 BOOLEAN StateMachineTouched = FALSE;
3267 #ifdef DOT11_N_SUPPORT
3268 OID_SET_HT_PHYMODE HT_PhyMode; //11n ,kathy
3269 #endif // DOT11_N_SUPPORT //
3270 #ifdef WPA_SUPPLICANT_SUPPORT
3271 PNDIS_802_11_PMKID pPmkId = NULL;
3272 BOOLEAN IEEE8021xState = FALSE;
3273 BOOLEAN IEEE8021x_required_keys = FALSE;
3274 UCHAR wpa_supplicant_enable = 0;
3275 #endif // WPA_SUPPLICANT_SUPPORT //
3278 TX_RTY_CFG_STRUC tx_rty_cfg;
3279 ULONG ShortRetryLimit, LongRetryLimit;
3281 #endif // SNMP_SUPPORT //
3285 #ifdef DOT11_N_SUPPORT
3286 MaxPhyMode = PHY_11N_5G;
3287 #endif // DOT11_N_SUPPORT //
3290 DBGPRINT(RT_DEBUG_TRACE, ("-->RTMPSetInformation(), 0x%08x\n", cmd&0x7FFF));
3291 switch(cmd & 0x7FFF) {
3292 case RT_OID_802_11_COUNTRY_REGION:
3293 if (wrq->u.data.length < sizeof(UCHAR))
3295 // Only avaliable when EEPROM not programming
3296 else if (!(pAdapter->CommonCfg.CountryRegion & 0x80) && !(pAdapter->CommonCfg.CountryRegionForABand & 0x80))
3301 Status = copy_from_user(&Country, wrq->u.data.pointer, wrq->u.data.length);
3302 pAdapter->CommonCfg.CountryRegion = (UCHAR)(Country & 0x000000FF);
3303 pAdapter->CommonCfg.CountryRegionForABand = (UCHAR)((Country >> 8) & 0x000000FF);
3304 TmpPhy = pAdapter->CommonCfg.PhyMode;
3305 pAdapter->CommonCfg.PhyMode = 0xff;
3306 // Build all corresponding channel information
3307 RTMPSetPhyMode(pAdapter, TmpPhy);
3308 #ifdef DOT11_N_SUPPORT
3309 SetCommonHT(pAdapter);
3310 #endif // DOT11_N_SUPPORT //
3311 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_COUNTRY_REGION (A:%d B/G:%d)\n", pAdapter->CommonCfg.CountryRegionForABand,
3312 pAdapter->CommonCfg.CountryRegion));
3315 case OID_802_11_BSSID_LIST_SCAN:
3317 if (ATE_ON(pAdapter))
3319 DBGPRINT(RT_DEBUG_TRACE, ("The driver is in ATE mode now\n"));
3322 #endif // RALINK_ATE //
3324 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_BSSID_LIST_SCAN, TxCnt = %d \n", pAdapter->RalinkCounters.LastOneSecTotalTxCount));
3326 if (MONITOR_ON(pAdapter))
3328 DBGPRINT(RT_DEBUG_TRACE, ("!!! Driver is in Monitor Mode now !!!\n"));
3332 //Benson add 20080527, when radio off, sta don't need to scan
3333 if (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_RADIO_OFF))
3336 if (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
3338 DBGPRINT(RT_DEBUG_TRACE, ("!!! Driver is scanning now !!!\n"));
3339 pAdapter->StaCfg.bScanReqIsFromWebUI = TRUE;
3340 Status = NDIS_STATUS_SUCCESS;
3344 if (pAdapter->RalinkCounters.LastOneSecTotalTxCount > 100)
3346 DBGPRINT(RT_DEBUG_TRACE, ("!!! Link UP, ignore this set::OID_802_11_BSSID_LIST_SCAN\n"));
3347 Status = NDIS_STATUS_SUCCESS;
3348 pAdapter->StaCfg.ScanCnt = 99; // Prevent auto scan triggered by this OID
3352 if ((OPSTATUS_TEST_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED)) &&
3353 ((pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA) ||
3354 (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK) ||
3355 (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA2) ||
3356 (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK)) &&
3357 (pAdapter->StaCfg.PortSecured == WPA_802_1X_PORT_NOT_SECURED))
3359 DBGPRINT(RT_DEBUG_TRACE, ("!!! Link UP, Port Not Secured! ignore this set::OID_802_11_BSSID_LIST_SCAN\n"));
3360 Status = NDIS_STATUS_SUCCESS;
3361 pAdapter->StaCfg.ScanCnt = 99; // Prevent auto scan triggered by this OID
3366 if (pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE)
3368 RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
3369 DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
3372 // tell CNTL state machine to call NdisMSetInformationComplete() after completing
3373 // this request, because this request is initiated by NDIS.
3374 pAdapter->MlmeAux.CurrReqIsFromNdis = FALSE;
3375 // Reset allowed scan retries
3376 pAdapter->StaCfg.ScanCnt = 0;
3377 pAdapter->StaCfg.LastScanTime = Now;
3379 pAdapter->StaCfg.bScanReqIsFromWebUI = TRUE;
3380 RTMP_SET_FLAG(pAdapter, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS);
3381 MlmeEnqueue(pAdapter,
3382 MLME_CNTL_STATE_MACHINE,
3383 OID_802_11_BSSID_LIST_SCAN,
3387 Status = NDIS_STATUS_SUCCESS;
3388 StateMachineTouched = TRUE;
3390 case OID_802_11_SSID:
3391 if (wrq->u.data.length != sizeof(NDIS_802_11_SSID))
3395 PCHAR pSsidString = NULL;
3396 Status = copy_from_user(&Ssid, wrq->u.data.pointer, wrq->u.data.length);
3398 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_SSID (Len=%d,Ssid=%s)\n", Ssid.SsidLength, Ssid.Ssid));
3399 if (Ssid.SsidLength > MAX_LEN_OF_SSID)
3403 if (Ssid.SsidLength == 0)
3405 Set_SSID_Proc(pAdapter, "");
3409 pSsidString = (CHAR *) kmalloc(MAX_LEN_OF_SSID+1, MEM_ALLOC_FLAG);
3412 NdisZeroMemory(pSsidString, MAX_LEN_OF_SSID+1);
3413 NdisMoveMemory(pSsidString, Ssid.Ssid, Ssid.SsidLength);
3414 Set_SSID_Proc(pAdapter, pSsidString);
3423 case OID_802_11_BSSID:
3425 if (ATE_ON(pAdapter))
3427 DBGPRINT(RT_DEBUG_TRACE, ("The driver is in ATE mode now\n"));
3430 #endif // RALINK_ATE //
3431 if (wrq->u.data.length != sizeof(NDIS_802_11_MAC_ADDRESS))
3435 Status = copy_from_user(&Bssid, wrq->u.data.pointer, wrq->u.data.length);
3437 // tell CNTL state machine to call NdisMSetInformationComplete() after completing
3438 // this request, because this request is initiated by NDIS.
3439 pAdapter->MlmeAux.CurrReqIsFromNdis = FALSE;
3441 // Prevent to connect AP again in STAMlmePeriodicExec
3442 pAdapter->MlmeAux.AutoReconnectSsidLen= 32;
3444 // Reset allowed scan retries
3445 pAdapter->StaCfg.ScanCnt = 0;
3447 if (pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE)
3449 RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
3450 DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
3452 MlmeEnqueue(pAdapter,
3453 MLME_CNTL_STATE_MACHINE,
3455 sizeof(NDIS_802_11_MAC_ADDRESS),
3457 Status = NDIS_STATUS_SUCCESS;
3458 StateMachineTouched = TRUE;
3460 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_BSSID %02x:%02x:%02x:%02x:%02x:%02x\n",
3461 Bssid[0], Bssid[1], Bssid[2], Bssid[3], Bssid[4], Bssid[5]));
3464 case RT_OID_802_11_RADIO:
3465 if (wrq->u.data.length != sizeof(BOOLEAN))
3469 Status = copy_from_user(&RadioState, wrq->u.data.pointer, wrq->u.data.length);
3470 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_RADIO (=%d)\n", RadioState));
3471 if (pAdapter->StaCfg.bSwRadio != RadioState)
3473 pAdapter->StaCfg.bSwRadio = RadioState;
3474 if (pAdapter->StaCfg.bRadio != (pAdapter->StaCfg.bHwRadio && pAdapter->StaCfg.bSwRadio))
3476 pAdapter->StaCfg.bRadio = (pAdapter->StaCfg.bHwRadio && pAdapter->StaCfg.bSwRadio);
3477 if (pAdapter->StaCfg.bRadio == TRUE)
3479 MlmeRadioOn(pAdapter);
3480 // Update extra information
3481 pAdapter->ExtraInfo = EXTRA_INFO_CLEAR;
3485 MlmeRadioOff(pAdapter);
3486 // Update extra information
3487 pAdapter->ExtraInfo = SW_RADIO_OFF;
3493 case RT_OID_802_11_PHY_MODE:
3494 if (wrq->u.data.length != sizeof(RT_802_11_PHY_MODE))
3498 Status = copy_from_user(&PhyMode, wrq->u.data.pointer, wrq->u.data.length);
3499 if (PhyMode <= MaxPhyMode)
3501 RTMPSetPhyMode(pAdapter, PhyMode);
3502 #ifdef DOT11_N_SUPPORT
3503 SetCommonHT(pAdapter);
3504 #endif // DOT11_N_SUPPORT //
3506 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_PHY_MODE (=%d)\n", PhyMode));
3509 case RT_OID_802_11_STA_CONFIG:
3510 if (wrq->u.data.length != sizeof(RT_802_11_STA_CONFIG))
3514 Status = copy_from_user(&StaConfig, wrq->u.data.pointer, wrq->u.data.length);
3515 pAdapter->CommonCfg.bEnableTxBurst = StaConfig.EnableTxBurst;
3516 pAdapter->CommonCfg.UseBGProtection = StaConfig.UseBGProtection;
3517 pAdapter->CommonCfg.bUseShortSlotTime = 1; // 2003-10-30 always SHORT SLOT capable
3518 if ((pAdapter->CommonCfg.PhyMode != StaConfig.AdhocMode) &&
3519 (StaConfig.AdhocMode <= MaxPhyMode))
3521 // allow dynamic change of "USE OFDM rate or not" in ADHOC mode
3522 // if setting changed, need to reset current TX rate as well as BEACON frame format
3523 if (pAdapter->StaCfg.BssType == BSS_ADHOC)
3525 pAdapter->CommonCfg.PhyMode = StaConfig.AdhocMode;
3526 RTMPSetPhyMode(pAdapter, PhyMode);
3527 MlmeUpdateTxRates(pAdapter, FALSE, 0);
3528 MakeIbssBeacon(pAdapter); // re-build BEACON frame
3529 AsicEnableIbssSync(pAdapter); // copy to on-chip memory
3532 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_SET_STA_CONFIG (Burst=%d, Protection=%ld,ShortSlot=%d\n",
3533 pAdapter->CommonCfg.bEnableTxBurst,
3534 pAdapter->CommonCfg.UseBGProtection,
3535 pAdapter->CommonCfg.bUseShortSlotTime));
3538 case OID_802_11_DESIRED_RATES:
3539 if (wrq->u.data.length != sizeof(NDIS_802_11_RATES))
3543 Status = copy_from_user(&aryRates, wrq->u.data.pointer, wrq->u.data.length);
3544 NdisZeroMemory(pAdapter->CommonCfg.DesireRate, MAX_LEN_OF_SUPPORTED_RATES);
3545 NdisMoveMemory(pAdapter->CommonCfg.DesireRate, &aryRates, sizeof(NDIS_802_11_RATES));
3546 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_DESIRED_RATES (%02x,%02x,%02x,%02x,%02x,%02x,%02x,%02x)\n",
3547 pAdapter->CommonCfg.DesireRate[0],pAdapter->CommonCfg.DesireRate[1],
3548 pAdapter->CommonCfg.DesireRate[2],pAdapter->CommonCfg.DesireRate[3],
3549 pAdapter->CommonCfg.DesireRate[4],pAdapter->CommonCfg.DesireRate[5],
3550 pAdapter->CommonCfg.DesireRate[6],pAdapter->CommonCfg.DesireRate[7] ));
3551 // Changing DesiredRate may affect the MAX TX rate we used to TX frames out
3552 MlmeUpdateTxRates(pAdapter, FALSE, 0);
3555 case RT_OID_802_11_PREAMBLE:
3556 if (wrq->u.data.length != sizeof(RT_802_11_PREAMBLE))
3560 Status = copy_from_user(&Preamble, wrq->u.data.pointer, wrq->u.data.length);
3561 if (Preamble == Rt802_11PreambleShort)
3563 pAdapter->CommonCfg.TxPreamble = Preamble;
3564 MlmeSetTxPreamble(pAdapter, Rt802_11PreambleShort);
3566 else if ((Preamble == Rt802_11PreambleLong) || (Preamble == Rt802_11PreambleAuto))
3568 // if user wants AUTO, initialize to LONG here, then change according to AP's
3569 // capability upon association.
3570 pAdapter->CommonCfg.TxPreamble = Preamble;
3571 MlmeSetTxPreamble(pAdapter, Rt802_11PreambleLong);
3578 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_PREAMBLE (=%d)\n", Preamble));
3581 case OID_802_11_WEP_STATUS:
3582 if (wrq->u.data.length != sizeof(NDIS_802_11_WEP_STATUS))
3586 Status = copy_from_user(&WepStatus, wrq->u.data.pointer, wrq->u.data.length);
3587 // Since TKIP, AES, WEP are all supported. It should not have any invalid setting
3588 if (WepStatus <= Ndis802_11Encryption3KeyAbsent)
3590 if (pAdapter->StaCfg.WepStatus != WepStatus)
3592 // Config has changed
3593 pAdapter->bConfigChanged = TRUE;
3595 pAdapter->StaCfg.WepStatus = WepStatus;
3596 pAdapter->StaCfg.OrigWepStatus = WepStatus;
3597 pAdapter->StaCfg.PairCipher = WepStatus;
3598 pAdapter->StaCfg.GroupCipher = WepStatus;
3605 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_WEP_STATUS (=%d)\n",WepStatus));
3608 case OID_802_11_AUTHENTICATION_MODE:
3609 if (wrq->u.data.length != sizeof(NDIS_802_11_AUTHENTICATION_MODE))
3613 Status = copy_from_user(&AuthMode, wrq->u.data.pointer, wrq->u.data.length);
3614 if (AuthMode > Ndis802_11AuthModeMax)
3621 if (pAdapter->StaCfg.AuthMode != AuthMode)
3623 // Config has changed
3624 pAdapter->bConfigChanged = TRUE;
3626 pAdapter->StaCfg.AuthMode = AuthMode;
3628 pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED;
3629 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_AUTHENTICATION_MODE (=%d) \n",pAdapter->StaCfg.AuthMode));
3632 case OID_802_11_INFRASTRUCTURE_MODE:
3633 if (wrq->u.data.length != sizeof(NDIS_802_11_NETWORK_INFRASTRUCTURE))
3637 Status = copy_from_user(&BssType, wrq->u.data.pointer, wrq->u.data.length);
3639 if (BssType == Ndis802_11IBSS)
3640 Set_NetworkType_Proc(pAdapter, "Adhoc");
3641 else if (BssType == Ndis802_11Infrastructure)
3642 Set_NetworkType_Proc(pAdapter, "Infra");
3643 else if (BssType == Ndis802_11Monitor)
3644 Set_NetworkType_Proc(pAdapter, "Monitor");
3648 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_INFRASTRUCTURE_MODE (unknown)\n"));
3652 case OID_802_11_REMOVE_WEP:
3653 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_WEP\n"));
3654 if (wrq->u.data.length != sizeof(NDIS_802_11_KEY_INDEX))
3660 KeyIdx = *(NDIS_802_11_KEY_INDEX *) wrq->u.data.pointer;
3662 if (KeyIdx & 0x80000000)
3664 // Should never set default bit when remove key
3669 KeyIdx = KeyIdx & 0x0fffffff;
3675 pAdapter->SharedKey[BSS0][KeyIdx].KeyLen = 0;
3676 pAdapter->SharedKey[BSS0][KeyIdx].CipherAlg = CIPHER_NONE;
3677 AsicRemoveSharedKeyEntry(pAdapter, 0, (UCHAR)KeyIdx);
3682 case RT_OID_802_11_RESET_COUNTERS:
3683 NdisZeroMemory(&pAdapter->WlanCounters, sizeof(COUNTER_802_11));
3684 NdisZeroMemory(&pAdapter->Counters8023, sizeof(COUNTER_802_3));
3685 NdisZeroMemory(&pAdapter->RalinkCounters, sizeof(COUNTER_RALINK));
3686 pAdapter->Counters8023.RxNoBuffer = 0;
3687 pAdapter->Counters8023.GoodReceives = 0;
3688 pAdapter->Counters8023.RxNoBuffer = 0;
3690 pAdapter->BulkOutComplete = 0;
3691 pAdapter->BulkOutCompleteOther= 0;
3692 pAdapter->BulkOutCompleteCancel = 0;
3693 pAdapter->BulkOutReq = 0;
3694 pAdapter->BulkInReq= 0;
3695 pAdapter->BulkInComplete = 0;
3696 pAdapter->BulkInCompleteFail = 0;
3698 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_RESET_COUNTERS \n"));
3700 case OID_802_11_RTS_THRESHOLD:
3701 if (wrq->u.data.length != sizeof(NDIS_802_11_RTS_THRESHOLD))
3705 Status = copy_from_user(&RtsThresh, wrq->u.data.pointer, wrq->u.data.length);
3706 if (RtsThresh > MAX_RTS_THRESHOLD)
3709 pAdapter->CommonCfg.RtsThreshold = (USHORT)RtsThresh;
3711 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_RTS_THRESHOLD (=%ld)\n",RtsThresh));
3713 case OID_802_11_FRAGMENTATION_THRESHOLD:
3714 if (wrq->u.data.length != sizeof(NDIS_802_11_FRAGMENTATION_THRESHOLD))
3718 Status = copy_from_user(&FragThresh, wrq->u.data.pointer, wrq->u.data.length);
3719 pAdapter->CommonCfg.bUseZeroToDisableFragment = FALSE;
3720 if (FragThresh > MAX_FRAG_THRESHOLD || FragThresh < MIN_FRAG_THRESHOLD)
3722 if (FragThresh == 0)
3724 pAdapter->CommonCfg.FragmentThreshold = MAX_FRAG_THRESHOLD;
3725 pAdapter->CommonCfg.bUseZeroToDisableFragment = TRUE;
3731 pAdapter->CommonCfg.FragmentThreshold = (USHORT)FragThresh;
3733 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_FRAGMENTATION_THRESHOLD (=%ld) \n",FragThresh));
3735 case OID_802_11_POWER_MODE:
3736 if (wrq->u.data.length != sizeof(NDIS_802_11_POWER_MODE))
3740 Status = copy_from_user(&PowerMode, wrq->u.data.pointer, wrq->u.data.length);
3741 if (PowerMode == Ndis802_11PowerModeCAM)
3742 Set_PSMode_Proc(pAdapter, "CAM");
3743 else if (PowerMode == Ndis802_11PowerModeMAX_PSP)
3744 Set_PSMode_Proc(pAdapter, "Max_PSP");
3745 else if (PowerMode == Ndis802_11PowerModeFast_PSP)
3746 Set_PSMode_Proc(pAdapter, "Fast_PSP");
3747 else if (PowerMode == Ndis802_11PowerModeLegacy_PSP)
3748 Set_PSMode_Proc(pAdapter, "Legacy_PSP");
3752 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_POWER_MODE (=%d)\n",PowerMode));
3754 case RT_OID_802_11_TX_POWER_LEVEL_1:
3755 if (wrq->u.data.length < sizeof(ULONG))
3759 Status = copy_from_user(&PowerTemp, wrq->u.data.pointer, wrq->u.data.length);
3760 if (PowerTemp > 100)
3761 PowerTemp = 0xffffffff; // AUTO
3762 pAdapter->CommonCfg.TxPowerDefault = PowerTemp; //keep current setting.
3763 pAdapter->CommonCfg.TxPowerPercentage = pAdapter->CommonCfg.TxPowerDefault;
3764 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_TX_POWER_LEVEL_1 (=%ld)\n", pAdapter->CommonCfg.TxPowerPercentage));
3767 case OID_802_11_NETWORK_TYPE_IN_USE:
3768 if (wrq->u.data.length != sizeof(NDIS_802_11_NETWORK_TYPE))
3772 Status = copy_from_user(&NetType, wrq->u.data.pointer, wrq->u.data.length);
3774 if (NetType == Ndis802_11DS)
3775 RTMPSetPhyMode(pAdapter, PHY_11B);
3776 else if (NetType == Ndis802_11OFDM24)
3777 RTMPSetPhyMode(pAdapter, PHY_11BG_MIXED);
3778 else if (NetType == Ndis802_11OFDM5)
3779 RTMPSetPhyMode(pAdapter, PHY_11A);
3782 #ifdef DOT11_N_SUPPORT
3783 if (Status == NDIS_STATUS_SUCCESS)
3784 SetCommonHT(pAdapter);
3785 #endif // DOT11_N_SUPPORT //
3786 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_NETWORK_TYPE_IN_USE (=%d)\n",NetType));
3789 // For WPA PSK PMK key
3790 case RT_OID_802_11_ADD_WPA:
3791 pKey = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
3798 Status = copy_from_user(pKey, wrq->u.data.pointer, wrq->u.data.length);
3799 if (pKey->Length != wrq->u.data.length)
3802 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_ADD_WPA, Failed!!\n"));
3806 if ((pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPAPSK) &&
3807 (pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPA2PSK) &&
3808 (pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPANone) )
3810 Status = -EOPNOTSUPP;
3811 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_ADD_WPA, Failed!! [AuthMode != WPAPSK/WPA2PSK/WPANONE]\n"));
3813 else if ((pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK) ||
3814 (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK) ||
3815 (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPANone) ) // Only for WPA PSK mode
3817 NdisMoveMemory(pAdapter->StaCfg.PMK, &pKey->KeyMaterial, pKey->KeyLength);
3818 // Use RaConfig as PSK agent.
3819 // Start STA supplicant state machine
3820 if (pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPANone)
3821 pAdapter->StaCfg.WpaState = SS_START;
3823 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_ADD_WPA (id=0x%x, Len=%d-byte)\n", pKey->KeyIndex, pKey->KeyLength));
3827 pAdapter->StaCfg.WpaState = SS_NOTUSE;
3828 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_ADD_WPA (id=0x%x, Len=%d-byte)\n", pKey->KeyIndex, pKey->KeyLength));
3833 case OID_802_11_REMOVE_KEY:
3834 pRemoveKey = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
3835 if(pRemoveKey == NULL)
3841 Status = copy_from_user(pRemoveKey, wrq->u.data.pointer, wrq->u.data.length);
3842 if (pRemoveKey->Length != wrq->u.data.length)
3845 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_KEY, Failed!!\n"));
3849 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
3851 RTMPWPARemoveKeyProc(pAdapter, pRemoveKey);
3852 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_KEY, Remove WPA Key!!\n"));
3856 KeyIdx = pRemoveKey->KeyIndex;
3858 if (KeyIdx & 0x80000000)
3860 // Should never set default bit when remove key
3862 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_KEY, Failed!!(Should never set default bit when remove key)\n"));
3866 KeyIdx = KeyIdx & 0x0fffffff;
3870 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_KEY, Failed!!(KeyId[%d] out of range)\n", KeyIdx));
3874 pAdapter->SharedKey[BSS0][KeyIdx].KeyLen = 0;
3875 pAdapter->SharedKey[BSS0][KeyIdx].CipherAlg = CIPHER_NONE;
3876 AsicRemoveSharedKeyEntry(pAdapter, 0, (UCHAR)KeyIdx);
3877 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_KEY (id=0x%x, Len=%d-byte)\n", pRemoveKey->KeyIndex, pRemoveKey->Length));
3885 case OID_802_11_ADD_KEY:
3886 pKey = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
3892 Status = copy_from_user(pKey, wrq->u.data.pointer, wrq->u.data.length);
3893 if (pKey->Length != wrq->u.data.length)
3896 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_KEY, Failed!!\n"));
3900 RTMPAddKey(pAdapter, pKey);
3901 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_KEY (id=0x%x, Len=%d-byte)\n", pKey->KeyIndex, pKey->KeyLength));
3905 case OID_802_11_CONFIGURATION:
3906 if (wrq->u.data.length != sizeof(NDIS_802_11_CONFIGURATION))
3910 Status = copy_from_user(&Config, wrq->u.data.pointer, wrq->u.data.length);
3913 if ((pConfig->BeaconPeriod >= 20) && (pConfig->BeaconPeriod <=400))
3914 pAdapter->CommonCfg.BeaconPeriod = (USHORT) pConfig->BeaconPeriod;
3916 pAdapter->StaActive.AtimWin = (USHORT) pConfig->ATIMWindow;
3917 MAP_KHZ_TO_CHANNEL_ID(pConfig->DSConfig, pAdapter->CommonCfg.Channel);
3919 // Save the channel on MlmeAux for CntlOidRTBssidProc used.
3921 pAdapter->MlmeAux.Channel = pAdapter->CommonCfg.Channel;
3923 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_CONFIGURATION (BeacnPeriod=%ld,AtimW=%ld,Ch=%d)\n",
3924 pConfig->BeaconPeriod, pConfig->ATIMWindow, pAdapter->CommonCfg.Channel));
3925 // Config has changed
3926 pAdapter->bConfigChanged = TRUE;
3929 #ifdef DOT11_N_SUPPORT
3930 case RT_OID_802_11_SET_HT_PHYMODE:
3931 if (wrq->u.data.length != sizeof(OID_SET_HT_PHYMODE))
3935 POID_SET_HT_PHYMODE pHTPhyMode = &HT_PhyMode;
3937 Status = copy_from_user(&HT_PhyMode, wrq->u.data.pointer, wrq->u.data.length);
3938 DBGPRINT(RT_DEBUG_TRACE, ("Set::pHTPhyMode (PhyMode = %d,TransmitNo = %d, HtMode = %d, ExtOffset = %d , MCS = %d, BW = %d, STBC = %d, SHORTGI = %d) \n",
3939 pHTPhyMode->PhyMode, pHTPhyMode->TransmitNo,pHTPhyMode->HtMode,pHTPhyMode->ExtOffset,
3940 pHTPhyMode->MCS, pHTPhyMode->BW, pHTPhyMode->STBC, pHTPhyMode->SHORTGI));
3941 if (pAdapter->CommonCfg.PhyMode >= PHY_11ABGN_MIXED)
3942 RTMPSetHT(pAdapter, pHTPhyMode);
3944 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_SET_HT_PHYMODE(MCS=%d,BW=%d,SGI=%d,STBC=%d)\n",
3945 pAdapter->StaCfg.HTPhyMode.field.MCS, pAdapter->StaCfg.HTPhyMode.field.BW, pAdapter->StaCfg.HTPhyMode.field.ShortGI,
3946 pAdapter->StaCfg.HTPhyMode.field.STBC));
3948 #endif // DOT11_N_SUPPORT //
3949 case RT_OID_802_11_SET_APSD_SETTING:
3950 if (wrq->u.data.length != sizeof(ULONG))
3955 Status = copy_from_user(&apsd, wrq->u.data.pointer, wrq->u.data.length);
3957 /*-------------------------------------------------------------------
3958 |B31~B7 | B6~B5 | B4 | B3 | B2 | B1 | B0 |
3959 ---------------------------------------------------------------------
3960 | Rsvd | Max SP Len | AC_VO | AC_VI | AC_BK | AC_BE | APSD Capable |
3961 ---------------------------------------------------------------------*/
3962 pAdapter->CommonCfg.bAPSDCapable = (apsd & 0x00000001) ? TRUE : FALSE;
3963 pAdapter->CommonCfg.bAPSDAC_BE = ((apsd & 0x00000002) >> 1) ? TRUE : FALSE;
3964 pAdapter->CommonCfg.bAPSDAC_BK = ((apsd & 0x00000004) >> 2) ? TRUE : FALSE;
3965 pAdapter->CommonCfg.bAPSDAC_VI = ((apsd & 0x00000008) >> 3) ? TRUE : FALSE;
3966 pAdapter->CommonCfg.bAPSDAC_VO = ((apsd & 0x00000010) >> 4) ? TRUE : FALSE;
3967 pAdapter->CommonCfg.MaxSPLength = (UCHAR)((apsd & 0x00000060) >> 5);
3969 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,
3970 pAdapter->CommonCfg.bAPSDAC_BE, pAdapter->CommonCfg.bAPSDAC_BK, pAdapter->CommonCfg.bAPSDAC_VI, pAdapter->CommonCfg.bAPSDAC_VO, pAdapter->CommonCfg.MaxSPLength));
3974 case RT_OID_802_11_SET_APSD_PSM:
3975 if (wrq->u.data.length != sizeof(ULONG))
3979 // Driver needs to notify AP when PSM changes
3980 Status = copy_from_user(&pAdapter->CommonCfg.bAPSDForcePowerSave, wrq->u.data.pointer, wrq->u.data.length);
3981 if (pAdapter->CommonCfg.bAPSDForcePowerSave != pAdapter->StaCfg.Psm)
3983 MlmeSetPsmBit(pAdapter, pAdapter->CommonCfg.bAPSDForcePowerSave);
3984 RTMPSendNullFrame(pAdapter, pAdapter->CommonCfg.TxRate, TRUE);
3986 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_SET_APSD_PSM (bAPSDForcePowerSave:%d)\n", pAdapter->CommonCfg.bAPSDForcePowerSave));
3989 #ifdef QOS_DLS_SUPPORT
3990 case RT_OID_802_11_SET_DLS:
3991 if (wrq->u.data.length != sizeof(ULONG))
3995 BOOLEAN oldvalue = pAdapter->CommonCfg.bDLSCapable;
3996 Status = copy_from_user(&pAdapter->CommonCfg.bDLSCapable, wrq->u.data.pointer, wrq->u.data.length);
3997 if (oldvalue && !pAdapter->CommonCfg.bDLSCapable)
4000 // tear down local dls table entry
4001 for (i=0; i<MAX_NUM_OF_INIT_DLS_ENTRY; i++)
4003 if (pAdapter->StaCfg.DLSEntry[i].Valid && (pAdapter->StaCfg.DLSEntry[i].Status == DLS_FINISH))
4005 pAdapter->StaCfg.DLSEntry[i].Status = DLS_NONE;
4006 pAdapter->StaCfg.DLSEntry[i].Valid = FALSE;
4007 RTMPSendDLSTearDownFrame(pAdapter, pAdapter->StaCfg.DLSEntry[i].MacAddr);
4011 // tear down peer dls table entry
4012 for (i=MAX_NUM_OF_INIT_DLS_ENTRY; i<MAX_NUM_OF_DLS_ENTRY; i++)
4014 if (pAdapter->StaCfg.DLSEntry[i].Valid && (pAdapter->StaCfg.DLSEntry[i].Status == DLS_FINISH))
4016 pAdapter->StaCfg.DLSEntry[i].Status = DLS_NONE;
4017 pAdapter->StaCfg.DLSEntry[i].Valid = FALSE;
4018 RTMPSendDLSTearDownFrame(pAdapter, pAdapter->StaCfg.DLSEntry[i].MacAddr);
4023 DBGPRINT(RT_DEBUG_TRACE,("Set::RT_OID_802_11_SET_DLS (=%d)\n", pAdapter->CommonCfg.bDLSCapable));
4027 case RT_OID_802_11_SET_DLS_PARAM:
4028 if (wrq->u.data.length != sizeof(RT_802_11_DLS_UI))
4034 NdisZeroMemory(&Dls, sizeof(RT_802_11_DLS));
4035 RTMPMoveMemory(&Dls, wrq->u.data.pointer, sizeof(RT_802_11_DLS_UI));
4036 MlmeEnqueue(pAdapter,
4037 MLME_CNTL_STATE_MACHINE,
4038 RT_OID_802_11_SET_DLS_PARAM,
4039 sizeof(RT_802_11_DLS),
4041 DBGPRINT(RT_DEBUG_TRACE,("Set::RT_OID_802_11_SET_DLS_PARAM \n"));
4044 #endif // QOS_DLS_SUPPORT //
4045 case RT_OID_802_11_SET_WMM:
4046 if (wrq->u.data.length != sizeof(BOOLEAN))
4050 Status = copy_from_user(&pAdapter->CommonCfg.bWmmCapable, wrq->u.data.pointer, wrq->u.data.length);
4051 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_SET_WMM (=%d) \n", pAdapter->CommonCfg.bWmmCapable));
4055 case OID_802_11_DISASSOCIATE:
4057 if (ATE_ON(pAdapter))
4059 DBGPRINT(RT_DEBUG_TRACE, ("The driver is in ATE mode now\n"));
4062 #endif // RALINK_ATE //
4064 // Set NdisRadioStateOff to TRUE, instead of called MlmeRadioOff.
4065 // Later on, NDIS_802_11_BSSID_LIST_EX->NumberOfItems should be 0
4066 // when query OID_802_11_BSSID_LIST.
4068 // TRUE: NumberOfItems will set to 0.
4069 // FALSE: NumberOfItems no change.
4071 pAdapter->CommonCfg.NdisRadioStateOff = TRUE;
4072 // Set to immediately send the media disconnect event
4073 pAdapter->MlmeAux.CurrReqIsFromNdis = TRUE;
4074 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_DISASSOCIATE \n"));
4076 if (INFRA_ON(pAdapter))
4078 if (pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE)
4080 RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
4081 DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
4084 MlmeEnqueue(pAdapter,
4085 MLME_CNTL_STATE_MACHINE,
4086 OID_802_11_DISASSOCIATE,
4090 StateMachineTouched = TRUE;
4094 #ifdef DOT11_N_SUPPORT
4095 case RT_OID_802_11_SET_IMME_BA_CAP:
4096 if (wrq->u.data.length != sizeof(OID_BACAP_STRUC))
4100 OID_BACAP_STRUC Orde ;
4101 Status = copy_from_user(&Orde, wrq->u.data.pointer, wrq->u.data.length);
4102 if (Orde.Policy > BA_NOTUSE)
4104 Status = NDIS_STATUS_INVALID_DATA;
4106 else if (Orde.Policy == BA_NOTUSE)
4108 pAdapter->CommonCfg.BACapability.field.Policy = BA_NOTUSE;
4109 pAdapter->CommonCfg.BACapability.field.MpduDensity = Orde.MpduDensity;
4110 pAdapter->CommonCfg.DesiredHtPhy.MpduDensity = Orde.MpduDensity;
4111 pAdapter->CommonCfg.DesiredHtPhy.AmsduEnable = Orde.AmsduEnable;
4112 pAdapter->CommonCfg.DesiredHtPhy.AmsduSize= Orde.AmsduSize;
4113 pAdapter->CommonCfg.DesiredHtPhy.MimoPs= Orde.MMPSmode;
4114 pAdapter->CommonCfg.BACapability.field.MMPSmode = Orde.MMPSmode;
4116 pAdapter->CommonCfg.HtCapability.HtCapInfo.MimoPs = Orde.MMPSmode;
4117 pAdapter->CommonCfg.HtCapability.HtCapInfo.AMsduSize = Orde.AmsduSize;
4118 pAdapter->CommonCfg.HtCapability.HtCapParm.MpduDensity = Orde.MpduDensity;
4122 pAdapter->CommonCfg.BACapability.field.AutoBA = Orde.AutoBA;
4123 pAdapter->CommonCfg.BACapability.field.Policy = IMMED_BA; // we only support immediate BA.
4124 pAdapter->CommonCfg.BACapability.field.MpduDensity = Orde.MpduDensity;
4125 pAdapter->CommonCfg.DesiredHtPhy.MpduDensity = Orde.MpduDensity;
4126 pAdapter->CommonCfg.DesiredHtPhy.AmsduEnable = Orde.AmsduEnable;
4127 pAdapter->CommonCfg.DesiredHtPhy.AmsduSize= Orde.AmsduSize;
4128 pAdapter->CommonCfg.DesiredHtPhy.MimoPs = Orde.MMPSmode;
4129 pAdapter->CommonCfg.BACapability.field.MMPSmode = Orde.MMPSmode;
4132 pAdapter->CommonCfg.HtCapability.HtCapInfo.MimoPs = Orde.MMPSmode;
4133 pAdapter->CommonCfg.HtCapability.HtCapInfo.AMsduSize = Orde.AmsduSize;
4134 pAdapter->CommonCfg.HtCapability.HtCapParm.MpduDensity = Orde.MpduDensity;
4136 if (pAdapter->CommonCfg.BACapability.field.RxBAWinLimit > MAX_RX_REORDERBUF)
4137 pAdapter->CommonCfg.BACapability.field.RxBAWinLimit = MAX_RX_REORDERBUF;
4141 pAdapter->CommonCfg.REGBACapability.word = pAdapter->CommonCfg.BACapability.word;
4142 DBGPRINT(RT_DEBUG_TRACE, ("Set::(Orde.AutoBA = %d) (Policy=%d)(ReBAWinLimit=%d)(TxBAWinLimit=%d)(AutoMode=%d)\n",Orde.AutoBA, pAdapter->CommonCfg.BACapability.field.Policy,
4143 pAdapter->CommonCfg.BACapability.field.RxBAWinLimit,pAdapter->CommonCfg.BACapability.field.TxBAWinLimit, pAdapter->CommonCfg.BACapability.field.AutoBA));
4144 DBGPRINT(RT_DEBUG_TRACE, ("Set::(MimoPs = %d)(AmsduEnable = %d) (AmsduSize=%d)(MpduDensity=%d)\n",pAdapter->CommonCfg.DesiredHtPhy.MimoPs, pAdapter->CommonCfg.DesiredHtPhy.AmsduEnable,
4145 pAdapter->CommonCfg.DesiredHtPhy.AmsduSize, pAdapter->CommonCfg.DesiredHtPhy.MpduDensity));
4149 case RT_OID_802_11_ADD_IMME_BA:
4150 DBGPRINT(RT_DEBUG_TRACE, (" Set :: RT_OID_802_11_ADD_IMME_BA \n"));
4151 if (wrq->u.data.length != sizeof(OID_ADD_BA_ENTRY))
4156 OID_ADD_BA_ENTRY BA;
4157 MAC_TABLE_ENTRY *pEntry;
4159 Status = copy_from_user(&BA, wrq->u.data.pointer, wrq->u.data.length);
4162 Status = NDIS_STATUS_INVALID_DATA;
4167 //BATableInsertEntry
4168 //As ad-hoc mode, BA pair is not limited to only BSSID. so add via OID.
4170 // in ad hoc mode, when adding BA pair, we should insert this entry into MACEntry too
4171 pEntry = MacTableLookup(pAdapter, BA.MACAddr);
4174 DBGPRINT(RT_DEBUG_TRACE, ("RT_OID_802_11_ADD_IMME_BA. break on no connection.----:%x:%x\n", BA.MACAddr[4], BA.MACAddr[5]));
4177 if (BA.IsRecipient == FALSE)
4179 if (pEntry->bIAmBadAtheros == TRUE)
4180 pAdapter->CommonCfg.BACapability.field.RxBAWinLimit = 0x10;
4182 BAOriSessionSetUp(pAdapter, pEntry, index, 0, 100, TRUE);
4186 //BATableInsertEntry(pAdapter, pEntry->Aid, BA.MACAddr, 0, 0xffff, BA.TID, BA.nMSDU, BA.IsRecipient);
4189 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_ADD_IMME_BA. Rec = %d. Mac = %x:%x:%x:%x:%x:%x . \n",
4190 BA.IsRecipient, BA.MACAddr[0], BA.MACAddr[1], BA.MACAddr[2], BA.MACAddr[2]
4191 , BA.MACAddr[4], BA.MACAddr[5]));
4196 case RT_OID_802_11_TEAR_IMME_BA:
4197 DBGPRINT(RT_DEBUG_TRACE, ("Set :: RT_OID_802_11_TEAR_IMME_BA \n"));
4198 if (wrq->u.data.length != sizeof(OID_ADD_BA_ENTRY))
4202 POID_ADD_BA_ENTRY pBA;
4203 MAC_TABLE_ENTRY *pEntry;
4205 pBA = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
4209 DBGPRINT(RT_DEBUG_TRACE, ("Set :: RT_OID_802_11_TEAR_IMME_BA kmalloc() can't allocate enough memory\n"));
4210 Status = NDIS_STATUS_FAILURE;
4214 Status = copy_from_user(pBA, wrq->u.data.pointer, wrq->u.data.length);
4215 DBGPRINT(RT_DEBUG_TRACE, ("Set :: RT_OID_802_11_TEAR_IMME_BA(TID=%d, bAllTid=%d)\n", pBA->TID, pBA->bAllTid));
4217 if (!pBA->bAllTid && (pBA->TID > NUM_OF_TID))
4219 Status = NDIS_STATUS_INVALID_DATA;
4223 if (pBA->IsRecipient == FALSE)
4225 pEntry = MacTableLookup(pAdapter, pBA->MACAddr);
4226 DBGPRINT(RT_DEBUG_TRACE, (" pBA->IsRecipient == FALSE\n"));
4229 DBGPRINT(RT_DEBUG_TRACE, (" pBA->pEntry\n"));
4230 BAOriSessionTearDown(pAdapter, pEntry->Aid, pBA->TID, FALSE, TRUE);
4233 DBGPRINT(RT_DEBUG_TRACE, ("Set :: Not found pEntry \n"));
4237 pEntry = MacTableLookup(pAdapter, pBA->MACAddr);
4240 BARecSessionTearDown( pAdapter, (UCHAR)pEntry->Aid, pBA->TID, TRUE);
4243 DBGPRINT(RT_DEBUG_TRACE, ("Set :: Not found pEntry \n"));
4249 #endif // DOT11_N_SUPPORT //
4251 // For WPA_SUPPLICANT to set static wep key
4252 case OID_802_11_ADD_WEP:
4253 pWepKey = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
4258 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_WEP, Failed!!\n"));
4261 Status = copy_from_user(pWepKey, wrq->u.data.pointer, wrq->u.data.length);
4265 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_WEP, Failed (length mismatch)!!\n"));
4269 KeyIdx = pWepKey->KeyIndex & 0x0fffffff;
4270 // KeyIdx must be 0 ~ 3
4274 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_WEP, Failed (KeyIdx must be smaller than 4)!!\n"));
4278 UCHAR CipherAlg = 0;
4281 // set key material and key length
4282 NdisZeroMemory(pAdapter->SharedKey[BSS0][KeyIdx].Key, 16);
4283 pAdapter->SharedKey[BSS0][KeyIdx].KeyLen = (UCHAR) pWepKey->KeyLength;
4284 NdisMoveMemory(pAdapter->SharedKey[BSS0][KeyIdx].Key, &pWepKey->KeyMaterial, pWepKey->KeyLength);
4286 switch(pWepKey->KeyLength)
4289 CipherAlg = CIPHER_WEP64;
4292 CipherAlg = CIPHER_WEP128;
4295 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_WEP, only support CIPHER_WEP64(len:5) & CIPHER_WEP128(len:13)!!\n"));
4299 pAdapter->SharedKey[BSS0][KeyIdx].CipherAlg = CipherAlg;
4301 // Default key for tx (shared key)
4302 if (pWepKey->KeyIndex & 0x80000000)
4304 #ifdef WPA_SUPPLICANT_SUPPORT
4305 // set key material and key length
4306 NdisZeroMemory(pAdapter->StaCfg.DesireSharedKey[KeyIdx].Key, 16);
4307 pAdapter->StaCfg.DesireSharedKey[KeyIdx].KeyLen = (UCHAR) pWepKey->KeyLength;
4308 NdisMoveMemory(pAdapter->StaCfg.DesireSharedKey[KeyIdx].Key, &pWepKey->KeyMaterial, pWepKey->KeyLength);
4309 pAdapter->StaCfg.DesireSharedKeyId = KeyIdx;
4310 pAdapter->StaCfg.DesireSharedKey[KeyIdx].CipherAlg = CipherAlg;
4311 #endif // WPA_SUPPLICANT_SUPPORT //
4312 pAdapter->StaCfg.DefaultKeyId = (UCHAR) KeyIdx;
4315 #ifdef WPA_SUPPLICANT_SUPPORT
4316 if ((pAdapter->StaCfg.WpaSupplicantUP != WPA_SUPPLICANT_DISABLE) &&
4317 (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA))
4319 Key = pWepKey->KeyMaterial;
4321 // Set Group key material to Asic
4322 AsicAddSharedKeyEntry(pAdapter, BSS0, KeyIdx, CipherAlg, Key, NULL, NULL);
4324 // Update WCID attribute table and IVEIV table for this group key table
4325 RTMPAddWcidAttributeEntry(pAdapter, BSS0, KeyIdx, CipherAlg, NULL);
4327 STA_PORT_SECURED(pAdapter);
4329 // Indicate Connected for GUI
4330 pAdapter->IndicateMediaState = NdisMediaStateConnected;
4332 else if (pAdapter->StaCfg.PortSecured == WPA_802_1X_PORT_SECURED)
4333 #endif // WPA_SUPPLICANT_SUPPORT
4335 Key = pAdapter->SharedKey[BSS0][KeyIdx].Key;
4337 // Set key material and cipherAlg to Asic
4338 AsicAddSharedKeyEntry(pAdapter, BSS0, KeyIdx, CipherAlg, Key, NULL, NULL);
4340 if (pWepKey->KeyIndex & 0x80000000)
4342 PMAC_TABLE_ENTRY pEntry = &pAdapter->MacTab.Content[BSSID_WCID];
4343 // Assign group key info
4344 RTMPAddWcidAttributeEntry(pAdapter, BSS0, KeyIdx, CipherAlg, NULL);
4345 // Assign pairwise key info
4346 RTMPAddWcidAttributeEntry(pAdapter, BSS0, KeyIdx, CipherAlg, pEntry);
4349 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"));
4354 #ifdef WPA_SUPPLICANT_SUPPORT
4355 case OID_SET_COUNTERMEASURES:
4356 if (wrq->u.data.length != sizeof(int))
4361 Status = copy_from_user(&enabled, wrq->u.data.pointer, wrq->u.data.length);
4363 pAdapter->StaCfg.bBlockAssoc = TRUE;
4365 // WPA MIC error should block association attempt for 60 seconds
4366 pAdapter->StaCfg.bBlockAssoc = FALSE;
4367 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_SET_COUNTERMEASURES bBlockAssoc=%s\n", pAdapter->StaCfg.bBlockAssoc ? "TRUE":"FALSE"));
4370 case RT_OID_WPA_SUPPLICANT_SUPPORT:
4371 if (wrq->u.data.length != sizeof(UCHAR))
4375 Status = copy_from_user(&wpa_supplicant_enable, wrq->u.data.pointer, wrq->u.data.length);
4376 pAdapter->StaCfg.WpaSupplicantUP = wpa_supplicant_enable;
4377 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_WPA_SUPPLICANT_SUPPORT (=%d)\n", pAdapter->StaCfg.WpaSupplicantUP));
4380 case OID_802_11_DEAUTHENTICATION:
4381 if (wrq->u.data.length != sizeof(MLME_DEAUTH_REQ_STRUCT))
4385 MLME_DEAUTH_REQ_STRUCT *pInfo;
4386 MLME_QUEUE_ELEM *MsgElem = (MLME_QUEUE_ELEM *) kmalloc(sizeof(MLME_QUEUE_ELEM), MEM_ALLOC_FLAG);
4388 pInfo = (MLME_DEAUTH_REQ_STRUCT *) MsgElem->Msg;
4389 Status = copy_from_user(pInfo, wrq->u.data.pointer, wrq->u.data.length);
4390 MlmeDeauthReqAction(pAdapter, MsgElem);
4393 if (INFRA_ON(pAdapter))
4395 LinkDown(pAdapter, FALSE);
4396 pAdapter->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
4398 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_DEAUTHENTICATION (Reason=%d)\n", pInfo->Reason));
4401 case OID_802_11_DROP_UNENCRYPTED:
4402 if (wrq->u.data.length != sizeof(int))
4407 Status = copy_from_user(&enabled, wrq->u.data.pointer, wrq->u.data.length);
4409 pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED;
4411 pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
4412 NdisAcquireSpinLock(&pAdapter->MacTabLock);
4413 pAdapter->MacTab.Content[BSSID_WCID].PortSecured = pAdapter->StaCfg.PortSecured;
4414 NdisReleaseSpinLock(&pAdapter->MacTabLock);
4415 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_DROP_UNENCRYPTED (=%d)\n", enabled));
4418 case OID_802_11_SET_IEEE8021X:
4419 if (wrq->u.data.length != sizeof(BOOLEAN))
4423 Status = copy_from_user(&IEEE8021xState, wrq->u.data.pointer, wrq->u.data.length);
4424 pAdapter->StaCfg.IEEE8021X = IEEE8021xState;
4425 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_SET_IEEE8021X (=%d)\n", IEEE8021xState));
4428 case OID_802_11_SET_IEEE8021X_REQUIRE_KEY:
4429 if (wrq->u.data.length != sizeof(BOOLEAN))
4433 Status = copy_from_user(&IEEE8021x_required_keys, wrq->u.data.pointer, wrq->u.data.length);
4434 pAdapter->StaCfg.IEEE8021x_required_keys = IEEE8021x_required_keys;
4435 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_SET_IEEE8021X_REQUIRE_KEY (%d)\n", IEEE8021x_required_keys));
4438 case OID_802_11_PMKID:
4439 pPmkId = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
4441 if(pPmkId == NULL) {
4445 Status = copy_from_user(pPmkId, wrq->u.data.pointer, wrq->u.data.length);
4447 // check the PMKID information
4448 if (pPmkId->BSSIDInfoCount == 0)
4449 NdisZeroMemory(pAdapter->StaCfg.SavedPMK, sizeof(BSSID_INFO)*PMKID_NO);
4452 PBSSID_INFO pBssIdInfo;
4456 for (BssIdx = 0; BssIdx < pPmkId->BSSIDInfoCount; BssIdx++)
4458 // point to the indexed BSSID_INFO structure
4459 pBssIdInfo = (PBSSID_INFO) ((PUCHAR) pPmkId + 2 * sizeof(UINT) + BssIdx * sizeof(BSSID_INFO));
4460 // Find the entry in the saved data base.
4461 for (CachedIdx = 0; CachedIdx < pAdapter->StaCfg.SavedPMKNum; CachedIdx++)
4463 // compare the BSSID
4464 if (NdisEqualMemory(pBssIdInfo->BSSID, pAdapter->StaCfg.SavedPMK[CachedIdx].BSSID, sizeof(NDIS_802_11_MAC_ADDRESS)))
4468 // Found, replace it
4469 if (CachedIdx < PMKID_NO)
4471 DBGPRINT(RT_DEBUG_OFF, ("Update OID_802_11_PMKID, idx = %d\n", CachedIdx));
4472 NdisMoveMemory(&pAdapter->StaCfg.SavedPMK[CachedIdx], pBssIdInfo, sizeof(BSSID_INFO));
4473 pAdapter->StaCfg.SavedPMKNum++;
4475 // Not found, replace the last one
4478 // Randomly replace one
4479 CachedIdx = (pBssIdInfo->BSSID[5] % PMKID_NO);
4480 DBGPRINT(RT_DEBUG_OFF, ("Update OID_802_11_PMKID, idx = %d\n", CachedIdx));
4481 NdisMoveMemory(&pAdapter->StaCfg.SavedPMK[CachedIdx], pBssIdInfo, sizeof(BSSID_INFO));
4488 #endif // WPA_SUPPLICANT_SUPPORT //
4493 case OID_802_11_SHORTRETRYLIMIT:
4494 if (wrq->u.data.length != sizeof(ULONG))
4498 Status = copy_from_user(&ShortRetryLimit, wrq->u.data.pointer, wrq->u.data.length);
4499 RTMP_IO_READ32(pAdapter, TX_RTY_CFG, &tx_rty_cfg.word);
4500 tx_rty_cfg.field.ShortRtyLimit = ShortRetryLimit;
4501 RTMP_IO_WRITE32(pAdapter, TX_RTY_CFG, tx_rty_cfg.word);
4502 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_SHORTRETRYLIMIT (tx_rty_cfg.field.ShortRetryLimit=%d, ShortRetryLimit=%ld)\n", tx_rty_cfg.field.ShortRtyLimit, ShortRetryLimit));
4506 case OID_802_11_LONGRETRYLIMIT:
4507 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_LONGRETRYLIMIT \n"));
4508 if (wrq->u.data.length != sizeof(ULONG))
4512 Status = copy_from_user(&LongRetryLimit, wrq->u.data.pointer, wrq->u.data.length);
4513 RTMP_IO_READ32(pAdapter, TX_RTY_CFG, &tx_rty_cfg.word);
4514 tx_rty_cfg.field.LongRtyLimit = LongRetryLimit;
4515 RTMP_IO_WRITE32(pAdapter, TX_RTY_CFG, tx_rty_cfg.word);
4516 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_LONGRETRYLIMIT (tx_rty_cfg.field.LongRetryLimit= %d,LongRetryLimit=%ld)\n", tx_rty_cfg.field.LongRtyLimit, LongRetryLimit));
4520 case OID_802_11_WEPDEFAULTKEYVALUE:
4521 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_WEPDEFAULTKEYVALUE\n"));
4522 pKey = kmalloc(wrq->u.data.length, GFP_KERNEL);
4523 Status = copy_from_user(pKey, wrq->u.data.pointer, wrq->u.data.length);
4526 if ( pKey->Length != wrq->u.data.length)
4529 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_WEPDEFAULTKEYVALUE, Failed!!\n"));
4531 KeyIdx = pKey->KeyIndex & 0x0fffffff;
4532 DBGPRINT(RT_DEBUG_TRACE,("pKey->KeyIndex =%d, pKey->KeyLength=%d\n", pKey->KeyIndex, pKey->KeyLength));
4534 // it is a shared key
4539 pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].KeyLen = (UCHAR) pKey->KeyLength;
4540 NdisMoveMemory(&pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].Key, &pKey->KeyMaterial, pKey->KeyLength);
4541 if (pKey->KeyIndex & 0x80000000)
4543 // Default key for tx (shared key)
4544 pAdapter->StaCfg.DefaultKeyId = (UCHAR) KeyIdx;
4546 //RestartAPIsRequired = TRUE;
4551 case OID_802_11_WEPDEFAULTKEYID:
4552 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_WEPDEFAULTKEYID \n"));
4554 if (wrq->u.data.length != sizeof(UCHAR))
4557 Status = copy_from_user(&pAdapter->StaCfg.DefaultKeyId, wrq->u.data.pointer, wrq->u.data.length);
4562 case OID_802_11_CURRENTCHANNEL:
4563 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_CURRENTCHANNEL \n"));
4564 if (wrq->u.data.length != sizeof(UCHAR))
4568 Status = copy_from_user(&ctmp, wrq->u.data.pointer, wrq->u.data.length);
4569 sprintf(&ctmp,"%d", ctmp);
4570 Set_Channel_Proc(pAdapter, &ctmp);
4578 DBGPRINT(RT_DEBUG_TRACE, ("Set::unknown IOCTL's subcmd = 0x%08x\n", cmd));
4579 Status = -EOPNOTSUPP;
4587 INT RTMPQueryInformation(
4588 IN PRTMP_ADAPTER pAdapter,
4589 IN OUT struct ifreq *rq,
4592 struct iwreq *wrq = (struct iwreq *) rq;
4593 NDIS_802_11_BSSID_LIST_EX *pBssidList = NULL;
4594 PNDIS_WLAN_BSSID_EX pBss;
4595 NDIS_802_11_SSID Ssid;
4596 NDIS_802_11_CONFIGURATION *pConfiguration = NULL;
4597 RT_802_11_LINK_STATUS *pLinkStatus = NULL;
4598 RT_802_11_STA_CONFIG *pStaConfig = NULL;
4599 NDIS_802_11_STATISTICS *pStatistics = NULL;
4600 NDIS_802_11_RTS_THRESHOLD RtsThresh;
4601 NDIS_802_11_FRAGMENTATION_THRESHOLD FragThresh;
4602 NDIS_802_11_POWER_MODE PowerMode;
4603 NDIS_802_11_NETWORK_INFRASTRUCTURE BssType;
4604 RT_802_11_PREAMBLE PreamType;
4605 NDIS_802_11_AUTHENTICATION_MODE AuthMode;
4606 NDIS_802_11_WEP_STATUS WepStatus;
4607 NDIS_MEDIA_STATE MediaState;
4608 ULONG BssBufSize, ulInfo=0, NetworkTypeList[4], apsd = 0;
4610 PUCHAR pBuf = NULL, pPtr;
4611 INT Status = NDIS_STATUS_SUCCESS;
4612 UINT we_version_compiled;
4613 UCHAR i, Padding = 0;
4615 UCHAR driverVersion[8];
4616 OID_SET_HT_PHYMODE *pHTPhyMode = NULL;
4621 DefaultKeyIdxValue *pKeyIdxValue;
4623 TX_RTY_CFG_STRUC tx_rty_cfg;
4624 ULONG ShortRetryLimit, LongRetryLimit;
4630 case RT_OID_DEVICE_NAME:
4631 wrq->u.data.length = sizeof(STA_NIC_DEVICE_NAME);
4632 Status = copy_to_user(wrq->u.data.pointer, STA_NIC_DEVICE_NAME, wrq->u.data.length);
4634 case RT_OID_VERSION_INFO:
4635 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_VERSION_INFO \n"));
4636 wrq->u.data.length = 8*sizeof(UCHAR);
4637 sprintf(&driverVersion[0], "%s", STA_DRIVER_VERSION);
4638 driverVersion[7] = '\0';
4639 if (copy_to_user(wrq->u.data.pointer, &driverVersion, wrq->u.data.length))
4645 case RT_QUERY_ATE_TXDONE_COUNT:
4646 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_QUERY_ATE_TXDONE_COUNT \n"));
4647 wrq->u.data.length = sizeof(UINT32);
4648 if (copy_to_user(wrq->u.data.pointer, &pAdapter->ate.TxDoneCount, wrq->u.data.length))
4653 #endif // RALINK_ATE //
4654 case OID_802_11_BSSID_LIST:
4655 if (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
4658 * Still scanning, indicate the caller should try again.
4660 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_BSSID_LIST (Still scanning)\n"));
4663 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_BSSID_LIST (%d BSS returned)\n",pAdapter->ScanTab.BssNr));
4664 pAdapter->StaCfg.bScanReqIsFromWebUI = FALSE;
4665 // Claculate total buffer size required
4666 BssBufSize = sizeof(ULONG);
4668 for (i = 0; i < pAdapter->ScanTab.BssNr; i++)
4670 // Align pointer to 4 bytes boundary.
4671 //Padding = 4 - (pAdapter->ScanTab.BssEntry[i].VarIELen & 0x0003);
4674 BssBufSize += (sizeof(NDIS_WLAN_BSSID_EX) - 1 + sizeof(NDIS_802_11_FIXED_IEs) + pAdapter->ScanTab.BssEntry[i].VarIELen + Padding);
4677 // For safety issue, we add 256 bytes just in case
4679 // Allocate the same size as passed from higher layer
4680 pBuf = kmalloc(BssBufSize, MEM_ALLOC_FLAG);
4686 // Init 802_11_BSSID_LIST_EX structure
4687 NdisZeroMemory(pBuf, BssBufSize);
4688 pBssidList = (PNDIS_802_11_BSSID_LIST_EX) pBuf;
4689 pBssidList->NumberOfItems = pAdapter->ScanTab.BssNr;
4691 // Calculate total buffer length
4692 BssLen = 4; // Consist of NumberOfItems
4693 // Point to start of NDIS_WLAN_BSSID_EX
4694 // pPtr = pBuf + sizeof(ULONG);
4695 pPtr = (PUCHAR) &pBssidList->Bssid[0];
4696 for (i = 0; i < pAdapter->ScanTab.BssNr; i++)
4698 pBss = (PNDIS_WLAN_BSSID_EX) pPtr;
4699 NdisMoveMemory(&pBss->MacAddress, &pAdapter->ScanTab.BssEntry[i].Bssid, MAC_ADDR_LEN);
4700 if ((pAdapter->ScanTab.BssEntry[i].Hidden == 1) && (pAdapter->StaCfg.bShowHiddenSSID == FALSE))
4703 // We must return this SSID during 4way handshaking, otherwise Aegis will failed to parse WPA infomation
4704 // and then failed to send EAPOl farame.
4706 if ((pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA) && (pAdapter->StaCfg.PortSecured != WPA_802_1X_PORT_SECURED))
4708 pBss->Ssid.SsidLength = pAdapter->ScanTab.BssEntry[i].SsidLen;
4709 NdisMoveMemory(pBss->Ssid.Ssid, pAdapter->ScanTab.BssEntry[i].Ssid, pAdapter->ScanTab.BssEntry[i].SsidLen);
4712 pBss->Ssid.SsidLength = 0;
4716 pBss->Ssid.SsidLength = pAdapter->ScanTab.BssEntry[i].SsidLen;
4717 NdisMoveMemory(pBss->Ssid.Ssid, pAdapter->ScanTab.BssEntry[i].Ssid, pAdapter->ScanTab.BssEntry[i].SsidLen);
4719 pBss->Privacy = pAdapter->ScanTab.BssEntry[i].Privacy;
4720 pBss->Rssi = pAdapter->ScanTab.BssEntry[i].Rssi - pAdapter->BbpRssiToDbmDelta;
4721 pBss->NetworkTypeInUse = NetworkTypeInUseSanity(&pAdapter->ScanTab.BssEntry[i]);
4722 pBss->Configuration.Length = sizeof(NDIS_802_11_CONFIGURATION);
4723 pBss->Configuration.BeaconPeriod = pAdapter->ScanTab.BssEntry[i].BeaconPeriod;
4724 pBss->Configuration.ATIMWindow = pAdapter->ScanTab.BssEntry[i].AtimWin;
4726 MAP_CHANNEL_ID_TO_KHZ(pAdapter->ScanTab.BssEntry[i].Channel, pBss->Configuration.DSConfig);
4728 if (pAdapter->ScanTab.BssEntry[i].BssType == BSS_INFRA)
4729 pBss->InfrastructureMode = Ndis802_11Infrastructure;
4731 pBss->InfrastructureMode = Ndis802_11IBSS;
4733 NdisMoveMemory(pBss->SupportedRates, pAdapter->ScanTab.BssEntry[i].SupRate, pAdapter->ScanTab.BssEntry[i].SupRateLen);
4734 NdisMoveMemory(pBss->SupportedRates + pAdapter->ScanTab.BssEntry[i].SupRateLen,
4735 pAdapter->ScanTab.BssEntry[i].ExtRate,
4736 pAdapter->ScanTab.BssEntry[i].ExtRateLen);
4738 if (pAdapter->ScanTab.BssEntry[i].VarIELen == 0)
4740 pBss->IELength = sizeof(NDIS_802_11_FIXED_IEs);
4741 NdisMoveMemory(pBss->IEs, &pAdapter->ScanTab.BssEntry[i].FixIEs, sizeof(NDIS_802_11_FIXED_IEs));
4742 pPtr = pPtr + sizeof(NDIS_WLAN_BSSID_EX) - 1 + sizeof(NDIS_802_11_FIXED_IEs);
4746 pBss->IELength = (ULONG)(sizeof(NDIS_802_11_FIXED_IEs) + pAdapter->ScanTab.BssEntry[i].VarIELen);
4747 pPtr = pPtr + sizeof(NDIS_WLAN_BSSID_EX) - 1 + sizeof(NDIS_802_11_FIXED_IEs);
4748 NdisMoveMemory(pBss->IEs, &pAdapter->ScanTab.BssEntry[i].FixIEs, sizeof(NDIS_802_11_FIXED_IEs));
4749 NdisMoveMemory(pBss->IEs + sizeof(NDIS_802_11_FIXED_IEs), pAdapter->ScanTab.BssEntry[i].VarIEs, pAdapter->ScanTab.BssEntry[i].VarIELen);
4750 pPtr += pAdapter->ScanTab.BssEntry[i].VarIELen;
4752 pBss->Length = (ULONG)(sizeof(NDIS_WLAN_BSSID_EX) - 1 + sizeof(NDIS_802_11_FIXED_IEs) + pAdapter->ScanTab.BssEntry[i].VarIELen + Padding);
4754 #if WIRELESS_EXT < 17
4755 if ((BssLen + pBss->Length) < wrq->u.data.length)
4756 BssLen += pBss->Length;
4759 pBssidList->NumberOfItems = i;
4763 BssLen += pBss->Length;
4767 #if WIRELESS_EXT < 17
4768 wrq->u.data.length = BssLen;
4770 if (BssLen > wrq->u.data.length)
4776 wrq->u.data.length = BssLen;
4778 Status = copy_to_user(wrq->u.data.pointer, pBssidList, BssLen);
4781 case OID_802_3_CURRENT_ADDRESS:
4782 wrq->u.data.length = MAC_ADDR_LEN;
4783 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CurrentAddress, wrq->u.data.length);
4785 case OID_GEN_MEDIA_CONNECT_STATUS:
4786 if (pAdapter->IndicateMediaState == NdisMediaStateConnected)
4787 MediaState = NdisMediaStateConnected;
4789 MediaState = NdisMediaStateDisconnected;
4791 wrq->u.data.length = sizeof(NDIS_MEDIA_STATE);
4792 Status = copy_to_user(wrq->u.data.pointer, &MediaState, wrq->u.data.length);
4794 case OID_802_11_BSSID:
4796 if (ATE_ON(pAdapter))
4798 DBGPRINT(RT_DEBUG_TRACE, ("The driver is in ATE mode now\n"));
4799 Status = NDIS_STATUS_RESOURCES;
4802 #endif // RALINK_ATE //
4803 if (INFRA_ON(pAdapter) || ADHOC_ON(pAdapter))
4805 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.Bssid, sizeof(NDIS_802_11_MAC_ADDRESS));
4810 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_BSSID(=EMPTY)\n"));
4814 case OID_802_11_SSID:
4815 NdisZeroMemory(&Ssid, sizeof(NDIS_802_11_SSID));
4816 NdisZeroMemory(Ssid.Ssid, MAX_LEN_OF_SSID);
4817 Ssid.SsidLength = pAdapter->CommonCfg.SsidLen;
4818 memcpy(Ssid.Ssid, pAdapter->CommonCfg.Ssid, Ssid.SsidLength);
4819 wrq->u.data.length = sizeof(NDIS_802_11_SSID);
4820 Status = copy_to_user(wrq->u.data.pointer, &Ssid, wrq->u.data.length);
4821 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_SSID (Len=%d, ssid=%s)\n", Ssid.SsidLength,Ssid.Ssid));
4823 case RT_OID_802_11_QUERY_LINK_STATUS:
4824 pLinkStatus = (RT_802_11_LINK_STATUS *) kmalloc(sizeof(RT_802_11_LINK_STATUS), MEM_ALLOC_FLAG);
4827 pLinkStatus->CurrTxRate = RateIdTo500Kbps[pAdapter->CommonCfg.TxRate]; // unit : 500 kbps
4828 pLinkStatus->ChannelQuality = pAdapter->Mlme.ChannelQuality;
4829 pLinkStatus->RxByteCount = pAdapter->RalinkCounters.ReceivedByteCount;
4830 pLinkStatus->TxByteCount = pAdapter->RalinkCounters.TransmittedByteCount;
4831 pLinkStatus->CentralChannel = pAdapter->CommonCfg.CentralChannel;
4832 wrq->u.data.length = sizeof(RT_802_11_LINK_STATUS);
4833 Status = copy_to_user(wrq->u.data.pointer, pLinkStatus, wrq->u.data.length);
4835 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_LINK_STATUS\n"));
4839 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_LINK_STATUS(kmalloc failed)\n"));
4843 case OID_802_11_CONFIGURATION:
4844 pConfiguration = (NDIS_802_11_CONFIGURATION *) kmalloc(sizeof(NDIS_802_11_CONFIGURATION), MEM_ALLOC_FLAG);
4847 pConfiguration->Length = sizeof(NDIS_802_11_CONFIGURATION);
4848 pConfiguration->BeaconPeriod = pAdapter->CommonCfg.BeaconPeriod;
4849 pConfiguration->ATIMWindow = pAdapter->StaActive.AtimWin;
4850 MAP_CHANNEL_ID_TO_KHZ(pAdapter->CommonCfg.Channel, pConfiguration->DSConfig);
4851 wrq->u.data.length = sizeof(NDIS_802_11_CONFIGURATION);
4852 Status = copy_to_user(wrq->u.data.pointer, pConfiguration, wrq->u.data.length);
4853 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_CONFIGURATION(BeaconPeriod=%ld,AtimW=%ld,Channel=%d) \n",
4854 pConfiguration->BeaconPeriod, pConfiguration->ATIMWindow, pAdapter->CommonCfg.Channel));
4855 kfree(pConfiguration);
4859 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_CONFIGURATION(kmalloc failed)\n"));
4863 case RT_OID_802_11_SNR_0:
4864 if ((pAdapter->StaCfg.LastSNR0 > 0))
4866 ulInfo = ((0xeb - pAdapter->StaCfg.LastSNR0) * 3) / 16 ;
4867 wrq->u.data.length = sizeof(ulInfo);
4868 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4869 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_SNR_0(0x=%lx)\n", ulInfo));
4874 case RT_OID_802_11_SNR_1:
4875 if ((pAdapter->Antenna.field.RxPath > 1) &&
4876 (pAdapter->StaCfg.LastSNR1 > 0))
4878 ulInfo = ((0xeb - pAdapter->StaCfg.LastSNR1) * 3) / 16 ;
4879 wrq->u.data.length = sizeof(ulInfo);
4880 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4881 DBGPRINT(RT_DEBUG_TRACE,("Query::RT_OID_802_11_SNR_1(0x=%lx)\n",ulInfo));
4885 DBGPRINT(RT_DEBUG_TRACE,("Query::RT_OID_802_11_SNR_1(pAdapter->StaCfg.LastSNR1=%d)\n",pAdapter->StaCfg.LastSNR1));
4887 case OID_802_11_RSSI_TRIGGER:
4888 ulInfo = pAdapter->StaCfg.RssiSample.LastRssi0 - pAdapter->BbpRssiToDbmDelta;
4889 wrq->u.data.length = sizeof(ulInfo);
4890 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4891 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_RSSI_TRIGGER(=%ld)\n", ulInfo));
4893 case OID_802_11_RSSI:
4894 case RT_OID_802_11_RSSI:
4895 ulInfo = pAdapter->StaCfg.RssiSample.LastRssi0;
4896 wrq->u.data.length = sizeof(ulInfo);
4897 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4899 case RT_OID_802_11_RSSI_1:
4900 ulInfo = pAdapter->StaCfg.RssiSample.LastRssi1;
4901 wrq->u.data.length = sizeof(ulInfo);
4902 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4904 case RT_OID_802_11_RSSI_2:
4905 ulInfo = pAdapter->StaCfg.RssiSample.LastRssi2;
4906 wrq->u.data.length = sizeof(ulInfo);
4907 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4909 case OID_802_11_STATISTICS:
4910 pStatistics = (NDIS_802_11_STATISTICS *) kmalloc(sizeof(NDIS_802_11_STATISTICS), MEM_ALLOC_FLAG);
4913 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_STATISTICS \n"));
4914 // add the most up-to-date h/w raw counters into software counters
4915 NICUpdateRawCounters(pAdapter);
4917 // Sanity check for calculation of sucessful count
4918 if (pAdapter->WlanCounters.TransmittedFragmentCount.QuadPart < pAdapter->WlanCounters.RetryCount.QuadPart)
4919 pAdapter->WlanCounters.TransmittedFragmentCount.QuadPart = pAdapter->WlanCounters.RetryCount.QuadPart;
4921 pStatistics->TransmittedFragmentCount.QuadPart = pAdapter->WlanCounters.TransmittedFragmentCount.QuadPart;
4922 pStatistics->MulticastTransmittedFrameCount.QuadPart = pAdapter->WlanCounters.MulticastTransmittedFrameCount.QuadPart;
4923 pStatistics->FailedCount.QuadPart = pAdapter->WlanCounters.FailedCount.QuadPart;
4924 pStatistics->RetryCount.QuadPart = pAdapter->WlanCounters.RetryCount.QuadPart;
4925 pStatistics->MultipleRetryCount.QuadPart = pAdapter->WlanCounters.MultipleRetryCount.QuadPart;
4926 pStatistics->RTSSuccessCount.QuadPart = pAdapter->WlanCounters.RTSSuccessCount.QuadPart;
4927 pStatistics->RTSFailureCount.QuadPart = pAdapter->WlanCounters.RTSFailureCount.QuadPart;
4928 pStatistics->ACKFailureCount.QuadPart = pAdapter->WlanCounters.ACKFailureCount.QuadPart;
4929 pStatistics->FrameDuplicateCount.QuadPart = pAdapter->WlanCounters.FrameDuplicateCount.QuadPart;
4930 pStatistics->ReceivedFragmentCount.QuadPart = pAdapter->WlanCounters.ReceivedFragmentCount.QuadPart;
4931 pStatistics->MulticastReceivedFrameCount.QuadPart = pAdapter->WlanCounters.MulticastReceivedFrameCount.QuadPart;
4933 pStatistics->FCSErrorCount = pAdapter->RalinkCounters.RealFcsErrCount;
4935 pStatistics->FCSErrorCount.QuadPart = pAdapter->WlanCounters.FCSErrorCount.QuadPart;
4936 pStatistics->FrameDuplicateCount.u.LowPart = pAdapter->WlanCounters.FrameDuplicateCount.u.LowPart / 100;
4938 wrq->u.data.length = sizeof(NDIS_802_11_STATISTICS);
4939 Status = copy_to_user(wrq->u.data.pointer, pStatistics, wrq->u.data.length);
4944 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_STATISTICS(kmalloc failed)\n"));
4948 case OID_GEN_RCV_OK:
4949 ulInfo = pAdapter->Counters8023.GoodReceives;
4950 wrq->u.data.length = sizeof(ulInfo);
4951 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4953 case OID_GEN_RCV_NO_BUFFER:
4954 ulInfo = pAdapter->Counters8023.RxNoBuffer;
4955 wrq->u.data.length = sizeof(ulInfo);
4956 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4958 case RT_OID_802_11_PHY_MODE:
4959 ulInfo = (ULONG)pAdapter->CommonCfg.PhyMode;
4960 wrq->u.data.length = sizeof(ulInfo);
4961 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4962 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_PHY_MODE (=%ld)\n", ulInfo));
4964 case RT_OID_802_11_STA_CONFIG:
4965 pStaConfig = (RT_802_11_STA_CONFIG *) kmalloc(sizeof(RT_802_11_STA_CONFIG), MEM_ALLOC_FLAG);
4968 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_STA_CONFIG\n"));
4969 pStaConfig->EnableTxBurst = pAdapter->CommonCfg.bEnableTxBurst;
4970 pStaConfig->EnableTurboRate = 0;
4971 pStaConfig->UseBGProtection = pAdapter->CommonCfg.UseBGProtection;
4972 pStaConfig->UseShortSlotTime = pAdapter->CommonCfg.bUseShortSlotTime;
4973 //pStaConfig->AdhocMode = pAdapter->StaCfg.AdhocMode;
4974 pStaConfig->HwRadioStatus = (pAdapter->StaCfg.bHwRadio == TRUE) ? 1 : 0;
4975 pStaConfig->Rsv1 = 0;
4976 pStaConfig->SystemErrorBitmap = pAdapter->SystemErrorBitmap;
4977 wrq->u.data.length = sizeof(RT_802_11_STA_CONFIG);
4978 Status = copy_to_user(wrq->u.data.pointer, pStaConfig, wrq->u.data.length);
4983 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_STA_CONFIG(kmalloc failed)\n"));
4987 case OID_802_11_RTS_THRESHOLD:
4988 RtsThresh = pAdapter->CommonCfg.RtsThreshold;
4989 wrq->u.data.length = sizeof(RtsThresh);
4990 Status = copy_to_user(wrq->u.data.pointer, &RtsThresh, wrq->u.data.length);
4991 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_RTS_THRESHOLD(=%ld)\n", RtsThresh));
4993 case OID_802_11_FRAGMENTATION_THRESHOLD:
4994 FragThresh = pAdapter->CommonCfg.FragmentThreshold;
4995 if (pAdapter->CommonCfg.bUseZeroToDisableFragment == TRUE)
4997 wrq->u.data.length = sizeof(FragThresh);
4998 Status = copy_to_user(wrq->u.data.pointer, &FragThresh, wrq->u.data.length);
4999 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_FRAGMENTATION_THRESHOLD(=%ld)\n", FragThresh));
5001 case OID_802_11_POWER_MODE:
5002 PowerMode = pAdapter->StaCfg.WindowsPowerMode;
5003 wrq->u.data.length = sizeof(PowerMode);
5004 Status = copy_to_user(wrq->u.data.pointer, &PowerMode, wrq->u.data.length);
5005 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_POWER_MODE(=%d)\n", PowerMode));
5007 case RT_OID_802_11_RADIO:
5008 RadioState = (BOOLEAN) pAdapter->StaCfg.bSwRadio;
5009 wrq->u.data.length = sizeof(RadioState);
5010 Status = copy_to_user(wrq->u.data.pointer, &RadioState, wrq->u.data.length);
5011 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_RADIO (=%d)\n", RadioState));
5013 case OID_802_11_INFRASTRUCTURE_MODE:
5014 if (pAdapter->StaCfg.BssType == BSS_ADHOC)
5015 BssType = Ndis802_11IBSS;
5016 else if (pAdapter->StaCfg.BssType == BSS_INFRA)
5017 BssType = Ndis802_11Infrastructure;
5018 else if (pAdapter->StaCfg.BssType == BSS_MONITOR)
5019 BssType = Ndis802_11Monitor;
5021 BssType = Ndis802_11AutoUnknown;
5023 wrq->u.data.length = sizeof(BssType);
5024 Status = copy_to_user(wrq->u.data.pointer, &BssType, wrq->u.data.length);
5025 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_INFRASTRUCTURE_MODE(=%d)\n", BssType));
5027 case RT_OID_802_11_PREAMBLE:
5028 PreamType = pAdapter->CommonCfg.TxPreamble;
5029 wrq->u.data.length = sizeof(PreamType);
5030 Status = copy_to_user(wrq->u.data.pointer, &PreamType, wrq->u.data.length);
5031 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_PREAMBLE(=%d)\n", PreamType));
5033 case OID_802_11_AUTHENTICATION_MODE:
5034 AuthMode = pAdapter->StaCfg.AuthMode;
5035 wrq->u.data.length = sizeof(AuthMode);
5036 Status = copy_to_user(wrq->u.data.pointer, &AuthMode, wrq->u.data.length);
5037 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_AUTHENTICATION_MODE(=%d)\n", AuthMode));
5039 case OID_802_11_WEP_STATUS:
5040 WepStatus = pAdapter->StaCfg.WepStatus;
5041 wrq->u.data.length = sizeof(WepStatus);
5042 Status = copy_to_user(wrq->u.data.pointer, &WepStatus, wrq->u.data.length);
5043 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_WEP_STATUS(=%d)\n", WepStatus));
5045 case OID_802_11_TX_POWER_LEVEL:
5046 wrq->u.data.length = sizeof(ULONG);
5047 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.TxPower, wrq->u.data.length);
5048 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_TX_POWER_LEVEL %x\n",pAdapter->CommonCfg.TxPower));
5050 case RT_OID_802_11_TX_POWER_LEVEL_1:
5051 wrq->u.data.length = sizeof(ULONG);
5052 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.TxPowerPercentage, wrq->u.data.length);
5053 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_TX_POWER_LEVEL_1 (=%ld)\n", pAdapter->CommonCfg.TxPowerPercentage));
5055 case OID_802_11_NETWORK_TYPES_SUPPORTED:
5056 if ((pAdapter->RfIcType == RFIC_2850) || (pAdapter->RfIcType == RFIC_2750))
5058 NetworkTypeList[0] = 3; // NumberOfItems = 3
5059 NetworkTypeList[1] = Ndis802_11DS; // NetworkType[1] = 11b
5060 NetworkTypeList[2] = Ndis802_11OFDM24; // NetworkType[2] = 11g
5061 NetworkTypeList[3] = Ndis802_11OFDM5; // NetworkType[3] = 11a
5062 wrq->u.data.length = 16;
5063 Status = copy_to_user(wrq->u.data.pointer, &NetworkTypeList[0], wrq->u.data.length);
5067 NetworkTypeList[0] = 2; // NumberOfItems = 2
5068 NetworkTypeList[1] = Ndis802_11DS; // NetworkType[1] = 11b
5069 NetworkTypeList[2] = Ndis802_11OFDM24; // NetworkType[2] = 11g
5070 wrq->u.data.length = 12;
5071 Status = copy_to_user(wrq->u.data.pointer, &NetworkTypeList[0], wrq->u.data.length);
5073 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_NETWORK_TYPES_SUPPORTED\n"));
5075 case OID_802_11_NETWORK_TYPE_IN_USE:
5076 wrq->u.data.length = sizeof(ULONG);
5077 if (pAdapter->CommonCfg.PhyMode == PHY_11A)
5078 ulInfo = Ndis802_11OFDM5;
5079 else if ((pAdapter->CommonCfg.PhyMode == PHY_11BG_MIXED) || (pAdapter->CommonCfg.PhyMode == PHY_11G))
5080 ulInfo = Ndis802_11OFDM24;
5082 ulInfo = Ndis802_11DS;
5083 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
5085 case RT_OID_802_11_QUERY_LAST_RX_RATE:
5086 ulInfo = (ULONG)pAdapter->LastRxRate;
5087 wrq->u.data.length = sizeof(ulInfo);
5088 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
5089 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_LAST_RX_RATE (=%ld)\n", ulInfo));
5091 case RT_OID_802_11_QUERY_LAST_TX_RATE:
5092 //ulInfo = (ULONG)pAdapter->LastTxRate;
5093 ulInfo = (ULONG)pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.word;
5094 wrq->u.data.length = sizeof(ulInfo);
5095 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
5096 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_LAST_TX_RATE (=%lx)\n", ulInfo));
5098 case RT_OID_802_11_QUERY_EEPROM_VERSION:
5099 wrq->u.data.length = sizeof(ULONG);
5100 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->EepromVersion, wrq->u.data.length);
5102 case RT_OID_802_11_QUERY_FIRMWARE_VERSION:
5103 wrq->u.data.length = sizeof(ULONG);
5104 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->FirmwareVersion, wrq->u.data.length);
5106 case RT_OID_802_11_QUERY_NOISE_LEVEL:
5107 wrq->u.data.length = sizeof(UCHAR);
5108 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->BbpWriteLatch[66], wrq->u.data.length);
5109 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_NOISE_LEVEL (=%d)\n", pAdapter->BbpWriteLatch[66]));
5111 case RT_OID_802_11_EXTRA_INFO:
5112 wrq->u.data.length = sizeof(ULONG);
5113 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->ExtraInfo, wrq->u.data.length);
5114 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_EXTRA_INFO (=%ld)\n", pAdapter->ExtraInfo));
5116 case RT_OID_WE_VERSION_COMPILED:
5117 wrq->u.data.length = sizeof(UINT);
5118 we_version_compiled = WIRELESS_EXT;
5119 Status = copy_to_user(wrq->u.data.pointer, &we_version_compiled, wrq->u.data.length);
5121 case RT_OID_802_11_QUERY_APSD_SETTING:
5122 apsd = (pAdapter->CommonCfg.bAPSDCapable | (pAdapter->CommonCfg.bAPSDAC_BE << 1) | (pAdapter->CommonCfg.bAPSDAC_BK << 2)
5123 | (pAdapter->CommonCfg.bAPSDAC_VI << 3) | (pAdapter->CommonCfg.bAPSDAC_VO << 4) | (pAdapter->CommonCfg.MaxSPLength << 5));
5125 wrq->u.data.length = sizeof(ULONG);
5126 Status = copy_to_user(wrq->u.data.pointer, &apsd, wrq->u.data.length);
5127 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",
5128 apsd,pAdapter->CommonCfg.bAPSDCapable,pAdapter->CommonCfg.bAPSDAC_BE,pAdapter->CommonCfg.bAPSDAC_BK,pAdapter->CommonCfg.bAPSDAC_VI,pAdapter->CommonCfg.bAPSDAC_VO,pAdapter->CommonCfg.MaxSPLength));
5130 case RT_OID_802_11_QUERY_APSD_PSM:
5131 wrq->u.data.length = sizeof(ULONG);
5132 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.bAPSDForcePowerSave, wrq->u.data.length);
5133 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_APSD_PSM (=%d)\n", pAdapter->CommonCfg.bAPSDForcePowerSave));
5135 case RT_OID_802_11_QUERY_WMM:
5136 wrq->u.data.length = sizeof(BOOLEAN);
5137 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.bWmmCapable, wrq->u.data.length);
5138 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_WMM (=%d)\n", pAdapter->CommonCfg.bWmmCapable));
5140 #ifdef WPA_SUPPLICANT_SUPPORT
5141 case RT_OID_NEW_DRIVER:
5144 wrq->u.data.length = sizeof(UCHAR);
5145 Status = copy_to_user(wrq->u.data.pointer, &enabled, wrq->u.data.length);
5146 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_NEW_DRIVER (=%d)\n", enabled));
5149 case RT_OID_WPA_SUPPLICANT_SUPPORT:
5150 wrq->u.data.length = sizeof(UCHAR);
5151 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->StaCfg.WpaSupplicantUP, wrq->u.data.length);
5152 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_WPA_SUPPLICANT_SUPPORT (=%d)\n", pAdapter->StaCfg.WpaSupplicantUP));
5154 #endif // WPA_SUPPLICANT_SUPPORT //
5156 case RT_OID_DRIVER_DEVICE_NAME:
5157 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_DRIVER_DEVICE_NAME \n"));
5158 wrq->u.data.length = 16;
5159 if (copy_to_user(wrq->u.data.pointer, pAdapter->StaCfg.dev_name, wrq->u.data.length))
5164 case RT_OID_802_11_QUERY_HT_PHYMODE:
5165 pHTPhyMode = (OID_SET_HT_PHYMODE *) kmalloc(sizeof(OID_SET_HT_PHYMODE), MEM_ALLOC_FLAG);
5168 pHTPhyMode->PhyMode = pAdapter->CommonCfg.PhyMode;
5169 pHTPhyMode->HtMode = (UCHAR)pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.field.MODE;
5170 pHTPhyMode->BW = (UCHAR)pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.field.BW;
5171 pHTPhyMode->MCS= (UCHAR)pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.field.MCS;
5172 pHTPhyMode->SHORTGI= (UCHAR)pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.field.ShortGI;
5173 pHTPhyMode->STBC= (UCHAR)pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.field.STBC;
5175 pHTPhyMode->ExtOffset = ((pAdapter->CommonCfg.CentralChannel < pAdapter->CommonCfg.Channel) ? (EXTCHA_BELOW) : (EXTCHA_ABOVE));
5176 wrq->u.data.length = sizeof(OID_SET_HT_PHYMODE);
5177 if (copy_to_user(wrq->u.data.pointer, pHTPhyMode, wrq->u.data.length))
5181 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_HT_PHYMODE (PhyMode = %d, MCS =%d, BW = %d, STBC = %d, ExtOffset=%d)\n",
5182 pHTPhyMode->HtMode, pHTPhyMode->MCS, pHTPhyMode->BW, pHTPhyMode->STBC, pHTPhyMode->ExtOffset));
5183 DBGPRINT(RT_DEBUG_TRACE, (" MlmeUpdateTxRates (.word = %x )\n", pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.word));
5187 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_STA_CONFIG(kmalloc failed)\n"));
5191 case RT_OID_802_11_COUNTRY_REGION:
5192 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_COUNTRY_REGION \n"));
5193 wrq->u.data.length = sizeof(ulInfo);
5194 ulInfo = pAdapter->CommonCfg.CountryRegionForABand;
5195 ulInfo = (ulInfo << 8)|(pAdapter->CommonCfg.CountryRegion);
5196 if (copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length))
5201 case RT_OID_802_11_QUERY_DAT_HT_PHYMODE:
5202 pHTPhyMode = (OID_SET_HT_PHYMODE *) kmalloc(sizeof(OID_SET_HT_PHYMODE), MEM_ALLOC_FLAG);
5205 pHTPhyMode->PhyMode = pAdapter->CommonCfg.PhyMode;
5206 pHTPhyMode->HtMode = (UCHAR)pAdapter->CommonCfg.RegTransmitSetting.field.HTMODE;
5207 pHTPhyMode->BW = (UCHAR)pAdapter->CommonCfg.RegTransmitSetting.field.BW;
5208 pHTPhyMode->MCS= (UCHAR)pAdapter->StaCfg.DesiredTransmitSetting.field.MCS;
5209 pHTPhyMode->SHORTGI= (UCHAR)pAdapter->CommonCfg.RegTransmitSetting.field.ShortGI;
5210 pHTPhyMode->STBC= (UCHAR)pAdapter->CommonCfg.RegTransmitSetting.field.STBC;
5212 wrq->u.data.length = sizeof(OID_SET_HT_PHYMODE);
5213 if (copy_to_user(wrq->u.data.pointer, pHTPhyMode, wrq->u.data.length))
5217 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_HT_PHYMODE (PhyMode = %d, MCS =%d, BW = %d, STBC = %d, ExtOffset=%d)\n",
5218 pHTPhyMode->HtMode, pHTPhyMode->MCS, pHTPhyMode->BW, pHTPhyMode->STBC, pHTPhyMode->ExtOffset));
5219 DBGPRINT(RT_DEBUG_TRACE, (" MlmeUpdateTxRates (.word = %x )\n", pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.word));
5223 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_STA_CONFIG(kmalloc failed)\n"));
5227 case RT_OID_QUERY_MULTIPLE_CARD_SUPPORT:
5228 wrq->u.data.length = sizeof(UCHAR);
5230 #ifdef MULTIPLE_CARD_SUPPORT
5232 #endif // MULTIPLE_CARD_SUPPORT //
5233 if (copy_to_user(wrq->u.data.pointer, &i, wrq->u.data.length))
5237 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_QUERY_MULTIPLE_CARD_SUPPORT(=%d) \n", i));
5240 case RT_OID_802_11_MAC_ADDRESS:
5241 wrq->u.data.length = MAC_ADDR_LEN;
5242 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CurrentAddress, wrq->u.data.length);
5245 case RT_OID_802_11_MANUFACTUREROUI:
5246 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_MANUFACTUREROUI \n"));
5247 wrq->u.data.length = ManufacturerOUI_LEN;
5248 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CurrentAddress, wrq->u.data.length);
5251 case RT_OID_802_11_MANUFACTURERNAME:
5252 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_MANUFACTURERNAME \n"));
5253 wrq->u.data.length = strlen(ManufacturerNAME);
5254 Status = copy_to_user(wrq->u.data.pointer, ManufacturerNAME, wrq->u.data.length);
5257 case RT_OID_802_11_RESOURCETYPEIDNAME:
5258 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_RESOURCETYPEIDNAME \n"));
5259 wrq->u.data.length = strlen(ResourceTypeIdName);
5260 Status = copy_to_user(wrq->u.data.pointer, ResourceTypeIdName, wrq->u.data.length);
5263 case RT_OID_802_11_PRIVACYOPTIONIMPLEMENTED:
5264 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_PRIVACYOPTIONIMPLEMENTED \n"));
5265 ulInfo = 1; // 1 is support wep else 2 is not support.
5266 wrq->u.data.length = sizeof(ulInfo);
5267 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
5270 case RT_OID_802_11_POWERMANAGEMENTMODE:
5271 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_POWERMANAGEMENTMODE \n"));
5272 if (pAdapter->StaCfg.Psm == PSMP_ACTION)
5273 ulInfo = 1; // 1 is power active else 2 is power save.
5277 wrq->u.data.length = sizeof(ulInfo);
5278 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
5281 case OID_802_11_WEPDEFAULTKEYVALUE:
5282 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_WEPDEFAULTKEYVALUE \n"));
5283 //KeyIdxValue.KeyIdx = pAd->PortCfg.MBSSID[pAd->IoctlIF].DefaultKeyId;
5284 pKeyIdxValue = wrq->u.data.pointer;
5285 DBGPRINT(RT_DEBUG_TRACE,("KeyIdxValue.KeyIdx = %d, \n",pKeyIdxValue->KeyIdx));
5286 valueLen = pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].KeyLen;
5287 NdisMoveMemory(pKeyIdxValue->Value,
5288 &pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].Key,
5290 pKeyIdxValue->Value[valueLen]='\0';
5292 wrq->u.data.length = sizeof(DefaultKeyIdxValue);
5294 Status = copy_to_user(wrq->u.data.pointer, pKeyIdxValue, wrq->u.data.length);
5295 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,
5296 pAdapter->SharedKey[BSS0][0].Key[0],
5297 pAdapter->SharedKey[BSS0][1].Key[0],
5298 pAdapter->SharedKey[BSS0][2].Key[0],
5299 pAdapter->SharedKey[BSS0][3].Key[0]));
5302 case OID_802_11_WEPDEFAULTKEYID:
5303 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_WEPDEFAULTKEYID \n"));
5304 wrq->u.data.length = sizeof(UCHAR);
5305 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->StaCfg.DefaultKeyId, wrq->u.data.length);
5306 DBGPRINT(RT_DEBUG_TRACE, ("DefaultKeyId =%d \n", pAdapter->StaCfg.DefaultKeyId));
5309 case RT_OID_802_11_WEPKEYMAPPINGLENGTH:
5310 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_WEPKEYMAPPINGLENGTH \n"));
5311 wrq->u.data.length = sizeof(UCHAR);
5312 Status = copy_to_user(wrq->u.data.pointer,
5313 &pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].KeyLen,
5314 wrq->u.data.length);
5317 case OID_802_11_SHORTRETRYLIMIT:
5318 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_SHORTRETRYLIMIT \n"));
5319 wrq->u.data.length = sizeof(ULONG);
5320 RTMP_IO_READ32(pAdapter, TX_RTY_CFG, &tx_rty_cfg.word);
5321 ShortRetryLimit = tx_rty_cfg.field.ShortRtyLimit;
5322 DBGPRINT(RT_DEBUG_TRACE, ("ShortRetryLimit =%ld, tx_rty_cfg.field.ShortRetryLimit=%d\n", ShortRetryLimit, tx_rty_cfg.field.ShortRtyLimit));
5323 Status = copy_to_user(wrq->u.data.pointer, &ShortRetryLimit, wrq->u.data.length);
5326 case OID_802_11_LONGRETRYLIMIT:
5327 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_LONGRETRYLIMIT \n"));
5328 wrq->u.data.length = sizeof(ULONG);
5329 RTMP_IO_READ32(pAdapter, TX_RTY_CFG, &tx_rty_cfg.word);
5330 LongRetryLimit = tx_rty_cfg.field.LongRtyLimit;
5331 DBGPRINT(RT_DEBUG_TRACE, ("LongRetryLimit =%ld, tx_rty_cfg.field.LongRtyLimit=%d\n", LongRetryLimit, tx_rty_cfg.field.LongRtyLimit));
5332 Status = copy_to_user(wrq->u.data.pointer, &LongRetryLimit, wrq->u.data.length);
5335 case RT_OID_802_11_PRODUCTID:
5336 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_PRODUCTID \n"));
5339 sprintf(tmp, "%04x %04x\n", ((POS_COOKIE)pAdapter->OS_Cookie)->pUsb_Dev->descriptor.idVendor ,((POS_COOKIE)pAdapter->OS_Cookie)->pUsb_Dev->descriptor.idProduct);
5342 wrq->u.data.length = strlen(tmp);
5343 Status = copy_to_user(wrq->u.data.pointer, tmp, wrq->u.data.length);
5346 case RT_OID_802_11_MANUFACTUREID:
5347 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_MANUFACTUREID \n"));
5348 wrq->u.data.length = strlen(ManufacturerNAME);
5349 Status = copy_to_user(wrq->u.data.pointer, ManufacturerNAME, wrq->u.data.length);
5352 case OID_802_11_CURRENTCHANNEL:
5353 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_CURRENTCHANNEL \n"));
5354 wrq->u.data.length = sizeof(UCHAR);
5355 DBGPRINT(RT_DEBUG_TRACE, ("sizeof UCHAR=%d, channel=%d \n", sizeof(UCHAR), pAdapter->CommonCfg.Channel));
5356 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.Channel, wrq->u.data.length);
5357 DBGPRINT(RT_DEBUG_TRACE, ("Status=%d\n", Status));
5359 #endif //SNMP_SUPPORT
5361 case OID_802_11_BUILD_CHANNEL_EX:
5364 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_BUILD_CHANNEL_EX \n"));
5365 wrq->u.data.length = sizeof(UCHAR);
5366 #ifdef EXT_BUILD_CHANNEL_LIST
5367 DBGPRINT(RT_DEBUG_TRACE, ("Support EXT_BUILD_CHANNEL_LIST.\n"));
5370 DBGPRINT(RT_DEBUG_TRACE, ("Doesn't support EXT_BUILD_CHANNEL_LIST.\n"));
5372 #endif // EXT_BUILD_CHANNEL_LIST //
5373 Status = copy_to_user(wrq->u.data.pointer, &value, 1);
5374 DBGPRINT(RT_DEBUG_TRACE, ("Status=%d\n", Status));
5378 case OID_802_11_GET_CH_LIST:
5380 PRT_CHANNEL_LIST_INFO pChListBuf;
5382 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_GET_CH_LIST \n"));
5383 if (pAdapter->ChannelListNum == 0)
5385 wrq->u.data.length = 0;
5389 pChListBuf = (RT_CHANNEL_LIST_INFO *) kmalloc(sizeof(RT_CHANNEL_LIST_INFO), MEM_ALLOC_FLAG);
5390 if (pChListBuf == NULL)
5392 wrq->u.data.length = 0;
5396 pChListBuf->ChannelListNum = pAdapter->ChannelListNum;
5397 for (i = 0; i < pChListBuf->ChannelListNum; i++)
5398 pChListBuf->ChannelList[i] = pAdapter->ChannelList[i].Channel;
5400 wrq->u.data.length = sizeof(RT_CHANNEL_LIST_INFO);
5401 Status = copy_to_user(wrq->u.data.pointer, pChListBuf, sizeof(RT_CHANNEL_LIST_INFO));
5402 DBGPRINT(RT_DEBUG_TRACE, ("Status=%d\n", Status));
5409 case OID_802_11_GET_COUNTRY_CODE:
5410 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_GET_COUNTRY_CODE \n"));
5411 wrq->u.data.length = 2;
5412 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.CountryCode, 2);
5413 DBGPRINT(RT_DEBUG_TRACE, ("Status=%d\n", Status));
5416 case OID_802_11_GET_CHANNEL_GEOGRAPHY:
5417 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_GET_CHANNEL_GEOGRAPHY \n"));
5418 wrq->u.data.length = 1;
5419 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.Geography, 1);
5420 DBGPRINT(RT_DEBUG_TRACE, ("Status=%d\n", Status));
5424 #ifdef QOS_DLS_SUPPORT
5425 case RT_OID_802_11_QUERY_DLS:
5426 wrq->u.data.length = sizeof(BOOLEAN);
5427 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.bDLSCapable, wrq->u.data.length);
5428 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_DLS(=%d)\n", pAdapter->CommonCfg.bDLSCapable));
5431 case RT_OID_802_11_QUERY_DLS_PARAM:
5433 PRT_802_11_DLS_INFO pDlsInfo = kmalloc(sizeof(RT_802_11_DLS_INFO), GFP_ATOMIC);
5434 if (pDlsInfo == NULL)
5437 for (i=0; i<MAX_NUM_OF_DLS_ENTRY; i++)
5439 RTMPMoveMemory(&pDlsInfo->Entry[i], &pAdapter->StaCfg.DLSEntry[i], sizeof(RT_802_11_DLS_UI));
5442 pDlsInfo->num = MAX_NUM_OF_DLS_ENTRY;
5443 wrq->u.data.length = sizeof(RT_802_11_DLS_INFO);
5444 Status = copy_to_user(wrq->u.data.pointer, pDlsInfo, wrq->u.data.length);
5445 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_DLS_PARAM\n"));
5451 #endif // QOS_DLS_SUPPORT //
5453 DBGPRINT(RT_DEBUG_TRACE, ("Query::unknown IOCTL's subcmd = 0x%08x\n", cmd));
5454 Status = -EOPNOTSUPP;
5460 INT rt28xx_sta_ioctl(
5461 IN struct net_device *net_dev,
5462 IN OUT struct ifreq *rq,
5466 VIRTUAL_ADAPTER *pVirtualAd = NULL;
5467 RTMP_ADAPTER *pAd = NULL;
5468 struct iwreq *wrq = (struct iwreq *) rq;
5469 BOOLEAN StateMachineTouched = FALSE;
5470 INT Status = NDIS_STATUS_SUCCESS;
5473 if (net_dev->priv_flags == INT_MAIN)
5475 pAd = net_dev->ml_priv;
5479 pVirtualAd = net_dev->ml_priv;
5480 pAd = pVirtualAd->RtmpDev->ml_priv;
5482 pObj = (POS_COOKIE) pAd->OS_Cookie;
5486 /* if 1st open fail, pAd will be free;
5487 So the net_dev->ml_priv will be NULL in 2rd open */
5491 //check if the interface is down
5492 if(!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_IN_USE))
5494 #ifdef CONFIG_APSTA_MIXED_SUPPORT
5495 if (wrq->u.data.pointer == NULL)
5500 if (strstr(wrq->u.data.pointer, "OpMode") == NULL)
5501 #endif // CONFIG_APSTA_MIXED_SUPPORT //
5503 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
5508 { // determine this ioctl command is comming from which interface.
5509 pObj->ioctl_if_type = INT_MAIN;
5510 pObj->ioctl_if = MAIN_MBSSID;
5516 #ifdef RALINK_28xx_QA
5517 case RTPRIV_IOCTL_ATE:
5519 RtmpDoAte(pAd, wrq);
5522 #endif // RALINK_28xx_QA //
5523 #endif // RALINK_ATE //
5525 DBGPRINT(RT_DEBUG_TRACE, ("IOCTL::SIOCGIFHWADDR\n"));
5526 memcpy(wrq->u.name, pAd->CurrentAddress, ETH_ALEN);
5530 char *name=&wrq->u.name[0];
5531 rt_ioctl_giwname(net_dev, NULL, name, NULL);
5534 case SIOCGIWESSID: //Get ESSID
5536 struct iw_point *essid=&wrq->u.essid;
5537 rt_ioctl_giwessid(net_dev, NULL, essid, essid->pointer);
5540 case SIOCSIWESSID: //Set ESSID
5542 struct iw_point *essid=&wrq->u.essid;
5543 rt_ioctl_siwessid(net_dev, NULL, essid, essid->pointer);
5546 case SIOCSIWNWID: // set network id (the cell)
5547 case SIOCGIWNWID: // get network id
5548 Status = -EOPNOTSUPP;
5550 case SIOCSIWFREQ: //set channel/frequency (Hz)
5552 struct iw_freq *freq=&wrq->u.freq;
5553 rt_ioctl_siwfreq(net_dev, NULL, freq, NULL);
5556 case SIOCGIWFREQ: // get channel/frequency (Hz)
5558 struct iw_freq *freq=&wrq->u.freq;
5559 rt_ioctl_giwfreq(net_dev, NULL, freq, NULL);
5562 case SIOCSIWNICKN: //set node name/nickname
5564 struct iw_point *data=&wrq->u.data;
5565 rt_ioctl_siwnickn(net_dev, NULL, data, NULL);
5568 case SIOCGIWNICKN: //get node name/nickname
5570 struct iw_point *data=&wrq->u.data;
5571 rt_ioctl_giwnickn(net_dev, NULL, data, NULL);
5574 case SIOCGIWRATE: //get default bit rate (bps)
5575 rt_ioctl_giwrate(net_dev, NULL, &wrq->u, NULL);
5577 case SIOCSIWRATE: //set default bit rate (bps)
5578 rt_ioctl_siwrate(net_dev, NULL, &wrq->u, NULL);
5580 case SIOCGIWRTS: // get RTS/CTS threshold (bytes)
5582 struct iw_param *rts=&wrq->u.rts;
5583 rt_ioctl_giwrts(net_dev, NULL, rts, NULL);
5586 case SIOCSIWRTS: //set RTS/CTS threshold (bytes)
5588 struct iw_param *rts=&wrq->u.rts;
5589 rt_ioctl_siwrts(net_dev, NULL, rts, NULL);
5592 case SIOCGIWFRAG: //get fragmentation thr (bytes)
5594 struct iw_param *frag=&wrq->u.frag;
5595 rt_ioctl_giwfrag(net_dev, NULL, frag, NULL);
5598 case SIOCSIWFRAG: //set fragmentation thr (bytes)
5600 struct iw_param *frag=&wrq->u.frag;
5601 rt_ioctl_siwfrag(net_dev, NULL, frag, NULL);
5604 case SIOCGIWENCODE: //get encoding token & mode
5606 struct iw_point *erq=&wrq->u.encoding;
5608 rt_ioctl_giwencode(net_dev, NULL, erq, erq->pointer);
5611 case SIOCSIWENCODE: //set encoding token & mode
5613 struct iw_point *erq=&wrq->u.encoding;
5615 rt_ioctl_siwencode(net_dev, NULL, erq, erq->pointer);
5618 case SIOCGIWAP: //get access point MAC addresses
5620 struct sockaddr *ap_addr=&wrq->u.ap_addr;
5621 rt_ioctl_giwap(net_dev, NULL, ap_addr, ap_addr->sa_data);
5624 case SIOCSIWAP: //set access point MAC addresses
5626 struct sockaddr *ap_addr=&wrq->u.ap_addr;
5627 rt_ioctl_siwap(net_dev, NULL, ap_addr, ap_addr->sa_data);
5630 case SIOCGIWMODE: //get operation mode
5632 __u32 *mode=&wrq->u.mode;
5633 rt_ioctl_giwmode(net_dev, NULL, mode, NULL);
5636 case SIOCSIWMODE: //set operation mode
5638 __u32 *mode=&wrq->u.mode;
5639 rt_ioctl_siwmode(net_dev, NULL, mode, NULL);
5642 case SIOCGIWSENS: //get sensitivity (dBm)
5643 case SIOCSIWSENS: //set sensitivity (dBm)
5644 case SIOCGIWPOWER: //get Power Management settings
5645 case SIOCSIWPOWER: //set Power Management settings
5646 case SIOCGIWTXPOW: //get transmit power (dBm)
5647 case SIOCSIWTXPOW: //set transmit power (dBm)
5648 case SIOCGIWRANGE: //Get range of parameters
5649 case SIOCGIWRETRY: //get retry limits and lifetime
5650 case SIOCSIWRETRY: //set retry limits and lifetime
5651 Status = -EOPNOTSUPP;
5654 subcmd = wrq->u.data.flags;
5655 if( subcmd & OID_GET_SET_TOGGLE)
5656 Status = RTMPSetInformation(pAd, rq, subcmd);
5658 Status = RTMPQueryInformation(pAd, rq, subcmd);
5661 if (wrq->u.data.pointer)
5663 if ( access_ok(VERIFY_WRITE, wrq->u.data.pointer, sizeof(privtab)) != TRUE)
5665 wrq->u.data.length = sizeof(privtab) / sizeof(privtab[0]);
5666 if (copy_to_user(wrq->u.data.pointer, privtab, sizeof(privtab)))
5670 case RTPRIV_IOCTL_SET:
5671 if(access_ok(VERIFY_READ, wrq->u.data.pointer, wrq->u.data.length) != TRUE)
5673 rt_ioctl_setparam(net_dev, NULL, NULL, wrq->u.data.pointer);
5675 case RTPRIV_IOCTL_GSITESURVEY:
5676 RTMPIoctlGetSiteSurvey(pAd, wrq);
5679 case RTPRIV_IOCTL_MAC:
5680 RTMPIoctlMAC(pAd, wrq);
5682 case RTPRIV_IOCTL_E2P:
5683 RTMPIoctlE2PROM(pAd, wrq);
5689 DBGPRINT(RT_DEBUG_ERROR, ("IOCTL::unknown IOCTL's cmd = 0x%08x\n", cmd));
5690 Status = -EOPNOTSUPP;
5694 if(StateMachineTouched) // Upper layer sent a MLME-related operations
5695 RT28XX_MLME_HANDLER(pAd);
5701 ==========================================================================
5705 TRUE if all parameters are OK, FALSE otherwise
5706 ==========================================================================
5709 IN PRTMP_ADAPTER pAdapter,
5712 NDIS_802_11_SSID Ssid, *pSsid=NULL;
5713 BOOLEAN StateMachineTouched = FALSE;
5716 if( strlen(arg) <= MAX_LEN_OF_SSID)
5718 NdisZeroMemory(&Ssid, sizeof(NDIS_802_11_SSID));
5719 if (strlen(arg) != 0)
5721 NdisMoveMemory(Ssid.Ssid, arg, strlen(arg));
5722 Ssid.SsidLength = strlen(arg);
5726 Ssid.SsidLength = 0;
5727 memcpy(Ssid.Ssid, "", 0);
5728 pAdapter->StaCfg.BssType = BSS_INFRA;
5729 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
5730 pAdapter->StaCfg.WepStatus = Ndis802_11EncryptionDisabled;
5734 if (pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE)
5736 RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
5737 DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
5740 pAdapter->MlmeAux.CurrReqIsFromNdis = TRUE;
5741 pAdapter->StaCfg.bScanReqIsFromWebUI = FALSE;
5742 pAdapter->bConfigChanged = TRUE;
5744 MlmeEnqueue(pAdapter,
5745 MLME_CNTL_STATE_MACHINE,
5747 sizeof(NDIS_802_11_SSID),
5750 StateMachineTouched = TRUE;
5751 DBGPRINT(RT_DEBUG_TRACE, ("Set_SSID_Proc::(Len=%d,Ssid=%s)\n", Ssid.SsidLength, Ssid.Ssid));
5756 if (StateMachineTouched) // Upper layer sent a MLME-related operations
5757 RT28XX_MLME_HANDLER(pAdapter);
5764 ==========================================================================
5766 Set WmmCapable Enable or Disable
5768 TRUE if all parameters are OK, FALSE otherwise
5769 ==========================================================================
5771 INT Set_WmmCapable_Proc(
5772 IN PRTMP_ADAPTER pAd,
5775 BOOLEAN bWmmCapable;
5777 bWmmCapable = simple_strtol(arg, 0, 10);
5779 if ((bWmmCapable == 1)
5781 && (pAd->NumberOfPipes >= 5)
5784 pAd->CommonCfg.bWmmCapable = TRUE;
5785 else if (bWmmCapable == 0)
5786 pAd->CommonCfg.bWmmCapable = FALSE;
5788 return FALSE; //Invalid argument
5790 DBGPRINT(RT_DEBUG_TRACE, ("Set_WmmCapable_Proc::(bWmmCapable=%d)\n",
5791 pAd->CommonCfg.bWmmCapable));
5795 #endif // WMM_SUPPORT //
5798 ==========================================================================
5800 Set Network Type(Infrastructure/Adhoc mode)
5802 TRUE if all parameters are OK, FALSE otherwise
5803 ==========================================================================
5805 INT Set_NetworkType_Proc(
5806 IN PRTMP_ADAPTER pAdapter,
5811 if (strcmp(arg, "Adhoc") == 0)
5813 if (pAdapter->StaCfg.BssType != BSS_ADHOC)
5815 // Config has changed
5816 pAdapter->bConfigChanged = TRUE;
5817 if (MONITOR_ON(pAdapter))
5819 RTMP_IO_WRITE32(pAdapter, RX_FILTR_CFG, STANORMAL);
5820 RTMP_IO_READ32(pAdapter, MAC_SYS_CTRL, &Value);
5822 RTMP_IO_WRITE32(pAdapter, MAC_SYS_CTRL, Value);
5823 OPSTATUS_CLEAR_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED);
5824 pAdapter->StaCfg.bAutoReconnect = TRUE;
5825 LinkDown(pAdapter, FALSE);
5827 if (INFRA_ON(pAdapter))
5829 //BOOLEAN Cancelled;
5830 // Set the AutoReconnectSsid to prevent it reconnect to old SSID
5831 // Since calling this indicate user don't want to connect to that SSID anymore.
5832 pAdapter->MlmeAux.AutoReconnectSsidLen= 32;
5833 NdisZeroMemory(pAdapter->MlmeAux.AutoReconnectSsid, pAdapter->MlmeAux.AutoReconnectSsidLen);
5835 LinkDown(pAdapter, FALSE);
5837 DBGPRINT(RT_DEBUG_TRACE, ("NDIS_STATUS_MEDIA_DISCONNECT Event BB!\n"));
5840 pAdapter->StaCfg.BssType = BSS_ADHOC;
5841 pAdapter->net_dev->type = pAdapter->StaCfg.OriDevType;
5842 DBGPRINT(RT_DEBUG_TRACE, ("===>Set_NetworkType_Proc::(AD-HOC)\n"));
5844 else if (strcmp(arg, "Infra") == 0)
5846 if (pAdapter->StaCfg.BssType != BSS_INFRA)
5848 // Config has changed
5849 pAdapter->bConfigChanged = TRUE;
5850 if (MONITOR_ON(pAdapter))
5852 RTMP_IO_WRITE32(pAdapter, RX_FILTR_CFG, STANORMAL);
5853 RTMP_IO_READ32(pAdapter, MAC_SYS_CTRL, &Value);
5855 RTMP_IO_WRITE32(pAdapter, MAC_SYS_CTRL, Value);
5856 OPSTATUS_CLEAR_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED);
5857 pAdapter->StaCfg.bAutoReconnect = TRUE;
5858 LinkDown(pAdapter, FALSE);
5860 if (ADHOC_ON(pAdapter))
5862 // Set the AutoReconnectSsid to prevent it reconnect to old SSID
5863 // Since calling this indicate user don't want to connect to that SSID anymore.
5864 pAdapter->MlmeAux.AutoReconnectSsidLen= 32;
5865 NdisZeroMemory(pAdapter->MlmeAux.AutoReconnectSsid, pAdapter->MlmeAux.AutoReconnectSsidLen);
5867 LinkDown(pAdapter, FALSE);
5870 pAdapter->StaCfg.BssType = BSS_INFRA;
5871 pAdapter->net_dev->type = pAdapter->StaCfg.OriDevType;
5872 DBGPRINT(RT_DEBUG_TRACE, ("===>Set_NetworkType_Proc::(INFRA)\n"));
5874 pAdapter->StaCfg.BssType = BSS_INFRA;
5876 else if (strcmp(arg, "Monitor") == 0)
5879 BCN_TIME_CFG_STRUC csr;
5880 OPSTATUS_CLEAR_FLAG(pAdapter, fOP_STATUS_INFRA_ON);
5881 OPSTATUS_CLEAR_FLAG(pAdapter, fOP_STATUS_ADHOC_ON);
5882 OPSTATUS_SET_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED);
5883 // disable all periodic state machine
5884 pAdapter->StaCfg.bAutoReconnect = FALSE;
5885 // reset all mlme state machine
5886 RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
5887 DBGPRINT(RT_DEBUG_TRACE, ("fOP_STATUS_MEDIA_STATE_CONNECTED \n"));
5888 if (pAdapter->CommonCfg.CentralChannel == 0)
5890 #ifdef DOT11_N_SUPPORT
5891 if (pAdapter->CommonCfg.PhyMode == PHY_11AN_MIXED)
5892 pAdapter->CommonCfg.CentralChannel = 36;
5894 #endif // DOT11_N_SUPPORT //
5895 pAdapter->CommonCfg.CentralChannel = 6;
5897 #ifdef DOT11_N_SUPPORT
5899 N_ChannelCheck(pAdapter);
5900 #endif // DOT11_N_SUPPORT //
5902 #ifdef DOT11_N_SUPPORT
5903 if (pAdapter->CommonCfg.PhyMode >= PHY_11ABGN_MIXED &&
5904 pAdapter->CommonCfg.RegTransmitSetting.field.BW == BW_40 &&
5905 pAdapter->CommonCfg.RegTransmitSetting.field.EXTCHA == EXTCHA_ABOVE)
5907 // 40MHz ,control channel at lower
5908 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, BBP_R4, &bbpValue);
5909 bbpValue &= (~0x18);
5911 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R4, bbpValue);
5912 pAdapter->CommonCfg.BBPCurrentBW = BW_40;
5913 // RX : control channel at lower
5914 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, BBP_R3, &bbpValue);
5915 bbpValue &= (~0x20);
5916 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R3, bbpValue);
5918 RTMP_IO_READ32(pAdapter, TX_BAND_CFG, &Value);
5919 Value &= 0xfffffffe;
5920 RTMP_IO_WRITE32(pAdapter, TX_BAND_CFG, Value);
5921 pAdapter->CommonCfg.CentralChannel = pAdapter->CommonCfg.Channel + 2;
5922 AsicSwitchChannel(pAdapter, pAdapter->CommonCfg.CentralChannel, FALSE);
5923 AsicLockChannel(pAdapter, pAdapter->CommonCfg.CentralChannel);
5924 DBGPRINT(RT_DEBUG_TRACE, ("BW_40 ,control_channel(%d), CentralChannel(%d) \n",
5925 pAdapter->CommonCfg.Channel,
5926 pAdapter->CommonCfg.CentralChannel));
5928 else if (pAdapter->CommonCfg.PhyMode >= PHY_11ABGN_MIXED &&
5929 pAdapter->CommonCfg.RegTransmitSetting.field.BW == BW_40 &&
5930 pAdapter->CommonCfg.RegTransmitSetting.field.EXTCHA == EXTCHA_BELOW)
5932 // 40MHz ,control channel at upper
5933 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, BBP_R4, &bbpValue);
5934 bbpValue &= (~0x18);
5936 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R4, bbpValue);
5937 pAdapter->CommonCfg.BBPCurrentBW = BW_40;
5938 RTMP_IO_READ32(pAdapter, TX_BAND_CFG, &Value);
5940 RTMP_IO_WRITE32(pAdapter, TX_BAND_CFG, Value);
5942 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, BBP_R3, &bbpValue);
5944 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R3, bbpValue);
5945 pAdapter->CommonCfg.CentralChannel = pAdapter->CommonCfg.Channel - 2;
5946 AsicSwitchChannel(pAdapter, pAdapter->CommonCfg.CentralChannel, FALSE);
5947 AsicLockChannel(pAdapter, pAdapter->CommonCfg.CentralChannel);
5948 DBGPRINT(RT_DEBUG_TRACE, ("BW_40 ,control_channel(%d), CentralChannel(%d) \n",
5949 pAdapter->CommonCfg.Channel,
5950 pAdapter->CommonCfg.CentralChannel));
5953 #endif // DOT11_N_SUPPORT //
5956 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, BBP_R4, &bbpValue);
5957 bbpValue &= (~0x18);
5958 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R4, bbpValue);
5959 pAdapter->CommonCfg.BBPCurrentBW = BW_20;
5960 AsicSwitchChannel(pAdapter, pAdapter->CommonCfg.Channel, FALSE);
5961 AsicLockChannel(pAdapter, pAdapter->CommonCfg.Channel);
5962 DBGPRINT(RT_DEBUG_TRACE, ("BW_20, Channel(%d)\n", pAdapter->CommonCfg.Channel));
5964 // Enable Rx with promiscuous reception
5965 RTMP_IO_WRITE32(pAdapter, RX_FILTR_CFG, 0x3);
5966 // ASIC supporsts sniffer function with replacing RSSI with timestamp.
5967 //RTMP_IO_READ32(pAdapter, MAC_SYS_CTRL, &Value);
5969 //RTMP_IO_WRITE32(pAdapter, MAC_SYS_CTRL, Value);
5971 RTMP_IO_READ32(pAdapter, BCN_TIME_CFG, &csr.word);
5972 csr.field.bBeaconGen = 0;
5973 csr.field.bTBTTEnable = 0;
5974 csr.field.TsfSyncMode = 0;
5975 RTMP_IO_WRITE32(pAdapter, BCN_TIME_CFG, csr.word);
5977 pAdapter->StaCfg.BssType = BSS_MONITOR;
5978 pAdapter->net_dev->type = ARPHRD_IEEE80211_PRISM; //ARPHRD_IEEE80211; // IEEE80211
5979 DBGPRINT(RT_DEBUG_TRACE, ("===>Set_NetworkType_Proc::(MONITOR)\n"));
5982 // Reset Ralink supplicant to not use, it will be set to start when UI set PMK key
5983 pAdapter->StaCfg.WpaState = SS_NOTUSE;
5985 DBGPRINT(RT_DEBUG_TRACE, ("Set_NetworkType_Proc::(NetworkType=%d)\n", pAdapter->StaCfg.BssType));
5991 ==========================================================================
5993 Set Authentication mode
5995 TRUE if all parameters are OK, FALSE otherwise
5996 ==========================================================================
5998 INT Set_AuthMode_Proc(
5999 IN PRTMP_ADAPTER pAdapter,
6002 if ((strcmp(arg, "WEPAUTO") == 0) || (strcmp(arg, "wepauto") == 0))
6003 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeAutoSwitch;
6004 else if ((strcmp(arg, "OPEN") == 0) || (strcmp(arg, "open") == 0))
6005 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
6006 else if ((strcmp(arg, "SHARED") == 0) || (strcmp(arg, "shared") == 0))
6007 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeShared;
6008 else if ((strcmp(arg, "WPAPSK") == 0) || (strcmp(arg, "wpapsk") == 0))
6009 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPAPSK;
6010 else if ((strcmp(arg, "WPANONE") == 0) || (strcmp(arg, "wpanone") == 0))
6011 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPANone;
6012 else if ((strcmp(arg, "WPA2PSK") == 0) || (strcmp(arg, "wpa2psk") == 0))
6013 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA2PSK;
6014 #ifdef WPA_SUPPLICANT_SUPPORT
6015 else if ((strcmp(arg, "WPA") == 0) || (strcmp(arg, "wpa") == 0))
6016 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA;
6017 else if ((strcmp(arg, "WPA2") == 0) || (strcmp(arg, "wpa2") == 0))
6018 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA2;
6019 #endif // WPA_SUPPLICANT_SUPPORT //
6023 pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED;
6025 DBGPRINT(RT_DEBUG_TRACE, ("Set_AuthMode_Proc::(AuthMode=%d)\n", pAdapter->StaCfg.AuthMode));
6031 ==========================================================================
6035 TRUE if all parameters are OK, FALSE otherwise
6036 ==========================================================================
6038 INT Set_EncrypType_Proc(
6039 IN PRTMP_ADAPTER pAdapter,
6042 if ((strcmp(arg, "NONE") == 0) || (strcmp(arg, "none") == 0))
6044 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
6045 return TRUE; // do nothing
6047 pAdapter->StaCfg.WepStatus = Ndis802_11WEPDisabled;
6048 pAdapter->StaCfg.PairCipher = Ndis802_11WEPDisabled;
6049 pAdapter->StaCfg.GroupCipher = Ndis802_11WEPDisabled;
6051 else if ((strcmp(arg, "WEP") == 0) || (strcmp(arg, "wep") == 0))
6053 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
6054 return TRUE; // do nothing
6056 pAdapter->StaCfg.WepStatus = Ndis802_11WEPEnabled;
6057 pAdapter->StaCfg.PairCipher = Ndis802_11WEPEnabled;
6058 pAdapter->StaCfg.GroupCipher = Ndis802_11WEPEnabled;
6060 else if ((strcmp(arg, "TKIP") == 0) || (strcmp(arg, "tkip") == 0))
6062 if (pAdapter->StaCfg.AuthMode < Ndis802_11AuthModeWPA)
6063 return TRUE; // do nothing
6065 pAdapter->StaCfg.WepStatus = Ndis802_11Encryption2Enabled;
6066 pAdapter->StaCfg.PairCipher = Ndis802_11Encryption2Enabled;
6067 pAdapter->StaCfg.GroupCipher = Ndis802_11Encryption2Enabled;
6069 else if ((strcmp(arg, "AES") == 0) || (strcmp(arg, "aes") == 0))
6071 if (pAdapter->StaCfg.AuthMode < Ndis802_11AuthModeWPA)
6072 return TRUE; // do nothing
6074 pAdapter->StaCfg.WepStatus = Ndis802_11Encryption3Enabled;
6075 pAdapter->StaCfg.PairCipher = Ndis802_11Encryption3Enabled;
6076 pAdapter->StaCfg.GroupCipher = Ndis802_11Encryption3Enabled;
6081 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
6083 DBGPRINT(RT_DEBUG_TRACE, ("Set_EncrypType_Proc::(EncrypType=%d)\n", pAdapter->StaCfg.WepStatus));
6089 ==========================================================================
6093 TRUE if all parameters are OK, FALSE otherwise
6094 ==========================================================================
6096 INT Set_DefaultKeyID_Proc(
6097 IN PRTMP_ADAPTER pAdapter,
6102 KeyIdx = simple_strtol(arg, 0, 10);
6103 if((KeyIdx >= 1 ) && (KeyIdx <= 4))
6104 pAdapter->StaCfg.DefaultKeyId = (UCHAR) (KeyIdx - 1 );
6106 return FALSE; //Invalid argument
6108 DBGPRINT(RT_DEBUG_TRACE, ("Set_DefaultKeyID_Proc::(DefaultKeyID=%d)\n", pAdapter->StaCfg.DefaultKeyId));
6114 ==========================================================================
6118 TRUE if all parameters are OK, FALSE otherwise
6119 ==========================================================================
6122 IN PRTMP_ADAPTER pAdapter,
6127 UCHAR CipherAlg=CIPHER_WEP64;
6129 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
6130 return TRUE; // do nothing
6132 KeyLen = strlen(arg);
6136 case 5: //wep 40 Ascii type
6137 pAdapter->SharedKey[BSS0][0].KeyLen = KeyLen;
6138 memcpy(pAdapter->SharedKey[BSS0][0].Key, arg, KeyLen);
6139 CipherAlg = CIPHER_WEP64;
6140 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key1_Proc::(Key1=%s and type=%s)\n", arg, "Ascii"));
6142 case 10: //wep 40 Hex type
6143 for(i=0; i < KeyLen; i++)
6145 if( !isxdigit(*(arg+i)) )
6146 return FALSE; //Not Hex value;
6148 pAdapter->SharedKey[BSS0][0].KeyLen = KeyLen / 2 ;
6149 AtoH(arg, pAdapter->SharedKey[BSS0][0].Key, KeyLen / 2);
6150 CipherAlg = CIPHER_WEP64;
6151 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key1_Proc::(Key1=%s and type=%s)\n", arg, "Hex"));
6153 case 13: //wep 104 Ascii type
6154 pAdapter->SharedKey[BSS0][0].KeyLen = KeyLen;
6155 memcpy(pAdapter->SharedKey[BSS0][0].Key, arg, KeyLen);
6156 CipherAlg = CIPHER_WEP128;
6157 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key1_Proc::(Key1=%s and type=%s)\n", arg, "Ascii"));
6159 case 26: //wep 104 Hex type
6160 for(i=0; i < KeyLen; i++)
6162 if( !isxdigit(*(arg+i)) )
6163 return FALSE; //Not Hex value;
6165 pAdapter->SharedKey[BSS0][0].KeyLen = KeyLen / 2 ;
6166 AtoH(arg, pAdapter->SharedKey[BSS0][0].Key, KeyLen / 2);
6167 CipherAlg = CIPHER_WEP128;
6168 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key1_Proc::(Key1=%s and type=%s)\n", arg, "Hex"));
6170 default: //Invalid argument
6171 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key1_Proc::Invalid argument (=%s)\n", arg));
6175 pAdapter->SharedKey[BSS0][0].CipherAlg = CipherAlg;
6177 // Set keys (into ASIC)
6178 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
6180 else // Old WEP stuff
6182 AsicAddSharedKeyEntry(pAdapter,
6185 pAdapter->SharedKey[BSS0][0].CipherAlg,
6186 pAdapter->SharedKey[BSS0][0].Key,
6194 ==========================================================================
6199 TRUE if all parameters are OK, FALSE otherwise
6200 ==========================================================================
6203 IN PRTMP_ADAPTER pAdapter,
6208 UCHAR CipherAlg=CIPHER_WEP64;
6210 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
6211 return TRUE; // do nothing
6213 KeyLen = strlen(arg);
6217 case 5: //wep 40 Ascii type
6218 pAdapter->SharedKey[BSS0][1].KeyLen = KeyLen;
6219 memcpy(pAdapter->SharedKey[BSS0][1].Key, arg, KeyLen);
6220 CipherAlg = CIPHER_WEP64;
6221 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key2_Proc::(Key2=%s and type=%s)\n", arg, "Ascii"));
6223 case 10: //wep 40 Hex type
6224 for(i=0; i < KeyLen; i++)
6226 if( !isxdigit(*(arg+i)) )
6227 return FALSE; //Not Hex value;
6229 pAdapter->SharedKey[BSS0][1].KeyLen = KeyLen / 2 ;
6230 AtoH(arg, pAdapter->SharedKey[BSS0][1].Key, KeyLen / 2);
6231 CipherAlg = CIPHER_WEP64;
6232 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key2_Proc::(Key2=%s and type=%s)\n", arg, "Hex"));
6234 case 13: //wep 104 Ascii type
6235 pAdapter->SharedKey[BSS0][1].KeyLen = KeyLen;
6236 memcpy(pAdapter->SharedKey[BSS0][1].Key, arg, KeyLen);
6237 CipherAlg = CIPHER_WEP128;
6238 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key2_Proc::(Key2=%s and type=%s)\n", arg, "Ascii"));
6240 case 26: //wep 104 Hex type
6241 for(i=0; i < KeyLen; i++)
6243 if( !isxdigit(*(arg+i)) )
6244 return FALSE; //Not Hex value;
6246 pAdapter->SharedKey[BSS0][1].KeyLen = KeyLen / 2 ;
6247 AtoH(arg, pAdapter->SharedKey[BSS0][1].Key, KeyLen / 2);
6248 CipherAlg = CIPHER_WEP128;
6249 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key2_Proc::(Key2=%s and type=%s)\n", arg, "Hex"));
6251 default: //Invalid argument
6252 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key2_Proc::Invalid argument (=%s)\n", arg));
6255 pAdapter->SharedKey[BSS0][1].CipherAlg = CipherAlg;
6257 // Set keys (into ASIC)
6258 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
6260 else // Old WEP stuff
6262 AsicAddSharedKeyEntry(pAdapter,
6265 pAdapter->SharedKey[BSS0][1].CipherAlg,
6266 pAdapter->SharedKey[BSS0][1].Key,
6274 ==========================================================================
6278 TRUE if all parameters are OK, FALSE otherwise
6279 ==========================================================================
6282 IN PRTMP_ADAPTER pAdapter,
6287 UCHAR CipherAlg=CIPHER_WEP64;
6289 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
6290 return TRUE; // do nothing
6292 KeyLen = strlen(arg);
6296 case 5: //wep 40 Ascii type
6297 pAdapter->SharedKey[BSS0][2].KeyLen = KeyLen;
6298 memcpy(pAdapter->SharedKey[BSS0][2].Key, arg, KeyLen);
6299 CipherAlg = CIPHER_WEP64;
6300 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key3_Proc::(Key3=%s and type=Ascii)\n", arg));
6302 case 10: //wep 40 Hex type
6303 for(i=0; i < KeyLen; i++)
6305 if( !isxdigit(*(arg+i)) )
6306 return FALSE; //Not Hex value;
6308 pAdapter->SharedKey[BSS0][2].KeyLen = KeyLen / 2 ;
6309 AtoH(arg, pAdapter->SharedKey[BSS0][2].Key, KeyLen / 2);
6310 CipherAlg = CIPHER_WEP64;
6311 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key3_Proc::(Key3=%s and type=Hex)\n", arg));
6313 case 13: //wep 104 Ascii type
6314 pAdapter->SharedKey[BSS0][2].KeyLen = KeyLen;
6315 memcpy(pAdapter->SharedKey[BSS0][2].Key, arg, KeyLen);
6316 CipherAlg = CIPHER_WEP128;
6317 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key3_Proc::(Key3=%s and type=Ascii)\n", arg));
6319 case 26: //wep 104 Hex type
6320 for(i=0; i < KeyLen; i++)
6322 if( !isxdigit(*(arg+i)) )
6323 return FALSE; //Not Hex value;
6325 pAdapter->SharedKey[BSS0][2].KeyLen = KeyLen / 2 ;
6326 AtoH(arg, pAdapter->SharedKey[BSS0][2].Key, KeyLen / 2);
6327 CipherAlg = CIPHER_WEP128;
6328 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key3_Proc::(Key3=%s and type=Hex)\n", arg));
6330 default: //Invalid argument
6331 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key3_Proc::Invalid argument (=%s)\n", arg));
6334 pAdapter->SharedKey[BSS0][2].CipherAlg = CipherAlg;
6336 // Set keys (into ASIC)
6337 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
6339 else // Old WEP stuff
6341 AsicAddSharedKeyEntry(pAdapter,
6344 pAdapter->SharedKey[BSS0][2].CipherAlg,
6345 pAdapter->SharedKey[BSS0][2].Key,
6353 ==========================================================================
6357 TRUE if all parameters are OK, FALSE otherwise
6358 ==========================================================================
6361 IN PRTMP_ADAPTER pAdapter,
6366 UCHAR CipherAlg=CIPHER_WEP64;
6368 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
6369 return TRUE; // do nothing
6371 KeyLen = strlen(arg);
6375 case 5: //wep 40 Ascii type
6376 pAdapter->SharedKey[BSS0][3].KeyLen = KeyLen;
6377 memcpy(pAdapter->SharedKey[BSS0][3].Key, arg, KeyLen);
6378 CipherAlg = CIPHER_WEP64;
6379 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key4_Proc::(Key4=%s and type=%s)\n", arg, "Ascii"));
6381 case 10: //wep 40 Hex type
6382 for(i=0; i < KeyLen; i++)
6384 if( !isxdigit(*(arg+i)) )
6385 return FALSE; //Not Hex value;
6387 pAdapter->SharedKey[BSS0][3].KeyLen = KeyLen / 2 ;
6388 AtoH(arg, pAdapter->SharedKey[BSS0][3].Key, KeyLen / 2);
6389 CipherAlg = CIPHER_WEP64;
6390 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key4_Proc::(Key4=%s and type=%s)\n", arg, "Hex"));
6392 case 13: //wep 104 Ascii type
6393 pAdapter->SharedKey[BSS0][3].KeyLen = KeyLen;
6394 memcpy(pAdapter->SharedKey[BSS0][3].Key, arg, KeyLen);
6395 CipherAlg = CIPHER_WEP128;
6396 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key4_Proc::(Key4=%s and type=%s)\n", arg, "Ascii"));
6398 case 26: //wep 104 Hex type
6399 for(i=0; i < KeyLen; i++)
6401 if( !isxdigit(*(arg+i)) )
6402 return FALSE; //Not Hex value;
6404 pAdapter->SharedKey[BSS0][3].KeyLen = KeyLen / 2 ;
6405 AtoH(arg, pAdapter->SharedKey[BSS0][3].Key, KeyLen / 2);
6406 CipherAlg = CIPHER_WEP128;
6407 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key4_Proc::(Key4=%s and type=%s)\n", arg, "Hex"));
6409 default: //Invalid argument
6410 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key4_Proc::Invalid argument (=%s)\n", arg));
6413 pAdapter->SharedKey[BSS0][3].CipherAlg = CipherAlg;
6415 // Set keys (into ASIC)
6416 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
6418 else // Old WEP stuff
6420 AsicAddSharedKeyEntry(pAdapter,
6423 pAdapter->SharedKey[BSS0][3].CipherAlg,
6424 pAdapter->SharedKey[BSS0][3].Key,
6433 ==========================================================================
6437 TRUE if all parameters are OK, FALSE otherwise
6438 ==========================================================================
6440 INT Set_WPAPSK_Proc(
6441 IN PRTMP_ADAPTER pAdapter,
6444 UCHAR keyMaterial[40];
6446 if ((pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPAPSK) &&
6447 (pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPA2PSK) &&
6448 (pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPANone)
6450 return TRUE; // do nothing
6452 DBGPRINT(RT_DEBUG_TRACE, ("Set_WPAPSK_Proc::(WPAPSK=%s)\n", arg));
6454 NdisZeroMemory(keyMaterial, 40);
6456 if ((strlen(arg) < 8) || (strlen(arg) > 64))
6458 DBGPRINT(RT_DEBUG_TRACE, ("Set failed!!(WPAPSK=%s), WPAPSK key-string required 8 ~ 64 characters \n", arg));
6462 if (strlen(arg) == 64)
6464 AtoH(arg, keyMaterial, 32);
6465 NdisMoveMemory(pAdapter->StaCfg.PMK, keyMaterial, 32);
6470 PasswordHash((char *)arg, pAdapter->MlmeAux.Ssid, pAdapter->MlmeAux.SsidLen, keyMaterial);
6471 NdisMoveMemory(pAdapter->StaCfg.PMK, keyMaterial, 32);
6476 if(pAdapter->StaCfg.BssType == BSS_ADHOC &&
6477 pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPANone)
6479 pAdapter->StaCfg.WpaState = SS_NOTUSE;
6483 // Start STA supplicant state machine
6484 pAdapter->StaCfg.WpaState = SS_START;
6491 ==========================================================================
6493 Set Power Saving mode
6495 TRUE if all parameters are OK, FALSE otherwise
6496 ==========================================================================
6498 INT Set_PSMode_Proc(
6499 IN PRTMP_ADAPTER pAdapter,
6502 if (pAdapter->StaCfg.BssType == BSS_INFRA)
6504 if ((strcmp(arg, "Max_PSP") == 0) ||
6505 (strcmp(arg, "max_psp") == 0) ||
6506 (strcmp(arg, "MAX_PSP") == 0))
6508 // do NOT turn on PSM bit here, wait until MlmeCheckForPsmChange()
6509 // to exclude certain situations.
6510 if (pAdapter->StaCfg.bWindowsACCAMEnable == FALSE)
6511 pAdapter->StaCfg.WindowsPowerMode = Ndis802_11PowerModeMAX_PSP;
6512 pAdapter->StaCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeMAX_PSP;
6513 OPSTATUS_SET_FLAG(pAdapter, fOP_STATUS_RECEIVE_DTIM);
6514 pAdapter->StaCfg.DefaultListenCount = 5;
6517 else if ((strcmp(arg, "Fast_PSP") == 0) ||
6518 (strcmp(arg, "fast_psp") == 0) ||
6519 (strcmp(arg, "FAST_PSP") == 0))
6521 // do NOT turn on PSM bit here, wait until MlmeCheckForPsmChange()
6522 // to exclude certain situations.
6523 OPSTATUS_SET_FLAG(pAdapter, fOP_STATUS_RECEIVE_DTIM);
6524 if (pAdapter->StaCfg.bWindowsACCAMEnable == FALSE)
6525 pAdapter->StaCfg.WindowsPowerMode = Ndis802_11PowerModeFast_PSP;
6526 pAdapter->StaCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeFast_PSP;
6527 pAdapter->StaCfg.DefaultListenCount = 3;
6529 else if ((strcmp(arg, "Legacy_PSP") == 0) ||
6530 (strcmp(arg, "legacy_psp") == 0) ||
6531 (strcmp(arg, "LEGACY_PSP") == 0))
6533 // do NOT turn on PSM bit here, wait until MlmeCheckForPsmChange()
6534 // to exclude certain situations.
6535 OPSTATUS_SET_FLAG(pAdapter, fOP_STATUS_RECEIVE_DTIM);
6536 if (pAdapter->StaCfg.bWindowsACCAMEnable == FALSE)
6537 pAdapter->StaCfg.WindowsPowerMode = Ndis802_11PowerModeLegacy_PSP;
6538 pAdapter->StaCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeLegacy_PSP;
6539 pAdapter->StaCfg.DefaultListenCount = 3;
6543 //Default Ndis802_11PowerModeCAM
6544 // clear PSM bit immediately
6545 MlmeSetPsmBit(pAdapter, PWR_ACTIVE);
6546 OPSTATUS_SET_FLAG(pAdapter, fOP_STATUS_RECEIVE_DTIM);
6547 if (pAdapter->StaCfg.bWindowsACCAMEnable == FALSE)
6548 pAdapter->StaCfg.WindowsPowerMode = Ndis802_11PowerModeCAM;
6549 pAdapter->StaCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeCAM;
6552 DBGPRINT(RT_DEBUG_TRACE, ("Set_PSMode_Proc::(PSMode=%ld)\n", pAdapter->StaCfg.WindowsPowerMode));
6561 #ifdef WPA_SUPPLICANT_SUPPORT
6563 ==========================================================================
6565 Set WpaSupport flag.
6567 0: Driver ignore wpa_supplicant.
6568 1: wpa_supplicant initiates scanning and AP selection.
6569 2: driver takes care of scanning, AP selection, and IEEE 802.11 association parameters.
6571 TRUE if all parameters are OK, FALSE otherwise
6572 ==========================================================================
6574 INT Set_Wpa_Support(
6575 IN PRTMP_ADAPTER pAd,
6579 if ( simple_strtol(arg, 0, 10) == 0)
6580 pAd->StaCfg.WpaSupplicantUP = WPA_SUPPLICANT_DISABLE;
6581 else if ( simple_strtol(arg, 0, 10) == 1)
6582 pAd->StaCfg.WpaSupplicantUP = WPA_SUPPLICANT_ENABLE;
6583 else if ( simple_strtol(arg, 0, 10) == 2)
6584 pAd->StaCfg.WpaSupplicantUP = WPA_SUPPLICANT_ENABLE_WITH_WEB_UI;
6586 pAd->StaCfg.WpaSupplicantUP = WPA_SUPPLICANT_DISABLE;
6588 DBGPRINT(RT_DEBUG_TRACE, ("Set_Wpa_Support::(WpaSupplicantUP=%d)\n", pAd->StaCfg.WpaSupplicantUP));
6592 #endif // WPA_SUPPLICANT_SUPPORT //
6596 ==========================================================================
6600 pAdapter Pointer to our adapter
6601 wrq Pointer to the ioctl argument
6608 1.) iwpriv ra0 mac 0 ==> read MAC where Addr=0x0
6609 2.) iwpriv ra0 mac 0=12 ==> write MAC where Addr=0x0, value=12
6610 ==========================================================================
6613 IN PRTMP_ADAPTER pAdapter,
6614 IN struct iwreq *wrq)
6622 UCHAR temp[16], temp2[16];
6623 UINT32 macValue = 0;
6627 memset(msg, 0x00, 1024);
6628 if (wrq->u.data.length > 1) //No parameters.
6630 Status = copy_from_user(arg, wrq->u.data.pointer, (wrq->u.data.length > 255) ? 255 : wrq->u.data.length);
6633 //Parsing Read or Write
6638 if ((value = rtstrchr(this_char, '=')) != NULL)
6641 if (!value || !*value)
6644 if(strlen(this_char) > 4)
6647 j = strlen(this_char);
6650 if(this_char[j] > 'f' || this_char[j] < '0')
6655 k = j = strlen(this_char);
6658 this_char[4-k+j] = this_char[j];
6662 this_char[3-k++]='0';
6665 if(strlen(this_char) == 4)
6667 AtoH(this_char, temp, 2);
6668 macAddr = *temp*256 + temp[1];
6669 if (macAddr < 0xFFFF)
6671 RTMP_IO_READ32(pAdapter, macAddr, &macValue);
6672 DBGPRINT(RT_DEBUG_TRACE, ("MacAddr=%lx, MacValue=%x\n", macAddr, macValue));
6673 sprintf(msg+strlen(msg), "[0x%08lX]:%08X ", macAddr , macValue);
6676 {//Invalid parametes, so default printk all bbp
6683 memcpy(&temp2, value, strlen(value));
6684 temp2[strlen(value)] = '\0';
6687 if((strlen(this_char) > 4) || strlen(temp2) > 8)
6690 j = strlen(this_char);
6693 if(this_char[j] > 'f' || this_char[j] < '0')
6700 if(temp2[j] > 'f' || temp2[j] < '0')
6705 k = j = strlen(this_char);
6708 this_char[4-k+j] = this_char[j];
6712 this_char[3-k++]='0';
6716 k = j = strlen(temp2);
6719 temp2[8-k+j] = temp2[j];
6727 AtoH(this_char, temp, 2);
6728 macAddr = *temp*256 + temp[1];
6730 AtoH(temp2, temp, 4);
6731 macValue = *temp*256*256*256 + temp[1]*256*256 + temp[2]*256 + temp[3];
6734 if (macAddr == (HW_DEBUG_SETTING_BASE + 4))
6736 // 0x2bf4: byte0 non-zero: enable R17 tuning, 0: disable R17 tuning
6737 if (macValue & 0x000000ff)
6739 pAdapter->BbpTuning.bEnable = TRUE;
6740 DBGPRINT(RT_DEBUG_TRACE,("turn on R17 tuning\n"));
6745 pAdapter->BbpTuning.bEnable = FALSE;
6746 R66 = 0x26 + GET_LNA_GAIN(pAdapter);
6748 if (ATE_ON(pAdapter))
6750 ATE_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R66, (0x26 + GET_LNA_GAIN(pAdapter)));
6753 #endif // RALINK_ATE //
6754 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R66, (0x26 + GET_LNA_GAIN(pAdapter)));
6755 DBGPRINT(RT_DEBUG_TRACE,("turn off R17 tuning, restore to 0x%02x\n", R66));
6760 DBGPRINT(RT_DEBUG_TRACE, ("MacAddr=%02lx, MacValue=0x%x\n", macAddr, macValue));
6762 RTMP_IO_WRITE32(pAdapter, macAddr, macValue);
6763 sprintf(msg+strlen(msg), "[0x%08lX]:%08X ", macAddr, macValue);
6768 if(strlen(msg) == 1)
6769 sprintf(msg+strlen(msg), "===>Error command format!");
6771 // Copy the information into the user buffer
6772 wrq->u.data.length = strlen(msg);
6773 Status = copy_to_user(wrq->u.data.pointer, msg, wrq->u.data.length);
6775 DBGPRINT(RT_DEBUG_TRACE, ("<==RTMPIoctlMAC\n\n"));
6779 ==========================================================================
6783 pAdapter Pointer to our adapter
6784 wrq Pointer to the ioctl argument
6791 1.) iwpriv ra0 e2p 0 ==> read E2PROM where Addr=0x0
6792 2.) iwpriv ra0 e2p 0=1234 ==> write E2PROM where Addr=0x0, value=1234
6793 ==========================================================================
6795 VOID RTMPIoctlE2PROM(
6796 IN PRTMP_ADAPTER pAdapter,
6797 IN struct iwreq *wrq)
6805 UCHAR temp[16], temp2[16];
6810 memset(msg, 0x00, 1024);
6811 if (wrq->u.data.length > 1) //No parameters.
6813 Status = copy_from_user(arg, wrq->u.data.pointer, (wrq->u.data.length > 255) ? 255 : wrq->u.data.length);
6816 //Parsing Read or Write
6823 if ((value = rtstrchr(this_char, '=')) != NULL)
6826 if (!value || !*value)
6830 if(strlen(this_char) > 4)
6833 j = strlen(this_char);
6836 if(this_char[j] > 'f' || this_char[j] < '0')
6841 k = j = strlen(this_char);
6844 this_char[4-k+j] = this_char[j];
6848 this_char[3-k++]='0';
6851 if(strlen(this_char) == 4)
6853 AtoH(this_char, temp, 2);
6854 eepAddr = *temp*256 + temp[1];
6855 if (eepAddr < 0xFFFF)
6857 RT28xx_EEPROM_READ16(pAdapter, eepAddr, eepValue);
6858 sprintf(msg+strlen(msg), "[0x%04X]:0x%04X ", eepAddr , eepValue);
6861 {//Invalid parametes, so default printk all bbp
6868 memcpy(&temp2, value, strlen(value));
6869 temp2[strlen(value)] = '\0';
6872 if((strlen(this_char) > 4) || strlen(temp2) > 8)
6875 j = strlen(this_char);
6878 if(this_char[j] > 'f' || this_char[j] < '0')
6884 if(temp2[j] > 'f' || temp2[j] < '0')
6889 k = j = strlen(this_char);
6892 this_char[4-k+j] = this_char[j];
6896 this_char[3-k++]='0';
6900 k = j = strlen(temp2);
6903 temp2[4-k+j] = temp2[j];
6910 AtoH(this_char, temp, 2);
6911 eepAddr = *temp*256 + temp[1];
6913 AtoH(temp2, temp, 2);
6914 eepValue = *temp*256 + temp[1];
6916 RT28xx_EEPROM_WRITE16(pAdapter, eepAddr, eepValue);
6917 sprintf(msg+strlen(msg), "[0x%02X]:%02X ", eepAddr, eepValue);
6921 if(strlen(msg) == 1)
6922 sprintf(msg+strlen(msg), "===>Error command format!");
6925 // Copy the information into the user buffer
6926 wrq->u.data.length = strlen(msg);
6927 Status = copy_to_user(wrq->u.data.pointer, msg, wrq->u.data.length);
6929 DBGPRINT(RT_DEBUG_TRACE, ("<==RTMPIoctlE2PROM\n"));
6936 INT Set_TGnWifiTest_Proc(
6937 IN PRTMP_ADAPTER pAd,
6940 if (simple_strtol(arg, 0, 10) == 0)
6941 pAd->StaCfg.bTGnWifiTest = FALSE;
6943 pAd->StaCfg.bTGnWifiTest = TRUE;
6945 DBGPRINT(RT_DEBUG_TRACE, ("IF Set_TGnWifiTest_Proc::(bTGnWifiTest=%d)\n", pAd->StaCfg.bTGnWifiTest));
6949 INT Set_LongRetryLimit_Proc(
6950 IN PRTMP_ADAPTER pAdapter,
6953 TX_RTY_CFG_STRUC tx_rty_cfg;
6954 UCHAR LongRetryLimit = (UCHAR)simple_strtol(arg, 0, 10);
6956 RTMP_IO_READ32(pAdapter, TX_RTY_CFG, &tx_rty_cfg.word);
6957 tx_rty_cfg.field.LongRtyLimit = LongRetryLimit;
6958 RTMP_IO_WRITE32(pAdapter, TX_RTY_CFG, tx_rty_cfg.word);
6959 DBGPRINT(RT_DEBUG_TRACE, ("IF Set_LongRetryLimit_Proc::(tx_rty_cfg=0x%x)\n", tx_rty_cfg.word));
6963 INT Set_ShortRetryLimit_Proc(
6964 IN PRTMP_ADAPTER pAdapter,
6967 TX_RTY_CFG_STRUC tx_rty_cfg;
6968 UCHAR ShortRetryLimit = (UCHAR)simple_strtol(arg, 0, 10);
6970 RTMP_IO_READ32(pAdapter, TX_RTY_CFG, &tx_rty_cfg.word);
6971 tx_rty_cfg.field.ShortRtyLimit = ShortRetryLimit;
6972 RTMP_IO_WRITE32(pAdapter, TX_RTY_CFG, tx_rty_cfg.word);
6973 DBGPRINT(RT_DEBUG_TRACE, ("IF Set_ShortRetryLimit_Proc::(tx_rty_cfg=0x%x)\n", tx_rty_cfg.word));
6977 #ifdef EXT_BUILD_CHANNEL_LIST
6978 INT Set_Ieee80211dClientMode_Proc(
6979 IN PRTMP_ADAPTER pAdapter,
6982 if (simple_strtol(arg, 0, 10) == 0)
6983 pAdapter->StaCfg.IEEE80211dClientMode = Rt802_11_D_None;
6984 else if (simple_strtol(arg, 0, 10) == 1)
6985 pAdapter->StaCfg.IEEE80211dClientMode = Rt802_11_D_Flexible;
6986 else if (simple_strtol(arg, 0, 10) == 2)
6987 pAdapter->StaCfg.IEEE80211dClientMode = Rt802_11_D_Strict;
6991 DBGPRINT(RT_DEBUG_TRACE, ("Set_Ieee802dMode_Proc::(IEEEE0211dMode=%d)\n", pAdapter->StaCfg.IEEE80211dClientMode));
6994 #endif // EXT_BUILD_CHANNEL_LIST //
6996 #ifdef CARRIER_DETECTION_SUPPORT
6997 INT Set_CarrierDetect_Proc(
6998 IN PRTMP_ADAPTER pAd,
7001 if (simple_strtol(arg, 0, 10) == 0)
7002 pAd->CommonCfg.CarrierDetect.Enable = FALSE;
7004 pAd->CommonCfg.CarrierDetect.Enable = TRUE;
7006 DBGPRINT(RT_DEBUG_TRACE, ("IF Set_CarrierDetect_Proc::(CarrierDetect.Enable=%d)\n", pAd->CommonCfg.CarrierDetect.Enable));
7009 #endif // CARRIER_DETECTION_SUPPORT //
7012 INT Show_Adhoc_MacTable_Proc(
7013 IN PRTMP_ADAPTER pAd,
7018 sprintf(extra, "\n");
7020 #ifdef DOT11_N_SUPPORT
7021 sprintf(extra + strlen(extra), "HT Operating Mode : %d\n", pAd->CommonCfg.AddHTInfo.AddHtInfo2.OperaionMode);
7022 #endif // DOT11_N_SUPPORT //
7024 sprintf(extra + strlen(extra), "\n%-19s%-4s%-4s%-7s%-7s%-7s%-10s%-6s%-6s%-6s%-6s\n",
7025 "MAC", "AID", "BSS", "RSSI0", "RSSI1", "RSSI2", "PhMd", "BW", "MCS", "SGI", "STBC");
7027 for (i=1; i<MAX_LEN_OF_MAC_TABLE; i++)
7029 PMAC_TABLE_ENTRY pEntry = &pAd->MacTab.Content[i];
7031 if (strlen(extra) > (IW_PRIV_SIZE_MASK - 30))
7033 if ((pEntry->ValidAsCLI || pEntry->ValidAsApCli) && (pEntry->Sst == SST_ASSOC))
7035 sprintf(extra + strlen(extra), "%02X:%02X:%02X:%02X:%02X:%02X ",
7036 pEntry->Addr[0], pEntry->Addr[1], pEntry->Addr[2],
7037 pEntry->Addr[3], pEntry->Addr[4], pEntry->Addr[5]);
7038 sprintf(extra + strlen(extra), "%-4d", (int)pEntry->Aid);
7039 sprintf(extra + strlen(extra), "%-4d", (int)pEntry->apidx);
7040 sprintf(extra + strlen(extra), "%-7d", pEntry->RssiSample.AvgRssi0);
7041 sprintf(extra + strlen(extra), "%-7d", pEntry->RssiSample.AvgRssi1);
7042 sprintf(extra + strlen(extra), "%-7d", pEntry->RssiSample.AvgRssi2);
7043 sprintf(extra + strlen(extra), "%-10s", GetPhyMode(pEntry->HTPhyMode.field.MODE));
7044 sprintf(extra + strlen(extra), "%-6s", GetBW(pEntry->HTPhyMode.field.BW));
7045 sprintf(extra + strlen(extra), "%-6d", pEntry->HTPhyMode.field.MCS);
7046 sprintf(extra + strlen(extra), "%-6d", pEntry->HTPhyMode.field.ShortGI);
7047 sprintf(extra + strlen(extra), "%-6d", pEntry->HTPhyMode.field.STBC);
7048 sprintf(extra + strlen(extra), "%-10d, %d, %d%%\n", pEntry->DebugFIFOCount, pEntry->DebugTxCount,
7049 (pEntry->DebugTxCount) ? ((pEntry->DebugTxCount-pEntry->DebugFIFOCount)*100/pEntry->DebugTxCount) : 0);
7050 sprintf(extra, "%s\n", extra);