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 #if !defined(RT2860) && !defined(RT30xx)
91 { SHOW_ADHOC_ENTRY_INFO,
92 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "adhocEntry" },
94 /* --- sub-ioctls relations --- */
98 IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK,
101 IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | 1024,
105 IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK,
109 IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | 1024,
113 { RTPRIV_IOCTL_STATISTICS,
114 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK,
116 { RTPRIV_IOCTL_GSITESURVEY,
117 0, IW_PRIV_TYPE_CHAR | 1024,
122 IN PRTMP_ADAPTER pAdapter,
126 INT Set_WmmCapable_Proc(
127 IN PRTMP_ADAPTER pAd,
131 INT Set_NetworkType_Proc(
132 IN PRTMP_ADAPTER pAdapter,
135 INT Set_AuthMode_Proc(
136 IN PRTMP_ADAPTER pAdapter,
139 INT Set_EncrypType_Proc(
140 IN PRTMP_ADAPTER pAdapter,
143 INT Set_DefaultKeyID_Proc(
144 IN PRTMP_ADAPTER pAdapter,
148 IN PRTMP_ADAPTER pAdapter,
152 IN PRTMP_ADAPTER pAdapter,
156 IN PRTMP_ADAPTER pAdapter,
160 IN PRTMP_ADAPTER pAdapter,
164 IN PRTMP_ADAPTER pAdapter,
169 IN PRTMP_ADAPTER pAdapter,
173 IN PRTMP_ADAPTER pAd,
177 #if !defined(RT2860) && !defined(RT30xx)
179 IN PRTMP_ADAPTER pAdapter,
180 IN struct iwreq *wrq);
184 IN PRTMP_ADAPTER pAdapter,
185 IN struct iwreq *wrq);
187 VOID RTMPIoctlE2PROM(
188 IN PRTMP_ADAPTER pAdapter,
189 IN struct iwreq *wrq);
193 IN PRTMP_ADAPTER pAdapter,
194 IN struct iwreq *wrq);
199 NDIS_STATUS RTMPWPANoneAddKeyProc(
200 IN PRTMP_ADAPTER pAd,
203 INT Set_FragTest_Proc(
204 IN PRTMP_ADAPTER pAdapter,
207 INT Set_TGnWifiTest_Proc(
208 IN PRTMP_ADAPTER pAd,
211 INT Set_LongRetryLimit_Proc(
212 IN PRTMP_ADAPTER pAdapter,
215 INT Set_ShortRetryLimit_Proc(
216 IN PRTMP_ADAPTER pAdapter,
219 #if !defined(RT2860) && !defined(RT30xx)
220 INT Show_Adhoc_MacTable_Proc(
221 IN PRTMP_ADAPTER pAd,
227 INT (*set_proc)(PRTMP_ADAPTER pAdapter, PUCHAR arg);
228 } *PRTMP_PRIVATE_SET_PROC, RTMP_PRIVATE_SUPPORT_PROC[] = {
229 {"DriverVersion", Set_DriverVersion_Proc},
230 {"CountryRegion", Set_CountryRegion_Proc},
231 {"CountryRegionABand", Set_CountryRegionABand_Proc},
232 {"SSID", Set_SSID_Proc},
233 {"WirelessMode", Set_WirelessMode_Proc},
234 {"TxBurst", Set_TxBurst_Proc},
235 {"TxPreamble", Set_TxPreamble_Proc},
236 {"TxPower", Set_TxPower_Proc},
237 {"Channel", Set_Channel_Proc},
238 {"BGProtection", Set_BGProtection_Proc},
239 {"RTSThreshold", Set_RTSThreshold_Proc},
240 {"FragThreshold", Set_FragThreshold_Proc},
241 {"HtBw", Set_HtBw_Proc},
242 {"HtMcs", Set_HtMcs_Proc},
243 {"HtGi", Set_HtGi_Proc},
244 {"HtOpMode", Set_HtOpMode_Proc},
245 {"HtExtcha", Set_HtExtcha_Proc},
246 {"HtMpduDensity", Set_HtMpduDensity_Proc},
247 {"HtBaWinSize", Set_HtBaWinSize_Proc},
248 {"HtRdg", Set_HtRdg_Proc},
249 {"HtAmsdu", Set_HtAmsdu_Proc},
250 {"HtAutoBa", Set_HtAutoBa_Proc},
251 {"HtBaDecline", Set_BADecline_Proc},
252 {"HtProtect", Set_HtProtect_Proc},
253 {"HtMimoPs", Set_HtMimoPs_Proc},
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},
276 {"WpaSupport", Set_Wpa_Support},
277 {"FixedTxMode", Set_FixedTxMode_Proc},
278 {"TGnWifiTest", Set_TGnWifiTest_Proc},
279 {"ForceGF", Set_ForceGF_Proc},
280 {"LongRetry", Set_LongRetryLimit_Proc},
281 {"ShortRetry", Set_ShortRetryLimit_Proc},
282 //2008/09/11:KH add to support efuse<--
284 {"efuseFreeNumber", set_eFuseGetFreeBlockCount_Proc},
285 {"efuseDump", set_eFusedump_Proc},
286 {"efuseLoadFromBin", set_eFuseLoadFromBin_Proc},
288 //2008/09/11:KH add to support efuse-->
294 IN PRTMP_ADAPTER pAd,
295 IN PNDIS_802_11_KEY pKey)
298 MAC_TABLE_ENTRY *pEntry;
300 DBGPRINT(RT_DEBUG_TRACE, ("RTMPAddKey ------>\n"));
303 RTMP_CLEAR_PSFLAG(pAd, fRTMP_PS_CAN_GO_SLEEP);
304 if (RTMP_TEST_PSFLAG(pAd, fRTMP_PS_SET_PCI_CLK_OFF_COMMAND))
306 if (pAd->StaCfg.bRadio == FALSE)
308 RTMP_SET_PSFLAG(pAd, fRTMP_PS_CAN_GO_SLEEP);
311 DBGPRINT(RT_DEBUG_TRACE,("RTMPWPAAddKeyProc1==>\n"));
312 RTMPPCIeLinkCtrlValueRestore(pAd, RESTORE_HALT);
314 pAd->bPCIclkOff = FALSE;
318 if (pAd->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
320 if (pKey->KeyIndex & 0x80000000)
322 if (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPANone)
324 NdisZeroMemory(pAd->StaCfg.PMK, 32);
325 NdisMoveMemory(pAd->StaCfg.PMK, pKey->KeyMaterial, pKey->KeyLength);
329 NdisZeroMemory(&pAd->SharedKey[BSS0][0], sizeof(CIPHER_KEY));
330 pAd->SharedKey[BSS0][0].KeyLen = LEN_TKIP_EK;
331 NdisMoveMemory(pAd->SharedKey[BSS0][0].Key, pKey->KeyMaterial, LEN_TKIP_EK);
333 if (pAd->StaCfg.PairCipher == Ndis802_11Encryption2Enabled)
335 NdisMoveMemory(pAd->SharedKey[BSS0][0].RxMic, pKey->KeyMaterial + LEN_TKIP_EK, LEN_TKIP_TXMICK);
336 NdisMoveMemory(pAd->SharedKey[BSS0][0].TxMic, pKey->KeyMaterial + LEN_TKIP_EK + LEN_TKIP_TXMICK, LEN_TKIP_RXMICK);
340 NdisMoveMemory(pAd->SharedKey[BSS0][0].TxMic, pKey->KeyMaterial + LEN_TKIP_EK, LEN_TKIP_TXMICK);
341 NdisMoveMemory(pAd->SharedKey[BSS0][0].RxMic, pKey->KeyMaterial + LEN_TKIP_EK + LEN_TKIP_TXMICK, LEN_TKIP_RXMICK);
344 // Decide its ChiperAlg
345 if (pAd->StaCfg.PairCipher == Ndis802_11Encryption2Enabled)
346 pAd->SharedKey[BSS0][0].CipherAlg = CIPHER_TKIP;
347 else if (pAd->StaCfg.PairCipher == Ndis802_11Encryption3Enabled)
348 pAd->SharedKey[BSS0][0].CipherAlg = CIPHER_AES;
350 pAd->SharedKey[BSS0][0].CipherAlg = CIPHER_NONE;
352 // Update these related information to MAC_TABLE_ENTRY
353 pEntry = &pAd->MacTab.Content[BSSID_WCID];
354 NdisMoveMemory(pEntry->PairwiseKey.Key, pAd->SharedKey[BSS0][0].Key, LEN_TKIP_EK);
355 NdisMoveMemory(pEntry->PairwiseKey.RxMic, pAd->SharedKey[BSS0][0].RxMic, LEN_TKIP_RXMICK);
356 NdisMoveMemory(pEntry->PairwiseKey.TxMic, pAd->SharedKey[BSS0][0].TxMic, LEN_TKIP_TXMICK);
357 pEntry->PairwiseKey.CipherAlg = pAd->SharedKey[BSS0][0].CipherAlg;
359 // Update pairwise key information to ASIC Shared Key Table
360 AsicAddSharedKeyEntry(pAd,
363 pAd->SharedKey[BSS0][0].CipherAlg,
364 pAd->SharedKey[BSS0][0].Key,
365 pAd->SharedKey[BSS0][0].TxMic,
366 pAd->SharedKey[BSS0][0].RxMic);
368 // Update ASIC WCID attribute table and IVEIV table
369 RTMPAddWcidAttributeEntry(pAd,
372 pAd->SharedKey[BSS0][0].CipherAlg,
375 if (pAd->StaCfg.AuthMode >= Ndis802_11AuthModeWPA2)
377 // set 802.1x port control
378 STA_PORT_SECURED(pAd);
380 // Indicate Connected for GUI
381 pAd->IndicateMediaState = NdisMediaStateConnected;
387 pAd->StaCfg.DefaultKeyId = (pKey->KeyIndex & 0xFF);
388 NdisZeroMemory(&pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId], sizeof(CIPHER_KEY));
389 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].KeyLen = LEN_TKIP_EK;
390 NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].Key, pKey->KeyMaterial, LEN_TKIP_EK);
392 if (pAd->StaCfg.GroupCipher == Ndis802_11Encryption2Enabled)
394 NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].RxMic, pKey->KeyMaterial + LEN_TKIP_EK, LEN_TKIP_TXMICK);
395 NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].TxMic, pKey->KeyMaterial + LEN_TKIP_EK + LEN_TKIP_TXMICK, LEN_TKIP_RXMICK);
399 NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].TxMic, pKey->KeyMaterial + LEN_TKIP_EK, LEN_TKIP_TXMICK);
400 NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].RxMic, pKey->KeyMaterial + LEN_TKIP_EK + LEN_TKIP_TXMICK, LEN_TKIP_RXMICK);
403 // Update Shared Key CipherAlg
404 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg = CIPHER_NONE;
405 if (pAd->StaCfg.GroupCipher == Ndis802_11Encryption2Enabled)
406 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg = CIPHER_TKIP;
407 else if (pAd->StaCfg.GroupCipher == Ndis802_11Encryption3Enabled)
408 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg = CIPHER_AES;
410 // Update group key information to ASIC Shared Key Table
411 AsicAddSharedKeyEntry(pAd,
413 pAd->StaCfg.DefaultKeyId,
414 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg,
415 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].Key,
416 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].TxMic,
417 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].RxMic);
419 // Update ASIC WCID attribute table and IVEIV table
420 RTMPAddWcidAttributeEntry(pAd,
422 pAd->StaCfg.DefaultKeyId,
423 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg,
426 // set 802.1x port control
427 STA_PORT_SECURED(pAd);
429 // Indicate Connected for GUI
430 pAd->IndicateMediaState = NdisMediaStateConnected;
433 else // dynamic WEP from wpa_supplicant
438 if(pKey->KeyLength == 32)
441 KeyIdx = pKey->KeyIndex & 0x0fffffff;
445 // it is a default shared key, for Pairwise key setting
446 if (pKey->KeyIndex & 0x80000000)
448 pEntry = MacTableLookup(pAd, pKey->BSSID);
452 DBGPRINT(RT_DEBUG_TRACE, ("RTMPAddKey: Set Pair-wise Key\n"));
454 // set key material and key length
455 pEntry->PairwiseKey.KeyLen = (UCHAR)pKey->KeyLength;
456 NdisMoveMemory(pEntry->PairwiseKey.Key, &pKey->KeyMaterial, pKey->KeyLength);
459 if (pKey->KeyLength == 5)
460 pEntry->PairwiseKey.CipherAlg = CIPHER_WEP64;
462 pEntry->PairwiseKey.CipherAlg = CIPHER_WEP128;
464 // Add Pair-wise key to Asic
465 AsicAddPairwiseKeyEntry(
469 &pEntry->PairwiseKey);
471 // update WCID attribute table and IVEIV table for this entry
472 RTMPAddWcidAttributeEntry(
475 KeyIdx, // The value may be not zero
476 pEntry->PairwiseKey.CipherAlg,
483 // Default key for tx (shared key)
484 pAd->StaCfg.DefaultKeyId = (UCHAR) KeyIdx;
486 // set key material and key length
487 pAd->SharedKey[BSS0][KeyIdx].KeyLen = (UCHAR) pKey->KeyLength;
488 NdisMoveMemory(pAd->SharedKey[BSS0][KeyIdx].Key, &pKey->KeyMaterial, pKey->KeyLength);
491 if (pKey->KeyLength == 5)
492 pAd->SharedKey[BSS0][KeyIdx].CipherAlg = CIPHER_WEP64;
494 pAd->SharedKey[BSS0][KeyIdx].CipherAlg = CIPHER_WEP128;
496 CipherAlg = pAd->SharedKey[BSS0][KeyIdx].CipherAlg;
497 Key = pAd->SharedKey[BSS0][KeyIdx].Key;
499 // Set Group key material to Asic
500 AsicAddSharedKeyEntry(pAd, BSS0, KeyIdx, CipherAlg, Key, NULL, NULL);
502 // Update WCID attribute table and IVEIV table for this group key table
503 RTMPAddWcidAttributeEntry(pAd, BSS0, KeyIdx, CipherAlg, NULL);
510 RTMP_SET_PSFLAG(pAd, fRTMP_PS_CAN_GO_SLEEP);
511 DBGPRINT(RT_DEBUG_INFO, ("<------ RTMPAddKey\n"));
516 char * rtstrchr(const char * s, int c)
518 for(; *s != (char) c; ++s)
525 This is required for LinEX2004/kernel2.6.7 to provide iwlist scanning function
529 rt_ioctl_giwname(struct net_device *dev,
530 struct iw_request_info *info,
531 char *name, char *extra)
533 // PRTMP_ADAPTER pAdapter = dev->ml_priv;
534 strncpy(name, RT28xx_CHIP_NAME " Wireless", IFNAMSIZ);
538 int rt_ioctl_siwfreq(struct net_device *dev,
539 struct iw_request_info *info,
540 struct iw_freq *freq, char *extra)
542 PRTMP_ADAPTER pAdapter = dev->ml_priv;
545 //check if the interface is down
546 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
548 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
556 if((freq->e == 0) && (freq->m <= 1000))
557 chan = freq->m; // Setting by channel number
559 MAP_KHZ_TO_CHANNEL_ID( (freq->m /100) , chan); // Setting by frequency - search the table , like 2.412G, 2.422G,
561 if (ChannelSanity(pAdapter, chan) == TRUE)
563 pAdapter->CommonCfg.Channel = chan;
564 DBGPRINT(RT_DEBUG_ERROR, ("==>rt_ioctl_siwfreq::SIOCSIWFREQ[cmd=0x%x] (Channel=%d)\n", SIOCSIWFREQ, pAdapter->CommonCfg.Channel));
571 int rt_ioctl_giwfreq(struct net_device *dev,
572 struct iw_request_info *info,
573 struct iw_freq *freq, char *extra)
575 PRTMP_ADAPTER pAdapter = dev->ml_priv;
576 UCHAR ch = pAdapter->CommonCfg.Channel;
579 DBGPRINT(RT_DEBUG_TRACE,("==>rt_ioctl_giwfreq %d\n", ch));
581 MAP_CHANNEL_ID_TO_KHZ(ch, m);
587 int rt_ioctl_siwmode(struct net_device *dev,
588 struct iw_request_info *info,
589 __u32 *mode, char *extra)
591 PRTMP_ADAPTER pAdapter = dev->ml_priv;
593 //check if the interface is down
594 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
596 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
603 Set_NetworkType_Proc(pAdapter, "Adhoc");
606 Set_NetworkType_Proc(pAdapter, "Infra");
608 case IW_MODE_MONITOR:
609 Set_NetworkType_Proc(pAdapter, "Monitor");
612 DBGPRINT(RT_DEBUG_TRACE, ("===>rt_ioctl_siwmode::SIOCSIWMODE (unknown %d)\n", *mode));
616 // Reset Ralink supplicant to not use, it will be set to start when UI set PMK key
617 pAdapter->StaCfg.WpaState = SS_NOTUSE;
622 int rt_ioctl_giwmode(struct net_device *dev,
623 struct iw_request_info *info,
624 __u32 *mode, char *extra)
626 PRTMP_ADAPTER pAdapter = dev->ml_priv;
628 if (ADHOC_ON(pAdapter))
629 *mode = IW_MODE_ADHOC;
630 else if (INFRA_ON(pAdapter))
631 *mode = IW_MODE_INFRA;
632 else if (MONITOR_ON(pAdapter))
634 *mode = IW_MODE_MONITOR;
637 *mode = IW_MODE_AUTO;
639 DBGPRINT(RT_DEBUG_TRACE, ("==>rt_ioctl_giwmode(mode=%d)\n", *mode));
643 int rt_ioctl_siwsens(struct net_device *dev,
644 struct iw_request_info *info,
645 char *name, char *extra)
647 PRTMP_ADAPTER pAdapter = dev->ml_priv;
649 //check if the interface is down
650 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
652 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
659 int rt_ioctl_giwsens(struct net_device *dev,
660 struct iw_request_info *info,
661 char *name, char *extra)
666 int rt_ioctl_giwrange(struct net_device *dev,
667 struct iw_request_info *info,
668 struct iw_point *data, char *extra)
670 PRTMP_ADAPTER pAdapter = dev->ml_priv;
671 struct iw_range *range = (struct iw_range *) extra;
675 DBGPRINT(RT_DEBUG_TRACE ,("===>rt_ioctl_giwrange\n"));
676 data->length = sizeof(struct iw_range);
677 memset(range, 0, sizeof(struct iw_range));
679 range->txpower_capa = IW_TXPOW_DBM;
681 if (INFRA_ON(pAdapter)||ADHOC_ON(pAdapter))
683 range->min_pmp = 1 * 1024;
684 range->max_pmp = 65535 * 1024;
685 range->min_pmt = 1 * 1024;
686 range->max_pmt = 1000 * 1024;
687 range->pmp_flags = IW_POWER_PERIOD;
688 range->pmt_flags = IW_POWER_TIMEOUT;
689 range->pm_capa = IW_POWER_PERIOD | IW_POWER_TIMEOUT |
690 IW_POWER_UNICAST_R | IW_POWER_ALL_R;
693 range->we_version_compiled = WIRELESS_EXT;
694 range->we_version_source = 14;
696 range->retry_capa = IW_RETRY_LIMIT;
697 range->retry_flags = IW_RETRY_LIMIT;
698 range->min_retry = 0;
699 range->max_retry = 255;
701 range->num_channels = pAdapter->ChannelListNum;
704 for (i = 1; i <= range->num_channels; i++)
707 range->freq[val].i = pAdapter->ChannelList[i-1].Channel;
708 MAP_CHANNEL_ID_TO_KHZ(pAdapter->ChannelList[i-1].Channel, m);
709 range->freq[val].m = m * 100; /* HZ */
711 range->freq[val].e = 1;
713 if (val == IW_MAX_FREQUENCIES)
716 range->num_frequency = val;
718 range->max_qual.qual = 100; /* what is correct max? This was not
719 * documented exactly. At least
720 * 69 has been observed. */
721 range->max_qual.level = 0; /* dB */
722 range->max_qual.noise = 0; /* dB */
724 /* What would be suitable values for "average/typical" qual? */
725 range->avg_qual.qual = 20;
726 range->avg_qual.level = -60;
727 range->avg_qual.noise = -95;
728 range->sensitivity = 3;
730 range->max_encoding_tokens = NR_WEP_KEYS;
731 range->num_encoding_sizes = 2;
732 range->encoding_size[0] = 5;
733 range->encoding_size[1] = 13;
736 range->max_rts = 2347;
737 range->min_frag = 256;
738 range->max_frag = 2346;
740 /* IW_ENC_CAPA_* bit field */
741 range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 |
742 IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP;
747 int rt_ioctl_siwap(struct net_device *dev,
748 struct iw_request_info *info,
749 struct sockaddr *ap_addr, char *extra)
751 PRTMP_ADAPTER pAdapter = dev->ml_priv;
752 NDIS_802_11_MAC_ADDRESS Bssid;
754 //check if the interface is down
755 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
757 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
761 if (pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE)
763 RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
764 DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
767 // tell CNTL state machine to call NdisMSetInformationComplete() after completing
768 // this request, because this request is initiated by NDIS.
769 pAdapter->MlmeAux.CurrReqIsFromNdis = FALSE;
770 // Prevent to connect AP again in STAMlmePeriodicExec
771 pAdapter->MlmeAux.AutoReconnectSsidLen= 32;
773 memset(Bssid, 0, MAC_ADDR_LEN);
774 memcpy(Bssid, ap_addr->sa_data, MAC_ADDR_LEN);
775 MlmeEnqueue(pAdapter,
776 MLME_CNTL_STATE_MACHINE,
778 sizeof(NDIS_802_11_MAC_ADDRESS),
781 DBGPRINT(RT_DEBUG_TRACE, ("IOCTL::SIOCSIWAP %02x:%02x:%02x:%02x:%02x:%02x\n",
782 Bssid[0], Bssid[1], Bssid[2], Bssid[3], Bssid[4], Bssid[5]));
787 int rt_ioctl_giwap(struct net_device *dev,
788 struct iw_request_info *info,
789 struct sockaddr *ap_addr, char *extra)
791 PRTMP_ADAPTER pAdapter = dev->ml_priv;
793 if (INFRA_ON(pAdapter) || ADHOC_ON(pAdapter))
795 ap_addr->sa_family = ARPHRD_ETHER;
796 memcpy(ap_addr->sa_data, &pAdapter->CommonCfg.Bssid, ETH_ALEN);
799 else if (pAdapter->StaCfg.WpaSupplicantUP != WPA_SUPPLICANT_DISABLE)
801 ap_addr->sa_family = ARPHRD_ETHER;
802 memcpy(ap_addr->sa_data, &pAdapter->MlmeAux.Bssid, ETH_ALEN);
806 DBGPRINT(RT_DEBUG_TRACE, ("IOCTL::SIOCGIWAP(=EMPTY)\n"));
814 * Units are in db above the noise floor. That means the
815 * rssi values reported in the tx/rx descriptors in the
816 * driver are the SNR expressed in db.
818 * If you assume that the noise floor is -95, which is an
819 * excellent assumption 99.5 % of the time, then you can
820 * derive the absolute signal level (i.e. -95 + rssi).
821 * There are some other slight factors to take into account
822 * depending on whether the rssi measurement is from 11b,
823 * 11g, or 11a. These differences are at most 2db and
826 * NB: various calculations are based on the orinoco/wavelan
827 * drivers for compatibility
829 static void set_quality(PRTMP_ADAPTER pAdapter,
830 struct iw_quality *iq,
837 ChannelQuality = 100;
838 else if (rssi >= -80) // between -50 ~ -80dbm
839 ChannelQuality = (__u8)(24 + ((rssi + 80) * 26)/10);
840 else if (rssi >= -90) // between -80 ~ -90dbm
841 ChannelQuality = (__u8)((rssi + 90) * 26)/10;
845 iq->qual = (__u8)ChannelQuality;
847 iq->level = (__u8)(rssi);
848 iq->noise = (pAdapter->BbpWriteLatch[66] > pAdapter->BbpTuning.FalseCcaUpperThreshold) ? ((__u8)pAdapter->BbpTuning.FalseCcaUpperThreshold) : ((__u8) pAdapter->BbpWriteLatch[66]); // noise level (dBm)
849 iq->noise += 256 - 143;
850 iq->updated = pAdapter->iw_stats.qual.updated;
853 int rt_ioctl_iwaplist(struct net_device *dev,
854 struct iw_request_info *info,
855 struct iw_point *data, char *extra)
857 PRTMP_ADAPTER pAdapter = dev->ml_priv;
859 struct sockaddr addr[IW_MAX_AP];
860 struct iw_quality qual[IW_MAX_AP];
863 //check if the interface is down
864 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
866 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
872 for (i = 0; i <IW_MAX_AP ; i++)
874 if (i >= pAdapter->ScanTab.BssNr)
876 addr[i].sa_family = ARPHRD_ETHER;
877 memcpy(addr[i].sa_data, &pAdapter->ScanTab.BssEntry[i].Bssid, MAC_ADDR_LEN);
878 set_quality(pAdapter, &qual[i], pAdapter->ScanTab.BssEntry[i].Rssi);
881 memcpy(extra, &addr, i*sizeof(addr[0]));
882 data->flags = 1; /* signal quality present (sort of) */
883 memcpy(extra + i*sizeof(addr[0]), &qual, i*sizeof(qual[i]));
888 int rt_ioctl_siwscan(struct net_device *dev,
889 struct iw_request_info *info,
890 struct iw_point *data, char *extra)
892 PRTMP_ADAPTER pAdapter = dev->ml_priv;
895 int Status = NDIS_STATUS_SUCCESS;
897 //check if the interface is down
898 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
900 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
904 if (MONITOR_ON(pAdapter))
906 DBGPRINT(RT_DEBUG_TRACE, ("!!! Driver is in Monitor Mode now !!!\n"));
910 if ((pAdapter->OpMode == OPMODE_STA) && (IDLE_ON(pAdapter))
911 && (pAdapter->StaCfg.bRadio == TRUE)
912 && (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_IDLE_RADIO_OFF)))
914 RT28xxPciAsicRadioOn(pAdapter, GUI_IDLE_POWER_SAVE);
916 // Check if still radio off.
917 else if (pAdapter->bPCIclkOff == TRUE)
920 if (pAdapter->StaCfg.WpaSupplicantUP == WPA_SUPPLICANT_ENABLE)
922 pAdapter->StaCfg.WpaSupplicantScanCount++;
925 pAdapter->StaCfg.bScanReqIsFromWebUI = TRUE;
926 if (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
931 if ((pAdapter->StaCfg.WpaSupplicantUP == WPA_SUPPLICANT_ENABLE) &&
932 (pAdapter->StaCfg.WpaSupplicantScanCount > 3))
934 DBGPRINT(RT_DEBUG_TRACE, ("!!! WpaSupplicantScanCount > 3\n"));
935 Status = NDIS_STATUS_SUCCESS;
939 if ((OPSTATUS_TEST_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED)) &&
940 ((pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA) ||
941 (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK)) &&
942 (pAdapter->StaCfg.PortSecured == WPA_802_1X_PORT_NOT_SECURED))
944 DBGPRINT(RT_DEBUG_TRACE, ("!!! Link UP, Port Not Secured! ignore this set::OID_802_11_BSSID_LIST_SCAN\n"));
945 Status = NDIS_STATUS_SUCCESS;
949 if (pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE)
951 RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
952 DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
955 // tell CNTL state machine to call NdisMSetInformationComplete() after completing
956 // this request, because this request is initiated by NDIS.
957 pAdapter->MlmeAux.CurrReqIsFromNdis = FALSE;
958 // Reset allowed scan retries
959 pAdapter->StaCfg.ScanCnt = 0;
960 pAdapter->StaCfg.LastScanTime = Now;
962 MlmeEnqueue(pAdapter,
963 MLME_CNTL_STATE_MACHINE,
964 OID_802_11_BSSID_LIST_SCAN,
968 Status = NDIS_STATUS_SUCCESS;
969 RT28XX_MLME_HANDLER(pAdapter);
974 int rt_ioctl_giwscan(struct net_device *dev,
975 struct iw_request_info *info,
976 struct iw_point *data, char *extra)
979 PRTMP_ADAPTER pAdapter = dev->ml_priv;
981 char *current_ev = extra, *previous_ev = extra;
983 char *current_val, custom[MAX_CUSTOM_LEN] = {0};
986 if (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
989 * Still scanning, indicate the caller should try again.
994 if (pAdapter->StaCfg.WpaSupplicantUP == WPA_SUPPLICANT_ENABLE)
996 pAdapter->StaCfg.WpaSupplicantScanCount = 0;
999 if (pAdapter->ScanTab.BssNr == 0)
1005 if (data->length > 0)
1006 end_buf = extra + data->length;
1008 end_buf = extra + IW_SCAN_MAX_DATA;
1010 for (i = 0; i < pAdapter->ScanTab.BssNr; i++)
1012 if (current_ev >= end_buf)
1016 //================================
1017 memset(&iwe, 0, sizeof(iwe));
1018 iwe.cmd = SIOCGIWAP;
1019 iwe.u.ap_addr.sa_family = ARPHRD_ETHER;
1020 memcpy(iwe.u.ap_addr.sa_data, &pAdapter->ScanTab.BssEntry[i].Bssid, ETH_ALEN);
1022 previous_ev = current_ev;
1023 current_ev = iwe_stream_add_event(info, current_ev,end_buf, &iwe, IW_EV_ADDR_LEN);
1025 if (current_ev == previous_ev)
1030 it will show scanned AP's WirelessMode .
1039 memset(&iwe, 0, sizeof(iwe));
1040 iwe.cmd = SIOCGIWNAME;
1044 PBSS_ENTRY pBssEntry=&pAdapter->ScanTab.BssEntry[i];
1045 BOOLEAN isGonly=FALSE;
1048 if (pBssEntry->Channel>14)
1050 if (pBssEntry->HtCapabilityLen!=0)
1051 strcpy(iwe.u.name,"802.11a/n");
1053 strcpy(iwe.u.name,"802.11a");
1058 if one of non B mode rate is set supported rate . it mean G only.
1060 for (rateCnt=0;rateCnt<pBssEntry->SupRateLen;rateCnt++)
1063 6Mbps(140) 9Mbps(146) and >=12Mbps(152) are supported rate , it mean G only.
1065 if (pBssEntry->SupRate[rateCnt]==140 || pBssEntry->SupRate[rateCnt]==146 || pBssEntry->SupRate[rateCnt]>=152)
1069 for (rateCnt=0;rateCnt<pBssEntry->ExtRateLen;rateCnt++)
1071 if (pBssEntry->ExtRate[rateCnt]==140 || pBssEntry->ExtRate[rateCnt]==146 || pBssEntry->ExtRate[rateCnt]>=152)
1076 if (pBssEntry->HtCapabilityLen!=0)
1079 strcpy(iwe.u.name,"802.11g/n");
1081 strcpy(iwe.u.name,"802.11b/g/n");
1086 strcpy(iwe.u.name,"802.11g");
1089 if (pBssEntry->SupRateLen==4 && pBssEntry->ExtRateLen==0)
1090 strcpy(iwe.u.name,"802.11b");
1092 strcpy(iwe.u.name,"802.11b/g");
1098 previous_ev = current_ev;
1099 current_ev = iwe_stream_add_event(info, current_ev, end_buf, &iwe, IW_EV_ADDR_LEN);
1101 if (current_ev == previous_ev)
1105 //================================
1106 memset(&iwe, 0, sizeof(iwe));
1107 iwe.cmd = SIOCGIWESSID;
1108 iwe.u.data.length = pAdapter->ScanTab.BssEntry[i].SsidLen;
1109 iwe.u.data.flags = 1;
1111 previous_ev = current_ev;
1112 current_ev = iwe_stream_add_point(info, current_ev,end_buf, &iwe, pAdapter->ScanTab.BssEntry[i].Ssid);
1113 if (current_ev == previous_ev)
1117 //================================
1118 memset(&iwe, 0, sizeof(iwe));
1119 iwe.cmd = SIOCGIWMODE;
1120 if (pAdapter->ScanTab.BssEntry[i].BssType == Ndis802_11IBSS)
1122 iwe.u.mode = IW_MODE_ADHOC;
1124 else if (pAdapter->ScanTab.BssEntry[i].BssType == Ndis802_11Infrastructure)
1126 iwe.u.mode = IW_MODE_INFRA;
1130 iwe.u.mode = IW_MODE_AUTO;
1132 iwe.len = IW_EV_UINT_LEN;
1134 previous_ev = current_ev;
1135 current_ev = iwe_stream_add_event(info, current_ev, end_buf, &iwe, IW_EV_UINT_LEN);
1136 if (current_ev == previous_ev)
1139 //Channel and Frequency
1140 //================================
1141 memset(&iwe, 0, sizeof(iwe));
1142 iwe.cmd = SIOCGIWFREQ;
1143 if (INFRA_ON(pAdapter) || ADHOC_ON(pAdapter))
1144 iwe.u.freq.m = pAdapter->ScanTab.BssEntry[i].Channel;
1146 iwe.u.freq.m = pAdapter->ScanTab.BssEntry[i].Channel;
1150 previous_ev = current_ev;
1151 current_ev = iwe_stream_add_event(info, current_ev, end_buf, &iwe, IW_EV_FREQ_LEN);
1152 if (current_ev == previous_ev)
1155 //Add quality statistics
1156 //================================
1157 memset(&iwe, 0, sizeof(iwe));
1159 iwe.u.qual.level = 0;
1160 iwe.u.qual.noise = 0;
1161 set_quality(pAdapter, &iwe.u.qual, pAdapter->ScanTab.BssEntry[i].Rssi);
1162 current_ev = iwe_stream_add_event(info, current_ev, end_buf, &iwe, IW_EV_QUAL_LEN);
1163 if (current_ev == previous_ev)
1167 //================================
1168 memset(&iwe, 0, sizeof(iwe));
1169 iwe.cmd = SIOCGIWENCODE;
1170 if (CAP_IS_PRIVACY_ON (pAdapter->ScanTab.BssEntry[i].CapabilityInfo ))
1171 iwe.u.data.flags =IW_ENCODE_ENABLED | IW_ENCODE_NOKEY;
1173 iwe.u.data.flags = IW_ENCODE_DISABLED;
1175 previous_ev = current_ev;
1176 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);
1177 if (current_ev == previous_ev)
1181 //================================
1182 if (pAdapter->ScanTab.BssEntry[i].SupRateLen)
1184 UCHAR tmpRate = pAdapter->ScanTab.BssEntry[i].SupRate[pAdapter->ScanTab.BssEntry[i].SupRateLen-1];
1185 memset(&iwe, 0, sizeof(iwe));
1186 iwe.cmd = SIOCGIWRATE;
1187 current_val = current_ev + IW_EV_LCP_LEN;
1188 if (tmpRate == 0x82)
1189 iwe.u.bitrate.value = 1 * 1000000;
1190 else if (tmpRate == 0x84)
1191 iwe.u.bitrate.value = 2 * 1000000;
1192 else if (tmpRate == 0x8B)
1193 iwe.u.bitrate.value = 5.5 * 1000000;
1194 else if (tmpRate == 0x96)
1195 iwe.u.bitrate.value = 11 * 1000000;
1197 iwe.u.bitrate.value = (tmpRate/2) * 1000000;
1199 iwe.u.bitrate.disabled = 0;
1200 current_val = iwe_stream_add_value(info, current_ev,
1201 current_val, end_buf, &iwe,
1204 if((current_val-current_ev)>IW_EV_LCP_LEN)
1205 current_ev = current_val;
1211 if (pAdapter->ScanTab.BssEntry[i].WpaIE.IELen > 0)
1213 memset(&iwe, 0, sizeof(iwe));
1214 memset(&custom[0], 0, MAX_CUSTOM_LEN);
1215 memcpy(custom, &(pAdapter->ScanTab.BssEntry[i].WpaIE.IE[0]),
1216 pAdapter->ScanTab.BssEntry[i].WpaIE.IELen);
1217 iwe.cmd = IWEVGENIE;
1218 iwe.u.data.length = pAdapter->ScanTab.BssEntry[i].WpaIE.IELen;
1219 current_ev = iwe_stream_add_point(info, current_ev, end_buf, &iwe, custom);
1220 if (current_ev == previous_ev)
1225 if (pAdapter->ScanTab.BssEntry[i].RsnIE.IELen > 0)
1227 memset(&iwe, 0, sizeof(iwe));
1228 memset(&custom[0], 0, MAX_CUSTOM_LEN);
1229 memcpy(custom, &(pAdapter->ScanTab.BssEntry[i].RsnIE.IE[0]),
1230 pAdapter->ScanTab.BssEntry[i].RsnIE.IELen);
1231 iwe.cmd = IWEVGENIE;
1232 iwe.u.data.length = pAdapter->ScanTab.BssEntry[i].RsnIE.IELen;
1233 current_ev = iwe_stream_add_point(info, current_ev, end_buf, &iwe, custom);
1234 if (current_ev == previous_ev)
1239 data->length = current_ev - extra;
1240 pAdapter->StaCfg.bScanReqIsFromWebUI = FALSE;
1241 DBGPRINT(RT_DEBUG_ERROR ,("===>rt_ioctl_giwscan. %d(%d) BSS returned, data->length = %d\n",i , pAdapter->ScanTab.BssNr, data->length));
1245 int rt_ioctl_siwessid(struct net_device *dev,
1246 struct iw_request_info *info,
1247 struct iw_point *data, char *essid)
1249 PRTMP_ADAPTER pAdapter = dev->ml_priv;
1251 //check if the interface is down
1252 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1254 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1260 PCHAR pSsidString = NULL;
1262 // Includes null character.
1263 if (data->length > (IW_ESSID_MAX_SIZE + 1))
1266 pSsidString = (CHAR *) kmalloc(MAX_LEN_OF_SSID+1, MEM_ALLOC_FLAG);
1269 NdisZeroMemory(pSsidString, MAX_LEN_OF_SSID+1);
1270 NdisMoveMemory(pSsidString, essid, data->length);
1271 if (Set_SSID_Proc(pAdapter, pSsidString) == FALSE)
1280 if (Set_SSID_Proc(pAdapter, "") == FALSE)
1286 int rt_ioctl_giwessid(struct net_device *dev,
1287 struct iw_request_info *info,
1288 struct iw_point *data, char *essid)
1290 PRTMP_ADAPTER pAdapter = dev->ml_priv;
1293 if (MONITOR_ON(pAdapter))
1299 if (OPSTATUS_TEST_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED))
1301 DBGPRINT(RT_DEBUG_TRACE ,("MediaState is connected\n"));
1302 data->length = pAdapter->CommonCfg.SsidLen;
1303 memcpy(essid, pAdapter->CommonCfg.Ssid, pAdapter->CommonCfg.SsidLen);
1307 else if (pAdapter->StaCfg.WpaSupplicantUP != WPA_SUPPLICANT_DISABLE)
1309 data->length = pAdapter->CommonCfg.SsidLen;
1310 memcpy(essid, pAdapter->CommonCfg.Ssid, pAdapter->CommonCfg.SsidLen);
1314 {//the ANY ssid was specified
1316 DBGPRINT(RT_DEBUG_TRACE ,("MediaState is not connected, ess\n"));
1323 int rt_ioctl_siwnickn(struct net_device *dev,
1324 struct iw_request_info *info,
1325 struct iw_point *data, char *nickname)
1327 PRTMP_ADAPTER pAdapter = dev->ml_priv;
1329 //check if the interface is down
1330 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1332 DBGPRINT(RT_DEBUG_TRACE ,("INFO::Network is down!\n"));
1336 if (data->length > IW_ESSID_MAX_SIZE)
1339 memset(pAdapter->nickname, 0, IW_ESSID_MAX_SIZE + 1);
1340 memcpy(pAdapter->nickname, nickname, data->length);
1346 int rt_ioctl_giwnickn(struct net_device *dev,
1347 struct iw_request_info *info,
1348 struct iw_point *data, char *nickname)
1350 PRTMP_ADAPTER pAdapter = dev->ml_priv;
1352 if (data->length > strlen(pAdapter->nickname) + 1)
1353 data->length = strlen(pAdapter->nickname) + 1;
1354 if (data->length > 0) {
1355 memcpy(nickname, pAdapter->nickname, data->length-1);
1356 nickname[data->length-1] = '\0';
1361 int rt_ioctl_siwrts(struct net_device *dev,
1362 struct iw_request_info *info,
1363 struct iw_param *rts, char *extra)
1365 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"));
1376 val = MAX_RTS_THRESHOLD;
1377 else if (rts->value < 0 || rts->value > MAX_RTS_THRESHOLD)
1379 else if (rts->value == 0)
1380 val = MAX_RTS_THRESHOLD;
1384 if (val != pAdapter->CommonCfg.RtsThreshold)
1385 pAdapter->CommonCfg.RtsThreshold = val;
1390 int rt_ioctl_giwrts(struct net_device *dev,
1391 struct iw_request_info *info,
1392 struct iw_param *rts, char *extra)
1394 PRTMP_ADAPTER pAdapter = dev->ml_priv;
1396 //check if the interface is down
1397 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1399 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1403 rts->value = pAdapter->CommonCfg.RtsThreshold;
1404 rts->disabled = (rts->value == MAX_RTS_THRESHOLD);
1410 int rt_ioctl_siwfrag(struct net_device *dev,
1411 struct iw_request_info *info,
1412 struct iw_param *frag, char *extra)
1414 PRTMP_ADAPTER pAdapter = dev->ml_priv;
1417 //check if the interface is down
1418 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1420 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1425 val = MAX_FRAG_THRESHOLD;
1426 else if (frag->value >= MIN_FRAG_THRESHOLD || frag->value <= MAX_FRAG_THRESHOLD)
1427 val = __cpu_to_le16(frag->value & ~0x1); /* even numbers only */
1428 else if (frag->value == 0)
1429 val = MAX_FRAG_THRESHOLD;
1433 pAdapter->CommonCfg.FragmentThreshold = val;
1437 int rt_ioctl_giwfrag(struct net_device *dev,
1438 struct iw_request_info *info,
1439 struct iw_param *frag, char *extra)
1441 PRTMP_ADAPTER pAdapter = dev->ml_priv;
1443 //check if the interface is down
1444 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1446 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1450 frag->value = pAdapter->CommonCfg.FragmentThreshold;
1451 frag->disabled = (frag->value == MAX_FRAG_THRESHOLD);
1457 #define MAX_WEP_KEY_SIZE 13
1458 #define MIN_WEP_KEY_SIZE 5
1459 int rt_ioctl_siwencode(struct net_device *dev,
1460 struct iw_request_info *info,
1461 struct iw_point *erq, char *extra)
1463 PRTMP_ADAPTER pAdapter = dev->ml_priv;
1465 //check if the interface is down
1466 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1468 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1472 if ((erq->length == 0) &&
1473 (erq->flags & IW_ENCODE_DISABLED))
1475 pAdapter->StaCfg.PairCipher = Ndis802_11WEPDisabled;
1476 pAdapter->StaCfg.GroupCipher = Ndis802_11WEPDisabled;
1477 pAdapter->StaCfg.WepStatus = Ndis802_11WEPDisabled;
1478 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
1479 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
1485 (erq->flags & IW_ENCODE_RESTRICTED || erq->flags & IW_ENCODE_OPEN)) {
1486 STA_PORT_SECURED(pAdapter);
1487 pAdapter->StaCfg.PairCipher = Ndis802_11WEPEnabled;
1488 pAdapter->StaCfg.GroupCipher = Ndis802_11WEPEnabled;
1489 pAdapter->StaCfg.WepStatus = Ndis802_11WEPEnabled;
1490 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
1491 if (erq->flags & IW_ENCODE_RESTRICTED)
1492 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeShared;
1494 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
1500 if (erq->length > 0)
1502 int keyIdx = (erq->flags & IW_ENCODE_INDEX) - 1;
1503 /* Check the size of the key */
1504 if (erq->length > MAX_WEP_KEY_SIZE) {
1507 /* Check key index */
1508 if ((keyIdx < 0) || (keyIdx >= NR_WEP_KEYS))
1510 DBGPRINT(RT_DEBUG_TRACE ,("==>rt_ioctl_siwencode::Wrong keyIdx=%d! Using default key instead (%d)\n",
1511 keyIdx, pAdapter->StaCfg.DefaultKeyId));
1514 keyIdx = pAdapter->StaCfg.DefaultKeyId;
1519 pAdapter->StaCfg.DefaultKeyId=keyIdx;
1523 NdisZeroMemory(pAdapter->SharedKey[BSS0][keyIdx].Key, 16);
1525 if (erq->length == MAX_WEP_KEY_SIZE)
1527 pAdapter->SharedKey[BSS0][keyIdx].KeyLen = MAX_WEP_KEY_SIZE;
1528 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CIPHER_WEP128;
1530 else if (erq->length == MIN_WEP_KEY_SIZE)
1532 pAdapter->SharedKey[BSS0][keyIdx].KeyLen = MIN_WEP_KEY_SIZE;
1533 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CIPHER_WEP64;
1536 /* Disable the key */
1537 pAdapter->SharedKey[BSS0][keyIdx].KeyLen = 0;
1539 /* Check if the key is not marked as invalid */
1540 if(!(erq->flags & IW_ENCODE_NOKEY)) {
1541 /* Copy the key in the driver */
1542 NdisMoveMemory(pAdapter->SharedKey[BSS0][keyIdx].Key, extra, erq->length);
1547 /* Do we want to just set the transmit key index ? */
1548 int index = (erq->flags & IW_ENCODE_INDEX) - 1;
1549 if ((index >= 0) && (index < 4))
1551 pAdapter->StaCfg.DefaultKeyId = index;
1554 /* Don't complain if only change the mode */
1555 if (!(erq->flags & IW_ENCODE_MODE)) {
1561 DBGPRINT(RT_DEBUG_TRACE ,("==>rt_ioctl_siwencode::erq->flags=%x\n",erq->flags));
1562 DBGPRINT(RT_DEBUG_TRACE ,("==>rt_ioctl_siwencode::AuthMode=%x\n",pAdapter->StaCfg.AuthMode));
1563 DBGPRINT(RT_DEBUG_TRACE ,("==>rt_ioctl_siwencode::DefaultKeyId=%x, KeyLen = %d\n",pAdapter->StaCfg.DefaultKeyId , pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].KeyLen));
1564 DBGPRINT(RT_DEBUG_TRACE ,("==>rt_ioctl_siwencode::WepStatus=%x\n",pAdapter->StaCfg.WepStatus));
1569 rt_ioctl_giwencode(struct net_device *dev,
1570 struct iw_request_info *info,
1571 struct iw_point *erq, char *key)
1573 PRTMP_ADAPTER pAdapter = dev->ml_priv;
1576 //check if the interface is down
1577 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1579 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1583 kid = erq->flags & IW_ENCODE_INDEX;
1584 DBGPRINT(RT_DEBUG_TRACE, ("===>rt_ioctl_giwencode %d\n", erq->flags & IW_ENCODE_INDEX));
1586 if (pAdapter->StaCfg.WepStatus == Ndis802_11WEPDisabled)
1589 erq->flags = IW_ENCODE_DISABLED;
1591 else if ((kid > 0) && (kid <=4))
1594 erq->flags = kid ; /* NB: base 1 */
1595 if (erq->length > pAdapter->SharedKey[BSS0][kid-1].KeyLen)
1596 erq->length = pAdapter->SharedKey[BSS0][kid-1].KeyLen;
1597 memcpy(key, pAdapter->SharedKey[BSS0][kid-1].Key, erq->length);
1598 //if ((kid == pAdapter->PortCfg.DefaultKeyId))
1599 //erq->flags |= IW_ENCODE_ENABLED; /* XXX */
1600 if (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeShared)
1601 erq->flags |= IW_ENCODE_RESTRICTED; /* XXX */
1603 erq->flags |= IW_ENCODE_OPEN; /* XXX */
1608 if (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeShared)
1609 erq->flags |= IW_ENCODE_RESTRICTED; /* XXX */
1611 erq->flags |= IW_ENCODE_OPEN; /* XXX */
1612 erq->length = pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].KeyLen;
1613 memcpy(key, pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].Key, erq->length);
1614 // copy default key ID
1615 if (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeShared)
1616 erq->flags |= IW_ENCODE_RESTRICTED; /* XXX */
1618 erq->flags |= IW_ENCODE_OPEN; /* XXX */
1619 erq->flags = pAdapter->StaCfg.DefaultKeyId + 1; /* NB: base 1 */
1620 erq->flags |= IW_ENCODE_ENABLED; /* XXX */
1628 rt_ioctl_setparam(struct net_device *dev, struct iw_request_info *info,
1629 void *w, char *extra)
1631 PRTMP_ADAPTER pAdapter = dev->ml_priv;
1632 POS_COOKIE pObj = (POS_COOKIE)pAdapter->OS_Cookie;
1633 char *this_char = extra;
1638 pObj->ioctl_if_type = INT_MAIN;
1639 pObj->ioctl_if = MAIN_MBSSID;
1642 //check if the interface is down
1643 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1645 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1652 if ((value = rtstrchr(this_char, '=')) != NULL)
1658 // reject setting nothing besides ANY ssid(ssidLen=0)
1659 if (!*value && (strcmp(this_char, "SSID") != 0))
1662 for (PRTMP_PRIVATE_SET_PROC = RTMP_PRIVATE_SUPPORT_PROC; PRTMP_PRIVATE_SET_PROC->name; PRTMP_PRIVATE_SET_PROC++)
1664 if (strcmp(this_char, PRTMP_PRIVATE_SET_PROC->name) == 0)
1666 if(!PRTMP_PRIVATE_SET_PROC->set_proc(pAdapter, value))
1667 { //FALSE:Set private failed then return Invalid argument
1670 break; //Exit for loop.
1674 if(PRTMP_PRIVATE_SET_PROC->name == NULL)
1675 { //Not found argument
1677 DBGPRINT(RT_DEBUG_TRACE, ("===>rt_ioctl_setparam:: (iwpriv) Not Support Set Command [%s=%s]\n", this_char, value));
1685 rt_private_get_statistics(struct net_device *dev, struct iw_request_info *info,
1686 struct iw_point *wrq, char *extra)
1689 PRTMP_ADAPTER pAd = dev->ml_priv;
1697 memset(extra, 0x00, IW_PRIV_SIZE_MASK);
1698 sprintf(extra, "\n\n");
1701 sprintf(extra+strlen(extra), "Tx success = %ld\n", (ULONG)pAd->WlanCounters.TransmittedFragmentCount.QuadPart);
1702 sprintf(extra+strlen(extra), "Tx success without retry = %ld\n", (ULONG)pAd->WlanCounters.TransmittedFragmentCount.QuadPart - (ULONG)pAd->WlanCounters.RetryCount.QuadPart);
1704 sprintf(extra+strlen(extra), "Tx success after retry = %ld\n", (ULONG)pAd->WlanCounters.RetryCount.QuadPart);
1705 sprintf(extra+strlen(extra), "Tx fail to Rcv ACK after retry = %ld\n", (ULONG)pAd->WlanCounters.FailedCount.QuadPart);
1706 sprintf(extra+strlen(extra), "RTS Success Rcv CTS = %ld\n", (ULONG)pAd->WlanCounters.RTSSuccessCount.QuadPart);
1707 sprintf(extra+strlen(extra), "RTS Fail Rcv CTS = %ld\n", (ULONG)pAd->WlanCounters.RTSFailureCount.QuadPart);
1709 sprintf(extra+strlen(extra), "Rx success = %ld\n", (ULONG)pAd->WlanCounters.ReceivedFragmentCount.QuadPart);
1710 sprintf(extra+strlen(extra), "Rx with CRC = %ld\n", (ULONG)pAd->WlanCounters.FCSErrorCount.QuadPart);
1711 sprintf(extra+strlen(extra), "Rx drop due to out of resource = %ld\n", (ULONG)pAd->Counters8023.RxNoBuffer);
1712 sprintf(extra+strlen(extra), "Rx duplicate frame = %ld\n", (ULONG)pAd->WlanCounters.FrameDuplicateCount.QuadPart);
1714 sprintf(extra+strlen(extra), "False CCA (one second) = %ld\n", (ULONG)pAd->RalinkCounters.OneSecFalseCCACnt);
1716 sprintf(extra+strlen(extra), "RSSI-A = %ld\n", (LONG)(pAd->StaCfg.RssiSample.LastRssi0 - pAd->BbpRssiToDbmDelta));
1717 sprintf(extra+strlen(extra), "RSSI-B (if available) = %ld\n", (LONG)(pAd->StaCfg.RssiSample.LastRssi1 - pAd->BbpRssiToDbmDelta));
1718 sprintf(extra+strlen(extra), "RSSI-C (if available) = %ld\n\n", (LONG)(pAd->StaCfg.RssiSample.LastRssi2 - pAd->BbpRssiToDbmDelta));
1720 sprintf(extra+strlen(extra), "WpaSupplicantUP = %d\n\n", pAd->StaCfg.WpaSupplicantUP);
1722 wrq->length = strlen(extra) + 1; // 1: size of '\0'
1723 DBGPRINT(RT_DEBUG_TRACE, ("<== rt_private_get_statistics, wrq->length = %d\n", wrq->length));
1729 IN PRTMP_ADAPTER pAd,
1733 BA_ORI_ENTRY *pOriBAEntry;
1734 BA_REC_ENTRY *pRecBAEntry;
1736 for (i=0; i<MAX_LEN_OF_MAC_TABLE; i++)
1738 PMAC_TABLE_ENTRY pEntry = &pAd->MacTab.Content[i];
1739 if (((pEntry->ValidAsCLI || pEntry->ValidAsApCli) && (pEntry->Sst == SST_ASSOC))
1740 || (pEntry->ValidAsWDS) || (pEntry->ValidAsMesh))
1742 sprintf(pOutBuf + strlen(pOutBuf), "\n%02X:%02X:%02X:%02X:%02X:%02X (Aid = %d) (AP) -\n",
1743 pEntry->Addr[0], pEntry->Addr[1], pEntry->Addr[2],
1744 pEntry->Addr[3], pEntry->Addr[4], pEntry->Addr[5], pEntry->Aid);
1746 sprintf(pOutBuf, "%s[Recipient]\n", pOutBuf);
1747 for (j=0; j < NUM_OF_TID; j++)
1749 if (pEntry->BARecWcidArray[j] != 0)
1751 pRecBAEntry =&pAd->BATable.BARecEntry[pEntry->BARecWcidArray[j]];
1752 sprintf(pOutBuf + strlen(pOutBuf), "TID=%d, BAWinSize=%d, LastIndSeq=%d, ReorderingPkts=%d\n", j, pRecBAEntry->BAWinSize, pRecBAEntry->LastIndSeq, pRecBAEntry->list.qlen);
1755 sprintf(pOutBuf, "%s\n", pOutBuf);
1757 sprintf(pOutBuf, "%s[Originator]\n", pOutBuf);
1758 for (j=0; j < NUM_OF_TID; j++)
1760 if (pEntry->BAOriWcidArray[j] != 0)
1762 pOriBAEntry =&pAd->BATable.BAOriEntry[pEntry->BAOriWcidArray[j]];
1763 sprintf(pOutBuf + strlen(pOutBuf), "TID=%d, BAWinSize=%d, StartSeq=%d, CurTxSeq=%d\n", j, pOriBAEntry->BAWinSize, pOriBAEntry->Sequence, pEntry->TxSeq[j]);
1766 sprintf(pOutBuf, "%s\n\n", pOutBuf);
1768 if (strlen(pOutBuf) > (IW_PRIV_SIZE_MASK - 30))
1776 rt_private_show(struct net_device *dev, struct iw_request_info *info,
1777 struct iw_point *wrq, char *extra)
1780 PRTMP_ADAPTER pAd = dev->ml_priv;
1781 POS_COOKIE pObj = (POS_COOKIE) pAd->OS_Cookie;
1782 u32 subcmd = wrq->flags;
1789 memset(extra, 0x00, IW_PRIV_SIZE_MASK);
1792 pObj->ioctl_if_type = INT_MAIN;
1793 pObj->ioctl_if = MAIN_MBSSID;
1799 case SHOW_CONN_STATUS:
1800 if (MONITOR_ON(pAd))
1802 if (pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED &&
1803 pAd->CommonCfg.RegTransmitSetting.field.BW)
1804 sprintf(extra, "Monitor Mode(CentralChannel %d)\n", pAd->CommonCfg.CentralChannel);
1806 sprintf(extra, "Monitor Mode(Channel %d)\n", pAd->CommonCfg.Channel);
1810 if (pAd->IndicateMediaState == NdisMediaStateConnected)
1814 sprintf(extra, "Connected(AP: %s[%02X:%02X:%02X:%02X:%02X:%02X])\n",
1815 pAd->CommonCfg.Ssid,
1816 pAd->CommonCfg.Bssid[0],
1817 pAd->CommonCfg.Bssid[1],
1818 pAd->CommonCfg.Bssid[2],
1819 pAd->CommonCfg.Bssid[3],
1820 pAd->CommonCfg.Bssid[4],
1821 pAd->CommonCfg.Bssid[5]);
1822 DBGPRINT(RT_DEBUG_TRACE ,("Ssid=%s ,Ssidlen = %d\n",pAd->CommonCfg.Ssid, pAd->CommonCfg.SsidLen));
1824 else if (ADHOC_ON(pAd))
1825 sprintf(extra, "Connected\n");
1829 sprintf(extra, "Disconnected\n");
1830 DBGPRINT(RT_DEBUG_TRACE ,("ConnStatus is not connected\n"));
1833 wrq->length = strlen(extra) + 1; // 1: size of '\0'
1835 case SHOW_DRVIER_VERION:
1836 sprintf(extra, "Driver version-%s, %s %s\n", STA_DRIVER_VERSION, __DATE__, __TIME__ );
1837 wrq->length = strlen(extra) + 1; // 1: size of '\0'
1840 getBaInfo(pAd, extra);
1841 wrq->length = strlen(extra) + 1; // 1: size of '\0'
1843 case SHOW_DESC_INFO:
1845 Show_DescInfo_Proc(pAd, NULL);
1846 wrq->length = 0; // 1: size of '\0'
1850 if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
1852 sprintf(extra, "Scanning\n");
1853 wrq->length = strlen(extra) + 1; // 1: size of '\0'
1856 pAd->StaCfg.bSwRadio = FALSE;
1857 if (pAd->StaCfg.bRadio != (pAd->StaCfg.bHwRadio && pAd->StaCfg.bSwRadio))
1859 pAd->StaCfg.bRadio = (pAd->StaCfg.bHwRadio && pAd->StaCfg.bSwRadio);
1860 if (pAd->StaCfg.bRadio == FALSE)
1863 // Update extra information
1864 pAd->ExtraInfo = SW_RADIO_OFF;
1867 sprintf(extra, "Radio Off\n");
1868 wrq->length = strlen(extra) + 1; // 1: size of '\0'
1872 if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
1874 sprintf(extra, "Scanning\n");
1875 wrq->length = strlen(extra) + 1; // 1: size of '\0'
1879 pAd->StaCfg.bSwRadio = TRUE;
1880 //if (pAd->StaCfg.bRadio != (pAd->StaCfg.bHwRadio && pAd->StaCfg.bSwRadio))
1882 pAd->StaCfg.bRadio = (pAd->StaCfg.bHwRadio && pAd->StaCfg.bSwRadio);
1883 if (pAd->StaCfg.bRadio == TRUE)
1886 // Update extra information
1887 pAd->ExtraInfo = EXTRA_INFO_CLEAR;
1890 sprintf(extra, "Radio On\n");
1891 wrq->length = strlen(extra) + 1; // 1: size of '\0'
1894 case SHOW_CFG_VALUE:
1896 Status = RTMPShowCfgValue(pAd, wrq->pointer, extra);
1898 wrq->length = strlen(extra) + 1; // 1: size of '\0'
1901 #if !defined(RT2860) && !defined(RT30xx)
1902 case SHOW_ADHOC_ENTRY_INFO:
1903 Show_Adhoc_MacTable_Proc(pAd, extra);
1904 wrq->length = strlen(extra) + 1; // 1: size of '\0'
1908 DBGPRINT(RT_DEBUG_TRACE, ("%s - unknow subcmd = %d\n", __func__, subcmd));
1915 int rt_ioctl_siwmlme(struct net_device *dev,
1916 struct iw_request_info *info,
1917 union iwreq_data *wrqu,
1920 PRTMP_ADAPTER pAd = dev->ml_priv;
1921 struct iw_mlme *pMlme = (struct iw_mlme *)wrqu->data.pointer;
1922 MLME_QUEUE_ELEM MsgElem;
1923 MLME_DISASSOC_REQ_STRUCT DisAssocReq;
1924 MLME_DEAUTH_REQ_STRUCT DeAuthReq;
1926 DBGPRINT(RT_DEBUG_TRACE, ("====> %s\n", __func__));
1933 #ifdef IW_MLME_DEAUTH
1934 case IW_MLME_DEAUTH:
1935 DBGPRINT(RT_DEBUG_TRACE, ("====> %s - IW_MLME_DEAUTH\n", __func__));
1936 COPY_MAC_ADDR(DeAuthReq.Addr, pAd->CommonCfg.Bssid);
1937 DeAuthReq.Reason = pMlme->reason_code;
1938 MsgElem.MsgLen = sizeof(MLME_DEAUTH_REQ_STRUCT);
1939 NdisMoveMemory(MsgElem.Msg, &DeAuthReq, sizeof(MLME_DEAUTH_REQ_STRUCT));
1940 MlmeDeauthReqAction(pAd, &MsgElem);
1943 LinkDown(pAd, FALSE);
1944 pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
1947 #endif // IW_MLME_DEAUTH //
1948 #ifdef IW_MLME_DISASSOC
1949 case IW_MLME_DISASSOC:
1950 DBGPRINT(RT_DEBUG_TRACE, ("====> %s - IW_MLME_DISASSOC\n", __func__));
1951 COPY_MAC_ADDR(DisAssocReq.Addr, pAd->CommonCfg.Bssid);
1952 DisAssocReq.Reason = pMlme->reason_code;
1954 MsgElem.Machine = ASSOC_STATE_MACHINE;
1955 MsgElem.MsgType = MT2_MLME_DISASSOC_REQ;
1956 MsgElem.MsgLen = sizeof(MLME_DISASSOC_REQ_STRUCT);
1957 NdisMoveMemory(MsgElem.Msg, &DisAssocReq, sizeof(MLME_DISASSOC_REQ_STRUCT));
1959 pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_OID_DISASSOC;
1960 MlmeDisassocReqAction(pAd, &MsgElem);
1962 #endif // IW_MLME_DISASSOC //
1964 DBGPRINT(RT_DEBUG_TRACE, ("====> %s - Unknow Command\n", __func__));
1971 int rt_ioctl_siwauth(struct net_device *dev,
1972 struct iw_request_info *info,
1973 union iwreq_data *wrqu, char *extra)
1975 PRTMP_ADAPTER pAdapter = dev->ml_priv;
1976 struct iw_param *param = &wrqu->param;
1978 //check if the interface is down
1979 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1981 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1984 switch (param->flags & IW_AUTH_INDEX) {
1985 case IW_AUTH_WPA_VERSION:
1986 if (param->value == IW_AUTH_WPA_VERSION_WPA)
1988 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPAPSK;
1989 if (pAdapter->StaCfg.BssType == BSS_ADHOC)
1990 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPANone;
1992 else if (param->value == IW_AUTH_WPA_VERSION_WPA2)
1993 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA2PSK;
1995 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_WPA_VERSION - param->value = %d!\n", __func__, param->value));
1997 case IW_AUTH_CIPHER_PAIRWISE:
1998 if (param->value == IW_AUTH_CIPHER_NONE)
2000 pAdapter->StaCfg.WepStatus = Ndis802_11WEPDisabled;
2001 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
2002 pAdapter->StaCfg.PairCipher = Ndis802_11WEPDisabled;
2004 else if (param->value == IW_AUTH_CIPHER_WEP40 ||
2005 param->value == IW_AUTH_CIPHER_WEP104)
2007 pAdapter->StaCfg.WepStatus = Ndis802_11WEPEnabled;
2008 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
2009 pAdapter->StaCfg.PairCipher = Ndis802_11WEPEnabled;
2010 pAdapter->StaCfg.IEEE8021X = FALSE;
2012 else if (param->value == IW_AUTH_CIPHER_TKIP)
2014 pAdapter->StaCfg.WepStatus = Ndis802_11Encryption2Enabled;
2015 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
2016 pAdapter->StaCfg.PairCipher = Ndis802_11Encryption2Enabled;
2018 else if (param->value == IW_AUTH_CIPHER_CCMP)
2020 pAdapter->StaCfg.WepStatus = Ndis802_11Encryption3Enabled;
2021 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
2022 pAdapter->StaCfg.PairCipher = Ndis802_11Encryption3Enabled;
2024 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_CIPHER_PAIRWISE - param->value = %d!\n", __func__, param->value));
2026 case IW_AUTH_CIPHER_GROUP:
2027 if (param->value == IW_AUTH_CIPHER_NONE)
2029 pAdapter->StaCfg.GroupCipher = Ndis802_11WEPDisabled;
2031 else if (param->value == IW_AUTH_CIPHER_WEP40 ||
2032 param->value == IW_AUTH_CIPHER_WEP104)
2034 pAdapter->StaCfg.GroupCipher = Ndis802_11WEPEnabled;
2036 else if (param->value == IW_AUTH_CIPHER_TKIP)
2038 pAdapter->StaCfg.GroupCipher = Ndis802_11Encryption2Enabled;
2040 else if (param->value == IW_AUTH_CIPHER_CCMP)
2042 pAdapter->StaCfg.GroupCipher = Ndis802_11Encryption3Enabled;
2044 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_CIPHER_GROUP - param->value = %d!\n", __func__, param->value));
2046 case IW_AUTH_KEY_MGMT:
2047 if (param->value == IW_AUTH_KEY_MGMT_802_1X)
2049 if (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK)
2051 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA;
2052 pAdapter->StaCfg.IEEE8021X = FALSE;
2054 else if (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK)
2056 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA2;
2057 pAdapter->StaCfg.IEEE8021X = FALSE;
2061 pAdapter->StaCfg.IEEE8021X = TRUE;
2063 else if (param->value == 0)
2065 STA_PORT_SECURED(pAdapter);
2067 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_KEY_MGMT - param->value = %d!\n", __func__, param->value));
2069 case IW_AUTH_RX_UNENCRYPTED_EAPOL:
2071 case IW_AUTH_PRIVACY_INVOKED:
2072 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_PRIVACY_INVOKED - param->value = %d!\n", __func__, param->value));
2074 case IW_AUTH_DROP_UNENCRYPTED:
2075 if (param->value != 0)
2076 pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED;
2079 STA_PORT_SECURED(pAdapter);
2081 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_WPA_VERSION - param->value = %d!\n", __func__, param->value));
2083 case IW_AUTH_80211_AUTH_ALG:
2084 if (param->value & IW_AUTH_ALG_SHARED_KEY)
2086 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeShared;
2088 else if (param->value & IW_AUTH_ALG_OPEN_SYSTEM)
2090 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
2094 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_80211_AUTH_ALG - param->value = %d!\n", __func__, param->value));
2096 case IW_AUTH_WPA_ENABLED:
2097 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_WPA_ENABLED - Driver supports WPA!(param->value = %d)\n", __func__, param->value));
2106 int rt_ioctl_giwauth(struct net_device *dev,
2107 struct iw_request_info *info,
2108 union iwreq_data *wrqu, char *extra)
2110 PRTMP_ADAPTER pAdapter = dev->ml_priv;
2111 struct iw_param *param = &wrqu->param;
2113 //check if the interface is down
2114 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
2116 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
2120 switch (param->flags & IW_AUTH_INDEX) {
2121 case IW_AUTH_DROP_UNENCRYPTED:
2122 param->value = (pAdapter->StaCfg.WepStatus == Ndis802_11WEPDisabled) ? 0 : 1;
2125 case IW_AUTH_80211_AUTH_ALG:
2126 param->value = (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeShared) ? IW_AUTH_ALG_SHARED_KEY : IW_AUTH_ALG_OPEN_SYSTEM;
2129 case IW_AUTH_WPA_ENABLED:
2130 param->value = (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA) ? 1 : 0;
2136 DBGPRINT(RT_DEBUG_TRACE, ("rt_ioctl_giwauth::param->value = %d!\n", param->value));
2140 void fnSetCipherKey(
2141 IN PRTMP_ADAPTER pAdapter,
2145 IN struct iw_encode_ext *ext)
2148 RTMP_CLEAR_PSFLAG(pAdapter, fRTMP_PS_CAN_GO_SLEEP);
2149 if (RTMP_TEST_PSFLAG(pAdapter, fRTMP_PS_SET_PCI_CLK_OFF_COMMAND))
2151 if (pAdapter->StaCfg.bRadio == FALSE)
2153 RTMP_SET_PSFLAG(pAdapter, fRTMP_PS_CAN_GO_SLEEP);
2156 DBGPRINT(RT_DEBUG_TRACE,("RTMPWPAAddKeyProc1==>\n"));
2157 RTMPPCIeLinkCtrlValueRestore(pAdapter, RESTORE_HALT);
2158 RTMPusecDelay(6000);
2159 pAdapter->bPCIclkOff = FALSE;
2162 NdisZeroMemory(&pAdapter->SharedKey[BSS0][keyIdx], sizeof(CIPHER_KEY));
2163 pAdapter->SharedKey[BSS0][keyIdx].KeyLen = LEN_TKIP_EK;
2164 NdisMoveMemory(pAdapter->SharedKey[BSS0][keyIdx].Key, ext->key, LEN_TKIP_EK);
2165 NdisMoveMemory(pAdapter->SharedKey[BSS0][keyIdx].TxMic, ext->key + LEN_TKIP_EK, LEN_TKIP_TXMICK);
2166 NdisMoveMemory(pAdapter->SharedKey[BSS0][keyIdx].RxMic, ext->key + LEN_TKIP_EK + LEN_TKIP_TXMICK, LEN_TKIP_RXMICK);
2167 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CipherAlg;
2169 // Update group key information to ASIC Shared Key Table
2170 AsicAddSharedKeyEntry(pAdapter,
2173 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg,
2174 pAdapter->SharedKey[BSS0][keyIdx].Key,
2175 pAdapter->SharedKey[BSS0][keyIdx].TxMic,
2176 pAdapter->SharedKey[BSS0][keyIdx].RxMic);
2179 // Update ASIC WCID attribute table and IVEIV table
2180 RTMPAddWcidAttributeEntry(pAdapter,
2183 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg,
2186 // Update ASIC WCID attribute table and IVEIV table
2187 RTMPAddWcidAttributeEntry(pAdapter,
2190 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg,
2191 &pAdapter->MacTab.Content[BSSID_WCID]);
2193 RTMP_SET_PSFLAG(pAdapter, fRTMP_PS_CAN_GO_SLEEP);
2197 int rt_ioctl_siwencodeext(struct net_device *dev,
2198 struct iw_request_info *info,
2199 union iwreq_data *wrqu,
2202 PRTMP_ADAPTER pAdapter = dev->ml_priv;
2203 struct iw_point *encoding = &wrqu->encoding;
2204 struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
2205 int keyIdx, alg = ext->alg;
2207 //check if the interface is down
2208 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
2210 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
2214 if (encoding->flags & IW_ENCODE_DISABLED)
2216 keyIdx = (encoding->flags & IW_ENCODE_INDEX) - 1;
2217 // set BSSID wcid entry of the Pair-wise Key table as no-security mode
2218 AsicRemovePairwiseKeyEntry(pAdapter, BSS0, BSSID_WCID);
2219 pAdapter->SharedKey[BSS0][keyIdx].KeyLen = 0;
2220 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CIPHER_NONE;
2221 AsicRemoveSharedKeyEntry(pAdapter, 0, (UCHAR)keyIdx);
2222 NdisZeroMemory(&pAdapter->SharedKey[BSS0][keyIdx], sizeof(CIPHER_KEY));
2223 DBGPRINT(RT_DEBUG_TRACE, ("%s::Remove all keys!(encoding->flags = %x)\n", __func__, encoding->flags));
2227 // Get Key Index and convet to our own defined key index
2228 keyIdx = (encoding->flags & IW_ENCODE_INDEX) - 1;
2229 if((keyIdx < 0) || (keyIdx >= NR_WEP_KEYS))
2232 if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
2234 pAdapter->StaCfg.DefaultKeyId = keyIdx;
2235 DBGPRINT(RT_DEBUG_TRACE, ("%s::DefaultKeyId = %d\n", __func__, pAdapter->StaCfg.DefaultKeyId));
2239 case IW_ENCODE_ALG_NONE:
2240 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_ENCODE_ALG_NONE\n", __func__));
2242 case IW_ENCODE_ALG_WEP:
2243 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_ENCODE_ALG_WEP - ext->key_len = %d, keyIdx = %d\n", __func__, ext->key_len, keyIdx));
2244 if (ext->key_len == MAX_WEP_KEY_SIZE)
2246 pAdapter->SharedKey[BSS0][keyIdx].KeyLen = MAX_WEP_KEY_SIZE;
2247 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CIPHER_WEP128;
2249 else if (ext->key_len == MIN_WEP_KEY_SIZE)
2251 pAdapter->SharedKey[BSS0][keyIdx].KeyLen = MIN_WEP_KEY_SIZE;
2252 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CIPHER_WEP64;
2257 NdisZeroMemory(pAdapter->SharedKey[BSS0][keyIdx].Key, 16);
2258 NdisMoveMemory(pAdapter->SharedKey[BSS0][keyIdx].Key, ext->key, ext->key_len);
2260 if (pAdapter->StaCfg.GroupCipher == Ndis802_11GroupWEP40Enabled ||
2261 pAdapter->StaCfg.GroupCipher == Ndis802_11GroupWEP104Enabled)
2263 // Set Group key material to Asic
2264 AsicAddSharedKeyEntry(pAdapter, BSS0, keyIdx, pAdapter->SharedKey[BSS0][keyIdx].CipherAlg, pAdapter->SharedKey[BSS0][keyIdx].Key, NULL, NULL);
2266 // Update WCID attribute table and IVEIV table for this group key table
2267 RTMPAddWcidAttributeEntry(pAdapter, BSS0, keyIdx, pAdapter->SharedKey[BSS0][keyIdx].CipherAlg, NULL);
2269 STA_PORT_SECURED(pAdapter);
2271 // Indicate Connected for GUI
2272 pAdapter->IndicateMediaState = NdisMediaStateConnected;
2276 case IW_ENCODE_ALG_TKIP:
2277 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_ENCODE_ALG_TKIP - keyIdx = %d, ext->key_len = %d\n", __func__, keyIdx, ext->key_len));
2278 if (ext->key_len == 32)
2280 if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
2282 fnSetCipherKey(pAdapter, keyIdx, CIPHER_TKIP, FALSE, ext);
2283 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA2)
2285 STA_PORT_SECURED(pAdapter);
2288 else if (ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY)
2290 fnSetCipherKey(pAdapter, keyIdx, CIPHER_TKIP, TRUE, ext);
2292 // set 802.1x port control
2293 STA_PORT_SECURED(pAdapter);
2299 case IW_ENCODE_ALG_CCMP:
2300 if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
2302 fnSetCipherKey(pAdapter, keyIdx, CIPHER_AES, FALSE, ext);
2303 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA2)
2304 STA_PORT_SECURED(pAdapter);
2306 else if (ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY)
2308 fnSetCipherKey(pAdapter, keyIdx, CIPHER_AES, TRUE, ext);
2310 // set 802.1x port control
2311 STA_PORT_SECURED(pAdapter);
2323 rt_ioctl_giwencodeext(struct net_device *dev,
2324 struct iw_request_info *info,
2325 union iwreq_data *wrqu, char *extra)
2327 PRTMP_ADAPTER pAd = dev->ml_priv;
2329 struct iw_point *encoding = &wrqu->encoding;
2330 struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
2331 int idx, max_key_len;
2333 DBGPRINT(RT_DEBUG_TRACE ,("===> rt_ioctl_giwencodeext\n"));
2335 max_key_len = encoding->length - sizeof(*ext);
2336 if (max_key_len < 0)
2339 idx = encoding->flags & IW_ENCODE_INDEX;
2342 if (idx < 1 || idx > 4)
2346 if ((pAd->StaCfg.WepStatus == Ndis802_11Encryption2Enabled) ||
2347 (pAd->StaCfg.WepStatus == Ndis802_11Encryption3Enabled))
2349 if (idx != pAd->StaCfg.DefaultKeyId)
2357 idx = pAd->StaCfg.DefaultKeyId;
2359 encoding->flags = idx + 1;
2360 memset(ext, 0, sizeof(*ext));
2363 switch(pAd->StaCfg.WepStatus) {
2364 case Ndis802_11WEPDisabled:
2365 ext->alg = IW_ENCODE_ALG_NONE;
2366 encoding->flags |= IW_ENCODE_DISABLED;
2368 case Ndis802_11WEPEnabled:
2369 ext->alg = IW_ENCODE_ALG_WEP;
2370 if (pAd->SharedKey[BSS0][idx].KeyLen > max_key_len)
2374 ext->key_len = pAd->SharedKey[BSS0][idx].KeyLen;
2375 pKey = &(pAd->SharedKey[BSS0][idx].Key[0]);
2378 case Ndis802_11Encryption2Enabled:
2379 case Ndis802_11Encryption3Enabled:
2380 if (pAd->StaCfg.WepStatus == Ndis802_11Encryption2Enabled)
2381 ext->alg = IW_ENCODE_ALG_TKIP;
2383 ext->alg = IW_ENCODE_ALG_CCMP;
2385 if (max_key_len < 32)
2390 pKey = &pAd->StaCfg.PMK[0];
2397 if (ext->key_len && pKey)
2399 encoding->flags |= IW_ENCODE_ENABLED;
2400 memcpy(ext->key, pKey, ext->key_len);
2406 int rt_ioctl_siwgenie(struct net_device *dev,
2407 struct iw_request_info *info,
2408 union iwreq_data *wrqu, char *extra)
2410 PRTMP_ADAPTER pAd = dev->ml_priv;
2412 if (wrqu->data.length > MAX_LEN_OF_RSNIE ||
2413 (wrqu->data.length && extra == NULL))
2416 if (wrqu->data.length)
2418 pAd->StaCfg.RSNIE_Len = wrqu->data.length;
2419 NdisMoveMemory(&pAd->StaCfg.RSN_IE[0], extra, pAd->StaCfg.RSNIE_Len);
2423 pAd->StaCfg.RSNIE_Len = 0;
2424 NdisZeroMemory(&pAd->StaCfg.RSN_IE[0], MAX_LEN_OF_RSNIE);
2430 int rt_ioctl_giwgenie(struct net_device *dev,
2431 struct iw_request_info *info,
2432 union iwreq_data *wrqu, char *extra)
2434 PRTMP_ADAPTER pAd = dev->ml_priv;
2436 if ((pAd->StaCfg.RSNIE_Len == 0) ||
2437 (pAd->StaCfg.AuthMode < Ndis802_11AuthModeWPA))
2439 wrqu->data.length = 0;
2443 if (pAd->StaCfg.WpaSupplicantUP == WPA_SUPPLICANT_ENABLE)
2445 if (wrqu->data.length < pAd->StaCfg.RSNIE_Len)
2448 wrqu->data.length = pAd->StaCfg.RSNIE_Len;
2449 memcpy(extra, &pAd->StaCfg.RSN_IE[0], pAd->StaCfg.RSNIE_Len);
2453 UCHAR RSNIe = IE_WPA;
2455 if (wrqu->data.length < (pAd->StaCfg.RSNIE_Len + 2)) // ID, Len
2457 wrqu->data.length = pAd->StaCfg.RSNIE_Len + 2;
2459 if ((pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK) ||
2460 (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2))
2463 extra[0] = (char)RSNIe;
2464 extra[1] = pAd->StaCfg.RSNIE_Len;
2465 memcpy(extra+2, &pAd->StaCfg.RSN_IE[0], pAd->StaCfg.RSNIE_Len);
2471 int rt_ioctl_siwpmksa(struct net_device *dev,
2472 struct iw_request_info *info,
2473 union iwreq_data *wrqu,
2476 PRTMP_ADAPTER pAd = dev->ml_priv;
2477 struct iw_pmksa *pPmksa = (struct iw_pmksa *)wrqu->data.pointer;
2478 INT CachedIdx = 0, idx = 0;
2483 DBGPRINT(RT_DEBUG_TRACE ,("===> rt_ioctl_siwpmksa\n"));
2486 case IW_PMKSA_FLUSH:
2487 NdisZeroMemory(pAd->StaCfg.SavedPMK, sizeof(BSSID_INFO)*PMKID_NO);
2488 DBGPRINT(RT_DEBUG_TRACE ,("rt_ioctl_siwpmksa - IW_PMKSA_FLUSH\n"));
2490 case IW_PMKSA_REMOVE:
2491 for (CachedIdx = 0; CachedIdx < pAd->StaCfg.SavedPMKNum; CachedIdx++)
2493 // compare the BSSID
2494 if (NdisEqualMemory(pPmksa->bssid.sa_data, pAd->StaCfg.SavedPMK[CachedIdx].BSSID, MAC_ADDR_LEN))
2496 NdisZeroMemory(pAd->StaCfg.SavedPMK[CachedIdx].BSSID, MAC_ADDR_LEN);
2497 NdisZeroMemory(pAd->StaCfg.SavedPMK[CachedIdx].PMKID, 16);
2498 for (idx = CachedIdx; idx < (pAd->StaCfg.SavedPMKNum - 1); idx++)
2500 NdisMoveMemory(&pAd->StaCfg.SavedPMK[idx].BSSID[0], &pAd->StaCfg.SavedPMK[idx+1].BSSID[0], MAC_ADDR_LEN);
2501 NdisMoveMemory(&pAd->StaCfg.SavedPMK[idx].PMKID[0], &pAd->StaCfg.SavedPMK[idx+1].PMKID[0], 16);
2503 pAd->StaCfg.SavedPMKNum--;
2508 DBGPRINT(RT_DEBUG_TRACE ,("rt_ioctl_siwpmksa - IW_PMKSA_REMOVE\n"));
2511 for (CachedIdx = 0; CachedIdx < pAd->StaCfg.SavedPMKNum; CachedIdx++)
2513 // compare the BSSID
2514 if (NdisEqualMemory(pPmksa->bssid.sa_data, pAd->StaCfg.SavedPMK[CachedIdx].BSSID, MAC_ADDR_LEN))
2518 // Found, replace it
2519 if (CachedIdx < PMKID_NO)
2521 DBGPRINT(RT_DEBUG_OFF, ("Update PMKID, idx = %d\n", CachedIdx));
2522 NdisMoveMemory(&pAd->StaCfg.SavedPMK[CachedIdx].BSSID[0], pPmksa->bssid.sa_data, MAC_ADDR_LEN);
2523 NdisMoveMemory(&pAd->StaCfg.SavedPMK[CachedIdx].PMKID[0], pPmksa->pmkid, 16);
2524 pAd->StaCfg.SavedPMKNum++;
2526 // Not found, replace the last one
2529 // Randomly replace one
2530 CachedIdx = (pPmksa->bssid.sa_data[5] % PMKID_NO);
2531 DBGPRINT(RT_DEBUG_OFF, ("Update PMKID, idx = %d\n", CachedIdx));
2532 NdisMoveMemory(&pAd->StaCfg.SavedPMK[CachedIdx].BSSID[0], pPmksa->bssid.sa_data, MAC_ADDR_LEN);
2533 NdisMoveMemory(&pAd->StaCfg.SavedPMK[CachedIdx].PMKID[0], pPmksa->pmkid, 16);
2536 DBGPRINT(RT_DEBUG_TRACE ,("rt_ioctl_siwpmksa - IW_PMKSA_ADD\n"));
2539 DBGPRINT(RT_DEBUG_TRACE ,("rt_ioctl_siwpmksa - Unknow Command!!\n"));
2548 rt_private_ioctl_bbp(struct net_device *dev, struct iw_request_info *info,
2549 struct iw_point *wrq, char *extra)
2556 BOOLEAN bIsPrintAllBBP = FALSE;
2558 PRTMP_ADAPTER pAdapter = dev->ml_priv;
2561 memset(extra, 0x00, IW_PRIV_SIZE_MASK);
2563 if (wrq->length > 1) //No parameters.
2565 sprintf(extra, "\n");
2567 //Parsing Read or Write
2568 this_char = wrq->pointer;
2569 DBGPRINT(RT_DEBUG_TRACE, ("this_char=%s\n", this_char));
2573 if ((value = rtstrchr(this_char, '=')) != NULL)
2576 if (!value || !*value)
2578 DBGPRINT(RT_DEBUG_TRACE, ("this_char=%s, value=%s\n", this_char, value));
2579 if (sscanf(this_char, "%d", &(bbpId)) == 1)
2585 if (bbpId <= 138) // edit by johnli, RF power sequence setup, add BBP R138 for ADC dynamic on/off control
2589 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, ®BBP);
2591 sprintf(extra+strlen(extra), "R%02d[0x%02X]:%02X\n", bbpId, bbpId*2, regBBP);
2592 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2593 DBGPRINT(RT_DEBUG_TRACE, ("msg=%s\n", extra));
2596 {//Invalid parametes, so default printk all bbp
2597 bIsPrintAllBBP = TRUE;
2602 { //Invalid parametes, so default printk all bbp
2603 bIsPrintAllBBP = TRUE;
2609 if ((sscanf(this_char, "%d", &(bbpId)) == 1) && (sscanf(value, "%x", &(bbpValue)) == 1))
2615 if (bbpId <= 138) // edit by johnli, RF power sequence setup, add BBP R138 for ADC dynamic on/off control
2619 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, bbpId, bbpValue);
2620 //Read it back for showing
2621 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, ®BBP);
2623 sprintf(extra+strlen(extra), "R%02d[0x%02X]:%02X\n", bbpId, bbpId*2, regBBP);
2624 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2625 DBGPRINT(RT_DEBUG_TRACE, ("msg=%s\n", extra));
2628 {//Invalid parametes, so default printk all bbp
2629 bIsPrintAllBBP = TRUE;
2634 { //Invalid parametes, so default printk all bbp
2635 bIsPrintAllBBP = TRUE;
2641 bIsPrintAllBBP = TRUE;
2646 memset(extra, 0x00, IW_PRIV_SIZE_MASK);
2647 sprintf(extra, "\n");
2649 for (bbpId = 0; bbpId <= 136; bbpId++)
2652 for (bbpId = 0; bbpId <= 138; bbpId++) // edit by johnli, RF power sequence setup, add BBP R138 for ADC dynamic on/off control
2655 if (strlen(extra) >= (IW_PRIV_SIZE_MASK - 10))
2657 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, ®BBP);
2659 sprintf(extra+strlen(extra), "R%02d[0x%02X]:%02X ", bbpId, bbpId*2, regBBP);
2661 sprintf(extra+strlen(extra), "\n");
2664 sprintf(extra+strlen(extra), "%03d = %02X\n", bbpId, regBBP); // edit by johnli, change display format
2668 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2669 DBGPRINT(RT_DEBUG_TRACE, ("wrq->length = %d\n", wrq->length));
2672 DBGPRINT(RT_DEBUG_TRACE, ("<==rt_private_ioctl_bbp\n\n"));
2678 int rt_ioctl_siwrate(struct net_device *dev,
2679 struct iw_request_info *info,
2680 union iwreq_data *wrqu, char *extra)
2682 PRTMP_ADAPTER pAd = dev->ml_priv;
2683 UINT32 rate = wrqu->bitrate.value, fixed = wrqu->bitrate.fixed;
2685 //check if the interface is down
2686 if(!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_IN_USE))
2688 DBGPRINT(RT_DEBUG_TRACE, ("rt_ioctl_siwrate::Network is down!\n"));
2692 DBGPRINT(RT_DEBUG_TRACE, ("rt_ioctl_siwrate::(rate = %d, fixed = %d)\n", rate, fixed));
2693 /* rate = -1 => auto rate
2694 rate = X, fixed = 1 => (fixed rate X)
2699 pAd->StaCfg.DesiredTransmitSetting.field.MCS = MCS_AUTO;
2700 pAd->StaCfg.bAutoTxRateSwitch = TRUE;
2701 if ((pAd->CommonCfg.PhyMode <= PHY_11G) ||
2702 (pAd->MacTab.Content[BSSID_WCID].HTPhyMode.field.MODE <= MODE_OFDM))
2703 RTMPSetDesiredRates(pAd, -1);
2711 pAd->StaCfg.bAutoTxRateSwitch = FALSE;
2712 if ((pAd->CommonCfg.PhyMode <= PHY_11G) ||
2713 (pAd->MacTab.Content[BSSID_WCID].HTPhyMode.field.MODE <= MODE_OFDM))
2714 RTMPSetDesiredRates(pAd, rate);
2717 pAd->StaCfg.DesiredTransmitSetting.field.MCS = MCS_AUTO;
2720 DBGPRINT(RT_DEBUG_TRACE, ("rt_ioctl_siwrate::(HtMcs=%d)\n",pAd->StaCfg.DesiredTransmitSetting.field.MCS));
2724 // TODO: rate = X, fixed = 0 => (rates <= X)
2732 int rt_ioctl_giwrate(struct net_device *dev,
2733 struct iw_request_info *info,
2734 union iwreq_data *wrqu, char *extra)
2736 PRTMP_ADAPTER pAd = dev->ml_priv;
2737 int rate_index = 0, rate_count = 0;
2738 HTTRANSMIT_SETTING ht_setting;
2739 __s32 ralinkrate[] =
2740 {2, 4, 11, 22, // CCK
2741 12, 18, 24, 36, 48, 72, 96, 108, // OFDM
2742 13, 26, 39, 52, 78, 104, 117, 130, 26, 52, 78, 104, 156, 208, 234, 260, // 20MHz, 800ns GI, MCS: 0 ~ 15
2743 39, 78, 117, 156, 234, 312, 351, 390, // 20MHz, 800ns GI, MCS: 16 ~ 23
2744 27, 54, 81, 108, 162, 216, 243, 270, 54, 108, 162, 216, 324, 432, 486, 540, // 40MHz, 800ns GI, MCS: 0 ~ 15
2745 81, 162, 243, 324, 486, 648, 729, 810, // 40MHz, 800ns GI, MCS: 16 ~ 23
2746 14, 29, 43, 57, 87, 115, 130, 144, 29, 59, 87, 115, 173, 230, 260, 288, // 20MHz, 400ns GI, MCS: 0 ~ 15
2747 43, 87, 130, 173, 260, 317, 390, 433, // 20MHz, 400ns GI, MCS: 16 ~ 23
2748 30, 60, 90, 120, 180, 240, 270, 300, 60, 120, 180, 240, 360, 480, 540, 600, // 40MHz, 400ns GI, MCS: 0 ~ 15
2749 90, 180, 270, 360, 540, 720, 810, 900}; // 40MHz, 400ns GI, MCS: 16 ~ 23
2751 rate_count = sizeof(ralinkrate)/sizeof(__s32);
2752 //check if the interface is down
2753 if(!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_IN_USE))
2755 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
2759 if ((pAd->StaCfg.bAutoTxRateSwitch == FALSE) &&
2761 ((pAd->CommonCfg.PhyMode <= PHY_11G) || (pAd->MacTab.Content[BSSID_WCID].HTPhyMode.field.MODE <= MODE_OFDM)))
2762 ht_setting.word = pAd->StaCfg.HTPhyMode.word;
2764 ht_setting.word = pAd->MacTab.Content[BSSID_WCID].HTPhyMode.word;
2766 if (ht_setting.field.MODE >= MODE_HTMIX)
2768 rate_index = 12 + ((UCHAR)ht_setting.field.BW *24) + ((UCHAR)ht_setting.field.ShortGI *48) + ((UCHAR)ht_setting.field.MCS);
2771 if (ht_setting.field.MODE == MODE_OFDM)
2772 rate_index = (UCHAR)(ht_setting.field.MCS) + 4;
2773 else if (ht_setting.field.MODE == MODE_CCK)
2774 rate_index = (UCHAR)(ht_setting.field.MCS);
2779 if (rate_index > rate_count)
2780 rate_index = rate_count;
2782 wrqu->bitrate.value = ralinkrate[rate_index] * 500000;
2783 wrqu->bitrate.disabled = 0;
2788 static const iw_handler rt_handler[] =
2790 (iw_handler) NULL, /* SIOCSIWCOMMIT */
2791 (iw_handler) rt_ioctl_giwname, /* SIOCGIWNAME */
2792 (iw_handler) NULL, /* SIOCSIWNWID */
2793 (iw_handler) NULL, /* SIOCGIWNWID */
2794 (iw_handler) rt_ioctl_siwfreq, /* SIOCSIWFREQ */
2795 (iw_handler) rt_ioctl_giwfreq, /* SIOCGIWFREQ */
2796 (iw_handler) rt_ioctl_siwmode, /* SIOCSIWMODE */
2797 (iw_handler) rt_ioctl_giwmode, /* SIOCGIWMODE */
2798 (iw_handler) NULL, /* SIOCSIWSENS */
2799 (iw_handler) NULL, /* SIOCGIWSENS */
2800 (iw_handler) NULL /* not used */, /* SIOCSIWRANGE */
2801 (iw_handler) rt_ioctl_giwrange, /* SIOCGIWRANGE */
2802 (iw_handler) NULL /* not used */, /* SIOCSIWPRIV */
2803 (iw_handler) NULL /* kernel code */, /* SIOCGIWPRIV */
2804 (iw_handler) NULL /* not used */, /* SIOCSIWSTATS */
2805 (iw_handler) rt28xx_get_wireless_stats /* kernel code */, /* SIOCGIWSTATS */
2806 (iw_handler) NULL, /* SIOCSIWSPY */
2807 (iw_handler) NULL, /* SIOCGIWSPY */
2808 (iw_handler) NULL, /* SIOCSIWTHRSPY */
2809 (iw_handler) NULL, /* SIOCGIWTHRSPY */
2810 (iw_handler) rt_ioctl_siwap, /* SIOCSIWAP */
2811 (iw_handler) rt_ioctl_giwap, /* SIOCGIWAP */
2812 (iw_handler) rt_ioctl_siwmlme, /* SIOCSIWMLME */
2813 (iw_handler) rt_ioctl_iwaplist, /* SIOCGIWAPLIST */
2814 (iw_handler) rt_ioctl_siwscan, /* SIOCSIWSCAN */
2815 (iw_handler) rt_ioctl_giwscan, /* SIOCGIWSCAN */
2816 (iw_handler) rt_ioctl_siwessid, /* SIOCSIWESSID */
2817 (iw_handler) rt_ioctl_giwessid, /* SIOCGIWESSID */
2818 (iw_handler) rt_ioctl_siwnickn, /* SIOCSIWNICKN */
2819 (iw_handler) rt_ioctl_giwnickn, /* SIOCGIWNICKN */
2820 (iw_handler) NULL, /* -- hole -- */
2821 (iw_handler) NULL, /* -- hole -- */
2822 (iw_handler) rt_ioctl_siwrate, /* SIOCSIWRATE */
2823 (iw_handler) rt_ioctl_giwrate, /* SIOCGIWRATE */
2824 (iw_handler) rt_ioctl_siwrts, /* SIOCSIWRTS */
2825 (iw_handler) rt_ioctl_giwrts, /* SIOCGIWRTS */
2826 (iw_handler) rt_ioctl_siwfrag, /* SIOCSIWFRAG */
2827 (iw_handler) rt_ioctl_giwfrag, /* SIOCGIWFRAG */
2828 (iw_handler) NULL, /* SIOCSIWTXPOW */
2829 (iw_handler) NULL, /* SIOCGIWTXPOW */
2830 (iw_handler) NULL, /* SIOCSIWRETRY */
2831 (iw_handler) NULL, /* SIOCGIWRETRY */
2832 (iw_handler) rt_ioctl_siwencode, /* SIOCSIWENCODE */
2833 (iw_handler) rt_ioctl_giwencode, /* SIOCGIWENCODE */
2834 (iw_handler) NULL, /* SIOCSIWPOWER */
2835 (iw_handler) NULL, /* SIOCGIWPOWER */
2836 (iw_handler) NULL, /* -- hole -- */
2837 (iw_handler) NULL, /* -- hole -- */
2838 (iw_handler) rt_ioctl_siwgenie, /* SIOCSIWGENIE */
2839 (iw_handler) rt_ioctl_giwgenie, /* SIOCGIWGENIE */
2840 (iw_handler) rt_ioctl_siwauth, /* SIOCSIWAUTH */
2841 (iw_handler) rt_ioctl_giwauth, /* SIOCGIWAUTH */
2842 (iw_handler) rt_ioctl_siwencodeext, /* SIOCSIWENCODEEXT */
2843 (iw_handler) rt_ioctl_giwencodeext, /* SIOCGIWENCODEEXT */
2844 (iw_handler) rt_ioctl_siwpmksa, /* SIOCSIWPMKSA */
2847 static const iw_handler rt_priv_handlers[] = {
2848 (iw_handler) NULL, /* + 0x00 */
2849 (iw_handler) NULL, /* + 0x01 */
2850 (iw_handler) rt_ioctl_setparam, /* + 0x02 */
2852 (iw_handler) rt_private_ioctl_bbp, /* + 0x03 */
2854 (iw_handler) NULL, /* + 0x03 */
2856 (iw_handler) NULL, /* + 0x04 */
2857 (iw_handler) NULL, /* + 0x05 */
2858 (iw_handler) NULL, /* + 0x06 */
2859 (iw_handler) NULL, /* + 0x07 */
2860 (iw_handler) NULL, /* + 0x08 */
2861 (iw_handler) rt_private_get_statistics, /* + 0x09 */
2862 (iw_handler) NULL, /* + 0x0A */
2863 (iw_handler) NULL, /* + 0x0B */
2864 (iw_handler) NULL, /* + 0x0C */
2865 (iw_handler) NULL, /* + 0x0D */
2866 (iw_handler) NULL, /* + 0x0E */
2867 (iw_handler) NULL, /* + 0x0F */
2868 (iw_handler) NULL, /* + 0x10 */
2869 (iw_handler) rt_private_show, /* + 0x11 */
2870 (iw_handler) NULL, /* + 0x12 */
2871 (iw_handler) NULL, /* + 0x13 */
2872 (iw_handler) NULL, /* + 0x15 */
2873 (iw_handler) NULL, /* + 0x17 */
2874 (iw_handler) NULL, /* + 0x18 */
2877 const struct iw_handler_def rt28xx_iw_handler_def =
2879 #define N(a) (sizeof (a) / sizeof (a[0]))
2880 .standard = (iw_handler *) rt_handler,
2881 .num_standard = sizeof(rt_handler) / sizeof(iw_handler),
2882 .private = (iw_handler *) rt_priv_handlers,
2883 .num_private = N(rt_priv_handlers),
2884 .private_args = (struct iw_priv_args *) privtab,
2885 .num_private_args = N(privtab),
2886 #if IW_HANDLER_VERSION >= 7
2887 .get_wireless_stats = rt28xx_get_wireless_stats,
2891 INT RTMPSetInformation(
2892 IN PRTMP_ADAPTER pAdapter,
2893 IN OUT struct ifreq *rq,
2896 struct iwreq *wrq = (struct iwreq *) rq;
2897 NDIS_802_11_SSID Ssid;
2898 NDIS_802_11_MAC_ADDRESS Bssid;
2899 RT_802_11_PHY_MODE PhyMode;
2900 RT_802_11_STA_CONFIG StaConfig;
2901 NDIS_802_11_RATES aryRates;
2902 RT_802_11_PREAMBLE Preamble;
2903 NDIS_802_11_WEP_STATUS WepStatus;
2904 NDIS_802_11_AUTHENTICATION_MODE AuthMode = Ndis802_11AuthModeMax;
2905 NDIS_802_11_NETWORK_INFRASTRUCTURE BssType;
2906 NDIS_802_11_RTS_THRESHOLD RtsThresh;
2907 NDIS_802_11_FRAGMENTATION_THRESHOLD FragThresh;
2908 NDIS_802_11_POWER_MODE PowerMode;
2909 PNDIS_802_11_KEY pKey = NULL;
2910 PNDIS_802_11_WEP pWepKey =NULL;
2911 PNDIS_802_11_REMOVE_KEY pRemoveKey = NULL;
2912 NDIS_802_11_CONFIGURATION Config, *pConfig = NULL;
2913 NDIS_802_11_NETWORK_TYPE NetType;
2916 INT Status = NDIS_STATUS_SUCCESS, MaxPhyMode = PHY_11G;
2919 BOOLEAN StateMachineTouched = FALSE;
2920 OID_SET_HT_PHYMODE HT_PhyMode; //11n ,kathy
2921 PNDIS_802_11_PMKID pPmkId = NULL;
2922 BOOLEAN IEEE8021xState = FALSE;
2923 BOOLEAN IEEE8021x_required_keys = FALSE;
2924 UCHAR wpa_supplicant_enable = 0;
2926 MaxPhyMode = PHY_11N_5G;
2928 DBGPRINT(RT_DEBUG_TRACE, ("-->RTMPSetInformation(), 0x%08x\n", cmd&0x7FFF));
2929 switch(cmd & 0x7FFF) {
2930 case RT_OID_802_11_COUNTRY_REGION:
2931 if (wrq->u.data.length < sizeof(UCHAR))
2933 // Only avaliable when EEPROM not programming
2934 else if (!(pAdapter->CommonCfg.CountryRegion & 0x80) && !(pAdapter->CommonCfg.CountryRegionForABand & 0x80))
2939 Status = copy_from_user(&Country, wrq->u.data.pointer, wrq->u.data.length);
2940 pAdapter->CommonCfg.CountryRegion = (UCHAR)(Country & 0x000000FF);
2941 pAdapter->CommonCfg.CountryRegionForABand = (UCHAR)((Country >> 8) & 0x000000FF);
2942 TmpPhy = pAdapter->CommonCfg.PhyMode;
2943 pAdapter->CommonCfg.PhyMode = 0xff;
2944 // Build all corresponding channel information
2945 RTMPSetPhyMode(pAdapter, TmpPhy);
2946 SetCommonHT(pAdapter);
2947 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_COUNTRY_REGION (A:%d B/G:%d)\n", pAdapter->CommonCfg.CountryRegionForABand,
2948 pAdapter->CommonCfg.CountryRegion));
2951 case OID_802_11_BSSID_LIST_SCAN:
2953 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_BSSID_LIST_SCAN, TxCnt = %d \n", pAdapter->RalinkCounters.LastOneSecTotalTxCount));
2955 if (MONITOR_ON(pAdapter))
2957 DBGPRINT(RT_DEBUG_TRACE, ("!!! Driver is in Monitor Mode now !!!\n"));
2961 //Benson add 20080527, when radio off, sta don't need to scan
2962 if (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_RADIO_OFF))
2965 if (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
2967 DBGPRINT(RT_DEBUG_TRACE, ("!!! Driver is scanning now !!!\n"));
2968 pAdapter->StaCfg.bScanReqIsFromWebUI = TRUE;
2969 Status = NDIS_STATUS_SUCCESS;
2973 if (pAdapter->RalinkCounters.LastOneSecTotalTxCount > 100)
2975 DBGPRINT(RT_DEBUG_TRACE, ("!!! Link UP, ignore this set::OID_802_11_BSSID_LIST_SCAN\n"));
2976 Status = NDIS_STATUS_SUCCESS;
2977 pAdapter->StaCfg.ScanCnt = 99; // Prevent auto scan triggered by this OID
2981 if ((OPSTATUS_TEST_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED)) &&
2982 ((pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA) ||
2983 (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK) ||
2984 (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA2) ||
2985 (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK)) &&
2986 (pAdapter->StaCfg.PortSecured == WPA_802_1X_PORT_NOT_SECURED))
2988 DBGPRINT(RT_DEBUG_TRACE, ("!!! Link UP, Port Not Secured! ignore this set::OID_802_11_BSSID_LIST_SCAN\n"));
2989 Status = NDIS_STATUS_SUCCESS;
2990 pAdapter->StaCfg.ScanCnt = 99; // Prevent auto scan triggered by this OID
2995 if (pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE)
2997 RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
2998 DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
3001 // tell CNTL state machine to call NdisMSetInformationComplete() after completing
3002 // this request, because this request is initiated by NDIS.
3003 pAdapter->MlmeAux.CurrReqIsFromNdis = FALSE;
3004 // Reset allowed scan retries
3005 pAdapter->StaCfg.ScanCnt = 0;
3006 pAdapter->StaCfg.LastScanTime = Now;
3008 pAdapter->StaCfg.bScanReqIsFromWebUI = TRUE;
3009 RTMP_SET_FLAG(pAdapter, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS);
3010 MlmeEnqueue(pAdapter,
3011 MLME_CNTL_STATE_MACHINE,
3012 OID_802_11_BSSID_LIST_SCAN,
3016 Status = NDIS_STATUS_SUCCESS;
3017 StateMachineTouched = TRUE;
3019 case OID_802_11_SSID:
3020 if (wrq->u.data.length != sizeof(NDIS_802_11_SSID))
3024 PCHAR pSsidString = NULL;
3025 Status = copy_from_user(&Ssid, wrq->u.data.pointer, wrq->u.data.length);
3027 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_SSID (Len=%d,Ssid=%s)\n", Ssid.SsidLength, Ssid.Ssid));
3028 if (Ssid.SsidLength > MAX_LEN_OF_SSID)
3032 if (Ssid.SsidLength == 0)
3034 Set_SSID_Proc(pAdapter, "");
3038 pSsidString = (CHAR *) kmalloc(MAX_LEN_OF_SSID+1, MEM_ALLOC_FLAG);
3041 NdisZeroMemory(pSsidString, MAX_LEN_OF_SSID+1);
3042 NdisMoveMemory(pSsidString, Ssid.Ssid, Ssid.SsidLength);
3043 Set_SSID_Proc(pAdapter, pSsidString);
3052 case OID_802_11_BSSID:
3053 if (wrq->u.data.length != sizeof(NDIS_802_11_MAC_ADDRESS))
3057 Status = copy_from_user(&Bssid, wrq->u.data.pointer, wrq->u.data.length);
3059 // tell CNTL state machine to call NdisMSetInformationComplete() after completing
3060 // this request, because this request is initiated by NDIS.
3061 pAdapter->MlmeAux.CurrReqIsFromNdis = FALSE;
3063 // Prevent to connect AP again in STAMlmePeriodicExec
3064 pAdapter->MlmeAux.AutoReconnectSsidLen= 32;
3066 // Reset allowed scan retries
3067 pAdapter->StaCfg.ScanCnt = 0;
3069 if (pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE)
3071 RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
3072 DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
3074 MlmeEnqueue(pAdapter,
3075 MLME_CNTL_STATE_MACHINE,
3077 sizeof(NDIS_802_11_MAC_ADDRESS),
3079 Status = NDIS_STATUS_SUCCESS;
3080 StateMachineTouched = TRUE;
3082 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_BSSID %02x:%02x:%02x:%02x:%02x:%02x\n",
3083 Bssid[0], Bssid[1], Bssid[2], Bssid[3], Bssid[4], Bssid[5]));
3086 case RT_OID_802_11_RADIO:
3087 if (wrq->u.data.length != sizeof(BOOLEAN))
3091 Status = copy_from_user(&RadioState, wrq->u.data.pointer, wrq->u.data.length);
3092 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_RADIO (=%d)\n", RadioState));
3093 if (pAdapter->StaCfg.bSwRadio != RadioState)
3095 pAdapter->StaCfg.bSwRadio = RadioState;
3096 if (pAdapter->StaCfg.bRadio != (pAdapter->StaCfg.bHwRadio && pAdapter->StaCfg.bSwRadio))
3098 pAdapter->StaCfg.bRadio = (pAdapter->StaCfg.bHwRadio && pAdapter->StaCfg.bSwRadio);
3099 if (pAdapter->StaCfg.bRadio == TRUE)
3101 MlmeRadioOn(pAdapter);
3102 // Update extra information
3103 pAdapter->ExtraInfo = EXTRA_INFO_CLEAR;
3107 MlmeRadioOff(pAdapter);
3108 // Update extra information
3109 pAdapter->ExtraInfo = SW_RADIO_OFF;
3115 case RT_OID_802_11_PHY_MODE:
3116 if (wrq->u.data.length != sizeof(RT_802_11_PHY_MODE))
3120 Status = copy_from_user(&PhyMode, wrq->u.data.pointer, wrq->u.data.length);
3121 if (PhyMode <= MaxPhyMode)
3123 RTMPSetPhyMode(pAdapter, PhyMode);
3124 SetCommonHT(pAdapter);
3126 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_PHY_MODE (=%d)\n", PhyMode));
3129 case RT_OID_802_11_STA_CONFIG:
3130 if (wrq->u.data.length != sizeof(RT_802_11_STA_CONFIG))
3134 Status = copy_from_user(&StaConfig, wrq->u.data.pointer, wrq->u.data.length);
3135 pAdapter->CommonCfg.bEnableTxBurst = StaConfig.EnableTxBurst;
3136 pAdapter->CommonCfg.UseBGProtection = StaConfig.UseBGProtection;
3137 pAdapter->CommonCfg.bUseShortSlotTime = 1; // 2003-10-30 always SHORT SLOT capable
3138 if ((pAdapter->CommonCfg.PhyMode != StaConfig.AdhocMode) &&
3139 (StaConfig.AdhocMode <= MaxPhyMode))
3141 // allow dynamic change of "USE OFDM rate or not" in ADHOC mode
3142 // if setting changed, need to reset current TX rate as well as BEACON frame format
3144 pAdapter->CommonCfg.PhyMode = StaConfig.AdhocMode;
3146 if (pAdapter->StaCfg.BssType == BSS_ADHOC)
3149 pAdapter->CommonCfg.PhyMode = StaConfig.AdhocMode;
3151 RTMPSetPhyMode(pAdapter, PhyMode);
3152 MlmeUpdateTxRates(pAdapter, FALSE, 0);
3153 MakeIbssBeacon(pAdapter); // re-build BEACON frame
3154 AsicEnableIbssSync(pAdapter); // copy to on-chip memory
3157 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_SET_STA_CONFIG (Burst=%d, Protection=%ld,ShortSlot=%d\n",
3158 pAdapter->CommonCfg.bEnableTxBurst,
3159 pAdapter->CommonCfg.UseBGProtection,
3160 pAdapter->CommonCfg.bUseShortSlotTime));
3163 case OID_802_11_DESIRED_RATES:
3164 if (wrq->u.data.length != sizeof(NDIS_802_11_RATES))
3168 Status = copy_from_user(&aryRates, wrq->u.data.pointer, wrq->u.data.length);
3169 NdisZeroMemory(pAdapter->CommonCfg.DesireRate, MAX_LEN_OF_SUPPORTED_RATES);
3170 NdisMoveMemory(pAdapter->CommonCfg.DesireRate, &aryRates, sizeof(NDIS_802_11_RATES));
3171 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_DESIRED_RATES (%02x,%02x,%02x,%02x,%02x,%02x,%02x,%02x)\n",
3172 pAdapter->CommonCfg.DesireRate[0],pAdapter->CommonCfg.DesireRate[1],
3173 pAdapter->CommonCfg.DesireRate[2],pAdapter->CommonCfg.DesireRate[3],
3174 pAdapter->CommonCfg.DesireRate[4],pAdapter->CommonCfg.DesireRate[5],
3175 pAdapter->CommonCfg.DesireRate[6],pAdapter->CommonCfg.DesireRate[7] ));
3176 // Changing DesiredRate may affect the MAX TX rate we used to TX frames out
3177 MlmeUpdateTxRates(pAdapter, FALSE, 0);
3180 case RT_OID_802_11_PREAMBLE:
3181 if (wrq->u.data.length != sizeof(RT_802_11_PREAMBLE))
3185 Status = copy_from_user(&Preamble, wrq->u.data.pointer, wrq->u.data.length);
3186 if (Preamble == Rt802_11PreambleShort)
3188 pAdapter->CommonCfg.TxPreamble = Preamble;
3189 MlmeSetTxPreamble(pAdapter, Rt802_11PreambleShort);
3191 else if ((Preamble == Rt802_11PreambleLong) || (Preamble == Rt802_11PreambleAuto))
3193 // if user wants AUTO, initialize to LONG here, then change according to AP's
3194 // capability upon association.
3195 pAdapter->CommonCfg.TxPreamble = Preamble;
3196 MlmeSetTxPreamble(pAdapter, Rt802_11PreambleLong);
3203 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_PREAMBLE (=%d)\n", Preamble));
3206 case OID_802_11_WEP_STATUS:
3207 if (wrq->u.data.length != sizeof(NDIS_802_11_WEP_STATUS))
3211 Status = copy_from_user(&WepStatus, wrq->u.data.pointer, wrq->u.data.length);
3212 // Since TKIP, AES, WEP are all supported. It should not have any invalid setting
3213 if (WepStatus <= Ndis802_11Encryption3KeyAbsent)
3215 if (pAdapter->StaCfg.WepStatus != WepStatus)
3217 // Config has changed
3218 pAdapter->bConfigChanged = TRUE;
3220 pAdapter->StaCfg.WepStatus = WepStatus;
3221 pAdapter->StaCfg.OrigWepStatus = WepStatus;
3222 pAdapter->StaCfg.PairCipher = WepStatus;
3223 pAdapter->StaCfg.GroupCipher = WepStatus;
3230 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_WEP_STATUS (=%d)\n",WepStatus));
3233 case OID_802_11_AUTHENTICATION_MODE:
3234 if (wrq->u.data.length != sizeof(NDIS_802_11_AUTHENTICATION_MODE))
3238 Status = copy_from_user(&AuthMode, wrq->u.data.pointer, wrq->u.data.length);
3239 if (AuthMode > Ndis802_11AuthModeMax)
3246 if (pAdapter->StaCfg.AuthMode != AuthMode)
3248 // Config has changed
3249 pAdapter->bConfigChanged = TRUE;
3251 pAdapter->StaCfg.AuthMode = AuthMode;
3253 pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED;
3254 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_AUTHENTICATION_MODE (=%d) \n",pAdapter->StaCfg.AuthMode));
3257 case OID_802_11_INFRASTRUCTURE_MODE:
3258 if (wrq->u.data.length != sizeof(NDIS_802_11_NETWORK_INFRASTRUCTURE))
3262 Status = copy_from_user(&BssType, wrq->u.data.pointer, wrq->u.data.length);
3264 if (BssType == Ndis802_11IBSS)
3265 Set_NetworkType_Proc(pAdapter, "Adhoc");
3266 else if (BssType == Ndis802_11Infrastructure)
3267 Set_NetworkType_Proc(pAdapter, "Infra");
3268 else if (BssType == Ndis802_11Monitor)
3269 Set_NetworkType_Proc(pAdapter, "Monitor");
3273 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_INFRASTRUCTURE_MODE (unknown)\n"));
3277 case OID_802_11_REMOVE_WEP:
3278 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_WEP\n"));
3279 if (wrq->u.data.length != sizeof(NDIS_802_11_KEY_INDEX))
3285 KeyIdx = *(NDIS_802_11_KEY_INDEX *) wrq->u.data.pointer;
3287 if (KeyIdx & 0x80000000)
3289 // Should never set default bit when remove key
3294 KeyIdx = KeyIdx & 0x0fffffff;
3300 pAdapter->SharedKey[BSS0][KeyIdx].KeyLen = 0;
3301 pAdapter->SharedKey[BSS0][KeyIdx].CipherAlg = CIPHER_NONE;
3302 AsicRemoveSharedKeyEntry(pAdapter, 0, (UCHAR)KeyIdx);
3307 case RT_OID_802_11_RESET_COUNTERS:
3308 NdisZeroMemory(&pAdapter->WlanCounters, sizeof(COUNTER_802_11));
3309 NdisZeroMemory(&pAdapter->Counters8023, sizeof(COUNTER_802_3));
3310 NdisZeroMemory(&pAdapter->RalinkCounters, sizeof(COUNTER_RALINK));
3311 pAdapter->Counters8023.RxNoBuffer = 0;
3312 pAdapter->Counters8023.GoodReceives = 0;
3313 pAdapter->Counters8023.RxNoBuffer = 0;
3315 pAdapter->BulkOutComplete = 0;
3316 pAdapter->BulkOutCompleteOther= 0;
3317 pAdapter->BulkOutCompleteCancel = 0;
3318 pAdapter->BulkOutReq = 0;
3319 pAdapter->BulkInReq= 0;
3320 pAdapter->BulkInComplete = 0;
3321 pAdapter->BulkInCompleteFail = 0;
3323 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_RESET_COUNTERS \n"));
3325 case OID_802_11_RTS_THRESHOLD:
3326 if (wrq->u.data.length != sizeof(NDIS_802_11_RTS_THRESHOLD))
3330 Status = copy_from_user(&RtsThresh, wrq->u.data.pointer, wrq->u.data.length);
3331 if (RtsThresh > MAX_RTS_THRESHOLD)
3334 pAdapter->CommonCfg.RtsThreshold = (USHORT)RtsThresh;
3336 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_RTS_THRESHOLD (=%ld)\n",RtsThresh));
3338 case OID_802_11_FRAGMENTATION_THRESHOLD:
3339 if (wrq->u.data.length != sizeof(NDIS_802_11_FRAGMENTATION_THRESHOLD))
3343 Status = copy_from_user(&FragThresh, wrq->u.data.pointer, wrq->u.data.length);
3344 pAdapter->CommonCfg.bUseZeroToDisableFragment = FALSE;
3345 if (FragThresh > MAX_FRAG_THRESHOLD || FragThresh < MIN_FRAG_THRESHOLD)
3347 if (FragThresh == 0)
3349 pAdapter->CommonCfg.FragmentThreshold = MAX_FRAG_THRESHOLD;
3350 pAdapter->CommonCfg.bUseZeroToDisableFragment = TRUE;
3356 pAdapter->CommonCfg.FragmentThreshold = (USHORT)FragThresh;
3358 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_FRAGMENTATION_THRESHOLD (=%ld) \n",FragThresh));
3360 case OID_802_11_POWER_MODE:
3361 if (wrq->u.data.length != sizeof(NDIS_802_11_POWER_MODE))
3365 Status = copy_from_user(&PowerMode, wrq->u.data.pointer, wrq->u.data.length);
3366 if (PowerMode == Ndis802_11PowerModeCAM)
3367 Set_PSMode_Proc(pAdapter, "CAM");
3368 else if (PowerMode == Ndis802_11PowerModeMAX_PSP)
3369 Set_PSMode_Proc(pAdapter, "Max_PSP");
3370 else if (PowerMode == Ndis802_11PowerModeFast_PSP)
3371 Set_PSMode_Proc(pAdapter, "Fast_PSP");
3372 else if (PowerMode == Ndis802_11PowerModeLegacy_PSP)
3373 Set_PSMode_Proc(pAdapter, "Legacy_PSP");
3377 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_POWER_MODE (=%d)\n",PowerMode));
3379 case RT_OID_802_11_TX_POWER_LEVEL_1:
3380 if (wrq->u.data.length < sizeof(ULONG))
3384 Status = copy_from_user(&PowerTemp, wrq->u.data.pointer, wrq->u.data.length);
3385 if (PowerTemp > 100)
3386 PowerTemp = 0xffffffff; // AUTO
3387 pAdapter->CommonCfg.TxPowerDefault = PowerTemp; //keep current setting.
3388 pAdapter->CommonCfg.TxPowerPercentage = pAdapter->CommonCfg.TxPowerDefault;
3389 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_TX_POWER_LEVEL_1 (=%ld)\n", pAdapter->CommonCfg.TxPowerPercentage));
3392 case OID_802_11_NETWORK_TYPE_IN_USE:
3393 if (wrq->u.data.length != sizeof(NDIS_802_11_NETWORK_TYPE))
3397 Status = copy_from_user(&NetType, wrq->u.data.pointer, wrq->u.data.length);
3399 if (NetType == Ndis802_11DS)
3400 RTMPSetPhyMode(pAdapter, PHY_11B);
3401 else if (NetType == Ndis802_11OFDM24)
3402 RTMPSetPhyMode(pAdapter, PHY_11BG_MIXED);
3403 else if (NetType == Ndis802_11OFDM5)
3404 RTMPSetPhyMode(pAdapter, PHY_11A);
3408 if (Status == NDIS_STATUS_SUCCESS)
3409 SetCommonHT(pAdapter);
3411 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_NETWORK_TYPE_IN_USE (=%d)\n",NetType));
3414 // For WPA PSK PMK key
3415 case RT_OID_802_11_ADD_WPA:
3416 pKey = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
3423 Status = copy_from_user(pKey, wrq->u.data.pointer, wrq->u.data.length);
3424 if (pKey->Length != wrq->u.data.length)
3427 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_ADD_WPA, Failed!!\n"));
3431 if ((pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPAPSK) &&
3432 (pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPA2PSK) &&
3433 (pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPANone) )
3435 Status = -EOPNOTSUPP;
3436 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_ADD_WPA, Failed!! [AuthMode != WPAPSK/WPA2PSK/WPANONE]\n"));
3438 else if ((pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK) ||
3439 (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK) ||
3440 (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPANone) ) // Only for WPA PSK mode
3442 NdisMoveMemory(pAdapter->StaCfg.PMK, &pKey->KeyMaterial, pKey->KeyLength);
3443 // Use RaConfig as PSK agent.
3444 // Start STA supplicant state machine
3445 if (pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPANone)
3446 pAdapter->StaCfg.WpaState = SS_START;
3448 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_ADD_WPA (id=0x%x, Len=%d-byte)\n", pKey->KeyIndex, pKey->KeyLength));
3452 pAdapter->StaCfg.WpaState = SS_NOTUSE;
3453 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_ADD_WPA (id=0x%x, Len=%d-byte)\n", pKey->KeyIndex, pKey->KeyLength));
3458 case OID_802_11_REMOVE_KEY:
3459 pRemoveKey = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
3460 if(pRemoveKey == NULL)
3466 Status = copy_from_user(pRemoveKey, wrq->u.data.pointer, wrq->u.data.length);
3467 if (pRemoveKey->Length != wrq->u.data.length)
3470 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_KEY, Failed!!\n"));
3474 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
3476 RTMPWPARemoveKeyProc(pAdapter, pRemoveKey);
3477 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_KEY, Remove WPA Key!!\n"));
3481 KeyIdx = pRemoveKey->KeyIndex;
3483 if (KeyIdx & 0x80000000)
3485 // Should never set default bit when remove key
3487 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_KEY, Failed!!(Should never set default bit when remove key)\n"));
3491 KeyIdx = KeyIdx & 0x0fffffff;
3495 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_KEY, Failed!!(KeyId[%d] out of range)\n", KeyIdx));
3499 pAdapter->SharedKey[BSS0][KeyIdx].KeyLen = 0;
3500 pAdapter->SharedKey[BSS0][KeyIdx].CipherAlg = CIPHER_NONE;
3501 AsicRemoveSharedKeyEntry(pAdapter, 0, (UCHAR)KeyIdx);
3502 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_KEY (id=0x%x, Len=%d-byte)\n", pRemoveKey->KeyIndex, pRemoveKey->Length));
3510 case OID_802_11_ADD_KEY:
3511 pKey = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
3517 Status = copy_from_user(pKey, wrq->u.data.pointer, wrq->u.data.length);
3518 if (pKey->Length != wrq->u.data.length)
3521 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_KEY, Failed!!\n"));
3525 RTMPAddKey(pAdapter, pKey);
3526 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_KEY (id=0x%x, Len=%d-byte)\n", pKey->KeyIndex, pKey->KeyLength));
3530 case OID_802_11_CONFIGURATION:
3531 if (wrq->u.data.length != sizeof(NDIS_802_11_CONFIGURATION))
3535 Status = copy_from_user(&Config, wrq->u.data.pointer, wrq->u.data.length);
3538 if ((pConfig->BeaconPeriod >= 20) && (pConfig->BeaconPeriod <=400))
3539 pAdapter->CommonCfg.BeaconPeriod = (USHORT) pConfig->BeaconPeriod;
3541 pAdapter->StaActive.AtimWin = (USHORT) pConfig->ATIMWindow;
3542 MAP_KHZ_TO_CHANNEL_ID(pConfig->DSConfig, pAdapter->CommonCfg.Channel);
3544 // Save the channel on MlmeAux for CntlOidRTBssidProc used.
3546 pAdapter->MlmeAux.Channel = pAdapter->CommonCfg.Channel;
3548 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_CONFIGURATION (BeacnPeriod=%ld,AtimW=%ld,Ch=%d)\n",
3549 pConfig->BeaconPeriod, pConfig->ATIMWindow, pAdapter->CommonCfg.Channel));
3550 // Config has changed
3551 pAdapter->bConfigChanged = TRUE;
3554 case RT_OID_802_11_SET_HT_PHYMODE:
3555 if (wrq->u.data.length != sizeof(OID_SET_HT_PHYMODE))
3559 POID_SET_HT_PHYMODE pHTPhyMode = &HT_PhyMode;
3561 Status = copy_from_user(&HT_PhyMode, wrq->u.data.pointer, wrq->u.data.length);
3562 DBGPRINT(RT_DEBUG_TRACE, ("Set::pHTPhyMode (PhyMode = %d,TransmitNo = %d, HtMode = %d, ExtOffset = %d , MCS = %d, BW = %d, STBC = %d, SHORTGI = %d) \n",
3563 pHTPhyMode->PhyMode, pHTPhyMode->TransmitNo,pHTPhyMode->HtMode,pHTPhyMode->ExtOffset,
3564 pHTPhyMode->MCS, pHTPhyMode->BW, pHTPhyMode->STBC, pHTPhyMode->SHORTGI));
3565 if (pAdapter->CommonCfg.PhyMode >= PHY_11ABGN_MIXED)
3566 RTMPSetHT(pAdapter, pHTPhyMode);
3568 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_SET_HT_PHYMODE(MCS=%d,BW=%d,SGI=%d,STBC=%d)\n",
3569 pAdapter->StaCfg.HTPhyMode.field.MCS, pAdapter->StaCfg.HTPhyMode.field.BW, pAdapter->StaCfg.HTPhyMode.field.ShortGI,
3570 pAdapter->StaCfg.HTPhyMode.field.STBC));
3572 case RT_OID_802_11_SET_APSD_SETTING:
3573 if (wrq->u.data.length != sizeof(ULONG))
3578 Status = copy_from_user(&apsd, wrq->u.data.pointer, wrq->u.data.length);
3580 /*-------------------------------------------------------------------
3581 |B31~B7 | B6~B5 | B4 | B3 | B2 | B1 | B0 |
3582 ---------------------------------------------------------------------
3583 | Rsvd | Max SP Len | AC_VO | AC_VI | AC_BK | AC_BE | APSD Capable |
3584 ---------------------------------------------------------------------*/
3585 pAdapter->CommonCfg.bAPSDCapable = (apsd & 0x00000001) ? TRUE : FALSE;
3586 pAdapter->CommonCfg.bAPSDAC_BE = ((apsd & 0x00000002) >> 1) ? TRUE : FALSE;
3587 pAdapter->CommonCfg.bAPSDAC_BK = ((apsd & 0x00000004) >> 2) ? TRUE : FALSE;
3588 pAdapter->CommonCfg.bAPSDAC_VI = ((apsd & 0x00000008) >> 3) ? TRUE : FALSE;
3589 pAdapter->CommonCfg.bAPSDAC_VO = ((apsd & 0x00000010) >> 4) ? TRUE : FALSE;
3590 pAdapter->CommonCfg.MaxSPLength = (UCHAR)((apsd & 0x00000060) >> 5);
3592 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,
3593 pAdapter->CommonCfg.bAPSDAC_BE, pAdapter->CommonCfg.bAPSDAC_BK, pAdapter->CommonCfg.bAPSDAC_VI, pAdapter->CommonCfg.bAPSDAC_VO, pAdapter->CommonCfg.MaxSPLength));
3597 case RT_OID_802_11_SET_APSD_PSM:
3598 if (wrq->u.data.length != sizeof(ULONG))
3602 // Driver needs to notify AP when PSM changes
3603 Status = copy_from_user(&pAdapter->CommonCfg.bAPSDForcePowerSave, wrq->u.data.pointer, wrq->u.data.length);
3604 if (pAdapter->CommonCfg.bAPSDForcePowerSave != pAdapter->StaCfg.Psm)
3606 MlmeSetPsmBit(pAdapter, pAdapter->CommonCfg.bAPSDForcePowerSave);
3607 RTMPSendNullFrame(pAdapter, pAdapter->CommonCfg.TxRate, TRUE);
3609 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_SET_APSD_PSM (bAPSDForcePowerSave:%d)\n", pAdapter->CommonCfg.bAPSDForcePowerSave));
3613 case RT_OID_802_11_SET_WMM:
3614 if (wrq->u.data.length != sizeof(BOOLEAN))
3618 Status = copy_from_user(&pAdapter->CommonCfg.bWmmCapable, wrq->u.data.pointer, wrq->u.data.length);
3619 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_SET_WMM (=%d) \n", pAdapter->CommonCfg.bWmmCapable));
3623 case OID_802_11_DISASSOCIATE:
3625 // Set NdisRadioStateOff to TRUE, instead of called MlmeRadioOff.
3626 // Later on, NDIS_802_11_BSSID_LIST_EX->NumberOfItems should be 0
3627 // when query OID_802_11_BSSID_LIST.
3629 // TRUE: NumberOfItems will set to 0.
3630 // FALSE: NumberOfItems no change.
3632 pAdapter->CommonCfg.NdisRadioStateOff = TRUE;
3633 // Set to immediately send the media disconnect event
3634 pAdapter->MlmeAux.CurrReqIsFromNdis = TRUE;
3635 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_DISASSOCIATE \n"));
3637 if (INFRA_ON(pAdapter))
3639 if (pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE)
3641 RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
3642 DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
3645 MlmeEnqueue(pAdapter,
3646 MLME_CNTL_STATE_MACHINE,
3647 OID_802_11_DISASSOCIATE,
3651 StateMachineTouched = TRUE;
3654 case RT_OID_802_11_SET_IMME_BA_CAP:
3655 if (wrq->u.data.length != sizeof(OID_BACAP_STRUC))
3659 OID_BACAP_STRUC Orde ;
3660 Status = copy_from_user(&Orde, wrq->u.data.pointer, wrq->u.data.length);
3661 if (Orde.Policy > BA_NOTUSE)
3663 Status = NDIS_STATUS_INVALID_DATA;
3665 else if (Orde.Policy == BA_NOTUSE)
3667 pAdapter->CommonCfg.BACapability.field.Policy = BA_NOTUSE;
3668 pAdapter->CommonCfg.BACapability.field.MpduDensity = Orde.MpduDensity;
3669 pAdapter->CommonCfg.DesiredHtPhy.MpduDensity = Orde.MpduDensity;
3670 pAdapter->CommonCfg.DesiredHtPhy.AmsduEnable = Orde.AmsduEnable;
3671 pAdapter->CommonCfg.DesiredHtPhy.AmsduSize= Orde.AmsduSize;
3672 pAdapter->CommonCfg.DesiredHtPhy.MimoPs= Orde.MMPSmode;
3673 pAdapter->CommonCfg.BACapability.field.MMPSmode = Orde.MMPSmode;
3675 pAdapter->CommonCfg.HtCapability.HtCapInfo.MimoPs = Orde.MMPSmode;
3676 pAdapter->CommonCfg.HtCapability.HtCapInfo.AMsduSize = Orde.AmsduSize;
3677 pAdapter->CommonCfg.HtCapability.HtCapParm.MpduDensity = Orde.MpduDensity;
3681 pAdapter->CommonCfg.BACapability.field.AutoBA = Orde.AutoBA;
3682 pAdapter->CommonCfg.BACapability.field.Policy = IMMED_BA; // we only support immediate BA.
3683 pAdapter->CommonCfg.BACapability.field.MpduDensity = Orde.MpduDensity;
3684 pAdapter->CommonCfg.DesiredHtPhy.MpduDensity = Orde.MpduDensity;
3685 pAdapter->CommonCfg.DesiredHtPhy.AmsduEnable = Orde.AmsduEnable;
3686 pAdapter->CommonCfg.DesiredHtPhy.AmsduSize= Orde.AmsduSize;
3687 pAdapter->CommonCfg.DesiredHtPhy.MimoPs = Orde.MMPSmode;
3688 pAdapter->CommonCfg.BACapability.field.MMPSmode = Orde.MMPSmode;
3691 pAdapter->CommonCfg.HtCapability.HtCapInfo.MimoPs = Orde.MMPSmode;
3692 pAdapter->CommonCfg.HtCapability.HtCapInfo.AMsduSize = Orde.AmsduSize;
3693 pAdapter->CommonCfg.HtCapability.HtCapParm.MpduDensity = Orde.MpduDensity;
3695 if (pAdapter->CommonCfg.BACapability.field.RxBAWinLimit > MAX_RX_REORDERBUF)
3696 pAdapter->CommonCfg.BACapability.field.RxBAWinLimit = MAX_RX_REORDERBUF;
3700 pAdapter->CommonCfg.REGBACapability.word = pAdapter->CommonCfg.BACapability.word;
3701 DBGPRINT(RT_DEBUG_TRACE, ("Set::(Orde.AutoBA = %d) (Policy=%d)(ReBAWinLimit=%d)(TxBAWinLimit=%d)(AutoMode=%d)\n",Orde.AutoBA, pAdapter->CommonCfg.BACapability.field.Policy,
3702 pAdapter->CommonCfg.BACapability.field.RxBAWinLimit,pAdapter->CommonCfg.BACapability.field.TxBAWinLimit, pAdapter->CommonCfg.BACapability.field.AutoBA));
3703 DBGPRINT(RT_DEBUG_TRACE, ("Set::(MimoPs = %d)(AmsduEnable = %d) (AmsduSize=%d)(MpduDensity=%d)\n",pAdapter->CommonCfg.DesiredHtPhy.MimoPs, pAdapter->CommonCfg.DesiredHtPhy.AmsduEnable,
3704 pAdapter->CommonCfg.DesiredHtPhy.AmsduSize, pAdapter->CommonCfg.DesiredHtPhy.MpduDensity));
3708 case RT_OID_802_11_ADD_IMME_BA:
3709 DBGPRINT(RT_DEBUG_TRACE, (" Set :: RT_OID_802_11_ADD_IMME_BA \n"));
3710 if (wrq->u.data.length != sizeof(OID_ADD_BA_ENTRY))
3715 OID_ADD_BA_ENTRY BA;
3716 MAC_TABLE_ENTRY *pEntry;
3718 Status = copy_from_user(&BA, wrq->u.data.pointer, wrq->u.data.length);
3721 Status = NDIS_STATUS_INVALID_DATA;
3726 //BATableInsertEntry
3727 //As ad-hoc mode, BA pair is not limited to only BSSID. so add via OID.
3729 // in ad hoc mode, when adding BA pair, we should insert this entry into MACEntry too
3730 pEntry = MacTableLookup(pAdapter, BA.MACAddr);
3733 DBGPRINT(RT_DEBUG_TRACE, ("RT_OID_802_11_ADD_IMME_BA. break on no connection.----:%x:%x\n", BA.MACAddr[4], BA.MACAddr[5]));
3736 if (BA.IsRecipient == FALSE)
3738 if (pEntry->bIAmBadAtheros == TRUE)
3739 pAdapter->CommonCfg.BACapability.field.RxBAWinLimit = 0x10;
3741 BAOriSessionSetUp(pAdapter, pEntry, index, 0, 100, TRUE);
3745 //BATableInsertEntry(pAdapter, pEntry->Aid, BA.MACAddr, 0, 0xffff, BA.TID, BA.nMSDU, BA.IsRecipient);
3748 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_ADD_IMME_BA. Rec = %d. Mac = %x:%x:%x:%x:%x:%x . \n",
3749 BA.IsRecipient, BA.MACAddr[0], BA.MACAddr[1], BA.MACAddr[2], BA.MACAddr[2]
3750 , BA.MACAddr[4], BA.MACAddr[5]));
3755 case RT_OID_802_11_TEAR_IMME_BA:
3756 DBGPRINT(RT_DEBUG_TRACE, ("Set :: RT_OID_802_11_TEAR_IMME_BA \n"));
3757 if (wrq->u.data.length != sizeof(OID_ADD_BA_ENTRY))
3761 POID_ADD_BA_ENTRY pBA;
3762 MAC_TABLE_ENTRY *pEntry;
3764 pBA = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
3768 DBGPRINT(RT_DEBUG_TRACE, ("Set :: RT_OID_802_11_TEAR_IMME_BA kmalloc() can't allocate enough memory\n"));
3769 Status = NDIS_STATUS_FAILURE;
3773 Status = copy_from_user(pBA, wrq->u.data.pointer, wrq->u.data.length);
3774 DBGPRINT(RT_DEBUG_TRACE, ("Set :: RT_OID_802_11_TEAR_IMME_BA(TID=%d, bAllTid=%d)\n", pBA->TID, pBA->bAllTid));
3776 if (!pBA->bAllTid && (pBA->TID > NUM_OF_TID))
3778 Status = NDIS_STATUS_INVALID_DATA;
3782 if (pBA->IsRecipient == FALSE)
3784 pEntry = MacTableLookup(pAdapter, pBA->MACAddr);
3785 DBGPRINT(RT_DEBUG_TRACE, (" pBA->IsRecipient == FALSE\n"));
3788 DBGPRINT(RT_DEBUG_TRACE, (" pBA->pEntry\n"));
3789 BAOriSessionTearDown(pAdapter, pEntry->Aid, pBA->TID, FALSE, TRUE);
3792 DBGPRINT(RT_DEBUG_TRACE, ("Set :: Not found pEntry \n"));
3796 pEntry = MacTableLookup(pAdapter, pBA->MACAddr);
3799 BARecSessionTearDown( pAdapter, (UCHAR)pEntry->Aid, pBA->TID, TRUE);
3802 DBGPRINT(RT_DEBUG_TRACE, ("Set :: Not found pEntry \n"));
3808 // For WPA_SUPPLICANT to set static wep key
3809 case OID_802_11_ADD_WEP:
3810 pWepKey = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
3815 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_WEP, Failed!!\n"));
3818 Status = copy_from_user(pWepKey, wrq->u.data.pointer, wrq->u.data.length);
3822 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_WEP, Failed (length mismatch)!!\n"));
3826 KeyIdx = pWepKey->KeyIndex & 0x0fffffff;
3827 // KeyIdx must be 0 ~ 3
3831 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_WEP, Failed (KeyIdx must be smaller than 4)!!\n"));
3835 UCHAR CipherAlg = 0;
3838 // set key material and key length
3839 NdisZeroMemory(pAdapter->SharedKey[BSS0][KeyIdx].Key, 16);
3840 pAdapter->SharedKey[BSS0][KeyIdx].KeyLen = (UCHAR) pWepKey->KeyLength;
3841 NdisMoveMemory(pAdapter->SharedKey[BSS0][KeyIdx].Key, &pWepKey->KeyMaterial, pWepKey->KeyLength);
3843 switch(pWepKey->KeyLength)
3846 CipherAlg = CIPHER_WEP64;
3849 CipherAlg = CIPHER_WEP128;
3852 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_WEP, only support CIPHER_WEP64(len:5) & CIPHER_WEP128(len:13)!!\n"));
3856 pAdapter->SharedKey[BSS0][KeyIdx].CipherAlg = CipherAlg;
3858 // Default key for tx (shared key)
3859 if (pWepKey->KeyIndex & 0x80000000)
3861 // set key material and key length
3862 NdisZeroMemory(pAdapter->StaCfg.DesireSharedKey[KeyIdx].Key, 16);
3863 pAdapter->StaCfg.DesireSharedKey[KeyIdx].KeyLen = (UCHAR) pWepKey->KeyLength;
3864 NdisMoveMemory(pAdapter->StaCfg.DesireSharedKey[KeyIdx].Key, &pWepKey->KeyMaterial, pWepKey->KeyLength);
3865 pAdapter->StaCfg.DesireSharedKeyId = KeyIdx;
3866 pAdapter->StaCfg.DesireSharedKey[KeyIdx].CipherAlg = CipherAlg;
3867 pAdapter->StaCfg.DefaultKeyId = (UCHAR) KeyIdx;
3871 if ((pAdapter->StaCfg.WpaSupplicantUP != 0) &&
3874 if ((pAdapter->StaCfg.WpaSupplicantUP != WPA_SUPPLICANT_DISABLE) &&
3876 (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA))
3878 Key = pWepKey->KeyMaterial;
3880 // Set Group key material to Asic
3881 AsicAddSharedKeyEntry(pAdapter, BSS0, KeyIdx, CipherAlg, Key, NULL, NULL);
3883 // Update WCID attribute table and IVEIV table for this group key table
3884 RTMPAddWcidAttributeEntry(pAdapter, BSS0, KeyIdx, CipherAlg, NULL);
3886 STA_PORT_SECURED(pAdapter);
3888 // Indicate Connected for GUI
3889 pAdapter->IndicateMediaState = NdisMediaStateConnected;
3891 else if (pAdapter->StaCfg.PortSecured == WPA_802_1X_PORT_SECURED)
3894 if (pAdapter->StaCfg.PortSecured == WPA_802_1X_PORT_SECURED)
3897 Key = pAdapter->SharedKey[BSS0][KeyIdx].Key;
3899 // Set key material and cipherAlg to Asic
3900 AsicAddSharedKeyEntry(pAdapter, BSS0, KeyIdx, CipherAlg, Key, NULL, NULL);
3902 if (pWepKey->KeyIndex & 0x80000000)
3904 PMAC_TABLE_ENTRY pEntry = &pAdapter->MacTab.Content[BSSID_WCID];
3905 // Assign group key info
3906 RTMPAddWcidAttributeEntry(pAdapter, BSS0, KeyIdx, CipherAlg, NULL);
3907 // Assign pairwise key info
3908 RTMPAddWcidAttributeEntry(pAdapter, BSS0, KeyIdx, CipherAlg, pEntry);
3911 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"));
3916 case OID_SET_COUNTERMEASURES:
3917 if (wrq->u.data.length != sizeof(int))
3922 Status = copy_from_user(&enabled, wrq->u.data.pointer, wrq->u.data.length);
3924 pAdapter->StaCfg.bBlockAssoc = TRUE;
3926 // WPA MIC error should block association attempt for 60 seconds
3927 pAdapter->StaCfg.bBlockAssoc = FALSE;
3928 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_SET_COUNTERMEASURES bBlockAssoc=%s\n", pAdapter->StaCfg.bBlockAssoc ? "TRUE":"FALSE"));
3931 case RT_OID_WPA_SUPPLICANT_SUPPORT:
3932 if (wrq->u.data.length != sizeof(UCHAR))
3936 Status = copy_from_user(&wpa_supplicant_enable, wrq->u.data.pointer, wrq->u.data.length);
3937 pAdapter->StaCfg.WpaSupplicantUP = wpa_supplicant_enable;
3938 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_WPA_SUPPLICANT_SUPPORT (=%d)\n", pAdapter->StaCfg.WpaSupplicantUP));
3941 case OID_802_11_DEAUTHENTICATION:
3942 if (wrq->u.data.length != sizeof(MLME_DEAUTH_REQ_STRUCT))
3946 MLME_DEAUTH_REQ_STRUCT *pInfo;
3947 MLME_QUEUE_ELEM *MsgElem = (MLME_QUEUE_ELEM *) kmalloc(sizeof(MLME_QUEUE_ELEM), MEM_ALLOC_FLAG);
3949 pInfo = (MLME_DEAUTH_REQ_STRUCT *) MsgElem->Msg;
3950 Status = copy_from_user(pInfo, wrq->u.data.pointer, wrq->u.data.length);
3951 MlmeDeauthReqAction(pAdapter, MsgElem);
3954 if (INFRA_ON(pAdapter))
3956 LinkDown(pAdapter, FALSE);
3957 pAdapter->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
3959 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_DEAUTHENTICATION (Reason=%d)\n", pInfo->Reason));
3962 case OID_802_11_DROP_UNENCRYPTED:
3963 if (wrq->u.data.length != sizeof(int))
3968 Status = copy_from_user(&enabled, wrq->u.data.pointer, wrq->u.data.length);
3970 pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED;
3972 pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
3973 NdisAcquireSpinLock(&pAdapter->MacTabLock);
3974 pAdapter->MacTab.Content[BSSID_WCID].PortSecured = pAdapter->StaCfg.PortSecured;
3975 NdisReleaseSpinLock(&pAdapter->MacTabLock);
3976 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_DROP_UNENCRYPTED (=%d)\n", enabled));
3979 case OID_802_11_SET_IEEE8021X:
3980 if (wrq->u.data.length != sizeof(BOOLEAN))
3984 Status = copy_from_user(&IEEE8021xState, wrq->u.data.pointer, wrq->u.data.length);
3985 pAdapter->StaCfg.IEEE8021X = IEEE8021xState;
3986 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_SET_IEEE8021X (=%d)\n", IEEE8021xState));
3989 case OID_802_11_SET_IEEE8021X_REQUIRE_KEY:
3990 if (wrq->u.data.length != sizeof(BOOLEAN))
3994 Status = copy_from_user(&IEEE8021x_required_keys, wrq->u.data.pointer, wrq->u.data.length);
3995 pAdapter->StaCfg.IEEE8021x_required_keys = IEEE8021x_required_keys;
3996 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_SET_IEEE8021X_REQUIRE_KEY (%d)\n", IEEE8021x_required_keys));
3999 case OID_802_11_PMKID:
4000 pPmkId = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
4002 if(pPmkId == NULL) {
4006 Status = copy_from_user(pPmkId, wrq->u.data.pointer, wrq->u.data.length);
4008 // check the PMKID information
4009 if (pPmkId->BSSIDInfoCount == 0)
4010 NdisZeroMemory(pAdapter->StaCfg.SavedPMK, sizeof(BSSID_INFO)*PMKID_NO);
4013 PBSSID_INFO pBssIdInfo;
4017 for (BssIdx = 0; BssIdx < pPmkId->BSSIDInfoCount; BssIdx++)
4019 // point to the indexed BSSID_INFO structure
4020 pBssIdInfo = (PBSSID_INFO) ((PUCHAR) pPmkId + 2 * sizeof(UINT) + BssIdx * sizeof(BSSID_INFO));
4021 // Find the entry in the saved data base.
4022 for (CachedIdx = 0; CachedIdx < pAdapter->StaCfg.SavedPMKNum; CachedIdx++)
4024 // compare the BSSID
4025 if (NdisEqualMemory(pBssIdInfo->BSSID, pAdapter->StaCfg.SavedPMK[CachedIdx].BSSID, sizeof(NDIS_802_11_MAC_ADDRESS)))
4029 // Found, replace it
4030 if (CachedIdx < PMKID_NO)
4032 DBGPRINT(RT_DEBUG_OFF, ("Update OID_802_11_PMKID, idx = %d\n", CachedIdx));
4033 NdisMoveMemory(&pAdapter->StaCfg.SavedPMK[CachedIdx], pBssIdInfo, sizeof(BSSID_INFO));
4034 pAdapter->StaCfg.SavedPMKNum++;
4036 // Not found, replace the last one
4039 // Randomly replace one
4040 CachedIdx = (pBssIdInfo->BSSID[5] % PMKID_NO);
4041 DBGPRINT(RT_DEBUG_OFF, ("Update OID_802_11_PMKID, idx = %d\n", CachedIdx));
4042 NdisMoveMemory(&pAdapter->StaCfg.SavedPMK[CachedIdx], pBssIdInfo, sizeof(BSSID_INFO));
4050 DBGPRINT(RT_DEBUG_TRACE, ("Set::unknown IOCTL's subcmd = 0x%08x\n", cmd));
4051 Status = -EOPNOTSUPP;
4059 INT RTMPQueryInformation(
4060 IN PRTMP_ADAPTER pAdapter,
4061 IN OUT struct ifreq *rq,
4064 struct iwreq *wrq = (struct iwreq *) rq;
4065 NDIS_802_11_BSSID_LIST_EX *pBssidList = NULL;
4066 PNDIS_WLAN_BSSID_EX pBss;
4067 NDIS_802_11_SSID Ssid;
4068 NDIS_802_11_CONFIGURATION *pConfiguration = NULL;
4069 RT_802_11_LINK_STATUS *pLinkStatus = NULL;
4070 RT_802_11_STA_CONFIG *pStaConfig = NULL;
4071 NDIS_802_11_STATISTICS *pStatistics = NULL;
4072 NDIS_802_11_RTS_THRESHOLD RtsThresh;
4073 NDIS_802_11_FRAGMENTATION_THRESHOLD FragThresh;
4074 NDIS_802_11_POWER_MODE PowerMode;
4075 NDIS_802_11_NETWORK_INFRASTRUCTURE BssType;
4076 RT_802_11_PREAMBLE PreamType;
4077 NDIS_802_11_AUTHENTICATION_MODE AuthMode;
4078 NDIS_802_11_WEP_STATUS WepStatus;
4079 NDIS_MEDIA_STATE MediaState;
4080 ULONG BssBufSize, ulInfo=0, NetworkTypeList[4], apsd = 0;
4082 PUCHAR pBuf = NULL, pPtr;
4083 INT Status = NDIS_STATUS_SUCCESS;
4084 UINT we_version_compiled;
4085 UCHAR i, Padding = 0;
4087 UCHAR driverVersion[8];
4088 OID_SET_HT_PHYMODE *pHTPhyMode = NULL;
4092 case RT_OID_DEVICE_NAME:
4093 wrq->u.data.length = sizeof(STA_NIC_DEVICE_NAME);
4094 Status = copy_to_user(wrq->u.data.pointer, STA_NIC_DEVICE_NAME, wrq->u.data.length);
4096 case RT_OID_VERSION_INFO:
4097 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_VERSION_INFO \n"));
4098 wrq->u.data.length = 8*sizeof(UCHAR);
4099 sprintf(&driverVersion[0], "%s", STA_DRIVER_VERSION);
4100 driverVersion[7] = '\0';
4101 if (copy_to_user(wrq->u.data.pointer, &driverVersion, wrq->u.data.length))
4106 case OID_802_11_BSSID_LIST:
4107 if (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
4110 * Still scanning, indicate the caller should try again.
4112 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_BSSID_LIST (Still scanning)\n"));
4115 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_BSSID_LIST (%d BSS returned)\n",pAdapter->ScanTab.BssNr));
4116 pAdapter->StaCfg.bScanReqIsFromWebUI = FALSE;
4117 // Claculate total buffer size required
4118 BssBufSize = sizeof(ULONG);
4120 for (i = 0; i < pAdapter->ScanTab.BssNr; i++)
4122 // Align pointer to 4 bytes boundary.
4123 //Padding = 4 - (pAdapter->ScanTab.BssEntry[i].VarIELen & 0x0003);
4126 BssBufSize += (sizeof(NDIS_WLAN_BSSID_EX) - 1 + sizeof(NDIS_802_11_FIXED_IEs) + pAdapter->ScanTab.BssEntry[i].VarIELen + Padding);
4129 // For safety issue, we add 256 bytes just in case
4131 // Allocate the same size as passed from higher layer
4132 pBuf = kmalloc(BssBufSize, MEM_ALLOC_FLAG);
4138 // Init 802_11_BSSID_LIST_EX structure
4139 NdisZeroMemory(pBuf, BssBufSize);
4140 pBssidList = (PNDIS_802_11_BSSID_LIST_EX) pBuf;
4141 pBssidList->NumberOfItems = pAdapter->ScanTab.BssNr;
4143 // Calculate total buffer length
4144 BssLen = 4; // Consist of NumberOfItems
4145 // Point to start of NDIS_WLAN_BSSID_EX
4146 // pPtr = pBuf + sizeof(ULONG);
4147 pPtr = (PUCHAR) &pBssidList->Bssid[0];
4148 for (i = 0; i < pAdapter->ScanTab.BssNr; i++)
4150 pBss = (PNDIS_WLAN_BSSID_EX) pPtr;
4151 NdisMoveMemory(&pBss->MacAddress, &pAdapter->ScanTab.BssEntry[i].Bssid, MAC_ADDR_LEN);
4152 if ((pAdapter->ScanTab.BssEntry[i].Hidden == 1) && (pAdapter->StaCfg.bShowHiddenSSID == FALSE))
4155 // We must return this SSID during 4way handshaking, otherwise Aegis will failed to parse WPA infomation
4156 // and then failed to send EAPOl farame.
4158 if ((pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA) && (pAdapter->StaCfg.PortSecured != WPA_802_1X_PORT_SECURED))
4160 pBss->Ssid.SsidLength = pAdapter->ScanTab.BssEntry[i].SsidLen;
4161 NdisMoveMemory(pBss->Ssid.Ssid, pAdapter->ScanTab.BssEntry[i].Ssid, pAdapter->ScanTab.BssEntry[i].SsidLen);
4164 pBss->Ssid.SsidLength = 0;
4168 pBss->Ssid.SsidLength = pAdapter->ScanTab.BssEntry[i].SsidLen;
4169 NdisMoveMemory(pBss->Ssid.Ssid, pAdapter->ScanTab.BssEntry[i].Ssid, pAdapter->ScanTab.BssEntry[i].SsidLen);
4171 pBss->Privacy = pAdapter->ScanTab.BssEntry[i].Privacy;
4172 pBss->Rssi = pAdapter->ScanTab.BssEntry[i].Rssi - pAdapter->BbpRssiToDbmDelta;
4173 pBss->NetworkTypeInUse = NetworkTypeInUseSanity(&pAdapter->ScanTab.BssEntry[i]);
4174 pBss->Configuration.Length = sizeof(NDIS_802_11_CONFIGURATION);
4175 pBss->Configuration.BeaconPeriod = pAdapter->ScanTab.BssEntry[i].BeaconPeriod;
4176 pBss->Configuration.ATIMWindow = pAdapter->ScanTab.BssEntry[i].AtimWin;
4178 MAP_CHANNEL_ID_TO_KHZ(pAdapter->ScanTab.BssEntry[i].Channel, pBss->Configuration.DSConfig);
4180 if (pAdapter->ScanTab.BssEntry[i].BssType == BSS_INFRA)
4181 pBss->InfrastructureMode = Ndis802_11Infrastructure;
4183 pBss->InfrastructureMode = Ndis802_11IBSS;
4185 NdisMoveMemory(pBss->SupportedRates, pAdapter->ScanTab.BssEntry[i].SupRate, pAdapter->ScanTab.BssEntry[i].SupRateLen);
4186 NdisMoveMemory(pBss->SupportedRates + pAdapter->ScanTab.BssEntry[i].SupRateLen,
4187 pAdapter->ScanTab.BssEntry[i].ExtRate,
4188 pAdapter->ScanTab.BssEntry[i].ExtRateLen);
4190 if (pAdapter->ScanTab.BssEntry[i].VarIELen == 0)
4192 pBss->IELength = sizeof(NDIS_802_11_FIXED_IEs);
4193 NdisMoveMemory(pBss->IEs, &pAdapter->ScanTab.BssEntry[i].FixIEs, sizeof(NDIS_802_11_FIXED_IEs));
4194 pPtr = pPtr + sizeof(NDIS_WLAN_BSSID_EX) - 1 + sizeof(NDIS_802_11_FIXED_IEs);
4198 pBss->IELength = (ULONG)(sizeof(NDIS_802_11_FIXED_IEs) + pAdapter->ScanTab.BssEntry[i].VarIELen);
4199 pPtr = pPtr + sizeof(NDIS_WLAN_BSSID_EX) - 1 + sizeof(NDIS_802_11_FIXED_IEs);
4200 NdisMoveMemory(pBss->IEs, &pAdapter->ScanTab.BssEntry[i].FixIEs, sizeof(NDIS_802_11_FIXED_IEs));
4201 NdisMoveMemory(pBss->IEs + sizeof(NDIS_802_11_FIXED_IEs), pAdapter->ScanTab.BssEntry[i].VarIEs, pAdapter->ScanTab.BssEntry[i].VarIELen);
4202 pPtr += pAdapter->ScanTab.BssEntry[i].VarIELen;
4204 pBss->Length = (ULONG)(sizeof(NDIS_WLAN_BSSID_EX) - 1 + sizeof(NDIS_802_11_FIXED_IEs) + pAdapter->ScanTab.BssEntry[i].VarIELen + Padding);
4206 BssLen += pBss->Length;
4209 if (BssLen > wrq->u.data.length)
4215 wrq->u.data.length = BssLen;
4216 Status = copy_to_user(wrq->u.data.pointer, pBssidList, BssLen);
4219 case OID_802_3_CURRENT_ADDRESS:
4220 wrq->u.data.length = MAC_ADDR_LEN;
4221 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CurrentAddress, wrq->u.data.length);
4223 case OID_GEN_MEDIA_CONNECT_STATUS:
4224 if (pAdapter->IndicateMediaState == NdisMediaStateConnected)
4225 MediaState = NdisMediaStateConnected;
4227 MediaState = NdisMediaStateDisconnected;
4229 wrq->u.data.length = sizeof(NDIS_MEDIA_STATE);
4230 Status = copy_to_user(wrq->u.data.pointer, &MediaState, wrq->u.data.length);
4232 case OID_802_11_BSSID:
4233 if (INFRA_ON(pAdapter) || ADHOC_ON(pAdapter))
4235 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.Bssid, sizeof(NDIS_802_11_MAC_ADDRESS));
4240 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_BSSID(=EMPTY)\n"));
4244 case OID_802_11_SSID:
4245 NdisZeroMemory(&Ssid, sizeof(NDIS_802_11_SSID));
4246 NdisZeroMemory(Ssid.Ssid, MAX_LEN_OF_SSID);
4247 Ssid.SsidLength = pAdapter->CommonCfg.SsidLen;
4248 memcpy(Ssid.Ssid, pAdapter->CommonCfg.Ssid, Ssid.SsidLength);
4249 wrq->u.data.length = sizeof(NDIS_802_11_SSID);
4250 Status = copy_to_user(wrq->u.data.pointer, &Ssid, wrq->u.data.length);
4251 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_SSID (Len=%d, ssid=%s)\n", Ssid.SsidLength,Ssid.Ssid));
4253 case RT_OID_802_11_QUERY_LINK_STATUS:
4254 pLinkStatus = (RT_802_11_LINK_STATUS *) kmalloc(sizeof(RT_802_11_LINK_STATUS), MEM_ALLOC_FLAG);
4257 pLinkStatus->CurrTxRate = RateIdTo500Kbps[pAdapter->CommonCfg.TxRate]; // unit : 500 kbps
4258 pLinkStatus->ChannelQuality = pAdapter->Mlme.ChannelQuality;
4259 pLinkStatus->RxByteCount = pAdapter->RalinkCounters.ReceivedByteCount;
4260 pLinkStatus->TxByteCount = pAdapter->RalinkCounters.TransmittedByteCount;
4261 pLinkStatus->CentralChannel = pAdapter->CommonCfg.CentralChannel;
4262 wrq->u.data.length = sizeof(RT_802_11_LINK_STATUS);
4263 Status = copy_to_user(wrq->u.data.pointer, pLinkStatus, wrq->u.data.length);
4265 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_LINK_STATUS\n"));
4269 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_LINK_STATUS(kmalloc failed)\n"));
4273 case OID_802_11_CONFIGURATION:
4274 pConfiguration = (NDIS_802_11_CONFIGURATION *) kmalloc(sizeof(NDIS_802_11_CONFIGURATION), MEM_ALLOC_FLAG);
4277 pConfiguration->Length = sizeof(NDIS_802_11_CONFIGURATION);
4278 pConfiguration->BeaconPeriod = pAdapter->CommonCfg.BeaconPeriod;
4279 pConfiguration->ATIMWindow = pAdapter->StaActive.AtimWin;
4280 MAP_CHANNEL_ID_TO_KHZ(pAdapter->CommonCfg.Channel, pConfiguration->DSConfig);
4281 wrq->u.data.length = sizeof(NDIS_802_11_CONFIGURATION);
4282 Status = copy_to_user(wrq->u.data.pointer, pConfiguration, wrq->u.data.length);
4283 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_CONFIGURATION(BeaconPeriod=%ld,AtimW=%ld,Channel=%d) \n",
4284 pConfiguration->BeaconPeriod, pConfiguration->ATIMWindow, pAdapter->CommonCfg.Channel));
4285 kfree(pConfiguration);
4289 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_CONFIGURATION(kmalloc failed)\n"));
4293 case RT_OID_802_11_SNR_0:
4294 if ((pAdapter->StaCfg.LastSNR0 > 0))
4296 ulInfo = ((0xeb - pAdapter->StaCfg.LastSNR0) * 3) / 16 ;
4297 wrq->u.data.length = sizeof(ulInfo);
4298 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4299 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_SNR_0(0x=%lx)\n", ulInfo));
4304 case RT_OID_802_11_SNR_1:
4305 if ((pAdapter->Antenna.field.RxPath > 1) &&
4306 (pAdapter->StaCfg.LastSNR1 > 0))
4308 ulInfo = ((0xeb - pAdapter->StaCfg.LastSNR1) * 3) / 16 ;
4309 wrq->u.data.length = sizeof(ulInfo);
4310 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4311 DBGPRINT(RT_DEBUG_TRACE,("Query::RT_OID_802_11_SNR_1(0x=%lx)\n",ulInfo));
4315 DBGPRINT(RT_DEBUG_TRACE,("Query::RT_OID_802_11_SNR_1(pAdapter->StaCfg.LastSNR1=%d)\n",pAdapter->StaCfg.LastSNR1));
4317 case OID_802_11_RSSI_TRIGGER:
4318 ulInfo = pAdapter->StaCfg.RssiSample.LastRssi0 - pAdapter->BbpRssiToDbmDelta;
4319 wrq->u.data.length = sizeof(ulInfo);
4320 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4321 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_RSSI_TRIGGER(=%ld)\n", ulInfo));
4323 case OID_802_11_RSSI:
4324 case RT_OID_802_11_RSSI:
4325 ulInfo = pAdapter->StaCfg.RssiSample.LastRssi0;
4326 wrq->u.data.length = sizeof(ulInfo);
4327 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4329 case RT_OID_802_11_RSSI_1:
4330 ulInfo = pAdapter->StaCfg.RssiSample.LastRssi1;
4331 wrq->u.data.length = sizeof(ulInfo);
4332 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4334 case RT_OID_802_11_RSSI_2:
4335 ulInfo = pAdapter->StaCfg.RssiSample.LastRssi2;
4336 wrq->u.data.length = sizeof(ulInfo);
4337 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4339 case OID_802_11_STATISTICS:
4340 pStatistics = (NDIS_802_11_STATISTICS *) kmalloc(sizeof(NDIS_802_11_STATISTICS), MEM_ALLOC_FLAG);
4343 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_STATISTICS \n"));
4344 // add the most up-to-date h/w raw counters into software counters
4345 NICUpdateRawCounters(pAdapter);
4347 // Sanity check for calculation of sucessful count
4348 if (pAdapter->WlanCounters.TransmittedFragmentCount.QuadPart < pAdapter->WlanCounters.RetryCount.QuadPart)
4349 pAdapter->WlanCounters.TransmittedFragmentCount.QuadPart = pAdapter->WlanCounters.RetryCount.QuadPart;
4351 pStatistics->TransmittedFragmentCount.QuadPart = pAdapter->WlanCounters.TransmittedFragmentCount.QuadPart;
4352 pStatistics->MulticastTransmittedFrameCount.QuadPart = pAdapter->WlanCounters.MulticastTransmittedFrameCount.QuadPart;
4353 pStatistics->FailedCount.QuadPart = pAdapter->WlanCounters.FailedCount.QuadPart;
4354 pStatistics->RetryCount.QuadPart = pAdapter->WlanCounters.RetryCount.QuadPart;
4355 pStatistics->MultipleRetryCount.QuadPart = pAdapter->WlanCounters.MultipleRetryCount.QuadPart;
4356 pStatistics->RTSSuccessCount.QuadPart = pAdapter->WlanCounters.RTSSuccessCount.QuadPart;
4357 pStatistics->RTSFailureCount.QuadPart = pAdapter->WlanCounters.RTSFailureCount.QuadPart;
4358 pStatistics->ACKFailureCount.QuadPart = pAdapter->WlanCounters.ACKFailureCount.QuadPart;
4359 pStatistics->FrameDuplicateCount.QuadPart = pAdapter->WlanCounters.FrameDuplicateCount.QuadPart;
4360 pStatistics->ReceivedFragmentCount.QuadPart = pAdapter->WlanCounters.ReceivedFragmentCount.QuadPart;
4361 pStatistics->MulticastReceivedFrameCount.QuadPart = pAdapter->WlanCounters.MulticastReceivedFrameCount.QuadPart;
4363 pStatistics->FCSErrorCount = pAdapter->RalinkCounters.RealFcsErrCount;
4365 pStatistics->FCSErrorCount.QuadPart = pAdapter->WlanCounters.FCSErrorCount.QuadPart;
4366 pStatistics->FrameDuplicateCount.u.LowPart = pAdapter->WlanCounters.FrameDuplicateCount.u.LowPart / 100;
4368 wrq->u.data.length = sizeof(NDIS_802_11_STATISTICS);
4369 Status = copy_to_user(wrq->u.data.pointer, pStatistics, wrq->u.data.length);
4374 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_STATISTICS(kmalloc failed)\n"));
4378 case OID_GEN_RCV_OK:
4379 ulInfo = pAdapter->Counters8023.GoodReceives;
4380 wrq->u.data.length = sizeof(ulInfo);
4381 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4383 case OID_GEN_RCV_NO_BUFFER:
4384 ulInfo = pAdapter->Counters8023.RxNoBuffer;
4385 wrq->u.data.length = sizeof(ulInfo);
4386 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4388 case RT_OID_802_11_PHY_MODE:
4389 ulInfo = (ULONG)pAdapter->CommonCfg.PhyMode;
4390 wrq->u.data.length = sizeof(ulInfo);
4391 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4392 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_PHY_MODE (=%ld)\n", ulInfo));
4394 case RT_OID_802_11_STA_CONFIG:
4395 pStaConfig = (RT_802_11_STA_CONFIG *) kmalloc(sizeof(RT_802_11_STA_CONFIG), MEM_ALLOC_FLAG);
4398 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_STA_CONFIG\n"));
4399 pStaConfig->EnableTxBurst = pAdapter->CommonCfg.bEnableTxBurst;
4400 pStaConfig->EnableTurboRate = 0;
4401 pStaConfig->UseBGProtection = pAdapter->CommonCfg.UseBGProtection;
4402 pStaConfig->UseShortSlotTime = pAdapter->CommonCfg.bUseShortSlotTime;
4403 //pStaConfig->AdhocMode = pAdapter->StaCfg.AdhocMode;
4404 pStaConfig->HwRadioStatus = (pAdapter->StaCfg.bHwRadio == TRUE) ? 1 : 0;
4405 pStaConfig->Rsv1 = 0;
4406 pStaConfig->SystemErrorBitmap = pAdapter->SystemErrorBitmap;
4407 wrq->u.data.length = sizeof(RT_802_11_STA_CONFIG);
4408 Status = copy_to_user(wrq->u.data.pointer, pStaConfig, wrq->u.data.length);
4413 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_STA_CONFIG(kmalloc failed)\n"));
4417 case OID_802_11_RTS_THRESHOLD:
4418 RtsThresh = pAdapter->CommonCfg.RtsThreshold;
4419 wrq->u.data.length = sizeof(RtsThresh);
4420 Status = copy_to_user(wrq->u.data.pointer, &RtsThresh, wrq->u.data.length);
4421 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_RTS_THRESHOLD(=%ld)\n", RtsThresh));
4423 case OID_802_11_FRAGMENTATION_THRESHOLD:
4424 FragThresh = pAdapter->CommonCfg.FragmentThreshold;
4425 if (pAdapter->CommonCfg.bUseZeroToDisableFragment == TRUE)
4427 wrq->u.data.length = sizeof(FragThresh);
4428 Status = copy_to_user(wrq->u.data.pointer, &FragThresh, wrq->u.data.length);
4429 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_FRAGMENTATION_THRESHOLD(=%ld)\n", FragThresh));
4431 case OID_802_11_POWER_MODE:
4432 PowerMode = pAdapter->StaCfg.WindowsPowerMode;
4433 wrq->u.data.length = sizeof(PowerMode);
4434 Status = copy_to_user(wrq->u.data.pointer, &PowerMode, wrq->u.data.length);
4435 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_POWER_MODE(=%d)\n", PowerMode));
4437 case RT_OID_802_11_RADIO:
4438 RadioState = (BOOLEAN) pAdapter->StaCfg.bSwRadio;
4439 wrq->u.data.length = sizeof(RadioState);
4440 Status = copy_to_user(wrq->u.data.pointer, &RadioState, wrq->u.data.length);
4441 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_RADIO (=%d)\n", RadioState));
4443 case OID_802_11_INFRASTRUCTURE_MODE:
4444 if (pAdapter->StaCfg.BssType == BSS_ADHOC)
4445 BssType = Ndis802_11IBSS;
4446 else if (pAdapter->StaCfg.BssType == BSS_INFRA)
4447 BssType = Ndis802_11Infrastructure;
4448 else if (pAdapter->StaCfg.BssType == BSS_MONITOR)
4449 BssType = Ndis802_11Monitor;
4451 BssType = Ndis802_11AutoUnknown;
4453 wrq->u.data.length = sizeof(BssType);
4454 Status = copy_to_user(wrq->u.data.pointer, &BssType, wrq->u.data.length);
4455 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_INFRASTRUCTURE_MODE(=%d)\n", BssType));
4457 case RT_OID_802_11_PREAMBLE:
4458 PreamType = pAdapter->CommonCfg.TxPreamble;
4459 wrq->u.data.length = sizeof(PreamType);
4460 Status = copy_to_user(wrq->u.data.pointer, &PreamType, wrq->u.data.length);
4461 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_PREAMBLE(=%d)\n", PreamType));
4463 case OID_802_11_AUTHENTICATION_MODE:
4464 AuthMode = pAdapter->StaCfg.AuthMode;
4465 wrq->u.data.length = sizeof(AuthMode);
4466 Status = copy_to_user(wrq->u.data.pointer, &AuthMode, wrq->u.data.length);
4467 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_AUTHENTICATION_MODE(=%d)\n", AuthMode));
4469 case OID_802_11_WEP_STATUS:
4470 WepStatus = pAdapter->StaCfg.WepStatus;
4471 wrq->u.data.length = sizeof(WepStatus);
4472 Status = copy_to_user(wrq->u.data.pointer, &WepStatus, wrq->u.data.length);
4473 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_WEP_STATUS(=%d)\n", WepStatus));
4475 case OID_802_11_TX_POWER_LEVEL:
4476 wrq->u.data.length = sizeof(ULONG);
4477 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.TxPower, wrq->u.data.length);
4478 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_TX_POWER_LEVEL %x\n",pAdapter->CommonCfg.TxPower));
4480 case RT_OID_802_11_TX_POWER_LEVEL_1:
4481 wrq->u.data.length = sizeof(ULONG);
4482 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.TxPowerPercentage, wrq->u.data.length);
4483 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_TX_POWER_LEVEL_1 (=%ld)\n", pAdapter->CommonCfg.TxPowerPercentage));
4485 case OID_802_11_NETWORK_TYPES_SUPPORTED:
4486 if ((pAdapter->RfIcType == RFIC_2850) || (pAdapter->RfIcType == RFIC_2750))
4488 NetworkTypeList[0] = 3; // NumberOfItems = 3
4489 NetworkTypeList[1] = Ndis802_11DS; // NetworkType[1] = 11b
4490 NetworkTypeList[2] = Ndis802_11OFDM24; // NetworkType[2] = 11g
4491 NetworkTypeList[3] = Ndis802_11OFDM5; // NetworkType[3] = 11a
4492 wrq->u.data.length = 16;
4493 Status = copy_to_user(wrq->u.data.pointer, &NetworkTypeList[0], wrq->u.data.length);
4497 NetworkTypeList[0] = 2; // NumberOfItems = 2
4498 NetworkTypeList[1] = Ndis802_11DS; // NetworkType[1] = 11b
4499 NetworkTypeList[2] = Ndis802_11OFDM24; // NetworkType[2] = 11g
4500 wrq->u.data.length = 12;
4501 Status = copy_to_user(wrq->u.data.pointer, &NetworkTypeList[0], wrq->u.data.length);
4503 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_NETWORK_TYPES_SUPPORTED\n"));
4505 case OID_802_11_NETWORK_TYPE_IN_USE:
4506 wrq->u.data.length = sizeof(ULONG);
4507 if (pAdapter->CommonCfg.PhyMode == PHY_11A)
4508 ulInfo = Ndis802_11OFDM5;
4509 else if ((pAdapter->CommonCfg.PhyMode == PHY_11BG_MIXED) || (pAdapter->CommonCfg.PhyMode == PHY_11G))
4510 ulInfo = Ndis802_11OFDM24;
4512 ulInfo = Ndis802_11DS;
4513 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4515 case RT_OID_802_11_QUERY_LAST_RX_RATE:
4516 ulInfo = (ULONG)pAdapter->LastRxRate;
4517 wrq->u.data.length = sizeof(ulInfo);
4518 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4519 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_LAST_RX_RATE (=%ld)\n", ulInfo));
4521 case RT_OID_802_11_QUERY_LAST_TX_RATE:
4522 //ulInfo = (ULONG)pAdapter->LastTxRate;
4523 ulInfo = (ULONG)pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.word;
4524 wrq->u.data.length = sizeof(ulInfo);
4525 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4526 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_LAST_TX_RATE (=%lx)\n", ulInfo));
4528 case RT_OID_802_11_QUERY_EEPROM_VERSION:
4529 wrq->u.data.length = sizeof(ULONG);
4530 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->EepromVersion, wrq->u.data.length);
4532 case RT_OID_802_11_QUERY_FIRMWARE_VERSION:
4533 wrq->u.data.length = sizeof(ULONG);
4534 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->FirmwareVersion, wrq->u.data.length);
4536 case RT_OID_802_11_QUERY_NOISE_LEVEL:
4537 wrq->u.data.length = sizeof(UCHAR);
4538 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->BbpWriteLatch[66], wrq->u.data.length);
4539 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_NOISE_LEVEL (=%d)\n", pAdapter->BbpWriteLatch[66]));
4541 case RT_OID_802_11_EXTRA_INFO:
4542 wrq->u.data.length = sizeof(ULONG);
4543 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->ExtraInfo, wrq->u.data.length);
4544 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_EXTRA_INFO (=%ld)\n", pAdapter->ExtraInfo));
4546 case RT_OID_WE_VERSION_COMPILED:
4547 wrq->u.data.length = sizeof(UINT);
4548 we_version_compiled = WIRELESS_EXT;
4549 Status = copy_to_user(wrq->u.data.pointer, &we_version_compiled, wrq->u.data.length);
4551 case RT_OID_802_11_QUERY_APSD_SETTING:
4552 apsd = (pAdapter->CommonCfg.bAPSDCapable | (pAdapter->CommonCfg.bAPSDAC_BE << 1) | (pAdapter->CommonCfg.bAPSDAC_BK << 2)
4553 | (pAdapter->CommonCfg.bAPSDAC_VI << 3) | (pAdapter->CommonCfg.bAPSDAC_VO << 4) | (pAdapter->CommonCfg.MaxSPLength << 5));
4555 wrq->u.data.length = sizeof(ULONG);
4556 Status = copy_to_user(wrq->u.data.pointer, &apsd, wrq->u.data.length);
4557 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",
4558 apsd,pAdapter->CommonCfg.bAPSDCapable,pAdapter->CommonCfg.bAPSDAC_BE,pAdapter->CommonCfg.bAPSDAC_BK,pAdapter->CommonCfg.bAPSDAC_VI,pAdapter->CommonCfg.bAPSDAC_VO,pAdapter->CommonCfg.MaxSPLength));
4560 case RT_OID_802_11_QUERY_APSD_PSM:
4561 wrq->u.data.length = sizeof(ULONG);
4562 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.bAPSDForcePowerSave, wrq->u.data.length);
4563 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_APSD_PSM (=%d)\n", pAdapter->CommonCfg.bAPSDForcePowerSave));
4565 case RT_OID_802_11_QUERY_WMM:
4566 wrq->u.data.length = sizeof(BOOLEAN);
4567 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.bWmmCapable, wrq->u.data.length);
4568 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_WMM (=%d)\n", pAdapter->CommonCfg.bWmmCapable));
4570 case RT_OID_NEW_DRIVER:
4573 wrq->u.data.length = sizeof(UCHAR);
4574 Status = copy_to_user(wrq->u.data.pointer, &enabled, wrq->u.data.length);
4575 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_NEW_DRIVER (=%d)\n", enabled));
4578 case RT_OID_WPA_SUPPLICANT_SUPPORT:
4579 wrq->u.data.length = sizeof(UCHAR);
4580 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->StaCfg.WpaSupplicantUP, wrq->u.data.length);
4581 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_WPA_SUPPLICANT_SUPPORT (=%d)\n", pAdapter->StaCfg.WpaSupplicantUP));
4583 case RT_OID_DRIVER_DEVICE_NAME:
4584 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_DRIVER_DEVICE_NAME \n"));
4585 wrq->u.data.length = 16;
4586 if (copy_to_user(wrq->u.data.pointer, pAdapter->StaCfg.dev_name, wrq->u.data.length))
4591 case RT_OID_802_11_QUERY_HT_PHYMODE:
4592 pHTPhyMode = (OID_SET_HT_PHYMODE *) kmalloc(sizeof(OID_SET_HT_PHYMODE), MEM_ALLOC_FLAG);
4595 pHTPhyMode->PhyMode = pAdapter->CommonCfg.PhyMode;
4596 pHTPhyMode->HtMode = (UCHAR)pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.field.MODE;
4597 pHTPhyMode->BW = (UCHAR)pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.field.BW;
4598 pHTPhyMode->MCS= (UCHAR)pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.field.MCS;
4599 pHTPhyMode->SHORTGI= (UCHAR)pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.field.ShortGI;
4600 pHTPhyMode->STBC= (UCHAR)pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.field.STBC;
4602 pHTPhyMode->ExtOffset = ((pAdapter->CommonCfg.CentralChannel < pAdapter->CommonCfg.Channel) ? (EXTCHA_BELOW) : (EXTCHA_ABOVE));
4603 wrq->u.data.length = sizeof(OID_SET_HT_PHYMODE);
4604 if (copy_to_user(wrq->u.data.pointer, pHTPhyMode, wrq->u.data.length))
4608 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_HT_PHYMODE (PhyMode = %d, MCS =%d, BW = %d, STBC = %d, ExtOffset=%d)\n",
4609 pHTPhyMode->HtMode, pHTPhyMode->MCS, pHTPhyMode->BW, pHTPhyMode->STBC, pHTPhyMode->ExtOffset));
4610 DBGPRINT(RT_DEBUG_TRACE, (" MlmeUpdateTxRates (.word = %x )\n", pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.word));
4614 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_STA_CONFIG(kmalloc failed)\n"));
4618 case RT_OID_802_11_COUNTRY_REGION:
4619 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_COUNTRY_REGION \n"));
4620 wrq->u.data.length = sizeof(ulInfo);
4621 ulInfo = pAdapter->CommonCfg.CountryRegionForABand;
4622 ulInfo = (ulInfo << 8)|(pAdapter->CommonCfg.CountryRegion);
4623 if (copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length))
4628 case RT_OID_802_11_QUERY_DAT_HT_PHYMODE:
4629 pHTPhyMode = (OID_SET_HT_PHYMODE *) kmalloc(sizeof(OID_SET_HT_PHYMODE), MEM_ALLOC_FLAG);
4632 pHTPhyMode->PhyMode = pAdapter->CommonCfg.PhyMode;
4633 pHTPhyMode->HtMode = (UCHAR)pAdapter->CommonCfg.RegTransmitSetting.field.HTMODE;
4634 pHTPhyMode->BW = (UCHAR)pAdapter->CommonCfg.RegTransmitSetting.field.BW;
4635 pHTPhyMode->MCS= (UCHAR)pAdapter->StaCfg.DesiredTransmitSetting.field.MCS;
4636 pHTPhyMode->SHORTGI= (UCHAR)pAdapter->CommonCfg.RegTransmitSetting.field.ShortGI;
4637 pHTPhyMode->STBC= (UCHAR)pAdapter->CommonCfg.RegTransmitSetting.field.STBC;
4639 wrq->u.data.length = sizeof(OID_SET_HT_PHYMODE);
4640 if (copy_to_user(wrq->u.data.pointer, pHTPhyMode, wrq->u.data.length))
4644 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_HT_PHYMODE (PhyMode = %d, MCS =%d, BW = %d, STBC = %d, ExtOffset=%d)\n",
4645 pHTPhyMode->HtMode, pHTPhyMode->MCS, pHTPhyMode->BW, pHTPhyMode->STBC, pHTPhyMode->ExtOffset));
4646 DBGPRINT(RT_DEBUG_TRACE, (" MlmeUpdateTxRates (.word = %x )\n", pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.word));
4650 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_STA_CONFIG(kmalloc failed)\n"));
4654 case RT_OID_QUERY_MULTIPLE_CARD_SUPPORT:
4655 wrq->u.data.length = sizeof(UCHAR);
4657 if (copy_to_user(wrq->u.data.pointer, &i, wrq->u.data.length))
4661 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_QUERY_MULTIPLE_CARD_SUPPORT(=%d) \n", i));
4664 case OID_802_11_BUILD_CHANNEL_EX:
4667 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_BUILD_CHANNEL_EX \n"));
4668 wrq->u.data.length = sizeof(UCHAR);
4669 DBGPRINT(RT_DEBUG_TRACE, ("Doesn't support EXT_BUILD_CHANNEL_LIST.\n"));
4671 Status = copy_to_user(wrq->u.data.pointer, &value, 1);
4672 DBGPRINT(RT_DEBUG_TRACE, ("Status=%d\n", Status));
4676 case OID_802_11_GET_CH_LIST:
4678 PRT_CHANNEL_LIST_INFO pChListBuf;
4680 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_GET_CH_LIST \n"));
4681 if (pAdapter->ChannelListNum == 0)
4683 wrq->u.data.length = 0;
4687 pChListBuf = (RT_CHANNEL_LIST_INFO *) kmalloc(sizeof(RT_CHANNEL_LIST_INFO), MEM_ALLOC_FLAG);
4688 if (pChListBuf == NULL)
4690 wrq->u.data.length = 0;
4694 pChListBuf->ChannelListNum = pAdapter->ChannelListNum;
4695 for (i = 0; i < pChListBuf->ChannelListNum; i++)
4696 pChListBuf->ChannelList[i] = pAdapter->ChannelList[i].Channel;
4698 wrq->u.data.length = sizeof(RT_CHANNEL_LIST_INFO);
4699 Status = copy_to_user(wrq->u.data.pointer, pChListBuf, sizeof(RT_CHANNEL_LIST_INFO));
4700 DBGPRINT(RT_DEBUG_TRACE, ("Status=%d\n", Status));
4707 case OID_802_11_GET_COUNTRY_CODE:
4708 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_GET_COUNTRY_CODE \n"));
4709 wrq->u.data.length = 2;
4710 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.CountryCode, 2);
4711 DBGPRINT(RT_DEBUG_TRACE, ("Status=%d\n", Status));
4714 case OID_802_11_GET_CHANNEL_GEOGRAPHY:
4715 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_GET_CHANNEL_GEOGRAPHY \n"));
4716 wrq->u.data.length = 1;
4717 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.Geography, 1);
4718 DBGPRINT(RT_DEBUG_TRACE, ("Status=%d\n", Status));
4722 DBGPRINT(RT_DEBUG_TRACE, ("Query::unknown IOCTL's subcmd = 0x%08x\n", cmd));
4723 Status = -EOPNOTSUPP;
4729 INT rt28xx_sta_ioctl(
4730 IN struct net_device *net_dev,
4731 IN OUT struct ifreq *rq,
4734 RTMP_ADAPTER *pAd = net_dev->ml_priv;
4735 POS_COOKIE pObj = (POS_COOKIE)pAd->OS_Cookie;
4736 struct iwreq *wrq = (struct iwreq *) rq;
4737 BOOLEAN StateMachineTouched = FALSE;
4738 INT Status = NDIS_STATUS_SUCCESS;
4741 //check if the interface is down
4742 if(!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_IN_USE))
4745 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
4750 { // determine this ioctl command is comming from which interface.
4751 pObj->ioctl_if_type = INT_MAIN;
4752 pObj->ioctl_if = MAIN_MBSSID;
4758 DBGPRINT(RT_DEBUG_TRACE, ("IOCTL::SIOCGIFHWADDR\n"));
4759 memcpy(wrq->u.name, pAd->CurrentAddress, ETH_ALEN);
4763 char *name=&wrq->u.name[0];
4764 rt_ioctl_giwname(net_dev, NULL, name, NULL);
4767 case SIOCGIWESSID: //Get ESSID
4769 struct iw_point *essid=&wrq->u.essid;
4770 rt_ioctl_giwessid(net_dev, NULL, essid, essid->pointer);
4773 case SIOCSIWESSID: //Set ESSID
4775 struct iw_point *essid=&wrq->u.essid;
4776 rt_ioctl_siwessid(net_dev, NULL, essid, essid->pointer);
4779 case SIOCSIWNWID: // set network id (the cell)
4780 case SIOCGIWNWID: // get network id
4781 Status = -EOPNOTSUPP;
4783 case SIOCSIWFREQ: //set channel/frequency (Hz)
4785 struct iw_freq *freq=&wrq->u.freq;
4786 rt_ioctl_siwfreq(net_dev, NULL, freq, NULL);
4789 case SIOCGIWFREQ: // get channel/frequency (Hz)
4791 struct iw_freq *freq=&wrq->u.freq;
4792 rt_ioctl_giwfreq(net_dev, NULL, freq, NULL);
4795 case SIOCSIWNICKN: //set node name/nickname
4797 struct iw_point *data=&wrq->u.data;
4798 rt_ioctl_siwnickn(net_dev, NULL, data, NULL);
4801 case SIOCGIWNICKN: //get node name/nickname
4803 struct iw_point *data=&wrq->u.data;
4804 rt_ioctl_giwnickn(net_dev, NULL, data, NULL);
4807 case SIOCGIWRATE: //get default bit rate (bps)
4808 rt_ioctl_giwrate(net_dev, NULL, &wrq->u, NULL);
4810 case SIOCSIWRATE: //set default bit rate (bps)
4811 rt_ioctl_siwrate(net_dev, NULL, &wrq->u, NULL);
4813 case SIOCGIWRTS: // get RTS/CTS threshold (bytes)
4815 struct iw_param *rts=&wrq->u.rts;
4816 rt_ioctl_giwrts(net_dev, NULL, rts, NULL);
4819 case SIOCSIWRTS: //set RTS/CTS threshold (bytes)
4821 struct iw_param *rts=&wrq->u.rts;
4822 rt_ioctl_siwrts(net_dev, NULL, rts, NULL);
4825 case SIOCGIWFRAG: //get fragmentation thr (bytes)
4827 struct iw_param *frag=&wrq->u.frag;
4828 rt_ioctl_giwfrag(net_dev, NULL, frag, NULL);
4831 case SIOCSIWFRAG: //set fragmentation thr (bytes)
4833 struct iw_param *frag=&wrq->u.frag;
4834 rt_ioctl_siwfrag(net_dev, NULL, frag, NULL);
4837 case SIOCGIWENCODE: //get encoding token & mode
4839 struct iw_point *erq=&wrq->u.encoding;
4841 rt_ioctl_giwencode(net_dev, NULL, erq, erq->pointer);
4844 case SIOCSIWENCODE: //set encoding token & mode
4846 struct iw_point *erq=&wrq->u.encoding;
4848 rt_ioctl_siwencode(net_dev, NULL, erq, erq->pointer);
4851 case SIOCGIWAP: //get access point MAC addresses
4853 struct sockaddr *ap_addr=&wrq->u.ap_addr;
4854 rt_ioctl_giwap(net_dev, NULL, ap_addr, ap_addr->sa_data);
4857 case SIOCSIWAP: //set access point MAC addresses
4859 struct sockaddr *ap_addr=&wrq->u.ap_addr;
4860 rt_ioctl_siwap(net_dev, NULL, ap_addr, ap_addr->sa_data);
4863 case SIOCGIWMODE: //get operation mode
4865 __u32 *mode=&wrq->u.mode;
4866 rt_ioctl_giwmode(net_dev, NULL, mode, NULL);
4869 case SIOCSIWMODE: //set operation mode
4871 __u32 *mode=&wrq->u.mode;
4872 rt_ioctl_siwmode(net_dev, NULL, mode, NULL);
4875 case SIOCGIWSENS: //get sensitivity (dBm)
4876 case SIOCSIWSENS: //set sensitivity (dBm)
4877 case SIOCGIWPOWER: //get Power Management settings
4878 case SIOCSIWPOWER: //set Power Management settings
4879 case SIOCGIWTXPOW: //get transmit power (dBm)
4880 case SIOCSIWTXPOW: //set transmit power (dBm)
4881 case SIOCGIWRANGE: //Get range of parameters
4882 case SIOCGIWRETRY: //get retry limits and lifetime
4883 case SIOCSIWRETRY: //set retry limits and lifetime
4884 Status = -EOPNOTSUPP;
4888 case RT_PRIV_IOCTL_EXT:
4890 subcmd = wrq->u.data.flags;
4891 if( subcmd & OID_GET_SET_TOGGLE)
4892 Status = RTMPSetInformation(pAd, rq, subcmd);
4894 Status = RTMPQueryInformation(pAd, rq, subcmd);
4897 if (wrq->u.data.pointer)
4899 if ( access_ok(VERIFY_WRITE, wrq->u.data.pointer, sizeof(privtab)) != TRUE)
4901 wrq->u.data.length = sizeof(privtab) / sizeof(privtab[0]);
4902 if (copy_to_user(wrq->u.data.pointer, privtab, sizeof(privtab)))
4906 case RTPRIV_IOCTL_SET:
4907 if(access_ok(VERIFY_READ, wrq->u.data.pointer, wrq->u.data.length) != TRUE)
4909 rt_ioctl_setparam(net_dev, NULL, NULL, wrq->u.data.pointer);
4911 case RTPRIV_IOCTL_GSITESURVEY:
4912 RTMPIoctlGetSiteSurvey(pAd, wrq);
4915 case RTPRIV_IOCTL_MAC:
4916 RTMPIoctlMAC(pAd, wrq);
4918 case RTPRIV_IOCTL_E2P:
4919 RTMPIoctlE2PROM(pAd, wrq);
4922 case RTPRIV_IOCTL_RF:
4923 RTMPIoctlRF(pAd, wrq);
4930 DBGPRINT(RT_DEBUG_ERROR, ("IOCTL::unknown IOCTL's cmd = 0x%08x\n", cmd));
4931 Status = -EOPNOTSUPP;
4935 if(StateMachineTouched) // Upper layer sent a MLME-related operations
4936 RT28XX_MLME_HANDLER(pAd);
4942 ==========================================================================
4946 TRUE if all parameters are OK, FALSE otherwise
4947 ==========================================================================
4950 IN PRTMP_ADAPTER pAdapter,
4953 NDIS_802_11_SSID Ssid, *pSsid=NULL;
4954 BOOLEAN StateMachineTouched = FALSE;
4957 if( strlen(arg) <= MAX_LEN_OF_SSID)
4959 NdisZeroMemory(&Ssid, sizeof(NDIS_802_11_SSID));
4960 if (strlen(arg) != 0)
4962 NdisMoveMemory(Ssid.Ssid, arg, strlen(arg));
4963 Ssid.SsidLength = strlen(arg);
4967 Ssid.SsidLength = 0;
4968 memcpy(Ssid.Ssid, "", 0);
4969 pAdapter->StaCfg.BssType = BSS_INFRA;
4970 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
4971 pAdapter->StaCfg.WepStatus = Ndis802_11EncryptionDisabled;
4975 if (pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE)
4977 RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
4978 DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
4981 pAdapter->MlmeAux.CurrReqIsFromNdis = TRUE;
4982 pAdapter->StaCfg.bScanReqIsFromWebUI = FALSE;
4983 pAdapter->bConfigChanged = TRUE;
4985 MlmeEnqueue(pAdapter,
4986 MLME_CNTL_STATE_MACHINE,
4988 sizeof(NDIS_802_11_SSID),
4991 StateMachineTouched = TRUE;
4992 DBGPRINT(RT_DEBUG_TRACE, ("Set_SSID_Proc::(Len=%d,Ssid=%s)\n", Ssid.SsidLength, Ssid.Ssid));
4997 if (StateMachineTouched) // Upper layer sent a MLME-related operations
4998 RT28XX_MLME_HANDLER(pAdapter);
5005 ==========================================================================
5007 Set WmmCapable Enable or Disable
5009 TRUE if all parameters are OK, FALSE otherwise
5010 ==========================================================================
5012 INT Set_WmmCapable_Proc(
5013 IN PRTMP_ADAPTER pAd,
5016 BOOLEAN bWmmCapable;
5018 bWmmCapable = simple_strtol(arg, 0, 10);
5020 if ((bWmmCapable == 1)
5022 && (pAd->NumberOfPipes >= 5)
5025 pAd->CommonCfg.bWmmCapable = TRUE;
5026 else if (bWmmCapable == 0)
5027 pAd->CommonCfg.bWmmCapable = FALSE;
5029 return FALSE; //Invalid argument
5031 DBGPRINT(RT_DEBUG_TRACE, ("Set_WmmCapable_Proc::(bWmmCapable=%d)\n",
5032 pAd->CommonCfg.bWmmCapable));
5036 #endif // WMM_SUPPORT //
5039 ==========================================================================
5041 Set Network Type(Infrastructure/Adhoc mode)
5043 TRUE if all parameters are OK, FALSE otherwise
5044 ==========================================================================
5046 INT Set_NetworkType_Proc(
5047 IN PRTMP_ADAPTER pAdapter,
5052 if (strcmp(arg, "Adhoc") == 0)
5054 if (pAdapter->StaCfg.BssType != BSS_ADHOC)
5056 // Config has changed
5057 pAdapter->bConfigChanged = TRUE;
5058 if (MONITOR_ON(pAdapter))
5060 RTMP_IO_WRITE32(pAdapter, RX_FILTR_CFG, STANORMAL);
5061 RTMP_IO_READ32(pAdapter, MAC_SYS_CTRL, &Value);
5063 RTMP_IO_WRITE32(pAdapter, MAC_SYS_CTRL, Value);
5064 OPSTATUS_CLEAR_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED);
5065 pAdapter->StaCfg.bAutoReconnect = TRUE;
5066 LinkDown(pAdapter, FALSE);
5068 if (INFRA_ON(pAdapter))
5070 //BOOLEAN Cancelled;
5071 // Set the AutoReconnectSsid to prevent it reconnect to old SSID
5072 // Since calling this indicate user don't want to connect to that SSID anymore.
5073 pAdapter->MlmeAux.AutoReconnectSsidLen= 32;
5074 NdisZeroMemory(pAdapter->MlmeAux.AutoReconnectSsid, pAdapter->MlmeAux.AutoReconnectSsidLen);
5076 LinkDown(pAdapter, FALSE);
5078 DBGPRINT(RT_DEBUG_TRACE, ("NDIS_STATUS_MEDIA_DISCONNECT Event BB!\n"));
5081 pAdapter->StaCfg.BssType = BSS_ADHOC;
5082 pAdapter->net_dev->type = pAdapter->StaCfg.OriDevType;
5083 DBGPRINT(RT_DEBUG_TRACE, ("===>Set_NetworkType_Proc::(AD-HOC)\n"));
5085 else if (strcmp(arg, "Infra") == 0)
5087 if (pAdapter->StaCfg.BssType != BSS_INFRA)
5089 // Config has changed
5090 pAdapter->bConfigChanged = TRUE;
5091 if (MONITOR_ON(pAdapter))
5093 RTMP_IO_WRITE32(pAdapter, RX_FILTR_CFG, STANORMAL);
5094 RTMP_IO_READ32(pAdapter, MAC_SYS_CTRL, &Value);
5096 RTMP_IO_WRITE32(pAdapter, MAC_SYS_CTRL, Value);
5097 OPSTATUS_CLEAR_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED);
5098 pAdapter->StaCfg.bAutoReconnect = TRUE;
5099 LinkDown(pAdapter, FALSE);
5101 if (ADHOC_ON(pAdapter))
5103 // Set the AutoReconnectSsid to prevent it reconnect to old SSID
5104 // Since calling this indicate user don't want to connect to that SSID anymore.
5105 pAdapter->MlmeAux.AutoReconnectSsidLen= 32;
5106 NdisZeroMemory(pAdapter->MlmeAux.AutoReconnectSsid, pAdapter->MlmeAux.AutoReconnectSsidLen);
5108 LinkDown(pAdapter, FALSE);
5111 pAdapter->StaCfg.BssType = BSS_INFRA;
5112 pAdapter->net_dev->type = pAdapter->StaCfg.OriDevType;
5113 DBGPRINT(RT_DEBUG_TRACE, ("===>Set_NetworkType_Proc::(INFRA)\n"));
5115 pAdapter->StaCfg.BssType = BSS_INFRA;
5117 else if (strcmp(arg, "Monitor") == 0)
5120 BCN_TIME_CFG_STRUC csr;
5121 OPSTATUS_CLEAR_FLAG(pAdapter, fOP_STATUS_INFRA_ON);
5122 OPSTATUS_CLEAR_FLAG(pAdapter, fOP_STATUS_ADHOC_ON);
5123 OPSTATUS_SET_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED);
5124 // disable all periodic state machine
5125 pAdapter->StaCfg.bAutoReconnect = FALSE;
5126 // reset all mlme state machine
5127 RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
5128 DBGPRINT(RT_DEBUG_TRACE, ("fOP_STATUS_MEDIA_STATE_CONNECTED \n"));
5129 if (pAdapter->CommonCfg.CentralChannel == 0)
5131 if (pAdapter->CommonCfg.PhyMode == PHY_11AN_MIXED)
5132 pAdapter->CommonCfg.CentralChannel = 36;
5134 pAdapter->CommonCfg.CentralChannel = 6;
5137 N_ChannelCheck(pAdapter);
5139 if (pAdapter->CommonCfg.PhyMode >= PHY_11ABGN_MIXED &&
5140 pAdapter->CommonCfg.RegTransmitSetting.field.BW == BW_40 &&
5141 pAdapter->CommonCfg.RegTransmitSetting.field.EXTCHA == EXTCHA_ABOVE)
5143 // 40MHz ,control channel at lower
5144 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, BBP_R4, &bbpValue);
5145 bbpValue &= (~0x18);
5147 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R4, bbpValue);
5148 pAdapter->CommonCfg.BBPCurrentBW = BW_40;
5149 // RX : control channel at lower
5150 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, BBP_R3, &bbpValue);
5151 bbpValue &= (~0x20);
5152 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R3, bbpValue);
5154 RTMP_IO_READ32(pAdapter, TX_BAND_CFG, &Value);
5155 Value &= 0xfffffffe;
5156 RTMP_IO_WRITE32(pAdapter, TX_BAND_CFG, Value);
5157 pAdapter->CommonCfg.CentralChannel = pAdapter->CommonCfg.Channel + 2;
5158 AsicSwitchChannel(pAdapter, pAdapter->CommonCfg.CentralChannel, FALSE);
5159 AsicLockChannel(pAdapter, pAdapter->CommonCfg.CentralChannel);
5160 DBGPRINT(RT_DEBUG_TRACE, ("BW_40 ,control_channel(%d), CentralChannel(%d) \n",
5161 pAdapter->CommonCfg.Channel,
5162 pAdapter->CommonCfg.CentralChannel));
5164 else if (pAdapter->CommonCfg.PhyMode >= PHY_11ABGN_MIXED &&
5165 pAdapter->CommonCfg.RegTransmitSetting.field.BW == BW_40 &&
5166 pAdapter->CommonCfg.RegTransmitSetting.field.EXTCHA == EXTCHA_BELOW)
5168 // 40MHz ,control channel at upper
5169 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, BBP_R4, &bbpValue);
5170 bbpValue &= (~0x18);
5172 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R4, bbpValue);
5173 pAdapter->CommonCfg.BBPCurrentBW = BW_40;
5174 RTMP_IO_READ32(pAdapter, TX_BAND_CFG, &Value);
5176 RTMP_IO_WRITE32(pAdapter, TX_BAND_CFG, Value);
5178 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, BBP_R3, &bbpValue);
5180 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R3, bbpValue);
5181 pAdapter->CommonCfg.CentralChannel = pAdapter->CommonCfg.Channel - 2;
5182 AsicSwitchChannel(pAdapter, pAdapter->CommonCfg.CentralChannel, FALSE);
5183 AsicLockChannel(pAdapter, pAdapter->CommonCfg.CentralChannel);
5184 DBGPRINT(RT_DEBUG_TRACE, ("BW_40 ,control_channel(%d), CentralChannel(%d) \n",
5185 pAdapter->CommonCfg.Channel,
5186 pAdapter->CommonCfg.CentralChannel));
5191 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, BBP_R4, &bbpValue);
5192 bbpValue &= (~0x18);
5193 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R4, bbpValue);
5194 pAdapter->CommonCfg.BBPCurrentBW = BW_20;
5195 AsicSwitchChannel(pAdapter, pAdapter->CommonCfg.Channel, FALSE);
5196 AsicLockChannel(pAdapter, pAdapter->CommonCfg.Channel);
5197 DBGPRINT(RT_DEBUG_TRACE, ("BW_20, Channel(%d)\n", pAdapter->CommonCfg.Channel));
5199 // Enable Rx with promiscuous reception
5200 RTMP_IO_WRITE32(pAdapter, RX_FILTR_CFG, 0x3);
5201 // ASIC supporsts sniffer function with replacing RSSI with timestamp.
5202 //RTMP_IO_READ32(pAdapter, MAC_SYS_CTRL, &Value);
5204 //RTMP_IO_WRITE32(pAdapter, MAC_SYS_CTRL, Value);
5206 RTMP_IO_READ32(pAdapter, BCN_TIME_CFG, &csr.word);
5207 csr.field.bBeaconGen = 0;
5208 csr.field.bTBTTEnable = 0;
5209 csr.field.TsfSyncMode = 0;
5210 RTMP_IO_WRITE32(pAdapter, BCN_TIME_CFG, csr.word);
5212 pAdapter->StaCfg.BssType = BSS_MONITOR;
5213 pAdapter->net_dev->type = ARPHRD_IEEE80211_PRISM; //ARPHRD_IEEE80211; // IEEE80211
5214 DBGPRINT(RT_DEBUG_TRACE, ("===>Set_NetworkType_Proc::(MONITOR)\n"));
5217 // Reset Ralink supplicant to not use, it will be set to start when UI set PMK key
5218 pAdapter->StaCfg.WpaState = SS_NOTUSE;
5220 DBGPRINT(RT_DEBUG_TRACE, ("Set_NetworkType_Proc::(NetworkType=%d)\n", pAdapter->StaCfg.BssType));
5226 ==========================================================================
5228 Set Authentication mode
5230 TRUE if all parameters are OK, FALSE otherwise
5231 ==========================================================================
5233 INT Set_AuthMode_Proc(
5234 IN PRTMP_ADAPTER pAdapter,
5237 if ((strcmp(arg, "WEPAUTO") == 0) || (strcmp(arg, "wepauto") == 0))
5238 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeAutoSwitch;
5239 else if ((strcmp(arg, "OPEN") == 0) || (strcmp(arg, "open") == 0))
5240 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
5241 else if ((strcmp(arg, "SHARED") == 0) || (strcmp(arg, "shared") == 0))
5242 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeShared;
5243 else if ((strcmp(arg, "WPAPSK") == 0) || (strcmp(arg, "wpapsk") == 0))
5244 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPAPSK;
5245 else if ((strcmp(arg, "WPANONE") == 0) || (strcmp(arg, "wpanone") == 0))
5246 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPANone;
5247 else if ((strcmp(arg, "WPA2PSK") == 0) || (strcmp(arg, "wpa2psk") == 0))
5248 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA2PSK;
5249 else if ((strcmp(arg, "WPA") == 0) || (strcmp(arg, "wpa") == 0))
5250 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA;
5251 else if ((strcmp(arg, "WPA2") == 0) || (strcmp(arg, "wpa2") == 0))
5252 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA2;
5256 pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED;
5258 DBGPRINT(RT_DEBUG_TRACE, ("Set_AuthMode_Proc::(AuthMode=%d)\n", pAdapter->StaCfg.AuthMode));
5264 ==========================================================================
5268 TRUE if all parameters are OK, FALSE otherwise
5269 ==========================================================================
5271 INT Set_EncrypType_Proc(
5272 IN PRTMP_ADAPTER pAdapter,
5275 if ((strcmp(arg, "NONE") == 0) || (strcmp(arg, "none") == 0))
5277 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
5278 return TRUE; // do nothing
5280 pAdapter->StaCfg.WepStatus = Ndis802_11WEPDisabled;
5281 pAdapter->StaCfg.PairCipher = Ndis802_11WEPDisabled;
5282 pAdapter->StaCfg.GroupCipher = Ndis802_11WEPDisabled;
5284 else if ((strcmp(arg, "WEP") == 0) || (strcmp(arg, "wep") == 0))
5286 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
5287 return TRUE; // do nothing
5289 pAdapter->StaCfg.WepStatus = Ndis802_11WEPEnabled;
5290 pAdapter->StaCfg.PairCipher = Ndis802_11WEPEnabled;
5291 pAdapter->StaCfg.GroupCipher = Ndis802_11WEPEnabled;
5293 else if ((strcmp(arg, "TKIP") == 0) || (strcmp(arg, "tkip") == 0))
5295 if (pAdapter->StaCfg.AuthMode < Ndis802_11AuthModeWPA)
5296 return TRUE; // do nothing
5298 pAdapter->StaCfg.WepStatus = Ndis802_11Encryption2Enabled;
5299 pAdapter->StaCfg.PairCipher = Ndis802_11Encryption2Enabled;
5300 pAdapter->StaCfg.GroupCipher = Ndis802_11Encryption2Enabled;
5302 else if ((strcmp(arg, "AES") == 0) || (strcmp(arg, "aes") == 0))
5304 if (pAdapter->StaCfg.AuthMode < Ndis802_11AuthModeWPA)
5305 return TRUE; // do nothing
5307 pAdapter->StaCfg.WepStatus = Ndis802_11Encryption3Enabled;
5308 pAdapter->StaCfg.PairCipher = Ndis802_11Encryption3Enabled;
5309 pAdapter->StaCfg.GroupCipher = Ndis802_11Encryption3Enabled;
5314 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
5316 DBGPRINT(RT_DEBUG_TRACE, ("Set_EncrypType_Proc::(EncrypType=%d)\n", pAdapter->StaCfg.WepStatus));
5322 ==========================================================================
5326 TRUE if all parameters are OK, FALSE otherwise
5327 ==========================================================================
5329 INT Set_DefaultKeyID_Proc(
5330 IN PRTMP_ADAPTER pAdapter,
5335 KeyIdx = simple_strtol(arg, 0, 10);
5336 if((KeyIdx >= 1 ) && (KeyIdx <= 4))
5337 pAdapter->StaCfg.DefaultKeyId = (UCHAR) (KeyIdx - 1 );
5339 return FALSE; //Invalid argument
5341 DBGPRINT(RT_DEBUG_TRACE, ("Set_DefaultKeyID_Proc::(DefaultKeyID=%d)\n", pAdapter->StaCfg.DefaultKeyId));
5347 ==========================================================================
5351 TRUE if all parameters are OK, FALSE otherwise
5352 ==========================================================================
5355 IN PRTMP_ADAPTER pAdapter,
5360 UCHAR CipherAlg=CIPHER_WEP64;
5362 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
5363 return TRUE; // do nothing
5365 KeyLen = strlen(arg);
5369 case 5: //wep 40 Ascii type
5370 pAdapter->SharedKey[BSS0][0].KeyLen = KeyLen;
5371 memcpy(pAdapter->SharedKey[BSS0][0].Key, arg, KeyLen);
5372 CipherAlg = CIPHER_WEP64;
5373 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key1_Proc::(Key1=%s and type=%s)\n", arg, "Ascii"));
5375 case 10: //wep 40 Hex type
5376 for(i=0; i < KeyLen; i++)
5378 if( !isxdigit(*(arg+i)) )
5379 return FALSE; //Not Hex value;
5381 pAdapter->SharedKey[BSS0][0].KeyLen = KeyLen / 2 ;
5382 AtoH(arg, pAdapter->SharedKey[BSS0][0].Key, KeyLen / 2);
5383 CipherAlg = CIPHER_WEP64;
5384 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key1_Proc::(Key1=%s and type=%s)\n", arg, "Hex"));
5386 case 13: //wep 104 Ascii type
5387 pAdapter->SharedKey[BSS0][0].KeyLen = KeyLen;
5388 memcpy(pAdapter->SharedKey[BSS0][0].Key, arg, KeyLen);
5389 CipherAlg = CIPHER_WEP128;
5390 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key1_Proc::(Key1=%s and type=%s)\n", arg, "Ascii"));
5392 case 26: //wep 104 Hex type
5393 for(i=0; i < KeyLen; i++)
5395 if( !isxdigit(*(arg+i)) )
5396 return FALSE; //Not Hex value;
5398 pAdapter->SharedKey[BSS0][0].KeyLen = KeyLen / 2 ;
5399 AtoH(arg, pAdapter->SharedKey[BSS0][0].Key, KeyLen / 2);
5400 CipherAlg = CIPHER_WEP128;
5401 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key1_Proc::(Key1=%s and type=%s)\n", arg, "Hex"));
5403 default: //Invalid argument
5404 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key1_Proc::Invalid argument (=%s)\n", arg));
5408 pAdapter->SharedKey[BSS0][0].CipherAlg = CipherAlg;
5410 // Set keys (into ASIC)
5411 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
5413 else // Old WEP stuff
5415 AsicAddSharedKeyEntry(pAdapter,
5418 pAdapter->SharedKey[BSS0][0].CipherAlg,
5419 pAdapter->SharedKey[BSS0][0].Key,
5427 ==========================================================================
5432 TRUE if all parameters are OK, FALSE otherwise
5433 ==========================================================================
5436 IN PRTMP_ADAPTER pAdapter,
5441 UCHAR CipherAlg=CIPHER_WEP64;
5443 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
5444 return TRUE; // do nothing
5446 KeyLen = strlen(arg);
5450 case 5: //wep 40 Ascii type
5451 pAdapter->SharedKey[BSS0][1].KeyLen = KeyLen;
5452 memcpy(pAdapter->SharedKey[BSS0][1].Key, arg, KeyLen);
5453 CipherAlg = CIPHER_WEP64;
5454 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key2_Proc::(Key2=%s and type=%s)\n", arg, "Ascii"));
5456 case 10: //wep 40 Hex type
5457 for(i=0; i < KeyLen; i++)
5459 if( !isxdigit(*(arg+i)) )
5460 return FALSE; //Not Hex value;
5462 pAdapter->SharedKey[BSS0][1].KeyLen = KeyLen / 2 ;
5463 AtoH(arg, pAdapter->SharedKey[BSS0][1].Key, KeyLen / 2);
5464 CipherAlg = CIPHER_WEP64;
5465 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key2_Proc::(Key2=%s and type=%s)\n", arg, "Hex"));
5467 case 13: //wep 104 Ascii type
5468 pAdapter->SharedKey[BSS0][1].KeyLen = KeyLen;
5469 memcpy(pAdapter->SharedKey[BSS0][1].Key, arg, KeyLen);
5470 CipherAlg = CIPHER_WEP128;
5471 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key2_Proc::(Key2=%s and type=%s)\n", arg, "Ascii"));
5473 case 26: //wep 104 Hex type
5474 for(i=0; i < KeyLen; i++)
5476 if( !isxdigit(*(arg+i)) )
5477 return FALSE; //Not Hex value;
5479 pAdapter->SharedKey[BSS0][1].KeyLen = KeyLen / 2 ;
5480 AtoH(arg, pAdapter->SharedKey[BSS0][1].Key, KeyLen / 2);
5481 CipherAlg = CIPHER_WEP128;
5482 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key2_Proc::(Key2=%s and type=%s)\n", arg, "Hex"));
5484 default: //Invalid argument
5485 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key2_Proc::Invalid argument (=%s)\n", arg));
5488 pAdapter->SharedKey[BSS0][1].CipherAlg = CipherAlg;
5490 // Set keys (into ASIC)
5491 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
5493 else // Old WEP stuff
5495 AsicAddSharedKeyEntry(pAdapter,
5498 pAdapter->SharedKey[BSS0][1].CipherAlg,
5499 pAdapter->SharedKey[BSS0][1].Key,
5507 ==========================================================================
5511 TRUE if all parameters are OK, FALSE otherwise
5512 ==========================================================================
5515 IN PRTMP_ADAPTER pAdapter,
5520 UCHAR CipherAlg=CIPHER_WEP64;
5522 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
5523 return TRUE; // do nothing
5525 KeyLen = strlen(arg);
5529 case 5: //wep 40 Ascii type
5530 pAdapter->SharedKey[BSS0][2].KeyLen = KeyLen;
5531 memcpy(pAdapter->SharedKey[BSS0][2].Key, arg, KeyLen);
5532 CipherAlg = CIPHER_WEP64;
5533 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key3_Proc::(Key3=%s and type=Ascii)\n", arg));
5535 case 10: //wep 40 Hex type
5536 for(i=0; i < KeyLen; i++)
5538 if( !isxdigit(*(arg+i)) )
5539 return FALSE; //Not Hex value;
5541 pAdapter->SharedKey[BSS0][2].KeyLen = KeyLen / 2 ;
5542 AtoH(arg, pAdapter->SharedKey[BSS0][2].Key, KeyLen / 2);
5543 CipherAlg = CIPHER_WEP64;
5544 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key3_Proc::(Key3=%s and type=Hex)\n", arg));
5546 case 13: //wep 104 Ascii type
5547 pAdapter->SharedKey[BSS0][2].KeyLen = KeyLen;
5548 memcpy(pAdapter->SharedKey[BSS0][2].Key, arg, KeyLen);
5549 CipherAlg = CIPHER_WEP128;
5550 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key3_Proc::(Key3=%s and type=Ascii)\n", arg));
5552 case 26: //wep 104 Hex type
5553 for(i=0; i < KeyLen; i++)
5555 if( !isxdigit(*(arg+i)) )
5556 return FALSE; //Not Hex value;
5558 pAdapter->SharedKey[BSS0][2].KeyLen = KeyLen / 2 ;
5559 AtoH(arg, pAdapter->SharedKey[BSS0][2].Key, KeyLen / 2);
5560 CipherAlg = CIPHER_WEP128;
5561 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key3_Proc::(Key3=%s and type=Hex)\n", arg));
5563 default: //Invalid argument
5564 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key3_Proc::Invalid argument (=%s)\n", arg));
5567 pAdapter->SharedKey[BSS0][2].CipherAlg = CipherAlg;
5569 // Set keys (into ASIC)
5570 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
5572 else // Old WEP stuff
5574 AsicAddSharedKeyEntry(pAdapter,
5577 pAdapter->SharedKey[BSS0][2].CipherAlg,
5578 pAdapter->SharedKey[BSS0][2].Key,
5586 ==========================================================================
5590 TRUE if all parameters are OK, FALSE otherwise
5591 ==========================================================================
5594 IN PRTMP_ADAPTER pAdapter,
5599 UCHAR CipherAlg=CIPHER_WEP64;
5601 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
5602 return TRUE; // do nothing
5604 KeyLen = strlen(arg);
5608 case 5: //wep 40 Ascii type
5609 pAdapter->SharedKey[BSS0][3].KeyLen = KeyLen;
5610 memcpy(pAdapter->SharedKey[BSS0][3].Key, arg, KeyLen);
5611 CipherAlg = CIPHER_WEP64;
5612 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key4_Proc::(Key4=%s and type=%s)\n", arg, "Ascii"));
5614 case 10: //wep 40 Hex type
5615 for(i=0; i < KeyLen; i++)
5617 if( !isxdigit(*(arg+i)) )
5618 return FALSE; //Not Hex value;
5620 pAdapter->SharedKey[BSS0][3].KeyLen = KeyLen / 2 ;
5621 AtoH(arg, pAdapter->SharedKey[BSS0][3].Key, KeyLen / 2);
5622 CipherAlg = CIPHER_WEP64;
5623 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key4_Proc::(Key4=%s and type=%s)\n", arg, "Hex"));
5625 case 13: //wep 104 Ascii type
5626 pAdapter->SharedKey[BSS0][3].KeyLen = KeyLen;
5627 memcpy(pAdapter->SharedKey[BSS0][3].Key, arg, KeyLen);
5628 CipherAlg = CIPHER_WEP128;
5629 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key4_Proc::(Key4=%s and type=%s)\n", arg, "Ascii"));
5631 case 26: //wep 104 Hex type
5632 for(i=0; i < KeyLen; i++)
5634 if( !isxdigit(*(arg+i)) )
5635 return FALSE; //Not Hex value;
5637 pAdapter->SharedKey[BSS0][3].KeyLen = KeyLen / 2 ;
5638 AtoH(arg, pAdapter->SharedKey[BSS0][3].Key, KeyLen / 2);
5639 CipherAlg = CIPHER_WEP128;
5640 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key4_Proc::(Key4=%s and type=%s)\n", arg, "Hex"));
5642 default: //Invalid argument
5643 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key4_Proc::Invalid argument (=%s)\n", arg));
5646 pAdapter->SharedKey[BSS0][3].CipherAlg = CipherAlg;
5648 // Set keys (into ASIC)
5649 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
5651 else // Old WEP stuff
5653 AsicAddSharedKeyEntry(pAdapter,
5656 pAdapter->SharedKey[BSS0][3].CipherAlg,
5657 pAdapter->SharedKey[BSS0][3].Key,
5666 ==========================================================================
5670 TRUE if all parameters are OK, FALSE otherwise
5671 ==========================================================================
5673 INT Set_WPAPSK_Proc(
5674 IN PRTMP_ADAPTER pAdapter,
5677 UCHAR keyMaterial[40];
5679 if ((pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPAPSK) &&
5680 (pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPA2PSK) &&
5681 (pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPANone)
5683 return TRUE; // do nothing
5685 DBGPRINT(RT_DEBUG_TRACE, ("Set_WPAPSK_Proc::(WPAPSK=%s)\n", arg));
5687 NdisZeroMemory(keyMaterial, 40);
5689 if ((strlen(arg) < 8) || (strlen(arg) > 64))
5691 DBGPRINT(RT_DEBUG_TRACE, ("Set failed!!(WPAPSK=%s), WPAPSK key-string required 8 ~ 64 characters \n", arg));
5695 if (strlen(arg) == 64)
5697 AtoH(arg, keyMaterial, 32);
5698 NdisMoveMemory(pAdapter->StaCfg.PMK, keyMaterial, 32);
5703 PasswordHash((char *)arg, pAdapter->MlmeAux.Ssid, pAdapter->MlmeAux.SsidLen, keyMaterial);
5704 NdisMoveMemory(pAdapter->StaCfg.PMK, keyMaterial, 32);
5709 if(pAdapter->StaCfg.BssType == BSS_ADHOC &&
5710 pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPANone)
5712 pAdapter->StaCfg.WpaState = SS_NOTUSE;
5716 // Start STA supplicant state machine
5717 pAdapter->StaCfg.WpaState = SS_START;
5724 ==========================================================================
5726 Set Power Saving mode
5728 TRUE if all parameters are OK, FALSE otherwise
5729 ==========================================================================
5731 INT Set_PSMode_Proc(
5732 IN PRTMP_ADAPTER pAdapter,
5735 if (pAdapter->StaCfg.BssType == BSS_INFRA)
5737 if ((strcmp(arg, "Max_PSP") == 0) ||
5738 (strcmp(arg, "max_psp") == 0) ||
5739 (strcmp(arg, "MAX_PSP") == 0))
5741 // do NOT turn on PSM bit here, wait until MlmeCheckForPsmChange()
5742 // to exclude certain situations.
5743 if (pAdapter->StaCfg.bWindowsACCAMEnable == FALSE)
5744 pAdapter->StaCfg.WindowsPowerMode = Ndis802_11PowerModeMAX_PSP;
5745 pAdapter->StaCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeMAX_PSP;
5746 OPSTATUS_SET_FLAG(pAdapter, fOP_STATUS_RECEIVE_DTIM);
5747 pAdapter->StaCfg.DefaultListenCount = 5;
5750 else if ((strcmp(arg, "Fast_PSP") == 0) ||
5751 (strcmp(arg, "fast_psp") == 0) ||
5752 (strcmp(arg, "FAST_PSP") == 0))
5754 // do NOT turn on PSM bit here, wait until MlmeCheckForPsmChange()
5755 // to exclude certain situations.
5756 OPSTATUS_SET_FLAG(pAdapter, fOP_STATUS_RECEIVE_DTIM);
5757 if (pAdapter->StaCfg.bWindowsACCAMEnable == FALSE)
5758 pAdapter->StaCfg.WindowsPowerMode = Ndis802_11PowerModeFast_PSP;
5759 pAdapter->StaCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeFast_PSP;
5760 pAdapter->StaCfg.DefaultListenCount = 3;
5762 else if ((strcmp(arg, "Legacy_PSP") == 0) ||
5763 (strcmp(arg, "legacy_psp") == 0) ||
5764 (strcmp(arg, "LEGACY_PSP") == 0))
5766 // do NOT turn on PSM bit here, wait until MlmeCheckForPsmChange()
5767 // to exclude certain situations.
5768 OPSTATUS_SET_FLAG(pAdapter, fOP_STATUS_RECEIVE_DTIM);
5769 if (pAdapter->StaCfg.bWindowsACCAMEnable == FALSE)
5770 pAdapter->StaCfg.WindowsPowerMode = Ndis802_11PowerModeLegacy_PSP;
5771 pAdapter->StaCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeLegacy_PSP;
5772 pAdapter->StaCfg.DefaultListenCount = 3;
5776 //Default Ndis802_11PowerModeCAM
5777 // clear PSM bit immediately
5778 MlmeSetPsmBit(pAdapter, PWR_ACTIVE);
5779 OPSTATUS_SET_FLAG(pAdapter, fOP_STATUS_RECEIVE_DTIM);
5780 if (pAdapter->StaCfg.bWindowsACCAMEnable == FALSE)
5781 pAdapter->StaCfg.WindowsPowerMode = Ndis802_11PowerModeCAM;
5782 pAdapter->StaCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeCAM;
5785 DBGPRINT(RT_DEBUG_TRACE, ("Set_PSMode_Proc::(PSMode=%ld)\n", pAdapter->StaCfg.WindowsPowerMode));
5795 ==========================================================================
5797 Set WpaSupport flag.
5799 0: Driver ignore wpa_supplicant.
5800 1: wpa_supplicant initiates scanning and AP selection.
5801 2: driver takes care of scanning, AP selection, and IEEE 802.11 association parameters.
5803 TRUE if all parameters are OK, FALSE otherwise
5804 ==========================================================================
5806 INT Set_Wpa_Support(
5807 IN PRTMP_ADAPTER pAd,
5811 if ( simple_strtol(arg, 0, 10) == 0)
5812 pAd->StaCfg.WpaSupplicantUP = WPA_SUPPLICANT_DISABLE;
5813 else if ( simple_strtol(arg, 0, 10) == 1)
5814 pAd->StaCfg.WpaSupplicantUP = WPA_SUPPLICANT_ENABLE;
5815 else if ( simple_strtol(arg, 0, 10) == 2)
5816 pAd->StaCfg.WpaSupplicantUP = WPA_SUPPLICANT_ENABLE_WITH_WEB_UI;
5818 pAd->StaCfg.WpaSupplicantUP = WPA_SUPPLICANT_DISABLE;
5820 DBGPRINT(RT_DEBUG_TRACE, ("Set_Wpa_Support::(WpaSupplicantUP=%d)\n", pAd->StaCfg.WpaSupplicantUP));
5827 ==========================================================================
5831 pAdapter Pointer to our adapter
5832 wrq Pointer to the ioctl argument
5839 1.) iwpriv ra0 mac 0 ==> read MAC where Addr=0x0
5840 2.) iwpriv ra0 mac 0=12 ==> write MAC where Addr=0x0, value=12
5841 ==========================================================================
5844 IN PRTMP_ADAPTER pAdapter,
5845 IN struct iwreq *wrq)
5853 UCHAR temp[16], temp2[16];
5854 UINT32 macValue = 0;
5857 BOOLEAN bIsPrintAllMAC = FALSE;
5860 memset(msg, 0x00, 1024);
5861 if (wrq->u.data.length > 1) //No parameters.
5863 Status = copy_from_user(arg, wrq->u.data.pointer, (wrq->u.data.length > 255) ? 255 : wrq->u.data.length);
5866 //Parsing Read or Write
5871 if ((value = rtstrchr(this_char, '=')) != NULL)
5874 if (!value || !*value)
5877 if(strlen(this_char) > 4)
5880 j = strlen(this_char);
5883 if(this_char[j] > 'f' || this_char[j] < '0')
5888 k = j = strlen(this_char);
5891 this_char[4-k+j] = this_char[j];
5895 this_char[3-k++]='0';
5898 if(strlen(this_char) == 4)
5900 AtoH(this_char, temp, 2);
5901 macAddr = *temp*256 + temp[1];
5902 if (macAddr < 0xFFFF)
5904 RTMP_IO_READ32(pAdapter, macAddr, &macValue);
5905 DBGPRINT(RT_DEBUG_TRACE, ("MacAddr=%lx, MacValue=%x\n", macAddr, macValue));
5906 sprintf(msg+strlen(msg), "[0x%08lX]:%08X ", macAddr , macValue);
5910 {//Invalid parametes, so default printk all bbp
5913 {//Invalid parametes, so default printk all mac
5914 bIsPrintAllMAC = TRUE;
5922 memcpy(&temp2, value, strlen(value));
5923 temp2[strlen(value)] = '\0';
5926 if((strlen(this_char) > 4) || strlen(temp2) > 8)
5929 j = strlen(this_char);
5932 if(this_char[j] > 'f' || this_char[j] < '0')
5939 if(temp2[j] > 'f' || temp2[j] < '0')
5944 k = j = strlen(this_char);
5947 this_char[4-k+j] = this_char[j];
5951 this_char[3-k++]='0';
5955 k = j = strlen(temp2);
5958 temp2[8-k+j] = temp2[j];
5966 AtoH(this_char, temp, 2);
5967 macAddr = *temp*256 + temp[1];
5969 AtoH(temp2, temp, 4);
5970 macValue = *temp*256*256*256 + temp[1]*256*256 + temp[2]*256 + temp[3];
5973 if (macAddr == (HW_DEBUG_SETTING_BASE + 4))
5975 // 0x2bf4: byte0 non-zero: enable R17 tuning, 0: disable R17 tuning
5976 if (macValue & 0x000000ff)
5978 pAdapter->BbpTuning.bEnable = TRUE;
5979 DBGPRINT(RT_DEBUG_TRACE,("turn on R17 tuning\n"));
5984 pAdapter->BbpTuning.bEnable = FALSE;
5985 R66 = 0x26 + GET_LNA_GAIN(pAdapter);
5986 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R66, (0x26 + GET_LNA_GAIN(pAdapter)));
5987 DBGPRINT(RT_DEBUG_TRACE,("turn off R17 tuning, restore to 0x%02x\n", R66));
5992 DBGPRINT(RT_DEBUG_TRACE, ("MacAddr=%02lx, MacValue=0x%x\n", macAddr, macValue));
5994 RTMP_IO_WRITE32(pAdapter, macAddr, macValue);
5995 sprintf(msg+strlen(msg), "[0x%08lX]:%08X ", macAddr, macValue);
6001 bIsPrintAllMAC = TRUE;
6007 struct file *file_w;
6008 PCHAR fileName = "MacDump.txt";
6009 mm_segment_t orig_fs;
6015 file_w = filp_open(fileName, O_WRONLY|O_CREAT, 0);
6018 DBGPRINT(RT_DEBUG_TRACE, ("-->2) %s: Error %ld opening %s\n", __func__, -PTR_ERR(file_w), fileName));
6022 if (file_w->f_op && file_w->f_op->write)
6027 while (macAddr <= 0x1800)
6029 RTMP_IO_READ32(pAdapter, macAddr, &macValue);
6030 sprintf(msg, "%08lx = %08X\n", macAddr, macValue);
6032 // write data to file
6033 file_w->f_op->write(file_w, msg, strlen(msg), &file_w->f_pos);
6038 sprintf(msg, "\nDump all MAC values to %s\n", fileName);
6040 filp_close(file_w, NULL);
6045 if(strlen(msg) == 1)
6046 sprintf(msg+strlen(msg), "===>Error command format!");
6048 // Copy the information into the user buffer
6049 wrq->u.data.length = strlen(msg);
6050 Status = copy_to_user(wrq->u.data.pointer, msg, wrq->u.data.length);
6052 DBGPRINT(RT_DEBUG_TRACE, ("<==RTMPIoctlMAC\n\n"));
6056 ==========================================================================
6060 pAdapter Pointer to our adapter
6061 wrq Pointer to the ioctl argument
6068 1.) iwpriv ra0 e2p 0 ==> read E2PROM where Addr=0x0
6069 2.) iwpriv ra0 e2p 0=1234 ==> write E2PROM where Addr=0x0, value=1234
6070 ==========================================================================
6072 VOID RTMPIoctlE2PROM(
6073 IN PRTMP_ADAPTER pAdapter,
6074 IN struct iwreq *wrq)
6082 UCHAR temp[16], temp2[16];
6086 BOOLEAN bIsPrintAllE2P = FALSE;
6089 memset(msg, 0x00, 1024);
6090 if (wrq->u.data.length > 1) //No parameters.
6092 Status = copy_from_user(arg, wrq->u.data.pointer, (wrq->u.data.length > 255) ? 255 : wrq->u.data.length);
6095 //Parsing Read or Write
6102 if ((value = rtstrchr(this_char, '=')) != NULL)
6105 if (!value || !*value)
6109 if(strlen(this_char) > 4)
6112 j = strlen(this_char);
6115 if(this_char[j] > 'f' || this_char[j] < '0')
6120 k = j = strlen(this_char);
6123 this_char[4-k+j] = this_char[j];
6127 this_char[3-k++]='0';
6130 if(strlen(this_char) == 4)
6132 AtoH(this_char, temp, 2);
6133 eepAddr = *temp*256 + temp[1];
6134 if (eepAddr < 0xFFFF)
6136 RT28xx_EEPROM_READ16(pAdapter, eepAddr, eepValue);
6137 sprintf(msg+strlen(msg), "[0x%04X]:0x%04X ", eepAddr , eepValue);
6140 {//Invalid parametes, so default printk all bbp
6142 bIsPrintAllE2P = TRUE;
6150 memcpy(&temp2, value, strlen(value));
6151 temp2[strlen(value)] = '\0';
6154 if((strlen(this_char) > 4) || strlen(temp2) > 8)
6157 j = strlen(this_char);
6160 if(this_char[j] > 'f' || this_char[j] < '0')
6166 if(temp2[j] > 'f' || temp2[j] < '0')
6171 k = j = strlen(this_char);
6174 this_char[4-k+j] = this_char[j];
6178 this_char[3-k++]='0';
6182 k = j = strlen(temp2);
6185 temp2[4-k+j] = temp2[j];
6192 AtoH(this_char, temp, 2);
6193 eepAddr = *temp*256 + temp[1];
6195 AtoH(temp2, temp, 2);
6196 eepValue = *temp*256 + temp[1];
6198 RT28xx_EEPROM_WRITE16(pAdapter, eepAddr, eepValue);
6199 sprintf(msg+strlen(msg), "[0x%02X]:%02X ", eepAddr, eepValue);
6204 bIsPrintAllE2P = TRUE;
6210 struct file *file_w;
6211 PCHAR fileName = "EEPROMDump.txt";
6212 mm_segment_t orig_fs;
6218 file_w = filp_open(fileName, O_WRONLY|O_CREAT, 0);
6221 DBGPRINT(RT_DEBUG_TRACE, ("-->2) %s: Error %ld opening %s\n", __func__, -PTR_ERR(file_w), fileName));
6225 if (file_w->f_op && file_w->f_op->write)
6230 while (eepAddr <= 0xFE)
6232 RT28xx_EEPROM_READ16(pAdapter, eepAddr, eepValue);
6233 sprintf(msg, "%08x = %04x\n", eepAddr , eepValue);
6235 // write data to file
6236 file_w->f_op->write(file_w, msg, strlen(msg), &file_w->f_pos);
6241 sprintf(msg, "\nDump all EEPROM values to %s\n", fileName);
6243 filp_close(file_w, NULL);
6248 if(strlen(msg) == 1)
6249 sprintf(msg+strlen(msg), "===>Error command format!");
6252 // Copy the information into the user buffer
6253 wrq->u.data.length = strlen(msg);
6254 Status = copy_to_user(wrq->u.data.pointer, msg, wrq->u.data.length);
6256 DBGPRINT(RT_DEBUG_TRACE, ("<==RTMPIoctlE2PROM\n"));
6260 ==========================================================================
6262 Read / Write RF register
6264 pAdapter Pointer to our adapter
6265 wrq Pointer to the ioctl argument
6272 1.) iwpriv ra0 rf ==> read all RF registers
6273 2.) iwpriv ra0 rf 1 ==> read RF where RegID=1
6274 3.) iwpriv ra0 rf 1=10 ==> write RF R1=0x10
6275 ==========================================================================
6278 IN PRTMP_ADAPTER pAdapter,
6279 IN struct iwreq *wrq)
6289 BOOLEAN bIsPrintAllRF = FALSE;
6292 memset(msg, 0x00, 2048);
6293 if (wrq->u.data.length > 1) //No parameters.
6295 Status = copy_from_user(arg, wrq->u.data.pointer, (wrq->u.data.length > 255) ? 255 : wrq->u.data.length);
6298 //Parsing Read or Write
6303 if ((value = strchr(this_char, '=')) != NULL)
6306 if (!value || !*value)
6308 if (sscanf(this_char, "%d", &(rfId)) == 1)
6312 // In RT2860 ATE mode, we do not load 8051 firmware.
6313 //We must access RF directly.
6314 // For RT2870 ATE mode, ATE_RF_IO_WRITE8(/READ8)_BY_REG_ID are redefined.
6315 // according to Andy, Gary, David require.
6316 // the command rf shall read rf register directly for dubug.
6317 // BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, ®BBP);
6318 RT30xxReadRFRegister(pAdapter, rfId, ®RF);
6320 sprintf(msg+strlen(msg), "R%02d[0x%02x]:%02X ", rfId, rfId*2, regRF);
6323 {//Invalid parametes, so default printk all RF
6324 bIsPrintAllRF = TRUE;
6329 { //Invalid parametes, so default printk all RF
6330 bIsPrintAllRF = TRUE;
6336 if ((sscanf(this_char, "%d", &(rfId)) == 1) && (sscanf(value, "%lx", &(rfValue)) == 1))
6340 // In RT2860 ATE mode, we do not load 8051 firmware.
6341 // We should access RF registers directly.
6342 // For RT2870 ATE mode, ATE_RF_IO_WRITE8/READ8_BY_REG_ID are redefined.
6344 // according to Andy, Gary, David require.
6345 // the command RF shall read/write RF register directly for dubug.
6346 //BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, ®BBP);
6347 //BBP_IO_WRITE8_BY_REG_ID(pAdapter, (UCHAR)bbpId,(UCHAR) bbpValue);
6348 RT30xxReadRFRegister(pAdapter, rfId, ®RF);
6349 RT30xxWriteRFRegister(pAdapter, (UCHAR)rfId,(UCHAR) rfValue);
6350 //Read it back for showing
6351 //BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, ®BBP);
6352 RT30xxReadRFRegister(pAdapter, rfId, ®RF);
6353 sprintf(msg+strlen(msg), "R%02d[0x%02X]:%02X\n", rfId, rfId*2, regRF);
6357 {//Invalid parametes, so default printk all RF
6358 bIsPrintAllRF = TRUE;
6362 { //Invalid parametes, so default printk all RF
6363 bIsPrintAllRF = TRUE;
6368 bIsPrintAllRF = TRUE;
6372 memset(msg, 0x00, 2048);
6374 for (rfId = 0; rfId <= 31; rfId++)
6376 // according to Andy, Gary, David require.
6377 // the command RF shall read/write RF register directly for dubug.
6378 RT30xxReadRFRegister(pAdapter, rfId, ®RF);
6379 sprintf(msg+strlen(msg), "%03d = %02X\n", rfId, regRF);
6381 // Copy the information into the user buffer
6382 DBGPRINT(RT_DEBUG_TRACE, ("strlen(msg)=%d\n", (UINT32)strlen(msg)));
6383 wrq->u.data.length = strlen(msg);
6384 if (copy_to_user(wrq->u.data.pointer, msg, wrq->u.data.length))
6386 DBGPRINT(RT_DEBUG_TRACE, ("%s: copy_to_user() fail\n", __func__));
6391 if(strlen(msg) == 1)
6392 sprintf(msg+strlen(msg), "===>Error command format!");
6394 DBGPRINT(RT_DEBUG_TRACE, ("copy to user [msg=%s]\n", msg));
6395 // Copy the information into the user buffer
6396 DBGPRINT(RT_DEBUG_TRACE, ("strlen(msg) =%d\n", (UINT32)strlen(msg)));
6398 // Copy the information into the user buffer
6399 wrq->u.data.length = strlen(msg);
6400 Status = copy_to_user(wrq->u.data.pointer, msg, wrq->u.data.length);
6403 DBGPRINT(RT_DEBUG_TRACE, ("<==RTMPIoctlRF\n\n"));
6411 INT Set_TGnWifiTest_Proc(
6412 IN PRTMP_ADAPTER pAd,
6415 if (simple_strtol(arg, 0, 10) == 0)
6416 pAd->StaCfg.bTGnWifiTest = FALSE;
6418 pAd->StaCfg.bTGnWifiTest = TRUE;
6420 DBGPRINT(RT_DEBUG_TRACE, ("IF Set_TGnWifiTest_Proc::(bTGnWifiTest=%d)\n", pAd->StaCfg.bTGnWifiTest));
6424 INT Set_LongRetryLimit_Proc(
6425 IN PRTMP_ADAPTER pAdapter,
6428 TX_RTY_CFG_STRUC tx_rty_cfg;
6429 UCHAR LongRetryLimit = (UCHAR)simple_strtol(arg, 0, 10);
6431 RTMP_IO_READ32(pAdapter, TX_RTY_CFG, &tx_rty_cfg.word);
6432 tx_rty_cfg.field.LongRtyLimit = LongRetryLimit;
6433 RTMP_IO_WRITE32(pAdapter, TX_RTY_CFG, tx_rty_cfg.word);
6434 DBGPRINT(RT_DEBUG_TRACE, ("IF Set_LongRetryLimit_Proc::(tx_rty_cfg=0x%x)\n", tx_rty_cfg.word));
6438 INT Set_ShortRetryLimit_Proc(
6439 IN PRTMP_ADAPTER pAdapter,
6442 TX_RTY_CFG_STRUC tx_rty_cfg;
6443 UCHAR ShortRetryLimit = (UCHAR)simple_strtol(arg, 0, 10);
6445 RTMP_IO_READ32(pAdapter, TX_RTY_CFG, &tx_rty_cfg.word);
6446 tx_rty_cfg.field.ShortRtyLimit = ShortRetryLimit;
6447 RTMP_IO_WRITE32(pAdapter, TX_RTY_CFG, tx_rty_cfg.word);
6448 DBGPRINT(RT_DEBUG_TRACE, ("IF Set_ShortRetryLimit_Proc::(tx_rty_cfg=0x%x)\n", tx_rty_cfg.word));
6452 #if !defined(RT2860) && !defined(RT30xx)
6453 INT Show_Adhoc_MacTable_Proc(
6454 IN PRTMP_ADAPTER pAd,
6459 sprintf(extra, "\n");
6461 sprintf(extra + strlen(extra), "HT Operating Mode : %d\n", pAd->CommonCfg.AddHTInfo.AddHtInfo2.OperaionMode);
6463 sprintf(extra + strlen(extra), "\n%-19s%-4s%-4s%-7s%-7s%-7s%-10s%-6s%-6s%-6s%-6s\n",
6464 "MAC", "AID", "BSS", "RSSI0", "RSSI1", "RSSI2", "PhMd", "BW", "MCS", "SGI", "STBC");
6466 for (i=1; i<MAX_LEN_OF_MAC_TABLE; i++)
6468 PMAC_TABLE_ENTRY pEntry = &pAd->MacTab.Content[i];
6470 if (strlen(extra) > (IW_PRIV_SIZE_MASK - 30))
6472 if ((pEntry->ValidAsCLI || pEntry->ValidAsApCli) && (pEntry->Sst == SST_ASSOC))
6474 sprintf(extra + strlen(extra), "%02X:%02X:%02X:%02X:%02X:%02X ",
6475 pEntry->Addr[0], pEntry->Addr[1], pEntry->Addr[2],
6476 pEntry->Addr[3], pEntry->Addr[4], pEntry->Addr[5]);
6477 sprintf(extra + strlen(extra), "%-4d", (int)pEntry->Aid);
6478 sprintf(extra + strlen(extra), "%-4d", (int)pEntry->apidx);
6479 sprintf(extra + strlen(extra), "%-7d", pEntry->RssiSample.AvgRssi0);
6480 sprintf(extra + strlen(extra), "%-7d", pEntry->RssiSample.AvgRssi1);
6481 sprintf(extra + strlen(extra), "%-7d", pEntry->RssiSample.AvgRssi2);
6482 sprintf(extra + strlen(extra), "%-10s", GetPhyMode(pEntry->HTPhyMode.field.MODE));
6483 sprintf(extra + strlen(extra), "%-6s", GetBW(pEntry->HTPhyMode.field.BW));
6484 sprintf(extra + strlen(extra), "%-6d", pEntry->HTPhyMode.field.MCS);
6485 sprintf(extra + strlen(extra), "%-6d", pEntry->HTPhyMode.field.ShortGI);
6486 sprintf(extra + strlen(extra), "%-6d", pEntry->HTPhyMode.field.STBC);
6487 sprintf(extra + strlen(extra), "%-10d, %d, %d%%\n", pEntry->DebugFIFOCount, pEntry->DebugTxCount,
6488 (pEntry->DebugTxCount) ? ((pEntry->DebugTxCount-pEntry->DebugFIFOCount)*100/pEntry->DebugTxCount) : 0);
6489 sprintf(extra, "%s\n", extra);