2 *************************************************************************
4 * 5F., No.36, Taiyuan St., Jhubei City,
8 * (c) Copyright 2002-2007, Ralink Technology, Inc.
10 * This program is free software; you can redistribute it and/or modify *
11 * it under the terms of the GNU General Public License as published by *
12 * the Free Software Foundation; either version 2 of the License, or *
13 * (at your option) any later version. *
15 * This program is distributed in the hope that it will be useful, *
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
18 * GNU General Public License for more details. *
20 * You should have received a copy of the GNU General Public License *
21 * along with this program; if not, write to the *
22 * Free Software Foundation, Inc., *
23 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
25 *************************************************************************
31 IOCTL related subroutines
35 -------- ---------- ----------------------------------------------
36 Rory Chen 01-03-2003 created
37 Rory Chen 02-14-2005 modify to support RT61
40 #include "rt_config.h"
43 extern ULONG RTDebugLevel;
47 #define WEP_SMALL_KEY_LEN (40/8)
48 #define WEP_LARGE_KEY_LEN (104/8)
50 #define GROUP_KEY_NO 4
52 extern UCHAR CipherWpa2Template[];
53 extern UCHAR CipherWpaPskTkip[];
54 extern UCHAR CipherWpaPskTkipLen;
56 typedef struct PACKED _RT_VERSION_INFO{
62 UINT DriverBuildMonth;
64 } RT_VERSION_INFO, *PRT_VERSION_INFO;
66 struct iw_priv_args privtab[] = {
68 IW_PRIV_TYPE_CHAR | 1024, 0,
71 { RTPRIV_IOCTL_SHOW, 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK,
73 { RTPRIV_IOCTL_SHOW, IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK,
75 /* --- sub-ioctls definitions --- */
77 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "connStatus" },
79 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "driverVer" },
81 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "bainfo" },
83 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "descinfo" },
85 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "radio_off" },
87 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "radio_on" },
88 #ifdef QOS_DLS_SUPPORT
89 { SHOW_DLS_ENTRY_INFO,
90 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "dlsentryinfo" },
91 #endif // QOS_DLS_SUPPORT //
93 IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "show" },
94 /* --- sub-ioctls relations --- */
98 IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK,
101 IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | 1024,
104 IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | 1024,
108 { RTPRIV_IOCTL_STATISTICS,
109 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK,
111 { RTPRIV_IOCTL_GSITESURVEY,
112 0, IW_PRIV_TYPE_CHAR | 1024,
117 IN PRTMP_ADAPTER pAdapter,
121 INT Set_WmmCapable_Proc(
122 IN PRTMP_ADAPTER pAd,
126 INT Set_NetworkType_Proc(
127 IN PRTMP_ADAPTER pAdapter,
130 INT Set_AuthMode_Proc(
131 IN PRTMP_ADAPTER pAdapter,
134 INT Set_EncrypType_Proc(
135 IN PRTMP_ADAPTER pAdapter,
138 INT Set_DefaultKeyID_Proc(
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,
159 IN PRTMP_ADAPTER pAdapter,
164 IN PRTMP_ADAPTER pAdapter,
167 #ifdef WPA_SUPPLICANT_SUPPORT
169 IN PRTMP_ADAPTER pAd,
171 #endif // WPA_SUPPLICANT_SUPPORT //
175 IN PRTMP_ADAPTER pAdapter,
176 IN struct iwreq *wrq);
179 IN PRTMP_ADAPTER pAdapter,
180 IN struct iwreq *wrq);
182 VOID RTMPIoctlE2PROM(
183 IN PRTMP_ADAPTER pAdapter,
184 IN struct iwreq *wrq);
188 NDIS_STATUS RTMPWPANoneAddKeyProc(
189 IN PRTMP_ADAPTER pAd,
192 INT Set_FragTest_Proc(
193 IN PRTMP_ADAPTER pAdapter,
196 #ifdef DOT11_N_SUPPORT
197 INT Set_TGnWifiTest_Proc(
198 IN PRTMP_ADAPTER pAd,
200 #endif // DOT11_N_SUPPORT //
202 INT Set_LongRetryLimit_Proc(
203 IN PRTMP_ADAPTER pAdapter,
206 INT Set_ShortRetryLimit_Proc(
207 IN PRTMP_ADAPTER pAdapter,
210 #ifdef EXT_BUILD_CHANNEL_LIST
211 INT Set_Ieee80211dClientMode_Proc(
212 IN PRTMP_ADAPTER pAdapter,
214 #endif // EXT_BUILD_CHANNEL_LIST //
216 #ifdef CARRIER_DETECTION_SUPPORT
217 INT Set_CarrierDetect_Proc(
218 IN PRTMP_ADAPTER pAd,
220 #endif // CARRIER_DETECTION_SUPPORT //
224 INT (*set_proc)(PRTMP_ADAPTER pAdapter, PUCHAR arg);
225 } *PRTMP_PRIVATE_SET_PROC, RTMP_PRIVATE_SUPPORT_PROC[] = {
226 {"DriverVersion", Set_DriverVersion_Proc},
227 {"CountryRegion", Set_CountryRegion_Proc},
228 {"CountryRegionABand", Set_CountryRegionABand_Proc},
229 {"SSID", Set_SSID_Proc},
230 {"WirelessMode", Set_WirelessMode_Proc},
231 {"TxBurst", Set_TxBurst_Proc},
232 {"TxPreamble", Set_TxPreamble_Proc},
233 {"TxPower", Set_TxPower_Proc},
234 {"Channel", Set_Channel_Proc},
235 {"BGProtection", Set_BGProtection_Proc},
236 {"RTSThreshold", Set_RTSThreshold_Proc},
237 {"FragThreshold", Set_FragThreshold_Proc},
238 #ifdef DOT11_N_SUPPORT
239 {"HtBw", Set_HtBw_Proc},
240 {"HtMcs", Set_HtMcs_Proc},
241 {"HtGi", Set_HtGi_Proc},
242 {"HtOpMode", Set_HtOpMode_Proc},
243 {"HtExtcha", Set_HtExtcha_Proc},
244 {"HtMpduDensity", Set_HtMpduDensity_Proc},
245 {"HtBaWinSize", Set_HtBaWinSize_Proc},
246 {"HtRdg", Set_HtRdg_Proc},
247 {"HtAmsdu", Set_HtAmsdu_Proc},
248 {"HtAutoBa", Set_HtAutoBa_Proc},
249 {"HtBaDecline", Set_BADecline_Proc},
250 {"HtProtect", Set_HtProtect_Proc},
251 {"HtMimoPs", Set_HtMimoPs_Proc},
252 #endif // DOT11_N_SUPPORT //
254 #ifdef AGGREGATION_SUPPORT
255 {"PktAggregate", Set_PktAggregate_Proc},
259 {"WmmCapable", Set_WmmCapable_Proc},
261 {"IEEE80211H", Set_IEEE80211H_Proc},
262 {"NetworkType", Set_NetworkType_Proc},
263 {"AuthMode", Set_AuthMode_Proc},
264 {"EncrypType", Set_EncrypType_Proc},
265 {"DefaultKeyID", Set_DefaultKeyID_Proc},
266 {"Key1", Set_Key1_Proc},
267 {"Key2", Set_Key2_Proc},
268 {"Key3", Set_Key3_Proc},
269 {"Key4", Set_Key4_Proc},
270 {"WPAPSK", Set_WPAPSK_Proc},
271 {"ResetCounter", Set_ResetStatCounter_Proc},
272 {"PSMode", Set_PSMode_Proc},
274 {"Debug", Set_Debug_Proc},
277 #ifdef WPA_SUPPLICANT_SUPPORT
278 {"WpaSupport", Set_Wpa_Support},
279 #endif // WPA_SUPPLICANT_SUPPORT //
283 {"FixedTxMode", Set_FixedTxMode_Proc},
284 #ifdef DOT11_N_SUPPORT
285 {"TGnWifiTest", Set_TGnWifiTest_Proc},
286 {"ForceGF", Set_ForceGF_Proc},
287 #endif // DOT11_N_SUPPORT //
288 #ifdef QOS_DLS_SUPPORT
289 {"DlsAddEntry", Set_DlsAddEntry_Proc},
290 {"DlsTearDownEntry", Set_DlsTearDownEntry_Proc},
291 #endif // QOS_DLS_SUPPORT //
292 {"LongRetry", Set_LongRetryLimit_Proc},
293 {"ShortRetry", Set_ShortRetryLimit_Proc},
294 #ifdef EXT_BUILD_CHANNEL_LIST
295 {"11dClientMode", Set_Ieee80211dClientMode_Proc},
296 #endif // EXT_BUILD_CHANNEL_LIST //
297 #ifdef CARRIER_DETECTION_SUPPORT
298 {"CarrierDetect", Set_CarrierDetect_Proc},
299 #endif // CARRIER_DETECTION_SUPPORT //
306 IN PRTMP_ADAPTER pAd,
307 IN PNDIS_802_11_KEY pKey)
310 MAC_TABLE_ENTRY *pEntry;
312 DBGPRINT(RT_DEBUG_TRACE, ("RTMPAddKey ------>\n"));
314 RTMP_CLEAR_PSFLAG(pAd, fRTMP_PS_CAN_GO_SLEEP);
315 if (RTMP_TEST_PSFLAG(pAd, fRTMP_PS_SET_PCI_CLK_OFF_COMMAND))
317 if (pAd->StaCfg.bRadio == FALSE)
319 RTMP_SET_PSFLAG(pAd, fRTMP_PS_CAN_GO_SLEEP);
322 DBGPRINT(RT_DEBUG_TRACE,("RTMPWPAAddKeyProc1==>\n"));
323 RTMPPCIeLinkCtrlValueRestore(pAd, RESTORE_HALT);
325 pAd->bPCIclkOff = FALSE;
328 if (pAd->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
330 if (pKey->KeyIndex & 0x80000000)
332 if (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPANone)
334 NdisZeroMemory(pAd->StaCfg.PMK, 32);
335 NdisMoveMemory(pAd->StaCfg.PMK, pKey->KeyMaterial, pKey->KeyLength);
339 NdisZeroMemory(&pAd->SharedKey[BSS0][0], sizeof(CIPHER_KEY));
340 pAd->SharedKey[BSS0][0].KeyLen = LEN_TKIP_EK;
341 NdisMoveMemory(pAd->SharedKey[BSS0][0].Key, pKey->KeyMaterial, LEN_TKIP_EK);
342 #ifdef WPA_SUPPLICANT_SUPPORT
343 if (pAd->StaCfg.PairCipher == Ndis802_11Encryption2Enabled)
345 NdisMoveMemory(pAd->SharedKey[BSS0][0].RxMic, pKey->KeyMaterial + LEN_TKIP_EK, LEN_TKIP_TXMICK);
346 NdisMoveMemory(pAd->SharedKey[BSS0][0].TxMic, pKey->KeyMaterial + LEN_TKIP_EK + LEN_TKIP_TXMICK, LEN_TKIP_RXMICK);
349 #endif // WPA_SUPPLICANT_SUPPORT //
351 NdisMoveMemory(pAd->SharedKey[BSS0][0].TxMic, pKey->KeyMaterial + LEN_TKIP_EK, LEN_TKIP_TXMICK);
352 NdisMoveMemory(pAd->SharedKey[BSS0][0].RxMic, pKey->KeyMaterial + LEN_TKIP_EK + LEN_TKIP_TXMICK, LEN_TKIP_RXMICK);
355 // Decide its ChiperAlg
356 if (pAd->StaCfg.PairCipher == Ndis802_11Encryption2Enabled)
357 pAd->SharedKey[BSS0][0].CipherAlg = CIPHER_TKIP;
358 else if (pAd->StaCfg.PairCipher == Ndis802_11Encryption3Enabled)
359 pAd->SharedKey[BSS0][0].CipherAlg = CIPHER_AES;
361 pAd->SharedKey[BSS0][0].CipherAlg = CIPHER_NONE;
363 // Update these related information to MAC_TABLE_ENTRY
364 pEntry = &pAd->MacTab.Content[BSSID_WCID];
365 NdisMoveMemory(pEntry->PairwiseKey.Key, pAd->SharedKey[BSS0][0].Key, LEN_TKIP_EK);
366 NdisMoveMemory(pEntry->PairwiseKey.RxMic, pAd->SharedKey[BSS0][0].RxMic, LEN_TKIP_RXMICK);
367 NdisMoveMemory(pEntry->PairwiseKey.TxMic, pAd->SharedKey[BSS0][0].TxMic, LEN_TKIP_TXMICK);
368 pEntry->PairwiseKey.CipherAlg = pAd->SharedKey[BSS0][0].CipherAlg;
370 // Update pairwise key information to ASIC Shared Key Table
371 AsicAddSharedKeyEntry(pAd,
374 pAd->SharedKey[BSS0][0].CipherAlg,
375 pAd->SharedKey[BSS0][0].Key,
376 pAd->SharedKey[BSS0][0].TxMic,
377 pAd->SharedKey[BSS0][0].RxMic);
379 // Update ASIC WCID attribute table and IVEIV table
380 RTMPAddWcidAttributeEntry(pAd,
383 pAd->SharedKey[BSS0][0].CipherAlg,
386 if (pAd->StaCfg.AuthMode >= Ndis802_11AuthModeWPA2)
388 // set 802.1x port control
389 STA_PORT_SECURED(pAd);
391 // Indicate Connected for GUI
392 pAd->IndicateMediaState = NdisMediaStateConnected;
398 pAd->StaCfg.DefaultKeyId = (pKey->KeyIndex & 0xFF);
399 NdisZeroMemory(&pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId], sizeof(CIPHER_KEY));
400 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].KeyLen = LEN_TKIP_EK;
401 NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].Key, pKey->KeyMaterial, LEN_TKIP_EK);
402 #ifdef WPA_SUPPLICANT_SUPPORT
403 if (pAd->StaCfg.GroupCipher == Ndis802_11Encryption2Enabled)
405 NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].RxMic, pKey->KeyMaterial + LEN_TKIP_EK, LEN_TKIP_TXMICK);
406 NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].TxMic, pKey->KeyMaterial + LEN_TKIP_EK + LEN_TKIP_TXMICK, LEN_TKIP_RXMICK);
409 #endif // WPA_SUPPLICANT_SUPPORT //
411 NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].TxMic, pKey->KeyMaterial + LEN_TKIP_EK, LEN_TKIP_TXMICK);
412 NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].RxMic, pKey->KeyMaterial + LEN_TKIP_EK + LEN_TKIP_TXMICK, LEN_TKIP_RXMICK);
415 // Update Shared Key CipherAlg
416 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg = CIPHER_NONE;
417 if (pAd->StaCfg.GroupCipher == Ndis802_11Encryption2Enabled)
418 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg = CIPHER_TKIP;
419 else if (pAd->StaCfg.GroupCipher == Ndis802_11Encryption3Enabled)
420 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg = CIPHER_AES;
422 // Update group key information to ASIC Shared Key Table
423 AsicAddSharedKeyEntry(pAd,
425 pAd->StaCfg.DefaultKeyId,
426 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg,
427 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].Key,
428 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].TxMic,
429 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].RxMic);
431 // Update ASIC WCID attribute table and IVEIV table
432 RTMPAddWcidAttributeEntry(pAd,
434 pAd->StaCfg.DefaultKeyId,
435 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg,
438 // set 802.1x port control
439 STA_PORT_SECURED(pAd);
441 // Indicate Connected for GUI
442 pAd->IndicateMediaState = NdisMediaStateConnected;
445 else // dynamic WEP from wpa_supplicant
450 if(pKey->KeyLength == 32)
453 KeyIdx = pKey->KeyIndex & 0x0fffffff;
457 // it is a default shared key, for Pairwise key setting
458 if (pKey->KeyIndex & 0x80000000)
460 pEntry = MacTableLookup(pAd, pKey->BSSID);
464 DBGPRINT(RT_DEBUG_TRACE, ("RTMPAddKey: Set Pair-wise Key\n"));
466 // set key material and key length
467 pEntry->PairwiseKey.KeyLen = (UCHAR)pKey->KeyLength;
468 NdisMoveMemory(pEntry->PairwiseKey.Key, &pKey->KeyMaterial, pKey->KeyLength);
471 if (pKey->KeyLength == 5)
472 pEntry->PairwiseKey.CipherAlg = CIPHER_WEP64;
474 pEntry->PairwiseKey.CipherAlg = CIPHER_WEP128;
476 // Add Pair-wise key to Asic
477 AsicAddPairwiseKeyEntry(
481 &pEntry->PairwiseKey);
483 // update WCID attribute table and IVEIV table for this entry
484 RTMPAddWcidAttributeEntry(
487 KeyIdx, // The value may be not zero
488 pEntry->PairwiseKey.CipherAlg,
495 // Default key for tx (shared key)
496 pAd->StaCfg.DefaultKeyId = (UCHAR) KeyIdx;
498 // set key material and key length
499 pAd->SharedKey[BSS0][KeyIdx].KeyLen = (UCHAR) pKey->KeyLength;
500 NdisMoveMemory(pAd->SharedKey[BSS0][KeyIdx].Key, &pKey->KeyMaterial, pKey->KeyLength);
503 if (pKey->KeyLength == 5)
504 pAd->SharedKey[BSS0][KeyIdx].CipherAlg = CIPHER_WEP64;
506 pAd->SharedKey[BSS0][KeyIdx].CipherAlg = CIPHER_WEP128;
508 CipherAlg = pAd->SharedKey[BSS0][KeyIdx].CipherAlg;
509 Key = pAd->SharedKey[BSS0][KeyIdx].Key;
511 // Set Group key material to Asic
512 AsicAddSharedKeyEntry(pAd, BSS0, KeyIdx, CipherAlg, Key, NULL, NULL);
514 // Update WCID attribute table and IVEIV table for this group key table
515 RTMPAddWcidAttributeEntry(pAd, BSS0, KeyIdx, CipherAlg, NULL);
521 RTMP_SET_PSFLAG(pAd, fRTMP_PS_CAN_GO_SLEEP);
522 DBGPRINT(RT_DEBUG_INFO, ("<------ RTMPAddKey\n"));
526 char * rtstrchr(const char * s, int c)
528 for(; *s != (char) c; ++s)
535 This is required for LinEX2004/kernel2.6.7 to provide iwlist scanning function
539 rt_ioctl_giwname(struct net_device *dev,
540 struct iw_request_info *info,
541 char *name, char *extra)
543 // PRTMP_ADAPTER pAdapter = dev->ml_priv;
545 strncpy(name, "RT2860 Wireless", IFNAMSIZ);
549 int rt_ioctl_siwfreq(struct net_device *dev,
550 struct iw_request_info *info,
551 struct iw_freq *freq, char *extra)
553 PRTMP_ADAPTER pAdapter = dev->ml_priv;
556 //check if the interface is down
557 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
559 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
567 if((freq->e == 0) && (freq->m <= 1000))
568 chan = freq->m; // Setting by channel number
570 MAP_KHZ_TO_CHANNEL_ID( (freq->m /100) , chan); // Setting by frequency - search the table , like 2.412G, 2.422G,
572 if (ChannelSanity(pAdapter, chan) == TRUE)
574 pAdapter->CommonCfg.Channel = chan;
575 DBGPRINT(RT_DEBUG_ERROR, ("==>rt_ioctl_siwfreq::SIOCSIWFREQ[cmd=0x%x] (Channel=%d)\n", SIOCSIWFREQ, pAdapter->CommonCfg.Channel));
582 int rt_ioctl_giwfreq(struct net_device *dev,
583 struct iw_request_info *info,
584 struct iw_freq *freq, char *extra)
586 VIRTUAL_ADAPTER *pVirtualAd = NULL;
587 PRTMP_ADAPTER pAdapter = NULL;
591 if (dev->priv_flags == INT_MAIN)
593 pAdapter = dev->ml_priv;
597 pVirtualAd = dev->ml_priv;
598 if (pVirtualAd && pVirtualAd->RtmpDev)
599 pAdapter = pVirtualAd->RtmpDev->ml_priv;
602 if (pAdapter == NULL)
604 /* if 1st open fail, pAd will be free;
605 So the net_dev->ml_priv will be NULL in 2rd open */
609 ch = pAdapter->CommonCfg.Channel;
611 DBGPRINT(RT_DEBUG_TRACE,("==>rt_ioctl_giwfreq %d\n", ch));
613 MAP_CHANNEL_ID_TO_KHZ(ch, m);
619 int rt_ioctl_siwmode(struct net_device *dev,
620 struct iw_request_info *info,
621 __u32 *mode, char *extra)
623 PRTMP_ADAPTER pAdapter = dev->ml_priv;
625 //check if the interface is down
626 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
628 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
635 Set_NetworkType_Proc(pAdapter, "Adhoc");
638 Set_NetworkType_Proc(pAdapter, "Infra");
640 case IW_MODE_MONITOR:
641 Set_NetworkType_Proc(pAdapter, "Monitor");
644 DBGPRINT(RT_DEBUG_TRACE, ("===>rt_ioctl_siwmode::SIOCSIWMODE (unknown %d)\n", *mode));
648 // Reset Ralink supplicant to not use, it will be set to start when UI set PMK key
649 pAdapter->StaCfg.WpaState = SS_NOTUSE;
654 int rt_ioctl_giwmode(struct net_device *dev,
655 struct iw_request_info *info,
656 __u32 *mode, char *extra)
658 PRTMP_ADAPTER pAdapter = NULL;
659 VIRTUAL_ADAPTER *pVirtualAd = NULL;
661 if (dev->priv_flags == INT_MAIN)
663 pAdapter = dev->ml_priv;
667 pVirtualAd = dev->ml_priv;
668 if (pVirtualAd && pVirtualAd->RtmpDev)
669 pAdapter = pVirtualAd->RtmpDev->ml_priv;
672 if (pAdapter == NULL)
674 /* if 1st open fail, pAd will be free;
675 So the net_dev->ml_priv will be NULL in 2rd open */
679 if (ADHOC_ON(pAdapter))
680 *mode = IW_MODE_ADHOC;
681 else if (INFRA_ON(pAdapter))
682 *mode = IW_MODE_INFRA;
683 else if (MONITOR_ON(pAdapter))
685 *mode = IW_MODE_MONITOR;
688 *mode = IW_MODE_AUTO;
690 DBGPRINT(RT_DEBUG_TRACE, ("==>rt_ioctl_giwmode(mode=%d)\n", *mode));
694 int rt_ioctl_siwsens(struct net_device *dev,
695 struct iw_request_info *info,
696 char *name, char *extra)
698 PRTMP_ADAPTER pAdapter = dev->ml_priv;
700 //check if the interface is down
701 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
703 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
710 int rt_ioctl_giwsens(struct net_device *dev,
711 struct iw_request_info *info,
712 char *name, char *extra)
717 int rt_ioctl_giwrange(struct net_device *dev,
718 struct iw_request_info *info,
719 struct iw_point *data, char *extra)
721 PRTMP_ADAPTER pAdapter = NULL;
722 VIRTUAL_ADAPTER *pVirtualAd = NULL;
723 struct iw_range *range = (struct iw_range *) extra;
727 if (dev->priv_flags == INT_MAIN)
729 pAdapter = dev->ml_priv;
733 pVirtualAd = dev->ml_priv;
734 if (pVirtualAd && pVirtualAd->RtmpDev)
735 pAdapter = pVirtualAd->RtmpDev->ml_priv;
738 if (pAdapter == NULL)
740 /* if 1st open fail, pAd will be free;
741 So the net_dev->ml_priv will be NULL in 2rd open */
745 DBGPRINT(RT_DEBUG_TRACE ,("===>rt_ioctl_giwrange\n"));
746 data->length = sizeof(struct iw_range);
747 memset(range, 0, sizeof(struct iw_range));
749 range->txpower_capa = IW_TXPOW_DBM;
751 if (INFRA_ON(pAdapter)||ADHOC_ON(pAdapter))
753 range->min_pmp = 1 * 1024;
754 range->max_pmp = 65535 * 1024;
755 range->min_pmt = 1 * 1024;
756 range->max_pmt = 1000 * 1024;
757 range->pmp_flags = IW_POWER_PERIOD;
758 range->pmt_flags = IW_POWER_TIMEOUT;
759 range->pm_capa = IW_POWER_PERIOD | IW_POWER_TIMEOUT |
760 IW_POWER_UNICAST_R | IW_POWER_ALL_R;
763 range->we_version_compiled = WIRELESS_EXT;
764 range->we_version_source = 14;
766 range->retry_capa = IW_RETRY_LIMIT;
767 range->retry_flags = IW_RETRY_LIMIT;
768 range->min_retry = 0;
769 range->max_retry = 255;
771 range->num_channels = pAdapter->ChannelListNum;
774 for (i = 1; i <= range->num_channels; i++)
777 range->freq[val].i = pAdapter->ChannelList[i-1].Channel;
778 MAP_CHANNEL_ID_TO_KHZ(pAdapter->ChannelList[i-1].Channel, m);
779 range->freq[val].m = m * 100; /* HZ */
781 range->freq[val].e = 1;
783 if (val == IW_MAX_FREQUENCIES)
786 range->num_frequency = val;
788 range->max_qual.qual = 100; /* what is correct max? This was not
789 * documented exactly. At least
790 * 69 has been observed. */
791 range->max_qual.level = 0; /* dB */
792 range->max_qual.noise = 0; /* dB */
794 /* What would be suitable values for "average/typical" qual? */
795 range->avg_qual.qual = 20;
796 range->avg_qual.level = -60;
797 range->avg_qual.noise = -95;
798 range->sensitivity = 3;
800 range->max_encoding_tokens = NR_WEP_KEYS;
801 range->num_encoding_sizes = 2;
802 range->encoding_size[0] = 5;
803 range->encoding_size[1] = 13;
806 range->max_rts = 2347;
807 range->min_frag = 256;
808 range->max_frag = 2346;
810 #if WIRELESS_EXT > 17
811 /* IW_ENC_CAPA_* bit field */
812 range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 |
813 IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP;
819 int rt_ioctl_siwap(struct net_device *dev,
820 struct iw_request_info *info,
821 struct sockaddr *ap_addr, char *extra)
823 PRTMP_ADAPTER pAdapter = dev->ml_priv;
824 NDIS_802_11_MAC_ADDRESS Bssid;
826 //check if the interface is down
827 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
829 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
833 if (pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE)
835 RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
836 DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
839 // tell CNTL state machine to call NdisMSetInformationComplete() after completing
840 // this request, because this request is initiated by NDIS.
841 pAdapter->MlmeAux.CurrReqIsFromNdis = FALSE;
842 // Prevent to connect AP again in STAMlmePeriodicExec
843 pAdapter->MlmeAux.AutoReconnectSsidLen= 32;
845 memset(Bssid, 0, MAC_ADDR_LEN);
846 memcpy(Bssid, ap_addr->sa_data, MAC_ADDR_LEN);
847 MlmeEnqueue(pAdapter,
848 MLME_CNTL_STATE_MACHINE,
850 sizeof(NDIS_802_11_MAC_ADDRESS),
853 DBGPRINT(RT_DEBUG_TRACE, ("IOCTL::SIOCSIWAP %02x:%02x:%02x:%02x:%02x:%02x\n",
854 Bssid[0], Bssid[1], Bssid[2], Bssid[3], Bssid[4], Bssid[5]));
859 int rt_ioctl_giwap(struct net_device *dev,
860 struct iw_request_info *info,
861 struct sockaddr *ap_addr, char *extra)
863 PRTMP_ADAPTER pAdapter = NULL;
864 VIRTUAL_ADAPTER *pVirtualAd = NULL;
866 if (dev->priv_flags == INT_MAIN)
868 pAdapter = dev->ml_priv;
872 pVirtualAd = dev->ml_priv;
873 if (pVirtualAd && pVirtualAd->RtmpDev)
874 pAdapter = pVirtualAd->RtmpDev->ml_priv;
877 if (pAdapter == NULL)
879 /* if 1st open fail, pAd will be free;
880 So the net_dev->ml_priv will be NULL in 2rd open */
884 if (INFRA_ON(pAdapter) || ADHOC_ON(pAdapter))
886 ap_addr->sa_family = ARPHRD_ETHER;
887 memcpy(ap_addr->sa_data, &pAdapter->CommonCfg.Bssid, ETH_ALEN);
889 #ifdef WPA_SUPPLICANT_SUPPORT
891 else if (pAdapter->StaCfg.WpaSupplicantUP != WPA_SUPPLICANT_DISABLE)
893 ap_addr->sa_family = ARPHRD_ETHER;
894 memcpy(ap_addr->sa_data, &pAdapter->MlmeAux.Bssid, ETH_ALEN);
896 #endif // WPA_SUPPLICANT_SUPPORT //
899 DBGPRINT(RT_DEBUG_TRACE, ("IOCTL::SIOCGIWAP(=EMPTY)\n"));
907 * Units are in db above the noise floor. That means the
908 * rssi values reported in the tx/rx descriptors in the
909 * driver are the SNR expressed in db.
911 * If you assume that the noise floor is -95, which is an
912 * excellent assumption 99.5 % of the time, then you can
913 * derive the absolute signal level (i.e. -95 + rssi).
914 * There are some other slight factors to take into account
915 * depending on whether the rssi measurement is from 11b,
916 * 11g, or 11a. These differences are at most 2db and
919 * NB: various calculations are based on the orinoco/wavelan
920 * drivers for compatibility
922 static void set_quality(PRTMP_ADAPTER pAdapter,
923 struct iw_quality *iq,
930 ChannelQuality = 100;
931 else if (rssi >= -80) // between -50 ~ -80dbm
932 ChannelQuality = (__u8)(24 + ((rssi + 80) * 26)/10);
933 else if (rssi >= -90) // between -80 ~ -90dbm
934 ChannelQuality = (__u8)((rssi + 90) * 26)/10;
938 iq->qual = (__u8)ChannelQuality;
940 iq->level = (__u8)(rssi);
941 iq->noise = (pAdapter->BbpWriteLatch[66] > pAdapter->BbpTuning.FalseCcaUpperThreshold) ? ((__u8)pAdapter->BbpTuning.FalseCcaUpperThreshold) : ((__u8) pAdapter->BbpWriteLatch[66]); // noise level (dBm)
942 iq->noise += 256 - 143;
943 iq->updated = pAdapter->iw_stats.qual.updated;
946 int rt_ioctl_iwaplist(struct net_device *dev,
947 struct iw_request_info *info,
948 struct iw_point *data, char *extra)
950 PRTMP_ADAPTER pAdapter = dev->ml_priv;
952 struct sockaddr addr[IW_MAX_AP];
953 struct iw_quality qual[IW_MAX_AP];
956 //check if the interface is down
957 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
959 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
965 for (i = 0; i <IW_MAX_AP ; i++)
967 if (i >= pAdapter->ScanTab.BssNr)
969 addr[i].sa_family = ARPHRD_ETHER;
970 memcpy(addr[i].sa_data, &pAdapter->ScanTab.BssEntry[i].Bssid, MAC_ADDR_LEN);
971 set_quality(pAdapter, &qual[i], pAdapter->ScanTab.BssEntry[i].Rssi);
974 memcpy(extra, &addr, i*sizeof(addr[0]));
975 data->flags = 1; /* signal quality present (sort of) */
976 memcpy(extra + i*sizeof(addr[0]), &qual, i*sizeof(qual[i]));
982 int rt_ioctl_siwscan(struct net_device *dev,
983 struct iw_request_info *info,
984 struct iw_point *data, char *extra)
986 PRTMP_ADAPTER pAdapter = dev->ml_priv;
989 int Status = NDIS_STATUS_SUCCESS;
991 //check if the interface is down
992 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
994 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
998 if (MONITOR_ON(pAdapter))
1000 DBGPRINT(RT_DEBUG_TRACE, ("!!! Driver is in Monitor Mode now !!!\n"));
1004 if ((pAdapter->OpMode == OPMODE_STA) && (IDLE_ON(pAdapter))
1005 && (pAdapter->StaCfg.bRadio == TRUE)
1006 && (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_IDLE_RADIO_OFF)))
1008 RT28xxPciAsicRadioOn(pAdapter, GUI_IDLE_POWER_SAVE);
1010 // Check if still radio off.
1011 else if (pAdapter->bPCIclkOff == TRUE)
1014 #ifdef WPA_SUPPLICANT_SUPPORT
1015 if (pAdapter->StaCfg.WpaSupplicantUP == WPA_SUPPLICANT_ENABLE)
1017 pAdapter->StaCfg.WpaSupplicantScanCount++;
1019 #endif // WPA_SUPPLICANT_SUPPORT //
1021 pAdapter->StaCfg.bScanReqIsFromWebUI = TRUE;
1022 if (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
1027 #ifdef WPA_SUPPLICANT_SUPPORT
1028 if ((pAdapter->StaCfg.WpaSupplicantUP == WPA_SUPPLICANT_ENABLE) &&
1029 (pAdapter->StaCfg.WpaSupplicantScanCount > 3))
1031 DBGPRINT(RT_DEBUG_TRACE, ("!!! WpaSupplicantScanCount > 3\n"));
1032 Status = NDIS_STATUS_SUCCESS;
1035 #endif // WPA_SUPPLICANT_SUPPORT //
1037 if ((OPSTATUS_TEST_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED)) &&
1038 ((pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA) ||
1039 (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK)) &&
1040 (pAdapter->StaCfg.PortSecured == WPA_802_1X_PORT_NOT_SECURED))
1042 DBGPRINT(RT_DEBUG_TRACE, ("!!! Link UP, Port Not Secured! ignore this set::OID_802_11_BSSID_LIST_SCAN\n"));
1043 Status = NDIS_STATUS_SUCCESS;
1047 if (pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE)
1049 RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
1050 DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
1053 // tell CNTL state machine to call NdisMSetInformationComplete() after completing
1054 // this request, because this request is initiated by NDIS.
1055 pAdapter->MlmeAux.CurrReqIsFromNdis = FALSE;
1056 // Reset allowed scan retries
1057 pAdapter->StaCfg.ScanCnt = 0;
1058 pAdapter->StaCfg.LastScanTime = Now;
1060 MlmeEnqueue(pAdapter,
1061 MLME_CNTL_STATE_MACHINE,
1062 OID_802_11_BSSID_LIST_SCAN,
1066 Status = NDIS_STATUS_SUCCESS;
1067 RT28XX_MLME_HANDLER(pAdapter);
1072 int rt_ioctl_giwscan(struct net_device *dev,
1073 struct iw_request_info *info,
1074 struct iw_point *data, char *extra)
1077 PRTMP_ADAPTER pAdapter = dev->ml_priv;
1079 char *current_ev = extra, *previous_ev = extra;
1081 char *current_val, custom[MAX_CUSTOM_LEN] = {0};
1084 #endif // IWEVGENIE //
1085 struct iw_event iwe;
1087 if (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
1090 * Still scanning, indicate the caller should try again.
1096 #ifdef WPA_SUPPLICANT_SUPPORT
1097 if (pAdapter->StaCfg.WpaSupplicantUP == WPA_SUPPLICANT_ENABLE)
1099 pAdapter->StaCfg.WpaSupplicantScanCount = 0;
1101 #endif // WPA_SUPPLICANT_SUPPORT //
1103 if (pAdapter->ScanTab.BssNr == 0)
1109 #if WIRELESS_EXT >= 17
1110 if (data->length > 0)
1111 end_buf = extra + data->length;
1113 end_buf = extra + IW_SCAN_MAX_DATA;
1115 end_buf = extra + IW_SCAN_MAX_DATA;
1118 for (i = 0; i < pAdapter->ScanTab.BssNr; i++)
1120 if (current_ev >= end_buf)
1122 #if WIRELESS_EXT >= 17
1130 //================================
1131 memset(&iwe, 0, sizeof(iwe));
1132 iwe.cmd = SIOCGIWAP;
1133 iwe.u.ap_addr.sa_family = ARPHRD_ETHER;
1134 memcpy(iwe.u.ap_addr.sa_data, &pAdapter->ScanTab.BssEntry[i].Bssid, ETH_ALEN);
1136 previous_ev = current_ev;
1137 current_ev = iwe_stream_add_event(info, current_ev,end_buf, &iwe, IW_EV_ADDR_LEN);
1138 if (current_ev == previous_ev)
1139 #if WIRELESS_EXT >= 17
1146 //================================
1147 memset(&iwe, 0, sizeof(iwe));
1148 iwe.cmd = SIOCGIWESSID;
1149 iwe.u.data.length = pAdapter->ScanTab.BssEntry[i].SsidLen;
1150 iwe.u.data.flags = 1;
1152 previous_ev = current_ev;
1153 current_ev = iwe_stream_add_point(info, current_ev,end_buf, &iwe, pAdapter->ScanTab.BssEntry[i].Ssid);
1154 if (current_ev == previous_ev)
1155 #if WIRELESS_EXT >= 17
1162 //================================
1163 memset(&iwe, 0, sizeof(iwe));
1164 iwe.cmd = SIOCGIWMODE;
1165 if (pAdapter->ScanTab.BssEntry[i].BssType == Ndis802_11IBSS)
1167 iwe.u.mode = IW_MODE_ADHOC;
1169 else if (pAdapter->ScanTab.BssEntry[i].BssType == Ndis802_11Infrastructure)
1171 iwe.u.mode = IW_MODE_INFRA;
1175 iwe.u.mode = IW_MODE_AUTO;
1177 iwe.len = IW_EV_UINT_LEN;
1179 previous_ev = current_ev;
1180 current_ev = iwe_stream_add_event(info, current_ev, end_buf, &iwe, IW_EV_UINT_LEN);
1181 if (current_ev == previous_ev)
1182 #if WIRELESS_EXT >= 17
1188 //Channel and Frequency
1189 //================================
1190 memset(&iwe, 0, sizeof(iwe));
1191 iwe.cmd = SIOCGIWFREQ;
1192 if (INFRA_ON(pAdapter) || ADHOC_ON(pAdapter))
1193 iwe.u.freq.m = pAdapter->ScanTab.BssEntry[i].Channel;
1195 iwe.u.freq.m = pAdapter->ScanTab.BssEntry[i].Channel;
1199 previous_ev = current_ev;
1200 current_ev = iwe_stream_add_event(info, current_ev, end_buf, &iwe, IW_EV_FREQ_LEN);
1201 if (current_ev == previous_ev)
1202 #if WIRELESS_EXT >= 17
1208 //Add quality statistics
1209 //================================
1210 memset(&iwe, 0, sizeof(iwe));
1212 iwe.u.qual.level = 0;
1213 iwe.u.qual.noise = 0;
1214 set_quality(pAdapter, &iwe.u.qual, pAdapter->ScanTab.BssEntry[i].Rssi);
1215 current_ev = iwe_stream_add_event(info, current_ev, end_buf, &iwe, IW_EV_QUAL_LEN);
1216 if (current_ev == previous_ev)
1217 #if WIRELESS_EXT >= 17
1224 //================================
1225 memset(&iwe, 0, sizeof(iwe));
1226 iwe.cmd = SIOCGIWENCODE;
1227 if (CAP_IS_PRIVACY_ON (pAdapter->ScanTab.BssEntry[i].CapabilityInfo ))
1228 iwe.u.data.flags =IW_ENCODE_ENABLED | IW_ENCODE_NOKEY;
1230 iwe.u.data.flags = IW_ENCODE_DISABLED;
1232 previous_ev = current_ev;
1233 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);
1234 if (current_ev == previous_ev)
1235 #if WIRELESS_EXT >= 17
1242 //================================
1243 if (pAdapter->ScanTab.BssEntry[i].SupRateLen)
1245 UCHAR tmpRate = pAdapter->ScanTab.BssEntry[i].SupRate[pAdapter->ScanTab.BssEntry[i].SupRateLen-1];
1246 memset(&iwe, 0, sizeof(iwe));
1247 iwe.cmd = SIOCGIWRATE;
1248 current_val = current_ev + IW_EV_LCP_LEN;
1249 if (tmpRate == 0x82)
1250 iwe.u.bitrate.value = 1 * 1000000;
1251 else if (tmpRate == 0x84)
1252 iwe.u.bitrate.value = 2 * 1000000;
1253 else if (tmpRate == 0x8B)
1254 iwe.u.bitrate.value = 5.5 * 1000000;
1255 else if (tmpRate == 0x96)
1256 iwe.u.bitrate.value = 11 * 1000000;
1258 iwe.u.bitrate.value = (tmpRate/2) * 1000000;
1260 iwe.u.bitrate.disabled = 0;
1261 current_val = iwe_stream_add_value(info, current_ev,
1262 current_val, end_buf, &iwe,
1265 if((current_val-current_ev)>IW_EV_LCP_LEN)
1266 current_ev = current_val;
1268 #if WIRELESS_EXT >= 17
1277 if (pAdapter->ScanTab.BssEntry[i].WpaIE.IELen > 0)
1279 memset(&iwe, 0, sizeof(iwe));
1280 memset(&custom[0], 0, MAX_CUSTOM_LEN);
1281 memcpy(custom, &(pAdapter->ScanTab.BssEntry[i].WpaIE.IE[0]),
1282 pAdapter->ScanTab.BssEntry[i].WpaIE.IELen);
1283 iwe.cmd = IWEVGENIE;
1284 iwe.u.data.length = pAdapter->ScanTab.BssEntry[i].WpaIE.IELen;
1285 current_ev = iwe_stream_add_point(info, current_ev, end_buf, &iwe, custom);
1286 if (current_ev == previous_ev)
1287 #if WIRELESS_EXT >= 17
1295 if (pAdapter->ScanTab.BssEntry[i].RsnIE.IELen > 0)
1297 memset(&iwe, 0, sizeof(iwe));
1298 memset(&custom[0], 0, MAX_CUSTOM_LEN);
1299 memcpy(custom, &(pAdapter->ScanTab.BssEntry[i].RsnIE.IE[0]),
1300 pAdapter->ScanTab.BssEntry[i].RsnIE.IELen);
1301 iwe.cmd = IWEVGENIE;
1302 iwe.u.data.length = pAdapter->ScanTab.BssEntry[i].RsnIE.IELen;
1303 current_ev = iwe_stream_add_point(info, current_ev, end_buf, &iwe, custom);
1304 if (current_ev == previous_ev)
1305 #if WIRELESS_EXT >= 17
1313 //================================
1314 if (pAdapter->ScanTab.BssEntry[i].WpaIE.IELen > 0)
1316 NdisZeroMemory(&iwe, sizeof(iwe));
1317 memset(&custom[0], 0, MAX_CUSTOM_LEN);
1318 iwe.cmd = IWEVCUSTOM;
1319 iwe.u.data.length = (pAdapter->ScanTab.BssEntry[i].WpaIE.IELen * 2) + 7;
1320 NdisMoveMemory(custom, "wpa_ie=", 7);
1321 for (idx = 0; idx < pAdapter->ScanTab.BssEntry[i].WpaIE.IELen; idx++)
1322 sprintf(custom + strlen(custom), "%02x", pAdapter->ScanTab.BssEntry[i].WpaIE.IE[idx]);
1323 previous_ev = current_ev;
1324 current_ev = iwe_stream_add_point(current_ev, end_buf, &iwe, custom);
1325 if (current_ev == previous_ev)
1326 #if WIRELESS_EXT >= 17
1334 if (pAdapter->ScanTab.BssEntry[i].RsnIE.IELen > 0)
1336 NdisZeroMemory(&iwe, sizeof(iwe));
1337 memset(&custom[0], 0, MAX_CUSTOM_LEN);
1338 iwe.cmd = IWEVCUSTOM;
1339 iwe.u.data.length = (pAdapter->ScanTab.BssEntry[i].RsnIE.IELen * 2) + 7;
1340 NdisMoveMemory(custom, "rsn_ie=", 7);
1341 for (idx = 0; idx < pAdapter->ScanTab.BssEntry[i].RsnIE.IELen; idx++)
1342 sprintf(custom + strlen(custom), "%02x", pAdapter->ScanTab.BssEntry[i].RsnIE.IE[idx]);
1343 previous_ev = current_ev;
1344 current_ev = iwe_stream_add_point(current_ev, end_buf, &iwe, custom);
1345 if (current_ev == previous_ev)
1346 #if WIRELESS_EXT >= 17
1352 #endif // IWEVGENIE //
1355 data->length = current_ev - extra;
1356 pAdapter->StaCfg.bScanReqIsFromWebUI = FALSE;
1357 DBGPRINT(RT_DEBUG_ERROR ,("===>rt_ioctl_giwscan. %d(%d) BSS returned, data->length = %d\n",i , pAdapter->ScanTab.BssNr, data->length));
1362 int rt_ioctl_siwessid(struct net_device *dev,
1363 struct iw_request_info *info,
1364 struct iw_point *data, char *essid)
1366 PRTMP_ADAPTER pAdapter = dev->ml_priv;
1368 //check if the interface is down
1369 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1371 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1377 PCHAR pSsidString = NULL;
1379 // Includes null character.
1380 if (data->length > (IW_ESSID_MAX_SIZE + 1))
1383 pSsidString = (CHAR *) kmalloc(MAX_LEN_OF_SSID+1, MEM_ALLOC_FLAG);
1386 NdisZeroMemory(pSsidString, MAX_LEN_OF_SSID+1);
1387 NdisMoveMemory(pSsidString, essid, data->length);
1388 if (Set_SSID_Proc(pAdapter, pSsidString) == FALSE)
1397 if (Set_SSID_Proc(pAdapter, "") == FALSE)
1403 int rt_ioctl_giwessid(struct net_device *dev,
1404 struct iw_request_info *info,
1405 struct iw_point *data, char *essid)
1407 PRTMP_ADAPTER pAdapter = NULL;
1408 VIRTUAL_ADAPTER *pVirtualAd = NULL;
1410 if (dev->priv_flags == INT_MAIN)
1412 pAdapter = dev->ml_priv;
1416 pVirtualAd = dev->ml_priv;
1417 if (pVirtualAd && pVirtualAd->RtmpDev)
1418 pAdapter = pVirtualAd->RtmpDev->ml_priv;
1421 if (pAdapter == NULL)
1423 /* if 1st open fail, pAd will be free;
1424 So the net_dev->ml_priv will be NULL in 2rd open */
1429 if (MONITOR_ON(pAdapter))
1435 if (OPSTATUS_TEST_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED))
1437 DBGPRINT(RT_DEBUG_TRACE ,("MediaState is connected\n"));
1438 data->length = pAdapter->CommonCfg.SsidLen;
1439 memcpy(essid, pAdapter->CommonCfg.Ssid, pAdapter->CommonCfg.SsidLen);
1442 {//the ANY ssid was specified
1444 DBGPRINT(RT_DEBUG_TRACE ,("MediaState is not connected, ess\n"));
1451 int rt_ioctl_siwnickn(struct net_device *dev,
1452 struct iw_request_info *info,
1453 struct iw_point *data, char *nickname)
1455 PRTMP_ADAPTER pAdapter = dev->ml_priv;
1457 //check if the interface is down
1458 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1460 DBGPRINT(RT_DEBUG_TRACE ,("INFO::Network is down!\n"));
1464 if (data->length > IW_ESSID_MAX_SIZE)
1467 memset(pAdapter->nickname, 0, IW_ESSID_MAX_SIZE + 1);
1468 memcpy(pAdapter->nickname, nickname, data->length);
1474 int rt_ioctl_giwnickn(struct net_device *dev,
1475 struct iw_request_info *info,
1476 struct iw_point *data, char *nickname)
1478 PRTMP_ADAPTER pAdapter = NULL;
1479 VIRTUAL_ADAPTER *pVirtualAd = NULL;
1481 if (dev->priv_flags == INT_MAIN)
1483 pAdapter = dev->ml_priv;
1487 pVirtualAd = dev->ml_priv;
1488 if (pVirtualAd && pVirtualAd->RtmpDev)
1489 pAdapter = pVirtualAd->RtmpDev->ml_priv;
1492 if (pAdapter == NULL)
1494 /* if 1st open fail, pAd will be free;
1495 So the net_dev->ml_priv will be NULL in 2rd open */
1499 if (data->length > strlen(pAdapter->nickname) + 1)
1500 data->length = strlen(pAdapter->nickname) + 1;
1501 if (data->length > 0) {
1502 memcpy(nickname, pAdapter->nickname, data->length-1);
1503 nickname[data->length-1] = '\0';
1508 int rt_ioctl_siwrts(struct net_device *dev,
1509 struct iw_request_info *info,
1510 struct iw_param *rts, char *extra)
1512 PRTMP_ADAPTER pAdapter = dev->ml_priv;
1515 //check if the interface is down
1516 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1518 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1523 val = MAX_RTS_THRESHOLD;
1524 else if (rts->value < 0 || rts->value > MAX_RTS_THRESHOLD)
1526 else if (rts->value == 0)
1527 val = MAX_RTS_THRESHOLD;
1531 if (val != pAdapter->CommonCfg.RtsThreshold)
1532 pAdapter->CommonCfg.RtsThreshold = val;
1537 int rt_ioctl_giwrts(struct net_device *dev,
1538 struct iw_request_info *info,
1539 struct iw_param *rts, char *extra)
1541 PRTMP_ADAPTER pAdapter = NULL;
1542 VIRTUAL_ADAPTER *pVirtualAd = NULL;
1544 if (dev->priv_flags == INT_MAIN)
1546 pAdapter = dev->ml_priv;
1550 pVirtualAd = dev->ml_priv;
1551 if (pVirtualAd && pVirtualAd->RtmpDev)
1552 pAdapter = pVirtualAd->RtmpDev->ml_priv;
1555 if (pAdapter == NULL)
1557 /* if 1st open fail, pAd will be free;
1558 So the net_dev->ml_priv will be NULL in 2rd open */
1562 //check if the interface is down
1563 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1565 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1569 rts->value = pAdapter->CommonCfg.RtsThreshold;
1570 rts->disabled = (rts->value == MAX_RTS_THRESHOLD);
1576 int rt_ioctl_siwfrag(struct net_device *dev,
1577 struct iw_request_info *info,
1578 struct iw_param *frag, char *extra)
1580 PRTMP_ADAPTER pAdapter = dev->ml_priv;
1583 //check if the interface is down
1584 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1586 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1591 val = MAX_FRAG_THRESHOLD;
1592 else if (frag->value >= MIN_FRAG_THRESHOLD || frag->value <= MAX_FRAG_THRESHOLD)
1593 val = __cpu_to_le16(frag->value & ~0x1); /* even numbers only */
1594 else if (frag->value == 0)
1595 val = MAX_FRAG_THRESHOLD;
1599 pAdapter->CommonCfg.FragmentThreshold = val;
1603 int rt_ioctl_giwfrag(struct net_device *dev,
1604 struct iw_request_info *info,
1605 struct iw_param *frag, char *extra)
1607 PRTMP_ADAPTER pAdapter = NULL;
1608 VIRTUAL_ADAPTER *pVirtualAd = NULL;
1610 if (dev->priv_flags == INT_MAIN)
1612 pAdapter = dev->ml_priv;
1616 pVirtualAd = dev->ml_priv;
1617 if (pVirtualAd && pVirtualAd->RtmpDev)
1618 pAdapter = pVirtualAd->RtmpDev->ml_priv;
1621 if (pAdapter == NULL)
1623 /* if 1st open fail, pAd will be free;
1624 So the net_dev->ml_priv will be NULL in 2rd open */
1628 //check if the interface is down
1629 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1631 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1635 frag->value = pAdapter->CommonCfg.FragmentThreshold;
1636 frag->disabled = (frag->value == MAX_FRAG_THRESHOLD);
1642 #define MAX_WEP_KEY_SIZE 13
1643 #define MIN_WEP_KEY_SIZE 5
1644 int rt_ioctl_siwencode(struct net_device *dev,
1645 struct iw_request_info *info,
1646 struct iw_point *erq, char *extra)
1648 PRTMP_ADAPTER pAdapter = dev->ml_priv;
1650 //check if the interface is down
1651 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1653 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1657 if ((erq->length == 0) &&
1658 (erq->flags & IW_ENCODE_DISABLED))
1660 pAdapter->StaCfg.PairCipher = Ndis802_11WEPDisabled;
1661 pAdapter->StaCfg.GroupCipher = Ndis802_11WEPDisabled;
1662 pAdapter->StaCfg.WepStatus = Ndis802_11WEPDisabled;
1663 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
1664 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
1667 else if ((erq->length == 0) &&
1668 (erq->flags & IW_ENCODE_RESTRICTED || erq->flags & IW_ENCODE_OPEN))
1670 STA_PORT_SECURED(pAdapter);
1671 pAdapter->StaCfg.PairCipher = Ndis802_11WEPEnabled;
1672 pAdapter->StaCfg.GroupCipher = Ndis802_11WEPEnabled;
1673 pAdapter->StaCfg.WepStatus = Ndis802_11WEPEnabled;
1674 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
1675 if (erq->flags & IW_ENCODE_RESTRICTED)
1676 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeShared;
1678 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
1682 if (erq->length > 0)
1684 int keyIdx = (erq->flags & IW_ENCODE_INDEX) - 1;
1685 /* Check the size of the key */
1686 if (erq->length > MAX_WEP_KEY_SIZE) {
1689 /* Check key index */
1690 if ((keyIdx < 0) || (keyIdx >= NR_WEP_KEYS))
1692 DBGPRINT(RT_DEBUG_TRACE ,("==>rt_ioctl_siwencode::Wrong keyIdx=%d! Using default key instead (%d)\n",
1693 keyIdx, pAdapter->StaCfg.DefaultKeyId));
1696 keyIdx = pAdapter->StaCfg.DefaultKeyId;
1699 NdisZeroMemory(pAdapter->SharedKey[BSS0][keyIdx].Key, 16);
1701 if (erq->length == MAX_WEP_KEY_SIZE)
1703 pAdapter->SharedKey[BSS0][keyIdx].KeyLen = MAX_WEP_KEY_SIZE;
1704 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CIPHER_WEP128;
1706 else if (erq->length == MIN_WEP_KEY_SIZE)
1708 pAdapter->SharedKey[BSS0][keyIdx].KeyLen = MIN_WEP_KEY_SIZE;
1709 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CIPHER_WEP64;
1712 /* Disable the key */
1713 pAdapter->SharedKey[BSS0][keyIdx].KeyLen = 0;
1715 /* Check if the key is not marked as invalid */
1716 if(!(erq->flags & IW_ENCODE_NOKEY)) {
1717 /* Copy the key in the driver */
1718 NdisMoveMemory(pAdapter->SharedKey[BSS0][keyIdx].Key, extra, erq->length);
1723 /* Do we want to just set the transmit key index ? */
1724 int index = (erq->flags & IW_ENCODE_INDEX) - 1;
1725 if ((index >= 0) && (index < 4))
1727 pAdapter->StaCfg.DefaultKeyId = index;
1730 /* Don't complain if only change the mode */
1731 if (!(erq->flags & IW_ENCODE_MODE)) {
1737 DBGPRINT(RT_DEBUG_TRACE ,("==>rt_ioctl_siwencode::erq->flags=%x\n",erq->flags));
1738 DBGPRINT(RT_DEBUG_TRACE ,("==>rt_ioctl_siwencode::AuthMode=%x\n",pAdapter->StaCfg.AuthMode));
1739 DBGPRINT(RT_DEBUG_TRACE ,("==>rt_ioctl_siwencode::DefaultKeyId=%x, KeyLen = %d\n",pAdapter->StaCfg.DefaultKeyId , pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].KeyLen));
1740 DBGPRINT(RT_DEBUG_TRACE ,("==>rt_ioctl_siwencode::WepStatus=%x\n",pAdapter->StaCfg.WepStatus));
1745 rt_ioctl_giwencode(struct net_device *dev,
1746 struct iw_request_info *info,
1747 struct iw_point *erq, char *key)
1750 PRTMP_ADAPTER pAdapter = NULL;
1751 VIRTUAL_ADAPTER *pVirtualAd = NULL;
1753 if (dev->priv_flags == INT_MAIN)
1755 pAdapter = dev->ml_priv;
1759 pVirtualAd = dev->ml_priv;
1760 if (pVirtualAd && pVirtualAd->RtmpDev)
1761 pAdapter = pVirtualAd->RtmpDev->ml_priv;
1764 if (pAdapter == NULL)
1766 /* if 1st open fail, pAd will be free;
1767 So the net_dev->ml_priv will be NULL in 2rd open */
1771 //check if the interface is down
1772 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1774 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1778 kid = erq->flags & IW_ENCODE_INDEX;
1779 DBGPRINT(RT_DEBUG_TRACE, ("===>rt_ioctl_giwencode %d\n", erq->flags & IW_ENCODE_INDEX));
1781 if (pAdapter->StaCfg.WepStatus == Ndis802_11WEPDisabled)
1784 erq->flags = IW_ENCODE_DISABLED;
1786 else if ((kid > 0) && (kid <=4))
1789 erq->flags = kid ; /* NB: base 1 */
1790 if (erq->length > pAdapter->SharedKey[BSS0][kid-1].KeyLen)
1791 erq->length = pAdapter->SharedKey[BSS0][kid-1].KeyLen;
1792 memcpy(key, pAdapter->SharedKey[BSS0][kid-1].Key, erq->length);
1793 //if ((kid == pAdapter->PortCfg.DefaultKeyId))
1794 //erq->flags |= IW_ENCODE_ENABLED; /* XXX */
1795 if (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeShared)
1796 erq->flags |= IW_ENCODE_RESTRICTED; /* XXX */
1798 erq->flags |= IW_ENCODE_OPEN; /* XXX */
1803 if (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeShared)
1804 erq->flags |= IW_ENCODE_RESTRICTED; /* XXX */
1806 erq->flags |= IW_ENCODE_OPEN; /* XXX */
1807 erq->length = pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].KeyLen;
1808 memcpy(key, pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].Key, erq->length);
1809 // copy default key ID
1810 if (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeShared)
1811 erq->flags |= IW_ENCODE_RESTRICTED; /* XXX */
1813 erq->flags |= IW_ENCODE_OPEN; /* XXX */
1814 erq->flags = pAdapter->StaCfg.DefaultKeyId + 1; /* NB: base 1 */
1815 erq->flags |= IW_ENCODE_ENABLED; /* XXX */
1823 rt_ioctl_setparam(struct net_device *dev, struct iw_request_info *info,
1824 void *w, char *extra)
1826 VIRTUAL_ADAPTER *pVirtualAd = NULL;
1827 PRTMP_ADAPTER pAdapter;
1829 char *this_char = extra;
1833 if (dev->priv_flags == INT_MAIN)
1835 pAdapter = dev->ml_priv;
1839 pVirtualAd = dev->ml_priv;
1840 pAdapter = pVirtualAd->RtmpDev->ml_priv;
1842 pObj = (POS_COOKIE) pAdapter->OS_Cookie;
1844 if (pAdapter == NULL)
1846 /* if 1st open fail, pAd will be free;
1847 So the net_dev->ml_priv will be NULL in 2rd open */
1852 pObj->ioctl_if_type = INT_MAIN;
1853 pObj->ioctl_if = MAIN_MBSSID;
1856 //check if the interface is down
1857 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1859 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1866 if ((value = rtstrchr(this_char, '=')) != NULL)
1872 // reject setting nothing besides ANY ssid(ssidLen=0)
1873 if (!*value && (strcmp(this_char, "SSID") != 0))
1876 for (PRTMP_PRIVATE_SET_PROC = RTMP_PRIVATE_SUPPORT_PROC; PRTMP_PRIVATE_SET_PROC->name; PRTMP_PRIVATE_SET_PROC++)
1878 if (strcmp(this_char, PRTMP_PRIVATE_SET_PROC->name) == 0)
1880 if(!PRTMP_PRIVATE_SET_PROC->set_proc(pAdapter, value))
1881 { //FALSE:Set private failed then return Invalid argument
1884 break; //Exit for loop.
1888 if(PRTMP_PRIVATE_SET_PROC->name == NULL)
1889 { //Not found argument
1891 DBGPRINT(RT_DEBUG_TRACE, ("===>rt_ioctl_setparam:: (iwpriv) Not Support Set Command [%s=%s]\n", this_char, value));
1899 rt_private_get_statistics(struct net_device *dev, struct iw_request_info *info,
1900 struct iw_point *wrq, char *extra)
1903 PRTMP_ADAPTER pAd = dev->ml_priv;
1911 memset(extra, 0x00, IW_PRIV_SIZE_MASK);
1912 sprintf(extra, "\n\n");
1915 sprintf(extra+strlen(extra), "Tx success = %ld\n", (ULONG)pAd->WlanCounters.TransmittedFragmentCount.QuadPart);
1916 sprintf(extra+strlen(extra), "Tx success without retry = %ld\n", (ULONG)pAd->WlanCounters.TransmittedFragmentCount.QuadPart - (ULONG)pAd->WlanCounters.RetryCount.QuadPart);
1918 sprintf(extra+strlen(extra), "Tx success after retry = %ld\n", (ULONG)pAd->WlanCounters.RetryCount.QuadPart);
1919 sprintf(extra+strlen(extra), "Tx fail to Rcv ACK after retry = %ld\n", (ULONG)pAd->WlanCounters.FailedCount.QuadPart);
1920 sprintf(extra+strlen(extra), "RTS Success Rcv CTS = %ld\n", (ULONG)pAd->WlanCounters.RTSSuccessCount.QuadPart);
1921 sprintf(extra+strlen(extra), "RTS Fail Rcv CTS = %ld\n", (ULONG)pAd->WlanCounters.RTSFailureCount.QuadPart);
1923 sprintf(extra+strlen(extra), "Rx success = %ld\n", (ULONG)pAd->WlanCounters.ReceivedFragmentCount.QuadPart);
1924 sprintf(extra+strlen(extra), "Rx with CRC = %ld\n", (ULONG)pAd->WlanCounters.FCSErrorCount.QuadPart);
1925 sprintf(extra+strlen(extra), "Rx drop due to out of resource = %ld\n", (ULONG)pAd->Counters8023.RxNoBuffer);
1926 sprintf(extra+strlen(extra), "Rx duplicate frame = %ld\n", (ULONG)pAd->WlanCounters.FrameDuplicateCount.QuadPart);
1928 sprintf(extra+strlen(extra), "False CCA (one second) = %ld\n", (ULONG)pAd->RalinkCounters.OneSecFalseCCACnt);
1930 sprintf(extra+strlen(extra), "RSSI-A = %ld\n", (LONG)(pAd->StaCfg.RssiSample.LastRssi0 - pAd->BbpRssiToDbmDelta));
1931 sprintf(extra+strlen(extra), "RSSI-B (if available) = %ld\n", (LONG)(pAd->StaCfg.RssiSample.LastRssi1 - pAd->BbpRssiToDbmDelta));
1932 sprintf(extra+strlen(extra), "RSSI-C (if available) = %ld\n\n", (LONG)(pAd->StaCfg.RssiSample.LastRssi2 - pAd->BbpRssiToDbmDelta));
1934 #ifdef WPA_SUPPLICANT_SUPPORT
1935 sprintf(extra+strlen(extra), "WpaSupplicantUP = %d\n\n", pAd->StaCfg.WpaSupplicantUP);
1936 #endif // WPA_SUPPLICANT_SUPPORT //
1939 wrq->length = strlen(extra) + 1; // 1: size of '\0'
1940 DBGPRINT(RT_DEBUG_TRACE, ("<== rt_private_get_statistics, wrq->length = %d\n", wrq->length));
1945 #ifdef DOT11_N_SUPPORT
1947 IN PRTMP_ADAPTER pAd,
1951 BA_ORI_ENTRY *pOriBAEntry;
1952 BA_REC_ENTRY *pRecBAEntry;
1954 for (i=0; i<MAX_LEN_OF_MAC_TABLE; i++)
1956 PMAC_TABLE_ENTRY pEntry = &pAd->MacTab.Content[i];
1957 if (((pEntry->ValidAsCLI || pEntry->ValidAsApCli) && (pEntry->Sst == SST_ASSOC))
1958 || (pEntry->ValidAsWDS) || (pEntry->ValidAsMesh))
1960 sprintf(pOutBuf + strlen(pOutBuf), "\n%02X:%02X:%02X:%02X:%02X:%02X (Aid = %d) (AP) -\n",
1961 pEntry->Addr[0], pEntry->Addr[1], pEntry->Addr[2],
1962 pEntry->Addr[3], pEntry->Addr[4], pEntry->Addr[5], pEntry->Aid);
1964 sprintf(pOutBuf, "%s[Recipient]\n", pOutBuf);
1965 for (j=0; j < NUM_OF_TID; j++)
1967 if (pEntry->BARecWcidArray[j] != 0)
1969 pRecBAEntry =&pAd->BATable.BARecEntry[pEntry->BARecWcidArray[j]];
1970 sprintf(pOutBuf + strlen(pOutBuf), "TID=%d, BAWinSize=%d, LastIndSeq=%d, ReorderingPkts=%d\n", j, pRecBAEntry->BAWinSize, pRecBAEntry->LastIndSeq, pRecBAEntry->list.qlen);
1973 sprintf(pOutBuf, "%s\n", pOutBuf);
1975 sprintf(pOutBuf, "%s[Originator]\n", pOutBuf);
1976 for (j=0; j < NUM_OF_TID; j++)
1978 if (pEntry->BAOriWcidArray[j] != 0)
1980 pOriBAEntry =&pAd->BATable.BAOriEntry[pEntry->BAOriWcidArray[j]];
1981 sprintf(pOutBuf + strlen(pOutBuf), "TID=%d, BAWinSize=%d, StartSeq=%d, CurTxSeq=%d\n", j, pOriBAEntry->BAWinSize, pOriBAEntry->Sequence, pEntry->TxSeq[j]);
1984 sprintf(pOutBuf, "%s\n\n", pOutBuf);
1986 if (strlen(pOutBuf) > (IW_PRIV_SIZE_MASK - 30))
1992 #endif // DOT11_N_SUPPORT //
1995 rt_private_show(struct net_device *dev, struct iw_request_info *info,
1996 struct iw_point *wrq, char *extra)
1999 VIRTUAL_ADAPTER *pVirtualAd = NULL;
2002 u32 subcmd = wrq->flags;
2004 if (dev->priv_flags == INT_MAIN)
2008 pVirtualAd = dev->ml_priv;
2009 pAd = pVirtualAd->RtmpDev->ml_priv;
2011 pObj = (POS_COOKIE) pAd->OS_Cookie;
2015 /* if 1st open fail, pAd will be free;
2016 So the net_dev->ml_priv will be NULL in 2rd open */
2025 memset(extra, 0x00, IW_PRIV_SIZE_MASK);
2028 pObj->ioctl_if_type = INT_MAIN;
2029 pObj->ioctl_if = MAIN_MBSSID;
2035 case SHOW_CONN_STATUS:
2036 if (MONITOR_ON(pAd))
2038 #ifdef DOT11_N_SUPPORT
2039 if (pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED &&
2040 pAd->CommonCfg.RegTransmitSetting.field.BW)
2041 sprintf(extra, "Monitor Mode(CentralChannel %d)\n", pAd->CommonCfg.CentralChannel);
2043 #endif // DOT11_N_SUPPORT //
2044 sprintf(extra, "Monitor Mode(Channel %d)\n", pAd->CommonCfg.Channel);
2048 if (pAd->IndicateMediaState == NdisMediaStateConnected)
2052 sprintf(extra, "Connected(AP: %s[%02X:%02X:%02X:%02X:%02X:%02X])\n",
2053 pAd->CommonCfg.Ssid,
2054 pAd->CommonCfg.Bssid[0],
2055 pAd->CommonCfg.Bssid[1],
2056 pAd->CommonCfg.Bssid[2],
2057 pAd->CommonCfg.Bssid[3],
2058 pAd->CommonCfg.Bssid[4],
2059 pAd->CommonCfg.Bssid[5]);
2060 DBGPRINT(RT_DEBUG_TRACE ,("Ssid=%s ,Ssidlen = %d\n",pAd->CommonCfg.Ssid, pAd->CommonCfg.SsidLen));
2062 else if (ADHOC_ON(pAd))
2063 sprintf(extra, "Connected\n");
2067 sprintf(extra, "Disconnected\n");
2068 DBGPRINT(RT_DEBUG_TRACE ,("ConnStatus is not connected\n"));
2071 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2073 case SHOW_DRVIER_VERION:
2074 sprintf(extra, "Driver version-%s, %s %s\n", STA_DRIVER_VERSION, __DATE__, __TIME__ );
2075 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2077 #ifdef DOT11_N_SUPPORT
2079 getBaInfo(pAd, extra);
2080 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2082 #endif // DOT11_N_SUPPORT //
2083 case SHOW_DESC_INFO:
2085 Show_DescInfo_Proc(pAd, NULL);
2086 wrq->length = 0; // 1: size of '\0'
2090 if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
2092 sprintf(extra, "Scanning\n");
2093 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2096 pAd->StaCfg.bSwRadio = FALSE;
2097 if (pAd->StaCfg.bRadio != (pAd->StaCfg.bHwRadio && pAd->StaCfg.bSwRadio))
2099 pAd->StaCfg.bRadio = (pAd->StaCfg.bHwRadio && pAd->StaCfg.bSwRadio);
2100 if (pAd->StaCfg.bRadio == FALSE)
2103 // Update extra information
2104 pAd->ExtraInfo = SW_RADIO_OFF;
2107 sprintf(extra, "Radio Off\n");
2108 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2111 pAd->StaCfg.bSwRadio = TRUE;
2112 //if (pAd->StaCfg.bRadio != (pAd->StaCfg.bHwRadio && pAd->StaCfg.bSwRadio))
2114 pAd->StaCfg.bRadio = (pAd->StaCfg.bHwRadio && pAd->StaCfg.bSwRadio);
2115 if (pAd->StaCfg.bRadio == TRUE)
2118 // Update extra information
2119 pAd->ExtraInfo = EXTRA_INFO_CLEAR;
2122 sprintf(extra, "Radio On\n");
2123 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2127 #ifdef QOS_DLS_SUPPORT
2128 case SHOW_DLS_ENTRY_INFO:
2130 Set_DlsEntryInfo_Display_Proc(pAd, NULL);
2131 wrq->length = 0; // 1: size of '\0'
2134 #endif // QOS_DLS_SUPPORT //
2136 case SHOW_CFG_VALUE:
2138 Status = RTMPShowCfgValue(pAd, wrq->pointer, extra);
2140 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2144 DBGPRINT(RT_DEBUG_TRACE, ("%s - unknow subcmd = %d\n", __func__, subcmd));
2152 int rt_ioctl_siwmlme(struct net_device *dev,
2153 struct iw_request_info *info,
2154 union iwreq_data *wrqu,
2157 PRTMP_ADAPTER pAd = dev->ml_priv;
2158 struct iw_mlme *pMlme = (struct iw_mlme *)wrqu->data.pointer;
2159 MLME_QUEUE_ELEM MsgElem;
2160 MLME_DISASSOC_REQ_STRUCT DisAssocReq;
2161 MLME_DEAUTH_REQ_STRUCT DeAuthReq;
2163 DBGPRINT(RT_DEBUG_TRACE, ("====> %s\n", __func__));
2170 #ifdef IW_MLME_DEAUTH
2171 case IW_MLME_DEAUTH:
2172 DBGPRINT(RT_DEBUG_TRACE, ("====> %s - IW_MLME_DEAUTH\n", __func__));
2173 COPY_MAC_ADDR(DeAuthReq.Addr, pAd->CommonCfg.Bssid);
2174 DeAuthReq.Reason = pMlme->reason_code;
2175 MsgElem.MsgLen = sizeof(MLME_DEAUTH_REQ_STRUCT);
2176 NdisMoveMemory(MsgElem.Msg, &DeAuthReq, sizeof(MLME_DEAUTH_REQ_STRUCT));
2177 MlmeDeauthReqAction(pAd, &MsgElem);
2180 LinkDown(pAd, FALSE);
2181 pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
2184 #endif // IW_MLME_DEAUTH //
2185 #ifdef IW_MLME_DISASSOC
2186 case IW_MLME_DISASSOC:
2187 DBGPRINT(RT_DEBUG_TRACE, ("====> %s - IW_MLME_DISASSOC\n", __func__));
2188 COPY_MAC_ADDR(DisAssocReq.Addr, pAd->CommonCfg.Bssid);
2189 DisAssocReq.Reason = pMlme->reason_code;
2191 MsgElem.Machine = ASSOC_STATE_MACHINE;
2192 MsgElem.MsgType = MT2_MLME_DISASSOC_REQ;
2193 MsgElem.MsgLen = sizeof(MLME_DISASSOC_REQ_STRUCT);
2194 NdisMoveMemory(MsgElem.Msg, &DisAssocReq, sizeof(MLME_DISASSOC_REQ_STRUCT));
2196 pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_OID_DISASSOC;
2197 MlmeDisassocReqAction(pAd, &MsgElem);
2199 #endif // IW_MLME_DISASSOC //
2201 DBGPRINT(RT_DEBUG_TRACE, ("====> %s - Unknow Command\n", __func__));
2207 #endif // SIOCSIWMLME //
2209 #if WIRELESS_EXT > 17
2210 int rt_ioctl_siwauth(struct net_device *dev,
2211 struct iw_request_info *info,
2212 union iwreq_data *wrqu, char *extra)
2214 PRTMP_ADAPTER pAdapter = dev->ml_priv;
2215 struct iw_param *param = &wrqu->param;
2217 //check if the interface is down
2218 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
2220 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
2223 switch (param->flags & IW_AUTH_INDEX) {
2224 case IW_AUTH_WPA_VERSION:
2225 if (param->value == IW_AUTH_WPA_VERSION_WPA)
2227 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPAPSK;
2228 if (pAdapter->StaCfg.BssType == BSS_ADHOC)
2229 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPANone;
2231 else if (param->value == IW_AUTH_WPA_VERSION_WPA2)
2232 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA2PSK;
2234 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_WPA_VERSION - param->value = %d!\n", __func__, param->value));
2236 case IW_AUTH_CIPHER_PAIRWISE:
2237 if (param->value == IW_AUTH_CIPHER_NONE)
2239 pAdapter->StaCfg.WepStatus = Ndis802_11WEPDisabled;
2240 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
2241 pAdapter->StaCfg.PairCipher = Ndis802_11WEPDisabled;
2243 else if (param->value == IW_AUTH_CIPHER_WEP40 ||
2244 param->value == IW_AUTH_CIPHER_WEP104)
2246 pAdapter->StaCfg.WepStatus = Ndis802_11WEPEnabled;
2247 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
2248 pAdapter->StaCfg.PairCipher = Ndis802_11WEPEnabled;
2249 #ifdef WPA_SUPPLICANT_SUPPORT
2250 pAdapter->StaCfg.IEEE8021X = FALSE;
2251 #endif // WPA_SUPPLICANT_SUPPORT //
2253 else if (param->value == IW_AUTH_CIPHER_TKIP)
2255 pAdapter->StaCfg.WepStatus = Ndis802_11Encryption2Enabled;
2256 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
2257 pAdapter->StaCfg.PairCipher = Ndis802_11Encryption2Enabled;
2259 else if (param->value == IW_AUTH_CIPHER_CCMP)
2261 pAdapter->StaCfg.WepStatus = Ndis802_11Encryption3Enabled;
2262 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
2263 pAdapter->StaCfg.PairCipher = Ndis802_11Encryption3Enabled;
2265 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_CIPHER_PAIRWISE - param->value = %d!\n", __func__, param->value));
2267 case IW_AUTH_CIPHER_GROUP:
2268 if (param->value == IW_AUTH_CIPHER_NONE)
2270 pAdapter->StaCfg.GroupCipher = Ndis802_11WEPDisabled;
2272 else if (param->value == IW_AUTH_CIPHER_WEP40 ||
2273 param->value == IW_AUTH_CIPHER_WEP104)
2275 pAdapter->StaCfg.GroupCipher = Ndis802_11WEPEnabled;
2277 else if (param->value == IW_AUTH_CIPHER_TKIP)
2279 pAdapter->StaCfg.GroupCipher = Ndis802_11Encryption2Enabled;
2281 else if (param->value == IW_AUTH_CIPHER_CCMP)
2283 pAdapter->StaCfg.GroupCipher = Ndis802_11Encryption3Enabled;
2285 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_CIPHER_GROUP - param->value = %d!\n", __func__, param->value));
2287 case IW_AUTH_KEY_MGMT:
2288 if (param->value == IW_AUTH_KEY_MGMT_802_1X)
2290 if (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK)
2292 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA;
2293 #ifdef WPA_SUPPLICANT_SUPPORT
2294 pAdapter->StaCfg.IEEE8021X = FALSE;
2295 #endif // WPA_SUPPLICANT_SUPPORT //
2297 else if (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK)
2299 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA2;
2300 #ifdef WPA_SUPPLICANT_SUPPORT
2301 pAdapter->StaCfg.IEEE8021X = FALSE;
2302 #endif // WPA_SUPPLICANT_SUPPORT //
2304 #ifdef WPA_SUPPLICANT_SUPPORT
2307 pAdapter->StaCfg.IEEE8021X = TRUE;
2308 #endif // WPA_SUPPLICANT_SUPPORT //
2310 else if (param->value == 0)
2312 STA_PORT_SECURED(pAdapter);
2314 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_KEY_MGMT - param->value = %d!\n", __func__, param->value));
2316 case IW_AUTH_RX_UNENCRYPTED_EAPOL:
2318 case IW_AUTH_PRIVACY_INVOKED:
2319 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_PRIVACY_INVOKED - param->value = %d!\n", __func__, param->value));
2321 case IW_AUTH_DROP_UNENCRYPTED:
2322 if (param->value != 0)
2323 pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED;
2326 STA_PORT_SECURED(pAdapter);
2328 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_WPA_VERSION - param->value = %d!\n", __func__, param->value));
2330 case IW_AUTH_80211_AUTH_ALG:
2331 if (param->value & IW_AUTH_ALG_SHARED_KEY)
2333 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeShared;
2335 else if (param->value & IW_AUTH_ALG_OPEN_SYSTEM)
2337 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
2341 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_80211_AUTH_ALG - param->value = %d!\n", __func__, param->value));
2343 case IW_AUTH_WPA_ENABLED:
2344 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_WPA_ENABLED - Driver supports WPA!(param->value = %d)\n", __func__, param->value));
2353 int rt_ioctl_giwauth(struct net_device *dev,
2354 struct iw_request_info *info,
2355 union iwreq_data *wrqu, char *extra)
2357 PRTMP_ADAPTER pAdapter = dev->ml_priv;
2358 struct iw_param *param = &wrqu->param;
2360 //check if the interface is down
2361 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
2363 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
2367 switch (param->flags & IW_AUTH_INDEX) {
2368 case IW_AUTH_DROP_UNENCRYPTED:
2369 param->value = (pAdapter->StaCfg.WepStatus == Ndis802_11WEPDisabled) ? 0 : 1;
2372 case IW_AUTH_80211_AUTH_ALG:
2373 param->value = (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeShared) ? IW_AUTH_ALG_SHARED_KEY : IW_AUTH_ALG_OPEN_SYSTEM;
2376 case IW_AUTH_WPA_ENABLED:
2377 param->value = (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA) ? 1 : 0;
2383 DBGPRINT(RT_DEBUG_TRACE, ("rt_ioctl_giwauth::param->value = %d!\n", param->value));
2387 void fnSetCipherKey(
2388 IN PRTMP_ADAPTER pAdapter,
2392 IN struct iw_encode_ext *ext)
2394 RTMP_CLEAR_PSFLAG(pAdapter, fRTMP_PS_CAN_GO_SLEEP);
2395 if (RTMP_TEST_PSFLAG(pAdapter, fRTMP_PS_SET_PCI_CLK_OFF_COMMAND))
2397 if (pAdapter->StaCfg.bRadio == FALSE)
2399 RTMP_SET_PSFLAG(pAdapter, fRTMP_PS_CAN_GO_SLEEP);
2402 DBGPRINT(RT_DEBUG_TRACE,("RTMPWPAAddKeyProc1==>\n"));
2403 RTMPPCIeLinkCtrlValueRestore(pAdapter, RESTORE_HALT);
2404 RTMPusecDelay(6000);
2405 pAdapter->bPCIclkOff = FALSE;
2408 NdisZeroMemory(&pAdapter->SharedKey[BSS0][keyIdx], sizeof(CIPHER_KEY));
2409 pAdapter->SharedKey[BSS0][keyIdx].KeyLen = LEN_TKIP_EK;
2410 NdisMoveMemory(pAdapter->SharedKey[BSS0][keyIdx].Key, ext->key, LEN_TKIP_EK);
2411 NdisMoveMemory(pAdapter->SharedKey[BSS0][keyIdx].TxMic, ext->key + LEN_TKIP_EK, LEN_TKIP_TXMICK);
2412 NdisMoveMemory(pAdapter->SharedKey[BSS0][keyIdx].RxMic, ext->key + LEN_TKIP_EK + LEN_TKIP_TXMICK, LEN_TKIP_RXMICK);
2413 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CipherAlg;
2415 // Update group key information to ASIC Shared Key Table
2416 AsicAddSharedKeyEntry(pAdapter,
2419 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg,
2420 pAdapter->SharedKey[BSS0][keyIdx].Key,
2421 pAdapter->SharedKey[BSS0][keyIdx].TxMic,
2422 pAdapter->SharedKey[BSS0][keyIdx].RxMic);
2425 // Update ASIC WCID attribute table and IVEIV table
2426 RTMPAddWcidAttributeEntry(pAdapter,
2429 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg,
2432 // Update ASIC WCID attribute table and IVEIV table
2433 RTMPAddWcidAttributeEntry(pAdapter,
2436 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg,
2437 &pAdapter->MacTab.Content[BSSID_WCID]);
2439 RTMP_SET_PSFLAG(pAdapter, fRTMP_PS_CAN_GO_SLEEP);
2442 int rt_ioctl_siwencodeext(struct net_device *dev,
2443 struct iw_request_info *info,
2444 union iwreq_data *wrqu,
2447 PRTMP_ADAPTER pAdapter = dev->ml_priv;
2448 struct iw_point *encoding = &wrqu->encoding;
2449 struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
2450 int keyIdx, alg = ext->alg;
2452 //check if the interface is down
2453 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
2455 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
2459 if (encoding->flags & IW_ENCODE_DISABLED)
2461 keyIdx = (encoding->flags & IW_ENCODE_INDEX) - 1;
2462 // set BSSID wcid entry of the Pair-wise Key table as no-security mode
2463 AsicRemovePairwiseKeyEntry(pAdapter, BSS0, BSSID_WCID);
2464 pAdapter->SharedKey[BSS0][keyIdx].KeyLen = 0;
2465 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CIPHER_NONE;
2466 AsicRemoveSharedKeyEntry(pAdapter, 0, (UCHAR)keyIdx);
2467 NdisZeroMemory(&pAdapter->SharedKey[BSS0][keyIdx], sizeof(CIPHER_KEY));
2468 DBGPRINT(RT_DEBUG_TRACE, ("%s::Remove all keys!(encoding->flags = %x)\n", __func__, encoding->flags));
2472 // Get Key Index and convet to our own defined key index
2473 keyIdx = (encoding->flags & IW_ENCODE_INDEX) - 1;
2474 if((keyIdx < 0) || (keyIdx >= NR_WEP_KEYS))
2477 if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
2479 pAdapter->StaCfg.DefaultKeyId = keyIdx;
2480 DBGPRINT(RT_DEBUG_TRACE, ("%s::DefaultKeyId = %d\n", __func__, pAdapter->StaCfg.DefaultKeyId));
2484 case IW_ENCODE_ALG_NONE:
2485 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_ENCODE_ALG_NONE\n", __func__));
2487 case IW_ENCODE_ALG_WEP:
2488 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_ENCODE_ALG_WEP - ext->key_len = %d, keyIdx = %d\n", __func__, ext->key_len, keyIdx));
2489 if (ext->key_len == MAX_WEP_KEY_SIZE)
2491 pAdapter->SharedKey[BSS0][keyIdx].KeyLen = MAX_WEP_KEY_SIZE;
2492 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CIPHER_WEP128;
2494 else if (ext->key_len == MIN_WEP_KEY_SIZE)
2496 pAdapter->SharedKey[BSS0][keyIdx].KeyLen = MIN_WEP_KEY_SIZE;
2497 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CIPHER_WEP64;
2502 NdisZeroMemory(pAdapter->SharedKey[BSS0][keyIdx].Key, 16);
2503 NdisMoveMemory(pAdapter->SharedKey[BSS0][keyIdx].Key, ext->key, ext->key_len);
2505 if (pAdapter->StaCfg.GroupCipher == Ndis802_11GroupWEP40Enabled ||
2506 pAdapter->StaCfg.GroupCipher == Ndis802_11GroupWEP104Enabled)
2508 // Set Group key material to Asic
2509 AsicAddSharedKeyEntry(pAdapter, BSS0, keyIdx, pAdapter->SharedKey[BSS0][keyIdx].CipherAlg, pAdapter->SharedKey[BSS0][keyIdx].Key, NULL, NULL);
2511 // Update WCID attribute table and IVEIV table for this group key table
2512 RTMPAddWcidAttributeEntry(pAdapter, BSS0, keyIdx, pAdapter->SharedKey[BSS0][keyIdx].CipherAlg, NULL);
2514 STA_PORT_SECURED(pAdapter);
2516 // Indicate Connected for GUI
2517 pAdapter->IndicateMediaState = NdisMediaStateConnected;
2520 case IW_ENCODE_ALG_TKIP:
2521 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_ENCODE_ALG_TKIP - keyIdx = %d, ext->key_len = %d\n", __func__, keyIdx, ext->key_len));
2522 if (ext->key_len == 32)
2524 if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
2526 fnSetCipherKey(pAdapter, keyIdx, CIPHER_TKIP, FALSE, ext);
2527 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA2)
2529 STA_PORT_SECURED(pAdapter);
2532 else if (ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY)
2534 fnSetCipherKey(pAdapter, keyIdx, CIPHER_TKIP, TRUE, ext);
2536 // set 802.1x port control
2537 STA_PORT_SECURED(pAdapter);
2543 case IW_ENCODE_ALG_CCMP:
2544 if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
2546 fnSetCipherKey(pAdapter, keyIdx, CIPHER_AES, FALSE, ext);
2547 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA2)
2548 STA_PORT_SECURED(pAdapter);
2550 else if (ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY)
2552 fnSetCipherKey(pAdapter, keyIdx, CIPHER_AES, TRUE, ext);
2554 // set 802.1x port control
2555 STA_PORT_SECURED(pAdapter);
2567 rt_ioctl_giwencodeext(struct net_device *dev,
2568 struct iw_request_info *info,
2569 union iwreq_data *wrqu, char *extra)
2571 PRTMP_ADAPTER pAd = dev->ml_priv;
2573 struct iw_point *encoding = &wrqu->encoding;
2574 struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
2575 int idx, max_key_len;
2577 DBGPRINT(RT_DEBUG_TRACE ,("===> rt_ioctl_giwencodeext\n"));
2579 max_key_len = encoding->length - sizeof(*ext);
2580 if (max_key_len < 0)
2583 idx = encoding->flags & IW_ENCODE_INDEX;
2586 if (idx < 1 || idx > 4)
2590 if ((pAd->StaCfg.WepStatus == Ndis802_11Encryption2Enabled) ||
2591 (pAd->StaCfg.WepStatus == Ndis802_11Encryption3Enabled))
2593 if (idx != pAd->StaCfg.DefaultKeyId)
2601 idx = pAd->StaCfg.DefaultKeyId;
2603 encoding->flags = idx + 1;
2604 memset(ext, 0, sizeof(*ext));
2607 switch(pAd->StaCfg.WepStatus) {
2608 case Ndis802_11WEPDisabled:
2609 ext->alg = IW_ENCODE_ALG_NONE;
2610 encoding->flags |= IW_ENCODE_DISABLED;
2612 case Ndis802_11WEPEnabled:
2613 ext->alg = IW_ENCODE_ALG_WEP;
2614 if (pAd->SharedKey[BSS0][idx].KeyLen > max_key_len)
2618 ext->key_len = pAd->SharedKey[BSS0][idx].KeyLen;
2619 pKey = &(pAd->SharedKey[BSS0][idx].Key[0]);
2622 case Ndis802_11Encryption2Enabled:
2623 case Ndis802_11Encryption3Enabled:
2624 if (pAd->StaCfg.WepStatus == Ndis802_11Encryption2Enabled)
2625 ext->alg = IW_ENCODE_ALG_TKIP;
2627 ext->alg = IW_ENCODE_ALG_CCMP;
2629 if (max_key_len < 32)
2634 pKey = &pAd->StaCfg.PMK[0];
2641 if (ext->key_len && pKey)
2643 encoding->flags |= IW_ENCODE_ENABLED;
2644 memcpy(ext->key, pKey, ext->key_len);
2651 int rt_ioctl_siwgenie(struct net_device *dev,
2652 struct iw_request_info *info,
2653 union iwreq_data *wrqu, char *extra)
2655 PRTMP_ADAPTER pAd = dev->ml_priv;
2657 if (wrqu->data.length > MAX_LEN_OF_RSNIE ||
2658 (wrqu->data.length && extra == NULL))
2661 if (wrqu->data.length)
2663 pAd->StaCfg.RSNIE_Len = wrqu->data.length;
2664 NdisMoveMemory(&pAd->StaCfg.RSN_IE[0], extra, pAd->StaCfg.RSNIE_Len);
2668 pAd->StaCfg.RSNIE_Len = 0;
2669 NdisZeroMemory(&pAd->StaCfg.RSN_IE[0], MAX_LEN_OF_RSNIE);
2674 #endif // SIOCSIWGENIE //
2676 int rt_ioctl_giwgenie(struct net_device *dev,
2677 struct iw_request_info *info,
2678 union iwreq_data *wrqu, char *extra)
2680 PRTMP_ADAPTER pAd = dev->ml_priv;
2682 if ((pAd->StaCfg.RSNIE_Len == 0) ||
2683 (pAd->StaCfg.AuthMode < Ndis802_11AuthModeWPA))
2685 wrqu->data.length = 0;
2689 #ifdef NATIVE_WPA_SUPPLICANT_SUPPORT
2691 if (pAd->StaCfg.WpaSupplicantUP == WPA_SUPPLICANT_ENABLE)
2693 if (wrqu->data.length < pAd->StaCfg.RSNIE_Len)
2696 wrqu->data.length = pAd->StaCfg.RSNIE_Len;
2697 memcpy(extra, &pAd->StaCfg.RSN_IE[0], pAd->StaCfg.RSNIE_Len);
2700 #endif // SIOCSIWGENIE //
2701 #endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
2703 UCHAR RSNIe = IE_WPA;
2705 if (wrqu->data.length < (pAd->StaCfg.RSNIE_Len + 2)) // ID, Len
2707 wrqu->data.length = pAd->StaCfg.RSNIE_Len + 2;
2709 if ((pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK) ||
2710 (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2))
2713 extra[0] = (char)RSNIe;
2714 extra[1] = pAd->StaCfg.RSNIE_Len;
2715 memcpy(extra+2, &pAd->StaCfg.RSN_IE[0], pAd->StaCfg.RSNIE_Len);
2721 int rt_ioctl_siwpmksa(struct net_device *dev,
2722 struct iw_request_info *info,
2723 union iwreq_data *wrqu,
2726 PRTMP_ADAPTER pAd = dev->ml_priv;
2727 struct iw_pmksa *pPmksa = (struct iw_pmksa *)wrqu->data.pointer;
2728 INT CachedIdx = 0, idx = 0;
2733 DBGPRINT(RT_DEBUG_TRACE ,("===> rt_ioctl_siwpmksa\n"));
2736 case IW_PMKSA_FLUSH:
2737 NdisZeroMemory(pAd->StaCfg.SavedPMK, sizeof(BSSID_INFO)*PMKID_NO);
2738 DBGPRINT(RT_DEBUG_TRACE ,("rt_ioctl_siwpmksa - IW_PMKSA_FLUSH\n"));
2740 case IW_PMKSA_REMOVE:
2741 for (CachedIdx = 0; CachedIdx < pAd->StaCfg.SavedPMKNum; CachedIdx++)
2743 // compare the BSSID
2744 if (NdisEqualMemory(pPmksa->bssid.sa_data, pAd->StaCfg.SavedPMK[CachedIdx].BSSID, MAC_ADDR_LEN))
2746 NdisZeroMemory(pAd->StaCfg.SavedPMK[CachedIdx].BSSID, MAC_ADDR_LEN);
2747 NdisZeroMemory(pAd->StaCfg.SavedPMK[CachedIdx].PMKID, 16);
2748 for (idx = CachedIdx; idx < (pAd->StaCfg.SavedPMKNum - 1); idx++)
2750 NdisMoveMemory(&pAd->StaCfg.SavedPMK[idx].BSSID[0], &pAd->StaCfg.SavedPMK[idx+1].BSSID[0], MAC_ADDR_LEN);
2751 NdisMoveMemory(&pAd->StaCfg.SavedPMK[idx].PMKID[0], &pAd->StaCfg.SavedPMK[idx+1].PMKID[0], 16);
2753 pAd->StaCfg.SavedPMKNum--;
2758 DBGPRINT(RT_DEBUG_TRACE ,("rt_ioctl_siwpmksa - IW_PMKSA_REMOVE\n"));
2761 for (CachedIdx = 0; CachedIdx < pAd->StaCfg.SavedPMKNum; CachedIdx++)
2763 // compare the BSSID
2764 if (NdisEqualMemory(pPmksa->bssid.sa_data, pAd->StaCfg.SavedPMK[CachedIdx].BSSID, MAC_ADDR_LEN))
2768 // Found, replace it
2769 if (CachedIdx < PMKID_NO)
2771 DBGPRINT(RT_DEBUG_OFF, ("Update PMKID, idx = %d\n", CachedIdx));
2772 NdisMoveMemory(&pAd->StaCfg.SavedPMK[CachedIdx].BSSID[0], pPmksa->bssid.sa_data, MAC_ADDR_LEN);
2773 NdisMoveMemory(&pAd->StaCfg.SavedPMK[CachedIdx].PMKID[0], pPmksa->pmkid, 16);
2774 pAd->StaCfg.SavedPMKNum++;
2776 // Not found, replace the last one
2779 // Randomly replace one
2780 CachedIdx = (pPmksa->bssid.sa_data[5] % PMKID_NO);
2781 DBGPRINT(RT_DEBUG_OFF, ("Update PMKID, idx = %d\n", CachedIdx));
2782 NdisMoveMemory(&pAd->StaCfg.SavedPMK[CachedIdx].BSSID[0], pPmksa->bssid.sa_data, MAC_ADDR_LEN);
2783 NdisMoveMemory(&pAd->StaCfg.SavedPMK[CachedIdx].PMKID[0], pPmksa->pmkid, 16);
2786 DBGPRINT(RT_DEBUG_TRACE ,("rt_ioctl_siwpmksa - IW_PMKSA_ADD\n"));
2789 DBGPRINT(RT_DEBUG_TRACE ,("rt_ioctl_siwpmksa - Unknow Command!!\n"));
2795 #endif // #if WIRELESS_EXT > 17
2799 rt_private_ioctl_bbp(struct net_device *dev, struct iw_request_info *info,
2800 struct iw_point *wrq, char *extra)
2807 BOOLEAN bIsPrintAllBBP = FALSE;
2809 PRTMP_ADAPTER pAdapter = dev->ml_priv;
2812 memset(extra, 0x00, IW_PRIV_SIZE_MASK);
2814 if (wrq->length > 1) //No parameters.
2816 sprintf(extra, "\n");
2818 //Parsing Read or Write
2819 this_char = wrq->pointer;
2820 DBGPRINT(RT_DEBUG_TRACE, ("this_char=%s\n", this_char));
2824 if ((value = rtstrchr(this_char, '=')) != NULL)
2827 if (!value || !*value)
2829 DBGPRINT(RT_DEBUG_TRACE, ("this_char=%s, value=%s\n", this_char, value));
2830 if (sscanf(this_char, "%d", &(bbpId)) == 1)
2835 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, ®BBP);
2837 sprintf(extra+strlen(extra), "R%02d[0x%02X]:%02X\n", bbpId, bbpId*2, regBBP);
2838 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2839 DBGPRINT(RT_DEBUG_TRACE, ("msg=%s\n", extra));
2842 {//Invalid parametes, so default printk all bbp
2843 bIsPrintAllBBP = TRUE;
2848 { //Invalid parametes, so default printk all bbp
2849 bIsPrintAllBBP = TRUE;
2855 if ((sscanf(this_char, "%d", &(bbpId)) == 1) && (sscanf(value, "%x", &(bbpValue)) == 1))
2860 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, bbpId, bbpValue);
2861 //Read it back for showing
2862 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, ®BBP);
2864 sprintf(extra+strlen(extra), "R%02d[0x%02X]:%02X\n", bbpId, bbpId*2, regBBP);
2865 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2866 DBGPRINT(RT_DEBUG_TRACE, ("msg=%s\n", extra));
2869 {//Invalid parametes, so default printk all bbp
2870 bIsPrintAllBBP = TRUE;
2875 { //Invalid parametes, so default printk all bbp
2876 bIsPrintAllBBP = TRUE;
2882 bIsPrintAllBBP = TRUE;
2887 memset(extra, 0x00, IW_PRIV_SIZE_MASK);
2888 sprintf(extra, "\n");
2889 for (bbpId = 0; bbpId <= 136; bbpId++)
2891 if (strlen(extra) >= (IW_PRIV_SIZE_MASK - 10))
2893 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, ®BBP);
2894 sprintf(extra+strlen(extra), "R%02d[0x%02X]:%02X ", bbpId, bbpId*2, regBBP);
2896 sprintf(extra+strlen(extra), "\n");
2899 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2900 DBGPRINT(RT_DEBUG_TRACE, ("wrq->length = %d\n", wrq->length));
2903 DBGPRINT(RT_DEBUG_TRACE, ("<==rt_private_ioctl_bbp\n\n"));
2909 int rt_ioctl_siwrate(struct net_device *dev,
2910 struct iw_request_info *info,
2911 union iwreq_data *wrqu, char *extra)
2913 PRTMP_ADAPTER pAd = dev->ml_priv;
2914 UINT32 rate = wrqu->bitrate.value, fixed = wrqu->bitrate.fixed;
2916 //check if the interface is down
2917 if(!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_IN_USE))
2919 DBGPRINT(RT_DEBUG_TRACE, ("rt_ioctl_siwrate::Network is down!\n"));
2923 DBGPRINT(RT_DEBUG_TRACE, ("rt_ioctl_siwrate::(rate = %d, fixed = %d)\n", rate, fixed));
2924 /* rate = -1 => auto rate
2925 rate = X, fixed = 1 => (fixed rate X)
2930 pAd->StaCfg.DesiredTransmitSetting.field.MCS = MCS_AUTO;
2931 pAd->StaCfg.bAutoTxRateSwitch = TRUE;
2932 if ((pAd->CommonCfg.PhyMode <= PHY_11G) ||
2933 (pAd->MacTab.Content[BSSID_WCID].HTPhyMode.field.MODE <= MODE_OFDM))
2934 RTMPSetDesiredRates(pAd, -1);
2936 #ifdef DOT11_N_SUPPORT
2938 #endif // DOT11_N_SUPPORT //
2944 pAd->StaCfg.bAutoTxRateSwitch = FALSE;
2945 if ((pAd->CommonCfg.PhyMode <= PHY_11G) ||
2946 (pAd->MacTab.Content[BSSID_WCID].HTPhyMode.field.MODE <= MODE_OFDM))
2947 RTMPSetDesiredRates(pAd, rate);
2950 pAd->StaCfg.DesiredTransmitSetting.field.MCS = MCS_AUTO;
2951 #ifdef DOT11_N_SUPPORT
2953 #endif // DOT11_N_SUPPORT //
2955 DBGPRINT(RT_DEBUG_TRACE, ("rt_ioctl_siwrate::(HtMcs=%d)\n",pAd->StaCfg.DesiredTransmitSetting.field.MCS));
2959 // TODO: rate = X, fixed = 0 => (rates <= X)
2967 int rt_ioctl_giwrate(struct net_device *dev,
2968 struct iw_request_info *info,
2969 union iwreq_data *wrqu, char *extra)
2971 PRTMP_ADAPTER pAd = dev->ml_priv;
2972 int rate_index = 0, rate_count = 0;
2973 HTTRANSMIT_SETTING ht_setting;
2974 __s32 ralinkrate[] =
2975 {2, 4, 11, 22, // CCK
2976 12, 18, 24, 36, 48, 72, 96, 108, // OFDM
2977 13, 26, 39, 52, 78, 104, 117, 130, 26, 52, 78, 104, 156, 208, 234, 260, // 20MHz, 800ns GI, MCS: 0 ~ 15
2978 39, 78, 117, 156, 234, 312, 351, 390, // 20MHz, 800ns GI, MCS: 16 ~ 23
2979 27, 54, 81, 108, 162, 216, 243, 270, 54, 108, 162, 216, 324, 432, 486, 540, // 40MHz, 800ns GI, MCS: 0 ~ 15
2980 81, 162, 243, 324, 486, 648, 729, 810, // 40MHz, 800ns GI, MCS: 16 ~ 23
2981 14, 29, 43, 57, 87, 115, 130, 144, 29, 59, 87, 115, 173, 230, 260, 288, // 20MHz, 400ns GI, MCS: 0 ~ 15
2982 43, 87, 130, 173, 260, 317, 390, 433, // 20MHz, 400ns GI, MCS: 16 ~ 23
2983 30, 60, 90, 120, 180, 240, 270, 300, 60, 120, 180, 240, 360, 480, 540, 600, // 40MHz, 400ns GI, MCS: 0 ~ 15
2984 90, 180, 270, 360, 540, 720, 810, 900}; // 40MHz, 400ns GI, MCS: 16 ~ 23
2986 rate_count = sizeof(ralinkrate)/sizeof(__s32);
2987 //check if the interface is down
2988 if(!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_IN_USE))
2990 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
2994 if ((pAd->StaCfg.bAutoTxRateSwitch == FALSE) &&
2996 ((pAd->CommonCfg.PhyMode <= PHY_11G) || (pAd->MacTab.Content[BSSID_WCID].HTPhyMode.field.MODE <= MODE_OFDM)))
2997 ht_setting.word = pAd->StaCfg.HTPhyMode.word;
2999 ht_setting.word = pAd->MacTab.Content[BSSID_WCID].HTPhyMode.word;
3001 #ifdef DOT11_N_SUPPORT
3002 if (ht_setting.field.MODE >= MODE_HTMIX)
3004 rate_index = 12 + ((UCHAR)ht_setting.field.BW *24) + ((UCHAR)ht_setting.field.ShortGI *48) + ((UCHAR)ht_setting.field.MCS);
3007 #endif // DOT11_N_SUPPORT //
3008 if (ht_setting.field.MODE == MODE_OFDM)
3009 rate_index = (UCHAR)(ht_setting.field.MCS) + 4;
3010 else if (ht_setting.field.MODE == MODE_CCK)
3011 rate_index = (UCHAR)(ht_setting.field.MCS);
3016 if (rate_index > rate_count)
3017 rate_index = rate_count;
3019 wrqu->bitrate.value = ralinkrate[rate_index] * 500000;
3020 wrqu->bitrate.disabled = 0;
3025 static const iw_handler rt_handler[] =
3027 (iw_handler) NULL, /* SIOCSIWCOMMIT */
3028 (iw_handler) rt_ioctl_giwname, /* SIOCGIWNAME */
3029 (iw_handler) NULL, /* SIOCSIWNWID */
3030 (iw_handler) NULL, /* SIOCGIWNWID */
3031 (iw_handler) rt_ioctl_siwfreq, /* SIOCSIWFREQ */
3032 (iw_handler) rt_ioctl_giwfreq, /* SIOCGIWFREQ */
3033 (iw_handler) rt_ioctl_siwmode, /* SIOCSIWMODE */
3034 (iw_handler) rt_ioctl_giwmode, /* SIOCGIWMODE */
3035 (iw_handler) NULL, /* SIOCSIWSENS */
3036 (iw_handler) NULL, /* SIOCGIWSENS */
3037 (iw_handler) NULL /* not used */, /* SIOCSIWRANGE */
3038 (iw_handler) rt_ioctl_giwrange, /* SIOCGIWRANGE */
3039 (iw_handler) NULL /* not used */, /* SIOCSIWPRIV */
3040 (iw_handler) NULL /* kernel code */, /* SIOCGIWPRIV */
3041 (iw_handler) NULL /* not used */, /* SIOCSIWSTATS */
3042 (iw_handler) rt28xx_get_wireless_stats /* kernel code */, /* SIOCGIWSTATS */
3043 (iw_handler) NULL, /* SIOCSIWSPY */
3044 (iw_handler) NULL, /* SIOCGIWSPY */
3045 (iw_handler) NULL, /* SIOCSIWTHRSPY */
3046 (iw_handler) NULL, /* SIOCGIWTHRSPY */
3047 (iw_handler) rt_ioctl_siwap, /* SIOCSIWAP */
3048 (iw_handler) rt_ioctl_giwap, /* SIOCGIWAP */
3050 (iw_handler) rt_ioctl_siwmlme, /* SIOCSIWMLME */
3052 (iw_handler) NULL, /* SIOCSIWMLME */
3053 #endif // SIOCSIWMLME //
3054 (iw_handler) rt_ioctl_iwaplist, /* SIOCGIWAPLIST */
3056 (iw_handler) rt_ioctl_siwscan, /* SIOCSIWSCAN */
3057 (iw_handler) rt_ioctl_giwscan, /* SIOCGIWSCAN */
3059 (iw_handler) NULL, /* SIOCSIWSCAN */
3060 (iw_handler) NULL, /* SIOCGIWSCAN */
3061 #endif /* SIOCGIWSCAN */
3062 (iw_handler) rt_ioctl_siwessid, /* SIOCSIWESSID */
3063 (iw_handler) rt_ioctl_giwessid, /* SIOCGIWESSID */
3064 (iw_handler) rt_ioctl_siwnickn, /* SIOCSIWNICKN */
3065 (iw_handler) rt_ioctl_giwnickn, /* SIOCGIWNICKN */
3066 (iw_handler) NULL, /* -- hole -- */
3067 (iw_handler) NULL, /* -- hole -- */
3068 (iw_handler) rt_ioctl_siwrate, /* SIOCSIWRATE */
3069 (iw_handler) rt_ioctl_giwrate, /* SIOCGIWRATE */
3070 (iw_handler) rt_ioctl_siwrts, /* SIOCSIWRTS */
3071 (iw_handler) rt_ioctl_giwrts, /* SIOCGIWRTS */
3072 (iw_handler) rt_ioctl_siwfrag, /* SIOCSIWFRAG */
3073 (iw_handler) rt_ioctl_giwfrag, /* SIOCGIWFRAG */
3074 (iw_handler) NULL, /* SIOCSIWTXPOW */
3075 (iw_handler) NULL, /* SIOCGIWTXPOW */
3076 (iw_handler) NULL, /* SIOCSIWRETRY */
3077 (iw_handler) NULL, /* SIOCGIWRETRY */
3078 (iw_handler) rt_ioctl_siwencode, /* SIOCSIWENCODE */
3079 (iw_handler) rt_ioctl_giwencode, /* SIOCGIWENCODE */
3080 (iw_handler) NULL, /* SIOCSIWPOWER */
3081 (iw_handler) NULL, /* SIOCGIWPOWER */
3082 (iw_handler) NULL, /* -- hole -- */
3083 (iw_handler) NULL, /* -- hole -- */
3084 #if WIRELESS_EXT > 17
3085 (iw_handler) rt_ioctl_siwgenie, /* SIOCSIWGENIE */
3086 (iw_handler) rt_ioctl_giwgenie, /* SIOCGIWGENIE */
3087 (iw_handler) rt_ioctl_siwauth, /* SIOCSIWAUTH */
3088 (iw_handler) rt_ioctl_giwauth, /* SIOCGIWAUTH */
3089 (iw_handler) rt_ioctl_siwencodeext, /* SIOCSIWENCODEEXT */
3090 (iw_handler) rt_ioctl_giwencodeext, /* SIOCGIWENCODEEXT */
3091 (iw_handler) rt_ioctl_siwpmksa, /* SIOCSIWPMKSA */
3095 static const iw_handler rt_priv_handlers[] = {
3096 (iw_handler) NULL, /* + 0x00 */
3097 (iw_handler) NULL, /* + 0x01 */
3098 #ifndef CONFIG_AP_SUPPORT
3099 (iw_handler) rt_ioctl_setparam, /* + 0x02 */
3101 (iw_handler) NULL, /* + 0x02 */
3102 #endif // CONFIG_AP_SUPPORT //
3104 (iw_handler) rt_private_ioctl_bbp, /* + 0x03 */
3106 (iw_handler) NULL, /* + 0x03 */
3108 (iw_handler) NULL, /* + 0x04 */
3109 (iw_handler) NULL, /* + 0x05 */
3110 (iw_handler) NULL, /* + 0x06 */
3111 (iw_handler) NULL, /* + 0x07 */
3112 (iw_handler) NULL, /* + 0x08 */
3113 (iw_handler) rt_private_get_statistics, /* + 0x09 */
3114 (iw_handler) NULL, /* + 0x0A */
3115 (iw_handler) NULL, /* + 0x0B */
3116 (iw_handler) NULL, /* + 0x0C */
3117 (iw_handler) NULL, /* + 0x0D */
3118 (iw_handler) NULL, /* + 0x0E */
3119 (iw_handler) NULL, /* + 0x0F */
3120 (iw_handler) NULL, /* + 0x10 */
3121 (iw_handler) rt_private_show, /* + 0x11 */
3122 (iw_handler) NULL, /* + 0x12 */
3123 (iw_handler) NULL, /* + 0x13 */
3124 (iw_handler) NULL, /* + 0x15 */
3125 (iw_handler) NULL, /* + 0x17 */
3126 (iw_handler) NULL, /* + 0x18 */
3129 const struct iw_handler_def rt28xx_iw_handler_def =
3131 #define N(a) (sizeof (a) / sizeof (a[0]))
3132 .standard = (iw_handler *) rt_handler,
3133 .num_standard = sizeof(rt_handler) / sizeof(iw_handler),
3134 .private = (iw_handler *) rt_priv_handlers,
3135 .num_private = N(rt_priv_handlers),
3136 .private_args = (struct iw_priv_args *) privtab,
3137 .num_private_args = N(privtab),
3138 #if IW_HANDLER_VERSION >= 7
3139 .get_wireless_stats = rt28xx_get_wireless_stats,
3143 INT RTMPSetInformation(
3144 IN PRTMP_ADAPTER pAdapter,
3145 IN OUT struct ifreq *rq,
3148 struct iwreq *wrq = (struct iwreq *) rq;
3149 NDIS_802_11_SSID Ssid;
3150 NDIS_802_11_MAC_ADDRESS Bssid;
3151 RT_802_11_PHY_MODE PhyMode;
3152 RT_802_11_STA_CONFIG StaConfig;
3153 NDIS_802_11_RATES aryRates;
3154 RT_802_11_PREAMBLE Preamble;
3155 NDIS_802_11_WEP_STATUS WepStatus;
3156 NDIS_802_11_AUTHENTICATION_MODE AuthMode = Ndis802_11AuthModeMax;
3157 NDIS_802_11_NETWORK_INFRASTRUCTURE BssType;
3158 NDIS_802_11_RTS_THRESHOLD RtsThresh;
3159 NDIS_802_11_FRAGMENTATION_THRESHOLD FragThresh;
3160 NDIS_802_11_POWER_MODE PowerMode;
3161 PNDIS_802_11_KEY pKey = NULL;
3162 PNDIS_802_11_WEP pWepKey =NULL;
3163 PNDIS_802_11_REMOVE_KEY pRemoveKey = NULL;
3164 NDIS_802_11_CONFIGURATION Config, *pConfig = NULL;
3165 NDIS_802_11_NETWORK_TYPE NetType;
3168 INT Status = NDIS_STATUS_SUCCESS, MaxPhyMode = PHY_11G;
3171 BOOLEAN StateMachineTouched = FALSE;
3172 #ifdef DOT11_N_SUPPORT
3173 OID_SET_HT_PHYMODE HT_PhyMode; //11n ,kathy
3174 #endif // DOT11_N_SUPPORT //
3175 #ifdef WPA_SUPPLICANT_SUPPORT
3176 PNDIS_802_11_PMKID pPmkId = NULL;
3177 BOOLEAN IEEE8021xState = FALSE;
3178 BOOLEAN IEEE8021x_required_keys = FALSE;
3179 UCHAR wpa_supplicant_enable = 0;
3180 #endif // WPA_SUPPLICANT_SUPPORT //
3183 TX_RTY_CFG_STRUC tx_rty_cfg;
3184 ULONG ShortRetryLimit, LongRetryLimit;
3186 #endif // SNMP_SUPPORT //
3189 #ifdef DOT11_N_SUPPORT
3190 MaxPhyMode = PHY_11N_5G;
3191 #endif // DOT11_N_SUPPORT //
3194 DBGPRINT(RT_DEBUG_TRACE, ("-->RTMPSetInformation(), 0x%08x\n", cmd&0x7FFF));
3195 switch(cmd & 0x7FFF) {
3196 case RT_OID_802_11_COUNTRY_REGION:
3197 if (wrq->u.data.length < sizeof(UCHAR))
3199 // Only avaliable when EEPROM not programming
3200 else if (!(pAdapter->CommonCfg.CountryRegion & 0x80) && !(pAdapter->CommonCfg.CountryRegionForABand & 0x80))
3205 Status = copy_from_user(&Country, wrq->u.data.pointer, wrq->u.data.length);
3206 pAdapter->CommonCfg.CountryRegion = (UCHAR)(Country & 0x000000FF);
3207 pAdapter->CommonCfg.CountryRegionForABand = (UCHAR)((Country >> 8) & 0x000000FF);
3208 TmpPhy = pAdapter->CommonCfg.PhyMode;
3209 pAdapter->CommonCfg.PhyMode = 0xff;
3210 // Build all corresponding channel information
3211 RTMPSetPhyMode(pAdapter, TmpPhy);
3212 #ifdef DOT11_N_SUPPORT
3213 SetCommonHT(pAdapter);
3214 #endif // DOT11_N_SUPPORT //
3215 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_COUNTRY_REGION (A:%d B/G:%d)\n", pAdapter->CommonCfg.CountryRegionForABand,
3216 pAdapter->CommonCfg.CountryRegion));
3219 case OID_802_11_BSSID_LIST_SCAN:
3221 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_BSSID_LIST_SCAN, TxCnt = %d \n", pAdapter->RalinkCounters.LastOneSecTotalTxCount));
3223 if (MONITOR_ON(pAdapter))
3225 DBGPRINT(RT_DEBUG_TRACE, ("!!! Driver is in Monitor Mode now !!!\n"));
3229 //Benson add 20080527, when radio off, sta don't need to scan
3230 if (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_RADIO_OFF))
3233 if (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
3235 DBGPRINT(RT_DEBUG_TRACE, ("!!! Driver is scanning now !!!\n"));
3236 pAdapter->StaCfg.bScanReqIsFromWebUI = TRUE;
3237 Status = NDIS_STATUS_SUCCESS;
3241 if (pAdapter->RalinkCounters.LastOneSecTotalTxCount > 100)
3243 DBGPRINT(RT_DEBUG_TRACE, ("!!! Link UP, ignore this set::OID_802_11_BSSID_LIST_SCAN\n"));
3244 Status = NDIS_STATUS_SUCCESS;
3245 pAdapter->StaCfg.ScanCnt = 99; // Prevent auto scan triggered by this OID
3249 if ((OPSTATUS_TEST_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED)) &&
3250 ((pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA) ||
3251 (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK) ||
3252 (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA2) ||
3253 (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK)) &&
3254 (pAdapter->StaCfg.PortSecured == WPA_802_1X_PORT_NOT_SECURED))
3256 DBGPRINT(RT_DEBUG_TRACE, ("!!! Link UP, Port Not Secured! ignore this set::OID_802_11_BSSID_LIST_SCAN\n"));
3257 Status = NDIS_STATUS_SUCCESS;
3258 pAdapter->StaCfg.ScanCnt = 99; // Prevent auto scan triggered by this OID
3263 if (pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE)
3265 RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
3266 DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
3269 // tell CNTL state machine to call NdisMSetInformationComplete() after completing
3270 // this request, because this request is initiated by NDIS.
3271 pAdapter->MlmeAux.CurrReqIsFromNdis = FALSE;
3272 // Reset allowed scan retries
3273 pAdapter->StaCfg.ScanCnt = 0;
3274 pAdapter->StaCfg.LastScanTime = Now;
3276 pAdapter->StaCfg.bScanReqIsFromWebUI = TRUE;
3277 RTMP_SET_FLAG(pAdapter, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS);
3278 MlmeEnqueue(pAdapter,
3279 MLME_CNTL_STATE_MACHINE,
3280 OID_802_11_BSSID_LIST_SCAN,
3284 Status = NDIS_STATUS_SUCCESS;
3285 StateMachineTouched = TRUE;
3287 case OID_802_11_SSID:
3288 if (wrq->u.data.length != sizeof(NDIS_802_11_SSID))
3292 PCHAR pSsidString = NULL;
3293 Status = copy_from_user(&Ssid, wrq->u.data.pointer, wrq->u.data.length);
3295 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_SSID (Len=%d,Ssid=%s)\n", Ssid.SsidLength, Ssid.Ssid));
3296 if (Ssid.SsidLength > MAX_LEN_OF_SSID)
3300 if (Ssid.SsidLength == 0)
3302 Set_SSID_Proc(pAdapter, "");
3306 pSsidString = (CHAR *) kmalloc(MAX_LEN_OF_SSID+1, MEM_ALLOC_FLAG);
3309 NdisZeroMemory(pSsidString, MAX_LEN_OF_SSID+1);
3310 NdisMoveMemory(pSsidString, Ssid.Ssid, Ssid.SsidLength);
3311 Set_SSID_Proc(pAdapter, pSsidString);
3320 case OID_802_11_BSSID:
3321 if (wrq->u.data.length != sizeof(NDIS_802_11_MAC_ADDRESS))
3325 Status = copy_from_user(&Bssid, wrq->u.data.pointer, wrq->u.data.length);
3327 // tell CNTL state machine to call NdisMSetInformationComplete() after completing
3328 // this request, because this request is initiated by NDIS.
3329 pAdapter->MlmeAux.CurrReqIsFromNdis = FALSE;
3331 // Prevent to connect AP again in STAMlmePeriodicExec
3332 pAdapter->MlmeAux.AutoReconnectSsidLen= 32;
3334 // Reset allowed scan retries
3335 pAdapter->StaCfg.ScanCnt = 0;
3337 if (pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE)
3339 RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
3340 DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
3342 MlmeEnqueue(pAdapter,
3343 MLME_CNTL_STATE_MACHINE,
3345 sizeof(NDIS_802_11_MAC_ADDRESS),
3347 Status = NDIS_STATUS_SUCCESS;
3348 StateMachineTouched = TRUE;
3350 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_BSSID %02x:%02x:%02x:%02x:%02x:%02x\n",
3351 Bssid[0], Bssid[1], Bssid[2], Bssid[3], Bssid[4], Bssid[5]));
3354 case RT_OID_802_11_RADIO:
3355 if (wrq->u.data.length != sizeof(BOOLEAN))
3359 Status = copy_from_user(&RadioState, wrq->u.data.pointer, wrq->u.data.length);
3360 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_RADIO (=%d)\n", RadioState));
3361 if (pAdapter->StaCfg.bSwRadio != RadioState)
3363 pAdapter->StaCfg.bSwRadio = RadioState;
3364 if (pAdapter->StaCfg.bRadio != (pAdapter->StaCfg.bHwRadio && pAdapter->StaCfg.bSwRadio))
3366 pAdapter->StaCfg.bRadio = (pAdapter->StaCfg.bHwRadio && pAdapter->StaCfg.bSwRadio);
3367 if (pAdapter->StaCfg.bRadio == TRUE)
3369 MlmeRadioOn(pAdapter);
3370 // Update extra information
3371 pAdapter->ExtraInfo = EXTRA_INFO_CLEAR;
3375 MlmeRadioOff(pAdapter);
3376 // Update extra information
3377 pAdapter->ExtraInfo = SW_RADIO_OFF;
3383 case RT_OID_802_11_PHY_MODE:
3384 if (wrq->u.data.length != sizeof(RT_802_11_PHY_MODE))
3388 Status = copy_from_user(&PhyMode, wrq->u.data.pointer, wrq->u.data.length);
3389 if (PhyMode <= MaxPhyMode)
3391 RTMPSetPhyMode(pAdapter, PhyMode);
3392 #ifdef DOT11_N_SUPPORT
3393 SetCommonHT(pAdapter);
3394 #endif // DOT11_N_SUPPORT //
3396 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_PHY_MODE (=%d)\n", PhyMode));
3399 case RT_OID_802_11_STA_CONFIG:
3400 if (wrq->u.data.length != sizeof(RT_802_11_STA_CONFIG))
3404 Status = copy_from_user(&StaConfig, wrq->u.data.pointer, wrq->u.data.length);
3405 pAdapter->CommonCfg.bEnableTxBurst = StaConfig.EnableTxBurst;
3406 pAdapter->CommonCfg.UseBGProtection = StaConfig.UseBGProtection;
3407 pAdapter->CommonCfg.bUseShortSlotTime = 1; // 2003-10-30 always SHORT SLOT capable
3408 if ((pAdapter->CommonCfg.PhyMode != StaConfig.AdhocMode) &&
3409 (StaConfig.AdhocMode <= MaxPhyMode))
3411 // allow dynamic change of "USE OFDM rate or not" in ADHOC mode
3412 // if setting changed, need to reset current TX rate as well as BEACON frame format
3413 if (pAdapter->StaCfg.BssType == BSS_ADHOC)
3415 pAdapter->CommonCfg.PhyMode = StaConfig.AdhocMode;
3416 RTMPSetPhyMode(pAdapter, PhyMode);
3417 MlmeUpdateTxRates(pAdapter, FALSE, 0);
3418 MakeIbssBeacon(pAdapter); // re-build BEACON frame
3419 AsicEnableIbssSync(pAdapter); // copy to on-chip memory
3422 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_SET_STA_CONFIG (Burst=%d, Protection=%ld,ShortSlot=%d\n",
3423 pAdapter->CommonCfg.bEnableTxBurst,
3424 pAdapter->CommonCfg.UseBGProtection,
3425 pAdapter->CommonCfg.bUseShortSlotTime));
3428 case OID_802_11_DESIRED_RATES:
3429 if (wrq->u.data.length != sizeof(NDIS_802_11_RATES))
3433 Status = copy_from_user(&aryRates, wrq->u.data.pointer, wrq->u.data.length);
3434 NdisZeroMemory(pAdapter->CommonCfg.DesireRate, MAX_LEN_OF_SUPPORTED_RATES);
3435 NdisMoveMemory(pAdapter->CommonCfg.DesireRate, &aryRates, sizeof(NDIS_802_11_RATES));
3436 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_DESIRED_RATES (%02x,%02x,%02x,%02x,%02x,%02x,%02x,%02x)\n",
3437 pAdapter->CommonCfg.DesireRate[0],pAdapter->CommonCfg.DesireRate[1],
3438 pAdapter->CommonCfg.DesireRate[2],pAdapter->CommonCfg.DesireRate[3],
3439 pAdapter->CommonCfg.DesireRate[4],pAdapter->CommonCfg.DesireRate[5],
3440 pAdapter->CommonCfg.DesireRate[6],pAdapter->CommonCfg.DesireRate[7] ));
3441 // Changing DesiredRate may affect the MAX TX rate we used to TX frames out
3442 MlmeUpdateTxRates(pAdapter, FALSE, 0);
3445 case RT_OID_802_11_PREAMBLE:
3446 if (wrq->u.data.length != sizeof(RT_802_11_PREAMBLE))
3450 Status = copy_from_user(&Preamble, wrq->u.data.pointer, wrq->u.data.length);
3451 if (Preamble == Rt802_11PreambleShort)
3453 pAdapter->CommonCfg.TxPreamble = Preamble;
3454 MlmeSetTxPreamble(pAdapter, Rt802_11PreambleShort);
3456 else if ((Preamble == Rt802_11PreambleLong) || (Preamble == Rt802_11PreambleAuto))
3458 // if user wants AUTO, initialize to LONG here, then change according to AP's
3459 // capability upon association.
3460 pAdapter->CommonCfg.TxPreamble = Preamble;
3461 MlmeSetTxPreamble(pAdapter, Rt802_11PreambleLong);
3468 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_PREAMBLE (=%d)\n", Preamble));
3471 case OID_802_11_WEP_STATUS:
3472 if (wrq->u.data.length != sizeof(NDIS_802_11_WEP_STATUS))
3476 Status = copy_from_user(&WepStatus, wrq->u.data.pointer, wrq->u.data.length);
3477 // Since TKIP, AES, WEP are all supported. It should not have any invalid setting
3478 if (WepStatus <= Ndis802_11Encryption3KeyAbsent)
3480 if (pAdapter->StaCfg.WepStatus != WepStatus)
3482 // Config has changed
3483 pAdapter->bConfigChanged = TRUE;
3485 pAdapter->StaCfg.WepStatus = WepStatus;
3486 pAdapter->StaCfg.OrigWepStatus = WepStatus;
3487 pAdapter->StaCfg.PairCipher = WepStatus;
3488 pAdapter->StaCfg.GroupCipher = WepStatus;
3495 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_WEP_STATUS (=%d)\n",WepStatus));
3498 case OID_802_11_AUTHENTICATION_MODE:
3499 if (wrq->u.data.length != sizeof(NDIS_802_11_AUTHENTICATION_MODE))
3503 Status = copy_from_user(&AuthMode, wrq->u.data.pointer, wrq->u.data.length);
3504 if (AuthMode > Ndis802_11AuthModeMax)
3511 if (pAdapter->StaCfg.AuthMode != AuthMode)
3513 // Config has changed
3514 pAdapter->bConfigChanged = TRUE;
3516 pAdapter->StaCfg.AuthMode = AuthMode;
3518 pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED;
3519 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_AUTHENTICATION_MODE (=%d) \n",pAdapter->StaCfg.AuthMode));
3522 case OID_802_11_INFRASTRUCTURE_MODE:
3523 if (wrq->u.data.length != sizeof(NDIS_802_11_NETWORK_INFRASTRUCTURE))
3527 Status = copy_from_user(&BssType, wrq->u.data.pointer, wrq->u.data.length);
3529 if (BssType == Ndis802_11IBSS)
3530 Set_NetworkType_Proc(pAdapter, "Adhoc");
3531 else if (BssType == Ndis802_11Infrastructure)
3532 Set_NetworkType_Proc(pAdapter, "Infra");
3533 else if (BssType == Ndis802_11Monitor)
3534 Set_NetworkType_Proc(pAdapter, "Monitor");
3538 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_INFRASTRUCTURE_MODE (unknown)\n"));
3542 case OID_802_11_REMOVE_WEP:
3543 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_WEP\n"));
3544 if (wrq->u.data.length != sizeof(NDIS_802_11_KEY_INDEX))
3550 KeyIdx = *(NDIS_802_11_KEY_INDEX *) wrq->u.data.pointer;
3552 if (KeyIdx & 0x80000000)
3554 // Should never set default bit when remove key
3559 KeyIdx = KeyIdx & 0x0fffffff;
3565 pAdapter->SharedKey[BSS0][KeyIdx].KeyLen = 0;
3566 pAdapter->SharedKey[BSS0][KeyIdx].CipherAlg = CIPHER_NONE;
3567 AsicRemoveSharedKeyEntry(pAdapter, 0, (UCHAR)KeyIdx);
3572 case RT_OID_802_11_RESET_COUNTERS:
3573 NdisZeroMemory(&pAdapter->WlanCounters, sizeof(COUNTER_802_11));
3574 NdisZeroMemory(&pAdapter->Counters8023, sizeof(COUNTER_802_3));
3575 NdisZeroMemory(&pAdapter->RalinkCounters, sizeof(COUNTER_RALINK));
3576 pAdapter->Counters8023.RxNoBuffer = 0;
3577 pAdapter->Counters8023.GoodReceives = 0;
3578 pAdapter->Counters8023.RxNoBuffer = 0;
3579 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_RESET_COUNTERS \n"));
3581 case OID_802_11_RTS_THRESHOLD:
3582 if (wrq->u.data.length != sizeof(NDIS_802_11_RTS_THRESHOLD))
3586 Status = copy_from_user(&RtsThresh, wrq->u.data.pointer, wrq->u.data.length);
3587 if (RtsThresh > MAX_RTS_THRESHOLD)
3590 pAdapter->CommonCfg.RtsThreshold = (USHORT)RtsThresh;
3592 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_RTS_THRESHOLD (=%ld)\n",RtsThresh));
3594 case OID_802_11_FRAGMENTATION_THRESHOLD:
3595 if (wrq->u.data.length != sizeof(NDIS_802_11_FRAGMENTATION_THRESHOLD))
3599 Status = copy_from_user(&FragThresh, wrq->u.data.pointer, wrq->u.data.length);
3600 pAdapter->CommonCfg.bUseZeroToDisableFragment = FALSE;
3601 if (FragThresh > MAX_FRAG_THRESHOLD || FragThresh < MIN_FRAG_THRESHOLD)
3603 if (FragThresh == 0)
3605 pAdapter->CommonCfg.FragmentThreshold = MAX_FRAG_THRESHOLD;
3606 pAdapter->CommonCfg.bUseZeroToDisableFragment = TRUE;
3612 pAdapter->CommonCfg.FragmentThreshold = (USHORT)FragThresh;
3614 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_FRAGMENTATION_THRESHOLD (=%ld) \n",FragThresh));
3616 case OID_802_11_POWER_MODE:
3617 if (wrq->u.data.length != sizeof(NDIS_802_11_POWER_MODE))
3621 Status = copy_from_user(&PowerMode, wrq->u.data.pointer, wrq->u.data.length);
3622 if (PowerMode == Ndis802_11PowerModeCAM)
3623 Set_PSMode_Proc(pAdapter, "CAM");
3624 else if (PowerMode == Ndis802_11PowerModeMAX_PSP)
3625 Set_PSMode_Proc(pAdapter, "Max_PSP");
3626 else if (PowerMode == Ndis802_11PowerModeFast_PSP)
3627 Set_PSMode_Proc(pAdapter, "Fast_PSP");
3628 else if (PowerMode == Ndis802_11PowerModeLegacy_PSP)
3629 Set_PSMode_Proc(pAdapter, "Legacy_PSP");
3633 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_POWER_MODE (=%d)\n",PowerMode));
3635 case RT_OID_802_11_TX_POWER_LEVEL_1:
3636 if (wrq->u.data.length < sizeof(ULONG))
3640 Status = copy_from_user(&PowerTemp, wrq->u.data.pointer, wrq->u.data.length);
3641 if (PowerTemp > 100)
3642 PowerTemp = 0xffffffff; // AUTO
3643 pAdapter->CommonCfg.TxPowerDefault = PowerTemp; //keep current setting.
3644 pAdapter->CommonCfg.TxPowerPercentage = pAdapter->CommonCfg.TxPowerDefault;
3645 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_TX_POWER_LEVEL_1 (=%ld)\n", pAdapter->CommonCfg.TxPowerPercentage));
3648 case OID_802_11_NETWORK_TYPE_IN_USE:
3649 if (wrq->u.data.length != sizeof(NDIS_802_11_NETWORK_TYPE))
3653 Status = copy_from_user(&NetType, wrq->u.data.pointer, wrq->u.data.length);
3655 if (NetType == Ndis802_11DS)
3656 RTMPSetPhyMode(pAdapter, PHY_11B);
3657 else if (NetType == Ndis802_11OFDM24)
3658 RTMPSetPhyMode(pAdapter, PHY_11BG_MIXED);
3659 else if (NetType == Ndis802_11OFDM5)
3660 RTMPSetPhyMode(pAdapter, PHY_11A);
3663 #ifdef DOT11_N_SUPPORT
3664 if (Status == NDIS_STATUS_SUCCESS)
3665 SetCommonHT(pAdapter);
3666 #endif // DOT11_N_SUPPORT //
3667 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_NETWORK_TYPE_IN_USE (=%d)\n",NetType));
3670 // For WPA PSK PMK key
3671 case RT_OID_802_11_ADD_WPA:
3672 pKey = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
3679 Status = copy_from_user(pKey, wrq->u.data.pointer, wrq->u.data.length);
3680 if (pKey->Length != wrq->u.data.length)
3683 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_ADD_WPA, Failed!!\n"));
3687 if ((pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPAPSK) &&
3688 (pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPA2PSK) &&
3689 (pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPANone) )
3691 Status = -EOPNOTSUPP;
3692 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_ADD_WPA, Failed!! [AuthMode != WPAPSK/WPA2PSK/WPANONE]\n"));
3694 else if ((pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK) ||
3695 (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK) ||
3696 (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPANone) ) // Only for WPA PSK mode
3698 NdisMoveMemory(pAdapter->StaCfg.PMK, &pKey->KeyMaterial, pKey->KeyLength);
3699 // Use RaConfig as PSK agent.
3700 // Start STA supplicant state machine
3701 if (pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPANone)
3702 pAdapter->StaCfg.WpaState = SS_START;
3704 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_ADD_WPA (id=0x%x, Len=%d-byte)\n", pKey->KeyIndex, pKey->KeyLength));
3708 pAdapter->StaCfg.WpaState = SS_NOTUSE;
3709 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_ADD_WPA (id=0x%x, Len=%d-byte)\n", pKey->KeyIndex, pKey->KeyLength));
3714 case OID_802_11_REMOVE_KEY:
3715 pRemoveKey = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
3716 if(pRemoveKey == NULL)
3722 Status = copy_from_user(pRemoveKey, wrq->u.data.pointer, wrq->u.data.length);
3723 if (pRemoveKey->Length != wrq->u.data.length)
3726 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_KEY, Failed!!\n"));
3730 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
3732 RTMPWPARemoveKeyProc(pAdapter, pRemoveKey);
3733 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_KEY, Remove WPA Key!!\n"));
3737 KeyIdx = pRemoveKey->KeyIndex;
3739 if (KeyIdx & 0x80000000)
3741 // Should never set default bit when remove key
3743 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_KEY, Failed!!(Should never set default bit when remove key)\n"));
3747 KeyIdx = KeyIdx & 0x0fffffff;
3751 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_KEY, Failed!!(KeyId[%d] out of range)\n", KeyIdx));
3755 pAdapter->SharedKey[BSS0][KeyIdx].KeyLen = 0;
3756 pAdapter->SharedKey[BSS0][KeyIdx].CipherAlg = CIPHER_NONE;
3757 AsicRemoveSharedKeyEntry(pAdapter, 0, (UCHAR)KeyIdx);
3758 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_KEY (id=0x%x, Len=%d-byte)\n", pRemoveKey->KeyIndex, pRemoveKey->Length));
3766 case OID_802_11_ADD_KEY:
3767 pKey = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
3773 Status = copy_from_user(pKey, wrq->u.data.pointer, wrq->u.data.length);
3774 if (pKey->Length != wrq->u.data.length)
3777 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_KEY, Failed!!\n"));
3781 RTMPAddKey(pAdapter, pKey);
3782 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_KEY (id=0x%x, Len=%d-byte)\n", pKey->KeyIndex, pKey->KeyLength));
3786 case OID_802_11_CONFIGURATION:
3787 if (wrq->u.data.length != sizeof(NDIS_802_11_CONFIGURATION))
3791 Status = copy_from_user(&Config, wrq->u.data.pointer, wrq->u.data.length);
3794 if ((pConfig->BeaconPeriod >= 20) && (pConfig->BeaconPeriod <=400))
3795 pAdapter->CommonCfg.BeaconPeriod = (USHORT) pConfig->BeaconPeriod;
3797 pAdapter->StaActive.AtimWin = (USHORT) pConfig->ATIMWindow;
3798 MAP_KHZ_TO_CHANNEL_ID(pConfig->DSConfig, pAdapter->CommonCfg.Channel);
3800 // Save the channel on MlmeAux for CntlOidRTBssidProc used.
3802 pAdapter->MlmeAux.Channel = pAdapter->CommonCfg.Channel;
3804 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_CONFIGURATION (BeacnPeriod=%ld,AtimW=%ld,Ch=%d)\n",
3805 pConfig->BeaconPeriod, pConfig->ATIMWindow, pAdapter->CommonCfg.Channel));
3806 // Config has changed
3807 pAdapter->bConfigChanged = TRUE;
3810 #ifdef DOT11_N_SUPPORT
3811 case RT_OID_802_11_SET_HT_PHYMODE:
3812 if (wrq->u.data.length != sizeof(OID_SET_HT_PHYMODE))
3816 POID_SET_HT_PHYMODE pHTPhyMode = &HT_PhyMode;
3818 Status = copy_from_user(&HT_PhyMode, wrq->u.data.pointer, wrq->u.data.length);
3819 DBGPRINT(RT_DEBUG_TRACE, ("Set::pHTPhyMode (PhyMode = %d,TransmitNo = %d, HtMode = %d, ExtOffset = %d , MCS = %d, BW = %d, STBC = %d, SHORTGI = %d) \n",
3820 pHTPhyMode->PhyMode, pHTPhyMode->TransmitNo,pHTPhyMode->HtMode,pHTPhyMode->ExtOffset,
3821 pHTPhyMode->MCS, pHTPhyMode->BW, pHTPhyMode->STBC, pHTPhyMode->SHORTGI));
3822 if (pAdapter->CommonCfg.PhyMode >= PHY_11ABGN_MIXED)
3823 RTMPSetHT(pAdapter, pHTPhyMode);
3825 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_SET_HT_PHYMODE(MCS=%d,BW=%d,SGI=%d,STBC=%d)\n",
3826 pAdapter->StaCfg.HTPhyMode.field.MCS, pAdapter->StaCfg.HTPhyMode.field.BW, pAdapter->StaCfg.HTPhyMode.field.ShortGI,
3827 pAdapter->StaCfg.HTPhyMode.field.STBC));
3829 #endif // DOT11_N_SUPPORT //
3830 case RT_OID_802_11_SET_APSD_SETTING:
3831 if (wrq->u.data.length != sizeof(ULONG))
3836 Status = copy_from_user(&apsd, wrq->u.data.pointer, wrq->u.data.length);
3838 /*-------------------------------------------------------------------
3839 |B31~B7 | B6~B5 | B4 | B3 | B2 | B1 | B0 |
3840 ---------------------------------------------------------------------
3841 | Rsvd | Max SP Len | AC_VO | AC_VI | AC_BK | AC_BE | APSD Capable |
3842 ---------------------------------------------------------------------*/
3843 pAdapter->CommonCfg.bAPSDCapable = (apsd & 0x00000001) ? TRUE : FALSE;
3844 pAdapter->CommonCfg.bAPSDAC_BE = ((apsd & 0x00000002) >> 1) ? TRUE : FALSE;
3845 pAdapter->CommonCfg.bAPSDAC_BK = ((apsd & 0x00000004) >> 2) ? TRUE : FALSE;
3846 pAdapter->CommonCfg.bAPSDAC_VI = ((apsd & 0x00000008) >> 3) ? TRUE : FALSE;
3847 pAdapter->CommonCfg.bAPSDAC_VO = ((apsd & 0x00000010) >> 4) ? TRUE : FALSE;
3848 pAdapter->CommonCfg.MaxSPLength = (UCHAR)((apsd & 0x00000060) >> 5);
3850 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,
3851 pAdapter->CommonCfg.bAPSDAC_BE, pAdapter->CommonCfg.bAPSDAC_BK, pAdapter->CommonCfg.bAPSDAC_VI, pAdapter->CommonCfg.bAPSDAC_VO, pAdapter->CommonCfg.MaxSPLength));
3855 case RT_OID_802_11_SET_APSD_PSM:
3856 if (wrq->u.data.length != sizeof(ULONG))
3860 // Driver needs to notify AP when PSM changes
3861 Status = copy_from_user(&pAdapter->CommonCfg.bAPSDForcePowerSave, wrq->u.data.pointer, wrq->u.data.length);
3862 if (pAdapter->CommonCfg.bAPSDForcePowerSave != pAdapter->StaCfg.Psm)
3864 MlmeSetPsmBit(pAdapter, pAdapter->CommonCfg.bAPSDForcePowerSave);
3865 RTMPSendNullFrame(pAdapter, pAdapter->CommonCfg.TxRate, TRUE);
3867 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_SET_APSD_PSM (bAPSDForcePowerSave:%d)\n", pAdapter->CommonCfg.bAPSDForcePowerSave));
3870 #ifdef QOS_DLS_SUPPORT
3871 case RT_OID_802_11_SET_DLS:
3872 if (wrq->u.data.length != sizeof(ULONG))
3876 BOOLEAN oldvalue = pAdapter->CommonCfg.bDLSCapable;
3877 Status = copy_from_user(&pAdapter->CommonCfg.bDLSCapable, wrq->u.data.pointer, wrq->u.data.length);
3878 if (oldvalue && !pAdapter->CommonCfg.bDLSCapable)
3881 // tear down local dls table entry
3882 for (i=0; i<MAX_NUM_OF_INIT_DLS_ENTRY; i++)
3884 if (pAdapter->StaCfg.DLSEntry[i].Valid && (pAdapter->StaCfg.DLSEntry[i].Status == DLS_FINISH))
3886 pAdapter->StaCfg.DLSEntry[i].Status = DLS_NONE;
3887 pAdapter->StaCfg.DLSEntry[i].Valid = FALSE;
3888 RTMPSendDLSTearDownFrame(pAdapter, pAdapter->StaCfg.DLSEntry[i].MacAddr);
3892 // tear down peer dls table entry
3893 for (i=MAX_NUM_OF_INIT_DLS_ENTRY; i<MAX_NUM_OF_DLS_ENTRY; i++)
3895 if (pAdapter->StaCfg.DLSEntry[i].Valid && (pAdapter->StaCfg.DLSEntry[i].Status == DLS_FINISH))
3897 pAdapter->StaCfg.DLSEntry[i].Status = DLS_NONE;
3898 pAdapter->StaCfg.DLSEntry[i].Valid = FALSE;
3899 RTMPSendDLSTearDownFrame(pAdapter, pAdapter->StaCfg.DLSEntry[i].MacAddr);
3904 DBGPRINT(RT_DEBUG_TRACE,("Set::RT_OID_802_11_SET_DLS (=%d)\n", pAdapter->CommonCfg.bDLSCapable));
3908 case RT_OID_802_11_SET_DLS_PARAM:
3909 if (wrq->u.data.length != sizeof(RT_802_11_DLS_UI))
3915 NdisZeroMemory(&Dls, sizeof(RT_802_11_DLS));
3916 RTMPMoveMemory(&Dls, wrq->u.data.pointer, sizeof(RT_802_11_DLS_UI));
3917 MlmeEnqueue(pAdapter,
3918 MLME_CNTL_STATE_MACHINE,
3919 RT_OID_802_11_SET_DLS_PARAM,
3920 sizeof(RT_802_11_DLS),
3922 DBGPRINT(RT_DEBUG_TRACE,("Set::RT_OID_802_11_SET_DLS_PARAM \n"));
3925 #endif // QOS_DLS_SUPPORT //
3926 case RT_OID_802_11_SET_WMM:
3927 if (wrq->u.data.length != sizeof(BOOLEAN))
3931 Status = copy_from_user(&pAdapter->CommonCfg.bWmmCapable, wrq->u.data.pointer, wrq->u.data.length);
3932 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_SET_WMM (=%d) \n", pAdapter->CommonCfg.bWmmCapable));
3936 case OID_802_11_DISASSOCIATE:
3938 // Set NdisRadioStateOff to TRUE, instead of called MlmeRadioOff.
3939 // Later on, NDIS_802_11_BSSID_LIST_EX->NumberOfItems should be 0
3940 // when query OID_802_11_BSSID_LIST.
3942 // TRUE: NumberOfItems will set to 0.
3943 // FALSE: NumberOfItems no change.
3945 pAdapter->CommonCfg.NdisRadioStateOff = TRUE;
3946 // Set to immediately send the media disconnect event
3947 pAdapter->MlmeAux.CurrReqIsFromNdis = TRUE;
3948 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_DISASSOCIATE \n"));
3950 if (INFRA_ON(pAdapter))
3952 if (pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE)
3954 RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
3955 DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
3958 MlmeEnqueue(pAdapter,
3959 MLME_CNTL_STATE_MACHINE,
3960 OID_802_11_DISASSOCIATE,
3964 StateMachineTouched = TRUE;
3968 #ifdef DOT11_N_SUPPORT
3969 case RT_OID_802_11_SET_IMME_BA_CAP:
3970 if (wrq->u.data.length != sizeof(OID_BACAP_STRUC))
3974 OID_BACAP_STRUC Orde ;
3975 Status = copy_from_user(&Orde, wrq->u.data.pointer, wrq->u.data.length);
3976 if (Orde.Policy > BA_NOTUSE)
3978 Status = NDIS_STATUS_INVALID_DATA;
3980 else if (Orde.Policy == BA_NOTUSE)
3982 pAdapter->CommonCfg.BACapability.field.Policy = BA_NOTUSE;
3983 pAdapter->CommonCfg.BACapability.field.MpduDensity = Orde.MpduDensity;
3984 pAdapter->CommonCfg.DesiredHtPhy.MpduDensity = Orde.MpduDensity;
3985 pAdapter->CommonCfg.DesiredHtPhy.AmsduEnable = Orde.AmsduEnable;
3986 pAdapter->CommonCfg.DesiredHtPhy.AmsduSize= Orde.AmsduSize;
3987 pAdapter->CommonCfg.DesiredHtPhy.MimoPs= Orde.MMPSmode;
3988 pAdapter->CommonCfg.BACapability.field.MMPSmode = Orde.MMPSmode;
3990 pAdapter->CommonCfg.HtCapability.HtCapInfo.MimoPs = Orde.MMPSmode;
3991 pAdapter->CommonCfg.HtCapability.HtCapInfo.AMsduSize = Orde.AmsduSize;
3992 pAdapter->CommonCfg.HtCapability.HtCapParm.MpduDensity = Orde.MpduDensity;
3996 pAdapter->CommonCfg.BACapability.field.AutoBA = Orde.AutoBA;
3997 pAdapter->CommonCfg.BACapability.field.Policy = IMMED_BA; // we only support immediate BA.
3998 pAdapter->CommonCfg.BACapability.field.MpduDensity = Orde.MpduDensity;
3999 pAdapter->CommonCfg.DesiredHtPhy.MpduDensity = Orde.MpduDensity;
4000 pAdapter->CommonCfg.DesiredHtPhy.AmsduEnable = Orde.AmsduEnable;
4001 pAdapter->CommonCfg.DesiredHtPhy.AmsduSize= Orde.AmsduSize;
4002 pAdapter->CommonCfg.DesiredHtPhy.MimoPs = Orde.MMPSmode;
4003 pAdapter->CommonCfg.BACapability.field.MMPSmode = Orde.MMPSmode;
4006 pAdapter->CommonCfg.HtCapability.HtCapInfo.MimoPs = Orde.MMPSmode;
4007 pAdapter->CommonCfg.HtCapability.HtCapInfo.AMsduSize = Orde.AmsduSize;
4008 pAdapter->CommonCfg.HtCapability.HtCapParm.MpduDensity = Orde.MpduDensity;
4010 if (pAdapter->CommonCfg.BACapability.field.RxBAWinLimit > MAX_RX_REORDERBUF)
4011 pAdapter->CommonCfg.BACapability.field.RxBAWinLimit = MAX_RX_REORDERBUF;
4015 pAdapter->CommonCfg.REGBACapability.word = pAdapter->CommonCfg.BACapability.word;
4016 DBGPRINT(RT_DEBUG_TRACE, ("Set::(Orde.AutoBA = %d) (Policy=%d)(ReBAWinLimit=%d)(TxBAWinLimit=%d)(AutoMode=%d)\n",Orde.AutoBA, pAdapter->CommonCfg.BACapability.field.Policy,
4017 pAdapter->CommonCfg.BACapability.field.RxBAWinLimit,pAdapter->CommonCfg.BACapability.field.TxBAWinLimit, pAdapter->CommonCfg.BACapability.field.AutoBA));
4018 DBGPRINT(RT_DEBUG_TRACE, ("Set::(MimoPs = %d)(AmsduEnable = %d) (AmsduSize=%d)(MpduDensity=%d)\n",pAdapter->CommonCfg.DesiredHtPhy.MimoPs, pAdapter->CommonCfg.DesiredHtPhy.AmsduEnable,
4019 pAdapter->CommonCfg.DesiredHtPhy.AmsduSize, pAdapter->CommonCfg.DesiredHtPhy.MpduDensity));
4023 case RT_OID_802_11_ADD_IMME_BA:
4024 DBGPRINT(RT_DEBUG_TRACE, (" Set :: RT_OID_802_11_ADD_IMME_BA \n"));
4025 if (wrq->u.data.length != sizeof(OID_ADD_BA_ENTRY))
4030 OID_ADD_BA_ENTRY BA;
4031 MAC_TABLE_ENTRY *pEntry;
4033 Status = copy_from_user(&BA, wrq->u.data.pointer, wrq->u.data.length);
4036 Status = NDIS_STATUS_INVALID_DATA;
4041 //BATableInsertEntry
4042 //As ad-hoc mode, BA pair is not limited to only BSSID. so add via OID.
4044 // in ad hoc mode, when adding BA pair, we should insert this entry into MACEntry too
4045 pEntry = MacTableLookup(pAdapter, BA.MACAddr);
4048 DBGPRINT(RT_DEBUG_TRACE, ("RT_OID_802_11_ADD_IMME_BA. break on no connection.----:%x:%x\n", BA.MACAddr[4], BA.MACAddr[5]));
4051 if (BA.IsRecipient == FALSE)
4053 if (pEntry->bIAmBadAtheros == TRUE)
4054 pAdapter->CommonCfg.BACapability.field.RxBAWinLimit = 0x10;
4056 BAOriSessionSetUp(pAdapter, pEntry, index, 0, 100, TRUE);
4060 //BATableInsertEntry(pAdapter, pEntry->Aid, BA.MACAddr, 0, 0xffff, BA.TID, BA.nMSDU, BA.IsRecipient);
4063 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_ADD_IMME_BA. Rec = %d. Mac = %x:%x:%x:%x:%x:%x . \n",
4064 BA.IsRecipient, BA.MACAddr[0], BA.MACAddr[1], BA.MACAddr[2], BA.MACAddr[2]
4065 , BA.MACAddr[4], BA.MACAddr[5]));
4070 case RT_OID_802_11_TEAR_IMME_BA:
4071 DBGPRINT(RT_DEBUG_TRACE, ("Set :: RT_OID_802_11_TEAR_IMME_BA \n"));
4072 if (wrq->u.data.length != sizeof(OID_ADD_BA_ENTRY))
4076 POID_ADD_BA_ENTRY pBA;
4077 MAC_TABLE_ENTRY *pEntry;
4079 pBA = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
4083 DBGPRINT(RT_DEBUG_TRACE, ("Set :: RT_OID_802_11_TEAR_IMME_BA kmalloc() can't allocate enough memory\n"));
4084 Status = NDIS_STATUS_FAILURE;
4088 Status = copy_from_user(pBA, wrq->u.data.pointer, wrq->u.data.length);
4089 DBGPRINT(RT_DEBUG_TRACE, ("Set :: RT_OID_802_11_TEAR_IMME_BA(TID=%d, bAllTid=%d)\n", pBA->TID, pBA->bAllTid));
4091 if (!pBA->bAllTid && (pBA->TID > NUM_OF_TID))
4093 Status = NDIS_STATUS_INVALID_DATA;
4097 if (pBA->IsRecipient == FALSE)
4099 pEntry = MacTableLookup(pAdapter, pBA->MACAddr);
4100 DBGPRINT(RT_DEBUG_TRACE, (" pBA->IsRecipient == FALSE\n"));
4103 DBGPRINT(RT_DEBUG_TRACE, (" pBA->pEntry\n"));
4104 BAOriSessionTearDown(pAdapter, pEntry->Aid, pBA->TID, FALSE, TRUE);
4107 DBGPRINT(RT_DEBUG_TRACE, ("Set :: Not found pEntry \n"));
4111 pEntry = MacTableLookup(pAdapter, pBA->MACAddr);
4114 BARecSessionTearDown( pAdapter, (UCHAR)pEntry->Aid, pBA->TID, TRUE);
4117 DBGPRINT(RT_DEBUG_TRACE, ("Set :: Not found pEntry \n"));
4123 #endif // DOT11_N_SUPPORT //
4125 // For WPA_SUPPLICANT to set static wep key
4126 case OID_802_11_ADD_WEP:
4127 pWepKey = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
4132 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_WEP, Failed!!\n"));
4135 Status = copy_from_user(pWepKey, wrq->u.data.pointer, wrq->u.data.length);
4139 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_WEP, Failed (length mismatch)!!\n"));
4143 KeyIdx = pWepKey->KeyIndex & 0x0fffffff;
4144 // KeyIdx must be 0 ~ 3
4148 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_WEP, Failed (KeyIdx must be smaller than 4)!!\n"));
4152 UCHAR CipherAlg = 0;
4155 // set key material and key length
4156 NdisZeroMemory(pAdapter->SharedKey[BSS0][KeyIdx].Key, 16);
4157 pAdapter->SharedKey[BSS0][KeyIdx].KeyLen = (UCHAR) pWepKey->KeyLength;
4158 NdisMoveMemory(pAdapter->SharedKey[BSS0][KeyIdx].Key, &pWepKey->KeyMaterial, pWepKey->KeyLength);
4160 switch(pWepKey->KeyLength)
4163 CipherAlg = CIPHER_WEP64;
4166 CipherAlg = CIPHER_WEP128;
4169 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_WEP, only support CIPHER_WEP64(len:5) & CIPHER_WEP128(len:13)!!\n"));
4173 pAdapter->SharedKey[BSS0][KeyIdx].CipherAlg = CipherAlg;
4175 // Default key for tx (shared key)
4176 if (pWepKey->KeyIndex & 0x80000000)
4178 #ifdef WPA_SUPPLICANT_SUPPORT
4179 // set key material and key length
4180 NdisZeroMemory(pAdapter->StaCfg.DesireSharedKey[KeyIdx].Key, 16);
4181 pAdapter->StaCfg.DesireSharedKey[KeyIdx].KeyLen = (UCHAR) pWepKey->KeyLength;
4182 NdisMoveMemory(pAdapter->StaCfg.DesireSharedKey[KeyIdx].Key, &pWepKey->KeyMaterial, pWepKey->KeyLength);
4183 pAdapter->StaCfg.DesireSharedKeyId = KeyIdx;
4184 pAdapter->StaCfg.DesireSharedKey[KeyIdx].CipherAlg = CipherAlg;
4185 #endif // WPA_SUPPLICANT_SUPPORT //
4186 pAdapter->StaCfg.DefaultKeyId = (UCHAR) KeyIdx;
4189 #ifdef WPA_SUPPLICANT_SUPPORT
4190 if ((pAdapter->StaCfg.WpaSupplicantUP != 0) &&
4191 (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA))
4193 Key = pWepKey->KeyMaterial;
4195 // Set Group key material to Asic
4196 AsicAddSharedKeyEntry(pAdapter, BSS0, KeyIdx, CipherAlg, Key, NULL, NULL);
4198 // Update WCID attribute table and IVEIV table for this group key table
4199 RTMPAddWcidAttributeEntry(pAdapter, BSS0, KeyIdx, CipherAlg, NULL);
4201 STA_PORT_SECURED(pAdapter);
4203 // Indicate Connected for GUI
4204 pAdapter->IndicateMediaState = NdisMediaStateConnected;
4206 else if (pAdapter->StaCfg.PortSecured == WPA_802_1X_PORT_SECURED)
4207 #endif // WPA_SUPPLICANT_SUPPORT
4209 Key = pAdapter->SharedKey[BSS0][KeyIdx].Key;
4211 // Set key material and cipherAlg to Asic
4212 AsicAddSharedKeyEntry(pAdapter, BSS0, KeyIdx, CipherAlg, Key, NULL, NULL);
4214 if (pWepKey->KeyIndex & 0x80000000)
4216 PMAC_TABLE_ENTRY pEntry = &pAdapter->MacTab.Content[BSSID_WCID];
4217 // Assign group key info
4218 RTMPAddWcidAttributeEntry(pAdapter, BSS0, KeyIdx, CipherAlg, NULL);
4219 // Assign pairwise key info
4220 RTMPAddWcidAttributeEntry(pAdapter, BSS0, KeyIdx, CipherAlg, pEntry);
4223 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"));
4228 #ifdef WPA_SUPPLICANT_SUPPORT
4229 case OID_SET_COUNTERMEASURES:
4230 if (wrq->u.data.length != sizeof(int))
4235 Status = copy_from_user(&enabled, wrq->u.data.pointer, wrq->u.data.length);
4237 pAdapter->StaCfg.bBlockAssoc = TRUE;
4239 // WPA MIC error should block association attempt for 60 seconds
4240 pAdapter->StaCfg.bBlockAssoc = FALSE;
4241 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_SET_COUNTERMEASURES bBlockAssoc=%s\n", pAdapter->StaCfg.bBlockAssoc ? "TRUE":"FALSE"));
4244 case RT_OID_WPA_SUPPLICANT_SUPPORT:
4245 if (wrq->u.data.length != sizeof(UCHAR))
4249 Status = copy_from_user(&wpa_supplicant_enable, wrq->u.data.pointer, wrq->u.data.length);
4250 pAdapter->StaCfg.WpaSupplicantUP = wpa_supplicant_enable;
4251 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_WPA_SUPPLICANT_SUPPORT (=%d)\n", pAdapter->StaCfg.WpaSupplicantUP));
4254 case OID_802_11_DEAUTHENTICATION:
4255 if (wrq->u.data.length != sizeof(MLME_DEAUTH_REQ_STRUCT))
4259 MLME_DEAUTH_REQ_STRUCT *pInfo;
4260 MLME_QUEUE_ELEM *MsgElem = (MLME_QUEUE_ELEM *) kmalloc(sizeof(MLME_QUEUE_ELEM), MEM_ALLOC_FLAG);
4262 pInfo = (MLME_DEAUTH_REQ_STRUCT *) MsgElem->Msg;
4263 Status = copy_from_user(pInfo, wrq->u.data.pointer, wrq->u.data.length);
4264 MlmeDeauthReqAction(pAdapter, MsgElem);
4267 if (INFRA_ON(pAdapter))
4269 LinkDown(pAdapter, FALSE);
4270 pAdapter->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
4272 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_DEAUTHENTICATION (Reason=%d)\n", pInfo->Reason));
4275 case OID_802_11_DROP_UNENCRYPTED:
4276 if (wrq->u.data.length != sizeof(int))
4281 Status = copy_from_user(&enabled, wrq->u.data.pointer, wrq->u.data.length);
4283 pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED;
4285 pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
4286 NdisAcquireSpinLock(&pAdapter->MacTabLock);
4287 pAdapter->MacTab.Content[BSSID_WCID].PortSecured = pAdapter->StaCfg.PortSecured;
4288 NdisReleaseSpinLock(&pAdapter->MacTabLock);
4289 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_DROP_UNENCRYPTED (=%d)\n", enabled));
4292 case OID_802_11_SET_IEEE8021X:
4293 if (wrq->u.data.length != sizeof(BOOLEAN))
4297 Status = copy_from_user(&IEEE8021xState, wrq->u.data.pointer, wrq->u.data.length);
4298 pAdapter->StaCfg.IEEE8021X = IEEE8021xState;
4299 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_SET_IEEE8021X (=%d)\n", IEEE8021xState));
4302 case OID_802_11_SET_IEEE8021X_REQUIRE_KEY:
4303 if (wrq->u.data.length != sizeof(BOOLEAN))
4307 Status = copy_from_user(&IEEE8021x_required_keys, wrq->u.data.pointer, wrq->u.data.length);
4308 pAdapter->StaCfg.IEEE8021x_required_keys = IEEE8021x_required_keys;
4309 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_SET_IEEE8021X_REQUIRE_KEY (%d)\n", IEEE8021x_required_keys));
4312 case OID_802_11_PMKID:
4313 pPmkId = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
4315 if(pPmkId == NULL) {
4319 Status = copy_from_user(pPmkId, wrq->u.data.pointer, wrq->u.data.length);
4321 // check the PMKID information
4322 if (pPmkId->BSSIDInfoCount == 0)
4323 NdisZeroMemory(pAdapter->StaCfg.SavedPMK, sizeof(BSSID_INFO)*PMKID_NO);
4326 PBSSID_INFO pBssIdInfo;
4330 for (BssIdx = 0; BssIdx < pPmkId->BSSIDInfoCount; BssIdx++)
4332 // point to the indexed BSSID_INFO structure
4333 pBssIdInfo = (PBSSID_INFO) ((PUCHAR) pPmkId + 2 * sizeof(UINT) + BssIdx * sizeof(BSSID_INFO));
4334 // Find the entry in the saved data base.
4335 for (CachedIdx = 0; CachedIdx < pAdapter->StaCfg.SavedPMKNum; CachedIdx++)
4337 // compare the BSSID
4338 if (NdisEqualMemory(pBssIdInfo->BSSID, pAdapter->StaCfg.SavedPMK[CachedIdx].BSSID, sizeof(NDIS_802_11_MAC_ADDRESS)))
4342 // Found, replace it
4343 if (CachedIdx < PMKID_NO)
4345 DBGPRINT(RT_DEBUG_OFF, ("Update OID_802_11_PMKID, idx = %d\n", CachedIdx));
4346 NdisMoveMemory(&pAdapter->StaCfg.SavedPMK[CachedIdx], pBssIdInfo, sizeof(BSSID_INFO));
4347 pAdapter->StaCfg.SavedPMKNum++;
4349 // Not found, replace the last one
4352 // Randomly replace one
4353 CachedIdx = (pBssIdInfo->BSSID[5] % PMKID_NO);
4354 DBGPRINT(RT_DEBUG_OFF, ("Update OID_802_11_PMKID, idx = %d\n", CachedIdx));
4355 NdisMoveMemory(&pAdapter->StaCfg.SavedPMK[CachedIdx], pBssIdInfo, sizeof(BSSID_INFO));
4362 #endif // WPA_SUPPLICANT_SUPPORT //
4367 case OID_802_11_SHORTRETRYLIMIT:
4368 if (wrq->u.data.length != sizeof(ULONG))
4372 Status = copy_from_user(&ShortRetryLimit, wrq->u.data.pointer, wrq->u.data.length);
4373 RTMP_IO_READ32(pAdapter, TX_RTY_CFG, &tx_rty_cfg.word);
4374 tx_rty_cfg.field.ShortRtyLimit = ShortRetryLimit;
4375 RTMP_IO_WRITE32(pAdapter, TX_RTY_CFG, tx_rty_cfg.word);
4376 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_SHORTRETRYLIMIT (tx_rty_cfg.field.ShortRetryLimit=%d, ShortRetryLimit=%ld)\n", tx_rty_cfg.field.ShortRtyLimit, ShortRetryLimit));
4380 case OID_802_11_LONGRETRYLIMIT:
4381 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_LONGRETRYLIMIT \n"));
4382 if (wrq->u.data.length != sizeof(ULONG))
4386 Status = copy_from_user(&LongRetryLimit, wrq->u.data.pointer, wrq->u.data.length);
4387 RTMP_IO_READ32(pAdapter, TX_RTY_CFG, &tx_rty_cfg.word);
4388 tx_rty_cfg.field.LongRtyLimit = LongRetryLimit;
4389 RTMP_IO_WRITE32(pAdapter, TX_RTY_CFG, tx_rty_cfg.word);
4390 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_LONGRETRYLIMIT (tx_rty_cfg.field.LongRetryLimit= %d,LongRetryLimit=%ld)\n", tx_rty_cfg.field.LongRtyLimit, LongRetryLimit));
4394 case OID_802_11_WEPDEFAULTKEYVALUE:
4395 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_WEPDEFAULTKEYVALUE\n"));
4396 pKey = kmalloc(wrq->u.data.length, GFP_KERNEL);
4397 Status = copy_from_user(pKey, wrq->u.data.pointer, wrq->u.data.length);
4400 if ( pKey->Length != wrq->u.data.length)
4403 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_WEPDEFAULTKEYVALUE, Failed!!\n"));
4405 KeyIdx = pKey->KeyIndex & 0x0fffffff;
4406 DBGPRINT(RT_DEBUG_TRACE,("pKey->KeyIndex =%d, pKey->KeyLength=%d\n", pKey->KeyIndex, pKey->KeyLength));
4408 // it is a shared key
4413 pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].KeyLen = (UCHAR) pKey->KeyLength;
4414 NdisMoveMemory(&pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].Key, &pKey->KeyMaterial, pKey->KeyLength);
4415 if (pKey->KeyIndex & 0x80000000)
4417 // Default key for tx (shared key)
4418 pAdapter->StaCfg.DefaultKeyId = (UCHAR) KeyIdx;
4420 //RestartAPIsRequired = TRUE;
4425 case OID_802_11_WEPDEFAULTKEYID:
4426 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_WEPDEFAULTKEYID \n"));
4428 if (wrq->u.data.length != sizeof(UCHAR))
4431 Status = copy_from_user(&pAdapter->StaCfg.DefaultKeyId, wrq->u.data.pointer, wrq->u.data.length);
4436 case OID_802_11_CURRENTCHANNEL:
4437 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_CURRENTCHANNEL \n"));
4438 if (wrq->u.data.length != sizeof(UCHAR))
4442 Status = copy_from_user(&ctmp, wrq->u.data.pointer, wrq->u.data.length);
4443 sprintf(&ctmp,"%d", ctmp);
4444 Set_Channel_Proc(pAdapter, &ctmp);
4452 DBGPRINT(RT_DEBUG_TRACE, ("Set::unknown IOCTL's subcmd = 0x%08x\n", cmd));
4453 Status = -EOPNOTSUPP;
4461 INT RTMPQueryInformation(
4462 IN PRTMP_ADAPTER pAdapter,
4463 IN OUT struct ifreq *rq,
4466 struct iwreq *wrq = (struct iwreq *) rq;
4467 NDIS_802_11_BSSID_LIST_EX *pBssidList = NULL;
4468 PNDIS_WLAN_BSSID_EX pBss;
4469 NDIS_802_11_SSID Ssid;
4470 NDIS_802_11_CONFIGURATION *pConfiguration = NULL;
4471 RT_802_11_LINK_STATUS *pLinkStatus = NULL;
4472 RT_802_11_STA_CONFIG *pStaConfig = NULL;
4473 NDIS_802_11_STATISTICS *pStatistics = NULL;
4474 NDIS_802_11_RTS_THRESHOLD RtsThresh;
4475 NDIS_802_11_FRAGMENTATION_THRESHOLD FragThresh;
4476 NDIS_802_11_POWER_MODE PowerMode;
4477 NDIS_802_11_NETWORK_INFRASTRUCTURE BssType;
4478 RT_802_11_PREAMBLE PreamType;
4479 NDIS_802_11_AUTHENTICATION_MODE AuthMode;
4480 NDIS_802_11_WEP_STATUS WepStatus;
4481 NDIS_MEDIA_STATE MediaState;
4482 ULONG BssBufSize, ulInfo=0, NetworkTypeList[4], apsd = 0;
4484 PUCHAR pBuf = NULL, pPtr;
4485 INT Status = NDIS_STATUS_SUCCESS;
4486 UINT we_version_compiled;
4487 UCHAR i, Padding = 0;
4489 UCHAR driverVersion[8];
4490 OID_SET_HT_PHYMODE *pHTPhyMode = NULL;
4495 DefaultKeyIdxValue *pKeyIdxValue;
4497 TX_RTY_CFG_STRUC tx_rty_cfg;
4498 ULONG ShortRetryLimit, LongRetryLimit;
4504 case RT_OID_DEVICE_NAME:
4505 wrq->u.data.length = sizeof(STA_NIC_DEVICE_NAME);
4506 Status = copy_to_user(wrq->u.data.pointer, STA_NIC_DEVICE_NAME, wrq->u.data.length);
4508 case RT_OID_VERSION_INFO:
4509 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_VERSION_INFO \n"));
4510 wrq->u.data.length = 8*sizeof(UCHAR);
4511 sprintf(&driverVersion[0], "%s", STA_DRIVER_VERSION);
4512 driverVersion[7] = '\0';
4513 if (copy_to_user(wrq->u.data.pointer, &driverVersion, wrq->u.data.length))
4518 case OID_802_11_BSSID_LIST:
4519 if (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
4522 * Still scanning, indicate the caller should try again.
4524 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_BSSID_LIST (Still scanning)\n"));
4527 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_BSSID_LIST (%d BSS returned)\n",pAdapter->ScanTab.BssNr));
4528 pAdapter->StaCfg.bScanReqIsFromWebUI = FALSE;
4529 // Claculate total buffer size required
4530 BssBufSize = sizeof(ULONG);
4532 for (i = 0; i < pAdapter->ScanTab.BssNr; i++)
4534 // Align pointer to 4 bytes boundary.
4535 //Padding = 4 - (pAdapter->ScanTab.BssEntry[i].VarIELen & 0x0003);
4538 BssBufSize += (sizeof(NDIS_WLAN_BSSID_EX) - 1 + sizeof(NDIS_802_11_FIXED_IEs) + pAdapter->ScanTab.BssEntry[i].VarIELen + Padding);
4541 // For safety issue, we add 256 bytes just in case
4543 // Allocate the same size as passed from higher layer
4544 pBuf = kmalloc(BssBufSize, MEM_ALLOC_FLAG);
4550 // Init 802_11_BSSID_LIST_EX structure
4551 NdisZeroMemory(pBuf, BssBufSize);
4552 pBssidList = (PNDIS_802_11_BSSID_LIST_EX) pBuf;
4553 pBssidList->NumberOfItems = pAdapter->ScanTab.BssNr;
4555 // Calculate total buffer length
4556 BssLen = 4; // Consist of NumberOfItems
4557 // Point to start of NDIS_WLAN_BSSID_EX
4558 // pPtr = pBuf + sizeof(ULONG);
4559 pPtr = (PUCHAR) &pBssidList->Bssid[0];
4560 for (i = 0; i < pAdapter->ScanTab.BssNr; i++)
4562 pBss = (PNDIS_WLAN_BSSID_EX) pPtr;
4563 NdisMoveMemory(&pBss->MacAddress, &pAdapter->ScanTab.BssEntry[i].Bssid, MAC_ADDR_LEN);
4564 if ((pAdapter->ScanTab.BssEntry[i].Hidden == 1) && (pAdapter->StaCfg.bShowHiddenSSID == FALSE))
4567 // We must return this SSID during 4way handshaking, otherwise Aegis will failed to parse WPA infomation
4568 // and then failed to send EAPOl farame.
4570 if ((pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA) && (pAdapter->StaCfg.PortSecured != WPA_802_1X_PORT_SECURED))
4572 pBss->Ssid.SsidLength = pAdapter->ScanTab.BssEntry[i].SsidLen;
4573 NdisMoveMemory(pBss->Ssid.Ssid, pAdapter->ScanTab.BssEntry[i].Ssid, pAdapter->ScanTab.BssEntry[i].SsidLen);
4576 pBss->Ssid.SsidLength = 0;
4580 pBss->Ssid.SsidLength = pAdapter->ScanTab.BssEntry[i].SsidLen;
4581 NdisMoveMemory(pBss->Ssid.Ssid, pAdapter->ScanTab.BssEntry[i].Ssid, pAdapter->ScanTab.BssEntry[i].SsidLen);
4583 pBss->Privacy = pAdapter->ScanTab.BssEntry[i].Privacy;
4584 pBss->Rssi = pAdapter->ScanTab.BssEntry[i].Rssi - pAdapter->BbpRssiToDbmDelta;
4585 pBss->NetworkTypeInUse = NetworkTypeInUseSanity(&pAdapter->ScanTab.BssEntry[i]);
4586 pBss->Configuration.Length = sizeof(NDIS_802_11_CONFIGURATION);
4587 pBss->Configuration.BeaconPeriod = pAdapter->ScanTab.BssEntry[i].BeaconPeriod;
4588 pBss->Configuration.ATIMWindow = pAdapter->ScanTab.BssEntry[i].AtimWin;
4590 MAP_CHANNEL_ID_TO_KHZ(pAdapter->ScanTab.BssEntry[i].Channel, pBss->Configuration.DSConfig);
4592 if (pAdapter->ScanTab.BssEntry[i].BssType == BSS_INFRA)
4593 pBss->InfrastructureMode = Ndis802_11Infrastructure;
4595 pBss->InfrastructureMode = Ndis802_11IBSS;
4597 NdisMoveMemory(pBss->SupportedRates, pAdapter->ScanTab.BssEntry[i].SupRate, pAdapter->ScanTab.BssEntry[i].SupRateLen);
4598 NdisMoveMemory(pBss->SupportedRates + pAdapter->ScanTab.BssEntry[i].SupRateLen,
4599 pAdapter->ScanTab.BssEntry[i].ExtRate,
4600 pAdapter->ScanTab.BssEntry[i].ExtRateLen);
4602 if (pAdapter->ScanTab.BssEntry[i].VarIELen == 0)
4604 pBss->IELength = sizeof(NDIS_802_11_FIXED_IEs);
4605 NdisMoveMemory(pBss->IEs, &pAdapter->ScanTab.BssEntry[i].FixIEs, sizeof(NDIS_802_11_FIXED_IEs));
4606 pPtr = pPtr + sizeof(NDIS_WLAN_BSSID_EX) - 1 + sizeof(NDIS_802_11_FIXED_IEs);
4610 pBss->IELength = (ULONG)(sizeof(NDIS_802_11_FIXED_IEs) + pAdapter->ScanTab.BssEntry[i].VarIELen);
4611 pPtr = pPtr + sizeof(NDIS_WLAN_BSSID_EX) - 1 + sizeof(NDIS_802_11_FIXED_IEs);
4612 NdisMoveMemory(pBss->IEs, &pAdapter->ScanTab.BssEntry[i].FixIEs, sizeof(NDIS_802_11_FIXED_IEs));
4613 NdisMoveMemory(pBss->IEs + sizeof(NDIS_802_11_FIXED_IEs), pAdapter->ScanTab.BssEntry[i].VarIEs, pAdapter->ScanTab.BssEntry[i].VarIELen);
4614 pPtr += pAdapter->ScanTab.BssEntry[i].VarIELen;
4616 pBss->Length = (ULONG)(sizeof(NDIS_WLAN_BSSID_EX) - 1 + sizeof(NDIS_802_11_FIXED_IEs) + pAdapter->ScanTab.BssEntry[i].VarIELen + Padding);
4618 #if WIRELESS_EXT < 17
4619 if ((BssLen + pBss->Length) < wrq->u.data.length)
4620 BssLen += pBss->Length;
4623 pBssidList->NumberOfItems = i;
4627 BssLen += pBss->Length;
4631 #if WIRELESS_EXT < 17
4632 wrq->u.data.length = BssLen;
4634 if (BssLen > wrq->u.data.length)
4640 wrq->u.data.length = BssLen;
4642 Status = copy_to_user(wrq->u.data.pointer, pBssidList, BssLen);
4645 case OID_802_3_CURRENT_ADDRESS:
4646 wrq->u.data.length = MAC_ADDR_LEN;
4647 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CurrentAddress, wrq->u.data.length);
4649 case OID_GEN_MEDIA_CONNECT_STATUS:
4650 if (pAdapter->IndicateMediaState == NdisMediaStateConnected)
4651 MediaState = NdisMediaStateConnected;
4653 MediaState = NdisMediaStateDisconnected;
4655 wrq->u.data.length = sizeof(NDIS_MEDIA_STATE);
4656 Status = copy_to_user(wrq->u.data.pointer, &MediaState, wrq->u.data.length);
4658 case OID_802_11_BSSID:
4659 if (INFRA_ON(pAdapter) || ADHOC_ON(pAdapter))
4661 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.Bssid, sizeof(NDIS_802_11_MAC_ADDRESS));
4666 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_BSSID(=EMPTY)\n"));
4670 case OID_802_11_SSID:
4671 NdisZeroMemory(&Ssid, sizeof(NDIS_802_11_SSID));
4672 NdisZeroMemory(Ssid.Ssid, MAX_LEN_OF_SSID);
4673 Ssid.SsidLength = pAdapter->CommonCfg.SsidLen;
4674 memcpy(Ssid.Ssid, pAdapter->CommonCfg.Ssid, Ssid.SsidLength);
4675 wrq->u.data.length = sizeof(NDIS_802_11_SSID);
4676 Status = copy_to_user(wrq->u.data.pointer, &Ssid, wrq->u.data.length);
4677 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_SSID (Len=%d, ssid=%s)\n", Ssid.SsidLength,Ssid.Ssid));
4679 case RT_OID_802_11_QUERY_LINK_STATUS:
4680 pLinkStatus = (RT_802_11_LINK_STATUS *) kmalloc(sizeof(RT_802_11_LINK_STATUS), MEM_ALLOC_FLAG);
4683 pLinkStatus->CurrTxRate = RateIdTo500Kbps[pAdapter->CommonCfg.TxRate]; // unit : 500 kbps
4684 pLinkStatus->ChannelQuality = pAdapter->Mlme.ChannelQuality;
4685 pLinkStatus->RxByteCount = pAdapter->RalinkCounters.ReceivedByteCount;
4686 pLinkStatus->TxByteCount = pAdapter->RalinkCounters.TransmittedByteCount;
4687 pLinkStatus->CentralChannel = pAdapter->CommonCfg.CentralChannel;
4688 wrq->u.data.length = sizeof(RT_802_11_LINK_STATUS);
4689 Status = copy_to_user(wrq->u.data.pointer, pLinkStatus, wrq->u.data.length);
4691 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_LINK_STATUS\n"));
4695 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_LINK_STATUS(kmalloc failed)\n"));
4699 case OID_802_11_CONFIGURATION:
4700 pConfiguration = (NDIS_802_11_CONFIGURATION *) kmalloc(sizeof(NDIS_802_11_CONFIGURATION), MEM_ALLOC_FLAG);
4703 pConfiguration->Length = sizeof(NDIS_802_11_CONFIGURATION);
4704 pConfiguration->BeaconPeriod = pAdapter->CommonCfg.BeaconPeriod;
4705 pConfiguration->ATIMWindow = pAdapter->StaActive.AtimWin;
4706 MAP_CHANNEL_ID_TO_KHZ(pAdapter->CommonCfg.Channel, pConfiguration->DSConfig);
4707 wrq->u.data.length = sizeof(NDIS_802_11_CONFIGURATION);
4708 Status = copy_to_user(wrq->u.data.pointer, pConfiguration, wrq->u.data.length);
4709 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_CONFIGURATION(BeaconPeriod=%ld,AtimW=%ld,Channel=%d) \n",
4710 pConfiguration->BeaconPeriod, pConfiguration->ATIMWindow, pAdapter->CommonCfg.Channel));
4711 kfree(pConfiguration);
4715 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_CONFIGURATION(kmalloc failed)\n"));
4719 case RT_OID_802_11_SNR_0:
4720 if ((pAdapter->StaCfg.LastSNR0 > 0))
4722 ulInfo = ((0xeb - pAdapter->StaCfg.LastSNR0) * 3) / 16 ;
4723 wrq->u.data.length = sizeof(ulInfo);
4724 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4725 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_SNR_0(0x=%lx)\n", ulInfo));
4730 case RT_OID_802_11_SNR_1:
4731 if ((pAdapter->Antenna.field.RxPath > 1) &&
4732 (pAdapter->StaCfg.LastSNR1 > 0))
4734 ulInfo = ((0xeb - pAdapter->StaCfg.LastSNR1) * 3) / 16 ;
4735 wrq->u.data.length = sizeof(ulInfo);
4736 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4737 DBGPRINT(RT_DEBUG_TRACE,("Query::RT_OID_802_11_SNR_1(0x=%lx)\n",ulInfo));
4741 DBGPRINT(RT_DEBUG_TRACE,("Query::RT_OID_802_11_SNR_1(pAdapter->StaCfg.LastSNR1=%d)\n",pAdapter->StaCfg.LastSNR1));
4743 case OID_802_11_RSSI_TRIGGER:
4744 ulInfo = pAdapter->StaCfg.RssiSample.LastRssi0 - pAdapter->BbpRssiToDbmDelta;
4745 wrq->u.data.length = sizeof(ulInfo);
4746 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4747 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_RSSI_TRIGGER(=%ld)\n", ulInfo));
4749 case OID_802_11_RSSI:
4750 case RT_OID_802_11_RSSI:
4751 ulInfo = pAdapter->StaCfg.RssiSample.LastRssi0;
4752 wrq->u.data.length = sizeof(ulInfo);
4753 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4755 case RT_OID_802_11_RSSI_1:
4756 ulInfo = pAdapter->StaCfg.RssiSample.LastRssi1;
4757 wrq->u.data.length = sizeof(ulInfo);
4758 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4760 case RT_OID_802_11_RSSI_2:
4761 ulInfo = pAdapter->StaCfg.RssiSample.LastRssi2;
4762 wrq->u.data.length = sizeof(ulInfo);
4763 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4765 case OID_802_11_STATISTICS:
4766 pStatistics = (NDIS_802_11_STATISTICS *) kmalloc(sizeof(NDIS_802_11_STATISTICS), MEM_ALLOC_FLAG);
4769 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_STATISTICS \n"));
4770 // add the most up-to-date h/w raw counters into software counters
4771 NICUpdateRawCounters(pAdapter);
4773 // Sanity check for calculation of sucessful count
4774 if (pAdapter->WlanCounters.TransmittedFragmentCount.QuadPart < pAdapter->WlanCounters.RetryCount.QuadPart)
4775 pAdapter->WlanCounters.TransmittedFragmentCount.QuadPart = pAdapter->WlanCounters.RetryCount.QuadPart;
4777 pStatistics->TransmittedFragmentCount.QuadPart = pAdapter->WlanCounters.TransmittedFragmentCount.QuadPart;
4778 pStatistics->MulticastTransmittedFrameCount.QuadPart = pAdapter->WlanCounters.MulticastTransmittedFrameCount.QuadPart;
4779 pStatistics->FailedCount.QuadPart = pAdapter->WlanCounters.FailedCount.QuadPart;
4780 pStatistics->RetryCount.QuadPart = pAdapter->WlanCounters.RetryCount.QuadPart;
4781 pStatistics->MultipleRetryCount.QuadPart = pAdapter->WlanCounters.MultipleRetryCount.QuadPart;
4782 pStatistics->RTSSuccessCount.QuadPart = pAdapter->WlanCounters.RTSSuccessCount.QuadPart;
4783 pStatistics->RTSFailureCount.QuadPart = pAdapter->WlanCounters.RTSFailureCount.QuadPart;
4784 pStatistics->ACKFailureCount.QuadPart = pAdapter->WlanCounters.ACKFailureCount.QuadPart;
4785 pStatistics->FrameDuplicateCount.QuadPart = pAdapter->WlanCounters.FrameDuplicateCount.QuadPart;
4786 pStatistics->ReceivedFragmentCount.QuadPart = pAdapter->WlanCounters.ReceivedFragmentCount.QuadPart;
4787 pStatistics->MulticastReceivedFrameCount.QuadPart = pAdapter->WlanCounters.MulticastReceivedFrameCount.QuadPart;
4789 pStatistics->FCSErrorCount = pAdapter->RalinkCounters.RealFcsErrCount;
4791 pStatistics->FCSErrorCount.QuadPart = pAdapter->WlanCounters.FCSErrorCount.QuadPart;
4792 pStatistics->FrameDuplicateCount.u.LowPart = pAdapter->WlanCounters.FrameDuplicateCount.u.LowPart / 100;
4794 wrq->u.data.length = sizeof(NDIS_802_11_STATISTICS);
4795 Status = copy_to_user(wrq->u.data.pointer, pStatistics, wrq->u.data.length);
4800 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_STATISTICS(kmalloc failed)\n"));
4804 case OID_GEN_RCV_OK:
4805 ulInfo = pAdapter->Counters8023.GoodReceives;
4806 wrq->u.data.length = sizeof(ulInfo);
4807 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4809 case OID_GEN_RCV_NO_BUFFER:
4810 ulInfo = pAdapter->Counters8023.RxNoBuffer;
4811 wrq->u.data.length = sizeof(ulInfo);
4812 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4814 case RT_OID_802_11_PHY_MODE:
4815 ulInfo = (ULONG)pAdapter->CommonCfg.PhyMode;
4816 wrq->u.data.length = sizeof(ulInfo);
4817 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4818 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_PHY_MODE (=%ld)\n", ulInfo));
4820 case RT_OID_802_11_STA_CONFIG:
4821 pStaConfig = (RT_802_11_STA_CONFIG *) kmalloc(sizeof(RT_802_11_STA_CONFIG), MEM_ALLOC_FLAG);
4824 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_STA_CONFIG\n"));
4825 pStaConfig->EnableTxBurst = pAdapter->CommonCfg.bEnableTxBurst;
4826 pStaConfig->EnableTurboRate = 0;
4827 pStaConfig->UseBGProtection = pAdapter->CommonCfg.UseBGProtection;
4828 pStaConfig->UseShortSlotTime = pAdapter->CommonCfg.bUseShortSlotTime;
4829 //pStaConfig->AdhocMode = pAdapter->StaCfg.AdhocMode;
4830 pStaConfig->HwRadioStatus = (pAdapter->StaCfg.bHwRadio == TRUE) ? 1 : 0;
4831 pStaConfig->Rsv1 = 0;
4832 pStaConfig->SystemErrorBitmap = pAdapter->SystemErrorBitmap;
4833 wrq->u.data.length = sizeof(RT_802_11_STA_CONFIG);
4834 Status = copy_to_user(wrq->u.data.pointer, pStaConfig, wrq->u.data.length);
4839 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_STA_CONFIG(kmalloc failed)\n"));
4843 case OID_802_11_RTS_THRESHOLD:
4844 RtsThresh = pAdapter->CommonCfg.RtsThreshold;
4845 wrq->u.data.length = sizeof(RtsThresh);
4846 Status = copy_to_user(wrq->u.data.pointer, &RtsThresh, wrq->u.data.length);
4847 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_RTS_THRESHOLD(=%ld)\n", RtsThresh));
4849 case OID_802_11_FRAGMENTATION_THRESHOLD:
4850 FragThresh = pAdapter->CommonCfg.FragmentThreshold;
4851 if (pAdapter->CommonCfg.bUseZeroToDisableFragment == TRUE)
4853 wrq->u.data.length = sizeof(FragThresh);
4854 Status = copy_to_user(wrq->u.data.pointer, &FragThresh, wrq->u.data.length);
4855 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_FRAGMENTATION_THRESHOLD(=%ld)\n", FragThresh));
4857 case OID_802_11_POWER_MODE:
4858 PowerMode = pAdapter->StaCfg.WindowsPowerMode;
4859 wrq->u.data.length = sizeof(PowerMode);
4860 Status = copy_to_user(wrq->u.data.pointer, &PowerMode, wrq->u.data.length);
4861 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_POWER_MODE(=%d)\n", PowerMode));
4863 case RT_OID_802_11_RADIO:
4864 RadioState = (BOOLEAN) pAdapter->StaCfg.bSwRadio;
4865 wrq->u.data.length = sizeof(RadioState);
4866 Status = copy_to_user(wrq->u.data.pointer, &RadioState, wrq->u.data.length);
4867 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_RADIO (=%d)\n", RadioState));
4869 case OID_802_11_INFRASTRUCTURE_MODE:
4870 if (pAdapter->StaCfg.BssType == BSS_ADHOC)
4871 BssType = Ndis802_11IBSS;
4872 else if (pAdapter->StaCfg.BssType == BSS_INFRA)
4873 BssType = Ndis802_11Infrastructure;
4874 else if (pAdapter->StaCfg.BssType == BSS_MONITOR)
4875 BssType = Ndis802_11Monitor;
4877 BssType = Ndis802_11AutoUnknown;
4879 wrq->u.data.length = sizeof(BssType);
4880 Status = copy_to_user(wrq->u.data.pointer, &BssType, wrq->u.data.length);
4881 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_INFRASTRUCTURE_MODE(=%d)\n", BssType));
4883 case RT_OID_802_11_PREAMBLE:
4884 PreamType = pAdapter->CommonCfg.TxPreamble;
4885 wrq->u.data.length = sizeof(PreamType);
4886 Status = copy_to_user(wrq->u.data.pointer, &PreamType, wrq->u.data.length);
4887 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_PREAMBLE(=%d)\n", PreamType));
4889 case OID_802_11_AUTHENTICATION_MODE:
4890 AuthMode = pAdapter->StaCfg.AuthMode;
4891 wrq->u.data.length = sizeof(AuthMode);
4892 Status = copy_to_user(wrq->u.data.pointer, &AuthMode, wrq->u.data.length);
4893 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_AUTHENTICATION_MODE(=%d)\n", AuthMode));
4895 case OID_802_11_WEP_STATUS:
4896 WepStatus = pAdapter->StaCfg.WepStatus;
4897 wrq->u.data.length = sizeof(WepStatus);
4898 Status = copy_to_user(wrq->u.data.pointer, &WepStatus, wrq->u.data.length);
4899 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_WEP_STATUS(=%d)\n", WepStatus));
4901 case OID_802_11_TX_POWER_LEVEL:
4902 wrq->u.data.length = sizeof(ULONG);
4903 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.TxPower, wrq->u.data.length);
4904 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_TX_POWER_LEVEL %x\n",pAdapter->CommonCfg.TxPower));
4906 case RT_OID_802_11_TX_POWER_LEVEL_1:
4907 wrq->u.data.length = sizeof(ULONG);
4908 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.TxPowerPercentage, wrq->u.data.length);
4909 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_TX_POWER_LEVEL_1 (=%ld)\n", pAdapter->CommonCfg.TxPowerPercentage));
4911 case OID_802_11_NETWORK_TYPES_SUPPORTED:
4912 if ((pAdapter->RfIcType == RFIC_2850) || (pAdapter->RfIcType == RFIC_2750))
4914 NetworkTypeList[0] = 3; // NumberOfItems = 3
4915 NetworkTypeList[1] = Ndis802_11DS; // NetworkType[1] = 11b
4916 NetworkTypeList[2] = Ndis802_11OFDM24; // NetworkType[2] = 11g
4917 NetworkTypeList[3] = Ndis802_11OFDM5; // NetworkType[3] = 11a
4918 wrq->u.data.length = 16;
4919 Status = copy_to_user(wrq->u.data.pointer, &NetworkTypeList[0], wrq->u.data.length);
4923 NetworkTypeList[0] = 2; // NumberOfItems = 2
4924 NetworkTypeList[1] = Ndis802_11DS; // NetworkType[1] = 11b
4925 NetworkTypeList[2] = Ndis802_11OFDM24; // NetworkType[2] = 11g
4926 wrq->u.data.length = 12;
4927 Status = copy_to_user(wrq->u.data.pointer, &NetworkTypeList[0], wrq->u.data.length);
4929 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_NETWORK_TYPES_SUPPORTED\n"));
4931 case OID_802_11_NETWORK_TYPE_IN_USE:
4932 wrq->u.data.length = sizeof(ULONG);
4933 if (pAdapter->CommonCfg.PhyMode == PHY_11A)
4934 ulInfo = Ndis802_11OFDM5;
4935 else if ((pAdapter->CommonCfg.PhyMode == PHY_11BG_MIXED) || (pAdapter->CommonCfg.PhyMode == PHY_11G))
4936 ulInfo = Ndis802_11OFDM24;
4938 ulInfo = Ndis802_11DS;
4939 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4941 case RT_OID_802_11_QUERY_LAST_RX_RATE:
4942 ulInfo = (ULONG)pAdapter->LastRxRate;
4943 wrq->u.data.length = sizeof(ulInfo);
4944 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4945 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_LAST_RX_RATE (=%ld)\n", ulInfo));
4947 case RT_OID_802_11_QUERY_LAST_TX_RATE:
4948 //ulInfo = (ULONG)pAdapter->LastTxRate;
4949 ulInfo = (ULONG)pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.word;
4950 wrq->u.data.length = sizeof(ulInfo);
4951 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4952 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_LAST_TX_RATE (=%lx)\n", ulInfo));
4954 case RT_OID_802_11_QUERY_EEPROM_VERSION:
4955 wrq->u.data.length = sizeof(ULONG);
4956 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->EepromVersion, wrq->u.data.length);
4958 case RT_OID_802_11_QUERY_FIRMWARE_VERSION:
4959 wrq->u.data.length = sizeof(ULONG);
4960 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->FirmwareVersion, wrq->u.data.length);
4962 case RT_OID_802_11_QUERY_NOISE_LEVEL:
4963 wrq->u.data.length = sizeof(UCHAR);
4964 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->BbpWriteLatch[66], wrq->u.data.length);
4965 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_NOISE_LEVEL (=%d)\n", pAdapter->BbpWriteLatch[66]));
4967 case RT_OID_802_11_EXTRA_INFO:
4968 wrq->u.data.length = sizeof(ULONG);
4969 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->ExtraInfo, wrq->u.data.length);
4970 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_EXTRA_INFO (=%ld)\n", pAdapter->ExtraInfo));
4972 case RT_OID_WE_VERSION_COMPILED:
4973 wrq->u.data.length = sizeof(UINT);
4974 we_version_compiled = WIRELESS_EXT;
4975 Status = copy_to_user(wrq->u.data.pointer, &we_version_compiled, wrq->u.data.length);
4977 case RT_OID_802_11_QUERY_APSD_SETTING:
4978 apsd = (pAdapter->CommonCfg.bAPSDCapable | (pAdapter->CommonCfg.bAPSDAC_BE << 1) | (pAdapter->CommonCfg.bAPSDAC_BK << 2)
4979 | (pAdapter->CommonCfg.bAPSDAC_VI << 3) | (pAdapter->CommonCfg.bAPSDAC_VO << 4) | (pAdapter->CommonCfg.MaxSPLength << 5));
4981 wrq->u.data.length = sizeof(ULONG);
4982 Status = copy_to_user(wrq->u.data.pointer, &apsd, wrq->u.data.length);
4983 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",
4984 apsd,pAdapter->CommonCfg.bAPSDCapable,pAdapter->CommonCfg.bAPSDAC_BE,pAdapter->CommonCfg.bAPSDAC_BK,pAdapter->CommonCfg.bAPSDAC_VI,pAdapter->CommonCfg.bAPSDAC_VO,pAdapter->CommonCfg.MaxSPLength));
4986 case RT_OID_802_11_QUERY_APSD_PSM:
4987 wrq->u.data.length = sizeof(ULONG);
4988 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.bAPSDForcePowerSave, wrq->u.data.length);
4989 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_APSD_PSM (=%d)\n", pAdapter->CommonCfg.bAPSDForcePowerSave));
4991 case RT_OID_802_11_QUERY_WMM:
4992 wrq->u.data.length = sizeof(BOOLEAN);
4993 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.bWmmCapable, wrq->u.data.length);
4994 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_WMM (=%d)\n", pAdapter->CommonCfg.bWmmCapable));
4996 #ifdef WPA_SUPPLICANT_SUPPORT
4997 case RT_OID_NEW_DRIVER:
5000 wrq->u.data.length = sizeof(UCHAR);
5001 Status = copy_to_user(wrq->u.data.pointer, &enabled, wrq->u.data.length);
5002 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_NEW_DRIVER (=%d)\n", enabled));
5005 case RT_OID_WPA_SUPPLICANT_SUPPORT:
5006 wrq->u.data.length = sizeof(UCHAR);
5007 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->StaCfg.WpaSupplicantUP, wrq->u.data.length);
5008 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_WPA_SUPPLICANT_SUPPORT (=%d)\n", pAdapter->StaCfg.WpaSupplicantUP));
5010 #endif // WPA_SUPPLICANT_SUPPORT //
5012 case RT_OID_DRIVER_DEVICE_NAME:
5013 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_DRIVER_DEVICE_NAME \n"));
5014 wrq->u.data.length = 16;
5015 if (copy_to_user(wrq->u.data.pointer, pAdapter->StaCfg.dev_name, wrq->u.data.length))
5020 case RT_OID_802_11_QUERY_HT_PHYMODE:
5021 pHTPhyMode = (OID_SET_HT_PHYMODE *) kmalloc(sizeof(OID_SET_HT_PHYMODE), MEM_ALLOC_FLAG);
5024 pHTPhyMode->PhyMode = pAdapter->CommonCfg.PhyMode;
5025 pHTPhyMode->HtMode = (UCHAR)pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.field.MODE;
5026 pHTPhyMode->BW = (UCHAR)pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.field.BW;
5027 pHTPhyMode->MCS= (UCHAR)pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.field.MCS;
5028 pHTPhyMode->SHORTGI= (UCHAR)pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.field.ShortGI;
5029 pHTPhyMode->STBC= (UCHAR)pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.field.STBC;
5031 pHTPhyMode->ExtOffset = ((pAdapter->CommonCfg.CentralChannel < pAdapter->CommonCfg.Channel) ? (EXTCHA_BELOW) : (EXTCHA_ABOVE));
5032 wrq->u.data.length = sizeof(OID_SET_HT_PHYMODE);
5033 if (copy_to_user(wrq->u.data.pointer, pHTPhyMode, wrq->u.data.length))
5037 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_HT_PHYMODE (PhyMode = %d, MCS =%d, BW = %d, STBC = %d, ExtOffset=%d)\n",
5038 pHTPhyMode->HtMode, pHTPhyMode->MCS, pHTPhyMode->BW, pHTPhyMode->STBC, pHTPhyMode->ExtOffset));
5039 DBGPRINT(RT_DEBUG_TRACE, (" MlmeUpdateTxRates (.word = %x )\n", pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.word));
5043 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_STA_CONFIG(kmalloc failed)\n"));
5047 case RT_OID_802_11_COUNTRY_REGION:
5048 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_COUNTRY_REGION \n"));
5049 wrq->u.data.length = sizeof(ulInfo);
5050 ulInfo = pAdapter->CommonCfg.CountryRegionForABand;
5051 ulInfo = (ulInfo << 8)|(pAdapter->CommonCfg.CountryRegion);
5052 if (copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length))
5057 case RT_OID_802_11_QUERY_DAT_HT_PHYMODE:
5058 pHTPhyMode = (OID_SET_HT_PHYMODE *) kmalloc(sizeof(OID_SET_HT_PHYMODE), MEM_ALLOC_FLAG);
5061 pHTPhyMode->PhyMode = pAdapter->CommonCfg.PhyMode;
5062 pHTPhyMode->HtMode = (UCHAR)pAdapter->CommonCfg.RegTransmitSetting.field.HTMODE;
5063 pHTPhyMode->BW = (UCHAR)pAdapter->CommonCfg.RegTransmitSetting.field.BW;
5064 pHTPhyMode->MCS= (UCHAR)pAdapter->StaCfg.DesiredTransmitSetting.field.MCS;
5065 pHTPhyMode->SHORTGI= (UCHAR)pAdapter->CommonCfg.RegTransmitSetting.field.ShortGI;
5066 pHTPhyMode->STBC= (UCHAR)pAdapter->CommonCfg.RegTransmitSetting.field.STBC;
5068 wrq->u.data.length = sizeof(OID_SET_HT_PHYMODE);
5069 if (copy_to_user(wrq->u.data.pointer, pHTPhyMode, wrq->u.data.length))
5073 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_HT_PHYMODE (PhyMode = %d, MCS =%d, BW = %d, STBC = %d, ExtOffset=%d)\n",
5074 pHTPhyMode->HtMode, pHTPhyMode->MCS, pHTPhyMode->BW, pHTPhyMode->STBC, pHTPhyMode->ExtOffset));
5075 DBGPRINT(RT_DEBUG_TRACE, (" MlmeUpdateTxRates (.word = %x )\n", pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.word));
5079 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_STA_CONFIG(kmalloc failed)\n"));
5083 case RT_OID_QUERY_MULTIPLE_CARD_SUPPORT:
5084 wrq->u.data.length = sizeof(UCHAR);
5086 #ifdef MULTIPLE_CARD_SUPPORT
5088 #endif // MULTIPLE_CARD_SUPPORT //
5089 if (copy_to_user(wrq->u.data.pointer, &i, wrq->u.data.length))
5093 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_QUERY_MULTIPLE_CARD_SUPPORT(=%d) \n", i));
5096 case RT_OID_802_11_MAC_ADDRESS:
5097 wrq->u.data.length = MAC_ADDR_LEN;
5098 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CurrentAddress, wrq->u.data.length);
5101 case RT_OID_802_11_MANUFACTUREROUI:
5102 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_MANUFACTUREROUI \n"));
5103 wrq->u.data.length = ManufacturerOUI_LEN;
5104 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CurrentAddress, wrq->u.data.length);
5107 case RT_OID_802_11_MANUFACTURERNAME:
5108 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_MANUFACTURERNAME \n"));
5109 wrq->u.data.length = strlen(ManufacturerNAME);
5110 Status = copy_to_user(wrq->u.data.pointer, ManufacturerNAME, wrq->u.data.length);
5113 case RT_OID_802_11_RESOURCETYPEIDNAME:
5114 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_RESOURCETYPEIDNAME \n"));
5115 wrq->u.data.length = strlen(ResourceTypeIdName);
5116 Status = copy_to_user(wrq->u.data.pointer, ResourceTypeIdName, wrq->u.data.length);
5119 case RT_OID_802_11_PRIVACYOPTIONIMPLEMENTED:
5120 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_PRIVACYOPTIONIMPLEMENTED \n"));
5121 ulInfo = 1; // 1 is support wep else 2 is not support.
5122 wrq->u.data.length = sizeof(ulInfo);
5123 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
5126 case RT_OID_802_11_POWERMANAGEMENTMODE:
5127 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_POWERMANAGEMENTMODE \n"));
5128 if (pAdapter->StaCfg.Psm == PSMP_ACTION)
5129 ulInfo = 1; // 1 is power active else 2 is power save.
5133 wrq->u.data.length = sizeof(ulInfo);
5134 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
5137 case OID_802_11_WEPDEFAULTKEYVALUE:
5138 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_WEPDEFAULTKEYVALUE \n"));
5139 //KeyIdxValue.KeyIdx = pAd->PortCfg.MBSSID[pAd->IoctlIF].DefaultKeyId;
5140 pKeyIdxValue = wrq->u.data.pointer;
5141 DBGPRINT(RT_DEBUG_TRACE,("KeyIdxValue.KeyIdx = %d, \n",pKeyIdxValue->KeyIdx));
5142 valueLen = pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].KeyLen;
5143 NdisMoveMemory(pKeyIdxValue->Value,
5144 &pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].Key,
5146 pKeyIdxValue->Value[valueLen]='\0';
5148 wrq->u.data.length = sizeof(DefaultKeyIdxValue);
5150 Status = copy_to_user(wrq->u.data.pointer, pKeyIdxValue, wrq->u.data.length);
5151 DBGPRINT(RT_DEBUG_TRACE,("DefaultKeyId = %d, total len = %d, str len=%d, KeyValue= %02x %02x %02x %02x \n", pAdapter->StaCfg.DefaultKeyId, wrq->u.data.length, pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].KeyLen,
5152 pAdapter->SharedKey[BSS0][0].Key[0],
5153 pAdapter->SharedKey[BSS0][1].Key[0],
5154 pAdapter->SharedKey[BSS0][2].Key[0],
5155 pAdapter->SharedKey[BSS0][3].Key[0]));
5158 case OID_802_11_WEPDEFAULTKEYID:
5159 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_WEPDEFAULTKEYID \n"));
5160 wrq->u.data.length = sizeof(UCHAR);
5161 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->StaCfg.DefaultKeyId, wrq->u.data.length);
5162 DBGPRINT(RT_DEBUG_TRACE, ("DefaultKeyId =%d \n", pAdapter->StaCfg.DefaultKeyId));
5165 case RT_OID_802_11_WEPKEYMAPPINGLENGTH:
5166 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_WEPKEYMAPPINGLENGTH \n"));
5167 wrq->u.data.length = sizeof(UCHAR);
5168 Status = copy_to_user(wrq->u.data.pointer,
5169 &pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].KeyLen,
5170 wrq->u.data.length);
5173 case OID_802_11_SHORTRETRYLIMIT:
5174 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_SHORTRETRYLIMIT \n"));
5175 wrq->u.data.length = sizeof(ULONG);
5176 RTMP_IO_READ32(pAdapter, TX_RTY_CFG, &tx_rty_cfg.word);
5177 ShortRetryLimit = tx_rty_cfg.field.ShortRtyLimit;
5178 DBGPRINT(RT_DEBUG_TRACE, ("ShortRetryLimit =%ld, tx_rty_cfg.field.ShortRetryLimit=%d\n", ShortRetryLimit, tx_rty_cfg.field.ShortRtyLimit));
5179 Status = copy_to_user(wrq->u.data.pointer, &ShortRetryLimit, wrq->u.data.length);
5182 case OID_802_11_LONGRETRYLIMIT:
5183 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_LONGRETRYLIMIT \n"));
5184 wrq->u.data.length = sizeof(ULONG);
5185 RTMP_IO_READ32(pAdapter, TX_RTY_CFG, &tx_rty_cfg.word);
5186 LongRetryLimit = tx_rty_cfg.field.LongRtyLimit;
5187 DBGPRINT(RT_DEBUG_TRACE, ("LongRetryLimit =%ld, tx_rty_cfg.field.LongRtyLimit=%d\n", LongRetryLimit, tx_rty_cfg.field.LongRtyLimit));
5188 Status = copy_to_user(wrq->u.data.pointer, &LongRetryLimit, wrq->u.data.length);
5191 case RT_OID_802_11_PRODUCTID:
5192 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_PRODUCTID \n"));
5197 if (((POS_COOKIE)pAdapter->OS_Cookie)->pci_dev != NULL)
5198 pci_read_config_word(((POS_COOKIE)pAdapter->OS_Cookie)->pci_dev, PCI_DEVICE_ID, &device_id);
5200 DBGPRINT(RT_DEBUG_TRACE, (" pci_dev = NULL\n"));
5201 sprintf(tmp, "%04x %04x\n", NIC_PCI_VENDOR_ID, device_id);
5203 wrq->u.data.length = strlen(tmp);
5204 Status = copy_to_user(wrq->u.data.pointer, tmp, wrq->u.data.length);
5207 case RT_OID_802_11_MANUFACTUREID:
5208 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_MANUFACTUREID \n"));
5209 wrq->u.data.length = strlen(ManufacturerNAME);
5210 Status = copy_to_user(wrq->u.data.pointer, ManufacturerNAME, wrq->u.data.length);
5213 case OID_802_11_CURRENTCHANNEL:
5214 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_CURRENTCHANNEL \n"));
5215 wrq->u.data.length = sizeof(UCHAR);
5216 DBGPRINT(RT_DEBUG_TRACE, ("sizeof UCHAR=%d, channel=%d \n", sizeof(UCHAR), pAdapter->CommonCfg.Channel));
5217 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.Channel, wrq->u.data.length);
5218 DBGPRINT(RT_DEBUG_TRACE, ("Status=%d\n", Status));
5220 #endif //SNMP_SUPPORT
5222 case OID_802_11_BUILD_CHANNEL_EX:
5225 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_BUILD_CHANNEL_EX \n"));
5226 wrq->u.data.length = sizeof(UCHAR);
5227 #ifdef EXT_BUILD_CHANNEL_LIST
5228 DBGPRINT(RT_DEBUG_TRACE, ("Support EXT_BUILD_CHANNEL_LIST.\n"));
5231 DBGPRINT(RT_DEBUG_TRACE, ("Doesn't support EXT_BUILD_CHANNEL_LIST.\n"));
5233 #endif // EXT_BUILD_CHANNEL_LIST //
5234 Status = copy_to_user(wrq->u.data.pointer, &value, 1);
5235 DBGPRINT(RT_DEBUG_TRACE, ("Status=%d\n", Status));
5239 case OID_802_11_GET_CH_LIST:
5241 PRT_CHANNEL_LIST_INFO pChListBuf;
5243 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_GET_CH_LIST \n"));
5244 if (pAdapter->ChannelListNum == 0)
5246 wrq->u.data.length = 0;
5250 pChListBuf = (RT_CHANNEL_LIST_INFO *) kmalloc(sizeof(RT_CHANNEL_LIST_INFO), MEM_ALLOC_FLAG);
5251 if (pChListBuf == NULL)
5253 wrq->u.data.length = 0;
5257 pChListBuf->ChannelListNum = pAdapter->ChannelListNum;
5258 for (i = 0; i < pChListBuf->ChannelListNum; i++)
5259 pChListBuf->ChannelList[i] = pAdapter->ChannelList[i].Channel;
5261 wrq->u.data.length = sizeof(RT_CHANNEL_LIST_INFO);
5262 Status = copy_to_user(wrq->u.data.pointer, pChListBuf, sizeof(RT_CHANNEL_LIST_INFO));
5263 DBGPRINT(RT_DEBUG_TRACE, ("Status=%d\n", Status));
5270 case OID_802_11_GET_COUNTRY_CODE:
5271 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_GET_COUNTRY_CODE \n"));
5272 wrq->u.data.length = 2;
5273 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.CountryCode, 2);
5274 DBGPRINT(RT_DEBUG_TRACE, ("Status=%d\n", Status));
5277 case OID_802_11_GET_CHANNEL_GEOGRAPHY:
5278 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_GET_CHANNEL_GEOGRAPHY \n"));
5279 wrq->u.data.length = 1;
5280 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.Geography, 1);
5281 DBGPRINT(RT_DEBUG_TRACE, ("Status=%d\n", Status));
5285 #ifdef QOS_DLS_SUPPORT
5286 case RT_OID_802_11_QUERY_DLS:
5287 wrq->u.data.length = sizeof(BOOLEAN);
5288 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.bDLSCapable, wrq->u.data.length);
5289 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_DLS(=%d)\n", pAdapter->CommonCfg.bDLSCapable));
5292 case RT_OID_802_11_QUERY_DLS_PARAM:
5294 PRT_802_11_DLS_INFO pDlsInfo = kmalloc(sizeof(RT_802_11_DLS_INFO), GFP_ATOMIC);
5295 if (pDlsInfo == NULL)
5298 for (i=0; i<MAX_NUM_OF_DLS_ENTRY; i++)
5300 RTMPMoveMemory(&pDlsInfo->Entry[i], &pAdapter->StaCfg.DLSEntry[i], sizeof(RT_802_11_DLS_UI));
5303 pDlsInfo->num = MAX_NUM_OF_DLS_ENTRY;
5304 wrq->u.data.length = sizeof(RT_802_11_DLS_INFO);
5305 Status = copy_to_user(wrq->u.data.pointer, pDlsInfo, wrq->u.data.length);
5306 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_DLS_PARAM\n"));
5312 #endif // QOS_DLS_SUPPORT //
5314 DBGPRINT(RT_DEBUG_TRACE, ("Query::unknown IOCTL's subcmd = 0x%08x\n", cmd));
5315 Status = -EOPNOTSUPP;
5321 INT rt28xx_sta_ioctl(
5322 IN struct net_device *net_dev,
5323 IN OUT struct ifreq *rq,
5327 VIRTUAL_ADAPTER *pVirtualAd = NULL;
5328 RTMP_ADAPTER *pAd = NULL;
5329 struct iwreq *wrq = (struct iwreq *) rq;
5330 BOOLEAN StateMachineTouched = FALSE;
5331 INT Status = NDIS_STATUS_SUCCESS;
5334 if (net_dev->priv_flags == INT_MAIN)
5336 pAd = net_dev->ml_priv;
5340 pVirtualAd = net_dev->ml_priv;
5341 pAd = pVirtualAd->RtmpDev->ml_priv;
5343 pObj = (POS_COOKIE) pAd->OS_Cookie;
5347 /* if 1st open fail, pAd will be free;
5348 So the net_dev->ml_priv will be NULL in 2rd open */
5352 //check if the interface is down
5353 if(!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_IN_USE))
5356 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
5361 { // determine this ioctl command is comming from which interface.
5362 pObj->ioctl_if_type = INT_MAIN;
5363 pObj->ioctl_if = MAIN_MBSSID;
5369 DBGPRINT(RT_DEBUG_TRACE, ("IOCTL::SIOCGIFHWADDR\n"));
5370 memcpy(wrq->u.name, pAd->CurrentAddress, ETH_ALEN);
5374 char *name=&wrq->u.name[0];
5375 rt_ioctl_giwname(net_dev, NULL, name, NULL);
5378 case SIOCGIWESSID: //Get ESSID
5380 struct iw_point *essid=&wrq->u.essid;
5381 rt_ioctl_giwessid(net_dev, NULL, essid, essid->pointer);
5384 case SIOCSIWESSID: //Set ESSID
5386 struct iw_point *essid=&wrq->u.essid;
5387 rt_ioctl_siwessid(net_dev, NULL, essid, essid->pointer);
5390 case SIOCSIWNWID: // set network id (the cell)
5391 case SIOCGIWNWID: // get network id
5392 Status = -EOPNOTSUPP;
5394 case SIOCSIWFREQ: //set channel/frequency (Hz)
5396 struct iw_freq *freq=&wrq->u.freq;
5397 rt_ioctl_siwfreq(net_dev, NULL, freq, NULL);
5400 case SIOCGIWFREQ: // get channel/frequency (Hz)
5402 struct iw_freq *freq=&wrq->u.freq;
5403 rt_ioctl_giwfreq(net_dev, NULL, freq, NULL);
5406 case SIOCSIWNICKN: //set node name/nickname
5408 struct iw_point *data=&wrq->u.data;
5409 rt_ioctl_siwnickn(net_dev, NULL, data, NULL);
5412 case SIOCGIWNICKN: //get node name/nickname
5414 struct iw_point *data=&wrq->u.data;
5415 rt_ioctl_giwnickn(net_dev, NULL, data, NULL);
5418 case SIOCGIWRATE: //get default bit rate (bps)
5419 rt_ioctl_giwrate(net_dev, NULL, &wrq->u, NULL);
5421 case SIOCSIWRATE: //set default bit rate (bps)
5422 rt_ioctl_siwrate(net_dev, NULL, &wrq->u, NULL);
5424 case SIOCGIWRTS: // get RTS/CTS threshold (bytes)
5426 struct iw_param *rts=&wrq->u.rts;
5427 rt_ioctl_giwrts(net_dev, NULL, rts, NULL);
5430 case SIOCSIWRTS: //set RTS/CTS threshold (bytes)
5432 struct iw_param *rts=&wrq->u.rts;
5433 rt_ioctl_siwrts(net_dev, NULL, rts, NULL);
5436 case SIOCGIWFRAG: //get fragmentation thr (bytes)
5438 struct iw_param *frag=&wrq->u.frag;
5439 rt_ioctl_giwfrag(net_dev, NULL, frag, NULL);
5442 case SIOCSIWFRAG: //set fragmentation thr (bytes)
5444 struct iw_param *frag=&wrq->u.frag;
5445 rt_ioctl_siwfrag(net_dev, NULL, frag, NULL);
5448 case SIOCGIWENCODE: //get encoding token & mode
5450 struct iw_point *erq=&wrq->u.encoding;
5452 rt_ioctl_giwencode(net_dev, NULL, erq, erq->pointer);
5455 case SIOCSIWENCODE: //set encoding token & mode
5457 struct iw_point *erq=&wrq->u.encoding;
5459 rt_ioctl_siwencode(net_dev, NULL, erq, erq->pointer);
5462 case SIOCGIWAP: //get access point MAC addresses
5464 struct sockaddr *ap_addr=&wrq->u.ap_addr;
5465 rt_ioctl_giwap(net_dev, NULL, ap_addr, ap_addr->sa_data);
5468 case SIOCSIWAP: //set access point MAC addresses
5470 struct sockaddr *ap_addr=&wrq->u.ap_addr;
5471 rt_ioctl_siwap(net_dev, NULL, ap_addr, ap_addr->sa_data);
5474 case SIOCGIWMODE: //get operation mode
5476 __u32 *mode=&wrq->u.mode;
5477 rt_ioctl_giwmode(net_dev, NULL, mode, NULL);
5480 case SIOCSIWMODE: //set operation mode
5482 __u32 *mode=&wrq->u.mode;
5483 rt_ioctl_siwmode(net_dev, NULL, mode, NULL);
5486 case SIOCGIWSENS: //get sensitivity (dBm)
5487 case SIOCSIWSENS: //set sensitivity (dBm)
5488 case SIOCGIWPOWER: //get Power Management settings
5489 case SIOCSIWPOWER: //set Power Management settings
5490 case SIOCGIWTXPOW: //get transmit power (dBm)
5491 case SIOCSIWTXPOW: //set transmit power (dBm)
5492 case SIOCGIWRANGE: //Get range of parameters
5493 case SIOCGIWRETRY: //get retry limits and lifetime
5494 case SIOCSIWRETRY: //set retry limits and lifetime
5495 Status = -EOPNOTSUPP;
5498 subcmd = wrq->u.data.flags;
5499 if( subcmd & OID_GET_SET_TOGGLE)
5500 Status = RTMPSetInformation(pAd, rq, subcmd);
5502 Status = RTMPQueryInformation(pAd, rq, subcmd);
5505 if (wrq->u.data.pointer)
5507 if ( access_ok(VERIFY_WRITE, wrq->u.data.pointer, sizeof(privtab)) != TRUE)
5509 wrq->u.data.length = sizeof(privtab) / sizeof(privtab[0]);
5510 if (copy_to_user(wrq->u.data.pointer, privtab, sizeof(privtab)))
5514 case RTPRIV_IOCTL_SET:
5515 if(access_ok(VERIFY_READ, wrq->u.data.pointer, wrq->u.data.length) != TRUE)
5517 rt_ioctl_setparam(net_dev, NULL, NULL, wrq->u.data.pointer);
5519 case RTPRIV_IOCTL_GSITESURVEY:
5520 RTMPIoctlGetSiteSurvey(pAd, wrq);
5523 case RTPRIV_IOCTL_MAC:
5524 RTMPIoctlMAC(pAd, wrq);
5526 case RTPRIV_IOCTL_E2P:
5527 RTMPIoctlE2PROM(pAd, wrq);
5533 DBGPRINT(RT_DEBUG_ERROR, ("IOCTL::unknown IOCTL's cmd = 0x%08x\n", cmd));
5534 Status = -EOPNOTSUPP;
5538 if(StateMachineTouched) // Upper layer sent a MLME-related operations
5539 RT28XX_MLME_HANDLER(pAd);
5545 ==========================================================================
5549 TRUE if all parameters are OK, FALSE otherwise
5550 ==========================================================================
5553 IN PRTMP_ADAPTER pAdapter,
5556 NDIS_802_11_SSID Ssid, *pSsid=NULL;
5557 BOOLEAN StateMachineTouched = FALSE;
5560 if( strlen(arg) <= MAX_LEN_OF_SSID)
5562 NdisZeroMemory(&Ssid, sizeof(NDIS_802_11_SSID));
5563 if (strlen(arg) != 0)
5565 NdisMoveMemory(Ssid.Ssid, arg, strlen(arg));
5566 Ssid.SsidLength = strlen(arg);
5570 Ssid.SsidLength = 0;
5571 memcpy(Ssid.Ssid, "", 0);
5572 pAdapter->StaCfg.BssType = BSS_INFRA;
5573 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
5574 pAdapter->StaCfg.WepStatus = Ndis802_11EncryptionDisabled;
5578 if (pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE)
5580 RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
5581 DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
5584 pAdapter->MlmeAux.CurrReqIsFromNdis = TRUE;
5585 pAdapter->StaCfg.bScanReqIsFromWebUI = FALSE;
5586 pAdapter->bConfigChanged = TRUE;
5588 MlmeEnqueue(pAdapter,
5589 MLME_CNTL_STATE_MACHINE,
5591 sizeof(NDIS_802_11_SSID),
5594 StateMachineTouched = TRUE;
5595 DBGPRINT(RT_DEBUG_TRACE, ("Set_SSID_Proc::(Len=%d,Ssid=%s)\n", Ssid.SsidLength, Ssid.Ssid));
5600 if (StateMachineTouched) // Upper layer sent a MLME-related operations
5601 RT28XX_MLME_HANDLER(pAdapter);
5608 ==========================================================================
5610 Set WmmCapable Enable or Disable
5612 TRUE if all parameters are OK, FALSE otherwise
5613 ==========================================================================
5615 INT Set_WmmCapable_Proc(
5616 IN PRTMP_ADAPTER pAd,
5619 BOOLEAN bWmmCapable;
5621 bWmmCapable = simple_strtol(arg, 0, 10);
5623 if ((bWmmCapable == 1)
5625 pAd->CommonCfg.bWmmCapable = TRUE;
5626 else if (bWmmCapable == 0)
5627 pAd->CommonCfg.bWmmCapable = FALSE;
5629 return FALSE; //Invalid argument
5631 DBGPRINT(RT_DEBUG_TRACE, ("Set_WmmCapable_Proc::(bWmmCapable=%d)\n",
5632 pAd->CommonCfg.bWmmCapable));
5636 #endif // WMM_SUPPORT //
5639 ==========================================================================
5641 Set Network Type(Infrastructure/Adhoc mode)
5643 TRUE if all parameters are OK, FALSE otherwise
5644 ==========================================================================
5646 INT Set_NetworkType_Proc(
5647 IN PRTMP_ADAPTER pAdapter,
5652 if (strcmp(arg, "Adhoc") == 0)
5654 if (pAdapter->StaCfg.BssType != BSS_ADHOC)
5656 // Config has changed
5657 pAdapter->bConfigChanged = TRUE;
5658 if (MONITOR_ON(pAdapter))
5660 RTMP_IO_WRITE32(pAdapter, RX_FILTR_CFG, STANORMAL);
5661 RTMP_IO_READ32(pAdapter, MAC_SYS_CTRL, &Value);
5663 RTMP_IO_WRITE32(pAdapter, MAC_SYS_CTRL, Value);
5664 OPSTATUS_CLEAR_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED);
5665 pAdapter->StaCfg.bAutoReconnect = TRUE;
5666 LinkDown(pAdapter, FALSE);
5668 if (INFRA_ON(pAdapter))
5670 //BOOLEAN Cancelled;
5671 // Set the AutoReconnectSsid to prevent it reconnect to old SSID
5672 // Since calling this indicate user don't want to connect to that SSID anymore.
5673 pAdapter->MlmeAux.AutoReconnectSsidLen= 32;
5674 NdisZeroMemory(pAdapter->MlmeAux.AutoReconnectSsid, pAdapter->MlmeAux.AutoReconnectSsidLen);
5676 LinkDown(pAdapter, FALSE);
5678 DBGPRINT(RT_DEBUG_TRACE, ("NDIS_STATUS_MEDIA_DISCONNECT Event BB!\n"));
5681 pAdapter->StaCfg.BssType = BSS_ADHOC;
5682 pAdapter->net_dev->type = pAdapter->StaCfg.OriDevType;
5683 DBGPRINT(RT_DEBUG_TRACE, ("===>Set_NetworkType_Proc::(AD-HOC)\n"));
5685 else if (strcmp(arg, "Infra") == 0)
5687 if (pAdapter->StaCfg.BssType != BSS_INFRA)
5689 // Config has changed
5690 pAdapter->bConfigChanged = TRUE;
5691 if (MONITOR_ON(pAdapter))
5693 RTMP_IO_WRITE32(pAdapter, RX_FILTR_CFG, STANORMAL);
5694 RTMP_IO_READ32(pAdapter, MAC_SYS_CTRL, &Value);
5696 RTMP_IO_WRITE32(pAdapter, MAC_SYS_CTRL, Value);
5697 OPSTATUS_CLEAR_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED);
5698 pAdapter->StaCfg.bAutoReconnect = TRUE;
5699 LinkDown(pAdapter, FALSE);
5701 if (ADHOC_ON(pAdapter))
5703 // Set the AutoReconnectSsid to prevent it reconnect to old SSID
5704 // Since calling this indicate user don't want to connect to that SSID anymore.
5705 pAdapter->MlmeAux.AutoReconnectSsidLen= 32;
5706 NdisZeroMemory(pAdapter->MlmeAux.AutoReconnectSsid, pAdapter->MlmeAux.AutoReconnectSsidLen);
5708 LinkDown(pAdapter, FALSE);
5711 pAdapter->StaCfg.BssType = BSS_INFRA;
5712 pAdapter->net_dev->type = pAdapter->StaCfg.OriDevType;
5713 DBGPRINT(RT_DEBUG_TRACE, ("===>Set_NetworkType_Proc::(INFRA)\n"));
5715 pAdapter->StaCfg.BssType = BSS_INFRA;
5717 else if (strcmp(arg, "Monitor") == 0)
5720 BCN_TIME_CFG_STRUC csr;
5721 OPSTATUS_CLEAR_FLAG(pAdapter, fOP_STATUS_INFRA_ON);
5722 OPSTATUS_CLEAR_FLAG(pAdapter, fOP_STATUS_ADHOC_ON);
5723 OPSTATUS_SET_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED);
5724 // disable all periodic state machine
5725 pAdapter->StaCfg.bAutoReconnect = FALSE;
5726 // reset all mlme state machine
5727 RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
5728 DBGPRINT(RT_DEBUG_TRACE, ("fOP_STATUS_MEDIA_STATE_CONNECTED \n"));
5729 if (pAdapter->CommonCfg.CentralChannel == 0)
5731 #ifdef DOT11_N_SUPPORT
5732 if (pAdapter->CommonCfg.PhyMode == PHY_11AN_MIXED)
5733 pAdapter->CommonCfg.CentralChannel = 36;
5735 #endif // DOT11_N_SUPPORT //
5736 pAdapter->CommonCfg.CentralChannel = 6;
5738 #ifdef DOT11_N_SUPPORT
5740 N_ChannelCheck(pAdapter);
5741 #endif // DOT11_N_SUPPORT //
5743 #ifdef DOT11_N_SUPPORT
5744 if (pAdapter->CommonCfg.PhyMode >= PHY_11ABGN_MIXED &&
5745 pAdapter->CommonCfg.RegTransmitSetting.field.BW == BW_40 &&
5746 pAdapter->CommonCfg.RegTransmitSetting.field.EXTCHA == EXTCHA_ABOVE)
5748 // 40MHz ,control channel at lower
5749 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, BBP_R4, &bbpValue);
5750 bbpValue &= (~0x18);
5752 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R4, bbpValue);
5753 pAdapter->CommonCfg.BBPCurrentBW = BW_40;
5754 // RX : control channel at lower
5755 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, BBP_R3, &bbpValue);
5756 bbpValue &= (~0x20);
5757 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R3, bbpValue);
5759 RTMP_IO_READ32(pAdapter, TX_BAND_CFG, &Value);
5760 Value &= 0xfffffffe;
5761 RTMP_IO_WRITE32(pAdapter, TX_BAND_CFG, Value);
5762 pAdapter->CommonCfg.CentralChannel = pAdapter->CommonCfg.Channel + 2;
5763 AsicSwitchChannel(pAdapter, pAdapter->CommonCfg.CentralChannel, FALSE);
5764 AsicLockChannel(pAdapter, pAdapter->CommonCfg.CentralChannel);
5765 DBGPRINT(RT_DEBUG_TRACE, ("BW_40 ,control_channel(%d), CentralChannel(%d) \n",
5766 pAdapter->CommonCfg.Channel,
5767 pAdapter->CommonCfg.CentralChannel));
5769 else if (pAdapter->CommonCfg.PhyMode >= PHY_11ABGN_MIXED &&
5770 pAdapter->CommonCfg.RegTransmitSetting.field.BW == BW_40 &&
5771 pAdapter->CommonCfg.RegTransmitSetting.field.EXTCHA == EXTCHA_BELOW)
5773 // 40MHz ,control channel at upper
5774 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, BBP_R4, &bbpValue);
5775 bbpValue &= (~0x18);
5777 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R4, bbpValue);
5778 pAdapter->CommonCfg.BBPCurrentBW = BW_40;
5779 RTMP_IO_READ32(pAdapter, TX_BAND_CFG, &Value);
5781 RTMP_IO_WRITE32(pAdapter, TX_BAND_CFG, Value);
5783 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, BBP_R3, &bbpValue);
5785 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R3, bbpValue);
5786 pAdapter->CommonCfg.CentralChannel = pAdapter->CommonCfg.Channel - 2;
5787 AsicSwitchChannel(pAdapter, pAdapter->CommonCfg.CentralChannel, FALSE);
5788 AsicLockChannel(pAdapter, pAdapter->CommonCfg.CentralChannel);
5789 DBGPRINT(RT_DEBUG_TRACE, ("BW_40 ,control_channel(%d), CentralChannel(%d) \n",
5790 pAdapter->CommonCfg.Channel,
5791 pAdapter->CommonCfg.CentralChannel));
5794 #endif // DOT11_N_SUPPORT //
5797 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, BBP_R4, &bbpValue);
5798 bbpValue &= (~0x18);
5799 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R4, bbpValue);
5800 pAdapter->CommonCfg.BBPCurrentBW = BW_20;
5801 AsicSwitchChannel(pAdapter, pAdapter->CommonCfg.Channel, FALSE);
5802 AsicLockChannel(pAdapter, pAdapter->CommonCfg.Channel);
5803 DBGPRINT(RT_DEBUG_TRACE, ("BW_20, Channel(%d)\n", pAdapter->CommonCfg.Channel));
5805 // Enable Rx with promiscuous reception
5806 RTMP_IO_WRITE32(pAdapter, RX_FILTR_CFG, 0x3);
5807 // ASIC supporsts sniffer function with replacing RSSI with timestamp.
5808 //RTMP_IO_READ32(pAdapter, MAC_SYS_CTRL, &Value);
5810 //RTMP_IO_WRITE32(pAdapter, MAC_SYS_CTRL, Value);
5812 RTMP_IO_READ32(pAdapter, BCN_TIME_CFG, &csr.word);
5813 csr.field.bBeaconGen = 0;
5814 csr.field.bTBTTEnable = 0;
5815 csr.field.TsfSyncMode = 0;
5816 RTMP_IO_WRITE32(pAdapter, BCN_TIME_CFG, csr.word);
5818 pAdapter->StaCfg.BssType = BSS_MONITOR;
5819 pAdapter->net_dev->type = ARPHRD_IEEE80211_PRISM; //ARPHRD_IEEE80211; // IEEE80211
5820 DBGPRINT(RT_DEBUG_TRACE, ("===>Set_NetworkType_Proc::(MONITOR)\n"));
5823 // Reset Ralink supplicant to not use, it will be set to start when UI set PMK key
5824 pAdapter->StaCfg.WpaState = SS_NOTUSE;
5826 DBGPRINT(RT_DEBUG_TRACE, ("Set_NetworkType_Proc::(NetworkType=%d)\n", pAdapter->StaCfg.BssType));
5832 ==========================================================================
5834 Set Authentication mode
5836 TRUE if all parameters are OK, FALSE otherwise
5837 ==========================================================================
5839 INT Set_AuthMode_Proc(
5840 IN PRTMP_ADAPTER pAdapter,
5843 if ((strcmp(arg, "WEPAUTO") == 0) || (strcmp(arg, "wepauto") == 0))
5844 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeAutoSwitch;
5845 else if ((strcmp(arg, "OPEN") == 0) || (strcmp(arg, "open") == 0))
5846 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
5847 else if ((strcmp(arg, "SHARED") == 0) || (strcmp(arg, "shared") == 0))
5848 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeShared;
5849 else if ((strcmp(arg, "WPAPSK") == 0) || (strcmp(arg, "wpapsk") == 0))
5850 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPAPSK;
5851 else if ((strcmp(arg, "WPANONE") == 0) || (strcmp(arg, "wpanone") == 0))
5852 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPANone;
5853 else if ((strcmp(arg, "WPA2PSK") == 0) || (strcmp(arg, "wpa2psk") == 0))
5854 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA2PSK;
5855 #ifdef WPA_SUPPLICANT_SUPPORT
5856 else if ((strcmp(arg, "WPA") == 0) || (strcmp(arg, "wpa") == 0))
5857 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA;
5858 else if ((strcmp(arg, "WPA2") == 0) || (strcmp(arg, "wpa2") == 0))
5859 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA2;
5860 #endif // WPA_SUPPLICANT_SUPPORT //
5864 pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED;
5866 DBGPRINT(RT_DEBUG_TRACE, ("Set_AuthMode_Proc::(AuthMode=%d)\n", pAdapter->StaCfg.AuthMode));
5872 ==========================================================================
5876 TRUE if all parameters are OK, FALSE otherwise
5877 ==========================================================================
5879 INT Set_EncrypType_Proc(
5880 IN PRTMP_ADAPTER pAdapter,
5883 if ((strcmp(arg, "NONE") == 0) || (strcmp(arg, "none") == 0))
5885 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
5886 return TRUE; // do nothing
5888 pAdapter->StaCfg.WepStatus = Ndis802_11WEPDisabled;
5889 pAdapter->StaCfg.PairCipher = Ndis802_11WEPDisabled;
5890 pAdapter->StaCfg.GroupCipher = Ndis802_11WEPDisabled;
5892 else if ((strcmp(arg, "WEP") == 0) || (strcmp(arg, "wep") == 0))
5894 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
5895 return TRUE; // do nothing
5897 pAdapter->StaCfg.WepStatus = Ndis802_11WEPEnabled;
5898 pAdapter->StaCfg.PairCipher = Ndis802_11WEPEnabled;
5899 pAdapter->StaCfg.GroupCipher = Ndis802_11WEPEnabled;
5901 else if ((strcmp(arg, "TKIP") == 0) || (strcmp(arg, "tkip") == 0))
5903 if (pAdapter->StaCfg.AuthMode < Ndis802_11AuthModeWPA)
5904 return TRUE; // do nothing
5906 pAdapter->StaCfg.WepStatus = Ndis802_11Encryption2Enabled;
5907 pAdapter->StaCfg.PairCipher = Ndis802_11Encryption2Enabled;
5908 pAdapter->StaCfg.GroupCipher = Ndis802_11Encryption2Enabled;
5910 else if ((strcmp(arg, "AES") == 0) || (strcmp(arg, "aes") == 0))
5912 if (pAdapter->StaCfg.AuthMode < Ndis802_11AuthModeWPA)
5913 return TRUE; // do nothing
5915 pAdapter->StaCfg.WepStatus = Ndis802_11Encryption3Enabled;
5916 pAdapter->StaCfg.PairCipher = Ndis802_11Encryption3Enabled;
5917 pAdapter->StaCfg.GroupCipher = Ndis802_11Encryption3Enabled;
5922 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
5924 DBGPRINT(RT_DEBUG_TRACE, ("Set_EncrypType_Proc::(EncrypType=%d)\n", pAdapter->StaCfg.WepStatus));
5930 ==========================================================================
5934 TRUE if all parameters are OK, FALSE otherwise
5935 ==========================================================================
5937 INT Set_DefaultKeyID_Proc(
5938 IN PRTMP_ADAPTER pAdapter,
5943 KeyIdx = simple_strtol(arg, 0, 10);
5944 if((KeyIdx >= 1 ) && (KeyIdx <= 4))
5945 pAdapter->StaCfg.DefaultKeyId = (UCHAR) (KeyIdx - 1 );
5947 return FALSE; //Invalid argument
5949 DBGPRINT(RT_DEBUG_TRACE, ("Set_DefaultKeyID_Proc::(DefaultKeyID=%d)\n", pAdapter->StaCfg.DefaultKeyId));
5955 ==========================================================================
5959 TRUE if all parameters are OK, FALSE otherwise
5960 ==========================================================================
5963 IN PRTMP_ADAPTER pAdapter,
5968 UCHAR CipherAlg=CIPHER_WEP64;
5970 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
5971 return TRUE; // do nothing
5973 KeyLen = strlen(arg);
5977 case 5: //wep 40 Ascii type
5978 pAdapter->SharedKey[BSS0][0].KeyLen = KeyLen;
5979 memcpy(pAdapter->SharedKey[BSS0][0].Key, arg, KeyLen);
5980 CipherAlg = CIPHER_WEP64;
5981 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key1_Proc::(Key1=%s and type=%s)\n", arg, "Ascii"));
5983 case 10: //wep 40 Hex type
5984 for(i=0; i < KeyLen; i++)
5986 if( !isxdigit(*(arg+i)) )
5987 return FALSE; //Not Hex value;
5989 pAdapter->SharedKey[BSS0][0].KeyLen = KeyLen / 2 ;
5990 AtoH(arg, pAdapter->SharedKey[BSS0][0].Key, KeyLen / 2);
5991 CipherAlg = CIPHER_WEP64;
5992 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key1_Proc::(Key1=%s and type=%s)\n", arg, "Hex"));
5994 case 13: //wep 104 Ascii type
5995 pAdapter->SharedKey[BSS0][0].KeyLen = KeyLen;
5996 memcpy(pAdapter->SharedKey[BSS0][0].Key, arg, KeyLen);
5997 CipherAlg = CIPHER_WEP128;
5998 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key1_Proc::(Key1=%s and type=%s)\n", arg, "Ascii"));
6000 case 26: //wep 104 Hex type
6001 for(i=0; i < KeyLen; i++)
6003 if( !isxdigit(*(arg+i)) )
6004 return FALSE; //Not Hex value;
6006 pAdapter->SharedKey[BSS0][0].KeyLen = KeyLen / 2 ;
6007 AtoH(arg, pAdapter->SharedKey[BSS0][0].Key, KeyLen / 2);
6008 CipherAlg = CIPHER_WEP128;
6009 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key1_Proc::(Key1=%s and type=%s)\n", arg, "Hex"));
6011 default: //Invalid argument
6012 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key1_Proc::Invalid argument (=%s)\n", arg));
6016 pAdapter->SharedKey[BSS0][0].CipherAlg = CipherAlg;
6018 // Set keys (into ASIC)
6019 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
6021 else // Old WEP stuff
6023 AsicAddSharedKeyEntry(pAdapter,
6026 pAdapter->SharedKey[BSS0][0].CipherAlg,
6027 pAdapter->SharedKey[BSS0][0].Key,
6035 ==========================================================================
6040 TRUE if all parameters are OK, FALSE otherwise
6041 ==========================================================================
6044 IN PRTMP_ADAPTER pAdapter,
6049 UCHAR CipherAlg=CIPHER_WEP64;
6051 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
6052 return TRUE; // do nothing
6054 KeyLen = strlen(arg);
6058 case 5: //wep 40 Ascii type
6059 pAdapter->SharedKey[BSS0][1].KeyLen = KeyLen;
6060 memcpy(pAdapter->SharedKey[BSS0][1].Key, arg, KeyLen);
6061 CipherAlg = CIPHER_WEP64;
6062 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key2_Proc::(Key2=%s and type=%s)\n", arg, "Ascii"));
6064 case 10: //wep 40 Hex type
6065 for(i=0; i < KeyLen; i++)
6067 if( !isxdigit(*(arg+i)) )
6068 return FALSE; //Not Hex value;
6070 pAdapter->SharedKey[BSS0][1].KeyLen = KeyLen / 2 ;
6071 AtoH(arg, pAdapter->SharedKey[BSS0][1].Key, KeyLen / 2);
6072 CipherAlg = CIPHER_WEP64;
6073 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key2_Proc::(Key2=%s and type=%s)\n", arg, "Hex"));
6075 case 13: //wep 104 Ascii type
6076 pAdapter->SharedKey[BSS0][1].KeyLen = KeyLen;
6077 memcpy(pAdapter->SharedKey[BSS0][1].Key, arg, KeyLen);
6078 CipherAlg = CIPHER_WEP128;
6079 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key2_Proc::(Key2=%s and type=%s)\n", arg, "Ascii"));
6081 case 26: //wep 104 Hex type
6082 for(i=0; i < KeyLen; i++)
6084 if( !isxdigit(*(arg+i)) )
6085 return FALSE; //Not Hex value;
6087 pAdapter->SharedKey[BSS0][1].KeyLen = KeyLen / 2 ;
6088 AtoH(arg, pAdapter->SharedKey[BSS0][1].Key, KeyLen / 2);
6089 CipherAlg = CIPHER_WEP128;
6090 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key2_Proc::(Key2=%s and type=%s)\n", arg, "Hex"));
6092 default: //Invalid argument
6093 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key2_Proc::Invalid argument (=%s)\n", arg));
6096 pAdapter->SharedKey[BSS0][1].CipherAlg = CipherAlg;
6098 // Set keys (into ASIC)
6099 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
6101 else // Old WEP stuff
6103 AsicAddSharedKeyEntry(pAdapter,
6106 pAdapter->SharedKey[BSS0][1].CipherAlg,
6107 pAdapter->SharedKey[BSS0][1].Key,
6115 ==========================================================================
6119 TRUE if all parameters are OK, FALSE otherwise
6120 ==========================================================================
6123 IN PRTMP_ADAPTER pAdapter,
6128 UCHAR CipherAlg=CIPHER_WEP64;
6130 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
6131 return TRUE; // do nothing
6133 KeyLen = strlen(arg);
6137 case 5: //wep 40 Ascii type
6138 pAdapter->SharedKey[BSS0][2].KeyLen = KeyLen;
6139 memcpy(pAdapter->SharedKey[BSS0][2].Key, arg, KeyLen);
6140 CipherAlg = CIPHER_WEP64;
6141 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key3_Proc::(Key3=%s and type=Ascii)\n", arg));
6143 case 10: //wep 40 Hex type
6144 for(i=0; i < KeyLen; i++)
6146 if( !isxdigit(*(arg+i)) )
6147 return FALSE; //Not Hex value;
6149 pAdapter->SharedKey[BSS0][2].KeyLen = KeyLen / 2 ;
6150 AtoH(arg, pAdapter->SharedKey[BSS0][2].Key, KeyLen / 2);
6151 CipherAlg = CIPHER_WEP64;
6152 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key3_Proc::(Key3=%s and type=Hex)\n", arg));
6154 case 13: //wep 104 Ascii type
6155 pAdapter->SharedKey[BSS0][2].KeyLen = KeyLen;
6156 memcpy(pAdapter->SharedKey[BSS0][2].Key, arg, KeyLen);
6157 CipherAlg = CIPHER_WEP128;
6158 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key3_Proc::(Key3=%s and type=Ascii)\n", arg));
6160 case 26: //wep 104 Hex type
6161 for(i=0; i < KeyLen; i++)
6163 if( !isxdigit(*(arg+i)) )
6164 return FALSE; //Not Hex value;
6166 pAdapter->SharedKey[BSS0][2].KeyLen = KeyLen / 2 ;
6167 AtoH(arg, pAdapter->SharedKey[BSS0][2].Key, KeyLen / 2);
6168 CipherAlg = CIPHER_WEP128;
6169 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key3_Proc::(Key3=%s and type=Hex)\n", arg));
6171 default: //Invalid argument
6172 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key3_Proc::Invalid argument (=%s)\n", arg));
6175 pAdapter->SharedKey[BSS0][2].CipherAlg = CipherAlg;
6177 // Set keys (into ASIC)
6178 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
6180 else // Old WEP stuff
6182 AsicAddSharedKeyEntry(pAdapter,
6185 pAdapter->SharedKey[BSS0][2].CipherAlg,
6186 pAdapter->SharedKey[BSS0][2].Key,
6194 ==========================================================================
6198 TRUE if all parameters are OK, FALSE otherwise
6199 ==========================================================================
6202 IN PRTMP_ADAPTER pAdapter,
6207 UCHAR CipherAlg=CIPHER_WEP64;
6209 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
6210 return TRUE; // do nothing
6212 KeyLen = strlen(arg);
6216 case 5: //wep 40 Ascii type
6217 pAdapter->SharedKey[BSS0][3].KeyLen = KeyLen;
6218 memcpy(pAdapter->SharedKey[BSS0][3].Key, arg, KeyLen);
6219 CipherAlg = CIPHER_WEP64;
6220 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key4_Proc::(Key4=%s and type=%s)\n", arg, "Ascii"));
6222 case 10: //wep 40 Hex type
6223 for(i=0; i < KeyLen; i++)
6225 if( !isxdigit(*(arg+i)) )
6226 return FALSE; //Not Hex value;
6228 pAdapter->SharedKey[BSS0][3].KeyLen = KeyLen / 2 ;
6229 AtoH(arg, pAdapter->SharedKey[BSS0][3].Key, KeyLen / 2);
6230 CipherAlg = CIPHER_WEP64;
6231 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key4_Proc::(Key4=%s and type=%s)\n", arg, "Hex"));
6233 case 13: //wep 104 Ascii type
6234 pAdapter->SharedKey[BSS0][3].KeyLen = KeyLen;
6235 memcpy(pAdapter->SharedKey[BSS0][3].Key, arg, KeyLen);
6236 CipherAlg = CIPHER_WEP128;
6237 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key4_Proc::(Key4=%s and type=%s)\n", arg, "Ascii"));
6239 case 26: //wep 104 Hex type
6240 for(i=0; i < KeyLen; i++)
6242 if( !isxdigit(*(arg+i)) )
6243 return FALSE; //Not Hex value;
6245 pAdapter->SharedKey[BSS0][3].KeyLen = KeyLen / 2 ;
6246 AtoH(arg, pAdapter->SharedKey[BSS0][3].Key, KeyLen / 2);
6247 CipherAlg = CIPHER_WEP128;
6248 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key4_Proc::(Key4=%s and type=%s)\n", arg, "Hex"));
6250 default: //Invalid argument
6251 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key4_Proc::Invalid argument (=%s)\n", arg));
6254 pAdapter->SharedKey[BSS0][3].CipherAlg = CipherAlg;
6256 // Set keys (into ASIC)
6257 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
6259 else // Old WEP stuff
6261 AsicAddSharedKeyEntry(pAdapter,
6264 pAdapter->SharedKey[BSS0][3].CipherAlg,
6265 pAdapter->SharedKey[BSS0][3].Key,
6274 ==========================================================================
6278 TRUE if all parameters are OK, FALSE otherwise
6279 ==========================================================================
6281 INT Set_WPAPSK_Proc(
6282 IN PRTMP_ADAPTER pAdapter,
6285 UCHAR keyMaterial[40];
6287 if ((pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPAPSK) &&
6288 (pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPA2PSK) &&
6289 (pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPANone)
6291 return TRUE; // do nothing
6293 DBGPRINT(RT_DEBUG_TRACE, ("Set_WPAPSK_Proc::(WPAPSK=%s)\n", arg));
6295 NdisZeroMemory(keyMaterial, 40);
6297 if ((strlen(arg) < 8) || (strlen(arg) > 64))
6299 DBGPRINT(RT_DEBUG_TRACE, ("Set failed!!(WPAPSK=%s), WPAPSK key-string required 8 ~ 64 characters \n", arg));
6303 if (strlen(arg) == 64)
6305 AtoH(arg, keyMaterial, 32);
6306 NdisMoveMemory(pAdapter->StaCfg.PMK, keyMaterial, 32);
6311 PasswordHash((char *)arg, pAdapter->MlmeAux.Ssid, pAdapter->MlmeAux.SsidLen, keyMaterial);
6312 NdisMoveMemory(pAdapter->StaCfg.PMK, keyMaterial, 32);
6317 if(pAdapter->StaCfg.BssType == BSS_ADHOC &&
6318 pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPANone)
6320 pAdapter->StaCfg.WpaState = SS_NOTUSE;
6324 // Start STA supplicant state machine
6325 pAdapter->StaCfg.WpaState = SS_START;
6332 ==========================================================================
6334 Set Power Saving mode
6336 TRUE if all parameters are OK, FALSE otherwise
6337 ==========================================================================
6339 INT Set_PSMode_Proc(
6340 IN PRTMP_ADAPTER pAdapter,
6343 if (pAdapter->StaCfg.BssType == BSS_INFRA)
6345 if ((strcmp(arg, "Max_PSP") == 0) ||
6346 (strcmp(arg, "max_psp") == 0) ||
6347 (strcmp(arg, "MAX_PSP") == 0))
6349 // do NOT turn on PSM bit here, wait until MlmeCheckForPsmChange()
6350 // to exclude certain situations.
6351 if (pAdapter->StaCfg.bWindowsACCAMEnable == FALSE)
6352 pAdapter->StaCfg.WindowsPowerMode = Ndis802_11PowerModeMAX_PSP;
6353 pAdapter->StaCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeMAX_PSP;
6354 OPSTATUS_SET_FLAG(pAdapter, fOP_STATUS_RECEIVE_DTIM);
6355 pAdapter->StaCfg.DefaultListenCount = 5;
6358 else if ((strcmp(arg, "Fast_PSP") == 0) ||
6359 (strcmp(arg, "fast_psp") == 0) ||
6360 (strcmp(arg, "FAST_PSP") == 0))
6362 // do NOT turn on PSM bit here, wait until MlmeCheckForPsmChange()
6363 // to exclude certain situations.
6364 OPSTATUS_SET_FLAG(pAdapter, fOP_STATUS_RECEIVE_DTIM);
6365 if (pAdapter->StaCfg.bWindowsACCAMEnable == FALSE)
6366 pAdapter->StaCfg.WindowsPowerMode = Ndis802_11PowerModeFast_PSP;
6367 pAdapter->StaCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeFast_PSP;
6368 pAdapter->StaCfg.DefaultListenCount = 3;
6370 else if ((strcmp(arg, "Legacy_PSP") == 0) ||
6371 (strcmp(arg, "legacy_psp") == 0) ||
6372 (strcmp(arg, "LEGACY_PSP") == 0))
6374 // do NOT turn on PSM bit here, wait until MlmeCheckForPsmChange()
6375 // to exclude certain situations.
6376 OPSTATUS_SET_FLAG(pAdapter, fOP_STATUS_RECEIVE_DTIM);
6377 if (pAdapter->StaCfg.bWindowsACCAMEnable == FALSE)
6378 pAdapter->StaCfg.WindowsPowerMode = Ndis802_11PowerModeLegacy_PSP;
6379 pAdapter->StaCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeLegacy_PSP;
6380 pAdapter->StaCfg.DefaultListenCount = 3;
6384 //Default Ndis802_11PowerModeCAM
6385 // clear PSM bit immediately
6386 MlmeSetPsmBit(pAdapter, PWR_ACTIVE);
6387 OPSTATUS_SET_FLAG(pAdapter, fOP_STATUS_RECEIVE_DTIM);
6388 if (pAdapter->StaCfg.bWindowsACCAMEnable == FALSE)
6389 pAdapter->StaCfg.WindowsPowerMode = Ndis802_11PowerModeCAM;
6390 pAdapter->StaCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeCAM;
6393 DBGPRINT(RT_DEBUG_TRACE, ("Set_PSMode_Proc::(PSMode=%ld)\n", pAdapter->StaCfg.WindowsPowerMode));
6402 #ifdef WPA_SUPPLICANT_SUPPORT
6404 ==========================================================================
6406 Set WpaSupport flag.
6408 0: Driver ignore wpa_supplicant.
6409 1: wpa_supplicant initiates scanning and AP selection.
6410 2: driver takes care of scanning, AP selection, and IEEE 802.11 association parameters.
6412 TRUE if all parameters are OK, FALSE otherwise
6413 ==========================================================================
6415 INT Set_Wpa_Support(
6416 IN PRTMP_ADAPTER pAd,
6420 if ( simple_strtol(arg, 0, 10) == 0)
6421 pAd->StaCfg.WpaSupplicantUP = WPA_SUPPLICANT_DISABLE;
6422 else if ( simple_strtol(arg, 0, 10) == 1)
6423 pAd->StaCfg.WpaSupplicantUP = WPA_SUPPLICANT_ENABLE;
6424 else if ( simple_strtol(arg, 0, 10) == 2)
6425 pAd->StaCfg.WpaSupplicantUP = WPA_SUPPLICANT_ENABLE_WITH_WEB_UI;
6427 pAd->StaCfg.WpaSupplicantUP = WPA_SUPPLICANT_DISABLE;
6429 DBGPRINT(RT_DEBUG_TRACE, ("Set_Wpa_Support::(WpaSupplicantUP=%d)\n", pAd->StaCfg.WpaSupplicantUP));
6433 #endif // WPA_SUPPLICANT_SUPPORT //
6437 ==========================================================================
6441 pAdapter Pointer to our adapter
6442 wrq Pointer to the ioctl argument
6449 1.) iwpriv ra0 mac 0 ==> read MAC where Addr=0x0
6450 2.) iwpriv ra0 mac 0=12 ==> write MAC where Addr=0x0, value=12
6451 ==========================================================================
6454 IN PRTMP_ADAPTER pAdapter,
6455 IN struct iwreq *wrq)
6463 UCHAR temp[16], temp2[16];
6464 UINT32 macValue = 0;
6468 memset(msg, 0x00, 1024);
6469 if (wrq->u.data.length > 1) //No parameters.
6471 Status = copy_from_user(arg, wrq->u.data.pointer, (wrq->u.data.length > 255) ? 255 : wrq->u.data.length);
6474 //Parsing Read or Write
6479 if ((value = rtstrchr(this_char, '=')) != NULL)
6482 if (!value || !*value)
6485 if(strlen(this_char) > 4)
6488 j = strlen(this_char);
6491 if(this_char[j] > 'f' || this_char[j] < '0')
6496 k = j = strlen(this_char);
6499 this_char[4-k+j] = this_char[j];
6503 this_char[3-k++]='0';
6506 if(strlen(this_char) == 4)
6508 AtoH(this_char, temp, 2);
6509 macAddr = *temp*256 + temp[1];
6510 if (macAddr < 0xFFFF)
6512 RTMP_IO_READ32(pAdapter, macAddr, &macValue);
6513 DBGPRINT(RT_DEBUG_TRACE, ("MacAddr=%lx, MacValue=%x\n", macAddr, macValue));
6514 sprintf(msg+strlen(msg), "[0x%08lX]:%08X ", macAddr , macValue);
6517 {//Invalid parametes, so default printk all bbp
6524 memcpy(&temp2, value, strlen(value));
6525 temp2[strlen(value)] = '\0';
6528 if((strlen(this_char) > 4) || strlen(temp2) > 8)
6531 j = strlen(this_char);
6534 if(this_char[j] > 'f' || this_char[j] < '0')
6541 if(temp2[j] > 'f' || temp2[j] < '0')
6546 k = j = strlen(this_char);
6549 this_char[4-k+j] = this_char[j];
6553 this_char[3-k++]='0';
6557 k = j = strlen(temp2);
6560 temp2[8-k+j] = temp2[j];
6568 AtoH(this_char, temp, 2);
6569 macAddr = *temp*256 + temp[1];
6571 AtoH(temp2, temp, 4);
6572 macValue = *temp*256*256*256 + temp[1]*256*256 + temp[2]*256 + temp[3];
6575 if (macAddr == (HW_DEBUG_SETTING_BASE + 4))
6577 // 0x2bf4: byte0 non-zero: enable R17 tuning, 0: disable R17 tuning
6578 if (macValue & 0x000000ff)
6580 pAdapter->BbpTuning.bEnable = TRUE;
6581 DBGPRINT(RT_DEBUG_TRACE,("turn on R17 tuning\n"));
6586 pAdapter->BbpTuning.bEnable = FALSE;
6587 R66 = 0x26 + GET_LNA_GAIN(pAdapter);
6588 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R66, (0x26 + GET_LNA_GAIN(pAdapter)));
6589 DBGPRINT(RT_DEBUG_TRACE,("turn off R17 tuning, restore to 0x%02x\n", R66));
6594 DBGPRINT(RT_DEBUG_TRACE, ("MacAddr=%02lx, MacValue=0x%x\n", macAddr, macValue));
6596 RTMP_IO_WRITE32(pAdapter, macAddr, macValue);
6597 sprintf(msg+strlen(msg), "[0x%08lX]:%08X ", macAddr, macValue);
6602 if(strlen(msg) == 1)
6603 sprintf(msg+strlen(msg), "===>Error command format!");
6605 // Copy the information into the user buffer
6606 wrq->u.data.length = strlen(msg);
6607 Status = copy_to_user(wrq->u.data.pointer, msg, wrq->u.data.length);
6609 DBGPRINT(RT_DEBUG_TRACE, ("<==RTMPIoctlMAC\n\n"));
6613 ==========================================================================
6617 pAdapter Pointer to our adapter
6618 wrq Pointer to the ioctl argument
6625 1.) iwpriv ra0 e2p 0 ==> read E2PROM where Addr=0x0
6626 2.) iwpriv ra0 e2p 0=1234 ==> write E2PROM where Addr=0x0, value=1234
6627 ==========================================================================
6629 VOID RTMPIoctlE2PROM(
6630 IN PRTMP_ADAPTER pAdapter,
6631 IN struct iwreq *wrq)
6639 UCHAR temp[16], temp2[16];
6644 memset(msg, 0x00, 1024);
6645 if (wrq->u.data.length > 1) //No parameters.
6647 Status = copy_from_user(arg, wrq->u.data.pointer, (wrq->u.data.length > 255) ? 255 : wrq->u.data.length);
6650 //Parsing Read or Write
6657 if ((value = rtstrchr(this_char, '=')) != NULL)
6660 if (!value || !*value)
6664 if(strlen(this_char) > 4)
6667 j = strlen(this_char);
6670 if(this_char[j] > 'f' || this_char[j] < '0')
6675 k = j = strlen(this_char);
6678 this_char[4-k+j] = this_char[j];
6682 this_char[3-k++]='0';
6685 if(strlen(this_char) == 4)
6687 AtoH(this_char, temp, 2);
6688 eepAddr = *temp*256 + temp[1];
6689 if (eepAddr < 0xFFFF)
6691 RT28xx_EEPROM_READ16(pAdapter, eepAddr, eepValue);
6692 sprintf(msg+strlen(msg), "[0x%04X]:0x%04X ", eepAddr , eepValue);
6695 {//Invalid parametes, so default printk all bbp
6702 memcpy(&temp2, value, strlen(value));
6703 temp2[strlen(value)] = '\0';
6706 if((strlen(this_char) > 4) || strlen(temp2) > 8)
6709 j = strlen(this_char);
6712 if(this_char[j] > 'f' || this_char[j] < '0')
6718 if(temp2[j] > 'f' || temp2[j] < '0')
6723 k = j = strlen(this_char);
6726 this_char[4-k+j] = this_char[j];
6730 this_char[3-k++]='0';
6734 k = j = strlen(temp2);
6737 temp2[4-k+j] = temp2[j];
6744 AtoH(this_char, temp, 2);
6745 eepAddr = *temp*256 + temp[1];
6747 AtoH(temp2, temp, 2);
6748 eepValue = *temp*256 + temp[1];
6750 RT28xx_EEPROM_WRITE16(pAdapter, eepAddr, eepValue);
6751 sprintf(msg+strlen(msg), "[0x%02X]:%02X ", eepAddr, eepValue);
6755 if(strlen(msg) == 1)
6756 sprintf(msg+strlen(msg), "===>Error command format!");
6759 // Copy the information into the user buffer
6760 wrq->u.data.length = strlen(msg);
6761 Status = copy_to_user(wrq->u.data.pointer, msg, wrq->u.data.length);
6763 DBGPRINT(RT_DEBUG_TRACE, ("<==RTMPIoctlE2PROM\n"));
6770 INT Set_TGnWifiTest_Proc(
6771 IN PRTMP_ADAPTER pAd,
6774 if (simple_strtol(arg, 0, 10) == 0)
6775 pAd->StaCfg.bTGnWifiTest = FALSE;
6777 pAd->StaCfg.bTGnWifiTest = TRUE;
6779 DBGPRINT(RT_DEBUG_TRACE, ("IF Set_TGnWifiTest_Proc::(bTGnWifiTest=%d)\n", pAd->StaCfg.bTGnWifiTest));
6783 INT Set_LongRetryLimit_Proc(
6784 IN PRTMP_ADAPTER pAdapter,
6787 TX_RTY_CFG_STRUC tx_rty_cfg;
6788 UCHAR LongRetryLimit = (UCHAR)simple_strtol(arg, 0, 10);
6790 RTMP_IO_READ32(pAdapter, TX_RTY_CFG, &tx_rty_cfg.word);
6791 tx_rty_cfg.field.LongRtyLimit = LongRetryLimit;
6792 RTMP_IO_WRITE32(pAdapter, TX_RTY_CFG, tx_rty_cfg.word);
6793 DBGPRINT(RT_DEBUG_TRACE, ("IF Set_LongRetryLimit_Proc::(tx_rty_cfg=0x%x)\n", tx_rty_cfg.word));
6797 INT Set_ShortRetryLimit_Proc(
6798 IN PRTMP_ADAPTER pAdapter,
6801 TX_RTY_CFG_STRUC tx_rty_cfg;
6802 UCHAR ShortRetryLimit = (UCHAR)simple_strtol(arg, 0, 10);
6804 RTMP_IO_READ32(pAdapter, TX_RTY_CFG, &tx_rty_cfg.word);
6805 tx_rty_cfg.field.ShortRtyLimit = ShortRetryLimit;
6806 RTMP_IO_WRITE32(pAdapter, TX_RTY_CFG, tx_rty_cfg.word);
6807 DBGPRINT(RT_DEBUG_TRACE, ("IF Set_ShortRetryLimit_Proc::(tx_rty_cfg=0x%x)\n", tx_rty_cfg.word));
6811 #ifdef EXT_BUILD_CHANNEL_LIST
6812 INT Set_Ieee80211dClientMode_Proc(
6813 IN PRTMP_ADAPTER pAdapter,
6816 if (simple_strtol(arg, 0, 10) == 0)
6817 pAdapter->StaCfg.IEEE80211dClientMode = Rt802_11_D_None;
6818 else if (simple_strtol(arg, 0, 10) == 1)
6819 pAdapter->StaCfg.IEEE80211dClientMode = Rt802_11_D_Flexible;
6820 else if (simple_strtol(arg, 0, 10) == 2)
6821 pAdapter->StaCfg.IEEE80211dClientMode = Rt802_11_D_Strict;
6825 DBGPRINT(RT_DEBUG_TRACE, ("Set_Ieee802dMode_Proc::(IEEEE0211dMode=%d)\n", pAdapter->StaCfg.IEEE80211dClientMode));
6828 #endif // EXT_BUILD_CHANNEL_LIST //
6830 #ifdef CARRIER_DETECTION_SUPPORT
6831 INT Set_CarrierDetect_Proc(
6832 IN PRTMP_ADAPTER pAd,
6835 if (simple_strtol(arg, 0, 10) == 0)
6836 pAd->CommonCfg.CarrierDetect.Enable = FALSE;
6838 pAd->CommonCfg.CarrierDetect.Enable = TRUE;
6840 DBGPRINT(RT_DEBUG_TRACE, ("IF Set_CarrierDetect_Proc::(CarrierDetect.Enable=%d)\n", pAd->CommonCfg.CarrierDetect.Enable));
6843 #endif // CARRIER_DETECTION_SUPPORT //