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" },
89 IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "show" },
90 /* --- sub-ioctls relations --- */
94 IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK,
97 IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | 1024,
101 IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK,
105 IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | 1024,
109 { RTPRIV_IOCTL_STATISTICS,
110 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK,
112 { RTPRIV_IOCTL_GSITESURVEY,
113 0, IW_PRIV_TYPE_CHAR | 1024,
120 IN PRTMP_ADAPTER pAdapter,
124 INT Set_WmmCapable_Proc(
125 IN PRTMP_ADAPTER pAd,
129 INT Set_NetworkType_Proc(
130 IN PRTMP_ADAPTER pAdapter,
133 INT Set_AuthMode_Proc(
134 IN PRTMP_ADAPTER pAdapter,
137 INT Set_EncrypType_Proc(
138 IN PRTMP_ADAPTER pAdapter,
141 INT Set_DefaultKeyID_Proc(
142 IN PRTMP_ADAPTER pAdapter,
146 IN PRTMP_ADAPTER pAdapter,
150 IN PRTMP_ADAPTER pAdapter,
154 IN PRTMP_ADAPTER pAdapter,
158 IN PRTMP_ADAPTER pAdapter,
162 IN PRTMP_ADAPTER pAdapter,
167 IN PRTMP_ADAPTER pAdapter,
170 #ifdef WPA_SUPPLICANT_SUPPORT
172 IN PRTMP_ADAPTER pAd,
174 #endif // WPA_SUPPLICANT_SUPPORT //
179 IN PRTMP_ADAPTER pAdapter,
180 IN struct iwreq *wrq);
182 VOID RTMPIoctlE2PROM(
183 IN PRTMP_ADAPTER pAdapter,
184 IN struct iwreq *wrq);
188 IN PRTMP_ADAPTER pAdapter,
189 IN struct iwreq *wrq);
194 NDIS_STATUS RTMPWPANoneAddKeyProc(
195 IN PRTMP_ADAPTER pAd,
198 INT Set_FragTest_Proc(
199 IN PRTMP_ADAPTER pAdapter,
202 #ifdef DOT11_N_SUPPORT
203 INT Set_TGnWifiTest_Proc(
204 IN PRTMP_ADAPTER pAd,
206 #endif // DOT11_N_SUPPORT //
208 INT Set_LongRetryLimit_Proc(
209 IN PRTMP_ADAPTER pAdapter,
212 INT Set_ShortRetryLimit_Proc(
213 IN PRTMP_ADAPTER pAdapter,
216 #ifdef EXT_BUILD_CHANNEL_LIST
217 INT Set_Ieee80211dClientMode_Proc(
218 IN PRTMP_ADAPTER pAdapter,
220 #endif // EXT_BUILD_CHANNEL_LIST //
224 INT (*set_proc)(PRTMP_ADAPTER pAdapter, PUCHAR arg);
225 } *PRTMP_PRIVATE_SET_PROC, RTMP_PRIVATE_SUPPORT_PROC[] = {
226 {"DriverVersion", Set_DriverVersion_Proc},
227 {"CountryRegion", Set_CountryRegion_Proc},
228 {"CountryRegionABand", Set_CountryRegionABand_Proc},
229 {"SSID", Set_SSID_Proc},
230 {"WirelessMode", Set_WirelessMode_Proc},
231 {"TxBurst", Set_TxBurst_Proc},
232 {"TxPreamble", Set_TxPreamble_Proc},
233 {"TxPower", Set_TxPower_Proc},
234 {"Channel", Set_Channel_Proc},
235 {"BGProtection", Set_BGProtection_Proc},
236 {"RTSThreshold", Set_RTSThreshold_Proc},
237 {"FragThreshold", Set_FragThreshold_Proc},
238 #ifdef DOT11_N_SUPPORT
239 {"HtBw", Set_HtBw_Proc},
240 {"HtMcs", Set_HtMcs_Proc},
241 {"HtGi", Set_HtGi_Proc},
242 {"HtOpMode", Set_HtOpMode_Proc},
243 {"HtExtcha", Set_HtExtcha_Proc},
244 {"HtMpduDensity", Set_HtMpduDensity_Proc},
245 {"HtBaWinSize", Set_HtBaWinSize_Proc},
246 {"HtRdg", Set_HtRdg_Proc},
247 {"HtAmsdu", Set_HtAmsdu_Proc},
248 {"HtAutoBa", Set_HtAutoBa_Proc},
249 {"HtBaDecline", Set_BADecline_Proc},
250 {"HtProtect", Set_HtProtect_Proc},
251 {"HtMimoPs", Set_HtMimoPs_Proc},
252 #endif // DOT11_N_SUPPORT //
254 #ifdef AGGREGATION_SUPPORT
255 {"PktAggregate", Set_PktAggregate_Proc},
259 {"WmmCapable", Set_WmmCapable_Proc},
261 {"IEEE80211H", Set_IEEE80211H_Proc},
262 {"NetworkType", Set_NetworkType_Proc},
263 {"AuthMode", Set_AuthMode_Proc},
264 {"EncrypType", Set_EncrypType_Proc},
265 {"DefaultKeyID", Set_DefaultKeyID_Proc},
266 {"Key1", Set_Key1_Proc},
267 {"Key2", Set_Key2_Proc},
268 {"Key3", Set_Key3_Proc},
269 {"Key4", Set_Key4_Proc},
270 {"WPAPSK", Set_WPAPSK_Proc},
271 {"ResetCounter", Set_ResetStatCounter_Proc},
272 {"PSMode", Set_PSMode_Proc},
274 {"Debug", Set_Debug_Proc},
277 #ifdef WPA_SUPPLICANT_SUPPORT
278 {"WpaSupport", Set_Wpa_Support},
279 #endif // WPA_SUPPLICANT_SUPPORT //
283 {"FixedTxMode", Set_FixedTxMode_Proc},
284 #ifdef DOT11_N_SUPPORT
285 {"TGnWifiTest", Set_TGnWifiTest_Proc},
286 {"ForceGF", Set_ForceGF_Proc},
287 #endif // DOT11_N_SUPPORT //
288 {"LongRetry", Set_LongRetryLimit_Proc},
289 {"ShortRetry", Set_ShortRetryLimit_Proc},
290 #ifdef EXT_BUILD_CHANNEL_LIST
291 {"11dClientMode", Set_Ieee80211dClientMode_Proc},
292 #endif // EXT_BUILD_CHANNEL_LIST //
293 //2008/09/11:KH add to support efuse<--
295 {"efuseFreeNumber", set_eFuseGetFreeBlockCount_Proc},
296 {"efuseDump", set_eFusedump_Proc},
297 {"efuseLoadFromBin", set_eFuseLoadFromBin_Proc},
299 //2008/09/11:KH add to support efuse-->
305 IN PRTMP_ADAPTER pAd,
306 IN PNDIS_802_11_KEY pKey)
309 MAC_TABLE_ENTRY *pEntry;
311 DBGPRINT(RT_DEBUG_TRACE, ("RTMPAddKey ------>\n"));
313 if (pAd->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
315 if (pKey->KeyIndex & 0x80000000)
317 if (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPANone)
319 NdisZeroMemory(pAd->StaCfg.PMK, 32);
320 NdisMoveMemory(pAd->StaCfg.PMK, pKey->KeyMaterial, pKey->KeyLength);
324 NdisZeroMemory(&pAd->SharedKey[BSS0][0], sizeof(CIPHER_KEY));
325 pAd->SharedKey[BSS0][0].KeyLen = LEN_TKIP_EK;
326 NdisMoveMemory(pAd->SharedKey[BSS0][0].Key, pKey->KeyMaterial, LEN_TKIP_EK);
327 #ifdef WPA_SUPPLICANT_SUPPORT
328 if (pAd->StaCfg.PairCipher == Ndis802_11Encryption2Enabled)
330 NdisMoveMemory(pAd->SharedKey[BSS0][0].RxMic, pKey->KeyMaterial + LEN_TKIP_EK, LEN_TKIP_TXMICK);
331 NdisMoveMemory(pAd->SharedKey[BSS0][0].TxMic, pKey->KeyMaterial + LEN_TKIP_EK + LEN_TKIP_TXMICK, LEN_TKIP_RXMICK);
334 #endif // WPA_SUPPLICANT_SUPPORT //
336 NdisMoveMemory(pAd->SharedKey[BSS0][0].TxMic, pKey->KeyMaterial + LEN_TKIP_EK, LEN_TKIP_TXMICK);
337 NdisMoveMemory(pAd->SharedKey[BSS0][0].RxMic, pKey->KeyMaterial + LEN_TKIP_EK + LEN_TKIP_TXMICK, LEN_TKIP_RXMICK);
340 // Decide its ChiperAlg
341 if (pAd->StaCfg.PairCipher == Ndis802_11Encryption2Enabled)
342 pAd->SharedKey[BSS0][0].CipherAlg = CIPHER_TKIP;
343 else if (pAd->StaCfg.PairCipher == Ndis802_11Encryption3Enabled)
344 pAd->SharedKey[BSS0][0].CipherAlg = CIPHER_AES;
346 pAd->SharedKey[BSS0][0].CipherAlg = CIPHER_NONE;
348 // Update these related information to MAC_TABLE_ENTRY
349 pEntry = &pAd->MacTab.Content[BSSID_WCID];
350 NdisMoveMemory(pEntry->PairwiseKey.Key, pAd->SharedKey[BSS0][0].Key, LEN_TKIP_EK);
351 NdisMoveMemory(pEntry->PairwiseKey.RxMic, pAd->SharedKey[BSS0][0].RxMic, LEN_TKIP_RXMICK);
352 NdisMoveMemory(pEntry->PairwiseKey.TxMic, pAd->SharedKey[BSS0][0].TxMic, LEN_TKIP_TXMICK);
353 pEntry->PairwiseKey.CipherAlg = pAd->SharedKey[BSS0][0].CipherAlg;
355 // Update pairwise key information to ASIC Shared Key Table
356 AsicAddSharedKeyEntry(pAd,
359 pAd->SharedKey[BSS0][0].CipherAlg,
360 pAd->SharedKey[BSS0][0].Key,
361 pAd->SharedKey[BSS0][0].TxMic,
362 pAd->SharedKey[BSS0][0].RxMic);
364 // Update ASIC WCID attribute table and IVEIV table
365 RTMPAddWcidAttributeEntry(pAd,
368 pAd->SharedKey[BSS0][0].CipherAlg,
371 if (pAd->StaCfg.AuthMode >= Ndis802_11AuthModeWPA2)
373 // set 802.1x port control
374 //pAd->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
375 STA_PORT_SECURED(pAd);
377 // Indicate Connected for GUI
378 pAd->IndicateMediaState = NdisMediaStateConnected;
384 pAd->StaCfg.DefaultKeyId = (pKey->KeyIndex & 0xFF);
385 NdisZeroMemory(&pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId], sizeof(CIPHER_KEY));
386 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].KeyLen = LEN_TKIP_EK;
387 NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].Key, pKey->KeyMaterial, LEN_TKIP_EK);
388 #ifdef WPA_SUPPLICANT_SUPPORT
389 if (pAd->StaCfg.GroupCipher == Ndis802_11Encryption2Enabled)
391 NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].RxMic, pKey->KeyMaterial + LEN_TKIP_EK, LEN_TKIP_TXMICK);
392 NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].TxMic, pKey->KeyMaterial + LEN_TKIP_EK + LEN_TKIP_TXMICK, LEN_TKIP_RXMICK);
395 #endif // WPA_SUPPLICANT_SUPPORT //
397 NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].TxMic, pKey->KeyMaterial + LEN_TKIP_EK, LEN_TKIP_TXMICK);
398 NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].RxMic, pKey->KeyMaterial + LEN_TKIP_EK + LEN_TKIP_TXMICK, LEN_TKIP_RXMICK);
401 // Update Shared Key CipherAlg
402 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg = CIPHER_NONE;
403 if (pAd->StaCfg.GroupCipher == Ndis802_11Encryption2Enabled)
404 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg = CIPHER_TKIP;
405 else if (pAd->StaCfg.GroupCipher == Ndis802_11Encryption3Enabled)
406 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg = CIPHER_AES;
408 // Update group key information to ASIC Shared Key Table
409 AsicAddSharedKeyEntry(pAd,
411 pAd->StaCfg.DefaultKeyId,
412 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg,
413 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].Key,
414 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].TxMic,
415 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].RxMic);
417 // Update ASIC WCID attribute table and IVEIV table
418 RTMPAddWcidAttributeEntry(pAd,
420 pAd->StaCfg.DefaultKeyId,
421 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg,
424 // set 802.1x port control
425 //pAd->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
426 STA_PORT_SECURED(pAd);
428 // Indicate Connected for GUI
429 pAd->IndicateMediaState = NdisMediaStateConnected;
432 else // dynamic WEP from wpa_supplicant
437 if(pKey->KeyLength == 32)
440 KeyIdx = pKey->KeyIndex & 0x0fffffff;
444 // it is a default shared key, for Pairwise key setting
445 if (pKey->KeyIndex & 0x80000000)
447 pEntry = MacTableLookup(pAd, pKey->BSSID);
451 DBGPRINT(RT_DEBUG_TRACE, ("RTMPAddKey: Set Pair-wise Key\n"));
453 // set key material and key length
454 pEntry->PairwiseKey.KeyLen = (UCHAR)pKey->KeyLength;
455 NdisMoveMemory(pEntry->PairwiseKey.Key, &pKey->KeyMaterial, pKey->KeyLength);
458 if (pKey->KeyLength == 5)
459 pEntry->PairwiseKey.CipherAlg = CIPHER_WEP64;
461 pEntry->PairwiseKey.CipherAlg = CIPHER_WEP128;
463 // Add Pair-wise key to Asic
464 AsicAddPairwiseKeyEntry(
468 &pEntry->PairwiseKey);
470 // update WCID attribute table and IVEIV table for this entry
471 RTMPAddWcidAttributeEntry(
474 KeyIdx, // The value may be not zero
475 pEntry->PairwiseKey.CipherAlg,
482 // Default key for tx (shared key)
483 pAd->StaCfg.DefaultKeyId = (UCHAR) KeyIdx;
485 // set key material and key length
486 pAd->SharedKey[BSS0][KeyIdx].KeyLen = (UCHAR) pKey->KeyLength;
487 NdisMoveMemory(pAd->SharedKey[BSS0][KeyIdx].Key, &pKey->KeyMaterial, pKey->KeyLength);
490 if (pKey->KeyLength == 5)
491 pAd->SharedKey[BSS0][KeyIdx].CipherAlg = CIPHER_WEP64;
493 pAd->SharedKey[BSS0][KeyIdx].CipherAlg = CIPHER_WEP128;
495 CipherAlg = pAd->SharedKey[BSS0][KeyIdx].CipherAlg;
496 Key = pAd->SharedKey[BSS0][KeyIdx].Key;
498 // Set Group key material to Asic
499 AsicAddSharedKeyEntry(pAd, BSS0, KeyIdx, CipherAlg, Key, NULL, NULL);
501 // Update WCID attribute table and IVEIV table for this group key table
502 RTMPAddWcidAttributeEntry(pAd, BSS0, KeyIdx, CipherAlg, NULL);
511 char * rtstrchr(const char * s, int c)
513 for(; *s != (char) c; ++s)
520 This is required for LinEX2004/kernel2.6.7 to provide iwlist scanning function
524 rt_ioctl_giwname(struct net_device *dev,
525 struct iw_request_info *info,
526 char *name, char *extra)
528 // PRTMP_ADAPTER pAdapter = dev->ml_priv;
531 strncpy(name, "RT2870 Wireless", IFNAMSIZ);
536 int rt_ioctl_siwfreq(struct net_device *dev,
537 struct iw_request_info *info,
538 struct iw_freq *freq, char *extra)
540 PRTMP_ADAPTER pAdapter = dev->ml_priv;
543 //check if the interface is down
544 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
546 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
554 if((freq->e == 0) && (freq->m <= 1000))
555 chan = freq->m; // Setting by channel number
557 MAP_KHZ_TO_CHANNEL_ID( (freq->m /100) , chan); // Setting by frequency - search the table , like 2.412G, 2.422G,
559 if (ChannelSanity(pAdapter, chan) == TRUE)
561 pAdapter->CommonCfg.Channel = chan;
562 DBGPRINT(RT_DEBUG_ERROR, ("==>rt_ioctl_siwfreq::SIOCSIWFREQ[cmd=0x%x] (Channel=%d)\n", SIOCSIWFREQ, pAdapter->CommonCfg.Channel));
569 int rt_ioctl_giwfreq(struct net_device *dev,
570 struct iw_request_info *info,
571 struct iw_freq *freq, char *extra)
573 VIRTUAL_ADAPTER *pVirtualAd = NULL;
574 PRTMP_ADAPTER pAdapter;
578 if (dev->priv_flags == INT_MAIN)
580 pAdapter = dev->ml_priv;
584 pVirtualAd = dev->ml_priv;
585 pAdapter = pVirtualAd->RtmpDev->ml_priv;
588 if (pAdapter == NULL)
590 /* if 1st open fail, pAd will be free;
591 So the net_dev->ml_priv will be NULL in 2rd open */
595 ch = pAdapter->CommonCfg.Channel;
597 DBGPRINT(RT_DEBUG_TRACE,("==>rt_ioctl_giwfreq %d\n", ch));
599 MAP_CHANNEL_ID_TO_KHZ(ch, m);
605 int rt_ioctl_siwmode(struct net_device *dev,
606 struct iw_request_info *info,
607 __u32 *mode, char *extra)
609 PRTMP_ADAPTER pAdapter = dev->ml_priv;
611 //check if the interface is down
612 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
614 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
621 Set_NetworkType_Proc(pAdapter, "Adhoc");
624 Set_NetworkType_Proc(pAdapter, "Infra");
626 case IW_MODE_MONITOR:
627 Set_NetworkType_Proc(pAdapter, "Monitor");
630 DBGPRINT(RT_DEBUG_TRACE, ("===>rt_ioctl_siwmode::SIOCSIWMODE (unknown %d)\n", *mode));
634 // Reset Ralink supplicant to not use, it will be set to start when UI set PMK key
635 pAdapter->StaCfg.WpaState = SS_NOTUSE;
640 int rt_ioctl_giwmode(struct net_device *dev,
641 struct iw_request_info *info,
642 __u32 *mode, char *extra)
644 PRTMP_ADAPTER pAdapter = dev->ml_priv;
646 if (ADHOC_ON(pAdapter))
647 *mode = IW_MODE_ADHOC;
648 else if (INFRA_ON(pAdapter))
649 *mode = IW_MODE_INFRA;
650 else if (MONITOR_ON(pAdapter))
652 *mode = IW_MODE_MONITOR;
655 *mode = IW_MODE_AUTO;
657 DBGPRINT(RT_DEBUG_TRACE, ("==>rt_ioctl_giwmode(mode=%d)\n", *mode));
661 int rt_ioctl_siwsens(struct net_device *dev,
662 struct iw_request_info *info,
663 char *name, char *extra)
665 PRTMP_ADAPTER pAdapter = dev->ml_priv;
667 //check if the interface is down
668 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
670 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
677 int rt_ioctl_giwsens(struct net_device *dev,
678 struct iw_request_info *info,
679 char *name, char *extra)
684 int rt_ioctl_giwrange(struct net_device *dev,
685 struct iw_request_info *info,
686 struct iw_point *data, char *extra)
688 PRTMP_ADAPTER pAdapter = dev->ml_priv;
690 struct iw_range *range = (struct iw_range *) extra;
694 DBGPRINT(RT_DEBUG_TRACE ,("===>rt_ioctl_giwrange\n"));
695 data->length = sizeof(struct iw_range);
696 memset(range, 0, sizeof(struct iw_range));
698 range->txpower_capa = IW_TXPOW_DBM;
700 if (INFRA_ON(pAdapter)||ADHOC_ON(pAdapter))
702 range->min_pmp = 1 * 1024;
703 range->max_pmp = 65535 * 1024;
704 range->min_pmt = 1 * 1024;
705 range->max_pmt = 1000 * 1024;
706 range->pmp_flags = IW_POWER_PERIOD;
707 range->pmt_flags = IW_POWER_TIMEOUT;
708 range->pm_capa = IW_POWER_PERIOD | IW_POWER_TIMEOUT |
709 IW_POWER_UNICAST_R | IW_POWER_ALL_R;
712 range->we_version_compiled = WIRELESS_EXT;
713 range->we_version_source = 14;
715 range->retry_capa = IW_RETRY_LIMIT;
716 range->retry_flags = IW_RETRY_LIMIT;
717 range->min_retry = 0;
718 range->max_retry = 255;
720 range->num_channels = pAdapter->ChannelListNum;
723 for (i = 1; i <= range->num_channels; i++)
726 range->freq[val].i = pAdapter->ChannelList[i-1].Channel;
727 MAP_CHANNEL_ID_TO_KHZ(pAdapter->ChannelList[i-1].Channel, m);
728 range->freq[val].m = m * 100; /* HZ */
730 range->freq[val].e = 1;
732 if (val == IW_MAX_FREQUENCIES)
735 range->num_frequency = val;
737 range->max_qual.qual = 100; /* what is correct max? This was not
738 * documented exactly. At least
739 * 69 has been observed. */
740 range->max_qual.level = 0; /* dB */
741 range->max_qual.noise = 0; /* dB */
743 /* What would be suitable values for "average/typical" qual? */
744 range->avg_qual.qual = 20;
745 range->avg_qual.level = -60;
746 range->avg_qual.noise = -95;
747 range->sensitivity = 3;
749 range->max_encoding_tokens = NR_WEP_KEYS;
750 range->num_encoding_sizes = 2;
751 range->encoding_size[0] = 5;
752 range->encoding_size[1] = 13;
755 range->max_rts = 2347;
756 range->min_frag = 256;
757 range->max_frag = 2346;
759 #if WIRELESS_EXT > 17
760 /* IW_ENC_CAPA_* bit field */
761 range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 |
762 IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP;
768 int rt_ioctl_siwap(struct net_device *dev,
769 struct iw_request_info *info,
770 struct sockaddr *ap_addr, char *extra)
772 PRTMP_ADAPTER pAdapter = dev->ml_priv;
773 NDIS_802_11_MAC_ADDRESS Bssid;
775 //check if the interface is down
776 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
778 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
782 if (pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE)
784 RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
785 DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
788 // tell CNTL state machine to call NdisMSetInformationComplete() after completing
789 // this request, because this request is initiated by NDIS.
790 pAdapter->MlmeAux.CurrReqIsFromNdis = FALSE;
791 // Prevent to connect AP again in STAMlmePeriodicExec
792 pAdapter->MlmeAux.AutoReconnectSsidLen= 32;
794 memset(Bssid, 0, MAC_ADDR_LEN);
795 memcpy(Bssid, ap_addr->sa_data, MAC_ADDR_LEN);
796 MlmeEnqueue(pAdapter,
797 MLME_CNTL_STATE_MACHINE,
799 sizeof(NDIS_802_11_MAC_ADDRESS),
802 DBGPRINT(RT_DEBUG_TRACE, ("IOCTL::SIOCSIWAP %02x:%02x:%02x:%02x:%02x:%02x\n",
803 Bssid[0], Bssid[1], Bssid[2], Bssid[3], Bssid[4], Bssid[5]));
808 int rt_ioctl_giwap(struct net_device *dev,
809 struct iw_request_info *info,
810 struct sockaddr *ap_addr, char *extra)
812 PRTMP_ADAPTER pAdapter = dev->ml_priv;
814 if (INFRA_ON(pAdapter) || ADHOC_ON(pAdapter))
816 ap_addr->sa_family = ARPHRD_ETHER;
817 memcpy(ap_addr->sa_data, &pAdapter->CommonCfg.Bssid, ETH_ALEN);
819 #ifdef WPA_SUPPLICANT_SUPPORT
821 else if (pAdapter->StaCfg.WpaSupplicantUP != WPA_SUPPLICANT_DISABLE)
823 ap_addr->sa_family = ARPHRD_ETHER;
824 memcpy(ap_addr->sa_data, &pAdapter->MlmeAux.Bssid, ETH_ALEN);
826 #endif // WPA_SUPPLICANT_SUPPORT //
829 DBGPRINT(RT_DEBUG_TRACE, ("IOCTL::SIOCGIWAP(=EMPTY)\n"));
837 * Units are in db above the noise floor. That means the
838 * rssi values reported in the tx/rx descriptors in the
839 * driver are the SNR expressed in db.
841 * If you assume that the noise floor is -95, which is an
842 * excellent assumption 99.5 % of the time, then you can
843 * derive the absolute signal level (i.e. -95 + rssi).
844 * There are some other slight factors to take into account
845 * depending on whether the rssi measurement is from 11b,
846 * 11g, or 11a. These differences are at most 2db and
849 * NB: various calculations are based on the orinoco/wavelan
850 * drivers for compatibility
852 static void set_quality(PRTMP_ADAPTER pAdapter,
853 struct iw_quality *iq,
860 ChannelQuality = 100;
861 else if (rssi >= -80) // between -50 ~ -80dbm
862 ChannelQuality = (__u8)(24 + ((rssi + 80) * 26)/10);
863 else if (rssi >= -90) // between -80 ~ -90dbm
864 ChannelQuality = (__u8)((rssi + 90) * 26)/10;
868 iq->qual = (__u8)ChannelQuality;
870 iq->level = (__u8)(rssi);
871 iq->noise = (pAdapter->BbpWriteLatch[66] > pAdapter->BbpTuning.FalseCcaUpperThreshold) ? ((__u8)pAdapter->BbpTuning.FalseCcaUpperThreshold) : ((__u8) pAdapter->BbpWriteLatch[66]); // noise level (dBm)
872 iq->noise += 256 - 143;
873 iq->updated = pAdapter->iw_stats.qual.updated;
876 int rt_ioctl_iwaplist(struct net_device *dev,
877 struct iw_request_info *info,
878 struct iw_point *data, char *extra)
880 PRTMP_ADAPTER pAdapter = dev->ml_priv;
882 struct sockaddr addr[IW_MAX_AP];
883 struct iw_quality qual[IW_MAX_AP];
886 //check if the interface is down
887 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
889 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
895 for (i = 0; i <IW_MAX_AP ; i++)
897 if (i >= pAdapter->ScanTab.BssNr)
899 addr[i].sa_family = ARPHRD_ETHER;
900 memcpy(addr[i].sa_data, &pAdapter->ScanTab.BssEntry[i].Bssid, MAC_ADDR_LEN);
901 set_quality(pAdapter, &qual[i], pAdapter->ScanTab.BssEntry[i].Rssi);
904 memcpy(extra, &addr, i*sizeof(addr[0]));
905 data->flags = 1; /* signal quality present (sort of) */
906 memcpy(extra + i*sizeof(addr[0]), &qual, i*sizeof(qual[i]));
912 int rt_ioctl_siwscan(struct net_device *dev,
913 struct iw_request_info *info,
914 struct iw_point *data, char *extra)
916 PRTMP_ADAPTER pAdapter = dev->ml_priv;
919 int Status = NDIS_STATUS_SUCCESS;
921 //check if the interface is down
922 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
924 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
928 if (MONITOR_ON(pAdapter))
930 DBGPRINT(RT_DEBUG_TRACE, ("!!! Driver is in Monitor Mode now !!!\n"));
935 #ifdef WPA_SUPPLICANT_SUPPORT
936 if (pAdapter->StaCfg.WpaSupplicantUP == WPA_SUPPLICANT_ENABLE)
938 pAdapter->StaCfg.WpaSupplicantScanCount++;
940 #endif // WPA_SUPPLICANT_SUPPORT //
942 pAdapter->StaCfg.bScanReqIsFromWebUI = TRUE;
943 if (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
948 #ifdef WPA_SUPPLICANT_SUPPORT
949 if ((pAdapter->StaCfg.WpaSupplicantUP == WPA_SUPPLICANT_ENABLE) &&
950 (pAdapter->StaCfg.WpaSupplicantScanCount > 3))
952 DBGPRINT(RT_DEBUG_TRACE, ("!!! WpaSupplicantScanCount > 3\n"));
953 Status = NDIS_STATUS_SUCCESS;
956 #endif // WPA_SUPPLICANT_SUPPORT //
958 if ((OPSTATUS_TEST_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED)) &&
959 ((pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA) ||
960 (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK)) &&
961 (pAdapter->StaCfg.PortSecured == WPA_802_1X_PORT_NOT_SECURED))
963 DBGPRINT(RT_DEBUG_TRACE, ("!!! Link UP, Port Not Secured! ignore this set::OID_802_11_BSSID_LIST_SCAN\n"));
964 Status = NDIS_STATUS_SUCCESS;
968 if (pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE)
970 RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
971 DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
974 // tell CNTL state machine to call NdisMSetInformationComplete() after completing
975 // this request, because this request is initiated by NDIS.
976 pAdapter->MlmeAux.CurrReqIsFromNdis = FALSE;
977 // Reset allowed scan retries
978 pAdapter->StaCfg.ScanCnt = 0;
979 pAdapter->StaCfg.LastScanTime = Now;
981 MlmeEnqueue(pAdapter,
982 MLME_CNTL_STATE_MACHINE,
983 OID_802_11_BSSID_LIST_SCAN,
987 Status = NDIS_STATUS_SUCCESS;
988 RT28XX_MLME_HANDLER(pAdapter);
993 int rt_ioctl_giwscan(struct net_device *dev,
994 struct iw_request_info *info,
995 struct iw_point *data, char *extra)
998 PRTMP_ADAPTER pAdapter = dev->ml_priv;
1000 char *current_ev = extra, *previous_ev = extra;
1002 char *current_val, custom[MAX_CUSTOM_LEN] = {0};
1005 #endif // IWEVGENIE //
1006 struct iw_event iwe;
1008 if (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
1011 * Still scanning, indicate the caller should try again.
1017 #ifdef WPA_SUPPLICANT_SUPPORT
1018 if (pAdapter->StaCfg.WpaSupplicantUP == WPA_SUPPLICANT_ENABLE)
1020 pAdapter->StaCfg.WpaSupplicantScanCount = 0;
1022 #endif // WPA_SUPPLICANT_SUPPORT //
1024 if (pAdapter->ScanTab.BssNr == 0)
1030 #if WIRELESS_EXT >= 17
1031 if (data->length > 0)
1032 end_buf = extra + data->length;
1034 end_buf = extra + IW_SCAN_MAX_DATA;
1036 end_buf = extra + IW_SCAN_MAX_DATA;
1039 for (i = 0; i < pAdapter->ScanTab.BssNr; i++)
1041 if (current_ev >= end_buf)
1043 #if WIRELESS_EXT >= 17
1051 //================================
1052 memset(&iwe, 0, sizeof(iwe));
1053 iwe.cmd = SIOCGIWAP;
1054 iwe.u.ap_addr.sa_family = ARPHRD_ETHER;
1055 memcpy(iwe.u.ap_addr.sa_data, &pAdapter->ScanTab.BssEntry[i].Bssid, ETH_ALEN);
1057 previous_ev = current_ev;
1058 current_ev = iwe_stream_add_event(info, current_ev, end_buf, &iwe, IW_EV_ADDR_LEN);
1059 if (current_ev == previous_ev)
1060 #if WIRELESS_EXT >= 17
1068 it will show scanned AP's WirelessMode .
1077 memset(&iwe, 0, sizeof(iwe));
1078 iwe.cmd = SIOCGIWNAME;
1082 PBSS_ENTRY pBssEntry=&pAdapter->ScanTab.BssEntry[i];
1083 BOOLEAN isGonly=FALSE;
1086 if (pBssEntry->Channel>14)
1088 if (pBssEntry->HtCapabilityLen!=0)
1089 strcpy(iwe.u.name,"802.11a/n");
1091 strcpy(iwe.u.name,"802.11a");
1096 if one of non B mode rate is set supported rate . it mean G only.
1098 for (rateCnt=0;rateCnt<pBssEntry->SupRateLen;rateCnt++)
1101 6Mbps(140) 9Mbps(146) and >=12Mbps(152) are supported rate , it mean G only.
1103 if (pBssEntry->SupRate[rateCnt]==140 || pBssEntry->SupRate[rateCnt]==146 || pBssEntry->SupRate[rateCnt]>=152)
1107 for (rateCnt=0;rateCnt<pBssEntry->ExtRateLen;rateCnt++)
1109 if (pBssEntry->ExtRate[rateCnt]==140 || pBssEntry->ExtRate[rateCnt]==146 || pBssEntry->ExtRate[rateCnt]>=152)
1114 if (pBssEntry->HtCapabilityLen!=0)
1117 strcpy(iwe.u.name,"802.11g/n");
1119 strcpy(iwe.u.name,"802.11b/g/n");
1124 strcpy(iwe.u.name,"802.11g");
1127 if (pBssEntry->SupRateLen==4 && pBssEntry->ExtRateLen==0)
1128 strcpy(iwe.u.name,"802.11b");
1130 strcpy(iwe.u.name,"802.11b/g");
1136 previous_ev = current_ev;
1137 current_ev = iwe_stream_add_event(info, current_ev, end_buf, &iwe, IW_EV_ADDR_LEN);
1138 if (current_ev == previous_ev)
1139 #if WIRELESS_EXT >= 17
1146 //================================
1147 memset(&iwe, 0, sizeof(iwe));
1148 iwe.cmd = SIOCGIWESSID;
1149 iwe.u.data.length = pAdapter->ScanTab.BssEntry[i].SsidLen;
1150 iwe.u.data.flags = 1;
1152 previous_ev = current_ev;
1153 current_ev = iwe_stream_add_point(info, current_ev, end_buf, &iwe, pAdapter->ScanTab.BssEntry[i].Ssid);
1154 if (current_ev == previous_ev)
1155 #if WIRELESS_EXT >= 17
1162 //================================
1163 memset(&iwe, 0, sizeof(iwe));
1164 iwe.cmd = SIOCGIWMODE;
1165 if (pAdapter->ScanTab.BssEntry[i].BssType == Ndis802_11IBSS)
1167 iwe.u.mode = IW_MODE_ADHOC;
1169 else if (pAdapter->ScanTab.BssEntry[i].BssType == Ndis802_11Infrastructure)
1171 iwe.u.mode = IW_MODE_INFRA;
1175 iwe.u.mode = IW_MODE_AUTO;
1177 iwe.len = IW_EV_UINT_LEN;
1179 previous_ev = current_ev;
1180 current_ev = iwe_stream_add_event(info, current_ev, end_buf, &iwe, IW_EV_UINT_LEN);
1181 if (current_ev == previous_ev)
1182 #if WIRELESS_EXT >= 17
1188 //Channel and Frequency
1189 //================================
1190 memset(&iwe, 0, sizeof(iwe));
1191 iwe.cmd = SIOCGIWFREQ;
1192 if (INFRA_ON(pAdapter) || ADHOC_ON(pAdapter))
1193 iwe.u.freq.m = pAdapter->ScanTab.BssEntry[i].Channel;
1195 iwe.u.freq.m = pAdapter->ScanTab.BssEntry[i].Channel;
1199 previous_ev = current_ev;
1200 current_ev = iwe_stream_add_event(info, current_ev, end_buf, &iwe, IW_EV_FREQ_LEN);
1201 if (current_ev == previous_ev)
1202 #if WIRELESS_EXT >= 17
1208 //Add quality statistics
1209 //================================
1210 memset(&iwe, 0, sizeof(iwe));
1212 iwe.u.qual.level = 0;
1213 iwe.u.qual.noise = 0;
1214 set_quality(pAdapter, &iwe.u.qual, pAdapter->ScanTab.BssEntry[i].Rssi);
1215 current_ev = iwe_stream_add_event(info, current_ev, end_buf, &iwe, IW_EV_QUAL_LEN);
1216 if (current_ev == previous_ev)
1217 #if WIRELESS_EXT >= 17
1224 //================================
1225 memset(&iwe, 0, sizeof(iwe));
1226 iwe.cmd = SIOCGIWENCODE;
1227 if (CAP_IS_PRIVACY_ON (pAdapter->ScanTab.BssEntry[i].CapabilityInfo ))
1228 iwe.u.data.flags =IW_ENCODE_ENABLED | IW_ENCODE_NOKEY;
1230 iwe.u.data.flags = IW_ENCODE_DISABLED;
1232 previous_ev = current_ev;
1233 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);
1234 if (current_ev == previous_ev)
1235 #if WIRELESS_EXT >= 17
1242 //================================
1243 if (pAdapter->ScanTab.BssEntry[i].SupRateLen)
1245 UCHAR tmpRate = pAdapter->ScanTab.BssEntry[i].SupRate[pAdapter->ScanTab.BssEntry[i].SupRateLen-1];
1246 memset(&iwe, 0, sizeof(iwe));
1247 iwe.cmd = SIOCGIWRATE;
1248 current_val = current_ev + IW_EV_LCP_LEN;
1249 if (tmpRate == 0x82)
1250 iwe.u.bitrate.value = 1 * 1000000;
1251 else if (tmpRate == 0x84)
1252 iwe.u.bitrate.value = 2 * 1000000;
1253 else if (tmpRate == 0x8B)
1254 iwe.u.bitrate.value = 5.5 * 1000000;
1255 else if (tmpRate == 0x96)
1256 iwe.u.bitrate.value = 11 * 1000000;
1258 iwe.u.bitrate.value = (tmpRate/2) * 1000000;
1260 iwe.u.bitrate.disabled = 0;
1261 current_val = iwe_stream_add_value(info, current_ev,
1262 current_val, end_buf, &iwe,
1265 if((current_val-current_ev)>IW_EV_LCP_LEN)
1266 current_ev = current_val;
1268 #if WIRELESS_EXT >= 17
1277 if (pAdapter->ScanTab.BssEntry[i].WpaIE.IELen > 0)
1279 memset(&iwe, 0, sizeof(iwe));
1280 memset(&custom[0], 0, MAX_CUSTOM_LEN);
1281 memcpy(custom, &(pAdapter->ScanTab.BssEntry[i].WpaIE.IE[0]),
1282 pAdapter->ScanTab.BssEntry[i].WpaIE.IELen);
1283 iwe.cmd = IWEVGENIE;
1284 iwe.u.data.length = pAdapter->ScanTab.BssEntry[i].WpaIE.IELen;
1285 current_ev = iwe_stream_add_point(info, current_ev, end_buf, &iwe, custom);
1286 if (current_ev == previous_ev)
1287 #if WIRELESS_EXT >= 17
1295 if (pAdapter->ScanTab.BssEntry[i].RsnIE.IELen > 0)
1297 memset(&iwe, 0, sizeof(iwe));
1298 memset(&custom[0], 0, MAX_CUSTOM_LEN);
1299 memcpy(custom, &(pAdapter->ScanTab.BssEntry[i].RsnIE.IE[0]),
1300 pAdapter->ScanTab.BssEntry[i].RsnIE.IELen);
1301 iwe.cmd = IWEVGENIE;
1302 iwe.u.data.length = pAdapter->ScanTab.BssEntry[i].RsnIE.IELen;
1303 current_ev = iwe_stream_add_point(info, current_ev, end_buf, &iwe, custom);
1304 if (current_ev == previous_ev)
1305 #if WIRELESS_EXT >= 17
1313 //================================
1314 if (pAdapter->ScanTab.BssEntry[i].WpaIE.IELen > 0)
1316 NdisZeroMemory(&iwe, sizeof(iwe));
1317 memset(&custom[0], 0, MAX_CUSTOM_LEN);
1318 iwe.cmd = IWEVCUSTOM;
1319 iwe.u.data.length = (pAdapter->ScanTab.BssEntry[i].WpaIE.IELen * 2) + 7;
1320 NdisMoveMemory(custom, "wpa_ie=", 7);
1321 for (idx = 0; idx < pAdapter->ScanTab.BssEntry[i].WpaIE.IELen; idx++)
1322 sprintf(custom, "%s%02x", custom, pAdapter->ScanTab.BssEntry[i].WpaIE.IE[idx]);
1323 previous_ev = current_ev;
1324 current_ev = iwe_stream_add_point(current_ev, end_buf, &iwe, custom);
1325 if (current_ev == previous_ev)
1326 #if WIRELESS_EXT >= 17
1334 if (pAdapter->ScanTab.BssEntry[i].RsnIE.IELen > 0)
1336 NdisZeroMemory(&iwe, sizeof(iwe));
1337 memset(&custom[0], 0, MAX_CUSTOM_LEN);
1338 iwe.cmd = IWEVCUSTOM;
1339 iwe.u.data.length = (pAdapter->ScanTab.BssEntry[i].RsnIE.IELen * 2) + 7;
1340 NdisMoveMemory(custom, "rsn_ie=", 7);
1341 for (idx = 0; idx < pAdapter->ScanTab.BssEntry[i].RsnIE.IELen; idx++)
1342 sprintf(custom, "%s%02x", custom, pAdapter->ScanTab.BssEntry[i].RsnIE.IE[idx]);
1343 previous_ev = current_ev;
1344 current_ev = iwe_stream_add_point(current_ev, end_buf, &iwe, custom);
1345 if (current_ev == previous_ev)
1346 #if WIRELESS_EXT >= 17
1352 #endif // IWEVGENIE //
1355 data->length = current_ev - extra;
1356 pAdapter->StaCfg.bScanReqIsFromWebUI = FALSE;
1357 DBGPRINT(RT_DEBUG_ERROR ,("===>rt_ioctl_giwscan. %d(%d) BSS returned, data->length = %d\n",i , pAdapter->ScanTab.BssNr, data->length));
1362 int rt_ioctl_siwessid(struct net_device *dev,
1363 struct iw_request_info *info,
1364 struct iw_point *data, char *essid)
1366 PRTMP_ADAPTER pAdapter = dev->ml_priv;
1368 //check if the interface is down
1369 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1371 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1377 PCHAR pSsidString = NULL;
1379 // Includes null character.
1380 if (data->length > (IW_ESSID_MAX_SIZE + 1))
1383 pSsidString = (CHAR *) kmalloc(MAX_LEN_OF_SSID+1, MEM_ALLOC_FLAG);
1386 NdisZeroMemory(pSsidString, MAX_LEN_OF_SSID+1);
1387 NdisMoveMemory(pSsidString, essid, data->length);
1388 if (Set_SSID_Proc(pAdapter, pSsidString) == FALSE)
1397 if (Set_SSID_Proc(pAdapter, "") == FALSE)
1403 int rt_ioctl_giwessid(struct net_device *dev,
1404 struct iw_request_info *info,
1405 struct iw_point *data, char *essid)
1407 PRTMP_ADAPTER pAdapter = dev->ml_priv;
1410 if (MONITOR_ON(pAdapter))
1416 if (OPSTATUS_TEST_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED))
1418 DBGPRINT(RT_DEBUG_TRACE ,("MediaState is connected\n"));
1419 data->length = pAdapter->CommonCfg.SsidLen;
1420 memcpy(essid, pAdapter->CommonCfg.Ssid, pAdapter->CommonCfg.SsidLen);
1423 #ifdef WPA_SUPPLICANT_SUPPORT
1425 else if (pAdapter->StaCfg.WpaSupplicantUP != WPA_SUPPLICANT_DISABLE)
1427 data->length = pAdapter->CommonCfg.SsidLen;
1428 memcpy(essid, pAdapter->CommonCfg.Ssid, pAdapter->CommonCfg.SsidLen);
1430 #endif // WPA_SUPPLICANT_SUPPORT //
1433 {//the ANY ssid was specified
1435 DBGPRINT(RT_DEBUG_TRACE ,("MediaState is not connected, ess\n"));
1442 int rt_ioctl_siwnickn(struct net_device *dev,
1443 struct iw_request_info *info,
1444 struct iw_point *data, char *nickname)
1446 PRTMP_ADAPTER pAdapter = dev->ml_priv;
1448 //check if the interface is down
1449 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1451 DBGPRINT(RT_DEBUG_TRACE ,("INFO::Network is down!\n"));
1455 if (data->length > IW_ESSID_MAX_SIZE)
1458 memset(pAdapter->nickname, 0, IW_ESSID_MAX_SIZE + 1);
1459 memcpy(pAdapter->nickname, nickname, data->length);
1465 int rt_ioctl_giwnickn(struct net_device *dev,
1466 struct iw_request_info *info,
1467 struct iw_point *data, char *nickname)
1469 PRTMP_ADAPTER pAdapter = dev->ml_priv;
1471 if (data->length > strlen(pAdapter->nickname) + 1)
1472 data->length = strlen(pAdapter->nickname) + 1;
1473 if (data->length > 0) {
1474 memcpy(nickname, pAdapter->nickname, data->length-1);
1475 nickname[data->length-1] = '\0';
1480 int rt_ioctl_siwrts(struct net_device *dev,
1481 struct iw_request_info *info,
1482 struct iw_param *rts, char *extra)
1484 PRTMP_ADAPTER pAdapter = dev->ml_priv;
1487 //check if the interface is down
1488 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1490 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1495 val = MAX_RTS_THRESHOLD;
1496 else if (rts->value < 0 || rts->value > MAX_RTS_THRESHOLD)
1498 else if (rts->value == 0)
1499 val = MAX_RTS_THRESHOLD;
1503 if (val != pAdapter->CommonCfg.RtsThreshold)
1504 pAdapter->CommonCfg.RtsThreshold = val;
1509 int rt_ioctl_giwrts(struct net_device *dev,
1510 struct iw_request_info *info,
1511 struct iw_param *rts, char *extra)
1513 PRTMP_ADAPTER pAdapter = dev->ml_priv;
1515 //check if the interface is down
1516 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1518 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1522 rts->value = pAdapter->CommonCfg.RtsThreshold;
1523 rts->disabled = (rts->value == MAX_RTS_THRESHOLD);
1529 int rt_ioctl_siwfrag(struct net_device *dev,
1530 struct iw_request_info *info,
1531 struct iw_param *frag, char *extra)
1533 PRTMP_ADAPTER pAdapter = dev->ml_priv;
1536 //check if the interface is down
1537 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1539 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1544 val = MAX_FRAG_THRESHOLD;
1545 else if (frag->value >= MIN_FRAG_THRESHOLD || frag->value <= MAX_FRAG_THRESHOLD)
1546 val = __cpu_to_le16(frag->value & ~0x1); /* even numbers only */
1547 else if (frag->value == 0)
1548 val = MAX_FRAG_THRESHOLD;
1552 pAdapter->CommonCfg.FragmentThreshold = val;
1556 int rt_ioctl_giwfrag(struct net_device *dev,
1557 struct iw_request_info *info,
1558 struct iw_param *frag, char *extra)
1560 PRTMP_ADAPTER pAdapter = dev->ml_priv;
1562 //check if the interface is down
1563 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1565 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1569 frag->value = pAdapter->CommonCfg.FragmentThreshold;
1570 frag->disabled = (frag->value == MAX_FRAG_THRESHOLD);
1576 #define MAX_WEP_KEY_SIZE 13
1577 #define MIN_WEP_KEY_SIZE 5
1578 int rt_ioctl_siwencode(struct net_device *dev,
1579 struct iw_request_info *info,
1580 struct iw_point *erq, char *extra)
1582 PRTMP_ADAPTER pAdapter = dev->ml_priv;
1584 //check if the interface is down
1585 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1587 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1591 if ((erq->length == 0) &&
1592 (erq->flags & IW_ENCODE_DISABLED))
1594 pAdapter->StaCfg.PairCipher = Ndis802_11WEPDisabled;
1595 pAdapter->StaCfg.GroupCipher = Ndis802_11WEPDisabled;
1596 pAdapter->StaCfg.WepStatus = Ndis802_11WEPDisabled;
1597 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
1598 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
1601 else if (erq->flags & IW_ENCODE_RESTRICTED || erq->flags & IW_ENCODE_OPEN)
1603 //pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
1604 STA_PORT_SECURED(pAdapter);
1605 pAdapter->StaCfg.PairCipher = Ndis802_11WEPEnabled;
1606 pAdapter->StaCfg.GroupCipher = Ndis802_11WEPEnabled;
1607 pAdapter->StaCfg.WepStatus = Ndis802_11WEPEnabled;
1608 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
1609 if (erq->flags & IW_ENCODE_RESTRICTED)
1610 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeShared;
1612 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
1615 if (erq->length > 0)
1617 int keyIdx = (erq->flags & IW_ENCODE_INDEX) - 1;
1618 /* Check the size of the key */
1619 if (erq->length > MAX_WEP_KEY_SIZE)
1623 /* Check key index */
1624 if ((keyIdx < 0) || (keyIdx >= NR_WEP_KEYS))
1626 DBGPRINT(RT_DEBUG_TRACE ,("==>rt_ioctl_siwencode::Wrong keyIdx=%d! Using default key instead (%d)\n",
1627 keyIdx, pAdapter->StaCfg.DefaultKeyId));
1630 keyIdx = pAdapter->StaCfg.DefaultKeyId;
1634 pAdapter->StaCfg.DefaultKeyId=keyIdx;
1637 NdisZeroMemory(pAdapter->SharedKey[BSS0][keyIdx].Key, 16);
1639 if (erq->length == MAX_WEP_KEY_SIZE)
1641 pAdapter->SharedKey[BSS0][keyIdx].KeyLen = MAX_WEP_KEY_SIZE;
1642 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CIPHER_WEP128;
1644 else if (erq->length == MIN_WEP_KEY_SIZE)
1646 pAdapter->SharedKey[BSS0][keyIdx].KeyLen = MIN_WEP_KEY_SIZE;
1647 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CIPHER_WEP64;
1650 /* Disable the key */
1651 pAdapter->SharedKey[BSS0][keyIdx].KeyLen = 0;
1653 /* Check if the key is not marked as invalid */
1654 if(!(erq->flags & IW_ENCODE_NOKEY))
1656 /* Copy the key in the driver */
1657 NdisMoveMemory(pAdapter->SharedKey[BSS0][keyIdx].Key, extra, erq->length);
1662 /* Do we want to just set the transmit key index ? */
1663 int index = (erq->flags & IW_ENCODE_INDEX) - 1;
1664 if ((index >= 0) && (index < 4))
1666 pAdapter->StaCfg.DefaultKeyId = index;
1669 /* Don't complain if only change the mode */
1670 if (!(erq->flags & IW_ENCODE_MODE))
1675 DBGPRINT(RT_DEBUG_TRACE ,("==>rt_ioctl_siwencode::erq->flags=%x\n",erq->flags));
1676 DBGPRINT(RT_DEBUG_TRACE ,("==>rt_ioctl_siwencode::AuthMode=%x\n",pAdapter->StaCfg.AuthMode));
1677 DBGPRINT(RT_DEBUG_TRACE ,("==>rt_ioctl_siwencode::DefaultKeyId=%x, KeyLen = %d\n",pAdapter->StaCfg.DefaultKeyId , pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].KeyLen));
1678 DBGPRINT(RT_DEBUG_TRACE ,("==>rt_ioctl_siwencode::WepStatus=%x\n",pAdapter->StaCfg.WepStatus));
1683 rt_ioctl_giwencode(struct net_device *dev,
1684 struct iw_request_info *info,
1685 struct iw_point *erq, char *key)
1687 PRTMP_ADAPTER pAdapter = dev->ml_priv;
1690 //check if the interface is down
1691 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1693 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1697 kid = erq->flags & IW_ENCODE_INDEX;
1698 DBGPRINT(RT_DEBUG_TRACE, ("===>rt_ioctl_giwencode %d\n", erq->flags & IW_ENCODE_INDEX));
1700 if (pAdapter->StaCfg.WepStatus == Ndis802_11WEPDisabled)
1703 erq->flags = IW_ENCODE_DISABLED;
1705 else if ((kid > 0) && (kid <=4))
1708 erq->flags = kid ; /* NB: base 1 */
1709 if (erq->length > pAdapter->SharedKey[BSS0][kid-1].KeyLen)
1710 erq->length = pAdapter->SharedKey[BSS0][kid-1].KeyLen;
1711 memcpy(key, pAdapter->SharedKey[BSS0][kid-1].Key, erq->length);
1712 //if ((kid == pAdapter->PortCfg.DefaultKeyId))
1713 //erq->flags |= IW_ENCODE_ENABLED; /* XXX */
1714 if (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeShared)
1715 erq->flags |= IW_ENCODE_RESTRICTED; /* XXX */
1717 erq->flags |= IW_ENCODE_OPEN; /* XXX */
1722 if (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeShared)
1723 erq->flags |= IW_ENCODE_RESTRICTED; /* XXX */
1725 erq->flags |= IW_ENCODE_OPEN; /* XXX */
1726 erq->length = pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].KeyLen;
1727 memcpy(key, pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].Key, erq->length);
1728 // copy default key ID
1729 if (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeShared)
1730 erq->flags |= IW_ENCODE_RESTRICTED; /* XXX */
1732 erq->flags |= IW_ENCODE_OPEN; /* XXX */
1733 erq->flags = pAdapter->StaCfg.DefaultKeyId + 1; /* NB: base 1 */
1734 erq->flags |= IW_ENCODE_ENABLED; /* XXX */
1742 rt_ioctl_setparam(struct net_device *dev, struct iw_request_info *info,
1743 void *w, char *extra)
1745 VIRTUAL_ADAPTER *pVirtualAd = NULL;
1746 PRTMP_ADAPTER pAdapter;
1748 char *this_char = extra;
1752 if (dev->priv_flags == INT_MAIN)
1754 pAdapter = dev->ml_priv;
1758 pVirtualAd = dev->ml_priv;
1759 pAdapter = pVirtualAd->RtmpDev->ml_priv;
1761 pObj = (POS_COOKIE) pAdapter->OS_Cookie;
1763 if (pAdapter == NULL)
1765 /* if 1st open fail, pAd will be free;
1766 So the net_dev->ml_priv will be NULL in 2rd open */
1771 pObj->ioctl_if_type = INT_MAIN;
1772 pObj->ioctl_if = MAIN_MBSSID;
1775 //check if the interface is down
1776 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1778 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1785 if ((value = rtstrchr(this_char, '=')) != NULL)
1791 // reject setting nothing besides ANY ssid(ssidLen=0)
1792 if (!*value && (strcmp(this_char, "SSID") != 0))
1795 for (PRTMP_PRIVATE_SET_PROC = RTMP_PRIVATE_SUPPORT_PROC; PRTMP_PRIVATE_SET_PROC->name; PRTMP_PRIVATE_SET_PROC++)
1797 if (strcmp(this_char, PRTMP_PRIVATE_SET_PROC->name) == 0)
1799 if(!PRTMP_PRIVATE_SET_PROC->set_proc(pAdapter, value))
1800 { //FALSE:Set private failed then return Invalid argument
1803 break; //Exit for loop.
1807 if(PRTMP_PRIVATE_SET_PROC->name == NULL)
1808 { //Not found argument
1810 DBGPRINT(RT_DEBUG_TRACE, ("===>rt_ioctl_setparam:: (iwpriv) Not Support Set Command [%s=%s]\n", this_char, value));
1818 rt_private_get_statistics(struct net_device *dev, struct iw_request_info *info,
1819 struct iw_point *wrq, char *extra)
1822 PRTMP_ADAPTER pAd = dev->ml_priv;
1830 memset(extra, 0x00, IW_PRIV_SIZE_MASK);
1831 sprintf(extra, "\n\n");
1834 sprintf(extra+strlen(extra), "Tx success = %ld\n", (ULONG)pAd->WlanCounters.TransmittedFragmentCount.QuadPart);
1835 sprintf(extra+strlen(extra), "Tx success without retry = %ld\n", (ULONG)pAd->WlanCounters.TransmittedFragmentCount.QuadPart - (ULONG)pAd->WlanCounters.RetryCount.QuadPart);
1837 sprintf(extra+strlen(extra), "Tx success after retry = %ld\n", (ULONG)pAd->WlanCounters.RetryCount.QuadPart);
1838 sprintf(extra+strlen(extra), "Tx fail to Rcv ACK after retry = %ld\n", (ULONG)pAd->WlanCounters.FailedCount.QuadPart);
1839 sprintf(extra+strlen(extra), "RTS Success Rcv CTS = %ld\n", (ULONG)pAd->WlanCounters.RTSSuccessCount.QuadPart);
1840 sprintf(extra+strlen(extra), "RTS Fail Rcv CTS = %ld\n", (ULONG)pAd->WlanCounters.RTSFailureCount.QuadPart);
1842 sprintf(extra+strlen(extra), "Rx success = %ld\n", (ULONG)pAd->WlanCounters.ReceivedFragmentCount.QuadPart);
1843 sprintf(extra+strlen(extra), "Rx with CRC = %ld\n", (ULONG)pAd->WlanCounters.FCSErrorCount.QuadPart);
1844 sprintf(extra+strlen(extra), "Rx drop due to out of resource = %ld\n", (ULONG)pAd->Counters8023.RxNoBuffer);
1845 sprintf(extra+strlen(extra), "Rx duplicate frame = %ld\n", (ULONG)pAd->WlanCounters.FrameDuplicateCount.QuadPart);
1847 sprintf(extra+strlen(extra), "False CCA (one second) = %ld\n", (ULONG)pAd->RalinkCounters.OneSecFalseCCACnt);
1849 sprintf(extra+strlen(extra), "RSSI-A = %ld\n", (LONG)(pAd->StaCfg.RssiSample.LastRssi0 - pAd->BbpRssiToDbmDelta));
1850 sprintf(extra+strlen(extra), "RSSI-B (if available) = %ld\n", (LONG)(pAd->StaCfg.RssiSample.LastRssi1 - pAd->BbpRssiToDbmDelta));
1851 sprintf(extra+strlen(extra), "RSSI-C (if available) = %ld\n\n", (LONG)(pAd->StaCfg.RssiSample.LastRssi2 - pAd->BbpRssiToDbmDelta));
1853 #ifdef WPA_SUPPLICANT_SUPPORT
1854 sprintf(extra+strlen(extra), "WpaSupplicantUP = %d\n\n", pAd->StaCfg.WpaSupplicantUP);
1855 #endif // WPA_SUPPLICANT_SUPPORT //
1858 wrq->length = strlen(extra) + 1; // 1: size of '\0'
1859 DBGPRINT(RT_DEBUG_TRACE, ("<== rt_private_get_statistics, wrq->length = %d\n", wrq->length));
1864 #ifdef DOT11_N_SUPPORT
1866 IN PRTMP_ADAPTER pAd,
1870 BA_ORI_ENTRY *pOriBAEntry;
1871 BA_REC_ENTRY *pRecBAEntry;
1873 for (i=0; i<MAX_LEN_OF_MAC_TABLE; i++)
1875 PMAC_TABLE_ENTRY pEntry = &pAd->MacTab.Content[i];
1876 if (((pEntry->ValidAsCLI || pEntry->ValidAsApCli) && (pEntry->Sst == SST_ASSOC))
1877 || (pEntry->ValidAsWDS) || (pEntry->ValidAsMesh))
1879 sprintf(pOutBuf, "%s\n%02X:%02X:%02X:%02X:%02X:%02X (Aid = %d) (AP) -\n",
1881 pEntry->Addr[0], pEntry->Addr[1], pEntry->Addr[2],
1882 pEntry->Addr[3], pEntry->Addr[4], pEntry->Addr[5], pEntry->Aid);
1884 sprintf(pOutBuf, "%s[Recipient]\n", pOutBuf);
1885 for (j=0; j < NUM_OF_TID; j++)
1887 if (pEntry->BARecWcidArray[j] != 0)
1889 pRecBAEntry =&pAd->BATable.BARecEntry[pEntry->BARecWcidArray[j]];
1890 sprintf(pOutBuf, "%sTID=%d, BAWinSize=%d, LastIndSeq=%d, ReorderingPkts=%d\n", pOutBuf, j, pRecBAEntry->BAWinSize, pRecBAEntry->LastIndSeq, pRecBAEntry->list.qlen);
1893 sprintf(pOutBuf, "%s\n", pOutBuf);
1895 sprintf(pOutBuf, "%s[Originator]\n", pOutBuf);
1896 for (j=0; j < NUM_OF_TID; j++)
1898 if (pEntry->BAOriWcidArray[j] != 0)
1900 pOriBAEntry =&pAd->BATable.BAOriEntry[pEntry->BAOriWcidArray[j]];
1901 sprintf(pOutBuf, "%sTID=%d, BAWinSize=%d, StartSeq=%d, CurTxSeq=%d\n", pOutBuf, j, pOriBAEntry->BAWinSize, pOriBAEntry->Sequence, pEntry->TxSeq[j]);
1904 sprintf(pOutBuf, "%s\n\n", pOutBuf);
1906 if (strlen(pOutBuf) > (IW_PRIV_SIZE_MASK - 30))
1912 #endif // DOT11_N_SUPPORT //
1915 rt_private_show(struct net_device *dev, struct iw_request_info *info,
1916 struct iw_point *wrq, char *extra)
1919 VIRTUAL_ADAPTER *pVirtualAd = NULL;
1922 u32 subcmd = wrq->flags;
1924 if (dev->priv_flags == INT_MAIN)
1928 pVirtualAd = dev->ml_priv;
1929 pAd = pVirtualAd->RtmpDev->ml_priv;
1931 pObj = (POS_COOKIE) pAd->OS_Cookie;
1935 /* if 1st open fail, pAd will be free;
1936 So the net_dev->ml_priv will be NULL in 2rd open */
1945 memset(extra, 0x00, IW_PRIV_SIZE_MASK);
1948 pObj->ioctl_if_type = INT_MAIN;
1949 pObj->ioctl_if = MAIN_MBSSID;
1955 case SHOW_CONN_STATUS:
1956 if (MONITOR_ON(pAd))
1958 #ifdef DOT11_N_SUPPORT
1959 if (pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED &&
1960 pAd->CommonCfg.RegTransmitSetting.field.BW)
1961 sprintf(extra, "Monitor Mode(CentralChannel %d)\n", pAd->CommonCfg.CentralChannel);
1963 #endif // DOT11_N_SUPPORT //
1964 sprintf(extra, "Monitor Mode(Channel %d)\n", pAd->CommonCfg.Channel);
1968 if (pAd->IndicateMediaState == NdisMediaStateConnected)
1972 sprintf(extra, "Connected(AP: %s[%02X:%02X:%02X:%02X:%02X:%02X])\n",
1973 pAd->CommonCfg.Ssid,
1974 pAd->CommonCfg.Bssid[0],
1975 pAd->CommonCfg.Bssid[1],
1976 pAd->CommonCfg.Bssid[2],
1977 pAd->CommonCfg.Bssid[3],
1978 pAd->CommonCfg.Bssid[4],
1979 pAd->CommonCfg.Bssid[5]);
1980 DBGPRINT(RT_DEBUG_TRACE ,("Ssid=%s ,Ssidlen = %d\n",pAd->CommonCfg.Ssid, pAd->CommonCfg.SsidLen));
1982 else if (ADHOC_ON(pAd))
1983 sprintf(extra, "Connected\n");
1987 sprintf(extra, "Disconnected\n");
1988 DBGPRINT(RT_DEBUG_TRACE ,("ConnStatus is not connected\n"));
1991 wrq->length = strlen(extra) + 1; // 1: size of '\0'
1993 case SHOW_DRVIER_VERION:
1994 sprintf(extra, "Driver version-%s, %s %s\n", STA_DRIVER_VERSION, __DATE__, __TIME__ );
1995 wrq->length = strlen(extra) + 1; // 1: size of '\0'
1997 #ifdef DOT11_N_SUPPORT
1999 getBaInfo(pAd, extra);
2000 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2002 #endif // DOT11_N_SUPPORT //
2003 case SHOW_DESC_INFO:
2005 Show_DescInfo_Proc(pAd, NULL);
2006 wrq->length = 0; // 1: size of '\0'
2010 if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
2012 sprintf(extra, "Scanning\n");
2013 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2016 pAd->StaCfg.bSwRadio = FALSE;
2017 if (pAd->StaCfg.bRadio != (pAd->StaCfg.bHwRadio && pAd->StaCfg.bSwRadio))
2019 pAd->StaCfg.bRadio = (pAd->StaCfg.bHwRadio && pAd->StaCfg.bSwRadio);
2020 if (pAd->StaCfg.bRadio == FALSE)
2023 // Update extra information
2024 pAd->ExtraInfo = SW_RADIO_OFF;
2027 sprintf(extra, "Radio Off\n");
2028 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2031 if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
2033 sprintf(extra, "Scanning\n");
2034 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2037 pAd->StaCfg.bSwRadio = TRUE;
2038 //if (pAd->StaCfg.bRadio != (pAd->StaCfg.bHwRadio && pAd->StaCfg.bSwRadio))
2040 pAd->StaCfg.bRadio = (pAd->StaCfg.bHwRadio && pAd->StaCfg.bSwRadio);
2041 if (pAd->StaCfg.bRadio == TRUE)
2044 // Update extra information
2045 pAd->ExtraInfo = EXTRA_INFO_CLEAR;
2048 sprintf(extra, "Radio On\n");
2049 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2052 case SHOW_CFG_VALUE:
2054 Status = RTMPShowCfgValue(pAd, wrq->pointer, extra);
2056 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2060 DBGPRINT(RT_DEBUG_TRACE, ("%s - unknow subcmd = %d\n", __func__, subcmd));
2068 int rt_ioctl_siwmlme(struct net_device *dev,
2069 struct iw_request_info *info,
2070 union iwreq_data *wrqu,
2073 PRTMP_ADAPTER pAd = dev->ml_priv;
2074 struct iw_mlme *pMlme = (struct iw_mlme *)wrqu->data.pointer;
2075 MLME_QUEUE_ELEM MsgElem;
2076 MLME_DISASSOC_REQ_STRUCT DisAssocReq;
2077 MLME_DEAUTH_REQ_STRUCT DeAuthReq;
2079 DBGPRINT(RT_DEBUG_TRACE, ("====> %s\n", __func__));
2086 #ifdef IW_MLME_DEAUTH
2087 case IW_MLME_DEAUTH:
2088 DBGPRINT(RT_DEBUG_TRACE, ("====> %s - IW_MLME_DEAUTH\n", __func__));
2089 COPY_MAC_ADDR(DeAuthReq.Addr, pAd->CommonCfg.Bssid);
2090 DeAuthReq.Reason = pMlme->reason_code;
2091 MsgElem.MsgLen = sizeof(MLME_DEAUTH_REQ_STRUCT);
2092 NdisMoveMemory(MsgElem.Msg, &DeAuthReq, sizeof(MLME_DEAUTH_REQ_STRUCT));
2093 MlmeDeauthReqAction(pAd, &MsgElem);
2096 LinkDown(pAd, FALSE);
2097 pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
2100 #endif // IW_MLME_DEAUTH //
2101 #ifdef IW_MLME_DISASSOC
2102 case IW_MLME_DISASSOC:
2103 DBGPRINT(RT_DEBUG_TRACE, ("====> %s - IW_MLME_DISASSOC\n", __func__));
2104 COPY_MAC_ADDR(DisAssocReq.Addr, pAd->CommonCfg.Bssid);
2105 DisAssocReq.Reason = pMlme->reason_code;
2107 MsgElem.Machine = ASSOC_STATE_MACHINE;
2108 MsgElem.MsgType = MT2_MLME_DISASSOC_REQ;
2109 MsgElem.MsgLen = sizeof(MLME_DISASSOC_REQ_STRUCT);
2110 NdisMoveMemory(MsgElem.Msg, &DisAssocReq, sizeof(MLME_DISASSOC_REQ_STRUCT));
2112 pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_OID_DISASSOC;
2113 MlmeDisassocReqAction(pAd, &MsgElem);
2115 #endif // IW_MLME_DISASSOC //
2117 DBGPRINT(RT_DEBUG_TRACE, ("====> %s - Unknow Command\n", __func__));
2123 #endif // SIOCSIWMLME //
2125 #if WIRELESS_EXT > 17
2126 int rt_ioctl_siwauth(struct net_device *dev,
2127 struct iw_request_info *info,
2128 union iwreq_data *wrqu, char *extra)
2130 PRTMP_ADAPTER pAdapter = dev->ml_priv;
2131 struct iw_param *param = &wrqu->param;
2133 //check if the interface is down
2134 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
2136 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
2139 switch (param->flags & IW_AUTH_INDEX) {
2140 case IW_AUTH_WPA_VERSION:
2141 if (param->value == IW_AUTH_WPA_VERSION_WPA)
2143 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPAPSK;
2144 if (pAdapter->StaCfg.BssType == BSS_ADHOC)
2145 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPANone;
2147 else if (param->value == IW_AUTH_WPA_VERSION_WPA2)
2148 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA2PSK;
2150 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_WPA_VERSION - param->value = %d!\n", __func__, param->value));
2152 case IW_AUTH_CIPHER_PAIRWISE:
2153 if (param->value == IW_AUTH_CIPHER_NONE)
2155 pAdapter->StaCfg.WepStatus = Ndis802_11WEPDisabled;
2156 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
2157 pAdapter->StaCfg.PairCipher = Ndis802_11WEPDisabled;
2159 else if (param->value == IW_AUTH_CIPHER_WEP40 ||
2160 param->value == IW_AUTH_CIPHER_WEP104)
2162 pAdapter->StaCfg.WepStatus = Ndis802_11WEPEnabled;
2163 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
2164 pAdapter->StaCfg.PairCipher = Ndis802_11WEPEnabled;
2165 #ifdef WPA_SUPPLICANT_SUPPORT
2166 pAdapter->StaCfg.IEEE8021X = FALSE;
2167 #endif // WPA_SUPPLICANT_SUPPORT //
2169 else if (param->value == IW_AUTH_CIPHER_TKIP)
2171 pAdapter->StaCfg.WepStatus = Ndis802_11Encryption2Enabled;
2172 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
2173 pAdapter->StaCfg.PairCipher = Ndis802_11Encryption2Enabled;
2175 else if (param->value == IW_AUTH_CIPHER_CCMP)
2177 pAdapter->StaCfg.WepStatus = Ndis802_11Encryption3Enabled;
2178 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
2179 pAdapter->StaCfg.PairCipher = Ndis802_11Encryption3Enabled;
2181 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_CIPHER_PAIRWISE - param->value = %d!\n", __func__, param->value));
2183 case IW_AUTH_CIPHER_GROUP:
2184 if (param->value == IW_AUTH_CIPHER_NONE)
2186 pAdapter->StaCfg.GroupCipher = Ndis802_11WEPDisabled;
2188 else if (param->value == IW_AUTH_CIPHER_WEP40 ||
2189 param->value == IW_AUTH_CIPHER_WEP104)
2191 pAdapter->StaCfg.GroupCipher = Ndis802_11WEPEnabled;
2193 else if (param->value == IW_AUTH_CIPHER_TKIP)
2195 pAdapter->StaCfg.GroupCipher = Ndis802_11Encryption2Enabled;
2197 else if (param->value == IW_AUTH_CIPHER_CCMP)
2199 pAdapter->StaCfg.GroupCipher = Ndis802_11Encryption3Enabled;
2201 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_CIPHER_GROUP - param->value = %d!\n", __func__, param->value));
2203 case IW_AUTH_KEY_MGMT:
2204 if (param->value == IW_AUTH_KEY_MGMT_802_1X)
2206 if (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK)
2208 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA;
2209 #ifdef WPA_SUPPLICANT_SUPPORT
2210 pAdapter->StaCfg.IEEE8021X = FALSE;
2211 #endif // WPA_SUPPLICANT_SUPPORT //
2213 else if (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK)
2215 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA2;
2216 #ifdef WPA_SUPPLICANT_SUPPORT
2217 pAdapter->StaCfg.IEEE8021X = FALSE;
2218 #endif // WPA_SUPPLICANT_SUPPORT //
2220 #ifdef WPA_SUPPLICANT_SUPPORT
2223 pAdapter->StaCfg.IEEE8021X = TRUE;
2224 #endif // WPA_SUPPLICANT_SUPPORT //
2226 else if (param->value == 0)
2228 //pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
2229 STA_PORT_SECURED(pAdapter);
2231 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_KEY_MGMT - param->value = %d!\n", __func__, param->value));
2233 case IW_AUTH_RX_UNENCRYPTED_EAPOL:
2235 case IW_AUTH_PRIVACY_INVOKED:
2236 /*if (param->value == 0)
2238 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
2239 pAdapter->StaCfg.WepStatus = Ndis802_11WEPDisabled;
2240 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
2241 pAdapter->StaCfg.PairCipher = Ndis802_11WEPDisabled;
2242 pAdapter->StaCfg.GroupCipher = Ndis802_11WEPDisabled;
2244 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_PRIVACY_INVOKED - param->value = %d!\n", __func__, param->value));
2246 case IW_AUTH_DROP_UNENCRYPTED:
2247 if (param->value != 0)
2248 pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED;
2251 //pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
2252 STA_PORT_SECURED(pAdapter);
2254 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_WPA_VERSION - param->value = %d!\n", __func__, param->value));
2256 case IW_AUTH_80211_AUTH_ALG:
2257 if (param->value & IW_AUTH_ALG_SHARED_KEY)
2259 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeShared;
2261 else if (param->value & IW_AUTH_ALG_OPEN_SYSTEM)
2263 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
2267 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_80211_AUTH_ALG - param->value = %d!\n", __func__, param->value));
2269 case IW_AUTH_WPA_ENABLED:
2270 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_WPA_ENABLED - Driver supports WPA!(param->value = %d)\n", __func__, param->value));
2279 int rt_ioctl_giwauth(struct net_device *dev,
2280 struct iw_request_info *info,
2281 union iwreq_data *wrqu, char *extra)
2283 PRTMP_ADAPTER pAdapter = dev->ml_priv;
2284 struct iw_param *param = &wrqu->param;
2286 //check if the interface is down
2287 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
2289 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
2293 switch (param->flags & IW_AUTH_INDEX) {
2294 case IW_AUTH_DROP_UNENCRYPTED:
2295 param->value = (pAdapter->StaCfg.WepStatus == Ndis802_11WEPDisabled) ? 0 : 1;
2298 case IW_AUTH_80211_AUTH_ALG:
2299 param->value = (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeShared) ? IW_AUTH_ALG_SHARED_KEY : IW_AUTH_ALG_OPEN_SYSTEM;
2302 case IW_AUTH_WPA_ENABLED:
2303 param->value = (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA) ? 1 : 0;
2309 DBGPRINT(RT_DEBUG_TRACE, ("rt_ioctl_giwauth::param->value = %d!\n", param->value));
2313 void fnSetCipherKey(
2314 IN PRTMP_ADAPTER pAdapter,
2318 IN struct iw_encode_ext *ext)
2320 NdisZeroMemory(&pAdapter->SharedKey[BSS0][keyIdx], sizeof(CIPHER_KEY));
2321 pAdapter->SharedKey[BSS0][keyIdx].KeyLen = LEN_TKIP_EK;
2322 NdisMoveMemory(pAdapter->SharedKey[BSS0][keyIdx].Key, ext->key, LEN_TKIP_EK);
2323 NdisMoveMemory(pAdapter->SharedKey[BSS0][keyIdx].TxMic, ext->key + LEN_TKIP_EK, LEN_TKIP_TXMICK);
2324 NdisMoveMemory(pAdapter->SharedKey[BSS0][keyIdx].RxMic, ext->key + LEN_TKIP_EK + LEN_TKIP_TXMICK, LEN_TKIP_RXMICK);
2325 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CipherAlg;
2327 // Update group key information to ASIC Shared Key Table
2328 AsicAddSharedKeyEntry(pAdapter,
2331 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg,
2332 pAdapter->SharedKey[BSS0][keyIdx].Key,
2333 pAdapter->SharedKey[BSS0][keyIdx].TxMic,
2334 pAdapter->SharedKey[BSS0][keyIdx].RxMic);
2337 // Update ASIC WCID attribute table and IVEIV table
2338 RTMPAddWcidAttributeEntry(pAdapter,
2341 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg,
2344 // Update ASIC WCID attribute table and IVEIV table
2345 RTMPAddWcidAttributeEntry(pAdapter,
2348 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg,
2349 &pAdapter->MacTab.Content[BSSID_WCID]);
2352 int rt_ioctl_siwencodeext(struct net_device *dev,
2353 struct iw_request_info *info,
2354 union iwreq_data *wrqu,
2357 PRTMP_ADAPTER pAdapter = dev->ml_priv;
2358 struct iw_point *encoding = &wrqu->encoding;
2359 struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
2360 int keyIdx, alg = ext->alg;
2362 //check if the interface is down
2363 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
2365 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
2369 if (encoding->flags & IW_ENCODE_DISABLED)
2371 keyIdx = (encoding->flags & IW_ENCODE_INDEX) - 1;
2372 // set BSSID wcid entry of the Pair-wise Key table as no-security mode
2373 AsicRemovePairwiseKeyEntry(pAdapter, BSS0, BSSID_WCID);
2374 pAdapter->SharedKey[BSS0][keyIdx].KeyLen = 0;
2375 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CIPHER_NONE;
2376 AsicRemoveSharedKeyEntry(pAdapter, 0, (UCHAR)keyIdx);
2377 NdisZeroMemory(&pAdapter->SharedKey[BSS0][keyIdx], sizeof(CIPHER_KEY));
2378 DBGPRINT(RT_DEBUG_TRACE, ("%s::Remove all keys!(encoding->flags = %x)\n", __func__, encoding->flags));
2382 // Get Key Index and convet to our own defined key index
2383 keyIdx = (encoding->flags & IW_ENCODE_INDEX) - 1;
2384 if((keyIdx < 0) || (keyIdx >= NR_WEP_KEYS))
2387 if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
2389 pAdapter->StaCfg.DefaultKeyId = keyIdx;
2390 DBGPRINT(RT_DEBUG_TRACE, ("%s::DefaultKeyId = %d\n", __func__, pAdapter->StaCfg.DefaultKeyId));
2394 case IW_ENCODE_ALG_NONE:
2395 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_ENCODE_ALG_NONE\n", __func__));
2397 case IW_ENCODE_ALG_WEP:
2398 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_ENCODE_ALG_WEP - ext->key_len = %d, keyIdx = %d\n", __func__, ext->key_len, keyIdx));
2399 if (ext->key_len == MAX_WEP_KEY_SIZE)
2401 pAdapter->SharedKey[BSS0][keyIdx].KeyLen = MAX_WEP_KEY_SIZE;
2402 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CIPHER_WEP128;
2404 else if (ext->key_len == MIN_WEP_KEY_SIZE)
2406 pAdapter->SharedKey[BSS0][keyIdx].KeyLen = MIN_WEP_KEY_SIZE;
2407 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CIPHER_WEP64;
2412 NdisZeroMemory(pAdapter->SharedKey[BSS0][keyIdx].Key, 16);
2413 NdisMoveMemory(pAdapter->SharedKey[BSS0][keyIdx].Key, ext->key, ext->key_len);
2415 case IW_ENCODE_ALG_TKIP:
2416 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_ENCODE_ALG_TKIP - keyIdx = %d, ext->key_len = %d\n", __func__, keyIdx, ext->key_len));
2417 if (ext->key_len == 32)
2419 if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
2421 fnSetCipherKey(pAdapter, keyIdx, CIPHER_TKIP, FALSE, ext);
2422 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA2)
2424 //pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
2425 STA_PORT_SECURED(pAdapter);
2428 else if (ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY)
2430 fnSetCipherKey(pAdapter, keyIdx, CIPHER_TKIP, TRUE, ext);
2432 // set 802.1x port control
2433 //pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
2434 STA_PORT_SECURED(pAdapter);
2440 case IW_ENCODE_ALG_CCMP:
2441 if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
2443 fnSetCipherKey(pAdapter, keyIdx, CIPHER_AES, FALSE, ext);
2444 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA2)
2445 //pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
2446 STA_PORT_SECURED(pAdapter);
2448 else if (ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY)
2450 fnSetCipherKey(pAdapter, keyIdx, CIPHER_AES, TRUE, ext);
2452 // set 802.1x port control
2453 //pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
2454 STA_PORT_SECURED(pAdapter);
2466 rt_ioctl_giwencodeext(struct net_device *dev,
2467 struct iw_request_info *info,
2468 union iwreq_data *wrqu, char *extra)
2470 PRTMP_ADAPTER pAd = dev->ml_priv;
2472 struct iw_point *encoding = &wrqu->encoding;
2473 struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
2474 int idx, max_key_len;
2476 DBGPRINT(RT_DEBUG_TRACE ,("===> rt_ioctl_giwencodeext\n"));
2478 max_key_len = encoding->length - sizeof(*ext);
2479 if (max_key_len < 0)
2482 idx = encoding->flags & IW_ENCODE_INDEX;
2485 if (idx < 1 || idx > 4)
2489 if ((pAd->StaCfg.WepStatus == Ndis802_11Encryption2Enabled) ||
2490 (pAd->StaCfg.WepStatus == Ndis802_11Encryption3Enabled))
2492 if (idx != pAd->StaCfg.DefaultKeyId)
2500 idx = pAd->StaCfg.DefaultKeyId;
2502 encoding->flags = idx + 1;
2503 memset(ext, 0, sizeof(*ext));
2506 switch(pAd->StaCfg.WepStatus) {
2507 case Ndis802_11WEPDisabled:
2508 ext->alg = IW_ENCODE_ALG_NONE;
2509 encoding->flags |= IW_ENCODE_DISABLED;
2511 case Ndis802_11WEPEnabled:
2512 ext->alg = IW_ENCODE_ALG_WEP;
2513 if (pAd->SharedKey[BSS0][idx].KeyLen > max_key_len)
2517 ext->key_len = pAd->SharedKey[BSS0][idx].KeyLen;
2518 pKey = &(pAd->SharedKey[BSS0][idx].Key[0]);
2521 case Ndis802_11Encryption2Enabled:
2522 case Ndis802_11Encryption3Enabled:
2523 if (pAd->StaCfg.WepStatus == Ndis802_11Encryption2Enabled)
2524 ext->alg = IW_ENCODE_ALG_TKIP;
2526 ext->alg = IW_ENCODE_ALG_CCMP;
2528 if (max_key_len < 32)
2533 pKey = &pAd->StaCfg.PMK[0];
2540 if (ext->key_len && pKey)
2542 encoding->flags |= IW_ENCODE_ENABLED;
2543 memcpy(ext->key, pKey, ext->key_len);
2550 int rt_ioctl_siwgenie(struct net_device *dev,
2551 struct iw_request_info *info,
2552 union iwreq_data *wrqu, char *extra)
2554 PRTMP_ADAPTER pAd = dev->ml_priv;
2556 if (wrqu->data.length > MAX_LEN_OF_RSNIE ||
2557 (wrqu->data.length && extra == NULL))
2560 if (wrqu->data.length)
2562 pAd->StaCfg.RSNIE_Len = wrqu->data.length;
2563 NdisMoveMemory(&pAd->StaCfg.RSN_IE[0], extra, pAd->StaCfg.RSNIE_Len);
2567 pAd->StaCfg.RSNIE_Len = 0;
2568 NdisZeroMemory(&pAd->StaCfg.RSN_IE[0], MAX_LEN_OF_RSNIE);
2573 #endif // SIOCSIWGENIE //
2575 int rt_ioctl_giwgenie(struct net_device *dev,
2576 struct iw_request_info *info,
2577 union iwreq_data *wrqu, char *extra)
2579 PRTMP_ADAPTER pAd = dev->ml_priv;
2581 if ((pAd->StaCfg.RSNIE_Len == 0) ||
2582 (pAd->StaCfg.AuthMode < Ndis802_11AuthModeWPA))
2584 wrqu->data.length = 0;
2588 #ifdef NATIVE_WPA_SUPPLICANT_SUPPORT
2590 if (pAd->StaCfg.WpaSupplicantUP == WPA_SUPPLICANT_ENABLE)
2592 if (wrqu->data.length < pAd->StaCfg.RSNIE_Len)
2595 wrqu->data.length = pAd->StaCfg.RSNIE_Len;
2596 memcpy(extra, &pAd->StaCfg.RSN_IE[0], pAd->StaCfg.RSNIE_Len);
2599 #endif // SIOCSIWGENIE //
2600 #endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
2602 UCHAR RSNIe = IE_WPA;
2604 if (wrqu->data.length < (pAd->StaCfg.RSNIE_Len + 2)) // ID, Len
2606 wrqu->data.length = pAd->StaCfg.RSNIE_Len + 2;
2608 if ((pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK) ||
2609 (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2))
2612 extra[0] = (char)RSNIe;
2613 extra[1] = pAd->StaCfg.RSNIE_Len;
2614 memcpy(extra+2, &pAd->StaCfg.RSN_IE[0], pAd->StaCfg.RSNIE_Len);
2620 int rt_ioctl_siwpmksa(struct net_device *dev,
2621 struct iw_request_info *info,
2622 union iwreq_data *wrqu,
2625 PRTMP_ADAPTER pAd = dev->ml_priv;
2626 struct iw_pmksa *pPmksa = (struct iw_pmksa *)wrqu->data.pointer;
2627 INT CachedIdx = 0, idx = 0;
2632 DBGPRINT(RT_DEBUG_TRACE ,("===> rt_ioctl_siwpmksa\n"));
2635 case IW_PMKSA_FLUSH:
2636 NdisZeroMemory(pAd->StaCfg.SavedPMK, sizeof(BSSID_INFO)*PMKID_NO);
2637 DBGPRINT(RT_DEBUG_TRACE ,("rt_ioctl_siwpmksa - IW_PMKSA_FLUSH\n"));
2639 case IW_PMKSA_REMOVE:
2640 for (CachedIdx = 0; CachedIdx < pAd->StaCfg.SavedPMKNum; CachedIdx++)
2642 // compare the BSSID
2643 if (NdisEqualMemory(pPmksa->bssid.sa_data, pAd->StaCfg.SavedPMK[CachedIdx].BSSID, MAC_ADDR_LEN))
2645 NdisZeroMemory(pAd->StaCfg.SavedPMK[CachedIdx].BSSID, MAC_ADDR_LEN);
2646 NdisZeroMemory(pAd->StaCfg.SavedPMK[CachedIdx].PMKID, 16);
2647 for (idx = CachedIdx; idx < (pAd->StaCfg.SavedPMKNum - 1); idx++)
2649 NdisMoveMemory(&pAd->StaCfg.SavedPMK[idx].BSSID[0], &pAd->StaCfg.SavedPMK[idx+1].BSSID[0], MAC_ADDR_LEN);
2650 NdisMoveMemory(&pAd->StaCfg.SavedPMK[idx].PMKID[0], &pAd->StaCfg.SavedPMK[idx+1].PMKID[0], 16);
2652 pAd->StaCfg.SavedPMKNum--;
2657 DBGPRINT(RT_DEBUG_TRACE ,("rt_ioctl_siwpmksa - IW_PMKSA_REMOVE\n"));
2660 for (CachedIdx = 0; CachedIdx < pAd->StaCfg.SavedPMKNum; CachedIdx++)
2662 // compare the BSSID
2663 if (NdisEqualMemory(pPmksa->bssid.sa_data, pAd->StaCfg.SavedPMK[CachedIdx].BSSID, MAC_ADDR_LEN))
2667 // Found, replace it
2668 if (CachedIdx < PMKID_NO)
2670 DBGPRINT(RT_DEBUG_OFF, ("Update PMKID, idx = %d\n", CachedIdx));
2671 NdisMoveMemory(&pAd->StaCfg.SavedPMK[CachedIdx].BSSID[0], pPmksa->bssid.sa_data, MAC_ADDR_LEN);
2672 NdisMoveMemory(&pAd->StaCfg.SavedPMK[CachedIdx].PMKID[0], pPmksa->pmkid, 16);
2673 pAd->StaCfg.SavedPMKNum++;
2675 // Not found, replace the last one
2678 // Randomly replace one
2679 CachedIdx = (pPmksa->bssid.sa_data[5] % PMKID_NO);
2680 DBGPRINT(RT_DEBUG_OFF, ("Update PMKID, idx = %d\n", CachedIdx));
2681 NdisMoveMemory(&pAd->StaCfg.SavedPMK[CachedIdx].BSSID[0], pPmksa->bssid.sa_data, MAC_ADDR_LEN);
2682 NdisMoveMemory(&pAd->StaCfg.SavedPMK[CachedIdx].PMKID[0], pPmksa->pmkid, 16);
2685 DBGPRINT(RT_DEBUG_TRACE ,("rt_ioctl_siwpmksa - IW_PMKSA_ADD\n"));
2688 DBGPRINT(RT_DEBUG_TRACE ,("rt_ioctl_siwpmksa - Unknow Command!!\n"));
2694 #endif // #if WIRELESS_EXT > 17
2698 rt_private_ioctl_bbp(struct net_device *dev, struct iw_request_info *info,
2699 struct iw_point *wrq, char *extra)
2704 // CHAR arg[255]={0};
2707 BOOLEAN bIsPrintAllBBP = FALSE;
2709 PRTMP_ADAPTER pAdapter = dev->ml_priv;
2712 memset(extra, 0x00, IW_PRIV_SIZE_MASK);
2714 if (wrq->length > 1) //No parameters.
2716 sprintf(extra, "\n");
2718 //Parsing Read or Write
2719 this_char = wrq->pointer;
2720 DBGPRINT(RT_DEBUG_TRACE, ("this_char=%s\n", this_char));
2724 if ((value = rtstrchr(this_char, '=')) != NULL)
2727 if (!value || !*value)
2729 DBGPRINT(RT_DEBUG_TRACE, ("this_char=%s, value=%s\n", this_char, value));
2730 if (sscanf(this_char, "%d", &(bbpId)) == 1)
2736 if (bbpId <= 138) // edit by johnli, RF power sequence setup, add BBP R138 for ADC dynamic on/off control
2740 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, ®BBP);
2742 sprintf(extra+strlen(extra), "R%02d[0x%02X]:%02X\n", bbpId, bbpId*2, regBBP);
2743 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2744 DBGPRINT(RT_DEBUG_TRACE, ("msg=%s\n", extra));
2747 {//Invalid parametes, so default printk all bbp
2748 bIsPrintAllBBP = TRUE;
2753 { //Invalid parametes, so default printk all bbp
2754 bIsPrintAllBBP = TRUE;
2760 if ((sscanf(this_char, "%d", &(bbpId)) == 1) && (sscanf(value, "%x", &(bbpValue)) == 1))
2766 if (bbpId <= 138) // edit by johnli, RF power sequence setup, add BBP R138 for ADC dynamic on/off control
2770 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, bbpId, bbpValue);
2771 //Read it back for showing
2772 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, ®BBP);
2774 sprintf(extra+strlen(extra), "R%02d[0x%02X]:%02X\n", bbpId, bbpId*2, regBBP);
2775 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2776 DBGPRINT(RT_DEBUG_TRACE, ("msg=%s\n", extra));
2779 {//Invalid parametes, so default printk all bbp
2780 bIsPrintAllBBP = TRUE;
2785 { //Invalid parametes, so default printk all bbp
2786 bIsPrintAllBBP = TRUE;
2792 bIsPrintAllBBP = TRUE;
2797 memset(extra, 0x00, IW_PRIV_SIZE_MASK);
2798 sprintf(extra, "\n");
2800 for (bbpId = 0; bbpId <= 136; bbpId++)
2803 for (bbpId = 0; bbpId <= 138; bbpId++) // edit by johnli, RF power sequence setup, add BBP R138 for ADC dynamic on/off control
2806 if (strlen(extra) >= (IW_PRIV_SIZE_MASK - 10))
2808 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, ®BBP);
2810 sprintf(extra+strlen(extra), "R%02d[0x%02X]:%02X ", bbpId, bbpId*2, regBBP);
2812 sprintf(extra+strlen(extra), "\n");
2814 sprintf(extra+strlen(extra), "%03d = %02X\n", bbpId, regBBP); // edit by johnli, change display format
2817 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2818 DBGPRINT(RT_DEBUG_TRACE, ("wrq->length = %d\n", wrq->length));
2821 DBGPRINT(RT_DEBUG_TRACE, ("<==rt_private_ioctl_bbp\n\n"));
2827 int rt_ioctl_siwrate(struct net_device *dev,
2828 struct iw_request_info *info,
2829 union iwreq_data *wrqu, char *extra)
2831 PRTMP_ADAPTER pAd = dev->ml_priv;
2832 UINT32 rate = wrqu->bitrate.value, fixed = wrqu->bitrate.fixed;
2834 //check if the interface is down
2835 if(!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_IN_USE))
2837 DBGPRINT(RT_DEBUG_TRACE, ("rt_ioctl_siwrate::Network is down!\n"));
2841 DBGPRINT(RT_DEBUG_TRACE, ("rt_ioctl_siwrate::(rate = %d, fixed = %d)\n", rate, fixed));
2842 /* rate = -1 => auto rate
2843 rate = X, fixed = 1 => (fixed rate X)
2848 pAd->StaCfg.DesiredTransmitSetting.field.MCS = MCS_AUTO;
2849 pAd->StaCfg.bAutoTxRateSwitch = TRUE;
2850 if ((pAd->CommonCfg.PhyMode <= PHY_11G) ||
2851 (pAd->MacTab.Content[BSSID_WCID].HTPhyMode.field.MODE <= MODE_OFDM))
2852 RTMPSetDesiredRates(pAd, -1);
2854 #ifdef DOT11_N_SUPPORT
2856 #endif // DOT11_N_SUPPORT //
2862 pAd->StaCfg.bAutoTxRateSwitch = FALSE;
2863 if ((pAd->CommonCfg.PhyMode <= PHY_11G) ||
2864 (pAd->MacTab.Content[BSSID_WCID].HTPhyMode.field.MODE <= MODE_OFDM))
2865 RTMPSetDesiredRates(pAd, rate);
2868 pAd->StaCfg.DesiredTransmitSetting.field.MCS = MCS_AUTO;
2869 #ifdef DOT11_N_SUPPORT
2871 #endif // DOT11_N_SUPPORT //
2873 DBGPRINT(RT_DEBUG_TRACE, ("rt_ioctl_siwrate::(HtMcs=%d)\n",pAd->StaCfg.DesiredTransmitSetting.field.MCS));
2877 // TODO: rate = X, fixed = 0 => (rates <= X)
2885 int rt_ioctl_giwrate(struct net_device *dev,
2886 struct iw_request_info *info,
2887 union iwreq_data *wrqu, char *extra)
2889 PRTMP_ADAPTER pAd = dev->ml_priv;
2890 int rate_index = 0, rate_count = 0;
2891 HTTRANSMIT_SETTING ht_setting;
2892 __s32 ralinkrate[] =
2893 {2, 4, 11, 22, // CCK
2894 12, 18, 24, 36, 48, 72, 96, 108, // OFDM
2895 13, 26, 39, 52, 78, 104, 117, 130, 26, 52, 78, 104, 156, 208, 234, 260, // 20MHz, 800ns GI, MCS: 0 ~ 15
2896 39, 78, 117, 156, 234, 312, 351, 390, // 20MHz, 800ns GI, MCS: 16 ~ 23
2897 27, 54, 81, 108, 162, 216, 243, 270, 54, 108, 162, 216, 324, 432, 486, 540, // 40MHz, 800ns GI, MCS: 0 ~ 15
2898 81, 162, 243, 324, 486, 648, 729, 810, // 40MHz, 800ns GI, MCS: 16 ~ 23
2899 14, 29, 43, 57, 87, 115, 130, 144, 29, 59, 87, 115, 173, 230, 260, 288, // 20MHz, 400ns GI, MCS: 0 ~ 15
2900 43, 87, 130, 173, 260, 317, 390, 433, // 20MHz, 400ns GI, MCS: 16 ~ 23
2901 30, 60, 90, 120, 180, 240, 270, 300, 60, 120, 180, 240, 360, 480, 540, 600, // 40MHz, 400ns GI, MCS: 0 ~ 15
2902 90, 180, 270, 360, 540, 720, 810, 900}; // 40MHz, 400ns GI, MCS: 16 ~ 23
2904 rate_count = sizeof(ralinkrate)/sizeof(__s32);
2905 //check if the interface is down
2906 if(!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_IN_USE))
2908 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
2912 if ((pAd->StaCfg.bAutoTxRateSwitch == FALSE) &&
2914 ((pAd->CommonCfg.PhyMode <= PHY_11G) || (pAd->MacTab.Content[BSSID_WCID].HTPhyMode.field.MODE <= MODE_OFDM)))
2915 ht_setting.word = pAd->StaCfg.HTPhyMode.word;
2917 ht_setting.word = pAd->MacTab.Content[BSSID_WCID].HTPhyMode.word;
2919 #ifdef DOT11_N_SUPPORT
2920 if (ht_setting.field.MODE >= MODE_HTMIX)
2922 // rate_index = 12 + ((UCHAR)ht_setting.field.BW *16) + ((UCHAR)ht_setting.field.ShortGI *32) + ((UCHAR)ht_setting.field.MCS);
2923 rate_index = 12 + ((UCHAR)ht_setting.field.BW *24) + ((UCHAR)ht_setting.field.ShortGI *48) + ((UCHAR)ht_setting.field.MCS);
2926 #endif // DOT11_N_SUPPORT //
2927 if (ht_setting.field.MODE == MODE_OFDM)
2928 rate_index = (UCHAR)(ht_setting.field.MCS) + 4;
2929 else if (ht_setting.field.MODE == MODE_CCK)
2930 rate_index = (UCHAR)(ht_setting.field.MCS);
2935 if (rate_index > rate_count)
2936 rate_index = rate_count;
2938 wrqu->bitrate.value = ralinkrate[rate_index] * 500000;
2939 wrqu->bitrate.disabled = 0;
2944 static const iw_handler rt_handler[] =
2946 (iw_handler) NULL, /* SIOCSIWCOMMIT */
2947 (iw_handler) rt_ioctl_giwname, /* SIOCGIWNAME */
2948 (iw_handler) NULL, /* SIOCSIWNWID */
2949 (iw_handler) NULL, /* SIOCGIWNWID */
2950 (iw_handler) rt_ioctl_siwfreq, /* SIOCSIWFREQ */
2951 (iw_handler) rt_ioctl_giwfreq, /* SIOCGIWFREQ */
2952 (iw_handler) rt_ioctl_siwmode, /* SIOCSIWMODE */
2953 (iw_handler) rt_ioctl_giwmode, /* SIOCGIWMODE */
2954 (iw_handler) NULL, /* SIOCSIWSENS */
2955 (iw_handler) NULL, /* SIOCGIWSENS */
2956 (iw_handler) NULL /* not used */, /* SIOCSIWRANGE */
2957 (iw_handler) rt_ioctl_giwrange, /* SIOCGIWRANGE */
2958 (iw_handler) NULL /* not used */, /* SIOCSIWPRIV */
2959 (iw_handler) NULL /* kernel code */, /* SIOCGIWPRIV */
2960 (iw_handler) NULL /* not used */, /* SIOCSIWSTATS */
2961 (iw_handler) rt28xx_get_wireless_stats /* kernel code */, /* SIOCGIWSTATS */
2962 (iw_handler) NULL, /* SIOCSIWSPY */
2963 (iw_handler) NULL, /* SIOCGIWSPY */
2964 (iw_handler) NULL, /* SIOCSIWTHRSPY */
2965 (iw_handler) NULL, /* SIOCGIWTHRSPY */
2966 (iw_handler) rt_ioctl_siwap, /* SIOCSIWAP */
2967 (iw_handler) rt_ioctl_giwap, /* SIOCGIWAP */
2969 (iw_handler) rt_ioctl_siwmlme, /* SIOCSIWMLME */
2971 (iw_handler) NULL, /* SIOCSIWMLME */
2972 #endif // SIOCSIWMLME //
2973 (iw_handler) rt_ioctl_iwaplist, /* SIOCGIWAPLIST */
2975 (iw_handler) rt_ioctl_siwscan, /* SIOCSIWSCAN */
2976 (iw_handler) rt_ioctl_giwscan, /* SIOCGIWSCAN */
2978 (iw_handler) NULL, /* SIOCSIWSCAN */
2979 (iw_handler) NULL, /* SIOCGIWSCAN */
2980 #endif /* SIOCGIWSCAN */
2981 (iw_handler) rt_ioctl_siwessid, /* SIOCSIWESSID */
2982 (iw_handler) rt_ioctl_giwessid, /* SIOCGIWESSID */
2983 (iw_handler) rt_ioctl_siwnickn, /* SIOCSIWNICKN */
2984 (iw_handler) rt_ioctl_giwnickn, /* SIOCGIWNICKN */
2985 (iw_handler) NULL, /* -- hole -- */
2986 (iw_handler) NULL, /* -- hole -- */
2987 (iw_handler) rt_ioctl_siwrate, /* SIOCSIWRATE */
2988 (iw_handler) rt_ioctl_giwrate, /* SIOCGIWRATE */
2989 (iw_handler) rt_ioctl_siwrts, /* SIOCSIWRTS */
2990 (iw_handler) rt_ioctl_giwrts, /* SIOCGIWRTS */
2991 (iw_handler) rt_ioctl_siwfrag, /* SIOCSIWFRAG */
2992 (iw_handler) rt_ioctl_giwfrag, /* SIOCGIWFRAG */
2993 (iw_handler) NULL, /* SIOCSIWTXPOW */
2994 (iw_handler) NULL, /* SIOCGIWTXPOW */
2995 (iw_handler) NULL, /* SIOCSIWRETRY */
2996 (iw_handler) NULL, /* SIOCGIWRETRY */
2997 (iw_handler) rt_ioctl_siwencode, /* SIOCSIWENCODE */
2998 (iw_handler) rt_ioctl_giwencode, /* SIOCGIWENCODE */
2999 (iw_handler) NULL, /* SIOCSIWPOWER */
3000 (iw_handler) NULL, /* SIOCGIWPOWER */
3001 (iw_handler) NULL, /* -- hole -- */
3002 (iw_handler) NULL, /* -- hole -- */
3003 #if WIRELESS_EXT > 17
3004 (iw_handler) rt_ioctl_siwgenie, /* SIOCSIWGENIE */
3005 (iw_handler) rt_ioctl_giwgenie, /* SIOCGIWGENIE */
3006 (iw_handler) rt_ioctl_siwauth, /* SIOCSIWAUTH */
3007 (iw_handler) rt_ioctl_giwauth, /* SIOCGIWAUTH */
3008 (iw_handler) rt_ioctl_siwencodeext, /* SIOCSIWENCODEEXT */
3009 (iw_handler) rt_ioctl_giwencodeext, /* SIOCGIWENCODEEXT */
3010 (iw_handler) rt_ioctl_siwpmksa, /* SIOCSIWPMKSA */
3014 static const iw_handler rt_priv_handlers[] = {
3015 (iw_handler) NULL, /* + 0x00 */
3016 (iw_handler) NULL, /* + 0x01 */
3017 #ifndef CONFIG_AP_SUPPORT
3018 (iw_handler) rt_ioctl_setparam, /* + 0x02 */
3020 (iw_handler) NULL, /* + 0x02 */
3021 #endif // CONFIG_AP_SUPPORT //
3023 (iw_handler) rt_private_ioctl_bbp, /* + 0x03 */
3025 (iw_handler) NULL, /* + 0x03 */
3027 (iw_handler) NULL, /* + 0x04 */
3028 (iw_handler) NULL, /* + 0x05 */
3029 (iw_handler) NULL, /* + 0x06 */
3030 (iw_handler) NULL, /* + 0x07 */
3031 (iw_handler) NULL, /* + 0x08 */
3032 (iw_handler) rt_private_get_statistics, /* + 0x09 */
3033 (iw_handler) NULL, /* + 0x0A */
3034 (iw_handler) NULL, /* + 0x0B */
3035 (iw_handler) NULL, /* + 0x0C */
3036 (iw_handler) NULL, /* + 0x0D */
3037 (iw_handler) NULL, /* + 0x0E */
3038 (iw_handler) NULL, /* + 0x0F */
3039 (iw_handler) NULL, /* + 0x10 */
3040 (iw_handler) rt_private_show, /* + 0x11 */
3041 (iw_handler) NULL, /* + 0x12 */
3042 (iw_handler) NULL, /* + 0x13 */
3043 (iw_handler) NULL, /* + 0x15 */
3044 (iw_handler) NULL, /* + 0x17 */
3045 (iw_handler) NULL, /* + 0x18 */
3048 const struct iw_handler_def rt28xx_iw_handler_def =
3050 #define N(a) (sizeof (a) / sizeof (a[0]))
3051 .standard = (iw_handler *) rt_handler,
3052 .num_standard = sizeof(rt_handler) / sizeof(iw_handler),
3053 .private = (iw_handler *) rt_priv_handlers,
3054 .num_private = N(rt_priv_handlers),
3055 .private_args = (struct iw_priv_args *) privtab,
3056 .num_private_args = N(privtab),
3057 #if IW_HANDLER_VERSION >= 7
3058 .get_wireless_stats = rt28xx_get_wireless_stats,
3062 INT RTMPSetInformation(
3063 IN PRTMP_ADAPTER pAdapter,
3064 IN OUT struct ifreq *rq,
3067 struct iwreq *wrq = (struct iwreq *) rq;
3068 NDIS_802_11_SSID Ssid;
3069 NDIS_802_11_MAC_ADDRESS Bssid;
3070 RT_802_11_PHY_MODE PhyMode;
3071 RT_802_11_STA_CONFIG StaConfig;
3072 NDIS_802_11_RATES aryRates;
3073 RT_802_11_PREAMBLE Preamble;
3074 NDIS_802_11_WEP_STATUS WepStatus;
3075 NDIS_802_11_AUTHENTICATION_MODE AuthMode = Ndis802_11AuthModeMax;
3076 NDIS_802_11_NETWORK_INFRASTRUCTURE BssType;
3077 NDIS_802_11_RTS_THRESHOLD RtsThresh;
3078 NDIS_802_11_FRAGMENTATION_THRESHOLD FragThresh;
3079 NDIS_802_11_POWER_MODE PowerMode;
3080 PNDIS_802_11_KEY pKey = NULL;
3081 PNDIS_802_11_WEP pWepKey =NULL;
3082 PNDIS_802_11_REMOVE_KEY pRemoveKey = NULL;
3083 NDIS_802_11_CONFIGURATION Config, *pConfig = NULL;
3084 NDIS_802_11_NETWORK_TYPE NetType;
3087 INT Status = NDIS_STATUS_SUCCESS, MaxPhyMode = PHY_11G;
3090 BOOLEAN StateMachineTouched = FALSE;
3091 #ifdef DOT11_N_SUPPORT
3092 OID_SET_HT_PHYMODE HT_PhyMode; //11n ,kathy
3093 #endif // DOT11_N_SUPPORT //
3094 #ifdef WPA_SUPPLICANT_SUPPORT
3095 PNDIS_802_11_PMKID pPmkId = NULL;
3096 BOOLEAN IEEE8021xState = FALSE;
3097 BOOLEAN IEEE8021x_required_keys = FALSE;
3098 UCHAR wpa_supplicant_enable = 0;
3099 #endif // WPA_SUPPLICANT_SUPPORT //
3102 TX_RTY_CFG_STRUC tx_rty_cfg;
3103 ULONG ShortRetryLimit, LongRetryLimit;
3105 #endif // SNMP_SUPPORT //
3108 #ifdef DOT11_N_SUPPORT
3109 MaxPhyMode = PHY_11N_5G;
3110 #endif // DOT11_N_SUPPORT //
3113 DBGPRINT(RT_DEBUG_TRACE, ("-->RTMPSetInformation(), 0x%08x\n", cmd&0x7FFF));
3114 switch(cmd & 0x7FFF) {
3115 case RT_OID_802_11_COUNTRY_REGION:
3116 if (wrq->u.data.length < sizeof(UCHAR))
3118 // Only avaliable when EEPROM not programming
3119 else if (!(pAdapter->CommonCfg.CountryRegion & 0x80) && !(pAdapter->CommonCfg.CountryRegionForABand & 0x80))
3124 Status = copy_from_user(&Country, wrq->u.data.pointer, wrq->u.data.length);
3125 pAdapter->CommonCfg.CountryRegion = (UCHAR)(Country & 0x000000FF);
3126 pAdapter->CommonCfg.CountryRegionForABand = (UCHAR)((Country >> 8) & 0x000000FF);
3127 TmpPhy = pAdapter->CommonCfg.PhyMode;
3128 pAdapter->CommonCfg.PhyMode = 0xff;
3129 // Build all corresponding channel information
3130 RTMPSetPhyMode(pAdapter, TmpPhy);
3131 #ifdef DOT11_N_SUPPORT
3132 SetCommonHT(pAdapter);
3133 #endif // DOT11_N_SUPPORT //
3134 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_COUNTRY_REGION (A:%d B/G:%d)\n", pAdapter->CommonCfg.CountryRegionForABand,
3135 pAdapter->CommonCfg.CountryRegion));
3138 case OID_802_11_BSSID_LIST_SCAN:
3140 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_BSSID_LIST_SCAN, TxCnt = %d \n", pAdapter->RalinkCounters.LastOneSecTotalTxCount));
3142 if (MONITOR_ON(pAdapter))
3144 DBGPRINT(RT_DEBUG_TRACE, ("!!! Driver is in Monitor Mode now !!!\n"));
3148 //Benson add 20080527, when radio off, sta don't need to scan
3149 if (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_RADIO_OFF))
3152 if (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
3154 DBGPRINT(RT_DEBUG_TRACE, ("!!! Driver is scanning now !!!\n"));
3155 pAdapter->StaCfg.bScanReqIsFromWebUI = TRUE;
3156 Status = NDIS_STATUS_SUCCESS;
3160 if (pAdapter->RalinkCounters.LastOneSecTotalTxCount > 100)
3162 DBGPRINT(RT_DEBUG_TRACE, ("!!! Link UP, ignore this set::OID_802_11_BSSID_LIST_SCAN\n"));
3163 Status = NDIS_STATUS_SUCCESS;
3164 pAdapter->StaCfg.ScanCnt = 99; // Prevent auto scan triggered by this OID
3168 if ((OPSTATUS_TEST_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED)) &&
3169 ((pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA) ||
3170 (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK) ||
3171 (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA2) ||
3172 (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK)) &&
3173 (pAdapter->StaCfg.PortSecured == WPA_802_1X_PORT_NOT_SECURED))
3175 DBGPRINT(RT_DEBUG_TRACE, ("!!! Link UP, Port Not Secured! ignore this set::OID_802_11_BSSID_LIST_SCAN\n"));
3176 Status = NDIS_STATUS_SUCCESS;
3177 pAdapter->StaCfg.ScanCnt = 99; // Prevent auto scan triggered by this OID
3182 if (pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE)
3184 RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
3185 DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
3188 // tell CNTL state machine to call NdisMSetInformationComplete() after completing
3189 // this request, because this request is initiated by NDIS.
3190 pAdapter->MlmeAux.CurrReqIsFromNdis = FALSE;
3191 // Reset allowed scan retries
3192 pAdapter->StaCfg.ScanCnt = 0;
3193 pAdapter->StaCfg.LastScanTime = Now;
3195 pAdapter->StaCfg.bScanReqIsFromWebUI = TRUE;
3196 RTMP_SET_FLAG(pAdapter, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS);
3197 MlmeEnqueue(pAdapter,
3198 MLME_CNTL_STATE_MACHINE,
3199 OID_802_11_BSSID_LIST_SCAN,
3203 Status = NDIS_STATUS_SUCCESS;
3204 StateMachineTouched = TRUE;
3206 case OID_802_11_SSID:
3207 if (wrq->u.data.length != sizeof(NDIS_802_11_SSID))
3211 PCHAR pSsidString = NULL;
3212 Status = copy_from_user(&Ssid, wrq->u.data.pointer, wrq->u.data.length);
3214 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_SSID (Len=%d,Ssid=%s)\n", Ssid.SsidLength, Ssid.Ssid));
3215 if (Ssid.SsidLength > MAX_LEN_OF_SSID)
3219 if (Ssid.SsidLength == 0)
3221 Set_SSID_Proc(pAdapter, "");
3225 pSsidString = (CHAR *) kmalloc(MAX_LEN_OF_SSID+1, MEM_ALLOC_FLAG);
3228 NdisZeroMemory(pSsidString, MAX_LEN_OF_SSID+1);
3229 NdisMoveMemory(pSsidString, Ssid.Ssid, Ssid.SsidLength);
3230 Set_SSID_Proc(pAdapter, pSsidString);
3239 case OID_802_11_BSSID:
3240 if (wrq->u.data.length != sizeof(NDIS_802_11_MAC_ADDRESS))
3244 Status = copy_from_user(&Bssid, wrq->u.data.pointer, wrq->u.data.length);
3246 // tell CNTL state machine to call NdisMSetInformationComplete() after completing
3247 // this request, because this request is initiated by NDIS.
3248 pAdapter->MlmeAux.CurrReqIsFromNdis = FALSE;
3250 // Prevent to connect AP again in STAMlmePeriodicExec
3251 pAdapter->MlmeAux.AutoReconnectSsidLen= 32;
3253 // Reset allowed scan retries
3254 pAdapter->StaCfg.ScanCnt = 0;
3256 if (pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE)
3258 RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
3259 DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
3261 MlmeEnqueue(pAdapter,
3262 MLME_CNTL_STATE_MACHINE,
3264 sizeof(NDIS_802_11_MAC_ADDRESS),
3266 Status = NDIS_STATUS_SUCCESS;
3267 StateMachineTouched = TRUE;
3269 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_BSSID %02x:%02x:%02x:%02x:%02x:%02x\n",
3270 Bssid[0], Bssid[1], Bssid[2], Bssid[3], Bssid[4], Bssid[5]));
3273 case RT_OID_802_11_RADIO:
3274 if (wrq->u.data.length != sizeof(BOOLEAN))
3278 Status = copy_from_user(&RadioState, wrq->u.data.pointer, wrq->u.data.length);
3279 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_RADIO (=%d)\n", RadioState));
3280 if (pAdapter->StaCfg.bSwRadio != RadioState)
3282 pAdapter->StaCfg.bSwRadio = RadioState;
3283 if (pAdapter->StaCfg.bRadio != (pAdapter->StaCfg.bHwRadio && pAdapter->StaCfg.bSwRadio))
3285 pAdapter->StaCfg.bRadio = (pAdapter->StaCfg.bHwRadio && pAdapter->StaCfg.bSwRadio);
3286 if (pAdapter->StaCfg.bRadio == TRUE)
3288 MlmeRadioOn(pAdapter);
3289 // Update extra information
3290 pAdapter->ExtraInfo = EXTRA_INFO_CLEAR;
3294 MlmeRadioOff(pAdapter);
3295 // Update extra information
3296 pAdapter->ExtraInfo = SW_RADIO_OFF;
3302 case RT_OID_802_11_PHY_MODE:
3303 if (wrq->u.data.length != sizeof(RT_802_11_PHY_MODE))
3307 Status = copy_from_user(&PhyMode, wrq->u.data.pointer, wrq->u.data.length);
3308 if (PhyMode <= MaxPhyMode)
3310 RTMPSetPhyMode(pAdapter, PhyMode);
3311 #ifdef DOT11_N_SUPPORT
3312 SetCommonHT(pAdapter);
3313 #endif // DOT11_N_SUPPORT //
3315 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_PHY_MODE (=%d)\n", PhyMode));
3318 case RT_OID_802_11_STA_CONFIG:
3319 if (wrq->u.data.length != sizeof(RT_802_11_STA_CONFIG))
3323 Status = copy_from_user(&StaConfig, wrq->u.data.pointer, wrq->u.data.length);
3324 pAdapter->CommonCfg.bEnableTxBurst = StaConfig.EnableTxBurst;
3325 pAdapter->CommonCfg.UseBGProtection = StaConfig.UseBGProtection;
3326 pAdapter->CommonCfg.bUseShortSlotTime = 1; // 2003-10-30 always SHORT SLOT capable
3327 if ((pAdapter->CommonCfg.PhyMode != StaConfig.AdhocMode) &&
3328 (StaConfig.AdhocMode <= MaxPhyMode))
3330 // allow dynamic change of "USE OFDM rate or not" in ADHOC mode
3331 // if setting changed, need to reset current TX rate as well as BEACON frame format
3332 pAdapter->CommonCfg.PhyMode = StaConfig.AdhocMode;
3333 if (pAdapter->StaCfg.BssType == BSS_ADHOC)
3335 RTMPSetPhyMode(pAdapter, PhyMode);
3336 MlmeUpdateTxRates(pAdapter, FALSE, 0);
3337 MakeIbssBeacon(pAdapter); // re-build BEACON frame
3338 AsicEnableIbssSync(pAdapter); // copy to on-chip memory
3341 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_SET_STA_CONFIG (Burst=%d, Protection=%ld,ShortSlot=%d\n",
3342 pAdapter->CommonCfg.bEnableTxBurst,
3343 pAdapter->CommonCfg.UseBGProtection,
3344 pAdapter->CommonCfg.bUseShortSlotTime));
3347 case OID_802_11_DESIRED_RATES:
3348 if (wrq->u.data.length != sizeof(NDIS_802_11_RATES))
3352 Status = copy_from_user(&aryRates, wrq->u.data.pointer, wrq->u.data.length);
3353 NdisZeroMemory(pAdapter->CommonCfg.DesireRate, MAX_LEN_OF_SUPPORTED_RATES);
3354 NdisMoveMemory(pAdapter->CommonCfg.DesireRate, &aryRates, sizeof(NDIS_802_11_RATES));
3355 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_DESIRED_RATES (%02x,%02x,%02x,%02x,%02x,%02x,%02x,%02x)\n",
3356 pAdapter->CommonCfg.DesireRate[0],pAdapter->CommonCfg.DesireRate[1],
3357 pAdapter->CommonCfg.DesireRate[2],pAdapter->CommonCfg.DesireRate[3],
3358 pAdapter->CommonCfg.DesireRate[4],pAdapter->CommonCfg.DesireRate[5],
3359 pAdapter->CommonCfg.DesireRate[6],pAdapter->CommonCfg.DesireRate[7] ));
3360 // Changing DesiredRate may affect the MAX TX rate we used to TX frames out
3361 MlmeUpdateTxRates(pAdapter, FALSE, 0);
3364 case RT_OID_802_11_PREAMBLE:
3365 if (wrq->u.data.length != sizeof(RT_802_11_PREAMBLE))
3369 Status = copy_from_user(&Preamble, wrq->u.data.pointer, wrq->u.data.length);
3370 if (Preamble == Rt802_11PreambleShort)
3372 pAdapter->CommonCfg.TxPreamble = Preamble;
3373 MlmeSetTxPreamble(pAdapter, Rt802_11PreambleShort);
3375 else if ((Preamble == Rt802_11PreambleLong) || (Preamble == Rt802_11PreambleAuto))
3377 // if user wants AUTO, initialize to LONG here, then change according to AP's
3378 // capability upon association.
3379 pAdapter->CommonCfg.TxPreamble = Preamble;
3380 MlmeSetTxPreamble(pAdapter, Rt802_11PreambleLong);
3387 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_PREAMBLE (=%d)\n", Preamble));
3390 case OID_802_11_WEP_STATUS:
3391 if (wrq->u.data.length != sizeof(NDIS_802_11_WEP_STATUS))
3395 Status = copy_from_user(&WepStatus, wrq->u.data.pointer, wrq->u.data.length);
3396 // Since TKIP, AES, WEP are all supported. It should not have any invalid setting
3397 if (WepStatus <= Ndis802_11Encryption3KeyAbsent)
3399 if (pAdapter->StaCfg.WepStatus != WepStatus)
3401 // Config has changed
3402 pAdapter->bConfigChanged = TRUE;
3404 pAdapter->StaCfg.WepStatus = WepStatus;
3405 pAdapter->StaCfg.OrigWepStatus = WepStatus;
3406 pAdapter->StaCfg.PairCipher = WepStatus;
3407 pAdapter->StaCfg.GroupCipher = WepStatus;
3414 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_WEP_STATUS (=%d)\n",WepStatus));
3417 case OID_802_11_AUTHENTICATION_MODE:
3418 if (wrq->u.data.length != sizeof(NDIS_802_11_AUTHENTICATION_MODE))
3422 Status = copy_from_user(&AuthMode, wrq->u.data.pointer, wrq->u.data.length);
3423 if (AuthMode > Ndis802_11AuthModeMax)
3430 if (pAdapter->StaCfg.AuthMode != AuthMode)
3432 // Config has changed
3433 pAdapter->bConfigChanged = TRUE;
3435 pAdapter->StaCfg.AuthMode = AuthMode;
3437 pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED;
3438 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_AUTHENTICATION_MODE (=%d) \n",pAdapter->StaCfg.AuthMode));
3441 case OID_802_11_INFRASTRUCTURE_MODE:
3442 if (wrq->u.data.length != sizeof(NDIS_802_11_NETWORK_INFRASTRUCTURE))
3446 Status = copy_from_user(&BssType, wrq->u.data.pointer, wrq->u.data.length);
3448 if (BssType == Ndis802_11IBSS)
3449 Set_NetworkType_Proc(pAdapter, "Adhoc");
3450 else if (BssType == Ndis802_11Infrastructure)
3451 Set_NetworkType_Proc(pAdapter, "Infra");
3452 else if (BssType == Ndis802_11Monitor)
3453 Set_NetworkType_Proc(pAdapter, "Monitor");
3457 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_INFRASTRUCTURE_MODE (unknown)\n"));
3461 case OID_802_11_REMOVE_WEP:
3462 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_WEP\n"));
3463 if (wrq->u.data.length != sizeof(NDIS_802_11_KEY_INDEX))
3469 KeyIdx = *(NDIS_802_11_KEY_INDEX *) wrq->u.data.pointer;
3471 if (KeyIdx & 0x80000000)
3473 // Should never set default bit when remove key
3478 KeyIdx = KeyIdx & 0x0fffffff;
3484 pAdapter->SharedKey[BSS0][KeyIdx].KeyLen = 0;
3485 pAdapter->SharedKey[BSS0][KeyIdx].CipherAlg = CIPHER_NONE;
3486 AsicRemoveSharedKeyEntry(pAdapter, 0, (UCHAR)KeyIdx);
3491 case RT_OID_802_11_RESET_COUNTERS:
3492 NdisZeroMemory(&pAdapter->WlanCounters, sizeof(COUNTER_802_11));
3493 NdisZeroMemory(&pAdapter->Counters8023, sizeof(COUNTER_802_3));
3494 NdisZeroMemory(&pAdapter->RalinkCounters, sizeof(COUNTER_RALINK));
3495 pAdapter->Counters8023.RxNoBuffer = 0;
3496 pAdapter->Counters8023.GoodReceives = 0;
3497 pAdapter->Counters8023.RxNoBuffer = 0;
3499 pAdapter->BulkOutComplete = 0;
3500 pAdapter->BulkOutCompleteOther= 0;
3501 pAdapter->BulkOutCompleteCancel = 0;
3502 pAdapter->BulkOutReq = 0;
3503 pAdapter->BulkInReq= 0;
3504 pAdapter->BulkInComplete = 0;
3505 pAdapter->BulkInCompleteFail = 0;
3507 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_RESET_COUNTERS \n"));
3509 case OID_802_11_RTS_THRESHOLD:
3510 if (wrq->u.data.length != sizeof(NDIS_802_11_RTS_THRESHOLD))
3514 Status = copy_from_user(&RtsThresh, wrq->u.data.pointer, wrq->u.data.length);
3515 if (RtsThresh > MAX_RTS_THRESHOLD)
3518 pAdapter->CommonCfg.RtsThreshold = (USHORT)RtsThresh;
3520 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_RTS_THRESHOLD (=%ld)\n",RtsThresh));
3522 case OID_802_11_FRAGMENTATION_THRESHOLD:
3523 if (wrq->u.data.length != sizeof(NDIS_802_11_FRAGMENTATION_THRESHOLD))
3527 Status = copy_from_user(&FragThresh, wrq->u.data.pointer, wrq->u.data.length);
3528 pAdapter->CommonCfg.bUseZeroToDisableFragment = FALSE;
3529 if (FragThresh > MAX_FRAG_THRESHOLD || FragThresh < MIN_FRAG_THRESHOLD)
3531 if (FragThresh == 0)
3533 pAdapter->CommonCfg.FragmentThreshold = MAX_FRAG_THRESHOLD;
3534 pAdapter->CommonCfg.bUseZeroToDisableFragment = TRUE;
3540 pAdapter->CommonCfg.FragmentThreshold = (USHORT)FragThresh;
3542 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_FRAGMENTATION_THRESHOLD (=%ld) \n",FragThresh));
3544 case OID_802_11_POWER_MODE:
3545 if (wrq->u.data.length != sizeof(NDIS_802_11_POWER_MODE))
3549 Status = copy_from_user(&PowerMode, wrq->u.data.pointer, wrq->u.data.length);
3550 if (PowerMode == Ndis802_11PowerModeCAM)
3551 Set_PSMode_Proc(pAdapter, "CAM");
3552 else if (PowerMode == Ndis802_11PowerModeMAX_PSP)
3553 Set_PSMode_Proc(pAdapter, "Max_PSP");
3554 else if (PowerMode == Ndis802_11PowerModeFast_PSP)
3555 Set_PSMode_Proc(pAdapter, "Fast_PSP");
3556 else if (PowerMode == Ndis802_11PowerModeLegacy_PSP)
3557 Set_PSMode_Proc(pAdapter, "Legacy_PSP");
3561 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_POWER_MODE (=%d)\n",PowerMode));
3563 case RT_OID_802_11_TX_POWER_LEVEL_1:
3564 if (wrq->u.data.length < sizeof(ULONG))
3568 Status = copy_from_user(&PowerTemp, wrq->u.data.pointer, wrq->u.data.length);
3569 if (PowerTemp > 100)
3570 PowerTemp = 0xffffffff; // AUTO
3571 pAdapter->CommonCfg.TxPowerDefault = PowerTemp; //keep current setting.
3572 pAdapter->CommonCfg.TxPowerPercentage = pAdapter->CommonCfg.TxPowerDefault;
3573 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_TX_POWER_LEVEL_1 (=%ld)\n", pAdapter->CommonCfg.TxPowerPercentage));
3576 case OID_802_11_NETWORK_TYPE_IN_USE:
3577 if (wrq->u.data.length != sizeof(NDIS_802_11_NETWORK_TYPE))
3581 Status = copy_from_user(&NetType, wrq->u.data.pointer, wrq->u.data.length);
3583 if (NetType == Ndis802_11DS)
3584 RTMPSetPhyMode(pAdapter, PHY_11B);
3585 else if (NetType == Ndis802_11OFDM24)
3586 RTMPSetPhyMode(pAdapter, PHY_11BG_MIXED);
3587 else if (NetType == Ndis802_11OFDM5)
3588 RTMPSetPhyMode(pAdapter, PHY_11A);
3591 #ifdef DOT11_N_SUPPORT
3592 if (Status == NDIS_STATUS_SUCCESS)
3593 SetCommonHT(pAdapter);
3594 #endif // DOT11_N_SUPPORT //
3595 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_NETWORK_TYPE_IN_USE (=%d)\n",NetType));
3598 // For WPA PSK PMK key
3599 case RT_OID_802_11_ADD_WPA:
3600 pKey = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
3607 Status = copy_from_user(pKey, wrq->u.data.pointer, wrq->u.data.length);
3608 if (pKey->Length != wrq->u.data.length)
3611 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_ADD_WPA, Failed!!\n"));
3615 if ((pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPAPSK) &&
3616 (pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPA2PSK) &&
3617 (pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPANone) )
3619 Status = -EOPNOTSUPP;
3620 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_ADD_WPA, Failed!! [AuthMode != WPAPSK/WPA2PSK/WPANONE]\n"));
3622 else if ((pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK) ||
3623 (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK) ||
3624 (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPANone) ) // Only for WPA PSK mode
3626 NdisMoveMemory(pAdapter->StaCfg.PMK, &pKey->KeyMaterial, pKey->KeyLength);
3627 // Use RaConfig as PSK agent.
3628 // Start STA supplicant state machine
3629 if (pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPANone)
3630 pAdapter->StaCfg.WpaState = SS_START;
3632 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_ADD_WPA (id=0x%x, Len=%d-byte)\n", pKey->KeyIndex, pKey->KeyLength));
3636 pAdapter->StaCfg.WpaState = SS_NOTUSE;
3637 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_ADD_WPA (id=0x%x, Len=%d-byte)\n", pKey->KeyIndex, pKey->KeyLength));
3642 case OID_802_11_REMOVE_KEY:
3643 pRemoveKey = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
3644 if(pRemoveKey == NULL)
3650 Status = copy_from_user(pRemoveKey, wrq->u.data.pointer, wrq->u.data.length);
3651 if (pRemoveKey->Length != wrq->u.data.length)
3654 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_KEY, Failed!!\n"));
3658 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
3660 RTMPWPARemoveKeyProc(pAdapter, pRemoveKey);
3661 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_KEY, Remove WPA Key!!\n"));
3665 KeyIdx = pRemoveKey->KeyIndex;
3667 if (KeyIdx & 0x80000000)
3669 // Should never set default bit when remove key
3671 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_KEY, Failed!!(Should never set default bit when remove key)\n"));
3675 KeyIdx = KeyIdx & 0x0fffffff;
3679 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_KEY, Failed!!(KeyId[%d] out of range)\n", KeyIdx));
3683 pAdapter->SharedKey[BSS0][KeyIdx].KeyLen = 0;
3684 pAdapter->SharedKey[BSS0][KeyIdx].CipherAlg = CIPHER_NONE;
3685 AsicRemoveSharedKeyEntry(pAdapter, 0, (UCHAR)KeyIdx);
3686 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_KEY (id=0x%x, Len=%d-byte)\n", pRemoveKey->KeyIndex, pRemoveKey->Length));
3694 case OID_802_11_ADD_KEY:
3695 pKey = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
3701 Status = copy_from_user(pKey, wrq->u.data.pointer, wrq->u.data.length);
3702 if (pKey->Length != wrq->u.data.length)
3705 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_KEY, Failed!!\n"));
3709 RTMPAddKey(pAdapter, pKey);
3710 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_KEY (id=0x%x, Len=%d-byte)\n", pKey->KeyIndex, pKey->KeyLength));
3714 case OID_802_11_CONFIGURATION:
3715 if (wrq->u.data.length != sizeof(NDIS_802_11_CONFIGURATION))
3719 Status = copy_from_user(&Config, wrq->u.data.pointer, wrq->u.data.length);
3722 if ((pConfig->BeaconPeriod >= 20) && (pConfig->BeaconPeriod <=400))
3723 pAdapter->CommonCfg.BeaconPeriod = (USHORT) pConfig->BeaconPeriod;
3725 pAdapter->StaActive.AtimWin = (USHORT) pConfig->ATIMWindow;
3726 MAP_KHZ_TO_CHANNEL_ID(pConfig->DSConfig, pAdapter->CommonCfg.Channel);
3728 // Save the channel on MlmeAux for CntlOidRTBssidProc used.
3730 pAdapter->MlmeAux.Channel = pAdapter->CommonCfg.Channel;
3732 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_CONFIGURATION (BeacnPeriod=%ld,AtimW=%ld,Ch=%d)\n",
3733 pConfig->BeaconPeriod, pConfig->ATIMWindow, pAdapter->CommonCfg.Channel));
3734 // Config has changed
3735 pAdapter->bConfigChanged = TRUE;
3738 #ifdef DOT11_N_SUPPORT
3739 case RT_OID_802_11_SET_HT_PHYMODE:
3740 if (wrq->u.data.length != sizeof(OID_SET_HT_PHYMODE))
3744 POID_SET_HT_PHYMODE pHTPhyMode = &HT_PhyMode;
3746 Status = copy_from_user(&HT_PhyMode, wrq->u.data.pointer, wrq->u.data.length);
3747 DBGPRINT(RT_DEBUG_TRACE, ("Set::pHTPhyMode (PhyMode = %d,TransmitNo = %d, HtMode = %d, ExtOffset = %d , MCS = %d, BW = %d, STBC = %d, SHORTGI = %d) \n",
3748 pHTPhyMode->PhyMode, pHTPhyMode->TransmitNo,pHTPhyMode->HtMode,pHTPhyMode->ExtOffset,
3749 pHTPhyMode->MCS, pHTPhyMode->BW, pHTPhyMode->STBC, pHTPhyMode->SHORTGI));
3750 if (pAdapter->CommonCfg.PhyMode >= PHY_11ABGN_MIXED)
3751 RTMPSetHT(pAdapter, pHTPhyMode);
3753 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_SET_HT_PHYMODE(MCS=%d,BW=%d,SGI=%d,STBC=%d)\n",
3754 pAdapter->StaCfg.HTPhyMode.field.MCS, pAdapter->StaCfg.HTPhyMode.field.BW, pAdapter->StaCfg.HTPhyMode.field.ShortGI,
3755 pAdapter->StaCfg.HTPhyMode.field.STBC));
3757 #endif // DOT11_N_SUPPORT //
3758 case RT_OID_802_11_SET_APSD_SETTING:
3759 if (wrq->u.data.length != sizeof(ULONG))
3764 Status = copy_from_user(&apsd, wrq->u.data.pointer, wrq->u.data.length);
3766 /*-------------------------------------------------------------------
3767 |B31~B7 | B6~B5 | B4 | B3 | B2 | B1 | B0 |
3768 ---------------------------------------------------------------------
3769 | Rsvd | Max SP Len | AC_VO | AC_VI | AC_BK | AC_BE | APSD Capable |
3770 ---------------------------------------------------------------------*/
3771 pAdapter->CommonCfg.bAPSDCapable = (apsd & 0x00000001) ? TRUE : FALSE;
3772 pAdapter->CommonCfg.bAPSDAC_BE = ((apsd & 0x00000002) >> 1) ? TRUE : FALSE;
3773 pAdapter->CommonCfg.bAPSDAC_BK = ((apsd & 0x00000004) >> 2) ? TRUE : FALSE;
3774 pAdapter->CommonCfg.bAPSDAC_VI = ((apsd & 0x00000008) >> 3) ? TRUE : FALSE;
3775 pAdapter->CommonCfg.bAPSDAC_VO = ((apsd & 0x00000010) >> 4) ? TRUE : FALSE;
3776 pAdapter->CommonCfg.MaxSPLength = (UCHAR)((apsd & 0x00000060) >> 5);
3778 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,
3779 pAdapter->CommonCfg.bAPSDAC_BE, pAdapter->CommonCfg.bAPSDAC_BK, pAdapter->CommonCfg.bAPSDAC_VI, pAdapter->CommonCfg.bAPSDAC_VO, pAdapter->CommonCfg.MaxSPLength));
3783 case RT_OID_802_11_SET_APSD_PSM:
3784 if (wrq->u.data.length != sizeof(ULONG))
3788 // Driver needs to notify AP when PSM changes
3789 Status = copy_from_user(&pAdapter->CommonCfg.bAPSDForcePowerSave, wrq->u.data.pointer, wrq->u.data.length);
3790 if (pAdapter->CommonCfg.bAPSDForcePowerSave != pAdapter->StaCfg.Psm)
3792 MlmeSetPsmBit(pAdapter, pAdapter->CommonCfg.bAPSDForcePowerSave);
3793 RTMPSendNullFrame(pAdapter, pAdapter->CommonCfg.TxRate, TRUE);
3795 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_SET_APSD_PSM (bAPSDForcePowerSave:%d)\n", pAdapter->CommonCfg.bAPSDForcePowerSave));
3799 case RT_OID_802_11_SET_WMM:
3800 if (wrq->u.data.length != sizeof(BOOLEAN))
3804 Status = copy_from_user(&pAdapter->CommonCfg.bWmmCapable, wrq->u.data.pointer, wrq->u.data.length);
3805 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_SET_WMM (=%d) \n", pAdapter->CommonCfg.bWmmCapable));
3809 case OID_802_11_DISASSOCIATE:
3811 // Set NdisRadioStateOff to TRUE, instead of called MlmeRadioOff.
3812 // Later on, NDIS_802_11_BSSID_LIST_EX->NumberOfItems should be 0
3813 // when query OID_802_11_BSSID_LIST.
3815 // TRUE: NumberOfItems will set to 0.
3816 // FALSE: NumberOfItems no change.
3818 pAdapter->CommonCfg.NdisRadioStateOff = TRUE;
3819 // Set to immediately send the media disconnect event
3820 pAdapter->MlmeAux.CurrReqIsFromNdis = TRUE;
3821 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_DISASSOCIATE \n"));
3823 if (INFRA_ON(pAdapter))
3825 if (pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE)
3827 RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
3828 DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
3831 MlmeEnqueue(pAdapter,
3832 MLME_CNTL_STATE_MACHINE,
3833 OID_802_11_DISASSOCIATE,
3837 StateMachineTouched = TRUE;
3841 #ifdef DOT11_N_SUPPORT
3842 case RT_OID_802_11_SET_IMME_BA_CAP:
3843 if (wrq->u.data.length != sizeof(OID_BACAP_STRUC))
3847 OID_BACAP_STRUC Orde ;
3848 Status = copy_from_user(&Orde, wrq->u.data.pointer, wrq->u.data.length);
3849 if (Orde.Policy > BA_NOTUSE)
3851 Status = NDIS_STATUS_INVALID_DATA;
3853 else if (Orde.Policy == BA_NOTUSE)
3855 pAdapter->CommonCfg.BACapability.field.Policy = BA_NOTUSE;
3856 pAdapter->CommonCfg.BACapability.field.MpduDensity = Orde.MpduDensity;
3857 pAdapter->CommonCfg.DesiredHtPhy.MpduDensity = Orde.MpduDensity;
3858 pAdapter->CommonCfg.DesiredHtPhy.AmsduEnable = Orde.AmsduEnable;
3859 pAdapter->CommonCfg.DesiredHtPhy.AmsduSize= Orde.AmsduSize;
3860 pAdapter->CommonCfg.DesiredHtPhy.MimoPs= Orde.MMPSmode;
3861 pAdapter->CommonCfg.BACapability.field.MMPSmode = Orde.MMPSmode;
3863 pAdapter->CommonCfg.HtCapability.HtCapInfo.MimoPs = Orde.MMPSmode;
3864 pAdapter->CommonCfg.HtCapability.HtCapInfo.AMsduSize = Orde.AmsduSize;
3865 pAdapter->CommonCfg.HtCapability.HtCapParm.MpduDensity = Orde.MpduDensity;
3869 pAdapter->CommonCfg.BACapability.field.AutoBA = Orde.AutoBA;
3870 pAdapter->CommonCfg.BACapability.field.Policy = IMMED_BA; // we only support immediate BA.
3871 pAdapter->CommonCfg.BACapability.field.MpduDensity = Orde.MpduDensity;
3872 pAdapter->CommonCfg.DesiredHtPhy.MpduDensity = Orde.MpduDensity;
3873 pAdapter->CommonCfg.DesiredHtPhy.AmsduEnable = Orde.AmsduEnable;
3874 pAdapter->CommonCfg.DesiredHtPhy.AmsduSize= Orde.AmsduSize;
3875 pAdapter->CommonCfg.DesiredHtPhy.MimoPs = Orde.MMPSmode;
3876 pAdapter->CommonCfg.BACapability.field.MMPSmode = Orde.MMPSmode;
3879 pAdapter->CommonCfg.HtCapability.HtCapInfo.MimoPs = Orde.MMPSmode;
3880 pAdapter->CommonCfg.HtCapability.HtCapInfo.AMsduSize = Orde.AmsduSize;
3881 pAdapter->CommonCfg.HtCapability.HtCapParm.MpduDensity = Orde.MpduDensity;
3883 if (pAdapter->CommonCfg.BACapability.field.RxBAWinLimit > MAX_RX_REORDERBUF)
3884 pAdapter->CommonCfg.BACapability.field.RxBAWinLimit = MAX_RX_REORDERBUF;
3888 pAdapter->CommonCfg.REGBACapability.word = pAdapter->CommonCfg.BACapability.word;
3889 DBGPRINT(RT_DEBUG_TRACE, ("Set::(Orde.AutoBA = %d) (Policy=%d)(ReBAWinLimit=%d)(TxBAWinLimit=%d)(AutoMode=%d)\n",Orde.AutoBA, pAdapter->CommonCfg.BACapability.field.Policy,
3890 pAdapter->CommonCfg.BACapability.field.RxBAWinLimit,pAdapter->CommonCfg.BACapability.field.TxBAWinLimit, pAdapter->CommonCfg.BACapability.field.AutoBA));
3891 DBGPRINT(RT_DEBUG_TRACE, ("Set::(MimoPs = %d)(AmsduEnable = %d) (AmsduSize=%d)(MpduDensity=%d)\n",pAdapter->CommonCfg.DesiredHtPhy.MimoPs, pAdapter->CommonCfg.DesiredHtPhy.AmsduEnable,
3892 pAdapter->CommonCfg.DesiredHtPhy.AmsduSize, pAdapter->CommonCfg.DesiredHtPhy.MpduDensity));
3896 case RT_OID_802_11_ADD_IMME_BA:
3897 DBGPRINT(RT_DEBUG_TRACE, (" Set :: RT_OID_802_11_ADD_IMME_BA \n"));
3898 if (wrq->u.data.length != sizeof(OID_ADD_BA_ENTRY))
3903 OID_ADD_BA_ENTRY BA;
3904 MAC_TABLE_ENTRY *pEntry;
3906 Status = copy_from_user(&BA, wrq->u.data.pointer, wrq->u.data.length);
3909 Status = NDIS_STATUS_INVALID_DATA;
3914 //BATableInsertEntry
3915 //As ad-hoc mode, BA pair is not limited to only BSSID. so add via OID.
3917 // in ad hoc mode, when adding BA pair, we should insert this entry into MACEntry too
3918 pEntry = MacTableLookup(pAdapter, BA.MACAddr);
3921 DBGPRINT(RT_DEBUG_TRACE, ("RT_OID_802_11_ADD_IMME_BA. break on no connection.----:%x:%x\n", BA.MACAddr[4], BA.MACAddr[5]));
3924 if (BA.IsRecipient == FALSE)
3926 if (pEntry->bIAmBadAtheros == TRUE)
3927 pAdapter->CommonCfg.BACapability.field.RxBAWinLimit = 0x10;
3929 BAOriSessionSetUp(pAdapter, pEntry, index, 0, 100, TRUE);
3933 //BATableInsertEntry(pAdapter, pEntry->Aid, BA.MACAddr, 0, 0xffff, BA.TID, BA.nMSDU, BA.IsRecipient);
3936 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_ADD_IMME_BA. Rec = %d. Mac = %x:%x:%x:%x:%x:%x . \n",
3937 BA.IsRecipient, BA.MACAddr[0], BA.MACAddr[1], BA.MACAddr[2], BA.MACAddr[2]
3938 , BA.MACAddr[4], BA.MACAddr[5]));
3943 case RT_OID_802_11_TEAR_IMME_BA:
3944 DBGPRINT(RT_DEBUG_TRACE, ("Set :: RT_OID_802_11_TEAR_IMME_BA \n"));
3945 if (wrq->u.data.length != sizeof(OID_ADD_BA_ENTRY))
3949 POID_ADD_BA_ENTRY pBA;
3950 MAC_TABLE_ENTRY *pEntry;
3952 pBA = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
3956 DBGPRINT(RT_DEBUG_TRACE, ("Set :: RT_OID_802_11_TEAR_IMME_BA kmalloc() can't allocate enough memory\n"));
3957 Status = NDIS_STATUS_FAILURE;
3961 Status = copy_from_user(pBA, wrq->u.data.pointer, wrq->u.data.length);
3962 DBGPRINT(RT_DEBUG_TRACE, ("Set :: RT_OID_802_11_TEAR_IMME_BA(TID=%d, bAllTid=%d)\n", pBA->TID, pBA->bAllTid));
3964 if (!pBA->bAllTid && (pBA->TID > NUM_OF_TID))
3966 Status = NDIS_STATUS_INVALID_DATA;
3970 if (pBA->IsRecipient == FALSE)
3972 pEntry = MacTableLookup(pAdapter, pBA->MACAddr);
3973 DBGPRINT(RT_DEBUG_TRACE, (" pBA->IsRecipient == FALSE\n"));
3976 DBGPRINT(RT_DEBUG_TRACE, (" pBA->pEntry\n"));
3977 BAOriSessionTearDown(pAdapter, pEntry->Aid, pBA->TID, FALSE, TRUE);
3980 DBGPRINT(RT_DEBUG_TRACE, ("Set :: Not found pEntry \n"));
3984 pEntry = MacTableLookup(pAdapter, pBA->MACAddr);
3987 BARecSessionTearDown( pAdapter, (UCHAR)pEntry->Aid, pBA->TID, TRUE);
3990 DBGPRINT(RT_DEBUG_TRACE, ("Set :: Not found pEntry \n"));
3996 #endif // DOT11_N_SUPPORT //
3998 // For WPA_SUPPLICANT to set static wep key
3999 case OID_802_11_ADD_WEP:
4000 pWepKey = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
4005 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_WEP, Failed!!\n"));
4008 Status = copy_from_user(pWepKey, wrq->u.data.pointer, wrq->u.data.length);
4012 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_WEP, Failed (length mismatch)!!\n"));
4016 KeyIdx = pWepKey->KeyIndex & 0x0fffffff;
4017 // KeyIdx must be 0 ~ 3
4021 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_WEP, Failed (KeyIdx must be smaller than 4)!!\n"));
4025 UCHAR CipherAlg = 0;
4028 // set key material and key length
4029 NdisZeroMemory(pAdapter->SharedKey[BSS0][KeyIdx].Key, 16);
4030 pAdapter->SharedKey[BSS0][KeyIdx].KeyLen = (UCHAR) pWepKey->KeyLength;
4031 NdisMoveMemory(pAdapter->SharedKey[BSS0][KeyIdx].Key, &pWepKey->KeyMaterial, pWepKey->KeyLength);
4033 switch(pWepKey->KeyLength)
4036 CipherAlg = CIPHER_WEP64;
4039 CipherAlg = CIPHER_WEP128;
4042 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_WEP, only support CIPHER_WEP64(len:5) & CIPHER_WEP128(len:13)!!\n"));
4046 pAdapter->SharedKey[BSS0][KeyIdx].CipherAlg = CipherAlg;
4048 // Default key for tx (shared key)
4049 if (pWepKey->KeyIndex & 0x80000000)
4051 #ifdef WPA_SUPPLICANT_SUPPORT
4052 // set key material and key length
4053 NdisZeroMemory(pAdapter->StaCfg.DesireSharedKey[KeyIdx].Key, 16);
4054 pAdapter->StaCfg.DesireSharedKey[KeyIdx].KeyLen = (UCHAR) pWepKey->KeyLength;
4055 NdisMoveMemory(pAdapter->StaCfg.DesireSharedKey[KeyIdx].Key, &pWepKey->KeyMaterial, pWepKey->KeyLength);
4056 pAdapter->StaCfg.DesireSharedKeyId = KeyIdx;
4057 pAdapter->StaCfg.DesireSharedKey[KeyIdx].CipherAlg = CipherAlg;
4058 #endif // WPA_SUPPLICANT_SUPPORT //
4059 pAdapter->StaCfg.DefaultKeyId = (UCHAR) KeyIdx;
4062 #ifdef WPA_SUPPLICANT_SUPPORT
4063 if (pAdapter->StaCfg.PortSecured == WPA_802_1X_PORT_SECURED)
4064 #endif // WPA_SUPPLICANT_SUPPORT
4066 Key = pAdapter->SharedKey[BSS0][KeyIdx].Key;
4068 // Set key material and cipherAlg to Asic
4069 AsicAddSharedKeyEntry(pAdapter, BSS0, KeyIdx, CipherAlg, Key, NULL, NULL);
4071 if (pWepKey->KeyIndex & 0x80000000)
4073 PMAC_TABLE_ENTRY pEntry = &pAdapter->MacTab.Content[BSSID_WCID];
4074 // Assign group key info
4075 RTMPAddWcidAttributeEntry(pAdapter, BSS0, KeyIdx, CipherAlg, NULL);
4076 // Assign pairwise key info
4077 RTMPAddWcidAttributeEntry(pAdapter, BSS0, KeyIdx, CipherAlg, pEntry);
4080 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"));
4085 #ifdef WPA_SUPPLICANT_SUPPORT
4086 case OID_SET_COUNTERMEASURES:
4087 if (wrq->u.data.length != sizeof(int))
4092 Status = copy_from_user(&enabled, wrq->u.data.pointer, wrq->u.data.length);
4094 pAdapter->StaCfg.bBlockAssoc = TRUE;
4096 // WPA MIC error should block association attempt for 60 seconds
4097 pAdapter->StaCfg.bBlockAssoc = FALSE;
4098 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_SET_COUNTERMEASURES bBlockAssoc=%s\n", pAdapter->StaCfg.bBlockAssoc ? "TRUE":"FALSE"));
4101 case RT_OID_WPA_SUPPLICANT_SUPPORT:
4102 if (wrq->u.data.length != sizeof(UCHAR))
4106 Status = copy_from_user(&wpa_supplicant_enable, wrq->u.data.pointer, wrq->u.data.length);
4107 pAdapter->StaCfg.WpaSupplicantUP = wpa_supplicant_enable;
4108 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_WPA_SUPPLICANT_SUPPORT (=%d)\n", pAdapter->StaCfg.WpaSupplicantUP));
4111 case OID_802_11_DEAUTHENTICATION:
4112 if (wrq->u.data.length != sizeof(MLME_DEAUTH_REQ_STRUCT))
4116 MLME_DEAUTH_REQ_STRUCT *pInfo;
4117 MLME_QUEUE_ELEM *MsgElem = (MLME_QUEUE_ELEM *) kmalloc(sizeof(MLME_QUEUE_ELEM), MEM_ALLOC_FLAG);
4119 pInfo = (MLME_DEAUTH_REQ_STRUCT *) MsgElem->Msg;
4120 Status = copy_from_user(pInfo, wrq->u.data.pointer, wrq->u.data.length);
4121 MlmeDeauthReqAction(pAdapter, MsgElem);
4124 if (INFRA_ON(pAdapter))
4126 LinkDown(pAdapter, FALSE);
4127 pAdapter->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
4129 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_DEAUTHENTICATION (Reason=%d)\n", pInfo->Reason));
4132 case OID_802_11_DROP_UNENCRYPTED:
4133 if (wrq->u.data.length != sizeof(int))
4138 Status = copy_from_user(&enabled, wrq->u.data.pointer, wrq->u.data.length);
4140 pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED;
4142 pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
4143 NdisAcquireSpinLock(&pAdapter->MacTabLock);
4144 pAdapter->MacTab.Content[BSSID_WCID].PortSecured = pAdapter->StaCfg.PortSecured;
4145 NdisReleaseSpinLock(&pAdapter->MacTabLock);
4146 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_DROP_UNENCRYPTED (=%d)\n", enabled));
4149 case OID_802_11_SET_IEEE8021X:
4150 if (wrq->u.data.length != sizeof(BOOLEAN))
4154 Status = copy_from_user(&IEEE8021xState, wrq->u.data.pointer, wrq->u.data.length);
4155 pAdapter->StaCfg.IEEE8021X = IEEE8021xState;
4156 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_SET_IEEE8021X (=%d)\n", IEEE8021xState));
4159 case OID_802_11_SET_IEEE8021X_REQUIRE_KEY:
4160 if (wrq->u.data.length != sizeof(BOOLEAN))
4164 Status = copy_from_user(&IEEE8021x_required_keys, wrq->u.data.pointer, wrq->u.data.length);
4165 pAdapter->StaCfg.IEEE8021x_required_keys = IEEE8021x_required_keys;
4166 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_SET_IEEE8021X_REQUIRE_KEY (%d)\n", IEEE8021x_required_keys));
4169 case OID_802_11_PMKID:
4170 pPmkId = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
4172 if(pPmkId == NULL) {
4176 Status = copy_from_user(pPmkId, wrq->u.data.pointer, wrq->u.data.length);
4178 // check the PMKID information
4179 if (pPmkId->BSSIDInfoCount == 0)
4180 NdisZeroMemory(pAdapter->StaCfg.SavedPMK, sizeof(BSSID_INFO)*PMKID_NO);
4183 PBSSID_INFO pBssIdInfo;
4187 for (BssIdx = 0; BssIdx < pPmkId->BSSIDInfoCount; BssIdx++)
4189 // point to the indexed BSSID_INFO structure
4190 pBssIdInfo = (PBSSID_INFO) ((PUCHAR) pPmkId + 2 * sizeof(UINT) + BssIdx * sizeof(BSSID_INFO));
4191 // Find the entry in the saved data base.
4192 for (CachedIdx = 0; CachedIdx < pAdapter->StaCfg.SavedPMKNum; CachedIdx++)
4194 // compare the BSSID
4195 if (NdisEqualMemory(pBssIdInfo->BSSID, pAdapter->StaCfg.SavedPMK[CachedIdx].BSSID, sizeof(NDIS_802_11_MAC_ADDRESS)))
4199 // Found, replace it
4200 if (CachedIdx < PMKID_NO)
4202 DBGPRINT(RT_DEBUG_OFF, ("Update OID_802_11_PMKID, idx = %d\n", CachedIdx));
4203 NdisMoveMemory(&pAdapter->StaCfg.SavedPMK[CachedIdx], pBssIdInfo, sizeof(BSSID_INFO));
4204 pAdapter->StaCfg.SavedPMKNum++;
4206 // Not found, replace the last one
4209 // Randomly replace one
4210 CachedIdx = (pBssIdInfo->BSSID[5] % PMKID_NO);
4211 DBGPRINT(RT_DEBUG_OFF, ("Update OID_802_11_PMKID, idx = %d\n", CachedIdx));
4212 NdisMoveMemory(&pAdapter->StaCfg.SavedPMK[CachedIdx], pBssIdInfo, sizeof(BSSID_INFO));
4219 #endif // WPA_SUPPLICANT_SUPPORT //
4224 case OID_802_11_SHORTRETRYLIMIT:
4225 if (wrq->u.data.length != sizeof(ULONG))
4229 Status = copy_from_user(&ShortRetryLimit, wrq->u.data.pointer, wrq->u.data.length);
4230 RTMP_IO_READ32(pAdapter, TX_RTY_CFG, &tx_rty_cfg.word);
4231 tx_rty_cfg.field.ShortRtyLimit = ShortRetryLimit;
4232 RTMP_IO_WRITE32(pAdapter, TX_RTY_CFG, tx_rty_cfg.word);
4233 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_SHORTRETRYLIMIT (tx_rty_cfg.field.ShortRetryLimit=%d, ShortRetryLimit=%ld)\n", tx_rty_cfg.field.ShortRtyLimit, ShortRetryLimit));
4237 case OID_802_11_LONGRETRYLIMIT:
4238 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_LONGRETRYLIMIT \n"));
4239 if (wrq->u.data.length != sizeof(ULONG))
4243 Status = copy_from_user(&LongRetryLimit, wrq->u.data.pointer, wrq->u.data.length);
4244 RTMP_IO_READ32(pAdapter, TX_RTY_CFG, &tx_rty_cfg.word);
4245 tx_rty_cfg.field.LongRtyLimit = LongRetryLimit;
4246 RTMP_IO_WRITE32(pAdapter, TX_RTY_CFG, tx_rty_cfg.word);
4247 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_LONGRETRYLIMIT (tx_rty_cfg.field.LongRetryLimit= %d,LongRetryLimit=%ld)\n", tx_rty_cfg.field.LongRtyLimit, LongRetryLimit));
4251 case OID_802_11_WEPDEFAULTKEYVALUE:
4252 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_WEPDEFAULTKEYVALUE\n"));
4253 pKey = kmalloc(wrq->u.data.length, GFP_KERNEL);
4254 Status = copy_from_user(pKey, wrq->u.data.pointer, wrq->u.data.length);
4257 if ( pKey->Length != wrq->u.data.length)
4260 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_WEPDEFAULTKEYVALUE, Failed!!\n"));
4262 KeyIdx = pKey->KeyIndex & 0x0fffffff;
4263 DBGPRINT(RT_DEBUG_TRACE,("pKey->KeyIndex =%d, pKey->KeyLength=%d\n", pKey->KeyIndex, pKey->KeyLength));
4265 // it is a shared key
4270 pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].KeyLen = (UCHAR) pKey->KeyLength;
4271 NdisMoveMemory(&pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].Key, &pKey->KeyMaterial, pKey->KeyLength);
4272 if (pKey->KeyIndex & 0x80000000)
4274 // Default key for tx (shared key)
4275 pAdapter->StaCfg.DefaultKeyId = (UCHAR) KeyIdx;
4277 //RestartAPIsRequired = TRUE;
4282 case OID_802_11_WEPDEFAULTKEYID:
4283 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_WEPDEFAULTKEYID \n"));
4285 if (wrq->u.data.length != sizeof(UCHAR))
4288 Status = copy_from_user(&pAdapter->StaCfg.DefaultKeyId, wrq->u.data.pointer, wrq->u.data.length);
4293 case OID_802_11_CURRENTCHANNEL:
4294 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_CURRENTCHANNEL \n"));
4295 if (wrq->u.data.length != sizeof(UCHAR))
4299 Status = copy_from_user(&ctmp, wrq->u.data.pointer, wrq->u.data.length);
4300 sprintf(&ctmp,"%d", ctmp);
4301 Set_Channel_Proc(pAdapter, &ctmp);
4309 DBGPRINT(RT_DEBUG_TRACE, ("Set::unknown IOCTL's subcmd = 0x%08x\n", cmd));
4310 Status = -EOPNOTSUPP;
4318 INT RTMPQueryInformation(
4319 IN PRTMP_ADAPTER pAdapter,
4320 IN OUT struct ifreq *rq,
4323 struct iwreq *wrq = (struct iwreq *) rq;
4324 NDIS_802_11_BSSID_LIST_EX *pBssidList = NULL;
4325 PNDIS_WLAN_BSSID_EX pBss;
4326 NDIS_802_11_SSID Ssid;
4327 NDIS_802_11_CONFIGURATION *pConfiguration = NULL;
4328 RT_802_11_LINK_STATUS *pLinkStatus = NULL;
4329 RT_802_11_STA_CONFIG *pStaConfig = NULL;
4330 NDIS_802_11_STATISTICS *pStatistics = NULL;
4331 NDIS_802_11_RTS_THRESHOLD RtsThresh;
4332 NDIS_802_11_FRAGMENTATION_THRESHOLD FragThresh;
4333 NDIS_802_11_POWER_MODE PowerMode;
4334 NDIS_802_11_NETWORK_INFRASTRUCTURE BssType;
4335 RT_802_11_PREAMBLE PreamType;
4336 NDIS_802_11_AUTHENTICATION_MODE AuthMode;
4337 NDIS_802_11_WEP_STATUS WepStatus;
4338 NDIS_MEDIA_STATE MediaState;
4339 ULONG BssBufSize, ulInfo=0, NetworkTypeList[4], apsd = 0;
4341 PUCHAR pBuf = NULL, pPtr;
4342 INT Status = NDIS_STATUS_SUCCESS;
4343 UINT we_version_compiled;
4344 UCHAR i, Padding = 0;
4346 UCHAR driverVersion[8];
4347 OID_SET_HT_PHYMODE *pHTPhyMode = NULL;
4352 DefaultKeyIdxValue *pKeyIdxValue;
4354 TX_RTY_CFG_STRUC tx_rty_cfg;
4355 ULONG ShortRetryLimit, LongRetryLimit;
4361 case RT_OID_DEVICE_NAME:
4362 wrq->u.data.length = sizeof(STA_NIC_DEVICE_NAME);
4363 Status = copy_to_user(wrq->u.data.pointer, STA_NIC_DEVICE_NAME, wrq->u.data.length);
4365 case RT_OID_VERSION_INFO:
4366 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_VERSION_INFO \n"));
4367 wrq->u.data.length = 8*sizeof(UCHAR);
4368 sprintf(&driverVersion[0], "%s", STA_DRIVER_VERSION);
4369 driverVersion[7] = '\0';
4370 if (copy_to_user(wrq->u.data.pointer, &driverVersion, wrq->u.data.length))
4375 case OID_802_11_BSSID_LIST:
4376 if (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
4379 * Still scanning, indicate the caller should try again.
4381 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_BSSID_LIST (Still scanning)\n"));
4384 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_BSSID_LIST (%d BSS returned)\n",pAdapter->ScanTab.BssNr));
4385 pAdapter->StaCfg.bScanReqIsFromWebUI = FALSE;
4386 // Claculate total buffer size required
4387 BssBufSize = sizeof(ULONG);
4389 for (i = 0; i < pAdapter->ScanTab.BssNr; i++)
4391 // Align pointer to 4 bytes boundary.
4392 //Padding = 4 - (pAdapter->ScanTab.BssEntry[i].VarIELen & 0x0003);
4395 BssBufSize += (sizeof(NDIS_WLAN_BSSID_EX) - 1 + sizeof(NDIS_802_11_FIXED_IEs) + pAdapter->ScanTab.BssEntry[i].VarIELen + Padding);
4398 // For safety issue, we add 256 bytes just in case
4400 // Allocate the same size as passed from higher layer
4401 pBuf = kmalloc(BssBufSize, MEM_ALLOC_FLAG);
4407 // Init 802_11_BSSID_LIST_EX structure
4408 NdisZeroMemory(pBuf, BssBufSize);
4409 pBssidList = (PNDIS_802_11_BSSID_LIST_EX) pBuf;
4410 pBssidList->NumberOfItems = pAdapter->ScanTab.BssNr;
4412 // Calculate total buffer length
4413 BssLen = 4; // Consist of NumberOfItems
4414 // Point to start of NDIS_WLAN_BSSID_EX
4415 // pPtr = pBuf + sizeof(ULONG);
4416 pPtr = (PUCHAR) &pBssidList->Bssid[0];
4417 for (i = 0; i < pAdapter->ScanTab.BssNr; i++)
4419 pBss = (PNDIS_WLAN_BSSID_EX) pPtr;
4420 NdisMoveMemory(&pBss->MacAddress, &pAdapter->ScanTab.BssEntry[i].Bssid, MAC_ADDR_LEN);
4421 if ((pAdapter->ScanTab.BssEntry[i].Hidden == 1) && (pAdapter->StaCfg.bShowHiddenSSID == FALSE))
4424 // We must return this SSID during 4way handshaking, otherwise Aegis will failed to parse WPA infomation
4425 // and then failed to send EAPOl farame.
4427 if ((pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA) && (pAdapter->StaCfg.PortSecured != WPA_802_1X_PORT_SECURED))
4429 pBss->Ssid.SsidLength = pAdapter->ScanTab.BssEntry[i].SsidLen;
4430 NdisMoveMemory(pBss->Ssid.Ssid, pAdapter->ScanTab.BssEntry[i].Ssid, pAdapter->ScanTab.BssEntry[i].SsidLen);
4433 pBss->Ssid.SsidLength = 0;
4437 pBss->Ssid.SsidLength = pAdapter->ScanTab.BssEntry[i].SsidLen;
4438 NdisMoveMemory(pBss->Ssid.Ssid, pAdapter->ScanTab.BssEntry[i].Ssid, pAdapter->ScanTab.BssEntry[i].SsidLen);
4440 pBss->Privacy = pAdapter->ScanTab.BssEntry[i].Privacy;
4441 pBss->Rssi = pAdapter->ScanTab.BssEntry[i].Rssi - pAdapter->BbpRssiToDbmDelta;
4442 pBss->NetworkTypeInUse = NetworkTypeInUseSanity(&pAdapter->ScanTab.BssEntry[i]);
4443 pBss->Configuration.Length = sizeof(NDIS_802_11_CONFIGURATION);
4444 pBss->Configuration.BeaconPeriod = pAdapter->ScanTab.BssEntry[i].BeaconPeriod;
4445 pBss->Configuration.ATIMWindow = pAdapter->ScanTab.BssEntry[i].AtimWin;
4447 MAP_CHANNEL_ID_TO_KHZ(pAdapter->ScanTab.BssEntry[i].Channel, pBss->Configuration.DSConfig);
4449 if (pAdapter->ScanTab.BssEntry[i].BssType == BSS_INFRA)
4450 pBss->InfrastructureMode = Ndis802_11Infrastructure;
4452 pBss->InfrastructureMode = Ndis802_11IBSS;
4454 NdisMoveMemory(pBss->SupportedRates, pAdapter->ScanTab.BssEntry[i].SupRate, pAdapter->ScanTab.BssEntry[i].SupRateLen);
4455 NdisMoveMemory(pBss->SupportedRates + pAdapter->ScanTab.BssEntry[i].SupRateLen,
4456 pAdapter->ScanTab.BssEntry[i].ExtRate,
4457 pAdapter->ScanTab.BssEntry[i].ExtRateLen);
4459 if (pAdapter->ScanTab.BssEntry[i].VarIELen == 0)
4461 pBss->IELength = sizeof(NDIS_802_11_FIXED_IEs);
4462 NdisMoveMemory(pBss->IEs, &pAdapter->ScanTab.BssEntry[i].FixIEs, sizeof(NDIS_802_11_FIXED_IEs));
4463 pPtr = pPtr + sizeof(NDIS_WLAN_BSSID_EX) - 1 + sizeof(NDIS_802_11_FIXED_IEs);
4467 pBss->IELength = (ULONG)(sizeof(NDIS_802_11_FIXED_IEs) + pAdapter->ScanTab.BssEntry[i].VarIELen);
4468 pPtr = pPtr + sizeof(NDIS_WLAN_BSSID_EX) - 1 + sizeof(NDIS_802_11_FIXED_IEs);
4469 NdisMoveMemory(pBss->IEs, &pAdapter->ScanTab.BssEntry[i].FixIEs, sizeof(NDIS_802_11_FIXED_IEs));
4470 NdisMoveMemory(pBss->IEs + sizeof(NDIS_802_11_FIXED_IEs), pAdapter->ScanTab.BssEntry[i].VarIEs, pAdapter->ScanTab.BssEntry[i].VarIELen);
4471 pPtr += pAdapter->ScanTab.BssEntry[i].VarIELen;
4473 pBss->Length = (ULONG)(sizeof(NDIS_WLAN_BSSID_EX) - 1 + sizeof(NDIS_802_11_FIXED_IEs) + pAdapter->ScanTab.BssEntry[i].VarIELen + Padding);
4475 #if WIRELESS_EXT < 17
4476 if ((BssLen + pBss->Length) < wrq->u.data.length)
4477 BssLen += pBss->Length;
4480 pBssidList->NumberOfItems = i;
4484 BssLen += pBss->Length;
4488 #if WIRELESS_EXT < 17
4489 wrq->u.data.length = BssLen;
4491 if (BssLen > wrq->u.data.length)
4497 wrq->u.data.length = BssLen;
4499 Status = copy_to_user(wrq->u.data.pointer, pBssidList, BssLen);
4502 case OID_802_3_CURRENT_ADDRESS:
4503 wrq->u.data.length = MAC_ADDR_LEN;
4504 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CurrentAddress, wrq->u.data.length);
4506 case OID_GEN_MEDIA_CONNECT_STATUS:
4507 if (pAdapter->IndicateMediaState == NdisMediaStateConnected)
4508 MediaState = NdisMediaStateConnected;
4510 MediaState = NdisMediaStateDisconnected;
4512 wrq->u.data.length = sizeof(NDIS_MEDIA_STATE);
4513 Status = copy_to_user(wrq->u.data.pointer, &MediaState, wrq->u.data.length);
4515 case OID_802_11_BSSID:
4516 if (INFRA_ON(pAdapter) || ADHOC_ON(pAdapter))
4518 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.Bssid, sizeof(NDIS_802_11_MAC_ADDRESS));
4523 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_BSSID(=EMPTY)\n"));
4527 case OID_802_11_SSID:
4528 NdisZeroMemory(&Ssid, sizeof(NDIS_802_11_SSID));
4529 NdisZeroMemory(Ssid.Ssid, MAX_LEN_OF_SSID);
4530 Ssid.SsidLength = pAdapter->CommonCfg.SsidLen;
4531 memcpy(Ssid.Ssid, pAdapter->CommonCfg.Ssid, Ssid.SsidLength);
4532 wrq->u.data.length = sizeof(NDIS_802_11_SSID);
4533 Status = copy_to_user(wrq->u.data.pointer, &Ssid, wrq->u.data.length);
4534 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_SSID (Len=%d, ssid=%s)\n", Ssid.SsidLength,Ssid.Ssid));
4536 case RT_OID_802_11_QUERY_LINK_STATUS:
4537 pLinkStatus = (RT_802_11_LINK_STATUS *) kmalloc(sizeof(RT_802_11_LINK_STATUS), MEM_ALLOC_FLAG);
4540 pLinkStatus->CurrTxRate = RateIdTo500Kbps[pAdapter->CommonCfg.TxRate]; // unit : 500 kbps
4541 pLinkStatus->ChannelQuality = pAdapter->Mlme.ChannelQuality;
4542 pLinkStatus->RxByteCount = pAdapter->RalinkCounters.ReceivedByteCount;
4543 pLinkStatus->TxByteCount = pAdapter->RalinkCounters.TransmittedByteCount;
4544 pLinkStatus->CentralChannel = pAdapter->CommonCfg.CentralChannel;
4545 wrq->u.data.length = sizeof(RT_802_11_LINK_STATUS);
4546 Status = copy_to_user(wrq->u.data.pointer, pLinkStatus, wrq->u.data.length);
4548 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_LINK_STATUS\n"));
4552 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_LINK_STATUS(kmalloc failed)\n"));
4556 case OID_802_11_CONFIGURATION:
4557 pConfiguration = (NDIS_802_11_CONFIGURATION *) kmalloc(sizeof(NDIS_802_11_CONFIGURATION), MEM_ALLOC_FLAG);
4560 pConfiguration->Length = sizeof(NDIS_802_11_CONFIGURATION);
4561 pConfiguration->BeaconPeriod = pAdapter->CommonCfg.BeaconPeriod;
4562 pConfiguration->ATIMWindow = pAdapter->StaActive.AtimWin;
4563 MAP_CHANNEL_ID_TO_KHZ(pAdapter->CommonCfg.Channel, pConfiguration->DSConfig);
4564 wrq->u.data.length = sizeof(NDIS_802_11_CONFIGURATION);
4565 Status = copy_to_user(wrq->u.data.pointer, pConfiguration, wrq->u.data.length);
4566 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_CONFIGURATION(BeaconPeriod=%ld,AtimW=%ld,Channel=%d) \n",
4567 pConfiguration->BeaconPeriod, pConfiguration->ATIMWindow, pAdapter->CommonCfg.Channel));
4568 kfree(pConfiguration);
4572 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_CONFIGURATION(kmalloc failed)\n"));
4576 case RT_OID_802_11_SNR_0:
4577 if ((pAdapter->StaCfg.LastSNR0 > 0))
4579 ulInfo = ((0xeb - pAdapter->StaCfg.LastSNR0) * 3) / 16 ;
4580 wrq->u.data.length = sizeof(ulInfo);
4581 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4582 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_SNR_0(0x=%lx)\n", ulInfo));
4587 case RT_OID_802_11_SNR_1:
4588 if ((pAdapter->Antenna.field.RxPath > 1) &&
4589 (pAdapter->StaCfg.LastSNR1 > 0))
4591 ulInfo = ((0xeb - pAdapter->StaCfg.LastSNR1) * 3) / 16 ;
4592 wrq->u.data.length = sizeof(ulInfo);
4593 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4594 DBGPRINT(RT_DEBUG_TRACE,("Query::RT_OID_802_11_SNR_1(0x=%lx)\n",ulInfo));
4598 DBGPRINT(RT_DEBUG_TRACE,("Query::RT_OID_802_11_SNR_1(pAdapter->StaCfg.LastSNR1=%d)\n",pAdapter->StaCfg.LastSNR1));
4600 case OID_802_11_RSSI_TRIGGER:
4601 ulInfo = pAdapter->StaCfg.RssiSample.LastRssi0 - pAdapter->BbpRssiToDbmDelta;
4602 wrq->u.data.length = sizeof(ulInfo);
4603 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4604 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_RSSI_TRIGGER(=%ld)\n", ulInfo));
4606 case OID_802_11_RSSI:
4607 case RT_OID_802_11_RSSI:
4608 ulInfo = pAdapter->StaCfg.RssiSample.LastRssi0;
4609 wrq->u.data.length = sizeof(ulInfo);
4610 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4612 case RT_OID_802_11_RSSI_1:
4613 ulInfo = pAdapter->StaCfg.RssiSample.LastRssi1;
4614 wrq->u.data.length = sizeof(ulInfo);
4615 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4617 case RT_OID_802_11_RSSI_2:
4618 ulInfo = pAdapter->StaCfg.RssiSample.LastRssi2;
4619 wrq->u.data.length = sizeof(ulInfo);
4620 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4622 case OID_802_11_STATISTICS:
4623 pStatistics = (NDIS_802_11_STATISTICS *) kmalloc(sizeof(NDIS_802_11_STATISTICS), MEM_ALLOC_FLAG);
4626 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_STATISTICS \n"));
4627 // add the most up-to-date h/w raw counters into software counters
4628 NICUpdateRawCounters(pAdapter);
4630 // Sanity check for calculation of sucessful count
4631 if (pAdapter->WlanCounters.TransmittedFragmentCount.QuadPart < pAdapter->WlanCounters.RetryCount.QuadPart)
4632 pAdapter->WlanCounters.TransmittedFragmentCount.QuadPart = pAdapter->WlanCounters.RetryCount.QuadPart;
4634 pStatistics->TransmittedFragmentCount.QuadPart = pAdapter->WlanCounters.TransmittedFragmentCount.QuadPart;
4635 pStatistics->MulticastTransmittedFrameCount.QuadPart = pAdapter->WlanCounters.MulticastTransmittedFrameCount.QuadPart;
4636 pStatistics->FailedCount.QuadPart = pAdapter->WlanCounters.FailedCount.QuadPart;
4637 pStatistics->RetryCount.QuadPart = pAdapter->WlanCounters.RetryCount.QuadPart;
4638 pStatistics->MultipleRetryCount.QuadPart = pAdapter->WlanCounters.MultipleRetryCount.QuadPart;
4639 pStatistics->RTSSuccessCount.QuadPart = pAdapter->WlanCounters.RTSSuccessCount.QuadPart;
4640 pStatistics->RTSFailureCount.QuadPart = pAdapter->WlanCounters.RTSFailureCount.QuadPart;
4641 pStatistics->ACKFailureCount.QuadPart = pAdapter->WlanCounters.ACKFailureCount.QuadPart;
4642 pStatistics->FrameDuplicateCount.QuadPart = pAdapter->WlanCounters.FrameDuplicateCount.QuadPart;
4643 pStatistics->ReceivedFragmentCount.QuadPart = pAdapter->WlanCounters.ReceivedFragmentCount.QuadPart;
4644 pStatistics->MulticastReceivedFrameCount.QuadPart = pAdapter->WlanCounters.MulticastReceivedFrameCount.QuadPart;
4646 pStatistics->FCSErrorCount = pAdapter->RalinkCounters.RealFcsErrCount;
4648 pStatistics->FCSErrorCount.QuadPart = pAdapter->WlanCounters.FCSErrorCount.QuadPart;
4649 pStatistics->FrameDuplicateCount.u.LowPart = pAdapter->WlanCounters.FrameDuplicateCount.u.LowPart / 100;
4651 wrq->u.data.length = sizeof(NDIS_802_11_STATISTICS);
4652 Status = copy_to_user(wrq->u.data.pointer, pStatistics, wrq->u.data.length);
4657 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_STATISTICS(kmalloc failed)\n"));
4661 case OID_GEN_RCV_OK:
4662 ulInfo = pAdapter->Counters8023.GoodReceives;
4663 wrq->u.data.length = sizeof(ulInfo);
4664 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4666 case OID_GEN_RCV_NO_BUFFER:
4667 ulInfo = pAdapter->Counters8023.RxNoBuffer;
4668 wrq->u.data.length = sizeof(ulInfo);
4669 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4671 case RT_OID_802_11_PHY_MODE:
4672 ulInfo = (ULONG)pAdapter->CommonCfg.PhyMode;
4673 wrq->u.data.length = sizeof(ulInfo);
4674 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4675 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_PHY_MODE (=%ld)\n", ulInfo));
4677 case RT_OID_802_11_STA_CONFIG:
4678 pStaConfig = (RT_802_11_STA_CONFIG *) kmalloc(sizeof(RT_802_11_STA_CONFIG), MEM_ALLOC_FLAG);
4681 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_STA_CONFIG\n"));
4682 pStaConfig->EnableTxBurst = pAdapter->CommonCfg.bEnableTxBurst;
4683 pStaConfig->EnableTurboRate = 0;
4684 pStaConfig->UseBGProtection = pAdapter->CommonCfg.UseBGProtection;
4685 pStaConfig->UseShortSlotTime = pAdapter->CommonCfg.bUseShortSlotTime;
4686 //pStaConfig->AdhocMode = pAdapter->StaCfg.AdhocMode;
4687 pStaConfig->HwRadioStatus = (pAdapter->StaCfg.bHwRadio == TRUE) ? 1 : 0;
4688 pStaConfig->Rsv1 = 0;
4689 pStaConfig->SystemErrorBitmap = pAdapter->SystemErrorBitmap;
4690 wrq->u.data.length = sizeof(RT_802_11_STA_CONFIG);
4691 Status = copy_to_user(wrq->u.data.pointer, pStaConfig, wrq->u.data.length);
4696 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_STA_CONFIG(kmalloc failed)\n"));
4700 case OID_802_11_RTS_THRESHOLD:
4701 RtsThresh = pAdapter->CommonCfg.RtsThreshold;
4702 wrq->u.data.length = sizeof(RtsThresh);
4703 Status = copy_to_user(wrq->u.data.pointer, &RtsThresh, wrq->u.data.length);
4704 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_RTS_THRESHOLD(=%ld)\n", RtsThresh));
4706 case OID_802_11_FRAGMENTATION_THRESHOLD:
4707 FragThresh = pAdapter->CommonCfg.FragmentThreshold;
4708 if (pAdapter->CommonCfg.bUseZeroToDisableFragment == TRUE)
4710 wrq->u.data.length = sizeof(FragThresh);
4711 Status = copy_to_user(wrq->u.data.pointer, &FragThresh, wrq->u.data.length);
4712 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_FRAGMENTATION_THRESHOLD(=%ld)\n", FragThresh));
4714 case OID_802_11_POWER_MODE:
4715 PowerMode = pAdapter->StaCfg.WindowsPowerMode;
4716 wrq->u.data.length = sizeof(PowerMode);
4717 Status = copy_to_user(wrq->u.data.pointer, &PowerMode, wrq->u.data.length);
4718 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_POWER_MODE(=%d)\n", PowerMode));
4720 case RT_OID_802_11_RADIO:
4721 RadioState = (BOOLEAN) pAdapter->StaCfg.bSwRadio;
4722 wrq->u.data.length = sizeof(RadioState);
4723 Status = copy_to_user(wrq->u.data.pointer, &RadioState, wrq->u.data.length);
4724 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_RADIO (=%d)\n", RadioState));
4726 case OID_802_11_INFRASTRUCTURE_MODE:
4727 if (pAdapter->StaCfg.BssType == BSS_ADHOC)
4728 BssType = Ndis802_11IBSS;
4729 else if (pAdapter->StaCfg.BssType == BSS_INFRA)
4730 BssType = Ndis802_11Infrastructure;
4731 else if (pAdapter->StaCfg.BssType == BSS_MONITOR)
4732 BssType = Ndis802_11Monitor;
4734 BssType = Ndis802_11AutoUnknown;
4736 wrq->u.data.length = sizeof(BssType);
4737 Status = copy_to_user(wrq->u.data.pointer, &BssType, wrq->u.data.length);
4738 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_INFRASTRUCTURE_MODE(=%d)\n", BssType));
4740 case RT_OID_802_11_PREAMBLE:
4741 PreamType = pAdapter->CommonCfg.TxPreamble;
4742 wrq->u.data.length = sizeof(PreamType);
4743 Status = copy_to_user(wrq->u.data.pointer, &PreamType, wrq->u.data.length);
4744 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_PREAMBLE(=%d)\n", PreamType));
4746 case OID_802_11_AUTHENTICATION_MODE:
4747 AuthMode = pAdapter->StaCfg.AuthMode;
4748 wrq->u.data.length = sizeof(AuthMode);
4749 Status = copy_to_user(wrq->u.data.pointer, &AuthMode, wrq->u.data.length);
4750 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_AUTHENTICATION_MODE(=%d)\n", AuthMode));
4752 case OID_802_11_WEP_STATUS:
4753 WepStatus = pAdapter->StaCfg.WepStatus;
4754 wrq->u.data.length = sizeof(WepStatus);
4755 Status = copy_to_user(wrq->u.data.pointer, &WepStatus, wrq->u.data.length);
4756 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_WEP_STATUS(=%d)\n", WepStatus));
4758 case OID_802_11_TX_POWER_LEVEL:
4759 wrq->u.data.length = sizeof(ULONG);
4760 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.TxPower, wrq->u.data.length);
4761 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_TX_POWER_LEVEL %x\n",pAdapter->CommonCfg.TxPower));
4763 case RT_OID_802_11_TX_POWER_LEVEL_1:
4764 wrq->u.data.length = sizeof(ULONG);
4765 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.TxPowerPercentage, wrq->u.data.length);
4766 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_TX_POWER_LEVEL_1 (=%ld)\n", pAdapter->CommonCfg.TxPowerPercentage));
4768 case OID_802_11_NETWORK_TYPES_SUPPORTED:
4769 if ((pAdapter->RfIcType == RFIC_2850) || (pAdapter->RfIcType == RFIC_2750))
4771 NetworkTypeList[0] = 3; // NumberOfItems = 3
4772 NetworkTypeList[1] = Ndis802_11DS; // NetworkType[1] = 11b
4773 NetworkTypeList[2] = Ndis802_11OFDM24; // NetworkType[2] = 11g
4774 NetworkTypeList[3] = Ndis802_11OFDM5; // NetworkType[3] = 11a
4775 wrq->u.data.length = 16;
4776 Status = copy_to_user(wrq->u.data.pointer, &NetworkTypeList[0], wrq->u.data.length);
4780 NetworkTypeList[0] = 2; // NumberOfItems = 2
4781 NetworkTypeList[1] = Ndis802_11DS; // NetworkType[1] = 11b
4782 NetworkTypeList[2] = Ndis802_11OFDM24; // NetworkType[2] = 11g
4783 wrq->u.data.length = 12;
4784 Status = copy_to_user(wrq->u.data.pointer, &NetworkTypeList[0], wrq->u.data.length);
4786 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_NETWORK_TYPES_SUPPORTED\n"));
4788 case OID_802_11_NETWORK_TYPE_IN_USE:
4789 wrq->u.data.length = sizeof(ULONG);
4790 if (pAdapter->CommonCfg.PhyMode == PHY_11A)
4791 ulInfo = Ndis802_11OFDM5;
4792 else if ((pAdapter->CommonCfg.PhyMode == PHY_11BG_MIXED) || (pAdapter->CommonCfg.PhyMode == PHY_11G))
4793 ulInfo = Ndis802_11OFDM24;
4795 ulInfo = Ndis802_11DS;
4796 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4798 case RT_OID_802_11_QUERY_LAST_RX_RATE:
4799 ulInfo = (ULONG)pAdapter->LastRxRate;
4800 wrq->u.data.length = sizeof(ulInfo);
4801 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4802 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_LAST_RX_RATE (=%ld)\n", ulInfo));
4804 case RT_OID_802_11_QUERY_LAST_TX_RATE:
4805 //ulInfo = (ULONG)pAdapter->LastTxRate;
4806 ulInfo = (ULONG)pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.word;
4807 wrq->u.data.length = sizeof(ulInfo);
4808 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4809 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_LAST_TX_RATE (=%lx)\n", ulInfo));
4811 case RT_OID_802_11_QUERY_EEPROM_VERSION:
4812 wrq->u.data.length = sizeof(ULONG);
4813 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->EepromVersion, wrq->u.data.length);
4815 case RT_OID_802_11_QUERY_FIRMWARE_VERSION:
4816 wrq->u.data.length = sizeof(ULONG);
4817 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->FirmwareVersion, wrq->u.data.length);
4819 case RT_OID_802_11_QUERY_NOISE_LEVEL:
4820 wrq->u.data.length = sizeof(UCHAR);
4821 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->BbpWriteLatch[66], wrq->u.data.length);
4822 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_NOISE_LEVEL (=%d)\n", pAdapter->BbpWriteLatch[66]));
4824 case RT_OID_802_11_EXTRA_INFO:
4825 wrq->u.data.length = sizeof(ULONG);
4826 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->ExtraInfo, wrq->u.data.length);
4827 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_EXTRA_INFO (=%ld)\n", pAdapter->ExtraInfo));
4829 case RT_OID_WE_VERSION_COMPILED:
4830 wrq->u.data.length = sizeof(UINT);
4831 we_version_compiled = WIRELESS_EXT;
4832 Status = copy_to_user(wrq->u.data.pointer, &we_version_compiled, wrq->u.data.length);
4834 case RT_OID_802_11_QUERY_APSD_SETTING:
4835 apsd = (pAdapter->CommonCfg.bAPSDCapable | (pAdapter->CommonCfg.bAPSDAC_BE << 1) | (pAdapter->CommonCfg.bAPSDAC_BK << 2)
4836 | (pAdapter->CommonCfg.bAPSDAC_VI << 3) | (pAdapter->CommonCfg.bAPSDAC_VO << 4) | (pAdapter->CommonCfg.MaxSPLength << 5));
4838 wrq->u.data.length = sizeof(ULONG);
4839 Status = copy_to_user(wrq->u.data.pointer, &apsd, wrq->u.data.length);
4840 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",
4841 apsd,pAdapter->CommonCfg.bAPSDCapable,pAdapter->CommonCfg.bAPSDAC_BE,pAdapter->CommonCfg.bAPSDAC_BK,pAdapter->CommonCfg.bAPSDAC_VI,pAdapter->CommonCfg.bAPSDAC_VO,pAdapter->CommonCfg.MaxSPLength));
4843 case RT_OID_802_11_QUERY_APSD_PSM:
4844 wrq->u.data.length = sizeof(ULONG);
4845 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.bAPSDForcePowerSave, wrq->u.data.length);
4846 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_APSD_PSM (=%d)\n", pAdapter->CommonCfg.bAPSDForcePowerSave));
4848 case RT_OID_802_11_QUERY_WMM:
4849 wrq->u.data.length = sizeof(BOOLEAN);
4850 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.bWmmCapable, wrq->u.data.length);
4851 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_WMM (=%d)\n", pAdapter->CommonCfg.bWmmCapable));
4853 #ifdef WPA_SUPPLICANT_SUPPORT
4854 case RT_OID_NEW_DRIVER:
4857 wrq->u.data.length = sizeof(UCHAR);
4858 Status = copy_to_user(wrq->u.data.pointer, &enabled, wrq->u.data.length);
4859 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_NEW_DRIVER (=%d)\n", enabled));
4862 case RT_OID_WPA_SUPPLICANT_SUPPORT:
4863 wrq->u.data.length = sizeof(UCHAR);
4864 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->StaCfg.WpaSupplicantUP, wrq->u.data.length);
4865 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_WPA_SUPPLICANT_SUPPORT (=%d)\n", pAdapter->StaCfg.WpaSupplicantUP));
4867 #endif // WPA_SUPPLICANT_SUPPORT //
4869 case RT_OID_DRIVER_DEVICE_NAME:
4870 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_DRIVER_DEVICE_NAME \n"));
4871 wrq->u.data.length = 16;
4872 if (copy_to_user(wrq->u.data.pointer, pAdapter->StaCfg.dev_name, wrq->u.data.length))
4877 case RT_OID_802_11_QUERY_HT_PHYMODE:
4878 pHTPhyMode = (OID_SET_HT_PHYMODE *) kmalloc(sizeof(OID_SET_HT_PHYMODE), MEM_ALLOC_FLAG);
4881 pHTPhyMode->PhyMode = pAdapter->CommonCfg.PhyMode;
4882 pHTPhyMode->HtMode = (UCHAR)pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.field.MODE;
4883 pHTPhyMode->BW = (UCHAR)pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.field.BW;
4884 pHTPhyMode->MCS= (UCHAR)pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.field.MCS;
4885 pHTPhyMode->SHORTGI= (UCHAR)pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.field.ShortGI;
4886 pHTPhyMode->STBC= (UCHAR)pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.field.STBC;
4888 pHTPhyMode->ExtOffset = ((pAdapter->CommonCfg.CentralChannel < pAdapter->CommonCfg.Channel) ? (EXTCHA_BELOW) : (EXTCHA_ABOVE));
4889 wrq->u.data.length = sizeof(OID_SET_HT_PHYMODE);
4890 if (copy_to_user(wrq->u.data.pointer, pHTPhyMode, wrq->u.data.length))
4894 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_HT_PHYMODE (PhyMode = %d, MCS =%d, BW = %d, STBC = %d, ExtOffset=%d)\n",
4895 pHTPhyMode->HtMode, pHTPhyMode->MCS, pHTPhyMode->BW, pHTPhyMode->STBC, pHTPhyMode->ExtOffset));
4896 DBGPRINT(RT_DEBUG_TRACE, (" MlmeUpdateTxRates (.word = %x )\n", pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.word));
4900 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_STA_CONFIG(kmalloc failed)\n"));
4904 case RT_OID_802_11_COUNTRY_REGION:
4905 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_COUNTRY_REGION \n"));
4906 wrq->u.data.length = sizeof(ulInfo);
4907 ulInfo = pAdapter->CommonCfg.CountryRegionForABand;
4908 ulInfo = (ulInfo << 8)|(pAdapter->CommonCfg.CountryRegion);
4909 if (copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length))
4914 case RT_OID_802_11_QUERY_DAT_HT_PHYMODE:
4915 pHTPhyMode = (OID_SET_HT_PHYMODE *) kmalloc(sizeof(OID_SET_HT_PHYMODE), MEM_ALLOC_FLAG);
4918 pHTPhyMode->PhyMode = pAdapter->CommonCfg.PhyMode;
4919 pHTPhyMode->HtMode = (UCHAR)pAdapter->CommonCfg.RegTransmitSetting.field.HTMODE;
4920 pHTPhyMode->BW = (UCHAR)pAdapter->CommonCfg.RegTransmitSetting.field.BW;
4921 pHTPhyMode->MCS= (UCHAR)pAdapter->StaCfg.DesiredTransmitSetting.field.MCS;
4922 pHTPhyMode->SHORTGI= (UCHAR)pAdapter->CommonCfg.RegTransmitSetting.field.ShortGI;
4923 pHTPhyMode->STBC= (UCHAR)pAdapter->CommonCfg.RegTransmitSetting.field.STBC;
4925 wrq->u.data.length = sizeof(OID_SET_HT_PHYMODE);
4926 if (copy_to_user(wrq->u.data.pointer, pHTPhyMode, wrq->u.data.length))
4930 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_HT_PHYMODE (PhyMode = %d, MCS =%d, BW = %d, STBC = %d, ExtOffset=%d)\n",
4931 pHTPhyMode->HtMode, pHTPhyMode->MCS, pHTPhyMode->BW, pHTPhyMode->STBC, pHTPhyMode->ExtOffset));
4932 DBGPRINT(RT_DEBUG_TRACE, (" MlmeUpdateTxRates (.word = %x )\n", pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.word));
4936 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_STA_CONFIG(kmalloc failed)\n"));
4940 case RT_OID_QUERY_MULTIPLE_CARD_SUPPORT:
4941 wrq->u.data.length = sizeof(UCHAR);
4943 if (copy_to_user(wrq->u.data.pointer, &i, wrq->u.data.length))
4947 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_QUERY_MULTIPLE_CARD_SUPPORT(=%d) \n", i));
4950 case RT_OID_802_11_MAC_ADDRESS:
4951 wrq->u.data.length = MAC_ADDR_LEN;
4952 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CurrentAddress, wrq->u.data.length);
4955 case RT_OID_802_11_MANUFACTUREROUI:
4956 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_MANUFACTUREROUI \n"));
4957 wrq->u.data.length = ManufacturerOUI_LEN;
4958 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CurrentAddress, wrq->u.data.length);
4961 case RT_OID_802_11_MANUFACTURERNAME:
4962 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_MANUFACTURERNAME \n"));
4963 wrq->u.data.length = strlen(ManufacturerNAME);
4964 Status = copy_to_user(wrq->u.data.pointer, ManufacturerNAME, wrq->u.data.length);
4967 case RT_OID_802_11_RESOURCETYPEIDNAME:
4968 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_RESOURCETYPEIDNAME \n"));
4969 wrq->u.data.length = strlen(ResourceTypeIdName);
4970 Status = copy_to_user(wrq->u.data.pointer, ResourceTypeIdName, wrq->u.data.length);
4973 case RT_OID_802_11_PRIVACYOPTIONIMPLEMENTED:
4974 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_PRIVACYOPTIONIMPLEMENTED \n"));
4975 ulInfo = 1; // 1 is support wep else 2 is not support.
4976 wrq->u.data.length = sizeof(ulInfo);
4977 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4980 case RT_OID_802_11_POWERMANAGEMENTMODE:
4981 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_POWERMANAGEMENTMODE \n"));
4982 if (pAdapter->StaCfg.Psm == PSMP_ACTION)
4983 ulInfo = 1; // 1 is power active else 2 is power save.
4987 wrq->u.data.length = sizeof(ulInfo);
4988 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4991 case OID_802_11_WEPDEFAULTKEYVALUE:
4992 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_WEPDEFAULTKEYVALUE \n"));
4993 //KeyIdxValue.KeyIdx = pAd->PortCfg.MBSSID[pAd->IoctlIF].DefaultKeyId;
4994 pKeyIdxValue = wrq->u.data.pointer;
4995 DBGPRINT(RT_DEBUG_TRACE,("KeyIdxValue.KeyIdx = %d, \n",pKeyIdxValue->KeyIdx));
4996 valueLen = pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].KeyLen;
4997 NdisMoveMemory(pKeyIdxValue->Value,
4998 &pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].Key,
5000 pKeyIdxValue->Value[valueLen]='\0';
5002 wrq->u.data.length = sizeof(DefaultKeyIdxValue);
5004 Status = copy_to_user(wrq->u.data.pointer, pKeyIdxValue, wrq->u.data.length);
5005 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,
5006 pAdapter->SharedKey[BSS0][0].Key[0],
5007 pAdapter->SharedKey[BSS0][1].Key[0],
5008 pAdapter->SharedKey[BSS0][2].Key[0],
5009 pAdapter->SharedKey[BSS0][3].Key[0]));
5012 case OID_802_11_WEPDEFAULTKEYID:
5013 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_WEPDEFAULTKEYID \n"));
5014 wrq->u.data.length = sizeof(UCHAR);
5015 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->StaCfg.DefaultKeyId, wrq->u.data.length);
5016 DBGPRINT(RT_DEBUG_TRACE, ("DefaultKeyId =%d \n", pAdapter->StaCfg.DefaultKeyId));
5019 case RT_OID_802_11_WEPKEYMAPPINGLENGTH:
5020 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_WEPKEYMAPPINGLENGTH \n"));
5021 wrq->u.data.length = sizeof(UCHAR);
5022 Status = copy_to_user(wrq->u.data.pointer,
5023 &pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].KeyLen,
5024 wrq->u.data.length);
5027 case OID_802_11_SHORTRETRYLIMIT:
5028 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_SHORTRETRYLIMIT \n"));
5029 wrq->u.data.length = sizeof(ULONG);
5030 RTMP_IO_READ32(pAdapter, TX_RTY_CFG, &tx_rty_cfg.word);
5031 ShortRetryLimit = tx_rty_cfg.field.ShortRtyLimit;
5032 DBGPRINT(RT_DEBUG_TRACE, ("ShortRetryLimit =%ld, tx_rty_cfg.field.ShortRetryLimit=%d\n", ShortRetryLimit, tx_rty_cfg.field.ShortRtyLimit));
5033 Status = copy_to_user(wrq->u.data.pointer, &ShortRetryLimit, wrq->u.data.length);
5036 case OID_802_11_LONGRETRYLIMIT:
5037 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_LONGRETRYLIMIT \n"));
5038 wrq->u.data.length = sizeof(ULONG);
5039 RTMP_IO_READ32(pAdapter, TX_RTY_CFG, &tx_rty_cfg.word);
5040 LongRetryLimit = tx_rty_cfg.field.LongRtyLimit;
5041 DBGPRINT(RT_DEBUG_TRACE, ("LongRetryLimit =%ld, tx_rty_cfg.field.LongRtyLimit=%d\n", LongRetryLimit, tx_rty_cfg.field.LongRtyLimit));
5042 Status = copy_to_user(wrq->u.data.pointer, &LongRetryLimit, wrq->u.data.length);
5045 case RT_OID_802_11_PRODUCTID:
5046 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_PRODUCTID \n"));
5049 sprintf(tmp, "%04x %04x\n", ((POS_COOKIE)pAdapter->OS_Cookie)->pUsb_Dev->descriptor.idVendor ,((POS_COOKIE)pAdapter->OS_Cookie)->pUsb_Dev->descriptor.idProduct);
5052 wrq->u.data.length = strlen(tmp);
5053 Status = copy_to_user(wrq->u.data.pointer, tmp, wrq->u.data.length);
5056 case RT_OID_802_11_MANUFACTUREID:
5057 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_MANUFACTUREID \n"));
5058 wrq->u.data.length = strlen(ManufacturerNAME);
5059 Status = copy_to_user(wrq->u.data.pointer, ManufacturerNAME, wrq->u.data.length);
5062 case OID_802_11_CURRENTCHANNEL:
5063 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_CURRENTCHANNEL \n"));
5064 wrq->u.data.length = sizeof(UCHAR);
5065 DBGPRINT(RT_DEBUG_TRACE, ("sizeof UCHAR=%d, channel=%d \n", sizeof(UCHAR), pAdapter->CommonCfg.Channel));
5066 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.Channel, wrq->u.data.length);
5067 DBGPRINT(RT_DEBUG_TRACE, ("Status=%d\n", Status));
5069 #endif //SNMP_SUPPORT
5071 case OID_802_11_BUILD_CHANNEL_EX:
5074 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_BUILD_CHANNEL_EX \n"));
5075 wrq->u.data.length = sizeof(UCHAR);
5076 #ifdef EXT_BUILD_CHANNEL_LIST
5077 DBGPRINT(RT_DEBUG_TRACE, ("Support EXT_BUILD_CHANNEL_LIST.\n"));
5080 DBGPRINT(RT_DEBUG_TRACE, ("Doesn't support EXT_BUILD_CHANNEL_LIST.\n"));
5082 #endif // EXT_BUILD_CHANNEL_LIST //
5083 Status = copy_to_user(wrq->u.data.pointer, &value, 1);
5084 DBGPRINT(RT_DEBUG_TRACE, ("Status=%d\n", Status));
5088 case OID_802_11_GET_CH_LIST:
5090 PRT_CHANNEL_LIST_INFO pChListBuf;
5092 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_GET_CH_LIST \n"));
5093 if (pAdapter->ChannelListNum == 0)
5095 wrq->u.data.length = 0;
5099 pChListBuf = (RT_CHANNEL_LIST_INFO *) kmalloc(sizeof(RT_CHANNEL_LIST_INFO), MEM_ALLOC_FLAG);
5100 if (pChListBuf == NULL)
5102 wrq->u.data.length = 0;
5106 pChListBuf->ChannelListNum = pAdapter->ChannelListNum;
5107 for (i = 0; i < pChListBuf->ChannelListNum; i++)
5108 pChListBuf->ChannelList[i] = pAdapter->ChannelList[i].Channel;
5110 wrq->u.data.length = sizeof(RT_CHANNEL_LIST_INFO);
5111 Status = copy_to_user(wrq->u.data.pointer, pChListBuf, sizeof(RT_CHANNEL_LIST_INFO));
5112 DBGPRINT(RT_DEBUG_TRACE, ("Status=%d\n", Status));
5119 case OID_802_11_GET_COUNTRY_CODE:
5120 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_GET_COUNTRY_CODE \n"));
5121 wrq->u.data.length = 2;
5122 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.CountryCode, 2);
5123 DBGPRINT(RT_DEBUG_TRACE, ("Status=%d\n", Status));
5126 case OID_802_11_GET_CHANNEL_GEOGRAPHY:
5127 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_GET_CHANNEL_GEOGRAPHY \n"));
5128 wrq->u.data.length = 1;
5129 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.Geography, 1);
5130 DBGPRINT(RT_DEBUG_TRACE, ("Status=%d\n", Status));
5134 DBGPRINT(RT_DEBUG_TRACE, ("Query::unknown IOCTL's subcmd = 0x%08x\n", cmd));
5135 Status = -EOPNOTSUPP;
5141 INT rt28xx_sta_ioctl(
5142 IN struct net_device *net_dev,
5143 IN OUT struct ifreq *rq,
5147 VIRTUAL_ADAPTER *pVirtualAd = NULL;
5148 RTMP_ADAPTER *pAd = NULL;
5149 struct iwreq *wrq = (struct iwreq *) rq;
5150 BOOLEAN StateMachineTouched = FALSE;
5151 INT Status = NDIS_STATUS_SUCCESS;
5154 if (net_dev->priv_flags == INT_MAIN)
5156 pAd = net_dev->ml_priv;
5160 pVirtualAd = net_dev->ml_priv;
5161 pAd = pVirtualAd->RtmpDev->ml_priv;
5163 pObj = (POS_COOKIE) pAd->OS_Cookie;
5167 /* if 1st open fail, pAd will be free;
5168 So the net_dev->ml_priv will be NULL in 2rd open */
5172 //check if the interface is down
5173 if(!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_IN_USE))
5176 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
5181 { // determine this ioctl command is comming from which interface.
5182 pObj->ioctl_if_type = INT_MAIN;
5183 pObj->ioctl_if = MAIN_MBSSID;
5189 DBGPRINT(RT_DEBUG_TRACE, ("IOCTL::SIOCGIFHWADDR\n"));
5190 memcpy(wrq->u.name, pAd->CurrentAddress, ETH_ALEN);
5194 char *name=&wrq->u.name[0];
5195 rt_ioctl_giwname(net_dev, NULL, name, NULL);
5198 case SIOCGIWESSID: //Get ESSID
5200 struct iw_point *essid=&wrq->u.essid;
5201 rt_ioctl_giwessid(net_dev, NULL, essid, essid->pointer);
5204 case SIOCSIWESSID: //Set ESSID
5206 struct iw_point *essid=&wrq->u.essid;
5207 rt_ioctl_siwessid(net_dev, NULL, essid, essid->pointer);
5210 case SIOCSIWNWID: // set network id (the cell)
5211 case SIOCGIWNWID: // get network id
5212 Status = -EOPNOTSUPP;
5214 case SIOCSIWFREQ: //set channel/frequency (Hz)
5216 struct iw_freq *freq=&wrq->u.freq;
5217 rt_ioctl_siwfreq(net_dev, NULL, freq, NULL);
5220 case SIOCGIWFREQ: // get channel/frequency (Hz)
5222 struct iw_freq *freq=&wrq->u.freq;
5223 rt_ioctl_giwfreq(net_dev, NULL, freq, NULL);
5226 case SIOCSIWNICKN: //set node name/nickname
5228 struct iw_point *data=&wrq->u.data;
5229 rt_ioctl_siwnickn(net_dev, NULL, data, NULL);
5232 case SIOCGIWNICKN: //get node name/nickname
5234 struct iw_point *data=&wrq->u.data;
5235 rt_ioctl_giwnickn(net_dev, NULL, data, NULL);
5238 case SIOCGIWRATE: //get default bit rate (bps)
5239 rt_ioctl_giwrate(net_dev, NULL, &wrq->u, NULL);
5241 case SIOCSIWRATE: //set default bit rate (bps)
5242 rt_ioctl_siwrate(net_dev, NULL, &wrq->u, NULL);
5244 case SIOCGIWRTS: // get RTS/CTS threshold (bytes)
5246 struct iw_param *rts=&wrq->u.rts;
5247 rt_ioctl_giwrts(net_dev, NULL, rts, NULL);
5250 case SIOCSIWRTS: //set RTS/CTS threshold (bytes)
5252 struct iw_param *rts=&wrq->u.rts;
5253 rt_ioctl_siwrts(net_dev, NULL, rts, NULL);
5256 case SIOCGIWFRAG: //get fragmentation thr (bytes)
5258 struct iw_param *frag=&wrq->u.frag;
5259 rt_ioctl_giwfrag(net_dev, NULL, frag, NULL);
5262 case SIOCSIWFRAG: //set fragmentation thr (bytes)
5264 struct iw_param *frag=&wrq->u.frag;
5265 rt_ioctl_siwfrag(net_dev, NULL, frag, NULL);
5268 case SIOCGIWENCODE: //get encoding token & mode
5270 struct iw_point *erq=&wrq->u.encoding;
5272 rt_ioctl_giwencode(net_dev, NULL, erq, erq->pointer);
5275 case SIOCSIWENCODE: //set encoding token & mode
5277 struct iw_point *erq=&wrq->u.encoding;
5279 rt_ioctl_siwencode(net_dev, NULL, erq, erq->pointer);
5282 case SIOCGIWAP: //get access point MAC addresses
5284 struct sockaddr *ap_addr=&wrq->u.ap_addr;
5285 rt_ioctl_giwap(net_dev, NULL, ap_addr, ap_addr->sa_data);
5288 case SIOCSIWAP: //set access point MAC addresses
5290 struct sockaddr *ap_addr=&wrq->u.ap_addr;
5291 rt_ioctl_siwap(net_dev, NULL, ap_addr, ap_addr->sa_data);
5294 case SIOCGIWMODE: //get operation mode
5296 __u32 *mode=&wrq->u.mode;
5297 rt_ioctl_giwmode(net_dev, NULL, mode, NULL);
5300 case SIOCSIWMODE: //set operation mode
5302 __u32 *mode=&wrq->u.mode;
5303 rt_ioctl_siwmode(net_dev, NULL, mode, NULL);
5306 case SIOCGIWSENS: //get sensitivity (dBm)
5307 case SIOCSIWSENS: //set sensitivity (dBm)
5308 case SIOCGIWPOWER: //get Power Management settings
5309 case SIOCSIWPOWER: //set Power Management settings
5310 case SIOCGIWTXPOW: //get transmit power (dBm)
5311 case SIOCSIWTXPOW: //set transmit power (dBm)
5312 case SIOCGIWRANGE: //Get range of parameters
5313 case SIOCGIWRETRY: //get retry limits and lifetime
5314 case SIOCSIWRETRY: //set retry limits and lifetime
5315 Status = -EOPNOTSUPP;
5318 case RT_PRIV_IOCTL_EXT:
5319 subcmd = wrq->u.data.flags;
5320 if( subcmd & OID_GET_SET_TOGGLE)
5321 Status = RTMPSetInformation(pAd, rq, subcmd);
5323 Status = RTMPQueryInformation(pAd, rq, subcmd);
5326 if (wrq->u.data.pointer)
5328 if ( access_ok(VERIFY_WRITE, wrq->u.data.pointer, sizeof(privtab)) != TRUE)
5330 wrq->u.data.length = sizeof(privtab) / sizeof(privtab[0]);
5331 if (copy_to_user(wrq->u.data.pointer, privtab, sizeof(privtab)))
5335 case RTPRIV_IOCTL_SET:
5336 if(access_ok(VERIFY_READ, wrq->u.data.pointer, wrq->u.data.length) != TRUE)
5338 rt_ioctl_setparam(net_dev, NULL, NULL, wrq->u.data.pointer);
5340 case RTPRIV_IOCTL_GSITESURVEY:
5341 RTMPIoctlGetSiteSurvey(pAd, wrq);
5344 case RTPRIV_IOCTL_MAC:
5345 RTMPIoctlMAC(pAd, wrq);
5347 case RTPRIV_IOCTL_E2P:
5348 RTMPIoctlE2PROM(pAd, wrq);
5351 case RTPRIV_IOCTL_RF:
5352 RTMPIoctlRF(pAd, wrq);
5359 DBGPRINT(RT_DEBUG_ERROR, ("IOCTL::unknown IOCTL's cmd = 0x%08x\n", cmd));
5360 Status = -EOPNOTSUPP;
5364 if(StateMachineTouched) // Upper layer sent a MLME-related operations
5365 RT28XX_MLME_HANDLER(pAd);
5371 ==========================================================================
5375 TRUE if all parameters are OK, FALSE otherwise
5376 ==========================================================================
5379 IN PRTMP_ADAPTER pAdapter,
5382 NDIS_802_11_SSID Ssid, *pSsid=NULL;
5383 BOOLEAN StateMachineTouched = FALSE;
5386 if( strlen(arg) <= MAX_LEN_OF_SSID)
5388 NdisZeroMemory(&Ssid, sizeof(NDIS_802_11_SSID));
5389 if (strlen(arg) != 0)
5391 NdisMoveMemory(Ssid.Ssid, arg, strlen(arg));
5392 Ssid.SsidLength = strlen(arg);
5396 Ssid.SsidLength = 0;
5397 memcpy(Ssid.Ssid, "", 0);
5398 pAdapter->StaCfg.BssType = BSS_INFRA;
5399 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
5400 pAdapter->StaCfg.WepStatus = Ndis802_11EncryptionDisabled;
5404 if (pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE)
5406 RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
5407 DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
5410 pAdapter->MlmeAux.CurrReqIsFromNdis = TRUE;
5411 pAdapter->StaCfg.bScanReqIsFromWebUI = FALSE;
5412 pAdapter->bConfigChanged = TRUE;
5414 MlmeEnqueue(pAdapter,
5415 MLME_CNTL_STATE_MACHINE,
5417 sizeof(NDIS_802_11_SSID),
5420 StateMachineTouched = TRUE;
5421 DBGPRINT(RT_DEBUG_TRACE, ("Set_SSID_Proc::(Len=%d,Ssid=%s)\n", Ssid.SsidLength, Ssid.Ssid));
5426 if (StateMachineTouched) // Upper layer sent a MLME-related operations
5427 RT28XX_MLME_HANDLER(pAdapter);
5434 ==========================================================================
5436 Set WmmCapable Enable or Disable
5438 TRUE if all parameters are OK, FALSE otherwise
5439 ==========================================================================
5441 INT Set_WmmCapable_Proc(
5442 IN PRTMP_ADAPTER pAd,
5445 BOOLEAN bWmmCapable;
5447 bWmmCapable = simple_strtol(arg, 0, 10);
5449 if ((bWmmCapable == 1)
5451 && (pAd->NumberOfPipes >= 5)
5454 pAd->CommonCfg.bWmmCapable = TRUE;
5455 else if (bWmmCapable == 0)
5456 pAd->CommonCfg.bWmmCapable = FALSE;
5458 return FALSE; //Invalid argument
5460 DBGPRINT(RT_DEBUG_TRACE, ("Set_WmmCapable_Proc::(bWmmCapable=%d)\n",
5461 pAd->CommonCfg.bWmmCapable));
5465 #endif // WMM_SUPPORT //
5468 ==========================================================================
5470 Set Network Type(Infrastructure/Adhoc mode)
5472 TRUE if all parameters are OK, FALSE otherwise
5473 ==========================================================================
5475 INT Set_NetworkType_Proc(
5476 IN PRTMP_ADAPTER pAdapter,
5481 if (strcmp(arg, "Adhoc") == 0)
5483 if (pAdapter->StaCfg.BssType != BSS_ADHOC)
5485 // Config has changed
5486 pAdapter->bConfigChanged = TRUE;
5487 if (MONITOR_ON(pAdapter))
5489 RTMP_IO_WRITE32(pAdapter, RX_FILTR_CFG, STANORMAL);
5490 RTMP_IO_READ32(pAdapter, MAC_SYS_CTRL, &Value);
5492 RTMP_IO_WRITE32(pAdapter, MAC_SYS_CTRL, Value);
5493 OPSTATUS_CLEAR_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED);
5494 pAdapter->StaCfg.bAutoReconnect = TRUE;
5495 LinkDown(pAdapter, FALSE);
5497 if (INFRA_ON(pAdapter))
5499 //BOOLEAN Cancelled;
5500 // Set the AutoReconnectSsid to prevent it reconnect to old SSID
5501 // Since calling this indicate user don't want to connect to that SSID anymore.
5502 pAdapter->MlmeAux.AutoReconnectSsidLen= 32;
5503 NdisZeroMemory(pAdapter->MlmeAux.AutoReconnectSsid, pAdapter->MlmeAux.AutoReconnectSsidLen);
5505 LinkDown(pAdapter, FALSE);
5507 DBGPRINT(RT_DEBUG_TRACE, ("NDIS_STATUS_MEDIA_DISCONNECT Event BB!\n"));
5510 pAdapter->StaCfg.BssType = BSS_ADHOC;
5511 pAdapter->net_dev->type = pAdapter->StaCfg.OriDevType;
5512 DBGPRINT(RT_DEBUG_TRACE, ("===>Set_NetworkType_Proc::(AD-HOC)\n"));
5514 else if (strcmp(arg, "Infra") == 0)
5516 if (pAdapter->StaCfg.BssType != BSS_INFRA)
5518 // Config has changed
5519 pAdapter->bConfigChanged = TRUE;
5520 if (MONITOR_ON(pAdapter))
5522 RTMP_IO_WRITE32(pAdapter, RX_FILTR_CFG, STANORMAL);
5523 RTMP_IO_READ32(pAdapter, MAC_SYS_CTRL, &Value);
5525 RTMP_IO_WRITE32(pAdapter, MAC_SYS_CTRL, Value);
5526 OPSTATUS_CLEAR_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED);
5527 pAdapter->StaCfg.bAutoReconnect = TRUE;
5528 LinkDown(pAdapter, FALSE);
5530 if (ADHOC_ON(pAdapter))
5532 // Set the AutoReconnectSsid to prevent it reconnect to old SSID
5533 // Since calling this indicate user don't want to connect to that SSID anymore.
5534 pAdapter->MlmeAux.AutoReconnectSsidLen= 32;
5535 NdisZeroMemory(pAdapter->MlmeAux.AutoReconnectSsid, pAdapter->MlmeAux.AutoReconnectSsidLen);
5537 LinkDown(pAdapter, FALSE);
5540 pAdapter->StaCfg.BssType = BSS_INFRA;
5541 pAdapter->net_dev->type = pAdapter->StaCfg.OriDevType;
5542 DBGPRINT(RT_DEBUG_TRACE, ("===>Set_NetworkType_Proc::(INFRA)\n"));
5544 pAdapter->StaCfg.BssType = BSS_INFRA;
5546 else if (strcmp(arg, "Monitor") == 0)
5549 BCN_TIME_CFG_STRUC csr;
5550 OPSTATUS_CLEAR_FLAG(pAdapter, fOP_STATUS_INFRA_ON);
5551 OPSTATUS_CLEAR_FLAG(pAdapter, fOP_STATUS_ADHOC_ON);
5552 OPSTATUS_SET_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED);
5553 // disable all periodic state machine
5554 pAdapter->StaCfg.bAutoReconnect = FALSE;
5555 // reset all mlme state machine
5556 RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
5557 DBGPRINT(RT_DEBUG_TRACE, ("fOP_STATUS_MEDIA_STATE_CONNECTED \n"));
5558 if (pAdapter->CommonCfg.CentralChannel == 0)
5560 #ifdef DOT11_N_SUPPORT
5561 if (pAdapter->CommonCfg.PhyMode == PHY_11AN_MIXED)
5562 pAdapter->CommonCfg.CentralChannel = 36;
5564 #endif // DOT11_N_SUPPORT //
5565 pAdapter->CommonCfg.CentralChannel = 6;
5567 #ifdef DOT11_N_SUPPORT
5569 N_ChannelCheck(pAdapter);
5570 #endif // DOT11_N_SUPPORT //
5572 #ifdef DOT11_N_SUPPORT
5573 if (pAdapter->CommonCfg.PhyMode >= PHY_11ABGN_MIXED &&
5574 pAdapter->CommonCfg.RegTransmitSetting.field.BW == BW_40 &&
5575 pAdapter->CommonCfg.RegTransmitSetting.field.EXTCHA == EXTCHA_ABOVE)
5577 // 40MHz ,control channel at lower
5578 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, BBP_R4, &bbpValue);
5579 bbpValue &= (~0x18);
5581 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R4, bbpValue);
5582 pAdapter->CommonCfg.BBPCurrentBW = BW_40;
5583 // RX : control channel at lower
5584 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, BBP_R3, &bbpValue);
5585 bbpValue &= (~0x20);
5586 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R3, bbpValue);
5588 RTMP_IO_READ32(pAdapter, TX_BAND_CFG, &Value);
5589 Value &= 0xfffffffe;
5590 RTMP_IO_WRITE32(pAdapter, TX_BAND_CFG, Value);
5591 pAdapter->CommonCfg.CentralChannel = pAdapter->CommonCfg.Channel + 2;
5592 AsicSwitchChannel(pAdapter, pAdapter->CommonCfg.CentralChannel, FALSE);
5593 AsicLockChannel(pAdapter, pAdapter->CommonCfg.CentralChannel);
5594 DBGPRINT(RT_DEBUG_TRACE, ("BW_40 ,control_channel(%d), CentralChannel(%d) \n",
5595 pAdapter->CommonCfg.Channel,
5596 pAdapter->CommonCfg.CentralChannel));
5598 else if (pAdapter->CommonCfg.PhyMode >= PHY_11ABGN_MIXED &&
5599 pAdapter->CommonCfg.RegTransmitSetting.field.BW == BW_40 &&
5600 pAdapter->CommonCfg.RegTransmitSetting.field.EXTCHA == EXTCHA_BELOW)
5602 // 40MHz ,control channel at upper
5603 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, BBP_R4, &bbpValue);
5604 bbpValue &= (~0x18);
5606 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R4, bbpValue);
5607 pAdapter->CommonCfg.BBPCurrentBW = BW_40;
5608 RTMP_IO_READ32(pAdapter, TX_BAND_CFG, &Value);
5610 RTMP_IO_WRITE32(pAdapter, TX_BAND_CFG, Value);
5612 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, BBP_R3, &bbpValue);
5614 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R3, bbpValue);
5615 pAdapter->CommonCfg.CentralChannel = pAdapter->CommonCfg.Channel - 2;
5616 AsicSwitchChannel(pAdapter, pAdapter->CommonCfg.CentralChannel, FALSE);
5617 AsicLockChannel(pAdapter, pAdapter->CommonCfg.CentralChannel);
5618 DBGPRINT(RT_DEBUG_TRACE, ("BW_40 ,control_channel(%d), CentralChannel(%d) \n",
5619 pAdapter->CommonCfg.Channel,
5620 pAdapter->CommonCfg.CentralChannel));
5623 #endif // DOT11_N_SUPPORT //
5626 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, BBP_R4, &bbpValue);
5627 bbpValue &= (~0x18);
5628 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R4, bbpValue);
5629 pAdapter->CommonCfg.BBPCurrentBW = BW_20;
5630 AsicSwitchChannel(pAdapter, pAdapter->CommonCfg.Channel, FALSE);
5631 AsicLockChannel(pAdapter, pAdapter->CommonCfg.Channel);
5632 DBGPRINT(RT_DEBUG_TRACE, ("BW_20, Channel(%d)\n", pAdapter->CommonCfg.Channel));
5634 // Enable Rx with promiscuous reception
5635 RTMP_IO_WRITE32(pAdapter, RX_FILTR_CFG, 0x3);
5636 // ASIC supporsts sniffer function with replacing RSSI with timestamp.
5637 //RTMP_IO_READ32(pAdapter, MAC_SYS_CTRL, &Value);
5639 //RTMP_IO_WRITE32(pAdapter, MAC_SYS_CTRL, Value);
5641 RTMP_IO_READ32(pAdapter, BCN_TIME_CFG, &csr.word);
5642 csr.field.bBeaconGen = 0;
5643 csr.field.bTBTTEnable = 0;
5644 csr.field.TsfSyncMode = 0;
5645 RTMP_IO_WRITE32(pAdapter, BCN_TIME_CFG, csr.word);
5647 pAdapter->StaCfg.BssType = BSS_MONITOR;
5648 pAdapter->net_dev->type = ARPHRD_IEEE80211_PRISM; //ARPHRD_IEEE80211; // IEEE80211
5649 DBGPRINT(RT_DEBUG_TRACE, ("===>Set_NetworkType_Proc::(MONITOR)\n"));
5652 // Reset Ralink supplicant to not use, it will be set to start when UI set PMK key
5653 pAdapter->StaCfg.WpaState = SS_NOTUSE;
5655 DBGPRINT(RT_DEBUG_TRACE, ("Set_NetworkType_Proc::(NetworkType=%d)\n", pAdapter->StaCfg.BssType));
5661 ==========================================================================
5663 Set Authentication mode
5665 TRUE if all parameters are OK, FALSE otherwise
5666 ==========================================================================
5668 INT Set_AuthMode_Proc(
5669 IN PRTMP_ADAPTER pAdapter,
5672 if ((strcmp(arg, "WEPAUTO") == 0) || (strcmp(arg, "wepauto") == 0))
5673 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeAutoSwitch;
5674 else if ((strcmp(arg, "OPEN") == 0) || (strcmp(arg, "open") == 0))
5675 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
5676 else if ((strcmp(arg, "SHARED") == 0) || (strcmp(arg, "shared") == 0))
5677 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeShared;
5678 else if ((strcmp(arg, "WPAPSK") == 0) || (strcmp(arg, "wpapsk") == 0))
5679 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPAPSK;
5680 else if ((strcmp(arg, "WPANONE") == 0) || (strcmp(arg, "wpanone") == 0))
5681 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPANone;
5682 else if ((strcmp(arg, "WPA2PSK") == 0) || (strcmp(arg, "wpa2psk") == 0))
5683 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA2PSK;
5684 #ifdef WPA_SUPPLICANT_SUPPORT
5685 else if ((strcmp(arg, "WPA") == 0) || (strcmp(arg, "wpa") == 0))
5686 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA;
5687 else if ((strcmp(arg, "WPA2") == 0) || (strcmp(arg, "wpa2") == 0))
5688 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA2;
5689 #endif // WPA_SUPPLICANT_SUPPORT //
5693 pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED;
5695 DBGPRINT(RT_DEBUG_TRACE, ("Set_AuthMode_Proc::(AuthMode=%d)\n", pAdapter->StaCfg.AuthMode));
5701 ==========================================================================
5705 TRUE if all parameters are OK, FALSE otherwise
5706 ==========================================================================
5708 INT Set_EncrypType_Proc(
5709 IN PRTMP_ADAPTER pAdapter,
5712 if ((strcmp(arg, "NONE") == 0) || (strcmp(arg, "none") == 0))
5714 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
5715 return TRUE; // do nothing
5717 pAdapter->StaCfg.WepStatus = Ndis802_11WEPDisabled;
5718 pAdapter->StaCfg.PairCipher = Ndis802_11WEPDisabled;
5719 pAdapter->StaCfg.GroupCipher = Ndis802_11WEPDisabled;
5721 else if ((strcmp(arg, "WEP") == 0) || (strcmp(arg, "wep") == 0))
5723 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
5724 return TRUE; // do nothing
5726 pAdapter->StaCfg.WepStatus = Ndis802_11WEPEnabled;
5727 pAdapter->StaCfg.PairCipher = Ndis802_11WEPEnabled;
5728 pAdapter->StaCfg.GroupCipher = Ndis802_11WEPEnabled;
5730 else if ((strcmp(arg, "TKIP") == 0) || (strcmp(arg, "tkip") == 0))
5732 if (pAdapter->StaCfg.AuthMode < Ndis802_11AuthModeWPA)
5733 return TRUE; // do nothing
5735 pAdapter->StaCfg.WepStatus = Ndis802_11Encryption2Enabled;
5736 pAdapter->StaCfg.PairCipher = Ndis802_11Encryption2Enabled;
5737 pAdapter->StaCfg.GroupCipher = Ndis802_11Encryption2Enabled;
5739 else if ((strcmp(arg, "AES") == 0) || (strcmp(arg, "aes") == 0))
5741 if (pAdapter->StaCfg.AuthMode < Ndis802_11AuthModeWPA)
5742 return TRUE; // do nothing
5744 pAdapter->StaCfg.WepStatus = Ndis802_11Encryption3Enabled;
5745 pAdapter->StaCfg.PairCipher = Ndis802_11Encryption3Enabled;
5746 pAdapter->StaCfg.GroupCipher = Ndis802_11Encryption3Enabled;
5751 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
5753 DBGPRINT(RT_DEBUG_TRACE, ("Set_EncrypType_Proc::(EncrypType=%d)\n", pAdapter->StaCfg.WepStatus));
5759 ==========================================================================
5763 TRUE if all parameters are OK, FALSE otherwise
5764 ==========================================================================
5766 INT Set_DefaultKeyID_Proc(
5767 IN PRTMP_ADAPTER pAdapter,
5772 KeyIdx = simple_strtol(arg, 0, 10);
5773 if((KeyIdx >= 1 ) && (KeyIdx <= 4))
5774 pAdapter->StaCfg.DefaultKeyId = (UCHAR) (KeyIdx - 1 );
5776 return FALSE; //Invalid argument
5778 DBGPRINT(RT_DEBUG_TRACE, ("Set_DefaultKeyID_Proc::(DefaultKeyID=%d)\n", pAdapter->StaCfg.DefaultKeyId));
5784 ==========================================================================
5788 TRUE if all parameters are OK, FALSE otherwise
5789 ==========================================================================
5792 IN PRTMP_ADAPTER pAdapter,
5797 UCHAR CipherAlg=CIPHER_WEP64;
5799 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
5800 return TRUE; // do nothing
5802 KeyLen = strlen(arg);
5806 case 5: //wep 40 Ascii type
5807 pAdapter->SharedKey[BSS0][0].KeyLen = KeyLen;
5808 memcpy(pAdapter->SharedKey[BSS0][0].Key, arg, KeyLen);
5809 CipherAlg = CIPHER_WEP64;
5810 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key1_Proc::(Key1=%s and type=%s)\n", arg, "Ascii"));
5812 case 10: //wep 40 Hex type
5813 for(i=0; i < KeyLen; i++)
5815 if( !isxdigit(*(arg+i)) )
5816 return FALSE; //Not Hex value;
5818 pAdapter->SharedKey[BSS0][0].KeyLen = KeyLen / 2 ;
5819 AtoH(arg, pAdapter->SharedKey[BSS0][0].Key, KeyLen / 2);
5820 CipherAlg = CIPHER_WEP64;
5821 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key1_Proc::(Key1=%s and type=%s)\n", arg, "Hex"));
5823 case 13: //wep 104 Ascii type
5824 pAdapter->SharedKey[BSS0][0].KeyLen = KeyLen;
5825 memcpy(pAdapter->SharedKey[BSS0][0].Key, arg, KeyLen);
5826 CipherAlg = CIPHER_WEP128;
5827 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key1_Proc::(Key1=%s and type=%s)\n", arg, "Ascii"));
5829 case 26: //wep 104 Hex type
5830 for(i=0; i < KeyLen; i++)
5832 if( !isxdigit(*(arg+i)) )
5833 return FALSE; //Not Hex value;
5835 pAdapter->SharedKey[BSS0][0].KeyLen = KeyLen / 2 ;
5836 AtoH(arg, pAdapter->SharedKey[BSS0][0].Key, KeyLen / 2);
5837 CipherAlg = CIPHER_WEP128;
5838 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key1_Proc::(Key1=%s and type=%s)\n", arg, "Hex"));
5840 default: //Invalid argument
5841 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key1_Proc::Invalid argument (=%s)\n", arg));
5845 pAdapter->SharedKey[BSS0][0].CipherAlg = CipherAlg;
5847 // Set keys (into ASIC)
5848 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
5850 else // Old WEP stuff
5852 AsicAddSharedKeyEntry(pAdapter,
5855 pAdapter->SharedKey[BSS0][0].CipherAlg,
5856 pAdapter->SharedKey[BSS0][0].Key,
5864 ==========================================================================
5869 TRUE if all parameters are OK, FALSE otherwise
5870 ==========================================================================
5873 IN PRTMP_ADAPTER pAdapter,
5878 UCHAR CipherAlg=CIPHER_WEP64;
5880 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
5881 return TRUE; // do nothing
5883 KeyLen = strlen(arg);
5887 case 5: //wep 40 Ascii type
5888 pAdapter->SharedKey[BSS0][1].KeyLen = KeyLen;
5889 memcpy(pAdapter->SharedKey[BSS0][1].Key, arg, KeyLen);
5890 CipherAlg = CIPHER_WEP64;
5891 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key2_Proc::(Key2=%s and type=%s)\n", arg, "Ascii"));
5893 case 10: //wep 40 Hex type
5894 for(i=0; i < KeyLen; i++)
5896 if( !isxdigit(*(arg+i)) )
5897 return FALSE; //Not Hex value;
5899 pAdapter->SharedKey[BSS0][1].KeyLen = KeyLen / 2 ;
5900 AtoH(arg, pAdapter->SharedKey[BSS0][1].Key, KeyLen / 2);
5901 CipherAlg = CIPHER_WEP64;
5902 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key2_Proc::(Key2=%s and type=%s)\n", arg, "Hex"));
5904 case 13: //wep 104 Ascii type
5905 pAdapter->SharedKey[BSS0][1].KeyLen = KeyLen;
5906 memcpy(pAdapter->SharedKey[BSS0][1].Key, arg, KeyLen);
5907 CipherAlg = CIPHER_WEP128;
5908 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key2_Proc::(Key2=%s and type=%s)\n", arg, "Ascii"));
5910 case 26: //wep 104 Hex type
5911 for(i=0; i < KeyLen; i++)
5913 if( !isxdigit(*(arg+i)) )
5914 return FALSE; //Not Hex value;
5916 pAdapter->SharedKey[BSS0][1].KeyLen = KeyLen / 2 ;
5917 AtoH(arg, pAdapter->SharedKey[BSS0][1].Key, KeyLen / 2);
5918 CipherAlg = CIPHER_WEP128;
5919 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key2_Proc::(Key2=%s and type=%s)\n", arg, "Hex"));
5921 default: //Invalid argument
5922 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key2_Proc::Invalid argument (=%s)\n", arg));
5925 pAdapter->SharedKey[BSS0][1].CipherAlg = CipherAlg;
5927 // Set keys (into ASIC)
5928 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
5930 else // Old WEP stuff
5932 AsicAddSharedKeyEntry(pAdapter,
5935 pAdapter->SharedKey[BSS0][1].CipherAlg,
5936 pAdapter->SharedKey[BSS0][1].Key,
5944 ==========================================================================
5948 TRUE if all parameters are OK, FALSE otherwise
5949 ==========================================================================
5952 IN PRTMP_ADAPTER pAdapter,
5957 UCHAR CipherAlg=CIPHER_WEP64;
5959 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
5960 return TRUE; // do nothing
5962 KeyLen = strlen(arg);
5966 case 5: //wep 40 Ascii type
5967 pAdapter->SharedKey[BSS0][2].KeyLen = KeyLen;
5968 memcpy(pAdapter->SharedKey[BSS0][2].Key, arg, KeyLen);
5969 CipherAlg = CIPHER_WEP64;
5970 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key3_Proc::(Key3=%s and type=Ascii)\n", arg));
5972 case 10: //wep 40 Hex type
5973 for(i=0; i < KeyLen; i++)
5975 if( !isxdigit(*(arg+i)) )
5976 return FALSE; //Not Hex value;
5978 pAdapter->SharedKey[BSS0][2].KeyLen = KeyLen / 2 ;
5979 AtoH(arg, pAdapter->SharedKey[BSS0][2].Key, KeyLen / 2);
5980 CipherAlg = CIPHER_WEP64;
5981 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key3_Proc::(Key3=%s and type=Hex)\n", arg));
5983 case 13: //wep 104 Ascii type
5984 pAdapter->SharedKey[BSS0][2].KeyLen = KeyLen;
5985 memcpy(pAdapter->SharedKey[BSS0][2].Key, arg, KeyLen);
5986 CipherAlg = CIPHER_WEP128;
5987 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key3_Proc::(Key3=%s and type=Ascii)\n", arg));
5989 case 26: //wep 104 Hex type
5990 for(i=0; i < KeyLen; i++)
5992 if( !isxdigit(*(arg+i)) )
5993 return FALSE; //Not Hex value;
5995 pAdapter->SharedKey[BSS0][2].KeyLen = KeyLen / 2 ;
5996 AtoH(arg, pAdapter->SharedKey[BSS0][2].Key, KeyLen / 2);
5997 CipherAlg = CIPHER_WEP128;
5998 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key3_Proc::(Key3=%s and type=Hex)\n", arg));
6000 default: //Invalid argument
6001 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key3_Proc::Invalid argument (=%s)\n", arg));
6004 pAdapter->SharedKey[BSS0][2].CipherAlg = CipherAlg;
6006 // Set keys (into ASIC)
6007 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
6009 else // Old WEP stuff
6011 AsicAddSharedKeyEntry(pAdapter,
6014 pAdapter->SharedKey[BSS0][2].CipherAlg,
6015 pAdapter->SharedKey[BSS0][2].Key,
6023 ==========================================================================
6027 TRUE if all parameters are OK, FALSE otherwise
6028 ==========================================================================
6031 IN PRTMP_ADAPTER pAdapter,
6036 UCHAR CipherAlg=CIPHER_WEP64;
6038 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
6039 return TRUE; // do nothing
6041 KeyLen = strlen(arg);
6045 case 5: //wep 40 Ascii type
6046 pAdapter->SharedKey[BSS0][3].KeyLen = KeyLen;
6047 memcpy(pAdapter->SharedKey[BSS0][3].Key, arg, KeyLen);
6048 CipherAlg = CIPHER_WEP64;
6049 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key4_Proc::(Key4=%s and type=%s)\n", arg, "Ascii"));
6051 case 10: //wep 40 Hex type
6052 for(i=0; i < KeyLen; i++)
6054 if( !isxdigit(*(arg+i)) )
6055 return FALSE; //Not Hex value;
6057 pAdapter->SharedKey[BSS0][3].KeyLen = KeyLen / 2 ;
6058 AtoH(arg, pAdapter->SharedKey[BSS0][3].Key, KeyLen / 2);
6059 CipherAlg = CIPHER_WEP64;
6060 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key4_Proc::(Key4=%s and type=%s)\n", arg, "Hex"));
6062 case 13: //wep 104 Ascii type
6063 pAdapter->SharedKey[BSS0][3].KeyLen = KeyLen;
6064 memcpy(pAdapter->SharedKey[BSS0][3].Key, arg, KeyLen);
6065 CipherAlg = CIPHER_WEP128;
6066 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key4_Proc::(Key4=%s and type=%s)\n", arg, "Ascii"));
6068 case 26: //wep 104 Hex type
6069 for(i=0; i < KeyLen; i++)
6071 if( !isxdigit(*(arg+i)) )
6072 return FALSE; //Not Hex value;
6074 pAdapter->SharedKey[BSS0][3].KeyLen = KeyLen / 2 ;
6075 AtoH(arg, pAdapter->SharedKey[BSS0][3].Key, KeyLen / 2);
6076 CipherAlg = CIPHER_WEP128;
6077 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key4_Proc::(Key4=%s and type=%s)\n", arg, "Hex"));
6079 default: //Invalid argument
6080 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key4_Proc::Invalid argument (=%s)\n", arg));
6083 pAdapter->SharedKey[BSS0][3].CipherAlg = CipherAlg;
6085 // Set keys (into ASIC)
6086 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
6088 else // Old WEP stuff
6090 AsicAddSharedKeyEntry(pAdapter,
6093 pAdapter->SharedKey[BSS0][3].CipherAlg,
6094 pAdapter->SharedKey[BSS0][3].Key,
6103 ==========================================================================
6107 TRUE if all parameters are OK, FALSE otherwise
6108 ==========================================================================
6110 INT Set_WPAPSK_Proc(
6111 IN PRTMP_ADAPTER pAdapter,
6114 UCHAR keyMaterial[40];
6116 if ((pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPAPSK) &&
6117 (pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPA2PSK) &&
6118 (pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPANone)
6120 return TRUE; // do nothing
6122 DBGPRINT(RT_DEBUG_TRACE, ("Set_WPAPSK_Proc::(WPAPSK=%s)\n", arg));
6124 NdisZeroMemory(keyMaterial, 40);
6126 if ((strlen(arg) < 8) || (strlen(arg) > 64))
6128 DBGPRINT(RT_DEBUG_TRACE, ("Set failed!!(WPAPSK=%s), WPAPSK key-string required 8 ~ 64 characters \n", arg));
6132 if (strlen(arg) == 64)
6134 AtoH(arg, keyMaterial, 32);
6135 NdisMoveMemory(pAdapter->StaCfg.PMK, keyMaterial, 32);
6140 PasswordHash((char *)arg, pAdapter->MlmeAux.Ssid, pAdapter->MlmeAux.SsidLen, keyMaterial);
6141 NdisMoveMemory(pAdapter->StaCfg.PMK, keyMaterial, 32);
6146 if(pAdapter->StaCfg.BssType == BSS_ADHOC &&
6147 pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPANone)
6149 pAdapter->StaCfg.WpaState = SS_NOTUSE;
6153 // Start STA supplicant state machine
6154 pAdapter->StaCfg.WpaState = SS_START;
6161 ==========================================================================
6163 Set Power Saving mode
6165 TRUE if all parameters are OK, FALSE otherwise
6166 ==========================================================================
6168 INT Set_PSMode_Proc(
6169 IN PRTMP_ADAPTER pAdapter,
6172 if (pAdapter->StaCfg.BssType == BSS_INFRA)
6174 if ((strcmp(arg, "Max_PSP") == 0) ||
6175 (strcmp(arg, "max_psp") == 0) ||
6176 (strcmp(arg, "MAX_PSP") == 0))
6178 // do NOT turn on PSM bit here, wait until MlmeCheckForPsmChange()
6179 // to exclude certain situations.
6180 if (pAdapter->StaCfg.bWindowsACCAMEnable == FALSE)
6181 pAdapter->StaCfg.WindowsPowerMode = Ndis802_11PowerModeMAX_PSP;
6182 pAdapter->StaCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeMAX_PSP;
6183 OPSTATUS_SET_FLAG(pAdapter, fOP_STATUS_RECEIVE_DTIM);
6184 pAdapter->StaCfg.DefaultListenCount = 5;
6187 else if ((strcmp(arg, "Fast_PSP") == 0) ||
6188 (strcmp(arg, "fast_psp") == 0) ||
6189 (strcmp(arg, "FAST_PSP") == 0))
6191 // do NOT turn on PSM bit here, wait until MlmeCheckForPsmChange()
6192 // to exclude certain situations.
6193 OPSTATUS_SET_FLAG(pAdapter, fOP_STATUS_RECEIVE_DTIM);
6194 if (pAdapter->StaCfg.bWindowsACCAMEnable == FALSE)
6195 pAdapter->StaCfg.WindowsPowerMode = Ndis802_11PowerModeFast_PSP;
6196 pAdapter->StaCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeFast_PSP;
6197 pAdapter->StaCfg.DefaultListenCount = 3;
6199 else if ((strcmp(arg, "Legacy_PSP") == 0) ||
6200 (strcmp(arg, "legacy_psp") == 0) ||
6201 (strcmp(arg, "LEGACY_PSP") == 0))
6203 // do NOT turn on PSM bit here, wait until MlmeCheckForPsmChange()
6204 // to exclude certain situations.
6205 OPSTATUS_SET_FLAG(pAdapter, fOP_STATUS_RECEIVE_DTIM);
6206 if (pAdapter->StaCfg.bWindowsACCAMEnable == FALSE)
6207 pAdapter->StaCfg.WindowsPowerMode = Ndis802_11PowerModeLegacy_PSP;
6208 pAdapter->StaCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeLegacy_PSP;
6209 pAdapter->StaCfg.DefaultListenCount = 3;
6213 //Default Ndis802_11PowerModeCAM
6214 // clear PSM bit immediately
6215 MlmeSetPsmBit(pAdapter, PWR_ACTIVE);
6216 OPSTATUS_SET_FLAG(pAdapter, fOP_STATUS_RECEIVE_DTIM);
6217 if (pAdapter->StaCfg.bWindowsACCAMEnable == FALSE)
6218 pAdapter->StaCfg.WindowsPowerMode = Ndis802_11PowerModeCAM;
6219 pAdapter->StaCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeCAM;
6222 DBGPRINT(RT_DEBUG_TRACE, ("Set_PSMode_Proc::(PSMode=%ld)\n", pAdapter->StaCfg.WindowsPowerMode));
6231 #ifdef WPA_SUPPLICANT_SUPPORT
6233 ==========================================================================
6235 Set WpaSupport flag.
6237 0: Driver ignore wpa_supplicant.
6238 1: wpa_supplicant initiates scanning and AP selection.
6239 2: driver takes care of scanning, AP selection, and IEEE 802.11 association parameters.
6241 TRUE if all parameters are OK, FALSE otherwise
6242 ==========================================================================
6244 INT Set_Wpa_Support(
6245 IN PRTMP_ADAPTER pAd,
6249 if ( simple_strtol(arg, 0, 10) == 0)
6250 pAd->StaCfg.WpaSupplicantUP = WPA_SUPPLICANT_DISABLE;
6251 else if ( simple_strtol(arg, 0, 10) == 1)
6252 pAd->StaCfg.WpaSupplicantUP = WPA_SUPPLICANT_ENABLE;
6253 else if ( simple_strtol(arg, 0, 10) == 2)
6254 pAd->StaCfg.WpaSupplicantUP = WPA_SUPPLICANT_ENABLE_WITH_WEB_UI;
6256 pAd->StaCfg.WpaSupplicantUP = WPA_SUPPLICANT_DISABLE;
6258 DBGPRINT(RT_DEBUG_TRACE, ("Set_Wpa_Support::(WpaSupplicantUP=%d)\n", pAd->StaCfg.WpaSupplicantUP));
6262 #endif // WPA_SUPPLICANT_SUPPORT //
6266 ==========================================================================
6270 pAdapter Pointer to our adapter
6271 wrq Pointer to the ioctl argument
6278 1.) iwpriv ra0 mac 0 ==> read MAC where Addr=0x0
6279 2.) iwpriv ra0 mac 0=12 ==> write MAC where Addr=0x0, value=12
6280 ==========================================================================
6283 IN PRTMP_ADAPTER pAdapter,
6284 IN struct iwreq *wrq)
6292 UCHAR temp[16], temp2[16];
6293 UINT32 macValue = 0;
6295 BOOLEAN bIsPrintAllMAC = FALSE;
6298 memset(msg, 0x00, 1024);
6299 if (wrq->u.data.length > 1) //No parameters.
6301 Status = copy_from_user(arg, wrq->u.data.pointer, (wrq->u.data.length > 255) ? 255 : wrq->u.data.length);
6304 //Parsing Read or Write
6309 if ((value = rtstrchr(this_char, '=')) != NULL)
6312 if (!value || !*value)
6315 if(strlen(this_char) > 4)
6318 j = strlen(this_char);
6321 if(this_char[j] > 'f' || this_char[j] < '0')
6326 k = j = strlen(this_char);
6329 this_char[4-k+j] = this_char[j];
6333 this_char[3-k++]='0';
6336 if(strlen(this_char) == 4)
6338 AtoH(this_char, temp, 2);
6339 macAddr = *temp*256 + temp[1];
6340 if (macAddr < 0xFFFF)
6342 RTMP_IO_READ32(pAdapter, macAddr, &macValue);
6343 DBGPRINT(RT_DEBUG_TRACE, ("MacAddr=%lx, MacValue=%x\n", macAddr, macValue));
6344 sprintf(msg+strlen(msg), "[0x%08lX]:%08X ", macAddr , macValue);
6347 {//Invalid parametes, so default printk all mac
6348 bIsPrintAllMAC = TRUE;
6355 memcpy(&temp2, value, strlen(value));
6356 temp2[strlen(value)] = '\0';
6359 if((strlen(this_char) > 4) || strlen(temp2) > 8)
6362 j = strlen(this_char);
6365 if(this_char[j] > 'f' || this_char[j] < '0')
6372 if(temp2[j] > 'f' || temp2[j] < '0')
6377 k = j = strlen(this_char);
6380 this_char[4-k+j] = this_char[j];
6384 this_char[3-k++]='0';
6388 k = j = strlen(temp2);
6391 temp2[8-k+j] = temp2[j];
6399 AtoH(this_char, temp, 2);
6400 macAddr = *temp*256 + temp[1];
6402 AtoH(temp2, temp, 4);
6403 macValue = *temp*256*256*256 + temp[1]*256*256 + temp[2]*256 + temp[3];
6406 if (macAddr == (HW_DEBUG_SETTING_BASE + 4))
6408 // 0x2bf4: byte0 non-zero: enable R17 tuning, 0: disable R17 tuning
6409 if (macValue & 0x000000ff)
6411 pAdapter->BbpTuning.bEnable = TRUE;
6412 DBGPRINT(RT_DEBUG_TRACE,("turn on R17 tuning\n"));
6417 pAdapter->BbpTuning.bEnable = FALSE;
6418 R66 = 0x26 + GET_LNA_GAIN(pAdapter);
6419 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R66, (0x26 + GET_LNA_GAIN(pAdapter)));
6420 DBGPRINT(RT_DEBUG_TRACE,("turn off R17 tuning, restore to 0x%02x\n", R66));
6425 DBGPRINT(RT_DEBUG_TRACE, ("MacAddr=%02lx, MacValue=0x%x\n", macAddr, macValue));
6427 RTMP_IO_WRITE32(pAdapter, macAddr, macValue);
6428 sprintf(msg+strlen(msg), "[0x%08lX]:%08X ", macAddr, macValue);
6433 bIsPrintAllMAC = TRUE;
6437 struct file *file_w;
6438 PCHAR fileName = "MacDump.txt";
6439 mm_segment_t orig_fs;
6445 file_w = filp_open(fileName, O_WRONLY|O_CREAT, 0);
6448 DBGPRINT(RT_DEBUG_TRACE, ("-->2) %s: Error %ld opening %s\n", __func__, -PTR_ERR(file_w), fileName));
6452 if (file_w->f_op && file_w->f_op->write)
6457 while (macAddr <= 0x1800)
6459 RTMP_IO_READ32(pAdapter, macAddr, &macValue);
6460 sprintf(msg, "%08lx = %08X\n", macAddr, macValue);
6462 // write data to file
6463 file_w->f_op->write(file_w, msg, strlen(msg), &file_w->f_pos);
6468 sprintf(msg, "\nDump all MAC values to %s\n", fileName);
6470 filp_close(file_w, NULL);
6474 if(strlen(msg) == 1)
6475 sprintf(msg+strlen(msg), "===>Error command format!");
6477 // Copy the information into the user buffer
6478 wrq->u.data.length = strlen(msg);
6479 Status = copy_to_user(wrq->u.data.pointer, msg, wrq->u.data.length);
6481 DBGPRINT(RT_DEBUG_TRACE, ("<==RTMPIoctlMAC\n\n"));
6485 ==========================================================================
6489 pAdapter Pointer to our adapter
6490 wrq Pointer to the ioctl argument
6497 1.) iwpriv ra0 e2p 0 ==> read E2PROM where Addr=0x0
6498 2.) iwpriv ra0 e2p 0=1234 ==> write E2PROM where Addr=0x0, value=1234
6499 ==========================================================================
6501 VOID RTMPIoctlE2PROM(
6502 IN PRTMP_ADAPTER pAdapter,
6503 IN struct iwreq *wrq)
6511 UCHAR temp[16], temp2[16];
6514 BOOLEAN bIsPrintAllE2P = FALSE;
6517 memset(msg, 0x00, 1024);
6518 if (wrq->u.data.length > 1) //No parameters.
6520 Status = copy_from_user(arg, wrq->u.data.pointer, (wrq->u.data.length > 255) ? 255 : wrq->u.data.length);
6523 //Parsing Read or Write
6530 if ((value = rtstrchr(this_char, '=')) != NULL)
6533 if (!value || !*value)
6537 if(strlen(this_char) > 4)
6540 j = strlen(this_char);
6543 if(this_char[j] > 'f' || this_char[j] < '0')
6548 k = j = strlen(this_char);
6551 this_char[4-k+j] = this_char[j];
6555 this_char[3-k++]='0';
6558 if(strlen(this_char) == 4)
6560 AtoH(this_char, temp, 2);
6561 eepAddr = *temp*256 + temp[1];
6562 if (eepAddr < 0xFFFF)
6564 RT28xx_EEPROM_READ16(pAdapter, eepAddr, eepValue);
6565 sprintf(msg+strlen(msg), "[0x%04X]:0x%04X ", eepAddr , eepValue);
6568 {//Invalid parametes, so default printk all bbp
6569 bIsPrintAllE2P = TRUE;
6576 memcpy(&temp2, value, strlen(value));
6577 temp2[strlen(value)] = '\0';
6580 if((strlen(this_char) > 4) || strlen(temp2) > 8)
6583 j = strlen(this_char);
6586 if(this_char[j] > 'f' || this_char[j] < '0')
6592 if(temp2[j] > 'f' || temp2[j] < '0')
6597 k = j = strlen(this_char);
6600 this_char[4-k+j] = this_char[j];
6604 this_char[3-k++]='0';
6608 k = j = strlen(temp2);
6611 temp2[4-k+j] = temp2[j];
6618 AtoH(this_char, temp, 2);
6619 eepAddr = *temp*256 + temp[1];
6621 AtoH(temp2, temp, 2);
6622 eepValue = *temp*256 + temp[1];
6624 RT28xx_EEPROM_WRITE16(pAdapter, eepAddr, eepValue);
6625 sprintf(msg+strlen(msg), "[0x%02X]:%02X ", eepAddr, eepValue);
6629 bIsPrintAllE2P = TRUE;
6633 struct file *file_w;
6634 PCHAR fileName = "EEPROMDump.txt";
6635 mm_segment_t orig_fs;
6641 file_w = filp_open(fileName, O_WRONLY|O_CREAT, 0);
6644 DBGPRINT(RT_DEBUG_TRACE, ("-->2) %s: Error %ld opening %s\n", __func__, -PTR_ERR(file_w), fileName));
6648 if (file_w->f_op && file_w->f_op->write)
6653 while (eepAddr <= 0xFE)
6655 RT28xx_EEPROM_READ16(pAdapter, eepAddr, eepValue);
6656 sprintf(msg, "%08x = %04x\n", eepAddr , eepValue);
6658 // write data to file
6659 file_w->f_op->write(file_w, msg, strlen(msg), &file_w->f_pos);
6664 sprintf(msg, "\nDump all EEPROM values to %s\n", fileName);
6666 filp_close(file_w, NULL);
6670 if(strlen(msg) == 1)
6671 sprintf(msg+strlen(msg), "===>Error command format!");
6674 // Copy the information into the user buffer
6675 wrq->u.data.length = strlen(msg);
6676 Status = copy_to_user(wrq->u.data.pointer, msg, wrq->u.data.length);
6678 DBGPRINT(RT_DEBUG_TRACE, ("<==RTMPIoctlE2PROM\n"));
6682 ==========================================================================
6684 Read / Write RF register
6686 pAdapter Pointer to our adapter
6687 wrq Pointer to the ioctl argument
6694 1.) iwpriv ra0 rf ==> read all RF registers
6695 2.) iwpriv ra0 rf 1 ==> read RF where RegID=1
6696 3.) iwpriv ra0 rf 1=10 ==> write RF R1=0x10
6697 ==========================================================================
6700 IN PRTMP_ADAPTER pAdapter,
6701 IN struct iwreq *wrq)
6711 BOOLEAN bIsPrintAllRF = FALSE;
6714 memset(msg, 0x00, 2048);
6715 if (wrq->u.data.length > 1) //No parameters.
6717 Status = copy_from_user(arg, wrq->u.data.pointer, (wrq->u.data.length > 255) ? 255 : wrq->u.data.length);
6720 //Parsing Read or Write
6725 if ((value = strchr(this_char, '=')) != NULL)
6728 if (!value || !*value)
6730 if (sscanf(this_char, "%d", &(rfId)) == 1)
6734 // In RT2860 ATE mode, we do not load 8051 firmware.
6735 //We must access RF directly.
6736 // For RT2870 ATE mode, ATE_RF_IO_WRITE8(/READ8)_BY_REG_ID are redefined.
6737 // according to Andy, Gary, David require.
6738 // the command rf shall read rf register directly for dubug.
6739 // BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, ®BBP);
6740 RT30xxReadRFRegister(pAdapter, rfId, ®RF);
6742 sprintf(msg+strlen(msg), "R%02d[0x%02x]:%02X ", rfId, rfId*2, regRF);
6745 {//Invalid parametes, so default printk all RF
6746 bIsPrintAllRF = TRUE;
6751 { //Invalid parametes, so default printk all RF
6752 bIsPrintAllRF = TRUE;
6758 if ((sscanf(this_char, "%d", &(rfId)) == 1) && (sscanf(value, "%lx", &(rfValue)) == 1))
6762 // In RT2860 ATE mode, we do not load 8051 firmware.
6763 // We should access RF registers directly.
6764 // For RT2870 ATE mode, ATE_RF_IO_WRITE8/READ8_BY_REG_ID are redefined.
6766 // according to Andy, Gary, David require.
6767 // the command RF shall read/write RF register directly for dubug.
6768 //BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, ®BBP);
6769 //BBP_IO_WRITE8_BY_REG_ID(pAdapter, (UCHAR)bbpId,(UCHAR) bbpValue);
6770 RT30xxReadRFRegister(pAdapter, rfId, ®RF);
6771 RT30xxWriteRFRegister(pAdapter, (UCHAR)rfId,(UCHAR) rfValue);
6772 //Read it back for showing
6773 //BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, ®BBP);
6774 RT30xxReadRFRegister(pAdapter, rfId, ®RF);
6775 sprintf(msg+strlen(msg), "R%02d[0x%02X]:%02X\n", rfId, rfId*2, regRF);
6779 {//Invalid parametes, so default printk all RF
6780 bIsPrintAllRF = TRUE;
6784 { //Invalid parametes, so default printk all RF
6785 bIsPrintAllRF = TRUE;
6790 bIsPrintAllRF = TRUE;
6794 memset(msg, 0x00, 2048);
6796 for (rfId = 0; rfId <= 31; rfId++)
6798 // according to Andy, Gary, David require.
6799 // the command RF shall read/write RF register directly for dubug.
6800 RT30xxReadRFRegister(pAdapter, rfId, ®RF);
6801 sprintf(msg+strlen(msg), "%03d = %02X\n", rfId, regRF);
6803 // Copy the information into the user buffer
6804 DBGPRINT(RT_DEBUG_TRACE, ("strlen(msg)=%d\n", (UINT32)strlen(msg)));
6805 wrq->u.data.length = strlen(msg);
6806 if (copy_to_user(wrq->u.data.pointer, msg, wrq->u.data.length))
6808 DBGPRINT(RT_DEBUG_TRACE, ("%s: copy_to_user() fail\n", __func__));
6813 if(strlen(msg) == 1)
6814 sprintf(msg+strlen(msg), "===>Error command format!");
6816 DBGPRINT(RT_DEBUG_TRACE, ("copy to user [msg=%s]\n", msg));
6817 // Copy the information into the user buffer
6818 DBGPRINT(RT_DEBUG_TRACE, ("strlen(msg) =%d\n", (UINT32)strlen(msg)));
6820 // Copy the information into the user buffer
6821 wrq->u.data.length = strlen(msg);
6822 Status = copy_to_user(wrq->u.data.pointer, msg, wrq->u.data.length);
6825 DBGPRINT(RT_DEBUG_TRACE, ("<==RTMPIoctlRF\n\n"));
6833 INT Set_TGnWifiTest_Proc(
6834 IN PRTMP_ADAPTER pAd,
6837 if (simple_strtol(arg, 0, 10) == 0)
6838 pAd->StaCfg.bTGnWifiTest = FALSE;
6840 pAd->StaCfg.bTGnWifiTest = TRUE;
6842 DBGPRINT(RT_DEBUG_TRACE, ("IF Set_TGnWifiTest_Proc::(bTGnWifiTest=%d)\n", pAd->StaCfg.bTGnWifiTest));
6846 INT Set_LongRetryLimit_Proc(
6847 IN PRTMP_ADAPTER pAdapter,
6850 TX_RTY_CFG_STRUC tx_rty_cfg;
6851 UCHAR LongRetryLimit = (UCHAR)simple_strtol(arg, 0, 10);
6853 RTMP_IO_READ32(pAdapter, TX_RTY_CFG, &tx_rty_cfg.word);
6854 tx_rty_cfg.field.LongRtyLimit = LongRetryLimit;
6855 RTMP_IO_WRITE32(pAdapter, TX_RTY_CFG, tx_rty_cfg.word);
6856 DBGPRINT(RT_DEBUG_TRACE, ("IF Set_LongRetryLimit_Proc::(tx_rty_cfg=0x%x)\n", tx_rty_cfg.word));
6860 INT Set_ShortRetryLimit_Proc(
6861 IN PRTMP_ADAPTER pAdapter,
6864 TX_RTY_CFG_STRUC tx_rty_cfg;
6865 UCHAR ShortRetryLimit = (UCHAR)simple_strtol(arg, 0, 10);
6867 RTMP_IO_READ32(pAdapter, TX_RTY_CFG, &tx_rty_cfg.word);
6868 tx_rty_cfg.field.ShortRtyLimit = ShortRetryLimit;
6869 RTMP_IO_WRITE32(pAdapter, TX_RTY_CFG, tx_rty_cfg.word);
6870 DBGPRINT(RT_DEBUG_TRACE, ("IF Set_ShortRetryLimit_Proc::(tx_rty_cfg=0x%x)\n", tx_rty_cfg.word));
6874 #ifdef EXT_BUILD_CHANNEL_LIST
6875 INT Set_Ieee80211dClientMode_Proc(
6876 IN PRTMP_ADAPTER pAdapter,
6879 if (simple_strtol(arg, 0, 10) == 0)
6880 pAdapter->StaCfg.IEEE80211dClientMode = Rt802_11_D_None;
6881 else if (simple_strtol(arg, 0, 10) == 1)
6882 pAdapter->StaCfg.IEEE80211dClientMode = Rt802_11_D_Flexible;
6883 else if (simple_strtol(arg, 0, 10) == 2)
6884 pAdapter->StaCfg.IEEE80211dClientMode = Rt802_11_D_Strict;
6888 DBGPRINT(RT_DEBUG_TRACE, ("Set_Ieee802dMode_Proc::(IEEEE0211dMode=%d)\n", pAdapter->StaCfg.IEEE80211dClientMode));
6891 #endif // EXT_BUILD_CHANNEL_LIST //