2 *************************************************************************
4 * 5F., No.36, Taiyuan St., Jhubei City,
8 * (c) Copyright 2002-2007, Ralink Technology, Inc.
10 * This program is free software; you can redistribute it and/or modify *
11 * it under the terms of the GNU General Public License as published by *
12 * the Free Software Foundation; either version 2 of the License, or *
13 * (at your option) any later version. *
15 * This program is distributed in the hope that it will be useful, *
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
18 * GNU General Public License for more details. *
20 * You should have received a copy of the GNU General Public License *
21 * along with this program; if not, write to the *
22 * Free Software Foundation, Inc., *
23 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
25 *************************************************************************
31 IOCTL related subroutines
35 -------- ---------- ----------------------------------------------
36 Rory Chen 01-03-2003 created
37 Rory Chen 02-14-2005 modify to support RT61
40 #include "rt_config.h"
43 extern ULONG RTDebugLevel;
47 #define WEP_SMALL_KEY_LEN (40/8)
48 #define WEP_LARGE_KEY_LEN (104/8)
50 #define GROUP_KEY_NO 4
52 extern UCHAR CipherWpa2Template[];
53 extern UCHAR CipherWpaPskTkip[];
54 extern UCHAR CipherWpaPskTkipLen;
56 typedef struct PACKED _RT_VERSION_INFO{
62 UINT DriverBuildMonth;
64 } RT_VERSION_INFO, *PRT_VERSION_INFO;
66 struct iw_priv_args privtab[] = {
68 IW_PRIV_TYPE_CHAR | 1024, 0,
71 { RTPRIV_IOCTL_SHOW, 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK,
73 { RTPRIV_IOCTL_SHOW, IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK,
75 /* --- sub-ioctls definitions --- */
77 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "connStatus" },
79 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "driverVer" },
81 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "bainfo" },
83 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "descinfo" },
85 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "radio_off" },
87 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "radio_on" },
88 #ifdef QOS_DLS_SUPPORT
89 { SHOW_DLS_ENTRY_INFO,
90 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "dlsentryinfo" },
91 #endif // QOS_DLS_SUPPORT //
93 IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "show" },
94 { SHOW_ADHOC_ENTRY_INFO,
95 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "adhocEntry" },
97 /* --- sub-ioctls relations --- */
101 IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK,
104 IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | 1024,
107 IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | 1024,
111 { RTPRIV_IOCTL_STATISTICS,
112 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK,
114 { RTPRIV_IOCTL_GSITESURVEY,
115 0, IW_PRIV_TYPE_CHAR | 1024,
120 IN PRTMP_ADAPTER pAdapter,
124 INT Set_WmmCapable_Proc(
125 IN PRTMP_ADAPTER pAd,
129 INT Set_NetworkType_Proc(
130 IN PRTMP_ADAPTER pAdapter,
133 INT Set_AuthMode_Proc(
134 IN PRTMP_ADAPTER pAdapter,
137 INT Set_EncrypType_Proc(
138 IN PRTMP_ADAPTER pAdapter,
141 INT Set_DefaultKeyID_Proc(
142 IN PRTMP_ADAPTER pAdapter,
146 IN PRTMP_ADAPTER pAdapter,
150 IN PRTMP_ADAPTER pAdapter,
154 IN PRTMP_ADAPTER pAdapter,
158 IN PRTMP_ADAPTER pAdapter,
162 IN PRTMP_ADAPTER pAdapter,
167 IN PRTMP_ADAPTER pAdapter,
170 #ifdef WPA_SUPPLICANT_SUPPORT
172 IN PRTMP_ADAPTER pAd,
174 #endif // WPA_SUPPLICANT_SUPPORT //
178 IN PRTMP_ADAPTER pAdapter,
179 IN struct iwreq *wrq);
182 IN PRTMP_ADAPTER pAdapter,
183 IN struct iwreq *wrq);
185 VOID RTMPIoctlE2PROM(
186 IN PRTMP_ADAPTER pAdapter,
187 IN struct iwreq *wrq);
191 NDIS_STATUS RTMPWPANoneAddKeyProc(
192 IN PRTMP_ADAPTER pAd,
195 INT Set_FragTest_Proc(
196 IN PRTMP_ADAPTER pAdapter,
199 #ifdef DOT11_N_SUPPORT
200 INT Set_TGnWifiTest_Proc(
201 IN PRTMP_ADAPTER pAd,
203 #endif // DOT11_N_SUPPORT //
205 INT Set_LongRetryLimit_Proc(
206 IN PRTMP_ADAPTER pAdapter,
209 INT Set_ShortRetryLimit_Proc(
210 IN PRTMP_ADAPTER pAdapter,
213 #ifdef EXT_BUILD_CHANNEL_LIST
214 INT Set_Ieee80211dClientMode_Proc(
215 IN PRTMP_ADAPTER pAdapter,
217 #endif // EXT_BUILD_CHANNEL_LIST //
219 INT Show_Adhoc_MacTable_Proc(
220 IN PRTMP_ADAPTER pAd,
225 INT (*set_proc)(PRTMP_ADAPTER pAdapter, PUCHAR arg);
226 } *PRTMP_PRIVATE_SET_PROC, RTMP_PRIVATE_SUPPORT_PROC[] = {
227 {"DriverVersion", Set_DriverVersion_Proc},
228 {"CountryRegion", Set_CountryRegion_Proc},
229 {"CountryRegionABand", Set_CountryRegionABand_Proc},
230 {"SSID", Set_SSID_Proc},
231 {"WirelessMode", Set_WirelessMode_Proc},
232 {"TxBurst", Set_TxBurst_Proc},
233 {"TxPreamble", Set_TxPreamble_Proc},
234 {"TxPower", Set_TxPower_Proc},
235 {"Channel", Set_Channel_Proc},
236 {"BGProtection", Set_BGProtection_Proc},
237 {"RTSThreshold", Set_RTSThreshold_Proc},
238 {"FragThreshold", Set_FragThreshold_Proc},
239 #ifdef DOT11_N_SUPPORT
240 {"HtBw", Set_HtBw_Proc},
241 {"HtMcs", Set_HtMcs_Proc},
242 {"HtGi", Set_HtGi_Proc},
243 {"HtOpMode", Set_HtOpMode_Proc},
244 {"HtExtcha", Set_HtExtcha_Proc},
245 {"HtMpduDensity", Set_HtMpduDensity_Proc},
246 {"HtBaWinSize", Set_HtBaWinSize_Proc},
247 {"HtRdg", Set_HtRdg_Proc},
248 {"HtAmsdu", Set_HtAmsdu_Proc},
249 {"HtAutoBa", Set_HtAutoBa_Proc},
250 {"HtBaDecline", Set_BADecline_Proc},
251 {"HtProtect", Set_HtProtect_Proc},
252 {"HtMimoPs", Set_HtMimoPs_Proc},
253 #endif // DOT11_N_SUPPORT //
255 #ifdef AGGREGATION_SUPPORT
256 {"PktAggregate", Set_PktAggregate_Proc},
260 {"WmmCapable", Set_WmmCapable_Proc},
262 {"IEEE80211H", Set_IEEE80211H_Proc},
263 {"NetworkType", Set_NetworkType_Proc},
264 {"AuthMode", Set_AuthMode_Proc},
265 {"EncrypType", Set_EncrypType_Proc},
266 {"DefaultKeyID", Set_DefaultKeyID_Proc},
267 {"Key1", Set_Key1_Proc},
268 {"Key2", Set_Key2_Proc},
269 {"Key3", Set_Key3_Proc},
270 {"Key4", Set_Key4_Proc},
271 {"WPAPSK", Set_WPAPSK_Proc},
272 {"ResetCounter", Set_ResetStatCounter_Proc},
273 {"PSMode", Set_PSMode_Proc},
275 {"Debug", Set_Debug_Proc},
278 #ifdef WPA_SUPPLICANT_SUPPORT
279 {"WpaSupport", Set_Wpa_Support},
280 #endif // WPA_SUPPLICANT_SUPPORT //
284 {"FixedTxMode", Set_FixedTxMode_Proc},
285 #ifdef DOT11_N_SUPPORT
286 {"TGnWifiTest", Set_TGnWifiTest_Proc},
287 {"ForceGF", Set_ForceGF_Proc},
288 #endif // DOT11_N_SUPPORT //
289 #ifdef QOS_DLS_SUPPORT
290 {"DlsAddEntry", Set_DlsAddEntry_Proc},
291 {"DlsTearDownEntry", Set_DlsTearDownEntry_Proc},
292 #endif // QOS_DLS_SUPPORT //
293 {"LongRetry", Set_LongRetryLimit_Proc},
294 {"ShortRetry", Set_ShortRetryLimit_Proc},
295 #ifdef EXT_BUILD_CHANNEL_LIST
296 {"11dClientMode", Set_Ieee80211dClientMode_Proc},
297 #endif // EXT_BUILD_CHANNEL_LIST //
303 IN PRTMP_ADAPTER pAd,
304 IN PNDIS_802_11_KEY pKey)
307 MAC_TABLE_ENTRY *pEntry;
309 DBGPRINT(RT_DEBUG_TRACE, ("RTMPAddKey ------>\n"));
311 if (pAd->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
313 if (pKey->KeyIndex & 0x80000000)
315 if (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPANone)
317 NdisZeroMemory(pAd->StaCfg.PMK, 32);
318 NdisMoveMemory(pAd->StaCfg.PMK, pKey->KeyMaterial, pKey->KeyLength);
322 NdisZeroMemory(&pAd->SharedKey[BSS0][0], sizeof(CIPHER_KEY));
323 pAd->SharedKey[BSS0][0].KeyLen = LEN_TKIP_EK;
324 NdisMoveMemory(pAd->SharedKey[BSS0][0].Key, pKey->KeyMaterial, LEN_TKIP_EK);
325 #ifdef WPA_SUPPLICANT_SUPPORT
326 if (pAd->StaCfg.PairCipher == Ndis802_11Encryption2Enabled)
328 NdisMoveMemory(pAd->SharedKey[BSS0][0].RxMic, pKey->KeyMaterial + LEN_TKIP_EK, LEN_TKIP_TXMICK);
329 NdisMoveMemory(pAd->SharedKey[BSS0][0].TxMic, pKey->KeyMaterial + LEN_TKIP_EK + LEN_TKIP_TXMICK, LEN_TKIP_RXMICK);
332 #endif // WPA_SUPPLICANT_SUPPORT //
334 NdisMoveMemory(pAd->SharedKey[BSS0][0].TxMic, pKey->KeyMaterial + LEN_TKIP_EK, LEN_TKIP_TXMICK);
335 NdisMoveMemory(pAd->SharedKey[BSS0][0].RxMic, pKey->KeyMaterial + LEN_TKIP_EK + LEN_TKIP_TXMICK, LEN_TKIP_RXMICK);
338 // Decide its ChiperAlg
339 if (pAd->StaCfg.PairCipher == Ndis802_11Encryption2Enabled)
340 pAd->SharedKey[BSS0][0].CipherAlg = CIPHER_TKIP;
341 else if (pAd->StaCfg.PairCipher == Ndis802_11Encryption3Enabled)
342 pAd->SharedKey[BSS0][0].CipherAlg = CIPHER_AES;
344 pAd->SharedKey[BSS0][0].CipherAlg = CIPHER_NONE;
346 // Update these related information to MAC_TABLE_ENTRY
347 pEntry = &pAd->MacTab.Content[BSSID_WCID];
348 NdisMoveMemory(pEntry->PairwiseKey.Key, pAd->SharedKey[BSS0][0].Key, LEN_TKIP_EK);
349 NdisMoveMemory(pEntry->PairwiseKey.RxMic, pAd->SharedKey[BSS0][0].RxMic, LEN_TKIP_RXMICK);
350 NdisMoveMemory(pEntry->PairwiseKey.TxMic, pAd->SharedKey[BSS0][0].TxMic, LEN_TKIP_TXMICK);
351 pEntry->PairwiseKey.CipherAlg = pAd->SharedKey[BSS0][0].CipherAlg;
353 // Update pairwise key information to ASIC Shared Key Table
354 AsicAddSharedKeyEntry(pAd,
357 pAd->SharedKey[BSS0][0].CipherAlg,
358 pAd->SharedKey[BSS0][0].Key,
359 pAd->SharedKey[BSS0][0].TxMic,
360 pAd->SharedKey[BSS0][0].RxMic);
362 // Update ASIC WCID attribute table and IVEIV table
363 RTMPAddWcidAttributeEntry(pAd,
366 pAd->SharedKey[BSS0][0].CipherAlg,
369 if (pAd->StaCfg.AuthMode >= Ndis802_11AuthModeWPA2)
371 // set 802.1x port control
372 //pAd->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
373 STA_PORT_SECURED(pAd);
375 // Indicate Connected for GUI
376 pAd->IndicateMediaState = NdisMediaStateConnected;
382 pAd->StaCfg.DefaultKeyId = (pKey->KeyIndex & 0xFF);
383 NdisZeroMemory(&pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId], sizeof(CIPHER_KEY));
384 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].KeyLen = LEN_TKIP_EK;
385 NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].Key, pKey->KeyMaterial, LEN_TKIP_EK);
386 #ifdef WPA_SUPPLICANT_SUPPORT
387 if (pAd->StaCfg.GroupCipher == Ndis802_11Encryption2Enabled)
389 NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].RxMic, pKey->KeyMaterial + LEN_TKIP_EK, LEN_TKIP_TXMICK);
390 NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].TxMic, pKey->KeyMaterial + LEN_TKIP_EK + LEN_TKIP_TXMICK, LEN_TKIP_RXMICK);
393 #endif // WPA_SUPPLICANT_SUPPORT //
395 NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].TxMic, pKey->KeyMaterial + LEN_TKIP_EK, LEN_TKIP_TXMICK);
396 NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].RxMic, pKey->KeyMaterial + LEN_TKIP_EK + LEN_TKIP_TXMICK, LEN_TKIP_RXMICK);
399 // Update Shared Key CipherAlg
400 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg = CIPHER_NONE;
401 if (pAd->StaCfg.GroupCipher == Ndis802_11Encryption2Enabled)
402 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg = CIPHER_TKIP;
403 else if (pAd->StaCfg.GroupCipher == Ndis802_11Encryption3Enabled)
404 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg = CIPHER_AES;
406 // Update group key information to ASIC Shared Key Table
407 AsicAddSharedKeyEntry(pAd,
409 pAd->StaCfg.DefaultKeyId,
410 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg,
411 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].Key,
412 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].TxMic,
413 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].RxMic);
415 // Update ASIC WCID attribute table and IVEIV table
416 RTMPAddWcidAttributeEntry(pAd,
418 pAd->StaCfg.DefaultKeyId,
419 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg,
422 // set 802.1x port control
423 //pAd->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
424 STA_PORT_SECURED(pAd);
426 // Indicate Connected for GUI
427 pAd->IndicateMediaState = NdisMediaStateConnected;
430 else // dynamic WEP from wpa_supplicant
435 if(pKey->KeyLength == 32)
438 KeyIdx = pKey->KeyIndex & 0x0fffffff;
442 // it is a default shared key, for Pairwise key setting
443 if (pKey->KeyIndex & 0x80000000)
445 pEntry = MacTableLookup(pAd, pKey->BSSID);
449 DBGPRINT(RT_DEBUG_TRACE, ("RTMPAddKey: Set Pair-wise Key\n"));
451 // set key material and key length
452 pEntry->PairwiseKey.KeyLen = (UCHAR)pKey->KeyLength;
453 NdisMoveMemory(pEntry->PairwiseKey.Key, &pKey->KeyMaterial, pKey->KeyLength);
456 if (pKey->KeyLength == 5)
457 pEntry->PairwiseKey.CipherAlg = CIPHER_WEP64;
459 pEntry->PairwiseKey.CipherAlg = CIPHER_WEP128;
461 // Add Pair-wise key to Asic
462 AsicAddPairwiseKeyEntry(
466 &pEntry->PairwiseKey);
468 // update WCID attribute table and IVEIV table for this entry
469 RTMPAddWcidAttributeEntry(
472 KeyIdx, // The value may be not zero
473 pEntry->PairwiseKey.CipherAlg,
480 // Default key for tx (shared key)
481 pAd->StaCfg.DefaultKeyId = (UCHAR) KeyIdx;
483 // set key material and key length
484 pAd->SharedKey[BSS0][KeyIdx].KeyLen = (UCHAR) pKey->KeyLength;
485 NdisMoveMemory(pAd->SharedKey[BSS0][KeyIdx].Key, &pKey->KeyMaterial, pKey->KeyLength);
488 if (pKey->KeyLength == 5)
489 pAd->SharedKey[BSS0][KeyIdx].CipherAlg = CIPHER_WEP64;
491 pAd->SharedKey[BSS0][KeyIdx].CipherAlg = CIPHER_WEP128;
493 CipherAlg = pAd->SharedKey[BSS0][KeyIdx].CipherAlg;
494 Key = pAd->SharedKey[BSS0][KeyIdx].Key;
496 // Set Group key material to Asic
497 AsicAddSharedKeyEntry(pAd, BSS0, KeyIdx, CipherAlg, Key, NULL, NULL);
499 // Update WCID attribute table and IVEIV table for this group key table
500 RTMPAddWcidAttributeEntry(pAd, BSS0, KeyIdx, CipherAlg, NULL);
509 char * rtstrchr(const char * s, int c)
511 for(; *s != (char) c; ++s)
518 This is required for LinEX2004/kernel2.6.7 to provide iwlist scanning function
522 rt_ioctl_giwname(struct net_device *dev,
523 struct iw_request_info *info,
524 char *name, char *extra)
526 // PRTMP_ADAPTER pAdapter = dev->ml_priv;
529 strncpy(name, "RT2870 Wireless", IFNAMSIZ);
534 int rt_ioctl_siwfreq(struct net_device *dev,
535 struct iw_request_info *info,
536 struct iw_freq *freq, char *extra)
538 PRTMP_ADAPTER pAdapter = dev->ml_priv;
541 //check if the interface is down
542 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
544 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
552 if((freq->e == 0) && (freq->m <= 1000))
553 chan = freq->m; // Setting by channel number
555 MAP_KHZ_TO_CHANNEL_ID( (freq->m /100) , chan); // Setting by frequency - search the table , like 2.412G, 2.422G,
557 if (ChannelSanity(pAdapter, chan) == TRUE)
559 pAdapter->CommonCfg.Channel = chan;
560 DBGPRINT(RT_DEBUG_ERROR, ("==>rt_ioctl_siwfreq::SIOCSIWFREQ[cmd=0x%x] (Channel=%d)\n", SIOCSIWFREQ, pAdapter->CommonCfg.Channel));
567 int rt_ioctl_giwfreq(struct net_device *dev,
568 struct iw_request_info *info,
569 struct iw_freq *freq, char *extra)
571 VIRTUAL_ADAPTER *pVirtualAd = NULL;
572 PRTMP_ADAPTER pAdapter = NULL;
576 if (dev->priv_flags == INT_MAIN)
578 pAdapter = dev->ml_priv;
582 pVirtualAd = dev->ml_priv;
583 if (pVirtualAd && pVirtualAd->RtmpDev)
584 pAdapter = pVirtualAd->RtmpDev->ml_priv;
587 if (pAdapter == NULL)
589 /* if 1st open fail, pAd will be free;
590 So the net_dev->ml_priv will be NULL in 2rd open */
594 ch = pAdapter->CommonCfg.Channel;
596 DBGPRINT(RT_DEBUG_TRACE,("==>rt_ioctl_giwfreq %d\n", ch));
598 MAP_CHANNEL_ID_TO_KHZ(ch, m);
604 int rt_ioctl_siwmode(struct net_device *dev,
605 struct iw_request_info *info,
606 __u32 *mode, char *extra)
608 PRTMP_ADAPTER pAdapter = dev->ml_priv;
610 //check if the interface is down
611 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
613 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
620 Set_NetworkType_Proc(pAdapter, "Adhoc");
623 Set_NetworkType_Proc(pAdapter, "Infra");
625 case IW_MODE_MONITOR:
626 Set_NetworkType_Proc(pAdapter, "Monitor");
629 DBGPRINT(RT_DEBUG_TRACE, ("===>rt_ioctl_siwmode::SIOCSIWMODE (unknown %d)\n", *mode));
633 // Reset Ralink supplicant to not use, it will be set to start when UI set PMK key
634 pAdapter->StaCfg.WpaState = SS_NOTUSE;
639 int rt_ioctl_giwmode(struct net_device *dev,
640 struct iw_request_info *info,
641 __u32 *mode, char *extra)
643 PRTMP_ADAPTER pAdapter = NULL;
644 VIRTUAL_ADAPTER *pVirtualAd = NULL;
646 if (dev->priv_flags == INT_MAIN)
648 pAdapter = dev->ml_priv;
652 pVirtualAd = dev->ml_priv;
653 if (pVirtualAd && pVirtualAd->RtmpDev)
654 pAdapter = pVirtualAd->RtmpDev->ml_priv;
657 if (pAdapter == NULL)
659 /* if 1st open fail, pAd will be free;
660 So the net_dev->ml_priv will be NULL in 2rd open */
664 if (ADHOC_ON(pAdapter))
665 *mode = IW_MODE_ADHOC;
666 else if (INFRA_ON(pAdapter))
667 *mode = IW_MODE_INFRA;
668 else if (MONITOR_ON(pAdapter))
670 *mode = IW_MODE_MONITOR;
673 *mode = IW_MODE_AUTO;
675 DBGPRINT(RT_DEBUG_TRACE, ("==>rt_ioctl_giwmode(mode=%d)\n", *mode));
679 int rt_ioctl_siwsens(struct net_device *dev,
680 struct iw_request_info *info,
681 char *name, char *extra)
683 PRTMP_ADAPTER pAdapter = dev->ml_priv;
685 //check if the interface is down
686 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
688 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
695 int rt_ioctl_giwsens(struct net_device *dev,
696 struct iw_request_info *info,
697 char *name, char *extra)
702 int rt_ioctl_giwrange(struct net_device *dev,
703 struct iw_request_info *info,
704 struct iw_point *data, char *extra)
706 PRTMP_ADAPTER pAdapter = NULL;
707 VIRTUAL_ADAPTER *pVirtualAd = NULL;
708 struct iw_range *range = (struct iw_range *) extra;
712 if (dev->priv_flags == INT_MAIN)
714 pAdapter = dev->ml_priv;
718 pVirtualAd = dev->ml_priv;
719 if (pVirtualAd && pVirtualAd->RtmpDev)
720 pAdapter = pVirtualAd->RtmpDev->ml_priv;
723 if (pAdapter == NULL)
725 /* if 1st open fail, pAd will be free;
726 So the net_dev->ml_priv will be NULL in 2rd open */
730 DBGPRINT(RT_DEBUG_TRACE ,("===>rt_ioctl_giwrange\n"));
731 data->length = sizeof(struct iw_range);
732 memset(range, 0, sizeof(struct iw_range));
734 range->txpower_capa = IW_TXPOW_DBM;
736 if (INFRA_ON(pAdapter)||ADHOC_ON(pAdapter))
738 range->min_pmp = 1 * 1024;
739 range->max_pmp = 65535 * 1024;
740 range->min_pmt = 1 * 1024;
741 range->max_pmt = 1000 * 1024;
742 range->pmp_flags = IW_POWER_PERIOD;
743 range->pmt_flags = IW_POWER_TIMEOUT;
744 range->pm_capa = IW_POWER_PERIOD | IW_POWER_TIMEOUT |
745 IW_POWER_UNICAST_R | IW_POWER_ALL_R;
748 range->we_version_compiled = WIRELESS_EXT;
749 range->we_version_source = 14;
751 range->retry_capa = IW_RETRY_LIMIT;
752 range->retry_flags = IW_RETRY_LIMIT;
753 range->min_retry = 0;
754 range->max_retry = 255;
756 range->num_channels = pAdapter->ChannelListNum;
759 for (i = 1; i <= range->num_channels; i++)
762 range->freq[val].i = pAdapter->ChannelList[i-1].Channel;
763 MAP_CHANNEL_ID_TO_KHZ(pAdapter->ChannelList[i-1].Channel, m);
764 range->freq[val].m = m * 100; /* HZ */
766 range->freq[val].e = 1;
768 if (val == IW_MAX_FREQUENCIES)
771 range->num_frequency = val;
773 range->max_qual.qual = 100; /* what is correct max? This was not
774 * documented exactly. At least
775 * 69 has been observed. */
776 range->max_qual.level = 0; /* dB */
777 range->max_qual.noise = 0; /* dB */
779 /* What would be suitable values for "average/typical" qual? */
780 range->avg_qual.qual = 20;
781 range->avg_qual.level = -60;
782 range->avg_qual.noise = -95;
783 range->sensitivity = 3;
785 range->max_encoding_tokens = NR_WEP_KEYS;
786 range->num_encoding_sizes = 2;
787 range->encoding_size[0] = 5;
788 range->encoding_size[1] = 13;
791 range->max_rts = 2347;
792 range->min_frag = 256;
793 range->max_frag = 2346;
795 #if WIRELESS_EXT > 17
796 /* IW_ENC_CAPA_* bit field */
797 range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 |
798 IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP;
804 int rt_ioctl_siwap(struct net_device *dev,
805 struct iw_request_info *info,
806 struct sockaddr *ap_addr, char *extra)
808 PRTMP_ADAPTER pAdapter = dev->ml_priv;
809 NDIS_802_11_MAC_ADDRESS Bssid;
811 //check if the interface is down
812 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
814 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
818 if (pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE)
820 RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
821 DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
824 // tell CNTL state machine to call NdisMSetInformationComplete() after completing
825 // this request, because this request is initiated by NDIS.
826 pAdapter->MlmeAux.CurrReqIsFromNdis = FALSE;
827 // Prevent to connect AP again in STAMlmePeriodicExec
828 pAdapter->MlmeAux.AutoReconnectSsidLen= 32;
830 memset(Bssid, 0, MAC_ADDR_LEN);
831 memcpy(Bssid, ap_addr->sa_data, MAC_ADDR_LEN);
832 MlmeEnqueue(pAdapter,
833 MLME_CNTL_STATE_MACHINE,
835 sizeof(NDIS_802_11_MAC_ADDRESS),
838 DBGPRINT(RT_DEBUG_TRACE, ("IOCTL::SIOCSIWAP %02x:%02x:%02x:%02x:%02x:%02x\n",
839 Bssid[0], Bssid[1], Bssid[2], Bssid[3], Bssid[4], Bssid[5]));
844 int rt_ioctl_giwap(struct net_device *dev,
845 struct iw_request_info *info,
846 struct sockaddr *ap_addr, char *extra)
848 PRTMP_ADAPTER pAdapter = NULL;
849 VIRTUAL_ADAPTER *pVirtualAd = NULL;
851 if (dev->priv_flags == INT_MAIN)
853 pAdapter = dev->ml_priv;
857 pVirtualAd = dev->ml_priv;
858 if (pVirtualAd && pVirtualAd->RtmpDev)
859 pAdapter = pVirtualAd->RtmpDev->ml_priv;
862 if (pAdapter == NULL)
864 /* if 1st open fail, pAd will be free;
865 So the net_dev->ml_priv will be NULL in 2rd open */
869 if (INFRA_ON(pAdapter) || ADHOC_ON(pAdapter))
871 ap_addr->sa_family = ARPHRD_ETHER;
872 memcpy(ap_addr->sa_data, &pAdapter->CommonCfg.Bssid, ETH_ALEN);
874 #ifdef WPA_SUPPLICANT_SUPPORT
876 else if (pAdapter->StaCfg.WpaSupplicantUP != WPA_SUPPLICANT_DISABLE)
878 ap_addr->sa_family = ARPHRD_ETHER;
879 memcpy(ap_addr->sa_data, &pAdapter->MlmeAux.Bssid, ETH_ALEN);
881 #endif // WPA_SUPPLICANT_SUPPORT //
884 DBGPRINT(RT_DEBUG_TRACE, ("IOCTL::SIOCGIWAP(=EMPTY)\n"));
892 * Units are in db above the noise floor. That means the
893 * rssi values reported in the tx/rx descriptors in the
894 * driver are the SNR expressed in db.
896 * If you assume that the noise floor is -95, which is an
897 * excellent assumption 99.5 % of the time, then you can
898 * derive the absolute signal level (i.e. -95 + rssi).
899 * There are some other slight factors to take into account
900 * depending on whether the rssi measurement is from 11b,
901 * 11g, or 11a. These differences are at most 2db and
904 * NB: various calculations are based on the orinoco/wavelan
905 * drivers for compatibility
907 static void set_quality(PRTMP_ADAPTER pAdapter,
908 struct iw_quality *iq,
915 ChannelQuality = 100;
916 else if (rssi >= -80) // between -50 ~ -80dbm
917 ChannelQuality = (__u8)(24 + ((rssi + 80) * 26)/10);
918 else if (rssi >= -90) // between -80 ~ -90dbm
919 ChannelQuality = (__u8)((rssi + 90) * 26)/10;
923 iq->qual = (__u8)ChannelQuality;
925 iq->level = (__u8)(rssi);
926 iq->noise = (pAdapter->BbpWriteLatch[66] > pAdapter->BbpTuning.FalseCcaUpperThreshold) ? ((__u8)pAdapter->BbpTuning.FalseCcaUpperThreshold) : ((__u8) pAdapter->BbpWriteLatch[66]); // noise level (dBm)
927 iq->noise += 256 - 143;
928 iq->updated = pAdapter->iw_stats.qual.updated;
931 int rt_ioctl_iwaplist(struct net_device *dev,
932 struct iw_request_info *info,
933 struct iw_point *data, char *extra)
935 PRTMP_ADAPTER pAdapter = dev->ml_priv;
937 struct sockaddr addr[IW_MAX_AP];
938 struct iw_quality qual[IW_MAX_AP];
941 //check if the interface is down
942 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
944 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
950 for (i = 0; i <IW_MAX_AP ; i++)
952 if (i >= pAdapter->ScanTab.BssNr)
954 addr[i].sa_family = ARPHRD_ETHER;
955 memcpy(addr[i].sa_data, &pAdapter->ScanTab.BssEntry[i].Bssid, MAC_ADDR_LEN);
956 set_quality(pAdapter, &qual[i], pAdapter->ScanTab.BssEntry[i].Rssi);
959 memcpy(extra, &addr, i*sizeof(addr[0]));
960 data->flags = 1; /* signal quality present (sort of) */
961 memcpy(extra + i*sizeof(addr[0]), &qual, i*sizeof(qual[i]));
967 int rt_ioctl_siwscan(struct net_device *dev,
968 struct iw_request_info *info,
969 struct iw_point *data, char *extra)
971 PRTMP_ADAPTER pAdapter = dev->ml_priv;
974 int Status = NDIS_STATUS_SUCCESS;
976 //check if the interface is down
977 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
979 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
983 if (MONITOR_ON(pAdapter))
985 DBGPRINT(RT_DEBUG_TRACE, ("!!! Driver is in Monitor Mode now !!!\n"));
990 #ifdef WPA_SUPPLICANT_SUPPORT
991 if (pAdapter->StaCfg.WpaSupplicantUP == WPA_SUPPLICANT_ENABLE)
993 pAdapter->StaCfg.WpaSupplicantScanCount++;
995 #endif // WPA_SUPPLICANT_SUPPORT //
997 pAdapter->StaCfg.bScanReqIsFromWebUI = TRUE;
998 if (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
1003 #ifdef WPA_SUPPLICANT_SUPPORT
1004 if ((pAdapter->StaCfg.WpaSupplicantUP == WPA_SUPPLICANT_ENABLE) &&
1005 (pAdapter->StaCfg.WpaSupplicantScanCount > 3))
1007 DBGPRINT(RT_DEBUG_TRACE, ("!!! WpaSupplicantScanCount > 3\n"));
1008 Status = NDIS_STATUS_SUCCESS;
1011 #endif // WPA_SUPPLICANT_SUPPORT //
1013 if ((OPSTATUS_TEST_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED)) &&
1014 ((pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA) ||
1015 (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK)) &&
1016 (pAdapter->StaCfg.PortSecured == WPA_802_1X_PORT_NOT_SECURED))
1018 DBGPRINT(RT_DEBUG_TRACE, ("!!! Link UP, Port Not Secured! ignore this set::OID_802_11_BSSID_LIST_SCAN\n"));
1019 Status = NDIS_STATUS_SUCCESS;
1023 if (pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE)
1025 RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
1026 DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
1029 // tell CNTL state machine to call NdisMSetInformationComplete() after completing
1030 // this request, because this request is initiated by NDIS.
1031 pAdapter->MlmeAux.CurrReqIsFromNdis = FALSE;
1032 // Reset allowed scan retries
1033 pAdapter->StaCfg.ScanCnt = 0;
1034 pAdapter->StaCfg.LastScanTime = Now;
1036 MlmeEnqueue(pAdapter,
1037 MLME_CNTL_STATE_MACHINE,
1038 OID_802_11_BSSID_LIST_SCAN,
1042 Status = NDIS_STATUS_SUCCESS;
1043 RT28XX_MLME_HANDLER(pAdapter);
1048 int rt_ioctl_giwscan(struct net_device *dev,
1049 struct iw_request_info *info,
1050 struct iw_point *data, char *extra)
1053 PRTMP_ADAPTER pAdapter = dev->ml_priv;
1055 char *current_ev = extra, *previous_ev = extra;
1057 char *current_val, custom[MAX_CUSTOM_LEN] = {0};
1060 #endif // IWEVGENIE //
1061 struct iw_event iwe;
1063 if (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
1066 * Still scanning, indicate the caller should try again.
1072 #ifdef WPA_SUPPLICANT_SUPPORT
1073 if (pAdapter->StaCfg.WpaSupplicantUP == WPA_SUPPLICANT_ENABLE)
1075 pAdapter->StaCfg.WpaSupplicantScanCount = 0;
1077 #endif // WPA_SUPPLICANT_SUPPORT //
1079 if (pAdapter->ScanTab.BssNr == 0)
1085 #if WIRELESS_EXT >= 17
1086 if (data->length > 0)
1087 end_buf = extra + data->length;
1089 end_buf = extra + IW_SCAN_MAX_DATA;
1091 end_buf = extra + IW_SCAN_MAX_DATA;
1094 for (i = 0; i < pAdapter->ScanTab.BssNr; i++)
1096 if (current_ev >= end_buf)
1098 #if WIRELESS_EXT >= 17
1106 //================================
1107 memset(&iwe, 0, sizeof(iwe));
1108 iwe.cmd = SIOCGIWAP;
1109 iwe.u.ap_addr.sa_family = ARPHRD_ETHER;
1110 memcpy(iwe.u.ap_addr.sa_data, &pAdapter->ScanTab.BssEntry[i].Bssid, ETH_ALEN);
1112 previous_ev = current_ev;
1113 current_ev = iwe_stream_add_event(info, current_ev,end_buf, &iwe, IW_EV_ADDR_LEN);
1114 if (current_ev == previous_ev)
1115 #if WIRELESS_EXT >= 17
1122 //================================
1123 memset(&iwe, 0, sizeof(iwe));
1124 iwe.cmd = SIOCGIWESSID;
1125 iwe.u.data.length = pAdapter->ScanTab.BssEntry[i].SsidLen;
1126 iwe.u.data.flags = 1;
1128 previous_ev = current_ev;
1129 current_ev = iwe_stream_add_point(info, current_ev,end_buf, &iwe, pAdapter->ScanTab.BssEntry[i].Ssid);
1130 if (current_ev == previous_ev)
1131 #if WIRELESS_EXT >= 17
1138 //================================
1139 memset(&iwe, 0, sizeof(iwe));
1140 iwe.cmd = SIOCGIWMODE;
1141 if (pAdapter->ScanTab.BssEntry[i].BssType == Ndis802_11IBSS)
1143 iwe.u.mode = IW_MODE_ADHOC;
1145 else if (pAdapter->ScanTab.BssEntry[i].BssType == Ndis802_11Infrastructure)
1147 iwe.u.mode = IW_MODE_INFRA;
1151 iwe.u.mode = IW_MODE_AUTO;
1153 iwe.len = IW_EV_UINT_LEN;
1155 previous_ev = current_ev;
1156 current_ev = iwe_stream_add_event(info, current_ev, end_buf, &iwe, IW_EV_UINT_LEN);
1157 if (current_ev == previous_ev)
1158 #if WIRELESS_EXT >= 17
1164 //Channel and Frequency
1165 //================================
1166 memset(&iwe, 0, sizeof(iwe));
1167 iwe.cmd = SIOCGIWFREQ;
1168 if (INFRA_ON(pAdapter) || ADHOC_ON(pAdapter))
1169 iwe.u.freq.m = pAdapter->ScanTab.BssEntry[i].Channel;
1171 iwe.u.freq.m = pAdapter->ScanTab.BssEntry[i].Channel;
1175 previous_ev = current_ev;
1176 current_ev = iwe_stream_add_event(info, current_ev, end_buf, &iwe, IW_EV_FREQ_LEN);
1177 if (current_ev == previous_ev)
1178 #if WIRELESS_EXT >= 17
1184 //Add quality statistics
1185 //================================
1186 memset(&iwe, 0, sizeof(iwe));
1188 iwe.u.qual.level = 0;
1189 iwe.u.qual.noise = 0;
1190 set_quality(pAdapter, &iwe.u.qual, pAdapter->ScanTab.BssEntry[i].Rssi);
1191 current_ev = iwe_stream_add_event(info, current_ev, end_buf, &iwe, IW_EV_QUAL_LEN);
1192 if (current_ev == previous_ev)
1193 #if WIRELESS_EXT >= 17
1200 //================================
1201 memset(&iwe, 0, sizeof(iwe));
1202 iwe.cmd = SIOCGIWENCODE;
1203 if (CAP_IS_PRIVACY_ON (pAdapter->ScanTab.BssEntry[i].CapabilityInfo ))
1204 iwe.u.data.flags =IW_ENCODE_ENABLED | IW_ENCODE_NOKEY;
1206 iwe.u.data.flags = IW_ENCODE_DISABLED;
1208 previous_ev = current_ev;
1209 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);
1210 if (current_ev == previous_ev)
1211 #if WIRELESS_EXT >= 17
1218 //================================
1219 if (pAdapter->ScanTab.BssEntry[i].SupRateLen)
1221 UCHAR tmpRate = pAdapter->ScanTab.BssEntry[i].SupRate[pAdapter->ScanTab.BssEntry[i].SupRateLen-1];
1222 memset(&iwe, 0, sizeof(iwe));
1223 iwe.cmd = SIOCGIWRATE;
1224 current_val = current_ev + IW_EV_LCP_LEN;
1225 if (tmpRate == 0x82)
1226 iwe.u.bitrate.value = 1 * 1000000;
1227 else if (tmpRate == 0x84)
1228 iwe.u.bitrate.value = 2 * 1000000;
1229 else if (tmpRate == 0x8B)
1230 iwe.u.bitrate.value = 5.5 * 1000000;
1231 else if (tmpRate == 0x96)
1232 iwe.u.bitrate.value = 11 * 1000000;
1234 iwe.u.bitrate.value = (tmpRate/2) * 1000000;
1236 iwe.u.bitrate.disabled = 0;
1237 current_val = iwe_stream_add_value(info, current_ev,
1238 current_val, end_buf, &iwe,
1241 if((current_val-current_ev)>IW_EV_LCP_LEN)
1242 current_ev = current_val;
1244 #if WIRELESS_EXT >= 17
1253 if (pAdapter->ScanTab.BssEntry[i].WpaIE.IELen > 0)
1255 memset(&iwe, 0, sizeof(iwe));
1256 memset(&custom[0], 0, MAX_CUSTOM_LEN);
1257 memcpy(custom, &(pAdapter->ScanTab.BssEntry[i].WpaIE.IE[0]),
1258 pAdapter->ScanTab.BssEntry[i].WpaIE.IELen);
1259 iwe.cmd = IWEVGENIE;
1260 iwe.u.data.length = pAdapter->ScanTab.BssEntry[i].WpaIE.IELen;
1261 current_ev = iwe_stream_add_point(info, current_ev, end_buf, &iwe, custom);
1262 if (current_ev == previous_ev)
1263 #if WIRELESS_EXT >= 17
1271 if (pAdapter->ScanTab.BssEntry[i].RsnIE.IELen > 0)
1273 memset(&iwe, 0, sizeof(iwe));
1274 memset(&custom[0], 0, MAX_CUSTOM_LEN);
1275 memcpy(custom, &(pAdapter->ScanTab.BssEntry[i].RsnIE.IE[0]),
1276 pAdapter->ScanTab.BssEntry[i].RsnIE.IELen);
1277 iwe.cmd = IWEVGENIE;
1278 iwe.u.data.length = pAdapter->ScanTab.BssEntry[i].RsnIE.IELen;
1279 current_ev = iwe_stream_add_point(info, current_ev, end_buf, &iwe, custom);
1280 if (current_ev == previous_ev)
1281 #if WIRELESS_EXT >= 17
1289 //================================
1290 if (pAdapter->ScanTab.BssEntry[i].WpaIE.IELen > 0)
1292 NdisZeroMemory(&iwe, sizeof(iwe));
1293 memset(&custom[0], 0, MAX_CUSTOM_LEN);
1294 iwe.cmd = IWEVCUSTOM;
1295 iwe.u.data.length = (pAdapter->ScanTab.BssEntry[i].WpaIE.IELen * 2) + 7;
1296 NdisMoveMemory(custom, "wpa_ie=", 7);
1297 for (idx = 0; idx < pAdapter->ScanTab.BssEntry[i].WpaIE.IELen; idx++)
1298 sprintf(custom + strlen(custom), "%02x", pAdapter->ScanTab.BssEntry[i].WpaIE.IE[idx]);
1299 previous_ev = current_ev;
1300 current_ev = iwe_stream_add_point(current_ev, end_buf, &iwe, custom);
1301 if (current_ev == previous_ev)
1302 #if WIRELESS_EXT >= 17
1310 if (pAdapter->ScanTab.BssEntry[i].RsnIE.IELen > 0)
1312 NdisZeroMemory(&iwe, sizeof(iwe));
1313 memset(&custom[0], 0, MAX_CUSTOM_LEN);
1314 iwe.cmd = IWEVCUSTOM;
1315 iwe.u.data.length = (pAdapter->ScanTab.BssEntry[i].RsnIE.IELen * 2) + 7;
1316 NdisMoveMemory(custom, "rsn_ie=", 7);
1317 for (idx = 0; idx < pAdapter->ScanTab.BssEntry[i].RsnIE.IELen; idx++)
1318 sprintf(custom + strlen(custom), "%02x", pAdapter->ScanTab.BssEntry[i].RsnIE.IE[idx]);
1319 previous_ev = current_ev;
1320 current_ev = iwe_stream_add_point(current_ev, end_buf, &iwe, custom);
1321 if (current_ev == previous_ev)
1322 #if WIRELESS_EXT >= 17
1328 #endif // IWEVGENIE //
1331 data->length = current_ev - extra;
1332 pAdapter->StaCfg.bScanReqIsFromWebUI = FALSE;
1333 DBGPRINT(RT_DEBUG_ERROR ,("===>rt_ioctl_giwscan. %d(%d) BSS returned, data->length = %d\n",i , pAdapter->ScanTab.BssNr, data->length));
1338 int rt_ioctl_siwessid(struct net_device *dev,
1339 struct iw_request_info *info,
1340 struct iw_point *data, char *essid)
1342 PRTMP_ADAPTER pAdapter = dev->ml_priv;
1344 //check if the interface is down
1345 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1347 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1353 PCHAR pSsidString = NULL;
1355 // Includes null character.
1356 if (data->length > (IW_ESSID_MAX_SIZE + 1))
1359 pSsidString = (CHAR *) kmalloc(MAX_LEN_OF_SSID+1, MEM_ALLOC_FLAG);
1362 NdisZeroMemory(pSsidString, MAX_LEN_OF_SSID+1);
1363 NdisMoveMemory(pSsidString, essid, data->length);
1364 if (Set_SSID_Proc(pAdapter, pSsidString) == FALSE)
1373 if (Set_SSID_Proc(pAdapter, "") == FALSE)
1379 int rt_ioctl_giwessid(struct net_device *dev,
1380 struct iw_request_info *info,
1381 struct iw_point *data, char *essid)
1383 PRTMP_ADAPTER pAdapter = NULL;
1384 VIRTUAL_ADAPTER *pVirtualAd = NULL;
1386 if (dev->priv_flags == INT_MAIN)
1388 pAdapter = dev->ml_priv;
1392 pVirtualAd = dev->ml_priv;
1393 if (pVirtualAd && pVirtualAd->RtmpDev)
1394 pAdapter = pVirtualAd->RtmpDev->ml_priv;
1397 if (pAdapter == NULL)
1399 /* if 1st open fail, pAd will be free;
1400 So the net_dev->ml_priv will be NULL in 2rd open */
1405 if (MONITOR_ON(pAdapter))
1411 if (OPSTATUS_TEST_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED))
1413 DBGPRINT(RT_DEBUG_TRACE ,("MediaState is connected\n"));
1414 data->length = pAdapter->CommonCfg.SsidLen;
1415 memcpy(essid, pAdapter->CommonCfg.Ssid, pAdapter->CommonCfg.SsidLen);
1418 #ifdef WPA_SUPPLICANT_SUPPORT
1420 else if (pAdapter->StaCfg.WpaSupplicantUP != WPA_SUPPLICANT_DISABLE)
1422 data->length = pAdapter->CommonCfg.SsidLen;
1423 memcpy(essid, pAdapter->CommonCfg.Ssid, pAdapter->CommonCfg.SsidLen);
1425 #endif // WPA_SUPPLICANT_SUPPORT //
1428 {//the ANY ssid was specified
1430 DBGPRINT(RT_DEBUG_TRACE ,("MediaState is not connected, ess\n"));
1437 int rt_ioctl_siwnickn(struct net_device *dev,
1438 struct iw_request_info *info,
1439 struct iw_point *data, char *nickname)
1441 PRTMP_ADAPTER pAdapter = dev->ml_priv;
1443 //check if the interface is down
1444 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1446 DBGPRINT(RT_DEBUG_TRACE ,("INFO::Network is down!\n"));
1450 if (data->length > IW_ESSID_MAX_SIZE)
1453 memset(pAdapter->nickname, 0, IW_ESSID_MAX_SIZE + 1);
1454 memcpy(pAdapter->nickname, nickname, data->length);
1460 int rt_ioctl_giwnickn(struct net_device *dev,
1461 struct iw_request_info *info,
1462 struct iw_point *data, char *nickname)
1464 PRTMP_ADAPTER pAdapter = NULL;
1465 VIRTUAL_ADAPTER *pVirtualAd = NULL;
1467 if (dev->priv_flags == INT_MAIN)
1469 pAdapter = dev->ml_priv;
1473 pVirtualAd = dev->ml_priv;
1474 if (pVirtualAd && pVirtualAd->RtmpDev)
1475 pAdapter = pVirtualAd->RtmpDev->ml_priv;
1478 if (pAdapter == NULL)
1480 /* if 1st open fail, pAd will be free;
1481 So the net_dev->ml_priv will be NULL in 2rd open */
1485 if (data->length > strlen(pAdapter->nickname) + 1)
1486 data->length = strlen(pAdapter->nickname) + 1;
1487 if (data->length > 0) {
1488 memcpy(nickname, pAdapter->nickname, data->length-1);
1489 nickname[data->length-1] = '\0';
1494 int rt_ioctl_siwrts(struct net_device *dev,
1495 struct iw_request_info *info,
1496 struct iw_param *rts, char *extra)
1498 PRTMP_ADAPTER pAdapter = dev->ml_priv;
1501 //check if the interface is down
1502 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1504 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1509 val = MAX_RTS_THRESHOLD;
1510 else if (rts->value < 0 || rts->value > MAX_RTS_THRESHOLD)
1512 else if (rts->value == 0)
1513 val = MAX_RTS_THRESHOLD;
1517 if (val != pAdapter->CommonCfg.RtsThreshold)
1518 pAdapter->CommonCfg.RtsThreshold = val;
1523 int rt_ioctl_giwrts(struct net_device *dev,
1524 struct iw_request_info *info,
1525 struct iw_param *rts, char *extra)
1527 PRTMP_ADAPTER pAdapter = NULL;
1528 VIRTUAL_ADAPTER *pVirtualAd = NULL;
1530 if (dev->priv_flags == INT_MAIN)
1532 pAdapter = dev->ml_priv;
1536 pVirtualAd = dev->ml_priv;
1537 if (pVirtualAd && pVirtualAd->RtmpDev)
1538 pAdapter = pVirtualAd->RtmpDev->ml_priv;
1541 if (pAdapter == NULL)
1543 /* if 1st open fail, pAd will be free;
1544 So the net_dev->ml_priv will be NULL in 2rd open */
1548 //check if the interface is down
1549 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1551 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1555 rts->value = pAdapter->CommonCfg.RtsThreshold;
1556 rts->disabled = (rts->value == MAX_RTS_THRESHOLD);
1562 int rt_ioctl_siwfrag(struct net_device *dev,
1563 struct iw_request_info *info,
1564 struct iw_param *frag, char *extra)
1566 PRTMP_ADAPTER pAdapter = dev->ml_priv;
1569 //check if the interface is down
1570 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1572 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1577 val = MAX_FRAG_THRESHOLD;
1578 else if (frag->value >= MIN_FRAG_THRESHOLD || frag->value <= MAX_FRAG_THRESHOLD)
1579 val = __cpu_to_le16(frag->value & ~0x1); /* even numbers only */
1580 else if (frag->value == 0)
1581 val = MAX_FRAG_THRESHOLD;
1585 pAdapter->CommonCfg.FragmentThreshold = val;
1589 int rt_ioctl_giwfrag(struct net_device *dev,
1590 struct iw_request_info *info,
1591 struct iw_param *frag, char *extra)
1593 PRTMP_ADAPTER pAdapter = NULL;
1594 VIRTUAL_ADAPTER *pVirtualAd = NULL;
1596 if (dev->priv_flags == INT_MAIN)
1598 pAdapter = dev->ml_priv;
1602 pVirtualAd = dev->ml_priv;
1603 if (pVirtualAd && pVirtualAd->RtmpDev)
1604 pAdapter = pVirtualAd->RtmpDev->ml_priv;
1607 if (pAdapter == NULL)
1609 /* if 1st open fail, pAd will be free;
1610 So the net_dev->ml_priv will be NULL in 2rd open */
1614 //check if the interface is down
1615 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1617 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1621 frag->value = pAdapter->CommonCfg.FragmentThreshold;
1622 frag->disabled = (frag->value == MAX_FRAG_THRESHOLD);
1628 #define MAX_WEP_KEY_SIZE 13
1629 #define MIN_WEP_KEY_SIZE 5
1630 int rt_ioctl_siwencode(struct net_device *dev,
1631 struct iw_request_info *info,
1632 struct iw_point *erq, char *extra)
1634 PRTMP_ADAPTER pAdapter = dev->ml_priv;
1636 //check if the interface is down
1637 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1639 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1643 if ((erq->length == 0) &&
1644 (erq->flags & IW_ENCODE_DISABLED))
1646 pAdapter->StaCfg.PairCipher = Ndis802_11WEPDisabled;
1647 pAdapter->StaCfg.GroupCipher = Ndis802_11WEPDisabled;
1648 pAdapter->StaCfg.WepStatus = Ndis802_11WEPDisabled;
1649 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
1650 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
1653 else if ((erq->length == 0) &&
1654 (erq->flags & IW_ENCODE_RESTRICTED || erq->flags & IW_ENCODE_OPEN))
1656 //pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
1657 STA_PORT_SECURED(pAdapter);
1658 pAdapter->StaCfg.PairCipher = Ndis802_11WEPEnabled;
1659 pAdapter->StaCfg.GroupCipher = Ndis802_11WEPEnabled;
1660 pAdapter->StaCfg.WepStatus = Ndis802_11WEPEnabled;
1661 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
1662 if (erq->flags & IW_ENCODE_RESTRICTED)
1663 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeShared;
1665 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
1669 if (erq->length > 0)
1671 int keyIdx = (erq->flags & IW_ENCODE_INDEX) - 1;
1672 /* Check the size of the key */
1673 if (erq->length > MAX_WEP_KEY_SIZE) {
1676 /* Check key index */
1677 if ((keyIdx < 0) || (keyIdx >= NR_WEP_KEYS))
1679 DBGPRINT(RT_DEBUG_TRACE ,("==>rt_ioctl_siwencode::Wrong keyIdx=%d! Using default key instead (%d)\n",
1680 keyIdx, pAdapter->StaCfg.DefaultKeyId));
1683 keyIdx = pAdapter->StaCfg.DefaultKeyId;
1686 NdisZeroMemory(pAdapter->SharedKey[BSS0][keyIdx].Key, 16);
1688 if (erq->length == MAX_WEP_KEY_SIZE)
1690 pAdapter->SharedKey[BSS0][keyIdx].KeyLen = MAX_WEP_KEY_SIZE;
1691 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CIPHER_WEP128;
1693 else if (erq->length == MIN_WEP_KEY_SIZE)
1695 pAdapter->SharedKey[BSS0][keyIdx].KeyLen = MIN_WEP_KEY_SIZE;
1696 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CIPHER_WEP64;
1699 /* Disable the key */
1700 pAdapter->SharedKey[BSS0][keyIdx].KeyLen = 0;
1702 /* Check if the key is not marked as invalid */
1703 if(!(erq->flags & IW_ENCODE_NOKEY)) {
1704 /* Copy the key in the driver */
1705 NdisMoveMemory(pAdapter->SharedKey[BSS0][keyIdx].Key, extra, erq->length);
1710 /* Do we want to just set the transmit key index ? */
1711 int index = (erq->flags & IW_ENCODE_INDEX) - 1;
1712 if ((index >= 0) && (index < 4))
1714 pAdapter->StaCfg.DefaultKeyId = index;
1717 /* Don't complain if only change the mode */
1718 if (!(erq->flags & IW_ENCODE_MODE)) {
1724 DBGPRINT(RT_DEBUG_TRACE ,("==>rt_ioctl_siwencode::erq->flags=%x\n",erq->flags));
1725 DBGPRINT(RT_DEBUG_TRACE ,("==>rt_ioctl_siwencode::AuthMode=%x\n",pAdapter->StaCfg.AuthMode));
1726 DBGPRINT(RT_DEBUG_TRACE ,("==>rt_ioctl_siwencode::DefaultKeyId=%x, KeyLen = %d\n",pAdapter->StaCfg.DefaultKeyId , pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].KeyLen));
1727 DBGPRINT(RT_DEBUG_TRACE ,("==>rt_ioctl_siwencode::WepStatus=%x\n",pAdapter->StaCfg.WepStatus));
1732 rt_ioctl_giwencode(struct net_device *dev,
1733 struct iw_request_info *info,
1734 struct iw_point *erq, char *key)
1737 PRTMP_ADAPTER pAdapter = NULL;
1738 VIRTUAL_ADAPTER *pVirtualAd = NULL;
1740 if (dev->priv_flags == INT_MAIN)
1742 pAdapter = dev->ml_priv;
1746 pVirtualAd = dev->ml_priv;
1747 if (pVirtualAd && pVirtualAd->RtmpDev)
1748 pAdapter = pVirtualAd->RtmpDev->ml_priv;
1751 if (pAdapter == NULL)
1753 /* if 1st open fail, pAd will be free;
1754 So the net_dev->ml_priv will be NULL in 2rd open */
1758 //check if the interface is down
1759 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1761 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1765 kid = erq->flags & IW_ENCODE_INDEX;
1766 DBGPRINT(RT_DEBUG_TRACE, ("===>rt_ioctl_giwencode %d\n", erq->flags & IW_ENCODE_INDEX));
1768 if (pAdapter->StaCfg.WepStatus == Ndis802_11WEPDisabled)
1771 erq->flags = IW_ENCODE_DISABLED;
1773 else if ((kid > 0) && (kid <=4))
1776 erq->flags = kid ; /* NB: base 1 */
1777 if (erq->length > pAdapter->SharedKey[BSS0][kid-1].KeyLen)
1778 erq->length = pAdapter->SharedKey[BSS0][kid-1].KeyLen;
1779 memcpy(key, pAdapter->SharedKey[BSS0][kid-1].Key, erq->length);
1780 //if ((kid == pAdapter->PortCfg.DefaultKeyId))
1781 //erq->flags |= IW_ENCODE_ENABLED; /* XXX */
1782 if (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeShared)
1783 erq->flags |= IW_ENCODE_RESTRICTED; /* XXX */
1785 erq->flags |= IW_ENCODE_OPEN; /* XXX */
1790 if (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeShared)
1791 erq->flags |= IW_ENCODE_RESTRICTED; /* XXX */
1793 erq->flags |= IW_ENCODE_OPEN; /* XXX */
1794 erq->length = pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].KeyLen;
1795 memcpy(key, pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].Key, erq->length);
1796 // copy default key ID
1797 if (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeShared)
1798 erq->flags |= IW_ENCODE_RESTRICTED; /* XXX */
1800 erq->flags |= IW_ENCODE_OPEN; /* XXX */
1801 erq->flags = pAdapter->StaCfg.DefaultKeyId + 1; /* NB: base 1 */
1802 erq->flags |= IW_ENCODE_ENABLED; /* XXX */
1810 rt_ioctl_setparam(struct net_device *dev, struct iw_request_info *info,
1811 void *w, char *extra)
1813 VIRTUAL_ADAPTER *pVirtualAd = NULL;
1814 PRTMP_ADAPTER pAdapter;
1816 char *this_char = extra;
1820 if (dev->priv_flags == INT_MAIN)
1822 pAdapter = dev->ml_priv;
1826 pVirtualAd = dev->ml_priv;
1827 pAdapter = pVirtualAd->RtmpDev->ml_priv;
1829 pObj = (POS_COOKIE) pAdapter->OS_Cookie;
1831 if (pAdapter == NULL)
1833 /* if 1st open fail, pAd will be free;
1834 So the net_dev->ml_priv will be NULL in 2rd open */
1839 pObj->ioctl_if_type = INT_MAIN;
1840 pObj->ioctl_if = MAIN_MBSSID;
1843 //check if the interface is down
1844 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1846 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1853 if ((value = rtstrchr(this_char, '=')) != NULL)
1859 // reject setting nothing besides ANY ssid(ssidLen=0)
1860 if (!*value && (strcmp(this_char, "SSID") != 0))
1863 for (PRTMP_PRIVATE_SET_PROC = RTMP_PRIVATE_SUPPORT_PROC; PRTMP_PRIVATE_SET_PROC->name; PRTMP_PRIVATE_SET_PROC++)
1865 if (strcmp(this_char, PRTMP_PRIVATE_SET_PROC->name) == 0)
1867 if(!PRTMP_PRIVATE_SET_PROC->set_proc(pAdapter, value))
1868 { //FALSE:Set private failed then return Invalid argument
1871 break; //Exit for loop.
1875 if(PRTMP_PRIVATE_SET_PROC->name == NULL)
1876 { //Not found argument
1878 DBGPRINT(RT_DEBUG_TRACE, ("===>rt_ioctl_setparam:: (iwpriv) Not Support Set Command [%s=%s]\n", this_char, value));
1886 rt_private_get_statistics(struct net_device *dev, struct iw_request_info *info,
1887 struct iw_point *wrq, char *extra)
1890 PRTMP_ADAPTER pAd = dev->ml_priv;
1898 memset(extra, 0x00, IW_PRIV_SIZE_MASK);
1899 sprintf(extra, "\n\n");
1902 sprintf(extra+strlen(extra), "Tx success = %ld\n", (ULONG)pAd->WlanCounters.TransmittedFragmentCount.QuadPart);
1903 sprintf(extra+strlen(extra), "Tx success without retry = %ld\n", (ULONG)pAd->WlanCounters.TransmittedFragmentCount.QuadPart - (ULONG)pAd->WlanCounters.RetryCount.QuadPart);
1905 sprintf(extra+strlen(extra), "Tx success after retry = %ld\n", (ULONG)pAd->WlanCounters.RetryCount.QuadPart);
1906 sprintf(extra+strlen(extra), "Tx fail to Rcv ACK after retry = %ld\n", (ULONG)pAd->WlanCounters.FailedCount.QuadPart);
1907 sprintf(extra+strlen(extra), "RTS Success Rcv CTS = %ld\n", (ULONG)pAd->WlanCounters.RTSSuccessCount.QuadPart);
1908 sprintf(extra+strlen(extra), "RTS Fail Rcv CTS = %ld\n", (ULONG)pAd->WlanCounters.RTSFailureCount.QuadPart);
1910 sprintf(extra+strlen(extra), "Rx success = %ld\n", (ULONG)pAd->WlanCounters.ReceivedFragmentCount.QuadPart);
1911 sprintf(extra+strlen(extra), "Rx with CRC = %ld\n", (ULONG)pAd->WlanCounters.FCSErrorCount.QuadPart);
1912 sprintf(extra+strlen(extra), "Rx drop due to out of resource = %ld\n", (ULONG)pAd->Counters8023.RxNoBuffer);
1913 sprintf(extra+strlen(extra), "Rx duplicate frame = %ld\n", (ULONG)pAd->WlanCounters.FrameDuplicateCount.QuadPart);
1915 sprintf(extra+strlen(extra), "False CCA (one second) = %ld\n", (ULONG)pAd->RalinkCounters.OneSecFalseCCACnt);
1917 sprintf(extra+strlen(extra), "RSSI-A = %ld\n", (LONG)(pAd->StaCfg.RssiSample.LastRssi0 - pAd->BbpRssiToDbmDelta));
1918 sprintf(extra+strlen(extra), "RSSI-B (if available) = %ld\n", (LONG)(pAd->StaCfg.RssiSample.LastRssi1 - pAd->BbpRssiToDbmDelta));
1919 sprintf(extra+strlen(extra), "RSSI-C (if available) = %ld\n\n", (LONG)(pAd->StaCfg.RssiSample.LastRssi2 - pAd->BbpRssiToDbmDelta));
1921 #ifdef WPA_SUPPLICANT_SUPPORT
1922 sprintf(extra+strlen(extra), "WpaSupplicantUP = %d\n\n", pAd->StaCfg.WpaSupplicantUP);
1923 #endif // WPA_SUPPLICANT_SUPPORT //
1926 wrq->length = strlen(extra) + 1; // 1: size of '\0'
1927 DBGPRINT(RT_DEBUG_TRACE, ("<== rt_private_get_statistics, wrq->length = %d\n", wrq->length));
1932 #ifdef DOT11_N_SUPPORT
1934 IN PRTMP_ADAPTER pAd,
1938 BA_ORI_ENTRY *pOriBAEntry;
1939 BA_REC_ENTRY *pRecBAEntry;
1941 for (i=0; i<MAX_LEN_OF_MAC_TABLE; i++)
1943 PMAC_TABLE_ENTRY pEntry = &pAd->MacTab.Content[i];
1944 if (((pEntry->ValidAsCLI || pEntry->ValidAsApCli) && (pEntry->Sst == SST_ASSOC))
1945 || (pEntry->ValidAsWDS) || (pEntry->ValidAsMesh))
1947 sprintf(pOutBuf + strlen(pOutBuf), "\n%02X:%02X:%02X:%02X:%02X:%02X (Aid = %d) (AP) -\n",
1948 pEntry->Addr[0], pEntry->Addr[1], pEntry->Addr[2],
1949 pEntry->Addr[3], pEntry->Addr[4], pEntry->Addr[5], pEntry->Aid);
1951 sprintf(pOutBuf, "%s[Recipient]\n", pOutBuf);
1952 for (j=0; j < NUM_OF_TID; j++)
1954 if (pEntry->BARecWcidArray[j] != 0)
1956 pRecBAEntry =&pAd->BATable.BARecEntry[pEntry->BARecWcidArray[j]];
1957 sprintf(pOutBuf + strlen(pOutBuf), "TID=%d, BAWinSize=%d, LastIndSeq=%d, ReorderingPkts=%d\n", j, pRecBAEntry->BAWinSize, pRecBAEntry->LastIndSeq, pRecBAEntry->list.qlen);
1960 sprintf(pOutBuf, "%s\n", pOutBuf);
1962 sprintf(pOutBuf, "%s[Originator]\n", pOutBuf);
1963 for (j=0; j < NUM_OF_TID; j++)
1965 if (pEntry->BAOriWcidArray[j] != 0)
1967 pOriBAEntry =&pAd->BATable.BAOriEntry[pEntry->BAOriWcidArray[j]];
1968 sprintf(pOutBuf + strlen(pOutBuf), "TID=%d, BAWinSize=%d, StartSeq=%d, CurTxSeq=%d\n", j, pOriBAEntry->BAWinSize, pOriBAEntry->Sequence, pEntry->TxSeq[j]);
1971 sprintf(pOutBuf, "%s\n\n", pOutBuf);
1973 if (strlen(pOutBuf) > (IW_PRIV_SIZE_MASK - 30))
1979 #endif // DOT11_N_SUPPORT //
1982 rt_private_show(struct net_device *dev, struct iw_request_info *info,
1983 struct iw_point *wrq, char *extra)
1986 VIRTUAL_ADAPTER *pVirtualAd = NULL;
1989 u32 subcmd = wrq->flags;
1991 if (dev->priv_flags == INT_MAIN)
1995 pVirtualAd = dev->ml_priv;
1996 pAd = pVirtualAd->RtmpDev->ml_priv;
1998 pObj = (POS_COOKIE) pAd->OS_Cookie;
2002 /* if 1st open fail, pAd will be free;
2003 So the net_dev->ml_priv will be NULL in 2rd open */
2012 memset(extra, 0x00, IW_PRIV_SIZE_MASK);
2015 pObj->ioctl_if_type = INT_MAIN;
2016 pObj->ioctl_if = MAIN_MBSSID;
2022 case SHOW_CONN_STATUS:
2023 if (MONITOR_ON(pAd))
2025 #ifdef DOT11_N_SUPPORT
2026 if (pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED &&
2027 pAd->CommonCfg.RegTransmitSetting.field.BW)
2028 sprintf(extra, "Monitor Mode(CentralChannel %d)\n", pAd->CommonCfg.CentralChannel);
2030 #endif // DOT11_N_SUPPORT //
2031 sprintf(extra, "Monitor Mode(Channel %d)\n", pAd->CommonCfg.Channel);
2035 if (pAd->IndicateMediaState == NdisMediaStateConnected)
2039 sprintf(extra, "Connected(AP: %s[%02X:%02X:%02X:%02X:%02X:%02X])\n",
2040 pAd->CommonCfg.Ssid,
2041 pAd->CommonCfg.Bssid[0],
2042 pAd->CommonCfg.Bssid[1],
2043 pAd->CommonCfg.Bssid[2],
2044 pAd->CommonCfg.Bssid[3],
2045 pAd->CommonCfg.Bssid[4],
2046 pAd->CommonCfg.Bssid[5]);
2047 DBGPRINT(RT_DEBUG_TRACE ,("Ssid=%s ,Ssidlen = %d\n",pAd->CommonCfg.Ssid, pAd->CommonCfg.SsidLen));
2049 else if (ADHOC_ON(pAd))
2050 sprintf(extra, "Connected\n");
2054 sprintf(extra, "Disconnected\n");
2055 DBGPRINT(RT_DEBUG_TRACE ,("ConnStatus is not connected\n"));
2058 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2060 case SHOW_DRVIER_VERION:
2061 sprintf(extra, "Driver version-%s, %s %s\n", STA_DRIVER_VERSION, __DATE__, __TIME__ );
2062 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2064 #ifdef DOT11_N_SUPPORT
2066 getBaInfo(pAd, extra);
2067 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2069 #endif // DOT11_N_SUPPORT //
2070 case SHOW_DESC_INFO:
2072 Show_DescInfo_Proc(pAd, NULL);
2073 wrq->length = 0; // 1: size of '\0'
2077 if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
2079 sprintf(extra, "Scanning\n");
2080 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2083 pAd->StaCfg.bSwRadio = FALSE;
2084 if (pAd->StaCfg.bRadio != (pAd->StaCfg.bHwRadio && pAd->StaCfg.bSwRadio))
2086 pAd->StaCfg.bRadio = (pAd->StaCfg.bHwRadio && pAd->StaCfg.bSwRadio);
2087 if (pAd->StaCfg.bRadio == FALSE)
2090 // Update extra information
2091 pAd->ExtraInfo = SW_RADIO_OFF;
2094 sprintf(extra, "Radio Off\n");
2095 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2098 if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
2100 sprintf(extra, "Scanning\n");
2101 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2104 pAd->StaCfg.bSwRadio = TRUE;
2105 //if (pAd->StaCfg.bRadio != (pAd->StaCfg.bHwRadio && pAd->StaCfg.bSwRadio))
2107 pAd->StaCfg.bRadio = (pAd->StaCfg.bHwRadio && pAd->StaCfg.bSwRadio);
2108 if (pAd->StaCfg.bRadio == TRUE)
2111 // Update extra information
2112 pAd->ExtraInfo = EXTRA_INFO_CLEAR;
2115 sprintf(extra, "Radio On\n");
2116 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2120 #ifdef QOS_DLS_SUPPORT
2121 case SHOW_DLS_ENTRY_INFO:
2123 Set_DlsEntryInfo_Display_Proc(pAd, NULL);
2124 wrq->length = 0; // 1: size of '\0'
2127 #endif // QOS_DLS_SUPPORT //
2129 case SHOW_CFG_VALUE:
2131 Status = RTMPShowCfgValue(pAd, wrq->pointer, extra);
2133 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2136 case SHOW_ADHOC_ENTRY_INFO:
2137 Show_Adhoc_MacTable_Proc(pAd, extra);
2138 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2141 DBGPRINT(RT_DEBUG_TRACE, ("%s - unknow subcmd = %d\n", __func__, subcmd));
2149 int rt_ioctl_siwmlme(struct net_device *dev,
2150 struct iw_request_info *info,
2151 union iwreq_data *wrqu,
2154 PRTMP_ADAPTER pAd = dev->ml_priv;
2155 struct iw_mlme *pMlme = (struct iw_mlme *)wrqu->data.pointer;
2156 MLME_QUEUE_ELEM MsgElem;
2157 MLME_DISASSOC_REQ_STRUCT DisAssocReq;
2158 MLME_DEAUTH_REQ_STRUCT DeAuthReq;
2160 DBGPRINT(RT_DEBUG_TRACE, ("====> %s\n", __func__));
2167 #ifdef IW_MLME_DEAUTH
2168 case IW_MLME_DEAUTH:
2169 DBGPRINT(RT_DEBUG_TRACE, ("====> %s - IW_MLME_DEAUTH\n", __func__));
2170 COPY_MAC_ADDR(DeAuthReq.Addr, pAd->CommonCfg.Bssid);
2171 DeAuthReq.Reason = pMlme->reason_code;
2172 MsgElem.MsgLen = sizeof(MLME_DEAUTH_REQ_STRUCT);
2173 NdisMoveMemory(MsgElem.Msg, &DeAuthReq, sizeof(MLME_DEAUTH_REQ_STRUCT));
2174 MlmeDeauthReqAction(pAd, &MsgElem);
2177 LinkDown(pAd, FALSE);
2178 pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
2181 #endif // IW_MLME_DEAUTH //
2182 #ifdef IW_MLME_DISASSOC
2183 case IW_MLME_DISASSOC:
2184 DBGPRINT(RT_DEBUG_TRACE, ("====> %s - IW_MLME_DISASSOC\n", __func__));
2185 COPY_MAC_ADDR(DisAssocReq.Addr, pAd->CommonCfg.Bssid);
2186 DisAssocReq.Reason = pMlme->reason_code;
2188 MsgElem.Machine = ASSOC_STATE_MACHINE;
2189 MsgElem.MsgType = MT2_MLME_DISASSOC_REQ;
2190 MsgElem.MsgLen = sizeof(MLME_DISASSOC_REQ_STRUCT);
2191 NdisMoveMemory(MsgElem.Msg, &DisAssocReq, sizeof(MLME_DISASSOC_REQ_STRUCT));
2193 pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_OID_DISASSOC;
2194 MlmeDisassocReqAction(pAd, &MsgElem);
2196 #endif // IW_MLME_DISASSOC //
2198 DBGPRINT(RT_DEBUG_TRACE, ("====> %s - Unknow Command\n", __func__));
2204 #endif // SIOCSIWMLME //
2206 #if WIRELESS_EXT > 17
2207 int rt_ioctl_siwauth(struct net_device *dev,
2208 struct iw_request_info *info,
2209 union iwreq_data *wrqu, char *extra)
2211 PRTMP_ADAPTER pAdapter = dev->ml_priv;
2212 struct iw_param *param = &wrqu->param;
2214 //check if the interface is down
2215 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
2217 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
2220 switch (param->flags & IW_AUTH_INDEX) {
2221 case IW_AUTH_WPA_VERSION:
2222 if (param->value == IW_AUTH_WPA_VERSION_WPA)
2224 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPAPSK;
2225 if (pAdapter->StaCfg.BssType == BSS_ADHOC)
2226 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPANone;
2228 else if (param->value == IW_AUTH_WPA_VERSION_WPA2)
2229 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA2PSK;
2231 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_WPA_VERSION - param->value = %d!\n", __func__, param->value));
2233 case IW_AUTH_CIPHER_PAIRWISE:
2234 if (param->value == IW_AUTH_CIPHER_NONE)
2236 pAdapter->StaCfg.WepStatus = Ndis802_11WEPDisabled;
2237 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
2238 pAdapter->StaCfg.PairCipher = Ndis802_11WEPDisabled;
2240 else if (param->value == IW_AUTH_CIPHER_WEP40 ||
2241 param->value == IW_AUTH_CIPHER_WEP104)
2243 pAdapter->StaCfg.WepStatus = Ndis802_11WEPEnabled;
2244 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
2245 pAdapter->StaCfg.PairCipher = Ndis802_11WEPEnabled;
2246 #ifdef WPA_SUPPLICANT_SUPPORT
2247 pAdapter->StaCfg.IEEE8021X = FALSE;
2248 #endif // WPA_SUPPLICANT_SUPPORT //
2250 else if (param->value == IW_AUTH_CIPHER_TKIP)
2252 pAdapter->StaCfg.WepStatus = Ndis802_11Encryption2Enabled;
2253 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
2254 pAdapter->StaCfg.PairCipher = Ndis802_11Encryption2Enabled;
2256 else if (param->value == IW_AUTH_CIPHER_CCMP)
2258 pAdapter->StaCfg.WepStatus = Ndis802_11Encryption3Enabled;
2259 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
2260 pAdapter->StaCfg.PairCipher = Ndis802_11Encryption3Enabled;
2262 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_CIPHER_PAIRWISE - param->value = %d!\n", __func__, param->value));
2264 case IW_AUTH_CIPHER_GROUP:
2265 if (param->value == IW_AUTH_CIPHER_NONE)
2267 pAdapter->StaCfg.GroupCipher = Ndis802_11WEPDisabled;
2269 else if (param->value == IW_AUTH_CIPHER_WEP40 ||
2270 param->value == IW_AUTH_CIPHER_WEP104)
2272 pAdapter->StaCfg.GroupCipher = Ndis802_11WEPEnabled;
2274 else if (param->value == IW_AUTH_CIPHER_TKIP)
2276 pAdapter->StaCfg.GroupCipher = Ndis802_11Encryption2Enabled;
2278 else if (param->value == IW_AUTH_CIPHER_CCMP)
2280 pAdapter->StaCfg.GroupCipher = Ndis802_11Encryption3Enabled;
2282 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_CIPHER_GROUP - param->value = %d!\n", __func__, param->value));
2284 case IW_AUTH_KEY_MGMT:
2285 if (param->value == IW_AUTH_KEY_MGMT_802_1X)
2287 if (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK)
2289 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA;
2290 #ifdef WPA_SUPPLICANT_SUPPORT
2291 pAdapter->StaCfg.IEEE8021X = FALSE;
2292 #endif // WPA_SUPPLICANT_SUPPORT //
2294 else if (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK)
2296 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA2;
2297 #ifdef WPA_SUPPLICANT_SUPPORT
2298 pAdapter->StaCfg.IEEE8021X = FALSE;
2299 #endif // WPA_SUPPLICANT_SUPPORT //
2301 #ifdef WPA_SUPPLICANT_SUPPORT
2304 pAdapter->StaCfg.IEEE8021X = TRUE;
2305 #endif // WPA_SUPPLICANT_SUPPORT //
2307 else if (param->value == 0)
2309 //pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
2310 STA_PORT_SECURED(pAdapter);
2312 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_KEY_MGMT - param->value = %d!\n", __func__, param->value));
2314 case IW_AUTH_RX_UNENCRYPTED_EAPOL:
2316 case IW_AUTH_PRIVACY_INVOKED:
2317 /*if (param->value == 0)
2319 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
2320 pAdapter->StaCfg.WepStatus = Ndis802_11WEPDisabled;
2321 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
2322 pAdapter->StaCfg.PairCipher = Ndis802_11WEPDisabled;
2323 pAdapter->StaCfg.GroupCipher = Ndis802_11WEPDisabled;
2325 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_PRIVACY_INVOKED - param->value = %d!\n", __func__, param->value));
2327 case IW_AUTH_DROP_UNENCRYPTED:
2328 if (param->value != 0)
2329 pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED;
2332 //pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
2333 STA_PORT_SECURED(pAdapter);
2335 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_WPA_VERSION - param->value = %d!\n", __func__, param->value));
2337 case IW_AUTH_80211_AUTH_ALG:
2338 if (param->value & IW_AUTH_ALG_SHARED_KEY)
2340 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeShared;
2342 else if (param->value & IW_AUTH_ALG_OPEN_SYSTEM)
2344 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
2348 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_80211_AUTH_ALG - param->value = %d!\n", __func__, param->value));
2350 case IW_AUTH_WPA_ENABLED:
2351 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_WPA_ENABLED - Driver supports WPA!(param->value = %d)\n", __func__, param->value));
2360 int rt_ioctl_giwauth(struct net_device *dev,
2361 struct iw_request_info *info,
2362 union iwreq_data *wrqu, char *extra)
2364 PRTMP_ADAPTER pAdapter = dev->ml_priv;
2365 struct iw_param *param = &wrqu->param;
2367 //check if the interface is down
2368 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
2370 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
2374 switch (param->flags & IW_AUTH_INDEX) {
2375 case IW_AUTH_DROP_UNENCRYPTED:
2376 param->value = (pAdapter->StaCfg.WepStatus == Ndis802_11WEPDisabled) ? 0 : 1;
2379 case IW_AUTH_80211_AUTH_ALG:
2380 param->value = (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeShared) ? IW_AUTH_ALG_SHARED_KEY : IW_AUTH_ALG_OPEN_SYSTEM;
2383 case IW_AUTH_WPA_ENABLED:
2384 param->value = (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA) ? 1 : 0;
2390 DBGPRINT(RT_DEBUG_TRACE, ("rt_ioctl_giwauth::param->value = %d!\n", param->value));
2394 void fnSetCipherKey(
2395 IN PRTMP_ADAPTER pAdapter,
2399 IN struct iw_encode_ext *ext)
2401 NdisZeroMemory(&pAdapter->SharedKey[BSS0][keyIdx], sizeof(CIPHER_KEY));
2402 pAdapter->SharedKey[BSS0][keyIdx].KeyLen = LEN_TKIP_EK;
2403 NdisMoveMemory(pAdapter->SharedKey[BSS0][keyIdx].Key, ext->key, LEN_TKIP_EK);
2404 NdisMoveMemory(pAdapter->SharedKey[BSS0][keyIdx].TxMic, ext->key + LEN_TKIP_EK, LEN_TKIP_TXMICK);
2405 NdisMoveMemory(pAdapter->SharedKey[BSS0][keyIdx].RxMic, ext->key + LEN_TKIP_EK + LEN_TKIP_TXMICK, LEN_TKIP_RXMICK);
2406 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CipherAlg;
2408 // Update group key information to ASIC Shared Key Table
2409 AsicAddSharedKeyEntry(pAdapter,
2412 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg,
2413 pAdapter->SharedKey[BSS0][keyIdx].Key,
2414 pAdapter->SharedKey[BSS0][keyIdx].TxMic,
2415 pAdapter->SharedKey[BSS0][keyIdx].RxMic);
2418 // Update ASIC WCID attribute table and IVEIV table
2419 RTMPAddWcidAttributeEntry(pAdapter,
2422 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg,
2425 // Update ASIC WCID attribute table and IVEIV table
2426 RTMPAddWcidAttributeEntry(pAdapter,
2429 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg,
2430 &pAdapter->MacTab.Content[BSSID_WCID]);
2433 int rt_ioctl_siwencodeext(struct net_device *dev,
2434 struct iw_request_info *info,
2435 union iwreq_data *wrqu,
2438 PRTMP_ADAPTER pAdapter = dev->ml_priv;
2439 struct iw_point *encoding = &wrqu->encoding;
2440 struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
2441 int keyIdx, alg = ext->alg;
2443 //check if the interface is down
2444 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
2446 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
2450 if (encoding->flags & IW_ENCODE_DISABLED)
2452 keyIdx = (encoding->flags & IW_ENCODE_INDEX) - 1;
2453 // set BSSID wcid entry of the Pair-wise Key table as no-security mode
2454 AsicRemovePairwiseKeyEntry(pAdapter, BSS0, BSSID_WCID);
2455 pAdapter->SharedKey[BSS0][keyIdx].KeyLen = 0;
2456 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CIPHER_NONE;
2457 AsicRemoveSharedKeyEntry(pAdapter, 0, (UCHAR)keyIdx);
2458 NdisZeroMemory(&pAdapter->SharedKey[BSS0][keyIdx], sizeof(CIPHER_KEY));
2459 DBGPRINT(RT_DEBUG_TRACE, ("%s::Remove all keys!(encoding->flags = %x)\n", __func__, encoding->flags));
2463 // Get Key Index and convet to our own defined key index
2464 keyIdx = (encoding->flags & IW_ENCODE_INDEX) - 1;
2465 if((keyIdx < 0) || (keyIdx >= NR_WEP_KEYS))
2468 if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
2470 pAdapter->StaCfg.DefaultKeyId = keyIdx;
2471 DBGPRINT(RT_DEBUG_TRACE, ("%s::DefaultKeyId = %d\n", __func__, pAdapter->StaCfg.DefaultKeyId));
2475 case IW_ENCODE_ALG_NONE:
2476 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_ENCODE_ALG_NONE\n", __func__));
2478 case IW_ENCODE_ALG_WEP:
2479 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_ENCODE_ALG_WEP - ext->key_len = %d, keyIdx = %d\n", __func__, ext->key_len, keyIdx));
2480 if (ext->key_len == MAX_WEP_KEY_SIZE)
2482 pAdapter->SharedKey[BSS0][keyIdx].KeyLen = MAX_WEP_KEY_SIZE;
2483 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CIPHER_WEP128;
2485 else if (ext->key_len == MIN_WEP_KEY_SIZE)
2487 pAdapter->SharedKey[BSS0][keyIdx].KeyLen = MIN_WEP_KEY_SIZE;
2488 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CIPHER_WEP64;
2493 NdisZeroMemory(pAdapter->SharedKey[BSS0][keyIdx].Key, 16);
2494 NdisMoveMemory(pAdapter->SharedKey[BSS0][keyIdx].Key, ext->key, ext->key_len);
2496 if (pAdapter->StaCfg.GroupCipher == Ndis802_11GroupWEP40Enabled ||
2497 pAdapter->StaCfg.GroupCipher == Ndis802_11GroupWEP104Enabled)
2499 // Set Group key material to Asic
2500 AsicAddSharedKeyEntry(pAdapter, BSS0, keyIdx, pAdapter->SharedKey[BSS0][keyIdx].CipherAlg, pAdapter->SharedKey[BSS0][keyIdx].Key, NULL, NULL);
2502 // Update WCID attribute table and IVEIV table for this group key table
2503 RTMPAddWcidAttributeEntry(pAdapter, BSS0, keyIdx, pAdapter->SharedKey[BSS0][keyIdx].CipherAlg, NULL);
2505 STA_PORT_SECURED(pAdapter);
2507 // Indicate Connected for GUI
2508 pAdapter->IndicateMediaState = NdisMediaStateConnected;
2511 case IW_ENCODE_ALG_TKIP:
2512 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_ENCODE_ALG_TKIP - keyIdx = %d, ext->key_len = %d\n", __func__, keyIdx, ext->key_len));
2513 if (ext->key_len == 32)
2515 if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
2517 fnSetCipherKey(pAdapter, keyIdx, CIPHER_TKIP, FALSE, ext);
2518 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA2)
2520 //pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
2521 STA_PORT_SECURED(pAdapter);
2524 else if (ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY)
2526 fnSetCipherKey(pAdapter, keyIdx, CIPHER_TKIP, TRUE, ext);
2528 // set 802.1x port control
2529 //pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
2530 STA_PORT_SECURED(pAdapter);
2536 case IW_ENCODE_ALG_CCMP:
2537 if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
2539 fnSetCipherKey(pAdapter, keyIdx, CIPHER_AES, FALSE, ext);
2540 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA2)
2541 //pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
2542 STA_PORT_SECURED(pAdapter);
2544 else if (ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY)
2546 fnSetCipherKey(pAdapter, keyIdx, CIPHER_AES, TRUE, ext);
2548 // set 802.1x port control
2549 //pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
2550 STA_PORT_SECURED(pAdapter);
2562 rt_ioctl_giwencodeext(struct net_device *dev,
2563 struct iw_request_info *info,
2564 union iwreq_data *wrqu, char *extra)
2566 PRTMP_ADAPTER pAd = dev->ml_priv;
2568 struct iw_point *encoding = &wrqu->encoding;
2569 struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
2570 int idx, max_key_len;
2572 DBGPRINT(RT_DEBUG_TRACE ,("===> rt_ioctl_giwencodeext\n"));
2574 max_key_len = encoding->length - sizeof(*ext);
2575 if (max_key_len < 0)
2578 idx = encoding->flags & IW_ENCODE_INDEX;
2581 if (idx < 1 || idx > 4)
2585 if ((pAd->StaCfg.WepStatus == Ndis802_11Encryption2Enabled) ||
2586 (pAd->StaCfg.WepStatus == Ndis802_11Encryption3Enabled))
2588 if (idx != pAd->StaCfg.DefaultKeyId)
2596 idx = pAd->StaCfg.DefaultKeyId;
2598 encoding->flags = idx + 1;
2599 memset(ext, 0, sizeof(*ext));
2602 switch(pAd->StaCfg.WepStatus) {
2603 case Ndis802_11WEPDisabled:
2604 ext->alg = IW_ENCODE_ALG_NONE;
2605 encoding->flags |= IW_ENCODE_DISABLED;
2607 case Ndis802_11WEPEnabled:
2608 ext->alg = IW_ENCODE_ALG_WEP;
2609 if (pAd->SharedKey[BSS0][idx].KeyLen > max_key_len)
2613 ext->key_len = pAd->SharedKey[BSS0][idx].KeyLen;
2614 pKey = &(pAd->SharedKey[BSS0][idx].Key[0]);
2617 case Ndis802_11Encryption2Enabled:
2618 case Ndis802_11Encryption3Enabled:
2619 if (pAd->StaCfg.WepStatus == Ndis802_11Encryption2Enabled)
2620 ext->alg = IW_ENCODE_ALG_TKIP;
2622 ext->alg = IW_ENCODE_ALG_CCMP;
2624 if (max_key_len < 32)
2629 pKey = &pAd->StaCfg.PMK[0];
2636 if (ext->key_len && pKey)
2638 encoding->flags |= IW_ENCODE_ENABLED;
2639 memcpy(ext->key, pKey, ext->key_len);
2646 int rt_ioctl_siwgenie(struct net_device *dev,
2647 struct iw_request_info *info,
2648 union iwreq_data *wrqu, char *extra)
2650 PRTMP_ADAPTER pAd = dev->ml_priv;
2652 if (wrqu->data.length > MAX_LEN_OF_RSNIE ||
2653 (wrqu->data.length && extra == NULL))
2656 if (wrqu->data.length)
2658 pAd->StaCfg.RSNIE_Len = wrqu->data.length;
2659 NdisMoveMemory(&pAd->StaCfg.RSN_IE[0], extra, pAd->StaCfg.RSNIE_Len);
2663 pAd->StaCfg.RSNIE_Len = 0;
2664 NdisZeroMemory(&pAd->StaCfg.RSN_IE[0], MAX_LEN_OF_RSNIE);
2669 #endif // SIOCSIWGENIE //
2671 int rt_ioctl_giwgenie(struct net_device *dev,
2672 struct iw_request_info *info,
2673 union iwreq_data *wrqu, char *extra)
2675 PRTMP_ADAPTER pAd = dev->ml_priv;
2677 if ((pAd->StaCfg.RSNIE_Len == 0) ||
2678 (pAd->StaCfg.AuthMode < Ndis802_11AuthModeWPA))
2680 wrqu->data.length = 0;
2684 #ifdef NATIVE_WPA_SUPPLICANT_SUPPORT
2686 if (pAd->StaCfg.WpaSupplicantUP == WPA_SUPPLICANT_ENABLE)
2688 if (wrqu->data.length < pAd->StaCfg.RSNIE_Len)
2691 wrqu->data.length = pAd->StaCfg.RSNIE_Len;
2692 memcpy(extra, &pAd->StaCfg.RSN_IE[0], pAd->StaCfg.RSNIE_Len);
2695 #endif // SIOCSIWGENIE //
2696 #endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
2698 UCHAR RSNIe = IE_WPA;
2700 if (wrqu->data.length < (pAd->StaCfg.RSNIE_Len + 2)) // ID, Len
2702 wrqu->data.length = pAd->StaCfg.RSNIE_Len + 2;
2704 if ((pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK) ||
2705 (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2))
2708 extra[0] = (char)RSNIe;
2709 extra[1] = pAd->StaCfg.RSNIE_Len;
2710 memcpy(extra+2, &pAd->StaCfg.RSN_IE[0], pAd->StaCfg.RSNIE_Len);
2716 int rt_ioctl_siwpmksa(struct net_device *dev,
2717 struct iw_request_info *info,
2718 union iwreq_data *wrqu,
2721 PRTMP_ADAPTER pAd = dev->ml_priv;
2722 struct iw_pmksa *pPmksa = (struct iw_pmksa *)wrqu->data.pointer;
2723 INT CachedIdx = 0, idx = 0;
2728 DBGPRINT(RT_DEBUG_TRACE ,("===> rt_ioctl_siwpmksa\n"));
2731 case IW_PMKSA_FLUSH:
2732 NdisZeroMemory(pAd->StaCfg.SavedPMK, sizeof(BSSID_INFO)*PMKID_NO);
2733 DBGPRINT(RT_DEBUG_TRACE ,("rt_ioctl_siwpmksa - IW_PMKSA_FLUSH\n"));
2735 case IW_PMKSA_REMOVE:
2736 for (CachedIdx = 0; CachedIdx < pAd->StaCfg.SavedPMKNum; CachedIdx++)
2738 // compare the BSSID
2739 if (NdisEqualMemory(pPmksa->bssid.sa_data, pAd->StaCfg.SavedPMK[CachedIdx].BSSID, MAC_ADDR_LEN))
2741 NdisZeroMemory(pAd->StaCfg.SavedPMK[CachedIdx].BSSID, MAC_ADDR_LEN);
2742 NdisZeroMemory(pAd->StaCfg.SavedPMK[CachedIdx].PMKID, 16);
2743 for (idx = CachedIdx; idx < (pAd->StaCfg.SavedPMKNum - 1); idx++)
2745 NdisMoveMemory(&pAd->StaCfg.SavedPMK[idx].BSSID[0], &pAd->StaCfg.SavedPMK[idx+1].BSSID[0], MAC_ADDR_LEN);
2746 NdisMoveMemory(&pAd->StaCfg.SavedPMK[idx].PMKID[0], &pAd->StaCfg.SavedPMK[idx+1].PMKID[0], 16);
2748 pAd->StaCfg.SavedPMKNum--;
2753 DBGPRINT(RT_DEBUG_TRACE ,("rt_ioctl_siwpmksa - IW_PMKSA_REMOVE\n"));
2756 for (CachedIdx = 0; CachedIdx < pAd->StaCfg.SavedPMKNum; CachedIdx++)
2758 // compare the BSSID
2759 if (NdisEqualMemory(pPmksa->bssid.sa_data, pAd->StaCfg.SavedPMK[CachedIdx].BSSID, MAC_ADDR_LEN))
2763 // Found, replace it
2764 if (CachedIdx < PMKID_NO)
2766 DBGPRINT(RT_DEBUG_OFF, ("Update PMKID, idx = %d\n", CachedIdx));
2767 NdisMoveMemory(&pAd->StaCfg.SavedPMK[CachedIdx].BSSID[0], pPmksa->bssid.sa_data, MAC_ADDR_LEN);
2768 NdisMoveMemory(&pAd->StaCfg.SavedPMK[CachedIdx].PMKID[0], pPmksa->pmkid, 16);
2769 pAd->StaCfg.SavedPMKNum++;
2771 // Not found, replace the last one
2774 // Randomly replace one
2775 CachedIdx = (pPmksa->bssid.sa_data[5] % PMKID_NO);
2776 DBGPRINT(RT_DEBUG_OFF, ("Update PMKID, idx = %d\n", CachedIdx));
2777 NdisMoveMemory(&pAd->StaCfg.SavedPMK[CachedIdx].BSSID[0], pPmksa->bssid.sa_data, MAC_ADDR_LEN);
2778 NdisMoveMemory(&pAd->StaCfg.SavedPMK[CachedIdx].PMKID[0], pPmksa->pmkid, 16);
2781 DBGPRINT(RT_DEBUG_TRACE ,("rt_ioctl_siwpmksa - IW_PMKSA_ADD\n"));
2784 DBGPRINT(RT_DEBUG_TRACE ,("rt_ioctl_siwpmksa - Unknow Command!!\n"));
2790 #endif // #if WIRELESS_EXT > 17
2794 rt_private_ioctl_bbp(struct net_device *dev, struct iw_request_info *info,
2795 struct iw_point *wrq, char *extra)
2800 // CHAR arg[255]={0};
2803 BOOLEAN bIsPrintAllBBP = FALSE;
2805 PRTMP_ADAPTER pAdapter = dev->ml_priv;
2808 memset(extra, 0x00, IW_PRIV_SIZE_MASK);
2810 if (wrq->length > 1) //No parameters.
2812 sprintf(extra, "\n");
2814 //Parsing Read or Write
2815 this_char = wrq->pointer;
2816 DBGPRINT(RT_DEBUG_TRACE, ("this_char=%s\n", this_char));
2820 if ((value = rtstrchr(this_char, '=')) != NULL)
2823 if (!value || !*value)
2825 DBGPRINT(RT_DEBUG_TRACE, ("this_char=%s, value=%s\n", this_char, value));
2826 if (sscanf(this_char, "%d", &(bbpId)) == 1)
2831 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, ®BBP);
2833 sprintf(extra+strlen(extra), "R%02d[0x%02X]:%02X\n", bbpId, bbpId*2, regBBP);
2834 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2835 DBGPRINT(RT_DEBUG_TRACE, ("msg=%s\n", extra));
2838 {//Invalid parametes, so default printk all bbp
2839 bIsPrintAllBBP = TRUE;
2844 { //Invalid parametes, so default printk all bbp
2845 bIsPrintAllBBP = TRUE;
2851 if ((sscanf(this_char, "%d", &(bbpId)) == 1) && (sscanf(value, "%x", &(bbpValue)) == 1))
2856 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, bbpId, bbpValue);
2857 //Read it back for showing
2858 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, ®BBP);
2860 sprintf(extra+strlen(extra), "R%02d[0x%02X]:%02X\n", bbpId, bbpId*2, regBBP);
2861 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2862 DBGPRINT(RT_DEBUG_TRACE, ("msg=%s\n", extra));
2865 {//Invalid parametes, so default printk all bbp
2866 bIsPrintAllBBP = TRUE;
2871 { //Invalid parametes, so default printk all bbp
2872 bIsPrintAllBBP = TRUE;
2878 bIsPrintAllBBP = TRUE;
2883 memset(extra, 0x00, IW_PRIV_SIZE_MASK);
2884 sprintf(extra, "\n");
2885 for (bbpId = 0; bbpId <= 136; bbpId++)
2887 if (strlen(extra) >= (IW_PRIV_SIZE_MASK - 10))
2889 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, ®BBP);
2890 sprintf(extra+strlen(extra), "R%02d[0x%02X]:%02X ", bbpId, bbpId*2, regBBP);
2892 sprintf(extra+strlen(extra), "\n");
2895 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2896 DBGPRINT(RT_DEBUG_TRACE, ("wrq->length = %d\n", wrq->length));
2899 DBGPRINT(RT_DEBUG_TRACE, ("<==rt_private_ioctl_bbp\n\n"));
2905 int rt_ioctl_siwrate(struct net_device *dev,
2906 struct iw_request_info *info,
2907 union iwreq_data *wrqu, char *extra)
2909 PRTMP_ADAPTER pAd = dev->ml_priv;
2910 UINT32 rate = wrqu->bitrate.value, fixed = wrqu->bitrate.fixed;
2912 //check if the interface is down
2913 if(!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_IN_USE))
2915 DBGPRINT(RT_DEBUG_TRACE, ("rt_ioctl_siwrate::Network is down!\n"));
2919 DBGPRINT(RT_DEBUG_TRACE, ("rt_ioctl_siwrate::(rate = %d, fixed = %d)\n", rate, fixed));
2920 /* rate = -1 => auto rate
2921 rate = X, fixed = 1 => (fixed rate X)
2926 pAd->StaCfg.DesiredTransmitSetting.field.MCS = MCS_AUTO;
2927 pAd->StaCfg.bAutoTxRateSwitch = TRUE;
2928 if ((pAd->CommonCfg.PhyMode <= PHY_11G) ||
2929 (pAd->MacTab.Content[BSSID_WCID].HTPhyMode.field.MODE <= MODE_OFDM))
2930 RTMPSetDesiredRates(pAd, -1);
2932 #ifdef DOT11_N_SUPPORT
2934 #endif // DOT11_N_SUPPORT //
2940 pAd->StaCfg.bAutoTxRateSwitch = FALSE;
2941 if ((pAd->CommonCfg.PhyMode <= PHY_11G) ||
2942 (pAd->MacTab.Content[BSSID_WCID].HTPhyMode.field.MODE <= MODE_OFDM))
2943 RTMPSetDesiredRates(pAd, rate);
2946 pAd->StaCfg.DesiredTransmitSetting.field.MCS = MCS_AUTO;
2947 #ifdef DOT11_N_SUPPORT
2949 #endif // DOT11_N_SUPPORT //
2951 DBGPRINT(RT_DEBUG_TRACE, ("rt_ioctl_siwrate::(HtMcs=%d)\n",pAd->StaCfg.DesiredTransmitSetting.field.MCS));
2955 // TODO: rate = X, fixed = 0 => (rates <= X)
2963 int rt_ioctl_giwrate(struct net_device *dev,
2964 struct iw_request_info *info,
2965 union iwreq_data *wrqu, char *extra)
2967 PRTMP_ADAPTER pAd = dev->ml_priv;
2968 int rate_index = 0, rate_count = 0;
2969 HTTRANSMIT_SETTING ht_setting;
2970 __s32 ralinkrate[] =
2971 {2, 4, 11, 22, // CCK
2972 12, 18, 24, 36, 48, 72, 96, 108, // OFDM
2973 13, 26, 39, 52, 78, 104, 117, 130, 26, 52, 78, 104, 156, 208, 234, 260, // 20MHz, 800ns GI, MCS: 0 ~ 15
2974 39, 78, 117, 156, 234, 312, 351, 390, // 20MHz, 800ns GI, MCS: 16 ~ 23
2975 27, 54, 81, 108, 162, 216, 243, 270, 54, 108, 162, 216, 324, 432, 486, 540, // 40MHz, 800ns GI, MCS: 0 ~ 15
2976 81, 162, 243, 324, 486, 648, 729, 810, // 40MHz, 800ns GI, MCS: 16 ~ 23
2977 14, 29, 43, 57, 87, 115, 130, 144, 29, 59, 87, 115, 173, 230, 260, 288, // 20MHz, 400ns GI, MCS: 0 ~ 15
2978 43, 87, 130, 173, 260, 317, 390, 433, // 20MHz, 400ns GI, MCS: 16 ~ 23
2979 30, 60, 90, 120, 180, 240, 270, 300, 60, 120, 180, 240, 360, 480, 540, 600, // 40MHz, 400ns GI, MCS: 0 ~ 15
2980 90, 180, 270, 360, 540, 720, 810, 900}; // 40MHz, 400ns GI, MCS: 16 ~ 23
2982 rate_count = sizeof(ralinkrate)/sizeof(__s32);
2983 //check if the interface is down
2984 if(!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_IN_USE))
2986 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
2990 if ((pAd->StaCfg.bAutoTxRateSwitch == FALSE) &&
2992 ((pAd->CommonCfg.PhyMode <= PHY_11G) || (pAd->MacTab.Content[BSSID_WCID].HTPhyMode.field.MODE <= MODE_OFDM)))
2993 ht_setting.word = pAd->StaCfg.HTPhyMode.word;
2995 ht_setting.word = pAd->MacTab.Content[BSSID_WCID].HTPhyMode.word;
2997 #ifdef DOT11_N_SUPPORT
2998 if (ht_setting.field.MODE >= MODE_HTMIX)
3000 // rate_index = 12 + ((UCHAR)ht_setting.field.BW *16) + ((UCHAR)ht_setting.field.ShortGI *32) + ((UCHAR)ht_setting.field.MCS);
3001 rate_index = 12 + ((UCHAR)ht_setting.field.BW *24) + ((UCHAR)ht_setting.field.ShortGI *48) + ((UCHAR)ht_setting.field.MCS);
3004 #endif // DOT11_N_SUPPORT //
3005 if (ht_setting.field.MODE == MODE_OFDM)
3006 rate_index = (UCHAR)(ht_setting.field.MCS) + 4;
3007 else if (ht_setting.field.MODE == MODE_CCK)
3008 rate_index = (UCHAR)(ht_setting.field.MCS);
3013 if (rate_index > rate_count)
3014 rate_index = rate_count;
3016 wrqu->bitrate.value = ralinkrate[rate_index] * 500000;
3017 wrqu->bitrate.disabled = 0;
3022 static const iw_handler rt_handler[] =
3024 (iw_handler) NULL, /* SIOCSIWCOMMIT */
3025 (iw_handler) rt_ioctl_giwname, /* SIOCGIWNAME */
3026 (iw_handler) NULL, /* SIOCSIWNWID */
3027 (iw_handler) NULL, /* SIOCGIWNWID */
3028 (iw_handler) rt_ioctl_siwfreq, /* SIOCSIWFREQ */
3029 (iw_handler) rt_ioctl_giwfreq, /* SIOCGIWFREQ */
3030 (iw_handler) rt_ioctl_siwmode, /* SIOCSIWMODE */
3031 (iw_handler) rt_ioctl_giwmode, /* SIOCGIWMODE */
3032 (iw_handler) NULL, /* SIOCSIWSENS */
3033 (iw_handler) NULL, /* SIOCGIWSENS */
3034 (iw_handler) NULL /* not used */, /* SIOCSIWRANGE */
3035 (iw_handler) rt_ioctl_giwrange, /* SIOCGIWRANGE */
3036 (iw_handler) NULL /* not used */, /* SIOCSIWPRIV */
3037 (iw_handler) NULL /* kernel code */, /* SIOCGIWPRIV */
3038 (iw_handler) NULL /* not used */, /* SIOCSIWSTATS */
3039 (iw_handler) rt28xx_get_wireless_stats /* kernel code */, /* SIOCGIWSTATS */
3040 (iw_handler) NULL, /* SIOCSIWSPY */
3041 (iw_handler) NULL, /* SIOCGIWSPY */
3042 (iw_handler) NULL, /* SIOCSIWTHRSPY */
3043 (iw_handler) NULL, /* SIOCGIWTHRSPY */
3044 (iw_handler) rt_ioctl_siwap, /* SIOCSIWAP */
3045 (iw_handler) rt_ioctl_giwap, /* SIOCGIWAP */
3047 (iw_handler) rt_ioctl_siwmlme, /* SIOCSIWMLME */
3049 (iw_handler) NULL, /* SIOCSIWMLME */
3050 #endif // SIOCSIWMLME //
3051 (iw_handler) rt_ioctl_iwaplist, /* SIOCGIWAPLIST */
3053 (iw_handler) rt_ioctl_siwscan, /* SIOCSIWSCAN */
3054 (iw_handler) rt_ioctl_giwscan, /* SIOCGIWSCAN */
3056 (iw_handler) NULL, /* SIOCSIWSCAN */
3057 (iw_handler) NULL, /* SIOCGIWSCAN */
3058 #endif /* SIOCGIWSCAN */
3059 (iw_handler) rt_ioctl_siwessid, /* SIOCSIWESSID */
3060 (iw_handler) rt_ioctl_giwessid, /* SIOCGIWESSID */
3061 (iw_handler) rt_ioctl_siwnickn, /* SIOCSIWNICKN */
3062 (iw_handler) rt_ioctl_giwnickn, /* SIOCGIWNICKN */
3063 (iw_handler) NULL, /* -- hole -- */
3064 (iw_handler) NULL, /* -- hole -- */
3065 (iw_handler) rt_ioctl_siwrate, /* SIOCSIWRATE */
3066 (iw_handler) rt_ioctl_giwrate, /* SIOCGIWRATE */
3067 (iw_handler) rt_ioctl_siwrts, /* SIOCSIWRTS */
3068 (iw_handler) rt_ioctl_giwrts, /* SIOCGIWRTS */
3069 (iw_handler) rt_ioctl_siwfrag, /* SIOCSIWFRAG */
3070 (iw_handler) rt_ioctl_giwfrag, /* SIOCGIWFRAG */
3071 (iw_handler) NULL, /* SIOCSIWTXPOW */
3072 (iw_handler) NULL, /* SIOCGIWTXPOW */
3073 (iw_handler) NULL, /* SIOCSIWRETRY */
3074 (iw_handler) NULL, /* SIOCGIWRETRY */
3075 (iw_handler) rt_ioctl_siwencode, /* SIOCSIWENCODE */
3076 (iw_handler) rt_ioctl_giwencode, /* SIOCGIWENCODE */
3077 (iw_handler) NULL, /* SIOCSIWPOWER */
3078 (iw_handler) NULL, /* SIOCGIWPOWER */
3079 (iw_handler) NULL, /* -- hole -- */
3080 (iw_handler) NULL, /* -- hole -- */
3081 #if WIRELESS_EXT > 17
3082 (iw_handler) rt_ioctl_siwgenie, /* SIOCSIWGENIE */
3083 (iw_handler) rt_ioctl_giwgenie, /* SIOCGIWGENIE */
3084 (iw_handler) rt_ioctl_siwauth, /* SIOCSIWAUTH */
3085 (iw_handler) rt_ioctl_giwauth, /* SIOCGIWAUTH */
3086 (iw_handler) rt_ioctl_siwencodeext, /* SIOCSIWENCODEEXT */
3087 (iw_handler) rt_ioctl_giwencodeext, /* SIOCGIWENCODEEXT */
3088 (iw_handler) rt_ioctl_siwpmksa, /* SIOCSIWPMKSA */
3092 static const iw_handler rt_priv_handlers[] = {
3093 (iw_handler) NULL, /* + 0x00 */
3094 (iw_handler) NULL, /* + 0x01 */
3095 #ifndef CONFIG_AP_SUPPORT
3096 (iw_handler) rt_ioctl_setparam, /* + 0x02 */
3098 (iw_handler) NULL, /* + 0x02 */
3099 #endif // CONFIG_AP_SUPPORT //
3101 (iw_handler) rt_private_ioctl_bbp, /* + 0x03 */
3103 (iw_handler) NULL, /* + 0x03 */
3105 (iw_handler) NULL, /* + 0x04 */
3106 (iw_handler) NULL, /* + 0x05 */
3107 (iw_handler) NULL, /* + 0x06 */
3108 (iw_handler) NULL, /* + 0x07 */
3109 (iw_handler) NULL, /* + 0x08 */
3110 (iw_handler) rt_private_get_statistics, /* + 0x09 */
3111 (iw_handler) NULL, /* + 0x0A */
3112 (iw_handler) NULL, /* + 0x0B */
3113 (iw_handler) NULL, /* + 0x0C */
3114 (iw_handler) NULL, /* + 0x0D */
3115 (iw_handler) NULL, /* + 0x0E */
3116 (iw_handler) NULL, /* + 0x0F */
3117 (iw_handler) NULL, /* + 0x10 */
3118 (iw_handler) rt_private_show, /* + 0x11 */
3119 (iw_handler) NULL, /* + 0x12 */
3120 (iw_handler) NULL, /* + 0x13 */
3121 (iw_handler) NULL, /* + 0x15 */
3122 (iw_handler) NULL, /* + 0x17 */
3123 (iw_handler) NULL, /* + 0x18 */
3126 const struct iw_handler_def rt28xx_iw_handler_def =
3128 #define N(a) (sizeof (a) / sizeof (a[0]))
3129 .standard = (iw_handler *) rt_handler,
3130 .num_standard = sizeof(rt_handler) / sizeof(iw_handler),
3131 .private = (iw_handler *) rt_priv_handlers,
3132 .num_private = N(rt_priv_handlers),
3133 .private_args = (struct iw_priv_args *) privtab,
3134 .num_private_args = N(privtab),
3135 #if IW_HANDLER_VERSION >= 7
3136 .get_wireless_stats = rt28xx_get_wireless_stats,
3140 INT RTMPSetInformation(
3141 IN PRTMP_ADAPTER pAdapter,
3142 IN OUT struct ifreq *rq,
3145 struct iwreq *wrq = (struct iwreq *) rq;
3146 NDIS_802_11_SSID Ssid;
3147 NDIS_802_11_MAC_ADDRESS Bssid;
3148 RT_802_11_PHY_MODE PhyMode;
3149 RT_802_11_STA_CONFIG StaConfig;
3150 NDIS_802_11_RATES aryRates;
3151 RT_802_11_PREAMBLE Preamble;
3152 NDIS_802_11_WEP_STATUS WepStatus;
3153 NDIS_802_11_AUTHENTICATION_MODE AuthMode = Ndis802_11AuthModeMax;
3154 NDIS_802_11_NETWORK_INFRASTRUCTURE BssType;
3155 NDIS_802_11_RTS_THRESHOLD RtsThresh;
3156 NDIS_802_11_FRAGMENTATION_THRESHOLD FragThresh;
3157 NDIS_802_11_POWER_MODE PowerMode;
3158 PNDIS_802_11_KEY pKey = NULL;
3159 PNDIS_802_11_WEP pWepKey =NULL;
3160 PNDIS_802_11_REMOVE_KEY pRemoveKey = NULL;
3161 NDIS_802_11_CONFIGURATION Config, *pConfig = NULL;
3162 NDIS_802_11_NETWORK_TYPE NetType;
3165 INT Status = NDIS_STATUS_SUCCESS, MaxPhyMode = PHY_11G;
3168 BOOLEAN StateMachineTouched = FALSE;
3169 #ifdef DOT11_N_SUPPORT
3170 OID_SET_HT_PHYMODE HT_PhyMode; //11n ,kathy
3171 #endif // DOT11_N_SUPPORT //
3172 #ifdef WPA_SUPPLICANT_SUPPORT
3173 PNDIS_802_11_PMKID pPmkId = NULL;
3174 BOOLEAN IEEE8021xState = FALSE;
3175 BOOLEAN IEEE8021x_required_keys = FALSE;
3176 UCHAR wpa_supplicant_enable = 0;
3177 #endif // WPA_SUPPLICANT_SUPPORT //
3180 TX_RTY_CFG_STRUC tx_rty_cfg;
3181 ULONG ShortRetryLimit, LongRetryLimit;
3183 #endif // SNMP_SUPPORT //
3187 #ifdef DOT11_N_SUPPORT
3188 MaxPhyMode = PHY_11N_5G;
3189 #endif // DOT11_N_SUPPORT //
3192 DBGPRINT(RT_DEBUG_TRACE, ("-->RTMPSetInformation(), 0x%08x\n", cmd&0x7FFF));
3193 switch(cmd & 0x7FFF) {
3194 case RT_OID_802_11_COUNTRY_REGION:
3195 if (wrq->u.data.length < sizeof(UCHAR))
3197 // Only avaliable when EEPROM not programming
3198 else if (!(pAdapter->CommonCfg.CountryRegion & 0x80) && !(pAdapter->CommonCfg.CountryRegionForABand & 0x80))
3203 Status = copy_from_user(&Country, wrq->u.data.pointer, wrq->u.data.length);
3204 pAdapter->CommonCfg.CountryRegion = (UCHAR)(Country & 0x000000FF);
3205 pAdapter->CommonCfg.CountryRegionForABand = (UCHAR)((Country >> 8) & 0x000000FF);
3206 TmpPhy = pAdapter->CommonCfg.PhyMode;
3207 pAdapter->CommonCfg.PhyMode = 0xff;
3208 // Build all corresponding channel information
3209 RTMPSetPhyMode(pAdapter, TmpPhy);
3210 #ifdef DOT11_N_SUPPORT
3211 SetCommonHT(pAdapter);
3212 #endif // DOT11_N_SUPPORT //
3213 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_COUNTRY_REGION (A:%d B/G:%d)\n", pAdapter->CommonCfg.CountryRegionForABand,
3214 pAdapter->CommonCfg.CountryRegion));
3217 case OID_802_11_BSSID_LIST_SCAN:
3219 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_BSSID_LIST_SCAN, TxCnt = %d \n", pAdapter->RalinkCounters.LastOneSecTotalTxCount));
3221 if (MONITOR_ON(pAdapter))
3223 DBGPRINT(RT_DEBUG_TRACE, ("!!! Driver is in Monitor Mode now !!!\n"));
3227 //Benson add 20080527, when radio off, sta don't need to scan
3228 if (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_RADIO_OFF))
3231 if (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
3233 DBGPRINT(RT_DEBUG_TRACE, ("!!! Driver is scanning now !!!\n"));
3234 pAdapter->StaCfg.bScanReqIsFromWebUI = TRUE;
3235 Status = NDIS_STATUS_SUCCESS;
3239 if (pAdapter->RalinkCounters.LastOneSecTotalTxCount > 100)
3241 DBGPRINT(RT_DEBUG_TRACE, ("!!! Link UP, ignore this set::OID_802_11_BSSID_LIST_SCAN\n"));
3242 Status = NDIS_STATUS_SUCCESS;
3243 pAdapter->StaCfg.ScanCnt = 99; // Prevent auto scan triggered by this OID
3247 if ((OPSTATUS_TEST_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED)) &&
3248 ((pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA) ||
3249 (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK) ||
3250 (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA2) ||
3251 (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK)) &&
3252 (pAdapter->StaCfg.PortSecured == WPA_802_1X_PORT_NOT_SECURED))
3254 DBGPRINT(RT_DEBUG_TRACE, ("!!! Link UP, Port Not Secured! ignore this set::OID_802_11_BSSID_LIST_SCAN\n"));
3255 Status = NDIS_STATUS_SUCCESS;
3256 pAdapter->StaCfg.ScanCnt = 99; // Prevent auto scan triggered by this OID
3261 if (pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE)
3263 RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
3264 DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
3267 // tell CNTL state machine to call NdisMSetInformationComplete() after completing
3268 // this request, because this request is initiated by NDIS.
3269 pAdapter->MlmeAux.CurrReqIsFromNdis = FALSE;
3270 // Reset allowed scan retries
3271 pAdapter->StaCfg.ScanCnt = 0;
3272 pAdapter->StaCfg.LastScanTime = Now;
3274 pAdapter->StaCfg.bScanReqIsFromWebUI = TRUE;
3275 RTMP_SET_FLAG(pAdapter, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS);
3276 MlmeEnqueue(pAdapter,
3277 MLME_CNTL_STATE_MACHINE,
3278 OID_802_11_BSSID_LIST_SCAN,
3282 Status = NDIS_STATUS_SUCCESS;
3283 StateMachineTouched = TRUE;
3285 case OID_802_11_SSID:
3286 if (wrq->u.data.length != sizeof(NDIS_802_11_SSID))
3290 PCHAR pSsidString = NULL;
3291 Status = copy_from_user(&Ssid, wrq->u.data.pointer, wrq->u.data.length);
3293 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_SSID (Len=%d,Ssid=%s)\n", Ssid.SsidLength, Ssid.Ssid));
3294 if (Ssid.SsidLength > MAX_LEN_OF_SSID)
3298 if (Ssid.SsidLength == 0)
3300 Set_SSID_Proc(pAdapter, "");
3304 pSsidString = (CHAR *) kmalloc(MAX_LEN_OF_SSID+1, MEM_ALLOC_FLAG);
3307 NdisZeroMemory(pSsidString, MAX_LEN_OF_SSID+1);
3308 NdisMoveMemory(pSsidString, Ssid.Ssid, Ssid.SsidLength);
3309 Set_SSID_Proc(pAdapter, pSsidString);
3318 case OID_802_11_BSSID:
3319 if (wrq->u.data.length != sizeof(NDIS_802_11_MAC_ADDRESS))
3323 Status = copy_from_user(&Bssid, wrq->u.data.pointer, wrq->u.data.length);
3325 // tell CNTL state machine to call NdisMSetInformationComplete() after completing
3326 // this request, because this request is initiated by NDIS.
3327 pAdapter->MlmeAux.CurrReqIsFromNdis = FALSE;
3329 // Prevent to connect AP again in STAMlmePeriodicExec
3330 pAdapter->MlmeAux.AutoReconnectSsidLen= 32;
3332 // Reset allowed scan retries
3333 pAdapter->StaCfg.ScanCnt = 0;
3335 if (pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE)
3337 RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
3338 DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
3340 MlmeEnqueue(pAdapter,
3341 MLME_CNTL_STATE_MACHINE,
3343 sizeof(NDIS_802_11_MAC_ADDRESS),
3345 Status = NDIS_STATUS_SUCCESS;
3346 StateMachineTouched = TRUE;
3348 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_BSSID %02x:%02x:%02x:%02x:%02x:%02x\n",
3349 Bssid[0], Bssid[1], Bssid[2], Bssid[3], Bssid[4], Bssid[5]));
3352 case RT_OID_802_11_RADIO:
3353 if (wrq->u.data.length != sizeof(BOOLEAN))
3357 Status = copy_from_user(&RadioState, wrq->u.data.pointer, wrq->u.data.length);
3358 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_RADIO (=%d)\n", RadioState));
3359 if (pAdapter->StaCfg.bSwRadio != RadioState)
3361 pAdapter->StaCfg.bSwRadio = RadioState;
3362 if (pAdapter->StaCfg.bRadio != (pAdapter->StaCfg.bHwRadio && pAdapter->StaCfg.bSwRadio))
3364 pAdapter->StaCfg.bRadio = (pAdapter->StaCfg.bHwRadio && pAdapter->StaCfg.bSwRadio);
3365 if (pAdapter->StaCfg.bRadio == TRUE)
3367 MlmeRadioOn(pAdapter);
3368 // Update extra information
3369 pAdapter->ExtraInfo = EXTRA_INFO_CLEAR;
3373 MlmeRadioOff(pAdapter);
3374 // Update extra information
3375 pAdapter->ExtraInfo = SW_RADIO_OFF;
3381 case RT_OID_802_11_PHY_MODE:
3382 if (wrq->u.data.length != sizeof(RT_802_11_PHY_MODE))
3386 Status = copy_from_user(&PhyMode, wrq->u.data.pointer, wrq->u.data.length);
3387 if (PhyMode <= MaxPhyMode)
3389 RTMPSetPhyMode(pAdapter, PhyMode);
3390 #ifdef DOT11_N_SUPPORT
3391 SetCommonHT(pAdapter);
3392 #endif // DOT11_N_SUPPORT //
3394 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_PHY_MODE (=%d)\n", PhyMode));
3397 case RT_OID_802_11_STA_CONFIG:
3398 if (wrq->u.data.length != sizeof(RT_802_11_STA_CONFIG))
3402 Status = copy_from_user(&StaConfig, wrq->u.data.pointer, wrq->u.data.length);
3403 pAdapter->CommonCfg.bEnableTxBurst = StaConfig.EnableTxBurst;
3404 pAdapter->CommonCfg.UseBGProtection = StaConfig.UseBGProtection;
3405 pAdapter->CommonCfg.bUseShortSlotTime = 1; // 2003-10-30 always SHORT SLOT capable
3406 if ((pAdapter->CommonCfg.PhyMode != StaConfig.AdhocMode) &&
3407 (StaConfig.AdhocMode <= MaxPhyMode))
3409 // allow dynamic change of "USE OFDM rate or not" in ADHOC mode
3410 // if setting changed, need to reset current TX rate as well as BEACON frame format
3411 if (pAdapter->StaCfg.BssType == BSS_ADHOC)
3413 pAdapter->CommonCfg.PhyMode = StaConfig.AdhocMode;
3414 RTMPSetPhyMode(pAdapter, PhyMode);
3415 MlmeUpdateTxRates(pAdapter, FALSE, 0);
3416 MakeIbssBeacon(pAdapter); // re-build BEACON frame
3417 AsicEnableIbssSync(pAdapter); // copy to on-chip memory
3420 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_SET_STA_CONFIG (Burst=%d, Protection=%ld,ShortSlot=%d\n",
3421 pAdapter->CommonCfg.bEnableTxBurst,
3422 pAdapter->CommonCfg.UseBGProtection,
3423 pAdapter->CommonCfg.bUseShortSlotTime));
3426 case OID_802_11_DESIRED_RATES:
3427 if (wrq->u.data.length != sizeof(NDIS_802_11_RATES))
3431 Status = copy_from_user(&aryRates, wrq->u.data.pointer, wrq->u.data.length);
3432 NdisZeroMemory(pAdapter->CommonCfg.DesireRate, MAX_LEN_OF_SUPPORTED_RATES);
3433 NdisMoveMemory(pAdapter->CommonCfg.DesireRate, &aryRates, sizeof(NDIS_802_11_RATES));
3434 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_DESIRED_RATES (%02x,%02x,%02x,%02x,%02x,%02x,%02x,%02x)\n",
3435 pAdapter->CommonCfg.DesireRate[0],pAdapter->CommonCfg.DesireRate[1],
3436 pAdapter->CommonCfg.DesireRate[2],pAdapter->CommonCfg.DesireRate[3],
3437 pAdapter->CommonCfg.DesireRate[4],pAdapter->CommonCfg.DesireRate[5],
3438 pAdapter->CommonCfg.DesireRate[6],pAdapter->CommonCfg.DesireRate[7] ));
3439 // Changing DesiredRate may affect the MAX TX rate we used to TX frames out
3440 MlmeUpdateTxRates(pAdapter, FALSE, 0);
3443 case RT_OID_802_11_PREAMBLE:
3444 if (wrq->u.data.length != sizeof(RT_802_11_PREAMBLE))
3448 Status = copy_from_user(&Preamble, wrq->u.data.pointer, wrq->u.data.length);
3449 if (Preamble == Rt802_11PreambleShort)
3451 pAdapter->CommonCfg.TxPreamble = Preamble;
3452 MlmeSetTxPreamble(pAdapter, Rt802_11PreambleShort);
3454 else if ((Preamble == Rt802_11PreambleLong) || (Preamble == Rt802_11PreambleAuto))
3456 // if user wants AUTO, initialize to LONG here, then change according to AP's
3457 // capability upon association.
3458 pAdapter->CommonCfg.TxPreamble = Preamble;
3459 MlmeSetTxPreamble(pAdapter, Rt802_11PreambleLong);
3466 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_PREAMBLE (=%d)\n", Preamble));
3469 case OID_802_11_WEP_STATUS:
3470 if (wrq->u.data.length != sizeof(NDIS_802_11_WEP_STATUS))
3474 Status = copy_from_user(&WepStatus, wrq->u.data.pointer, wrq->u.data.length);
3475 // Since TKIP, AES, WEP are all supported. It should not have any invalid setting
3476 if (WepStatus <= Ndis802_11Encryption3KeyAbsent)
3478 if (pAdapter->StaCfg.WepStatus != WepStatus)
3480 // Config has changed
3481 pAdapter->bConfigChanged = TRUE;
3483 pAdapter->StaCfg.WepStatus = WepStatus;
3484 pAdapter->StaCfg.OrigWepStatus = WepStatus;
3485 pAdapter->StaCfg.PairCipher = WepStatus;
3486 pAdapter->StaCfg.GroupCipher = WepStatus;
3493 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_WEP_STATUS (=%d)\n",WepStatus));
3496 case OID_802_11_AUTHENTICATION_MODE:
3497 if (wrq->u.data.length != sizeof(NDIS_802_11_AUTHENTICATION_MODE))
3501 Status = copy_from_user(&AuthMode, wrq->u.data.pointer, wrq->u.data.length);
3502 if (AuthMode > Ndis802_11AuthModeMax)
3509 if (pAdapter->StaCfg.AuthMode != AuthMode)
3511 // Config has changed
3512 pAdapter->bConfigChanged = TRUE;
3514 pAdapter->StaCfg.AuthMode = AuthMode;
3516 pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED;
3517 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_AUTHENTICATION_MODE (=%d) \n",pAdapter->StaCfg.AuthMode));
3520 case OID_802_11_INFRASTRUCTURE_MODE:
3521 if (wrq->u.data.length != sizeof(NDIS_802_11_NETWORK_INFRASTRUCTURE))
3525 Status = copy_from_user(&BssType, wrq->u.data.pointer, wrq->u.data.length);
3527 if (BssType == Ndis802_11IBSS)
3528 Set_NetworkType_Proc(pAdapter, "Adhoc");
3529 else if (BssType == Ndis802_11Infrastructure)
3530 Set_NetworkType_Proc(pAdapter, "Infra");
3531 else if (BssType == Ndis802_11Monitor)
3532 Set_NetworkType_Proc(pAdapter, "Monitor");
3536 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_INFRASTRUCTURE_MODE (unknown)\n"));
3540 case OID_802_11_REMOVE_WEP:
3541 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_WEP\n"));
3542 if (wrq->u.data.length != sizeof(NDIS_802_11_KEY_INDEX))
3548 KeyIdx = *(NDIS_802_11_KEY_INDEX *) wrq->u.data.pointer;
3550 if (KeyIdx & 0x80000000)
3552 // Should never set default bit when remove key
3557 KeyIdx = KeyIdx & 0x0fffffff;
3563 pAdapter->SharedKey[BSS0][KeyIdx].KeyLen = 0;
3564 pAdapter->SharedKey[BSS0][KeyIdx].CipherAlg = CIPHER_NONE;
3565 AsicRemoveSharedKeyEntry(pAdapter, 0, (UCHAR)KeyIdx);
3570 case RT_OID_802_11_RESET_COUNTERS:
3571 NdisZeroMemory(&pAdapter->WlanCounters, sizeof(COUNTER_802_11));
3572 NdisZeroMemory(&pAdapter->Counters8023, sizeof(COUNTER_802_3));
3573 NdisZeroMemory(&pAdapter->RalinkCounters, sizeof(COUNTER_RALINK));
3574 pAdapter->Counters8023.RxNoBuffer = 0;
3575 pAdapter->Counters8023.GoodReceives = 0;
3576 pAdapter->Counters8023.RxNoBuffer = 0;
3578 pAdapter->BulkOutComplete = 0;
3579 pAdapter->BulkOutCompleteOther= 0;
3580 pAdapter->BulkOutCompleteCancel = 0;
3581 pAdapter->BulkOutReq = 0;
3582 pAdapter->BulkInReq= 0;
3583 pAdapter->BulkInComplete = 0;
3584 pAdapter->BulkInCompleteFail = 0;
3586 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_RESET_COUNTERS \n"));
3588 case OID_802_11_RTS_THRESHOLD:
3589 if (wrq->u.data.length != sizeof(NDIS_802_11_RTS_THRESHOLD))
3593 Status = copy_from_user(&RtsThresh, wrq->u.data.pointer, wrq->u.data.length);
3594 if (RtsThresh > MAX_RTS_THRESHOLD)
3597 pAdapter->CommonCfg.RtsThreshold = (USHORT)RtsThresh;
3599 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_RTS_THRESHOLD (=%ld)\n",RtsThresh));
3601 case OID_802_11_FRAGMENTATION_THRESHOLD:
3602 if (wrq->u.data.length != sizeof(NDIS_802_11_FRAGMENTATION_THRESHOLD))
3606 Status = copy_from_user(&FragThresh, wrq->u.data.pointer, wrq->u.data.length);
3607 pAdapter->CommonCfg.bUseZeroToDisableFragment = FALSE;
3608 if (FragThresh > MAX_FRAG_THRESHOLD || FragThresh < MIN_FRAG_THRESHOLD)
3610 if (FragThresh == 0)
3612 pAdapter->CommonCfg.FragmentThreshold = MAX_FRAG_THRESHOLD;
3613 pAdapter->CommonCfg.bUseZeroToDisableFragment = TRUE;
3619 pAdapter->CommonCfg.FragmentThreshold = (USHORT)FragThresh;
3621 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_FRAGMENTATION_THRESHOLD (=%ld) \n",FragThresh));
3623 case OID_802_11_POWER_MODE:
3624 if (wrq->u.data.length != sizeof(NDIS_802_11_POWER_MODE))
3628 Status = copy_from_user(&PowerMode, wrq->u.data.pointer, wrq->u.data.length);
3629 if (PowerMode == Ndis802_11PowerModeCAM)
3630 Set_PSMode_Proc(pAdapter, "CAM");
3631 else if (PowerMode == Ndis802_11PowerModeMAX_PSP)
3632 Set_PSMode_Proc(pAdapter, "Max_PSP");
3633 else if (PowerMode == Ndis802_11PowerModeFast_PSP)
3634 Set_PSMode_Proc(pAdapter, "Fast_PSP");
3635 else if (PowerMode == Ndis802_11PowerModeLegacy_PSP)
3636 Set_PSMode_Proc(pAdapter, "Legacy_PSP");
3640 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_POWER_MODE (=%d)\n",PowerMode));
3642 case RT_OID_802_11_TX_POWER_LEVEL_1:
3643 if (wrq->u.data.length < sizeof(ULONG))
3647 Status = copy_from_user(&PowerTemp, wrq->u.data.pointer, wrq->u.data.length);
3648 if (PowerTemp > 100)
3649 PowerTemp = 0xffffffff; // AUTO
3650 pAdapter->CommonCfg.TxPowerDefault = PowerTemp; //keep current setting.
3651 pAdapter->CommonCfg.TxPowerPercentage = pAdapter->CommonCfg.TxPowerDefault;
3652 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_TX_POWER_LEVEL_1 (=%ld)\n", pAdapter->CommonCfg.TxPowerPercentage));
3655 case OID_802_11_NETWORK_TYPE_IN_USE:
3656 if (wrq->u.data.length != sizeof(NDIS_802_11_NETWORK_TYPE))
3660 Status = copy_from_user(&NetType, wrq->u.data.pointer, wrq->u.data.length);
3662 if (NetType == Ndis802_11DS)
3663 RTMPSetPhyMode(pAdapter, PHY_11B);
3664 else if (NetType == Ndis802_11OFDM24)
3665 RTMPSetPhyMode(pAdapter, PHY_11BG_MIXED);
3666 else if (NetType == Ndis802_11OFDM5)
3667 RTMPSetPhyMode(pAdapter, PHY_11A);
3670 #ifdef DOT11_N_SUPPORT
3671 if (Status == NDIS_STATUS_SUCCESS)
3672 SetCommonHT(pAdapter);
3673 #endif // DOT11_N_SUPPORT //
3674 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_NETWORK_TYPE_IN_USE (=%d)\n",NetType));
3677 // For WPA PSK PMK key
3678 case RT_OID_802_11_ADD_WPA:
3679 pKey = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
3686 Status = copy_from_user(pKey, wrq->u.data.pointer, wrq->u.data.length);
3687 if (pKey->Length != wrq->u.data.length)
3690 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_ADD_WPA, Failed!!\n"));
3694 if ((pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPAPSK) &&
3695 (pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPA2PSK) &&
3696 (pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPANone) )
3698 Status = -EOPNOTSUPP;
3699 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_ADD_WPA, Failed!! [AuthMode != WPAPSK/WPA2PSK/WPANONE]\n"));
3701 else if ((pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK) ||
3702 (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK) ||
3703 (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPANone) ) // Only for WPA PSK mode
3705 NdisMoveMemory(pAdapter->StaCfg.PMK, &pKey->KeyMaterial, pKey->KeyLength);
3706 // Use RaConfig as PSK agent.
3707 // Start STA supplicant state machine
3708 if (pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPANone)
3709 pAdapter->StaCfg.WpaState = SS_START;
3711 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_ADD_WPA (id=0x%x, Len=%d-byte)\n", pKey->KeyIndex, pKey->KeyLength));
3715 pAdapter->StaCfg.WpaState = SS_NOTUSE;
3716 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_ADD_WPA (id=0x%x, Len=%d-byte)\n", pKey->KeyIndex, pKey->KeyLength));
3721 case OID_802_11_REMOVE_KEY:
3722 pRemoveKey = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
3723 if(pRemoveKey == NULL)
3729 Status = copy_from_user(pRemoveKey, wrq->u.data.pointer, wrq->u.data.length);
3730 if (pRemoveKey->Length != wrq->u.data.length)
3733 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_KEY, Failed!!\n"));
3737 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
3739 RTMPWPARemoveKeyProc(pAdapter, pRemoveKey);
3740 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_KEY, Remove WPA Key!!\n"));
3744 KeyIdx = pRemoveKey->KeyIndex;
3746 if (KeyIdx & 0x80000000)
3748 // Should never set default bit when remove key
3750 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_KEY, Failed!!(Should never set default bit when remove key)\n"));
3754 KeyIdx = KeyIdx & 0x0fffffff;
3758 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_KEY, Failed!!(KeyId[%d] out of range)\n", KeyIdx));
3762 pAdapter->SharedKey[BSS0][KeyIdx].KeyLen = 0;
3763 pAdapter->SharedKey[BSS0][KeyIdx].CipherAlg = CIPHER_NONE;
3764 AsicRemoveSharedKeyEntry(pAdapter, 0, (UCHAR)KeyIdx);
3765 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_KEY (id=0x%x, Len=%d-byte)\n", pRemoveKey->KeyIndex, pRemoveKey->Length));
3773 case OID_802_11_ADD_KEY:
3774 pKey = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
3780 Status = copy_from_user(pKey, wrq->u.data.pointer, wrq->u.data.length);
3781 if (pKey->Length != wrq->u.data.length)
3784 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_KEY, Failed!!\n"));
3788 RTMPAddKey(pAdapter, pKey);
3789 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_KEY (id=0x%x, Len=%d-byte)\n", pKey->KeyIndex, pKey->KeyLength));
3793 case OID_802_11_CONFIGURATION:
3794 if (wrq->u.data.length != sizeof(NDIS_802_11_CONFIGURATION))
3798 Status = copy_from_user(&Config, wrq->u.data.pointer, wrq->u.data.length);
3801 if ((pConfig->BeaconPeriod >= 20) && (pConfig->BeaconPeriod <=400))
3802 pAdapter->CommonCfg.BeaconPeriod = (USHORT) pConfig->BeaconPeriod;
3804 pAdapter->StaActive.AtimWin = (USHORT) pConfig->ATIMWindow;
3805 MAP_KHZ_TO_CHANNEL_ID(pConfig->DSConfig, pAdapter->CommonCfg.Channel);
3807 // Save the channel on MlmeAux for CntlOidRTBssidProc used.
3809 pAdapter->MlmeAux.Channel = pAdapter->CommonCfg.Channel;
3811 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_CONFIGURATION (BeacnPeriod=%ld,AtimW=%ld,Ch=%d)\n",
3812 pConfig->BeaconPeriod, pConfig->ATIMWindow, pAdapter->CommonCfg.Channel));
3813 // Config has changed
3814 pAdapter->bConfigChanged = TRUE;
3817 #ifdef DOT11_N_SUPPORT
3818 case RT_OID_802_11_SET_HT_PHYMODE:
3819 if (wrq->u.data.length != sizeof(OID_SET_HT_PHYMODE))
3823 POID_SET_HT_PHYMODE pHTPhyMode = &HT_PhyMode;
3825 Status = copy_from_user(&HT_PhyMode, wrq->u.data.pointer, wrq->u.data.length);
3826 DBGPRINT(RT_DEBUG_TRACE, ("Set::pHTPhyMode (PhyMode = %d,TransmitNo = %d, HtMode = %d, ExtOffset = %d , MCS = %d, BW = %d, STBC = %d, SHORTGI = %d) \n",
3827 pHTPhyMode->PhyMode, pHTPhyMode->TransmitNo,pHTPhyMode->HtMode,pHTPhyMode->ExtOffset,
3828 pHTPhyMode->MCS, pHTPhyMode->BW, pHTPhyMode->STBC, pHTPhyMode->SHORTGI));
3829 if (pAdapter->CommonCfg.PhyMode >= PHY_11ABGN_MIXED)
3830 RTMPSetHT(pAdapter, pHTPhyMode);
3832 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_SET_HT_PHYMODE(MCS=%d,BW=%d,SGI=%d,STBC=%d)\n",
3833 pAdapter->StaCfg.HTPhyMode.field.MCS, pAdapter->StaCfg.HTPhyMode.field.BW, pAdapter->StaCfg.HTPhyMode.field.ShortGI,
3834 pAdapter->StaCfg.HTPhyMode.field.STBC));
3836 #endif // DOT11_N_SUPPORT //
3837 case RT_OID_802_11_SET_APSD_SETTING:
3838 if (wrq->u.data.length != sizeof(ULONG))
3843 Status = copy_from_user(&apsd, wrq->u.data.pointer, wrq->u.data.length);
3845 /*-------------------------------------------------------------------
3846 |B31~B7 | B6~B5 | B4 | B3 | B2 | B1 | B0 |
3847 ---------------------------------------------------------------------
3848 | Rsvd | Max SP Len | AC_VO | AC_VI | AC_BK | AC_BE | APSD Capable |
3849 ---------------------------------------------------------------------*/
3850 pAdapter->CommonCfg.bAPSDCapable = (apsd & 0x00000001) ? TRUE : FALSE;
3851 pAdapter->CommonCfg.bAPSDAC_BE = ((apsd & 0x00000002) >> 1) ? TRUE : FALSE;
3852 pAdapter->CommonCfg.bAPSDAC_BK = ((apsd & 0x00000004) >> 2) ? TRUE : FALSE;
3853 pAdapter->CommonCfg.bAPSDAC_VI = ((apsd & 0x00000008) >> 3) ? TRUE : FALSE;
3854 pAdapter->CommonCfg.bAPSDAC_VO = ((apsd & 0x00000010) >> 4) ? TRUE : FALSE;
3855 pAdapter->CommonCfg.MaxSPLength = (UCHAR)((apsd & 0x00000060) >> 5);
3857 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,
3858 pAdapter->CommonCfg.bAPSDAC_BE, pAdapter->CommonCfg.bAPSDAC_BK, pAdapter->CommonCfg.bAPSDAC_VI, pAdapter->CommonCfg.bAPSDAC_VO, pAdapter->CommonCfg.MaxSPLength));
3862 case RT_OID_802_11_SET_APSD_PSM:
3863 if (wrq->u.data.length != sizeof(ULONG))
3867 // Driver needs to notify AP when PSM changes
3868 Status = copy_from_user(&pAdapter->CommonCfg.bAPSDForcePowerSave, wrq->u.data.pointer, wrq->u.data.length);
3869 if (pAdapter->CommonCfg.bAPSDForcePowerSave != pAdapter->StaCfg.Psm)
3871 MlmeSetPsmBit(pAdapter, pAdapter->CommonCfg.bAPSDForcePowerSave);
3872 RTMPSendNullFrame(pAdapter, pAdapter->CommonCfg.TxRate, TRUE);
3874 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_SET_APSD_PSM (bAPSDForcePowerSave:%d)\n", pAdapter->CommonCfg.bAPSDForcePowerSave));
3877 #ifdef QOS_DLS_SUPPORT
3878 case RT_OID_802_11_SET_DLS:
3879 if (wrq->u.data.length != sizeof(ULONG))
3883 BOOLEAN oldvalue = pAdapter->CommonCfg.bDLSCapable;
3884 Status = copy_from_user(&pAdapter->CommonCfg.bDLSCapable, wrq->u.data.pointer, wrq->u.data.length);
3885 if (oldvalue && !pAdapter->CommonCfg.bDLSCapable)
3888 // tear down local dls table entry
3889 for (i=0; i<MAX_NUM_OF_INIT_DLS_ENTRY; i++)
3891 if (pAdapter->StaCfg.DLSEntry[i].Valid && (pAdapter->StaCfg.DLSEntry[i].Status == DLS_FINISH))
3893 pAdapter->StaCfg.DLSEntry[i].Status = DLS_NONE;
3894 pAdapter->StaCfg.DLSEntry[i].Valid = FALSE;
3895 RTMPSendDLSTearDownFrame(pAdapter, pAdapter->StaCfg.DLSEntry[i].MacAddr);
3899 // tear down peer dls table entry
3900 for (i=MAX_NUM_OF_INIT_DLS_ENTRY; i<MAX_NUM_OF_DLS_ENTRY; i++)
3902 if (pAdapter->StaCfg.DLSEntry[i].Valid && (pAdapter->StaCfg.DLSEntry[i].Status == DLS_FINISH))
3904 pAdapter->StaCfg.DLSEntry[i].Status = DLS_NONE;
3905 pAdapter->StaCfg.DLSEntry[i].Valid = FALSE;
3906 RTMPSendDLSTearDownFrame(pAdapter, pAdapter->StaCfg.DLSEntry[i].MacAddr);
3911 DBGPRINT(RT_DEBUG_TRACE,("Set::RT_OID_802_11_SET_DLS (=%d)\n", pAdapter->CommonCfg.bDLSCapable));
3915 case RT_OID_802_11_SET_DLS_PARAM:
3916 if (wrq->u.data.length != sizeof(RT_802_11_DLS_UI))
3922 NdisZeroMemory(&Dls, sizeof(RT_802_11_DLS));
3923 RTMPMoveMemory(&Dls, wrq->u.data.pointer, sizeof(RT_802_11_DLS_UI));
3924 MlmeEnqueue(pAdapter,
3925 MLME_CNTL_STATE_MACHINE,
3926 RT_OID_802_11_SET_DLS_PARAM,
3927 sizeof(RT_802_11_DLS),
3929 DBGPRINT(RT_DEBUG_TRACE,("Set::RT_OID_802_11_SET_DLS_PARAM \n"));
3932 #endif // QOS_DLS_SUPPORT //
3933 case RT_OID_802_11_SET_WMM:
3934 if (wrq->u.data.length != sizeof(BOOLEAN))
3938 Status = copy_from_user(&pAdapter->CommonCfg.bWmmCapable, wrq->u.data.pointer, wrq->u.data.length);
3939 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_SET_WMM (=%d) \n", pAdapter->CommonCfg.bWmmCapable));
3943 case OID_802_11_DISASSOCIATE:
3945 // Set NdisRadioStateOff to TRUE, instead of called MlmeRadioOff.
3946 // Later on, NDIS_802_11_BSSID_LIST_EX->NumberOfItems should be 0
3947 // when query OID_802_11_BSSID_LIST.
3949 // TRUE: NumberOfItems will set to 0.
3950 // FALSE: NumberOfItems no change.
3952 pAdapter->CommonCfg.NdisRadioStateOff = TRUE;
3953 // Set to immediately send the media disconnect event
3954 pAdapter->MlmeAux.CurrReqIsFromNdis = TRUE;
3955 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_DISASSOCIATE \n"));
3957 if (INFRA_ON(pAdapter))
3959 if (pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE)
3961 RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
3962 DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
3965 MlmeEnqueue(pAdapter,
3966 MLME_CNTL_STATE_MACHINE,
3967 OID_802_11_DISASSOCIATE,
3971 StateMachineTouched = TRUE;
3975 #ifdef DOT11_N_SUPPORT
3976 case RT_OID_802_11_SET_IMME_BA_CAP:
3977 if (wrq->u.data.length != sizeof(OID_BACAP_STRUC))
3981 OID_BACAP_STRUC Orde ;
3982 Status = copy_from_user(&Orde, wrq->u.data.pointer, wrq->u.data.length);
3983 if (Orde.Policy > BA_NOTUSE)
3985 Status = NDIS_STATUS_INVALID_DATA;
3987 else if (Orde.Policy == BA_NOTUSE)
3989 pAdapter->CommonCfg.BACapability.field.Policy = BA_NOTUSE;
3990 pAdapter->CommonCfg.BACapability.field.MpduDensity = Orde.MpduDensity;
3991 pAdapter->CommonCfg.DesiredHtPhy.MpduDensity = Orde.MpduDensity;
3992 pAdapter->CommonCfg.DesiredHtPhy.AmsduEnable = Orde.AmsduEnable;
3993 pAdapter->CommonCfg.DesiredHtPhy.AmsduSize= Orde.AmsduSize;
3994 pAdapter->CommonCfg.DesiredHtPhy.MimoPs= Orde.MMPSmode;
3995 pAdapter->CommonCfg.BACapability.field.MMPSmode = Orde.MMPSmode;
3997 pAdapter->CommonCfg.HtCapability.HtCapInfo.MimoPs = Orde.MMPSmode;
3998 pAdapter->CommonCfg.HtCapability.HtCapInfo.AMsduSize = Orde.AmsduSize;
3999 pAdapter->CommonCfg.HtCapability.HtCapParm.MpduDensity = Orde.MpduDensity;
4003 pAdapter->CommonCfg.BACapability.field.AutoBA = Orde.AutoBA;
4004 pAdapter->CommonCfg.BACapability.field.Policy = IMMED_BA; // we only support immediate BA.
4005 pAdapter->CommonCfg.BACapability.field.MpduDensity = Orde.MpduDensity;
4006 pAdapter->CommonCfg.DesiredHtPhy.MpduDensity = Orde.MpduDensity;
4007 pAdapter->CommonCfg.DesiredHtPhy.AmsduEnable = Orde.AmsduEnable;
4008 pAdapter->CommonCfg.DesiredHtPhy.AmsduSize= Orde.AmsduSize;
4009 pAdapter->CommonCfg.DesiredHtPhy.MimoPs = Orde.MMPSmode;
4010 pAdapter->CommonCfg.BACapability.field.MMPSmode = Orde.MMPSmode;
4013 pAdapter->CommonCfg.HtCapability.HtCapInfo.MimoPs = Orde.MMPSmode;
4014 pAdapter->CommonCfg.HtCapability.HtCapInfo.AMsduSize = Orde.AmsduSize;
4015 pAdapter->CommonCfg.HtCapability.HtCapParm.MpduDensity = Orde.MpduDensity;
4017 if (pAdapter->CommonCfg.BACapability.field.RxBAWinLimit > MAX_RX_REORDERBUF)
4018 pAdapter->CommonCfg.BACapability.field.RxBAWinLimit = MAX_RX_REORDERBUF;
4022 pAdapter->CommonCfg.REGBACapability.word = pAdapter->CommonCfg.BACapability.word;
4023 DBGPRINT(RT_DEBUG_TRACE, ("Set::(Orde.AutoBA = %d) (Policy=%d)(ReBAWinLimit=%d)(TxBAWinLimit=%d)(AutoMode=%d)\n",Orde.AutoBA, pAdapter->CommonCfg.BACapability.field.Policy,
4024 pAdapter->CommonCfg.BACapability.field.RxBAWinLimit,pAdapter->CommonCfg.BACapability.field.TxBAWinLimit, pAdapter->CommonCfg.BACapability.field.AutoBA));
4025 DBGPRINT(RT_DEBUG_TRACE, ("Set::(MimoPs = %d)(AmsduEnable = %d) (AmsduSize=%d)(MpduDensity=%d)\n",pAdapter->CommonCfg.DesiredHtPhy.MimoPs, pAdapter->CommonCfg.DesiredHtPhy.AmsduEnable,
4026 pAdapter->CommonCfg.DesiredHtPhy.AmsduSize, pAdapter->CommonCfg.DesiredHtPhy.MpduDensity));
4030 case RT_OID_802_11_ADD_IMME_BA:
4031 DBGPRINT(RT_DEBUG_TRACE, (" Set :: RT_OID_802_11_ADD_IMME_BA \n"));
4032 if (wrq->u.data.length != sizeof(OID_ADD_BA_ENTRY))
4037 OID_ADD_BA_ENTRY BA;
4038 MAC_TABLE_ENTRY *pEntry;
4040 Status = copy_from_user(&BA, wrq->u.data.pointer, wrq->u.data.length);
4043 Status = NDIS_STATUS_INVALID_DATA;
4048 //BATableInsertEntry
4049 //As ad-hoc mode, BA pair is not limited to only BSSID. so add via OID.
4051 // in ad hoc mode, when adding BA pair, we should insert this entry into MACEntry too
4052 pEntry = MacTableLookup(pAdapter, BA.MACAddr);
4055 DBGPRINT(RT_DEBUG_TRACE, ("RT_OID_802_11_ADD_IMME_BA. break on no connection.----:%x:%x\n", BA.MACAddr[4], BA.MACAddr[5]));
4058 if (BA.IsRecipient == FALSE)
4060 if (pEntry->bIAmBadAtheros == TRUE)
4061 pAdapter->CommonCfg.BACapability.field.RxBAWinLimit = 0x10;
4063 BAOriSessionSetUp(pAdapter, pEntry, index, 0, 100, TRUE);
4067 //BATableInsertEntry(pAdapter, pEntry->Aid, BA.MACAddr, 0, 0xffff, BA.TID, BA.nMSDU, BA.IsRecipient);
4070 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_ADD_IMME_BA. Rec = %d. Mac = %x:%x:%x:%x:%x:%x . \n",
4071 BA.IsRecipient, BA.MACAddr[0], BA.MACAddr[1], BA.MACAddr[2], BA.MACAddr[2]
4072 , BA.MACAddr[4], BA.MACAddr[5]));
4077 case RT_OID_802_11_TEAR_IMME_BA:
4078 DBGPRINT(RT_DEBUG_TRACE, ("Set :: RT_OID_802_11_TEAR_IMME_BA \n"));
4079 if (wrq->u.data.length != sizeof(OID_ADD_BA_ENTRY))
4083 POID_ADD_BA_ENTRY pBA;
4084 MAC_TABLE_ENTRY *pEntry;
4086 pBA = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
4090 DBGPRINT(RT_DEBUG_TRACE, ("Set :: RT_OID_802_11_TEAR_IMME_BA kmalloc() can't allocate enough memory\n"));
4091 Status = NDIS_STATUS_FAILURE;
4095 Status = copy_from_user(pBA, wrq->u.data.pointer, wrq->u.data.length);
4096 DBGPRINT(RT_DEBUG_TRACE, ("Set :: RT_OID_802_11_TEAR_IMME_BA(TID=%d, bAllTid=%d)\n", pBA->TID, pBA->bAllTid));
4098 if (!pBA->bAllTid && (pBA->TID > NUM_OF_TID))
4100 Status = NDIS_STATUS_INVALID_DATA;
4104 if (pBA->IsRecipient == FALSE)
4106 pEntry = MacTableLookup(pAdapter, pBA->MACAddr);
4107 DBGPRINT(RT_DEBUG_TRACE, (" pBA->IsRecipient == FALSE\n"));
4110 DBGPRINT(RT_DEBUG_TRACE, (" pBA->pEntry\n"));
4111 BAOriSessionTearDown(pAdapter, pEntry->Aid, pBA->TID, FALSE, TRUE);
4114 DBGPRINT(RT_DEBUG_TRACE, ("Set :: Not found pEntry \n"));
4118 pEntry = MacTableLookup(pAdapter, pBA->MACAddr);
4121 BARecSessionTearDown( pAdapter, (UCHAR)pEntry->Aid, pBA->TID, TRUE);
4124 DBGPRINT(RT_DEBUG_TRACE, ("Set :: Not found pEntry \n"));
4130 #endif // DOT11_N_SUPPORT //
4132 // For WPA_SUPPLICANT to set static wep key
4133 case OID_802_11_ADD_WEP:
4134 pWepKey = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
4139 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_WEP, Failed!!\n"));
4142 Status = copy_from_user(pWepKey, wrq->u.data.pointer, wrq->u.data.length);
4146 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_WEP, Failed (length mismatch)!!\n"));
4150 KeyIdx = pWepKey->KeyIndex & 0x0fffffff;
4151 // KeyIdx must be 0 ~ 3
4155 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_WEP, Failed (KeyIdx must be smaller than 4)!!\n"));
4159 UCHAR CipherAlg = 0;
4162 // set key material and key length
4163 NdisZeroMemory(pAdapter->SharedKey[BSS0][KeyIdx].Key, 16);
4164 pAdapter->SharedKey[BSS0][KeyIdx].KeyLen = (UCHAR) pWepKey->KeyLength;
4165 NdisMoveMemory(pAdapter->SharedKey[BSS0][KeyIdx].Key, &pWepKey->KeyMaterial, pWepKey->KeyLength);
4167 switch(pWepKey->KeyLength)
4170 CipherAlg = CIPHER_WEP64;
4173 CipherAlg = CIPHER_WEP128;
4176 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_WEP, only support CIPHER_WEP64(len:5) & CIPHER_WEP128(len:13)!!\n"));
4180 pAdapter->SharedKey[BSS0][KeyIdx].CipherAlg = CipherAlg;
4182 // Default key for tx (shared key)
4183 if (pWepKey->KeyIndex & 0x80000000)
4185 #ifdef WPA_SUPPLICANT_SUPPORT
4186 // set key material and key length
4187 NdisZeroMemory(pAdapter->StaCfg.DesireSharedKey[KeyIdx].Key, 16);
4188 pAdapter->StaCfg.DesireSharedKey[KeyIdx].KeyLen = (UCHAR) pWepKey->KeyLength;
4189 NdisMoveMemory(pAdapter->StaCfg.DesireSharedKey[KeyIdx].Key, &pWepKey->KeyMaterial, pWepKey->KeyLength);
4190 pAdapter->StaCfg.DesireSharedKeyId = KeyIdx;
4191 pAdapter->StaCfg.DesireSharedKey[KeyIdx].CipherAlg = CipherAlg;
4192 #endif // WPA_SUPPLICANT_SUPPORT //
4193 pAdapter->StaCfg.DefaultKeyId = (UCHAR) KeyIdx;
4196 #ifdef WPA_SUPPLICANT_SUPPORT
4197 if ((pAdapter->StaCfg.WpaSupplicantUP != WPA_SUPPLICANT_DISABLE) &&
4198 (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA))
4200 Key = pWepKey->KeyMaterial;
4202 // Set Group key material to Asic
4203 AsicAddSharedKeyEntry(pAdapter, BSS0, KeyIdx, CipherAlg, Key, NULL, NULL);
4205 // Update WCID attribute table and IVEIV table for this group key table
4206 RTMPAddWcidAttributeEntry(pAdapter, BSS0, KeyIdx, CipherAlg, NULL);
4208 STA_PORT_SECURED(pAdapter);
4210 // Indicate Connected for GUI
4211 pAdapter->IndicateMediaState = NdisMediaStateConnected;
4213 else if (pAdapter->StaCfg.PortSecured == WPA_802_1X_PORT_SECURED)
4214 #endif // WPA_SUPPLICANT_SUPPORT
4216 Key = pAdapter->SharedKey[BSS0][KeyIdx].Key;
4218 // Set key material and cipherAlg to Asic
4219 AsicAddSharedKeyEntry(pAdapter, BSS0, KeyIdx, CipherAlg, Key, NULL, NULL);
4221 if (pWepKey->KeyIndex & 0x80000000)
4223 PMAC_TABLE_ENTRY pEntry = &pAdapter->MacTab.Content[BSSID_WCID];
4224 // Assign group key info
4225 RTMPAddWcidAttributeEntry(pAdapter, BSS0, KeyIdx, CipherAlg, NULL);
4226 // Assign pairwise key info
4227 RTMPAddWcidAttributeEntry(pAdapter, BSS0, KeyIdx, CipherAlg, pEntry);
4230 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"));
4235 #ifdef WPA_SUPPLICANT_SUPPORT
4236 case OID_SET_COUNTERMEASURES:
4237 if (wrq->u.data.length != sizeof(int))
4242 Status = copy_from_user(&enabled, wrq->u.data.pointer, wrq->u.data.length);
4244 pAdapter->StaCfg.bBlockAssoc = TRUE;
4246 // WPA MIC error should block association attempt for 60 seconds
4247 pAdapter->StaCfg.bBlockAssoc = FALSE;
4248 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_SET_COUNTERMEASURES bBlockAssoc=%s\n", pAdapter->StaCfg.bBlockAssoc ? "TRUE":"FALSE"));
4251 case RT_OID_WPA_SUPPLICANT_SUPPORT:
4252 if (wrq->u.data.length != sizeof(UCHAR))
4256 Status = copy_from_user(&wpa_supplicant_enable, wrq->u.data.pointer, wrq->u.data.length);
4257 pAdapter->StaCfg.WpaSupplicantUP = wpa_supplicant_enable;
4258 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_WPA_SUPPLICANT_SUPPORT (=%d)\n", pAdapter->StaCfg.WpaSupplicantUP));
4261 case OID_802_11_DEAUTHENTICATION:
4262 if (wrq->u.data.length != sizeof(MLME_DEAUTH_REQ_STRUCT))
4266 MLME_DEAUTH_REQ_STRUCT *pInfo;
4267 MLME_QUEUE_ELEM *MsgElem = (MLME_QUEUE_ELEM *) kmalloc(sizeof(MLME_QUEUE_ELEM), MEM_ALLOC_FLAG);
4269 pInfo = (MLME_DEAUTH_REQ_STRUCT *) MsgElem->Msg;
4270 Status = copy_from_user(pInfo, wrq->u.data.pointer, wrq->u.data.length);
4271 MlmeDeauthReqAction(pAdapter, MsgElem);
4274 if (INFRA_ON(pAdapter))
4276 LinkDown(pAdapter, FALSE);
4277 pAdapter->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
4279 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_DEAUTHENTICATION (Reason=%d)\n", pInfo->Reason));
4282 case OID_802_11_DROP_UNENCRYPTED:
4283 if (wrq->u.data.length != sizeof(int))
4288 Status = copy_from_user(&enabled, wrq->u.data.pointer, wrq->u.data.length);
4290 pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED;
4292 pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
4293 NdisAcquireSpinLock(&pAdapter->MacTabLock);
4294 pAdapter->MacTab.Content[BSSID_WCID].PortSecured = pAdapter->StaCfg.PortSecured;
4295 NdisReleaseSpinLock(&pAdapter->MacTabLock);
4296 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_DROP_UNENCRYPTED (=%d)\n", enabled));
4299 case OID_802_11_SET_IEEE8021X:
4300 if (wrq->u.data.length != sizeof(BOOLEAN))
4304 Status = copy_from_user(&IEEE8021xState, wrq->u.data.pointer, wrq->u.data.length);
4305 pAdapter->StaCfg.IEEE8021X = IEEE8021xState;
4306 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_SET_IEEE8021X (=%d)\n", IEEE8021xState));
4309 case OID_802_11_SET_IEEE8021X_REQUIRE_KEY:
4310 if (wrq->u.data.length != sizeof(BOOLEAN))
4314 Status = copy_from_user(&IEEE8021x_required_keys, wrq->u.data.pointer, wrq->u.data.length);
4315 pAdapter->StaCfg.IEEE8021x_required_keys = IEEE8021x_required_keys;
4316 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_SET_IEEE8021X_REQUIRE_KEY (%d)\n", IEEE8021x_required_keys));
4319 case OID_802_11_PMKID:
4320 pPmkId = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
4322 if(pPmkId == NULL) {
4326 Status = copy_from_user(pPmkId, wrq->u.data.pointer, wrq->u.data.length);
4328 // check the PMKID information
4329 if (pPmkId->BSSIDInfoCount == 0)
4330 NdisZeroMemory(pAdapter->StaCfg.SavedPMK, sizeof(BSSID_INFO)*PMKID_NO);
4333 PBSSID_INFO pBssIdInfo;
4337 for (BssIdx = 0; BssIdx < pPmkId->BSSIDInfoCount; BssIdx++)
4339 // point to the indexed BSSID_INFO structure
4340 pBssIdInfo = (PBSSID_INFO) ((PUCHAR) pPmkId + 2 * sizeof(UINT) + BssIdx * sizeof(BSSID_INFO));
4341 // Find the entry in the saved data base.
4342 for (CachedIdx = 0; CachedIdx < pAdapter->StaCfg.SavedPMKNum; CachedIdx++)
4344 // compare the BSSID
4345 if (NdisEqualMemory(pBssIdInfo->BSSID, pAdapter->StaCfg.SavedPMK[CachedIdx].BSSID, sizeof(NDIS_802_11_MAC_ADDRESS)))
4349 // Found, replace it
4350 if (CachedIdx < PMKID_NO)
4352 DBGPRINT(RT_DEBUG_OFF, ("Update OID_802_11_PMKID, idx = %d\n", CachedIdx));
4353 NdisMoveMemory(&pAdapter->StaCfg.SavedPMK[CachedIdx], pBssIdInfo, sizeof(BSSID_INFO));
4354 pAdapter->StaCfg.SavedPMKNum++;
4356 // Not found, replace the last one
4359 // Randomly replace one
4360 CachedIdx = (pBssIdInfo->BSSID[5] % PMKID_NO);
4361 DBGPRINT(RT_DEBUG_OFF, ("Update OID_802_11_PMKID, idx = %d\n", CachedIdx));
4362 NdisMoveMemory(&pAdapter->StaCfg.SavedPMK[CachedIdx], pBssIdInfo, sizeof(BSSID_INFO));
4369 #endif // WPA_SUPPLICANT_SUPPORT //
4374 case OID_802_11_SHORTRETRYLIMIT:
4375 if (wrq->u.data.length != sizeof(ULONG))
4379 Status = copy_from_user(&ShortRetryLimit, wrq->u.data.pointer, wrq->u.data.length);
4380 RTMP_IO_READ32(pAdapter, TX_RTY_CFG, &tx_rty_cfg.word);
4381 tx_rty_cfg.field.ShortRtyLimit = ShortRetryLimit;
4382 RTMP_IO_WRITE32(pAdapter, TX_RTY_CFG, tx_rty_cfg.word);
4383 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_SHORTRETRYLIMIT (tx_rty_cfg.field.ShortRetryLimit=%d, ShortRetryLimit=%ld)\n", tx_rty_cfg.field.ShortRtyLimit, ShortRetryLimit));
4387 case OID_802_11_LONGRETRYLIMIT:
4388 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_LONGRETRYLIMIT \n"));
4389 if (wrq->u.data.length != sizeof(ULONG))
4393 Status = copy_from_user(&LongRetryLimit, wrq->u.data.pointer, wrq->u.data.length);
4394 RTMP_IO_READ32(pAdapter, TX_RTY_CFG, &tx_rty_cfg.word);
4395 tx_rty_cfg.field.LongRtyLimit = LongRetryLimit;
4396 RTMP_IO_WRITE32(pAdapter, TX_RTY_CFG, tx_rty_cfg.word);
4397 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_LONGRETRYLIMIT (tx_rty_cfg.field.LongRetryLimit= %d,LongRetryLimit=%ld)\n", tx_rty_cfg.field.LongRtyLimit, LongRetryLimit));
4401 case OID_802_11_WEPDEFAULTKEYVALUE:
4402 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_WEPDEFAULTKEYVALUE\n"));
4403 pKey = kmalloc(wrq->u.data.length, GFP_KERNEL);
4404 Status = copy_from_user(pKey, wrq->u.data.pointer, wrq->u.data.length);
4407 if ( pKey->Length != wrq->u.data.length)
4410 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_WEPDEFAULTKEYVALUE, Failed!!\n"));
4412 KeyIdx = pKey->KeyIndex & 0x0fffffff;
4413 DBGPRINT(RT_DEBUG_TRACE,("pKey->KeyIndex =%d, pKey->KeyLength=%d\n", pKey->KeyIndex, pKey->KeyLength));
4415 // it is a shared key
4420 pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].KeyLen = (UCHAR) pKey->KeyLength;
4421 NdisMoveMemory(&pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].Key, &pKey->KeyMaterial, pKey->KeyLength);
4422 if (pKey->KeyIndex & 0x80000000)
4424 // Default key for tx (shared key)
4425 pAdapter->StaCfg.DefaultKeyId = (UCHAR) KeyIdx;
4427 //RestartAPIsRequired = TRUE;
4432 case OID_802_11_WEPDEFAULTKEYID:
4433 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_WEPDEFAULTKEYID \n"));
4435 if (wrq->u.data.length != sizeof(UCHAR))
4438 Status = copy_from_user(&pAdapter->StaCfg.DefaultKeyId, wrq->u.data.pointer, wrq->u.data.length);
4443 case OID_802_11_CURRENTCHANNEL:
4444 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_CURRENTCHANNEL \n"));
4445 if (wrq->u.data.length != sizeof(UCHAR))
4449 Status = copy_from_user(&ctmp, wrq->u.data.pointer, wrq->u.data.length);
4450 sprintf(&ctmp,"%d", ctmp);
4451 Set_Channel_Proc(pAdapter, &ctmp);
4459 DBGPRINT(RT_DEBUG_TRACE, ("Set::unknown IOCTL's subcmd = 0x%08x\n", cmd));
4460 Status = -EOPNOTSUPP;
4468 INT RTMPQueryInformation(
4469 IN PRTMP_ADAPTER pAdapter,
4470 IN OUT struct ifreq *rq,
4473 struct iwreq *wrq = (struct iwreq *) rq;
4474 NDIS_802_11_BSSID_LIST_EX *pBssidList = NULL;
4475 PNDIS_WLAN_BSSID_EX pBss;
4476 NDIS_802_11_SSID Ssid;
4477 NDIS_802_11_CONFIGURATION *pConfiguration = NULL;
4478 RT_802_11_LINK_STATUS *pLinkStatus = NULL;
4479 RT_802_11_STA_CONFIG *pStaConfig = NULL;
4480 NDIS_802_11_STATISTICS *pStatistics = NULL;
4481 NDIS_802_11_RTS_THRESHOLD RtsThresh;
4482 NDIS_802_11_FRAGMENTATION_THRESHOLD FragThresh;
4483 NDIS_802_11_POWER_MODE PowerMode;
4484 NDIS_802_11_NETWORK_INFRASTRUCTURE BssType;
4485 RT_802_11_PREAMBLE PreamType;
4486 NDIS_802_11_AUTHENTICATION_MODE AuthMode;
4487 NDIS_802_11_WEP_STATUS WepStatus;
4488 NDIS_MEDIA_STATE MediaState;
4489 ULONG BssBufSize, ulInfo=0, NetworkTypeList[4], apsd = 0;
4491 PUCHAR pBuf = NULL, pPtr;
4492 INT Status = NDIS_STATUS_SUCCESS;
4493 UINT we_version_compiled;
4494 UCHAR i, Padding = 0;
4496 UCHAR driverVersion[8];
4497 OID_SET_HT_PHYMODE *pHTPhyMode = NULL;
4502 DefaultKeyIdxValue *pKeyIdxValue;
4504 TX_RTY_CFG_STRUC tx_rty_cfg;
4505 ULONG ShortRetryLimit, LongRetryLimit;
4511 case RT_OID_DEVICE_NAME:
4512 wrq->u.data.length = sizeof(STA_NIC_DEVICE_NAME);
4513 Status = copy_to_user(wrq->u.data.pointer, STA_NIC_DEVICE_NAME, wrq->u.data.length);
4515 case RT_OID_VERSION_INFO:
4516 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_VERSION_INFO \n"));
4517 wrq->u.data.length = 8*sizeof(UCHAR);
4518 sprintf(&driverVersion[0], "%s", STA_DRIVER_VERSION);
4519 driverVersion[7] = '\0';
4520 if (copy_to_user(wrq->u.data.pointer, &driverVersion, wrq->u.data.length))
4525 case OID_802_11_BSSID_LIST:
4526 if (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
4529 * Still scanning, indicate the caller should try again.
4531 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_BSSID_LIST (Still scanning)\n"));
4534 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_BSSID_LIST (%d BSS returned)\n",pAdapter->ScanTab.BssNr));
4535 pAdapter->StaCfg.bScanReqIsFromWebUI = FALSE;
4536 // Claculate total buffer size required
4537 BssBufSize = sizeof(ULONG);
4539 for (i = 0; i < pAdapter->ScanTab.BssNr; i++)
4541 // Align pointer to 4 bytes boundary.
4542 //Padding = 4 - (pAdapter->ScanTab.BssEntry[i].VarIELen & 0x0003);
4545 BssBufSize += (sizeof(NDIS_WLAN_BSSID_EX) - 1 + sizeof(NDIS_802_11_FIXED_IEs) + pAdapter->ScanTab.BssEntry[i].VarIELen + Padding);
4548 // For safety issue, we add 256 bytes just in case
4550 // Allocate the same size as passed from higher layer
4551 pBuf = kmalloc(BssBufSize, MEM_ALLOC_FLAG);
4557 // Init 802_11_BSSID_LIST_EX structure
4558 NdisZeroMemory(pBuf, BssBufSize);
4559 pBssidList = (PNDIS_802_11_BSSID_LIST_EX) pBuf;
4560 pBssidList->NumberOfItems = pAdapter->ScanTab.BssNr;
4562 // Calculate total buffer length
4563 BssLen = 4; // Consist of NumberOfItems
4564 // Point to start of NDIS_WLAN_BSSID_EX
4565 // pPtr = pBuf + sizeof(ULONG);
4566 pPtr = (PUCHAR) &pBssidList->Bssid[0];
4567 for (i = 0; i < pAdapter->ScanTab.BssNr; i++)
4569 pBss = (PNDIS_WLAN_BSSID_EX) pPtr;
4570 NdisMoveMemory(&pBss->MacAddress, &pAdapter->ScanTab.BssEntry[i].Bssid, MAC_ADDR_LEN);
4571 if ((pAdapter->ScanTab.BssEntry[i].Hidden == 1) && (pAdapter->StaCfg.bShowHiddenSSID == FALSE))
4574 // We must return this SSID during 4way handshaking, otherwise Aegis will failed to parse WPA infomation
4575 // and then failed to send EAPOl farame.
4577 if ((pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA) && (pAdapter->StaCfg.PortSecured != WPA_802_1X_PORT_SECURED))
4579 pBss->Ssid.SsidLength = pAdapter->ScanTab.BssEntry[i].SsidLen;
4580 NdisMoveMemory(pBss->Ssid.Ssid, pAdapter->ScanTab.BssEntry[i].Ssid, pAdapter->ScanTab.BssEntry[i].SsidLen);
4583 pBss->Ssid.SsidLength = 0;
4587 pBss->Ssid.SsidLength = pAdapter->ScanTab.BssEntry[i].SsidLen;
4588 NdisMoveMemory(pBss->Ssid.Ssid, pAdapter->ScanTab.BssEntry[i].Ssid, pAdapter->ScanTab.BssEntry[i].SsidLen);
4590 pBss->Privacy = pAdapter->ScanTab.BssEntry[i].Privacy;
4591 pBss->Rssi = pAdapter->ScanTab.BssEntry[i].Rssi - pAdapter->BbpRssiToDbmDelta;
4592 pBss->NetworkTypeInUse = NetworkTypeInUseSanity(&pAdapter->ScanTab.BssEntry[i]);
4593 pBss->Configuration.Length = sizeof(NDIS_802_11_CONFIGURATION);
4594 pBss->Configuration.BeaconPeriod = pAdapter->ScanTab.BssEntry[i].BeaconPeriod;
4595 pBss->Configuration.ATIMWindow = pAdapter->ScanTab.BssEntry[i].AtimWin;
4597 MAP_CHANNEL_ID_TO_KHZ(pAdapter->ScanTab.BssEntry[i].Channel, pBss->Configuration.DSConfig);
4599 if (pAdapter->ScanTab.BssEntry[i].BssType == BSS_INFRA)
4600 pBss->InfrastructureMode = Ndis802_11Infrastructure;
4602 pBss->InfrastructureMode = Ndis802_11IBSS;
4604 NdisMoveMemory(pBss->SupportedRates, pAdapter->ScanTab.BssEntry[i].SupRate, pAdapter->ScanTab.BssEntry[i].SupRateLen);
4605 NdisMoveMemory(pBss->SupportedRates + pAdapter->ScanTab.BssEntry[i].SupRateLen,
4606 pAdapter->ScanTab.BssEntry[i].ExtRate,
4607 pAdapter->ScanTab.BssEntry[i].ExtRateLen);
4609 if (pAdapter->ScanTab.BssEntry[i].VarIELen == 0)
4611 pBss->IELength = sizeof(NDIS_802_11_FIXED_IEs);
4612 NdisMoveMemory(pBss->IEs, &pAdapter->ScanTab.BssEntry[i].FixIEs, sizeof(NDIS_802_11_FIXED_IEs));
4613 pPtr = pPtr + sizeof(NDIS_WLAN_BSSID_EX) - 1 + sizeof(NDIS_802_11_FIXED_IEs);
4617 pBss->IELength = (ULONG)(sizeof(NDIS_802_11_FIXED_IEs) + pAdapter->ScanTab.BssEntry[i].VarIELen);
4618 pPtr = pPtr + sizeof(NDIS_WLAN_BSSID_EX) - 1 + sizeof(NDIS_802_11_FIXED_IEs);
4619 NdisMoveMemory(pBss->IEs, &pAdapter->ScanTab.BssEntry[i].FixIEs, sizeof(NDIS_802_11_FIXED_IEs));
4620 NdisMoveMemory(pBss->IEs + sizeof(NDIS_802_11_FIXED_IEs), pAdapter->ScanTab.BssEntry[i].VarIEs, pAdapter->ScanTab.BssEntry[i].VarIELen);
4621 pPtr += pAdapter->ScanTab.BssEntry[i].VarIELen;
4623 pBss->Length = (ULONG)(sizeof(NDIS_WLAN_BSSID_EX) - 1 + sizeof(NDIS_802_11_FIXED_IEs) + pAdapter->ScanTab.BssEntry[i].VarIELen + Padding);
4625 #if WIRELESS_EXT < 17
4626 if ((BssLen + pBss->Length) < wrq->u.data.length)
4627 BssLen += pBss->Length;
4630 pBssidList->NumberOfItems = i;
4634 BssLen += pBss->Length;
4638 #if WIRELESS_EXT < 17
4639 wrq->u.data.length = BssLen;
4641 if (BssLen > wrq->u.data.length)
4647 wrq->u.data.length = BssLen;
4649 Status = copy_to_user(wrq->u.data.pointer, pBssidList, BssLen);
4652 case OID_802_3_CURRENT_ADDRESS:
4653 wrq->u.data.length = MAC_ADDR_LEN;
4654 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CurrentAddress, wrq->u.data.length);
4656 case OID_GEN_MEDIA_CONNECT_STATUS:
4657 if (pAdapter->IndicateMediaState == NdisMediaStateConnected)
4658 MediaState = NdisMediaStateConnected;
4660 MediaState = NdisMediaStateDisconnected;
4662 wrq->u.data.length = sizeof(NDIS_MEDIA_STATE);
4663 Status = copy_to_user(wrq->u.data.pointer, &MediaState, wrq->u.data.length);
4665 case OID_802_11_BSSID:
4666 if (INFRA_ON(pAdapter) || ADHOC_ON(pAdapter))
4668 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.Bssid, sizeof(NDIS_802_11_MAC_ADDRESS));
4673 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_BSSID(=EMPTY)\n"));
4677 case OID_802_11_SSID:
4678 NdisZeroMemory(&Ssid, sizeof(NDIS_802_11_SSID));
4679 NdisZeroMemory(Ssid.Ssid, MAX_LEN_OF_SSID);
4680 Ssid.SsidLength = pAdapter->CommonCfg.SsidLen;
4681 memcpy(Ssid.Ssid, pAdapter->CommonCfg.Ssid, Ssid.SsidLength);
4682 wrq->u.data.length = sizeof(NDIS_802_11_SSID);
4683 Status = copy_to_user(wrq->u.data.pointer, &Ssid, wrq->u.data.length);
4684 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_SSID (Len=%d, ssid=%s)\n", Ssid.SsidLength,Ssid.Ssid));
4686 case RT_OID_802_11_QUERY_LINK_STATUS:
4687 pLinkStatus = (RT_802_11_LINK_STATUS *) kmalloc(sizeof(RT_802_11_LINK_STATUS), MEM_ALLOC_FLAG);
4690 pLinkStatus->CurrTxRate = RateIdTo500Kbps[pAdapter->CommonCfg.TxRate]; // unit : 500 kbps
4691 pLinkStatus->ChannelQuality = pAdapter->Mlme.ChannelQuality;
4692 pLinkStatus->RxByteCount = pAdapter->RalinkCounters.ReceivedByteCount;
4693 pLinkStatus->TxByteCount = pAdapter->RalinkCounters.TransmittedByteCount;
4694 pLinkStatus->CentralChannel = pAdapter->CommonCfg.CentralChannel;
4695 wrq->u.data.length = sizeof(RT_802_11_LINK_STATUS);
4696 Status = copy_to_user(wrq->u.data.pointer, pLinkStatus, wrq->u.data.length);
4698 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_LINK_STATUS\n"));
4702 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_LINK_STATUS(kmalloc failed)\n"));
4706 case OID_802_11_CONFIGURATION:
4707 pConfiguration = (NDIS_802_11_CONFIGURATION *) kmalloc(sizeof(NDIS_802_11_CONFIGURATION), MEM_ALLOC_FLAG);
4710 pConfiguration->Length = sizeof(NDIS_802_11_CONFIGURATION);
4711 pConfiguration->BeaconPeriod = pAdapter->CommonCfg.BeaconPeriod;
4712 pConfiguration->ATIMWindow = pAdapter->StaActive.AtimWin;
4713 MAP_CHANNEL_ID_TO_KHZ(pAdapter->CommonCfg.Channel, pConfiguration->DSConfig);
4714 wrq->u.data.length = sizeof(NDIS_802_11_CONFIGURATION);
4715 Status = copy_to_user(wrq->u.data.pointer, pConfiguration, wrq->u.data.length);
4716 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_CONFIGURATION(BeaconPeriod=%ld,AtimW=%ld,Channel=%d) \n",
4717 pConfiguration->BeaconPeriod, pConfiguration->ATIMWindow, pAdapter->CommonCfg.Channel));
4718 kfree(pConfiguration);
4722 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_CONFIGURATION(kmalloc failed)\n"));
4726 case RT_OID_802_11_SNR_0:
4727 if ((pAdapter->StaCfg.LastSNR0 > 0))
4729 ulInfo = ((0xeb - pAdapter->StaCfg.LastSNR0) * 3) / 16 ;
4730 wrq->u.data.length = sizeof(ulInfo);
4731 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4732 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_SNR_0(0x=%lx)\n", ulInfo));
4737 case RT_OID_802_11_SNR_1:
4738 if ((pAdapter->Antenna.field.RxPath > 1) &&
4739 (pAdapter->StaCfg.LastSNR1 > 0))
4741 ulInfo = ((0xeb - pAdapter->StaCfg.LastSNR1) * 3) / 16 ;
4742 wrq->u.data.length = sizeof(ulInfo);
4743 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4744 DBGPRINT(RT_DEBUG_TRACE,("Query::RT_OID_802_11_SNR_1(0x=%lx)\n",ulInfo));
4748 DBGPRINT(RT_DEBUG_TRACE,("Query::RT_OID_802_11_SNR_1(pAdapter->StaCfg.LastSNR1=%d)\n",pAdapter->StaCfg.LastSNR1));
4750 case OID_802_11_RSSI_TRIGGER:
4751 ulInfo = pAdapter->StaCfg.RssiSample.LastRssi0 - pAdapter->BbpRssiToDbmDelta;
4752 wrq->u.data.length = sizeof(ulInfo);
4753 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4754 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_RSSI_TRIGGER(=%ld)\n", ulInfo));
4756 case OID_802_11_RSSI:
4757 case RT_OID_802_11_RSSI:
4758 ulInfo = pAdapter->StaCfg.RssiSample.LastRssi0;
4759 wrq->u.data.length = sizeof(ulInfo);
4760 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4762 case RT_OID_802_11_RSSI_1:
4763 ulInfo = pAdapter->StaCfg.RssiSample.LastRssi1;
4764 wrq->u.data.length = sizeof(ulInfo);
4765 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4767 case RT_OID_802_11_RSSI_2:
4768 ulInfo = pAdapter->StaCfg.RssiSample.LastRssi2;
4769 wrq->u.data.length = sizeof(ulInfo);
4770 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4772 case OID_802_11_STATISTICS:
4773 pStatistics = (NDIS_802_11_STATISTICS *) kmalloc(sizeof(NDIS_802_11_STATISTICS), MEM_ALLOC_FLAG);
4776 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_STATISTICS \n"));
4777 // add the most up-to-date h/w raw counters into software counters
4778 NICUpdateRawCounters(pAdapter);
4780 // Sanity check for calculation of sucessful count
4781 if (pAdapter->WlanCounters.TransmittedFragmentCount.QuadPart < pAdapter->WlanCounters.RetryCount.QuadPart)
4782 pAdapter->WlanCounters.TransmittedFragmentCount.QuadPart = pAdapter->WlanCounters.RetryCount.QuadPart;
4784 pStatistics->TransmittedFragmentCount.QuadPart = pAdapter->WlanCounters.TransmittedFragmentCount.QuadPart;
4785 pStatistics->MulticastTransmittedFrameCount.QuadPart = pAdapter->WlanCounters.MulticastTransmittedFrameCount.QuadPart;
4786 pStatistics->FailedCount.QuadPart = pAdapter->WlanCounters.FailedCount.QuadPart;
4787 pStatistics->RetryCount.QuadPart = pAdapter->WlanCounters.RetryCount.QuadPart;
4788 pStatistics->MultipleRetryCount.QuadPart = pAdapter->WlanCounters.MultipleRetryCount.QuadPart;
4789 pStatistics->RTSSuccessCount.QuadPart = pAdapter->WlanCounters.RTSSuccessCount.QuadPart;
4790 pStatistics->RTSFailureCount.QuadPart = pAdapter->WlanCounters.RTSFailureCount.QuadPart;
4791 pStatistics->ACKFailureCount.QuadPart = pAdapter->WlanCounters.ACKFailureCount.QuadPart;
4792 pStatistics->FrameDuplicateCount.QuadPart = pAdapter->WlanCounters.FrameDuplicateCount.QuadPart;
4793 pStatistics->ReceivedFragmentCount.QuadPart = pAdapter->WlanCounters.ReceivedFragmentCount.QuadPart;
4794 pStatistics->MulticastReceivedFrameCount.QuadPart = pAdapter->WlanCounters.MulticastReceivedFrameCount.QuadPart;
4796 pStatistics->FCSErrorCount = pAdapter->RalinkCounters.RealFcsErrCount;
4798 pStatistics->FCSErrorCount.QuadPart = pAdapter->WlanCounters.FCSErrorCount.QuadPart;
4799 pStatistics->FrameDuplicateCount.u.LowPart = pAdapter->WlanCounters.FrameDuplicateCount.u.LowPart / 100;
4801 wrq->u.data.length = sizeof(NDIS_802_11_STATISTICS);
4802 Status = copy_to_user(wrq->u.data.pointer, pStatistics, wrq->u.data.length);
4807 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_STATISTICS(kmalloc failed)\n"));
4811 case OID_GEN_RCV_OK:
4812 ulInfo = pAdapter->Counters8023.GoodReceives;
4813 wrq->u.data.length = sizeof(ulInfo);
4814 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4816 case OID_GEN_RCV_NO_BUFFER:
4817 ulInfo = pAdapter->Counters8023.RxNoBuffer;
4818 wrq->u.data.length = sizeof(ulInfo);
4819 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4821 case RT_OID_802_11_PHY_MODE:
4822 ulInfo = (ULONG)pAdapter->CommonCfg.PhyMode;
4823 wrq->u.data.length = sizeof(ulInfo);
4824 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4825 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_PHY_MODE (=%ld)\n", ulInfo));
4827 case RT_OID_802_11_STA_CONFIG:
4828 pStaConfig = (RT_802_11_STA_CONFIG *) kmalloc(sizeof(RT_802_11_STA_CONFIG), MEM_ALLOC_FLAG);
4831 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_STA_CONFIG\n"));
4832 pStaConfig->EnableTxBurst = pAdapter->CommonCfg.bEnableTxBurst;
4833 pStaConfig->EnableTurboRate = 0;
4834 pStaConfig->UseBGProtection = pAdapter->CommonCfg.UseBGProtection;
4835 pStaConfig->UseShortSlotTime = pAdapter->CommonCfg.bUseShortSlotTime;
4836 //pStaConfig->AdhocMode = pAdapter->StaCfg.AdhocMode;
4837 pStaConfig->HwRadioStatus = (pAdapter->StaCfg.bHwRadio == TRUE) ? 1 : 0;
4838 pStaConfig->Rsv1 = 0;
4839 pStaConfig->SystemErrorBitmap = pAdapter->SystemErrorBitmap;
4840 wrq->u.data.length = sizeof(RT_802_11_STA_CONFIG);
4841 Status = copy_to_user(wrq->u.data.pointer, pStaConfig, wrq->u.data.length);
4846 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_STA_CONFIG(kmalloc failed)\n"));
4850 case OID_802_11_RTS_THRESHOLD:
4851 RtsThresh = pAdapter->CommonCfg.RtsThreshold;
4852 wrq->u.data.length = sizeof(RtsThresh);
4853 Status = copy_to_user(wrq->u.data.pointer, &RtsThresh, wrq->u.data.length);
4854 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_RTS_THRESHOLD(=%ld)\n", RtsThresh));
4856 case OID_802_11_FRAGMENTATION_THRESHOLD:
4857 FragThresh = pAdapter->CommonCfg.FragmentThreshold;
4858 if (pAdapter->CommonCfg.bUseZeroToDisableFragment == TRUE)
4860 wrq->u.data.length = sizeof(FragThresh);
4861 Status = copy_to_user(wrq->u.data.pointer, &FragThresh, wrq->u.data.length);
4862 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_FRAGMENTATION_THRESHOLD(=%ld)\n", FragThresh));
4864 case OID_802_11_POWER_MODE:
4865 PowerMode = pAdapter->StaCfg.WindowsPowerMode;
4866 wrq->u.data.length = sizeof(PowerMode);
4867 Status = copy_to_user(wrq->u.data.pointer, &PowerMode, wrq->u.data.length);
4868 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_POWER_MODE(=%d)\n", PowerMode));
4870 case RT_OID_802_11_RADIO:
4871 RadioState = (BOOLEAN) pAdapter->StaCfg.bSwRadio;
4872 wrq->u.data.length = sizeof(RadioState);
4873 Status = copy_to_user(wrq->u.data.pointer, &RadioState, wrq->u.data.length);
4874 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_RADIO (=%d)\n", RadioState));
4876 case OID_802_11_INFRASTRUCTURE_MODE:
4877 if (pAdapter->StaCfg.BssType == BSS_ADHOC)
4878 BssType = Ndis802_11IBSS;
4879 else if (pAdapter->StaCfg.BssType == BSS_INFRA)
4880 BssType = Ndis802_11Infrastructure;
4881 else if (pAdapter->StaCfg.BssType == BSS_MONITOR)
4882 BssType = Ndis802_11Monitor;
4884 BssType = Ndis802_11AutoUnknown;
4886 wrq->u.data.length = sizeof(BssType);
4887 Status = copy_to_user(wrq->u.data.pointer, &BssType, wrq->u.data.length);
4888 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_INFRASTRUCTURE_MODE(=%d)\n", BssType));
4890 case RT_OID_802_11_PREAMBLE:
4891 PreamType = pAdapter->CommonCfg.TxPreamble;
4892 wrq->u.data.length = sizeof(PreamType);
4893 Status = copy_to_user(wrq->u.data.pointer, &PreamType, wrq->u.data.length);
4894 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_PREAMBLE(=%d)\n", PreamType));
4896 case OID_802_11_AUTHENTICATION_MODE:
4897 AuthMode = pAdapter->StaCfg.AuthMode;
4898 wrq->u.data.length = sizeof(AuthMode);
4899 Status = copy_to_user(wrq->u.data.pointer, &AuthMode, wrq->u.data.length);
4900 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_AUTHENTICATION_MODE(=%d)\n", AuthMode));
4902 case OID_802_11_WEP_STATUS:
4903 WepStatus = pAdapter->StaCfg.WepStatus;
4904 wrq->u.data.length = sizeof(WepStatus);
4905 Status = copy_to_user(wrq->u.data.pointer, &WepStatus, wrq->u.data.length);
4906 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_WEP_STATUS(=%d)\n", WepStatus));
4908 case OID_802_11_TX_POWER_LEVEL:
4909 wrq->u.data.length = sizeof(ULONG);
4910 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.TxPower, wrq->u.data.length);
4911 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_TX_POWER_LEVEL %x\n",pAdapter->CommonCfg.TxPower));
4913 case RT_OID_802_11_TX_POWER_LEVEL_1:
4914 wrq->u.data.length = sizeof(ULONG);
4915 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.TxPowerPercentage, wrq->u.data.length);
4916 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_TX_POWER_LEVEL_1 (=%ld)\n", pAdapter->CommonCfg.TxPowerPercentage));
4918 case OID_802_11_NETWORK_TYPES_SUPPORTED:
4919 if ((pAdapter->RfIcType == RFIC_2850) || (pAdapter->RfIcType == RFIC_2750))
4921 NetworkTypeList[0] = 3; // NumberOfItems = 3
4922 NetworkTypeList[1] = Ndis802_11DS; // NetworkType[1] = 11b
4923 NetworkTypeList[2] = Ndis802_11OFDM24; // NetworkType[2] = 11g
4924 NetworkTypeList[3] = Ndis802_11OFDM5; // NetworkType[3] = 11a
4925 wrq->u.data.length = 16;
4926 Status = copy_to_user(wrq->u.data.pointer, &NetworkTypeList[0], wrq->u.data.length);
4930 NetworkTypeList[0] = 2; // NumberOfItems = 2
4931 NetworkTypeList[1] = Ndis802_11DS; // NetworkType[1] = 11b
4932 NetworkTypeList[2] = Ndis802_11OFDM24; // NetworkType[2] = 11g
4933 wrq->u.data.length = 12;
4934 Status = copy_to_user(wrq->u.data.pointer, &NetworkTypeList[0], wrq->u.data.length);
4936 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_NETWORK_TYPES_SUPPORTED\n"));
4938 case OID_802_11_NETWORK_TYPE_IN_USE:
4939 wrq->u.data.length = sizeof(ULONG);
4940 if (pAdapter->CommonCfg.PhyMode == PHY_11A)
4941 ulInfo = Ndis802_11OFDM5;
4942 else if ((pAdapter->CommonCfg.PhyMode == PHY_11BG_MIXED) || (pAdapter->CommonCfg.PhyMode == PHY_11G))
4943 ulInfo = Ndis802_11OFDM24;
4945 ulInfo = Ndis802_11DS;
4946 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4948 case RT_OID_802_11_QUERY_LAST_RX_RATE:
4949 ulInfo = (ULONG)pAdapter->LastRxRate;
4950 wrq->u.data.length = sizeof(ulInfo);
4951 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4952 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_LAST_RX_RATE (=%ld)\n", ulInfo));
4954 case RT_OID_802_11_QUERY_LAST_TX_RATE:
4955 //ulInfo = (ULONG)pAdapter->LastTxRate;
4956 ulInfo = (ULONG)pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.word;
4957 wrq->u.data.length = sizeof(ulInfo);
4958 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4959 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_LAST_TX_RATE (=%lx)\n", ulInfo));
4961 case RT_OID_802_11_QUERY_EEPROM_VERSION:
4962 wrq->u.data.length = sizeof(ULONG);
4963 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->EepromVersion, wrq->u.data.length);
4965 case RT_OID_802_11_QUERY_FIRMWARE_VERSION:
4966 wrq->u.data.length = sizeof(ULONG);
4967 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->FirmwareVersion, wrq->u.data.length);
4969 case RT_OID_802_11_QUERY_NOISE_LEVEL:
4970 wrq->u.data.length = sizeof(UCHAR);
4971 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->BbpWriteLatch[66], wrq->u.data.length);
4972 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_NOISE_LEVEL (=%d)\n", pAdapter->BbpWriteLatch[66]));
4974 case RT_OID_802_11_EXTRA_INFO:
4975 wrq->u.data.length = sizeof(ULONG);
4976 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->ExtraInfo, wrq->u.data.length);
4977 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_EXTRA_INFO (=%ld)\n", pAdapter->ExtraInfo));
4979 case RT_OID_WE_VERSION_COMPILED:
4980 wrq->u.data.length = sizeof(UINT);
4981 we_version_compiled = WIRELESS_EXT;
4982 Status = copy_to_user(wrq->u.data.pointer, &we_version_compiled, wrq->u.data.length);
4984 case RT_OID_802_11_QUERY_APSD_SETTING:
4985 apsd = (pAdapter->CommonCfg.bAPSDCapable | (pAdapter->CommonCfg.bAPSDAC_BE << 1) | (pAdapter->CommonCfg.bAPSDAC_BK << 2)
4986 | (pAdapter->CommonCfg.bAPSDAC_VI << 3) | (pAdapter->CommonCfg.bAPSDAC_VO << 4) | (pAdapter->CommonCfg.MaxSPLength << 5));
4988 wrq->u.data.length = sizeof(ULONG);
4989 Status = copy_to_user(wrq->u.data.pointer, &apsd, wrq->u.data.length);
4990 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",
4991 apsd,pAdapter->CommonCfg.bAPSDCapable,pAdapter->CommonCfg.bAPSDAC_BE,pAdapter->CommonCfg.bAPSDAC_BK,pAdapter->CommonCfg.bAPSDAC_VI,pAdapter->CommonCfg.bAPSDAC_VO,pAdapter->CommonCfg.MaxSPLength));
4993 case RT_OID_802_11_QUERY_APSD_PSM:
4994 wrq->u.data.length = sizeof(ULONG);
4995 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.bAPSDForcePowerSave, wrq->u.data.length);
4996 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_APSD_PSM (=%d)\n", pAdapter->CommonCfg.bAPSDForcePowerSave));
4998 case RT_OID_802_11_QUERY_WMM:
4999 wrq->u.data.length = sizeof(BOOLEAN);
5000 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.bWmmCapable, wrq->u.data.length);
5001 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_WMM (=%d)\n", pAdapter->CommonCfg.bWmmCapable));
5003 #ifdef WPA_SUPPLICANT_SUPPORT
5004 case RT_OID_NEW_DRIVER:
5007 wrq->u.data.length = sizeof(UCHAR);
5008 Status = copy_to_user(wrq->u.data.pointer, &enabled, wrq->u.data.length);
5009 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_NEW_DRIVER (=%d)\n", enabled));
5012 case RT_OID_WPA_SUPPLICANT_SUPPORT:
5013 wrq->u.data.length = sizeof(UCHAR);
5014 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->StaCfg.WpaSupplicantUP, wrq->u.data.length);
5015 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_WPA_SUPPLICANT_SUPPORT (=%d)\n", pAdapter->StaCfg.WpaSupplicantUP));
5017 #endif // WPA_SUPPLICANT_SUPPORT //
5019 case RT_OID_DRIVER_DEVICE_NAME:
5020 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_DRIVER_DEVICE_NAME \n"));
5021 wrq->u.data.length = 16;
5022 if (copy_to_user(wrq->u.data.pointer, pAdapter->StaCfg.dev_name, wrq->u.data.length))
5027 case RT_OID_802_11_QUERY_HT_PHYMODE:
5028 pHTPhyMode = (OID_SET_HT_PHYMODE *) kmalloc(sizeof(OID_SET_HT_PHYMODE), MEM_ALLOC_FLAG);
5031 pHTPhyMode->PhyMode = pAdapter->CommonCfg.PhyMode;
5032 pHTPhyMode->HtMode = (UCHAR)pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.field.MODE;
5033 pHTPhyMode->BW = (UCHAR)pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.field.BW;
5034 pHTPhyMode->MCS= (UCHAR)pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.field.MCS;
5035 pHTPhyMode->SHORTGI= (UCHAR)pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.field.ShortGI;
5036 pHTPhyMode->STBC= (UCHAR)pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.field.STBC;
5038 pHTPhyMode->ExtOffset = ((pAdapter->CommonCfg.CentralChannel < pAdapter->CommonCfg.Channel) ? (EXTCHA_BELOW) : (EXTCHA_ABOVE));
5039 wrq->u.data.length = sizeof(OID_SET_HT_PHYMODE);
5040 if (copy_to_user(wrq->u.data.pointer, pHTPhyMode, wrq->u.data.length))
5044 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_HT_PHYMODE (PhyMode = %d, MCS =%d, BW = %d, STBC = %d, ExtOffset=%d)\n",
5045 pHTPhyMode->HtMode, pHTPhyMode->MCS, pHTPhyMode->BW, pHTPhyMode->STBC, pHTPhyMode->ExtOffset));
5046 DBGPRINT(RT_DEBUG_TRACE, (" MlmeUpdateTxRates (.word = %x )\n", pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.word));
5050 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_STA_CONFIG(kmalloc failed)\n"));
5054 case RT_OID_802_11_COUNTRY_REGION:
5055 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_COUNTRY_REGION \n"));
5056 wrq->u.data.length = sizeof(ulInfo);
5057 ulInfo = pAdapter->CommonCfg.CountryRegionForABand;
5058 ulInfo = (ulInfo << 8)|(pAdapter->CommonCfg.CountryRegion);
5059 if (copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length))
5064 case RT_OID_802_11_QUERY_DAT_HT_PHYMODE:
5065 pHTPhyMode = (OID_SET_HT_PHYMODE *) kmalloc(sizeof(OID_SET_HT_PHYMODE), MEM_ALLOC_FLAG);
5068 pHTPhyMode->PhyMode = pAdapter->CommonCfg.PhyMode;
5069 pHTPhyMode->HtMode = (UCHAR)pAdapter->CommonCfg.RegTransmitSetting.field.HTMODE;
5070 pHTPhyMode->BW = (UCHAR)pAdapter->CommonCfg.RegTransmitSetting.field.BW;
5071 pHTPhyMode->MCS= (UCHAR)pAdapter->StaCfg.DesiredTransmitSetting.field.MCS;
5072 pHTPhyMode->SHORTGI= (UCHAR)pAdapter->CommonCfg.RegTransmitSetting.field.ShortGI;
5073 pHTPhyMode->STBC= (UCHAR)pAdapter->CommonCfg.RegTransmitSetting.field.STBC;
5075 wrq->u.data.length = sizeof(OID_SET_HT_PHYMODE);
5076 if (copy_to_user(wrq->u.data.pointer, pHTPhyMode, wrq->u.data.length))
5080 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_HT_PHYMODE (PhyMode = %d, MCS =%d, BW = %d, STBC = %d, ExtOffset=%d)\n",
5081 pHTPhyMode->HtMode, pHTPhyMode->MCS, pHTPhyMode->BW, pHTPhyMode->STBC, pHTPhyMode->ExtOffset));
5082 DBGPRINT(RT_DEBUG_TRACE, (" MlmeUpdateTxRates (.word = %x )\n", pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.word));
5086 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_STA_CONFIG(kmalloc failed)\n"));
5090 case RT_OID_QUERY_MULTIPLE_CARD_SUPPORT:
5091 wrq->u.data.length = sizeof(UCHAR);
5093 #ifdef MULTIPLE_CARD_SUPPORT
5095 #endif // MULTIPLE_CARD_SUPPORT //
5096 if (copy_to_user(wrq->u.data.pointer, &i, wrq->u.data.length))
5100 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_QUERY_MULTIPLE_CARD_SUPPORT(=%d) \n", i));
5103 case RT_OID_802_11_MAC_ADDRESS:
5104 wrq->u.data.length = MAC_ADDR_LEN;
5105 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CurrentAddress, wrq->u.data.length);
5108 case RT_OID_802_11_MANUFACTUREROUI:
5109 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_MANUFACTUREROUI \n"));
5110 wrq->u.data.length = ManufacturerOUI_LEN;
5111 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CurrentAddress, wrq->u.data.length);
5114 case RT_OID_802_11_MANUFACTURERNAME:
5115 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_MANUFACTURERNAME \n"));
5116 wrq->u.data.length = strlen(ManufacturerNAME);
5117 Status = copy_to_user(wrq->u.data.pointer, ManufacturerNAME, wrq->u.data.length);
5120 case RT_OID_802_11_RESOURCETYPEIDNAME:
5121 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_RESOURCETYPEIDNAME \n"));
5122 wrq->u.data.length = strlen(ResourceTypeIdName);
5123 Status = copy_to_user(wrq->u.data.pointer, ResourceTypeIdName, wrq->u.data.length);
5126 case RT_OID_802_11_PRIVACYOPTIONIMPLEMENTED:
5127 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_PRIVACYOPTIONIMPLEMENTED \n"));
5128 ulInfo = 1; // 1 is support wep else 2 is not support.
5129 wrq->u.data.length = sizeof(ulInfo);
5130 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
5133 case RT_OID_802_11_POWERMANAGEMENTMODE:
5134 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_POWERMANAGEMENTMODE \n"));
5135 if (pAdapter->StaCfg.Psm == PSMP_ACTION)
5136 ulInfo = 1; // 1 is power active else 2 is power save.
5140 wrq->u.data.length = sizeof(ulInfo);
5141 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
5144 case OID_802_11_WEPDEFAULTKEYVALUE:
5145 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_WEPDEFAULTKEYVALUE \n"));
5146 //KeyIdxValue.KeyIdx = pAd->PortCfg.MBSSID[pAd->IoctlIF].DefaultKeyId;
5147 pKeyIdxValue = wrq->u.data.pointer;
5148 DBGPRINT(RT_DEBUG_TRACE,("KeyIdxValue.KeyIdx = %d, \n",pKeyIdxValue->KeyIdx));
5149 valueLen = pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].KeyLen;
5150 NdisMoveMemory(pKeyIdxValue->Value,
5151 &pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].Key,
5153 pKeyIdxValue->Value[valueLen]='\0';
5155 wrq->u.data.length = sizeof(DefaultKeyIdxValue);
5157 Status = copy_to_user(wrq->u.data.pointer, pKeyIdxValue, wrq->u.data.length);
5158 DBGPRINT(RT_DEBUG_TRACE,("DefaultKeyId = %d, total len = %d, str len=%d, KeyValue= %02x %02x %02x %02x \n", pAdapter->StaCfg.DefaultKeyId, wrq->u.data.length, pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].KeyLen,
5159 pAdapter->SharedKey[BSS0][0].Key[0],
5160 pAdapter->SharedKey[BSS0][1].Key[0],
5161 pAdapter->SharedKey[BSS0][2].Key[0],
5162 pAdapter->SharedKey[BSS0][3].Key[0]));
5165 case OID_802_11_WEPDEFAULTKEYID:
5166 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_WEPDEFAULTKEYID \n"));
5167 wrq->u.data.length = sizeof(UCHAR);
5168 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->StaCfg.DefaultKeyId, wrq->u.data.length);
5169 DBGPRINT(RT_DEBUG_TRACE, ("DefaultKeyId =%d \n", pAdapter->StaCfg.DefaultKeyId));
5172 case RT_OID_802_11_WEPKEYMAPPINGLENGTH:
5173 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_WEPKEYMAPPINGLENGTH \n"));
5174 wrq->u.data.length = sizeof(UCHAR);
5175 Status = copy_to_user(wrq->u.data.pointer,
5176 &pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].KeyLen,
5177 wrq->u.data.length);
5180 case OID_802_11_SHORTRETRYLIMIT:
5181 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_SHORTRETRYLIMIT \n"));
5182 wrq->u.data.length = sizeof(ULONG);
5183 RTMP_IO_READ32(pAdapter, TX_RTY_CFG, &tx_rty_cfg.word);
5184 ShortRetryLimit = tx_rty_cfg.field.ShortRtyLimit;
5185 DBGPRINT(RT_DEBUG_TRACE, ("ShortRetryLimit =%ld, tx_rty_cfg.field.ShortRetryLimit=%d\n", ShortRetryLimit, tx_rty_cfg.field.ShortRtyLimit));
5186 Status = copy_to_user(wrq->u.data.pointer, &ShortRetryLimit, wrq->u.data.length);
5189 case OID_802_11_LONGRETRYLIMIT:
5190 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_LONGRETRYLIMIT \n"));
5191 wrq->u.data.length = sizeof(ULONG);
5192 RTMP_IO_READ32(pAdapter, TX_RTY_CFG, &tx_rty_cfg.word);
5193 LongRetryLimit = tx_rty_cfg.field.LongRtyLimit;
5194 DBGPRINT(RT_DEBUG_TRACE, ("LongRetryLimit =%ld, tx_rty_cfg.field.LongRtyLimit=%d\n", LongRetryLimit, tx_rty_cfg.field.LongRtyLimit));
5195 Status = copy_to_user(wrq->u.data.pointer, &LongRetryLimit, wrq->u.data.length);
5198 case RT_OID_802_11_PRODUCTID:
5199 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_PRODUCTID \n"));
5202 sprintf(tmp, "%04x %04x\n", ((POS_COOKIE)pAdapter->OS_Cookie)->pUsb_Dev->descriptor.idVendor ,((POS_COOKIE)pAdapter->OS_Cookie)->pUsb_Dev->descriptor.idProduct);
5205 wrq->u.data.length = strlen(tmp);
5206 Status = copy_to_user(wrq->u.data.pointer, tmp, wrq->u.data.length);
5209 case RT_OID_802_11_MANUFACTUREID:
5210 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_MANUFACTUREID \n"));
5211 wrq->u.data.length = strlen(ManufacturerNAME);
5212 Status = copy_to_user(wrq->u.data.pointer, ManufacturerNAME, wrq->u.data.length);
5215 case OID_802_11_CURRENTCHANNEL:
5216 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_CURRENTCHANNEL \n"));
5217 wrq->u.data.length = sizeof(UCHAR);
5218 DBGPRINT(RT_DEBUG_TRACE, ("sizeof UCHAR=%d, channel=%d \n", sizeof(UCHAR), pAdapter->CommonCfg.Channel));
5219 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.Channel, wrq->u.data.length);
5220 DBGPRINT(RT_DEBUG_TRACE, ("Status=%d\n", Status));
5222 #endif //SNMP_SUPPORT
5224 case OID_802_11_BUILD_CHANNEL_EX:
5227 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_BUILD_CHANNEL_EX \n"));
5228 wrq->u.data.length = sizeof(UCHAR);
5229 #ifdef EXT_BUILD_CHANNEL_LIST
5230 DBGPRINT(RT_DEBUG_TRACE, ("Support EXT_BUILD_CHANNEL_LIST.\n"));
5233 DBGPRINT(RT_DEBUG_TRACE, ("Doesn't support EXT_BUILD_CHANNEL_LIST.\n"));
5235 #endif // EXT_BUILD_CHANNEL_LIST //
5236 Status = copy_to_user(wrq->u.data.pointer, &value, 1);
5237 DBGPRINT(RT_DEBUG_TRACE, ("Status=%d\n", Status));
5241 case OID_802_11_GET_CH_LIST:
5243 PRT_CHANNEL_LIST_INFO pChListBuf;
5245 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_GET_CH_LIST \n"));
5246 if (pAdapter->ChannelListNum == 0)
5248 wrq->u.data.length = 0;
5252 pChListBuf = (RT_CHANNEL_LIST_INFO *) kmalloc(sizeof(RT_CHANNEL_LIST_INFO), MEM_ALLOC_FLAG);
5253 if (pChListBuf == NULL)
5255 wrq->u.data.length = 0;
5259 pChListBuf->ChannelListNum = pAdapter->ChannelListNum;
5260 for (i = 0; i < pChListBuf->ChannelListNum; i++)
5261 pChListBuf->ChannelList[i] = pAdapter->ChannelList[i].Channel;
5263 wrq->u.data.length = sizeof(RT_CHANNEL_LIST_INFO);
5264 Status = copy_to_user(wrq->u.data.pointer, pChListBuf, sizeof(RT_CHANNEL_LIST_INFO));
5265 DBGPRINT(RT_DEBUG_TRACE, ("Status=%d\n", Status));
5272 case OID_802_11_GET_COUNTRY_CODE:
5273 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_GET_COUNTRY_CODE \n"));
5274 wrq->u.data.length = 2;
5275 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.CountryCode, 2);
5276 DBGPRINT(RT_DEBUG_TRACE, ("Status=%d\n", Status));
5279 case OID_802_11_GET_CHANNEL_GEOGRAPHY:
5280 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_GET_CHANNEL_GEOGRAPHY \n"));
5281 wrq->u.data.length = 1;
5282 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.Geography, 1);
5283 DBGPRINT(RT_DEBUG_TRACE, ("Status=%d\n", Status));
5287 #ifdef QOS_DLS_SUPPORT
5288 case RT_OID_802_11_QUERY_DLS:
5289 wrq->u.data.length = sizeof(BOOLEAN);
5290 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.bDLSCapable, wrq->u.data.length);
5291 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_DLS(=%d)\n", pAdapter->CommonCfg.bDLSCapable));
5294 case RT_OID_802_11_QUERY_DLS_PARAM:
5296 PRT_802_11_DLS_INFO pDlsInfo = kmalloc(sizeof(RT_802_11_DLS_INFO), GFP_ATOMIC);
5297 if (pDlsInfo == NULL)
5300 for (i=0; i<MAX_NUM_OF_DLS_ENTRY; i++)
5302 RTMPMoveMemory(&pDlsInfo->Entry[i], &pAdapter->StaCfg.DLSEntry[i], sizeof(RT_802_11_DLS_UI));
5305 pDlsInfo->num = MAX_NUM_OF_DLS_ENTRY;
5306 wrq->u.data.length = sizeof(RT_802_11_DLS_INFO);
5307 Status = copy_to_user(wrq->u.data.pointer, pDlsInfo, wrq->u.data.length);
5308 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_DLS_PARAM\n"));
5314 #endif // QOS_DLS_SUPPORT //
5316 DBGPRINT(RT_DEBUG_TRACE, ("Query::unknown IOCTL's subcmd = 0x%08x\n", cmd));
5317 Status = -EOPNOTSUPP;
5323 INT rt28xx_sta_ioctl(
5324 IN struct net_device *net_dev,
5325 IN OUT struct ifreq *rq,
5329 VIRTUAL_ADAPTER *pVirtualAd = NULL;
5330 RTMP_ADAPTER *pAd = NULL;
5331 struct iwreq *wrq = (struct iwreq *) rq;
5332 BOOLEAN StateMachineTouched = FALSE;
5333 INT Status = NDIS_STATUS_SUCCESS;
5336 if (net_dev->priv_flags == INT_MAIN)
5338 pAd = net_dev->ml_priv;
5342 pVirtualAd = net_dev->ml_priv;
5343 pAd = pVirtualAd->RtmpDev->ml_priv;
5345 pObj = (POS_COOKIE) pAd->OS_Cookie;
5349 /* if 1st open fail, pAd will be free;
5350 So the net_dev->ml_priv will be NULL in 2rd open */
5354 //check if the interface is down
5355 if(!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_IN_USE))
5358 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
5363 { // determine this ioctl command is comming from which interface.
5364 pObj->ioctl_if_type = INT_MAIN;
5365 pObj->ioctl_if = MAIN_MBSSID;
5371 DBGPRINT(RT_DEBUG_TRACE, ("IOCTL::SIOCGIFHWADDR\n"));
5372 memcpy(wrq->u.name, pAd->CurrentAddress, ETH_ALEN);
5376 char *name=&wrq->u.name[0];
5377 rt_ioctl_giwname(net_dev, NULL, name, NULL);
5380 case SIOCGIWESSID: //Get ESSID
5382 struct iw_point *essid=&wrq->u.essid;
5383 rt_ioctl_giwessid(net_dev, NULL, essid, essid->pointer);
5386 case SIOCSIWESSID: //Set ESSID
5388 struct iw_point *essid=&wrq->u.essid;
5389 rt_ioctl_siwessid(net_dev, NULL, essid, essid->pointer);
5392 case SIOCSIWNWID: // set network id (the cell)
5393 case SIOCGIWNWID: // get network id
5394 Status = -EOPNOTSUPP;
5396 case SIOCSIWFREQ: //set channel/frequency (Hz)
5398 struct iw_freq *freq=&wrq->u.freq;
5399 rt_ioctl_siwfreq(net_dev, NULL, freq, NULL);
5402 case SIOCGIWFREQ: // get channel/frequency (Hz)
5404 struct iw_freq *freq=&wrq->u.freq;
5405 rt_ioctl_giwfreq(net_dev, NULL, freq, NULL);
5408 case SIOCSIWNICKN: //set node name/nickname
5410 struct iw_point *data=&wrq->u.data;
5411 rt_ioctl_siwnickn(net_dev, NULL, data, NULL);
5414 case SIOCGIWNICKN: //get node name/nickname
5416 struct iw_point *data=&wrq->u.data;
5417 rt_ioctl_giwnickn(net_dev, NULL, data, NULL);
5420 case SIOCGIWRATE: //get default bit rate (bps)
5421 rt_ioctl_giwrate(net_dev, NULL, &wrq->u, NULL);
5423 case SIOCSIWRATE: //set default bit rate (bps)
5424 rt_ioctl_siwrate(net_dev, NULL, &wrq->u, NULL);
5426 case SIOCGIWRTS: // get RTS/CTS threshold (bytes)
5428 struct iw_param *rts=&wrq->u.rts;
5429 rt_ioctl_giwrts(net_dev, NULL, rts, NULL);
5432 case SIOCSIWRTS: //set RTS/CTS threshold (bytes)
5434 struct iw_param *rts=&wrq->u.rts;
5435 rt_ioctl_siwrts(net_dev, NULL, rts, NULL);
5438 case SIOCGIWFRAG: //get fragmentation thr (bytes)
5440 struct iw_param *frag=&wrq->u.frag;
5441 rt_ioctl_giwfrag(net_dev, NULL, frag, NULL);
5444 case SIOCSIWFRAG: //set fragmentation thr (bytes)
5446 struct iw_param *frag=&wrq->u.frag;
5447 rt_ioctl_siwfrag(net_dev, NULL, frag, NULL);
5450 case SIOCGIWENCODE: //get encoding token & mode
5452 struct iw_point *erq=&wrq->u.encoding;
5454 rt_ioctl_giwencode(net_dev, NULL, erq, erq->pointer);
5457 case SIOCSIWENCODE: //set encoding token & mode
5459 struct iw_point *erq=&wrq->u.encoding;
5461 rt_ioctl_siwencode(net_dev, NULL, erq, erq->pointer);
5464 case SIOCGIWAP: //get access point MAC addresses
5466 struct sockaddr *ap_addr=&wrq->u.ap_addr;
5467 rt_ioctl_giwap(net_dev, NULL, ap_addr, ap_addr->sa_data);
5470 case SIOCSIWAP: //set access point MAC addresses
5472 struct sockaddr *ap_addr=&wrq->u.ap_addr;
5473 rt_ioctl_siwap(net_dev, NULL, ap_addr, ap_addr->sa_data);
5476 case SIOCGIWMODE: //get operation mode
5478 __u32 *mode=&wrq->u.mode;
5479 rt_ioctl_giwmode(net_dev, NULL, mode, NULL);
5482 case SIOCSIWMODE: //set operation mode
5484 __u32 *mode=&wrq->u.mode;
5485 rt_ioctl_siwmode(net_dev, NULL, mode, NULL);
5488 case SIOCGIWSENS: //get sensitivity (dBm)
5489 case SIOCSIWSENS: //set sensitivity (dBm)
5490 case SIOCGIWPOWER: //get Power Management settings
5491 case SIOCSIWPOWER: //set Power Management settings
5492 case SIOCGIWTXPOW: //get transmit power (dBm)
5493 case SIOCSIWTXPOW: //set transmit power (dBm)
5494 case SIOCGIWRANGE: //Get range of parameters
5495 case SIOCGIWRETRY: //get retry limits and lifetime
5496 case SIOCSIWRETRY: //set retry limits and lifetime
5497 Status = -EOPNOTSUPP;
5500 subcmd = wrq->u.data.flags;
5501 if( subcmd & OID_GET_SET_TOGGLE)
5502 Status = RTMPSetInformation(pAd, rq, subcmd);
5504 Status = RTMPQueryInformation(pAd, rq, subcmd);
5507 if (wrq->u.data.pointer)
5509 if ( access_ok(VERIFY_WRITE, wrq->u.data.pointer, sizeof(privtab)) != TRUE)
5511 wrq->u.data.length = sizeof(privtab) / sizeof(privtab[0]);
5512 if (copy_to_user(wrq->u.data.pointer, privtab, sizeof(privtab)))
5516 case RTPRIV_IOCTL_SET:
5517 if(access_ok(VERIFY_READ, wrq->u.data.pointer, wrq->u.data.length) != TRUE)
5519 rt_ioctl_setparam(net_dev, NULL, NULL, wrq->u.data.pointer);
5521 case RTPRIV_IOCTL_GSITESURVEY:
5522 RTMPIoctlGetSiteSurvey(pAd, wrq);
5525 case RTPRIV_IOCTL_MAC:
5526 RTMPIoctlMAC(pAd, wrq);
5528 case RTPRIV_IOCTL_E2P:
5529 RTMPIoctlE2PROM(pAd, wrq);
5535 DBGPRINT(RT_DEBUG_ERROR, ("IOCTL::unknown IOCTL's cmd = 0x%08x\n", cmd));
5536 Status = -EOPNOTSUPP;
5540 if(StateMachineTouched) // Upper layer sent a MLME-related operations
5541 RT28XX_MLME_HANDLER(pAd);
5547 ==========================================================================
5551 TRUE if all parameters are OK, FALSE otherwise
5552 ==========================================================================
5555 IN PRTMP_ADAPTER pAdapter,
5558 NDIS_802_11_SSID Ssid, *pSsid=NULL;
5559 BOOLEAN StateMachineTouched = FALSE;
5562 if( strlen(arg) <= MAX_LEN_OF_SSID)
5564 NdisZeroMemory(&Ssid, sizeof(NDIS_802_11_SSID));
5565 if (strlen(arg) != 0)
5567 NdisMoveMemory(Ssid.Ssid, arg, strlen(arg));
5568 Ssid.SsidLength = strlen(arg);
5572 Ssid.SsidLength = 0;
5573 memcpy(Ssid.Ssid, "", 0);
5574 pAdapter->StaCfg.BssType = BSS_INFRA;
5575 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
5576 pAdapter->StaCfg.WepStatus = Ndis802_11EncryptionDisabled;
5580 if (pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE)
5582 RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
5583 DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
5586 pAdapter->MlmeAux.CurrReqIsFromNdis = TRUE;
5587 pAdapter->StaCfg.bScanReqIsFromWebUI = FALSE;
5588 pAdapter->bConfigChanged = TRUE;
5590 MlmeEnqueue(pAdapter,
5591 MLME_CNTL_STATE_MACHINE,
5593 sizeof(NDIS_802_11_SSID),
5596 StateMachineTouched = TRUE;
5597 DBGPRINT(RT_DEBUG_TRACE, ("Set_SSID_Proc::(Len=%d,Ssid=%s)\n", Ssid.SsidLength, Ssid.Ssid));
5602 if (StateMachineTouched) // Upper layer sent a MLME-related operations
5603 RT28XX_MLME_HANDLER(pAdapter);
5610 ==========================================================================
5612 Set WmmCapable Enable or Disable
5614 TRUE if all parameters are OK, FALSE otherwise
5615 ==========================================================================
5617 INT Set_WmmCapable_Proc(
5618 IN PRTMP_ADAPTER pAd,
5621 BOOLEAN bWmmCapable;
5623 bWmmCapable = simple_strtol(arg, 0, 10);
5625 if ((bWmmCapable == 1)
5627 && (pAd->NumberOfPipes >= 5)
5630 pAd->CommonCfg.bWmmCapable = TRUE;
5631 else if (bWmmCapable == 0)
5632 pAd->CommonCfg.bWmmCapable = FALSE;
5634 return FALSE; //Invalid argument
5636 DBGPRINT(RT_DEBUG_TRACE, ("Set_WmmCapable_Proc::(bWmmCapable=%d)\n",
5637 pAd->CommonCfg.bWmmCapable));
5641 #endif // WMM_SUPPORT //
5644 ==========================================================================
5646 Set Network Type(Infrastructure/Adhoc mode)
5648 TRUE if all parameters are OK, FALSE otherwise
5649 ==========================================================================
5651 INT Set_NetworkType_Proc(
5652 IN PRTMP_ADAPTER pAdapter,
5657 if (strcmp(arg, "Adhoc") == 0)
5659 if (pAdapter->StaCfg.BssType != BSS_ADHOC)
5661 // Config has changed
5662 pAdapter->bConfigChanged = TRUE;
5663 if (MONITOR_ON(pAdapter))
5665 RTMP_IO_WRITE32(pAdapter, RX_FILTR_CFG, STANORMAL);
5666 RTMP_IO_READ32(pAdapter, MAC_SYS_CTRL, &Value);
5668 RTMP_IO_WRITE32(pAdapter, MAC_SYS_CTRL, Value);
5669 OPSTATUS_CLEAR_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED);
5670 pAdapter->StaCfg.bAutoReconnect = TRUE;
5671 LinkDown(pAdapter, FALSE);
5673 if (INFRA_ON(pAdapter))
5675 //BOOLEAN Cancelled;
5676 // Set the AutoReconnectSsid to prevent it reconnect to old SSID
5677 // Since calling this indicate user don't want to connect to that SSID anymore.
5678 pAdapter->MlmeAux.AutoReconnectSsidLen= 32;
5679 NdisZeroMemory(pAdapter->MlmeAux.AutoReconnectSsid, pAdapter->MlmeAux.AutoReconnectSsidLen);
5681 LinkDown(pAdapter, FALSE);
5683 DBGPRINT(RT_DEBUG_TRACE, ("NDIS_STATUS_MEDIA_DISCONNECT Event BB!\n"));
5686 pAdapter->StaCfg.BssType = BSS_ADHOC;
5687 pAdapter->net_dev->type = pAdapter->StaCfg.OriDevType;
5688 DBGPRINT(RT_DEBUG_TRACE, ("===>Set_NetworkType_Proc::(AD-HOC)\n"));
5690 else if (strcmp(arg, "Infra") == 0)
5692 if (pAdapter->StaCfg.BssType != BSS_INFRA)
5694 // Config has changed
5695 pAdapter->bConfigChanged = TRUE;
5696 if (MONITOR_ON(pAdapter))
5698 RTMP_IO_WRITE32(pAdapter, RX_FILTR_CFG, STANORMAL);
5699 RTMP_IO_READ32(pAdapter, MAC_SYS_CTRL, &Value);
5701 RTMP_IO_WRITE32(pAdapter, MAC_SYS_CTRL, Value);
5702 OPSTATUS_CLEAR_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED);
5703 pAdapter->StaCfg.bAutoReconnect = TRUE;
5704 LinkDown(pAdapter, FALSE);
5706 if (ADHOC_ON(pAdapter))
5708 // Set the AutoReconnectSsid to prevent it reconnect to old SSID
5709 // Since calling this indicate user don't want to connect to that SSID anymore.
5710 pAdapter->MlmeAux.AutoReconnectSsidLen= 32;
5711 NdisZeroMemory(pAdapter->MlmeAux.AutoReconnectSsid, pAdapter->MlmeAux.AutoReconnectSsidLen);
5713 LinkDown(pAdapter, FALSE);
5716 pAdapter->StaCfg.BssType = BSS_INFRA;
5717 pAdapter->net_dev->type = pAdapter->StaCfg.OriDevType;
5718 DBGPRINT(RT_DEBUG_TRACE, ("===>Set_NetworkType_Proc::(INFRA)\n"));
5720 pAdapter->StaCfg.BssType = BSS_INFRA;
5722 else if (strcmp(arg, "Monitor") == 0)
5725 BCN_TIME_CFG_STRUC csr;
5726 OPSTATUS_CLEAR_FLAG(pAdapter, fOP_STATUS_INFRA_ON);
5727 OPSTATUS_CLEAR_FLAG(pAdapter, fOP_STATUS_ADHOC_ON);
5728 OPSTATUS_SET_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED);
5729 // disable all periodic state machine
5730 pAdapter->StaCfg.bAutoReconnect = FALSE;
5731 // reset all mlme state machine
5732 RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
5733 DBGPRINT(RT_DEBUG_TRACE, ("fOP_STATUS_MEDIA_STATE_CONNECTED \n"));
5734 if (pAdapter->CommonCfg.CentralChannel == 0)
5736 #ifdef DOT11_N_SUPPORT
5737 if (pAdapter->CommonCfg.PhyMode == PHY_11AN_MIXED)
5738 pAdapter->CommonCfg.CentralChannel = 36;
5740 #endif // DOT11_N_SUPPORT //
5741 pAdapter->CommonCfg.CentralChannel = 6;
5743 #ifdef DOT11_N_SUPPORT
5745 N_ChannelCheck(pAdapter);
5746 #endif // DOT11_N_SUPPORT //
5748 #ifdef DOT11_N_SUPPORT
5749 if (pAdapter->CommonCfg.PhyMode >= PHY_11ABGN_MIXED &&
5750 pAdapter->CommonCfg.RegTransmitSetting.field.BW == BW_40 &&
5751 pAdapter->CommonCfg.RegTransmitSetting.field.EXTCHA == EXTCHA_ABOVE)
5753 // 40MHz ,control channel at lower
5754 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, BBP_R4, &bbpValue);
5755 bbpValue &= (~0x18);
5757 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R4, bbpValue);
5758 pAdapter->CommonCfg.BBPCurrentBW = BW_40;
5759 // RX : control channel at lower
5760 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, BBP_R3, &bbpValue);
5761 bbpValue &= (~0x20);
5762 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R3, bbpValue);
5764 RTMP_IO_READ32(pAdapter, TX_BAND_CFG, &Value);
5765 Value &= 0xfffffffe;
5766 RTMP_IO_WRITE32(pAdapter, TX_BAND_CFG, Value);
5767 pAdapter->CommonCfg.CentralChannel = pAdapter->CommonCfg.Channel + 2;
5768 AsicSwitchChannel(pAdapter, pAdapter->CommonCfg.CentralChannel, FALSE);
5769 AsicLockChannel(pAdapter, pAdapter->CommonCfg.CentralChannel);
5770 DBGPRINT(RT_DEBUG_TRACE, ("BW_40 ,control_channel(%d), CentralChannel(%d) \n",
5771 pAdapter->CommonCfg.Channel,
5772 pAdapter->CommonCfg.CentralChannel));
5774 else if (pAdapter->CommonCfg.PhyMode >= PHY_11ABGN_MIXED &&
5775 pAdapter->CommonCfg.RegTransmitSetting.field.BW == BW_40 &&
5776 pAdapter->CommonCfg.RegTransmitSetting.field.EXTCHA == EXTCHA_BELOW)
5778 // 40MHz ,control channel at upper
5779 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, BBP_R4, &bbpValue);
5780 bbpValue &= (~0x18);
5782 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R4, bbpValue);
5783 pAdapter->CommonCfg.BBPCurrentBW = BW_40;
5784 RTMP_IO_READ32(pAdapter, TX_BAND_CFG, &Value);
5786 RTMP_IO_WRITE32(pAdapter, TX_BAND_CFG, Value);
5788 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, BBP_R3, &bbpValue);
5790 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R3, bbpValue);
5791 pAdapter->CommonCfg.CentralChannel = pAdapter->CommonCfg.Channel - 2;
5792 AsicSwitchChannel(pAdapter, pAdapter->CommonCfg.CentralChannel, FALSE);
5793 AsicLockChannel(pAdapter, pAdapter->CommonCfg.CentralChannel);
5794 DBGPRINT(RT_DEBUG_TRACE, ("BW_40 ,control_channel(%d), CentralChannel(%d) \n",
5795 pAdapter->CommonCfg.Channel,
5796 pAdapter->CommonCfg.CentralChannel));
5799 #endif // DOT11_N_SUPPORT //
5802 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, BBP_R4, &bbpValue);
5803 bbpValue &= (~0x18);
5804 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R4, bbpValue);
5805 pAdapter->CommonCfg.BBPCurrentBW = BW_20;
5806 AsicSwitchChannel(pAdapter, pAdapter->CommonCfg.Channel, FALSE);
5807 AsicLockChannel(pAdapter, pAdapter->CommonCfg.Channel);
5808 DBGPRINT(RT_DEBUG_TRACE, ("BW_20, Channel(%d)\n", pAdapter->CommonCfg.Channel));
5810 // Enable Rx with promiscuous reception
5811 RTMP_IO_WRITE32(pAdapter, RX_FILTR_CFG, 0x3);
5812 // ASIC supporsts sniffer function with replacing RSSI with timestamp.
5813 //RTMP_IO_READ32(pAdapter, MAC_SYS_CTRL, &Value);
5815 //RTMP_IO_WRITE32(pAdapter, MAC_SYS_CTRL, Value);
5817 RTMP_IO_READ32(pAdapter, BCN_TIME_CFG, &csr.word);
5818 csr.field.bBeaconGen = 0;
5819 csr.field.bTBTTEnable = 0;
5820 csr.field.TsfSyncMode = 0;
5821 RTMP_IO_WRITE32(pAdapter, BCN_TIME_CFG, csr.word);
5823 pAdapter->StaCfg.BssType = BSS_MONITOR;
5824 pAdapter->net_dev->type = ARPHRD_IEEE80211_PRISM; //ARPHRD_IEEE80211; // IEEE80211
5825 DBGPRINT(RT_DEBUG_TRACE, ("===>Set_NetworkType_Proc::(MONITOR)\n"));
5828 // Reset Ralink supplicant to not use, it will be set to start when UI set PMK key
5829 pAdapter->StaCfg.WpaState = SS_NOTUSE;
5831 DBGPRINT(RT_DEBUG_TRACE, ("Set_NetworkType_Proc::(NetworkType=%d)\n", pAdapter->StaCfg.BssType));
5837 ==========================================================================
5839 Set Authentication mode
5841 TRUE if all parameters are OK, FALSE otherwise
5842 ==========================================================================
5844 INT Set_AuthMode_Proc(
5845 IN PRTMP_ADAPTER pAdapter,
5848 if ((strcmp(arg, "WEPAUTO") == 0) || (strcmp(arg, "wepauto") == 0))
5849 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeAutoSwitch;
5850 else if ((strcmp(arg, "OPEN") == 0) || (strcmp(arg, "open") == 0))
5851 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
5852 else if ((strcmp(arg, "SHARED") == 0) || (strcmp(arg, "shared") == 0))
5853 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeShared;
5854 else if ((strcmp(arg, "WPAPSK") == 0) || (strcmp(arg, "wpapsk") == 0))
5855 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPAPSK;
5856 else if ((strcmp(arg, "WPANONE") == 0) || (strcmp(arg, "wpanone") == 0))
5857 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPANone;
5858 else if ((strcmp(arg, "WPA2PSK") == 0) || (strcmp(arg, "wpa2psk") == 0))
5859 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA2PSK;
5860 #ifdef WPA_SUPPLICANT_SUPPORT
5861 else if ((strcmp(arg, "WPA") == 0) || (strcmp(arg, "wpa") == 0))
5862 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA;
5863 else if ((strcmp(arg, "WPA2") == 0) || (strcmp(arg, "wpa2") == 0))
5864 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA2;
5865 #endif // WPA_SUPPLICANT_SUPPORT //
5869 pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED;
5871 DBGPRINT(RT_DEBUG_TRACE, ("Set_AuthMode_Proc::(AuthMode=%d)\n", pAdapter->StaCfg.AuthMode));
5877 ==========================================================================
5881 TRUE if all parameters are OK, FALSE otherwise
5882 ==========================================================================
5884 INT Set_EncrypType_Proc(
5885 IN PRTMP_ADAPTER pAdapter,
5888 if ((strcmp(arg, "NONE") == 0) || (strcmp(arg, "none") == 0))
5890 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
5891 return TRUE; // do nothing
5893 pAdapter->StaCfg.WepStatus = Ndis802_11WEPDisabled;
5894 pAdapter->StaCfg.PairCipher = Ndis802_11WEPDisabled;
5895 pAdapter->StaCfg.GroupCipher = Ndis802_11WEPDisabled;
5897 else if ((strcmp(arg, "WEP") == 0) || (strcmp(arg, "wep") == 0))
5899 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
5900 return TRUE; // do nothing
5902 pAdapter->StaCfg.WepStatus = Ndis802_11WEPEnabled;
5903 pAdapter->StaCfg.PairCipher = Ndis802_11WEPEnabled;
5904 pAdapter->StaCfg.GroupCipher = Ndis802_11WEPEnabled;
5906 else if ((strcmp(arg, "TKIP") == 0) || (strcmp(arg, "tkip") == 0))
5908 if (pAdapter->StaCfg.AuthMode < Ndis802_11AuthModeWPA)
5909 return TRUE; // do nothing
5911 pAdapter->StaCfg.WepStatus = Ndis802_11Encryption2Enabled;
5912 pAdapter->StaCfg.PairCipher = Ndis802_11Encryption2Enabled;
5913 pAdapter->StaCfg.GroupCipher = Ndis802_11Encryption2Enabled;
5915 else if ((strcmp(arg, "AES") == 0) || (strcmp(arg, "aes") == 0))
5917 if (pAdapter->StaCfg.AuthMode < Ndis802_11AuthModeWPA)
5918 return TRUE; // do nothing
5920 pAdapter->StaCfg.WepStatus = Ndis802_11Encryption3Enabled;
5921 pAdapter->StaCfg.PairCipher = Ndis802_11Encryption3Enabled;
5922 pAdapter->StaCfg.GroupCipher = Ndis802_11Encryption3Enabled;
5927 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
5929 DBGPRINT(RT_DEBUG_TRACE, ("Set_EncrypType_Proc::(EncrypType=%d)\n", pAdapter->StaCfg.WepStatus));
5935 ==========================================================================
5939 TRUE if all parameters are OK, FALSE otherwise
5940 ==========================================================================
5942 INT Set_DefaultKeyID_Proc(
5943 IN PRTMP_ADAPTER pAdapter,
5948 KeyIdx = simple_strtol(arg, 0, 10);
5949 if((KeyIdx >= 1 ) && (KeyIdx <= 4))
5950 pAdapter->StaCfg.DefaultKeyId = (UCHAR) (KeyIdx - 1 );
5952 return FALSE; //Invalid argument
5954 DBGPRINT(RT_DEBUG_TRACE, ("Set_DefaultKeyID_Proc::(DefaultKeyID=%d)\n", pAdapter->StaCfg.DefaultKeyId));
5960 ==========================================================================
5964 TRUE if all parameters are OK, FALSE otherwise
5965 ==========================================================================
5968 IN PRTMP_ADAPTER pAdapter,
5973 UCHAR CipherAlg=CIPHER_WEP64;
5975 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
5976 return TRUE; // do nothing
5978 KeyLen = strlen(arg);
5982 case 5: //wep 40 Ascii type
5983 pAdapter->SharedKey[BSS0][0].KeyLen = KeyLen;
5984 memcpy(pAdapter->SharedKey[BSS0][0].Key, arg, KeyLen);
5985 CipherAlg = CIPHER_WEP64;
5986 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key1_Proc::(Key1=%s and type=%s)\n", arg, "Ascii"));
5988 case 10: //wep 40 Hex type
5989 for(i=0; i < KeyLen; i++)
5991 if( !isxdigit(*(arg+i)) )
5992 return FALSE; //Not Hex value;
5994 pAdapter->SharedKey[BSS0][0].KeyLen = KeyLen / 2 ;
5995 AtoH(arg, pAdapter->SharedKey[BSS0][0].Key, KeyLen / 2);
5996 CipherAlg = CIPHER_WEP64;
5997 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key1_Proc::(Key1=%s and type=%s)\n", arg, "Hex"));
5999 case 13: //wep 104 Ascii type
6000 pAdapter->SharedKey[BSS0][0].KeyLen = KeyLen;
6001 memcpy(pAdapter->SharedKey[BSS0][0].Key, arg, KeyLen);
6002 CipherAlg = CIPHER_WEP128;
6003 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key1_Proc::(Key1=%s and type=%s)\n", arg, "Ascii"));
6005 case 26: //wep 104 Hex type
6006 for(i=0; i < KeyLen; i++)
6008 if( !isxdigit(*(arg+i)) )
6009 return FALSE; //Not Hex value;
6011 pAdapter->SharedKey[BSS0][0].KeyLen = KeyLen / 2 ;
6012 AtoH(arg, pAdapter->SharedKey[BSS0][0].Key, KeyLen / 2);
6013 CipherAlg = CIPHER_WEP128;
6014 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key1_Proc::(Key1=%s and type=%s)\n", arg, "Hex"));
6016 default: //Invalid argument
6017 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key1_Proc::Invalid argument (=%s)\n", arg));
6021 pAdapter->SharedKey[BSS0][0].CipherAlg = CipherAlg;
6023 // Set keys (into ASIC)
6024 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
6026 else // Old WEP stuff
6028 AsicAddSharedKeyEntry(pAdapter,
6031 pAdapter->SharedKey[BSS0][0].CipherAlg,
6032 pAdapter->SharedKey[BSS0][0].Key,
6040 ==========================================================================
6045 TRUE if all parameters are OK, FALSE otherwise
6046 ==========================================================================
6049 IN PRTMP_ADAPTER pAdapter,
6054 UCHAR CipherAlg=CIPHER_WEP64;
6056 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
6057 return TRUE; // do nothing
6059 KeyLen = strlen(arg);
6063 case 5: //wep 40 Ascii type
6064 pAdapter->SharedKey[BSS0][1].KeyLen = KeyLen;
6065 memcpy(pAdapter->SharedKey[BSS0][1].Key, arg, KeyLen);
6066 CipherAlg = CIPHER_WEP64;
6067 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key2_Proc::(Key2=%s and type=%s)\n", arg, "Ascii"));
6069 case 10: //wep 40 Hex type
6070 for(i=0; i < KeyLen; i++)
6072 if( !isxdigit(*(arg+i)) )
6073 return FALSE; //Not Hex value;
6075 pAdapter->SharedKey[BSS0][1].KeyLen = KeyLen / 2 ;
6076 AtoH(arg, pAdapter->SharedKey[BSS0][1].Key, KeyLen / 2);
6077 CipherAlg = CIPHER_WEP64;
6078 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key2_Proc::(Key2=%s and type=%s)\n", arg, "Hex"));
6080 case 13: //wep 104 Ascii type
6081 pAdapter->SharedKey[BSS0][1].KeyLen = KeyLen;
6082 memcpy(pAdapter->SharedKey[BSS0][1].Key, arg, KeyLen);
6083 CipherAlg = CIPHER_WEP128;
6084 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key2_Proc::(Key2=%s and type=%s)\n", arg, "Ascii"));
6086 case 26: //wep 104 Hex type
6087 for(i=0; i < KeyLen; i++)
6089 if( !isxdigit(*(arg+i)) )
6090 return FALSE; //Not Hex value;
6092 pAdapter->SharedKey[BSS0][1].KeyLen = KeyLen / 2 ;
6093 AtoH(arg, pAdapter->SharedKey[BSS0][1].Key, KeyLen / 2);
6094 CipherAlg = CIPHER_WEP128;
6095 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key2_Proc::(Key2=%s and type=%s)\n", arg, "Hex"));
6097 default: //Invalid argument
6098 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key2_Proc::Invalid argument (=%s)\n", arg));
6101 pAdapter->SharedKey[BSS0][1].CipherAlg = CipherAlg;
6103 // Set keys (into ASIC)
6104 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
6106 else // Old WEP stuff
6108 AsicAddSharedKeyEntry(pAdapter,
6111 pAdapter->SharedKey[BSS0][1].CipherAlg,
6112 pAdapter->SharedKey[BSS0][1].Key,
6120 ==========================================================================
6124 TRUE if all parameters are OK, FALSE otherwise
6125 ==========================================================================
6128 IN PRTMP_ADAPTER pAdapter,
6133 UCHAR CipherAlg=CIPHER_WEP64;
6135 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
6136 return TRUE; // do nothing
6138 KeyLen = strlen(arg);
6142 case 5: //wep 40 Ascii type
6143 pAdapter->SharedKey[BSS0][2].KeyLen = KeyLen;
6144 memcpy(pAdapter->SharedKey[BSS0][2].Key, arg, KeyLen);
6145 CipherAlg = CIPHER_WEP64;
6146 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key3_Proc::(Key3=%s and type=Ascii)\n", arg));
6148 case 10: //wep 40 Hex type
6149 for(i=0; i < KeyLen; i++)
6151 if( !isxdigit(*(arg+i)) )
6152 return FALSE; //Not Hex value;
6154 pAdapter->SharedKey[BSS0][2].KeyLen = KeyLen / 2 ;
6155 AtoH(arg, pAdapter->SharedKey[BSS0][2].Key, KeyLen / 2);
6156 CipherAlg = CIPHER_WEP64;
6157 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key3_Proc::(Key3=%s and type=Hex)\n", arg));
6159 case 13: //wep 104 Ascii type
6160 pAdapter->SharedKey[BSS0][2].KeyLen = KeyLen;
6161 memcpy(pAdapter->SharedKey[BSS0][2].Key, arg, KeyLen);
6162 CipherAlg = CIPHER_WEP128;
6163 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key3_Proc::(Key3=%s and type=Ascii)\n", arg));
6165 case 26: //wep 104 Hex type
6166 for(i=0; i < KeyLen; i++)
6168 if( !isxdigit(*(arg+i)) )
6169 return FALSE; //Not Hex value;
6171 pAdapter->SharedKey[BSS0][2].KeyLen = KeyLen / 2 ;
6172 AtoH(arg, pAdapter->SharedKey[BSS0][2].Key, KeyLen / 2);
6173 CipherAlg = CIPHER_WEP128;
6174 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key3_Proc::(Key3=%s and type=Hex)\n", arg));
6176 default: //Invalid argument
6177 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key3_Proc::Invalid argument (=%s)\n", arg));
6180 pAdapter->SharedKey[BSS0][2].CipherAlg = CipherAlg;
6182 // Set keys (into ASIC)
6183 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
6185 else // Old WEP stuff
6187 AsicAddSharedKeyEntry(pAdapter,
6190 pAdapter->SharedKey[BSS0][2].CipherAlg,
6191 pAdapter->SharedKey[BSS0][2].Key,
6199 ==========================================================================
6203 TRUE if all parameters are OK, FALSE otherwise
6204 ==========================================================================
6207 IN PRTMP_ADAPTER pAdapter,
6212 UCHAR CipherAlg=CIPHER_WEP64;
6214 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
6215 return TRUE; // do nothing
6217 KeyLen = strlen(arg);
6221 case 5: //wep 40 Ascii type
6222 pAdapter->SharedKey[BSS0][3].KeyLen = KeyLen;
6223 memcpy(pAdapter->SharedKey[BSS0][3].Key, arg, KeyLen);
6224 CipherAlg = CIPHER_WEP64;
6225 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key4_Proc::(Key4=%s and type=%s)\n", arg, "Ascii"));
6227 case 10: //wep 40 Hex type
6228 for(i=0; i < KeyLen; i++)
6230 if( !isxdigit(*(arg+i)) )
6231 return FALSE; //Not Hex value;
6233 pAdapter->SharedKey[BSS0][3].KeyLen = KeyLen / 2 ;
6234 AtoH(arg, pAdapter->SharedKey[BSS0][3].Key, KeyLen / 2);
6235 CipherAlg = CIPHER_WEP64;
6236 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key4_Proc::(Key4=%s and type=%s)\n", arg, "Hex"));
6238 case 13: //wep 104 Ascii type
6239 pAdapter->SharedKey[BSS0][3].KeyLen = KeyLen;
6240 memcpy(pAdapter->SharedKey[BSS0][3].Key, arg, KeyLen);
6241 CipherAlg = CIPHER_WEP128;
6242 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key4_Proc::(Key4=%s and type=%s)\n", arg, "Ascii"));
6244 case 26: //wep 104 Hex type
6245 for(i=0; i < KeyLen; i++)
6247 if( !isxdigit(*(arg+i)) )
6248 return FALSE; //Not Hex value;
6250 pAdapter->SharedKey[BSS0][3].KeyLen = KeyLen / 2 ;
6251 AtoH(arg, pAdapter->SharedKey[BSS0][3].Key, KeyLen / 2);
6252 CipherAlg = CIPHER_WEP128;
6253 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key4_Proc::(Key4=%s and type=%s)\n", arg, "Hex"));
6255 default: //Invalid argument
6256 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key4_Proc::Invalid argument (=%s)\n", arg));
6259 pAdapter->SharedKey[BSS0][3].CipherAlg = CipherAlg;
6261 // Set keys (into ASIC)
6262 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
6264 else // Old WEP stuff
6266 AsicAddSharedKeyEntry(pAdapter,
6269 pAdapter->SharedKey[BSS0][3].CipherAlg,
6270 pAdapter->SharedKey[BSS0][3].Key,
6279 ==========================================================================
6283 TRUE if all parameters are OK, FALSE otherwise
6284 ==========================================================================
6286 INT Set_WPAPSK_Proc(
6287 IN PRTMP_ADAPTER pAdapter,
6290 UCHAR keyMaterial[40];
6292 if ((pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPAPSK) &&
6293 (pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPA2PSK) &&
6294 (pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPANone)
6296 return TRUE; // do nothing
6298 DBGPRINT(RT_DEBUG_TRACE, ("Set_WPAPSK_Proc::(WPAPSK=%s)\n", arg));
6300 NdisZeroMemory(keyMaterial, 40);
6302 if ((strlen(arg) < 8) || (strlen(arg) > 64))
6304 DBGPRINT(RT_DEBUG_TRACE, ("Set failed!!(WPAPSK=%s), WPAPSK key-string required 8 ~ 64 characters \n", arg));
6308 if (strlen(arg) == 64)
6310 AtoH(arg, keyMaterial, 32);
6311 NdisMoveMemory(pAdapter->StaCfg.PMK, keyMaterial, 32);
6316 PasswordHash((char *)arg, pAdapter->MlmeAux.Ssid, pAdapter->MlmeAux.SsidLen, keyMaterial);
6317 NdisMoveMemory(pAdapter->StaCfg.PMK, keyMaterial, 32);
6322 if(pAdapter->StaCfg.BssType == BSS_ADHOC &&
6323 pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPANone)
6325 pAdapter->StaCfg.WpaState = SS_NOTUSE;
6329 // Start STA supplicant state machine
6330 pAdapter->StaCfg.WpaState = SS_START;
6337 ==========================================================================
6339 Set Power Saving mode
6341 TRUE if all parameters are OK, FALSE otherwise
6342 ==========================================================================
6344 INT Set_PSMode_Proc(
6345 IN PRTMP_ADAPTER pAdapter,
6348 if (pAdapter->StaCfg.BssType == BSS_INFRA)
6350 if ((strcmp(arg, "Max_PSP") == 0) ||
6351 (strcmp(arg, "max_psp") == 0) ||
6352 (strcmp(arg, "MAX_PSP") == 0))
6354 // do NOT turn on PSM bit here, wait until MlmeCheckForPsmChange()
6355 // to exclude certain situations.
6356 if (pAdapter->StaCfg.bWindowsACCAMEnable == FALSE)
6357 pAdapter->StaCfg.WindowsPowerMode = Ndis802_11PowerModeMAX_PSP;
6358 pAdapter->StaCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeMAX_PSP;
6359 OPSTATUS_SET_FLAG(pAdapter, fOP_STATUS_RECEIVE_DTIM);
6360 pAdapter->StaCfg.DefaultListenCount = 5;
6363 else if ((strcmp(arg, "Fast_PSP") == 0) ||
6364 (strcmp(arg, "fast_psp") == 0) ||
6365 (strcmp(arg, "FAST_PSP") == 0))
6367 // do NOT turn on PSM bit here, wait until MlmeCheckForPsmChange()
6368 // to exclude certain situations.
6369 OPSTATUS_SET_FLAG(pAdapter, fOP_STATUS_RECEIVE_DTIM);
6370 if (pAdapter->StaCfg.bWindowsACCAMEnable == FALSE)
6371 pAdapter->StaCfg.WindowsPowerMode = Ndis802_11PowerModeFast_PSP;
6372 pAdapter->StaCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeFast_PSP;
6373 pAdapter->StaCfg.DefaultListenCount = 3;
6375 else if ((strcmp(arg, "Legacy_PSP") == 0) ||
6376 (strcmp(arg, "legacy_psp") == 0) ||
6377 (strcmp(arg, "LEGACY_PSP") == 0))
6379 // do NOT turn on PSM bit here, wait until MlmeCheckForPsmChange()
6380 // to exclude certain situations.
6381 OPSTATUS_SET_FLAG(pAdapter, fOP_STATUS_RECEIVE_DTIM);
6382 if (pAdapter->StaCfg.bWindowsACCAMEnable == FALSE)
6383 pAdapter->StaCfg.WindowsPowerMode = Ndis802_11PowerModeLegacy_PSP;
6384 pAdapter->StaCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeLegacy_PSP;
6385 pAdapter->StaCfg.DefaultListenCount = 3;
6389 //Default Ndis802_11PowerModeCAM
6390 // clear PSM bit immediately
6391 MlmeSetPsmBit(pAdapter, PWR_ACTIVE);
6392 OPSTATUS_SET_FLAG(pAdapter, fOP_STATUS_RECEIVE_DTIM);
6393 if (pAdapter->StaCfg.bWindowsACCAMEnable == FALSE)
6394 pAdapter->StaCfg.WindowsPowerMode = Ndis802_11PowerModeCAM;
6395 pAdapter->StaCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeCAM;
6398 DBGPRINT(RT_DEBUG_TRACE, ("Set_PSMode_Proc::(PSMode=%ld)\n", pAdapter->StaCfg.WindowsPowerMode));
6407 #ifdef WPA_SUPPLICANT_SUPPORT
6409 ==========================================================================
6411 Set WpaSupport flag.
6413 0: Driver ignore wpa_supplicant.
6414 1: wpa_supplicant initiates scanning and AP selection.
6415 2: driver takes care of scanning, AP selection, and IEEE 802.11 association parameters.
6417 TRUE if all parameters are OK, FALSE otherwise
6418 ==========================================================================
6420 INT Set_Wpa_Support(
6421 IN PRTMP_ADAPTER pAd,
6425 if ( simple_strtol(arg, 0, 10) == 0)
6426 pAd->StaCfg.WpaSupplicantUP = WPA_SUPPLICANT_DISABLE;
6427 else if ( simple_strtol(arg, 0, 10) == 1)
6428 pAd->StaCfg.WpaSupplicantUP = WPA_SUPPLICANT_ENABLE;
6429 else if ( simple_strtol(arg, 0, 10) == 2)
6430 pAd->StaCfg.WpaSupplicantUP = WPA_SUPPLICANT_ENABLE_WITH_WEB_UI;
6432 pAd->StaCfg.WpaSupplicantUP = WPA_SUPPLICANT_DISABLE;
6434 DBGPRINT(RT_DEBUG_TRACE, ("Set_Wpa_Support::(WpaSupplicantUP=%d)\n", pAd->StaCfg.WpaSupplicantUP));
6438 #endif // WPA_SUPPLICANT_SUPPORT //
6442 ==========================================================================
6446 pAdapter Pointer to our adapter
6447 wrq Pointer to the ioctl argument
6454 1.) iwpriv ra0 mac 0 ==> read MAC where Addr=0x0
6455 2.) iwpriv ra0 mac 0=12 ==> write MAC where Addr=0x0, value=12
6456 ==========================================================================
6459 IN PRTMP_ADAPTER pAdapter,
6460 IN struct iwreq *wrq)
6468 UCHAR temp[16], temp2[16];
6469 UINT32 macValue = 0;
6473 memset(msg, 0x00, 1024);
6474 if (wrq->u.data.length > 1) //No parameters.
6476 Status = copy_from_user(arg, wrq->u.data.pointer, (wrq->u.data.length > 255) ? 255 : wrq->u.data.length);
6479 //Parsing Read or Write
6484 if ((value = rtstrchr(this_char, '=')) != NULL)
6487 if (!value || !*value)
6490 if(strlen(this_char) > 4)
6493 j = strlen(this_char);
6496 if(this_char[j] > 'f' || this_char[j] < '0')
6501 k = j = strlen(this_char);
6504 this_char[4-k+j] = this_char[j];
6508 this_char[3-k++]='0';
6511 if(strlen(this_char) == 4)
6513 AtoH(this_char, temp, 2);
6514 macAddr = *temp*256 + temp[1];
6515 if (macAddr < 0xFFFF)
6517 RTMP_IO_READ32(pAdapter, macAddr, &macValue);
6518 DBGPRINT(RT_DEBUG_TRACE, ("MacAddr=%lx, MacValue=%x\n", macAddr, macValue));
6519 sprintf(msg+strlen(msg), "[0x%08lX]:%08X ", macAddr , macValue);
6522 {//Invalid parametes, so default printk all bbp
6529 memcpy(&temp2, value, strlen(value));
6530 temp2[strlen(value)] = '\0';
6533 if((strlen(this_char) > 4) || strlen(temp2) > 8)
6536 j = strlen(this_char);
6539 if(this_char[j] > 'f' || this_char[j] < '0')
6546 if(temp2[j] > 'f' || temp2[j] < '0')
6551 k = j = strlen(this_char);
6554 this_char[4-k+j] = this_char[j];
6558 this_char[3-k++]='0';
6562 k = j = strlen(temp2);
6565 temp2[8-k+j] = temp2[j];
6573 AtoH(this_char, temp, 2);
6574 macAddr = *temp*256 + temp[1];
6576 AtoH(temp2, temp, 4);
6577 macValue = *temp*256*256*256 + temp[1]*256*256 + temp[2]*256 + temp[3];
6580 if (macAddr == (HW_DEBUG_SETTING_BASE + 4))
6582 // 0x2bf4: byte0 non-zero: enable R17 tuning, 0: disable R17 tuning
6583 if (macValue & 0x000000ff)
6585 pAdapter->BbpTuning.bEnable = TRUE;
6586 DBGPRINT(RT_DEBUG_TRACE,("turn on R17 tuning\n"));
6591 pAdapter->BbpTuning.bEnable = FALSE;
6592 R66 = 0x26 + GET_LNA_GAIN(pAdapter);
6593 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R66, (0x26 + GET_LNA_GAIN(pAdapter)));
6594 DBGPRINT(RT_DEBUG_TRACE,("turn off R17 tuning, restore to 0x%02x\n", R66));
6599 DBGPRINT(RT_DEBUG_TRACE, ("MacAddr=%02lx, MacValue=0x%x\n", macAddr, macValue));
6601 RTMP_IO_WRITE32(pAdapter, macAddr, macValue);
6602 sprintf(msg+strlen(msg), "[0x%08lX]:%08X ", macAddr, macValue);
6607 if(strlen(msg) == 1)
6608 sprintf(msg+strlen(msg), "===>Error command format!");
6610 // Copy the information into the user buffer
6611 wrq->u.data.length = strlen(msg);
6612 Status = copy_to_user(wrq->u.data.pointer, msg, wrq->u.data.length);
6614 DBGPRINT(RT_DEBUG_TRACE, ("<==RTMPIoctlMAC\n\n"));
6618 ==========================================================================
6622 pAdapter Pointer to our adapter
6623 wrq Pointer to the ioctl argument
6630 1.) iwpriv ra0 e2p 0 ==> read E2PROM where Addr=0x0
6631 2.) iwpriv ra0 e2p 0=1234 ==> write E2PROM where Addr=0x0, value=1234
6632 ==========================================================================
6634 VOID RTMPIoctlE2PROM(
6635 IN PRTMP_ADAPTER pAdapter,
6636 IN struct iwreq *wrq)
6644 UCHAR temp[16], temp2[16];
6649 memset(msg, 0x00, 1024);
6650 if (wrq->u.data.length > 1) //No parameters.
6652 Status = copy_from_user(arg, wrq->u.data.pointer, (wrq->u.data.length > 255) ? 255 : wrq->u.data.length);
6655 //Parsing Read or Write
6662 if ((value = rtstrchr(this_char, '=')) != NULL)
6665 if (!value || !*value)
6669 if(strlen(this_char) > 4)
6672 j = strlen(this_char);
6675 if(this_char[j] > 'f' || this_char[j] < '0')
6680 k = j = strlen(this_char);
6683 this_char[4-k+j] = this_char[j];
6687 this_char[3-k++]='0';
6690 if(strlen(this_char) == 4)
6692 AtoH(this_char, temp, 2);
6693 eepAddr = *temp*256 + temp[1];
6694 if (eepAddr < 0xFFFF)
6696 RT28xx_EEPROM_READ16(pAdapter, eepAddr, eepValue);
6697 sprintf(msg+strlen(msg), "[0x%04X]:0x%04X ", eepAddr , eepValue);
6700 {//Invalid parametes, so default printk all bbp
6707 memcpy(&temp2, value, strlen(value));
6708 temp2[strlen(value)] = '\0';
6711 if((strlen(this_char) > 4) || strlen(temp2) > 8)
6714 j = strlen(this_char);
6717 if(this_char[j] > 'f' || this_char[j] < '0')
6723 if(temp2[j] > 'f' || temp2[j] < '0')
6728 k = j = strlen(this_char);
6731 this_char[4-k+j] = this_char[j];
6735 this_char[3-k++]='0';
6739 k = j = strlen(temp2);
6742 temp2[4-k+j] = temp2[j];
6749 AtoH(this_char, temp, 2);
6750 eepAddr = *temp*256 + temp[1];
6752 AtoH(temp2, temp, 2);
6753 eepValue = *temp*256 + temp[1];
6755 RT28xx_EEPROM_WRITE16(pAdapter, eepAddr, eepValue);
6756 sprintf(msg+strlen(msg), "[0x%02X]:%02X ", eepAddr, eepValue);
6760 if(strlen(msg) == 1)
6761 sprintf(msg+strlen(msg), "===>Error command format!");
6764 // Copy the information into the user buffer
6765 wrq->u.data.length = strlen(msg);
6766 Status = copy_to_user(wrq->u.data.pointer, msg, wrq->u.data.length);
6768 DBGPRINT(RT_DEBUG_TRACE, ("<==RTMPIoctlE2PROM\n"));
6775 INT Set_TGnWifiTest_Proc(
6776 IN PRTMP_ADAPTER pAd,
6779 if (simple_strtol(arg, 0, 10) == 0)
6780 pAd->StaCfg.bTGnWifiTest = FALSE;
6782 pAd->StaCfg.bTGnWifiTest = TRUE;
6784 DBGPRINT(RT_DEBUG_TRACE, ("IF Set_TGnWifiTest_Proc::(bTGnWifiTest=%d)\n", pAd->StaCfg.bTGnWifiTest));
6788 INT Set_LongRetryLimit_Proc(
6789 IN PRTMP_ADAPTER pAdapter,
6792 TX_RTY_CFG_STRUC tx_rty_cfg;
6793 UCHAR LongRetryLimit = (UCHAR)simple_strtol(arg, 0, 10);
6795 RTMP_IO_READ32(pAdapter, TX_RTY_CFG, &tx_rty_cfg.word);
6796 tx_rty_cfg.field.LongRtyLimit = LongRetryLimit;
6797 RTMP_IO_WRITE32(pAdapter, TX_RTY_CFG, tx_rty_cfg.word);
6798 DBGPRINT(RT_DEBUG_TRACE, ("IF Set_LongRetryLimit_Proc::(tx_rty_cfg=0x%x)\n", tx_rty_cfg.word));
6802 INT Set_ShortRetryLimit_Proc(
6803 IN PRTMP_ADAPTER pAdapter,
6806 TX_RTY_CFG_STRUC tx_rty_cfg;
6807 UCHAR ShortRetryLimit = (UCHAR)simple_strtol(arg, 0, 10);
6809 RTMP_IO_READ32(pAdapter, TX_RTY_CFG, &tx_rty_cfg.word);
6810 tx_rty_cfg.field.ShortRtyLimit = ShortRetryLimit;
6811 RTMP_IO_WRITE32(pAdapter, TX_RTY_CFG, tx_rty_cfg.word);
6812 DBGPRINT(RT_DEBUG_TRACE, ("IF Set_ShortRetryLimit_Proc::(tx_rty_cfg=0x%x)\n", tx_rty_cfg.word));
6816 #ifdef EXT_BUILD_CHANNEL_LIST
6817 INT Set_Ieee80211dClientMode_Proc(
6818 IN PRTMP_ADAPTER pAdapter,
6821 if (simple_strtol(arg, 0, 10) == 0)
6822 pAdapter->StaCfg.IEEE80211dClientMode = Rt802_11_D_None;
6823 else if (simple_strtol(arg, 0, 10) == 1)
6824 pAdapter->StaCfg.IEEE80211dClientMode = Rt802_11_D_Flexible;
6825 else if (simple_strtol(arg, 0, 10) == 2)
6826 pAdapter->StaCfg.IEEE80211dClientMode = Rt802_11_D_Strict;
6830 DBGPRINT(RT_DEBUG_TRACE, ("Set_Ieee802dMode_Proc::(IEEEE0211dMode=%d)\n", pAdapter->StaCfg.IEEE80211dClientMode));
6833 #endif // EXT_BUILD_CHANNEL_LIST //
6835 INT Show_Adhoc_MacTable_Proc(
6836 IN PRTMP_ADAPTER pAd,
6841 sprintf(extra, "\n");
6843 #ifdef DOT11_N_SUPPORT
6844 sprintf(extra + strlen(extra), "HT Operating Mode : %d\n", pAd->CommonCfg.AddHTInfo.AddHtInfo2.OperaionMode);
6845 #endif // DOT11_N_SUPPORT //
6847 sprintf(extra + strlen(extra), "\n%-19s%-4s%-4s%-7s%-7s%-7s%-10s%-6s%-6s%-6s%-6s\n",
6848 "MAC", "AID", "BSS", "RSSI0", "RSSI1", "RSSI2", "PhMd", "BW", "MCS", "SGI", "STBC");
6850 for (i=1; i<MAX_LEN_OF_MAC_TABLE; i++)
6852 PMAC_TABLE_ENTRY pEntry = &pAd->MacTab.Content[i];
6854 if (strlen(extra) > (IW_PRIV_SIZE_MASK - 30))
6856 if ((pEntry->ValidAsCLI || pEntry->ValidAsApCli) && (pEntry->Sst == SST_ASSOC))
6858 sprintf(extra + strlen(extra), "%02X:%02X:%02X:%02X:%02X:%02X ",
6859 pEntry->Addr[0], pEntry->Addr[1], pEntry->Addr[2],
6860 pEntry->Addr[3], pEntry->Addr[4], pEntry->Addr[5]);
6861 sprintf(extra + strlen(extra), "%-4d", (int)pEntry->Aid);
6862 sprintf(extra + strlen(extra), "%-4d", (int)pEntry->apidx);
6863 sprintf(extra + strlen(extra), "%-7d", pEntry->RssiSample.AvgRssi0);
6864 sprintf(extra + strlen(extra), "%-7d", pEntry->RssiSample.AvgRssi1);
6865 sprintf(extra + strlen(extra), "%-7d", pEntry->RssiSample.AvgRssi2);
6866 sprintf(extra + strlen(extra), "%-10s", GetPhyMode(pEntry->HTPhyMode.field.MODE));
6867 sprintf(extra + strlen(extra), "%-6s", GetBW(pEntry->HTPhyMode.field.BW));
6868 sprintf(extra + strlen(extra), "%-6d", pEntry->HTPhyMode.field.MCS);
6869 sprintf(extra + strlen(extra), "%-6d", pEntry->HTPhyMode.field.ShortGI);
6870 sprintf(extra + strlen(extra), "%-6d", pEntry->HTPhyMode.field.STBC);
6871 sprintf(extra + strlen(extra), "%-10d, %d, %d%%\n", pEntry->DebugFIFOCount, pEntry->DebugTxCount,
6872 (pEntry->DebugTxCount) ? ((pEntry->DebugTxCount-pEntry->DebugFIFOCount)*100/pEntry->DebugTxCount) : 0);
6873 sprintf(extra, "%s\n", extra);