2 *************************************************************************
4 * 5F., No.36, Taiyuan St., Jhubei City,
8 * (c) Copyright 2002-2007, Ralink Technology, Inc.
10 * This program is free software; you can redistribute it and/or modify *
11 * it under the terms of the GNU General Public License as published by *
12 * the Free Software Foundation; either version 2 of the License, or *
13 * (at your option) any later version. *
15 * This program is distributed in the hope that it will be useful, *
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
18 * GNU General Public License for more details. *
20 * You should have received a copy of the GNU General Public License *
21 * along with this program; if not, write to the *
22 * Free Software Foundation, Inc., *
23 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
25 *************************************************************************
31 IOCTL related subroutines
35 -------- ---------- ----------------------------------------------
36 Rory Chen 01-03-2003 created
37 Rory Chen 02-14-2005 modify to support RT61
40 #include "rt_config.h"
43 extern ULONG RTDebugLevel;
47 #define WEP_SMALL_KEY_LEN (40/8)
48 #define WEP_LARGE_KEY_LEN (104/8)
50 #define GROUP_KEY_NO 4
52 extern UCHAR CipherWpa2Template[];
53 extern UCHAR CipherWpaPskTkip[];
54 extern UCHAR CipherWpaPskTkipLen;
56 typedef struct PACKED _RT_VERSION_INFO{
62 UINT DriverBuildMonth;
64 } RT_VERSION_INFO, *PRT_VERSION_INFO;
66 struct iw_priv_args privtab[] = {
68 IW_PRIV_TYPE_CHAR | 1024, 0,
71 { RTPRIV_IOCTL_SHOW, 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK,
73 { RTPRIV_IOCTL_SHOW, IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK,
75 /* --- sub-ioctls definitions --- */
77 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "connStatus" },
79 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "driverVer" },
81 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "bainfo" },
83 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "descinfo" },
85 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "radio_off" },
87 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "radio_on" },
89 IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "show" },
90 /* --- sub-ioctls relations --- */
94 IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK,
97 IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | 1024,
100 IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | 1024,
104 { RTPRIV_IOCTL_STATISTICS,
105 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK,
107 { RTPRIV_IOCTL_GSITESURVEY,
108 0, IW_PRIV_TYPE_CHAR | 1024,
113 IN PRTMP_ADAPTER pAdapter,
117 INT Set_WmmCapable_Proc(
118 IN PRTMP_ADAPTER pAd,
122 INT Set_NetworkType_Proc(
123 IN PRTMP_ADAPTER pAdapter,
126 INT Set_AuthMode_Proc(
127 IN PRTMP_ADAPTER pAdapter,
130 INT Set_EncrypType_Proc(
131 IN PRTMP_ADAPTER pAdapter,
134 INT Set_DefaultKeyID_Proc(
135 IN PRTMP_ADAPTER pAdapter,
139 IN PRTMP_ADAPTER pAdapter,
143 IN PRTMP_ADAPTER pAdapter,
147 IN PRTMP_ADAPTER pAdapter,
151 IN PRTMP_ADAPTER pAdapter,
155 IN PRTMP_ADAPTER pAdapter,
160 IN PRTMP_ADAPTER pAdapter,
164 IN PRTMP_ADAPTER pAd,
169 IN PRTMP_ADAPTER pAdapter,
170 IN struct iwreq *wrq);
173 IN PRTMP_ADAPTER pAdapter,
174 IN struct iwreq *wrq);
176 VOID RTMPIoctlE2PROM(
177 IN PRTMP_ADAPTER pAdapter,
178 IN struct iwreq *wrq);
182 NDIS_STATUS RTMPWPANoneAddKeyProc(
183 IN PRTMP_ADAPTER pAd,
186 INT Set_FragTest_Proc(
187 IN PRTMP_ADAPTER pAdapter,
190 #ifdef DOT11_N_SUPPORT
191 INT Set_TGnWifiTest_Proc(
192 IN PRTMP_ADAPTER pAd,
194 #endif // DOT11_N_SUPPORT //
196 INT Set_LongRetryLimit_Proc(
197 IN PRTMP_ADAPTER pAdapter,
200 INT Set_ShortRetryLimit_Proc(
201 IN PRTMP_ADAPTER pAdapter,
206 INT (*set_proc)(PRTMP_ADAPTER pAdapter, PUCHAR arg);
207 } *PRTMP_PRIVATE_SET_PROC, RTMP_PRIVATE_SUPPORT_PROC[] = {
208 {"DriverVersion", Set_DriverVersion_Proc},
209 {"CountryRegion", Set_CountryRegion_Proc},
210 {"CountryRegionABand", Set_CountryRegionABand_Proc},
211 {"SSID", Set_SSID_Proc},
212 {"WirelessMode", Set_WirelessMode_Proc},
213 {"TxBurst", Set_TxBurst_Proc},
214 {"TxPreamble", Set_TxPreamble_Proc},
215 {"TxPower", Set_TxPower_Proc},
216 {"Channel", Set_Channel_Proc},
217 {"BGProtection", Set_BGProtection_Proc},
218 {"RTSThreshold", Set_RTSThreshold_Proc},
219 {"FragThreshold", Set_FragThreshold_Proc},
220 #ifdef DOT11_N_SUPPORT
221 {"HtBw", Set_HtBw_Proc},
222 {"HtMcs", Set_HtMcs_Proc},
223 {"HtGi", Set_HtGi_Proc},
224 {"HtOpMode", Set_HtOpMode_Proc},
225 {"HtExtcha", Set_HtExtcha_Proc},
226 {"HtMpduDensity", Set_HtMpduDensity_Proc},
227 {"HtBaWinSize", Set_HtBaWinSize_Proc},
228 {"HtRdg", Set_HtRdg_Proc},
229 {"HtAmsdu", Set_HtAmsdu_Proc},
230 {"HtAutoBa", Set_HtAutoBa_Proc},
231 {"HtBaDecline", Set_BADecline_Proc},
232 {"HtProtect", Set_HtProtect_Proc},
233 {"HtMimoPs", Set_HtMimoPs_Proc},
234 #endif // DOT11_N_SUPPORT //
236 #ifdef AGGREGATION_SUPPORT
237 {"PktAggregate", Set_PktAggregate_Proc},
241 {"WmmCapable", Set_WmmCapable_Proc},
243 {"IEEE80211H", Set_IEEE80211H_Proc},
244 {"NetworkType", Set_NetworkType_Proc},
245 {"AuthMode", Set_AuthMode_Proc},
246 {"EncrypType", Set_EncrypType_Proc},
247 {"DefaultKeyID", Set_DefaultKeyID_Proc},
248 {"Key1", Set_Key1_Proc},
249 {"Key2", Set_Key2_Proc},
250 {"Key3", Set_Key3_Proc},
251 {"Key4", Set_Key4_Proc},
252 {"WPAPSK", Set_WPAPSK_Proc},
253 {"ResetCounter", Set_ResetStatCounter_Proc},
254 {"PSMode", Set_PSMode_Proc},
256 {"Debug", Set_Debug_Proc},
258 {"WpaSupport", Set_Wpa_Support},
259 {"FixedTxMode", Set_FixedTxMode_Proc},
260 #ifdef DOT11_N_SUPPORT
261 {"TGnWifiTest", Set_TGnWifiTest_Proc},
262 {"ForceGF", Set_ForceGF_Proc},
263 #endif // DOT11_N_SUPPORT //
264 {"LongRetry", Set_LongRetryLimit_Proc},
265 {"ShortRetry", Set_ShortRetryLimit_Proc},
271 IN PRTMP_ADAPTER pAd,
272 IN PNDIS_802_11_KEY pKey)
275 MAC_TABLE_ENTRY *pEntry;
277 DBGPRINT(RT_DEBUG_TRACE, ("RTMPAddKey ------>\n"));
279 RTMP_CLEAR_PSFLAG(pAd, fRTMP_PS_CAN_GO_SLEEP);
280 if (RTMP_TEST_PSFLAG(pAd, fRTMP_PS_SET_PCI_CLK_OFF_COMMAND))
282 if (pAd->StaCfg.bRadio == FALSE)
284 RTMP_SET_PSFLAG(pAd, fRTMP_PS_CAN_GO_SLEEP);
287 DBGPRINT(RT_DEBUG_TRACE,("RTMPWPAAddKeyProc1==>\n"));
288 RTMPPCIeLinkCtrlValueRestore(pAd, RESTORE_HALT);
290 pAd->bPCIclkOff = FALSE;
293 if (pAd->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
295 if (pKey->KeyIndex & 0x80000000)
297 if (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPANone)
299 NdisZeroMemory(pAd->StaCfg.PMK, 32);
300 NdisMoveMemory(pAd->StaCfg.PMK, pKey->KeyMaterial, pKey->KeyLength);
304 NdisZeroMemory(&pAd->SharedKey[BSS0][0], sizeof(CIPHER_KEY));
305 pAd->SharedKey[BSS0][0].KeyLen = LEN_TKIP_EK;
306 NdisMoveMemory(pAd->SharedKey[BSS0][0].Key, pKey->KeyMaterial, LEN_TKIP_EK);
308 if (pAd->StaCfg.PairCipher == Ndis802_11Encryption2Enabled)
310 NdisMoveMemory(pAd->SharedKey[BSS0][0].RxMic, pKey->KeyMaterial + LEN_TKIP_EK, LEN_TKIP_TXMICK);
311 NdisMoveMemory(pAd->SharedKey[BSS0][0].TxMic, pKey->KeyMaterial + LEN_TKIP_EK + LEN_TKIP_TXMICK, LEN_TKIP_RXMICK);
315 NdisMoveMemory(pAd->SharedKey[BSS0][0].TxMic, pKey->KeyMaterial + LEN_TKIP_EK, LEN_TKIP_TXMICK);
316 NdisMoveMemory(pAd->SharedKey[BSS0][0].RxMic, pKey->KeyMaterial + LEN_TKIP_EK + LEN_TKIP_TXMICK, LEN_TKIP_RXMICK);
319 // Decide its ChiperAlg
320 if (pAd->StaCfg.PairCipher == Ndis802_11Encryption2Enabled)
321 pAd->SharedKey[BSS0][0].CipherAlg = CIPHER_TKIP;
322 else if (pAd->StaCfg.PairCipher == Ndis802_11Encryption3Enabled)
323 pAd->SharedKey[BSS0][0].CipherAlg = CIPHER_AES;
325 pAd->SharedKey[BSS0][0].CipherAlg = CIPHER_NONE;
327 // Update these related information to MAC_TABLE_ENTRY
328 pEntry = &pAd->MacTab.Content[BSSID_WCID];
329 NdisMoveMemory(pEntry->PairwiseKey.Key, pAd->SharedKey[BSS0][0].Key, LEN_TKIP_EK);
330 NdisMoveMemory(pEntry->PairwiseKey.RxMic, pAd->SharedKey[BSS0][0].RxMic, LEN_TKIP_RXMICK);
331 NdisMoveMemory(pEntry->PairwiseKey.TxMic, pAd->SharedKey[BSS0][0].TxMic, LEN_TKIP_TXMICK);
332 pEntry->PairwiseKey.CipherAlg = pAd->SharedKey[BSS0][0].CipherAlg;
334 // Update pairwise key information to ASIC Shared Key Table
335 AsicAddSharedKeyEntry(pAd,
338 pAd->SharedKey[BSS0][0].CipherAlg,
339 pAd->SharedKey[BSS0][0].Key,
340 pAd->SharedKey[BSS0][0].TxMic,
341 pAd->SharedKey[BSS0][0].RxMic);
343 // Update ASIC WCID attribute table and IVEIV table
344 RTMPAddWcidAttributeEntry(pAd,
347 pAd->SharedKey[BSS0][0].CipherAlg,
350 if (pAd->StaCfg.AuthMode >= Ndis802_11AuthModeWPA2)
352 // set 802.1x port control
353 STA_PORT_SECURED(pAd);
355 // Indicate Connected for GUI
356 pAd->IndicateMediaState = NdisMediaStateConnected;
362 pAd->StaCfg.DefaultKeyId = (pKey->KeyIndex & 0xFF);
363 NdisZeroMemory(&pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId], sizeof(CIPHER_KEY));
364 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].KeyLen = LEN_TKIP_EK;
365 NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].Key, pKey->KeyMaterial, LEN_TKIP_EK);
367 if (pAd->StaCfg.GroupCipher == Ndis802_11Encryption2Enabled)
369 NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].RxMic, pKey->KeyMaterial + LEN_TKIP_EK, LEN_TKIP_TXMICK);
370 NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].TxMic, pKey->KeyMaterial + LEN_TKIP_EK + LEN_TKIP_TXMICK, LEN_TKIP_RXMICK);
374 NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].TxMic, pKey->KeyMaterial + LEN_TKIP_EK, LEN_TKIP_TXMICK);
375 NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].RxMic, pKey->KeyMaterial + LEN_TKIP_EK + LEN_TKIP_TXMICK, LEN_TKIP_RXMICK);
378 // Update Shared Key CipherAlg
379 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg = CIPHER_NONE;
380 if (pAd->StaCfg.GroupCipher == Ndis802_11Encryption2Enabled)
381 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg = CIPHER_TKIP;
382 else if (pAd->StaCfg.GroupCipher == Ndis802_11Encryption3Enabled)
383 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg = CIPHER_AES;
385 // Update group key information to ASIC Shared Key Table
386 AsicAddSharedKeyEntry(pAd,
388 pAd->StaCfg.DefaultKeyId,
389 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg,
390 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].Key,
391 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].TxMic,
392 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].RxMic);
394 // Update ASIC WCID attribute table and IVEIV table
395 RTMPAddWcidAttributeEntry(pAd,
397 pAd->StaCfg.DefaultKeyId,
398 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg,
401 // set 802.1x port control
402 STA_PORT_SECURED(pAd);
404 // Indicate Connected for GUI
405 pAd->IndicateMediaState = NdisMediaStateConnected;
408 else // dynamic WEP from wpa_supplicant
413 if(pKey->KeyLength == 32)
416 KeyIdx = pKey->KeyIndex & 0x0fffffff;
420 // it is a default shared key, for Pairwise key setting
421 if (pKey->KeyIndex & 0x80000000)
423 pEntry = MacTableLookup(pAd, pKey->BSSID);
427 DBGPRINT(RT_DEBUG_TRACE, ("RTMPAddKey: Set Pair-wise Key\n"));
429 // set key material and key length
430 pEntry->PairwiseKey.KeyLen = (UCHAR)pKey->KeyLength;
431 NdisMoveMemory(pEntry->PairwiseKey.Key, &pKey->KeyMaterial, pKey->KeyLength);
434 if (pKey->KeyLength == 5)
435 pEntry->PairwiseKey.CipherAlg = CIPHER_WEP64;
437 pEntry->PairwiseKey.CipherAlg = CIPHER_WEP128;
439 // Add Pair-wise key to Asic
440 AsicAddPairwiseKeyEntry(
444 &pEntry->PairwiseKey);
446 // update WCID attribute table and IVEIV table for this entry
447 RTMPAddWcidAttributeEntry(
450 KeyIdx, // The value may be not zero
451 pEntry->PairwiseKey.CipherAlg,
458 // Default key for tx (shared key)
459 pAd->StaCfg.DefaultKeyId = (UCHAR) KeyIdx;
461 // set key material and key length
462 pAd->SharedKey[BSS0][KeyIdx].KeyLen = (UCHAR) pKey->KeyLength;
463 NdisMoveMemory(pAd->SharedKey[BSS0][KeyIdx].Key, &pKey->KeyMaterial, pKey->KeyLength);
466 if (pKey->KeyLength == 5)
467 pAd->SharedKey[BSS0][KeyIdx].CipherAlg = CIPHER_WEP64;
469 pAd->SharedKey[BSS0][KeyIdx].CipherAlg = CIPHER_WEP128;
471 CipherAlg = pAd->SharedKey[BSS0][KeyIdx].CipherAlg;
472 Key = pAd->SharedKey[BSS0][KeyIdx].Key;
474 // Set Group key material to Asic
475 AsicAddSharedKeyEntry(pAd, BSS0, KeyIdx, CipherAlg, Key, NULL, NULL);
477 // Update WCID attribute table and IVEIV table for this group key table
478 RTMPAddWcidAttributeEntry(pAd, BSS0, KeyIdx, CipherAlg, NULL);
484 RTMP_SET_PSFLAG(pAd, fRTMP_PS_CAN_GO_SLEEP);
485 DBGPRINT(RT_DEBUG_INFO, ("<------ RTMPAddKey\n"));
489 char * rtstrchr(const char * s, int c)
491 for(; *s != (char) c; ++s)
498 This is required for LinEX2004/kernel2.6.7 to provide iwlist scanning function
502 rt_ioctl_giwname(struct net_device *dev,
503 struct iw_request_info *info,
504 char *name, char *extra)
506 // PRTMP_ADAPTER pAdapter = dev->ml_priv;
508 strncpy(name, "RT2860 Wireless", IFNAMSIZ);
512 int rt_ioctl_siwfreq(struct net_device *dev,
513 struct iw_request_info *info,
514 struct iw_freq *freq, char *extra)
516 PRTMP_ADAPTER pAdapter = dev->ml_priv;
519 //check if the interface is down
520 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
522 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
530 if((freq->e == 0) && (freq->m <= 1000))
531 chan = freq->m; // Setting by channel number
533 MAP_KHZ_TO_CHANNEL_ID( (freq->m /100) , chan); // Setting by frequency - search the table , like 2.412G, 2.422G,
535 if (ChannelSanity(pAdapter, chan) == TRUE)
537 pAdapter->CommonCfg.Channel = chan;
538 DBGPRINT(RT_DEBUG_ERROR, ("==>rt_ioctl_siwfreq::SIOCSIWFREQ[cmd=0x%x] (Channel=%d)\n", SIOCSIWFREQ, pAdapter->CommonCfg.Channel));
545 int rt_ioctl_giwfreq(struct net_device *dev,
546 struct iw_request_info *info,
547 struct iw_freq *freq, char *extra)
549 VIRTUAL_ADAPTER *pVirtualAd = NULL;
550 PRTMP_ADAPTER pAdapter = NULL;
554 if (dev->priv_flags == INT_MAIN)
556 pAdapter = dev->ml_priv;
560 pVirtualAd = dev->ml_priv;
561 if (pVirtualAd && pVirtualAd->RtmpDev)
562 pAdapter = pVirtualAd->RtmpDev->ml_priv;
565 if (pAdapter == NULL)
567 /* if 1st open fail, pAd will be free;
568 So the net_dev->ml_priv will be NULL in 2rd open */
572 ch = pAdapter->CommonCfg.Channel;
574 DBGPRINT(RT_DEBUG_TRACE,("==>rt_ioctl_giwfreq %d\n", ch));
576 MAP_CHANNEL_ID_TO_KHZ(ch, m);
582 int rt_ioctl_siwmode(struct net_device *dev,
583 struct iw_request_info *info,
584 __u32 *mode, char *extra)
586 PRTMP_ADAPTER pAdapter = dev->ml_priv;
588 //check if the interface is down
589 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
591 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
598 Set_NetworkType_Proc(pAdapter, "Adhoc");
601 Set_NetworkType_Proc(pAdapter, "Infra");
603 case IW_MODE_MONITOR:
604 Set_NetworkType_Proc(pAdapter, "Monitor");
607 DBGPRINT(RT_DEBUG_TRACE, ("===>rt_ioctl_siwmode::SIOCSIWMODE (unknown %d)\n", *mode));
611 // Reset Ralink supplicant to not use, it will be set to start when UI set PMK key
612 pAdapter->StaCfg.WpaState = SS_NOTUSE;
617 int rt_ioctl_giwmode(struct net_device *dev,
618 struct iw_request_info *info,
619 __u32 *mode, char *extra)
621 PRTMP_ADAPTER pAdapter = NULL;
622 VIRTUAL_ADAPTER *pVirtualAd = NULL;
624 if (dev->priv_flags == INT_MAIN)
626 pAdapter = dev->ml_priv;
630 pVirtualAd = dev->ml_priv;
631 if (pVirtualAd && pVirtualAd->RtmpDev)
632 pAdapter = pVirtualAd->RtmpDev->ml_priv;
635 if (pAdapter == NULL)
637 /* if 1st open fail, pAd will be free;
638 So the net_dev->ml_priv will be NULL in 2rd open */
642 if (ADHOC_ON(pAdapter))
643 *mode = IW_MODE_ADHOC;
644 else if (INFRA_ON(pAdapter))
645 *mode = IW_MODE_INFRA;
646 else if (MONITOR_ON(pAdapter))
648 *mode = IW_MODE_MONITOR;
651 *mode = IW_MODE_AUTO;
653 DBGPRINT(RT_DEBUG_TRACE, ("==>rt_ioctl_giwmode(mode=%d)\n", *mode));
657 int rt_ioctl_siwsens(struct net_device *dev,
658 struct iw_request_info *info,
659 char *name, char *extra)
661 PRTMP_ADAPTER pAdapter = dev->ml_priv;
663 //check if the interface is down
664 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
666 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
673 int rt_ioctl_giwsens(struct net_device *dev,
674 struct iw_request_info *info,
675 char *name, char *extra)
680 int rt_ioctl_giwrange(struct net_device *dev,
681 struct iw_request_info *info,
682 struct iw_point *data, char *extra)
684 PRTMP_ADAPTER pAdapter = NULL;
685 VIRTUAL_ADAPTER *pVirtualAd = NULL;
686 struct iw_range *range = (struct iw_range *) extra;
690 if (dev->priv_flags == INT_MAIN)
692 pAdapter = dev->ml_priv;
696 pVirtualAd = dev->ml_priv;
697 if (pVirtualAd && pVirtualAd->RtmpDev)
698 pAdapter = pVirtualAd->RtmpDev->ml_priv;
701 if (pAdapter == NULL)
703 /* if 1st open fail, pAd will be free;
704 So the net_dev->ml_priv will be NULL in 2rd open */
708 DBGPRINT(RT_DEBUG_TRACE ,("===>rt_ioctl_giwrange\n"));
709 data->length = sizeof(struct iw_range);
710 memset(range, 0, sizeof(struct iw_range));
712 range->txpower_capa = IW_TXPOW_DBM;
714 if (INFRA_ON(pAdapter)||ADHOC_ON(pAdapter))
716 range->min_pmp = 1 * 1024;
717 range->max_pmp = 65535 * 1024;
718 range->min_pmt = 1 * 1024;
719 range->max_pmt = 1000 * 1024;
720 range->pmp_flags = IW_POWER_PERIOD;
721 range->pmt_flags = IW_POWER_TIMEOUT;
722 range->pm_capa = IW_POWER_PERIOD | IW_POWER_TIMEOUT |
723 IW_POWER_UNICAST_R | IW_POWER_ALL_R;
726 range->we_version_compiled = WIRELESS_EXT;
727 range->we_version_source = 14;
729 range->retry_capa = IW_RETRY_LIMIT;
730 range->retry_flags = IW_RETRY_LIMIT;
731 range->min_retry = 0;
732 range->max_retry = 255;
734 range->num_channels = pAdapter->ChannelListNum;
737 for (i = 1; i <= range->num_channels; i++)
740 range->freq[val].i = pAdapter->ChannelList[i-1].Channel;
741 MAP_CHANNEL_ID_TO_KHZ(pAdapter->ChannelList[i-1].Channel, m);
742 range->freq[val].m = m * 100; /* HZ */
744 range->freq[val].e = 1;
746 if (val == IW_MAX_FREQUENCIES)
749 range->num_frequency = val;
751 range->max_qual.qual = 100; /* what is correct max? This was not
752 * documented exactly. At least
753 * 69 has been observed. */
754 range->max_qual.level = 0; /* dB */
755 range->max_qual.noise = 0; /* dB */
757 /* What would be suitable values for "average/typical" qual? */
758 range->avg_qual.qual = 20;
759 range->avg_qual.level = -60;
760 range->avg_qual.noise = -95;
761 range->sensitivity = 3;
763 range->max_encoding_tokens = NR_WEP_KEYS;
764 range->num_encoding_sizes = 2;
765 range->encoding_size[0] = 5;
766 range->encoding_size[1] = 13;
769 range->max_rts = 2347;
770 range->min_frag = 256;
771 range->max_frag = 2346;
773 #if WIRELESS_EXT > 17
774 /* IW_ENC_CAPA_* bit field */
775 range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 |
776 IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP;
782 int rt_ioctl_siwap(struct net_device *dev,
783 struct iw_request_info *info,
784 struct sockaddr *ap_addr, char *extra)
786 PRTMP_ADAPTER pAdapter = dev->ml_priv;
787 NDIS_802_11_MAC_ADDRESS Bssid;
789 //check if the interface is down
790 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
792 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
796 if (pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE)
798 RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
799 DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
802 // tell CNTL state machine to call NdisMSetInformationComplete() after completing
803 // this request, because this request is initiated by NDIS.
804 pAdapter->MlmeAux.CurrReqIsFromNdis = FALSE;
805 // Prevent to connect AP again in STAMlmePeriodicExec
806 pAdapter->MlmeAux.AutoReconnectSsidLen= 32;
808 memset(Bssid, 0, MAC_ADDR_LEN);
809 memcpy(Bssid, ap_addr->sa_data, MAC_ADDR_LEN);
810 MlmeEnqueue(pAdapter,
811 MLME_CNTL_STATE_MACHINE,
813 sizeof(NDIS_802_11_MAC_ADDRESS),
816 DBGPRINT(RT_DEBUG_TRACE, ("IOCTL::SIOCSIWAP %02x:%02x:%02x:%02x:%02x:%02x\n",
817 Bssid[0], Bssid[1], Bssid[2], Bssid[3], Bssid[4], Bssid[5]));
822 int rt_ioctl_giwap(struct net_device *dev,
823 struct iw_request_info *info,
824 struct sockaddr *ap_addr, char *extra)
826 PRTMP_ADAPTER pAdapter = NULL;
827 VIRTUAL_ADAPTER *pVirtualAd = NULL;
829 if (dev->priv_flags == INT_MAIN)
831 pAdapter = dev->ml_priv;
835 pVirtualAd = dev->ml_priv;
836 if (pVirtualAd && pVirtualAd->RtmpDev)
837 pAdapter = pVirtualAd->RtmpDev->ml_priv;
840 if (pAdapter == NULL)
842 /* if 1st open fail, pAd will be free;
843 So the net_dev->ml_priv will be NULL in 2rd open */
847 if (INFRA_ON(pAdapter) || ADHOC_ON(pAdapter))
849 ap_addr->sa_family = ARPHRD_ETHER;
850 memcpy(ap_addr->sa_data, &pAdapter->CommonCfg.Bssid, ETH_ALEN);
853 else if (pAdapter->StaCfg.WpaSupplicantUP != WPA_SUPPLICANT_DISABLE)
855 ap_addr->sa_family = ARPHRD_ETHER;
856 memcpy(ap_addr->sa_data, &pAdapter->MlmeAux.Bssid, ETH_ALEN);
860 DBGPRINT(RT_DEBUG_TRACE, ("IOCTL::SIOCGIWAP(=EMPTY)\n"));
868 * Units are in db above the noise floor. That means the
869 * rssi values reported in the tx/rx descriptors in the
870 * driver are the SNR expressed in db.
872 * If you assume that the noise floor is -95, which is an
873 * excellent assumption 99.5 % of the time, then you can
874 * derive the absolute signal level (i.e. -95 + rssi).
875 * There are some other slight factors to take into account
876 * depending on whether the rssi measurement is from 11b,
877 * 11g, or 11a. These differences are at most 2db and
880 * NB: various calculations are based on the orinoco/wavelan
881 * drivers for compatibility
883 static void set_quality(PRTMP_ADAPTER pAdapter,
884 struct iw_quality *iq,
891 ChannelQuality = 100;
892 else if (rssi >= -80) // between -50 ~ -80dbm
893 ChannelQuality = (__u8)(24 + ((rssi + 80) * 26)/10);
894 else if (rssi >= -90) // between -80 ~ -90dbm
895 ChannelQuality = (__u8)((rssi + 90) * 26)/10;
899 iq->qual = (__u8)ChannelQuality;
901 iq->level = (__u8)(rssi);
902 iq->noise = (pAdapter->BbpWriteLatch[66] > pAdapter->BbpTuning.FalseCcaUpperThreshold) ? ((__u8)pAdapter->BbpTuning.FalseCcaUpperThreshold) : ((__u8) pAdapter->BbpWriteLatch[66]); // noise level (dBm)
903 iq->noise += 256 - 143;
904 iq->updated = pAdapter->iw_stats.qual.updated;
907 int rt_ioctl_iwaplist(struct net_device *dev,
908 struct iw_request_info *info,
909 struct iw_point *data, char *extra)
911 PRTMP_ADAPTER pAdapter = dev->ml_priv;
913 struct sockaddr addr[IW_MAX_AP];
914 struct iw_quality qual[IW_MAX_AP];
917 //check if the interface is down
918 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
920 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
926 for (i = 0; i <IW_MAX_AP ; i++)
928 if (i >= pAdapter->ScanTab.BssNr)
930 addr[i].sa_family = ARPHRD_ETHER;
931 memcpy(addr[i].sa_data, &pAdapter->ScanTab.BssEntry[i].Bssid, MAC_ADDR_LEN);
932 set_quality(pAdapter, &qual[i], pAdapter->ScanTab.BssEntry[i].Rssi);
935 memcpy(extra, &addr, i*sizeof(addr[0]));
936 data->flags = 1; /* signal quality present (sort of) */
937 memcpy(extra + i*sizeof(addr[0]), &qual, i*sizeof(qual[i]));
943 int rt_ioctl_siwscan(struct net_device *dev,
944 struct iw_request_info *info,
945 struct iw_point *data, char *extra)
947 PRTMP_ADAPTER pAdapter = dev->ml_priv;
950 int Status = NDIS_STATUS_SUCCESS;
952 //check if the interface is down
953 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
955 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
959 if (MONITOR_ON(pAdapter))
961 DBGPRINT(RT_DEBUG_TRACE, ("!!! Driver is in Monitor Mode now !!!\n"));
965 if ((pAdapter->OpMode == OPMODE_STA) && (IDLE_ON(pAdapter))
966 && (pAdapter->StaCfg.bRadio == TRUE)
967 && (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_IDLE_RADIO_OFF)))
969 RT28xxPciAsicRadioOn(pAdapter, GUI_IDLE_POWER_SAVE);
971 // Check if still radio off.
972 else if (pAdapter->bPCIclkOff == TRUE)
975 if (pAdapter->StaCfg.WpaSupplicantUP == WPA_SUPPLICANT_ENABLE)
977 pAdapter->StaCfg.WpaSupplicantScanCount++;
980 pAdapter->StaCfg.bScanReqIsFromWebUI = TRUE;
981 if (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
986 if ((pAdapter->StaCfg.WpaSupplicantUP == WPA_SUPPLICANT_ENABLE) &&
987 (pAdapter->StaCfg.WpaSupplicantScanCount > 3))
989 DBGPRINT(RT_DEBUG_TRACE, ("!!! WpaSupplicantScanCount > 3\n"));
990 Status = NDIS_STATUS_SUCCESS;
994 if ((OPSTATUS_TEST_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED)) &&
995 ((pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA) ||
996 (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK)) &&
997 (pAdapter->StaCfg.PortSecured == WPA_802_1X_PORT_NOT_SECURED))
999 DBGPRINT(RT_DEBUG_TRACE, ("!!! Link UP, Port Not Secured! ignore this set::OID_802_11_BSSID_LIST_SCAN\n"));
1000 Status = NDIS_STATUS_SUCCESS;
1004 if (pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE)
1006 RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
1007 DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
1010 // tell CNTL state machine to call NdisMSetInformationComplete() after completing
1011 // this request, because this request is initiated by NDIS.
1012 pAdapter->MlmeAux.CurrReqIsFromNdis = FALSE;
1013 // Reset allowed scan retries
1014 pAdapter->StaCfg.ScanCnt = 0;
1015 pAdapter->StaCfg.LastScanTime = Now;
1017 MlmeEnqueue(pAdapter,
1018 MLME_CNTL_STATE_MACHINE,
1019 OID_802_11_BSSID_LIST_SCAN,
1023 Status = NDIS_STATUS_SUCCESS;
1024 RT28XX_MLME_HANDLER(pAdapter);
1029 int rt_ioctl_giwscan(struct net_device *dev,
1030 struct iw_request_info *info,
1031 struct iw_point *data, char *extra)
1034 PRTMP_ADAPTER pAdapter = dev->ml_priv;
1036 char *current_ev = extra, *previous_ev = extra;
1038 char *current_val, custom[MAX_CUSTOM_LEN] = {0};
1041 #endif // IWEVGENIE //
1042 struct iw_event iwe;
1044 if (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
1047 * Still scanning, indicate the caller should try again.
1052 if (pAdapter->StaCfg.WpaSupplicantUP == WPA_SUPPLICANT_ENABLE)
1054 pAdapter->StaCfg.WpaSupplicantScanCount = 0;
1057 if (pAdapter->ScanTab.BssNr == 0)
1063 #if WIRELESS_EXT >= 17
1064 if (data->length > 0)
1065 end_buf = extra + data->length;
1067 end_buf = extra + IW_SCAN_MAX_DATA;
1069 end_buf = extra + IW_SCAN_MAX_DATA;
1072 for (i = 0; i < pAdapter->ScanTab.BssNr; i++)
1074 if (current_ev >= end_buf)
1076 #if WIRELESS_EXT >= 17
1084 //================================
1085 memset(&iwe, 0, sizeof(iwe));
1086 iwe.cmd = SIOCGIWAP;
1087 iwe.u.ap_addr.sa_family = ARPHRD_ETHER;
1088 memcpy(iwe.u.ap_addr.sa_data, &pAdapter->ScanTab.BssEntry[i].Bssid, ETH_ALEN);
1090 previous_ev = current_ev;
1091 current_ev = iwe_stream_add_event(info, current_ev,end_buf, &iwe, IW_EV_ADDR_LEN);
1092 if (current_ev == previous_ev)
1093 #if WIRELESS_EXT >= 17
1100 //================================
1101 memset(&iwe, 0, sizeof(iwe));
1102 iwe.cmd = SIOCGIWESSID;
1103 iwe.u.data.length = pAdapter->ScanTab.BssEntry[i].SsidLen;
1104 iwe.u.data.flags = 1;
1106 previous_ev = current_ev;
1107 current_ev = iwe_stream_add_point(info, current_ev,end_buf, &iwe, pAdapter->ScanTab.BssEntry[i].Ssid);
1108 if (current_ev == previous_ev)
1109 #if WIRELESS_EXT >= 17
1116 //================================
1117 memset(&iwe, 0, sizeof(iwe));
1118 iwe.cmd = SIOCGIWMODE;
1119 if (pAdapter->ScanTab.BssEntry[i].BssType == Ndis802_11IBSS)
1121 iwe.u.mode = IW_MODE_ADHOC;
1123 else if (pAdapter->ScanTab.BssEntry[i].BssType == Ndis802_11Infrastructure)
1125 iwe.u.mode = IW_MODE_INFRA;
1129 iwe.u.mode = IW_MODE_AUTO;
1131 iwe.len = IW_EV_UINT_LEN;
1133 previous_ev = current_ev;
1134 current_ev = iwe_stream_add_event(info, current_ev, end_buf, &iwe, IW_EV_UINT_LEN);
1135 if (current_ev == previous_ev)
1136 #if WIRELESS_EXT >= 17
1142 //Channel and Frequency
1143 //================================
1144 memset(&iwe, 0, sizeof(iwe));
1145 iwe.cmd = SIOCGIWFREQ;
1146 if (INFRA_ON(pAdapter) || ADHOC_ON(pAdapter))
1147 iwe.u.freq.m = pAdapter->ScanTab.BssEntry[i].Channel;
1149 iwe.u.freq.m = pAdapter->ScanTab.BssEntry[i].Channel;
1153 previous_ev = current_ev;
1154 current_ev = iwe_stream_add_event(info, current_ev, end_buf, &iwe, IW_EV_FREQ_LEN);
1155 if (current_ev == previous_ev)
1156 #if WIRELESS_EXT >= 17
1162 //Add quality statistics
1163 //================================
1164 memset(&iwe, 0, sizeof(iwe));
1166 iwe.u.qual.level = 0;
1167 iwe.u.qual.noise = 0;
1168 set_quality(pAdapter, &iwe.u.qual, pAdapter->ScanTab.BssEntry[i].Rssi);
1169 current_ev = iwe_stream_add_event(info, current_ev, end_buf, &iwe, IW_EV_QUAL_LEN);
1170 if (current_ev == previous_ev)
1171 #if WIRELESS_EXT >= 17
1178 //================================
1179 memset(&iwe, 0, sizeof(iwe));
1180 iwe.cmd = SIOCGIWENCODE;
1181 if (CAP_IS_PRIVACY_ON (pAdapter->ScanTab.BssEntry[i].CapabilityInfo ))
1182 iwe.u.data.flags =IW_ENCODE_ENABLED | IW_ENCODE_NOKEY;
1184 iwe.u.data.flags = IW_ENCODE_DISABLED;
1186 previous_ev = current_ev;
1187 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);
1188 if (current_ev == previous_ev)
1189 #if WIRELESS_EXT >= 17
1196 //================================
1197 if (pAdapter->ScanTab.BssEntry[i].SupRateLen)
1199 UCHAR tmpRate = pAdapter->ScanTab.BssEntry[i].SupRate[pAdapter->ScanTab.BssEntry[i].SupRateLen-1];
1200 memset(&iwe, 0, sizeof(iwe));
1201 iwe.cmd = SIOCGIWRATE;
1202 current_val = current_ev + IW_EV_LCP_LEN;
1203 if (tmpRate == 0x82)
1204 iwe.u.bitrate.value = 1 * 1000000;
1205 else if (tmpRate == 0x84)
1206 iwe.u.bitrate.value = 2 * 1000000;
1207 else if (tmpRate == 0x8B)
1208 iwe.u.bitrate.value = 5.5 * 1000000;
1209 else if (tmpRate == 0x96)
1210 iwe.u.bitrate.value = 11 * 1000000;
1212 iwe.u.bitrate.value = (tmpRate/2) * 1000000;
1214 iwe.u.bitrate.disabled = 0;
1215 current_val = iwe_stream_add_value(info, current_ev,
1216 current_val, end_buf, &iwe,
1219 if((current_val-current_ev)>IW_EV_LCP_LEN)
1220 current_ev = current_val;
1222 #if WIRELESS_EXT >= 17
1231 if (pAdapter->ScanTab.BssEntry[i].WpaIE.IELen > 0)
1233 memset(&iwe, 0, sizeof(iwe));
1234 memset(&custom[0], 0, MAX_CUSTOM_LEN);
1235 memcpy(custom, &(pAdapter->ScanTab.BssEntry[i].WpaIE.IE[0]),
1236 pAdapter->ScanTab.BssEntry[i].WpaIE.IELen);
1237 iwe.cmd = IWEVGENIE;
1238 iwe.u.data.length = pAdapter->ScanTab.BssEntry[i].WpaIE.IELen;
1239 current_ev = iwe_stream_add_point(info, current_ev, end_buf, &iwe, custom);
1240 if (current_ev == previous_ev)
1241 #if WIRELESS_EXT >= 17
1249 if (pAdapter->ScanTab.BssEntry[i].RsnIE.IELen > 0)
1251 memset(&iwe, 0, sizeof(iwe));
1252 memset(&custom[0], 0, MAX_CUSTOM_LEN);
1253 memcpy(custom, &(pAdapter->ScanTab.BssEntry[i].RsnIE.IE[0]),
1254 pAdapter->ScanTab.BssEntry[i].RsnIE.IELen);
1255 iwe.cmd = IWEVGENIE;
1256 iwe.u.data.length = pAdapter->ScanTab.BssEntry[i].RsnIE.IELen;
1257 current_ev = iwe_stream_add_point(info, current_ev, end_buf, &iwe, custom);
1258 if (current_ev == previous_ev)
1259 #if WIRELESS_EXT >= 17
1267 //================================
1268 if (pAdapter->ScanTab.BssEntry[i].WpaIE.IELen > 0)
1270 NdisZeroMemory(&iwe, sizeof(iwe));
1271 memset(&custom[0], 0, MAX_CUSTOM_LEN);
1272 iwe.cmd = IWEVCUSTOM;
1273 iwe.u.data.length = (pAdapter->ScanTab.BssEntry[i].WpaIE.IELen * 2) + 7;
1274 NdisMoveMemory(custom, "wpa_ie=", 7);
1275 for (idx = 0; idx < pAdapter->ScanTab.BssEntry[i].WpaIE.IELen; idx++)
1276 sprintf(custom + strlen(custom), "%02x", pAdapter->ScanTab.BssEntry[i].WpaIE.IE[idx]);
1277 previous_ev = current_ev;
1278 current_ev = iwe_stream_add_point(current_ev, end_buf, &iwe, custom);
1279 if (current_ev == previous_ev)
1280 #if WIRELESS_EXT >= 17
1288 if (pAdapter->ScanTab.BssEntry[i].RsnIE.IELen > 0)
1290 NdisZeroMemory(&iwe, sizeof(iwe));
1291 memset(&custom[0], 0, MAX_CUSTOM_LEN);
1292 iwe.cmd = IWEVCUSTOM;
1293 iwe.u.data.length = (pAdapter->ScanTab.BssEntry[i].RsnIE.IELen * 2) + 7;
1294 NdisMoveMemory(custom, "rsn_ie=", 7);
1295 for (idx = 0; idx < pAdapter->ScanTab.BssEntry[i].RsnIE.IELen; idx++)
1296 sprintf(custom + strlen(custom), "%02x", pAdapter->ScanTab.BssEntry[i].RsnIE.IE[idx]);
1297 previous_ev = current_ev;
1298 current_ev = iwe_stream_add_point(current_ev, end_buf, &iwe, custom);
1299 if (current_ev == previous_ev)
1300 #if WIRELESS_EXT >= 17
1306 #endif // IWEVGENIE //
1309 data->length = current_ev - extra;
1310 pAdapter->StaCfg.bScanReqIsFromWebUI = FALSE;
1311 DBGPRINT(RT_DEBUG_ERROR ,("===>rt_ioctl_giwscan. %d(%d) BSS returned, data->length = %d\n",i , pAdapter->ScanTab.BssNr, data->length));
1316 int rt_ioctl_siwessid(struct net_device *dev,
1317 struct iw_request_info *info,
1318 struct iw_point *data, char *essid)
1320 PRTMP_ADAPTER pAdapter = dev->ml_priv;
1322 //check if the interface is down
1323 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1325 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1331 PCHAR pSsidString = NULL;
1333 // Includes null character.
1334 if (data->length > (IW_ESSID_MAX_SIZE + 1))
1337 pSsidString = (CHAR *) kmalloc(MAX_LEN_OF_SSID+1, MEM_ALLOC_FLAG);
1340 NdisZeroMemory(pSsidString, MAX_LEN_OF_SSID+1);
1341 NdisMoveMemory(pSsidString, essid, data->length);
1342 if (Set_SSID_Proc(pAdapter, pSsidString) == FALSE)
1351 if (Set_SSID_Proc(pAdapter, "") == FALSE)
1357 int rt_ioctl_giwessid(struct net_device *dev,
1358 struct iw_request_info *info,
1359 struct iw_point *data, char *essid)
1361 PRTMP_ADAPTER pAdapter = NULL;
1362 VIRTUAL_ADAPTER *pVirtualAd = NULL;
1364 if (dev->priv_flags == INT_MAIN)
1366 pAdapter = dev->ml_priv;
1370 pVirtualAd = dev->ml_priv;
1371 if (pVirtualAd && pVirtualAd->RtmpDev)
1372 pAdapter = pVirtualAd->RtmpDev->ml_priv;
1375 if (pAdapter == NULL)
1377 /* if 1st open fail, pAd will be free;
1378 So the net_dev->ml_priv will be NULL in 2rd open */
1383 if (MONITOR_ON(pAdapter))
1389 if (OPSTATUS_TEST_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED))
1391 DBGPRINT(RT_DEBUG_TRACE ,("MediaState is connected\n"));
1392 data->length = pAdapter->CommonCfg.SsidLen;
1393 memcpy(essid, pAdapter->CommonCfg.Ssid, pAdapter->CommonCfg.SsidLen);
1396 {//the ANY ssid was specified
1398 DBGPRINT(RT_DEBUG_TRACE ,("MediaState is not connected, ess\n"));
1405 int rt_ioctl_siwnickn(struct net_device *dev,
1406 struct iw_request_info *info,
1407 struct iw_point *data, char *nickname)
1409 PRTMP_ADAPTER pAdapter = dev->ml_priv;
1411 //check if the interface is down
1412 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1414 DBGPRINT(RT_DEBUG_TRACE ,("INFO::Network is down!\n"));
1418 if (data->length > IW_ESSID_MAX_SIZE)
1421 memset(pAdapter->nickname, 0, IW_ESSID_MAX_SIZE + 1);
1422 memcpy(pAdapter->nickname, nickname, data->length);
1428 int rt_ioctl_giwnickn(struct net_device *dev,
1429 struct iw_request_info *info,
1430 struct iw_point *data, char *nickname)
1432 PRTMP_ADAPTER pAdapter = NULL;
1433 VIRTUAL_ADAPTER *pVirtualAd = NULL;
1435 if (dev->priv_flags == INT_MAIN)
1437 pAdapter = dev->ml_priv;
1441 pVirtualAd = dev->ml_priv;
1442 if (pVirtualAd && pVirtualAd->RtmpDev)
1443 pAdapter = pVirtualAd->RtmpDev->ml_priv;
1446 if (pAdapter == NULL)
1448 /* if 1st open fail, pAd will be free;
1449 So the net_dev->ml_priv will be NULL in 2rd open */
1453 if (data->length > strlen(pAdapter->nickname) + 1)
1454 data->length = strlen(pAdapter->nickname) + 1;
1455 if (data->length > 0) {
1456 memcpy(nickname, pAdapter->nickname, data->length-1);
1457 nickname[data->length-1] = '\0';
1462 int rt_ioctl_siwrts(struct net_device *dev,
1463 struct iw_request_info *info,
1464 struct iw_param *rts, char *extra)
1466 PRTMP_ADAPTER pAdapter = dev->ml_priv;
1469 //check if the interface is down
1470 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1472 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1477 val = MAX_RTS_THRESHOLD;
1478 else if (rts->value < 0 || rts->value > MAX_RTS_THRESHOLD)
1480 else if (rts->value == 0)
1481 val = MAX_RTS_THRESHOLD;
1485 if (val != pAdapter->CommonCfg.RtsThreshold)
1486 pAdapter->CommonCfg.RtsThreshold = val;
1491 int rt_ioctl_giwrts(struct net_device *dev,
1492 struct iw_request_info *info,
1493 struct iw_param *rts, char *extra)
1495 PRTMP_ADAPTER pAdapter = NULL;
1496 VIRTUAL_ADAPTER *pVirtualAd = NULL;
1498 if (dev->priv_flags == INT_MAIN)
1500 pAdapter = dev->ml_priv;
1504 pVirtualAd = dev->ml_priv;
1505 if (pVirtualAd && pVirtualAd->RtmpDev)
1506 pAdapter = pVirtualAd->RtmpDev->ml_priv;
1509 if (pAdapter == NULL)
1511 /* if 1st open fail, pAd will be free;
1512 So the net_dev->ml_priv will be NULL in 2rd open */
1516 //check if the interface is down
1517 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1519 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1523 rts->value = pAdapter->CommonCfg.RtsThreshold;
1524 rts->disabled = (rts->value == MAX_RTS_THRESHOLD);
1530 int rt_ioctl_siwfrag(struct net_device *dev,
1531 struct iw_request_info *info,
1532 struct iw_param *frag, char *extra)
1534 PRTMP_ADAPTER pAdapter = dev->ml_priv;
1537 //check if the interface is down
1538 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1540 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1545 val = MAX_FRAG_THRESHOLD;
1546 else if (frag->value >= MIN_FRAG_THRESHOLD || frag->value <= MAX_FRAG_THRESHOLD)
1547 val = __cpu_to_le16(frag->value & ~0x1); /* even numbers only */
1548 else if (frag->value == 0)
1549 val = MAX_FRAG_THRESHOLD;
1553 pAdapter->CommonCfg.FragmentThreshold = val;
1557 int rt_ioctl_giwfrag(struct net_device *dev,
1558 struct iw_request_info *info,
1559 struct iw_param *frag, char *extra)
1561 PRTMP_ADAPTER pAdapter = NULL;
1562 VIRTUAL_ADAPTER *pVirtualAd = NULL;
1564 if (dev->priv_flags == INT_MAIN)
1566 pAdapter = dev->ml_priv;
1570 pVirtualAd = dev->ml_priv;
1571 if (pVirtualAd && pVirtualAd->RtmpDev)
1572 pAdapter = pVirtualAd->RtmpDev->ml_priv;
1575 if (pAdapter == NULL)
1577 /* if 1st open fail, pAd will be free;
1578 So the net_dev->ml_priv will be NULL in 2rd open */
1582 //check if the interface is down
1583 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1585 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1589 frag->value = pAdapter->CommonCfg.FragmentThreshold;
1590 frag->disabled = (frag->value == MAX_FRAG_THRESHOLD);
1596 #define MAX_WEP_KEY_SIZE 13
1597 #define MIN_WEP_KEY_SIZE 5
1598 int rt_ioctl_siwencode(struct net_device *dev,
1599 struct iw_request_info *info,
1600 struct iw_point *erq, char *extra)
1602 PRTMP_ADAPTER pAdapter = dev->ml_priv;
1604 //check if the interface is down
1605 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1607 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1611 if ((erq->length == 0) &&
1612 (erq->flags & IW_ENCODE_DISABLED))
1614 pAdapter->StaCfg.PairCipher = Ndis802_11WEPDisabled;
1615 pAdapter->StaCfg.GroupCipher = Ndis802_11WEPDisabled;
1616 pAdapter->StaCfg.WepStatus = Ndis802_11WEPDisabled;
1617 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
1618 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
1621 else if ((erq->length == 0) &&
1622 (erq->flags & IW_ENCODE_RESTRICTED || erq->flags & IW_ENCODE_OPEN))
1624 STA_PORT_SECURED(pAdapter);
1625 pAdapter->StaCfg.PairCipher = Ndis802_11WEPEnabled;
1626 pAdapter->StaCfg.GroupCipher = Ndis802_11WEPEnabled;
1627 pAdapter->StaCfg.WepStatus = Ndis802_11WEPEnabled;
1628 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
1629 if (erq->flags & IW_ENCODE_RESTRICTED)
1630 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeShared;
1632 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
1636 if (erq->length > 0)
1638 int keyIdx = (erq->flags & IW_ENCODE_INDEX) - 1;
1639 /* Check the size of the key */
1640 if (erq->length > MAX_WEP_KEY_SIZE) {
1643 /* Check key index */
1644 if ((keyIdx < 0) || (keyIdx >= NR_WEP_KEYS))
1646 DBGPRINT(RT_DEBUG_TRACE ,("==>rt_ioctl_siwencode::Wrong keyIdx=%d! Using default key instead (%d)\n",
1647 keyIdx, pAdapter->StaCfg.DefaultKeyId));
1650 keyIdx = pAdapter->StaCfg.DefaultKeyId;
1653 NdisZeroMemory(pAdapter->SharedKey[BSS0][keyIdx].Key, 16);
1655 if (erq->length == MAX_WEP_KEY_SIZE)
1657 pAdapter->SharedKey[BSS0][keyIdx].KeyLen = MAX_WEP_KEY_SIZE;
1658 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CIPHER_WEP128;
1660 else if (erq->length == MIN_WEP_KEY_SIZE)
1662 pAdapter->SharedKey[BSS0][keyIdx].KeyLen = MIN_WEP_KEY_SIZE;
1663 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CIPHER_WEP64;
1666 /* Disable the key */
1667 pAdapter->SharedKey[BSS0][keyIdx].KeyLen = 0;
1669 /* Check if the key is not marked as invalid */
1670 if(!(erq->flags & IW_ENCODE_NOKEY)) {
1671 /* Copy the key in the driver */
1672 NdisMoveMemory(pAdapter->SharedKey[BSS0][keyIdx].Key, extra, erq->length);
1677 /* Do we want to just set the transmit key index ? */
1678 int index = (erq->flags & IW_ENCODE_INDEX) - 1;
1679 if ((index >= 0) && (index < 4))
1681 pAdapter->StaCfg.DefaultKeyId = index;
1684 /* Don't complain if only change the mode */
1685 if (!(erq->flags & IW_ENCODE_MODE)) {
1691 DBGPRINT(RT_DEBUG_TRACE ,("==>rt_ioctl_siwencode::erq->flags=%x\n",erq->flags));
1692 DBGPRINT(RT_DEBUG_TRACE ,("==>rt_ioctl_siwencode::AuthMode=%x\n",pAdapter->StaCfg.AuthMode));
1693 DBGPRINT(RT_DEBUG_TRACE ,("==>rt_ioctl_siwencode::DefaultKeyId=%x, KeyLen = %d\n",pAdapter->StaCfg.DefaultKeyId , pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].KeyLen));
1694 DBGPRINT(RT_DEBUG_TRACE ,("==>rt_ioctl_siwencode::WepStatus=%x\n",pAdapter->StaCfg.WepStatus));
1699 rt_ioctl_giwencode(struct net_device *dev,
1700 struct iw_request_info *info,
1701 struct iw_point *erq, char *key)
1704 PRTMP_ADAPTER pAdapter = NULL;
1705 VIRTUAL_ADAPTER *pVirtualAd = NULL;
1707 if (dev->priv_flags == INT_MAIN)
1709 pAdapter = dev->ml_priv;
1713 pVirtualAd = dev->ml_priv;
1714 if (pVirtualAd && pVirtualAd->RtmpDev)
1715 pAdapter = pVirtualAd->RtmpDev->ml_priv;
1718 if (pAdapter == NULL)
1720 /* if 1st open fail, pAd will be free;
1721 So the net_dev->ml_priv will be NULL in 2rd open */
1725 //check if the interface is down
1726 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1728 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1732 kid = erq->flags & IW_ENCODE_INDEX;
1733 DBGPRINT(RT_DEBUG_TRACE, ("===>rt_ioctl_giwencode %d\n", erq->flags & IW_ENCODE_INDEX));
1735 if (pAdapter->StaCfg.WepStatus == Ndis802_11WEPDisabled)
1738 erq->flags = IW_ENCODE_DISABLED;
1740 else if ((kid > 0) && (kid <=4))
1743 erq->flags = kid ; /* NB: base 1 */
1744 if (erq->length > pAdapter->SharedKey[BSS0][kid-1].KeyLen)
1745 erq->length = pAdapter->SharedKey[BSS0][kid-1].KeyLen;
1746 memcpy(key, pAdapter->SharedKey[BSS0][kid-1].Key, erq->length);
1747 //if ((kid == pAdapter->PortCfg.DefaultKeyId))
1748 //erq->flags |= IW_ENCODE_ENABLED; /* XXX */
1749 if (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeShared)
1750 erq->flags |= IW_ENCODE_RESTRICTED; /* XXX */
1752 erq->flags |= IW_ENCODE_OPEN; /* XXX */
1757 if (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeShared)
1758 erq->flags |= IW_ENCODE_RESTRICTED; /* XXX */
1760 erq->flags |= IW_ENCODE_OPEN; /* XXX */
1761 erq->length = pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].KeyLen;
1762 memcpy(key, pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].Key, erq->length);
1763 // copy default key ID
1764 if (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeShared)
1765 erq->flags |= IW_ENCODE_RESTRICTED; /* XXX */
1767 erq->flags |= IW_ENCODE_OPEN; /* XXX */
1768 erq->flags = pAdapter->StaCfg.DefaultKeyId + 1; /* NB: base 1 */
1769 erq->flags |= IW_ENCODE_ENABLED; /* XXX */
1777 rt_ioctl_setparam(struct net_device *dev, struct iw_request_info *info,
1778 void *w, char *extra)
1780 VIRTUAL_ADAPTER *pVirtualAd = NULL;
1781 PRTMP_ADAPTER pAdapter;
1783 char *this_char = extra;
1787 if (dev->priv_flags == INT_MAIN)
1789 pAdapter = dev->ml_priv;
1793 pVirtualAd = dev->ml_priv;
1794 pAdapter = pVirtualAd->RtmpDev->ml_priv;
1796 pObj = (POS_COOKIE) pAdapter->OS_Cookie;
1798 if (pAdapter == NULL)
1800 /* if 1st open fail, pAd will be free;
1801 So the net_dev->ml_priv will be NULL in 2rd open */
1806 pObj->ioctl_if_type = INT_MAIN;
1807 pObj->ioctl_if = MAIN_MBSSID;
1810 //check if the interface is down
1811 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1813 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1820 if ((value = rtstrchr(this_char, '=')) != NULL)
1826 // reject setting nothing besides ANY ssid(ssidLen=0)
1827 if (!*value && (strcmp(this_char, "SSID") != 0))
1830 for (PRTMP_PRIVATE_SET_PROC = RTMP_PRIVATE_SUPPORT_PROC; PRTMP_PRIVATE_SET_PROC->name; PRTMP_PRIVATE_SET_PROC++)
1832 if (strcmp(this_char, PRTMP_PRIVATE_SET_PROC->name) == 0)
1834 if(!PRTMP_PRIVATE_SET_PROC->set_proc(pAdapter, value))
1835 { //FALSE:Set private failed then return Invalid argument
1838 break; //Exit for loop.
1842 if(PRTMP_PRIVATE_SET_PROC->name == NULL)
1843 { //Not found argument
1845 DBGPRINT(RT_DEBUG_TRACE, ("===>rt_ioctl_setparam:: (iwpriv) Not Support Set Command [%s=%s]\n", this_char, value));
1853 rt_private_get_statistics(struct net_device *dev, struct iw_request_info *info,
1854 struct iw_point *wrq, char *extra)
1857 PRTMP_ADAPTER pAd = dev->ml_priv;
1865 memset(extra, 0x00, IW_PRIV_SIZE_MASK);
1866 sprintf(extra, "\n\n");
1869 sprintf(extra+strlen(extra), "Tx success = %ld\n", (ULONG)pAd->WlanCounters.TransmittedFragmentCount.QuadPart);
1870 sprintf(extra+strlen(extra), "Tx success without retry = %ld\n", (ULONG)pAd->WlanCounters.TransmittedFragmentCount.QuadPart - (ULONG)pAd->WlanCounters.RetryCount.QuadPart);
1872 sprintf(extra+strlen(extra), "Tx success after retry = %ld\n", (ULONG)pAd->WlanCounters.RetryCount.QuadPart);
1873 sprintf(extra+strlen(extra), "Tx fail to Rcv ACK after retry = %ld\n", (ULONG)pAd->WlanCounters.FailedCount.QuadPart);
1874 sprintf(extra+strlen(extra), "RTS Success Rcv CTS = %ld\n", (ULONG)pAd->WlanCounters.RTSSuccessCount.QuadPart);
1875 sprintf(extra+strlen(extra), "RTS Fail Rcv CTS = %ld\n", (ULONG)pAd->WlanCounters.RTSFailureCount.QuadPart);
1877 sprintf(extra+strlen(extra), "Rx success = %ld\n", (ULONG)pAd->WlanCounters.ReceivedFragmentCount.QuadPart);
1878 sprintf(extra+strlen(extra), "Rx with CRC = %ld\n", (ULONG)pAd->WlanCounters.FCSErrorCount.QuadPart);
1879 sprintf(extra+strlen(extra), "Rx drop due to out of resource = %ld\n", (ULONG)pAd->Counters8023.RxNoBuffer);
1880 sprintf(extra+strlen(extra), "Rx duplicate frame = %ld\n", (ULONG)pAd->WlanCounters.FrameDuplicateCount.QuadPart);
1882 sprintf(extra+strlen(extra), "False CCA (one second) = %ld\n", (ULONG)pAd->RalinkCounters.OneSecFalseCCACnt);
1884 sprintf(extra+strlen(extra), "RSSI-A = %ld\n", (LONG)(pAd->StaCfg.RssiSample.LastRssi0 - pAd->BbpRssiToDbmDelta));
1885 sprintf(extra+strlen(extra), "RSSI-B (if available) = %ld\n", (LONG)(pAd->StaCfg.RssiSample.LastRssi1 - pAd->BbpRssiToDbmDelta));
1886 sprintf(extra+strlen(extra), "RSSI-C (if available) = %ld\n\n", (LONG)(pAd->StaCfg.RssiSample.LastRssi2 - pAd->BbpRssiToDbmDelta));
1888 sprintf(extra+strlen(extra), "WpaSupplicantUP = %d\n\n", pAd->StaCfg.WpaSupplicantUP);
1890 wrq->length = strlen(extra) + 1; // 1: size of '\0'
1891 DBGPRINT(RT_DEBUG_TRACE, ("<== rt_private_get_statistics, wrq->length = %d\n", wrq->length));
1896 #ifdef DOT11_N_SUPPORT
1898 IN PRTMP_ADAPTER pAd,
1902 BA_ORI_ENTRY *pOriBAEntry;
1903 BA_REC_ENTRY *pRecBAEntry;
1905 for (i=0; i<MAX_LEN_OF_MAC_TABLE; i++)
1907 PMAC_TABLE_ENTRY pEntry = &pAd->MacTab.Content[i];
1908 if (((pEntry->ValidAsCLI || pEntry->ValidAsApCli) && (pEntry->Sst == SST_ASSOC))
1909 || (pEntry->ValidAsWDS) || (pEntry->ValidAsMesh))
1911 sprintf(pOutBuf + strlen(pOutBuf), "\n%02X:%02X:%02X:%02X:%02X:%02X (Aid = %d) (AP) -\n",
1912 pEntry->Addr[0], pEntry->Addr[1], pEntry->Addr[2],
1913 pEntry->Addr[3], pEntry->Addr[4], pEntry->Addr[5], pEntry->Aid);
1915 sprintf(pOutBuf, "%s[Recipient]\n", pOutBuf);
1916 for (j=0; j < NUM_OF_TID; j++)
1918 if (pEntry->BARecWcidArray[j] != 0)
1920 pRecBAEntry =&pAd->BATable.BARecEntry[pEntry->BARecWcidArray[j]];
1921 sprintf(pOutBuf + strlen(pOutBuf), "TID=%d, BAWinSize=%d, LastIndSeq=%d, ReorderingPkts=%d\n", j, pRecBAEntry->BAWinSize, pRecBAEntry->LastIndSeq, pRecBAEntry->list.qlen);
1924 sprintf(pOutBuf, "%s\n", pOutBuf);
1926 sprintf(pOutBuf, "%s[Originator]\n", pOutBuf);
1927 for (j=0; j < NUM_OF_TID; j++)
1929 if (pEntry->BAOriWcidArray[j] != 0)
1931 pOriBAEntry =&pAd->BATable.BAOriEntry[pEntry->BAOriWcidArray[j]];
1932 sprintf(pOutBuf + strlen(pOutBuf), "TID=%d, BAWinSize=%d, StartSeq=%d, CurTxSeq=%d\n", j, pOriBAEntry->BAWinSize, pOriBAEntry->Sequence, pEntry->TxSeq[j]);
1935 sprintf(pOutBuf, "%s\n\n", pOutBuf);
1937 if (strlen(pOutBuf) > (IW_PRIV_SIZE_MASK - 30))
1943 #endif // DOT11_N_SUPPORT //
1946 rt_private_show(struct net_device *dev, struct iw_request_info *info,
1947 struct iw_point *wrq, char *extra)
1950 VIRTUAL_ADAPTER *pVirtualAd = NULL;
1953 u32 subcmd = wrq->flags;
1955 if (dev->priv_flags == INT_MAIN)
1959 pVirtualAd = dev->ml_priv;
1960 pAd = pVirtualAd->RtmpDev->ml_priv;
1962 pObj = (POS_COOKIE) pAd->OS_Cookie;
1966 /* if 1st open fail, pAd will be free;
1967 So the net_dev->ml_priv will be NULL in 2rd open */
1976 memset(extra, 0x00, IW_PRIV_SIZE_MASK);
1979 pObj->ioctl_if_type = INT_MAIN;
1980 pObj->ioctl_if = MAIN_MBSSID;
1986 case SHOW_CONN_STATUS:
1987 if (MONITOR_ON(pAd))
1989 #ifdef DOT11_N_SUPPORT
1990 if (pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED &&
1991 pAd->CommonCfg.RegTransmitSetting.field.BW)
1992 sprintf(extra, "Monitor Mode(CentralChannel %d)\n", pAd->CommonCfg.CentralChannel);
1994 #endif // DOT11_N_SUPPORT //
1995 sprintf(extra, "Monitor Mode(Channel %d)\n", pAd->CommonCfg.Channel);
1999 if (pAd->IndicateMediaState == NdisMediaStateConnected)
2003 sprintf(extra, "Connected(AP: %s[%02X:%02X:%02X:%02X:%02X:%02X])\n",
2004 pAd->CommonCfg.Ssid,
2005 pAd->CommonCfg.Bssid[0],
2006 pAd->CommonCfg.Bssid[1],
2007 pAd->CommonCfg.Bssid[2],
2008 pAd->CommonCfg.Bssid[3],
2009 pAd->CommonCfg.Bssid[4],
2010 pAd->CommonCfg.Bssid[5]);
2011 DBGPRINT(RT_DEBUG_TRACE ,("Ssid=%s ,Ssidlen = %d\n",pAd->CommonCfg.Ssid, pAd->CommonCfg.SsidLen));
2013 else if (ADHOC_ON(pAd))
2014 sprintf(extra, "Connected\n");
2018 sprintf(extra, "Disconnected\n");
2019 DBGPRINT(RT_DEBUG_TRACE ,("ConnStatus is not connected\n"));
2022 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2024 case SHOW_DRVIER_VERION:
2025 sprintf(extra, "Driver version-%s, %s %s\n", STA_DRIVER_VERSION, __DATE__, __TIME__ );
2026 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2028 #ifdef DOT11_N_SUPPORT
2030 getBaInfo(pAd, extra);
2031 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2033 #endif // DOT11_N_SUPPORT //
2034 case SHOW_DESC_INFO:
2036 Show_DescInfo_Proc(pAd, NULL);
2037 wrq->length = 0; // 1: size of '\0'
2041 if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
2043 sprintf(extra, "Scanning\n");
2044 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2047 pAd->StaCfg.bSwRadio = FALSE;
2048 if (pAd->StaCfg.bRadio != (pAd->StaCfg.bHwRadio && pAd->StaCfg.bSwRadio))
2050 pAd->StaCfg.bRadio = (pAd->StaCfg.bHwRadio && pAd->StaCfg.bSwRadio);
2051 if (pAd->StaCfg.bRadio == FALSE)
2054 // Update extra information
2055 pAd->ExtraInfo = SW_RADIO_OFF;
2058 sprintf(extra, "Radio Off\n");
2059 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2062 pAd->StaCfg.bSwRadio = TRUE;
2063 //if (pAd->StaCfg.bRadio != (pAd->StaCfg.bHwRadio && pAd->StaCfg.bSwRadio))
2065 pAd->StaCfg.bRadio = (pAd->StaCfg.bHwRadio && pAd->StaCfg.bSwRadio);
2066 if (pAd->StaCfg.bRadio == TRUE)
2069 // Update extra information
2070 pAd->ExtraInfo = EXTRA_INFO_CLEAR;
2073 sprintf(extra, "Radio On\n");
2074 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2077 case SHOW_CFG_VALUE:
2079 Status = RTMPShowCfgValue(pAd, wrq->pointer, extra);
2081 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2085 DBGPRINT(RT_DEBUG_TRACE, ("%s - unknow subcmd = %d\n", __func__, subcmd));
2093 int rt_ioctl_siwmlme(struct net_device *dev,
2094 struct iw_request_info *info,
2095 union iwreq_data *wrqu,
2098 PRTMP_ADAPTER pAd = dev->ml_priv;
2099 struct iw_mlme *pMlme = (struct iw_mlme *)wrqu->data.pointer;
2100 MLME_QUEUE_ELEM MsgElem;
2101 MLME_DISASSOC_REQ_STRUCT DisAssocReq;
2102 MLME_DEAUTH_REQ_STRUCT DeAuthReq;
2104 DBGPRINT(RT_DEBUG_TRACE, ("====> %s\n", __func__));
2111 #ifdef IW_MLME_DEAUTH
2112 case IW_MLME_DEAUTH:
2113 DBGPRINT(RT_DEBUG_TRACE, ("====> %s - IW_MLME_DEAUTH\n", __func__));
2114 COPY_MAC_ADDR(DeAuthReq.Addr, pAd->CommonCfg.Bssid);
2115 DeAuthReq.Reason = pMlme->reason_code;
2116 MsgElem.MsgLen = sizeof(MLME_DEAUTH_REQ_STRUCT);
2117 NdisMoveMemory(MsgElem.Msg, &DeAuthReq, sizeof(MLME_DEAUTH_REQ_STRUCT));
2118 MlmeDeauthReqAction(pAd, &MsgElem);
2121 LinkDown(pAd, FALSE);
2122 pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
2125 #endif // IW_MLME_DEAUTH //
2126 #ifdef IW_MLME_DISASSOC
2127 case IW_MLME_DISASSOC:
2128 DBGPRINT(RT_DEBUG_TRACE, ("====> %s - IW_MLME_DISASSOC\n", __func__));
2129 COPY_MAC_ADDR(DisAssocReq.Addr, pAd->CommonCfg.Bssid);
2130 DisAssocReq.Reason = pMlme->reason_code;
2132 MsgElem.Machine = ASSOC_STATE_MACHINE;
2133 MsgElem.MsgType = MT2_MLME_DISASSOC_REQ;
2134 MsgElem.MsgLen = sizeof(MLME_DISASSOC_REQ_STRUCT);
2135 NdisMoveMemory(MsgElem.Msg, &DisAssocReq, sizeof(MLME_DISASSOC_REQ_STRUCT));
2137 pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_OID_DISASSOC;
2138 MlmeDisassocReqAction(pAd, &MsgElem);
2140 #endif // IW_MLME_DISASSOC //
2142 DBGPRINT(RT_DEBUG_TRACE, ("====> %s - Unknow Command\n", __func__));
2148 #endif // SIOCSIWMLME //
2150 #if WIRELESS_EXT > 17
2151 int rt_ioctl_siwauth(struct net_device *dev,
2152 struct iw_request_info *info,
2153 union iwreq_data *wrqu, char *extra)
2155 PRTMP_ADAPTER pAdapter = dev->ml_priv;
2156 struct iw_param *param = &wrqu->param;
2158 //check if the interface is down
2159 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
2161 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
2164 switch (param->flags & IW_AUTH_INDEX) {
2165 case IW_AUTH_WPA_VERSION:
2166 if (param->value == IW_AUTH_WPA_VERSION_WPA)
2168 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPAPSK;
2169 if (pAdapter->StaCfg.BssType == BSS_ADHOC)
2170 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPANone;
2172 else if (param->value == IW_AUTH_WPA_VERSION_WPA2)
2173 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA2PSK;
2175 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_WPA_VERSION - param->value = %d!\n", __func__, param->value));
2177 case IW_AUTH_CIPHER_PAIRWISE:
2178 if (param->value == IW_AUTH_CIPHER_NONE)
2180 pAdapter->StaCfg.WepStatus = Ndis802_11WEPDisabled;
2181 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
2182 pAdapter->StaCfg.PairCipher = Ndis802_11WEPDisabled;
2184 else if (param->value == IW_AUTH_CIPHER_WEP40 ||
2185 param->value == IW_AUTH_CIPHER_WEP104)
2187 pAdapter->StaCfg.WepStatus = Ndis802_11WEPEnabled;
2188 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
2189 pAdapter->StaCfg.PairCipher = Ndis802_11WEPEnabled;
2190 pAdapter->StaCfg.IEEE8021X = FALSE;
2192 else if (param->value == IW_AUTH_CIPHER_TKIP)
2194 pAdapter->StaCfg.WepStatus = Ndis802_11Encryption2Enabled;
2195 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
2196 pAdapter->StaCfg.PairCipher = Ndis802_11Encryption2Enabled;
2198 else if (param->value == IW_AUTH_CIPHER_CCMP)
2200 pAdapter->StaCfg.WepStatus = Ndis802_11Encryption3Enabled;
2201 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
2202 pAdapter->StaCfg.PairCipher = Ndis802_11Encryption3Enabled;
2204 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_CIPHER_PAIRWISE - param->value = %d!\n", __func__, param->value));
2206 case IW_AUTH_CIPHER_GROUP:
2207 if (param->value == IW_AUTH_CIPHER_NONE)
2209 pAdapter->StaCfg.GroupCipher = Ndis802_11WEPDisabled;
2211 else if (param->value == IW_AUTH_CIPHER_WEP40 ||
2212 param->value == IW_AUTH_CIPHER_WEP104)
2214 pAdapter->StaCfg.GroupCipher = Ndis802_11WEPEnabled;
2216 else if (param->value == IW_AUTH_CIPHER_TKIP)
2218 pAdapter->StaCfg.GroupCipher = Ndis802_11Encryption2Enabled;
2220 else if (param->value == IW_AUTH_CIPHER_CCMP)
2222 pAdapter->StaCfg.GroupCipher = Ndis802_11Encryption3Enabled;
2224 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_CIPHER_GROUP - param->value = %d!\n", __func__, param->value));
2226 case IW_AUTH_KEY_MGMT:
2227 if (param->value == IW_AUTH_KEY_MGMT_802_1X)
2229 if (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK)
2231 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA;
2232 pAdapter->StaCfg.IEEE8021X = FALSE;
2234 else if (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK)
2236 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA2;
2237 pAdapter->StaCfg.IEEE8021X = FALSE;
2241 pAdapter->StaCfg.IEEE8021X = TRUE;
2243 else if (param->value == 0)
2245 STA_PORT_SECURED(pAdapter);
2247 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_KEY_MGMT - param->value = %d!\n", __func__, param->value));
2249 case IW_AUTH_RX_UNENCRYPTED_EAPOL:
2251 case IW_AUTH_PRIVACY_INVOKED:
2252 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_PRIVACY_INVOKED - param->value = %d!\n", __func__, param->value));
2254 case IW_AUTH_DROP_UNENCRYPTED:
2255 if (param->value != 0)
2256 pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED;
2259 STA_PORT_SECURED(pAdapter);
2261 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_WPA_VERSION - param->value = %d!\n", __func__, param->value));
2263 case IW_AUTH_80211_AUTH_ALG:
2264 if (param->value & IW_AUTH_ALG_SHARED_KEY)
2266 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeShared;
2268 else if (param->value & IW_AUTH_ALG_OPEN_SYSTEM)
2270 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
2274 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_80211_AUTH_ALG - param->value = %d!\n", __func__, param->value));
2276 case IW_AUTH_WPA_ENABLED:
2277 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_WPA_ENABLED - Driver supports WPA!(param->value = %d)\n", __func__, param->value));
2286 int rt_ioctl_giwauth(struct net_device *dev,
2287 struct iw_request_info *info,
2288 union iwreq_data *wrqu, char *extra)
2290 PRTMP_ADAPTER pAdapter = dev->ml_priv;
2291 struct iw_param *param = &wrqu->param;
2293 //check if the interface is down
2294 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
2296 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
2300 switch (param->flags & IW_AUTH_INDEX) {
2301 case IW_AUTH_DROP_UNENCRYPTED:
2302 param->value = (pAdapter->StaCfg.WepStatus == Ndis802_11WEPDisabled) ? 0 : 1;
2305 case IW_AUTH_80211_AUTH_ALG:
2306 param->value = (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeShared) ? IW_AUTH_ALG_SHARED_KEY : IW_AUTH_ALG_OPEN_SYSTEM;
2309 case IW_AUTH_WPA_ENABLED:
2310 param->value = (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA) ? 1 : 0;
2316 DBGPRINT(RT_DEBUG_TRACE, ("rt_ioctl_giwauth::param->value = %d!\n", param->value));
2320 void fnSetCipherKey(
2321 IN PRTMP_ADAPTER pAdapter,
2325 IN struct iw_encode_ext *ext)
2327 RTMP_CLEAR_PSFLAG(pAdapter, fRTMP_PS_CAN_GO_SLEEP);
2328 if (RTMP_TEST_PSFLAG(pAdapter, fRTMP_PS_SET_PCI_CLK_OFF_COMMAND))
2330 if (pAdapter->StaCfg.bRadio == FALSE)
2332 RTMP_SET_PSFLAG(pAdapter, fRTMP_PS_CAN_GO_SLEEP);
2335 DBGPRINT(RT_DEBUG_TRACE,("RTMPWPAAddKeyProc1==>\n"));
2336 RTMPPCIeLinkCtrlValueRestore(pAdapter, RESTORE_HALT);
2337 RTMPusecDelay(6000);
2338 pAdapter->bPCIclkOff = FALSE;
2341 NdisZeroMemory(&pAdapter->SharedKey[BSS0][keyIdx], sizeof(CIPHER_KEY));
2342 pAdapter->SharedKey[BSS0][keyIdx].KeyLen = LEN_TKIP_EK;
2343 NdisMoveMemory(pAdapter->SharedKey[BSS0][keyIdx].Key, ext->key, LEN_TKIP_EK);
2344 NdisMoveMemory(pAdapter->SharedKey[BSS0][keyIdx].TxMic, ext->key + LEN_TKIP_EK, LEN_TKIP_TXMICK);
2345 NdisMoveMemory(pAdapter->SharedKey[BSS0][keyIdx].RxMic, ext->key + LEN_TKIP_EK + LEN_TKIP_TXMICK, LEN_TKIP_RXMICK);
2346 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CipherAlg;
2348 // Update group key information to ASIC Shared Key Table
2349 AsicAddSharedKeyEntry(pAdapter,
2352 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg,
2353 pAdapter->SharedKey[BSS0][keyIdx].Key,
2354 pAdapter->SharedKey[BSS0][keyIdx].TxMic,
2355 pAdapter->SharedKey[BSS0][keyIdx].RxMic);
2358 // Update ASIC WCID attribute table and IVEIV table
2359 RTMPAddWcidAttributeEntry(pAdapter,
2362 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg,
2365 // Update ASIC WCID attribute table and IVEIV table
2366 RTMPAddWcidAttributeEntry(pAdapter,
2369 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg,
2370 &pAdapter->MacTab.Content[BSSID_WCID]);
2372 RTMP_SET_PSFLAG(pAdapter, fRTMP_PS_CAN_GO_SLEEP);
2375 int rt_ioctl_siwencodeext(struct net_device *dev,
2376 struct iw_request_info *info,
2377 union iwreq_data *wrqu,
2380 PRTMP_ADAPTER pAdapter = dev->ml_priv;
2381 struct iw_point *encoding = &wrqu->encoding;
2382 struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
2383 int keyIdx, alg = ext->alg;
2385 //check if the interface is down
2386 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
2388 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
2392 if (encoding->flags & IW_ENCODE_DISABLED)
2394 keyIdx = (encoding->flags & IW_ENCODE_INDEX) - 1;
2395 // set BSSID wcid entry of the Pair-wise Key table as no-security mode
2396 AsicRemovePairwiseKeyEntry(pAdapter, BSS0, BSSID_WCID);
2397 pAdapter->SharedKey[BSS0][keyIdx].KeyLen = 0;
2398 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CIPHER_NONE;
2399 AsicRemoveSharedKeyEntry(pAdapter, 0, (UCHAR)keyIdx);
2400 NdisZeroMemory(&pAdapter->SharedKey[BSS0][keyIdx], sizeof(CIPHER_KEY));
2401 DBGPRINT(RT_DEBUG_TRACE, ("%s::Remove all keys!(encoding->flags = %x)\n", __func__, encoding->flags));
2405 // Get Key Index and convet to our own defined key index
2406 keyIdx = (encoding->flags & IW_ENCODE_INDEX) - 1;
2407 if((keyIdx < 0) || (keyIdx >= NR_WEP_KEYS))
2410 if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
2412 pAdapter->StaCfg.DefaultKeyId = keyIdx;
2413 DBGPRINT(RT_DEBUG_TRACE, ("%s::DefaultKeyId = %d\n", __func__, pAdapter->StaCfg.DefaultKeyId));
2417 case IW_ENCODE_ALG_NONE:
2418 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_ENCODE_ALG_NONE\n", __func__));
2420 case IW_ENCODE_ALG_WEP:
2421 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_ENCODE_ALG_WEP - ext->key_len = %d, keyIdx = %d\n", __func__, ext->key_len, keyIdx));
2422 if (ext->key_len == MAX_WEP_KEY_SIZE)
2424 pAdapter->SharedKey[BSS0][keyIdx].KeyLen = MAX_WEP_KEY_SIZE;
2425 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CIPHER_WEP128;
2427 else if (ext->key_len == MIN_WEP_KEY_SIZE)
2429 pAdapter->SharedKey[BSS0][keyIdx].KeyLen = MIN_WEP_KEY_SIZE;
2430 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CIPHER_WEP64;
2435 NdisZeroMemory(pAdapter->SharedKey[BSS0][keyIdx].Key, 16);
2436 NdisMoveMemory(pAdapter->SharedKey[BSS0][keyIdx].Key, ext->key, ext->key_len);
2438 if (pAdapter->StaCfg.GroupCipher == Ndis802_11GroupWEP40Enabled ||
2439 pAdapter->StaCfg.GroupCipher == Ndis802_11GroupWEP104Enabled)
2441 // Set Group key material to Asic
2442 AsicAddSharedKeyEntry(pAdapter, BSS0, keyIdx, pAdapter->SharedKey[BSS0][keyIdx].CipherAlg, pAdapter->SharedKey[BSS0][keyIdx].Key, NULL, NULL);
2444 // Update WCID attribute table and IVEIV table for this group key table
2445 RTMPAddWcidAttributeEntry(pAdapter, BSS0, keyIdx, pAdapter->SharedKey[BSS0][keyIdx].CipherAlg, NULL);
2447 STA_PORT_SECURED(pAdapter);
2449 // Indicate Connected for GUI
2450 pAdapter->IndicateMediaState = NdisMediaStateConnected;
2453 case IW_ENCODE_ALG_TKIP:
2454 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_ENCODE_ALG_TKIP - keyIdx = %d, ext->key_len = %d\n", __func__, keyIdx, ext->key_len));
2455 if (ext->key_len == 32)
2457 if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
2459 fnSetCipherKey(pAdapter, keyIdx, CIPHER_TKIP, FALSE, ext);
2460 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA2)
2462 STA_PORT_SECURED(pAdapter);
2465 else if (ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY)
2467 fnSetCipherKey(pAdapter, keyIdx, CIPHER_TKIP, TRUE, ext);
2469 // set 802.1x port control
2470 STA_PORT_SECURED(pAdapter);
2476 case IW_ENCODE_ALG_CCMP:
2477 if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
2479 fnSetCipherKey(pAdapter, keyIdx, CIPHER_AES, FALSE, ext);
2480 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA2)
2481 STA_PORT_SECURED(pAdapter);
2483 else if (ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY)
2485 fnSetCipherKey(pAdapter, keyIdx, CIPHER_AES, TRUE, ext);
2487 // set 802.1x port control
2488 STA_PORT_SECURED(pAdapter);
2500 rt_ioctl_giwencodeext(struct net_device *dev,
2501 struct iw_request_info *info,
2502 union iwreq_data *wrqu, char *extra)
2504 PRTMP_ADAPTER pAd = dev->ml_priv;
2506 struct iw_point *encoding = &wrqu->encoding;
2507 struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
2508 int idx, max_key_len;
2510 DBGPRINT(RT_DEBUG_TRACE ,("===> rt_ioctl_giwencodeext\n"));
2512 max_key_len = encoding->length - sizeof(*ext);
2513 if (max_key_len < 0)
2516 idx = encoding->flags & IW_ENCODE_INDEX;
2519 if (idx < 1 || idx > 4)
2523 if ((pAd->StaCfg.WepStatus == Ndis802_11Encryption2Enabled) ||
2524 (pAd->StaCfg.WepStatus == Ndis802_11Encryption3Enabled))
2526 if (idx != pAd->StaCfg.DefaultKeyId)
2534 idx = pAd->StaCfg.DefaultKeyId;
2536 encoding->flags = idx + 1;
2537 memset(ext, 0, sizeof(*ext));
2540 switch(pAd->StaCfg.WepStatus) {
2541 case Ndis802_11WEPDisabled:
2542 ext->alg = IW_ENCODE_ALG_NONE;
2543 encoding->flags |= IW_ENCODE_DISABLED;
2545 case Ndis802_11WEPEnabled:
2546 ext->alg = IW_ENCODE_ALG_WEP;
2547 if (pAd->SharedKey[BSS0][idx].KeyLen > max_key_len)
2551 ext->key_len = pAd->SharedKey[BSS0][idx].KeyLen;
2552 pKey = &(pAd->SharedKey[BSS0][idx].Key[0]);
2555 case Ndis802_11Encryption2Enabled:
2556 case Ndis802_11Encryption3Enabled:
2557 if (pAd->StaCfg.WepStatus == Ndis802_11Encryption2Enabled)
2558 ext->alg = IW_ENCODE_ALG_TKIP;
2560 ext->alg = IW_ENCODE_ALG_CCMP;
2562 if (max_key_len < 32)
2567 pKey = &pAd->StaCfg.PMK[0];
2574 if (ext->key_len && pKey)
2576 encoding->flags |= IW_ENCODE_ENABLED;
2577 memcpy(ext->key, pKey, ext->key_len);
2584 int rt_ioctl_siwgenie(struct net_device *dev,
2585 struct iw_request_info *info,
2586 union iwreq_data *wrqu, char *extra)
2588 PRTMP_ADAPTER pAd = dev->ml_priv;
2590 if (wrqu->data.length > MAX_LEN_OF_RSNIE ||
2591 (wrqu->data.length && extra == NULL))
2594 if (wrqu->data.length)
2596 pAd->StaCfg.RSNIE_Len = wrqu->data.length;
2597 NdisMoveMemory(&pAd->StaCfg.RSN_IE[0], extra, pAd->StaCfg.RSNIE_Len);
2601 pAd->StaCfg.RSNIE_Len = 0;
2602 NdisZeroMemory(&pAd->StaCfg.RSN_IE[0], MAX_LEN_OF_RSNIE);
2607 #endif // SIOCSIWGENIE //
2609 int rt_ioctl_giwgenie(struct net_device *dev,
2610 struct iw_request_info *info,
2611 union iwreq_data *wrqu, char *extra)
2613 PRTMP_ADAPTER pAd = dev->ml_priv;
2615 if ((pAd->StaCfg.RSNIE_Len == 0) ||
2616 (pAd->StaCfg.AuthMode < Ndis802_11AuthModeWPA))
2618 wrqu->data.length = 0;
2623 if (pAd->StaCfg.WpaSupplicantUP == WPA_SUPPLICANT_ENABLE)
2625 if (wrqu->data.length < pAd->StaCfg.RSNIE_Len)
2628 wrqu->data.length = pAd->StaCfg.RSNIE_Len;
2629 memcpy(extra, &pAd->StaCfg.RSN_IE[0], pAd->StaCfg.RSNIE_Len);
2632 #endif // SIOCSIWGENIE //
2634 UCHAR RSNIe = IE_WPA;
2636 if (wrqu->data.length < (pAd->StaCfg.RSNIE_Len + 2)) // ID, Len
2638 wrqu->data.length = pAd->StaCfg.RSNIE_Len + 2;
2640 if ((pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK) ||
2641 (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2))
2644 extra[0] = (char)RSNIe;
2645 extra[1] = pAd->StaCfg.RSNIE_Len;
2646 memcpy(extra+2, &pAd->StaCfg.RSN_IE[0], pAd->StaCfg.RSNIE_Len);
2652 int rt_ioctl_siwpmksa(struct net_device *dev,
2653 struct iw_request_info *info,
2654 union iwreq_data *wrqu,
2657 PRTMP_ADAPTER pAd = dev->ml_priv;
2658 struct iw_pmksa *pPmksa = (struct iw_pmksa *)wrqu->data.pointer;
2659 INT CachedIdx = 0, idx = 0;
2664 DBGPRINT(RT_DEBUG_TRACE ,("===> rt_ioctl_siwpmksa\n"));
2667 case IW_PMKSA_FLUSH:
2668 NdisZeroMemory(pAd->StaCfg.SavedPMK, sizeof(BSSID_INFO)*PMKID_NO);
2669 DBGPRINT(RT_DEBUG_TRACE ,("rt_ioctl_siwpmksa - IW_PMKSA_FLUSH\n"));
2671 case IW_PMKSA_REMOVE:
2672 for (CachedIdx = 0; CachedIdx < pAd->StaCfg.SavedPMKNum; CachedIdx++)
2674 // compare the BSSID
2675 if (NdisEqualMemory(pPmksa->bssid.sa_data, pAd->StaCfg.SavedPMK[CachedIdx].BSSID, MAC_ADDR_LEN))
2677 NdisZeroMemory(pAd->StaCfg.SavedPMK[CachedIdx].BSSID, MAC_ADDR_LEN);
2678 NdisZeroMemory(pAd->StaCfg.SavedPMK[CachedIdx].PMKID, 16);
2679 for (idx = CachedIdx; idx < (pAd->StaCfg.SavedPMKNum - 1); idx++)
2681 NdisMoveMemory(&pAd->StaCfg.SavedPMK[idx].BSSID[0], &pAd->StaCfg.SavedPMK[idx+1].BSSID[0], MAC_ADDR_LEN);
2682 NdisMoveMemory(&pAd->StaCfg.SavedPMK[idx].PMKID[0], &pAd->StaCfg.SavedPMK[idx+1].PMKID[0], 16);
2684 pAd->StaCfg.SavedPMKNum--;
2689 DBGPRINT(RT_DEBUG_TRACE ,("rt_ioctl_siwpmksa - IW_PMKSA_REMOVE\n"));
2692 for (CachedIdx = 0; CachedIdx < pAd->StaCfg.SavedPMKNum; CachedIdx++)
2694 // compare the BSSID
2695 if (NdisEqualMemory(pPmksa->bssid.sa_data, pAd->StaCfg.SavedPMK[CachedIdx].BSSID, MAC_ADDR_LEN))
2699 // Found, replace it
2700 if (CachedIdx < PMKID_NO)
2702 DBGPRINT(RT_DEBUG_OFF, ("Update PMKID, idx = %d\n", CachedIdx));
2703 NdisMoveMemory(&pAd->StaCfg.SavedPMK[CachedIdx].BSSID[0], pPmksa->bssid.sa_data, MAC_ADDR_LEN);
2704 NdisMoveMemory(&pAd->StaCfg.SavedPMK[CachedIdx].PMKID[0], pPmksa->pmkid, 16);
2705 pAd->StaCfg.SavedPMKNum++;
2707 // Not found, replace the last one
2710 // Randomly replace one
2711 CachedIdx = (pPmksa->bssid.sa_data[5] % PMKID_NO);
2712 DBGPRINT(RT_DEBUG_OFF, ("Update PMKID, idx = %d\n", CachedIdx));
2713 NdisMoveMemory(&pAd->StaCfg.SavedPMK[CachedIdx].BSSID[0], pPmksa->bssid.sa_data, MAC_ADDR_LEN);
2714 NdisMoveMemory(&pAd->StaCfg.SavedPMK[CachedIdx].PMKID[0], pPmksa->pmkid, 16);
2717 DBGPRINT(RT_DEBUG_TRACE ,("rt_ioctl_siwpmksa - IW_PMKSA_ADD\n"));
2720 DBGPRINT(RT_DEBUG_TRACE ,("rt_ioctl_siwpmksa - Unknow Command!!\n"));
2726 #endif // #if WIRELESS_EXT > 17
2730 rt_private_ioctl_bbp(struct net_device *dev, struct iw_request_info *info,
2731 struct iw_point *wrq, char *extra)
2738 BOOLEAN bIsPrintAllBBP = FALSE;
2740 PRTMP_ADAPTER pAdapter = dev->ml_priv;
2743 memset(extra, 0x00, IW_PRIV_SIZE_MASK);
2745 if (wrq->length > 1) //No parameters.
2747 sprintf(extra, "\n");
2749 //Parsing Read or Write
2750 this_char = wrq->pointer;
2751 DBGPRINT(RT_DEBUG_TRACE, ("this_char=%s\n", this_char));
2755 if ((value = rtstrchr(this_char, '=')) != NULL)
2758 if (!value || !*value)
2760 DBGPRINT(RT_DEBUG_TRACE, ("this_char=%s, value=%s\n", this_char, value));
2761 if (sscanf(this_char, "%d", &(bbpId)) == 1)
2766 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, ®BBP);
2768 sprintf(extra+strlen(extra), "R%02d[0x%02X]:%02X\n", bbpId, bbpId*2, regBBP);
2769 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2770 DBGPRINT(RT_DEBUG_TRACE, ("msg=%s\n", extra));
2773 {//Invalid parametes, so default printk all bbp
2774 bIsPrintAllBBP = TRUE;
2779 { //Invalid parametes, so default printk all bbp
2780 bIsPrintAllBBP = TRUE;
2786 if ((sscanf(this_char, "%d", &(bbpId)) == 1) && (sscanf(value, "%x", &(bbpValue)) == 1))
2791 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, bbpId, bbpValue);
2792 //Read it back for showing
2793 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, ®BBP);
2795 sprintf(extra+strlen(extra), "R%02d[0x%02X]:%02X\n", bbpId, bbpId*2, regBBP);
2796 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2797 DBGPRINT(RT_DEBUG_TRACE, ("msg=%s\n", extra));
2800 {//Invalid parametes, so default printk all bbp
2801 bIsPrintAllBBP = TRUE;
2806 { //Invalid parametes, so default printk all bbp
2807 bIsPrintAllBBP = TRUE;
2813 bIsPrintAllBBP = TRUE;
2818 memset(extra, 0x00, IW_PRIV_SIZE_MASK);
2819 sprintf(extra, "\n");
2820 for (bbpId = 0; bbpId <= 136; bbpId++)
2822 if (strlen(extra) >= (IW_PRIV_SIZE_MASK - 10))
2824 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, ®BBP);
2825 sprintf(extra+strlen(extra), "R%02d[0x%02X]:%02X ", bbpId, bbpId*2, regBBP);
2827 sprintf(extra+strlen(extra), "\n");
2830 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2831 DBGPRINT(RT_DEBUG_TRACE, ("wrq->length = %d\n", wrq->length));
2834 DBGPRINT(RT_DEBUG_TRACE, ("<==rt_private_ioctl_bbp\n\n"));
2840 int rt_ioctl_siwrate(struct net_device *dev,
2841 struct iw_request_info *info,
2842 union iwreq_data *wrqu, char *extra)
2844 PRTMP_ADAPTER pAd = dev->ml_priv;
2845 UINT32 rate = wrqu->bitrate.value, fixed = wrqu->bitrate.fixed;
2847 //check if the interface is down
2848 if(!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_IN_USE))
2850 DBGPRINT(RT_DEBUG_TRACE, ("rt_ioctl_siwrate::Network is down!\n"));
2854 DBGPRINT(RT_DEBUG_TRACE, ("rt_ioctl_siwrate::(rate = %d, fixed = %d)\n", rate, fixed));
2855 /* rate = -1 => auto rate
2856 rate = X, fixed = 1 => (fixed rate X)
2861 pAd->StaCfg.DesiredTransmitSetting.field.MCS = MCS_AUTO;
2862 pAd->StaCfg.bAutoTxRateSwitch = TRUE;
2863 if ((pAd->CommonCfg.PhyMode <= PHY_11G) ||
2864 (pAd->MacTab.Content[BSSID_WCID].HTPhyMode.field.MODE <= MODE_OFDM))
2865 RTMPSetDesiredRates(pAd, -1);
2867 #ifdef DOT11_N_SUPPORT
2869 #endif // DOT11_N_SUPPORT //
2875 pAd->StaCfg.bAutoTxRateSwitch = FALSE;
2876 if ((pAd->CommonCfg.PhyMode <= PHY_11G) ||
2877 (pAd->MacTab.Content[BSSID_WCID].HTPhyMode.field.MODE <= MODE_OFDM))
2878 RTMPSetDesiredRates(pAd, rate);
2881 pAd->StaCfg.DesiredTransmitSetting.field.MCS = MCS_AUTO;
2882 #ifdef DOT11_N_SUPPORT
2884 #endif // DOT11_N_SUPPORT //
2886 DBGPRINT(RT_DEBUG_TRACE, ("rt_ioctl_siwrate::(HtMcs=%d)\n",pAd->StaCfg.DesiredTransmitSetting.field.MCS));
2890 // TODO: rate = X, fixed = 0 => (rates <= X)
2898 int rt_ioctl_giwrate(struct net_device *dev,
2899 struct iw_request_info *info,
2900 union iwreq_data *wrqu, char *extra)
2902 PRTMP_ADAPTER pAd = dev->ml_priv;
2903 int rate_index = 0, rate_count = 0;
2904 HTTRANSMIT_SETTING ht_setting;
2905 __s32 ralinkrate[] =
2906 {2, 4, 11, 22, // CCK
2907 12, 18, 24, 36, 48, 72, 96, 108, // OFDM
2908 13, 26, 39, 52, 78, 104, 117, 130, 26, 52, 78, 104, 156, 208, 234, 260, // 20MHz, 800ns GI, MCS: 0 ~ 15
2909 39, 78, 117, 156, 234, 312, 351, 390, // 20MHz, 800ns GI, MCS: 16 ~ 23
2910 27, 54, 81, 108, 162, 216, 243, 270, 54, 108, 162, 216, 324, 432, 486, 540, // 40MHz, 800ns GI, MCS: 0 ~ 15
2911 81, 162, 243, 324, 486, 648, 729, 810, // 40MHz, 800ns GI, MCS: 16 ~ 23
2912 14, 29, 43, 57, 87, 115, 130, 144, 29, 59, 87, 115, 173, 230, 260, 288, // 20MHz, 400ns GI, MCS: 0 ~ 15
2913 43, 87, 130, 173, 260, 317, 390, 433, // 20MHz, 400ns GI, MCS: 16 ~ 23
2914 30, 60, 90, 120, 180, 240, 270, 300, 60, 120, 180, 240, 360, 480, 540, 600, // 40MHz, 400ns GI, MCS: 0 ~ 15
2915 90, 180, 270, 360, 540, 720, 810, 900}; // 40MHz, 400ns GI, MCS: 16 ~ 23
2917 rate_count = sizeof(ralinkrate)/sizeof(__s32);
2918 //check if the interface is down
2919 if(!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_IN_USE))
2921 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
2925 if ((pAd->StaCfg.bAutoTxRateSwitch == FALSE) &&
2927 ((pAd->CommonCfg.PhyMode <= PHY_11G) || (pAd->MacTab.Content[BSSID_WCID].HTPhyMode.field.MODE <= MODE_OFDM)))
2928 ht_setting.word = pAd->StaCfg.HTPhyMode.word;
2930 ht_setting.word = pAd->MacTab.Content[BSSID_WCID].HTPhyMode.word;
2932 #ifdef DOT11_N_SUPPORT
2933 if (ht_setting.field.MODE >= MODE_HTMIX)
2935 rate_index = 12 + ((UCHAR)ht_setting.field.BW *24) + ((UCHAR)ht_setting.field.ShortGI *48) + ((UCHAR)ht_setting.field.MCS);
2938 #endif // DOT11_N_SUPPORT //
2939 if (ht_setting.field.MODE == MODE_OFDM)
2940 rate_index = (UCHAR)(ht_setting.field.MCS) + 4;
2941 else if (ht_setting.field.MODE == MODE_CCK)
2942 rate_index = (UCHAR)(ht_setting.field.MCS);
2947 if (rate_index > rate_count)
2948 rate_index = rate_count;
2950 wrqu->bitrate.value = ralinkrate[rate_index] * 500000;
2951 wrqu->bitrate.disabled = 0;
2956 static const iw_handler rt_handler[] =
2958 (iw_handler) NULL, /* SIOCSIWCOMMIT */
2959 (iw_handler) rt_ioctl_giwname, /* SIOCGIWNAME */
2960 (iw_handler) NULL, /* SIOCSIWNWID */
2961 (iw_handler) NULL, /* SIOCGIWNWID */
2962 (iw_handler) rt_ioctl_siwfreq, /* SIOCSIWFREQ */
2963 (iw_handler) rt_ioctl_giwfreq, /* SIOCGIWFREQ */
2964 (iw_handler) rt_ioctl_siwmode, /* SIOCSIWMODE */
2965 (iw_handler) rt_ioctl_giwmode, /* SIOCGIWMODE */
2966 (iw_handler) NULL, /* SIOCSIWSENS */
2967 (iw_handler) NULL, /* SIOCGIWSENS */
2968 (iw_handler) NULL /* not used */, /* SIOCSIWRANGE */
2969 (iw_handler) rt_ioctl_giwrange, /* SIOCGIWRANGE */
2970 (iw_handler) NULL /* not used */, /* SIOCSIWPRIV */
2971 (iw_handler) NULL /* kernel code */, /* SIOCGIWPRIV */
2972 (iw_handler) NULL /* not used */, /* SIOCSIWSTATS */
2973 (iw_handler) rt28xx_get_wireless_stats /* kernel code */, /* SIOCGIWSTATS */
2974 (iw_handler) NULL, /* SIOCSIWSPY */
2975 (iw_handler) NULL, /* SIOCGIWSPY */
2976 (iw_handler) NULL, /* SIOCSIWTHRSPY */
2977 (iw_handler) NULL, /* SIOCGIWTHRSPY */
2978 (iw_handler) rt_ioctl_siwap, /* SIOCSIWAP */
2979 (iw_handler) rt_ioctl_giwap, /* SIOCGIWAP */
2981 (iw_handler) rt_ioctl_siwmlme, /* SIOCSIWMLME */
2983 (iw_handler) NULL, /* SIOCSIWMLME */
2984 #endif // SIOCSIWMLME //
2985 (iw_handler) rt_ioctl_iwaplist, /* SIOCGIWAPLIST */
2987 (iw_handler) rt_ioctl_siwscan, /* SIOCSIWSCAN */
2988 (iw_handler) rt_ioctl_giwscan, /* SIOCGIWSCAN */
2990 (iw_handler) NULL, /* SIOCSIWSCAN */
2991 (iw_handler) NULL, /* SIOCGIWSCAN */
2992 #endif /* SIOCGIWSCAN */
2993 (iw_handler) rt_ioctl_siwessid, /* SIOCSIWESSID */
2994 (iw_handler) rt_ioctl_giwessid, /* SIOCGIWESSID */
2995 (iw_handler) rt_ioctl_siwnickn, /* SIOCSIWNICKN */
2996 (iw_handler) rt_ioctl_giwnickn, /* SIOCGIWNICKN */
2997 (iw_handler) NULL, /* -- hole -- */
2998 (iw_handler) NULL, /* -- hole -- */
2999 (iw_handler) rt_ioctl_siwrate, /* SIOCSIWRATE */
3000 (iw_handler) rt_ioctl_giwrate, /* SIOCGIWRATE */
3001 (iw_handler) rt_ioctl_siwrts, /* SIOCSIWRTS */
3002 (iw_handler) rt_ioctl_giwrts, /* SIOCGIWRTS */
3003 (iw_handler) rt_ioctl_siwfrag, /* SIOCSIWFRAG */
3004 (iw_handler) rt_ioctl_giwfrag, /* SIOCGIWFRAG */
3005 (iw_handler) NULL, /* SIOCSIWTXPOW */
3006 (iw_handler) NULL, /* SIOCGIWTXPOW */
3007 (iw_handler) NULL, /* SIOCSIWRETRY */
3008 (iw_handler) NULL, /* SIOCGIWRETRY */
3009 (iw_handler) rt_ioctl_siwencode, /* SIOCSIWENCODE */
3010 (iw_handler) rt_ioctl_giwencode, /* SIOCGIWENCODE */
3011 (iw_handler) NULL, /* SIOCSIWPOWER */
3012 (iw_handler) NULL, /* SIOCGIWPOWER */
3013 (iw_handler) NULL, /* -- hole -- */
3014 (iw_handler) NULL, /* -- hole -- */
3015 #if WIRELESS_EXT > 17
3016 (iw_handler) rt_ioctl_siwgenie, /* SIOCSIWGENIE */
3017 (iw_handler) rt_ioctl_giwgenie, /* SIOCGIWGENIE */
3018 (iw_handler) rt_ioctl_siwauth, /* SIOCSIWAUTH */
3019 (iw_handler) rt_ioctl_giwauth, /* SIOCGIWAUTH */
3020 (iw_handler) rt_ioctl_siwencodeext, /* SIOCSIWENCODEEXT */
3021 (iw_handler) rt_ioctl_giwencodeext, /* SIOCGIWENCODEEXT */
3022 (iw_handler) rt_ioctl_siwpmksa, /* SIOCSIWPMKSA */
3026 static const iw_handler rt_priv_handlers[] = {
3027 (iw_handler) NULL, /* + 0x00 */
3028 (iw_handler) NULL, /* + 0x01 */
3029 #ifndef CONFIG_AP_SUPPORT
3030 (iw_handler) rt_ioctl_setparam, /* + 0x02 */
3032 (iw_handler) NULL, /* + 0x02 */
3033 #endif // CONFIG_AP_SUPPORT //
3035 (iw_handler) rt_private_ioctl_bbp, /* + 0x03 */
3037 (iw_handler) NULL, /* + 0x03 */
3039 (iw_handler) NULL, /* + 0x04 */
3040 (iw_handler) NULL, /* + 0x05 */
3041 (iw_handler) NULL, /* + 0x06 */
3042 (iw_handler) NULL, /* + 0x07 */
3043 (iw_handler) NULL, /* + 0x08 */
3044 (iw_handler) rt_private_get_statistics, /* + 0x09 */
3045 (iw_handler) NULL, /* + 0x0A */
3046 (iw_handler) NULL, /* + 0x0B */
3047 (iw_handler) NULL, /* + 0x0C */
3048 (iw_handler) NULL, /* + 0x0D */
3049 (iw_handler) NULL, /* + 0x0E */
3050 (iw_handler) NULL, /* + 0x0F */
3051 (iw_handler) NULL, /* + 0x10 */
3052 (iw_handler) rt_private_show, /* + 0x11 */
3053 (iw_handler) NULL, /* + 0x12 */
3054 (iw_handler) NULL, /* + 0x13 */
3055 (iw_handler) NULL, /* + 0x15 */
3056 (iw_handler) NULL, /* + 0x17 */
3057 (iw_handler) NULL, /* + 0x18 */
3060 const struct iw_handler_def rt28xx_iw_handler_def =
3062 #define N(a) (sizeof (a) / sizeof (a[0]))
3063 .standard = (iw_handler *) rt_handler,
3064 .num_standard = sizeof(rt_handler) / sizeof(iw_handler),
3065 .private = (iw_handler *) rt_priv_handlers,
3066 .num_private = N(rt_priv_handlers),
3067 .private_args = (struct iw_priv_args *) privtab,
3068 .num_private_args = N(privtab),
3069 #if IW_HANDLER_VERSION >= 7
3070 .get_wireless_stats = rt28xx_get_wireless_stats,
3074 INT RTMPSetInformation(
3075 IN PRTMP_ADAPTER pAdapter,
3076 IN OUT struct ifreq *rq,
3079 struct iwreq *wrq = (struct iwreq *) rq;
3080 NDIS_802_11_SSID Ssid;
3081 NDIS_802_11_MAC_ADDRESS Bssid;
3082 RT_802_11_PHY_MODE PhyMode;
3083 RT_802_11_STA_CONFIG StaConfig;
3084 NDIS_802_11_RATES aryRates;
3085 RT_802_11_PREAMBLE Preamble;
3086 NDIS_802_11_WEP_STATUS WepStatus;
3087 NDIS_802_11_AUTHENTICATION_MODE AuthMode = Ndis802_11AuthModeMax;
3088 NDIS_802_11_NETWORK_INFRASTRUCTURE BssType;
3089 NDIS_802_11_RTS_THRESHOLD RtsThresh;
3090 NDIS_802_11_FRAGMENTATION_THRESHOLD FragThresh;
3091 NDIS_802_11_POWER_MODE PowerMode;
3092 PNDIS_802_11_KEY pKey = NULL;
3093 PNDIS_802_11_WEP pWepKey =NULL;
3094 PNDIS_802_11_REMOVE_KEY pRemoveKey = NULL;
3095 NDIS_802_11_CONFIGURATION Config, *pConfig = NULL;
3096 NDIS_802_11_NETWORK_TYPE NetType;
3099 INT Status = NDIS_STATUS_SUCCESS, MaxPhyMode = PHY_11G;
3102 BOOLEAN StateMachineTouched = FALSE;
3103 #ifdef DOT11_N_SUPPORT
3104 OID_SET_HT_PHYMODE HT_PhyMode; //11n ,kathy
3105 #endif // DOT11_N_SUPPORT //
3106 PNDIS_802_11_PMKID pPmkId = NULL;
3107 BOOLEAN IEEE8021xState = FALSE;
3108 BOOLEAN IEEE8021x_required_keys = FALSE;
3109 UCHAR wpa_supplicant_enable = 0;
3111 #ifdef DOT11_N_SUPPORT
3112 MaxPhyMode = PHY_11N_5G;
3113 #endif // DOT11_N_SUPPORT //
3116 DBGPRINT(RT_DEBUG_TRACE, ("-->RTMPSetInformation(), 0x%08x\n", cmd&0x7FFF));
3117 switch(cmd & 0x7FFF) {
3118 case RT_OID_802_11_COUNTRY_REGION:
3119 if (wrq->u.data.length < sizeof(UCHAR))
3121 // Only avaliable when EEPROM not programming
3122 else if (!(pAdapter->CommonCfg.CountryRegion & 0x80) && !(pAdapter->CommonCfg.CountryRegionForABand & 0x80))
3127 Status = copy_from_user(&Country, wrq->u.data.pointer, wrq->u.data.length);
3128 pAdapter->CommonCfg.CountryRegion = (UCHAR)(Country & 0x000000FF);
3129 pAdapter->CommonCfg.CountryRegionForABand = (UCHAR)((Country >> 8) & 0x000000FF);
3130 TmpPhy = pAdapter->CommonCfg.PhyMode;
3131 pAdapter->CommonCfg.PhyMode = 0xff;
3132 // Build all corresponding channel information
3133 RTMPSetPhyMode(pAdapter, TmpPhy);
3134 #ifdef DOT11_N_SUPPORT
3135 SetCommonHT(pAdapter);
3136 #endif // DOT11_N_SUPPORT //
3137 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_COUNTRY_REGION (A:%d B/G:%d)\n", pAdapter->CommonCfg.CountryRegionForABand,
3138 pAdapter->CommonCfg.CountryRegion));
3141 case OID_802_11_BSSID_LIST_SCAN:
3143 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_BSSID_LIST_SCAN, TxCnt = %d \n", pAdapter->RalinkCounters.LastOneSecTotalTxCount));
3145 if (MONITOR_ON(pAdapter))
3147 DBGPRINT(RT_DEBUG_TRACE, ("!!! Driver is in Monitor Mode now !!!\n"));
3151 //Benson add 20080527, when radio off, sta don't need to scan
3152 if (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_RADIO_OFF))
3155 if (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
3157 DBGPRINT(RT_DEBUG_TRACE, ("!!! Driver is scanning now !!!\n"));
3158 pAdapter->StaCfg.bScanReqIsFromWebUI = TRUE;
3159 Status = NDIS_STATUS_SUCCESS;
3163 if (pAdapter->RalinkCounters.LastOneSecTotalTxCount > 100)
3165 DBGPRINT(RT_DEBUG_TRACE, ("!!! Link UP, ignore this set::OID_802_11_BSSID_LIST_SCAN\n"));
3166 Status = NDIS_STATUS_SUCCESS;
3167 pAdapter->StaCfg.ScanCnt = 99; // Prevent auto scan triggered by this OID
3171 if ((OPSTATUS_TEST_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED)) &&
3172 ((pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA) ||
3173 (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK) ||
3174 (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA2) ||
3175 (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK)) &&
3176 (pAdapter->StaCfg.PortSecured == WPA_802_1X_PORT_NOT_SECURED))
3178 DBGPRINT(RT_DEBUG_TRACE, ("!!! Link UP, Port Not Secured! ignore this set::OID_802_11_BSSID_LIST_SCAN\n"));
3179 Status = NDIS_STATUS_SUCCESS;
3180 pAdapter->StaCfg.ScanCnt = 99; // Prevent auto scan triggered by this OID
3185 if (pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE)
3187 RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
3188 DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
3191 // tell CNTL state machine to call NdisMSetInformationComplete() after completing
3192 // this request, because this request is initiated by NDIS.
3193 pAdapter->MlmeAux.CurrReqIsFromNdis = FALSE;
3194 // Reset allowed scan retries
3195 pAdapter->StaCfg.ScanCnt = 0;
3196 pAdapter->StaCfg.LastScanTime = Now;
3198 pAdapter->StaCfg.bScanReqIsFromWebUI = TRUE;
3199 RTMP_SET_FLAG(pAdapter, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS);
3200 MlmeEnqueue(pAdapter,
3201 MLME_CNTL_STATE_MACHINE,
3202 OID_802_11_BSSID_LIST_SCAN,
3206 Status = NDIS_STATUS_SUCCESS;
3207 StateMachineTouched = TRUE;
3209 case OID_802_11_SSID:
3210 if (wrq->u.data.length != sizeof(NDIS_802_11_SSID))
3214 PCHAR pSsidString = NULL;
3215 Status = copy_from_user(&Ssid, wrq->u.data.pointer, wrq->u.data.length);
3217 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_SSID (Len=%d,Ssid=%s)\n", Ssid.SsidLength, Ssid.Ssid));
3218 if (Ssid.SsidLength > MAX_LEN_OF_SSID)
3222 if (Ssid.SsidLength == 0)
3224 Set_SSID_Proc(pAdapter, "");
3228 pSsidString = (CHAR *) kmalloc(MAX_LEN_OF_SSID+1, MEM_ALLOC_FLAG);
3231 NdisZeroMemory(pSsidString, MAX_LEN_OF_SSID+1);
3232 NdisMoveMemory(pSsidString, Ssid.Ssid, Ssid.SsidLength);
3233 Set_SSID_Proc(pAdapter, pSsidString);
3242 case OID_802_11_BSSID:
3243 if (wrq->u.data.length != sizeof(NDIS_802_11_MAC_ADDRESS))
3247 Status = copy_from_user(&Bssid, wrq->u.data.pointer, wrq->u.data.length);
3249 // tell CNTL state machine to call NdisMSetInformationComplete() after completing
3250 // this request, because this request is initiated by NDIS.
3251 pAdapter->MlmeAux.CurrReqIsFromNdis = FALSE;
3253 // Prevent to connect AP again in STAMlmePeriodicExec
3254 pAdapter->MlmeAux.AutoReconnectSsidLen= 32;
3256 // Reset allowed scan retries
3257 pAdapter->StaCfg.ScanCnt = 0;
3259 if (pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE)
3261 RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
3262 DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
3264 MlmeEnqueue(pAdapter,
3265 MLME_CNTL_STATE_MACHINE,
3267 sizeof(NDIS_802_11_MAC_ADDRESS),
3269 Status = NDIS_STATUS_SUCCESS;
3270 StateMachineTouched = TRUE;
3272 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_BSSID %02x:%02x:%02x:%02x:%02x:%02x\n",
3273 Bssid[0], Bssid[1], Bssid[2], Bssid[3], Bssid[4], Bssid[5]));
3276 case RT_OID_802_11_RADIO:
3277 if (wrq->u.data.length != sizeof(BOOLEAN))
3281 Status = copy_from_user(&RadioState, wrq->u.data.pointer, wrq->u.data.length);
3282 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_RADIO (=%d)\n", RadioState));
3283 if (pAdapter->StaCfg.bSwRadio != RadioState)
3285 pAdapter->StaCfg.bSwRadio = RadioState;
3286 if (pAdapter->StaCfg.bRadio != (pAdapter->StaCfg.bHwRadio && pAdapter->StaCfg.bSwRadio))
3288 pAdapter->StaCfg.bRadio = (pAdapter->StaCfg.bHwRadio && pAdapter->StaCfg.bSwRadio);
3289 if (pAdapter->StaCfg.bRadio == TRUE)
3291 MlmeRadioOn(pAdapter);
3292 // Update extra information
3293 pAdapter->ExtraInfo = EXTRA_INFO_CLEAR;
3297 MlmeRadioOff(pAdapter);
3298 // Update extra information
3299 pAdapter->ExtraInfo = SW_RADIO_OFF;
3305 case RT_OID_802_11_PHY_MODE:
3306 if (wrq->u.data.length != sizeof(RT_802_11_PHY_MODE))
3310 Status = copy_from_user(&PhyMode, wrq->u.data.pointer, wrq->u.data.length);
3311 if (PhyMode <= MaxPhyMode)
3313 RTMPSetPhyMode(pAdapter, PhyMode);
3314 #ifdef DOT11_N_SUPPORT
3315 SetCommonHT(pAdapter);
3316 #endif // DOT11_N_SUPPORT //
3318 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_PHY_MODE (=%d)\n", PhyMode));
3321 case RT_OID_802_11_STA_CONFIG:
3322 if (wrq->u.data.length != sizeof(RT_802_11_STA_CONFIG))
3326 Status = copy_from_user(&StaConfig, wrq->u.data.pointer, wrq->u.data.length);
3327 pAdapter->CommonCfg.bEnableTxBurst = StaConfig.EnableTxBurst;
3328 pAdapter->CommonCfg.UseBGProtection = StaConfig.UseBGProtection;
3329 pAdapter->CommonCfg.bUseShortSlotTime = 1; // 2003-10-30 always SHORT SLOT capable
3330 if ((pAdapter->CommonCfg.PhyMode != StaConfig.AdhocMode) &&
3331 (StaConfig.AdhocMode <= MaxPhyMode))
3333 // allow dynamic change of "USE OFDM rate or not" in ADHOC mode
3334 // if setting changed, need to reset current TX rate as well as BEACON frame format
3335 if (pAdapter->StaCfg.BssType == BSS_ADHOC)
3337 pAdapter->CommonCfg.PhyMode = StaConfig.AdhocMode;
3338 RTMPSetPhyMode(pAdapter, PhyMode);
3339 MlmeUpdateTxRates(pAdapter, FALSE, 0);
3340 MakeIbssBeacon(pAdapter); // re-build BEACON frame
3341 AsicEnableIbssSync(pAdapter); // copy to on-chip memory
3344 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_SET_STA_CONFIG (Burst=%d, Protection=%ld,ShortSlot=%d\n",
3345 pAdapter->CommonCfg.bEnableTxBurst,
3346 pAdapter->CommonCfg.UseBGProtection,
3347 pAdapter->CommonCfg.bUseShortSlotTime));
3350 case OID_802_11_DESIRED_RATES:
3351 if (wrq->u.data.length != sizeof(NDIS_802_11_RATES))
3355 Status = copy_from_user(&aryRates, wrq->u.data.pointer, wrq->u.data.length);
3356 NdisZeroMemory(pAdapter->CommonCfg.DesireRate, MAX_LEN_OF_SUPPORTED_RATES);
3357 NdisMoveMemory(pAdapter->CommonCfg.DesireRate, &aryRates, sizeof(NDIS_802_11_RATES));
3358 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_DESIRED_RATES (%02x,%02x,%02x,%02x,%02x,%02x,%02x,%02x)\n",
3359 pAdapter->CommonCfg.DesireRate[0],pAdapter->CommonCfg.DesireRate[1],
3360 pAdapter->CommonCfg.DesireRate[2],pAdapter->CommonCfg.DesireRate[3],
3361 pAdapter->CommonCfg.DesireRate[4],pAdapter->CommonCfg.DesireRate[5],
3362 pAdapter->CommonCfg.DesireRate[6],pAdapter->CommonCfg.DesireRate[7] ));
3363 // Changing DesiredRate may affect the MAX TX rate we used to TX frames out
3364 MlmeUpdateTxRates(pAdapter, FALSE, 0);
3367 case RT_OID_802_11_PREAMBLE:
3368 if (wrq->u.data.length != sizeof(RT_802_11_PREAMBLE))
3372 Status = copy_from_user(&Preamble, wrq->u.data.pointer, wrq->u.data.length);
3373 if (Preamble == Rt802_11PreambleShort)
3375 pAdapter->CommonCfg.TxPreamble = Preamble;
3376 MlmeSetTxPreamble(pAdapter, Rt802_11PreambleShort);
3378 else if ((Preamble == Rt802_11PreambleLong) || (Preamble == Rt802_11PreambleAuto))
3380 // if user wants AUTO, initialize to LONG here, then change according to AP's
3381 // capability upon association.
3382 pAdapter->CommonCfg.TxPreamble = Preamble;
3383 MlmeSetTxPreamble(pAdapter, Rt802_11PreambleLong);
3390 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_PREAMBLE (=%d)\n", Preamble));
3393 case OID_802_11_WEP_STATUS:
3394 if (wrq->u.data.length != sizeof(NDIS_802_11_WEP_STATUS))
3398 Status = copy_from_user(&WepStatus, wrq->u.data.pointer, wrq->u.data.length);
3399 // Since TKIP, AES, WEP are all supported. It should not have any invalid setting
3400 if (WepStatus <= Ndis802_11Encryption3KeyAbsent)
3402 if (pAdapter->StaCfg.WepStatus != WepStatus)
3404 // Config has changed
3405 pAdapter->bConfigChanged = TRUE;
3407 pAdapter->StaCfg.WepStatus = WepStatus;
3408 pAdapter->StaCfg.OrigWepStatus = WepStatus;
3409 pAdapter->StaCfg.PairCipher = WepStatus;
3410 pAdapter->StaCfg.GroupCipher = WepStatus;
3417 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_WEP_STATUS (=%d)\n",WepStatus));
3420 case OID_802_11_AUTHENTICATION_MODE:
3421 if (wrq->u.data.length != sizeof(NDIS_802_11_AUTHENTICATION_MODE))
3425 Status = copy_from_user(&AuthMode, wrq->u.data.pointer, wrq->u.data.length);
3426 if (AuthMode > Ndis802_11AuthModeMax)
3433 if (pAdapter->StaCfg.AuthMode != AuthMode)
3435 // Config has changed
3436 pAdapter->bConfigChanged = TRUE;
3438 pAdapter->StaCfg.AuthMode = AuthMode;
3440 pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED;
3441 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_AUTHENTICATION_MODE (=%d) \n",pAdapter->StaCfg.AuthMode));
3444 case OID_802_11_INFRASTRUCTURE_MODE:
3445 if (wrq->u.data.length != sizeof(NDIS_802_11_NETWORK_INFRASTRUCTURE))
3449 Status = copy_from_user(&BssType, wrq->u.data.pointer, wrq->u.data.length);
3451 if (BssType == Ndis802_11IBSS)
3452 Set_NetworkType_Proc(pAdapter, "Adhoc");
3453 else if (BssType == Ndis802_11Infrastructure)
3454 Set_NetworkType_Proc(pAdapter, "Infra");
3455 else if (BssType == Ndis802_11Monitor)
3456 Set_NetworkType_Proc(pAdapter, "Monitor");
3460 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_INFRASTRUCTURE_MODE (unknown)\n"));
3464 case OID_802_11_REMOVE_WEP:
3465 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_WEP\n"));
3466 if (wrq->u.data.length != sizeof(NDIS_802_11_KEY_INDEX))
3472 KeyIdx = *(NDIS_802_11_KEY_INDEX *) wrq->u.data.pointer;
3474 if (KeyIdx & 0x80000000)
3476 // Should never set default bit when remove key
3481 KeyIdx = KeyIdx & 0x0fffffff;
3487 pAdapter->SharedKey[BSS0][KeyIdx].KeyLen = 0;
3488 pAdapter->SharedKey[BSS0][KeyIdx].CipherAlg = CIPHER_NONE;
3489 AsicRemoveSharedKeyEntry(pAdapter, 0, (UCHAR)KeyIdx);
3494 case RT_OID_802_11_RESET_COUNTERS:
3495 NdisZeroMemory(&pAdapter->WlanCounters, sizeof(COUNTER_802_11));
3496 NdisZeroMemory(&pAdapter->Counters8023, sizeof(COUNTER_802_3));
3497 NdisZeroMemory(&pAdapter->RalinkCounters, sizeof(COUNTER_RALINK));
3498 pAdapter->Counters8023.RxNoBuffer = 0;
3499 pAdapter->Counters8023.GoodReceives = 0;
3500 pAdapter->Counters8023.RxNoBuffer = 0;
3501 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_RESET_COUNTERS \n"));
3503 case OID_802_11_RTS_THRESHOLD:
3504 if (wrq->u.data.length != sizeof(NDIS_802_11_RTS_THRESHOLD))
3508 Status = copy_from_user(&RtsThresh, wrq->u.data.pointer, wrq->u.data.length);
3509 if (RtsThresh > MAX_RTS_THRESHOLD)
3512 pAdapter->CommonCfg.RtsThreshold = (USHORT)RtsThresh;
3514 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_RTS_THRESHOLD (=%ld)\n",RtsThresh));
3516 case OID_802_11_FRAGMENTATION_THRESHOLD:
3517 if (wrq->u.data.length != sizeof(NDIS_802_11_FRAGMENTATION_THRESHOLD))
3521 Status = copy_from_user(&FragThresh, wrq->u.data.pointer, wrq->u.data.length);
3522 pAdapter->CommonCfg.bUseZeroToDisableFragment = FALSE;
3523 if (FragThresh > MAX_FRAG_THRESHOLD || FragThresh < MIN_FRAG_THRESHOLD)
3525 if (FragThresh == 0)
3527 pAdapter->CommonCfg.FragmentThreshold = MAX_FRAG_THRESHOLD;
3528 pAdapter->CommonCfg.bUseZeroToDisableFragment = TRUE;
3534 pAdapter->CommonCfg.FragmentThreshold = (USHORT)FragThresh;
3536 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_FRAGMENTATION_THRESHOLD (=%ld) \n",FragThresh));
3538 case OID_802_11_POWER_MODE:
3539 if (wrq->u.data.length != sizeof(NDIS_802_11_POWER_MODE))
3543 Status = copy_from_user(&PowerMode, wrq->u.data.pointer, wrq->u.data.length);
3544 if (PowerMode == Ndis802_11PowerModeCAM)
3545 Set_PSMode_Proc(pAdapter, "CAM");
3546 else if (PowerMode == Ndis802_11PowerModeMAX_PSP)
3547 Set_PSMode_Proc(pAdapter, "Max_PSP");
3548 else if (PowerMode == Ndis802_11PowerModeFast_PSP)
3549 Set_PSMode_Proc(pAdapter, "Fast_PSP");
3550 else if (PowerMode == Ndis802_11PowerModeLegacy_PSP)
3551 Set_PSMode_Proc(pAdapter, "Legacy_PSP");
3555 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_POWER_MODE (=%d)\n",PowerMode));
3557 case RT_OID_802_11_TX_POWER_LEVEL_1:
3558 if (wrq->u.data.length < sizeof(ULONG))
3562 Status = copy_from_user(&PowerTemp, wrq->u.data.pointer, wrq->u.data.length);
3563 if (PowerTemp > 100)
3564 PowerTemp = 0xffffffff; // AUTO
3565 pAdapter->CommonCfg.TxPowerDefault = PowerTemp; //keep current setting.
3566 pAdapter->CommonCfg.TxPowerPercentage = pAdapter->CommonCfg.TxPowerDefault;
3567 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_TX_POWER_LEVEL_1 (=%ld)\n", pAdapter->CommonCfg.TxPowerPercentage));
3570 case OID_802_11_NETWORK_TYPE_IN_USE:
3571 if (wrq->u.data.length != sizeof(NDIS_802_11_NETWORK_TYPE))
3575 Status = copy_from_user(&NetType, wrq->u.data.pointer, wrq->u.data.length);
3577 if (NetType == Ndis802_11DS)
3578 RTMPSetPhyMode(pAdapter, PHY_11B);
3579 else if (NetType == Ndis802_11OFDM24)
3580 RTMPSetPhyMode(pAdapter, PHY_11BG_MIXED);
3581 else if (NetType == Ndis802_11OFDM5)
3582 RTMPSetPhyMode(pAdapter, PHY_11A);
3585 #ifdef DOT11_N_SUPPORT
3586 if (Status == NDIS_STATUS_SUCCESS)
3587 SetCommonHT(pAdapter);
3588 #endif // DOT11_N_SUPPORT //
3589 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_NETWORK_TYPE_IN_USE (=%d)\n",NetType));
3592 // For WPA PSK PMK key
3593 case RT_OID_802_11_ADD_WPA:
3594 pKey = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
3601 Status = copy_from_user(pKey, wrq->u.data.pointer, wrq->u.data.length);
3602 if (pKey->Length != wrq->u.data.length)
3605 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_ADD_WPA, Failed!!\n"));
3609 if ((pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPAPSK) &&
3610 (pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPA2PSK) &&
3611 (pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPANone) )
3613 Status = -EOPNOTSUPP;
3614 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_ADD_WPA, Failed!! [AuthMode != WPAPSK/WPA2PSK/WPANONE]\n"));
3616 else if ((pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK) ||
3617 (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK) ||
3618 (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPANone) ) // Only for WPA PSK mode
3620 NdisMoveMemory(pAdapter->StaCfg.PMK, &pKey->KeyMaterial, pKey->KeyLength);
3621 // Use RaConfig as PSK agent.
3622 // Start STA supplicant state machine
3623 if (pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPANone)
3624 pAdapter->StaCfg.WpaState = SS_START;
3626 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_ADD_WPA (id=0x%x, Len=%d-byte)\n", pKey->KeyIndex, pKey->KeyLength));
3630 pAdapter->StaCfg.WpaState = SS_NOTUSE;
3631 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_ADD_WPA (id=0x%x, Len=%d-byte)\n", pKey->KeyIndex, pKey->KeyLength));
3636 case OID_802_11_REMOVE_KEY:
3637 pRemoveKey = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
3638 if(pRemoveKey == NULL)
3644 Status = copy_from_user(pRemoveKey, wrq->u.data.pointer, wrq->u.data.length);
3645 if (pRemoveKey->Length != wrq->u.data.length)
3648 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_KEY, Failed!!\n"));
3652 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
3654 RTMPWPARemoveKeyProc(pAdapter, pRemoveKey);
3655 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_KEY, Remove WPA Key!!\n"));
3659 KeyIdx = pRemoveKey->KeyIndex;
3661 if (KeyIdx & 0x80000000)
3663 // Should never set default bit when remove key
3665 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_KEY, Failed!!(Should never set default bit when remove key)\n"));
3669 KeyIdx = KeyIdx & 0x0fffffff;
3673 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_KEY, Failed!!(KeyId[%d] out of range)\n", KeyIdx));
3677 pAdapter->SharedKey[BSS0][KeyIdx].KeyLen = 0;
3678 pAdapter->SharedKey[BSS0][KeyIdx].CipherAlg = CIPHER_NONE;
3679 AsicRemoveSharedKeyEntry(pAdapter, 0, (UCHAR)KeyIdx);
3680 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_KEY (id=0x%x, Len=%d-byte)\n", pRemoveKey->KeyIndex, pRemoveKey->Length));
3688 case OID_802_11_ADD_KEY:
3689 pKey = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
3695 Status = copy_from_user(pKey, wrq->u.data.pointer, wrq->u.data.length);
3696 if (pKey->Length != wrq->u.data.length)
3699 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_KEY, Failed!!\n"));
3703 RTMPAddKey(pAdapter, pKey);
3704 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_KEY (id=0x%x, Len=%d-byte)\n", pKey->KeyIndex, pKey->KeyLength));
3708 case OID_802_11_CONFIGURATION:
3709 if (wrq->u.data.length != sizeof(NDIS_802_11_CONFIGURATION))
3713 Status = copy_from_user(&Config, wrq->u.data.pointer, wrq->u.data.length);
3716 if ((pConfig->BeaconPeriod >= 20) && (pConfig->BeaconPeriod <=400))
3717 pAdapter->CommonCfg.BeaconPeriod = (USHORT) pConfig->BeaconPeriod;
3719 pAdapter->StaActive.AtimWin = (USHORT) pConfig->ATIMWindow;
3720 MAP_KHZ_TO_CHANNEL_ID(pConfig->DSConfig, pAdapter->CommonCfg.Channel);
3722 // Save the channel on MlmeAux for CntlOidRTBssidProc used.
3724 pAdapter->MlmeAux.Channel = pAdapter->CommonCfg.Channel;
3726 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_CONFIGURATION (BeacnPeriod=%ld,AtimW=%ld,Ch=%d)\n",
3727 pConfig->BeaconPeriod, pConfig->ATIMWindow, pAdapter->CommonCfg.Channel));
3728 // Config has changed
3729 pAdapter->bConfigChanged = TRUE;
3732 #ifdef DOT11_N_SUPPORT
3733 case RT_OID_802_11_SET_HT_PHYMODE:
3734 if (wrq->u.data.length != sizeof(OID_SET_HT_PHYMODE))
3738 POID_SET_HT_PHYMODE pHTPhyMode = &HT_PhyMode;
3740 Status = copy_from_user(&HT_PhyMode, wrq->u.data.pointer, wrq->u.data.length);
3741 DBGPRINT(RT_DEBUG_TRACE, ("Set::pHTPhyMode (PhyMode = %d,TransmitNo = %d, HtMode = %d, ExtOffset = %d , MCS = %d, BW = %d, STBC = %d, SHORTGI = %d) \n",
3742 pHTPhyMode->PhyMode, pHTPhyMode->TransmitNo,pHTPhyMode->HtMode,pHTPhyMode->ExtOffset,
3743 pHTPhyMode->MCS, pHTPhyMode->BW, pHTPhyMode->STBC, pHTPhyMode->SHORTGI));
3744 if (pAdapter->CommonCfg.PhyMode >= PHY_11ABGN_MIXED)
3745 RTMPSetHT(pAdapter, pHTPhyMode);
3747 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_SET_HT_PHYMODE(MCS=%d,BW=%d,SGI=%d,STBC=%d)\n",
3748 pAdapter->StaCfg.HTPhyMode.field.MCS, pAdapter->StaCfg.HTPhyMode.field.BW, pAdapter->StaCfg.HTPhyMode.field.ShortGI,
3749 pAdapter->StaCfg.HTPhyMode.field.STBC));
3751 #endif // DOT11_N_SUPPORT //
3752 case RT_OID_802_11_SET_APSD_SETTING:
3753 if (wrq->u.data.length != sizeof(ULONG))
3758 Status = copy_from_user(&apsd, wrq->u.data.pointer, wrq->u.data.length);
3760 /*-------------------------------------------------------------------
3761 |B31~B7 | B6~B5 | B4 | B3 | B2 | B1 | B0 |
3762 ---------------------------------------------------------------------
3763 | Rsvd | Max SP Len | AC_VO | AC_VI | AC_BK | AC_BE | APSD Capable |
3764 ---------------------------------------------------------------------*/
3765 pAdapter->CommonCfg.bAPSDCapable = (apsd & 0x00000001) ? TRUE : FALSE;
3766 pAdapter->CommonCfg.bAPSDAC_BE = ((apsd & 0x00000002) >> 1) ? TRUE : FALSE;
3767 pAdapter->CommonCfg.bAPSDAC_BK = ((apsd & 0x00000004) >> 2) ? TRUE : FALSE;
3768 pAdapter->CommonCfg.bAPSDAC_VI = ((apsd & 0x00000008) >> 3) ? TRUE : FALSE;
3769 pAdapter->CommonCfg.bAPSDAC_VO = ((apsd & 0x00000010) >> 4) ? TRUE : FALSE;
3770 pAdapter->CommonCfg.MaxSPLength = (UCHAR)((apsd & 0x00000060) >> 5);
3772 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,
3773 pAdapter->CommonCfg.bAPSDAC_BE, pAdapter->CommonCfg.bAPSDAC_BK, pAdapter->CommonCfg.bAPSDAC_VI, pAdapter->CommonCfg.bAPSDAC_VO, pAdapter->CommonCfg.MaxSPLength));
3777 case RT_OID_802_11_SET_APSD_PSM:
3778 if (wrq->u.data.length != sizeof(ULONG))
3782 // Driver needs to notify AP when PSM changes
3783 Status = copy_from_user(&pAdapter->CommonCfg.bAPSDForcePowerSave, wrq->u.data.pointer, wrq->u.data.length);
3784 if (pAdapter->CommonCfg.bAPSDForcePowerSave != pAdapter->StaCfg.Psm)
3786 MlmeSetPsmBit(pAdapter, pAdapter->CommonCfg.bAPSDForcePowerSave);
3787 RTMPSendNullFrame(pAdapter, pAdapter->CommonCfg.TxRate, TRUE);
3789 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_SET_APSD_PSM (bAPSDForcePowerSave:%d)\n", pAdapter->CommonCfg.bAPSDForcePowerSave));
3793 case RT_OID_802_11_SET_WMM:
3794 if (wrq->u.data.length != sizeof(BOOLEAN))
3798 Status = copy_from_user(&pAdapter->CommonCfg.bWmmCapable, wrq->u.data.pointer, wrq->u.data.length);
3799 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_SET_WMM (=%d) \n", pAdapter->CommonCfg.bWmmCapable));
3803 case OID_802_11_DISASSOCIATE:
3805 // Set NdisRadioStateOff to TRUE, instead of called MlmeRadioOff.
3806 // Later on, NDIS_802_11_BSSID_LIST_EX->NumberOfItems should be 0
3807 // when query OID_802_11_BSSID_LIST.
3809 // TRUE: NumberOfItems will set to 0.
3810 // FALSE: NumberOfItems no change.
3812 pAdapter->CommonCfg.NdisRadioStateOff = TRUE;
3813 // Set to immediately send the media disconnect event
3814 pAdapter->MlmeAux.CurrReqIsFromNdis = TRUE;
3815 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_DISASSOCIATE \n"));
3817 if (INFRA_ON(pAdapter))
3819 if (pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE)
3821 RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
3822 DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
3825 MlmeEnqueue(pAdapter,
3826 MLME_CNTL_STATE_MACHINE,
3827 OID_802_11_DISASSOCIATE,
3831 StateMachineTouched = TRUE;
3835 #ifdef DOT11_N_SUPPORT
3836 case RT_OID_802_11_SET_IMME_BA_CAP:
3837 if (wrq->u.data.length != sizeof(OID_BACAP_STRUC))
3841 OID_BACAP_STRUC Orde ;
3842 Status = copy_from_user(&Orde, wrq->u.data.pointer, wrq->u.data.length);
3843 if (Orde.Policy > BA_NOTUSE)
3845 Status = NDIS_STATUS_INVALID_DATA;
3847 else if (Orde.Policy == BA_NOTUSE)
3849 pAdapter->CommonCfg.BACapability.field.Policy = BA_NOTUSE;
3850 pAdapter->CommonCfg.BACapability.field.MpduDensity = Orde.MpduDensity;
3851 pAdapter->CommonCfg.DesiredHtPhy.MpduDensity = Orde.MpduDensity;
3852 pAdapter->CommonCfg.DesiredHtPhy.AmsduEnable = Orde.AmsduEnable;
3853 pAdapter->CommonCfg.DesiredHtPhy.AmsduSize= Orde.AmsduSize;
3854 pAdapter->CommonCfg.DesiredHtPhy.MimoPs= Orde.MMPSmode;
3855 pAdapter->CommonCfg.BACapability.field.MMPSmode = Orde.MMPSmode;
3857 pAdapter->CommonCfg.HtCapability.HtCapInfo.MimoPs = Orde.MMPSmode;
3858 pAdapter->CommonCfg.HtCapability.HtCapInfo.AMsduSize = Orde.AmsduSize;
3859 pAdapter->CommonCfg.HtCapability.HtCapParm.MpduDensity = Orde.MpduDensity;
3863 pAdapter->CommonCfg.BACapability.field.AutoBA = Orde.AutoBA;
3864 pAdapter->CommonCfg.BACapability.field.Policy = IMMED_BA; // we only support immediate BA.
3865 pAdapter->CommonCfg.BACapability.field.MpduDensity = Orde.MpduDensity;
3866 pAdapter->CommonCfg.DesiredHtPhy.MpduDensity = Orde.MpduDensity;
3867 pAdapter->CommonCfg.DesiredHtPhy.AmsduEnable = Orde.AmsduEnable;
3868 pAdapter->CommonCfg.DesiredHtPhy.AmsduSize= Orde.AmsduSize;
3869 pAdapter->CommonCfg.DesiredHtPhy.MimoPs = Orde.MMPSmode;
3870 pAdapter->CommonCfg.BACapability.field.MMPSmode = Orde.MMPSmode;
3873 pAdapter->CommonCfg.HtCapability.HtCapInfo.MimoPs = Orde.MMPSmode;
3874 pAdapter->CommonCfg.HtCapability.HtCapInfo.AMsduSize = Orde.AmsduSize;
3875 pAdapter->CommonCfg.HtCapability.HtCapParm.MpduDensity = Orde.MpduDensity;
3877 if (pAdapter->CommonCfg.BACapability.field.RxBAWinLimit > MAX_RX_REORDERBUF)
3878 pAdapter->CommonCfg.BACapability.field.RxBAWinLimit = MAX_RX_REORDERBUF;
3882 pAdapter->CommonCfg.REGBACapability.word = pAdapter->CommonCfg.BACapability.word;
3883 DBGPRINT(RT_DEBUG_TRACE, ("Set::(Orde.AutoBA = %d) (Policy=%d)(ReBAWinLimit=%d)(TxBAWinLimit=%d)(AutoMode=%d)\n",Orde.AutoBA, pAdapter->CommonCfg.BACapability.field.Policy,
3884 pAdapter->CommonCfg.BACapability.field.RxBAWinLimit,pAdapter->CommonCfg.BACapability.field.TxBAWinLimit, pAdapter->CommonCfg.BACapability.field.AutoBA));
3885 DBGPRINT(RT_DEBUG_TRACE, ("Set::(MimoPs = %d)(AmsduEnable = %d) (AmsduSize=%d)(MpduDensity=%d)\n",pAdapter->CommonCfg.DesiredHtPhy.MimoPs, pAdapter->CommonCfg.DesiredHtPhy.AmsduEnable,
3886 pAdapter->CommonCfg.DesiredHtPhy.AmsduSize, pAdapter->CommonCfg.DesiredHtPhy.MpduDensity));
3890 case RT_OID_802_11_ADD_IMME_BA:
3891 DBGPRINT(RT_DEBUG_TRACE, (" Set :: RT_OID_802_11_ADD_IMME_BA \n"));
3892 if (wrq->u.data.length != sizeof(OID_ADD_BA_ENTRY))
3897 OID_ADD_BA_ENTRY BA;
3898 MAC_TABLE_ENTRY *pEntry;
3900 Status = copy_from_user(&BA, wrq->u.data.pointer, wrq->u.data.length);
3903 Status = NDIS_STATUS_INVALID_DATA;
3908 //BATableInsertEntry
3909 //As ad-hoc mode, BA pair is not limited to only BSSID. so add via OID.
3911 // in ad hoc mode, when adding BA pair, we should insert this entry into MACEntry too
3912 pEntry = MacTableLookup(pAdapter, BA.MACAddr);
3915 DBGPRINT(RT_DEBUG_TRACE, ("RT_OID_802_11_ADD_IMME_BA. break on no connection.----:%x:%x\n", BA.MACAddr[4], BA.MACAddr[5]));
3918 if (BA.IsRecipient == FALSE)
3920 if (pEntry->bIAmBadAtheros == TRUE)
3921 pAdapter->CommonCfg.BACapability.field.RxBAWinLimit = 0x10;
3923 BAOriSessionSetUp(pAdapter, pEntry, index, 0, 100, TRUE);
3927 //BATableInsertEntry(pAdapter, pEntry->Aid, BA.MACAddr, 0, 0xffff, BA.TID, BA.nMSDU, BA.IsRecipient);
3930 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_ADD_IMME_BA. Rec = %d. Mac = %x:%x:%x:%x:%x:%x . \n",
3931 BA.IsRecipient, BA.MACAddr[0], BA.MACAddr[1], BA.MACAddr[2], BA.MACAddr[2]
3932 , BA.MACAddr[4], BA.MACAddr[5]));
3937 case RT_OID_802_11_TEAR_IMME_BA:
3938 DBGPRINT(RT_DEBUG_TRACE, ("Set :: RT_OID_802_11_TEAR_IMME_BA \n"));
3939 if (wrq->u.data.length != sizeof(OID_ADD_BA_ENTRY))
3943 POID_ADD_BA_ENTRY pBA;
3944 MAC_TABLE_ENTRY *pEntry;
3946 pBA = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
3950 DBGPRINT(RT_DEBUG_TRACE, ("Set :: RT_OID_802_11_TEAR_IMME_BA kmalloc() can't allocate enough memory\n"));
3951 Status = NDIS_STATUS_FAILURE;
3955 Status = copy_from_user(pBA, wrq->u.data.pointer, wrq->u.data.length);
3956 DBGPRINT(RT_DEBUG_TRACE, ("Set :: RT_OID_802_11_TEAR_IMME_BA(TID=%d, bAllTid=%d)\n", pBA->TID, pBA->bAllTid));
3958 if (!pBA->bAllTid && (pBA->TID > NUM_OF_TID))
3960 Status = NDIS_STATUS_INVALID_DATA;
3964 if (pBA->IsRecipient == FALSE)
3966 pEntry = MacTableLookup(pAdapter, pBA->MACAddr);
3967 DBGPRINT(RT_DEBUG_TRACE, (" pBA->IsRecipient == FALSE\n"));
3970 DBGPRINT(RT_DEBUG_TRACE, (" pBA->pEntry\n"));
3971 BAOriSessionTearDown(pAdapter, pEntry->Aid, pBA->TID, FALSE, TRUE);
3974 DBGPRINT(RT_DEBUG_TRACE, ("Set :: Not found pEntry \n"));
3978 pEntry = MacTableLookup(pAdapter, pBA->MACAddr);
3981 BARecSessionTearDown( pAdapter, (UCHAR)pEntry->Aid, pBA->TID, TRUE);
3984 DBGPRINT(RT_DEBUG_TRACE, ("Set :: Not found pEntry \n"));
3990 #endif // DOT11_N_SUPPORT //
3992 // For WPA_SUPPLICANT to set static wep key
3993 case OID_802_11_ADD_WEP:
3994 pWepKey = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
3999 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_WEP, Failed!!\n"));
4002 Status = copy_from_user(pWepKey, wrq->u.data.pointer, wrq->u.data.length);
4006 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_WEP, Failed (length mismatch)!!\n"));
4010 KeyIdx = pWepKey->KeyIndex & 0x0fffffff;
4011 // KeyIdx must be 0 ~ 3
4015 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_WEP, Failed (KeyIdx must be smaller than 4)!!\n"));
4019 UCHAR CipherAlg = 0;
4022 // set key material and key length
4023 NdisZeroMemory(pAdapter->SharedKey[BSS0][KeyIdx].Key, 16);
4024 pAdapter->SharedKey[BSS0][KeyIdx].KeyLen = (UCHAR) pWepKey->KeyLength;
4025 NdisMoveMemory(pAdapter->SharedKey[BSS0][KeyIdx].Key, &pWepKey->KeyMaterial, pWepKey->KeyLength);
4027 switch(pWepKey->KeyLength)
4030 CipherAlg = CIPHER_WEP64;
4033 CipherAlg = CIPHER_WEP128;
4036 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_WEP, only support CIPHER_WEP64(len:5) & CIPHER_WEP128(len:13)!!\n"));
4040 pAdapter->SharedKey[BSS0][KeyIdx].CipherAlg = CipherAlg;
4042 // Default key for tx (shared key)
4043 if (pWepKey->KeyIndex & 0x80000000)
4045 // set key material and key length
4046 NdisZeroMemory(pAdapter->StaCfg.DesireSharedKey[KeyIdx].Key, 16);
4047 pAdapter->StaCfg.DesireSharedKey[KeyIdx].KeyLen = (UCHAR) pWepKey->KeyLength;
4048 NdisMoveMemory(pAdapter->StaCfg.DesireSharedKey[KeyIdx].Key, &pWepKey->KeyMaterial, pWepKey->KeyLength);
4049 pAdapter->StaCfg.DesireSharedKeyId = KeyIdx;
4050 pAdapter->StaCfg.DesireSharedKey[KeyIdx].CipherAlg = CipherAlg;
4051 pAdapter->StaCfg.DefaultKeyId = (UCHAR) KeyIdx;
4054 if ((pAdapter->StaCfg.WpaSupplicantUP != 0) &&
4055 (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA))
4057 Key = pWepKey->KeyMaterial;
4059 // Set Group key material to Asic
4060 AsicAddSharedKeyEntry(pAdapter, BSS0, KeyIdx, CipherAlg, Key, NULL, NULL);
4062 // Update WCID attribute table and IVEIV table for this group key table
4063 RTMPAddWcidAttributeEntry(pAdapter, BSS0, KeyIdx, CipherAlg, NULL);
4065 STA_PORT_SECURED(pAdapter);
4067 // Indicate Connected for GUI
4068 pAdapter->IndicateMediaState = NdisMediaStateConnected;
4070 else if (pAdapter->StaCfg.PortSecured == WPA_802_1X_PORT_SECURED)
4072 Key = pAdapter->SharedKey[BSS0][KeyIdx].Key;
4074 // Set key material and cipherAlg to Asic
4075 AsicAddSharedKeyEntry(pAdapter, BSS0, KeyIdx, CipherAlg, Key, NULL, NULL);
4077 if (pWepKey->KeyIndex & 0x80000000)
4079 PMAC_TABLE_ENTRY pEntry = &pAdapter->MacTab.Content[BSSID_WCID];
4080 // Assign group key info
4081 RTMPAddWcidAttributeEntry(pAdapter, BSS0, KeyIdx, CipherAlg, NULL);
4082 // Assign pairwise key info
4083 RTMPAddWcidAttributeEntry(pAdapter, BSS0, KeyIdx, CipherAlg, pEntry);
4086 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"));
4091 case OID_SET_COUNTERMEASURES:
4092 if (wrq->u.data.length != sizeof(int))
4097 Status = copy_from_user(&enabled, wrq->u.data.pointer, wrq->u.data.length);
4099 pAdapter->StaCfg.bBlockAssoc = TRUE;
4101 // WPA MIC error should block association attempt for 60 seconds
4102 pAdapter->StaCfg.bBlockAssoc = FALSE;
4103 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_SET_COUNTERMEASURES bBlockAssoc=%s\n", pAdapter->StaCfg.bBlockAssoc ? "TRUE":"FALSE"));
4106 case RT_OID_WPA_SUPPLICANT_SUPPORT:
4107 if (wrq->u.data.length != sizeof(UCHAR))
4111 Status = copy_from_user(&wpa_supplicant_enable, wrq->u.data.pointer, wrq->u.data.length);
4112 pAdapter->StaCfg.WpaSupplicantUP = wpa_supplicant_enable;
4113 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_WPA_SUPPLICANT_SUPPORT (=%d)\n", pAdapter->StaCfg.WpaSupplicantUP));
4116 case OID_802_11_DEAUTHENTICATION:
4117 if (wrq->u.data.length != sizeof(MLME_DEAUTH_REQ_STRUCT))
4121 MLME_DEAUTH_REQ_STRUCT *pInfo;
4122 MLME_QUEUE_ELEM *MsgElem = (MLME_QUEUE_ELEM *) kmalloc(sizeof(MLME_QUEUE_ELEM), MEM_ALLOC_FLAG);
4124 pInfo = (MLME_DEAUTH_REQ_STRUCT *) MsgElem->Msg;
4125 Status = copy_from_user(pInfo, wrq->u.data.pointer, wrq->u.data.length);
4126 MlmeDeauthReqAction(pAdapter, MsgElem);
4129 if (INFRA_ON(pAdapter))
4131 LinkDown(pAdapter, FALSE);
4132 pAdapter->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
4134 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_DEAUTHENTICATION (Reason=%d)\n", pInfo->Reason));
4137 case OID_802_11_DROP_UNENCRYPTED:
4138 if (wrq->u.data.length != sizeof(int))
4143 Status = copy_from_user(&enabled, wrq->u.data.pointer, wrq->u.data.length);
4145 pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED;
4147 pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
4148 NdisAcquireSpinLock(&pAdapter->MacTabLock);
4149 pAdapter->MacTab.Content[BSSID_WCID].PortSecured = pAdapter->StaCfg.PortSecured;
4150 NdisReleaseSpinLock(&pAdapter->MacTabLock);
4151 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_DROP_UNENCRYPTED (=%d)\n", enabled));
4154 case OID_802_11_SET_IEEE8021X:
4155 if (wrq->u.data.length != sizeof(BOOLEAN))
4159 Status = copy_from_user(&IEEE8021xState, wrq->u.data.pointer, wrq->u.data.length);
4160 pAdapter->StaCfg.IEEE8021X = IEEE8021xState;
4161 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_SET_IEEE8021X (=%d)\n", IEEE8021xState));
4164 case OID_802_11_SET_IEEE8021X_REQUIRE_KEY:
4165 if (wrq->u.data.length != sizeof(BOOLEAN))
4169 Status = copy_from_user(&IEEE8021x_required_keys, wrq->u.data.pointer, wrq->u.data.length);
4170 pAdapter->StaCfg.IEEE8021x_required_keys = IEEE8021x_required_keys;
4171 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_SET_IEEE8021X_REQUIRE_KEY (%d)\n", IEEE8021x_required_keys));
4174 case OID_802_11_PMKID:
4175 pPmkId = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
4177 if(pPmkId == NULL) {
4181 Status = copy_from_user(pPmkId, wrq->u.data.pointer, wrq->u.data.length);
4183 // check the PMKID information
4184 if (pPmkId->BSSIDInfoCount == 0)
4185 NdisZeroMemory(pAdapter->StaCfg.SavedPMK, sizeof(BSSID_INFO)*PMKID_NO);
4188 PBSSID_INFO pBssIdInfo;
4192 for (BssIdx = 0; BssIdx < pPmkId->BSSIDInfoCount; BssIdx++)
4194 // point to the indexed BSSID_INFO structure
4195 pBssIdInfo = (PBSSID_INFO) ((PUCHAR) pPmkId + 2 * sizeof(UINT) + BssIdx * sizeof(BSSID_INFO));
4196 // Find the entry in the saved data base.
4197 for (CachedIdx = 0; CachedIdx < pAdapter->StaCfg.SavedPMKNum; CachedIdx++)
4199 // compare the BSSID
4200 if (NdisEqualMemory(pBssIdInfo->BSSID, pAdapter->StaCfg.SavedPMK[CachedIdx].BSSID, sizeof(NDIS_802_11_MAC_ADDRESS)))
4204 // Found, replace it
4205 if (CachedIdx < PMKID_NO)
4207 DBGPRINT(RT_DEBUG_OFF, ("Update OID_802_11_PMKID, idx = %d\n", CachedIdx));
4208 NdisMoveMemory(&pAdapter->StaCfg.SavedPMK[CachedIdx], pBssIdInfo, sizeof(BSSID_INFO));
4209 pAdapter->StaCfg.SavedPMKNum++;
4211 // Not found, replace the last one
4214 // Randomly replace one
4215 CachedIdx = (pBssIdInfo->BSSID[5] % PMKID_NO);
4216 DBGPRINT(RT_DEBUG_OFF, ("Update OID_802_11_PMKID, idx = %d\n", CachedIdx));
4217 NdisMoveMemory(&pAdapter->StaCfg.SavedPMK[CachedIdx], pBssIdInfo, sizeof(BSSID_INFO));
4225 DBGPRINT(RT_DEBUG_TRACE, ("Set::unknown IOCTL's subcmd = 0x%08x\n", cmd));
4226 Status = -EOPNOTSUPP;
4234 INT RTMPQueryInformation(
4235 IN PRTMP_ADAPTER pAdapter,
4236 IN OUT struct ifreq *rq,
4239 struct iwreq *wrq = (struct iwreq *) rq;
4240 NDIS_802_11_BSSID_LIST_EX *pBssidList = NULL;
4241 PNDIS_WLAN_BSSID_EX pBss;
4242 NDIS_802_11_SSID Ssid;
4243 NDIS_802_11_CONFIGURATION *pConfiguration = NULL;
4244 RT_802_11_LINK_STATUS *pLinkStatus = NULL;
4245 RT_802_11_STA_CONFIG *pStaConfig = NULL;
4246 NDIS_802_11_STATISTICS *pStatistics = NULL;
4247 NDIS_802_11_RTS_THRESHOLD RtsThresh;
4248 NDIS_802_11_FRAGMENTATION_THRESHOLD FragThresh;
4249 NDIS_802_11_POWER_MODE PowerMode;
4250 NDIS_802_11_NETWORK_INFRASTRUCTURE BssType;
4251 RT_802_11_PREAMBLE PreamType;
4252 NDIS_802_11_AUTHENTICATION_MODE AuthMode;
4253 NDIS_802_11_WEP_STATUS WepStatus;
4254 NDIS_MEDIA_STATE MediaState;
4255 ULONG BssBufSize, ulInfo=0, NetworkTypeList[4], apsd = 0;
4257 PUCHAR pBuf = NULL, pPtr;
4258 INT Status = NDIS_STATUS_SUCCESS;
4259 UINT we_version_compiled;
4260 UCHAR i, Padding = 0;
4262 UCHAR driverVersion[8];
4263 OID_SET_HT_PHYMODE *pHTPhyMode = NULL;
4267 case RT_OID_DEVICE_NAME:
4268 wrq->u.data.length = sizeof(STA_NIC_DEVICE_NAME);
4269 Status = copy_to_user(wrq->u.data.pointer, STA_NIC_DEVICE_NAME, wrq->u.data.length);
4271 case RT_OID_VERSION_INFO:
4272 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_VERSION_INFO \n"));
4273 wrq->u.data.length = 8*sizeof(UCHAR);
4274 sprintf(&driverVersion[0], "%s", STA_DRIVER_VERSION);
4275 driverVersion[7] = '\0';
4276 if (copy_to_user(wrq->u.data.pointer, &driverVersion, wrq->u.data.length))
4281 case OID_802_11_BSSID_LIST:
4282 if (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
4285 * Still scanning, indicate the caller should try again.
4287 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_BSSID_LIST (Still scanning)\n"));
4290 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_BSSID_LIST (%d BSS returned)\n",pAdapter->ScanTab.BssNr));
4291 pAdapter->StaCfg.bScanReqIsFromWebUI = FALSE;
4292 // Claculate total buffer size required
4293 BssBufSize = sizeof(ULONG);
4295 for (i = 0; i < pAdapter->ScanTab.BssNr; i++)
4297 // Align pointer to 4 bytes boundary.
4298 //Padding = 4 - (pAdapter->ScanTab.BssEntry[i].VarIELen & 0x0003);
4301 BssBufSize += (sizeof(NDIS_WLAN_BSSID_EX) - 1 + sizeof(NDIS_802_11_FIXED_IEs) + pAdapter->ScanTab.BssEntry[i].VarIELen + Padding);
4304 // For safety issue, we add 256 bytes just in case
4306 // Allocate the same size as passed from higher layer
4307 pBuf = kmalloc(BssBufSize, MEM_ALLOC_FLAG);
4313 // Init 802_11_BSSID_LIST_EX structure
4314 NdisZeroMemory(pBuf, BssBufSize);
4315 pBssidList = (PNDIS_802_11_BSSID_LIST_EX) pBuf;
4316 pBssidList->NumberOfItems = pAdapter->ScanTab.BssNr;
4318 // Calculate total buffer length
4319 BssLen = 4; // Consist of NumberOfItems
4320 // Point to start of NDIS_WLAN_BSSID_EX
4321 // pPtr = pBuf + sizeof(ULONG);
4322 pPtr = (PUCHAR) &pBssidList->Bssid[0];
4323 for (i = 0; i < pAdapter->ScanTab.BssNr; i++)
4325 pBss = (PNDIS_WLAN_BSSID_EX) pPtr;
4326 NdisMoveMemory(&pBss->MacAddress, &pAdapter->ScanTab.BssEntry[i].Bssid, MAC_ADDR_LEN);
4327 if ((pAdapter->ScanTab.BssEntry[i].Hidden == 1) && (pAdapter->StaCfg.bShowHiddenSSID == FALSE))
4330 // We must return this SSID during 4way handshaking, otherwise Aegis will failed to parse WPA infomation
4331 // and then failed to send EAPOl farame.
4333 if ((pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA) && (pAdapter->StaCfg.PortSecured != WPA_802_1X_PORT_SECURED))
4335 pBss->Ssid.SsidLength = pAdapter->ScanTab.BssEntry[i].SsidLen;
4336 NdisMoveMemory(pBss->Ssid.Ssid, pAdapter->ScanTab.BssEntry[i].Ssid, pAdapter->ScanTab.BssEntry[i].SsidLen);
4339 pBss->Ssid.SsidLength = 0;
4343 pBss->Ssid.SsidLength = pAdapter->ScanTab.BssEntry[i].SsidLen;
4344 NdisMoveMemory(pBss->Ssid.Ssid, pAdapter->ScanTab.BssEntry[i].Ssid, pAdapter->ScanTab.BssEntry[i].SsidLen);
4346 pBss->Privacy = pAdapter->ScanTab.BssEntry[i].Privacy;
4347 pBss->Rssi = pAdapter->ScanTab.BssEntry[i].Rssi - pAdapter->BbpRssiToDbmDelta;
4348 pBss->NetworkTypeInUse = NetworkTypeInUseSanity(&pAdapter->ScanTab.BssEntry[i]);
4349 pBss->Configuration.Length = sizeof(NDIS_802_11_CONFIGURATION);
4350 pBss->Configuration.BeaconPeriod = pAdapter->ScanTab.BssEntry[i].BeaconPeriod;
4351 pBss->Configuration.ATIMWindow = pAdapter->ScanTab.BssEntry[i].AtimWin;
4353 MAP_CHANNEL_ID_TO_KHZ(pAdapter->ScanTab.BssEntry[i].Channel, pBss->Configuration.DSConfig);
4355 if (pAdapter->ScanTab.BssEntry[i].BssType == BSS_INFRA)
4356 pBss->InfrastructureMode = Ndis802_11Infrastructure;
4358 pBss->InfrastructureMode = Ndis802_11IBSS;
4360 NdisMoveMemory(pBss->SupportedRates, pAdapter->ScanTab.BssEntry[i].SupRate, pAdapter->ScanTab.BssEntry[i].SupRateLen);
4361 NdisMoveMemory(pBss->SupportedRates + pAdapter->ScanTab.BssEntry[i].SupRateLen,
4362 pAdapter->ScanTab.BssEntry[i].ExtRate,
4363 pAdapter->ScanTab.BssEntry[i].ExtRateLen);
4365 if (pAdapter->ScanTab.BssEntry[i].VarIELen == 0)
4367 pBss->IELength = sizeof(NDIS_802_11_FIXED_IEs);
4368 NdisMoveMemory(pBss->IEs, &pAdapter->ScanTab.BssEntry[i].FixIEs, sizeof(NDIS_802_11_FIXED_IEs));
4369 pPtr = pPtr + sizeof(NDIS_WLAN_BSSID_EX) - 1 + sizeof(NDIS_802_11_FIXED_IEs);
4373 pBss->IELength = (ULONG)(sizeof(NDIS_802_11_FIXED_IEs) + pAdapter->ScanTab.BssEntry[i].VarIELen);
4374 pPtr = pPtr + sizeof(NDIS_WLAN_BSSID_EX) - 1 + sizeof(NDIS_802_11_FIXED_IEs);
4375 NdisMoveMemory(pBss->IEs, &pAdapter->ScanTab.BssEntry[i].FixIEs, sizeof(NDIS_802_11_FIXED_IEs));
4376 NdisMoveMemory(pBss->IEs + sizeof(NDIS_802_11_FIXED_IEs), pAdapter->ScanTab.BssEntry[i].VarIEs, pAdapter->ScanTab.BssEntry[i].VarIELen);
4377 pPtr += pAdapter->ScanTab.BssEntry[i].VarIELen;
4379 pBss->Length = (ULONG)(sizeof(NDIS_WLAN_BSSID_EX) - 1 + sizeof(NDIS_802_11_FIXED_IEs) + pAdapter->ScanTab.BssEntry[i].VarIELen + Padding);
4381 #if WIRELESS_EXT < 17
4382 if ((BssLen + pBss->Length) < wrq->u.data.length)
4383 BssLen += pBss->Length;
4386 pBssidList->NumberOfItems = i;
4390 BssLen += pBss->Length;
4394 #if WIRELESS_EXT < 17
4395 wrq->u.data.length = BssLen;
4397 if (BssLen > wrq->u.data.length)
4403 wrq->u.data.length = BssLen;
4405 Status = copy_to_user(wrq->u.data.pointer, pBssidList, BssLen);
4408 case OID_802_3_CURRENT_ADDRESS:
4409 wrq->u.data.length = MAC_ADDR_LEN;
4410 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CurrentAddress, wrq->u.data.length);
4412 case OID_GEN_MEDIA_CONNECT_STATUS:
4413 if (pAdapter->IndicateMediaState == NdisMediaStateConnected)
4414 MediaState = NdisMediaStateConnected;
4416 MediaState = NdisMediaStateDisconnected;
4418 wrq->u.data.length = sizeof(NDIS_MEDIA_STATE);
4419 Status = copy_to_user(wrq->u.data.pointer, &MediaState, wrq->u.data.length);
4421 case OID_802_11_BSSID:
4422 if (INFRA_ON(pAdapter) || ADHOC_ON(pAdapter))
4424 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.Bssid, sizeof(NDIS_802_11_MAC_ADDRESS));
4429 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_BSSID(=EMPTY)\n"));
4433 case OID_802_11_SSID:
4434 NdisZeroMemory(&Ssid, sizeof(NDIS_802_11_SSID));
4435 NdisZeroMemory(Ssid.Ssid, MAX_LEN_OF_SSID);
4436 Ssid.SsidLength = pAdapter->CommonCfg.SsidLen;
4437 memcpy(Ssid.Ssid, pAdapter->CommonCfg.Ssid, Ssid.SsidLength);
4438 wrq->u.data.length = sizeof(NDIS_802_11_SSID);
4439 Status = copy_to_user(wrq->u.data.pointer, &Ssid, wrq->u.data.length);
4440 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_SSID (Len=%d, ssid=%s)\n", Ssid.SsidLength,Ssid.Ssid));
4442 case RT_OID_802_11_QUERY_LINK_STATUS:
4443 pLinkStatus = (RT_802_11_LINK_STATUS *) kmalloc(sizeof(RT_802_11_LINK_STATUS), MEM_ALLOC_FLAG);
4446 pLinkStatus->CurrTxRate = RateIdTo500Kbps[pAdapter->CommonCfg.TxRate]; // unit : 500 kbps
4447 pLinkStatus->ChannelQuality = pAdapter->Mlme.ChannelQuality;
4448 pLinkStatus->RxByteCount = pAdapter->RalinkCounters.ReceivedByteCount;
4449 pLinkStatus->TxByteCount = pAdapter->RalinkCounters.TransmittedByteCount;
4450 pLinkStatus->CentralChannel = pAdapter->CommonCfg.CentralChannel;
4451 wrq->u.data.length = sizeof(RT_802_11_LINK_STATUS);
4452 Status = copy_to_user(wrq->u.data.pointer, pLinkStatus, wrq->u.data.length);
4454 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_LINK_STATUS\n"));
4458 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_LINK_STATUS(kmalloc failed)\n"));
4462 case OID_802_11_CONFIGURATION:
4463 pConfiguration = (NDIS_802_11_CONFIGURATION *) kmalloc(sizeof(NDIS_802_11_CONFIGURATION), MEM_ALLOC_FLAG);
4466 pConfiguration->Length = sizeof(NDIS_802_11_CONFIGURATION);
4467 pConfiguration->BeaconPeriod = pAdapter->CommonCfg.BeaconPeriod;
4468 pConfiguration->ATIMWindow = pAdapter->StaActive.AtimWin;
4469 MAP_CHANNEL_ID_TO_KHZ(pAdapter->CommonCfg.Channel, pConfiguration->DSConfig);
4470 wrq->u.data.length = sizeof(NDIS_802_11_CONFIGURATION);
4471 Status = copy_to_user(wrq->u.data.pointer, pConfiguration, wrq->u.data.length);
4472 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_CONFIGURATION(BeaconPeriod=%ld,AtimW=%ld,Channel=%d) \n",
4473 pConfiguration->BeaconPeriod, pConfiguration->ATIMWindow, pAdapter->CommonCfg.Channel));
4474 kfree(pConfiguration);
4478 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_CONFIGURATION(kmalloc failed)\n"));
4482 case RT_OID_802_11_SNR_0:
4483 if ((pAdapter->StaCfg.LastSNR0 > 0))
4485 ulInfo = ((0xeb - pAdapter->StaCfg.LastSNR0) * 3) / 16 ;
4486 wrq->u.data.length = sizeof(ulInfo);
4487 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4488 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_SNR_0(0x=%lx)\n", ulInfo));
4493 case RT_OID_802_11_SNR_1:
4494 if ((pAdapter->Antenna.field.RxPath > 1) &&
4495 (pAdapter->StaCfg.LastSNR1 > 0))
4497 ulInfo = ((0xeb - pAdapter->StaCfg.LastSNR1) * 3) / 16 ;
4498 wrq->u.data.length = sizeof(ulInfo);
4499 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4500 DBGPRINT(RT_DEBUG_TRACE,("Query::RT_OID_802_11_SNR_1(0x=%lx)\n",ulInfo));
4504 DBGPRINT(RT_DEBUG_TRACE,("Query::RT_OID_802_11_SNR_1(pAdapter->StaCfg.LastSNR1=%d)\n",pAdapter->StaCfg.LastSNR1));
4506 case OID_802_11_RSSI_TRIGGER:
4507 ulInfo = pAdapter->StaCfg.RssiSample.LastRssi0 - pAdapter->BbpRssiToDbmDelta;
4508 wrq->u.data.length = sizeof(ulInfo);
4509 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4510 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_RSSI_TRIGGER(=%ld)\n", ulInfo));
4512 case OID_802_11_RSSI:
4513 case RT_OID_802_11_RSSI:
4514 ulInfo = pAdapter->StaCfg.RssiSample.LastRssi0;
4515 wrq->u.data.length = sizeof(ulInfo);
4516 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4518 case RT_OID_802_11_RSSI_1:
4519 ulInfo = pAdapter->StaCfg.RssiSample.LastRssi1;
4520 wrq->u.data.length = sizeof(ulInfo);
4521 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4523 case RT_OID_802_11_RSSI_2:
4524 ulInfo = pAdapter->StaCfg.RssiSample.LastRssi2;
4525 wrq->u.data.length = sizeof(ulInfo);
4526 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4528 case OID_802_11_STATISTICS:
4529 pStatistics = (NDIS_802_11_STATISTICS *) kmalloc(sizeof(NDIS_802_11_STATISTICS), MEM_ALLOC_FLAG);
4532 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_STATISTICS \n"));
4533 // add the most up-to-date h/w raw counters into software counters
4534 NICUpdateRawCounters(pAdapter);
4536 // Sanity check for calculation of sucessful count
4537 if (pAdapter->WlanCounters.TransmittedFragmentCount.QuadPart < pAdapter->WlanCounters.RetryCount.QuadPart)
4538 pAdapter->WlanCounters.TransmittedFragmentCount.QuadPart = pAdapter->WlanCounters.RetryCount.QuadPart;
4540 pStatistics->TransmittedFragmentCount.QuadPart = pAdapter->WlanCounters.TransmittedFragmentCount.QuadPart;
4541 pStatistics->MulticastTransmittedFrameCount.QuadPart = pAdapter->WlanCounters.MulticastTransmittedFrameCount.QuadPart;
4542 pStatistics->FailedCount.QuadPart = pAdapter->WlanCounters.FailedCount.QuadPart;
4543 pStatistics->RetryCount.QuadPart = pAdapter->WlanCounters.RetryCount.QuadPart;
4544 pStatistics->MultipleRetryCount.QuadPart = pAdapter->WlanCounters.MultipleRetryCount.QuadPart;
4545 pStatistics->RTSSuccessCount.QuadPart = pAdapter->WlanCounters.RTSSuccessCount.QuadPart;
4546 pStatistics->RTSFailureCount.QuadPart = pAdapter->WlanCounters.RTSFailureCount.QuadPart;
4547 pStatistics->ACKFailureCount.QuadPart = pAdapter->WlanCounters.ACKFailureCount.QuadPart;
4548 pStatistics->FrameDuplicateCount.QuadPart = pAdapter->WlanCounters.FrameDuplicateCount.QuadPart;
4549 pStatistics->ReceivedFragmentCount.QuadPart = pAdapter->WlanCounters.ReceivedFragmentCount.QuadPart;
4550 pStatistics->MulticastReceivedFrameCount.QuadPart = pAdapter->WlanCounters.MulticastReceivedFrameCount.QuadPart;
4552 pStatistics->FCSErrorCount = pAdapter->RalinkCounters.RealFcsErrCount;
4554 pStatistics->FCSErrorCount.QuadPart = pAdapter->WlanCounters.FCSErrorCount.QuadPart;
4555 pStatistics->FrameDuplicateCount.u.LowPart = pAdapter->WlanCounters.FrameDuplicateCount.u.LowPart / 100;
4557 wrq->u.data.length = sizeof(NDIS_802_11_STATISTICS);
4558 Status = copy_to_user(wrq->u.data.pointer, pStatistics, wrq->u.data.length);
4563 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_STATISTICS(kmalloc failed)\n"));
4567 case OID_GEN_RCV_OK:
4568 ulInfo = pAdapter->Counters8023.GoodReceives;
4569 wrq->u.data.length = sizeof(ulInfo);
4570 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4572 case OID_GEN_RCV_NO_BUFFER:
4573 ulInfo = pAdapter->Counters8023.RxNoBuffer;
4574 wrq->u.data.length = sizeof(ulInfo);
4575 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4577 case RT_OID_802_11_PHY_MODE:
4578 ulInfo = (ULONG)pAdapter->CommonCfg.PhyMode;
4579 wrq->u.data.length = sizeof(ulInfo);
4580 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4581 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_PHY_MODE (=%ld)\n", ulInfo));
4583 case RT_OID_802_11_STA_CONFIG:
4584 pStaConfig = (RT_802_11_STA_CONFIG *) kmalloc(sizeof(RT_802_11_STA_CONFIG), MEM_ALLOC_FLAG);
4587 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_STA_CONFIG\n"));
4588 pStaConfig->EnableTxBurst = pAdapter->CommonCfg.bEnableTxBurst;
4589 pStaConfig->EnableTurboRate = 0;
4590 pStaConfig->UseBGProtection = pAdapter->CommonCfg.UseBGProtection;
4591 pStaConfig->UseShortSlotTime = pAdapter->CommonCfg.bUseShortSlotTime;
4592 //pStaConfig->AdhocMode = pAdapter->StaCfg.AdhocMode;
4593 pStaConfig->HwRadioStatus = (pAdapter->StaCfg.bHwRadio == TRUE) ? 1 : 0;
4594 pStaConfig->Rsv1 = 0;
4595 pStaConfig->SystemErrorBitmap = pAdapter->SystemErrorBitmap;
4596 wrq->u.data.length = sizeof(RT_802_11_STA_CONFIG);
4597 Status = copy_to_user(wrq->u.data.pointer, pStaConfig, wrq->u.data.length);
4602 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_STA_CONFIG(kmalloc failed)\n"));
4606 case OID_802_11_RTS_THRESHOLD:
4607 RtsThresh = pAdapter->CommonCfg.RtsThreshold;
4608 wrq->u.data.length = sizeof(RtsThresh);
4609 Status = copy_to_user(wrq->u.data.pointer, &RtsThresh, wrq->u.data.length);
4610 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_RTS_THRESHOLD(=%ld)\n", RtsThresh));
4612 case OID_802_11_FRAGMENTATION_THRESHOLD:
4613 FragThresh = pAdapter->CommonCfg.FragmentThreshold;
4614 if (pAdapter->CommonCfg.bUseZeroToDisableFragment == TRUE)
4616 wrq->u.data.length = sizeof(FragThresh);
4617 Status = copy_to_user(wrq->u.data.pointer, &FragThresh, wrq->u.data.length);
4618 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_FRAGMENTATION_THRESHOLD(=%ld)\n", FragThresh));
4620 case OID_802_11_POWER_MODE:
4621 PowerMode = pAdapter->StaCfg.WindowsPowerMode;
4622 wrq->u.data.length = sizeof(PowerMode);
4623 Status = copy_to_user(wrq->u.data.pointer, &PowerMode, wrq->u.data.length);
4624 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_POWER_MODE(=%d)\n", PowerMode));
4626 case RT_OID_802_11_RADIO:
4627 RadioState = (BOOLEAN) pAdapter->StaCfg.bSwRadio;
4628 wrq->u.data.length = sizeof(RadioState);
4629 Status = copy_to_user(wrq->u.data.pointer, &RadioState, wrq->u.data.length);
4630 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_RADIO (=%d)\n", RadioState));
4632 case OID_802_11_INFRASTRUCTURE_MODE:
4633 if (pAdapter->StaCfg.BssType == BSS_ADHOC)
4634 BssType = Ndis802_11IBSS;
4635 else if (pAdapter->StaCfg.BssType == BSS_INFRA)
4636 BssType = Ndis802_11Infrastructure;
4637 else if (pAdapter->StaCfg.BssType == BSS_MONITOR)
4638 BssType = Ndis802_11Monitor;
4640 BssType = Ndis802_11AutoUnknown;
4642 wrq->u.data.length = sizeof(BssType);
4643 Status = copy_to_user(wrq->u.data.pointer, &BssType, wrq->u.data.length);
4644 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_INFRASTRUCTURE_MODE(=%d)\n", BssType));
4646 case RT_OID_802_11_PREAMBLE:
4647 PreamType = pAdapter->CommonCfg.TxPreamble;
4648 wrq->u.data.length = sizeof(PreamType);
4649 Status = copy_to_user(wrq->u.data.pointer, &PreamType, wrq->u.data.length);
4650 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_PREAMBLE(=%d)\n", PreamType));
4652 case OID_802_11_AUTHENTICATION_MODE:
4653 AuthMode = pAdapter->StaCfg.AuthMode;
4654 wrq->u.data.length = sizeof(AuthMode);
4655 Status = copy_to_user(wrq->u.data.pointer, &AuthMode, wrq->u.data.length);
4656 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_AUTHENTICATION_MODE(=%d)\n", AuthMode));
4658 case OID_802_11_WEP_STATUS:
4659 WepStatus = pAdapter->StaCfg.WepStatus;
4660 wrq->u.data.length = sizeof(WepStatus);
4661 Status = copy_to_user(wrq->u.data.pointer, &WepStatus, wrq->u.data.length);
4662 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_WEP_STATUS(=%d)\n", WepStatus));
4664 case OID_802_11_TX_POWER_LEVEL:
4665 wrq->u.data.length = sizeof(ULONG);
4666 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.TxPower, wrq->u.data.length);
4667 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_TX_POWER_LEVEL %x\n",pAdapter->CommonCfg.TxPower));
4669 case RT_OID_802_11_TX_POWER_LEVEL_1:
4670 wrq->u.data.length = sizeof(ULONG);
4671 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.TxPowerPercentage, wrq->u.data.length);
4672 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_TX_POWER_LEVEL_1 (=%ld)\n", pAdapter->CommonCfg.TxPowerPercentage));
4674 case OID_802_11_NETWORK_TYPES_SUPPORTED:
4675 if ((pAdapter->RfIcType == RFIC_2850) || (pAdapter->RfIcType == RFIC_2750))
4677 NetworkTypeList[0] = 3; // NumberOfItems = 3
4678 NetworkTypeList[1] = Ndis802_11DS; // NetworkType[1] = 11b
4679 NetworkTypeList[2] = Ndis802_11OFDM24; // NetworkType[2] = 11g
4680 NetworkTypeList[3] = Ndis802_11OFDM5; // NetworkType[3] = 11a
4681 wrq->u.data.length = 16;
4682 Status = copy_to_user(wrq->u.data.pointer, &NetworkTypeList[0], wrq->u.data.length);
4686 NetworkTypeList[0] = 2; // NumberOfItems = 2
4687 NetworkTypeList[1] = Ndis802_11DS; // NetworkType[1] = 11b
4688 NetworkTypeList[2] = Ndis802_11OFDM24; // NetworkType[2] = 11g
4689 wrq->u.data.length = 12;
4690 Status = copy_to_user(wrq->u.data.pointer, &NetworkTypeList[0], wrq->u.data.length);
4692 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_NETWORK_TYPES_SUPPORTED\n"));
4694 case OID_802_11_NETWORK_TYPE_IN_USE:
4695 wrq->u.data.length = sizeof(ULONG);
4696 if (pAdapter->CommonCfg.PhyMode == PHY_11A)
4697 ulInfo = Ndis802_11OFDM5;
4698 else if ((pAdapter->CommonCfg.PhyMode == PHY_11BG_MIXED) || (pAdapter->CommonCfg.PhyMode == PHY_11G))
4699 ulInfo = Ndis802_11OFDM24;
4701 ulInfo = Ndis802_11DS;
4702 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4704 case RT_OID_802_11_QUERY_LAST_RX_RATE:
4705 ulInfo = (ULONG)pAdapter->LastRxRate;
4706 wrq->u.data.length = sizeof(ulInfo);
4707 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4708 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_LAST_RX_RATE (=%ld)\n", ulInfo));
4710 case RT_OID_802_11_QUERY_LAST_TX_RATE:
4711 //ulInfo = (ULONG)pAdapter->LastTxRate;
4712 ulInfo = (ULONG)pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.word;
4713 wrq->u.data.length = sizeof(ulInfo);
4714 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4715 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_LAST_TX_RATE (=%lx)\n", ulInfo));
4717 case RT_OID_802_11_QUERY_EEPROM_VERSION:
4718 wrq->u.data.length = sizeof(ULONG);
4719 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->EepromVersion, wrq->u.data.length);
4721 case RT_OID_802_11_QUERY_FIRMWARE_VERSION:
4722 wrq->u.data.length = sizeof(ULONG);
4723 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->FirmwareVersion, wrq->u.data.length);
4725 case RT_OID_802_11_QUERY_NOISE_LEVEL:
4726 wrq->u.data.length = sizeof(UCHAR);
4727 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->BbpWriteLatch[66], wrq->u.data.length);
4728 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_NOISE_LEVEL (=%d)\n", pAdapter->BbpWriteLatch[66]));
4730 case RT_OID_802_11_EXTRA_INFO:
4731 wrq->u.data.length = sizeof(ULONG);
4732 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->ExtraInfo, wrq->u.data.length);
4733 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_EXTRA_INFO (=%ld)\n", pAdapter->ExtraInfo));
4735 case RT_OID_WE_VERSION_COMPILED:
4736 wrq->u.data.length = sizeof(UINT);
4737 we_version_compiled = WIRELESS_EXT;
4738 Status = copy_to_user(wrq->u.data.pointer, &we_version_compiled, wrq->u.data.length);
4740 case RT_OID_802_11_QUERY_APSD_SETTING:
4741 apsd = (pAdapter->CommonCfg.bAPSDCapable | (pAdapter->CommonCfg.bAPSDAC_BE << 1) | (pAdapter->CommonCfg.bAPSDAC_BK << 2)
4742 | (pAdapter->CommonCfg.bAPSDAC_VI << 3) | (pAdapter->CommonCfg.bAPSDAC_VO << 4) | (pAdapter->CommonCfg.MaxSPLength << 5));
4744 wrq->u.data.length = sizeof(ULONG);
4745 Status = copy_to_user(wrq->u.data.pointer, &apsd, wrq->u.data.length);
4746 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",
4747 apsd,pAdapter->CommonCfg.bAPSDCapable,pAdapter->CommonCfg.bAPSDAC_BE,pAdapter->CommonCfg.bAPSDAC_BK,pAdapter->CommonCfg.bAPSDAC_VI,pAdapter->CommonCfg.bAPSDAC_VO,pAdapter->CommonCfg.MaxSPLength));
4749 case RT_OID_802_11_QUERY_APSD_PSM:
4750 wrq->u.data.length = sizeof(ULONG);
4751 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.bAPSDForcePowerSave, wrq->u.data.length);
4752 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_APSD_PSM (=%d)\n", pAdapter->CommonCfg.bAPSDForcePowerSave));
4754 case RT_OID_802_11_QUERY_WMM:
4755 wrq->u.data.length = sizeof(BOOLEAN);
4756 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.bWmmCapable, wrq->u.data.length);
4757 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_WMM (=%d)\n", pAdapter->CommonCfg.bWmmCapable));
4759 case RT_OID_NEW_DRIVER:
4762 wrq->u.data.length = sizeof(UCHAR);
4763 Status = copy_to_user(wrq->u.data.pointer, &enabled, wrq->u.data.length);
4764 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_NEW_DRIVER (=%d)\n", enabled));
4767 case RT_OID_WPA_SUPPLICANT_SUPPORT:
4768 wrq->u.data.length = sizeof(UCHAR);
4769 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->StaCfg.WpaSupplicantUP, wrq->u.data.length);
4770 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_WPA_SUPPLICANT_SUPPORT (=%d)\n", pAdapter->StaCfg.WpaSupplicantUP));
4772 case RT_OID_DRIVER_DEVICE_NAME:
4773 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_DRIVER_DEVICE_NAME \n"));
4774 wrq->u.data.length = 16;
4775 if (copy_to_user(wrq->u.data.pointer, pAdapter->StaCfg.dev_name, wrq->u.data.length))
4780 case RT_OID_802_11_QUERY_HT_PHYMODE:
4781 pHTPhyMode = (OID_SET_HT_PHYMODE *) kmalloc(sizeof(OID_SET_HT_PHYMODE), MEM_ALLOC_FLAG);
4784 pHTPhyMode->PhyMode = pAdapter->CommonCfg.PhyMode;
4785 pHTPhyMode->HtMode = (UCHAR)pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.field.MODE;
4786 pHTPhyMode->BW = (UCHAR)pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.field.BW;
4787 pHTPhyMode->MCS= (UCHAR)pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.field.MCS;
4788 pHTPhyMode->SHORTGI= (UCHAR)pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.field.ShortGI;
4789 pHTPhyMode->STBC= (UCHAR)pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.field.STBC;
4791 pHTPhyMode->ExtOffset = ((pAdapter->CommonCfg.CentralChannel < pAdapter->CommonCfg.Channel) ? (EXTCHA_BELOW) : (EXTCHA_ABOVE));
4792 wrq->u.data.length = sizeof(OID_SET_HT_PHYMODE);
4793 if (copy_to_user(wrq->u.data.pointer, pHTPhyMode, wrq->u.data.length))
4797 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_HT_PHYMODE (PhyMode = %d, MCS =%d, BW = %d, STBC = %d, ExtOffset=%d)\n",
4798 pHTPhyMode->HtMode, pHTPhyMode->MCS, pHTPhyMode->BW, pHTPhyMode->STBC, pHTPhyMode->ExtOffset));
4799 DBGPRINT(RT_DEBUG_TRACE, (" MlmeUpdateTxRates (.word = %x )\n", pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.word));
4803 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_STA_CONFIG(kmalloc failed)\n"));
4807 case RT_OID_802_11_COUNTRY_REGION:
4808 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_COUNTRY_REGION \n"));
4809 wrq->u.data.length = sizeof(ulInfo);
4810 ulInfo = pAdapter->CommonCfg.CountryRegionForABand;
4811 ulInfo = (ulInfo << 8)|(pAdapter->CommonCfg.CountryRegion);
4812 if (copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length))
4817 case RT_OID_802_11_QUERY_DAT_HT_PHYMODE:
4818 pHTPhyMode = (OID_SET_HT_PHYMODE *) kmalloc(sizeof(OID_SET_HT_PHYMODE), MEM_ALLOC_FLAG);
4821 pHTPhyMode->PhyMode = pAdapter->CommonCfg.PhyMode;
4822 pHTPhyMode->HtMode = (UCHAR)pAdapter->CommonCfg.RegTransmitSetting.field.HTMODE;
4823 pHTPhyMode->BW = (UCHAR)pAdapter->CommonCfg.RegTransmitSetting.field.BW;
4824 pHTPhyMode->MCS= (UCHAR)pAdapter->StaCfg.DesiredTransmitSetting.field.MCS;
4825 pHTPhyMode->SHORTGI= (UCHAR)pAdapter->CommonCfg.RegTransmitSetting.field.ShortGI;
4826 pHTPhyMode->STBC= (UCHAR)pAdapter->CommonCfg.RegTransmitSetting.field.STBC;
4828 wrq->u.data.length = sizeof(OID_SET_HT_PHYMODE);
4829 if (copy_to_user(wrq->u.data.pointer, pHTPhyMode, wrq->u.data.length))
4833 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_HT_PHYMODE (PhyMode = %d, MCS =%d, BW = %d, STBC = %d, ExtOffset=%d)\n",
4834 pHTPhyMode->HtMode, pHTPhyMode->MCS, pHTPhyMode->BW, pHTPhyMode->STBC, pHTPhyMode->ExtOffset));
4835 DBGPRINT(RT_DEBUG_TRACE, (" MlmeUpdateTxRates (.word = %x )\n", pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.word));
4839 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_STA_CONFIG(kmalloc failed)\n"));
4843 case RT_OID_QUERY_MULTIPLE_CARD_SUPPORT:
4844 wrq->u.data.length = sizeof(UCHAR);
4846 if (copy_to_user(wrq->u.data.pointer, &i, wrq->u.data.length))
4850 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_QUERY_MULTIPLE_CARD_SUPPORT(=%d) \n", i));
4853 case OID_802_11_BUILD_CHANNEL_EX:
4856 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_BUILD_CHANNEL_EX \n"));
4857 wrq->u.data.length = sizeof(UCHAR);
4858 DBGPRINT(RT_DEBUG_TRACE, ("Doesn't support EXT_BUILD_CHANNEL_LIST.\n"));
4860 Status = copy_to_user(wrq->u.data.pointer, &value, 1);
4861 DBGPRINT(RT_DEBUG_TRACE, ("Status=%d\n", Status));
4865 case OID_802_11_GET_CH_LIST:
4867 PRT_CHANNEL_LIST_INFO pChListBuf;
4869 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_GET_CH_LIST \n"));
4870 if (pAdapter->ChannelListNum == 0)
4872 wrq->u.data.length = 0;
4876 pChListBuf = (RT_CHANNEL_LIST_INFO *) kmalloc(sizeof(RT_CHANNEL_LIST_INFO), MEM_ALLOC_FLAG);
4877 if (pChListBuf == NULL)
4879 wrq->u.data.length = 0;
4883 pChListBuf->ChannelListNum = pAdapter->ChannelListNum;
4884 for (i = 0; i < pChListBuf->ChannelListNum; i++)
4885 pChListBuf->ChannelList[i] = pAdapter->ChannelList[i].Channel;
4887 wrq->u.data.length = sizeof(RT_CHANNEL_LIST_INFO);
4888 Status = copy_to_user(wrq->u.data.pointer, pChListBuf, sizeof(RT_CHANNEL_LIST_INFO));
4889 DBGPRINT(RT_DEBUG_TRACE, ("Status=%d\n", Status));
4896 case OID_802_11_GET_COUNTRY_CODE:
4897 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_GET_COUNTRY_CODE \n"));
4898 wrq->u.data.length = 2;
4899 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.CountryCode, 2);
4900 DBGPRINT(RT_DEBUG_TRACE, ("Status=%d\n", Status));
4903 case OID_802_11_GET_CHANNEL_GEOGRAPHY:
4904 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_GET_CHANNEL_GEOGRAPHY \n"));
4905 wrq->u.data.length = 1;
4906 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.Geography, 1);
4907 DBGPRINT(RT_DEBUG_TRACE, ("Status=%d\n", Status));
4911 DBGPRINT(RT_DEBUG_TRACE, ("Query::unknown IOCTL's subcmd = 0x%08x\n", cmd));
4912 Status = -EOPNOTSUPP;
4918 INT rt28xx_sta_ioctl(
4919 IN struct net_device *net_dev,
4920 IN OUT struct ifreq *rq,
4924 VIRTUAL_ADAPTER *pVirtualAd = NULL;
4925 RTMP_ADAPTER *pAd = NULL;
4926 struct iwreq *wrq = (struct iwreq *) rq;
4927 BOOLEAN StateMachineTouched = FALSE;
4928 INT Status = NDIS_STATUS_SUCCESS;
4931 if (net_dev->priv_flags == INT_MAIN)
4933 pAd = net_dev->ml_priv;
4937 pVirtualAd = net_dev->ml_priv;
4938 pAd = pVirtualAd->RtmpDev->ml_priv;
4940 pObj = (POS_COOKIE) pAd->OS_Cookie;
4944 /* if 1st open fail, pAd will be free;
4945 So the net_dev->ml_priv will be NULL in 2rd open */
4949 //check if the interface is down
4950 if(!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_IN_USE))
4953 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
4958 { // determine this ioctl command is comming from which interface.
4959 pObj->ioctl_if_type = INT_MAIN;
4960 pObj->ioctl_if = MAIN_MBSSID;
4966 DBGPRINT(RT_DEBUG_TRACE, ("IOCTL::SIOCGIFHWADDR\n"));
4967 memcpy(wrq->u.name, pAd->CurrentAddress, ETH_ALEN);
4971 char *name=&wrq->u.name[0];
4972 rt_ioctl_giwname(net_dev, NULL, name, NULL);
4975 case SIOCGIWESSID: //Get ESSID
4977 struct iw_point *essid=&wrq->u.essid;
4978 rt_ioctl_giwessid(net_dev, NULL, essid, essid->pointer);
4981 case SIOCSIWESSID: //Set ESSID
4983 struct iw_point *essid=&wrq->u.essid;
4984 rt_ioctl_siwessid(net_dev, NULL, essid, essid->pointer);
4987 case SIOCSIWNWID: // set network id (the cell)
4988 case SIOCGIWNWID: // get network id
4989 Status = -EOPNOTSUPP;
4991 case SIOCSIWFREQ: //set channel/frequency (Hz)
4993 struct iw_freq *freq=&wrq->u.freq;
4994 rt_ioctl_siwfreq(net_dev, NULL, freq, NULL);
4997 case SIOCGIWFREQ: // get channel/frequency (Hz)
4999 struct iw_freq *freq=&wrq->u.freq;
5000 rt_ioctl_giwfreq(net_dev, NULL, freq, NULL);
5003 case SIOCSIWNICKN: //set node name/nickname
5005 struct iw_point *data=&wrq->u.data;
5006 rt_ioctl_siwnickn(net_dev, NULL, data, NULL);
5009 case SIOCGIWNICKN: //get node name/nickname
5011 struct iw_point *data=&wrq->u.data;
5012 rt_ioctl_giwnickn(net_dev, NULL, data, NULL);
5015 case SIOCGIWRATE: //get default bit rate (bps)
5016 rt_ioctl_giwrate(net_dev, NULL, &wrq->u, NULL);
5018 case SIOCSIWRATE: //set default bit rate (bps)
5019 rt_ioctl_siwrate(net_dev, NULL, &wrq->u, NULL);
5021 case SIOCGIWRTS: // get RTS/CTS threshold (bytes)
5023 struct iw_param *rts=&wrq->u.rts;
5024 rt_ioctl_giwrts(net_dev, NULL, rts, NULL);
5027 case SIOCSIWRTS: //set RTS/CTS threshold (bytes)
5029 struct iw_param *rts=&wrq->u.rts;
5030 rt_ioctl_siwrts(net_dev, NULL, rts, NULL);
5033 case SIOCGIWFRAG: //get fragmentation thr (bytes)
5035 struct iw_param *frag=&wrq->u.frag;
5036 rt_ioctl_giwfrag(net_dev, NULL, frag, NULL);
5039 case SIOCSIWFRAG: //set fragmentation thr (bytes)
5041 struct iw_param *frag=&wrq->u.frag;
5042 rt_ioctl_siwfrag(net_dev, NULL, frag, NULL);
5045 case SIOCGIWENCODE: //get encoding token & mode
5047 struct iw_point *erq=&wrq->u.encoding;
5049 rt_ioctl_giwencode(net_dev, NULL, erq, erq->pointer);
5052 case SIOCSIWENCODE: //set encoding token & mode
5054 struct iw_point *erq=&wrq->u.encoding;
5056 rt_ioctl_siwencode(net_dev, NULL, erq, erq->pointer);
5059 case SIOCGIWAP: //get access point MAC addresses
5061 struct sockaddr *ap_addr=&wrq->u.ap_addr;
5062 rt_ioctl_giwap(net_dev, NULL, ap_addr, ap_addr->sa_data);
5065 case SIOCSIWAP: //set access point MAC addresses
5067 struct sockaddr *ap_addr=&wrq->u.ap_addr;
5068 rt_ioctl_siwap(net_dev, NULL, ap_addr, ap_addr->sa_data);
5071 case SIOCGIWMODE: //get operation mode
5073 __u32 *mode=&wrq->u.mode;
5074 rt_ioctl_giwmode(net_dev, NULL, mode, NULL);
5077 case SIOCSIWMODE: //set operation mode
5079 __u32 *mode=&wrq->u.mode;
5080 rt_ioctl_siwmode(net_dev, NULL, mode, NULL);
5083 case SIOCGIWSENS: //get sensitivity (dBm)
5084 case SIOCSIWSENS: //set sensitivity (dBm)
5085 case SIOCGIWPOWER: //get Power Management settings
5086 case SIOCSIWPOWER: //set Power Management settings
5087 case SIOCGIWTXPOW: //get transmit power (dBm)
5088 case SIOCSIWTXPOW: //set transmit power (dBm)
5089 case SIOCGIWRANGE: //Get range of parameters
5090 case SIOCGIWRETRY: //get retry limits and lifetime
5091 case SIOCSIWRETRY: //set retry limits and lifetime
5092 Status = -EOPNOTSUPP;
5095 subcmd = wrq->u.data.flags;
5096 if( subcmd & OID_GET_SET_TOGGLE)
5097 Status = RTMPSetInformation(pAd, rq, subcmd);
5099 Status = RTMPQueryInformation(pAd, rq, subcmd);
5102 if (wrq->u.data.pointer)
5104 if ( access_ok(VERIFY_WRITE, wrq->u.data.pointer, sizeof(privtab)) != TRUE)
5106 wrq->u.data.length = sizeof(privtab) / sizeof(privtab[0]);
5107 if (copy_to_user(wrq->u.data.pointer, privtab, sizeof(privtab)))
5111 case RTPRIV_IOCTL_SET:
5112 if(access_ok(VERIFY_READ, wrq->u.data.pointer, wrq->u.data.length) != TRUE)
5114 rt_ioctl_setparam(net_dev, NULL, NULL, wrq->u.data.pointer);
5116 case RTPRIV_IOCTL_GSITESURVEY:
5117 RTMPIoctlGetSiteSurvey(pAd, wrq);
5120 case RTPRIV_IOCTL_MAC:
5121 RTMPIoctlMAC(pAd, wrq);
5123 case RTPRIV_IOCTL_E2P:
5124 RTMPIoctlE2PROM(pAd, wrq);
5130 DBGPRINT(RT_DEBUG_ERROR, ("IOCTL::unknown IOCTL's cmd = 0x%08x\n", cmd));
5131 Status = -EOPNOTSUPP;
5135 if(StateMachineTouched) // Upper layer sent a MLME-related operations
5136 RT28XX_MLME_HANDLER(pAd);
5142 ==========================================================================
5146 TRUE if all parameters are OK, FALSE otherwise
5147 ==========================================================================
5150 IN PRTMP_ADAPTER pAdapter,
5153 NDIS_802_11_SSID Ssid, *pSsid=NULL;
5154 BOOLEAN StateMachineTouched = FALSE;
5157 if( strlen(arg) <= MAX_LEN_OF_SSID)
5159 NdisZeroMemory(&Ssid, sizeof(NDIS_802_11_SSID));
5160 if (strlen(arg) != 0)
5162 NdisMoveMemory(Ssid.Ssid, arg, strlen(arg));
5163 Ssid.SsidLength = strlen(arg);
5167 Ssid.SsidLength = 0;
5168 memcpy(Ssid.Ssid, "", 0);
5169 pAdapter->StaCfg.BssType = BSS_INFRA;
5170 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
5171 pAdapter->StaCfg.WepStatus = Ndis802_11EncryptionDisabled;
5175 if (pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE)
5177 RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
5178 DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
5181 pAdapter->MlmeAux.CurrReqIsFromNdis = TRUE;
5182 pAdapter->StaCfg.bScanReqIsFromWebUI = FALSE;
5183 pAdapter->bConfigChanged = TRUE;
5185 MlmeEnqueue(pAdapter,
5186 MLME_CNTL_STATE_MACHINE,
5188 sizeof(NDIS_802_11_SSID),
5191 StateMachineTouched = TRUE;
5192 DBGPRINT(RT_DEBUG_TRACE, ("Set_SSID_Proc::(Len=%d,Ssid=%s)\n", Ssid.SsidLength, Ssid.Ssid));
5197 if (StateMachineTouched) // Upper layer sent a MLME-related operations
5198 RT28XX_MLME_HANDLER(pAdapter);
5205 ==========================================================================
5207 Set WmmCapable Enable or Disable
5209 TRUE if all parameters are OK, FALSE otherwise
5210 ==========================================================================
5212 INT Set_WmmCapable_Proc(
5213 IN PRTMP_ADAPTER pAd,
5216 BOOLEAN bWmmCapable;
5218 bWmmCapable = simple_strtol(arg, 0, 10);
5220 if ((bWmmCapable == 1)
5222 pAd->CommonCfg.bWmmCapable = TRUE;
5223 else if (bWmmCapable == 0)
5224 pAd->CommonCfg.bWmmCapable = FALSE;
5226 return FALSE; //Invalid argument
5228 DBGPRINT(RT_DEBUG_TRACE, ("Set_WmmCapable_Proc::(bWmmCapable=%d)\n",
5229 pAd->CommonCfg.bWmmCapable));
5233 #endif // WMM_SUPPORT //
5236 ==========================================================================
5238 Set Network Type(Infrastructure/Adhoc mode)
5240 TRUE if all parameters are OK, FALSE otherwise
5241 ==========================================================================
5243 INT Set_NetworkType_Proc(
5244 IN PRTMP_ADAPTER pAdapter,
5249 if (strcmp(arg, "Adhoc") == 0)
5251 if (pAdapter->StaCfg.BssType != BSS_ADHOC)
5253 // Config has changed
5254 pAdapter->bConfigChanged = TRUE;
5255 if (MONITOR_ON(pAdapter))
5257 RTMP_IO_WRITE32(pAdapter, RX_FILTR_CFG, STANORMAL);
5258 RTMP_IO_READ32(pAdapter, MAC_SYS_CTRL, &Value);
5260 RTMP_IO_WRITE32(pAdapter, MAC_SYS_CTRL, Value);
5261 OPSTATUS_CLEAR_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED);
5262 pAdapter->StaCfg.bAutoReconnect = TRUE;
5263 LinkDown(pAdapter, FALSE);
5265 if (INFRA_ON(pAdapter))
5267 //BOOLEAN Cancelled;
5268 // Set the AutoReconnectSsid to prevent it reconnect to old SSID
5269 // Since calling this indicate user don't want to connect to that SSID anymore.
5270 pAdapter->MlmeAux.AutoReconnectSsidLen= 32;
5271 NdisZeroMemory(pAdapter->MlmeAux.AutoReconnectSsid, pAdapter->MlmeAux.AutoReconnectSsidLen);
5273 LinkDown(pAdapter, FALSE);
5275 DBGPRINT(RT_DEBUG_TRACE, ("NDIS_STATUS_MEDIA_DISCONNECT Event BB!\n"));
5278 pAdapter->StaCfg.BssType = BSS_ADHOC;
5279 pAdapter->net_dev->type = pAdapter->StaCfg.OriDevType;
5280 DBGPRINT(RT_DEBUG_TRACE, ("===>Set_NetworkType_Proc::(AD-HOC)\n"));
5282 else if (strcmp(arg, "Infra") == 0)
5284 if (pAdapter->StaCfg.BssType != BSS_INFRA)
5286 // Config has changed
5287 pAdapter->bConfigChanged = TRUE;
5288 if (MONITOR_ON(pAdapter))
5290 RTMP_IO_WRITE32(pAdapter, RX_FILTR_CFG, STANORMAL);
5291 RTMP_IO_READ32(pAdapter, MAC_SYS_CTRL, &Value);
5293 RTMP_IO_WRITE32(pAdapter, MAC_SYS_CTRL, Value);
5294 OPSTATUS_CLEAR_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED);
5295 pAdapter->StaCfg.bAutoReconnect = TRUE;
5296 LinkDown(pAdapter, FALSE);
5298 if (ADHOC_ON(pAdapter))
5300 // Set the AutoReconnectSsid to prevent it reconnect to old SSID
5301 // Since calling this indicate user don't want to connect to that SSID anymore.
5302 pAdapter->MlmeAux.AutoReconnectSsidLen= 32;
5303 NdisZeroMemory(pAdapter->MlmeAux.AutoReconnectSsid, pAdapter->MlmeAux.AutoReconnectSsidLen);
5305 LinkDown(pAdapter, FALSE);
5308 pAdapter->StaCfg.BssType = BSS_INFRA;
5309 pAdapter->net_dev->type = pAdapter->StaCfg.OriDevType;
5310 DBGPRINT(RT_DEBUG_TRACE, ("===>Set_NetworkType_Proc::(INFRA)\n"));
5312 pAdapter->StaCfg.BssType = BSS_INFRA;
5314 else if (strcmp(arg, "Monitor") == 0)
5317 BCN_TIME_CFG_STRUC csr;
5318 OPSTATUS_CLEAR_FLAG(pAdapter, fOP_STATUS_INFRA_ON);
5319 OPSTATUS_CLEAR_FLAG(pAdapter, fOP_STATUS_ADHOC_ON);
5320 OPSTATUS_SET_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED);
5321 // disable all periodic state machine
5322 pAdapter->StaCfg.bAutoReconnect = FALSE;
5323 // reset all mlme state machine
5324 RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
5325 DBGPRINT(RT_DEBUG_TRACE, ("fOP_STATUS_MEDIA_STATE_CONNECTED \n"));
5326 if (pAdapter->CommonCfg.CentralChannel == 0)
5328 #ifdef DOT11_N_SUPPORT
5329 if (pAdapter->CommonCfg.PhyMode == PHY_11AN_MIXED)
5330 pAdapter->CommonCfg.CentralChannel = 36;
5332 #endif // DOT11_N_SUPPORT //
5333 pAdapter->CommonCfg.CentralChannel = 6;
5335 #ifdef DOT11_N_SUPPORT
5337 N_ChannelCheck(pAdapter);
5338 #endif // DOT11_N_SUPPORT //
5340 #ifdef DOT11_N_SUPPORT
5341 if (pAdapter->CommonCfg.PhyMode >= PHY_11ABGN_MIXED &&
5342 pAdapter->CommonCfg.RegTransmitSetting.field.BW == BW_40 &&
5343 pAdapter->CommonCfg.RegTransmitSetting.field.EXTCHA == EXTCHA_ABOVE)
5345 // 40MHz ,control channel at lower
5346 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, BBP_R4, &bbpValue);
5347 bbpValue &= (~0x18);
5349 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R4, bbpValue);
5350 pAdapter->CommonCfg.BBPCurrentBW = BW_40;
5351 // RX : control channel at lower
5352 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, BBP_R3, &bbpValue);
5353 bbpValue &= (~0x20);
5354 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R3, bbpValue);
5356 RTMP_IO_READ32(pAdapter, TX_BAND_CFG, &Value);
5357 Value &= 0xfffffffe;
5358 RTMP_IO_WRITE32(pAdapter, TX_BAND_CFG, Value);
5359 pAdapter->CommonCfg.CentralChannel = pAdapter->CommonCfg.Channel + 2;
5360 AsicSwitchChannel(pAdapter, pAdapter->CommonCfg.CentralChannel, FALSE);
5361 AsicLockChannel(pAdapter, pAdapter->CommonCfg.CentralChannel);
5362 DBGPRINT(RT_DEBUG_TRACE, ("BW_40 ,control_channel(%d), CentralChannel(%d) \n",
5363 pAdapter->CommonCfg.Channel,
5364 pAdapter->CommonCfg.CentralChannel));
5366 else if (pAdapter->CommonCfg.PhyMode >= PHY_11ABGN_MIXED &&
5367 pAdapter->CommonCfg.RegTransmitSetting.field.BW == BW_40 &&
5368 pAdapter->CommonCfg.RegTransmitSetting.field.EXTCHA == EXTCHA_BELOW)
5370 // 40MHz ,control channel at upper
5371 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, BBP_R4, &bbpValue);
5372 bbpValue &= (~0x18);
5374 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R4, bbpValue);
5375 pAdapter->CommonCfg.BBPCurrentBW = BW_40;
5376 RTMP_IO_READ32(pAdapter, TX_BAND_CFG, &Value);
5378 RTMP_IO_WRITE32(pAdapter, TX_BAND_CFG, Value);
5380 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, BBP_R3, &bbpValue);
5382 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R3, bbpValue);
5383 pAdapter->CommonCfg.CentralChannel = pAdapter->CommonCfg.Channel - 2;
5384 AsicSwitchChannel(pAdapter, pAdapter->CommonCfg.CentralChannel, FALSE);
5385 AsicLockChannel(pAdapter, pAdapter->CommonCfg.CentralChannel);
5386 DBGPRINT(RT_DEBUG_TRACE, ("BW_40 ,control_channel(%d), CentralChannel(%d) \n",
5387 pAdapter->CommonCfg.Channel,
5388 pAdapter->CommonCfg.CentralChannel));
5391 #endif // DOT11_N_SUPPORT //
5394 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, BBP_R4, &bbpValue);
5395 bbpValue &= (~0x18);
5396 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R4, bbpValue);
5397 pAdapter->CommonCfg.BBPCurrentBW = BW_20;
5398 AsicSwitchChannel(pAdapter, pAdapter->CommonCfg.Channel, FALSE);
5399 AsicLockChannel(pAdapter, pAdapter->CommonCfg.Channel);
5400 DBGPRINT(RT_DEBUG_TRACE, ("BW_20, Channel(%d)\n", pAdapter->CommonCfg.Channel));
5402 // Enable Rx with promiscuous reception
5403 RTMP_IO_WRITE32(pAdapter, RX_FILTR_CFG, 0x3);
5404 // ASIC supporsts sniffer function with replacing RSSI with timestamp.
5405 //RTMP_IO_READ32(pAdapter, MAC_SYS_CTRL, &Value);
5407 //RTMP_IO_WRITE32(pAdapter, MAC_SYS_CTRL, Value);
5409 RTMP_IO_READ32(pAdapter, BCN_TIME_CFG, &csr.word);
5410 csr.field.bBeaconGen = 0;
5411 csr.field.bTBTTEnable = 0;
5412 csr.field.TsfSyncMode = 0;
5413 RTMP_IO_WRITE32(pAdapter, BCN_TIME_CFG, csr.word);
5415 pAdapter->StaCfg.BssType = BSS_MONITOR;
5416 pAdapter->net_dev->type = ARPHRD_IEEE80211_PRISM; //ARPHRD_IEEE80211; // IEEE80211
5417 DBGPRINT(RT_DEBUG_TRACE, ("===>Set_NetworkType_Proc::(MONITOR)\n"));
5420 // Reset Ralink supplicant to not use, it will be set to start when UI set PMK key
5421 pAdapter->StaCfg.WpaState = SS_NOTUSE;
5423 DBGPRINT(RT_DEBUG_TRACE, ("Set_NetworkType_Proc::(NetworkType=%d)\n", pAdapter->StaCfg.BssType));
5429 ==========================================================================
5431 Set Authentication mode
5433 TRUE if all parameters are OK, FALSE otherwise
5434 ==========================================================================
5436 INT Set_AuthMode_Proc(
5437 IN PRTMP_ADAPTER pAdapter,
5440 if ((strcmp(arg, "WEPAUTO") == 0) || (strcmp(arg, "wepauto") == 0))
5441 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeAutoSwitch;
5442 else if ((strcmp(arg, "OPEN") == 0) || (strcmp(arg, "open") == 0))
5443 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
5444 else if ((strcmp(arg, "SHARED") == 0) || (strcmp(arg, "shared") == 0))
5445 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeShared;
5446 else if ((strcmp(arg, "WPAPSK") == 0) || (strcmp(arg, "wpapsk") == 0))
5447 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPAPSK;
5448 else if ((strcmp(arg, "WPANONE") == 0) || (strcmp(arg, "wpanone") == 0))
5449 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPANone;
5450 else if ((strcmp(arg, "WPA2PSK") == 0) || (strcmp(arg, "wpa2psk") == 0))
5451 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA2PSK;
5452 else if ((strcmp(arg, "WPA") == 0) || (strcmp(arg, "wpa") == 0))
5453 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA;
5454 else if ((strcmp(arg, "WPA2") == 0) || (strcmp(arg, "wpa2") == 0))
5455 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA2;
5459 pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED;
5461 DBGPRINT(RT_DEBUG_TRACE, ("Set_AuthMode_Proc::(AuthMode=%d)\n", pAdapter->StaCfg.AuthMode));
5467 ==========================================================================
5471 TRUE if all parameters are OK, FALSE otherwise
5472 ==========================================================================
5474 INT Set_EncrypType_Proc(
5475 IN PRTMP_ADAPTER pAdapter,
5478 if ((strcmp(arg, "NONE") == 0) || (strcmp(arg, "none") == 0))
5480 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
5481 return TRUE; // do nothing
5483 pAdapter->StaCfg.WepStatus = Ndis802_11WEPDisabled;
5484 pAdapter->StaCfg.PairCipher = Ndis802_11WEPDisabled;
5485 pAdapter->StaCfg.GroupCipher = Ndis802_11WEPDisabled;
5487 else if ((strcmp(arg, "WEP") == 0) || (strcmp(arg, "wep") == 0))
5489 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
5490 return TRUE; // do nothing
5492 pAdapter->StaCfg.WepStatus = Ndis802_11WEPEnabled;
5493 pAdapter->StaCfg.PairCipher = Ndis802_11WEPEnabled;
5494 pAdapter->StaCfg.GroupCipher = Ndis802_11WEPEnabled;
5496 else if ((strcmp(arg, "TKIP") == 0) || (strcmp(arg, "tkip") == 0))
5498 if (pAdapter->StaCfg.AuthMode < Ndis802_11AuthModeWPA)
5499 return TRUE; // do nothing
5501 pAdapter->StaCfg.WepStatus = Ndis802_11Encryption2Enabled;
5502 pAdapter->StaCfg.PairCipher = Ndis802_11Encryption2Enabled;
5503 pAdapter->StaCfg.GroupCipher = Ndis802_11Encryption2Enabled;
5505 else if ((strcmp(arg, "AES") == 0) || (strcmp(arg, "aes") == 0))
5507 if (pAdapter->StaCfg.AuthMode < Ndis802_11AuthModeWPA)
5508 return TRUE; // do nothing
5510 pAdapter->StaCfg.WepStatus = Ndis802_11Encryption3Enabled;
5511 pAdapter->StaCfg.PairCipher = Ndis802_11Encryption3Enabled;
5512 pAdapter->StaCfg.GroupCipher = Ndis802_11Encryption3Enabled;
5517 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
5519 DBGPRINT(RT_DEBUG_TRACE, ("Set_EncrypType_Proc::(EncrypType=%d)\n", pAdapter->StaCfg.WepStatus));
5525 ==========================================================================
5529 TRUE if all parameters are OK, FALSE otherwise
5530 ==========================================================================
5532 INT Set_DefaultKeyID_Proc(
5533 IN PRTMP_ADAPTER pAdapter,
5538 KeyIdx = simple_strtol(arg, 0, 10);
5539 if((KeyIdx >= 1 ) && (KeyIdx <= 4))
5540 pAdapter->StaCfg.DefaultKeyId = (UCHAR) (KeyIdx - 1 );
5542 return FALSE; //Invalid argument
5544 DBGPRINT(RT_DEBUG_TRACE, ("Set_DefaultKeyID_Proc::(DefaultKeyID=%d)\n", pAdapter->StaCfg.DefaultKeyId));
5550 ==========================================================================
5554 TRUE if all parameters are OK, FALSE otherwise
5555 ==========================================================================
5558 IN PRTMP_ADAPTER pAdapter,
5563 UCHAR CipherAlg=CIPHER_WEP64;
5565 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
5566 return TRUE; // do nothing
5568 KeyLen = strlen(arg);
5572 case 5: //wep 40 Ascii type
5573 pAdapter->SharedKey[BSS0][0].KeyLen = KeyLen;
5574 memcpy(pAdapter->SharedKey[BSS0][0].Key, arg, KeyLen);
5575 CipherAlg = CIPHER_WEP64;
5576 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key1_Proc::(Key1=%s and type=%s)\n", arg, "Ascii"));
5578 case 10: //wep 40 Hex type
5579 for(i=0; i < KeyLen; i++)
5581 if( !isxdigit(*(arg+i)) )
5582 return FALSE; //Not Hex value;
5584 pAdapter->SharedKey[BSS0][0].KeyLen = KeyLen / 2 ;
5585 AtoH(arg, pAdapter->SharedKey[BSS0][0].Key, KeyLen / 2);
5586 CipherAlg = CIPHER_WEP64;
5587 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key1_Proc::(Key1=%s and type=%s)\n", arg, "Hex"));
5589 case 13: //wep 104 Ascii type
5590 pAdapter->SharedKey[BSS0][0].KeyLen = KeyLen;
5591 memcpy(pAdapter->SharedKey[BSS0][0].Key, arg, KeyLen);
5592 CipherAlg = CIPHER_WEP128;
5593 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key1_Proc::(Key1=%s and type=%s)\n", arg, "Ascii"));
5595 case 26: //wep 104 Hex type
5596 for(i=0; i < KeyLen; i++)
5598 if( !isxdigit(*(arg+i)) )
5599 return FALSE; //Not Hex value;
5601 pAdapter->SharedKey[BSS0][0].KeyLen = KeyLen / 2 ;
5602 AtoH(arg, pAdapter->SharedKey[BSS0][0].Key, KeyLen / 2);
5603 CipherAlg = CIPHER_WEP128;
5604 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key1_Proc::(Key1=%s and type=%s)\n", arg, "Hex"));
5606 default: //Invalid argument
5607 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key1_Proc::Invalid argument (=%s)\n", arg));
5611 pAdapter->SharedKey[BSS0][0].CipherAlg = CipherAlg;
5613 // Set keys (into ASIC)
5614 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
5616 else // Old WEP stuff
5618 AsicAddSharedKeyEntry(pAdapter,
5621 pAdapter->SharedKey[BSS0][0].CipherAlg,
5622 pAdapter->SharedKey[BSS0][0].Key,
5630 ==========================================================================
5635 TRUE if all parameters are OK, FALSE otherwise
5636 ==========================================================================
5639 IN PRTMP_ADAPTER pAdapter,
5644 UCHAR CipherAlg=CIPHER_WEP64;
5646 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
5647 return TRUE; // do nothing
5649 KeyLen = strlen(arg);
5653 case 5: //wep 40 Ascii type
5654 pAdapter->SharedKey[BSS0][1].KeyLen = KeyLen;
5655 memcpy(pAdapter->SharedKey[BSS0][1].Key, arg, KeyLen);
5656 CipherAlg = CIPHER_WEP64;
5657 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key2_Proc::(Key2=%s and type=%s)\n", arg, "Ascii"));
5659 case 10: //wep 40 Hex type
5660 for(i=0; i < KeyLen; i++)
5662 if( !isxdigit(*(arg+i)) )
5663 return FALSE; //Not Hex value;
5665 pAdapter->SharedKey[BSS0][1].KeyLen = KeyLen / 2 ;
5666 AtoH(arg, pAdapter->SharedKey[BSS0][1].Key, KeyLen / 2);
5667 CipherAlg = CIPHER_WEP64;
5668 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key2_Proc::(Key2=%s and type=%s)\n", arg, "Hex"));
5670 case 13: //wep 104 Ascii type
5671 pAdapter->SharedKey[BSS0][1].KeyLen = KeyLen;
5672 memcpy(pAdapter->SharedKey[BSS0][1].Key, arg, KeyLen);
5673 CipherAlg = CIPHER_WEP128;
5674 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key2_Proc::(Key2=%s and type=%s)\n", arg, "Ascii"));
5676 case 26: //wep 104 Hex type
5677 for(i=0; i < KeyLen; i++)
5679 if( !isxdigit(*(arg+i)) )
5680 return FALSE; //Not Hex value;
5682 pAdapter->SharedKey[BSS0][1].KeyLen = KeyLen / 2 ;
5683 AtoH(arg, pAdapter->SharedKey[BSS0][1].Key, KeyLen / 2);
5684 CipherAlg = CIPHER_WEP128;
5685 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key2_Proc::(Key2=%s and type=%s)\n", arg, "Hex"));
5687 default: //Invalid argument
5688 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key2_Proc::Invalid argument (=%s)\n", arg));
5691 pAdapter->SharedKey[BSS0][1].CipherAlg = CipherAlg;
5693 // Set keys (into ASIC)
5694 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
5696 else // Old WEP stuff
5698 AsicAddSharedKeyEntry(pAdapter,
5701 pAdapter->SharedKey[BSS0][1].CipherAlg,
5702 pAdapter->SharedKey[BSS0][1].Key,
5710 ==========================================================================
5714 TRUE if all parameters are OK, FALSE otherwise
5715 ==========================================================================
5718 IN PRTMP_ADAPTER pAdapter,
5723 UCHAR CipherAlg=CIPHER_WEP64;
5725 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
5726 return TRUE; // do nothing
5728 KeyLen = strlen(arg);
5732 case 5: //wep 40 Ascii type
5733 pAdapter->SharedKey[BSS0][2].KeyLen = KeyLen;
5734 memcpy(pAdapter->SharedKey[BSS0][2].Key, arg, KeyLen);
5735 CipherAlg = CIPHER_WEP64;
5736 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key3_Proc::(Key3=%s and type=Ascii)\n", arg));
5738 case 10: //wep 40 Hex type
5739 for(i=0; i < KeyLen; i++)
5741 if( !isxdigit(*(arg+i)) )
5742 return FALSE; //Not Hex value;
5744 pAdapter->SharedKey[BSS0][2].KeyLen = KeyLen / 2 ;
5745 AtoH(arg, pAdapter->SharedKey[BSS0][2].Key, KeyLen / 2);
5746 CipherAlg = CIPHER_WEP64;
5747 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key3_Proc::(Key3=%s and type=Hex)\n", arg));
5749 case 13: //wep 104 Ascii type
5750 pAdapter->SharedKey[BSS0][2].KeyLen = KeyLen;
5751 memcpy(pAdapter->SharedKey[BSS0][2].Key, arg, KeyLen);
5752 CipherAlg = CIPHER_WEP128;
5753 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key3_Proc::(Key3=%s and type=Ascii)\n", arg));
5755 case 26: //wep 104 Hex type
5756 for(i=0; i < KeyLen; i++)
5758 if( !isxdigit(*(arg+i)) )
5759 return FALSE; //Not Hex value;
5761 pAdapter->SharedKey[BSS0][2].KeyLen = KeyLen / 2 ;
5762 AtoH(arg, pAdapter->SharedKey[BSS0][2].Key, KeyLen / 2);
5763 CipherAlg = CIPHER_WEP128;
5764 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key3_Proc::(Key3=%s and type=Hex)\n", arg));
5766 default: //Invalid argument
5767 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key3_Proc::Invalid argument (=%s)\n", arg));
5770 pAdapter->SharedKey[BSS0][2].CipherAlg = CipherAlg;
5772 // Set keys (into ASIC)
5773 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
5775 else // Old WEP stuff
5777 AsicAddSharedKeyEntry(pAdapter,
5780 pAdapter->SharedKey[BSS0][2].CipherAlg,
5781 pAdapter->SharedKey[BSS0][2].Key,
5789 ==========================================================================
5793 TRUE if all parameters are OK, FALSE otherwise
5794 ==========================================================================
5797 IN PRTMP_ADAPTER pAdapter,
5802 UCHAR CipherAlg=CIPHER_WEP64;
5804 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
5805 return TRUE; // do nothing
5807 KeyLen = strlen(arg);
5811 case 5: //wep 40 Ascii type
5812 pAdapter->SharedKey[BSS0][3].KeyLen = KeyLen;
5813 memcpy(pAdapter->SharedKey[BSS0][3].Key, arg, KeyLen);
5814 CipherAlg = CIPHER_WEP64;
5815 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key4_Proc::(Key4=%s and type=%s)\n", arg, "Ascii"));
5817 case 10: //wep 40 Hex type
5818 for(i=0; i < KeyLen; i++)
5820 if( !isxdigit(*(arg+i)) )
5821 return FALSE; //Not Hex value;
5823 pAdapter->SharedKey[BSS0][3].KeyLen = KeyLen / 2 ;
5824 AtoH(arg, pAdapter->SharedKey[BSS0][3].Key, KeyLen / 2);
5825 CipherAlg = CIPHER_WEP64;
5826 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key4_Proc::(Key4=%s and type=%s)\n", arg, "Hex"));
5828 case 13: //wep 104 Ascii type
5829 pAdapter->SharedKey[BSS0][3].KeyLen = KeyLen;
5830 memcpy(pAdapter->SharedKey[BSS0][3].Key, arg, KeyLen);
5831 CipherAlg = CIPHER_WEP128;
5832 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key4_Proc::(Key4=%s and type=%s)\n", arg, "Ascii"));
5834 case 26: //wep 104 Hex type
5835 for(i=0; i < KeyLen; i++)
5837 if( !isxdigit(*(arg+i)) )
5838 return FALSE; //Not Hex value;
5840 pAdapter->SharedKey[BSS0][3].KeyLen = KeyLen / 2 ;
5841 AtoH(arg, pAdapter->SharedKey[BSS0][3].Key, KeyLen / 2);
5842 CipherAlg = CIPHER_WEP128;
5843 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key4_Proc::(Key4=%s and type=%s)\n", arg, "Hex"));
5845 default: //Invalid argument
5846 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key4_Proc::Invalid argument (=%s)\n", arg));
5849 pAdapter->SharedKey[BSS0][3].CipherAlg = CipherAlg;
5851 // Set keys (into ASIC)
5852 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
5854 else // Old WEP stuff
5856 AsicAddSharedKeyEntry(pAdapter,
5859 pAdapter->SharedKey[BSS0][3].CipherAlg,
5860 pAdapter->SharedKey[BSS0][3].Key,
5869 ==========================================================================
5873 TRUE if all parameters are OK, FALSE otherwise
5874 ==========================================================================
5876 INT Set_WPAPSK_Proc(
5877 IN PRTMP_ADAPTER pAdapter,
5880 UCHAR keyMaterial[40];
5882 if ((pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPAPSK) &&
5883 (pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPA2PSK) &&
5884 (pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPANone)
5886 return TRUE; // do nothing
5888 DBGPRINT(RT_DEBUG_TRACE, ("Set_WPAPSK_Proc::(WPAPSK=%s)\n", arg));
5890 NdisZeroMemory(keyMaterial, 40);
5892 if ((strlen(arg) < 8) || (strlen(arg) > 64))
5894 DBGPRINT(RT_DEBUG_TRACE, ("Set failed!!(WPAPSK=%s), WPAPSK key-string required 8 ~ 64 characters \n", arg));
5898 if (strlen(arg) == 64)
5900 AtoH(arg, keyMaterial, 32);
5901 NdisMoveMemory(pAdapter->StaCfg.PMK, keyMaterial, 32);
5906 PasswordHash((char *)arg, pAdapter->MlmeAux.Ssid, pAdapter->MlmeAux.SsidLen, keyMaterial);
5907 NdisMoveMemory(pAdapter->StaCfg.PMK, keyMaterial, 32);
5912 if(pAdapter->StaCfg.BssType == BSS_ADHOC &&
5913 pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPANone)
5915 pAdapter->StaCfg.WpaState = SS_NOTUSE;
5919 // Start STA supplicant state machine
5920 pAdapter->StaCfg.WpaState = SS_START;
5927 ==========================================================================
5929 Set Power Saving mode
5931 TRUE if all parameters are OK, FALSE otherwise
5932 ==========================================================================
5934 INT Set_PSMode_Proc(
5935 IN PRTMP_ADAPTER pAdapter,
5938 if (pAdapter->StaCfg.BssType == BSS_INFRA)
5940 if ((strcmp(arg, "Max_PSP") == 0) ||
5941 (strcmp(arg, "max_psp") == 0) ||
5942 (strcmp(arg, "MAX_PSP") == 0))
5944 // do NOT turn on PSM bit here, wait until MlmeCheckForPsmChange()
5945 // to exclude certain situations.
5946 if (pAdapter->StaCfg.bWindowsACCAMEnable == FALSE)
5947 pAdapter->StaCfg.WindowsPowerMode = Ndis802_11PowerModeMAX_PSP;
5948 pAdapter->StaCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeMAX_PSP;
5949 OPSTATUS_SET_FLAG(pAdapter, fOP_STATUS_RECEIVE_DTIM);
5950 pAdapter->StaCfg.DefaultListenCount = 5;
5953 else if ((strcmp(arg, "Fast_PSP") == 0) ||
5954 (strcmp(arg, "fast_psp") == 0) ||
5955 (strcmp(arg, "FAST_PSP") == 0))
5957 // do NOT turn on PSM bit here, wait until MlmeCheckForPsmChange()
5958 // to exclude certain situations.
5959 OPSTATUS_SET_FLAG(pAdapter, fOP_STATUS_RECEIVE_DTIM);
5960 if (pAdapter->StaCfg.bWindowsACCAMEnable == FALSE)
5961 pAdapter->StaCfg.WindowsPowerMode = Ndis802_11PowerModeFast_PSP;
5962 pAdapter->StaCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeFast_PSP;
5963 pAdapter->StaCfg.DefaultListenCount = 3;
5965 else if ((strcmp(arg, "Legacy_PSP") == 0) ||
5966 (strcmp(arg, "legacy_psp") == 0) ||
5967 (strcmp(arg, "LEGACY_PSP") == 0))
5969 // do NOT turn on PSM bit here, wait until MlmeCheckForPsmChange()
5970 // to exclude certain situations.
5971 OPSTATUS_SET_FLAG(pAdapter, fOP_STATUS_RECEIVE_DTIM);
5972 if (pAdapter->StaCfg.bWindowsACCAMEnable == FALSE)
5973 pAdapter->StaCfg.WindowsPowerMode = Ndis802_11PowerModeLegacy_PSP;
5974 pAdapter->StaCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeLegacy_PSP;
5975 pAdapter->StaCfg.DefaultListenCount = 3;
5979 //Default Ndis802_11PowerModeCAM
5980 // clear PSM bit immediately
5981 MlmeSetPsmBit(pAdapter, PWR_ACTIVE);
5982 OPSTATUS_SET_FLAG(pAdapter, fOP_STATUS_RECEIVE_DTIM);
5983 if (pAdapter->StaCfg.bWindowsACCAMEnable == FALSE)
5984 pAdapter->StaCfg.WindowsPowerMode = Ndis802_11PowerModeCAM;
5985 pAdapter->StaCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeCAM;
5988 DBGPRINT(RT_DEBUG_TRACE, ("Set_PSMode_Proc::(PSMode=%ld)\n", pAdapter->StaCfg.WindowsPowerMode));
5998 ==========================================================================
6000 Set WpaSupport flag.
6002 0: Driver ignore wpa_supplicant.
6003 1: wpa_supplicant initiates scanning and AP selection.
6004 2: driver takes care of scanning, AP selection, and IEEE 802.11 association parameters.
6006 TRUE if all parameters are OK, FALSE otherwise
6007 ==========================================================================
6009 INT Set_Wpa_Support(
6010 IN PRTMP_ADAPTER pAd,
6014 if ( simple_strtol(arg, 0, 10) == 0)
6015 pAd->StaCfg.WpaSupplicantUP = WPA_SUPPLICANT_DISABLE;
6016 else if ( simple_strtol(arg, 0, 10) == 1)
6017 pAd->StaCfg.WpaSupplicantUP = WPA_SUPPLICANT_ENABLE;
6018 else if ( simple_strtol(arg, 0, 10) == 2)
6019 pAd->StaCfg.WpaSupplicantUP = WPA_SUPPLICANT_ENABLE_WITH_WEB_UI;
6021 pAd->StaCfg.WpaSupplicantUP = WPA_SUPPLICANT_DISABLE;
6023 DBGPRINT(RT_DEBUG_TRACE, ("Set_Wpa_Support::(WpaSupplicantUP=%d)\n", pAd->StaCfg.WpaSupplicantUP));
6030 ==========================================================================
6034 pAdapter Pointer to our adapter
6035 wrq Pointer to the ioctl argument
6042 1.) iwpriv ra0 mac 0 ==> read MAC where Addr=0x0
6043 2.) iwpriv ra0 mac 0=12 ==> write MAC where Addr=0x0, value=12
6044 ==========================================================================
6047 IN PRTMP_ADAPTER pAdapter,
6048 IN struct iwreq *wrq)
6056 UCHAR temp[16], temp2[16];
6057 UINT32 macValue = 0;
6061 memset(msg, 0x00, 1024);
6062 if (wrq->u.data.length > 1) //No parameters.
6064 Status = copy_from_user(arg, wrq->u.data.pointer, (wrq->u.data.length > 255) ? 255 : wrq->u.data.length);
6067 //Parsing Read or Write
6072 if ((value = rtstrchr(this_char, '=')) != NULL)
6075 if (!value || !*value)
6078 if(strlen(this_char) > 4)
6081 j = strlen(this_char);
6084 if(this_char[j] > 'f' || this_char[j] < '0')
6089 k = j = strlen(this_char);
6092 this_char[4-k+j] = this_char[j];
6096 this_char[3-k++]='0';
6099 if(strlen(this_char) == 4)
6101 AtoH(this_char, temp, 2);
6102 macAddr = *temp*256 + temp[1];
6103 if (macAddr < 0xFFFF)
6105 RTMP_IO_READ32(pAdapter, macAddr, &macValue);
6106 DBGPRINT(RT_DEBUG_TRACE, ("MacAddr=%lx, MacValue=%x\n", macAddr, macValue));
6107 sprintf(msg+strlen(msg), "[0x%08lX]:%08X ", macAddr , macValue);
6110 {//Invalid parametes, so default printk all bbp
6117 memcpy(&temp2, value, strlen(value));
6118 temp2[strlen(value)] = '\0';
6121 if((strlen(this_char) > 4) || strlen(temp2) > 8)
6124 j = strlen(this_char);
6127 if(this_char[j] > 'f' || this_char[j] < '0')
6134 if(temp2[j] > 'f' || temp2[j] < '0')
6139 k = j = strlen(this_char);
6142 this_char[4-k+j] = this_char[j];
6146 this_char[3-k++]='0';
6150 k = j = strlen(temp2);
6153 temp2[8-k+j] = temp2[j];
6161 AtoH(this_char, temp, 2);
6162 macAddr = *temp*256 + temp[1];
6164 AtoH(temp2, temp, 4);
6165 macValue = *temp*256*256*256 + temp[1]*256*256 + temp[2]*256 + temp[3];
6168 if (macAddr == (HW_DEBUG_SETTING_BASE + 4))
6170 // 0x2bf4: byte0 non-zero: enable R17 tuning, 0: disable R17 tuning
6171 if (macValue & 0x000000ff)
6173 pAdapter->BbpTuning.bEnable = TRUE;
6174 DBGPRINT(RT_DEBUG_TRACE,("turn on R17 tuning\n"));
6179 pAdapter->BbpTuning.bEnable = FALSE;
6180 R66 = 0x26 + GET_LNA_GAIN(pAdapter);
6181 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R66, (0x26 + GET_LNA_GAIN(pAdapter)));
6182 DBGPRINT(RT_DEBUG_TRACE,("turn off R17 tuning, restore to 0x%02x\n", R66));
6187 DBGPRINT(RT_DEBUG_TRACE, ("MacAddr=%02lx, MacValue=0x%x\n", macAddr, macValue));
6189 RTMP_IO_WRITE32(pAdapter, macAddr, macValue);
6190 sprintf(msg+strlen(msg), "[0x%08lX]:%08X ", macAddr, macValue);
6195 if(strlen(msg) == 1)
6196 sprintf(msg+strlen(msg), "===>Error command format!");
6198 // Copy the information into the user buffer
6199 wrq->u.data.length = strlen(msg);
6200 Status = copy_to_user(wrq->u.data.pointer, msg, wrq->u.data.length);
6202 DBGPRINT(RT_DEBUG_TRACE, ("<==RTMPIoctlMAC\n\n"));
6206 ==========================================================================
6210 pAdapter Pointer to our adapter
6211 wrq Pointer to the ioctl argument
6218 1.) iwpriv ra0 e2p 0 ==> read E2PROM where Addr=0x0
6219 2.) iwpriv ra0 e2p 0=1234 ==> write E2PROM where Addr=0x0, value=1234
6220 ==========================================================================
6222 VOID RTMPIoctlE2PROM(
6223 IN PRTMP_ADAPTER pAdapter,
6224 IN struct iwreq *wrq)
6232 UCHAR temp[16], temp2[16];
6237 memset(msg, 0x00, 1024);
6238 if (wrq->u.data.length > 1) //No parameters.
6240 Status = copy_from_user(arg, wrq->u.data.pointer, (wrq->u.data.length > 255) ? 255 : wrq->u.data.length);
6243 //Parsing Read or Write
6250 if ((value = rtstrchr(this_char, '=')) != NULL)
6253 if (!value || !*value)
6257 if(strlen(this_char) > 4)
6260 j = strlen(this_char);
6263 if(this_char[j] > 'f' || this_char[j] < '0')
6268 k = j = strlen(this_char);
6271 this_char[4-k+j] = this_char[j];
6275 this_char[3-k++]='0';
6278 if(strlen(this_char) == 4)
6280 AtoH(this_char, temp, 2);
6281 eepAddr = *temp*256 + temp[1];
6282 if (eepAddr < 0xFFFF)
6284 RT28xx_EEPROM_READ16(pAdapter, eepAddr, eepValue);
6285 sprintf(msg+strlen(msg), "[0x%04X]:0x%04X ", eepAddr , eepValue);
6288 {//Invalid parametes, so default printk all bbp
6295 memcpy(&temp2, value, strlen(value));
6296 temp2[strlen(value)] = '\0';
6299 if((strlen(this_char) > 4) || strlen(temp2) > 8)
6302 j = strlen(this_char);
6305 if(this_char[j] > 'f' || this_char[j] < '0')
6311 if(temp2[j] > 'f' || temp2[j] < '0')
6316 k = j = strlen(this_char);
6319 this_char[4-k+j] = this_char[j];
6323 this_char[3-k++]='0';
6327 k = j = strlen(temp2);
6330 temp2[4-k+j] = temp2[j];
6337 AtoH(this_char, temp, 2);
6338 eepAddr = *temp*256 + temp[1];
6340 AtoH(temp2, temp, 2);
6341 eepValue = *temp*256 + temp[1];
6343 RT28xx_EEPROM_WRITE16(pAdapter, eepAddr, eepValue);
6344 sprintf(msg+strlen(msg), "[0x%02X]:%02X ", eepAddr, eepValue);
6348 if(strlen(msg) == 1)
6349 sprintf(msg+strlen(msg), "===>Error command format!");
6352 // Copy the information into the user buffer
6353 wrq->u.data.length = strlen(msg);
6354 Status = copy_to_user(wrq->u.data.pointer, msg, wrq->u.data.length);
6356 DBGPRINT(RT_DEBUG_TRACE, ("<==RTMPIoctlE2PROM\n"));
6363 INT Set_TGnWifiTest_Proc(
6364 IN PRTMP_ADAPTER pAd,
6367 if (simple_strtol(arg, 0, 10) == 0)
6368 pAd->StaCfg.bTGnWifiTest = FALSE;
6370 pAd->StaCfg.bTGnWifiTest = TRUE;
6372 DBGPRINT(RT_DEBUG_TRACE, ("IF Set_TGnWifiTest_Proc::(bTGnWifiTest=%d)\n", pAd->StaCfg.bTGnWifiTest));
6376 INT Set_LongRetryLimit_Proc(
6377 IN PRTMP_ADAPTER pAdapter,
6380 TX_RTY_CFG_STRUC tx_rty_cfg;
6381 UCHAR LongRetryLimit = (UCHAR)simple_strtol(arg, 0, 10);
6383 RTMP_IO_READ32(pAdapter, TX_RTY_CFG, &tx_rty_cfg.word);
6384 tx_rty_cfg.field.LongRtyLimit = LongRetryLimit;
6385 RTMP_IO_WRITE32(pAdapter, TX_RTY_CFG, tx_rty_cfg.word);
6386 DBGPRINT(RT_DEBUG_TRACE, ("IF Set_LongRetryLimit_Proc::(tx_rty_cfg=0x%x)\n", tx_rty_cfg.word));
6390 INT Set_ShortRetryLimit_Proc(
6391 IN PRTMP_ADAPTER pAdapter,
6394 TX_RTY_CFG_STRUC tx_rty_cfg;
6395 UCHAR ShortRetryLimit = (UCHAR)simple_strtol(arg, 0, 10);
6397 RTMP_IO_READ32(pAdapter, TX_RTY_CFG, &tx_rty_cfg.word);
6398 tx_rty_cfg.field.ShortRtyLimit = ShortRetryLimit;
6399 RTMP_IO_WRITE32(pAdapter, TX_RTY_CFG, tx_rty_cfg.word);
6400 DBGPRINT(RT_DEBUG_TRACE, ("IF Set_ShortRetryLimit_Proc::(tx_rty_cfg=0x%x)\n", tx_rty_cfg.word));