2 *************************************************************************
4 * 5F., No.36, Taiyuan St., Jhubei City,
8 * (c) Copyright 2002-2007, Ralink Technology, Inc.
10 * This program is free software; you can redistribute it and/or modify *
11 * it under the terms of the GNU General Public License as published by *
12 * the Free Software Foundation; either version 2 of the License, or *
13 * (at your option) any later version. *
15 * This program is distributed in the hope that it will be useful, *
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
18 * GNU General Public License for more details. *
20 * You should have received a copy of the GNU General Public License *
21 * along with this program; if not, write to the *
22 * Free Software Foundation, Inc., *
23 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
25 *************************************************************************
31 IOCTL related subroutines
35 -------- ---------- ----------------------------------------------
36 Rory Chen 01-03-2003 created
37 Rory Chen 02-14-2005 modify to support RT61
40 #include "rt_config.h"
43 extern ULONG RTDebugLevel;
47 #define WEP_SMALL_KEY_LEN (40/8)
48 #define WEP_LARGE_KEY_LEN (104/8)
50 #define GROUP_KEY_NO 4
52 extern UCHAR CipherWpa2Template[];
53 extern UCHAR CipherWpaPskTkip[];
54 extern UCHAR CipherWpaPskTkipLen;
56 typedef struct PACKED _RT_VERSION_INFO{
62 UINT DriverBuildMonth;
64 } RT_VERSION_INFO, *PRT_VERSION_INFO;
66 struct iw_priv_args privtab[] = {
68 IW_PRIV_TYPE_CHAR | 1024, 0,
71 { RTPRIV_IOCTL_SHOW, 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK,
73 { RTPRIV_IOCTL_SHOW, IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK,
75 /* --- sub-ioctls definitions --- */
77 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "connStatus" },
79 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "driverVer" },
81 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "bainfo" },
83 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "descinfo" },
85 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "radio_off" },
87 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "radio_on" },
89 IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "show" },
90 /* --- sub-ioctls relations --- */
94 IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK,
97 IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | 1024,
100 IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | 1024,
104 { RTPRIV_IOCTL_STATISTICS,
105 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK,
107 { RTPRIV_IOCTL_GSITESURVEY,
108 0, IW_PRIV_TYPE_CHAR | 1024,
113 IN PRTMP_ADAPTER pAdapter,
117 INT Set_WmmCapable_Proc(
118 IN PRTMP_ADAPTER pAd,
122 INT Set_NetworkType_Proc(
123 IN PRTMP_ADAPTER pAdapter,
126 INT Set_AuthMode_Proc(
127 IN PRTMP_ADAPTER pAdapter,
130 INT Set_EncrypType_Proc(
131 IN PRTMP_ADAPTER pAdapter,
134 INT Set_DefaultKeyID_Proc(
135 IN PRTMP_ADAPTER pAdapter,
139 IN PRTMP_ADAPTER pAdapter,
143 IN PRTMP_ADAPTER pAdapter,
147 IN PRTMP_ADAPTER pAdapter,
151 IN PRTMP_ADAPTER pAdapter,
155 IN PRTMP_ADAPTER pAdapter,
160 IN PRTMP_ADAPTER pAdapter,
164 IN PRTMP_ADAPTER pAd,
169 IN PRTMP_ADAPTER pAdapter,
170 IN struct iwreq *wrq);
173 IN PRTMP_ADAPTER pAdapter,
174 IN struct iwreq *wrq);
176 VOID RTMPIoctlE2PROM(
177 IN PRTMP_ADAPTER pAdapter,
178 IN struct iwreq *wrq);
182 NDIS_STATUS RTMPWPANoneAddKeyProc(
183 IN PRTMP_ADAPTER pAd,
186 INT Set_FragTest_Proc(
187 IN PRTMP_ADAPTER pAdapter,
190 INT Set_TGnWifiTest_Proc(
191 IN PRTMP_ADAPTER pAd,
194 INT Set_LongRetryLimit_Proc(
195 IN PRTMP_ADAPTER pAdapter,
198 INT Set_ShortRetryLimit_Proc(
199 IN PRTMP_ADAPTER pAdapter,
204 INT (*set_proc)(PRTMP_ADAPTER pAdapter, PUCHAR arg);
205 } *PRTMP_PRIVATE_SET_PROC, RTMP_PRIVATE_SUPPORT_PROC[] = {
206 {"DriverVersion", Set_DriverVersion_Proc},
207 {"CountryRegion", Set_CountryRegion_Proc},
208 {"CountryRegionABand", Set_CountryRegionABand_Proc},
209 {"SSID", Set_SSID_Proc},
210 {"WirelessMode", Set_WirelessMode_Proc},
211 {"TxBurst", Set_TxBurst_Proc},
212 {"TxPreamble", Set_TxPreamble_Proc},
213 {"TxPower", Set_TxPower_Proc},
214 {"Channel", Set_Channel_Proc},
215 {"BGProtection", Set_BGProtection_Proc},
216 {"RTSThreshold", Set_RTSThreshold_Proc},
217 {"FragThreshold", Set_FragThreshold_Proc},
218 {"HtBw", Set_HtBw_Proc},
219 {"HtMcs", Set_HtMcs_Proc},
220 {"HtGi", Set_HtGi_Proc},
221 {"HtOpMode", Set_HtOpMode_Proc},
222 {"HtExtcha", Set_HtExtcha_Proc},
223 {"HtMpduDensity", Set_HtMpduDensity_Proc},
224 {"HtBaWinSize", Set_HtBaWinSize_Proc},
225 {"HtRdg", Set_HtRdg_Proc},
226 {"HtAmsdu", Set_HtAmsdu_Proc},
227 {"HtAutoBa", Set_HtAutoBa_Proc},
228 {"HtBaDecline", Set_BADecline_Proc},
229 {"HtProtect", Set_HtProtect_Proc},
230 {"HtMimoPs", Set_HtMimoPs_Proc},
231 #ifdef AGGREGATION_SUPPORT
232 {"PktAggregate", Set_PktAggregate_Proc},
236 {"WmmCapable", Set_WmmCapable_Proc},
238 {"IEEE80211H", Set_IEEE80211H_Proc},
239 {"NetworkType", Set_NetworkType_Proc},
240 {"AuthMode", Set_AuthMode_Proc},
241 {"EncrypType", Set_EncrypType_Proc},
242 {"DefaultKeyID", Set_DefaultKeyID_Proc},
243 {"Key1", Set_Key1_Proc},
244 {"Key2", Set_Key2_Proc},
245 {"Key3", Set_Key3_Proc},
246 {"Key4", Set_Key4_Proc},
247 {"WPAPSK", Set_WPAPSK_Proc},
248 {"ResetCounter", Set_ResetStatCounter_Proc},
249 {"PSMode", Set_PSMode_Proc},
251 {"Debug", Set_Debug_Proc},
253 {"WpaSupport", Set_Wpa_Support},
254 {"FixedTxMode", Set_FixedTxMode_Proc},
255 {"TGnWifiTest", Set_TGnWifiTest_Proc},
256 {"ForceGF", Set_ForceGF_Proc},
257 {"LongRetry", Set_LongRetryLimit_Proc},
258 {"ShortRetry", Set_ShortRetryLimit_Proc},
264 IN PRTMP_ADAPTER pAd,
265 IN PNDIS_802_11_KEY pKey)
268 MAC_TABLE_ENTRY *pEntry;
270 DBGPRINT(RT_DEBUG_TRACE, ("RTMPAddKey ------>\n"));
272 RTMP_CLEAR_PSFLAG(pAd, fRTMP_PS_CAN_GO_SLEEP);
273 if (RTMP_TEST_PSFLAG(pAd, fRTMP_PS_SET_PCI_CLK_OFF_COMMAND))
275 if (pAd->StaCfg.bRadio == FALSE)
277 RTMP_SET_PSFLAG(pAd, fRTMP_PS_CAN_GO_SLEEP);
280 DBGPRINT(RT_DEBUG_TRACE,("RTMPWPAAddKeyProc1==>\n"));
281 RTMPPCIeLinkCtrlValueRestore(pAd, RESTORE_HALT);
283 pAd->bPCIclkOff = FALSE;
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 STA_PORT_SECURED(pAd);
348 // Indicate Connected for GUI
349 pAd->IndicateMediaState = NdisMediaStateConnected;
355 pAd->StaCfg.DefaultKeyId = (pKey->KeyIndex & 0xFF);
356 NdisZeroMemory(&pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId], sizeof(CIPHER_KEY));
357 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].KeyLen = LEN_TKIP_EK;
358 NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].Key, pKey->KeyMaterial, LEN_TKIP_EK);
360 if (pAd->StaCfg.GroupCipher == Ndis802_11Encryption2Enabled)
362 NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].RxMic, pKey->KeyMaterial + LEN_TKIP_EK, LEN_TKIP_TXMICK);
363 NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].TxMic, pKey->KeyMaterial + LEN_TKIP_EK + LEN_TKIP_TXMICK, LEN_TKIP_RXMICK);
367 NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].TxMic, pKey->KeyMaterial + LEN_TKIP_EK, LEN_TKIP_TXMICK);
368 NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].RxMic, pKey->KeyMaterial + LEN_TKIP_EK + LEN_TKIP_TXMICK, LEN_TKIP_RXMICK);
371 // Update Shared Key CipherAlg
372 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg = CIPHER_NONE;
373 if (pAd->StaCfg.GroupCipher == Ndis802_11Encryption2Enabled)
374 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg = CIPHER_TKIP;
375 else if (pAd->StaCfg.GroupCipher == Ndis802_11Encryption3Enabled)
376 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg = CIPHER_AES;
378 // Update group key information to ASIC Shared Key Table
379 AsicAddSharedKeyEntry(pAd,
381 pAd->StaCfg.DefaultKeyId,
382 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg,
383 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].Key,
384 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].TxMic,
385 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].RxMic);
387 // Update ASIC WCID attribute table and IVEIV table
388 RTMPAddWcidAttributeEntry(pAd,
390 pAd->StaCfg.DefaultKeyId,
391 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg,
394 // set 802.1x port control
395 STA_PORT_SECURED(pAd);
397 // Indicate Connected for GUI
398 pAd->IndicateMediaState = NdisMediaStateConnected;
401 else // dynamic WEP from wpa_supplicant
406 if(pKey->KeyLength == 32)
409 KeyIdx = pKey->KeyIndex & 0x0fffffff;
413 // it is a default shared key, for Pairwise key setting
414 if (pKey->KeyIndex & 0x80000000)
416 pEntry = MacTableLookup(pAd, pKey->BSSID);
420 DBGPRINT(RT_DEBUG_TRACE, ("RTMPAddKey: Set Pair-wise Key\n"));
422 // set key material and key length
423 pEntry->PairwiseKey.KeyLen = (UCHAR)pKey->KeyLength;
424 NdisMoveMemory(pEntry->PairwiseKey.Key, &pKey->KeyMaterial, pKey->KeyLength);
427 if (pKey->KeyLength == 5)
428 pEntry->PairwiseKey.CipherAlg = CIPHER_WEP64;
430 pEntry->PairwiseKey.CipherAlg = CIPHER_WEP128;
432 // Add Pair-wise key to Asic
433 AsicAddPairwiseKeyEntry(
437 &pEntry->PairwiseKey);
439 // update WCID attribute table and IVEIV table for this entry
440 RTMPAddWcidAttributeEntry(
443 KeyIdx, // The value may be not zero
444 pEntry->PairwiseKey.CipherAlg,
451 // Default key for tx (shared key)
452 pAd->StaCfg.DefaultKeyId = (UCHAR) KeyIdx;
454 // set key material and key length
455 pAd->SharedKey[BSS0][KeyIdx].KeyLen = (UCHAR) pKey->KeyLength;
456 NdisMoveMemory(pAd->SharedKey[BSS0][KeyIdx].Key, &pKey->KeyMaterial, pKey->KeyLength);
459 if (pKey->KeyLength == 5)
460 pAd->SharedKey[BSS0][KeyIdx].CipherAlg = CIPHER_WEP64;
462 pAd->SharedKey[BSS0][KeyIdx].CipherAlg = CIPHER_WEP128;
464 CipherAlg = pAd->SharedKey[BSS0][KeyIdx].CipherAlg;
465 Key = pAd->SharedKey[BSS0][KeyIdx].Key;
467 // Set Group key material to Asic
468 AsicAddSharedKeyEntry(pAd, BSS0, KeyIdx, CipherAlg, Key, NULL, NULL);
470 // Update WCID attribute table and IVEIV table for this group key table
471 RTMPAddWcidAttributeEntry(pAd, BSS0, KeyIdx, CipherAlg, NULL);
477 RTMP_SET_PSFLAG(pAd, fRTMP_PS_CAN_GO_SLEEP);
478 DBGPRINT(RT_DEBUG_INFO, ("<------ RTMPAddKey\n"));
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;
501 strncpy(name, "RT2860 Wireless", IFNAMSIZ);
505 int rt_ioctl_siwfreq(struct net_device *dev,
506 struct iw_request_info *info,
507 struct iw_freq *freq, char *extra)
509 PRTMP_ADAPTER pAdapter = dev->ml_priv;
512 //check if the interface is down
513 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
515 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
523 if((freq->e == 0) && (freq->m <= 1000))
524 chan = freq->m; // Setting by channel number
526 MAP_KHZ_TO_CHANNEL_ID( (freq->m /100) , chan); // Setting by frequency - search the table , like 2.412G, 2.422G,
528 if (ChannelSanity(pAdapter, chan) == TRUE)
530 pAdapter->CommonCfg.Channel = chan;
531 DBGPRINT(RT_DEBUG_ERROR, ("==>rt_ioctl_siwfreq::SIOCSIWFREQ[cmd=0x%x] (Channel=%d)\n", SIOCSIWFREQ, pAdapter->CommonCfg.Channel));
538 int rt_ioctl_giwfreq(struct net_device *dev,
539 struct iw_request_info *info,
540 struct iw_freq *freq, char *extra)
542 VIRTUAL_ADAPTER *pVirtualAd = NULL;
543 PRTMP_ADAPTER pAdapter = NULL;
547 if (dev->priv_flags == INT_MAIN)
549 pAdapter = dev->ml_priv;
553 pVirtualAd = dev->ml_priv;
554 if (pVirtualAd && pVirtualAd->RtmpDev)
555 pAdapter = pVirtualAd->RtmpDev->ml_priv;
558 if (pAdapter == NULL)
560 /* if 1st open fail, pAd will be free;
561 So the net_dev->ml_priv will be NULL in 2rd open */
565 ch = pAdapter->CommonCfg.Channel;
567 DBGPRINT(RT_DEBUG_TRACE,("==>rt_ioctl_giwfreq %d\n", ch));
569 MAP_CHANNEL_ID_TO_KHZ(ch, m);
575 int rt_ioctl_siwmode(struct net_device *dev,
576 struct iw_request_info *info,
577 __u32 *mode, char *extra)
579 PRTMP_ADAPTER pAdapter = dev->ml_priv;
581 //check if the interface is down
582 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
584 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
591 Set_NetworkType_Proc(pAdapter, "Adhoc");
594 Set_NetworkType_Proc(pAdapter, "Infra");
596 case IW_MODE_MONITOR:
597 Set_NetworkType_Proc(pAdapter, "Monitor");
600 DBGPRINT(RT_DEBUG_TRACE, ("===>rt_ioctl_siwmode::SIOCSIWMODE (unknown %d)\n", *mode));
604 // Reset Ralink supplicant to not use, it will be set to start when UI set PMK key
605 pAdapter->StaCfg.WpaState = SS_NOTUSE;
610 int rt_ioctl_giwmode(struct net_device *dev,
611 struct iw_request_info *info,
612 __u32 *mode, char *extra)
614 PRTMP_ADAPTER pAdapter = NULL;
615 VIRTUAL_ADAPTER *pVirtualAd = NULL;
617 if (dev->priv_flags == INT_MAIN)
619 pAdapter = dev->ml_priv;
623 pVirtualAd = dev->ml_priv;
624 if (pVirtualAd && pVirtualAd->RtmpDev)
625 pAdapter = pVirtualAd->RtmpDev->ml_priv;
628 if (pAdapter == NULL)
630 /* if 1st open fail, pAd will be free;
631 So the net_dev->ml_priv will be NULL in 2rd open */
635 if (ADHOC_ON(pAdapter))
636 *mode = IW_MODE_ADHOC;
637 else if (INFRA_ON(pAdapter))
638 *mode = IW_MODE_INFRA;
639 else if (MONITOR_ON(pAdapter))
641 *mode = IW_MODE_MONITOR;
644 *mode = IW_MODE_AUTO;
646 DBGPRINT(RT_DEBUG_TRACE, ("==>rt_ioctl_giwmode(mode=%d)\n", *mode));
650 int rt_ioctl_siwsens(struct net_device *dev,
651 struct iw_request_info *info,
652 char *name, char *extra)
654 PRTMP_ADAPTER pAdapter = dev->ml_priv;
656 //check if the interface is down
657 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
659 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
666 int rt_ioctl_giwsens(struct net_device *dev,
667 struct iw_request_info *info,
668 char *name, char *extra)
673 int rt_ioctl_giwrange(struct net_device *dev,
674 struct iw_request_info *info,
675 struct iw_point *data, char *extra)
677 PRTMP_ADAPTER pAdapter = NULL;
678 VIRTUAL_ADAPTER *pVirtualAd = NULL;
679 struct iw_range *range = (struct iw_range *) extra;
683 if (dev->priv_flags == INT_MAIN)
685 pAdapter = dev->ml_priv;
689 pVirtualAd = dev->ml_priv;
690 if (pVirtualAd && pVirtualAd->RtmpDev)
691 pAdapter = pVirtualAd->RtmpDev->ml_priv;
694 if (pAdapter == NULL)
696 /* if 1st open fail, pAd will be free;
697 So the net_dev->ml_priv will be NULL in 2rd open */
701 DBGPRINT(RT_DEBUG_TRACE ,("===>rt_ioctl_giwrange\n"));
702 data->length = sizeof(struct iw_range);
703 memset(range, 0, sizeof(struct iw_range));
705 range->txpower_capa = IW_TXPOW_DBM;
707 if (INFRA_ON(pAdapter)||ADHOC_ON(pAdapter))
709 range->min_pmp = 1 * 1024;
710 range->max_pmp = 65535 * 1024;
711 range->min_pmt = 1 * 1024;
712 range->max_pmt = 1000 * 1024;
713 range->pmp_flags = IW_POWER_PERIOD;
714 range->pmt_flags = IW_POWER_TIMEOUT;
715 range->pm_capa = IW_POWER_PERIOD | IW_POWER_TIMEOUT |
716 IW_POWER_UNICAST_R | IW_POWER_ALL_R;
719 range->we_version_compiled = WIRELESS_EXT;
720 range->we_version_source = 14;
722 range->retry_capa = IW_RETRY_LIMIT;
723 range->retry_flags = IW_RETRY_LIMIT;
724 range->min_retry = 0;
725 range->max_retry = 255;
727 range->num_channels = pAdapter->ChannelListNum;
730 for (i = 1; i <= range->num_channels; i++)
733 range->freq[val].i = pAdapter->ChannelList[i-1].Channel;
734 MAP_CHANNEL_ID_TO_KHZ(pAdapter->ChannelList[i-1].Channel, m);
735 range->freq[val].m = m * 100; /* HZ */
737 range->freq[val].e = 1;
739 if (val == IW_MAX_FREQUENCIES)
742 range->num_frequency = val;
744 range->max_qual.qual = 100; /* what is correct max? This was not
745 * documented exactly. At least
746 * 69 has been observed. */
747 range->max_qual.level = 0; /* dB */
748 range->max_qual.noise = 0; /* dB */
750 /* What would be suitable values for "average/typical" qual? */
751 range->avg_qual.qual = 20;
752 range->avg_qual.level = -60;
753 range->avg_qual.noise = -95;
754 range->sensitivity = 3;
756 range->max_encoding_tokens = NR_WEP_KEYS;
757 range->num_encoding_sizes = 2;
758 range->encoding_size[0] = 5;
759 range->encoding_size[1] = 13;
762 range->max_rts = 2347;
763 range->min_frag = 256;
764 range->max_frag = 2346;
766 #if WIRELESS_EXT > 17
767 /* IW_ENC_CAPA_* bit field */
768 range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 |
769 IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP;
775 int rt_ioctl_siwap(struct net_device *dev,
776 struct iw_request_info *info,
777 struct sockaddr *ap_addr, char *extra)
779 PRTMP_ADAPTER pAdapter = dev->ml_priv;
780 NDIS_802_11_MAC_ADDRESS Bssid;
782 //check if the interface is down
783 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
785 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
789 if (pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE)
791 RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
792 DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
795 // tell CNTL state machine to call NdisMSetInformationComplete() after completing
796 // this request, because this request is initiated by NDIS.
797 pAdapter->MlmeAux.CurrReqIsFromNdis = FALSE;
798 // Prevent to connect AP again in STAMlmePeriodicExec
799 pAdapter->MlmeAux.AutoReconnectSsidLen= 32;
801 memset(Bssid, 0, MAC_ADDR_LEN);
802 memcpy(Bssid, ap_addr->sa_data, MAC_ADDR_LEN);
803 MlmeEnqueue(pAdapter,
804 MLME_CNTL_STATE_MACHINE,
806 sizeof(NDIS_802_11_MAC_ADDRESS),
809 DBGPRINT(RT_DEBUG_TRACE, ("IOCTL::SIOCSIWAP %02x:%02x:%02x:%02x:%02x:%02x\n",
810 Bssid[0], Bssid[1], Bssid[2], Bssid[3], Bssid[4], Bssid[5]));
815 int rt_ioctl_giwap(struct net_device *dev,
816 struct iw_request_info *info,
817 struct sockaddr *ap_addr, char *extra)
819 PRTMP_ADAPTER pAdapter = NULL;
820 VIRTUAL_ADAPTER *pVirtualAd = NULL;
822 if (dev->priv_flags == INT_MAIN)
824 pAdapter = dev->ml_priv;
828 pVirtualAd = dev->ml_priv;
829 if (pVirtualAd && pVirtualAd->RtmpDev)
830 pAdapter = pVirtualAd->RtmpDev->ml_priv;
833 if (pAdapter == NULL)
835 /* if 1st open fail, pAd will be free;
836 So the net_dev->ml_priv will be NULL in 2rd open */
840 if (INFRA_ON(pAdapter) || ADHOC_ON(pAdapter))
842 ap_addr->sa_family = ARPHRD_ETHER;
843 memcpy(ap_addr->sa_data, &pAdapter->CommonCfg.Bssid, ETH_ALEN);
846 else if (pAdapter->StaCfg.WpaSupplicantUP != WPA_SUPPLICANT_DISABLE)
848 ap_addr->sa_family = ARPHRD_ETHER;
849 memcpy(ap_addr->sa_data, &pAdapter->MlmeAux.Bssid, ETH_ALEN);
853 DBGPRINT(RT_DEBUG_TRACE, ("IOCTL::SIOCGIWAP(=EMPTY)\n"));
861 * Units are in db above the noise floor. That means the
862 * rssi values reported in the tx/rx descriptors in the
863 * driver are the SNR expressed in db.
865 * If you assume that the noise floor is -95, which is an
866 * excellent assumption 99.5 % of the time, then you can
867 * derive the absolute signal level (i.e. -95 + rssi).
868 * There are some other slight factors to take into account
869 * depending on whether the rssi measurement is from 11b,
870 * 11g, or 11a. These differences are at most 2db and
873 * NB: various calculations are based on the orinoco/wavelan
874 * drivers for compatibility
876 static void set_quality(PRTMP_ADAPTER pAdapter,
877 struct iw_quality *iq,
884 ChannelQuality = 100;
885 else if (rssi >= -80) // between -50 ~ -80dbm
886 ChannelQuality = (__u8)(24 + ((rssi + 80) * 26)/10);
887 else if (rssi >= -90) // between -80 ~ -90dbm
888 ChannelQuality = (__u8)((rssi + 90) * 26)/10;
892 iq->qual = (__u8)ChannelQuality;
894 iq->level = (__u8)(rssi);
895 iq->noise = (pAdapter->BbpWriteLatch[66] > pAdapter->BbpTuning.FalseCcaUpperThreshold) ? ((__u8)pAdapter->BbpTuning.FalseCcaUpperThreshold) : ((__u8) pAdapter->BbpWriteLatch[66]); // noise level (dBm)
896 iq->noise += 256 - 143;
897 iq->updated = pAdapter->iw_stats.qual.updated;
900 int rt_ioctl_iwaplist(struct net_device *dev,
901 struct iw_request_info *info,
902 struct iw_point *data, char *extra)
904 PRTMP_ADAPTER pAdapter = dev->ml_priv;
906 struct sockaddr addr[IW_MAX_AP];
907 struct iw_quality qual[IW_MAX_AP];
910 //check if the interface is down
911 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
913 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
919 for (i = 0; i <IW_MAX_AP ; i++)
921 if (i >= pAdapter->ScanTab.BssNr)
923 addr[i].sa_family = ARPHRD_ETHER;
924 memcpy(addr[i].sa_data, &pAdapter->ScanTab.BssEntry[i].Bssid, MAC_ADDR_LEN);
925 set_quality(pAdapter, &qual[i], pAdapter->ScanTab.BssEntry[i].Rssi);
928 memcpy(extra, &addr, i*sizeof(addr[0]));
929 data->flags = 1; /* signal quality present (sort of) */
930 memcpy(extra + i*sizeof(addr[0]), &qual, i*sizeof(qual[i]));
936 int rt_ioctl_siwscan(struct net_device *dev,
937 struct iw_request_info *info,
938 struct iw_point *data, char *extra)
940 PRTMP_ADAPTER pAdapter = dev->ml_priv;
943 int Status = NDIS_STATUS_SUCCESS;
945 //check if the interface is down
946 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
948 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
952 if (MONITOR_ON(pAdapter))
954 DBGPRINT(RT_DEBUG_TRACE, ("!!! Driver is in Monitor Mode now !!!\n"));
958 if ((pAdapter->OpMode == OPMODE_STA) && (IDLE_ON(pAdapter))
959 && (pAdapter->StaCfg.bRadio == TRUE)
960 && (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_IDLE_RADIO_OFF)))
962 RT28xxPciAsicRadioOn(pAdapter, GUI_IDLE_POWER_SAVE);
964 // Check if still radio off.
965 else if (pAdapter->bPCIclkOff == TRUE)
968 if (pAdapter->StaCfg.WpaSupplicantUP == WPA_SUPPLICANT_ENABLE)
970 pAdapter->StaCfg.WpaSupplicantScanCount++;
973 pAdapter->StaCfg.bScanReqIsFromWebUI = TRUE;
974 if (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
979 if ((pAdapter->StaCfg.WpaSupplicantUP == WPA_SUPPLICANT_ENABLE) &&
980 (pAdapter->StaCfg.WpaSupplicantScanCount > 3))
982 DBGPRINT(RT_DEBUG_TRACE, ("!!! WpaSupplicantScanCount > 3\n"));
983 Status = NDIS_STATUS_SUCCESS;
987 if ((OPSTATUS_TEST_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED)) &&
988 ((pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA) ||
989 (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK)) &&
990 (pAdapter->StaCfg.PortSecured == WPA_802_1X_PORT_NOT_SECURED))
992 DBGPRINT(RT_DEBUG_TRACE, ("!!! Link UP, Port Not Secured! ignore this set::OID_802_11_BSSID_LIST_SCAN\n"));
993 Status = NDIS_STATUS_SUCCESS;
997 if (pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE)
999 RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
1000 DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
1003 // tell CNTL state machine to call NdisMSetInformationComplete() after completing
1004 // this request, because this request is initiated by NDIS.
1005 pAdapter->MlmeAux.CurrReqIsFromNdis = FALSE;
1006 // Reset allowed scan retries
1007 pAdapter->StaCfg.ScanCnt = 0;
1008 pAdapter->StaCfg.LastScanTime = Now;
1010 MlmeEnqueue(pAdapter,
1011 MLME_CNTL_STATE_MACHINE,
1012 OID_802_11_BSSID_LIST_SCAN,
1016 Status = NDIS_STATUS_SUCCESS;
1017 RT28XX_MLME_HANDLER(pAdapter);
1022 int rt_ioctl_giwscan(struct net_device *dev,
1023 struct iw_request_info *info,
1024 struct iw_point *data, char *extra)
1027 PRTMP_ADAPTER pAdapter = dev->ml_priv;
1029 char *current_ev = extra, *previous_ev = extra;
1031 char *current_val, custom[MAX_CUSTOM_LEN] = {0};
1034 #endif // IWEVGENIE //
1035 struct iw_event iwe;
1037 if (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
1040 * Still scanning, indicate the caller should try again.
1045 if (pAdapter->StaCfg.WpaSupplicantUP == WPA_SUPPLICANT_ENABLE)
1047 pAdapter->StaCfg.WpaSupplicantScanCount = 0;
1050 if (pAdapter->ScanTab.BssNr == 0)
1056 #if WIRELESS_EXT >= 17
1057 if (data->length > 0)
1058 end_buf = extra + data->length;
1060 end_buf = extra + IW_SCAN_MAX_DATA;
1062 end_buf = extra + IW_SCAN_MAX_DATA;
1065 for (i = 0; i < pAdapter->ScanTab.BssNr; i++)
1067 if (current_ev >= end_buf)
1069 #if WIRELESS_EXT >= 17
1077 //================================
1078 memset(&iwe, 0, sizeof(iwe));
1079 iwe.cmd = SIOCGIWAP;
1080 iwe.u.ap_addr.sa_family = ARPHRD_ETHER;
1081 memcpy(iwe.u.ap_addr.sa_data, &pAdapter->ScanTab.BssEntry[i].Bssid, ETH_ALEN);
1083 previous_ev = current_ev;
1084 current_ev = iwe_stream_add_event(info, current_ev,end_buf, &iwe, IW_EV_ADDR_LEN);
1085 if (current_ev == previous_ev)
1086 #if WIRELESS_EXT >= 17
1093 //================================
1094 memset(&iwe, 0, sizeof(iwe));
1095 iwe.cmd = SIOCGIWESSID;
1096 iwe.u.data.length = pAdapter->ScanTab.BssEntry[i].SsidLen;
1097 iwe.u.data.flags = 1;
1099 previous_ev = current_ev;
1100 current_ev = iwe_stream_add_point(info, current_ev,end_buf, &iwe, pAdapter->ScanTab.BssEntry[i].Ssid);
1101 if (current_ev == previous_ev)
1102 #if WIRELESS_EXT >= 17
1109 //================================
1110 memset(&iwe, 0, sizeof(iwe));
1111 iwe.cmd = SIOCGIWMODE;
1112 if (pAdapter->ScanTab.BssEntry[i].BssType == Ndis802_11IBSS)
1114 iwe.u.mode = IW_MODE_ADHOC;
1116 else if (pAdapter->ScanTab.BssEntry[i].BssType == Ndis802_11Infrastructure)
1118 iwe.u.mode = IW_MODE_INFRA;
1122 iwe.u.mode = IW_MODE_AUTO;
1124 iwe.len = IW_EV_UINT_LEN;
1126 previous_ev = current_ev;
1127 current_ev = iwe_stream_add_event(info, current_ev, end_buf, &iwe, IW_EV_UINT_LEN);
1128 if (current_ev == previous_ev)
1129 #if WIRELESS_EXT >= 17
1135 //Channel and Frequency
1136 //================================
1137 memset(&iwe, 0, sizeof(iwe));
1138 iwe.cmd = SIOCGIWFREQ;
1139 if (INFRA_ON(pAdapter) || ADHOC_ON(pAdapter))
1140 iwe.u.freq.m = pAdapter->ScanTab.BssEntry[i].Channel;
1142 iwe.u.freq.m = pAdapter->ScanTab.BssEntry[i].Channel;
1146 previous_ev = current_ev;
1147 current_ev = iwe_stream_add_event(info, current_ev, end_buf, &iwe, IW_EV_FREQ_LEN);
1148 if (current_ev == previous_ev)
1149 #if WIRELESS_EXT >= 17
1155 //Add quality statistics
1156 //================================
1157 memset(&iwe, 0, sizeof(iwe));
1159 iwe.u.qual.level = 0;
1160 iwe.u.qual.noise = 0;
1161 set_quality(pAdapter, &iwe.u.qual, pAdapter->ScanTab.BssEntry[i].Rssi);
1162 current_ev = iwe_stream_add_event(info, current_ev, end_buf, &iwe, IW_EV_QUAL_LEN);
1163 if (current_ev == previous_ev)
1164 #if WIRELESS_EXT >= 17
1171 //================================
1172 memset(&iwe, 0, sizeof(iwe));
1173 iwe.cmd = SIOCGIWENCODE;
1174 if (CAP_IS_PRIVACY_ON (pAdapter->ScanTab.BssEntry[i].CapabilityInfo ))
1175 iwe.u.data.flags =IW_ENCODE_ENABLED | IW_ENCODE_NOKEY;
1177 iwe.u.data.flags = IW_ENCODE_DISABLED;
1179 previous_ev = current_ev;
1180 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);
1181 if (current_ev == previous_ev)
1182 #if WIRELESS_EXT >= 17
1189 //================================
1190 if (pAdapter->ScanTab.BssEntry[i].SupRateLen)
1192 UCHAR tmpRate = pAdapter->ScanTab.BssEntry[i].SupRate[pAdapter->ScanTab.BssEntry[i].SupRateLen-1];
1193 memset(&iwe, 0, sizeof(iwe));
1194 iwe.cmd = SIOCGIWRATE;
1195 current_val = current_ev + IW_EV_LCP_LEN;
1196 if (tmpRate == 0x82)
1197 iwe.u.bitrate.value = 1 * 1000000;
1198 else if (tmpRate == 0x84)
1199 iwe.u.bitrate.value = 2 * 1000000;
1200 else if (tmpRate == 0x8B)
1201 iwe.u.bitrate.value = 5.5 * 1000000;
1202 else if (tmpRate == 0x96)
1203 iwe.u.bitrate.value = 11 * 1000000;
1205 iwe.u.bitrate.value = (tmpRate/2) * 1000000;
1207 iwe.u.bitrate.disabled = 0;
1208 current_val = iwe_stream_add_value(info, current_ev,
1209 current_val, end_buf, &iwe,
1212 if((current_val-current_ev)>IW_EV_LCP_LEN)
1213 current_ev = current_val;
1215 #if WIRELESS_EXT >= 17
1224 if (pAdapter->ScanTab.BssEntry[i].WpaIE.IELen > 0)
1226 memset(&iwe, 0, sizeof(iwe));
1227 memset(&custom[0], 0, MAX_CUSTOM_LEN);
1228 memcpy(custom, &(pAdapter->ScanTab.BssEntry[i].WpaIE.IE[0]),
1229 pAdapter->ScanTab.BssEntry[i].WpaIE.IELen);
1230 iwe.cmd = IWEVGENIE;
1231 iwe.u.data.length = pAdapter->ScanTab.BssEntry[i].WpaIE.IELen;
1232 current_ev = iwe_stream_add_point(info, current_ev, end_buf, &iwe, custom);
1233 if (current_ev == previous_ev)
1234 #if WIRELESS_EXT >= 17
1242 if (pAdapter->ScanTab.BssEntry[i].RsnIE.IELen > 0)
1244 memset(&iwe, 0, sizeof(iwe));
1245 memset(&custom[0], 0, MAX_CUSTOM_LEN);
1246 memcpy(custom, &(pAdapter->ScanTab.BssEntry[i].RsnIE.IE[0]),
1247 pAdapter->ScanTab.BssEntry[i].RsnIE.IELen);
1248 iwe.cmd = IWEVGENIE;
1249 iwe.u.data.length = pAdapter->ScanTab.BssEntry[i].RsnIE.IELen;
1250 current_ev = iwe_stream_add_point(info, current_ev, end_buf, &iwe, custom);
1251 if (current_ev == previous_ev)
1252 #if WIRELESS_EXT >= 17
1260 //================================
1261 if (pAdapter->ScanTab.BssEntry[i].WpaIE.IELen > 0)
1263 NdisZeroMemory(&iwe, sizeof(iwe));
1264 memset(&custom[0], 0, MAX_CUSTOM_LEN);
1265 iwe.cmd = IWEVCUSTOM;
1266 iwe.u.data.length = (pAdapter->ScanTab.BssEntry[i].WpaIE.IELen * 2) + 7;
1267 NdisMoveMemory(custom, "wpa_ie=", 7);
1268 for (idx = 0; idx < pAdapter->ScanTab.BssEntry[i].WpaIE.IELen; idx++)
1269 sprintf(custom + strlen(custom), "%02x", pAdapter->ScanTab.BssEntry[i].WpaIE.IE[idx]);
1270 previous_ev = current_ev;
1271 current_ev = iwe_stream_add_point(current_ev, end_buf, &iwe, custom);
1272 if (current_ev == previous_ev)
1273 #if WIRELESS_EXT >= 17
1281 if (pAdapter->ScanTab.BssEntry[i].RsnIE.IELen > 0)
1283 NdisZeroMemory(&iwe, sizeof(iwe));
1284 memset(&custom[0], 0, MAX_CUSTOM_LEN);
1285 iwe.cmd = IWEVCUSTOM;
1286 iwe.u.data.length = (pAdapter->ScanTab.BssEntry[i].RsnIE.IELen * 2) + 7;
1287 NdisMoveMemory(custom, "rsn_ie=", 7);
1288 for (idx = 0; idx < pAdapter->ScanTab.BssEntry[i].RsnIE.IELen; idx++)
1289 sprintf(custom + strlen(custom), "%02x", pAdapter->ScanTab.BssEntry[i].RsnIE.IE[idx]);
1290 previous_ev = current_ev;
1291 current_ev = iwe_stream_add_point(current_ev, end_buf, &iwe, custom);
1292 if (current_ev == previous_ev)
1293 #if WIRELESS_EXT >= 17
1299 #endif // IWEVGENIE //
1302 data->length = current_ev - extra;
1303 pAdapter->StaCfg.bScanReqIsFromWebUI = FALSE;
1304 DBGPRINT(RT_DEBUG_ERROR ,("===>rt_ioctl_giwscan. %d(%d) BSS returned, data->length = %d\n",i , pAdapter->ScanTab.BssNr, data->length));
1309 int rt_ioctl_siwessid(struct net_device *dev,
1310 struct iw_request_info *info,
1311 struct iw_point *data, char *essid)
1313 PRTMP_ADAPTER pAdapter = dev->ml_priv;
1315 //check if the interface is down
1316 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1318 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1324 PCHAR pSsidString = NULL;
1326 // Includes null character.
1327 if (data->length > (IW_ESSID_MAX_SIZE + 1))
1330 pSsidString = (CHAR *) kmalloc(MAX_LEN_OF_SSID+1, MEM_ALLOC_FLAG);
1333 NdisZeroMemory(pSsidString, MAX_LEN_OF_SSID+1);
1334 NdisMoveMemory(pSsidString, essid, data->length);
1335 if (Set_SSID_Proc(pAdapter, pSsidString) == FALSE)
1344 if (Set_SSID_Proc(pAdapter, "") == FALSE)
1350 int rt_ioctl_giwessid(struct net_device *dev,
1351 struct iw_request_info *info,
1352 struct iw_point *data, char *essid)
1354 PRTMP_ADAPTER pAdapter = NULL;
1355 VIRTUAL_ADAPTER *pVirtualAd = NULL;
1357 if (dev->priv_flags == INT_MAIN)
1359 pAdapter = dev->ml_priv;
1363 pVirtualAd = dev->ml_priv;
1364 if (pVirtualAd && pVirtualAd->RtmpDev)
1365 pAdapter = pVirtualAd->RtmpDev->ml_priv;
1368 if (pAdapter == NULL)
1370 /* if 1st open fail, pAd will be free;
1371 So the net_dev->ml_priv will be NULL in 2rd open */
1376 if (MONITOR_ON(pAdapter))
1382 if (OPSTATUS_TEST_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED))
1384 DBGPRINT(RT_DEBUG_TRACE ,("MediaState is connected\n"));
1385 data->length = pAdapter->CommonCfg.SsidLen;
1386 memcpy(essid, pAdapter->CommonCfg.Ssid, pAdapter->CommonCfg.SsidLen);
1389 {//the ANY ssid was specified
1391 DBGPRINT(RT_DEBUG_TRACE ,("MediaState is not connected, ess\n"));
1398 int rt_ioctl_siwnickn(struct net_device *dev,
1399 struct iw_request_info *info,
1400 struct iw_point *data, char *nickname)
1402 PRTMP_ADAPTER pAdapter = dev->ml_priv;
1404 //check if the interface is down
1405 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1407 DBGPRINT(RT_DEBUG_TRACE ,("INFO::Network is down!\n"));
1411 if (data->length > IW_ESSID_MAX_SIZE)
1414 memset(pAdapter->nickname, 0, IW_ESSID_MAX_SIZE + 1);
1415 memcpy(pAdapter->nickname, nickname, data->length);
1421 int rt_ioctl_giwnickn(struct net_device *dev,
1422 struct iw_request_info *info,
1423 struct iw_point *data, char *nickname)
1425 PRTMP_ADAPTER pAdapter = NULL;
1426 VIRTUAL_ADAPTER *pVirtualAd = NULL;
1428 if (dev->priv_flags == INT_MAIN)
1430 pAdapter = dev->ml_priv;
1434 pVirtualAd = dev->ml_priv;
1435 if (pVirtualAd && pVirtualAd->RtmpDev)
1436 pAdapter = pVirtualAd->RtmpDev->ml_priv;
1439 if (pAdapter == NULL)
1441 /* if 1st open fail, pAd will be free;
1442 So the net_dev->ml_priv will be NULL in 2rd open */
1446 if (data->length > strlen(pAdapter->nickname) + 1)
1447 data->length = strlen(pAdapter->nickname) + 1;
1448 if (data->length > 0) {
1449 memcpy(nickname, pAdapter->nickname, data->length-1);
1450 nickname[data->length-1] = '\0';
1455 int rt_ioctl_siwrts(struct net_device *dev,
1456 struct iw_request_info *info,
1457 struct iw_param *rts, char *extra)
1459 PRTMP_ADAPTER pAdapter = dev->ml_priv;
1462 //check if the interface is down
1463 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1465 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1470 val = MAX_RTS_THRESHOLD;
1471 else if (rts->value < 0 || rts->value > MAX_RTS_THRESHOLD)
1473 else if (rts->value == 0)
1474 val = MAX_RTS_THRESHOLD;
1478 if (val != pAdapter->CommonCfg.RtsThreshold)
1479 pAdapter->CommonCfg.RtsThreshold = val;
1484 int rt_ioctl_giwrts(struct net_device *dev,
1485 struct iw_request_info *info,
1486 struct iw_param *rts, char *extra)
1488 PRTMP_ADAPTER pAdapter = NULL;
1489 VIRTUAL_ADAPTER *pVirtualAd = NULL;
1491 if (dev->priv_flags == INT_MAIN)
1493 pAdapter = dev->ml_priv;
1497 pVirtualAd = dev->ml_priv;
1498 if (pVirtualAd && pVirtualAd->RtmpDev)
1499 pAdapter = pVirtualAd->RtmpDev->ml_priv;
1502 if (pAdapter == NULL)
1504 /* if 1st open fail, pAd will be free;
1505 So the net_dev->ml_priv will be NULL in 2rd open */
1509 //check if the interface is down
1510 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1512 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1516 rts->value = pAdapter->CommonCfg.RtsThreshold;
1517 rts->disabled = (rts->value == MAX_RTS_THRESHOLD);
1523 int rt_ioctl_siwfrag(struct net_device *dev,
1524 struct iw_request_info *info,
1525 struct iw_param *frag, char *extra)
1527 PRTMP_ADAPTER pAdapter = dev->ml_priv;
1530 //check if the interface is down
1531 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1533 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1538 val = MAX_FRAG_THRESHOLD;
1539 else if (frag->value >= MIN_FRAG_THRESHOLD || frag->value <= MAX_FRAG_THRESHOLD)
1540 val = __cpu_to_le16(frag->value & ~0x1); /* even numbers only */
1541 else if (frag->value == 0)
1542 val = MAX_FRAG_THRESHOLD;
1546 pAdapter->CommonCfg.FragmentThreshold = val;
1550 int rt_ioctl_giwfrag(struct net_device *dev,
1551 struct iw_request_info *info,
1552 struct iw_param *frag, char *extra)
1554 PRTMP_ADAPTER pAdapter = NULL;
1555 VIRTUAL_ADAPTER *pVirtualAd = NULL;
1557 if (dev->priv_flags == INT_MAIN)
1559 pAdapter = dev->ml_priv;
1563 pVirtualAd = dev->ml_priv;
1564 if (pVirtualAd && pVirtualAd->RtmpDev)
1565 pAdapter = pVirtualAd->RtmpDev->ml_priv;
1568 if (pAdapter == NULL)
1570 /* if 1st open fail, pAd will be free;
1571 So the net_dev->ml_priv will be NULL in 2rd open */
1575 //check if the interface is down
1576 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1578 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1582 frag->value = pAdapter->CommonCfg.FragmentThreshold;
1583 frag->disabled = (frag->value == MAX_FRAG_THRESHOLD);
1589 #define MAX_WEP_KEY_SIZE 13
1590 #define MIN_WEP_KEY_SIZE 5
1591 int rt_ioctl_siwencode(struct net_device *dev,
1592 struct iw_request_info *info,
1593 struct iw_point *erq, char *extra)
1595 PRTMP_ADAPTER pAdapter = dev->ml_priv;
1597 //check if the interface is down
1598 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1600 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1604 if ((erq->length == 0) &&
1605 (erq->flags & IW_ENCODE_DISABLED))
1607 pAdapter->StaCfg.PairCipher = Ndis802_11WEPDisabled;
1608 pAdapter->StaCfg.GroupCipher = Ndis802_11WEPDisabled;
1609 pAdapter->StaCfg.WepStatus = Ndis802_11WEPDisabled;
1610 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
1611 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
1614 else if ((erq->length == 0) &&
1615 (erq->flags & IW_ENCODE_RESTRICTED || erq->flags & IW_ENCODE_OPEN))
1617 STA_PORT_SECURED(pAdapter);
1618 pAdapter->StaCfg.PairCipher = Ndis802_11WEPEnabled;
1619 pAdapter->StaCfg.GroupCipher = Ndis802_11WEPEnabled;
1620 pAdapter->StaCfg.WepStatus = Ndis802_11WEPEnabled;
1621 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
1622 if (erq->flags & IW_ENCODE_RESTRICTED)
1623 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeShared;
1625 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
1629 if (erq->length > 0)
1631 int keyIdx = (erq->flags & IW_ENCODE_INDEX) - 1;
1632 /* Check the size of the key */
1633 if (erq->length > MAX_WEP_KEY_SIZE) {
1636 /* Check key index */
1637 if ((keyIdx < 0) || (keyIdx >= NR_WEP_KEYS))
1639 DBGPRINT(RT_DEBUG_TRACE ,("==>rt_ioctl_siwencode::Wrong keyIdx=%d! Using default key instead (%d)\n",
1640 keyIdx, pAdapter->StaCfg.DefaultKeyId));
1643 keyIdx = pAdapter->StaCfg.DefaultKeyId;
1646 NdisZeroMemory(pAdapter->SharedKey[BSS0][keyIdx].Key, 16);
1648 if (erq->length == MAX_WEP_KEY_SIZE)
1650 pAdapter->SharedKey[BSS0][keyIdx].KeyLen = MAX_WEP_KEY_SIZE;
1651 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CIPHER_WEP128;
1653 else if (erq->length == MIN_WEP_KEY_SIZE)
1655 pAdapter->SharedKey[BSS0][keyIdx].KeyLen = MIN_WEP_KEY_SIZE;
1656 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CIPHER_WEP64;
1659 /* Disable the key */
1660 pAdapter->SharedKey[BSS0][keyIdx].KeyLen = 0;
1662 /* Check if the key is not marked as invalid */
1663 if(!(erq->flags & IW_ENCODE_NOKEY)) {
1664 /* Copy the key in the driver */
1665 NdisMoveMemory(pAdapter->SharedKey[BSS0][keyIdx].Key, extra, erq->length);
1670 /* Do we want to just set the transmit key index ? */
1671 int index = (erq->flags & IW_ENCODE_INDEX) - 1;
1672 if ((index >= 0) && (index < 4))
1674 pAdapter->StaCfg.DefaultKeyId = index;
1677 /* Don't complain if only change the mode */
1678 if (!(erq->flags & IW_ENCODE_MODE)) {
1684 DBGPRINT(RT_DEBUG_TRACE ,("==>rt_ioctl_siwencode::erq->flags=%x\n",erq->flags));
1685 DBGPRINT(RT_DEBUG_TRACE ,("==>rt_ioctl_siwencode::AuthMode=%x\n",pAdapter->StaCfg.AuthMode));
1686 DBGPRINT(RT_DEBUG_TRACE ,("==>rt_ioctl_siwencode::DefaultKeyId=%x, KeyLen = %d\n",pAdapter->StaCfg.DefaultKeyId , pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].KeyLen));
1687 DBGPRINT(RT_DEBUG_TRACE ,("==>rt_ioctl_siwencode::WepStatus=%x\n",pAdapter->StaCfg.WepStatus));
1692 rt_ioctl_giwencode(struct net_device *dev,
1693 struct iw_request_info *info,
1694 struct iw_point *erq, char *key)
1697 PRTMP_ADAPTER pAdapter = NULL;
1698 VIRTUAL_ADAPTER *pVirtualAd = NULL;
1700 if (dev->priv_flags == INT_MAIN)
1702 pAdapter = dev->ml_priv;
1706 pVirtualAd = dev->ml_priv;
1707 if (pVirtualAd && pVirtualAd->RtmpDev)
1708 pAdapter = pVirtualAd->RtmpDev->ml_priv;
1711 if (pAdapter == NULL)
1713 /* if 1st open fail, pAd will be free;
1714 So the net_dev->ml_priv will be NULL in 2rd open */
1718 //check if the interface is down
1719 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1721 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1725 kid = erq->flags & IW_ENCODE_INDEX;
1726 DBGPRINT(RT_DEBUG_TRACE, ("===>rt_ioctl_giwencode %d\n", erq->flags & IW_ENCODE_INDEX));
1728 if (pAdapter->StaCfg.WepStatus == Ndis802_11WEPDisabled)
1731 erq->flags = IW_ENCODE_DISABLED;
1733 else if ((kid > 0) && (kid <=4))
1736 erq->flags = kid ; /* NB: base 1 */
1737 if (erq->length > pAdapter->SharedKey[BSS0][kid-1].KeyLen)
1738 erq->length = pAdapter->SharedKey[BSS0][kid-1].KeyLen;
1739 memcpy(key, pAdapter->SharedKey[BSS0][kid-1].Key, erq->length);
1740 //if ((kid == pAdapter->PortCfg.DefaultKeyId))
1741 //erq->flags |= IW_ENCODE_ENABLED; /* XXX */
1742 if (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeShared)
1743 erq->flags |= IW_ENCODE_RESTRICTED; /* XXX */
1745 erq->flags |= IW_ENCODE_OPEN; /* XXX */
1750 if (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeShared)
1751 erq->flags |= IW_ENCODE_RESTRICTED; /* XXX */
1753 erq->flags |= IW_ENCODE_OPEN; /* XXX */
1754 erq->length = pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].KeyLen;
1755 memcpy(key, pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].Key, erq->length);
1756 // copy default key ID
1757 if (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeShared)
1758 erq->flags |= IW_ENCODE_RESTRICTED; /* XXX */
1760 erq->flags |= IW_ENCODE_OPEN; /* XXX */
1761 erq->flags = pAdapter->StaCfg.DefaultKeyId + 1; /* NB: base 1 */
1762 erq->flags |= IW_ENCODE_ENABLED; /* XXX */
1770 rt_ioctl_setparam(struct net_device *dev, struct iw_request_info *info,
1771 void *w, char *extra)
1773 VIRTUAL_ADAPTER *pVirtualAd = NULL;
1774 PRTMP_ADAPTER pAdapter;
1776 char *this_char = extra;
1780 if (dev->priv_flags == INT_MAIN)
1782 pAdapter = dev->ml_priv;
1786 pVirtualAd = dev->ml_priv;
1787 pAdapter = pVirtualAd->RtmpDev->ml_priv;
1789 pObj = (POS_COOKIE) pAdapter->OS_Cookie;
1791 if (pAdapter == NULL)
1793 /* if 1st open fail, pAd will be free;
1794 So the net_dev->ml_priv will be NULL in 2rd open */
1799 pObj->ioctl_if_type = INT_MAIN;
1800 pObj->ioctl_if = MAIN_MBSSID;
1803 //check if the interface is down
1804 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1806 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1813 if ((value = rtstrchr(this_char, '=')) != NULL)
1819 // reject setting nothing besides ANY ssid(ssidLen=0)
1820 if (!*value && (strcmp(this_char, "SSID") != 0))
1823 for (PRTMP_PRIVATE_SET_PROC = RTMP_PRIVATE_SUPPORT_PROC; PRTMP_PRIVATE_SET_PROC->name; PRTMP_PRIVATE_SET_PROC++)
1825 if (strcmp(this_char, PRTMP_PRIVATE_SET_PROC->name) == 0)
1827 if(!PRTMP_PRIVATE_SET_PROC->set_proc(pAdapter, value))
1828 { //FALSE:Set private failed then return Invalid argument
1831 break; //Exit for loop.
1835 if(PRTMP_PRIVATE_SET_PROC->name == NULL)
1836 { //Not found argument
1838 DBGPRINT(RT_DEBUG_TRACE, ("===>rt_ioctl_setparam:: (iwpriv) Not Support Set Command [%s=%s]\n", this_char, value));
1846 rt_private_get_statistics(struct net_device *dev, struct iw_request_info *info,
1847 struct iw_point *wrq, char *extra)
1850 PRTMP_ADAPTER pAd = dev->ml_priv;
1858 memset(extra, 0x00, IW_PRIV_SIZE_MASK);
1859 sprintf(extra, "\n\n");
1862 sprintf(extra+strlen(extra), "Tx success = %ld\n", (ULONG)pAd->WlanCounters.TransmittedFragmentCount.QuadPart);
1863 sprintf(extra+strlen(extra), "Tx success without retry = %ld\n", (ULONG)pAd->WlanCounters.TransmittedFragmentCount.QuadPart - (ULONG)pAd->WlanCounters.RetryCount.QuadPart);
1865 sprintf(extra+strlen(extra), "Tx success after retry = %ld\n", (ULONG)pAd->WlanCounters.RetryCount.QuadPart);
1866 sprintf(extra+strlen(extra), "Tx fail to Rcv ACK after retry = %ld\n", (ULONG)pAd->WlanCounters.FailedCount.QuadPart);
1867 sprintf(extra+strlen(extra), "RTS Success Rcv CTS = %ld\n", (ULONG)pAd->WlanCounters.RTSSuccessCount.QuadPart);
1868 sprintf(extra+strlen(extra), "RTS Fail Rcv CTS = %ld\n", (ULONG)pAd->WlanCounters.RTSFailureCount.QuadPart);
1870 sprintf(extra+strlen(extra), "Rx success = %ld\n", (ULONG)pAd->WlanCounters.ReceivedFragmentCount.QuadPart);
1871 sprintf(extra+strlen(extra), "Rx with CRC = %ld\n", (ULONG)pAd->WlanCounters.FCSErrorCount.QuadPart);
1872 sprintf(extra+strlen(extra), "Rx drop due to out of resource = %ld\n", (ULONG)pAd->Counters8023.RxNoBuffer);
1873 sprintf(extra+strlen(extra), "Rx duplicate frame = %ld\n", (ULONG)pAd->WlanCounters.FrameDuplicateCount.QuadPart);
1875 sprintf(extra+strlen(extra), "False CCA (one second) = %ld\n", (ULONG)pAd->RalinkCounters.OneSecFalseCCACnt);
1877 sprintf(extra+strlen(extra), "RSSI-A = %ld\n", (LONG)(pAd->StaCfg.RssiSample.LastRssi0 - pAd->BbpRssiToDbmDelta));
1878 sprintf(extra+strlen(extra), "RSSI-B (if available) = %ld\n", (LONG)(pAd->StaCfg.RssiSample.LastRssi1 - pAd->BbpRssiToDbmDelta));
1879 sprintf(extra+strlen(extra), "RSSI-C (if available) = %ld\n\n", (LONG)(pAd->StaCfg.RssiSample.LastRssi2 - pAd->BbpRssiToDbmDelta));
1881 sprintf(extra+strlen(extra), "WpaSupplicantUP = %d\n\n", pAd->StaCfg.WpaSupplicantUP);
1883 wrq->length = strlen(extra) + 1; // 1: size of '\0'
1884 DBGPRINT(RT_DEBUG_TRACE, ("<== rt_private_get_statistics, wrq->length = %d\n", wrq->length));
1890 IN PRTMP_ADAPTER pAd,
1894 BA_ORI_ENTRY *pOriBAEntry;
1895 BA_REC_ENTRY *pRecBAEntry;
1897 for (i=0; i<MAX_LEN_OF_MAC_TABLE; i++)
1899 PMAC_TABLE_ENTRY pEntry = &pAd->MacTab.Content[i];
1900 if (((pEntry->ValidAsCLI || pEntry->ValidAsApCli) && (pEntry->Sst == SST_ASSOC))
1901 || (pEntry->ValidAsWDS) || (pEntry->ValidAsMesh))
1903 sprintf(pOutBuf + strlen(pOutBuf), "\n%02X:%02X:%02X:%02X:%02X:%02X (Aid = %d) (AP) -\n",
1904 pEntry->Addr[0], pEntry->Addr[1], pEntry->Addr[2],
1905 pEntry->Addr[3], pEntry->Addr[4], pEntry->Addr[5], pEntry->Aid);
1907 sprintf(pOutBuf, "%s[Recipient]\n", pOutBuf);
1908 for (j=0; j < NUM_OF_TID; j++)
1910 if (pEntry->BARecWcidArray[j] != 0)
1912 pRecBAEntry =&pAd->BATable.BARecEntry[pEntry->BARecWcidArray[j]];
1913 sprintf(pOutBuf + strlen(pOutBuf), "TID=%d, BAWinSize=%d, LastIndSeq=%d, ReorderingPkts=%d\n", j, pRecBAEntry->BAWinSize, pRecBAEntry->LastIndSeq, pRecBAEntry->list.qlen);
1916 sprintf(pOutBuf, "%s\n", pOutBuf);
1918 sprintf(pOutBuf, "%s[Originator]\n", pOutBuf);
1919 for (j=0; j < NUM_OF_TID; j++)
1921 if (pEntry->BAOriWcidArray[j] != 0)
1923 pOriBAEntry =&pAd->BATable.BAOriEntry[pEntry->BAOriWcidArray[j]];
1924 sprintf(pOutBuf + strlen(pOutBuf), "TID=%d, BAWinSize=%d, StartSeq=%d, CurTxSeq=%d\n", j, pOriBAEntry->BAWinSize, pOriBAEntry->Sequence, pEntry->TxSeq[j]);
1927 sprintf(pOutBuf, "%s\n\n", pOutBuf);
1929 if (strlen(pOutBuf) > (IW_PRIV_SIZE_MASK - 30))
1937 rt_private_show(struct net_device *dev, struct iw_request_info *info,
1938 struct iw_point *wrq, char *extra)
1941 VIRTUAL_ADAPTER *pVirtualAd = NULL;
1944 u32 subcmd = wrq->flags;
1946 if (dev->priv_flags == INT_MAIN)
1950 pVirtualAd = dev->ml_priv;
1951 pAd = pVirtualAd->RtmpDev->ml_priv;
1953 pObj = (POS_COOKIE) pAd->OS_Cookie;
1957 /* if 1st open fail, pAd will be free;
1958 So the net_dev->ml_priv will be NULL in 2rd open */
1967 memset(extra, 0x00, IW_PRIV_SIZE_MASK);
1970 pObj->ioctl_if_type = INT_MAIN;
1971 pObj->ioctl_if = MAIN_MBSSID;
1977 case SHOW_CONN_STATUS:
1978 if (MONITOR_ON(pAd))
1980 if (pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED &&
1981 pAd->CommonCfg.RegTransmitSetting.field.BW)
1982 sprintf(extra, "Monitor Mode(CentralChannel %d)\n", pAd->CommonCfg.CentralChannel);
1984 sprintf(extra, "Monitor Mode(Channel %d)\n", pAd->CommonCfg.Channel);
1988 if (pAd->IndicateMediaState == NdisMediaStateConnected)
1992 sprintf(extra, "Connected(AP: %s[%02X:%02X:%02X:%02X:%02X:%02X])\n",
1993 pAd->CommonCfg.Ssid,
1994 pAd->CommonCfg.Bssid[0],
1995 pAd->CommonCfg.Bssid[1],
1996 pAd->CommonCfg.Bssid[2],
1997 pAd->CommonCfg.Bssid[3],
1998 pAd->CommonCfg.Bssid[4],
1999 pAd->CommonCfg.Bssid[5]);
2000 DBGPRINT(RT_DEBUG_TRACE ,("Ssid=%s ,Ssidlen = %d\n",pAd->CommonCfg.Ssid, pAd->CommonCfg.SsidLen));
2002 else if (ADHOC_ON(pAd))
2003 sprintf(extra, "Connected\n");
2007 sprintf(extra, "Disconnected\n");
2008 DBGPRINT(RT_DEBUG_TRACE ,("ConnStatus is not connected\n"));
2011 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2013 case SHOW_DRVIER_VERION:
2014 sprintf(extra, "Driver version-%s, %s %s\n", STA_DRIVER_VERSION, __DATE__, __TIME__ );
2015 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2018 getBaInfo(pAd, extra);
2019 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2021 case SHOW_DESC_INFO:
2023 Show_DescInfo_Proc(pAd, NULL);
2024 wrq->length = 0; // 1: size of '\0'
2028 if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
2030 sprintf(extra, "Scanning\n");
2031 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2034 pAd->StaCfg.bSwRadio = FALSE;
2035 if (pAd->StaCfg.bRadio != (pAd->StaCfg.bHwRadio && pAd->StaCfg.bSwRadio))
2037 pAd->StaCfg.bRadio = (pAd->StaCfg.bHwRadio && pAd->StaCfg.bSwRadio);
2038 if (pAd->StaCfg.bRadio == FALSE)
2041 // Update extra information
2042 pAd->ExtraInfo = SW_RADIO_OFF;
2045 sprintf(extra, "Radio Off\n");
2046 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2049 pAd->StaCfg.bSwRadio = TRUE;
2050 //if (pAd->StaCfg.bRadio != (pAd->StaCfg.bHwRadio && pAd->StaCfg.bSwRadio))
2052 pAd->StaCfg.bRadio = (pAd->StaCfg.bHwRadio && pAd->StaCfg.bSwRadio);
2053 if (pAd->StaCfg.bRadio == TRUE)
2056 // Update extra information
2057 pAd->ExtraInfo = EXTRA_INFO_CLEAR;
2060 sprintf(extra, "Radio On\n");
2061 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2064 case SHOW_CFG_VALUE:
2066 Status = RTMPShowCfgValue(pAd, wrq->pointer, extra);
2068 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2072 DBGPRINT(RT_DEBUG_TRACE, ("%s - unknow subcmd = %d\n", __func__, subcmd));
2080 int rt_ioctl_siwmlme(struct net_device *dev,
2081 struct iw_request_info *info,
2082 union iwreq_data *wrqu,
2085 PRTMP_ADAPTER pAd = dev->ml_priv;
2086 struct iw_mlme *pMlme = (struct iw_mlme *)wrqu->data.pointer;
2087 MLME_QUEUE_ELEM MsgElem;
2088 MLME_DISASSOC_REQ_STRUCT DisAssocReq;
2089 MLME_DEAUTH_REQ_STRUCT DeAuthReq;
2091 DBGPRINT(RT_DEBUG_TRACE, ("====> %s\n", __func__));
2098 #ifdef IW_MLME_DEAUTH
2099 case IW_MLME_DEAUTH:
2100 DBGPRINT(RT_DEBUG_TRACE, ("====> %s - IW_MLME_DEAUTH\n", __func__));
2101 COPY_MAC_ADDR(DeAuthReq.Addr, pAd->CommonCfg.Bssid);
2102 DeAuthReq.Reason = pMlme->reason_code;
2103 MsgElem.MsgLen = sizeof(MLME_DEAUTH_REQ_STRUCT);
2104 NdisMoveMemory(MsgElem.Msg, &DeAuthReq, sizeof(MLME_DEAUTH_REQ_STRUCT));
2105 MlmeDeauthReqAction(pAd, &MsgElem);
2108 LinkDown(pAd, FALSE);
2109 pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
2112 #endif // IW_MLME_DEAUTH //
2113 #ifdef IW_MLME_DISASSOC
2114 case IW_MLME_DISASSOC:
2115 DBGPRINT(RT_DEBUG_TRACE, ("====> %s - IW_MLME_DISASSOC\n", __func__));
2116 COPY_MAC_ADDR(DisAssocReq.Addr, pAd->CommonCfg.Bssid);
2117 DisAssocReq.Reason = pMlme->reason_code;
2119 MsgElem.Machine = ASSOC_STATE_MACHINE;
2120 MsgElem.MsgType = MT2_MLME_DISASSOC_REQ;
2121 MsgElem.MsgLen = sizeof(MLME_DISASSOC_REQ_STRUCT);
2122 NdisMoveMemory(MsgElem.Msg, &DisAssocReq, sizeof(MLME_DISASSOC_REQ_STRUCT));
2124 pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_OID_DISASSOC;
2125 MlmeDisassocReqAction(pAd, &MsgElem);
2127 #endif // IW_MLME_DISASSOC //
2129 DBGPRINT(RT_DEBUG_TRACE, ("====> %s - Unknow Command\n", __func__));
2135 #endif // SIOCSIWMLME //
2137 #if WIRELESS_EXT > 17
2138 int rt_ioctl_siwauth(struct net_device *dev,
2139 struct iw_request_info *info,
2140 union iwreq_data *wrqu, char *extra)
2142 PRTMP_ADAPTER pAdapter = dev->ml_priv;
2143 struct iw_param *param = &wrqu->param;
2145 //check if the interface is down
2146 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
2148 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
2151 switch (param->flags & IW_AUTH_INDEX) {
2152 case IW_AUTH_WPA_VERSION:
2153 if (param->value == IW_AUTH_WPA_VERSION_WPA)
2155 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPAPSK;
2156 if (pAdapter->StaCfg.BssType == BSS_ADHOC)
2157 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPANone;
2159 else if (param->value == IW_AUTH_WPA_VERSION_WPA2)
2160 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA2PSK;
2162 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_WPA_VERSION - param->value = %d!\n", __func__, param->value));
2164 case IW_AUTH_CIPHER_PAIRWISE:
2165 if (param->value == IW_AUTH_CIPHER_NONE)
2167 pAdapter->StaCfg.WepStatus = Ndis802_11WEPDisabled;
2168 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
2169 pAdapter->StaCfg.PairCipher = Ndis802_11WEPDisabled;
2171 else if (param->value == IW_AUTH_CIPHER_WEP40 ||
2172 param->value == IW_AUTH_CIPHER_WEP104)
2174 pAdapter->StaCfg.WepStatus = Ndis802_11WEPEnabled;
2175 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
2176 pAdapter->StaCfg.PairCipher = Ndis802_11WEPEnabled;
2177 pAdapter->StaCfg.IEEE8021X = FALSE;
2179 else if (param->value == IW_AUTH_CIPHER_TKIP)
2181 pAdapter->StaCfg.WepStatus = Ndis802_11Encryption2Enabled;
2182 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
2183 pAdapter->StaCfg.PairCipher = Ndis802_11Encryption2Enabled;
2185 else if (param->value == IW_AUTH_CIPHER_CCMP)
2187 pAdapter->StaCfg.WepStatus = Ndis802_11Encryption3Enabled;
2188 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
2189 pAdapter->StaCfg.PairCipher = Ndis802_11Encryption3Enabled;
2191 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_CIPHER_PAIRWISE - param->value = %d!\n", __func__, param->value));
2193 case IW_AUTH_CIPHER_GROUP:
2194 if (param->value == IW_AUTH_CIPHER_NONE)
2196 pAdapter->StaCfg.GroupCipher = Ndis802_11WEPDisabled;
2198 else if (param->value == IW_AUTH_CIPHER_WEP40 ||
2199 param->value == IW_AUTH_CIPHER_WEP104)
2201 pAdapter->StaCfg.GroupCipher = Ndis802_11WEPEnabled;
2203 else if (param->value == IW_AUTH_CIPHER_TKIP)
2205 pAdapter->StaCfg.GroupCipher = Ndis802_11Encryption2Enabled;
2207 else if (param->value == IW_AUTH_CIPHER_CCMP)
2209 pAdapter->StaCfg.GroupCipher = Ndis802_11Encryption3Enabled;
2211 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_CIPHER_GROUP - param->value = %d!\n", __func__, param->value));
2213 case IW_AUTH_KEY_MGMT:
2214 if (param->value == IW_AUTH_KEY_MGMT_802_1X)
2216 if (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK)
2218 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA;
2219 pAdapter->StaCfg.IEEE8021X = FALSE;
2221 else if (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK)
2223 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA2;
2224 pAdapter->StaCfg.IEEE8021X = FALSE;
2228 pAdapter->StaCfg.IEEE8021X = TRUE;
2230 else if (param->value == 0)
2232 STA_PORT_SECURED(pAdapter);
2234 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_KEY_MGMT - param->value = %d!\n", __func__, param->value));
2236 case IW_AUTH_RX_UNENCRYPTED_EAPOL:
2238 case IW_AUTH_PRIVACY_INVOKED:
2239 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_PRIVACY_INVOKED - param->value = %d!\n", __func__, param->value));
2241 case IW_AUTH_DROP_UNENCRYPTED:
2242 if (param->value != 0)
2243 pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED;
2246 STA_PORT_SECURED(pAdapter);
2248 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_WPA_VERSION - param->value = %d!\n", __func__, param->value));
2250 case IW_AUTH_80211_AUTH_ALG:
2251 if (param->value & IW_AUTH_ALG_SHARED_KEY)
2253 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeShared;
2255 else if (param->value & IW_AUTH_ALG_OPEN_SYSTEM)
2257 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
2261 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_80211_AUTH_ALG - param->value = %d!\n", __func__, param->value));
2263 case IW_AUTH_WPA_ENABLED:
2264 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_WPA_ENABLED - Driver supports WPA!(param->value = %d)\n", __func__, param->value));
2273 int rt_ioctl_giwauth(struct net_device *dev,
2274 struct iw_request_info *info,
2275 union iwreq_data *wrqu, char *extra)
2277 PRTMP_ADAPTER pAdapter = dev->ml_priv;
2278 struct iw_param *param = &wrqu->param;
2280 //check if the interface is down
2281 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
2283 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
2287 switch (param->flags & IW_AUTH_INDEX) {
2288 case IW_AUTH_DROP_UNENCRYPTED:
2289 param->value = (pAdapter->StaCfg.WepStatus == Ndis802_11WEPDisabled) ? 0 : 1;
2292 case IW_AUTH_80211_AUTH_ALG:
2293 param->value = (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeShared) ? IW_AUTH_ALG_SHARED_KEY : IW_AUTH_ALG_OPEN_SYSTEM;
2296 case IW_AUTH_WPA_ENABLED:
2297 param->value = (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA) ? 1 : 0;
2303 DBGPRINT(RT_DEBUG_TRACE, ("rt_ioctl_giwauth::param->value = %d!\n", param->value));
2307 void fnSetCipherKey(
2308 IN PRTMP_ADAPTER pAdapter,
2312 IN struct iw_encode_ext *ext)
2314 RTMP_CLEAR_PSFLAG(pAdapter, fRTMP_PS_CAN_GO_SLEEP);
2315 if (RTMP_TEST_PSFLAG(pAdapter, fRTMP_PS_SET_PCI_CLK_OFF_COMMAND))
2317 if (pAdapter->StaCfg.bRadio == FALSE)
2319 RTMP_SET_PSFLAG(pAdapter, fRTMP_PS_CAN_GO_SLEEP);
2322 DBGPRINT(RT_DEBUG_TRACE,("RTMPWPAAddKeyProc1==>\n"));
2323 RTMPPCIeLinkCtrlValueRestore(pAdapter, RESTORE_HALT);
2324 RTMPusecDelay(6000);
2325 pAdapter->bPCIclkOff = FALSE;
2328 NdisZeroMemory(&pAdapter->SharedKey[BSS0][keyIdx], sizeof(CIPHER_KEY));
2329 pAdapter->SharedKey[BSS0][keyIdx].KeyLen = LEN_TKIP_EK;
2330 NdisMoveMemory(pAdapter->SharedKey[BSS0][keyIdx].Key, ext->key, LEN_TKIP_EK);
2331 NdisMoveMemory(pAdapter->SharedKey[BSS0][keyIdx].TxMic, ext->key + LEN_TKIP_EK, LEN_TKIP_TXMICK);
2332 NdisMoveMemory(pAdapter->SharedKey[BSS0][keyIdx].RxMic, ext->key + LEN_TKIP_EK + LEN_TKIP_TXMICK, LEN_TKIP_RXMICK);
2333 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CipherAlg;
2335 // Update group key information to ASIC Shared Key Table
2336 AsicAddSharedKeyEntry(pAdapter,
2339 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg,
2340 pAdapter->SharedKey[BSS0][keyIdx].Key,
2341 pAdapter->SharedKey[BSS0][keyIdx].TxMic,
2342 pAdapter->SharedKey[BSS0][keyIdx].RxMic);
2345 // Update ASIC WCID attribute table and IVEIV table
2346 RTMPAddWcidAttributeEntry(pAdapter,
2349 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg,
2352 // Update ASIC WCID attribute table and IVEIV table
2353 RTMPAddWcidAttributeEntry(pAdapter,
2356 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg,
2357 &pAdapter->MacTab.Content[BSSID_WCID]);
2359 RTMP_SET_PSFLAG(pAdapter, fRTMP_PS_CAN_GO_SLEEP);
2362 int rt_ioctl_siwencodeext(struct net_device *dev,
2363 struct iw_request_info *info,
2364 union iwreq_data *wrqu,
2367 PRTMP_ADAPTER pAdapter = dev->ml_priv;
2368 struct iw_point *encoding = &wrqu->encoding;
2369 struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
2370 int keyIdx, alg = ext->alg;
2372 //check if the interface is down
2373 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
2375 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
2379 if (encoding->flags & IW_ENCODE_DISABLED)
2381 keyIdx = (encoding->flags & IW_ENCODE_INDEX) - 1;
2382 // set BSSID wcid entry of the Pair-wise Key table as no-security mode
2383 AsicRemovePairwiseKeyEntry(pAdapter, BSS0, BSSID_WCID);
2384 pAdapter->SharedKey[BSS0][keyIdx].KeyLen = 0;
2385 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CIPHER_NONE;
2386 AsicRemoveSharedKeyEntry(pAdapter, 0, (UCHAR)keyIdx);
2387 NdisZeroMemory(&pAdapter->SharedKey[BSS0][keyIdx], sizeof(CIPHER_KEY));
2388 DBGPRINT(RT_DEBUG_TRACE, ("%s::Remove all keys!(encoding->flags = %x)\n", __func__, encoding->flags));
2392 // Get Key Index and convet to our own defined key index
2393 keyIdx = (encoding->flags & IW_ENCODE_INDEX) - 1;
2394 if((keyIdx < 0) || (keyIdx >= NR_WEP_KEYS))
2397 if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
2399 pAdapter->StaCfg.DefaultKeyId = keyIdx;
2400 DBGPRINT(RT_DEBUG_TRACE, ("%s::DefaultKeyId = %d\n", __func__, pAdapter->StaCfg.DefaultKeyId));
2404 case IW_ENCODE_ALG_NONE:
2405 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_ENCODE_ALG_NONE\n", __func__));
2407 case IW_ENCODE_ALG_WEP:
2408 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_ENCODE_ALG_WEP - ext->key_len = %d, keyIdx = %d\n", __func__, ext->key_len, keyIdx));
2409 if (ext->key_len == MAX_WEP_KEY_SIZE)
2411 pAdapter->SharedKey[BSS0][keyIdx].KeyLen = MAX_WEP_KEY_SIZE;
2412 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CIPHER_WEP128;
2414 else if (ext->key_len == MIN_WEP_KEY_SIZE)
2416 pAdapter->SharedKey[BSS0][keyIdx].KeyLen = MIN_WEP_KEY_SIZE;
2417 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CIPHER_WEP64;
2422 NdisZeroMemory(pAdapter->SharedKey[BSS0][keyIdx].Key, 16);
2423 NdisMoveMemory(pAdapter->SharedKey[BSS0][keyIdx].Key, ext->key, ext->key_len);
2425 if (pAdapter->StaCfg.GroupCipher == Ndis802_11GroupWEP40Enabled ||
2426 pAdapter->StaCfg.GroupCipher == Ndis802_11GroupWEP104Enabled)
2428 // Set Group key material to Asic
2429 AsicAddSharedKeyEntry(pAdapter, BSS0, keyIdx, pAdapter->SharedKey[BSS0][keyIdx].CipherAlg, pAdapter->SharedKey[BSS0][keyIdx].Key, NULL, NULL);
2431 // Update WCID attribute table and IVEIV table for this group key table
2432 RTMPAddWcidAttributeEntry(pAdapter, BSS0, keyIdx, pAdapter->SharedKey[BSS0][keyIdx].CipherAlg, NULL);
2434 STA_PORT_SECURED(pAdapter);
2436 // Indicate Connected for GUI
2437 pAdapter->IndicateMediaState = NdisMediaStateConnected;
2440 case IW_ENCODE_ALG_TKIP:
2441 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_ENCODE_ALG_TKIP - keyIdx = %d, ext->key_len = %d\n", __func__, keyIdx, ext->key_len));
2442 if (ext->key_len == 32)
2444 if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
2446 fnSetCipherKey(pAdapter, keyIdx, CIPHER_TKIP, FALSE, ext);
2447 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA2)
2449 STA_PORT_SECURED(pAdapter);
2452 else if (ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY)
2454 fnSetCipherKey(pAdapter, keyIdx, CIPHER_TKIP, TRUE, ext);
2456 // set 802.1x port control
2457 STA_PORT_SECURED(pAdapter);
2463 case IW_ENCODE_ALG_CCMP:
2464 if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
2466 fnSetCipherKey(pAdapter, keyIdx, CIPHER_AES, FALSE, ext);
2467 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA2)
2468 STA_PORT_SECURED(pAdapter);
2470 else if (ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY)
2472 fnSetCipherKey(pAdapter, keyIdx, CIPHER_AES, TRUE, ext);
2474 // set 802.1x port control
2475 STA_PORT_SECURED(pAdapter);
2487 rt_ioctl_giwencodeext(struct net_device *dev,
2488 struct iw_request_info *info,
2489 union iwreq_data *wrqu, char *extra)
2491 PRTMP_ADAPTER pAd = dev->ml_priv;
2493 struct iw_point *encoding = &wrqu->encoding;
2494 struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
2495 int idx, max_key_len;
2497 DBGPRINT(RT_DEBUG_TRACE ,("===> rt_ioctl_giwencodeext\n"));
2499 max_key_len = encoding->length - sizeof(*ext);
2500 if (max_key_len < 0)
2503 idx = encoding->flags & IW_ENCODE_INDEX;
2506 if (idx < 1 || idx > 4)
2510 if ((pAd->StaCfg.WepStatus == Ndis802_11Encryption2Enabled) ||
2511 (pAd->StaCfg.WepStatus == Ndis802_11Encryption3Enabled))
2513 if (idx != pAd->StaCfg.DefaultKeyId)
2521 idx = pAd->StaCfg.DefaultKeyId;
2523 encoding->flags = idx + 1;
2524 memset(ext, 0, sizeof(*ext));
2527 switch(pAd->StaCfg.WepStatus) {
2528 case Ndis802_11WEPDisabled:
2529 ext->alg = IW_ENCODE_ALG_NONE;
2530 encoding->flags |= IW_ENCODE_DISABLED;
2532 case Ndis802_11WEPEnabled:
2533 ext->alg = IW_ENCODE_ALG_WEP;
2534 if (pAd->SharedKey[BSS0][idx].KeyLen > max_key_len)
2538 ext->key_len = pAd->SharedKey[BSS0][idx].KeyLen;
2539 pKey = &(pAd->SharedKey[BSS0][idx].Key[0]);
2542 case Ndis802_11Encryption2Enabled:
2543 case Ndis802_11Encryption3Enabled:
2544 if (pAd->StaCfg.WepStatus == Ndis802_11Encryption2Enabled)
2545 ext->alg = IW_ENCODE_ALG_TKIP;
2547 ext->alg = IW_ENCODE_ALG_CCMP;
2549 if (max_key_len < 32)
2554 pKey = &pAd->StaCfg.PMK[0];
2561 if (ext->key_len && pKey)
2563 encoding->flags |= IW_ENCODE_ENABLED;
2564 memcpy(ext->key, pKey, ext->key_len);
2571 int rt_ioctl_siwgenie(struct net_device *dev,
2572 struct iw_request_info *info,
2573 union iwreq_data *wrqu, char *extra)
2575 PRTMP_ADAPTER pAd = dev->ml_priv;
2577 if (wrqu->data.length > MAX_LEN_OF_RSNIE ||
2578 (wrqu->data.length && extra == NULL))
2581 if (wrqu->data.length)
2583 pAd->StaCfg.RSNIE_Len = wrqu->data.length;
2584 NdisMoveMemory(&pAd->StaCfg.RSN_IE[0], extra, pAd->StaCfg.RSNIE_Len);
2588 pAd->StaCfg.RSNIE_Len = 0;
2589 NdisZeroMemory(&pAd->StaCfg.RSN_IE[0], MAX_LEN_OF_RSNIE);
2594 #endif // SIOCSIWGENIE //
2596 int rt_ioctl_giwgenie(struct net_device *dev,
2597 struct iw_request_info *info,
2598 union iwreq_data *wrqu, char *extra)
2600 PRTMP_ADAPTER pAd = dev->ml_priv;
2602 if ((pAd->StaCfg.RSNIE_Len == 0) ||
2603 (pAd->StaCfg.AuthMode < Ndis802_11AuthModeWPA))
2605 wrqu->data.length = 0;
2610 if (pAd->StaCfg.WpaSupplicantUP == WPA_SUPPLICANT_ENABLE)
2612 if (wrqu->data.length < pAd->StaCfg.RSNIE_Len)
2615 wrqu->data.length = pAd->StaCfg.RSNIE_Len;
2616 memcpy(extra, &pAd->StaCfg.RSN_IE[0], pAd->StaCfg.RSNIE_Len);
2619 #endif // SIOCSIWGENIE //
2621 UCHAR RSNIe = IE_WPA;
2623 if (wrqu->data.length < (pAd->StaCfg.RSNIE_Len + 2)) // ID, Len
2625 wrqu->data.length = pAd->StaCfg.RSNIE_Len + 2;
2627 if ((pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK) ||
2628 (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2))
2631 extra[0] = (char)RSNIe;
2632 extra[1] = pAd->StaCfg.RSNIE_Len;
2633 memcpy(extra+2, &pAd->StaCfg.RSN_IE[0], pAd->StaCfg.RSNIE_Len);
2639 int rt_ioctl_siwpmksa(struct net_device *dev,
2640 struct iw_request_info *info,
2641 union iwreq_data *wrqu,
2644 PRTMP_ADAPTER pAd = dev->ml_priv;
2645 struct iw_pmksa *pPmksa = (struct iw_pmksa *)wrqu->data.pointer;
2646 INT CachedIdx = 0, idx = 0;
2651 DBGPRINT(RT_DEBUG_TRACE ,("===> rt_ioctl_siwpmksa\n"));
2654 case IW_PMKSA_FLUSH:
2655 NdisZeroMemory(pAd->StaCfg.SavedPMK, sizeof(BSSID_INFO)*PMKID_NO);
2656 DBGPRINT(RT_DEBUG_TRACE ,("rt_ioctl_siwpmksa - IW_PMKSA_FLUSH\n"));
2658 case IW_PMKSA_REMOVE:
2659 for (CachedIdx = 0; CachedIdx < pAd->StaCfg.SavedPMKNum; CachedIdx++)
2661 // compare the BSSID
2662 if (NdisEqualMemory(pPmksa->bssid.sa_data, pAd->StaCfg.SavedPMK[CachedIdx].BSSID, MAC_ADDR_LEN))
2664 NdisZeroMemory(pAd->StaCfg.SavedPMK[CachedIdx].BSSID, MAC_ADDR_LEN);
2665 NdisZeroMemory(pAd->StaCfg.SavedPMK[CachedIdx].PMKID, 16);
2666 for (idx = CachedIdx; idx < (pAd->StaCfg.SavedPMKNum - 1); idx++)
2668 NdisMoveMemory(&pAd->StaCfg.SavedPMK[idx].BSSID[0], &pAd->StaCfg.SavedPMK[idx+1].BSSID[0], MAC_ADDR_LEN);
2669 NdisMoveMemory(&pAd->StaCfg.SavedPMK[idx].PMKID[0], &pAd->StaCfg.SavedPMK[idx+1].PMKID[0], 16);
2671 pAd->StaCfg.SavedPMKNum--;
2676 DBGPRINT(RT_DEBUG_TRACE ,("rt_ioctl_siwpmksa - IW_PMKSA_REMOVE\n"));
2679 for (CachedIdx = 0; CachedIdx < pAd->StaCfg.SavedPMKNum; CachedIdx++)
2681 // compare the BSSID
2682 if (NdisEqualMemory(pPmksa->bssid.sa_data, pAd->StaCfg.SavedPMK[CachedIdx].BSSID, MAC_ADDR_LEN))
2686 // Found, replace it
2687 if (CachedIdx < PMKID_NO)
2689 DBGPRINT(RT_DEBUG_OFF, ("Update PMKID, idx = %d\n", CachedIdx));
2690 NdisMoveMemory(&pAd->StaCfg.SavedPMK[CachedIdx].BSSID[0], pPmksa->bssid.sa_data, MAC_ADDR_LEN);
2691 NdisMoveMemory(&pAd->StaCfg.SavedPMK[CachedIdx].PMKID[0], pPmksa->pmkid, 16);
2692 pAd->StaCfg.SavedPMKNum++;
2694 // Not found, replace the last one
2697 // Randomly replace one
2698 CachedIdx = (pPmksa->bssid.sa_data[5] % PMKID_NO);
2699 DBGPRINT(RT_DEBUG_OFF, ("Update PMKID, idx = %d\n", CachedIdx));
2700 NdisMoveMemory(&pAd->StaCfg.SavedPMK[CachedIdx].BSSID[0], pPmksa->bssid.sa_data, MAC_ADDR_LEN);
2701 NdisMoveMemory(&pAd->StaCfg.SavedPMK[CachedIdx].PMKID[0], pPmksa->pmkid, 16);
2704 DBGPRINT(RT_DEBUG_TRACE ,("rt_ioctl_siwpmksa - IW_PMKSA_ADD\n"));
2707 DBGPRINT(RT_DEBUG_TRACE ,("rt_ioctl_siwpmksa - Unknow Command!!\n"));
2713 #endif // #if WIRELESS_EXT > 17
2717 rt_private_ioctl_bbp(struct net_device *dev, struct iw_request_info *info,
2718 struct iw_point *wrq, char *extra)
2725 BOOLEAN bIsPrintAllBBP = FALSE;
2727 PRTMP_ADAPTER pAdapter = dev->ml_priv;
2730 memset(extra, 0x00, IW_PRIV_SIZE_MASK);
2732 if (wrq->length > 1) //No parameters.
2734 sprintf(extra, "\n");
2736 //Parsing Read or Write
2737 this_char = wrq->pointer;
2738 DBGPRINT(RT_DEBUG_TRACE, ("this_char=%s\n", this_char));
2742 if ((value = rtstrchr(this_char, '=')) != NULL)
2745 if (!value || !*value)
2747 DBGPRINT(RT_DEBUG_TRACE, ("this_char=%s, value=%s\n", this_char, value));
2748 if (sscanf(this_char, "%d", &(bbpId)) == 1)
2753 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, ®BBP);
2755 sprintf(extra+strlen(extra), "R%02d[0x%02X]:%02X\n", bbpId, bbpId*2, regBBP);
2756 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2757 DBGPRINT(RT_DEBUG_TRACE, ("msg=%s\n", extra));
2760 {//Invalid parametes, so default printk all bbp
2761 bIsPrintAllBBP = TRUE;
2766 { //Invalid parametes, so default printk all bbp
2767 bIsPrintAllBBP = TRUE;
2773 if ((sscanf(this_char, "%d", &(bbpId)) == 1) && (sscanf(value, "%x", &(bbpValue)) == 1))
2778 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, bbpId, bbpValue);
2779 //Read it back for showing
2780 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, ®BBP);
2782 sprintf(extra+strlen(extra), "R%02d[0x%02X]:%02X\n", bbpId, bbpId*2, regBBP);
2783 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2784 DBGPRINT(RT_DEBUG_TRACE, ("msg=%s\n", extra));
2787 {//Invalid parametes, so default printk all bbp
2788 bIsPrintAllBBP = TRUE;
2793 { //Invalid parametes, so default printk all bbp
2794 bIsPrintAllBBP = TRUE;
2800 bIsPrintAllBBP = TRUE;
2805 memset(extra, 0x00, IW_PRIV_SIZE_MASK);
2806 sprintf(extra, "\n");
2807 for (bbpId = 0; bbpId <= 136; bbpId++)
2809 if (strlen(extra) >= (IW_PRIV_SIZE_MASK - 10))
2811 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, ®BBP);
2812 sprintf(extra+strlen(extra), "R%02d[0x%02X]:%02X ", bbpId, bbpId*2, regBBP);
2814 sprintf(extra+strlen(extra), "\n");
2817 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2818 DBGPRINT(RT_DEBUG_TRACE, ("wrq->length = %d\n", wrq->length));
2821 DBGPRINT(RT_DEBUG_TRACE, ("<==rt_private_ioctl_bbp\n\n"));
2827 int rt_ioctl_siwrate(struct net_device *dev,
2828 struct iw_request_info *info,
2829 union iwreq_data *wrqu, char *extra)
2831 PRTMP_ADAPTER pAd = dev->ml_priv;
2832 UINT32 rate = wrqu->bitrate.value, fixed = wrqu->bitrate.fixed;
2834 //check if the interface is down
2835 if(!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_IN_USE))
2837 DBGPRINT(RT_DEBUG_TRACE, ("rt_ioctl_siwrate::Network is down!\n"));
2841 DBGPRINT(RT_DEBUG_TRACE, ("rt_ioctl_siwrate::(rate = %d, fixed = %d)\n", rate, fixed));
2842 /* rate = -1 => auto rate
2843 rate = X, fixed = 1 => (fixed rate X)
2848 pAd->StaCfg.DesiredTransmitSetting.field.MCS = MCS_AUTO;
2849 pAd->StaCfg.bAutoTxRateSwitch = TRUE;
2850 if ((pAd->CommonCfg.PhyMode <= PHY_11G) ||
2851 (pAd->MacTab.Content[BSSID_WCID].HTPhyMode.field.MODE <= MODE_OFDM))
2852 RTMPSetDesiredRates(pAd, -1);
2860 pAd->StaCfg.bAutoTxRateSwitch = FALSE;
2861 if ((pAd->CommonCfg.PhyMode <= PHY_11G) ||
2862 (pAd->MacTab.Content[BSSID_WCID].HTPhyMode.field.MODE <= MODE_OFDM))
2863 RTMPSetDesiredRates(pAd, rate);
2866 pAd->StaCfg.DesiredTransmitSetting.field.MCS = MCS_AUTO;
2869 DBGPRINT(RT_DEBUG_TRACE, ("rt_ioctl_siwrate::(HtMcs=%d)\n",pAd->StaCfg.DesiredTransmitSetting.field.MCS));
2873 // TODO: rate = X, fixed = 0 => (rates <= X)
2881 int rt_ioctl_giwrate(struct net_device *dev,
2882 struct iw_request_info *info,
2883 union iwreq_data *wrqu, char *extra)
2885 PRTMP_ADAPTER pAd = dev->ml_priv;
2886 int rate_index = 0, rate_count = 0;
2887 HTTRANSMIT_SETTING ht_setting;
2888 __s32 ralinkrate[] =
2889 {2, 4, 11, 22, // CCK
2890 12, 18, 24, 36, 48, 72, 96, 108, // OFDM
2891 13, 26, 39, 52, 78, 104, 117, 130, 26, 52, 78, 104, 156, 208, 234, 260, // 20MHz, 800ns GI, MCS: 0 ~ 15
2892 39, 78, 117, 156, 234, 312, 351, 390, // 20MHz, 800ns GI, MCS: 16 ~ 23
2893 27, 54, 81, 108, 162, 216, 243, 270, 54, 108, 162, 216, 324, 432, 486, 540, // 40MHz, 800ns GI, MCS: 0 ~ 15
2894 81, 162, 243, 324, 486, 648, 729, 810, // 40MHz, 800ns GI, MCS: 16 ~ 23
2895 14, 29, 43, 57, 87, 115, 130, 144, 29, 59, 87, 115, 173, 230, 260, 288, // 20MHz, 400ns GI, MCS: 0 ~ 15
2896 43, 87, 130, 173, 260, 317, 390, 433, // 20MHz, 400ns GI, MCS: 16 ~ 23
2897 30, 60, 90, 120, 180, 240, 270, 300, 60, 120, 180, 240, 360, 480, 540, 600, // 40MHz, 400ns GI, MCS: 0 ~ 15
2898 90, 180, 270, 360, 540, 720, 810, 900}; // 40MHz, 400ns GI, MCS: 16 ~ 23
2900 rate_count = sizeof(ralinkrate)/sizeof(__s32);
2901 //check if the interface is down
2902 if(!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_IN_USE))
2904 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
2908 if ((pAd->StaCfg.bAutoTxRateSwitch == FALSE) &&
2910 ((pAd->CommonCfg.PhyMode <= PHY_11G) || (pAd->MacTab.Content[BSSID_WCID].HTPhyMode.field.MODE <= MODE_OFDM)))
2911 ht_setting.word = pAd->StaCfg.HTPhyMode.word;
2913 ht_setting.word = pAd->MacTab.Content[BSSID_WCID].HTPhyMode.word;
2915 if (ht_setting.field.MODE >= MODE_HTMIX)
2917 rate_index = 12 + ((UCHAR)ht_setting.field.BW *24) + ((UCHAR)ht_setting.field.ShortGI *48) + ((UCHAR)ht_setting.field.MCS);
2920 if (ht_setting.field.MODE == MODE_OFDM)
2921 rate_index = (UCHAR)(ht_setting.field.MCS) + 4;
2922 else if (ht_setting.field.MODE == MODE_CCK)
2923 rate_index = (UCHAR)(ht_setting.field.MCS);
2928 if (rate_index > rate_count)
2929 rate_index = rate_count;
2931 wrqu->bitrate.value = ralinkrate[rate_index] * 500000;
2932 wrqu->bitrate.disabled = 0;
2937 static const iw_handler rt_handler[] =
2939 (iw_handler) NULL, /* SIOCSIWCOMMIT */
2940 (iw_handler) rt_ioctl_giwname, /* SIOCGIWNAME */
2941 (iw_handler) NULL, /* SIOCSIWNWID */
2942 (iw_handler) NULL, /* SIOCGIWNWID */
2943 (iw_handler) rt_ioctl_siwfreq, /* SIOCSIWFREQ */
2944 (iw_handler) rt_ioctl_giwfreq, /* SIOCGIWFREQ */
2945 (iw_handler) rt_ioctl_siwmode, /* SIOCSIWMODE */
2946 (iw_handler) rt_ioctl_giwmode, /* SIOCGIWMODE */
2947 (iw_handler) NULL, /* SIOCSIWSENS */
2948 (iw_handler) NULL, /* SIOCGIWSENS */
2949 (iw_handler) NULL /* not used */, /* SIOCSIWRANGE */
2950 (iw_handler) rt_ioctl_giwrange, /* SIOCGIWRANGE */
2951 (iw_handler) NULL /* not used */, /* SIOCSIWPRIV */
2952 (iw_handler) NULL /* kernel code */, /* SIOCGIWPRIV */
2953 (iw_handler) NULL /* not used */, /* SIOCSIWSTATS */
2954 (iw_handler) rt28xx_get_wireless_stats /* kernel code */, /* SIOCGIWSTATS */
2955 (iw_handler) NULL, /* SIOCSIWSPY */
2956 (iw_handler) NULL, /* SIOCGIWSPY */
2957 (iw_handler) NULL, /* SIOCSIWTHRSPY */
2958 (iw_handler) NULL, /* SIOCGIWTHRSPY */
2959 (iw_handler) rt_ioctl_siwap, /* SIOCSIWAP */
2960 (iw_handler) rt_ioctl_giwap, /* SIOCGIWAP */
2962 (iw_handler) rt_ioctl_siwmlme, /* SIOCSIWMLME */
2964 (iw_handler) NULL, /* SIOCSIWMLME */
2965 #endif // SIOCSIWMLME //
2966 (iw_handler) rt_ioctl_iwaplist, /* SIOCGIWAPLIST */
2968 (iw_handler) rt_ioctl_siwscan, /* SIOCSIWSCAN */
2969 (iw_handler) rt_ioctl_giwscan, /* SIOCGIWSCAN */
2971 (iw_handler) NULL, /* SIOCSIWSCAN */
2972 (iw_handler) NULL, /* SIOCGIWSCAN */
2973 #endif /* SIOCGIWSCAN */
2974 (iw_handler) rt_ioctl_siwessid, /* SIOCSIWESSID */
2975 (iw_handler) rt_ioctl_giwessid, /* SIOCGIWESSID */
2976 (iw_handler) rt_ioctl_siwnickn, /* SIOCSIWNICKN */
2977 (iw_handler) rt_ioctl_giwnickn, /* SIOCGIWNICKN */
2978 (iw_handler) NULL, /* -- hole -- */
2979 (iw_handler) NULL, /* -- hole -- */
2980 (iw_handler) rt_ioctl_siwrate, /* SIOCSIWRATE */
2981 (iw_handler) rt_ioctl_giwrate, /* SIOCGIWRATE */
2982 (iw_handler) rt_ioctl_siwrts, /* SIOCSIWRTS */
2983 (iw_handler) rt_ioctl_giwrts, /* SIOCGIWRTS */
2984 (iw_handler) rt_ioctl_siwfrag, /* SIOCSIWFRAG */
2985 (iw_handler) rt_ioctl_giwfrag, /* SIOCGIWFRAG */
2986 (iw_handler) NULL, /* SIOCSIWTXPOW */
2987 (iw_handler) NULL, /* SIOCGIWTXPOW */
2988 (iw_handler) NULL, /* SIOCSIWRETRY */
2989 (iw_handler) NULL, /* SIOCGIWRETRY */
2990 (iw_handler) rt_ioctl_siwencode, /* SIOCSIWENCODE */
2991 (iw_handler) rt_ioctl_giwencode, /* SIOCGIWENCODE */
2992 (iw_handler) NULL, /* SIOCSIWPOWER */
2993 (iw_handler) NULL, /* SIOCGIWPOWER */
2994 (iw_handler) NULL, /* -- hole -- */
2995 (iw_handler) NULL, /* -- hole -- */
2996 #if WIRELESS_EXT > 17
2997 (iw_handler) rt_ioctl_siwgenie, /* SIOCSIWGENIE */
2998 (iw_handler) rt_ioctl_giwgenie, /* SIOCGIWGENIE */
2999 (iw_handler) rt_ioctl_siwauth, /* SIOCSIWAUTH */
3000 (iw_handler) rt_ioctl_giwauth, /* SIOCGIWAUTH */
3001 (iw_handler) rt_ioctl_siwencodeext, /* SIOCSIWENCODEEXT */
3002 (iw_handler) rt_ioctl_giwencodeext, /* SIOCGIWENCODEEXT */
3003 (iw_handler) rt_ioctl_siwpmksa, /* SIOCSIWPMKSA */
3007 static const iw_handler rt_priv_handlers[] = {
3008 (iw_handler) NULL, /* + 0x00 */
3009 (iw_handler) NULL, /* + 0x01 */
3010 #ifndef CONFIG_AP_SUPPORT
3011 (iw_handler) rt_ioctl_setparam, /* + 0x02 */
3013 (iw_handler) NULL, /* + 0x02 */
3014 #endif // CONFIG_AP_SUPPORT //
3016 (iw_handler) rt_private_ioctl_bbp, /* + 0x03 */
3018 (iw_handler) NULL, /* + 0x03 */
3020 (iw_handler) NULL, /* + 0x04 */
3021 (iw_handler) NULL, /* + 0x05 */
3022 (iw_handler) NULL, /* + 0x06 */
3023 (iw_handler) NULL, /* + 0x07 */
3024 (iw_handler) NULL, /* + 0x08 */
3025 (iw_handler) rt_private_get_statistics, /* + 0x09 */
3026 (iw_handler) NULL, /* + 0x0A */
3027 (iw_handler) NULL, /* + 0x0B */
3028 (iw_handler) NULL, /* + 0x0C */
3029 (iw_handler) NULL, /* + 0x0D */
3030 (iw_handler) NULL, /* + 0x0E */
3031 (iw_handler) NULL, /* + 0x0F */
3032 (iw_handler) NULL, /* + 0x10 */
3033 (iw_handler) rt_private_show, /* + 0x11 */
3034 (iw_handler) NULL, /* + 0x12 */
3035 (iw_handler) NULL, /* + 0x13 */
3036 (iw_handler) NULL, /* + 0x15 */
3037 (iw_handler) NULL, /* + 0x17 */
3038 (iw_handler) NULL, /* + 0x18 */
3041 const struct iw_handler_def rt28xx_iw_handler_def =
3043 #define N(a) (sizeof (a) / sizeof (a[0]))
3044 .standard = (iw_handler *) rt_handler,
3045 .num_standard = sizeof(rt_handler) / sizeof(iw_handler),
3046 .private = (iw_handler *) rt_priv_handlers,
3047 .num_private = N(rt_priv_handlers),
3048 .private_args = (struct iw_priv_args *) privtab,
3049 .num_private_args = N(privtab),
3050 #if IW_HANDLER_VERSION >= 7
3051 .get_wireless_stats = rt28xx_get_wireless_stats,
3055 INT RTMPSetInformation(
3056 IN PRTMP_ADAPTER pAdapter,
3057 IN OUT struct ifreq *rq,
3060 struct iwreq *wrq = (struct iwreq *) rq;
3061 NDIS_802_11_SSID Ssid;
3062 NDIS_802_11_MAC_ADDRESS Bssid;
3063 RT_802_11_PHY_MODE PhyMode;
3064 RT_802_11_STA_CONFIG StaConfig;
3065 NDIS_802_11_RATES aryRates;
3066 RT_802_11_PREAMBLE Preamble;
3067 NDIS_802_11_WEP_STATUS WepStatus;
3068 NDIS_802_11_AUTHENTICATION_MODE AuthMode = Ndis802_11AuthModeMax;
3069 NDIS_802_11_NETWORK_INFRASTRUCTURE BssType;
3070 NDIS_802_11_RTS_THRESHOLD RtsThresh;
3071 NDIS_802_11_FRAGMENTATION_THRESHOLD FragThresh;
3072 NDIS_802_11_POWER_MODE PowerMode;
3073 PNDIS_802_11_KEY pKey = NULL;
3074 PNDIS_802_11_WEP pWepKey =NULL;
3075 PNDIS_802_11_REMOVE_KEY pRemoveKey = NULL;
3076 NDIS_802_11_CONFIGURATION Config, *pConfig = NULL;
3077 NDIS_802_11_NETWORK_TYPE NetType;
3080 INT Status = NDIS_STATUS_SUCCESS, MaxPhyMode = PHY_11G;
3083 BOOLEAN StateMachineTouched = FALSE;
3084 OID_SET_HT_PHYMODE HT_PhyMode; //11n ,kathy
3085 PNDIS_802_11_PMKID pPmkId = NULL;
3086 BOOLEAN IEEE8021xState = FALSE;
3087 BOOLEAN IEEE8021x_required_keys = FALSE;
3088 UCHAR wpa_supplicant_enable = 0;
3090 MaxPhyMode = PHY_11N_5G;
3092 DBGPRINT(RT_DEBUG_TRACE, ("-->RTMPSetInformation(), 0x%08x\n", cmd&0x7FFF));
3093 switch(cmd & 0x7FFF) {
3094 case RT_OID_802_11_COUNTRY_REGION:
3095 if (wrq->u.data.length < sizeof(UCHAR))
3097 // Only avaliable when EEPROM not programming
3098 else if (!(pAdapter->CommonCfg.CountryRegion & 0x80) && !(pAdapter->CommonCfg.CountryRegionForABand & 0x80))
3103 Status = copy_from_user(&Country, wrq->u.data.pointer, wrq->u.data.length);
3104 pAdapter->CommonCfg.CountryRegion = (UCHAR)(Country & 0x000000FF);
3105 pAdapter->CommonCfg.CountryRegionForABand = (UCHAR)((Country >> 8) & 0x000000FF);
3106 TmpPhy = pAdapter->CommonCfg.PhyMode;
3107 pAdapter->CommonCfg.PhyMode = 0xff;
3108 // Build all corresponding channel information
3109 RTMPSetPhyMode(pAdapter, TmpPhy);
3110 SetCommonHT(pAdapter);
3111 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_COUNTRY_REGION (A:%d B/G:%d)\n", pAdapter->CommonCfg.CountryRegionForABand,
3112 pAdapter->CommonCfg.CountryRegion));
3115 case OID_802_11_BSSID_LIST_SCAN:
3117 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_BSSID_LIST_SCAN, TxCnt = %d \n", pAdapter->RalinkCounters.LastOneSecTotalTxCount));
3119 if (MONITOR_ON(pAdapter))
3121 DBGPRINT(RT_DEBUG_TRACE, ("!!! Driver is in Monitor Mode now !!!\n"));
3125 //Benson add 20080527, when radio off, sta don't need to scan
3126 if (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_RADIO_OFF))
3129 if (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
3131 DBGPRINT(RT_DEBUG_TRACE, ("!!! Driver is scanning now !!!\n"));
3132 pAdapter->StaCfg.bScanReqIsFromWebUI = TRUE;
3133 Status = NDIS_STATUS_SUCCESS;
3137 if (pAdapter->RalinkCounters.LastOneSecTotalTxCount > 100)
3139 DBGPRINT(RT_DEBUG_TRACE, ("!!! Link UP, ignore this set::OID_802_11_BSSID_LIST_SCAN\n"));
3140 Status = NDIS_STATUS_SUCCESS;
3141 pAdapter->StaCfg.ScanCnt = 99; // Prevent auto scan triggered by this OID
3145 if ((OPSTATUS_TEST_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED)) &&
3146 ((pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA) ||
3147 (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK) ||
3148 (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA2) ||
3149 (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK)) &&
3150 (pAdapter->StaCfg.PortSecured == WPA_802_1X_PORT_NOT_SECURED))
3152 DBGPRINT(RT_DEBUG_TRACE, ("!!! Link UP, Port Not Secured! ignore this set::OID_802_11_BSSID_LIST_SCAN\n"));
3153 Status = NDIS_STATUS_SUCCESS;
3154 pAdapter->StaCfg.ScanCnt = 99; // Prevent auto scan triggered by this OID
3159 if (pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE)
3161 RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
3162 DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
3165 // tell CNTL state machine to call NdisMSetInformationComplete() after completing
3166 // this request, because this request is initiated by NDIS.
3167 pAdapter->MlmeAux.CurrReqIsFromNdis = FALSE;
3168 // Reset allowed scan retries
3169 pAdapter->StaCfg.ScanCnt = 0;
3170 pAdapter->StaCfg.LastScanTime = Now;
3172 pAdapter->StaCfg.bScanReqIsFromWebUI = TRUE;
3173 RTMP_SET_FLAG(pAdapter, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS);
3174 MlmeEnqueue(pAdapter,
3175 MLME_CNTL_STATE_MACHINE,
3176 OID_802_11_BSSID_LIST_SCAN,
3180 Status = NDIS_STATUS_SUCCESS;
3181 StateMachineTouched = TRUE;
3183 case OID_802_11_SSID:
3184 if (wrq->u.data.length != sizeof(NDIS_802_11_SSID))
3188 PCHAR pSsidString = NULL;
3189 Status = copy_from_user(&Ssid, wrq->u.data.pointer, wrq->u.data.length);
3191 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_SSID (Len=%d,Ssid=%s)\n", Ssid.SsidLength, Ssid.Ssid));
3192 if (Ssid.SsidLength > MAX_LEN_OF_SSID)
3196 if (Ssid.SsidLength == 0)
3198 Set_SSID_Proc(pAdapter, "");
3202 pSsidString = (CHAR *) kmalloc(MAX_LEN_OF_SSID+1, MEM_ALLOC_FLAG);
3205 NdisZeroMemory(pSsidString, MAX_LEN_OF_SSID+1);
3206 NdisMoveMemory(pSsidString, Ssid.Ssid, Ssid.SsidLength);
3207 Set_SSID_Proc(pAdapter, pSsidString);
3216 case OID_802_11_BSSID:
3217 if (wrq->u.data.length != sizeof(NDIS_802_11_MAC_ADDRESS))
3221 Status = copy_from_user(&Bssid, wrq->u.data.pointer, wrq->u.data.length);
3223 // tell CNTL state machine to call NdisMSetInformationComplete() after completing
3224 // this request, because this request is initiated by NDIS.
3225 pAdapter->MlmeAux.CurrReqIsFromNdis = FALSE;
3227 // Prevent to connect AP again in STAMlmePeriodicExec
3228 pAdapter->MlmeAux.AutoReconnectSsidLen= 32;
3230 // Reset allowed scan retries
3231 pAdapter->StaCfg.ScanCnt = 0;
3233 if (pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE)
3235 RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
3236 DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
3238 MlmeEnqueue(pAdapter,
3239 MLME_CNTL_STATE_MACHINE,
3241 sizeof(NDIS_802_11_MAC_ADDRESS),
3243 Status = NDIS_STATUS_SUCCESS;
3244 StateMachineTouched = TRUE;
3246 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_BSSID %02x:%02x:%02x:%02x:%02x:%02x\n",
3247 Bssid[0], Bssid[1], Bssid[2], Bssid[3], Bssid[4], Bssid[5]));
3250 case RT_OID_802_11_RADIO:
3251 if (wrq->u.data.length != sizeof(BOOLEAN))
3255 Status = copy_from_user(&RadioState, wrq->u.data.pointer, wrq->u.data.length);
3256 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_RADIO (=%d)\n", RadioState));
3257 if (pAdapter->StaCfg.bSwRadio != RadioState)
3259 pAdapter->StaCfg.bSwRadio = RadioState;
3260 if (pAdapter->StaCfg.bRadio != (pAdapter->StaCfg.bHwRadio && pAdapter->StaCfg.bSwRadio))
3262 pAdapter->StaCfg.bRadio = (pAdapter->StaCfg.bHwRadio && pAdapter->StaCfg.bSwRadio);
3263 if (pAdapter->StaCfg.bRadio == TRUE)
3265 MlmeRadioOn(pAdapter);
3266 // Update extra information
3267 pAdapter->ExtraInfo = EXTRA_INFO_CLEAR;
3271 MlmeRadioOff(pAdapter);
3272 // Update extra information
3273 pAdapter->ExtraInfo = SW_RADIO_OFF;
3279 case RT_OID_802_11_PHY_MODE:
3280 if (wrq->u.data.length != sizeof(RT_802_11_PHY_MODE))
3284 Status = copy_from_user(&PhyMode, wrq->u.data.pointer, wrq->u.data.length);
3285 if (PhyMode <= MaxPhyMode)
3287 RTMPSetPhyMode(pAdapter, PhyMode);
3288 SetCommonHT(pAdapter);
3290 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_PHY_MODE (=%d)\n", PhyMode));
3293 case RT_OID_802_11_STA_CONFIG:
3294 if (wrq->u.data.length != sizeof(RT_802_11_STA_CONFIG))
3298 Status = copy_from_user(&StaConfig, wrq->u.data.pointer, wrq->u.data.length);
3299 pAdapter->CommonCfg.bEnableTxBurst = StaConfig.EnableTxBurst;
3300 pAdapter->CommonCfg.UseBGProtection = StaConfig.UseBGProtection;
3301 pAdapter->CommonCfg.bUseShortSlotTime = 1; // 2003-10-30 always SHORT SLOT capable
3302 if ((pAdapter->CommonCfg.PhyMode != StaConfig.AdhocMode) &&
3303 (StaConfig.AdhocMode <= MaxPhyMode))
3305 // allow dynamic change of "USE OFDM rate or not" in ADHOC mode
3306 // if setting changed, need to reset current TX rate as well as BEACON frame format
3307 if (pAdapter->StaCfg.BssType == BSS_ADHOC)
3309 pAdapter->CommonCfg.PhyMode = StaConfig.AdhocMode;
3310 RTMPSetPhyMode(pAdapter, PhyMode);
3311 MlmeUpdateTxRates(pAdapter, FALSE, 0);
3312 MakeIbssBeacon(pAdapter); // re-build BEACON frame
3313 AsicEnableIbssSync(pAdapter); // copy to on-chip memory
3316 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_SET_STA_CONFIG (Burst=%d, Protection=%ld,ShortSlot=%d\n",
3317 pAdapter->CommonCfg.bEnableTxBurst,
3318 pAdapter->CommonCfg.UseBGProtection,
3319 pAdapter->CommonCfg.bUseShortSlotTime));
3322 case OID_802_11_DESIRED_RATES:
3323 if (wrq->u.data.length != sizeof(NDIS_802_11_RATES))
3327 Status = copy_from_user(&aryRates, wrq->u.data.pointer, wrq->u.data.length);
3328 NdisZeroMemory(pAdapter->CommonCfg.DesireRate, MAX_LEN_OF_SUPPORTED_RATES);
3329 NdisMoveMemory(pAdapter->CommonCfg.DesireRate, &aryRates, sizeof(NDIS_802_11_RATES));
3330 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_DESIRED_RATES (%02x,%02x,%02x,%02x,%02x,%02x,%02x,%02x)\n",
3331 pAdapter->CommonCfg.DesireRate[0],pAdapter->CommonCfg.DesireRate[1],
3332 pAdapter->CommonCfg.DesireRate[2],pAdapter->CommonCfg.DesireRate[3],
3333 pAdapter->CommonCfg.DesireRate[4],pAdapter->CommonCfg.DesireRate[5],
3334 pAdapter->CommonCfg.DesireRate[6],pAdapter->CommonCfg.DesireRate[7] ));
3335 // Changing DesiredRate may affect the MAX TX rate we used to TX frames out
3336 MlmeUpdateTxRates(pAdapter, FALSE, 0);
3339 case RT_OID_802_11_PREAMBLE:
3340 if (wrq->u.data.length != sizeof(RT_802_11_PREAMBLE))
3344 Status = copy_from_user(&Preamble, wrq->u.data.pointer, wrq->u.data.length);
3345 if (Preamble == Rt802_11PreambleShort)
3347 pAdapter->CommonCfg.TxPreamble = Preamble;
3348 MlmeSetTxPreamble(pAdapter, Rt802_11PreambleShort);
3350 else if ((Preamble == Rt802_11PreambleLong) || (Preamble == Rt802_11PreambleAuto))
3352 // if user wants AUTO, initialize to LONG here, then change according to AP's
3353 // capability upon association.
3354 pAdapter->CommonCfg.TxPreamble = Preamble;
3355 MlmeSetTxPreamble(pAdapter, Rt802_11PreambleLong);
3362 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_PREAMBLE (=%d)\n", Preamble));
3365 case OID_802_11_WEP_STATUS:
3366 if (wrq->u.data.length != sizeof(NDIS_802_11_WEP_STATUS))
3370 Status = copy_from_user(&WepStatus, wrq->u.data.pointer, wrq->u.data.length);
3371 // Since TKIP, AES, WEP are all supported. It should not have any invalid setting
3372 if (WepStatus <= Ndis802_11Encryption3KeyAbsent)
3374 if (pAdapter->StaCfg.WepStatus != WepStatus)
3376 // Config has changed
3377 pAdapter->bConfigChanged = TRUE;
3379 pAdapter->StaCfg.WepStatus = WepStatus;
3380 pAdapter->StaCfg.OrigWepStatus = WepStatus;
3381 pAdapter->StaCfg.PairCipher = WepStatus;
3382 pAdapter->StaCfg.GroupCipher = WepStatus;
3389 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_WEP_STATUS (=%d)\n",WepStatus));
3392 case OID_802_11_AUTHENTICATION_MODE:
3393 if (wrq->u.data.length != sizeof(NDIS_802_11_AUTHENTICATION_MODE))
3397 Status = copy_from_user(&AuthMode, wrq->u.data.pointer, wrq->u.data.length);
3398 if (AuthMode > Ndis802_11AuthModeMax)
3405 if (pAdapter->StaCfg.AuthMode != AuthMode)
3407 // Config has changed
3408 pAdapter->bConfigChanged = TRUE;
3410 pAdapter->StaCfg.AuthMode = AuthMode;
3412 pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED;
3413 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_AUTHENTICATION_MODE (=%d) \n",pAdapter->StaCfg.AuthMode));
3416 case OID_802_11_INFRASTRUCTURE_MODE:
3417 if (wrq->u.data.length != sizeof(NDIS_802_11_NETWORK_INFRASTRUCTURE))
3421 Status = copy_from_user(&BssType, wrq->u.data.pointer, wrq->u.data.length);
3423 if (BssType == Ndis802_11IBSS)
3424 Set_NetworkType_Proc(pAdapter, "Adhoc");
3425 else if (BssType == Ndis802_11Infrastructure)
3426 Set_NetworkType_Proc(pAdapter, "Infra");
3427 else if (BssType == Ndis802_11Monitor)
3428 Set_NetworkType_Proc(pAdapter, "Monitor");
3432 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_INFRASTRUCTURE_MODE (unknown)\n"));
3436 case OID_802_11_REMOVE_WEP:
3437 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_WEP\n"));
3438 if (wrq->u.data.length != sizeof(NDIS_802_11_KEY_INDEX))
3444 KeyIdx = *(NDIS_802_11_KEY_INDEX *) wrq->u.data.pointer;
3446 if (KeyIdx & 0x80000000)
3448 // Should never set default bit when remove key
3453 KeyIdx = KeyIdx & 0x0fffffff;
3459 pAdapter->SharedKey[BSS0][KeyIdx].KeyLen = 0;
3460 pAdapter->SharedKey[BSS0][KeyIdx].CipherAlg = CIPHER_NONE;
3461 AsicRemoveSharedKeyEntry(pAdapter, 0, (UCHAR)KeyIdx);
3466 case RT_OID_802_11_RESET_COUNTERS:
3467 NdisZeroMemory(&pAdapter->WlanCounters, sizeof(COUNTER_802_11));
3468 NdisZeroMemory(&pAdapter->Counters8023, sizeof(COUNTER_802_3));
3469 NdisZeroMemory(&pAdapter->RalinkCounters, sizeof(COUNTER_RALINK));
3470 pAdapter->Counters8023.RxNoBuffer = 0;
3471 pAdapter->Counters8023.GoodReceives = 0;
3472 pAdapter->Counters8023.RxNoBuffer = 0;
3473 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_RESET_COUNTERS \n"));
3475 case OID_802_11_RTS_THRESHOLD:
3476 if (wrq->u.data.length != sizeof(NDIS_802_11_RTS_THRESHOLD))
3480 Status = copy_from_user(&RtsThresh, wrq->u.data.pointer, wrq->u.data.length);
3481 if (RtsThresh > MAX_RTS_THRESHOLD)
3484 pAdapter->CommonCfg.RtsThreshold = (USHORT)RtsThresh;
3486 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_RTS_THRESHOLD (=%ld)\n",RtsThresh));
3488 case OID_802_11_FRAGMENTATION_THRESHOLD:
3489 if (wrq->u.data.length != sizeof(NDIS_802_11_FRAGMENTATION_THRESHOLD))
3493 Status = copy_from_user(&FragThresh, wrq->u.data.pointer, wrq->u.data.length);
3494 pAdapter->CommonCfg.bUseZeroToDisableFragment = FALSE;
3495 if (FragThresh > MAX_FRAG_THRESHOLD || FragThresh < MIN_FRAG_THRESHOLD)
3497 if (FragThresh == 0)
3499 pAdapter->CommonCfg.FragmentThreshold = MAX_FRAG_THRESHOLD;
3500 pAdapter->CommonCfg.bUseZeroToDisableFragment = TRUE;
3506 pAdapter->CommonCfg.FragmentThreshold = (USHORT)FragThresh;
3508 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_FRAGMENTATION_THRESHOLD (=%ld) \n",FragThresh));
3510 case OID_802_11_POWER_MODE:
3511 if (wrq->u.data.length != sizeof(NDIS_802_11_POWER_MODE))
3515 Status = copy_from_user(&PowerMode, wrq->u.data.pointer, wrq->u.data.length);
3516 if (PowerMode == Ndis802_11PowerModeCAM)
3517 Set_PSMode_Proc(pAdapter, "CAM");
3518 else if (PowerMode == Ndis802_11PowerModeMAX_PSP)
3519 Set_PSMode_Proc(pAdapter, "Max_PSP");
3520 else if (PowerMode == Ndis802_11PowerModeFast_PSP)
3521 Set_PSMode_Proc(pAdapter, "Fast_PSP");
3522 else if (PowerMode == Ndis802_11PowerModeLegacy_PSP)
3523 Set_PSMode_Proc(pAdapter, "Legacy_PSP");
3527 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_POWER_MODE (=%d)\n",PowerMode));
3529 case RT_OID_802_11_TX_POWER_LEVEL_1:
3530 if (wrq->u.data.length < sizeof(ULONG))
3534 Status = copy_from_user(&PowerTemp, wrq->u.data.pointer, wrq->u.data.length);
3535 if (PowerTemp > 100)
3536 PowerTemp = 0xffffffff; // AUTO
3537 pAdapter->CommonCfg.TxPowerDefault = PowerTemp; //keep current setting.
3538 pAdapter->CommonCfg.TxPowerPercentage = pAdapter->CommonCfg.TxPowerDefault;
3539 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_TX_POWER_LEVEL_1 (=%ld)\n", pAdapter->CommonCfg.TxPowerPercentage));
3542 case OID_802_11_NETWORK_TYPE_IN_USE:
3543 if (wrq->u.data.length != sizeof(NDIS_802_11_NETWORK_TYPE))
3547 Status = copy_from_user(&NetType, wrq->u.data.pointer, wrq->u.data.length);
3549 if (NetType == Ndis802_11DS)
3550 RTMPSetPhyMode(pAdapter, PHY_11B);
3551 else if (NetType == Ndis802_11OFDM24)
3552 RTMPSetPhyMode(pAdapter, PHY_11BG_MIXED);
3553 else if (NetType == Ndis802_11OFDM5)
3554 RTMPSetPhyMode(pAdapter, PHY_11A);
3558 if (Status == NDIS_STATUS_SUCCESS)
3559 SetCommonHT(pAdapter);
3561 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_NETWORK_TYPE_IN_USE (=%d)\n",NetType));
3564 // For WPA PSK PMK key
3565 case RT_OID_802_11_ADD_WPA:
3566 pKey = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
3573 Status = copy_from_user(pKey, wrq->u.data.pointer, wrq->u.data.length);
3574 if (pKey->Length != wrq->u.data.length)
3577 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_ADD_WPA, Failed!!\n"));
3581 if ((pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPAPSK) &&
3582 (pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPA2PSK) &&
3583 (pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPANone) )
3585 Status = -EOPNOTSUPP;
3586 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_ADD_WPA, Failed!! [AuthMode != WPAPSK/WPA2PSK/WPANONE]\n"));
3588 else if ((pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK) ||
3589 (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK) ||
3590 (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPANone) ) // Only for WPA PSK mode
3592 NdisMoveMemory(pAdapter->StaCfg.PMK, &pKey->KeyMaterial, pKey->KeyLength);
3593 // Use RaConfig as PSK agent.
3594 // Start STA supplicant state machine
3595 if (pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPANone)
3596 pAdapter->StaCfg.WpaState = SS_START;
3598 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_ADD_WPA (id=0x%x, Len=%d-byte)\n", pKey->KeyIndex, pKey->KeyLength));
3602 pAdapter->StaCfg.WpaState = SS_NOTUSE;
3603 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_ADD_WPA (id=0x%x, Len=%d-byte)\n", pKey->KeyIndex, pKey->KeyLength));
3608 case OID_802_11_REMOVE_KEY:
3609 pRemoveKey = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
3610 if(pRemoveKey == NULL)
3616 Status = copy_from_user(pRemoveKey, wrq->u.data.pointer, wrq->u.data.length);
3617 if (pRemoveKey->Length != wrq->u.data.length)
3620 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_KEY, Failed!!\n"));
3624 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
3626 RTMPWPARemoveKeyProc(pAdapter, pRemoveKey);
3627 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_KEY, Remove WPA Key!!\n"));
3631 KeyIdx = pRemoveKey->KeyIndex;
3633 if (KeyIdx & 0x80000000)
3635 // Should never set default bit when remove key
3637 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_KEY, Failed!!(Should never set default bit when remove key)\n"));
3641 KeyIdx = KeyIdx & 0x0fffffff;
3645 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_KEY, Failed!!(KeyId[%d] out of range)\n", KeyIdx));
3649 pAdapter->SharedKey[BSS0][KeyIdx].KeyLen = 0;
3650 pAdapter->SharedKey[BSS0][KeyIdx].CipherAlg = CIPHER_NONE;
3651 AsicRemoveSharedKeyEntry(pAdapter, 0, (UCHAR)KeyIdx);
3652 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_KEY (id=0x%x, Len=%d-byte)\n", pRemoveKey->KeyIndex, pRemoveKey->Length));
3660 case OID_802_11_ADD_KEY:
3661 pKey = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
3667 Status = copy_from_user(pKey, wrq->u.data.pointer, wrq->u.data.length);
3668 if (pKey->Length != wrq->u.data.length)
3671 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_KEY, Failed!!\n"));
3675 RTMPAddKey(pAdapter, pKey);
3676 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_KEY (id=0x%x, Len=%d-byte)\n", pKey->KeyIndex, pKey->KeyLength));
3680 case OID_802_11_CONFIGURATION:
3681 if (wrq->u.data.length != sizeof(NDIS_802_11_CONFIGURATION))
3685 Status = copy_from_user(&Config, wrq->u.data.pointer, wrq->u.data.length);
3688 if ((pConfig->BeaconPeriod >= 20) && (pConfig->BeaconPeriod <=400))
3689 pAdapter->CommonCfg.BeaconPeriod = (USHORT) pConfig->BeaconPeriod;
3691 pAdapter->StaActive.AtimWin = (USHORT) pConfig->ATIMWindow;
3692 MAP_KHZ_TO_CHANNEL_ID(pConfig->DSConfig, pAdapter->CommonCfg.Channel);
3694 // Save the channel on MlmeAux for CntlOidRTBssidProc used.
3696 pAdapter->MlmeAux.Channel = pAdapter->CommonCfg.Channel;
3698 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_CONFIGURATION (BeacnPeriod=%ld,AtimW=%ld,Ch=%d)\n",
3699 pConfig->BeaconPeriod, pConfig->ATIMWindow, pAdapter->CommonCfg.Channel));
3700 // Config has changed
3701 pAdapter->bConfigChanged = TRUE;
3704 case RT_OID_802_11_SET_HT_PHYMODE:
3705 if (wrq->u.data.length != sizeof(OID_SET_HT_PHYMODE))
3709 POID_SET_HT_PHYMODE pHTPhyMode = &HT_PhyMode;
3711 Status = copy_from_user(&HT_PhyMode, wrq->u.data.pointer, wrq->u.data.length);
3712 DBGPRINT(RT_DEBUG_TRACE, ("Set::pHTPhyMode (PhyMode = %d,TransmitNo = %d, HtMode = %d, ExtOffset = %d , MCS = %d, BW = %d, STBC = %d, SHORTGI = %d) \n",
3713 pHTPhyMode->PhyMode, pHTPhyMode->TransmitNo,pHTPhyMode->HtMode,pHTPhyMode->ExtOffset,
3714 pHTPhyMode->MCS, pHTPhyMode->BW, pHTPhyMode->STBC, pHTPhyMode->SHORTGI));
3715 if (pAdapter->CommonCfg.PhyMode >= PHY_11ABGN_MIXED)
3716 RTMPSetHT(pAdapter, pHTPhyMode);
3718 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_SET_HT_PHYMODE(MCS=%d,BW=%d,SGI=%d,STBC=%d)\n",
3719 pAdapter->StaCfg.HTPhyMode.field.MCS, pAdapter->StaCfg.HTPhyMode.field.BW, pAdapter->StaCfg.HTPhyMode.field.ShortGI,
3720 pAdapter->StaCfg.HTPhyMode.field.STBC));
3722 case RT_OID_802_11_SET_APSD_SETTING:
3723 if (wrq->u.data.length != sizeof(ULONG))
3728 Status = copy_from_user(&apsd, wrq->u.data.pointer, wrq->u.data.length);
3730 /*-------------------------------------------------------------------
3731 |B31~B7 | B6~B5 | B4 | B3 | B2 | B1 | B0 |
3732 ---------------------------------------------------------------------
3733 | Rsvd | Max SP Len | AC_VO | AC_VI | AC_BK | AC_BE | APSD Capable |
3734 ---------------------------------------------------------------------*/
3735 pAdapter->CommonCfg.bAPSDCapable = (apsd & 0x00000001) ? TRUE : FALSE;
3736 pAdapter->CommonCfg.bAPSDAC_BE = ((apsd & 0x00000002) >> 1) ? TRUE : FALSE;
3737 pAdapter->CommonCfg.bAPSDAC_BK = ((apsd & 0x00000004) >> 2) ? TRUE : FALSE;
3738 pAdapter->CommonCfg.bAPSDAC_VI = ((apsd & 0x00000008) >> 3) ? TRUE : FALSE;
3739 pAdapter->CommonCfg.bAPSDAC_VO = ((apsd & 0x00000010) >> 4) ? TRUE : FALSE;
3740 pAdapter->CommonCfg.MaxSPLength = (UCHAR)((apsd & 0x00000060) >> 5);
3742 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,
3743 pAdapter->CommonCfg.bAPSDAC_BE, pAdapter->CommonCfg.bAPSDAC_BK, pAdapter->CommonCfg.bAPSDAC_VI, pAdapter->CommonCfg.bAPSDAC_VO, pAdapter->CommonCfg.MaxSPLength));
3747 case RT_OID_802_11_SET_APSD_PSM:
3748 if (wrq->u.data.length != sizeof(ULONG))
3752 // Driver needs to notify AP when PSM changes
3753 Status = copy_from_user(&pAdapter->CommonCfg.bAPSDForcePowerSave, wrq->u.data.pointer, wrq->u.data.length);
3754 if (pAdapter->CommonCfg.bAPSDForcePowerSave != pAdapter->StaCfg.Psm)
3756 MlmeSetPsmBit(pAdapter, pAdapter->CommonCfg.bAPSDForcePowerSave);
3757 RTMPSendNullFrame(pAdapter, pAdapter->CommonCfg.TxRate, TRUE);
3759 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_SET_APSD_PSM (bAPSDForcePowerSave:%d)\n", pAdapter->CommonCfg.bAPSDForcePowerSave));
3763 case RT_OID_802_11_SET_WMM:
3764 if (wrq->u.data.length != sizeof(BOOLEAN))
3768 Status = copy_from_user(&pAdapter->CommonCfg.bWmmCapable, wrq->u.data.pointer, wrq->u.data.length);
3769 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_SET_WMM (=%d) \n", pAdapter->CommonCfg.bWmmCapable));
3773 case OID_802_11_DISASSOCIATE:
3775 // Set NdisRadioStateOff to TRUE, instead of called MlmeRadioOff.
3776 // Later on, NDIS_802_11_BSSID_LIST_EX->NumberOfItems should be 0
3777 // when query OID_802_11_BSSID_LIST.
3779 // TRUE: NumberOfItems will set to 0.
3780 // FALSE: NumberOfItems no change.
3782 pAdapter->CommonCfg.NdisRadioStateOff = TRUE;
3783 // Set to immediately send the media disconnect event
3784 pAdapter->MlmeAux.CurrReqIsFromNdis = TRUE;
3785 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_DISASSOCIATE \n"));
3787 if (INFRA_ON(pAdapter))
3789 if (pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE)
3791 RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
3792 DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
3795 MlmeEnqueue(pAdapter,
3796 MLME_CNTL_STATE_MACHINE,
3797 OID_802_11_DISASSOCIATE,
3801 StateMachineTouched = TRUE;
3804 case RT_OID_802_11_SET_IMME_BA_CAP:
3805 if (wrq->u.data.length != sizeof(OID_BACAP_STRUC))
3809 OID_BACAP_STRUC Orde ;
3810 Status = copy_from_user(&Orde, wrq->u.data.pointer, wrq->u.data.length);
3811 if (Orde.Policy > BA_NOTUSE)
3813 Status = NDIS_STATUS_INVALID_DATA;
3815 else if (Orde.Policy == BA_NOTUSE)
3817 pAdapter->CommonCfg.BACapability.field.Policy = BA_NOTUSE;
3818 pAdapter->CommonCfg.BACapability.field.MpduDensity = Orde.MpduDensity;
3819 pAdapter->CommonCfg.DesiredHtPhy.MpduDensity = Orde.MpduDensity;
3820 pAdapter->CommonCfg.DesiredHtPhy.AmsduEnable = Orde.AmsduEnable;
3821 pAdapter->CommonCfg.DesiredHtPhy.AmsduSize= Orde.AmsduSize;
3822 pAdapter->CommonCfg.DesiredHtPhy.MimoPs= Orde.MMPSmode;
3823 pAdapter->CommonCfg.BACapability.field.MMPSmode = Orde.MMPSmode;
3825 pAdapter->CommonCfg.HtCapability.HtCapInfo.MimoPs = Orde.MMPSmode;
3826 pAdapter->CommonCfg.HtCapability.HtCapInfo.AMsduSize = Orde.AmsduSize;
3827 pAdapter->CommonCfg.HtCapability.HtCapParm.MpduDensity = Orde.MpduDensity;
3831 pAdapter->CommonCfg.BACapability.field.AutoBA = Orde.AutoBA;
3832 pAdapter->CommonCfg.BACapability.field.Policy = IMMED_BA; // we only support immediate BA.
3833 pAdapter->CommonCfg.BACapability.field.MpduDensity = Orde.MpduDensity;
3834 pAdapter->CommonCfg.DesiredHtPhy.MpduDensity = Orde.MpduDensity;
3835 pAdapter->CommonCfg.DesiredHtPhy.AmsduEnable = Orde.AmsduEnable;
3836 pAdapter->CommonCfg.DesiredHtPhy.AmsduSize= Orde.AmsduSize;
3837 pAdapter->CommonCfg.DesiredHtPhy.MimoPs = Orde.MMPSmode;
3838 pAdapter->CommonCfg.BACapability.field.MMPSmode = Orde.MMPSmode;
3841 pAdapter->CommonCfg.HtCapability.HtCapInfo.MimoPs = Orde.MMPSmode;
3842 pAdapter->CommonCfg.HtCapability.HtCapInfo.AMsduSize = Orde.AmsduSize;
3843 pAdapter->CommonCfg.HtCapability.HtCapParm.MpduDensity = Orde.MpduDensity;
3845 if (pAdapter->CommonCfg.BACapability.field.RxBAWinLimit > MAX_RX_REORDERBUF)
3846 pAdapter->CommonCfg.BACapability.field.RxBAWinLimit = MAX_RX_REORDERBUF;
3850 pAdapter->CommonCfg.REGBACapability.word = pAdapter->CommonCfg.BACapability.word;
3851 DBGPRINT(RT_DEBUG_TRACE, ("Set::(Orde.AutoBA = %d) (Policy=%d)(ReBAWinLimit=%d)(TxBAWinLimit=%d)(AutoMode=%d)\n",Orde.AutoBA, pAdapter->CommonCfg.BACapability.field.Policy,
3852 pAdapter->CommonCfg.BACapability.field.RxBAWinLimit,pAdapter->CommonCfg.BACapability.field.TxBAWinLimit, pAdapter->CommonCfg.BACapability.field.AutoBA));
3853 DBGPRINT(RT_DEBUG_TRACE, ("Set::(MimoPs = %d)(AmsduEnable = %d) (AmsduSize=%d)(MpduDensity=%d)\n",pAdapter->CommonCfg.DesiredHtPhy.MimoPs, pAdapter->CommonCfg.DesiredHtPhy.AmsduEnable,
3854 pAdapter->CommonCfg.DesiredHtPhy.AmsduSize, pAdapter->CommonCfg.DesiredHtPhy.MpduDensity));
3858 case RT_OID_802_11_ADD_IMME_BA:
3859 DBGPRINT(RT_DEBUG_TRACE, (" Set :: RT_OID_802_11_ADD_IMME_BA \n"));
3860 if (wrq->u.data.length != sizeof(OID_ADD_BA_ENTRY))
3865 OID_ADD_BA_ENTRY BA;
3866 MAC_TABLE_ENTRY *pEntry;
3868 Status = copy_from_user(&BA, wrq->u.data.pointer, wrq->u.data.length);
3871 Status = NDIS_STATUS_INVALID_DATA;
3876 //BATableInsertEntry
3877 //As ad-hoc mode, BA pair is not limited to only BSSID. so add via OID.
3879 // in ad hoc mode, when adding BA pair, we should insert this entry into MACEntry too
3880 pEntry = MacTableLookup(pAdapter, BA.MACAddr);
3883 DBGPRINT(RT_DEBUG_TRACE, ("RT_OID_802_11_ADD_IMME_BA. break on no connection.----:%x:%x\n", BA.MACAddr[4], BA.MACAddr[5]));
3886 if (BA.IsRecipient == FALSE)
3888 if (pEntry->bIAmBadAtheros == TRUE)
3889 pAdapter->CommonCfg.BACapability.field.RxBAWinLimit = 0x10;
3891 BAOriSessionSetUp(pAdapter, pEntry, index, 0, 100, TRUE);
3895 //BATableInsertEntry(pAdapter, pEntry->Aid, BA.MACAddr, 0, 0xffff, BA.TID, BA.nMSDU, BA.IsRecipient);
3898 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_ADD_IMME_BA. Rec = %d. Mac = %x:%x:%x:%x:%x:%x . \n",
3899 BA.IsRecipient, BA.MACAddr[0], BA.MACAddr[1], BA.MACAddr[2], BA.MACAddr[2]
3900 , BA.MACAddr[4], BA.MACAddr[5]));
3905 case RT_OID_802_11_TEAR_IMME_BA:
3906 DBGPRINT(RT_DEBUG_TRACE, ("Set :: RT_OID_802_11_TEAR_IMME_BA \n"));
3907 if (wrq->u.data.length != sizeof(OID_ADD_BA_ENTRY))
3911 POID_ADD_BA_ENTRY pBA;
3912 MAC_TABLE_ENTRY *pEntry;
3914 pBA = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
3918 DBGPRINT(RT_DEBUG_TRACE, ("Set :: RT_OID_802_11_TEAR_IMME_BA kmalloc() can't allocate enough memory\n"));
3919 Status = NDIS_STATUS_FAILURE;
3923 Status = copy_from_user(pBA, wrq->u.data.pointer, wrq->u.data.length);
3924 DBGPRINT(RT_DEBUG_TRACE, ("Set :: RT_OID_802_11_TEAR_IMME_BA(TID=%d, bAllTid=%d)\n", pBA->TID, pBA->bAllTid));
3926 if (!pBA->bAllTid && (pBA->TID > NUM_OF_TID))
3928 Status = NDIS_STATUS_INVALID_DATA;
3932 if (pBA->IsRecipient == FALSE)
3934 pEntry = MacTableLookup(pAdapter, pBA->MACAddr);
3935 DBGPRINT(RT_DEBUG_TRACE, (" pBA->IsRecipient == FALSE\n"));
3938 DBGPRINT(RT_DEBUG_TRACE, (" pBA->pEntry\n"));
3939 BAOriSessionTearDown(pAdapter, pEntry->Aid, pBA->TID, FALSE, TRUE);
3942 DBGPRINT(RT_DEBUG_TRACE, ("Set :: Not found pEntry \n"));
3946 pEntry = MacTableLookup(pAdapter, pBA->MACAddr);
3949 BARecSessionTearDown( pAdapter, (UCHAR)pEntry->Aid, pBA->TID, TRUE);
3952 DBGPRINT(RT_DEBUG_TRACE, ("Set :: Not found pEntry \n"));
3958 // For WPA_SUPPLICANT to set static wep key
3959 case OID_802_11_ADD_WEP:
3960 pWepKey = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
3965 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_WEP, Failed!!\n"));
3968 Status = copy_from_user(pWepKey, wrq->u.data.pointer, wrq->u.data.length);
3972 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_WEP, Failed (length mismatch)!!\n"));
3976 KeyIdx = pWepKey->KeyIndex & 0x0fffffff;
3977 // KeyIdx must be 0 ~ 3
3981 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_WEP, Failed (KeyIdx must be smaller than 4)!!\n"));
3985 UCHAR CipherAlg = 0;
3988 // set key material and key length
3989 NdisZeroMemory(pAdapter->SharedKey[BSS0][KeyIdx].Key, 16);
3990 pAdapter->SharedKey[BSS0][KeyIdx].KeyLen = (UCHAR) pWepKey->KeyLength;
3991 NdisMoveMemory(pAdapter->SharedKey[BSS0][KeyIdx].Key, &pWepKey->KeyMaterial, pWepKey->KeyLength);
3993 switch(pWepKey->KeyLength)
3996 CipherAlg = CIPHER_WEP64;
3999 CipherAlg = CIPHER_WEP128;
4002 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_WEP, only support CIPHER_WEP64(len:5) & CIPHER_WEP128(len:13)!!\n"));
4006 pAdapter->SharedKey[BSS0][KeyIdx].CipherAlg = CipherAlg;
4008 // Default key for tx (shared key)
4009 if (pWepKey->KeyIndex & 0x80000000)
4011 // set key material and key length
4012 NdisZeroMemory(pAdapter->StaCfg.DesireSharedKey[KeyIdx].Key, 16);
4013 pAdapter->StaCfg.DesireSharedKey[KeyIdx].KeyLen = (UCHAR) pWepKey->KeyLength;
4014 NdisMoveMemory(pAdapter->StaCfg.DesireSharedKey[KeyIdx].Key, &pWepKey->KeyMaterial, pWepKey->KeyLength);
4015 pAdapter->StaCfg.DesireSharedKeyId = KeyIdx;
4016 pAdapter->StaCfg.DesireSharedKey[KeyIdx].CipherAlg = CipherAlg;
4017 pAdapter->StaCfg.DefaultKeyId = (UCHAR) KeyIdx;
4020 if ((pAdapter->StaCfg.WpaSupplicantUP != 0) &&
4021 (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA))
4023 Key = pWepKey->KeyMaterial;
4025 // Set Group key material to Asic
4026 AsicAddSharedKeyEntry(pAdapter, BSS0, KeyIdx, CipherAlg, Key, NULL, NULL);
4028 // Update WCID attribute table and IVEIV table for this group key table
4029 RTMPAddWcidAttributeEntry(pAdapter, BSS0, KeyIdx, CipherAlg, NULL);
4031 STA_PORT_SECURED(pAdapter);
4033 // Indicate Connected for GUI
4034 pAdapter->IndicateMediaState = NdisMediaStateConnected;
4036 else if (pAdapter->StaCfg.PortSecured == WPA_802_1X_PORT_SECURED)
4038 Key = pAdapter->SharedKey[BSS0][KeyIdx].Key;
4040 // Set key material and cipherAlg to Asic
4041 AsicAddSharedKeyEntry(pAdapter, BSS0, KeyIdx, CipherAlg, Key, NULL, NULL);
4043 if (pWepKey->KeyIndex & 0x80000000)
4045 PMAC_TABLE_ENTRY pEntry = &pAdapter->MacTab.Content[BSSID_WCID];
4046 // Assign group key info
4047 RTMPAddWcidAttributeEntry(pAdapter, BSS0, KeyIdx, CipherAlg, NULL);
4048 // Assign pairwise key info
4049 RTMPAddWcidAttributeEntry(pAdapter, BSS0, KeyIdx, CipherAlg, pEntry);
4052 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"));
4057 case OID_SET_COUNTERMEASURES:
4058 if (wrq->u.data.length != sizeof(int))
4063 Status = copy_from_user(&enabled, wrq->u.data.pointer, wrq->u.data.length);
4065 pAdapter->StaCfg.bBlockAssoc = TRUE;
4067 // WPA MIC error should block association attempt for 60 seconds
4068 pAdapter->StaCfg.bBlockAssoc = FALSE;
4069 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_SET_COUNTERMEASURES bBlockAssoc=%s\n", pAdapter->StaCfg.bBlockAssoc ? "TRUE":"FALSE"));
4072 case RT_OID_WPA_SUPPLICANT_SUPPORT:
4073 if (wrq->u.data.length != sizeof(UCHAR))
4077 Status = copy_from_user(&wpa_supplicant_enable, wrq->u.data.pointer, wrq->u.data.length);
4078 pAdapter->StaCfg.WpaSupplicantUP = wpa_supplicant_enable;
4079 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_WPA_SUPPLICANT_SUPPORT (=%d)\n", pAdapter->StaCfg.WpaSupplicantUP));
4082 case OID_802_11_DEAUTHENTICATION:
4083 if (wrq->u.data.length != sizeof(MLME_DEAUTH_REQ_STRUCT))
4087 MLME_DEAUTH_REQ_STRUCT *pInfo;
4088 MLME_QUEUE_ELEM *MsgElem = (MLME_QUEUE_ELEM *) kmalloc(sizeof(MLME_QUEUE_ELEM), MEM_ALLOC_FLAG);
4090 pInfo = (MLME_DEAUTH_REQ_STRUCT *) MsgElem->Msg;
4091 Status = copy_from_user(pInfo, wrq->u.data.pointer, wrq->u.data.length);
4092 MlmeDeauthReqAction(pAdapter, MsgElem);
4095 if (INFRA_ON(pAdapter))
4097 LinkDown(pAdapter, FALSE);
4098 pAdapter->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
4100 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_DEAUTHENTICATION (Reason=%d)\n", pInfo->Reason));
4103 case OID_802_11_DROP_UNENCRYPTED:
4104 if (wrq->u.data.length != sizeof(int))
4109 Status = copy_from_user(&enabled, wrq->u.data.pointer, wrq->u.data.length);
4111 pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED;
4113 pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
4114 NdisAcquireSpinLock(&pAdapter->MacTabLock);
4115 pAdapter->MacTab.Content[BSSID_WCID].PortSecured = pAdapter->StaCfg.PortSecured;
4116 NdisReleaseSpinLock(&pAdapter->MacTabLock);
4117 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_DROP_UNENCRYPTED (=%d)\n", enabled));
4120 case OID_802_11_SET_IEEE8021X:
4121 if (wrq->u.data.length != sizeof(BOOLEAN))
4125 Status = copy_from_user(&IEEE8021xState, wrq->u.data.pointer, wrq->u.data.length);
4126 pAdapter->StaCfg.IEEE8021X = IEEE8021xState;
4127 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_SET_IEEE8021X (=%d)\n", IEEE8021xState));
4130 case OID_802_11_SET_IEEE8021X_REQUIRE_KEY:
4131 if (wrq->u.data.length != sizeof(BOOLEAN))
4135 Status = copy_from_user(&IEEE8021x_required_keys, wrq->u.data.pointer, wrq->u.data.length);
4136 pAdapter->StaCfg.IEEE8021x_required_keys = IEEE8021x_required_keys;
4137 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_SET_IEEE8021X_REQUIRE_KEY (%d)\n", IEEE8021x_required_keys));
4140 case OID_802_11_PMKID:
4141 pPmkId = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
4143 if(pPmkId == NULL) {
4147 Status = copy_from_user(pPmkId, wrq->u.data.pointer, wrq->u.data.length);
4149 // check the PMKID information
4150 if (pPmkId->BSSIDInfoCount == 0)
4151 NdisZeroMemory(pAdapter->StaCfg.SavedPMK, sizeof(BSSID_INFO)*PMKID_NO);
4154 PBSSID_INFO pBssIdInfo;
4158 for (BssIdx = 0; BssIdx < pPmkId->BSSIDInfoCount; BssIdx++)
4160 // point to the indexed BSSID_INFO structure
4161 pBssIdInfo = (PBSSID_INFO) ((PUCHAR) pPmkId + 2 * sizeof(UINT) + BssIdx * sizeof(BSSID_INFO));
4162 // Find the entry in the saved data base.
4163 for (CachedIdx = 0; CachedIdx < pAdapter->StaCfg.SavedPMKNum; CachedIdx++)
4165 // compare the BSSID
4166 if (NdisEqualMemory(pBssIdInfo->BSSID, pAdapter->StaCfg.SavedPMK[CachedIdx].BSSID, sizeof(NDIS_802_11_MAC_ADDRESS)))
4170 // Found, replace it
4171 if (CachedIdx < PMKID_NO)
4173 DBGPRINT(RT_DEBUG_OFF, ("Update OID_802_11_PMKID, idx = %d\n", CachedIdx));
4174 NdisMoveMemory(&pAdapter->StaCfg.SavedPMK[CachedIdx], pBssIdInfo, sizeof(BSSID_INFO));
4175 pAdapter->StaCfg.SavedPMKNum++;
4177 // Not found, replace the last one
4180 // Randomly replace one
4181 CachedIdx = (pBssIdInfo->BSSID[5] % PMKID_NO);
4182 DBGPRINT(RT_DEBUG_OFF, ("Update OID_802_11_PMKID, idx = %d\n", CachedIdx));
4183 NdisMoveMemory(&pAdapter->StaCfg.SavedPMK[CachedIdx], pBssIdInfo, sizeof(BSSID_INFO));
4191 DBGPRINT(RT_DEBUG_TRACE, ("Set::unknown IOCTL's subcmd = 0x%08x\n", cmd));
4192 Status = -EOPNOTSUPP;
4200 INT RTMPQueryInformation(
4201 IN PRTMP_ADAPTER pAdapter,
4202 IN OUT struct ifreq *rq,
4205 struct iwreq *wrq = (struct iwreq *) rq;
4206 NDIS_802_11_BSSID_LIST_EX *pBssidList = NULL;
4207 PNDIS_WLAN_BSSID_EX pBss;
4208 NDIS_802_11_SSID Ssid;
4209 NDIS_802_11_CONFIGURATION *pConfiguration = NULL;
4210 RT_802_11_LINK_STATUS *pLinkStatus = NULL;
4211 RT_802_11_STA_CONFIG *pStaConfig = NULL;
4212 NDIS_802_11_STATISTICS *pStatistics = NULL;
4213 NDIS_802_11_RTS_THRESHOLD RtsThresh;
4214 NDIS_802_11_FRAGMENTATION_THRESHOLD FragThresh;
4215 NDIS_802_11_POWER_MODE PowerMode;
4216 NDIS_802_11_NETWORK_INFRASTRUCTURE BssType;
4217 RT_802_11_PREAMBLE PreamType;
4218 NDIS_802_11_AUTHENTICATION_MODE AuthMode;
4219 NDIS_802_11_WEP_STATUS WepStatus;
4220 NDIS_MEDIA_STATE MediaState;
4221 ULONG BssBufSize, ulInfo=0, NetworkTypeList[4], apsd = 0;
4223 PUCHAR pBuf = NULL, pPtr;
4224 INT Status = NDIS_STATUS_SUCCESS;
4225 UINT we_version_compiled;
4226 UCHAR i, Padding = 0;
4228 UCHAR driverVersion[8];
4229 OID_SET_HT_PHYMODE *pHTPhyMode = NULL;
4233 case RT_OID_DEVICE_NAME:
4234 wrq->u.data.length = sizeof(STA_NIC_DEVICE_NAME);
4235 Status = copy_to_user(wrq->u.data.pointer, STA_NIC_DEVICE_NAME, wrq->u.data.length);
4237 case RT_OID_VERSION_INFO:
4238 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_VERSION_INFO \n"));
4239 wrq->u.data.length = 8*sizeof(UCHAR);
4240 sprintf(&driverVersion[0], "%s", STA_DRIVER_VERSION);
4241 driverVersion[7] = '\0';
4242 if (copy_to_user(wrq->u.data.pointer, &driverVersion, wrq->u.data.length))
4247 case OID_802_11_BSSID_LIST:
4248 if (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
4251 * Still scanning, indicate the caller should try again.
4253 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_BSSID_LIST (Still scanning)\n"));
4256 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_BSSID_LIST (%d BSS returned)\n",pAdapter->ScanTab.BssNr));
4257 pAdapter->StaCfg.bScanReqIsFromWebUI = FALSE;
4258 // Claculate total buffer size required
4259 BssBufSize = sizeof(ULONG);
4261 for (i = 0; i < pAdapter->ScanTab.BssNr; i++)
4263 // Align pointer to 4 bytes boundary.
4264 //Padding = 4 - (pAdapter->ScanTab.BssEntry[i].VarIELen & 0x0003);
4267 BssBufSize += (sizeof(NDIS_WLAN_BSSID_EX) - 1 + sizeof(NDIS_802_11_FIXED_IEs) + pAdapter->ScanTab.BssEntry[i].VarIELen + Padding);
4270 // For safety issue, we add 256 bytes just in case
4272 // Allocate the same size as passed from higher layer
4273 pBuf = kmalloc(BssBufSize, MEM_ALLOC_FLAG);
4279 // Init 802_11_BSSID_LIST_EX structure
4280 NdisZeroMemory(pBuf, BssBufSize);
4281 pBssidList = (PNDIS_802_11_BSSID_LIST_EX) pBuf;
4282 pBssidList->NumberOfItems = pAdapter->ScanTab.BssNr;
4284 // Calculate total buffer length
4285 BssLen = 4; // Consist of NumberOfItems
4286 // Point to start of NDIS_WLAN_BSSID_EX
4287 // pPtr = pBuf + sizeof(ULONG);
4288 pPtr = (PUCHAR) &pBssidList->Bssid[0];
4289 for (i = 0; i < pAdapter->ScanTab.BssNr; i++)
4291 pBss = (PNDIS_WLAN_BSSID_EX) pPtr;
4292 NdisMoveMemory(&pBss->MacAddress, &pAdapter->ScanTab.BssEntry[i].Bssid, MAC_ADDR_LEN);
4293 if ((pAdapter->ScanTab.BssEntry[i].Hidden == 1) && (pAdapter->StaCfg.bShowHiddenSSID == FALSE))
4296 // We must return this SSID during 4way handshaking, otherwise Aegis will failed to parse WPA infomation
4297 // and then failed to send EAPOl farame.
4299 if ((pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA) && (pAdapter->StaCfg.PortSecured != WPA_802_1X_PORT_SECURED))
4301 pBss->Ssid.SsidLength = pAdapter->ScanTab.BssEntry[i].SsidLen;
4302 NdisMoveMemory(pBss->Ssid.Ssid, pAdapter->ScanTab.BssEntry[i].Ssid, pAdapter->ScanTab.BssEntry[i].SsidLen);
4305 pBss->Ssid.SsidLength = 0;
4309 pBss->Ssid.SsidLength = pAdapter->ScanTab.BssEntry[i].SsidLen;
4310 NdisMoveMemory(pBss->Ssid.Ssid, pAdapter->ScanTab.BssEntry[i].Ssid, pAdapter->ScanTab.BssEntry[i].SsidLen);
4312 pBss->Privacy = pAdapter->ScanTab.BssEntry[i].Privacy;
4313 pBss->Rssi = pAdapter->ScanTab.BssEntry[i].Rssi - pAdapter->BbpRssiToDbmDelta;
4314 pBss->NetworkTypeInUse = NetworkTypeInUseSanity(&pAdapter->ScanTab.BssEntry[i]);
4315 pBss->Configuration.Length = sizeof(NDIS_802_11_CONFIGURATION);
4316 pBss->Configuration.BeaconPeriod = pAdapter->ScanTab.BssEntry[i].BeaconPeriod;
4317 pBss->Configuration.ATIMWindow = pAdapter->ScanTab.BssEntry[i].AtimWin;
4319 MAP_CHANNEL_ID_TO_KHZ(pAdapter->ScanTab.BssEntry[i].Channel, pBss->Configuration.DSConfig);
4321 if (pAdapter->ScanTab.BssEntry[i].BssType == BSS_INFRA)
4322 pBss->InfrastructureMode = Ndis802_11Infrastructure;
4324 pBss->InfrastructureMode = Ndis802_11IBSS;
4326 NdisMoveMemory(pBss->SupportedRates, pAdapter->ScanTab.BssEntry[i].SupRate, pAdapter->ScanTab.BssEntry[i].SupRateLen);
4327 NdisMoveMemory(pBss->SupportedRates + pAdapter->ScanTab.BssEntry[i].SupRateLen,
4328 pAdapter->ScanTab.BssEntry[i].ExtRate,
4329 pAdapter->ScanTab.BssEntry[i].ExtRateLen);
4331 if (pAdapter->ScanTab.BssEntry[i].VarIELen == 0)
4333 pBss->IELength = sizeof(NDIS_802_11_FIXED_IEs);
4334 NdisMoveMemory(pBss->IEs, &pAdapter->ScanTab.BssEntry[i].FixIEs, sizeof(NDIS_802_11_FIXED_IEs));
4335 pPtr = pPtr + sizeof(NDIS_WLAN_BSSID_EX) - 1 + sizeof(NDIS_802_11_FIXED_IEs);
4339 pBss->IELength = (ULONG)(sizeof(NDIS_802_11_FIXED_IEs) + pAdapter->ScanTab.BssEntry[i].VarIELen);
4340 pPtr = pPtr + sizeof(NDIS_WLAN_BSSID_EX) - 1 + sizeof(NDIS_802_11_FIXED_IEs);
4341 NdisMoveMemory(pBss->IEs, &pAdapter->ScanTab.BssEntry[i].FixIEs, sizeof(NDIS_802_11_FIXED_IEs));
4342 NdisMoveMemory(pBss->IEs + sizeof(NDIS_802_11_FIXED_IEs), pAdapter->ScanTab.BssEntry[i].VarIEs, pAdapter->ScanTab.BssEntry[i].VarIELen);
4343 pPtr += pAdapter->ScanTab.BssEntry[i].VarIELen;
4345 pBss->Length = (ULONG)(sizeof(NDIS_WLAN_BSSID_EX) - 1 + sizeof(NDIS_802_11_FIXED_IEs) + pAdapter->ScanTab.BssEntry[i].VarIELen + Padding);
4347 #if WIRELESS_EXT < 17
4348 if ((BssLen + pBss->Length) < wrq->u.data.length)
4349 BssLen += pBss->Length;
4352 pBssidList->NumberOfItems = i;
4356 BssLen += pBss->Length;
4360 #if WIRELESS_EXT < 17
4361 wrq->u.data.length = BssLen;
4363 if (BssLen > wrq->u.data.length)
4369 wrq->u.data.length = BssLen;
4371 Status = copy_to_user(wrq->u.data.pointer, pBssidList, BssLen);
4374 case OID_802_3_CURRENT_ADDRESS:
4375 wrq->u.data.length = MAC_ADDR_LEN;
4376 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CurrentAddress, wrq->u.data.length);
4378 case OID_GEN_MEDIA_CONNECT_STATUS:
4379 if (pAdapter->IndicateMediaState == NdisMediaStateConnected)
4380 MediaState = NdisMediaStateConnected;
4382 MediaState = NdisMediaStateDisconnected;
4384 wrq->u.data.length = sizeof(NDIS_MEDIA_STATE);
4385 Status = copy_to_user(wrq->u.data.pointer, &MediaState, wrq->u.data.length);
4387 case OID_802_11_BSSID:
4388 if (INFRA_ON(pAdapter) || ADHOC_ON(pAdapter))
4390 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.Bssid, sizeof(NDIS_802_11_MAC_ADDRESS));
4395 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_BSSID(=EMPTY)\n"));
4399 case OID_802_11_SSID:
4400 NdisZeroMemory(&Ssid, sizeof(NDIS_802_11_SSID));
4401 NdisZeroMemory(Ssid.Ssid, MAX_LEN_OF_SSID);
4402 Ssid.SsidLength = pAdapter->CommonCfg.SsidLen;
4403 memcpy(Ssid.Ssid, pAdapter->CommonCfg.Ssid, Ssid.SsidLength);
4404 wrq->u.data.length = sizeof(NDIS_802_11_SSID);
4405 Status = copy_to_user(wrq->u.data.pointer, &Ssid, wrq->u.data.length);
4406 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_SSID (Len=%d, ssid=%s)\n", Ssid.SsidLength,Ssid.Ssid));
4408 case RT_OID_802_11_QUERY_LINK_STATUS:
4409 pLinkStatus = (RT_802_11_LINK_STATUS *) kmalloc(sizeof(RT_802_11_LINK_STATUS), MEM_ALLOC_FLAG);
4412 pLinkStatus->CurrTxRate = RateIdTo500Kbps[pAdapter->CommonCfg.TxRate]; // unit : 500 kbps
4413 pLinkStatus->ChannelQuality = pAdapter->Mlme.ChannelQuality;
4414 pLinkStatus->RxByteCount = pAdapter->RalinkCounters.ReceivedByteCount;
4415 pLinkStatus->TxByteCount = pAdapter->RalinkCounters.TransmittedByteCount;
4416 pLinkStatus->CentralChannel = pAdapter->CommonCfg.CentralChannel;
4417 wrq->u.data.length = sizeof(RT_802_11_LINK_STATUS);
4418 Status = copy_to_user(wrq->u.data.pointer, pLinkStatus, wrq->u.data.length);
4420 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_LINK_STATUS\n"));
4424 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_LINK_STATUS(kmalloc failed)\n"));
4428 case OID_802_11_CONFIGURATION:
4429 pConfiguration = (NDIS_802_11_CONFIGURATION *) kmalloc(sizeof(NDIS_802_11_CONFIGURATION), MEM_ALLOC_FLAG);
4432 pConfiguration->Length = sizeof(NDIS_802_11_CONFIGURATION);
4433 pConfiguration->BeaconPeriod = pAdapter->CommonCfg.BeaconPeriod;
4434 pConfiguration->ATIMWindow = pAdapter->StaActive.AtimWin;
4435 MAP_CHANNEL_ID_TO_KHZ(pAdapter->CommonCfg.Channel, pConfiguration->DSConfig);
4436 wrq->u.data.length = sizeof(NDIS_802_11_CONFIGURATION);
4437 Status = copy_to_user(wrq->u.data.pointer, pConfiguration, wrq->u.data.length);
4438 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_CONFIGURATION(BeaconPeriod=%ld,AtimW=%ld,Channel=%d) \n",
4439 pConfiguration->BeaconPeriod, pConfiguration->ATIMWindow, pAdapter->CommonCfg.Channel));
4440 kfree(pConfiguration);
4444 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_CONFIGURATION(kmalloc failed)\n"));
4448 case RT_OID_802_11_SNR_0:
4449 if ((pAdapter->StaCfg.LastSNR0 > 0))
4451 ulInfo = ((0xeb - pAdapter->StaCfg.LastSNR0) * 3) / 16 ;
4452 wrq->u.data.length = sizeof(ulInfo);
4453 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4454 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_SNR_0(0x=%lx)\n", ulInfo));
4459 case RT_OID_802_11_SNR_1:
4460 if ((pAdapter->Antenna.field.RxPath > 1) &&
4461 (pAdapter->StaCfg.LastSNR1 > 0))
4463 ulInfo = ((0xeb - pAdapter->StaCfg.LastSNR1) * 3) / 16 ;
4464 wrq->u.data.length = sizeof(ulInfo);
4465 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4466 DBGPRINT(RT_DEBUG_TRACE,("Query::RT_OID_802_11_SNR_1(0x=%lx)\n",ulInfo));
4470 DBGPRINT(RT_DEBUG_TRACE,("Query::RT_OID_802_11_SNR_1(pAdapter->StaCfg.LastSNR1=%d)\n",pAdapter->StaCfg.LastSNR1));
4472 case OID_802_11_RSSI_TRIGGER:
4473 ulInfo = pAdapter->StaCfg.RssiSample.LastRssi0 - pAdapter->BbpRssiToDbmDelta;
4474 wrq->u.data.length = sizeof(ulInfo);
4475 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4476 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_RSSI_TRIGGER(=%ld)\n", ulInfo));
4478 case OID_802_11_RSSI:
4479 case RT_OID_802_11_RSSI:
4480 ulInfo = pAdapter->StaCfg.RssiSample.LastRssi0;
4481 wrq->u.data.length = sizeof(ulInfo);
4482 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4484 case RT_OID_802_11_RSSI_1:
4485 ulInfo = pAdapter->StaCfg.RssiSample.LastRssi1;
4486 wrq->u.data.length = sizeof(ulInfo);
4487 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4489 case RT_OID_802_11_RSSI_2:
4490 ulInfo = pAdapter->StaCfg.RssiSample.LastRssi2;
4491 wrq->u.data.length = sizeof(ulInfo);
4492 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4494 case OID_802_11_STATISTICS:
4495 pStatistics = (NDIS_802_11_STATISTICS *) kmalloc(sizeof(NDIS_802_11_STATISTICS), MEM_ALLOC_FLAG);
4498 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_STATISTICS \n"));
4499 // add the most up-to-date h/w raw counters into software counters
4500 NICUpdateRawCounters(pAdapter);
4502 // Sanity check for calculation of sucessful count
4503 if (pAdapter->WlanCounters.TransmittedFragmentCount.QuadPart < pAdapter->WlanCounters.RetryCount.QuadPart)
4504 pAdapter->WlanCounters.TransmittedFragmentCount.QuadPart = pAdapter->WlanCounters.RetryCount.QuadPart;
4506 pStatistics->TransmittedFragmentCount.QuadPart = pAdapter->WlanCounters.TransmittedFragmentCount.QuadPart;
4507 pStatistics->MulticastTransmittedFrameCount.QuadPart = pAdapter->WlanCounters.MulticastTransmittedFrameCount.QuadPart;
4508 pStatistics->FailedCount.QuadPart = pAdapter->WlanCounters.FailedCount.QuadPart;
4509 pStatistics->RetryCount.QuadPart = pAdapter->WlanCounters.RetryCount.QuadPart;
4510 pStatistics->MultipleRetryCount.QuadPart = pAdapter->WlanCounters.MultipleRetryCount.QuadPart;
4511 pStatistics->RTSSuccessCount.QuadPart = pAdapter->WlanCounters.RTSSuccessCount.QuadPart;
4512 pStatistics->RTSFailureCount.QuadPart = pAdapter->WlanCounters.RTSFailureCount.QuadPart;
4513 pStatistics->ACKFailureCount.QuadPart = pAdapter->WlanCounters.ACKFailureCount.QuadPart;
4514 pStatistics->FrameDuplicateCount.QuadPart = pAdapter->WlanCounters.FrameDuplicateCount.QuadPart;
4515 pStatistics->ReceivedFragmentCount.QuadPart = pAdapter->WlanCounters.ReceivedFragmentCount.QuadPart;
4516 pStatistics->MulticastReceivedFrameCount.QuadPart = pAdapter->WlanCounters.MulticastReceivedFrameCount.QuadPart;
4518 pStatistics->FCSErrorCount = pAdapter->RalinkCounters.RealFcsErrCount;
4520 pStatistics->FCSErrorCount.QuadPart = pAdapter->WlanCounters.FCSErrorCount.QuadPart;
4521 pStatistics->FrameDuplicateCount.u.LowPart = pAdapter->WlanCounters.FrameDuplicateCount.u.LowPart / 100;
4523 wrq->u.data.length = sizeof(NDIS_802_11_STATISTICS);
4524 Status = copy_to_user(wrq->u.data.pointer, pStatistics, wrq->u.data.length);
4529 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_STATISTICS(kmalloc failed)\n"));
4533 case OID_GEN_RCV_OK:
4534 ulInfo = pAdapter->Counters8023.GoodReceives;
4535 wrq->u.data.length = sizeof(ulInfo);
4536 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4538 case OID_GEN_RCV_NO_BUFFER:
4539 ulInfo = pAdapter->Counters8023.RxNoBuffer;
4540 wrq->u.data.length = sizeof(ulInfo);
4541 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4543 case RT_OID_802_11_PHY_MODE:
4544 ulInfo = (ULONG)pAdapter->CommonCfg.PhyMode;
4545 wrq->u.data.length = sizeof(ulInfo);
4546 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4547 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_PHY_MODE (=%ld)\n", ulInfo));
4549 case RT_OID_802_11_STA_CONFIG:
4550 pStaConfig = (RT_802_11_STA_CONFIG *) kmalloc(sizeof(RT_802_11_STA_CONFIG), MEM_ALLOC_FLAG);
4553 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_STA_CONFIG\n"));
4554 pStaConfig->EnableTxBurst = pAdapter->CommonCfg.bEnableTxBurst;
4555 pStaConfig->EnableTurboRate = 0;
4556 pStaConfig->UseBGProtection = pAdapter->CommonCfg.UseBGProtection;
4557 pStaConfig->UseShortSlotTime = pAdapter->CommonCfg.bUseShortSlotTime;
4558 //pStaConfig->AdhocMode = pAdapter->StaCfg.AdhocMode;
4559 pStaConfig->HwRadioStatus = (pAdapter->StaCfg.bHwRadio == TRUE) ? 1 : 0;
4560 pStaConfig->Rsv1 = 0;
4561 pStaConfig->SystemErrorBitmap = pAdapter->SystemErrorBitmap;
4562 wrq->u.data.length = sizeof(RT_802_11_STA_CONFIG);
4563 Status = copy_to_user(wrq->u.data.pointer, pStaConfig, wrq->u.data.length);
4568 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_STA_CONFIG(kmalloc failed)\n"));
4572 case OID_802_11_RTS_THRESHOLD:
4573 RtsThresh = pAdapter->CommonCfg.RtsThreshold;
4574 wrq->u.data.length = sizeof(RtsThresh);
4575 Status = copy_to_user(wrq->u.data.pointer, &RtsThresh, wrq->u.data.length);
4576 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_RTS_THRESHOLD(=%ld)\n", RtsThresh));
4578 case OID_802_11_FRAGMENTATION_THRESHOLD:
4579 FragThresh = pAdapter->CommonCfg.FragmentThreshold;
4580 if (pAdapter->CommonCfg.bUseZeroToDisableFragment == TRUE)
4582 wrq->u.data.length = sizeof(FragThresh);
4583 Status = copy_to_user(wrq->u.data.pointer, &FragThresh, wrq->u.data.length);
4584 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_FRAGMENTATION_THRESHOLD(=%ld)\n", FragThresh));
4586 case OID_802_11_POWER_MODE:
4587 PowerMode = pAdapter->StaCfg.WindowsPowerMode;
4588 wrq->u.data.length = sizeof(PowerMode);
4589 Status = copy_to_user(wrq->u.data.pointer, &PowerMode, wrq->u.data.length);
4590 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_POWER_MODE(=%d)\n", PowerMode));
4592 case RT_OID_802_11_RADIO:
4593 RadioState = (BOOLEAN) pAdapter->StaCfg.bSwRadio;
4594 wrq->u.data.length = sizeof(RadioState);
4595 Status = copy_to_user(wrq->u.data.pointer, &RadioState, wrq->u.data.length);
4596 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_RADIO (=%d)\n", RadioState));
4598 case OID_802_11_INFRASTRUCTURE_MODE:
4599 if (pAdapter->StaCfg.BssType == BSS_ADHOC)
4600 BssType = Ndis802_11IBSS;
4601 else if (pAdapter->StaCfg.BssType == BSS_INFRA)
4602 BssType = Ndis802_11Infrastructure;
4603 else if (pAdapter->StaCfg.BssType == BSS_MONITOR)
4604 BssType = Ndis802_11Monitor;
4606 BssType = Ndis802_11AutoUnknown;
4608 wrq->u.data.length = sizeof(BssType);
4609 Status = copy_to_user(wrq->u.data.pointer, &BssType, wrq->u.data.length);
4610 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_INFRASTRUCTURE_MODE(=%d)\n", BssType));
4612 case RT_OID_802_11_PREAMBLE:
4613 PreamType = pAdapter->CommonCfg.TxPreamble;
4614 wrq->u.data.length = sizeof(PreamType);
4615 Status = copy_to_user(wrq->u.data.pointer, &PreamType, wrq->u.data.length);
4616 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_PREAMBLE(=%d)\n", PreamType));
4618 case OID_802_11_AUTHENTICATION_MODE:
4619 AuthMode = pAdapter->StaCfg.AuthMode;
4620 wrq->u.data.length = sizeof(AuthMode);
4621 Status = copy_to_user(wrq->u.data.pointer, &AuthMode, wrq->u.data.length);
4622 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_AUTHENTICATION_MODE(=%d)\n", AuthMode));
4624 case OID_802_11_WEP_STATUS:
4625 WepStatus = pAdapter->StaCfg.WepStatus;
4626 wrq->u.data.length = sizeof(WepStatus);
4627 Status = copy_to_user(wrq->u.data.pointer, &WepStatus, wrq->u.data.length);
4628 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_WEP_STATUS(=%d)\n", WepStatus));
4630 case OID_802_11_TX_POWER_LEVEL:
4631 wrq->u.data.length = sizeof(ULONG);
4632 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.TxPower, wrq->u.data.length);
4633 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_TX_POWER_LEVEL %x\n",pAdapter->CommonCfg.TxPower));
4635 case RT_OID_802_11_TX_POWER_LEVEL_1:
4636 wrq->u.data.length = sizeof(ULONG);
4637 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.TxPowerPercentage, wrq->u.data.length);
4638 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_TX_POWER_LEVEL_1 (=%ld)\n", pAdapter->CommonCfg.TxPowerPercentage));
4640 case OID_802_11_NETWORK_TYPES_SUPPORTED:
4641 if ((pAdapter->RfIcType == RFIC_2850) || (pAdapter->RfIcType == RFIC_2750))
4643 NetworkTypeList[0] = 3; // NumberOfItems = 3
4644 NetworkTypeList[1] = Ndis802_11DS; // NetworkType[1] = 11b
4645 NetworkTypeList[2] = Ndis802_11OFDM24; // NetworkType[2] = 11g
4646 NetworkTypeList[3] = Ndis802_11OFDM5; // NetworkType[3] = 11a
4647 wrq->u.data.length = 16;
4648 Status = copy_to_user(wrq->u.data.pointer, &NetworkTypeList[0], wrq->u.data.length);
4652 NetworkTypeList[0] = 2; // NumberOfItems = 2
4653 NetworkTypeList[1] = Ndis802_11DS; // NetworkType[1] = 11b
4654 NetworkTypeList[2] = Ndis802_11OFDM24; // NetworkType[2] = 11g
4655 wrq->u.data.length = 12;
4656 Status = copy_to_user(wrq->u.data.pointer, &NetworkTypeList[0], wrq->u.data.length);
4658 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_NETWORK_TYPES_SUPPORTED\n"));
4660 case OID_802_11_NETWORK_TYPE_IN_USE:
4661 wrq->u.data.length = sizeof(ULONG);
4662 if (pAdapter->CommonCfg.PhyMode == PHY_11A)
4663 ulInfo = Ndis802_11OFDM5;
4664 else if ((pAdapter->CommonCfg.PhyMode == PHY_11BG_MIXED) || (pAdapter->CommonCfg.PhyMode == PHY_11G))
4665 ulInfo = Ndis802_11OFDM24;
4667 ulInfo = Ndis802_11DS;
4668 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4670 case RT_OID_802_11_QUERY_LAST_RX_RATE:
4671 ulInfo = (ULONG)pAdapter->LastRxRate;
4672 wrq->u.data.length = sizeof(ulInfo);
4673 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4674 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_LAST_RX_RATE (=%ld)\n", ulInfo));
4676 case RT_OID_802_11_QUERY_LAST_TX_RATE:
4677 //ulInfo = (ULONG)pAdapter->LastTxRate;
4678 ulInfo = (ULONG)pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.word;
4679 wrq->u.data.length = sizeof(ulInfo);
4680 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4681 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_LAST_TX_RATE (=%lx)\n", ulInfo));
4683 case RT_OID_802_11_QUERY_EEPROM_VERSION:
4684 wrq->u.data.length = sizeof(ULONG);
4685 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->EepromVersion, wrq->u.data.length);
4687 case RT_OID_802_11_QUERY_FIRMWARE_VERSION:
4688 wrq->u.data.length = sizeof(ULONG);
4689 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->FirmwareVersion, wrq->u.data.length);
4691 case RT_OID_802_11_QUERY_NOISE_LEVEL:
4692 wrq->u.data.length = sizeof(UCHAR);
4693 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->BbpWriteLatch[66], wrq->u.data.length);
4694 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_NOISE_LEVEL (=%d)\n", pAdapter->BbpWriteLatch[66]));
4696 case RT_OID_802_11_EXTRA_INFO:
4697 wrq->u.data.length = sizeof(ULONG);
4698 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->ExtraInfo, wrq->u.data.length);
4699 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_EXTRA_INFO (=%ld)\n", pAdapter->ExtraInfo));
4701 case RT_OID_WE_VERSION_COMPILED:
4702 wrq->u.data.length = sizeof(UINT);
4703 we_version_compiled = WIRELESS_EXT;
4704 Status = copy_to_user(wrq->u.data.pointer, &we_version_compiled, wrq->u.data.length);
4706 case RT_OID_802_11_QUERY_APSD_SETTING:
4707 apsd = (pAdapter->CommonCfg.bAPSDCapable | (pAdapter->CommonCfg.bAPSDAC_BE << 1) | (pAdapter->CommonCfg.bAPSDAC_BK << 2)
4708 | (pAdapter->CommonCfg.bAPSDAC_VI << 3) | (pAdapter->CommonCfg.bAPSDAC_VO << 4) | (pAdapter->CommonCfg.MaxSPLength << 5));
4710 wrq->u.data.length = sizeof(ULONG);
4711 Status = copy_to_user(wrq->u.data.pointer, &apsd, wrq->u.data.length);
4712 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",
4713 apsd,pAdapter->CommonCfg.bAPSDCapable,pAdapter->CommonCfg.bAPSDAC_BE,pAdapter->CommonCfg.bAPSDAC_BK,pAdapter->CommonCfg.bAPSDAC_VI,pAdapter->CommonCfg.bAPSDAC_VO,pAdapter->CommonCfg.MaxSPLength));
4715 case RT_OID_802_11_QUERY_APSD_PSM:
4716 wrq->u.data.length = sizeof(ULONG);
4717 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.bAPSDForcePowerSave, wrq->u.data.length);
4718 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_APSD_PSM (=%d)\n", pAdapter->CommonCfg.bAPSDForcePowerSave));
4720 case RT_OID_802_11_QUERY_WMM:
4721 wrq->u.data.length = sizeof(BOOLEAN);
4722 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.bWmmCapable, wrq->u.data.length);
4723 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_WMM (=%d)\n", pAdapter->CommonCfg.bWmmCapable));
4725 case RT_OID_NEW_DRIVER:
4728 wrq->u.data.length = sizeof(UCHAR);
4729 Status = copy_to_user(wrq->u.data.pointer, &enabled, wrq->u.data.length);
4730 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_NEW_DRIVER (=%d)\n", enabled));
4733 case RT_OID_WPA_SUPPLICANT_SUPPORT:
4734 wrq->u.data.length = sizeof(UCHAR);
4735 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->StaCfg.WpaSupplicantUP, wrq->u.data.length);
4736 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_WPA_SUPPLICANT_SUPPORT (=%d)\n", pAdapter->StaCfg.WpaSupplicantUP));
4738 case RT_OID_DRIVER_DEVICE_NAME:
4739 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_DRIVER_DEVICE_NAME \n"));
4740 wrq->u.data.length = 16;
4741 if (copy_to_user(wrq->u.data.pointer, pAdapter->StaCfg.dev_name, wrq->u.data.length))
4746 case RT_OID_802_11_QUERY_HT_PHYMODE:
4747 pHTPhyMode = (OID_SET_HT_PHYMODE *) kmalloc(sizeof(OID_SET_HT_PHYMODE), MEM_ALLOC_FLAG);
4750 pHTPhyMode->PhyMode = pAdapter->CommonCfg.PhyMode;
4751 pHTPhyMode->HtMode = (UCHAR)pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.field.MODE;
4752 pHTPhyMode->BW = (UCHAR)pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.field.BW;
4753 pHTPhyMode->MCS= (UCHAR)pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.field.MCS;
4754 pHTPhyMode->SHORTGI= (UCHAR)pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.field.ShortGI;
4755 pHTPhyMode->STBC= (UCHAR)pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.field.STBC;
4757 pHTPhyMode->ExtOffset = ((pAdapter->CommonCfg.CentralChannel < pAdapter->CommonCfg.Channel) ? (EXTCHA_BELOW) : (EXTCHA_ABOVE));
4758 wrq->u.data.length = sizeof(OID_SET_HT_PHYMODE);
4759 if (copy_to_user(wrq->u.data.pointer, pHTPhyMode, wrq->u.data.length))
4763 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_HT_PHYMODE (PhyMode = %d, MCS =%d, BW = %d, STBC = %d, ExtOffset=%d)\n",
4764 pHTPhyMode->HtMode, pHTPhyMode->MCS, pHTPhyMode->BW, pHTPhyMode->STBC, pHTPhyMode->ExtOffset));
4765 DBGPRINT(RT_DEBUG_TRACE, (" MlmeUpdateTxRates (.word = %x )\n", pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.word));
4769 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_STA_CONFIG(kmalloc failed)\n"));
4773 case RT_OID_802_11_COUNTRY_REGION:
4774 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_COUNTRY_REGION \n"));
4775 wrq->u.data.length = sizeof(ulInfo);
4776 ulInfo = pAdapter->CommonCfg.CountryRegionForABand;
4777 ulInfo = (ulInfo << 8)|(pAdapter->CommonCfg.CountryRegion);
4778 if (copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length))
4783 case RT_OID_802_11_QUERY_DAT_HT_PHYMODE:
4784 pHTPhyMode = (OID_SET_HT_PHYMODE *) kmalloc(sizeof(OID_SET_HT_PHYMODE), MEM_ALLOC_FLAG);
4787 pHTPhyMode->PhyMode = pAdapter->CommonCfg.PhyMode;
4788 pHTPhyMode->HtMode = (UCHAR)pAdapter->CommonCfg.RegTransmitSetting.field.HTMODE;
4789 pHTPhyMode->BW = (UCHAR)pAdapter->CommonCfg.RegTransmitSetting.field.BW;
4790 pHTPhyMode->MCS= (UCHAR)pAdapter->StaCfg.DesiredTransmitSetting.field.MCS;
4791 pHTPhyMode->SHORTGI= (UCHAR)pAdapter->CommonCfg.RegTransmitSetting.field.ShortGI;
4792 pHTPhyMode->STBC= (UCHAR)pAdapter->CommonCfg.RegTransmitSetting.field.STBC;
4794 wrq->u.data.length = sizeof(OID_SET_HT_PHYMODE);
4795 if (copy_to_user(wrq->u.data.pointer, pHTPhyMode, wrq->u.data.length))
4799 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_HT_PHYMODE (PhyMode = %d, MCS =%d, BW = %d, STBC = %d, ExtOffset=%d)\n",
4800 pHTPhyMode->HtMode, pHTPhyMode->MCS, pHTPhyMode->BW, pHTPhyMode->STBC, pHTPhyMode->ExtOffset));
4801 DBGPRINT(RT_DEBUG_TRACE, (" MlmeUpdateTxRates (.word = %x )\n", pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.word));
4805 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_STA_CONFIG(kmalloc failed)\n"));
4809 case RT_OID_QUERY_MULTIPLE_CARD_SUPPORT:
4810 wrq->u.data.length = sizeof(UCHAR);
4812 if (copy_to_user(wrq->u.data.pointer, &i, wrq->u.data.length))
4816 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_QUERY_MULTIPLE_CARD_SUPPORT(=%d) \n", i));
4819 case OID_802_11_BUILD_CHANNEL_EX:
4822 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_BUILD_CHANNEL_EX \n"));
4823 wrq->u.data.length = sizeof(UCHAR);
4824 DBGPRINT(RT_DEBUG_TRACE, ("Doesn't support EXT_BUILD_CHANNEL_LIST.\n"));
4826 Status = copy_to_user(wrq->u.data.pointer, &value, 1);
4827 DBGPRINT(RT_DEBUG_TRACE, ("Status=%d\n", Status));
4831 case OID_802_11_GET_CH_LIST:
4833 PRT_CHANNEL_LIST_INFO pChListBuf;
4835 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_GET_CH_LIST \n"));
4836 if (pAdapter->ChannelListNum == 0)
4838 wrq->u.data.length = 0;
4842 pChListBuf = (RT_CHANNEL_LIST_INFO *) kmalloc(sizeof(RT_CHANNEL_LIST_INFO), MEM_ALLOC_FLAG);
4843 if (pChListBuf == NULL)
4845 wrq->u.data.length = 0;
4849 pChListBuf->ChannelListNum = pAdapter->ChannelListNum;
4850 for (i = 0; i < pChListBuf->ChannelListNum; i++)
4851 pChListBuf->ChannelList[i] = pAdapter->ChannelList[i].Channel;
4853 wrq->u.data.length = sizeof(RT_CHANNEL_LIST_INFO);
4854 Status = copy_to_user(wrq->u.data.pointer, pChListBuf, sizeof(RT_CHANNEL_LIST_INFO));
4855 DBGPRINT(RT_DEBUG_TRACE, ("Status=%d\n", Status));
4862 case OID_802_11_GET_COUNTRY_CODE:
4863 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_GET_COUNTRY_CODE \n"));
4864 wrq->u.data.length = 2;
4865 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.CountryCode, 2);
4866 DBGPRINT(RT_DEBUG_TRACE, ("Status=%d\n", Status));
4869 case OID_802_11_GET_CHANNEL_GEOGRAPHY:
4870 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_GET_CHANNEL_GEOGRAPHY \n"));
4871 wrq->u.data.length = 1;
4872 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.Geography, 1);
4873 DBGPRINT(RT_DEBUG_TRACE, ("Status=%d\n", Status));
4877 DBGPRINT(RT_DEBUG_TRACE, ("Query::unknown IOCTL's subcmd = 0x%08x\n", cmd));
4878 Status = -EOPNOTSUPP;
4884 INT rt28xx_sta_ioctl(
4885 IN struct net_device *net_dev,
4886 IN OUT struct ifreq *rq,
4890 VIRTUAL_ADAPTER *pVirtualAd = NULL;
4891 RTMP_ADAPTER *pAd = NULL;
4892 struct iwreq *wrq = (struct iwreq *) rq;
4893 BOOLEAN StateMachineTouched = FALSE;
4894 INT Status = NDIS_STATUS_SUCCESS;
4897 if (net_dev->priv_flags == INT_MAIN)
4899 pAd = net_dev->ml_priv;
4903 pVirtualAd = net_dev->ml_priv;
4904 pAd = pVirtualAd->RtmpDev->ml_priv;
4906 pObj = (POS_COOKIE) pAd->OS_Cookie;
4910 /* if 1st open fail, pAd will be free;
4911 So the net_dev->ml_priv will be NULL in 2rd open */
4915 //check if the interface is down
4916 if(!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_IN_USE))
4919 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
4924 { // determine this ioctl command is comming from which interface.
4925 pObj->ioctl_if_type = INT_MAIN;
4926 pObj->ioctl_if = MAIN_MBSSID;
4932 DBGPRINT(RT_DEBUG_TRACE, ("IOCTL::SIOCGIFHWADDR\n"));
4933 memcpy(wrq->u.name, pAd->CurrentAddress, ETH_ALEN);
4937 char *name=&wrq->u.name[0];
4938 rt_ioctl_giwname(net_dev, NULL, name, NULL);
4941 case SIOCGIWESSID: //Get ESSID
4943 struct iw_point *essid=&wrq->u.essid;
4944 rt_ioctl_giwessid(net_dev, NULL, essid, essid->pointer);
4947 case SIOCSIWESSID: //Set ESSID
4949 struct iw_point *essid=&wrq->u.essid;
4950 rt_ioctl_siwessid(net_dev, NULL, essid, essid->pointer);
4953 case SIOCSIWNWID: // set network id (the cell)
4954 case SIOCGIWNWID: // get network id
4955 Status = -EOPNOTSUPP;
4957 case SIOCSIWFREQ: //set channel/frequency (Hz)
4959 struct iw_freq *freq=&wrq->u.freq;
4960 rt_ioctl_siwfreq(net_dev, NULL, freq, NULL);
4963 case SIOCGIWFREQ: // get channel/frequency (Hz)
4965 struct iw_freq *freq=&wrq->u.freq;
4966 rt_ioctl_giwfreq(net_dev, NULL, freq, NULL);
4969 case SIOCSIWNICKN: //set node name/nickname
4971 struct iw_point *data=&wrq->u.data;
4972 rt_ioctl_siwnickn(net_dev, NULL, data, NULL);
4975 case SIOCGIWNICKN: //get node name/nickname
4977 struct iw_point *data=&wrq->u.data;
4978 rt_ioctl_giwnickn(net_dev, NULL, data, NULL);
4981 case SIOCGIWRATE: //get default bit rate (bps)
4982 rt_ioctl_giwrate(net_dev, NULL, &wrq->u, NULL);
4984 case SIOCSIWRATE: //set default bit rate (bps)
4985 rt_ioctl_siwrate(net_dev, NULL, &wrq->u, NULL);
4987 case SIOCGIWRTS: // get RTS/CTS threshold (bytes)
4989 struct iw_param *rts=&wrq->u.rts;
4990 rt_ioctl_giwrts(net_dev, NULL, rts, NULL);
4993 case SIOCSIWRTS: //set RTS/CTS threshold (bytes)
4995 struct iw_param *rts=&wrq->u.rts;
4996 rt_ioctl_siwrts(net_dev, NULL, rts, NULL);
4999 case SIOCGIWFRAG: //get fragmentation thr (bytes)
5001 struct iw_param *frag=&wrq->u.frag;
5002 rt_ioctl_giwfrag(net_dev, NULL, frag, NULL);
5005 case SIOCSIWFRAG: //set fragmentation thr (bytes)
5007 struct iw_param *frag=&wrq->u.frag;
5008 rt_ioctl_siwfrag(net_dev, NULL, frag, NULL);
5011 case SIOCGIWENCODE: //get encoding token & mode
5013 struct iw_point *erq=&wrq->u.encoding;
5015 rt_ioctl_giwencode(net_dev, NULL, erq, erq->pointer);
5018 case SIOCSIWENCODE: //set encoding token & mode
5020 struct iw_point *erq=&wrq->u.encoding;
5022 rt_ioctl_siwencode(net_dev, NULL, erq, erq->pointer);
5025 case SIOCGIWAP: //get access point MAC addresses
5027 struct sockaddr *ap_addr=&wrq->u.ap_addr;
5028 rt_ioctl_giwap(net_dev, NULL, ap_addr, ap_addr->sa_data);
5031 case SIOCSIWAP: //set access point MAC addresses
5033 struct sockaddr *ap_addr=&wrq->u.ap_addr;
5034 rt_ioctl_siwap(net_dev, NULL, ap_addr, ap_addr->sa_data);
5037 case SIOCGIWMODE: //get operation mode
5039 __u32 *mode=&wrq->u.mode;
5040 rt_ioctl_giwmode(net_dev, NULL, mode, NULL);
5043 case SIOCSIWMODE: //set operation mode
5045 __u32 *mode=&wrq->u.mode;
5046 rt_ioctl_siwmode(net_dev, NULL, mode, NULL);
5049 case SIOCGIWSENS: //get sensitivity (dBm)
5050 case SIOCSIWSENS: //set sensitivity (dBm)
5051 case SIOCGIWPOWER: //get Power Management settings
5052 case SIOCSIWPOWER: //set Power Management settings
5053 case SIOCGIWTXPOW: //get transmit power (dBm)
5054 case SIOCSIWTXPOW: //set transmit power (dBm)
5055 case SIOCGIWRANGE: //Get range of parameters
5056 case SIOCGIWRETRY: //get retry limits and lifetime
5057 case SIOCSIWRETRY: //set retry limits and lifetime
5058 Status = -EOPNOTSUPP;
5061 subcmd = wrq->u.data.flags;
5062 if( subcmd & OID_GET_SET_TOGGLE)
5063 Status = RTMPSetInformation(pAd, rq, subcmd);
5065 Status = RTMPQueryInformation(pAd, rq, subcmd);
5068 if (wrq->u.data.pointer)
5070 if ( access_ok(VERIFY_WRITE, wrq->u.data.pointer, sizeof(privtab)) != TRUE)
5072 wrq->u.data.length = sizeof(privtab) / sizeof(privtab[0]);
5073 if (copy_to_user(wrq->u.data.pointer, privtab, sizeof(privtab)))
5077 case RTPRIV_IOCTL_SET:
5078 if(access_ok(VERIFY_READ, wrq->u.data.pointer, wrq->u.data.length) != TRUE)
5080 rt_ioctl_setparam(net_dev, NULL, NULL, wrq->u.data.pointer);
5082 case RTPRIV_IOCTL_GSITESURVEY:
5083 RTMPIoctlGetSiteSurvey(pAd, wrq);
5086 case RTPRIV_IOCTL_MAC:
5087 RTMPIoctlMAC(pAd, wrq);
5089 case RTPRIV_IOCTL_E2P:
5090 RTMPIoctlE2PROM(pAd, wrq);
5096 DBGPRINT(RT_DEBUG_ERROR, ("IOCTL::unknown IOCTL's cmd = 0x%08x\n", cmd));
5097 Status = -EOPNOTSUPP;
5101 if(StateMachineTouched) // Upper layer sent a MLME-related operations
5102 RT28XX_MLME_HANDLER(pAd);
5108 ==========================================================================
5112 TRUE if all parameters are OK, FALSE otherwise
5113 ==========================================================================
5116 IN PRTMP_ADAPTER pAdapter,
5119 NDIS_802_11_SSID Ssid, *pSsid=NULL;
5120 BOOLEAN StateMachineTouched = FALSE;
5123 if( strlen(arg) <= MAX_LEN_OF_SSID)
5125 NdisZeroMemory(&Ssid, sizeof(NDIS_802_11_SSID));
5126 if (strlen(arg) != 0)
5128 NdisMoveMemory(Ssid.Ssid, arg, strlen(arg));
5129 Ssid.SsidLength = strlen(arg);
5133 Ssid.SsidLength = 0;
5134 memcpy(Ssid.Ssid, "", 0);
5135 pAdapter->StaCfg.BssType = BSS_INFRA;
5136 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
5137 pAdapter->StaCfg.WepStatus = Ndis802_11EncryptionDisabled;
5141 if (pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE)
5143 RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
5144 DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
5147 pAdapter->MlmeAux.CurrReqIsFromNdis = TRUE;
5148 pAdapter->StaCfg.bScanReqIsFromWebUI = FALSE;
5149 pAdapter->bConfigChanged = TRUE;
5151 MlmeEnqueue(pAdapter,
5152 MLME_CNTL_STATE_MACHINE,
5154 sizeof(NDIS_802_11_SSID),
5157 StateMachineTouched = TRUE;
5158 DBGPRINT(RT_DEBUG_TRACE, ("Set_SSID_Proc::(Len=%d,Ssid=%s)\n", Ssid.SsidLength, Ssid.Ssid));
5163 if (StateMachineTouched) // Upper layer sent a MLME-related operations
5164 RT28XX_MLME_HANDLER(pAdapter);
5171 ==========================================================================
5173 Set WmmCapable Enable or Disable
5175 TRUE if all parameters are OK, FALSE otherwise
5176 ==========================================================================
5178 INT Set_WmmCapable_Proc(
5179 IN PRTMP_ADAPTER pAd,
5182 BOOLEAN bWmmCapable;
5184 bWmmCapable = simple_strtol(arg, 0, 10);
5186 if ((bWmmCapable == 1)
5188 pAd->CommonCfg.bWmmCapable = TRUE;
5189 else if (bWmmCapable == 0)
5190 pAd->CommonCfg.bWmmCapable = FALSE;
5192 return FALSE; //Invalid argument
5194 DBGPRINT(RT_DEBUG_TRACE, ("Set_WmmCapable_Proc::(bWmmCapable=%d)\n",
5195 pAd->CommonCfg.bWmmCapable));
5199 #endif // WMM_SUPPORT //
5202 ==========================================================================
5204 Set Network Type(Infrastructure/Adhoc mode)
5206 TRUE if all parameters are OK, FALSE otherwise
5207 ==========================================================================
5209 INT Set_NetworkType_Proc(
5210 IN PRTMP_ADAPTER pAdapter,
5215 if (strcmp(arg, "Adhoc") == 0)
5217 if (pAdapter->StaCfg.BssType != BSS_ADHOC)
5219 // Config has changed
5220 pAdapter->bConfigChanged = TRUE;
5221 if (MONITOR_ON(pAdapter))
5223 RTMP_IO_WRITE32(pAdapter, RX_FILTR_CFG, STANORMAL);
5224 RTMP_IO_READ32(pAdapter, MAC_SYS_CTRL, &Value);
5226 RTMP_IO_WRITE32(pAdapter, MAC_SYS_CTRL, Value);
5227 OPSTATUS_CLEAR_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED);
5228 pAdapter->StaCfg.bAutoReconnect = TRUE;
5229 LinkDown(pAdapter, FALSE);
5231 if (INFRA_ON(pAdapter))
5233 //BOOLEAN Cancelled;
5234 // Set the AutoReconnectSsid to prevent it reconnect to old SSID
5235 // Since calling this indicate user don't want to connect to that SSID anymore.
5236 pAdapter->MlmeAux.AutoReconnectSsidLen= 32;
5237 NdisZeroMemory(pAdapter->MlmeAux.AutoReconnectSsid, pAdapter->MlmeAux.AutoReconnectSsidLen);
5239 LinkDown(pAdapter, FALSE);
5241 DBGPRINT(RT_DEBUG_TRACE, ("NDIS_STATUS_MEDIA_DISCONNECT Event BB!\n"));
5244 pAdapter->StaCfg.BssType = BSS_ADHOC;
5245 pAdapter->net_dev->type = pAdapter->StaCfg.OriDevType;
5246 DBGPRINT(RT_DEBUG_TRACE, ("===>Set_NetworkType_Proc::(AD-HOC)\n"));
5248 else if (strcmp(arg, "Infra") == 0)
5250 if (pAdapter->StaCfg.BssType != BSS_INFRA)
5252 // Config has changed
5253 pAdapter->bConfigChanged = TRUE;
5254 if (MONITOR_ON(pAdapter))
5256 RTMP_IO_WRITE32(pAdapter, RX_FILTR_CFG, STANORMAL);
5257 RTMP_IO_READ32(pAdapter, MAC_SYS_CTRL, &Value);
5259 RTMP_IO_WRITE32(pAdapter, MAC_SYS_CTRL, Value);
5260 OPSTATUS_CLEAR_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED);
5261 pAdapter->StaCfg.bAutoReconnect = TRUE;
5262 LinkDown(pAdapter, FALSE);
5264 if (ADHOC_ON(pAdapter))
5266 // Set the AutoReconnectSsid to prevent it reconnect to old SSID
5267 // Since calling this indicate user don't want to connect to that SSID anymore.
5268 pAdapter->MlmeAux.AutoReconnectSsidLen= 32;
5269 NdisZeroMemory(pAdapter->MlmeAux.AutoReconnectSsid, pAdapter->MlmeAux.AutoReconnectSsidLen);
5271 LinkDown(pAdapter, FALSE);
5274 pAdapter->StaCfg.BssType = BSS_INFRA;
5275 pAdapter->net_dev->type = pAdapter->StaCfg.OriDevType;
5276 DBGPRINT(RT_DEBUG_TRACE, ("===>Set_NetworkType_Proc::(INFRA)\n"));
5278 pAdapter->StaCfg.BssType = BSS_INFRA;
5280 else if (strcmp(arg, "Monitor") == 0)
5283 BCN_TIME_CFG_STRUC csr;
5284 OPSTATUS_CLEAR_FLAG(pAdapter, fOP_STATUS_INFRA_ON);
5285 OPSTATUS_CLEAR_FLAG(pAdapter, fOP_STATUS_ADHOC_ON);
5286 OPSTATUS_SET_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED);
5287 // disable all periodic state machine
5288 pAdapter->StaCfg.bAutoReconnect = FALSE;
5289 // reset all mlme state machine
5290 RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
5291 DBGPRINT(RT_DEBUG_TRACE, ("fOP_STATUS_MEDIA_STATE_CONNECTED \n"));
5292 if (pAdapter->CommonCfg.CentralChannel == 0)
5294 if (pAdapter->CommonCfg.PhyMode == PHY_11AN_MIXED)
5295 pAdapter->CommonCfg.CentralChannel = 36;
5297 pAdapter->CommonCfg.CentralChannel = 6;
5300 N_ChannelCheck(pAdapter);
5302 if (pAdapter->CommonCfg.PhyMode >= PHY_11ABGN_MIXED &&
5303 pAdapter->CommonCfg.RegTransmitSetting.field.BW == BW_40 &&
5304 pAdapter->CommonCfg.RegTransmitSetting.field.EXTCHA == EXTCHA_ABOVE)
5306 // 40MHz ,control channel at lower
5307 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, BBP_R4, &bbpValue);
5308 bbpValue &= (~0x18);
5310 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R4, bbpValue);
5311 pAdapter->CommonCfg.BBPCurrentBW = BW_40;
5312 // RX : control channel at lower
5313 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, BBP_R3, &bbpValue);
5314 bbpValue &= (~0x20);
5315 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R3, bbpValue);
5317 RTMP_IO_READ32(pAdapter, TX_BAND_CFG, &Value);
5318 Value &= 0xfffffffe;
5319 RTMP_IO_WRITE32(pAdapter, TX_BAND_CFG, Value);
5320 pAdapter->CommonCfg.CentralChannel = pAdapter->CommonCfg.Channel + 2;
5321 AsicSwitchChannel(pAdapter, pAdapter->CommonCfg.CentralChannel, FALSE);
5322 AsicLockChannel(pAdapter, pAdapter->CommonCfg.CentralChannel);
5323 DBGPRINT(RT_DEBUG_TRACE, ("BW_40 ,control_channel(%d), CentralChannel(%d) \n",
5324 pAdapter->CommonCfg.Channel,
5325 pAdapter->CommonCfg.CentralChannel));
5327 else if (pAdapter->CommonCfg.PhyMode >= PHY_11ABGN_MIXED &&
5328 pAdapter->CommonCfg.RegTransmitSetting.field.BW == BW_40 &&
5329 pAdapter->CommonCfg.RegTransmitSetting.field.EXTCHA == EXTCHA_BELOW)
5331 // 40MHz ,control channel at upper
5332 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, BBP_R4, &bbpValue);
5333 bbpValue &= (~0x18);
5335 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R4, bbpValue);
5336 pAdapter->CommonCfg.BBPCurrentBW = BW_40;
5337 RTMP_IO_READ32(pAdapter, TX_BAND_CFG, &Value);
5339 RTMP_IO_WRITE32(pAdapter, TX_BAND_CFG, Value);
5341 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, BBP_R3, &bbpValue);
5343 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R3, bbpValue);
5344 pAdapter->CommonCfg.CentralChannel = pAdapter->CommonCfg.Channel - 2;
5345 AsicSwitchChannel(pAdapter, pAdapter->CommonCfg.CentralChannel, FALSE);
5346 AsicLockChannel(pAdapter, pAdapter->CommonCfg.CentralChannel);
5347 DBGPRINT(RT_DEBUG_TRACE, ("BW_40 ,control_channel(%d), CentralChannel(%d) \n",
5348 pAdapter->CommonCfg.Channel,
5349 pAdapter->CommonCfg.CentralChannel));
5354 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, BBP_R4, &bbpValue);
5355 bbpValue &= (~0x18);
5356 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R4, bbpValue);
5357 pAdapter->CommonCfg.BBPCurrentBW = BW_20;
5358 AsicSwitchChannel(pAdapter, pAdapter->CommonCfg.Channel, FALSE);
5359 AsicLockChannel(pAdapter, pAdapter->CommonCfg.Channel);
5360 DBGPRINT(RT_DEBUG_TRACE, ("BW_20, Channel(%d)\n", pAdapter->CommonCfg.Channel));
5362 // Enable Rx with promiscuous reception
5363 RTMP_IO_WRITE32(pAdapter, RX_FILTR_CFG, 0x3);
5364 // ASIC supporsts sniffer function with replacing RSSI with timestamp.
5365 //RTMP_IO_READ32(pAdapter, MAC_SYS_CTRL, &Value);
5367 //RTMP_IO_WRITE32(pAdapter, MAC_SYS_CTRL, Value);
5369 RTMP_IO_READ32(pAdapter, BCN_TIME_CFG, &csr.word);
5370 csr.field.bBeaconGen = 0;
5371 csr.field.bTBTTEnable = 0;
5372 csr.field.TsfSyncMode = 0;
5373 RTMP_IO_WRITE32(pAdapter, BCN_TIME_CFG, csr.word);
5375 pAdapter->StaCfg.BssType = BSS_MONITOR;
5376 pAdapter->net_dev->type = ARPHRD_IEEE80211_PRISM; //ARPHRD_IEEE80211; // IEEE80211
5377 DBGPRINT(RT_DEBUG_TRACE, ("===>Set_NetworkType_Proc::(MONITOR)\n"));
5380 // Reset Ralink supplicant to not use, it will be set to start when UI set PMK key
5381 pAdapter->StaCfg.WpaState = SS_NOTUSE;
5383 DBGPRINT(RT_DEBUG_TRACE, ("Set_NetworkType_Proc::(NetworkType=%d)\n", pAdapter->StaCfg.BssType));
5389 ==========================================================================
5391 Set Authentication mode
5393 TRUE if all parameters are OK, FALSE otherwise
5394 ==========================================================================
5396 INT Set_AuthMode_Proc(
5397 IN PRTMP_ADAPTER pAdapter,
5400 if ((strcmp(arg, "WEPAUTO") == 0) || (strcmp(arg, "wepauto") == 0))
5401 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeAutoSwitch;
5402 else if ((strcmp(arg, "OPEN") == 0) || (strcmp(arg, "open") == 0))
5403 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
5404 else if ((strcmp(arg, "SHARED") == 0) || (strcmp(arg, "shared") == 0))
5405 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeShared;
5406 else if ((strcmp(arg, "WPAPSK") == 0) || (strcmp(arg, "wpapsk") == 0))
5407 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPAPSK;
5408 else if ((strcmp(arg, "WPANONE") == 0) || (strcmp(arg, "wpanone") == 0))
5409 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPANone;
5410 else if ((strcmp(arg, "WPA2PSK") == 0) || (strcmp(arg, "wpa2psk") == 0))
5411 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA2PSK;
5412 else if ((strcmp(arg, "WPA") == 0) || (strcmp(arg, "wpa") == 0))
5413 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA;
5414 else if ((strcmp(arg, "WPA2") == 0) || (strcmp(arg, "wpa2") == 0))
5415 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA2;
5419 pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED;
5421 DBGPRINT(RT_DEBUG_TRACE, ("Set_AuthMode_Proc::(AuthMode=%d)\n", pAdapter->StaCfg.AuthMode));
5427 ==========================================================================
5431 TRUE if all parameters are OK, FALSE otherwise
5432 ==========================================================================
5434 INT Set_EncrypType_Proc(
5435 IN PRTMP_ADAPTER pAdapter,
5438 if ((strcmp(arg, "NONE") == 0) || (strcmp(arg, "none") == 0))
5440 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
5441 return TRUE; // do nothing
5443 pAdapter->StaCfg.WepStatus = Ndis802_11WEPDisabled;
5444 pAdapter->StaCfg.PairCipher = Ndis802_11WEPDisabled;
5445 pAdapter->StaCfg.GroupCipher = Ndis802_11WEPDisabled;
5447 else if ((strcmp(arg, "WEP") == 0) || (strcmp(arg, "wep") == 0))
5449 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
5450 return TRUE; // do nothing
5452 pAdapter->StaCfg.WepStatus = Ndis802_11WEPEnabled;
5453 pAdapter->StaCfg.PairCipher = Ndis802_11WEPEnabled;
5454 pAdapter->StaCfg.GroupCipher = Ndis802_11WEPEnabled;
5456 else if ((strcmp(arg, "TKIP") == 0) || (strcmp(arg, "tkip") == 0))
5458 if (pAdapter->StaCfg.AuthMode < Ndis802_11AuthModeWPA)
5459 return TRUE; // do nothing
5461 pAdapter->StaCfg.WepStatus = Ndis802_11Encryption2Enabled;
5462 pAdapter->StaCfg.PairCipher = Ndis802_11Encryption2Enabled;
5463 pAdapter->StaCfg.GroupCipher = Ndis802_11Encryption2Enabled;
5465 else if ((strcmp(arg, "AES") == 0) || (strcmp(arg, "aes") == 0))
5467 if (pAdapter->StaCfg.AuthMode < Ndis802_11AuthModeWPA)
5468 return TRUE; // do nothing
5470 pAdapter->StaCfg.WepStatus = Ndis802_11Encryption3Enabled;
5471 pAdapter->StaCfg.PairCipher = Ndis802_11Encryption3Enabled;
5472 pAdapter->StaCfg.GroupCipher = Ndis802_11Encryption3Enabled;
5477 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
5479 DBGPRINT(RT_DEBUG_TRACE, ("Set_EncrypType_Proc::(EncrypType=%d)\n", pAdapter->StaCfg.WepStatus));
5485 ==========================================================================
5489 TRUE if all parameters are OK, FALSE otherwise
5490 ==========================================================================
5492 INT Set_DefaultKeyID_Proc(
5493 IN PRTMP_ADAPTER pAdapter,
5498 KeyIdx = simple_strtol(arg, 0, 10);
5499 if((KeyIdx >= 1 ) && (KeyIdx <= 4))
5500 pAdapter->StaCfg.DefaultKeyId = (UCHAR) (KeyIdx - 1 );
5502 return FALSE; //Invalid argument
5504 DBGPRINT(RT_DEBUG_TRACE, ("Set_DefaultKeyID_Proc::(DefaultKeyID=%d)\n", pAdapter->StaCfg.DefaultKeyId));
5510 ==========================================================================
5514 TRUE if all parameters are OK, FALSE otherwise
5515 ==========================================================================
5518 IN PRTMP_ADAPTER pAdapter,
5523 UCHAR CipherAlg=CIPHER_WEP64;
5525 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
5526 return TRUE; // do nothing
5528 KeyLen = strlen(arg);
5532 case 5: //wep 40 Ascii type
5533 pAdapter->SharedKey[BSS0][0].KeyLen = KeyLen;
5534 memcpy(pAdapter->SharedKey[BSS0][0].Key, arg, KeyLen);
5535 CipherAlg = CIPHER_WEP64;
5536 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key1_Proc::(Key1=%s and type=%s)\n", arg, "Ascii"));
5538 case 10: //wep 40 Hex type
5539 for(i=0; i < KeyLen; i++)
5541 if( !isxdigit(*(arg+i)) )
5542 return FALSE; //Not Hex value;
5544 pAdapter->SharedKey[BSS0][0].KeyLen = KeyLen / 2 ;
5545 AtoH(arg, pAdapter->SharedKey[BSS0][0].Key, KeyLen / 2);
5546 CipherAlg = CIPHER_WEP64;
5547 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key1_Proc::(Key1=%s and type=%s)\n", arg, "Hex"));
5549 case 13: //wep 104 Ascii type
5550 pAdapter->SharedKey[BSS0][0].KeyLen = KeyLen;
5551 memcpy(pAdapter->SharedKey[BSS0][0].Key, arg, KeyLen);
5552 CipherAlg = CIPHER_WEP128;
5553 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key1_Proc::(Key1=%s and type=%s)\n", arg, "Ascii"));
5555 case 26: //wep 104 Hex type
5556 for(i=0; i < KeyLen; i++)
5558 if( !isxdigit(*(arg+i)) )
5559 return FALSE; //Not Hex value;
5561 pAdapter->SharedKey[BSS0][0].KeyLen = KeyLen / 2 ;
5562 AtoH(arg, pAdapter->SharedKey[BSS0][0].Key, KeyLen / 2);
5563 CipherAlg = CIPHER_WEP128;
5564 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key1_Proc::(Key1=%s and type=%s)\n", arg, "Hex"));
5566 default: //Invalid argument
5567 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key1_Proc::Invalid argument (=%s)\n", arg));
5571 pAdapter->SharedKey[BSS0][0].CipherAlg = CipherAlg;
5573 // Set keys (into ASIC)
5574 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
5576 else // Old WEP stuff
5578 AsicAddSharedKeyEntry(pAdapter,
5581 pAdapter->SharedKey[BSS0][0].CipherAlg,
5582 pAdapter->SharedKey[BSS0][0].Key,
5590 ==========================================================================
5595 TRUE if all parameters are OK, FALSE otherwise
5596 ==========================================================================
5599 IN PRTMP_ADAPTER pAdapter,
5604 UCHAR CipherAlg=CIPHER_WEP64;
5606 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
5607 return TRUE; // do nothing
5609 KeyLen = strlen(arg);
5613 case 5: //wep 40 Ascii type
5614 pAdapter->SharedKey[BSS0][1].KeyLen = KeyLen;
5615 memcpy(pAdapter->SharedKey[BSS0][1].Key, arg, KeyLen);
5616 CipherAlg = CIPHER_WEP64;
5617 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key2_Proc::(Key2=%s and type=%s)\n", arg, "Ascii"));
5619 case 10: //wep 40 Hex type
5620 for(i=0; i < KeyLen; i++)
5622 if( !isxdigit(*(arg+i)) )
5623 return FALSE; //Not Hex value;
5625 pAdapter->SharedKey[BSS0][1].KeyLen = KeyLen / 2 ;
5626 AtoH(arg, pAdapter->SharedKey[BSS0][1].Key, KeyLen / 2);
5627 CipherAlg = CIPHER_WEP64;
5628 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key2_Proc::(Key2=%s and type=%s)\n", arg, "Hex"));
5630 case 13: //wep 104 Ascii type
5631 pAdapter->SharedKey[BSS0][1].KeyLen = KeyLen;
5632 memcpy(pAdapter->SharedKey[BSS0][1].Key, arg, KeyLen);
5633 CipherAlg = CIPHER_WEP128;
5634 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key2_Proc::(Key2=%s and type=%s)\n", arg, "Ascii"));
5636 case 26: //wep 104 Hex type
5637 for(i=0; i < KeyLen; i++)
5639 if( !isxdigit(*(arg+i)) )
5640 return FALSE; //Not Hex value;
5642 pAdapter->SharedKey[BSS0][1].KeyLen = KeyLen / 2 ;
5643 AtoH(arg, pAdapter->SharedKey[BSS0][1].Key, KeyLen / 2);
5644 CipherAlg = CIPHER_WEP128;
5645 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key2_Proc::(Key2=%s and type=%s)\n", arg, "Hex"));
5647 default: //Invalid argument
5648 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key2_Proc::Invalid argument (=%s)\n", arg));
5651 pAdapter->SharedKey[BSS0][1].CipherAlg = CipherAlg;
5653 // Set keys (into ASIC)
5654 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
5656 else // Old WEP stuff
5658 AsicAddSharedKeyEntry(pAdapter,
5661 pAdapter->SharedKey[BSS0][1].CipherAlg,
5662 pAdapter->SharedKey[BSS0][1].Key,
5670 ==========================================================================
5674 TRUE if all parameters are OK, FALSE otherwise
5675 ==========================================================================
5678 IN PRTMP_ADAPTER pAdapter,
5683 UCHAR CipherAlg=CIPHER_WEP64;
5685 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
5686 return TRUE; // do nothing
5688 KeyLen = strlen(arg);
5692 case 5: //wep 40 Ascii type
5693 pAdapter->SharedKey[BSS0][2].KeyLen = KeyLen;
5694 memcpy(pAdapter->SharedKey[BSS0][2].Key, arg, KeyLen);
5695 CipherAlg = CIPHER_WEP64;
5696 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key3_Proc::(Key3=%s and type=Ascii)\n", arg));
5698 case 10: //wep 40 Hex type
5699 for(i=0; i < KeyLen; i++)
5701 if( !isxdigit(*(arg+i)) )
5702 return FALSE; //Not Hex value;
5704 pAdapter->SharedKey[BSS0][2].KeyLen = KeyLen / 2 ;
5705 AtoH(arg, pAdapter->SharedKey[BSS0][2].Key, KeyLen / 2);
5706 CipherAlg = CIPHER_WEP64;
5707 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key3_Proc::(Key3=%s and type=Hex)\n", arg));
5709 case 13: //wep 104 Ascii type
5710 pAdapter->SharedKey[BSS0][2].KeyLen = KeyLen;
5711 memcpy(pAdapter->SharedKey[BSS0][2].Key, arg, KeyLen);
5712 CipherAlg = CIPHER_WEP128;
5713 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key3_Proc::(Key3=%s and type=Ascii)\n", arg));
5715 case 26: //wep 104 Hex type
5716 for(i=0; i < KeyLen; i++)
5718 if( !isxdigit(*(arg+i)) )
5719 return FALSE; //Not Hex value;
5721 pAdapter->SharedKey[BSS0][2].KeyLen = KeyLen / 2 ;
5722 AtoH(arg, pAdapter->SharedKey[BSS0][2].Key, KeyLen / 2);
5723 CipherAlg = CIPHER_WEP128;
5724 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key3_Proc::(Key3=%s and type=Hex)\n", arg));
5726 default: //Invalid argument
5727 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key3_Proc::Invalid argument (=%s)\n", arg));
5730 pAdapter->SharedKey[BSS0][2].CipherAlg = CipherAlg;
5732 // Set keys (into ASIC)
5733 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
5735 else // Old WEP stuff
5737 AsicAddSharedKeyEntry(pAdapter,
5740 pAdapter->SharedKey[BSS0][2].CipherAlg,
5741 pAdapter->SharedKey[BSS0][2].Key,
5749 ==========================================================================
5753 TRUE if all parameters are OK, FALSE otherwise
5754 ==========================================================================
5757 IN PRTMP_ADAPTER pAdapter,
5762 UCHAR CipherAlg=CIPHER_WEP64;
5764 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
5765 return TRUE; // do nothing
5767 KeyLen = strlen(arg);
5771 case 5: //wep 40 Ascii type
5772 pAdapter->SharedKey[BSS0][3].KeyLen = KeyLen;
5773 memcpy(pAdapter->SharedKey[BSS0][3].Key, arg, KeyLen);
5774 CipherAlg = CIPHER_WEP64;
5775 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key4_Proc::(Key4=%s and type=%s)\n", arg, "Ascii"));
5777 case 10: //wep 40 Hex type
5778 for(i=0; i < KeyLen; i++)
5780 if( !isxdigit(*(arg+i)) )
5781 return FALSE; //Not Hex value;
5783 pAdapter->SharedKey[BSS0][3].KeyLen = KeyLen / 2 ;
5784 AtoH(arg, pAdapter->SharedKey[BSS0][3].Key, KeyLen / 2);
5785 CipherAlg = CIPHER_WEP64;
5786 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key4_Proc::(Key4=%s and type=%s)\n", arg, "Hex"));
5788 case 13: //wep 104 Ascii type
5789 pAdapter->SharedKey[BSS0][3].KeyLen = KeyLen;
5790 memcpy(pAdapter->SharedKey[BSS0][3].Key, arg, KeyLen);
5791 CipherAlg = CIPHER_WEP128;
5792 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key4_Proc::(Key4=%s and type=%s)\n", arg, "Ascii"));
5794 case 26: //wep 104 Hex type
5795 for(i=0; i < KeyLen; i++)
5797 if( !isxdigit(*(arg+i)) )
5798 return FALSE; //Not Hex value;
5800 pAdapter->SharedKey[BSS0][3].KeyLen = KeyLen / 2 ;
5801 AtoH(arg, pAdapter->SharedKey[BSS0][3].Key, KeyLen / 2);
5802 CipherAlg = CIPHER_WEP128;
5803 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key4_Proc::(Key4=%s and type=%s)\n", arg, "Hex"));
5805 default: //Invalid argument
5806 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key4_Proc::Invalid argument (=%s)\n", arg));
5809 pAdapter->SharedKey[BSS0][3].CipherAlg = CipherAlg;
5811 // Set keys (into ASIC)
5812 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
5814 else // Old WEP stuff
5816 AsicAddSharedKeyEntry(pAdapter,
5819 pAdapter->SharedKey[BSS0][3].CipherAlg,
5820 pAdapter->SharedKey[BSS0][3].Key,
5829 ==========================================================================
5833 TRUE if all parameters are OK, FALSE otherwise
5834 ==========================================================================
5836 INT Set_WPAPSK_Proc(
5837 IN PRTMP_ADAPTER pAdapter,
5840 UCHAR keyMaterial[40];
5842 if ((pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPAPSK) &&
5843 (pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPA2PSK) &&
5844 (pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPANone)
5846 return TRUE; // do nothing
5848 DBGPRINT(RT_DEBUG_TRACE, ("Set_WPAPSK_Proc::(WPAPSK=%s)\n", arg));
5850 NdisZeroMemory(keyMaterial, 40);
5852 if ((strlen(arg) < 8) || (strlen(arg) > 64))
5854 DBGPRINT(RT_DEBUG_TRACE, ("Set failed!!(WPAPSK=%s), WPAPSK key-string required 8 ~ 64 characters \n", arg));
5858 if (strlen(arg) == 64)
5860 AtoH(arg, keyMaterial, 32);
5861 NdisMoveMemory(pAdapter->StaCfg.PMK, keyMaterial, 32);
5866 PasswordHash((char *)arg, pAdapter->MlmeAux.Ssid, pAdapter->MlmeAux.SsidLen, keyMaterial);
5867 NdisMoveMemory(pAdapter->StaCfg.PMK, keyMaterial, 32);
5872 if(pAdapter->StaCfg.BssType == BSS_ADHOC &&
5873 pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPANone)
5875 pAdapter->StaCfg.WpaState = SS_NOTUSE;
5879 // Start STA supplicant state machine
5880 pAdapter->StaCfg.WpaState = SS_START;
5887 ==========================================================================
5889 Set Power Saving mode
5891 TRUE if all parameters are OK, FALSE otherwise
5892 ==========================================================================
5894 INT Set_PSMode_Proc(
5895 IN PRTMP_ADAPTER pAdapter,
5898 if (pAdapter->StaCfg.BssType == BSS_INFRA)
5900 if ((strcmp(arg, "Max_PSP") == 0) ||
5901 (strcmp(arg, "max_psp") == 0) ||
5902 (strcmp(arg, "MAX_PSP") == 0))
5904 // do NOT turn on PSM bit here, wait until MlmeCheckForPsmChange()
5905 // to exclude certain situations.
5906 if (pAdapter->StaCfg.bWindowsACCAMEnable == FALSE)
5907 pAdapter->StaCfg.WindowsPowerMode = Ndis802_11PowerModeMAX_PSP;
5908 pAdapter->StaCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeMAX_PSP;
5909 OPSTATUS_SET_FLAG(pAdapter, fOP_STATUS_RECEIVE_DTIM);
5910 pAdapter->StaCfg.DefaultListenCount = 5;
5913 else if ((strcmp(arg, "Fast_PSP") == 0) ||
5914 (strcmp(arg, "fast_psp") == 0) ||
5915 (strcmp(arg, "FAST_PSP") == 0))
5917 // do NOT turn on PSM bit here, wait until MlmeCheckForPsmChange()
5918 // to exclude certain situations.
5919 OPSTATUS_SET_FLAG(pAdapter, fOP_STATUS_RECEIVE_DTIM);
5920 if (pAdapter->StaCfg.bWindowsACCAMEnable == FALSE)
5921 pAdapter->StaCfg.WindowsPowerMode = Ndis802_11PowerModeFast_PSP;
5922 pAdapter->StaCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeFast_PSP;
5923 pAdapter->StaCfg.DefaultListenCount = 3;
5925 else if ((strcmp(arg, "Legacy_PSP") == 0) ||
5926 (strcmp(arg, "legacy_psp") == 0) ||
5927 (strcmp(arg, "LEGACY_PSP") == 0))
5929 // do NOT turn on PSM bit here, wait until MlmeCheckForPsmChange()
5930 // to exclude certain situations.
5931 OPSTATUS_SET_FLAG(pAdapter, fOP_STATUS_RECEIVE_DTIM);
5932 if (pAdapter->StaCfg.bWindowsACCAMEnable == FALSE)
5933 pAdapter->StaCfg.WindowsPowerMode = Ndis802_11PowerModeLegacy_PSP;
5934 pAdapter->StaCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeLegacy_PSP;
5935 pAdapter->StaCfg.DefaultListenCount = 3;
5939 //Default Ndis802_11PowerModeCAM
5940 // clear PSM bit immediately
5941 MlmeSetPsmBit(pAdapter, PWR_ACTIVE);
5942 OPSTATUS_SET_FLAG(pAdapter, fOP_STATUS_RECEIVE_DTIM);
5943 if (pAdapter->StaCfg.bWindowsACCAMEnable == FALSE)
5944 pAdapter->StaCfg.WindowsPowerMode = Ndis802_11PowerModeCAM;
5945 pAdapter->StaCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeCAM;
5948 DBGPRINT(RT_DEBUG_TRACE, ("Set_PSMode_Proc::(PSMode=%ld)\n", pAdapter->StaCfg.WindowsPowerMode));
5958 ==========================================================================
5960 Set WpaSupport flag.
5962 0: Driver ignore wpa_supplicant.
5963 1: wpa_supplicant initiates scanning and AP selection.
5964 2: driver takes care of scanning, AP selection, and IEEE 802.11 association parameters.
5966 TRUE if all parameters are OK, FALSE otherwise
5967 ==========================================================================
5969 INT Set_Wpa_Support(
5970 IN PRTMP_ADAPTER pAd,
5974 if ( simple_strtol(arg, 0, 10) == 0)
5975 pAd->StaCfg.WpaSupplicantUP = WPA_SUPPLICANT_DISABLE;
5976 else if ( simple_strtol(arg, 0, 10) == 1)
5977 pAd->StaCfg.WpaSupplicantUP = WPA_SUPPLICANT_ENABLE;
5978 else if ( simple_strtol(arg, 0, 10) == 2)
5979 pAd->StaCfg.WpaSupplicantUP = WPA_SUPPLICANT_ENABLE_WITH_WEB_UI;
5981 pAd->StaCfg.WpaSupplicantUP = WPA_SUPPLICANT_DISABLE;
5983 DBGPRINT(RT_DEBUG_TRACE, ("Set_Wpa_Support::(WpaSupplicantUP=%d)\n", pAd->StaCfg.WpaSupplicantUP));
5990 ==========================================================================
5994 pAdapter Pointer to our adapter
5995 wrq Pointer to the ioctl argument
6002 1.) iwpriv ra0 mac 0 ==> read MAC where Addr=0x0
6003 2.) iwpriv ra0 mac 0=12 ==> write MAC where Addr=0x0, value=12
6004 ==========================================================================
6007 IN PRTMP_ADAPTER pAdapter,
6008 IN struct iwreq *wrq)
6016 UCHAR temp[16], temp2[16];
6017 UINT32 macValue = 0;
6021 memset(msg, 0x00, 1024);
6022 if (wrq->u.data.length > 1) //No parameters.
6024 Status = copy_from_user(arg, wrq->u.data.pointer, (wrq->u.data.length > 255) ? 255 : wrq->u.data.length);
6027 //Parsing Read or Write
6032 if ((value = rtstrchr(this_char, '=')) != NULL)
6035 if (!value || !*value)
6038 if(strlen(this_char) > 4)
6041 j = strlen(this_char);
6044 if(this_char[j] > 'f' || this_char[j] < '0')
6049 k = j = strlen(this_char);
6052 this_char[4-k+j] = this_char[j];
6056 this_char[3-k++]='0';
6059 if(strlen(this_char) == 4)
6061 AtoH(this_char, temp, 2);
6062 macAddr = *temp*256 + temp[1];
6063 if (macAddr < 0xFFFF)
6065 RTMP_IO_READ32(pAdapter, macAddr, &macValue);
6066 DBGPRINT(RT_DEBUG_TRACE, ("MacAddr=%lx, MacValue=%x\n", macAddr, macValue));
6067 sprintf(msg+strlen(msg), "[0x%08lX]:%08X ", macAddr , macValue);
6070 {//Invalid parametes, so default printk all bbp
6077 memcpy(&temp2, value, strlen(value));
6078 temp2[strlen(value)] = '\0';
6081 if((strlen(this_char) > 4) || strlen(temp2) > 8)
6084 j = strlen(this_char);
6087 if(this_char[j] > 'f' || this_char[j] < '0')
6094 if(temp2[j] > 'f' || temp2[j] < '0')
6099 k = j = strlen(this_char);
6102 this_char[4-k+j] = this_char[j];
6106 this_char[3-k++]='0';
6110 k = j = strlen(temp2);
6113 temp2[8-k+j] = temp2[j];
6121 AtoH(this_char, temp, 2);
6122 macAddr = *temp*256 + temp[1];
6124 AtoH(temp2, temp, 4);
6125 macValue = *temp*256*256*256 + temp[1]*256*256 + temp[2]*256 + temp[3];
6128 if (macAddr == (HW_DEBUG_SETTING_BASE + 4))
6130 // 0x2bf4: byte0 non-zero: enable R17 tuning, 0: disable R17 tuning
6131 if (macValue & 0x000000ff)
6133 pAdapter->BbpTuning.bEnable = TRUE;
6134 DBGPRINT(RT_DEBUG_TRACE,("turn on R17 tuning\n"));
6139 pAdapter->BbpTuning.bEnable = FALSE;
6140 R66 = 0x26 + GET_LNA_GAIN(pAdapter);
6141 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R66, (0x26 + GET_LNA_GAIN(pAdapter)));
6142 DBGPRINT(RT_DEBUG_TRACE,("turn off R17 tuning, restore to 0x%02x\n", R66));
6147 DBGPRINT(RT_DEBUG_TRACE, ("MacAddr=%02lx, MacValue=0x%x\n", macAddr, macValue));
6149 RTMP_IO_WRITE32(pAdapter, macAddr, macValue);
6150 sprintf(msg+strlen(msg), "[0x%08lX]:%08X ", macAddr, macValue);
6155 if(strlen(msg) == 1)
6156 sprintf(msg+strlen(msg), "===>Error command format!");
6158 // Copy the information into the user buffer
6159 wrq->u.data.length = strlen(msg);
6160 Status = copy_to_user(wrq->u.data.pointer, msg, wrq->u.data.length);
6162 DBGPRINT(RT_DEBUG_TRACE, ("<==RTMPIoctlMAC\n\n"));
6166 ==========================================================================
6170 pAdapter Pointer to our adapter
6171 wrq Pointer to the ioctl argument
6178 1.) iwpriv ra0 e2p 0 ==> read E2PROM where Addr=0x0
6179 2.) iwpriv ra0 e2p 0=1234 ==> write E2PROM where Addr=0x0, value=1234
6180 ==========================================================================
6182 VOID RTMPIoctlE2PROM(
6183 IN PRTMP_ADAPTER pAdapter,
6184 IN struct iwreq *wrq)
6192 UCHAR temp[16], temp2[16];
6197 memset(msg, 0x00, 1024);
6198 if (wrq->u.data.length > 1) //No parameters.
6200 Status = copy_from_user(arg, wrq->u.data.pointer, (wrq->u.data.length > 255) ? 255 : wrq->u.data.length);
6203 //Parsing Read or Write
6210 if ((value = rtstrchr(this_char, '=')) != NULL)
6213 if (!value || !*value)
6217 if(strlen(this_char) > 4)
6220 j = strlen(this_char);
6223 if(this_char[j] > 'f' || this_char[j] < '0')
6228 k = j = strlen(this_char);
6231 this_char[4-k+j] = this_char[j];
6235 this_char[3-k++]='0';
6238 if(strlen(this_char) == 4)
6240 AtoH(this_char, temp, 2);
6241 eepAddr = *temp*256 + temp[1];
6242 if (eepAddr < 0xFFFF)
6244 RT28xx_EEPROM_READ16(pAdapter, eepAddr, eepValue);
6245 sprintf(msg+strlen(msg), "[0x%04X]:0x%04X ", eepAddr , eepValue);
6248 {//Invalid parametes, so default printk all bbp
6255 memcpy(&temp2, value, strlen(value));
6256 temp2[strlen(value)] = '\0';
6259 if((strlen(this_char) > 4) || strlen(temp2) > 8)
6262 j = strlen(this_char);
6265 if(this_char[j] > 'f' || this_char[j] < '0')
6271 if(temp2[j] > 'f' || temp2[j] < '0')
6276 k = j = strlen(this_char);
6279 this_char[4-k+j] = this_char[j];
6283 this_char[3-k++]='0';
6287 k = j = strlen(temp2);
6290 temp2[4-k+j] = temp2[j];
6297 AtoH(this_char, temp, 2);
6298 eepAddr = *temp*256 + temp[1];
6300 AtoH(temp2, temp, 2);
6301 eepValue = *temp*256 + temp[1];
6303 RT28xx_EEPROM_WRITE16(pAdapter, eepAddr, eepValue);
6304 sprintf(msg+strlen(msg), "[0x%02X]:%02X ", eepAddr, eepValue);
6308 if(strlen(msg) == 1)
6309 sprintf(msg+strlen(msg), "===>Error command format!");
6312 // Copy the information into the user buffer
6313 wrq->u.data.length = strlen(msg);
6314 Status = copy_to_user(wrq->u.data.pointer, msg, wrq->u.data.length);
6316 DBGPRINT(RT_DEBUG_TRACE, ("<==RTMPIoctlE2PROM\n"));
6323 INT Set_TGnWifiTest_Proc(
6324 IN PRTMP_ADAPTER pAd,
6327 if (simple_strtol(arg, 0, 10) == 0)
6328 pAd->StaCfg.bTGnWifiTest = FALSE;
6330 pAd->StaCfg.bTGnWifiTest = TRUE;
6332 DBGPRINT(RT_DEBUG_TRACE, ("IF Set_TGnWifiTest_Proc::(bTGnWifiTest=%d)\n", pAd->StaCfg.bTGnWifiTest));
6336 INT Set_LongRetryLimit_Proc(
6337 IN PRTMP_ADAPTER pAdapter,
6340 TX_RTY_CFG_STRUC tx_rty_cfg;
6341 UCHAR LongRetryLimit = (UCHAR)simple_strtol(arg, 0, 10);
6343 RTMP_IO_READ32(pAdapter, TX_RTY_CFG, &tx_rty_cfg.word);
6344 tx_rty_cfg.field.LongRtyLimit = LongRetryLimit;
6345 RTMP_IO_WRITE32(pAdapter, TX_RTY_CFG, tx_rty_cfg.word);
6346 DBGPRINT(RT_DEBUG_TRACE, ("IF Set_LongRetryLimit_Proc::(tx_rty_cfg=0x%x)\n", tx_rty_cfg.word));
6350 INT Set_ShortRetryLimit_Proc(
6351 IN PRTMP_ADAPTER pAdapter,
6354 TX_RTY_CFG_STRUC tx_rty_cfg;
6355 UCHAR ShortRetryLimit = (UCHAR)simple_strtol(arg, 0, 10);
6357 RTMP_IO_READ32(pAdapter, TX_RTY_CFG, &tx_rty_cfg.word);
6358 tx_rty_cfg.field.ShortRtyLimit = ShortRetryLimit;
6359 RTMP_IO_WRITE32(pAdapter, TX_RTY_CFG, tx_rty_cfg.word);
6360 DBGPRINT(RT_DEBUG_TRACE, ("IF Set_ShortRetryLimit_Proc::(tx_rty_cfg=0x%x)\n", tx_rty_cfg.word));