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,
163 #ifdef WPA_SUPPLICANT_SUPPORT
165 IN PRTMP_ADAPTER pAd,
167 #endif // WPA_SUPPLICANT_SUPPORT //
171 IN PRTMP_ADAPTER pAdapter,
172 IN struct iwreq *wrq);
175 IN PRTMP_ADAPTER pAdapter,
176 IN struct iwreq *wrq);
178 VOID RTMPIoctlE2PROM(
179 IN PRTMP_ADAPTER pAdapter,
180 IN struct iwreq *wrq);
184 NDIS_STATUS RTMPWPANoneAddKeyProc(
185 IN PRTMP_ADAPTER pAd,
188 INT Set_FragTest_Proc(
189 IN PRTMP_ADAPTER pAdapter,
192 #ifdef DOT11_N_SUPPORT
193 INT Set_TGnWifiTest_Proc(
194 IN PRTMP_ADAPTER pAd,
196 #endif // DOT11_N_SUPPORT //
198 INT Set_LongRetryLimit_Proc(
199 IN PRTMP_ADAPTER pAdapter,
202 INT Set_ShortRetryLimit_Proc(
203 IN PRTMP_ADAPTER pAdapter,
208 INT (*set_proc)(PRTMP_ADAPTER pAdapter, PUCHAR arg);
209 } *PRTMP_PRIVATE_SET_PROC, RTMP_PRIVATE_SUPPORT_PROC[] = {
210 {"DriverVersion", Set_DriverVersion_Proc},
211 {"CountryRegion", Set_CountryRegion_Proc},
212 {"CountryRegionABand", Set_CountryRegionABand_Proc},
213 {"SSID", Set_SSID_Proc},
214 {"WirelessMode", Set_WirelessMode_Proc},
215 {"TxBurst", Set_TxBurst_Proc},
216 {"TxPreamble", Set_TxPreamble_Proc},
217 {"TxPower", Set_TxPower_Proc},
218 {"Channel", Set_Channel_Proc},
219 {"BGProtection", Set_BGProtection_Proc},
220 {"RTSThreshold", Set_RTSThreshold_Proc},
221 {"FragThreshold", Set_FragThreshold_Proc},
222 #ifdef DOT11_N_SUPPORT
223 {"HtBw", Set_HtBw_Proc},
224 {"HtMcs", Set_HtMcs_Proc},
225 {"HtGi", Set_HtGi_Proc},
226 {"HtOpMode", Set_HtOpMode_Proc},
227 {"HtExtcha", Set_HtExtcha_Proc},
228 {"HtMpduDensity", Set_HtMpduDensity_Proc},
229 {"HtBaWinSize", Set_HtBaWinSize_Proc},
230 {"HtRdg", Set_HtRdg_Proc},
231 {"HtAmsdu", Set_HtAmsdu_Proc},
232 {"HtAutoBa", Set_HtAutoBa_Proc},
233 {"HtBaDecline", Set_BADecline_Proc},
234 {"HtProtect", Set_HtProtect_Proc},
235 {"HtMimoPs", Set_HtMimoPs_Proc},
236 #endif // DOT11_N_SUPPORT //
238 #ifdef AGGREGATION_SUPPORT
239 {"PktAggregate", Set_PktAggregate_Proc},
243 {"WmmCapable", Set_WmmCapable_Proc},
245 {"IEEE80211H", Set_IEEE80211H_Proc},
246 {"NetworkType", Set_NetworkType_Proc},
247 {"AuthMode", Set_AuthMode_Proc},
248 {"EncrypType", Set_EncrypType_Proc},
249 {"DefaultKeyID", Set_DefaultKeyID_Proc},
250 {"Key1", Set_Key1_Proc},
251 {"Key2", Set_Key2_Proc},
252 {"Key3", Set_Key3_Proc},
253 {"Key4", Set_Key4_Proc},
254 {"WPAPSK", Set_WPAPSK_Proc},
255 {"ResetCounter", Set_ResetStatCounter_Proc},
256 {"PSMode", Set_PSMode_Proc},
258 {"Debug", Set_Debug_Proc},
261 #ifdef WPA_SUPPLICANT_SUPPORT
262 {"WpaSupport", Set_Wpa_Support},
263 #endif // WPA_SUPPLICANT_SUPPORT //
267 {"FixedTxMode", Set_FixedTxMode_Proc},
268 #ifdef DOT11_N_SUPPORT
269 {"TGnWifiTest", Set_TGnWifiTest_Proc},
270 {"ForceGF", Set_ForceGF_Proc},
271 #endif // DOT11_N_SUPPORT //
272 {"LongRetry", Set_LongRetryLimit_Proc},
273 {"ShortRetry", Set_ShortRetryLimit_Proc},
279 IN PRTMP_ADAPTER pAd,
280 IN PNDIS_802_11_KEY pKey)
283 MAC_TABLE_ENTRY *pEntry;
285 DBGPRINT(RT_DEBUG_TRACE, ("RTMPAddKey ------>\n"));
287 RTMP_CLEAR_PSFLAG(pAd, fRTMP_PS_CAN_GO_SLEEP);
288 if (RTMP_TEST_PSFLAG(pAd, fRTMP_PS_SET_PCI_CLK_OFF_COMMAND))
290 if (pAd->StaCfg.bRadio == FALSE)
292 RTMP_SET_PSFLAG(pAd, fRTMP_PS_CAN_GO_SLEEP);
295 DBGPRINT(RT_DEBUG_TRACE,("RTMPWPAAddKeyProc1==>\n"));
296 RTMPPCIeLinkCtrlValueRestore(pAd, RESTORE_HALT);
298 pAd->bPCIclkOff = FALSE;
301 if (pAd->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
303 if (pKey->KeyIndex & 0x80000000)
305 if (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPANone)
307 NdisZeroMemory(pAd->StaCfg.PMK, 32);
308 NdisMoveMemory(pAd->StaCfg.PMK, pKey->KeyMaterial, pKey->KeyLength);
312 NdisZeroMemory(&pAd->SharedKey[BSS0][0], sizeof(CIPHER_KEY));
313 pAd->SharedKey[BSS0][0].KeyLen = LEN_TKIP_EK;
314 NdisMoveMemory(pAd->SharedKey[BSS0][0].Key, pKey->KeyMaterial, LEN_TKIP_EK);
315 #ifdef WPA_SUPPLICANT_SUPPORT
316 if (pAd->StaCfg.PairCipher == Ndis802_11Encryption2Enabled)
318 NdisMoveMemory(pAd->SharedKey[BSS0][0].RxMic, pKey->KeyMaterial + LEN_TKIP_EK, LEN_TKIP_TXMICK);
319 NdisMoveMemory(pAd->SharedKey[BSS0][0].TxMic, pKey->KeyMaterial + LEN_TKIP_EK + LEN_TKIP_TXMICK, LEN_TKIP_RXMICK);
322 #endif // WPA_SUPPLICANT_SUPPORT //
324 NdisMoveMemory(pAd->SharedKey[BSS0][0].TxMic, pKey->KeyMaterial + LEN_TKIP_EK, LEN_TKIP_TXMICK);
325 NdisMoveMemory(pAd->SharedKey[BSS0][0].RxMic, pKey->KeyMaterial + LEN_TKIP_EK + LEN_TKIP_TXMICK, LEN_TKIP_RXMICK);
328 // Decide its ChiperAlg
329 if (pAd->StaCfg.PairCipher == Ndis802_11Encryption2Enabled)
330 pAd->SharedKey[BSS0][0].CipherAlg = CIPHER_TKIP;
331 else if (pAd->StaCfg.PairCipher == Ndis802_11Encryption3Enabled)
332 pAd->SharedKey[BSS0][0].CipherAlg = CIPHER_AES;
334 pAd->SharedKey[BSS0][0].CipherAlg = CIPHER_NONE;
336 // Update these related information to MAC_TABLE_ENTRY
337 pEntry = &pAd->MacTab.Content[BSSID_WCID];
338 NdisMoveMemory(pEntry->PairwiseKey.Key, pAd->SharedKey[BSS0][0].Key, LEN_TKIP_EK);
339 NdisMoveMemory(pEntry->PairwiseKey.RxMic, pAd->SharedKey[BSS0][0].RxMic, LEN_TKIP_RXMICK);
340 NdisMoveMemory(pEntry->PairwiseKey.TxMic, pAd->SharedKey[BSS0][0].TxMic, LEN_TKIP_TXMICK);
341 pEntry->PairwiseKey.CipherAlg = pAd->SharedKey[BSS0][0].CipherAlg;
343 // Update pairwise key information to ASIC Shared Key Table
344 AsicAddSharedKeyEntry(pAd,
347 pAd->SharedKey[BSS0][0].CipherAlg,
348 pAd->SharedKey[BSS0][0].Key,
349 pAd->SharedKey[BSS0][0].TxMic,
350 pAd->SharedKey[BSS0][0].RxMic);
352 // Update ASIC WCID attribute table and IVEIV table
353 RTMPAddWcidAttributeEntry(pAd,
356 pAd->SharedKey[BSS0][0].CipherAlg,
359 if (pAd->StaCfg.AuthMode >= Ndis802_11AuthModeWPA2)
361 // set 802.1x port control
362 STA_PORT_SECURED(pAd);
364 // Indicate Connected for GUI
365 pAd->IndicateMediaState = NdisMediaStateConnected;
371 pAd->StaCfg.DefaultKeyId = (pKey->KeyIndex & 0xFF);
372 NdisZeroMemory(&pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId], sizeof(CIPHER_KEY));
373 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].KeyLen = LEN_TKIP_EK;
374 NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].Key, pKey->KeyMaterial, LEN_TKIP_EK);
375 #ifdef WPA_SUPPLICANT_SUPPORT
376 if (pAd->StaCfg.GroupCipher == Ndis802_11Encryption2Enabled)
378 NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].RxMic, pKey->KeyMaterial + LEN_TKIP_EK, LEN_TKIP_TXMICK);
379 NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].TxMic, pKey->KeyMaterial + LEN_TKIP_EK + LEN_TKIP_TXMICK, LEN_TKIP_RXMICK);
382 #endif // WPA_SUPPLICANT_SUPPORT //
384 NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].TxMic, pKey->KeyMaterial + LEN_TKIP_EK, LEN_TKIP_TXMICK);
385 NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].RxMic, pKey->KeyMaterial + LEN_TKIP_EK + LEN_TKIP_TXMICK, LEN_TKIP_RXMICK);
388 // Update Shared Key CipherAlg
389 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg = CIPHER_NONE;
390 if (pAd->StaCfg.GroupCipher == Ndis802_11Encryption2Enabled)
391 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg = CIPHER_TKIP;
392 else if (pAd->StaCfg.GroupCipher == Ndis802_11Encryption3Enabled)
393 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg = CIPHER_AES;
395 // Update group key information to ASIC Shared Key Table
396 AsicAddSharedKeyEntry(pAd,
398 pAd->StaCfg.DefaultKeyId,
399 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg,
400 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].Key,
401 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].TxMic,
402 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].RxMic);
404 // Update ASIC WCID attribute table and IVEIV table
405 RTMPAddWcidAttributeEntry(pAd,
407 pAd->StaCfg.DefaultKeyId,
408 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg,
411 // set 802.1x port control
412 STA_PORT_SECURED(pAd);
414 // Indicate Connected for GUI
415 pAd->IndicateMediaState = NdisMediaStateConnected;
418 else // dynamic WEP from wpa_supplicant
423 if(pKey->KeyLength == 32)
426 KeyIdx = pKey->KeyIndex & 0x0fffffff;
430 // it is a default shared key, for Pairwise key setting
431 if (pKey->KeyIndex & 0x80000000)
433 pEntry = MacTableLookup(pAd, pKey->BSSID);
437 DBGPRINT(RT_DEBUG_TRACE, ("RTMPAddKey: Set Pair-wise Key\n"));
439 // set key material and key length
440 pEntry->PairwiseKey.KeyLen = (UCHAR)pKey->KeyLength;
441 NdisMoveMemory(pEntry->PairwiseKey.Key, &pKey->KeyMaterial, pKey->KeyLength);
444 if (pKey->KeyLength == 5)
445 pEntry->PairwiseKey.CipherAlg = CIPHER_WEP64;
447 pEntry->PairwiseKey.CipherAlg = CIPHER_WEP128;
449 // Add Pair-wise key to Asic
450 AsicAddPairwiseKeyEntry(
454 &pEntry->PairwiseKey);
456 // update WCID attribute table and IVEIV table for this entry
457 RTMPAddWcidAttributeEntry(
460 KeyIdx, // The value may be not zero
461 pEntry->PairwiseKey.CipherAlg,
468 // Default key for tx (shared key)
469 pAd->StaCfg.DefaultKeyId = (UCHAR) KeyIdx;
471 // set key material and key length
472 pAd->SharedKey[BSS0][KeyIdx].KeyLen = (UCHAR) pKey->KeyLength;
473 NdisMoveMemory(pAd->SharedKey[BSS0][KeyIdx].Key, &pKey->KeyMaterial, pKey->KeyLength);
476 if (pKey->KeyLength == 5)
477 pAd->SharedKey[BSS0][KeyIdx].CipherAlg = CIPHER_WEP64;
479 pAd->SharedKey[BSS0][KeyIdx].CipherAlg = CIPHER_WEP128;
481 CipherAlg = pAd->SharedKey[BSS0][KeyIdx].CipherAlg;
482 Key = pAd->SharedKey[BSS0][KeyIdx].Key;
484 // Set Group key material to Asic
485 AsicAddSharedKeyEntry(pAd, BSS0, KeyIdx, CipherAlg, Key, NULL, NULL);
487 // Update WCID attribute table and IVEIV table for this group key table
488 RTMPAddWcidAttributeEntry(pAd, BSS0, KeyIdx, CipherAlg, NULL);
494 RTMP_SET_PSFLAG(pAd, fRTMP_PS_CAN_GO_SLEEP);
495 DBGPRINT(RT_DEBUG_INFO, ("<------ RTMPAddKey\n"));
499 char * rtstrchr(const char * s, int c)
501 for(; *s != (char) c; ++s)
508 This is required for LinEX2004/kernel2.6.7 to provide iwlist scanning function
512 rt_ioctl_giwname(struct net_device *dev,
513 struct iw_request_info *info,
514 char *name, char *extra)
516 // PRTMP_ADAPTER pAdapter = dev->ml_priv;
518 strncpy(name, "RT2860 Wireless", IFNAMSIZ);
522 int rt_ioctl_siwfreq(struct net_device *dev,
523 struct iw_request_info *info,
524 struct iw_freq *freq, char *extra)
526 PRTMP_ADAPTER pAdapter = dev->ml_priv;
529 //check if the interface is down
530 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
532 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
540 if((freq->e == 0) && (freq->m <= 1000))
541 chan = freq->m; // Setting by channel number
543 MAP_KHZ_TO_CHANNEL_ID( (freq->m /100) , chan); // Setting by frequency - search the table , like 2.412G, 2.422G,
545 if (ChannelSanity(pAdapter, chan) == TRUE)
547 pAdapter->CommonCfg.Channel = chan;
548 DBGPRINT(RT_DEBUG_ERROR, ("==>rt_ioctl_siwfreq::SIOCSIWFREQ[cmd=0x%x] (Channel=%d)\n", SIOCSIWFREQ, pAdapter->CommonCfg.Channel));
555 int rt_ioctl_giwfreq(struct net_device *dev,
556 struct iw_request_info *info,
557 struct iw_freq *freq, char *extra)
559 VIRTUAL_ADAPTER *pVirtualAd = NULL;
560 PRTMP_ADAPTER pAdapter = NULL;
564 if (dev->priv_flags == INT_MAIN)
566 pAdapter = dev->ml_priv;
570 pVirtualAd = dev->ml_priv;
571 if (pVirtualAd && pVirtualAd->RtmpDev)
572 pAdapter = pVirtualAd->RtmpDev->ml_priv;
575 if (pAdapter == NULL)
577 /* if 1st open fail, pAd will be free;
578 So the net_dev->ml_priv will be NULL in 2rd open */
582 ch = pAdapter->CommonCfg.Channel;
584 DBGPRINT(RT_DEBUG_TRACE,("==>rt_ioctl_giwfreq %d\n", ch));
586 MAP_CHANNEL_ID_TO_KHZ(ch, m);
592 int rt_ioctl_siwmode(struct net_device *dev,
593 struct iw_request_info *info,
594 __u32 *mode, char *extra)
596 PRTMP_ADAPTER pAdapter = dev->ml_priv;
598 //check if the interface is down
599 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
601 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
608 Set_NetworkType_Proc(pAdapter, "Adhoc");
611 Set_NetworkType_Proc(pAdapter, "Infra");
613 case IW_MODE_MONITOR:
614 Set_NetworkType_Proc(pAdapter, "Monitor");
617 DBGPRINT(RT_DEBUG_TRACE, ("===>rt_ioctl_siwmode::SIOCSIWMODE (unknown %d)\n", *mode));
621 // Reset Ralink supplicant to not use, it will be set to start when UI set PMK key
622 pAdapter->StaCfg.WpaState = SS_NOTUSE;
627 int rt_ioctl_giwmode(struct net_device *dev,
628 struct iw_request_info *info,
629 __u32 *mode, char *extra)
631 PRTMP_ADAPTER pAdapter = NULL;
632 VIRTUAL_ADAPTER *pVirtualAd = NULL;
634 if (dev->priv_flags == INT_MAIN)
636 pAdapter = dev->ml_priv;
640 pVirtualAd = dev->ml_priv;
641 if (pVirtualAd && pVirtualAd->RtmpDev)
642 pAdapter = pVirtualAd->RtmpDev->ml_priv;
645 if (pAdapter == NULL)
647 /* if 1st open fail, pAd will be free;
648 So the net_dev->ml_priv will be NULL in 2rd open */
652 if (ADHOC_ON(pAdapter))
653 *mode = IW_MODE_ADHOC;
654 else if (INFRA_ON(pAdapter))
655 *mode = IW_MODE_INFRA;
656 else if (MONITOR_ON(pAdapter))
658 *mode = IW_MODE_MONITOR;
661 *mode = IW_MODE_AUTO;
663 DBGPRINT(RT_DEBUG_TRACE, ("==>rt_ioctl_giwmode(mode=%d)\n", *mode));
667 int rt_ioctl_siwsens(struct net_device *dev,
668 struct iw_request_info *info,
669 char *name, char *extra)
671 PRTMP_ADAPTER pAdapter = dev->ml_priv;
673 //check if the interface is down
674 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
676 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
683 int rt_ioctl_giwsens(struct net_device *dev,
684 struct iw_request_info *info,
685 char *name, char *extra)
690 int rt_ioctl_giwrange(struct net_device *dev,
691 struct iw_request_info *info,
692 struct iw_point *data, char *extra)
694 PRTMP_ADAPTER pAdapter = NULL;
695 VIRTUAL_ADAPTER *pVirtualAd = NULL;
696 struct iw_range *range = (struct iw_range *) extra;
700 if (dev->priv_flags == INT_MAIN)
702 pAdapter = dev->ml_priv;
706 pVirtualAd = dev->ml_priv;
707 if (pVirtualAd && pVirtualAd->RtmpDev)
708 pAdapter = pVirtualAd->RtmpDev->ml_priv;
711 if (pAdapter == NULL)
713 /* if 1st open fail, pAd will be free;
714 So the net_dev->ml_priv will be NULL in 2rd open */
718 DBGPRINT(RT_DEBUG_TRACE ,("===>rt_ioctl_giwrange\n"));
719 data->length = sizeof(struct iw_range);
720 memset(range, 0, sizeof(struct iw_range));
722 range->txpower_capa = IW_TXPOW_DBM;
724 if (INFRA_ON(pAdapter)||ADHOC_ON(pAdapter))
726 range->min_pmp = 1 * 1024;
727 range->max_pmp = 65535 * 1024;
728 range->min_pmt = 1 * 1024;
729 range->max_pmt = 1000 * 1024;
730 range->pmp_flags = IW_POWER_PERIOD;
731 range->pmt_flags = IW_POWER_TIMEOUT;
732 range->pm_capa = IW_POWER_PERIOD | IW_POWER_TIMEOUT |
733 IW_POWER_UNICAST_R | IW_POWER_ALL_R;
736 range->we_version_compiled = WIRELESS_EXT;
737 range->we_version_source = 14;
739 range->retry_capa = IW_RETRY_LIMIT;
740 range->retry_flags = IW_RETRY_LIMIT;
741 range->min_retry = 0;
742 range->max_retry = 255;
744 range->num_channels = pAdapter->ChannelListNum;
747 for (i = 1; i <= range->num_channels; i++)
750 range->freq[val].i = pAdapter->ChannelList[i-1].Channel;
751 MAP_CHANNEL_ID_TO_KHZ(pAdapter->ChannelList[i-1].Channel, m);
752 range->freq[val].m = m * 100; /* HZ */
754 range->freq[val].e = 1;
756 if (val == IW_MAX_FREQUENCIES)
759 range->num_frequency = val;
761 range->max_qual.qual = 100; /* what is correct max? This was not
762 * documented exactly. At least
763 * 69 has been observed. */
764 range->max_qual.level = 0; /* dB */
765 range->max_qual.noise = 0; /* dB */
767 /* What would be suitable values for "average/typical" qual? */
768 range->avg_qual.qual = 20;
769 range->avg_qual.level = -60;
770 range->avg_qual.noise = -95;
771 range->sensitivity = 3;
773 range->max_encoding_tokens = NR_WEP_KEYS;
774 range->num_encoding_sizes = 2;
775 range->encoding_size[0] = 5;
776 range->encoding_size[1] = 13;
779 range->max_rts = 2347;
780 range->min_frag = 256;
781 range->max_frag = 2346;
783 #if WIRELESS_EXT > 17
784 /* IW_ENC_CAPA_* bit field */
785 range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 |
786 IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP;
792 int rt_ioctl_siwap(struct net_device *dev,
793 struct iw_request_info *info,
794 struct sockaddr *ap_addr, char *extra)
796 PRTMP_ADAPTER pAdapter = dev->ml_priv;
797 NDIS_802_11_MAC_ADDRESS Bssid;
799 //check if the interface is down
800 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
802 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
806 if (pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE)
808 RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
809 DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
812 // tell CNTL state machine to call NdisMSetInformationComplete() after completing
813 // this request, because this request is initiated by NDIS.
814 pAdapter->MlmeAux.CurrReqIsFromNdis = FALSE;
815 // Prevent to connect AP again in STAMlmePeriodicExec
816 pAdapter->MlmeAux.AutoReconnectSsidLen= 32;
818 memset(Bssid, 0, MAC_ADDR_LEN);
819 memcpy(Bssid, ap_addr->sa_data, MAC_ADDR_LEN);
820 MlmeEnqueue(pAdapter,
821 MLME_CNTL_STATE_MACHINE,
823 sizeof(NDIS_802_11_MAC_ADDRESS),
826 DBGPRINT(RT_DEBUG_TRACE, ("IOCTL::SIOCSIWAP %02x:%02x:%02x:%02x:%02x:%02x\n",
827 Bssid[0], Bssid[1], Bssid[2], Bssid[3], Bssid[4], Bssid[5]));
832 int rt_ioctl_giwap(struct net_device *dev,
833 struct iw_request_info *info,
834 struct sockaddr *ap_addr, char *extra)
836 PRTMP_ADAPTER pAdapter = NULL;
837 VIRTUAL_ADAPTER *pVirtualAd = NULL;
839 if (dev->priv_flags == INT_MAIN)
841 pAdapter = dev->ml_priv;
845 pVirtualAd = dev->ml_priv;
846 if (pVirtualAd && pVirtualAd->RtmpDev)
847 pAdapter = pVirtualAd->RtmpDev->ml_priv;
850 if (pAdapter == NULL)
852 /* if 1st open fail, pAd will be free;
853 So the net_dev->ml_priv will be NULL in 2rd open */
857 if (INFRA_ON(pAdapter) || ADHOC_ON(pAdapter))
859 ap_addr->sa_family = ARPHRD_ETHER;
860 memcpy(ap_addr->sa_data, &pAdapter->CommonCfg.Bssid, ETH_ALEN);
862 #ifdef WPA_SUPPLICANT_SUPPORT
864 else if (pAdapter->StaCfg.WpaSupplicantUP != WPA_SUPPLICANT_DISABLE)
866 ap_addr->sa_family = ARPHRD_ETHER;
867 memcpy(ap_addr->sa_data, &pAdapter->MlmeAux.Bssid, ETH_ALEN);
869 #endif // WPA_SUPPLICANT_SUPPORT //
872 DBGPRINT(RT_DEBUG_TRACE, ("IOCTL::SIOCGIWAP(=EMPTY)\n"));
880 * Units are in db above the noise floor. That means the
881 * rssi values reported in the tx/rx descriptors in the
882 * driver are the SNR expressed in db.
884 * If you assume that the noise floor is -95, which is an
885 * excellent assumption 99.5 % of the time, then you can
886 * derive the absolute signal level (i.e. -95 + rssi).
887 * There are some other slight factors to take into account
888 * depending on whether the rssi measurement is from 11b,
889 * 11g, or 11a. These differences are at most 2db and
892 * NB: various calculations are based on the orinoco/wavelan
893 * drivers for compatibility
895 static void set_quality(PRTMP_ADAPTER pAdapter,
896 struct iw_quality *iq,
903 ChannelQuality = 100;
904 else if (rssi >= -80) // between -50 ~ -80dbm
905 ChannelQuality = (__u8)(24 + ((rssi + 80) * 26)/10);
906 else if (rssi >= -90) // between -80 ~ -90dbm
907 ChannelQuality = (__u8)((rssi + 90) * 26)/10;
911 iq->qual = (__u8)ChannelQuality;
913 iq->level = (__u8)(rssi);
914 iq->noise = (pAdapter->BbpWriteLatch[66] > pAdapter->BbpTuning.FalseCcaUpperThreshold) ? ((__u8)pAdapter->BbpTuning.FalseCcaUpperThreshold) : ((__u8) pAdapter->BbpWriteLatch[66]); // noise level (dBm)
915 iq->noise += 256 - 143;
916 iq->updated = pAdapter->iw_stats.qual.updated;
919 int rt_ioctl_iwaplist(struct net_device *dev,
920 struct iw_request_info *info,
921 struct iw_point *data, char *extra)
923 PRTMP_ADAPTER pAdapter = dev->ml_priv;
925 struct sockaddr addr[IW_MAX_AP];
926 struct iw_quality qual[IW_MAX_AP];
929 //check if the interface is down
930 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
932 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
938 for (i = 0; i <IW_MAX_AP ; i++)
940 if (i >= pAdapter->ScanTab.BssNr)
942 addr[i].sa_family = ARPHRD_ETHER;
943 memcpy(addr[i].sa_data, &pAdapter->ScanTab.BssEntry[i].Bssid, MAC_ADDR_LEN);
944 set_quality(pAdapter, &qual[i], pAdapter->ScanTab.BssEntry[i].Rssi);
947 memcpy(extra, &addr, i*sizeof(addr[0]));
948 data->flags = 1; /* signal quality present (sort of) */
949 memcpy(extra + i*sizeof(addr[0]), &qual, i*sizeof(qual[i]));
955 int rt_ioctl_siwscan(struct net_device *dev,
956 struct iw_request_info *info,
957 struct iw_point *data, char *extra)
959 PRTMP_ADAPTER pAdapter = dev->ml_priv;
962 int Status = NDIS_STATUS_SUCCESS;
964 //check if the interface is down
965 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
967 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
971 if (MONITOR_ON(pAdapter))
973 DBGPRINT(RT_DEBUG_TRACE, ("!!! Driver is in Monitor Mode now !!!\n"));
977 if ((pAdapter->OpMode == OPMODE_STA) && (IDLE_ON(pAdapter))
978 && (pAdapter->StaCfg.bRadio == TRUE)
979 && (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_IDLE_RADIO_OFF)))
981 RT28xxPciAsicRadioOn(pAdapter, GUI_IDLE_POWER_SAVE);
983 // Check if still radio off.
984 else if (pAdapter->bPCIclkOff == TRUE)
987 #ifdef WPA_SUPPLICANT_SUPPORT
988 if (pAdapter->StaCfg.WpaSupplicantUP == WPA_SUPPLICANT_ENABLE)
990 pAdapter->StaCfg.WpaSupplicantScanCount++;
992 #endif // WPA_SUPPLICANT_SUPPORT //
994 pAdapter->StaCfg.bScanReqIsFromWebUI = TRUE;
995 if (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
1000 #ifdef WPA_SUPPLICANT_SUPPORT
1001 if ((pAdapter->StaCfg.WpaSupplicantUP == WPA_SUPPLICANT_ENABLE) &&
1002 (pAdapter->StaCfg.WpaSupplicantScanCount > 3))
1004 DBGPRINT(RT_DEBUG_TRACE, ("!!! WpaSupplicantScanCount > 3\n"));
1005 Status = NDIS_STATUS_SUCCESS;
1008 #endif // WPA_SUPPLICANT_SUPPORT //
1010 if ((OPSTATUS_TEST_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED)) &&
1011 ((pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA) ||
1012 (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK)) &&
1013 (pAdapter->StaCfg.PortSecured == WPA_802_1X_PORT_NOT_SECURED))
1015 DBGPRINT(RT_DEBUG_TRACE, ("!!! Link UP, Port Not Secured! ignore this set::OID_802_11_BSSID_LIST_SCAN\n"));
1016 Status = NDIS_STATUS_SUCCESS;
1020 if (pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE)
1022 RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
1023 DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
1026 // tell CNTL state machine to call NdisMSetInformationComplete() after completing
1027 // this request, because this request is initiated by NDIS.
1028 pAdapter->MlmeAux.CurrReqIsFromNdis = FALSE;
1029 // Reset allowed scan retries
1030 pAdapter->StaCfg.ScanCnt = 0;
1031 pAdapter->StaCfg.LastScanTime = Now;
1033 MlmeEnqueue(pAdapter,
1034 MLME_CNTL_STATE_MACHINE,
1035 OID_802_11_BSSID_LIST_SCAN,
1039 Status = NDIS_STATUS_SUCCESS;
1040 RT28XX_MLME_HANDLER(pAdapter);
1045 int rt_ioctl_giwscan(struct net_device *dev,
1046 struct iw_request_info *info,
1047 struct iw_point *data, char *extra)
1050 PRTMP_ADAPTER pAdapter = dev->ml_priv;
1052 char *current_ev = extra, *previous_ev = extra;
1054 char *current_val, custom[MAX_CUSTOM_LEN] = {0};
1057 #endif // IWEVGENIE //
1058 struct iw_event iwe;
1060 if (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
1063 * Still scanning, indicate the caller should try again.
1069 #ifdef WPA_SUPPLICANT_SUPPORT
1070 if (pAdapter->StaCfg.WpaSupplicantUP == WPA_SUPPLICANT_ENABLE)
1072 pAdapter->StaCfg.WpaSupplicantScanCount = 0;
1074 #endif // WPA_SUPPLICANT_SUPPORT //
1076 if (pAdapter->ScanTab.BssNr == 0)
1082 #if WIRELESS_EXT >= 17
1083 if (data->length > 0)
1084 end_buf = extra + data->length;
1086 end_buf = extra + IW_SCAN_MAX_DATA;
1088 end_buf = extra + IW_SCAN_MAX_DATA;
1091 for (i = 0; i < pAdapter->ScanTab.BssNr; i++)
1093 if (current_ev >= end_buf)
1095 #if WIRELESS_EXT >= 17
1103 //================================
1104 memset(&iwe, 0, sizeof(iwe));
1105 iwe.cmd = SIOCGIWAP;
1106 iwe.u.ap_addr.sa_family = ARPHRD_ETHER;
1107 memcpy(iwe.u.ap_addr.sa_data, &pAdapter->ScanTab.BssEntry[i].Bssid, ETH_ALEN);
1109 previous_ev = current_ev;
1110 current_ev = iwe_stream_add_event(info, current_ev,end_buf, &iwe, IW_EV_ADDR_LEN);
1111 if (current_ev == previous_ev)
1112 #if WIRELESS_EXT >= 17
1119 //================================
1120 memset(&iwe, 0, sizeof(iwe));
1121 iwe.cmd = SIOCGIWESSID;
1122 iwe.u.data.length = pAdapter->ScanTab.BssEntry[i].SsidLen;
1123 iwe.u.data.flags = 1;
1125 previous_ev = current_ev;
1126 current_ev = iwe_stream_add_point(info, current_ev,end_buf, &iwe, pAdapter->ScanTab.BssEntry[i].Ssid);
1127 if (current_ev == previous_ev)
1128 #if WIRELESS_EXT >= 17
1135 //================================
1136 memset(&iwe, 0, sizeof(iwe));
1137 iwe.cmd = SIOCGIWMODE;
1138 if (pAdapter->ScanTab.BssEntry[i].BssType == Ndis802_11IBSS)
1140 iwe.u.mode = IW_MODE_ADHOC;
1142 else if (pAdapter->ScanTab.BssEntry[i].BssType == Ndis802_11Infrastructure)
1144 iwe.u.mode = IW_MODE_INFRA;
1148 iwe.u.mode = IW_MODE_AUTO;
1150 iwe.len = IW_EV_UINT_LEN;
1152 previous_ev = current_ev;
1153 current_ev = iwe_stream_add_event(info, current_ev, end_buf, &iwe, IW_EV_UINT_LEN);
1154 if (current_ev == previous_ev)
1155 #if WIRELESS_EXT >= 17
1161 //Channel and Frequency
1162 //================================
1163 memset(&iwe, 0, sizeof(iwe));
1164 iwe.cmd = SIOCGIWFREQ;
1165 if (INFRA_ON(pAdapter) || ADHOC_ON(pAdapter))
1166 iwe.u.freq.m = pAdapter->ScanTab.BssEntry[i].Channel;
1168 iwe.u.freq.m = pAdapter->ScanTab.BssEntry[i].Channel;
1172 previous_ev = current_ev;
1173 current_ev = iwe_stream_add_event(info, current_ev, end_buf, &iwe, IW_EV_FREQ_LEN);
1174 if (current_ev == previous_ev)
1175 #if WIRELESS_EXT >= 17
1181 //Add quality statistics
1182 //================================
1183 memset(&iwe, 0, sizeof(iwe));
1185 iwe.u.qual.level = 0;
1186 iwe.u.qual.noise = 0;
1187 set_quality(pAdapter, &iwe.u.qual, pAdapter->ScanTab.BssEntry[i].Rssi);
1188 current_ev = iwe_stream_add_event(info, current_ev, end_buf, &iwe, IW_EV_QUAL_LEN);
1189 if (current_ev == previous_ev)
1190 #if WIRELESS_EXT >= 17
1197 //================================
1198 memset(&iwe, 0, sizeof(iwe));
1199 iwe.cmd = SIOCGIWENCODE;
1200 if (CAP_IS_PRIVACY_ON (pAdapter->ScanTab.BssEntry[i].CapabilityInfo ))
1201 iwe.u.data.flags =IW_ENCODE_ENABLED | IW_ENCODE_NOKEY;
1203 iwe.u.data.flags = IW_ENCODE_DISABLED;
1205 previous_ev = current_ev;
1206 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);
1207 if (current_ev == previous_ev)
1208 #if WIRELESS_EXT >= 17
1215 //================================
1216 if (pAdapter->ScanTab.BssEntry[i].SupRateLen)
1218 UCHAR tmpRate = pAdapter->ScanTab.BssEntry[i].SupRate[pAdapter->ScanTab.BssEntry[i].SupRateLen-1];
1219 memset(&iwe, 0, sizeof(iwe));
1220 iwe.cmd = SIOCGIWRATE;
1221 current_val = current_ev + IW_EV_LCP_LEN;
1222 if (tmpRate == 0x82)
1223 iwe.u.bitrate.value = 1 * 1000000;
1224 else if (tmpRate == 0x84)
1225 iwe.u.bitrate.value = 2 * 1000000;
1226 else if (tmpRate == 0x8B)
1227 iwe.u.bitrate.value = 5.5 * 1000000;
1228 else if (tmpRate == 0x96)
1229 iwe.u.bitrate.value = 11 * 1000000;
1231 iwe.u.bitrate.value = (tmpRate/2) * 1000000;
1233 iwe.u.bitrate.disabled = 0;
1234 current_val = iwe_stream_add_value(info, current_ev,
1235 current_val, end_buf, &iwe,
1238 if((current_val-current_ev)>IW_EV_LCP_LEN)
1239 current_ev = current_val;
1241 #if WIRELESS_EXT >= 17
1250 if (pAdapter->ScanTab.BssEntry[i].WpaIE.IELen > 0)
1252 memset(&iwe, 0, sizeof(iwe));
1253 memset(&custom[0], 0, MAX_CUSTOM_LEN);
1254 memcpy(custom, &(pAdapter->ScanTab.BssEntry[i].WpaIE.IE[0]),
1255 pAdapter->ScanTab.BssEntry[i].WpaIE.IELen);
1256 iwe.cmd = IWEVGENIE;
1257 iwe.u.data.length = pAdapter->ScanTab.BssEntry[i].WpaIE.IELen;
1258 current_ev = iwe_stream_add_point(info, current_ev, end_buf, &iwe, custom);
1259 if (current_ev == previous_ev)
1260 #if WIRELESS_EXT >= 17
1268 if (pAdapter->ScanTab.BssEntry[i].RsnIE.IELen > 0)
1270 memset(&iwe, 0, sizeof(iwe));
1271 memset(&custom[0], 0, MAX_CUSTOM_LEN);
1272 memcpy(custom, &(pAdapter->ScanTab.BssEntry[i].RsnIE.IE[0]),
1273 pAdapter->ScanTab.BssEntry[i].RsnIE.IELen);
1274 iwe.cmd = IWEVGENIE;
1275 iwe.u.data.length = pAdapter->ScanTab.BssEntry[i].RsnIE.IELen;
1276 current_ev = iwe_stream_add_point(info, current_ev, end_buf, &iwe, custom);
1277 if (current_ev == previous_ev)
1278 #if WIRELESS_EXT >= 17
1286 //================================
1287 if (pAdapter->ScanTab.BssEntry[i].WpaIE.IELen > 0)
1289 NdisZeroMemory(&iwe, sizeof(iwe));
1290 memset(&custom[0], 0, MAX_CUSTOM_LEN);
1291 iwe.cmd = IWEVCUSTOM;
1292 iwe.u.data.length = (pAdapter->ScanTab.BssEntry[i].WpaIE.IELen * 2) + 7;
1293 NdisMoveMemory(custom, "wpa_ie=", 7);
1294 for (idx = 0; idx < pAdapter->ScanTab.BssEntry[i].WpaIE.IELen; idx++)
1295 sprintf(custom + strlen(custom), "%02x", pAdapter->ScanTab.BssEntry[i].WpaIE.IE[idx]);
1296 previous_ev = current_ev;
1297 current_ev = iwe_stream_add_point(current_ev, end_buf, &iwe, custom);
1298 if (current_ev == previous_ev)
1299 #if WIRELESS_EXT >= 17
1307 if (pAdapter->ScanTab.BssEntry[i].RsnIE.IELen > 0)
1309 NdisZeroMemory(&iwe, sizeof(iwe));
1310 memset(&custom[0], 0, MAX_CUSTOM_LEN);
1311 iwe.cmd = IWEVCUSTOM;
1312 iwe.u.data.length = (pAdapter->ScanTab.BssEntry[i].RsnIE.IELen * 2) + 7;
1313 NdisMoveMemory(custom, "rsn_ie=", 7);
1314 for (idx = 0; idx < pAdapter->ScanTab.BssEntry[i].RsnIE.IELen; idx++)
1315 sprintf(custom + strlen(custom), "%02x", pAdapter->ScanTab.BssEntry[i].RsnIE.IE[idx]);
1316 previous_ev = current_ev;
1317 current_ev = iwe_stream_add_point(current_ev, end_buf, &iwe, custom);
1318 if (current_ev == previous_ev)
1319 #if WIRELESS_EXT >= 17
1325 #endif // IWEVGENIE //
1328 data->length = current_ev - extra;
1329 pAdapter->StaCfg.bScanReqIsFromWebUI = FALSE;
1330 DBGPRINT(RT_DEBUG_ERROR ,("===>rt_ioctl_giwscan. %d(%d) BSS returned, data->length = %d\n",i , pAdapter->ScanTab.BssNr, data->length));
1335 int rt_ioctl_siwessid(struct net_device *dev,
1336 struct iw_request_info *info,
1337 struct iw_point *data, char *essid)
1339 PRTMP_ADAPTER pAdapter = dev->ml_priv;
1341 //check if the interface is down
1342 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1344 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1350 PCHAR pSsidString = NULL;
1352 // Includes null character.
1353 if (data->length > (IW_ESSID_MAX_SIZE + 1))
1356 pSsidString = (CHAR *) kmalloc(MAX_LEN_OF_SSID+1, MEM_ALLOC_FLAG);
1359 NdisZeroMemory(pSsidString, MAX_LEN_OF_SSID+1);
1360 NdisMoveMemory(pSsidString, essid, data->length);
1361 if (Set_SSID_Proc(pAdapter, pSsidString) == FALSE)
1370 if (Set_SSID_Proc(pAdapter, "") == FALSE)
1376 int rt_ioctl_giwessid(struct net_device *dev,
1377 struct iw_request_info *info,
1378 struct iw_point *data, char *essid)
1380 PRTMP_ADAPTER pAdapter = NULL;
1381 VIRTUAL_ADAPTER *pVirtualAd = NULL;
1383 if (dev->priv_flags == INT_MAIN)
1385 pAdapter = dev->ml_priv;
1389 pVirtualAd = dev->ml_priv;
1390 if (pVirtualAd && pVirtualAd->RtmpDev)
1391 pAdapter = pVirtualAd->RtmpDev->ml_priv;
1394 if (pAdapter == NULL)
1396 /* if 1st open fail, pAd will be free;
1397 So the net_dev->ml_priv will be NULL in 2rd open */
1402 if (MONITOR_ON(pAdapter))
1408 if (OPSTATUS_TEST_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED))
1410 DBGPRINT(RT_DEBUG_TRACE ,("MediaState is connected\n"));
1411 data->length = pAdapter->CommonCfg.SsidLen;
1412 memcpy(essid, pAdapter->CommonCfg.Ssid, pAdapter->CommonCfg.SsidLen);
1415 {//the ANY ssid was specified
1417 DBGPRINT(RT_DEBUG_TRACE ,("MediaState is not connected, ess\n"));
1424 int rt_ioctl_siwnickn(struct net_device *dev,
1425 struct iw_request_info *info,
1426 struct iw_point *data, char *nickname)
1428 PRTMP_ADAPTER pAdapter = dev->ml_priv;
1430 //check if the interface is down
1431 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1433 DBGPRINT(RT_DEBUG_TRACE ,("INFO::Network is down!\n"));
1437 if (data->length > IW_ESSID_MAX_SIZE)
1440 memset(pAdapter->nickname, 0, IW_ESSID_MAX_SIZE + 1);
1441 memcpy(pAdapter->nickname, nickname, data->length);
1447 int rt_ioctl_giwnickn(struct net_device *dev,
1448 struct iw_request_info *info,
1449 struct iw_point *data, char *nickname)
1451 PRTMP_ADAPTER pAdapter = NULL;
1452 VIRTUAL_ADAPTER *pVirtualAd = NULL;
1454 if (dev->priv_flags == INT_MAIN)
1456 pAdapter = dev->ml_priv;
1460 pVirtualAd = dev->ml_priv;
1461 if (pVirtualAd && pVirtualAd->RtmpDev)
1462 pAdapter = pVirtualAd->RtmpDev->ml_priv;
1465 if (pAdapter == NULL)
1467 /* if 1st open fail, pAd will be free;
1468 So the net_dev->ml_priv will be NULL in 2rd open */
1472 if (data->length > strlen(pAdapter->nickname) + 1)
1473 data->length = strlen(pAdapter->nickname) + 1;
1474 if (data->length > 0) {
1475 memcpy(nickname, pAdapter->nickname, data->length-1);
1476 nickname[data->length-1] = '\0';
1481 int rt_ioctl_siwrts(struct net_device *dev,
1482 struct iw_request_info *info,
1483 struct iw_param *rts, char *extra)
1485 PRTMP_ADAPTER pAdapter = dev->ml_priv;
1488 //check if the interface is down
1489 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1491 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1496 val = MAX_RTS_THRESHOLD;
1497 else if (rts->value < 0 || rts->value > MAX_RTS_THRESHOLD)
1499 else if (rts->value == 0)
1500 val = MAX_RTS_THRESHOLD;
1504 if (val != pAdapter->CommonCfg.RtsThreshold)
1505 pAdapter->CommonCfg.RtsThreshold = val;
1510 int rt_ioctl_giwrts(struct net_device *dev,
1511 struct iw_request_info *info,
1512 struct iw_param *rts, char *extra)
1514 PRTMP_ADAPTER pAdapter = NULL;
1515 VIRTUAL_ADAPTER *pVirtualAd = NULL;
1517 if (dev->priv_flags == INT_MAIN)
1519 pAdapter = dev->ml_priv;
1523 pVirtualAd = dev->ml_priv;
1524 if (pVirtualAd && pVirtualAd->RtmpDev)
1525 pAdapter = pVirtualAd->RtmpDev->ml_priv;
1528 if (pAdapter == NULL)
1530 /* if 1st open fail, pAd will be free;
1531 So the net_dev->ml_priv will be NULL in 2rd open */
1535 //check if the interface is down
1536 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1538 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1542 rts->value = pAdapter->CommonCfg.RtsThreshold;
1543 rts->disabled = (rts->value == MAX_RTS_THRESHOLD);
1549 int rt_ioctl_siwfrag(struct net_device *dev,
1550 struct iw_request_info *info,
1551 struct iw_param *frag, char *extra)
1553 PRTMP_ADAPTER pAdapter = dev->ml_priv;
1556 //check if the interface is down
1557 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1559 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1564 val = MAX_FRAG_THRESHOLD;
1565 else if (frag->value >= MIN_FRAG_THRESHOLD || frag->value <= MAX_FRAG_THRESHOLD)
1566 val = __cpu_to_le16(frag->value & ~0x1); /* even numbers only */
1567 else if (frag->value == 0)
1568 val = MAX_FRAG_THRESHOLD;
1572 pAdapter->CommonCfg.FragmentThreshold = val;
1576 int rt_ioctl_giwfrag(struct net_device *dev,
1577 struct iw_request_info *info,
1578 struct iw_param *frag, char *extra)
1580 PRTMP_ADAPTER pAdapter = NULL;
1581 VIRTUAL_ADAPTER *pVirtualAd = NULL;
1583 if (dev->priv_flags == INT_MAIN)
1585 pAdapter = dev->ml_priv;
1589 pVirtualAd = dev->ml_priv;
1590 if (pVirtualAd && pVirtualAd->RtmpDev)
1591 pAdapter = pVirtualAd->RtmpDev->ml_priv;
1594 if (pAdapter == NULL)
1596 /* if 1st open fail, pAd will be free;
1597 So the net_dev->ml_priv will be NULL in 2rd open */
1601 //check if the interface is down
1602 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1604 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1608 frag->value = pAdapter->CommonCfg.FragmentThreshold;
1609 frag->disabled = (frag->value == MAX_FRAG_THRESHOLD);
1615 #define MAX_WEP_KEY_SIZE 13
1616 #define MIN_WEP_KEY_SIZE 5
1617 int rt_ioctl_siwencode(struct net_device *dev,
1618 struct iw_request_info *info,
1619 struct iw_point *erq, char *extra)
1621 PRTMP_ADAPTER pAdapter = dev->ml_priv;
1623 //check if the interface is down
1624 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1626 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1630 if ((erq->length == 0) &&
1631 (erq->flags & IW_ENCODE_DISABLED))
1633 pAdapter->StaCfg.PairCipher = Ndis802_11WEPDisabled;
1634 pAdapter->StaCfg.GroupCipher = Ndis802_11WEPDisabled;
1635 pAdapter->StaCfg.WepStatus = Ndis802_11WEPDisabled;
1636 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
1637 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
1640 else if ((erq->length == 0) &&
1641 (erq->flags & IW_ENCODE_RESTRICTED || erq->flags & IW_ENCODE_OPEN))
1643 STA_PORT_SECURED(pAdapter);
1644 pAdapter->StaCfg.PairCipher = Ndis802_11WEPEnabled;
1645 pAdapter->StaCfg.GroupCipher = Ndis802_11WEPEnabled;
1646 pAdapter->StaCfg.WepStatus = Ndis802_11WEPEnabled;
1647 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
1648 if (erq->flags & IW_ENCODE_RESTRICTED)
1649 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeShared;
1651 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
1655 if (erq->length > 0)
1657 int keyIdx = (erq->flags & IW_ENCODE_INDEX) - 1;
1658 /* Check the size of the key */
1659 if (erq->length > MAX_WEP_KEY_SIZE) {
1662 /* Check key index */
1663 if ((keyIdx < 0) || (keyIdx >= NR_WEP_KEYS))
1665 DBGPRINT(RT_DEBUG_TRACE ,("==>rt_ioctl_siwencode::Wrong keyIdx=%d! Using default key instead (%d)\n",
1666 keyIdx, pAdapter->StaCfg.DefaultKeyId));
1669 keyIdx = pAdapter->StaCfg.DefaultKeyId;
1672 NdisZeroMemory(pAdapter->SharedKey[BSS0][keyIdx].Key, 16);
1674 if (erq->length == MAX_WEP_KEY_SIZE)
1676 pAdapter->SharedKey[BSS0][keyIdx].KeyLen = MAX_WEP_KEY_SIZE;
1677 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CIPHER_WEP128;
1679 else if (erq->length == MIN_WEP_KEY_SIZE)
1681 pAdapter->SharedKey[BSS0][keyIdx].KeyLen = MIN_WEP_KEY_SIZE;
1682 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CIPHER_WEP64;
1685 /* Disable the key */
1686 pAdapter->SharedKey[BSS0][keyIdx].KeyLen = 0;
1688 /* Check if the key is not marked as invalid */
1689 if(!(erq->flags & IW_ENCODE_NOKEY)) {
1690 /* Copy the key in the driver */
1691 NdisMoveMemory(pAdapter->SharedKey[BSS0][keyIdx].Key, extra, erq->length);
1696 /* Do we want to just set the transmit key index ? */
1697 int index = (erq->flags & IW_ENCODE_INDEX) - 1;
1698 if ((index >= 0) && (index < 4))
1700 pAdapter->StaCfg.DefaultKeyId = index;
1703 /* Don't complain if only change the mode */
1704 if (!(erq->flags & IW_ENCODE_MODE)) {
1710 DBGPRINT(RT_DEBUG_TRACE ,("==>rt_ioctl_siwencode::erq->flags=%x\n",erq->flags));
1711 DBGPRINT(RT_DEBUG_TRACE ,("==>rt_ioctl_siwencode::AuthMode=%x\n",pAdapter->StaCfg.AuthMode));
1712 DBGPRINT(RT_DEBUG_TRACE ,("==>rt_ioctl_siwencode::DefaultKeyId=%x, KeyLen = %d\n",pAdapter->StaCfg.DefaultKeyId , pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].KeyLen));
1713 DBGPRINT(RT_DEBUG_TRACE ,("==>rt_ioctl_siwencode::WepStatus=%x\n",pAdapter->StaCfg.WepStatus));
1718 rt_ioctl_giwencode(struct net_device *dev,
1719 struct iw_request_info *info,
1720 struct iw_point *erq, char *key)
1723 PRTMP_ADAPTER pAdapter = NULL;
1724 VIRTUAL_ADAPTER *pVirtualAd = NULL;
1726 if (dev->priv_flags == INT_MAIN)
1728 pAdapter = dev->ml_priv;
1732 pVirtualAd = dev->ml_priv;
1733 if (pVirtualAd && pVirtualAd->RtmpDev)
1734 pAdapter = pVirtualAd->RtmpDev->ml_priv;
1737 if (pAdapter == NULL)
1739 /* if 1st open fail, pAd will be free;
1740 So the net_dev->ml_priv will be NULL in 2rd open */
1744 //check if the interface is down
1745 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1747 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1751 kid = erq->flags & IW_ENCODE_INDEX;
1752 DBGPRINT(RT_DEBUG_TRACE, ("===>rt_ioctl_giwencode %d\n", erq->flags & IW_ENCODE_INDEX));
1754 if (pAdapter->StaCfg.WepStatus == Ndis802_11WEPDisabled)
1757 erq->flags = IW_ENCODE_DISABLED;
1759 else if ((kid > 0) && (kid <=4))
1762 erq->flags = kid ; /* NB: base 1 */
1763 if (erq->length > pAdapter->SharedKey[BSS0][kid-1].KeyLen)
1764 erq->length = pAdapter->SharedKey[BSS0][kid-1].KeyLen;
1765 memcpy(key, pAdapter->SharedKey[BSS0][kid-1].Key, erq->length);
1766 //if ((kid == pAdapter->PortCfg.DefaultKeyId))
1767 //erq->flags |= IW_ENCODE_ENABLED; /* XXX */
1768 if (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeShared)
1769 erq->flags |= IW_ENCODE_RESTRICTED; /* XXX */
1771 erq->flags |= IW_ENCODE_OPEN; /* XXX */
1776 if (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeShared)
1777 erq->flags |= IW_ENCODE_RESTRICTED; /* XXX */
1779 erq->flags |= IW_ENCODE_OPEN; /* XXX */
1780 erq->length = pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].KeyLen;
1781 memcpy(key, pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].Key, erq->length);
1782 // copy default key ID
1783 if (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeShared)
1784 erq->flags |= IW_ENCODE_RESTRICTED; /* XXX */
1786 erq->flags |= IW_ENCODE_OPEN; /* XXX */
1787 erq->flags = pAdapter->StaCfg.DefaultKeyId + 1; /* NB: base 1 */
1788 erq->flags |= IW_ENCODE_ENABLED; /* XXX */
1796 rt_ioctl_setparam(struct net_device *dev, struct iw_request_info *info,
1797 void *w, char *extra)
1799 VIRTUAL_ADAPTER *pVirtualAd = NULL;
1800 PRTMP_ADAPTER pAdapter;
1802 char *this_char = extra;
1806 if (dev->priv_flags == INT_MAIN)
1808 pAdapter = dev->ml_priv;
1812 pVirtualAd = dev->ml_priv;
1813 pAdapter = pVirtualAd->RtmpDev->ml_priv;
1815 pObj = (POS_COOKIE) pAdapter->OS_Cookie;
1817 if (pAdapter == NULL)
1819 /* if 1st open fail, pAd will be free;
1820 So the net_dev->ml_priv will be NULL in 2rd open */
1825 pObj->ioctl_if_type = INT_MAIN;
1826 pObj->ioctl_if = MAIN_MBSSID;
1829 //check if the interface is down
1830 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1832 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1839 if ((value = rtstrchr(this_char, '=')) != NULL)
1845 // reject setting nothing besides ANY ssid(ssidLen=0)
1846 if (!*value && (strcmp(this_char, "SSID") != 0))
1849 for (PRTMP_PRIVATE_SET_PROC = RTMP_PRIVATE_SUPPORT_PROC; PRTMP_PRIVATE_SET_PROC->name; PRTMP_PRIVATE_SET_PROC++)
1851 if (strcmp(this_char, PRTMP_PRIVATE_SET_PROC->name) == 0)
1853 if(!PRTMP_PRIVATE_SET_PROC->set_proc(pAdapter, value))
1854 { //FALSE:Set private failed then return Invalid argument
1857 break; //Exit for loop.
1861 if(PRTMP_PRIVATE_SET_PROC->name == NULL)
1862 { //Not found argument
1864 DBGPRINT(RT_DEBUG_TRACE, ("===>rt_ioctl_setparam:: (iwpriv) Not Support Set Command [%s=%s]\n", this_char, value));
1872 rt_private_get_statistics(struct net_device *dev, struct iw_request_info *info,
1873 struct iw_point *wrq, char *extra)
1876 PRTMP_ADAPTER pAd = dev->ml_priv;
1884 memset(extra, 0x00, IW_PRIV_SIZE_MASK);
1885 sprintf(extra, "\n\n");
1888 sprintf(extra+strlen(extra), "Tx success = %ld\n", (ULONG)pAd->WlanCounters.TransmittedFragmentCount.QuadPart);
1889 sprintf(extra+strlen(extra), "Tx success without retry = %ld\n", (ULONG)pAd->WlanCounters.TransmittedFragmentCount.QuadPart - (ULONG)pAd->WlanCounters.RetryCount.QuadPart);
1891 sprintf(extra+strlen(extra), "Tx success after retry = %ld\n", (ULONG)pAd->WlanCounters.RetryCount.QuadPart);
1892 sprintf(extra+strlen(extra), "Tx fail to Rcv ACK after retry = %ld\n", (ULONG)pAd->WlanCounters.FailedCount.QuadPart);
1893 sprintf(extra+strlen(extra), "RTS Success Rcv CTS = %ld\n", (ULONG)pAd->WlanCounters.RTSSuccessCount.QuadPart);
1894 sprintf(extra+strlen(extra), "RTS Fail Rcv CTS = %ld\n", (ULONG)pAd->WlanCounters.RTSFailureCount.QuadPart);
1896 sprintf(extra+strlen(extra), "Rx success = %ld\n", (ULONG)pAd->WlanCounters.ReceivedFragmentCount.QuadPart);
1897 sprintf(extra+strlen(extra), "Rx with CRC = %ld\n", (ULONG)pAd->WlanCounters.FCSErrorCount.QuadPart);
1898 sprintf(extra+strlen(extra), "Rx drop due to out of resource = %ld\n", (ULONG)pAd->Counters8023.RxNoBuffer);
1899 sprintf(extra+strlen(extra), "Rx duplicate frame = %ld\n", (ULONG)pAd->WlanCounters.FrameDuplicateCount.QuadPart);
1901 sprintf(extra+strlen(extra), "False CCA (one second) = %ld\n", (ULONG)pAd->RalinkCounters.OneSecFalseCCACnt);
1903 sprintf(extra+strlen(extra), "RSSI-A = %ld\n", (LONG)(pAd->StaCfg.RssiSample.LastRssi0 - pAd->BbpRssiToDbmDelta));
1904 sprintf(extra+strlen(extra), "RSSI-B (if available) = %ld\n", (LONG)(pAd->StaCfg.RssiSample.LastRssi1 - pAd->BbpRssiToDbmDelta));
1905 sprintf(extra+strlen(extra), "RSSI-C (if available) = %ld\n\n", (LONG)(pAd->StaCfg.RssiSample.LastRssi2 - pAd->BbpRssiToDbmDelta));
1907 #ifdef WPA_SUPPLICANT_SUPPORT
1908 sprintf(extra+strlen(extra), "WpaSupplicantUP = %d\n\n", pAd->StaCfg.WpaSupplicantUP);
1909 #endif // WPA_SUPPLICANT_SUPPORT //
1912 wrq->length = strlen(extra) + 1; // 1: size of '\0'
1913 DBGPRINT(RT_DEBUG_TRACE, ("<== rt_private_get_statistics, wrq->length = %d\n", wrq->length));
1918 #ifdef DOT11_N_SUPPORT
1920 IN PRTMP_ADAPTER pAd,
1924 BA_ORI_ENTRY *pOriBAEntry;
1925 BA_REC_ENTRY *pRecBAEntry;
1927 for (i=0; i<MAX_LEN_OF_MAC_TABLE; i++)
1929 PMAC_TABLE_ENTRY pEntry = &pAd->MacTab.Content[i];
1930 if (((pEntry->ValidAsCLI || pEntry->ValidAsApCli) && (pEntry->Sst == SST_ASSOC))
1931 || (pEntry->ValidAsWDS) || (pEntry->ValidAsMesh))
1933 sprintf(pOutBuf + strlen(pOutBuf), "\n%02X:%02X:%02X:%02X:%02X:%02X (Aid = %d) (AP) -\n",
1934 pEntry->Addr[0], pEntry->Addr[1], pEntry->Addr[2],
1935 pEntry->Addr[3], pEntry->Addr[4], pEntry->Addr[5], pEntry->Aid);
1937 sprintf(pOutBuf, "%s[Recipient]\n", pOutBuf);
1938 for (j=0; j < NUM_OF_TID; j++)
1940 if (pEntry->BARecWcidArray[j] != 0)
1942 pRecBAEntry =&pAd->BATable.BARecEntry[pEntry->BARecWcidArray[j]];
1943 sprintf(pOutBuf + strlen(pOutBuf), "TID=%d, BAWinSize=%d, LastIndSeq=%d, ReorderingPkts=%d\n", j, pRecBAEntry->BAWinSize, pRecBAEntry->LastIndSeq, pRecBAEntry->list.qlen);
1946 sprintf(pOutBuf, "%s\n", pOutBuf);
1948 sprintf(pOutBuf, "%s[Originator]\n", pOutBuf);
1949 for (j=0; j < NUM_OF_TID; j++)
1951 if (pEntry->BAOriWcidArray[j] != 0)
1953 pOriBAEntry =&pAd->BATable.BAOriEntry[pEntry->BAOriWcidArray[j]];
1954 sprintf(pOutBuf + strlen(pOutBuf), "TID=%d, BAWinSize=%d, StartSeq=%d, CurTxSeq=%d\n", j, pOriBAEntry->BAWinSize, pOriBAEntry->Sequence, pEntry->TxSeq[j]);
1957 sprintf(pOutBuf, "%s\n\n", pOutBuf);
1959 if (strlen(pOutBuf) > (IW_PRIV_SIZE_MASK - 30))
1965 #endif // DOT11_N_SUPPORT //
1968 rt_private_show(struct net_device *dev, struct iw_request_info *info,
1969 struct iw_point *wrq, char *extra)
1972 VIRTUAL_ADAPTER *pVirtualAd = NULL;
1975 u32 subcmd = wrq->flags;
1977 if (dev->priv_flags == INT_MAIN)
1981 pVirtualAd = dev->ml_priv;
1982 pAd = pVirtualAd->RtmpDev->ml_priv;
1984 pObj = (POS_COOKIE) pAd->OS_Cookie;
1988 /* if 1st open fail, pAd will be free;
1989 So the net_dev->ml_priv will be NULL in 2rd open */
1998 memset(extra, 0x00, IW_PRIV_SIZE_MASK);
2001 pObj->ioctl_if_type = INT_MAIN;
2002 pObj->ioctl_if = MAIN_MBSSID;
2008 case SHOW_CONN_STATUS:
2009 if (MONITOR_ON(pAd))
2011 #ifdef DOT11_N_SUPPORT
2012 if (pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED &&
2013 pAd->CommonCfg.RegTransmitSetting.field.BW)
2014 sprintf(extra, "Monitor Mode(CentralChannel %d)\n", pAd->CommonCfg.CentralChannel);
2016 #endif // DOT11_N_SUPPORT //
2017 sprintf(extra, "Monitor Mode(Channel %d)\n", pAd->CommonCfg.Channel);
2021 if (pAd->IndicateMediaState == NdisMediaStateConnected)
2025 sprintf(extra, "Connected(AP: %s[%02X:%02X:%02X:%02X:%02X:%02X])\n",
2026 pAd->CommonCfg.Ssid,
2027 pAd->CommonCfg.Bssid[0],
2028 pAd->CommonCfg.Bssid[1],
2029 pAd->CommonCfg.Bssid[2],
2030 pAd->CommonCfg.Bssid[3],
2031 pAd->CommonCfg.Bssid[4],
2032 pAd->CommonCfg.Bssid[5]);
2033 DBGPRINT(RT_DEBUG_TRACE ,("Ssid=%s ,Ssidlen = %d\n",pAd->CommonCfg.Ssid, pAd->CommonCfg.SsidLen));
2035 else if (ADHOC_ON(pAd))
2036 sprintf(extra, "Connected\n");
2040 sprintf(extra, "Disconnected\n");
2041 DBGPRINT(RT_DEBUG_TRACE ,("ConnStatus is not connected\n"));
2044 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2046 case SHOW_DRVIER_VERION:
2047 sprintf(extra, "Driver version-%s, %s %s\n", STA_DRIVER_VERSION, __DATE__, __TIME__ );
2048 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2050 #ifdef DOT11_N_SUPPORT
2052 getBaInfo(pAd, extra);
2053 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2055 #endif // DOT11_N_SUPPORT //
2056 case SHOW_DESC_INFO:
2058 Show_DescInfo_Proc(pAd, NULL);
2059 wrq->length = 0; // 1: size of '\0'
2063 if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
2065 sprintf(extra, "Scanning\n");
2066 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2069 pAd->StaCfg.bSwRadio = FALSE;
2070 if (pAd->StaCfg.bRadio != (pAd->StaCfg.bHwRadio && pAd->StaCfg.bSwRadio))
2072 pAd->StaCfg.bRadio = (pAd->StaCfg.bHwRadio && pAd->StaCfg.bSwRadio);
2073 if (pAd->StaCfg.bRadio == FALSE)
2076 // Update extra information
2077 pAd->ExtraInfo = SW_RADIO_OFF;
2080 sprintf(extra, "Radio Off\n");
2081 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2084 pAd->StaCfg.bSwRadio = TRUE;
2085 //if (pAd->StaCfg.bRadio != (pAd->StaCfg.bHwRadio && pAd->StaCfg.bSwRadio))
2087 pAd->StaCfg.bRadio = (pAd->StaCfg.bHwRadio && pAd->StaCfg.bSwRadio);
2088 if (pAd->StaCfg.bRadio == TRUE)
2091 // Update extra information
2092 pAd->ExtraInfo = EXTRA_INFO_CLEAR;
2095 sprintf(extra, "Radio On\n");
2096 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2099 case SHOW_CFG_VALUE:
2101 Status = RTMPShowCfgValue(pAd, wrq->pointer, extra);
2103 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2107 DBGPRINT(RT_DEBUG_TRACE, ("%s - unknow subcmd = %d\n", __func__, subcmd));
2115 int rt_ioctl_siwmlme(struct net_device *dev,
2116 struct iw_request_info *info,
2117 union iwreq_data *wrqu,
2120 PRTMP_ADAPTER pAd = dev->ml_priv;
2121 struct iw_mlme *pMlme = (struct iw_mlme *)wrqu->data.pointer;
2122 MLME_QUEUE_ELEM MsgElem;
2123 MLME_DISASSOC_REQ_STRUCT DisAssocReq;
2124 MLME_DEAUTH_REQ_STRUCT DeAuthReq;
2126 DBGPRINT(RT_DEBUG_TRACE, ("====> %s\n", __func__));
2133 #ifdef IW_MLME_DEAUTH
2134 case IW_MLME_DEAUTH:
2135 DBGPRINT(RT_DEBUG_TRACE, ("====> %s - IW_MLME_DEAUTH\n", __func__));
2136 COPY_MAC_ADDR(DeAuthReq.Addr, pAd->CommonCfg.Bssid);
2137 DeAuthReq.Reason = pMlme->reason_code;
2138 MsgElem.MsgLen = sizeof(MLME_DEAUTH_REQ_STRUCT);
2139 NdisMoveMemory(MsgElem.Msg, &DeAuthReq, sizeof(MLME_DEAUTH_REQ_STRUCT));
2140 MlmeDeauthReqAction(pAd, &MsgElem);
2143 LinkDown(pAd, FALSE);
2144 pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
2147 #endif // IW_MLME_DEAUTH //
2148 #ifdef IW_MLME_DISASSOC
2149 case IW_MLME_DISASSOC:
2150 DBGPRINT(RT_DEBUG_TRACE, ("====> %s - IW_MLME_DISASSOC\n", __func__));
2151 COPY_MAC_ADDR(DisAssocReq.Addr, pAd->CommonCfg.Bssid);
2152 DisAssocReq.Reason = pMlme->reason_code;
2154 MsgElem.Machine = ASSOC_STATE_MACHINE;
2155 MsgElem.MsgType = MT2_MLME_DISASSOC_REQ;
2156 MsgElem.MsgLen = sizeof(MLME_DISASSOC_REQ_STRUCT);
2157 NdisMoveMemory(MsgElem.Msg, &DisAssocReq, sizeof(MLME_DISASSOC_REQ_STRUCT));
2159 pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_OID_DISASSOC;
2160 MlmeDisassocReqAction(pAd, &MsgElem);
2162 #endif // IW_MLME_DISASSOC //
2164 DBGPRINT(RT_DEBUG_TRACE, ("====> %s - Unknow Command\n", __func__));
2170 #endif // SIOCSIWMLME //
2172 #if WIRELESS_EXT > 17
2173 int rt_ioctl_siwauth(struct net_device *dev,
2174 struct iw_request_info *info,
2175 union iwreq_data *wrqu, char *extra)
2177 PRTMP_ADAPTER pAdapter = dev->ml_priv;
2178 struct iw_param *param = &wrqu->param;
2180 //check if the interface is down
2181 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
2183 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
2186 switch (param->flags & IW_AUTH_INDEX) {
2187 case IW_AUTH_WPA_VERSION:
2188 if (param->value == IW_AUTH_WPA_VERSION_WPA)
2190 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPAPSK;
2191 if (pAdapter->StaCfg.BssType == BSS_ADHOC)
2192 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPANone;
2194 else if (param->value == IW_AUTH_WPA_VERSION_WPA2)
2195 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA2PSK;
2197 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_WPA_VERSION - param->value = %d!\n", __func__, param->value));
2199 case IW_AUTH_CIPHER_PAIRWISE:
2200 if (param->value == IW_AUTH_CIPHER_NONE)
2202 pAdapter->StaCfg.WepStatus = Ndis802_11WEPDisabled;
2203 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
2204 pAdapter->StaCfg.PairCipher = Ndis802_11WEPDisabled;
2206 else if (param->value == IW_AUTH_CIPHER_WEP40 ||
2207 param->value == IW_AUTH_CIPHER_WEP104)
2209 pAdapter->StaCfg.WepStatus = Ndis802_11WEPEnabled;
2210 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
2211 pAdapter->StaCfg.PairCipher = Ndis802_11WEPEnabled;
2212 #ifdef WPA_SUPPLICANT_SUPPORT
2213 pAdapter->StaCfg.IEEE8021X = FALSE;
2214 #endif // WPA_SUPPLICANT_SUPPORT //
2216 else if (param->value == IW_AUTH_CIPHER_TKIP)
2218 pAdapter->StaCfg.WepStatus = Ndis802_11Encryption2Enabled;
2219 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
2220 pAdapter->StaCfg.PairCipher = Ndis802_11Encryption2Enabled;
2222 else if (param->value == IW_AUTH_CIPHER_CCMP)
2224 pAdapter->StaCfg.WepStatus = Ndis802_11Encryption3Enabled;
2225 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
2226 pAdapter->StaCfg.PairCipher = Ndis802_11Encryption3Enabled;
2228 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_CIPHER_PAIRWISE - param->value = %d!\n", __func__, param->value));
2230 case IW_AUTH_CIPHER_GROUP:
2231 if (param->value == IW_AUTH_CIPHER_NONE)
2233 pAdapter->StaCfg.GroupCipher = Ndis802_11WEPDisabled;
2235 else if (param->value == IW_AUTH_CIPHER_WEP40 ||
2236 param->value == IW_AUTH_CIPHER_WEP104)
2238 pAdapter->StaCfg.GroupCipher = Ndis802_11WEPEnabled;
2240 else if (param->value == IW_AUTH_CIPHER_TKIP)
2242 pAdapter->StaCfg.GroupCipher = Ndis802_11Encryption2Enabled;
2244 else if (param->value == IW_AUTH_CIPHER_CCMP)
2246 pAdapter->StaCfg.GroupCipher = Ndis802_11Encryption3Enabled;
2248 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_CIPHER_GROUP - param->value = %d!\n", __func__, param->value));
2250 case IW_AUTH_KEY_MGMT:
2251 if (param->value == IW_AUTH_KEY_MGMT_802_1X)
2253 if (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK)
2255 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA;
2256 #ifdef WPA_SUPPLICANT_SUPPORT
2257 pAdapter->StaCfg.IEEE8021X = FALSE;
2258 #endif // WPA_SUPPLICANT_SUPPORT //
2260 else if (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK)
2262 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA2;
2263 #ifdef WPA_SUPPLICANT_SUPPORT
2264 pAdapter->StaCfg.IEEE8021X = FALSE;
2265 #endif // WPA_SUPPLICANT_SUPPORT //
2267 #ifdef WPA_SUPPLICANT_SUPPORT
2270 pAdapter->StaCfg.IEEE8021X = TRUE;
2271 #endif // WPA_SUPPLICANT_SUPPORT //
2273 else if (param->value == 0)
2275 STA_PORT_SECURED(pAdapter);
2277 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_KEY_MGMT - param->value = %d!\n", __func__, param->value));
2279 case IW_AUTH_RX_UNENCRYPTED_EAPOL:
2281 case IW_AUTH_PRIVACY_INVOKED:
2282 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_PRIVACY_INVOKED - param->value = %d!\n", __func__, param->value));
2284 case IW_AUTH_DROP_UNENCRYPTED:
2285 if (param->value != 0)
2286 pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED;
2289 STA_PORT_SECURED(pAdapter);
2291 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_WPA_VERSION - param->value = %d!\n", __func__, param->value));
2293 case IW_AUTH_80211_AUTH_ALG:
2294 if (param->value & IW_AUTH_ALG_SHARED_KEY)
2296 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeShared;
2298 else if (param->value & IW_AUTH_ALG_OPEN_SYSTEM)
2300 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
2304 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_80211_AUTH_ALG - param->value = %d!\n", __func__, param->value));
2306 case IW_AUTH_WPA_ENABLED:
2307 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_WPA_ENABLED - Driver supports WPA!(param->value = %d)\n", __func__, param->value));
2316 int rt_ioctl_giwauth(struct net_device *dev,
2317 struct iw_request_info *info,
2318 union iwreq_data *wrqu, char *extra)
2320 PRTMP_ADAPTER pAdapter = dev->ml_priv;
2321 struct iw_param *param = &wrqu->param;
2323 //check if the interface is down
2324 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
2326 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
2330 switch (param->flags & IW_AUTH_INDEX) {
2331 case IW_AUTH_DROP_UNENCRYPTED:
2332 param->value = (pAdapter->StaCfg.WepStatus == Ndis802_11WEPDisabled) ? 0 : 1;
2335 case IW_AUTH_80211_AUTH_ALG:
2336 param->value = (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeShared) ? IW_AUTH_ALG_SHARED_KEY : IW_AUTH_ALG_OPEN_SYSTEM;
2339 case IW_AUTH_WPA_ENABLED:
2340 param->value = (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA) ? 1 : 0;
2346 DBGPRINT(RT_DEBUG_TRACE, ("rt_ioctl_giwauth::param->value = %d!\n", param->value));
2350 void fnSetCipherKey(
2351 IN PRTMP_ADAPTER pAdapter,
2355 IN struct iw_encode_ext *ext)
2357 RTMP_CLEAR_PSFLAG(pAdapter, fRTMP_PS_CAN_GO_SLEEP);
2358 if (RTMP_TEST_PSFLAG(pAdapter, fRTMP_PS_SET_PCI_CLK_OFF_COMMAND))
2360 if (pAdapter->StaCfg.bRadio == FALSE)
2362 RTMP_SET_PSFLAG(pAdapter, fRTMP_PS_CAN_GO_SLEEP);
2365 DBGPRINT(RT_DEBUG_TRACE,("RTMPWPAAddKeyProc1==>\n"));
2366 RTMPPCIeLinkCtrlValueRestore(pAdapter, RESTORE_HALT);
2367 RTMPusecDelay(6000);
2368 pAdapter->bPCIclkOff = FALSE;
2371 NdisZeroMemory(&pAdapter->SharedKey[BSS0][keyIdx], sizeof(CIPHER_KEY));
2372 pAdapter->SharedKey[BSS0][keyIdx].KeyLen = LEN_TKIP_EK;
2373 NdisMoveMemory(pAdapter->SharedKey[BSS0][keyIdx].Key, ext->key, LEN_TKIP_EK);
2374 NdisMoveMemory(pAdapter->SharedKey[BSS0][keyIdx].TxMic, ext->key + LEN_TKIP_EK, LEN_TKIP_TXMICK);
2375 NdisMoveMemory(pAdapter->SharedKey[BSS0][keyIdx].RxMic, ext->key + LEN_TKIP_EK + LEN_TKIP_TXMICK, LEN_TKIP_RXMICK);
2376 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CipherAlg;
2378 // Update group key information to ASIC Shared Key Table
2379 AsicAddSharedKeyEntry(pAdapter,
2382 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg,
2383 pAdapter->SharedKey[BSS0][keyIdx].Key,
2384 pAdapter->SharedKey[BSS0][keyIdx].TxMic,
2385 pAdapter->SharedKey[BSS0][keyIdx].RxMic);
2388 // Update ASIC WCID attribute table and IVEIV table
2389 RTMPAddWcidAttributeEntry(pAdapter,
2392 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg,
2395 // Update ASIC WCID attribute table and IVEIV table
2396 RTMPAddWcidAttributeEntry(pAdapter,
2399 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg,
2400 &pAdapter->MacTab.Content[BSSID_WCID]);
2402 RTMP_SET_PSFLAG(pAdapter, fRTMP_PS_CAN_GO_SLEEP);
2405 int rt_ioctl_siwencodeext(struct net_device *dev,
2406 struct iw_request_info *info,
2407 union iwreq_data *wrqu,
2410 PRTMP_ADAPTER pAdapter = dev->ml_priv;
2411 struct iw_point *encoding = &wrqu->encoding;
2412 struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
2413 int keyIdx, alg = ext->alg;
2415 //check if the interface is down
2416 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
2418 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
2422 if (encoding->flags & IW_ENCODE_DISABLED)
2424 keyIdx = (encoding->flags & IW_ENCODE_INDEX) - 1;
2425 // set BSSID wcid entry of the Pair-wise Key table as no-security mode
2426 AsicRemovePairwiseKeyEntry(pAdapter, BSS0, BSSID_WCID);
2427 pAdapter->SharedKey[BSS0][keyIdx].KeyLen = 0;
2428 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CIPHER_NONE;
2429 AsicRemoveSharedKeyEntry(pAdapter, 0, (UCHAR)keyIdx);
2430 NdisZeroMemory(&pAdapter->SharedKey[BSS0][keyIdx], sizeof(CIPHER_KEY));
2431 DBGPRINT(RT_DEBUG_TRACE, ("%s::Remove all keys!(encoding->flags = %x)\n", __func__, encoding->flags));
2435 // Get Key Index and convet to our own defined key index
2436 keyIdx = (encoding->flags & IW_ENCODE_INDEX) - 1;
2437 if((keyIdx < 0) || (keyIdx >= NR_WEP_KEYS))
2440 if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
2442 pAdapter->StaCfg.DefaultKeyId = keyIdx;
2443 DBGPRINT(RT_DEBUG_TRACE, ("%s::DefaultKeyId = %d\n", __func__, pAdapter->StaCfg.DefaultKeyId));
2447 case IW_ENCODE_ALG_NONE:
2448 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_ENCODE_ALG_NONE\n", __func__));
2450 case IW_ENCODE_ALG_WEP:
2451 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_ENCODE_ALG_WEP - ext->key_len = %d, keyIdx = %d\n", __func__, ext->key_len, keyIdx));
2452 if (ext->key_len == MAX_WEP_KEY_SIZE)
2454 pAdapter->SharedKey[BSS0][keyIdx].KeyLen = MAX_WEP_KEY_SIZE;
2455 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CIPHER_WEP128;
2457 else if (ext->key_len == MIN_WEP_KEY_SIZE)
2459 pAdapter->SharedKey[BSS0][keyIdx].KeyLen = MIN_WEP_KEY_SIZE;
2460 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CIPHER_WEP64;
2465 NdisZeroMemory(pAdapter->SharedKey[BSS0][keyIdx].Key, 16);
2466 NdisMoveMemory(pAdapter->SharedKey[BSS0][keyIdx].Key, ext->key, ext->key_len);
2468 if (pAdapter->StaCfg.GroupCipher == Ndis802_11GroupWEP40Enabled ||
2469 pAdapter->StaCfg.GroupCipher == Ndis802_11GroupWEP104Enabled)
2471 // Set Group key material to Asic
2472 AsicAddSharedKeyEntry(pAdapter, BSS0, keyIdx, pAdapter->SharedKey[BSS0][keyIdx].CipherAlg, pAdapter->SharedKey[BSS0][keyIdx].Key, NULL, NULL);
2474 // Update WCID attribute table and IVEIV table for this group key table
2475 RTMPAddWcidAttributeEntry(pAdapter, BSS0, keyIdx, pAdapter->SharedKey[BSS0][keyIdx].CipherAlg, NULL);
2477 STA_PORT_SECURED(pAdapter);
2479 // Indicate Connected for GUI
2480 pAdapter->IndicateMediaState = NdisMediaStateConnected;
2483 case IW_ENCODE_ALG_TKIP:
2484 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_ENCODE_ALG_TKIP - keyIdx = %d, ext->key_len = %d\n", __func__, keyIdx, ext->key_len));
2485 if (ext->key_len == 32)
2487 if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
2489 fnSetCipherKey(pAdapter, keyIdx, CIPHER_TKIP, FALSE, ext);
2490 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA2)
2492 STA_PORT_SECURED(pAdapter);
2495 else if (ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY)
2497 fnSetCipherKey(pAdapter, keyIdx, CIPHER_TKIP, TRUE, ext);
2499 // set 802.1x port control
2500 STA_PORT_SECURED(pAdapter);
2506 case IW_ENCODE_ALG_CCMP:
2507 if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
2509 fnSetCipherKey(pAdapter, keyIdx, CIPHER_AES, FALSE, ext);
2510 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA2)
2511 STA_PORT_SECURED(pAdapter);
2513 else if (ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY)
2515 fnSetCipherKey(pAdapter, keyIdx, CIPHER_AES, TRUE, ext);
2517 // set 802.1x port control
2518 STA_PORT_SECURED(pAdapter);
2530 rt_ioctl_giwencodeext(struct net_device *dev,
2531 struct iw_request_info *info,
2532 union iwreq_data *wrqu, char *extra)
2534 PRTMP_ADAPTER pAd = dev->ml_priv;
2536 struct iw_point *encoding = &wrqu->encoding;
2537 struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
2538 int idx, max_key_len;
2540 DBGPRINT(RT_DEBUG_TRACE ,("===> rt_ioctl_giwencodeext\n"));
2542 max_key_len = encoding->length - sizeof(*ext);
2543 if (max_key_len < 0)
2546 idx = encoding->flags & IW_ENCODE_INDEX;
2549 if (idx < 1 || idx > 4)
2553 if ((pAd->StaCfg.WepStatus == Ndis802_11Encryption2Enabled) ||
2554 (pAd->StaCfg.WepStatus == Ndis802_11Encryption3Enabled))
2556 if (idx != pAd->StaCfg.DefaultKeyId)
2564 idx = pAd->StaCfg.DefaultKeyId;
2566 encoding->flags = idx + 1;
2567 memset(ext, 0, sizeof(*ext));
2570 switch(pAd->StaCfg.WepStatus) {
2571 case Ndis802_11WEPDisabled:
2572 ext->alg = IW_ENCODE_ALG_NONE;
2573 encoding->flags |= IW_ENCODE_DISABLED;
2575 case Ndis802_11WEPEnabled:
2576 ext->alg = IW_ENCODE_ALG_WEP;
2577 if (pAd->SharedKey[BSS0][idx].KeyLen > max_key_len)
2581 ext->key_len = pAd->SharedKey[BSS0][idx].KeyLen;
2582 pKey = &(pAd->SharedKey[BSS0][idx].Key[0]);
2585 case Ndis802_11Encryption2Enabled:
2586 case Ndis802_11Encryption3Enabled:
2587 if (pAd->StaCfg.WepStatus == Ndis802_11Encryption2Enabled)
2588 ext->alg = IW_ENCODE_ALG_TKIP;
2590 ext->alg = IW_ENCODE_ALG_CCMP;
2592 if (max_key_len < 32)
2597 pKey = &pAd->StaCfg.PMK[0];
2604 if (ext->key_len && pKey)
2606 encoding->flags |= IW_ENCODE_ENABLED;
2607 memcpy(ext->key, pKey, ext->key_len);
2614 int rt_ioctl_siwgenie(struct net_device *dev,
2615 struct iw_request_info *info,
2616 union iwreq_data *wrqu, char *extra)
2618 PRTMP_ADAPTER pAd = dev->ml_priv;
2620 if (wrqu->data.length > MAX_LEN_OF_RSNIE ||
2621 (wrqu->data.length && extra == NULL))
2624 if (wrqu->data.length)
2626 pAd->StaCfg.RSNIE_Len = wrqu->data.length;
2627 NdisMoveMemory(&pAd->StaCfg.RSN_IE[0], extra, pAd->StaCfg.RSNIE_Len);
2631 pAd->StaCfg.RSNIE_Len = 0;
2632 NdisZeroMemory(&pAd->StaCfg.RSN_IE[0], MAX_LEN_OF_RSNIE);
2637 #endif // SIOCSIWGENIE //
2639 int rt_ioctl_giwgenie(struct net_device *dev,
2640 struct iw_request_info *info,
2641 union iwreq_data *wrqu, char *extra)
2643 PRTMP_ADAPTER pAd = dev->ml_priv;
2645 if ((pAd->StaCfg.RSNIE_Len == 0) ||
2646 (pAd->StaCfg.AuthMode < Ndis802_11AuthModeWPA))
2648 wrqu->data.length = 0;
2652 #ifdef NATIVE_WPA_SUPPLICANT_SUPPORT
2654 if (pAd->StaCfg.WpaSupplicantUP == WPA_SUPPLICANT_ENABLE)
2656 if (wrqu->data.length < pAd->StaCfg.RSNIE_Len)
2659 wrqu->data.length = pAd->StaCfg.RSNIE_Len;
2660 memcpy(extra, &pAd->StaCfg.RSN_IE[0], pAd->StaCfg.RSNIE_Len);
2663 #endif // SIOCSIWGENIE //
2664 #endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
2666 UCHAR RSNIe = IE_WPA;
2668 if (wrqu->data.length < (pAd->StaCfg.RSNIE_Len + 2)) // ID, Len
2670 wrqu->data.length = pAd->StaCfg.RSNIE_Len + 2;
2672 if ((pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK) ||
2673 (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2))
2676 extra[0] = (char)RSNIe;
2677 extra[1] = pAd->StaCfg.RSNIE_Len;
2678 memcpy(extra+2, &pAd->StaCfg.RSN_IE[0], pAd->StaCfg.RSNIE_Len);
2684 int rt_ioctl_siwpmksa(struct net_device *dev,
2685 struct iw_request_info *info,
2686 union iwreq_data *wrqu,
2689 PRTMP_ADAPTER pAd = dev->ml_priv;
2690 struct iw_pmksa *pPmksa = (struct iw_pmksa *)wrqu->data.pointer;
2691 INT CachedIdx = 0, idx = 0;
2696 DBGPRINT(RT_DEBUG_TRACE ,("===> rt_ioctl_siwpmksa\n"));
2699 case IW_PMKSA_FLUSH:
2700 NdisZeroMemory(pAd->StaCfg.SavedPMK, sizeof(BSSID_INFO)*PMKID_NO);
2701 DBGPRINT(RT_DEBUG_TRACE ,("rt_ioctl_siwpmksa - IW_PMKSA_FLUSH\n"));
2703 case IW_PMKSA_REMOVE:
2704 for (CachedIdx = 0; CachedIdx < pAd->StaCfg.SavedPMKNum; CachedIdx++)
2706 // compare the BSSID
2707 if (NdisEqualMemory(pPmksa->bssid.sa_data, pAd->StaCfg.SavedPMK[CachedIdx].BSSID, MAC_ADDR_LEN))
2709 NdisZeroMemory(pAd->StaCfg.SavedPMK[CachedIdx].BSSID, MAC_ADDR_LEN);
2710 NdisZeroMemory(pAd->StaCfg.SavedPMK[CachedIdx].PMKID, 16);
2711 for (idx = CachedIdx; idx < (pAd->StaCfg.SavedPMKNum - 1); idx++)
2713 NdisMoveMemory(&pAd->StaCfg.SavedPMK[idx].BSSID[0], &pAd->StaCfg.SavedPMK[idx+1].BSSID[0], MAC_ADDR_LEN);
2714 NdisMoveMemory(&pAd->StaCfg.SavedPMK[idx].PMKID[0], &pAd->StaCfg.SavedPMK[idx+1].PMKID[0], 16);
2716 pAd->StaCfg.SavedPMKNum--;
2721 DBGPRINT(RT_DEBUG_TRACE ,("rt_ioctl_siwpmksa - IW_PMKSA_REMOVE\n"));
2724 for (CachedIdx = 0; CachedIdx < pAd->StaCfg.SavedPMKNum; CachedIdx++)
2726 // compare the BSSID
2727 if (NdisEqualMemory(pPmksa->bssid.sa_data, pAd->StaCfg.SavedPMK[CachedIdx].BSSID, MAC_ADDR_LEN))
2731 // Found, replace it
2732 if (CachedIdx < PMKID_NO)
2734 DBGPRINT(RT_DEBUG_OFF, ("Update PMKID, idx = %d\n", CachedIdx));
2735 NdisMoveMemory(&pAd->StaCfg.SavedPMK[CachedIdx].BSSID[0], pPmksa->bssid.sa_data, MAC_ADDR_LEN);
2736 NdisMoveMemory(&pAd->StaCfg.SavedPMK[CachedIdx].PMKID[0], pPmksa->pmkid, 16);
2737 pAd->StaCfg.SavedPMKNum++;
2739 // Not found, replace the last one
2742 // Randomly replace one
2743 CachedIdx = (pPmksa->bssid.sa_data[5] % PMKID_NO);
2744 DBGPRINT(RT_DEBUG_OFF, ("Update PMKID, idx = %d\n", CachedIdx));
2745 NdisMoveMemory(&pAd->StaCfg.SavedPMK[CachedIdx].BSSID[0], pPmksa->bssid.sa_data, MAC_ADDR_LEN);
2746 NdisMoveMemory(&pAd->StaCfg.SavedPMK[CachedIdx].PMKID[0], pPmksa->pmkid, 16);
2749 DBGPRINT(RT_DEBUG_TRACE ,("rt_ioctl_siwpmksa - IW_PMKSA_ADD\n"));
2752 DBGPRINT(RT_DEBUG_TRACE ,("rt_ioctl_siwpmksa - Unknow Command!!\n"));
2758 #endif // #if WIRELESS_EXT > 17
2762 rt_private_ioctl_bbp(struct net_device *dev, struct iw_request_info *info,
2763 struct iw_point *wrq, char *extra)
2770 BOOLEAN bIsPrintAllBBP = FALSE;
2772 PRTMP_ADAPTER pAdapter = dev->ml_priv;
2775 memset(extra, 0x00, IW_PRIV_SIZE_MASK);
2777 if (wrq->length > 1) //No parameters.
2779 sprintf(extra, "\n");
2781 //Parsing Read or Write
2782 this_char = wrq->pointer;
2783 DBGPRINT(RT_DEBUG_TRACE, ("this_char=%s\n", this_char));
2787 if ((value = rtstrchr(this_char, '=')) != NULL)
2790 if (!value || !*value)
2792 DBGPRINT(RT_DEBUG_TRACE, ("this_char=%s, value=%s\n", this_char, value));
2793 if (sscanf(this_char, "%d", &(bbpId)) == 1)
2798 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, ®BBP);
2800 sprintf(extra+strlen(extra), "R%02d[0x%02X]:%02X\n", bbpId, bbpId*2, regBBP);
2801 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2802 DBGPRINT(RT_DEBUG_TRACE, ("msg=%s\n", extra));
2805 {//Invalid parametes, so default printk all bbp
2806 bIsPrintAllBBP = TRUE;
2811 { //Invalid parametes, so default printk all bbp
2812 bIsPrintAllBBP = TRUE;
2818 if ((sscanf(this_char, "%d", &(bbpId)) == 1) && (sscanf(value, "%x", &(bbpValue)) == 1))
2823 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, bbpId, bbpValue);
2824 //Read it back for showing
2825 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, ®BBP);
2827 sprintf(extra+strlen(extra), "R%02d[0x%02X]:%02X\n", bbpId, bbpId*2, regBBP);
2828 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2829 DBGPRINT(RT_DEBUG_TRACE, ("msg=%s\n", extra));
2832 {//Invalid parametes, so default printk all bbp
2833 bIsPrintAllBBP = TRUE;
2838 { //Invalid parametes, so default printk all bbp
2839 bIsPrintAllBBP = TRUE;
2845 bIsPrintAllBBP = TRUE;
2850 memset(extra, 0x00, IW_PRIV_SIZE_MASK);
2851 sprintf(extra, "\n");
2852 for (bbpId = 0; bbpId <= 136; bbpId++)
2854 if (strlen(extra) >= (IW_PRIV_SIZE_MASK - 10))
2856 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, ®BBP);
2857 sprintf(extra+strlen(extra), "R%02d[0x%02X]:%02X ", bbpId, bbpId*2, regBBP);
2859 sprintf(extra+strlen(extra), "\n");
2862 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2863 DBGPRINT(RT_DEBUG_TRACE, ("wrq->length = %d\n", wrq->length));
2866 DBGPRINT(RT_DEBUG_TRACE, ("<==rt_private_ioctl_bbp\n\n"));
2872 int rt_ioctl_siwrate(struct net_device *dev,
2873 struct iw_request_info *info,
2874 union iwreq_data *wrqu, char *extra)
2876 PRTMP_ADAPTER pAd = dev->ml_priv;
2877 UINT32 rate = wrqu->bitrate.value, fixed = wrqu->bitrate.fixed;
2879 //check if the interface is down
2880 if(!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_IN_USE))
2882 DBGPRINT(RT_DEBUG_TRACE, ("rt_ioctl_siwrate::Network is down!\n"));
2886 DBGPRINT(RT_DEBUG_TRACE, ("rt_ioctl_siwrate::(rate = %d, fixed = %d)\n", rate, fixed));
2887 /* rate = -1 => auto rate
2888 rate = X, fixed = 1 => (fixed rate X)
2893 pAd->StaCfg.DesiredTransmitSetting.field.MCS = MCS_AUTO;
2894 pAd->StaCfg.bAutoTxRateSwitch = TRUE;
2895 if ((pAd->CommonCfg.PhyMode <= PHY_11G) ||
2896 (pAd->MacTab.Content[BSSID_WCID].HTPhyMode.field.MODE <= MODE_OFDM))
2897 RTMPSetDesiredRates(pAd, -1);
2899 #ifdef DOT11_N_SUPPORT
2901 #endif // DOT11_N_SUPPORT //
2907 pAd->StaCfg.bAutoTxRateSwitch = FALSE;
2908 if ((pAd->CommonCfg.PhyMode <= PHY_11G) ||
2909 (pAd->MacTab.Content[BSSID_WCID].HTPhyMode.field.MODE <= MODE_OFDM))
2910 RTMPSetDesiredRates(pAd, rate);
2913 pAd->StaCfg.DesiredTransmitSetting.field.MCS = MCS_AUTO;
2914 #ifdef DOT11_N_SUPPORT
2916 #endif // DOT11_N_SUPPORT //
2918 DBGPRINT(RT_DEBUG_TRACE, ("rt_ioctl_siwrate::(HtMcs=%d)\n",pAd->StaCfg.DesiredTransmitSetting.field.MCS));
2922 // TODO: rate = X, fixed = 0 => (rates <= X)
2930 int rt_ioctl_giwrate(struct net_device *dev,
2931 struct iw_request_info *info,
2932 union iwreq_data *wrqu, char *extra)
2934 PRTMP_ADAPTER pAd = dev->ml_priv;
2935 int rate_index = 0, rate_count = 0;
2936 HTTRANSMIT_SETTING ht_setting;
2937 __s32 ralinkrate[] =
2938 {2, 4, 11, 22, // CCK
2939 12, 18, 24, 36, 48, 72, 96, 108, // OFDM
2940 13, 26, 39, 52, 78, 104, 117, 130, 26, 52, 78, 104, 156, 208, 234, 260, // 20MHz, 800ns GI, MCS: 0 ~ 15
2941 39, 78, 117, 156, 234, 312, 351, 390, // 20MHz, 800ns GI, MCS: 16 ~ 23
2942 27, 54, 81, 108, 162, 216, 243, 270, 54, 108, 162, 216, 324, 432, 486, 540, // 40MHz, 800ns GI, MCS: 0 ~ 15
2943 81, 162, 243, 324, 486, 648, 729, 810, // 40MHz, 800ns GI, MCS: 16 ~ 23
2944 14, 29, 43, 57, 87, 115, 130, 144, 29, 59, 87, 115, 173, 230, 260, 288, // 20MHz, 400ns GI, MCS: 0 ~ 15
2945 43, 87, 130, 173, 260, 317, 390, 433, // 20MHz, 400ns GI, MCS: 16 ~ 23
2946 30, 60, 90, 120, 180, 240, 270, 300, 60, 120, 180, 240, 360, 480, 540, 600, // 40MHz, 400ns GI, MCS: 0 ~ 15
2947 90, 180, 270, 360, 540, 720, 810, 900}; // 40MHz, 400ns GI, MCS: 16 ~ 23
2949 rate_count = sizeof(ralinkrate)/sizeof(__s32);
2950 //check if the interface is down
2951 if(!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_IN_USE))
2953 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
2957 if ((pAd->StaCfg.bAutoTxRateSwitch == FALSE) &&
2959 ((pAd->CommonCfg.PhyMode <= PHY_11G) || (pAd->MacTab.Content[BSSID_WCID].HTPhyMode.field.MODE <= MODE_OFDM)))
2960 ht_setting.word = pAd->StaCfg.HTPhyMode.word;
2962 ht_setting.word = pAd->MacTab.Content[BSSID_WCID].HTPhyMode.word;
2964 #ifdef DOT11_N_SUPPORT
2965 if (ht_setting.field.MODE >= MODE_HTMIX)
2967 rate_index = 12 + ((UCHAR)ht_setting.field.BW *24) + ((UCHAR)ht_setting.field.ShortGI *48) + ((UCHAR)ht_setting.field.MCS);
2970 #endif // DOT11_N_SUPPORT //
2971 if (ht_setting.field.MODE == MODE_OFDM)
2972 rate_index = (UCHAR)(ht_setting.field.MCS) + 4;
2973 else if (ht_setting.field.MODE == MODE_CCK)
2974 rate_index = (UCHAR)(ht_setting.field.MCS);
2979 if (rate_index > rate_count)
2980 rate_index = rate_count;
2982 wrqu->bitrate.value = ralinkrate[rate_index] * 500000;
2983 wrqu->bitrate.disabled = 0;
2988 static const iw_handler rt_handler[] =
2990 (iw_handler) NULL, /* SIOCSIWCOMMIT */
2991 (iw_handler) rt_ioctl_giwname, /* SIOCGIWNAME */
2992 (iw_handler) NULL, /* SIOCSIWNWID */
2993 (iw_handler) NULL, /* SIOCGIWNWID */
2994 (iw_handler) rt_ioctl_siwfreq, /* SIOCSIWFREQ */
2995 (iw_handler) rt_ioctl_giwfreq, /* SIOCGIWFREQ */
2996 (iw_handler) rt_ioctl_siwmode, /* SIOCSIWMODE */
2997 (iw_handler) rt_ioctl_giwmode, /* SIOCGIWMODE */
2998 (iw_handler) NULL, /* SIOCSIWSENS */
2999 (iw_handler) NULL, /* SIOCGIWSENS */
3000 (iw_handler) NULL /* not used */, /* SIOCSIWRANGE */
3001 (iw_handler) rt_ioctl_giwrange, /* SIOCGIWRANGE */
3002 (iw_handler) NULL /* not used */, /* SIOCSIWPRIV */
3003 (iw_handler) NULL /* kernel code */, /* SIOCGIWPRIV */
3004 (iw_handler) NULL /* not used */, /* SIOCSIWSTATS */
3005 (iw_handler) rt28xx_get_wireless_stats /* kernel code */, /* SIOCGIWSTATS */
3006 (iw_handler) NULL, /* SIOCSIWSPY */
3007 (iw_handler) NULL, /* SIOCGIWSPY */
3008 (iw_handler) NULL, /* SIOCSIWTHRSPY */
3009 (iw_handler) NULL, /* SIOCGIWTHRSPY */
3010 (iw_handler) rt_ioctl_siwap, /* SIOCSIWAP */
3011 (iw_handler) rt_ioctl_giwap, /* SIOCGIWAP */
3013 (iw_handler) rt_ioctl_siwmlme, /* SIOCSIWMLME */
3015 (iw_handler) NULL, /* SIOCSIWMLME */
3016 #endif // SIOCSIWMLME //
3017 (iw_handler) rt_ioctl_iwaplist, /* SIOCGIWAPLIST */
3019 (iw_handler) rt_ioctl_siwscan, /* SIOCSIWSCAN */
3020 (iw_handler) rt_ioctl_giwscan, /* SIOCGIWSCAN */
3022 (iw_handler) NULL, /* SIOCSIWSCAN */
3023 (iw_handler) NULL, /* SIOCGIWSCAN */
3024 #endif /* SIOCGIWSCAN */
3025 (iw_handler) rt_ioctl_siwessid, /* SIOCSIWESSID */
3026 (iw_handler) rt_ioctl_giwessid, /* SIOCGIWESSID */
3027 (iw_handler) rt_ioctl_siwnickn, /* SIOCSIWNICKN */
3028 (iw_handler) rt_ioctl_giwnickn, /* SIOCGIWNICKN */
3029 (iw_handler) NULL, /* -- hole -- */
3030 (iw_handler) NULL, /* -- hole -- */
3031 (iw_handler) rt_ioctl_siwrate, /* SIOCSIWRATE */
3032 (iw_handler) rt_ioctl_giwrate, /* SIOCGIWRATE */
3033 (iw_handler) rt_ioctl_siwrts, /* SIOCSIWRTS */
3034 (iw_handler) rt_ioctl_giwrts, /* SIOCGIWRTS */
3035 (iw_handler) rt_ioctl_siwfrag, /* SIOCSIWFRAG */
3036 (iw_handler) rt_ioctl_giwfrag, /* SIOCGIWFRAG */
3037 (iw_handler) NULL, /* SIOCSIWTXPOW */
3038 (iw_handler) NULL, /* SIOCGIWTXPOW */
3039 (iw_handler) NULL, /* SIOCSIWRETRY */
3040 (iw_handler) NULL, /* SIOCGIWRETRY */
3041 (iw_handler) rt_ioctl_siwencode, /* SIOCSIWENCODE */
3042 (iw_handler) rt_ioctl_giwencode, /* SIOCGIWENCODE */
3043 (iw_handler) NULL, /* SIOCSIWPOWER */
3044 (iw_handler) NULL, /* SIOCGIWPOWER */
3045 (iw_handler) NULL, /* -- hole -- */
3046 (iw_handler) NULL, /* -- hole -- */
3047 #if WIRELESS_EXT > 17
3048 (iw_handler) rt_ioctl_siwgenie, /* SIOCSIWGENIE */
3049 (iw_handler) rt_ioctl_giwgenie, /* SIOCGIWGENIE */
3050 (iw_handler) rt_ioctl_siwauth, /* SIOCSIWAUTH */
3051 (iw_handler) rt_ioctl_giwauth, /* SIOCGIWAUTH */
3052 (iw_handler) rt_ioctl_siwencodeext, /* SIOCSIWENCODEEXT */
3053 (iw_handler) rt_ioctl_giwencodeext, /* SIOCGIWENCODEEXT */
3054 (iw_handler) rt_ioctl_siwpmksa, /* SIOCSIWPMKSA */
3058 static const iw_handler rt_priv_handlers[] = {
3059 (iw_handler) NULL, /* + 0x00 */
3060 (iw_handler) NULL, /* + 0x01 */
3061 #ifndef CONFIG_AP_SUPPORT
3062 (iw_handler) rt_ioctl_setparam, /* + 0x02 */
3064 (iw_handler) NULL, /* + 0x02 */
3065 #endif // CONFIG_AP_SUPPORT //
3067 (iw_handler) rt_private_ioctl_bbp, /* + 0x03 */
3069 (iw_handler) NULL, /* + 0x03 */
3071 (iw_handler) NULL, /* + 0x04 */
3072 (iw_handler) NULL, /* + 0x05 */
3073 (iw_handler) NULL, /* + 0x06 */
3074 (iw_handler) NULL, /* + 0x07 */
3075 (iw_handler) NULL, /* + 0x08 */
3076 (iw_handler) rt_private_get_statistics, /* + 0x09 */
3077 (iw_handler) NULL, /* + 0x0A */
3078 (iw_handler) NULL, /* + 0x0B */
3079 (iw_handler) NULL, /* + 0x0C */
3080 (iw_handler) NULL, /* + 0x0D */
3081 (iw_handler) NULL, /* + 0x0E */
3082 (iw_handler) NULL, /* + 0x0F */
3083 (iw_handler) NULL, /* + 0x10 */
3084 (iw_handler) rt_private_show, /* + 0x11 */
3085 (iw_handler) NULL, /* + 0x12 */
3086 (iw_handler) NULL, /* + 0x13 */
3087 (iw_handler) NULL, /* + 0x15 */
3088 (iw_handler) NULL, /* + 0x17 */
3089 (iw_handler) NULL, /* + 0x18 */
3092 const struct iw_handler_def rt28xx_iw_handler_def =
3094 #define N(a) (sizeof (a) / sizeof (a[0]))
3095 .standard = (iw_handler *) rt_handler,
3096 .num_standard = sizeof(rt_handler) / sizeof(iw_handler),
3097 .private = (iw_handler *) rt_priv_handlers,
3098 .num_private = N(rt_priv_handlers),
3099 .private_args = (struct iw_priv_args *) privtab,
3100 .num_private_args = N(privtab),
3101 #if IW_HANDLER_VERSION >= 7
3102 .get_wireless_stats = rt28xx_get_wireless_stats,
3106 INT RTMPSetInformation(
3107 IN PRTMP_ADAPTER pAdapter,
3108 IN OUT struct ifreq *rq,
3111 struct iwreq *wrq = (struct iwreq *) rq;
3112 NDIS_802_11_SSID Ssid;
3113 NDIS_802_11_MAC_ADDRESS Bssid;
3114 RT_802_11_PHY_MODE PhyMode;
3115 RT_802_11_STA_CONFIG StaConfig;
3116 NDIS_802_11_RATES aryRates;
3117 RT_802_11_PREAMBLE Preamble;
3118 NDIS_802_11_WEP_STATUS WepStatus;
3119 NDIS_802_11_AUTHENTICATION_MODE AuthMode = Ndis802_11AuthModeMax;
3120 NDIS_802_11_NETWORK_INFRASTRUCTURE BssType;
3121 NDIS_802_11_RTS_THRESHOLD RtsThresh;
3122 NDIS_802_11_FRAGMENTATION_THRESHOLD FragThresh;
3123 NDIS_802_11_POWER_MODE PowerMode;
3124 PNDIS_802_11_KEY pKey = NULL;
3125 PNDIS_802_11_WEP pWepKey =NULL;
3126 PNDIS_802_11_REMOVE_KEY pRemoveKey = NULL;
3127 NDIS_802_11_CONFIGURATION Config, *pConfig = NULL;
3128 NDIS_802_11_NETWORK_TYPE NetType;
3131 INT Status = NDIS_STATUS_SUCCESS, MaxPhyMode = PHY_11G;
3134 BOOLEAN StateMachineTouched = FALSE;
3135 #ifdef DOT11_N_SUPPORT
3136 OID_SET_HT_PHYMODE HT_PhyMode; //11n ,kathy
3137 #endif // DOT11_N_SUPPORT //
3138 #ifdef WPA_SUPPLICANT_SUPPORT
3139 PNDIS_802_11_PMKID pPmkId = NULL;
3140 BOOLEAN IEEE8021xState = FALSE;
3141 BOOLEAN IEEE8021x_required_keys = FALSE;
3142 UCHAR wpa_supplicant_enable = 0;
3143 #endif // WPA_SUPPLICANT_SUPPORT //
3145 #ifdef DOT11_N_SUPPORT
3146 MaxPhyMode = PHY_11N_5G;
3147 #endif // DOT11_N_SUPPORT //
3150 DBGPRINT(RT_DEBUG_TRACE, ("-->RTMPSetInformation(), 0x%08x\n", cmd&0x7FFF));
3151 switch(cmd & 0x7FFF) {
3152 case RT_OID_802_11_COUNTRY_REGION:
3153 if (wrq->u.data.length < sizeof(UCHAR))
3155 // Only avaliable when EEPROM not programming
3156 else if (!(pAdapter->CommonCfg.CountryRegion & 0x80) && !(pAdapter->CommonCfg.CountryRegionForABand & 0x80))
3161 Status = copy_from_user(&Country, wrq->u.data.pointer, wrq->u.data.length);
3162 pAdapter->CommonCfg.CountryRegion = (UCHAR)(Country & 0x000000FF);
3163 pAdapter->CommonCfg.CountryRegionForABand = (UCHAR)((Country >> 8) & 0x000000FF);
3164 TmpPhy = pAdapter->CommonCfg.PhyMode;
3165 pAdapter->CommonCfg.PhyMode = 0xff;
3166 // Build all corresponding channel information
3167 RTMPSetPhyMode(pAdapter, TmpPhy);
3168 #ifdef DOT11_N_SUPPORT
3169 SetCommonHT(pAdapter);
3170 #endif // DOT11_N_SUPPORT //
3171 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_COUNTRY_REGION (A:%d B/G:%d)\n", pAdapter->CommonCfg.CountryRegionForABand,
3172 pAdapter->CommonCfg.CountryRegion));
3175 case OID_802_11_BSSID_LIST_SCAN:
3177 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_BSSID_LIST_SCAN, TxCnt = %d \n", pAdapter->RalinkCounters.LastOneSecTotalTxCount));
3179 if (MONITOR_ON(pAdapter))
3181 DBGPRINT(RT_DEBUG_TRACE, ("!!! Driver is in Monitor Mode now !!!\n"));
3185 //Benson add 20080527, when radio off, sta don't need to scan
3186 if (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_RADIO_OFF))
3189 if (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
3191 DBGPRINT(RT_DEBUG_TRACE, ("!!! Driver is scanning now !!!\n"));
3192 pAdapter->StaCfg.bScanReqIsFromWebUI = TRUE;
3193 Status = NDIS_STATUS_SUCCESS;
3197 if (pAdapter->RalinkCounters.LastOneSecTotalTxCount > 100)
3199 DBGPRINT(RT_DEBUG_TRACE, ("!!! Link UP, ignore this set::OID_802_11_BSSID_LIST_SCAN\n"));
3200 Status = NDIS_STATUS_SUCCESS;
3201 pAdapter->StaCfg.ScanCnt = 99; // Prevent auto scan triggered by this OID
3205 if ((OPSTATUS_TEST_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED)) &&
3206 ((pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA) ||
3207 (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK) ||
3208 (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA2) ||
3209 (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK)) &&
3210 (pAdapter->StaCfg.PortSecured == WPA_802_1X_PORT_NOT_SECURED))
3212 DBGPRINT(RT_DEBUG_TRACE, ("!!! Link UP, Port Not Secured! ignore this set::OID_802_11_BSSID_LIST_SCAN\n"));
3213 Status = NDIS_STATUS_SUCCESS;
3214 pAdapter->StaCfg.ScanCnt = 99; // Prevent auto scan triggered by this OID
3219 if (pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE)
3221 RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
3222 DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
3225 // tell CNTL state machine to call NdisMSetInformationComplete() after completing
3226 // this request, because this request is initiated by NDIS.
3227 pAdapter->MlmeAux.CurrReqIsFromNdis = FALSE;
3228 // Reset allowed scan retries
3229 pAdapter->StaCfg.ScanCnt = 0;
3230 pAdapter->StaCfg.LastScanTime = Now;
3232 pAdapter->StaCfg.bScanReqIsFromWebUI = TRUE;
3233 RTMP_SET_FLAG(pAdapter, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS);
3234 MlmeEnqueue(pAdapter,
3235 MLME_CNTL_STATE_MACHINE,
3236 OID_802_11_BSSID_LIST_SCAN,
3240 Status = NDIS_STATUS_SUCCESS;
3241 StateMachineTouched = TRUE;
3243 case OID_802_11_SSID:
3244 if (wrq->u.data.length != sizeof(NDIS_802_11_SSID))
3248 PCHAR pSsidString = NULL;
3249 Status = copy_from_user(&Ssid, wrq->u.data.pointer, wrq->u.data.length);
3251 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_SSID (Len=%d,Ssid=%s)\n", Ssid.SsidLength, Ssid.Ssid));
3252 if (Ssid.SsidLength > MAX_LEN_OF_SSID)
3256 if (Ssid.SsidLength == 0)
3258 Set_SSID_Proc(pAdapter, "");
3262 pSsidString = (CHAR *) kmalloc(MAX_LEN_OF_SSID+1, MEM_ALLOC_FLAG);
3265 NdisZeroMemory(pSsidString, MAX_LEN_OF_SSID+1);
3266 NdisMoveMemory(pSsidString, Ssid.Ssid, Ssid.SsidLength);
3267 Set_SSID_Proc(pAdapter, pSsidString);
3276 case OID_802_11_BSSID:
3277 if (wrq->u.data.length != sizeof(NDIS_802_11_MAC_ADDRESS))
3281 Status = copy_from_user(&Bssid, wrq->u.data.pointer, wrq->u.data.length);
3283 // tell CNTL state machine to call NdisMSetInformationComplete() after completing
3284 // this request, because this request is initiated by NDIS.
3285 pAdapter->MlmeAux.CurrReqIsFromNdis = FALSE;
3287 // Prevent to connect AP again in STAMlmePeriodicExec
3288 pAdapter->MlmeAux.AutoReconnectSsidLen= 32;
3290 // Reset allowed scan retries
3291 pAdapter->StaCfg.ScanCnt = 0;
3293 if (pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE)
3295 RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
3296 DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
3298 MlmeEnqueue(pAdapter,
3299 MLME_CNTL_STATE_MACHINE,
3301 sizeof(NDIS_802_11_MAC_ADDRESS),
3303 Status = NDIS_STATUS_SUCCESS;
3304 StateMachineTouched = TRUE;
3306 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_BSSID %02x:%02x:%02x:%02x:%02x:%02x\n",
3307 Bssid[0], Bssid[1], Bssid[2], Bssid[3], Bssid[4], Bssid[5]));
3310 case RT_OID_802_11_RADIO:
3311 if (wrq->u.data.length != sizeof(BOOLEAN))
3315 Status = copy_from_user(&RadioState, wrq->u.data.pointer, wrq->u.data.length);
3316 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_RADIO (=%d)\n", RadioState));
3317 if (pAdapter->StaCfg.bSwRadio != RadioState)
3319 pAdapter->StaCfg.bSwRadio = RadioState;
3320 if (pAdapter->StaCfg.bRadio != (pAdapter->StaCfg.bHwRadio && pAdapter->StaCfg.bSwRadio))
3322 pAdapter->StaCfg.bRadio = (pAdapter->StaCfg.bHwRadio && pAdapter->StaCfg.bSwRadio);
3323 if (pAdapter->StaCfg.bRadio == TRUE)
3325 MlmeRadioOn(pAdapter);
3326 // Update extra information
3327 pAdapter->ExtraInfo = EXTRA_INFO_CLEAR;
3331 MlmeRadioOff(pAdapter);
3332 // Update extra information
3333 pAdapter->ExtraInfo = SW_RADIO_OFF;
3339 case RT_OID_802_11_PHY_MODE:
3340 if (wrq->u.data.length != sizeof(RT_802_11_PHY_MODE))
3344 Status = copy_from_user(&PhyMode, wrq->u.data.pointer, wrq->u.data.length);
3345 if (PhyMode <= MaxPhyMode)
3347 RTMPSetPhyMode(pAdapter, PhyMode);
3348 #ifdef DOT11_N_SUPPORT
3349 SetCommonHT(pAdapter);
3350 #endif // DOT11_N_SUPPORT //
3352 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_PHY_MODE (=%d)\n", PhyMode));
3355 case RT_OID_802_11_STA_CONFIG:
3356 if (wrq->u.data.length != sizeof(RT_802_11_STA_CONFIG))
3360 Status = copy_from_user(&StaConfig, wrq->u.data.pointer, wrq->u.data.length);
3361 pAdapter->CommonCfg.bEnableTxBurst = StaConfig.EnableTxBurst;
3362 pAdapter->CommonCfg.UseBGProtection = StaConfig.UseBGProtection;
3363 pAdapter->CommonCfg.bUseShortSlotTime = 1; // 2003-10-30 always SHORT SLOT capable
3364 if ((pAdapter->CommonCfg.PhyMode != StaConfig.AdhocMode) &&
3365 (StaConfig.AdhocMode <= MaxPhyMode))
3367 // allow dynamic change of "USE OFDM rate or not" in ADHOC mode
3368 // if setting changed, need to reset current TX rate as well as BEACON frame format
3369 if (pAdapter->StaCfg.BssType == BSS_ADHOC)
3371 pAdapter->CommonCfg.PhyMode = StaConfig.AdhocMode;
3372 RTMPSetPhyMode(pAdapter, PhyMode);
3373 MlmeUpdateTxRates(pAdapter, FALSE, 0);
3374 MakeIbssBeacon(pAdapter); // re-build BEACON frame
3375 AsicEnableIbssSync(pAdapter); // copy to on-chip memory
3378 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_SET_STA_CONFIG (Burst=%d, Protection=%ld,ShortSlot=%d\n",
3379 pAdapter->CommonCfg.bEnableTxBurst,
3380 pAdapter->CommonCfg.UseBGProtection,
3381 pAdapter->CommonCfg.bUseShortSlotTime));
3384 case OID_802_11_DESIRED_RATES:
3385 if (wrq->u.data.length != sizeof(NDIS_802_11_RATES))
3389 Status = copy_from_user(&aryRates, wrq->u.data.pointer, wrq->u.data.length);
3390 NdisZeroMemory(pAdapter->CommonCfg.DesireRate, MAX_LEN_OF_SUPPORTED_RATES);
3391 NdisMoveMemory(pAdapter->CommonCfg.DesireRate, &aryRates, sizeof(NDIS_802_11_RATES));
3392 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_DESIRED_RATES (%02x,%02x,%02x,%02x,%02x,%02x,%02x,%02x)\n",
3393 pAdapter->CommonCfg.DesireRate[0],pAdapter->CommonCfg.DesireRate[1],
3394 pAdapter->CommonCfg.DesireRate[2],pAdapter->CommonCfg.DesireRate[3],
3395 pAdapter->CommonCfg.DesireRate[4],pAdapter->CommonCfg.DesireRate[5],
3396 pAdapter->CommonCfg.DesireRate[6],pAdapter->CommonCfg.DesireRate[7] ));
3397 // Changing DesiredRate may affect the MAX TX rate we used to TX frames out
3398 MlmeUpdateTxRates(pAdapter, FALSE, 0);
3401 case RT_OID_802_11_PREAMBLE:
3402 if (wrq->u.data.length != sizeof(RT_802_11_PREAMBLE))
3406 Status = copy_from_user(&Preamble, wrq->u.data.pointer, wrq->u.data.length);
3407 if (Preamble == Rt802_11PreambleShort)
3409 pAdapter->CommonCfg.TxPreamble = Preamble;
3410 MlmeSetTxPreamble(pAdapter, Rt802_11PreambleShort);
3412 else if ((Preamble == Rt802_11PreambleLong) || (Preamble == Rt802_11PreambleAuto))
3414 // if user wants AUTO, initialize to LONG here, then change according to AP's
3415 // capability upon association.
3416 pAdapter->CommonCfg.TxPreamble = Preamble;
3417 MlmeSetTxPreamble(pAdapter, Rt802_11PreambleLong);
3424 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_PREAMBLE (=%d)\n", Preamble));
3427 case OID_802_11_WEP_STATUS:
3428 if (wrq->u.data.length != sizeof(NDIS_802_11_WEP_STATUS))
3432 Status = copy_from_user(&WepStatus, wrq->u.data.pointer, wrq->u.data.length);
3433 // Since TKIP, AES, WEP are all supported. It should not have any invalid setting
3434 if (WepStatus <= Ndis802_11Encryption3KeyAbsent)
3436 if (pAdapter->StaCfg.WepStatus != WepStatus)
3438 // Config has changed
3439 pAdapter->bConfigChanged = TRUE;
3441 pAdapter->StaCfg.WepStatus = WepStatus;
3442 pAdapter->StaCfg.OrigWepStatus = WepStatus;
3443 pAdapter->StaCfg.PairCipher = WepStatus;
3444 pAdapter->StaCfg.GroupCipher = WepStatus;
3451 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_WEP_STATUS (=%d)\n",WepStatus));
3454 case OID_802_11_AUTHENTICATION_MODE:
3455 if (wrq->u.data.length != sizeof(NDIS_802_11_AUTHENTICATION_MODE))
3459 Status = copy_from_user(&AuthMode, wrq->u.data.pointer, wrq->u.data.length);
3460 if (AuthMode > Ndis802_11AuthModeMax)
3467 if (pAdapter->StaCfg.AuthMode != AuthMode)
3469 // Config has changed
3470 pAdapter->bConfigChanged = TRUE;
3472 pAdapter->StaCfg.AuthMode = AuthMode;
3474 pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED;
3475 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_AUTHENTICATION_MODE (=%d) \n",pAdapter->StaCfg.AuthMode));
3478 case OID_802_11_INFRASTRUCTURE_MODE:
3479 if (wrq->u.data.length != sizeof(NDIS_802_11_NETWORK_INFRASTRUCTURE))
3483 Status = copy_from_user(&BssType, wrq->u.data.pointer, wrq->u.data.length);
3485 if (BssType == Ndis802_11IBSS)
3486 Set_NetworkType_Proc(pAdapter, "Adhoc");
3487 else if (BssType == Ndis802_11Infrastructure)
3488 Set_NetworkType_Proc(pAdapter, "Infra");
3489 else if (BssType == Ndis802_11Monitor)
3490 Set_NetworkType_Proc(pAdapter, "Monitor");
3494 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_INFRASTRUCTURE_MODE (unknown)\n"));
3498 case OID_802_11_REMOVE_WEP:
3499 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_WEP\n"));
3500 if (wrq->u.data.length != sizeof(NDIS_802_11_KEY_INDEX))
3506 KeyIdx = *(NDIS_802_11_KEY_INDEX *) wrq->u.data.pointer;
3508 if (KeyIdx & 0x80000000)
3510 // Should never set default bit when remove key
3515 KeyIdx = KeyIdx & 0x0fffffff;
3521 pAdapter->SharedKey[BSS0][KeyIdx].KeyLen = 0;
3522 pAdapter->SharedKey[BSS0][KeyIdx].CipherAlg = CIPHER_NONE;
3523 AsicRemoveSharedKeyEntry(pAdapter, 0, (UCHAR)KeyIdx);
3528 case RT_OID_802_11_RESET_COUNTERS:
3529 NdisZeroMemory(&pAdapter->WlanCounters, sizeof(COUNTER_802_11));
3530 NdisZeroMemory(&pAdapter->Counters8023, sizeof(COUNTER_802_3));
3531 NdisZeroMemory(&pAdapter->RalinkCounters, sizeof(COUNTER_RALINK));
3532 pAdapter->Counters8023.RxNoBuffer = 0;
3533 pAdapter->Counters8023.GoodReceives = 0;
3534 pAdapter->Counters8023.RxNoBuffer = 0;
3535 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_RESET_COUNTERS \n"));
3537 case OID_802_11_RTS_THRESHOLD:
3538 if (wrq->u.data.length != sizeof(NDIS_802_11_RTS_THRESHOLD))
3542 Status = copy_from_user(&RtsThresh, wrq->u.data.pointer, wrq->u.data.length);
3543 if (RtsThresh > MAX_RTS_THRESHOLD)
3546 pAdapter->CommonCfg.RtsThreshold = (USHORT)RtsThresh;
3548 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_RTS_THRESHOLD (=%ld)\n",RtsThresh));
3550 case OID_802_11_FRAGMENTATION_THRESHOLD:
3551 if (wrq->u.data.length != sizeof(NDIS_802_11_FRAGMENTATION_THRESHOLD))
3555 Status = copy_from_user(&FragThresh, wrq->u.data.pointer, wrq->u.data.length);
3556 pAdapter->CommonCfg.bUseZeroToDisableFragment = FALSE;
3557 if (FragThresh > MAX_FRAG_THRESHOLD || FragThresh < MIN_FRAG_THRESHOLD)
3559 if (FragThresh == 0)
3561 pAdapter->CommonCfg.FragmentThreshold = MAX_FRAG_THRESHOLD;
3562 pAdapter->CommonCfg.bUseZeroToDisableFragment = TRUE;
3568 pAdapter->CommonCfg.FragmentThreshold = (USHORT)FragThresh;
3570 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_FRAGMENTATION_THRESHOLD (=%ld) \n",FragThresh));
3572 case OID_802_11_POWER_MODE:
3573 if (wrq->u.data.length != sizeof(NDIS_802_11_POWER_MODE))
3577 Status = copy_from_user(&PowerMode, wrq->u.data.pointer, wrq->u.data.length);
3578 if (PowerMode == Ndis802_11PowerModeCAM)
3579 Set_PSMode_Proc(pAdapter, "CAM");
3580 else if (PowerMode == Ndis802_11PowerModeMAX_PSP)
3581 Set_PSMode_Proc(pAdapter, "Max_PSP");
3582 else if (PowerMode == Ndis802_11PowerModeFast_PSP)
3583 Set_PSMode_Proc(pAdapter, "Fast_PSP");
3584 else if (PowerMode == Ndis802_11PowerModeLegacy_PSP)
3585 Set_PSMode_Proc(pAdapter, "Legacy_PSP");
3589 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_POWER_MODE (=%d)\n",PowerMode));
3591 case RT_OID_802_11_TX_POWER_LEVEL_1:
3592 if (wrq->u.data.length < sizeof(ULONG))
3596 Status = copy_from_user(&PowerTemp, wrq->u.data.pointer, wrq->u.data.length);
3597 if (PowerTemp > 100)
3598 PowerTemp = 0xffffffff; // AUTO
3599 pAdapter->CommonCfg.TxPowerDefault = PowerTemp; //keep current setting.
3600 pAdapter->CommonCfg.TxPowerPercentage = pAdapter->CommonCfg.TxPowerDefault;
3601 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_TX_POWER_LEVEL_1 (=%ld)\n", pAdapter->CommonCfg.TxPowerPercentage));
3604 case OID_802_11_NETWORK_TYPE_IN_USE:
3605 if (wrq->u.data.length != sizeof(NDIS_802_11_NETWORK_TYPE))
3609 Status = copy_from_user(&NetType, wrq->u.data.pointer, wrq->u.data.length);
3611 if (NetType == Ndis802_11DS)
3612 RTMPSetPhyMode(pAdapter, PHY_11B);
3613 else if (NetType == Ndis802_11OFDM24)
3614 RTMPSetPhyMode(pAdapter, PHY_11BG_MIXED);
3615 else if (NetType == Ndis802_11OFDM5)
3616 RTMPSetPhyMode(pAdapter, PHY_11A);
3619 #ifdef DOT11_N_SUPPORT
3620 if (Status == NDIS_STATUS_SUCCESS)
3621 SetCommonHT(pAdapter);
3622 #endif // DOT11_N_SUPPORT //
3623 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_NETWORK_TYPE_IN_USE (=%d)\n",NetType));
3626 // For WPA PSK PMK key
3627 case RT_OID_802_11_ADD_WPA:
3628 pKey = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
3635 Status = copy_from_user(pKey, wrq->u.data.pointer, wrq->u.data.length);
3636 if (pKey->Length != wrq->u.data.length)
3639 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_ADD_WPA, Failed!!\n"));
3643 if ((pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPAPSK) &&
3644 (pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPA2PSK) &&
3645 (pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPANone) )
3647 Status = -EOPNOTSUPP;
3648 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_ADD_WPA, Failed!! [AuthMode != WPAPSK/WPA2PSK/WPANONE]\n"));
3650 else if ((pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK) ||
3651 (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK) ||
3652 (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPANone) ) // Only for WPA PSK mode
3654 NdisMoveMemory(pAdapter->StaCfg.PMK, &pKey->KeyMaterial, pKey->KeyLength);
3655 // Use RaConfig as PSK agent.
3656 // Start STA supplicant state machine
3657 if (pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPANone)
3658 pAdapter->StaCfg.WpaState = SS_START;
3660 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_ADD_WPA (id=0x%x, Len=%d-byte)\n", pKey->KeyIndex, pKey->KeyLength));
3664 pAdapter->StaCfg.WpaState = SS_NOTUSE;
3665 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_ADD_WPA (id=0x%x, Len=%d-byte)\n", pKey->KeyIndex, pKey->KeyLength));
3670 case OID_802_11_REMOVE_KEY:
3671 pRemoveKey = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
3672 if(pRemoveKey == NULL)
3678 Status = copy_from_user(pRemoveKey, wrq->u.data.pointer, wrq->u.data.length);
3679 if (pRemoveKey->Length != wrq->u.data.length)
3682 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_KEY, Failed!!\n"));
3686 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
3688 RTMPWPARemoveKeyProc(pAdapter, pRemoveKey);
3689 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_KEY, Remove WPA Key!!\n"));
3693 KeyIdx = pRemoveKey->KeyIndex;
3695 if (KeyIdx & 0x80000000)
3697 // Should never set default bit when remove key
3699 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_KEY, Failed!!(Should never set default bit when remove key)\n"));
3703 KeyIdx = KeyIdx & 0x0fffffff;
3707 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_KEY, Failed!!(KeyId[%d] out of range)\n", KeyIdx));
3711 pAdapter->SharedKey[BSS0][KeyIdx].KeyLen = 0;
3712 pAdapter->SharedKey[BSS0][KeyIdx].CipherAlg = CIPHER_NONE;
3713 AsicRemoveSharedKeyEntry(pAdapter, 0, (UCHAR)KeyIdx);
3714 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_KEY (id=0x%x, Len=%d-byte)\n", pRemoveKey->KeyIndex, pRemoveKey->Length));
3722 case OID_802_11_ADD_KEY:
3723 pKey = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
3729 Status = copy_from_user(pKey, wrq->u.data.pointer, wrq->u.data.length);
3730 if (pKey->Length != wrq->u.data.length)
3733 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_KEY, Failed!!\n"));
3737 RTMPAddKey(pAdapter, pKey);
3738 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_KEY (id=0x%x, Len=%d-byte)\n", pKey->KeyIndex, pKey->KeyLength));
3742 case OID_802_11_CONFIGURATION:
3743 if (wrq->u.data.length != sizeof(NDIS_802_11_CONFIGURATION))
3747 Status = copy_from_user(&Config, wrq->u.data.pointer, wrq->u.data.length);
3750 if ((pConfig->BeaconPeriod >= 20) && (pConfig->BeaconPeriod <=400))
3751 pAdapter->CommonCfg.BeaconPeriod = (USHORT) pConfig->BeaconPeriod;
3753 pAdapter->StaActive.AtimWin = (USHORT) pConfig->ATIMWindow;
3754 MAP_KHZ_TO_CHANNEL_ID(pConfig->DSConfig, pAdapter->CommonCfg.Channel);
3756 // Save the channel on MlmeAux for CntlOidRTBssidProc used.
3758 pAdapter->MlmeAux.Channel = pAdapter->CommonCfg.Channel;
3760 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_CONFIGURATION (BeacnPeriod=%ld,AtimW=%ld,Ch=%d)\n",
3761 pConfig->BeaconPeriod, pConfig->ATIMWindow, pAdapter->CommonCfg.Channel));
3762 // Config has changed
3763 pAdapter->bConfigChanged = TRUE;
3766 #ifdef DOT11_N_SUPPORT
3767 case RT_OID_802_11_SET_HT_PHYMODE:
3768 if (wrq->u.data.length != sizeof(OID_SET_HT_PHYMODE))
3772 POID_SET_HT_PHYMODE pHTPhyMode = &HT_PhyMode;
3774 Status = copy_from_user(&HT_PhyMode, wrq->u.data.pointer, wrq->u.data.length);
3775 DBGPRINT(RT_DEBUG_TRACE, ("Set::pHTPhyMode (PhyMode = %d,TransmitNo = %d, HtMode = %d, ExtOffset = %d , MCS = %d, BW = %d, STBC = %d, SHORTGI = %d) \n",
3776 pHTPhyMode->PhyMode, pHTPhyMode->TransmitNo,pHTPhyMode->HtMode,pHTPhyMode->ExtOffset,
3777 pHTPhyMode->MCS, pHTPhyMode->BW, pHTPhyMode->STBC, pHTPhyMode->SHORTGI));
3778 if (pAdapter->CommonCfg.PhyMode >= PHY_11ABGN_MIXED)
3779 RTMPSetHT(pAdapter, pHTPhyMode);
3781 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_SET_HT_PHYMODE(MCS=%d,BW=%d,SGI=%d,STBC=%d)\n",
3782 pAdapter->StaCfg.HTPhyMode.field.MCS, pAdapter->StaCfg.HTPhyMode.field.BW, pAdapter->StaCfg.HTPhyMode.field.ShortGI,
3783 pAdapter->StaCfg.HTPhyMode.field.STBC));
3785 #endif // DOT11_N_SUPPORT //
3786 case RT_OID_802_11_SET_APSD_SETTING:
3787 if (wrq->u.data.length != sizeof(ULONG))
3792 Status = copy_from_user(&apsd, wrq->u.data.pointer, wrq->u.data.length);
3794 /*-------------------------------------------------------------------
3795 |B31~B7 | B6~B5 | B4 | B3 | B2 | B1 | B0 |
3796 ---------------------------------------------------------------------
3797 | Rsvd | Max SP Len | AC_VO | AC_VI | AC_BK | AC_BE | APSD Capable |
3798 ---------------------------------------------------------------------*/
3799 pAdapter->CommonCfg.bAPSDCapable = (apsd & 0x00000001) ? TRUE : FALSE;
3800 pAdapter->CommonCfg.bAPSDAC_BE = ((apsd & 0x00000002) >> 1) ? TRUE : FALSE;
3801 pAdapter->CommonCfg.bAPSDAC_BK = ((apsd & 0x00000004) >> 2) ? TRUE : FALSE;
3802 pAdapter->CommonCfg.bAPSDAC_VI = ((apsd & 0x00000008) >> 3) ? TRUE : FALSE;
3803 pAdapter->CommonCfg.bAPSDAC_VO = ((apsd & 0x00000010) >> 4) ? TRUE : FALSE;
3804 pAdapter->CommonCfg.MaxSPLength = (UCHAR)((apsd & 0x00000060) >> 5);
3806 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,
3807 pAdapter->CommonCfg.bAPSDAC_BE, pAdapter->CommonCfg.bAPSDAC_BK, pAdapter->CommonCfg.bAPSDAC_VI, pAdapter->CommonCfg.bAPSDAC_VO, pAdapter->CommonCfg.MaxSPLength));
3811 case RT_OID_802_11_SET_APSD_PSM:
3812 if (wrq->u.data.length != sizeof(ULONG))
3816 // Driver needs to notify AP when PSM changes
3817 Status = copy_from_user(&pAdapter->CommonCfg.bAPSDForcePowerSave, wrq->u.data.pointer, wrq->u.data.length);
3818 if (pAdapter->CommonCfg.bAPSDForcePowerSave != pAdapter->StaCfg.Psm)
3820 MlmeSetPsmBit(pAdapter, pAdapter->CommonCfg.bAPSDForcePowerSave);
3821 RTMPSendNullFrame(pAdapter, pAdapter->CommonCfg.TxRate, TRUE);
3823 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_SET_APSD_PSM (bAPSDForcePowerSave:%d)\n", pAdapter->CommonCfg.bAPSDForcePowerSave));
3827 case RT_OID_802_11_SET_WMM:
3828 if (wrq->u.data.length != sizeof(BOOLEAN))
3832 Status = copy_from_user(&pAdapter->CommonCfg.bWmmCapable, wrq->u.data.pointer, wrq->u.data.length);
3833 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_SET_WMM (=%d) \n", pAdapter->CommonCfg.bWmmCapable));
3837 case OID_802_11_DISASSOCIATE:
3839 // Set NdisRadioStateOff to TRUE, instead of called MlmeRadioOff.
3840 // Later on, NDIS_802_11_BSSID_LIST_EX->NumberOfItems should be 0
3841 // when query OID_802_11_BSSID_LIST.
3843 // TRUE: NumberOfItems will set to 0.
3844 // FALSE: NumberOfItems no change.
3846 pAdapter->CommonCfg.NdisRadioStateOff = TRUE;
3847 // Set to immediately send the media disconnect event
3848 pAdapter->MlmeAux.CurrReqIsFromNdis = TRUE;
3849 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_DISASSOCIATE \n"));
3851 if (INFRA_ON(pAdapter))
3853 if (pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE)
3855 RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
3856 DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
3859 MlmeEnqueue(pAdapter,
3860 MLME_CNTL_STATE_MACHINE,
3861 OID_802_11_DISASSOCIATE,
3865 StateMachineTouched = TRUE;
3869 #ifdef DOT11_N_SUPPORT
3870 case RT_OID_802_11_SET_IMME_BA_CAP:
3871 if (wrq->u.data.length != sizeof(OID_BACAP_STRUC))
3875 OID_BACAP_STRUC Orde ;
3876 Status = copy_from_user(&Orde, wrq->u.data.pointer, wrq->u.data.length);
3877 if (Orde.Policy > BA_NOTUSE)
3879 Status = NDIS_STATUS_INVALID_DATA;
3881 else if (Orde.Policy == BA_NOTUSE)
3883 pAdapter->CommonCfg.BACapability.field.Policy = BA_NOTUSE;
3884 pAdapter->CommonCfg.BACapability.field.MpduDensity = Orde.MpduDensity;
3885 pAdapter->CommonCfg.DesiredHtPhy.MpduDensity = Orde.MpduDensity;
3886 pAdapter->CommonCfg.DesiredHtPhy.AmsduEnable = Orde.AmsduEnable;
3887 pAdapter->CommonCfg.DesiredHtPhy.AmsduSize= Orde.AmsduSize;
3888 pAdapter->CommonCfg.DesiredHtPhy.MimoPs= Orde.MMPSmode;
3889 pAdapter->CommonCfg.BACapability.field.MMPSmode = Orde.MMPSmode;
3891 pAdapter->CommonCfg.HtCapability.HtCapInfo.MimoPs = Orde.MMPSmode;
3892 pAdapter->CommonCfg.HtCapability.HtCapInfo.AMsduSize = Orde.AmsduSize;
3893 pAdapter->CommonCfg.HtCapability.HtCapParm.MpduDensity = Orde.MpduDensity;
3897 pAdapter->CommonCfg.BACapability.field.AutoBA = Orde.AutoBA;
3898 pAdapter->CommonCfg.BACapability.field.Policy = IMMED_BA; // we only support immediate BA.
3899 pAdapter->CommonCfg.BACapability.field.MpduDensity = Orde.MpduDensity;
3900 pAdapter->CommonCfg.DesiredHtPhy.MpduDensity = Orde.MpduDensity;
3901 pAdapter->CommonCfg.DesiredHtPhy.AmsduEnable = Orde.AmsduEnable;
3902 pAdapter->CommonCfg.DesiredHtPhy.AmsduSize= Orde.AmsduSize;
3903 pAdapter->CommonCfg.DesiredHtPhy.MimoPs = Orde.MMPSmode;
3904 pAdapter->CommonCfg.BACapability.field.MMPSmode = Orde.MMPSmode;
3907 pAdapter->CommonCfg.HtCapability.HtCapInfo.MimoPs = Orde.MMPSmode;
3908 pAdapter->CommonCfg.HtCapability.HtCapInfo.AMsduSize = Orde.AmsduSize;
3909 pAdapter->CommonCfg.HtCapability.HtCapParm.MpduDensity = Orde.MpduDensity;
3911 if (pAdapter->CommonCfg.BACapability.field.RxBAWinLimit > MAX_RX_REORDERBUF)
3912 pAdapter->CommonCfg.BACapability.field.RxBAWinLimit = MAX_RX_REORDERBUF;
3916 pAdapter->CommonCfg.REGBACapability.word = pAdapter->CommonCfg.BACapability.word;
3917 DBGPRINT(RT_DEBUG_TRACE, ("Set::(Orde.AutoBA = %d) (Policy=%d)(ReBAWinLimit=%d)(TxBAWinLimit=%d)(AutoMode=%d)\n",Orde.AutoBA, pAdapter->CommonCfg.BACapability.field.Policy,
3918 pAdapter->CommonCfg.BACapability.field.RxBAWinLimit,pAdapter->CommonCfg.BACapability.field.TxBAWinLimit, pAdapter->CommonCfg.BACapability.field.AutoBA));
3919 DBGPRINT(RT_DEBUG_TRACE, ("Set::(MimoPs = %d)(AmsduEnable = %d) (AmsduSize=%d)(MpduDensity=%d)\n",pAdapter->CommonCfg.DesiredHtPhy.MimoPs, pAdapter->CommonCfg.DesiredHtPhy.AmsduEnable,
3920 pAdapter->CommonCfg.DesiredHtPhy.AmsduSize, pAdapter->CommonCfg.DesiredHtPhy.MpduDensity));
3924 case RT_OID_802_11_ADD_IMME_BA:
3925 DBGPRINT(RT_DEBUG_TRACE, (" Set :: RT_OID_802_11_ADD_IMME_BA \n"));
3926 if (wrq->u.data.length != sizeof(OID_ADD_BA_ENTRY))
3931 OID_ADD_BA_ENTRY BA;
3932 MAC_TABLE_ENTRY *pEntry;
3934 Status = copy_from_user(&BA, wrq->u.data.pointer, wrq->u.data.length);
3937 Status = NDIS_STATUS_INVALID_DATA;
3942 //BATableInsertEntry
3943 //As ad-hoc mode, BA pair is not limited to only BSSID. so add via OID.
3945 // in ad hoc mode, when adding BA pair, we should insert this entry into MACEntry too
3946 pEntry = MacTableLookup(pAdapter, BA.MACAddr);
3949 DBGPRINT(RT_DEBUG_TRACE, ("RT_OID_802_11_ADD_IMME_BA. break on no connection.----:%x:%x\n", BA.MACAddr[4], BA.MACAddr[5]));
3952 if (BA.IsRecipient == FALSE)
3954 if (pEntry->bIAmBadAtheros == TRUE)
3955 pAdapter->CommonCfg.BACapability.field.RxBAWinLimit = 0x10;
3957 BAOriSessionSetUp(pAdapter, pEntry, index, 0, 100, TRUE);
3961 //BATableInsertEntry(pAdapter, pEntry->Aid, BA.MACAddr, 0, 0xffff, BA.TID, BA.nMSDU, BA.IsRecipient);
3964 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_ADD_IMME_BA. Rec = %d. Mac = %x:%x:%x:%x:%x:%x . \n",
3965 BA.IsRecipient, BA.MACAddr[0], BA.MACAddr[1], BA.MACAddr[2], BA.MACAddr[2]
3966 , BA.MACAddr[4], BA.MACAddr[5]));
3971 case RT_OID_802_11_TEAR_IMME_BA:
3972 DBGPRINT(RT_DEBUG_TRACE, ("Set :: RT_OID_802_11_TEAR_IMME_BA \n"));
3973 if (wrq->u.data.length != sizeof(OID_ADD_BA_ENTRY))
3977 POID_ADD_BA_ENTRY pBA;
3978 MAC_TABLE_ENTRY *pEntry;
3980 pBA = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
3984 DBGPRINT(RT_DEBUG_TRACE, ("Set :: RT_OID_802_11_TEAR_IMME_BA kmalloc() can't allocate enough memory\n"));
3985 Status = NDIS_STATUS_FAILURE;
3989 Status = copy_from_user(pBA, wrq->u.data.pointer, wrq->u.data.length);
3990 DBGPRINT(RT_DEBUG_TRACE, ("Set :: RT_OID_802_11_TEAR_IMME_BA(TID=%d, bAllTid=%d)\n", pBA->TID, pBA->bAllTid));
3992 if (!pBA->bAllTid && (pBA->TID > NUM_OF_TID))
3994 Status = NDIS_STATUS_INVALID_DATA;
3998 if (pBA->IsRecipient == FALSE)
4000 pEntry = MacTableLookup(pAdapter, pBA->MACAddr);
4001 DBGPRINT(RT_DEBUG_TRACE, (" pBA->IsRecipient == FALSE\n"));
4004 DBGPRINT(RT_DEBUG_TRACE, (" pBA->pEntry\n"));
4005 BAOriSessionTearDown(pAdapter, pEntry->Aid, pBA->TID, FALSE, TRUE);
4008 DBGPRINT(RT_DEBUG_TRACE, ("Set :: Not found pEntry \n"));
4012 pEntry = MacTableLookup(pAdapter, pBA->MACAddr);
4015 BARecSessionTearDown( pAdapter, (UCHAR)pEntry->Aid, pBA->TID, TRUE);
4018 DBGPRINT(RT_DEBUG_TRACE, ("Set :: Not found pEntry \n"));
4024 #endif // DOT11_N_SUPPORT //
4026 // For WPA_SUPPLICANT to set static wep key
4027 case OID_802_11_ADD_WEP:
4028 pWepKey = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
4033 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_WEP, Failed!!\n"));
4036 Status = copy_from_user(pWepKey, wrq->u.data.pointer, wrq->u.data.length);
4040 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_WEP, Failed (length mismatch)!!\n"));
4044 KeyIdx = pWepKey->KeyIndex & 0x0fffffff;
4045 // KeyIdx must be 0 ~ 3
4049 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_WEP, Failed (KeyIdx must be smaller than 4)!!\n"));
4053 UCHAR CipherAlg = 0;
4056 // set key material and key length
4057 NdisZeroMemory(pAdapter->SharedKey[BSS0][KeyIdx].Key, 16);
4058 pAdapter->SharedKey[BSS0][KeyIdx].KeyLen = (UCHAR) pWepKey->KeyLength;
4059 NdisMoveMemory(pAdapter->SharedKey[BSS0][KeyIdx].Key, &pWepKey->KeyMaterial, pWepKey->KeyLength);
4061 switch(pWepKey->KeyLength)
4064 CipherAlg = CIPHER_WEP64;
4067 CipherAlg = CIPHER_WEP128;
4070 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_WEP, only support CIPHER_WEP64(len:5) & CIPHER_WEP128(len:13)!!\n"));
4074 pAdapter->SharedKey[BSS0][KeyIdx].CipherAlg = CipherAlg;
4076 // Default key for tx (shared key)
4077 if (pWepKey->KeyIndex & 0x80000000)
4079 #ifdef WPA_SUPPLICANT_SUPPORT
4080 // set key material and key length
4081 NdisZeroMemory(pAdapter->StaCfg.DesireSharedKey[KeyIdx].Key, 16);
4082 pAdapter->StaCfg.DesireSharedKey[KeyIdx].KeyLen = (UCHAR) pWepKey->KeyLength;
4083 NdisMoveMemory(pAdapter->StaCfg.DesireSharedKey[KeyIdx].Key, &pWepKey->KeyMaterial, pWepKey->KeyLength);
4084 pAdapter->StaCfg.DesireSharedKeyId = KeyIdx;
4085 pAdapter->StaCfg.DesireSharedKey[KeyIdx].CipherAlg = CipherAlg;
4086 #endif // WPA_SUPPLICANT_SUPPORT //
4087 pAdapter->StaCfg.DefaultKeyId = (UCHAR) KeyIdx;
4090 #ifdef WPA_SUPPLICANT_SUPPORT
4091 if ((pAdapter->StaCfg.WpaSupplicantUP != 0) &&
4092 (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA))
4094 Key = pWepKey->KeyMaterial;
4096 // Set Group key material to Asic
4097 AsicAddSharedKeyEntry(pAdapter, BSS0, KeyIdx, CipherAlg, Key, NULL, NULL);
4099 // Update WCID attribute table and IVEIV table for this group key table
4100 RTMPAddWcidAttributeEntry(pAdapter, BSS0, KeyIdx, CipherAlg, NULL);
4102 STA_PORT_SECURED(pAdapter);
4104 // Indicate Connected for GUI
4105 pAdapter->IndicateMediaState = NdisMediaStateConnected;
4107 else if (pAdapter->StaCfg.PortSecured == WPA_802_1X_PORT_SECURED)
4108 #endif // WPA_SUPPLICANT_SUPPORT
4110 Key = pAdapter->SharedKey[BSS0][KeyIdx].Key;
4112 // Set key material and cipherAlg to Asic
4113 AsicAddSharedKeyEntry(pAdapter, BSS0, KeyIdx, CipherAlg, Key, NULL, NULL);
4115 if (pWepKey->KeyIndex & 0x80000000)
4117 PMAC_TABLE_ENTRY pEntry = &pAdapter->MacTab.Content[BSSID_WCID];
4118 // Assign group key info
4119 RTMPAddWcidAttributeEntry(pAdapter, BSS0, KeyIdx, CipherAlg, NULL);
4120 // Assign pairwise key info
4121 RTMPAddWcidAttributeEntry(pAdapter, BSS0, KeyIdx, CipherAlg, pEntry);
4124 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"));
4129 #ifdef WPA_SUPPLICANT_SUPPORT
4130 case OID_SET_COUNTERMEASURES:
4131 if (wrq->u.data.length != sizeof(int))
4136 Status = copy_from_user(&enabled, wrq->u.data.pointer, wrq->u.data.length);
4138 pAdapter->StaCfg.bBlockAssoc = TRUE;
4140 // WPA MIC error should block association attempt for 60 seconds
4141 pAdapter->StaCfg.bBlockAssoc = FALSE;
4142 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_SET_COUNTERMEASURES bBlockAssoc=%s\n", pAdapter->StaCfg.bBlockAssoc ? "TRUE":"FALSE"));
4145 case RT_OID_WPA_SUPPLICANT_SUPPORT:
4146 if (wrq->u.data.length != sizeof(UCHAR))
4150 Status = copy_from_user(&wpa_supplicant_enable, wrq->u.data.pointer, wrq->u.data.length);
4151 pAdapter->StaCfg.WpaSupplicantUP = wpa_supplicant_enable;
4152 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_WPA_SUPPLICANT_SUPPORT (=%d)\n", pAdapter->StaCfg.WpaSupplicantUP));
4155 case OID_802_11_DEAUTHENTICATION:
4156 if (wrq->u.data.length != sizeof(MLME_DEAUTH_REQ_STRUCT))
4160 MLME_DEAUTH_REQ_STRUCT *pInfo;
4161 MLME_QUEUE_ELEM *MsgElem = (MLME_QUEUE_ELEM *) kmalloc(sizeof(MLME_QUEUE_ELEM), MEM_ALLOC_FLAG);
4163 pInfo = (MLME_DEAUTH_REQ_STRUCT *) MsgElem->Msg;
4164 Status = copy_from_user(pInfo, wrq->u.data.pointer, wrq->u.data.length);
4165 MlmeDeauthReqAction(pAdapter, MsgElem);
4168 if (INFRA_ON(pAdapter))
4170 LinkDown(pAdapter, FALSE);
4171 pAdapter->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
4173 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_DEAUTHENTICATION (Reason=%d)\n", pInfo->Reason));
4176 case OID_802_11_DROP_UNENCRYPTED:
4177 if (wrq->u.data.length != sizeof(int))
4182 Status = copy_from_user(&enabled, wrq->u.data.pointer, wrq->u.data.length);
4184 pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED;
4186 pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
4187 NdisAcquireSpinLock(&pAdapter->MacTabLock);
4188 pAdapter->MacTab.Content[BSSID_WCID].PortSecured = pAdapter->StaCfg.PortSecured;
4189 NdisReleaseSpinLock(&pAdapter->MacTabLock);
4190 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_DROP_UNENCRYPTED (=%d)\n", enabled));
4193 case OID_802_11_SET_IEEE8021X:
4194 if (wrq->u.data.length != sizeof(BOOLEAN))
4198 Status = copy_from_user(&IEEE8021xState, wrq->u.data.pointer, wrq->u.data.length);
4199 pAdapter->StaCfg.IEEE8021X = IEEE8021xState;
4200 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_SET_IEEE8021X (=%d)\n", IEEE8021xState));
4203 case OID_802_11_SET_IEEE8021X_REQUIRE_KEY:
4204 if (wrq->u.data.length != sizeof(BOOLEAN))
4208 Status = copy_from_user(&IEEE8021x_required_keys, wrq->u.data.pointer, wrq->u.data.length);
4209 pAdapter->StaCfg.IEEE8021x_required_keys = IEEE8021x_required_keys;
4210 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_SET_IEEE8021X_REQUIRE_KEY (%d)\n", IEEE8021x_required_keys));
4213 case OID_802_11_PMKID:
4214 pPmkId = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
4216 if(pPmkId == NULL) {
4220 Status = copy_from_user(pPmkId, wrq->u.data.pointer, wrq->u.data.length);
4222 // check the PMKID information
4223 if (pPmkId->BSSIDInfoCount == 0)
4224 NdisZeroMemory(pAdapter->StaCfg.SavedPMK, sizeof(BSSID_INFO)*PMKID_NO);
4227 PBSSID_INFO pBssIdInfo;
4231 for (BssIdx = 0; BssIdx < pPmkId->BSSIDInfoCount; BssIdx++)
4233 // point to the indexed BSSID_INFO structure
4234 pBssIdInfo = (PBSSID_INFO) ((PUCHAR) pPmkId + 2 * sizeof(UINT) + BssIdx * sizeof(BSSID_INFO));
4235 // Find the entry in the saved data base.
4236 for (CachedIdx = 0; CachedIdx < pAdapter->StaCfg.SavedPMKNum; CachedIdx++)
4238 // compare the BSSID
4239 if (NdisEqualMemory(pBssIdInfo->BSSID, pAdapter->StaCfg.SavedPMK[CachedIdx].BSSID, sizeof(NDIS_802_11_MAC_ADDRESS)))
4243 // Found, replace it
4244 if (CachedIdx < PMKID_NO)
4246 DBGPRINT(RT_DEBUG_OFF, ("Update OID_802_11_PMKID, idx = %d\n", CachedIdx));
4247 NdisMoveMemory(&pAdapter->StaCfg.SavedPMK[CachedIdx], pBssIdInfo, sizeof(BSSID_INFO));
4248 pAdapter->StaCfg.SavedPMKNum++;
4250 // Not found, replace the last one
4253 // Randomly replace one
4254 CachedIdx = (pBssIdInfo->BSSID[5] % PMKID_NO);
4255 DBGPRINT(RT_DEBUG_OFF, ("Update OID_802_11_PMKID, idx = %d\n", CachedIdx));
4256 NdisMoveMemory(&pAdapter->StaCfg.SavedPMK[CachedIdx], pBssIdInfo, sizeof(BSSID_INFO));
4263 #endif // WPA_SUPPLICANT_SUPPORT //
4266 DBGPRINT(RT_DEBUG_TRACE, ("Set::unknown IOCTL's subcmd = 0x%08x\n", cmd));
4267 Status = -EOPNOTSUPP;
4275 INT RTMPQueryInformation(
4276 IN PRTMP_ADAPTER pAdapter,
4277 IN OUT struct ifreq *rq,
4280 struct iwreq *wrq = (struct iwreq *) rq;
4281 NDIS_802_11_BSSID_LIST_EX *pBssidList = NULL;
4282 PNDIS_WLAN_BSSID_EX pBss;
4283 NDIS_802_11_SSID Ssid;
4284 NDIS_802_11_CONFIGURATION *pConfiguration = NULL;
4285 RT_802_11_LINK_STATUS *pLinkStatus = NULL;
4286 RT_802_11_STA_CONFIG *pStaConfig = NULL;
4287 NDIS_802_11_STATISTICS *pStatistics = NULL;
4288 NDIS_802_11_RTS_THRESHOLD RtsThresh;
4289 NDIS_802_11_FRAGMENTATION_THRESHOLD FragThresh;
4290 NDIS_802_11_POWER_MODE PowerMode;
4291 NDIS_802_11_NETWORK_INFRASTRUCTURE BssType;
4292 RT_802_11_PREAMBLE PreamType;
4293 NDIS_802_11_AUTHENTICATION_MODE AuthMode;
4294 NDIS_802_11_WEP_STATUS WepStatus;
4295 NDIS_MEDIA_STATE MediaState;
4296 ULONG BssBufSize, ulInfo=0, NetworkTypeList[4], apsd = 0;
4298 PUCHAR pBuf = NULL, pPtr;
4299 INT Status = NDIS_STATUS_SUCCESS;
4300 UINT we_version_compiled;
4301 UCHAR i, Padding = 0;
4303 UCHAR driverVersion[8];
4304 OID_SET_HT_PHYMODE *pHTPhyMode = NULL;
4308 case RT_OID_DEVICE_NAME:
4309 wrq->u.data.length = sizeof(STA_NIC_DEVICE_NAME);
4310 Status = copy_to_user(wrq->u.data.pointer, STA_NIC_DEVICE_NAME, wrq->u.data.length);
4312 case RT_OID_VERSION_INFO:
4313 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_VERSION_INFO \n"));
4314 wrq->u.data.length = 8*sizeof(UCHAR);
4315 sprintf(&driverVersion[0], "%s", STA_DRIVER_VERSION);
4316 driverVersion[7] = '\0';
4317 if (copy_to_user(wrq->u.data.pointer, &driverVersion, wrq->u.data.length))
4322 case OID_802_11_BSSID_LIST:
4323 if (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
4326 * Still scanning, indicate the caller should try again.
4328 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_BSSID_LIST (Still scanning)\n"));
4331 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_BSSID_LIST (%d BSS returned)\n",pAdapter->ScanTab.BssNr));
4332 pAdapter->StaCfg.bScanReqIsFromWebUI = FALSE;
4333 // Claculate total buffer size required
4334 BssBufSize = sizeof(ULONG);
4336 for (i = 0; i < pAdapter->ScanTab.BssNr; i++)
4338 // Align pointer to 4 bytes boundary.
4339 //Padding = 4 - (pAdapter->ScanTab.BssEntry[i].VarIELen & 0x0003);
4342 BssBufSize += (sizeof(NDIS_WLAN_BSSID_EX) - 1 + sizeof(NDIS_802_11_FIXED_IEs) + pAdapter->ScanTab.BssEntry[i].VarIELen + Padding);
4345 // For safety issue, we add 256 bytes just in case
4347 // Allocate the same size as passed from higher layer
4348 pBuf = kmalloc(BssBufSize, MEM_ALLOC_FLAG);
4354 // Init 802_11_BSSID_LIST_EX structure
4355 NdisZeroMemory(pBuf, BssBufSize);
4356 pBssidList = (PNDIS_802_11_BSSID_LIST_EX) pBuf;
4357 pBssidList->NumberOfItems = pAdapter->ScanTab.BssNr;
4359 // Calculate total buffer length
4360 BssLen = 4; // Consist of NumberOfItems
4361 // Point to start of NDIS_WLAN_BSSID_EX
4362 // pPtr = pBuf + sizeof(ULONG);
4363 pPtr = (PUCHAR) &pBssidList->Bssid[0];
4364 for (i = 0; i < pAdapter->ScanTab.BssNr; i++)
4366 pBss = (PNDIS_WLAN_BSSID_EX) pPtr;
4367 NdisMoveMemory(&pBss->MacAddress, &pAdapter->ScanTab.BssEntry[i].Bssid, MAC_ADDR_LEN);
4368 if ((pAdapter->ScanTab.BssEntry[i].Hidden == 1) && (pAdapter->StaCfg.bShowHiddenSSID == FALSE))
4371 // We must return this SSID during 4way handshaking, otherwise Aegis will failed to parse WPA infomation
4372 // and then failed to send EAPOl farame.
4374 if ((pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA) && (pAdapter->StaCfg.PortSecured != WPA_802_1X_PORT_SECURED))
4376 pBss->Ssid.SsidLength = pAdapter->ScanTab.BssEntry[i].SsidLen;
4377 NdisMoveMemory(pBss->Ssid.Ssid, pAdapter->ScanTab.BssEntry[i].Ssid, pAdapter->ScanTab.BssEntry[i].SsidLen);
4380 pBss->Ssid.SsidLength = 0;
4384 pBss->Ssid.SsidLength = pAdapter->ScanTab.BssEntry[i].SsidLen;
4385 NdisMoveMemory(pBss->Ssid.Ssid, pAdapter->ScanTab.BssEntry[i].Ssid, pAdapter->ScanTab.BssEntry[i].SsidLen);
4387 pBss->Privacy = pAdapter->ScanTab.BssEntry[i].Privacy;
4388 pBss->Rssi = pAdapter->ScanTab.BssEntry[i].Rssi - pAdapter->BbpRssiToDbmDelta;
4389 pBss->NetworkTypeInUse = NetworkTypeInUseSanity(&pAdapter->ScanTab.BssEntry[i]);
4390 pBss->Configuration.Length = sizeof(NDIS_802_11_CONFIGURATION);
4391 pBss->Configuration.BeaconPeriod = pAdapter->ScanTab.BssEntry[i].BeaconPeriod;
4392 pBss->Configuration.ATIMWindow = pAdapter->ScanTab.BssEntry[i].AtimWin;
4394 MAP_CHANNEL_ID_TO_KHZ(pAdapter->ScanTab.BssEntry[i].Channel, pBss->Configuration.DSConfig);
4396 if (pAdapter->ScanTab.BssEntry[i].BssType == BSS_INFRA)
4397 pBss->InfrastructureMode = Ndis802_11Infrastructure;
4399 pBss->InfrastructureMode = Ndis802_11IBSS;
4401 NdisMoveMemory(pBss->SupportedRates, pAdapter->ScanTab.BssEntry[i].SupRate, pAdapter->ScanTab.BssEntry[i].SupRateLen);
4402 NdisMoveMemory(pBss->SupportedRates + pAdapter->ScanTab.BssEntry[i].SupRateLen,
4403 pAdapter->ScanTab.BssEntry[i].ExtRate,
4404 pAdapter->ScanTab.BssEntry[i].ExtRateLen);
4406 if (pAdapter->ScanTab.BssEntry[i].VarIELen == 0)
4408 pBss->IELength = sizeof(NDIS_802_11_FIXED_IEs);
4409 NdisMoveMemory(pBss->IEs, &pAdapter->ScanTab.BssEntry[i].FixIEs, sizeof(NDIS_802_11_FIXED_IEs));
4410 pPtr = pPtr + sizeof(NDIS_WLAN_BSSID_EX) - 1 + sizeof(NDIS_802_11_FIXED_IEs);
4414 pBss->IELength = (ULONG)(sizeof(NDIS_802_11_FIXED_IEs) + pAdapter->ScanTab.BssEntry[i].VarIELen);
4415 pPtr = pPtr + sizeof(NDIS_WLAN_BSSID_EX) - 1 + sizeof(NDIS_802_11_FIXED_IEs);
4416 NdisMoveMemory(pBss->IEs, &pAdapter->ScanTab.BssEntry[i].FixIEs, sizeof(NDIS_802_11_FIXED_IEs));
4417 NdisMoveMemory(pBss->IEs + sizeof(NDIS_802_11_FIXED_IEs), pAdapter->ScanTab.BssEntry[i].VarIEs, pAdapter->ScanTab.BssEntry[i].VarIELen);
4418 pPtr += pAdapter->ScanTab.BssEntry[i].VarIELen;
4420 pBss->Length = (ULONG)(sizeof(NDIS_WLAN_BSSID_EX) - 1 + sizeof(NDIS_802_11_FIXED_IEs) + pAdapter->ScanTab.BssEntry[i].VarIELen + Padding);
4422 #if WIRELESS_EXT < 17
4423 if ((BssLen + pBss->Length) < wrq->u.data.length)
4424 BssLen += pBss->Length;
4427 pBssidList->NumberOfItems = i;
4431 BssLen += pBss->Length;
4435 #if WIRELESS_EXT < 17
4436 wrq->u.data.length = BssLen;
4438 if (BssLen > wrq->u.data.length)
4444 wrq->u.data.length = BssLen;
4446 Status = copy_to_user(wrq->u.data.pointer, pBssidList, BssLen);
4449 case OID_802_3_CURRENT_ADDRESS:
4450 wrq->u.data.length = MAC_ADDR_LEN;
4451 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CurrentAddress, wrq->u.data.length);
4453 case OID_GEN_MEDIA_CONNECT_STATUS:
4454 if (pAdapter->IndicateMediaState == NdisMediaStateConnected)
4455 MediaState = NdisMediaStateConnected;
4457 MediaState = NdisMediaStateDisconnected;
4459 wrq->u.data.length = sizeof(NDIS_MEDIA_STATE);
4460 Status = copy_to_user(wrq->u.data.pointer, &MediaState, wrq->u.data.length);
4462 case OID_802_11_BSSID:
4463 if (INFRA_ON(pAdapter) || ADHOC_ON(pAdapter))
4465 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.Bssid, sizeof(NDIS_802_11_MAC_ADDRESS));
4470 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_BSSID(=EMPTY)\n"));
4474 case OID_802_11_SSID:
4475 NdisZeroMemory(&Ssid, sizeof(NDIS_802_11_SSID));
4476 NdisZeroMemory(Ssid.Ssid, MAX_LEN_OF_SSID);
4477 Ssid.SsidLength = pAdapter->CommonCfg.SsidLen;
4478 memcpy(Ssid.Ssid, pAdapter->CommonCfg.Ssid, Ssid.SsidLength);
4479 wrq->u.data.length = sizeof(NDIS_802_11_SSID);
4480 Status = copy_to_user(wrq->u.data.pointer, &Ssid, wrq->u.data.length);
4481 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_SSID (Len=%d, ssid=%s)\n", Ssid.SsidLength,Ssid.Ssid));
4483 case RT_OID_802_11_QUERY_LINK_STATUS:
4484 pLinkStatus = (RT_802_11_LINK_STATUS *) kmalloc(sizeof(RT_802_11_LINK_STATUS), MEM_ALLOC_FLAG);
4487 pLinkStatus->CurrTxRate = RateIdTo500Kbps[pAdapter->CommonCfg.TxRate]; // unit : 500 kbps
4488 pLinkStatus->ChannelQuality = pAdapter->Mlme.ChannelQuality;
4489 pLinkStatus->RxByteCount = pAdapter->RalinkCounters.ReceivedByteCount;
4490 pLinkStatus->TxByteCount = pAdapter->RalinkCounters.TransmittedByteCount;
4491 pLinkStatus->CentralChannel = pAdapter->CommonCfg.CentralChannel;
4492 wrq->u.data.length = sizeof(RT_802_11_LINK_STATUS);
4493 Status = copy_to_user(wrq->u.data.pointer, pLinkStatus, wrq->u.data.length);
4495 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_LINK_STATUS\n"));
4499 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_LINK_STATUS(kmalloc failed)\n"));
4503 case OID_802_11_CONFIGURATION:
4504 pConfiguration = (NDIS_802_11_CONFIGURATION *) kmalloc(sizeof(NDIS_802_11_CONFIGURATION), MEM_ALLOC_FLAG);
4507 pConfiguration->Length = sizeof(NDIS_802_11_CONFIGURATION);
4508 pConfiguration->BeaconPeriod = pAdapter->CommonCfg.BeaconPeriod;
4509 pConfiguration->ATIMWindow = pAdapter->StaActive.AtimWin;
4510 MAP_CHANNEL_ID_TO_KHZ(pAdapter->CommonCfg.Channel, pConfiguration->DSConfig);
4511 wrq->u.data.length = sizeof(NDIS_802_11_CONFIGURATION);
4512 Status = copy_to_user(wrq->u.data.pointer, pConfiguration, wrq->u.data.length);
4513 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_CONFIGURATION(BeaconPeriod=%ld,AtimW=%ld,Channel=%d) \n",
4514 pConfiguration->BeaconPeriod, pConfiguration->ATIMWindow, pAdapter->CommonCfg.Channel));
4515 kfree(pConfiguration);
4519 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_CONFIGURATION(kmalloc failed)\n"));
4523 case RT_OID_802_11_SNR_0:
4524 if ((pAdapter->StaCfg.LastSNR0 > 0))
4526 ulInfo = ((0xeb - pAdapter->StaCfg.LastSNR0) * 3) / 16 ;
4527 wrq->u.data.length = sizeof(ulInfo);
4528 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4529 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_SNR_0(0x=%lx)\n", ulInfo));
4534 case RT_OID_802_11_SNR_1:
4535 if ((pAdapter->Antenna.field.RxPath > 1) &&
4536 (pAdapter->StaCfg.LastSNR1 > 0))
4538 ulInfo = ((0xeb - pAdapter->StaCfg.LastSNR1) * 3) / 16 ;
4539 wrq->u.data.length = sizeof(ulInfo);
4540 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4541 DBGPRINT(RT_DEBUG_TRACE,("Query::RT_OID_802_11_SNR_1(0x=%lx)\n",ulInfo));
4545 DBGPRINT(RT_DEBUG_TRACE,("Query::RT_OID_802_11_SNR_1(pAdapter->StaCfg.LastSNR1=%d)\n",pAdapter->StaCfg.LastSNR1));
4547 case OID_802_11_RSSI_TRIGGER:
4548 ulInfo = pAdapter->StaCfg.RssiSample.LastRssi0 - pAdapter->BbpRssiToDbmDelta;
4549 wrq->u.data.length = sizeof(ulInfo);
4550 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4551 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_RSSI_TRIGGER(=%ld)\n", ulInfo));
4553 case OID_802_11_RSSI:
4554 case RT_OID_802_11_RSSI:
4555 ulInfo = pAdapter->StaCfg.RssiSample.LastRssi0;
4556 wrq->u.data.length = sizeof(ulInfo);
4557 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4559 case RT_OID_802_11_RSSI_1:
4560 ulInfo = pAdapter->StaCfg.RssiSample.LastRssi1;
4561 wrq->u.data.length = sizeof(ulInfo);
4562 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4564 case RT_OID_802_11_RSSI_2:
4565 ulInfo = pAdapter->StaCfg.RssiSample.LastRssi2;
4566 wrq->u.data.length = sizeof(ulInfo);
4567 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4569 case OID_802_11_STATISTICS:
4570 pStatistics = (NDIS_802_11_STATISTICS *) kmalloc(sizeof(NDIS_802_11_STATISTICS), MEM_ALLOC_FLAG);
4573 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_STATISTICS \n"));
4574 // add the most up-to-date h/w raw counters into software counters
4575 NICUpdateRawCounters(pAdapter);
4577 // Sanity check for calculation of sucessful count
4578 if (pAdapter->WlanCounters.TransmittedFragmentCount.QuadPart < pAdapter->WlanCounters.RetryCount.QuadPart)
4579 pAdapter->WlanCounters.TransmittedFragmentCount.QuadPart = pAdapter->WlanCounters.RetryCount.QuadPart;
4581 pStatistics->TransmittedFragmentCount.QuadPart = pAdapter->WlanCounters.TransmittedFragmentCount.QuadPart;
4582 pStatistics->MulticastTransmittedFrameCount.QuadPart = pAdapter->WlanCounters.MulticastTransmittedFrameCount.QuadPart;
4583 pStatistics->FailedCount.QuadPart = pAdapter->WlanCounters.FailedCount.QuadPart;
4584 pStatistics->RetryCount.QuadPart = pAdapter->WlanCounters.RetryCount.QuadPart;
4585 pStatistics->MultipleRetryCount.QuadPart = pAdapter->WlanCounters.MultipleRetryCount.QuadPart;
4586 pStatistics->RTSSuccessCount.QuadPart = pAdapter->WlanCounters.RTSSuccessCount.QuadPart;
4587 pStatistics->RTSFailureCount.QuadPart = pAdapter->WlanCounters.RTSFailureCount.QuadPart;
4588 pStatistics->ACKFailureCount.QuadPart = pAdapter->WlanCounters.ACKFailureCount.QuadPart;
4589 pStatistics->FrameDuplicateCount.QuadPart = pAdapter->WlanCounters.FrameDuplicateCount.QuadPart;
4590 pStatistics->ReceivedFragmentCount.QuadPart = pAdapter->WlanCounters.ReceivedFragmentCount.QuadPart;
4591 pStatistics->MulticastReceivedFrameCount.QuadPart = pAdapter->WlanCounters.MulticastReceivedFrameCount.QuadPart;
4593 pStatistics->FCSErrorCount = pAdapter->RalinkCounters.RealFcsErrCount;
4595 pStatistics->FCSErrorCount.QuadPart = pAdapter->WlanCounters.FCSErrorCount.QuadPart;
4596 pStatistics->FrameDuplicateCount.u.LowPart = pAdapter->WlanCounters.FrameDuplicateCount.u.LowPart / 100;
4598 wrq->u.data.length = sizeof(NDIS_802_11_STATISTICS);
4599 Status = copy_to_user(wrq->u.data.pointer, pStatistics, wrq->u.data.length);
4604 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_STATISTICS(kmalloc failed)\n"));
4608 case OID_GEN_RCV_OK:
4609 ulInfo = pAdapter->Counters8023.GoodReceives;
4610 wrq->u.data.length = sizeof(ulInfo);
4611 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4613 case OID_GEN_RCV_NO_BUFFER:
4614 ulInfo = pAdapter->Counters8023.RxNoBuffer;
4615 wrq->u.data.length = sizeof(ulInfo);
4616 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4618 case RT_OID_802_11_PHY_MODE:
4619 ulInfo = (ULONG)pAdapter->CommonCfg.PhyMode;
4620 wrq->u.data.length = sizeof(ulInfo);
4621 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4622 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_PHY_MODE (=%ld)\n", ulInfo));
4624 case RT_OID_802_11_STA_CONFIG:
4625 pStaConfig = (RT_802_11_STA_CONFIG *) kmalloc(sizeof(RT_802_11_STA_CONFIG), MEM_ALLOC_FLAG);
4628 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_STA_CONFIG\n"));
4629 pStaConfig->EnableTxBurst = pAdapter->CommonCfg.bEnableTxBurst;
4630 pStaConfig->EnableTurboRate = 0;
4631 pStaConfig->UseBGProtection = pAdapter->CommonCfg.UseBGProtection;
4632 pStaConfig->UseShortSlotTime = pAdapter->CommonCfg.bUseShortSlotTime;
4633 //pStaConfig->AdhocMode = pAdapter->StaCfg.AdhocMode;
4634 pStaConfig->HwRadioStatus = (pAdapter->StaCfg.bHwRadio == TRUE) ? 1 : 0;
4635 pStaConfig->Rsv1 = 0;
4636 pStaConfig->SystemErrorBitmap = pAdapter->SystemErrorBitmap;
4637 wrq->u.data.length = sizeof(RT_802_11_STA_CONFIG);
4638 Status = copy_to_user(wrq->u.data.pointer, pStaConfig, wrq->u.data.length);
4643 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_STA_CONFIG(kmalloc failed)\n"));
4647 case OID_802_11_RTS_THRESHOLD:
4648 RtsThresh = pAdapter->CommonCfg.RtsThreshold;
4649 wrq->u.data.length = sizeof(RtsThresh);
4650 Status = copy_to_user(wrq->u.data.pointer, &RtsThresh, wrq->u.data.length);
4651 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_RTS_THRESHOLD(=%ld)\n", RtsThresh));
4653 case OID_802_11_FRAGMENTATION_THRESHOLD:
4654 FragThresh = pAdapter->CommonCfg.FragmentThreshold;
4655 if (pAdapter->CommonCfg.bUseZeroToDisableFragment == TRUE)
4657 wrq->u.data.length = sizeof(FragThresh);
4658 Status = copy_to_user(wrq->u.data.pointer, &FragThresh, wrq->u.data.length);
4659 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_FRAGMENTATION_THRESHOLD(=%ld)\n", FragThresh));
4661 case OID_802_11_POWER_MODE:
4662 PowerMode = pAdapter->StaCfg.WindowsPowerMode;
4663 wrq->u.data.length = sizeof(PowerMode);
4664 Status = copy_to_user(wrq->u.data.pointer, &PowerMode, wrq->u.data.length);
4665 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_POWER_MODE(=%d)\n", PowerMode));
4667 case RT_OID_802_11_RADIO:
4668 RadioState = (BOOLEAN) pAdapter->StaCfg.bSwRadio;
4669 wrq->u.data.length = sizeof(RadioState);
4670 Status = copy_to_user(wrq->u.data.pointer, &RadioState, wrq->u.data.length);
4671 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_RADIO (=%d)\n", RadioState));
4673 case OID_802_11_INFRASTRUCTURE_MODE:
4674 if (pAdapter->StaCfg.BssType == BSS_ADHOC)
4675 BssType = Ndis802_11IBSS;
4676 else if (pAdapter->StaCfg.BssType == BSS_INFRA)
4677 BssType = Ndis802_11Infrastructure;
4678 else if (pAdapter->StaCfg.BssType == BSS_MONITOR)
4679 BssType = Ndis802_11Monitor;
4681 BssType = Ndis802_11AutoUnknown;
4683 wrq->u.data.length = sizeof(BssType);
4684 Status = copy_to_user(wrq->u.data.pointer, &BssType, wrq->u.data.length);
4685 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_INFRASTRUCTURE_MODE(=%d)\n", BssType));
4687 case RT_OID_802_11_PREAMBLE:
4688 PreamType = pAdapter->CommonCfg.TxPreamble;
4689 wrq->u.data.length = sizeof(PreamType);
4690 Status = copy_to_user(wrq->u.data.pointer, &PreamType, wrq->u.data.length);
4691 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_PREAMBLE(=%d)\n", PreamType));
4693 case OID_802_11_AUTHENTICATION_MODE:
4694 AuthMode = pAdapter->StaCfg.AuthMode;
4695 wrq->u.data.length = sizeof(AuthMode);
4696 Status = copy_to_user(wrq->u.data.pointer, &AuthMode, wrq->u.data.length);
4697 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_AUTHENTICATION_MODE(=%d)\n", AuthMode));
4699 case OID_802_11_WEP_STATUS:
4700 WepStatus = pAdapter->StaCfg.WepStatus;
4701 wrq->u.data.length = sizeof(WepStatus);
4702 Status = copy_to_user(wrq->u.data.pointer, &WepStatus, wrq->u.data.length);
4703 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_WEP_STATUS(=%d)\n", WepStatus));
4705 case OID_802_11_TX_POWER_LEVEL:
4706 wrq->u.data.length = sizeof(ULONG);
4707 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.TxPower, wrq->u.data.length);
4708 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_TX_POWER_LEVEL %x\n",pAdapter->CommonCfg.TxPower));
4710 case RT_OID_802_11_TX_POWER_LEVEL_1:
4711 wrq->u.data.length = sizeof(ULONG);
4712 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.TxPowerPercentage, wrq->u.data.length);
4713 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_TX_POWER_LEVEL_1 (=%ld)\n", pAdapter->CommonCfg.TxPowerPercentage));
4715 case OID_802_11_NETWORK_TYPES_SUPPORTED:
4716 if ((pAdapter->RfIcType == RFIC_2850) || (pAdapter->RfIcType == RFIC_2750))
4718 NetworkTypeList[0] = 3; // NumberOfItems = 3
4719 NetworkTypeList[1] = Ndis802_11DS; // NetworkType[1] = 11b
4720 NetworkTypeList[2] = Ndis802_11OFDM24; // NetworkType[2] = 11g
4721 NetworkTypeList[3] = Ndis802_11OFDM5; // NetworkType[3] = 11a
4722 wrq->u.data.length = 16;
4723 Status = copy_to_user(wrq->u.data.pointer, &NetworkTypeList[0], wrq->u.data.length);
4727 NetworkTypeList[0] = 2; // NumberOfItems = 2
4728 NetworkTypeList[1] = Ndis802_11DS; // NetworkType[1] = 11b
4729 NetworkTypeList[2] = Ndis802_11OFDM24; // NetworkType[2] = 11g
4730 wrq->u.data.length = 12;
4731 Status = copy_to_user(wrq->u.data.pointer, &NetworkTypeList[0], wrq->u.data.length);
4733 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_NETWORK_TYPES_SUPPORTED\n"));
4735 case OID_802_11_NETWORK_TYPE_IN_USE:
4736 wrq->u.data.length = sizeof(ULONG);
4737 if (pAdapter->CommonCfg.PhyMode == PHY_11A)
4738 ulInfo = Ndis802_11OFDM5;
4739 else if ((pAdapter->CommonCfg.PhyMode == PHY_11BG_MIXED) || (pAdapter->CommonCfg.PhyMode == PHY_11G))
4740 ulInfo = Ndis802_11OFDM24;
4742 ulInfo = Ndis802_11DS;
4743 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4745 case RT_OID_802_11_QUERY_LAST_RX_RATE:
4746 ulInfo = (ULONG)pAdapter->LastRxRate;
4747 wrq->u.data.length = sizeof(ulInfo);
4748 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4749 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_LAST_RX_RATE (=%ld)\n", ulInfo));
4751 case RT_OID_802_11_QUERY_LAST_TX_RATE:
4752 //ulInfo = (ULONG)pAdapter->LastTxRate;
4753 ulInfo = (ULONG)pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.word;
4754 wrq->u.data.length = sizeof(ulInfo);
4755 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4756 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_LAST_TX_RATE (=%lx)\n", ulInfo));
4758 case RT_OID_802_11_QUERY_EEPROM_VERSION:
4759 wrq->u.data.length = sizeof(ULONG);
4760 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->EepromVersion, wrq->u.data.length);
4762 case RT_OID_802_11_QUERY_FIRMWARE_VERSION:
4763 wrq->u.data.length = sizeof(ULONG);
4764 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->FirmwareVersion, wrq->u.data.length);
4766 case RT_OID_802_11_QUERY_NOISE_LEVEL:
4767 wrq->u.data.length = sizeof(UCHAR);
4768 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->BbpWriteLatch[66], wrq->u.data.length);
4769 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_NOISE_LEVEL (=%d)\n", pAdapter->BbpWriteLatch[66]));
4771 case RT_OID_802_11_EXTRA_INFO:
4772 wrq->u.data.length = sizeof(ULONG);
4773 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->ExtraInfo, wrq->u.data.length);
4774 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_EXTRA_INFO (=%ld)\n", pAdapter->ExtraInfo));
4776 case RT_OID_WE_VERSION_COMPILED:
4777 wrq->u.data.length = sizeof(UINT);
4778 we_version_compiled = WIRELESS_EXT;
4779 Status = copy_to_user(wrq->u.data.pointer, &we_version_compiled, wrq->u.data.length);
4781 case RT_OID_802_11_QUERY_APSD_SETTING:
4782 apsd = (pAdapter->CommonCfg.bAPSDCapable | (pAdapter->CommonCfg.bAPSDAC_BE << 1) | (pAdapter->CommonCfg.bAPSDAC_BK << 2)
4783 | (pAdapter->CommonCfg.bAPSDAC_VI << 3) | (pAdapter->CommonCfg.bAPSDAC_VO << 4) | (pAdapter->CommonCfg.MaxSPLength << 5));
4785 wrq->u.data.length = sizeof(ULONG);
4786 Status = copy_to_user(wrq->u.data.pointer, &apsd, wrq->u.data.length);
4787 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",
4788 apsd,pAdapter->CommonCfg.bAPSDCapable,pAdapter->CommonCfg.bAPSDAC_BE,pAdapter->CommonCfg.bAPSDAC_BK,pAdapter->CommonCfg.bAPSDAC_VI,pAdapter->CommonCfg.bAPSDAC_VO,pAdapter->CommonCfg.MaxSPLength));
4790 case RT_OID_802_11_QUERY_APSD_PSM:
4791 wrq->u.data.length = sizeof(ULONG);
4792 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.bAPSDForcePowerSave, wrq->u.data.length);
4793 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_APSD_PSM (=%d)\n", pAdapter->CommonCfg.bAPSDForcePowerSave));
4795 case RT_OID_802_11_QUERY_WMM:
4796 wrq->u.data.length = sizeof(BOOLEAN);
4797 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.bWmmCapable, wrq->u.data.length);
4798 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_WMM (=%d)\n", pAdapter->CommonCfg.bWmmCapable));
4800 #ifdef WPA_SUPPLICANT_SUPPORT
4801 case RT_OID_NEW_DRIVER:
4804 wrq->u.data.length = sizeof(UCHAR);
4805 Status = copy_to_user(wrq->u.data.pointer, &enabled, wrq->u.data.length);
4806 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_NEW_DRIVER (=%d)\n", enabled));
4809 case RT_OID_WPA_SUPPLICANT_SUPPORT:
4810 wrq->u.data.length = sizeof(UCHAR);
4811 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->StaCfg.WpaSupplicantUP, wrq->u.data.length);
4812 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_WPA_SUPPLICANT_SUPPORT (=%d)\n", pAdapter->StaCfg.WpaSupplicantUP));
4814 #endif // WPA_SUPPLICANT_SUPPORT //
4816 case RT_OID_DRIVER_DEVICE_NAME:
4817 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_DRIVER_DEVICE_NAME \n"));
4818 wrq->u.data.length = 16;
4819 if (copy_to_user(wrq->u.data.pointer, pAdapter->StaCfg.dev_name, wrq->u.data.length))
4824 case RT_OID_802_11_QUERY_HT_PHYMODE:
4825 pHTPhyMode = (OID_SET_HT_PHYMODE *) kmalloc(sizeof(OID_SET_HT_PHYMODE), MEM_ALLOC_FLAG);
4828 pHTPhyMode->PhyMode = pAdapter->CommonCfg.PhyMode;
4829 pHTPhyMode->HtMode = (UCHAR)pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.field.MODE;
4830 pHTPhyMode->BW = (UCHAR)pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.field.BW;
4831 pHTPhyMode->MCS= (UCHAR)pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.field.MCS;
4832 pHTPhyMode->SHORTGI= (UCHAR)pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.field.ShortGI;
4833 pHTPhyMode->STBC= (UCHAR)pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.field.STBC;
4835 pHTPhyMode->ExtOffset = ((pAdapter->CommonCfg.CentralChannel < pAdapter->CommonCfg.Channel) ? (EXTCHA_BELOW) : (EXTCHA_ABOVE));
4836 wrq->u.data.length = sizeof(OID_SET_HT_PHYMODE);
4837 if (copy_to_user(wrq->u.data.pointer, pHTPhyMode, wrq->u.data.length))
4841 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_HT_PHYMODE (PhyMode = %d, MCS =%d, BW = %d, STBC = %d, ExtOffset=%d)\n",
4842 pHTPhyMode->HtMode, pHTPhyMode->MCS, pHTPhyMode->BW, pHTPhyMode->STBC, pHTPhyMode->ExtOffset));
4843 DBGPRINT(RT_DEBUG_TRACE, (" MlmeUpdateTxRates (.word = %x )\n", pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.word));
4847 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_STA_CONFIG(kmalloc failed)\n"));
4851 case RT_OID_802_11_COUNTRY_REGION:
4852 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_COUNTRY_REGION \n"));
4853 wrq->u.data.length = sizeof(ulInfo);
4854 ulInfo = pAdapter->CommonCfg.CountryRegionForABand;
4855 ulInfo = (ulInfo << 8)|(pAdapter->CommonCfg.CountryRegion);
4856 if (copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length))
4861 case RT_OID_802_11_QUERY_DAT_HT_PHYMODE:
4862 pHTPhyMode = (OID_SET_HT_PHYMODE *) kmalloc(sizeof(OID_SET_HT_PHYMODE), MEM_ALLOC_FLAG);
4865 pHTPhyMode->PhyMode = pAdapter->CommonCfg.PhyMode;
4866 pHTPhyMode->HtMode = (UCHAR)pAdapter->CommonCfg.RegTransmitSetting.field.HTMODE;
4867 pHTPhyMode->BW = (UCHAR)pAdapter->CommonCfg.RegTransmitSetting.field.BW;
4868 pHTPhyMode->MCS= (UCHAR)pAdapter->StaCfg.DesiredTransmitSetting.field.MCS;
4869 pHTPhyMode->SHORTGI= (UCHAR)pAdapter->CommonCfg.RegTransmitSetting.field.ShortGI;
4870 pHTPhyMode->STBC= (UCHAR)pAdapter->CommonCfg.RegTransmitSetting.field.STBC;
4872 wrq->u.data.length = sizeof(OID_SET_HT_PHYMODE);
4873 if (copy_to_user(wrq->u.data.pointer, pHTPhyMode, wrq->u.data.length))
4877 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_HT_PHYMODE (PhyMode = %d, MCS =%d, BW = %d, STBC = %d, ExtOffset=%d)\n",
4878 pHTPhyMode->HtMode, pHTPhyMode->MCS, pHTPhyMode->BW, pHTPhyMode->STBC, pHTPhyMode->ExtOffset));
4879 DBGPRINT(RT_DEBUG_TRACE, (" MlmeUpdateTxRates (.word = %x )\n", pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.word));
4883 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_STA_CONFIG(kmalloc failed)\n"));
4887 case RT_OID_QUERY_MULTIPLE_CARD_SUPPORT:
4888 wrq->u.data.length = sizeof(UCHAR);
4890 if (copy_to_user(wrq->u.data.pointer, &i, wrq->u.data.length))
4894 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_QUERY_MULTIPLE_CARD_SUPPORT(=%d) \n", i));
4897 case OID_802_11_BUILD_CHANNEL_EX:
4900 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_BUILD_CHANNEL_EX \n"));
4901 wrq->u.data.length = sizeof(UCHAR);
4902 DBGPRINT(RT_DEBUG_TRACE, ("Doesn't support EXT_BUILD_CHANNEL_LIST.\n"));
4904 Status = copy_to_user(wrq->u.data.pointer, &value, 1);
4905 DBGPRINT(RT_DEBUG_TRACE, ("Status=%d\n", Status));
4909 case OID_802_11_GET_CH_LIST:
4911 PRT_CHANNEL_LIST_INFO pChListBuf;
4913 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_GET_CH_LIST \n"));
4914 if (pAdapter->ChannelListNum == 0)
4916 wrq->u.data.length = 0;
4920 pChListBuf = (RT_CHANNEL_LIST_INFO *) kmalloc(sizeof(RT_CHANNEL_LIST_INFO), MEM_ALLOC_FLAG);
4921 if (pChListBuf == NULL)
4923 wrq->u.data.length = 0;
4927 pChListBuf->ChannelListNum = pAdapter->ChannelListNum;
4928 for (i = 0; i < pChListBuf->ChannelListNum; i++)
4929 pChListBuf->ChannelList[i] = pAdapter->ChannelList[i].Channel;
4931 wrq->u.data.length = sizeof(RT_CHANNEL_LIST_INFO);
4932 Status = copy_to_user(wrq->u.data.pointer, pChListBuf, sizeof(RT_CHANNEL_LIST_INFO));
4933 DBGPRINT(RT_DEBUG_TRACE, ("Status=%d\n", Status));
4940 case OID_802_11_GET_COUNTRY_CODE:
4941 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_GET_COUNTRY_CODE \n"));
4942 wrq->u.data.length = 2;
4943 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.CountryCode, 2);
4944 DBGPRINT(RT_DEBUG_TRACE, ("Status=%d\n", Status));
4947 case OID_802_11_GET_CHANNEL_GEOGRAPHY:
4948 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_GET_CHANNEL_GEOGRAPHY \n"));
4949 wrq->u.data.length = 1;
4950 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.Geography, 1);
4951 DBGPRINT(RT_DEBUG_TRACE, ("Status=%d\n", Status));
4955 DBGPRINT(RT_DEBUG_TRACE, ("Query::unknown IOCTL's subcmd = 0x%08x\n", cmd));
4956 Status = -EOPNOTSUPP;
4962 INT rt28xx_sta_ioctl(
4963 IN struct net_device *net_dev,
4964 IN OUT struct ifreq *rq,
4968 VIRTUAL_ADAPTER *pVirtualAd = NULL;
4969 RTMP_ADAPTER *pAd = NULL;
4970 struct iwreq *wrq = (struct iwreq *) rq;
4971 BOOLEAN StateMachineTouched = FALSE;
4972 INT Status = NDIS_STATUS_SUCCESS;
4975 if (net_dev->priv_flags == INT_MAIN)
4977 pAd = net_dev->ml_priv;
4981 pVirtualAd = net_dev->ml_priv;
4982 pAd = pVirtualAd->RtmpDev->ml_priv;
4984 pObj = (POS_COOKIE) pAd->OS_Cookie;
4988 /* if 1st open fail, pAd will be free;
4989 So the net_dev->ml_priv will be NULL in 2rd open */
4993 //check if the interface is down
4994 if(!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_IN_USE))
4997 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
5002 { // determine this ioctl command is comming from which interface.
5003 pObj->ioctl_if_type = INT_MAIN;
5004 pObj->ioctl_if = MAIN_MBSSID;
5010 DBGPRINT(RT_DEBUG_TRACE, ("IOCTL::SIOCGIFHWADDR\n"));
5011 memcpy(wrq->u.name, pAd->CurrentAddress, ETH_ALEN);
5015 char *name=&wrq->u.name[0];
5016 rt_ioctl_giwname(net_dev, NULL, name, NULL);
5019 case SIOCGIWESSID: //Get ESSID
5021 struct iw_point *essid=&wrq->u.essid;
5022 rt_ioctl_giwessid(net_dev, NULL, essid, essid->pointer);
5025 case SIOCSIWESSID: //Set ESSID
5027 struct iw_point *essid=&wrq->u.essid;
5028 rt_ioctl_siwessid(net_dev, NULL, essid, essid->pointer);
5031 case SIOCSIWNWID: // set network id (the cell)
5032 case SIOCGIWNWID: // get network id
5033 Status = -EOPNOTSUPP;
5035 case SIOCSIWFREQ: //set channel/frequency (Hz)
5037 struct iw_freq *freq=&wrq->u.freq;
5038 rt_ioctl_siwfreq(net_dev, NULL, freq, NULL);
5041 case SIOCGIWFREQ: // get channel/frequency (Hz)
5043 struct iw_freq *freq=&wrq->u.freq;
5044 rt_ioctl_giwfreq(net_dev, NULL, freq, NULL);
5047 case SIOCSIWNICKN: //set node name/nickname
5049 struct iw_point *data=&wrq->u.data;
5050 rt_ioctl_siwnickn(net_dev, NULL, data, NULL);
5053 case SIOCGIWNICKN: //get node name/nickname
5055 struct iw_point *data=&wrq->u.data;
5056 rt_ioctl_giwnickn(net_dev, NULL, data, NULL);
5059 case SIOCGIWRATE: //get default bit rate (bps)
5060 rt_ioctl_giwrate(net_dev, NULL, &wrq->u, NULL);
5062 case SIOCSIWRATE: //set default bit rate (bps)
5063 rt_ioctl_siwrate(net_dev, NULL, &wrq->u, NULL);
5065 case SIOCGIWRTS: // get RTS/CTS threshold (bytes)
5067 struct iw_param *rts=&wrq->u.rts;
5068 rt_ioctl_giwrts(net_dev, NULL, rts, NULL);
5071 case SIOCSIWRTS: //set RTS/CTS threshold (bytes)
5073 struct iw_param *rts=&wrq->u.rts;
5074 rt_ioctl_siwrts(net_dev, NULL, rts, NULL);
5077 case SIOCGIWFRAG: //get fragmentation thr (bytes)
5079 struct iw_param *frag=&wrq->u.frag;
5080 rt_ioctl_giwfrag(net_dev, NULL, frag, NULL);
5083 case SIOCSIWFRAG: //set fragmentation thr (bytes)
5085 struct iw_param *frag=&wrq->u.frag;
5086 rt_ioctl_siwfrag(net_dev, NULL, frag, NULL);
5089 case SIOCGIWENCODE: //get encoding token & mode
5091 struct iw_point *erq=&wrq->u.encoding;
5093 rt_ioctl_giwencode(net_dev, NULL, erq, erq->pointer);
5096 case SIOCSIWENCODE: //set encoding token & mode
5098 struct iw_point *erq=&wrq->u.encoding;
5100 rt_ioctl_siwencode(net_dev, NULL, erq, erq->pointer);
5103 case SIOCGIWAP: //get access point MAC addresses
5105 struct sockaddr *ap_addr=&wrq->u.ap_addr;
5106 rt_ioctl_giwap(net_dev, NULL, ap_addr, ap_addr->sa_data);
5109 case SIOCSIWAP: //set access point MAC addresses
5111 struct sockaddr *ap_addr=&wrq->u.ap_addr;
5112 rt_ioctl_siwap(net_dev, NULL, ap_addr, ap_addr->sa_data);
5115 case SIOCGIWMODE: //get operation mode
5117 __u32 *mode=&wrq->u.mode;
5118 rt_ioctl_giwmode(net_dev, NULL, mode, NULL);
5121 case SIOCSIWMODE: //set operation mode
5123 __u32 *mode=&wrq->u.mode;
5124 rt_ioctl_siwmode(net_dev, NULL, mode, NULL);
5127 case SIOCGIWSENS: //get sensitivity (dBm)
5128 case SIOCSIWSENS: //set sensitivity (dBm)
5129 case SIOCGIWPOWER: //get Power Management settings
5130 case SIOCSIWPOWER: //set Power Management settings
5131 case SIOCGIWTXPOW: //get transmit power (dBm)
5132 case SIOCSIWTXPOW: //set transmit power (dBm)
5133 case SIOCGIWRANGE: //Get range of parameters
5134 case SIOCGIWRETRY: //get retry limits and lifetime
5135 case SIOCSIWRETRY: //set retry limits and lifetime
5136 Status = -EOPNOTSUPP;
5139 subcmd = wrq->u.data.flags;
5140 if( subcmd & OID_GET_SET_TOGGLE)
5141 Status = RTMPSetInformation(pAd, rq, subcmd);
5143 Status = RTMPQueryInformation(pAd, rq, subcmd);
5146 if (wrq->u.data.pointer)
5148 if ( access_ok(VERIFY_WRITE, wrq->u.data.pointer, sizeof(privtab)) != TRUE)
5150 wrq->u.data.length = sizeof(privtab) / sizeof(privtab[0]);
5151 if (copy_to_user(wrq->u.data.pointer, privtab, sizeof(privtab)))
5155 case RTPRIV_IOCTL_SET:
5156 if(access_ok(VERIFY_READ, wrq->u.data.pointer, wrq->u.data.length) != TRUE)
5158 rt_ioctl_setparam(net_dev, NULL, NULL, wrq->u.data.pointer);
5160 case RTPRIV_IOCTL_GSITESURVEY:
5161 RTMPIoctlGetSiteSurvey(pAd, wrq);
5164 case RTPRIV_IOCTL_MAC:
5165 RTMPIoctlMAC(pAd, wrq);
5167 case RTPRIV_IOCTL_E2P:
5168 RTMPIoctlE2PROM(pAd, wrq);
5174 DBGPRINT(RT_DEBUG_ERROR, ("IOCTL::unknown IOCTL's cmd = 0x%08x\n", cmd));
5175 Status = -EOPNOTSUPP;
5179 if(StateMachineTouched) // Upper layer sent a MLME-related operations
5180 RT28XX_MLME_HANDLER(pAd);
5186 ==========================================================================
5190 TRUE if all parameters are OK, FALSE otherwise
5191 ==========================================================================
5194 IN PRTMP_ADAPTER pAdapter,
5197 NDIS_802_11_SSID Ssid, *pSsid=NULL;
5198 BOOLEAN StateMachineTouched = FALSE;
5201 if( strlen(arg) <= MAX_LEN_OF_SSID)
5203 NdisZeroMemory(&Ssid, sizeof(NDIS_802_11_SSID));
5204 if (strlen(arg) != 0)
5206 NdisMoveMemory(Ssid.Ssid, arg, strlen(arg));
5207 Ssid.SsidLength = strlen(arg);
5211 Ssid.SsidLength = 0;
5212 memcpy(Ssid.Ssid, "", 0);
5213 pAdapter->StaCfg.BssType = BSS_INFRA;
5214 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
5215 pAdapter->StaCfg.WepStatus = Ndis802_11EncryptionDisabled;
5219 if (pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE)
5221 RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
5222 DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
5225 pAdapter->MlmeAux.CurrReqIsFromNdis = TRUE;
5226 pAdapter->StaCfg.bScanReqIsFromWebUI = FALSE;
5227 pAdapter->bConfigChanged = TRUE;
5229 MlmeEnqueue(pAdapter,
5230 MLME_CNTL_STATE_MACHINE,
5232 sizeof(NDIS_802_11_SSID),
5235 StateMachineTouched = TRUE;
5236 DBGPRINT(RT_DEBUG_TRACE, ("Set_SSID_Proc::(Len=%d,Ssid=%s)\n", Ssid.SsidLength, Ssid.Ssid));
5241 if (StateMachineTouched) // Upper layer sent a MLME-related operations
5242 RT28XX_MLME_HANDLER(pAdapter);
5249 ==========================================================================
5251 Set WmmCapable Enable or Disable
5253 TRUE if all parameters are OK, FALSE otherwise
5254 ==========================================================================
5256 INT Set_WmmCapable_Proc(
5257 IN PRTMP_ADAPTER pAd,
5260 BOOLEAN bWmmCapable;
5262 bWmmCapable = simple_strtol(arg, 0, 10);
5264 if ((bWmmCapable == 1)
5266 pAd->CommonCfg.bWmmCapable = TRUE;
5267 else if (bWmmCapable == 0)
5268 pAd->CommonCfg.bWmmCapable = FALSE;
5270 return FALSE; //Invalid argument
5272 DBGPRINT(RT_DEBUG_TRACE, ("Set_WmmCapable_Proc::(bWmmCapable=%d)\n",
5273 pAd->CommonCfg.bWmmCapable));
5277 #endif // WMM_SUPPORT //
5280 ==========================================================================
5282 Set Network Type(Infrastructure/Adhoc mode)
5284 TRUE if all parameters are OK, FALSE otherwise
5285 ==========================================================================
5287 INT Set_NetworkType_Proc(
5288 IN PRTMP_ADAPTER pAdapter,
5293 if (strcmp(arg, "Adhoc") == 0)
5295 if (pAdapter->StaCfg.BssType != BSS_ADHOC)
5297 // Config has changed
5298 pAdapter->bConfigChanged = TRUE;
5299 if (MONITOR_ON(pAdapter))
5301 RTMP_IO_WRITE32(pAdapter, RX_FILTR_CFG, STANORMAL);
5302 RTMP_IO_READ32(pAdapter, MAC_SYS_CTRL, &Value);
5304 RTMP_IO_WRITE32(pAdapter, MAC_SYS_CTRL, Value);
5305 OPSTATUS_CLEAR_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED);
5306 pAdapter->StaCfg.bAutoReconnect = TRUE;
5307 LinkDown(pAdapter, FALSE);
5309 if (INFRA_ON(pAdapter))
5311 //BOOLEAN Cancelled;
5312 // Set the AutoReconnectSsid to prevent it reconnect to old SSID
5313 // Since calling this indicate user don't want to connect to that SSID anymore.
5314 pAdapter->MlmeAux.AutoReconnectSsidLen= 32;
5315 NdisZeroMemory(pAdapter->MlmeAux.AutoReconnectSsid, pAdapter->MlmeAux.AutoReconnectSsidLen);
5317 LinkDown(pAdapter, FALSE);
5319 DBGPRINT(RT_DEBUG_TRACE, ("NDIS_STATUS_MEDIA_DISCONNECT Event BB!\n"));
5322 pAdapter->StaCfg.BssType = BSS_ADHOC;
5323 pAdapter->net_dev->type = pAdapter->StaCfg.OriDevType;
5324 DBGPRINT(RT_DEBUG_TRACE, ("===>Set_NetworkType_Proc::(AD-HOC)\n"));
5326 else if (strcmp(arg, "Infra") == 0)
5328 if (pAdapter->StaCfg.BssType != BSS_INFRA)
5330 // Config has changed
5331 pAdapter->bConfigChanged = TRUE;
5332 if (MONITOR_ON(pAdapter))
5334 RTMP_IO_WRITE32(pAdapter, RX_FILTR_CFG, STANORMAL);
5335 RTMP_IO_READ32(pAdapter, MAC_SYS_CTRL, &Value);
5337 RTMP_IO_WRITE32(pAdapter, MAC_SYS_CTRL, Value);
5338 OPSTATUS_CLEAR_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED);
5339 pAdapter->StaCfg.bAutoReconnect = TRUE;
5340 LinkDown(pAdapter, FALSE);
5342 if (ADHOC_ON(pAdapter))
5344 // Set the AutoReconnectSsid to prevent it reconnect to old SSID
5345 // Since calling this indicate user don't want to connect to that SSID anymore.
5346 pAdapter->MlmeAux.AutoReconnectSsidLen= 32;
5347 NdisZeroMemory(pAdapter->MlmeAux.AutoReconnectSsid, pAdapter->MlmeAux.AutoReconnectSsidLen);
5349 LinkDown(pAdapter, FALSE);
5352 pAdapter->StaCfg.BssType = BSS_INFRA;
5353 pAdapter->net_dev->type = pAdapter->StaCfg.OriDevType;
5354 DBGPRINT(RT_DEBUG_TRACE, ("===>Set_NetworkType_Proc::(INFRA)\n"));
5356 pAdapter->StaCfg.BssType = BSS_INFRA;
5358 else if (strcmp(arg, "Monitor") == 0)
5361 BCN_TIME_CFG_STRUC csr;
5362 OPSTATUS_CLEAR_FLAG(pAdapter, fOP_STATUS_INFRA_ON);
5363 OPSTATUS_CLEAR_FLAG(pAdapter, fOP_STATUS_ADHOC_ON);
5364 OPSTATUS_SET_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED);
5365 // disable all periodic state machine
5366 pAdapter->StaCfg.bAutoReconnect = FALSE;
5367 // reset all mlme state machine
5368 RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
5369 DBGPRINT(RT_DEBUG_TRACE, ("fOP_STATUS_MEDIA_STATE_CONNECTED \n"));
5370 if (pAdapter->CommonCfg.CentralChannel == 0)
5372 #ifdef DOT11_N_SUPPORT
5373 if (pAdapter->CommonCfg.PhyMode == PHY_11AN_MIXED)
5374 pAdapter->CommonCfg.CentralChannel = 36;
5376 #endif // DOT11_N_SUPPORT //
5377 pAdapter->CommonCfg.CentralChannel = 6;
5379 #ifdef DOT11_N_SUPPORT
5381 N_ChannelCheck(pAdapter);
5382 #endif // DOT11_N_SUPPORT //
5384 #ifdef DOT11_N_SUPPORT
5385 if (pAdapter->CommonCfg.PhyMode >= PHY_11ABGN_MIXED &&
5386 pAdapter->CommonCfg.RegTransmitSetting.field.BW == BW_40 &&
5387 pAdapter->CommonCfg.RegTransmitSetting.field.EXTCHA == EXTCHA_ABOVE)
5389 // 40MHz ,control channel at lower
5390 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, BBP_R4, &bbpValue);
5391 bbpValue &= (~0x18);
5393 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R4, bbpValue);
5394 pAdapter->CommonCfg.BBPCurrentBW = BW_40;
5395 // RX : control channel at lower
5396 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, BBP_R3, &bbpValue);
5397 bbpValue &= (~0x20);
5398 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R3, bbpValue);
5400 RTMP_IO_READ32(pAdapter, TX_BAND_CFG, &Value);
5401 Value &= 0xfffffffe;
5402 RTMP_IO_WRITE32(pAdapter, TX_BAND_CFG, Value);
5403 pAdapter->CommonCfg.CentralChannel = pAdapter->CommonCfg.Channel + 2;
5404 AsicSwitchChannel(pAdapter, pAdapter->CommonCfg.CentralChannel, FALSE);
5405 AsicLockChannel(pAdapter, pAdapter->CommonCfg.CentralChannel);
5406 DBGPRINT(RT_DEBUG_TRACE, ("BW_40 ,control_channel(%d), CentralChannel(%d) \n",
5407 pAdapter->CommonCfg.Channel,
5408 pAdapter->CommonCfg.CentralChannel));
5410 else if (pAdapter->CommonCfg.PhyMode >= PHY_11ABGN_MIXED &&
5411 pAdapter->CommonCfg.RegTransmitSetting.field.BW == BW_40 &&
5412 pAdapter->CommonCfg.RegTransmitSetting.field.EXTCHA == EXTCHA_BELOW)
5414 // 40MHz ,control channel at upper
5415 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, BBP_R4, &bbpValue);
5416 bbpValue &= (~0x18);
5418 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R4, bbpValue);
5419 pAdapter->CommonCfg.BBPCurrentBW = BW_40;
5420 RTMP_IO_READ32(pAdapter, TX_BAND_CFG, &Value);
5422 RTMP_IO_WRITE32(pAdapter, TX_BAND_CFG, Value);
5424 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, BBP_R3, &bbpValue);
5426 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R3, bbpValue);
5427 pAdapter->CommonCfg.CentralChannel = pAdapter->CommonCfg.Channel - 2;
5428 AsicSwitchChannel(pAdapter, pAdapter->CommonCfg.CentralChannel, FALSE);
5429 AsicLockChannel(pAdapter, pAdapter->CommonCfg.CentralChannel);
5430 DBGPRINT(RT_DEBUG_TRACE, ("BW_40 ,control_channel(%d), CentralChannel(%d) \n",
5431 pAdapter->CommonCfg.Channel,
5432 pAdapter->CommonCfg.CentralChannel));
5435 #endif // DOT11_N_SUPPORT //
5438 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, BBP_R4, &bbpValue);
5439 bbpValue &= (~0x18);
5440 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R4, bbpValue);
5441 pAdapter->CommonCfg.BBPCurrentBW = BW_20;
5442 AsicSwitchChannel(pAdapter, pAdapter->CommonCfg.Channel, FALSE);
5443 AsicLockChannel(pAdapter, pAdapter->CommonCfg.Channel);
5444 DBGPRINT(RT_DEBUG_TRACE, ("BW_20, Channel(%d)\n", pAdapter->CommonCfg.Channel));
5446 // Enable Rx with promiscuous reception
5447 RTMP_IO_WRITE32(pAdapter, RX_FILTR_CFG, 0x3);
5448 // ASIC supporsts sniffer function with replacing RSSI with timestamp.
5449 //RTMP_IO_READ32(pAdapter, MAC_SYS_CTRL, &Value);
5451 //RTMP_IO_WRITE32(pAdapter, MAC_SYS_CTRL, Value);
5453 RTMP_IO_READ32(pAdapter, BCN_TIME_CFG, &csr.word);
5454 csr.field.bBeaconGen = 0;
5455 csr.field.bTBTTEnable = 0;
5456 csr.field.TsfSyncMode = 0;
5457 RTMP_IO_WRITE32(pAdapter, BCN_TIME_CFG, csr.word);
5459 pAdapter->StaCfg.BssType = BSS_MONITOR;
5460 pAdapter->net_dev->type = ARPHRD_IEEE80211_PRISM; //ARPHRD_IEEE80211; // IEEE80211
5461 DBGPRINT(RT_DEBUG_TRACE, ("===>Set_NetworkType_Proc::(MONITOR)\n"));
5464 // Reset Ralink supplicant to not use, it will be set to start when UI set PMK key
5465 pAdapter->StaCfg.WpaState = SS_NOTUSE;
5467 DBGPRINT(RT_DEBUG_TRACE, ("Set_NetworkType_Proc::(NetworkType=%d)\n", pAdapter->StaCfg.BssType));
5473 ==========================================================================
5475 Set Authentication mode
5477 TRUE if all parameters are OK, FALSE otherwise
5478 ==========================================================================
5480 INT Set_AuthMode_Proc(
5481 IN PRTMP_ADAPTER pAdapter,
5484 if ((strcmp(arg, "WEPAUTO") == 0) || (strcmp(arg, "wepauto") == 0))
5485 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeAutoSwitch;
5486 else if ((strcmp(arg, "OPEN") == 0) || (strcmp(arg, "open") == 0))
5487 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
5488 else if ((strcmp(arg, "SHARED") == 0) || (strcmp(arg, "shared") == 0))
5489 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeShared;
5490 else if ((strcmp(arg, "WPAPSK") == 0) || (strcmp(arg, "wpapsk") == 0))
5491 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPAPSK;
5492 else if ((strcmp(arg, "WPANONE") == 0) || (strcmp(arg, "wpanone") == 0))
5493 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPANone;
5494 else if ((strcmp(arg, "WPA2PSK") == 0) || (strcmp(arg, "wpa2psk") == 0))
5495 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA2PSK;
5496 #ifdef WPA_SUPPLICANT_SUPPORT
5497 else if ((strcmp(arg, "WPA") == 0) || (strcmp(arg, "wpa") == 0))
5498 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA;
5499 else if ((strcmp(arg, "WPA2") == 0) || (strcmp(arg, "wpa2") == 0))
5500 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA2;
5501 #endif // WPA_SUPPLICANT_SUPPORT //
5505 pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED;
5507 DBGPRINT(RT_DEBUG_TRACE, ("Set_AuthMode_Proc::(AuthMode=%d)\n", pAdapter->StaCfg.AuthMode));
5513 ==========================================================================
5517 TRUE if all parameters are OK, FALSE otherwise
5518 ==========================================================================
5520 INT Set_EncrypType_Proc(
5521 IN PRTMP_ADAPTER pAdapter,
5524 if ((strcmp(arg, "NONE") == 0) || (strcmp(arg, "none") == 0))
5526 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
5527 return TRUE; // do nothing
5529 pAdapter->StaCfg.WepStatus = Ndis802_11WEPDisabled;
5530 pAdapter->StaCfg.PairCipher = Ndis802_11WEPDisabled;
5531 pAdapter->StaCfg.GroupCipher = Ndis802_11WEPDisabled;
5533 else if ((strcmp(arg, "WEP") == 0) || (strcmp(arg, "wep") == 0))
5535 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
5536 return TRUE; // do nothing
5538 pAdapter->StaCfg.WepStatus = Ndis802_11WEPEnabled;
5539 pAdapter->StaCfg.PairCipher = Ndis802_11WEPEnabled;
5540 pAdapter->StaCfg.GroupCipher = Ndis802_11WEPEnabled;
5542 else if ((strcmp(arg, "TKIP") == 0) || (strcmp(arg, "tkip") == 0))
5544 if (pAdapter->StaCfg.AuthMode < Ndis802_11AuthModeWPA)
5545 return TRUE; // do nothing
5547 pAdapter->StaCfg.WepStatus = Ndis802_11Encryption2Enabled;
5548 pAdapter->StaCfg.PairCipher = Ndis802_11Encryption2Enabled;
5549 pAdapter->StaCfg.GroupCipher = Ndis802_11Encryption2Enabled;
5551 else if ((strcmp(arg, "AES") == 0) || (strcmp(arg, "aes") == 0))
5553 if (pAdapter->StaCfg.AuthMode < Ndis802_11AuthModeWPA)
5554 return TRUE; // do nothing
5556 pAdapter->StaCfg.WepStatus = Ndis802_11Encryption3Enabled;
5557 pAdapter->StaCfg.PairCipher = Ndis802_11Encryption3Enabled;
5558 pAdapter->StaCfg.GroupCipher = Ndis802_11Encryption3Enabled;
5563 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
5565 DBGPRINT(RT_DEBUG_TRACE, ("Set_EncrypType_Proc::(EncrypType=%d)\n", pAdapter->StaCfg.WepStatus));
5571 ==========================================================================
5575 TRUE if all parameters are OK, FALSE otherwise
5576 ==========================================================================
5578 INT Set_DefaultKeyID_Proc(
5579 IN PRTMP_ADAPTER pAdapter,
5584 KeyIdx = simple_strtol(arg, 0, 10);
5585 if((KeyIdx >= 1 ) && (KeyIdx <= 4))
5586 pAdapter->StaCfg.DefaultKeyId = (UCHAR) (KeyIdx - 1 );
5588 return FALSE; //Invalid argument
5590 DBGPRINT(RT_DEBUG_TRACE, ("Set_DefaultKeyID_Proc::(DefaultKeyID=%d)\n", pAdapter->StaCfg.DefaultKeyId));
5596 ==========================================================================
5600 TRUE if all parameters are OK, FALSE otherwise
5601 ==========================================================================
5604 IN PRTMP_ADAPTER pAdapter,
5609 UCHAR CipherAlg=CIPHER_WEP64;
5611 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
5612 return TRUE; // do nothing
5614 KeyLen = strlen(arg);
5618 case 5: //wep 40 Ascii type
5619 pAdapter->SharedKey[BSS0][0].KeyLen = KeyLen;
5620 memcpy(pAdapter->SharedKey[BSS0][0].Key, arg, KeyLen);
5621 CipherAlg = CIPHER_WEP64;
5622 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key1_Proc::(Key1=%s and type=%s)\n", arg, "Ascii"));
5624 case 10: //wep 40 Hex type
5625 for(i=0; i < KeyLen; i++)
5627 if( !isxdigit(*(arg+i)) )
5628 return FALSE; //Not Hex value;
5630 pAdapter->SharedKey[BSS0][0].KeyLen = KeyLen / 2 ;
5631 AtoH(arg, pAdapter->SharedKey[BSS0][0].Key, KeyLen / 2);
5632 CipherAlg = CIPHER_WEP64;
5633 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key1_Proc::(Key1=%s and type=%s)\n", arg, "Hex"));
5635 case 13: //wep 104 Ascii type
5636 pAdapter->SharedKey[BSS0][0].KeyLen = KeyLen;
5637 memcpy(pAdapter->SharedKey[BSS0][0].Key, arg, KeyLen);
5638 CipherAlg = CIPHER_WEP128;
5639 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key1_Proc::(Key1=%s and type=%s)\n", arg, "Ascii"));
5641 case 26: //wep 104 Hex type
5642 for(i=0; i < KeyLen; i++)
5644 if( !isxdigit(*(arg+i)) )
5645 return FALSE; //Not Hex value;
5647 pAdapter->SharedKey[BSS0][0].KeyLen = KeyLen / 2 ;
5648 AtoH(arg, pAdapter->SharedKey[BSS0][0].Key, KeyLen / 2);
5649 CipherAlg = CIPHER_WEP128;
5650 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key1_Proc::(Key1=%s and type=%s)\n", arg, "Hex"));
5652 default: //Invalid argument
5653 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key1_Proc::Invalid argument (=%s)\n", arg));
5657 pAdapter->SharedKey[BSS0][0].CipherAlg = CipherAlg;
5659 // Set keys (into ASIC)
5660 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
5662 else // Old WEP stuff
5664 AsicAddSharedKeyEntry(pAdapter,
5667 pAdapter->SharedKey[BSS0][0].CipherAlg,
5668 pAdapter->SharedKey[BSS0][0].Key,
5676 ==========================================================================
5681 TRUE if all parameters are OK, FALSE otherwise
5682 ==========================================================================
5685 IN PRTMP_ADAPTER pAdapter,
5690 UCHAR CipherAlg=CIPHER_WEP64;
5692 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
5693 return TRUE; // do nothing
5695 KeyLen = strlen(arg);
5699 case 5: //wep 40 Ascii type
5700 pAdapter->SharedKey[BSS0][1].KeyLen = KeyLen;
5701 memcpy(pAdapter->SharedKey[BSS0][1].Key, arg, KeyLen);
5702 CipherAlg = CIPHER_WEP64;
5703 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key2_Proc::(Key2=%s and type=%s)\n", arg, "Ascii"));
5705 case 10: //wep 40 Hex type
5706 for(i=0; i < KeyLen; i++)
5708 if( !isxdigit(*(arg+i)) )
5709 return FALSE; //Not Hex value;
5711 pAdapter->SharedKey[BSS0][1].KeyLen = KeyLen / 2 ;
5712 AtoH(arg, pAdapter->SharedKey[BSS0][1].Key, KeyLen / 2);
5713 CipherAlg = CIPHER_WEP64;
5714 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key2_Proc::(Key2=%s and type=%s)\n", arg, "Hex"));
5716 case 13: //wep 104 Ascii type
5717 pAdapter->SharedKey[BSS0][1].KeyLen = KeyLen;
5718 memcpy(pAdapter->SharedKey[BSS0][1].Key, arg, KeyLen);
5719 CipherAlg = CIPHER_WEP128;
5720 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key2_Proc::(Key2=%s and type=%s)\n", arg, "Ascii"));
5722 case 26: //wep 104 Hex type
5723 for(i=0; i < KeyLen; i++)
5725 if( !isxdigit(*(arg+i)) )
5726 return FALSE; //Not Hex value;
5728 pAdapter->SharedKey[BSS0][1].KeyLen = KeyLen / 2 ;
5729 AtoH(arg, pAdapter->SharedKey[BSS0][1].Key, KeyLen / 2);
5730 CipherAlg = CIPHER_WEP128;
5731 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key2_Proc::(Key2=%s and type=%s)\n", arg, "Hex"));
5733 default: //Invalid argument
5734 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key2_Proc::Invalid argument (=%s)\n", arg));
5737 pAdapter->SharedKey[BSS0][1].CipherAlg = CipherAlg;
5739 // Set keys (into ASIC)
5740 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
5742 else // Old WEP stuff
5744 AsicAddSharedKeyEntry(pAdapter,
5747 pAdapter->SharedKey[BSS0][1].CipherAlg,
5748 pAdapter->SharedKey[BSS0][1].Key,
5756 ==========================================================================
5760 TRUE if all parameters are OK, FALSE otherwise
5761 ==========================================================================
5764 IN PRTMP_ADAPTER pAdapter,
5769 UCHAR CipherAlg=CIPHER_WEP64;
5771 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
5772 return TRUE; // do nothing
5774 KeyLen = strlen(arg);
5778 case 5: //wep 40 Ascii type
5779 pAdapter->SharedKey[BSS0][2].KeyLen = KeyLen;
5780 memcpy(pAdapter->SharedKey[BSS0][2].Key, arg, KeyLen);
5781 CipherAlg = CIPHER_WEP64;
5782 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key3_Proc::(Key3=%s and type=Ascii)\n", arg));
5784 case 10: //wep 40 Hex type
5785 for(i=0; i < KeyLen; i++)
5787 if( !isxdigit(*(arg+i)) )
5788 return FALSE; //Not Hex value;
5790 pAdapter->SharedKey[BSS0][2].KeyLen = KeyLen / 2 ;
5791 AtoH(arg, pAdapter->SharedKey[BSS0][2].Key, KeyLen / 2);
5792 CipherAlg = CIPHER_WEP64;
5793 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key3_Proc::(Key3=%s and type=Hex)\n", arg));
5795 case 13: //wep 104 Ascii type
5796 pAdapter->SharedKey[BSS0][2].KeyLen = KeyLen;
5797 memcpy(pAdapter->SharedKey[BSS0][2].Key, arg, KeyLen);
5798 CipherAlg = CIPHER_WEP128;
5799 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key3_Proc::(Key3=%s and type=Ascii)\n", arg));
5801 case 26: //wep 104 Hex type
5802 for(i=0; i < KeyLen; i++)
5804 if( !isxdigit(*(arg+i)) )
5805 return FALSE; //Not Hex value;
5807 pAdapter->SharedKey[BSS0][2].KeyLen = KeyLen / 2 ;
5808 AtoH(arg, pAdapter->SharedKey[BSS0][2].Key, KeyLen / 2);
5809 CipherAlg = CIPHER_WEP128;
5810 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key3_Proc::(Key3=%s and type=Hex)\n", arg));
5812 default: //Invalid argument
5813 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key3_Proc::Invalid argument (=%s)\n", arg));
5816 pAdapter->SharedKey[BSS0][2].CipherAlg = CipherAlg;
5818 // Set keys (into ASIC)
5819 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
5821 else // Old WEP stuff
5823 AsicAddSharedKeyEntry(pAdapter,
5826 pAdapter->SharedKey[BSS0][2].CipherAlg,
5827 pAdapter->SharedKey[BSS0][2].Key,
5835 ==========================================================================
5839 TRUE if all parameters are OK, FALSE otherwise
5840 ==========================================================================
5843 IN PRTMP_ADAPTER pAdapter,
5848 UCHAR CipherAlg=CIPHER_WEP64;
5850 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
5851 return TRUE; // do nothing
5853 KeyLen = strlen(arg);
5857 case 5: //wep 40 Ascii type
5858 pAdapter->SharedKey[BSS0][3].KeyLen = KeyLen;
5859 memcpy(pAdapter->SharedKey[BSS0][3].Key, arg, KeyLen);
5860 CipherAlg = CIPHER_WEP64;
5861 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key4_Proc::(Key4=%s and type=%s)\n", arg, "Ascii"));
5863 case 10: //wep 40 Hex type
5864 for(i=0; i < KeyLen; i++)
5866 if( !isxdigit(*(arg+i)) )
5867 return FALSE; //Not Hex value;
5869 pAdapter->SharedKey[BSS0][3].KeyLen = KeyLen / 2 ;
5870 AtoH(arg, pAdapter->SharedKey[BSS0][3].Key, KeyLen / 2);
5871 CipherAlg = CIPHER_WEP64;
5872 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key4_Proc::(Key4=%s and type=%s)\n", arg, "Hex"));
5874 case 13: //wep 104 Ascii type
5875 pAdapter->SharedKey[BSS0][3].KeyLen = KeyLen;
5876 memcpy(pAdapter->SharedKey[BSS0][3].Key, arg, KeyLen);
5877 CipherAlg = CIPHER_WEP128;
5878 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key4_Proc::(Key4=%s and type=%s)\n", arg, "Ascii"));
5880 case 26: //wep 104 Hex type
5881 for(i=0; i < KeyLen; i++)
5883 if( !isxdigit(*(arg+i)) )
5884 return FALSE; //Not Hex value;
5886 pAdapter->SharedKey[BSS0][3].KeyLen = KeyLen / 2 ;
5887 AtoH(arg, pAdapter->SharedKey[BSS0][3].Key, KeyLen / 2);
5888 CipherAlg = CIPHER_WEP128;
5889 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key4_Proc::(Key4=%s and type=%s)\n", arg, "Hex"));
5891 default: //Invalid argument
5892 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key4_Proc::Invalid argument (=%s)\n", arg));
5895 pAdapter->SharedKey[BSS0][3].CipherAlg = CipherAlg;
5897 // Set keys (into ASIC)
5898 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
5900 else // Old WEP stuff
5902 AsicAddSharedKeyEntry(pAdapter,
5905 pAdapter->SharedKey[BSS0][3].CipherAlg,
5906 pAdapter->SharedKey[BSS0][3].Key,
5915 ==========================================================================
5919 TRUE if all parameters are OK, FALSE otherwise
5920 ==========================================================================
5922 INT Set_WPAPSK_Proc(
5923 IN PRTMP_ADAPTER pAdapter,
5926 UCHAR keyMaterial[40];
5928 if ((pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPAPSK) &&
5929 (pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPA2PSK) &&
5930 (pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPANone)
5932 return TRUE; // do nothing
5934 DBGPRINT(RT_DEBUG_TRACE, ("Set_WPAPSK_Proc::(WPAPSK=%s)\n", arg));
5936 NdisZeroMemory(keyMaterial, 40);
5938 if ((strlen(arg) < 8) || (strlen(arg) > 64))
5940 DBGPRINT(RT_DEBUG_TRACE, ("Set failed!!(WPAPSK=%s), WPAPSK key-string required 8 ~ 64 characters \n", arg));
5944 if (strlen(arg) == 64)
5946 AtoH(arg, keyMaterial, 32);
5947 NdisMoveMemory(pAdapter->StaCfg.PMK, keyMaterial, 32);
5952 PasswordHash((char *)arg, pAdapter->MlmeAux.Ssid, pAdapter->MlmeAux.SsidLen, keyMaterial);
5953 NdisMoveMemory(pAdapter->StaCfg.PMK, keyMaterial, 32);
5958 if(pAdapter->StaCfg.BssType == BSS_ADHOC &&
5959 pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPANone)
5961 pAdapter->StaCfg.WpaState = SS_NOTUSE;
5965 // Start STA supplicant state machine
5966 pAdapter->StaCfg.WpaState = SS_START;
5973 ==========================================================================
5975 Set Power Saving mode
5977 TRUE if all parameters are OK, FALSE otherwise
5978 ==========================================================================
5980 INT Set_PSMode_Proc(
5981 IN PRTMP_ADAPTER pAdapter,
5984 if (pAdapter->StaCfg.BssType == BSS_INFRA)
5986 if ((strcmp(arg, "Max_PSP") == 0) ||
5987 (strcmp(arg, "max_psp") == 0) ||
5988 (strcmp(arg, "MAX_PSP") == 0))
5990 // do NOT turn on PSM bit here, wait until MlmeCheckForPsmChange()
5991 // to exclude certain situations.
5992 if (pAdapter->StaCfg.bWindowsACCAMEnable == FALSE)
5993 pAdapter->StaCfg.WindowsPowerMode = Ndis802_11PowerModeMAX_PSP;
5994 pAdapter->StaCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeMAX_PSP;
5995 OPSTATUS_SET_FLAG(pAdapter, fOP_STATUS_RECEIVE_DTIM);
5996 pAdapter->StaCfg.DefaultListenCount = 5;
5999 else if ((strcmp(arg, "Fast_PSP") == 0) ||
6000 (strcmp(arg, "fast_psp") == 0) ||
6001 (strcmp(arg, "FAST_PSP") == 0))
6003 // do NOT turn on PSM bit here, wait until MlmeCheckForPsmChange()
6004 // to exclude certain situations.
6005 OPSTATUS_SET_FLAG(pAdapter, fOP_STATUS_RECEIVE_DTIM);
6006 if (pAdapter->StaCfg.bWindowsACCAMEnable == FALSE)
6007 pAdapter->StaCfg.WindowsPowerMode = Ndis802_11PowerModeFast_PSP;
6008 pAdapter->StaCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeFast_PSP;
6009 pAdapter->StaCfg.DefaultListenCount = 3;
6011 else if ((strcmp(arg, "Legacy_PSP") == 0) ||
6012 (strcmp(arg, "legacy_psp") == 0) ||
6013 (strcmp(arg, "LEGACY_PSP") == 0))
6015 // do NOT turn on PSM bit here, wait until MlmeCheckForPsmChange()
6016 // to exclude certain situations.
6017 OPSTATUS_SET_FLAG(pAdapter, fOP_STATUS_RECEIVE_DTIM);
6018 if (pAdapter->StaCfg.bWindowsACCAMEnable == FALSE)
6019 pAdapter->StaCfg.WindowsPowerMode = Ndis802_11PowerModeLegacy_PSP;
6020 pAdapter->StaCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeLegacy_PSP;
6021 pAdapter->StaCfg.DefaultListenCount = 3;
6025 //Default Ndis802_11PowerModeCAM
6026 // clear PSM bit immediately
6027 MlmeSetPsmBit(pAdapter, PWR_ACTIVE);
6028 OPSTATUS_SET_FLAG(pAdapter, fOP_STATUS_RECEIVE_DTIM);
6029 if (pAdapter->StaCfg.bWindowsACCAMEnable == FALSE)
6030 pAdapter->StaCfg.WindowsPowerMode = Ndis802_11PowerModeCAM;
6031 pAdapter->StaCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeCAM;
6034 DBGPRINT(RT_DEBUG_TRACE, ("Set_PSMode_Proc::(PSMode=%ld)\n", pAdapter->StaCfg.WindowsPowerMode));
6043 #ifdef WPA_SUPPLICANT_SUPPORT
6045 ==========================================================================
6047 Set WpaSupport flag.
6049 0: Driver ignore wpa_supplicant.
6050 1: wpa_supplicant initiates scanning and AP selection.
6051 2: driver takes care of scanning, AP selection, and IEEE 802.11 association parameters.
6053 TRUE if all parameters are OK, FALSE otherwise
6054 ==========================================================================
6056 INT Set_Wpa_Support(
6057 IN PRTMP_ADAPTER pAd,
6061 if ( simple_strtol(arg, 0, 10) == 0)
6062 pAd->StaCfg.WpaSupplicantUP = WPA_SUPPLICANT_DISABLE;
6063 else if ( simple_strtol(arg, 0, 10) == 1)
6064 pAd->StaCfg.WpaSupplicantUP = WPA_SUPPLICANT_ENABLE;
6065 else if ( simple_strtol(arg, 0, 10) == 2)
6066 pAd->StaCfg.WpaSupplicantUP = WPA_SUPPLICANT_ENABLE_WITH_WEB_UI;
6068 pAd->StaCfg.WpaSupplicantUP = WPA_SUPPLICANT_DISABLE;
6070 DBGPRINT(RT_DEBUG_TRACE, ("Set_Wpa_Support::(WpaSupplicantUP=%d)\n", pAd->StaCfg.WpaSupplicantUP));
6074 #endif // WPA_SUPPLICANT_SUPPORT //
6078 ==========================================================================
6082 pAdapter Pointer to our adapter
6083 wrq Pointer to the ioctl argument
6090 1.) iwpriv ra0 mac 0 ==> read MAC where Addr=0x0
6091 2.) iwpriv ra0 mac 0=12 ==> write MAC where Addr=0x0, value=12
6092 ==========================================================================
6095 IN PRTMP_ADAPTER pAdapter,
6096 IN struct iwreq *wrq)
6104 UCHAR temp[16], temp2[16];
6105 UINT32 macValue = 0;
6109 memset(msg, 0x00, 1024);
6110 if (wrq->u.data.length > 1) //No parameters.
6112 Status = copy_from_user(arg, wrq->u.data.pointer, (wrq->u.data.length > 255) ? 255 : wrq->u.data.length);
6115 //Parsing Read or Write
6120 if ((value = rtstrchr(this_char, '=')) != NULL)
6123 if (!value || !*value)
6126 if(strlen(this_char) > 4)
6129 j = strlen(this_char);
6132 if(this_char[j] > 'f' || this_char[j] < '0')
6137 k = j = strlen(this_char);
6140 this_char[4-k+j] = this_char[j];
6144 this_char[3-k++]='0';
6147 if(strlen(this_char) == 4)
6149 AtoH(this_char, temp, 2);
6150 macAddr = *temp*256 + temp[1];
6151 if (macAddr < 0xFFFF)
6153 RTMP_IO_READ32(pAdapter, macAddr, &macValue);
6154 DBGPRINT(RT_DEBUG_TRACE, ("MacAddr=%lx, MacValue=%x\n", macAddr, macValue));
6155 sprintf(msg+strlen(msg), "[0x%08lX]:%08X ", macAddr , macValue);
6158 {//Invalid parametes, so default printk all bbp
6165 memcpy(&temp2, value, strlen(value));
6166 temp2[strlen(value)] = '\0';
6169 if((strlen(this_char) > 4) || strlen(temp2) > 8)
6172 j = strlen(this_char);
6175 if(this_char[j] > 'f' || this_char[j] < '0')
6182 if(temp2[j] > 'f' || temp2[j] < '0')
6187 k = j = strlen(this_char);
6190 this_char[4-k+j] = this_char[j];
6194 this_char[3-k++]='0';
6198 k = j = strlen(temp2);
6201 temp2[8-k+j] = temp2[j];
6209 AtoH(this_char, temp, 2);
6210 macAddr = *temp*256 + temp[1];
6212 AtoH(temp2, temp, 4);
6213 macValue = *temp*256*256*256 + temp[1]*256*256 + temp[2]*256 + temp[3];
6216 if (macAddr == (HW_DEBUG_SETTING_BASE + 4))
6218 // 0x2bf4: byte0 non-zero: enable R17 tuning, 0: disable R17 tuning
6219 if (macValue & 0x000000ff)
6221 pAdapter->BbpTuning.bEnable = TRUE;
6222 DBGPRINT(RT_DEBUG_TRACE,("turn on R17 tuning\n"));
6227 pAdapter->BbpTuning.bEnable = FALSE;
6228 R66 = 0x26 + GET_LNA_GAIN(pAdapter);
6229 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R66, (0x26 + GET_LNA_GAIN(pAdapter)));
6230 DBGPRINT(RT_DEBUG_TRACE,("turn off R17 tuning, restore to 0x%02x\n", R66));
6235 DBGPRINT(RT_DEBUG_TRACE, ("MacAddr=%02lx, MacValue=0x%x\n", macAddr, macValue));
6237 RTMP_IO_WRITE32(pAdapter, macAddr, macValue);
6238 sprintf(msg+strlen(msg), "[0x%08lX]:%08X ", macAddr, macValue);
6243 if(strlen(msg) == 1)
6244 sprintf(msg+strlen(msg), "===>Error command format!");
6246 // Copy the information into the user buffer
6247 wrq->u.data.length = strlen(msg);
6248 Status = copy_to_user(wrq->u.data.pointer, msg, wrq->u.data.length);
6250 DBGPRINT(RT_DEBUG_TRACE, ("<==RTMPIoctlMAC\n\n"));
6254 ==========================================================================
6258 pAdapter Pointer to our adapter
6259 wrq Pointer to the ioctl argument
6266 1.) iwpriv ra0 e2p 0 ==> read E2PROM where Addr=0x0
6267 2.) iwpriv ra0 e2p 0=1234 ==> write E2PROM where Addr=0x0, value=1234
6268 ==========================================================================
6270 VOID RTMPIoctlE2PROM(
6271 IN PRTMP_ADAPTER pAdapter,
6272 IN struct iwreq *wrq)
6280 UCHAR temp[16], temp2[16];
6285 memset(msg, 0x00, 1024);
6286 if (wrq->u.data.length > 1) //No parameters.
6288 Status = copy_from_user(arg, wrq->u.data.pointer, (wrq->u.data.length > 255) ? 255 : wrq->u.data.length);
6291 //Parsing Read or Write
6298 if ((value = rtstrchr(this_char, '=')) != NULL)
6301 if (!value || !*value)
6305 if(strlen(this_char) > 4)
6308 j = strlen(this_char);
6311 if(this_char[j] > 'f' || this_char[j] < '0')
6316 k = j = strlen(this_char);
6319 this_char[4-k+j] = this_char[j];
6323 this_char[3-k++]='0';
6326 if(strlen(this_char) == 4)
6328 AtoH(this_char, temp, 2);
6329 eepAddr = *temp*256 + temp[1];
6330 if (eepAddr < 0xFFFF)
6332 RT28xx_EEPROM_READ16(pAdapter, eepAddr, eepValue);
6333 sprintf(msg+strlen(msg), "[0x%04X]:0x%04X ", eepAddr , eepValue);
6336 {//Invalid parametes, so default printk all bbp
6343 memcpy(&temp2, value, strlen(value));
6344 temp2[strlen(value)] = '\0';
6347 if((strlen(this_char) > 4) || strlen(temp2) > 8)
6350 j = strlen(this_char);
6353 if(this_char[j] > 'f' || this_char[j] < '0')
6359 if(temp2[j] > 'f' || temp2[j] < '0')
6364 k = j = strlen(this_char);
6367 this_char[4-k+j] = this_char[j];
6371 this_char[3-k++]='0';
6375 k = j = strlen(temp2);
6378 temp2[4-k+j] = temp2[j];
6385 AtoH(this_char, temp, 2);
6386 eepAddr = *temp*256 + temp[1];
6388 AtoH(temp2, temp, 2);
6389 eepValue = *temp*256 + temp[1];
6391 RT28xx_EEPROM_WRITE16(pAdapter, eepAddr, eepValue);
6392 sprintf(msg+strlen(msg), "[0x%02X]:%02X ", eepAddr, eepValue);
6396 if(strlen(msg) == 1)
6397 sprintf(msg+strlen(msg), "===>Error command format!");
6400 // Copy the information into the user buffer
6401 wrq->u.data.length = strlen(msg);
6402 Status = copy_to_user(wrq->u.data.pointer, msg, wrq->u.data.length);
6404 DBGPRINT(RT_DEBUG_TRACE, ("<==RTMPIoctlE2PROM\n"));
6411 INT Set_TGnWifiTest_Proc(
6412 IN PRTMP_ADAPTER pAd,
6415 if (simple_strtol(arg, 0, 10) == 0)
6416 pAd->StaCfg.bTGnWifiTest = FALSE;
6418 pAd->StaCfg.bTGnWifiTest = TRUE;
6420 DBGPRINT(RT_DEBUG_TRACE, ("IF Set_TGnWifiTest_Proc::(bTGnWifiTest=%d)\n", pAd->StaCfg.bTGnWifiTest));
6424 INT Set_LongRetryLimit_Proc(
6425 IN PRTMP_ADAPTER pAdapter,
6428 TX_RTY_CFG_STRUC tx_rty_cfg;
6429 UCHAR LongRetryLimit = (UCHAR)simple_strtol(arg, 0, 10);
6431 RTMP_IO_READ32(pAdapter, TX_RTY_CFG, &tx_rty_cfg.word);
6432 tx_rty_cfg.field.LongRtyLimit = LongRetryLimit;
6433 RTMP_IO_WRITE32(pAdapter, TX_RTY_CFG, tx_rty_cfg.word);
6434 DBGPRINT(RT_DEBUG_TRACE, ("IF Set_LongRetryLimit_Proc::(tx_rty_cfg=0x%x)\n", tx_rty_cfg.word));
6438 INT Set_ShortRetryLimit_Proc(
6439 IN PRTMP_ADAPTER pAdapter,
6442 TX_RTY_CFG_STRUC tx_rty_cfg;
6443 UCHAR ShortRetryLimit = (UCHAR)simple_strtol(arg, 0, 10);
6445 RTMP_IO_READ32(pAdapter, TX_RTY_CFG, &tx_rty_cfg.word);
6446 tx_rty_cfg.field.ShortRtyLimit = ShortRetryLimit;
6447 RTMP_IO_WRITE32(pAdapter, TX_RTY_CFG, tx_rty_cfg.word);
6448 DBGPRINT(RT_DEBUG_TRACE, ("IF Set_ShortRetryLimit_Proc::(tx_rty_cfg=0x%x)\n", tx_rty_cfg.word));