2 *************************************************************************
4 * 5F., No.36, Taiyuan St., Jhubei City,
8 * (c) Copyright 2002-2007, Ralink Technology, Inc.
10 * This program is free software; you can redistribute it and/or modify *
11 * it under the terms of the GNU General Public License as published by *
12 * the Free Software Foundation; either version 2 of the License, or *
13 * (at your option) any later version. *
15 * This program is distributed in the hope that it will be useful, *
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
18 * GNU General Public License for more details. *
20 * You should have received a copy of the GNU General Public License *
21 * along with this program; if not, write to the *
22 * Free Software Foundation, Inc., *
23 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
25 *************************************************************************
31 IOCTL related subroutines
35 -------- ---------- ----------------------------------------------
36 Rory Chen 01-03-2003 created
37 Rory Chen 02-14-2005 modify to support RT61
40 #include "rt_config.h"
43 extern ULONG RTDebugLevel;
47 #define WEP_SMALL_KEY_LEN (40/8)
48 #define WEP_LARGE_KEY_LEN (104/8)
50 #define GROUP_KEY_NO 4
52 extern UCHAR CipherWpa2Template[];
53 extern UCHAR CipherWpaPskTkip[];
54 extern UCHAR CipherWpaPskTkipLen;
56 typedef struct PACKED _RT_VERSION_INFO{
62 UINT DriverBuildMonth;
64 } RT_VERSION_INFO, *PRT_VERSION_INFO;
66 struct iw_priv_args privtab[] = {
68 IW_PRIV_TYPE_CHAR | 1024, 0,
71 { RTPRIV_IOCTL_SHOW, 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK,
73 { RTPRIV_IOCTL_SHOW, IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK,
75 /* --- sub-ioctls definitions --- */
77 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "connStatus" },
79 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "driverVer" },
81 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "bainfo" },
83 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "descinfo" },
85 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "radio_off" },
87 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "radio_on" },
89 IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "show" },
90 { SHOW_ADHOC_ENTRY_INFO,
91 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "adhocEntry" },
93 /* --- sub-ioctls relations --- */
97 IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK,
100 IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | 1024,
103 IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | 1024,
107 { RTPRIV_IOCTL_STATISTICS,
108 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK,
110 { RTPRIV_IOCTL_GSITESURVEY,
111 0, IW_PRIV_TYPE_CHAR | 1024,
116 IN PRTMP_ADAPTER pAdapter,
120 INT Set_WmmCapable_Proc(
121 IN PRTMP_ADAPTER pAd,
125 INT Set_NetworkType_Proc(
126 IN PRTMP_ADAPTER pAdapter,
129 INT Set_AuthMode_Proc(
130 IN PRTMP_ADAPTER pAdapter,
133 INT Set_EncrypType_Proc(
134 IN PRTMP_ADAPTER pAdapter,
137 INT Set_DefaultKeyID_Proc(
138 IN PRTMP_ADAPTER pAdapter,
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,
163 IN PRTMP_ADAPTER pAdapter,
167 IN PRTMP_ADAPTER pAd,
172 IN PRTMP_ADAPTER pAdapter,
173 IN struct iwreq *wrq);
176 IN PRTMP_ADAPTER pAdapter,
177 IN struct iwreq *wrq);
179 VOID RTMPIoctlE2PROM(
180 IN PRTMP_ADAPTER pAdapter,
181 IN struct iwreq *wrq);
185 NDIS_STATUS RTMPWPANoneAddKeyProc(
186 IN PRTMP_ADAPTER pAd,
189 INT Set_FragTest_Proc(
190 IN PRTMP_ADAPTER pAdapter,
193 #ifdef DOT11_N_SUPPORT
194 INT Set_TGnWifiTest_Proc(
195 IN PRTMP_ADAPTER pAd,
197 #endif // DOT11_N_SUPPORT //
199 INT Set_LongRetryLimit_Proc(
200 IN PRTMP_ADAPTER pAdapter,
203 INT Set_ShortRetryLimit_Proc(
204 IN PRTMP_ADAPTER pAdapter,
207 INT Show_Adhoc_MacTable_Proc(
208 IN PRTMP_ADAPTER pAd,
213 INT (*set_proc)(PRTMP_ADAPTER pAdapter, PUCHAR arg);
214 } *PRTMP_PRIVATE_SET_PROC, RTMP_PRIVATE_SUPPORT_PROC[] = {
215 {"DriverVersion", Set_DriverVersion_Proc},
216 {"CountryRegion", Set_CountryRegion_Proc},
217 {"CountryRegionABand", Set_CountryRegionABand_Proc},
218 {"SSID", Set_SSID_Proc},
219 {"WirelessMode", Set_WirelessMode_Proc},
220 {"TxBurst", Set_TxBurst_Proc},
221 {"TxPreamble", Set_TxPreamble_Proc},
222 {"TxPower", Set_TxPower_Proc},
223 {"Channel", Set_Channel_Proc},
224 {"BGProtection", Set_BGProtection_Proc},
225 {"RTSThreshold", Set_RTSThreshold_Proc},
226 {"FragThreshold", Set_FragThreshold_Proc},
227 #ifdef DOT11_N_SUPPORT
228 {"HtBw", Set_HtBw_Proc},
229 {"HtMcs", Set_HtMcs_Proc},
230 {"HtGi", Set_HtGi_Proc},
231 {"HtOpMode", Set_HtOpMode_Proc},
232 {"HtExtcha", Set_HtExtcha_Proc},
233 {"HtMpduDensity", Set_HtMpduDensity_Proc},
234 {"HtBaWinSize", Set_HtBaWinSize_Proc},
235 {"HtRdg", Set_HtRdg_Proc},
236 {"HtAmsdu", Set_HtAmsdu_Proc},
237 {"HtAutoBa", Set_HtAutoBa_Proc},
238 {"HtBaDecline", Set_BADecline_Proc},
239 {"HtProtect", Set_HtProtect_Proc},
240 {"HtMimoPs", Set_HtMimoPs_Proc},
241 #endif // DOT11_N_SUPPORT //
243 #ifdef AGGREGATION_SUPPORT
244 {"PktAggregate", Set_PktAggregate_Proc},
248 {"WmmCapable", Set_WmmCapable_Proc},
250 {"IEEE80211H", Set_IEEE80211H_Proc},
251 {"NetworkType", Set_NetworkType_Proc},
252 {"AuthMode", Set_AuthMode_Proc},
253 {"EncrypType", Set_EncrypType_Proc},
254 {"DefaultKeyID", Set_DefaultKeyID_Proc},
255 {"Key1", Set_Key1_Proc},
256 {"Key2", Set_Key2_Proc},
257 {"Key3", Set_Key3_Proc},
258 {"Key4", Set_Key4_Proc},
259 {"WPAPSK", Set_WPAPSK_Proc},
260 {"ResetCounter", Set_ResetStatCounter_Proc},
261 {"PSMode", Set_PSMode_Proc},
263 {"Debug", Set_Debug_Proc},
265 {"WpaSupport", Set_Wpa_Support},
266 {"FixedTxMode", Set_FixedTxMode_Proc},
267 #ifdef DOT11_N_SUPPORT
268 {"TGnWifiTest", Set_TGnWifiTest_Proc},
269 {"ForceGF", Set_ForceGF_Proc},
270 #endif // DOT11_N_SUPPORT //
271 {"LongRetry", Set_LongRetryLimit_Proc},
272 {"ShortRetry", Set_ShortRetryLimit_Proc},
278 IN PRTMP_ADAPTER pAd,
279 IN PNDIS_802_11_KEY pKey)
282 MAC_TABLE_ENTRY *pEntry;
284 DBGPRINT(RT_DEBUG_TRACE, ("RTMPAddKey ------>\n"));
286 if (pAd->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
288 if (pKey->KeyIndex & 0x80000000)
290 if (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPANone)
292 NdisZeroMemory(pAd->StaCfg.PMK, 32);
293 NdisMoveMemory(pAd->StaCfg.PMK, pKey->KeyMaterial, pKey->KeyLength);
297 NdisZeroMemory(&pAd->SharedKey[BSS0][0], sizeof(CIPHER_KEY));
298 pAd->SharedKey[BSS0][0].KeyLen = LEN_TKIP_EK;
299 NdisMoveMemory(pAd->SharedKey[BSS0][0].Key, pKey->KeyMaterial, LEN_TKIP_EK);
301 if (pAd->StaCfg.PairCipher == Ndis802_11Encryption2Enabled)
303 NdisMoveMemory(pAd->SharedKey[BSS0][0].RxMic, pKey->KeyMaterial + LEN_TKIP_EK, LEN_TKIP_TXMICK);
304 NdisMoveMemory(pAd->SharedKey[BSS0][0].TxMic, pKey->KeyMaterial + LEN_TKIP_EK + LEN_TKIP_TXMICK, LEN_TKIP_RXMICK);
308 NdisMoveMemory(pAd->SharedKey[BSS0][0].TxMic, pKey->KeyMaterial + LEN_TKIP_EK, LEN_TKIP_TXMICK);
309 NdisMoveMemory(pAd->SharedKey[BSS0][0].RxMic, pKey->KeyMaterial + LEN_TKIP_EK + LEN_TKIP_TXMICK, LEN_TKIP_RXMICK);
312 // Decide its ChiperAlg
313 if (pAd->StaCfg.PairCipher == Ndis802_11Encryption2Enabled)
314 pAd->SharedKey[BSS0][0].CipherAlg = CIPHER_TKIP;
315 else if (pAd->StaCfg.PairCipher == Ndis802_11Encryption3Enabled)
316 pAd->SharedKey[BSS0][0].CipherAlg = CIPHER_AES;
318 pAd->SharedKey[BSS0][0].CipherAlg = CIPHER_NONE;
320 // Update these related information to MAC_TABLE_ENTRY
321 pEntry = &pAd->MacTab.Content[BSSID_WCID];
322 NdisMoveMemory(pEntry->PairwiseKey.Key, pAd->SharedKey[BSS0][0].Key, LEN_TKIP_EK);
323 NdisMoveMemory(pEntry->PairwiseKey.RxMic, pAd->SharedKey[BSS0][0].RxMic, LEN_TKIP_RXMICK);
324 NdisMoveMemory(pEntry->PairwiseKey.TxMic, pAd->SharedKey[BSS0][0].TxMic, LEN_TKIP_TXMICK);
325 pEntry->PairwiseKey.CipherAlg = pAd->SharedKey[BSS0][0].CipherAlg;
327 // Update pairwise key information to ASIC Shared Key Table
328 AsicAddSharedKeyEntry(pAd,
331 pAd->SharedKey[BSS0][0].CipherAlg,
332 pAd->SharedKey[BSS0][0].Key,
333 pAd->SharedKey[BSS0][0].TxMic,
334 pAd->SharedKey[BSS0][0].RxMic);
336 // Update ASIC WCID attribute table and IVEIV table
337 RTMPAddWcidAttributeEntry(pAd,
340 pAd->SharedKey[BSS0][0].CipherAlg,
343 if (pAd->StaCfg.AuthMode >= Ndis802_11AuthModeWPA2)
345 // set 802.1x port control
346 //pAd->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
347 STA_PORT_SECURED(pAd);
349 // Indicate Connected for GUI
350 pAd->IndicateMediaState = NdisMediaStateConnected;
356 pAd->StaCfg.DefaultKeyId = (pKey->KeyIndex & 0xFF);
357 NdisZeroMemory(&pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId], sizeof(CIPHER_KEY));
358 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].KeyLen = LEN_TKIP_EK;
359 NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].Key, pKey->KeyMaterial, LEN_TKIP_EK);
361 if (pAd->StaCfg.GroupCipher == Ndis802_11Encryption2Enabled)
363 NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].RxMic, pKey->KeyMaterial + LEN_TKIP_EK, LEN_TKIP_TXMICK);
364 NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].TxMic, pKey->KeyMaterial + LEN_TKIP_EK + LEN_TKIP_TXMICK, LEN_TKIP_RXMICK);
368 NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].TxMic, pKey->KeyMaterial + LEN_TKIP_EK, LEN_TKIP_TXMICK);
369 NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].RxMic, pKey->KeyMaterial + LEN_TKIP_EK + LEN_TKIP_TXMICK, LEN_TKIP_RXMICK);
372 // Update Shared Key CipherAlg
373 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg = CIPHER_NONE;
374 if (pAd->StaCfg.GroupCipher == Ndis802_11Encryption2Enabled)
375 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg = CIPHER_TKIP;
376 else if (pAd->StaCfg.GroupCipher == Ndis802_11Encryption3Enabled)
377 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg = CIPHER_AES;
379 // Update group key information to ASIC Shared Key Table
380 AsicAddSharedKeyEntry(pAd,
382 pAd->StaCfg.DefaultKeyId,
383 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg,
384 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].Key,
385 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].TxMic,
386 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].RxMic);
388 // Update ASIC WCID attribute table and IVEIV table
389 RTMPAddWcidAttributeEntry(pAd,
391 pAd->StaCfg.DefaultKeyId,
392 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg,
395 // set 802.1x port control
396 //pAd->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
397 STA_PORT_SECURED(pAd);
399 // Indicate Connected for GUI
400 pAd->IndicateMediaState = NdisMediaStateConnected;
403 else // dynamic WEP from wpa_supplicant
408 if(pKey->KeyLength == 32)
411 KeyIdx = pKey->KeyIndex & 0x0fffffff;
415 // it is a default shared key, for Pairwise key setting
416 if (pKey->KeyIndex & 0x80000000)
418 pEntry = MacTableLookup(pAd, pKey->BSSID);
422 DBGPRINT(RT_DEBUG_TRACE, ("RTMPAddKey: Set Pair-wise Key\n"));
424 // set key material and key length
425 pEntry->PairwiseKey.KeyLen = (UCHAR)pKey->KeyLength;
426 NdisMoveMemory(pEntry->PairwiseKey.Key, &pKey->KeyMaterial, pKey->KeyLength);
429 if (pKey->KeyLength == 5)
430 pEntry->PairwiseKey.CipherAlg = CIPHER_WEP64;
432 pEntry->PairwiseKey.CipherAlg = CIPHER_WEP128;
434 // Add Pair-wise key to Asic
435 AsicAddPairwiseKeyEntry(
439 &pEntry->PairwiseKey);
441 // update WCID attribute table and IVEIV table for this entry
442 RTMPAddWcidAttributeEntry(
445 KeyIdx, // The value may be not zero
446 pEntry->PairwiseKey.CipherAlg,
453 // Default key for tx (shared key)
454 pAd->StaCfg.DefaultKeyId = (UCHAR) KeyIdx;
456 // set key material and key length
457 pAd->SharedKey[BSS0][KeyIdx].KeyLen = (UCHAR) pKey->KeyLength;
458 NdisMoveMemory(pAd->SharedKey[BSS0][KeyIdx].Key, &pKey->KeyMaterial, pKey->KeyLength);
461 if (pKey->KeyLength == 5)
462 pAd->SharedKey[BSS0][KeyIdx].CipherAlg = CIPHER_WEP64;
464 pAd->SharedKey[BSS0][KeyIdx].CipherAlg = CIPHER_WEP128;
466 CipherAlg = pAd->SharedKey[BSS0][KeyIdx].CipherAlg;
467 Key = pAd->SharedKey[BSS0][KeyIdx].Key;
469 // Set Group key material to Asic
470 AsicAddSharedKeyEntry(pAd, BSS0, KeyIdx, CipherAlg, Key, NULL, NULL);
472 // Update WCID attribute table and IVEIV table for this group key table
473 RTMPAddWcidAttributeEntry(pAd, BSS0, KeyIdx, CipherAlg, NULL);
482 char * rtstrchr(const char * s, int c)
484 for(; *s != (char) c; ++s)
491 This is required for LinEX2004/kernel2.6.7 to provide iwlist scanning function
495 rt_ioctl_giwname(struct net_device *dev,
496 struct iw_request_info *info,
497 char *name, char *extra)
499 // PRTMP_ADAPTER pAdapter = dev->ml_priv;
502 strncpy(name, "RT2870 Wireless", IFNAMSIZ);
507 int rt_ioctl_siwfreq(struct net_device *dev,
508 struct iw_request_info *info,
509 struct iw_freq *freq, char *extra)
511 PRTMP_ADAPTER pAdapter = dev->ml_priv;
514 //check if the interface is down
515 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
517 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
525 if((freq->e == 0) && (freq->m <= 1000))
526 chan = freq->m; // Setting by channel number
528 MAP_KHZ_TO_CHANNEL_ID( (freq->m /100) , chan); // Setting by frequency - search the table , like 2.412G, 2.422G,
530 if (ChannelSanity(pAdapter, chan) == TRUE)
532 pAdapter->CommonCfg.Channel = chan;
533 DBGPRINT(RT_DEBUG_ERROR, ("==>rt_ioctl_siwfreq::SIOCSIWFREQ[cmd=0x%x] (Channel=%d)\n", SIOCSIWFREQ, pAdapter->CommonCfg.Channel));
540 int rt_ioctl_giwfreq(struct net_device *dev,
541 struct iw_request_info *info,
542 struct iw_freq *freq, char *extra)
544 VIRTUAL_ADAPTER *pVirtualAd = NULL;
545 PRTMP_ADAPTER pAdapter = NULL;
549 if (dev->priv_flags == INT_MAIN)
551 pAdapter = dev->ml_priv;
555 pVirtualAd = dev->ml_priv;
556 if (pVirtualAd && pVirtualAd->RtmpDev)
557 pAdapter = pVirtualAd->RtmpDev->ml_priv;
560 if (pAdapter == NULL)
562 /* if 1st open fail, pAd will be free;
563 So the net_dev->ml_priv will be NULL in 2rd open */
567 ch = pAdapter->CommonCfg.Channel;
569 DBGPRINT(RT_DEBUG_TRACE,("==>rt_ioctl_giwfreq %d\n", ch));
571 MAP_CHANNEL_ID_TO_KHZ(ch, m);
577 int rt_ioctl_siwmode(struct net_device *dev,
578 struct iw_request_info *info,
579 __u32 *mode, char *extra)
581 PRTMP_ADAPTER pAdapter = dev->ml_priv;
583 //check if the interface is down
584 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
586 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
593 Set_NetworkType_Proc(pAdapter, "Adhoc");
596 Set_NetworkType_Proc(pAdapter, "Infra");
598 case IW_MODE_MONITOR:
599 Set_NetworkType_Proc(pAdapter, "Monitor");
602 DBGPRINT(RT_DEBUG_TRACE, ("===>rt_ioctl_siwmode::SIOCSIWMODE (unknown %d)\n", *mode));
606 // Reset Ralink supplicant to not use, it will be set to start when UI set PMK key
607 pAdapter->StaCfg.WpaState = SS_NOTUSE;
612 int rt_ioctl_giwmode(struct net_device *dev,
613 struct iw_request_info *info,
614 __u32 *mode, char *extra)
616 PRTMP_ADAPTER pAdapter = NULL;
617 VIRTUAL_ADAPTER *pVirtualAd = NULL;
619 if (dev->priv_flags == INT_MAIN)
621 pAdapter = dev->ml_priv;
625 pVirtualAd = dev->ml_priv;
626 if (pVirtualAd && pVirtualAd->RtmpDev)
627 pAdapter = pVirtualAd->RtmpDev->ml_priv;
630 if (pAdapter == NULL)
632 /* if 1st open fail, pAd will be free;
633 So the net_dev->ml_priv will be NULL in 2rd open */
637 if (ADHOC_ON(pAdapter))
638 *mode = IW_MODE_ADHOC;
639 else if (INFRA_ON(pAdapter))
640 *mode = IW_MODE_INFRA;
641 else if (MONITOR_ON(pAdapter))
643 *mode = IW_MODE_MONITOR;
646 *mode = IW_MODE_AUTO;
648 DBGPRINT(RT_DEBUG_TRACE, ("==>rt_ioctl_giwmode(mode=%d)\n", *mode));
652 int rt_ioctl_siwsens(struct net_device *dev,
653 struct iw_request_info *info,
654 char *name, char *extra)
656 PRTMP_ADAPTER pAdapter = dev->ml_priv;
658 //check if the interface is down
659 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
661 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
668 int rt_ioctl_giwsens(struct net_device *dev,
669 struct iw_request_info *info,
670 char *name, char *extra)
675 int rt_ioctl_giwrange(struct net_device *dev,
676 struct iw_request_info *info,
677 struct iw_point *data, char *extra)
679 PRTMP_ADAPTER pAdapter = NULL;
680 VIRTUAL_ADAPTER *pVirtualAd = NULL;
681 struct iw_range *range = (struct iw_range *) extra;
685 if (dev->priv_flags == INT_MAIN)
687 pAdapter = dev->ml_priv;
691 pVirtualAd = dev->ml_priv;
692 if (pVirtualAd && pVirtualAd->RtmpDev)
693 pAdapter = pVirtualAd->RtmpDev->ml_priv;
696 if (pAdapter == NULL)
698 /* if 1st open fail, pAd will be free;
699 So the net_dev->ml_priv will be NULL in 2rd open */
703 DBGPRINT(RT_DEBUG_TRACE ,("===>rt_ioctl_giwrange\n"));
704 data->length = sizeof(struct iw_range);
705 memset(range, 0, sizeof(struct iw_range));
707 range->txpower_capa = IW_TXPOW_DBM;
709 if (INFRA_ON(pAdapter)||ADHOC_ON(pAdapter))
711 range->min_pmp = 1 * 1024;
712 range->max_pmp = 65535 * 1024;
713 range->min_pmt = 1 * 1024;
714 range->max_pmt = 1000 * 1024;
715 range->pmp_flags = IW_POWER_PERIOD;
716 range->pmt_flags = IW_POWER_TIMEOUT;
717 range->pm_capa = IW_POWER_PERIOD | IW_POWER_TIMEOUT |
718 IW_POWER_UNICAST_R | IW_POWER_ALL_R;
721 range->we_version_compiled = WIRELESS_EXT;
722 range->we_version_source = 14;
724 range->retry_capa = IW_RETRY_LIMIT;
725 range->retry_flags = IW_RETRY_LIMIT;
726 range->min_retry = 0;
727 range->max_retry = 255;
729 range->num_channels = pAdapter->ChannelListNum;
732 for (i = 1; i <= range->num_channels; i++)
735 range->freq[val].i = pAdapter->ChannelList[i-1].Channel;
736 MAP_CHANNEL_ID_TO_KHZ(pAdapter->ChannelList[i-1].Channel, m);
737 range->freq[val].m = m * 100; /* HZ */
739 range->freq[val].e = 1;
741 if (val == IW_MAX_FREQUENCIES)
744 range->num_frequency = val;
746 range->max_qual.qual = 100; /* what is correct max? This was not
747 * documented exactly. At least
748 * 69 has been observed. */
749 range->max_qual.level = 0; /* dB */
750 range->max_qual.noise = 0; /* dB */
752 /* What would be suitable values for "average/typical" qual? */
753 range->avg_qual.qual = 20;
754 range->avg_qual.level = -60;
755 range->avg_qual.noise = -95;
756 range->sensitivity = 3;
758 range->max_encoding_tokens = NR_WEP_KEYS;
759 range->num_encoding_sizes = 2;
760 range->encoding_size[0] = 5;
761 range->encoding_size[1] = 13;
764 range->max_rts = 2347;
765 range->min_frag = 256;
766 range->max_frag = 2346;
768 #if WIRELESS_EXT > 17
769 /* IW_ENC_CAPA_* bit field */
770 range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 |
771 IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP;
777 int rt_ioctl_siwap(struct net_device *dev,
778 struct iw_request_info *info,
779 struct sockaddr *ap_addr, char *extra)
781 PRTMP_ADAPTER pAdapter = dev->ml_priv;
782 NDIS_802_11_MAC_ADDRESS Bssid;
784 //check if the interface is down
785 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
787 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
791 if (pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE)
793 RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
794 DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
797 // tell CNTL state machine to call NdisMSetInformationComplete() after completing
798 // this request, because this request is initiated by NDIS.
799 pAdapter->MlmeAux.CurrReqIsFromNdis = FALSE;
800 // Prevent to connect AP again in STAMlmePeriodicExec
801 pAdapter->MlmeAux.AutoReconnectSsidLen= 32;
803 memset(Bssid, 0, MAC_ADDR_LEN);
804 memcpy(Bssid, ap_addr->sa_data, MAC_ADDR_LEN);
805 MlmeEnqueue(pAdapter,
806 MLME_CNTL_STATE_MACHINE,
808 sizeof(NDIS_802_11_MAC_ADDRESS),
811 DBGPRINT(RT_DEBUG_TRACE, ("IOCTL::SIOCSIWAP %02x:%02x:%02x:%02x:%02x:%02x\n",
812 Bssid[0], Bssid[1], Bssid[2], Bssid[3], Bssid[4], Bssid[5]));
817 int rt_ioctl_giwap(struct net_device *dev,
818 struct iw_request_info *info,
819 struct sockaddr *ap_addr, char *extra)
821 PRTMP_ADAPTER pAdapter = NULL;
822 VIRTUAL_ADAPTER *pVirtualAd = NULL;
824 if (dev->priv_flags == INT_MAIN)
826 pAdapter = dev->ml_priv;
830 pVirtualAd = dev->ml_priv;
831 if (pVirtualAd && pVirtualAd->RtmpDev)
832 pAdapter = pVirtualAd->RtmpDev->ml_priv;
835 if (pAdapter == NULL)
837 /* if 1st open fail, pAd will be free;
838 So the net_dev->ml_priv will be NULL in 2rd open */
842 if (INFRA_ON(pAdapter) || ADHOC_ON(pAdapter))
844 ap_addr->sa_family = ARPHRD_ETHER;
845 memcpy(ap_addr->sa_data, &pAdapter->CommonCfg.Bssid, ETH_ALEN);
848 else if (pAdapter->StaCfg.WpaSupplicantUP != WPA_SUPPLICANT_DISABLE)
850 ap_addr->sa_family = ARPHRD_ETHER;
851 memcpy(ap_addr->sa_data, &pAdapter->MlmeAux.Bssid, ETH_ALEN);
855 DBGPRINT(RT_DEBUG_TRACE, ("IOCTL::SIOCGIWAP(=EMPTY)\n"));
863 * Units are in db above the noise floor. That means the
864 * rssi values reported in the tx/rx descriptors in the
865 * driver are the SNR expressed in db.
867 * If you assume that the noise floor is -95, which is an
868 * excellent assumption 99.5 % of the time, then you can
869 * derive the absolute signal level (i.e. -95 + rssi).
870 * There are some other slight factors to take into account
871 * depending on whether the rssi measurement is from 11b,
872 * 11g, or 11a. These differences are at most 2db and
875 * NB: various calculations are based on the orinoco/wavelan
876 * drivers for compatibility
878 static void set_quality(PRTMP_ADAPTER pAdapter,
879 struct iw_quality *iq,
886 ChannelQuality = 100;
887 else if (rssi >= -80) // between -50 ~ -80dbm
888 ChannelQuality = (__u8)(24 + ((rssi + 80) * 26)/10);
889 else if (rssi >= -90) // between -80 ~ -90dbm
890 ChannelQuality = (__u8)((rssi + 90) * 26)/10;
894 iq->qual = (__u8)ChannelQuality;
896 iq->level = (__u8)(rssi);
897 iq->noise = (pAdapter->BbpWriteLatch[66] > pAdapter->BbpTuning.FalseCcaUpperThreshold) ? ((__u8)pAdapter->BbpTuning.FalseCcaUpperThreshold) : ((__u8) pAdapter->BbpWriteLatch[66]); // noise level (dBm)
898 iq->noise += 256 - 143;
899 iq->updated = pAdapter->iw_stats.qual.updated;
902 int rt_ioctl_iwaplist(struct net_device *dev,
903 struct iw_request_info *info,
904 struct iw_point *data, char *extra)
906 PRTMP_ADAPTER pAdapter = dev->ml_priv;
908 struct sockaddr addr[IW_MAX_AP];
909 struct iw_quality qual[IW_MAX_AP];
912 //check if the interface is down
913 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
915 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
921 for (i = 0; i <IW_MAX_AP ; i++)
923 if (i >= pAdapter->ScanTab.BssNr)
925 addr[i].sa_family = ARPHRD_ETHER;
926 memcpy(addr[i].sa_data, &pAdapter->ScanTab.BssEntry[i].Bssid, MAC_ADDR_LEN);
927 set_quality(pAdapter, &qual[i], pAdapter->ScanTab.BssEntry[i].Rssi);
930 memcpy(extra, &addr, i*sizeof(addr[0]));
931 data->flags = 1; /* signal quality present (sort of) */
932 memcpy(extra + i*sizeof(addr[0]), &qual, i*sizeof(qual[i]));
938 int rt_ioctl_siwscan(struct net_device *dev,
939 struct iw_request_info *info,
940 struct iw_point *data, char *extra)
942 PRTMP_ADAPTER pAdapter = dev->ml_priv;
945 int Status = NDIS_STATUS_SUCCESS;
947 //check if the interface is down
948 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
950 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
954 if (MONITOR_ON(pAdapter))
956 DBGPRINT(RT_DEBUG_TRACE, ("!!! Driver is in Monitor Mode now !!!\n"));
961 if (pAdapter->StaCfg.WpaSupplicantUP == WPA_SUPPLICANT_ENABLE)
963 pAdapter->StaCfg.WpaSupplicantScanCount++;
966 pAdapter->StaCfg.bScanReqIsFromWebUI = TRUE;
967 if (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
972 if ((pAdapter->StaCfg.WpaSupplicantUP == WPA_SUPPLICANT_ENABLE) &&
973 (pAdapter->StaCfg.WpaSupplicantScanCount > 3))
975 DBGPRINT(RT_DEBUG_TRACE, ("!!! WpaSupplicantScanCount > 3\n"));
976 Status = NDIS_STATUS_SUCCESS;
980 if ((OPSTATUS_TEST_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED)) &&
981 ((pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA) ||
982 (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK)) &&
983 (pAdapter->StaCfg.PortSecured == WPA_802_1X_PORT_NOT_SECURED))
985 DBGPRINT(RT_DEBUG_TRACE, ("!!! Link UP, Port Not Secured! ignore this set::OID_802_11_BSSID_LIST_SCAN\n"));
986 Status = NDIS_STATUS_SUCCESS;
990 if (pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE)
992 RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
993 DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
996 // tell CNTL state machine to call NdisMSetInformationComplete() after completing
997 // this request, because this request is initiated by NDIS.
998 pAdapter->MlmeAux.CurrReqIsFromNdis = FALSE;
999 // Reset allowed scan retries
1000 pAdapter->StaCfg.ScanCnt = 0;
1001 pAdapter->StaCfg.LastScanTime = Now;
1003 MlmeEnqueue(pAdapter,
1004 MLME_CNTL_STATE_MACHINE,
1005 OID_802_11_BSSID_LIST_SCAN,
1009 Status = NDIS_STATUS_SUCCESS;
1010 RT28XX_MLME_HANDLER(pAdapter);
1015 int rt_ioctl_giwscan(struct net_device *dev,
1016 struct iw_request_info *info,
1017 struct iw_point *data, char *extra)
1020 PRTMP_ADAPTER pAdapter = dev->ml_priv;
1022 char *current_ev = extra, *previous_ev = extra;
1024 char *current_val, custom[MAX_CUSTOM_LEN] = {0};
1027 #endif // IWEVGENIE //
1028 struct iw_event iwe;
1030 if (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
1033 * Still scanning, indicate the caller should try again.
1038 if (pAdapter->StaCfg.WpaSupplicantUP == WPA_SUPPLICANT_ENABLE)
1040 pAdapter->StaCfg.WpaSupplicantScanCount = 0;
1043 if (pAdapter->ScanTab.BssNr == 0)
1049 #if WIRELESS_EXT >= 17
1050 if (data->length > 0)
1051 end_buf = extra + data->length;
1053 end_buf = extra + IW_SCAN_MAX_DATA;
1055 end_buf = extra + IW_SCAN_MAX_DATA;
1058 for (i = 0; i < pAdapter->ScanTab.BssNr; i++)
1060 if (current_ev >= end_buf)
1062 #if WIRELESS_EXT >= 17
1070 //================================
1071 memset(&iwe, 0, sizeof(iwe));
1072 iwe.cmd = SIOCGIWAP;
1073 iwe.u.ap_addr.sa_family = ARPHRD_ETHER;
1074 memcpy(iwe.u.ap_addr.sa_data, &pAdapter->ScanTab.BssEntry[i].Bssid, ETH_ALEN);
1076 previous_ev = current_ev;
1077 current_ev = iwe_stream_add_event(info, current_ev,end_buf, &iwe, IW_EV_ADDR_LEN);
1078 if (current_ev == previous_ev)
1079 #if WIRELESS_EXT >= 17
1086 //================================
1087 memset(&iwe, 0, sizeof(iwe));
1088 iwe.cmd = SIOCGIWESSID;
1089 iwe.u.data.length = pAdapter->ScanTab.BssEntry[i].SsidLen;
1090 iwe.u.data.flags = 1;
1092 previous_ev = current_ev;
1093 current_ev = iwe_stream_add_point(info, current_ev,end_buf, &iwe, pAdapter->ScanTab.BssEntry[i].Ssid);
1094 if (current_ev == previous_ev)
1095 #if WIRELESS_EXT >= 17
1102 //================================
1103 memset(&iwe, 0, sizeof(iwe));
1104 iwe.cmd = SIOCGIWMODE;
1105 if (pAdapter->ScanTab.BssEntry[i].BssType == Ndis802_11IBSS)
1107 iwe.u.mode = IW_MODE_ADHOC;
1109 else if (pAdapter->ScanTab.BssEntry[i].BssType == Ndis802_11Infrastructure)
1111 iwe.u.mode = IW_MODE_INFRA;
1115 iwe.u.mode = IW_MODE_AUTO;
1117 iwe.len = IW_EV_UINT_LEN;
1119 previous_ev = current_ev;
1120 current_ev = iwe_stream_add_event(info, current_ev, end_buf, &iwe, IW_EV_UINT_LEN);
1121 if (current_ev == previous_ev)
1122 #if WIRELESS_EXT >= 17
1128 //Channel and Frequency
1129 //================================
1130 memset(&iwe, 0, sizeof(iwe));
1131 iwe.cmd = SIOCGIWFREQ;
1132 if (INFRA_ON(pAdapter) || ADHOC_ON(pAdapter))
1133 iwe.u.freq.m = pAdapter->ScanTab.BssEntry[i].Channel;
1135 iwe.u.freq.m = pAdapter->ScanTab.BssEntry[i].Channel;
1139 previous_ev = current_ev;
1140 current_ev = iwe_stream_add_event(info, current_ev, end_buf, &iwe, IW_EV_FREQ_LEN);
1141 if (current_ev == previous_ev)
1142 #if WIRELESS_EXT >= 17
1148 //Add quality statistics
1149 //================================
1150 memset(&iwe, 0, sizeof(iwe));
1152 iwe.u.qual.level = 0;
1153 iwe.u.qual.noise = 0;
1154 set_quality(pAdapter, &iwe.u.qual, pAdapter->ScanTab.BssEntry[i].Rssi);
1155 current_ev = iwe_stream_add_event(info, current_ev, end_buf, &iwe, IW_EV_QUAL_LEN);
1156 if (current_ev == previous_ev)
1157 #if WIRELESS_EXT >= 17
1164 //================================
1165 memset(&iwe, 0, sizeof(iwe));
1166 iwe.cmd = SIOCGIWENCODE;
1167 if (CAP_IS_PRIVACY_ON (pAdapter->ScanTab.BssEntry[i].CapabilityInfo ))
1168 iwe.u.data.flags =IW_ENCODE_ENABLED | IW_ENCODE_NOKEY;
1170 iwe.u.data.flags = IW_ENCODE_DISABLED;
1172 previous_ev = current_ev;
1173 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);
1174 if (current_ev == previous_ev)
1175 #if WIRELESS_EXT >= 17
1182 //================================
1183 if (pAdapter->ScanTab.BssEntry[i].SupRateLen)
1185 UCHAR tmpRate = pAdapter->ScanTab.BssEntry[i].SupRate[pAdapter->ScanTab.BssEntry[i].SupRateLen-1];
1186 memset(&iwe, 0, sizeof(iwe));
1187 iwe.cmd = SIOCGIWRATE;
1188 current_val = current_ev + IW_EV_LCP_LEN;
1189 if (tmpRate == 0x82)
1190 iwe.u.bitrate.value = 1 * 1000000;
1191 else if (tmpRate == 0x84)
1192 iwe.u.bitrate.value = 2 * 1000000;
1193 else if (tmpRate == 0x8B)
1194 iwe.u.bitrate.value = 5.5 * 1000000;
1195 else if (tmpRate == 0x96)
1196 iwe.u.bitrate.value = 11 * 1000000;
1198 iwe.u.bitrate.value = (tmpRate/2) * 1000000;
1200 iwe.u.bitrate.disabled = 0;
1201 current_val = iwe_stream_add_value(info, current_ev,
1202 current_val, end_buf, &iwe,
1205 if((current_val-current_ev)>IW_EV_LCP_LEN)
1206 current_ev = current_val;
1208 #if WIRELESS_EXT >= 17
1217 if (pAdapter->ScanTab.BssEntry[i].WpaIE.IELen > 0)
1219 memset(&iwe, 0, sizeof(iwe));
1220 memset(&custom[0], 0, MAX_CUSTOM_LEN);
1221 memcpy(custom, &(pAdapter->ScanTab.BssEntry[i].WpaIE.IE[0]),
1222 pAdapter->ScanTab.BssEntry[i].WpaIE.IELen);
1223 iwe.cmd = IWEVGENIE;
1224 iwe.u.data.length = pAdapter->ScanTab.BssEntry[i].WpaIE.IELen;
1225 current_ev = iwe_stream_add_point(info, current_ev, end_buf, &iwe, custom);
1226 if (current_ev == previous_ev)
1227 #if WIRELESS_EXT >= 17
1235 if (pAdapter->ScanTab.BssEntry[i].RsnIE.IELen > 0)
1237 memset(&iwe, 0, sizeof(iwe));
1238 memset(&custom[0], 0, MAX_CUSTOM_LEN);
1239 memcpy(custom, &(pAdapter->ScanTab.BssEntry[i].RsnIE.IE[0]),
1240 pAdapter->ScanTab.BssEntry[i].RsnIE.IELen);
1241 iwe.cmd = IWEVGENIE;
1242 iwe.u.data.length = pAdapter->ScanTab.BssEntry[i].RsnIE.IELen;
1243 current_ev = iwe_stream_add_point(info, current_ev, end_buf, &iwe, custom);
1244 if (current_ev == previous_ev)
1245 #if WIRELESS_EXT >= 17
1253 //================================
1254 if (pAdapter->ScanTab.BssEntry[i].WpaIE.IELen > 0)
1256 NdisZeroMemory(&iwe, sizeof(iwe));
1257 memset(&custom[0], 0, MAX_CUSTOM_LEN);
1258 iwe.cmd = IWEVCUSTOM;
1259 iwe.u.data.length = (pAdapter->ScanTab.BssEntry[i].WpaIE.IELen * 2) + 7;
1260 NdisMoveMemory(custom, "wpa_ie=", 7);
1261 for (idx = 0; idx < pAdapter->ScanTab.BssEntry[i].WpaIE.IELen; idx++)
1262 sprintf(custom + strlen(custom), "%02x", pAdapter->ScanTab.BssEntry[i].WpaIE.IE[idx]);
1263 previous_ev = current_ev;
1264 current_ev = iwe_stream_add_point(current_ev, end_buf, &iwe, custom);
1265 if (current_ev == previous_ev)
1266 #if WIRELESS_EXT >= 17
1274 if (pAdapter->ScanTab.BssEntry[i].RsnIE.IELen > 0)
1276 NdisZeroMemory(&iwe, sizeof(iwe));
1277 memset(&custom[0], 0, MAX_CUSTOM_LEN);
1278 iwe.cmd = IWEVCUSTOM;
1279 iwe.u.data.length = (pAdapter->ScanTab.BssEntry[i].RsnIE.IELen * 2) + 7;
1280 NdisMoveMemory(custom, "rsn_ie=", 7);
1281 for (idx = 0; idx < pAdapter->ScanTab.BssEntry[i].RsnIE.IELen; idx++)
1282 sprintf(custom + strlen(custom), "%02x", pAdapter->ScanTab.BssEntry[i].RsnIE.IE[idx]);
1283 previous_ev = current_ev;
1284 current_ev = iwe_stream_add_point(current_ev, end_buf, &iwe, custom);
1285 if (current_ev == previous_ev)
1286 #if WIRELESS_EXT >= 17
1292 #endif // IWEVGENIE //
1295 data->length = current_ev - extra;
1296 pAdapter->StaCfg.bScanReqIsFromWebUI = FALSE;
1297 DBGPRINT(RT_DEBUG_ERROR ,("===>rt_ioctl_giwscan. %d(%d) BSS returned, data->length = %d\n",i , pAdapter->ScanTab.BssNr, data->length));
1302 int rt_ioctl_siwessid(struct net_device *dev,
1303 struct iw_request_info *info,
1304 struct iw_point *data, char *essid)
1306 PRTMP_ADAPTER pAdapter = dev->ml_priv;
1308 //check if the interface is down
1309 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1311 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1317 PCHAR pSsidString = NULL;
1319 // Includes null character.
1320 if (data->length > (IW_ESSID_MAX_SIZE + 1))
1323 pSsidString = (CHAR *) kmalloc(MAX_LEN_OF_SSID+1, MEM_ALLOC_FLAG);
1326 NdisZeroMemory(pSsidString, MAX_LEN_OF_SSID+1);
1327 NdisMoveMemory(pSsidString, essid, data->length);
1328 if (Set_SSID_Proc(pAdapter, pSsidString) == FALSE)
1337 if (Set_SSID_Proc(pAdapter, "") == FALSE)
1343 int rt_ioctl_giwessid(struct net_device *dev,
1344 struct iw_request_info *info,
1345 struct iw_point *data, char *essid)
1347 PRTMP_ADAPTER pAdapter = NULL;
1348 VIRTUAL_ADAPTER *pVirtualAd = NULL;
1350 if (dev->priv_flags == INT_MAIN)
1352 pAdapter = dev->ml_priv;
1356 pVirtualAd = dev->ml_priv;
1357 if (pVirtualAd && pVirtualAd->RtmpDev)
1358 pAdapter = pVirtualAd->RtmpDev->ml_priv;
1361 if (pAdapter == NULL)
1363 /* if 1st open fail, pAd will be free;
1364 So the net_dev->ml_priv will be NULL in 2rd open */
1369 if (MONITOR_ON(pAdapter))
1375 if (OPSTATUS_TEST_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED))
1377 DBGPRINT(RT_DEBUG_TRACE ,("MediaState is connected\n"));
1378 data->length = pAdapter->CommonCfg.SsidLen;
1379 memcpy(essid, pAdapter->CommonCfg.Ssid, pAdapter->CommonCfg.SsidLen);
1383 else if (pAdapter->StaCfg.WpaSupplicantUP != WPA_SUPPLICANT_DISABLE)
1385 data->length = pAdapter->CommonCfg.SsidLen;
1386 memcpy(essid, pAdapter->CommonCfg.Ssid, pAdapter->CommonCfg.SsidLen);
1390 {//the ANY ssid was specified
1392 DBGPRINT(RT_DEBUG_TRACE ,("MediaState is not connected, ess\n"));
1399 int rt_ioctl_siwnickn(struct net_device *dev,
1400 struct iw_request_info *info,
1401 struct iw_point *data, char *nickname)
1403 PRTMP_ADAPTER pAdapter = dev->ml_priv;
1405 //check if the interface is down
1406 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1408 DBGPRINT(RT_DEBUG_TRACE ,("INFO::Network is down!\n"));
1412 if (data->length > IW_ESSID_MAX_SIZE)
1415 memset(pAdapter->nickname, 0, IW_ESSID_MAX_SIZE + 1);
1416 memcpy(pAdapter->nickname, nickname, data->length);
1422 int rt_ioctl_giwnickn(struct net_device *dev,
1423 struct iw_request_info *info,
1424 struct iw_point *data, char *nickname)
1426 PRTMP_ADAPTER pAdapter = NULL;
1427 VIRTUAL_ADAPTER *pVirtualAd = NULL;
1429 if (dev->priv_flags == INT_MAIN)
1431 pAdapter = dev->ml_priv;
1435 pVirtualAd = dev->ml_priv;
1436 if (pVirtualAd && pVirtualAd->RtmpDev)
1437 pAdapter = pVirtualAd->RtmpDev->ml_priv;
1440 if (pAdapter == NULL)
1442 /* if 1st open fail, pAd will be free;
1443 So the net_dev->ml_priv will be NULL in 2rd open */
1447 if (data->length > strlen(pAdapter->nickname) + 1)
1448 data->length = strlen(pAdapter->nickname) + 1;
1449 if (data->length > 0) {
1450 memcpy(nickname, pAdapter->nickname, data->length-1);
1451 nickname[data->length-1] = '\0';
1456 int rt_ioctl_siwrts(struct net_device *dev,
1457 struct iw_request_info *info,
1458 struct iw_param *rts, char *extra)
1460 PRTMP_ADAPTER pAdapter = dev->ml_priv;
1463 //check if the interface is down
1464 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1466 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1471 val = MAX_RTS_THRESHOLD;
1472 else if (rts->value < 0 || rts->value > MAX_RTS_THRESHOLD)
1474 else if (rts->value == 0)
1475 val = MAX_RTS_THRESHOLD;
1479 if (val != pAdapter->CommonCfg.RtsThreshold)
1480 pAdapter->CommonCfg.RtsThreshold = val;
1485 int rt_ioctl_giwrts(struct net_device *dev,
1486 struct iw_request_info *info,
1487 struct iw_param *rts, char *extra)
1489 PRTMP_ADAPTER pAdapter = NULL;
1490 VIRTUAL_ADAPTER *pVirtualAd = NULL;
1492 if (dev->priv_flags == INT_MAIN)
1494 pAdapter = dev->ml_priv;
1498 pVirtualAd = dev->ml_priv;
1499 if (pVirtualAd && pVirtualAd->RtmpDev)
1500 pAdapter = pVirtualAd->RtmpDev->ml_priv;
1503 if (pAdapter == NULL)
1505 /* if 1st open fail, pAd will be free;
1506 So the net_dev->ml_priv will be NULL in 2rd open */
1510 //check if the interface is down
1511 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1513 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1517 rts->value = pAdapter->CommonCfg.RtsThreshold;
1518 rts->disabled = (rts->value == MAX_RTS_THRESHOLD);
1524 int rt_ioctl_siwfrag(struct net_device *dev,
1525 struct iw_request_info *info,
1526 struct iw_param *frag, char *extra)
1528 PRTMP_ADAPTER pAdapter = dev->ml_priv;
1531 //check if the interface is down
1532 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1534 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1539 val = MAX_FRAG_THRESHOLD;
1540 else if (frag->value >= MIN_FRAG_THRESHOLD || frag->value <= MAX_FRAG_THRESHOLD)
1541 val = __cpu_to_le16(frag->value & ~0x1); /* even numbers only */
1542 else if (frag->value == 0)
1543 val = MAX_FRAG_THRESHOLD;
1547 pAdapter->CommonCfg.FragmentThreshold = val;
1551 int rt_ioctl_giwfrag(struct net_device *dev,
1552 struct iw_request_info *info,
1553 struct iw_param *frag, char *extra)
1555 PRTMP_ADAPTER pAdapter = NULL;
1556 VIRTUAL_ADAPTER *pVirtualAd = NULL;
1558 if (dev->priv_flags == INT_MAIN)
1560 pAdapter = dev->ml_priv;
1564 pVirtualAd = dev->ml_priv;
1565 if (pVirtualAd && pVirtualAd->RtmpDev)
1566 pAdapter = pVirtualAd->RtmpDev->ml_priv;
1569 if (pAdapter == NULL)
1571 /* if 1st open fail, pAd will be free;
1572 So the net_dev->ml_priv will be NULL in 2rd open */
1576 //check if the interface is down
1577 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1579 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1583 frag->value = pAdapter->CommonCfg.FragmentThreshold;
1584 frag->disabled = (frag->value == MAX_FRAG_THRESHOLD);
1590 #define MAX_WEP_KEY_SIZE 13
1591 #define MIN_WEP_KEY_SIZE 5
1592 int rt_ioctl_siwencode(struct net_device *dev,
1593 struct iw_request_info *info,
1594 struct iw_point *erq, char *extra)
1596 PRTMP_ADAPTER pAdapter = dev->ml_priv;
1598 //check if the interface is down
1599 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1601 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1605 if ((erq->length == 0) &&
1606 (erq->flags & IW_ENCODE_DISABLED))
1608 pAdapter->StaCfg.PairCipher = Ndis802_11WEPDisabled;
1609 pAdapter->StaCfg.GroupCipher = Ndis802_11WEPDisabled;
1610 pAdapter->StaCfg.WepStatus = Ndis802_11WEPDisabled;
1611 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
1612 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
1615 else if ((erq->length == 0) &&
1616 (erq->flags & IW_ENCODE_RESTRICTED || erq->flags & IW_ENCODE_OPEN))
1618 //pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
1619 STA_PORT_SECURED(pAdapter);
1620 pAdapter->StaCfg.PairCipher = Ndis802_11WEPEnabled;
1621 pAdapter->StaCfg.GroupCipher = Ndis802_11WEPEnabled;
1622 pAdapter->StaCfg.WepStatus = Ndis802_11WEPEnabled;
1623 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
1624 if (erq->flags & IW_ENCODE_RESTRICTED)
1625 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeShared;
1627 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
1631 if (erq->length > 0)
1633 int keyIdx = (erq->flags & IW_ENCODE_INDEX) - 1;
1634 /* Check the size of the key */
1635 if (erq->length > MAX_WEP_KEY_SIZE) {
1638 /* Check key index */
1639 if ((keyIdx < 0) || (keyIdx >= NR_WEP_KEYS))
1641 DBGPRINT(RT_DEBUG_TRACE ,("==>rt_ioctl_siwencode::Wrong keyIdx=%d! Using default key instead (%d)\n",
1642 keyIdx, pAdapter->StaCfg.DefaultKeyId));
1645 keyIdx = pAdapter->StaCfg.DefaultKeyId;
1648 NdisZeroMemory(pAdapter->SharedKey[BSS0][keyIdx].Key, 16);
1650 if (erq->length == MAX_WEP_KEY_SIZE)
1652 pAdapter->SharedKey[BSS0][keyIdx].KeyLen = MAX_WEP_KEY_SIZE;
1653 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CIPHER_WEP128;
1655 else if (erq->length == MIN_WEP_KEY_SIZE)
1657 pAdapter->SharedKey[BSS0][keyIdx].KeyLen = MIN_WEP_KEY_SIZE;
1658 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CIPHER_WEP64;
1661 /* Disable the key */
1662 pAdapter->SharedKey[BSS0][keyIdx].KeyLen = 0;
1664 /* Check if the key is not marked as invalid */
1665 if(!(erq->flags & IW_ENCODE_NOKEY)) {
1666 /* Copy the key in the driver */
1667 NdisMoveMemory(pAdapter->SharedKey[BSS0][keyIdx].Key, extra, erq->length);
1672 /* Do we want to just set the transmit key index ? */
1673 int index = (erq->flags & IW_ENCODE_INDEX) - 1;
1674 if ((index >= 0) && (index < 4))
1676 pAdapter->StaCfg.DefaultKeyId = index;
1679 /* Don't complain if only change the mode */
1680 if (!(erq->flags & IW_ENCODE_MODE)) {
1686 DBGPRINT(RT_DEBUG_TRACE ,("==>rt_ioctl_siwencode::erq->flags=%x\n",erq->flags));
1687 DBGPRINT(RT_DEBUG_TRACE ,("==>rt_ioctl_siwencode::AuthMode=%x\n",pAdapter->StaCfg.AuthMode));
1688 DBGPRINT(RT_DEBUG_TRACE ,("==>rt_ioctl_siwencode::DefaultKeyId=%x, KeyLen = %d\n",pAdapter->StaCfg.DefaultKeyId , pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].KeyLen));
1689 DBGPRINT(RT_DEBUG_TRACE ,("==>rt_ioctl_siwencode::WepStatus=%x\n",pAdapter->StaCfg.WepStatus));
1694 rt_ioctl_giwencode(struct net_device *dev,
1695 struct iw_request_info *info,
1696 struct iw_point *erq, char *key)
1699 PRTMP_ADAPTER pAdapter = NULL;
1700 VIRTUAL_ADAPTER *pVirtualAd = NULL;
1702 if (dev->priv_flags == INT_MAIN)
1704 pAdapter = dev->ml_priv;
1708 pVirtualAd = dev->ml_priv;
1709 if (pVirtualAd && pVirtualAd->RtmpDev)
1710 pAdapter = pVirtualAd->RtmpDev->ml_priv;
1713 if (pAdapter == NULL)
1715 /* if 1st open fail, pAd will be free;
1716 So the net_dev->ml_priv will be NULL in 2rd open */
1720 //check if the interface is down
1721 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1723 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1727 kid = erq->flags & IW_ENCODE_INDEX;
1728 DBGPRINT(RT_DEBUG_TRACE, ("===>rt_ioctl_giwencode %d\n", erq->flags & IW_ENCODE_INDEX));
1730 if (pAdapter->StaCfg.WepStatus == Ndis802_11WEPDisabled)
1733 erq->flags = IW_ENCODE_DISABLED;
1735 else if ((kid > 0) && (kid <=4))
1738 erq->flags = kid ; /* NB: base 1 */
1739 if (erq->length > pAdapter->SharedKey[BSS0][kid-1].KeyLen)
1740 erq->length = pAdapter->SharedKey[BSS0][kid-1].KeyLen;
1741 memcpy(key, pAdapter->SharedKey[BSS0][kid-1].Key, erq->length);
1742 //if ((kid == pAdapter->PortCfg.DefaultKeyId))
1743 //erq->flags |= IW_ENCODE_ENABLED; /* XXX */
1744 if (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeShared)
1745 erq->flags |= IW_ENCODE_RESTRICTED; /* XXX */
1747 erq->flags |= IW_ENCODE_OPEN; /* XXX */
1752 if (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeShared)
1753 erq->flags |= IW_ENCODE_RESTRICTED; /* XXX */
1755 erq->flags |= IW_ENCODE_OPEN; /* XXX */
1756 erq->length = pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].KeyLen;
1757 memcpy(key, pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].Key, erq->length);
1758 // copy default key ID
1759 if (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeShared)
1760 erq->flags |= IW_ENCODE_RESTRICTED; /* XXX */
1762 erq->flags |= IW_ENCODE_OPEN; /* XXX */
1763 erq->flags = pAdapter->StaCfg.DefaultKeyId + 1; /* NB: base 1 */
1764 erq->flags |= IW_ENCODE_ENABLED; /* XXX */
1772 rt_ioctl_setparam(struct net_device *dev, struct iw_request_info *info,
1773 void *w, char *extra)
1775 VIRTUAL_ADAPTER *pVirtualAd = NULL;
1776 PRTMP_ADAPTER pAdapter;
1778 char *this_char = extra;
1782 if (dev->priv_flags == INT_MAIN)
1784 pAdapter = dev->ml_priv;
1788 pVirtualAd = dev->ml_priv;
1789 pAdapter = pVirtualAd->RtmpDev->ml_priv;
1791 pObj = (POS_COOKIE) pAdapter->OS_Cookie;
1793 if (pAdapter == NULL)
1795 /* if 1st open fail, pAd will be free;
1796 So the net_dev->ml_priv will be NULL in 2rd open */
1801 pObj->ioctl_if_type = INT_MAIN;
1802 pObj->ioctl_if = MAIN_MBSSID;
1805 //check if the interface is down
1806 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1808 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1815 if ((value = rtstrchr(this_char, '=')) != NULL)
1821 // reject setting nothing besides ANY ssid(ssidLen=0)
1822 if (!*value && (strcmp(this_char, "SSID") != 0))
1825 for (PRTMP_PRIVATE_SET_PROC = RTMP_PRIVATE_SUPPORT_PROC; PRTMP_PRIVATE_SET_PROC->name; PRTMP_PRIVATE_SET_PROC++)
1827 if (strcmp(this_char, PRTMP_PRIVATE_SET_PROC->name) == 0)
1829 if(!PRTMP_PRIVATE_SET_PROC->set_proc(pAdapter, value))
1830 { //FALSE:Set private failed then return Invalid argument
1833 break; //Exit for loop.
1837 if(PRTMP_PRIVATE_SET_PROC->name == NULL)
1838 { //Not found argument
1840 DBGPRINT(RT_DEBUG_TRACE, ("===>rt_ioctl_setparam:: (iwpriv) Not Support Set Command [%s=%s]\n", this_char, value));
1848 rt_private_get_statistics(struct net_device *dev, struct iw_request_info *info,
1849 struct iw_point *wrq, char *extra)
1852 PRTMP_ADAPTER pAd = dev->ml_priv;
1860 memset(extra, 0x00, IW_PRIV_SIZE_MASK);
1861 sprintf(extra, "\n\n");
1864 sprintf(extra+strlen(extra), "Tx success = %ld\n", (ULONG)pAd->WlanCounters.TransmittedFragmentCount.QuadPart);
1865 sprintf(extra+strlen(extra), "Tx success without retry = %ld\n", (ULONG)pAd->WlanCounters.TransmittedFragmentCount.QuadPart - (ULONG)pAd->WlanCounters.RetryCount.QuadPart);
1867 sprintf(extra+strlen(extra), "Tx success after retry = %ld\n", (ULONG)pAd->WlanCounters.RetryCount.QuadPart);
1868 sprintf(extra+strlen(extra), "Tx fail to Rcv ACK after retry = %ld\n", (ULONG)pAd->WlanCounters.FailedCount.QuadPart);
1869 sprintf(extra+strlen(extra), "RTS Success Rcv CTS = %ld\n", (ULONG)pAd->WlanCounters.RTSSuccessCount.QuadPart);
1870 sprintf(extra+strlen(extra), "RTS Fail Rcv CTS = %ld\n", (ULONG)pAd->WlanCounters.RTSFailureCount.QuadPart);
1872 sprintf(extra+strlen(extra), "Rx success = %ld\n", (ULONG)pAd->WlanCounters.ReceivedFragmentCount.QuadPart);
1873 sprintf(extra+strlen(extra), "Rx with CRC = %ld\n", (ULONG)pAd->WlanCounters.FCSErrorCount.QuadPart);
1874 sprintf(extra+strlen(extra), "Rx drop due to out of resource = %ld\n", (ULONG)pAd->Counters8023.RxNoBuffer);
1875 sprintf(extra+strlen(extra), "Rx duplicate frame = %ld\n", (ULONG)pAd->WlanCounters.FrameDuplicateCount.QuadPart);
1877 sprintf(extra+strlen(extra), "False CCA (one second) = %ld\n", (ULONG)pAd->RalinkCounters.OneSecFalseCCACnt);
1879 sprintf(extra+strlen(extra), "RSSI-A = %ld\n", (LONG)(pAd->StaCfg.RssiSample.LastRssi0 - pAd->BbpRssiToDbmDelta));
1880 sprintf(extra+strlen(extra), "RSSI-B (if available) = %ld\n", (LONG)(pAd->StaCfg.RssiSample.LastRssi1 - pAd->BbpRssiToDbmDelta));
1881 sprintf(extra+strlen(extra), "RSSI-C (if available) = %ld\n\n", (LONG)(pAd->StaCfg.RssiSample.LastRssi2 - pAd->BbpRssiToDbmDelta));
1883 sprintf(extra+strlen(extra), "WpaSupplicantUP = %d\n\n", pAd->StaCfg.WpaSupplicantUP);
1885 wrq->length = strlen(extra) + 1; // 1: size of '\0'
1886 DBGPRINT(RT_DEBUG_TRACE, ("<== rt_private_get_statistics, wrq->length = %d\n", wrq->length));
1891 #ifdef DOT11_N_SUPPORT
1893 IN PRTMP_ADAPTER pAd,
1897 BA_ORI_ENTRY *pOriBAEntry;
1898 BA_REC_ENTRY *pRecBAEntry;
1900 for (i=0; i<MAX_LEN_OF_MAC_TABLE; i++)
1902 PMAC_TABLE_ENTRY pEntry = &pAd->MacTab.Content[i];
1903 if (((pEntry->ValidAsCLI || pEntry->ValidAsApCli) && (pEntry->Sst == SST_ASSOC))
1904 || (pEntry->ValidAsWDS) || (pEntry->ValidAsMesh))
1906 sprintf(pOutBuf + strlen(pOutBuf), "\n%02X:%02X:%02X:%02X:%02X:%02X (Aid = %d) (AP) -\n",
1907 pEntry->Addr[0], pEntry->Addr[1], pEntry->Addr[2],
1908 pEntry->Addr[3], pEntry->Addr[4], pEntry->Addr[5], pEntry->Aid);
1910 sprintf(pOutBuf, "%s[Recipient]\n", pOutBuf);
1911 for (j=0; j < NUM_OF_TID; j++)
1913 if (pEntry->BARecWcidArray[j] != 0)
1915 pRecBAEntry =&pAd->BATable.BARecEntry[pEntry->BARecWcidArray[j]];
1916 sprintf(pOutBuf + strlen(pOutBuf), "TID=%d, BAWinSize=%d, LastIndSeq=%d, ReorderingPkts=%d\n", j, pRecBAEntry->BAWinSize, pRecBAEntry->LastIndSeq, pRecBAEntry->list.qlen);
1919 sprintf(pOutBuf, "%s\n", pOutBuf);
1921 sprintf(pOutBuf, "%s[Originator]\n", pOutBuf);
1922 for (j=0; j < NUM_OF_TID; j++)
1924 if (pEntry->BAOriWcidArray[j] != 0)
1926 pOriBAEntry =&pAd->BATable.BAOriEntry[pEntry->BAOriWcidArray[j]];
1927 sprintf(pOutBuf + strlen(pOutBuf), "TID=%d, BAWinSize=%d, StartSeq=%d, CurTxSeq=%d\n", j, pOriBAEntry->BAWinSize, pOriBAEntry->Sequence, pEntry->TxSeq[j]);
1930 sprintf(pOutBuf, "%s\n\n", pOutBuf);
1932 if (strlen(pOutBuf) > (IW_PRIV_SIZE_MASK - 30))
1938 #endif // DOT11_N_SUPPORT //
1941 rt_private_show(struct net_device *dev, struct iw_request_info *info,
1942 struct iw_point *wrq, char *extra)
1945 VIRTUAL_ADAPTER *pVirtualAd = NULL;
1948 u32 subcmd = wrq->flags;
1950 if (dev->priv_flags == INT_MAIN)
1954 pVirtualAd = dev->ml_priv;
1955 pAd = pVirtualAd->RtmpDev->ml_priv;
1957 pObj = (POS_COOKIE) pAd->OS_Cookie;
1961 /* if 1st open fail, pAd will be free;
1962 So the net_dev->ml_priv will be NULL in 2rd open */
1971 memset(extra, 0x00, IW_PRIV_SIZE_MASK);
1974 pObj->ioctl_if_type = INT_MAIN;
1975 pObj->ioctl_if = MAIN_MBSSID;
1981 case SHOW_CONN_STATUS:
1982 if (MONITOR_ON(pAd))
1984 #ifdef DOT11_N_SUPPORT
1985 if (pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED &&
1986 pAd->CommonCfg.RegTransmitSetting.field.BW)
1987 sprintf(extra, "Monitor Mode(CentralChannel %d)\n", pAd->CommonCfg.CentralChannel);
1989 #endif // DOT11_N_SUPPORT //
1990 sprintf(extra, "Monitor Mode(Channel %d)\n", pAd->CommonCfg.Channel);
1994 if (pAd->IndicateMediaState == NdisMediaStateConnected)
1998 sprintf(extra, "Connected(AP: %s[%02X:%02X:%02X:%02X:%02X:%02X])\n",
1999 pAd->CommonCfg.Ssid,
2000 pAd->CommonCfg.Bssid[0],
2001 pAd->CommonCfg.Bssid[1],
2002 pAd->CommonCfg.Bssid[2],
2003 pAd->CommonCfg.Bssid[3],
2004 pAd->CommonCfg.Bssid[4],
2005 pAd->CommonCfg.Bssid[5]);
2006 DBGPRINT(RT_DEBUG_TRACE ,("Ssid=%s ,Ssidlen = %d\n",pAd->CommonCfg.Ssid, pAd->CommonCfg.SsidLen));
2008 else if (ADHOC_ON(pAd))
2009 sprintf(extra, "Connected\n");
2013 sprintf(extra, "Disconnected\n");
2014 DBGPRINT(RT_DEBUG_TRACE ,("ConnStatus is not connected\n"));
2017 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2019 case SHOW_DRVIER_VERION:
2020 sprintf(extra, "Driver version-%s, %s %s\n", STA_DRIVER_VERSION, __DATE__, __TIME__ );
2021 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2023 #ifdef DOT11_N_SUPPORT
2025 getBaInfo(pAd, extra);
2026 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2028 #endif // DOT11_N_SUPPORT //
2029 case SHOW_DESC_INFO:
2031 Show_DescInfo_Proc(pAd, NULL);
2032 wrq->length = 0; // 1: size of '\0'
2036 if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
2038 sprintf(extra, "Scanning\n");
2039 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2042 pAd->StaCfg.bSwRadio = FALSE;
2043 if (pAd->StaCfg.bRadio != (pAd->StaCfg.bHwRadio && pAd->StaCfg.bSwRadio))
2045 pAd->StaCfg.bRadio = (pAd->StaCfg.bHwRadio && pAd->StaCfg.bSwRadio);
2046 if (pAd->StaCfg.bRadio == FALSE)
2049 // Update extra information
2050 pAd->ExtraInfo = SW_RADIO_OFF;
2053 sprintf(extra, "Radio Off\n");
2054 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2057 if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
2059 sprintf(extra, "Scanning\n");
2060 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2063 pAd->StaCfg.bSwRadio = TRUE;
2064 //if (pAd->StaCfg.bRadio != (pAd->StaCfg.bHwRadio && pAd->StaCfg.bSwRadio))
2066 pAd->StaCfg.bRadio = (pAd->StaCfg.bHwRadio && pAd->StaCfg.bSwRadio);
2067 if (pAd->StaCfg.bRadio == TRUE)
2070 // Update extra information
2071 pAd->ExtraInfo = EXTRA_INFO_CLEAR;
2074 sprintf(extra, "Radio On\n");
2075 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2078 case SHOW_CFG_VALUE:
2080 Status = RTMPShowCfgValue(pAd, wrq->pointer, extra);
2082 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2085 case SHOW_ADHOC_ENTRY_INFO:
2086 Show_Adhoc_MacTable_Proc(pAd, extra);
2087 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2090 DBGPRINT(RT_DEBUG_TRACE, ("%s - unknow subcmd = %d\n", __func__, subcmd));
2098 int rt_ioctl_siwmlme(struct net_device *dev,
2099 struct iw_request_info *info,
2100 union iwreq_data *wrqu,
2103 PRTMP_ADAPTER pAd = dev->ml_priv;
2104 struct iw_mlme *pMlme = (struct iw_mlme *)wrqu->data.pointer;
2105 MLME_QUEUE_ELEM MsgElem;
2106 MLME_DISASSOC_REQ_STRUCT DisAssocReq;
2107 MLME_DEAUTH_REQ_STRUCT DeAuthReq;
2109 DBGPRINT(RT_DEBUG_TRACE, ("====> %s\n", __func__));
2116 #ifdef IW_MLME_DEAUTH
2117 case IW_MLME_DEAUTH:
2118 DBGPRINT(RT_DEBUG_TRACE, ("====> %s - IW_MLME_DEAUTH\n", __func__));
2119 COPY_MAC_ADDR(DeAuthReq.Addr, pAd->CommonCfg.Bssid);
2120 DeAuthReq.Reason = pMlme->reason_code;
2121 MsgElem.MsgLen = sizeof(MLME_DEAUTH_REQ_STRUCT);
2122 NdisMoveMemory(MsgElem.Msg, &DeAuthReq, sizeof(MLME_DEAUTH_REQ_STRUCT));
2123 MlmeDeauthReqAction(pAd, &MsgElem);
2126 LinkDown(pAd, FALSE);
2127 pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
2130 #endif // IW_MLME_DEAUTH //
2131 #ifdef IW_MLME_DISASSOC
2132 case IW_MLME_DISASSOC:
2133 DBGPRINT(RT_DEBUG_TRACE, ("====> %s - IW_MLME_DISASSOC\n", __func__));
2134 COPY_MAC_ADDR(DisAssocReq.Addr, pAd->CommonCfg.Bssid);
2135 DisAssocReq.Reason = pMlme->reason_code;
2137 MsgElem.Machine = ASSOC_STATE_MACHINE;
2138 MsgElem.MsgType = MT2_MLME_DISASSOC_REQ;
2139 MsgElem.MsgLen = sizeof(MLME_DISASSOC_REQ_STRUCT);
2140 NdisMoveMemory(MsgElem.Msg, &DisAssocReq, sizeof(MLME_DISASSOC_REQ_STRUCT));
2142 pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_OID_DISASSOC;
2143 MlmeDisassocReqAction(pAd, &MsgElem);
2145 #endif // IW_MLME_DISASSOC //
2147 DBGPRINT(RT_DEBUG_TRACE, ("====> %s - Unknow Command\n", __func__));
2153 #endif // SIOCSIWMLME //
2155 #if WIRELESS_EXT > 17
2156 int rt_ioctl_siwauth(struct net_device *dev,
2157 struct iw_request_info *info,
2158 union iwreq_data *wrqu, char *extra)
2160 PRTMP_ADAPTER pAdapter = dev->ml_priv;
2161 struct iw_param *param = &wrqu->param;
2163 //check if the interface is down
2164 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
2166 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
2169 switch (param->flags & IW_AUTH_INDEX) {
2170 case IW_AUTH_WPA_VERSION:
2171 if (param->value == IW_AUTH_WPA_VERSION_WPA)
2173 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPAPSK;
2174 if (pAdapter->StaCfg.BssType == BSS_ADHOC)
2175 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPANone;
2177 else if (param->value == IW_AUTH_WPA_VERSION_WPA2)
2178 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA2PSK;
2180 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_WPA_VERSION - param->value = %d!\n", __func__, param->value));
2182 case IW_AUTH_CIPHER_PAIRWISE:
2183 if (param->value == IW_AUTH_CIPHER_NONE)
2185 pAdapter->StaCfg.WepStatus = Ndis802_11WEPDisabled;
2186 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
2187 pAdapter->StaCfg.PairCipher = Ndis802_11WEPDisabled;
2189 else if (param->value == IW_AUTH_CIPHER_WEP40 ||
2190 param->value == IW_AUTH_CIPHER_WEP104)
2192 pAdapter->StaCfg.WepStatus = Ndis802_11WEPEnabled;
2193 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
2194 pAdapter->StaCfg.PairCipher = Ndis802_11WEPEnabled;
2195 pAdapter->StaCfg.IEEE8021X = FALSE;
2197 else if (param->value == IW_AUTH_CIPHER_TKIP)
2199 pAdapter->StaCfg.WepStatus = Ndis802_11Encryption2Enabled;
2200 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
2201 pAdapter->StaCfg.PairCipher = Ndis802_11Encryption2Enabled;
2203 else if (param->value == IW_AUTH_CIPHER_CCMP)
2205 pAdapter->StaCfg.WepStatus = Ndis802_11Encryption3Enabled;
2206 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
2207 pAdapter->StaCfg.PairCipher = Ndis802_11Encryption3Enabled;
2209 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_CIPHER_PAIRWISE - param->value = %d!\n", __func__, param->value));
2211 case IW_AUTH_CIPHER_GROUP:
2212 if (param->value == IW_AUTH_CIPHER_NONE)
2214 pAdapter->StaCfg.GroupCipher = Ndis802_11WEPDisabled;
2216 else if (param->value == IW_AUTH_CIPHER_WEP40 ||
2217 param->value == IW_AUTH_CIPHER_WEP104)
2219 pAdapter->StaCfg.GroupCipher = Ndis802_11WEPEnabled;
2221 else if (param->value == IW_AUTH_CIPHER_TKIP)
2223 pAdapter->StaCfg.GroupCipher = Ndis802_11Encryption2Enabled;
2225 else if (param->value == IW_AUTH_CIPHER_CCMP)
2227 pAdapter->StaCfg.GroupCipher = Ndis802_11Encryption3Enabled;
2229 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_CIPHER_GROUP - param->value = %d!\n", __func__, param->value));
2231 case IW_AUTH_KEY_MGMT:
2232 if (param->value == IW_AUTH_KEY_MGMT_802_1X)
2234 if (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK)
2236 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA;
2237 pAdapter->StaCfg.IEEE8021X = FALSE;
2239 else if (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK)
2241 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA2;
2242 pAdapter->StaCfg.IEEE8021X = FALSE;
2246 pAdapter->StaCfg.IEEE8021X = TRUE;
2248 else if (param->value == 0)
2250 //pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
2251 STA_PORT_SECURED(pAdapter);
2253 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_KEY_MGMT - param->value = %d!\n", __func__, param->value));
2255 case IW_AUTH_RX_UNENCRYPTED_EAPOL:
2257 case IW_AUTH_PRIVACY_INVOKED:
2258 /*if (param->value == 0)
2260 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
2261 pAdapter->StaCfg.WepStatus = Ndis802_11WEPDisabled;
2262 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
2263 pAdapter->StaCfg.PairCipher = Ndis802_11WEPDisabled;
2264 pAdapter->StaCfg.GroupCipher = Ndis802_11WEPDisabled;
2266 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_PRIVACY_INVOKED - param->value = %d!\n", __func__, param->value));
2268 case IW_AUTH_DROP_UNENCRYPTED:
2269 if (param->value != 0)
2270 pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED;
2273 //pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
2274 STA_PORT_SECURED(pAdapter);
2276 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_WPA_VERSION - param->value = %d!\n", __func__, param->value));
2278 case IW_AUTH_80211_AUTH_ALG:
2279 if (param->value & IW_AUTH_ALG_SHARED_KEY)
2281 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeShared;
2283 else if (param->value & IW_AUTH_ALG_OPEN_SYSTEM)
2285 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
2289 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_80211_AUTH_ALG - param->value = %d!\n", __func__, param->value));
2291 case IW_AUTH_WPA_ENABLED:
2292 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_WPA_ENABLED - Driver supports WPA!(param->value = %d)\n", __func__, param->value));
2301 int rt_ioctl_giwauth(struct net_device *dev,
2302 struct iw_request_info *info,
2303 union iwreq_data *wrqu, char *extra)
2305 PRTMP_ADAPTER pAdapter = dev->ml_priv;
2306 struct iw_param *param = &wrqu->param;
2308 //check if the interface is down
2309 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
2311 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
2315 switch (param->flags & IW_AUTH_INDEX) {
2316 case IW_AUTH_DROP_UNENCRYPTED:
2317 param->value = (pAdapter->StaCfg.WepStatus == Ndis802_11WEPDisabled) ? 0 : 1;
2320 case IW_AUTH_80211_AUTH_ALG:
2321 param->value = (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeShared) ? IW_AUTH_ALG_SHARED_KEY : IW_AUTH_ALG_OPEN_SYSTEM;
2324 case IW_AUTH_WPA_ENABLED:
2325 param->value = (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA) ? 1 : 0;
2331 DBGPRINT(RT_DEBUG_TRACE, ("rt_ioctl_giwauth::param->value = %d!\n", param->value));
2335 void fnSetCipherKey(
2336 IN PRTMP_ADAPTER pAdapter,
2340 IN struct iw_encode_ext *ext)
2342 NdisZeroMemory(&pAdapter->SharedKey[BSS0][keyIdx], sizeof(CIPHER_KEY));
2343 pAdapter->SharedKey[BSS0][keyIdx].KeyLen = LEN_TKIP_EK;
2344 NdisMoveMemory(pAdapter->SharedKey[BSS0][keyIdx].Key, ext->key, LEN_TKIP_EK);
2345 NdisMoveMemory(pAdapter->SharedKey[BSS0][keyIdx].TxMic, ext->key + LEN_TKIP_EK, LEN_TKIP_TXMICK);
2346 NdisMoveMemory(pAdapter->SharedKey[BSS0][keyIdx].RxMic, ext->key + LEN_TKIP_EK + LEN_TKIP_TXMICK, LEN_TKIP_RXMICK);
2347 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CipherAlg;
2349 // Update group key information to ASIC Shared Key Table
2350 AsicAddSharedKeyEntry(pAdapter,
2353 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg,
2354 pAdapter->SharedKey[BSS0][keyIdx].Key,
2355 pAdapter->SharedKey[BSS0][keyIdx].TxMic,
2356 pAdapter->SharedKey[BSS0][keyIdx].RxMic);
2359 // Update ASIC WCID attribute table and IVEIV table
2360 RTMPAddWcidAttributeEntry(pAdapter,
2363 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg,
2366 // Update ASIC WCID attribute table and IVEIV table
2367 RTMPAddWcidAttributeEntry(pAdapter,
2370 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg,
2371 &pAdapter->MacTab.Content[BSSID_WCID]);
2374 int rt_ioctl_siwencodeext(struct net_device *dev,
2375 struct iw_request_info *info,
2376 union iwreq_data *wrqu,
2379 PRTMP_ADAPTER pAdapter = dev->ml_priv;
2380 struct iw_point *encoding = &wrqu->encoding;
2381 struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
2382 int keyIdx, alg = ext->alg;
2384 //check if the interface is down
2385 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
2387 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
2391 if (encoding->flags & IW_ENCODE_DISABLED)
2393 keyIdx = (encoding->flags & IW_ENCODE_INDEX) - 1;
2394 // set BSSID wcid entry of the Pair-wise Key table as no-security mode
2395 AsicRemovePairwiseKeyEntry(pAdapter, BSS0, BSSID_WCID);
2396 pAdapter->SharedKey[BSS0][keyIdx].KeyLen = 0;
2397 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CIPHER_NONE;
2398 AsicRemoveSharedKeyEntry(pAdapter, 0, (UCHAR)keyIdx);
2399 NdisZeroMemory(&pAdapter->SharedKey[BSS0][keyIdx], sizeof(CIPHER_KEY));
2400 DBGPRINT(RT_DEBUG_TRACE, ("%s::Remove all keys!(encoding->flags = %x)\n", __func__, encoding->flags));
2404 // Get Key Index and convet to our own defined key index
2405 keyIdx = (encoding->flags & IW_ENCODE_INDEX) - 1;
2406 if((keyIdx < 0) || (keyIdx >= NR_WEP_KEYS))
2409 if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
2411 pAdapter->StaCfg.DefaultKeyId = keyIdx;
2412 DBGPRINT(RT_DEBUG_TRACE, ("%s::DefaultKeyId = %d\n", __func__, pAdapter->StaCfg.DefaultKeyId));
2416 case IW_ENCODE_ALG_NONE:
2417 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_ENCODE_ALG_NONE\n", __func__));
2419 case IW_ENCODE_ALG_WEP:
2420 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_ENCODE_ALG_WEP - ext->key_len = %d, keyIdx = %d\n", __func__, ext->key_len, keyIdx));
2421 if (ext->key_len == MAX_WEP_KEY_SIZE)
2423 pAdapter->SharedKey[BSS0][keyIdx].KeyLen = MAX_WEP_KEY_SIZE;
2424 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CIPHER_WEP128;
2426 else if (ext->key_len == MIN_WEP_KEY_SIZE)
2428 pAdapter->SharedKey[BSS0][keyIdx].KeyLen = MIN_WEP_KEY_SIZE;
2429 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CIPHER_WEP64;
2434 NdisZeroMemory(pAdapter->SharedKey[BSS0][keyIdx].Key, 16);
2435 NdisMoveMemory(pAdapter->SharedKey[BSS0][keyIdx].Key, ext->key, ext->key_len);
2437 if (pAdapter->StaCfg.GroupCipher == Ndis802_11GroupWEP40Enabled ||
2438 pAdapter->StaCfg.GroupCipher == Ndis802_11GroupWEP104Enabled)
2440 // Set Group key material to Asic
2441 AsicAddSharedKeyEntry(pAdapter, BSS0, keyIdx, pAdapter->SharedKey[BSS0][keyIdx].CipherAlg, pAdapter->SharedKey[BSS0][keyIdx].Key, NULL, NULL);
2443 // Update WCID attribute table and IVEIV table for this group key table
2444 RTMPAddWcidAttributeEntry(pAdapter, BSS0, keyIdx, pAdapter->SharedKey[BSS0][keyIdx].CipherAlg, NULL);
2446 STA_PORT_SECURED(pAdapter);
2448 // Indicate Connected for GUI
2449 pAdapter->IndicateMediaState = NdisMediaStateConnected;
2452 case IW_ENCODE_ALG_TKIP:
2453 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_ENCODE_ALG_TKIP - keyIdx = %d, ext->key_len = %d\n", __func__, keyIdx, ext->key_len));
2454 if (ext->key_len == 32)
2456 if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
2458 fnSetCipherKey(pAdapter, keyIdx, CIPHER_TKIP, FALSE, ext);
2459 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA2)
2461 //pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
2462 STA_PORT_SECURED(pAdapter);
2465 else if (ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY)
2467 fnSetCipherKey(pAdapter, keyIdx, CIPHER_TKIP, TRUE, ext);
2469 // set 802.1x port control
2470 //pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
2471 STA_PORT_SECURED(pAdapter);
2477 case IW_ENCODE_ALG_CCMP:
2478 if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
2480 fnSetCipherKey(pAdapter, keyIdx, CIPHER_AES, FALSE, ext);
2481 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA2)
2482 //pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
2483 STA_PORT_SECURED(pAdapter);
2485 else if (ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY)
2487 fnSetCipherKey(pAdapter, keyIdx, CIPHER_AES, TRUE, ext);
2489 // set 802.1x port control
2490 //pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
2491 STA_PORT_SECURED(pAdapter);
2503 rt_ioctl_giwencodeext(struct net_device *dev,
2504 struct iw_request_info *info,
2505 union iwreq_data *wrqu, char *extra)
2507 PRTMP_ADAPTER pAd = dev->ml_priv;
2509 struct iw_point *encoding = &wrqu->encoding;
2510 struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
2511 int idx, max_key_len;
2513 DBGPRINT(RT_DEBUG_TRACE ,("===> rt_ioctl_giwencodeext\n"));
2515 max_key_len = encoding->length - sizeof(*ext);
2516 if (max_key_len < 0)
2519 idx = encoding->flags & IW_ENCODE_INDEX;
2522 if (idx < 1 || idx > 4)
2526 if ((pAd->StaCfg.WepStatus == Ndis802_11Encryption2Enabled) ||
2527 (pAd->StaCfg.WepStatus == Ndis802_11Encryption3Enabled))
2529 if (idx != pAd->StaCfg.DefaultKeyId)
2537 idx = pAd->StaCfg.DefaultKeyId;
2539 encoding->flags = idx + 1;
2540 memset(ext, 0, sizeof(*ext));
2543 switch(pAd->StaCfg.WepStatus) {
2544 case Ndis802_11WEPDisabled:
2545 ext->alg = IW_ENCODE_ALG_NONE;
2546 encoding->flags |= IW_ENCODE_DISABLED;
2548 case Ndis802_11WEPEnabled:
2549 ext->alg = IW_ENCODE_ALG_WEP;
2550 if (pAd->SharedKey[BSS0][idx].KeyLen > max_key_len)
2554 ext->key_len = pAd->SharedKey[BSS0][idx].KeyLen;
2555 pKey = &(pAd->SharedKey[BSS0][idx].Key[0]);
2558 case Ndis802_11Encryption2Enabled:
2559 case Ndis802_11Encryption3Enabled:
2560 if (pAd->StaCfg.WepStatus == Ndis802_11Encryption2Enabled)
2561 ext->alg = IW_ENCODE_ALG_TKIP;
2563 ext->alg = IW_ENCODE_ALG_CCMP;
2565 if (max_key_len < 32)
2570 pKey = &pAd->StaCfg.PMK[0];
2577 if (ext->key_len && pKey)
2579 encoding->flags |= IW_ENCODE_ENABLED;
2580 memcpy(ext->key, pKey, ext->key_len);
2587 int rt_ioctl_siwgenie(struct net_device *dev,
2588 struct iw_request_info *info,
2589 union iwreq_data *wrqu, char *extra)
2591 PRTMP_ADAPTER pAd = dev->ml_priv;
2593 if (wrqu->data.length > MAX_LEN_OF_RSNIE ||
2594 (wrqu->data.length && extra == NULL))
2597 if (wrqu->data.length)
2599 pAd->StaCfg.RSNIE_Len = wrqu->data.length;
2600 NdisMoveMemory(&pAd->StaCfg.RSN_IE[0], extra, pAd->StaCfg.RSNIE_Len);
2604 pAd->StaCfg.RSNIE_Len = 0;
2605 NdisZeroMemory(&pAd->StaCfg.RSN_IE[0], MAX_LEN_OF_RSNIE);
2610 #endif // SIOCSIWGENIE //
2612 int rt_ioctl_giwgenie(struct net_device *dev,
2613 struct iw_request_info *info,
2614 union iwreq_data *wrqu, char *extra)
2616 PRTMP_ADAPTER pAd = dev->ml_priv;
2618 if ((pAd->StaCfg.RSNIE_Len == 0) ||
2619 (pAd->StaCfg.AuthMode < Ndis802_11AuthModeWPA))
2621 wrqu->data.length = 0;
2626 if (pAd->StaCfg.WpaSupplicantUP == WPA_SUPPLICANT_ENABLE)
2628 if (wrqu->data.length < pAd->StaCfg.RSNIE_Len)
2631 wrqu->data.length = pAd->StaCfg.RSNIE_Len;
2632 memcpy(extra, &pAd->StaCfg.RSN_IE[0], pAd->StaCfg.RSNIE_Len);
2635 #endif // SIOCSIWGENIE //
2637 UCHAR RSNIe = IE_WPA;
2639 if (wrqu->data.length < (pAd->StaCfg.RSNIE_Len + 2)) // ID, Len
2641 wrqu->data.length = pAd->StaCfg.RSNIE_Len + 2;
2643 if ((pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK) ||
2644 (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2))
2647 extra[0] = (char)RSNIe;
2648 extra[1] = pAd->StaCfg.RSNIE_Len;
2649 memcpy(extra+2, &pAd->StaCfg.RSN_IE[0], pAd->StaCfg.RSNIE_Len);
2655 int rt_ioctl_siwpmksa(struct net_device *dev,
2656 struct iw_request_info *info,
2657 union iwreq_data *wrqu,
2660 PRTMP_ADAPTER pAd = dev->ml_priv;
2661 struct iw_pmksa *pPmksa = (struct iw_pmksa *)wrqu->data.pointer;
2662 INT CachedIdx = 0, idx = 0;
2667 DBGPRINT(RT_DEBUG_TRACE ,("===> rt_ioctl_siwpmksa\n"));
2670 case IW_PMKSA_FLUSH:
2671 NdisZeroMemory(pAd->StaCfg.SavedPMK, sizeof(BSSID_INFO)*PMKID_NO);
2672 DBGPRINT(RT_DEBUG_TRACE ,("rt_ioctl_siwpmksa - IW_PMKSA_FLUSH\n"));
2674 case IW_PMKSA_REMOVE:
2675 for (CachedIdx = 0; CachedIdx < pAd->StaCfg.SavedPMKNum; CachedIdx++)
2677 // compare the BSSID
2678 if (NdisEqualMemory(pPmksa->bssid.sa_data, pAd->StaCfg.SavedPMK[CachedIdx].BSSID, MAC_ADDR_LEN))
2680 NdisZeroMemory(pAd->StaCfg.SavedPMK[CachedIdx].BSSID, MAC_ADDR_LEN);
2681 NdisZeroMemory(pAd->StaCfg.SavedPMK[CachedIdx].PMKID, 16);
2682 for (idx = CachedIdx; idx < (pAd->StaCfg.SavedPMKNum - 1); idx++)
2684 NdisMoveMemory(&pAd->StaCfg.SavedPMK[idx].BSSID[0], &pAd->StaCfg.SavedPMK[idx+1].BSSID[0], MAC_ADDR_LEN);
2685 NdisMoveMemory(&pAd->StaCfg.SavedPMK[idx].PMKID[0], &pAd->StaCfg.SavedPMK[idx+1].PMKID[0], 16);
2687 pAd->StaCfg.SavedPMKNum--;
2692 DBGPRINT(RT_DEBUG_TRACE ,("rt_ioctl_siwpmksa - IW_PMKSA_REMOVE\n"));
2695 for (CachedIdx = 0; CachedIdx < pAd->StaCfg.SavedPMKNum; CachedIdx++)
2697 // compare the BSSID
2698 if (NdisEqualMemory(pPmksa->bssid.sa_data, pAd->StaCfg.SavedPMK[CachedIdx].BSSID, MAC_ADDR_LEN))
2702 // Found, replace it
2703 if (CachedIdx < PMKID_NO)
2705 DBGPRINT(RT_DEBUG_OFF, ("Update PMKID, idx = %d\n", CachedIdx));
2706 NdisMoveMemory(&pAd->StaCfg.SavedPMK[CachedIdx].BSSID[0], pPmksa->bssid.sa_data, MAC_ADDR_LEN);
2707 NdisMoveMemory(&pAd->StaCfg.SavedPMK[CachedIdx].PMKID[0], pPmksa->pmkid, 16);
2708 pAd->StaCfg.SavedPMKNum++;
2710 // Not found, replace the last one
2713 // Randomly replace one
2714 CachedIdx = (pPmksa->bssid.sa_data[5] % PMKID_NO);
2715 DBGPRINT(RT_DEBUG_OFF, ("Update PMKID, idx = %d\n", CachedIdx));
2716 NdisMoveMemory(&pAd->StaCfg.SavedPMK[CachedIdx].BSSID[0], pPmksa->bssid.sa_data, MAC_ADDR_LEN);
2717 NdisMoveMemory(&pAd->StaCfg.SavedPMK[CachedIdx].PMKID[0], pPmksa->pmkid, 16);
2720 DBGPRINT(RT_DEBUG_TRACE ,("rt_ioctl_siwpmksa - IW_PMKSA_ADD\n"));
2723 DBGPRINT(RT_DEBUG_TRACE ,("rt_ioctl_siwpmksa - Unknow Command!!\n"));
2729 #endif // #if WIRELESS_EXT > 17
2733 rt_private_ioctl_bbp(struct net_device *dev, struct iw_request_info *info,
2734 struct iw_point *wrq, char *extra)
2739 // CHAR arg[255]={0};
2742 BOOLEAN bIsPrintAllBBP = FALSE;
2744 PRTMP_ADAPTER pAdapter = dev->ml_priv;
2747 memset(extra, 0x00, IW_PRIV_SIZE_MASK);
2749 if (wrq->length > 1) //No parameters.
2751 sprintf(extra, "\n");
2753 //Parsing Read or Write
2754 this_char = wrq->pointer;
2755 DBGPRINT(RT_DEBUG_TRACE, ("this_char=%s\n", this_char));
2759 if ((value = rtstrchr(this_char, '=')) != NULL)
2762 if (!value || !*value)
2764 DBGPRINT(RT_DEBUG_TRACE, ("this_char=%s, value=%s\n", this_char, value));
2765 if (sscanf(this_char, "%d", &(bbpId)) == 1)
2770 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, ®BBP);
2772 sprintf(extra+strlen(extra), "R%02d[0x%02X]:%02X\n", bbpId, bbpId*2, regBBP);
2773 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2774 DBGPRINT(RT_DEBUG_TRACE, ("msg=%s\n", extra));
2777 {//Invalid parametes, so default printk all bbp
2778 bIsPrintAllBBP = TRUE;
2783 { //Invalid parametes, so default printk all bbp
2784 bIsPrintAllBBP = TRUE;
2790 if ((sscanf(this_char, "%d", &(bbpId)) == 1) && (sscanf(value, "%x", &(bbpValue)) == 1))
2795 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, bbpId, bbpValue);
2796 //Read it back for showing
2797 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, ®BBP);
2799 sprintf(extra+strlen(extra), "R%02d[0x%02X]:%02X\n", bbpId, bbpId*2, regBBP);
2800 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2801 DBGPRINT(RT_DEBUG_TRACE, ("msg=%s\n", extra));
2804 {//Invalid parametes, so default printk all bbp
2805 bIsPrintAllBBP = TRUE;
2810 { //Invalid parametes, so default printk all bbp
2811 bIsPrintAllBBP = TRUE;
2817 bIsPrintAllBBP = TRUE;
2822 memset(extra, 0x00, IW_PRIV_SIZE_MASK);
2823 sprintf(extra, "\n");
2824 for (bbpId = 0; bbpId <= 136; bbpId++)
2826 if (strlen(extra) >= (IW_PRIV_SIZE_MASK - 10))
2828 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, ®BBP);
2829 sprintf(extra+strlen(extra), "R%02d[0x%02X]:%02X ", bbpId, bbpId*2, regBBP);
2831 sprintf(extra+strlen(extra), "\n");
2834 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2835 DBGPRINT(RT_DEBUG_TRACE, ("wrq->length = %d\n", wrq->length));
2838 DBGPRINT(RT_DEBUG_TRACE, ("<==rt_private_ioctl_bbp\n\n"));
2844 int rt_ioctl_siwrate(struct net_device *dev,
2845 struct iw_request_info *info,
2846 union iwreq_data *wrqu, char *extra)
2848 PRTMP_ADAPTER pAd = dev->ml_priv;
2849 UINT32 rate = wrqu->bitrate.value, fixed = wrqu->bitrate.fixed;
2851 //check if the interface is down
2852 if(!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_IN_USE))
2854 DBGPRINT(RT_DEBUG_TRACE, ("rt_ioctl_siwrate::Network is down!\n"));
2858 DBGPRINT(RT_DEBUG_TRACE, ("rt_ioctl_siwrate::(rate = %d, fixed = %d)\n", rate, fixed));
2859 /* rate = -1 => auto rate
2860 rate = X, fixed = 1 => (fixed rate X)
2865 pAd->StaCfg.DesiredTransmitSetting.field.MCS = MCS_AUTO;
2866 pAd->StaCfg.bAutoTxRateSwitch = TRUE;
2867 if ((pAd->CommonCfg.PhyMode <= PHY_11G) ||
2868 (pAd->MacTab.Content[BSSID_WCID].HTPhyMode.field.MODE <= MODE_OFDM))
2869 RTMPSetDesiredRates(pAd, -1);
2871 #ifdef DOT11_N_SUPPORT
2873 #endif // DOT11_N_SUPPORT //
2879 pAd->StaCfg.bAutoTxRateSwitch = FALSE;
2880 if ((pAd->CommonCfg.PhyMode <= PHY_11G) ||
2881 (pAd->MacTab.Content[BSSID_WCID].HTPhyMode.field.MODE <= MODE_OFDM))
2882 RTMPSetDesiredRates(pAd, rate);
2885 pAd->StaCfg.DesiredTransmitSetting.field.MCS = MCS_AUTO;
2886 #ifdef DOT11_N_SUPPORT
2888 #endif // DOT11_N_SUPPORT //
2890 DBGPRINT(RT_DEBUG_TRACE, ("rt_ioctl_siwrate::(HtMcs=%d)\n",pAd->StaCfg.DesiredTransmitSetting.field.MCS));
2894 // TODO: rate = X, fixed = 0 => (rates <= X)
2902 int rt_ioctl_giwrate(struct net_device *dev,
2903 struct iw_request_info *info,
2904 union iwreq_data *wrqu, char *extra)
2906 PRTMP_ADAPTER pAd = dev->ml_priv;
2907 int rate_index = 0, rate_count = 0;
2908 HTTRANSMIT_SETTING ht_setting;
2909 __s32 ralinkrate[] =
2910 {2, 4, 11, 22, // CCK
2911 12, 18, 24, 36, 48, 72, 96, 108, // OFDM
2912 13, 26, 39, 52, 78, 104, 117, 130, 26, 52, 78, 104, 156, 208, 234, 260, // 20MHz, 800ns GI, MCS: 0 ~ 15
2913 39, 78, 117, 156, 234, 312, 351, 390, // 20MHz, 800ns GI, MCS: 16 ~ 23
2914 27, 54, 81, 108, 162, 216, 243, 270, 54, 108, 162, 216, 324, 432, 486, 540, // 40MHz, 800ns GI, MCS: 0 ~ 15
2915 81, 162, 243, 324, 486, 648, 729, 810, // 40MHz, 800ns GI, MCS: 16 ~ 23
2916 14, 29, 43, 57, 87, 115, 130, 144, 29, 59, 87, 115, 173, 230, 260, 288, // 20MHz, 400ns GI, MCS: 0 ~ 15
2917 43, 87, 130, 173, 260, 317, 390, 433, // 20MHz, 400ns GI, MCS: 16 ~ 23
2918 30, 60, 90, 120, 180, 240, 270, 300, 60, 120, 180, 240, 360, 480, 540, 600, // 40MHz, 400ns GI, MCS: 0 ~ 15
2919 90, 180, 270, 360, 540, 720, 810, 900}; // 40MHz, 400ns GI, MCS: 16 ~ 23
2921 rate_count = sizeof(ralinkrate)/sizeof(__s32);
2922 //check if the interface is down
2923 if(!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_IN_USE))
2925 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
2929 if ((pAd->StaCfg.bAutoTxRateSwitch == FALSE) &&
2931 ((pAd->CommonCfg.PhyMode <= PHY_11G) || (pAd->MacTab.Content[BSSID_WCID].HTPhyMode.field.MODE <= MODE_OFDM)))
2932 ht_setting.word = pAd->StaCfg.HTPhyMode.word;
2934 ht_setting.word = pAd->MacTab.Content[BSSID_WCID].HTPhyMode.word;
2936 #ifdef DOT11_N_SUPPORT
2937 if (ht_setting.field.MODE >= MODE_HTMIX)
2939 // rate_index = 12 + ((UCHAR)ht_setting.field.BW *16) + ((UCHAR)ht_setting.field.ShortGI *32) + ((UCHAR)ht_setting.field.MCS);
2940 rate_index = 12 + ((UCHAR)ht_setting.field.BW *24) + ((UCHAR)ht_setting.field.ShortGI *48) + ((UCHAR)ht_setting.field.MCS);
2943 #endif // DOT11_N_SUPPORT //
2944 if (ht_setting.field.MODE == MODE_OFDM)
2945 rate_index = (UCHAR)(ht_setting.field.MCS) + 4;
2946 else if (ht_setting.field.MODE == MODE_CCK)
2947 rate_index = (UCHAR)(ht_setting.field.MCS);
2952 if (rate_index > rate_count)
2953 rate_index = rate_count;
2955 wrqu->bitrate.value = ralinkrate[rate_index] * 500000;
2956 wrqu->bitrate.disabled = 0;
2961 static const iw_handler rt_handler[] =
2963 (iw_handler) NULL, /* SIOCSIWCOMMIT */
2964 (iw_handler) rt_ioctl_giwname, /* SIOCGIWNAME */
2965 (iw_handler) NULL, /* SIOCSIWNWID */
2966 (iw_handler) NULL, /* SIOCGIWNWID */
2967 (iw_handler) rt_ioctl_siwfreq, /* SIOCSIWFREQ */
2968 (iw_handler) rt_ioctl_giwfreq, /* SIOCGIWFREQ */
2969 (iw_handler) rt_ioctl_siwmode, /* SIOCSIWMODE */
2970 (iw_handler) rt_ioctl_giwmode, /* SIOCGIWMODE */
2971 (iw_handler) NULL, /* SIOCSIWSENS */
2972 (iw_handler) NULL, /* SIOCGIWSENS */
2973 (iw_handler) NULL /* not used */, /* SIOCSIWRANGE */
2974 (iw_handler) rt_ioctl_giwrange, /* SIOCGIWRANGE */
2975 (iw_handler) NULL /* not used */, /* SIOCSIWPRIV */
2976 (iw_handler) NULL /* kernel code */, /* SIOCGIWPRIV */
2977 (iw_handler) NULL /* not used */, /* SIOCSIWSTATS */
2978 (iw_handler) rt28xx_get_wireless_stats /* kernel code */, /* SIOCGIWSTATS */
2979 (iw_handler) NULL, /* SIOCSIWSPY */
2980 (iw_handler) NULL, /* SIOCGIWSPY */
2981 (iw_handler) NULL, /* SIOCSIWTHRSPY */
2982 (iw_handler) NULL, /* SIOCGIWTHRSPY */
2983 (iw_handler) rt_ioctl_siwap, /* SIOCSIWAP */
2984 (iw_handler) rt_ioctl_giwap, /* SIOCGIWAP */
2986 (iw_handler) rt_ioctl_siwmlme, /* SIOCSIWMLME */
2988 (iw_handler) NULL, /* SIOCSIWMLME */
2989 #endif // SIOCSIWMLME //
2990 (iw_handler) rt_ioctl_iwaplist, /* SIOCGIWAPLIST */
2992 (iw_handler) rt_ioctl_siwscan, /* SIOCSIWSCAN */
2993 (iw_handler) rt_ioctl_giwscan, /* SIOCGIWSCAN */
2995 (iw_handler) NULL, /* SIOCSIWSCAN */
2996 (iw_handler) NULL, /* SIOCGIWSCAN */
2997 #endif /* SIOCGIWSCAN */
2998 (iw_handler) rt_ioctl_siwessid, /* SIOCSIWESSID */
2999 (iw_handler) rt_ioctl_giwessid, /* SIOCGIWESSID */
3000 (iw_handler) rt_ioctl_siwnickn, /* SIOCSIWNICKN */
3001 (iw_handler) rt_ioctl_giwnickn, /* SIOCGIWNICKN */
3002 (iw_handler) NULL, /* -- hole -- */
3003 (iw_handler) NULL, /* -- hole -- */
3004 (iw_handler) rt_ioctl_siwrate, /* SIOCSIWRATE */
3005 (iw_handler) rt_ioctl_giwrate, /* SIOCGIWRATE */
3006 (iw_handler) rt_ioctl_siwrts, /* SIOCSIWRTS */
3007 (iw_handler) rt_ioctl_giwrts, /* SIOCGIWRTS */
3008 (iw_handler) rt_ioctl_siwfrag, /* SIOCSIWFRAG */
3009 (iw_handler) rt_ioctl_giwfrag, /* SIOCGIWFRAG */
3010 (iw_handler) NULL, /* SIOCSIWTXPOW */
3011 (iw_handler) NULL, /* SIOCGIWTXPOW */
3012 (iw_handler) NULL, /* SIOCSIWRETRY */
3013 (iw_handler) NULL, /* SIOCGIWRETRY */
3014 (iw_handler) rt_ioctl_siwencode, /* SIOCSIWENCODE */
3015 (iw_handler) rt_ioctl_giwencode, /* SIOCGIWENCODE */
3016 (iw_handler) NULL, /* SIOCSIWPOWER */
3017 (iw_handler) NULL, /* SIOCGIWPOWER */
3018 (iw_handler) NULL, /* -- hole -- */
3019 (iw_handler) NULL, /* -- hole -- */
3020 #if WIRELESS_EXT > 17
3021 (iw_handler) rt_ioctl_siwgenie, /* SIOCSIWGENIE */
3022 (iw_handler) rt_ioctl_giwgenie, /* SIOCGIWGENIE */
3023 (iw_handler) rt_ioctl_siwauth, /* SIOCSIWAUTH */
3024 (iw_handler) rt_ioctl_giwauth, /* SIOCGIWAUTH */
3025 (iw_handler) rt_ioctl_siwencodeext, /* SIOCSIWENCODEEXT */
3026 (iw_handler) rt_ioctl_giwencodeext, /* SIOCGIWENCODEEXT */
3027 (iw_handler) rt_ioctl_siwpmksa, /* SIOCSIWPMKSA */
3031 static const iw_handler rt_priv_handlers[] = {
3032 (iw_handler) NULL, /* + 0x00 */
3033 (iw_handler) NULL, /* + 0x01 */
3034 #ifndef CONFIG_AP_SUPPORT
3035 (iw_handler) rt_ioctl_setparam, /* + 0x02 */
3037 (iw_handler) NULL, /* + 0x02 */
3038 #endif // CONFIG_AP_SUPPORT //
3040 (iw_handler) rt_private_ioctl_bbp, /* + 0x03 */
3042 (iw_handler) NULL, /* + 0x03 */
3044 (iw_handler) NULL, /* + 0x04 */
3045 (iw_handler) NULL, /* + 0x05 */
3046 (iw_handler) NULL, /* + 0x06 */
3047 (iw_handler) NULL, /* + 0x07 */
3048 (iw_handler) NULL, /* + 0x08 */
3049 (iw_handler) rt_private_get_statistics, /* + 0x09 */
3050 (iw_handler) NULL, /* + 0x0A */
3051 (iw_handler) NULL, /* + 0x0B */
3052 (iw_handler) NULL, /* + 0x0C */
3053 (iw_handler) NULL, /* + 0x0D */
3054 (iw_handler) NULL, /* + 0x0E */
3055 (iw_handler) NULL, /* + 0x0F */
3056 (iw_handler) NULL, /* + 0x10 */
3057 (iw_handler) rt_private_show, /* + 0x11 */
3058 (iw_handler) NULL, /* + 0x12 */
3059 (iw_handler) NULL, /* + 0x13 */
3060 (iw_handler) NULL, /* + 0x15 */
3061 (iw_handler) NULL, /* + 0x17 */
3062 (iw_handler) NULL, /* + 0x18 */
3065 const struct iw_handler_def rt28xx_iw_handler_def =
3067 #define N(a) (sizeof (a) / sizeof (a[0]))
3068 .standard = (iw_handler *) rt_handler,
3069 .num_standard = sizeof(rt_handler) / sizeof(iw_handler),
3070 .private = (iw_handler *) rt_priv_handlers,
3071 .num_private = N(rt_priv_handlers),
3072 .private_args = (struct iw_priv_args *) privtab,
3073 .num_private_args = N(privtab),
3074 #if IW_HANDLER_VERSION >= 7
3075 .get_wireless_stats = rt28xx_get_wireless_stats,
3079 INT RTMPSetInformation(
3080 IN PRTMP_ADAPTER pAdapter,
3081 IN OUT struct ifreq *rq,
3084 struct iwreq *wrq = (struct iwreq *) rq;
3085 NDIS_802_11_SSID Ssid;
3086 NDIS_802_11_MAC_ADDRESS Bssid;
3087 RT_802_11_PHY_MODE PhyMode;
3088 RT_802_11_STA_CONFIG StaConfig;
3089 NDIS_802_11_RATES aryRates;
3090 RT_802_11_PREAMBLE Preamble;
3091 NDIS_802_11_WEP_STATUS WepStatus;
3092 NDIS_802_11_AUTHENTICATION_MODE AuthMode = Ndis802_11AuthModeMax;
3093 NDIS_802_11_NETWORK_INFRASTRUCTURE BssType;
3094 NDIS_802_11_RTS_THRESHOLD RtsThresh;
3095 NDIS_802_11_FRAGMENTATION_THRESHOLD FragThresh;
3096 NDIS_802_11_POWER_MODE PowerMode;
3097 PNDIS_802_11_KEY pKey = NULL;
3098 PNDIS_802_11_WEP pWepKey =NULL;
3099 PNDIS_802_11_REMOVE_KEY pRemoveKey = NULL;
3100 NDIS_802_11_CONFIGURATION Config, *pConfig = NULL;
3101 NDIS_802_11_NETWORK_TYPE NetType;
3104 INT Status = NDIS_STATUS_SUCCESS, MaxPhyMode = PHY_11G;
3107 BOOLEAN StateMachineTouched = FALSE;
3108 #ifdef DOT11_N_SUPPORT
3109 OID_SET_HT_PHYMODE HT_PhyMode; //11n ,kathy
3110 #endif // DOT11_N_SUPPORT //
3111 PNDIS_802_11_PMKID pPmkId = NULL;
3112 BOOLEAN IEEE8021xState = FALSE;
3113 BOOLEAN IEEE8021x_required_keys = FALSE;
3114 UCHAR wpa_supplicant_enable = 0;
3116 #ifdef DOT11_N_SUPPORT
3117 MaxPhyMode = PHY_11N_5G;
3118 #endif // DOT11_N_SUPPORT //
3121 DBGPRINT(RT_DEBUG_TRACE, ("-->RTMPSetInformation(), 0x%08x\n", cmd&0x7FFF));
3122 switch(cmd & 0x7FFF) {
3123 case RT_OID_802_11_COUNTRY_REGION:
3124 if (wrq->u.data.length < sizeof(UCHAR))
3126 // Only avaliable when EEPROM not programming
3127 else if (!(pAdapter->CommonCfg.CountryRegion & 0x80) && !(pAdapter->CommonCfg.CountryRegionForABand & 0x80))
3132 Status = copy_from_user(&Country, wrq->u.data.pointer, wrq->u.data.length);
3133 pAdapter->CommonCfg.CountryRegion = (UCHAR)(Country & 0x000000FF);
3134 pAdapter->CommonCfg.CountryRegionForABand = (UCHAR)((Country >> 8) & 0x000000FF);
3135 TmpPhy = pAdapter->CommonCfg.PhyMode;
3136 pAdapter->CommonCfg.PhyMode = 0xff;
3137 // Build all corresponding channel information
3138 RTMPSetPhyMode(pAdapter, TmpPhy);
3139 #ifdef DOT11_N_SUPPORT
3140 SetCommonHT(pAdapter);
3141 #endif // DOT11_N_SUPPORT //
3142 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_COUNTRY_REGION (A:%d B/G:%d)\n", pAdapter->CommonCfg.CountryRegionForABand,
3143 pAdapter->CommonCfg.CountryRegion));
3146 case OID_802_11_BSSID_LIST_SCAN:
3148 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_BSSID_LIST_SCAN, TxCnt = %d \n", pAdapter->RalinkCounters.LastOneSecTotalTxCount));
3150 if (MONITOR_ON(pAdapter))
3152 DBGPRINT(RT_DEBUG_TRACE, ("!!! Driver is in Monitor Mode now !!!\n"));
3156 //Benson add 20080527, when radio off, sta don't need to scan
3157 if (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_RADIO_OFF))
3160 if (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
3162 DBGPRINT(RT_DEBUG_TRACE, ("!!! Driver is scanning now !!!\n"));
3163 pAdapter->StaCfg.bScanReqIsFromWebUI = TRUE;
3164 Status = NDIS_STATUS_SUCCESS;
3168 if (pAdapter->RalinkCounters.LastOneSecTotalTxCount > 100)
3170 DBGPRINT(RT_DEBUG_TRACE, ("!!! Link UP, ignore this set::OID_802_11_BSSID_LIST_SCAN\n"));
3171 Status = NDIS_STATUS_SUCCESS;
3172 pAdapter->StaCfg.ScanCnt = 99; // Prevent auto scan triggered by this OID
3176 if ((OPSTATUS_TEST_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED)) &&
3177 ((pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA) ||
3178 (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK) ||
3179 (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA2) ||
3180 (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK)) &&
3181 (pAdapter->StaCfg.PortSecured == WPA_802_1X_PORT_NOT_SECURED))
3183 DBGPRINT(RT_DEBUG_TRACE, ("!!! Link UP, Port Not Secured! ignore this set::OID_802_11_BSSID_LIST_SCAN\n"));
3184 Status = NDIS_STATUS_SUCCESS;
3185 pAdapter->StaCfg.ScanCnt = 99; // Prevent auto scan triggered by this OID
3190 if (pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE)
3192 RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
3193 DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
3196 // tell CNTL state machine to call NdisMSetInformationComplete() after completing
3197 // this request, because this request is initiated by NDIS.
3198 pAdapter->MlmeAux.CurrReqIsFromNdis = FALSE;
3199 // Reset allowed scan retries
3200 pAdapter->StaCfg.ScanCnt = 0;
3201 pAdapter->StaCfg.LastScanTime = Now;
3203 pAdapter->StaCfg.bScanReqIsFromWebUI = TRUE;
3204 RTMP_SET_FLAG(pAdapter, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS);
3205 MlmeEnqueue(pAdapter,
3206 MLME_CNTL_STATE_MACHINE,
3207 OID_802_11_BSSID_LIST_SCAN,
3211 Status = NDIS_STATUS_SUCCESS;
3212 StateMachineTouched = TRUE;
3214 case OID_802_11_SSID:
3215 if (wrq->u.data.length != sizeof(NDIS_802_11_SSID))
3219 PCHAR pSsidString = NULL;
3220 Status = copy_from_user(&Ssid, wrq->u.data.pointer, wrq->u.data.length);
3222 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_SSID (Len=%d,Ssid=%s)\n", Ssid.SsidLength, Ssid.Ssid));
3223 if (Ssid.SsidLength > MAX_LEN_OF_SSID)
3227 if (Ssid.SsidLength == 0)
3229 Set_SSID_Proc(pAdapter, "");
3233 pSsidString = (CHAR *) kmalloc(MAX_LEN_OF_SSID+1, MEM_ALLOC_FLAG);
3236 NdisZeroMemory(pSsidString, MAX_LEN_OF_SSID+1);
3237 NdisMoveMemory(pSsidString, Ssid.Ssid, Ssid.SsidLength);
3238 Set_SSID_Proc(pAdapter, pSsidString);
3247 case OID_802_11_BSSID:
3248 if (wrq->u.data.length != sizeof(NDIS_802_11_MAC_ADDRESS))
3252 Status = copy_from_user(&Bssid, wrq->u.data.pointer, wrq->u.data.length);
3254 // tell CNTL state machine to call NdisMSetInformationComplete() after completing
3255 // this request, because this request is initiated by NDIS.
3256 pAdapter->MlmeAux.CurrReqIsFromNdis = FALSE;
3258 // Prevent to connect AP again in STAMlmePeriodicExec
3259 pAdapter->MlmeAux.AutoReconnectSsidLen= 32;
3261 // Reset allowed scan retries
3262 pAdapter->StaCfg.ScanCnt = 0;
3264 if (pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE)
3266 RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
3267 DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
3269 MlmeEnqueue(pAdapter,
3270 MLME_CNTL_STATE_MACHINE,
3272 sizeof(NDIS_802_11_MAC_ADDRESS),
3274 Status = NDIS_STATUS_SUCCESS;
3275 StateMachineTouched = TRUE;
3277 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_BSSID %02x:%02x:%02x:%02x:%02x:%02x\n",
3278 Bssid[0], Bssid[1], Bssid[2], Bssid[3], Bssid[4], Bssid[5]));
3281 case RT_OID_802_11_RADIO:
3282 if (wrq->u.data.length != sizeof(BOOLEAN))
3286 Status = copy_from_user(&RadioState, wrq->u.data.pointer, wrq->u.data.length);
3287 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_RADIO (=%d)\n", RadioState));
3288 if (pAdapter->StaCfg.bSwRadio != RadioState)
3290 pAdapter->StaCfg.bSwRadio = RadioState;
3291 if (pAdapter->StaCfg.bRadio != (pAdapter->StaCfg.bHwRadio && pAdapter->StaCfg.bSwRadio))
3293 pAdapter->StaCfg.bRadio = (pAdapter->StaCfg.bHwRadio && pAdapter->StaCfg.bSwRadio);
3294 if (pAdapter->StaCfg.bRadio == TRUE)
3296 MlmeRadioOn(pAdapter);
3297 // Update extra information
3298 pAdapter->ExtraInfo = EXTRA_INFO_CLEAR;
3302 MlmeRadioOff(pAdapter);
3303 // Update extra information
3304 pAdapter->ExtraInfo = SW_RADIO_OFF;
3310 case RT_OID_802_11_PHY_MODE:
3311 if (wrq->u.data.length != sizeof(RT_802_11_PHY_MODE))
3315 Status = copy_from_user(&PhyMode, wrq->u.data.pointer, wrq->u.data.length);
3316 if (PhyMode <= MaxPhyMode)
3318 RTMPSetPhyMode(pAdapter, PhyMode);
3319 #ifdef DOT11_N_SUPPORT
3320 SetCommonHT(pAdapter);
3321 #endif // DOT11_N_SUPPORT //
3323 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_PHY_MODE (=%d)\n", PhyMode));
3326 case RT_OID_802_11_STA_CONFIG:
3327 if (wrq->u.data.length != sizeof(RT_802_11_STA_CONFIG))
3331 Status = copy_from_user(&StaConfig, wrq->u.data.pointer, wrq->u.data.length);
3332 pAdapter->CommonCfg.bEnableTxBurst = StaConfig.EnableTxBurst;
3333 pAdapter->CommonCfg.UseBGProtection = StaConfig.UseBGProtection;
3334 pAdapter->CommonCfg.bUseShortSlotTime = 1; // 2003-10-30 always SHORT SLOT capable
3335 if ((pAdapter->CommonCfg.PhyMode != StaConfig.AdhocMode) &&
3336 (StaConfig.AdhocMode <= MaxPhyMode))
3338 // allow dynamic change of "USE OFDM rate or not" in ADHOC mode
3339 // if setting changed, need to reset current TX rate as well as BEACON frame format
3340 if (pAdapter->StaCfg.BssType == BSS_ADHOC)
3342 pAdapter->CommonCfg.PhyMode = StaConfig.AdhocMode;
3343 RTMPSetPhyMode(pAdapter, PhyMode);
3344 MlmeUpdateTxRates(pAdapter, FALSE, 0);
3345 MakeIbssBeacon(pAdapter); // re-build BEACON frame
3346 AsicEnableIbssSync(pAdapter); // copy to on-chip memory
3349 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_SET_STA_CONFIG (Burst=%d, Protection=%ld,ShortSlot=%d\n",
3350 pAdapter->CommonCfg.bEnableTxBurst,
3351 pAdapter->CommonCfg.UseBGProtection,
3352 pAdapter->CommonCfg.bUseShortSlotTime));
3355 case OID_802_11_DESIRED_RATES:
3356 if (wrq->u.data.length != sizeof(NDIS_802_11_RATES))
3360 Status = copy_from_user(&aryRates, wrq->u.data.pointer, wrq->u.data.length);
3361 NdisZeroMemory(pAdapter->CommonCfg.DesireRate, MAX_LEN_OF_SUPPORTED_RATES);
3362 NdisMoveMemory(pAdapter->CommonCfg.DesireRate, &aryRates, sizeof(NDIS_802_11_RATES));
3363 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_DESIRED_RATES (%02x,%02x,%02x,%02x,%02x,%02x,%02x,%02x)\n",
3364 pAdapter->CommonCfg.DesireRate[0],pAdapter->CommonCfg.DesireRate[1],
3365 pAdapter->CommonCfg.DesireRate[2],pAdapter->CommonCfg.DesireRate[3],
3366 pAdapter->CommonCfg.DesireRate[4],pAdapter->CommonCfg.DesireRate[5],
3367 pAdapter->CommonCfg.DesireRate[6],pAdapter->CommonCfg.DesireRate[7] ));
3368 // Changing DesiredRate may affect the MAX TX rate we used to TX frames out
3369 MlmeUpdateTxRates(pAdapter, FALSE, 0);
3372 case RT_OID_802_11_PREAMBLE:
3373 if (wrq->u.data.length != sizeof(RT_802_11_PREAMBLE))
3377 Status = copy_from_user(&Preamble, wrq->u.data.pointer, wrq->u.data.length);
3378 if (Preamble == Rt802_11PreambleShort)
3380 pAdapter->CommonCfg.TxPreamble = Preamble;
3381 MlmeSetTxPreamble(pAdapter, Rt802_11PreambleShort);
3383 else if ((Preamble == Rt802_11PreambleLong) || (Preamble == Rt802_11PreambleAuto))
3385 // if user wants AUTO, initialize to LONG here, then change according to AP's
3386 // capability upon association.
3387 pAdapter->CommonCfg.TxPreamble = Preamble;
3388 MlmeSetTxPreamble(pAdapter, Rt802_11PreambleLong);
3395 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_PREAMBLE (=%d)\n", Preamble));
3398 case OID_802_11_WEP_STATUS:
3399 if (wrq->u.data.length != sizeof(NDIS_802_11_WEP_STATUS))
3403 Status = copy_from_user(&WepStatus, wrq->u.data.pointer, wrq->u.data.length);
3404 // Since TKIP, AES, WEP are all supported. It should not have any invalid setting
3405 if (WepStatus <= Ndis802_11Encryption3KeyAbsent)
3407 if (pAdapter->StaCfg.WepStatus != WepStatus)
3409 // Config has changed
3410 pAdapter->bConfigChanged = TRUE;
3412 pAdapter->StaCfg.WepStatus = WepStatus;
3413 pAdapter->StaCfg.OrigWepStatus = WepStatus;
3414 pAdapter->StaCfg.PairCipher = WepStatus;
3415 pAdapter->StaCfg.GroupCipher = WepStatus;
3422 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_WEP_STATUS (=%d)\n",WepStatus));
3425 case OID_802_11_AUTHENTICATION_MODE:
3426 if (wrq->u.data.length != sizeof(NDIS_802_11_AUTHENTICATION_MODE))
3430 Status = copy_from_user(&AuthMode, wrq->u.data.pointer, wrq->u.data.length);
3431 if (AuthMode > Ndis802_11AuthModeMax)
3438 if (pAdapter->StaCfg.AuthMode != AuthMode)
3440 // Config has changed
3441 pAdapter->bConfigChanged = TRUE;
3443 pAdapter->StaCfg.AuthMode = AuthMode;
3445 pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED;
3446 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_AUTHENTICATION_MODE (=%d) \n",pAdapter->StaCfg.AuthMode));
3449 case OID_802_11_INFRASTRUCTURE_MODE:
3450 if (wrq->u.data.length != sizeof(NDIS_802_11_NETWORK_INFRASTRUCTURE))
3454 Status = copy_from_user(&BssType, wrq->u.data.pointer, wrq->u.data.length);
3456 if (BssType == Ndis802_11IBSS)
3457 Set_NetworkType_Proc(pAdapter, "Adhoc");
3458 else if (BssType == Ndis802_11Infrastructure)
3459 Set_NetworkType_Proc(pAdapter, "Infra");
3460 else if (BssType == Ndis802_11Monitor)
3461 Set_NetworkType_Proc(pAdapter, "Monitor");
3465 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_INFRASTRUCTURE_MODE (unknown)\n"));
3469 case OID_802_11_REMOVE_WEP:
3470 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_WEP\n"));
3471 if (wrq->u.data.length != sizeof(NDIS_802_11_KEY_INDEX))
3477 KeyIdx = *(NDIS_802_11_KEY_INDEX *) wrq->u.data.pointer;
3479 if (KeyIdx & 0x80000000)
3481 // Should never set default bit when remove key
3486 KeyIdx = KeyIdx & 0x0fffffff;
3492 pAdapter->SharedKey[BSS0][KeyIdx].KeyLen = 0;
3493 pAdapter->SharedKey[BSS0][KeyIdx].CipherAlg = CIPHER_NONE;
3494 AsicRemoveSharedKeyEntry(pAdapter, 0, (UCHAR)KeyIdx);
3499 case RT_OID_802_11_RESET_COUNTERS:
3500 NdisZeroMemory(&pAdapter->WlanCounters, sizeof(COUNTER_802_11));
3501 NdisZeroMemory(&pAdapter->Counters8023, sizeof(COUNTER_802_3));
3502 NdisZeroMemory(&pAdapter->RalinkCounters, sizeof(COUNTER_RALINK));
3503 pAdapter->Counters8023.RxNoBuffer = 0;
3504 pAdapter->Counters8023.GoodReceives = 0;
3505 pAdapter->Counters8023.RxNoBuffer = 0;
3507 pAdapter->BulkOutComplete = 0;
3508 pAdapter->BulkOutCompleteOther= 0;
3509 pAdapter->BulkOutCompleteCancel = 0;
3510 pAdapter->BulkOutReq = 0;
3511 pAdapter->BulkInReq= 0;
3512 pAdapter->BulkInComplete = 0;
3513 pAdapter->BulkInCompleteFail = 0;
3515 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_RESET_COUNTERS \n"));
3517 case OID_802_11_RTS_THRESHOLD:
3518 if (wrq->u.data.length != sizeof(NDIS_802_11_RTS_THRESHOLD))
3522 Status = copy_from_user(&RtsThresh, wrq->u.data.pointer, wrq->u.data.length);
3523 if (RtsThresh > MAX_RTS_THRESHOLD)
3526 pAdapter->CommonCfg.RtsThreshold = (USHORT)RtsThresh;
3528 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_RTS_THRESHOLD (=%ld)\n",RtsThresh));
3530 case OID_802_11_FRAGMENTATION_THRESHOLD:
3531 if (wrq->u.data.length != sizeof(NDIS_802_11_FRAGMENTATION_THRESHOLD))
3535 Status = copy_from_user(&FragThresh, wrq->u.data.pointer, wrq->u.data.length);
3536 pAdapter->CommonCfg.bUseZeroToDisableFragment = FALSE;
3537 if (FragThresh > MAX_FRAG_THRESHOLD || FragThresh < MIN_FRAG_THRESHOLD)
3539 if (FragThresh == 0)
3541 pAdapter->CommonCfg.FragmentThreshold = MAX_FRAG_THRESHOLD;
3542 pAdapter->CommonCfg.bUseZeroToDisableFragment = TRUE;
3548 pAdapter->CommonCfg.FragmentThreshold = (USHORT)FragThresh;
3550 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_FRAGMENTATION_THRESHOLD (=%ld) \n",FragThresh));
3552 case OID_802_11_POWER_MODE:
3553 if (wrq->u.data.length != sizeof(NDIS_802_11_POWER_MODE))
3557 Status = copy_from_user(&PowerMode, wrq->u.data.pointer, wrq->u.data.length);
3558 if (PowerMode == Ndis802_11PowerModeCAM)
3559 Set_PSMode_Proc(pAdapter, "CAM");
3560 else if (PowerMode == Ndis802_11PowerModeMAX_PSP)
3561 Set_PSMode_Proc(pAdapter, "Max_PSP");
3562 else if (PowerMode == Ndis802_11PowerModeFast_PSP)
3563 Set_PSMode_Proc(pAdapter, "Fast_PSP");
3564 else if (PowerMode == Ndis802_11PowerModeLegacy_PSP)
3565 Set_PSMode_Proc(pAdapter, "Legacy_PSP");
3569 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_POWER_MODE (=%d)\n",PowerMode));
3571 case RT_OID_802_11_TX_POWER_LEVEL_1:
3572 if (wrq->u.data.length < sizeof(ULONG))
3576 Status = copy_from_user(&PowerTemp, wrq->u.data.pointer, wrq->u.data.length);
3577 if (PowerTemp > 100)
3578 PowerTemp = 0xffffffff; // AUTO
3579 pAdapter->CommonCfg.TxPowerDefault = PowerTemp; //keep current setting.
3580 pAdapter->CommonCfg.TxPowerPercentage = pAdapter->CommonCfg.TxPowerDefault;
3581 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_TX_POWER_LEVEL_1 (=%ld)\n", pAdapter->CommonCfg.TxPowerPercentage));
3584 case OID_802_11_NETWORK_TYPE_IN_USE:
3585 if (wrq->u.data.length != sizeof(NDIS_802_11_NETWORK_TYPE))
3589 Status = copy_from_user(&NetType, wrq->u.data.pointer, wrq->u.data.length);
3591 if (NetType == Ndis802_11DS)
3592 RTMPSetPhyMode(pAdapter, PHY_11B);
3593 else if (NetType == Ndis802_11OFDM24)
3594 RTMPSetPhyMode(pAdapter, PHY_11BG_MIXED);
3595 else if (NetType == Ndis802_11OFDM5)
3596 RTMPSetPhyMode(pAdapter, PHY_11A);
3599 #ifdef DOT11_N_SUPPORT
3600 if (Status == NDIS_STATUS_SUCCESS)
3601 SetCommonHT(pAdapter);
3602 #endif // DOT11_N_SUPPORT //
3603 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_NETWORK_TYPE_IN_USE (=%d)\n",NetType));
3606 // For WPA PSK PMK key
3607 case RT_OID_802_11_ADD_WPA:
3608 pKey = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
3615 Status = copy_from_user(pKey, wrq->u.data.pointer, wrq->u.data.length);
3616 if (pKey->Length != wrq->u.data.length)
3619 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_ADD_WPA, Failed!!\n"));
3623 if ((pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPAPSK) &&
3624 (pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPA2PSK) &&
3625 (pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPANone) )
3627 Status = -EOPNOTSUPP;
3628 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_ADD_WPA, Failed!! [AuthMode != WPAPSK/WPA2PSK/WPANONE]\n"));
3630 else if ((pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK) ||
3631 (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK) ||
3632 (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPANone) ) // Only for WPA PSK mode
3634 NdisMoveMemory(pAdapter->StaCfg.PMK, &pKey->KeyMaterial, pKey->KeyLength);
3635 // Use RaConfig as PSK agent.
3636 // Start STA supplicant state machine
3637 if (pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPANone)
3638 pAdapter->StaCfg.WpaState = SS_START;
3640 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_ADD_WPA (id=0x%x, Len=%d-byte)\n", pKey->KeyIndex, pKey->KeyLength));
3644 pAdapter->StaCfg.WpaState = SS_NOTUSE;
3645 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_ADD_WPA (id=0x%x, Len=%d-byte)\n", pKey->KeyIndex, pKey->KeyLength));
3650 case OID_802_11_REMOVE_KEY:
3651 pRemoveKey = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
3652 if(pRemoveKey == NULL)
3658 Status = copy_from_user(pRemoveKey, wrq->u.data.pointer, wrq->u.data.length);
3659 if (pRemoveKey->Length != wrq->u.data.length)
3662 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_KEY, Failed!!\n"));
3666 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
3668 RTMPWPARemoveKeyProc(pAdapter, pRemoveKey);
3669 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_KEY, Remove WPA Key!!\n"));
3673 KeyIdx = pRemoveKey->KeyIndex;
3675 if (KeyIdx & 0x80000000)
3677 // Should never set default bit when remove key
3679 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_KEY, Failed!!(Should never set default bit when remove key)\n"));
3683 KeyIdx = KeyIdx & 0x0fffffff;
3687 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_KEY, Failed!!(KeyId[%d] out of range)\n", KeyIdx));
3691 pAdapter->SharedKey[BSS0][KeyIdx].KeyLen = 0;
3692 pAdapter->SharedKey[BSS0][KeyIdx].CipherAlg = CIPHER_NONE;
3693 AsicRemoveSharedKeyEntry(pAdapter, 0, (UCHAR)KeyIdx);
3694 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_KEY (id=0x%x, Len=%d-byte)\n", pRemoveKey->KeyIndex, pRemoveKey->Length));
3702 case OID_802_11_ADD_KEY:
3703 pKey = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
3709 Status = copy_from_user(pKey, wrq->u.data.pointer, wrq->u.data.length);
3710 if (pKey->Length != wrq->u.data.length)
3713 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_KEY, Failed!!\n"));
3717 RTMPAddKey(pAdapter, pKey);
3718 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_KEY (id=0x%x, Len=%d-byte)\n", pKey->KeyIndex, pKey->KeyLength));
3722 case OID_802_11_CONFIGURATION:
3723 if (wrq->u.data.length != sizeof(NDIS_802_11_CONFIGURATION))
3727 Status = copy_from_user(&Config, wrq->u.data.pointer, wrq->u.data.length);
3730 if ((pConfig->BeaconPeriod >= 20) && (pConfig->BeaconPeriod <=400))
3731 pAdapter->CommonCfg.BeaconPeriod = (USHORT) pConfig->BeaconPeriod;
3733 pAdapter->StaActive.AtimWin = (USHORT) pConfig->ATIMWindow;
3734 MAP_KHZ_TO_CHANNEL_ID(pConfig->DSConfig, pAdapter->CommonCfg.Channel);
3736 // Save the channel on MlmeAux for CntlOidRTBssidProc used.
3738 pAdapter->MlmeAux.Channel = pAdapter->CommonCfg.Channel;
3740 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_CONFIGURATION (BeacnPeriod=%ld,AtimW=%ld,Ch=%d)\n",
3741 pConfig->BeaconPeriod, pConfig->ATIMWindow, pAdapter->CommonCfg.Channel));
3742 // Config has changed
3743 pAdapter->bConfigChanged = TRUE;
3746 #ifdef DOT11_N_SUPPORT
3747 case RT_OID_802_11_SET_HT_PHYMODE:
3748 if (wrq->u.data.length != sizeof(OID_SET_HT_PHYMODE))
3752 POID_SET_HT_PHYMODE pHTPhyMode = &HT_PhyMode;
3754 Status = copy_from_user(&HT_PhyMode, wrq->u.data.pointer, wrq->u.data.length);
3755 DBGPRINT(RT_DEBUG_TRACE, ("Set::pHTPhyMode (PhyMode = %d,TransmitNo = %d, HtMode = %d, ExtOffset = %d , MCS = %d, BW = %d, STBC = %d, SHORTGI = %d) \n",
3756 pHTPhyMode->PhyMode, pHTPhyMode->TransmitNo,pHTPhyMode->HtMode,pHTPhyMode->ExtOffset,
3757 pHTPhyMode->MCS, pHTPhyMode->BW, pHTPhyMode->STBC, pHTPhyMode->SHORTGI));
3758 if (pAdapter->CommonCfg.PhyMode >= PHY_11ABGN_MIXED)
3759 RTMPSetHT(pAdapter, pHTPhyMode);
3761 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_SET_HT_PHYMODE(MCS=%d,BW=%d,SGI=%d,STBC=%d)\n",
3762 pAdapter->StaCfg.HTPhyMode.field.MCS, pAdapter->StaCfg.HTPhyMode.field.BW, pAdapter->StaCfg.HTPhyMode.field.ShortGI,
3763 pAdapter->StaCfg.HTPhyMode.field.STBC));
3765 #endif // DOT11_N_SUPPORT //
3766 case RT_OID_802_11_SET_APSD_SETTING:
3767 if (wrq->u.data.length != sizeof(ULONG))
3772 Status = copy_from_user(&apsd, wrq->u.data.pointer, wrq->u.data.length);
3774 /*-------------------------------------------------------------------
3775 |B31~B7 | B6~B5 | B4 | B3 | B2 | B1 | B0 |
3776 ---------------------------------------------------------------------
3777 | Rsvd | Max SP Len | AC_VO | AC_VI | AC_BK | AC_BE | APSD Capable |
3778 ---------------------------------------------------------------------*/
3779 pAdapter->CommonCfg.bAPSDCapable = (apsd & 0x00000001) ? TRUE : FALSE;
3780 pAdapter->CommonCfg.bAPSDAC_BE = ((apsd & 0x00000002) >> 1) ? TRUE : FALSE;
3781 pAdapter->CommonCfg.bAPSDAC_BK = ((apsd & 0x00000004) >> 2) ? TRUE : FALSE;
3782 pAdapter->CommonCfg.bAPSDAC_VI = ((apsd & 0x00000008) >> 3) ? TRUE : FALSE;
3783 pAdapter->CommonCfg.bAPSDAC_VO = ((apsd & 0x00000010) >> 4) ? TRUE : FALSE;
3784 pAdapter->CommonCfg.MaxSPLength = (UCHAR)((apsd & 0x00000060) >> 5);
3786 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,
3787 pAdapter->CommonCfg.bAPSDAC_BE, pAdapter->CommonCfg.bAPSDAC_BK, pAdapter->CommonCfg.bAPSDAC_VI, pAdapter->CommonCfg.bAPSDAC_VO, pAdapter->CommonCfg.MaxSPLength));
3791 case RT_OID_802_11_SET_APSD_PSM:
3792 if (wrq->u.data.length != sizeof(ULONG))
3796 // Driver needs to notify AP when PSM changes
3797 Status = copy_from_user(&pAdapter->CommonCfg.bAPSDForcePowerSave, wrq->u.data.pointer, wrq->u.data.length);
3798 if (pAdapter->CommonCfg.bAPSDForcePowerSave != pAdapter->StaCfg.Psm)
3800 MlmeSetPsmBit(pAdapter, pAdapter->CommonCfg.bAPSDForcePowerSave);
3801 RTMPSendNullFrame(pAdapter, pAdapter->CommonCfg.TxRate, TRUE);
3803 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_SET_APSD_PSM (bAPSDForcePowerSave:%d)\n", pAdapter->CommonCfg.bAPSDForcePowerSave));
3807 case RT_OID_802_11_SET_WMM:
3808 if (wrq->u.data.length != sizeof(BOOLEAN))
3812 Status = copy_from_user(&pAdapter->CommonCfg.bWmmCapable, wrq->u.data.pointer, wrq->u.data.length);
3813 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_SET_WMM (=%d) \n", pAdapter->CommonCfg.bWmmCapable));
3817 case OID_802_11_DISASSOCIATE:
3819 // Set NdisRadioStateOff to TRUE, instead of called MlmeRadioOff.
3820 // Later on, NDIS_802_11_BSSID_LIST_EX->NumberOfItems should be 0
3821 // when query OID_802_11_BSSID_LIST.
3823 // TRUE: NumberOfItems will set to 0.
3824 // FALSE: NumberOfItems no change.
3826 pAdapter->CommonCfg.NdisRadioStateOff = TRUE;
3827 // Set to immediately send the media disconnect event
3828 pAdapter->MlmeAux.CurrReqIsFromNdis = TRUE;
3829 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_DISASSOCIATE \n"));
3831 if (INFRA_ON(pAdapter))
3833 if (pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE)
3835 RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
3836 DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
3839 MlmeEnqueue(pAdapter,
3840 MLME_CNTL_STATE_MACHINE,
3841 OID_802_11_DISASSOCIATE,
3845 StateMachineTouched = TRUE;
3849 #ifdef DOT11_N_SUPPORT
3850 case RT_OID_802_11_SET_IMME_BA_CAP:
3851 if (wrq->u.data.length != sizeof(OID_BACAP_STRUC))
3855 OID_BACAP_STRUC Orde ;
3856 Status = copy_from_user(&Orde, wrq->u.data.pointer, wrq->u.data.length);
3857 if (Orde.Policy > BA_NOTUSE)
3859 Status = NDIS_STATUS_INVALID_DATA;
3861 else if (Orde.Policy == BA_NOTUSE)
3863 pAdapter->CommonCfg.BACapability.field.Policy = BA_NOTUSE;
3864 pAdapter->CommonCfg.BACapability.field.MpduDensity = Orde.MpduDensity;
3865 pAdapter->CommonCfg.DesiredHtPhy.MpduDensity = Orde.MpduDensity;
3866 pAdapter->CommonCfg.DesiredHtPhy.AmsduEnable = Orde.AmsduEnable;
3867 pAdapter->CommonCfg.DesiredHtPhy.AmsduSize= Orde.AmsduSize;
3868 pAdapter->CommonCfg.DesiredHtPhy.MimoPs= Orde.MMPSmode;
3869 pAdapter->CommonCfg.BACapability.field.MMPSmode = Orde.MMPSmode;
3871 pAdapter->CommonCfg.HtCapability.HtCapInfo.MimoPs = Orde.MMPSmode;
3872 pAdapter->CommonCfg.HtCapability.HtCapInfo.AMsduSize = Orde.AmsduSize;
3873 pAdapter->CommonCfg.HtCapability.HtCapParm.MpduDensity = Orde.MpduDensity;
3877 pAdapter->CommonCfg.BACapability.field.AutoBA = Orde.AutoBA;
3878 pAdapter->CommonCfg.BACapability.field.Policy = IMMED_BA; // we only support immediate BA.
3879 pAdapter->CommonCfg.BACapability.field.MpduDensity = Orde.MpduDensity;
3880 pAdapter->CommonCfg.DesiredHtPhy.MpduDensity = Orde.MpduDensity;
3881 pAdapter->CommonCfg.DesiredHtPhy.AmsduEnable = Orde.AmsduEnable;
3882 pAdapter->CommonCfg.DesiredHtPhy.AmsduSize= Orde.AmsduSize;
3883 pAdapter->CommonCfg.DesiredHtPhy.MimoPs = Orde.MMPSmode;
3884 pAdapter->CommonCfg.BACapability.field.MMPSmode = Orde.MMPSmode;
3887 pAdapter->CommonCfg.HtCapability.HtCapInfo.MimoPs = Orde.MMPSmode;
3888 pAdapter->CommonCfg.HtCapability.HtCapInfo.AMsduSize = Orde.AmsduSize;
3889 pAdapter->CommonCfg.HtCapability.HtCapParm.MpduDensity = Orde.MpduDensity;
3891 if (pAdapter->CommonCfg.BACapability.field.RxBAWinLimit > MAX_RX_REORDERBUF)
3892 pAdapter->CommonCfg.BACapability.field.RxBAWinLimit = MAX_RX_REORDERBUF;
3896 pAdapter->CommonCfg.REGBACapability.word = pAdapter->CommonCfg.BACapability.word;
3897 DBGPRINT(RT_DEBUG_TRACE, ("Set::(Orde.AutoBA = %d) (Policy=%d)(ReBAWinLimit=%d)(TxBAWinLimit=%d)(AutoMode=%d)\n",Orde.AutoBA, pAdapter->CommonCfg.BACapability.field.Policy,
3898 pAdapter->CommonCfg.BACapability.field.RxBAWinLimit,pAdapter->CommonCfg.BACapability.field.TxBAWinLimit, pAdapter->CommonCfg.BACapability.field.AutoBA));
3899 DBGPRINT(RT_DEBUG_TRACE, ("Set::(MimoPs = %d)(AmsduEnable = %d) (AmsduSize=%d)(MpduDensity=%d)\n",pAdapter->CommonCfg.DesiredHtPhy.MimoPs, pAdapter->CommonCfg.DesiredHtPhy.AmsduEnable,
3900 pAdapter->CommonCfg.DesiredHtPhy.AmsduSize, pAdapter->CommonCfg.DesiredHtPhy.MpduDensity));
3904 case RT_OID_802_11_ADD_IMME_BA:
3905 DBGPRINT(RT_DEBUG_TRACE, (" Set :: RT_OID_802_11_ADD_IMME_BA \n"));
3906 if (wrq->u.data.length != sizeof(OID_ADD_BA_ENTRY))
3911 OID_ADD_BA_ENTRY BA;
3912 MAC_TABLE_ENTRY *pEntry;
3914 Status = copy_from_user(&BA, wrq->u.data.pointer, wrq->u.data.length);
3917 Status = NDIS_STATUS_INVALID_DATA;
3922 //BATableInsertEntry
3923 //As ad-hoc mode, BA pair is not limited to only BSSID. so add via OID.
3925 // in ad hoc mode, when adding BA pair, we should insert this entry into MACEntry too
3926 pEntry = MacTableLookup(pAdapter, BA.MACAddr);
3929 DBGPRINT(RT_DEBUG_TRACE, ("RT_OID_802_11_ADD_IMME_BA. break on no connection.----:%x:%x\n", BA.MACAddr[4], BA.MACAddr[5]));
3932 if (BA.IsRecipient == FALSE)
3934 if (pEntry->bIAmBadAtheros == TRUE)
3935 pAdapter->CommonCfg.BACapability.field.RxBAWinLimit = 0x10;
3937 BAOriSessionSetUp(pAdapter, pEntry, index, 0, 100, TRUE);
3941 //BATableInsertEntry(pAdapter, pEntry->Aid, BA.MACAddr, 0, 0xffff, BA.TID, BA.nMSDU, BA.IsRecipient);
3944 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_ADD_IMME_BA. Rec = %d. Mac = %x:%x:%x:%x:%x:%x . \n",
3945 BA.IsRecipient, BA.MACAddr[0], BA.MACAddr[1], BA.MACAddr[2], BA.MACAddr[2]
3946 , BA.MACAddr[4], BA.MACAddr[5]));
3951 case RT_OID_802_11_TEAR_IMME_BA:
3952 DBGPRINT(RT_DEBUG_TRACE, ("Set :: RT_OID_802_11_TEAR_IMME_BA \n"));
3953 if (wrq->u.data.length != sizeof(OID_ADD_BA_ENTRY))
3957 POID_ADD_BA_ENTRY pBA;
3958 MAC_TABLE_ENTRY *pEntry;
3960 pBA = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
3964 DBGPRINT(RT_DEBUG_TRACE, ("Set :: RT_OID_802_11_TEAR_IMME_BA kmalloc() can't allocate enough memory\n"));
3965 Status = NDIS_STATUS_FAILURE;
3969 Status = copy_from_user(pBA, wrq->u.data.pointer, wrq->u.data.length);
3970 DBGPRINT(RT_DEBUG_TRACE, ("Set :: RT_OID_802_11_TEAR_IMME_BA(TID=%d, bAllTid=%d)\n", pBA->TID, pBA->bAllTid));
3972 if (!pBA->bAllTid && (pBA->TID > NUM_OF_TID))
3974 Status = NDIS_STATUS_INVALID_DATA;
3978 if (pBA->IsRecipient == FALSE)
3980 pEntry = MacTableLookup(pAdapter, pBA->MACAddr);
3981 DBGPRINT(RT_DEBUG_TRACE, (" pBA->IsRecipient == FALSE\n"));
3984 DBGPRINT(RT_DEBUG_TRACE, (" pBA->pEntry\n"));
3985 BAOriSessionTearDown(pAdapter, pEntry->Aid, pBA->TID, FALSE, TRUE);
3988 DBGPRINT(RT_DEBUG_TRACE, ("Set :: Not found pEntry \n"));
3992 pEntry = MacTableLookup(pAdapter, pBA->MACAddr);
3995 BARecSessionTearDown( pAdapter, (UCHAR)pEntry->Aid, pBA->TID, TRUE);
3998 DBGPRINT(RT_DEBUG_TRACE, ("Set :: Not found pEntry \n"));
4004 #endif // DOT11_N_SUPPORT //
4006 // For WPA_SUPPLICANT to set static wep key
4007 case OID_802_11_ADD_WEP:
4008 pWepKey = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
4013 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_WEP, Failed!!\n"));
4016 Status = copy_from_user(pWepKey, wrq->u.data.pointer, wrq->u.data.length);
4020 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_WEP, Failed (length mismatch)!!\n"));
4024 KeyIdx = pWepKey->KeyIndex & 0x0fffffff;
4025 // KeyIdx must be 0 ~ 3
4029 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_WEP, Failed (KeyIdx must be smaller than 4)!!\n"));
4033 UCHAR CipherAlg = 0;
4036 // set key material and key length
4037 NdisZeroMemory(pAdapter->SharedKey[BSS0][KeyIdx].Key, 16);
4038 pAdapter->SharedKey[BSS0][KeyIdx].KeyLen = (UCHAR) pWepKey->KeyLength;
4039 NdisMoveMemory(pAdapter->SharedKey[BSS0][KeyIdx].Key, &pWepKey->KeyMaterial, pWepKey->KeyLength);
4041 switch(pWepKey->KeyLength)
4044 CipherAlg = CIPHER_WEP64;
4047 CipherAlg = CIPHER_WEP128;
4050 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_WEP, only support CIPHER_WEP64(len:5) & CIPHER_WEP128(len:13)!!\n"));
4054 pAdapter->SharedKey[BSS0][KeyIdx].CipherAlg = CipherAlg;
4056 // Default key for tx (shared key)
4057 if (pWepKey->KeyIndex & 0x80000000)
4059 // set key material and key length
4060 NdisZeroMemory(pAdapter->StaCfg.DesireSharedKey[KeyIdx].Key, 16);
4061 pAdapter->StaCfg.DesireSharedKey[KeyIdx].KeyLen = (UCHAR) pWepKey->KeyLength;
4062 NdisMoveMemory(pAdapter->StaCfg.DesireSharedKey[KeyIdx].Key, &pWepKey->KeyMaterial, pWepKey->KeyLength);
4063 pAdapter->StaCfg.DesireSharedKeyId = KeyIdx;
4064 pAdapter->StaCfg.DesireSharedKey[KeyIdx].CipherAlg = CipherAlg;
4065 pAdapter->StaCfg.DefaultKeyId = (UCHAR) KeyIdx;
4068 if ((pAdapter->StaCfg.WpaSupplicantUP != WPA_SUPPLICANT_DISABLE) &&
4069 (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA))
4071 Key = pWepKey->KeyMaterial;
4073 // Set Group key material to Asic
4074 AsicAddSharedKeyEntry(pAdapter, BSS0, KeyIdx, CipherAlg, Key, NULL, NULL);
4076 // Update WCID attribute table and IVEIV table for this group key table
4077 RTMPAddWcidAttributeEntry(pAdapter, BSS0, KeyIdx, CipherAlg, NULL);
4079 STA_PORT_SECURED(pAdapter);
4081 // Indicate Connected for GUI
4082 pAdapter->IndicateMediaState = NdisMediaStateConnected;
4084 else if (pAdapter->StaCfg.PortSecured == WPA_802_1X_PORT_SECURED)
4086 Key = pAdapter->SharedKey[BSS0][KeyIdx].Key;
4088 // Set key material and cipherAlg to Asic
4089 AsicAddSharedKeyEntry(pAdapter, BSS0, KeyIdx, CipherAlg, Key, NULL, NULL);
4091 if (pWepKey->KeyIndex & 0x80000000)
4093 PMAC_TABLE_ENTRY pEntry = &pAdapter->MacTab.Content[BSSID_WCID];
4094 // Assign group key info
4095 RTMPAddWcidAttributeEntry(pAdapter, BSS0, KeyIdx, CipherAlg, NULL);
4096 // Assign pairwise key info
4097 RTMPAddWcidAttributeEntry(pAdapter, BSS0, KeyIdx, CipherAlg, pEntry);
4100 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"));
4105 case OID_SET_COUNTERMEASURES:
4106 if (wrq->u.data.length != sizeof(int))
4111 Status = copy_from_user(&enabled, wrq->u.data.pointer, wrq->u.data.length);
4113 pAdapter->StaCfg.bBlockAssoc = TRUE;
4115 // WPA MIC error should block association attempt for 60 seconds
4116 pAdapter->StaCfg.bBlockAssoc = FALSE;
4117 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_SET_COUNTERMEASURES bBlockAssoc=%s\n", pAdapter->StaCfg.bBlockAssoc ? "TRUE":"FALSE"));
4120 case RT_OID_WPA_SUPPLICANT_SUPPORT:
4121 if (wrq->u.data.length != sizeof(UCHAR))
4125 Status = copy_from_user(&wpa_supplicant_enable, wrq->u.data.pointer, wrq->u.data.length);
4126 pAdapter->StaCfg.WpaSupplicantUP = wpa_supplicant_enable;
4127 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_WPA_SUPPLICANT_SUPPORT (=%d)\n", pAdapter->StaCfg.WpaSupplicantUP));
4130 case OID_802_11_DEAUTHENTICATION:
4131 if (wrq->u.data.length != sizeof(MLME_DEAUTH_REQ_STRUCT))
4135 MLME_DEAUTH_REQ_STRUCT *pInfo;
4136 MLME_QUEUE_ELEM *MsgElem = (MLME_QUEUE_ELEM *) kmalloc(sizeof(MLME_QUEUE_ELEM), MEM_ALLOC_FLAG);
4138 pInfo = (MLME_DEAUTH_REQ_STRUCT *) MsgElem->Msg;
4139 Status = copy_from_user(pInfo, wrq->u.data.pointer, wrq->u.data.length);
4140 MlmeDeauthReqAction(pAdapter, MsgElem);
4143 if (INFRA_ON(pAdapter))
4145 LinkDown(pAdapter, FALSE);
4146 pAdapter->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
4148 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_DEAUTHENTICATION (Reason=%d)\n", pInfo->Reason));
4151 case OID_802_11_DROP_UNENCRYPTED:
4152 if (wrq->u.data.length != sizeof(int))
4157 Status = copy_from_user(&enabled, wrq->u.data.pointer, wrq->u.data.length);
4159 pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED;
4161 pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
4162 NdisAcquireSpinLock(&pAdapter->MacTabLock);
4163 pAdapter->MacTab.Content[BSSID_WCID].PortSecured = pAdapter->StaCfg.PortSecured;
4164 NdisReleaseSpinLock(&pAdapter->MacTabLock);
4165 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_DROP_UNENCRYPTED (=%d)\n", enabled));
4168 case OID_802_11_SET_IEEE8021X:
4169 if (wrq->u.data.length != sizeof(BOOLEAN))
4173 Status = copy_from_user(&IEEE8021xState, wrq->u.data.pointer, wrq->u.data.length);
4174 pAdapter->StaCfg.IEEE8021X = IEEE8021xState;
4175 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_SET_IEEE8021X (=%d)\n", IEEE8021xState));
4178 case OID_802_11_SET_IEEE8021X_REQUIRE_KEY:
4179 if (wrq->u.data.length != sizeof(BOOLEAN))
4183 Status = copy_from_user(&IEEE8021x_required_keys, wrq->u.data.pointer, wrq->u.data.length);
4184 pAdapter->StaCfg.IEEE8021x_required_keys = IEEE8021x_required_keys;
4185 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_SET_IEEE8021X_REQUIRE_KEY (%d)\n", IEEE8021x_required_keys));
4188 case OID_802_11_PMKID:
4189 pPmkId = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
4191 if(pPmkId == NULL) {
4195 Status = copy_from_user(pPmkId, wrq->u.data.pointer, wrq->u.data.length);
4197 // check the PMKID information
4198 if (pPmkId->BSSIDInfoCount == 0)
4199 NdisZeroMemory(pAdapter->StaCfg.SavedPMK, sizeof(BSSID_INFO)*PMKID_NO);
4202 PBSSID_INFO pBssIdInfo;
4206 for (BssIdx = 0; BssIdx < pPmkId->BSSIDInfoCount; BssIdx++)
4208 // point to the indexed BSSID_INFO structure
4209 pBssIdInfo = (PBSSID_INFO) ((PUCHAR) pPmkId + 2 * sizeof(UINT) + BssIdx * sizeof(BSSID_INFO));
4210 // Find the entry in the saved data base.
4211 for (CachedIdx = 0; CachedIdx < pAdapter->StaCfg.SavedPMKNum; CachedIdx++)
4213 // compare the BSSID
4214 if (NdisEqualMemory(pBssIdInfo->BSSID, pAdapter->StaCfg.SavedPMK[CachedIdx].BSSID, sizeof(NDIS_802_11_MAC_ADDRESS)))
4218 // Found, replace it
4219 if (CachedIdx < PMKID_NO)
4221 DBGPRINT(RT_DEBUG_OFF, ("Update OID_802_11_PMKID, idx = %d\n", CachedIdx));
4222 NdisMoveMemory(&pAdapter->StaCfg.SavedPMK[CachedIdx], pBssIdInfo, sizeof(BSSID_INFO));
4223 pAdapter->StaCfg.SavedPMKNum++;
4225 // Not found, replace the last one
4228 // Randomly replace one
4229 CachedIdx = (pBssIdInfo->BSSID[5] % PMKID_NO);
4230 DBGPRINT(RT_DEBUG_OFF, ("Update OID_802_11_PMKID, idx = %d\n", CachedIdx));
4231 NdisMoveMemory(&pAdapter->StaCfg.SavedPMK[CachedIdx], pBssIdInfo, sizeof(BSSID_INFO));
4239 DBGPRINT(RT_DEBUG_TRACE, ("Set::unknown IOCTL's subcmd = 0x%08x\n", cmd));
4240 Status = -EOPNOTSUPP;
4248 INT RTMPQueryInformation(
4249 IN PRTMP_ADAPTER pAdapter,
4250 IN OUT struct ifreq *rq,
4253 struct iwreq *wrq = (struct iwreq *) rq;
4254 NDIS_802_11_BSSID_LIST_EX *pBssidList = NULL;
4255 PNDIS_WLAN_BSSID_EX pBss;
4256 NDIS_802_11_SSID Ssid;
4257 NDIS_802_11_CONFIGURATION *pConfiguration = NULL;
4258 RT_802_11_LINK_STATUS *pLinkStatus = NULL;
4259 RT_802_11_STA_CONFIG *pStaConfig = NULL;
4260 NDIS_802_11_STATISTICS *pStatistics = NULL;
4261 NDIS_802_11_RTS_THRESHOLD RtsThresh;
4262 NDIS_802_11_FRAGMENTATION_THRESHOLD FragThresh;
4263 NDIS_802_11_POWER_MODE PowerMode;
4264 NDIS_802_11_NETWORK_INFRASTRUCTURE BssType;
4265 RT_802_11_PREAMBLE PreamType;
4266 NDIS_802_11_AUTHENTICATION_MODE AuthMode;
4267 NDIS_802_11_WEP_STATUS WepStatus;
4268 NDIS_MEDIA_STATE MediaState;
4269 ULONG BssBufSize, ulInfo=0, NetworkTypeList[4], apsd = 0;
4271 PUCHAR pBuf = NULL, pPtr;
4272 INT Status = NDIS_STATUS_SUCCESS;
4273 UINT we_version_compiled;
4274 UCHAR i, Padding = 0;
4276 UCHAR driverVersion[8];
4277 OID_SET_HT_PHYMODE *pHTPhyMode = NULL;
4281 case RT_OID_DEVICE_NAME:
4282 wrq->u.data.length = sizeof(STA_NIC_DEVICE_NAME);
4283 Status = copy_to_user(wrq->u.data.pointer, STA_NIC_DEVICE_NAME, wrq->u.data.length);
4285 case RT_OID_VERSION_INFO:
4286 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_VERSION_INFO \n"));
4287 wrq->u.data.length = 8*sizeof(UCHAR);
4288 sprintf(&driverVersion[0], "%s", STA_DRIVER_VERSION);
4289 driverVersion[7] = '\0';
4290 if (copy_to_user(wrq->u.data.pointer, &driverVersion, wrq->u.data.length))
4295 case OID_802_11_BSSID_LIST:
4296 if (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
4299 * Still scanning, indicate the caller should try again.
4301 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_BSSID_LIST (Still scanning)\n"));
4304 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_BSSID_LIST (%d BSS returned)\n",pAdapter->ScanTab.BssNr));
4305 pAdapter->StaCfg.bScanReqIsFromWebUI = FALSE;
4306 // Claculate total buffer size required
4307 BssBufSize = sizeof(ULONG);
4309 for (i = 0; i < pAdapter->ScanTab.BssNr; i++)
4311 // Align pointer to 4 bytes boundary.
4312 //Padding = 4 - (pAdapter->ScanTab.BssEntry[i].VarIELen & 0x0003);
4315 BssBufSize += (sizeof(NDIS_WLAN_BSSID_EX) - 1 + sizeof(NDIS_802_11_FIXED_IEs) + pAdapter->ScanTab.BssEntry[i].VarIELen + Padding);
4318 // For safety issue, we add 256 bytes just in case
4320 // Allocate the same size as passed from higher layer
4321 pBuf = kmalloc(BssBufSize, MEM_ALLOC_FLAG);
4327 // Init 802_11_BSSID_LIST_EX structure
4328 NdisZeroMemory(pBuf, BssBufSize);
4329 pBssidList = (PNDIS_802_11_BSSID_LIST_EX) pBuf;
4330 pBssidList->NumberOfItems = pAdapter->ScanTab.BssNr;
4332 // Calculate total buffer length
4333 BssLen = 4; // Consist of NumberOfItems
4334 // Point to start of NDIS_WLAN_BSSID_EX
4335 // pPtr = pBuf + sizeof(ULONG);
4336 pPtr = (PUCHAR) &pBssidList->Bssid[0];
4337 for (i = 0; i < pAdapter->ScanTab.BssNr; i++)
4339 pBss = (PNDIS_WLAN_BSSID_EX) pPtr;
4340 NdisMoveMemory(&pBss->MacAddress, &pAdapter->ScanTab.BssEntry[i].Bssid, MAC_ADDR_LEN);
4341 if ((pAdapter->ScanTab.BssEntry[i].Hidden == 1) && (pAdapter->StaCfg.bShowHiddenSSID == FALSE))
4344 // We must return this SSID during 4way handshaking, otherwise Aegis will failed to parse WPA infomation
4345 // and then failed to send EAPOl farame.
4347 if ((pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA) && (pAdapter->StaCfg.PortSecured != WPA_802_1X_PORT_SECURED))
4349 pBss->Ssid.SsidLength = pAdapter->ScanTab.BssEntry[i].SsidLen;
4350 NdisMoveMemory(pBss->Ssid.Ssid, pAdapter->ScanTab.BssEntry[i].Ssid, pAdapter->ScanTab.BssEntry[i].SsidLen);
4353 pBss->Ssid.SsidLength = 0;
4357 pBss->Ssid.SsidLength = pAdapter->ScanTab.BssEntry[i].SsidLen;
4358 NdisMoveMemory(pBss->Ssid.Ssid, pAdapter->ScanTab.BssEntry[i].Ssid, pAdapter->ScanTab.BssEntry[i].SsidLen);
4360 pBss->Privacy = pAdapter->ScanTab.BssEntry[i].Privacy;
4361 pBss->Rssi = pAdapter->ScanTab.BssEntry[i].Rssi - pAdapter->BbpRssiToDbmDelta;
4362 pBss->NetworkTypeInUse = NetworkTypeInUseSanity(&pAdapter->ScanTab.BssEntry[i]);
4363 pBss->Configuration.Length = sizeof(NDIS_802_11_CONFIGURATION);
4364 pBss->Configuration.BeaconPeriod = pAdapter->ScanTab.BssEntry[i].BeaconPeriod;
4365 pBss->Configuration.ATIMWindow = pAdapter->ScanTab.BssEntry[i].AtimWin;
4367 MAP_CHANNEL_ID_TO_KHZ(pAdapter->ScanTab.BssEntry[i].Channel, pBss->Configuration.DSConfig);
4369 if (pAdapter->ScanTab.BssEntry[i].BssType == BSS_INFRA)
4370 pBss->InfrastructureMode = Ndis802_11Infrastructure;
4372 pBss->InfrastructureMode = Ndis802_11IBSS;
4374 NdisMoveMemory(pBss->SupportedRates, pAdapter->ScanTab.BssEntry[i].SupRate, pAdapter->ScanTab.BssEntry[i].SupRateLen);
4375 NdisMoveMemory(pBss->SupportedRates + pAdapter->ScanTab.BssEntry[i].SupRateLen,
4376 pAdapter->ScanTab.BssEntry[i].ExtRate,
4377 pAdapter->ScanTab.BssEntry[i].ExtRateLen);
4379 if (pAdapter->ScanTab.BssEntry[i].VarIELen == 0)
4381 pBss->IELength = sizeof(NDIS_802_11_FIXED_IEs);
4382 NdisMoveMemory(pBss->IEs, &pAdapter->ScanTab.BssEntry[i].FixIEs, sizeof(NDIS_802_11_FIXED_IEs));
4383 pPtr = pPtr + sizeof(NDIS_WLAN_BSSID_EX) - 1 + sizeof(NDIS_802_11_FIXED_IEs);
4387 pBss->IELength = (ULONG)(sizeof(NDIS_802_11_FIXED_IEs) + pAdapter->ScanTab.BssEntry[i].VarIELen);
4388 pPtr = pPtr + sizeof(NDIS_WLAN_BSSID_EX) - 1 + sizeof(NDIS_802_11_FIXED_IEs);
4389 NdisMoveMemory(pBss->IEs, &pAdapter->ScanTab.BssEntry[i].FixIEs, sizeof(NDIS_802_11_FIXED_IEs));
4390 NdisMoveMemory(pBss->IEs + sizeof(NDIS_802_11_FIXED_IEs), pAdapter->ScanTab.BssEntry[i].VarIEs, pAdapter->ScanTab.BssEntry[i].VarIELen);
4391 pPtr += pAdapter->ScanTab.BssEntry[i].VarIELen;
4393 pBss->Length = (ULONG)(sizeof(NDIS_WLAN_BSSID_EX) - 1 + sizeof(NDIS_802_11_FIXED_IEs) + pAdapter->ScanTab.BssEntry[i].VarIELen + Padding);
4395 #if WIRELESS_EXT < 17
4396 if ((BssLen + pBss->Length) < wrq->u.data.length)
4397 BssLen += pBss->Length;
4400 pBssidList->NumberOfItems = i;
4404 BssLen += pBss->Length;
4408 #if WIRELESS_EXT < 17
4409 wrq->u.data.length = BssLen;
4411 if (BssLen > wrq->u.data.length)
4417 wrq->u.data.length = BssLen;
4419 Status = copy_to_user(wrq->u.data.pointer, pBssidList, BssLen);
4422 case OID_802_3_CURRENT_ADDRESS:
4423 wrq->u.data.length = MAC_ADDR_LEN;
4424 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CurrentAddress, wrq->u.data.length);
4426 case OID_GEN_MEDIA_CONNECT_STATUS:
4427 if (pAdapter->IndicateMediaState == NdisMediaStateConnected)
4428 MediaState = NdisMediaStateConnected;
4430 MediaState = NdisMediaStateDisconnected;
4432 wrq->u.data.length = sizeof(NDIS_MEDIA_STATE);
4433 Status = copy_to_user(wrq->u.data.pointer, &MediaState, wrq->u.data.length);
4435 case OID_802_11_BSSID:
4436 if (INFRA_ON(pAdapter) || ADHOC_ON(pAdapter))
4438 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.Bssid, sizeof(NDIS_802_11_MAC_ADDRESS));
4443 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_BSSID(=EMPTY)\n"));
4447 case OID_802_11_SSID:
4448 NdisZeroMemory(&Ssid, sizeof(NDIS_802_11_SSID));
4449 NdisZeroMemory(Ssid.Ssid, MAX_LEN_OF_SSID);
4450 Ssid.SsidLength = pAdapter->CommonCfg.SsidLen;
4451 memcpy(Ssid.Ssid, pAdapter->CommonCfg.Ssid, Ssid.SsidLength);
4452 wrq->u.data.length = sizeof(NDIS_802_11_SSID);
4453 Status = copy_to_user(wrq->u.data.pointer, &Ssid, wrq->u.data.length);
4454 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_SSID (Len=%d, ssid=%s)\n", Ssid.SsidLength,Ssid.Ssid));
4456 case RT_OID_802_11_QUERY_LINK_STATUS:
4457 pLinkStatus = (RT_802_11_LINK_STATUS *) kmalloc(sizeof(RT_802_11_LINK_STATUS), MEM_ALLOC_FLAG);
4460 pLinkStatus->CurrTxRate = RateIdTo500Kbps[pAdapter->CommonCfg.TxRate]; // unit : 500 kbps
4461 pLinkStatus->ChannelQuality = pAdapter->Mlme.ChannelQuality;
4462 pLinkStatus->RxByteCount = pAdapter->RalinkCounters.ReceivedByteCount;
4463 pLinkStatus->TxByteCount = pAdapter->RalinkCounters.TransmittedByteCount;
4464 pLinkStatus->CentralChannel = pAdapter->CommonCfg.CentralChannel;
4465 wrq->u.data.length = sizeof(RT_802_11_LINK_STATUS);
4466 Status = copy_to_user(wrq->u.data.pointer, pLinkStatus, wrq->u.data.length);
4468 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_LINK_STATUS\n"));
4472 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_LINK_STATUS(kmalloc failed)\n"));
4476 case OID_802_11_CONFIGURATION:
4477 pConfiguration = (NDIS_802_11_CONFIGURATION *) kmalloc(sizeof(NDIS_802_11_CONFIGURATION), MEM_ALLOC_FLAG);
4480 pConfiguration->Length = sizeof(NDIS_802_11_CONFIGURATION);
4481 pConfiguration->BeaconPeriod = pAdapter->CommonCfg.BeaconPeriod;
4482 pConfiguration->ATIMWindow = pAdapter->StaActive.AtimWin;
4483 MAP_CHANNEL_ID_TO_KHZ(pAdapter->CommonCfg.Channel, pConfiguration->DSConfig);
4484 wrq->u.data.length = sizeof(NDIS_802_11_CONFIGURATION);
4485 Status = copy_to_user(wrq->u.data.pointer, pConfiguration, wrq->u.data.length);
4486 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_CONFIGURATION(BeaconPeriod=%ld,AtimW=%ld,Channel=%d) \n",
4487 pConfiguration->BeaconPeriod, pConfiguration->ATIMWindow, pAdapter->CommonCfg.Channel));
4488 kfree(pConfiguration);
4492 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_CONFIGURATION(kmalloc failed)\n"));
4496 case RT_OID_802_11_SNR_0:
4497 if ((pAdapter->StaCfg.LastSNR0 > 0))
4499 ulInfo = ((0xeb - pAdapter->StaCfg.LastSNR0) * 3) / 16 ;
4500 wrq->u.data.length = sizeof(ulInfo);
4501 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4502 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_SNR_0(0x=%lx)\n", ulInfo));
4507 case RT_OID_802_11_SNR_1:
4508 if ((pAdapter->Antenna.field.RxPath > 1) &&
4509 (pAdapter->StaCfg.LastSNR1 > 0))
4511 ulInfo = ((0xeb - pAdapter->StaCfg.LastSNR1) * 3) / 16 ;
4512 wrq->u.data.length = sizeof(ulInfo);
4513 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4514 DBGPRINT(RT_DEBUG_TRACE,("Query::RT_OID_802_11_SNR_1(0x=%lx)\n",ulInfo));
4518 DBGPRINT(RT_DEBUG_TRACE,("Query::RT_OID_802_11_SNR_1(pAdapter->StaCfg.LastSNR1=%d)\n",pAdapter->StaCfg.LastSNR1));
4520 case OID_802_11_RSSI_TRIGGER:
4521 ulInfo = pAdapter->StaCfg.RssiSample.LastRssi0 - pAdapter->BbpRssiToDbmDelta;
4522 wrq->u.data.length = sizeof(ulInfo);
4523 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4524 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_RSSI_TRIGGER(=%ld)\n", ulInfo));
4526 case OID_802_11_RSSI:
4527 case RT_OID_802_11_RSSI:
4528 ulInfo = pAdapter->StaCfg.RssiSample.LastRssi0;
4529 wrq->u.data.length = sizeof(ulInfo);
4530 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4532 case RT_OID_802_11_RSSI_1:
4533 ulInfo = pAdapter->StaCfg.RssiSample.LastRssi1;
4534 wrq->u.data.length = sizeof(ulInfo);
4535 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4537 case RT_OID_802_11_RSSI_2:
4538 ulInfo = pAdapter->StaCfg.RssiSample.LastRssi2;
4539 wrq->u.data.length = sizeof(ulInfo);
4540 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4542 case OID_802_11_STATISTICS:
4543 pStatistics = (NDIS_802_11_STATISTICS *) kmalloc(sizeof(NDIS_802_11_STATISTICS), MEM_ALLOC_FLAG);
4546 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_STATISTICS \n"));
4547 // add the most up-to-date h/w raw counters into software counters
4548 NICUpdateRawCounters(pAdapter);
4550 // Sanity check for calculation of sucessful count
4551 if (pAdapter->WlanCounters.TransmittedFragmentCount.QuadPart < pAdapter->WlanCounters.RetryCount.QuadPart)
4552 pAdapter->WlanCounters.TransmittedFragmentCount.QuadPart = pAdapter->WlanCounters.RetryCount.QuadPart;
4554 pStatistics->TransmittedFragmentCount.QuadPart = pAdapter->WlanCounters.TransmittedFragmentCount.QuadPart;
4555 pStatistics->MulticastTransmittedFrameCount.QuadPart = pAdapter->WlanCounters.MulticastTransmittedFrameCount.QuadPart;
4556 pStatistics->FailedCount.QuadPart = pAdapter->WlanCounters.FailedCount.QuadPart;
4557 pStatistics->RetryCount.QuadPart = pAdapter->WlanCounters.RetryCount.QuadPart;
4558 pStatistics->MultipleRetryCount.QuadPart = pAdapter->WlanCounters.MultipleRetryCount.QuadPart;
4559 pStatistics->RTSSuccessCount.QuadPart = pAdapter->WlanCounters.RTSSuccessCount.QuadPart;
4560 pStatistics->RTSFailureCount.QuadPart = pAdapter->WlanCounters.RTSFailureCount.QuadPart;
4561 pStatistics->ACKFailureCount.QuadPart = pAdapter->WlanCounters.ACKFailureCount.QuadPart;
4562 pStatistics->FrameDuplicateCount.QuadPart = pAdapter->WlanCounters.FrameDuplicateCount.QuadPart;
4563 pStatistics->ReceivedFragmentCount.QuadPart = pAdapter->WlanCounters.ReceivedFragmentCount.QuadPart;
4564 pStatistics->MulticastReceivedFrameCount.QuadPart = pAdapter->WlanCounters.MulticastReceivedFrameCount.QuadPart;
4566 pStatistics->FCSErrorCount = pAdapter->RalinkCounters.RealFcsErrCount;
4568 pStatistics->FCSErrorCount.QuadPart = pAdapter->WlanCounters.FCSErrorCount.QuadPart;
4569 pStatistics->FrameDuplicateCount.u.LowPart = pAdapter->WlanCounters.FrameDuplicateCount.u.LowPart / 100;
4571 wrq->u.data.length = sizeof(NDIS_802_11_STATISTICS);
4572 Status = copy_to_user(wrq->u.data.pointer, pStatistics, wrq->u.data.length);
4577 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_STATISTICS(kmalloc failed)\n"));
4581 case OID_GEN_RCV_OK:
4582 ulInfo = pAdapter->Counters8023.GoodReceives;
4583 wrq->u.data.length = sizeof(ulInfo);
4584 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4586 case OID_GEN_RCV_NO_BUFFER:
4587 ulInfo = pAdapter->Counters8023.RxNoBuffer;
4588 wrq->u.data.length = sizeof(ulInfo);
4589 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4591 case RT_OID_802_11_PHY_MODE:
4592 ulInfo = (ULONG)pAdapter->CommonCfg.PhyMode;
4593 wrq->u.data.length = sizeof(ulInfo);
4594 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4595 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_PHY_MODE (=%ld)\n", ulInfo));
4597 case RT_OID_802_11_STA_CONFIG:
4598 pStaConfig = (RT_802_11_STA_CONFIG *) kmalloc(sizeof(RT_802_11_STA_CONFIG), MEM_ALLOC_FLAG);
4601 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_STA_CONFIG\n"));
4602 pStaConfig->EnableTxBurst = pAdapter->CommonCfg.bEnableTxBurst;
4603 pStaConfig->EnableTurboRate = 0;
4604 pStaConfig->UseBGProtection = pAdapter->CommonCfg.UseBGProtection;
4605 pStaConfig->UseShortSlotTime = pAdapter->CommonCfg.bUseShortSlotTime;
4606 //pStaConfig->AdhocMode = pAdapter->StaCfg.AdhocMode;
4607 pStaConfig->HwRadioStatus = (pAdapter->StaCfg.bHwRadio == TRUE) ? 1 : 0;
4608 pStaConfig->Rsv1 = 0;
4609 pStaConfig->SystemErrorBitmap = pAdapter->SystemErrorBitmap;
4610 wrq->u.data.length = sizeof(RT_802_11_STA_CONFIG);
4611 Status = copy_to_user(wrq->u.data.pointer, pStaConfig, wrq->u.data.length);
4616 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_STA_CONFIG(kmalloc failed)\n"));
4620 case OID_802_11_RTS_THRESHOLD:
4621 RtsThresh = pAdapter->CommonCfg.RtsThreshold;
4622 wrq->u.data.length = sizeof(RtsThresh);
4623 Status = copy_to_user(wrq->u.data.pointer, &RtsThresh, wrq->u.data.length);
4624 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_RTS_THRESHOLD(=%ld)\n", RtsThresh));
4626 case OID_802_11_FRAGMENTATION_THRESHOLD:
4627 FragThresh = pAdapter->CommonCfg.FragmentThreshold;
4628 if (pAdapter->CommonCfg.bUseZeroToDisableFragment == TRUE)
4630 wrq->u.data.length = sizeof(FragThresh);
4631 Status = copy_to_user(wrq->u.data.pointer, &FragThresh, wrq->u.data.length);
4632 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_FRAGMENTATION_THRESHOLD(=%ld)\n", FragThresh));
4634 case OID_802_11_POWER_MODE:
4635 PowerMode = pAdapter->StaCfg.WindowsPowerMode;
4636 wrq->u.data.length = sizeof(PowerMode);
4637 Status = copy_to_user(wrq->u.data.pointer, &PowerMode, wrq->u.data.length);
4638 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_POWER_MODE(=%d)\n", PowerMode));
4640 case RT_OID_802_11_RADIO:
4641 RadioState = (BOOLEAN) pAdapter->StaCfg.bSwRadio;
4642 wrq->u.data.length = sizeof(RadioState);
4643 Status = copy_to_user(wrq->u.data.pointer, &RadioState, wrq->u.data.length);
4644 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_RADIO (=%d)\n", RadioState));
4646 case OID_802_11_INFRASTRUCTURE_MODE:
4647 if (pAdapter->StaCfg.BssType == BSS_ADHOC)
4648 BssType = Ndis802_11IBSS;
4649 else if (pAdapter->StaCfg.BssType == BSS_INFRA)
4650 BssType = Ndis802_11Infrastructure;
4651 else if (pAdapter->StaCfg.BssType == BSS_MONITOR)
4652 BssType = Ndis802_11Monitor;
4654 BssType = Ndis802_11AutoUnknown;
4656 wrq->u.data.length = sizeof(BssType);
4657 Status = copy_to_user(wrq->u.data.pointer, &BssType, wrq->u.data.length);
4658 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_INFRASTRUCTURE_MODE(=%d)\n", BssType));
4660 case RT_OID_802_11_PREAMBLE:
4661 PreamType = pAdapter->CommonCfg.TxPreamble;
4662 wrq->u.data.length = sizeof(PreamType);
4663 Status = copy_to_user(wrq->u.data.pointer, &PreamType, wrq->u.data.length);
4664 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_PREAMBLE(=%d)\n", PreamType));
4666 case OID_802_11_AUTHENTICATION_MODE:
4667 AuthMode = pAdapter->StaCfg.AuthMode;
4668 wrq->u.data.length = sizeof(AuthMode);
4669 Status = copy_to_user(wrq->u.data.pointer, &AuthMode, wrq->u.data.length);
4670 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_AUTHENTICATION_MODE(=%d)\n", AuthMode));
4672 case OID_802_11_WEP_STATUS:
4673 WepStatus = pAdapter->StaCfg.WepStatus;
4674 wrq->u.data.length = sizeof(WepStatus);
4675 Status = copy_to_user(wrq->u.data.pointer, &WepStatus, wrq->u.data.length);
4676 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_WEP_STATUS(=%d)\n", WepStatus));
4678 case OID_802_11_TX_POWER_LEVEL:
4679 wrq->u.data.length = sizeof(ULONG);
4680 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.TxPower, wrq->u.data.length);
4681 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_TX_POWER_LEVEL %x\n",pAdapter->CommonCfg.TxPower));
4683 case RT_OID_802_11_TX_POWER_LEVEL_1:
4684 wrq->u.data.length = sizeof(ULONG);
4685 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.TxPowerPercentage, wrq->u.data.length);
4686 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_TX_POWER_LEVEL_1 (=%ld)\n", pAdapter->CommonCfg.TxPowerPercentage));
4688 case OID_802_11_NETWORK_TYPES_SUPPORTED:
4689 if ((pAdapter->RfIcType == RFIC_2850) || (pAdapter->RfIcType == RFIC_2750))
4691 NetworkTypeList[0] = 3; // NumberOfItems = 3
4692 NetworkTypeList[1] = Ndis802_11DS; // NetworkType[1] = 11b
4693 NetworkTypeList[2] = Ndis802_11OFDM24; // NetworkType[2] = 11g
4694 NetworkTypeList[3] = Ndis802_11OFDM5; // NetworkType[3] = 11a
4695 wrq->u.data.length = 16;
4696 Status = copy_to_user(wrq->u.data.pointer, &NetworkTypeList[0], wrq->u.data.length);
4700 NetworkTypeList[0] = 2; // NumberOfItems = 2
4701 NetworkTypeList[1] = Ndis802_11DS; // NetworkType[1] = 11b
4702 NetworkTypeList[2] = Ndis802_11OFDM24; // NetworkType[2] = 11g
4703 wrq->u.data.length = 12;
4704 Status = copy_to_user(wrq->u.data.pointer, &NetworkTypeList[0], wrq->u.data.length);
4706 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_NETWORK_TYPES_SUPPORTED\n"));
4708 case OID_802_11_NETWORK_TYPE_IN_USE:
4709 wrq->u.data.length = sizeof(ULONG);
4710 if (pAdapter->CommonCfg.PhyMode == PHY_11A)
4711 ulInfo = Ndis802_11OFDM5;
4712 else if ((pAdapter->CommonCfg.PhyMode == PHY_11BG_MIXED) || (pAdapter->CommonCfg.PhyMode == PHY_11G))
4713 ulInfo = Ndis802_11OFDM24;
4715 ulInfo = Ndis802_11DS;
4716 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4718 case RT_OID_802_11_QUERY_LAST_RX_RATE:
4719 ulInfo = (ULONG)pAdapter->LastRxRate;
4720 wrq->u.data.length = sizeof(ulInfo);
4721 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4722 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_LAST_RX_RATE (=%ld)\n", ulInfo));
4724 case RT_OID_802_11_QUERY_LAST_TX_RATE:
4725 //ulInfo = (ULONG)pAdapter->LastTxRate;
4726 ulInfo = (ULONG)pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.word;
4727 wrq->u.data.length = sizeof(ulInfo);
4728 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4729 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_LAST_TX_RATE (=%lx)\n", ulInfo));
4731 case RT_OID_802_11_QUERY_EEPROM_VERSION:
4732 wrq->u.data.length = sizeof(ULONG);
4733 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->EepromVersion, wrq->u.data.length);
4735 case RT_OID_802_11_QUERY_FIRMWARE_VERSION:
4736 wrq->u.data.length = sizeof(ULONG);
4737 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->FirmwareVersion, wrq->u.data.length);
4739 case RT_OID_802_11_QUERY_NOISE_LEVEL:
4740 wrq->u.data.length = sizeof(UCHAR);
4741 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->BbpWriteLatch[66], wrq->u.data.length);
4742 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_NOISE_LEVEL (=%d)\n", pAdapter->BbpWriteLatch[66]));
4744 case RT_OID_802_11_EXTRA_INFO:
4745 wrq->u.data.length = sizeof(ULONG);
4746 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->ExtraInfo, wrq->u.data.length);
4747 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_EXTRA_INFO (=%ld)\n", pAdapter->ExtraInfo));
4749 case RT_OID_WE_VERSION_COMPILED:
4750 wrq->u.data.length = sizeof(UINT);
4751 we_version_compiled = WIRELESS_EXT;
4752 Status = copy_to_user(wrq->u.data.pointer, &we_version_compiled, wrq->u.data.length);
4754 case RT_OID_802_11_QUERY_APSD_SETTING:
4755 apsd = (pAdapter->CommonCfg.bAPSDCapable | (pAdapter->CommonCfg.bAPSDAC_BE << 1) | (pAdapter->CommonCfg.bAPSDAC_BK << 2)
4756 | (pAdapter->CommonCfg.bAPSDAC_VI << 3) | (pAdapter->CommonCfg.bAPSDAC_VO << 4) | (pAdapter->CommonCfg.MaxSPLength << 5));
4758 wrq->u.data.length = sizeof(ULONG);
4759 Status = copy_to_user(wrq->u.data.pointer, &apsd, wrq->u.data.length);
4760 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",
4761 apsd,pAdapter->CommonCfg.bAPSDCapable,pAdapter->CommonCfg.bAPSDAC_BE,pAdapter->CommonCfg.bAPSDAC_BK,pAdapter->CommonCfg.bAPSDAC_VI,pAdapter->CommonCfg.bAPSDAC_VO,pAdapter->CommonCfg.MaxSPLength));
4763 case RT_OID_802_11_QUERY_APSD_PSM:
4764 wrq->u.data.length = sizeof(ULONG);
4765 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.bAPSDForcePowerSave, wrq->u.data.length);
4766 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_APSD_PSM (=%d)\n", pAdapter->CommonCfg.bAPSDForcePowerSave));
4768 case RT_OID_802_11_QUERY_WMM:
4769 wrq->u.data.length = sizeof(BOOLEAN);
4770 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.bWmmCapable, wrq->u.data.length);
4771 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_WMM (=%d)\n", pAdapter->CommonCfg.bWmmCapable));
4773 case RT_OID_NEW_DRIVER:
4776 wrq->u.data.length = sizeof(UCHAR);
4777 Status = copy_to_user(wrq->u.data.pointer, &enabled, wrq->u.data.length);
4778 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_NEW_DRIVER (=%d)\n", enabled));
4781 case RT_OID_WPA_SUPPLICANT_SUPPORT:
4782 wrq->u.data.length = sizeof(UCHAR);
4783 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->StaCfg.WpaSupplicantUP, wrq->u.data.length);
4784 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_WPA_SUPPLICANT_SUPPORT (=%d)\n", pAdapter->StaCfg.WpaSupplicantUP));
4786 case RT_OID_DRIVER_DEVICE_NAME:
4787 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_DRIVER_DEVICE_NAME \n"));
4788 wrq->u.data.length = 16;
4789 if (copy_to_user(wrq->u.data.pointer, pAdapter->StaCfg.dev_name, wrq->u.data.length))
4794 case RT_OID_802_11_QUERY_HT_PHYMODE:
4795 pHTPhyMode = (OID_SET_HT_PHYMODE *) kmalloc(sizeof(OID_SET_HT_PHYMODE), MEM_ALLOC_FLAG);
4798 pHTPhyMode->PhyMode = pAdapter->CommonCfg.PhyMode;
4799 pHTPhyMode->HtMode = (UCHAR)pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.field.MODE;
4800 pHTPhyMode->BW = (UCHAR)pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.field.BW;
4801 pHTPhyMode->MCS= (UCHAR)pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.field.MCS;
4802 pHTPhyMode->SHORTGI= (UCHAR)pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.field.ShortGI;
4803 pHTPhyMode->STBC= (UCHAR)pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.field.STBC;
4805 pHTPhyMode->ExtOffset = ((pAdapter->CommonCfg.CentralChannel < pAdapter->CommonCfg.Channel) ? (EXTCHA_BELOW) : (EXTCHA_ABOVE));
4806 wrq->u.data.length = sizeof(OID_SET_HT_PHYMODE);
4807 if (copy_to_user(wrq->u.data.pointer, pHTPhyMode, wrq->u.data.length))
4811 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_HT_PHYMODE (PhyMode = %d, MCS =%d, BW = %d, STBC = %d, ExtOffset=%d)\n",
4812 pHTPhyMode->HtMode, pHTPhyMode->MCS, pHTPhyMode->BW, pHTPhyMode->STBC, pHTPhyMode->ExtOffset));
4813 DBGPRINT(RT_DEBUG_TRACE, (" MlmeUpdateTxRates (.word = %x )\n", pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.word));
4817 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_STA_CONFIG(kmalloc failed)\n"));
4821 case RT_OID_802_11_COUNTRY_REGION:
4822 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_COUNTRY_REGION \n"));
4823 wrq->u.data.length = sizeof(ulInfo);
4824 ulInfo = pAdapter->CommonCfg.CountryRegionForABand;
4825 ulInfo = (ulInfo << 8)|(pAdapter->CommonCfg.CountryRegion);
4826 if (copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length))
4831 case RT_OID_802_11_QUERY_DAT_HT_PHYMODE:
4832 pHTPhyMode = (OID_SET_HT_PHYMODE *) kmalloc(sizeof(OID_SET_HT_PHYMODE), MEM_ALLOC_FLAG);
4835 pHTPhyMode->PhyMode = pAdapter->CommonCfg.PhyMode;
4836 pHTPhyMode->HtMode = (UCHAR)pAdapter->CommonCfg.RegTransmitSetting.field.HTMODE;
4837 pHTPhyMode->BW = (UCHAR)pAdapter->CommonCfg.RegTransmitSetting.field.BW;
4838 pHTPhyMode->MCS= (UCHAR)pAdapter->StaCfg.DesiredTransmitSetting.field.MCS;
4839 pHTPhyMode->SHORTGI= (UCHAR)pAdapter->CommonCfg.RegTransmitSetting.field.ShortGI;
4840 pHTPhyMode->STBC= (UCHAR)pAdapter->CommonCfg.RegTransmitSetting.field.STBC;
4842 wrq->u.data.length = sizeof(OID_SET_HT_PHYMODE);
4843 if (copy_to_user(wrq->u.data.pointer, pHTPhyMode, wrq->u.data.length))
4847 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_HT_PHYMODE (PhyMode = %d, MCS =%d, BW = %d, STBC = %d, ExtOffset=%d)\n",
4848 pHTPhyMode->HtMode, pHTPhyMode->MCS, pHTPhyMode->BW, pHTPhyMode->STBC, pHTPhyMode->ExtOffset));
4849 DBGPRINT(RT_DEBUG_TRACE, (" MlmeUpdateTxRates (.word = %x )\n", pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.word));
4853 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_STA_CONFIG(kmalloc failed)\n"));
4857 case RT_OID_QUERY_MULTIPLE_CARD_SUPPORT:
4858 wrq->u.data.length = sizeof(UCHAR);
4860 if (copy_to_user(wrq->u.data.pointer, &i, wrq->u.data.length))
4864 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_QUERY_MULTIPLE_CARD_SUPPORT(=%d) \n", i));
4867 case OID_802_11_BUILD_CHANNEL_EX:
4870 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_BUILD_CHANNEL_EX \n"));
4871 wrq->u.data.length = sizeof(UCHAR);
4872 DBGPRINT(RT_DEBUG_TRACE, ("Doesn't support EXT_BUILD_CHANNEL_LIST.\n"));
4874 Status = copy_to_user(wrq->u.data.pointer, &value, 1);
4875 DBGPRINT(RT_DEBUG_TRACE, ("Status=%d\n", Status));
4879 case OID_802_11_GET_CH_LIST:
4881 PRT_CHANNEL_LIST_INFO pChListBuf;
4883 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_GET_CH_LIST \n"));
4884 if (pAdapter->ChannelListNum == 0)
4886 wrq->u.data.length = 0;
4890 pChListBuf = (RT_CHANNEL_LIST_INFO *) kmalloc(sizeof(RT_CHANNEL_LIST_INFO), MEM_ALLOC_FLAG);
4891 if (pChListBuf == NULL)
4893 wrq->u.data.length = 0;
4897 pChListBuf->ChannelListNum = pAdapter->ChannelListNum;
4898 for (i = 0; i < pChListBuf->ChannelListNum; i++)
4899 pChListBuf->ChannelList[i] = pAdapter->ChannelList[i].Channel;
4901 wrq->u.data.length = sizeof(RT_CHANNEL_LIST_INFO);
4902 Status = copy_to_user(wrq->u.data.pointer, pChListBuf, sizeof(RT_CHANNEL_LIST_INFO));
4903 DBGPRINT(RT_DEBUG_TRACE, ("Status=%d\n", Status));
4910 case OID_802_11_GET_COUNTRY_CODE:
4911 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_GET_COUNTRY_CODE \n"));
4912 wrq->u.data.length = 2;
4913 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.CountryCode, 2);
4914 DBGPRINT(RT_DEBUG_TRACE, ("Status=%d\n", Status));
4917 case OID_802_11_GET_CHANNEL_GEOGRAPHY:
4918 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_GET_CHANNEL_GEOGRAPHY \n"));
4919 wrq->u.data.length = 1;
4920 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.Geography, 1);
4921 DBGPRINT(RT_DEBUG_TRACE, ("Status=%d\n", Status));
4925 DBGPRINT(RT_DEBUG_TRACE, ("Query::unknown IOCTL's subcmd = 0x%08x\n", cmd));
4926 Status = -EOPNOTSUPP;
4932 INT rt28xx_sta_ioctl(
4933 IN struct net_device *net_dev,
4934 IN OUT struct ifreq *rq,
4938 VIRTUAL_ADAPTER *pVirtualAd = NULL;
4939 RTMP_ADAPTER *pAd = NULL;
4940 struct iwreq *wrq = (struct iwreq *) rq;
4941 BOOLEAN StateMachineTouched = FALSE;
4942 INT Status = NDIS_STATUS_SUCCESS;
4945 if (net_dev->priv_flags == INT_MAIN)
4947 pAd = net_dev->ml_priv;
4951 pVirtualAd = net_dev->ml_priv;
4952 pAd = pVirtualAd->RtmpDev->ml_priv;
4954 pObj = (POS_COOKIE) pAd->OS_Cookie;
4958 /* if 1st open fail, pAd will be free;
4959 So the net_dev->ml_priv will be NULL in 2rd open */
4963 //check if the interface is down
4964 if(!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_IN_USE))
4967 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
4972 { // determine this ioctl command is comming from which interface.
4973 pObj->ioctl_if_type = INT_MAIN;
4974 pObj->ioctl_if = MAIN_MBSSID;
4980 DBGPRINT(RT_DEBUG_TRACE, ("IOCTL::SIOCGIFHWADDR\n"));
4981 memcpy(wrq->u.name, pAd->CurrentAddress, ETH_ALEN);
4985 char *name=&wrq->u.name[0];
4986 rt_ioctl_giwname(net_dev, NULL, name, NULL);
4989 case SIOCGIWESSID: //Get ESSID
4991 struct iw_point *essid=&wrq->u.essid;
4992 rt_ioctl_giwessid(net_dev, NULL, essid, essid->pointer);
4995 case SIOCSIWESSID: //Set ESSID
4997 struct iw_point *essid=&wrq->u.essid;
4998 rt_ioctl_siwessid(net_dev, NULL, essid, essid->pointer);
5001 case SIOCSIWNWID: // set network id (the cell)
5002 case SIOCGIWNWID: // get network id
5003 Status = -EOPNOTSUPP;
5005 case SIOCSIWFREQ: //set channel/frequency (Hz)
5007 struct iw_freq *freq=&wrq->u.freq;
5008 rt_ioctl_siwfreq(net_dev, NULL, freq, NULL);
5011 case SIOCGIWFREQ: // get channel/frequency (Hz)
5013 struct iw_freq *freq=&wrq->u.freq;
5014 rt_ioctl_giwfreq(net_dev, NULL, freq, NULL);
5017 case SIOCSIWNICKN: //set node name/nickname
5019 struct iw_point *data=&wrq->u.data;
5020 rt_ioctl_siwnickn(net_dev, NULL, data, NULL);
5023 case SIOCGIWNICKN: //get node name/nickname
5025 struct iw_point *data=&wrq->u.data;
5026 rt_ioctl_giwnickn(net_dev, NULL, data, NULL);
5029 case SIOCGIWRATE: //get default bit rate (bps)
5030 rt_ioctl_giwrate(net_dev, NULL, &wrq->u, NULL);
5032 case SIOCSIWRATE: //set default bit rate (bps)
5033 rt_ioctl_siwrate(net_dev, NULL, &wrq->u, NULL);
5035 case SIOCGIWRTS: // get RTS/CTS threshold (bytes)
5037 struct iw_param *rts=&wrq->u.rts;
5038 rt_ioctl_giwrts(net_dev, NULL, rts, NULL);
5041 case SIOCSIWRTS: //set RTS/CTS threshold (bytes)
5043 struct iw_param *rts=&wrq->u.rts;
5044 rt_ioctl_siwrts(net_dev, NULL, rts, NULL);
5047 case SIOCGIWFRAG: //get fragmentation thr (bytes)
5049 struct iw_param *frag=&wrq->u.frag;
5050 rt_ioctl_giwfrag(net_dev, NULL, frag, NULL);
5053 case SIOCSIWFRAG: //set fragmentation thr (bytes)
5055 struct iw_param *frag=&wrq->u.frag;
5056 rt_ioctl_siwfrag(net_dev, NULL, frag, NULL);
5059 case SIOCGIWENCODE: //get encoding token & mode
5061 struct iw_point *erq=&wrq->u.encoding;
5063 rt_ioctl_giwencode(net_dev, NULL, erq, erq->pointer);
5066 case SIOCSIWENCODE: //set encoding token & mode
5068 struct iw_point *erq=&wrq->u.encoding;
5070 rt_ioctl_siwencode(net_dev, NULL, erq, erq->pointer);
5073 case SIOCGIWAP: //get access point MAC addresses
5075 struct sockaddr *ap_addr=&wrq->u.ap_addr;
5076 rt_ioctl_giwap(net_dev, NULL, ap_addr, ap_addr->sa_data);
5079 case SIOCSIWAP: //set access point MAC addresses
5081 struct sockaddr *ap_addr=&wrq->u.ap_addr;
5082 rt_ioctl_siwap(net_dev, NULL, ap_addr, ap_addr->sa_data);
5085 case SIOCGIWMODE: //get operation mode
5087 __u32 *mode=&wrq->u.mode;
5088 rt_ioctl_giwmode(net_dev, NULL, mode, NULL);
5091 case SIOCSIWMODE: //set operation mode
5093 __u32 *mode=&wrq->u.mode;
5094 rt_ioctl_siwmode(net_dev, NULL, mode, NULL);
5097 case SIOCGIWSENS: //get sensitivity (dBm)
5098 case SIOCSIWSENS: //set sensitivity (dBm)
5099 case SIOCGIWPOWER: //get Power Management settings
5100 case SIOCSIWPOWER: //set Power Management settings
5101 case SIOCGIWTXPOW: //get transmit power (dBm)
5102 case SIOCSIWTXPOW: //set transmit power (dBm)
5103 case SIOCGIWRANGE: //Get range of parameters
5104 case SIOCGIWRETRY: //get retry limits and lifetime
5105 case SIOCSIWRETRY: //set retry limits and lifetime
5106 Status = -EOPNOTSUPP;
5109 subcmd = wrq->u.data.flags;
5110 if( subcmd & OID_GET_SET_TOGGLE)
5111 Status = RTMPSetInformation(pAd, rq, subcmd);
5113 Status = RTMPQueryInformation(pAd, rq, subcmd);
5116 if (wrq->u.data.pointer)
5118 if ( access_ok(VERIFY_WRITE, wrq->u.data.pointer, sizeof(privtab)) != TRUE)
5120 wrq->u.data.length = sizeof(privtab) / sizeof(privtab[0]);
5121 if (copy_to_user(wrq->u.data.pointer, privtab, sizeof(privtab)))
5125 case RTPRIV_IOCTL_SET:
5126 if(access_ok(VERIFY_READ, wrq->u.data.pointer, wrq->u.data.length) != TRUE)
5128 rt_ioctl_setparam(net_dev, NULL, NULL, wrq->u.data.pointer);
5130 case RTPRIV_IOCTL_GSITESURVEY:
5131 RTMPIoctlGetSiteSurvey(pAd, wrq);
5134 case RTPRIV_IOCTL_MAC:
5135 RTMPIoctlMAC(pAd, wrq);
5137 case RTPRIV_IOCTL_E2P:
5138 RTMPIoctlE2PROM(pAd, wrq);
5144 DBGPRINT(RT_DEBUG_ERROR, ("IOCTL::unknown IOCTL's cmd = 0x%08x\n", cmd));
5145 Status = -EOPNOTSUPP;
5149 if(StateMachineTouched) // Upper layer sent a MLME-related operations
5150 RT28XX_MLME_HANDLER(pAd);
5156 ==========================================================================
5160 TRUE if all parameters are OK, FALSE otherwise
5161 ==========================================================================
5164 IN PRTMP_ADAPTER pAdapter,
5167 NDIS_802_11_SSID Ssid, *pSsid=NULL;
5168 BOOLEAN StateMachineTouched = FALSE;
5171 if( strlen(arg) <= MAX_LEN_OF_SSID)
5173 NdisZeroMemory(&Ssid, sizeof(NDIS_802_11_SSID));
5174 if (strlen(arg) != 0)
5176 NdisMoveMemory(Ssid.Ssid, arg, strlen(arg));
5177 Ssid.SsidLength = strlen(arg);
5181 Ssid.SsidLength = 0;
5182 memcpy(Ssid.Ssid, "", 0);
5183 pAdapter->StaCfg.BssType = BSS_INFRA;
5184 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
5185 pAdapter->StaCfg.WepStatus = Ndis802_11EncryptionDisabled;
5189 if (pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE)
5191 RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
5192 DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
5195 pAdapter->MlmeAux.CurrReqIsFromNdis = TRUE;
5196 pAdapter->StaCfg.bScanReqIsFromWebUI = FALSE;
5197 pAdapter->bConfigChanged = TRUE;
5199 MlmeEnqueue(pAdapter,
5200 MLME_CNTL_STATE_MACHINE,
5202 sizeof(NDIS_802_11_SSID),
5205 StateMachineTouched = TRUE;
5206 DBGPRINT(RT_DEBUG_TRACE, ("Set_SSID_Proc::(Len=%d,Ssid=%s)\n", Ssid.SsidLength, Ssid.Ssid));
5211 if (StateMachineTouched) // Upper layer sent a MLME-related operations
5212 RT28XX_MLME_HANDLER(pAdapter);
5219 ==========================================================================
5221 Set WmmCapable Enable or Disable
5223 TRUE if all parameters are OK, FALSE otherwise
5224 ==========================================================================
5226 INT Set_WmmCapable_Proc(
5227 IN PRTMP_ADAPTER pAd,
5230 BOOLEAN bWmmCapable;
5232 bWmmCapable = simple_strtol(arg, 0, 10);
5234 if ((bWmmCapable == 1)
5236 && (pAd->NumberOfPipes >= 5)
5239 pAd->CommonCfg.bWmmCapable = TRUE;
5240 else if (bWmmCapable == 0)
5241 pAd->CommonCfg.bWmmCapable = FALSE;
5243 return FALSE; //Invalid argument
5245 DBGPRINT(RT_DEBUG_TRACE, ("Set_WmmCapable_Proc::(bWmmCapable=%d)\n",
5246 pAd->CommonCfg.bWmmCapable));
5250 #endif // WMM_SUPPORT //
5253 ==========================================================================
5255 Set Network Type(Infrastructure/Adhoc mode)
5257 TRUE if all parameters are OK, FALSE otherwise
5258 ==========================================================================
5260 INT Set_NetworkType_Proc(
5261 IN PRTMP_ADAPTER pAdapter,
5266 if (strcmp(arg, "Adhoc") == 0)
5268 if (pAdapter->StaCfg.BssType != BSS_ADHOC)
5270 // Config has changed
5271 pAdapter->bConfigChanged = TRUE;
5272 if (MONITOR_ON(pAdapter))
5274 RTMP_IO_WRITE32(pAdapter, RX_FILTR_CFG, STANORMAL);
5275 RTMP_IO_READ32(pAdapter, MAC_SYS_CTRL, &Value);
5277 RTMP_IO_WRITE32(pAdapter, MAC_SYS_CTRL, Value);
5278 OPSTATUS_CLEAR_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED);
5279 pAdapter->StaCfg.bAutoReconnect = TRUE;
5280 LinkDown(pAdapter, FALSE);
5282 if (INFRA_ON(pAdapter))
5284 //BOOLEAN Cancelled;
5285 // Set the AutoReconnectSsid to prevent it reconnect to old SSID
5286 // Since calling this indicate user don't want to connect to that SSID anymore.
5287 pAdapter->MlmeAux.AutoReconnectSsidLen= 32;
5288 NdisZeroMemory(pAdapter->MlmeAux.AutoReconnectSsid, pAdapter->MlmeAux.AutoReconnectSsidLen);
5290 LinkDown(pAdapter, FALSE);
5292 DBGPRINT(RT_DEBUG_TRACE, ("NDIS_STATUS_MEDIA_DISCONNECT Event BB!\n"));
5295 pAdapter->StaCfg.BssType = BSS_ADHOC;
5296 pAdapter->net_dev->type = pAdapter->StaCfg.OriDevType;
5297 DBGPRINT(RT_DEBUG_TRACE, ("===>Set_NetworkType_Proc::(AD-HOC)\n"));
5299 else if (strcmp(arg, "Infra") == 0)
5301 if (pAdapter->StaCfg.BssType != BSS_INFRA)
5303 // Config has changed
5304 pAdapter->bConfigChanged = TRUE;
5305 if (MONITOR_ON(pAdapter))
5307 RTMP_IO_WRITE32(pAdapter, RX_FILTR_CFG, STANORMAL);
5308 RTMP_IO_READ32(pAdapter, MAC_SYS_CTRL, &Value);
5310 RTMP_IO_WRITE32(pAdapter, MAC_SYS_CTRL, Value);
5311 OPSTATUS_CLEAR_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED);
5312 pAdapter->StaCfg.bAutoReconnect = TRUE;
5313 LinkDown(pAdapter, FALSE);
5315 if (ADHOC_ON(pAdapter))
5317 // Set the AutoReconnectSsid to prevent it reconnect to old SSID
5318 // Since calling this indicate user don't want to connect to that SSID anymore.
5319 pAdapter->MlmeAux.AutoReconnectSsidLen= 32;
5320 NdisZeroMemory(pAdapter->MlmeAux.AutoReconnectSsid, pAdapter->MlmeAux.AutoReconnectSsidLen);
5322 LinkDown(pAdapter, FALSE);
5325 pAdapter->StaCfg.BssType = BSS_INFRA;
5326 pAdapter->net_dev->type = pAdapter->StaCfg.OriDevType;
5327 DBGPRINT(RT_DEBUG_TRACE, ("===>Set_NetworkType_Proc::(INFRA)\n"));
5329 pAdapter->StaCfg.BssType = BSS_INFRA;
5331 else if (strcmp(arg, "Monitor") == 0)
5334 BCN_TIME_CFG_STRUC csr;
5335 OPSTATUS_CLEAR_FLAG(pAdapter, fOP_STATUS_INFRA_ON);
5336 OPSTATUS_CLEAR_FLAG(pAdapter, fOP_STATUS_ADHOC_ON);
5337 OPSTATUS_SET_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED);
5338 // disable all periodic state machine
5339 pAdapter->StaCfg.bAutoReconnect = FALSE;
5340 // reset all mlme state machine
5341 RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
5342 DBGPRINT(RT_DEBUG_TRACE, ("fOP_STATUS_MEDIA_STATE_CONNECTED \n"));
5343 if (pAdapter->CommonCfg.CentralChannel == 0)
5345 #ifdef DOT11_N_SUPPORT
5346 if (pAdapter->CommonCfg.PhyMode == PHY_11AN_MIXED)
5347 pAdapter->CommonCfg.CentralChannel = 36;
5349 #endif // DOT11_N_SUPPORT //
5350 pAdapter->CommonCfg.CentralChannel = 6;
5352 #ifdef DOT11_N_SUPPORT
5354 N_ChannelCheck(pAdapter);
5355 #endif // DOT11_N_SUPPORT //
5357 #ifdef DOT11_N_SUPPORT
5358 if (pAdapter->CommonCfg.PhyMode >= PHY_11ABGN_MIXED &&
5359 pAdapter->CommonCfg.RegTransmitSetting.field.BW == BW_40 &&
5360 pAdapter->CommonCfg.RegTransmitSetting.field.EXTCHA == EXTCHA_ABOVE)
5362 // 40MHz ,control channel at lower
5363 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, BBP_R4, &bbpValue);
5364 bbpValue &= (~0x18);
5366 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R4, bbpValue);
5367 pAdapter->CommonCfg.BBPCurrentBW = BW_40;
5368 // RX : control channel at lower
5369 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, BBP_R3, &bbpValue);
5370 bbpValue &= (~0x20);
5371 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R3, bbpValue);
5373 RTMP_IO_READ32(pAdapter, TX_BAND_CFG, &Value);
5374 Value &= 0xfffffffe;
5375 RTMP_IO_WRITE32(pAdapter, TX_BAND_CFG, Value);
5376 pAdapter->CommonCfg.CentralChannel = pAdapter->CommonCfg.Channel + 2;
5377 AsicSwitchChannel(pAdapter, pAdapter->CommonCfg.CentralChannel, FALSE);
5378 AsicLockChannel(pAdapter, pAdapter->CommonCfg.CentralChannel);
5379 DBGPRINT(RT_DEBUG_TRACE, ("BW_40 ,control_channel(%d), CentralChannel(%d) \n",
5380 pAdapter->CommonCfg.Channel,
5381 pAdapter->CommonCfg.CentralChannel));
5383 else if (pAdapter->CommonCfg.PhyMode >= PHY_11ABGN_MIXED &&
5384 pAdapter->CommonCfg.RegTransmitSetting.field.BW == BW_40 &&
5385 pAdapter->CommonCfg.RegTransmitSetting.field.EXTCHA == EXTCHA_BELOW)
5387 // 40MHz ,control channel at upper
5388 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, BBP_R4, &bbpValue);
5389 bbpValue &= (~0x18);
5391 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R4, bbpValue);
5392 pAdapter->CommonCfg.BBPCurrentBW = BW_40;
5393 RTMP_IO_READ32(pAdapter, TX_BAND_CFG, &Value);
5395 RTMP_IO_WRITE32(pAdapter, TX_BAND_CFG, Value);
5397 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, BBP_R3, &bbpValue);
5399 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R3, bbpValue);
5400 pAdapter->CommonCfg.CentralChannel = pAdapter->CommonCfg.Channel - 2;
5401 AsicSwitchChannel(pAdapter, pAdapter->CommonCfg.CentralChannel, FALSE);
5402 AsicLockChannel(pAdapter, pAdapter->CommonCfg.CentralChannel);
5403 DBGPRINT(RT_DEBUG_TRACE, ("BW_40 ,control_channel(%d), CentralChannel(%d) \n",
5404 pAdapter->CommonCfg.Channel,
5405 pAdapter->CommonCfg.CentralChannel));
5408 #endif // DOT11_N_SUPPORT //
5411 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, BBP_R4, &bbpValue);
5412 bbpValue &= (~0x18);
5413 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R4, bbpValue);
5414 pAdapter->CommonCfg.BBPCurrentBW = BW_20;
5415 AsicSwitchChannel(pAdapter, pAdapter->CommonCfg.Channel, FALSE);
5416 AsicLockChannel(pAdapter, pAdapter->CommonCfg.Channel);
5417 DBGPRINT(RT_DEBUG_TRACE, ("BW_20, Channel(%d)\n", pAdapter->CommonCfg.Channel));
5419 // Enable Rx with promiscuous reception
5420 RTMP_IO_WRITE32(pAdapter, RX_FILTR_CFG, 0x3);
5421 // ASIC supporsts sniffer function with replacing RSSI with timestamp.
5422 //RTMP_IO_READ32(pAdapter, MAC_SYS_CTRL, &Value);
5424 //RTMP_IO_WRITE32(pAdapter, MAC_SYS_CTRL, Value);
5426 RTMP_IO_READ32(pAdapter, BCN_TIME_CFG, &csr.word);
5427 csr.field.bBeaconGen = 0;
5428 csr.field.bTBTTEnable = 0;
5429 csr.field.TsfSyncMode = 0;
5430 RTMP_IO_WRITE32(pAdapter, BCN_TIME_CFG, csr.word);
5432 pAdapter->StaCfg.BssType = BSS_MONITOR;
5433 pAdapter->net_dev->type = ARPHRD_IEEE80211_PRISM; //ARPHRD_IEEE80211; // IEEE80211
5434 DBGPRINT(RT_DEBUG_TRACE, ("===>Set_NetworkType_Proc::(MONITOR)\n"));
5437 // Reset Ralink supplicant to not use, it will be set to start when UI set PMK key
5438 pAdapter->StaCfg.WpaState = SS_NOTUSE;
5440 DBGPRINT(RT_DEBUG_TRACE, ("Set_NetworkType_Proc::(NetworkType=%d)\n", pAdapter->StaCfg.BssType));
5446 ==========================================================================
5448 Set Authentication mode
5450 TRUE if all parameters are OK, FALSE otherwise
5451 ==========================================================================
5453 INT Set_AuthMode_Proc(
5454 IN PRTMP_ADAPTER pAdapter,
5457 if ((strcmp(arg, "WEPAUTO") == 0) || (strcmp(arg, "wepauto") == 0))
5458 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeAutoSwitch;
5459 else if ((strcmp(arg, "OPEN") == 0) || (strcmp(arg, "open") == 0))
5460 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
5461 else if ((strcmp(arg, "SHARED") == 0) || (strcmp(arg, "shared") == 0))
5462 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeShared;
5463 else if ((strcmp(arg, "WPAPSK") == 0) || (strcmp(arg, "wpapsk") == 0))
5464 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPAPSK;
5465 else if ((strcmp(arg, "WPANONE") == 0) || (strcmp(arg, "wpanone") == 0))
5466 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPANone;
5467 else if ((strcmp(arg, "WPA2PSK") == 0) || (strcmp(arg, "wpa2psk") == 0))
5468 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA2PSK;
5469 else if ((strcmp(arg, "WPA") == 0) || (strcmp(arg, "wpa") == 0))
5470 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA;
5471 else if ((strcmp(arg, "WPA2") == 0) || (strcmp(arg, "wpa2") == 0))
5472 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA2;
5476 pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED;
5478 DBGPRINT(RT_DEBUG_TRACE, ("Set_AuthMode_Proc::(AuthMode=%d)\n", pAdapter->StaCfg.AuthMode));
5484 ==========================================================================
5488 TRUE if all parameters are OK, FALSE otherwise
5489 ==========================================================================
5491 INT Set_EncrypType_Proc(
5492 IN PRTMP_ADAPTER pAdapter,
5495 if ((strcmp(arg, "NONE") == 0) || (strcmp(arg, "none") == 0))
5497 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
5498 return TRUE; // do nothing
5500 pAdapter->StaCfg.WepStatus = Ndis802_11WEPDisabled;
5501 pAdapter->StaCfg.PairCipher = Ndis802_11WEPDisabled;
5502 pAdapter->StaCfg.GroupCipher = Ndis802_11WEPDisabled;
5504 else if ((strcmp(arg, "WEP") == 0) || (strcmp(arg, "wep") == 0))
5506 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
5507 return TRUE; // do nothing
5509 pAdapter->StaCfg.WepStatus = Ndis802_11WEPEnabled;
5510 pAdapter->StaCfg.PairCipher = Ndis802_11WEPEnabled;
5511 pAdapter->StaCfg.GroupCipher = Ndis802_11WEPEnabled;
5513 else if ((strcmp(arg, "TKIP") == 0) || (strcmp(arg, "tkip") == 0))
5515 if (pAdapter->StaCfg.AuthMode < Ndis802_11AuthModeWPA)
5516 return TRUE; // do nothing
5518 pAdapter->StaCfg.WepStatus = Ndis802_11Encryption2Enabled;
5519 pAdapter->StaCfg.PairCipher = Ndis802_11Encryption2Enabled;
5520 pAdapter->StaCfg.GroupCipher = Ndis802_11Encryption2Enabled;
5522 else if ((strcmp(arg, "AES") == 0) || (strcmp(arg, "aes") == 0))
5524 if (pAdapter->StaCfg.AuthMode < Ndis802_11AuthModeWPA)
5525 return TRUE; // do nothing
5527 pAdapter->StaCfg.WepStatus = Ndis802_11Encryption3Enabled;
5528 pAdapter->StaCfg.PairCipher = Ndis802_11Encryption3Enabled;
5529 pAdapter->StaCfg.GroupCipher = Ndis802_11Encryption3Enabled;
5534 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
5536 DBGPRINT(RT_DEBUG_TRACE, ("Set_EncrypType_Proc::(EncrypType=%d)\n", pAdapter->StaCfg.WepStatus));
5542 ==========================================================================
5546 TRUE if all parameters are OK, FALSE otherwise
5547 ==========================================================================
5549 INT Set_DefaultKeyID_Proc(
5550 IN PRTMP_ADAPTER pAdapter,
5555 KeyIdx = simple_strtol(arg, 0, 10);
5556 if((KeyIdx >= 1 ) && (KeyIdx <= 4))
5557 pAdapter->StaCfg.DefaultKeyId = (UCHAR) (KeyIdx - 1 );
5559 return FALSE; //Invalid argument
5561 DBGPRINT(RT_DEBUG_TRACE, ("Set_DefaultKeyID_Proc::(DefaultKeyID=%d)\n", pAdapter->StaCfg.DefaultKeyId));
5567 ==========================================================================
5571 TRUE if all parameters are OK, FALSE otherwise
5572 ==========================================================================
5575 IN PRTMP_ADAPTER pAdapter,
5580 UCHAR CipherAlg=CIPHER_WEP64;
5582 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
5583 return TRUE; // do nothing
5585 KeyLen = strlen(arg);
5589 case 5: //wep 40 Ascii type
5590 pAdapter->SharedKey[BSS0][0].KeyLen = KeyLen;
5591 memcpy(pAdapter->SharedKey[BSS0][0].Key, arg, KeyLen);
5592 CipherAlg = CIPHER_WEP64;
5593 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key1_Proc::(Key1=%s and type=%s)\n", arg, "Ascii"));
5595 case 10: //wep 40 Hex type
5596 for(i=0; i < KeyLen; i++)
5598 if( !isxdigit(*(arg+i)) )
5599 return FALSE; //Not Hex value;
5601 pAdapter->SharedKey[BSS0][0].KeyLen = KeyLen / 2 ;
5602 AtoH(arg, pAdapter->SharedKey[BSS0][0].Key, KeyLen / 2);
5603 CipherAlg = CIPHER_WEP64;
5604 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key1_Proc::(Key1=%s and type=%s)\n", arg, "Hex"));
5606 case 13: //wep 104 Ascii type
5607 pAdapter->SharedKey[BSS0][0].KeyLen = KeyLen;
5608 memcpy(pAdapter->SharedKey[BSS0][0].Key, arg, KeyLen);
5609 CipherAlg = CIPHER_WEP128;
5610 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key1_Proc::(Key1=%s and type=%s)\n", arg, "Ascii"));
5612 case 26: //wep 104 Hex type
5613 for(i=0; i < KeyLen; i++)
5615 if( !isxdigit(*(arg+i)) )
5616 return FALSE; //Not Hex value;
5618 pAdapter->SharedKey[BSS0][0].KeyLen = KeyLen / 2 ;
5619 AtoH(arg, pAdapter->SharedKey[BSS0][0].Key, KeyLen / 2);
5620 CipherAlg = CIPHER_WEP128;
5621 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key1_Proc::(Key1=%s and type=%s)\n", arg, "Hex"));
5623 default: //Invalid argument
5624 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key1_Proc::Invalid argument (=%s)\n", arg));
5628 pAdapter->SharedKey[BSS0][0].CipherAlg = CipherAlg;
5630 // Set keys (into ASIC)
5631 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
5633 else // Old WEP stuff
5635 AsicAddSharedKeyEntry(pAdapter,
5638 pAdapter->SharedKey[BSS0][0].CipherAlg,
5639 pAdapter->SharedKey[BSS0][0].Key,
5647 ==========================================================================
5652 TRUE if all parameters are OK, FALSE otherwise
5653 ==========================================================================
5656 IN PRTMP_ADAPTER pAdapter,
5661 UCHAR CipherAlg=CIPHER_WEP64;
5663 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
5664 return TRUE; // do nothing
5666 KeyLen = strlen(arg);
5670 case 5: //wep 40 Ascii type
5671 pAdapter->SharedKey[BSS0][1].KeyLen = KeyLen;
5672 memcpy(pAdapter->SharedKey[BSS0][1].Key, arg, KeyLen);
5673 CipherAlg = CIPHER_WEP64;
5674 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key2_Proc::(Key2=%s and type=%s)\n", arg, "Ascii"));
5676 case 10: //wep 40 Hex type
5677 for(i=0; i < KeyLen; i++)
5679 if( !isxdigit(*(arg+i)) )
5680 return FALSE; //Not Hex value;
5682 pAdapter->SharedKey[BSS0][1].KeyLen = KeyLen / 2 ;
5683 AtoH(arg, pAdapter->SharedKey[BSS0][1].Key, KeyLen / 2);
5684 CipherAlg = CIPHER_WEP64;
5685 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key2_Proc::(Key2=%s and type=%s)\n", arg, "Hex"));
5687 case 13: //wep 104 Ascii type
5688 pAdapter->SharedKey[BSS0][1].KeyLen = KeyLen;
5689 memcpy(pAdapter->SharedKey[BSS0][1].Key, arg, KeyLen);
5690 CipherAlg = CIPHER_WEP128;
5691 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key2_Proc::(Key2=%s and type=%s)\n", arg, "Ascii"));
5693 case 26: //wep 104 Hex type
5694 for(i=0; i < KeyLen; i++)
5696 if( !isxdigit(*(arg+i)) )
5697 return FALSE; //Not Hex value;
5699 pAdapter->SharedKey[BSS0][1].KeyLen = KeyLen / 2 ;
5700 AtoH(arg, pAdapter->SharedKey[BSS0][1].Key, KeyLen / 2);
5701 CipherAlg = CIPHER_WEP128;
5702 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key2_Proc::(Key2=%s and type=%s)\n", arg, "Hex"));
5704 default: //Invalid argument
5705 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key2_Proc::Invalid argument (=%s)\n", arg));
5708 pAdapter->SharedKey[BSS0][1].CipherAlg = CipherAlg;
5710 // Set keys (into ASIC)
5711 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
5713 else // Old WEP stuff
5715 AsicAddSharedKeyEntry(pAdapter,
5718 pAdapter->SharedKey[BSS0][1].CipherAlg,
5719 pAdapter->SharedKey[BSS0][1].Key,
5727 ==========================================================================
5731 TRUE if all parameters are OK, FALSE otherwise
5732 ==========================================================================
5735 IN PRTMP_ADAPTER pAdapter,
5740 UCHAR CipherAlg=CIPHER_WEP64;
5742 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
5743 return TRUE; // do nothing
5745 KeyLen = strlen(arg);
5749 case 5: //wep 40 Ascii type
5750 pAdapter->SharedKey[BSS0][2].KeyLen = KeyLen;
5751 memcpy(pAdapter->SharedKey[BSS0][2].Key, arg, KeyLen);
5752 CipherAlg = CIPHER_WEP64;
5753 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key3_Proc::(Key3=%s and type=Ascii)\n", arg));
5755 case 10: //wep 40 Hex type
5756 for(i=0; i < KeyLen; i++)
5758 if( !isxdigit(*(arg+i)) )
5759 return FALSE; //Not Hex value;
5761 pAdapter->SharedKey[BSS0][2].KeyLen = KeyLen / 2 ;
5762 AtoH(arg, pAdapter->SharedKey[BSS0][2].Key, KeyLen / 2);
5763 CipherAlg = CIPHER_WEP64;
5764 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key3_Proc::(Key3=%s and type=Hex)\n", arg));
5766 case 13: //wep 104 Ascii type
5767 pAdapter->SharedKey[BSS0][2].KeyLen = KeyLen;
5768 memcpy(pAdapter->SharedKey[BSS0][2].Key, arg, KeyLen);
5769 CipherAlg = CIPHER_WEP128;
5770 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key3_Proc::(Key3=%s and type=Ascii)\n", arg));
5772 case 26: //wep 104 Hex type
5773 for(i=0; i < KeyLen; i++)
5775 if( !isxdigit(*(arg+i)) )
5776 return FALSE; //Not Hex value;
5778 pAdapter->SharedKey[BSS0][2].KeyLen = KeyLen / 2 ;
5779 AtoH(arg, pAdapter->SharedKey[BSS0][2].Key, KeyLen / 2);
5780 CipherAlg = CIPHER_WEP128;
5781 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key3_Proc::(Key3=%s and type=Hex)\n", arg));
5783 default: //Invalid argument
5784 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key3_Proc::Invalid argument (=%s)\n", arg));
5787 pAdapter->SharedKey[BSS0][2].CipherAlg = CipherAlg;
5789 // Set keys (into ASIC)
5790 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
5792 else // Old WEP stuff
5794 AsicAddSharedKeyEntry(pAdapter,
5797 pAdapter->SharedKey[BSS0][2].CipherAlg,
5798 pAdapter->SharedKey[BSS0][2].Key,
5806 ==========================================================================
5810 TRUE if all parameters are OK, FALSE otherwise
5811 ==========================================================================
5814 IN PRTMP_ADAPTER pAdapter,
5819 UCHAR CipherAlg=CIPHER_WEP64;
5821 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
5822 return TRUE; // do nothing
5824 KeyLen = strlen(arg);
5828 case 5: //wep 40 Ascii type
5829 pAdapter->SharedKey[BSS0][3].KeyLen = KeyLen;
5830 memcpy(pAdapter->SharedKey[BSS0][3].Key, arg, KeyLen);
5831 CipherAlg = CIPHER_WEP64;
5832 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key4_Proc::(Key4=%s and type=%s)\n", arg, "Ascii"));
5834 case 10: //wep 40 Hex type
5835 for(i=0; i < KeyLen; i++)
5837 if( !isxdigit(*(arg+i)) )
5838 return FALSE; //Not Hex value;
5840 pAdapter->SharedKey[BSS0][3].KeyLen = KeyLen / 2 ;
5841 AtoH(arg, pAdapter->SharedKey[BSS0][3].Key, KeyLen / 2);
5842 CipherAlg = CIPHER_WEP64;
5843 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key4_Proc::(Key4=%s and type=%s)\n", arg, "Hex"));
5845 case 13: //wep 104 Ascii type
5846 pAdapter->SharedKey[BSS0][3].KeyLen = KeyLen;
5847 memcpy(pAdapter->SharedKey[BSS0][3].Key, arg, KeyLen);
5848 CipherAlg = CIPHER_WEP128;
5849 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key4_Proc::(Key4=%s and type=%s)\n", arg, "Ascii"));
5851 case 26: //wep 104 Hex type
5852 for(i=0; i < KeyLen; i++)
5854 if( !isxdigit(*(arg+i)) )
5855 return FALSE; //Not Hex value;
5857 pAdapter->SharedKey[BSS0][3].KeyLen = KeyLen / 2 ;
5858 AtoH(arg, pAdapter->SharedKey[BSS0][3].Key, KeyLen / 2);
5859 CipherAlg = CIPHER_WEP128;
5860 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key4_Proc::(Key4=%s and type=%s)\n", arg, "Hex"));
5862 default: //Invalid argument
5863 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key4_Proc::Invalid argument (=%s)\n", arg));
5866 pAdapter->SharedKey[BSS0][3].CipherAlg = CipherAlg;
5868 // Set keys (into ASIC)
5869 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
5871 else // Old WEP stuff
5873 AsicAddSharedKeyEntry(pAdapter,
5876 pAdapter->SharedKey[BSS0][3].CipherAlg,
5877 pAdapter->SharedKey[BSS0][3].Key,
5886 ==========================================================================
5890 TRUE if all parameters are OK, FALSE otherwise
5891 ==========================================================================
5893 INT Set_WPAPSK_Proc(
5894 IN PRTMP_ADAPTER pAdapter,
5897 UCHAR keyMaterial[40];
5899 if ((pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPAPSK) &&
5900 (pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPA2PSK) &&
5901 (pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPANone)
5903 return TRUE; // do nothing
5905 DBGPRINT(RT_DEBUG_TRACE, ("Set_WPAPSK_Proc::(WPAPSK=%s)\n", arg));
5907 NdisZeroMemory(keyMaterial, 40);
5909 if ((strlen(arg) < 8) || (strlen(arg) > 64))
5911 DBGPRINT(RT_DEBUG_TRACE, ("Set failed!!(WPAPSK=%s), WPAPSK key-string required 8 ~ 64 characters \n", arg));
5915 if (strlen(arg) == 64)
5917 AtoH(arg, keyMaterial, 32);
5918 NdisMoveMemory(pAdapter->StaCfg.PMK, keyMaterial, 32);
5923 PasswordHash((char *)arg, pAdapter->MlmeAux.Ssid, pAdapter->MlmeAux.SsidLen, keyMaterial);
5924 NdisMoveMemory(pAdapter->StaCfg.PMK, keyMaterial, 32);
5929 if(pAdapter->StaCfg.BssType == BSS_ADHOC &&
5930 pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPANone)
5932 pAdapter->StaCfg.WpaState = SS_NOTUSE;
5936 // Start STA supplicant state machine
5937 pAdapter->StaCfg.WpaState = SS_START;
5944 ==========================================================================
5946 Set Power Saving mode
5948 TRUE if all parameters are OK, FALSE otherwise
5949 ==========================================================================
5951 INT Set_PSMode_Proc(
5952 IN PRTMP_ADAPTER pAdapter,
5955 if (pAdapter->StaCfg.BssType == BSS_INFRA)
5957 if ((strcmp(arg, "Max_PSP") == 0) ||
5958 (strcmp(arg, "max_psp") == 0) ||
5959 (strcmp(arg, "MAX_PSP") == 0))
5961 // do NOT turn on PSM bit here, wait until MlmeCheckForPsmChange()
5962 // to exclude certain situations.
5963 if (pAdapter->StaCfg.bWindowsACCAMEnable == FALSE)
5964 pAdapter->StaCfg.WindowsPowerMode = Ndis802_11PowerModeMAX_PSP;
5965 pAdapter->StaCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeMAX_PSP;
5966 OPSTATUS_SET_FLAG(pAdapter, fOP_STATUS_RECEIVE_DTIM);
5967 pAdapter->StaCfg.DefaultListenCount = 5;
5970 else if ((strcmp(arg, "Fast_PSP") == 0) ||
5971 (strcmp(arg, "fast_psp") == 0) ||
5972 (strcmp(arg, "FAST_PSP") == 0))
5974 // do NOT turn on PSM bit here, wait until MlmeCheckForPsmChange()
5975 // to exclude certain situations.
5976 OPSTATUS_SET_FLAG(pAdapter, fOP_STATUS_RECEIVE_DTIM);
5977 if (pAdapter->StaCfg.bWindowsACCAMEnable == FALSE)
5978 pAdapter->StaCfg.WindowsPowerMode = Ndis802_11PowerModeFast_PSP;
5979 pAdapter->StaCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeFast_PSP;
5980 pAdapter->StaCfg.DefaultListenCount = 3;
5982 else if ((strcmp(arg, "Legacy_PSP") == 0) ||
5983 (strcmp(arg, "legacy_psp") == 0) ||
5984 (strcmp(arg, "LEGACY_PSP") == 0))
5986 // do NOT turn on PSM bit here, wait until MlmeCheckForPsmChange()
5987 // to exclude certain situations.
5988 OPSTATUS_SET_FLAG(pAdapter, fOP_STATUS_RECEIVE_DTIM);
5989 if (pAdapter->StaCfg.bWindowsACCAMEnable == FALSE)
5990 pAdapter->StaCfg.WindowsPowerMode = Ndis802_11PowerModeLegacy_PSP;
5991 pAdapter->StaCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeLegacy_PSP;
5992 pAdapter->StaCfg.DefaultListenCount = 3;
5996 //Default Ndis802_11PowerModeCAM
5997 // clear PSM bit immediately
5998 MlmeSetPsmBit(pAdapter, PWR_ACTIVE);
5999 OPSTATUS_SET_FLAG(pAdapter, fOP_STATUS_RECEIVE_DTIM);
6000 if (pAdapter->StaCfg.bWindowsACCAMEnable == FALSE)
6001 pAdapter->StaCfg.WindowsPowerMode = Ndis802_11PowerModeCAM;
6002 pAdapter->StaCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeCAM;
6005 DBGPRINT(RT_DEBUG_TRACE, ("Set_PSMode_Proc::(PSMode=%ld)\n", pAdapter->StaCfg.WindowsPowerMode));
6015 ==========================================================================
6017 Set WpaSupport flag.
6019 0: Driver ignore wpa_supplicant.
6020 1: wpa_supplicant initiates scanning and AP selection.
6021 2: driver takes care of scanning, AP selection, and IEEE 802.11 association parameters.
6023 TRUE if all parameters are OK, FALSE otherwise
6024 ==========================================================================
6026 INT Set_Wpa_Support(
6027 IN PRTMP_ADAPTER pAd,
6031 if ( simple_strtol(arg, 0, 10) == 0)
6032 pAd->StaCfg.WpaSupplicantUP = WPA_SUPPLICANT_DISABLE;
6033 else if ( simple_strtol(arg, 0, 10) == 1)
6034 pAd->StaCfg.WpaSupplicantUP = WPA_SUPPLICANT_ENABLE;
6035 else if ( simple_strtol(arg, 0, 10) == 2)
6036 pAd->StaCfg.WpaSupplicantUP = WPA_SUPPLICANT_ENABLE_WITH_WEB_UI;
6038 pAd->StaCfg.WpaSupplicantUP = WPA_SUPPLICANT_DISABLE;
6040 DBGPRINT(RT_DEBUG_TRACE, ("Set_Wpa_Support::(WpaSupplicantUP=%d)\n", pAd->StaCfg.WpaSupplicantUP));
6047 ==========================================================================
6051 pAdapter Pointer to our adapter
6052 wrq Pointer to the ioctl argument
6059 1.) iwpriv ra0 mac 0 ==> read MAC where Addr=0x0
6060 2.) iwpriv ra0 mac 0=12 ==> write MAC where Addr=0x0, value=12
6061 ==========================================================================
6064 IN PRTMP_ADAPTER pAdapter,
6065 IN struct iwreq *wrq)
6073 UCHAR temp[16], temp2[16];
6074 UINT32 macValue = 0;
6078 memset(msg, 0x00, 1024);
6079 if (wrq->u.data.length > 1) //No parameters.
6081 Status = copy_from_user(arg, wrq->u.data.pointer, (wrq->u.data.length > 255) ? 255 : wrq->u.data.length);
6084 //Parsing Read or Write
6089 if ((value = rtstrchr(this_char, '=')) != NULL)
6092 if (!value || !*value)
6095 if(strlen(this_char) > 4)
6098 j = strlen(this_char);
6101 if(this_char[j] > 'f' || this_char[j] < '0')
6106 k = j = strlen(this_char);
6109 this_char[4-k+j] = this_char[j];
6113 this_char[3-k++]='0';
6116 if(strlen(this_char) == 4)
6118 AtoH(this_char, temp, 2);
6119 macAddr = *temp*256 + temp[1];
6120 if (macAddr < 0xFFFF)
6122 RTMP_IO_READ32(pAdapter, macAddr, &macValue);
6123 DBGPRINT(RT_DEBUG_TRACE, ("MacAddr=%lx, MacValue=%x\n", macAddr, macValue));
6124 sprintf(msg+strlen(msg), "[0x%08lX]:%08X ", macAddr , macValue);
6127 {//Invalid parametes, so default printk all bbp
6134 memcpy(&temp2, value, strlen(value));
6135 temp2[strlen(value)] = '\0';
6138 if((strlen(this_char) > 4) || strlen(temp2) > 8)
6141 j = strlen(this_char);
6144 if(this_char[j] > 'f' || this_char[j] < '0')
6151 if(temp2[j] > 'f' || temp2[j] < '0')
6156 k = j = strlen(this_char);
6159 this_char[4-k+j] = this_char[j];
6163 this_char[3-k++]='0';
6167 k = j = strlen(temp2);
6170 temp2[8-k+j] = temp2[j];
6178 AtoH(this_char, temp, 2);
6179 macAddr = *temp*256 + temp[1];
6181 AtoH(temp2, temp, 4);
6182 macValue = *temp*256*256*256 + temp[1]*256*256 + temp[2]*256 + temp[3];
6185 if (macAddr == (HW_DEBUG_SETTING_BASE + 4))
6187 // 0x2bf4: byte0 non-zero: enable R17 tuning, 0: disable R17 tuning
6188 if (macValue & 0x000000ff)
6190 pAdapter->BbpTuning.bEnable = TRUE;
6191 DBGPRINT(RT_DEBUG_TRACE,("turn on R17 tuning\n"));
6196 pAdapter->BbpTuning.bEnable = FALSE;
6197 R66 = 0x26 + GET_LNA_GAIN(pAdapter);
6198 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R66, (0x26 + GET_LNA_GAIN(pAdapter)));
6199 DBGPRINT(RT_DEBUG_TRACE,("turn off R17 tuning, restore to 0x%02x\n", R66));
6204 DBGPRINT(RT_DEBUG_TRACE, ("MacAddr=%02lx, MacValue=0x%x\n", macAddr, macValue));
6206 RTMP_IO_WRITE32(pAdapter, macAddr, macValue);
6207 sprintf(msg+strlen(msg), "[0x%08lX]:%08X ", macAddr, macValue);
6212 if(strlen(msg) == 1)
6213 sprintf(msg+strlen(msg), "===>Error command format!");
6215 // Copy the information into the user buffer
6216 wrq->u.data.length = strlen(msg);
6217 Status = copy_to_user(wrq->u.data.pointer, msg, wrq->u.data.length);
6219 DBGPRINT(RT_DEBUG_TRACE, ("<==RTMPIoctlMAC\n\n"));
6223 ==========================================================================
6227 pAdapter Pointer to our adapter
6228 wrq Pointer to the ioctl argument
6235 1.) iwpriv ra0 e2p 0 ==> read E2PROM where Addr=0x0
6236 2.) iwpriv ra0 e2p 0=1234 ==> write E2PROM where Addr=0x0, value=1234
6237 ==========================================================================
6239 VOID RTMPIoctlE2PROM(
6240 IN PRTMP_ADAPTER pAdapter,
6241 IN struct iwreq *wrq)
6249 UCHAR temp[16], temp2[16];
6254 memset(msg, 0x00, 1024);
6255 if (wrq->u.data.length > 1) //No parameters.
6257 Status = copy_from_user(arg, wrq->u.data.pointer, (wrq->u.data.length > 255) ? 255 : wrq->u.data.length);
6260 //Parsing Read or Write
6267 if ((value = rtstrchr(this_char, '=')) != NULL)
6270 if (!value || !*value)
6274 if(strlen(this_char) > 4)
6277 j = strlen(this_char);
6280 if(this_char[j] > 'f' || this_char[j] < '0')
6285 k = j = strlen(this_char);
6288 this_char[4-k+j] = this_char[j];
6292 this_char[3-k++]='0';
6295 if(strlen(this_char) == 4)
6297 AtoH(this_char, temp, 2);
6298 eepAddr = *temp*256 + temp[1];
6299 if (eepAddr < 0xFFFF)
6301 RT28xx_EEPROM_READ16(pAdapter, eepAddr, eepValue);
6302 sprintf(msg+strlen(msg), "[0x%04X]:0x%04X ", eepAddr , eepValue);
6305 {//Invalid parametes, so default printk all bbp
6312 memcpy(&temp2, value, strlen(value));
6313 temp2[strlen(value)] = '\0';
6316 if((strlen(this_char) > 4) || strlen(temp2) > 8)
6319 j = strlen(this_char);
6322 if(this_char[j] > 'f' || this_char[j] < '0')
6328 if(temp2[j] > 'f' || temp2[j] < '0')
6333 k = j = strlen(this_char);
6336 this_char[4-k+j] = this_char[j];
6340 this_char[3-k++]='0';
6344 k = j = strlen(temp2);
6347 temp2[4-k+j] = temp2[j];
6354 AtoH(this_char, temp, 2);
6355 eepAddr = *temp*256 + temp[1];
6357 AtoH(temp2, temp, 2);
6358 eepValue = *temp*256 + temp[1];
6360 RT28xx_EEPROM_WRITE16(pAdapter, eepAddr, eepValue);
6361 sprintf(msg+strlen(msg), "[0x%02X]:%02X ", eepAddr, eepValue);
6365 if(strlen(msg) == 1)
6366 sprintf(msg+strlen(msg), "===>Error command format!");
6369 // Copy the information into the user buffer
6370 wrq->u.data.length = strlen(msg);
6371 Status = copy_to_user(wrq->u.data.pointer, msg, wrq->u.data.length);
6373 DBGPRINT(RT_DEBUG_TRACE, ("<==RTMPIoctlE2PROM\n"));
6380 INT Set_TGnWifiTest_Proc(
6381 IN PRTMP_ADAPTER pAd,
6384 if (simple_strtol(arg, 0, 10) == 0)
6385 pAd->StaCfg.bTGnWifiTest = FALSE;
6387 pAd->StaCfg.bTGnWifiTest = TRUE;
6389 DBGPRINT(RT_DEBUG_TRACE, ("IF Set_TGnWifiTest_Proc::(bTGnWifiTest=%d)\n", pAd->StaCfg.bTGnWifiTest));
6393 INT Set_LongRetryLimit_Proc(
6394 IN PRTMP_ADAPTER pAdapter,
6397 TX_RTY_CFG_STRUC tx_rty_cfg;
6398 UCHAR LongRetryLimit = (UCHAR)simple_strtol(arg, 0, 10);
6400 RTMP_IO_READ32(pAdapter, TX_RTY_CFG, &tx_rty_cfg.word);
6401 tx_rty_cfg.field.LongRtyLimit = LongRetryLimit;
6402 RTMP_IO_WRITE32(pAdapter, TX_RTY_CFG, tx_rty_cfg.word);
6403 DBGPRINT(RT_DEBUG_TRACE, ("IF Set_LongRetryLimit_Proc::(tx_rty_cfg=0x%x)\n", tx_rty_cfg.word));
6407 INT Set_ShortRetryLimit_Proc(
6408 IN PRTMP_ADAPTER pAdapter,
6411 TX_RTY_CFG_STRUC tx_rty_cfg;
6412 UCHAR ShortRetryLimit = (UCHAR)simple_strtol(arg, 0, 10);
6414 RTMP_IO_READ32(pAdapter, TX_RTY_CFG, &tx_rty_cfg.word);
6415 tx_rty_cfg.field.ShortRtyLimit = ShortRetryLimit;
6416 RTMP_IO_WRITE32(pAdapter, TX_RTY_CFG, tx_rty_cfg.word);
6417 DBGPRINT(RT_DEBUG_TRACE, ("IF Set_ShortRetryLimit_Proc::(tx_rty_cfg=0x%x)\n", tx_rty_cfg.word));
6421 INT Show_Adhoc_MacTable_Proc(
6422 IN PRTMP_ADAPTER pAd,
6427 sprintf(extra, "\n");
6429 #ifdef DOT11_N_SUPPORT
6430 sprintf(extra + strlen(extra), "HT Operating Mode : %d\n", pAd->CommonCfg.AddHTInfo.AddHtInfo2.OperaionMode);
6431 #endif // DOT11_N_SUPPORT //
6433 sprintf(extra + strlen(extra), "\n%-19s%-4s%-4s%-7s%-7s%-7s%-10s%-6s%-6s%-6s%-6s\n",
6434 "MAC", "AID", "BSS", "RSSI0", "RSSI1", "RSSI2", "PhMd", "BW", "MCS", "SGI", "STBC");
6436 for (i=1; i<MAX_LEN_OF_MAC_TABLE; i++)
6438 PMAC_TABLE_ENTRY pEntry = &pAd->MacTab.Content[i];
6440 if (strlen(extra) > (IW_PRIV_SIZE_MASK - 30))
6442 if ((pEntry->ValidAsCLI || pEntry->ValidAsApCli) && (pEntry->Sst == SST_ASSOC))
6444 sprintf(extra + strlen(extra), "%02X:%02X:%02X:%02X:%02X:%02X ",
6445 pEntry->Addr[0], pEntry->Addr[1], pEntry->Addr[2],
6446 pEntry->Addr[3], pEntry->Addr[4], pEntry->Addr[5]);
6447 sprintf(extra + strlen(extra), "%-4d", (int)pEntry->Aid);
6448 sprintf(extra + strlen(extra), "%-4d", (int)pEntry->apidx);
6449 sprintf(extra + strlen(extra), "%-7d", pEntry->RssiSample.AvgRssi0);
6450 sprintf(extra + strlen(extra), "%-7d", pEntry->RssiSample.AvgRssi1);
6451 sprintf(extra + strlen(extra), "%-7d", pEntry->RssiSample.AvgRssi2);
6452 sprintf(extra + strlen(extra), "%-10s", GetPhyMode(pEntry->HTPhyMode.field.MODE));
6453 sprintf(extra + strlen(extra), "%-6s", GetBW(pEntry->HTPhyMode.field.BW));
6454 sprintf(extra + strlen(extra), "%-6d", pEntry->HTPhyMode.field.MCS);
6455 sprintf(extra + strlen(extra), "%-6d", pEntry->HTPhyMode.field.ShortGI);
6456 sprintf(extra + strlen(extra), "%-6d", pEntry->HTPhyMode.field.STBC);
6457 sprintf(extra + strlen(extra), "%-10d, %d, %d%%\n", pEntry->DebugFIFOCount, pEntry->DebugTxCount,
6458 (pEntry->DebugTxCount) ? ((pEntry->DebugTxCount-pEntry->DebugFIFOCount)*100/pEntry->DebugTxCount) : 0);
6459 sprintf(extra, "%s\n", extra);