2 *************************************************************************
4 * 5F., No.36, Taiyuan St., Jhubei City,
8 * (c) Copyright 2002-2007, Ralink Technology, Inc.
10 * This program is free software; you can redistribute it and/or modify *
11 * it under the terms of the GNU General Public License as published by *
12 * the Free Software Foundation; either version 2 of the License, or *
13 * (at your option) any later version. *
15 * This program is distributed in the hope that it will be useful, *
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
18 * GNU General Public License for more details. *
20 * You should have received a copy of the GNU General Public License *
21 * along with this program; if not, write to the *
22 * Free Software Foundation, Inc., *
23 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
25 *************************************************************************
31 IOCTL related subroutines
35 -------- ---------- ----------------------------------------------
36 Rory Chen 01-03-2003 created
37 Rory Chen 02-14-2005 modify to support RT61
40 #include "rt_config.h"
43 extern ULONG RTDebugLevel;
47 #define WEP_SMALL_KEY_LEN (40/8)
48 #define WEP_LARGE_KEY_LEN (104/8)
50 #define GROUP_KEY_NO 4
52 extern UCHAR CipherWpa2Template[];
53 extern UCHAR CipherWpaPskTkip[];
54 extern UCHAR CipherWpaPskTkipLen;
56 typedef struct PACKED _RT_VERSION_INFO{
62 UINT DriverBuildMonth;
64 } RT_VERSION_INFO, *PRT_VERSION_INFO;
66 struct iw_priv_args privtab[] = {
68 IW_PRIV_TYPE_CHAR | 1024, 0,
71 { RTPRIV_IOCTL_SHOW, 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK,
73 { RTPRIV_IOCTL_SHOW, IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK,
75 /* --- sub-ioctls definitions --- */
77 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "connStatus" },
79 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "driverVer" },
81 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "bainfo" },
83 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "descinfo" },
85 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "radio_off" },
87 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "radio_on" },
88 #ifdef QOS_DLS_SUPPORT
89 { SHOW_DLS_ENTRY_INFO,
90 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "dlsentryinfo" },
91 #endif // QOS_DLS_SUPPORT //
93 IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "show" },
94 /* --- sub-ioctls relations --- */
98 IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK,
101 IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | 1024,
105 IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK,
109 IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | 1024,
113 { RTPRIV_IOCTL_STATISTICS,
114 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK,
116 { RTPRIV_IOCTL_GSITESURVEY,
117 0, IW_PRIV_TYPE_CHAR | 1024,
124 IN PRTMP_ADAPTER pAdapter,
128 INT Set_WmmCapable_Proc(
129 IN PRTMP_ADAPTER pAd,
133 INT Set_NetworkType_Proc(
134 IN PRTMP_ADAPTER pAdapter,
137 INT Set_AuthMode_Proc(
138 IN PRTMP_ADAPTER pAdapter,
141 INT Set_EncrypType_Proc(
142 IN PRTMP_ADAPTER pAdapter,
145 INT Set_DefaultKeyID_Proc(
146 IN PRTMP_ADAPTER pAdapter,
150 IN PRTMP_ADAPTER pAdapter,
154 IN PRTMP_ADAPTER pAdapter,
158 IN PRTMP_ADAPTER pAdapter,
162 IN PRTMP_ADAPTER pAdapter,
166 IN PRTMP_ADAPTER pAdapter,
171 IN PRTMP_ADAPTER pAdapter,
174 #ifdef WPA_SUPPLICANT_SUPPORT
176 IN PRTMP_ADAPTER pAd,
178 #endif // WPA_SUPPLICANT_SUPPORT //
183 IN PRTMP_ADAPTER pAdapter,
184 IN struct iwreq *wrq);
186 VOID RTMPIoctlE2PROM(
187 IN PRTMP_ADAPTER pAdapter,
188 IN struct iwreq *wrq);
192 IN PRTMP_ADAPTER pAdapter,
193 IN struct iwreq *wrq);
198 NDIS_STATUS RTMPWPANoneAddKeyProc(
199 IN PRTMP_ADAPTER pAd,
202 INT Set_FragTest_Proc(
203 IN PRTMP_ADAPTER pAdapter,
206 #ifdef DOT11_N_SUPPORT
207 INT Set_TGnWifiTest_Proc(
208 IN PRTMP_ADAPTER pAd,
210 #endif // DOT11_N_SUPPORT //
212 INT Set_LongRetryLimit_Proc(
213 IN PRTMP_ADAPTER pAdapter,
216 INT Set_ShortRetryLimit_Proc(
217 IN PRTMP_ADAPTER pAdapter,
220 #ifdef EXT_BUILD_CHANNEL_LIST
221 INT Set_Ieee80211dClientMode_Proc(
222 IN PRTMP_ADAPTER pAdapter,
224 #endif // EXT_BUILD_CHANNEL_LIST //
228 INT (*set_proc)(PRTMP_ADAPTER pAdapter, PUCHAR arg);
229 } *PRTMP_PRIVATE_SET_PROC, RTMP_PRIVATE_SUPPORT_PROC[] = {
230 {"DriverVersion", Set_DriverVersion_Proc},
231 {"CountryRegion", Set_CountryRegion_Proc},
232 {"CountryRegionABand", Set_CountryRegionABand_Proc},
233 {"SSID", Set_SSID_Proc},
234 {"WirelessMode", Set_WirelessMode_Proc},
235 {"TxBurst", Set_TxBurst_Proc},
236 {"TxPreamble", Set_TxPreamble_Proc},
237 {"TxPower", Set_TxPower_Proc},
238 {"Channel", Set_Channel_Proc},
239 {"BGProtection", Set_BGProtection_Proc},
240 {"RTSThreshold", Set_RTSThreshold_Proc},
241 {"FragThreshold", Set_FragThreshold_Proc},
242 #ifdef DOT11_N_SUPPORT
243 {"HtBw", Set_HtBw_Proc},
244 {"HtMcs", Set_HtMcs_Proc},
245 {"HtGi", Set_HtGi_Proc},
246 {"HtOpMode", Set_HtOpMode_Proc},
247 {"HtExtcha", Set_HtExtcha_Proc},
248 {"HtMpduDensity", Set_HtMpduDensity_Proc},
249 {"HtBaWinSize", Set_HtBaWinSize_Proc},
250 {"HtRdg", Set_HtRdg_Proc},
251 {"HtAmsdu", Set_HtAmsdu_Proc},
252 {"HtAutoBa", Set_HtAutoBa_Proc},
253 {"HtBaDecline", Set_BADecline_Proc},
254 {"HtProtect", Set_HtProtect_Proc},
255 {"HtMimoPs", Set_HtMimoPs_Proc},
256 #endif // DOT11_N_SUPPORT //
258 #ifdef AGGREGATION_SUPPORT
259 {"PktAggregate", Set_PktAggregate_Proc},
263 {"WmmCapable", Set_WmmCapable_Proc},
265 {"IEEE80211H", Set_IEEE80211H_Proc},
266 {"NetworkType", Set_NetworkType_Proc},
267 {"AuthMode", Set_AuthMode_Proc},
268 {"EncrypType", Set_EncrypType_Proc},
269 {"DefaultKeyID", Set_DefaultKeyID_Proc},
270 {"Key1", Set_Key1_Proc},
271 {"Key2", Set_Key2_Proc},
272 {"Key3", Set_Key3_Proc},
273 {"Key4", Set_Key4_Proc},
274 {"WPAPSK", Set_WPAPSK_Proc},
275 {"ResetCounter", Set_ResetStatCounter_Proc},
276 {"PSMode", Set_PSMode_Proc},
278 {"Debug", Set_Debug_Proc},
281 #ifdef WPA_SUPPLICANT_SUPPORT
282 {"WpaSupport", Set_Wpa_Support},
283 #endif // WPA_SUPPLICANT_SUPPORT //
287 {"FixedTxMode", Set_FixedTxMode_Proc},
288 #ifdef DOT11_N_SUPPORT
289 {"TGnWifiTest", Set_TGnWifiTest_Proc},
290 {"ForceGF", Set_ForceGF_Proc},
291 #endif // DOT11_N_SUPPORT //
292 #ifdef QOS_DLS_SUPPORT
293 {"DlsAddEntry", Set_DlsAddEntry_Proc},
294 {"DlsTearDownEntry", Set_DlsTearDownEntry_Proc},
295 #endif // QOS_DLS_SUPPORT //
296 {"LongRetry", Set_LongRetryLimit_Proc},
297 {"ShortRetry", Set_ShortRetryLimit_Proc},
298 #ifdef EXT_BUILD_CHANNEL_LIST
299 {"11dClientMode", Set_Ieee80211dClientMode_Proc},
300 #endif // EXT_BUILD_CHANNEL_LIST //
301 //2008/09/11:KH add to support efuse<--
303 {"efuseFreeNumber", set_eFuseGetFreeBlockCount_Proc},
304 {"efuseDump", set_eFusedump_Proc},
305 {"efuseLoadFromBin", set_eFuseLoadFromBin_Proc},
307 //2008/09/11:KH add to support efuse-->
313 IN PRTMP_ADAPTER pAd,
314 IN PNDIS_802_11_KEY pKey)
317 MAC_TABLE_ENTRY *pEntry;
319 DBGPRINT(RT_DEBUG_TRACE, ("RTMPAddKey ------>\n"));
321 if (pAd->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
323 if (pKey->KeyIndex & 0x80000000)
325 if (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPANone)
327 NdisZeroMemory(pAd->StaCfg.PMK, 32);
328 NdisMoveMemory(pAd->StaCfg.PMK, pKey->KeyMaterial, pKey->KeyLength);
332 NdisZeroMemory(&pAd->SharedKey[BSS0][0], sizeof(CIPHER_KEY));
333 pAd->SharedKey[BSS0][0].KeyLen = LEN_TKIP_EK;
334 NdisMoveMemory(pAd->SharedKey[BSS0][0].Key, pKey->KeyMaterial, LEN_TKIP_EK);
335 #ifdef WPA_SUPPLICANT_SUPPORT
336 if (pAd->StaCfg.PairCipher == Ndis802_11Encryption2Enabled)
338 NdisMoveMemory(pAd->SharedKey[BSS0][0].RxMic, pKey->KeyMaterial + LEN_TKIP_EK, LEN_TKIP_TXMICK);
339 NdisMoveMemory(pAd->SharedKey[BSS0][0].TxMic, pKey->KeyMaterial + LEN_TKIP_EK + LEN_TKIP_TXMICK, LEN_TKIP_RXMICK);
342 #endif // WPA_SUPPLICANT_SUPPORT //
344 NdisMoveMemory(pAd->SharedKey[BSS0][0].TxMic, pKey->KeyMaterial + LEN_TKIP_EK, LEN_TKIP_TXMICK);
345 NdisMoveMemory(pAd->SharedKey[BSS0][0].RxMic, pKey->KeyMaterial + LEN_TKIP_EK + LEN_TKIP_TXMICK, LEN_TKIP_RXMICK);
348 // Decide its ChiperAlg
349 if (pAd->StaCfg.PairCipher == Ndis802_11Encryption2Enabled)
350 pAd->SharedKey[BSS0][0].CipherAlg = CIPHER_TKIP;
351 else if (pAd->StaCfg.PairCipher == Ndis802_11Encryption3Enabled)
352 pAd->SharedKey[BSS0][0].CipherAlg = CIPHER_AES;
354 pAd->SharedKey[BSS0][0].CipherAlg = CIPHER_NONE;
356 // Update these related information to MAC_TABLE_ENTRY
357 pEntry = &pAd->MacTab.Content[BSSID_WCID];
358 NdisMoveMemory(pEntry->PairwiseKey.Key, pAd->SharedKey[BSS0][0].Key, LEN_TKIP_EK);
359 NdisMoveMemory(pEntry->PairwiseKey.RxMic, pAd->SharedKey[BSS0][0].RxMic, LEN_TKIP_RXMICK);
360 NdisMoveMemory(pEntry->PairwiseKey.TxMic, pAd->SharedKey[BSS0][0].TxMic, LEN_TKIP_TXMICK);
361 pEntry->PairwiseKey.CipherAlg = pAd->SharedKey[BSS0][0].CipherAlg;
363 // Update pairwise key information to ASIC Shared Key Table
364 AsicAddSharedKeyEntry(pAd,
367 pAd->SharedKey[BSS0][0].CipherAlg,
368 pAd->SharedKey[BSS0][0].Key,
369 pAd->SharedKey[BSS0][0].TxMic,
370 pAd->SharedKey[BSS0][0].RxMic);
372 // Update ASIC WCID attribute table and IVEIV table
373 RTMPAddWcidAttributeEntry(pAd,
376 pAd->SharedKey[BSS0][0].CipherAlg,
379 if (pAd->StaCfg.AuthMode >= Ndis802_11AuthModeWPA2)
381 // set 802.1x port control
382 //pAd->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
383 STA_PORT_SECURED(pAd);
385 // Indicate Connected for GUI
386 pAd->IndicateMediaState = NdisMediaStateConnected;
392 pAd->StaCfg.DefaultKeyId = (pKey->KeyIndex & 0xFF);
393 NdisZeroMemory(&pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId], sizeof(CIPHER_KEY));
394 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].KeyLen = LEN_TKIP_EK;
395 NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].Key, pKey->KeyMaterial, LEN_TKIP_EK);
396 #ifdef WPA_SUPPLICANT_SUPPORT
397 if (pAd->StaCfg.GroupCipher == Ndis802_11Encryption2Enabled)
399 NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].RxMic, pKey->KeyMaterial + LEN_TKIP_EK, LEN_TKIP_TXMICK);
400 NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].TxMic, pKey->KeyMaterial + LEN_TKIP_EK + LEN_TKIP_TXMICK, LEN_TKIP_RXMICK);
403 #endif // WPA_SUPPLICANT_SUPPORT //
405 NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].TxMic, pKey->KeyMaterial + LEN_TKIP_EK, LEN_TKIP_TXMICK);
406 NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].RxMic, pKey->KeyMaterial + LEN_TKIP_EK + LEN_TKIP_TXMICK, LEN_TKIP_RXMICK);
409 // Update Shared Key CipherAlg
410 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg = CIPHER_NONE;
411 if (pAd->StaCfg.GroupCipher == Ndis802_11Encryption2Enabled)
412 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg = CIPHER_TKIP;
413 else if (pAd->StaCfg.GroupCipher == Ndis802_11Encryption3Enabled)
414 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg = CIPHER_AES;
416 // Update group key information to ASIC Shared Key Table
417 AsicAddSharedKeyEntry(pAd,
419 pAd->StaCfg.DefaultKeyId,
420 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg,
421 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].Key,
422 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].TxMic,
423 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].RxMic);
425 // Update ASIC WCID attribute table and IVEIV table
426 RTMPAddWcidAttributeEntry(pAd,
428 pAd->StaCfg.DefaultKeyId,
429 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg,
432 // set 802.1x port control
433 //pAd->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
434 STA_PORT_SECURED(pAd);
436 // Indicate Connected for GUI
437 pAd->IndicateMediaState = NdisMediaStateConnected;
440 else // dynamic WEP from wpa_supplicant
445 if(pKey->KeyLength == 32)
448 KeyIdx = pKey->KeyIndex & 0x0fffffff;
452 // it is a default shared key, for Pairwise key setting
453 if (pKey->KeyIndex & 0x80000000)
455 pEntry = MacTableLookup(pAd, pKey->BSSID);
459 DBGPRINT(RT_DEBUG_TRACE, ("RTMPAddKey: Set Pair-wise Key\n"));
461 // set key material and key length
462 pEntry->PairwiseKey.KeyLen = (UCHAR)pKey->KeyLength;
463 NdisMoveMemory(pEntry->PairwiseKey.Key, &pKey->KeyMaterial, pKey->KeyLength);
466 if (pKey->KeyLength == 5)
467 pEntry->PairwiseKey.CipherAlg = CIPHER_WEP64;
469 pEntry->PairwiseKey.CipherAlg = CIPHER_WEP128;
471 // Add Pair-wise key to Asic
472 AsicAddPairwiseKeyEntry(
476 &pEntry->PairwiseKey);
478 // update WCID attribute table and IVEIV table for this entry
479 RTMPAddWcidAttributeEntry(
482 KeyIdx, // The value may be not zero
483 pEntry->PairwiseKey.CipherAlg,
490 // Default key for tx (shared key)
491 pAd->StaCfg.DefaultKeyId = (UCHAR) KeyIdx;
493 // set key material and key length
494 pAd->SharedKey[BSS0][KeyIdx].KeyLen = (UCHAR) pKey->KeyLength;
495 NdisMoveMemory(pAd->SharedKey[BSS0][KeyIdx].Key, &pKey->KeyMaterial, pKey->KeyLength);
498 if (pKey->KeyLength == 5)
499 pAd->SharedKey[BSS0][KeyIdx].CipherAlg = CIPHER_WEP64;
501 pAd->SharedKey[BSS0][KeyIdx].CipherAlg = CIPHER_WEP128;
503 CipherAlg = pAd->SharedKey[BSS0][KeyIdx].CipherAlg;
504 Key = pAd->SharedKey[BSS0][KeyIdx].Key;
506 // Set Group key material to Asic
507 AsicAddSharedKeyEntry(pAd, BSS0, KeyIdx, CipherAlg, Key, NULL, NULL);
509 // Update WCID attribute table and IVEIV table for this group key table
510 RTMPAddWcidAttributeEntry(pAd, BSS0, KeyIdx, CipherAlg, NULL);
519 char * rtstrchr(const char * s, int c)
521 for(; *s != (char) c; ++s)
528 This is required for LinEX2004/kernel2.6.7 to provide iwlist scanning function
532 rt_ioctl_giwname(struct net_device *dev,
533 struct iw_request_info *info,
534 char *name, char *extra)
536 // PRTMP_ADAPTER pAdapter = dev->ml_priv;
539 strncpy(name, "RT2870 Wireless", IFNAMSIZ);
544 int rt_ioctl_siwfreq(struct net_device *dev,
545 struct iw_request_info *info,
546 struct iw_freq *freq, char *extra)
548 PRTMP_ADAPTER pAdapter = dev->ml_priv;
551 //check if the interface is down
552 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
554 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
562 if((freq->e == 0) && (freq->m <= 1000))
563 chan = freq->m; // Setting by channel number
565 MAP_KHZ_TO_CHANNEL_ID( (freq->m /100) , chan); // Setting by frequency - search the table , like 2.412G, 2.422G,
567 if (ChannelSanity(pAdapter, chan) == TRUE)
569 pAdapter->CommonCfg.Channel = chan;
570 DBGPRINT(RT_DEBUG_ERROR, ("==>rt_ioctl_siwfreq::SIOCSIWFREQ[cmd=0x%x] (Channel=%d)\n", SIOCSIWFREQ, pAdapter->CommonCfg.Channel));
577 int rt_ioctl_giwfreq(struct net_device *dev,
578 struct iw_request_info *info,
579 struct iw_freq *freq, char *extra)
581 VIRTUAL_ADAPTER *pVirtualAd = NULL;
582 PRTMP_ADAPTER pAdapter;
586 if (dev->priv_flags == INT_MAIN)
588 pAdapter = dev->ml_priv;
592 pVirtualAd = dev->ml_priv;
593 pAdapter = pVirtualAd->RtmpDev->ml_priv;
596 if (pAdapter == NULL)
598 /* if 1st open fail, pAd will be free;
599 So the net_dev->ml_priv will be NULL in 2rd open */
603 ch = pAdapter->CommonCfg.Channel;
605 DBGPRINT(RT_DEBUG_TRACE,("==>rt_ioctl_giwfreq %d\n", ch));
607 MAP_CHANNEL_ID_TO_KHZ(ch, m);
613 int rt_ioctl_siwmode(struct net_device *dev,
614 struct iw_request_info *info,
615 __u32 *mode, char *extra)
617 PRTMP_ADAPTER pAdapter = dev->ml_priv;
619 //check if the interface is down
620 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
622 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
629 Set_NetworkType_Proc(pAdapter, "Adhoc");
632 Set_NetworkType_Proc(pAdapter, "Infra");
634 case IW_MODE_MONITOR:
635 Set_NetworkType_Proc(pAdapter, "Monitor");
638 DBGPRINT(RT_DEBUG_TRACE, ("===>rt_ioctl_siwmode::SIOCSIWMODE (unknown %d)\n", *mode));
642 // Reset Ralink supplicant to not use, it will be set to start when UI set PMK key
643 pAdapter->StaCfg.WpaState = SS_NOTUSE;
648 int rt_ioctl_giwmode(struct net_device *dev,
649 struct iw_request_info *info,
650 __u32 *mode, char *extra)
652 PRTMP_ADAPTER pAdapter = dev->ml_priv;
654 if (ADHOC_ON(pAdapter))
655 *mode = IW_MODE_ADHOC;
656 else if (INFRA_ON(pAdapter))
657 *mode = IW_MODE_INFRA;
658 else if (MONITOR_ON(pAdapter))
660 *mode = IW_MODE_MONITOR;
663 *mode = IW_MODE_AUTO;
665 DBGPRINT(RT_DEBUG_TRACE, ("==>rt_ioctl_giwmode(mode=%d)\n", *mode));
669 int rt_ioctl_siwsens(struct net_device *dev,
670 struct iw_request_info *info,
671 char *name, char *extra)
673 PRTMP_ADAPTER pAdapter = dev->ml_priv;
675 //check if the interface is down
676 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
678 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
685 int rt_ioctl_giwsens(struct net_device *dev,
686 struct iw_request_info *info,
687 char *name, char *extra)
692 int rt_ioctl_giwrange(struct net_device *dev,
693 struct iw_request_info *info,
694 struct iw_point *data, char *extra)
696 PRTMP_ADAPTER pAdapter = dev->ml_priv;
698 struct iw_range *range = (struct iw_range *) extra;
702 DBGPRINT(RT_DEBUG_TRACE ,("===>rt_ioctl_giwrange\n"));
703 data->length = sizeof(struct iw_range);
704 memset(range, 0, sizeof(struct iw_range));
706 range->txpower_capa = IW_TXPOW_DBM;
708 if (INFRA_ON(pAdapter)||ADHOC_ON(pAdapter))
710 range->min_pmp = 1 * 1024;
711 range->max_pmp = 65535 * 1024;
712 range->min_pmt = 1 * 1024;
713 range->max_pmt = 1000 * 1024;
714 range->pmp_flags = IW_POWER_PERIOD;
715 range->pmt_flags = IW_POWER_TIMEOUT;
716 range->pm_capa = IW_POWER_PERIOD | IW_POWER_TIMEOUT |
717 IW_POWER_UNICAST_R | IW_POWER_ALL_R;
720 range->we_version_compiled = WIRELESS_EXT;
721 range->we_version_source = 14;
723 range->retry_capa = IW_RETRY_LIMIT;
724 range->retry_flags = IW_RETRY_LIMIT;
725 range->min_retry = 0;
726 range->max_retry = 255;
728 range->num_channels = pAdapter->ChannelListNum;
731 for (i = 1; i <= range->num_channels; i++)
734 range->freq[val].i = pAdapter->ChannelList[i-1].Channel;
735 MAP_CHANNEL_ID_TO_KHZ(pAdapter->ChannelList[i-1].Channel, m);
736 range->freq[val].m = m * 100; /* HZ */
738 range->freq[val].e = 1;
740 if (val == IW_MAX_FREQUENCIES)
743 range->num_frequency = val;
745 range->max_qual.qual = 100; /* what is correct max? This was not
746 * documented exactly. At least
747 * 69 has been observed. */
748 range->max_qual.level = 0; /* dB */
749 range->max_qual.noise = 0; /* dB */
751 /* What would be suitable values for "average/typical" qual? */
752 range->avg_qual.qual = 20;
753 range->avg_qual.level = -60;
754 range->avg_qual.noise = -95;
755 range->sensitivity = 3;
757 range->max_encoding_tokens = NR_WEP_KEYS;
758 range->num_encoding_sizes = 2;
759 range->encoding_size[0] = 5;
760 range->encoding_size[1] = 13;
763 range->max_rts = 2347;
764 range->min_frag = 256;
765 range->max_frag = 2346;
767 #if WIRELESS_EXT > 17
768 /* IW_ENC_CAPA_* bit field */
769 range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 |
770 IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP;
776 int rt_ioctl_siwap(struct net_device *dev,
777 struct iw_request_info *info,
778 struct sockaddr *ap_addr, char *extra)
780 PRTMP_ADAPTER pAdapter = dev->ml_priv;
781 NDIS_802_11_MAC_ADDRESS Bssid;
783 //check if the interface is down
784 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
786 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
790 if (pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE)
792 RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
793 DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
796 // tell CNTL state machine to call NdisMSetInformationComplete() after completing
797 // this request, because this request is initiated by NDIS.
798 pAdapter->MlmeAux.CurrReqIsFromNdis = FALSE;
799 // Prevent to connect AP again in STAMlmePeriodicExec
800 pAdapter->MlmeAux.AutoReconnectSsidLen= 32;
802 memset(Bssid, 0, MAC_ADDR_LEN);
803 memcpy(Bssid, ap_addr->sa_data, MAC_ADDR_LEN);
804 MlmeEnqueue(pAdapter,
805 MLME_CNTL_STATE_MACHINE,
807 sizeof(NDIS_802_11_MAC_ADDRESS),
810 DBGPRINT(RT_DEBUG_TRACE, ("IOCTL::SIOCSIWAP %02x:%02x:%02x:%02x:%02x:%02x\n",
811 Bssid[0], Bssid[1], Bssid[2], Bssid[3], Bssid[4], Bssid[5]));
816 int rt_ioctl_giwap(struct net_device *dev,
817 struct iw_request_info *info,
818 struct sockaddr *ap_addr, char *extra)
820 PRTMP_ADAPTER pAdapter = dev->ml_priv;
822 if (INFRA_ON(pAdapter) || ADHOC_ON(pAdapter))
824 ap_addr->sa_family = ARPHRD_ETHER;
825 memcpy(ap_addr->sa_data, &pAdapter->CommonCfg.Bssid, ETH_ALEN);
827 #ifdef WPA_SUPPLICANT_SUPPORT
829 else if (pAdapter->StaCfg.WpaSupplicantUP != WPA_SUPPLICANT_DISABLE)
831 ap_addr->sa_family = ARPHRD_ETHER;
832 memcpy(ap_addr->sa_data, &pAdapter->MlmeAux.Bssid, ETH_ALEN);
834 #endif // WPA_SUPPLICANT_SUPPORT //
837 DBGPRINT(RT_DEBUG_TRACE, ("IOCTL::SIOCGIWAP(=EMPTY)\n"));
845 * Units are in db above the noise floor. That means the
846 * rssi values reported in the tx/rx descriptors in the
847 * driver are the SNR expressed in db.
849 * If you assume that the noise floor is -95, which is an
850 * excellent assumption 99.5 % of the time, then you can
851 * derive the absolute signal level (i.e. -95 + rssi).
852 * There are some other slight factors to take into account
853 * depending on whether the rssi measurement is from 11b,
854 * 11g, or 11a. These differences are at most 2db and
857 * NB: various calculations are based on the orinoco/wavelan
858 * drivers for compatibility
860 static void set_quality(PRTMP_ADAPTER pAdapter,
861 struct iw_quality *iq,
868 ChannelQuality = 100;
869 else if (rssi >= -80) // between -50 ~ -80dbm
870 ChannelQuality = (__u8)(24 + ((rssi + 80) * 26)/10);
871 else if (rssi >= -90) // between -80 ~ -90dbm
872 ChannelQuality = (__u8)((rssi + 90) * 26)/10;
876 iq->qual = (__u8)ChannelQuality;
878 iq->level = (__u8)(rssi);
879 iq->noise = (pAdapter->BbpWriteLatch[66] > pAdapter->BbpTuning.FalseCcaUpperThreshold) ? ((__u8)pAdapter->BbpTuning.FalseCcaUpperThreshold) : ((__u8) pAdapter->BbpWriteLatch[66]); // noise level (dBm)
880 iq->noise += 256 - 143;
881 iq->updated = pAdapter->iw_stats.qual.updated;
884 int rt_ioctl_iwaplist(struct net_device *dev,
885 struct iw_request_info *info,
886 struct iw_point *data, char *extra)
888 PRTMP_ADAPTER pAdapter = dev->ml_priv;
890 struct sockaddr addr[IW_MAX_AP];
891 struct iw_quality qual[IW_MAX_AP];
894 //check if the interface is down
895 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
897 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
903 for (i = 0; i <IW_MAX_AP ; i++)
905 if (i >= pAdapter->ScanTab.BssNr)
907 addr[i].sa_family = ARPHRD_ETHER;
908 memcpy(addr[i].sa_data, &pAdapter->ScanTab.BssEntry[i].Bssid, MAC_ADDR_LEN);
909 set_quality(pAdapter, &qual[i], pAdapter->ScanTab.BssEntry[i].Rssi);
912 memcpy(extra, &addr, i*sizeof(addr[0]));
913 data->flags = 1; /* signal quality present (sort of) */
914 memcpy(extra + i*sizeof(addr[0]), &qual, i*sizeof(qual[i]));
920 int rt_ioctl_siwscan(struct net_device *dev,
921 struct iw_request_info *info,
922 struct iw_point *data, char *extra)
924 PRTMP_ADAPTER pAdapter = dev->ml_priv;
927 int Status = NDIS_STATUS_SUCCESS;
929 //check if the interface is down
930 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
932 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
936 if (MONITOR_ON(pAdapter))
938 DBGPRINT(RT_DEBUG_TRACE, ("!!! Driver is in Monitor Mode now !!!\n"));
943 #ifdef WPA_SUPPLICANT_SUPPORT
944 if (pAdapter->StaCfg.WpaSupplicantUP == WPA_SUPPLICANT_ENABLE)
946 pAdapter->StaCfg.WpaSupplicantScanCount++;
948 #endif // WPA_SUPPLICANT_SUPPORT //
950 pAdapter->StaCfg.bScanReqIsFromWebUI = TRUE;
951 if (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
956 #ifdef WPA_SUPPLICANT_SUPPORT
957 if ((pAdapter->StaCfg.WpaSupplicantUP == WPA_SUPPLICANT_ENABLE) &&
958 (pAdapter->StaCfg.WpaSupplicantScanCount > 3))
960 DBGPRINT(RT_DEBUG_TRACE, ("!!! WpaSupplicantScanCount > 3\n"));
961 Status = NDIS_STATUS_SUCCESS;
964 #endif // WPA_SUPPLICANT_SUPPORT //
966 if ((OPSTATUS_TEST_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED)) &&
967 ((pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA) ||
968 (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK)) &&
969 (pAdapter->StaCfg.PortSecured == WPA_802_1X_PORT_NOT_SECURED))
971 DBGPRINT(RT_DEBUG_TRACE, ("!!! Link UP, Port Not Secured! ignore this set::OID_802_11_BSSID_LIST_SCAN\n"));
972 Status = NDIS_STATUS_SUCCESS;
976 if (pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE)
978 RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
979 DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
982 // tell CNTL state machine to call NdisMSetInformationComplete() after completing
983 // this request, because this request is initiated by NDIS.
984 pAdapter->MlmeAux.CurrReqIsFromNdis = FALSE;
985 // Reset allowed scan retries
986 pAdapter->StaCfg.ScanCnt = 0;
987 pAdapter->StaCfg.LastScanTime = Now;
989 MlmeEnqueue(pAdapter,
990 MLME_CNTL_STATE_MACHINE,
991 OID_802_11_BSSID_LIST_SCAN,
995 Status = NDIS_STATUS_SUCCESS;
996 RT28XX_MLME_HANDLER(pAdapter);
1001 int rt_ioctl_giwscan(struct net_device *dev,
1002 struct iw_request_info *info,
1003 struct iw_point *data, char *extra)
1006 PRTMP_ADAPTER pAdapter = dev->ml_priv;
1008 char *current_ev = extra, *previous_ev = extra;
1010 char *current_val, custom[MAX_CUSTOM_LEN] = {0};
1013 #endif // IWEVGENIE //
1014 struct iw_event iwe;
1016 if (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
1019 * Still scanning, indicate the caller should try again.
1025 #ifdef WPA_SUPPLICANT_SUPPORT
1026 if (pAdapter->StaCfg.WpaSupplicantUP == WPA_SUPPLICANT_ENABLE)
1028 pAdapter->StaCfg.WpaSupplicantScanCount = 0;
1030 #endif // WPA_SUPPLICANT_SUPPORT //
1032 if (pAdapter->ScanTab.BssNr == 0)
1038 #if WIRELESS_EXT >= 17
1039 if (data->length > 0)
1040 end_buf = extra + data->length;
1042 end_buf = extra + IW_SCAN_MAX_DATA;
1044 end_buf = extra + IW_SCAN_MAX_DATA;
1047 for (i = 0; i < pAdapter->ScanTab.BssNr; i++)
1049 if (current_ev >= end_buf)
1051 #if WIRELESS_EXT >= 17
1059 //================================
1060 memset(&iwe, 0, sizeof(iwe));
1061 iwe.cmd = SIOCGIWAP;
1062 iwe.u.ap_addr.sa_family = ARPHRD_ETHER;
1063 memcpy(iwe.u.ap_addr.sa_data, &pAdapter->ScanTab.BssEntry[i].Bssid, ETH_ALEN);
1065 previous_ev = current_ev;
1066 current_ev = iwe_stream_add_event(info, current_ev, end_buf, &iwe, IW_EV_ADDR_LEN);
1067 if (current_ev == previous_ev)
1068 #if WIRELESS_EXT >= 17
1076 it will show scanned AP's WirelessMode .
1085 memset(&iwe, 0, sizeof(iwe));
1086 iwe.cmd = SIOCGIWNAME;
1090 PBSS_ENTRY pBssEntry=&pAdapter->ScanTab.BssEntry[i];
1091 BOOLEAN isGonly=FALSE;
1094 if (pBssEntry->Channel>14)
1096 if (pBssEntry->HtCapabilityLen!=0)
1097 strcpy(iwe.u.name,"802.11a/n");
1099 strcpy(iwe.u.name,"802.11a");
1104 if one of non B mode rate is set supported rate . it mean G only.
1106 for (rateCnt=0;rateCnt<pBssEntry->SupRateLen;rateCnt++)
1109 6Mbps(140) 9Mbps(146) and >=12Mbps(152) are supported rate , it mean G only.
1111 if (pBssEntry->SupRate[rateCnt]==140 || pBssEntry->SupRate[rateCnt]==146 || pBssEntry->SupRate[rateCnt]>=152)
1115 for (rateCnt=0;rateCnt<pBssEntry->ExtRateLen;rateCnt++)
1117 if (pBssEntry->ExtRate[rateCnt]==140 || pBssEntry->ExtRate[rateCnt]==146 || pBssEntry->ExtRate[rateCnt]>=152)
1122 if (pBssEntry->HtCapabilityLen!=0)
1125 strcpy(iwe.u.name,"802.11g/n");
1127 strcpy(iwe.u.name,"802.11b/g/n");
1132 strcpy(iwe.u.name,"802.11g");
1135 if (pBssEntry->SupRateLen==4 && pBssEntry->ExtRateLen==0)
1136 strcpy(iwe.u.name,"802.11b");
1138 strcpy(iwe.u.name,"802.11b/g");
1144 previous_ev = current_ev;
1145 current_ev = iwe_stream_add_event(info, current_ev, end_buf, &iwe, IW_EV_ADDR_LEN);
1146 if (current_ev == previous_ev)
1147 #if WIRELESS_EXT >= 17
1154 //================================
1155 memset(&iwe, 0, sizeof(iwe));
1156 iwe.cmd = SIOCGIWESSID;
1157 iwe.u.data.length = pAdapter->ScanTab.BssEntry[i].SsidLen;
1158 iwe.u.data.flags = 1;
1160 previous_ev = current_ev;
1161 current_ev = iwe_stream_add_point(info, current_ev, end_buf, &iwe, pAdapter->ScanTab.BssEntry[i].Ssid);
1162 if (current_ev == previous_ev)
1163 #if WIRELESS_EXT >= 17
1170 //================================
1171 memset(&iwe, 0, sizeof(iwe));
1172 iwe.cmd = SIOCGIWMODE;
1173 if (pAdapter->ScanTab.BssEntry[i].BssType == Ndis802_11IBSS)
1175 iwe.u.mode = IW_MODE_ADHOC;
1177 else if (pAdapter->ScanTab.BssEntry[i].BssType == Ndis802_11Infrastructure)
1179 iwe.u.mode = IW_MODE_INFRA;
1183 iwe.u.mode = IW_MODE_AUTO;
1185 iwe.len = IW_EV_UINT_LEN;
1187 previous_ev = current_ev;
1188 current_ev = iwe_stream_add_event(info, current_ev, end_buf, &iwe, IW_EV_UINT_LEN);
1189 if (current_ev == previous_ev)
1190 #if WIRELESS_EXT >= 17
1196 //Channel and Frequency
1197 //================================
1198 memset(&iwe, 0, sizeof(iwe));
1199 iwe.cmd = SIOCGIWFREQ;
1200 if (INFRA_ON(pAdapter) || ADHOC_ON(pAdapter))
1201 iwe.u.freq.m = pAdapter->ScanTab.BssEntry[i].Channel;
1203 iwe.u.freq.m = pAdapter->ScanTab.BssEntry[i].Channel;
1207 previous_ev = current_ev;
1208 current_ev = iwe_stream_add_event(info, current_ev, end_buf, &iwe, IW_EV_FREQ_LEN);
1209 if (current_ev == previous_ev)
1210 #if WIRELESS_EXT >= 17
1216 //Add quality statistics
1217 //================================
1218 memset(&iwe, 0, sizeof(iwe));
1220 iwe.u.qual.level = 0;
1221 iwe.u.qual.noise = 0;
1222 set_quality(pAdapter, &iwe.u.qual, pAdapter->ScanTab.BssEntry[i].Rssi);
1223 current_ev = iwe_stream_add_event(info, current_ev, end_buf, &iwe, IW_EV_QUAL_LEN);
1224 if (current_ev == previous_ev)
1225 #if WIRELESS_EXT >= 17
1232 //================================
1233 memset(&iwe, 0, sizeof(iwe));
1234 iwe.cmd = SIOCGIWENCODE;
1235 if (CAP_IS_PRIVACY_ON (pAdapter->ScanTab.BssEntry[i].CapabilityInfo ))
1236 iwe.u.data.flags =IW_ENCODE_ENABLED | IW_ENCODE_NOKEY;
1238 iwe.u.data.flags = IW_ENCODE_DISABLED;
1240 previous_ev = current_ev;
1241 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);
1242 if (current_ev == previous_ev)
1243 #if WIRELESS_EXT >= 17
1250 //================================
1251 if (pAdapter->ScanTab.BssEntry[i].SupRateLen)
1253 UCHAR tmpRate = pAdapter->ScanTab.BssEntry[i].SupRate[pAdapter->ScanTab.BssEntry[i].SupRateLen-1];
1254 memset(&iwe, 0, sizeof(iwe));
1255 iwe.cmd = SIOCGIWRATE;
1256 current_val = current_ev + IW_EV_LCP_LEN;
1257 if (tmpRate == 0x82)
1258 iwe.u.bitrate.value = 1 * 1000000;
1259 else if (tmpRate == 0x84)
1260 iwe.u.bitrate.value = 2 * 1000000;
1261 else if (tmpRate == 0x8B)
1262 iwe.u.bitrate.value = 5.5 * 1000000;
1263 else if (tmpRate == 0x96)
1264 iwe.u.bitrate.value = 11 * 1000000;
1266 iwe.u.bitrate.value = (tmpRate/2) * 1000000;
1268 iwe.u.bitrate.disabled = 0;
1269 current_val = iwe_stream_add_value(info, current_ev,
1270 current_val, end_buf, &iwe,
1273 if((current_val-current_ev)>IW_EV_LCP_LEN)
1274 current_ev = current_val;
1276 #if WIRELESS_EXT >= 17
1285 if (pAdapter->ScanTab.BssEntry[i].WpaIE.IELen > 0)
1287 memset(&iwe, 0, sizeof(iwe));
1288 memset(&custom[0], 0, MAX_CUSTOM_LEN);
1289 memcpy(custom, &(pAdapter->ScanTab.BssEntry[i].WpaIE.IE[0]),
1290 pAdapter->ScanTab.BssEntry[i].WpaIE.IELen);
1291 iwe.cmd = IWEVGENIE;
1292 iwe.u.data.length = pAdapter->ScanTab.BssEntry[i].WpaIE.IELen;
1293 current_ev = iwe_stream_add_point(info, current_ev, end_buf, &iwe, custom);
1294 if (current_ev == previous_ev)
1295 #if WIRELESS_EXT >= 17
1303 if (pAdapter->ScanTab.BssEntry[i].RsnIE.IELen > 0)
1305 memset(&iwe, 0, sizeof(iwe));
1306 memset(&custom[0], 0, MAX_CUSTOM_LEN);
1307 memcpy(custom, &(pAdapter->ScanTab.BssEntry[i].RsnIE.IE[0]),
1308 pAdapter->ScanTab.BssEntry[i].RsnIE.IELen);
1309 iwe.cmd = IWEVGENIE;
1310 iwe.u.data.length = pAdapter->ScanTab.BssEntry[i].RsnIE.IELen;
1311 current_ev = iwe_stream_add_point(info, current_ev, end_buf, &iwe, custom);
1312 if (current_ev == previous_ev)
1313 #if WIRELESS_EXT >= 17
1321 //================================
1322 if (pAdapter->ScanTab.BssEntry[i].WpaIE.IELen > 0)
1324 NdisZeroMemory(&iwe, sizeof(iwe));
1325 memset(&custom[0], 0, MAX_CUSTOM_LEN);
1326 iwe.cmd = IWEVCUSTOM;
1327 iwe.u.data.length = (pAdapter->ScanTab.BssEntry[i].WpaIE.IELen * 2) + 7;
1328 NdisMoveMemory(custom, "wpa_ie=", 7);
1329 for (idx = 0; idx < pAdapter->ScanTab.BssEntry[i].WpaIE.IELen; idx++)
1330 sprintf(custom, "%s%02x", custom, pAdapter->ScanTab.BssEntry[i].WpaIE.IE[idx]);
1331 previous_ev = current_ev;
1332 current_ev = iwe_stream_add_point(current_ev, end_buf, &iwe, custom);
1333 if (current_ev == previous_ev)
1334 #if WIRELESS_EXT >= 17
1342 if (pAdapter->ScanTab.BssEntry[i].RsnIE.IELen > 0)
1344 NdisZeroMemory(&iwe, sizeof(iwe));
1345 memset(&custom[0], 0, MAX_CUSTOM_LEN);
1346 iwe.cmd = IWEVCUSTOM;
1347 iwe.u.data.length = (pAdapter->ScanTab.BssEntry[i].RsnIE.IELen * 2) + 7;
1348 NdisMoveMemory(custom, "rsn_ie=", 7);
1349 for (idx = 0; idx < pAdapter->ScanTab.BssEntry[i].RsnIE.IELen; idx++)
1350 sprintf(custom, "%s%02x", custom, pAdapter->ScanTab.BssEntry[i].RsnIE.IE[idx]);
1351 previous_ev = current_ev;
1352 current_ev = iwe_stream_add_point(current_ev, end_buf, &iwe, custom);
1353 if (current_ev == previous_ev)
1354 #if WIRELESS_EXT >= 17
1360 #endif // IWEVGENIE //
1363 data->length = current_ev - extra;
1364 pAdapter->StaCfg.bScanReqIsFromWebUI = FALSE;
1365 DBGPRINT(RT_DEBUG_ERROR ,("===>rt_ioctl_giwscan. %d(%d) BSS returned, data->length = %d\n",i , pAdapter->ScanTab.BssNr, data->length));
1370 int rt_ioctl_siwessid(struct net_device *dev,
1371 struct iw_request_info *info,
1372 struct iw_point *data, char *essid)
1374 PRTMP_ADAPTER pAdapter = dev->ml_priv;
1376 //check if the interface is down
1377 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1379 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1385 PCHAR pSsidString = NULL;
1387 // Includes null character.
1388 if (data->length > (IW_ESSID_MAX_SIZE + 1))
1391 pSsidString = (CHAR *) kmalloc(MAX_LEN_OF_SSID+1, MEM_ALLOC_FLAG);
1394 NdisZeroMemory(pSsidString, MAX_LEN_OF_SSID+1);
1395 NdisMoveMemory(pSsidString, essid, data->length);
1396 if (Set_SSID_Proc(pAdapter, pSsidString) == FALSE)
1405 if (Set_SSID_Proc(pAdapter, "") == FALSE)
1411 int rt_ioctl_giwessid(struct net_device *dev,
1412 struct iw_request_info *info,
1413 struct iw_point *data, char *essid)
1415 PRTMP_ADAPTER pAdapter = dev->ml_priv;
1418 if (MONITOR_ON(pAdapter))
1424 if (OPSTATUS_TEST_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED))
1426 DBGPRINT(RT_DEBUG_TRACE ,("MediaState is connected\n"));
1427 data->length = pAdapter->CommonCfg.SsidLen;
1428 memcpy(essid, pAdapter->CommonCfg.Ssid, pAdapter->CommonCfg.SsidLen);
1431 #ifdef WPA_SUPPLICANT_SUPPORT
1433 else if (pAdapter->StaCfg.WpaSupplicantUP != WPA_SUPPLICANT_DISABLE)
1435 data->length = pAdapter->CommonCfg.SsidLen;
1436 memcpy(essid, pAdapter->CommonCfg.Ssid, pAdapter->CommonCfg.SsidLen);
1438 #endif // WPA_SUPPLICANT_SUPPORT //
1441 {//the ANY ssid was specified
1443 DBGPRINT(RT_DEBUG_TRACE ,("MediaState is not connected, ess\n"));
1450 int rt_ioctl_siwnickn(struct net_device *dev,
1451 struct iw_request_info *info,
1452 struct iw_point *data, char *nickname)
1454 PRTMP_ADAPTER pAdapter = dev->ml_priv;
1456 //check if the interface is down
1457 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1459 DBGPRINT(RT_DEBUG_TRACE ,("INFO::Network is down!\n"));
1463 if (data->length > IW_ESSID_MAX_SIZE)
1466 memset(pAdapter->nickname, 0, IW_ESSID_MAX_SIZE + 1);
1467 memcpy(pAdapter->nickname, nickname, data->length);
1473 int rt_ioctl_giwnickn(struct net_device *dev,
1474 struct iw_request_info *info,
1475 struct iw_point *data, char *nickname)
1477 PRTMP_ADAPTER pAdapter = dev->ml_priv;
1479 if (data->length > strlen(pAdapter->nickname) + 1)
1480 data->length = strlen(pAdapter->nickname) + 1;
1481 if (data->length > 0) {
1482 memcpy(nickname, pAdapter->nickname, data->length-1);
1483 nickname[data->length-1] = '\0';
1488 int rt_ioctl_siwrts(struct net_device *dev,
1489 struct iw_request_info *info,
1490 struct iw_param *rts, char *extra)
1492 PRTMP_ADAPTER pAdapter = dev->ml_priv;
1495 //check if the interface is down
1496 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1498 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1503 val = MAX_RTS_THRESHOLD;
1504 else if (rts->value < 0 || rts->value > MAX_RTS_THRESHOLD)
1506 else if (rts->value == 0)
1507 val = MAX_RTS_THRESHOLD;
1511 if (val != pAdapter->CommonCfg.RtsThreshold)
1512 pAdapter->CommonCfg.RtsThreshold = val;
1517 int rt_ioctl_giwrts(struct net_device *dev,
1518 struct iw_request_info *info,
1519 struct iw_param *rts, char *extra)
1521 PRTMP_ADAPTER pAdapter = dev->ml_priv;
1523 //check if the interface is down
1524 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1526 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1530 rts->value = pAdapter->CommonCfg.RtsThreshold;
1531 rts->disabled = (rts->value == MAX_RTS_THRESHOLD);
1537 int rt_ioctl_siwfrag(struct net_device *dev,
1538 struct iw_request_info *info,
1539 struct iw_param *frag, char *extra)
1541 PRTMP_ADAPTER pAdapter = dev->ml_priv;
1544 //check if the interface is down
1545 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1547 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1552 val = MAX_FRAG_THRESHOLD;
1553 else if (frag->value >= MIN_FRAG_THRESHOLD || frag->value <= MAX_FRAG_THRESHOLD)
1554 val = __cpu_to_le16(frag->value & ~0x1); /* even numbers only */
1555 else if (frag->value == 0)
1556 val = MAX_FRAG_THRESHOLD;
1560 pAdapter->CommonCfg.FragmentThreshold = val;
1564 int rt_ioctl_giwfrag(struct net_device *dev,
1565 struct iw_request_info *info,
1566 struct iw_param *frag, char *extra)
1568 PRTMP_ADAPTER pAdapter = dev->ml_priv;
1570 //check if the interface is down
1571 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1573 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1577 frag->value = pAdapter->CommonCfg.FragmentThreshold;
1578 frag->disabled = (frag->value == MAX_FRAG_THRESHOLD);
1584 #define MAX_WEP_KEY_SIZE 13
1585 #define MIN_WEP_KEY_SIZE 5
1586 int rt_ioctl_siwencode(struct net_device *dev,
1587 struct iw_request_info *info,
1588 struct iw_point *erq, char *extra)
1590 PRTMP_ADAPTER pAdapter = dev->ml_priv;
1592 //check if the interface is down
1593 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1595 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1599 if ((erq->length == 0) &&
1600 (erq->flags & IW_ENCODE_DISABLED))
1602 pAdapter->StaCfg.PairCipher = Ndis802_11WEPDisabled;
1603 pAdapter->StaCfg.GroupCipher = Ndis802_11WEPDisabled;
1604 pAdapter->StaCfg.WepStatus = Ndis802_11WEPDisabled;
1605 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
1606 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
1609 else if (erq->flags & IW_ENCODE_RESTRICTED || erq->flags & IW_ENCODE_OPEN)
1611 //pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
1612 STA_PORT_SECURED(pAdapter);
1613 pAdapter->StaCfg.PairCipher = Ndis802_11WEPEnabled;
1614 pAdapter->StaCfg.GroupCipher = Ndis802_11WEPEnabled;
1615 pAdapter->StaCfg.WepStatus = Ndis802_11WEPEnabled;
1616 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
1617 if (erq->flags & IW_ENCODE_RESTRICTED)
1618 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeShared;
1620 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
1623 if (erq->length > 0)
1625 int keyIdx = (erq->flags & IW_ENCODE_INDEX) - 1;
1626 /* Check the size of the key */
1627 if (erq->length > MAX_WEP_KEY_SIZE)
1631 /* Check key index */
1632 if ((keyIdx < 0) || (keyIdx >= NR_WEP_KEYS))
1634 DBGPRINT(RT_DEBUG_TRACE ,("==>rt_ioctl_siwencode::Wrong keyIdx=%d! Using default key instead (%d)\n",
1635 keyIdx, pAdapter->StaCfg.DefaultKeyId));
1638 keyIdx = pAdapter->StaCfg.DefaultKeyId;
1642 pAdapter->StaCfg.DefaultKeyId=keyIdx;
1645 NdisZeroMemory(pAdapter->SharedKey[BSS0][keyIdx].Key, 16);
1647 if (erq->length == MAX_WEP_KEY_SIZE)
1649 pAdapter->SharedKey[BSS0][keyIdx].KeyLen = MAX_WEP_KEY_SIZE;
1650 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CIPHER_WEP128;
1652 else if (erq->length == MIN_WEP_KEY_SIZE)
1654 pAdapter->SharedKey[BSS0][keyIdx].KeyLen = MIN_WEP_KEY_SIZE;
1655 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CIPHER_WEP64;
1658 /* Disable the key */
1659 pAdapter->SharedKey[BSS0][keyIdx].KeyLen = 0;
1661 /* Check if the key is not marked as invalid */
1662 if(!(erq->flags & IW_ENCODE_NOKEY))
1664 /* Copy the key in the driver */
1665 NdisMoveMemory(pAdapter->SharedKey[BSS0][keyIdx].Key, extra, erq->length);
1670 /* Do we want to just set the transmit key index ? */
1671 int index = (erq->flags & IW_ENCODE_INDEX) - 1;
1672 if ((index >= 0) && (index < 4))
1674 pAdapter->StaCfg.DefaultKeyId = index;
1677 /* Don't complain if only change the mode */
1678 if (!(erq->flags & IW_ENCODE_MODE))
1683 DBGPRINT(RT_DEBUG_TRACE ,("==>rt_ioctl_siwencode::erq->flags=%x\n",erq->flags));
1684 DBGPRINT(RT_DEBUG_TRACE ,("==>rt_ioctl_siwencode::AuthMode=%x\n",pAdapter->StaCfg.AuthMode));
1685 DBGPRINT(RT_DEBUG_TRACE ,("==>rt_ioctl_siwencode::DefaultKeyId=%x, KeyLen = %d\n",pAdapter->StaCfg.DefaultKeyId , pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].KeyLen));
1686 DBGPRINT(RT_DEBUG_TRACE ,("==>rt_ioctl_siwencode::WepStatus=%x\n",pAdapter->StaCfg.WepStatus));
1691 rt_ioctl_giwencode(struct net_device *dev,
1692 struct iw_request_info *info,
1693 struct iw_point *erq, char *key)
1695 PRTMP_ADAPTER pAdapter = dev->ml_priv;
1698 //check if the interface is down
1699 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1701 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1705 kid = erq->flags & IW_ENCODE_INDEX;
1706 DBGPRINT(RT_DEBUG_TRACE, ("===>rt_ioctl_giwencode %d\n", erq->flags & IW_ENCODE_INDEX));
1708 if (pAdapter->StaCfg.WepStatus == Ndis802_11WEPDisabled)
1711 erq->flags = IW_ENCODE_DISABLED;
1713 else if ((kid > 0) && (kid <=4))
1716 erq->flags = kid ; /* NB: base 1 */
1717 if (erq->length > pAdapter->SharedKey[BSS0][kid-1].KeyLen)
1718 erq->length = pAdapter->SharedKey[BSS0][kid-1].KeyLen;
1719 memcpy(key, pAdapter->SharedKey[BSS0][kid-1].Key, erq->length);
1720 //if ((kid == pAdapter->PortCfg.DefaultKeyId))
1721 //erq->flags |= IW_ENCODE_ENABLED; /* XXX */
1722 if (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeShared)
1723 erq->flags |= IW_ENCODE_RESTRICTED; /* XXX */
1725 erq->flags |= IW_ENCODE_OPEN; /* XXX */
1730 if (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeShared)
1731 erq->flags |= IW_ENCODE_RESTRICTED; /* XXX */
1733 erq->flags |= IW_ENCODE_OPEN; /* XXX */
1734 erq->length = pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].KeyLen;
1735 memcpy(key, pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].Key, erq->length);
1736 // copy default key ID
1737 if (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeShared)
1738 erq->flags |= IW_ENCODE_RESTRICTED; /* XXX */
1740 erq->flags |= IW_ENCODE_OPEN; /* XXX */
1741 erq->flags = pAdapter->StaCfg.DefaultKeyId + 1; /* NB: base 1 */
1742 erq->flags |= IW_ENCODE_ENABLED; /* XXX */
1750 rt_ioctl_setparam(struct net_device *dev, struct iw_request_info *info,
1751 void *w, char *extra)
1753 VIRTUAL_ADAPTER *pVirtualAd = NULL;
1754 PRTMP_ADAPTER pAdapter;
1756 char *this_char = extra;
1760 if (dev->priv_flags == INT_MAIN)
1762 pAdapter = dev->ml_priv;
1766 pVirtualAd = dev->ml_priv;
1767 pAdapter = pVirtualAd->RtmpDev->ml_priv;
1769 pObj = (POS_COOKIE) pAdapter->OS_Cookie;
1771 if (pAdapter == NULL)
1773 /* if 1st open fail, pAd will be free;
1774 So the net_dev->ml_priv will be NULL in 2rd open */
1779 pObj->ioctl_if_type = INT_MAIN;
1780 pObj->ioctl_if = MAIN_MBSSID;
1783 //check if the interface is down
1784 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1786 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1793 if ((value = rtstrchr(this_char, '=')) != NULL)
1799 // reject setting nothing besides ANY ssid(ssidLen=0)
1800 if (!*value && (strcmp(this_char, "SSID") != 0))
1803 for (PRTMP_PRIVATE_SET_PROC = RTMP_PRIVATE_SUPPORT_PROC; PRTMP_PRIVATE_SET_PROC->name; PRTMP_PRIVATE_SET_PROC++)
1805 if (strcmp(this_char, PRTMP_PRIVATE_SET_PROC->name) == 0)
1807 if(!PRTMP_PRIVATE_SET_PROC->set_proc(pAdapter, value))
1808 { //FALSE:Set private failed then return Invalid argument
1811 break; //Exit for loop.
1815 if(PRTMP_PRIVATE_SET_PROC->name == NULL)
1816 { //Not found argument
1818 DBGPRINT(RT_DEBUG_TRACE, ("===>rt_ioctl_setparam:: (iwpriv) Not Support Set Command [%s=%s]\n", this_char, value));
1826 rt_private_get_statistics(struct net_device *dev, struct iw_request_info *info,
1827 struct iw_point *wrq, char *extra)
1830 PRTMP_ADAPTER pAd = dev->ml_priv;
1838 memset(extra, 0x00, IW_PRIV_SIZE_MASK);
1839 sprintf(extra, "\n\n");
1842 sprintf(extra+strlen(extra), "Tx success = %ld\n", (ULONG)pAd->WlanCounters.TransmittedFragmentCount.QuadPart);
1843 sprintf(extra+strlen(extra), "Tx success without retry = %ld\n", (ULONG)pAd->WlanCounters.TransmittedFragmentCount.QuadPart - (ULONG)pAd->WlanCounters.RetryCount.QuadPart);
1845 sprintf(extra+strlen(extra), "Tx success after retry = %ld\n", (ULONG)pAd->WlanCounters.RetryCount.QuadPart);
1846 sprintf(extra+strlen(extra), "Tx fail to Rcv ACK after retry = %ld\n", (ULONG)pAd->WlanCounters.FailedCount.QuadPart);
1847 sprintf(extra+strlen(extra), "RTS Success Rcv CTS = %ld\n", (ULONG)pAd->WlanCounters.RTSSuccessCount.QuadPart);
1848 sprintf(extra+strlen(extra), "RTS Fail Rcv CTS = %ld\n", (ULONG)pAd->WlanCounters.RTSFailureCount.QuadPart);
1850 sprintf(extra+strlen(extra), "Rx success = %ld\n", (ULONG)pAd->WlanCounters.ReceivedFragmentCount.QuadPart);
1851 sprintf(extra+strlen(extra), "Rx with CRC = %ld\n", (ULONG)pAd->WlanCounters.FCSErrorCount.QuadPart);
1852 sprintf(extra+strlen(extra), "Rx drop due to out of resource = %ld\n", (ULONG)pAd->Counters8023.RxNoBuffer);
1853 sprintf(extra+strlen(extra), "Rx duplicate frame = %ld\n", (ULONG)pAd->WlanCounters.FrameDuplicateCount.QuadPart);
1855 sprintf(extra+strlen(extra), "False CCA (one second) = %ld\n", (ULONG)pAd->RalinkCounters.OneSecFalseCCACnt);
1857 sprintf(extra+strlen(extra), "RSSI-A = %ld\n", (LONG)(pAd->StaCfg.RssiSample.LastRssi0 - pAd->BbpRssiToDbmDelta));
1858 sprintf(extra+strlen(extra), "RSSI-B (if available) = %ld\n", (LONG)(pAd->StaCfg.RssiSample.LastRssi1 - pAd->BbpRssiToDbmDelta));
1859 sprintf(extra+strlen(extra), "RSSI-C (if available) = %ld\n\n", (LONG)(pAd->StaCfg.RssiSample.LastRssi2 - pAd->BbpRssiToDbmDelta));
1861 #ifdef WPA_SUPPLICANT_SUPPORT
1862 sprintf(extra+strlen(extra), "WpaSupplicantUP = %d\n\n", pAd->StaCfg.WpaSupplicantUP);
1863 #endif // WPA_SUPPLICANT_SUPPORT //
1866 wrq->length = strlen(extra) + 1; // 1: size of '\0'
1867 DBGPRINT(RT_DEBUG_TRACE, ("<== rt_private_get_statistics, wrq->length = %d\n", wrq->length));
1872 #ifdef DOT11_N_SUPPORT
1874 IN PRTMP_ADAPTER pAd,
1878 BA_ORI_ENTRY *pOriBAEntry;
1879 BA_REC_ENTRY *pRecBAEntry;
1881 for (i=0; i<MAX_LEN_OF_MAC_TABLE; i++)
1883 PMAC_TABLE_ENTRY pEntry = &pAd->MacTab.Content[i];
1884 if (((pEntry->ValidAsCLI || pEntry->ValidAsApCli) && (pEntry->Sst == SST_ASSOC))
1885 || (pEntry->ValidAsWDS) || (pEntry->ValidAsMesh))
1887 sprintf(pOutBuf, "%s\n%02X:%02X:%02X:%02X:%02X:%02X (Aid = %d) (AP) -\n",
1889 pEntry->Addr[0], pEntry->Addr[1], pEntry->Addr[2],
1890 pEntry->Addr[3], pEntry->Addr[4], pEntry->Addr[5], pEntry->Aid);
1892 sprintf(pOutBuf, "%s[Recipient]\n", pOutBuf);
1893 for (j=0; j < NUM_OF_TID; j++)
1895 if (pEntry->BARecWcidArray[j] != 0)
1897 pRecBAEntry =&pAd->BATable.BARecEntry[pEntry->BARecWcidArray[j]];
1898 sprintf(pOutBuf, "%sTID=%d, BAWinSize=%d, LastIndSeq=%d, ReorderingPkts=%d\n", pOutBuf, j, pRecBAEntry->BAWinSize, pRecBAEntry->LastIndSeq, pRecBAEntry->list.qlen);
1901 sprintf(pOutBuf, "%s\n", pOutBuf);
1903 sprintf(pOutBuf, "%s[Originator]\n", pOutBuf);
1904 for (j=0; j < NUM_OF_TID; j++)
1906 if (pEntry->BAOriWcidArray[j] != 0)
1908 pOriBAEntry =&pAd->BATable.BAOriEntry[pEntry->BAOriWcidArray[j]];
1909 sprintf(pOutBuf, "%sTID=%d, BAWinSize=%d, StartSeq=%d, CurTxSeq=%d\n", pOutBuf, j, pOriBAEntry->BAWinSize, pOriBAEntry->Sequence, pEntry->TxSeq[j]);
1912 sprintf(pOutBuf, "%s\n\n", pOutBuf);
1914 if (strlen(pOutBuf) > (IW_PRIV_SIZE_MASK - 30))
1920 #endif // DOT11_N_SUPPORT //
1923 rt_private_show(struct net_device *dev, struct iw_request_info *info,
1924 struct iw_point *wrq, char *extra)
1927 VIRTUAL_ADAPTER *pVirtualAd = NULL;
1930 u32 subcmd = wrq->flags;
1932 if (dev->priv_flags == INT_MAIN)
1936 pVirtualAd = dev->ml_priv;
1937 pAd = pVirtualAd->RtmpDev->ml_priv;
1939 pObj = (POS_COOKIE) pAd->OS_Cookie;
1943 /* if 1st open fail, pAd will be free;
1944 So the net_dev->ml_priv will be NULL in 2rd open */
1953 memset(extra, 0x00, IW_PRIV_SIZE_MASK);
1956 pObj->ioctl_if_type = INT_MAIN;
1957 pObj->ioctl_if = MAIN_MBSSID;
1963 case SHOW_CONN_STATUS:
1964 if (MONITOR_ON(pAd))
1966 #ifdef DOT11_N_SUPPORT
1967 if (pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED &&
1968 pAd->CommonCfg.RegTransmitSetting.field.BW)
1969 sprintf(extra, "Monitor Mode(CentralChannel %d)\n", pAd->CommonCfg.CentralChannel);
1971 #endif // DOT11_N_SUPPORT //
1972 sprintf(extra, "Monitor Mode(Channel %d)\n", pAd->CommonCfg.Channel);
1976 if (pAd->IndicateMediaState == NdisMediaStateConnected)
1980 sprintf(extra, "Connected(AP: %s[%02X:%02X:%02X:%02X:%02X:%02X])\n",
1981 pAd->CommonCfg.Ssid,
1982 pAd->CommonCfg.Bssid[0],
1983 pAd->CommonCfg.Bssid[1],
1984 pAd->CommonCfg.Bssid[2],
1985 pAd->CommonCfg.Bssid[3],
1986 pAd->CommonCfg.Bssid[4],
1987 pAd->CommonCfg.Bssid[5]);
1988 DBGPRINT(RT_DEBUG_TRACE ,("Ssid=%s ,Ssidlen = %d\n",pAd->CommonCfg.Ssid, pAd->CommonCfg.SsidLen));
1990 else if (ADHOC_ON(pAd))
1991 sprintf(extra, "Connected\n");
1995 sprintf(extra, "Disconnected\n");
1996 DBGPRINT(RT_DEBUG_TRACE ,("ConnStatus is not connected\n"));
1999 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2001 case SHOW_DRVIER_VERION:
2002 sprintf(extra, "Driver version-%s, %s %s\n", STA_DRIVER_VERSION, __DATE__, __TIME__ );
2003 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2005 #ifdef DOT11_N_SUPPORT
2007 getBaInfo(pAd, extra);
2008 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2010 #endif // DOT11_N_SUPPORT //
2011 case SHOW_DESC_INFO:
2013 Show_DescInfo_Proc(pAd, NULL);
2014 wrq->length = 0; // 1: size of '\0'
2018 if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
2020 sprintf(extra, "Scanning\n");
2021 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2024 pAd->StaCfg.bSwRadio = FALSE;
2025 if (pAd->StaCfg.bRadio != (pAd->StaCfg.bHwRadio && pAd->StaCfg.bSwRadio))
2027 pAd->StaCfg.bRadio = (pAd->StaCfg.bHwRadio && pAd->StaCfg.bSwRadio);
2028 if (pAd->StaCfg.bRadio == FALSE)
2031 // Update extra information
2032 pAd->ExtraInfo = SW_RADIO_OFF;
2035 sprintf(extra, "Radio Off\n");
2036 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2039 if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
2041 sprintf(extra, "Scanning\n");
2042 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2045 pAd->StaCfg.bSwRadio = TRUE;
2046 //if (pAd->StaCfg.bRadio != (pAd->StaCfg.bHwRadio && pAd->StaCfg.bSwRadio))
2048 pAd->StaCfg.bRadio = (pAd->StaCfg.bHwRadio && pAd->StaCfg.bSwRadio);
2049 if (pAd->StaCfg.bRadio == TRUE)
2052 // Update extra information
2053 pAd->ExtraInfo = EXTRA_INFO_CLEAR;
2056 sprintf(extra, "Radio On\n");
2057 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2061 #ifdef QOS_DLS_SUPPORT
2062 case SHOW_DLS_ENTRY_INFO:
2064 Set_DlsEntryInfo_Display_Proc(pAd, NULL);
2065 wrq->length = 0; // 1: size of '\0'
2068 #endif // QOS_DLS_SUPPORT //
2070 case SHOW_CFG_VALUE:
2072 Status = RTMPShowCfgValue(pAd, wrq->pointer, extra);
2074 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2078 DBGPRINT(RT_DEBUG_TRACE, ("%s - unknow subcmd = %d\n", __func__, subcmd));
2086 int rt_ioctl_siwmlme(struct net_device *dev,
2087 struct iw_request_info *info,
2088 union iwreq_data *wrqu,
2091 PRTMP_ADAPTER pAd = dev->ml_priv;
2092 struct iw_mlme *pMlme = (struct iw_mlme *)wrqu->data.pointer;
2093 MLME_QUEUE_ELEM MsgElem;
2094 MLME_DISASSOC_REQ_STRUCT DisAssocReq;
2095 MLME_DEAUTH_REQ_STRUCT DeAuthReq;
2097 DBGPRINT(RT_DEBUG_TRACE, ("====> %s\n", __func__));
2104 #ifdef IW_MLME_DEAUTH
2105 case IW_MLME_DEAUTH:
2106 DBGPRINT(RT_DEBUG_TRACE, ("====> %s - IW_MLME_DEAUTH\n", __func__));
2107 COPY_MAC_ADDR(DeAuthReq.Addr, pAd->CommonCfg.Bssid);
2108 DeAuthReq.Reason = pMlme->reason_code;
2109 MsgElem.MsgLen = sizeof(MLME_DEAUTH_REQ_STRUCT);
2110 NdisMoveMemory(MsgElem.Msg, &DeAuthReq, sizeof(MLME_DEAUTH_REQ_STRUCT));
2111 MlmeDeauthReqAction(pAd, &MsgElem);
2114 LinkDown(pAd, FALSE);
2115 pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
2118 #endif // IW_MLME_DEAUTH //
2119 #ifdef IW_MLME_DISASSOC
2120 case IW_MLME_DISASSOC:
2121 DBGPRINT(RT_DEBUG_TRACE, ("====> %s - IW_MLME_DISASSOC\n", __func__));
2122 COPY_MAC_ADDR(DisAssocReq.Addr, pAd->CommonCfg.Bssid);
2123 DisAssocReq.Reason = pMlme->reason_code;
2125 MsgElem.Machine = ASSOC_STATE_MACHINE;
2126 MsgElem.MsgType = MT2_MLME_DISASSOC_REQ;
2127 MsgElem.MsgLen = sizeof(MLME_DISASSOC_REQ_STRUCT);
2128 NdisMoveMemory(MsgElem.Msg, &DisAssocReq, sizeof(MLME_DISASSOC_REQ_STRUCT));
2130 pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_OID_DISASSOC;
2131 MlmeDisassocReqAction(pAd, &MsgElem);
2133 #endif // IW_MLME_DISASSOC //
2135 DBGPRINT(RT_DEBUG_TRACE, ("====> %s - Unknow Command\n", __func__));
2141 #endif // SIOCSIWMLME //
2143 #if WIRELESS_EXT > 17
2144 int rt_ioctl_siwauth(struct net_device *dev,
2145 struct iw_request_info *info,
2146 union iwreq_data *wrqu, char *extra)
2148 PRTMP_ADAPTER pAdapter = dev->ml_priv;
2149 struct iw_param *param = &wrqu->param;
2151 //check if the interface is down
2152 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
2154 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
2157 switch (param->flags & IW_AUTH_INDEX) {
2158 case IW_AUTH_WPA_VERSION:
2159 if (param->value == IW_AUTH_WPA_VERSION_WPA)
2161 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPAPSK;
2162 if (pAdapter->StaCfg.BssType == BSS_ADHOC)
2163 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPANone;
2165 else if (param->value == IW_AUTH_WPA_VERSION_WPA2)
2166 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA2PSK;
2168 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_WPA_VERSION - param->value = %d!\n", __func__, param->value));
2170 case IW_AUTH_CIPHER_PAIRWISE:
2171 if (param->value == IW_AUTH_CIPHER_NONE)
2173 pAdapter->StaCfg.WepStatus = Ndis802_11WEPDisabled;
2174 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
2175 pAdapter->StaCfg.PairCipher = Ndis802_11WEPDisabled;
2177 else if (param->value == IW_AUTH_CIPHER_WEP40 ||
2178 param->value == IW_AUTH_CIPHER_WEP104)
2180 pAdapter->StaCfg.WepStatus = Ndis802_11WEPEnabled;
2181 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
2182 pAdapter->StaCfg.PairCipher = Ndis802_11WEPEnabled;
2183 #ifdef WPA_SUPPLICANT_SUPPORT
2184 pAdapter->StaCfg.IEEE8021X = FALSE;
2185 #endif // WPA_SUPPLICANT_SUPPORT //
2187 else if (param->value == IW_AUTH_CIPHER_TKIP)
2189 pAdapter->StaCfg.WepStatus = Ndis802_11Encryption2Enabled;
2190 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
2191 pAdapter->StaCfg.PairCipher = Ndis802_11Encryption2Enabled;
2193 else if (param->value == IW_AUTH_CIPHER_CCMP)
2195 pAdapter->StaCfg.WepStatus = Ndis802_11Encryption3Enabled;
2196 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
2197 pAdapter->StaCfg.PairCipher = Ndis802_11Encryption3Enabled;
2199 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_CIPHER_PAIRWISE - param->value = %d!\n", __func__, param->value));
2201 case IW_AUTH_CIPHER_GROUP:
2202 if (param->value == IW_AUTH_CIPHER_NONE)
2204 pAdapter->StaCfg.GroupCipher = Ndis802_11WEPDisabled;
2206 else if (param->value == IW_AUTH_CIPHER_WEP40 ||
2207 param->value == IW_AUTH_CIPHER_WEP104)
2209 pAdapter->StaCfg.GroupCipher = Ndis802_11WEPEnabled;
2211 else if (param->value == IW_AUTH_CIPHER_TKIP)
2213 pAdapter->StaCfg.GroupCipher = Ndis802_11Encryption2Enabled;
2215 else if (param->value == IW_AUTH_CIPHER_CCMP)
2217 pAdapter->StaCfg.GroupCipher = Ndis802_11Encryption3Enabled;
2219 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_CIPHER_GROUP - param->value = %d!\n", __func__, param->value));
2221 case IW_AUTH_KEY_MGMT:
2222 if (param->value == IW_AUTH_KEY_MGMT_802_1X)
2224 if (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK)
2226 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA;
2227 #ifdef WPA_SUPPLICANT_SUPPORT
2228 pAdapter->StaCfg.IEEE8021X = FALSE;
2229 #endif // WPA_SUPPLICANT_SUPPORT //
2231 else if (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK)
2233 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA2;
2234 #ifdef WPA_SUPPLICANT_SUPPORT
2235 pAdapter->StaCfg.IEEE8021X = FALSE;
2236 #endif // WPA_SUPPLICANT_SUPPORT //
2238 #ifdef WPA_SUPPLICANT_SUPPORT
2241 pAdapter->StaCfg.IEEE8021X = TRUE;
2242 #endif // WPA_SUPPLICANT_SUPPORT //
2244 else if (param->value == 0)
2246 //pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
2247 STA_PORT_SECURED(pAdapter);
2249 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_KEY_MGMT - param->value = %d!\n", __func__, param->value));
2251 case IW_AUTH_RX_UNENCRYPTED_EAPOL:
2253 case IW_AUTH_PRIVACY_INVOKED:
2254 /*if (param->value == 0)
2256 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
2257 pAdapter->StaCfg.WepStatus = Ndis802_11WEPDisabled;
2258 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
2259 pAdapter->StaCfg.PairCipher = Ndis802_11WEPDisabled;
2260 pAdapter->StaCfg.GroupCipher = Ndis802_11WEPDisabled;
2262 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_PRIVACY_INVOKED - param->value = %d!\n", __func__, param->value));
2264 case IW_AUTH_DROP_UNENCRYPTED:
2265 if (param->value != 0)
2266 pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED;
2269 //pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
2270 STA_PORT_SECURED(pAdapter);
2272 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_WPA_VERSION - param->value = %d!\n", __func__, param->value));
2274 case IW_AUTH_80211_AUTH_ALG:
2275 if (param->value & IW_AUTH_ALG_SHARED_KEY)
2277 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeShared;
2279 else if (param->value & IW_AUTH_ALG_OPEN_SYSTEM)
2281 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
2285 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_80211_AUTH_ALG - param->value = %d!\n", __func__, param->value));
2287 case IW_AUTH_WPA_ENABLED:
2288 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_WPA_ENABLED - Driver supports WPA!(param->value = %d)\n", __func__, param->value));
2297 int rt_ioctl_giwauth(struct net_device *dev,
2298 struct iw_request_info *info,
2299 union iwreq_data *wrqu, char *extra)
2301 PRTMP_ADAPTER pAdapter = dev->ml_priv;
2302 struct iw_param *param = &wrqu->param;
2304 //check if the interface is down
2305 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
2307 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
2311 switch (param->flags & IW_AUTH_INDEX) {
2312 case IW_AUTH_DROP_UNENCRYPTED:
2313 param->value = (pAdapter->StaCfg.WepStatus == Ndis802_11WEPDisabled) ? 0 : 1;
2316 case IW_AUTH_80211_AUTH_ALG:
2317 param->value = (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeShared) ? IW_AUTH_ALG_SHARED_KEY : IW_AUTH_ALG_OPEN_SYSTEM;
2320 case IW_AUTH_WPA_ENABLED:
2321 param->value = (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA) ? 1 : 0;
2327 DBGPRINT(RT_DEBUG_TRACE, ("rt_ioctl_giwauth::param->value = %d!\n", param->value));
2331 void fnSetCipherKey(
2332 IN PRTMP_ADAPTER pAdapter,
2336 IN struct iw_encode_ext *ext)
2338 NdisZeroMemory(&pAdapter->SharedKey[BSS0][keyIdx], sizeof(CIPHER_KEY));
2339 pAdapter->SharedKey[BSS0][keyIdx].KeyLen = LEN_TKIP_EK;
2340 NdisMoveMemory(pAdapter->SharedKey[BSS0][keyIdx].Key, ext->key, LEN_TKIP_EK);
2341 NdisMoveMemory(pAdapter->SharedKey[BSS0][keyIdx].TxMic, ext->key + LEN_TKIP_EK, LEN_TKIP_TXMICK);
2342 NdisMoveMemory(pAdapter->SharedKey[BSS0][keyIdx].RxMic, ext->key + LEN_TKIP_EK + LEN_TKIP_TXMICK, LEN_TKIP_RXMICK);
2343 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CipherAlg;
2345 // Update group key information to ASIC Shared Key Table
2346 AsicAddSharedKeyEntry(pAdapter,
2349 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg,
2350 pAdapter->SharedKey[BSS0][keyIdx].Key,
2351 pAdapter->SharedKey[BSS0][keyIdx].TxMic,
2352 pAdapter->SharedKey[BSS0][keyIdx].RxMic);
2355 // Update ASIC WCID attribute table and IVEIV table
2356 RTMPAddWcidAttributeEntry(pAdapter,
2359 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg,
2362 // Update ASIC WCID attribute table and IVEIV table
2363 RTMPAddWcidAttributeEntry(pAdapter,
2366 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg,
2367 &pAdapter->MacTab.Content[BSSID_WCID]);
2370 int rt_ioctl_siwencodeext(struct net_device *dev,
2371 struct iw_request_info *info,
2372 union iwreq_data *wrqu,
2375 PRTMP_ADAPTER pAdapter = dev->ml_priv;
2376 struct iw_point *encoding = &wrqu->encoding;
2377 struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
2378 int keyIdx, alg = ext->alg;
2380 //check if the interface is down
2381 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
2383 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
2387 if (encoding->flags & IW_ENCODE_DISABLED)
2389 keyIdx = (encoding->flags & IW_ENCODE_INDEX) - 1;
2390 // set BSSID wcid entry of the Pair-wise Key table as no-security mode
2391 AsicRemovePairwiseKeyEntry(pAdapter, BSS0, BSSID_WCID);
2392 pAdapter->SharedKey[BSS0][keyIdx].KeyLen = 0;
2393 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CIPHER_NONE;
2394 AsicRemoveSharedKeyEntry(pAdapter, 0, (UCHAR)keyIdx);
2395 NdisZeroMemory(&pAdapter->SharedKey[BSS0][keyIdx], sizeof(CIPHER_KEY));
2396 DBGPRINT(RT_DEBUG_TRACE, ("%s::Remove all keys!(encoding->flags = %x)\n", __func__, encoding->flags));
2400 // Get Key Index and convet to our own defined key index
2401 keyIdx = (encoding->flags & IW_ENCODE_INDEX) - 1;
2402 if((keyIdx < 0) || (keyIdx >= NR_WEP_KEYS))
2405 if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
2407 pAdapter->StaCfg.DefaultKeyId = keyIdx;
2408 DBGPRINT(RT_DEBUG_TRACE, ("%s::DefaultKeyId = %d\n", __func__, pAdapter->StaCfg.DefaultKeyId));
2412 case IW_ENCODE_ALG_NONE:
2413 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_ENCODE_ALG_NONE\n", __func__));
2415 case IW_ENCODE_ALG_WEP:
2416 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_ENCODE_ALG_WEP - ext->key_len = %d, keyIdx = %d\n", __func__, ext->key_len, keyIdx));
2417 if (ext->key_len == MAX_WEP_KEY_SIZE)
2419 pAdapter->SharedKey[BSS0][keyIdx].KeyLen = MAX_WEP_KEY_SIZE;
2420 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CIPHER_WEP128;
2422 else if (ext->key_len == MIN_WEP_KEY_SIZE)
2424 pAdapter->SharedKey[BSS0][keyIdx].KeyLen = MIN_WEP_KEY_SIZE;
2425 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CIPHER_WEP64;
2430 NdisZeroMemory(pAdapter->SharedKey[BSS0][keyIdx].Key, 16);
2431 NdisMoveMemory(pAdapter->SharedKey[BSS0][keyIdx].Key, ext->key, ext->key_len);
2433 case IW_ENCODE_ALG_TKIP:
2434 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_ENCODE_ALG_TKIP - keyIdx = %d, ext->key_len = %d\n", __func__, keyIdx, ext->key_len));
2435 if (ext->key_len == 32)
2437 if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
2439 fnSetCipherKey(pAdapter, keyIdx, CIPHER_TKIP, FALSE, ext);
2440 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA2)
2442 //pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
2443 STA_PORT_SECURED(pAdapter);
2446 else if (ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY)
2448 fnSetCipherKey(pAdapter, keyIdx, CIPHER_TKIP, TRUE, ext);
2450 // set 802.1x port control
2451 //pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
2452 STA_PORT_SECURED(pAdapter);
2458 case IW_ENCODE_ALG_CCMP:
2459 if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
2461 fnSetCipherKey(pAdapter, keyIdx, CIPHER_AES, FALSE, ext);
2462 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA2)
2463 //pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
2464 STA_PORT_SECURED(pAdapter);
2466 else if (ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY)
2468 fnSetCipherKey(pAdapter, keyIdx, CIPHER_AES, TRUE, ext);
2470 // set 802.1x port control
2471 //pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
2472 STA_PORT_SECURED(pAdapter);
2484 rt_ioctl_giwencodeext(struct net_device *dev,
2485 struct iw_request_info *info,
2486 union iwreq_data *wrqu, char *extra)
2488 PRTMP_ADAPTER pAd = dev->ml_priv;
2490 struct iw_point *encoding = &wrqu->encoding;
2491 struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
2492 int idx, max_key_len;
2494 DBGPRINT(RT_DEBUG_TRACE ,("===> rt_ioctl_giwencodeext\n"));
2496 max_key_len = encoding->length - sizeof(*ext);
2497 if (max_key_len < 0)
2500 idx = encoding->flags & IW_ENCODE_INDEX;
2503 if (idx < 1 || idx > 4)
2507 if ((pAd->StaCfg.WepStatus == Ndis802_11Encryption2Enabled) ||
2508 (pAd->StaCfg.WepStatus == Ndis802_11Encryption3Enabled))
2510 if (idx != pAd->StaCfg.DefaultKeyId)
2518 idx = pAd->StaCfg.DefaultKeyId;
2520 encoding->flags = idx + 1;
2521 memset(ext, 0, sizeof(*ext));
2524 switch(pAd->StaCfg.WepStatus) {
2525 case Ndis802_11WEPDisabled:
2526 ext->alg = IW_ENCODE_ALG_NONE;
2527 encoding->flags |= IW_ENCODE_DISABLED;
2529 case Ndis802_11WEPEnabled:
2530 ext->alg = IW_ENCODE_ALG_WEP;
2531 if (pAd->SharedKey[BSS0][idx].KeyLen > max_key_len)
2535 ext->key_len = pAd->SharedKey[BSS0][idx].KeyLen;
2536 pKey = &(pAd->SharedKey[BSS0][idx].Key[0]);
2539 case Ndis802_11Encryption2Enabled:
2540 case Ndis802_11Encryption3Enabled:
2541 if (pAd->StaCfg.WepStatus == Ndis802_11Encryption2Enabled)
2542 ext->alg = IW_ENCODE_ALG_TKIP;
2544 ext->alg = IW_ENCODE_ALG_CCMP;
2546 if (max_key_len < 32)
2551 pKey = &pAd->StaCfg.PMK[0];
2558 if (ext->key_len && pKey)
2560 encoding->flags |= IW_ENCODE_ENABLED;
2561 memcpy(ext->key, pKey, ext->key_len);
2568 int rt_ioctl_siwgenie(struct net_device *dev,
2569 struct iw_request_info *info,
2570 union iwreq_data *wrqu, char *extra)
2572 PRTMP_ADAPTER pAd = dev->ml_priv;
2574 if (wrqu->data.length > MAX_LEN_OF_RSNIE ||
2575 (wrqu->data.length && extra == NULL))
2578 if (wrqu->data.length)
2580 pAd->StaCfg.RSNIE_Len = wrqu->data.length;
2581 NdisMoveMemory(&pAd->StaCfg.RSN_IE[0], extra, pAd->StaCfg.RSNIE_Len);
2585 pAd->StaCfg.RSNIE_Len = 0;
2586 NdisZeroMemory(&pAd->StaCfg.RSN_IE[0], MAX_LEN_OF_RSNIE);
2591 #endif // SIOCSIWGENIE //
2593 int rt_ioctl_giwgenie(struct net_device *dev,
2594 struct iw_request_info *info,
2595 union iwreq_data *wrqu, char *extra)
2597 PRTMP_ADAPTER pAd = dev->ml_priv;
2599 if ((pAd->StaCfg.RSNIE_Len == 0) ||
2600 (pAd->StaCfg.AuthMode < Ndis802_11AuthModeWPA))
2602 wrqu->data.length = 0;
2606 #ifdef NATIVE_WPA_SUPPLICANT_SUPPORT
2608 if (pAd->StaCfg.WpaSupplicantUP == WPA_SUPPLICANT_ENABLE)
2610 if (wrqu->data.length < pAd->StaCfg.RSNIE_Len)
2613 wrqu->data.length = pAd->StaCfg.RSNIE_Len;
2614 memcpy(extra, &pAd->StaCfg.RSN_IE[0], pAd->StaCfg.RSNIE_Len);
2617 #endif // SIOCSIWGENIE //
2618 #endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
2620 UCHAR RSNIe = IE_WPA;
2622 if (wrqu->data.length < (pAd->StaCfg.RSNIE_Len + 2)) // ID, Len
2624 wrqu->data.length = pAd->StaCfg.RSNIE_Len + 2;
2626 if ((pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK) ||
2627 (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2))
2630 extra[0] = (char)RSNIe;
2631 extra[1] = pAd->StaCfg.RSNIE_Len;
2632 memcpy(extra+2, &pAd->StaCfg.RSN_IE[0], pAd->StaCfg.RSNIE_Len);
2638 int rt_ioctl_siwpmksa(struct net_device *dev,
2639 struct iw_request_info *info,
2640 union iwreq_data *wrqu,
2643 PRTMP_ADAPTER pAd = dev->ml_priv;
2644 struct iw_pmksa *pPmksa = (struct iw_pmksa *)wrqu->data.pointer;
2645 INT CachedIdx = 0, idx = 0;
2650 DBGPRINT(RT_DEBUG_TRACE ,("===> rt_ioctl_siwpmksa\n"));
2653 case IW_PMKSA_FLUSH:
2654 NdisZeroMemory(pAd->StaCfg.SavedPMK, sizeof(BSSID_INFO)*PMKID_NO);
2655 DBGPRINT(RT_DEBUG_TRACE ,("rt_ioctl_siwpmksa - IW_PMKSA_FLUSH\n"));
2657 case IW_PMKSA_REMOVE:
2658 for (CachedIdx = 0; CachedIdx < pAd->StaCfg.SavedPMKNum; CachedIdx++)
2660 // compare the BSSID
2661 if (NdisEqualMemory(pPmksa->bssid.sa_data, pAd->StaCfg.SavedPMK[CachedIdx].BSSID, MAC_ADDR_LEN))
2663 NdisZeroMemory(pAd->StaCfg.SavedPMK[CachedIdx].BSSID, MAC_ADDR_LEN);
2664 NdisZeroMemory(pAd->StaCfg.SavedPMK[CachedIdx].PMKID, 16);
2665 for (idx = CachedIdx; idx < (pAd->StaCfg.SavedPMKNum - 1); idx++)
2667 NdisMoveMemory(&pAd->StaCfg.SavedPMK[idx].BSSID[0], &pAd->StaCfg.SavedPMK[idx+1].BSSID[0], MAC_ADDR_LEN);
2668 NdisMoveMemory(&pAd->StaCfg.SavedPMK[idx].PMKID[0], &pAd->StaCfg.SavedPMK[idx+1].PMKID[0], 16);
2670 pAd->StaCfg.SavedPMKNum--;
2675 DBGPRINT(RT_DEBUG_TRACE ,("rt_ioctl_siwpmksa - IW_PMKSA_REMOVE\n"));
2678 for (CachedIdx = 0; CachedIdx < pAd->StaCfg.SavedPMKNum; CachedIdx++)
2680 // compare the BSSID
2681 if (NdisEqualMemory(pPmksa->bssid.sa_data, pAd->StaCfg.SavedPMK[CachedIdx].BSSID, MAC_ADDR_LEN))
2685 // Found, replace it
2686 if (CachedIdx < PMKID_NO)
2688 DBGPRINT(RT_DEBUG_OFF, ("Update PMKID, idx = %d\n", CachedIdx));
2689 NdisMoveMemory(&pAd->StaCfg.SavedPMK[CachedIdx].BSSID[0], pPmksa->bssid.sa_data, MAC_ADDR_LEN);
2690 NdisMoveMemory(&pAd->StaCfg.SavedPMK[CachedIdx].PMKID[0], pPmksa->pmkid, 16);
2691 pAd->StaCfg.SavedPMKNum++;
2693 // Not found, replace the last one
2696 // Randomly replace one
2697 CachedIdx = (pPmksa->bssid.sa_data[5] % PMKID_NO);
2698 DBGPRINT(RT_DEBUG_OFF, ("Update PMKID, idx = %d\n", CachedIdx));
2699 NdisMoveMemory(&pAd->StaCfg.SavedPMK[CachedIdx].BSSID[0], pPmksa->bssid.sa_data, MAC_ADDR_LEN);
2700 NdisMoveMemory(&pAd->StaCfg.SavedPMK[CachedIdx].PMKID[0], pPmksa->pmkid, 16);
2703 DBGPRINT(RT_DEBUG_TRACE ,("rt_ioctl_siwpmksa - IW_PMKSA_ADD\n"));
2706 DBGPRINT(RT_DEBUG_TRACE ,("rt_ioctl_siwpmksa - Unknow Command!!\n"));
2712 #endif // #if WIRELESS_EXT > 17
2716 rt_private_ioctl_bbp(struct net_device *dev, struct iw_request_info *info,
2717 struct iw_point *wrq, char *extra)
2722 // CHAR arg[255]={0};
2725 BOOLEAN bIsPrintAllBBP = FALSE;
2727 PRTMP_ADAPTER pAdapter = dev->ml_priv;
2730 memset(extra, 0x00, IW_PRIV_SIZE_MASK);
2732 if (wrq->length > 1) //No parameters.
2734 sprintf(extra, "\n");
2736 //Parsing Read or Write
2737 this_char = wrq->pointer;
2738 DBGPRINT(RT_DEBUG_TRACE, ("this_char=%s\n", this_char));
2742 if ((value = rtstrchr(this_char, '=')) != NULL)
2745 if (!value || !*value)
2747 DBGPRINT(RT_DEBUG_TRACE, ("this_char=%s, value=%s\n", this_char, value));
2748 if (sscanf(this_char, "%d", &(bbpId)) == 1)
2754 if (bbpId <= 138) // edit by johnli, RF power sequence setup, add BBP R138 for ADC dynamic on/off control
2758 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, ®BBP);
2760 sprintf(extra+strlen(extra), "R%02d[0x%02X]:%02X\n", bbpId, bbpId*2, regBBP);
2761 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2762 DBGPRINT(RT_DEBUG_TRACE, ("msg=%s\n", extra));
2765 {//Invalid parametes, so default printk all bbp
2766 bIsPrintAllBBP = TRUE;
2771 { //Invalid parametes, so default printk all bbp
2772 bIsPrintAllBBP = TRUE;
2778 if ((sscanf(this_char, "%d", &(bbpId)) == 1) && (sscanf(value, "%x", &(bbpValue)) == 1))
2784 if (bbpId <= 138) // edit by johnli, RF power sequence setup, add BBP R138 for ADC dynamic on/off control
2788 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, bbpId, bbpValue);
2789 //Read it back for showing
2790 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, ®BBP);
2792 sprintf(extra+strlen(extra), "R%02d[0x%02X]:%02X\n", bbpId, bbpId*2, regBBP);
2793 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2794 DBGPRINT(RT_DEBUG_TRACE, ("msg=%s\n", extra));
2797 {//Invalid parametes, so default printk all bbp
2798 bIsPrintAllBBP = TRUE;
2803 { //Invalid parametes, so default printk all bbp
2804 bIsPrintAllBBP = TRUE;
2810 bIsPrintAllBBP = TRUE;
2815 memset(extra, 0x00, IW_PRIV_SIZE_MASK);
2816 sprintf(extra, "\n");
2818 for (bbpId = 0; bbpId <= 136; bbpId++)
2821 for (bbpId = 0; bbpId <= 138; bbpId++) // edit by johnli, RF power sequence setup, add BBP R138 for ADC dynamic on/off control
2824 if (strlen(extra) >= (IW_PRIV_SIZE_MASK - 10))
2826 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, ®BBP);
2828 sprintf(extra+strlen(extra), "R%02d[0x%02X]:%02X ", bbpId, bbpId*2, regBBP);
2830 sprintf(extra+strlen(extra), "\n");
2832 sprintf(extra+strlen(extra), "%03d = %02X\n", bbpId, regBBP); // edit by johnli, change display format
2835 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2836 DBGPRINT(RT_DEBUG_TRACE, ("wrq->length = %d\n", wrq->length));
2839 DBGPRINT(RT_DEBUG_TRACE, ("<==rt_private_ioctl_bbp\n\n"));
2845 int rt_ioctl_siwrate(struct net_device *dev,
2846 struct iw_request_info *info,
2847 union iwreq_data *wrqu, char *extra)
2849 PRTMP_ADAPTER pAd = dev->ml_priv;
2850 UINT32 rate = wrqu->bitrate.value, fixed = wrqu->bitrate.fixed;
2852 //check if the interface is down
2853 if(!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_IN_USE))
2855 DBGPRINT(RT_DEBUG_TRACE, ("rt_ioctl_siwrate::Network is down!\n"));
2859 DBGPRINT(RT_DEBUG_TRACE, ("rt_ioctl_siwrate::(rate = %d, fixed = %d)\n", rate, fixed));
2860 /* rate = -1 => auto rate
2861 rate = X, fixed = 1 => (fixed rate X)
2866 pAd->StaCfg.DesiredTransmitSetting.field.MCS = MCS_AUTO;
2867 pAd->StaCfg.bAutoTxRateSwitch = TRUE;
2868 if ((pAd->CommonCfg.PhyMode <= PHY_11G) ||
2869 (pAd->MacTab.Content[BSSID_WCID].HTPhyMode.field.MODE <= MODE_OFDM))
2870 RTMPSetDesiredRates(pAd, -1);
2872 #ifdef DOT11_N_SUPPORT
2874 #endif // DOT11_N_SUPPORT //
2880 pAd->StaCfg.bAutoTxRateSwitch = FALSE;
2881 if ((pAd->CommonCfg.PhyMode <= PHY_11G) ||
2882 (pAd->MacTab.Content[BSSID_WCID].HTPhyMode.field.MODE <= MODE_OFDM))
2883 RTMPSetDesiredRates(pAd, rate);
2886 pAd->StaCfg.DesiredTransmitSetting.field.MCS = MCS_AUTO;
2887 #ifdef DOT11_N_SUPPORT
2889 #endif // DOT11_N_SUPPORT //
2891 DBGPRINT(RT_DEBUG_TRACE, ("rt_ioctl_siwrate::(HtMcs=%d)\n",pAd->StaCfg.DesiredTransmitSetting.field.MCS));
2895 // TODO: rate = X, fixed = 0 => (rates <= X)
2903 int rt_ioctl_giwrate(struct net_device *dev,
2904 struct iw_request_info *info,
2905 union iwreq_data *wrqu, char *extra)
2907 PRTMP_ADAPTER pAd = dev->ml_priv;
2908 int rate_index = 0, rate_count = 0;
2909 HTTRANSMIT_SETTING ht_setting;
2910 __s32 ralinkrate[] =
2911 {2, 4, 11, 22, // CCK
2912 12, 18, 24, 36, 48, 72, 96, 108, // OFDM
2913 13, 26, 39, 52, 78, 104, 117, 130, 26, 52, 78, 104, 156, 208, 234, 260, // 20MHz, 800ns GI, MCS: 0 ~ 15
2914 39, 78, 117, 156, 234, 312, 351, 390, // 20MHz, 800ns GI, MCS: 16 ~ 23
2915 27, 54, 81, 108, 162, 216, 243, 270, 54, 108, 162, 216, 324, 432, 486, 540, // 40MHz, 800ns GI, MCS: 0 ~ 15
2916 81, 162, 243, 324, 486, 648, 729, 810, // 40MHz, 800ns GI, MCS: 16 ~ 23
2917 14, 29, 43, 57, 87, 115, 130, 144, 29, 59, 87, 115, 173, 230, 260, 288, // 20MHz, 400ns GI, MCS: 0 ~ 15
2918 43, 87, 130, 173, 260, 317, 390, 433, // 20MHz, 400ns GI, MCS: 16 ~ 23
2919 30, 60, 90, 120, 180, 240, 270, 300, 60, 120, 180, 240, 360, 480, 540, 600, // 40MHz, 400ns GI, MCS: 0 ~ 15
2920 90, 180, 270, 360, 540, 720, 810, 900}; // 40MHz, 400ns GI, MCS: 16 ~ 23
2922 rate_count = sizeof(ralinkrate)/sizeof(__s32);
2923 //check if the interface is down
2924 if(!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_IN_USE))
2926 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
2930 if ((pAd->StaCfg.bAutoTxRateSwitch == FALSE) &&
2932 ((pAd->CommonCfg.PhyMode <= PHY_11G) || (pAd->MacTab.Content[BSSID_WCID].HTPhyMode.field.MODE <= MODE_OFDM)))
2933 ht_setting.word = pAd->StaCfg.HTPhyMode.word;
2935 ht_setting.word = pAd->MacTab.Content[BSSID_WCID].HTPhyMode.word;
2937 #ifdef DOT11_N_SUPPORT
2938 if (ht_setting.field.MODE >= MODE_HTMIX)
2940 // rate_index = 12 + ((UCHAR)ht_setting.field.BW *16) + ((UCHAR)ht_setting.field.ShortGI *32) + ((UCHAR)ht_setting.field.MCS);
2941 rate_index = 12 + ((UCHAR)ht_setting.field.BW *24) + ((UCHAR)ht_setting.field.ShortGI *48) + ((UCHAR)ht_setting.field.MCS);
2944 #endif // DOT11_N_SUPPORT //
2945 if (ht_setting.field.MODE == MODE_OFDM)
2946 rate_index = (UCHAR)(ht_setting.field.MCS) + 4;
2947 else if (ht_setting.field.MODE == MODE_CCK)
2948 rate_index = (UCHAR)(ht_setting.field.MCS);
2953 if (rate_index > rate_count)
2954 rate_index = rate_count;
2956 wrqu->bitrate.value = ralinkrate[rate_index] * 500000;
2957 wrqu->bitrate.disabled = 0;
2962 static const iw_handler rt_handler[] =
2964 (iw_handler) NULL, /* SIOCSIWCOMMIT */
2965 (iw_handler) rt_ioctl_giwname, /* SIOCGIWNAME */
2966 (iw_handler) NULL, /* SIOCSIWNWID */
2967 (iw_handler) NULL, /* SIOCGIWNWID */
2968 (iw_handler) rt_ioctl_siwfreq, /* SIOCSIWFREQ */
2969 (iw_handler) rt_ioctl_giwfreq, /* SIOCGIWFREQ */
2970 (iw_handler) rt_ioctl_siwmode, /* SIOCSIWMODE */
2971 (iw_handler) rt_ioctl_giwmode, /* SIOCGIWMODE */
2972 (iw_handler) NULL, /* SIOCSIWSENS */
2973 (iw_handler) NULL, /* SIOCGIWSENS */
2974 (iw_handler) NULL /* not used */, /* SIOCSIWRANGE */
2975 (iw_handler) rt_ioctl_giwrange, /* SIOCGIWRANGE */
2976 (iw_handler) NULL /* not used */, /* SIOCSIWPRIV */
2977 (iw_handler) NULL /* kernel code */, /* SIOCGIWPRIV */
2978 (iw_handler) NULL /* not used */, /* SIOCSIWSTATS */
2979 (iw_handler) rt28xx_get_wireless_stats /* kernel code */, /* SIOCGIWSTATS */
2980 (iw_handler) NULL, /* SIOCSIWSPY */
2981 (iw_handler) NULL, /* SIOCGIWSPY */
2982 (iw_handler) NULL, /* SIOCSIWTHRSPY */
2983 (iw_handler) NULL, /* SIOCGIWTHRSPY */
2984 (iw_handler) rt_ioctl_siwap, /* SIOCSIWAP */
2985 (iw_handler) rt_ioctl_giwap, /* SIOCGIWAP */
2987 (iw_handler) rt_ioctl_siwmlme, /* SIOCSIWMLME */
2989 (iw_handler) NULL, /* SIOCSIWMLME */
2990 #endif // SIOCSIWMLME //
2991 (iw_handler) rt_ioctl_iwaplist, /* SIOCGIWAPLIST */
2993 (iw_handler) rt_ioctl_siwscan, /* SIOCSIWSCAN */
2994 (iw_handler) rt_ioctl_giwscan, /* SIOCGIWSCAN */
2996 (iw_handler) NULL, /* SIOCSIWSCAN */
2997 (iw_handler) NULL, /* SIOCGIWSCAN */
2998 #endif /* SIOCGIWSCAN */
2999 (iw_handler) rt_ioctl_siwessid, /* SIOCSIWESSID */
3000 (iw_handler) rt_ioctl_giwessid, /* SIOCGIWESSID */
3001 (iw_handler) rt_ioctl_siwnickn, /* SIOCSIWNICKN */
3002 (iw_handler) rt_ioctl_giwnickn, /* SIOCGIWNICKN */
3003 (iw_handler) NULL, /* -- hole -- */
3004 (iw_handler) NULL, /* -- hole -- */
3005 (iw_handler) rt_ioctl_siwrate, /* SIOCSIWRATE */
3006 (iw_handler) rt_ioctl_giwrate, /* SIOCGIWRATE */
3007 (iw_handler) rt_ioctl_siwrts, /* SIOCSIWRTS */
3008 (iw_handler) rt_ioctl_giwrts, /* SIOCGIWRTS */
3009 (iw_handler) rt_ioctl_siwfrag, /* SIOCSIWFRAG */
3010 (iw_handler) rt_ioctl_giwfrag, /* SIOCGIWFRAG */
3011 (iw_handler) NULL, /* SIOCSIWTXPOW */
3012 (iw_handler) NULL, /* SIOCGIWTXPOW */
3013 (iw_handler) NULL, /* SIOCSIWRETRY */
3014 (iw_handler) NULL, /* SIOCGIWRETRY */
3015 (iw_handler) rt_ioctl_siwencode, /* SIOCSIWENCODE */
3016 (iw_handler) rt_ioctl_giwencode, /* SIOCGIWENCODE */
3017 (iw_handler) NULL, /* SIOCSIWPOWER */
3018 (iw_handler) NULL, /* SIOCGIWPOWER */
3019 (iw_handler) NULL, /* -- hole -- */
3020 (iw_handler) NULL, /* -- hole -- */
3021 #if WIRELESS_EXT > 17
3022 (iw_handler) rt_ioctl_siwgenie, /* SIOCSIWGENIE */
3023 (iw_handler) rt_ioctl_giwgenie, /* SIOCGIWGENIE */
3024 (iw_handler) rt_ioctl_siwauth, /* SIOCSIWAUTH */
3025 (iw_handler) rt_ioctl_giwauth, /* SIOCGIWAUTH */
3026 (iw_handler) rt_ioctl_siwencodeext, /* SIOCSIWENCODEEXT */
3027 (iw_handler) rt_ioctl_giwencodeext, /* SIOCGIWENCODEEXT */
3028 (iw_handler) rt_ioctl_siwpmksa, /* SIOCSIWPMKSA */
3032 static const iw_handler rt_priv_handlers[] = {
3033 (iw_handler) NULL, /* + 0x00 */
3034 (iw_handler) NULL, /* + 0x01 */
3035 #ifndef CONFIG_AP_SUPPORT
3036 (iw_handler) rt_ioctl_setparam, /* + 0x02 */
3038 (iw_handler) NULL, /* + 0x02 */
3039 #endif // CONFIG_AP_SUPPORT //
3041 (iw_handler) rt_private_ioctl_bbp, /* + 0x03 */
3043 (iw_handler) NULL, /* + 0x03 */
3045 (iw_handler) NULL, /* + 0x04 */
3046 (iw_handler) NULL, /* + 0x05 */
3047 (iw_handler) NULL, /* + 0x06 */
3048 (iw_handler) NULL, /* + 0x07 */
3049 (iw_handler) NULL, /* + 0x08 */
3050 (iw_handler) rt_private_get_statistics, /* + 0x09 */
3051 (iw_handler) NULL, /* + 0x0A */
3052 (iw_handler) NULL, /* + 0x0B */
3053 (iw_handler) NULL, /* + 0x0C */
3054 (iw_handler) NULL, /* + 0x0D */
3055 (iw_handler) NULL, /* + 0x0E */
3056 (iw_handler) NULL, /* + 0x0F */
3057 (iw_handler) NULL, /* + 0x10 */
3058 (iw_handler) rt_private_show, /* + 0x11 */
3059 (iw_handler) NULL, /* + 0x12 */
3060 (iw_handler) NULL, /* + 0x13 */
3061 (iw_handler) NULL, /* + 0x15 */
3062 (iw_handler) NULL, /* + 0x17 */
3063 (iw_handler) NULL, /* + 0x18 */
3066 const struct iw_handler_def rt28xx_iw_handler_def =
3068 #define N(a) (sizeof (a) / sizeof (a[0]))
3069 .standard = (iw_handler *) rt_handler,
3070 .num_standard = sizeof(rt_handler) / sizeof(iw_handler),
3071 .private = (iw_handler *) rt_priv_handlers,
3072 .num_private = N(rt_priv_handlers),
3073 .private_args = (struct iw_priv_args *) privtab,
3074 .num_private_args = N(privtab),
3075 #if IW_HANDLER_VERSION >= 7
3076 .get_wireless_stats = rt28xx_get_wireless_stats,
3080 INT RTMPSetInformation(
3081 IN PRTMP_ADAPTER pAdapter,
3082 IN OUT struct ifreq *rq,
3085 struct iwreq *wrq = (struct iwreq *) rq;
3086 NDIS_802_11_SSID Ssid;
3087 NDIS_802_11_MAC_ADDRESS Bssid;
3088 RT_802_11_PHY_MODE PhyMode;
3089 RT_802_11_STA_CONFIG StaConfig;
3090 NDIS_802_11_RATES aryRates;
3091 RT_802_11_PREAMBLE Preamble;
3092 NDIS_802_11_WEP_STATUS WepStatus;
3093 NDIS_802_11_AUTHENTICATION_MODE AuthMode = Ndis802_11AuthModeMax;
3094 NDIS_802_11_NETWORK_INFRASTRUCTURE BssType;
3095 NDIS_802_11_RTS_THRESHOLD RtsThresh;
3096 NDIS_802_11_FRAGMENTATION_THRESHOLD FragThresh;
3097 NDIS_802_11_POWER_MODE PowerMode;
3098 PNDIS_802_11_KEY pKey = NULL;
3099 PNDIS_802_11_WEP pWepKey =NULL;
3100 PNDIS_802_11_REMOVE_KEY pRemoveKey = NULL;
3101 NDIS_802_11_CONFIGURATION Config, *pConfig = NULL;
3102 NDIS_802_11_NETWORK_TYPE NetType;
3105 INT Status = NDIS_STATUS_SUCCESS, MaxPhyMode = PHY_11G;
3108 BOOLEAN StateMachineTouched = FALSE;
3109 #ifdef DOT11_N_SUPPORT
3110 OID_SET_HT_PHYMODE HT_PhyMode; //11n ,kathy
3111 #endif // DOT11_N_SUPPORT //
3112 #ifdef WPA_SUPPLICANT_SUPPORT
3113 PNDIS_802_11_PMKID pPmkId = NULL;
3114 BOOLEAN IEEE8021xState = FALSE;
3115 BOOLEAN IEEE8021x_required_keys = FALSE;
3116 UCHAR wpa_supplicant_enable = 0;
3117 #endif // WPA_SUPPLICANT_SUPPORT //
3120 TX_RTY_CFG_STRUC tx_rty_cfg;
3121 ULONG ShortRetryLimit, LongRetryLimit;
3123 #endif // SNMP_SUPPORT //
3126 #ifdef DOT11_N_SUPPORT
3127 MaxPhyMode = PHY_11N_5G;
3128 #endif // DOT11_N_SUPPORT //
3131 DBGPRINT(RT_DEBUG_TRACE, ("-->RTMPSetInformation(), 0x%08x\n", cmd&0x7FFF));
3132 switch(cmd & 0x7FFF) {
3133 case RT_OID_802_11_COUNTRY_REGION:
3134 if (wrq->u.data.length < sizeof(UCHAR))
3136 // Only avaliable when EEPROM not programming
3137 else if (!(pAdapter->CommonCfg.CountryRegion & 0x80) && !(pAdapter->CommonCfg.CountryRegionForABand & 0x80))
3142 Status = copy_from_user(&Country, wrq->u.data.pointer, wrq->u.data.length);
3143 pAdapter->CommonCfg.CountryRegion = (UCHAR)(Country & 0x000000FF);
3144 pAdapter->CommonCfg.CountryRegionForABand = (UCHAR)((Country >> 8) & 0x000000FF);
3145 TmpPhy = pAdapter->CommonCfg.PhyMode;
3146 pAdapter->CommonCfg.PhyMode = 0xff;
3147 // Build all corresponding channel information
3148 RTMPSetPhyMode(pAdapter, TmpPhy);
3149 #ifdef DOT11_N_SUPPORT
3150 SetCommonHT(pAdapter);
3151 #endif // DOT11_N_SUPPORT //
3152 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_COUNTRY_REGION (A:%d B/G:%d)\n", pAdapter->CommonCfg.CountryRegionForABand,
3153 pAdapter->CommonCfg.CountryRegion));
3156 case OID_802_11_BSSID_LIST_SCAN:
3158 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_BSSID_LIST_SCAN, TxCnt = %d \n", pAdapter->RalinkCounters.LastOneSecTotalTxCount));
3160 if (MONITOR_ON(pAdapter))
3162 DBGPRINT(RT_DEBUG_TRACE, ("!!! Driver is in Monitor Mode now !!!\n"));
3166 //Benson add 20080527, when radio off, sta don't need to scan
3167 if (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_RADIO_OFF))
3170 if (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
3172 DBGPRINT(RT_DEBUG_TRACE, ("!!! Driver is scanning now !!!\n"));
3173 pAdapter->StaCfg.bScanReqIsFromWebUI = TRUE;
3174 Status = NDIS_STATUS_SUCCESS;
3178 if (pAdapter->RalinkCounters.LastOneSecTotalTxCount > 100)
3180 DBGPRINT(RT_DEBUG_TRACE, ("!!! Link UP, ignore this set::OID_802_11_BSSID_LIST_SCAN\n"));
3181 Status = NDIS_STATUS_SUCCESS;
3182 pAdapter->StaCfg.ScanCnt = 99; // Prevent auto scan triggered by this OID
3186 if ((OPSTATUS_TEST_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED)) &&
3187 ((pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA) ||
3188 (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK) ||
3189 (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA2) ||
3190 (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK)) &&
3191 (pAdapter->StaCfg.PortSecured == WPA_802_1X_PORT_NOT_SECURED))
3193 DBGPRINT(RT_DEBUG_TRACE, ("!!! Link UP, Port Not Secured! ignore this set::OID_802_11_BSSID_LIST_SCAN\n"));
3194 Status = NDIS_STATUS_SUCCESS;
3195 pAdapter->StaCfg.ScanCnt = 99; // Prevent auto scan triggered by this OID
3200 if (pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE)
3202 RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
3203 DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
3206 // tell CNTL state machine to call NdisMSetInformationComplete() after completing
3207 // this request, because this request is initiated by NDIS.
3208 pAdapter->MlmeAux.CurrReqIsFromNdis = FALSE;
3209 // Reset allowed scan retries
3210 pAdapter->StaCfg.ScanCnt = 0;
3211 pAdapter->StaCfg.LastScanTime = Now;
3213 pAdapter->StaCfg.bScanReqIsFromWebUI = TRUE;
3214 RTMP_SET_FLAG(pAdapter, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS);
3215 MlmeEnqueue(pAdapter,
3216 MLME_CNTL_STATE_MACHINE,
3217 OID_802_11_BSSID_LIST_SCAN,
3221 Status = NDIS_STATUS_SUCCESS;
3222 StateMachineTouched = TRUE;
3224 case OID_802_11_SSID:
3225 if (wrq->u.data.length != sizeof(NDIS_802_11_SSID))
3229 PCHAR pSsidString = NULL;
3230 Status = copy_from_user(&Ssid, wrq->u.data.pointer, wrq->u.data.length);
3232 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_SSID (Len=%d,Ssid=%s)\n", Ssid.SsidLength, Ssid.Ssid));
3233 if (Ssid.SsidLength > MAX_LEN_OF_SSID)
3237 if (Ssid.SsidLength == 0)
3239 Set_SSID_Proc(pAdapter, "");
3243 pSsidString = (CHAR *) kmalloc(MAX_LEN_OF_SSID+1, MEM_ALLOC_FLAG);
3246 NdisZeroMemory(pSsidString, MAX_LEN_OF_SSID+1);
3247 NdisMoveMemory(pSsidString, Ssid.Ssid, Ssid.SsidLength);
3248 Set_SSID_Proc(pAdapter, pSsidString);
3257 case OID_802_11_BSSID:
3258 if (wrq->u.data.length != sizeof(NDIS_802_11_MAC_ADDRESS))
3262 Status = copy_from_user(&Bssid, wrq->u.data.pointer, wrq->u.data.length);
3264 // tell CNTL state machine to call NdisMSetInformationComplete() after completing
3265 // this request, because this request is initiated by NDIS.
3266 pAdapter->MlmeAux.CurrReqIsFromNdis = FALSE;
3268 // Prevent to connect AP again in STAMlmePeriodicExec
3269 pAdapter->MlmeAux.AutoReconnectSsidLen= 32;
3271 // Reset allowed scan retries
3272 pAdapter->StaCfg.ScanCnt = 0;
3274 if (pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE)
3276 RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
3277 DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
3279 MlmeEnqueue(pAdapter,
3280 MLME_CNTL_STATE_MACHINE,
3282 sizeof(NDIS_802_11_MAC_ADDRESS),
3284 Status = NDIS_STATUS_SUCCESS;
3285 StateMachineTouched = TRUE;
3287 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_BSSID %02x:%02x:%02x:%02x:%02x:%02x\n",
3288 Bssid[0], Bssid[1], Bssid[2], Bssid[3], Bssid[4], Bssid[5]));
3291 case RT_OID_802_11_RADIO:
3292 if (wrq->u.data.length != sizeof(BOOLEAN))
3296 Status = copy_from_user(&RadioState, wrq->u.data.pointer, wrq->u.data.length);
3297 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_RADIO (=%d)\n", RadioState));
3298 if (pAdapter->StaCfg.bSwRadio != RadioState)
3300 pAdapter->StaCfg.bSwRadio = RadioState;
3301 if (pAdapter->StaCfg.bRadio != (pAdapter->StaCfg.bHwRadio && pAdapter->StaCfg.bSwRadio))
3303 pAdapter->StaCfg.bRadio = (pAdapter->StaCfg.bHwRadio && pAdapter->StaCfg.bSwRadio);
3304 if (pAdapter->StaCfg.bRadio == TRUE)
3306 MlmeRadioOn(pAdapter);
3307 // Update extra information
3308 pAdapter->ExtraInfo = EXTRA_INFO_CLEAR;
3312 MlmeRadioOff(pAdapter);
3313 // Update extra information
3314 pAdapter->ExtraInfo = SW_RADIO_OFF;
3320 case RT_OID_802_11_PHY_MODE:
3321 if (wrq->u.data.length != sizeof(RT_802_11_PHY_MODE))
3325 Status = copy_from_user(&PhyMode, wrq->u.data.pointer, wrq->u.data.length);
3326 if (PhyMode <= MaxPhyMode)
3328 RTMPSetPhyMode(pAdapter, PhyMode);
3329 #ifdef DOT11_N_SUPPORT
3330 SetCommonHT(pAdapter);
3331 #endif // DOT11_N_SUPPORT //
3333 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_PHY_MODE (=%d)\n", PhyMode));
3336 case RT_OID_802_11_STA_CONFIG:
3337 if (wrq->u.data.length != sizeof(RT_802_11_STA_CONFIG))
3341 Status = copy_from_user(&StaConfig, wrq->u.data.pointer, wrq->u.data.length);
3342 pAdapter->CommonCfg.bEnableTxBurst = StaConfig.EnableTxBurst;
3343 pAdapter->CommonCfg.UseBGProtection = StaConfig.UseBGProtection;
3344 pAdapter->CommonCfg.bUseShortSlotTime = 1; // 2003-10-30 always SHORT SLOT capable
3345 if ((pAdapter->CommonCfg.PhyMode != StaConfig.AdhocMode) &&
3346 (StaConfig.AdhocMode <= MaxPhyMode))
3348 // allow dynamic change of "USE OFDM rate or not" in ADHOC mode
3349 // if setting changed, need to reset current TX rate as well as BEACON frame format
3350 pAdapter->CommonCfg.PhyMode = StaConfig.AdhocMode;
3351 if (pAdapter->StaCfg.BssType == BSS_ADHOC)
3353 RTMPSetPhyMode(pAdapter, PhyMode);
3354 MlmeUpdateTxRates(pAdapter, FALSE, 0);
3355 MakeIbssBeacon(pAdapter); // re-build BEACON frame
3356 AsicEnableIbssSync(pAdapter); // copy to on-chip memory
3359 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_SET_STA_CONFIG (Burst=%d, Protection=%ld,ShortSlot=%d\n",
3360 pAdapter->CommonCfg.bEnableTxBurst,
3361 pAdapter->CommonCfg.UseBGProtection,
3362 pAdapter->CommonCfg.bUseShortSlotTime));
3365 case OID_802_11_DESIRED_RATES:
3366 if (wrq->u.data.length != sizeof(NDIS_802_11_RATES))
3370 Status = copy_from_user(&aryRates, wrq->u.data.pointer, wrq->u.data.length);
3371 NdisZeroMemory(pAdapter->CommonCfg.DesireRate, MAX_LEN_OF_SUPPORTED_RATES);
3372 NdisMoveMemory(pAdapter->CommonCfg.DesireRate, &aryRates, sizeof(NDIS_802_11_RATES));
3373 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_DESIRED_RATES (%02x,%02x,%02x,%02x,%02x,%02x,%02x,%02x)\n",
3374 pAdapter->CommonCfg.DesireRate[0],pAdapter->CommonCfg.DesireRate[1],
3375 pAdapter->CommonCfg.DesireRate[2],pAdapter->CommonCfg.DesireRate[3],
3376 pAdapter->CommonCfg.DesireRate[4],pAdapter->CommonCfg.DesireRate[5],
3377 pAdapter->CommonCfg.DesireRate[6],pAdapter->CommonCfg.DesireRate[7] ));
3378 // Changing DesiredRate may affect the MAX TX rate we used to TX frames out
3379 MlmeUpdateTxRates(pAdapter, FALSE, 0);
3382 case RT_OID_802_11_PREAMBLE:
3383 if (wrq->u.data.length != sizeof(RT_802_11_PREAMBLE))
3387 Status = copy_from_user(&Preamble, wrq->u.data.pointer, wrq->u.data.length);
3388 if (Preamble == Rt802_11PreambleShort)
3390 pAdapter->CommonCfg.TxPreamble = Preamble;
3391 MlmeSetTxPreamble(pAdapter, Rt802_11PreambleShort);
3393 else if ((Preamble == Rt802_11PreambleLong) || (Preamble == Rt802_11PreambleAuto))
3395 // if user wants AUTO, initialize to LONG here, then change according to AP's
3396 // capability upon association.
3397 pAdapter->CommonCfg.TxPreamble = Preamble;
3398 MlmeSetTxPreamble(pAdapter, Rt802_11PreambleLong);
3405 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_PREAMBLE (=%d)\n", Preamble));
3408 case OID_802_11_WEP_STATUS:
3409 if (wrq->u.data.length != sizeof(NDIS_802_11_WEP_STATUS))
3413 Status = copy_from_user(&WepStatus, wrq->u.data.pointer, wrq->u.data.length);
3414 // Since TKIP, AES, WEP are all supported. It should not have any invalid setting
3415 if (WepStatus <= Ndis802_11Encryption3KeyAbsent)
3417 if (pAdapter->StaCfg.WepStatus != WepStatus)
3419 // Config has changed
3420 pAdapter->bConfigChanged = TRUE;
3422 pAdapter->StaCfg.WepStatus = WepStatus;
3423 pAdapter->StaCfg.OrigWepStatus = WepStatus;
3424 pAdapter->StaCfg.PairCipher = WepStatus;
3425 pAdapter->StaCfg.GroupCipher = WepStatus;
3432 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_WEP_STATUS (=%d)\n",WepStatus));
3435 case OID_802_11_AUTHENTICATION_MODE:
3436 if (wrq->u.data.length != sizeof(NDIS_802_11_AUTHENTICATION_MODE))
3440 Status = copy_from_user(&AuthMode, wrq->u.data.pointer, wrq->u.data.length);
3441 if (AuthMode > Ndis802_11AuthModeMax)
3448 if (pAdapter->StaCfg.AuthMode != AuthMode)
3450 // Config has changed
3451 pAdapter->bConfigChanged = TRUE;
3453 pAdapter->StaCfg.AuthMode = AuthMode;
3455 pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED;
3456 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_AUTHENTICATION_MODE (=%d) \n",pAdapter->StaCfg.AuthMode));
3459 case OID_802_11_INFRASTRUCTURE_MODE:
3460 if (wrq->u.data.length != sizeof(NDIS_802_11_NETWORK_INFRASTRUCTURE))
3464 Status = copy_from_user(&BssType, wrq->u.data.pointer, wrq->u.data.length);
3466 if (BssType == Ndis802_11IBSS)
3467 Set_NetworkType_Proc(pAdapter, "Adhoc");
3468 else if (BssType == Ndis802_11Infrastructure)
3469 Set_NetworkType_Proc(pAdapter, "Infra");
3470 else if (BssType == Ndis802_11Monitor)
3471 Set_NetworkType_Proc(pAdapter, "Monitor");
3475 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_INFRASTRUCTURE_MODE (unknown)\n"));
3479 case OID_802_11_REMOVE_WEP:
3480 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_WEP\n"));
3481 if (wrq->u.data.length != sizeof(NDIS_802_11_KEY_INDEX))
3487 KeyIdx = *(NDIS_802_11_KEY_INDEX *) wrq->u.data.pointer;
3489 if (KeyIdx & 0x80000000)
3491 // Should never set default bit when remove key
3496 KeyIdx = KeyIdx & 0x0fffffff;
3502 pAdapter->SharedKey[BSS0][KeyIdx].KeyLen = 0;
3503 pAdapter->SharedKey[BSS0][KeyIdx].CipherAlg = CIPHER_NONE;
3504 AsicRemoveSharedKeyEntry(pAdapter, 0, (UCHAR)KeyIdx);
3509 case RT_OID_802_11_RESET_COUNTERS:
3510 NdisZeroMemory(&pAdapter->WlanCounters, sizeof(COUNTER_802_11));
3511 NdisZeroMemory(&pAdapter->Counters8023, sizeof(COUNTER_802_3));
3512 NdisZeroMemory(&pAdapter->RalinkCounters, sizeof(COUNTER_RALINK));
3513 pAdapter->Counters8023.RxNoBuffer = 0;
3514 pAdapter->Counters8023.GoodReceives = 0;
3515 pAdapter->Counters8023.RxNoBuffer = 0;
3517 pAdapter->BulkOutComplete = 0;
3518 pAdapter->BulkOutCompleteOther= 0;
3519 pAdapter->BulkOutCompleteCancel = 0;
3520 pAdapter->BulkOutReq = 0;
3521 pAdapter->BulkInReq= 0;
3522 pAdapter->BulkInComplete = 0;
3523 pAdapter->BulkInCompleteFail = 0;
3525 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_RESET_COUNTERS \n"));
3527 case OID_802_11_RTS_THRESHOLD:
3528 if (wrq->u.data.length != sizeof(NDIS_802_11_RTS_THRESHOLD))
3532 Status = copy_from_user(&RtsThresh, wrq->u.data.pointer, wrq->u.data.length);
3533 if (RtsThresh > MAX_RTS_THRESHOLD)
3536 pAdapter->CommonCfg.RtsThreshold = (USHORT)RtsThresh;
3538 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_RTS_THRESHOLD (=%ld)\n",RtsThresh));
3540 case OID_802_11_FRAGMENTATION_THRESHOLD:
3541 if (wrq->u.data.length != sizeof(NDIS_802_11_FRAGMENTATION_THRESHOLD))
3545 Status = copy_from_user(&FragThresh, wrq->u.data.pointer, wrq->u.data.length);
3546 pAdapter->CommonCfg.bUseZeroToDisableFragment = FALSE;
3547 if (FragThresh > MAX_FRAG_THRESHOLD || FragThresh < MIN_FRAG_THRESHOLD)
3549 if (FragThresh == 0)
3551 pAdapter->CommonCfg.FragmentThreshold = MAX_FRAG_THRESHOLD;
3552 pAdapter->CommonCfg.bUseZeroToDisableFragment = TRUE;
3558 pAdapter->CommonCfg.FragmentThreshold = (USHORT)FragThresh;
3560 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_FRAGMENTATION_THRESHOLD (=%ld) \n",FragThresh));
3562 case OID_802_11_POWER_MODE:
3563 if (wrq->u.data.length != sizeof(NDIS_802_11_POWER_MODE))
3567 Status = copy_from_user(&PowerMode, wrq->u.data.pointer, wrq->u.data.length);
3568 if (PowerMode == Ndis802_11PowerModeCAM)
3569 Set_PSMode_Proc(pAdapter, "CAM");
3570 else if (PowerMode == Ndis802_11PowerModeMAX_PSP)
3571 Set_PSMode_Proc(pAdapter, "Max_PSP");
3572 else if (PowerMode == Ndis802_11PowerModeFast_PSP)
3573 Set_PSMode_Proc(pAdapter, "Fast_PSP");
3574 else if (PowerMode == Ndis802_11PowerModeLegacy_PSP)
3575 Set_PSMode_Proc(pAdapter, "Legacy_PSP");
3579 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_POWER_MODE (=%d)\n",PowerMode));
3581 case RT_OID_802_11_TX_POWER_LEVEL_1:
3582 if (wrq->u.data.length < sizeof(ULONG))
3586 Status = copy_from_user(&PowerTemp, wrq->u.data.pointer, wrq->u.data.length);
3587 if (PowerTemp > 100)
3588 PowerTemp = 0xffffffff; // AUTO
3589 pAdapter->CommonCfg.TxPowerDefault = PowerTemp; //keep current setting.
3590 pAdapter->CommonCfg.TxPowerPercentage = pAdapter->CommonCfg.TxPowerDefault;
3591 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_TX_POWER_LEVEL_1 (=%ld)\n", pAdapter->CommonCfg.TxPowerPercentage));
3594 case OID_802_11_NETWORK_TYPE_IN_USE:
3595 if (wrq->u.data.length != sizeof(NDIS_802_11_NETWORK_TYPE))
3599 Status = copy_from_user(&NetType, wrq->u.data.pointer, wrq->u.data.length);
3601 if (NetType == Ndis802_11DS)
3602 RTMPSetPhyMode(pAdapter, PHY_11B);
3603 else if (NetType == Ndis802_11OFDM24)
3604 RTMPSetPhyMode(pAdapter, PHY_11BG_MIXED);
3605 else if (NetType == Ndis802_11OFDM5)
3606 RTMPSetPhyMode(pAdapter, PHY_11A);
3609 #ifdef DOT11_N_SUPPORT
3610 if (Status == NDIS_STATUS_SUCCESS)
3611 SetCommonHT(pAdapter);
3612 #endif // DOT11_N_SUPPORT //
3613 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_NETWORK_TYPE_IN_USE (=%d)\n",NetType));
3616 // For WPA PSK PMK key
3617 case RT_OID_802_11_ADD_WPA:
3618 pKey = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
3625 Status = copy_from_user(pKey, wrq->u.data.pointer, wrq->u.data.length);
3626 if (pKey->Length != wrq->u.data.length)
3629 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_ADD_WPA, Failed!!\n"));
3633 if ((pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPAPSK) &&
3634 (pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPA2PSK) &&
3635 (pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPANone) )
3637 Status = -EOPNOTSUPP;
3638 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_ADD_WPA, Failed!! [AuthMode != WPAPSK/WPA2PSK/WPANONE]\n"));
3640 else if ((pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK) ||
3641 (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK) ||
3642 (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPANone) ) // Only for WPA PSK mode
3644 NdisMoveMemory(pAdapter->StaCfg.PMK, &pKey->KeyMaterial, pKey->KeyLength);
3645 // Use RaConfig as PSK agent.
3646 // Start STA supplicant state machine
3647 if (pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPANone)
3648 pAdapter->StaCfg.WpaState = SS_START;
3650 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_ADD_WPA (id=0x%x, Len=%d-byte)\n", pKey->KeyIndex, pKey->KeyLength));
3654 pAdapter->StaCfg.WpaState = SS_NOTUSE;
3655 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_ADD_WPA (id=0x%x, Len=%d-byte)\n", pKey->KeyIndex, pKey->KeyLength));
3660 case OID_802_11_REMOVE_KEY:
3661 pRemoveKey = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
3662 if(pRemoveKey == NULL)
3668 Status = copy_from_user(pRemoveKey, wrq->u.data.pointer, wrq->u.data.length);
3669 if (pRemoveKey->Length != wrq->u.data.length)
3672 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_KEY, Failed!!\n"));
3676 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
3678 RTMPWPARemoveKeyProc(pAdapter, pRemoveKey);
3679 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_KEY, Remove WPA Key!!\n"));
3683 KeyIdx = pRemoveKey->KeyIndex;
3685 if (KeyIdx & 0x80000000)
3687 // Should never set default bit when remove key
3689 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_KEY, Failed!!(Should never set default bit when remove key)\n"));
3693 KeyIdx = KeyIdx & 0x0fffffff;
3697 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_KEY, Failed!!(KeyId[%d] out of range)\n", KeyIdx));
3701 pAdapter->SharedKey[BSS0][KeyIdx].KeyLen = 0;
3702 pAdapter->SharedKey[BSS0][KeyIdx].CipherAlg = CIPHER_NONE;
3703 AsicRemoveSharedKeyEntry(pAdapter, 0, (UCHAR)KeyIdx);
3704 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_KEY (id=0x%x, Len=%d-byte)\n", pRemoveKey->KeyIndex, pRemoveKey->Length));
3712 case OID_802_11_ADD_KEY:
3713 pKey = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
3719 Status = copy_from_user(pKey, wrq->u.data.pointer, wrq->u.data.length);
3720 if (pKey->Length != wrq->u.data.length)
3723 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_KEY, Failed!!\n"));
3727 RTMPAddKey(pAdapter, pKey);
3728 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_KEY (id=0x%x, Len=%d-byte)\n", pKey->KeyIndex, pKey->KeyLength));
3732 case OID_802_11_CONFIGURATION:
3733 if (wrq->u.data.length != sizeof(NDIS_802_11_CONFIGURATION))
3737 Status = copy_from_user(&Config, wrq->u.data.pointer, wrq->u.data.length);
3740 if ((pConfig->BeaconPeriod >= 20) && (pConfig->BeaconPeriod <=400))
3741 pAdapter->CommonCfg.BeaconPeriod = (USHORT) pConfig->BeaconPeriod;
3743 pAdapter->StaActive.AtimWin = (USHORT) pConfig->ATIMWindow;
3744 MAP_KHZ_TO_CHANNEL_ID(pConfig->DSConfig, pAdapter->CommonCfg.Channel);
3746 // Save the channel on MlmeAux for CntlOidRTBssidProc used.
3748 pAdapter->MlmeAux.Channel = pAdapter->CommonCfg.Channel;
3750 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_CONFIGURATION (BeacnPeriod=%ld,AtimW=%ld,Ch=%d)\n",
3751 pConfig->BeaconPeriod, pConfig->ATIMWindow, pAdapter->CommonCfg.Channel));
3752 // Config has changed
3753 pAdapter->bConfigChanged = TRUE;
3756 #ifdef DOT11_N_SUPPORT
3757 case RT_OID_802_11_SET_HT_PHYMODE:
3758 if (wrq->u.data.length != sizeof(OID_SET_HT_PHYMODE))
3762 POID_SET_HT_PHYMODE pHTPhyMode = &HT_PhyMode;
3764 Status = copy_from_user(&HT_PhyMode, wrq->u.data.pointer, wrq->u.data.length);
3765 DBGPRINT(RT_DEBUG_TRACE, ("Set::pHTPhyMode (PhyMode = %d,TransmitNo = %d, HtMode = %d, ExtOffset = %d , MCS = %d, BW = %d, STBC = %d, SHORTGI = %d) \n",
3766 pHTPhyMode->PhyMode, pHTPhyMode->TransmitNo,pHTPhyMode->HtMode,pHTPhyMode->ExtOffset,
3767 pHTPhyMode->MCS, pHTPhyMode->BW, pHTPhyMode->STBC, pHTPhyMode->SHORTGI));
3768 if (pAdapter->CommonCfg.PhyMode >= PHY_11ABGN_MIXED)
3769 RTMPSetHT(pAdapter, pHTPhyMode);
3771 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_SET_HT_PHYMODE(MCS=%d,BW=%d,SGI=%d,STBC=%d)\n",
3772 pAdapter->StaCfg.HTPhyMode.field.MCS, pAdapter->StaCfg.HTPhyMode.field.BW, pAdapter->StaCfg.HTPhyMode.field.ShortGI,
3773 pAdapter->StaCfg.HTPhyMode.field.STBC));
3775 #endif // DOT11_N_SUPPORT //
3776 case RT_OID_802_11_SET_APSD_SETTING:
3777 if (wrq->u.data.length != sizeof(ULONG))
3782 Status = copy_from_user(&apsd, wrq->u.data.pointer, wrq->u.data.length);
3784 /*-------------------------------------------------------------------
3785 |B31~B7 | B6~B5 | B4 | B3 | B2 | B1 | B0 |
3786 ---------------------------------------------------------------------
3787 | Rsvd | Max SP Len | AC_VO | AC_VI | AC_BK | AC_BE | APSD Capable |
3788 ---------------------------------------------------------------------*/
3789 pAdapter->CommonCfg.bAPSDCapable = (apsd & 0x00000001) ? TRUE : FALSE;
3790 pAdapter->CommonCfg.bAPSDAC_BE = ((apsd & 0x00000002) >> 1) ? TRUE : FALSE;
3791 pAdapter->CommonCfg.bAPSDAC_BK = ((apsd & 0x00000004) >> 2) ? TRUE : FALSE;
3792 pAdapter->CommonCfg.bAPSDAC_VI = ((apsd & 0x00000008) >> 3) ? TRUE : FALSE;
3793 pAdapter->CommonCfg.bAPSDAC_VO = ((apsd & 0x00000010) >> 4) ? TRUE : FALSE;
3794 pAdapter->CommonCfg.MaxSPLength = (UCHAR)((apsd & 0x00000060) >> 5);
3796 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,
3797 pAdapter->CommonCfg.bAPSDAC_BE, pAdapter->CommonCfg.bAPSDAC_BK, pAdapter->CommonCfg.bAPSDAC_VI, pAdapter->CommonCfg.bAPSDAC_VO, pAdapter->CommonCfg.MaxSPLength));
3801 case RT_OID_802_11_SET_APSD_PSM:
3802 if (wrq->u.data.length != sizeof(ULONG))
3806 // Driver needs to notify AP when PSM changes
3807 Status = copy_from_user(&pAdapter->CommonCfg.bAPSDForcePowerSave, wrq->u.data.pointer, wrq->u.data.length);
3808 if (pAdapter->CommonCfg.bAPSDForcePowerSave != pAdapter->StaCfg.Psm)
3810 MlmeSetPsmBit(pAdapter, pAdapter->CommonCfg.bAPSDForcePowerSave);
3811 RTMPSendNullFrame(pAdapter, pAdapter->CommonCfg.TxRate, TRUE);
3813 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_SET_APSD_PSM (bAPSDForcePowerSave:%d)\n", pAdapter->CommonCfg.bAPSDForcePowerSave));
3816 #ifdef QOS_DLS_SUPPORT
3817 case RT_OID_802_11_SET_DLS:
3818 if (wrq->u.data.length != sizeof(ULONG))
3822 BOOLEAN oldvalue = pAdapter->CommonCfg.bDLSCapable;
3823 Status = copy_from_user(&pAdapter->CommonCfg.bDLSCapable, wrq->u.data.pointer, wrq->u.data.length);
3824 if (oldvalue && !pAdapter->CommonCfg.bDLSCapable)
3827 // tear down local dls table entry
3828 for (i=0; i<MAX_NUM_OF_INIT_DLS_ENTRY; i++)
3830 if (pAdapter->StaCfg.DLSEntry[i].Valid && (pAdapter->StaCfg.DLSEntry[i].Status == DLS_FINISH))
3832 pAdapter->StaCfg.DLSEntry[i].Status = DLS_NONE;
3833 pAdapter->StaCfg.DLSEntry[i].Valid = FALSE;
3834 RTMPSendDLSTearDownFrame(pAdapter, pAdapter->StaCfg.DLSEntry[i].MacAddr);
3838 // tear down peer dls table entry
3839 for (i=MAX_NUM_OF_INIT_DLS_ENTRY; i<MAX_NUM_OF_DLS_ENTRY; i++)
3841 if (pAdapter->StaCfg.DLSEntry[i].Valid && (pAdapter->StaCfg.DLSEntry[i].Status == DLS_FINISH))
3843 pAdapter->StaCfg.DLSEntry[i].Status = DLS_NONE;
3844 pAdapter->StaCfg.DLSEntry[i].Valid = FALSE;
3845 RTMPSendDLSTearDownFrame(pAdapter, pAdapter->StaCfg.DLSEntry[i].MacAddr);
3850 DBGPRINT(RT_DEBUG_TRACE,("Set::RT_OID_802_11_SET_DLS (=%d)\n", pAdapter->CommonCfg.bDLSCapable));
3854 case RT_OID_802_11_SET_DLS_PARAM:
3855 if (wrq->u.data.length != sizeof(RT_802_11_DLS_UI))
3861 NdisZeroMemory(&Dls, sizeof(RT_802_11_DLS));
3862 RTMPMoveMemory(&Dls, wrq->u.data.pointer, sizeof(RT_802_11_DLS_UI));
3863 MlmeEnqueue(pAdapter,
3864 MLME_CNTL_STATE_MACHINE,
3865 RT_OID_802_11_SET_DLS_PARAM,
3866 sizeof(RT_802_11_DLS),
3868 DBGPRINT(RT_DEBUG_TRACE,("Set::RT_OID_802_11_SET_DLS_PARAM \n"));
3871 #endif // QOS_DLS_SUPPORT //
3872 case RT_OID_802_11_SET_WMM:
3873 if (wrq->u.data.length != sizeof(BOOLEAN))
3877 Status = copy_from_user(&pAdapter->CommonCfg.bWmmCapable, wrq->u.data.pointer, wrq->u.data.length);
3878 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_SET_WMM (=%d) \n", pAdapter->CommonCfg.bWmmCapable));
3882 case OID_802_11_DISASSOCIATE:
3884 // Set NdisRadioStateOff to TRUE, instead of called MlmeRadioOff.
3885 // Later on, NDIS_802_11_BSSID_LIST_EX->NumberOfItems should be 0
3886 // when query OID_802_11_BSSID_LIST.
3888 // TRUE: NumberOfItems will set to 0.
3889 // FALSE: NumberOfItems no change.
3891 pAdapter->CommonCfg.NdisRadioStateOff = TRUE;
3892 // Set to immediately send the media disconnect event
3893 pAdapter->MlmeAux.CurrReqIsFromNdis = TRUE;
3894 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_DISASSOCIATE \n"));
3896 if (INFRA_ON(pAdapter))
3898 if (pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE)
3900 RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
3901 DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
3904 MlmeEnqueue(pAdapter,
3905 MLME_CNTL_STATE_MACHINE,
3906 OID_802_11_DISASSOCIATE,
3910 StateMachineTouched = TRUE;
3914 #ifdef DOT11_N_SUPPORT
3915 case RT_OID_802_11_SET_IMME_BA_CAP:
3916 if (wrq->u.data.length != sizeof(OID_BACAP_STRUC))
3920 OID_BACAP_STRUC Orde ;
3921 Status = copy_from_user(&Orde, wrq->u.data.pointer, wrq->u.data.length);
3922 if (Orde.Policy > BA_NOTUSE)
3924 Status = NDIS_STATUS_INVALID_DATA;
3926 else if (Orde.Policy == BA_NOTUSE)
3928 pAdapter->CommonCfg.BACapability.field.Policy = BA_NOTUSE;
3929 pAdapter->CommonCfg.BACapability.field.MpduDensity = Orde.MpduDensity;
3930 pAdapter->CommonCfg.DesiredHtPhy.MpduDensity = Orde.MpduDensity;
3931 pAdapter->CommonCfg.DesiredHtPhy.AmsduEnable = Orde.AmsduEnable;
3932 pAdapter->CommonCfg.DesiredHtPhy.AmsduSize= Orde.AmsduSize;
3933 pAdapter->CommonCfg.DesiredHtPhy.MimoPs= Orde.MMPSmode;
3934 pAdapter->CommonCfg.BACapability.field.MMPSmode = Orde.MMPSmode;
3936 pAdapter->CommonCfg.HtCapability.HtCapInfo.MimoPs = Orde.MMPSmode;
3937 pAdapter->CommonCfg.HtCapability.HtCapInfo.AMsduSize = Orde.AmsduSize;
3938 pAdapter->CommonCfg.HtCapability.HtCapParm.MpduDensity = Orde.MpduDensity;
3942 pAdapter->CommonCfg.BACapability.field.AutoBA = Orde.AutoBA;
3943 pAdapter->CommonCfg.BACapability.field.Policy = IMMED_BA; // we only support immediate BA.
3944 pAdapter->CommonCfg.BACapability.field.MpduDensity = Orde.MpduDensity;
3945 pAdapter->CommonCfg.DesiredHtPhy.MpduDensity = Orde.MpduDensity;
3946 pAdapter->CommonCfg.DesiredHtPhy.AmsduEnable = Orde.AmsduEnable;
3947 pAdapter->CommonCfg.DesiredHtPhy.AmsduSize= Orde.AmsduSize;
3948 pAdapter->CommonCfg.DesiredHtPhy.MimoPs = Orde.MMPSmode;
3949 pAdapter->CommonCfg.BACapability.field.MMPSmode = Orde.MMPSmode;
3952 pAdapter->CommonCfg.HtCapability.HtCapInfo.MimoPs = Orde.MMPSmode;
3953 pAdapter->CommonCfg.HtCapability.HtCapInfo.AMsduSize = Orde.AmsduSize;
3954 pAdapter->CommonCfg.HtCapability.HtCapParm.MpduDensity = Orde.MpduDensity;
3956 if (pAdapter->CommonCfg.BACapability.field.RxBAWinLimit > MAX_RX_REORDERBUF)
3957 pAdapter->CommonCfg.BACapability.field.RxBAWinLimit = MAX_RX_REORDERBUF;
3961 pAdapter->CommonCfg.REGBACapability.word = pAdapter->CommonCfg.BACapability.word;
3962 DBGPRINT(RT_DEBUG_TRACE, ("Set::(Orde.AutoBA = %d) (Policy=%d)(ReBAWinLimit=%d)(TxBAWinLimit=%d)(AutoMode=%d)\n",Orde.AutoBA, pAdapter->CommonCfg.BACapability.field.Policy,
3963 pAdapter->CommonCfg.BACapability.field.RxBAWinLimit,pAdapter->CommonCfg.BACapability.field.TxBAWinLimit, pAdapter->CommonCfg.BACapability.field.AutoBA));
3964 DBGPRINT(RT_DEBUG_TRACE, ("Set::(MimoPs = %d)(AmsduEnable = %d) (AmsduSize=%d)(MpduDensity=%d)\n",pAdapter->CommonCfg.DesiredHtPhy.MimoPs, pAdapter->CommonCfg.DesiredHtPhy.AmsduEnable,
3965 pAdapter->CommonCfg.DesiredHtPhy.AmsduSize, pAdapter->CommonCfg.DesiredHtPhy.MpduDensity));
3969 case RT_OID_802_11_ADD_IMME_BA:
3970 DBGPRINT(RT_DEBUG_TRACE, (" Set :: RT_OID_802_11_ADD_IMME_BA \n"));
3971 if (wrq->u.data.length != sizeof(OID_ADD_BA_ENTRY))
3976 OID_ADD_BA_ENTRY BA;
3977 MAC_TABLE_ENTRY *pEntry;
3979 Status = copy_from_user(&BA, wrq->u.data.pointer, wrq->u.data.length);
3982 Status = NDIS_STATUS_INVALID_DATA;
3987 //BATableInsertEntry
3988 //As ad-hoc mode, BA pair is not limited to only BSSID. so add via OID.
3990 // in ad hoc mode, when adding BA pair, we should insert this entry into MACEntry too
3991 pEntry = MacTableLookup(pAdapter, BA.MACAddr);
3994 DBGPRINT(RT_DEBUG_TRACE, ("RT_OID_802_11_ADD_IMME_BA. break on no connection.----:%x:%x\n", BA.MACAddr[4], BA.MACAddr[5]));
3997 if (BA.IsRecipient == FALSE)
3999 if (pEntry->bIAmBadAtheros == TRUE)
4000 pAdapter->CommonCfg.BACapability.field.RxBAWinLimit = 0x10;
4002 BAOriSessionSetUp(pAdapter, pEntry, index, 0, 100, TRUE);
4006 //BATableInsertEntry(pAdapter, pEntry->Aid, BA.MACAddr, 0, 0xffff, BA.TID, BA.nMSDU, BA.IsRecipient);
4009 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_ADD_IMME_BA. Rec = %d. Mac = %x:%x:%x:%x:%x:%x . \n",
4010 BA.IsRecipient, BA.MACAddr[0], BA.MACAddr[1], BA.MACAddr[2], BA.MACAddr[2]
4011 , BA.MACAddr[4], BA.MACAddr[5]));
4016 case RT_OID_802_11_TEAR_IMME_BA:
4017 DBGPRINT(RT_DEBUG_TRACE, ("Set :: RT_OID_802_11_TEAR_IMME_BA \n"));
4018 if (wrq->u.data.length != sizeof(OID_ADD_BA_ENTRY))
4022 POID_ADD_BA_ENTRY pBA;
4023 MAC_TABLE_ENTRY *pEntry;
4025 pBA = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
4029 DBGPRINT(RT_DEBUG_TRACE, ("Set :: RT_OID_802_11_TEAR_IMME_BA kmalloc() can't allocate enough memory\n"));
4030 Status = NDIS_STATUS_FAILURE;
4034 Status = copy_from_user(pBA, wrq->u.data.pointer, wrq->u.data.length);
4035 DBGPRINT(RT_DEBUG_TRACE, ("Set :: RT_OID_802_11_TEAR_IMME_BA(TID=%d, bAllTid=%d)\n", pBA->TID, pBA->bAllTid));
4037 if (!pBA->bAllTid && (pBA->TID > NUM_OF_TID))
4039 Status = NDIS_STATUS_INVALID_DATA;
4043 if (pBA->IsRecipient == FALSE)
4045 pEntry = MacTableLookup(pAdapter, pBA->MACAddr);
4046 DBGPRINT(RT_DEBUG_TRACE, (" pBA->IsRecipient == FALSE\n"));
4049 DBGPRINT(RT_DEBUG_TRACE, (" pBA->pEntry\n"));
4050 BAOriSessionTearDown(pAdapter, pEntry->Aid, pBA->TID, FALSE, TRUE);
4053 DBGPRINT(RT_DEBUG_TRACE, ("Set :: Not found pEntry \n"));
4057 pEntry = MacTableLookup(pAdapter, pBA->MACAddr);
4060 BARecSessionTearDown( pAdapter, (UCHAR)pEntry->Aid, pBA->TID, TRUE);
4063 DBGPRINT(RT_DEBUG_TRACE, ("Set :: Not found pEntry \n"));
4069 #endif // DOT11_N_SUPPORT //
4071 // For WPA_SUPPLICANT to set static wep key
4072 case OID_802_11_ADD_WEP:
4073 pWepKey = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
4078 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_WEP, Failed!!\n"));
4081 Status = copy_from_user(pWepKey, wrq->u.data.pointer, wrq->u.data.length);
4085 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_WEP, Failed (length mismatch)!!\n"));
4089 KeyIdx = pWepKey->KeyIndex & 0x0fffffff;
4090 // KeyIdx must be 0 ~ 3
4094 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_WEP, Failed (KeyIdx must be smaller than 4)!!\n"));
4098 UCHAR CipherAlg = 0;
4101 // set key material and key length
4102 NdisZeroMemory(pAdapter->SharedKey[BSS0][KeyIdx].Key, 16);
4103 pAdapter->SharedKey[BSS0][KeyIdx].KeyLen = (UCHAR) pWepKey->KeyLength;
4104 NdisMoveMemory(pAdapter->SharedKey[BSS0][KeyIdx].Key, &pWepKey->KeyMaterial, pWepKey->KeyLength);
4106 switch(pWepKey->KeyLength)
4109 CipherAlg = CIPHER_WEP64;
4112 CipherAlg = CIPHER_WEP128;
4115 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_WEP, only support CIPHER_WEP64(len:5) & CIPHER_WEP128(len:13)!!\n"));
4119 pAdapter->SharedKey[BSS0][KeyIdx].CipherAlg = CipherAlg;
4121 // Default key for tx (shared key)
4122 if (pWepKey->KeyIndex & 0x80000000)
4124 #ifdef WPA_SUPPLICANT_SUPPORT
4125 // set key material and key length
4126 NdisZeroMemory(pAdapter->StaCfg.DesireSharedKey[KeyIdx].Key, 16);
4127 pAdapter->StaCfg.DesireSharedKey[KeyIdx].KeyLen = (UCHAR) pWepKey->KeyLength;
4128 NdisMoveMemory(pAdapter->StaCfg.DesireSharedKey[KeyIdx].Key, &pWepKey->KeyMaterial, pWepKey->KeyLength);
4129 pAdapter->StaCfg.DesireSharedKeyId = KeyIdx;
4130 pAdapter->StaCfg.DesireSharedKey[KeyIdx].CipherAlg = CipherAlg;
4131 #endif // WPA_SUPPLICANT_SUPPORT //
4132 pAdapter->StaCfg.DefaultKeyId = (UCHAR) KeyIdx;
4135 #ifdef WPA_SUPPLICANT_SUPPORT
4136 if (pAdapter->StaCfg.PortSecured == WPA_802_1X_PORT_SECURED)
4137 #endif // WPA_SUPPLICANT_SUPPORT
4139 Key = pAdapter->SharedKey[BSS0][KeyIdx].Key;
4141 // Set key material and cipherAlg to Asic
4142 AsicAddSharedKeyEntry(pAdapter, BSS0, KeyIdx, CipherAlg, Key, NULL, NULL);
4144 if (pWepKey->KeyIndex & 0x80000000)
4146 PMAC_TABLE_ENTRY pEntry = &pAdapter->MacTab.Content[BSSID_WCID];
4147 // Assign group key info
4148 RTMPAddWcidAttributeEntry(pAdapter, BSS0, KeyIdx, CipherAlg, NULL);
4149 // Assign pairwise key info
4150 RTMPAddWcidAttributeEntry(pAdapter, BSS0, KeyIdx, CipherAlg, pEntry);
4153 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"));
4158 #ifdef WPA_SUPPLICANT_SUPPORT
4159 case OID_SET_COUNTERMEASURES:
4160 if (wrq->u.data.length != sizeof(int))
4165 Status = copy_from_user(&enabled, wrq->u.data.pointer, wrq->u.data.length);
4167 pAdapter->StaCfg.bBlockAssoc = TRUE;
4169 // WPA MIC error should block association attempt for 60 seconds
4170 pAdapter->StaCfg.bBlockAssoc = FALSE;
4171 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_SET_COUNTERMEASURES bBlockAssoc=%s\n", pAdapter->StaCfg.bBlockAssoc ? "TRUE":"FALSE"));
4174 case RT_OID_WPA_SUPPLICANT_SUPPORT:
4175 if (wrq->u.data.length != sizeof(UCHAR))
4179 Status = copy_from_user(&wpa_supplicant_enable, wrq->u.data.pointer, wrq->u.data.length);
4180 pAdapter->StaCfg.WpaSupplicantUP = wpa_supplicant_enable;
4181 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_WPA_SUPPLICANT_SUPPORT (=%d)\n", pAdapter->StaCfg.WpaSupplicantUP));
4184 case OID_802_11_DEAUTHENTICATION:
4185 if (wrq->u.data.length != sizeof(MLME_DEAUTH_REQ_STRUCT))
4189 MLME_DEAUTH_REQ_STRUCT *pInfo;
4190 MLME_QUEUE_ELEM *MsgElem = (MLME_QUEUE_ELEM *) kmalloc(sizeof(MLME_QUEUE_ELEM), MEM_ALLOC_FLAG);
4192 pInfo = (MLME_DEAUTH_REQ_STRUCT *) MsgElem->Msg;
4193 Status = copy_from_user(pInfo, wrq->u.data.pointer, wrq->u.data.length);
4194 MlmeDeauthReqAction(pAdapter, MsgElem);
4197 if (INFRA_ON(pAdapter))
4199 LinkDown(pAdapter, FALSE);
4200 pAdapter->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
4202 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_DEAUTHENTICATION (Reason=%d)\n", pInfo->Reason));
4205 case OID_802_11_DROP_UNENCRYPTED:
4206 if (wrq->u.data.length != sizeof(int))
4211 Status = copy_from_user(&enabled, wrq->u.data.pointer, wrq->u.data.length);
4213 pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED;
4215 pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
4216 NdisAcquireSpinLock(&pAdapter->MacTabLock);
4217 pAdapter->MacTab.Content[BSSID_WCID].PortSecured = pAdapter->StaCfg.PortSecured;
4218 NdisReleaseSpinLock(&pAdapter->MacTabLock);
4219 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_DROP_UNENCRYPTED (=%d)\n", enabled));
4222 case OID_802_11_SET_IEEE8021X:
4223 if (wrq->u.data.length != sizeof(BOOLEAN))
4227 Status = copy_from_user(&IEEE8021xState, wrq->u.data.pointer, wrq->u.data.length);
4228 pAdapter->StaCfg.IEEE8021X = IEEE8021xState;
4229 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_SET_IEEE8021X (=%d)\n", IEEE8021xState));
4232 case OID_802_11_SET_IEEE8021X_REQUIRE_KEY:
4233 if (wrq->u.data.length != sizeof(BOOLEAN))
4237 Status = copy_from_user(&IEEE8021x_required_keys, wrq->u.data.pointer, wrq->u.data.length);
4238 pAdapter->StaCfg.IEEE8021x_required_keys = IEEE8021x_required_keys;
4239 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_SET_IEEE8021X_REQUIRE_KEY (%d)\n", IEEE8021x_required_keys));
4242 case OID_802_11_PMKID:
4243 pPmkId = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
4245 if(pPmkId == NULL) {
4249 Status = copy_from_user(pPmkId, wrq->u.data.pointer, wrq->u.data.length);
4251 // check the PMKID information
4252 if (pPmkId->BSSIDInfoCount == 0)
4253 NdisZeroMemory(pAdapter->StaCfg.SavedPMK, sizeof(BSSID_INFO)*PMKID_NO);
4256 PBSSID_INFO pBssIdInfo;
4260 for (BssIdx = 0; BssIdx < pPmkId->BSSIDInfoCount; BssIdx++)
4262 // point to the indexed BSSID_INFO structure
4263 pBssIdInfo = (PBSSID_INFO) ((PUCHAR) pPmkId + 2 * sizeof(UINT) + BssIdx * sizeof(BSSID_INFO));
4264 // Find the entry in the saved data base.
4265 for (CachedIdx = 0; CachedIdx < pAdapter->StaCfg.SavedPMKNum; CachedIdx++)
4267 // compare the BSSID
4268 if (NdisEqualMemory(pBssIdInfo->BSSID, pAdapter->StaCfg.SavedPMK[CachedIdx].BSSID, sizeof(NDIS_802_11_MAC_ADDRESS)))
4272 // Found, replace it
4273 if (CachedIdx < PMKID_NO)
4275 DBGPRINT(RT_DEBUG_OFF, ("Update OID_802_11_PMKID, idx = %d\n", CachedIdx));
4276 NdisMoveMemory(&pAdapter->StaCfg.SavedPMK[CachedIdx], pBssIdInfo, sizeof(BSSID_INFO));
4277 pAdapter->StaCfg.SavedPMKNum++;
4279 // Not found, replace the last one
4282 // Randomly replace one
4283 CachedIdx = (pBssIdInfo->BSSID[5] % PMKID_NO);
4284 DBGPRINT(RT_DEBUG_OFF, ("Update OID_802_11_PMKID, idx = %d\n", CachedIdx));
4285 NdisMoveMemory(&pAdapter->StaCfg.SavedPMK[CachedIdx], pBssIdInfo, sizeof(BSSID_INFO));
4292 #endif // WPA_SUPPLICANT_SUPPORT //
4297 case OID_802_11_SHORTRETRYLIMIT:
4298 if (wrq->u.data.length != sizeof(ULONG))
4302 Status = copy_from_user(&ShortRetryLimit, wrq->u.data.pointer, wrq->u.data.length);
4303 RTMP_IO_READ32(pAdapter, TX_RTY_CFG, &tx_rty_cfg.word);
4304 tx_rty_cfg.field.ShortRtyLimit = ShortRetryLimit;
4305 RTMP_IO_WRITE32(pAdapter, TX_RTY_CFG, tx_rty_cfg.word);
4306 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_SHORTRETRYLIMIT (tx_rty_cfg.field.ShortRetryLimit=%d, ShortRetryLimit=%ld)\n", tx_rty_cfg.field.ShortRtyLimit, ShortRetryLimit));
4310 case OID_802_11_LONGRETRYLIMIT:
4311 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_LONGRETRYLIMIT \n"));
4312 if (wrq->u.data.length != sizeof(ULONG))
4316 Status = copy_from_user(&LongRetryLimit, wrq->u.data.pointer, wrq->u.data.length);
4317 RTMP_IO_READ32(pAdapter, TX_RTY_CFG, &tx_rty_cfg.word);
4318 tx_rty_cfg.field.LongRtyLimit = LongRetryLimit;
4319 RTMP_IO_WRITE32(pAdapter, TX_RTY_CFG, tx_rty_cfg.word);
4320 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_LONGRETRYLIMIT (tx_rty_cfg.field.LongRetryLimit= %d,LongRetryLimit=%ld)\n", tx_rty_cfg.field.LongRtyLimit, LongRetryLimit));
4324 case OID_802_11_WEPDEFAULTKEYVALUE:
4325 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_WEPDEFAULTKEYVALUE\n"));
4326 pKey = kmalloc(wrq->u.data.length, GFP_KERNEL);
4327 Status = copy_from_user(pKey, wrq->u.data.pointer, wrq->u.data.length);
4330 if ( pKey->Length != wrq->u.data.length)
4333 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_WEPDEFAULTKEYVALUE, Failed!!\n"));
4335 KeyIdx = pKey->KeyIndex & 0x0fffffff;
4336 DBGPRINT(RT_DEBUG_TRACE,("pKey->KeyIndex =%d, pKey->KeyLength=%d\n", pKey->KeyIndex, pKey->KeyLength));
4338 // it is a shared key
4343 pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].KeyLen = (UCHAR) pKey->KeyLength;
4344 NdisMoveMemory(&pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].Key, &pKey->KeyMaterial, pKey->KeyLength);
4345 if (pKey->KeyIndex & 0x80000000)
4347 // Default key for tx (shared key)
4348 pAdapter->StaCfg.DefaultKeyId = (UCHAR) KeyIdx;
4350 //RestartAPIsRequired = TRUE;
4355 case OID_802_11_WEPDEFAULTKEYID:
4356 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_WEPDEFAULTKEYID \n"));
4358 if (wrq->u.data.length != sizeof(UCHAR))
4361 Status = copy_from_user(&pAdapter->StaCfg.DefaultKeyId, wrq->u.data.pointer, wrq->u.data.length);
4366 case OID_802_11_CURRENTCHANNEL:
4367 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_CURRENTCHANNEL \n"));
4368 if (wrq->u.data.length != sizeof(UCHAR))
4372 Status = copy_from_user(&ctmp, wrq->u.data.pointer, wrq->u.data.length);
4373 sprintf(&ctmp,"%d", ctmp);
4374 Set_Channel_Proc(pAdapter, &ctmp);
4382 DBGPRINT(RT_DEBUG_TRACE, ("Set::unknown IOCTL's subcmd = 0x%08x\n", cmd));
4383 Status = -EOPNOTSUPP;
4391 INT RTMPQueryInformation(
4392 IN PRTMP_ADAPTER pAdapter,
4393 IN OUT struct ifreq *rq,
4396 struct iwreq *wrq = (struct iwreq *) rq;
4397 NDIS_802_11_BSSID_LIST_EX *pBssidList = NULL;
4398 PNDIS_WLAN_BSSID_EX pBss;
4399 NDIS_802_11_SSID Ssid;
4400 NDIS_802_11_CONFIGURATION *pConfiguration = NULL;
4401 RT_802_11_LINK_STATUS *pLinkStatus = NULL;
4402 RT_802_11_STA_CONFIG *pStaConfig = NULL;
4403 NDIS_802_11_STATISTICS *pStatistics = NULL;
4404 NDIS_802_11_RTS_THRESHOLD RtsThresh;
4405 NDIS_802_11_FRAGMENTATION_THRESHOLD FragThresh;
4406 NDIS_802_11_POWER_MODE PowerMode;
4407 NDIS_802_11_NETWORK_INFRASTRUCTURE BssType;
4408 RT_802_11_PREAMBLE PreamType;
4409 NDIS_802_11_AUTHENTICATION_MODE AuthMode;
4410 NDIS_802_11_WEP_STATUS WepStatus;
4411 NDIS_MEDIA_STATE MediaState;
4412 ULONG BssBufSize, ulInfo=0, NetworkTypeList[4], apsd = 0;
4414 PUCHAR pBuf = NULL, pPtr;
4415 INT Status = NDIS_STATUS_SUCCESS;
4416 UINT we_version_compiled;
4417 UCHAR i, Padding = 0;
4419 UCHAR driverVersion[8];
4420 OID_SET_HT_PHYMODE *pHTPhyMode = NULL;
4425 DefaultKeyIdxValue *pKeyIdxValue;
4427 TX_RTY_CFG_STRUC tx_rty_cfg;
4428 ULONG ShortRetryLimit, LongRetryLimit;
4434 case RT_OID_DEVICE_NAME:
4435 wrq->u.data.length = sizeof(STA_NIC_DEVICE_NAME);
4436 Status = copy_to_user(wrq->u.data.pointer, STA_NIC_DEVICE_NAME, wrq->u.data.length);
4438 case RT_OID_VERSION_INFO:
4439 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_VERSION_INFO \n"));
4440 wrq->u.data.length = 8*sizeof(UCHAR);
4441 sprintf(&driverVersion[0], "%s", STA_DRIVER_VERSION);
4442 driverVersion[7] = '\0';
4443 if (copy_to_user(wrq->u.data.pointer, &driverVersion, wrq->u.data.length))
4448 case OID_802_11_BSSID_LIST:
4449 if (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
4452 * Still scanning, indicate the caller should try again.
4454 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_BSSID_LIST (Still scanning)\n"));
4457 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_BSSID_LIST (%d BSS returned)\n",pAdapter->ScanTab.BssNr));
4458 pAdapter->StaCfg.bScanReqIsFromWebUI = FALSE;
4459 // Claculate total buffer size required
4460 BssBufSize = sizeof(ULONG);
4462 for (i = 0; i < pAdapter->ScanTab.BssNr; i++)
4464 // Align pointer to 4 bytes boundary.
4465 //Padding = 4 - (pAdapter->ScanTab.BssEntry[i].VarIELen & 0x0003);
4468 BssBufSize += (sizeof(NDIS_WLAN_BSSID_EX) - 1 + sizeof(NDIS_802_11_FIXED_IEs) + pAdapter->ScanTab.BssEntry[i].VarIELen + Padding);
4471 // For safety issue, we add 256 bytes just in case
4473 // Allocate the same size as passed from higher layer
4474 pBuf = kmalloc(BssBufSize, MEM_ALLOC_FLAG);
4480 // Init 802_11_BSSID_LIST_EX structure
4481 NdisZeroMemory(pBuf, BssBufSize);
4482 pBssidList = (PNDIS_802_11_BSSID_LIST_EX) pBuf;
4483 pBssidList->NumberOfItems = pAdapter->ScanTab.BssNr;
4485 // Calculate total buffer length
4486 BssLen = 4; // Consist of NumberOfItems
4487 // Point to start of NDIS_WLAN_BSSID_EX
4488 // pPtr = pBuf + sizeof(ULONG);
4489 pPtr = (PUCHAR) &pBssidList->Bssid[0];
4490 for (i = 0; i < pAdapter->ScanTab.BssNr; i++)
4492 pBss = (PNDIS_WLAN_BSSID_EX) pPtr;
4493 NdisMoveMemory(&pBss->MacAddress, &pAdapter->ScanTab.BssEntry[i].Bssid, MAC_ADDR_LEN);
4494 if ((pAdapter->ScanTab.BssEntry[i].Hidden == 1) && (pAdapter->StaCfg.bShowHiddenSSID == FALSE))
4497 // We must return this SSID during 4way handshaking, otherwise Aegis will failed to parse WPA infomation
4498 // and then failed to send EAPOl farame.
4500 if ((pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA) && (pAdapter->StaCfg.PortSecured != WPA_802_1X_PORT_SECURED))
4502 pBss->Ssid.SsidLength = pAdapter->ScanTab.BssEntry[i].SsidLen;
4503 NdisMoveMemory(pBss->Ssid.Ssid, pAdapter->ScanTab.BssEntry[i].Ssid, pAdapter->ScanTab.BssEntry[i].SsidLen);
4506 pBss->Ssid.SsidLength = 0;
4510 pBss->Ssid.SsidLength = pAdapter->ScanTab.BssEntry[i].SsidLen;
4511 NdisMoveMemory(pBss->Ssid.Ssid, pAdapter->ScanTab.BssEntry[i].Ssid, pAdapter->ScanTab.BssEntry[i].SsidLen);
4513 pBss->Privacy = pAdapter->ScanTab.BssEntry[i].Privacy;
4514 pBss->Rssi = pAdapter->ScanTab.BssEntry[i].Rssi - pAdapter->BbpRssiToDbmDelta;
4515 pBss->NetworkTypeInUse = NetworkTypeInUseSanity(&pAdapter->ScanTab.BssEntry[i]);
4516 pBss->Configuration.Length = sizeof(NDIS_802_11_CONFIGURATION);
4517 pBss->Configuration.BeaconPeriod = pAdapter->ScanTab.BssEntry[i].BeaconPeriod;
4518 pBss->Configuration.ATIMWindow = pAdapter->ScanTab.BssEntry[i].AtimWin;
4520 MAP_CHANNEL_ID_TO_KHZ(pAdapter->ScanTab.BssEntry[i].Channel, pBss->Configuration.DSConfig);
4522 if (pAdapter->ScanTab.BssEntry[i].BssType == BSS_INFRA)
4523 pBss->InfrastructureMode = Ndis802_11Infrastructure;
4525 pBss->InfrastructureMode = Ndis802_11IBSS;
4527 NdisMoveMemory(pBss->SupportedRates, pAdapter->ScanTab.BssEntry[i].SupRate, pAdapter->ScanTab.BssEntry[i].SupRateLen);
4528 NdisMoveMemory(pBss->SupportedRates + pAdapter->ScanTab.BssEntry[i].SupRateLen,
4529 pAdapter->ScanTab.BssEntry[i].ExtRate,
4530 pAdapter->ScanTab.BssEntry[i].ExtRateLen);
4532 if (pAdapter->ScanTab.BssEntry[i].VarIELen == 0)
4534 pBss->IELength = sizeof(NDIS_802_11_FIXED_IEs);
4535 NdisMoveMemory(pBss->IEs, &pAdapter->ScanTab.BssEntry[i].FixIEs, sizeof(NDIS_802_11_FIXED_IEs));
4536 pPtr = pPtr + sizeof(NDIS_WLAN_BSSID_EX) - 1 + sizeof(NDIS_802_11_FIXED_IEs);
4540 pBss->IELength = (ULONG)(sizeof(NDIS_802_11_FIXED_IEs) + pAdapter->ScanTab.BssEntry[i].VarIELen);
4541 pPtr = pPtr + sizeof(NDIS_WLAN_BSSID_EX) - 1 + sizeof(NDIS_802_11_FIXED_IEs);
4542 NdisMoveMemory(pBss->IEs, &pAdapter->ScanTab.BssEntry[i].FixIEs, sizeof(NDIS_802_11_FIXED_IEs));
4543 NdisMoveMemory(pBss->IEs + sizeof(NDIS_802_11_FIXED_IEs), pAdapter->ScanTab.BssEntry[i].VarIEs, pAdapter->ScanTab.BssEntry[i].VarIELen);
4544 pPtr += pAdapter->ScanTab.BssEntry[i].VarIELen;
4546 pBss->Length = (ULONG)(sizeof(NDIS_WLAN_BSSID_EX) - 1 + sizeof(NDIS_802_11_FIXED_IEs) + pAdapter->ScanTab.BssEntry[i].VarIELen + Padding);
4548 #if WIRELESS_EXT < 17
4549 if ((BssLen + pBss->Length) < wrq->u.data.length)
4550 BssLen += pBss->Length;
4553 pBssidList->NumberOfItems = i;
4557 BssLen += pBss->Length;
4561 #if WIRELESS_EXT < 17
4562 wrq->u.data.length = BssLen;
4564 if (BssLen > wrq->u.data.length)
4570 wrq->u.data.length = BssLen;
4572 Status = copy_to_user(wrq->u.data.pointer, pBssidList, BssLen);
4575 case OID_802_3_CURRENT_ADDRESS:
4576 wrq->u.data.length = MAC_ADDR_LEN;
4577 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CurrentAddress, wrq->u.data.length);
4579 case OID_GEN_MEDIA_CONNECT_STATUS:
4580 if (pAdapter->IndicateMediaState == NdisMediaStateConnected)
4581 MediaState = NdisMediaStateConnected;
4583 MediaState = NdisMediaStateDisconnected;
4585 wrq->u.data.length = sizeof(NDIS_MEDIA_STATE);
4586 Status = copy_to_user(wrq->u.data.pointer, &MediaState, wrq->u.data.length);
4588 case OID_802_11_BSSID:
4589 if (INFRA_ON(pAdapter) || ADHOC_ON(pAdapter))
4591 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.Bssid, sizeof(NDIS_802_11_MAC_ADDRESS));
4596 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_BSSID(=EMPTY)\n"));
4600 case OID_802_11_SSID:
4601 NdisZeroMemory(&Ssid, sizeof(NDIS_802_11_SSID));
4602 NdisZeroMemory(Ssid.Ssid, MAX_LEN_OF_SSID);
4603 Ssid.SsidLength = pAdapter->CommonCfg.SsidLen;
4604 memcpy(Ssid.Ssid, pAdapter->CommonCfg.Ssid, Ssid.SsidLength);
4605 wrq->u.data.length = sizeof(NDIS_802_11_SSID);
4606 Status = copy_to_user(wrq->u.data.pointer, &Ssid, wrq->u.data.length);
4607 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_SSID (Len=%d, ssid=%s)\n", Ssid.SsidLength,Ssid.Ssid));
4609 case RT_OID_802_11_QUERY_LINK_STATUS:
4610 pLinkStatus = (RT_802_11_LINK_STATUS *) kmalloc(sizeof(RT_802_11_LINK_STATUS), MEM_ALLOC_FLAG);
4613 pLinkStatus->CurrTxRate = RateIdTo500Kbps[pAdapter->CommonCfg.TxRate]; // unit : 500 kbps
4614 pLinkStatus->ChannelQuality = pAdapter->Mlme.ChannelQuality;
4615 pLinkStatus->RxByteCount = pAdapter->RalinkCounters.ReceivedByteCount;
4616 pLinkStatus->TxByteCount = pAdapter->RalinkCounters.TransmittedByteCount;
4617 pLinkStatus->CentralChannel = pAdapter->CommonCfg.CentralChannel;
4618 wrq->u.data.length = sizeof(RT_802_11_LINK_STATUS);
4619 Status = copy_to_user(wrq->u.data.pointer, pLinkStatus, wrq->u.data.length);
4621 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_LINK_STATUS\n"));
4625 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_LINK_STATUS(kmalloc failed)\n"));
4629 case OID_802_11_CONFIGURATION:
4630 pConfiguration = (NDIS_802_11_CONFIGURATION *) kmalloc(sizeof(NDIS_802_11_CONFIGURATION), MEM_ALLOC_FLAG);
4633 pConfiguration->Length = sizeof(NDIS_802_11_CONFIGURATION);
4634 pConfiguration->BeaconPeriod = pAdapter->CommonCfg.BeaconPeriod;
4635 pConfiguration->ATIMWindow = pAdapter->StaActive.AtimWin;
4636 MAP_CHANNEL_ID_TO_KHZ(pAdapter->CommonCfg.Channel, pConfiguration->DSConfig);
4637 wrq->u.data.length = sizeof(NDIS_802_11_CONFIGURATION);
4638 Status = copy_to_user(wrq->u.data.pointer, pConfiguration, wrq->u.data.length);
4639 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_CONFIGURATION(BeaconPeriod=%ld,AtimW=%ld,Channel=%d) \n",
4640 pConfiguration->BeaconPeriod, pConfiguration->ATIMWindow, pAdapter->CommonCfg.Channel));
4641 kfree(pConfiguration);
4645 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_CONFIGURATION(kmalloc failed)\n"));
4649 case RT_OID_802_11_SNR_0:
4650 if ((pAdapter->StaCfg.LastSNR0 > 0))
4652 ulInfo = ((0xeb - pAdapter->StaCfg.LastSNR0) * 3) / 16 ;
4653 wrq->u.data.length = sizeof(ulInfo);
4654 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4655 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_SNR_0(0x=%lx)\n", ulInfo));
4660 case RT_OID_802_11_SNR_1:
4661 if ((pAdapter->Antenna.field.RxPath > 1) &&
4662 (pAdapter->StaCfg.LastSNR1 > 0))
4664 ulInfo = ((0xeb - pAdapter->StaCfg.LastSNR1) * 3) / 16 ;
4665 wrq->u.data.length = sizeof(ulInfo);
4666 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4667 DBGPRINT(RT_DEBUG_TRACE,("Query::RT_OID_802_11_SNR_1(0x=%lx)\n",ulInfo));
4671 DBGPRINT(RT_DEBUG_TRACE,("Query::RT_OID_802_11_SNR_1(pAdapter->StaCfg.LastSNR1=%d)\n",pAdapter->StaCfg.LastSNR1));
4673 case OID_802_11_RSSI_TRIGGER:
4674 ulInfo = pAdapter->StaCfg.RssiSample.LastRssi0 - pAdapter->BbpRssiToDbmDelta;
4675 wrq->u.data.length = sizeof(ulInfo);
4676 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4677 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_RSSI_TRIGGER(=%ld)\n", ulInfo));
4679 case OID_802_11_RSSI:
4680 case RT_OID_802_11_RSSI:
4681 ulInfo = pAdapter->StaCfg.RssiSample.LastRssi0;
4682 wrq->u.data.length = sizeof(ulInfo);
4683 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4685 case RT_OID_802_11_RSSI_1:
4686 ulInfo = pAdapter->StaCfg.RssiSample.LastRssi1;
4687 wrq->u.data.length = sizeof(ulInfo);
4688 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4690 case RT_OID_802_11_RSSI_2:
4691 ulInfo = pAdapter->StaCfg.RssiSample.LastRssi2;
4692 wrq->u.data.length = sizeof(ulInfo);
4693 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4695 case OID_802_11_STATISTICS:
4696 pStatistics = (NDIS_802_11_STATISTICS *) kmalloc(sizeof(NDIS_802_11_STATISTICS), MEM_ALLOC_FLAG);
4699 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_STATISTICS \n"));
4700 // add the most up-to-date h/w raw counters into software counters
4701 NICUpdateRawCounters(pAdapter);
4703 // Sanity check for calculation of sucessful count
4704 if (pAdapter->WlanCounters.TransmittedFragmentCount.QuadPart < pAdapter->WlanCounters.RetryCount.QuadPart)
4705 pAdapter->WlanCounters.TransmittedFragmentCount.QuadPart = pAdapter->WlanCounters.RetryCount.QuadPart;
4707 pStatistics->TransmittedFragmentCount.QuadPart = pAdapter->WlanCounters.TransmittedFragmentCount.QuadPart;
4708 pStatistics->MulticastTransmittedFrameCount.QuadPart = pAdapter->WlanCounters.MulticastTransmittedFrameCount.QuadPart;
4709 pStatistics->FailedCount.QuadPart = pAdapter->WlanCounters.FailedCount.QuadPart;
4710 pStatistics->RetryCount.QuadPart = pAdapter->WlanCounters.RetryCount.QuadPart;
4711 pStatistics->MultipleRetryCount.QuadPart = pAdapter->WlanCounters.MultipleRetryCount.QuadPart;
4712 pStatistics->RTSSuccessCount.QuadPart = pAdapter->WlanCounters.RTSSuccessCount.QuadPart;
4713 pStatistics->RTSFailureCount.QuadPart = pAdapter->WlanCounters.RTSFailureCount.QuadPart;
4714 pStatistics->ACKFailureCount.QuadPart = pAdapter->WlanCounters.ACKFailureCount.QuadPart;
4715 pStatistics->FrameDuplicateCount.QuadPart = pAdapter->WlanCounters.FrameDuplicateCount.QuadPart;
4716 pStatistics->ReceivedFragmentCount.QuadPart = pAdapter->WlanCounters.ReceivedFragmentCount.QuadPart;
4717 pStatistics->MulticastReceivedFrameCount.QuadPart = pAdapter->WlanCounters.MulticastReceivedFrameCount.QuadPart;
4719 pStatistics->FCSErrorCount = pAdapter->RalinkCounters.RealFcsErrCount;
4721 pStatistics->FCSErrorCount.QuadPart = pAdapter->WlanCounters.FCSErrorCount.QuadPart;
4722 pStatistics->FrameDuplicateCount.u.LowPart = pAdapter->WlanCounters.FrameDuplicateCount.u.LowPart / 100;
4724 wrq->u.data.length = sizeof(NDIS_802_11_STATISTICS);
4725 Status = copy_to_user(wrq->u.data.pointer, pStatistics, wrq->u.data.length);
4730 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_STATISTICS(kmalloc failed)\n"));
4734 case OID_GEN_RCV_OK:
4735 ulInfo = pAdapter->Counters8023.GoodReceives;
4736 wrq->u.data.length = sizeof(ulInfo);
4737 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4739 case OID_GEN_RCV_NO_BUFFER:
4740 ulInfo = pAdapter->Counters8023.RxNoBuffer;
4741 wrq->u.data.length = sizeof(ulInfo);
4742 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4744 case RT_OID_802_11_PHY_MODE:
4745 ulInfo = (ULONG)pAdapter->CommonCfg.PhyMode;
4746 wrq->u.data.length = sizeof(ulInfo);
4747 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4748 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_PHY_MODE (=%ld)\n", ulInfo));
4750 case RT_OID_802_11_STA_CONFIG:
4751 pStaConfig = (RT_802_11_STA_CONFIG *) kmalloc(sizeof(RT_802_11_STA_CONFIG), MEM_ALLOC_FLAG);
4754 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_STA_CONFIG\n"));
4755 pStaConfig->EnableTxBurst = pAdapter->CommonCfg.bEnableTxBurst;
4756 pStaConfig->EnableTurboRate = 0;
4757 pStaConfig->UseBGProtection = pAdapter->CommonCfg.UseBGProtection;
4758 pStaConfig->UseShortSlotTime = pAdapter->CommonCfg.bUseShortSlotTime;
4759 //pStaConfig->AdhocMode = pAdapter->StaCfg.AdhocMode;
4760 pStaConfig->HwRadioStatus = (pAdapter->StaCfg.bHwRadio == TRUE) ? 1 : 0;
4761 pStaConfig->Rsv1 = 0;
4762 pStaConfig->SystemErrorBitmap = pAdapter->SystemErrorBitmap;
4763 wrq->u.data.length = sizeof(RT_802_11_STA_CONFIG);
4764 Status = copy_to_user(wrq->u.data.pointer, pStaConfig, wrq->u.data.length);
4769 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_STA_CONFIG(kmalloc failed)\n"));
4773 case OID_802_11_RTS_THRESHOLD:
4774 RtsThresh = pAdapter->CommonCfg.RtsThreshold;
4775 wrq->u.data.length = sizeof(RtsThresh);
4776 Status = copy_to_user(wrq->u.data.pointer, &RtsThresh, wrq->u.data.length);
4777 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_RTS_THRESHOLD(=%ld)\n", RtsThresh));
4779 case OID_802_11_FRAGMENTATION_THRESHOLD:
4780 FragThresh = pAdapter->CommonCfg.FragmentThreshold;
4781 if (pAdapter->CommonCfg.bUseZeroToDisableFragment == TRUE)
4783 wrq->u.data.length = sizeof(FragThresh);
4784 Status = copy_to_user(wrq->u.data.pointer, &FragThresh, wrq->u.data.length);
4785 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_FRAGMENTATION_THRESHOLD(=%ld)\n", FragThresh));
4787 case OID_802_11_POWER_MODE:
4788 PowerMode = pAdapter->StaCfg.WindowsPowerMode;
4789 wrq->u.data.length = sizeof(PowerMode);
4790 Status = copy_to_user(wrq->u.data.pointer, &PowerMode, wrq->u.data.length);
4791 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_POWER_MODE(=%d)\n", PowerMode));
4793 case RT_OID_802_11_RADIO:
4794 RadioState = (BOOLEAN) pAdapter->StaCfg.bSwRadio;
4795 wrq->u.data.length = sizeof(RadioState);
4796 Status = copy_to_user(wrq->u.data.pointer, &RadioState, wrq->u.data.length);
4797 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_RADIO (=%d)\n", RadioState));
4799 case OID_802_11_INFRASTRUCTURE_MODE:
4800 if (pAdapter->StaCfg.BssType == BSS_ADHOC)
4801 BssType = Ndis802_11IBSS;
4802 else if (pAdapter->StaCfg.BssType == BSS_INFRA)
4803 BssType = Ndis802_11Infrastructure;
4804 else if (pAdapter->StaCfg.BssType == BSS_MONITOR)
4805 BssType = Ndis802_11Monitor;
4807 BssType = Ndis802_11AutoUnknown;
4809 wrq->u.data.length = sizeof(BssType);
4810 Status = copy_to_user(wrq->u.data.pointer, &BssType, wrq->u.data.length);
4811 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_INFRASTRUCTURE_MODE(=%d)\n", BssType));
4813 case RT_OID_802_11_PREAMBLE:
4814 PreamType = pAdapter->CommonCfg.TxPreamble;
4815 wrq->u.data.length = sizeof(PreamType);
4816 Status = copy_to_user(wrq->u.data.pointer, &PreamType, wrq->u.data.length);
4817 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_PREAMBLE(=%d)\n", PreamType));
4819 case OID_802_11_AUTHENTICATION_MODE:
4820 AuthMode = pAdapter->StaCfg.AuthMode;
4821 wrq->u.data.length = sizeof(AuthMode);
4822 Status = copy_to_user(wrq->u.data.pointer, &AuthMode, wrq->u.data.length);
4823 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_AUTHENTICATION_MODE(=%d)\n", AuthMode));
4825 case OID_802_11_WEP_STATUS:
4826 WepStatus = pAdapter->StaCfg.WepStatus;
4827 wrq->u.data.length = sizeof(WepStatus);
4828 Status = copy_to_user(wrq->u.data.pointer, &WepStatus, wrq->u.data.length);
4829 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_WEP_STATUS(=%d)\n", WepStatus));
4831 case OID_802_11_TX_POWER_LEVEL:
4832 wrq->u.data.length = sizeof(ULONG);
4833 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.TxPower, wrq->u.data.length);
4834 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_TX_POWER_LEVEL %x\n",pAdapter->CommonCfg.TxPower));
4836 case RT_OID_802_11_TX_POWER_LEVEL_1:
4837 wrq->u.data.length = sizeof(ULONG);
4838 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.TxPowerPercentage, wrq->u.data.length);
4839 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_TX_POWER_LEVEL_1 (=%ld)\n", pAdapter->CommonCfg.TxPowerPercentage));
4841 case OID_802_11_NETWORK_TYPES_SUPPORTED:
4842 if ((pAdapter->RfIcType == RFIC_2850) || (pAdapter->RfIcType == RFIC_2750))
4844 NetworkTypeList[0] = 3; // NumberOfItems = 3
4845 NetworkTypeList[1] = Ndis802_11DS; // NetworkType[1] = 11b
4846 NetworkTypeList[2] = Ndis802_11OFDM24; // NetworkType[2] = 11g
4847 NetworkTypeList[3] = Ndis802_11OFDM5; // NetworkType[3] = 11a
4848 wrq->u.data.length = 16;
4849 Status = copy_to_user(wrq->u.data.pointer, &NetworkTypeList[0], wrq->u.data.length);
4853 NetworkTypeList[0] = 2; // NumberOfItems = 2
4854 NetworkTypeList[1] = Ndis802_11DS; // NetworkType[1] = 11b
4855 NetworkTypeList[2] = Ndis802_11OFDM24; // NetworkType[2] = 11g
4856 wrq->u.data.length = 12;
4857 Status = copy_to_user(wrq->u.data.pointer, &NetworkTypeList[0], wrq->u.data.length);
4859 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_NETWORK_TYPES_SUPPORTED\n"));
4861 case OID_802_11_NETWORK_TYPE_IN_USE:
4862 wrq->u.data.length = sizeof(ULONG);
4863 if (pAdapter->CommonCfg.PhyMode == PHY_11A)
4864 ulInfo = Ndis802_11OFDM5;
4865 else if ((pAdapter->CommonCfg.PhyMode == PHY_11BG_MIXED) || (pAdapter->CommonCfg.PhyMode == PHY_11G))
4866 ulInfo = Ndis802_11OFDM24;
4868 ulInfo = Ndis802_11DS;
4869 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4871 case RT_OID_802_11_QUERY_LAST_RX_RATE:
4872 ulInfo = (ULONG)pAdapter->LastRxRate;
4873 wrq->u.data.length = sizeof(ulInfo);
4874 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4875 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_LAST_RX_RATE (=%ld)\n", ulInfo));
4877 case RT_OID_802_11_QUERY_LAST_TX_RATE:
4878 //ulInfo = (ULONG)pAdapter->LastTxRate;
4879 ulInfo = (ULONG)pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.word;
4880 wrq->u.data.length = sizeof(ulInfo);
4881 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4882 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_LAST_TX_RATE (=%lx)\n", ulInfo));
4884 case RT_OID_802_11_QUERY_EEPROM_VERSION:
4885 wrq->u.data.length = sizeof(ULONG);
4886 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->EepromVersion, wrq->u.data.length);
4888 case RT_OID_802_11_QUERY_FIRMWARE_VERSION:
4889 wrq->u.data.length = sizeof(ULONG);
4890 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->FirmwareVersion, wrq->u.data.length);
4892 case RT_OID_802_11_QUERY_NOISE_LEVEL:
4893 wrq->u.data.length = sizeof(UCHAR);
4894 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->BbpWriteLatch[66], wrq->u.data.length);
4895 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_NOISE_LEVEL (=%d)\n", pAdapter->BbpWriteLatch[66]));
4897 case RT_OID_802_11_EXTRA_INFO:
4898 wrq->u.data.length = sizeof(ULONG);
4899 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->ExtraInfo, wrq->u.data.length);
4900 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_EXTRA_INFO (=%ld)\n", pAdapter->ExtraInfo));
4902 case RT_OID_WE_VERSION_COMPILED:
4903 wrq->u.data.length = sizeof(UINT);
4904 we_version_compiled = WIRELESS_EXT;
4905 Status = copy_to_user(wrq->u.data.pointer, &we_version_compiled, wrq->u.data.length);
4907 case RT_OID_802_11_QUERY_APSD_SETTING:
4908 apsd = (pAdapter->CommonCfg.bAPSDCapable | (pAdapter->CommonCfg.bAPSDAC_BE << 1) | (pAdapter->CommonCfg.bAPSDAC_BK << 2)
4909 | (pAdapter->CommonCfg.bAPSDAC_VI << 3) | (pAdapter->CommonCfg.bAPSDAC_VO << 4) | (pAdapter->CommonCfg.MaxSPLength << 5));
4911 wrq->u.data.length = sizeof(ULONG);
4912 Status = copy_to_user(wrq->u.data.pointer, &apsd, wrq->u.data.length);
4913 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",
4914 apsd,pAdapter->CommonCfg.bAPSDCapable,pAdapter->CommonCfg.bAPSDAC_BE,pAdapter->CommonCfg.bAPSDAC_BK,pAdapter->CommonCfg.bAPSDAC_VI,pAdapter->CommonCfg.bAPSDAC_VO,pAdapter->CommonCfg.MaxSPLength));
4916 case RT_OID_802_11_QUERY_APSD_PSM:
4917 wrq->u.data.length = sizeof(ULONG);
4918 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.bAPSDForcePowerSave, wrq->u.data.length);
4919 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_APSD_PSM (=%d)\n", pAdapter->CommonCfg.bAPSDForcePowerSave));
4921 case RT_OID_802_11_QUERY_WMM:
4922 wrq->u.data.length = sizeof(BOOLEAN);
4923 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.bWmmCapable, wrq->u.data.length);
4924 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_WMM (=%d)\n", pAdapter->CommonCfg.bWmmCapable));
4926 #ifdef WPA_SUPPLICANT_SUPPORT
4927 case RT_OID_NEW_DRIVER:
4930 wrq->u.data.length = sizeof(UCHAR);
4931 Status = copy_to_user(wrq->u.data.pointer, &enabled, wrq->u.data.length);
4932 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_NEW_DRIVER (=%d)\n", enabled));
4935 case RT_OID_WPA_SUPPLICANT_SUPPORT:
4936 wrq->u.data.length = sizeof(UCHAR);
4937 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->StaCfg.WpaSupplicantUP, wrq->u.data.length);
4938 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_WPA_SUPPLICANT_SUPPORT (=%d)\n", pAdapter->StaCfg.WpaSupplicantUP));
4940 #endif // WPA_SUPPLICANT_SUPPORT //
4942 case RT_OID_DRIVER_DEVICE_NAME:
4943 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_DRIVER_DEVICE_NAME \n"));
4944 wrq->u.data.length = 16;
4945 if (copy_to_user(wrq->u.data.pointer, pAdapter->StaCfg.dev_name, wrq->u.data.length))
4950 case RT_OID_802_11_QUERY_HT_PHYMODE:
4951 pHTPhyMode = (OID_SET_HT_PHYMODE *) kmalloc(sizeof(OID_SET_HT_PHYMODE), MEM_ALLOC_FLAG);
4954 pHTPhyMode->PhyMode = pAdapter->CommonCfg.PhyMode;
4955 pHTPhyMode->HtMode = (UCHAR)pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.field.MODE;
4956 pHTPhyMode->BW = (UCHAR)pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.field.BW;
4957 pHTPhyMode->MCS= (UCHAR)pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.field.MCS;
4958 pHTPhyMode->SHORTGI= (UCHAR)pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.field.ShortGI;
4959 pHTPhyMode->STBC= (UCHAR)pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.field.STBC;
4961 pHTPhyMode->ExtOffset = ((pAdapter->CommonCfg.CentralChannel < pAdapter->CommonCfg.Channel) ? (EXTCHA_BELOW) : (EXTCHA_ABOVE));
4962 wrq->u.data.length = sizeof(OID_SET_HT_PHYMODE);
4963 if (copy_to_user(wrq->u.data.pointer, pHTPhyMode, wrq->u.data.length))
4967 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_HT_PHYMODE (PhyMode = %d, MCS =%d, BW = %d, STBC = %d, ExtOffset=%d)\n",
4968 pHTPhyMode->HtMode, pHTPhyMode->MCS, pHTPhyMode->BW, pHTPhyMode->STBC, pHTPhyMode->ExtOffset));
4969 DBGPRINT(RT_DEBUG_TRACE, (" MlmeUpdateTxRates (.word = %x )\n", pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.word));
4973 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_STA_CONFIG(kmalloc failed)\n"));
4977 case RT_OID_802_11_COUNTRY_REGION:
4978 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_COUNTRY_REGION \n"));
4979 wrq->u.data.length = sizeof(ulInfo);
4980 ulInfo = pAdapter->CommonCfg.CountryRegionForABand;
4981 ulInfo = (ulInfo << 8)|(pAdapter->CommonCfg.CountryRegion);
4982 if (copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length))
4987 case RT_OID_802_11_QUERY_DAT_HT_PHYMODE:
4988 pHTPhyMode = (OID_SET_HT_PHYMODE *) kmalloc(sizeof(OID_SET_HT_PHYMODE), MEM_ALLOC_FLAG);
4991 pHTPhyMode->PhyMode = pAdapter->CommonCfg.PhyMode;
4992 pHTPhyMode->HtMode = (UCHAR)pAdapter->CommonCfg.RegTransmitSetting.field.HTMODE;
4993 pHTPhyMode->BW = (UCHAR)pAdapter->CommonCfg.RegTransmitSetting.field.BW;
4994 pHTPhyMode->MCS= (UCHAR)pAdapter->StaCfg.DesiredTransmitSetting.field.MCS;
4995 pHTPhyMode->SHORTGI= (UCHAR)pAdapter->CommonCfg.RegTransmitSetting.field.ShortGI;
4996 pHTPhyMode->STBC= (UCHAR)pAdapter->CommonCfg.RegTransmitSetting.field.STBC;
4998 wrq->u.data.length = sizeof(OID_SET_HT_PHYMODE);
4999 if (copy_to_user(wrq->u.data.pointer, pHTPhyMode, wrq->u.data.length))
5003 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_HT_PHYMODE (PhyMode = %d, MCS =%d, BW = %d, STBC = %d, ExtOffset=%d)\n",
5004 pHTPhyMode->HtMode, pHTPhyMode->MCS, pHTPhyMode->BW, pHTPhyMode->STBC, pHTPhyMode->ExtOffset));
5005 DBGPRINT(RT_DEBUG_TRACE, (" MlmeUpdateTxRates (.word = %x )\n", pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.word));
5009 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_STA_CONFIG(kmalloc failed)\n"));
5013 case RT_OID_QUERY_MULTIPLE_CARD_SUPPORT:
5014 wrq->u.data.length = sizeof(UCHAR);
5016 if (copy_to_user(wrq->u.data.pointer, &i, wrq->u.data.length))
5020 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_QUERY_MULTIPLE_CARD_SUPPORT(=%d) \n", i));
5023 case RT_OID_802_11_MAC_ADDRESS:
5024 wrq->u.data.length = MAC_ADDR_LEN;
5025 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CurrentAddress, wrq->u.data.length);
5028 case RT_OID_802_11_MANUFACTUREROUI:
5029 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_MANUFACTUREROUI \n"));
5030 wrq->u.data.length = ManufacturerOUI_LEN;
5031 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CurrentAddress, wrq->u.data.length);
5034 case RT_OID_802_11_MANUFACTURERNAME:
5035 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_MANUFACTURERNAME \n"));
5036 wrq->u.data.length = strlen(ManufacturerNAME);
5037 Status = copy_to_user(wrq->u.data.pointer, ManufacturerNAME, wrq->u.data.length);
5040 case RT_OID_802_11_RESOURCETYPEIDNAME:
5041 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_RESOURCETYPEIDNAME \n"));
5042 wrq->u.data.length = strlen(ResourceTypeIdName);
5043 Status = copy_to_user(wrq->u.data.pointer, ResourceTypeIdName, wrq->u.data.length);
5046 case RT_OID_802_11_PRIVACYOPTIONIMPLEMENTED:
5047 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_PRIVACYOPTIONIMPLEMENTED \n"));
5048 ulInfo = 1; // 1 is support wep else 2 is not support.
5049 wrq->u.data.length = sizeof(ulInfo);
5050 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
5053 case RT_OID_802_11_POWERMANAGEMENTMODE:
5054 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_POWERMANAGEMENTMODE \n"));
5055 if (pAdapter->StaCfg.Psm == PSMP_ACTION)
5056 ulInfo = 1; // 1 is power active else 2 is power save.
5060 wrq->u.data.length = sizeof(ulInfo);
5061 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
5064 case OID_802_11_WEPDEFAULTKEYVALUE:
5065 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_WEPDEFAULTKEYVALUE \n"));
5066 //KeyIdxValue.KeyIdx = pAd->PortCfg.MBSSID[pAd->IoctlIF].DefaultKeyId;
5067 pKeyIdxValue = wrq->u.data.pointer;
5068 DBGPRINT(RT_DEBUG_TRACE,("KeyIdxValue.KeyIdx = %d, \n",pKeyIdxValue->KeyIdx));
5069 valueLen = pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].KeyLen;
5070 NdisMoveMemory(pKeyIdxValue->Value,
5071 &pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].Key,
5073 pKeyIdxValue->Value[valueLen]='\0';
5075 wrq->u.data.length = sizeof(DefaultKeyIdxValue);
5077 Status = copy_to_user(wrq->u.data.pointer, pKeyIdxValue, wrq->u.data.length);
5078 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,
5079 pAdapter->SharedKey[BSS0][0].Key[0],
5080 pAdapter->SharedKey[BSS0][1].Key[0],
5081 pAdapter->SharedKey[BSS0][2].Key[0],
5082 pAdapter->SharedKey[BSS0][3].Key[0]));
5085 case OID_802_11_WEPDEFAULTKEYID:
5086 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_WEPDEFAULTKEYID \n"));
5087 wrq->u.data.length = sizeof(UCHAR);
5088 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->StaCfg.DefaultKeyId, wrq->u.data.length);
5089 DBGPRINT(RT_DEBUG_TRACE, ("DefaultKeyId =%d \n", pAdapter->StaCfg.DefaultKeyId));
5092 case RT_OID_802_11_WEPKEYMAPPINGLENGTH:
5093 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_WEPKEYMAPPINGLENGTH \n"));
5094 wrq->u.data.length = sizeof(UCHAR);
5095 Status = copy_to_user(wrq->u.data.pointer,
5096 &pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].KeyLen,
5097 wrq->u.data.length);
5100 case OID_802_11_SHORTRETRYLIMIT:
5101 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_SHORTRETRYLIMIT \n"));
5102 wrq->u.data.length = sizeof(ULONG);
5103 RTMP_IO_READ32(pAdapter, TX_RTY_CFG, &tx_rty_cfg.word);
5104 ShortRetryLimit = tx_rty_cfg.field.ShortRtyLimit;
5105 DBGPRINT(RT_DEBUG_TRACE, ("ShortRetryLimit =%ld, tx_rty_cfg.field.ShortRetryLimit=%d\n", ShortRetryLimit, tx_rty_cfg.field.ShortRtyLimit));
5106 Status = copy_to_user(wrq->u.data.pointer, &ShortRetryLimit, wrq->u.data.length);
5109 case OID_802_11_LONGRETRYLIMIT:
5110 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_LONGRETRYLIMIT \n"));
5111 wrq->u.data.length = sizeof(ULONG);
5112 RTMP_IO_READ32(pAdapter, TX_RTY_CFG, &tx_rty_cfg.word);
5113 LongRetryLimit = tx_rty_cfg.field.LongRtyLimit;
5114 DBGPRINT(RT_DEBUG_TRACE, ("LongRetryLimit =%ld, tx_rty_cfg.field.LongRtyLimit=%d\n", LongRetryLimit, tx_rty_cfg.field.LongRtyLimit));
5115 Status = copy_to_user(wrq->u.data.pointer, &LongRetryLimit, wrq->u.data.length);
5118 case RT_OID_802_11_PRODUCTID:
5119 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_PRODUCTID \n"));
5122 sprintf(tmp, "%04x %04x\n", ((POS_COOKIE)pAdapter->OS_Cookie)->pUsb_Dev->descriptor.idVendor ,((POS_COOKIE)pAdapter->OS_Cookie)->pUsb_Dev->descriptor.idProduct);
5125 wrq->u.data.length = strlen(tmp);
5126 Status = copy_to_user(wrq->u.data.pointer, tmp, wrq->u.data.length);
5129 case RT_OID_802_11_MANUFACTUREID:
5130 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_MANUFACTUREID \n"));
5131 wrq->u.data.length = strlen(ManufacturerNAME);
5132 Status = copy_to_user(wrq->u.data.pointer, ManufacturerNAME, wrq->u.data.length);
5135 case OID_802_11_CURRENTCHANNEL:
5136 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_CURRENTCHANNEL \n"));
5137 wrq->u.data.length = sizeof(UCHAR);
5138 DBGPRINT(RT_DEBUG_TRACE, ("sizeof UCHAR=%d, channel=%d \n", sizeof(UCHAR), pAdapter->CommonCfg.Channel));
5139 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.Channel, wrq->u.data.length);
5140 DBGPRINT(RT_DEBUG_TRACE, ("Status=%d\n", Status));
5142 #endif //SNMP_SUPPORT
5144 case OID_802_11_BUILD_CHANNEL_EX:
5147 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_BUILD_CHANNEL_EX \n"));
5148 wrq->u.data.length = sizeof(UCHAR);
5149 #ifdef EXT_BUILD_CHANNEL_LIST
5150 DBGPRINT(RT_DEBUG_TRACE, ("Support EXT_BUILD_CHANNEL_LIST.\n"));
5153 DBGPRINT(RT_DEBUG_TRACE, ("Doesn't support EXT_BUILD_CHANNEL_LIST.\n"));
5155 #endif // EXT_BUILD_CHANNEL_LIST //
5156 Status = copy_to_user(wrq->u.data.pointer, &value, 1);
5157 DBGPRINT(RT_DEBUG_TRACE, ("Status=%d\n", Status));
5161 case OID_802_11_GET_CH_LIST:
5163 PRT_CHANNEL_LIST_INFO pChListBuf;
5165 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_GET_CH_LIST \n"));
5166 if (pAdapter->ChannelListNum == 0)
5168 wrq->u.data.length = 0;
5172 pChListBuf = (RT_CHANNEL_LIST_INFO *) kmalloc(sizeof(RT_CHANNEL_LIST_INFO), MEM_ALLOC_FLAG);
5173 if (pChListBuf == NULL)
5175 wrq->u.data.length = 0;
5179 pChListBuf->ChannelListNum = pAdapter->ChannelListNum;
5180 for (i = 0; i < pChListBuf->ChannelListNum; i++)
5181 pChListBuf->ChannelList[i] = pAdapter->ChannelList[i].Channel;
5183 wrq->u.data.length = sizeof(RT_CHANNEL_LIST_INFO);
5184 Status = copy_to_user(wrq->u.data.pointer, pChListBuf, sizeof(RT_CHANNEL_LIST_INFO));
5185 DBGPRINT(RT_DEBUG_TRACE, ("Status=%d\n", Status));
5192 case OID_802_11_GET_COUNTRY_CODE:
5193 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_GET_COUNTRY_CODE \n"));
5194 wrq->u.data.length = 2;
5195 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.CountryCode, 2);
5196 DBGPRINT(RT_DEBUG_TRACE, ("Status=%d\n", Status));
5199 case OID_802_11_GET_CHANNEL_GEOGRAPHY:
5200 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_GET_CHANNEL_GEOGRAPHY \n"));
5201 wrq->u.data.length = 1;
5202 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.Geography, 1);
5203 DBGPRINT(RT_DEBUG_TRACE, ("Status=%d\n", Status));
5207 #ifdef QOS_DLS_SUPPORT
5208 case RT_OID_802_11_QUERY_DLS:
5209 wrq->u.data.length = sizeof(BOOLEAN);
5210 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.bDLSCapable, wrq->u.data.length);
5211 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_DLS(=%d)\n", pAdapter->CommonCfg.bDLSCapable));
5214 case RT_OID_802_11_QUERY_DLS_PARAM:
5216 PRT_802_11_DLS_INFO pDlsInfo = kmalloc(sizeof(RT_802_11_DLS_INFO), GFP_ATOMIC);
5217 if (pDlsInfo == NULL)
5220 for (i=0; i<MAX_NUM_OF_DLS_ENTRY; i++)
5222 RTMPMoveMemory(&pDlsInfo->Entry[i], &pAdapter->StaCfg.DLSEntry[i], sizeof(RT_802_11_DLS_UI));
5225 pDlsInfo->num = MAX_NUM_OF_DLS_ENTRY;
5226 wrq->u.data.length = sizeof(RT_802_11_DLS_INFO);
5227 Status = copy_to_user(wrq->u.data.pointer, pDlsInfo, wrq->u.data.length);
5228 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_DLS_PARAM\n"));
5234 #endif // QOS_DLS_SUPPORT //
5236 DBGPRINT(RT_DEBUG_TRACE, ("Query::unknown IOCTL's subcmd = 0x%08x\n", cmd));
5237 Status = -EOPNOTSUPP;
5243 INT rt28xx_sta_ioctl(
5244 IN struct net_device *net_dev,
5245 IN OUT struct ifreq *rq,
5249 VIRTUAL_ADAPTER *pVirtualAd = NULL;
5250 RTMP_ADAPTER *pAd = NULL;
5251 struct iwreq *wrq = (struct iwreq *) rq;
5252 BOOLEAN StateMachineTouched = FALSE;
5253 INT Status = NDIS_STATUS_SUCCESS;
5256 if (net_dev->priv_flags == INT_MAIN)
5258 pAd = net_dev->ml_priv;
5262 pVirtualAd = net_dev->ml_priv;
5263 pAd = pVirtualAd->RtmpDev->ml_priv;
5265 pObj = (POS_COOKIE) pAd->OS_Cookie;
5269 /* if 1st open fail, pAd will be free;
5270 So the net_dev->ml_priv will be NULL in 2rd open */
5274 //check if the interface is down
5275 if(!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_IN_USE))
5278 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
5283 { // determine this ioctl command is comming from which interface.
5284 pObj->ioctl_if_type = INT_MAIN;
5285 pObj->ioctl_if = MAIN_MBSSID;
5291 DBGPRINT(RT_DEBUG_TRACE, ("IOCTL::SIOCGIFHWADDR\n"));
5292 memcpy(wrq->u.name, pAd->CurrentAddress, ETH_ALEN);
5296 char *name=&wrq->u.name[0];
5297 rt_ioctl_giwname(net_dev, NULL, name, NULL);
5300 case SIOCGIWESSID: //Get ESSID
5302 struct iw_point *essid=&wrq->u.essid;
5303 rt_ioctl_giwessid(net_dev, NULL, essid, essid->pointer);
5306 case SIOCSIWESSID: //Set ESSID
5308 struct iw_point *essid=&wrq->u.essid;
5309 rt_ioctl_siwessid(net_dev, NULL, essid, essid->pointer);
5312 case SIOCSIWNWID: // set network id (the cell)
5313 case SIOCGIWNWID: // get network id
5314 Status = -EOPNOTSUPP;
5316 case SIOCSIWFREQ: //set channel/frequency (Hz)
5318 struct iw_freq *freq=&wrq->u.freq;
5319 rt_ioctl_siwfreq(net_dev, NULL, freq, NULL);
5322 case SIOCGIWFREQ: // get channel/frequency (Hz)
5324 struct iw_freq *freq=&wrq->u.freq;
5325 rt_ioctl_giwfreq(net_dev, NULL, freq, NULL);
5328 case SIOCSIWNICKN: //set node name/nickname
5330 struct iw_point *data=&wrq->u.data;
5331 rt_ioctl_siwnickn(net_dev, NULL, data, NULL);
5334 case SIOCGIWNICKN: //get node name/nickname
5336 struct iw_point *data=&wrq->u.data;
5337 rt_ioctl_giwnickn(net_dev, NULL, data, NULL);
5340 case SIOCGIWRATE: //get default bit rate (bps)
5341 rt_ioctl_giwrate(net_dev, NULL, &wrq->u, NULL);
5343 case SIOCSIWRATE: //set default bit rate (bps)
5344 rt_ioctl_siwrate(net_dev, NULL, &wrq->u, NULL);
5346 case SIOCGIWRTS: // get RTS/CTS threshold (bytes)
5348 struct iw_param *rts=&wrq->u.rts;
5349 rt_ioctl_giwrts(net_dev, NULL, rts, NULL);
5352 case SIOCSIWRTS: //set RTS/CTS threshold (bytes)
5354 struct iw_param *rts=&wrq->u.rts;
5355 rt_ioctl_siwrts(net_dev, NULL, rts, NULL);
5358 case SIOCGIWFRAG: //get fragmentation thr (bytes)
5360 struct iw_param *frag=&wrq->u.frag;
5361 rt_ioctl_giwfrag(net_dev, NULL, frag, NULL);
5364 case SIOCSIWFRAG: //set fragmentation thr (bytes)
5366 struct iw_param *frag=&wrq->u.frag;
5367 rt_ioctl_siwfrag(net_dev, NULL, frag, NULL);
5370 case SIOCGIWENCODE: //get encoding token & mode
5372 struct iw_point *erq=&wrq->u.encoding;
5374 rt_ioctl_giwencode(net_dev, NULL, erq, erq->pointer);
5377 case SIOCSIWENCODE: //set encoding token & mode
5379 struct iw_point *erq=&wrq->u.encoding;
5381 rt_ioctl_siwencode(net_dev, NULL, erq, erq->pointer);
5384 case SIOCGIWAP: //get access point MAC addresses
5386 struct sockaddr *ap_addr=&wrq->u.ap_addr;
5387 rt_ioctl_giwap(net_dev, NULL, ap_addr, ap_addr->sa_data);
5390 case SIOCSIWAP: //set access point MAC addresses
5392 struct sockaddr *ap_addr=&wrq->u.ap_addr;
5393 rt_ioctl_siwap(net_dev, NULL, ap_addr, ap_addr->sa_data);
5396 case SIOCGIWMODE: //get operation mode
5398 __u32 *mode=&wrq->u.mode;
5399 rt_ioctl_giwmode(net_dev, NULL, mode, NULL);
5402 case SIOCSIWMODE: //set operation mode
5404 __u32 *mode=&wrq->u.mode;
5405 rt_ioctl_siwmode(net_dev, NULL, mode, NULL);
5408 case SIOCGIWSENS: //get sensitivity (dBm)
5409 case SIOCSIWSENS: //set sensitivity (dBm)
5410 case SIOCGIWPOWER: //get Power Management settings
5411 case SIOCSIWPOWER: //set Power Management settings
5412 case SIOCGIWTXPOW: //get transmit power (dBm)
5413 case SIOCSIWTXPOW: //set transmit power (dBm)
5414 case SIOCGIWRANGE: //Get range of parameters
5415 case SIOCGIWRETRY: //get retry limits and lifetime
5416 case SIOCSIWRETRY: //set retry limits and lifetime
5417 Status = -EOPNOTSUPP;
5420 case RT_PRIV_IOCTL_EXT:
5421 subcmd = wrq->u.data.flags;
5422 if( subcmd & OID_GET_SET_TOGGLE)
5423 Status = RTMPSetInformation(pAd, rq, subcmd);
5425 Status = RTMPQueryInformation(pAd, rq, subcmd);
5428 if (wrq->u.data.pointer)
5430 if ( access_ok(VERIFY_WRITE, wrq->u.data.pointer, sizeof(privtab)) != TRUE)
5432 wrq->u.data.length = sizeof(privtab) / sizeof(privtab[0]);
5433 if (copy_to_user(wrq->u.data.pointer, privtab, sizeof(privtab)))
5437 case RTPRIV_IOCTL_SET:
5438 if(access_ok(VERIFY_READ, wrq->u.data.pointer, wrq->u.data.length) != TRUE)
5440 rt_ioctl_setparam(net_dev, NULL, NULL, wrq->u.data.pointer);
5442 case RTPRIV_IOCTL_GSITESURVEY:
5443 RTMPIoctlGetSiteSurvey(pAd, wrq);
5446 case RTPRIV_IOCTL_MAC:
5447 RTMPIoctlMAC(pAd, wrq);
5449 case RTPRIV_IOCTL_E2P:
5450 RTMPIoctlE2PROM(pAd, wrq);
5453 case RTPRIV_IOCTL_RF:
5454 RTMPIoctlRF(pAd, wrq);
5461 DBGPRINT(RT_DEBUG_ERROR, ("IOCTL::unknown IOCTL's cmd = 0x%08x\n", cmd));
5462 Status = -EOPNOTSUPP;
5466 if(StateMachineTouched) // Upper layer sent a MLME-related operations
5467 RT28XX_MLME_HANDLER(pAd);
5473 ==========================================================================
5477 TRUE if all parameters are OK, FALSE otherwise
5478 ==========================================================================
5481 IN PRTMP_ADAPTER pAdapter,
5484 NDIS_802_11_SSID Ssid, *pSsid=NULL;
5485 BOOLEAN StateMachineTouched = FALSE;
5488 if( strlen(arg) <= MAX_LEN_OF_SSID)
5490 NdisZeroMemory(&Ssid, sizeof(NDIS_802_11_SSID));
5491 if (strlen(arg) != 0)
5493 NdisMoveMemory(Ssid.Ssid, arg, strlen(arg));
5494 Ssid.SsidLength = strlen(arg);
5498 Ssid.SsidLength = 0;
5499 memcpy(Ssid.Ssid, "", 0);
5500 pAdapter->StaCfg.BssType = BSS_INFRA;
5501 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
5502 pAdapter->StaCfg.WepStatus = Ndis802_11EncryptionDisabled;
5506 if (pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE)
5508 RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
5509 DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
5512 pAdapter->MlmeAux.CurrReqIsFromNdis = TRUE;
5513 pAdapter->StaCfg.bScanReqIsFromWebUI = FALSE;
5514 pAdapter->bConfigChanged = TRUE;
5516 MlmeEnqueue(pAdapter,
5517 MLME_CNTL_STATE_MACHINE,
5519 sizeof(NDIS_802_11_SSID),
5522 StateMachineTouched = TRUE;
5523 DBGPRINT(RT_DEBUG_TRACE, ("Set_SSID_Proc::(Len=%d,Ssid=%s)\n", Ssid.SsidLength, Ssid.Ssid));
5528 if (StateMachineTouched) // Upper layer sent a MLME-related operations
5529 RT28XX_MLME_HANDLER(pAdapter);
5536 ==========================================================================
5538 Set WmmCapable Enable or Disable
5540 TRUE if all parameters are OK, FALSE otherwise
5541 ==========================================================================
5543 INT Set_WmmCapable_Proc(
5544 IN PRTMP_ADAPTER pAd,
5547 BOOLEAN bWmmCapable;
5549 bWmmCapable = simple_strtol(arg, 0, 10);
5551 if ((bWmmCapable == 1)
5553 && (pAd->NumberOfPipes >= 5)
5556 pAd->CommonCfg.bWmmCapable = TRUE;
5557 else if (bWmmCapable == 0)
5558 pAd->CommonCfg.bWmmCapable = FALSE;
5560 return FALSE; //Invalid argument
5562 DBGPRINT(RT_DEBUG_TRACE, ("Set_WmmCapable_Proc::(bWmmCapable=%d)\n",
5563 pAd->CommonCfg.bWmmCapable));
5567 #endif // WMM_SUPPORT //
5570 ==========================================================================
5572 Set Network Type(Infrastructure/Adhoc mode)
5574 TRUE if all parameters are OK, FALSE otherwise
5575 ==========================================================================
5577 INT Set_NetworkType_Proc(
5578 IN PRTMP_ADAPTER pAdapter,
5583 if (strcmp(arg, "Adhoc") == 0)
5585 if (pAdapter->StaCfg.BssType != BSS_ADHOC)
5587 // Config has changed
5588 pAdapter->bConfigChanged = TRUE;
5589 if (MONITOR_ON(pAdapter))
5591 RTMP_IO_WRITE32(pAdapter, RX_FILTR_CFG, STANORMAL);
5592 RTMP_IO_READ32(pAdapter, MAC_SYS_CTRL, &Value);
5594 RTMP_IO_WRITE32(pAdapter, MAC_SYS_CTRL, Value);
5595 OPSTATUS_CLEAR_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED);
5596 pAdapter->StaCfg.bAutoReconnect = TRUE;
5597 LinkDown(pAdapter, FALSE);
5599 if (INFRA_ON(pAdapter))
5601 //BOOLEAN Cancelled;
5602 // Set the AutoReconnectSsid to prevent it reconnect to old SSID
5603 // Since calling this indicate user don't want to connect to that SSID anymore.
5604 pAdapter->MlmeAux.AutoReconnectSsidLen= 32;
5605 NdisZeroMemory(pAdapter->MlmeAux.AutoReconnectSsid, pAdapter->MlmeAux.AutoReconnectSsidLen);
5607 LinkDown(pAdapter, FALSE);
5609 DBGPRINT(RT_DEBUG_TRACE, ("NDIS_STATUS_MEDIA_DISCONNECT Event BB!\n"));
5612 pAdapter->StaCfg.BssType = BSS_ADHOC;
5613 pAdapter->net_dev->type = pAdapter->StaCfg.OriDevType;
5614 DBGPRINT(RT_DEBUG_TRACE, ("===>Set_NetworkType_Proc::(AD-HOC)\n"));
5616 else if (strcmp(arg, "Infra") == 0)
5618 if (pAdapter->StaCfg.BssType != BSS_INFRA)
5620 // Config has changed
5621 pAdapter->bConfigChanged = TRUE;
5622 if (MONITOR_ON(pAdapter))
5624 RTMP_IO_WRITE32(pAdapter, RX_FILTR_CFG, STANORMAL);
5625 RTMP_IO_READ32(pAdapter, MAC_SYS_CTRL, &Value);
5627 RTMP_IO_WRITE32(pAdapter, MAC_SYS_CTRL, Value);
5628 OPSTATUS_CLEAR_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED);
5629 pAdapter->StaCfg.bAutoReconnect = TRUE;
5630 LinkDown(pAdapter, FALSE);
5632 if (ADHOC_ON(pAdapter))
5634 // Set the AutoReconnectSsid to prevent it reconnect to old SSID
5635 // Since calling this indicate user don't want to connect to that SSID anymore.
5636 pAdapter->MlmeAux.AutoReconnectSsidLen= 32;
5637 NdisZeroMemory(pAdapter->MlmeAux.AutoReconnectSsid, pAdapter->MlmeAux.AutoReconnectSsidLen);
5639 LinkDown(pAdapter, FALSE);
5642 pAdapter->StaCfg.BssType = BSS_INFRA;
5643 pAdapter->net_dev->type = pAdapter->StaCfg.OriDevType;
5644 DBGPRINT(RT_DEBUG_TRACE, ("===>Set_NetworkType_Proc::(INFRA)\n"));
5646 pAdapter->StaCfg.BssType = BSS_INFRA;
5648 else if (strcmp(arg, "Monitor") == 0)
5651 BCN_TIME_CFG_STRUC csr;
5652 OPSTATUS_CLEAR_FLAG(pAdapter, fOP_STATUS_INFRA_ON);
5653 OPSTATUS_CLEAR_FLAG(pAdapter, fOP_STATUS_ADHOC_ON);
5654 OPSTATUS_SET_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED);
5655 // disable all periodic state machine
5656 pAdapter->StaCfg.bAutoReconnect = FALSE;
5657 // reset all mlme state machine
5658 RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
5659 DBGPRINT(RT_DEBUG_TRACE, ("fOP_STATUS_MEDIA_STATE_CONNECTED \n"));
5660 if (pAdapter->CommonCfg.CentralChannel == 0)
5662 #ifdef DOT11_N_SUPPORT
5663 if (pAdapter->CommonCfg.PhyMode == PHY_11AN_MIXED)
5664 pAdapter->CommonCfg.CentralChannel = 36;
5666 #endif // DOT11_N_SUPPORT //
5667 pAdapter->CommonCfg.CentralChannel = 6;
5669 #ifdef DOT11_N_SUPPORT
5671 N_ChannelCheck(pAdapter);
5672 #endif // DOT11_N_SUPPORT //
5674 #ifdef DOT11_N_SUPPORT
5675 if (pAdapter->CommonCfg.PhyMode >= PHY_11ABGN_MIXED &&
5676 pAdapter->CommonCfg.RegTransmitSetting.field.BW == BW_40 &&
5677 pAdapter->CommonCfg.RegTransmitSetting.field.EXTCHA == EXTCHA_ABOVE)
5679 // 40MHz ,control channel at lower
5680 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, BBP_R4, &bbpValue);
5681 bbpValue &= (~0x18);
5683 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R4, bbpValue);
5684 pAdapter->CommonCfg.BBPCurrentBW = BW_40;
5685 // RX : control channel at lower
5686 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, BBP_R3, &bbpValue);
5687 bbpValue &= (~0x20);
5688 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R3, bbpValue);
5690 RTMP_IO_READ32(pAdapter, TX_BAND_CFG, &Value);
5691 Value &= 0xfffffffe;
5692 RTMP_IO_WRITE32(pAdapter, TX_BAND_CFG, Value);
5693 pAdapter->CommonCfg.CentralChannel = pAdapter->CommonCfg.Channel + 2;
5694 AsicSwitchChannel(pAdapter, pAdapter->CommonCfg.CentralChannel, FALSE);
5695 AsicLockChannel(pAdapter, pAdapter->CommonCfg.CentralChannel);
5696 DBGPRINT(RT_DEBUG_TRACE, ("BW_40 ,control_channel(%d), CentralChannel(%d) \n",
5697 pAdapter->CommonCfg.Channel,
5698 pAdapter->CommonCfg.CentralChannel));
5700 else if (pAdapter->CommonCfg.PhyMode >= PHY_11ABGN_MIXED &&
5701 pAdapter->CommonCfg.RegTransmitSetting.field.BW == BW_40 &&
5702 pAdapter->CommonCfg.RegTransmitSetting.field.EXTCHA == EXTCHA_BELOW)
5704 // 40MHz ,control channel at upper
5705 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, BBP_R4, &bbpValue);
5706 bbpValue &= (~0x18);
5708 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R4, bbpValue);
5709 pAdapter->CommonCfg.BBPCurrentBW = BW_40;
5710 RTMP_IO_READ32(pAdapter, TX_BAND_CFG, &Value);
5712 RTMP_IO_WRITE32(pAdapter, TX_BAND_CFG, Value);
5714 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, BBP_R3, &bbpValue);
5716 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R3, bbpValue);
5717 pAdapter->CommonCfg.CentralChannel = pAdapter->CommonCfg.Channel - 2;
5718 AsicSwitchChannel(pAdapter, pAdapter->CommonCfg.CentralChannel, FALSE);
5719 AsicLockChannel(pAdapter, pAdapter->CommonCfg.CentralChannel);
5720 DBGPRINT(RT_DEBUG_TRACE, ("BW_40 ,control_channel(%d), CentralChannel(%d) \n",
5721 pAdapter->CommonCfg.Channel,
5722 pAdapter->CommonCfg.CentralChannel));
5725 #endif // DOT11_N_SUPPORT //
5728 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, BBP_R4, &bbpValue);
5729 bbpValue &= (~0x18);
5730 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R4, bbpValue);
5731 pAdapter->CommonCfg.BBPCurrentBW = BW_20;
5732 AsicSwitchChannel(pAdapter, pAdapter->CommonCfg.Channel, FALSE);
5733 AsicLockChannel(pAdapter, pAdapter->CommonCfg.Channel);
5734 DBGPRINT(RT_DEBUG_TRACE, ("BW_20, Channel(%d)\n", pAdapter->CommonCfg.Channel));
5736 // Enable Rx with promiscuous reception
5737 RTMP_IO_WRITE32(pAdapter, RX_FILTR_CFG, 0x3);
5738 // ASIC supporsts sniffer function with replacing RSSI with timestamp.
5739 //RTMP_IO_READ32(pAdapter, MAC_SYS_CTRL, &Value);
5741 //RTMP_IO_WRITE32(pAdapter, MAC_SYS_CTRL, Value);
5743 RTMP_IO_READ32(pAdapter, BCN_TIME_CFG, &csr.word);
5744 csr.field.bBeaconGen = 0;
5745 csr.field.bTBTTEnable = 0;
5746 csr.field.TsfSyncMode = 0;
5747 RTMP_IO_WRITE32(pAdapter, BCN_TIME_CFG, csr.word);
5749 pAdapter->StaCfg.BssType = BSS_MONITOR;
5750 pAdapter->net_dev->type = ARPHRD_IEEE80211_PRISM; //ARPHRD_IEEE80211; // IEEE80211
5751 DBGPRINT(RT_DEBUG_TRACE, ("===>Set_NetworkType_Proc::(MONITOR)\n"));
5754 // Reset Ralink supplicant to not use, it will be set to start when UI set PMK key
5755 pAdapter->StaCfg.WpaState = SS_NOTUSE;
5757 DBGPRINT(RT_DEBUG_TRACE, ("Set_NetworkType_Proc::(NetworkType=%d)\n", pAdapter->StaCfg.BssType));
5763 ==========================================================================
5765 Set Authentication mode
5767 TRUE if all parameters are OK, FALSE otherwise
5768 ==========================================================================
5770 INT Set_AuthMode_Proc(
5771 IN PRTMP_ADAPTER pAdapter,
5774 if ((strcmp(arg, "WEPAUTO") == 0) || (strcmp(arg, "wepauto") == 0))
5775 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeAutoSwitch;
5776 else if ((strcmp(arg, "OPEN") == 0) || (strcmp(arg, "open") == 0))
5777 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
5778 else if ((strcmp(arg, "SHARED") == 0) || (strcmp(arg, "shared") == 0))
5779 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeShared;
5780 else if ((strcmp(arg, "WPAPSK") == 0) || (strcmp(arg, "wpapsk") == 0))
5781 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPAPSK;
5782 else if ((strcmp(arg, "WPANONE") == 0) || (strcmp(arg, "wpanone") == 0))
5783 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPANone;
5784 else if ((strcmp(arg, "WPA2PSK") == 0) || (strcmp(arg, "wpa2psk") == 0))
5785 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA2PSK;
5786 #ifdef WPA_SUPPLICANT_SUPPORT
5787 else if ((strcmp(arg, "WPA") == 0) || (strcmp(arg, "wpa") == 0))
5788 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA;
5789 else if ((strcmp(arg, "WPA2") == 0) || (strcmp(arg, "wpa2") == 0))
5790 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA2;
5791 #endif // WPA_SUPPLICANT_SUPPORT //
5795 pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED;
5797 DBGPRINT(RT_DEBUG_TRACE, ("Set_AuthMode_Proc::(AuthMode=%d)\n", pAdapter->StaCfg.AuthMode));
5803 ==========================================================================
5807 TRUE if all parameters are OK, FALSE otherwise
5808 ==========================================================================
5810 INT Set_EncrypType_Proc(
5811 IN PRTMP_ADAPTER pAdapter,
5814 if ((strcmp(arg, "NONE") == 0) || (strcmp(arg, "none") == 0))
5816 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
5817 return TRUE; // do nothing
5819 pAdapter->StaCfg.WepStatus = Ndis802_11WEPDisabled;
5820 pAdapter->StaCfg.PairCipher = Ndis802_11WEPDisabled;
5821 pAdapter->StaCfg.GroupCipher = Ndis802_11WEPDisabled;
5823 else if ((strcmp(arg, "WEP") == 0) || (strcmp(arg, "wep") == 0))
5825 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
5826 return TRUE; // do nothing
5828 pAdapter->StaCfg.WepStatus = Ndis802_11WEPEnabled;
5829 pAdapter->StaCfg.PairCipher = Ndis802_11WEPEnabled;
5830 pAdapter->StaCfg.GroupCipher = Ndis802_11WEPEnabled;
5832 else if ((strcmp(arg, "TKIP") == 0) || (strcmp(arg, "tkip") == 0))
5834 if (pAdapter->StaCfg.AuthMode < Ndis802_11AuthModeWPA)
5835 return TRUE; // do nothing
5837 pAdapter->StaCfg.WepStatus = Ndis802_11Encryption2Enabled;
5838 pAdapter->StaCfg.PairCipher = Ndis802_11Encryption2Enabled;
5839 pAdapter->StaCfg.GroupCipher = Ndis802_11Encryption2Enabled;
5841 else if ((strcmp(arg, "AES") == 0) || (strcmp(arg, "aes") == 0))
5843 if (pAdapter->StaCfg.AuthMode < Ndis802_11AuthModeWPA)
5844 return TRUE; // do nothing
5846 pAdapter->StaCfg.WepStatus = Ndis802_11Encryption3Enabled;
5847 pAdapter->StaCfg.PairCipher = Ndis802_11Encryption3Enabled;
5848 pAdapter->StaCfg.GroupCipher = Ndis802_11Encryption3Enabled;
5853 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
5855 DBGPRINT(RT_DEBUG_TRACE, ("Set_EncrypType_Proc::(EncrypType=%d)\n", pAdapter->StaCfg.WepStatus));
5861 ==========================================================================
5865 TRUE if all parameters are OK, FALSE otherwise
5866 ==========================================================================
5868 INT Set_DefaultKeyID_Proc(
5869 IN PRTMP_ADAPTER pAdapter,
5874 KeyIdx = simple_strtol(arg, 0, 10);
5875 if((KeyIdx >= 1 ) && (KeyIdx <= 4))
5876 pAdapter->StaCfg.DefaultKeyId = (UCHAR) (KeyIdx - 1 );
5878 return FALSE; //Invalid argument
5880 DBGPRINT(RT_DEBUG_TRACE, ("Set_DefaultKeyID_Proc::(DefaultKeyID=%d)\n", pAdapter->StaCfg.DefaultKeyId));
5886 ==========================================================================
5890 TRUE if all parameters are OK, FALSE otherwise
5891 ==========================================================================
5894 IN PRTMP_ADAPTER pAdapter,
5899 UCHAR CipherAlg=CIPHER_WEP64;
5901 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
5902 return TRUE; // do nothing
5904 KeyLen = strlen(arg);
5908 case 5: //wep 40 Ascii type
5909 pAdapter->SharedKey[BSS0][0].KeyLen = KeyLen;
5910 memcpy(pAdapter->SharedKey[BSS0][0].Key, arg, KeyLen);
5911 CipherAlg = CIPHER_WEP64;
5912 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key1_Proc::(Key1=%s and type=%s)\n", arg, "Ascii"));
5914 case 10: //wep 40 Hex type
5915 for(i=0; i < KeyLen; i++)
5917 if( !isxdigit(*(arg+i)) )
5918 return FALSE; //Not Hex value;
5920 pAdapter->SharedKey[BSS0][0].KeyLen = KeyLen / 2 ;
5921 AtoH(arg, pAdapter->SharedKey[BSS0][0].Key, KeyLen / 2);
5922 CipherAlg = CIPHER_WEP64;
5923 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key1_Proc::(Key1=%s and type=%s)\n", arg, "Hex"));
5925 case 13: //wep 104 Ascii type
5926 pAdapter->SharedKey[BSS0][0].KeyLen = KeyLen;
5927 memcpy(pAdapter->SharedKey[BSS0][0].Key, arg, KeyLen);
5928 CipherAlg = CIPHER_WEP128;
5929 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key1_Proc::(Key1=%s and type=%s)\n", arg, "Ascii"));
5931 case 26: //wep 104 Hex type
5932 for(i=0; i < KeyLen; i++)
5934 if( !isxdigit(*(arg+i)) )
5935 return FALSE; //Not Hex value;
5937 pAdapter->SharedKey[BSS0][0].KeyLen = KeyLen / 2 ;
5938 AtoH(arg, pAdapter->SharedKey[BSS0][0].Key, KeyLen / 2);
5939 CipherAlg = CIPHER_WEP128;
5940 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key1_Proc::(Key1=%s and type=%s)\n", arg, "Hex"));
5942 default: //Invalid argument
5943 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key1_Proc::Invalid argument (=%s)\n", arg));
5947 pAdapter->SharedKey[BSS0][0].CipherAlg = CipherAlg;
5949 // Set keys (into ASIC)
5950 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
5952 else // Old WEP stuff
5954 AsicAddSharedKeyEntry(pAdapter,
5957 pAdapter->SharedKey[BSS0][0].CipherAlg,
5958 pAdapter->SharedKey[BSS0][0].Key,
5966 ==========================================================================
5971 TRUE if all parameters are OK, FALSE otherwise
5972 ==========================================================================
5975 IN PRTMP_ADAPTER pAdapter,
5980 UCHAR CipherAlg=CIPHER_WEP64;
5982 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
5983 return TRUE; // do nothing
5985 KeyLen = strlen(arg);
5989 case 5: //wep 40 Ascii type
5990 pAdapter->SharedKey[BSS0][1].KeyLen = KeyLen;
5991 memcpy(pAdapter->SharedKey[BSS0][1].Key, arg, KeyLen);
5992 CipherAlg = CIPHER_WEP64;
5993 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key2_Proc::(Key2=%s and type=%s)\n", arg, "Ascii"));
5995 case 10: //wep 40 Hex type
5996 for(i=0; i < KeyLen; i++)
5998 if( !isxdigit(*(arg+i)) )
5999 return FALSE; //Not Hex value;
6001 pAdapter->SharedKey[BSS0][1].KeyLen = KeyLen / 2 ;
6002 AtoH(arg, pAdapter->SharedKey[BSS0][1].Key, KeyLen / 2);
6003 CipherAlg = CIPHER_WEP64;
6004 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key2_Proc::(Key2=%s and type=%s)\n", arg, "Hex"));
6006 case 13: //wep 104 Ascii type
6007 pAdapter->SharedKey[BSS0][1].KeyLen = KeyLen;
6008 memcpy(pAdapter->SharedKey[BSS0][1].Key, arg, KeyLen);
6009 CipherAlg = CIPHER_WEP128;
6010 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key2_Proc::(Key2=%s and type=%s)\n", arg, "Ascii"));
6012 case 26: //wep 104 Hex type
6013 for(i=0; i < KeyLen; i++)
6015 if( !isxdigit(*(arg+i)) )
6016 return FALSE; //Not Hex value;
6018 pAdapter->SharedKey[BSS0][1].KeyLen = KeyLen / 2 ;
6019 AtoH(arg, pAdapter->SharedKey[BSS0][1].Key, KeyLen / 2);
6020 CipherAlg = CIPHER_WEP128;
6021 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key2_Proc::(Key2=%s and type=%s)\n", arg, "Hex"));
6023 default: //Invalid argument
6024 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key2_Proc::Invalid argument (=%s)\n", arg));
6027 pAdapter->SharedKey[BSS0][1].CipherAlg = CipherAlg;
6029 // Set keys (into ASIC)
6030 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
6032 else // Old WEP stuff
6034 AsicAddSharedKeyEntry(pAdapter,
6037 pAdapter->SharedKey[BSS0][1].CipherAlg,
6038 pAdapter->SharedKey[BSS0][1].Key,
6046 ==========================================================================
6050 TRUE if all parameters are OK, FALSE otherwise
6051 ==========================================================================
6054 IN PRTMP_ADAPTER pAdapter,
6059 UCHAR CipherAlg=CIPHER_WEP64;
6061 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
6062 return TRUE; // do nothing
6064 KeyLen = strlen(arg);
6068 case 5: //wep 40 Ascii type
6069 pAdapter->SharedKey[BSS0][2].KeyLen = KeyLen;
6070 memcpy(pAdapter->SharedKey[BSS0][2].Key, arg, KeyLen);
6071 CipherAlg = CIPHER_WEP64;
6072 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key3_Proc::(Key3=%s and type=Ascii)\n", arg));
6074 case 10: //wep 40 Hex type
6075 for(i=0; i < KeyLen; i++)
6077 if( !isxdigit(*(arg+i)) )
6078 return FALSE; //Not Hex value;
6080 pAdapter->SharedKey[BSS0][2].KeyLen = KeyLen / 2 ;
6081 AtoH(arg, pAdapter->SharedKey[BSS0][2].Key, KeyLen / 2);
6082 CipherAlg = CIPHER_WEP64;
6083 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key3_Proc::(Key3=%s and type=Hex)\n", arg));
6085 case 13: //wep 104 Ascii type
6086 pAdapter->SharedKey[BSS0][2].KeyLen = KeyLen;
6087 memcpy(pAdapter->SharedKey[BSS0][2].Key, arg, KeyLen);
6088 CipherAlg = CIPHER_WEP128;
6089 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key3_Proc::(Key3=%s and type=Ascii)\n", arg));
6091 case 26: //wep 104 Hex type
6092 for(i=0; i < KeyLen; i++)
6094 if( !isxdigit(*(arg+i)) )
6095 return FALSE; //Not Hex value;
6097 pAdapter->SharedKey[BSS0][2].KeyLen = KeyLen / 2 ;
6098 AtoH(arg, pAdapter->SharedKey[BSS0][2].Key, KeyLen / 2);
6099 CipherAlg = CIPHER_WEP128;
6100 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key3_Proc::(Key3=%s and type=Hex)\n", arg));
6102 default: //Invalid argument
6103 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key3_Proc::Invalid argument (=%s)\n", arg));
6106 pAdapter->SharedKey[BSS0][2].CipherAlg = CipherAlg;
6108 // Set keys (into ASIC)
6109 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
6111 else // Old WEP stuff
6113 AsicAddSharedKeyEntry(pAdapter,
6116 pAdapter->SharedKey[BSS0][2].CipherAlg,
6117 pAdapter->SharedKey[BSS0][2].Key,
6125 ==========================================================================
6129 TRUE if all parameters are OK, FALSE otherwise
6130 ==========================================================================
6133 IN PRTMP_ADAPTER pAdapter,
6138 UCHAR CipherAlg=CIPHER_WEP64;
6140 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
6141 return TRUE; // do nothing
6143 KeyLen = strlen(arg);
6147 case 5: //wep 40 Ascii type
6148 pAdapter->SharedKey[BSS0][3].KeyLen = KeyLen;
6149 memcpy(pAdapter->SharedKey[BSS0][3].Key, arg, KeyLen);
6150 CipherAlg = CIPHER_WEP64;
6151 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key4_Proc::(Key4=%s and type=%s)\n", arg, "Ascii"));
6153 case 10: //wep 40 Hex type
6154 for(i=0; i < KeyLen; i++)
6156 if( !isxdigit(*(arg+i)) )
6157 return FALSE; //Not Hex value;
6159 pAdapter->SharedKey[BSS0][3].KeyLen = KeyLen / 2 ;
6160 AtoH(arg, pAdapter->SharedKey[BSS0][3].Key, KeyLen / 2);
6161 CipherAlg = CIPHER_WEP64;
6162 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key4_Proc::(Key4=%s and type=%s)\n", arg, "Hex"));
6164 case 13: //wep 104 Ascii type
6165 pAdapter->SharedKey[BSS0][3].KeyLen = KeyLen;
6166 memcpy(pAdapter->SharedKey[BSS0][3].Key, arg, KeyLen);
6167 CipherAlg = CIPHER_WEP128;
6168 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key4_Proc::(Key4=%s and type=%s)\n", arg, "Ascii"));
6170 case 26: //wep 104 Hex type
6171 for(i=0; i < KeyLen; i++)
6173 if( !isxdigit(*(arg+i)) )
6174 return FALSE; //Not Hex value;
6176 pAdapter->SharedKey[BSS0][3].KeyLen = KeyLen / 2 ;
6177 AtoH(arg, pAdapter->SharedKey[BSS0][3].Key, KeyLen / 2);
6178 CipherAlg = CIPHER_WEP128;
6179 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key4_Proc::(Key4=%s and type=%s)\n", arg, "Hex"));
6181 default: //Invalid argument
6182 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key4_Proc::Invalid argument (=%s)\n", arg));
6185 pAdapter->SharedKey[BSS0][3].CipherAlg = CipherAlg;
6187 // Set keys (into ASIC)
6188 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
6190 else // Old WEP stuff
6192 AsicAddSharedKeyEntry(pAdapter,
6195 pAdapter->SharedKey[BSS0][3].CipherAlg,
6196 pAdapter->SharedKey[BSS0][3].Key,
6205 ==========================================================================
6209 TRUE if all parameters are OK, FALSE otherwise
6210 ==========================================================================
6212 INT Set_WPAPSK_Proc(
6213 IN PRTMP_ADAPTER pAdapter,
6216 UCHAR keyMaterial[40];
6218 if ((pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPAPSK) &&
6219 (pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPA2PSK) &&
6220 (pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPANone)
6222 return TRUE; // do nothing
6224 DBGPRINT(RT_DEBUG_TRACE, ("Set_WPAPSK_Proc::(WPAPSK=%s)\n", arg));
6226 NdisZeroMemory(keyMaterial, 40);
6228 if ((strlen(arg) < 8) || (strlen(arg) > 64))
6230 DBGPRINT(RT_DEBUG_TRACE, ("Set failed!!(WPAPSK=%s), WPAPSK key-string required 8 ~ 64 characters \n", arg));
6234 if (strlen(arg) == 64)
6236 AtoH(arg, keyMaterial, 32);
6237 NdisMoveMemory(pAdapter->StaCfg.PMK, keyMaterial, 32);
6242 PasswordHash((char *)arg, pAdapter->MlmeAux.Ssid, pAdapter->MlmeAux.SsidLen, keyMaterial);
6243 NdisMoveMemory(pAdapter->StaCfg.PMK, keyMaterial, 32);
6248 if(pAdapter->StaCfg.BssType == BSS_ADHOC &&
6249 pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPANone)
6251 pAdapter->StaCfg.WpaState = SS_NOTUSE;
6255 // Start STA supplicant state machine
6256 pAdapter->StaCfg.WpaState = SS_START;
6263 ==========================================================================
6265 Set Power Saving mode
6267 TRUE if all parameters are OK, FALSE otherwise
6268 ==========================================================================
6270 INT Set_PSMode_Proc(
6271 IN PRTMP_ADAPTER pAdapter,
6274 if (pAdapter->StaCfg.BssType == BSS_INFRA)
6276 if ((strcmp(arg, "Max_PSP") == 0) ||
6277 (strcmp(arg, "max_psp") == 0) ||
6278 (strcmp(arg, "MAX_PSP") == 0))
6280 // do NOT turn on PSM bit here, wait until MlmeCheckForPsmChange()
6281 // to exclude certain situations.
6282 if (pAdapter->StaCfg.bWindowsACCAMEnable == FALSE)
6283 pAdapter->StaCfg.WindowsPowerMode = Ndis802_11PowerModeMAX_PSP;
6284 pAdapter->StaCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeMAX_PSP;
6285 OPSTATUS_SET_FLAG(pAdapter, fOP_STATUS_RECEIVE_DTIM);
6286 pAdapter->StaCfg.DefaultListenCount = 5;
6289 else if ((strcmp(arg, "Fast_PSP") == 0) ||
6290 (strcmp(arg, "fast_psp") == 0) ||
6291 (strcmp(arg, "FAST_PSP") == 0))
6293 // do NOT turn on PSM bit here, wait until MlmeCheckForPsmChange()
6294 // to exclude certain situations.
6295 OPSTATUS_SET_FLAG(pAdapter, fOP_STATUS_RECEIVE_DTIM);
6296 if (pAdapter->StaCfg.bWindowsACCAMEnable == FALSE)
6297 pAdapter->StaCfg.WindowsPowerMode = Ndis802_11PowerModeFast_PSP;
6298 pAdapter->StaCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeFast_PSP;
6299 pAdapter->StaCfg.DefaultListenCount = 3;
6301 else if ((strcmp(arg, "Legacy_PSP") == 0) ||
6302 (strcmp(arg, "legacy_psp") == 0) ||
6303 (strcmp(arg, "LEGACY_PSP") == 0))
6305 // do NOT turn on PSM bit here, wait until MlmeCheckForPsmChange()
6306 // to exclude certain situations.
6307 OPSTATUS_SET_FLAG(pAdapter, fOP_STATUS_RECEIVE_DTIM);
6308 if (pAdapter->StaCfg.bWindowsACCAMEnable == FALSE)
6309 pAdapter->StaCfg.WindowsPowerMode = Ndis802_11PowerModeLegacy_PSP;
6310 pAdapter->StaCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeLegacy_PSP;
6311 pAdapter->StaCfg.DefaultListenCount = 3;
6315 //Default Ndis802_11PowerModeCAM
6316 // clear PSM bit immediately
6317 MlmeSetPsmBit(pAdapter, PWR_ACTIVE);
6318 OPSTATUS_SET_FLAG(pAdapter, fOP_STATUS_RECEIVE_DTIM);
6319 if (pAdapter->StaCfg.bWindowsACCAMEnable == FALSE)
6320 pAdapter->StaCfg.WindowsPowerMode = Ndis802_11PowerModeCAM;
6321 pAdapter->StaCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeCAM;
6324 DBGPRINT(RT_DEBUG_TRACE, ("Set_PSMode_Proc::(PSMode=%ld)\n", pAdapter->StaCfg.WindowsPowerMode));
6333 #ifdef WPA_SUPPLICANT_SUPPORT
6335 ==========================================================================
6337 Set WpaSupport flag.
6339 0: Driver ignore wpa_supplicant.
6340 1: wpa_supplicant initiates scanning and AP selection.
6341 2: driver takes care of scanning, AP selection, and IEEE 802.11 association parameters.
6343 TRUE if all parameters are OK, FALSE otherwise
6344 ==========================================================================
6346 INT Set_Wpa_Support(
6347 IN PRTMP_ADAPTER pAd,
6351 if ( simple_strtol(arg, 0, 10) == 0)
6352 pAd->StaCfg.WpaSupplicantUP = WPA_SUPPLICANT_DISABLE;
6353 else if ( simple_strtol(arg, 0, 10) == 1)
6354 pAd->StaCfg.WpaSupplicantUP = WPA_SUPPLICANT_ENABLE;
6355 else if ( simple_strtol(arg, 0, 10) == 2)
6356 pAd->StaCfg.WpaSupplicantUP = WPA_SUPPLICANT_ENABLE_WITH_WEB_UI;
6358 pAd->StaCfg.WpaSupplicantUP = WPA_SUPPLICANT_DISABLE;
6360 DBGPRINT(RT_DEBUG_TRACE, ("Set_Wpa_Support::(WpaSupplicantUP=%d)\n", pAd->StaCfg.WpaSupplicantUP));
6364 #endif // WPA_SUPPLICANT_SUPPORT //
6368 ==========================================================================
6372 pAdapter Pointer to our adapter
6373 wrq Pointer to the ioctl argument
6380 1.) iwpriv ra0 mac 0 ==> read MAC where Addr=0x0
6381 2.) iwpriv ra0 mac 0=12 ==> write MAC where Addr=0x0, value=12
6382 ==========================================================================
6385 IN PRTMP_ADAPTER pAdapter,
6386 IN struct iwreq *wrq)
6394 UCHAR temp[16], temp2[16];
6395 UINT32 macValue = 0;
6397 BOOLEAN bIsPrintAllMAC = FALSE;
6400 memset(msg, 0x00, 1024);
6401 if (wrq->u.data.length > 1) //No parameters.
6403 Status = copy_from_user(arg, wrq->u.data.pointer, (wrq->u.data.length > 255) ? 255 : wrq->u.data.length);
6406 //Parsing Read or Write
6411 if ((value = rtstrchr(this_char, '=')) != NULL)
6414 if (!value || !*value)
6417 if(strlen(this_char) > 4)
6420 j = strlen(this_char);
6423 if(this_char[j] > 'f' || this_char[j] < '0')
6428 k = j = strlen(this_char);
6431 this_char[4-k+j] = this_char[j];
6435 this_char[3-k++]='0';
6438 if(strlen(this_char) == 4)
6440 AtoH(this_char, temp, 2);
6441 macAddr = *temp*256 + temp[1];
6442 if (macAddr < 0xFFFF)
6444 RTMP_IO_READ32(pAdapter, macAddr, &macValue);
6445 DBGPRINT(RT_DEBUG_TRACE, ("MacAddr=%lx, MacValue=%x\n", macAddr, macValue));
6446 sprintf(msg+strlen(msg), "[0x%08lX]:%08X ", macAddr , macValue);
6449 {//Invalid parametes, so default printk all mac
6450 bIsPrintAllMAC = TRUE;
6457 memcpy(&temp2, value, strlen(value));
6458 temp2[strlen(value)] = '\0';
6461 if((strlen(this_char) > 4) || strlen(temp2) > 8)
6464 j = strlen(this_char);
6467 if(this_char[j] > 'f' || this_char[j] < '0')
6474 if(temp2[j] > 'f' || temp2[j] < '0')
6479 k = j = strlen(this_char);
6482 this_char[4-k+j] = this_char[j];
6486 this_char[3-k++]='0';
6490 k = j = strlen(temp2);
6493 temp2[8-k+j] = temp2[j];
6501 AtoH(this_char, temp, 2);
6502 macAddr = *temp*256 + temp[1];
6504 AtoH(temp2, temp, 4);
6505 macValue = *temp*256*256*256 + temp[1]*256*256 + temp[2]*256 + temp[3];
6508 if (macAddr == (HW_DEBUG_SETTING_BASE + 4))
6510 // 0x2bf4: byte0 non-zero: enable R17 tuning, 0: disable R17 tuning
6511 if (macValue & 0x000000ff)
6513 pAdapter->BbpTuning.bEnable = TRUE;
6514 DBGPRINT(RT_DEBUG_TRACE,("turn on R17 tuning\n"));
6519 pAdapter->BbpTuning.bEnable = FALSE;
6520 R66 = 0x26 + GET_LNA_GAIN(pAdapter);
6521 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R66, (0x26 + GET_LNA_GAIN(pAdapter)));
6522 DBGPRINT(RT_DEBUG_TRACE,("turn off R17 tuning, restore to 0x%02x\n", R66));
6527 DBGPRINT(RT_DEBUG_TRACE, ("MacAddr=%02lx, MacValue=0x%x\n", macAddr, macValue));
6529 RTMP_IO_WRITE32(pAdapter, macAddr, macValue);
6530 sprintf(msg+strlen(msg), "[0x%08lX]:%08X ", macAddr, macValue);
6535 bIsPrintAllMAC = TRUE;
6539 struct file *file_w;
6540 PCHAR fileName = "MacDump.txt";
6541 mm_segment_t orig_fs;
6547 file_w = filp_open(fileName, O_WRONLY|O_CREAT, 0);
6550 DBGPRINT(RT_DEBUG_TRACE, ("-->2) %s: Error %ld opening %s\n", __func__, -PTR_ERR(file_w), fileName));
6554 if (file_w->f_op && file_w->f_op->write)
6559 while (macAddr <= 0x1800)
6561 RTMP_IO_READ32(pAdapter, macAddr, &macValue);
6562 sprintf(msg, "%08lx = %08X\n", macAddr, macValue);
6564 // write data to file
6565 file_w->f_op->write(file_w, msg, strlen(msg), &file_w->f_pos);
6570 sprintf(msg, "\nDump all MAC values to %s\n", fileName);
6572 filp_close(file_w, NULL);
6576 if(strlen(msg) == 1)
6577 sprintf(msg+strlen(msg), "===>Error command format!");
6579 // Copy the information into the user buffer
6580 wrq->u.data.length = strlen(msg);
6581 Status = copy_to_user(wrq->u.data.pointer, msg, wrq->u.data.length);
6583 DBGPRINT(RT_DEBUG_TRACE, ("<==RTMPIoctlMAC\n\n"));
6587 ==========================================================================
6591 pAdapter Pointer to our adapter
6592 wrq Pointer to the ioctl argument
6599 1.) iwpriv ra0 e2p 0 ==> read E2PROM where Addr=0x0
6600 2.) iwpriv ra0 e2p 0=1234 ==> write E2PROM where Addr=0x0, value=1234
6601 ==========================================================================
6603 VOID RTMPIoctlE2PROM(
6604 IN PRTMP_ADAPTER pAdapter,
6605 IN struct iwreq *wrq)
6613 UCHAR temp[16], temp2[16];
6616 BOOLEAN bIsPrintAllE2P = FALSE;
6619 memset(msg, 0x00, 1024);
6620 if (wrq->u.data.length > 1) //No parameters.
6622 Status = copy_from_user(arg, wrq->u.data.pointer, (wrq->u.data.length > 255) ? 255 : wrq->u.data.length);
6625 //Parsing Read or Write
6632 if ((value = rtstrchr(this_char, '=')) != NULL)
6635 if (!value || !*value)
6639 if(strlen(this_char) > 4)
6642 j = strlen(this_char);
6645 if(this_char[j] > 'f' || this_char[j] < '0')
6650 k = j = strlen(this_char);
6653 this_char[4-k+j] = this_char[j];
6657 this_char[3-k++]='0';
6660 if(strlen(this_char) == 4)
6662 AtoH(this_char, temp, 2);
6663 eepAddr = *temp*256 + temp[1];
6664 if (eepAddr < 0xFFFF)
6666 RT28xx_EEPROM_READ16(pAdapter, eepAddr, eepValue);
6667 sprintf(msg+strlen(msg), "[0x%04X]:0x%04X ", eepAddr , eepValue);
6670 {//Invalid parametes, so default printk all bbp
6671 bIsPrintAllE2P = TRUE;
6678 memcpy(&temp2, value, strlen(value));
6679 temp2[strlen(value)] = '\0';
6682 if((strlen(this_char) > 4) || strlen(temp2) > 8)
6685 j = strlen(this_char);
6688 if(this_char[j] > 'f' || this_char[j] < '0')
6694 if(temp2[j] > 'f' || temp2[j] < '0')
6699 k = j = strlen(this_char);
6702 this_char[4-k+j] = this_char[j];
6706 this_char[3-k++]='0';
6710 k = j = strlen(temp2);
6713 temp2[4-k+j] = temp2[j];
6720 AtoH(this_char, temp, 2);
6721 eepAddr = *temp*256 + temp[1];
6723 AtoH(temp2, temp, 2);
6724 eepValue = *temp*256 + temp[1];
6726 RT28xx_EEPROM_WRITE16(pAdapter, eepAddr, eepValue);
6727 sprintf(msg+strlen(msg), "[0x%02X]:%02X ", eepAddr, eepValue);
6731 bIsPrintAllE2P = TRUE;
6735 struct file *file_w;
6736 PCHAR fileName = "EEPROMDump.txt";
6737 mm_segment_t orig_fs;
6743 file_w = filp_open(fileName, O_WRONLY|O_CREAT, 0);
6746 DBGPRINT(RT_DEBUG_TRACE, ("-->2) %s: Error %ld opening %s\n", __func__, -PTR_ERR(file_w), fileName));
6750 if (file_w->f_op && file_w->f_op->write)
6755 while (eepAddr <= 0xFE)
6757 RT28xx_EEPROM_READ16(pAdapter, eepAddr, eepValue);
6758 sprintf(msg, "%08x = %04x\n", eepAddr , eepValue);
6760 // write data to file
6761 file_w->f_op->write(file_w, msg, strlen(msg), &file_w->f_pos);
6766 sprintf(msg, "\nDump all EEPROM values to %s\n", fileName);
6768 filp_close(file_w, NULL);
6772 if(strlen(msg) == 1)
6773 sprintf(msg+strlen(msg), "===>Error command format!");
6776 // Copy the information into the user buffer
6777 wrq->u.data.length = strlen(msg);
6778 Status = copy_to_user(wrq->u.data.pointer, msg, wrq->u.data.length);
6780 DBGPRINT(RT_DEBUG_TRACE, ("<==RTMPIoctlE2PROM\n"));
6784 ==========================================================================
6786 Read / Write RF register
6788 pAdapter Pointer to our adapter
6789 wrq Pointer to the ioctl argument
6796 1.) iwpriv ra0 rf ==> read all RF registers
6797 2.) iwpriv ra0 rf 1 ==> read RF where RegID=1
6798 3.) iwpriv ra0 rf 1=10 ==> write RF R1=0x10
6799 ==========================================================================
6802 IN PRTMP_ADAPTER pAdapter,
6803 IN struct iwreq *wrq)
6813 BOOLEAN bIsPrintAllRF = FALSE;
6816 memset(msg, 0x00, 2048);
6817 if (wrq->u.data.length > 1) //No parameters.
6819 Status = copy_from_user(arg, wrq->u.data.pointer, (wrq->u.data.length > 255) ? 255 : wrq->u.data.length);
6822 //Parsing Read or Write
6827 if ((value = strchr(this_char, '=')) != NULL)
6830 if (!value || !*value)
6832 if (sscanf(this_char, "%d", &(rfId)) == 1)
6836 // In RT2860 ATE mode, we do not load 8051 firmware.
6837 //We must access RF directly.
6838 // For RT2870 ATE mode, ATE_RF_IO_WRITE8(/READ8)_BY_REG_ID are redefined.
6839 // according to Andy, Gary, David require.
6840 // the command rf shall read rf register directly for dubug.
6841 // BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, ®BBP);
6842 RT30xxReadRFRegister(pAdapter, rfId, ®RF);
6844 sprintf(msg+strlen(msg), "R%02d[0x%02x]:%02X ", rfId, rfId*2, regRF);
6847 {//Invalid parametes, so default printk all RF
6848 bIsPrintAllRF = TRUE;
6853 { //Invalid parametes, so default printk all RF
6854 bIsPrintAllRF = TRUE;
6860 if ((sscanf(this_char, "%d", &(rfId)) == 1) && (sscanf(value, "%lx", &(rfValue)) == 1))
6864 // In RT2860 ATE mode, we do not load 8051 firmware.
6865 // We should access RF registers directly.
6866 // For RT2870 ATE mode, ATE_RF_IO_WRITE8/READ8_BY_REG_ID are redefined.
6868 // according to Andy, Gary, David require.
6869 // the command RF shall read/write RF register directly for dubug.
6870 //BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, ®BBP);
6871 //BBP_IO_WRITE8_BY_REG_ID(pAdapter, (UCHAR)bbpId,(UCHAR) bbpValue);
6872 RT30xxReadRFRegister(pAdapter, rfId, ®RF);
6873 RT30xxWriteRFRegister(pAdapter, (UCHAR)rfId,(UCHAR) rfValue);
6874 //Read it back for showing
6875 //BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, ®BBP);
6876 RT30xxReadRFRegister(pAdapter, rfId, ®RF);
6877 sprintf(msg+strlen(msg), "R%02d[0x%02X]:%02X\n", rfId, rfId*2, regRF);
6881 {//Invalid parametes, so default printk all RF
6882 bIsPrintAllRF = TRUE;
6886 { //Invalid parametes, so default printk all RF
6887 bIsPrintAllRF = TRUE;
6892 bIsPrintAllRF = TRUE;
6896 memset(msg, 0x00, 2048);
6898 for (rfId = 0; rfId <= 31; rfId++)
6900 // according to Andy, Gary, David require.
6901 // the command RF shall read/write RF register directly for dubug.
6902 RT30xxReadRFRegister(pAdapter, rfId, ®RF);
6903 sprintf(msg+strlen(msg), "%03d = %02X\n", rfId, regRF);
6905 // Copy the information into the user buffer
6906 DBGPRINT(RT_DEBUG_TRACE, ("strlen(msg)=%d\n", (UINT32)strlen(msg)));
6907 wrq->u.data.length = strlen(msg);
6908 if (copy_to_user(wrq->u.data.pointer, msg, wrq->u.data.length))
6910 DBGPRINT(RT_DEBUG_TRACE, ("%s: copy_to_user() fail\n", __func__));
6915 if(strlen(msg) == 1)
6916 sprintf(msg+strlen(msg), "===>Error command format!");
6918 DBGPRINT(RT_DEBUG_TRACE, ("copy to user [msg=%s]\n", msg));
6919 // Copy the information into the user buffer
6920 DBGPRINT(RT_DEBUG_TRACE, ("strlen(msg) =%d\n", (UINT32)strlen(msg)));
6922 // Copy the information into the user buffer
6923 wrq->u.data.length = strlen(msg);
6924 Status = copy_to_user(wrq->u.data.pointer, msg, wrq->u.data.length);
6927 DBGPRINT(RT_DEBUG_TRACE, ("<==RTMPIoctlRF\n\n"));
6935 INT Set_TGnWifiTest_Proc(
6936 IN PRTMP_ADAPTER pAd,
6939 if (simple_strtol(arg, 0, 10) == 0)
6940 pAd->StaCfg.bTGnWifiTest = FALSE;
6942 pAd->StaCfg.bTGnWifiTest = TRUE;
6944 DBGPRINT(RT_DEBUG_TRACE, ("IF Set_TGnWifiTest_Proc::(bTGnWifiTest=%d)\n", pAd->StaCfg.bTGnWifiTest));
6948 INT Set_LongRetryLimit_Proc(
6949 IN PRTMP_ADAPTER pAdapter,
6952 TX_RTY_CFG_STRUC tx_rty_cfg;
6953 UCHAR LongRetryLimit = (UCHAR)simple_strtol(arg, 0, 10);
6955 RTMP_IO_READ32(pAdapter, TX_RTY_CFG, &tx_rty_cfg.word);
6956 tx_rty_cfg.field.LongRtyLimit = LongRetryLimit;
6957 RTMP_IO_WRITE32(pAdapter, TX_RTY_CFG, tx_rty_cfg.word);
6958 DBGPRINT(RT_DEBUG_TRACE, ("IF Set_LongRetryLimit_Proc::(tx_rty_cfg=0x%x)\n", tx_rty_cfg.word));
6962 INT Set_ShortRetryLimit_Proc(
6963 IN PRTMP_ADAPTER pAdapter,
6966 TX_RTY_CFG_STRUC tx_rty_cfg;
6967 UCHAR ShortRetryLimit = (UCHAR)simple_strtol(arg, 0, 10);
6969 RTMP_IO_READ32(pAdapter, TX_RTY_CFG, &tx_rty_cfg.word);
6970 tx_rty_cfg.field.ShortRtyLimit = ShortRetryLimit;
6971 RTMP_IO_WRITE32(pAdapter, TX_RTY_CFG, tx_rty_cfg.word);
6972 DBGPRINT(RT_DEBUG_TRACE, ("IF Set_ShortRetryLimit_Proc::(tx_rty_cfg=0x%x)\n", tx_rty_cfg.word));
6976 #ifdef EXT_BUILD_CHANNEL_LIST
6977 INT Set_Ieee80211dClientMode_Proc(
6978 IN PRTMP_ADAPTER pAdapter,
6981 if (simple_strtol(arg, 0, 10) == 0)
6982 pAdapter->StaCfg.IEEE80211dClientMode = Rt802_11_D_None;
6983 else if (simple_strtol(arg, 0, 10) == 1)
6984 pAdapter->StaCfg.IEEE80211dClientMode = Rt802_11_D_Flexible;
6985 else if (simple_strtol(arg, 0, 10) == 2)
6986 pAdapter->StaCfg.IEEE80211dClientMode = Rt802_11_D_Strict;
6990 DBGPRINT(RT_DEBUG_TRACE, ("Set_Ieee802dMode_Proc::(IEEEE0211dMode=%d)\n", pAdapter->StaCfg.IEEE80211dClientMode));
6993 #endif // EXT_BUILD_CHANNEL_LIST //